Name
nix nario export - serialize store paths to standard output in nario format
Synopsis
nix nario export [option…] installables…
Examples
-
Export the closure of the build of
nixpkgs#hello:# nix nario export --format 2 -r nixpkgs#hello > dump.narioIt can be imported into another store:
# nix nario import --no-check-sigs < dump.nario -
Export the closure of a new version of
hello, assuming that the destination already has the closure of an old version:# nix nario export --format 2 -r /nix/store/6i6xl6bmcpxqd51m8nlva40d5c1bhndx-hello-2.12.3 \ --base /nix/store/nm7p8wxflggcwxfzayhysq4z6a1wg373-hello-2.12.3 > update.nario
Description
This command prints to standard output a serialization of the specified store paths in nario format. This serialization can be imported into another store using nix nario import.
References of a path are not exported by default; use -r to export a complete closure.
Paths are exported in topologically sorted order (i.e. if path X refers to Y, then Y appears before X).
You must specify the desired nario version. Currently the following versions are supported:
-
1: This version is compatible with the legacynix-store --exportandnix-store --importcommands. It should be avoided because it is not memory-efficient on import. It does not support signatures, so you have to use--no-check-sigson import. -
2: The latest version. Recommended.
Binary diffs
The --base flag specifies one or more installables whose closure (the base closure) is assumed to be present in the store into which the nario will be imported. This can greatly reduce the size of the nario when deploying an update to a closure:
-
Paths that are in the base closure are not included in the nario. Instead, the nario records that they’re expected to be present, and
nix nario importfails if they’re missing or have a different NAR hash. -
For other paths,
nix nario exportlooks for a suitable path in the base closure. How this path is selected is determined by the flag--base-selection-method. Currently, the only method isby-name(the default), which selects a path with the same name (ignoring the version), e.g.hello-2.12.2forhello-2.12.3. If a suitable path exists, the path is stored as a binary diff against the NAR of that base path, provided that the diff is sufficiently small.nix nario importreconstructs the path by applying the diff to the base path, after verifying that the base path has the expected NAR hash.
The flag --diff-algorithm determines how binary diffs are computed:
-
zstd(the default): The NAR is compressed using zstd, with the NAR of the base path as a dictionary. -
hdiffpatch: The diff is computed using HDiffPatch and compressed using zstd. This is experimental.
Binary diffs require nario format 2. Narios that contain binary diffs cannot be imported by versions of Nix that don’t support them.
Compression
By default, the NARs in a nario are not compressed. The --compression flag specifies a compression method (such as zstd or xz) for NARs that are not exported as binary diffs. (Binary diffs are always compressed.) This is preferable to compressing the nario as a whole, since compressing binary diffs a second time is a waste of time. For example:
# nix nario export --format 2 --compression zstd -r /nix/store/6i6xl6bmcpxqd51m8nlva40d5c1bhndx-hello-2.12.3 > hello.nario
The --compression-level flag specifies the compression level. For zstd, the default is 9, which is still fast but compresses significantly better than zstd’s own default of 3.
Compression requires nario format 2. Narios that contain compressed NARs cannot be imported by versions of Nix that don’t support them.
Options
-
--baseinstallableAssume that the closure of installable is already present at the destination. Paths in this closure are not exported, and other paths are exported as binary diffs against paths in this closure where possible. Can be specified multiple times.
-
--base-selection-methodmethodHow to select the path in the base closure against which to diff a path. Currently the only method is
by-name(select a path with the same name, ignoring the version), which is the default. -
--compressionmethodCompression method (e.g.
zstd) to use for NARs that are not exported as binary diffs. The default isnone. Requires nario format 2. -
--compression-levellevelCompression level to use for the method specified by
--compression. The default is 9 forzstd, and the compression method’s own default for other methods. -
--default-flake-schemasflake-refThe URL of the flake providing default flake schema definitions.
-
--diff-algorithmalgorithmAlgorithm to use for computing binary diffs. Must be
zstd(the default) orhdiffpatch.hdiffpatchis experimental. -
--formatnario-formatVersion of the nario format to use. Must be
1or2. -
Read installables from the standard input. No default installable applied.
Common evaluation options
-
--argname exprPass the value expr as the argument name to Nix functions.
-
--arg-from-filename pathPass the contents of file path as the argument name to Nix functions.
-
--arg-from-stdinnamePass the contents of stdin as the argument name to Nix functions.
-
--argstrname stringPass the string string as the argument name to Nix functions.
-
Start an interactive environment if evaluation fails.
-
--eval-storestore-urlThe URL of the Nix store to use for evaluation, i.e. to store derivations (
.drvfiles) and inputs referenced by them. -
Allow access to mutable paths and repositories.
-
--include/-IpathAdd path to search path entries used to resolve lookup paths
This option may be given multiple times.
Paths added through
-Itake precedence over thenix-pathconfiguration setting and theNIX_PATHenvironment variable. -
--override-flakeoriginal-ref resolved-refOverride the flake registries, redirecting original-ref to resolved-ref.
Common flake-related options
-
Commit changes to the flake’s lock file.
-
--inputs-fromflake-urlUse the inputs of the specified flake as registry entries.
-
Don’t allow lookups in the flake registries.
DEPRECATED
Use
--no-use-registriesinstead. -
Do not allow any updates to the flake’s lock file.
-
Do not write the flake’s newly generated lock file.
-
--output-lock-fileflake-lock-pathWrite the given lock file instead of
flake.lockwithin the top-level flake. -
--override-inputinput-path flake-urlOverride a specific flake input (e.g.
dwarffs/nixpkgs). The input path must not be empty. This implies--no-write-lock-file. -
Recreate the flake’s lock file from scratch.
DEPRECATED
Use
nix flake updateinstead. -
--reference-lock-fileflake-lock-pathRead the given lock file instead of
flake.lockwithin the top-level flake. -
--update-inputinput-pathUpdate a specific flake input (ignoring its previous entry in the lock file).
DEPRECATED
Use
nix flake updateinstead.
Logging-related options
-
Set the logging verbosity level to ‘debug’.
-
--log-formatformatSet the format of log output; one of
raw,internal-json,barorbar-with-logs. -
--print-build-logs/-LPrint full build logs on standard error.
-
Decrease the logging verbosity level.
-
--verbose/-vIncrease the logging verbosity level.
Miscellaneous global options
-
Show usage information.
-
Disable substituters and consider all previously downloaded files up-to-date.
-
--optionname valueSet the Nix configuration setting name to value (overriding
nix.conf). -
Consider all previously downloaded files out-of-date.
-
During evaluation, rewrite missing or corrupted files in the Nix store. During building, rebuild missing or corrupted store paths.
-
Show version information.
Options that change the interpretation of installables
-
Apply the operation to every store path.
-
Operate on the store derivation rather than its outputs.
-
--exprexprInterpret installables as attribute paths relative to the Nix expression expr.
-
--file/-ffileInterpret installables as attribute paths relative to the Nix expression stored in file. If file is the character -, then a Nix expression is read from standard input. Implies
--impure. -
--recursive/-rApply operation to closure of the specified paths.
Note
See
man nix.conffor overriding configuration settings with command line flags.