@@ -3,22 +3,13 @@
33 xml:id="chap-stdenv">
44 <title>The Standard Environment</title>
55 <para>
6− The standard build environment in the Nix Packages collection provides an
7− environment for building Unix packages that does a lot of common build tasks
8− automatically. In fact, for Unix packages that use the standard
9− <literal>./configure; make; make install</literal> build interface, you
10− don’t need to write a build script at all; the standard environment does
11− everything automatically. If <literal>stdenv</literal> doesn’t do what you
12− need automatically, you can easily customise or override the various build
13− phases.
6+ 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.
147 </para>
158 <section xml:id="sec-using-stdenv">
169 <title>Using <literal>stdenv</literal></title>
1710
1811 <para>
19− To build a package with the standard environment, you use the function
20− <varname>stdenv.mkDerivation</varname>, instead of the primitive built-in
21− function <varname>derivation</varname>, e.g.
12+ 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.
2213<programlisting>
2314stdenv.mkDerivation {
2415 name = "libfoo-1.2.3";
@@ -27,17 +18,7 @@ stdenv.mkDerivation {
2718 sha256 = "0x2g1jqygyr5wiwg4ma1nd7w4ydpy82z9gkcv8vh2v8dn3y58v5m";
2819 };
2920}</programlisting>
30− (<varname>stdenv</varname> needs to be in scope, so if you write this in a
31− separate Nix expression from <filename>pkgs/all-packages.nix</filename>, you
32− need to pass it as a function argument.) Specifying a
33− <varname>name</varname> and a <varname>src</varname> is the absolute minimum
34− Nix requires. For convenience, you can also use <varname>pname</varname> and
35− <varname>version</varname> attributes and <literal>mkDerivation</literal>
36− will automatically set <varname>name</varname> to
37− <literal>"${pname}-${version}"</literal> by default. Since
38− <link xlink:href="https://github.com/NixOS/rfcs/pull/35">RFC 0035</link>,
39− this is preferred for packages in Nixpkgs, as it allows us to reuse the
40− version easily:
21+ (<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 Nix requires. For convenience, you can also use <varname>pname</varname> and <varname>version</varname> attributes and <literal>mkDerivation</literal> will automatically set <varname>name</varname> to <literal>"${pname}-${version}"</literal> by default. Since <link xlink:href="https://github.com/NixOS/rfcs/pull/35">RFC 0035</link>, this is preferred for packages in Nixpkgs, as it allows us to reuse the version easily:
4122<programlisting>
4223stdenv.mkDerivation rec {
4324 pname = "libfoo";
@@ -50,31 +31,18 @@ stdenv.mkDerivation rec {
5031 </para>
5132
5233 <para>
53− Many packages have dependencies that are not provided in the standard
54− environment. It’s usually sufficient to specify those dependencies in the
55− <varname>buildInputs</varname> attribute:
34+ 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:
5635<programlisting>
5736stdenv.mkDerivation {
5837 name = "libfoo-1.2.3";
5938 ...
6039 buildInputs = [libbar perl ncurses];
6140}</programlisting>
62− This attribute ensures that the <filename>bin</filename> subdirectories of
63− these packages appear in the <envar>PATH</envar> environment variable during
64− the build, that their <filename>include</filename> subdirectories are
65− searched by the C compiler, and so on. (See
66− <xref linkend="ssec-setup-hooks"/> for details.)
41+ 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.)
6742 </para>
6843
6944 <para>
70− Often it is necessary to override or modify some aspect of the build. To
71− make this easier, the standard environment breaks the package build into a
72− number of <emphasis>phases</emphasis>, all of which can be overridden or
73− modified individually: unpacking the sources, applying patches, configuring,
74− building, and installing. (There are some others; see
75− <xref linkend="sec-stdenv-phases"/>.) For instance, a package that doesn’t
76− supply a makefile but instead has to be compiled “manually” could be
77− handled like this:
45+ 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:
7846<programlisting>
7947stdenv.mkDerivation {
8048 name = "fnord-4.5";
@@ -87,20 +55,15 @@ stdenv.mkDerivation {
8755 cp foo $out/bin
8856 '';
8957}</programlisting>
90− (Note the use of <literal>''</literal>-style string literals, which are very
91− convenient for large multi-line script fragments because they don’t need
92− escaping of <literal>"</literal> and <literal>\</literal>, and because
93− indentation is intelligently removed.)
58+ (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.)
9459 </para>
9560
9661 <para>
97− There are many other attributes to customise the build. These are listed in
98− <xref linkend="ssec-stdenv-attributes"/>.
62+ There are many other attributes to customise the build. These are listed in <xref linkend="ssec-stdenv-attributes"/>.
9963 </para>
10064
10165 <para>
102− While the standard environment provides a generic builder, you can still
103− supply your own build script:
66+ While the standard environment provides a generic builder, you can still supply your own build script:
10467<programlisting>
10568stdenv.mkDerivation {
10669 name = "libfoo-1.2.3";
@@ -111,9 +74,7 @@ stdenv.mkDerivation {
11174<programlisting>
11275source $stdenv/setup
11376</programlisting>
114− to let <literal>stdenv</literal> set up the environment (e.g., process the
115− <varname>buildInputs</varname>). If you want, you can still use
116− <literal>stdenv</literal>’s generic builder:
77+ 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:
11778<programlisting>
11879source $stdenv/setup
11980
@@ -179,23 +140,17 @@ genericBuild
179140 </listitem>
180141 <listitem>
181142 <para>
182− <command>gzip</command>, <command>bzip2</command> and
183− <command>xz</command>.
143+ <command>gzip</command>, <command>bzip2</command> and <command>xz</command>.
184144 </para>
185145 </listitem>
186146 <listitem>
187147 <para>
188− GNU Make. It has been patched to provide <quote>nested</quote> output
189− that can be fed into the <command>nix-log2xml</command> command and
190− <command>log2html</command> stylesheet to create a structured, readable
191− output of the build steps performed by Make.
148+ 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.
192149 </para>
193150 </listitem>
194151 <listitem>
195152 <para>
196− Bash. This is the shell used for all builders in the Nix Packages
197− collection. Not using <command>/bin/sh</command> removes a large source
198− of portability problems.
153+ 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.
199154 </para>
200155 </listitem>
201156 <listitem>
@@ -207,108 +162,52 @@ genericBuild
207162 </para>
208163
209164 <para>
210− On Linux, <literal>stdenv</literal> also includes the
211− <command>patchelf</command> utility.
165+ On Linux, <literal>stdenv</literal> also includes the <command>patchelf</command> utility.
212166 </para>
213167 </section>
214168 <section xml:id="ssec-stdenv-dependencies">
215169 <title>Specifying dependencies</title>
216170
217171 <para>
218− As described in the Nix manual, almost any <filename>*.drv</filename> store
219− path in a derivation's attribute set will induce a dependency on that
220− derivation. <varname>mkDerivation</varname>, however, takes a few attributes
221− intended to, between them, include all the dependencies of a package. This
222− is done both for structure and consistency, but also so that certain other
223− setup can take place. For example, certain dependencies need their bin
224− directories added to the <envar>PATH</envar>. That is built-in, but other
225− setup is done via a pluggable mechanism that works in conjunction with these
226− dependency attributes. See <xref linkend="ssec-setup-hooks"/> for details.
172+ 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.
227173 </para>
228174
229175 <para>
230− Dependencies can be broken down along three axes: their host and target
231− platforms relative to the new derivation's, and whether they are propagated.
232− The platform distinctions are motivated by cross compilation; see
233− <xref linkend="chap-cross"/> for exactly what each platform means.
176+ 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.
234177 <footnote xml:id="footnote-stdenv-ignored-build-platform">
235178 <para>
236− The build platform is ignored because it is a mere implementation detail
237− of the package satisfying the dependency: As a general programming
238− principle, dependencies are always <emphasis>specified</emphasis> as
239− interfaces, not concrete implementation.
179+ 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.
240180 </para>
241181 </footnote>
242− But even if one is not cross compiling, the platforms imply whether or not
243− the dependency is needed at run-time or build-time, a concept that makes
244− perfect sense outside of cross compilation. By default, the
245− run-time/build-time distinction is just a hint for mental clarity, but with
246− <varname>strictDeps</varname> set it is mostly enforced even in the native
247− case.
182+ 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. By default, the run-time/build-time distinction is just a hint for mental clarity, but with <varname>strictDeps</varname> set it is mostly enforced even in the native case.
248183 </para>
249184
250185 <para>
251− The extension of <envar>PATH</envar> with dependencies, alluded to above,
252− proceeds according to the relative platforms alone. The process is carried
253− out only for dependencies whose host platform matches the new derivation's
254− build platform i.e. dependencies which run on the platform where the new
255− derivation will be built.
186+ 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. dependencies which run on the platform where the new derivation will be built.
256187 <footnote xml:id="footnote-stdenv-native-dependencies-in-path">
257188 <para>
258− Currently, this means for native builds all dependencies are put on the
259− <envar>PATH</envar>. But in the future that may not be the case for sake
260− of matching cross: the platforms would be assumed to be unique for native
261− and cross builds alike, so only the <varname>depsBuild*</varname> and
262− <varname>nativeBuildInputs</varname> would be added to the
263− <envar>PATH</envar>.
189+ Currently, this 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>nativeBuildInputs</varname> would be added to the <envar>PATH</envar>.
264190 </para>
265191 </footnote>
266− For each dependency <replaceable>dep</replaceable> of those dependencies,
267− <filename><replaceable>dep</replaceable>/bin</filename>, if present, is
268− added to the <envar>PATH</envar> environment variable.
192+ 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.
269193 </para>
270194
271195 <para>
272− The dependency is propagated when it forces some of its other-transitive
273− (non-immediate) downstream dependencies to also take it on as an immediate
274− dependency. Nix itself already takes a package's transitive dependencies
275− into account, but this propagation ensures nixpkgs-specific infrastructure
276− like setup hooks (mentioned above) also are run as if the propagated
277− dependency.
196+ 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.
278197 </para>
279198
280199 <para>
281− It is important to note that dependencies are not necessarily propagated as
282− the same sort of dependency that they were before, but rather as the
283− corresponding sort so that the platform rules still line up. The exact rules
284− for dependency propagation can be given by assigning to each dependency two
285− integers based one how its host and target platforms are offset from the
286− depending derivation's platforms. Those offsets are given below in the
287− descriptions of each dependency list attribute. Algorithmically, we traverse
288− propagated inputs, accumulating every propagated dependency's propagated
289− dependencies and adjusting them to account for the "shift in perspective"
290− described by the current dependency's platform offsets. This results in sort
291− a transitive closure of the dependency relation, with the offsets being
292− approximately summed when two dependency links are combined. We also prune
293− transitive dependencies whose combined offsets go out-of-bounds, which can
294− be viewed as a filter over that transitive closure removing dependencies
295− that are blatantly absurd.
200+ It is important to note that dependencies are not necessarily 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 to each dependency two integers based one how its host and target platforms are offset from the depending derivation's platforms. Those offsets are given below in the descriptions of each dependency list attribute. Algorithmically, we traverse propagated inputs, accumulating every propagated dependency's propagated dependencies and adjusting them to account for the "shift in perspective" described by the current dependency'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 dependencies whose combined offsets go out-of-bounds, which can be viewed as a filter over that transitive closure removing dependencies that are blatantly absurd.
296201 </para>
297202
298203 <para>
299− We can define the process precisely with
300− <link xlink:href="https://en.wikipedia.org/wiki/Natural_deduction">Natural
301− Deduction</link> using the inference rules. This probably seems a bit
302− obtuse, but so is the bash code that actually implements it!
204+ 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!
303205 <footnote xml:id="footnote-stdenv-find-inputs-location">
304206 <para>
305− The <function>findInputs</function> function, currently residing in
306− <filename>pkgs/stdenv/generic/setup.sh</filename>, implements the
307− propagation logic.
207+ The <function>findInputs</function> function, currently residing in <filename>pkgs/stdenv/generic/setup.sh</filename>, implements the propagation logic.
308208 </para>
309209 </footnote>
310− They're confusing in very different ways so... hopefully if something
311− doesn't make sense in one presentation, it will in the other!
210+ They're confusing in very different ways so... hopefully if something doesn't make sense in one presentation, it will in the other!
312211<programlisting>
313212let mapOffset(h, t, i) = i + (if i <= 0 then h else t - 1)
314213
@@ -335,50 +234,22 @@ propagated-dep(mapOffset(h0, t0, h1),
335234propagated-dep(h, t, A, B)
336235----------------------------- Propagated dependencies count as dependencies
337236dep(h, t, A, B)</programlisting>
338− Some explanation of this monstrosity is in order. In the common case, the
339− target offset of a dependency is the successor to the target offset:
340− <literal>t = h + 1</literal>. That means that:
237+ 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:
341238<programlisting>
342239let f(h, t, i) = i + (if i <= 0 then h else t - 1)
343240let f(h, h + 1, i) = i + (if i <= 0 then h else (h + 1) - 1)
344241let f(h, h + 1, i) = i + (if i <= 0 then h else h)
345242let f(h, h + 1, i) = i + h
346243</programlisting>
347− This is where "sum-like" comes in from above: We can just sum all of the
348− host offsets to get the host offset of the transitive dependency. The target
349− offset is the transitive dependency is simply the host offset + 1, just as
350− it was with the dependencies composed to make this transitive one; it can be
351− ignored as it doesn't add any new information.
244+ This is where "sum-like" comes in from above: We can just sum all of the host offsets to get the host offset of the transitive dependency. The target offset is the transitive dependency 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.
352245 </para>
353246
354247 <para>
355− Because of the bounds checks, the uncommon cases are <literal>h =
356− t</literal> and <literal>h + 2 = t</literal>. In the former case, the
357− motivation for <function>mapOffset</function> is that since its host and
358− target platforms are the same, no transitive dependency of it should be able
359− to "discover" an offset greater than its reduced target offsets.
360− <function>mapOffset</function> effectively "squashes" all its transitive
361− dependencies' offsets so that none will ever be greater than the target
362− offset of the original <literal>h = t</literal> package. In the other case,
363− <literal>h + 1</literal> is skipped over between the host and target
364− offsets. Instead of squashing the offsets, we need to "rip" them apart so no
365− transitive dependencies' offset is that one.
248+ 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 dependency 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.
366249 </para>
367250
368251 <para>
369− Overall, the unifying theme here is that propagation shouldn't be
370− introducing transitive dependencies involving platforms the depending
371− package is unaware of. [One can imagine the dependending package asking for
372− dependencies with the platforms it knows about; other platforms it doesn't
373− know how to ask for. The platform description in that scenario is a kind of
374− unforagable capability.] The offset bounds checking and definition of
375− <function>mapOffset</function> together ensure that this is the case.
376− Discovering a new offset is discovering a new platform, and since those
377− platforms weren't in the derivation "spec" of the needing package, they
378− cannot be relevant. From a capability perspective, we can imagine that the
379− host and target platforms of a package are the capabilities a package
380− requires, and the depending package must provide the capability to the
381− dependency.
252+ Overall, the unifying theme here is that propagation shouldn't be introducing transitive dependencies involving platforms the depending package is unaware of. [One can imagine the dependending package asking for dependencies with the platforms it knows about; other platforms it doesn't know how to ask for. The platform description in that scenario is a kind of unforagable capability.] 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.
382253 </para>
383254
384255 <variablelist>
@@ -389,23 +260,10 @@ let f(h, h + 1, i) = i + h
389260 </term>
390261 <listitem>
391262 <para>
392− A list of dependencies whose host and target platforms are the new
393− derivation's build platform. This means a <literal>-1</literal> host and
394− <literal>-1</literal> target offset from the new derivation's platforms.
395− These are programs and libraries used at build time that produce programs
396− and libraries also used at build time. If the dependency doesn't care
397− about the target platform (i.e. isn't a compiler or similar tool), put it
398− in <varname>nativeBuildInputs</varname> instead. The most common use of
399− this <literal>buildPackages.stdenv.cc</literal>, the default C compiler
400− for this role. That example crops up more than one might think in old
401− commonly used C libraries.
263+ 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. These are programs and libraries used at build time that produce programs and 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 of 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.
402264 </para>
403265 <para>
404− Since these packages are able to be run at build-time, they are always
405− added to the <envar>PATH</envar>, as described above. But since these
406− packages are only guaranteed to be able to run then, they shouldn't
407− persist as run-time dependencies. This isn't currently enforced, but
408− could be in the future.
266+ Since these packages are able to be run at build-time, they 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.
409267 </para>
410268 </listitem>
411269 </varlistentry>
@@ -415,24 +273,10 @@ let f(h, h + 1, i) = i + h
415273 </term>
416274 <listitem>
417275 <para>
418− A list of dependencies whose host platform is the new derivation's build
419− platform, and target platform is the new derivation's host platform. This
420− means a <literal>-1</literal> host offset and <literal>0</literal> target
421− offset from the new derivation's platforms. These are programs and
422− libraries used at build-time that, if they are a compiler or similar
423− tool, produce code to run at run-time—i.e. tools used to build the new
424− derivation. If the dependency doesn't care about the target platform
425− (i.e. isn't a compiler or similar tool), put it here, rather than in
426− <varname>depsBuildBuild</varname> or <varname>depsBuildTarget</varname>.
427− This could be called <varname>depsBuildHost</varname> but
428− <varname>nativeBuildInputs</varname> is used for historical continuity.
429− </para>
430− <para>
431− Since these packages are able to be run at build-time, they are added to
432− the <envar>PATH</envar>, as described above. But since these packages are
433− only guaranteed to be able to run then, they shouldn't persist as
434− run-time dependencies. This isn't currently enforced, but could be in the
435− future.
276+ 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. These are programs and 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 could be called <varname>depsBuildHost</varname> but <varname>nativeBuildInputs</varname> is used for historical continuity.
277+ </para>
278+ <para>
279+ Since these packages are able to be run at build-time, they are 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.
436280 </para>
437281 </listitem>
438282 </varlistentry>
@@ -442,39 +286,13 @@ let f(h, h + 1, i) = i + h
442286 </term>
443287 <listitem>
444288 <para>
445− A list of dependencies whose host platform is the new derivation's build
446− platform, and target platform is the new derivation's target platform.
447− This means a <literal>-1</literal> host offset and <literal>1</literal>
448− target offset from the new derivation's platforms. These are programs
449− used at build time that produce code to run with code produced by the
450− depending package. Most commonly, these are tools used to build the
451− runtime or standard library that the currently-being-built compiler will
452− inject into any code it compiles. In many cases, the
453− currently-being-built-compiler is itself employed for that task, but when
454− that compiler won't run (i.e. its build and host platform differ) this is
455− not possible. Other times, the compiler relies on some other tool, like
456− binutils, that is always built separately so that the dependency is
457− unconditional.
458− </para>
459− <para>
460− This is a somewhat confusing concept to wrap one’s head around, and for
461− good reason. As the only dependency type where the platform offsets are
462− not adjacent integers, it requires thinking of a bootstrapping stage
463− <emphasis>two</emphasis> away from the current one. It and its use-case
464− go hand in hand and are both considered poor form: try to not need this
465− sort of dependency, and try to avoid building standard libraries and
466− runtimes in the same derivation as the compiler produces code using them.
467− Instead strive to build those like a normal library, using the
468− newly-built compiler just as a normal library would. In short, do not use
469− this attribute unless you are packaging a compiler and are sure it is
470− needed.
471− </para>
472− <para>
473− Since these packages are able to run at build time, they are added to the
474− <envar>PATH</envar>, as described above. But since these packages are
475− only guaranteed to be able to run then, they shouldn't persist as
476− run-time dependencies. This isn't currently enforced, but could be in the
477− future.
289+ 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. These are programs used at build time that produce code to run with code produced by the depending package. Most commonly, these are tools used to build the runtime or standard library that 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 that the dependency is unconditional.
290+ </para>
291+ <para>
292+ This is a somewhat confusing concept to wrap one’s head around, and for good reason. As the only dependency type 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 its use-case go hand in hand and are both considered poor form: try to not need this sort of dependency, and try to avoid building standard libraries and 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.
293+ </para>
294+ <para>
295+ Since these packages are able to run at build time, they are 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.
478296 </para>
479297 </listitem>
480298 </varlistentry>
@@ -484,16 +302,7 @@ let f(h, h + 1, i) = i + h
484302 </term>
485303 <listitem>
486304 <para>
487− A list of dependencies whose host and target platforms match the new
488− derivation's host platform. This means a <literal>0</literal> host offset
489− and <literal>0</literal> target offset from the new derivation's host
490− platform. These are packages used at run-time to generate code also used
491− at run-time. In practice, this would usually be tools used by compilers
492− for macros or a metaprogramming system, or libraries used by the macros
493− or metaprogramming code itself. It's always preferable to use a
494− <varname>depsBuildBuild</varname> dependency in the derivation being
495− built over a <varname>depsHostHost</varname> on the tool doing the
496− building for this purpose.
305+ A list of dependencies whose host and target platforms match the new derivation's host platform. This means a <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, this would usually be tools used by compilers for macros or a metaprogramming system, or libraries used by the macros or metaprogramming code itself. It's always preferable to use a <varname>depsBuildBuild</varname> dependency in the derivation being built over a <varname>depsHostHost</varname> on the tool doing the building for this purpose.
497306 </para>
498307 </listitem>
499308 </varlistentry>
@@ -503,21 +312,10 @@ let f(h, h + 1, i) = i + h
503312 </term>
504313 <listitem>
505314 <para>
506− A list of dependencies whose host platform and target platform match the
507− new derivation's. This means a <literal>0</literal> host offset and a
508− <literal>1</literal> target offset from the new derivation's host
509− platform. This would be called <varname>depsHostTarget</varname> but for
510− historical continuity. If the dependency doesn't care about the target
511− platform (i.e. isn't a compiler or similar tool), put it here, rather
512− than in <varname>depsBuildBuild</varname>.
315+ A list of dependencies whose host platform and target platform match the new derivation's. This means a <literal>0</literal> host offset and a <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>.
513316 </para>
514317 <para>
515− These are often programs and libraries used by the new derivation at
516− <emphasis>run</emphasis>-time, but that isn't always the case. For
517− example, the machine code in a statically-linked library is only used at
518− run-time, but the derivation containing the library is only needed at
519− build-time. Even in the dynamic case, the library may also be needed at
520− build-time to appease the linker.
318+ These are often programs and 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.
521319 </para>
522320 </listitem>
523321 </varlistentry>
@@ -527,14 +325,7 @@ let f(h, h + 1, i) = i + h
527325 </term>
528326 <listitem>
529327 <para>
530− A list of dependencies whose host platform matches the new derivation's
531− target platform. This means a <literal>1</literal> offset from the new
532− derivation's platforms. These are packages that run on the target
533− platform, e.g. the standard library or run-time deps of standard library
534− that a compiler insists on knowing about. It's poor form in almost all
535− cases for a package to depend on another from a future stage [future
536− stage corresponding to positive offset]. Do not use this attribute unless
537− you are packaging a compiler and are sure it is needed.
328+ A list of dependencies whose host platform matches the new derivation's target platform. This means a <literal>1</literal> offset from the new derivation's platforms. These are packages that run on the target platform, e.g. the standard library or run-time deps of standard library that a compiler insists on knowing about. It's poor form in almost all cases for a package to depend on another from a future stage [future stage corresponding to positive offset]. Do not use this attribute unless you are packaging a compiler and are sure it is needed.
538329 </para>
539330 </listitem>
540331 </varlistentry>
@@ -544,9 +335,7 @@ let f(h, h + 1, i) = i + h
544335 </term>
545336 <listitem>
546337 <para>
547− The propagated equivalent of <varname>depsBuildBuild</varname>. This
548− perhaps never ought to be used, but it is included for consistency [see
549− below for the others].
338+ The propagated equivalent of <varname>depsBuildBuild</varname>. This perhaps never ought to be used, but it is included for consistency [see below for the others].
550339 </para>
551340 </listitem>
552341 </varlistentry>
@@ -556,18 +345,7 @@ let f(h, h + 1, i) = i + h
556345 </term>
557346 <listitem>
558347 <para>
559− The propagated equivalent of <varname>nativeBuildInputs</varname>. This
560− would be called <varname>depsBuildHostPropagated</varname> but for
561− historical continuity. For example, if package <varname>Y</varname> has
562− <literal>propagatedNativeBuildInputs = [X]</literal>, and package
563− <varname>Z</varname> has <literal>buildInputs = [Y]</literal>, then
564− package <varname>Z</varname> will be built as if it included package
565− <varname>X</varname> in its <varname>nativeBuildInputs</varname>. If
566− instead, package <varname>Z</varname> has <literal>nativeBuildInputs =
567− [Y]</literal>, then <varname>Z</varname> will be built as if it included
568− <varname>X</varname> in the <varname>depsBuildBuild</varname> of package
569− <varname>Z</varname>, because of the sum of the two <literal>-1</literal>
570− host offsets.
348+ The propagated equivalent of <varname>nativeBuildInputs</varname>. This would be called <varname>depsBuildHostPropagated</varname> but for historical continuity. For example, if package <varname>Y</varname> has <literal>propagatedNativeBuildInputs = [X]</literal>, and package <varname>Z</varname> has <literal>buildInputs = [Y]</literal>, then package <varname>Z</varname> will be built as if it included package <varname>X</varname> in its <varname>nativeBuildInputs</varname>. If instead, package <varname>Z</varname> has <literal>nativeBuildInputs = [Y]</literal>, then <varname>Z</varname> will be built as if it included <varname>X</varname> in the <varname>depsBuildBuild</varname> of package <varname>Z</varname>, because of the sum of the two <literal>-1</literal> host offsets.
571349 </para>
572350 </listitem>
573351 </varlistentry>
@@ -577,8 +355,7 @@ let f(h, h + 1, i) = i + h
577355 </term>
578356 <listitem>
579357 <para>
580− The propagated equivalent of <varname>depsBuildTarget</varname>. This is
581− prefixed for the same reason of alerting potential users.
358+ The propagated equivalent of <varname>depsBuildTarget</varname>. This is prefixed for the same reason of alerting potential users.
582359 </para>
583360 </listitem>
584361 </varlistentry>
@@ -598,9 +375,7 @@ let f(h, h + 1, i) = i + h
598375 </term>
599376 <listitem>
600377 <para>
601− The propagated equivalent of <varname>buildInputs</varname>. This would
602− be called <varname>depsHostTargetPropagated</varname> but for historical
603− continuity.
378+ The propagated equivalent of <varname>buildInputs</varname>. This would be called <varname>depsHostTargetPropagated</varname> but for historical continuity.
604379 </para>
605380 </listitem>
606381 </varlistentry>
@@ -610,8 +385,7 @@ let f(h, h + 1, i) = i + h
610385 </term>
611386 <listitem>
612387 <para>
613− The propagated equivalent of <varname>depsTargetTarget</varname>. This is
614− prefixed for the same reason of alerting potential users.
388+ The propagated equivalent of <varname>depsTargetTarget</varname>. This is prefixed for the same reason of alerting potential users.
615389 </para>
616390 </listitem>
617391 </varlistentry>
@@ -628,15 +402,7 @@ let f(h, h + 1, i) = i + h
628402 </term>
629403 <listitem>
630404 <para>
631− A natural number indicating how much information to log. If set to 1 or
632− higher, <literal>stdenv</literal> will print moderate debugging
633− information during the build. In particular, the <command>gcc</command>
634− and <command>ld</command> wrapper scripts will print out the complete
635− command line passed to the wrapped tools. If set to 6 or higher, the
636− <literal>stdenv</literal> setup script will be run with <literal>set
637− -x</literal> tracing. If set to 7 or higher, the <command>gcc</command>
638− and <command>ld</command> wrapper scripts will also be run with
639− <literal>set -x</literal> tracing.
405+ A natural number indicating how much information to log. If set to 1 or higher, <literal>stdenv</literal> will print moderate debugging information during the build. In particular, the <command>gcc</command> and <command>ld</command> wrapper scripts will print out the complete command line passed to the wrapped tools. If set to 6 or higher, the <literal>stdenv</literal> setup script will be run with <literal>set -x</literal> tracing. If set to 7 or higher, the <command>gcc</command> and <command>ld</command> wrapper scripts will also be run with <literal>set -x</literal> tracing.
640406 </para>
641407 </listitem>
642408 </varlistentry>
@@ -650,15 +416,10 @@ let f(h, h + 1, i) = i + h
650416 </term>
651417 <listitem>
652418 <para>
653− If set to <literal>true</literal>, <literal>stdenv</literal> will pass
654− specific flags to <literal>make</literal> and other build tools to enable
655− parallel building with up to <literal>build-cores</literal> workers.
419+ If set to <literal>true</literal>, <literal>stdenv</literal> will pass specific flags to <literal>make</literal> and other build tools to enable parallel building with up to <literal>build-cores</literal> workers.
656420 </para>
657421 <para>
658− Unless set to <literal>false</literal>, some build systems with good
659− support for parallel building including <literal>cmake</literal>,
660− <literal>meson</literal>, and <literal>qmake</literal> will set it to
661− <literal>true</literal>.
422+ Unless set to <literal>false</literal>, some build systems with good support for parallel building including <literal>cmake</literal>, <literal>meson</literal>, and <literal>qmake</literal> will set it to <literal>true</literal>.
662423 </para>
663424 </listitem>
664425 </varlistentry>
@@ -672,8 +433,7 @@ let f(h, h + 1, i) = i + h
672433 </term>
673434 <listitem>
674435 <para>
675− This is an attribute set which can be filled with arbitrary values. For
676− example:
436+ This is an attribute set which can be filled with arbitrary values. For example:
677437<programlisting>
678438passthru = {
679439 foo = "bar";
@@ -685,17 +445,7 @@ passthru = {
685445</programlisting>
686446 </para>
687447 <para>
688− Values inside it are not passed to the builder, so you can change them
689− without triggering a rebuild. However, they can be accessed outside of a
690− derivation directly, as if they were set inside a derivation itself, e.g.
691− <literal>hello.baz.value1</literal>. We don't specify any usage or schema
692− of <literal>passthru</literal> - it is meant for values that would be
693− useful outside the derivation in other parts of a Nix expression (e.g. in
694− other derivations). An example would be to convey some specific
695− dependency of your derivation which contains a program with plugins
696− support. Later, others who make derivations with plugins can use
697− passed-through dependency to ensure that their plugin would be
698− binary-compatible with built program.
448+ Values inside it are not passed to the builder, so you can change them without triggering a rebuild. However, they can be accessed outside of a derivation directly, as if they were set inside a derivation itself, e.g. <literal>hello.baz.value1</literal>. We don't specify any usage or schema of <literal>passthru</literal> - it is meant for values that would be useful outside the derivation in other parts of a Nix expression (e.g. in other derivations). An example would be to convey some specific dependency of your derivation which contains a program with plugins support. Later, others who make derivations with plugins can use passed-through dependency to ensure that their plugin would be binary-compatible with built program.
699449 </para>
700450 </listitem>
701451 </varlistentry>
@@ -705,9 +455,7 @@ passthru = {
705455 </term>
706456 <listitem>
707457 <para>
708− A script to be run by <filename>maintainers/scripts/update.nix</filename>
709− when the package is matched. It needs to be an executable file, either on
710− the file system:
458+ A script to be run by <filename>maintainers/scripts/update.nix</filename> when the package is matched. It needs to be an executable file, either on the file system:
711459<programlisting>
712460passthru.updateScript = ./update.sh;
713461</programlisting>
@@ -723,21 +471,16 @@ passthru.updateScript = writeScript "update-zoom-us" ''
723471 update-source-version zoom-us "$version"
724472'';
725473</programlisting>
726− The attribute can also contain a list, a script followed by arguments to
727− be passed to it:
474+ The attribute can also contain a list, a script followed by arguments to be passed to it:
728475<programlisting>
729476passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ];
730477</programlisting>
731478 </para>
732479 <para>
733− The script will be usually run from the root of the Nixpkgs repository
734− but you should not rely on that. Also note that the update scripts will
735− be run in parallel by default; you should avoid running <command>git
736− commit</command> or any other commands that cannot handle that.
480+ The script will be usually run from the root of the Nixpkgs repository but you should not rely on that. Also note that the update scripts will be run in parallel by default; you should avoid running <command>git commit</command> or any other commands that cannot handle that.
737481 </para>
738482 <para>
739− For information about how to run the updates, execute <command>nix-shell
740− maintainers/scripts/update.nix</command>.
483+ For information about how to run the updates, execute <command>nix-shell maintainers/scripts/update.nix</command>.
741484 </para>
742485 </listitem>
743486 </varlistentry>
@@ -747,33 +490,18 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
747490 <title>Phases</title>
748491
749492 <para>
750− The generic builder has a number of <emphasis>phases</emphasis>. Package
751− builds are split into phases to make it easier to override specific parts of
752− the build (e.g., unpacking the sources or installing the binaries).
753− Furthermore, it allows a nicer presentation of build logs in the Nix build
754− farm.
493+ The generic builder has a number of <emphasis>phases</emphasis>. Package builds are split into phases to make it easier to override specific parts of the build (e.g., unpacking the sources or installing the binaries). Furthermore, it allows a nicer presentation of build logs in the Nix build farm.
755494 </para>
756495
757496 <para>
758− Each phase can be overridden in its entirety either by setting the
759− environment variable <varname><replaceable>name</replaceable>Phase</varname>
760− to a string containing some shell commands to be executed, or by redefining
761− the shell function <varname><replaceable>name</replaceable>Phase</varname>.
762− The former is convenient to override a phase from the derivation, while the
763− latter is convenient from a build script. However, typically one only wants
764− to <emphasis>add</emphasis> some commands to a phase, e.g. by defining
765− <literal>postInstall</literal> or <literal>preFixup</literal>, as skipping
766− some of the default actions may have unexpected consequences. The default
767− script for each phase is defined in the file
768− <filename>pkgs/stdenv/generic/setup.sh</filename>.
497+ Each phase can be overridden in its entirety either by setting the environment variable <varname><replaceable>name</replaceable>Phase</varname> to a string containing some shell commands to be executed, or by redefining the shell function <varname><replaceable>name</replaceable>Phase</varname>. The former is convenient to override a phase from the derivation, while the latter is convenient from a build script. However, typically one only wants to <emphasis>add</emphasis> some commands to a phase, e.g. by defining <literal>postInstall</literal> or <literal>preFixup</literal>, as skipping some of the default actions may have unexpected consequences. The default script for each phase is defined in the file <filename>pkgs/stdenv/generic/setup.sh</filename>.
769498 </para>
770499
771500 <section xml:id="ssec-controlling-phases">
772501 <title>Controlling phases</title>
773502
774503 <para>
775− There are a number of variables that control what phases are executed and
776− in what order:
504+ There are a number of variables that control what phases are executed and in what order:
777505 <variablelist>
778506 <title>Variables affecting phase control</title>
779507 <varlistentry>
@@ -782,19 +510,10 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
782510 </term>
783511 <listitem>
784512 <para>
785− Specifies the phases. You can change the order in which phases are
786− executed, or add new phases, by setting this variable. If it’s not
787− set, the default value is used, which is <literal>$prePhases
788− unpackPhase patchPhase $preConfigurePhases configurePhase
789− $preBuildPhases buildPhase checkPhase $preInstallPhases installPhase
790− fixupPhase installCheckPhase $preDistPhases distPhase
791− $postPhases</literal>.
513+ Specifies the phases. You can change the order in which phases are executed, or add new phases, by setting this variable. If it’s not set, the default value is used, which is <literal>$prePhases unpackPhase patchPhase $preConfigurePhases configurePhase $preBuildPhases buildPhase checkPhase $preInstallPhases installPhase fixupPhase installCheckPhase $preDistPhases distPhase $postPhases</literal>.
792514 </para>
793515 <para>
794− Usually, if you just want to add a few phases, it’s more convenient
795− to set one of the variables below (such as
796− <varname>preInstallPhases</varname>), as you then don’t specify all
797− the normal phases.
516+ Usually, if you just want to add a few phases, it’s more convenient to set one of the variables below (such as <varname>preInstallPhases</varname>), as you then don’t specify all the normal phases.
798517 </para>
799518 </listitem>
800519 </varlistentry>
@@ -876,11 +595,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
876595 <title>The unpack phase</title>
877596
878597 <para>
879− The unpack phase is responsible for unpacking the source code of the
880− package. The default implementation of <function>unpackPhase</function>
881− unpacks the source files listed in the <envar>src</envar> environment
882− variable to the current directory. It supports the following files by
883− default:
598+ The unpack phase is responsible for unpacking the source code of the package. The default implementation of <function>unpackPhase</function> unpacks the source files listed in the <envar>src</envar> environment variable to the current directory. It supports the following files by default:
884599 <variablelist>
885600 <varlistentry>
886601 <term>
@@ -888,13 +603,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
888603 </term>
889604 <listitem>
890605 <para>
891− These can optionally be compressed using <command>gzip</command>
892− (<filename>.tar.gz</filename>, <filename>.tgz</filename> or
893− <filename>.tar.Z</filename>), <command>bzip2</command>
894− (<filename>.tar.bz2</filename>, <filename>.tbz2</filename> or
895− <filename>.tbz</filename>) or <command>xz</command>
896− (<filename>.tar.xz</filename>, <filename>.tar.lzma</filename> or
897− <filename>.txz</filename>).
606+ These can optionally be compressed using <command>gzip</command> (<filename>.tar.gz</filename>, <filename>.tgz</filename> or <filename>.tar.Z</filename>), <command>bzip2</command> (<filename>.tar.bz2</filename>, <filename>.tbz2</filename> or <filename>.tbz</filename>) or <command>xz</command> (<filename>.tar.xz</filename>, <filename>.tar.lzma</filename> or <filename>.txz</filename>).
898607 </para>
899608 </listitem>
900609 </varlistentry>
@@ -904,9 +613,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
904613 </term>
905614 <listitem>
906615 <para>
907− Zip files are unpacked using <command>unzip</command>. However,
908− <command>unzip</command> is not in the standard environment, so you
909− should add it to <varname>nativeBuildInputs</varname> yourself.
616+ Zip files are unpacked using <command>unzip</command>. However, <command>unzip</command> is not in the standard environment, so you should add it to <varname>nativeBuildInputs</varname> yourself.
910617 </para>
911618 </listitem>
912619 </varlistentry>
@@ -916,16 +623,12 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
916623 </term>
917624 <listitem>
918625 <para>
919− These are simply copied to the current directory. The hash part of the
920− file name is stripped, e.g.
921− <filename>/nix/store/1wydxgby13cz...-my-sources</filename> would be
922− copied to <filename>my-sources</filename>.
626+ These are simply copied to the current directory. The hash part of the file name is stripped, e.g. <filename>/nix/store/1wydxgby13cz...-my-sources</filename> would be copied to <filename>my-sources</filename>.
923627 </para>
924628 </listitem>
925629 </varlistentry>
926630 </variablelist>
927− Additional file types can be supported by setting the
928− <varname>unpackCmd</varname> variable (see below).
631+ Additional file types can be supported by setting the <varname>unpackCmd</varname> variable (see below).
929632 </para>
930633
931634 <para></para>
@@ -938,8 +641,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
938641 </term>
939642 <listitem>
940643 <para>
941− The list of source files or directories to be unpacked or copied. One of
942− these must be set.
644+ The list of source files or directories to be unpacked or copied. One of these must be set.
943645 </para>
944646 </listitem>
945647 </varlistentry>
@@ -949,10 +651,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
949651 </term>
950652 <listitem>
951653 <para>
952− After running <function>unpackPhase</function>, the generic builder
953− changes the current directory to the directory created by unpacking the
954− sources. If there are multiple source directories, you should set
955− <varname>sourceRoot</varname> to the name of the intended directory.
654+ After running <function>unpackPhase</function>, the generic builder changes the current directory to the directory created by unpacking the sources. If there are multiple source directories, you should set <varname>sourceRoot</varname> to the name of the intended directory.
956655 </para>
957656 </listitem>
958657 </varlistentry>
@@ -962,10 +661,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
962661 </term>
963662 <listitem>
964663 <para>
965− Alternatively to setting <varname>sourceRoot</varname>, you can set
966− <varname>setSourceRoot</varname> to a shell command to be evaluated by
967− the unpack phase after the sources have been unpacked. This command must
968− set <varname>sourceRoot</varname>.
664+ Alternatively to setting <varname>sourceRoot</varname>, you can set <varname>setSourceRoot</varname> to a shell command to be evaluated by the unpack phase after the sources have been unpacked. This command must set <varname>sourceRoot</varname>.
969665 </para>
970666 </listitem>
971667 </varlistentry>
@@ -1005,10 +701,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1005701 </term>
1006702 <listitem>
1007703 <para>
1008− If set to <literal>1</literal>, the unpacked sources are
1009− <emphasis>not</emphasis> made writable. By default, they are made
1010− writable to prevent problems with read-only sources. For example, copied
1011− store directories would be read-only without this.
704+ If set to <literal>1</literal>, the unpacked sources are <emphasis>not</emphasis> made writable. By default, they are made writable to prevent problems with read-only sources. For example, copied store directories would be read-only without this.
1012705 </para>
1013706 </listitem>
1014707 </varlistentry>
@@ -1018,9 +711,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1018711 </term>
1019712 <listitem>
1020713 <para>
1021− The unpack phase evaluates the string <literal>$unpackCmd</literal> for
1022− any unrecognised file. The path to the current source file is contained
1023− in the <varname>curSrc</varname> variable.
714+ The unpack phase evaluates the string <literal>$unpackCmd</literal> for any unrecognised file. The path to the current source file is contained in the <varname>curSrc</varname> variable.
1024715 </para>
1025716 </listitem>
1026717 </varlistentry>
@@ -1031,8 +722,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1031722 <title>The patch phase</title>
1032723
1033724 <para>
1034− The patch phase applies the list of patches defined in the
1035− <varname>patches</varname> variable.
725+ The patch phase applies the list of patches defined in the <varname>patches</varname> variable.
1036726 </para>
1037727
1038728 <variablelist>
@@ -1043,11 +733,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1043733 </term>
1044734 <listitem>
1045735 <para>
1046− The list of patches. They must be in the format accepted by the
1047− <command>patch</command> command, and may optionally be compressed using
1048− <command>gzip</command> (<filename>.gz</filename>),
1049− <command>bzip2</command> (<filename>.bz2</filename>) or
1050− <command>xz</command> (<filename>.xz</filename>).
736+ The list of patches. They must be in the format accepted by the <command>patch</command> command, and may optionally be compressed using <command>gzip</command> (<filename>.gz</filename>), <command>bzip2</command> (<filename>.bz2</filename>) or <command>xz</command> (<filename>.xz</filename>).
1051737 </para>
1052738 </listitem>
1053739 </varlistentry>
@@ -1057,9 +743,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1057743 </term>
1058744 <listitem>
1059745 <para>
1060− Flags to be passed to <command>patch</command>. If not set, the argument
1061− <option>-p1</option> is used, which causes the leading directory
1062− component to be stripped from the file names in each patch.
746+ Flags to be passed to <command>patch</command>. If not set, the argument <option>-p1</option> is used, which causes the leading directory component to be stripped from the file names in each patch.
1063747 </para>
1064748 </listitem>
1065749 </varlistentry>
@@ -1090,9 +774,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1090774 <title>The configure phase</title>
1091775
1092776 <para>
1093− The configure phase prepares the source tree for building. The default
1094− <function>configurePhase</function> runs <filename>./configure</filename>
1095− (typically an Autoconf-generated script) if it exists.
777+ The configure phase prepares the source tree for building. The default <function>configurePhase</function> runs <filename>./configure</filename> (typically an Autoconf-generated script) if it exists.
1096778 </para>
1097779
1098780 <variablelist>
@@ -1103,10 +785,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1103785 </term>
1104786 <listitem>
1105787 <para>
1106− The name of the configure script. It defaults to
1107− <filename>./configure</filename> if it exists; otherwise, the configure
1108− phase is skipped. This can actually be a command (like <literal>perl
1109− ./Configure.pl</literal>).
788+ The name of the configure script. It defaults to <filename>./configure</filename> if it exists; otherwise, the configure phase is skipped. This can actually be a command (like <literal>perl ./Configure.pl</literal>).
1110789 </para>
1111790 </listitem>
1112791 </varlistentry>
@@ -1116,8 +795,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1116795 </term>
1117796 <listitem>
1118797 <para>
1119− A list of strings passed as additional arguments to the configure
1120− script.
798+ A list of strings passed as additional arguments to the configure script.
1121799 </para>
1122800 </listitem>
1123801 </varlistentry>
@@ -1137,9 +815,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1137815 </term>
1138816 <listitem>
1139817 <para>
1140− A shell array containing additional arguments passed to the configure
1141− script. You must use this instead of <varname>configureFlags</varname>
1142− if the arguments contain spaces.
818+ A shell array containing additional arguments passed to the configure script. You must use this instead of <varname>configureFlags</varname> if the arguments contain spaces.
1143819 </para>
1144820 </listitem>
1145821 </varlistentry>
@@ -1149,8 +825,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1149825 </term>
1150826 <listitem>
1151827 <para>
1152− By default, the flag <literal>--prefix=$prefix</literal> is added to the
1153− configure flags. If this is undesirable, set this variable to true.
828+ By default, the flag <literal>--prefix=$prefix</literal> is added to the configure flags. If this is undesirable, set this variable to true.
1154829 </para>
1155830 </listitem>
1156831 </varlistentry>
@@ -1160,9 +835,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1160835 </term>
1161836 <listitem>
1162837 <para>
1163− The prefix under which the package must be installed, passed via the
1164− <option>--prefix</option> option to the configure script. It defaults to
1165− <option>$out</option>.
838+ The prefix under which the package must be installed, passed via the <option>--prefix</option> option to the configure script. It defaults to <option>$out</option>.
1166839 </para>
1167840 </listitem>
1168841 </varlistentry>
@@ -1172,8 +845,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1172845 </term>
1173846 <listitem>
1174847 <para>
1175− The key to use when specifying the prefix. By default, this is set to
1176− <option>--prefix=</option> as that is used by the majority of packages.
848+ The key to use when specifying the prefix. By default, this is set to <option>--prefix=</option> as that is used by the majority of packages.
1177849 </para>
1178850 </listitem>
1179851 </varlistentry>
@@ -1183,9 +855,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1183855 </term>
1184856 <listitem>
1185857 <para>
1186− By default, the flag <literal>--disable-dependency-tracking</literal> is
1187− added to the configure flags to speed up Automake-based builds. If this
1188− is undesirable, set this variable to true.
858+ By default, the flag <literal>--disable-dependency-tracking</literal> is added to the configure flags to speed up Automake-based builds. If this is undesirable, set this variable to true.
1189859 </para>
1190860 </listitem>
1191861 </varlistentry>
@@ -1195,15 +865,10 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1195865 </term>
1196866 <listitem>
1197867 <para>
1198− By default, the configure phase applies some special hackery to all
1199− files called <filename>ltmain.sh</filename> before running the configure
1200− script in order to improve the purity of Libtool-based packages
868+ By default, the configure phase applies some special hackery to all files called <filename>ltmain.sh</filename> before running the configure script in order to improve the purity of Libtool-based packages
1201869 <footnote xml:id="footnote-stdenv-sys-lib-search-path">
1202870 <para>
1203− It clears the
1204− <varname>sys_lib_<replaceable>*</replaceable>search_path</varname>
1205− variables in the Libtool script to prevent Libtool from using
1206− libraries in <filename>/usr/lib</filename> and such.
871+ It clears the <varname>sys_lib_<replaceable>*</replaceable>search_path</varname> variables in the Libtool script to prevent Libtool from using libraries in <filename>/usr/lib</filename> and such.
1207872 </para>
1208873 </footnote>
1209874 . If this is undesirable, set this variable to true.
@@ -1216,9 +881,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1216881 </term>
1217882 <listitem>
1218883 <para>
1219− By default, when the configure script has
1220− <option>--enable-static</option>, the option
1221− <option>--disable-static</option> is added to the configure flags.
884+ By default, when the configure script has <option>--enable-static</option>, the option <option>--disable-static</option> is added to the configure flags.
1222885 </para>
1223886 <para>
1224887 If this is undesirable, set this variable to true.
@@ -1231,16 +894,10 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1231894 </term>
1232895 <listitem>
1233896 <para>
1234− By default, when cross compiling, the configure script has
1235− <option>--build=...</option> and <option>--host=...</option> passed.
1236− Packages can instead pass <literal>[ "build" "host" "target" ]</literal>
1237− or a subset to control exactly which platform flags are passed.
1238− Compilers and other tools can use this to also pass the target platform.
897+ By default, when cross compiling, the configure script has <option>--build=...</option> and <option>--host=...</option> passed. Packages can instead pass <literal>[ "build" "host" "target" ]</literal> or a subset to control exactly which platform flags are passed. Compilers and other tools can use this to also pass the target platform.
1239898 <footnote xml:id="footnote-stdenv-build-time-guessing-impurity">
1240899 <para>
1241− Eventually these will be passed building natively as well, to improve
1242− determinism: build-time guessing, as is done today, is a risk of
1243− impurity.
900+ Eventually these will be passed building natively as well, to improve determinism: build-time guessing, as is done today, is a risk of impurity.
1244901 </para>
1245902 </footnote>
1246903 </para>
@@ -1273,12 +930,7 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1273930 <title>The build phase</title>
1274931
1275932 <para>
1276− The build phase is responsible for actually building the package (e.g.
1277− compiling it). The default <function>buildPhase</function> simply calls
1278− <command>make</command> if a file named <filename>Makefile</filename>,
1279− <filename>makefile</filename> or <filename>GNUmakefile</filename> exists in
1280− the current directory (or the <varname>makefile</varname> is explicitly
1281− set); otherwise it does nothing.
933+ The build phase is responsible for actually building the package (e.g. compiling it). The default <function>buildPhase</function> simply calls <command>make</command> if a file named <filename>Makefile</filename>, <filename>makefile</filename> or <filename>GNUmakefile</filename> exists in the current directory (or the <varname>makefile</varname> is explicitly set); otherwise it does nothing.
1282934 </para>
1283935
1284936 <variablelist>
@@ -1309,17 +961,13 @@ passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]
1309961 </term>
1310962 <listitem>
1311963 <para>
1312− A list of strings passed as additional flags to <command>make</command>.
1313− These flags are also used by the default install and check phase. For
1314− setting make flags specific to the build phase, use
1315− <varname>buildFlags</varname> (see below).
964+ A list of strings passed as additional flags to <command>make</command>. These flags are also used by the default install and check phase. For setting make flags specific to the build phase, use <varname>buildFlags</varname> (see below).
1316965<programlisting>
1317966makeFlags = [ "PREFIX=$(out)" ];
1318967</programlisting>
1319968 <note>
1320969 <para>
1321− The flags are quoted in bash, but environment variables can be
1322− specified by using the make syntax.
970+ The flags are quoted in bash, but environment variables can be specified by using the make syntax.
1323971 </para>
1324972 </note>
1325973 </para>
@@ -1331,18 +979,13 @@ makeFlags = [ "PREFIX=$(out)" ];
1331979 </term>
1332980 <listitem>
1333981 <para>
1334− A shell array containing additional arguments passed to
1335− <command>make</command>. You must use this instead of
1336− <varname>makeFlags</varname> if the arguments contain spaces, e.g.
982+ A shell array containing additional arguments passed to <command>make</command>. You must use this instead of <varname>makeFlags</varname> if the arguments contain spaces, e.g.
1337983<programlisting>
1338984preBuild = ''
1339985 makeFlagsArray+=(CFLAGS="-O0 -g" LDFLAGS="-lfoo -lbar")
1340986'';
1341987</programlisting>
1342− Note that shell arrays cannot be passed through environment variables,
1343− so you cannot set <varname>makeFlagsArray</varname> in a derivation
1344− attribute (because those are passed through environment variables): you
1345− have to define them in shell code.
988+ Note that shell arrays cannot be passed through environment variables, so you cannot set <varname>makeFlagsArray</varname> in a derivation attribute (because those are passed through environment variables): you have to define them in shell code.
1346989 </para>
1347990 </listitem>
1348991 </varlistentry>
@@ -1352,9 +995,7 @@ preBuild = ''
1352995 </term>
1353996 <listitem>
1354997 <para>
1355− A list of strings passed as additional flags to <command>make</command>.
1356− Like <varname>makeFlags</varname> and <varname>makeFlagsArray</varname>,
1357− but only used by the build phase.
998+ A list of strings passed as additional flags to <command>make</command>. Like <varname>makeFlags</varname> and <varname>makeFlagsArray</varname>, but only used by the build phase.
1358999 </para>
13591000 </listitem>
13601001 </varlistentry>
@@ -1381,14 +1022,11 @@ preBuild = ''
13811022 </variablelist>
13821023
13831024 <para>
1384− You can set flags for <command>make</command> through the
1385− <varname>makeFlags</varname> variable.
1025+ You can set flags for <command>make</command> through the <varname>makeFlags</varname> variable.
13861026 </para>
13871027
13881028 <para>
1389− Before and after running <command>make</command>, the hooks
1390− <varname>preBuild</varname> and <varname>postBuild</varname> are called,
1391− respectively.
1029+ Before and after running <command>make</command>, the hooks <varname>preBuild</varname> and <varname>postBuild</varname> are called, respectively.
13921030 </para>
13931031 </section>
13941032
@@ -1396,10 +1034,7 @@ preBuild = ''
13961034 <title>The check phase</title>
13971035
13981036 <para>
1399− The check phase checks whether the package was built correctly by running
1400− its test suite. The default <function>checkPhase</function> calls
1401− <command>make check</command>, but only if the <varname>doCheck</varname>
1402− variable is enabled.
1037+ The check phase checks whether the package was built correctly by running its test suite. The default <function>checkPhase</function> calls <command>make check</command>, but only if the <varname>doCheck</varname> variable is enabled.
14031038 </para>
14041039
14051040 <variablelist>
@@ -1410,14 +1045,9 @@ preBuild = ''
14101045 </term>
14111046 <listitem>
14121047 <para>
1413− Controls whether the check phase is executed. By default it is skipped,
1414− but if <varname>doCheck</varname> is set to true, the check phase is
1415− usually executed. Thus you should set
1048+ Controls whether the check phase is executed. By default it is skipped, but if <varname>doCheck</varname> is set to true, the check phase is usually executed. Thus you should set
14161049<programlisting>doCheck = true;</programlisting>
1417− in the derivation to enable checks. The exception is cross compilation.
1418− Cross compiled builds never run tests, no matter how
1419− <varname>doCheck</varname> is set, as the newly-built program won't run
1420− on the platform used to build it.
1050+ in the derivation to enable checks. The exception is cross compilation. Cross compiled builds never run tests, no matter how <varname>doCheck</varname> is set, as the newly-built program won't run on the platform used to build it.
14211051 </para>
14221052 </listitem>
14231053 </varlistentry>
@@ -1437,8 +1067,7 @@ preBuild = ''
14371067 </term>
14381068 <listitem>
14391069 <para>
1440− The make target that runs the tests. Defaults to
1441− <literal>check</literal>.
1070+ The make target that runs the tests. Defaults to <literal>check</literal>.
14421071 </para>
14431072 </listitem>
14441073 </varlistentry>
@@ -1448,9 +1077,7 @@ preBuild = ''
14481077 </term>
14491078 <listitem>
14501079 <para>
1451− A list of strings passed as additional flags to <command>make</command>.
1452− Like <varname>makeFlags</varname> and <varname>makeFlagsArray</varname>,
1453− but only used by the check phase.
1080+ A list of strings passed as additional flags to <command>make</command>. Like <varname>makeFlags</varname> and <varname>makeFlagsArray</varname>, but only used by the check phase.
14541081 </para>
14551082 </listitem>
14561083 </varlistentry>
@@ -1460,9 +1087,7 @@ preBuild = ''
14601087 </term>
14611088 <listitem>
14621089 <para>
1463− A list of dependencies used by the phase. This gets included in
1464− <varname>nativeBuildInputs</varname> when <varname>doCheck</varname> is
1465− set.
1090+ A list of dependencies used by the phase. This gets included in <varname>nativeBuildInputs</varname> when <varname>doCheck</varname> is set.
14661091 </para>
14671092 </listitem>
14681093 </varlistentry>
@@ -1493,10 +1118,7 @@ preBuild = ''
14931118 <title>The install phase</title>
14941119
14951120 <para>
1496− The install phase is responsible for installing the package in the Nix
1497− store under <envar>out</envar>. The default
1498− <function>installPhase</function> creates the directory
1499− <literal>$out</literal> and calls <command>make install</command>.
1121+ The install phase is responsible for installing the package in the Nix store under <envar>out</envar>. The default <function>installPhase</function> creates the directory <literal>$out</literal> and calls <command>make install</command>.
15001122 </para>
15011123
15021124 <variablelist>
@@ -1517,8 +1139,7 @@ preBuild = ''
15171139 </term>
15181140 <listitem>
15191141 <para>
1520− The make targets that perform the installation. Defaults to
1521− <literal>install</literal>. Example:
1142+ The make targets that perform the installation. Defaults to <literal>install</literal>. Example:
15221143<programlisting>
15231144installTargets = "install-bin install-doc";</programlisting>
15241145 </para>
@@ -1530,9 +1151,7 @@ installTargets = "install-bin install-doc";</programlisting>
15301151 </term>
15311152 <listitem>
15321153 <para>
1533− A list of strings passed as additional flags to <command>make</command>.
1534− Like <varname>makeFlags</varname> and <varname>makeFlagsArray</varname>,
1535− but only used by the install phase.
1154+ A list of strings passed as additional flags to <command>make</command>. Like <varname>makeFlags</varname> and <varname>makeFlagsArray</varname>, but only used by the install phase.
15361155 </para>
15371156 </listitem>
15381157 </varlistentry>
@@ -1563,15 +1182,11 @@ installTargets = "install-bin install-doc";</programlisting>
15631182 <title>The fixup phase</title>
15641183
15651184 <para>
1566− The fixup phase performs some (Nix-specific) post-processing actions on the
1567− files installed under <filename>$out</filename> by the install phase. The
1568− default <function>fixupPhase</function> does the following:
1185+ The fixup phase performs some (Nix-specific) post-processing actions on the files installed under <filename>$out</filename> by the install phase. The default <function>fixupPhase</function> does the following:
15691186 <itemizedlist>
15701187 <listitem>
15711188 <para>
1572− It moves the <filename>man/</filename>, <filename>doc/</filename> and
1573− <filename>info/</filename> subdirectories of <envar>$out</envar> to
1574− <filename>share/</filename>.
1189+ It moves the <filename>man/</filename>, <filename>doc/</filename> and <filename>info/</filename> subdirectories of <envar>$out</envar> to <filename>share/</filename>.
15751190 </para>
15761191 </listitem>
15771192 <listitem>
@@ -1581,19 +1196,12 @@ installTargets = "install-bin install-doc";</programlisting>
15811196 </listitem>
15821197 <listitem>
15831198 <para>
1584− On Linux, it applies the <command>patchelf</command> command to ELF
1585− executables and libraries to remove unused directories from the
1586− <literal>RPATH</literal> in order to prevent unnecessary runtime
1587− dependencies.
1199+ On Linux, it applies the <command>patchelf</command> command to ELF executables and libraries to remove unused directories from the <literal>RPATH</literal> in order to prevent unnecessary runtime dependencies.
15881200 </para>
15891201 </listitem>
15901202 <listitem>
15911203 <para>
1592− It rewrites the interpreter paths of shell scripts to paths found in
1593− <envar>PATH</envar>. E.g., <filename>/usr/bin/perl</filename> will be
1594− rewritten to
1595− <filename>/nix/store/<replaceable>some-perl</replaceable>/bin/perl</filename>
1596− found in <envar>PATH</envar>.
1204+ It rewrites the interpreter paths of shell scripts to paths found in <envar>PATH</envar>. E.g., <filename>/usr/bin/perl</filename> will be rewritten to <filename>/nix/store/<replaceable>some-perl</replaceable>/bin/perl</filename> found in <envar>PATH</envar>.
15971205 </para>
15981206 </listitem>
15991207 </itemizedlist>
@@ -1617,8 +1225,7 @@ installTargets = "install-bin install-doc";</programlisting>
16171225 </term>
16181226 <listitem>
16191227 <para>
1620− If set, libraries and executables are not stripped. By default, they
1621− are.
1228+ If set, libraries and executables are not stripped. By default, they are.
16221229 </para>
16231230 </listitem>
16241231 </varlistentry>
@@ -1628,10 +1235,7 @@ installTargets = "install-bin install-doc";</programlisting>
16281235 </term>
16291236 <listitem>
16301237 <para>
1631− Like <varname>dontStrip</varname>, but only affects the
1632− <command>strip</command> command targetting the package's host platform.
1633− Useful when supporting cross compilation, but otherwise feel free to
1634− ignore.
1238+ Like <varname>dontStrip</varname>, but only affects the <command>strip</command> command targetting the package's host platform. Useful when supporting cross compilation, but otherwise feel free to ignore.
16351239 </para>
16361240 </listitem>
16371241 </varlistentry>
@@ -1641,10 +1245,7 @@ installTargets = "install-bin install-doc";</programlisting>
16411245 </term>
16421246 <listitem>
16431247 <para>
1644− Like <varname>dontStrip</varname>, but only affects the
1645− <command>strip</command> command targetting the packages' target
1646− platform. Useful when supporting cross compilation, but otherwise feel
1647− free to ignore.
1248+ Like <varname>dontStrip</varname>, but only affects the <command>strip</command> command targetting the packages' target platform. Useful when supporting cross compilation, but otherwise feel free to ignore.
16481249 </para>
16491250 </listitem>
16501251 </varlistentry>
@@ -1654,8 +1255,7 @@ installTargets = "install-bin install-doc";</programlisting>
16541255 </term>
16551256 <listitem>
16561257 <para>
1657− If set, files in <filename>$out/sbin</filename> are not moved to
1658− <filename>$out/bin</filename>. By default, they are.
1258+ If set, files in <filename>$out/sbin</filename> are not moved to <filename>$out/bin</filename>. By default, they are.
16591259 </para>
16601260 </listitem>
16611261 </varlistentry>
@@ -1665,10 +1265,7 @@ installTargets = "install-bin install-doc";</programlisting>
16651265 </term>
16661266 <listitem>
16671267 <para>
1668− List of directories to search for libraries and executables from which
1669− <emphasis>all</emphasis> symbols should be stripped. By default, it’s
1670− empty. Stripping all symbols is risky, since it may remove not just
1671− debug symbols but also ELF information necessary for normal execution.
1268+ List of directories to search for libraries and executables from which <emphasis>all</emphasis> symbols should be stripped. By default, it’s empty. Stripping all symbols is risky, since it may remove not just debug symbols but also ELF information necessary for normal execution.
16721269 </para>
16731270 </listitem>
16741271 </varlistentry>
@@ -1678,9 +1275,7 @@ installTargets = "install-bin install-doc";</programlisting>
16781275 </term>
16791276 <listitem>
16801277 <para>
1681− Flags passed to the <command>strip</command> command applied to the
1682− files in the directories listed in <varname>stripAllList</varname>.
1683− Defaults to <option>-s</option> (i.e. <option>--strip-all</option>).
1278+ Flags passed to the <command>strip</command> command applied to the files in the directories listed in <varname>stripAllList</varname>. Defaults to <option>-s</option> (i.e. <option>--strip-all</option>).
16841279 </para>
16851280 </listitem>
16861281 </varlistentry>
@@ -1690,9 +1285,7 @@ installTargets = "install-bin install-doc";</programlisting>
16901285 </term>
16911286 <listitem>
16921287 <para>
1693− List of directories to search for libraries and executables from which
1694− only debugging-related symbols should be stripped. It defaults to
1695− <literal>lib bin sbin</literal>.
1288+ List of directories to search for libraries and executables from which only debugging-related symbols should be stripped. It defaults to <literal>lib bin sbin</literal>.
16961289 </para>
16971290 </listitem>
16981291 </varlistentry>
@@ -1702,9 +1295,7 @@ installTargets = "install-bin install-doc";</programlisting>
17021295 </term>
17031296 <listitem>
17041297 <para>
1705− Flags passed to the <command>strip</command> command applied to the
1706− files in the directories listed in <varname>stripDebugList</varname>.
1707− Defaults to <option>-S</option> (i.e. <option>--strip-debug</option>).
1298+ Flags passed to the <command>strip</command> command applied to the files in the directories listed in <varname>stripDebugList</varname>. Defaults to <option>-S</option> (i.e. <option>--strip-debug</option>).
17081299 </para>
17091300 </listitem>
17101301 </varlistentry>
@@ -1714,8 +1305,7 @@ installTargets = "install-bin install-doc";</programlisting>
17141305 </term>
17151306 <listitem>
17161307 <para>
1717− If set, the <command>patchelf</command> command is not used to remove
1718− unnecessary <literal>RPATH</literal> entries. Only applies to Linux.
1308+ If set, the <command>patchelf</command> command is not used to remove unnecessary <literal>RPATH</literal> entries. Only applies to Linux.
17191309 </para>
17201310 </listitem>
17211311 </varlistentry>
@@ -1725,8 +1315,7 @@ installTargets = "install-bin install-doc";</programlisting>
17251315 </term>
17261316 <listitem>
17271317 <para>
1728− If set, scripts starting with <literal>#!</literal> do not have their
1729− interpreter paths rewritten to paths in the Nix store.
1318+ If set, scripts starting with <literal>#!</literal> do not have their interpreter paths rewritten to paths in the Nix store.
17301319 </para>
17311320 </listitem>
17321321 </varlistentry>
@@ -1736,9 +1325,7 @@ installTargets = "install-bin install-doc";</programlisting>
17361325 </term>
17371326 <listitem>
17381327 <para>
1739− If set, libtool <literal>.la</literal> files associated with shared
1740− libraries won't have their <literal>dependency_libs</literal> field
1741− cleared.
1328+ If set, libtool <literal>.la</literal> files associated with shared libraries won't have their <literal>dependency_libs</literal> field cleared.
17421329 </para>
17431330 </listitem>
17441331 </varlistentry>
@@ -1748,9 +1335,7 @@ installTargets = "install-bin install-doc";</programlisting>
17481335 </term>
17491336 <listitem>
17501337 <para>
1751− The list of directories that must be moved from
1752− <filename>$out</filename> to <filename>$out/share</filename>. Defaults
1753− to <literal>man doc info</literal>.
1338+ The list of directories that must be moved from <filename>$out</filename> to <filename>$out/share</filename>. Defaults to <literal>man doc info</literal>.
17541339 </para>
17551340 </listitem>
17561341 </varlistentry>
@@ -1760,11 +1345,7 @@ installTargets = "install-bin install-doc";</programlisting>
17601345 </term>
17611346 <listitem>
17621347 <para>
1763− A package can export a <link linkend="ssec-setup-hooks">setup
1764− hook</link> by setting this variable. The setup hook, if defined, is
1765− copied to <filename>$out/nix-support/setup-hook</filename>. Environment
1766− variables are then substituted in it using
1767− <function
1348+ A package can export a <link linkend="ssec-setup-hooks">setup hook</link> by setting this variable. The setup hook, if defined, is copied to <filename>$out/nix-support/setup-hook</filename>. Environment variables are then substituted in it using <function
17681349 linkend="fun-substituteAll">substituteAll</function>.
17691350 </para>
17701351 </listitem>
@@ -1795,25 +1376,14 @@ installTargets = "install-bin install-doc";</programlisting>
17951376 </term>
17961377 <listitem>
17971378 <para>
1798− If set to <literal>true</literal>, the standard environment will enable
1799− debug information in C/C++ builds. After installation, the debug
1800− information will be separated from the executables and stored in the
1801− output named <literal>debug</literal>. (This output is enabled
1802− automatically; you don’t need to set the <varname>outputs</varname>
1803− attribute explicitly.) To be precise, the debug information is stored in
1804− <filename><replaceable>debug</replaceable>/lib/debug/.build-id/<replaceable>XX</replaceable>/<replaceable>YYYY…</replaceable></filename>,
1805− where <replaceable>XXYYYY…</replaceable> is the <replaceable>build
1806− ID</replaceable> of the binary — a SHA-1 hash of the contents of the
1807− binary. Debuggers like GDB use the build ID to look up the separated
1808− debug information.
1379+ If set to <literal>true</literal>, the standard environment will enable debug information in C/C++ builds. After installation, the debug information will be separated from the executables and stored in the output named <literal>debug</literal>. (This output is enabled automatically; you don’t need to set the <varname>outputs</varname> attribute explicitly.) To be precise, the debug information is stored in <filename><replaceable>debug</replaceable>/lib/debug/.build-id/<replaceable>XX</replaceable>/<replaceable>YYYY…</replaceable></filename>, where <replaceable>XXYYYY…</replaceable> is the <replaceable>build ID</replaceable> of the binary — a SHA-1 hash of the contents of the binary. Debuggers like GDB use the build ID to look up the separated debug information.
18091380 </para>
18101381 <para>
18111382 For example, with GDB, you can add
18121383<programlisting>
18131384set debug-file-directory ~/.nix-profile/lib/debug
18141385</programlisting>
1815− to <filename>~/.gdbinit</filename>. GDB will then be able to find debug
1816− information installed via <literal>nix-env -i</literal>.
1386+ to <filename>~/.gdbinit</filename>. GDB will then be able to find debug information installed via <literal>nix-env -i</literal>.
18171387 </para>
18181388 </listitem>
18191389 </varlistentry>
@@ -1824,10 +1394,7 @@ set debug-file-directory ~/.nix-profile/lib/debug
18241394 <title>The installCheck phase</title>
18251395
18261396 <para>
1827− The installCheck phase checks whether the package was installed correctly
1828− by running its test suite against the installed directories. The default
1829− <function>installCheck</function> calls <command>make
1830− installcheck</command>.
1397+ The installCheck phase checks whether the package was installed correctly by running its test suite against the installed directories. The default <function>installCheck</function> calls <command>make installcheck</command>.
18311398 </para>
18321399
18331400 <variablelist>
@@ -1838,14 +1405,9 @@ set debug-file-directory ~/.nix-profile/lib/debug
18381405 </term>
18391406 <listitem>
18401407 <para>
1841− Controls whether the installCheck phase is executed. By default it is
1842− skipped, but if <varname>doInstallCheck</varname> is set to true, the
1843− installCheck phase is usually executed. Thus you should set
1408+ Controls whether the installCheck phase is executed. By default it is skipped, but if <varname>doInstallCheck</varname> is set to true, the installCheck phase is usually executed. Thus you should set
18441409<programlisting>doInstallCheck = true;</programlisting>
1845− in the derivation to enable install checks. The exception is cross
1846− compilation. Cross compiled builds never run tests, no matter how
1847− <varname>doInstallCheck</varname> is set, as the newly-built program
1848− won't run on the platform used to build it.
1410+ in the derivation to enable install checks. The exception is cross compilation. Cross compiled builds never run tests, no matter how <varname>doInstallCheck</varname> is set, as the newly-built program won't run on the platform used to build it.
18491411 </para>
18501412 </listitem>
18511413 </varlistentry>
@@ -1855,8 +1417,7 @@ set debug-file-directory ~/.nix-profile/lib/debug
18551417 </term>
18561418 <listitem>
18571419 <para>
1858− The make target that runs the install tests. Defaults to
1859− <literal>installcheck</literal>.
1420+ The make target that runs the install tests. Defaults to <literal>installcheck</literal>.
18601421 </para>
18611422 </listitem>
18621423 </varlistentry>
@@ -1866,9 +1427,7 @@ set debug-file-directory ~/.nix-profile/lib/debug
18661427 </term>
18671428 <listitem>
18681429 <para>
1869− A list of strings passed as additional flags to <command>make</command>.
1870− Like <varname>makeFlags</varname> and <varname>makeFlagsArray</varname>,
1871− but only used by the installCheck phase.
1430+ A list of strings passed as additional flags to <command>make</command>. Like <varname>makeFlags</varname> and <varname>makeFlagsArray</varname>, but only used by the installCheck phase.
18721431 </para>
18731432 </listitem>
18741433 </varlistentry>
@@ -1878,9 +1437,7 @@ set debug-file-directory ~/.nix-profile/lib/debug
18781437 </term>
18791438 <listitem>
18801439 <para>
1881− A list of dependencies used by the phase. This gets included in
1882− <varname>nativeBuildInputs</varname> when
1883− <varname>doInstallCheck</varname> is set.
1440+ A list of dependencies used by the phase. This gets included in <varname>nativeBuildInputs</varname> when <varname>doInstallCheck</varname> is set.
18841441 </para>
18851442 </listitem>
18861443 </varlistentry>
@@ -1911,11 +1468,7 @@ set debug-file-directory ~/.nix-profile/lib/debug
19111468 <title>The distribution phase</title>
19121469
19131470 <para>
1914− The distribution phase is intended to produce a source distribution of the
1915− package. The default <function>distPhase</function> first calls
1916− <command>make dist</command>, then it copies the resulting source tarballs
1917− to <filename>$out/tarballs/</filename>. This phase is only executed if the
1918− attribute <varname>doDist</varname> is set.
1471+ The distribution phase is intended to produce a source distribution of the package. The default <function>distPhase</function> first calls <command>make dist</command>, then it copies the resulting source tarballs to <filename>$out/tarballs/</filename>. This phase is only executed if the attribute <varname>doDist</varname> is set.
19191472 </para>
19201473
19211474 <variablelist>
@@ -1926,8 +1479,7 @@ set debug-file-directory ~/.nix-profile/lib/debug
19261479 </term>
19271480 <listitem>
19281481 <para>
1929− The make target that produces the distribution. Defaults to
1930− <literal>dist</literal>.
1482+ The make target that produces the distribution. Defaults to <literal>dist</literal>.
19311483 </para>
19321484 </listitem>
19331485 </varlistentry>
@@ -1947,9 +1499,7 @@ set debug-file-directory ~/.nix-profile/lib/debug
19471499 </term>
19481500 <listitem>
19491501 <para>
1950− The names of the source distribution files to be copied to
1951− <filename>$out/tarballs/</filename>. It can contain shell wildcards. The
1952− default is <filename>*.tar.gz</filename>.
1502+ The names of the source distribution files to be copied to <filename>$out/tarballs/</filename>. It can contain shell wildcards. The default is <filename>*.tar.gz</filename>.
19531503 </para>
19541504 </listitem>
19551505 </varlistentry>
@@ -2000,8 +1550,7 @@ set debug-file-directory ~/.nix-profile/lib/debug
20001550 </term>
20011551 <listitem>
20021552 <para>
2003− Constructs a wrapper for a program with various possible arguments. For
2004− example:
1553+ Constructs a wrapper for a program with various possible arguments. For example:
20051554<programlisting>
20061555# adds `FOOBAR=baz` to `$out/bin/foo`’s environment
20071556makeWrapper $out/bin/foo $wrapperfile --set FOOBAR baz
@@ -2011,12 +1560,10 @@ makeWrapper $out/bin/foo $wrapperfile --set FOOBAR baz
20111560# (via string replacements or in `configurePhase`).
20121561makeWrapper $out/bin/foo $wrapperfile --prefix PATH : ${lib.makeBinPath [ hello git ]}
20131562</programlisting>
2014− There’s many more kinds of arguments, they are documented in
2015− <literal>nixpkgs/pkgs/build-support/setup-hooks/make-wrapper.sh</literal>.
1563+ There’s many more kinds of arguments, they are documented in <literal>nixpkgs/pkgs/build-support/setup-hooks/make-wrapper.sh</literal>.
20161564 </para>
20171565 <para>
2018− <literal>wrapProgram</literal> is a convenience function you probably
2019− want to use most of the time.
1566+ <literal>wrapProgram</literal> is a convenience function you probably want to use most of the time.
20201567 </para>
20211568 </listitem>
20221569 </varlistentry>
@@ -2026,10 +1573,7 @@ makeWrapper $out/bin/foo $wrapperfile --prefix PATH : ${lib.makeBinPath [ hello
20261573 </term>
20271574 <listitem>
20281575 <para>
2029− Performs string substitution on the contents of
2030− <replaceable>infile</replaceable>, writing the result to
2031− <replaceable>outfile</replaceable>. The substitutions in
2032− <replaceable>subs</replaceable> are of the following form:
1576+ Performs string substitution on the contents of <replaceable>infile</replaceable>, writing the result to <replaceable>outfile</replaceable>. The substitutions in <replaceable>subs</replaceable> are of the following form:
20331577 <variablelist>
20341578 <varlistentry>
20351579 <term>
@@ -2037,8 +1581,7 @@ makeWrapper $out/bin/foo $wrapperfile --prefix PATH : ${lib.makeBinPath [ hello
20371581 </term>
20381582 <listitem>
20391583 <para>
2040− Replace every occurrence of the string <replaceable>s1</replaceable>
2041− by <replaceable>s2</replaceable>.
1584+ Replace every occurrence of the string <replaceable>s1</replaceable> by <replaceable>s2</replaceable>.
20421585 </para>
20431586 </listitem>
20441587 </varlistentry>
@@ -2048,13 +1591,7 @@ makeWrapper $out/bin/foo $wrapperfile --prefix PATH : ${lib.makeBinPath [ hello
20481591 </term>
20491592 <listitem>
20501593 <para>
2051− Replace every occurrence of
2052− <literal>@<replaceable>varName</replaceable>@</literal> by the
2053− contents of the environment variable
2054− <replaceable>varName</replaceable>. This is useful for generating
2055− files from templates, using
2056− <literal>@<replaceable>...</replaceable>@</literal> in the template
2057− as placeholders.
1594+ Replace every occurrence of <literal>@<replaceable>varName</replaceable>@</literal> by the contents of the environment variable <replaceable>varName</replaceable>. This is useful for generating files from templates, using <literal>@<replaceable>...</replaceable>@</literal> in the template as placeholders.
20581595 </para>
20591596 </listitem>
20601597 </varlistentry>
@@ -2064,9 +1601,7 @@ makeWrapper $out/bin/foo $wrapperfile --prefix PATH : ${lib.makeBinPath [ hello
20641601 </term>
20651602 <listitem>
20661603 <para>
2067− Replace every occurrence of
2068− <literal>@<replaceable>varName</replaceable>@</literal> by the string
2069− <replaceable>s</replaceable>.
1604+ Replace every occurrence of <literal>@<replaceable>varName</replaceable>@</literal> by the string <replaceable>s</replaceable>.
20701605 </para>
20711606 </listitem>
20721607 </varlistentry>
@@ -2082,14 +1617,8 @@ substitute ./foo.in ./foo.out \
20821617</programlisting>
20831618 </para>
20841619 <para>
2085− <function>substitute</function> is implemented using the
2086− <command
2087− xlink:href="http://replace.richardlloyd.org.uk/">replace</command>
2088− command. Unlike with the <command>sed</command> command, you don’t have
2089− to worry about escaping special characters. It supports performing
2090− substitutions on binary files (such as executables), though there
2091− you’ll probably want to make sure that the replacement string is as
2092− long as the replaced string.
1620+ <function>substitute</function> is implemented using the <command
1621+ xlink:href="http://replace.richardlloyd.org.uk/">replace</command> command. Unlike with the <command>sed</command> command, you don’t have to worry about escaping special characters. It supports performing substitutions on binary files (such as executables), though there you’ll probably want to make sure that the replacement string is as long as the replaced string.
20931622 </para>
20941623 </listitem>
20951624 </varlistentry>
@@ -2099,8 +1628,7 @@ substitute ./foo.in ./foo.out \
20991628 </term>
21001629 <listitem>
21011630 <para>
2102− Like <function>substitute</function>, but performs the substitutions in
2103− place on the file <replaceable>file</replaceable>.
1631+ Like <function>substitute</function>, but performs the substitutions in place on the file <replaceable>file</replaceable>.
21041632 </para>
21051633 </listitem>
21061634 </varlistentry>
@@ -2110,22 +1638,13 @@ substitute ./foo.in ./foo.out \
21101638 </term>
21111639 <listitem>
21121640 <para>
2113− Replaces every occurrence of
2114− <literal>@<replaceable>varName</replaceable>@</literal>, where
2115− <replaceable>varName</replaceable> is any environment variable, in
2116− <replaceable>infile</replaceable>, writing the result to
2117− <replaceable>outfile</replaceable>. For instance, if
2118− <replaceable>infile</replaceable> has the contents
1641+ Replaces every occurrence of <literal>@<replaceable>varName</replaceable>@</literal>, where <replaceable>varName</replaceable> is any environment variable, in <replaceable>infile</replaceable>, writing the result to <replaceable>outfile</replaceable>. For instance, if <replaceable>infile</replaceable> has the contents
21191642<programlisting>
21201643#! @bash@/bin/sh
21211644PATH=@coreutils@/bin
21221645echo @foo@
21231646</programlisting>
2124− and the environment contains
2125− <literal>bash=/nix/store/bmwp0q28cf21...-bash-3.2-p39</literal> and
2126− <literal>coreutils=/nix/store/68afga4khv0w...-coreutils-6.12</literal>,
2127− but does not contain the variable <varname>foo</varname>, then the output
2128− will be
1647+ and the environment contains <literal>bash=/nix/store/bmwp0q28cf21...-bash-3.2-p39</literal> and <literal>coreutils=/nix/store/68afga4khv0w...-coreutils-6.12</literal>, but does not contain the variable <varname>foo</varname>, then the output will be
21291648<programlisting>
21301649#! /nix/store/bmwp0q28cf21...-bash-3.2-p39/bin/sh
21311650PATH=/nix/store/68afga4khv0w...-coreutils-6.12/bin
@@ -2134,13 +1653,7 @@ echo @foo@
21341653 That is, no substitution is performed for undefined variables.
21351654 </para>
21361655 <para>
2137− Environment variables that start with an uppercase letter or an
2138− underscore are filtered out, to prevent global variables (like
2139− <literal>HOME</literal>) or private variables (like
2140− <literal>__ETC_PROFILE_DONE</literal>) from accidentally getting
2141− substituted. The variables also have to be valid bash “names”, as
2142− defined in the bash manpage (alphanumeric or <literal>_</literal>, must
2143− not start with a number).
1656+ Environment variables that start with an uppercase letter or an underscore are filtered out, to prevent global variables (like <literal>HOME</literal>) or private variables (like <literal>__ETC_PROFILE_DONE</literal>) from accidentally getting substituted. The variables also have to be valid bash “names”, as defined in the bash manpage (alphanumeric or <literal>_</literal>, must not start with a number).
21441657 </para>
21451658 </listitem>
21461659 </varlistentry>
@@ -2150,8 +1663,7 @@ echo @foo@
21501663 </term>
21511664 <listitem>
21521665 <para>
2153− Like <function>substituteAll</function>, but performs the substitutions
2154− in place on the file <replaceable>file</replaceable>.
1666+ Like <function>substituteAll</function>, but performs the substitutions in place on the file <replaceable>file</replaceable>.
21551667 </para>
21561668 </listitem>
21571669 </varlistentry>
@@ -2161,14 +1673,12 @@ echo @foo@
21611673 </term>
21621674 <listitem>
21631675 <para>
2164− Strips the directory and hash part of a store path, outputting the name
2165− part to <literal>stdout</literal>. For example:
1676+ Strips the directory and hash part of a store path, outputting the name part to <literal>stdout</literal>. For example:
21661677<programlisting>
21671678# prints coreutils-8.24
21681679stripHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
21691680</programlisting>
2170− If you wish to store the result in another variable, then the following
2171− idiom may be useful:
1681+ If you wish to store the result in another variable, then the following idiom may be useful:
21721682<programlisting>
21731683name="/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
21741684someVar=$(stripHash $name)
@@ -2182,13 +1692,10 @@ someVar=$(stripHash $name)
21821692 </term>
21831693 <listitem>
21841694 <para>
2185− Convenience function for <literal>makeWrapper</literal> that
2186− automatically creates a sane wrapper file It takes all the same arguments
2187− as <literal>makeWrapper</literal>, except for <literal>--argv0</literal>.
1695+ Convenience function for <literal>makeWrapper</literal> that automatically creates a sane wrapper file It takes all the same arguments as <literal>makeWrapper</literal>, except for <literal>--argv0</literal>.
21881696 </para>
21891697 <para>
2190− It cannot be applied multiple times, since it will overwrite the wrapper
2191− file.
1698+ It cannot be applied multiple times, since it will overwrite the wrapper file.
21921699 </para>
21931700 </listitem>
21941701 </varlistentry>
@@ -2198,85 +1705,34 @@ someVar=$(stripHash $name)
21981705 <title>Package setup hooks</title>
21991706
22001707 <para>
2201− Nix itself considers a build-time dependency as merely something that should
2202− previously be built and accessible at build time—packages themselves are
2203− on their own to perform any additional setup. In most cases, that is fine,
2204− and the downstream derivation can deal with its own dependencies. But for a
2205− few common tasks, that would result in almost every package doing the same
2206− sort of setup work—depending not on the package itself, but entirely on
2207− which dependencies were used.
1708+ Nix itself considers a build-time dependency as merely something that should previously be built and accessible at build time—packages themselves are on their own to perform any additional setup. In most cases, that is fine, and the downstream derivation can deal with its own dependencies. But for a few common tasks, that would result in almost every package doing the same sort of setup work—depending not on the package itself, but entirely on which dependencies were used.
22081709 </para>
22091710
22101711 <para>
2211− In order to alleviate this burden, the <firstterm>setup hook</firstterm>
2212− mechanism was written, where any package can include a shell script that [by
2213− convention rather than enforcement by Nix], any downstream
2214− reverse-dependency will source as part of its build process. That allows the
2215− downstream dependency to merely specify its dependencies, and lets those
2216− dependencies effectively initialize themselves. No boilerplate mirroring the
2217− list of dependencies is needed.
1712+ In order to alleviate this burden, the <firstterm>setup hook</firstterm> mechanism was written, where any package can include a shell script that [by convention rather than enforcement by Nix], any downstream reverse-dependency will source as part of its build process. That allows the downstream dependency to merely specify its dependencies, and lets those dependencies effectively initialize themselves. No boilerplate mirroring the list of dependencies is needed.
22181713 </para>
22191714
22201715 <para>
2221− The setup hook mechanism is a bit of a sledgehammer though: a powerful
2222− feature with a broad and indiscriminate area of effect. The combination of
2223− its power and implicit use may be expedient, but isn't without costs. Nix
2224− itself is unchanged, but the spirit of added dependencies being effect-free
2225− is violated even if the letter isn't. For example, if a derivation path is
2226− mentioned more than once, Nix itself doesn't care and simply makes sure the
2227− dependency derivation is already built just the same—depending is just
2228− needing something to exist, and needing is idempotent. However, a dependency
2229− specified twice will have its setup hook run twice, and that could easily
2230− change the build environment (though a well-written setup hook will
2231− therefore strive to be idempotent so this is in fact not observable). More
2232− broadly, setup hooks are anti-modular in that multiple dependencies, whether
2233− the same or different, should not interfere and yet their setup hooks may
2234− well do so.
1716+ The setup hook mechanism is a bit of a sledgehammer though: a powerful feature with a broad and indiscriminate area of effect. The combination of its power and implicit use may be expedient, but isn't without costs. Nix itself is unchanged, but the spirit of added dependencies being effect-free is violated even if the letter isn't. For example, if a derivation path is mentioned more than once, Nix itself doesn't care and simply makes sure the dependency derivation is already built just the same—depending is just needing something to exist, and needing is idempotent. However, a dependency specified twice will have its setup hook run twice, and that could easily change the build environment (though a well-written setup hook will therefore strive to be idempotent so this is in fact not observable). More broadly, setup hooks are anti-modular in that multiple dependencies, whether the same or different, should not interfere and yet their setup hooks may well do so.
22351717 </para>
22361718
22371719 <para>
2238− The most typical use of the setup hook is actually to add other hooks which
2239− are then run (i.e. after all the setup hooks) on each dependency. For
2240− example, the C compiler wrapper's setup hook feeds itself flags for each
2241− dependency that contains relevant libraries and headers. This is done by
2242− defining a bash function, and appending its name to one of
2243− <envar>envBuildBuildHooks</envar>`, <envar>envBuildHostHooks</envar>`,
2244− <envar>envBuildTargetHooks</envar>`, <envar>envHostHostHooks</envar>`,
2245− <envar>envHostTargetHooks</envar>`, or <envar>envTargetTargetHooks</envar>`.
2246− These 6 bash variables correspond to the 6 sorts of dependencies by platform
2247− (there's 12 total but we ignore the propagated/non-propagated axis).
1720+ The most typical use of the setup hook is actually to add other hooks which are then run (i.e. after all the setup hooks) on each dependency. For example, the C compiler wrapper's setup hook feeds itself flags for each dependency that contains relevant libraries and headers. This is done by defining a bash function, and appending its name to one of <envar>envBuildBuildHooks</envar>`, <envar>envBuildHostHooks</envar>`, <envar>envBuildTargetHooks</envar>`, <envar>envHostHostHooks</envar>`, <envar>envHostTargetHooks</envar>`, or <envar>envTargetTargetHooks</envar>`. These 6 bash variables correspond to the 6 sorts of dependencies by platform (there's 12 total but we ignore the propagated/non-propagated axis).
22481721 </para>
22491722
22501723 <para>
2251− Packages adding a hook should not hard code a specific hook, but rather
2252− choose a variable <emphasis>relative</emphasis> to how they are included.
2253− Returning to the C compiler wrapper example, if the wrapper itself is an
2254− <literal>n</literal> dependency, then it only wants to accumulate flags from
2255− <literal>n + 1</literal> dependencies, as only those ones match the
2256− compiler's target platform. The <envar>hostOffset</envar> variable is
2257− defined with the current dependency's host offset
2258− <envar>targetOffset</envar> with its target offset, before its setup hook is
2259− sourced. Additionally, since most environment hooks don't care about the
2260− target platform, that means the setup hook can append to the right bash
2261− array by doing something like
1724+ Packages adding a hook should not hard code a specific hook, but rather choose a variable <emphasis>relative</emphasis> to how they are included. Returning to the C compiler wrapper example, if the wrapper itself is an <literal>n</literal> dependency, then it only wants to accumulate flags from <literal>n + 1</literal> dependencies, as only those ones match the compiler's target platform. The <envar>hostOffset</envar> variable is defined with the current dependency's host offset <envar>targetOffset</envar> with its target offset, before its setup hook is sourced. Additionally, since most environment hooks don't care about the target platform, that means the setup hook can append to the right bash array by doing something like
22621725<programlisting language="bash">
22631726addEnvHooks "$hostOffset" myBashFunction
22641727</programlisting>
22651728 </para>
22661729
22671730 <para>
2268− The <emphasis>existence</emphasis> of setups hooks has long been documented
2269− and packages inside Nixpkgs are free to use this mechanism. Other packages,
2270− however, should not rely on these mechanisms not changing between Nixpkgs
2271− versions. Because of the existing issues with this system, there's little
2272− benefit from mandating it be stable for any period of time.
1731+ The <emphasis>existence</emphasis> of setups hooks has long been documented and packages inside Nixpkgs are free to use this mechanism. Other packages, however, should not rely on these mechanisms not changing between Nixpkgs versions. Because of the existing issues with this system, there's little benefit from mandating it be stable for any period of time.
22731732 </para>
22741733
22751734 <para>
2276− First, let’s cover some setup hooks that are part of Nixpkgs default
2277− stdenv. This means that they are run for every package built using
2278− <function>stdenv.mkDerivation</function>. Some of these are platform
2279− specific, so they may run on Linux but not Darwin or vice-versa.
1735+ First, let’s cover some setup hooks that are part of Nixpkgs default stdenv. This means that they are run for every package built using <function>stdenv.mkDerivation</function>. Some of these are platform specific, so they may run on Linux but not Darwin or vice-versa.
22801736 <variablelist>
22811737 <varlistentry>
22821738 <term>
@@ -2284,10 +1740,7 @@ addEnvHooks "$hostOffset" myBashFunction
22841740 </term>
22851741 <listitem>
22861742 <para>
2287− This setup hook moves any installed documentation to the
2288− <literal>/share</literal> subdirectory directory. This includes the man,
2289− doc and info directories. This is needed for legacy programs that do not
2290− know how to use the <literal>share</literal> subdirectory.
1743+ This setup hook moves any installed documentation to the <literal>/share</literal> subdirectory directory. This includes the man, doc and info directories. This is needed for legacy programs that do not know how to use the <literal>share</literal> subdirectory.
22911744 </para>
22921745 </listitem>
22931746 </varlistentry>
@@ -2297,9 +1750,7 @@ addEnvHooks "$hostOffset" myBashFunction
22971750 </term>
22981751 <listitem>
22991752 <para>
2300− This setup hook compresses any man pages that have been installed. The
2301− compression is done using the gzip program. This helps to reduce the
2302− installed size of packages.
1753+ This setup hook compresses any man pages that have been installed. The compression is done using the gzip program. This helps to reduce the installed size of packages.
23031754 </para>
23041755 </listitem>
23051756 </varlistentry>
@@ -2309,9 +1760,7 @@ addEnvHooks "$hostOffset" myBashFunction
23091760 </term>
23101761 <listitem>
23111762 <para>
2312− This runs the strip command on installed binaries and libraries. This
2313− removes unnecessary information like debug symbols when they are not
2314− needed. This also helps to reduce the installed size of packages.
1763+ This runs the strip command on installed binaries and libraries. This removes unnecessary information like debug symbols when they are not needed. This also helps to reduce the installed size of packages.
23151764 </para>
23161765 </listitem>
23171766 </varlistentry>
@@ -2321,12 +1770,7 @@ addEnvHooks "$hostOffset" myBashFunction
23211770 </term>
23221771 <listitem>
23231772 <para>
2324− This setup hook patches installed scripts to use the full path to the
2325− shebang interpreter. A shebang interpreter is the first commented line
2326− of a script telling the operating system which program will run the
2327− script (e.g <literal>#!/bin/bash</literal>). In Nix, we want an exact
2328− path to that interpreter to be used. This often replaces
2329− <literal>/bin/sh</literal> with a path in the Nix store.
1773+ This setup hook patches installed scripts to use the full path to the shebang interpreter. A shebang interpreter is the first commented line of a script telling the operating system which program will run the script (e.g <literal>#!/bin/bash</literal>). In Nix, we want an exact path to that interpreter to be used. This often replaces <literal>/bin/sh</literal> with a path in the Nix store.
23301774 </para>
23311775 </listitem>
23321776 </varlistentry>
@@ -2336,10 +1780,7 @@ addEnvHooks "$hostOffset" myBashFunction
23361780 </term>
23371781 <listitem>
23381782 <para>
2339− This verifies that no references are left from the install binaries to
2340− the directory used to build those binaries. This ensures that the
2341− binaries do not need things outside the Nix store. This is currently
2342− supported in Linux only.
1783+ This verifies that no references are left from the install binaries to the directory used to build those binaries. This ensures that the binaries do not need things outside the Nix store. This is currently supported in Linux only.
23431784 </para>
23441785 </listitem>
23451786 </varlistentry>
@@ -2349,12 +1790,7 @@ addEnvHooks "$hostOffset" myBashFunction
23491790 </term>
23501791 <listitem>
23511792 <para>
2352− This setup hook adds configure flags that tell packages to install files
2353− into any one of the proper outputs listed in <literal>outputs</literal>.
2354− This behavior can be turned off by setting
2355− <literal>setOutputFlags</literal> to false in the derivation
2356− environment. See <xref linkend="chap-multiple-output"/> for more
2357− information.
1793+ This setup hook adds configure flags that tell packages to install files into any one of the proper outputs listed in <literal>outputs</literal>. This behavior can be turned off by setting <literal>setOutputFlags</literal> to false in the derivation environment. See <xref linkend="chap-multiple-output"/> for more information.
23581794 </para>
23591795 </listitem>
23601796 </varlistentry>
@@ -2364,9 +1800,7 @@ addEnvHooks "$hostOffset" myBashFunction
23641800 </term>
23651801 <listitem>
23661802 <para>
2367− This setup hook moves any binaries installed in the sbin subdirectory
2368− into bin. In addition, a link is provided from sbin to bin for
2369− compatibility.
1803+ This setup hook moves any binaries installed in the sbin subdirectory into bin. In addition, a link is provided from sbin to bin for compatibility.
23701804 </para>
23711805 </listitem>
23721806 </varlistentry>
@@ -2376,9 +1810,7 @@ addEnvHooks "$hostOffset" myBashFunction
23761810 </term>
23771811 <listitem>
23781812 <para>
2379− This setup hook moves any libraries installed in the lib64 subdirectory
2380− into lib. In addition, a link is provided from lib64 to lib for
2381− compatibility.
1813+ This setup hook moves any libraries installed in the lib64 subdirectory into lib. In addition, a link is provided from lib64 to lib for compatibility.
23821814 </para>
23831815 </listitem>
23841816 </varlistentry>
@@ -2388,8 +1820,7 @@ addEnvHooks "$hostOffset" myBashFunction
23881820 </term>
23891821 <listitem>
23901822 <para>
2391− This sets <literal>SOURCE_DATE_EPOCH</literal> to the modification time
2392− of the most recent file.
1823+ This sets <literal>SOURCE_DATE_EPOCH</literal> to the modification time of the most recent file.
23931824 </para>
23941825 </listitem>
23951826 </varlistentry>
@@ -2399,70 +1830,22 @@ addEnvHooks "$hostOffset" myBashFunction
23991830 </term>
24001831 <listitem>
24011832 <para>
2402− The Bintools Wrapper wraps the binary utilities for a bunch of
2403− miscellaneous purposes. These are GNU Binutils when targetting Linux,
2404− and a mix of cctools and GNU binutils for Darwin. [The "Bintools" name
2405− is supposed to be a compromise between "Binutils" and "cctools" not
2406− denoting any specific implementation.] Specifically, the underlying
2407− bintools package, and a C standard library (glibc or Darwin's libSystem,
2408− just for the dynamic loader) are all fed in, and dependency finding,
2409− hardening (see below), and purity checks for each are handled by the
2410− Bintools Wrapper. Packages typically depend on CC Wrapper, which in turn
2411− (at run time) depends on the Bintools Wrapper.
2412− </para>
2413− <para>
2414− The Bintools Wrapper was only just recently split off from CC Wrapper,
2415− so the division of labor is still being worked out. For example, it
2416− shouldn't care about the C standard library, but just take a derivation
2417− with the dynamic loader (which happens to be the glibc on linux).
2418− Dependency finding however is a task both wrappers will continue to need
2419− to share, and probably the most important to understand. It is currently
2420− accomplished by collecting directories of host-platform dependencies
2421− (i.e. <varname>buildInputs</varname> and
2422− <varname>nativeBuildInputs</varname>) in environment variables. The
2423− Bintools Wrapper's setup hook causes any <filename>lib</filename> and
2424− <filename>lib64</filename> subdirectories to be added to
2425− <envar>NIX_LDFLAGS</envar>. Since the CC Wrapper and the Bintools
2426− Wrapper use the same strategy, most of the Bintools Wrapper code is
2427− sparsely commented and refers to the CC Wrapper. But the CC Wrapper's
2428− code, by contrast, has quite lengthy comments. The Bintools Wrapper
2429− merely cites those, rather than repeating them, to avoid falling out of
2430− sync.
2431− </para>
2432− <para>
2433− A final task of the setup hook is defining a number of standard
2434− environment variables to tell build systems which executables fulfill
2435− which purpose. They are defined to just be the base name of the tools,
2436− under the assumption that the Bintools Wrapper's binaries will be on the
2437− path. Firstly, this helps poorly-written packages, e.g. ones that look
2438− for just <command>gcc</command> when <envar>CC</envar> isn't defined yet
2439− <command>clang</command> is to be used. Secondly, this helps packages
2440− not get confused when cross-compiling, in which case multiple Bintools
2441− Wrappers may simultaneously be in use.
1833+ The Bintools Wrapper wraps the binary utilities for a bunch of miscellaneous purposes. These are GNU Binutils when targetting Linux, and a mix of cctools and GNU binutils for Darwin. [The "Bintools" name is supposed to be a compromise between "Binutils" and "cctools" not denoting any specific implementation.] Specifically, the underlying bintools package, and a C standard library (glibc or Darwin's libSystem, just for the dynamic loader) are all fed in, and dependency finding, hardening (see below), and purity checks for each are handled by the Bintools Wrapper. Packages typically depend on CC Wrapper, which in turn (at run time) depends on the Bintools Wrapper.
1834+ </para>
1835+ <para>
1836+ The Bintools Wrapper was only just recently split off from CC Wrapper, so the division of labor is still being worked out. For example, it shouldn't care about the C standard library, but just take a derivation with the dynamic loader (which happens to be the glibc on linux). Dependency finding however is a task both wrappers will continue to need to share, and probably the most important to understand. It is currently accomplished by collecting directories of host-platform dependencies (i.e. <varname>buildInputs</varname> and <varname>nativeBuildInputs</varname>) in environment variables. The Bintools Wrapper's setup hook causes any <filename>lib</filename> and <filename>lib64</filename> subdirectories to be added to <envar>NIX_LDFLAGS</envar>. Since the CC Wrapper and the Bintools Wrapper use the same strategy, most of the Bintools Wrapper code is sparsely commented and refers to the CC Wrapper. But the CC Wrapper's code, by contrast, has quite lengthy comments. The Bintools Wrapper merely cites those, rather than repeating them, to avoid falling out of sync.
1837+ </para>
1838+ <para>
1839+ A final task of the setup hook is defining a number of standard environment variables to tell build systems which executables fulfill which purpose. They are defined to just be the base name of the tools, under the assumption that the Bintools Wrapper's binaries will be on the path. Firstly, this helps poorly-written packages, e.g. ones that look for just <command>gcc</command> when <envar>CC</envar> isn't defined yet <command>clang</command> is to be used. Secondly, this helps packages not get confused when cross-compiling, in which case multiple Bintools Wrappers may simultaneously be in use.
24421840 <footnote xml:id="footnote-stdenv-per-platform-wrapper">
24431841 <para>
2444− Each wrapper targets a single platform, so if binaries for multiple
2445− platforms are needed, the underlying binaries must be wrapped multiple
2446− times. As this is a property of the wrapper itself, the multiple
2447− wrappings are needed whether or not the same underlying binaries can
2448− target multiple platforms.
1842+ Each wrapper targets a single platform, so if binaries for multiple platforms are needed, the underlying binaries must be wrapped multiple times. As this is a property of the wrapper itself, the multiple wrappings are needed whether or not the same underlying binaries can target multiple platforms.
24491843 </para>
24501844 </footnote>
2451− <envar>BUILD_</envar>- and <envar>TARGET_</envar>-prefixed versions of
2452− the normal environment variable are defined for additional Bintools
2453− Wrappers, properly disambiguating them.
1845+ <envar>BUILD_</envar>- and <envar>TARGET_</envar>-prefixed versions of the normal environment variable are defined for additional Bintools Wrappers, properly disambiguating them.
24541846 </para>
24551847 <para>
2456− A problem with this final task is that the Bintools Wrapper is honest
2457− and defines <envar>LD</envar> as <command>ld</command>. Most packages,
2458− however, firstly use the C compiler for linking, secondly use
2459− <envar>LD</envar> anyways, defining it as the C compiler, and thirdly,
2460− only so define <envar>LD</envar> when it is undefined as a fallback.
2461− This triple-threat means Bintools Wrapper will break those packages, as
2462− LD is already defined as the actual linker which the package won't
2463− override yet doesn't want to use. The workaround is to define, just for
2464− the problematic package, <envar>LD</envar> as the C compiler. A good way
2465− to do this would be <command>preConfigure = "LD=$CC"</command>.
1848+ A problem with this final task is that the Bintools Wrapper is honest and defines <envar>LD</envar> as <command>ld</command>. Most packages, however, firstly use the C compiler for linking, secondly use <envar>LD</envar> anyways, defining it as the C compiler, and thirdly, only so define <envar>LD</envar> when it is undefined as a fallback. This triple-threat means Bintools Wrapper will break those packages, as LD is already defined as the actual linker which the package won't override yet doesn't want to use. The workaround is to define, just for the problematic package, <envar>LD</envar> as the C compiler. A good way to do this would be <command>preConfigure = "LD=$CC"</command>.
24661849 </para>
24671850 </listitem>
24681851 </varlistentry>
@@ -2472,31 +1855,13 @@ addEnvHooks "$hostOffset" myBashFunction
24721855 </term>
24731856 <listitem>
24741857 <para>
2475− The CC Wrapper wraps a C toolchain for a bunch of miscellaneous
2476− purposes. Specifically, a C compiler (GCC or Clang), wrapped binary
2477− tools, and a C standard library (glibc or Darwin's libSystem, just for
2478− the dynamic loader) are all fed in, and dependency finding, hardening
2479− (see below), and purity checks for each are handled by the CC Wrapper.
2480− Packages typically depend on the CC Wrapper, which in turn (at run-time)
2481− depends on the Bintools Wrapper.
1858+ The CC Wrapper wraps a C toolchain for a bunch of miscellaneous purposes. Specifically, a C compiler (GCC or Clang), wrapped binary tools, and a C standard library (glibc or Darwin's libSystem, just for the dynamic loader) are all fed in, and dependency finding, hardening (see below), and purity checks for each are handled by the CC Wrapper. Packages typically depend on the CC Wrapper, which in turn (at run-time) depends on the Bintools Wrapper.
24821859 </para>
24831860 <para>
2484− Dependency finding is undoubtedly the main task of the CC Wrapper. This
2485− works just like the Bintools Wrapper, except that any
2486− <filename>include</filename> subdirectory of any relevant dependency is
2487− added to <envar>NIX_CFLAGS_COMPILE</envar>. The setup hook itself
2488− contains some lengthy comments describing the exact convoluted mechanism
2489− by which this is accomplished.
1861+ Dependency finding is undoubtedly the main task of the CC Wrapper. This works just like the Bintools Wrapper, except that any <filename>include</filename> subdirectory of any relevant dependency is added to <envar>NIX_CFLAGS_COMPILE</envar>. The setup hook itself contains some lengthy comments describing the exact convoluted mechanism by which this is accomplished.
24901862 </para>
24911863 <para>
2492− Similarly, the CC Wrapper follows the Bintools Wrapper in defining
2493− standard environment variables with the names of the tools it wraps, for
2494− the same reasons described above. Importantly, while it includes a
2495− <command>cc</command> symlink to the c compiler for portability, the
2496− <envar>CC</envar> will be defined using the compiler's "real name" (i.e.
2497− <command>gcc</command> or <command>clang</command>). This helps lousy
2498− build systems that inspect on the name of the compiler rather than run
2499− it.
1864+ Similarly, the CC Wrapper follows the Bintools Wrapper in defining standard environment variables with the names of the tools it wraps, for the same reasons described above. Importantly, while it includes a <command>cc</command> symlink to the c compiler for portability, the <envar>CC</envar> will be defined using the compiler's "real name" (i.e. <command>gcc</command> or <command>clang</command>). This helps lousy build systems that inspect on the name of the compiler rather than run it.
25001865 </para>
25011866 </listitem>
25021867 </varlistentry>
@@ -2504,9 +1869,7 @@ addEnvHooks "$hostOffset" myBashFunction
25041869 </para>
25051870
25061871 <para>
2507− Here are some more packages that provide a setup hook. Since the list of
2508− hooks is extensible, this is not an exhaustive list the mechanism is only to
2509− be used as a last resort, it might cover most uses.
1872+ Here are some more packages that provide a setup hook. Since the list of hooks is extensible, this is not an exhaustive list the mechanism is only to be used as a last resort, it might cover most uses.
25101873 <variablelist>
25111874 <varlistentry>
25121875 <term>
@@ -2514,11 +1877,7 @@ addEnvHooks "$hostOffset" myBashFunction
25141877 </term>
25151878 <listitem>
25161879 <para>
2517− Adds the <filename>lib/site_perl</filename> subdirectory of each build
2518− input to the <envar>PERL5LIB</envar> environment variable. For instance,
2519− if <varname>buildInputs</varname> contains Perl, then the
2520− <filename>lib/site_perl</filename> subdirectory of each input is added
2521− to the <envar>PERL5LIB</envar> environment variable.
1880+ Adds the <filename>lib/site_perl</filename> subdirectory of each build input to the <envar>PERL5LIB</envar> environment variable. For instance, if <varname>buildInputs</varname> contains Perl, then the <filename>lib/site_perl</filename> subdirectory of each input is added to the <envar>PERL5LIB</envar> environment variable.
25221881 </para>
25231882 </listitem>
25241883 </varlistentry>
@@ -2528,9 +1887,7 @@ addEnvHooks "$hostOffset" myBashFunction
25281887 </term>
25291888 <listitem>
25301889 <para>
2531− Adds the <filename>lib/${python.libPrefix}/site-packages</filename>
2532− subdirectory of each build input to the <envar>PYTHONPATH</envar>
2533− environment variable.
1890+ Adds the <filename>lib/${python.libPrefix}/site-packages</filename> subdirectory of each build input to the <envar>PYTHONPATH</envar> environment variable.
25341891 </para>
25351892 </listitem>
25361893 </varlistentry>
@@ -2540,9 +1897,7 @@ addEnvHooks "$hostOffset" myBashFunction
25401897 </term>
25411898 <listitem>
25421899 <para>
2543− Adds the <filename>lib/pkgconfig</filename> and
2544− <filename>share/pkgconfig</filename> subdirectories of each build input
2545− to the <envar>PKG_CONFIG_PATH</envar> environment variable.
1900+ Adds the <filename>lib/pkgconfig</filename> and <filename>share/pkgconfig</filename> subdirectories of each build input to the <envar>PKG_CONFIG_PATH</envar> environment variable.
25461901 </para>
25471902 </listitem>
25481903 </varlistentry>
@@ -2552,8 +1907,7 @@ addEnvHooks "$hostOffset" myBashFunction
25521907 </term>
25531908 <listitem>
25541909 <para>
2555− Adds the <filename>share/aclocal</filename> subdirectory of each build
2556− input to the <envar>ACLOCAL_PATH</envar> environment variable.
1910+ Adds the <filename>share/aclocal</filename> subdirectory of each build input to the <envar>ACLOCAL_PATH</envar> environment variable.
25571911 </para>
25581912 </listitem>
25591913 </varlistentry>
@@ -2563,12 +1917,7 @@ addEnvHooks "$hostOffset" myBashFunction
25631917 </term>
25641918 <listitem>
25651919 <para>
2566− The <varname>autoreconfHook</varname> derivation adds
2567− <varname>autoreconfPhase</varname>, which runs autoreconf, libtoolize
2568− and automake, essentially preparing the configure script in
2569− autotools-based builds. Most autotools-based packages come with the
2570− configure script pre-generated, but this hook is necessary for a few
2571− packages and when you need to patch the package’s configure scripts.
1920+ The <varname>autoreconfHook</varname> derivation adds <varname>autoreconfPhase</varname>, which runs autoreconf, libtoolize and automake, essentially preparing the configure script in autotools-based builds. Most autotools-based packages come with the configure script pre-generated, but this hook is necessary for a few packages and when you need to patch the package’s configure scripts.
25721921 </para>
25731922 </listitem>
25741923 </varlistentry>
@@ -2578,10 +1927,7 @@ addEnvHooks "$hostOffset" myBashFunction
25781927 </term>
25791928 <listitem>
25801929 <para>
2581− Adds every file named <filename>catalog.xml</filename> found under the
2582− <filename>xml/dtd</filename> and <filename>xml/xsl</filename>
2583− subdirectories of each build input to the
2584− <envar>XML_CATALOG_FILES</envar> environment variable.
1930+ Adds every file named <filename>catalog.xml</filename> found under the <filename>xml/dtd</filename> and <filename>xml/xsl</filename> subdirectories of each build input to the <envar>XML_CATALOG_FILES</envar> environment variable.
25851931 </para>
25861932 </listitem>
25871933 </varlistentry>
@@ -2591,8 +1937,7 @@ addEnvHooks "$hostOffset" myBashFunction
25911937 </term>
25921938 <listitem>
25931939 <para>
2594− Adds the <filename>share/texmf-nix</filename> subdirectory of each build
2595− input to the <envar>TEXINPUTS</envar> environment variable.
1940+ Adds the <filename>share/texmf-nix</filename> subdirectory of each build input to the <envar>TEXINPUTS</envar> environment variable.
25961941 </para>
25971942 </listitem>
25981943 </varlistentry>
@@ -2612,9 +1957,7 @@ addEnvHooks "$hostOffset" myBashFunction
26121957 </term>
26131958 <listitem>
26141959 <para>
2615− Exports <envar>GDK_PIXBUF_MODULE_FILE</envar> environment variable to
2616− the builder. Add librsvg package to <varname>buildInputs</varname> to
2617− get svg support.
1960+ Exports <envar>GDK_PIXBUF_MODULE_FILE</envar> environment variable to the builder. Add librsvg package to <varname>buildInputs</varname> to get svg support.
26181961 </para>
26191962 </listitem>
26201963 </varlistentry>
@@ -2624,8 +1967,7 @@ addEnvHooks "$hostOffset" myBashFunction
26241967 </term>
26251968 <listitem>
26261969 <para>
2627− Creates a temporary package database and registers every Haskell build
2628− input in it (TODO: how?).
1970+ Creates a temporary package database and registers every Haskell build input in it (TODO: how?).
26291971 </para>
26301972 </listitem>
26311973 </varlistentry>
@@ -2635,8 +1977,7 @@ addEnvHooks "$hostOffset" myBashFunction
26351977 </term>
26361978 <listitem>
26371979 <para>
2638− Hooks related to GNOME platform and related libraries like GLib, GTK and
2639− GStreamer are described in <xref linkend="sec-language-gnome" />.
1980+ Hooks related to GNOME platform and related libraries like GLib, GTK and GStreamer are described in <xref linkend="sec-language-gnome" />.
26401981 </para>
26411982 </listitem>
26421983 </varlistentry>
@@ -2646,15 +1987,10 @@ addEnvHooks "$hostOffset" myBashFunction
26461987 </term>
26471988 <listitem>
26481989 <para>
2649− This is a special setup hook which helps in packaging proprietary
2650− software in that it automatically tries to find missing shared library
2651− dependencies of ELF files based on the given
2652− <varname>buildInputs</varname> and <varname>nativeBuildInputs</varname>.
1990+ This is a special setup hook which helps in packaging proprietary software in that it automatically tries to find missing shared library dependencies of ELF files based on the given <varname>buildInputs</varname> and <varname>nativeBuildInputs</varname>.
26531991 </para>
26541992 <para>
2655− You can also specify a <envar>runtimeDependencies</envar> environment
2656− variable which lists dependencies that are unconditionally added to all
2657− executables.
1993+ You can also specify a <envar>runtimeDependencies</envar> environment variable which lists dependencies that are unconditionally added to all executables.
26581994 </para>
26591995 <para>
26601996 This is useful for programs that use <citerefentry>
@@ -2662,16 +1998,10 @@ addEnvHooks "$hostOffset" myBashFunction
26621998 <manvolnum>3</manvolnum> </citerefentry> to load libraries at runtime.
26631999 </para>
26642000 <para>
2665− In certain situations you may want to run the main command
2666− (<command>autoPatchelf</command>) of the setup hook on a file or a set
2667− of directories instead of unconditionally patching all outputs. This can
2668− be done by setting the <envar>dontAutoPatchelf</envar> environment
2669− variable to a non-empty value.
2001+ In certain situations you may want to run the main command (<command>autoPatchelf</command>) of the setup hook on a file or a set of directories instead of unconditionally patching all outputs. This can be done by setting the <envar>dontAutoPatchelf</envar> environment variable to a non-empty value.
26702002 </para>
26712003 <para>
2672− The <command>autoPatchelf</command> command also recognizes a
2673− <parameter class="command">--no-recurse</parameter> command line flag,
2674− which prevents it from recursing into subdirectories.
2004+ The <command>autoPatchelf</command> command also recognizes a <parameter class="command">--no-recurse</parameter> command line flag, which prevents it from recursing into subdirectories.
26752005 </para>
26762006 </listitem>
26772007 </varlistentry>
@@ -2681,36 +2011,16 @@ addEnvHooks "$hostOffset" myBashFunction
26812011 </term>
26822012 <listitem>
26832013 <para>
2684− This hook will make a build pause instead of stopping when a failure
2685− happens. It prevents nix from cleaning up the build environment
2686− immediately and allows the user to attach to a build environment using
2687− the <command>cntr</command> command. Upon build error it will print
2688− instructions on how to use <command>cntr</command>, which can be used to
2689− enter the environment for debugging. Installing cntr and running the
2690− command will provide shell access to the build sandbox of failed build.
2691− At <filename>/var/lib/cntr</filename> the sandboxed filesystem is
2692− mounted. All commands and files of the system are still accessible
2693− within the shell. To execute commands from the sandbox use the cntr exec
2694− subcommand. <command>cntr</command> is only supported on Linux-based
2695− platforms. To use it first add <literal>cntr</literal> to your
2696− <literal>environment.systemPackages</literal> on NixOS or alternatively
2697− to the root user on non-NixOS systems. Then in the package that is
2698− supposed to be inspected, add <literal>breakpointHook</literal> to
2699− <literal>nativeBuildInputs</literal>.
2014+ This hook will make a build pause instead of stopping when a failure happens. It prevents nix from cleaning up the build environment immediately and allows the user to attach to a build environment using the <command>cntr</command> command. Upon build error it will print instructions on how to use <command>cntr</command>, which can be used to enter the environment for debugging. Installing cntr and running the command will provide shell access to the build sandbox of failed build. At <filename>/var/lib/cntr</filename> the sandboxed filesystem is mounted. All commands and files of the system are still accessible within the shell. To execute commands from the sandbox use the cntr exec subcommand. <command>cntr</command> is only supported on Linux-based platforms. To use it first add <literal>cntr</literal> to your <literal>environment.systemPackages</literal> on NixOS or alternatively to the root user on non-NixOS systems. Then in the package that is supposed to be inspected, add <literal>breakpointHook</literal> to <literal>nativeBuildInputs</literal>.
27002015<programlisting>
27012016nativeBuildInputs = [ breakpointHook ];
27022017</programlisting>
2703− When a build failure happens there will be an instruction printed that
2704− shows how to attach with <literal>cntr</literal> to the build sandbox.
2018+ When a build failure happens there will be an instruction printed that shows how to attach with <literal>cntr</literal> to the build sandbox.
27052019 </para>
27062020 <note>
27072021 <title>Caution with remote builds</title>
27082022 <para>
2709− This won't work with remote builds as the build environment is on a
2710− different machine and can't be accessed by <command>cntr</command>.
2711− Remote builds can be turned off by setting <literal>--option builders
2712− ''</literal> for <command>nix-build</command> or <literal>--builders
2713− ''</literal> for <command>nix build</command>.
2023+ This won't work with remote builds as the build environment is on a different machine and can't be accessed by <command>cntr</command>. Remote builds can be turned off by setting <literal>--option builders ''</literal> for <command>nix-build</command> or <literal>--builders ''</literal> for <command>nix build</command>.
27142024 </para>
27152025 </note>
27162026 </listitem>
@@ -2721,28 +2031,13 @@ nativeBuildInputs = [ breakpointHook ];
27212031 </term>
27222032 <listitem>
27232033 <para>
2724− This hook helps with installing manpages and shell completion files. It
2725− exposes 2 shell functions <literal>installManPage</literal> and
2726− <literal>installShellCompletion</literal> that can be used from your
2727− <literal>postInstall</literal> hook.
2034+ This hook helps with installing manpages and shell completion files. It exposes 2 shell functions <literal>installManPage</literal> and <literal>installShellCompletion</literal> that can be used from your <literal>postInstall</literal> hook.
27282035 </para>
27292036 <para>
2730− The <literal>installManPage</literal> function takes one or more paths
2731− to manpages to install. The manpages must have a section suffix, and may
2732− optionally be compressed (with <literal>.gz</literal> suffix). This
2733− function will place them into the correct directory.
2037+ The <literal>installManPage</literal> function takes one or more paths to manpages to install. The manpages must have a section suffix, and may optionally be compressed (with <literal>.gz</literal> suffix). This function will place them into the correct directory.
27342038 </para>
27352039 <para>
2736− The <literal>installShellCompletion</literal> function takes one or more
2737− paths to shell completion files. By default it will autodetect the shell
2738− type from the completion file extension, but you may also specify it by
2739− passing one of <literal>--bash</literal>, <literal>--fish</literal>, or
2740− <literal>--zsh</literal>. These flags apply to all paths listed after
2741− them (up until another shell flag is given). Each path may also have a
2742− custom installation name provided by providing a flag <literal>--name
2743− NAME</literal> before the path. If this flag is not provided, zsh
2744− completions will be renamed automatically such that
2745− <literal>foobar.zsh</literal> becomes <literal>_foobar</literal>.
2040+ The <literal>installShellCompletion</literal> function takes one or more paths to shell completion files. By default it will autodetect the shell type from the completion file extension, but you may also specify it by passing one of <literal>--bash</literal>, <literal>--fish</literal>, or <literal>--zsh</literal>. These flags apply to all paths listed after them (up until another shell flag is given). Each path may also have a custom installation name provided by providing a flag <literal>--name NAME</literal> before the path. If this flag is not provided, zsh completions will be renamed automatically such that <literal>foobar.zsh</literal> becomes <literal>_foobar</literal>.
27462041<programlisting>
27472042nativeBuildInputs = [ installShellFiles ];
27482043postInstall = ''
@@ -2764,13 +2059,7 @@ postInstall = ''
27642059 </term>
27652060 <listitem>
27662061 <para>
2767− A few libraries automatically add to <literal>NIX_LDFLAGS</literal>
2768− their library, making their symbols automatically available to the
2769− linker. This includes libiconv and libintl (gettext). This is done to
2770− provide compatibility between GNU Linux, where libiconv and libintl are
2771− bundled in, and other systems where that might not be the case.
2772− Sometimes, this behavior is not desired. To disable this behavior, set
2773− <literal>dontAddExtraLibs</literal>.
2062+ A few libraries automatically add to <literal>NIX_LDFLAGS</literal> their library, making their symbols automatically available to the linker. This includes libiconv and libintl (gettext). This is done to provide compatibility between GNU Linux, where libiconv and libintl are bundled in, and other systems where that might not be the case. Sometimes, this behavior is not desired. To disable this behavior, set <literal>dontAddExtraLibs</literal>.
27742063 </para>
27752064 </listitem>
27762065 </varlistentry>
@@ -2780,16 +2069,7 @@ postInstall = ''
27802069 </term>
27812070 <listitem>
27822071 <para>
2783− Overrides the default configure phase to run the CMake command. By
2784− default, we use the Make generator of CMake. In addition, dependencies
2785− are added automatically to CMAKE_PREFIX_PATH so that packages are
2786− correctly detected by CMake. Some additional flags are passed in to give
2787− similar behavior to configure-based packages. You can disable this
2788− hook’s behavior by setting configurePhase to a custom value, or by
2789− setting dontUseCmakeConfigure. cmakeFlags controls flags passed only to
2790− CMake. By default, parallel building is enabled as CMake supports
2791− parallel building almost everywhere. When Ninja is also in use, CMake
2792− will detect that and use the ninja generator.
2072+ Overrides the default configure phase to run the CMake command. By default, we use the Make generator of CMake. In addition, dependencies are added automatically to CMAKE_PREFIX_PATH so that packages are correctly detected by CMake. Some additional flags are passed in to give similar behavior to configure-based packages. You can disable this hook’s behavior by setting configurePhase to a custom value, or by setting dontUseCmakeConfigure. cmakeFlags controls flags passed only to CMake. By default, parallel building is enabled as CMake supports parallel building almost everywhere. When Ninja is also in use, CMake will detect that and use the ninja generator.
27932073 </para>
27942074 </listitem>
27952075 </varlistentry>
@@ -2799,11 +2079,7 @@ postInstall = ''
27992079 </term>
28002080 <listitem>
28012081 <para>
2802− Overrides the build and install phases to run the “xcbuild” command.
2803− This hook is needed when a project only comes with build files for the
2804− XCode build system. You can disable this behavior by setting buildPhase
2805− and configurePhase to a custom value. xcbuildFlags controls flags passed
2806− only to xcbuild.
2082+ Overrides the build and install phases to run the “xcbuild” command. This hook is needed when a project only comes with build files for the XCode build system. You can disable this behavior by setting buildPhase and configurePhase to a custom value. xcbuildFlags controls flags passed only to xcbuild.
28072083 </para>
28082084 </listitem>
28092085 </varlistentry>
@@ -2813,10 +2089,7 @@ postInstall = ''
28132089 </term>
28142090 <listitem>
28152091 <para>
2816− Overrides the configure phase to run meson to generate Ninja files. To
2817− run these files, you should accompany Meson with ninja. By default,
2818− <varname>enableParallelBuilding</varname> is enabled as Meson supports
2819− parallel building almost everywhere.
2092+ Overrides the configure phase to run meson to generate Ninja files. To run these files, you should accompany Meson with ninja. By default, <varname>enableParallelBuilding</varname> is enabled as Meson supports parallel building almost everywhere.
28202093 </para>
28212094 <variablelist>
28222095 <title>Variables controlling Meson</title>
@@ -2836,10 +2109,8 @@ postInstall = ''
28362109 </term>
28372110 <listitem>
28382111 <para>
2839− Which
2840− <link
2841− xlink:href="https://mesonbuild.com/Builtin-options.html#core-options"><command>--buildtype</command></link>
2842− to pass to Meson. We default to <literal>plain</literal>.
2112+ Which <link
2113+ xlink:href="https://mesonbuild.com/Builtin-options.html#core-options"><command>--buildtype</command></link> to pass to Meson. We default to <literal>plain</literal>.
28432114 </para>
28442115 </listitem>
28452116 </varlistentry>
@@ -2849,10 +2120,8 @@ postInstall = ''
28492120 </term>
28502121 <listitem>
28512122 <para>
2852− What value to set
2853− <link
2854− xlink:href="https://mesonbuild.com/Builtin-options.html#core-options"><command>-Dauto_features=</command></link>
2855− to. We default to <command>enabled</command>.
2123+ What value to set <link
2124+ xlink:href="https://mesonbuild.com/Builtin-options.html#core-options"><command>-Dauto_features=</command></link> to. We default to <command>enabled</command>.
28562125 </para>
28572126 </listitem>
28582127 </varlistentry>
@@ -2862,11 +2131,8 @@ postInstall = ''
28622131 </term>
28632132 <listitem>
28642133 <para>
2865− What value to set
2866− <link
2867− xlink:href="https://mesonbuild.com/Builtin-options.html#core-options"><command>-Dwrap_mode=</command></link>
2868− to. We default to <command>nodownload</command> as we disallow
2869− network access.
2134+ What value to set <link
2135+ xlink:href="https://mesonbuild.com/Builtin-options.html#core-options"><command>-Dwrap_mode=</command></link> to. We default to <command>nodownload</command> as we disallow network access.
28702136 </para>
28712137 </listitem>
28722138 </varlistentry>
@@ -2889,10 +2155,7 @@ postInstall = ''
28892155 </term>
28902156 <listitem>
28912157 <para>
2892− Overrides the build, install, and check phase to run ninja instead of
2893− make. You can disable this behavior with the dontUseNinjaBuild,
2894− dontUseNinjaInstall, and dontUseNinjaCheck, respectively. Parallel
2895− building is enabled by default in Ninja.
2158+ Overrides the build, install, and check phase to run ninja instead of make. You can disable this behavior with the dontUseNinjaBuild, dontUseNinjaInstall, and dontUseNinjaCheck, respectively. Parallel building is enabled by default in Ninja.
28962159 </para>
28972160 </listitem>
28982161 </varlistentry>
@@ -2902,8 +2165,7 @@ postInstall = ''
29022165 </term>
29032166 <listitem>
29042167 <para>
2905− This setup hook will allow you to unzip .zip files specified in $src.
2906− There are many similar packages like unrar, undmg, etc.
2168+ This setup hook will allow you to unzip .zip files specified in $src. There are many similar packages like unrar, undmg, etc.
29072169 </para>
29082170 </listitem>
29092171 </varlistentry>
@@ -2913,10 +2175,7 @@ postInstall = ''
29132175 </term>
29142176 <listitem>
29152177 <para>
2916− Overrides the configure, build, and install phases. This will run the
2917− "waf" script used by many projects. If wafPath (default ./waf) doesn’t
2918− exist, it will copy the version of waf available in Nixpkgs. wafFlags
2919− can be used to pass flags to the waf script.
2178+ Overrides the configure, build, and install phases. This will run the "waf" script used by many projects. If wafPath (default ./waf) doesn’t exist, it will copy the version of waf available in Nixpkgs. wafFlags can be used to pass flags to the waf script.
29202179 </para>
29212180 </listitem>
29222181 </varlistentry>
@@ -2926,9 +2185,7 @@ postInstall = ''
29262185 </term>
29272186 <listitem>
29282187 <para>
2929− Overrides the build, install, and check phases. This uses the scons
2930− build system as a replacement for make. scons does not provide a
2931− configure phase, so everything is managed at build and install time.
2188+ Overrides the build, install, and check phases. This uses the scons build system as a replacement for make. scons does not provide a configure phase, so everything is managed at build and install time.
29322189 </para>
29332190 </listitem>
29342191 </varlistentry>
@@ -2939,40 +2196,26 @@ postInstall = ''
29392196 <title>Purity in Nixpkgs</title>
29402197
29412198 <para>
2942− [measures taken to prevent dependencies on packages outside the store, and
2943− what you can do to prevent them]
2199+ [measures taken to prevent dependencies on packages outside the store, and what you can do to prevent them]
29442200 </para>
29452201
29462202 <para>
2947− GCC doesn't search in locations such as <filename>/usr/include</filename>.
2948− In fact, attempts to add such directories through the <option>-I</option>
2949− flag are filtered out. Likewise, the linker (from GNU binutils) doesn't
2950− search in standard locations such as <filename>/usr/lib</filename>. Programs
2951− built on Linux are linked against a GNU C Library that likewise doesn't
2952− search in the default system locations.
2203+ GCC doesn't search in locations such as <filename>/usr/include</filename>. In fact, attempts to add such directories through the <option>-I</option> flag are filtered out. Likewise, the linker (from GNU binutils) doesn't search in standard locations such as <filename>/usr/lib</filename>. Programs built on Linux are linked against a GNU C Library that likewise doesn't search in the default system locations.
29532204 </para>
29542205 </section>
29552206 <section xml:id="sec-hardening-in-nixpkgs">
29562207 <title>Hardening in Nixpkgs</title>
29572208
29582209 <para>
2959− There are flags available to harden packages at compile or link-time. These
2960− can be toggled using the <varname>stdenv.mkDerivation</varname> parameters
2961− <varname>hardeningDisable</varname> and <varname>hardeningEnable</varname>.
2210+ There are flags available to harden packages at compile or link-time. These can be toggled using the <varname>stdenv.mkDerivation</varname> parameters <varname>hardeningDisable</varname> and <varname>hardeningEnable</varname>.
29622211 </para>
29632212
29642213 <para>
2965− Both parameters take a list of flags as strings. The special
2966− <varname>"all"</varname> flag can be passed to
2967− <varname>hardeningDisable</varname> to turn off all hardening. These flags
2968− can also be used as environment variables for testing or development
2969− purposes.
2214+ Both parameters take a list of flags as strings. The special <varname>"all"</varname> flag can be passed to <varname>hardeningDisable</varname> to turn off all hardening. These flags can also be used as environment variables for testing or development purposes.
29702215 </para>
29712216
29722217 <para>
2973− The following flags are enabled by default and might require disabling with
2974− <varname>hardeningDisable</varname> if the program to package is
2975− incompatible.
2218+ The following flags are enabled by default and might require disabling with <varname>hardeningDisable</varname> if the program to package is incompatible.
29762219 </para>
29772220
29782221 <variablelist>
@@ -2982,13 +2225,7 @@ postInstall = ''
29822225 </term>
29832226 <listitem>
29842227 <para>
2985− Adds the <option>-Wformat -Wformat-security
2986− -Werror=format-security</option> compiler options. At present, this warns
2987− about calls to <varname>printf</varname> and <varname>scanf</varname>
2988− functions where the format string is not a string literal and there are
2989− no format arguments, as in <literal>printf(foo);</literal>. This may be a
2990− security hole if the format string came from untrusted input and contains
2991− <literal>%n</literal>.
2228+ Adds the <option>-Wformat -Wformat-security -Werror=format-security</option> compiler options. At present, this warns about calls to <varname>printf</varname> and <varname>scanf</varname> functions where the format string is not a string literal and there are no format arguments, as in <literal>printf(foo);</literal>. This may be a security hole if the format string came from untrusted input and contains <literal>%n</literal>.
29922229 </para>
29932230 <para>
29942231 This needs to be turned off or fixed for errors similar to:
@@ -3007,12 +2244,7 @@ cc1plus: some warnings being treated as errors
30072244 </term>
30082245 <listitem>
30092246 <para>
3010− Adds the <option>-fstack-protector-strong --param
3011− ssp-buffer-size=4</option> compiler options. This adds safety checks
3012− against stack overwrites rendering many potential code injection attacks
3013− into aborting situations. In the best case this turns code injection
3014− vulnerabilities into denial of service or into non-issues (depending on
3015− the application).
2247+ Adds the <option>-fstack-protector-strong --param ssp-buffer-size=4</option> compiler options. This adds safety checks against stack overwrites rendering many potential code injection attacks into aborting situations. In the best case this turns code injection vulnerabilities into denial of service or into non-issues (depending on the application).
30162248 </para>
30172249 <para>
30182250 This needs to be turned off or fixed for errors similar to:
@@ -3029,19 +2261,10 @@ bin/blib.a(bios_console.o): In function `bios_handle_cup':
30292261 </term>
30302262 <listitem>
30312263 <para>
3032− Adds the <option>-O2 -D_FORTIFY_SOURCE=2</option> compiler options.
3033− During code generation the compiler knows a great deal of information
3034− about buffer sizes (where possible), and attempts to replace insecure
3035− unlimited length buffer function calls with length-limited ones. This is
3036− especially useful for old, crufty code. Additionally, format strings in
3037− writable memory that contain '%n' are blocked. If an application depends
3038− on such a format string, it will need to be worked around.
2264+ Adds the <option>-O2 -D_FORTIFY_SOURCE=2</option> compiler options. During code generation the compiler knows a great deal of information about buffer sizes (where possible), and attempts to replace insecure unlimited length buffer function calls with length-limited ones. This is especially useful for old, crufty code. Additionally, format strings in writable memory that contain '%n' are blocked. If an application depends on such a format string, it will need to be worked around.
30392265 </para>
30402266 <para>
3041− Additionally, some warnings are enabled which might trigger build
3042− failures if compiler warnings are treated as errors in the package build.
3043− In this case, set <option>NIX_CFLAGS_COMPILE</option> to
3044− <option>-Wno-error=warning-type</option>.
2267+ Additionally, some warnings are enabled which might trigger build failures if compiler warnings are treated as errors in the package build. In this case, set <option>NIX_CFLAGS_COMPILE</option> to <option>-Wno-error=warning-type</option>.
30452268 </para>
30462269 <para>
30472270 This needs to be turned off or fixed for errors similar to:
@@ -3070,15 +2293,10 @@ fcntl2.h:50:4: error: call to '__open_missing_mode' declared with attribute erro
30702293 </term>
30712294 <listitem>
30722295 <para>
3073− Adds the <option>-fPIC</option> compiler options. This options adds
3074− support for position independent code in shared libraries and thus making
3075− ASLR possible.
2296+ Adds the <option>-fPIC</option> compiler options. This options adds support for position independent code in shared libraries and thus making ASLR possible.
30762297 </para>
30772298 <para>
3078− Most notably, the Linux kernel, kernel modules and other code not running
3079− in an operating system environment like boot loaders won't build with PIC
3080− enabled. The compiler will is most cases complain that PIC is not
3081− supported for a specific build.
2299+ Most notably, the Linux kernel, kernel modules and other code not running in an operating system environment like boot loaders won't build with PIC enabled. The compiler will is most cases complain that PIC is not supported for a specific build.
30822300 </para>
30832301 <para>
30842302 This needs to be turned off or fixed for assembler errors similar to:
@@ -3095,13 +2313,7 @@ ccbLfRgg.s:33: Error: missing or invalid displacement expression `private_key_le
30952313 </term>
30962314 <listitem>
30972315 <para>
3098− Signed integer overflow is undefined behaviour according to the C
3099− standard. If it happens, it is an error in the program as it should check
3100− for overflow before it can happen, not afterwards. GCC provides built-in
3101− functions to perform arithmetic with overflow checking, which are correct
3102− and faster than any custom implementation. As a workaround, the option
3103− <option>-fno-strict-overflow</option> makes gcc behave as if signed
3104− integer overflows were defined.
2316+ Signed integer overflow is undefined behaviour according to the C standard. If it happens, it is an error in the program as it should check for overflow before it can happen, not afterwards. GCC provides built-in functions to perform arithmetic with overflow checking, which are correct and faster than any custom implementation. As a workaround, the option <option>-fno-strict-overflow</option> makes gcc behave as if signed integer overflows were defined.
31052317 </para>
31062318 <para>
31072319 This flag should not trigger any build or runtime errors.
@@ -3114,18 +2326,10 @@ ccbLfRgg.s:33: Error: missing or invalid displacement expression `private_key_le
31142326 </term>
31152327 <listitem>
31162328 <para>
3117− Adds the <option>-z relro</option> linker option. During program load,
3118− several ELF memory sections need to be written to by the linker, but can
3119− be turned read-only before turning over control to the program. This
3120− prevents some GOT (and .dtors) overwrite attacks, but at least the part
3121− of the GOT used by the dynamic linker (.got.plt) is still vulnerable.
2329+ Adds the <option>-z relro</option> linker option. During program load, several ELF memory sections need to be written to by the linker, but can be turned read-only before turning over control to the program. This prevents some GOT (and .dtors) overwrite attacks, but at least the part of the GOT used by the dynamic linker (.got.plt) is still vulnerable.
31222330 </para>
31232331 <para>
3124− This flag can break dynamic shared object loading. For instance, the
3125− module systems of Xorg and OpenCV are incompatible with this flag. In
3126− almost all cases the <varname>bindnow</varname> flag must also be
3127− disabled and incompatible programs typically fail with similar errors at
3128− runtime.
2332+ This flag can break dynamic shared object loading. For instance, the module systems of Xorg and OpenCV are incompatible with this flag. In almost all cases the <varname>bindnow</varname> flag must also be disabled and incompatible programs typically fail with similar errors at runtime.
31292333 </para>
31302334 </listitem>
31312335 </varlistentry>
@@ -3135,18 +2339,10 @@ ccbLfRgg.s:33: Error: missing or invalid displacement expression `private_key_le
31352339 </term>
31362340 <listitem>
31372341 <para>
3138− Adds the <option>-z bindnow</option> linker option. During program load,
3139− all dynamic symbols are resolved, allowing for the complete GOT to be
3140− marked read-only (due to <varname>relro</varname>). This prevents GOT
3141− overwrite attacks. For very large applications, this can incur some
3142− performance loss during initial load while symbols are resolved, but this
3143− shouldn't be an issue for daemons.
2342+ Adds the <option>-z bindnow</option> linker option. During program load, all dynamic symbols are resolved, allowing for the complete GOT to be marked read-only (due to <varname>relro</varname>). This prevents GOT overwrite attacks. For very large applications, this can incur some performance loss during initial load while symbols are resolved, but this shouldn't be an issue for daemons.
31442343 </para>
31452344 <para>
3146− This flag can break dynamic shared object loading. For instance, the
3147− module systems of Xorg and PHP are incompatible with this flag. Programs
3148− incompatible with this flag often fail at runtime due to missing symbols,
3149− like:
2345+ This flag can break dynamic shared object loading. For instance, the module systems of Xorg and PHP are incompatible with this flag. Programs incompatible with this flag often fail at runtime due to missing symbols, like:
31502346 </para>
31512347<programlisting>
31522348intel_drv.so: undefined symbol: vgaHWFreeHWRec
@@ -3156,9 +2352,7 @@ intel_drv.so: undefined symbol: vgaHWFreeHWRec
31562352 </variablelist>
31572353
31582354 <para>
3159− The following flags are disabled by default and should be enabled with
3160− <varname>hardeningEnable</varname> for packages that take untrusted input
3161− like network services.
2355+ The following flags are disabled by default and should be enabled with <varname>hardeningEnable</varname> for packages that take untrusted input like network services.
31622356 </para>
31632357
31642358 <variablelist>
@@ -3168,31 +2362,14 @@ intel_drv.so: undefined symbol: vgaHWFreeHWRec
31682362 </term>
31692363 <listitem>
31702364 <para>
3171− Adds the <option>-fPIE</option> compiler and <option>-pie</option> linker
3172− options. Position Independent Executables are needed to take advantage of
3173− Address Space Layout Randomization, supported by modern kernel versions.
3174− While ASLR can already be enforced for data areas in the stack and heap
3175− (brk and mmap), the code areas must be compiled as position-independent.
3176− Shared libraries already do this with the <varname>pic</varname> flag, so
3177− they gain ASLR automatically, but binary .text regions need to be build
3178− with <varname>pie</varname> to gain ASLR. When this happens, ROP attacks
3179− are much harder since there are no static locations to bounce off of
3180− during a memory corruption attack.
2365+ Adds the <option>-fPIE</option> compiler and <option>-pie</option> linker options. Position Independent Executables are needed to take advantage of Address Space Layout Randomization, supported by modern kernel versions. While ASLR can already be enforced for data areas in the stack and heap (brk and mmap), the code areas must be compiled as position-independent. Shared libraries already do this with the <varname>pic</varname> flag, so they gain ASLR automatically, but binary .text regions need to be build with <varname>pie</varname> to gain ASLR. When this happens, ROP attacks are much harder since there are no static locations to bounce off of during a memory corruption attack.
31812366 </para>
31822367 </listitem>
31832368 </varlistentry>
31842369 </variablelist>
31852370
31862371 <para>
3187− For more in-depth information on these hardening flags and hardening in
3188− general, refer to the
3189− <link xlink:href="https://wiki.debian.org/Hardening">Debian Wiki</link>,
3190− <link xlink:href="https://wiki.ubuntu.com/Security/Features">Ubuntu
3191− Wiki</link>,
3192− <link xlink:href="https://wiki.gentoo.org/wiki/Project:Hardened">Gentoo
3193− Wiki</link>, and the
3194− <link xlink:href="https://wiki.archlinux.org/index.php/DeveloperWiki:Security">
3195− Arch Wiki</link>.
2372+ For more in-depth information on these hardening flags and hardening in general, refer to the <link xlink:href="https://wiki.debian.org/Hardening">Debian Wiki</link>, <link xlink:href="https://wiki.ubuntu.com/Security/Features">Ubuntu Wiki</link>, <link xlink:href="https://wiki.gentoo.org/wiki/Project:Hardened">Gentoo Wiki</link>, and the <link xlink:href="https://wiki.archlinux.org/index.php/DeveloperWiki:Security"> Arch Wiki</link>.
31962373 </para>
31972374 </section>
31982375</chapter>