Picking a version


#1

I just recompiled hello :frowning:
Now I tried to install coreutils, just because.

mral@sunburst20171202:/nix/store$ nix-env -qas coreutils
warning: name collision in input Nix expressions, skipping ‘/home/mral/.nix-defexpr/channels_root/nixpkgs’
-PS coreutils-8.30
–S coreutils-8.30
–S coreutils-8.30
mral@sunburst20171202:/nix/store$ nix-env -i coreutils
warning: name collision in input Nix expressions, skipping ‘/home/mral/.nix-defexpr/channels_root/nixpkgs’
warning: there are multiple derivations named ‘coreutils-8.30’; using the first one
installing ‘coreutils-8.30’
building ‘/nix/store/abydy82zzqcvkwvvnzm5qla85frizqm4-user-environment.drv’…
created 110 symlinks in user environment

the nix-env status shows 3 version but I have no idea what the difference is.
When I installed it says that it picked the first one.

Questions:
What criteria was used to establish the order?
I assume the present one was there because to the work done to compile hello.

What is different about the other two?

What is the warning telling me?
What names are colliding?


#2

From https://nixos.org/nix/manual/#queries (and also the manpage on nix-env(1)):

Print the status of the derivation. The status consists of three characters. The first is I or - , indicating whether the derivation is currently installed in the current generation of the active profile. This is by definition the case for --installed , but not for --available . The second is P or - , indicating whether the derivation is present on the system. This indicates whether installation of an available derivation will require the derivation to be built. The third is S or - , indicating whether a substitute is available for the derivation.

Note that you also used -a, which shows all the available derivations, but if you want to know what you currently have in the environment, I’d suggest to use just nix-env -q, possibly with the --out-path to see the difference if you have collisions.

Another thing I’d recommend is using nix-env -iA instead of nix-env -i, because the latter recurses through all package attributes trying to find a specific derivation name instead of an attribute. Using -A allows you to directly specify the attribute path instead, which avoids this recursion.


#3

The first one should be the one you want. These are where the dupes come from:

  coreutils = callPackage ../tools/misc/coreutils { };
  coreutils-full = coreutils.override { minimal = false; };
  coreutils-prefixed = coreutils.override { withPrefix = true; singleBinary = false; };

coreutils-full links to openssl and has some small performance advantages. coreutils-prefixed prefixes all of the binaries with “g”. You can get the attribute path that differentiates them with:

$ nix-env -qasP coreutils
-PS  nixpkgs.coreutils           coreutils-8.30
--S  nixpkgs.coreutils-full      coreutils-8.30
--S  nixpkgs.coreutils-prefixed  coreutils-8.30

#4

thanks, I have lots to learn