nix-super/doc/manual/src/command-ref/nix-store/export.md
Valentin Gagarin 209d75529c
reword documentation on nix-store --export (#10713)
- add links to definitions of terms
- one sentence per line
- be more specific about which store is used for the import
- clearly distinguish store paths and store objects
- make a recommendation to use `nix-copy-closure` for efficient SSH transfers
2024-05-20 08:28:35 +02:00

1.9 KiB

Name

nix-store --export - export store paths to a Nix Archive

Synopsis

nix-store --export paths…

Description

The operation --export writes a serialisation of the given store objects to standard output in a format that can be imported into another Nix store with nix-store --import.

Warning

This command does not produce a closure of the specified store paths. Trying to import a store object that refers to store paths not available in the target Nix store will fail.

Use nix-store --query to obtain the closure of a store path.

This command is different from nix-store --dump, which produces a Nix archive that does not contain the set of references of a given store path.

Note

For efficient transfer of closures to remote machines over SSH, use nix-copy-closure.

{{#include ./opt-common.md}}

{{#include ../opt-common.md}}

{{#include ../env-common.md}}

Examples

Example

Deploy GNU Hello to an airgapped machine via USB stick.

Write the closure to the block device on a machine with internet connection:

[alice@itchy]$ storePath=$(nix-build '<nixpkgs>' -I nixpkgs=channel:nixpkgs-unstable -A hello --no-out-link)
[alice@itchy]$ nix-store --export $(nix-store --query --requisites $storePath) | sudo dd of=/dev/usb

Read the closure from the block device on the machine without internet connection:

[bob@scratchy]$ hello=$(sudo dd if=/dev/usb | nix-store --import | tail -1)
[bob@scratchy]$ $hello/bin/hello
Hello, world!