Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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.nario
    

    It 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 legacy nix-store --export and nix-store --import commands. It should be avoided because it is not memory-efficient on import. It does not support signatures, so you have to use --no-check-sigs on 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 import fails if they’re missing or have a different NAR hash.

  • For other paths, nix nario export looks 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 is by-name (the default), which selects a path with the same name (ignoring the version), e.g. hello-2.12.2 for hello-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 import reconstructs 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

  • --base installable

    Assume 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-method method

    How 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.

  • --compression method

    Compression method (e.g. zstd) to use for NARs that are not exported as binary diffs. The default is none. Requires nario format 2.

  • --compression-level level

    Compression level to use for the method specified by --compression. The default is 9 for zstd, and the compression method’s own default for other methods.

  • --default-flake-schemas flake-ref

    The URL of the flake providing default flake schema definitions.

  • --diff-algorithm algorithm

    Algorithm to use for computing binary diffs. Must be zstd (the default) or hdiffpatch. hdiffpatch is experimental.

  • --format nario-format

    Version of the nario format to use. Must be 1 or 2.

  • --stdin

    Read installables from the standard input. No default installable applied.

Common evaluation options

  • --arg name expr

    Pass the value expr as the argument name to Nix functions.

  • --arg-from-file name path

    Pass the contents of file path as the argument name to Nix functions.

  • --arg-from-stdin name

    Pass the contents of stdin as the argument name to Nix functions.

  • --argstr name string

    Pass the string string as the argument name to Nix functions.

  • --debugger

    Start an interactive environment if evaluation fails.

  • --eval-store store-url

    The URL of the Nix store to use for evaluation, i.e. to store derivations (.drv files) and inputs referenced by them.

  • --impure

    Allow access to mutable paths and repositories.

  • --include / -I path

    Add path to search path entries used to resolve lookup paths

    This option may be given multiple times.

    Paths added through -I take precedence over the nix-path configuration setting and the NIX_PATH environment variable.

  • --override-flake original-ref resolved-ref

    Override the flake registries, redirecting original-ref to resolved-ref.

  • --debug

    Set the logging verbosity level to ‘debug’.

  • --log-format format

    Set the format of log output; one of raw, internal-json, bar or bar-with-logs.

  • --print-build-logs / -L

    Print full build logs on standard error.

  • --quiet

    Decrease the logging verbosity level.

  • --verbose / -v

    Increase the logging verbosity level.

Miscellaneous global options

  • --help

    Show usage information.

  • --offline

    Disable substituters and consider all previously downloaded files up-to-date.

  • --option name value

    Set the Nix configuration setting name to value (overriding nix.conf).

  • --refresh

    Consider all previously downloaded files out-of-date.

  • --repair

    During evaluation, rewrite missing or corrupted files in the Nix store. During building, rebuild missing or corrupted store paths.

  • --version

    Show version information.

Options that change the interpretation of installables

  • --all

    Apply the operation to every store path.

  • --derivation

    Operate on the store derivation rather than its outputs.

  • --expr expr

    Interpret installables as attribute paths relative to the Nix expression expr.

  • --file / -f file

    Interpret 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 / -r

    Apply operation to closure of the specified paths.

Note

See man nix.conf for overriding configuration settings with command line flags.