1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 06:01:48 +02:00

<envar> -> <literal>

This commit is contained in:
Eelco Dolstra 2020-07-23 10:38:19 +02:00
parent 942cd687f9
commit c20c082383
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
33 changed files with 111 additions and 111 deletions

View file

@ -139,7 +139,7 @@ impureEnvVars = [ "http_proxy" "https_proxy" <replaceable>...</replaceable> ];
</programlisting>
to make it use the proxy server configuration specified by the
user in the environment variables <envar>http_proxy</envar> and
user in the environment variables <literal>http_proxy</literal> and
friends.</para>
<para>This attribute is only allowed in <link
@ -294,12 +294,12 @@ big = "a very long string";
</programlisting>
then when the builder runs, the environment variable
<envar>bigPath</envar> will contain the absolute path to a
<literal>bigPath</literal> will contain the absolute path to a
temporary file containing <literal>a very long
string</literal>. That is, for any attribute
<replaceable>x</replaceable> listed in
<varname>passAsFile</varname>, Nix will pass an environment
variable <envar><replaceable>x</replaceable>Path</envar> holding
variable <literal><replaceable>x</replaceable>Path</literal> holding
the path of the file containing the value of attribute
<replaceable>x</replaceable>. This is useful when you need to pass
large strings to a builder, since most operating systems impose a

View file

@ -35,19 +35,19 @@ steps:</para>
<para>When Nix runs a builder, it initially completely clears the
environment (except for the attributes declared in the
derivation). For instance, the <envar>PATH</envar> variable is
derivation). For instance, the <literal>PATH</literal> variable is
empty<footnote><para>Actually, it's initialised to
<filename>/path-not-set</filename> to prevent Bash from setting it
to a default value.</para></footnote>. This is done to prevent
undeclared inputs from being used in the build process. If for
example the <envar>PATH</envar> contained
example the <literal>PATH</literal> contained
<filename>/usr/bin</filename>, then you might accidentally use
<filename>/usr/bin/gcc</filename>.</para>
<para>So the first step is to set up the environment. This is
done by calling the <filename>setup</filename> script of the
standard environment. The environment variable
<envar>stdenv</envar> points to the location of the standard
<literal>stdenv</literal> points to the location of the standard
environment being used. (It wasn't specified explicitly as an
attribute in <xref linkend='ex-hello-nix' />, but
<varname>mkDerivation</varname> adds it automatically.)</para>
@ -57,7 +57,7 @@ steps:</para>
<callout arearefs='ex-hello-builder-co-2'>
<para>Since Hello needs Perl, we have to make sure that Perl is in
the <envar>PATH</envar>. The <envar>perl</envar> environment
the <literal>PATH</literal>. The <literal>perl</literal> environment
variable points to the location of the Perl package (since it
was passed in as an attribute to the derivation), so
<filename><replaceable>$perl</replaceable>/bin</filename> is the
@ -70,7 +70,7 @@ steps:</para>
<para>Now we have to unpack the sources. The
<varname>src</varname> attribute was bound to the result of
fetching the Hello source tarball from the network, so the
<envar>src</envar> environment variable points to the location in
<literal>src</literal> environment variable points to the location in
the Nix store to which the tarball was downloaded. After
unpacking, we <command>cd</command> to the resulting source
directory.</para>
@ -93,7 +93,7 @@ steps:</para>
<filename>/nix/store/9a54ba97fb71b65fda531012d0443ce2-hello-2.1.1</filename>.
Nix computes this path by cryptographically hashing all attributes
of the derivation. The path is passed to the builder through the
<envar>out</envar> environment variable. So here we give
<literal>out</literal> environment variable. So here we give
<filename>configure</filename> the parameter
<literal>--prefix=$out</literal> to cause Hello to be installed in
the expected location.</para>
@ -103,7 +103,7 @@ steps:</para>
<callout arearefs='ex-hello-builder-co-5'>
<para>Finally we build Hello (<literal>make</literal>) and install
it into the location specified by <envar>out</envar>
it into the location specified by <literal>out</literal>
(<literal>make install</literal>).</para>
</callout>

View file

