stdenv.mkDerivation: support output checks with structuredAttrs

Once __structuredAttrs are enabled, nix only supports
disallowedReferences and friends inside the outputChecks attribute set,
defined specifically for each output.

Top-level disallowedReferences, as used throughout nixpkgs without
structuredAttrs, throws a warning instead:

  warning: In a derivation named 'perl-5.40.0', 'structuredAttrs'
  disables the effect of the derivation attribute
  'disallowedReferences'; use
  'outputChecks.<output>.disallowedReferences' instead

To support a seamless migration to enabling structuredAttrs by default,
those derivation attributes are now mapped to each output separately
when structuredAttrs are enabled.

Since both top-level disallowedReferences and outputChecks can be given
at the same time, those are now merged together. One package that can be
simplified this way is neovim, because all checks should be applied to
all outputs anyway.
This commit is contained in:
Wolfgang Walther
2024-11-25 18:46:07 +01:00
parent 5bff902d5e
commit d37f90a2b3
2 changed files with 9 additions and 14 deletions
+1 -12
View File
@@ -193,18 +193,7 @@ stdenv.mkDerivation (
find "$out" -type f -exec remove-references-to -t ${stdenv.cc} '{}' +
'';
# check that the above patching actually works
outputChecks =
let
disallowedRequisites = [ stdenv.cc ] ++ lib.optional (lua != codegenLua) codegenLua;
in
{
out = {
inherit disallowedRequisites;
};
debug = {
inherit disallowedRequisites;
};
};
disallowedRequisites = [ stdenv.cc ] ++ lib.optional (lua != codegenLua) codegenLua;
cmakeFlags =
[
+8 -2
View File
@@ -493,10 +493,16 @@ else let
"/bin/sh"
];
__propagatedImpureHostDeps = computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps;
}) // (
}) // lib.optionalAttrs (!__structuredAttrs) (
makeOutputChecks attrs
) // lib.optionalAttrs (__structuredAttrs) {
outputChecks = builtins.mapAttrs (_: makeOutputChecks) attrs.outputChecks or {};
outputChecks = builtins.listToAttrs (map (name: {
inherit name;
value = lib.zipAttrsWith (_: builtins.concatLists) [
(makeOutputChecks attrs)
(makeOutputChecks attrs.outputChecks.${name} or {})
];
}) outputs);
};
in