Merge pull request #26805 from obsidiansystems/cross-elegant

Make cross compilation elegant
This commit is contained in:
John Ericson 2017-12-30 22:58:02 -05:00 committed by GitHub
commit 4d2b763817
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
88 changed files with 1059 additions and 699 deletions

View File

@ -187,7 +187,7 @@
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.
For example, <varname>buildPackages.gcc</varname> should be used at build time, while <varname>gcc</varname> should be used at run time.
Now, for most of Nixpkgs's history, there was no <varname>buildPackages</varname>, and most packages have not been refactored to use it explicitly.
Instead, one can use the four attributes used for specifying dependencies as documented in <xref linkend="ssec-stdenv-attributes"/>.
Instead, one can use the six (<emphasis>gasp</emphasis>) attributes used for specifying dependencies as documented in <xref linkend="ssec-stdenv-dependencies"/>.
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.
This splicing can be skipped when not cross compiling as the package sets are the same, but is a bit slow for cross compiling.
Because of this, a best-of-both-worlds solution is in the works with no splicing or explicit access of <varname>buildPackages</varname> needed.
@ -200,6 +200,45 @@
</para></note>
</section>
<section>
<title>Cross packagaing cookbook</title>
<para>
Some frequently problems when packaging for cross compilation are good to just spell and answer.
Ideally the information above is exhaustive, so this section cannot provide any new information,
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.
Feel free to add to this list!
</para>
<qandaset>
<qandaentry>
<question><para>
What if my package's build system needs to build a C program to be run under the build environment?
</para></question>
<answer><para>
<programlisting>depsBuildBuild = [ buildPackages.stdenv.cc ];</programlisting>
Add it to your <function>mkDerivation</function> invocation.
</para></answer>
</qandaentry>
<qandaentry>
<question><para>
My package fails to find <command>ar</command>.
</para></question>
<answer><para>
Many packages assume that an unprefixed <command>ar</command> is available, but Nix doesn't provide one.
It only provides a prefixed one, just as it only does for all the other binutils programs.
It may be necessary to patch the package to fix the build system to use a prefixed `ar`.
</para></answer>
</qandaentry>
<qandaentry>
<question><para>
My package's testsuite needs to run host platform code.
</para></question>
<answer><para>
<programlisting>doCheck = stdenv.hostPlatform != stdenv.buildPlatfrom;</programlisting>
Add it to your <function>mkDerivation</function> invocation.
</para></answer>
</qandaentry>
</qandaset>
</section>
</section>
<!--============================================================-->

View File

@ -179,6 +179,269 @@ genericBuild
</section>
<section xml:id="ssec-stdenv-dependencies"><title>Specifying dependencies</title>
<para>
As described in the Nix manual, almost any <filename>*.drv</filename> store path in a derivation's attribute set will induce a dependency on that derivation.
<varname>mkDerivation</varname>, however, takes a few attributes intended to, between them, include all the dependencies of a package.
This is done both for structure and consistency, but also so that certain other setup can take place.
For example, certain dependencies need their bin directories added to the <envar>PATH</envar>.
That is built-in, but other setup is done via a pluggable mechanism that works in conjunction with these dependency attributes.
See <xref linkend="ssec-setup-hooks"/> for details.
</para>
<para>
Dependencies can be broken down along three axes: their host and target platforms relative to the new derivation's, and whether they are propagated.
The platform distinctions are motivated by cross compilation; see <xref linkend="chap-cross"/> for exactly what each platform means.
<footnote><para>
The build platform is ignored because it is a mere implementation detail of the package satisfying the dependency:
As a general programming principle, dependencies are always <emphasis>specified</emphasis> as interfaces, not concrete implementation.
</para></footnote>
But even if one is not cross compiling, the platforms imply whether or not the dependency is needed at run-time or build-time, a concept that makes perfect sense outside of cross compilation.
For now, the run-time/build-time distinction is just a hint for mental clarity, but in the future it perhaps could be enforced.
</para>
<para>
The extension of <envar>PATH</envar> with dependencies, alluded to above, proceeds according to the relative platforms alone.
The process is carried out only for dependencies whose host platform matches the new derivation's build platformi.e. which run on the platform where the new derivation will be built.
<footnote><para>
Currently, that means for native builds all dependencies are put on the <envar>PATH</envar>.
But in the future that may not be the case for sake of matching cross:
the platforms would be assumed to be unique for native and cross builds alike, so only the <varname>depsBuild*</varname> and <varname>nativeBuildDependencies</varname> dependencies would affect the <envar>PATH</envar>.
</para></footnote>
For each dependency <replaceable>dep</replaceable> of those dependencies, <filename><replaceable>dep</replaceable>/bin</filename>, if present, is added to the <envar>PATH</envar> environment variable.
</para>
<para>
The dependency is propagated when it forces some of its other-transitive (non-immediate) downstream dependencies to also take it on as an immediate dependency.
Nix itself already takes a package's transitive dependencies into account, but this propagation ensures nixpkgs-specific infrastructure like setup hooks (mentioned above) also are run as if the propagated dependency.
</para>
<para>
It is important to note dependencies are not necessary propagated as the same sort of dependency that they were before, but rather as the corresponding sort so that the platform rules still line up.
The exact rules for dependency propagation can be given by assigning each sort of dependency two integers based one how it's host and target platforms are offset from the depending derivation's platforms.
Those offsets are given are given below in the descriptions of each dependency list attribute.
Algorithmically, we traverse propagated inputs, accumulating every propagated dep's propagated deps and adjusting them to account for the "shift in perspective" described by the current dep's platform offsets.
This results in sort a transitive closure of the dependency relation, with the offsets being approximately summed when two dependency links are combined.
We also prune transitive deps whose combined offsets go out-of-bounds, which can be viewed as a filter over that transitive closure removing dependencies that are blatantly absurd.
</para>
<para>
We can define the process precisely with <link xlink:href="https://en.wikipedia.org/wiki/Natural_deduction">Natural Deduction</link> using the inference rules.
This probably seems a bit obtuse, but so is the bash code that actually implements it!
<footnote><para>
The <function>findInputs</function> function, currently residing in <filename>pkgs/stdenv/generic/setup.sh</filename>, implements the propagation logic.
</para></footnote>
They're confusing in very different ways so...hopefully if something doesn't make sense in one presentation, it does in the other!
<programlisting>
let mapOffset(h, t, i) = i + (if i &lt;= 0 then h else t - 1)
propagated-dep(h0, t0, A, B)
propagated-dep(h1, t1, B, C)
h0 + h1 in {-1, 0, 1}
h0 + t1 in {-1, 0, 1}
-------------------------------------- Transitive property
propagated-dep(mapOffset(h0, t0, h1),
mapOffset(h0, t0, t1),
A, C)</programlisting>
<programlisting>
let mapOffset(h, t, i) = i + (if i &lt;= 0 then h else t - 1)
dep(h0, _, A, B)
propagated-dep(h1, t1, B, C)
h0 + h1 in {-1, 0, 1}
h0 + t1 in {-1, 0, -1}
-------------------------------------- Take immediate deps' propagated deps
propagated-dep(mapOffset(h0, t0, h1),
mapOffset(h0, t0, t1),
A, C)</programlisting>
<programlisting>
propagated-dep(h, t, A, B)
-------------------------------------- Propagated deps count as deps
dep(h, t, A, B)</programlisting>
Some explanation of this monstrosity is in order.
In the common case, the target offset of a dependency is the successor to the target offset: <literal>t = h + 1</literal>.
That means that:
<programlisting>
let f(h, t, i) = i + (if i &lt;= 0 then h else t - 1)
let f(h, h + 1, i) = i + (if i &lt;= 0 then h else (h + 1) - 1)
let f(h, h + 1, i) = i + (if i &lt;= 0 then h else h)
let f(h, h + 1, i) = i + h
</programlisting>
This is where the "sum-like" comes from above:
We can just sum all the host offset to get the host offset of the transitive dependency.
The target offset is the transitive dep is simply the host offset + 1, just as it was with the dependencies composed to make this transitive one;
it can be ignored as it doesn't add any new information.
</para>
<para>
Because of the bounds checks, the uncommon cases are <literal>h = t</literal> and <literal>h + 2 = t</literal>.
In the former case, the motivation for <function>mapOffset</function> is that since its host and target platforms are the same, no transitive dep of it should be able to "discover" an offset greater than its reduced target offsets.
<function>mapOffset</function> effectively "squashes" all its transitive dependencies' offsets so that none will ever be greater than the target offset of the original <literal>h = t</literal> package.
In the other case, <literal>h + 1</literal> is skipped over between the host and target offsets.
Instead of squashing the offsets, we need to "rip" them apart so no transitive dependencies' offset is that one.
</para>
<para>
Overall, the unifying theme here is that propagation shouldn't be introducing transitive dependencies involving platforms the needing package is unaware of.
The offset bounds checking and definition of <function>mapOffset</function> together ensure that this is the case.
Discovering a new offset is discovering a new platform, and since those platforms weren't in the derivation "spec" of the needing package, they cannot be relevant.
From a capability perspective, we can imagine that the host and target platforms of a package are the capabilities a package requires, and the depending package must provide the capability to the dependency.
</para>
<variablelist>
<title>Variables specifying dependencies</title>
<varlistentry>
<term><varname>depsBuildBuild</varname></term>
<listitem>
<para>
A list of dependencies whose host and target platforms are the new derivation's build platform.
This means a <literal>-1</literal> host and <literal>-1</literal> target offset from the new derivation's platforms.
They are programs/libraries used at build time that furthermore produce programs/libraries also used at build time.
If the dependency doesn't care about the target platform (i.e. isn't a compiler or similar tool), put it in <varname>nativeBuildInputs</varname>instead.
The most common use for this <literal>buildPackages.stdenv.cc</literal>, the default C compiler for this role.
That example crops up more than one might think in old commonly used C libraries.
</para>
<para>
Since these packages are able to be run at build time, that are always added to the <envar>PATH</envar>, as described above.
But since these packages are only guaranteed to be able to run then, they shouldn't persist as run-time dependencies.
This isn't currently enforced, but could be in the future.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>nativeBuildInputs</varname></term>
<listitem>
<para>
A list of dependencies whose host platform is the new derivation's build platform, and target platform is the new derivation's host platform.
This means a <literal>-1</literal> host offset and <literal>0</literal> target offset from the new derivation's platforms.
They are programs/libraries used at build time that, if they are a compiler or similar tool, produce code to run at run time—i.e. tools used to build the new derivation.
If the dependency doesn't care about the target platform (i.e. isn't a compiler or similar tool), put it here, rather than in <varname>depsBuildBuild</varname> or <varname>depsBuildTarget</varname>.
This would be called <varname>depsBuildHost</varname> but for historical continuity.
</para>
<para>
Since these packages are able to be run at build time, that are added to the <envar>PATH</envar>, as described above.
But since these packages only are guaranteed to be able to run then, they shouldn't persist as run-time dependencies.
This isn't currently enforced, but could be in the future.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>depsBuildTarget</varname></term>
<listitem>
<para>
A list of dependencies whose host platform is the new derivation's build platform, and target platform is the new derivation's target platform.
This means a <literal>-1</literal> host offset and <literal>1</literal> target offset from the new derivation's platforms.
They are programs used at build time that produce code to run at run with code produced by the depending package.
Most commonly, these would tools used to build the runtime or standard library the currently-being-built compiler will inject into any code it compiles.
In many cases, the currently-being built compiler is itself employed for that task, but when that compiler won't run (i.e. its build and host platform differ) this is not possible.
Other times, the compiler relies on some other tool, like binutils, that is always built separately so the dependency is unconditional.
</para>
<para>
This is a somewhat confusing dependency to wrap ones head around, and for good reason.
As the only one where the platform offsets are not adjacent integers, it requires thinking of a bootstrapping stage <emphasis>two</emphasis> away from the current one.
It and it's use-case go hand in hand and are both considered poor form:
try not to need this sort dependency, and try not avoid building standard libraries / runtimes in the same derivation as the compiler produces code using them.
Instead strive to build those like a normal library, using the newly-built compiler just as a normal library would.
In short, do not use this attribute unless you are packaging a compiler and are sure it is needed.
</para>
<para>
Since these packages are able to be run at build time, that are added to the <envar>PATH</envar>, as described above.
But since these packages only are guaranteed to be able to run then, they shouldn't persist as run-time dependencies.
This isn't currently enforced, but could be in the future.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>depsHostHost</varname></term>
<listitem><para>
A list of dependencies whose host and target platforms match the new derivation's host platform.
This means a both <literal>0</literal> host offset and <literal>0</literal> target offset from the new derivation's host platform.
These are packages used at run-time to generate code also used at run-time.
In practice, that would usually be tools used by compilers for metaprogramming/macro systems, or libraries used by the macros/metaprogramming code itself.
It's always preferable to use a <varname>depsBuildBuild</varname> dependency in the derivation being built than a <varname>depsHostHost</varname> on the tool doing the building for this purpose.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>buildInputs</varname></term>
<listitem>
<para>
A list of dependencies whose host platform and target platform match the new derivation's.
This means a <literal>0</literal> host offset and <literal>1</literal> target offset from the new derivation's host platform.
This would be called <varname>depsHostTarget</varname> but for historical continuity.
If the dependency doesn't care about the target platform (i.e. isn't a compiler or similar tool), put it here, rather than in <varname>depsBuildBuild</varname>.
</para>
<para>
These often are programs/libraries used by the new derivation at <emphasis>run</emphasis>-time, but that isn't always the case.
For example, the machine code in a statically linked library is only used at run time, but the derivation containing the library is only needed at build time.
Even in the dynamic case, the library may also be needed at build time to appease the linker.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>depsTargetTarget</varname></term>
<listitem><para>
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.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>depsBuildBuildPropagated</varname></term>
<listitem><para>
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].
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>propagatedNativeBuildInputs</varname></term>
<listitem><para>
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.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>depsBuildTargetPropagated</varname></term>
<listitem><para>
The propagated equivalent of <varname>depsBuildTarget</varname>.
This is prefixed for the same reason of alerting potential users.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>depsHostHostPropagated</varname></term>
<listitem><para>
The propagated equivalent of <varname>depsHostHost</varname>.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>propagatedBuildInputs</varname></term>
<listitem><para>
The propagated equivalent of <varname>buildInputs</varname>.
This would be called <varname>depsHostTargetPropagated</varname> but for historical continuity.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>depsTargetTarget</varname></term>
<listitem><para>
The propagated equivalent of <varname>depsTargetTarget</varname>.
This is prefixed for the same reason of alerting potential users.
</para></listitem>
</varlistentry>
</variablelist>
</section>
<section xml:id="ssec-stdenv-attributes"><title>Attributes</title>
<variablelist>
@ -198,54 +461,6 @@ genericBuild
</variablelist>
<variablelist>
<title>Variables specifying dependencies</title>
<varlistentry>
<term><varname>nativeBuildInputs</varname></term>
<listitem><para>
A list of dependencies used by the new derivation at <emphasis>build</emphasis>-time.
I.e. these dependencies should not make it into the package's runtime-closure, though this is currently not checked.
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.
Other environment variables are also set up via a pluggable mechanism.
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.
See <xref linkend="ssec-setup-hooks"/> for details.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>buildInputs</varname></term>
<listitem><para>
A list of dependencies used by the new derivation at <emphasis>run</emphasis>-time.
Currently, the build-time environment is modified in the exact same way as with <varname>nativeBuildInputs</varname>.
This is problematic in that when cross-compiling, foreign executables can clobber native ones on the <envar>PATH</envar>.
Even more confusing is static-linking.
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.
A less confusing solution to this would be nice.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>propagatedNativeBuildInputs</varname></term>
<listitem><para>
Like <varname>nativeBuildInputs</varname>, but these dependencies are <emphasis>propagated</emphasis>:
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.
So if package Y has <literal>propagatedNativeBuildInputs = [X]</literal>, and package Z has <literal>nativeBuildInputs = [Y]</literal>,
then package X will appear in Zs build environment automatically.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>propagatedBuildInputs</varname></term>
<listitem><para>
Like <varname>buildInputs</varname>, but propagated just like <varname>propagatedNativeBuildInputs</varname>.
This inherits <varname>buildInputs</varname>'s flaws of clobbering native executables when cross-compiling and being confusing for static linking.
</para></listitem>
</varlistentry>
</variablelist>
<variablelist>
<title>Variables affecting build properties</title>
@ -656,7 +871,7 @@ script) if it exists.</para>
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 should use this to also pass the target platform, for example.
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.
<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>
</para></listitem>
</varlistentry>
@ -923,6 +1138,20 @@ following:
<listitem><para>If set, libraries and executables are not
stripped. By default, they are.</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>dontStripHost</varname></term>
<listitem><para>
Like <varname>dontStripHost</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.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>dontStripTarget</varname></term>
<listitem><para>
Like <varname>dontStripHost</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.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>dontMoveSbin</varname></term>
@ -1353,8 +1582,55 @@ someVar=$(stripHash $name)
<section xml:id="ssec-setup-hooks"><title>Package setup hooks</title>
<para>The following packages provide a setup hook:
<para>
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.
In most cases, that is fine, and the downstream derivation can deal with it's 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.
</para>
<para>
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.
</para>
<para>
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 adding 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.
</para>
<para>
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 libaries 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).
</para>
<para>
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 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.
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.
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
<programlisting language="bash">
addEnvHooks "$hostOffset" myBashFunction
</programlisting>
</para>
<para>
The <emphasis>existence</emphasis> of setups hooks has long been documented and packages inside Nixpkgs are free to use these 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.
</para>
<para>
Here are some packages that provide a setup hook.
Since the mechanism is modular, this probably isn't an exhaustive list.
Then again, since the mechanism is only to be used as a last resort, it might be.
<variablelist>
<varlistentry>
@ -1421,9 +1697,12 @@ someVar=$(stripHash $name)
<varlistentry>
<term>Perl</term>
<listitem><para>Adds the <filename>lib/site_perl</filename> subdirectory
of each build input to the <envar>PERL5LIB</envar>
environment variable.</para></listitem>
<listitem>
<para>
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.
</para>
</listitem>
</varlistentry>
<varlistentry>