@ -122,7 +122,7 @@ the Nixpkgs manual for details.</para>
<itemizedlist>
<listitem><para>A temporary directory is created under the directory
specified by <envar>TMPDIR</envar> (default
specified by <literal>TMPDIR</literal> (default
<filename>/tmp</filename>) where the build will take place. The
current directory is changed to this directory.</para></listitem>
@ -133,29 +133,29 @@ the Nixpkgs manual for details.</para>
<itemizedlist>
<listitem><para><envar>NIX_BUILD_TOP</envar> contains the path of
<listitem><para><literal>NIX_BUILD_TOP</literal> contains the path of
the temporary directory for this build.</para></listitem>
<listitem><para>Also, <envar>TMPDIR</envar>,
<envar>TEMPDIR</envar>, <envar>TMP</envar>, <envar>TEMP</envar>
<listitem><para>Also, <literal>TMPDIR</literal>,
<literal>TEMPDIR</literal>, <literal>TMP</literal>, <literal>TEMP</literal>
are set to point to the temporary directory. This is to prevent
the builder from accidentally writing temporary files anywhere
else. Doing so might cause interference by other
processes.</para></listitem>
<listitem><para><envar>PATH</envar> is set to
<listitem><para><literal>PATH</literal> is set to
<filename>/path-not-set</filename> to prevent shells from
initialising it to their built-in default value.</para></listitem>
<listitem><para><envar>HOME</envar> is set to
<listitem><para><literal>HOME</literal> is set to
<filename>/homeless-shelter</filename> to prevent programs from
using <filename>/etc/passwd</filename> or the like to find the
user's home directory, which could cause impurity. Usually, when
<envar>HOME</envar> is set, it is used as the location of the home
<literal>HOME</literal> is set, it is used as the location of the home
directory, even if it points to a non-existent
path.</para></listitem>
<listitem><para><envar>NIX_STORE</envar> is set to the path of the
<listitem><para><literal>NIX_STORE</literal> is set to the path of the
top-level Nix store directory (typically,
<filename>/nix/store</filename>).</para></listitem>

View file

@ -38,18 +38,18 @@ genericBuild <co xml:id='ex-hello-builder2-co-3' /></programlisting>
<callout arearefs='ex-hello-builder2-co-1'>
<para>The <envar>buildInputs</envar> variable tells
<para>The <literal>buildInputs</literal> variable tells
<filename>setup</filename> to use the indicated packages as
<quote>inputs</quote>. This means that if a package provides a
<filename>bin</filename> subdirectory, it's added to
<envar>PATH</envar>; if it has a <filename>include</filename>
<literal>PATH</literal>; if it has a <filename>include</filename>
subdirectory, it's added to GCC's header search path; and so
on.<footnote><para>How does it work? <filename>setup</filename>
tries to source the file
<filename><replaceable>pkg</replaceable>/nix-support/setup-hook</filename>
of all dependencies. These “setup hooks” can then set up whatever
environment variables they want; for instance, the setup hook for
Perl sets the <envar>PERL5LIB</envar> environment variable to
Perl sets the <literal>PERL5LIB</literal> environment variable to
contain the <filename>lib/site_perl</filename> directories of all
inputs.</para></footnote>
</para>
@ -78,7 +78,7 @@ genericBuild <co xml:id='ex-hello-builder2-co-3' /></programlisting>
</calloutlist>
<para>Discerning readers will note that the
<envar>buildInputs</envar> could just as well have been set in the Nix
<literal>buildInputs</literal> could just as well have been set in the Nix
expression, like this:
<programlisting>

View file

@ -176,7 +176,7 @@ stdenv.mkDerivation {
<para>Paths can also be specified between angle brackets, e.g.
<literal>&lt;nixpkgs&gt;</literal>. This means that the directories
listed in the environment variable
<envar linkend="env-NIX_PATH">NIX_PATH</envar> will be searched
<envar linkend="env-NIX_PATH">NIX_PATH</literal> will be searched
for the given file or directory name.
</para>

View file

@ -45,7 +45,7 @@ name.</para>
<para>Nix has transactional semantics. Once a build finishes
successfully, Nix makes a note of this in its database: it registers
that the path denoted by <envar>out</envar> is now
that the path denoted by <literal>out</literal> is now
<quote>valid</quote>. If you try to build the derivation again, Nix
will see that the path is already valid and finish immediately. If a
build fails, either because it returns a non-zero exit code, because