-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
nix-channel doesn't work as expected with sudo #1548
Comments
cc @grahamc given that this changed with the multi-user setup |
cc @jmitchell |
Doing some debugging, so far things are looking okay here:
I wonder if I definitely have the problem:
|
More info:
plus
plus https://github.com/NixOS/nix/blob/1.11-maintenance/scripts/nix-channel.in#L25-L26 = nix-channel is looking at user's channels w/ sudo on macos, and root's channels w/ sudo on nixos. This is because of this macOS default:
|
So where go from here? It seems like a workaround would be to just edit the sudoers file when a multiuser installation is done. I'm not sure this would be a good idea though since this change has deeper implications than most of the other changes the multiuser install seems to make. Would modifying the way Nix gets the home directory be better? I'm interested in seeing this fixed. While this is a minor irritation it poses a pretty big barrier for people trying to use Nix on MacOS who are just starting out. |
Maybe something like: if |
I would prefer not to depend on |
I removed
|
I discovered this as well:
though
this was definitely confusing initially, as it seemed as though I could install packages without being subscribed to any channels at all. |
I marked this as stale due to inactivity. → More info |
well, until the questions around whether |
I marked this as stale due to inactivity. → More info |
Not stale. Also occurs on NixOS with |
I marked this as stale due to inactivity. → More info |
On darwin, sudo does not clear HOME, so HOME will still be set to a users home directory rather than root's. util::getHome reads that value of HOME and is used in a number of different places, which causes unexpected behavior in quite a few ways See NixOS#1548 for some issues with nix-channel nix profile will symlink ~/.nix-profile to the default system profile nix will create ~/.cache owned by root: $ rm -r ~/.cache $ sudo nix --extra-experimental-features "nix-command flakes" run nixpkgs#hello Hello, world! $ ls -ld ~/.cache drwxr-xr-x 3 root staff 96 Jun 6 17:14 /Users/matthew/.cache I'm guessing similar problems occur elsewhere getHome is used
On darwin, sudo does not clear HOME, so HOME will still be set to a user's home directory rather than root's. util::getHome reads that value of HOME and is used in a number of different places, which causes unexpected behavior in quite a few ways See NixOS#1548 for some issues with nix-channel nix profile will symlink ~/.nix-profile to the default system profile nix will create ~/.cache owned by root: $ rm -r ~/.cache $ sudo nix --extra-experimental-features "nix-command flakes" run nixpkgs#hello Hello, world! $ ls -ld ~/.cache drwxr-xr-x 3 root staff 96 Jun 6 17:14 /Users/matthew/.cache I'm guessing similar problems occur elsewhere getHome is used
This issue can be closed. I recently added a PR (since landed) which fixes this on macos. |
On macOS it seems like nix-channel doesn't behave correctly when just using sudo.
I'm not sure if this also happens on other platforms, but it works fine on nixos.
and even more confusing
The text was updated successfully, but these errors were encountered: