nix.conf - Nix Reference Manual (original) (raw)

Nix supports a variety of configuration settings, which are read from configuration files or taken as command line flags.

Configuration files consist of name = value pairs, one per line. Comments start with a # character.

Other files can be included with a line like include <path>, where <path> is interpreted relative to the current configuration file. A missing file is an error unless !include is used instead.

A configuration setting usually overrides any previous value. However, for settings that take a list of items, you can prefix the name of the setting by extra- to append to the previous value.

defines the substituters setting to be a b c d.

Unknown option names are not an error, and are simply ignored with a warning.

Configuration options can be set on the command line, overriding the values set in the configuration file:

The extra- prefix is supported for settings that take a list of items (e.g. --extra-trusted users alice or --option extra-trusted-users alice).

Settings that have an integer type support the suffixes K, M, Gand T. These cause the specified value to be multiplied by 2^10, 2^20, 2^30 and 2^40, respectively. For instance, --min-free 1M is equivalent to --min-free 1048576.

extra-experimental-features = flakes
accept-flake-config = ...

Whether to accept nix configuration from a flake without prompting.  
**Default:** `false`
access-tokens = github.com=23ac...b289 gitlab.mycompany.com=PAT:A123Bp_Cd..EfG gitlab.com=OAuth2:1jklw3jk  

Example ~/code/flake.nix:

input.foo = {  
  type = "gitlab";  
  host = "gitlab.mycompany.com";  
  owner = "mycompany";  
  repo = "pro";  
};  

This example specifies three tokens, one each for accessing github.com, gitlab.mycompany.com, and gitlab.com.
The input.foo uses the "gitlab" fetcher, which might requires specifying the token type along with the token value.
Default: empty

extern "C" typedef void (*ValueInitialiser) (EvalState & state, Value & v);  

The Nix C++ API documentation has more details on evaluator internals.

extra-experimental-features = auto-allocate-uids
auto-allocate-uids = ...

Whether to select UIDs for builds automatically, instead of using the users in `build-users-group`.  
UIDs are allocated starting at 872415232 (0x34000000) on Linux and 56930 on macOS.  
**Default:** `false`

builders = @/etc/nix/machines

Each machine specification consists of the following elements, separated by spaces. Only the first element is required. To leave a field at its default, set it to `-`.  
  1. The URI of the remote store in the format ssh://[username@]hostname.

    Example

    ssh://nix@mac
    For backward compatibility, ssh:// may be omitted. The hostname may be an alias defined in ~/.ssh/config.

  2. A comma-separated list of Nix system types. If omitted, this defaults to the local platform type.

    Example

    aarch64-darwin
    It is possible for a machine to support multiple platform types.
    Example

    i686-linux,x86_64-linux

  3. The SSH identity file to be used to log in to the remote machine. If omitted, SSH will use its regular identities.

    Example

    /home/user/.ssh/id_mac

  4. The maximum number of builds that Nix will execute in parallel on the machine. Typically this should be equal to the number of CPU cores.
  5. The “speed factor”, indicating the relative speed of the machine as a positive integer. If there are multiple machines of the right type, Nix will prefer the fastest, taking load into account.
  6. A comma-separated list of supported system features.
    A machine will only be used to build a derivation if all the features in the derivation's requiredSystemFeatures attribute are supported by that machine.
  7. A comma-separated list of required system features.
    A machine will only be used to build a derivation if all of the machine’s required features appear in the derivation’s requiredSystemFeatures attribute.
  8. The (base64-encoded) public host key of the remote machine. If omitted, SSH will use its regular known_hosts file.
    The value for this field can be obtained via base64 -w0.

    Example

    Multiple builders specified on the command line:

    --builders 'ssh://mac x86_64-darwin ; ssh://beastie x86_64-freebsd'  
     

    Example

    This specifies several machines that can perform i686-linux builds:

    nix@scratchy.labs.cs.uu.nl i686-linux /home/nix/.ssh/id_scratchy 8 1 kvm  
    nix@itchy.labs.cs.uu.nl    i686-linux /home/nix/.ssh/id_scratchy 8 2  
    nix@poochie.labs.cs.uu.nl  i686-linux /home/nix/.ssh/id_scratchy 1 2 kvm benchmark  
     

    However, poochie will only build derivations that have the attribute

    requiredSystemFeatures = [ "benchmark" ];  
     

    or

    requiredSystemFeatures = [ "benchmark" "kvm" ];  
     

    itchy cannot do builds that require kvm, but scratchy does support such builds. For regular builds, itchy will be preferred over scratchy because it has a higher speed factor.
    For Nix to use substituters, the calling user must be in the trusted-users list.
    Note

    A build machine must be accessible via SSH and have Nix installed.nix must be available in $PATH for the user connecting over SSH.
    Warning

    If you are building via the Nix daemon (default), the Nix daemon user account on the local machine (that is, root) requires access to a user account on the remote machine (not necessarily root).

    If you can’t or don’t want to configure root to be able to access the remote machine, set store to any local store, e.g. by passing --store /tmp to the command on the local machine.
    To build only on remote machines and disable local builds, set max-jobs to 0.
    If you want the remote machines to use substituters, set builders-use-substitutes to true.
    Default: machine-specific

