···187187 How does this work in practice? Nixpkgs is now structured so that build-time dependencies are taken from <varname>buildPackages</varname>, whereas run-time dependencies are taken from the top level attribute set.
188188 For example, <varname>buildPackages.gcc</varname> should be used at build time, while <varname>gcc</varname> should be used at run time.
189189 Now, for most of Nixpkgs's history, there was no <varname>buildPackages</varname>, and most packages have not been refactored to use it explicitly.
190190- Instead, one can use the four attributes used for specifying dependencies as documented in <xref linkend="ssec-stdenv-attributes"/>.
190190+ Instead, one can use the six (<emphasis>gasp</emphasis>) attributes used for specifying dependencies as documented in <xref linkend="ssec-stdenv-dependencies"/>.
191191 We "splice" together the run-time and build-time package sets with <varname>callPackage</varname>, and then <varname>mkDerivation</varname> for each of four attributes pulls the right derivation out.
192192 This splicing can be skipped when not cross compiling as the package sets are the same, but is a bit slow for cross compiling.
193193 Because of this, a best-of-both-worlds solution is in the works with no splicing or explicit access of <varname>buildPackages</varname> needed.
···200200 </para></note>
201201 </section>
202202203203+ <section>
204204+ <title>Cross packagaing cookbook</title>
205205+ <para>
206206+ Some frequently problems when packaging for cross compilation are good to just spell and answer.
207207+ Ideally the information above is exhaustive, so this section cannot provide any new information,
208208+ but its ludicrous and cruel to expect everyone to spend effort working through the interaction of many features just to figure out the same answer to the same common problem.
209209+ Feel free to add to this list!
210210+ </para>
211211+ <qandaset>
212212+ <qandaentry>
213213+ <question><para>
214214+ What if my package's build system needs to build a C program to be run under the build environment?
215215+ </para></question>
216216+ <answer><para>
217217+ <programlisting>depsBuildBuild = [ buildPackages.stdenv.cc ];</programlisting>
218218+ Add it to your <function>mkDerivation</function> invocation.
219219+ </para></answer>
220220+ </qandaentry>
221221+ <qandaentry>
222222+ <question><para>
223223+ My package fails to find <command>ar</command>.
224224+ </para></question>
225225+ <answer><para>
226226+ Many packages assume that an unprefixed <command>ar</command> is available, but Nix doesn't provide one.
227227+ It only provides a prefixed one, just as it only does for all the other binutils programs.
228228+ It may be necessary to patch the package to fix the build system to use a prefixed `ar`.
229229+ </para></answer>
230230+ </qandaentry>
231231+ <qandaentry>
232232+ <question><para>
233233+ My package's testsuite needs to run host platform code.
234234+ </para></question>
235235+ <answer><para>
236236+ <programlisting>doCheck = stdenv.hostPlatform != stdenv.buildPlatfrom;</programlisting>
237237+ Add it to your <function>mkDerivation</function> invocation.
238238+ </para></answer>
239239+ </qandaentry>
240240+ </qandaset>
241241+ </section>
203242</section>
204243205244<!--============================================================-->
+318-39
doc/stdenv.xml
···179179</section>
180180181181182182-<section xml:id="ssec-stdenv-attributes"><title>Attributes</title>
182182+<section xml:id="ssec-stdenv-dependencies"><title>Specifying dependencies</title>
183183+184184+<para>
185185+ 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.
186186+ <varname>mkDerivation</varname>, however, takes a few attributes intended to, between them, include all the dependencies of a package.
187187+ This is done both for structure and consistency, but also so that certain other setup can take place.
188188+ For example, certain dependencies need their bin directories added to the <envar>PATH</envar>.
189189+ That is built-in, but other setup is done via a pluggable mechanism that works in conjunction with these dependency attributes.
190190+ See <xref linkend="ssec-setup-hooks"/> for details.
191191+</para>
192192+<para>
193193+ Dependencies can be broken down along three axes: their host and target platforms relative to the new derivation's, and whether they are propagated.
194194+ The platform distinctions are motivated by cross compilation; see <xref linkend="chap-cross"/> for exactly what each platform means.
195195+ <footnote><para>
196196+ The build platform is ignored because it is a mere implementation detail of the package satisfying the dependency:
197197+ As a general programming principle, dependencies are always <emphasis>specified</emphasis> as interfaces, not concrete implementation.
198198+ </para></footnote>
199199+ 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.
200200+ For now, the run-time/build-time distinction is just a hint for mental clarity, but in the future it perhaps could be enforced.
201201+</para>
202202+<para>
203203+ The extension of <envar>PATH</envar> with dependencies, alluded to above, proceeds according to the relative platforms alone.
204204+ The process is carried out only for dependencies whose host platform matches the new derivation's build platform–i.e. which run on the platform where the new derivation will be built.
205205+ <footnote><para>
206206+ Currently, that means for native builds all dependencies are put on the <envar>PATH</envar>.
207207+ But in the future that may not be the case for sake of matching cross:
208208+ the platforms would be assumed to be unique for native and cross builds alike, so only the <varname>depsBuild*</varname> and <varname>nativeBuildDependencies</varname> dependencies would affect the <envar>PATH</envar>.
209209+ </para></footnote>
210210+ 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.
211211+</para>
212212+<para>
213213+ 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.
214214+ 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.
215215+</para>
216216+<para>
217217+ It is important to note dependencies are not necessary propagated as the same sort of dependency that they were before, but rather as the corresponding sort so that the platform rules still line up.
218218+ The exact rules for dependency propagation can be given by assigning each sort of dependency two integers based one how it's host and target platforms are offset from the depending derivation's platforms.
219219+ Those offsets are given are given below in the descriptions of each dependency list attribute.
220220+ Algorithmically, we traverse propagated inputs, accumulating every propagated dep's propagated deps and adjusting them to account for the "shift in perspective" described by the current dep's platform offsets.
221221+ This results in sort a transitive closure of the dependency relation, with the offsets being approximately summed when two dependency links are combined.
222222+ We also prune transitive deps whose combined offsets go out-of-bounds, which can be viewed as a filter over that transitive closure removing dependencies that are blatantly absurd.
223223+</para>
224224+<para>
225225+ We can define the process precisely with <link xlink:href="https://en.wikipedia.org/wiki/Natural_deduction">Natural Deduction</link> using the inference rules.
226226+ This probably seems a bit obtuse, but so is the bash code that actually implements it!
227227+ <footnote><para>
228228+ The <function>findInputs</function> function, currently residing in <filename>pkgs/stdenv/generic/setup.sh</filename>, implements the propagation logic.
229229+ </para></footnote>
230230+ They're confusing in very different ways so...hopefully if something doesn't make sense in one presentation, it does in the other!
231231+ <programlisting>
232232+let mapOffset(h, t, i) = i + (if i <= 0 then h else t - 1)
233233+234234+propagated-dep(h0, t0, A, B)
235235+propagated-dep(h1, t1, B, C)
236236+h0 + h1 in {-1, 0, 1}
237237+h0 + t1 in {-1, 0, 1}
238238+-------------------------------------- Transitive property
239239+propagated-dep(mapOffset(h0, t0, h1),
240240+ mapOffset(h0, t0, t1),
241241+ A, C)</programlisting>
242242+ <programlisting>
243243+let mapOffset(h, t, i) = i + (if i <= 0 then h else t - 1)
244244+245245+dep(h0, _, A, B)
246246+propagated-dep(h1, t1, B, C)
247247+h0 + h1 in {-1, 0, 1}
248248+h0 + t1 in {-1, 0, -1}
249249+-------------------------------------- Take immediate deps' propagated deps
250250+propagated-dep(mapOffset(h0, t0, h1),
251251+ mapOffset(h0, t0, t1),
252252+ A, C)</programlisting>
253253+ <programlisting>
254254+propagated-dep(h, t, A, B)
255255+-------------------------------------- Propagated deps count as deps
256256+dep(h, t, A, B)</programlisting>
257257+ Some explanation of this monstrosity is in order.
258258+ In the common case, the target offset of a dependency is the successor to the target offset: <literal>t = h + 1</literal>.
259259+ That means that:
260260+ <programlisting>
261261+let f(h, t, i) = i + (if i <= 0 then h else t - 1)
262262+let f(h, h + 1, i) = i + (if i <= 0 then h else (h + 1) - 1)
263263+let f(h, h + 1, i) = i + (if i <= 0 then h else h)
264264+let f(h, h + 1, i) = i + h
265265+ </programlisting>
266266+ This is where the "sum-like" comes from above:
267267+ We can just sum all the host offset to get the host offset of the transitive dependency.
268268+ The target offset is the transitive dep is simply the host offset + 1, just as it was with the dependencies composed to make this transitive one;
269269+ it can be ignored as it doesn't add any new information.
270270+</para>
271271+<para>
272272+ Because of the bounds checks, the uncommon cases are <literal>h = t</literal> and <literal>h + 2 = t</literal>.
273273+ In the former case, the motivation for <function>mapOffset</function> is that since its host and target platforms are the same, no transitive dep of it should be able to "discover" an offset greater than its reduced target offsets.
274274+ <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.
275275+ In the other case, <literal>h + 1</literal> is skipped over between the host and target offsets.
276276+ Instead of squashing the offsets, we need to "rip" them apart so no transitive dependencies' offset is that one.
277277+</para>
278278+<para>
279279+Overall, the unifying theme here is that propagation shouldn't be introducing transitive dependencies involving platforms the needing package is unaware of.
280280+The offset bounds checking and definition of <function>mapOffset</function> together ensure that this is the case.
281281+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.
282282+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.
283283+</para>
183284184285<variablelist>
185185- <title>Variables affecting <literal>stdenv</literal>
186186- initialisation</title>
286286+ <title>Variables specifying dependencies</title>
287287+288288+ <varlistentry>
289289+ <term><varname>depsBuildBuild</varname></term>
290290+ <listitem>
291291+ <para>
292292+ A list of dependencies whose host and target platforms are the new derivation's build platform.
293293+ This means a <literal>-1</literal> host and <literal>-1</literal> target offset from the new derivation's platforms.
294294+ They are programs/libraries used at build time that furthermore produce programs/libraries also used at build time.
295295+ 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.
296296+ The most common use for this <literal>buildPackages.stdenv.cc</literal>, the default C compiler for this role.
297297+ That example crops up more than one might think in old commonly used C libraries.
298298+ </para>
299299+ <para>
300300+ Since these packages are able to be run at build time, that are always added to the <envar>PATH</envar>, as described above.
301301+ But since these packages are only guaranteed to be able to run then, they shouldn't persist as run-time dependencies.
302302+ This isn't currently enforced, but could be in the future.
303303+ </para>
304304+ </listitem>
305305+ </varlistentry>
306306+307307+ <varlistentry>
308308+ <term><varname>nativeBuildInputs</varname></term>
309309+ <listitem>
310310+ <para>
311311+ A list of dependencies whose host platform is the new derivation's build platform, and target platform is the new derivation's host platform.
312312+ This means a <literal>-1</literal> host offset and <literal>0</literal> target offset from the new derivation's platforms.
313313+ They are programs/libraries used at build time that, if they are a compiler or similar tool, produce code to run at run time—i.e. tools used to build the new derivation.
314314+ 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>.
315315+ This would be called <varname>depsBuildHost</varname> but for historical continuity.
316316+ </para>
317317+ <para>
318318+ Since these packages are able to be run at build time, that are added to the <envar>PATH</envar>, as described above.
319319+ But since these packages only are guaranteed to be able to run then, they shouldn't persist as run-time dependencies.
320320+ This isn't currently enforced, but could be in the future.
321321+ </para>
322322+ </listitem>
323323+ </varlistentry>
187324188325 <varlistentry>
189189- <term><varname>NIX_DEBUG</varname></term>
326326+ <term><varname>depsBuildTarget</varname></term>
327327+ <listitem>
328328+ <para>
329329+ A list of dependencies whose host platform is the new derivation's build platform, and target platform is the new derivation's target platform.
330330+ This means a <literal>-1</literal> host offset and <literal>1</literal> target offset from the new derivation's platforms.
331331+ They are programs used at build time that produce code to run at run with code produced by the depending package.
332332+ Most commonly, these would tools used to build the runtime or standard library the currently-being-built compiler will inject into any code it compiles.
333333+ 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.
334334+ Other times, the compiler relies on some other tool, like binutils, that is always built separately so the dependency is unconditional.
335335+ </para>
336336+ <para>
337337+ This is a somewhat confusing dependency to wrap ones head around, and for good reason.
338338+ As the only one where the platform offsets are not adjacent integers, it requires thinking of a bootstrapping stage <emphasis>two</emphasis> away from the current one.
339339+ It and it's use-case go hand in hand and are both considered poor form:
340340+ try not to need this sort dependency, and try not avoid building standard libraries / runtimes in the same derivation as the compiler produces code using them.
341341+ Instead strive to build those like a normal library, using the newly-built compiler just as a normal library would.
342342+ In short, do not use this attribute unless you are packaging a compiler and are sure it is needed.
343343+ </para>
344344+ <para>
345345+ Since these packages are able to be run at build time, that are added to the <envar>PATH</envar>, as described above.
346346+ But since these packages only are guaranteed to be able to run then, they shouldn't persist as run-time dependencies.
347347+ This isn't currently enforced, but could be in the future.
348348+ </para>
349349+ </listitem>
350350+ </varlistentry>
351351+352352+ <varlistentry>
353353+ <term><varname>depsHostHost</varname></term>
190354 <listitem><para>
191191- A natural number indicating how much information to log.
192192- If set to 1 or higher, <literal>stdenv</literal> will print moderate debug information during the build.
193193- In particular, the <command>gcc</command> and <command>ld</command> wrapper scripts will print out the complete command line passed to the wrapped tools.
194194- If set to 6 or higher, the <literal>stdenv</literal> setup script will be run with <literal>set -x</literal> tracing.
195195- 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.
355355+ A list of dependencies whose host and target platforms match the new derivation's host platform.
356356+ This means a both <literal>0</literal> host offset and <literal>0</literal> target offset from the new derivation's host platform.
357357+ These are packages used at run-time to generate code also used at run-time.
358358+ In practice, that would usually be tools used by compilers for metaprogramming/macro systems, or libraries used by the macros/metaprogramming code itself.
359359+ It's always preferable to use a <varname>depsBuildBuild</varname> dependency in the derivation being built than a <varname>depsHostHost</varname> on the tool doing the building for this purpose.
196360 </para></listitem>
197361 </varlistentry>
198362199199-</variablelist>
363363+ <varlistentry>
364364+ <term><varname>buildInputs</varname></term>
365365+ <listitem>
366366+ <para>
367367+ A list of dependencies whose host platform and target platform match the new derivation's.
368368+ This means a <literal>0</literal> host offset and <literal>1</literal> target offset from the new derivation's host platform.
369369+ This would be called <varname>depsHostTarget</varname> but for historical continuity.
370370+ 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>.
371371+ </para>
372372+ <para>
373373+ These often are programs/libraries used by the new derivation at <emphasis>run</emphasis>-time, but that isn't always the case.
374374+ 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.
375375+ Even in the dynamic case, the library may also be needed at build time to appease the linker.
376376+ </para>
377377+ </listitem>
378378+ </varlistentry>
200379201201-<variablelist>
202202- <title>Variables specifying dependencies</title>
380380+ <varlistentry>
381381+ <term><varname>depsTargetTarget</varname></term>
382382+ <listitem><para>
383383+ A list of dependencies whose host platform matches the new derivation's target platform.
384384+ This means a <literal>1</literal> offset from the new derivation's platforms.
385385+ 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.
386386+ 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].
387387+ Do not use this attribute unless you are packaging a compiler and are sure it is needed.
388388+ </para></listitem>
389389+ </varlistentry>
203390204391 <varlistentry>
205205- <term><varname>nativeBuildInputs</varname></term>
392392+ <term><varname>depsBuildBuildPropagated</varname></term>
206393 <listitem><para>
207207- A list of dependencies used by the new derivation at <emphasis>build</emphasis>-time.
208208- I.e. these dependencies should not make it into the package's runtime-closure, though this is currently not checked.
209209- For each dependency <replaceable>dir</replaceable>, the directory <filename><replaceable>dir</replaceable>/bin</filename>, if it exists, is added to the <envar>PATH</envar> environment variable.
210210- Other environment variables are also set up via a pluggable mechanism.
211211- 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.
212212- See <xref linkend="ssec-setup-hooks"/> for details.
394394+ The propagated equivalent of <varname>depsBuildBuild</varname>.
395395+ This perhaps never ought to be used, but it is included for consistency [see below for the others].
213396 </para></listitem>
214397 </varlistentry>
215398216399 <varlistentry>
217217- <term><varname>buildInputs</varname></term>
400400+ <term><varname>propagatedNativeBuildInputs</varname></term>
218401 <listitem><para>
219219- A list of dependencies used by the new derivation at <emphasis>run</emphasis>-time.
220220- Currently, the build-time environment is modified in the exact same way as with <varname>nativeBuildInputs</varname>.
221221- This is problematic in that when cross-compiling, foreign executables can clobber native ones on the <envar>PATH</envar>.
222222- Even more confusing is static-linking.
223223- A statically-linked library should be listed here because ultimately that generated machine code will be used at run-time, even though a derivation containing the object files or static archives will only be used at build-time.
224224- A less confusing solution to this would be nice.
402402+ The propagated equivalent of <varname>nativeBuildInputs</varname>.
403403+ This would be called <varname>depsBuildHostPropagated</varname> but for historical continuity.
404404+ 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>.
405405+ 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.
225406 </para></listitem>
226407 </varlistentry>
227408409409+ <varlistentry>
410410+ <term><varname>depsBuildTargetPropagated</varname></term>
411411+ <listitem><para>
412412+ The propagated equivalent of <varname>depsBuildTarget</varname>.
413413+ This is prefixed for the same reason of alerting potential users.
414414+ </para></listitem>
415415+ </varlistentry>
228416229417 <varlistentry>
230230- <term><varname>propagatedNativeBuildInputs</varname></term>
418418+ <term><varname>depsHostHostPropagated</varname></term>
231419 <listitem><para>
232232- Like <varname>nativeBuildInputs</varname>, but these dependencies are <emphasis>propagated</emphasis>:
233233- that is, the dependencies listed here are added to the <varname>nativeBuildInputs</varname> of any package that uses <emphasis>this</emphasis> package as a dependency.
234234- So if package Y has <literal>propagatedNativeBuildInputs = [X]</literal>, and package Z has <literal>nativeBuildInputs = [Y]</literal>,
235235- then package X will appear in Z’s build environment automatically.
420420+ The propagated equivalent of <varname>depsHostHost</varname>.
236421 </para></listitem>
237422 </varlistentry>
238423239424 <varlistentry>
240425 <term><varname>propagatedBuildInputs</varname></term>
241426 <listitem><para>
242242- Like <varname>buildInputs</varname>, but propagated just like <varname>propagatedNativeBuildInputs</varname>.
243243- This inherits <varname>buildInputs</varname>'s flaws of clobbering native executables when cross-compiling and being confusing for static linking.
427427+ The propagated equivalent of <varname>buildInputs</varname>.
428428+ This would be called <varname>depsHostTargetPropagated</varname> but for historical continuity.
429429+ </para></listitem>
430430+ </varlistentry>
431431+432432+ <varlistentry>
433433+ <term><varname>depsTargetTarget</varname></term>
434434+ <listitem><para>
435435+ The propagated equivalent of <varname>depsTargetTarget</varname>.
436436+ This is prefixed for the same reason of alerting potential users.
437437+ </para></listitem>
438438+ </varlistentry>
439439+440440+</variablelist>
441441+442442+</section>
443443+444444+445445+<section xml:id="ssec-stdenv-attributes"><title>Attributes</title>
446446+447447+<variablelist>
448448+ <title>Variables affecting <literal>stdenv</literal>
449449+ initialisation</title>
450450+451451+ <varlistentry>
452452+ <term><varname>NIX_DEBUG</varname></term>
453453+ <listitem><para>
454454+ A natural number indicating how much information to log.
455455+ If set to 1 or higher, <literal>stdenv</literal> will print moderate debug information during the build.
456456+ In particular, the <command>gcc</command> and <command>ld</command> wrapper scripts will print out the complete command line passed to the wrapped tools.
457457+ If set to 6 or higher, the <literal>stdenv</literal> setup script will be run with <literal>set -x</literal> tracing.
458458+ 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.
244459 </para></listitem>
245460 </varlistentry>
246461···656871 By default, when cross compiling, the configure script has <option>--build=...</option> and <option>--host=...</option> passed.
657872 Packages can instead pass <literal>[ "build" "host" "target" ]</literal> or a subset to control exactly which platform flags are passed.
658873 Compilers and other tools should use this to also pass the target platform, for example.
659659- Note eventually these will be passed when in native builds too, to improve determinism: build-time guessing, as is done today, is a risk of impurity.
874874+ <footnote><para>Eventually these will be passed when in native builds too, to improve determinism: build-time guessing, as is done today, is a risk of impurity.</para></footnote>
660875 </para></listitem>
661876 </varlistentry>
662877···9231138 <listitem><para>If set, libraries and executables are not
9241139 stripped. By default, they are.</para></listitem>
9251140 </varlistentry>
11411141+ <varlistentry>
11421142+ <term><varname>dontStripHost</varname></term>
11431143+ <listitem><para>
11441144+ Like <varname>dontStripHost</varname>, but only affects the <command>strip</command> command targetting the package's host platform.
11451145+ Useful when supporting cross compilation, but otherwise feel free to ignore.
11461146+ </para></listitem>
11471147+ </varlistentry>
11481148+ <varlistentry>
11491149+ <term><varname>dontStripTarget</varname></term>
11501150+ <listitem><para>
11511151+ Like <varname>dontStripHost</varname>, but only affects the <command>strip</command> command targetting the packages' target platform.
11521152+ Useful when supporting cross compilation, but otherwise feel free to ignore.
11531153+ </para></listitem>
11541154+ </varlistentry>
92611559271156 <varlistentry>
9281157 <term><varname>dontMoveSbin</varname></term>
···1353158213541583<section xml:id="ssec-setup-hooks"><title>Package setup hooks</title>
1355158413561356-<para>The following packages provide a setup hook:
13571357-15851585+<para>
15861586+ Nix itself considers a build-time dependency merely something that should previously be built and accessible at build time—packages themselves are on their own to perform any additional setup.
15871587+ In most cases, that is fine, and the downstream derivation can deal with it's own dependencies.
15881588+ 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.
15891589+</para>
15901590+<para>
15911591+ 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.
15921592+ That allows the downstream dependency to merely specify its dependencies, and lets those dependencies effectively initialize themselves.
15931593+ No boilerplate mirroring the list of dependencies is needed.
15941594+</para>
15951595+<para>
15961596+ The Setup hook mechanism is a bit of a sledgehammer though: a powerful feature with a broad and indiscriminate area of effect.
15971597+ The combination of its power and implicit use may be expedient, but isn't without costs.
15981598+ Nix itself is unchanged, but the spirit of adding dependencies being effect-free is violated even if the letter isn't.
15991599+ 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.
16001600+ 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).
16011601+ 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.
16021602+</para>
16031603+<para>
16041604+ 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.
16051605+ For example, the C compiler wrapper's setup hook feeds itself flags for each dependency that contains relevant libaries and headers.
16061606+ This is done by defining a bash function, and appending its name to one of
16071607+ <envar>envBuildBuildHooks</envar>`,
16081608+ <envar>envBuildHostHooks</envar>`,
16091609+ <envar>envBuildTargetHooks</envar>`,
16101610+ <envar>envHostHostHooks</envar>`,
16111611+ <envar>envHostTargetHooks</envar>`, or
16121612+ <envar>envTargetTargetHooks</envar>`.
16131613+ 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).
16141614+</para>
16151615+<para>
16161616+ Packages adding a hook should not hard code a specific hook, but rather choose a variable <emphasis>relative</emphasis> to how they are included.
16171617+ Returning to the C compiler wrapper example, if it 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.
16181618+ The <envar>hostOffset</envar> variable is defined with the current dependency's host offset <envar>targetOffset</envar> with its target offset, before it's setup hook is sourced.
16191619+ Additionally, since most environment hooks don't care about the target platform,
16201620+ That means the setup hook can append to the right bash array by doing something like
16211621+ <programlisting language="bash">
16221622+addEnvHooks "$hostOffset" myBashFunction
16231623+ </programlisting>
16241624+</para>
16251625+<para>
16261626+ The <emphasis>existence</emphasis> of setups hooks has long been documented and packages inside Nixpkgs are free to use these mechanism.
16271627+ Other packages, however, should not rely on these mechanisms not changing between Nixpkgs versions.
16281628+ Because of the existing issues with this system, there's little benefit from mandating it be stable for any period of time.
16291629+</para>
16301630+<para>
16311631+ Here are some packages that provide a setup hook.
16321632+ Since the mechanism is modular, this probably isn't an exhaustive list.
16331633+ Then again, since the mechanism is only to be used as a last resort, it might be.
13581634<variablelist>
1359163513601636 <varlistentry>
···1421169714221698 <varlistentry>
14231699 <term>Perl</term>
14241424- <listitem><para>Adds the <filename>lib/site_perl</filename> subdirectory
14251425- of each build input to the <envar>PERL5LIB</envar>
14261426- environment variable.</para></listitem>
17001700+ <listitem>
17011701+ <para>
17021702+ Adds the <filename>lib/site_perl</filename> subdirectory of each build input to the <envar>PERL5LIB</envar> environment variable.
17031703+ 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.
17041704+ </para>
17051705+ </listitem>
14271706 </varlistentry>
1428170714291708 <varlistentry>
+28
nixos/doc/manual/release-notes/rl-1803.xml
···2020<itemizedlist>
2121 <listitem>
2222 <para>
2323+ MariaDB 10.2, updated from 10.1, is now the default MySQL implementation. While upgrading a few changes
2424+ have been made to the infrastructure involved:
2525+ <itemizedlist>
2626+ <listitem>
2727+ <para>
2828+ <literal>libmysql</literal> has been deprecated, please use <literal>mysql.connector-c</literal>
2929+ instead, a compatibility passthru has been added to the MySQL packages.
3030+ </para>
3131+ </listitem>
3232+ <listitem>
3333+ <para>
3434+ The <literal>mysql57</literal> package has a new <literal>static</literal> output containing
3535+ the static libraries including <literal>libmysqld.a</literal>
3636+ </para>
3737+ </listitem>
3838+ </itemizedlist>
2339 </para>
2440 </listitem>
2541</itemizedlist>
···101117 The most commonly used files in <filename>nix-support</filename> are now split between the two wrappers.
102118 Some commonly used ones, like <filename>nix-support/dynamic-linker</filename>, are duplicated for backwards compatability, even though they rightly belong only in <literal>bintools-wrapper</literal>.
103119 Other more obscure ones are just moved.
120120+ </para>
121121+ </listitem>
122122+ <listitem>
123123+ <para>
124124+ The propagation logic has been changed.
125125+ The new logic, along with new types of dependencies that go with, is thoroughly documented in the "Specifying dependencies" section of the "Standard Environment" chapter of the nixpkgs manual.
126126+ <!-- That's <xref linkend="ssec-stdenv-attributes"> were we to merge the manuals. -->
127127+ The old logic isn't but is easy to describe: dependencies were propagated as the same type of dependency no matter what.
128128+ In practice, that means that many <function>propagatedNativeBuildInputs</function> should instead be <function>propagatedBuildInputs</function>.
129129+ Thankfully, that was and is the least used type of dependency.
130130+ Also, it means that some <function>propagatedBuildInputs</function> should instead be <function>depsTargetTargetPropagated</function>.
131131+ Other types dependencies should be unaffected.
104132 </para>
105133 </listitem>
106134</itemizedlist>
···164164 set +u
165165 '';
166166167167- propagatedBuildInputs = extraPackages;
167167+ emulation = let
168168+ fmt =
169169+ /**/ if targetPlatform.isDarwin then "mach-o"
170170+ else if targetPlatform.isWindows then "pe"
171171+ else "elf" + toString targetPlatform.parsed.cpu.bits;
172172+ endianPrefix = if targetPlatform.isBigEndian then "big" else "little";
173173+ arch =
174174+ /**/ if targetPlatform.isAarch64 then endianPrefix + "aarch64"
175175+ else if targetPlatform.isArm then endianPrefix + "arm"
176176+ else if targetPlatform.isx86_64 then "x86-64"
177177+ else if targetPlatform.isi686 then "i386"
178178+ else throw "unknown emulation for platform: " + targetPlatform.config;
179179+ in targetPlatform.platform.bfdEmulation or (fmt + "-" + arch);
180180+181181+ depsTargetTargetPropagated = extraPackages;
168182169183 setupHook = ./setup-hook.sh;
170184
+5
pkgs/build-support/bintools-wrapper/ld-wrapper.sh
···67676868extraAfter+=($NIX_@infixSalt@_LDFLAGS_AFTER)
69697070+# Specify the target emulation if nothing is passed in ("-m" overrides this
7171+# environment variable). Ensures we never blindly fallback on targeting the host
7272+# platform.
7373+: ${LDEMULATION:=@emulation@}
7474+7075# Three tasks:
7176#
7277# 1. Find all -L... switches for rpath
+33-12
pkgs/build-support/bintools-wrapper/setup-hook.sh
···22#
33# See comments in cc-wrapper's setup hook. This works exactly the same way.
4455+set -u
66+77+# Skip setup hook if we're neither a build-time dep, nor, temporarily, doing a
88+# native compile.
99+#
1010+# TODO(@Ericson2314): No native exception
1111+[[ -z ${crossConfig-} ]] || (( "$hostOffset" < 0 )) || return 0
1212+513bintoolsWrapper_addLDVars () {
66- case $depOffset in
1414+ case $depHostOffset in
715 -1) local role='BUILD_' ;;
816 0) local role='' ;;
917 1) local role='TARGET_' ;;
1010- *) echo "bintools-wrapper: Error: Cannot be used with $depOffset-offset deps, " >2;
1818+ *) echo "bintools-wrapper: Error: Cannot be used with $depHostOffset-offset deps" >2;
1119 return 1 ;;
1220 esac
1321···2028 fi
2129}
22302323-if [ -n "${crossConfig:-}" ]; then
2424- export NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_BUILD=1
2525- role_pre='BUILD_'
2626- role_post='_FOR_BUILD'
2727-else
2828- export NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_HOST=1
2929- role_pre=""
3030- role_post=''
3131-fi
3131+case $targetOffset in
3232+ -1)
3333+ export NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_BUILD=1
3434+ role_pre='BUILD_'
3535+ role_post='_FOR_BUILD'
3636+ ;;
3737+ 0)
3838+ export NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_HOST=1
3939+ role_pre=''
4040+ role_post=''
4141+ ;;
4242+ 1)
4343+ export NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_TARGET=1
4444+ role_pre='TARGET_'
4545+ role_post='_FOR_TARGET'
4646+ ;;
4747+ *)
4848+ echo "cc-wrapper: used as improper sort of dependency" >2;
4949+ return 1
5050+ ;;
5151+esac
32523333-envHooks+=(bintoolsWrapper_addLDVars)
5353+addEnvHooks "$targetOffset" bintoolsWrapper_addLDVars
34543555# shellcheck disable=SC2157
3656if [ -n "@bintools_bin@" ]; then
···65856686# No local scope in sourced file
6787unset -v role_pre role_post cmd upper_case
8888+set +u
···5454# For more details, read the individual files where the mechanisms used to
5555# accomplish this will be individually documented.
56565757+set -u
5858+5959+# Skip setup hook if we're neither a build-time dep, nor, temporarily, doing a
6060+# native compile.
6161+#
6262+# TODO(@Ericson2314): No native exception
6363+[[ -z ${crossConfig-} ]] || (( "$hostOffset" < 0 )) || return 0
57645865# It's fine that any other cc-wrapper will redefine this. Bash functions close
5966# over no state, and there's no @-substitutions within, so any redefined
6067# function is guaranteed to be exactly the same.
6168ccWrapper_addCVars () {
6262- # The `depOffset` describes how the platforms of the dependencies are slid
6363- # relative to the depending package. It is brought into scope of the
6464- # environment hook defined as the role of the dependency being applied.
6565- case $depOffset in
6969+ # The `depHostOffset` describes how the host platform of the dependencies
7070+ # are slid relative to the depending package. It is brought into scope of
7171+ # the environment hook defined as the role of the dependency being applied.
7272+ case $depHostOffset in
6673 -1) local role='BUILD_' ;;
6774 0) local role='' ;;
6875 1) local role='TARGET_' ;;
6969- *) echo "cc-wrapper: Error: Cannot be used with $depOffset-offset deps, " >2;
7676+ *) echo "cc-wrapper: Error: Cannot be used with $depHostOffset-offset deps" >2;
7077 return 1 ;;
7178 esac
7279···8794#
8895# We also need to worry about what role is being added on *this* invocation of
8996# setup-hook, which `role` tracks.
9090-if [ -n "${crossConfig:-}" ]; then
9191- export NIX_CC_WRAPPER_@infixSalt@_TARGET_BUILD=1
9292- role_pre='BUILD_'
9393- role_post='_FOR_BUILD'
9494-else
9595- export NIX_CC_WRAPPER_@infixSalt@_TARGET_HOST=1
9696- role_pre=''
9797- role_post=''
9898-fi
9797+case $targetOffset in
9898+ -1)
9999+ export NIX_CC_WRAPPER_@infixSalt@_TARGET_BUILD=1
100100+ role_pre='BUILD_'
101101+ role_post='_FOR_BUILD'
102102+ ;;
103103+ 0)
104104+ export NIX_CC_WRAPPER_@infixSalt@_TARGET_HOST=1
105105+ role_pre=''
106106+ role_post=''
107107+ ;;
108108+ 1)
109109+ export NIX_CC_WRAPPER_@infixSalt@_TARGET_TARGET=1
110110+ role_pre='TARGET_'
111111+ role_post='_FOR_TARGET'
112112+ ;;
113113+ *)
114114+ echo "cc-wrapper: used as improper sort of dependency" >2;
115115+ return 1
116116+ ;;
117117+esac
99118100100-# Eventually the exact sort of env-hook we create will depend on the role. This
101101-# is because based on what relative platform we are targeting, we use different
102102-# dependencies.
103103-envHooks+=(ccWrapper_addCVars)
119119+# We use the `targetOffset` to choose the right env hook to accumulate the right
120120+# sort of deps (those with that offset).
121121+addEnvHooks "$targetOffset" ccWrapper_addCVars
104122105123# Note 1: these come *after* $out in the PATH (see setup.sh).
106124# Note 2: phase separation makes this look useless to shellcheck.
···131149132150# No local scope in sourced file
133151unset -v role_pre role_post
152152+set +u
+5-1
pkgs/build-support/emacs/setup-hook.sh
···44 fi
55}
6677-envHooks+=(addEmacsVars)
77+# If this is for a wrapper derivation, emacs and the dependencies are all
88+# run-time dependencies. If this is for precompiling packages into bytecode,
99+# emacs is a compile-time dependency of the package.
1010+addEnvHooks "$targetOffset" addEmacsVars
1111+addEnvHooks "$targetOffset" addEmacsVars
+2-2
pkgs/build-support/gcc-wrapper-old/setup-hook.sh
···11-addCVars () {
11+gccWrapperOld_addCVars () {
22 if test -d $1/include; then
33 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem $1/include"
44 fi
···1212 fi
1313}
14141515-envHooks=(${envHooks[@]} addCVars)
1515+envBuildBuildHooks+=(gccWrapperOld_addCVars)
16161717# Note: these come *after* $out in the PATH (see setup.sh).
1818
···1818 # xmllint and xsltproc from looking in /etc/xml/catalog.
1919 export XML_CATALOG_FILES
2020 if [ -z "$XML_CATALOG_FILES" ]; then XML_CATALOG_FILES=" "; fi
2121- envHooks+=(addXMLCatalogs)
2121+ addEnvHooks "$hostOffset" addXMLCatalogs
2222fi
···33fixupOutputHooks+=(_doStrip)
4455_doStrip() {
66- if [ -z "$dontStrip" ]; then
66+ # We don't bother to strip build platform code because it shouldn't make it
77+ # to $out anyways---if it does, that's a bigger problem that a lack of
88+ # stripping will help catch.
99+ local -ra flags=(dontStripHost dontStripTarget)
1010+ local -ra stripCmds=(STRIP TARGET_STRIP)
1111+1212+ # Optimization
1313+ if [[ "$STRIP" == "$TARGET_STRIP" ]]; then
1414+ dontStripTarget+=1
1515+ fi
1616+1717+ local i
1818+ for i in ${!stripCmds[@]}; do
1919+ local -n flag="${flags[$i]}"
2020+ local -n stripCmd="${stripCmds[$i]}"
2121+2222+ # `dontStrip` disables them all
2323+ if [[ "$dontStrip" || "$flag" ]] || ! type -f "$stripCmd" 2>/dev/null
2424+ then continue; fi
2525+726 stripDebugList=${stripDebugList:-lib lib32 lib64 libexec bin sbin}
827 if [ -n "$stripDebugList" ]; then
99- stripDirs "$stripDebugList" "${stripDebugFlags:--S}"
2828+ stripDirs "$stripCmd" "$stripDebugList" "${stripDebugFlags:--S}"
1029 fi
11301231 stripAllList=${stripAllList:-}
1332 if [ -n "$stripAllList" ]; then
1414- stripDirs "$stripAllList" "${stripAllFlags:--s}"
3333+ stripDirs "$stripCmd" "$stripAllList" "${stripAllFlags:--s}"
1534 fi
1616- fi
3535+ done
1736}
18371938stripDirs() {
2020- local dirs="$1"
2121- local stripFlags="$2"
3939+ local cmd="$1"
4040+ local dirs="$2"
4141+ local stripFlags="$3"
2242 local dirsNew=
23434444+ local d
2445 for d in ${dirs}; do
2546 if [ -d "$prefix/$d" ]; then
2647 dirsNew="${dirsNew} $prefix/$d "
···2950 dirs=${dirsNew}
30513152 if [ -n "${dirs}" ]; then
3232- header "stripping (with flags $stripFlags) in$dirs"
3333- find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} $STRIP $commonStripFlags $stripFlags 2>/dev/null || true
5353+ header "stripping (with command $cmd and flags $stripFlags) in$dirs"
5454+ find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} $cmd $commonStripFlags $stripFlags 2>/dev/null || true
3455 stopNest
3556 fi
3657}
+1-1
pkgs/build-support/setup-hooks/wrap-gapps-hook.sh
···66 fi
77}
8899-envHooks+=(find_gio_modules)
99+addEnvHooks "$targetOffset" find_gio_modules
10101111# Note: $gappsWrapperArgs still gets defined even if $dontWrapGApps is set.
1212wrapGAppsHook() {
+2-1
pkgs/data/icons/hicolor-icon-theme/setup-hook.sh
···8899}
10101111-envHooks+=(hicolorIconThemeHook)
1111+# I think this is meant to be a runtime dep
1212+addEnvHooks "$hostOffset" hicolorIconThemeHook
12131314# Remove icon cache
1415hicolorPreFixupPhase() {
···1717stdenv.mkDerivation {
1818 name = "lldb-${version}";
19192020- src = fetch "lldb" "0zcbav39srf6awv9znvzr7nqdrj704i8da3wdgc8362y20rcm860";
2020+ src = fetch "lldb" "0sipv8k37ai44m7jcf6wsbm2q41dgk3sk9m3i6823jkmg7kckhdp";
21212222 postPatch = ''
2323 # Fix up various paths that assume llvm and clang are installed in the same place
+1-1
pkgs/development/compilers/llvm/5/llvm.nix
···2222}:
23232424let
2525- src = fetch "llvm" "1nin64vz21hyng6jr19knxipvggaqlkl2l9jpd5czbc4c2pcnpg3";
2525+ src = fetch "llvm" "1c07i0b61j69m578lgjkyayg419sh7sn40xb3j112nr2q2gli9sz";
26262727 # Used when creating a version-suffixed symlink of libLLVM.dylib
2828 shortVersion = with stdenv.lib;
···70707171 # Use the default version of mysql to build this package (which is actually mariadb).
7272 # test phase requires networking
7373- mysql = dontCheck (super.mysql.override { mysql = pkgs.mysql.lib; });
7373+ mysql = dontCheck (super.mysql.override { mysql = pkgs.mysql.connector-c; });
74747575 # check requires mysql server
7676 mysql-simple = dontCheck super.mysql-simple;
···53535454 # Use the default version of mysql to build this package (which is actually mariadb).
5555 # test phase requires networking
5656- mysql = dontCheck (super.mysql.override { mysql = pkgs.mysql.lib; });
5656+ mysql = dontCheck (super.mysql.override { mysql = pkgs.mysql.connector-c; });
57575858 # CUDA needs help finding the SDK headers and libraries.
5959 cuda = overrideCabal super.cuda (drv: {
···222222 setupCompileFlags="${concatStringsSep " " setupCompileFlags}"
223223 configureFlags="${concatStringsSep " " defaultConfigureFlags} $configureFlags"
224224225225- # nativePkgs defined in stdenv/setup.hs
226226- for p in "''${nativePkgs[@]}"; do
225225+ # host.*Pkgs defined in stdenv/setup.hs
226226+ for p in "''${pkgsHostHost[@]}" "''${pkgsHostTarget[@]}"; do
227227 if [ -d "$p/lib/${ghc.name}/package.conf.d" ]; then
228228 cp -f "$p/lib/${ghc.name}/package.conf.d/"*.conf $packageConfDir/
229229 continue
···1212 echo $result
1313}
14141515-envHooks+=(addPythonPath)
1515+addEnvHooks "$hostOffset" addPythonPath
16161717# Determinism: The interpreter is patched to write null timestamps when compiling python files.
1818# This way python doesn't try to update them when we freeze timestamps in nix store.
1919export DETERMINISTIC_BUILD=1;
2020# Determinism: We fix the hashes of str, bytes and datetime objects.
2121export PYTHONHASHSEED=0;
2222+# Determinism. Whenever Python is included, it should not check user site-packages.
2323+# This option is only relevant when the sandbox is disabled.
2424+export PYTHONNOUSERSITE=1;
···11+diff --git a/sysdeps/unix/sysv/linux/configure b/sysdeps/unix/sysv/linux/configure
22+index cace758c01..38fe7fe0b0 100644
33+--- a/sysdeps/unix/sysv/linux/configure
44++++ b/sysdeps/unix/sysv/linux/configure
55+@@ -69,7 +69,7 @@ fi
66+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kernel header at least $minimum_kernel" >&5
77+ $as_echo_n "checking for kernel header at least $minimum_kernel... " >&6; }
88+ decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
99+-abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
1010++abinum=`echo "2.6.32.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
1111+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1212+ /* end confdefs.h. */
1313+ #include <linux/version.h>
1414+diff --git a/sysdeps/unix/sysv/linux/configure.ac b/sysdeps/unix/sysv/linux/configure.ac
1515+index 13abda0a51..6abc12eaed 100644
1616+--- a/sysdeps/unix/sysv/linux/configure.ac
1717++++ b/sysdeps/unix/sysv/linux/configure.ac
1818+@@ -50,7 +50,7 @@ fi
1919+ AC_MSG_CHECKING(for kernel header at least $minimum_kernel)
2020+ changequote(,)dnl
2121+ decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
2222+-abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
2323++abinum=`echo "2.6.32.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
2424+ changequote([,])dnl
2525+ AC_TRY_COMPILE([#include <linux/version.h>
2626+ #if LINUX_VERSION_CODE < $decnum
2727+diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h
2828+index 823cd8224d..482caaeeec 100644
2929+--- a/sysdeps/unix/sysv/linux/dl-osinfo.h
3030++++ b/sysdeps/unix/sysv/linux/dl-osinfo.h
3131+@@ -39,7 +39,7 @@
3232+ GLRO(dl_osversion) = version; \
3333+ \
3434+ /* Now we can test with the required version. */ \
3535+- if (__LINUX_KERNEL_VERSION > 0 && version < __LINUX_KERNEL_VERSION) \
3636++ if (__LINUX_KERNEL_VERSION > 0 && version < __LINUX_KERNEL_VERSION && version != 0x020620) \
3737+ /* Not sufficent. */ \
3838+ FATAL ("FATAL: kernel too old\n"); \
3939+ } \
+22-2
pkgs/development/libraries/glibc/common.nix
···20202121let
2222 version = "2.26";
2323- patchSuffix = "-75";
2323+ patchSuffix = "-115";
2424 sha256 = "1ggnj1hzjym7sn93rbwydcqd562q73lsb7g7kd199g6j9j9hlkp5";
2525 cross = if buildPlatform != hostPlatform then hostPlatform else null;
2626in
···4747 $ git show --reverse glibc-2.25..release/2.25/master | gzip -n -9 --rsyncable - > 2.25-49.patch.gz
4848 */
4949 ./2.26-75.patch.gz
5050+ ./2.26-75to115.diff.gz
50515152 /* Have rpcgen(1) look for cpp(1) in $PATH. */
5253 ./rpcgen-path.patch
···6465 "/bin:/usr/bin", which is inappropriate on NixOS machines. This
6566 patch extends the search path by "/run/current-system/sw/bin". */
6667 ./fix_path_attribute_in_getconf.patch
6868+6969+ /* Allow running with RHEL 6 -like kernels. The patch adds an exception
7070+ for glibc to accept 2.6.32 and to tag the ELFs as 2.6.32-compatible
7171+ (otherwise the loader would refuse libc).
7272+ Note that glibc will fully work only on their heavily patched kernels
7373+ and we lose early mismatch detection on 2.6.32.
7474+7575+ On major glibc updates we should check that the patched kernel supports
7676+ all the required features. ATM it's verified up to glibc-2.26-115.
7777+ # HOWTO: check glibc sources for changes in kernel requirements
7878+ git log -p glibc-2.25.. sysdeps/unix/sysv/linux/x86_64/kernel-features.h sysdeps/unix/sysv/linux/kernel-features.h
7979+ # get kernel sources (update the URL)
8080+ mkdir tmp && cd tmp
8181+ curl http://vault.centos.org/6.9/os/Source/SPackages/kernel-2.6.32-696.el6.src.rpm | rpm2cpio - | cpio -idmv
8282+ tar xf linux-*.bz2
8383+ # check syscall presence, for example
8484+ less linux-*?/arch/x86/kernel/syscall_table_32.S
8585+ */
8686+ ./allow-kernel-2.6.32.patch
6787 ]
6888 ++ lib.optional stdenv.isx86_64 ./fix-x64-abi.patch;
6989···121141122142 outputs = [ "out" "bin" "dev" "static" ];
123143124124- nativeBuildInputs = lib.optional (cross != null) buildPackages.stdenv.cc;
144144+ depsBuildBuild = [ buildPackages.stdenv.cc ];
125145 buildInputs = lib.optionals withGd [ gd libpng ];
126146127147 # Needed to install share/zoneinfo/zone.tab. Set to impure /bin/sh to
···22 addToSearchPath XDG_DATA_DIRS "$1/share"
33 addToSearchPath XDG_CONFIG_DIRS "$1/etc/xdg"
44}
55-envHooks+=(_ecmEnvHook)
55+addEnvHooks "$targetOffset" _ecmEnvHook
6677_ecmPreConfigureHook() {
88 # Because we need to use absolute paths here, we must set *all* the paths.
···11-{ stdenv, fetchurl
22-, gettext, glibc
11+{ stdenv
22+, fetchurl, autoreconfHook, gettext
33, buildPlatform, hostPlatform
44}:
55···17171818 doCheck = true;
19192020- # Libelf's custom NLS macros fail to determine the catalog file extension on
2121- # Darwin, so disable NLS for now.
2222- # FIXME: Eventually make Gettext a build input on all platforms.
2323- configureFlags = stdenv.lib.optional hostPlatform.isDarwin "--disable-nls";
2020+ configureFlags = []
2121+ # Configure check for dynamic lib support is broken, see
2222+ # http://lists.uclibc.org/pipermail/uclibc-cvs/2005-August/019383.html
2323+ ++ stdenv.lib.optional (hostPlatform != buildPlatform) "mr_cv_target_elf=yes"
2424+ # Libelf's custom NLS macros fail to determine the catalog file extension
2525+ # on Darwin, so disable NLS for now.
2626+ ++ stdenv.lib.optional hostPlatform.isDarwin "--disable-nls";
24272525- nativeBuildInputs = [ gettext ];
2828+ nativeBuildInputs = [ gettext ]
2929+ # Need to regenerate configure script with newer version in order to pass
3030+ # "mr_cv_target_elf=yes", but `autoreconfHook` brings in `makeWrapper`
3131+ # which doesn't work with the bootstrapTools bash, so can only do this
3232+ # for cross builds when `stdenv.shell` is a newer bash.
3333+ ++ stdenv.lib.optional (hostPlatform != buildPlatform) autoreconfHook;
26342735 meta = {
2836 description = "ELF object file access library";
···3030buildPythonPackage rec {
3131 name = "${pname}-${version}";
3232 pname = "Nikola";
3333- version = "7.8.10";
3333+ version = "7.8.11";
34343535 # Nix contains only Python 3 supported version of doit, which is a dependency
3636 # of Nikola. Python 2 support would require older doit 0.29.0 (which on the
···47474848 src = fetchPypi {
4949 inherit pname version;
5050- sha256 = "e242c3d0dd175d95a0baf5268b108081ba160b83ceafec8c9bc2ec0a24a56537";
5050+ sha256 = "10d95b3af84e61496ef729665eafa2235fd0fd4cc6c57644dd0f2c19a968dd0f";
5151 };
52525353 meta = {
···11+{ lib
22+, buildPythonPackage
33+, fetchPypi
44+, numpy
55+}:
66+77+buildPythonPackage rec {
88+ pname = "biopython";
99+ version = "1.70";
1010+1111+ src = fetchPypi {
1212+ inherit pname version;
1313+ sha256 = "4a7c5298f03d1a45523f32bae1fffcff323ea9dce007fb1241af092f5ab2e45b";
1414+ };
1515+1616+ propagatedBuildInputs = [ numpy ];
1717+ # Checks try to write to $HOME, which does not work with nix
1818+ doCheck = false;
1919+ meta = {
2020+ description = "Python library for bioinformatics";
2121+ longDescription = ''
2222+ Biopython is a set of freely available tools for biological computation
2323+ written in Python by an international team of developers. It is a
2424+ distributed collaborative effort to develop Python libraries and
2525+ applications which address the needs of current and future work in
2626+ bioinformatics.
2727+ '';
2828+ homepage = http://biopython.org/wiki/Documentation;
2929+ maintainers = with lib.maintainers; [ luispedro ];
3030+ license = lib.licenses.bsd3;
3131+ };
3232+}
···11{ stdenv, buildPythonPackage, fetchPypi }:
22buildPythonPackage rec {
33 pname = "htmlmin";
44- version = "0.1.11";
44+ version = "0.1.12";
55 name = "${pname}-${version}";
66 src = fetchPypi {
77 inherit pname version;
88- sha256 = "f27fb96fdddeb1725ee077be532c7bea23288c69d0e996e7798f24fae7a14e5e";
88+ sha256 = "50c1ef4630374a5d723900096a961cff426dff46b48f34d194a81bbe14eca178";
99 };
10101111 # Tests run fine in a normal source checkout, but not when being built by nix.
···11{ stdenv, fetchPypi, buildPythonPackage, lib }:
2233buildPythonPackage rec {
44- version = "3.8.3";
44+ version = "3.9.0";
55 pname = "thespian";
66 name = "${pname}-${version}";
7788 src = fetchPypi {
99 inherit pname version;
1010 extension = "zip";
1111- sha256 = "0vvwsh3waxd5ldrayr86kdcshv07bp361fl7p16g9i044vklwly4";
1111+ sha256 = "e698e3c5369d7b06de5c4ce7b877ea65991c99f7b0fabd09f29e91bc981c7d22";
1212 };
13131414 # Do not run the test suite: it takes a long type and uses
···11+diff --git a/ld/genscripts.sh b/ld/genscripts.sh
22+index b6940d376d..0feb1adfd0 100755
33+--- a/ld/genscripts.sh
44++++ b/ld/genscripts.sh
55+@@ -125,6 +125,9 @@ if test "x$NATIVE" = "xyes" ; then
66+ USE_LIBPATH=yes
77+ fi
88+99++# TODO: why is this needed?
1010++USE_LIBPATH=yes
1111++
1212+ # Set the library search path, for libraries named by -lfoo.
1313+ # If LIB_PATH is defined (e.g., by Makefile) and non-empty, it is used.
1414+ # Otherwise, the default is set here.
+11-6
pkgs/development/tools/misc/binutils/default.nix
···5353 # elf32-littlearm-vxworks in favor of the first.
5454 # https://github.com/NixOS/nixpkgs/pull/30484#issuecomment-345472766
5555 ./disambiguate-arm-targets.patch
5656+5757+ # For some reason bfd ld doesn't search DT_RPATH when cross-compiling. It's
5858+ # not clear why this behavior was decided upon but it has the unfortunate
5959+ # consequence that the linker will fail to find transitive dependencies of
6060+ # shared objects when cross-compiling. Consequently, we are forced to
6161+ # override this behavior, forcing ld to search DT_RPATH even when
6262+ # cross-compiling.
6363+ ./always-search-rpath.patch
5664 ];
57655866 outputs = [ "out" "info" "man" ];
59676060- nativeBuildInputs = [ bison buildPackages.stdenv.cc ];
6868+ depsBuildBuild = [ buildPackages.stdenv.cc ];
6969+ nativeBuildInputs = [ bison ];
6170 buildInputs = [ zlib ];
62716372 inherit noSysDirs;
···8291 else "-static-libgcc";
83928493 # TODO(@Ericson2314): Always pass "--target" and always targetPrefix.
8585- configurePlatforms =
8686- # TODO(@Ericson2314): Figure out what's going wrong with Arm
8787- if hostPlatform == targetPlatform && targetPlatform.isArm
8888- then []
8989- else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
9494+ configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
90959196 configureFlags = [
9297 "--enable-targets=all" "--enable-64-bit-bfd"
···24242525 # It may look odd that we use `stdenvNoCC`, and yet explicit depend on a cc.
2626 # We do this so we have a build->build, not build->host, C compiler.
2727- nativeBuildInputs = [ buildPackages.stdenv.cc perl ];
2727+ depsBuildBuild = [ buildPackages.stdenv.cc ];
2828+ nativeBuildInputs = [ perl ];
28292930 extraIncludeDirs = lib.optional hostPlatform.isPowerPC ["ppc"];
3031
···11+--- a/include/CMakeLists.txt 2017-12-25 05:59:07.204144374 +0100
22++++ b/include/CMakeLists.txt 2017-12-25 05:59:26.339552817 +0100
33+@@ -94,7 +94,7 @@
44+ ENDIF()
55+66+ MACRO(INSTALL_COMPAT_HEADER file footer)
77+- INSTALL(CODE "FILE(WRITE \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDEDIR}/${file}
88++ INSTALL(CODE "FILE(WRITE ${INSTALL_INCLUDEDIR}/${file}
99+ \"/* Do not edit this file directly, it was auto-generated by cmake */
1010+1111+ #warning This file should not be included by clients, include only <mysql.h>
···16161717 echo "propagating requisites $requires"
18181919- if test -n "$crossConfig"; then
2020- local pkgs=("${crossPkgs[@]}")
2121- else
2222- local pkgs=("${nativePkgs[@]}")
2323- fi
2419 for r in $requires; do
2525- for p in "${pkgs[@]}"; do
2020+ for p in "${pkgsHostHost[@]}" "${pkgsHostTarget[@]}"; do
2621 if test -e $p/lib/pkgconfig/$r.pc; then
2722 echo " found requisite $r in $p"
2823 propagatedBuildInputs+=" $p"
···300300runHook addInputsHook
301301302302303303-# Recursively find all build inputs.
303303+# Package accumulators
304304+305305+# shellcheck disable=SC2034
306306+declare -a pkgsBuildBuild pkgsBuildHost pkgsBuildTarget
307307+declare -a pkgsHostHost pkgsHostTarget
308308+declare -a pkgsTargetTarget
309309+310310+declare -ra pkgBuildAccumVars=(pkgsBuildBuild pkgsBuildHost pkgsBuildTarget)
311311+declare -ra pkgHostAccumVars=(pkgsHostHost pkgsHostTarget)
312312+declare -ra pkgTargetAccumVars=(pkgsTargetTarget)
313313+314314+declare -ra pkgAccumVarVars=(pkgBuildAccumVars pkgHostAccumVars pkgTargetAccumVars)
315315+316316+317317+# Hooks
318318+319319+declare -a envBuildBuildHooks envBuildHostHooks envBuildTargetHooks
320320+declare -a envHostHostHooks envHostTargetHooks
321321+declare -a envTargetTargetHooks
322322+323323+declare -ra pkgBuildHookVars=(envBuildBuildHook envBuildHostHook envBuildTargetHook)
324324+declare -ra pkgHostHookVars=(envHostHostHook envHostTargetHook)
325325+declare -ra pkgTargetHookVars=(envTargetTargetHook)
326326+327327+declare -ra pkgHookVarVars=(pkgBuildHookVars pkgHostHookVars pkgTargetHookVars)
328328+329329+# Add env hooks for all sorts of deps with the specified host offset.
330330+addEnvHooks() {
331331+ local depHostOffset="$1"
332332+ shift
333333+ local pkgHookVarsSlice="${pkgHookVarVars[$depHostOffset + 1]}[@]"
334334+ local pkgHookVar
335335+ for pkgHookVar in "${!pkgHookVarsSlice}"; do
336336+ eval "${pkgHookVar}s"'+=("$@")'
337337+ done
338338+}
339339+340340+341341+# Propagated dep files
342342+343343+declare -ra propagatedBuildDepFiles=(
344344+ propagated-build-build-deps
345345+ propagated-native-build-inputs # Legacy name for back-compat
346346+ propagated-build-target-deps
347347+)
348348+declare -ra propagatedHostDepFiles=(
349349+ propagated-host-host-deps
350350+ propagated-build-inputs # Legacy name for back-compat
351351+)
352352+declare -ra propagatedTargetDepFiles=(
353353+ propagated-target-target-deps
354354+)
355355+declare -ra propagatedDepFilesVars=(
356356+ propagatedBuildDepFiles
357357+ propagatedHostDepFiles
358358+ propagatedTargetDepFiles
359359+)
360360+361361+# Platform offsets: build = -1, host = 0, target = 1
362362+declare -ra allPlatOffsets=(-1 0 1)
363363+364364+365365+# Mutually-recursively find all build inputs. See the dependency section of the
366366+# stdenv chapter of the Nixpkgs manual for the specification this algorithm
367367+# implements.
304368findInputs() {
305305- local pkg="$1"; shift
306306- local var="$1"; shift
307307- local propagatedBuildInputsFiles=("$@")
369369+ local -r pkg="$1"
370370+ local -ri hostOffset="$2"
371371+ local -ri targetOffset="$3"
372372+373373+ # Sanity check
374374+ (( "$hostOffset" <= "$targetOffset" )) || exit -1
375375+376376+ local varVar="${pkgAccumVarVars[$hostOffset + 1]}"
377377+ local varRef="$varVar[\$targetOffset - \$hostOffset]"
378378+ local var="${!varRef}"
379379+ unset -v varVar varRef
308380309381 # TODO(@Ericson2314): Restore using associative array once Darwin
310382 # nix-shell doesn't use impure bash. This should replace the O(n)
···324396 exit 1
325397 fi
326398327327- local file
328328- for file in "${propagatedBuildInputsFiles[@]}"; do
329329- file="$pkg/nix-support/$file"
330330- [[ -f "$file" ]] || continue
399399+ # The current package's host and target offset together
400400+ # provide a <=-preserving homomorphism from the relative
401401+ # offsets to current offset
402402+ function mapOffset() {
403403+ local -ri inputOffset="$1"
404404+ if (( "$inputOffset" <= 0 )); then
405405+ local -ri outputOffset="$inputOffset + $hostOffset"
406406+ else
407407+ local -ri outputOffset="$inputOffset - 1 + $targetOffset"
408408+ fi
409409+ echo "$outputOffset"
410410+ }
411411+412412+ # Host offset relative to that of the package whose immediate
413413+ # dependencies we are currently exploring.
414414+ local -i relHostOffset
415415+ for relHostOffset in "${allPlatOffsets[@]}"; do
416416+ # `+ 1` so we start at 0 for valid index
417417+ local files="${propagatedDepFilesVars[$relHostOffset + 1]}"
418418+419419+ # Host offset relative to the package currently being
420420+ # built---as absolute an offset as will be used.
421421+ local -i hostOffsetNext
422422+ hostOffsetNext="$(mapOffset relHostOffset)"
423423+424424+ # Ensure we're in bounds relative to the package currently
425425+ # being built.
426426+ [[ "${allPlatOffsets[*]}" = *"$hostOffsetNext"* ]] || continue
427427+428428+ # Target offset relative to the *host* offset of the package
429429+ # whose immediate dependencies we are currently exploring.
430430+ local -i relTargetOffset
431431+ for relTargetOffset in "${allPlatOffsets[@]}"; do
432432+ (( "$relHostOffset" <= "$relTargetOffset" )) || continue
433433+434434+ local fileRef="${files}[$relTargetOffset - $relHostOffset]"
435435+ local file="${!fileRef}"
436436+ unset -v fileRef
437437+438438+ # Target offset relative to the package currently being
439439+ # built.
440440+ local -i targetOffsetNext
441441+ targetOffsetNext="$(mapOffset relTargetOffset)"
442442+443443+ # Once again, ensure we're in bounds relative to the
444444+ # package currently being built.
445445+ [[ "${allPlatOffsets[*]}" = *"$targetOffsetNext"* ]] || continue
446446+447447+ [[ -f "$pkg/nix-support/$file" ]] || continue
331448332332- local pkgNext
333333- for pkgNext in $(< "$file"); do
334334- findInputs "$pkgNext" "$var" "${propagatedBuildInputsFiles[@]}"
449449+ local pkgNext
450450+ for pkgNext in $(< "$pkg/nix-support/$file"); do
451451+ findInputs "$pkgNext" "$hostOffsetNext" "$targetOffsetNext"
452452+ done
335453 done
336454 done
337455}
338456457457+# Make sure all are at least defined as empty
458458+: ${depsBuildBuild=} ${depsBuildBuildPropagated=}
459459+: ${nativeBuildInputs=} ${propagatedNativeBuildInputs=} ${defaultNativeBuildInputs=}
460460+: ${depsBuildTarget=} ${depsBuildTargetPropagated=}
461461+: ${depsHostHost=} ${depsHostHostPropagated=}
462462+: ${buildInputs=} ${propagatedBuildInputs=} ${defaultBuildInputs=}
463463+: ${depsTargetTarget=} ${depsTargetTargetPropagated=}
464464+465465+for pkg in $depsBuildBuild $depsBuildBuildPropagated; do
466466+ findInputs "$pkg" -1 -1
467467+done
468468+for pkg in $nativeBuildInputs $propagatedNativeBuildInputs; do
469469+ findInputs "$pkg" -1 0
470470+done
471471+for pkg in $depsBuildTarget $depsBuildTargetPropagated; do
472472+ findInputs "$pkg" -1 1
473473+done
474474+for pkg in $depsHostHost $depsHostHostPropagated; do
475475+ findInputs "$pkg" 0 0
476476+done
477477+for pkg in $buildInputs $propagatedBuildInputs ; do
478478+ findInputs "$pkg" 0 1
479479+done
480480+for pkg in $depsTargetTarget $depsTargetTargetPropagated; do
481481+ findInputs "$pkg" 1 1
482482+done
483483+# Default inputs must be processed last
484484+for pkg in $defaultNativeBuildInputs; do
485485+ findInputs "$pkg" -1 0
486486+done
487487+for pkg in $defaultBuildInputs; do
488488+ findInputs "$pkg" 0 1
489489+done
490490+339491# Add package to the future PATH and run setup hooks
340492activatePackage() {
341493 local pkg="$1"
494494+ local -ri hostOffset="$2"
495495+ local -ri targetOffset="$3"
496496+497497+ # Sanity check
498498+ (( "$hostOffset" <= "$targetOffset" )) || exit -1
342499343500 if [ -f "$pkg" ]; then
344501 local oldOpts="$(shopt -po nounset)"
···347504 eval "$oldOpts"
348505 fi
349506350350- if [ -d "$pkg/bin" ]; then
507507+ # Only dependencies whose host platform is guaranteed to match the
508508+ # build platform are included here. That would be `depsBuild*`,
509509+ # and legacy `nativeBuildInputs`, in general. If we aren't cross
510510+ # compiling, however, everything can be put on the PATH. To ease
511511+ # the transition, we do include everything in thatcase.
512512+ #
513513+ # TODO(@Ericson2314): Don't special-case native compilation
514514+ if [[ ( -z "${crossConfig-}" || "$hostOffset" -le -1 ) && -d "$pkg/bin" ]]; then
351515 addToSearchPath _PATH "$pkg/bin"
352516 fi
353517354354- if [ -f "$pkg/nix-support/setup-hook" ]; then
518518+ if [[ -f "$pkg/nix-support/setup-hook" ]]; then
355519 local oldOpts="$(shopt -po nounset)"
356520 set +u
357521 source "$pkg/nix-support/setup-hook"
···359523 fi
360524}
361525362362-declare -a nativePkgs crossPkgs
363363-if [ -z "${crossConfig:-}" ]; then
364364- # Not cross-compiling - both buildInputs (and variants like propagatedBuildInputs)
365365- # are handled identically to nativeBuildInputs
366366- for i in ${nativeBuildInputs:-} ${buildInputs:-} \
367367- ${defaultNativeBuildInputs:-} ${defaultBuildInputs:-} \
368368- ${propagatedNativeBuildInputs:-} ${propagatedBuildInputs:-}; do
369369- findInputs "$i" nativePkgs propagated-native-build-inputs propagated-build-inputs
370370- done
371371-else
372372- for i in ${nativeBuildInputs:-} ${defaultNativeBuildInputs:-} ${propagatedNativeBuildInputs:-}; do
373373- findInputs "$i" nativePkgs propagated-native-build-inputs
526526+_activatePkgs() {
527527+ local -i hostOffset targetOffset
528528+ local pkg
529529+530530+ for hostOffset in "${allPlatOffsets[@]}"; do
531531+ local pkgsVar="${pkgAccumVarVars[$hostOffset + 1]}"
532532+ for targetOffset in "${allPlatOffsets[@]}"; do
533533+ (( "$hostOffset" <= "$targetOffset" )) || continue
534534+ local pkgsRef="${pkgsVar}[$targetOffset - $hostOffset]"
535535+ local pkgsSlice="${!pkgsRef}[@]"
536536+ for pkg in ${!pkgsSlice+"${!pkgsSlice}"}; do
537537+ activatePackage "$pkg" "$hostOffset" "$targetOffset"
538538+ done
539539+ done
374540 done
375375- for i in ${buildInputs:-} ${defaultBuildInputs:-} ${propagatedBuildInputs:-}; do
376376- findInputs "$i" crossPkgs propagated-build-inputs
377377- done
378378-fi
541541+}
379542380380-for i in ${nativePkgs+"${nativePkgs[@]}"} ${crossPkgs+"${crossPkgs[@]}"}; do
381381- activatePackage "$i"
382382-done
383383-543543+# Run the package setup hooks and build _PATH
544544+_activatePkgs
384545385546# Set the relevant environment variables to point to the build inputs
386547# found above.
387548#
388388-# These `depOffset`s tell the env hook what sort of dependency
389389-# (ignoring propagatedness) is being passed to the env hook. In a real
390390-# language, we'd append a closure with this information to the
391391-# relevant env hook array, but bash doesn't have closures, so it's
392392-# easier to just pass this in.
549549+# These `depOffset`s, beyond indexing the arrays, also tell the env
550550+# hook what sort of dependency (ignoring propagatedness) is being
551551+# passed to the env hook. In a real language, we'd append a closure
552552+# with this information to the relevant env hook array, but bash
553553+# doesn't have closures, so it's easier to just pass this in.
554554+_addToEnv() {
555555+ local -i depHostOffset depTargetOffset
556556+ local pkg
393557394394-_addToNativeEnv() {
395395- local pkg="$1"
396396- if [[ -n "${crossConfig:-}" ]]; then
397397- local -i depOffset=-1
398398- else
399399- local -i depOffset=0
400400- fi
401401-402402- # Run the package-specific hooks set by the setup-hook scripts.
403403- runHook envHook "$pkg"
404404-}
405405-406406-# Old bash empty array hack
407407-for i in ${nativePkgs+"${nativePkgs[@]}"}; do
408408- _addToNativeEnv "$i"
409409-done
410410-411411-_addToCrossEnv() {
412412- local pkg="$1"
413413- local -i depOffset=0
414414-415415- # Run the package-specific hooks set by the setup-hook scripts.
416416- runHook crossEnvHook "$pkg"
558558+ for depHostOffset in "${allPlatOffsets[@]}"; do
559559+ local hookVar="${pkgHookVarVars[$depHostOffset + 1]}"
560560+ local pkgsVar="${pkgAccumVarVars[$depHostOffset + 1]}"
561561+ for depTargetOffset in "${allPlatOffsets[@]}"; do
562562+ (( "$depHostOffset" <= "$depTargetOffset" )) || continue
563563+ local hookRef="${hookVar}[$depTargetOffset - $depHostOffset]"
564564+ if [[ -z "${crossConfig-}" ]]; then
565565+ # Apply environment hooks to all packages during native
566566+ # compilation to ease the transition.
567567+ #
568568+ # TODO(@Ericson2314): Don't special-case native compilation
569569+ for pkg in \
570570+ ${pkgsBuildBuild+"${pkgsBuildBuild[@]}"} \
571571+ ${pkgsBuildHost+"${pkgsBuildHost[@]}"} \
572572+ ${pkgsBuildTarget+"${pkgsBuildTarget[@]}"} \
573573+ ${pkgsHostHost+"${pkgsHostHost[@]}"} \
574574+ ${pkgsHostTarget+"${pkgsHostTarget[@]}"} \
575575+ ${pkgsTargetTarget+"${pkgsTargetTarget[@]}"}
576576+ do
577577+ runHook "${!hookRef}" "$pkg"
578578+ done
579579+ else
580580+ local pkgsRef="${pkgsVar}[$depTargetOffset - $depHostOffset]"
581581+ local pkgsSlice="${!pkgsRef}[@]"
582582+ for pkg in ${!pkgsSlice+"${!pkgsSlice}"}; do
583583+ runHook "${!hookRef}" "$pkg"
584584+ done
585585+ fi
586586+ done
587587+ done
417588}
418589419419-# Old bash empty array hack
420420-for i in ${crossPkgs+"${crossPkgs[@]}"}; do
421421- _addToCrossEnv "$i"
422422-done
590590+# Run the package-specific hooks set by the setup-hook scripts.
591591+_addToEnv
423592424593425594_addRpathPrefix "$out"
···8821051# propagated-build-inputs.
8831052fixupPhase() {
8841053 # Make sure everything is writable so "strip" et al. work.
10541054+ local output
8851055 for output in $outputs; do
8861056 if [ -e "${!output}" ]; then chmod -R u+w "${!output}"; fi
8871057 done
···8951065 done
89610668971067898898- # Propagate build inputs and setup hook into the development output.
10681068+ # Propagate dependencies & setup hook into the development output.
10691069+ declare -ra flatVars=(
10701070+ # Build
10711071+ depsBuildBuildPropagated
10721072+ propagatedNativeBuildInputs
10731073+ depsBuildTargetPropagated
10741074+ # Host
10751075+ depsHostHostPropagated
10761076+ propagatedBuildInputs
10771077+ # Target
10781078+ depsTargetTargetPropagated
10791079+ )
10801080+ declare -ra flatFiles=(
10811081+ "${propagatedBuildDepFiles[@]}"
10821082+ "${propagatedHostDepFiles[@]}"
10831083+ "${propagatedTargetDepFiles[@]}"
10841084+ )
10851085+10861086+ local propagatedInputsIndex
10871087+ for propagatedInputsIndex in "${!flatVars[@]}"; do
10881088+ local propagatedInputsSlice="${flatVars[$propagatedInputsIndex]}[@]"
10891089+ local propagatedInputsFile="${flatFiles[$propagatedInputsIndex]}"
8991090900900- if [ -n "${propagatedBuildInputs:-}" ]; then
901901- mkdir -p "${!outputDev}/nix-support"
902902- # shellcheck disable=SC2086
903903- printWords $propagatedBuildInputs > "${!outputDev}/nix-support/propagated-build-inputs"
904904- fi
10911091+ [[ "${!propagatedInputsSlice}" ]] || continue
9051092906906- if [ -n "${propagatedNativeBuildInputs:-}" ]; then
9071093 mkdir -p "${!outputDev}/nix-support"
9081094 # shellcheck disable=SC2086
909909- printWords $propagatedNativeBuildInputs > "${!outputDev}/nix-support/propagated-native-build-inputs"
910910- fi
10951095+ printWords ${!propagatedInputsSlice} > "${!outputDev}/nix-support/$propagatedInputsFile"
10961096+ done
911109791210989131099 if [ -n "${setupHook:-}" ]; then
···1717 configureFlags =
1818 # "pr" need not be on the PATH as a run-time dep, so we need to tell
1919 # configure where it is. Covers the cross and native case alike.
2020- stdenv.lib.optional (coreutils != null) "PR_PROGRAM=${coreutils}/bin/pr";
2020+ stdenv.lib.optional (coreutils != null) "PR_PROGRAM=${coreutils}/bin/pr"
2121+ ++ stdenv.lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) "gl_cv_func_getopt_gnu=yes";
21222223 meta = {
2324 homepage = http://www.gnu.org/software/diffutils/diffutils.html;