-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stdenv.mkDerivation: support output checks with and without structuredAttrs #357054
stdenv.mkDerivation: support output checks with and without structuredAttrs #357054
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sgtm 👍
This just moves the code around a little bit to be able to build on it in follow up commits without too much of a diff. Adding to removedOrReplacedAttrNames is just a cleanup right now and doesn't change anything functionally, yet. This will be required for later on to avoid having structured outputChecks and those directly on the derivation at the same time.
…hecks This was added for non-structuredAttrs output checks in NixOS#211783. Here we extend the same concept to structuredAttrs-enabled outputChecks, too. The postgresql package worked around this with some conditionals. Those can now be removed - without causing LLVM to be built or substituted.
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.
c87e982
to
d37f90a
Compare
Rebased to target staging, because of the number of rebuilds. |
re rebuilds: IIUC, those are caused by adding empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me.
}) // lib.optionalAttrs (!__structuredAttrs) ( | ||
makeOutputChecks attrs | ||
) // lib.optionalAttrs (__structuredAttrs) { | ||
outputChecks = builtins.listToAttrs (map (name: { | ||
inherit name; | ||
value = lib.zipAttrsWith (_: builtins.concatLists) [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The functions should be inherited from lib at the top of the file for improved perf
How can I run those performance tests myself?
What else should I be looking at, then? In general: Is there some documentation somewhere on writing performant nix code for such heavily used code paths as |
With a recent enough nix, there will be an eval warning when building a derivation with
__structuredAttrs = true
and e.g.disallowedReferences = ..
. With structuredAttrs, nix expects those split up inoutputChecks.<output>.disallowedReferences
etc. instead.To allow derivations to support both structuredAttrs enabled and disabled during a transition period, this PR maps top-level
disallowedReferences
and friends to each output'soutputChecks
. This has the nice side-effect that it is possible to define checks which should apply to all outputs at the top-level, and extend them with output-specific checks as well.While on it, we also apply the same fix that #211783 did to those structured
outputChecks
, which had not been the case before.Part of the overall effort to enable structuredAttrs by default eventually, tracking: #205690
Marking as draft for now, because I intend to add some tests as well.It's really annoying to write tests for this, because we effectively need to test anix-build
failure :/Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.