about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Ericson <Ericson2314@yahoo.com>2016-11-08 10:00:04 -0500
committerGitHub <noreply@github.com>2016-11-08 10:00:04 -0500
commita24728fe295f28648f1812b3565541f7ef6269f1 (patch)
tree345a00b32ad23a250c71690c669e7c944d03f6b0
parentfebf3cfd34b5c846949d5952df1a8ba70d4a8efc (diff)
parent6bfe04277f40a0da27fa6373edfb24a6b139548b (diff)
downloadnixlib-a24728fe295f28648f1812b3565541f7ef6269f1.tar
nixlib-a24728fe295f28648f1812b3565541f7ef6269f1.tar.gz
nixlib-a24728fe295f28648f1812b3565541f7ef6269f1.tar.bz2
nixlib-a24728fe295f28648f1812b3565541f7ef6269f1.tar.lz
nixlib-a24728fe295f28648f1812b3565541f7ef6269f1.tar.xz
nixlib-a24728fe295f28648f1812b3565541f7ef6269f1.tar.zst
nixlib-a24728fe295f28648f1812b3565541f7ef6269f1.zip
Merge pull request #20108 from Ericson2314/top-level-cleanup
Move stdenvCross and customStdenv to pkgs/stdenv
-rw-r--r--pkgs/stdenv/cross/default.nix31
-rw-r--r--pkgs/stdenv/custom/default.nix17
-rw-r--r--pkgs/stdenv/default.nix10
-rw-r--r--pkgs/top-level/all-packages.nix4
-rw-r--r--pkgs/top-level/default.nix24
-rw-r--r--pkgs/top-level/stdenv.nix27
6 files changed, 79 insertions, 34 deletions
diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix
new file mode 100644
index 000000000000..93c5a21d9d5a
--- /dev/null
+++ b/pkgs/stdenv/cross/default.nix
@@ -0,0 +1,31 @@
+{ system, allPackages, platform, crossSystem, config, ... } @ args:
+
+rec {
+  argClobber = {
+    crossSystem = null;
+    # Ignore custom stdenvs when cross compiling for compatability
+    config = builtins.removeAttrs config [ "replaceStdenv" ];
+  };
+  vanillaStdenv = (import ../. (args // argClobber // {
+    allPackages = args: allPackages (argClobber // args);
+  })).stdenv;
+
+  # Yeah this isn't so cleanly just build-time packages yet. Notice the
+  # buildPackages <-> stdenvCross cycle. Yup, it's very weird.
+  #
+  # This works because the derivation used to build `stdenvCross` are in
+  # fact using `forceNativeDrv` to use the `nativeDrv` attribute of the resulting
+  # derivation built with `vanillaStdenv` (second argument of `makeStdenvCross`).
+  #
+  # Eventually, `forceNativeDrv` should be removed and the cycle broken.
+  buildPackages = allPackages {
+    # It's OK to change the built-time dependencies
+    allowCustomOverrides = true;
+    bootStdenv = stdenvCross;
+    inherit system platform crossSystem config;
+  };
+
+  stdenvCross = buildPackages.makeStdenvCross
+    vanillaStdenv crossSystem
+    buildPackages.binutilsCross buildPackages.gccCrossStageFinal;
+}
diff --git a/pkgs/stdenv/custom/default.nix b/pkgs/stdenv/custom/default.nix
new file mode 100644
index 000000000000..2f2f495b388b
--- /dev/null
+++ b/pkgs/stdenv/custom/default.nix
@@ -0,0 +1,17 @@
+{ system, allPackages, platform, crossSystem, config, ... } @ args:
+
+rec {
+  vanillaStdenv = (import ../. (args // {
+    # Remove config.replaceStdenv to ensure termination.
+    config = builtins.removeAttrs config [ "replaceStdenv" ];
+  })).stdenv;
+
+  buildPackages = allPackages {
+    # It's OK to change the built-time dependencies
+    allowCustomOverrides = true;
+    bootStdenv = vanillaStdenv;
+    inherit system platform crossSystem config;
+  };
+
+  stdenvCustom = config.replaceStdenv { pkgs = buildPackages; };
+}
diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix
index 3035d87e1fc5..10086ee6a853 100644
--- a/pkgs/stdenv/default.nix
+++ b/pkgs/stdenv/default.nix
@@ -5,7 +5,7 @@
 # Posix utilities, the GNU C compiler, and so on.  On other systems,
 # we use the native C library.
 
