diff options
author | John Ericson <git@JohnEricson.me> | 2019-09-02 01:31:31 -0400 |
---|---|---|
committer | John Ericson <git@JohnEricson.me> | 2019-09-02 01:31:31 -0400 |
commit | c33d80c071927d783bd10943e723ed408ec89e48 (patch) | |
tree | ee0d82edaae37f797995468b8dbd5ce4beffab27 /pkgs/stdenv | |
parent | 446f8c851d599326373a2c910841d092ff8e68ae (diff) | |
parent | 74b42e28b94cc42f93b50c5aeee8794f66795fd0 (diff) |
Merge remote-tracking branch 'upstream/master' into feature/js-unknown-ghcjs
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r-- | pkgs/stdenv/adapters.nix | 16 | ||||
-rw-r--r-- | pkgs/stdenv/booter.nix | 28 | ||||
-rw-r--r-- | pkgs/stdenv/cross/default.nix | 9 | ||||
-rw-r--r-- | pkgs/stdenv/darwin/darwin-secure-format.patch | 15 | ||||
-rw-r--r-- | pkgs/stdenv/darwin/default.nix | 54 | ||||
-rw-r--r-- | pkgs/stdenv/darwin/make-bootstrap-tools.nix | 12 | ||||
-rw-r--r-- | pkgs/stdenv/default.nix | 7 | ||||
-rw-r--r-- | pkgs/stdenv/generic/check-meta.nix | 41 | ||||
-rw-r--r-- | pkgs/stdenv/generic/default.nix | 2 | ||||
-rw-r--r-- | pkgs/stdenv/generic/make-derivation.nix | 30 | ||||
-rw-r--r-- | pkgs/stdenv/generic/setup.sh | 24 | ||||
-rw-r--r-- | pkgs/stdenv/linux/default.nix | 15 |
12 files changed, 149 insertions, 104 deletions
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 7823d6413442d..8f62bd24dda10 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -60,9 +60,23 @@ rec { "--enable-static" "--disable-shared" ]; + mesonFlags = (args.mesonFlags or []) ++ [ "-Ddefault_library=static" ]; }); + static = true; }; + + /* Modify a stdenv so that all buildInputs are implicitly propagated to + consuming derivations + */ + propagateBuildInputs = stdenv: stdenv // + { mkDerivation = args: stdenv.mkDerivation (args // { + propagatedBuildInputs = (args.propagatedBuildInputs or []) ++ (args.buildInputs or []); + buildInputs = []; + }); + }; + + /* Modify a stdenv so that the specified attributes are added to every derivation returned by its mkDerivation function. @@ -128,7 +142,7 @@ rec { with the following function: isFree = license: with builtins; - if isNull license then true + if license == null then true else if isList license then lib.all isFree license else license != "non-free" && license != "unfree"; diff --git a/pkgs/stdenv/booter.nix b/pkgs/stdenv/booter.nix index 7364a586fc2a8..1df05099fbf5e 100644 --- a/pkgs/stdenv/booter.nix +++ b/pkgs/stdenv/booter.nix @@ -43,7 +43,7 @@ stageFuns: let /* "dfold" a ternary function `op' between successive elements of `list' as if it was a doubly-linked list with `lnul' and `rnul` base cases at either - end. In precise terms, `fold op lnul rnul [x_0 x_1 x_2 ... x_n-1]` is the + end. In precise terms, `dfold op lnul rnul [x_0 x_1 x_2 ... x_n-1]` is the same as let @@ -95,13 +95,25 @@ stageFuns: let __hatPackages = nextStage; }; }; - in - if args.__raw or false - then args' - else allPackages ((builtins.removeAttrs args' ["selfBuild"]) // { - buildPackages = if args.selfBuild or true then null else prevStage; - targetPackages = if args.selfBuild or true then null else nextStage; - }); + thisStage = + if args.__raw or false + then args' + else allPackages ((builtins.removeAttrs args' ["selfBuild"]) // { + adjacentPackages = if args.selfBuild or true then null else rec { + pkgsBuildBuild = prevStage.buildPackages; + pkgsBuildHost = prevStage; + pkgsBuildTarget = + if args.stdenv.targetPlatform == args.stdenv.hostPlatform + then pkgsBuildHost + else assert args.stdenv.hostPlatform == args.stdenv.buildPlatform; thisStage; + pkgsHostHost = + if args.stdenv.hostPlatform == args.stdenv.targetPlatform + then thisStage + else assert args.stdenv.buildPlatform == args.stdenv.hostPlatform; pkgsBuildHost; + pkgsTargetTarget = nextStage; + }; + }); + in thisStage; # This is a hack for resolving cross-compiled compilers' run-time # deps. (That is, compilers that are themselves cross-compiled, as diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix index 1c211f890b0c6..4e5c4cc2e8333 100644 --- a/pkgs/stdenv/cross/default.nix +++ b/pkgs/stdenv/cross/default.nix @@ -37,7 +37,8 @@ in lib.init bootStages ++ [ # Run Packages (buildPackages: { inherit config; - overlays = overlays ++ crossOverlays; + overlays = overlays ++ crossOverlays + ++ (if crossSystem.isWasm then [(import ../../top-level/static.nix)] else []); selfBuild = false; stdenv = buildPackages.stdenv.override (old: rec { buildPlatform = localSystem; @@ -53,9 +54,11 @@ in lib.init bootStages ++ [ cc = if crossSystem.useiOSPrebuilt or false then buildPackages.darwin.iosSdkPkgs.clang else if crossSystem.useAndroidPrebuilt or false - then buildPackages."androidndkPkgs_${crossSystem.ndkVer}".gcc + then buildPackages."androidndkPkgs_${crossSystem.ndkVer}".clang else if targetPlatform.isGhcjs then null + else if crossSystem.useLLVM or false + then buildPackages.llvmPackages_8.lldClang else buildPackages.gcc; extraNativeBuildInputs = old.extraNativeBuildInputs @@ -63,7 +66,7 @@ in lib.init bootStages ++ [ (hostPlatform.isLinux && !buildPlatform.isLinux) [ buildPackages.patchelf ] ++ lib.optional - (let f = p: !p.isx86 || p.libc == "musl"; in f hostPlatform && !(f buildPlatform)) + (let f = p: !p.isx86 || p.libc == "musl" || p.libc == "wasilibc" || p.isiOS; in f hostPlatform && !(f buildPlatform)) buildPackages.updateAutotoolsGnuConfigScriptsHook # without proper `file` command, libtool sometimes fails # to recognize 64-bit DLLs diff --git a/pkgs/stdenv/darwin/darwin-secure-format.patch b/pkgs/stdenv/darwin/darwin-secure-format.patch deleted file mode 100644 index b14d8be6ef16a..0000000000000 --- a/pkgs/stdenv/darwin/darwin-secure-format.patch +++ /dev/null @@ -1,15 +0,0 @@ -With format string strictness, High Sierra also enforces that %n isn't used -in dynamic format strings, but we should just disable its use on darwin in -general. - ---- a/lib/vasnprintf.c 2017-06-22 15:19:15.000000000 -0700 -+++ b/lib/vasnprintf.c 2017-06-22 15:20:20.000000000 -0700 -@@ -4869,7 +4869,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t * - #endif - *fbp = dp->conversion; - #if USE_SNPRINTF --# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) -+# if !defined(__APPLE__) && !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) - fbp[1] = '%'; - fbp[2] = 'n'; - fbp[3] = '\0'; diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index b7d8e3ba5236b..b6a488ed2f232 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -32,7 +32,7 @@ in rec { export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}" export NIX_IGNORE_LD_THROUGH_GCC=1 stripAllFlags=" " # the Darwin "strip" command doesn't know "-s" - export MACOSX_DEPLOYMENT_TARGET=10.10 + export MACOSX_DEPLOYMENT_TARGET=10.12 export SDKROOT= export CMAKE_OSX_ARCHITECTURES=x86_64 # Workaround for https://openradar.appspot.com/22671534 on 10.11. @@ -81,7 +81,7 @@ in rec { bintools = { name = "${name}-binutils"; outPath = bootstrapTools; }; }; - cc = if isNull last then "/dev/null" else import ../../build-support/cc-wrapper { + cc = if last == null then "/dev/null" else import ../../build-support/cc-wrapper { inherit shell; inherit (last) stdenvNoCC; @@ -132,9 +132,6 @@ in rec { extraAttrs = { inherit platform; parent = last; - - # This is used all over the place so I figured I'd just leave it here for now - secure-format-patch = ./darwin-secure-format.patch; }; overrides = self: super: (overrides self super) // { fetchurl = thisStdenv.fetchurlBoot; }; }; @@ -158,7 +155,7 @@ in rec { dyld = bootstrapTools; }; - llvmPackages_5 = { + llvmPackages_7 = { libcxx = stdenv.mkDerivation { name = "bootstrap-stage0-libcxx"; phases = [ "installPhase" "fixupPhase" ]; @@ -200,7 +197,11 @@ in rec { python2 = self.python; ninja = super.ninja.override { buildDocs = false; }; - darwin = super.darwin // { cctools = super.darwin.cctools.override { llvm = null; }; }; + darwin = super.darwin // { + cctools = super.darwin.cctools.override { + enableTapiSupport = false; + }; + }; }; in with prevStage; stageFun 1 prevStage { extraPreHook = "export NIX_CFLAGS_COMPILE+=\" -F${bootstrapTools}/Library/Frameworks\""; @@ -260,9 +261,9 @@ in rec { # Avoid pulling in a full python and its extra dependencies for the llvm/clang builds. libxml2 = super.libxml2.override { pythonSupport = false; }; - llvmPackages_5 = super.llvmPackages_5 // (let - libraries = super.llvmPackages_5.libraries.extend (_: _: { - inherit (llvmPackages_5) libcxx libcxxabi; + llvmPackages_7 = super.llvmPackages_7 // (let + libraries = super.llvmPackages_7.libraries.extend (_: _: { + inherit (llvmPackages_7) libcxx libcxxabi; }); in { inherit libraries; } // libraries); @@ -278,8 +279,8 @@ in rec { # enables patchShebangs above. Unfortunately, patchShebangs ignores our $SHELL setting # and instead goes by $PATH, which happens to contain bootstrapTools. So it goes and # patches our shebangs back to point at bootstrapTools. This makes sure bash comes first. - extraNativeBuildInputs = with pkgs; [ xz pkgs.bash ]; - extraBuildInputs = [ pkgs.darwin.CF ]; + extraNativeBuildInputs = with pkgs; [ xz ]; + extraBuildInputs = [ pkgs.darwin.CF pkgs.bash ]; libcxx = pkgs.libcxx; extraPreHook = '' @@ -314,18 +315,20 @@ in rec { ]; }); - llvmPackages_5 = super.llvmPackages_5 // (let - tools = super.llvmPackages_5.tools.extend (llvmSelf: _: { - inherit (llvmPackages_5) llvm clang-unwrapped; + llvmPackages_7 = super.llvmPackages_7 // (let + tools = super.llvmPackages_7.tools.extend (llvmSelf: _: { + clang-unwrapped = llvmPackages_7.clang-unwrapped.override { llvm = llvmSelf.llvm; }; + llvm = llvmPackages_7.llvm.override { libxml2 = self.darwin.libxml2-nopython; }; }); - libraries = super.llvmPackages_5.libraries.extend (llvmSelf: _: { - inherit (llvmPackages_5) libcxx libcxxabi compiler-rt; + libraries = super.llvmPackages_7.libraries.extend (llvmSelf: _: { + inherit (llvmPackages_7) libcxx libcxxabi compiler-rt; }); in { inherit tools libraries; } // tools // libraries); darwin = super.darwin // rec { inherit (darwin) dyld Libsystem libiconv locale; + cctools = super.darwin.cctools.override { enableTapiSupport = false; }; libxml2-nopython = super.libxml2.override { pythonSupport = false; }; CF = super.darwin.CF.override { libxml2 = libxml2-nopython; @@ -335,8 +338,8 @@ in rec { }; in with prevStage; stageFun 4 prevStage { shell = "${pkgs.bash}/bin/bash"; - extraNativeBuildInputs = with pkgs; [ xz pkgs.bash ]; - extraBuildInputs = [ pkgs.darwin.CF ]; + extraNativeBuildInputs = with pkgs; [ xz ]; + extraBuildInputs = [ pkgs.darwin.CF pkgs.bash ]; libcxx = pkgs.libcxx; extraPreHook = '' @@ -353,12 +356,12 @@ in rec { ncurses libffi zlib llvm gmp pcre gnugrep coreutils findutils diffutils patchutils; - llvmPackages_5 = super.llvmPackages_5 // (let - tools = super.llvmPackages_5.tools.extend (_: super: { - inherit (llvmPackages_5) llvm clang-unwrapped; + llvmPackages_7 = super.llvmPackages_7 // (let + tools = super.llvmPackages_7.tools.extend (_: super: { + inherit (llvmPackages_7) llvm clang-unwrapped; }); - libraries = super.llvmPackages_5.libraries.extend (_: _: { - inherit (llvmPackages_5) compiler-rt libcxx libcxxabi; + libraries = super.llvmPackages_7.libraries.extend (_: _: { + inherit (llvmPackages_7) compiler-rt libcxx libcxxabi; }); in { inherit tools libraries; } // tools // libraries); @@ -414,9 +417,6 @@ in rec { inherit platform bootstrapTools; libc = pkgs.darwin.Libsystem; shellPackage = pkgs.bash; - - # This is used all over the place so I figured I'd just leave it here for now - secure-format-patch = ./darwin-secure-format.patch; }; allowedRequisites = (with pkgs; [ diff --git a/pkgs/stdenv/darwin/make-bootstrap-tools.nix b/pkgs/stdenv/darwin/make-bootstrap-tools.nix index 670215a735d74..a299879693c85 100644 --- a/pkgs/stdenv/darwin/make-bootstrap-tools.nix +++ b/pkgs/stdenv/darwin/make-bootstrap-tools.nix @@ -3,7 +3,7 @@ with import pkgspath { inherit system; }; let - llvmPackages = llvmPackages_5; + llvmPackages = llvmPackages_7; in rec { coreutils_ = coreutils.override (args: { # We want coreutils without ACL support. @@ -12,9 +12,7 @@ in rec { singleBinary = false; }); - # We want a version of cctools without LLVM, because the LTO support ends up making - # the bootstrap tools huge and isn't really necessary for bootstrap - cctools_ = darwin.cctools.override { llvm = null; }; + cctools_ = darwin.cctools; # Avoid debugging larger changes for now. bzip2_ = bzip2.override (args: { linkStatic = true; }); @@ -80,14 +78,14 @@ in rec { cp -d ${libxml2.out}/lib/libxml2*.dylib $out/lib # Copy what we need of clang - cp -d ${llvmPackages.clang-unwrapped}/bin/clang $out/bin - cp -d ${llvmPackages.clang-unwrapped}/bin/clang++ $out/bin - cp -d ${llvmPackages.clang-unwrapped}/bin/clang-[0-9].[0-9] $out/bin + cp -d ${llvmPackages.clang-unwrapped}/bin/clang* $out/bin cp -rL ${llvmPackages.clang-unwrapped}/lib/clang $out/lib cp -d ${llvmPackages.libcxx}/lib/libc++*.dylib $out/lib cp -d ${llvmPackages.libcxxabi}/lib/libc++abi*.dylib $out/lib + cp -d ${llvmPackages.llvm.lib}/lib/libLLVM.dylib $out/lib + cp -d ${libffi}/lib/libffi*.dylib $out/lib mkdir $out/include cp -rd ${llvmPackages.libcxx}/include/c++ $out/include diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix index c0bbe24e5219c..1f752f021524a 100644 --- a/pkgs/stdenv/default.nix +++ b/pkgs/stdenv/default.nix @@ -43,7 +43,14 @@ in "x86_64-linux" = stagesLinux; "armv5tel-linux" = stagesLinux; "armv6l-linux" = stagesLinux; + "armv6m-linux" = stagesLinux; + "armv7a-linux" = stagesLinux; "armv7l-linux" = stagesLinux; + "armv7r-linux" = stagesLinux; + "armv7m-linux" = stagesLinux; + "armv8a-linux" = stagesLinux; + "armv8r-linux" = stagesLinux; + "armv8m-linux" = stagesLinux; "aarch64-linux" = stagesLinux; "mipsel-linux" = stagesLinux; "powerpc-linux" = /* stagesLinux */ stagesNative; diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index fe0c8cfad9190..1a96d9b3acf77 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -1,12 +1,13 @@ # Checks derivation meta and attrs for problems (like brokenness, # licenses, etc). -{ lib, config, hostPlatform, meta }: +{ lib, config, hostPlatform }: let # If we're in hydra, we can dispense with the more verbose error # messages and make problems easier to spot. inHydra = config.inHydra or false; + getName = attrs: attrs.name or ("${attrs.pname or "«name-missing»"}-${attrs.version or "«version-missing»"}"); # See discussion at https://github.com/NixOS/nixpkgs/pull/25304#issuecomment-298385426 # for why this defaults to false, but I (@copumpkin) want to default it to true soon. @@ -76,7 +77,7 @@ let showLicense = license: license.shortName or "unknown"; - pos_str = meta.position or "«unknown-file»"; + pos_str = meta: meta.position or "«unknown-file»"; remediation = { unfree = remediate_whitelist "Unfree"; @@ -107,23 +108,23 @@ let You can install it anyway by whitelisting this package, using the following methods: - a) for `nixos-rebuild` you can add ‘${attrs.name or "«name-missing»"}’ to + a) for `nixos-rebuild` you can add ‘${getName attrs}’ to `nixpkgs.config.permittedInsecurePackages` in the configuration.nix, like so: { nixpkgs.config.permittedInsecurePackages = [ - "${attrs.name or "«name-missing»"}" + "${getName attrs}" ]; } b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add - ‘${attrs.name or "«name-missing»"}’ to `permittedInsecurePackages` in + ‘${getName attrs}’ to `permittedInsecurePackages` in ~/.config/nixpkgs/config.nix, like so: { permittedInsecurePackages = [ - "${attrs.name or "«name-missing»"}" + "${getName attrs}" ]; } @@ -134,21 +135,21 @@ let actualOutputs = attrs.outputs or [ "out" ]; missingOutputs = builtins.filter (output: ! builtins.elem output actualOutputs) expectedOutputs; in '' - The package ${attrs.name} has set meta.outputsToInstall to: ${builtins.concatStringsSep ", " expectedOutputs} + The package ${getName attrs} has set meta.outputsToInstall to: ${builtins.concatStringsSep ", " expectedOutputs} - however ${attrs.name} only has the outputs: ${builtins.concatStringsSep ", " actualOutputs} + however ${getName attrs} only has the outputs: ${builtins.concatStringsSep ", " actualOutputs} and is missing the following ouputs: ${lib.concatStrings (builtins.map (output: " - ${output}\n") missingOutputs)} ''; - handleEvalIssue = attrs: { reason , errormsg ? "" }: + handleEvalIssue = { meta, attrs }: { reason , errormsg ? "" }: let msg = if inHydra - then "Failed to evaluate ${attrs.name or "«name-missing»"}: «${reason}»: ${errormsg}" + then "Failed to evaluate ${getName attrs}: «${reason}»: ${errormsg}" else '' - Package ‘${attrs.name or "«name-missing»"}’ in ${pos_str} ${errormsg}, refusing to evaluate. + Package ‘${getName attrs}’ in ${pos_str meta} ${errormsg}, refusing to evaluate. '' + (builtins.getAttr reason remediation) attrs; @@ -165,10 +166,11 @@ let branch = str; homepage = either (listOf str) str; downloadPage = str; + changelog = either (listOf str) str; license = either (listOf lib.types.attrs) (either lib.types.attrs str); maintainers = listOf (attrsOf str); priority = int; - platforms = listOf (either str lib.systems.parsedPlatform.types.system); + platforms = listOf str; hydraPlatforms = listOf str; broken = bool; # TODO: refactor once something like Profpatsch's types-simple will land @@ -209,11 +211,6 @@ let else "key '${k}' is unrecognized; expected one of: \n\t [${lib.concatMapStringsSep ", " (x: "'${x}'") (lib.attrNames metaTypes)}]"; checkMeta = meta: if shouldCheckMeta then lib.remove null (lib.mapAttrsToList checkMetaAttr meta) else []; - checkPlatform = attrs: let - anyMatch = lib.any (lib.meta.platformMatch hostPlatform); - in anyMatch (attrs.meta.platforms or lib.platforms.all) && - ! anyMatch (attrs.meta.badPlatforms or []); - checkOutputsToInstall = attrs: let expectedOutputs = attrs.meta.outputsToInstall or []; actualOutputs = attrs.outputs or [ "out" ]; @@ -235,8 +232,10 @@ let { valid = false; reason = "blacklisted"; errormsg = "has a blacklisted license (‘${showLicense attrs.meta.license}’)"; } else if !allowBroken && attrs.meta.broken or false then { valid = false; reason = "broken"; errormsg = "is marked as broken"; } - else if !allowUnsupportedSystem && !(checkPlatform attrs) then - { valid = false; reason = "unsupported"; errormsg = "is not supported on ‘${hostPlatform.config}’"; } + else if !allowUnsupportedSystem && + (!lib.lists.elem hostPlatform.system (attrs.meta.platforms or lib.platforms.all) || + lib.lists.elem hostPlatform.system (attrs.meta.badPlatforms or [])) then + { valid = false; reason = "unsupported"; errormsg = "is not supported on ‘${hostPlatform.system}’"; } else if !(hasAllowedInsecure attrs) then { valid = false; reason = "insecure"; errormsg = "is marked as insecure"; } else if checkOutputsToInstall attrs then @@ -245,12 +244,12 @@ let { valid = false; reason = "unknown-meta"; errormsg = "has an invalid meta attrset:${lib.concatMapStrings (x: "\n\t - " + x) res}"; } else { valid = true; }; - assertValidity = attrs: let + assertValidity = { meta, attrs }: let validity = checkValidity attrs; in validity // { # Throw an error if trying to evaluate an non-valid derivation handled = if !validity.valid - then handleEvalIssue attrs (removeAttrs validity ["valid"]) + then handleEvalIssue { inherit meta attrs; } (removeAttrs validity ["valid"]) else true; }; diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index 04117de326932..1ef2ab52029b4 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -88,7 +88,7 @@ let # there (yet?) so it goes here until then. preHook = preHook+ lib.optionalString buildPlatform.isDarwin '' export NIX_BUILD_DONT_SET_RPATH=1 - '' + lib.optionalString hostPlatform.isDarwin '' + '' + lib.optionalString (hostPlatform.isDarwin || (hostPlatform.parsed.kernel.execFormat != lib.systems.parse.execFormats.elf && hostPlatform.parsed.kernel.execFormat != lib.systems.parse.execFormats.macho)) '' export NIX_DONT_SET_RPATH=1 export NIX_NO_SELF_RPATH=1 '' diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index cafd1031ab8b9..a11b280b047ee 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -1,6 +1,13 @@ { lib, config, stdenv }: -rec { +let + checkMeta = import ./check-meta.nix { + inherit lib config; + # Nix itself uses the `system` field of a derivation to decide where + # to build it. This is a bit confusing for cross compilation. + inherit (stdenv) hostPlatform; + }; +in rec { # `mkDerivation` wraps the builtin `derivation` function to # produce derivations that use this stdenv and its shell. # @@ -70,6 +77,7 @@ rec { else builtins.unsafeGetAttrPos "name" attrs) , separateDebugInfo ? false , outputs ? [ "out" ] + , __darwinAllowLocalNetworking ? false , __impureHostDeps ? [] , __propagatedImpureHostDeps ? [] , sandboxProfile ? "" @@ -78,6 +86,8 @@ rec { , hardeningEnable ? [] , hardeningDisable ? [] + , patches ? [] + , ... } @ attrs: let @@ -86,10 +96,9 @@ rec { doCheck' = doCheck && stdenv.hostPlatform == stdenv.buildPlatform; doInstallCheck' = doInstallCheck && stdenv.hostPlatform == stdenv.buildPlatform; - separateDebugInfo' = separateDebugInfo && stdenv.hostPlatform.isLinux; + separateDebugInfo' = separateDebugInfo && stdenv.hostPlatform.isLinux && !(stdenv.hostPlatform.useLLVM or false); outputs' = outputs ++ lib.optional separateDebugInfo' "debug"; - fixedOutputDrv = attrs ? outputHash; noNonNativeDeps = builtins.length (depsBuildTarget ++ depsBuildTargetPropagated ++ depsHostHost ++ depsHostHostPropagated ++ buildInputs ++ propagatedBuildInputs @@ -175,6 +184,7 @@ rec { (removeAttrs attrs ["meta" "passthru" "pos" "checkInputs" "installCheckInputs" + "__darwinAllowLocalNetworking" "__impureHostDeps" "__propagatedImpureHostDeps" "sandboxProfile" "propagatedSandboxProfile"]) // (lib.optionalAttrs (!(attrs ? name) && attrs ? pname && attrs ? version)) { @@ -226,6 +236,8 @@ rec { ++ optional (elem "host" configurePlatforms) "--host=${stdenv.hostPlatform.config}" ++ optional (elem "target" configurePlatforms) "--target=${stdenv.targetPlatform.config}"; + inherit patches; + inherit doCheck doInstallCheck; inherit outputs; @@ -234,7 +246,7 @@ rec { (/**/ if lib.isString cmakeFlags then [cmakeFlags] else if cmakeFlags == null then [] else cmakeFlags) - ++ lib.optional (stdenv.hostPlatform.uname.system != null) "-DCMAKE_SYSTEM_NAME=${stdenv.hostPlatform.uname.system}" + ++ [ "-DCMAKE_SYSTEM_NAME=${lib.findFirst lib.isString "Generic" [ stdenv.hostPlatform.uname.system ]}" ] ++ lib.optional (stdenv.hostPlatform.uname.processor != null) "-DCMAKE_SYSTEM_PROCESSOR=${stdenv.hostPlatform.uname.processor}" ++ lib.optional (stdenv.hostPlatform.uname.release != null) "-DCMAKE_SYSTEM_VERSION=${stdenv.hostPlatform.release}" ++ lib.optional (stdenv.buildPlatform.uname.system != null) "-DCMAKE_HOST_SYSTEM_NAME=${stdenv.buildPlatform.uname.system}" @@ -244,7 +256,10 @@ rec { enableParallelChecking = attrs.enableParallelChecking or true; } // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != []) { NIX_HARDENING_ENABLE = enabledHardeningOptions; + } // lib.optionalAttrs (stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform ? platform.gcc.arch) { + requiredSystemFeatures = attrs.requiredSystemFeatures or [] ++ [ "gccarch-${stdenv.hostPlatform.platform.gcc.arch}" ]; } // lib.optionalAttrs (stdenv.buildPlatform.isDarwin) { + inherit __darwinAllowLocalNetworking; # TODO: remove lib.unique once nix has a list canonicalization primitive __sandboxProfile = let profiles = [ stdenv.extraSandboxProfile ] ++ computedSandboxProfile ++ computedPropagatedSandboxProfile ++ [ propagatedSandboxProfile sandboxProfile ]; @@ -260,12 +275,7 @@ rec { __propagatedImpureHostDeps = computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps; }; - validity = import ./check-meta.nix { - inherit lib config meta; - # Nix itself uses the `system` field of a derivation to decide where - # to build it. This is a bit confusing for cross compilation. - inherit (stdenv) hostPlatform; - } attrs; + validity = checkMeta { inherit meta attrs; }; # The meta attribute is passed in the resulting attribute set, # but it's not part of the actual derivation, i.e., it's not diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 8dff355780710..ebcedce60b87a 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -182,10 +182,8 @@ addToSearchPathWithCustomDelimiter() { fi } -PATH_DELIMITER=':' - addToSearchPath() { - addToSearchPathWithCustomDelimiter "${PATH_DELIMITER}" "$@" + addToSearchPathWithCustomDelimiter ":" "$@" } # Add $1/lib* into rpaths. @@ -508,7 +506,7 @@ activatePackage() { fi if [[ "$hostOffset" -eq 0 && -d "$pkg/bin" ]]; then - addToSearchPath HOST_PATH "$pkg/bin" + addToSearchPath _HOST_PATH "$pkg/bin" fi if [[ -f "$pkg/nix-support/setup-hook" ]]; then @@ -617,10 +615,15 @@ fi PATH="${_PATH-}${_PATH:+${PATH:+:}}$PATH" +HOST_PATH="${_HOST_PATH-}${_HOST_PATH:+${HOST_PATH:+:}}$HOST_PATH" if (( "${NIX_DEBUG:-0}" >= 1 )); then echo "final path: $PATH" + echo "final host path: $HOST_PATH" fi +unset _PATH +unset _HOST_PATH + # Make GNU Make produce nested output. export NIX_INDENT_MAKE=1 @@ -643,10 +646,13 @@ fi export NIX_BUILD_CORES -# Prevent OpenSSL-based applications from using certificates in -# /etc/ssl. -# Leave it in shells for convenience. -if [ -z "${SSL_CERT_FILE:-}" ] && [ -z "${IN_NIX_SHELL:-}" ]; then +# Prevent SSL libraries from using certificates in /etc/ssl, unless set explicitly. +# Leave it in impure shells for convenience. +if [ -z "${NIX_SSL_CERT_FILE:-}" ] && [ "${IN_NIX_SHELL:-}" != "impure" ]; then + export NIX_SSL_CERT_FILE=/no-cert-file.crt +fi +# Another variant left for compatibility. +if [ -z "${SSL_CERT_FILE:-}" ] && [ "${IN_NIX_SHELL:-}" != "impure" ]; then export SSL_CERT_FILE=/no-cert-file.crt fi @@ -1277,6 +1283,8 @@ genericBuild() { fi for curPhase in $phases; do + if [[ "$curPhase" = unpackPhase && -n "${dontUnpack:-}" ]]; then continue; fi + if [[ "$curPhase" = configurePhase && -n "${dontConfigure:-}" ]]; then continue; fi if [[ "$curPhase" = buildPhase && -n "${dontBuild:-}" ]]; then continue; fi if [[ "$curPhase" = checkPhase && -z "${doCheck:-}" ]]; then continue; fi if [[ "$curPhase" = installPhase && -n "${dontInstall:-}" ]]; then continue; fi diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 12bf781de709f..390c7f1123ecc 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -25,10 +25,19 @@ "powerpc64le-linux" = import ./bootstrap-files/ppc64le-musl.nix; }; }; + + # Try to find an architecture compatible with our current system. We + # just try every bootstrap we’ve got and test to see if it is + # compatible with or current architecture. + getCompatibleTools = lib.foldl (v: system: + if v != null then v + else if localSystem.isCompatible (lib.systems.elaborate { inherit system; }) then archLookupTable.${system} + else null) null (lib.attrNames archLookupTable); + archLookupTable = table.${localSystem.libc} or (abort "unsupported libc for the pure Linux stdenv"); - files = archLookupTable.${localSystem.system} - or (abort "unsupported platform for the pure Linux stdenv"); + files = archLookupTable.${localSystem.system} or (if getCompatibleTools != null then getCompatibleTools + else (abort "unsupported platform for the pure Linux stdenv")); in files }: @@ -87,7 +96,7 @@ let inherit system; }; - cc = if isNull prevStage.gcc-unwrapped + cc = if prevStage.gcc-unwrapped == null then null else lib.makeOverridable (import ../../build-support/cc-wrapper) { name = "${name}-gcc-wrapper"; |