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
Mention number of derivations to be build/fetched in output #3709
Conversation
Produces output like
I've sometimes wanted to know the number of derivations/paths in big lists. The |
src/libmain/shared.cc
Outdated
printMsg(lvl, fmt("%s will be fetched (%.2f MiB download, %.2f MiB unpacked):", | ||
willSubstitute.size() == 1 | ||
? "this path" | ||
: fmt("these %d paths",willSubstitute.size()), |
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.
BTW if we ever want to add translations to Nix, then splitting strings in this way is annoying, because in many languages the translation of "will be fetched" depends on the number of the subject. So it's better to write
if (willSubstitute.size() == 1)
printMsg(lvl, fmt("this path will be fetched...", ...);
else
printMsg(lvl, fmt("these %d paths will be fetched...", ...);
This is also easier to read IMHO.
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.
That is indeed how I had it initially, but I was unhappy with the duplication this incurred.
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.
Fixed
@@ -122,7 +122,7 @@ post-build-hook = /etc/nix/upload-to-cache.sh | |||
|
|||
<screen> | |||
$ nix-build -E '(import <nixpkgs> {}).writeText "example" (builtins.toString builtins.currentTime)' | |||
these derivations will be built: | |||
this derivation will be built: |
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.
It seems to me that in this case we should just omit the entire this derivation will be built
message because it's superfluous. After all the next line already says building '/nix/store/s4pnfbkalzy5qz57qs6yybna8wylkig6-example.drv'...
.
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.
In the case where there is a derivation being built and some being fetched, it distinguishes the build expression from the one being fetched.
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.
Also, the derivation may not be displayed promptly if one has to be "waiting for locks or build slots..."
Also correct grammar for the case of a single derivation.
Thanks! |
Also correct grammar for the case of a single derivation.