-
-
Notifications
You must be signed in to change notification settings - Fork 16.6k
nixos/system-path: add overrides #415090
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
base: master
Are you sure you want to change the base?
nixos/system-path: add overrides #415090
Conversation
fb0ab8f
to
5d80888
Compare
nixos/modules/config/system-path.nix
Outdated
if requiredPackagesPriority == null then | ||
((pkg.meta.priority or lib.meta.defaultPriority) + 3) | ||
else | ||
requiredPackagesPriority |
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.
https://nix.dev/manual/nix/2.28/language/operators#attribute-selection
But:
- only works with full attrpaths, can't be used for single variables
- I MISUNDERSTOOD, it only check for defined/undefined, not null/non-null or truthy/falsy. Ignore my suggestion, I apologize for misinformation
5d80888
to
83f7041
Compare
83f7041
to
adb0ec8
Compare
…ages` At the moment, we reduce the priority of `requiredPackages` by default to ensure that said packages are installed in the system. This opens up the possibility of a binary being used from an unintentional package. I noticed this with the `xz` and the `rpi-imager` package so I will explain with that as an example. - The `xz` package has not set a priority using the `meta.priority` attribute. Given that it is in the `requiredPackages` list of packages, the `map` function assigns it the priority of 8 because `lib.meta.defaultPriority` is 5 and then a value of 3 is added to it for safe measure. Making it a priority of 8 using `lib.setPrio`. - The `rpi-imager` package, like `xz` does not have a priority set either. But, when it is included in the `paths` attribute of `pkgs.buildEnv` function, if no priority is set, a default priority is provided to it of the value of `lib.meta.defaultPriority`[0]. Now making the priority value of `rpi-imager` 5. This means, if there were ever to be a conflict of paths between `rpi-imager` and `xz`, `rpi-imager` would have a higher priority. And, given that both packages provide a binary called `xz` under `${pkg}/bin`, this does indeed create a path collision for `sw/bin/xz` between the `xz` and `rpi-imager` packages. This is just one instance of such an error that I only happened to notice because of a guide I was writing. To me, this behaviour was unintentional and this commit adds a way for like minded individuals to override the priority value assigned to `requiredPackages`, instead of yak shaving if the priority value for `requiredPackages` should be higher or lower. [0]: https://github.com/NixOS/nixpkgs/blob/a8f509677f4a392d75b21b72de4bc74d52b177fb/pkgs/build-support/buildenv/default.nix#L83
adb0ec8
to
641743b
Compare
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.
What exactly is the motivation behind this?
I don't really understand why this is necessary given that you should be able to override stuff with hiPrio pkg
already.
@Ma27, the commit |
Honestly this just feels wrong? Maybe we should just default priority to 0, and disallow collisions? At least that way the end users will hopefully be forced to choose. |
Ouch, apologies!
So, I think there are two cases where you run into this:
This is probably the interesting thing to discuss about: were the collisions you encountered accidental (such as the xz thing) or was there a different reason? Right now, I'm not aware of a third case which is the reason for my skepticism.
I'm wondering if adding a |
I agree that my commits don't actually solve the problem and feel wrong but I made them this way so that the user has more control over the knobs. Another reason, as I mentioned in the first commit, is that if I come up with a PR to address this tree-wide, there's a very high probably it will not be a productive discussion. This is a temporary fix, until someone else can address it with more knowledge than me. |
641743b
to
b3455e4
Compare
I agree. But IMHO, the packages in
I don't follow. I explained why I thought the collision occurred. I came to the conclusion that due to the current state, I don't know what you mean by "accidental." But I do believe that setting a lower priority for
Yeah that sounds better than my approach. I reworked the second commit and force pushed it. |
Yes, but that would cause a lot of breakage. And I'm not familiar enough with the entirety of nixpkgs to check for every breakage and fix it treewide. |
My point is, the fact that If that's the case, I'd argue that this is the wrong knob, but instead we should establish explicit rules to not do this (unless they already exist and I just failed to find them) and fix the packages instead.
Agreed, that's what you should use I'm not sure about what a sensible migration path would be, but I think I agree with @K900 here on how to fix this, i.e. by changing the |
I get your point. Would it be better if the first commit were to set a priority value of I'll also work on finding and resolving as many conflicts as I can. |
Sounds reasonable to me. @K900 wdyt? also cc @anthonyroussel for rpi-imager. |
Sounds reasonable. |
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Given this module has no maintainers in the file, I'm pinging some people who were involved in a PR related to this file. @SuperSandro2000 @Aleksanaa @0x4A6F @davidak @Ericson2314
Add a 👍 reaction to pull requests you find important.