···1010, zlib ? null, extraPackages ? [], extraBuildCommands ? ""
1111, dyld ? null # TODO: should this be a setup-hook on dyld?
1212, isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
1313-, hostPlatform, targetPlatform
1413, runCommand ? null
1514}:
1615···2221assert !(nativeLibc && noLibc);
2322assert (noLibc || nativeLibc) == (libc == null);
24232525-assert targetPlatform != hostPlatform -> runCommand != null;
2424+assert stdenv.targetPlatform != stdenv.hostPlatform -> runCommand != null;
26252726# For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper.
2827assert cc.langVhdl or false -> zlib != null;
29283029let
3030+ inherit (stdenv) hostPlatform targetPlatform;
3131+3132 # Prefix for binaries. Customarily ends with a dash separator.
3233 #
3334 # TODO(@Ericson2314) Make unconditional, or optional but always true by
+3-5
pkgs/stdenv/adapters.nix
···6161 , buildPlatform, hostPlatform, targetPlatform
6262 } @ overrideArgs: let
6363 stdenv = overrideArgs.stdenv.override {
6464- # TODO(@Ericson2314): Cannot do this for now because then Nix thinks the
6565- # resulting derivation should be built on the host platform.
6666- #hostPlatform = buildPlatform;
6767- #targetPlatform = hostPlatform;
6868- inherit cc;
6464+ inherit
6565+ buildPlatform hostPlatform targetPlatform
6666+ cc;
69677068 allowedRequisites = null;
7169
···1515, stdenvSandboxProfile ? ""
1616, extraSandboxProfile ? ""
17171818-, # The platforms here do *not* correspond to the stage the stdenv is
1919- # used in, but rather the previous one, in which it was built. We
2020- # use the latter two platforms, like a cross compiler, because the
2121- # stand environment is a build tool if you squint at it, and because
2222- # neither of these are used when building stdenv so we know the
2323- # build platform is irrelevant.
2424- hostPlatform, targetPlatform
1818+ ## Platform parameters
1919+ ##
2020+ ## The "build" "host" "target" terminology below comes from GNU Autotools. See
2121+ ## its documentation for more information on what those words mean. Note that
2222+ ## each should always be defined, even when not cross compiling.
2323+ ##
2424+ ## For purposes of bootstrapping, think of each stage as a "sliding window"
2525+ ## over a list of platforms. Specifically, the host platform of the previous
2626+ ## stage becomes the build platform of the current one, and likewise the
2727+ ## target platform of the previous stage becomes the host platform of the
2828+ ## current one.
2929+ ##
3030+3131+, # The platform on which packages are built. Consists of `system`, a
3232+ # string (e.g.,`i686-linux') identifying the most import attributes of the
3333+ # build platform, and `platform` a set of other details.
3434+ buildPlatform
3535+3636+, # The platform on which packages run.
3737+ hostPlatform
3838+3939+, # The platform which build tools (especially compilers) build for in this stage,
4040+ targetPlatform
2541}:
26422743let
2828- inherit (targetPlatform) system;
2929-3044 defaultNativeBuildInputs = extraBuildInputs ++
3145 [ ../../build-support/setup-hooks/move-docs.sh
3246 ../../build-support/setup-hooks/compress-man-pages.sh
···4963 derivation (
5064 (if isNull allowedRequisites then {} else { allowedRequisites = allowedRequisites ++ defaultNativeBuildInputs; }) //
5165 {
5252- inherit system name;
6666+ inherit name;
6767+6868+ # Nix itself uses the `system` field of a derivation to decide where to
6969+ # build it. This is a bit confusing for cross compilation.
7070+ inherit (buildPlatform) system;
53715472 builder = shell;
5573···59776078 inherit preHook initialPath shell defaultNativeBuildInputs;
6179 }
6262- // lib.optionalAttrs hostPlatform.isDarwin {
8080+ // lib.optionalAttrs buildPlatform.isDarwin {
6381 __sandboxProfile = stdenvSandboxProfile;
6482 __impureHostDeps = __stdenvImpureHostDeps;
6583 })
···7189 platforms = lib.platforms.all;
7290 };
73919292+ inherit buildPlatform hostPlatform targetPlatform;
9393+7494 inherit extraBuildInputs __extraImpureHostDeps extraSandboxProfile;
75957696 # Utility flags to test the type of platform.
···8510586106 inherit (import ./make-derivation.nix {
87107 inherit lib config stdenv;
8888- # TODO(@Ericson2314): Remove
8989- inherit
9090- hostPlatform targetPlatform;
91108 }) mkDerivation;
9210993110 # For convenience, bring in the library functions in lib/ so
+8-10
pkgs/stdenv/generic/make-derivation.nix
···11-{ lib, config, stdenv
22-33-# TODO(@Ericson2314): get off stdenv
44-, hostPlatform, targetPlatform
55-}:
11+{ lib, config, stdenv }:
6273rec {
84 # `mkDerivation` wraps the builtin `derivation` function to
···49455046 outputs' =
5147 outputs ++
5252- (if separateDebugInfo then assert targetPlatform.isLinux; [ "debug" ] else []);
4848+ (if separateDebugInfo then assert stdenv.hostPlatform.isLinux; [ "debug" ] else []);
53495450 dependencies' = let
5551 justMap = map lib.chooseDevOutputs dependencies;
5652 nativeBuildInputs = lib.elemAt justMap 0
5757- ++ lib.optional targetPlatform.isWindows ../../build-support/setup-hooks/win-dll-link.sh;
5353+ ++ lib.optional stdenv.hostPlatform.isWindows ../../build-support/setup-hooks/win-dll-link.sh;
5854 buildInputs = lib.elemAt justMap 1
5955 # TODO(@Ericson2314): Should instead also be appended to `nativeBuildInputs`.
6056 ++ lib.optional separateDebugInfo ../../build-support/setup-hooks/separate-debug-info.sh;
···8278 builder = attrs.realBuilder or stdenv.shell;
8379 args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
8480 inherit stdenv;
8585- system = stdenv.system; # TODO(@Ericson2314): be correct about cross compilation
8181+ inherit (stdenv) system;
8682 userHook = config.stdenv.userHook or null;
8783 __ignoreNulls = true;
8884···91879288 propagatedNativeBuildInputs = lib.elemAt propagatedDependencies' 0;
9389 propagatedBuildInputs = lib.elemAt propagatedDependencies' 1;
9494- } // lib.optionalAttrs (hostPlatform.isDarwin) {
9090+ } // lib.optionalAttrs (stdenv.buildPlatform.isDarwin) {
9591 # TODO: remove lib.unique once nix has a list canonicalization primitive
9692 __sandboxProfile =
9793 let profiles = [ stdenv.extraSandboxProfile ] ++ computedSandboxProfile ++ computedPropagatedSandboxProfile ++ [ propagatedSandboxProfile sandboxProfile ];
···139135 {
140136 inherit lib config meta derivationArg;
141137 mkDerivationArg = attrs;
142142- inherit (stdenv) system; # TODO: cross-compilation?
138138+ # Nix itself uses the `system` field of a derivation to decide where
139139+ # to build it. This is a bit confusing for cross compilation.
140140+ inherit (stdenv) system;
143141 }))
144142 ( {
145143 overrideAttrs = f: mkDerivation (attrs // (f attrs));
···1818, # Use to reevaluate Nixpkgs; a dirty hack that should be removed
1919 nixpkgsFun
20202121- ## Platform parameters
2222- ##
2323- ## The "build" "host" "target" terminology below comes from GNU Autotools. See
2424- ## its documentation for more information on what those words mean. Note that
2525- ## each should always be defined, even when not cross compiling.
2626- ##
2727- ## For purposes of bootstrapping, think of each stage as a "sliding window"
2828- ## over a list of platforms. Specifically, the host platform of the previous
2929- ## stage becomes the build platform of the current one, and likewise the
3030- ## target platform of the previous stage becomes the host platform of the
3131- ## current one.
3232- ##
3333-3434-, # The platform on which packages are built. Consists of `system`, a
3535- # string (e.g.,`i686-linux') identifying the most import attributes of the
3636- # build platform, and `platform` a set of other details.
3737- buildPlatform
3838-3939-, # The platform on which packages run.
4040- hostPlatform
4141-4242-, # The platform which build tools (especially compilers) build for in this stage,
4343- targetPlatform
4444-4521 ## Other parameters
4622 ##
4723···6945, # Non-GNU/Linux OSes are currently "impure" platforms, with their libc
7046 # outside of the store. Thus, GCC, GFortran, & co. must always look for files
7147 # in standard system directories (/usr/include, etc.)
7272- noSysDirs ? buildPlatform.system != "x86_64-freebsd"
7373- && buildPlatform.system != "i686-freebsd"
7474- && buildPlatform.system != "x86_64-solaris"
7575- && buildPlatform.system != "x86_64-kfreebsd-gnu"
4848+ noSysDirs ? stdenv.buildPlatform.system != "x86_64-freebsd"
4949+ && stdenv.buildPlatform.system != "i686-freebsd"
5050+ && stdenv.buildPlatform.system != "x86_64-solaris"
5151+ && stdenv.buildPlatform.system != "x86_64-kfreebsd-gnu"
76527753, # The configuration attribute set
7854 config
···9874 // { recurseForDerivations = false; };
9975 __targetPackages = (if __targetPackages == null then self else __targetPackages)
10076 // { recurseForDerivations = false; };
101101- inherit stdenv
102102- buildPlatform hostPlatform targetPlatform;
7777+ inherit stdenv;
10378 };
1047910580 # The old identifiers for cross-compiling. These should eventually be removed,
10681 # and the packages that rely on them refactored accordingly.
10782 platformCompat = self: super: let
108108- # TODO(@Ericson2314) this causes infinite recursion
109109- #inherit (self) buildPlatform hostPlatform targetPlatform;
8383+ inherit (super.stdenv) buildPlatform hostPlatform targetPlatform;
11084 in {
11185 stdenv = super.stdenv // {
112112- inherit (buildPlatform) platform;
8686+ inherit (super.stdenv.buildPlatform) platform;
11387 };
8888+ inherit buildPlatform hostPlatform targetPlatform;
11489 inherit (buildPlatform) system platform;
11590 };
11691