View File

@ -119,6 +119,18 @@ following incompatible changes:</para>
Other more obscure ones are just moved.
</para>
</listitem>
<listitem>
<para>
The propagation logic has been changed.
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.
<!-- That's <xref linkend="ssec-stdenv-attributes"> were we to merge the manuals. -->
The old logic isn't but is easy to describe: dependencies were propagated as the same type of dependency no matter what.
In practice, that means that many <function>propagatedNativeBuildInputs</function> should instead be <function>propagatedBuildInputs</function>.
Thankfully, that was and is the least used type of dependency.
Also, it means that some <function>propagatedBuildInputs</function> should instead be <function>depsTargetTargetPropagated</function>.
Other types dependencies should be unaffected.
</para>
</listitem>
</itemizedlist>
</section>

View File

@ -8,8 +8,8 @@ mkDerivation {
license = with licenses; [ gpl2 lgpl21 bsd3 ];
maintainers = with maintainers; [ peterhoeg ];
};
nativeBuildInputs = [ extra-cmake-modules ];
buildInputs = [ qtbase kdoctools ];
nativeBuildInputs = [ extra-cmake-modules kdoctools ];
buildInputs = [ qtbase ];
propagatedBuildInputs = [
kcodecs ki18n kio kwidgetsaddons
libmusicbrainz5

View File

@ -22,9 +22,9 @@ stdenv.mkDerivation rec {
configureFlags = [ "--enable-widec" ] ++ stdenv.lib.optional sslSupport "--with-ssl";
nativeBuildInputs = stdenv.lib.optional sslSupport pkgconfig
++ stdenv.lib.optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc
++ [ nukeReferences ];
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ nukeReferences ]
++ stdenv.lib.optional sslSupport pkgconfig;
buildInputs = [ ncurses gzip ] ++ stdenv.lib.optional sslSupport openssl.dev;

View File

@ -14,9 +14,12 @@ mkDerivation rec {
sha256 = "1dbvdrkdpgv39v8h7k3mri0nzlslfyd5kk410czj0jdn4qq400md";
};
nativeBuildInputs = [ cmake extra-cmake-modules shared_mime_info ];
nativeBuildInputs = [
cmake extra-cmake-modules kdoctools shared_mime_info
];
buildInputs = [ qtwebkit qtscript grantlee kxmlgui kwallet kparts kdoctools
buildInputs = [
qtwebkit qtscript grantlee kxmlgui kwallet kparts
kjobwidgets kdesignerplugin kiconthemes knewstuff sqlcipher qca-qt5
kactivities karchive kguiaddons knotifyconfig krunner kwindowsystem libofx
];

View File

@ -60,7 +60,7 @@ stdenv.mkDerivation {
fi
}
envHooks=(''${envHooks[@]} addCoqPath)
addEnvHooks "$targetOffset" addCoqPath
'';
passthru = {

View File

@ -110,7 +110,7 @@ self = stdenv.mkDerivation {
fi
}
envHooks=(''${envHooks[@]} addCoqPath)
addEnvHooks "$targetOffset" addCoqPath
'';
preConfigure = ''

View File

@ -1,5 +1,7 @@
addRLibPath () {
addToSearchPath R_LIBS_SITE $1/library
if [[ -d "$1/library" ]]; then
addToSearchPath R_LIBS_SITE "$1/library"
fi
}
envHooks+=(addRLibPath)
addEnvHooks "$targetOffset" addRLibPath

View File

@ -102,7 +102,8 @@ stdenv.mkDerivation rec {
rm -rf ffmpeg
'';
nativeBuildInputs = [ buildPackages.stdenv.cc pkgconfig yasm ];
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ pkgconfig yasm ];
buildInputs = with stdenv.lib;
[ freetype ffmpeg ]
++ optional aalibSupport aalib

View File

@ -178,7 +178,7 @@ stdenv.mkDerivation {
else throw "unknown emulation for platform: " + targetPlatform.config;
in targetPlatform.platform.bfdEmulation or (fmt + "-" + arch);
propagatedBuildInputs = extraPackages;
depsTargetTargetPropagated = extraPackages;
setupHook = ./setup-hook.sh;

View File

@ -2,12 +2,20 @@
#
# See comments in cc-wrapper's setup hook. This works exactly the same way.
set -u
# Skip setup hook if we're neither a build-time dep, nor, temporarily, doing a
# native compile.
#
# TODO(@Ericson2314): No native exception
[[ -z ${crossConfig-} ]] || (( "$hostOffset" < 0 )) || return 0
bintoolsWrapper_addLDVars () {
case $depOffset in
case $depHostOffset in
-1) local role='BUILD_' ;;
0) local role='' ;;
1) local role='TARGET_' ;;
*) echo "bintools-wrapper: Error: Cannot be used with $depOffset-offset deps, " >2;
*) echo "bintools-wrapper: Error: Cannot be used with $depHostOffset-offset deps" >2;
return 1 ;;
esac
@ -20,17 +28,29 @@ bintoolsWrapper_addLDVars () {
fi
}
if [ -n "${crossConfig:-}" ]; then
export NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_BUILD=1
role_pre='BUILD_'
role_post='_FOR_BUILD'
else
export NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_HOST=1
role_pre=""
role_post=''
fi
case $targetOffset in
-1)
export NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_BUILD=1
role_pre='BUILD_'
role_post='_FOR_BUILD'
;;
0)
export NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_HOST=1
role_pre=''
role_post=''
;;
1)
export NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_TARGET=1
role_pre='TARGET_'
role_post='_FOR_TARGET'
;;
*)
echo "cc-wrapper: used as improper sort of dependency" >2;
return 1
;;
esac
envHooks+=(bintoolsWrapper_addLDVars)
addEnvHooks "$targetOffset" bintoolsWrapper_addLDVars
# shellcheck disable=SC2157
if [ -n "@bintools_bin@" ]; then
@ -65,3 +85,4 @@ done
# No local scope in sourced file
unset -v role_pre role_post cmd upper_case
set +u

View File

