NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.54k stars 1.5k forks source link

Symlinks produced by `nix build` are in arbitrary order #7472

Open Kha opened 1 year ago

Kha commented 1 year ago

Describe the bug

nix build creates symlinks with suffixes -1, -2, ... when given multiple installables, but not necessarily in an order corresponding to the order given on the cmdline

Steps To Reproduce

$ nix build nixpkgs#hello nixpkgs#cowsay
lrwxrwxrwx 55 sebastian 17 Dec 14:36 result -> /nix/store/3d54xbrqj5zixa0cfnyki09jrffr0g3a-cowsay-3.04
lrwxrwxrwx 56 sebastian 17 Dec 14:36 result-1 -> /nix/store/g2m8kfw7kpgpph05v2fxcx4d5an09hl3-hello-2.12.1

Expected behavior

result should be the result of the first given installable etc.

nix-env --version output

nix-env (Nix) 2.11.0

Priorities

Add :+1: to issues you find important.

bjornfor commented 1 year ago

Is the order really arbitrary or is it sorted by store path?

Kha commented 1 year ago

I think they are in fact sorted by derivation name (DerivationGoal::key more specifically), but that sounds still pretty arbitrary to me :)

roberth commented 1 year ago

Déjà vu

ktrinh-anduril commented 2 months ago

Hi, is this issue still being tracked? I think at least the documentation should be changed to reflect the sorting order. Right now it states:

Each symlink has a suffix --, where N is the index of the installable (with the left-most installable having index 0), and outname is the symbolic derivation output name (e.g. bin, dev or lib). - is omitted if N = 0, and - is omitted if outname = out (denoting the default output).