nix-store manipulate or query the Nix store nix-store &opt-common-syn; operation options arguments Description The command nix-store performs primitive operations on the Nix store. You generally do not need to run this command manually. nix-store takes exactly one operation flag which indicates the subcommand to be performed. These are documented below. 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. &opt-common; Environment variables The following environment variables affect the behaviour of nix-store. TMPDIR=path Use the directory path to store temporary files. In particular, this includes temporary build directories; these can take up substantial amounts of disk space. The default is /tmp. Operation <option>--realise</option> Synopsis nix-store paths Description The operation realises in the file system the store expressions stored in paths. If these expressions are derivation expressions, they are first normalised into a closure expression. This may happen in two ways. First, the corresponding closure expression (the successor) may already known (either because the build has already been performed, or because a successor was explicitly registered through the operation). Otherwise, the build action described by the derivation is performed, and a closure expression is computed by scanning the result of the build for references to other paths in the store. The paths of the closure expression corresponding to each expression in paths is printed on standard output. Operation <option>--gc</option> Synopsis nix-store age Description The operation performs a garbage collection on the Nix store. What it does specifically is determined by the sub-operation, which is one of the following: This operation prints on standard output the set of live store paths, which are all the store paths reachable from a set of root store expressions read from standard input. 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. 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. This operation performs an actual garbage collection. All dead paths are removed from the store. The set of root store expressions is read from standard input. Each line should contain exactly one store path. The option specifies a minimum time in hours that an unreachable store path must not have been used before it is considered dead. The default is 0 (consider all unreachable store paths dead). Whether a store path has been used is determined by looking at its access time (atime), so this does not work if the store is located on a file system that has the noatime option set. You generally will want to use the command nix-collect-garbage, which figures out the roots and then calls this command automatically. Operation <option>--query</option> Synopsis nix-store args Description The operation displays various bits of information about store expressions or store paths. The queries are described below. At most one query can be specified. The default query is . Common query options / For those queries that take a Nix store expression, this option causes those expressions to be normalised first. / For those queries that take a Nix store expression, this option causes those expressions to be realised first. This is just a short-cut for the common idiom nix-store --realise /nix/store/bla.store x=`nix-store --query --normalise /nix/store/bla.store` (do something with the path $x which using this flag can be written as x=`nix-store --query --normalise --force-realise /nix/store/bla.store` (do something with the path $x Queries / Prints out the output paths of the store expressions indicated by the identifiers args. In the case of a derivation expression, these are the paths that will be produced when the derivation is realised. In the case of a closure expression, these are the paths that were produced the derivation expression of which the closure expression is a successor. / Prints out the requisite paths of the store expressions indicated by the identifiers args. The requisite paths of a Nix expression are the paths that need to be present in the system to be able to realise the expression. That is, they form the closure of the expression in the file system (i.e., no path in the set of requisite paths points to anything outside the set of requisite paths). The notion of requisite paths is very useful when one wants to distribute store expressions. Since they form a closure, they are the only paths one needs to distribute to another system to be able to realise the expression on the other system. This query is generally used to implement various kinds of deployment. A source deployment is obtained by distributing the requisite paths of a derivation expression. A binary deployment is obtained by distributing the requisite paths of a closure expression. A cache deployment is obtained by distributing the requisite paths of a derivation expression and specifying the option . This will include not just the paths of a source and binary deployment, but also all expressions and paths of subterms of the source. This is useful if one wants to realise on the target system a Nix expression that is similar but not quite the same as the one being distributed, since any common subterms will be reused. This query has a number of options: Excludes the paths of store expressions. This causes the closure property to be lost, that is, the resulting set of paths is not enough to ensure realisibility. Also include the requisites of successors (normal forms). Only the requisites of known successors are included, i.e., the normal forms of derivation expressions that have never been normalised will not be included. Note that not just the successor of a derivation expression will be included, but also the successors of all input expressions of that derivation expression. I.e., all normal forms of subterms involved in the normalisation of the top-level term are included. For each store expression stored at paths args, prints its predecessors. A derivation expression p is a predecessor of a store expression q iff q is a successor of p. Prints a graph of the closure of the store expressions identified by args in the format of the dot tool of AT&T's GraphViz package. Operation <option>--successor</option> Synopsis nix-store srcpath sucpath Description The operation registers that the closure expression in sucpath is a successor of the derivation expression in srcpath. This is used to implement binary deployment. Operation <option>--substitute</option> Synopsis nix-store srcpath subpath Description The operation registers that the store path srcpath can be built by realising the derivation expression in subpath. This is used to implement binary deployment. Operation <option>--verify</option> Synopsis nix-store Description The operation 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.