@ -201,7 +201,8 @@ stdenv.mkDerivation {
ln -s $ccPath/${targetPrefix}ghdl $out/bin/${targetPrefix}ghdl
'';
propagatedBuildInputs = [ bintools ] ++ extraPackages;
propagatedBuildInputs = [ bintools ];
depsTargetTargetPropagated = extraPackages;
setupHook = ./setup-hook.sh;

View File

@ -54,19 +54,26 @@
# For more details, read the individual files where the mechanisms used to
# accomplish this will be individually documented.
set -u
# Skip setup hook if we're neither a build-time dep, nor, temporarily, doing a
# native compile.
#
# TODO(@Ericson2314): No native exception
[[ -z ${crossConfig-} ]] || (( "$hostOffset" < 0 )) || return 0
# It's fine that any other cc-wrapper will redefine this. Bash functions close
# over no state, and there's no @-substitutions within, so any redefined
# function is guaranteed to be exactly the same.
ccWrapper_addCVars () {
# The `depOffset` describes how the platforms of the dependencies are slid
# relative to the depending package. It is brought into scope of the
# environment hook defined as the role of the dependency being applied.
case $depOffset in
# The `depHostOffset` describes how the host platform of the dependencies
# are slid relative to the depending package. It is brought into scope of
# the environment hook defined as the role of the dependency being applied.
case $depHostOffset in
-1) local role='BUILD_' ;;
0) local role='' ;;
1) local role='TARGET_' ;;
*) echo "cc-wrapper: Error: Cannot be used with $depOffset-offset deps, " >2;
*) echo "cc-wrapper: Error: Cannot be used with $depHostOffset-offset deps" >2;
return 1 ;;
esac
@ -87,20 +94,31 @@ ccWrapper_addCVars () {
#
# We also need to worry about what role is being added on *this* invocation of
# setup-hook, which `role` tracks.
if [ -n "${crossConfig:-}" ]; then
export NIX_CC_WRAPPER_@infixSalt@_TARGET_BUILD=1
role_pre='BUILD_'
role_post='_FOR_BUILD'
else
export NIX_CC_WRAPPER_@infixSalt@_TARGET_HOST=1
role_pre=''
role_post=''
fi
case $targetOffset in
-1)
export NIX_CC_WRAPPER_@infixSalt@_TARGET_BUILD=1
role_pre='BUILD_'
role_post='_FOR_BUILD'
;;
0)
export NIX_CC_WRAPPER_@infixSalt@_TARGET_HOST=1
role_pre=''
role_post=''
;;
1)
export NIX_CC_WRAPPER_@infixSalt@_TARGET_TARGET=1
role_pre='TARGET_'
role_post='_FOR_TARGET'
;;
*)
echo "cc-wrapper: used as improper sort of dependency" >2;
return 1
;;
esac
# Eventually the exact sort of env-hook we create will depend on the role. This
# is because based on what relative platform we are targeting, we use different
# dependencies.
envHooks+=(ccWrapper_addCVars)
# We use the `targetOffset` to choose the right env hook to accumulate the right
# sort of deps (those with that offset).
addEnvHooks "$targetOffset" ccWrapper_addCVars
# Note 1: these come *after* $out in the PATH (see setup.sh).
# Note 2: phase separation makes this look useless to shellcheck.
@ -131,3 +149,4 @@ export CXX${role_post}=@named_cxx@
# No local scope in sourced file
unset -v role_pre role_post
set +u

View File

@ -4,4 +4,8 @@ addEmacsVars () {
fi
}
envHooks+=(addEmacsVars)
# If this is for a wrapper derivation, emacs and the dependencies are all
# run-time dependencies. If this is for precompiling packages into bytecode,
# emacs is a compile-time dependency of the package.
addEnvHooks "$targetOffset" addEmacsVars
addEnvHooks "$targetOffset" addEmacsVars

View File

