nix-super/doc/manual/command-ref/env-common.xml

210 lines
6.9 KiB
XML
Raw Normal View History

2014-08-27 19:41:09 +03: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">
2014-08-27 19:41:09 +03:00
<title>Common Environment Variables</title>
<para>Most Nix commands interpret the following environment variables:</para>
<variablelist xml:id="env-common">
2020-07-23 11:38:19 +03:00
<varlistentry><term><literal>IN_NIX_SHELL</literal></term>
2016-02-19 00:25:23 +02:00
<listitem><para>Indicator that tells if the current environment was set up by
<command>nix-shell</command>. Since Nix 2.0 the values are
<literal>"pure"</literal> and <literal>"impure"</literal></para></listitem>
2016-02-19 00:25:23 +02:00
</varlistentry>
2020-07-23 11:38:19 +03:00
<varlistentry xml:id="env-NIX_PATH"><term><literal>NIX_PATH</literal></term>
2012-05-10 02:06:13 +03:00
<listitem>
<para>A colon-separated list of directories used to look up Nix
expressions enclosed in angle brackets (i.e.,
<literal>&lt;<replaceable>path</replaceable>></literal>). For
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
<filename>/etc/nixos</filename>, in this order. It is also
2012-05-10 02:06:13 +03:00
possible to match paths against a prefix. For example, the value
2012-05-10 02:06:13 +03:00
<screen>
nixpkgs=/home/eelco/Dev/nixpkgs-branch:/etc/nixos</screen>
will cause Nix to search for
<literal>&lt;nixpkgs/<replaceable>path</replaceable>></literal> in
<filename>/home/eelco/Dev/nixpkgs-branch/<replaceable>path</replaceable></filename>
and
2015-06-01 16:14:44 +03:00
<filename>/etc/nixos/nixpkgs/<replaceable>path</replaceable></filename>.</para>
<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 11:38:19 +03:00
<literal>NIX_PATH</literal> to
2015-06-01 16:14:44 +03:00
<screen>
nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-15.09.tar.gz</screen>
2015-06-01 16:14:44 +03:00
tells Nix to download the latest revision in the Nixpkgs/NixOS
15.09 channel.</para>
<para>A following shorthand can be used to refer to the official channels:
<screen>nixpkgs=channel:nixos-15.09</screen>
</para>
2012-05-10 02:06:13 +03:00
<para>The search path can be extended using the <option
linkend="opt-I">-I</option> option, which takes precedence over
2020-07-23 11:38:19 +03:00
<literal>NIX_PATH</literal>.</para></listitem>
2012-05-10 02:06:13 +03:00
</varlistentry>
2012-05-10 02:06:13 +03:00
2020-07-23 11:38:19 +03:00
<varlistentry><term><literal>NIX_IGNORE_SYMLINK_STORE</literal></term>
<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 youre not going to do that, you can set
2020-07-23 11:38:19 +03:00
<literal>NIX_IGNORE_SYMLINK_STORE</literal> to <literal>1</literal>.</para>
<para>Note that if youre symlinking the Nix store so that you can
put it on another file system than the root file system, on Linux
youre better off using <literal>bind</literal> mount points, e.g.,
<screen>
$ mkdir /nix
$ 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 11:38:19 +03:00
<varlistentry><term><literal>NIX_STORE_DIR</literal></term>
<listitem><para>Overrides the location of the Nix store (default
<filename><replaceable>prefix</replaceable>/store</filename>).</para></listitem>
</varlistentry>
2020-07-23 11:38:19 +03:00
<varlistentry><term><literal>NIX_DATA_DIR</literal></term>
<listitem><para>Overrides the location of the Nix static data
directory (default
<filename><replaceable>prefix</replaceable>/share</filename>).</para></listitem>
</varlistentry>
2020-07-23 11:38:19 +03:00
<varlistentry><term><literal>NIX_LOG_DIR</literal></term>
<listitem><para>Overrides the location of the Nix log directory
(default <filename><replaceable>prefix</replaceable>/var/log/nix</filename>).</para></listitem>
</varlistentry>
2020-07-23 11:38:19 +03:00
<varlistentry><term><literal>NIX_STATE_DIR</literal></term>
<listitem><para>Overrides the location of the Nix state directory
(default <filename><replaceable>prefix</replaceable>/var/nix</filename>).</para></listitem>
</varlistentry>
2020-07-23 11:38:19 +03:00
<varlistentry><term><literal>NIX_CONF_DIR</literal></term>
<listitem><para>Overrides the location of the system Nix configuration
directory (default
<filename><replaceable>prefix</replaceable>/etc/nix</filename>).</para></listitem>
</varlistentry>
2020-07-23 11:38:19 +03:00
<varlistentry><term><literal>NIX_USER_CONF_FILES</literal></term>
<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>
2020-07-23 11:38:19 +03:00
<varlistentry><term><literal>TMPDIR</literal></term>
2005-03-17 12:30:53 +02: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>
2005-03-17 12:30:53 +02:00
</varlistentry>
2020-07-23 11:38:19 +03:00
<varlistentry xml:id="envar-remote"><term><literal>NIX_REMOTE</literal></term>
2007-10-31 20:01:56 +02:00
<listitem><para>This variable should be set to
<literal>daemon</literal> if you want to use the Nix daemon to
2012-12-21 01:18:59 +02:00
execute Nix operations. This is necessary in <link
2007-10-31 20:01:56 +02:00
linkend="ssec-multi-user">multi-user Nix installations</link>.
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 20:01:56 +02:00
Otherwise, it should be left unset.</para></listitem>
</varlistentry>
2020-07-23 11:38:19 +03:00
<varlistentry><term><literal>NIX_SHOW_STATS</literal></term>
<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 11:38:19 +03:00
<varlistentry><term><literal>NIX_COUNT_CALLS</literal></term>
<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 11:38:19 +03:00
<varlistentry><term><literal>GC_INITIAL_HEAP_SIZE</literal></term>
2010-10-29 17:44:02 +03: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>
</variablelist>
2014-08-27 19:41:09 +03:00
</chapter>