-{ system, allPackages ? import ../.., platform, config, lib }:
+{ system, allPackages ? import ../.., platform, config, crossSystem, lib }:
 
 
 rec {
@@ -36,10 +36,16 @@ rec {
   # Linux standard environment.
   inherit (import ./linux { inherit system allPackages platform config lib; }) stdenvLinux;
 
-  inherit (import ./darwin { inherit system allPackages platform config;}) stdenvDarwin;
+  inherit (import ./darwin { inherit system allPackages platform config; }) stdenvDarwin;
+
+  inherit (import ./cross { inherit system allPackages platform crossSystem config lib; }) stdenvCross;
+
+  inherit (import ./custom { inherit system allPackages platform crossSystem config lib; }) stdenvCustom;
 
   # Select the appropriate stdenv for the platform `system'.
   stdenv =
+    if crossSystem != null then stdenvCross else
+    if config ? replaceStdenv then stdenvCustom else
     if system == "i686-linux" then stdenvLinux else
     if system == "x86_64-linux" then stdenvLinux else
     if system == "armv5tel-linux" then stdenvLinux else
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index e78ab21fd81e..38a2a2428477 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -5,9 +5,9 @@
  * to merges. Please use the full-text search of your editor. ;)
  * Hint: ### starts category names.
  */
-{ system, bootStdenv, noSysDirs, config, crossSystem, platform, lib
+{ system, noSysDirs, config, crossSystem, platform, lib
 , nixpkgsFun
-, ... }:
+}:
 self: pkgs:
 
 with pkgs;
diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix
index 7d370bec6b5d..831b1db0cea3 100644
--- a/pkgs/top-level/default.nix
+++ b/pkgs/top-level/default.nix
@@ -12,6 +12,11 @@
   # null, the default standard environment is used.
   bootStdenv ? null
 
+, # This is used because stdenv replacement and the stdenvCross do benefit from
+  # the overridden configuration provided by the user, as opposed to the normal
+  # bootstrapping stdenvs.
+  allowCustomOverrides ? (bootStdenv == null)
+
 , # Non-GNU/Linux OSes are currently "impure" platforms, with their libc
   # outside of the store.  Thus, GCC, GFortran, & co. must always look for
   # files in standard system directories (/usr/include, etc.)
@@ -56,10 +61,6 @@ let
   platform = if platform_ != null then platform_
     else config.platform or platformAuto;
 
-  topLevelArguments = {
-    inherit system bootStdenv noSysDirs config crossSystem platform lib nixpkgsFun;
-  };
-
   # A few packages make a new package set to draw their dependencies from.
   # (Currently to get a cross tool chain, or forced-i686 package.) Rather than
   # give `all-packages.nix` all the arguments to this function, even ones that
@@ -77,14 +78,19 @@ let
     };
 
   trivialBuilders = self: super:
-    (import ../build-support/trivial-builders.nix {
+    import ../build-support/trivial-builders.nix {
       inherit lib; inherit (self) stdenv stdenvNoCC; inherit (self.xorg) lndir;
-    });
+    };
 
-  stdenvDefault = self: super: (import ./stdenv.nix topLevelArguments) pkgs;
+  stdenvDefault = self: super:
+    import ./stdenv.nix {
+      inherit system bootStdenv crossSystem config platform lib nixpkgsFun;
+    };
 
   allPackages = self: super:
-    let res = import ./all-packages.nix topLevelArguments res self;
+    let res = import ./all-packages.nix
+      { inherit system noSysDirs config crossSystem platform lib nixpkgsFun; }
+      res self;
     in res;
 
   aliases = self: super: import ./aliases.nix super;
@@ -108,7 +114,7 @@ let
   # attributes to refer to the original attributes (e.g. "foo =
   # ... pkgs.foo ...").
   configOverrides = self: super:
-    lib.optionalAttrs (bootStdenv == null)
+    lib.optionalAttrs allowCustomOverrides
       ((config.packageOverrides or (super: {})) super);
 
   # The complete chain of package set builders, applied from top to bottom
diff --git a/pkgs/top-level/stdenv.nix b/pkgs/top-level/stdenv.nix
index c36b0fed091a..9f485b8c90ef 100644
--- a/pkgs/top-level/stdenv.nix
+++ b/pkgs/top-level/stdenv.nix
@@ -1,30 +1,15 @@
-{ system, bootStdenv, crossSystem, config, platform, lib, nixpkgsFun, ... }:
-pkgs:
+{ system, bootStdenv, crossSystem, config, platform, lib, nixpkgsFun }:
 
 rec {
   allStdenvs = import ../stdenv {
-    inherit system platform config lib;
-    # TODO(@Ericson2314): hack for cross-compiling until I clean that in follow-up PR
-    allPackages = args: nixpkgsFun (args // { crossSystem = null; });
+    inherit system platform config crossSystem lib;
+    allPackages = nixpkgsFun;
   };
 
   defaultStdenv = allStdenvs.stdenv // { inherit platform; };
 
   stdenv =
-    if bootStdenv != null then (bootStdenv // {inherit platform;}) else
-      if crossSystem != null then
-        pkgs.stdenvCross
-      else
-        let
-            changer = config.replaceStdenv or null;
-        in if changer != null then
-          changer {
-            # We import again all-packages to avoid recursivities.
-            pkgs = nixpkgsFun {
-              # We remove packageOverrides to avoid recursivities
-              config = removeAttrs config [ "replaceStdenv" ];
-            };
-          }
-      else
-        defaultStdenv;
+    if bootStdenv != null
+    then (bootStdenv // { inherit platform; })
+    else defaultStdenv;
 }