top-level: {build,host,target}Platform are defined in the stdenv instead

See #27069 for a discussion of this

+90 -124
+3 -2
pkgs/build-support/cc-wrapper/default.nix
··· 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 ··· 22 assert !(nativeLibc && noLibc); 23 assert (noLibc || nativeLibc) == (libc == null); 24 25 - assert targetPlatform != hostPlatform -> runCommand != null; 26 27 # For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper. 28 assert cc.langVhdl or false -> zlib != null; 29 30 let 31 # 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 13 , runCommand ? null 14 }: 15 ··· 21 assert !(nativeLibc && noLibc); 22 assert (noLibc || nativeLibc) == (libc == null); 23 24 + assert stdenv.targetPlatform != stdenv.hostPlatform -> runCommand != null; 25 26 # For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper. 27 assert cc.langVhdl or false -> zlib != null; 28 29 let 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; 69 70 allowedRequisites = null; 71
··· 61 , buildPlatform, hostPlatform, targetPlatform 62 } @ overrideArgs: let 63 stdenv = overrideArgs.stdenv.override { 64 + inherit 65 + buildPlatform hostPlatform targetPlatform 66 + cc; 67 68 allowedRequisites = null; 69
+4 -7
pkgs/stdenv/cross/default.nix
··· 14 15 # Build Packages 16 (vanillaPackages: { 17 - buildPlatform = localSystem; 18 - hostPlatform = localSystem; 19 - targetPlatform = crossSystem; 20 inherit config overlays; 21 selfBuild = false; 22 # It's OK to change the built-time dependencies 23 allowCustomOverrides = true; 24 - inherit (vanillaPackages) stdenv; 25 }) 26 27 # Run Packages 28 (buildPackages: { 29 - buildPlatform = localSystem; 30 - hostPlatform = crossSystem; 31 - targetPlatform = crossSystem; 32 inherit config overlays; 33 selfBuild = false; 34 stdenv = buildPackages.makeStdenvCross {
··· 14 15 # Build Packages 16 (vanillaPackages: { 17 inherit config overlays; 18 selfBuild = false; 19 + stdenv = 20 + assert vanillaPackages.hostPlatform == localSystem; 21 + assert vanillaPackages.targetPlatform == localSystem; 22 + vanillaPackages.stdenv.override { targetPlatform = crossSystem; }; 23 # It's OK to change the built-time dependencies 24 allowCustomOverrides = true; 25 }) 26 27 # Run Packages 28 (buildPackages: { 29 inherit config overlays; 30 selfBuild = false; 31 stdenv = buildPackages.makeStdenvCross {
+4 -4
pkgs/stdenv/custom/default.nix
··· 15 16 # Additional stage, built using custom stdenv 17 (vanillaPackages: { 18 - buildPlatform = localSystem; 19 - hostPlatform = localSystem; 20 - targetPlatform = localSystem; 21 inherit config overlays; 22 - stdenv = config.replaceStdenv { pkgs = vanillaPackages; }; 23 }) 24 25 ]
··· 15 16 # Additional stage, built using custom stdenv 17 (vanillaPackages: { 18 inherit config overlays; 19 + stdenv = 20 + assert vanillaPackages.hostPlatform == localSystem; 21 + assert vanillaPackages.targetPlatform == localSystem; 22 + config.replaceStdenv { pkgs = vanillaPackages; }; 23 }) 24 25 ]
+8 -16
pkgs/stdenv/darwin/default.nix
··· 65 66 name = "stdenv-darwin-boot-${toString step}"; 67 68 cc = if isNull last then "/dev/null" else import ../../build-support/cc-wrapper { 69 inherit shell; 70 inherit (last) stdenv; ··· 73 nativeTools = true; 74 nativePrefix = bootstrapTools; 75 nativeLibc = false; 76 - hostPlatform = localSystem; 77 - targetPlatform = localSystem; 78 libc = last.pkgs.darwin.Libsystem; 79 isClang = true; 80 cc = { name = "clang-9.9.9"; outPath = bootstrapTools; }; ··· 90 ''; 91 initialPath = [ bootstrapTools ]; 92 93 - hostPlatform = localSystem; 94 - targetPlatform = localSystem; 95 - 96 fetchurlBoot = import ../../build-support/fetchurl { 97 stdenv = stage0.stdenv; 98 curl = bootstrapTools; ··· 107 }; 108 109 in { 110 - buildPlatform = localSystem; 111 - hostPlatform = localSystem; 112 - targetPlatform = localSystem; 113 inherit config overlays; 114 stdenv = thisStdenv; 115 }; ··· 279 280 name = "stdenv-darwin"; 281 282 preHook = commonPreHook + '' 283 export PATH_LOCALE=${pkgs.darwin.locale}/share/locale 284 ''; ··· 286 stdenvSandboxProfile = binShClosure + libSystemProfile; 287 extraSandboxProfile = binShClosure + libSystemProfile; 288 289 - hostPlatform = localSystem; 290 - targetPlatform = localSystem; 291 - 292 initialPath = import ../common-path.nix { inherit pkgs; }; 293 shell = "${pkgs.bash}/bin/bash"; 294 ··· 297 inherit shell; 298 nativeTools = false; 299 nativeLibc = false; 300 - hostPlatform = localSystem; 301 - targetPlatform = localSystem; 302 inherit (pkgs) coreutils binutils gnugrep; 303 inherit (pkgs.darwin) dyld; 304 cc = pkgs.llvmPackages.clang-unwrapped; ··· 338 stage3 339 stage4 340 (prevStage: { 341 - buildPlatform = localSystem; 342 - hostPlatform = localSystem; 343 - targetPlatform = localSystem; 344 inherit config overlays; 345 stdenv = stdenvDarwin prevStage; 346 })
··· 65 66 name = "stdenv-darwin-boot-${toString step}"; 67 68 + buildPlatform = localSystem; 69 + hostPlatform = localSystem; 70 + targetPlatform = localSystem; 71 + 72 cc = if isNull last then "/dev/null" else import ../../build-support/cc-wrapper { 73 inherit shell; 74 inherit (last) stdenv; ··· 77 nativeTools = true; 78 nativePrefix = bootstrapTools; 79 nativeLibc = false; 80 libc = last.pkgs.darwin.Libsystem; 81 isClang = true; 82 cc = { name = "clang-9.9.9"; outPath = bootstrapTools; }; ··· 92 ''; 93 initialPath = [ bootstrapTools ]; 94 95 fetchurlBoot = import ../../build-support/fetchurl { 96 stdenv = stage0.stdenv; 97 curl = bootstrapTools; ··· 106 }; 107 108 in { 109 inherit config overlays; 110 stdenv = thisStdenv; 111 }; ··· 275 276 name = "stdenv-darwin"; 277 278 + buildPlatform = localSystem; 279 + hostPlatform = localSystem; 280 + targetPlatform = localSystem; 281 + 282 preHook = commonPreHook + '' 283 export PATH_LOCALE=${pkgs.darwin.locale}/share/locale 284 ''; ··· 286 stdenvSandboxProfile = binShClosure + libSystemProfile; 287 extraSandboxProfile = binShClosure + libSystemProfile; 288 289 initialPath = import ../common-path.nix { inherit pkgs; }; 290 shell = "${pkgs.bash}/bin/bash"; 291 ··· 294 inherit shell; 295 nativeTools = false; 296 nativeLibc = false; 297 inherit (pkgs) coreutils binutils gnugrep; 298 inherit (pkgs.darwin) dyld; 299 cc = pkgs.llvmPackages.clang-unwrapped; ··· 333 stage3 334 stage4 335 (prevStage: { 336 inherit config overlays; 337 stdenv = stdenvDarwin prevStage; 338 })
+9 -5
pkgs/stdenv/freebsd/default.nix
··· 35 36 stdenv = import ../generic { 37 name = "stdenv-freebsd-boot-1"; 38 inherit config; 39 initialPath = [ "/" "/usr" ]; 40 hostPlatform = localSystem; ··· 52 53 stdenv = import ../generic { 54 name = "stdenv-freebsd-boot-0"; 55 inherit config; 56 initialPath = [ prevStage.bootstrapTools ]; 57 inherit (prevStage.stdenv) ··· 62 }) 63 64 (prevStage: { 65 - buildPlatform = localSystem; 66 - hostPlatform = localSystem; 67 - targetPlatform = localSystem; 68 inherit config overlays; 69 stdenv = import ../generic { 70 name = "stdenv-freebsd-boot-3"; 71 inherit config; 72 73 inherit (prevStage.stdenv) ··· 77 nativeTools = true; 78 nativePrefix = "/usr"; 79 nativeLibc = true; 80 - hostPlatform = localSystem; 81 - targetPlatform = localSystem; 82 inherit (prevStage) stdenv; 83 cc = { 84 name = "clang-9.9.9";
··· 35 36 stdenv = import ../generic { 37 name = "stdenv-freebsd-boot-1"; 38 + buildPlatform = localSystem; 39 + hostPlatform = localSystem; 40 + targetPlatform = localSystem; 41 inherit config; 42 initialPath = [ "/" "/usr" ]; 43 hostPlatform = localSystem; ··· 55 56 stdenv = import ../generic { 57 name = "stdenv-freebsd-boot-0"; 58 + buildPlatform = localSystem; 59 + hostPlatform = localSystem; 60 + targetPlatform = localSystem; 61 inherit config; 62 initialPath = [ prevStage.bootstrapTools ]; 63 inherit (prevStage.stdenv) ··· 68 }) 69 70 (prevStage: { 71 inherit config overlays; 72 stdenv = import ../generic { 73 name = "stdenv-freebsd-boot-3"; 74 + buildPlatform = localSystem; 75 + hostPlatform = localSystem; 76 + targetPlatform = localSystem; 77 inherit config; 78 79 inherit (prevStage.stdenv) ··· 83 nativeTools = true; 84 nativePrefix = "/usr"; 85 nativeLibc = true; 86 inherit (prevStage) stdenv; 87 cc = { 88 name = "clang-9.9.9";
+31 -14
pkgs/stdenv/generic/default.nix
··· 15 , stdenvSandboxProfile ? "" 16 , extraSandboxProfile ? "" 17 18 - , # 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 25 }: 26 27 let 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; 53 54 builder = shell; 55 ··· 59 60 inherit preHook initialPath shell defaultNativeBuildInputs; 61 } 62 - // lib.optionalAttrs hostPlatform.isDarwin { 63 __sandboxProfile = stdenvSandboxProfile; 64 __impureHostDeps = __stdenvImpureHostDeps; 65 }) ··· 71 platforms = lib.platforms.all; 72 }; 73 74 inherit extraBuildInputs __extraImpureHostDeps extraSandboxProfile; 75 76 # Utility flags to test the type of platform. ··· 85 86 inherit (import ./make-derivation.nix { 87 inherit lib config stdenv; 88 - # TODO(@Ericson2314): Remove 89 - inherit 90 - hostPlatform targetPlatform; 91 }) mkDerivation; 92 93 # For convenience, bring in the library functions in lib/ so
··· 15 , stdenvSandboxProfile ? "" 16 , extraSandboxProfile ? "" 17 18 + ## 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 }: 42 43 let 44 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; 71 72 builder = shell; 73 ··· 77 78 inherit preHook initialPath shell defaultNativeBuildInputs; 79 } 80 + // lib.optionalAttrs buildPlatform.isDarwin { 81 __sandboxProfile = stdenvSandboxProfile; 82 __impureHostDeps = __stdenvImpureHostDeps; 83 }) ··· 89 platforms = lib.platforms.all; 90 }; 91 92 + inherit buildPlatform hostPlatform targetPlatform; 93 + 94 inherit extraBuildInputs __extraImpureHostDeps extraSandboxProfile; 95 96 # Utility flags to test the type of platform. ··· 105 106 inherit (import ./make-derivation.nix { 107 inherit lib config stdenv; 108 }) mkDerivation; 109 110 # 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 - }: 6 7 rec { 8 # `mkDerivation` wraps the builtin `derivation` function to ··· 49 50 outputs' = 51 outputs ++ 52 - (if separateDebugInfo then assert targetPlatform.isLinux; [ "debug" ] else []); 53 54 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 ··· 91 92 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? 143 })) 144 ( { 145 overrideAttrs = f: mkDerivation (attrs // (f attrs));
··· 1 + { lib, config, stdenv }: 2 3 rec { 4 # `mkDerivation` wraps the builtin `derivation` function to ··· 45 46 outputs' = 47 outputs ++ 48 + (if separateDebugInfo then assert stdenv.hostPlatform.isLinux; [ "debug" ] else []); 49 50 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 ··· 87 88 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));
+7 -17
pkgs/stdenv/linux/default.nix
··· 52 let 53 54 thisStdenv = import ../generic { 55 inherit config extraBuildInputs; 56 - name = "stdenv-linux-boot"; 57 preHook = 58 '' 59 # Don't patch #!/interpreter because it leads to retained ··· 64 shell = "${bootstrapTools}/bin/bash"; 65 initialPath = [bootstrapTools]; 66 67 - hostPlatform = localSystem; 68 - targetPlatform = localSystem; 69 - 70 fetchurlBoot = import ../../build-support/fetchurl/boot.nix { 71 inherit system; 72 }; ··· 76 else lib.makeOverridable (import ../../build-support/cc-wrapper) { 77 nativeTools = false; 78 nativeLibc = false; 79 - hostPlatform = localSystem; 80 - targetPlatform = localSystem; 81 cc = prevStage.gcc-unwrapped; 82 isGNU = true; 83 libc = prevStage.glibc; ··· 99 }; 100 101 in { 102 - buildPlatform = localSystem; 103 - hostPlatform = localSystem; 104 - targetPlatform = localSystem; 105 inherit config overlays; 106 stdenv = thisStdenv; 107 }; ··· 241 nativeTools = false; 242 nativeLibc = false; 243 isGNU = true; 244 - hostPlatform = localSystem; 245 - targetPlatform = localSystem; 246 cc = prevStage.gcc-unwrapped; 247 libc = self.glibc; 248 inherit (self) stdenv binutils coreutils gnugrep; ··· 263 # dependency (`nix-store -qR') on bootstrapTools or the first 264 # binutils built. 265 (prevStage: { 266 - buildPlatform = localSystem; 267 - hostPlatform = localSystem; 268 - targetPlatform = localSystem; 269 inherit config overlays; 270 stdenv = import ../generic rec { 271 inherit config; 272 273 preHook = '' ··· 279 280 initialPath = 281 ((import ../common-path.nix) {pkgs = prevStage;}); 282 - 283 - hostPlatform = localSystem; 284 - targetPlatform = localSystem; 285 286 extraBuildInputs = [ prevStage.patchelf prevStage.paxctl ] ++ 287 # Many tarballs come with obsolete config.sub/config.guess that don't recognize aarch64.
··· 52 let 53 54 thisStdenv = import ../generic { 55 + name = "stdenv-linux-boot"; 56 + buildPlatform = localSystem; 57 + hostPlatform = localSystem; 58 + targetPlatform = localSystem; 59 inherit config extraBuildInputs; 60 preHook = 61 '' 62 # Don't patch #!/interpreter because it leads to retained ··· 67 shell = "${bootstrapTools}/bin/bash"; 68 initialPath = [bootstrapTools]; 69 70 fetchurlBoot = import ../../build-support/fetchurl/boot.nix { 71 inherit system; 72 }; ··· 76 else lib.makeOverridable (import ../../build-support/cc-wrapper) { 77 nativeTools = false; 78 nativeLibc = false; 79 cc = prevStage.gcc-unwrapped; 80 isGNU = true; 81 libc = prevStage.glibc; ··· 97 }; 98 99 in { 100 inherit config overlays; 101 stdenv = thisStdenv; 102 }; ··· 236 nativeTools = false; 237 nativeLibc = false; 238 isGNU = true; 239 cc = prevStage.gcc-unwrapped; 240 libc = self.glibc; 241 inherit (self) stdenv binutils coreutils gnugrep; ··· 256 # dependency (`nix-store -qR') on bootstrapTools or the first 257 # binutils built. 258 (prevStage: { 259 inherit config overlays; 260 stdenv = import ../generic rec { 261 + buildPlatform = localSystem; 262 + hostPlatform = localSystem; 263 + targetPlatform = localSystem; 264 inherit config; 265 266 preHook = '' ··· 272 273 initialPath = 274 ((import ../common-path.nix) {pkgs = prevStage;}); 275 276 extraBuildInputs = [ prevStage.patchelf prevStage.paxctl ] ++ 277 # Many tarballs come with obsolete config.sub/config.guess that don't recognize aarch64.
+1 -8
pkgs/stdenv/native/default.nix
··· 81 { cc, fetchurl, extraPath ? [], overrides ? (self: super: { }) }: 82 83 import ../generic { 84 hostPlatform = localSystem; 85 targetPlatform = localSystem; 86 ··· 125 "i686-solaris" = "/usr/gnu"; 126 "x86_64-solaris" = "/opt/local/gcc47"; 127 }.${system} or "/usr"; 128 - hostPlatform = localSystem; 129 - targetPlatform = localSystem; 130 inherit stdenv; 131 }; 132 ··· 140 141 # First build a stdenv based only on tools outside the store. 142 (prevStage: { 143 - buildPlatform = localSystem; 144 - hostPlatform = localSystem; 145 - targetPlatform = localSystem; 146 inherit config overlays; 147 stdenv = makeStdenv { 148 inherit (prevStage) cc fetchurl; ··· 152 # Using that, build a stdenv that adds the ‘xz’ command (which most systems 153 # don't have, so we mustn't rely on the native environment providing it). 154 (prevStage: { 155 - buildPlatform = localSystem; 156 - hostPlatform = localSystem; 157 - targetPlatform = localSystem; 158 inherit config overlays; 159 stdenv = makeStdenv { 160 inherit (prevStage.stdenv) cc fetchurl;
··· 81 { cc, fetchurl, extraPath ? [], overrides ? (self: super: { }) }: 82 83 import ../generic { 84 + buildPlatform = localSystem; 85 hostPlatform = localSystem; 86 targetPlatform = localSystem; 87 ··· 126 "i686-solaris" = "/usr/gnu"; 127 "x86_64-solaris" = "/opt/local/gcc47"; 128 }.${system} or "/usr"; 129 inherit stdenv; 130 }; 131 ··· 139 140 # First build a stdenv based only on tools outside the store. 141 (prevStage: { 142 inherit config overlays; 143 stdenv = makeStdenv { 144 inherit (prevStage) cc fetchurl; ··· 148 # Using that, build a stdenv that adds the ‘xz’ command (which most systems 149 # don't have, so we mustn't rely on the native environment providing it). 150 (prevStage: { 151 inherit config overlays; 152 stdenv = makeStdenv { 153 inherit (prevStage.stdenv) cc fetchurl;
+4 -3
pkgs/stdenv/nix/default.nix
··· 10 (prevStage: let 11 inherit (prevStage) stdenv; 12 in { 13 - inherit (prevStage) buildPlatform hostPlatform targetPlatform; 14 inherit config overlays; 15 16 stdenv = import ../generic rec { 17 inherit config; 18 19 preHook = '' ··· 30 nativeTools = false; 31 nativePrefix = stdenv.lib.optionalString hostPlatform.isSunOS "/usr"; 32 nativeLibc = true; 33 - hostPlatform = localSystem; 34 - targetPlatform = localSystem; 35 inherit stdenv; 36 inherit (prevStage) binutils coreutils gnugrep; 37 cc = prevStage.gcc.cc;
··· 10 (prevStage: let 11 inherit (prevStage) stdenv; 12 in { 13 inherit config overlays; 14 15 stdenv = import ../generic rec { 16 + buildPlatform = localSystem; 17 + hostPlatform = localSystem; 18 + targetPlatform = localSystem; 19 + 20 inherit config; 21 22 preHook = '' ··· 33 nativeTools = false; 34 nativePrefix = stdenv.lib.optionalString hostPlatform.isSunOS "/usr"; 35 nativeLibc = true; 36 inherit stdenv; 37 inherit (prevStage) binutils coreutils gnugrep; 38 cc = prevStage.gcc.cc;
+8 -33
pkgs/top-level/stage.nix
··· 18 , # Use to reevaluate Nixpkgs; a dirty hack that should be removed 19 nixpkgsFun 20 21 - ## 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" 76 77 , # 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 }; 104 105 # 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 }; 114 inherit (buildPlatform) system platform; 115 }; 116
··· 18 , # Use to reevaluate Nixpkgs; a dirty hack that should be removed 19 nixpkgsFun 20 21 ## 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" 52 53 , # The configuration attribute set 54 config ··· 74 // { recurseForDerivations = false; }; 75 __targetPackages = (if __targetPackages == null then self else __targetPackages) 76 // { recurseForDerivations = false; }; 77 + inherit stdenv; 78 }; 79 80 # 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; 84 in { 85 stdenv = super.stdenv // { 86 + inherit (super.stdenv.buildPlatform) platform; 87 }; 88 + inherit buildPlatform hostPlatform targetPlatform; 89 inherit (buildPlatform) system platform; 90 }; 91