Merge pull request #44517 from oxij/stdenv/shadows

stdenv: simplify a bit using shadowing
This commit is contained in:
John Ericson 2018-08-08 15:20:39 -04:00 committed by GitHub
commit fe68c9d450
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 21 deletions

View File

@ -78,6 +78,15 @@ rec {
, ... } @ attrs: , ... } @ attrs:
let let
# TODO(@oxij, @Ericson2314): This is here to keep the old semantics, remove when
# no package has `doCheck = true`.
doCheck' = doCheck && stdenv.hostPlatform == stdenv.buildPlatform;
doInstallCheck' = doInstallCheck && stdenv.hostPlatform == stdenv.buildPlatform;
outputs' =
outputs ++
(if separateDebugInfo then assert stdenv.hostPlatform.isLinux; [ "debug" ] else []);
fixedOutputDrv = attrs ? outputHash; fixedOutputDrv = attrs ? outputHash;
noNonNativeDeps = builtins.length (depsBuildTarget ++ depsBuildTargetPropagated noNonNativeDeps = builtins.length (depsBuildTarget ++ depsBuildTargetPropagated
++ depsHostHost ++ depsHostHostPropagated ++ depsHostHost ++ depsHostHostPropagated
@ -97,6 +106,11 @@ rec {
inherit erroneousHardeningFlags hardeningDisable hardeningEnable supportedHardeningFlags; inherit erroneousHardeningFlags hardeningDisable hardeningEnable supportedHardeningFlags;
}) })
else let else let
doCheck = doCheck';
doInstallCheck = doInstallCheck';
outputs = outputs';
references = nativeBuildInputs ++ buildInputs references = nativeBuildInputs ++ buildInputs
++ propagatedNativeBuildInputs ++ propagatedBuildInputs; ++ propagatedNativeBuildInputs ++ propagatedBuildInputs;
@ -111,7 +125,7 @@ rec {
[ [
(map (drv: drv.__spliced.hostHost or drv) depsHostHost) (map (drv: drv.__spliced.hostHost or drv) depsHostHost)
(map (drv: drv.crossDrv or drv) (buildInputs (map (drv: drv.crossDrv or drv) (buildInputs
++ lib.optionals doCheck' checkInputs ++ lib.optionals doCheck checkInputs
++ lib.optionals doInstallCheck' installCheckInputs)) ++ lib.optionals doInstallCheck' installCheckInputs))
] ]
[ [
@ -133,15 +147,6 @@ rec {
] ]
]; ];
# TODO(@oxij, @Ericson2314): This is here to keep the old semantics, remove when
# no package has `doCheck = true`.
doCheck' = doCheck && stdenv.hostPlatform == stdenv.buildPlatform;
doInstallCheck' = doInstallCheck && stdenv.hostPlatform == stdenv.buildPlatform;
outputs' =
outputs ++
(if separateDebugInfo then assert stdenv.hostPlatform.isLinux; [ "debug" ] else []);
computedSandboxProfile = computedSandboxProfile =
lib.concatMap (input: input.__propagatedSandboxProfile or []) lib.concatMap (input: input.__propagatedSandboxProfile or [])
(stdenv.extraNativeBuildInputs (stdenv.extraNativeBuildInputs
@ -165,7 +170,6 @@ rec {
derivationArg = derivationArg =
(removeAttrs attrs (removeAttrs attrs
["meta" "passthru" "pos" ["meta" "passthru" "pos"
"doCheck" "doInstallCheck"
"checkInputs" "installCheckInputs" "checkInputs" "installCheckInputs"
"__impureHostDeps" "__propagatedImpureHostDeps" "__impureHostDeps" "__propagatedImpureHostDeps"
"sandboxProfile" "propagatedSandboxProfile"]) "sandboxProfile" "propagatedSandboxProfile"])
@ -212,15 +216,11 @@ rec {
++ optional (elem "host" configurePlatforms) "--host=${stdenv.hostPlatform.config}" ++ optional (elem "host" configurePlatforms) "--host=${stdenv.hostPlatform.config}"
++ optional (elem "target" configurePlatforms) "--target=${stdenv.targetPlatform.config}"; ++ optional (elem "target" configurePlatforms) "--target=${stdenv.targetPlatform.config}";
inherit doCheck doInstallCheck;
inherit outputs;
} // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != []) { } // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != []) {
NIX_HARDENING_ENABLE = enabledHardeningOptions; NIX_HARDENING_ENABLE = enabledHardeningOptions;
} // lib.optionalAttrs (outputs' != [ "out" ]) {
outputs = outputs';
} // lib.optionalAttrs doCheck' {
doCheck = true;
} // lib.optionalAttrs doInstallCheck' {
doInstallCheck = true;
} // lib.optionalAttrs (stdenv.buildPlatform.isDarwin) { } // lib.optionalAttrs (stdenv.buildPlatform.isDarwin) {
# TODO: remove lib.unique once nix has a list canonicalization primitive # TODO: remove lib.unique once nix has a list canonicalization primitive
__sandboxProfile = __sandboxProfile =
@ -261,9 +261,8 @@ rec {
# unless they are comfortable with this default. # unless they are comfortable with this default.
outputsToInstall = outputsToInstall =
let let
outs = outputs'; # the value passed to derivation primitive hasOutput = out: builtins.elem out outputs;
hasOutput = out: builtins.elem out outs; in [( lib.findFirst hasOutput null (["bin" "out"] ++ outputs) )];
in [( lib.findFirst hasOutput null (["bin" "out"] ++ outs) )];
} }
// attrs.meta or {} // attrs.meta or {}
# Fill `meta.position` to identify the source location of the package. # Fill `meta.position` to identify the source location of the package.