stdenv: define is* predicates with hostPlatform.is*

This is a saner default until stdenv's are removed altogether

+50 -59
+9 -2
pkgs/stdenv/darwin/default.nix
··· 61 61 allowedRequisites ? null}: 62 62 let 63 63 thisStdenv = import ../generic { 64 - inherit system config shell extraBuildInputs allowedRequisites; 64 + inherit config shell extraBuildInputs allowedRequisites; 65 65 66 66 name = "stdenv-darwin-boot-${toString step}"; 67 67 ··· 87 87 ${extraPreHook} 88 88 ''; 89 89 initialPath = [ bootstrapTools ]; 90 + 91 + hostPlatform = localSystem; 92 + targetPlatform = localSystem; 93 + 90 94 fetchurlBoot = import ../../build-support/fetchurl { 91 95 stdenv = stage0.stdenv; 92 96 curl = bootstrapTools; ··· 268 272 }; 269 273 270 274 stdenvDarwin = prevStage: let pkgs = prevStage; in import ../generic rec { 271 - inherit system config; 275 + inherit config; 272 276 inherit (pkgs.stdenv) fetchurlBoot; 273 277 274 278 name = "stdenv-darwin"; ··· 279 283 280 284 stdenvSandboxProfile = binShClosure + libSystemProfile; 281 285 extraSandboxProfile = binShClosure + libSystemProfile; 286 + 287 + hostPlatform = localSystem; 288 + targetPlatform = localSystem; 282 289 283 290 initialPath = import ../common-path.nix { inherit pkgs; }; 284 291 shell = "${pkgs.bash}/bin/bash";
+8 -5
pkgs/stdenv/freebsd/default.nix
··· 35 35 36 36 stdenv = import ../generic { 37 37 name = "stdenv-freebsd-boot-1"; 38 - inherit system config; 38 + inherit config; 39 39 initialPath = [ "/" "/usr" ]; 40 + hostPlatform = localSystem; 41 + targetPlatform = localSystem; 40 42 shell = "${bootstrapTools}/bin/bash"; 41 43 fetchurlBoot = null; 42 44 cc = null; ··· 50 52 51 53 stdenv = import ../generic { 52 54 name = "stdenv-freebsd-boot-0"; 53 - inherit system config; 55 + inherit config; 54 56 initialPath = [ prevStage.bootstrapTools ]; 55 - inherit (prevStage.stdenv) shell; 57 + inherit (prevStage.stdenv) 58 + hostPlatform targetPlatform shell; 56 59 fetchurlBoot = prevStage.fetchurl; 57 60 cc = null; 58 61 }; ··· 65 68 inherit config overlays; 66 69 stdenv = import ../generic { 67 70 name = "stdenv-freebsd-boot-3"; 68 - inherit system config; 71 + inherit config; 69 72 70 73 inherit (prevStage.stdenv) 71 - initialPath shell fetchurlBoot; 74 + hostPlatform targetPlatform initialPath shell fetchurlBoot; 72 75 73 76 cc = import ../../build-support/cc-wrapper { 74 77 nativeTools = true;
+20 -48
pkgs/stdenv/generic/default.nix
··· 1 1 let lib = import ../../../lib; in lib.makeOverridable ( 2 2 3 - { system, name ? "stdenv", preHook ? "", initialPath, cc, shell 3 + { name ? "stdenv", preHook ? "", initialPath, cc, shell 4 4 , allowedRequisites ? null, extraAttrs ? {}, overrides ? (self: super: {}), config 5 5 6 6 , # The `fetchurl' to use for downloading curl and its dependencies ··· 14 14 , __extraImpureHostDeps ? [] 15 15 , stdenvSandboxProfile ? "" 16 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 17 25 }: 18 26 19 27 let 28 + inherit (targetPlatform) system; 20 29 21 30 # See discussion at https://github.com/NixOS/nixpkgs/pull/25304#issuecomment-298385426 22 31 # for why this defaults to false, but I (@copumpkin) want to default it to true soon. ··· 265 274 266 275 outputs' = 267 276 outputs ++ 268 - (if separateDebugInfo then assert result.isLinux; [ "debug" ] else []); 277 + (if separateDebugInfo then assert targetPlatform.isLinux; [ "debug" ] else []); 269 278 270 279 buildInputs' = lib.chooseDevOutputs buildInputs ++ 271 280 (if separateDebugInfo then [ ../../build-support/setup-hooks/separate-debug-info.sh ] else []); ··· 311 320 # Inputs built by the usual native compiler. 312 321 nativeBuildInputs = nativeBuildInputs' 313 322 ++ lib.optional 314 - (result.isCygwin 323 + (hostPlatform.isCygwin 315 324 || (crossConfig != null && lib.hasSuffix "mingw32" crossConfig)) 316 325 ../../build-support/setup-hooks/win-dll-link.sh 317 326 ; ··· 392 401 }; 393 402 394 403 # Utility flags to test the type of platform. 395 - isDarwin = system == "x86_64-darwin"; 396 - isLinux = system == "i686-linux" 397 - || system == "x86_64-linux" 398 - || system == "powerpc-linux" 399 - || system == "armv5tel-linux" 400 - || system == "armv6l-linux" 401 - || system == "armv7l-linux" 402 - || system == "aarch64-linux" 403 - || system == "mips64el-linux"; 404 - isGNU = system == "i686-gnu"; # GNU/Hurd 405 - isSunOS = system == "i686-solaris" 406 - || system == "x86_64-solaris"; 407 - isCygwin = system == "i686-cygwin" 408 - || system == "x86_64-cygwin"; 409 - isFreeBSD = system == "i686-freebsd" 410 - || system == "x86_64-freebsd"; 411 - isOpenBSD = system == "i686-openbsd" 412 - || system == "x86_64-openbsd"; 413 - isi686 = system == "i686-linux" 414 - || system == "i686-gnu" 415 - || system == "i686-freebsd" 416 - || system == "i686-openbsd" 417 - || system == "i686-cygwin" 418 - || system == "i386-sunos"; 419 - isx86_64 = system == "x86_64-linux" 420 - || system == "x86_64-darwin" 421 - || system == "x86_64-freebsd" 422 - || system == "x86_64-openbsd" 423 - || system == "x86_64-cygwin" 424 - || system == "x86_64-solaris"; 425 - is64bit = system == "x86_64-linux" 426 - || system == "x86_64-darwin" 427 - || system == "x86_64-freebsd" 428 - || system == "x86_64-openbsd" 429 - || system == "x86_64-cygwin" 430 - || system == "x86_64-solaris" 431 - || system == "aarch64-linux" 432 - || system == "mips64el-linux"; 433 - isMips = system == "mips-linux" 434 - || system == "mips64el-linux"; 435 - isArm = system == "armv5tel-linux" 436 - || system == "armv6l-linux" 437 - || system == "armv7l-linux"; 438 - isAarch64 = system == "aarch64-linux"; 439 - isBigEndian = system == "powerpc-linux"; 404 + inherit (hostPlatform) 405 + isDarwin isLinux isSunOS isCygwin isFreeBSD isOpenBSD isi686 isx86_64 406 + is64bit isMips isBigEndian; 407 + isArm = hostPlatform.isArm32; 408 + isAarch64 = hostPlatform.isArm64; 409 + # Other code instead checks for anything using GNU userland, 410 + # e.g. GNU/linux. This refers just to GNU Hurd. 411 + isGNU = system == "i686-gnu"; 440 412 441 413 # Whether we should run paxctl to pax-mark binaries. 442 414 needsPax = isLinux;
+8 -2
pkgs/stdenv/linux/default.nix
··· 52 52 let 53 53 54 54 thisStdenv = import ../generic { 55 - inherit system config extraBuildInputs; 55 + inherit config extraBuildInputs; 56 56 name = "stdenv-linux-boot"; 57 57 preHook = 58 58 '' ··· 63 63 ''; 64 64 shell = "${bootstrapTools}/bin/bash"; 65 65 initialPath = [bootstrapTools]; 66 + 67 + hostPlatform = localSystem; 68 + targetPlatform = localSystem; 66 69 67 70 fetchurlBoot = import ../../build-support/fetchurl/boot.nix { 68 71 inherit system; ··· 261 264 targetPlatform = localSystem; 262 265 inherit config overlays; 263 266 stdenv = import ../generic rec { 264 - inherit system config; 267 + inherit config; 265 268 266 269 preHook = '' 267 270 # Make "strip" produce deterministic output, by setting ··· 272 275 273 276 initialPath = 274 277 ((import ../common-path.nix) {pkgs = prevStage;}); 278 + 279 + hostPlatform = localSystem; 280 + targetPlatform = localSystem; 275 281 276 282 extraBuildInputs = [ prevStage.patchelf prevStage.paxctl ] ++ 277 283 # Many tarballs come with obsolete config.sub/config.guess that don't recognize aarch64.
+3
pkgs/stdenv/native/default.nix
··· 81 81 { cc, fetchurl, extraPath ? [], overrides ? (self: super: { }) }: 82 82 83 83 import ../generic { 84 + hostPlatform = localSystem; 85 + targetPlatform = localSystem; 86 + 84 87 preHook = 85 88 if system == "i686-freebsd" then prehookFreeBSD else 86 89 if system == "x86_64-freebsd" then prehookFreeBSD else
+2 -2
pkgs/stdenv/nix/default.nix
··· 24 24 25 25 initialPath = (import ../common-path.nix) { pkgs = prevStage; }; 26 26 27 - system = stdenv.system; 27 + inherit (prevStage.stdenv) hostPlatform targetPlatform; 28 28 29 29 cc = import ../../build-support/cc-wrapper { 30 30 nativeTools = false; 31 - nativePrefix = stdenv.lib.optionalString stdenv.isSunOS "/usr"; 31 + nativePrefix = stdenv.lib.optionalString hostPlatform.isSunOS "/usr"; 32 32 nativeLibc = true; 33 33 inherit stdenv; 34 34 inherit (prevStage) binutils coreutils gnugrep;