nix-channel: do not set empty nix-path when disabling channels#273170
nix-channel: do not set empty nix-path when disabling channels#273170oxalica wants to merge 1 commit intoNixOS:masterfrom
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. |
r-vdp
left a comment
There was a problem hiding this comment.
Been running with this for a bit now and seems to work well. Thanks!
roberth
left a comment
There was a problem hiding this comment.
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: |
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: |
@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: |
@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''; |
|
The diff for the temporary merge commit c0b482cb974cca649d183ab4914b05f546c59482 is empty. |
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.nixPathhave 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-pathis set innix.confMic92/nixpkgs-review#343Not sure what to test.
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-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.