···10, zlib ? null, extraPackages ? [], extraBuildCommands ? ""
11, dyld ? null # TODO: should this be a setup-hook on dyld?
12, isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
13-, hostPlatform, targetPlatform
14, runCommand ? null
15}:
16···22assert !(nativeLibc && noLibc);
23assert (noLibc || nativeLibc) == (libc == null);
2425-assert targetPlatform != hostPlatform -> runCommand != null;
2627# For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper.
28assert cc.langVhdl or false -> zlib != null;
2930let
0031 # Prefix for binaries. Customarily ends with a dash separator.
32 #
33 # TODO(@Ericson2314) Make unconditional, or optional but always true by
···10, zlib ? null, extraPackages ? [], extraBuildCommands ? ""
11, dyld ? null # TODO: should this be a setup-hook on dyld?
12, isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
013, runCommand ? null
14}:
15···21assert !(nativeLibc && noLibc);
22assert (noLibc || nativeLibc) == (libc == null);
2324+assert stdenv.targetPlatform != stdenv.hostPlatform -> runCommand != null;
2526# For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper.
27assert cc.langVhdl or false -> zlib != null;
2829let
30+ inherit (stdenv) hostPlatform targetPlatform;
31+32 # Prefix for binaries. Customarily ends with a dash separator.
33 #
34 # TODO(@Ericson2314) Make unconditional, or optional but always true by
+3-5
pkgs/stdenv/adapters.nix
···61 , buildPlatform, hostPlatform, targetPlatform
62 } @ overrideArgs: let
63 stdenv = overrideArgs.stdenv.override {
64- # TODO(@Ericson2314): Cannot do this for now because then Nix thinks the
65- # resulting derivation should be built on the host platform.
66- #hostPlatform = buildPlatform;
67- #targetPlatform = hostPlatform;
68- inherit cc;
6970 allowedRequisites = null;
71
···15, stdenvSandboxProfile ? ""
16, extraSandboxProfile ? ""
1718-, # The platforms here do *not* correspond to the stage the stdenv is
19- # used in, but rather the previous one, in which it was built. We
20- # use the latter two platforms, like a cross compiler, because the
21- # stand environment is a build tool if you squint at it, and because
22- # neither of these are used when building stdenv so we know the
23- # build platform is irrelevant.
24- hostPlatform, targetPlatform
000000000000000025}:
2627let
28- inherit (targetPlatform) system;
29-30 defaultNativeBuildInputs = extraBuildInputs ++
31 [ ../../build-support/setup-hooks/move-docs.sh
32 ../../build-support/setup-hooks/compress-man-pages.sh
···49 derivation (
50 (if isNull allowedRequisites then {} else { allowedRequisites = allowedRequisites ++ defaultNativeBuildInputs; }) //
51 {
52- inherit system name;
00005354 builder = shell;
55···5960 inherit preHook initialPath shell defaultNativeBuildInputs;
61 }
62- // lib.optionalAttrs hostPlatform.isDarwin {
63 __sandboxProfile = stdenvSandboxProfile;
64 __impureHostDeps = __stdenvImpureHostDeps;
65 })
···71 platforms = lib.platforms.all;
72 };
730074 inherit extraBuildInputs __extraImpureHostDeps extraSandboxProfile;
7576 # Utility flags to test the type of platform.
···8586 inherit (import ./make-derivation.nix {
87 inherit lib config stdenv;
88- # TODO(@Ericson2314): Remove
89- inherit
90- hostPlatform targetPlatform;
91 }) mkDerivation;
9293 # For convenience, bring in the library functions in lib/ so
···15, stdenvSandboxProfile ? ""
16, extraSandboxProfile ? ""
1718+ ## Platform parameters
19+ ##
20+ ## The "build" "host" "target" terminology below comes from GNU Autotools. See
21+ ## its documentation for more information on what those words mean. Note that
22+ ## each should always be defined, even when not cross compiling.
23+ ##
24+ ## For purposes of bootstrapping, think of each stage as a "sliding window"
25+ ## over a list of platforms. Specifically, the host platform of the previous
26+ ## stage becomes the build platform of the current one, and likewise the
27+ ## target platform of the previous stage becomes the host platform of the
28+ ## current one.
29+ ##
30+31+, # The platform on which packages are built. Consists of `system`, a
32+ # string (e.g.,`i686-linux') identifying the most import attributes of the
33+ # build platform, and `platform` a set of other details.
34+ buildPlatform
35+36+, # The platform on which packages run.
37+ hostPlatform
38+39+, # The platform which build tools (especially compilers) build for in this stage,
40+ targetPlatform
41}:
4243let
0044 defaultNativeBuildInputs = extraBuildInputs ++
45 [ ../../build-support/setup-hooks/move-docs.sh
46 ../../build-support/setup-hooks/compress-man-pages.sh
···63 derivation (
64 (if isNull allowedRequisites then {} else { allowedRequisites = allowedRequisites ++ defaultNativeBuildInputs; }) //
65 {
66+ inherit name;
67+68+ # Nix itself uses the `system` field of a derivation to decide where to
69+ # build it. This is a bit confusing for cross compilation.
70+ inherit (buildPlatform) system;
7172 builder = shell;
73···7778 inherit preHook initialPath shell defaultNativeBuildInputs;
79 }
80+ // lib.optionalAttrs buildPlatform.isDarwin {
81 __sandboxProfile = stdenvSandboxProfile;
82 __impureHostDeps = __stdenvImpureHostDeps;
83 })
···89 platforms = lib.platforms.all;
90 };
9192+ inherit buildPlatform hostPlatform targetPlatform;
93+94 inherit extraBuildInputs __extraImpureHostDeps extraSandboxProfile;
9596 # Utility flags to test the type of platform.
···105106 inherit (import ./make-derivation.nix {
107 inherit lib config stdenv;
000108 }) mkDerivation;
109110 # For convenience, bring in the library functions in lib/ so
+8-10
pkgs/stdenv/generic/make-derivation.nix
···1-{ lib, config, stdenv
2-3-# TODO(@Ericson2314): get off stdenv
4-, hostPlatform, targetPlatform
5-}:
67rec {
8 # `mkDerivation` wraps the builtin `derivation` function to
···4950 outputs' =
51 outputs ++
52- (if separateDebugInfo then assert targetPlatform.isLinux; [ "debug" ] else []);
5354 dependencies' = let
55 justMap = map lib.chooseDevOutputs dependencies;
56 nativeBuildInputs = lib.elemAt justMap 0
57- ++ lib.optional targetPlatform.isWindows ../../build-support/setup-hooks/win-dll-link.sh;
58 buildInputs = lib.elemAt justMap 1
59 # TODO(@Ericson2314): Should instead also be appended to `nativeBuildInputs`.
60 ++ lib.optional separateDebugInfo ../../build-support/setup-hooks/separate-debug-info.sh;
···82 builder = attrs.realBuilder or stdenv.shell;
83 args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
84 inherit stdenv;
85- system = stdenv.system; # TODO(@Ericson2314): be correct about cross compilation
86 userHook = config.stdenv.userHook or null;
87 __ignoreNulls = true;
88···9192 propagatedNativeBuildInputs = lib.elemAt propagatedDependencies' 0;
93 propagatedBuildInputs = lib.elemAt propagatedDependencies' 1;
94- } // lib.optionalAttrs (hostPlatform.isDarwin) {
95 # TODO: remove lib.unique once nix has a list canonicalization primitive
96 __sandboxProfile =
97 let profiles = [ stdenv.extraSandboxProfile ] ++ computedSandboxProfile ++ computedPropagatedSandboxProfile ++ [ propagatedSandboxProfile sandboxProfile ];
···139 {
140 inherit lib config meta derivationArg;
141 mkDerivationArg = attrs;
142- inherit (stdenv) system; # TODO: cross-compilation?
00143 }))
144 ( {
145 overrideAttrs = f: mkDerivation (attrs // (f attrs));
···1+{ lib, config, stdenv }:
000023rec {
4 # `mkDerivation` wraps the builtin `derivation` function to
···4546 outputs' =
47 outputs ++
48+ (if separateDebugInfo then assert stdenv.hostPlatform.isLinux; [ "debug" ] else []);
4950 dependencies' = let
51 justMap = map lib.chooseDevOutputs dependencies;
52 nativeBuildInputs = lib.elemAt justMap 0
53+ ++ lib.optional stdenv.hostPlatform.isWindows ../../build-support/setup-hooks/win-dll-link.sh;
54 buildInputs = lib.elemAt justMap 1
55 # TODO(@Ericson2314): Should instead also be appended to `nativeBuildInputs`.
56 ++ lib.optional separateDebugInfo ../../build-support/setup-hooks/separate-debug-info.sh;
···78 builder = attrs.realBuilder or stdenv.shell;
79 args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
80 inherit stdenv;
81+ inherit (stdenv) system;
82 userHook = config.stdenv.userHook or null;
83 __ignoreNulls = true;
84···8788 propagatedNativeBuildInputs = lib.elemAt propagatedDependencies' 0;
89 propagatedBuildInputs = lib.elemAt propagatedDependencies' 1;
90+ } // lib.optionalAttrs (stdenv.buildPlatform.isDarwin) {
91 # TODO: remove lib.unique once nix has a list canonicalization primitive
92 __sandboxProfile =
93 let profiles = [ stdenv.extraSandboxProfile ] ++ computedSandboxProfile ++ computedPropagatedSandboxProfile ++ [ propagatedSandboxProfile sandboxProfile ];
···135 {
136 inherit lib config meta derivationArg;
137 mkDerivationArg = attrs;
138+ # Nix itself uses the `system` field of a derivation to decide where
139+ # to build it. This is a bit confusing for cross compilation.
140+ inherit (stdenv) system;
141 }))
142 ( {
143 overrideAttrs = f: mkDerivation (attrs // (f attrs));
···18, # Use to reevaluate Nixpkgs; a dirty hack that should be removed
19 nixpkgsFun
2021- ## Platform parameters
22- ##
23- ## The "build" "host" "target" terminology below comes from GNU Autotools. See
24- ## its documentation for more information on what those words mean. Note that
25- ## each should always be defined, even when not cross compiling.
26- ##
27- ## For purposes of bootstrapping, think of each stage as a "sliding window"
28- ## over a list of platforms. Specifically, the host platform of the previous
29- ## stage becomes the build platform of the current one, and likewise the
30- ## target platform of the previous stage becomes the host platform of the
31- ## current one.
32- ##
33-34-, # The platform on which packages are built. Consists of `system`, a
35- # string (e.g.,`i686-linux') identifying the most import attributes of the
36- # build platform, and `platform` a set of other details.
37- buildPlatform
38-39-, # The platform on which packages run.
40- hostPlatform
41-42-, # The platform which build tools (especially compilers) build for in this stage,
43- targetPlatform
44-45 ## Other parameters
46 ##
47···69, # Non-GNU/Linux OSes are currently "impure" platforms, with their libc
70 # outside of the store. Thus, GCC, GFortran, & co. must always look for files
71 # in standard system directories (/usr/include, etc.)
72- noSysDirs ? buildPlatform.system != "x86_64-freebsd"
73- && buildPlatform.system != "i686-freebsd"
74- && buildPlatform.system != "x86_64-solaris"
75- && buildPlatform.system != "x86_64-kfreebsd-gnu"
7677, # The configuration attribute set
78 config
···98 // { recurseForDerivations = false; };
99 __targetPackages = (if __targetPackages == null then self else __targetPackages)
100 // { recurseForDerivations = false; };
101- inherit stdenv
102- buildPlatform hostPlatform targetPlatform;
103 };
104105 # The old identifiers for cross-compiling. These should eventually be removed,
106 # and the packages that rely on them refactored accordingly.
107 platformCompat = self: super: let
108- # TODO(@Ericson2314) this causes infinite recursion
109- #inherit (self) buildPlatform hostPlatform targetPlatform;
110 in {
111 stdenv = super.stdenv // {
112- inherit (buildPlatform) platform;
113 };
0114 inherit (buildPlatform) system platform;
115 };
116
···18, # Use to reevaluate Nixpkgs; a dirty hack that should be removed
19 nixpkgsFun
2000000000000000000000000021 ## Other parameters
22 ##
23···45, # Non-GNU/Linux OSes are currently "impure" platforms, with their libc
46 # outside of the store. Thus, GCC, GFortran, & co. must always look for files
47 # in standard system directories (/usr/include, etc.)
48+ noSysDirs ? stdenv.buildPlatform.system != "x86_64-freebsd"
49+ && stdenv.buildPlatform.system != "i686-freebsd"
50+ && stdenv.buildPlatform.system != "x86_64-solaris"
51+ && stdenv.buildPlatform.system != "x86_64-kfreebsd-gnu"
5253, # The configuration attribute set
54 config
···74 // { recurseForDerivations = false; };
75 __targetPackages = (if __targetPackages == null then self else __targetPackages)
76 // { recurseForDerivations = false; };
77+ inherit stdenv;
078 };
7980 # The old identifiers for cross-compiling. These should eventually be removed,
81 # and the packages that rely on them refactored accordingly.
82 platformCompat = self: super: let
83+ inherit (super.stdenv) buildPlatform hostPlatform targetPlatform;
084 in {
85 stdenv = super.stdenv // {
86+ inherit (super.stdenv.buildPlatform) platform;
87 };
88+ inherit buildPlatform hostPlatform targetPlatform;
89 inherit (buildPlatform) system platform;
90 };
91