-
Notifications
You must be signed in to change notification settings - Fork 66
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
os.environ["NIX_PATH"] = self.nixpkgs_path()
silently get ignored when nix-path
is set in nix.conf
#343
Comments
We can pass |
We are actually not depending on NIX_PATH to build packages and for our shell already: nixpkgs-review/nixpkgs_review/nix.py Line 291 in 720dea6
Can you point out under what circumstances you see issues? |
The callsite is
|
I opened #349 as a workaround for now |
@NickCao Is this behavior of nix expected? Were you ever able to figure out exactly what codepath is taken that makes it so that this: ends up being empty: as far as I can tell, this: is where that value gets set, and it doesn't get set anywhere else unless I'm missing something obvious. I get that maybe it could be argued that this is desired behavior, but it feels very strange to me that setting nix-path in nix.conf makes it so that the environment variable is just completely ignored with no warning. |
https://github.com/NixOS/nix/blob/4a8c9bb9aa872d0f20c5aeb62357f832b4f9c0b4/src/libexpr/eval-settings.hh#L19 is probably where the
Since 3 runs last, the config file takes precedence over the environment variable |
right, this was my guess as well, but its really hard to work out where this is actually happening. Also, In practice, when I compiled it and ran it, it seemed that actually what was happening is that somehow the section that sets the environment variable just wasn't being hit. But also, I will just say that its pretty unconventional to have a config file take precedence over an environment variable. I feel like the typical hierarchy is, because generally speaking the precedence given to these things is: command line argument > environment variable > config file that feels very logical to me, because it orders them by how "dynamic"/ likely it is that the user explicitly set them that way. |
Its very likely that the call that results in all of this happens here: but its just very unclear to me whats going on overall. |
I added a print statement and it seems to be working as expected. The $NIX_PATH code gets executed and $ NIX_CONF_DIR=/etc/nix nix repl
/home/figsoda/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/c
hannels
Welcome to Nix 2.18.0. Type :? for help.
nix-repl> :p builtins.nixPath
[ { path = "/nix/store/9rajnwbn6zh0w4ww7mw74y71dy23ssn8-source"; prefix = "nixpkgs"; } ] Here is the patch I applied on top of HEAD: --- a/src/libexpr/eval-settings.cc
+++ b/src/libexpr/eval-settings.cc
@@ -46,7 +46,10 @@ static Strings parseNixPath(const std::string & s)
EvalSettings::EvalSettings()
{
auto var = getEnv("NIX_PATH");
- if (var) nixPath = parseNixPath(*var);
+ if (var) {
+ nixPath = parseNixPath(*var);
+ printError(*var);
+ }
}
Strings EvalSettings::getDefaultNixPath() The precedence is a bit unintuitive, but that might be better brought up to upstream. |
yeah I just worked out what was going on. If you try to use debug here, you wont get output at that point because the configuration for log verbosity has not been parsed yet. |
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
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 - NixOS/nix#10998 Co-authored-by: oxalica <[email protected]>
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
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 - NixOS/nix#10998 Co-authored-by: oxalica <[email protected]> (cherry picked from commit 1e6acab)
This may or may not be considered a bug of nix. But it breaks
nixpkgs-review
whennix.channel.enable = false;
is set.Reference: NixOS/nixpkgs#242098 https://github.com/NixOS/nixpkgs/blob/b56ed968c4840efdc871f7408997b1d9c07bf76a/nixos/modules/config/nix-channel.nix#L98
The text was updated successfully, but these errors were encountered: