diff options
author | John Ericson <Ericson2314@Yahoo.com> | 2016-12-24 10:55:11 -0800 |
---|---|---|
committer | John Ericson <Ericson2314@Yahoo.com> | 2017-01-24 11:37:56 -0500 |
commit | 92edcb7ebbf5b4b324288ec62bebbc58a3f96ef6 (patch) | |
tree | 810ca0e0f429364adcf030867095fffe655cb3ab /pkgs/top-level/stage.nix | |
parent | 5b88f09ec4d6b3ac953cd9d252ebfd6663205c57 (diff) | |
download | nixpkgs-92edcb7ebbf5b4b324288ec62bebbc58a3f96ef6.tar nixpkgs-92edcb7ebbf5b4b324288ec62bebbc58a3f96ef6.tar.gz nixpkgs-92edcb7ebbf5b4b324288ec62bebbc58a3f96ef6.tar.bz2 nixpkgs-92edcb7ebbf5b4b324288ec62bebbc58a3f96ef6.tar.lz nixpkgs-92edcb7ebbf5b4b324288ec62bebbc58a3f96ef6.tar.xz nixpkgs-92edcb7ebbf5b4b324288ec62bebbc58a3f96ef6.tar.zst nixpkgs-92edcb7ebbf5b4b324288ec62bebbc58a3f96ef6.zip |
top-level: Lay the groundwork for `{build,host,target}Platform`
The long term goal is a big replace: { inherit system platform; } => buildPlatform crossSystem => hostPlatform stdenv.cross => targetPlatform And additionally making sure each is defined even when not cross compiling. This commit refactors the bootstrapping code along that vision, but leaves the old identifiers with their null semantics in place so packages can be modernized incrementally.
Diffstat (limited to 'pkgs/top-level/stage.nix')
-rw-r--r-- | pkgs/top-level/stage.nix | 82 |
1 files changed, 64 insertions, 18 deletions
diff --git a/pkgs/top-level/stage.nix b/pkgs/top-level/stage.nix index c100e21473c..780be566436 100644 --- a/pkgs/top-level/stage.nix +++ b/pkgs/top-level/stage.nix @@ -9,10 +9,43 @@ import `pkgs/default.nix` or `default.nix`. */ -{ # The system (e.g., `i686-linux') for which to build the packages. - system - -, # the package set used at build-time +{ ## Misc parameters kept the same for all stages + ## + + # Utility functions, could just import but passing in for efficiency + lib + +, # Use to reevaluate Nixpkgs; a dirty hack that should be removed + nixpkgsFun + + ## Platform parameters + ## + ## The "build" "host" "target" terminology below comes from GNU Autotools. See + ## its documentation for more information on what those words mean. Note that + ## each should always be defined, even when not cross compiling. + ## + ## For purposes of bootstrapping, think of each stage as a "sliding window" + ## over a list of platforms. Specifically, the host platform of the previous + ## stage becomes the build platform of the current one, and likewise the + ## target platform of the previous stage becomes the host platform of the + ## current one. + ## + +, # The platform on which packages are built. Consists of `system`, a + # string (e.g.,`i686-linux') identifying the most import attributes of the + # build platform, and `platform` a set of other details. + buildPlatform + +, # The platform on which packages run. + hostPlatform + +, # The platform which build tools (especially compilers) build for in this stage, + targetPlatform + + ## Other parameters + ## + +, # The package set used at build-time buildPackages , # The standard environment to use for building packages. @@ -24,21 +57,19 @@ allowCustomOverrides , # 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.) - noSysDirs ? (system != "x86_64-freebsd" && system != "i686-freebsd" - && system != "x86_64-solaris" - && system != "x86_64-kfreebsd-gnu") + # outside of the store. Thus, GCC, GFortran, & co. must always look for files + # in standard system directories (/usr/include, etc.) + noSysDirs ? buildPlatform.system != "x86_64-freebsd" + && buildPlatform.system != "i686-freebsd" + && buildPlatform.system != "x86_64-solaris" + && buildPlatform.system != "x86_64-kfreebsd-gnu" , # The configuration attribute set config -, overlays # List of overlays to use in the fix-point. - -, crossSystem -, platform -, lib -, nixpkgsFun +, # A list of overlays (Additional `self: super: { .. }` customization + # functions) to be fixed together in the produced package set + overlays }: let @@ -53,10 +84,24 @@ let }; stdenvBootstappingAndPlatforms = self: super: { - stdenv = stdenv // { inherit platform; }; buildPackages = buildPackages // { recurseForDerivations = false; }; - inherit - system platform crossSystem; + inherit stdenv + buildPlatform hostPlatform targetPlatform; + }; + + # The old identifiers for cross-compiling. These should eventually be removed, + # and the packages that rely on them refactored accordingly. + platformCompat = self: super: let + # TODO(@Ericson2314) this causes infinite recursion + #inherit (self) buildPlatform hostPlatform targetPlatform; + in { + stdenv = super.stdenv // { + inherit (buildPlatform) platform; + } // lib.optionalAttrs (targetPlatform != buildPlatform) { + cross = targetPlatform; + }; + inherit (buildPlatform) system platform; + crossSystem = if targetPlatform != buildPlatform then targetPlatform else null; }; splice = self: super: import ./splice.nix lib self; @@ -89,6 +134,7 @@ let # The complete chain of package set builders, applied from top to bottom toFix = lib.foldl' (lib.flip lib.extends) (self: {}) ([ stdenvBootstappingAndPlatforms + platformCompat stdenvAdapters trivialBuilders splice |