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.
This commit is contained in:
John Ericson
2017-01-13 13:23:23 -05:00
parent 0ef8b69d12
commit 3e197f7d81
12 changed files with 391 additions and 270 deletions
+43 -39
View File
@@ -1,10 +1,10 @@
{ lib, allPackages
{ lib
, system, platform, crossSystem, config
}:
assert crossSystem == null;
rec {
let
shell =
if system == "i686-freebsd" || system == "x86_64-freebsd" then "/usr/local/bin/bash"
@@ -101,50 +101,54 @@ rec {
inherit system shell cc overrides config;
};
in
stdenvBoot0 = makeStdenv {
cc = null;
fetchurl = null;
};
[
({}: rec {
__raw = true;
cc = import ../../build-support/cc-wrapper {
name = "cc-native";
nativeTools = true;
nativeLibc = true;
nativePrefix = if system == "i686-solaris" then "/usr/gnu" else if system == "x86_64-solaris" then "/opt/local/gcc47" else "/usr";
stdenv = stdenvBoot0;
};
stdenv = makeStdenv {
cc = null;
fetchurl = null;
};
cc = import ../../build-support/cc-wrapper {
name = "cc-native";
nativeTools = true;
nativeLibc = true;
nativePrefix = { # switch
"i686-solaris" = "/usr/gnu";
"x86_64-solaris" = "/opt/local/gcc47";
}.${system} or "/usr";
inherit stdenv;
};
fetchurl = import ../../build-support/fetchurl {
stdenv = stdenvBoot0;
# Curl should be in /usr/bin or so.
curl = null;
};
fetchurl = import ../../build-support/fetchurl {
inherit stdenv;
# Curl should be in /usr/bin or so.
curl = null;
};
})
# First build a stdenv based only on tools outside the store.
stdenvBoot1 = makeStdenv {
inherit cc fetchurl;
} // {inherit fetchurl;};
(prevStage: {
inherit system crossSystem platform config;
stdenv = makeStdenv {
inherit (prevStage) cc fetchurl;
} // { inherit (prevStage) fetchurl; };
})
stdenvBoot1Pkgs = allPackages {
inherit system platform crossSystem config;
allowCustomOverrides = false;
stdenv = stdenvBoot1;
};
# Using that, build a stdenv that adds the xz command (which most systems
# don't have, so we mustn't rely on the native environment providing it).
(prevStage: {
inherit system crossSystem platform config;
stdenv = makeStdenv {
inherit (prevStage.stdenv) cc fetchurl;
extraPath = [ prevStage.xz ];
overrides = self: super: { inherit (prevStage) xz; };
};
})
# Using that, build a stdenv that adds the xz command (which most
# systems don't have, so we mustn't rely on the native environment
# providing it).
stdenvBoot2 = makeStdenv {
inherit cc fetchurl;
extraPath = [ stdenvBoot1Pkgs.xz ];
overrides = self: super: { inherit (stdenvBoot1Pkgs) xz; };
};
stdenvNative = stdenvBoot2;
}
]