git.iko.soy/typeable/nixpkgs
on master help sign in
top-level: Make stdenvCross which appears at first glance normal...

...but actually is weird just like the original

commite22346c35ee8cb872d0587320083ba44230bd44b authorJohn Ericson <Ericson2314@Yahoo.com> dateSun 6 Nov 2016, 21:27 (10 years ago) parenteed34bd
4 files changed+52−22
pkgs/stdenv/cross/default.nix+27 pkgs/stdenv/default.nix+5−2 pkgs/top-level/default.nix+6−1 pkgs/top-level/stdenv.nix+14−19
pkgs/stdenv/cross/default.nixnew file+27
@@ -0,0 +1,27 @@
1+{ system, allPackages, platform, crossSystem, config, ... } @ args:
2+
3+rec {
4+ vanillaStdenv = (import ../. (args // {
5+ crossSystem = null;
6+ allPackages = args: allPackages ({ crossSystem = null; } // args);
7+ })).stdenv;
8+
9+ # Yeah this isn't so cleanly just build-time packages yet. Notice the
10+ # buildPackages <-> stdenvCross cycle. Yup, it's very weird.
11+ #
12+ # This works because the derivation used to build `stdenvCross` are in
13+ # fact using `forceNativeDrv` to use the `nativeDrv` attribute of the resulting
14+ # derivation built with `vanillaStdenv` (second argument of `makeStdenvCross`).
15+ #
16+ # Eventually, `forceNativeDrv` should be removed and the cycle broken.
17+ buildPackages = allPackages {
18+ # It's OK to change the built-time dependencies
19+ allowCustomOverrides = true;
20+ bootStdenv = stdenvCross;
21+ inherit system platform crossSystem config;
22+ };
23+
24+ stdenvCross = buildPackages.makeStdenvCross
25+ vanillaStdenv crossSystem
26+ buildPackages.binutilsCross buildPackages.gccCrossStageFinal;
27+}
pkgs/stdenv/default.nix+5−2
@@ -5,7 +5,7 @@
55# Posix utilities, the GNU C compiler, and so on. On other systems,
66# we use the native C library.
77
8−{ system, allPackages ? import ../.., platform, config, lib }:
8+{ system, allPackages ? import ../.., platform, config, crossSystem, lib }:
99
1010
1111rec {
@@ -36,10 +36,13 @@ rec {
3636 # Linux standard environment.
3737 inherit (import ./linux { inherit system allPackages platform config lib; }) stdenvLinux;
3838
39− inherit (import ./darwin { inherit system allPackages platform config;}) stdenvDarwin;
39+ inherit (import ./darwin { inherit system allPackages platform config; }) stdenvDarwin;
40+
41+ inherit (import ./cross { inherit system allPackages platform crossSystem config lib; }) stdenvCross;
4042
4143 # Select the appropriate stdenv for the platform `system'.
4244 stdenv =
45+ if crossSystem != null then stdenvCross else
4346 if system == "i686-linux" then stdenvLinux else
4447 if system == "x86_64-linux" then stdenvLinux else
4548 if system == "armv5tel-linux" then stdenvLinux else
pkgs/top-level/default.nix+6−1
@@ -12,6 +12,11 @@
1212 # null, the default standard environment is used.
1313 bootStdenv ? null
1414
15+, # This is used because stdenv replacement and the stdenvCross do benefit from
16+ # the overridden configuration provided by the user, as opposed to the normal
17+ # bootstrapping stdenvs.
18+ allowCustomOverrides ? (bootStdenv == null)
19+
1520, # Non-GNU/Linux OSes are currently "impure" platforms, with their libc
1621 # outside of the store. Thus, GCC, GFortran, & co. must always look for
1722 # files in standard system directories (/usr/include, etc.)
@@ -109,7 +114,7 @@ let
109114 # attributes to refer to the original attributes (e.g. "foo =
110115 # ... pkgs.foo ...").
111116 configOverrides = self: super:
112− lib.optionalAttrs (bootStdenv == null)
117+ lib.optionalAttrs allowCustomOverrides
113118 ((config.packageOverrides or (super: {})) super);
114119
115120 # The complete chain of package set builders, applied from top to bottom
pkgs/top-level/stdenv.nix+14−19
@@ -2,28 +2,23 @@
22
33rec {
44 allStdenvs = import ../stdenv {
5− inherit system platform config lib;
6− # TODO(@Ericson2314): hack for cross-compiling until I clean that in follow-up PR
7− allPackages = args: nixpkgsFun (args // { crossSystem = null; });
5+ inherit system platform config crossSystem lib;
6+ allPackages = nixpkgsFun;
87 };
98
109 defaultStdenv = allStdenvs.stdenv // { inherit platform; };
1110
1211 stdenv =
13− if bootStdenv != null then (bootStdenv // {inherit platform;}) else
14− if crossSystem != null then
15− pkgs.stdenvCross
16− else
17− let
18− changer = config.replaceStdenv or null;
19− in if changer != null then
20− changer {
21− # We import again all-packages to avoid recursivities.
22− pkgs = nixpkgsFun {
23− # We remove packageOverrides to avoid recursivities
24− config = removeAttrs config [ "replaceStdenv" ];
25− };
26− }
27− else
28− defaultStdenv;
12+ if bootStdenv != null then
13+ (bootStdenv // { inherit platform; })
14+ else if crossSystem == null && config ? replaceStdenv then
15+ config.replaceStdenv {
16+ # We import again all-packages to avoid recursivities.
17+ pkgs = nixpkgsFun {
18+ # We remove packageOverrides to avoid recursivities
19+ config = removeAttrs config [ "replaceStdenv" ];
20+ };
21+ }
22+ else
23+ defaultStdenv;
2924}