Common environment variablesMost Nix commands interpret the following environment variables:NIX_IGNORE_SYMLINK_STORENormally, 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.
Thus, builds on different machines (with
/nix/store resolving to different locations)
could yield different results. This is generally not a problem,
except when builds are deployed to machines where
/nix/store resolves differently. If you are
sure that you’re not going to do that, you can set
NIX_IGNORE_SYMLINK_STORE to 1.Note that if you’re symlinking the Nix store so that 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 mount8 manual page for details.NIX_STORE_DIROverrides the location of the Nix store (default
prefix/store).NIX_DATA_DIROverrides the location of the Nix static data
directory (default
prefix/share).NIX_LOG_DIROverrides the location of the Nix log directory
(default prefix/log/nix).NIX_STATE_DIROverrides the location of the Nix state directory
(default prefix/var/nix).NIX_DB_DIROverrides the location of the Nix database (default
$NIX_STATE_DIR/db, i.e.,
prefix/var/nix/db).NIX_CONF_DIROverrides the location of the Nix configuration
directory (default
prefix/etc/nix).NIX_LOG_TYPEEquivalent to the
option.TMPDIRUse 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_BUILD_HOOKSpecifies the location of the build hook,
which is a program (typically some script) that Nix will call
whenever it wants to build a derivation. This is used to implement
distributed builds (see ). The protocol by which the calling Nix process and the build
hook communicate is as follows.The build hook is called with the following command-line
arguments:
A boolean value 0 or
1 specifying whether Nix can locally execute
more builds, as per the option.
The purpose of this argument is to allow the hook to not have to
maintain bookkeeping for the local machine.The Nix platform identifier for the local machine
(e.g., i686-linux).The Nix platform identifier for the derivation,
i.e., its system
attribute.The store path of the derivation.On the basis of this information, and whatever persistent
state the build hook keeps about other machines and their current
load, it has to decide what to do with the build. It should print
out on standard error one of the following responses (terminated by
a newline, "\n"):
# declineThe build hook is not willing or able to perform
the build; the calling Nix process should do the build itself,
if possible.# postponeThe build hook cannot perform the build now, but
can do so in the future (e.g., because all available build slots
on remote machines are in use). The calling Nix process should
postpone this build until at least one currently running build
has terminated.# acceptThe build hook has accepted the
build.After sending # accept, the hook should
read one line from standard input, which will be the string
okay. It can then proceed with the build.
Before sending okay, Nix will store in the hook’s
current directory a number of text files that contain information
about the derivation:
inputsThe set of store paths that are inputs to the
build process (one per line). These have to be copied
to the remote machine (in addition to the
store derivation itself).outputsThe set of store paths that are outputs of the
derivation (one per line). These have to be copied
from the remote machine if the build
succeeds.referencesThe reference graph of the inputs, in the format
accepted by the command nix-store
--register-validity. It is necessary to run this
command on the remote machine after copying the inputs to inform
Nix on the remote machine that the inputs are valid
paths.The hook should copy the inputs to the remote machine,
register the validity of the inputs, perform the remote build, and
copy the outputs back to the local machine. An exit code other than
0 indicates that the hook has failed. An exit
code equal to 100 means that the remote build failed (as opposed to,
e.g., a network error).NIX_REMOTEThis variable should be set to
daemon if you want to use the Nix daemon to
executed Nix operations, which is necessary in multi-user Nix installations.
Otherwise, it should be left unset.NIX_OTHER_STORESThis variable contains the paths of remote Nix
installations from whichs paths can be copied, separated by colons.
See for details. Each path
should be the /nix directory of a remote Nix
installation (i.e., not the /nix/store
directory). The paths are subject to globbing, so you can set it so
something like /var/run/nix/remote-stores/*/nix
and mount multiple remote filesystems in
/var/run/nix/remote-stores.Note that if you’re building through the Nix daemon, the only setting for
this variable that matters is the one that the
nix-worker process uses. So if you want to
change it, you have to restart the daemon.