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
[WIP] lib: modules: clear documentation of priority overrides hierarchy #69397
base: master
Are you sure you want to change the base?
[WIP] lib: modules: clear documentation of priority overrides hierarchy #69397
Conversation
Derived from: NixOS#69377 investivation & the screen play
Hold on, there's a mix-up here. I'm pretty sure that the priorities used by |
It all always has the same name - of course. This is why it was a play, my way of saying what is hard to show and explain. I hope somebody understood the meta of Not expected Spanish Inquisition!. But seems like nobody reacted to the seriousness of it, nobody shown he was there - except actors. I opened a PR, so things would go cleaner from that. And here you helping me. Ok. Yes, I thought that there is big probability that it is the case, but was too tired. If that is true. And I so far found now explanation about the difference of the two. |
I remember something that |
I already crawled through the Deus & relevant commits in the |
So I looked into this myself, and one part is indeed a bit messed up. Derivation prioritiesNix derivation priorities are apparently used for two different decisions, with different default priorities! For deciding which files to useOne decision is made by environment builders to figure out which package a file should come from if multiple of them have one at some included path. The main environment builders are For deciding which derivation to installThe second decision is made by Example of weirdnessSo as a result, this can lead to some odd behavior. E.g. let with import <nixpkgs> {};
let mkDrv = name: priority: runCommandNoCC name
(lib.optionalAttrs (priority != null) { meta.priority = priority; })
"mkdir $out; echo 'name = ${name}\npriority = ${toString priority}' > $out/priority";
in rec {
aaa = mkDrv "foo" 4;
bbb = mkDrv "foo" null; # Default priority, 0 or 5
ccc = mkDrv "bar" 2;
} We can have the following sequence of commands: $ nix-env -f prio.nix -i foo
installing 'foo'
$ cat ~/.nix-profile/priority
name = foo
priority = Here
Here NixOS option prioritiesOverride prioritiesNixOS option override priorities are used by the NixOS module system to decide which definitions of options should be used. Only definitions with the highest priority get merged together to build the final value, all others are ignored/overridden. Option definitions by default have priority 100, a lower number means higher priority. Due to the implementation, 9999 is the lowest possible priority as of now. Functions Ordering prioritiesOnce the list of definitions to be used has been decided with override priorities, ordering priorities can be used to control the ordering of definitions. The default ordering priority is 1000, with functions |
Thank you for your contributions.
|
I marked this as stale due to inactivity. → More info |
Motivation for this change
Derived from: #69377 - investigation & the screen play.
Main message of explanation that resulted in PR is: #69377 (comment)
Things done
Added cleaner explanation.