-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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: do not set empty nix-path when disabling channels #273170
base: master
Are you sure you want to change the base?
Conversation
An empty nix-path in nix.conf will disable NIX_PATH environment variable entirely, which is not necessarily implied by users who want to disable nix channels. NIX_PATH also has some usages in tools like nixos-rebuild or just as user aliases. That change is surprising and debatable, and also caused breakages in nixpkgs-review and user configs. See: - https://github.com/NixOS/nixpkgs/pull/242098/files#r1269891427 - Mic92/nixpkgs-review#343
b576318
to
0f2cd55
Compare
IIUC this change will Nix to set its hardcoded default value. If a system has not been manually cleaned after disabling The actual root cause is in Nix. Unfortunately it's non-trivial because of implementation design, and legacy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Been running with this for a bit now and seems to work well. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see two ways to move this forward without breaking users' expectations.
- Either print a clear warning in the activation script if the channel data still exists in
/nix/var/...
and can therefore still be found by Nix, - or make this an explicit opt-in: add an option such as
nix.dontUnsetNixPath
.
In the latter case, we can deprecate the option when the root cause has been solved in Nix.
From my testing, NIX_PATH takes precedence over that hardcoded default. If I unset IIUC when |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/disabling-channels-breaks-nix-path-resolution/34825/3 |
As stated by @nbdd0121, this is not true. When It's already covered by the test |
Ok, I suppose we could apply this change while NixOS/nix#9574 isn't resolved then. @ofborg test installer.switchToFlake |
Or maybe not, because of $ export NIX_PATH=test=$PWD
$ nix-shell --pure -I nixpkgs=. -p hello --run 'env | grep NIX_PATH'
$ |
I don't think this matter. |
@oxalica The problem is that an empty NIX_PATH makes Nix use the default, which then includes the channels unless you have them deleted.. |
My argument is that, For example, |
The problem is that the "true default" behavior breaks the intended effect of the option. It's a system option, so it will be perceived to have authority over the system. Arguably that wouldn't be as big of a deal if the activation script were to print a big fat warning that commands such as |
a warning would go a long way to helping users out here. previously, i was setting: nix.nixPath = [ "nixpkgs=/path/to/my/dev/fork/of/nixpkgs" ]; this was working for quite a while. eventually though i set anyway, there are people out there setting |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/how-to-get-a-derivation-path-for-nixpkgs/41231/4 |
@nbdd0121 That being said, is there a path forward for this? It's been sitting for quite a while 😕 Have we considered just nuking (or at least moving/automatically backing up/restoring a la nix-darwin) the channel data? |
|
Can you explain, please? For me it looks like it was partially reverted by https://github.com/ryan4yin/nix-config/pull/123/files but as another comment stated (don't know why it's gone/not showing up for me?): Nix path is set to:
|
Sorry, I made a mistake, this issue has not been resolved yet. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/24-05-add-flake-to-nix-path/46310/11 |
@roberth I agree. I implemented this suggestion in #323613, if you'd like to have a look. |
Note that since NixOS/nix#11079 made its way into Nix 2.24, the current behavior of exporting the An empty value now effectively prevents This can detect and fix the problem in a Zsh RC file: programs.zsh.shellInit = ''(( ''${+NIX_PATH} )) && [[ -z ''${NIX_PATH} ]] && unset NIX_PATH''; |
Description of changes
This reverts the line introduced by #242098.
An empty nix-path in nix.conf will disable NIX_PATH environment variable entirely, which is not necessarily implied by users who want to disable nix channels. NIX_PATH also has some usages in tools like nixos-rebuild or just as user aliases.
EDIT: It seems that empty nix-path also makes config
nix.nixPath
have no effect, because NIX_PATH is always ignored.That change is surprising and debatable, and also caused breakages in nixpkgs-review and user configs.
See:
os.environ["NIX_PATH"] = self.nixpkgs_path()
silently get ignored whennix-path
is set innix.conf
Mic92/nixpkgs-review#343Not sure what to test.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.