.\" -*- mode: troff; coding: utf-8 -*- .TH "nix-store" "1" "" .SH Name \fCnix-store\fR - manipulate or query the Nix store .SH Synopsis \fCnix-store\fR \fIoperation\fR [\fIoptions…\fR] [\fIarguments…\fR] [\fC--option\fR \fIname\fR \fIvalue\fR] [\fC--add-root\fR \fIpath\fR] .SH Description The command \fCnix-store\fR performs primitive operations on the Nix store. You generally do not need to run this command manually. .PP \fCnix-store\fR takes exactly one \fIoperation\fR flag which indicates the subcommand to be performed. These are documented below. .SH Common options This section lists the options that are common to all operations. These options are allowed for every subcommand, though they may not always have an effect. .IP "\(bu" 2 \fC--add-root\fR \fIpath\fR .br Causes the result of a realisation (\fC--realise\fR and \fC--force-realise\fR) to be registered as a root of the garbage collector. \fIpath\fR will be created as a symlink to the resulting store path. In addition, a uniquely named symlink to \fIpath\fR will be created in \fC/nix/var/nix/gcroots/auto/\fR. For instance, .LP .EX $ nix-store --add-root /home/eelco/bla/result -r ... $ 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 .EE .IP Thus, when \fC/home/eelco/bla/result\fR is removed, the GC root in the \fCauto\fR directory becomes a dangling symlink and will be ignored by the collector. .RS .IP \fBWarning\fR .IP Note that it is not possible to move or rename GC roots, since the symlink in the \fCauto\fR directory will still point to the old location. .RE .IP If there are multiple results, then multiple symlinks will be created by sequentially numbering symlinks beyond the first one (e.g., \fCfoo\fR, \fCfoo-2\fR, \fCfoo-3\fR, and so on). .SH Operation \fC--realise\fR .SS Synopsis \fCnix-store\fR {\fC--realise\fR | \fC-r\fR} \fIpaths…\fR [\fC--dry-run\fR] .SS Description The operation \fC--realise\fR essentially “builds” the specified store paths. Realisation is a somewhat overloaded term: .IP "\(bu" 2 If the store path is a \fIderivation\fR, realisation ensures that the output paths of the derivation are \fBvalid\fR (\fI../glossary.md\fR) (i.e., the output path and its closure exist in the file system). This can be done in several ways. First, it is possible that the outputs are already valid, in which case we are done immediately. Otherwise, there may be \fBsubstitutes\fR (\fI../glossary.md\fR) that produce the outputs (e.g., by downloading them). Finally, the outputs can be produced by performing the build action described by the derivation. .IP "\(bu" 2 If the store path is not a derivation, realisation ensures that the specified path is valid (i.e., it and its closure exist in the file system). If the path is already valid, we are done immediately. Otherwise, the path and any missing paths in its closure may be produced through substitutes. If there are no (successful) substitutes, realisation fails. .LP The output path of each derivation is printed on standard output. (For non-derivations argument, the argument itself is printed.) .PP The following flags are available: .IP "\(bu" 2 \fC--dry-run\fR .br Print on standard error a description of what packages would be built or downloaded, without actually performing the operation. .IP "\(bu" 2 \fC--ignore-unknown\fR .br If a non-derivation path does not have a substitute, then silently ignore it. .IP "\(bu" 2 \fC--check\fR .br This option allows you to check whether a derivation is deterministic. It rebuilds the specified derivation and checks whether the result is bitwise-identical with the existing outputs, printing an error if that’s not the case. The outputs of the specified derivation must already exist. When used with \fC-K\fR, if an output path is not identical to the corresponding output from the previous build, the new output path is left in \fC/nix/store/name.check.\fR .IP See also the \fCbuild-repeat\fR configuration option, which repeats a derivation a number of times and prevents its outputs from being registered as “valid” in the Nix store unless they are identical. .LP Special exit codes: .IP "\(bu" 2 \fC100\fR .br Generic build failure, the builder process returned with a non-zero exit code. .IP "\(bu" 2 \fC101\fR .br Build timeout, the build was aborted because it did not complete within the specified \fCtimeout\fR. .IP "\(bu" 2 \fC102\fR .br Hash mismatch, the build output was rejected because it does not match the \fB\fCoutputHash\fR attribute of the derivation\fR (\fI../expressions/advanced-attributes.md\fR). .IP "\(bu" 2 \fC104\fR .br Not deterministic, the build succeeded in check mode but the resulting output is not binary reproducible. .LP With the \fC--keep-going\fR flag it\[u2019]s possible for multiple failures to occur, in this case the 1xx status codes are or combined using binary or. .LP .EX 1100100 \(ha\(ha\(ha\(ha |||\(ga- timeout ||\(ga-- output hash mismatch |\(ga--- build failure \(ga---- not deterministic .EE .SS Examples This operation is typically used to build store derivations produced by \fB\fCnix-instantiate\fR\fR (\fInix-instantiate.md\fR): .LP .EX $ nix-store -r $(nix-instantiate ./test.nix) /nix/store/31axcgrlbfsxzmfff1gyj1bf62hvkby2-aterm-2.3.1 .EE .PP This is essentially what \fB\fCnix-build\fR\fR (\fInix-build.md\fR) does. .PP To test whether a previously-built derivation is deterministic: .LP .EX $ nix-build '' -A hello --check -K .EE .SH Operation \fC--serve\fR .SS Synopsis \fCnix-store\fR \fC--serve\fR [\fC--write\fR] .SS Description The operation \fC--serve\fR provides access to the Nix store over stdin and stdout, and is intended to be used as a means of providing Nix store access to a restricted ssh user. .PP The following flags are available: .IP "\(bu" 2 \fC--write\fR .br Allow the connected client to request the realization of derivations. In effect, this can be used to make the host act as a remote builder. .SS Examples To turn a host into a build server, the \fCauthorized_keys\fR file can be used to provide build access to a given SSH public key: .LP .EX $ cat <>/root/.ssh/authorized_keys command=\(dqnice -n20 nix-store --serve --write\(dq ssh-rsa AAAAB3NzaC1yc2EAAAA... EOF .EE .SH Operation \fC--gc\fR .SS Synopsis \fCnix-store\fR \fC--gc\fR [\fC--print-roots\fR | \fC--print-live\fR | \fC--print-dead\fR] [\fC--max-freed\fR \fIbytes\fR] .SS Description Without additional flags, the operation \fC--gc\fR performs a garbage collection on the Nix store. That is, all paths in the Nix store not reachable via file system references from a set of “roots”, are deleted. .PP The following suboperations may be specified: .IP "\(bu" 2 \fC--print-roots\fR .br This operation prints on standard output the set of roots used by the garbage collector. .IP "\(bu" 2 \fC--print-live\fR .br This operation prints on standard output the set of “live” store paths, which are all the store paths reachable from the roots. Live paths should never be deleted, since that would break consistency — it would become possible that applications are installed that reference things that are no longer present in the store. .IP "\(bu" 2 \fC--print-dead\fR .br This operation prints out on standard output the set of “dead” store paths, which is just the opposite of the set of live paths: any path in the store that is not live (with respect to the roots) is dead. .LP By default, all unreachable paths are deleted. The following options control what gets deleted and in what order: .IP "\(bu" 2 \fC--max-freed\fR \fIbytes\fR .br Keep deleting paths until at least \fIbytes\fR bytes have been deleted, then stop. The argument \fIbytes\fR can be followed by the multiplicative suffix \fCK\fR, \fCM\fR, \fCG\fR or \fCT\fR, denoting KiB, MiB, GiB or TiB units. .LP The behaviour of the collector is also influenced by the \fCkeep-outputs\fR and \fCkeep-derivations\fR settings in the Nix configuration file. .PP By default, the collector prints the total number of freed bytes when it finishes (or when it is interrupted). With \fC--print-dead\fR, it prints the number of bytes that would be freed. .SS Examples To delete all unreachable paths, just do: .LP .EX $ nix-store --gc deleting \(ga/nix/store/kq82idx6g0nyzsp2s14gfsc38npai7lf-cairo-1.0.4.tar.gz.drv' \&... 8825586 bytes freed (8.42 MiB) .EE .PP To delete at least 100 MiBs of unreachable paths: .LP .EX $ nix-store --gc --max-freed $((100 * 1024 * 1024)) .EE .SH Operation \fC--delete\fR .SS Synopsis \fCnix-store\fR \fC--delete\fR [\fC--ignore-liveness\fR] \fIpaths…\fR .SS Description The operation \fC--delete\fR deletes the store paths \fIpaths\fR from the Nix store, but only if it is safe to do so; that is, when the path is not reachable from a root of the garbage collector. This means that you can only delete paths that would also be deleted by \fCnix-store --gc\fR. Thus, \fC--delete\fR is a more targeted version of \fC--gc\fR. .PP With the option \fC--ignore-liveness\fR, reachability from the roots is ignored. However, the path still won’t be deleted if there are other paths in the store that refer to it (i.e., depend on it). .SS Example .LP .EX $ nix-store --delete /nix/store/zq0h41l75vlb4z45kzgjjmsjxvcv1qk7-mesa-6.4 0 bytes freed (0.00 MiB) error: cannot delete path \(ga/nix/store/zq0h41l75vlb4z45kzgjjmsjxvcv1qk7-mesa-6.4' since it is still alive .EE .SH Operation \fC--query\fR .SS Synopsis \fCnix-store\fR {\fC--query\fR | \fC-q\fR} {\fC--outputs\fR | \fC--requisites\fR | \fC-R\fR | \fC--references\fR | \fC--referrers\fR | \fC--referrers-closure\fR | \fC--deriver\fR | \fC-d\fR | \fC--graph\fR | \fC--tree\fR | \fC--binding\fR \fIname\fR | \fC-b\fR \fIname\fR | \fC--hash\fR | \fC--size\fR | \fC--roots\fR} [\fC--use-output\fR] [\fC-u\fR] [\fC--force-realise\fR] [\fC-f\fR] \fIpaths…\fR .SS Description The operation \fC--query\fR displays various bits of information about the store paths . The queries are described below. At most one query can be specified. The default query is \fC--outputs\fR. .PP The paths \fIpaths\fR may also be symlinks from outside of the Nix store, to the Nix store. In that case, the query is applied to the target of the symlink. .SS Common query options .IP "\(bu" 2 \fC--use-output\fR; \fC-u\fR .br For each argument to the query that is a store derivation, apply the query to the output path of the derivation instead. .IP "\(bu" 2 \fC--force-realise\fR; \fC-f\fR .br Realise each argument to the query first (see \fB\fCnix-store --realise\fR\fR (\fI#operation---realise\fR)). .SS Queries .IP "\(bu" 2 \fC--outputs\fR .br Prints out the \fBoutput paths\fR (\fI../glossary.md\fR) of the store derivations \fIpaths\fR. These are the paths that will be produced when the derivation is built. .IP "\(bu" 2 \fC--requisites\fR; \fC-R\fR .br Prints out the \fBclosure\fR (\fI../glossary.md\fR) of the store path \fIpaths\fR. .IP This query has one option: .RS .IP "\(bu" 2 \fC--include-outputs\fR Also include the existing output paths of store derivations, and their closures. .RE .IP This query can be used to implement various kinds of deployment. A \fIsource deployment\fR is obtained by distributing the closure of a store derivation. A \fIbinary deployment\fR is obtained by distributing the closure of an output path. A \fIcache deployment\fR (combined source/binary deployment, including binaries of build-time-only dependencies) is obtained by distributing the closure of a store derivation and specifying the option \fC--include-outputs\fR. .IP "\(bu" 2 \fC--references\fR .br Prints the set of \fBreferences\fR (\fI../glossary.md\fR) of the store paths \fIpaths\fR, that is, their immediate dependencies. (For \fIall\fR dependencies, use \fC--requisites\fR.) .IP "\(bu" 2 \fC--referrers\fR .br Prints the set of \fIreferrers\fR of the store paths \fIpaths\fR, that is, the store paths currently existing in the Nix store that refer to one of \fIpaths\fR. Note that contrary to the references, the set of referrers is not constant; it can change as store paths are added or removed. .IP "\(bu" 2 \fC--referrers-closure\fR .br Prints the closure of the set of store paths \fIpaths\fR under the referrers relation; that is, all store paths that directly or indirectly refer to one of \fIpaths\fR. These are all the path currently in the Nix store that are dependent on \fIpaths\fR. .IP "\(bu" 2 \fC--deriver\fR; \fC-d\fR .br Prints the \fBderiver\fR (\fI../glossary.md\fR) of the store paths \fIpaths\fR. If the path has no deriver (e.g., if it is a source file), or if the deriver is not known (e.g., in the case of a binary-only deployment), the string \fCunknown-deriver\fR is printed. .IP "\(bu" 2 \fC--graph\fR .br Prints the references graph of the store paths \fIpaths\fR in the format of the \fCdot\fR tool of AT&T\[u2019]s \fBGraphviz package\fR (\fIhttp://www.graphviz.org/\fR). This can be used to visualise dependency graphs. To obtain a build-time dependency graph, apply this to a store derivation. To obtain a runtime dependency graph, apply it to an output path. .IP "\(bu" 2 \fC--tree\fR .br Prints the references graph of the store paths \fIpaths\fR as a nested ASCII tree. References are ordered by descending closure size; this tends to flatten the tree, making it more readable. The query only recurses into a store path when it is first encountered; this prevents a blowup of the tree representation of the graph. .IP "\(bu" 2 \fC--graphml\fR .br Prints the references graph of the store paths \fIpaths\fR in the \fBGraphML\fR (\fIhttp://graphml.graphdrawing.org/\fR) file format. This can be used to visualise dependency graphs. To obtain a build-time dependency graph, apply this to a store derivation. To obtain a runtime dependency graph, apply it to an output path. .IP "\(bu" 2 \fC--binding\fR \fIname\fR; \fC-b\fR \fIname\fR .br Prints the value of the attribute \fIname\fR (i.e., environment variable) of the store derivations \fIpaths\fR. It is an error for a derivation to not have the specified attribute. .IP "\(bu" 2 \fC--hash\fR .br Prints the SHA-256 hash of the contents of the store paths \fIpaths\fR (that is, the hash of the output of \fCnix-store --dump\fR on the given paths). Since the hash is stored in the Nix database, this is a fast operation. .IP "\(bu" 2 \fC--size\fR .br Prints the size in bytes of the contents of the store paths \fIpaths\fR — to be precise, the size of the output of \fCnix-store --dump\fR on the given paths. Note that the actual disk space required by the store paths may be higher, especially on filesystems with large cluster sizes. .IP "\(bu" 2 \fC--roots\fR .br Prints the garbage collector roots that point, directly or indirectly, at the store paths \fIpaths\fR. .SS Examples Print the closure (runtime dependencies) of the \fCsvn\fR program in the current user environment: .LP .EX $ nix-store -qR $(which svn) /nix/store/5mbglq5ldqld8sj57273aljwkfvj22mc-subversion-1.1.4 /nix/store/9lz9yc6zgmc0vlqmn2ipcpkjlmbi51vv-glibc-2.3.4 \&... .EE .PP Print the build-time dependencies of \fCsvn\fR: .LP .EX $ nix-store -qR $(nix-store -qd $(which svn)) /nix/store/02iizgn86m42q905rddvg4ja975bk2i4-grep-2.5.1.tar.bz2.drv /nix/store/07a2bzxmzwz5hp58nf03pahrv2ygwgs3-gcc-wrapper.sh /nix/store/0ma7c9wsbaxahwwl04gbw3fcd806ski4-glibc-2.3.4.drv \&... lots of other paths ... .EE .PP The difference with the previous example is that we ask the closure of the derivation (\fC-qd\fR), not the closure of the output path that contains \fCsvn\fR. .PP Show the build-time dependencies as a tree: .LP .EX $ nix-store -q --tree $(nix-store -qd $(which svn)) /nix/store/7i5082kfb6yjbqdbiwdhhza0am2xvh6c-subversion-1.1.4.drv +---/nix/store/d8afh10z72n8l1cr5w42366abiblgn54-builder.sh +---/nix/store/fmzxmpjx2lh849ph0l36snfj9zdibw67-bash-3.0.drv | +---/nix/store/570hmhmx3v57605cqg9yfvvyh0nnb8k8-bash | +---/nix/store/p3srsbd8dx44v2pg6nbnszab5mcwx03v-builder.sh \&... .EE .PP Show all paths that depend on the same OpenSSL library as \fCsvn\fR: .LP .EX $ nix-store -q --referrers $(nix-store -q --binding openssl $(nix-store -qd $(which svn))) /nix/store/23ny9l9wixx21632y2wi4p585qhva1q8-sylpheed-1.0.0 /nix/store/5mbglq5ldqld8sj57273aljwkfvj22mc-subversion-1.1.4 /nix/store/dpmvp969yhdqs7lm2r1a3gng7pyq6vy4-subversion-1.1.3 /nix/store/l51240xqsgg8a7yrbqdx1rfzyv6l26fx-lynx-2.8.5 .EE .PP Show all paths that directly or indirectly depend on the Glibc (C library) used by \fCsvn\fR: .LP .EX $ nix-store -q --referrers-closure $(ldd $(which svn) | grep /libc.so | awk '{print $3}') /nix/store/034a6h4vpz9kds5r6kzb9lhh81mscw43-libgnomeprintui-2.8.2 /nix/store/15l3yi0d45prm7a82pcrknxdh6nzmxza-gawk-3.1.4 \&... .EE .PP Note that \fCldd\fR is a command that prints out the dynamic libraries used by an ELF executable. .PP Make a picture of the runtime dependency graph of the current user environment: .LP .EX $ nix-store -q --graph \(ti/.nix-profile | dot -Tps > graph.ps $ gv graph.ps .EE .PP Show every garbage collector root that points to a store path that depends on \fCsvn\fR: .LP .EX $ nix-store -q --roots $(which svn) /nix/var/nix/profiles/default-81-link /nix/var/nix/profiles/default-82-link /nix/var/nix/profiles/per-user/eelco/profile-97-link .EE .SH Operation \fC--add\fR .SS Synopsis \fCnix-store\fR \fC--add\fR \fIpaths…\fR .SS Description The operation \fC--add\fR adds the specified paths to the Nix store. It prints the resulting paths in the Nix store on standard output. .SS Example .LP .EX $ nix-store --add ./foo.c /nix/store/m7lrha58ph6rcnv109yzx1nk1cj7k7zf-foo.c .EE .SH Operation \fC--add-fixed\fR .SS Synopsis \fCnix-store\fR \fC--add-fixed\fR [\fC--recursive\fR] \fIalgorithm\fR \fIpaths…\fR .SS Description The operation \fC--add-fixed\fR adds the specified paths to the Nix store. Unlike \fC--add\fR paths are registered using the specified hashing algorithm, resulting in the same output path as a fixed-output derivation. This can be used for sources that are not available from a public url or broke since the download expression was written. .PP This operation has the following options: .IP "\(bu" 2 \fC--recursive\fR .br Use recursive instead of flat hashing mode, used when adding directories to the store. .SS Example .LP .EX $ nix-store --add-fixed sha256 ./hello-2.10.tar.gz /nix/store/3x7dwzq014bblazs7kq20p9hyzz0qh8g-hello-2.10.tar.gz .EE .SH Operation \fC--verify\fR .SS Synopsis \fCnix-store\fR \fC--verify\fR [\fC--check-contents\fR] [\fC--repair\fR] .SS Description The operation \fC--verify\fR verifies the internal consistency of the Nix database, and the consistency between the Nix database and the Nix store. Any inconsistencies encountered are automatically repaired. Inconsistencies are generally the result of the Nix store or database being modified by non-Nix tools, or of bugs in Nix itself. .PP This operation has the following options: .IP "\(bu" 2 \fC--check-contents\fR .br Checks that the contents of every valid store path has not been altered by computing a SHA-256 hash of the contents and comparing it with the hash stored in the Nix database at build time. Paths that have been modified are printed out. For large stores, \fC--check-contents\fR is obviously quite slow. .IP "\(bu" 2 \fC--repair\fR .br If any valid path is missing from the store, or (if \fC--check-contents\fR is given) the contents of a valid path has been modified, then try to repair the path by redownloading it. See \fCnix-store --repair-path\fR for details. .SH Operation \fC--verify-path\fR .SS Synopsis \fCnix-store\fR \fC--verify-path\fR \fIpaths…\fR .SS Description The operation \fC--verify-path\fR compares the contents of the given store paths to their cryptographic hashes stored in Nix’s database. For every changed path, it prints a warning message. The exit status is 0 if no path has changed, and 1 otherwise. .SS Example To verify the integrity of the \fCsvn\fR command and all its dependencies: .LP .EX $ nix-store --verify-path $(nix-store -qR $(which svn)) .EE .SH Operation \fC--repair-path\fR .SS Synopsis \fCnix-store\fR \fC--repair-path\fR \fIpaths…\fR .SS Description The operation \fC--repair-path\fR attempts to “repair” the specified paths by redownloading them using the available substituters. If no substitutes are available, then repair is not possible. .RS .PP \fBWarning\fR .PP During repair, there is a very small time window during which the old path (if it exists) is moved out of the way and replaced with the new path. If repair is interrupted in between, then the system may be left in a broken state (e.g., if the path contains a critical system component like the GNU C Library). .RE .SS Example .LP .EX $ nix-store --verify-path /nix/store/dj7a81wsm1ijwwpkks3725661h3263p5-glibc-2.13 path \(ga/nix/store/dj7a81wsm1ijwwpkks3725661h3263p5-glibc-2.13' was modified! expected hash \(ga2db57715ae90b7e31ff1f2ecb8c12ec1cc43da920efcbe3b22763f36a1861588', got \(ga481c5aa5483ebc97c20457bb8bca24deea56550d3985cda0027f67fe54b808e4' $ nix-store --repair-path /nix/store/dj7a81wsm1ijwwpkks3725661h3263p5-glibc-2.13 fetching path \(ga/nix/store/d7a81wsm1ijwwpkks3725661h3263p5-glibc-2.13'... … .EE .SH Operation \fC--dump\fR .SS Synopsis \fCnix-store\fR \fC--dump\fR \fIpath\fR .SS Description The operation \fC--dump\fR produces a NAR (Nix ARchive) file containing the contents of the file system tree rooted at \fIpath\fR. The archive is written to standard output. .PP 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. .PP Also, a NAR archive is \fIcanonical\fR, 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 \fCnix-store -q --hash\fR) are SHA-256 hashes of the NAR dump of each store path. .PP 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). .PP A Nix archive can be unpacked using \fCnix-store --restore\fR. .SH Operation \fC--restore\fR .SS Synopsis \fCnix-store\fR \fC--restore\fR \fIpath\fR .SS Description The operation \fC--restore\fR unpacks a NAR archive to \fIpath\fR, which must not already exist. The archive is read from standard input. .SH Operation \fC--export\fR .SS Synopsis \fCnix-store\fR \fC--export\fR \fIpaths…\fR .SS Description The operation \fC--export\fR writes a serialisation of the specified store paths to standard output in a format that can be imported into another Nix store with \fCnix-store --import\fR. This is like \fCnix-store --dump\fR, except that the NAR archive produced by that command doesn’t contain the necessary meta-information to allow it to be imported into another Nix store (namely, the set of references of the path). .PP This command does not produce a \fIclosure\fR of the specified paths, so if a store path references other store paths that are missing in the target Nix store, the import will fail. To copy a whole closure, do something like: .LP .EX $ nix-store --export $(nix-store -qR paths) > out .EE .PP To import the whole closure again, run: .LP .EX $ nix-store --import < out .EE .SH Operation \fC--import\fR .SS Synopsis \fCnix-store\fR \fC--import\fR .SS Description The operation \fC--import\fR reads a serialisation of a set of store paths produced by \fCnix-store --export\fR from standard input and adds those store paths to the Nix store. Paths that already exist in the Nix store are ignored. If a path refers to another path that doesn’t exist in the Nix store, the import fails. .SH Operation \fC--optimise\fR .SS Synopsis \fCnix-store\fR \fC--optimise\fR .SS Description The operation \fC--optimise\fR reduces Nix store disk space usage by finding identical files in the store and hard-linking them to each other. It typically reduces the size of the store by something like 25-35%. Only regular files and symlinks are hard-linked in this manner. Files are considered identical when they have the same NAR archive serialisation: that is, regular files must have the same contents and permission (executable or non-executable), and symlinks must have the same contents. .PP After completion, or when the command is interrupted, a report on the achieved savings is printed on standard error. .PP Use \fC-vv\fR or \fC-vvv\fR to get some progress indication. .SS Example .LP .EX $ nix-store --optimise hashing files in \(ga/nix/store/qhqx7l2f1kmwihc9bnxs7rc159hsxnf3-gcc-4.1.1' \&... 541838819 bytes (516.74 MiB) freed by hard-linking 54143 files; there are 114486 files with equal contents out of 215894 files in total .EE .SH Operation \fC--read-log\fR .SS Synopsis \fCnix-store\fR {\fC--read-log\fR | \fC-l\fR} \fIpaths…\fR .SS Description The operation \fC--read-log\fR prints the build log of the specified store paths on standard output. The build log is whatever the builder of a derivation wrote to standard output and standard error. If a store path is not a derivation, the deriver of the store path is used. .PP Build logs are kept in \fC/nix/var/log/nix/drvs\fR. However, there is no guarantee that a build log is available for any particular store path. For instance, if the path was downloaded as a pre-built binary through a substitute, then the log is unavailable. .SS Example .LP .EX $ nix-store -l $(which ktorrent) building /nix/store/dhc73pvzpnzxhdgpimsd9sw39di66ph1-ktorrent-2.2.1 unpacking sources unpacking source archive /nix/store/p8n1jpqs27mgkjw07pb5269717nzf5f8-ktorrent-2.2.1.tar.gz ktorrent-2.2.1/ ktorrent-2.2.1/NEWS \&... .EE .SH Operation \fC--dump-db\fR .SS Synopsis \fCnix-store\fR \fC--dump-db\fR [\fIpaths…\fR] .SS Description The operation \fC--dump-db\fR writes a dump of the Nix database to standard output. It can be loaded into an empty Nix store using \fC--load-db\fR. This is useful for making backups and when migrating to different database schemas. .PP By default, \fC--dump-db\fR will dump the entire Nix database. When one or more store paths is passed, only the subset of the Nix database for those store paths is dumped. As with \fC--export\fR, the user is responsible for passing all the store paths for a closure. See \fC--export\fR for an example. .SH Operation \fC--load-db\fR .SS Synopsis \fCnix-store\fR \fC--load-db\fR .SS Description The operation \fC--load-db\fR reads a dump of the Nix database created by \fC--dump-db\fR from standard input and loads it into the Nix database. .SH Operation \fC--print-env\fR .SS Synopsis \fCnix-store\fR \fC--print-env\fR \fIdrvpath\fR .SS Description The operation \fC--print-env\fR prints out the environment of a derivation in a format that can be evaluated by a shell. The command line arguments of the builder are placed in the variable \fC_args\fR. .SS Example .LP .EX $ nix-store --print-env $(nix-instantiate '' -A firefox) … export src; src='/nix/store/plpj7qrwcz94z2psh6fchsi7s8yihc7k-firefox-12.0.source.tar.bz2' export stdenv; stdenv='/nix/store/7c8asx3yfrg5dg1gzhzyq2236zfgibnn-stdenv' export system; system='x86_64-linux' export _args; _args='-e /nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25c-default-builder.sh' .EE .SH Operation \fC--generate-binary-cache-key\fR .SS Synopsis \fCnix-store\fR \fC--generate-binary-cache-key\fR \fIkey-name\fR \fIsecret-key-file\fR \fIpublic-key-file\fR .SS Description This command generates an \fBEd25519 key pair\fR (\fIhttp://ed25519.cr.yp.to/\fR) that can be used to create a signed binary cache. It takes three mandatory parameters: .IP "1. " A key name, such as \fCcache.example.org-1\fR, that is used to look up keys on the client when it verifies signatures. It can be anything, but it’s suggested to use the host name of your cache (e.g. \fCcache.example.org\fR) with a suffix denoting the number of the key (to be incremented every time you need to revoke a key). .IP "2. " The file name where the secret key is to be stored. .IP "3. " The file name where the public key is to be stored.