Skip to content
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

Merged
merged 1 commit into from Jun 18, 2020

Conversation

expipiplus1
Copy link
Contributor

Also correct grammar for the case of a single derivation.

@expipiplus1
Copy link
Contributor Author

Produces output like

$ nix-shell -p kakoune
this derivation will be built:
  /nix/store/a48gid3azj821qvxa88xz821w144zas2-kakoune-2020.01.16.drv
these 2 paths will be fetched (0.98 MiB download, 4.19 MiB unpacked):
  /nix/store/b2q8105b1ba1zyw3isl6vfl23xr3v26n-bash-4.4-p23-dev
  /nix/store/f6sg1j79w45rs2wa0acgqfqg7ralx5jb-kakoune-unwrapped-2020.01.16
copying path '/nix/store/b2q8105b1ba1zyw3isl6vfl23xr3v26n-bash-4.4-p23-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/f6sg1j79w45rs2wa0acgqfqg7ralx5jb-kakoune-unwrapped-2020.01.16' from 'https://cache.nixos.org'...
building '/nix/store/a48gid3azj821qvxa88xz821w144zas2-kakoune-2020.01.16.drv'...

I've sometimes wanted to know the number of derivations/paths in big lists.

The these -> this change was to avoid writing these 1 derivations....

printMsg(lvl, fmt("%s will be fetched (%.2f MiB download, %.2f MiB unpacked):",
willSubstitute.size() == 1
? "this path"
: fmt("these %d paths",willSubstitute.size()),
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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 &lt;nixpkgs&gt; {}).writeText "example" (builtins.toString builtins.currentTime)'
these derivations will be built:
this derivation will be built:
Copy link
Member

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'....

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.
@expipiplus1
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants