NIX-STORE-DUMP(1)
β¨ NAME β¨
nix-store --dump β write a single path to a Nix Archive. (Yes bestie, this is the manual page for nix-store --dump(1) from the General Commands Manual. π)
π SYNOPSIS π
nix-store --dump path
πΈ DESCRIPTION πΈ
okay so the --dump operation is giving archive-creator realness: it produces a Nix archive (NAR) file containing the contents of the file system tree rooted at path. The archive is written to standard output. π
A NAR archive is like a TAR or Zip archive, but it contains only the information that Nix considers important. For instance, timestamps are elided because all files in the Nix store have their timestamp set to 0 anyway. Likewise, all permissions are left out except for the execute bit, because all files in the Nix store have 444 or 555 permission.
Also, a NAR archive is canonical, meaning that βequalβ paths always produce the same NAR archive. For instance, directory entries are always sorted so that the actual on-disk order doesnβt influence the result. This means that the cryptographic hash of a NAR dump of a path is usable as a fingerprint of the contents of the path. Indeed, the hashes of store paths stored in Nixβs database (see nix-store --query --hash) are SHA-256 hashes of the NAR dump of each store path.
NAR archives support filenames of unlimited length and 64-bit file sizes. They can contain regular files, directories, and symbolic links, but not other types of files (such as device nodes). π¦
A Nix archive can be unpacked using nix-store --restore.
π OPTIONS π
The following options are allowed for all nix-store operations, but may not always have an effect.
--add-rootpath β causes the result of a realisation (--realiseand--force-realise) to be registered as a root of the garbage collector.pathwill be created as a symlink to the resulting store path. In addition, a uniquely named symlink topathwill be created in/nix/var/nix/gcroots/auto/. For instance,
$ nix-store --add-root /home/eelco/bla/result --realise ...
$ ls -l /nix/var/nix/gcroots/auto
lrwxrwxrwx 1 ... 2005-03-13 21:10 dn54lcypm8f8... -> /home/eelco/bla/result
$ ls -l /home/eelco/bla/result
lrwxrwxrwx 1 ... 2005-03-13 21:10 /home/eelco/bla/result -> /nix/store/1r11343n6qd4...-f-spot-0.0.10
Thus, when /home/eelco/bla/result is removed, the GC root in the auto directory becomes a dangling symlink and will be ignored by the collector.
Warning β note that it is not possible to move or rename GC roots, since the symlink in the auto directory will still point to the old location. π
If there are multiple results, then multiple symlinks will be created by sequentially numbering symlinks beyond the first one (e.g., foo, foo-2, foo-3, and so on).
π Common Options π
okay bestie, so basically most Nix commands are out here accepting these command-line options, and you're gonna wanna know all of them π
--helpβ prints out a lil summary of the command syntax and then dips. exits immediately, no cap.--versionβ prints the Nix version number on standard output and exits. iconic, brief, slays.--verbose/-vβ turns the volume UP on diagnostic messages printed on standard error π₯. lowkey important: for each Nix operation, the stuff printed on standard output is well-defined; any diagnostic info goes to standard error, and literally never to standard output. this option can be given over and over again (repeatable!). rn the verbosity levels are:- 0 βErrors onlyβ β only prints the messages explaining why your Nix invocation failed π
- 1 βInformationalβ β prints useful messages about what Nix is doing. this is the default β¨
- 2 βTalkativeβ β more informational messages
- 3 βChattyβ β even more informational messages
- 4 βDebugβ β prints debug info
- 5 βVomitβ β prints vast amounts of debug info π
--quietβ turns the volume DOWN on diagnostic messages printed on standard error. it's the exact inverse option to-v/--verbose. also repeatable, and it uses the same verbosity levels list as above π«Ά--log-format formatβ this one changes how the log output looks, where format is one of:rawβ the raw format, as outputted bynix-buildinternal-jsonβ outputs the logs in a structured manner
β οΈ Warning β while the schema itself is relatively stable, the format of the error-messages (namely of the msg-field) can change between releases. so like, don't get too attached π
barβ only displays a progress bar during the buildsbar-with-logsβ displays the raw logs, with the progress bar at the bottom π
--no-build-output/-Qβ by default, output written by builders to standard output and standard error gets echoed to the Nix command's standard error. this option suppresses that behaviour, so β¨ silence β¨. but note: the builder's standard output and error are always written to a log file inprefix/nix/var/log/nix, so nothing's actually lost bestie.--max-jobs/-jnumber β sets the max number of build jobs Nix will do in parallel to the number you give it. you can specifyautoto use the number of CPUs in the system. the default is specified by themax-jobsconfiguration setting, which itself defaults to1. a higher value is useful on SMP systems or to exploit I/O latency. setting it to0disallows building on the local machine β which is exactly what you want when you want builds to happen only on remote builders π°οΈ--coresβ sets the value of theNIX_BUILD_CORESenvironment variable in the invocation of builders. builders can use this variable at their discretion to control the max amount of parallelism. for instance, in Nixpkgs, if the derivation attributeenableParallelBuildingis set totrue, the builder passes the-jNflag to GNU Make. it defaults to the value of thecoresconfiguration setting, if set, or1otherwise. the value0means the builder should use all available CPU cores in the system π--max-silent-timeβ sets the max number of seconds a builder can go without producing any data on standard output or standard error. the default is specified by themax-silent-timeconfiguration setting.0means no time-out, i.e. it can stay silent forever, mood honestly π--timeoutβ sets the max number of seconds a builder can run. the default is specified by thetimeoutconfiguration setting.0means no timeout β°--keep-going/-kβ keep going when builds fail, to the greatest extent possible. so like, if building an input of some derivation fails, Nix will still build the other inputs β but not the derivation itself. without this option, Nix stops if any build fails (except for builds of substitutes), possibly killing builds in progress (in case of parallel or distributed builds) π--keep-failed/-Kβ says that in case of a build failure, the temporary directory (usually in/tmp) where the build takes place should not be deleted. the path of the build directory gets printed as an informational message so you can go snooping π--fallbackβ whenever Nix tries to build a derivation for which substitutes are known for each output path, but realising the output paths through those substitutes fails, it falls back on building the derivation itself. the most common scenario where this is useful is when we've registered substitutes to do binary distribution from, say, a network repository. if the repository is down, the realisation of the derivation will fail. specify this option and Nix will build the derivation instead. so installation from binaries falls back on installation from source π«‘. this option is not the default, since it's generally not desirable for a transient failure in obtaining the substitutes to lead to a full build from source (with the related consumption of resources).--readonly-modeβ with this one, no attempt is made to open the Nix database. most Nix operations do need database access, so those operations will fail. no cap, they just fail π«--argname value β accepted bynix-env,nix-instantiate,nix-shellandnix-build. when evaluating Nix expressions, the expression evaluator automatically tries to call functions that it encounters. it can automatically call functions for which every argument has a default value (e.g.,{ argName ? defaultValue }: ...).
with --arg, you can also call functions that have arguments without a default value (or override a default value). that is, if the evaluator encounters a function with an argument named name, it will call it with value value.
for instance, the top-level default.nix in Nixpkgs is actually a function:
{ # The system (e.g., `i686-linux') for which to build the packages.
system ? builtins.currentSystem
...
}: ...
so if you call this Nix expression (e.g., when you do nix-env --install --attr pkgname), the function will be called automatically using the value builtins.currentSystem for the system argument. you can override this using --arg, e.g., nix-env --install --attr pkgname --arg system \"i686-freebsd\". (note that since the argument is a Nix string literal, you have to escape the quotes.) β¨
--arg-from-filename path β passes the contents of file path as the argument name to Nix functions π--arg-from-stdinname β passes the contents of stdin as the argument name to Nix functions β¨οΈ--argstrname value β this is like--arg, only the value is not a Nix expression but a string. so instead of--arg system \"i686-linux\"(the outer quotes are to keep the shell happy) you can just say--argstr system i686-linux. way less escaping drama, obsessed π--attr/-AattrPath β selects an attribute from the top-level Nix expression being evaluated. (nix-env,nix-instantiate,nix-buildandnix-shellonly, bestie.) the attribute path attrPath is a sequence of attribute names separated by dots. for instance, given a top-level Nix expressione, the attribute pathxorg.xorgserverwould cause the expressione.xorg.xorgserverto be used. seenix-env --installfor some concrete examples.
in addition to attribute names, you can also specify array indices π’. for instance, the attribute path foo.3.bar selects the bar attribute of the fourth element of the array in the foo attribute of the top-level expression.
--eval-storestore-url β the URL to the Nix store to use for evaluation, i.e. where to store derivations (.drvfiles) and inputs referenced by them π¦--expr/-Eβ interprets the command line arguments as a list of Nix expressions to be parsed and evaluated, rather than as a list of file names of Nix expressions. (nix-instantiate,nix-buildandnix-shellonly.)
for nix-shell, this option is commonly used to give you a shell in which you can build the packages returned by the expression. if you want to get a shell which contains the built packages ready for use, give your expression to the nix-shell --packages convenience flag instead π
-I/--includepath β add an entry to the list of search paths 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 π--impureβ allow access to mutable paths and repositories. that's it, that's the whole vibe π¦--optionname value β set the Nix configuration option name to value. this overrides settings in the Nix configuration file (seenix.conf5) π§--repairβ fixes corrupted or missing store paths by redownloading or rebuilding them. heads up though: this is slow because it requires computing a cryptographic hash of the contents of every path in the closure of the build π. also note the warning undernix-store --repair-path.
π Note β see man nix.conf for overriding configuration settings with command line flags.
π Common Environment Variables π
Most Nix commands read these environment variables, bestie. Learn them, love them, and your shell will simply behave. β¨
βοΈ Configuration environment variables
These cuties decide how Nix loads its configuration. See the configuration file documentation for the full tea. π΅
NIX_CONF_DIRβ overrides the system configuration directory. πNIX_USER_CONF_FILESβ overrides the user configuration file locations. πNIX_CONFIGβ provides configuration settings inline, right there in the variable, no file needed. π
πͺ Store setting environment variables
NIX_IGNORE_SYMLINK_STOREβ okay so normally the Nix store directory (typically/nix/store) is not allowed to contain any symlink components. This is to prevent "impure" builds. Builders sometimes "canonicalise" paths by resolving all symlink components. So builds on different machines (with/nix/storeresolving to different locations) could yield different results. This is generally not a problem β except when builds are deployed to machines where/nix/storeresolves differently. If you are sure that you're not going to do that, you can setNIX_IGNORE_SYMLINK_STOREto1.
Heads up bestie: if you're symlinking the Nix store so you can put it on another file system than the root file system, on Linux you're better off using bind mount points, e.g. π«Ά
$ mkdir /nix
$ mount -o bind /mnt/otherdisk/nix /nix
Consult the mount 8 manual page for the details. β¨
NIX_STORE_DIRβ overrides the location of the Nix store. On Unix, the default is/nix/store, set at compile time by thelibstore:store-dirbuild option. On Windows, there is no compile-time setting; the default is%PROGRAMDATA%\nix\store, determined at runtime using the%PROGRAMDATA%Known Folder. πͺ
See the Store Types chapter β each store has a store setting linking back to this as its default. π
NIX_LOG_DIRβ overrides the location of the Nix log directory. On Unix, the default is/nix/var/log/nix, set at compile time by thelog-dirbuild option. On Windows, there is no compile-time setting; the default is%PROGRAMDATA%\nix\log, determined at runtime using the%PROGRAMDATA%Known Folder. π
The Local Store, Local Daemon Store, and Experimental SSH Store with filesystem mounted have per-store settings that override this. π
NIX_STATE_DIRβ overrides the location of the Nix state directory. On Unix, the default is${localstatedir}/nix, wherelocalstatediris a compile-time build option defaulting to/nix/var. On Windows, there is no compile-time setting; the default is%PROGRAMDATA%\nix\state, determined at runtime using the%PROGRAMDATA%Known Folder. ποΈ
The Local Store, Local Daemon Store, and Experimental SSH Store with filesystem mounted have per-store settings that override this. π
NIX_DAEMON_SOCKET_PATHβ overrides the path to the Unix domain socket used to communicate with the Nix daemon. Defaults todaemon-socket/socketwithin the state directory (seeNIX_STATE_DIR). π
See the Local Daemon Store documentation for the details on how the socket path is resolved. iykyk. πΈ
TMPDIRβ use the specified directory to store temporary files. In particular, this includes temporary build directories; these can take up substantial amounts of disk space. The default is/tmp. βNIX_REMOTEβ overrides the store setting. Periodt. β¨
π§ Nix language evaluator settings
NIX_SHOW_STATSβ if set to1, Nix will print some evaluation statistics, such as the number of values allocated. πNIX_COUNT_CALLSβ if set to1, Nix will print how often functions were called during Nix expression evaluation. This is useful for profiling your Nix expressions. πGC_INITIAL_HEAP_SIZEβ if Nix has been configured to use the Boehm garbage collector, this variable sets the initial size of the heap in bytes. It defaults to384 MiB. Setting it to a low value reduces memory consumption, but will increase runtime due to the overhead of garbage collection. ποΈNIX_PATHβ a colon-separated list of search path entries used to resolve lookup paths. π§
This environment variable overrides the value of the nix-path configuration setting.
It can be extended using the -I option.
Example β¨
$ export NIX_PATH=/home/eelco/Dev:nixos-config=/etc/nixos
If NIX_PATH is set to an empty string, resolving search paths will always fail. π
Example π
$ NIX_PATH= nix-instantiate --eval '<nixpkgs>'
error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)
π User Directories π¦
Nix supports per-user configuration, state, and cache directories. These environment variables override the locations for those directories: π
- the user configuration directory (
#user-conf-dir):NIX_CONFIG_HOME(#env-NIXCONFIGHOME) - the user state directory:
NIX_STATE_HOME(#env-NIXSTATEHOME) - the user cache directory:
NIX_CACHE_HOME(#env-NIXCACHEHOME)
When these are not set, the defaults depend on the platform: π
- On Unix, the XDG base directories:
$XDG_CONFIG_HOME/nix,$XDG_STATE_HOME/nix,$XDG_CACHE_HOME/nix - On Windows, the Windows Known Folders:
%APPDATA%\nix\config,%LOCALAPPDATA%\nix\state,%LOCALAPPDATA%\nix\cache
For backwards compatibility, legacy Nix commands (e.g. nix-env, nix-channel) use dotfiles in $HOME instead of these directories unless use-xdg-base-directories is enabled. New Nix commands (experimental) use the proper directories by default. π
When use-xdg-base-directories is enabled, the configuration directory is resolved as:
$NIX_CONFIG_HOME, if it is defined- Otherwise, the platform default (e.g.
$XDG_CONFIG_HOME/nixon Unix)
Likewise for the state and cache directories. π
π² Miscellaneous environment variables
IN_NIX_SHELLβ an indicator that tells if the current environment was set up bynix-shell. It can have the valuespureorimpure. π«§
π Appendix: OS-specific conventions π
This information is not Nix-specific, but is referenced above. No cap. π
π§ Unix: XDG Base Directories
The XDG Base Directory Specification defines standard locations for user-specific configuration, state, and cache files on Unix systems.
The following environment variables are used:
XDG_CONFIG_HOME(#env-XDGCONFIGHOME) (default~/.config)XDG_STATE_HOME(#env-XDGSTATEHOME) (default~/.local/state)XDG_CACHE_HOME(#env-XDGCACHEHOME) (default~/.cache)XDG_CONFIG_DIRS(#env-XDGCONFIGDIRS) (default/etc/xdg) β colon-separated list of additional configuration base directories, searched afterXDG_CONFIG_HOME
πͺ Windows: Known Folders
On Windows, Known Folders provide standard locations for application data on Windows.
The relevant folders are:
%APPDATA%(#env-APPDATA) β per-user roaming application data%LOCALAPPDATA%(#env-LOCALAPPDATA) β per-user local application data%PROGRAMDATA%(#env-PROGRAMDATA) β system-wide application data
and that's the whole page bestie!! π this was the nix-store --dump(1) manual, straight from the source β go read the manual page yourself if you want the exact version and date stamps, because this diva is signing off. stay pure, stay impure, stay iconic. periodt. π
β¨π
π¦ where this page comes from
- fedora 44: nix-legacy 2.35.3-2.fc44 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms