2014-08-27 16:41:09 +00:00
|
|
|
|
<chapter xmlns="http://docbook.org/ns/docbook"
|
|
|
|
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
|
|
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
|
|
|
|
version="5.0"
|
|
|
|
|
xml:id="sec-common-env">
|
2006-08-21 16:05:11 +00:00
|
|
|
|
|
2014-08-27 16:41:09 +00:00
|
|
|
|
<title>Common Environment Variables</title>
|
2006-08-21 16:05:11 +00:00
|
|
|
|
|
2005-03-16 16:45:29 +00:00
|
|
|
|
|
|
|
|
|
<para>Most Nix commands interpret the following environment variables:</para>
|
|
|
|
|
|
2012-04-06 19:56:20 +00:00
|
|
|
|
<variablelist xml:id="env-common">
|
2005-03-16 16:45:29 +00:00
|
|
|
|
|
2020-07-23 08:38:19 +00:00
|
|
|
|
<varlistentry><term><literal>IN_NIX_SHELL</literal></term>
|
2016-02-18 22:25:23 +00:00
|
|
|
|
|
|
|
|
|
<listitem><para>Indicator that tells if the current environment was set up by
|
2019-05-17 07:50:42 +00:00
|
|
|
|
<command>nix-shell</command>. Since Nix 2.0 the values are
|
|
|
|
|
<literal>"pure"</literal> and <literal>"impure"</literal></para></listitem>
|
2016-02-18 22:25:23 +00:00
|
|
|
|
|
|
|
|
|
</varlistentry>
|
2014-09-16 09:20:09 +00:00
|
|
|
|
|
2020-07-23 08:38:19 +00:00
|
|
|
|
<varlistentry xml:id="env-NIX_PATH"><term><literal>NIX_PATH</literal></term>
|
2012-05-09 23:06:13 +00:00
|
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
|
|
|
|
|
|
<para>A colon-separated list of directories used to look up Nix
|
|
|
|
|
expressions enclosed in angle brackets (i.e.,
|
2020-07-23 12:28:05 +00:00
|
|
|
|
<literal><<emphasis>path</emphasis>></literal>). For
|
2012-05-09 23:06:13 +00:00
|
|
|
|
instance, the value
|
|
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
|
/home/eelco/Dev:/etc/nixos</screen>
|
|
|
|
|
|
|
|
|
|
will cause Nix to look for paths relative to
|
|
|
|
|
<filename>/home/eelco/Dev</filename> and
|
2020-03-30 13:31:14 +00:00
|
|
|
|
<filename>/etc/nixos</filename>, in this order. It is also
|
2012-05-09 23:06:13 +00:00
|
|
|
|
possible to match paths against a prefix. For example, the value
|
2014-09-16 09:20:09 +00:00
|
|
|
|
|
2012-05-09 23:06:13 +00:00
|
|
|
|
<screen>
|
|
|
|
|
nixpkgs=/home/eelco/Dev/nixpkgs-branch:/etc/nixos</screen>
|
|
|
|
|
|
|
|
|
|
will cause Nix to search for
|
2020-07-23 12:28:05 +00:00
|
|
|
|
<literal><nixpkgs/<emphasis>path</emphasis>></literal> in
|
|
|
|
|
<filename>/home/eelco/Dev/nixpkgs-branch/<emphasis>path</emphasis></filename>
|
2012-05-09 23:06:13 +00:00
|
|
|
|
and
|
2020-07-23 12:28:05 +00:00
|
|
|
|
<filename>/etc/nixos/nixpkgs/<emphasis>path</emphasis></filename>.</para>
|
2015-06-01 13:14:44 +00:00
|
|
|
|
|
|
|
|
|
<para>If a path in the Nix search path starts with
|
|
|
|
|
<literal>http://</literal> or <literal>https://</literal>, it is
|
|
|
|
|
interpreted as the URL of a tarball that will be downloaded and
|
|
|
|
|
unpacked to a temporary location. The tarball must consist of a
|
|
|
|
|
single top-level directory. For example, setting
|
2020-07-23 08:38:19 +00:00
|
|
|
|
<literal>NIX_PATH</literal> to
|
2015-06-01 13:14:44 +00:00
|
|
|
|
|
|
|
|
|
<screen>
|
2020-05-23 13:26:59 +00:00
|
|
|
|
nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-15.09.tar.gz</screen>
|
2015-06-01 13:14:44 +00:00
|
|
|
|
|
|
|
|
|
tells Nix to download the latest revision in the Nixpkgs/NixOS
|
2019-03-26 00:55:28 +00:00
|
|
|
|
15.09 channel.</para>
|
|
|
|
|
|
|
|
|
|
<para>A following shorthand can be used to refer to the official channels:
|
2020-03-30 13:31:14 +00:00
|
|
|
|
|
2019-03-26 00:55:28 +00:00
|
|
|
|
<screen>nixpkgs=channel:nixos-15.09</screen>
|
|
|
|
|
</para>
|
2012-05-09 23:06:13 +00:00
|
|
|
|
|
2014-09-16 09:20:09 +00:00
|
|
|
|
<para>The search path can be extended using the <option
|
|
|
|
|
linkend="opt-I">-I</option> option, which takes precedence over
|
2020-07-23 08:38:19 +00:00
|
|
|
|
<literal>NIX_PATH</literal>.</para></listitem>
|
2012-05-09 23:06:13 +00:00
|
|
|
|
|
|
|
|
|
</varlistentry>
|
2014-09-16 09:20:09 +00:00
|
|
|
|
|
2012-05-09 23:06:13 +00:00
|
|
|
|
|
2020-07-23 08:38:19 +00:00
|
|
|
|
<varlistentry><term><literal>NIX_IGNORE_SYMLINK_STORE</literal></term>
|
2005-03-16 16:45:29 +00:00
|
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
|
|
|
|
|
|
<para>Normally, the Nix store directory (typically
|
|
|
|
|
<filename>/nix/store</filename>) 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
|
|
|
|
|
<filename>/nix/store</filename> resolving to different locations)
|
|
|
|
|
could yield different results. This is generally not a problem,
|
|
|
|
|
except when builds are deployed to machines where
|
|
|
|
|
<filename>/nix/store</filename> resolves differently. If you are
|
|
|
|
|
sure that you’re not going to do that, you can set
|
2020-07-23 08:38:19 +00:00
|
|
|
|
<literal>NIX_IGNORE_SYMLINK_STORE</literal> to <literal>1</literal>.</para>
|
2005-03-16 16:45:29 +00:00
|
|
|
|
|
|
|
|
|
<para>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 <literal>bind</literal> mount points, e.g.,
|
|
|
|
|
|
|
|
|
|
<screen>
|
2014-09-16 09:20:09 +00:00
|
|
|
|
$ mkdir /nix
|
2005-03-16 16:45:29 +00:00
|
|
|
|
$ mount -o bind /mnt/otherdisk/nix /nix</screen>
|
|
|
|
|
|
|
|
|
|
Consult the <citerefentry><refentrytitle>mount</refentrytitle>
|
|
|
|
|
<manvolnum>8</manvolnum></citerefentry> manual page for details.</para>
|
|
|
|
|
|
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
|
|
|
2020-07-23 08:38:19 +00:00
|
|
|
|
<varlistentry><term><literal>NIX_STORE_DIR</literal></term>
|
2005-03-16 16:45:29 +00:00
|
|
|
|
|
|
|
|
|
<listitem><para>Overrides the location of the Nix store (default
|
2020-07-23 12:28:05 +00:00
|
|
|
|
<filename><emphasis>prefix</emphasis>/store</filename>).</para></listitem>
|
2014-09-16 09:20:09 +00:00
|
|
|
|
|
2005-03-16 16:45:29 +00:00
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
|
|
|
2020-07-23 08:38:19 +00:00
|
|
|
|
<varlistentry><term><literal>NIX_DATA_DIR</literal></term>
|
2005-03-16 16:45:29 +00:00
|
|
|
|
|
|
|
|
|
<listitem><para>Overrides the location of the Nix static data
|
|
|
|
|
directory (default
|
2020-07-23 12:28:05 +00:00
|
|
|
|
<filename><emphasis>prefix</emphasis>/share</filename>).</para></listitem>
|
2014-09-16 09:20:09 +00:00
|
|
|
|
|
2005-03-16 16:45:29 +00:00
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
|
|
|
2020-07-23 08:38:19 +00:00
|
|
|
|
<varlistentry><term><literal>NIX_LOG_DIR</literal></term>
|
2005-03-16 16:45:29 +00:00
|
|
|
|
|
|
|
|
|
<listitem><para>Overrides the location of the Nix log directory
|
2020-07-23 12:28:05 +00:00
|
|
|
|
(default <filename><emphasis>prefix</emphasis>/var/log/nix</filename>).</para></listitem>
|
2014-09-16 09:20:09 +00:00
|
|
|
|
|
2005-03-16 16:45:29 +00:00
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
|
|
|
2020-07-23 08:38:19 +00:00
|
|
|
|
<varlistentry><term><literal>NIX_STATE_DIR</literal></term>
|
2005-03-16 16:45:29 +00:00
|
|
|
|
|
|
|
|
|
<listitem><para>Overrides the location of the Nix state directory
|
2020-07-23 12:28:05 +00:00
|
|
|
|
(default <filename><emphasis>prefix</emphasis>/var/nix</filename>).</para></listitem>
|
2014-09-16 09:20:09 +00:00
|
|
|
|
|
2005-03-16 16:45:29 +00:00
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
|
|
|
2020-07-23 08:38:19 +00:00
|
|
|
|
<varlistentry><term><literal>NIX_CONF_DIR</literal></term>
|
2005-03-16 16:45:29 +00:00
|
|
|
|
|
2020-03-30 13:31:14 +00:00
|
|
|
|
<listitem><para>Overrides the location of the system Nix configuration
|
2005-03-16 16:45:29 +00:00
|
|
|
|
directory (default
|
2020-07-23 12:28:05 +00:00
|
|
|
|
<filename><emphasis>prefix</emphasis>/etc/nix</filename>).</para></listitem>
|
2014-09-16 09:20:09 +00:00
|
|
|
|
|
2005-03-16 16:45:29 +00:00
|
|
|
|
</varlistentry>
|
|
|
|
|
|
2020-07-23 08:38:19 +00:00
|
|
|
|
<varlistentry><term><literal>NIX_USER_CONF_FILES</literal></term>
|
2020-03-30 13:31:14 +00:00
|
|
|
|
|
|
|
|
|
<listitem><para>Overrides the location of the user Nix configuration files
|
|
|
|
|
to load from (defaults to the XDG spec locations). The variable is treated
|
|
|
|
|
as a list separated by the <literal>:</literal> token.</para></listitem>
|
|
|
|
|
|
|
|
|
|
</varlistentry>
|
2005-03-16 16:45:29 +00:00
|
|
|
|
|
2020-07-23 08:38:19 +00:00
|
|
|
|
<varlistentry><term><literal>TMPDIR</literal></term>
|
2005-03-17 10:30:53 +00:00
|
|
|
|
|
|
|
|
|
<listitem><para>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
|
|
|
|
|
<filename>/tmp</filename>.</para></listitem>
|
2014-09-16 09:20:09 +00:00
|
|
|
|
|
2005-03-17 10:30:53 +00:00
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
|
|
|
2020-07-23 08:38:19 +00:00
|
|
|
|
<varlistentry xml:id="envar-remote"><term><literal>NIX_REMOTE</literal></term>
|
2007-10-31 18:01:56 +00:00
|
|
|
|
|
|
|
|
|
<listitem><para>This variable should be set to
|
|
|
|
|
<literal>daemon</literal> if you want to use the Nix daemon to
|
2012-12-20 23:18:59 +00:00
|
|
|
|
execute Nix operations. This is necessary in <link
|
2007-10-31 18:01:56 +00:00
|
|
|
|
linkend="ssec-multi-user">multi-user Nix installations</link>.
|
2018-01-31 22:47:16 +00:00
|
|
|
|
If the Nix daemon's Unix socket is at some non-standard path,
|
|
|
|
|
this variable should be set to <literal>unix://path/to/socket</literal>.
|
2007-10-31 18:01:56 +00:00
|
|
|
|
Otherwise, it should be left unset.</para></listitem>
|
|
|
|
|
|
|
|
|
|
</varlistentry>
|
|
|
|
|
|
2014-09-16 09:20:09 +00:00
|
|
|
|
|
2020-07-23 08:38:19 +00:00
|
|
|
|
<varlistentry><term><literal>NIX_SHOW_STATS</literal></term>
|
2013-10-24 00:22:24 +00:00
|
|
|
|
|
|
|
|
|
<listitem><para>If set to <literal>1</literal>, Nix will print some
|
|
|
|
|
evaluation statistics, such as the number of values
|
|
|
|
|
allocated.</para></listitem>
|
|
|
|
|
|
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
|
|
|
2020-07-23 08:38:19 +00:00
|
|
|
|
<varlistentry><term><literal>NIX_COUNT_CALLS</literal></term>
|
2013-10-24 00:22:24 +00:00
|
|
|
|
|
|
|
|
|
<listitem><para>If set to <literal>1</literal>, Nix will print how
|
|
|
|
|
often functions were called during Nix expression evaluation. This
|
|
|
|
|
is useful for profiling your Nix expressions.</para></listitem>
|
|
|
|
|
|
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
|
|
|
2020-07-23 08:38:19 +00:00
|
|
|
|
<varlistentry><term><literal>GC_INITIAL_HEAP_SIZE</literal></term>
|
2010-10-29 14:44:02 +00:00
|
|
|
|
|
|
|
|
|
<listitem><para>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.</para></listitem>
|
|
|
|
|
|
|
|
|
|
</varlistentry>
|
|
|
|
|
|
2014-09-16 09:20:09 +00:00
|
|
|
|
|
2005-03-16 16:45:29 +00:00
|
|
|
|
</variablelist>
|
|
|
|
|
|
2006-08-21 16:05:11 +00:00
|
|
|
|
|
2014-08-27 16:41:09 +00:00
|
|
|
|
</chapter>
|