git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #20108 from Ericson2314/top-level-cleanup

Move stdenvCross and customStdenv to pkgs/stdenv

commita24728fe295f28648f1812b3565541f7ef6269f1 authorJohn Ericson <Ericson2314@yahoo.com> dateTue 8 Nov 2016, 10:00 (10 years ago) parentfebf3cf6bfe042
6 files changed+79−34
pkgs/stdenv/cross/default.nix+31 pkgs/stdenv/custom/default.nix+17 pkgs/stdenv/default.nix+8−2 pkgs/top-level/all-packages.nix+2−2 pkgs/top-level/default.nix+15−9 pkgs/top-level/stdenv.nix+6−21
pkgs/stdenv/cross/default.nixnew file+31
@@ -0,0 +1,31 @@
1+{ system, allPackages, platform, crossSystem, config, ... } @ args:
2+
3+rec {
4+ argClobber = {
5+ crossSystem = null;
6+ # Ignore custom stdenvs when cross compiling for compatability
7+ config = builtins.removeAttrs config [ "replaceStdenv" ];
8+ };
9+ vanillaStdenv = (import ../. (args // argClobber // {
10+ allPackages = args: allPackages (argClobber // args);
11+ })).stdenv;
12+
13+ # Yeah this isn't so cleanly just build-time packages yet. Notice the
14+ # buildPackages <-> stdenvCross cycle. Yup, it's very weird.
15+ #
16+ # This works because the derivation used to build `stdenvCross` are in
17+ # fact using `forceNativeDrv` to use the `nativeDrv` attribute of the resulting
18+ # derivation built with `vanillaStdenv` (second argument of `makeStdenvCross`).
19+ #
20+ # Eventually, `forceNativeDrv` should be removed and the cycle broken.
21+ buildPackages = allPackages {
22+ # It's OK to change the built-time dependencies
23+ allowCustomOverrides = true;
24+ bootStdenv = stdenvCross;
25+ inherit system platform crossSystem config;
26+ };
27+
28+ stdenvCross = buildPackages.makeStdenvCross
29+ vanillaStdenv crossSystem
30+ buildPackages.binutilsCross buildPackages.gccCrossStageFinal;
31+}
pkgs/stdenv/custom/default.nixnew file+17
@@ -0,0 +1,17 @@
1+{ system, allPackages, platform, crossSystem, config, ... } @ args:
2+
3+rec {
4+ vanillaStdenv = (import ../. (args // {
5+ # Remove config.replaceStdenv to ensure termination.
6+ config = builtins.removeAttrs config [ "replaceStdenv" ];
7+ })).stdenv;
8+
9+ buildPackages = allPackages {
10+ # It's OK to change the built-time dependencies
11+ allowCustomOverrides = true;
12+ bootStdenv = vanillaStdenv;
13+ inherit system platform crossSystem config;
14+ };
15+
16+ stdenvCustom = config.replaceStdenv { pkgs = buildPackages; };
17+}
pkgs/stdenv/default.nix+8−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,16 @@ 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;
42+
43+ inherit (import ./custom { inherit system allPackages platform crossSystem config lib; }) stdenvCustom;
4044
4145 # Select the appropriate stdenv for the platform `system'.
4246 stdenv =
47+ if crossSystem != null then stdenvCross else
48+ if config ? replaceStdenv then stdenvCustom else
4349 if system == "i686-linux" then stdenvLinux else
4450 if system == "x86_64-linux" then stdenvLinux else
4551 if system == "armv5tel-linux" then stdenvLinux else
pkgs/top-level/all-packages.nix+2−2
@@ -5,9 +5,9 @@
55 * to merges. Please use the full-text search of your editor. ;)
66 * Hint: ### starts category names.
77 */
8−{ system, bootStdenv, noSysDirs, config, crossSystem, platform, lib
8+{ system, noSysDirs, config, crossSystem, platform, lib
99, nixpkgsFun
10−, ... }:
10+}:
1111self: pkgs:
1212
1313with pkgs;
pkgs/top-level/default.nix+15−9
@@ -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.)
@@ -56,10 +61,6 @@ let
5661 platform = if platform_ != null then platform_
5762 else config.platform or platformAuto;
5863
59− topLevelArguments = {
60− inherit system bootStdenv noSysDirs config crossSystem platform lib nixpkgsFun;
61− };
62−
6364 # A few packages make a new package set to draw their dependencies from.
6465 # (Currently to get a cross tool chain, or forced-i686 package.) Rather than
6566 # give `all-packages.nix` all the arguments to this function, even ones that
@@ -77,14 +78,19 @@ let
7778 };
7879
7980 trivialBuilders = self: super:
80− (import ../build-support/trivial-builders.nix {
81+ import ../build-support/trivial-builders.nix {
8182 inherit lib; inherit (self) stdenv stdenvNoCC; inherit (self.xorg) lndir;
82− });
83+ };
8384
84− stdenvDefault = self: super: (import ./stdenv.nix topLevelArguments) pkgs;
85+ stdenvDefault = self: super:
86+ import ./stdenv.nix {
87+ inherit system bootStdenv crossSystem config platform lib nixpkgsFun;
88+ };
8589
8690 allPackages = self: super:
87− let res = import ./all-packages.nix topLevelArguments res self;
91+ let res = import ./all-packages.nix
92+ { inherit system noSysDirs config crossSystem platform lib nixpkgsFun; }
93+ res self;
8894 in res;
8995
9096 aliases = self: super: import ./aliases.nix super;
@@ -108,7 +114,7 @@ let
108114 # attributes to refer to the original attributes (e.g. "foo =
109115 # ... pkgs.foo ...").
110116 configOverrides = self: super:
111− lib.optionalAttrs (bootStdenv == null)
117+ lib.optionalAttrs allowCustomOverrides
112118 ((config.packageOverrides or (super: {})) super);
113119
114120 # The complete chain of package set builders, applied from top to bottom
pkgs/top-level/stdenv.nix+6−21
@@ -1,30 +1,15 @@
1−{ system, bootStdenv, crossSystem, config, platform, lib, nixpkgsFun, ... }:
2−pkgs:
1+{ system, bootStdenv, crossSystem, config, platform, lib, nixpkgsFun }:
32
43rec {
54 allStdenvs = import ../stdenv {
6− inherit system platform config lib;
7− # TODO(@Ericson2314): hack for cross-compiling until I clean that in follow-up PR
8− allPackages = args: nixpkgsFun (args // { crossSystem = null; });
5+ inherit system platform config crossSystem lib;
6+ allPackages = nixpkgsFun;
97 };
108
119 defaultStdenv = allStdenvs.stdenv // { inherit platform; };
1210
1311 stdenv =
14− if bootStdenv != null then (bootStdenv // {inherit platform;}) else
15− if crossSystem != null then
16− pkgs.stdenvCross
17− else
18− let
19− changer = config.replaceStdenv or null;
20− in if changer != null then
21− changer {
22− # We import again all-packages to avoid recursivities.
23− pkgs = nixpkgsFun {
24− # We remove packageOverrides to avoid recursivities
25− config = removeAttrs config [ "replaceStdenv" ];
26− };
27− }
28− else
29− defaultStdenv;
12+ if bootStdenv != null
13+ then (bootStdenv // { inherit platform; })
14+ else defaultStdenv;
3015}