-
-
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
Reduce warning spam from nix search
#355271
Conversation
f5f0b59
to
d3de41f
Compare
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.
Nice, this improves the UX !
lib/derivations.nix
Outdated
|
||
::: | ||
*/ | ||
wrapWithWarn = |
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.
I'm ok for this to be top level in lib
, but then a slightly more specific name would be nice.
Starting with warn
makes it more discoverable in the repl.
How about warnOnInstantiate
or warnOutputs
?
(well, depends on the outcome of the other comment - maybe skip this one for now)
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.
I've switched to warnOnInstantiate
at least for now, I agree that starting with warn
is nice.
|
||
/** | ||
Wrap a derivation such that instantiating it produces a warning. | ||
|
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.
Maybe also wrap override
and overrideAttrs
if they exist? That doesn't cover all possible overriding functions (passthru.withFoo = finalAttrs.finalPackage.overrideAttrs ...;
) but that's quite rare.
Perhaps it'd be better to cover all attributes except like meta
, name
and type
?
Regardless of what works best, it would be good to document how it works.
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.
Changed it to wrap everything except those three attributes. Also added a sentence on what exactly it does, and a hint that it's related to nix search
.
lib/derivations.nix
Outdated
::: | ||
*/ | ||
wrapWithWarn = | ||
msg: pkg: |
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.
Since package is not as well defined as a derivation is. And you also call it 'The derivation to wrap.' in your docs.
msg: pkg: | |
msg: drv: |
Or did you really mean package? This includes derivations that are built by mkDerivation
rather than only builtins.derivation
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.
I think it's good to talk about these things as packages at the language level, because of the package attrset definition, but until packages and derivations are untangled in more places I don't expect anyone to get it right anyway, if there even is such a thing as right (before more untangling, e.g. NixOS/nix#6507, Nixpkgs code for rfc 92 dynamic derivations, etc).
(Also let's not make a fuss about it until that stuff is more relevant in Nixpkgs. I'm already oversharing.)
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.
Changed to drv
– may as well be consistent.
lib/derivations.nix
Outdated
// { | ||
drvPath = lib.warn msg pkg.drvPath; | ||
} | ||
// builtins.listToAttrs ( |
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.
This reminds me of
instead of adding a new default output here pkgs.outputs or [ "out" ]
i would map over the existing list
pkg.all
which is an empty list.
Your current line assumes there must be some default output added called "out"
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.
pkg.outputs
is the correct source of truth here.
all
only has the values, and you can't get the output attribute name from those, or at least not without questionable code with many assumptions.
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.
I think this is not relevant if we just wrap (almost) all attributes, rather than specifically targetting outputs.
May I ask why we're showing aliases in search tooling in the first place? Given that these are removed frequently it seems better to not show them in the first place (unless explicitly enabled perhaps). Like, please don't consider this comment blocking, this seems like a reasonable (and probably quicker) fix. But to me it seems we have an underlying issue here. |
@Ma27 great question. This is a problem at the interface between Nix and Nixpkgs. As far as I know, we currently don't have a good way to make explicit that an attribute or package is an alias. Some ideas: A
A special attribute in the package set, e.g.
|
d3de41f
to
9016686
Compare
@sersorrel can you rebase this? Keeping this open for too long will require continous rebases. And this is a nice improvement already. |
9016686
to
7d1dc69
Compare
rebased. now we see only the |
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.
Found a small simplification, but let's get this in first, so we don't get more conflicts.
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.
No need to wait for ofborg evaluation anymore, since we have the new GitHub Action-based evaluation now :)
This LGTM! I say let's merge this while it's hot and do the simplification in a new PR
7d1dc69
to
bc4353b
Compare
bc4353b
to
c62f9b2
Compare
Wow, this is great! |
When you
nix search nixpkgs
for the first time (or usenix-env -u
), you get an enormous number of warnings printed due to renamed or deprecated packages, like:There seems to be no appetite on the Nix side to hide these warnings when doing a search (2024-08-21 Nix team meeting minutes), so let's work around the problem in Nixpkgs instead.
The approach I take is to modify a few attributes of the wrapped derivation so that they emit a warning when evaluated: each of the outputs, as well as
drvPath
, is wrapped withlib.warn
. This is in contrast to the current approach, where evaluating the derivation itself (to do things like "find its name and version", which are necessary fornix search
) causes the warning.Outstanding issues:
cudaPackages
is currently wrapped in alib.warn
, andwriteReferencesToFile
(a function) is as well, so these warnings persist after this PR.drvPath
works here or if it's the right thing to do. In trace: warning while doing nix-env -u #306276 (comment), @roberth suggested instead wrappingoutPath
, but for me this didn't seem to ever print the warnings.wrapWithWarn
should probably be changed; other candidates includemkStub
,mkWarnDrv
, etc.lib.derivations
is perhaps not the correct place for this helper to live, and it may need tests too – I'm unlikely to have the energy to figure this out on my own, but if someone else wants to put in the work or tell me what to do, feel free.Fixes #306276, related to NixOS/nix#10882
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.