Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pkgs/stdenv/generic/make-derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ let
elemAt
extendDerivation
filter
filterAttrs
getDev
head
imap1
Expand Down Expand Up @@ -709,8 +710,12 @@ let
];
}
// (
let
attrsOutputChecks = makeOutputChecks attrs;
attrsOutputChecksFiltered = filterAttrs (_: v: v != null) attrsOutputChecks;
in
if !__structuredAttrs then
makeOutputChecks attrs
attrsOutputChecks
else
{
outputChecks = builtins.listToAttrs (
Expand All @@ -719,7 +724,7 @@ let
value =
let
raw = zipAttrsWith (_: builtins.concatLists) [
(makeOutputChecks attrs)
attrsOutputChecksFiltered
(makeOutputChecks attrs.outputChecks.${name} or { })
];
Comment on lines 726 to 729
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to imagine when setting allowedRe... = null is useful - and I think it only makes sense when overriding attrs, right?

But consider this:

mkDerivation {
  __structuredAttrs = true;
  outputChecks.allowedRequisites = [ foo ];
}

When overriding this with allowedRequisites = null;, it will not have the intended effect - foo will still be in there.

When overriding attrs of a structuredAttrs-enabled derivation, then you just need to override outputChecks.... and not the non-structured-attrs variant.

We only have this compatibility hack to be able to create derivations that don't specify __structuredAttrs at all, i.e. rely on the default, and will then still work when flipping the default later.

I think we don't need to support overrideAttrs for this thing - it's discouraged from using inside Nixpkgs anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a package with { allowedRequisites = [ ... ]; }, and I want to override it so to be { __structuredAttrs = true; }; it would then be helpful to cancel the top-level allowedRequisites with null.

in
Expand Down
10 changes: 10 additions & 0 deletions pkgs/test/overriding.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ let
}).pname;
expected = "hello-no-final-attrs-overridden";
};
structuredAttrs-allowedRequisites-nullability = {
expr =
lib.hasPrefix builtins.storeDir
(pkgs.stdenv.mkDerivation {
__structuredAttrs = true;
inherit (pkgs.hello) pname version src;
allowedRequisites = null;
}).drvPath;
expected = true;
};
};

test-extendMkDerivation =
Expand Down
Loading