about summary refs log tree commit diff
path: root/pkgs/stdenv/default.nix
diff options
context:
space:
mode:
authorJohn Ericson <Ericson2314@Yahoo.com>2016-12-16 05:22:02 -0800
committerJohn Ericson <Ericson2314@Yahoo.com>2017-01-13 13:23:23 -0500
commit3e197f7d81130defacfe5bdad71ca5ebe63324ff (patch)
treed06650289f9729f647814eff912e8d39bdd523a8 /pkgs/stdenv/default.nix
parent0ef8b69d12d1ab1574568f5660b44feba1f44179 (diff)
top-level: Normalize stdenv booting
Introduce new abstraction, `stdenv/booter.nix` for composing bootstraping
stages, and use it everywhere for consistency. See that file for more doc.

Stdenvs besides Linux and Darwin are completely refactored to utilize this.
Those two, due to their size and complexity, are minimally edited for
easier reviewing.

No hashes should be changed.
Diffstat (limited to 'pkgs/stdenv/default.nix')
-rw-r--r--pkgs/stdenv/default.nix78
1 files changed, 33 insertions, 45 deletions
diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix
index 3b49d0de83068..e8e609c722018 100644
--- a/pkgs/stdenv/default.nix
+++ b/pkgs/stdenv/default.nix
@@ -1,13 +1,12 @@
-# This file defines the various standard build environments.
+# This file chooses a sane default stdenv given the system, platform, etc.
 #
-# On Linux systems, the standard build environment consists of
-# Nix-built instances glibc and the `standard' Unix tools, i.e., the
-# Posix utilities, the GNU C compiler, and so on.  On other systems,
-# we use the native C library.
+# Rather than returning a stdenv, this returns a list of functions---one per
+# each bootstrapping stage. See `./booter.nix` for exactly what this list should
+# contain.
 
 { # Args just for stdenvs' usage
-  lib, allPackages
-  # Args to pass on to `allPacakges` too
+  lib
+  # Args to pass on to the pkgset builder, too
 , system, platform, crossSystem, config
 } @ args:
 
@@ -17,50 +16,39 @@ let
   # i.e., the stuff in /bin, /usr/bin, etc.  This environment should
   # be used with care, since many Nix packages will not build properly
   # with it (e.g., because they require GNU Make).
-  inherit (import ./native args) stdenvNative;
-
-  stdenvNativePkgs = allPackages {
-    inherit system platform crossSystem config;
-    allowCustomOverrides = false;
-    stdenv = stdenvNative;
-    noSysDirs = false;
-  };
-
+  stagesNative = import ./native args;
 
   # The Nix build environment.
-  stdenvNix = assert crossSystem == null; import ./nix {
-    inherit config lib;
-    stdenv = stdenvNative;
-    pkgs = stdenvNativePkgs;
-  };
+  stagesNix = import ./nix (args // { bootStages = stagesNative; });
 
-  inherit (import ./freebsd args) stdenvFreeBSD;
+  stagesFreeBSD = import ./freebsd args;
 
-  # Linux standard environment.
-  inherit (import ./linux args) stdenvLinux;
+  # On Linux systems, the standard build environment consists of Nix-built
+  # instances glibc and the `standard' Unix tools, i.e., the Posix utilities,
+  # the GNU C compiler, and so on.
+  inherit (import ./linux args) stagesLinux;
 
-  inherit (import ./darwin args) stdenvDarwin;
+  inherit (import ./darwin args) stagesDarwin;
 
-  inherit (import ./cross args) stdenvCross stdenvCrossiOS;
+  stagesCross = import ./cross args;
 
-  inherit (import ./custom args) stdenvCustom;
+  stagesCustom = import ./custom args;
 
-  # Select the appropriate stdenv for the platform `system'.
+  # Select the appropriate stages for the platform `system'.
 in
-    if crossSystem != null then
-      if crossSystem.useiOSCross or false then stdenvCrossiOS
-      else 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
-    if system == "armv6l-linux" then stdenvLinux else
-    if system == "armv7l-linux" then stdenvLinux else
-    if system == "mips64el-linux" then stdenvLinux else
-    if system == "powerpc-linux" then /* stdenvLinux */ stdenvNative else
-    if system == "x86_64-darwin" then stdenvDarwin else
-    if system == "x86_64-solaris" then stdenvNix else
-    if system == "i686-cygwin" then stdenvNative else
-    if system == "x86_64-cygwin" then stdenvNative else
-    if system == "x86_64-freebsd" then stdenvFreeBSD else
-    stdenvNative
+  if crossSystem != null then stagesCross
+  else if config ? replaceStdenv then stagesCustom
+  else { # switch
+    "i686-linux" = stagesLinux;
+    "x86_64-linux" = stagesLinux;
+    "armv5tel-linux" = stagesLinux;
+    "armv6l-linux" = stagesLinux;
+    "armv7l-linux" = stagesLinux;
+    "mips64el-linux" = stagesLinux;
+    "powerpc-linux" = /* stagesLinux */ stagesNative;
+    "x86_64-darwin" = stagesDarwin;
+    "x86_64-solaris" = stagesNix;
+    "i686-cygwin" = stagesNative;
+    "x86_64-cygwin" = stagesNative;
+    "x86_64-freebsd" = stagesFreeBSD;
+  }.${system} or stagesNative