extra-experimental-features = flakes
commit-lock-file-summary = ...

The commit summary to use when committing changed flake lock files. If empty, the summary is generated based on the action performed.  
**Default:** _empty_  
**Deprecated alias:** `commit-lockfile-summary`
  1. A path to the previous build's results
  2. A path to the current build's results
  3. The path to the build's derivation
  4. The path to the build's scratch directory. This directory will exist only if the build was run with --keep-failed.
    The stderr and stdout output from the diff hook will not be displayed to the user. Instead, it will print to the nix-daemon's log.
    When using the Nix daemon, diff-hook must be set in the nix.confconfiguration file, and cannot be passed at the command line.
    Default: ``
experimental-features = nix-command flakes  

The following experimental features are available:

extra-experimental-features = flakes
flake-registry = ...

Path or URI of the global flake registry.  
When empty, disables the global flake registry.  
**Default:** `https://channels.nixos.org/flake-registry.json`
builtins.fetchurl {  
  url = "https://example.org/foo-1.2.3.tar.xz";  
  sha256 = "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae";  
}  

Nix will attempt to download this file fromhttp://tarballs.nixos.org/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7aefirst. If it is not available there, if will try the original URI.
Default: empty

extra-experimental-features = configurable-impure-env
impure-env = ...

A list of items, each in the format of:  
$ rm $HOME/.cache/nix/binary-cache-v*.sqlite*  
# rm /root/.cache/nix/binary-cache-v*.sqlite*  

Default: 3600

machine my-machine  
login my-username  
password my-password  

For the exact syntax, see the curldocumentation.

Note

This must be an absolute path, and ~ is not resolved. For example, ~/.netrc won't resolve to your home directory's.netrc.
Default: /dummy/netrc

  1. /etc/ssl/certs/ca-certificates.crt
  2. /nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt
    The path can be overridden by the following environment variables, in order of precedence:
  3. NIX_SSL_CERT_FILE
  4. SSL_CERT_FILE
    Default: empty
function-trace entered undefined position at 1565795816999559622  
function-trace exited undefined position at 1565795816999581277  
function-trace entered /nix/store/.../example.nix:226:41 at 1565795253249935150  
function-trace exited /nix/store/.../example.nix:226:41 at 1565795253249941684  

The undefined position means the function call is a builtin.
Use the contrib/stack-collapse.py script distributed with the Nix source code to convert the trace logs in to a format suitable forflamegraph.pl.
Default: false

extra-experimental-features = flakes
use-registries = ...

Whether to use flake registries to resolve flake references.  
**Default:** `true`
nix_state_home=${XDG_STATE_HOME-$HOME/.local/state}/nix  
mkdir -p $nix_state_home  
mv <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>H</mi><mi>O</mi><mi>M</mi><mi>E</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">.</mi><mi>n</mi><mi>i</mi><mi>x</mi><mo>−</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>f</mi><mi>i</mi><mi>l</mi><mi>e</mi></mrow><annotation encoding="application/x-tex">HOME/.nix-profile </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.08125em;">H</span><span class="mord mathnormal" style="margin-right:0.05764em;">OME</span><span class="mord">/.</span><span class="mord mathnormal">ni</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mord mathnormal">ro</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal">i</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">e</span></span></span></span>nix_state_home/profile  
mv <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>H</mi><mi>O</mi><mi>M</mi><mi>E</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">.</mi><mi>n</mi><mi>i</mi><mi>x</mi><mo>−</mo><mi>d</mi><mi>e</mi><mi>f</mi><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi></mrow><annotation encoding="application/x-tex">HOME/.nix-defexpr </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.08125em;">H</span><span class="mord mathnormal" style="margin-right:0.05764em;">OME</span><span class="mord">/.</span><span class="mord mathnormal">ni</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">d</span><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal">e</span><span class="mord mathnormal">x</span><span class="mord mathnormal">p</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span></span></span></span>nix_state_home/defexpr  
mv <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>H</mi><mi>O</mi><mi>M</mi><mi>E</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">.</mi><mi>n</mi><mi>i</mi><mi>x</mi><mo>−</mo><mi>c</mi><mi>h</mi><mi>a</mi><mi>n</mi><mi>n</mi><mi>e</mi><mi>l</mi><mi>s</mi></mrow><annotation encoding="application/x-tex">HOME/.nix-channels </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.08125em;">H</span><span class="mord mathnormal" style="margin-right:0.05764em;">OME</span><span class="mord">/.</span><span class="mord mathnormal">ni</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">c</span><span class="mord mathnormal">hann</span><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">s</span></span></span></span>nix_state_home/channels  

Default: false