@ -1,4 +1,4 @@
addCVars () {
gccWrapperOld_addCVars () {
if test -d $1/include; then
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem $1/include"
fi
@ -12,7 +12,7 @@ addCVars () {
fi
}
envHooks=(${envHooks[@]} addCVars)
envBuildBuildHooks+=(gccWrapperOld_addCVars)
# Note: these come *after* $out in the PATH (see setup.sh).

View File

@ -18,5 +18,5 @@ if [ -z "$libxmlHookDone" ]; then
# xmllint and xsltproc from looking in /etc/xml/catalog.
export XML_CATALOG_FILES
if [ -z "$XML_CATALOG_FILES" ]; then XML_CATALOG_FILES=" "; fi
envHooks+=(addXMLCatalogs)
addEnvHooks "$hostOffset" addXMLCatalogs
fi

View File

@ -10,4 +10,4 @@ addPkgToClassPath () {
done
}
envHooks+=(addPkgToClassPath)
addEnvHooks "$targetOffset" addPkgToClassPath

View File

@ -2,4 +2,4 @@ setupDebugInfoDirs () {
addToSearchPath NIX_DEBUG_INFO_DIRS $1/lib/debug
}
envHooks+=(setupDebugInfoDirs)
addEnvHooks "$targetOffset" setupDebugInfoDirs

View File

@ -3,24 +3,45 @@
fixupOutputHooks+=(_doStrip)
_doStrip() {
if [ -z "$dontStrip" ]; then
# We don't bother to strip build platform code because it shouldn't make it
# to $out anyways---if it does, that's a bigger problem that a lack of
# stripping will help catch.
local -ra flags=(dontStripHost dontStripTarget)
local -ra stripCmds=(STRIP TARGET_STRIP)
# Optimization
if [[ "$STRIP" == "$TARGET_STRIP" ]]; then
dontStripTarget+=1
fi
local i
for i in ${!stripCmds[@]}; do
local -n flag="${flags[$i]}"
local -n stripCmd="${stripCmds[$i]}"
# `dontStrip` disables them all
if [[ "$dontStrip" || "$flag" ]] || ! type -f "$stripCmd" 2>/dev/null
then continue; fi
stripDebugList=${stripDebugList:-lib lib32 lib64 libexec bin sbin}
if [ -n "$stripDebugList" ]; then
stripDirs "$stripDebugList" "${stripDebugFlags:--S}"
stripDirs "$stripCmd" "$stripDebugList" "${stripDebugFlags:--S}"
fi
stripAllList=${stripAllList:-}
if [ -n "$stripAllList" ]; then
stripDirs "$stripAllList" "${stripAllFlags:--s}"
stripDirs "$stripCmd" "$stripAllList" "${stripAllFlags:--s}"
fi
fi
done
}
stripDirs() {
local dirs="$1"
local stripFlags="$2"
local cmd="$1"
local dirs="$2"
local stripFlags="$3"
local dirsNew=
local d
for d in ${dirs}; do
if [ -d "$prefix/$d" ]; then
dirsNew="${dirsNew} $prefix/$d "
@ -29,8 +50,8 @@ stripDirs() {
dirs=${dirsNew}
if [ -n "${dirs}" ]; then
header "stripping (with flags $stripFlags) in$dirs"
find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} $STRIP $commonStripFlags $stripFlags 2>/dev/null || true
header "stripping (with command $cmd and flags $stripFlags) in$dirs"
find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} $cmd $commonStripFlags $stripFlags 2>/dev/null || true
stopNest
fi
}

View File

@ -6,7 +6,7 @@ find_gio_modules() {
fi
}
envHooks+=(find_gio_modules)
addEnvHooks "$targetOffset" find_gio_modules
# Note: $gappsWrapperArgs still gets defined even if $dontWrapGApps is set.
wrapGAppsHook() {

View File

@ -8,7 +8,8 @@ hicolorIconThemeHook() {
}
envHooks+=(hicolorIconThemeHook)
# I think this is meant to be a runtime dep
addEnvHooks "$hostOffset" hicolorIconThemeHook
# Remove icon cache
hicolorPreFixupPhase() {

View File

@ -4,4 +4,4 @@ make_grilo_find_plugins() {
fi
}
envHooks+=(make_grilo_find_plugins)
addEnvHooks "$hostOffset" make_grilo_find_plugins

View File

@ -74,4 +74,4 @@ addEnvVars() {
addToSearchPath NIX_GNUSTEP_SYSTEM_DOC_INFO "$tmp"
fi
}
envHooks=(${envHooks[@]} addEnvVars)
addEnvHooks "$targetOffset" addEnvVars

View File

@ -4,4 +4,4 @@ addChickenRepositoryPath() {
export CHICKEN_INCLUDE_PATH="$1/share;$CHICKEN_INCLUDE_PATH"
}
envHooks=(${envHooks[@]} addChickenRepositoryPath)
addEnvHooks "$targetOffset" addChickenRepositoryPath

View File

@ -229,11 +229,22 @@ stdenv.mkDerivation ({
inherit noSysDirs profiledCompiler staticCompiler langJava
libcCross crossMingw;
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ texinfo which gettext ]
++ optional (perl != null) perl;
buildInputs = [ gmp mpfr libmpc libelf ]
++ (optional (ppl != null) ppl)
# For building runtime libs
depsBuildTarget =
if hostPlatform == buildPlatform then [
targetPackages.stdenv.cc.bintools # newly-built gcc will be used
] else assert targetPlatform == hostPlatform; [ # build != host == target
stdenv.cc
];
buildInputs = [
gmp mpfr libmpc libelf
targetPackages.stdenv.cc.bintools # For linking code at run-time
] ++ (optional (ppl != null) ppl)
++ (optional (cloogppl != null) cloogppl)
++ (optional (zlib != null) zlib)
++ (optional langJava boehmgc)
@ -245,11 +256,7 @@ stdenv.mkDerivation ({
;
# TODO(@Ericson2314): Always pass "--target" and always prefix.
configurePlatforms =
# TODO(@Ericson2314): Figure out what's going wrong with Arm
if hostPlatform == targetPlatform && targetPlatform.isArm
then []
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags =
# Basic dependencies
@ -314,56 +321,9 @@ stdenv.mkDerivation ({
/* For cross-built gcc (build != host == target) */
crossAttrs = {
AR_FOR_BUILD = "ar";
AS_FOR_BUILD = "as";
LD_FOR_BUILD = "ld";
NM_FOR_BUILD = "nm";
OBJCOPY_FOR_BUILD = "objcopy";
OBJDUMP_FOR_BUILD = "objdump";
RANLIB_FOR_BUILD = "ranlib";
SIZE_FOR_BUILD = "size";
STRINGS_FOR_BUILD = "strings";
STRIP_FOR_BUILD = "strip";
CC_FOR_BUILD = "gcc";
CXX_FOR_BUILD = "g++";
AR = "${targetPlatform.config}-ar";
AS = "${targetPlatform.config}-as";
LD = "${targetPlatform.config}-ld";
NM = "${targetPlatform.config}-nm";
OBJCOPY = "${targetPlatform.config}-objcopy";
OBJDUMP = "${targetPlatform.config}-objdump";
RANLIB = "${targetPlatform.config}-ranlib";
SIZE = "${targetPlatform.config}-size";
STRINGS = "${targetPlatform.config}-strings";
STRIP = "${targetPlatform.config}-strip";
CC = "${targetPlatform.config}-gcc";
CXX = "${targetPlatform.config}-g++";
AR_FOR_TARGET = "${targetPlatform.config}-ar";
AS_FOR_TARGET = "${targetPlatform.config}-as";
LD_FOR_TARGET = "${targetPlatform.config}-ld";
NM_FOR_TARGET = "${targetPlatform.config}-nm";
OBJCOPY_FOR_TARGET = "${targetPlatform.config}-objcopy";
OBJDUMP_FOR_TARGET = "${targetPlatform.config}-objdump";
RANLIB_FOR_TARGET = "${targetPlatform.config}-ranlib";
SIZE_FOR_TARGET = "${targetPlatform.config}-size";
STRINGS_FOR_TARGET = "${targetPlatform.config}-strings";
STRIP_FOR_TARGET = "${targetPlatform.config}-strip";
CC_FOR_TARGET = "${targetPlatform.config}-gcc";
CXX_FOR_TARGET = "${targetPlatform.config}-g++";
dontStrip = true;
};
NIX_BUILD_BINTOOLS = buildPackages.stdenv.cc.bintools;
NIX_BUILD_CC = buildPackages.stdenv.cc;
# Needed for the cross compilation to work
AR = "ar";
LD = "ld";
CC = "gcc";
# Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the
# library headers and binaries, regarless of the language being compiled.
#

View File

@ -267,6 +267,7 @@ stdenv.mkDerivation ({
inherit noSysDirs staticCompiler langJava
libcCross crossMingw;
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ texinfo which gettext ]
++ (optional (perl != null) perl)
++ (optional javaAwtGtk pkgconfig);
@ -297,11 +298,7 @@ stdenv.mkDerivation ({
dontDisableStatic = true;
# TODO(@Ericson2314): Always pass "--target" and always prefix.
configurePlatforms =
# TODO(@Ericson2314): Figure out what's going wrong with Arm
if hostPlatform == targetPlatform && targetPlatform.isArm
then []
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags =
# Basic dependencies
@ -397,57 +394,12 @@ stdenv.mkDerivation ({
/* For cross-built gcc (build != host == target) */
crossAttrs = {
AR_FOR_BUILD = "ar";
AS_FOR_BUILD = "as";
LD_FOR_BUILD = "ld";
NM_FOR_BUILD = "nm";
OBJCOPY_FOR_BUILD = "objcopy";
OBJDUMP_FOR_BUILD = "objdump";
RANLIB_FOR_BUILD = "ranlib";
SIZE_FOR_BUILD = "size";
STRINGS_FOR_BUILD = "strings";
STRIP_FOR_BUILD = "strip";
CC_FOR_BUILD = "gcc";
CXX_FOR_BUILD = "g++";
AR = "${targetPlatform.config}-ar";
AS = "${targetPlatform.config}-as";
LD = "${targetPlatform.config}-ld";
NM = "${targetPlatform.config}-nm";
OBJCOPY = "${targetPlatform.config}-objcopy";
OBJDUMP = "${targetPlatform.config}-objdump";
RANLIB = "${targetPlatform.config}-ranlib";
SIZE = "${targetPlatform.config}-size";
STRINGS = "${targetPlatform.config}-strings";
STRIP = "${targetPlatform.config}-strip";
CC = "${targetPlatform.config}-gcc";
CXX = "${targetPlatform.config}-g++";
AR_FOR_TARGET = "${targetPlatform.config}-ar";
AS_FOR_TARGET = "${targetPlatform.config}-as";
LD_FOR_TARGET = "${targetPlatform.config}-ld";
NM_FOR_TARGET = "${targetPlatform.config}-nm";
OBJCOPY_FOR_TARGET = "${targetPlatform.config}-objcopy";
OBJDUMP_FOR_TARGET = "${targetPlatform.config}-objdump";
RANLIB_FOR_TARGET = "${targetPlatform.config}-ranlib";
SIZE_FOR_TARGET = "${targetPlatform.config}-size";
STRINGS_FOR_TARGET = "${targetPlatform.config}-strings";
STRIP_FOR_TARGET = "${targetPlatform.config}-strip";
CC_FOR_TARGET = "${targetPlatform.config}-gcc";
CXX_FOR_TARGET = "${targetPlatform.config}-g++";
dontStrip = true;
buildFlags = "";
};
NIX_BUILD_BINTOOLS = buildPackages.stdenv.cc.bintools;
NIX_BUILD_CC = buildPackages.stdenv.cc;
# Needed for the cross compilation to work
AR = "ar";
LD = "ld";
# http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc";
${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64";
# Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the
# library headers and binaries, regarless of the language being compiled.

View File

@ -262,12 +262,23 @@ stdenv.mkDerivation ({
inherit noSysDirs staticCompiler langJava
libcCross crossMingw;
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ texinfo which gettext ]
++ (optional (perl != null) perl)
++ (optional javaAwtGtk pkgconfig);
buildInputs = [ gmp mpfr libmpc libelf ]
++ (optional (cloog != null) cloog)
# For building runtime libs
depsBuildTarget =
if hostPlatform == buildPlatform then [
targetPackages.stdenv.cc.bintools # newly-built gcc will be used
] else assert targetPlatform == hostPlatform; [ # build != host == target
stdenv.cc
];
buildInputs = [
gmp mpfr libmpc libelf
targetPackages.stdenv.cc.bintools # For linking code at run-time
] ++ (optional (cloog != null) cloog)
++ (optional (isl != null) isl)
++ (optional (zlib != null) zlib)
++ (optionals langJava [ boehmgc zip unzip ])
@ -296,11 +307,7 @@ stdenv.mkDerivation ({
dontDisableStatic = true;
# TODO(@Ericson2314): Always pass "--target" and always prefix.
configurePlatforms =
# TODO(@Ericson2314): Figure out what's going wrong with Arm
if hostPlatform == targetPlatform && targetPlatform.isArm
then []
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags =
# Basic dependencies
@ -395,57 +402,12 @@ stdenv.mkDerivation ({
/* For cross-built gcc (build != host == target) */
crossAttrs = {
AR_FOR_BUILD = "ar";
AS_FOR_BUILD = "as";
LD_FOR_BUILD = "ld";
NM_FOR_BUILD = "nm";
OBJCOPY_FOR_BUILD = "objcopy";
OBJDUMP_FOR_BUILD = "objdump";
RANLIB_FOR_BUILD = "ranlib";
SIZE_FOR_BUILD = "size";
STRINGS_FOR_BUILD = "strings";
STRIP_FOR_BUILD = "strip";
CC_FOR_BUILD = "gcc";
CXX_FOR_BUILD = "g++";
AR = "${targetPlatform.config}-ar";
AS = "${targetPlatform.config}-as";
LD = "${targetPlatform.config}-ld";
NM = "${targetPlatform.config}-nm";
OBJCOPY = "${targetPlatform.config}-objcopy";
OBJDUMP = "${targetPlatform.config}-objdump";
RANLIB = "${targetPlatform.config}-ranlib";
SIZE = "${targetPlatform.config}-size";
STRINGS = "${targetPlatform.config}-strings";
STRIP = "${targetPlatform.config}-strip";
CC = "${targetPlatform.config}-gcc";
CXX = "${targetPlatform.config}-g++";
AR_FOR_TARGET = "${targetPlatform.config}-ar";
AS_FOR_TARGET = "${targetPlatform.config}-as";
LD_FOR_TARGET = "${targetPlatform.config}-ld";
NM_FOR_TARGET = "${targetPlatform.config}-nm";
OBJCOPY_FOR_TARGET = "${targetPlatform.config}-objcopy";
OBJDUMP_FOR_TARGET = "${targetPlatform.config}-objdump";
RANLIB_FOR_TARGET = "${targetPlatform.config}-ranlib";
SIZE_FOR_TARGET = "${targetPlatform.config}-size";
STRINGS_FOR_TARGET = "${targetPlatform.config}-strings";
STRIP_FOR_TARGET = "${targetPlatform.config}-strip";
CC_FOR_TARGET = "${targetPlatform.config}-gcc";
CXX_FOR_TARGET = "${targetPlatform.config}-g++";
dontStrip = true;
buildFlags = "";
};
NIX_BUILD_BINTOOLS = buildPackages.stdenv.cc.bintools;
NIX_BUILD_CC = buildPackages.stdenv.cc;
# Needed for the cross compilation to work
AR = "ar";
LD = "ld";
# http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc";
${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64";
# Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the
# library headers and binaries, regarless of the language being compiled.

View File

@ -49,9 +49,6 @@ assert libelf != null -> zlib != null;
# Make sure we get GNU sed.
assert hostPlatform.isDarwin -> gnused != null;
# Need c++filt on darwin
assert hostPlatform.isDarwin -> targetPackages.stdenv.cc.bintools or null != null;
# The go frontend is written in c++
assert langGo -> langCC;
@ -277,17 +274,27 @@ stdenv.mkDerivation ({
inherit noSysDirs staticCompiler langJava
libcCross crossMingw;
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ texinfo which gettext ]
++ (optional (perl != null) perl)
++ (optional javaAwtGtk pkgconfig);
buildInputs = [ gmp mpfr libmpc libelf ]
++ (optional (isl != null) isl)
# For building runtime libs
depsBuildTarget =
if hostPlatform == buildPlatform then [
targetPackages.stdenv.cc.bintools # newly-built gcc will be used
] else assert targetPlatform == hostPlatform; [ # build != host == target
stdenv.cc
];
buildInputs = [
gmp mpfr libmpc libelf
targetPackages.stdenv.cc.bintools # For linking code at run-time
] ++ (optional (isl != null) isl)
++ (optional (zlib != null) zlib)
++ (optionals langJava [ boehmgc zip unzip ])
++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
++ (optionals (targetPlatform != hostPlatform) [targetPackages.stdenv.cc.bintools])
++ (optionals (buildPlatform != hostPlatform) [buildPackages.stdenv.cc])
++ (optionals langAda [gnatboot])
++ (optionals langVhdl [gnat])
@ -309,11 +316,7 @@ stdenv.mkDerivation ({
dontDisableStatic = true;
# TODO(@Ericson2314): Always pass "--target" and always prefix.
configurePlatforms =
# TODO(@Ericson2314): Figure out what's going wrong with Arm
if hostPlatform == targetPlatform && targetPlatform.isArm
then []
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags =
# Basic dependencies
@ -404,57 +407,12 @@ stdenv.mkDerivation ({
/* For cross-built gcc (build != host == target) */
crossAttrs = {
AR_FOR_BUILD = "ar";
AS_FOR_BUILD = "as";
LD_FOR_BUILD = "ld";
NM_FOR_BUILD = "nm";
OBJCOPY_FOR_BUILD = "objcopy";
OBJDUMP_FOR_BUILD = "objdump";
RANLIB_FOR_BUILD = "ranlib";
SIZE_FOR_BUILD = "size";
STRINGS_FOR_BUILD = "strings";
STRIP_FOR_BUILD = "strip";
CC_FOR_BUILD = "gcc";
CXX_FOR_BUILD = "g++";
AR = "${targetPlatform.config}-ar";
AS = "${targetPlatform.config}-as";
LD = "${targetPlatform.config}-ld";
NM = "${targetPlatform.config}-nm";
OBJCOPY = "${targetPlatform.config}-objcopy";
OBJDUMP = "${targetPlatform.config}-objdump";
RANLIB = "${targetPlatform.config}-ranlib";
SIZE = "${targetPlatform.config}-size";
STRINGS = "${targetPlatform.config}-strings";
STRIP = "${targetPlatform.config}-strip";
CC = "${targetPlatform.config}-gcc";
CXX = "${targetPlatform.config}-g++";
AR_FOR_TARGET = "${targetPlatform.config}-ar";
AS_FOR_TARGET = "${targetPlatform.config}-as";
LD_FOR_TARGET = "${targetPlatform.config}-ld";
NM_FOR_TARGET = "${targetPlatform.config}-nm";
OBJCOPY_FOR_TARGET = "${targetPlatform.config}-objcopy";
OBJDUMP_FOR_TARGET = "${targetPlatform.config}-objdump";
RANLIB_FOR_TARGET = "${targetPlatform.config}-ranlib";
SIZE_FOR_TARGET = "${targetPlatform.config}-size";
STRINGS_FOR_TARGET = "${targetPlatform.config}-strings";
STRIP_FOR_TARGET = "${targetPlatform.config}-strip";
CC_FOR_TARGET = "${targetPlatform.config}-gcc";
CXX_FOR_TARGET = "${targetPlatform.config}-g++";
dontStrip = true;
buildFlags = "";
};
NIX_BUILD_BINTOOLS = buildPackages.stdenv.cc.bintools;
NIX_BUILD_CC = buildPackages.stdenv.cc;
# Needed for the cross compilation to work
AR = "ar";
LD = "ld";
# http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc";
${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64";
# Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the
# library headers and binaries, regarless of the language being compiled.

View File

@ -49,9 +49,6 @@ assert libelf != null -> zlib != null;
# Make sure we get GNU sed.
assert hostPlatform.isDarwin -> gnused != null;
# Need c++filt on darwin
assert hostPlatform.isDarwin -> targetPackages.stdenv.cc.bintools or null != null;
# The go frontend is written in c++
assert langGo -> langCC;
@ -276,12 +273,23 @@ stdenv.mkDerivation ({
inherit noSysDirs staticCompiler langJava
libcCross crossMingw;
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ texinfo which gettext ]
++ (optional (perl != null) perl)
++ (optional javaAwtGtk pkgconfig);
buildInputs = [ gmp mpfr libmpc libelf ]
++ (optional (isl != null) isl)
# For building runtime libs
depsBuildTarget =
if hostPlatform == buildPlatform then [
targetPackages.stdenv.cc.bintools # newly-built gcc will be used
] else assert targetPlatform == hostPlatform; [ # build != host == target
stdenv.cc
];
buildInputs = [
gmp mpfr libmpc libelf
targetPackages.stdenv.cc.bintools # For linking code at run-time
] ++ (optional (isl != null) isl)
++ (optional (zlib != null) zlib)
++ (optionals langJava [ boehmgc zip unzip ])
++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
@ -311,11 +319,7 @@ stdenv.mkDerivation ({
dontDisableStatic = true;
# TODO(@Ericson2314): Always pass "--target" and always prefix.
configurePlatforms =
# TODO(@Ericson2314): Figure out what's going wrong with Arm
if hostPlatform == targetPlatform && targetPlatform.isArm
then []
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags =
# Basic dependencies
@ -405,57 +409,12 @@ stdenv.mkDerivation ({
/* For cross-built gcc (build != host == target) */
crossAttrs = {
AR_FOR_BUILD = "ar";
AS_FOR_BUILD = "as";
LD_FOR_BUILD = "ld";
NM_FOR_BUILD = "nm";
OBJCOPY_FOR_BUILD = "objcopy";
OBJDUMP_FOR_BUILD = "objdump";
RANLIB_FOR_BUILD = "ranlib";
SIZE_FOR_BUILD = "size";
STRINGS_FOR_BUILD = "strings";
STRIP_FOR_BUILD = "strip";
CC_FOR_BUILD = "gcc";
CXX_FOR_BUILD = "g++";
AR = "${targetPlatform.config}-ar";
AS = "${targetPlatform.config}-as";
LD = "${targetPlatform.config}-ld";
NM = "${targetPlatform.config}-nm";
OBJCOPY = "${targetPlatform.config}-objcopy";
OBJDUMP = "${targetPlatform.config}-objdump";
RANLIB = "${targetPlatform.config}-ranlib";
SIZE = "${targetPlatform.config}-size";
STRINGS = "${targetPlatform.config}-strings";
STRIP = "${targetPlatform.config}-strip";
CC = "${targetPlatform.config}-gcc";
CXX = "${targetPlatform.config}-g++";
AR_FOR_TARGET = "${targetPlatform.config}-ar";
AS_FOR_TARGET = "${targetPlatform.config}-as";
LD_FOR_TARGET = "${targetPlatform.config}-ld";
NM_FOR_TARGET = "${targetPlatform.config}-nm";
OBJCOPY_FOR_TARGET = "${targetPlatform.config}-objcopy";
OBJDUMP_FOR_TARGET = "${targetPlatform.config}-objdump";
RANLIB_FOR_TARGET = "${targetPlatform.config}-ranlib";
SIZE_FOR_TARGET = "${targetPlatform.config}-size";
STRINGS_FOR_TARGET = "${targetPlatform.config}-strings";
STRIP_FOR_TARGET = "${targetPlatform.config}-strip";
CC_FOR_TARGET = "${targetPlatform.config}-gcc";
CXX_FOR_TARGET = "${targetPlatform.config}-g++";
dontStrip = true;
buildFlags = "";
};
NIX_BUILD_BINTOOLS = buildPackages.stdenv.cc.bintools;
NIX_BUILD_CC = buildPackages.stdenv.cc;
# Needed for the cross compilation to work
AR = "ar";
LD = "ld";
# http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc";
${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64";
# Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the
# library headers and binaries, regarless of the language being compiled.

View File

@ -50,9 +50,6 @@ assert libelf != null -> zlib != null;
# Make sure we get GNU sed.
assert hostPlatform.isDarwin -> gnused != null;
# Need c++filt on darwin
assert hostPlatform.isDarwin -> targetPackages.stdenv.cc.bintools or null != null;
# The go frontend is written in c++
assert langGo -> langCC;
@ -273,12 +270,23 @@ stdenv.mkDerivation ({
inherit noSysDirs staticCompiler langJava
libcCross crossMingw;
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ texinfo which gettext ]
++ (optional (perl != null) perl)
++ (optional javaAwtGtk pkgconfig);
buildInputs = [ gmp mpfr libmpc libelf flex ]
++ (optional (isl != null) isl)
# For building runtime libs
depsBuildTarget =
if hostPlatform == buildPlatform then [
targetPackages.stdenv.cc.bintools # newly-built gcc will be used
] else assert targetPlatform == hostPlatform; [ # build != host == target
stdenv.cc
];
buildInputs = [
gmp mpfr libmpc libelf flex
targetPackages.stdenv.cc.bintools # For linking code at run-time
] ++ (optional (isl != null) isl)
++ (optional (zlib != null) zlib)
++ (optionals langJava [ boehmgc zip unzip ])
++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
@ -304,11 +312,7 @@ stdenv.mkDerivation ({
dontDisableStatic = true;
# TODO(@Ericson2314): Always pass "--target" and always prefix.
configurePlatforms =
# TODO(@Ericson2314): Figure out what's going wrong with Arm
if hostPlatform == targetPlatform && targetPlatform.isArm
then []
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags =
# Basic dependencies
@ -399,57 +403,12 @@ stdenv.mkDerivation ({
/* For cross-built gcc (build != host == target) */
crossAttrs = {
AR_FOR_BUILD = "ar";
AS_FOR_BUILD = "as";
LD_FOR_BUILD = "ld";
NM_FOR_BUILD = "nm";
OBJCOPY_FOR_BUILD = "objcopy";
OBJDUMP_FOR_BUILD = "objdump";
RANLIB_FOR_BUILD = "ranlib";
SIZE_FOR_BUILD = "size";
STRINGS_FOR_BUILD = "strings";
STRIP_FOR_BUILD = "strip";
CC_FOR_BUILD = "gcc";
CXX_FOR_BUILD = "g++";
AR = "${targetPlatform.config}-ar";
AS = "${targetPlatform.config}-as";
LD = "${targetPlatform.config}-ld";
NM = "${targetPlatform.config}-nm";
OBJCOPY = "${targetPlatform.config}-objcopy";
OBJDUMP = "${targetPlatform.config}-objdump";
RANLIB = "${targetPlatform.config}-ranlib";
SIZE = "${targetPlatform.config}-size";
STRINGS = "${targetPlatform.config}-strings";
STRIP = "${targetPlatform.config}-strip";
CC = "${targetPlatform.config}-gcc";
CXX = "${targetPlatform.config}-g++";
AR_FOR_TARGET = "${targetPlatform.config}-ar";
AS_FOR_TARGET = "${targetPlatform.config}-as";
LD_FOR_TARGET = "${targetPlatform.config}-ld";
NM_FOR_TARGET = "${targetPlatform.config}-nm";
OBJCOPY_FOR_TARGET = "${targetPlatform.config}-objcopy";
OBJDUMP_FOR_TARGET = "${targetPlatform.config}-objdump";
RANLIB_FOR_TARGET = "${targetPlatform.config}-ranlib";
SIZE_FOR_TARGET = "${targetPlatform.config}-size";
STRINGS_FOR_TARGET = "${targetPlatform.config}-strings";
STRIP_FOR_TARGET = "${targetPlatform.config}-strip";
CC_FOR_TARGET = "${targetPlatform.config}-gcc";
CXX_FOR_TARGET = "${targetPlatform.config}-g++";
dontStrip = true;
buildFlags = "";
};
NIX_BUILD_BINTOOLS = buildPackages.stdenv.cc.bintools;
NIX_BUILD_CC = buildPackages.stdenv.cc;
# Needed for the cross compilation to work
AR = "ar";
LD = "ld";
# http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc";
${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64";
# Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the
# library headers and binaries, regarless of the language being compiled.

View File

@ -50,9 +50,6 @@ assert libelf != null -> zlib != null;
# Make sure we get GNU sed.
assert hostPlatform.isDarwin -> gnused != null;
# Need c++filt on darwin
assert hostPlatform.isDarwin -> targetPackages.stdenv.cc.bintools or null != null;
# The go frontend is written in c++
assert langGo -> langCC;
@ -260,12 +257,23 @@ stdenv.mkDerivation ({
inherit noSysDirs staticCompiler langJava
libcCross crossMingw;
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ texinfo which gettext ]
++ (optional (perl != null) perl)
++ (optional javaAwtGtk pkgconfig);
buildInputs = [ gmp mpfr libmpc libelf flex ]
++ (optional (isl != null) isl)
# For building runtime libs
depsBuildTarget =
if hostPlatform == buildPlatform then [
targetPackages.stdenv.cc.bintools # newly-built gcc will be used
] else assert targetPlatform == hostPlatform; [ # build != host == target
stdenv.cc
];
buildInputs = [
gmp mpfr libmpc libelf flex
targetPackages.stdenv.cc.bintools # For linking code at run-time
] ++ (optional (isl != null) isl)
++ (optional (zlib != null) zlib)
++ (optionals langJava [ boehmgc zip unzip ])
++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
@ -291,11 +299,7 @@ stdenv.mkDerivation ({
dontDisableStatic = true;
# TODO(@Ericson2314): Always pass "--target" and always prefix.
configurePlatforms =
# TODO(@Ericson2314): Figure out what's going wrong with Arm
if hostPlatform == targetPlatform && targetPlatform.isArm
then []
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags =
# Basic dependencies
@ -386,57 +390,12 @@ stdenv.mkDerivation ({
/* For cross-built gcc (build != host == target) */
crossAttrs = {
AR_FOR_BUILD = "ar";
AS_FOR_BUILD = "as";
LD_FOR_BUILD = "ld";
NM_FOR_BUILD = "nm";
OBJCOPY_FOR_BUILD = "objcopy";
OBJDUMP_FOR_BUILD = "objdump";
RANLIB_FOR_BUILD = "ranlib";
SIZE_FOR_BUILD = "size";
STRINGS_FOR_BUILD = "strings";
STRIP_FOR_BUILD = "strip";
CC_FOR_BUILD = "gcc";
CXX_FOR_BUILD = "g++";
AR = "${targetPlatform.config}-ar";
AS = "${targetPlatform.config}-as";
LD = "${targetPlatform.config}-ld";
NM = "${targetPlatform.config}-nm";
OBJCOPY = "${targetPlatform.config}-objcopy";
OBJDUMP = "${targetPlatform.config}-objdump";
RANLIB = "${targetPlatform.config}-ranlib";
SIZE = "${targetPlatform.config}-size";
STRINGS = "${targetPlatform.config}-strings";
STRIP = "${targetPlatform.config}-strip";
CC = "${targetPlatform.config}-gcc";
CXX = "${targetPlatform.config}-g++";
AR_FOR_TARGET = "${targetPlatform.config}-ar";
AS_FOR_TARGET = "${targetPlatform.config}-as";
LD_FOR_TARGET = "${targetPlatform.config}-ld";
NM_FOR_TARGET = "${targetPlatform.config}-nm";
OBJCOPY_FOR_TARGET = "${targetPlatform.config}-objcopy";
OBJDUMP_FOR_TARGET = "${targetPlatform.config}-objdump";
RANLIB_FOR_TARGET = "${targetPlatform.config}-ranlib";
SIZE_FOR_TARGET = "${targetPlatform.config}-size";
STRINGS_FOR_TARGET = "${targetPlatform.config}-strings";
STRIP_FOR_TARGET = "${targetPlatform.config}-strip";
CC_FOR_TARGET = "${targetPlatform.config}-gcc";
CXX_FOR_TARGET = "${targetPlatform.config}-g++";
dontStrip = true;
buildFlags = "";
};
NIX_BUILD_BINTOOLS = buildPackages.stdenv.cc.bintools;
NIX_BUILD_CC = buildPackages.stdenv.cc;
# Needed for the cross compilation to work
AR = "ar";
LD = "ld";
# http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc";
${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64";
# Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the
# library headers and binaries, regarless of the language being compiled.

View File

@ -2,4 +2,4 @@ addToGoPath() {
addToSearchPath GOPATH $1/share/go
}
envHooks=(${envHooks[@]} addToGoPath)
addEnvHooks "$targetOffset" addToGoPath

View File

@ -4,4 +4,4 @@ addHaxeLibPath() {
fi
}
envHooks+=(addHaxeLibPath)
addEnvHooks "$targetOffset" addHaxeLibPath

View File

@ -91,7 +91,7 @@ stdenv.mkDerivation rec {
# Specifying $SBCL_HOME is only truly needed with `purgeNixReferences = true`.
setupHook = writeText "setupHook.sh" ''
envHooks+=(_setSbclHome)
addEnvHooks "$targetOffset" _setSbclHome
_setSbclHome() {
export SBCL_HOME='@out@/lib/sbcl/'
}

View File

@ -222,8 +222,8 @@ stdenv.mkDerivation ({
setupCompileFlags="${concatStringsSep " " setupCompileFlags}"
configureFlags="${concatStringsSep " " defaultConfigureFlags} $configureFlags"
# nativePkgs defined in stdenv/setup.hs
for p in "''${nativePkgs[@]}"; do
# host.*Pkgs defined in stdenv/setup.hs
for p in "''${pkgsHostHost[@]}" "''${pkgsHostTarget[@]}"; do
if [ -d "$p/lib/${ghc.name}/package.conf.d" ]; then
cp -f "$p/lib/${ghc.name}/package.conf.d/"*.conf $packageConfDir/
continue

View File

@ -18,7 +18,8 @@
fi
}
envHooks+=(addIdrisLibs)
# All run-time deps
addEnvHooks 0 addIdrisLibs
'';
buildPhase = ''

View File

@ -14,7 +14,7 @@
fi
}
envHooks+=(installIdrisLib)
envHostTargetHooks+=(installIdrisLib)
'';
unpackPhase = ''

View File

@ -2,4 +2,4 @@ addErlLibPath() {
addToSearchPath ERL_LIBS $1/lib/elixir/lib
}
envHooks+=(addErlLibPath)
addEnvHooks "$hostOffset" addErlLibPath

View File

@ -2,4 +2,4 @@ addErlangLibPath() {
addToSearchPath ERL_LIBS $1/lib/erlang/lib
}
envHooks+=(addErlangLibPath)
addEnvHooks "$hostOffset" addErlangLibPath

View File

@ -10,4 +10,4 @@ addGuileLibPath () {
fi
}
envHooks+=(addGuileLibPath)
addEnvHooks "$hostOffset" addGuileLibPath

View File

@ -10,4 +10,4 @@ addGuileLibPath () {
fi
}
envHooks+=(addGuileLibPath)
addEnvHooks "$hostOffset" addGuileLibPath

View File

@ -5,4 +5,4 @@ addGuileLibPath () {
fi
}
envHooks+=(addGuileLibPath)
addEnvHooks "$hostOffset" addGuileLibPath

View File

@ -36,7 +36,7 @@ jruby = stdenv.mkDerivation rec {
addToSearchPath GEM_PATH \$1/${passthru.gemPath}
}
envHooks+=(addGemPath)
addEnvHooks "$hostOffset" addGemPath
EOF
'';

View File

@ -2,4 +2,4 @@ addPerlLibPath () {
addToSearchPath PERL5LIB $1/lib/perl5/site_perl
}
envHooks+=(addPerlLibPath)
addEnvHooks "$hostOffset" addPerlLibPath

View File

@ -12,7 +12,7 @@ toPythonPath() {
echo $result
}
envHooks+=(addPythonPath)
addEnvHooks "$hostOffset" addPythonPath
# Determinism: The interpreter is patched to write null timestamps when compiling python files.
# This way python doesn't try to update them when we freeze timestamps in nix store.

View File

@ -142,7 +142,7 @@ let
addToSearchPath GEM_PATH \$1/${passthru.gemPath}
}
envHooks+=(addGemPath)
addEnvHooks "$hostOffset" addGemPath
EOF
'' + opString useRailsExpress ''
rbConfig=$(find $out/lib/ruby -name rbconfig.rb)

View File

@ -4,8 +4,4 @@ addSDLPath () {
fi
}
if test -n "$crossConfig"; then
crossEnvHooks+=(addSDLPath)
else
envHooks+=(addSDLPath)
fi
addEnvHooks "$hostOffset" addSDLPath

View File

@ -4,8 +4,4 @@ addSDL2Path () {
fi
}
if test -n "$crossConfig"; then
crossEnvHooks+=(addSDL2Path)
else
envHooks+=(addSDL2Path)
fi
addEnvHooks "$hostOffset" addSDL2Path

View File

@ -14,4 +14,4 @@ findGdkPixbufLoaders() {
}
envHooks+=(findGdkPixbufLoaders)
addEnvHooks "$hostOffset" findGdkPixbufLoaders

View File

@ -5,7 +5,7 @@ make_glib_find_gsettings_schemas() {
addToSearchPath GSETTINGS_SCHEMAS_PATH "$1/share/gsettings-schemas/"*
fi
}
envHooks+=(make_glib_find_gsettings_schemas)
addEnvHooks "$hostOffset" make_glib_find_gsettings_schemas
# Install gschemas, if any, in a package-specific directory
glibPreInstallPhase() {

View File

@ -141,7 +141,7 @@ stdenv.mkDerivation ({
outputs = [ "out" "bin" "dev" "static" ];
nativeBuildInputs = lib.optional (cross != null) buildPackages.stdenv.cc;
depsBuildBuild = [ buildPackages.stdenv.cc ];
buildInputs = lib.optionals withGd [ gd libpng ];
# Needed to install share/zoneinfo/zone.tab. Set to impure /bin/sh to

View File

@ -19,8 +19,8 @@ let self = stdenv.mkDerivation rec {
outputs = [ "out" "dev" "info" ];
passthru.static = self.out;
nativeBuildInputs = [ m4 ]
++ stdenv.lib.optional (buildPlatform != hostPlatform) buildPackages.stdenv.cc;
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ m4 ];
configureFlags =
# Build a "fat binary", with routines for several sub-architectures

View File

@ -11,7 +11,7 @@ make_gobject_introspection_find_gir_files() {
fi
}
envHooks+=(make_gobject_introspection_find_gir_files)
addEnvHooks "$hostOffset" make_gobject_introspection_find_gir_files
_multioutMoveGlibGir() {
moveToOutput share/gir-1.0 "${!outputDev}"

View File

@ -10,8 +10,4 @@ _grantleeEnvHook() {
propagatedUserEnvPkgs+=" $1"
fi
}
if [ "$crossEnv" ]; then
crossEnvHooks+=(_grantleeEnvHook)
else
envHooks+=(_grantleeEnvHook)
fi
addEnvHooks "$hostOffset" _grantleeEnvHook

View File

@ -5,5 +5,5 @@ addGstreamer1LibPath () {
fi
}
envHooks+=(addGstreamer1LibPath)
addEnvHooks "$hostOffset" addGstreamer1LibPath

View File

@ -5,4 +5,4 @@ addGstreamerLibPath () {
fi
}
envHooks+=(addGstreamerLibPath)
addEnvHooks "$hostOffset" addGstreamerLibPath

View File

@ -2,7 +2,7 @@ _ecmEnvHook() {
addToSearchPath XDG_DATA_DIRS "$1/share"
addToSearchPath XDG_CONFIG_DIRS "$1/etc/xdg"
}
envHooks+=(_ecmEnvHook)
addEnvHooks "$targetOffset" _ecmEnvHook
_ecmPreConfigureHook() {
# Because we need to use absolute paths here, we must set *all* the paths.

View File

@ -8,10 +8,18 @@
mkDerivation {
name = "kdoctools";
meta = { maintainers = [ lib.maintainers.ttuegel ]; };
nativeBuildInputs = [ extra-cmake-modules ];
propagatedNativeBuildInputs = [ perl perlPackages.URI ];
nativeBuildInputs = [
extra-cmake-modules
# The build system insists on having native Perl.
perl perlPackages.URI
];
propagatedBuildInputs = [
# kdoctools at runtime actually needs Perl for the platform kdoctools is
# running on, not necessarily native perl.
perl perlPackages.URI
qtbase
];
buildInputs = [ karchive ki18n ];
propagatedBuildInputs = [ qtbase ];
outputs = [ "out" "dev" ];
patches = [ ./kdoctools-no-find-docbook-xml.patch ];
cmakeFlags = [

View File

@ -2,4 +2,4 @@ addXdgData() {
addToSearchPath XDG_DATA_DIRS "$1/share"
}
envHooks+=(addXdgData)
addEnvHooks "$targetOffset" addXdgData

View File

@ -19,7 +19,8 @@ stdenv.mkDerivation rec {
find . ../include/opcode -type f -exec sed {} -i -e 's/"bfd.h"/<bfd.h>/' \;
'';
nativeBuildInputs = [ autoreconfHook264 bison buildPackages.stdenv.cc ];
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ autoreconfHook264 bison ];
buildInputs = [ libiberty ];
# dis-asm.h includes bfd.h
propagatedBuildInputs = [ libbfd ];

View File

@ -2,4 +2,4 @@ addRepDLLoadPath () {
addToSearchPath REP_DL_LOAD_PATH $1/lib/rep
}
envHooks+=(addRepDLLoadPath)
addEnvHooks "$hostOffset" addRepDLLoadPath

View File

@ -37,10 +37,11 @@ stdenv.mkDerivation rec {
# Only the C compiler, and explicitly not C++ compiler needs this flag on solaris:
CFLAGS = lib.optionalString stdenv.isSunOS "-D_XOPEN_SOURCE_EXTENDED";
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [
pkgconfig
] ++ lib.optionals (buildPlatform != hostPlatform) [
buildPackages.ncurses buildPackages.stdenv.cc
buildPackages.ncurses
];
buildInputs = lib.optional (mouseSupport && stdenv.isLinux) gpm;

View File

@ -42,11 +42,7 @@ qtEnvHook() {
propagatedUserEnvPkgs+=" $1"
fi
}
if [ "$crossConfig" ]; then
crossEnvHooks+=(qtEnvHook)
else
envHooks+=(qtEnvHook)
fi
envHostTargetHooks+=(qtEnvHook)
postPatchMkspecs() {
local bin="${!outputBin}"

View File

@ -2,4 +2,4 @@ addRepDLLoadPath () {
addToSearchPath REP_DL_LOAD_PATH $1/lib/rep
}
envHooks+=(addRepDLLoadPath)
addEnvHooks "$hostOffset" addRepDLLoadPath

View File

@ -10,4 +10,4 @@ addSlibPath () {
fi
}
envHooks+=(addSlibPath)
addEnvHooks "$hostOffset" addSlibPath

View File

@ -31,7 +31,7 @@ collectNixLispLDLP () {
export NIX_LISP_COMMAND NIX_LISP CL_SOURCE_REGISTRY NIX_LISP_ASDF
envHooks+=(addASDFPaths setLisp collectNixLispLDLP)
addEnvHooks "$targetOffset" addASDFPaths setLisp collectNixLispLDLP
mkdir -p "$HOME"/.cache/common-lisp || HOME="$TMP/.temp-$USER-home"
mkdir -p "$HOME"/.cache/common-lisp

View File

@ -2,4 +2,4 @@ addOcsigenDistilleryTemplate() {
addToSearchPathWithCustomDelimiter : ELIOM_DISTILLERY_PATH $1/eliom-distillery-templates
}
envHooks+=(addOcsigenDistilleryTemplate)
addEnvHooks "$hostOffset" addOcsigenDistilleryTemplate

View File

@ -2,4 +2,4 @@ addOcamlMakefile () {
export OCAMLMAKEFILE="@out@/include/OCamlMakefile"
}
envHooks+=(addOcamlMakefile)
addEnvHooks "$targetOffset" addOcamlMakefile

View File

@ -72,11 +72,7 @@ if [ -z "$dontUseCmakeConfigure" -a -z "$configurePhase" ]; then
configurePhase=cmakeConfigurePhase
fi
if [ -n "$crossConfig" ]; then
crossEnvHooks+=(addCMakeParams)
else
envHooks+=(addCMakeParams)
fi
addEnvHooks "$targetOffset" addCMakeParams
makeCmakeFindLibs(){
isystem_seen=

View File

@ -2,4 +2,4 @@ addAclocals () {
addToSearchPathWithCustomDelimiter : ACLOCAL_PATH $1/share/aclocal
}
envHooks+=(addAclocals)
addEnvHooks "$hostOffset" addAclocals

View File

@ -65,7 +65,8 @@ stdenv.mkDerivation rec {
outputs = [ "out" "info" "man" ];
nativeBuildInputs = [ bison buildPackages.stdenv.cc ];
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ bison ];
buildInputs = [ zlib ];
inherit noSysDirs;
@ -90,11 +91,7 @@ stdenv.mkDerivation rec {
else "-static-libgcc";
# TODO(@Ericson2314): Always pass "--target" and always targetPrefix.
configurePlatforms =
# TODO(@Ericson2314): Figure out what's going wrong with Arm
if hostPlatform == targetPlatform && targetPlatform.isArm
then []
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags = [
"--enable-targets=all" "--enable-64-bit-bfd"

View File

@ -3,8 +3,4 @@ addPkgConfigPath () {
addToSearchPath PKG_CONFIG_PATH $1/share/pkgconfig
}
if test -n "$crossConfig"; then
crossEnvHooks+=(addPkgConfigPath)
else
envHooks+=(addPkgConfigPath)
fi
addEnvHooks "$targetOffset" addPkgConfigPath

View File

@ -40,7 +40,7 @@ stdenv.mkDerivation rec {
fi
}
envHooks+=(addOCamlPath)
addEnvHooks "$targetOffset" addOCamlPath
'';
meta = {

View File

@ -2,4 +2,4 @@ addNodePath () {
addToSearchPath NODE_PATH $1/lib/node_modules
}
envHooks+=(addNodePath)
addEnvHooks "$hostOffset" addNodePath

View File

@ -39,4 +39,4 @@ useSystemCoreFoundationFramework () {
export NIX_COREFOUNDATION_RPATH=/System/Library/Frameworks
}
envHooks+=(useSystemCoreFoundationFramework)
addEnvHooks "$hostOffset" useSystemCoreFoundationFramework

View File

@ -7,4 +7,4 @@ noDeprecatedDeclarations() {
fi
}
envHooks+=(noDeprecatedDeclarations)
addEnvHooks "$hostOffset" noDeprecatedDeclarations

View File

@ -95,7 +95,7 @@ stdenv.mkDerivation rec {
makeFlagsArray+=("CC=${stdenv.cc.targetPrefix}gcc -isystem ${musl}/include -B${musl}/lib -L${musl}/lib")
'';
nativeBuildInputs = lib.optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc;
depsBuildBuild = [ buildPackages.stdenv.cc ];
buildInputs = lib.optionals (enableStatic && !useMusl) [ stdenv.cc.libc stdenv.cc.libc.static ];

View File

@ -24,7 +24,8 @@ stdenvNoCC.mkDerivation {
# It may look odd that we use `stdenvNoCC`, and yet explicit depend on a cc.
# We do this so we have a build->build, not build->host, C compiler.
nativeBuildInputs = [ buildPackages.stdenv.cc perl ];
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ perl ];
extraIncludeDirs = lib.optional hostPlatform.isPowerPC ["ppc"];

View File

@ -16,13 +16,8 @@ postInstall() {
echo "propagating requisites $requires"
if test -n "$crossConfig"; then
local pkgs=("${crossPkgs[@]}")
else
local pkgs=("${nativePkgs[@]}")
fi
for r in $requires; do
for p in "${pkgs[@]}"; do
for p in "${pkgsHostHost[@]}" "${pkgsHostTarget[@]}"; do
if test -e $p/lib/pkgconfig/$r.pc; then
echo " found requisite $r in $p"
propagatedBuildInputs+=" $p"

View File

@ -68,10 +68,10 @@ stdenv.mkDerivation rec {
];
# Note: Bison is needed because the patches above modify parse.y.
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [bison]
++ optional (texinfo != null) texinfo
++ optional hostPlatform.isDarwin binutils
++ optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc;
++ optional hostPlatform.isDarwin binutils;
buildInputs = optional interactive readline70;

View File

@ -14,11 +14,27 @@ rec {
mkDerivation =
{ name ? ""
, nativeBuildInputs ? []
, buildInputs ? []
# These types of dependencies are all exhaustively documented in
# the "Specifying Dependencies" section of the "Standard
# Environment" chapter of the Nixpkgs manual.
, propagatedNativeBuildInputs ? []
, propagatedBuildInputs ? []
# TODO(@Ericson2314): Stop using legacy dep attribute names
# host offset -> target offset
, depsBuildBuild ? [] # -1 -> -1
, depsBuildBuildPropagated ? [] # -1 -> -1
, nativeBuildInputs ? [] # -1 -> 0 N.B. Legacy name
, propagatedNativeBuildInputs ? [] # -1 -> 0 N.B. Legacy name
, depsBuildTarget ? [] # -1 -> 1
, depsBuildTargetPropagated ? [] # -1 -> 1
, depsHostHost ? [] # 0 -> 0
, depsHostHostPropagated ? [] # 0 -> 0
, buildInputs ? [] # 0 -> 1 N.B. Legacy name
, propagatedBuildInputs ? [] # 0 -> 1 N.B. Legacy name
, depsTargetTarget ? [] # 1 -> 1
, depsTargetTargetPropagated ? [] # 1 -> 1
, configureFlags ? []
, # Target is not included by default because most programs don't care.
@ -56,15 +72,35 @@ rec {
inherit erroneousHardeningFlags hardeningDisable hardeningEnable supportedHardeningFlags;
})
else let
dependencies = map lib.chooseDevOutputs [
(map (drv: drv.nativeDrv or drv) nativeBuildInputs
++ lib.optional separateDebugInfo ../../build-support/setup-hooks/separate-debug-info.sh
++ lib.optional stdenv.hostPlatform.isWindows ../../build-support/setup-hooks/win-dll-link.sh)
(map (drv: drv.crossDrv or drv) buildInputs)
dependencies = map (map lib.chooseDevOutputs) [
[
(map (drv: drv.__spliced.buildBuild or drv) depsBuildBuild)
(map (drv: drv.nativeDrv or drv) nativeBuildInputs
++ lib.optional separateDebugInfo ../../build-support/setup-hooks/separate-debug-info.sh
++ lib.optional stdenv.hostPlatform.isWindows ../../build-support/setup-hooks/win-dll-link.sh)
(map (drv: drv.__spliced.buildTarget or drv) depsBuildTarget)
]
[
(map (drv: drv.__spliced.hostHost or drv) depsHostHost)
(map (drv: drv.crossDrv or drv) buildInputs)
]
[
(map (drv: drv.__spliced.targetTarget or drv) depsTargetTarget)
]
];
propagatedDependencies = map lib.chooseDevOutputs [
(map (drv: drv.nativeDrv or drv) propagatedNativeBuildInputs)
(map (drv: drv.crossDrv or drv) propagatedBuildInputs)
propagatedDependencies = map (map lib.chooseDevOutputs) [
[
(map (drv: drv.__spliced.buildBuild or drv) depsBuildBuildPropagated)
(map (drv: drv.nativeDrv or drv) propagatedNativeBuildInputs)
(map (drv: drv.__spliced.buildTarget or drv) depsBuildTargetPropagated)
]
[
(map (drv: drv.__spliced.hostHost or drv) depsHostHostPropagated)
(map (drv: drv.crossDrv or drv) propagatedBuildInputs)
]
[
(map (drv: drv.__spliced.targetTarget or drv) depsTargetTargetPropagated)
]
];
outputs' =
@ -105,11 +141,19 @@ rec {
userHook = config.stdenv.userHook or null;
__ignoreNulls = true;
nativeBuildInputs = lib.elemAt dependencies 0;
buildInputs = lib.elemAt dependencies 1;
depsBuildBuild = lib.elemAt (lib.elemAt dependencies 0) 0;
nativeBuildInputs = lib.elemAt (lib.elemAt dependencies 0) 1;
depsBuildTarget = lib.elemAt (lib.elemAt dependencies 0) 2;
depsHostBuild = lib.elemAt (lib.elemAt dependencies 1) 0;
buildInputs = lib.elemAt (lib.elemAt dependencies 1) 1;
depsTargetTarget = lib.elemAt (lib.elemAt dependencies 2) 0;
propagatedNativeBuildInputs = lib.elemAt propagatedDependencies 0;
propagatedBuildInputs = lib.elemAt propagatedDependencies 1;
depsBuildBuildPropagated = lib.elemAt (lib.elemAt propagatedDependencies 0) 0;
propagatedNativeBuildInputs = lib.elemAt (lib.elemAt propagatedDependencies 0) 1;
depsBuildTargetPropagated = lib.elemAt (lib.elemAt propagatedDependencies 0) 2;
depsHostBuildPropagated = lib.elemAt (lib.elemAt propagatedDependencies 1) 0;
propagatedBuildInputs = lib.elemAt (lib.elemAt propagatedDependencies 1) 1;
depsTargetTargetPropagated = lib.elemAt (lib.elemAt propagatedDependencies 2) 0;
# This parameter is sometimes a string, sometimes null, and sometimes a list, yuck
configureFlags = let inherit (lib) optional elem; in

View File

@ -300,11 +300,83 @@ runHook preHook
runHook addInputsHook
# Recursively find all build inputs.
# Package accumulators
# shellcheck disable=SC2034
declare -a pkgsBuildBuild pkgsBuildHost pkgsBuildTarget
declare -a pkgsHostHost pkgsHostTarget
declare -a pkgsTargetTarget
declare -ra pkgBuildAccumVars=(pkgsBuildBuild pkgsBuildHost pkgsBuildTarget)
declare -ra pkgHostAccumVars=(pkgsHostHost pkgsHostTarget)
declare -ra pkgTargetAccumVars=(pkgsTargetTarget)
declare -ra pkgAccumVarVars=(pkgBuildAccumVars pkgHostAccumVars pkgTargetAccumVars)
# Hooks
declare -a envBuildBuildHooks envBuildHostHooks envBuildTargetHooks
declare -a envHostHostHooks envHostTargetHooks
declare -a envTargetTargetHooks
declare -ra pkgBuildHookVars=(envBuildBuildHook envBuildHostHook envBuildTargetHook)
declare -ra pkgHostHookVars=(envHostHostHook envHostTargetHook)
declare -ra pkgTargetHookVars=(envTargetTargetHook)
declare -ra pkgHookVarVars=(pkgBuildHookVars pkgHostHookVars pkgTargetHookVars)
# Add env hooks for all sorts of deps with the specified host offset.
addEnvHooks() {
local depHostOffset="$1"
shift
local pkgHookVarsSlice="${pkgHookVarVars[$depHostOffset + 1]}[@]"
local pkgHookVar
for pkgHookVar in "${!pkgHookVarsSlice}"; do
eval "${pkgHookVar}s"'+=("$@")'
done
}
# Propagated dep files
declare -ra propagatedBuildDepFiles=(
propagated-build-build-deps
propagated-native-build-inputs # Legacy name for back-compat
propagated-build-target-deps
)
declare -ra propagatedHostDepFiles=(
propagated-host-host-deps
propagated-build-inputs # Legacy name for back-compat
)
declare -ra propagatedTargetDepFiles=(
propagated-target-target-deps
)
declare -ra propagatedDepFilesVars=(
propagatedBuildDepFiles
propagatedHostDepFiles
propagatedTargetDepFiles
)
# Platform offsets: build = -1, host = 0, target = 1
declare -ra allPlatOffsets=(-1 0 1)
# Mutually-recursively find all build inputs. See the dependency section of the
# stdenv chapter of the Nixpkgs manual for the specification this algorithm
# implements.
findInputs() {
local pkg="$1"; shift
local var="$1"; shift
local propagatedBuildInputsFiles=("$@")
local -r pkg="$1"
local -ri hostOffset="$2"
local -ri targetOffset="$3"
# Sanity check
(( "$hostOffset" <= "$targetOffset" )) || exit -1
local varVar="${pkgAccumVarVars[$hostOffset + 1]}"
local varRef="$varVar[\$targetOffset - \$hostOffset]"
local var="${!varRef}"
unset -v varVar varRef
# TODO(@Ericson2314): Restore using associative array once Darwin
# nix-shell doesn't use impure bash. This should replace the O(n)
@ -324,21 +396,106 @@ findInputs() {
exit 1
fi
local file
for file in "${propagatedBuildInputsFiles[@]}"; do
file="$pkg/nix-support/$file"
[[ -f "$file" ]] || continue
# The current package's host and target offset together
# provide a <=-preserving homomorphism from the relative
# offsets to current offset
function mapOffset() {
local -ri inputOffset="$1"
if (( "$inputOffset" <= 0 )); then
local -ri outputOffset="$inputOffset + $hostOffset"
else
local -ri outputOffset="$inputOffset - 1 + $targetOffset"
fi
echo "$outputOffset"
}
local pkgNext
for pkgNext in $(< "$file"); do
findInputs "$pkgNext" "$var" "${propagatedBuildInputsFiles[@]}"
# Host offset relative to that of the package whose immediate
# dependencies we are currently exploring.
local -i relHostOffset
for relHostOffset in "${allPlatOffsets[@]}"; do
# `+ 1` so we start at 0 for valid index
local files="${propagatedDepFilesVars[$relHostOffset + 1]}"
# Host offset relative to the package currently being
# built---as absolute an offset as will be used.
local -i hostOffsetNext
hostOffsetNext="$(mapOffset relHostOffset)"
# Ensure we're in bounds relative to the package currently
# being built.
[[ "${allPlatOffsets[*]}" = *"$hostOffsetNext"* ]] || continue
# Target offset relative to the *host* offset of the package
# whose immediate dependencies we are currently exploring.
local -i relTargetOffset
for relTargetOffset in "${allPlatOffsets[@]}"; do
(( "$relHostOffset" <= "$relTargetOffset" )) || continue
local fileRef="${files}[$relTargetOffset - $relHostOffset]"
local file="${!fileRef}"
unset -v fileRef
# Target offset relative to the package currently being
# built.
local -i targetOffsetNext
targetOffsetNext="$(mapOffset relTargetOffset)"
# Once again, ensure we're in bounds relative to the
# package currently being built.
[[ "${allPlatOffsets[*]}" = *"$targetOffsetNext"* ]] || continue
[[ -f "$pkg/nix-support/$file" ]] || continue
local pkgNext
for pkgNext in $(< "$pkg/nix-support/$file"); do
findInputs "$pkgNext" "$hostOffsetNext" "$targetOffsetNext"
done
done
done
}
# Make sure all are at least defined as empty
: ${depsBuildBuild=} ${depsBuildBuildPropagated=}
: ${nativeBuildInputs=} ${propagatedNativeBuildInputs=} ${defaultNativeBuildInputs=}
: ${depsBuildTarget=} ${depsBuildTargetPropagated=}
: ${depsHostHost=} ${depsHostHostPropagated=}
: ${buildInputs=} ${propagatedBuildInputs=} ${defaultBuildInputs=}
: ${depsTargetTarget=} ${depsTargetTargetPropagated=}
for pkg in $depsBuildBuild $depsBuildBuildPropagated; do
findInputs "$pkg" -1 -1
done
for pkg in $nativeBuildInputs $propagatedNativeBuildInputs; do
findInputs "$pkg" -1 0
done
for pkg in $depsBuildTarget $depsBuildTargetPropagated; do
findInputs "$pkg" -1 1
done
for pkg in $depsHostHost $depsHostHostPropagated; do
findInputs "$pkg" 0 0
done
for pkg in $buildInputs $propagatedBuildInputs ; do
findInputs "$pkg" 0 1
done
for pkg in $depsTargetTarget $depsTargetTargetPropagated; do
findInputs "$pkg" 1 1
done
# Default inputs must be processed last
for pkg in $defaultNativeBuildInputs; do
findInputs "$pkg" -1 0
done
for pkg in $defaultBuildInputs; do
findInputs "$pkg" 0 1
done
# Add package to the future PATH and run setup hooks
activatePackage() {
local pkg="$1"
local -ri hostOffset="$2"
local -ri targetOffset="$3"
# Sanity check
(( "$hostOffset" <= "$targetOffset" )) || exit -1
if [ -f "$pkg" ]; then
local oldOpts="$(shopt -po nounset)"
@ -347,11 +504,18 @@ activatePackage() {
eval "$oldOpts"
fi
if [ -d "$pkg/bin" ]; then
# Only dependencies whose host platform is guaranteed to match the
# build platform are included here. That would be `depsBuild*`,
# and legacy `nativeBuildInputs`, in general. If we aren't cross
# compiling, however, everything can be put on the PATH. To ease
# the transition, we do include everything in thatcase.
#
# TODO(@Ericson2314): Don't special-case native compilation
if [[ ( -z "${crossConfig-}" || "$hostOffset" -le -1 ) && -d "$pkg/bin" ]]; then
addToSearchPath _PATH "$pkg/bin"
fi
if [ -f "$pkg/nix-support/setup-hook" ]; then
if [[ -f "$pkg/nix-support/setup-hook" ]]; then
local oldOpts="$(shopt -po nounset)"
set +u
source "$pkg/nix-support/setup-hook"
@ -359,67 +523,72 @@ activatePackage() {
fi
}
declare -a nativePkgs crossPkgs
if [ -z "${crossConfig:-}" ]; then
# Not cross-compiling - both buildInputs (and variants like propagatedBuildInputs)
# are handled identically to nativeBuildInputs
for i in ${nativeBuildInputs:-} ${buildInputs:-} \
${defaultNativeBuildInputs:-} ${defaultBuildInputs:-} \
${propagatedNativeBuildInputs:-} ${propagatedBuildInputs:-}; do
findInputs "$i" nativePkgs propagated-native-build-inputs propagated-build-inputs
done
else
for i in ${nativeBuildInputs:-} ${defaultNativeBuildInputs:-} ${propagatedNativeBuildInputs:-}; do
findInputs "$i" nativePkgs propagated-native-build-inputs
done
for i in ${buildInputs:-} ${defaultBuildInputs:-} ${propagatedBuildInputs:-}; do
findInputs "$i" crossPkgs propagated-build-inputs
done
fi
_activatePkgs() {
local -i hostOffset targetOffset
local pkg
for i in ${nativePkgs+"${nativePkgs[@]}"} ${crossPkgs+"${crossPkgs[@]}"}; do
activatePackage "$i"
done
for hostOffset in "${allPlatOffsets[@]}"; do
local pkgsVar="${pkgAccumVarVars[$hostOffset + 1]}"
for targetOffset in "${allPlatOffsets[@]}"; do
(( "$hostOffset" <= "$targetOffset" )) || continue
local pkgsRef="${pkgsVar}[$targetOffset - $hostOffset]"
local pkgsSlice="${!pkgsRef}[@]"
for pkg in ${!pkgsSlice+"${!pkgsSlice}"}; do
activatePackage "$pkg" "$hostOffset" "$targetOffset"
done
done
done
}
# Run the package setup hooks and build _PATH
_activatePkgs
# Set the relevant environment variables to point to the build inputs
# found above.
#
# These `depOffset`s tell the env hook what sort of dependency
# (ignoring propagatedness) is being passed to the env hook. In a real
# language, we'd append a closure with this information to the
# relevant env hook array, but bash doesn't have closures, so it's
# easier to just pass this in.
# These `depOffset`s, beyond indexing the arrays, also tell the env
# hook what sort of dependency (ignoring propagatedness) is being
# passed to the env hook. In a real language, we'd append a closure
# with this information to the relevant env hook array, but bash
# doesn't have closures, so it's easier to just pass this in.
_addToEnv() {
local -i depHostOffset depTargetOffset
local pkg
_addToNativeEnv() {
local pkg="$1"
if [[ -n "${crossConfig:-}" ]]; then
local -i depOffset=-1
else
local -i depOffset=0
fi
# Run the package-specific hooks set by the setup-hook scripts.
runHook envHook "$pkg"
for depHostOffset in "${allPlatOffsets[@]}"; do
local hookVar="${pkgHookVarVars[$depHostOffset + 1]}"
local pkgsVar="${pkgAccumVarVars[$depHostOffset + 1]}"
for depTargetOffset in "${allPlatOffsets[@]}"; do
(( "$depHostOffset" <= "$depTargetOffset" )) || continue
local hookRef="${hookVar}[$depTargetOffset - $depHostOffset]"
if [[ -z "${crossConfig-}" ]]; then
# Apply environment hooks to all packages during native
# compilation to ease the transition.
#
# TODO(@Ericson2314): Don't special-case native compilation
for pkg in \
${pkgsBuildBuild+"${pkgsBuildBuild[@]}"} \
${pkgsBuildHost+"${pkgsBuildHost[@]}"} \
${pkgsBuildTarget+"${pkgsBuildTarget[@]}"} \
${pkgsHostHost+"${pkgsHostHost[@]}"} \
${pkgsHostTarget+"${pkgsHostTarget[@]}"} \
${pkgsTargetTarget+"${pkgsTargetTarget[@]}"}
do
runHook "${!hookRef}" "$pkg"
done
else
local pkgsRef="${pkgsVar}[$depTargetOffset - $depHostOffset]"
local pkgsSlice="${!pkgsRef}[@]"
for pkg in ${!pkgsSlice+"${!pkgsSlice}"}; do
runHook "${!hookRef}" "$pkg"
done
fi
done
done
}
# Old bash empty array hack
for i in ${nativePkgs+"${nativePkgs[@]}"}; do
_addToNativeEnv "$i"
done
_addToCrossEnv() {
local pkg="$1"
local -i depOffset=0
# Run the package-specific hooks set by the setup-hook scripts.
runHook crossEnvHook "$pkg"
}
# Old bash empty array hack
for i in ${crossPkgs+"${crossPkgs[@]}"}; do
_addToCrossEnv "$i"
done
# Run the package-specific hooks set by the setup-hook scripts.
_addToEnv
_addRpathPrefix "$out"
@ -882,6 +1051,7 @@ installPhase() {
# propagated-build-inputs.
fixupPhase() {
# Make sure everything is writable so "strip" et al. work.
local output
for output in $outputs; do
if [ -e "${!output}" ]; then chmod -R u+w "${!output}"; fi
done
@ -895,19 +1065,35 @@ fixupPhase() {
done
# Propagate build inputs and setup hook into the development output.
# Propagate dependencies & setup hook into the development output.
declare -ra flatVars=(
# Build
depsBuildBuildPropagated
propagatedNativeBuildInputs
depsBuildTargetPropagated
# Host
depsHostHostPropagated
propagatedBuildInputs
# Target
depsTargetTargetPropagated
)
declare -ra flatFiles=(
"${propagatedBuildDepFiles[@]}"
"${propagatedHostDepFiles[@]}"
"${propagatedTargetDepFiles[@]}"
)
local propagatedInputsIndex
for propagatedInputsIndex in "${!flatVars[@]}"; do
local propagatedInputsSlice="${flatVars[$propagatedInputsIndex]}[@]"
local propagatedInputsFile="${flatFiles[$propagatedInputsIndex]}"
[[ "${!propagatedInputsSlice}" ]] || continue
if [ -n "${propagatedBuildInputs:-}" ]; then
mkdir -p "${!outputDev}/nix-support"
# shellcheck disable=SC2086
printWords $propagatedBuildInputs > "${!outputDev}/nix-support/propagated-build-inputs"
fi
if [ -n "${propagatedNativeBuildInputs:-}" ]; then
mkdir -p "${!outputDev}/nix-support"
# shellcheck disable=SC2086
printWords $propagatedNativeBuildInputs > "${!outputDev}/nix-support/propagated-native-build-inputs"
fi
printWords ${!propagatedInputsSlice} > "${!outputDev}/nix-support/$propagatedInputsFile"
done
if [ -n "${setupHook:-}" ]; then

View File

@ -193,6 +193,7 @@ rec {
nuke-refs $out/bin/*
nuke-refs $out/lib/*
nuke-refs $out/libexec/gcc/*/*/*
nuke-refs $out/lib/gcc/*/*/*
mkdir $out/.pack
mv $out/* $out/.pack

View File

@ -18,5 +18,5 @@ if test -z "$sgmlHookDone"; then
export ftp_proxy=http://nodtd.invalid/
export SGML_CATALOG_FILES
envHooks+=(addSGMLCatalogs)
addEnvHooks "$targetOffset" addSGMLCatalogs
fi

View File

@ -4,4 +4,4 @@ addTeXMFPath () {
fi
}
envHooks+=(addTeXMFPath)
addEnvHooks "$targetOffset" addTeXMFPath

View File

@ -4,4 +4,4 @@ addTeXMFPath () {
fi
}
envHooks+=(addTeXMFPath)
addEnvHooks "$targetOffset" addTeXMFPath

View File

@ -24,25 +24,52 @@
lib: pkgs: actuallySplice:
let
defaultBuildScope = pkgs.buildPackages // pkgs.buildPackages.xorg;
defaultBuildBuildScope = pkgs.buildPackages.buildPackages // pkgs.buildPackages.buildPackages.xorg;
defaultBuildHostScope = pkgs.buildPackages // pkgs.buildPackages.xorg;
defaultBuildTargetScope =
if pkgs.targetPlatform == pkgs.hostPlatform
then defaultBuildHostScope
else assert pkgs.hostPlatform == pkgs.buildPlatform; defaultHostTargetScope;
defaultHostHostScope = {}; # unimplemented
# TODO(@Ericson2314): we shouldn't preclude run-time fetching by removing
# these attributes. We should have a more general solution for selecting
# whether `nativeDrv` or `crossDrv` is the default in `defaultScope`.
pkgsWithoutFetchers = lib.filterAttrs (n: _: !lib.hasPrefix "fetch" n) pkgs;
defaultRunScope = pkgsWithoutFetchers // pkgs.xorg;
targetPkgsWithoutFetchers = lib.filterAttrs (n: _: !lib.hasPrefix "fetch" n) pkgs.targetPackages;
defaultHostTargetScope = pkgsWithoutFetchers // pkgs.xorg;
defaultTargetTargetScope = targetPkgsWithoutFetchers // targetPkgsWithoutFetchers.xorg or {};
splicer = buildPkgs: runPkgs: let
mash = buildPkgs // runPkgs;
splicer = pkgsBuildBuild: pkgsBuildHost: pkgsBuildTarget:
pkgsHostHost: pkgsHostTarget:
pkgsTargetTarget: let
mash =
# Other pkgs sets
pkgsBuildBuild // pkgsBuildTarget // pkgsHostHost // pkgsTargetTarget
# The same pkgs sets one probably intends
// pkgsBuildHost // pkgsHostTarget;
merge = name: {
inherit name;
value = let
defaultValue = mash.${name};
# `or {}` is for the non-derivation attsert splicing case, where `{}` is the identity.
buildValue = buildPkgs.${name} or {};
runValue = runPkgs.${name} or {};
valueBuildBuild = pkgsBuildBuild.${name} or {};
valueBuildHost = pkgsBuildHost.${name} or {};
valueBuildTarget = pkgsBuildTarget.${name} or {};
valueHostHost = throw "`valueHostHost` unimplemented: pass manually rather than relying on splicer.";
valueHostTarget = pkgsHostTarget.${name} or {};
valueTargetTarget = pkgsTargetTarget.${name} or {};
augmentedValue = defaultValue
// (lib.optionalAttrs (buildPkgs ? ${name}) { nativeDrv = buildValue; })
// (lib.optionalAttrs (runPkgs ? ${name}) { crossDrv = runValue; });
# TODO(@Ericson2314): Stop using old names after transition period
// (lib.optionalAttrs (pkgsBuildHost ? ${name}) { nativeDrv = valueBuildHost; })
// (lib.optionalAttrs (pkgsHostTarget ? ${name}) { crossDrv = valueHostTarget; })
// {
__spliced =
(lib.optionalAttrs (pkgsBuildBuild ? ${name}) { buildBuild = valueBuildBuild; })
// (lib.optionalAttrs (pkgsBuildTarget ? ${name}) { buildTarget = valueBuildTarget; })
// { hostHost = valueHostHost; }
// (lib.optionalAttrs (pkgsTargetTarget ? ${name}) { targetTarget = valueTargetTarget;
});
};
# Get the set of outputs of a derivation. If one derivation fails to
# evaluate we don't want to diverge the entire splice, so we fall back
# on {}
@ -55,10 +82,15 @@ let
in
# The derivation along with its outputs, which we recur
# on to splice them together.
if lib.isDerivation defaultValue then augmentedValue
// splicer (tryGetOutputs buildValue) (getOutputs runValue)
if lib.isDerivation defaultValue then augmentedValue // splicer
(tryGetOutputs valueBuildBuild) (tryGetOutputs valueBuildHost) (tryGetOutputs valueBuildTarget)
(tryGetOutputs valueHostHost) (getOutputs valueHostTarget)
(tryGetOutputs valueTargetTarget)
# Just recur on plain attrsets
else if lib.isAttrs defaultValue then splicer buildValue runValue
else if lib.isAttrs defaultValue then splicer
valueBuildBuild valueBuildHost valueBuildTarget
{} valueHostTarget
valueTargetTarget
# Don't be fancy about non-derivations. But we could have used used
# `__functor__` for functions instead.
else defaultValue;
@ -67,11 +99,16 @@ let
splicedPackages =
if actuallySplice
then splicer defaultBuildScope defaultRunScope // {
# These should never be spliced under any circumstances
inherit (pkgs) pkgs buildPackages targetPackages
buildPlatform targetPlatform hostPlatform;
}
then
splicer
defaultBuildBuildScope defaultBuildHostScope defaultBuildTargetScope
defaultHostHostScope defaultHostTargetScope
defaultTargetTargetScope
// {
# These should never be spliced under any circumstances
inherit (pkgs) pkgs buildPackages targetPackages
buildPlatform targetPlatform hostPlatform;
}
else pkgs // pkgs.xorg;
in