2020-08-19 19:28:04 +03:00
# Name
`nix.conf` - Nix configuration file
# Description
2023-06-17 04:53:37 +03:00
Nix supports a variety of configuration settings, which are read from configuration files or taken as command line flags.
## Configuration file
2023-06-20 13:12:03 +03:00
By default Nix reads settings from the following places, in that order:
2020-08-19 19:28:04 +03:00
2023-06-20 13:12:03 +03:00
1. The system-wide configuration file `sysconfdir/nix/nix.conf` (i.e. `/etc/nix/nix.conf` on most systems), or `$NIX_CONF_DIR/nix.conf` if [`NIX_CONF_DIR` ](./env-common.md#env-NIX_CONF_DIR ) is set.
2020-08-19 19:28:04 +03:00
2023-06-20 13:12:03 +03:00
Values loaded in this file are not forwarded to the Nix daemon.
The client assumes that the daemon has already loaded them.
2020-08-19 19:28:04 +03:00
2023-06-20 13:12:03 +03:00
1. If [`NIX_USER_CONF_FILES` ](./env-common.md#env-NIX_USER_CONF_FILES ) is set, then each path separated by `:` will be loaded in reverse order.
2020-08-19 19:28:04 +03:00
2023-06-20 13:12:03 +03:00
Otherwise it will look for `nix/nix.conf` files in `XDG_CONFIG_DIRS` and [`XDG_CONFIG_HOME` ](./env-common.md#env-XDG_CONFIG_HOME ).
If unset, `XDG_CONFIG_DIRS` defaults to `/etc/xdg` , and `XDG_CONFIG_HOME` defaults to `$HOME/.config` as per [XDG Base Directory Specification ](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html ).
2023-06-17 04:25:57 +03:00
2023-06-20 13:12:03 +03:00
1. If [`NIX_CONFIG` ](./env-common.md#env-NIX_CONFIG ) is set, its contents are treated as the contents of a configuration file.
2020-10-20 00:08:50 +03:00
2023-06-17 04:53:37 +03:00
### File format
Configuration files consist of `name = value` pairs, one per line.
Comments start with a `#` character.
Example:
```
keep-outputs = true # Nice for developers
keep-derivations = true # Idem
```
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.
2023-06-20 13:12:03 +03:00
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.
2023-06-17 04:25:57 +03:00
2023-06-17 04:53:37 +03:00
For instance,
2020-08-19 19:28:04 +03:00
2023-06-17 04:53:37 +03:00
```
substituters = a b
extra-substituters = c d
```
2020-08-19 19:28:04 +03:00
2023-06-17 04:53:37 +03:00
defines the `substituters` setting to be `a b c d` .
2020-10-29 19:17:39 +02:00
2023-06-20 13:12:23 +03:00
Unknown option names are not an error, and are simply ignored with a warning.
2023-06-17 04:53:37 +03:00
## Command line flags
2020-10-29 19:17:39 +02:00
2023-06-20 13:12:23 +03:00
Configuration options can be set on the command line, overriding the values set in the [configuration file ](#configuration-file ):
- Every configuration setting has corresponding command line flag (e.g. `--max-jobs 16` ).
Boolean settings do not need an argument, and can be explicitly disabled with the `no-` prefix (e.g. `--keep-failed` and `--no-keep-failed` ).
Unknown option names are invalid flags (unless there is already a flag with that name), and are rejected with an error.
- The flag `--option <name> <value>` is interpreted exactly like a `<name> = <value>` in a setting file.
Unknown option names are ignored with a warning.
2020-10-29 19:17:39 +02:00
2023-06-20 13:12:23 +03:00
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` ).
2020-08-19 19:28:04 +03:00
2023-02-16 16:16:30 +02:00
## Integer settings
Settings that have an integer type support the suffixes `K` , `M` , `G`
and `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` .
2023-06-17 04:53:37 +03:00
# Available settings
2020-08-19 19:28:04 +03:00