trofi / nix-guix-gentoo

Gentoo overlay for nix and guix functional package managers.
110 stars 9 forks source link

Redundant paths in PATH #20

Closed dakotaclemenceplaza closed 2 years ago

dakotaclemenceplaza commented 2 years ago

Both files nix-daemon.sh and nix.sh in /etc/profile.d add $HOME/.nix-profile/bin to PATH. Also, the official nix manual says

You generally wouldn’t have /nix/var/nix/profiles/some-profile/bin in your PATH. Rather, there is a symlink ~/.nix-profile that points to your current profile.

whereas nix-daemon.sh adds this path.

trofi commented 2 years ago

Are you talking about /nix/var/nix/profiles/default/bin profile specifically? Note: it's not a currently selected profile, but rather a always-present profile for everyone. root can install packages for every user to be visible that way.

Or you are seeing something else as well?

I don't think we patch init script in overlay package. Whatever sys-apps/nix does should be an upstream behavior we observer.

Here are my PATHs on NixOS:

$ echo $PATH |& tr ':' $'\n'
/run/wrappers/bin
/home/fresh/.nix-profile/bin
/etc/profiles/per-user/fresh/bin
/nix/var/nix/profiles/default/bin
/run/current-system/sw/bin

/nix/var/nix/profiles/default/bin is certainly there.

Here are my PATHs on Gentoo/nix:

$ echo $PATH | tr ':' $'\n'
/home/fresh/.nix-profile/bin
/home/fresh/.nix-profile/bin
/nix/var/nix/profiles/default/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/opt/bin
/usr/lib/llvm/14/bin
/usr/lib/llvm/13/bin

/nix/var/nix/profiles/default/bin is also there.

I think that you won't get any other profiles into the PATH. Note that /home/$HOME/.nix-profile/bin is the first in the list. That defines your current user's profile.

Do you think it's an incorrect behavior?

dakotaclemenceplaza commented 2 years ago

My PATH on Gentoo is just as yours regarding nix, nothing else. I don't know if it's incorrect really, duplication certainly would not bring any problems, I guess, but since I noticed it I went to see why is it duplicated, does nix-daemon.sh really needs to set $HOME/.nix-profile/bin if nix.sh will set it anyway? And regarding the other path, that's just what I read in the manual, so I thought that only $HOME/.nix-profile/bin should be in PATH of a user and nothing else and that maybe Gentoo installation changes something.

trofi commented 2 years ago

Oh, I somehow missed the PATH duplication entirely. Let's try to sort it first:

And then we'll try to improve documentation around various PATHs.

trofi commented 2 years ago

Hm, having read through scripts/install-multi-user.sh I think nix-daemon.sh is ever intended for daemon itself, never for user. Removing it should fix both issue you have noticed.

trofi commented 2 years ago

Pushed the change as https://github.com/trofi/nix-guix-gentoo/commit/7da9ad51d6a9ce15048460839d966c2aba1cf64c

Should be available as nix-2.9.0-r1. Please give it a try.

dakotaclemenceplaza commented 2 years ago

Seems to work as expected.

trofi commented 2 years ago

Woohoo! Thank you for the report and test!

Let's close it as fixed then.