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