summaryrefslogtreecommitdiffstats
path: root/doc/stdenv.xml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/stdenv.xml')
-rw-r--r--doc/stdenv.xml4129
1 files changed, 2301 insertions, 1828 deletions
diff --git a/doc/stdenv.xml b/doc/stdenv.xml
index 2a3316b8d018..d5028c51cd51 100644
--- a/doc/stdenv.xml
+++ b/doc/stdenv.xml
@@ -1,27 +1,24 @@
<chapter xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xml:id="chap-stdenv">
-
-<title>The Standard Environment</title>
-
-
-<para>The standard build environment in the Nix Packages collection
-provides an environment for building Unix packages that does a lot of
-common build tasks automatically. In fact, for Unix packages that use
-the standard <literal>./configure; make; make install</literal> build
-interface, you don’t need to write a build script at all; the standard
-environment does everything automatically. If
-<literal>stdenv</literal> doesn’t do what you need automatically, you
-can easily customise or override the various build phases.</para>
-
-
-<section xml:id="sec-using-stdenv"><title>Using
-<literal>stdenv</literal></title>
-
-<para>To build a package with the standard environment, you use the
-function <varname>stdenv.mkDerivation</varname>, instead of the
-primitive built-in function <varname>derivation</varname>, e.g.
-
+ <title>The Standard Environment</title>
+ <para>
+ The standard build environment in the Nix Packages collection provides an
+ environment for building Unix packages that does a lot of common build tasks
+ automatically. In fact, for Unix packages that use the standard
+ <literal>./configure; make; make install</literal> build interface, you
+ don’t need to write a build script at all; the standard environment does
+ everything automatically. If <literal>stdenv</literal> doesn’t do what you
+ need automatically, you can easily customise or override the various build
+ phases.
+ </para>
+ <section xml:id="sec-using-stdenv">
+ <title>Using <literal>stdenv</literal></title>
+
+ <para>
+ To build a package with the standard environment, you use the function
+ <varname>stdenv.mkDerivation</varname>, instead of the primitive built-in
+ function <varname>derivation</varname>, e.g.
<programlisting>
stdenv.mkDerivation {
name = "libfoo-1.2.3";
@@ -30,39 +27,35 @@ stdenv.mkDerivation {
sha256 = "0x2g1jqygyr5wiwg4ma1nd7w4ydpy82z9gkcv8vh2v8dn3y58v5m";
};
}</programlisting>
-
-(<varname>stdenv</varname> needs to be in scope, so if you write this
-in a separate Nix expression from
-<filename>pkgs/all-packages.nix</filename>, you need to pass it as a
-function argument.) Specifying a <varname>name</varname> and a
-<varname>src</varname> is the absolute minimum you need to do. Many
-packages have dependencies that are not provided in the standard
-environment. It’s usually sufficient to specify those dependencies in
-the <varname>buildInputs</varname> attribute:
-
+ (<varname>stdenv</varname> needs to be in scope, so if you write this in a
+ separate Nix expression from <filename>pkgs/all-packages.nix</filename>, you
+ need to pass it as a function argument.) Specifying a
+ <varname>name</varname> and a <varname>src</varname> is the absolute minimum
+ you need to do. Many packages have dependencies that are not provided in the
+ standard environment. It’s usually sufficient to specify those
+ dependencies in the <varname>buildInputs</varname> attribute:
<programlisting>
stdenv.mkDerivation {
name = "libfoo-1.2.3";
...
buildInputs = [libbar perl ncurses];
}</programlisting>
-
-This attribute ensures that the <filename>bin</filename>
-subdirectories of these packages appear in the <envar>PATH</envar>
-environment variable during the build, that their
-<filename>include</filename> subdirectories are searched by the C
-compiler, and so on. (See <xref linkend="ssec-setup-hooks"/> for
-details.)</para>
-
-<para>Often it is necessary to override or modify some aspect of the
-build. To make this easier, the standard environment breaks the
-package build into a number of <emphasis>phases</emphasis>, all of
-which can be overridden or modified individually: unpacking the
-sources, applying patches, configuring, building, and installing.
-(There are some others; see <xref linkend="sec-stdenv-phases"/>.)
-For instance, a package that doesn’t supply a makefile but instead has
-to be compiled “manually” could be handled like this:
-
+ This attribute ensures that the <filename>bin</filename> subdirectories of
+ these packages appear in the <envar>PATH</envar> environment variable during
+ the build, that their <filename>include</filename> subdirectories are
+ searched by the C compiler, and so on. (See
+ <xref linkend="ssec-setup-hooks"/> for details.)
+ </para>
+
+ <para>
+ Often it is necessary to override or modify some aspect of the build. To
+ make this easier, the standard environment breaks the package build into a
+ number of <emphasis>phases</emphasis>, all of which can be overridden or
+ modified individually: unpacking the sources, applying patches, configuring,
+ building, and installing. (There are some others; see
+ <xref linkend="sec-stdenv-phases"/>.) For instance, a package that doesn’t
+ supply a makefile but instead has to be compiled “manually” could be
+ handled like this:
<programlisting>
stdenv.mkDerivation {
name = "fnord-4.5";
@@ -75,35 +68,33 @@ stdenv.mkDerivation {
cp foo $out/bin
'';
}</programlisting>
-
-(Note the use of <literal>''</literal>-style string literals, which
-are very convenient for large multi-line script fragments because they
-don’t need escaping of <literal>"</literal> and <literal>\</literal>,
-and because indentation is intelligently removed.)</para>
-
-<para>There are many other attributes to customise the build. These
-are listed in <xref linkend="ssec-stdenv-attributes"/>.</para>
-
-<para>While the standard environment provides a generic builder, you
-can still supply your own build script:
-
+ (Note the use of <literal>''</literal>-style string literals, which are very
+ convenient for large multi-line script fragments because they don’t need
+ escaping of <literal>"</literal> and <literal>\</literal>, and because
+ indentation is intelligently removed.)
+ </para>
+
+ <para>
+ There are many other attributes to customise the build. These are listed in
+ <xref linkend="ssec-stdenv-attributes"/>.
+ </para>
+
+ <para>
+ While the standard environment provides a generic builder, you can still
+ supply your own build script:
<programlisting>
stdenv.mkDerivation {
name = "libfoo-1.2.3";
...
builder = ./builder.sh;
}</programlisting>
-
-where the builder can do anything it wants, but typically starts with
-
+ where the builder can do anything it wants, but typically starts with
<programlisting>
source $stdenv/setup
</programlisting>
-
-to let <literal>stdenv</literal> set up the environment (e.g., process
-the <varname>buildInputs</varname>). If you want, you can still use
-<literal>stdenv</literal>’s generic builder:
-
+ to let <literal>stdenv</literal> set up the environment (e.g., process the
+ <varname>buildInputs</varname>). If you want, you can still use
+ <literal>stdenv</literal>’s generic builder:
<programlisting>
source $stdenv/setup
@@ -119,116 +110,186 @@ installPhase() {
genericBuild
</programlisting>
-
-</para>
-
-</section>
-
-
-<section xml:id="sec-tools-of-stdenv"><title>Tools provided by
-<literal>stdenv</literal></title>
-
-<para>The standard environment provides the following packages:
-
-<itemizedlist>
-
- <listitem><para>The GNU C Compiler, configured with C and C++
- support.</para></listitem>
-
- <listitem><para>GNU coreutils (contains a few dozen standard Unix
- commands).</para></listitem>
-
- <listitem><para>GNU findutils (contains
- <command>find</command>).</para></listitem>
-
- <listitem><para>GNU diffutils (contains <command>diff</command>,
- <command>cmp</command>).</para></listitem>
-
- <listitem><para>GNU <command>sed</command>.</para></listitem>
-
- <listitem><para>GNU <command>grep</command>.</para></listitem>
-
- <listitem><para>GNU <command>awk</command>.</para></listitem>
-
- <listitem><para>GNU <command>tar</command>.</para></listitem>
-
- <listitem><para><command>gzip</command>, <command>bzip2</command>
- and <command>xz</command>.</para></listitem>
-
- <listitem><para>GNU Make. It has been patched to provide
- <quote>nested</quote> output that can be fed into the
- <command>nix-log2xml</command> command and
- <command>log2html</command> stylesheet to create a structured,
- readable output of the build steps performed by
- Make.</para></listitem>
-
- <listitem><para>Bash. This is the shell used for all builders in
- the Nix Packages collection. Not using <command>/bin/sh</command>
- removes a large source of portability problems.</para></listitem>
-
- <listitem><para>The <command>patch</command>
- command.</para></listitem>
-
-</itemizedlist>
-
-</para>
-
-<para>On Linux, <literal>stdenv</literal> also includes the
-<command>patchelf</command> utility.</para>
-
-</section>
-
-
-<section xml:id="ssec-stdenv-dependencies"><title>Specifying dependencies</title>
-
-<para>
- As described in the Nix manual, almost any <filename>*.drv</filename> store path in a derivation's attribute set will induce a dependency on that derivation.
- <varname>mkDerivation</varname>, however, takes a few attributes intended to, between them, include all the dependencies of a package.
- This is done both for structure and consistency, but also so that certain other setup can take place.
- For example, certain dependencies need their bin directories added to the <envar>PATH</envar>.
- That is built-in, but other setup is done via a pluggable mechanism that works in conjunction with these dependency attributes.
- See <xref linkend="ssec-setup-hooks"/> for details.
-</para>
-<para>
- Dependencies can be broken down along three axes: their host and target platforms relative to the new derivation's, and whether they are propagated.
- The platform distinctions are motivated by cross compilation; see <xref linkend="chap-cross"/> for exactly what each platform means.
- <footnote><para>
- The build platform is ignored because it is a mere implementation detail of the package satisfying the dependency:
- As a general programming principle, dependencies are always <emphasis>specified</emphasis> as interfaces, not concrete implementation.
- </para></footnote>
- But even if one is not cross compiling, the platforms imply whether or not the dependency is needed at run-time or build-time, a concept that makes perfect sense outside of cross compilation.
- For now, the run-time/build-time distinction is just a hint for mental clarity, but in the future it perhaps could be enforced.
-</para>
-<para>
- The extension of <envar>PATH</envar> with dependencies, alluded to above, proceeds according to the relative platforms alone.
- The process is carried out only for dependencies whose host platform matches the new derivation's build platform–i.e. which run on the platform where the new derivation will be built.
- <footnote><para>
- Currently, that means for native builds all dependencies are put on the <envar>PATH</envar>.
- But in the future that may not be the case for sake of matching cross:
- the platforms would be assumed to be unique for native and cross builds alike, so only the <varname>depsBuild*</varname> and <varname>nativeBuildDependencies</varname> dependencies would affect the <envar>PATH</envar>.
- </para></footnote>
- For each dependency <replaceable>dep</replaceable> of those dependencies, <filename><replaceable>dep</replaceable>/bin</filename>, if present, is added to the <envar>PATH</envar> environment variable.
-</para>
-<para>
- The dependency is propagated when it forces some of its other-transitive (non-immediate) downstream dependencies to also take it on as an immediate dependency.
- Nix itself already takes a package's transitive dependencies into account, but this propagation ensures nixpkgs-specific infrastructure like setup hooks (mentioned above) also are run as if the propagated dependency.
-</para>
-<para>
- It is important to note dependencies are not necessary propagated as the same sort of dependency that they were before, but rather as the corresponding sort so that the platform rules still line up.
- The exact rules for dependency propagation can be given by assigning each sort of dependency two integers based one how it's host and target platforms are offset from the depending derivation's platforms.
- Those offsets are given are given below in the descriptions of each dependency list attribute.
- Algorithmically, we traverse propagated inputs, accumulating every propagated dep's propagated deps and adjusting them to account for the "shift in perspective" described by the current dep's platform offsets.
- This results in sort a transitive closure of the dependency relation, with the offsets being approximately summed when two dependency links are combined.
- We also prune transitive deps whose combined offsets go out-of-bounds, which can be viewed as a filter over that transitive closure removing dependencies that are blatantly absurd.
-</para>
-<para>
- We can define the process precisely with <link xlink:href="https://en.wikipedia.org/wiki/Natural_deduction">Natural Deduction</link> using the inference rules.
- This probably seems a bit obtuse, but so is the bash code that actually implements it!
- <footnote><para>
- The <function>findInputs</function> function, currently residing in <filename>pkgs/stdenv/generic/setup.sh</filename>, implements the propagation logic.
- </para></footnote>
- They're confusing in very different ways so...hopefully if something doesn't make sense in one presentation, it does in the other!
- <programlisting>
+ </para>
+ </section>
+ <section xml:id="sec-tools-of-stdenv">
+ <title>Tools provided by <literal>stdenv</literal></title>
+
+ <para>
+ The standard environment provides the following packages:
+ <itemizedlist>
+ <listitem>
+ <para>
+ The GNU C Compiler, configured with C and C++ support.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ GNU coreutils (contains a few dozen standard Unix commands).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ GNU findutils (contains <command>find</command>).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ GNU diffutils (contains <command>diff</command>, <command>cmp</command>).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ GNU <command>sed</command>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ GNU <command>grep</command>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ GNU <command>awk</command>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ GNU <command>tar</command>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <command>gzip</command>, <command>bzip2</command> and
+ <command>xz</command>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ GNU Make. It has been patched to provide <quote>nested</quote> output
+ that can be fed into the <command>nix-log2xml</command> command and
+ <command>log2html</command> stylesheet to create a structured, readable
+ output of the build steps performed by Make.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Bash. This is the shell used for all builders in the Nix Packages
+ collection. Not using <command>/bin/sh</command> removes a large source
+ of portability problems.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ The <command>patch</command> command.
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+
+ <para>
+ On Linux, <literal>stdenv</literal> also includes the
+ <command>patchelf</command> utility.
+ </para>
+ </section>
+ <section xml:id="ssec-stdenv-dependencies">
+ <title>Specifying dependencies</title>
+
+ <para>
+ As described in the Nix manual, almost any <filename>*.drv</filename> store
+ path in a derivation's attribute set will induce a dependency on that
+ derivation. <varname>mkDerivation</varname>, however, takes a few attributes
+ intended to, between them, include all the dependencies of a package. This
+ is done both for structure and consistency, but also so that certain other
+ setup can take place. For example, certain dependencies need their bin
+ directories added to the <envar>PATH</envar>. That is built-in, but other
+ setup is done via a pluggable mechanism that works in conjunction with these
+ dependency attributes. See <xref linkend="ssec-setup-hooks"/> for details.
+ </para>
+
+ <para>
+ Dependencies can be broken down along three axes: their host and target
+ platforms relative to the new derivation's, and whether they are propagated.
+ The platform distinctions are motivated by cross compilation; see
+ <xref linkend="chap-cross"/> for exactly what each platform means.
+ <footnote>
+ <para>
+ The build platform is ignored because it is a mere implementation detail
+ of the package satisfying the dependency: As a general programming
+ principle, dependencies are always <emphasis>specified</emphasis> as
+ interfaces, not concrete implementation.
+ </para>
+ </footnote>
+ But even if one is not cross compiling, the platforms imply whether or not
+ the dependency is needed at run-time or build-time, a concept that makes
+ perfect sense outside of cross compilation. For now, the run-time/build-time
+ distinction is just a hint for mental clarity, but in the future it perhaps
+ could be enforced.
+ </para>
+
+ <para>
+ The extension of <envar>PATH</envar> with dependencies, alluded to above,
+ proceeds according to the relative platforms alone. The process is carried
+ out only for dependencies whose host platform matches the new derivation's
+ build platform–i.e. which run on the platform where the new derivation
+ will be built.
+ <footnote>
+ <para>
+ Currently, that means for native builds all dependencies are put on the
+ <envar>PATH</envar>. But in the future that may not be the case for sake
+ of matching cross: the platforms would be assumed to be unique for native
+ and cross builds alike, so only the <varname>depsBuild*</varname> and
+ <varname>nativeBuildDependencies</varname> dependencies would affect the
+ <envar>PATH</envar>.
+ </para>
+ </footnote>
+ For each dependency <replaceable>dep</replaceable> of those dependencies,
+ <filename><replaceable>dep</replaceable>/bin</filename>, if present, is
+ added to the <envar>PATH</envar> environment variable.
+ </para>
+
+ <para>
+ The dependency is propagated when it forces some of its other-transitive
+ (non-immediate) downstream dependencies to also take it on as an immediate
+ dependency. Nix itself already takes a package's transitive dependencies
+ into account, but this propagation ensures nixpkgs-specific infrastructure
+ like setup hooks (mentioned above) also are run as if the propagated
+ dependency.
+ </para>
+
+ <para>
+ It is important to note dependencies are not necessary propagated as the
+ same sort of dependency that they were before, but rather as the
+ corresponding sort so that the platform rules still line up. The exact rules
+ for dependency propagation can be given by assigning each sort of dependency
+ two integers based one how it's host and target platforms are offset from
+ the depending derivation's platforms. Those offsets are given are given
+ below in the descriptions of each dependency list attribute.
+ Algorithmically, we traverse propagated inputs, accumulating every
+ propagated dep's propagated deps and adjusting them to account for the
+ "shift in perspective" described by the current dep's platform offsets. This
+ results in sort a transitive closure of the dependency relation, with the
+ offsets being approximately summed when two dependency links are combined.
+ We also prune transitive deps whose combined offsets go out-of-bounds, which
+ can be viewed as a filter over that transitive closure removing dependencies
+ that are blatantly absurd.
+ </para>
+
+ <para>
+ We can define the process precisely with
+ <link xlink:href="https://en.wikipedia.org/wiki/Natural_deduction">Natural
+ Deduction</link> using the inference rules. This probably seems a bit
+ obtuse, but so is the bash code that actually implements it!
+ <footnote>
+ <para>
+ The <function>findInputs</function> function, currently residing in
+ <filename>pkgs/stdenv/generic/setup.sh</filename>, implements the
+ propagation logic.
+ </para>
+ </footnote>
+ They're confusing in very different ways so...hopefully if something doesn't
+ make sense in one presentation, it does in the other!
+<programlisting>
let mapOffset(h, t, i) = i + (if i &lt;= 0 then h else t - 1)
propagated-dep(h0, t0, A, B)
@@ -239,7 +300,7 @@ h0 + t1 in {-1, 0, 1}
propagated-dep(mapOffset(h0, t0, h1),
mapOffset(h0, t0, t1),
A, C)</programlisting>
- <programlisting>
+<programlisting>
let mapOffset(h, t, i) = i + (if i &lt;= 0 then h else t - 1)
dep(h0, _, A, B)
@@ -250,1139 +311,1450 @@ h0 + t1 in {-1, 0, -1}
propagated-dep(mapOffset(h0, t0, h1),
mapOffset(h0, t0, t1),
A, C)</programlisting>
- <programlisting>
+<programlisting>
propagated-dep(h, t, A, B)
-------------------------------------- Propagated deps count as deps
dep(h, t, A, B)</programlisting>
- Some explanation of this monstrosity is in order.
- In the common case, the target offset of a dependency is the successor to the target offset: <literal>t = h + 1</literal>.
- That means that:
- <programlisting>
+ Some explanation of this monstrosity is in order. In the common case, the
+ target offset of a dependency is the successor to the target offset:
+ <literal>t = h + 1</literal>. That means that:
+<programlisting>
let f(h, t, i) = i + (if i &lt;= 0 then h else t - 1)
let f(h, h + 1, i) = i + (if i &lt;= 0 then h else (h + 1) - 1)
let f(h, h + 1, i) = i + (if i &lt;= 0 then h else h)
let f(h, h + 1, i) = i + h
</programlisting>
- This is where the "sum-like" comes from above:
- We can just sum all the host offset to get the host offset of the transitive dependency.
- The target offset is the transitive dep is simply the host offset + 1, just as it was with the dependencies composed to make this transitive one;
- it can be ignored as it doesn't add any new information.
-</para>
-<para>
- Because of the bounds checks, the uncommon cases are <literal>h = t</literal> and <literal>h + 2 = t</literal>.
- In the former case, the motivation for <function>mapOffset</function> is that since its host and target platforms are the same, no transitive dep of it should be able to "discover" an offset greater than its reduced target offsets.
- <function>mapOffset</function> effectively "squashes" all its transitive dependencies' offsets so that none will ever be greater than the target offset of the original <literal>h = t</literal> package.
- In the other case, <literal>h + 1</literal> is skipped over between the host and target offsets.
- Instead of squashing the offsets, we need to "rip" them apart so no transitive dependencies' offset is that one.
-</para>
-<para>
-Overall, the unifying theme here is that propagation shouldn't be introducing transitive dependencies involving platforms the needing package is unaware of.
-The offset bounds checking and definition of <function>mapOffset</function> together ensure that this is the case.
-Discovering a new offset is discovering a new platform, and since those platforms weren't in the derivation "spec" of the needing package, they cannot be relevant.
-From a capability perspective, we can imagine that the host and target platforms of a package are the capabilities a package requires, and the depending package must provide the capability to the dependency.
-</para>
-
-<variablelist>
- <title>Variables specifying dependencies</title>
-
+ This is where the "sum-like" comes from above: We can just sum all the host
+ offset to get the host offset of the transitive dependency. The target
+ offset is the transitive dep is simply the host offset + 1, just as it was
+ with the dependencies composed to make this transitive one; it can be
+ ignored as it doesn't add any new information.
+ </para>
+
+ <para>
+ Because of the bounds checks, the uncommon cases are <literal>h =
+ t</literal> and <literal>h + 2 = t</literal>. In the former case, the
+ motivation for <function>mapOffset</function> is that since its host and
+ target platforms are the same, no transitive dep of it should be able to
+ "discover" an offset greater than its reduced target offsets.
+ <function>mapOffset</function> effectively "squashes" all its transitive
+ dependencies' offsets so that none will ever be greater than the target
+ offset of the original <literal>h = t</literal> package. In the other case,
+ <literal>h + 1</literal> is skipped over between the host and target
+ offsets. Instead of squashing the offsets, we need to "rip" them apart so no
+ transitive dependencies' offset is that one.
+ </para>
+
+ <para>
+ Overall, the unifying theme here is that propagation shouldn't be
+ introducing transitive dependencies involving platforms the needing package
+ is unaware of. The offset bounds checking and definition of
+ <function>mapOffset</function> together ensure that this is the case.
+ Discovering a new offset is discovering a new platform, and since those
+ platforms weren't in the derivation "spec" of the needing package, they
+ cannot be relevant. From a capability perspective, we can imagine that the
+ host and target platforms of a package are the capabilities a package
+ requires, and the depending package must provide the capability to the
+ dependency.
+ </para>
+
+ <variablelist>
+ <title>Variables specifying dependencies</title>
<varlistentry>
- <term><varname>depsBuildBuild</varname></term>
- <listitem>
- <para>
- A list of dependencies whose host and target platforms are the new derivation's build platform.
- This means a <literal>-1</literal> host and <literal>-1</literal> target offset from the new derivation's platforms.
- They are programs/libraries used at build time that furthermore produce programs/libraries also used at build time.
- If the dependency doesn't care about the target platform (i.e. isn't a compiler or similar tool), put it in <varname>nativeBuildInputs</varname>instead.
- The most common use for this <literal>buildPackages.stdenv.cc</literal>, the default C compiler for this role.
- That example crops up more than one might think in old commonly used C libraries.
- </para>
- <para>
- Since these packages are able to be run at build time, that are always added to the <envar>PATH</envar>, as described above.
- But since these packages are only guaranteed to be able to run then, they shouldn't persist as run-time dependencies.
- This isn't currently enforced, but could be in the future.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term><varname>nativeBuildInputs</varname></term>
+ <term><varname>depsBuildBuild</varname>
+ </term>
<listitem>
- <para>
- A list of dependencies whose host platform is the new derivation's build platform, and target platform is the new derivation's host platform.
- This means a <literal>-1</literal> host offset and <literal>0</literal> target offset from the new derivation's platforms.
- They are programs/libraries used at build time that, if they are a compiler or similar tool, produce code to run at run time—i.e. tools used to build the new derivation.
- If the dependency doesn't care about the target platform (i.e. isn't a compiler or similar tool), put it here, rather than in <varname>depsBuildBuild</varname> or <varname>depsBuildTarget</varname>.
- This would be called <varname>depsBuildHost</varname> but for historical continuity.
- </para>
- <para>
- Since these packages are able to be run at build time, that are added to the <envar>PATH</envar>, as described above.
- But since these packages only are guaranteed to be able to run then, they shouldn't persist as run-time dependencies.
- This isn't currently enforced, but could be in the future.
- </para>
+ <para>
+ A list of dependencies whose host and target platforms are the new
+ derivation's build platform. This means a <literal>-1</literal> host and
+ <literal>-1</literal> target offset from the new derivation's platforms.
+ They are programs/libraries used at build time that furthermore produce
+ programs/libraries also used at build time. If the dependency doesn't
+ care about the target platform (i.e. isn't a compiler or similar tool),
+ put it in <varname>nativeBuildInputs</varname>instead. The most common
+ use for this <literal>buildPackages.stdenv.cc</literal>, the default C
+ compiler for this role. That example crops up more than one might think
+ in old commonly used C libraries.
+ </para>
+ <para>
+ Since these packages are able to be run at build time, that are always
+ added to the <envar>PATH</envar>, as described above. But since these
+ packages are only guaranteed to be able to run then, they shouldn't
+ persist as run-time dependencies. This isn't currently enforced, but
+ could be in the future.
+ </para>
</listitem>
- </varlistentry>
-
- <varlistentry>
- <term><varname>depsBuildTarget</varname></term>
+ </varlistentry>
+ <varlistentry>
+ <term><varname>nativeBuildInputs</varname>
+ </term>
<listitem>
- <para>
- A list of dependencies whose host platform is the new derivation's build platform, and target platform is the new derivation's target platform.
- This means a <literal>-1</literal> host offset and <literal>1</literal> target offset from the new derivation's platforms.
- They are programs used at build time that produce code to run at run with code produced by the depending package.
- Most commonly, these would tools used to build the runtime or standard library the currently-being-built compiler will inject into any code it compiles.
- In many cases, the currently-being built compiler is itself employed for that task, but when that compiler won't run (i.e. its build and host platform differ) this is not possible.
- Other times, the compiler relies on some other tool, like binutils, that is always built separately so the dependency is unconditional.
- </para>
- <para>
- This is a somewhat confusing dependency to wrap ones head around, and for good reason.
- As the only one where the platform offsets are not adjacent integers, it requires thinking of a bootstrapping stage <emphasis>two</emphasis> away from the current one.
- It and it's use-case go hand in hand and are both considered poor form:
- try not to need this sort dependency, and try not avoid building standard libraries / runtimes in the same derivation as the compiler produces code using them.
- Instead strive to build those like a normal library, using the newly-built compiler just as a normal library would.
- In short, do not use this attribute unless you are packaging a compiler and are sure it is needed.
+ <para>
+ A list of dependencies whose host platform is the new derivation's build
+ platform, and target platform is the new derivation's host platform. This
+ means a <literal>-1</literal> host offset and <literal>0</literal> target
+ offset from the new derivation's platforms. They are programs/libraries
+ used at build time that, if they are a compiler or similar tool, produce
+ code to run at run time—i.e. tools used to build the new derivation. If
+ the dependency doesn't care about the target platform (i.e. isn't a
+ compiler or similar tool), put it here, rather than in
+ <varname>depsBuildBuild</varname> or <varname>depsBuildTarget</varname>.
+ This would be called <varname>depsBuildHost</varname> but for historical
+ continuity.
</para>
<para>
- Since these packages are able to be run at build time, that are added to the <envar>PATH</envar>, as described above.
- But since these packages only are guaranteed to be able to run then, they shouldn't persist as run-time dependencies.
- This isn't currently enforced, but could be in the future.
+ Since these packages are able to be run at build time, that are added to
+ the <envar>PATH</envar>, as described above. But since these packages
+ only are guaranteed to be able to run then, they shouldn't persist as
+ run-time dependencies. This isn't currently enforced, but could be in the
+ future.
</para>
</listitem>
- </varlistentry>
-
- <varlistentry>
- <term><varname>depsHostHost</varname></term>
- <listitem><para>
- A list of dependencies whose host and target platforms match the new derivation's host platform.
- This means a both <literal>0</literal> host offset and <literal>0</literal> target offset from the new derivation's host platform.
- These are packages used at run-time to generate code also used at run-time.
- In practice, that would usually be tools used by compilers for metaprogramming/macro systems, or libraries used by the macros/metaprogramming code itself.
- It's always preferable to use a <varname>depsBuildBuild</varname> dependency in the derivation being built than a <varname>depsHostHost</varname> on the tool doing the building for this purpose.
- </para></listitem>
- </varlistentry>
-
- <varlistentry>
- <term><varname>buildInputs</varname></term>
+ </varlistentry>
+ <varlistentry>
+ <term><varname>depsBuildTarget</varname>
+ </term>
<listitem>
- <para>
- A list of dependencies whose host platform and target platform match the new derivation's.
- This means a <literal>0</literal> host offset and <literal>1</literal> target offset from the new derivation's host platform.
- This would be called <varname>depsHostTarget</varname> but for historical continuity.
- If the dependency doesn't care about the target platform (i.e. isn't a compiler or similar tool), put it here, rather than in <varname>depsBuildBuild</varname>.
- </para>
- <para>
- These often are programs/libraries used by the new derivation at <emphasis>run</emphasis>-time, but that isn't always the case.
- For example, the machine code in a statically linked library is only used at run time, but the derivation containing the library is only needed at build time.
- Even in the dynamic case, the library may also be needed at build time to appease the linker.
- </para>
+ <para>
+ A list of dependencies whose host platform is the new derivation's build
+ platform, and target platform is the new derivation's target platform.
+ This means a <literal>-1</literal> host offset and <literal>1</literal>
+ target offset from the new derivation's platforms. They are programs used
+ at build time that produce code to run at run with code produced by the
+ depending package. Most commonly, these would tools used to build the
+ runtime or standard library the currently-being-built compiler will
+ inject into any code it compiles. In many cases, the currently-being
+ built compiler is itself employed for that task, but when that compiler
+ won't run (i.e. its build and host platform differ) this is not possible.
+ Other times, the compiler relies on some other tool, like binutils, that
+ is always built separately so the dependency is unconditional.
+ </para>
+ <para>
+ This is a somewhat confusing dependency to wrap ones head around, and for
+ good reason. As the only one where the platform offsets are not adjacent
+ integers, it requires thinking of a bootstrapping stage
+ <emphasis>two</emphasis> away from the current one. It and it's use-case
+ go hand in hand and are both considered poor form: try not to need this
+ sort dependency, and try not avoid building standard libraries / runtimes
+ in the same derivation as the compiler produces code using them. Instead
+ strive to build those like a normal library, using the newly-built
+ compiler just as a normal library would. In short, do not use this
+ attribute unless you are packaging a compiler and are sure it is needed.
+ </para>
+ <para>
+ Since these packages are able to be run at build time, that are added to
+ the <envar>PATH</envar>, as described above. But since these packages
+ only are guaranteed to be able to run then, they shouldn't persist as
+ run-time dependencies. This isn't currently enforced, but could be in the
+ future.
+ </para>
</listitem>
- </varlistentry>
-
- <varlistentry>
- <term><varname>depsTargetTarget</varname></term>
- <listitem><para>
- A list of dependencies whose host platform matches the new derivation's target platform.</