[Nix#9574] Broken NIX_PATH tracking issue #89

Open
opened 2024-03-16 06:44:51 +00:00 by lix-bot · 3 comments
Member

Upstream-Issue: NixOS/nix#9574

Describe the bug

NIX_PATH environment variable does not work when nix.conf has a nix-path setting.
This is highly unexpected and not intentional.
Multiple issues and PRs exist, but solving this problem has proven difficult within the established abstractions for settings handling.

Issues

PRs

Priorities

Add 👍 to issues you find important.

Upstream-Issue: https://git.lix.systems/NixOS/nix/issues/9574 **Describe the bug** `NIX_PATH` environment variable does not work when `nix.conf` has a `nix-path` setting. This is highly unexpected and not intentional. Multiple issues and PRs exist, but solving this problem has proven difficult within the established abstractions for settings handling. **Issues** - #8784 - #8890 **PRs** - #7871 - #8902 **Priorities** Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).
lix-bot added the
bug
imported
labels 2024-03-16 06:44:51 +00:00
Member

To quote myself on the GitHub side:

While this is definitely a Nix bug, I'd argue that the NixOS module is broken as well: The nix.nixPath option sets environment.sessionVariables.NIX_PATH instead of settings.nix-path, which is surprising.

However, even with both of these fixed, I'd argue that the general behavior and interaction between these two would be suboptimal and surprising: If one configures the Nix path through nix.conf and then a script goes along and wants to append to NIX_PATH, it will effectively override the existing path instead of appending, which is clearly not intended. (The alternative of appending/merging both is equally problematic for other reasons. Maybe the two simply should not coexist …)

How feasible would it be to remove nix-path from nix.conf?

To quote myself on the GitHub side: > While this is definitely a Nix bug, I'd argue that the NixOS module is broken as well: The `nix.nixPath` option sets `environment.sessionVariables.NIX_PATH` instead of `settings.nix-path`, which is surprising. > > However, even with both of these fixed, I'd argue that the general behavior and interaction between these two would be suboptimal and surprising: If one configures the Nix path through `nix.conf` and then a script goes along and wants to append to `NIX_PATH`, it will effectively override the existing path instead of appending, which is clearly not intended. (The alternative of appending/merging both is equally problematic for other reasons. Maybe the two simply should not coexist …) How feasible would it be to remove `nix-path` from `nix.conf`?
Owner

It seems to be used to disable channel in NixOS (not in home-manager):

nixos/modules/config/nix-channel.nix
97:    nix.settings.nix-path = mkIf (! cfg.channel.enable) (mkDefault "");

nixos/tests/nix-config.nix
6:      nix-path = [ "nonextra=/etc/value.nix" ];
7:      extra-nix-path = [ "extra=/etc/value.nix" ];

Other than that, I don't see any blocker.

It seems to be used to disable channel in NixOS (not in home-manager): ``` nixos/modules/config/nix-channel.nix 97: nix.settings.nix-path = mkIf (! cfg.channel.enable) (mkDefault ""); nixos/tests/nix-config.nix 6: nix-path = [ "nonextra=/etc/value.nix" ]; 7: extra-nix-path = [ "extra=/etc/value.nix" ]; ``` Other than that, I don't see any blocker.
Owner

Yeah I am not opposed to just deleting this, does -I use it, or how does it work?

Yeah I am not opposed to just deleting this, does `-I` use it, or how does it work?
Sign in to join this conversation.
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#89
No description provided.