Common environment variables Most Nix commands interpret the following environment variables: NIX_IGNORE_SYMLINK_STORE 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. 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 mount 8 manual page for details. NIX_STORE_DIR Overrides the location of the Nix store (default prefix/store). NIX_DATA_DIR Overrides the location of the Nix static data directory (default prefix/share). NIX_LOG_DIR Overrides the location of the Nix log directory (default prefix/log/nix). NIX_STATE_DIR Overrides the location of the Nix state directory (default prefix/var/nix). NIX_DB_DIR Overrides the location of the Nix database (default $NIX_STATE_DIR/db, i.e., prefix/var/nix/db). NIX_CONF_DIR Overrides the location of the Nix configuration directory (default prefix/etc/nix). NIX_LOG_TYPE Equivalent to the option. 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_BUILD_HOOK Specifies 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"): # decline The build hook is not willing or able to perform the build; the calling Nix process should do the build itself, if possible. # postpone The 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. # accept The 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: inputs The 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). outputs The 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. references The 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_REMOTE This 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_STORES This 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. 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 to 384 MiB. Setting it to a low value reduces memory consumption, but will increase runtime due to the overhead of garbage collection.