top-level/stage: abort lazily in internallyDisallowedAttrPathsOverlay - #537799
Conversation
infinisil
left a comment
There was a problem hiding this comment.
Makes sense, especially also because meta.problems only trigger on instantiate!
Instead of replacing internally disallowed attrs entirely with an abort, we now abort lazily on instantiation. This allows evaluating and/or reusing metadata and utilities from problematic packages while still blocking dependencies on their outputs. Not to be confused with `lib.warnOnInstantiate`, which actually warns on almost all usage, not just instantiation. Also: refactored abort message to use `lib.showAttrPath`.
2a18efe to
beefc61
Compare
|
Following the discussion around @infinisil and @llakala, it'd be great if you're able to take another look. |
|
I'd like to land this if there are no objections, but I'm conscious that the implementation has changed since it was reviewed and performance could be better optimised (although performance only affects CI). |
|
Friendly bump; would be great to get some eyeballs on the revised approach! |
|
I'll merge this soon unless anyone objects 🙂 |
|
Sorry for missing this. I'm fine to merge this. To be honest, I disagree with the design behind meta.problems only being allowed for leaf packages - @whispersofthedawn has convinced me that it should be allowed everywhere. But this is a fine incremental improvement. |
Followup to #533376 (comment), I noticed in #522364 that inheriting a problematic package's
versionwas enough to trigger the abort.There's a debate to be had about what kinda relationships should require re-declaring dependencies' problems. My view is that depending on derivation outputs requires declaring a problem, while inheriting metadata from a problem-package could easily be inlined if/when that package is removed, so should not require declaring a problem.
Instead of replacing internally disallowed attrs entirely with an abort, we now lazily abort on access while preserving a small allowlist of metadata attributes.EDIT: After discussion around the intended semantics oflib.warnOnInstantiate, I've changed the implementation to take a different approach.Instead of replacing internally disallowed attrs with an immediate abort, we now abort lazily when a derivation (or one of its outputs) is instantiated. This preserves access to metadata and helper attributes while still preventing dependencies on the derivation's outputs.
Unlike
lib.warnOnInstantiate, this only intercepts instantiation (i.e. evaluation ofdrvPath,outPath,shellPath, or an output's corresponding paths), rather than warning on most interactions with the derivation.I also refactored the abort message to use
lib.showAttrPathinstead ofconcatStringsSep ".", which correctly formats attrpaths containing non-identifier segments.Previous implementation
The original version of this PR preserved access to a small allowlist of attributes (
version,meta,passthru, etc.) by wrapping derivations in a similar fashion tolib.warnOnInstantiate.The current implementation instead preserves the entire derivation object and only aborts at instantiation time, which better matches the intended policy.
Tested in the repl:
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.