-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Default Nix installations don't include user channels in NIX_PATH, causing inconsistent tool behavior #2033
Comments
Yes, before root IMO. |
Do you know why For everything to be perfectly aligned, |
@zimbatm Mostly because |
I guess it's easier to fix the installer than nix-env :) |
@grahamc Assigned to you, you pretty much own the install process these days 😀 Feel free to make a call on your own or call in @NixOS/nix-core as you see fit. |
I'm happy to implement these changes to the installer and what-not, but'd love input from @NixOS/nix-core too |
This isn't specific to the installer, it's this way to match the defaults from nixos. Also what is the plan for channels/user profiles with the new ui? |
This kind of change seems good to me, if we do it before the official announcement. That would mean to do the change rather quickly now (and test it does what we want), within a couple days. |
What is the motivation? Note the Nix docs on |
@FRidh Earlier paths take precedence, and in general letting users override system-wide policy is the right call (outside of access control issues, of course) |
Previously I believe I've seen Nix complain about multiple entiries-- I think when prepending "~/.nix-defexpr/channels" to NIX_PATH. Not sure if still happens, but just a heads-up. |
Yes, if in my user profile add
|
It seemed pretty easy to get into a position of being warned and a bit confusing to get out of it - wish I understood the purpose of adding On my mac running 2.0.4, I ended up just removing all root channels to avoid the duplication - |
It would be great to have |
This broke my configuration and the commit message gives no indication about how to fix it. What is the proper way to stop this behaviour? |
@mpickering What commit are you referring to? |
8ab8d9cb74e75de46e647a5d77c137f7ef3ebd2b I think I should fix it by removing all channels? |
Could someone explain the purpose of every user having:
as set up by the The problem right now is that if the user additionally sources Would anything break if the root channels were only added to |
This also sources ~/.nix-profile/etc/profile.d/nix.sh if it exists. See NixOS/nix#2033 for details.
I just tried to install Nix on MacOS today. Steps to reproduce: # Install multi-user on MacOS with auto-create of /nix volume
$ sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume --daemon
# After installation successful, I check /etc/zshrc and /etc/bashrc. Both have
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
# Next I can check the $NIX_PATH of the new shells (both BASH and ZSH):
$ echo $NIX_PATH
nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixpkgs:/nix/var/nix/profiles/per-user/root/channels It is all fine and game until I follow this step in the manual. Chapter 7 – Environment Variables. I tried to add: $ cat $ZDOTDIR/.zshrc.local -r 41:41
source '~/.nix-profile/etc/profile.d/nix.sh' but everytime a new shell open, it showed this error: I can run it after the shell has been initialized but in general, I don't know how to fix this. |
Hi @anhdle14 you'd run The if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi There shouldn't be any need to Also when you say you can run it after the shell has been initialized what it "it"? Are you suggesting that the same command does not error with |
Hi, @nathanshelly! Thank for the quick response.
"it" here is the the script to change NIX_PATH during shell init lifecycle. Yes, if I ran the script after the shell startup it can find the file. In any locations other than The reason I was fixating on using the I couldn't understand why installing something like # From
export NIX_PATH=nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixpkgs:/nix/var/nix/profiles/per-user/root/channels
# To
export NIX_PATH=nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixpkgs:/nix/var/nix/profiles/per-user/root/channels:~/.nix-defexpr/channels But the problems is I can't fix Sorry I just learning Nix for 2 days, maybe I am doing something wrong but the documentations are pretty bad to follow. |
If I understand things correctly I believe your issues could be solved by adding the following line (which this issue is proposing should be included by default) to your export NIX_PATH=$NIX_PATH:$HOME/.nix-defexpr/channels I'm still learning Nix myself so I don't have context on why that is not the default already. Let me know if that doesn't work and we can try to keep debugging things 😄 |
Thank you that did the trick, I thought i have to use nix.sh for correct tools per user, or else it only going to use the root one |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/emacs-app-installed-incorrectly-via-home-manager/10577/2 |
When I first faced this issue, I was disappointed and surprised but luckily I came up with a workaround that works for me:
I was able to automate my simple nix setup nicely with this way. |
Was there a resolution to this issue? I see that is was fixed in NixOS/nixpkgs@5d03cce but those changes were reverted in NixOS/nixpkgs@fa67ca1. For reference, I just performed a fresh multi-user install on a new Mac (Big Sure 11.3.1) and $ echo $NIX_PATH
nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixpkgs:/nix/var/nix/profiles/per-user/root/channels which does not include As best I can tell, export NIX_PATH="nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixpkgs:/nix/var/nix/profiles/per-user/root/channels" |
Was unable to get |
I had a friend install Nix today and NIX_PATH wasn't set on an aarch64-darwin install after using the default multi-user install (Nix 2.8). |
Installing a clean NixOS also currently (9a2e72335c6651d5fb16e6901aa4b5c790c243db) results in this broken state where channels added with What is the path to having a working user environment after a clean install of NixOS? |
It looks like most folks here are installing nix on non-NixOS, so this won't be relevant for most. But for a NixOS install, I've ended up with the following workaround in the nixos configuration (with the added bonus of avoiding channels_root being added):
|
Should Nix installations include
$HOME/.nix-defexpr/channels
in the NIX_PATH? Should it appear before or after root channels?vs:
With this configuration, and the explicitly specified nixpkgs, is it possible for users to override
nixpkgs
without redefining the NIX_PATH? Does it matter?The text was updated successfully, but these errors were encountered: