-
-
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
Restore NIX_PATH taking precedence over nix-path #7871
Conversation
This restores the Nix <= 2.13 behaviour. Environment variables (which are dynamic) should take precedence over configuration file settings (which are static). Fixes NixOS#7857.
Alternatively, we can revert #7689, which has the benefit of simply restoring the old behaviour. |
I think there is correct behavior, and this is strictly
If the current code structure doesn't allow expressing it cleanly, probably that structure should be changed. I understand that this would be quite some work for mostly a side issue, and I think that the change in this PR is a net improvement over both the current state and reverting #7689. |
@@ -519,33 +519,40 @@ EvalState::EvalState( | |||
static_assert(sizeof(Env) <= 16, "environment must be <= 16 bytes"); | |||
|
|||
/* Initialise the Nix expression search path. */ | |||
evalSettings.nixPath.setDefault(evalSettings.getDefaultNixPath()); | |||
if (!evalSettings.pureEval) { |
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.
Is there anything speaking against
if (evalSettings.pureEval) {
createBaseEnv();
return;
}
and then increasing looseness in the following?
The inverted logic makes reasoning quite cumbersome.
I would say the order would be this:
Agreed. And I am inclined to again hypothesize these globals are not helping. |
That makes good sense to me, personally. |
There are some fundamentally conflicting requirements here. Anyway, I've made #7911 which has the simpler fix of reverting #7689. I'll merge that before the next release tomorrow. |
This, very much. But getting away from As long as we're not there yet, let's try make that behavior as consistent as possible.
This sounds like the way settings are constructed doesn't represent the precedence @grahamc outlined. While it would be really cumbersome to rework that, it would provide both some end-user value (by naturally fixing the surprising behavior and allowing for straightforward explanation on how settings are overridden) and improve developer experience significantly (by making the code in question tangibly easier to navigate, and therefore to work on). This sounds like something fundamentally important we should consider approaching somehow - regardless the current problem at hand, because the CLI and settings will continue developing. |
Yeah I think it is. IMO |
Documented the desired behavior in #7772. One could merge that and treat deviating behavior as a bug to be fixed. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/tweag-nix-dev-update-45/26397/1 |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-03-31-nix-team-meeting-minutes-45/27002/1 |
Discussed in the Nix team meeting:
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-05-05-nix-team-meeting-minutes-52/27893/1 |
I'm having trouble with this sometimes because I use I think we reached a decision. Is this blocked on anything? |
Please fix this! |
Superseded by #11079 |
Motivation
This restores the Nix <= 2.13 behaviour. Environment variables (which are dynamic) should take precedence over configuration file settings (which are static).
nix-env --query --available
does not followNIX_PATH
#8784Note however that it does make
NIX_PATH
take precedence over the--nix-path
and--extra-nix-path
command line options, due to the way settings are implemented. There really is no correct behaviour here, e.g. should--extra-nix-path
overrideNIX_PATH
or the configuration file? If--extra-nix-path
is used in restricted eval mode, should it extend the default value (which includes the channels)?Bottom line: it's best to stop using restricted eval and/or
NIX_PATH
.Context
Checklist for maintainers
Maintainers: tick if completed or explain if not relevant
tests/**.sh
src/*/tests
tests/nixos/*