-
-
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
Make the NIX_PATH environment variable take precedence over config files #8902
Conversation
@roberth Is there any chance this could be looked at/merged soon. Do you have any thoughts about:
|
The team will triage this on Friday, and I hope we can decide soon.
In a project that uses |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-09-15-nix-team-meeting-minutes-86/33171/1 |
Discussed in Nix team meeting: The interaction between Complete discussion
Assigned to @fricklerhandwerk and @regnat to figure out. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-09-18-nix-team-meeting-minutes-87/33194/1 |
@fricklerhandwerk glad to hear that someone is actively thinking about it. Can't quite say I understand what is wrong with the approach in the PR, but sounds like it might have something to do with restrict-eval? |
@colonelpanic8 the comment with the mess was not referring to your work but the general situation. In #9066 we outlined what Nix should do. Someone still has to spend time on actually writing out those test cases and then making them pass. Would you be willing to work on some of that? After looking at the various attempts at solving the problem for so long, I'd really not want to merge anything that doesn't test it through. |
@fricklerhandwerk I'm not quite sure I understand how what I did doesn't do the right thing according to the comments here. I did add a small amount of testing but also happy to do more. |
Arrgh the worst typo, I'm so sorry. It was not referring to your work. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/nix-path-is-not-recognized/38404/6 |
Superceded by #11079 Thanks @colonelpanic8 for the preliminary work! |
Fixes #8890 #8784
Motivation
Almost every program that I can think of takes configuration parameters in this order of precedence:
This ordering is based roughly on how dynamic/persistent each of these types of values are, which gives the user a lot of flexibility to override things in the way they see fit. It also feels like the most obvious and intuitive order. Chat GPT agrees with me that this is the standard and most intuitive way to do things:
https://chat.openai.com/share/68fb24c9-2b91-47bd-9fab-baa956702cca
There is some discussion here that seems to imply that maybe this is a deliberate behavior:
NixOS/nixpkgs#242098 (comment)
but this position doesn't make a ton of sense to me, given that, as I pointed out here:
NixOS/nixpkgs#242098 (comment)
users must opt in to impure behavior with the --impure flag for flake aware commands.
There is one open question in my mind, which is whether or not a NIX_PATH setting should actually clobber any settings from configuration files, or if the configuration file values should also be used.
As the code is currently written, the values in the configuration files will still take effect.
This is actually arguably inconsistent with what is written here:
nix/doc/manual/src/command-ref/env-common.md
Line 22 in 197afd0
The thing is, the current behavior is ALSO inconsistent with what is written there. If you set NIX_PATH="" but have values in your nix.conf files, those paths will still be searched (as things stand atm).
Checklist for maintainers
Maintainers: tick if completed or explain if not relevant
tests/**.sh
src/*/tests
tests/nixos/*
Priorities
Add 👍 to pull requests you find important.