nixos/nixpkgs.config: make use of the module defined in config.nix#489889
nixos/nixpkgs.config: make use of the module defined in config.nix#489889jopejoe1 wants to merge 3 commits intoNixOS:masterfrom
Conversation
These are handled in the NixOS modules for `nixpkgs.config` as special merges; add them here.
8bf94f4 to
36c82f3
Compare
36c82f3 to
f707c6d
Compare
Makes it possible to render it in the NixOS manual, as that one does not contain the Nixpkgs manual specific ones.
This makes it so that the `nixpkgs.config` options can be merged with the module system It also makes the defined options show up in search and the manual.
f707c6d to
d8d2005
Compare
| }@args: | ||
|
|
||
| let | ||
| docPrefix = args.docPrefix or ""; |
There was a problem hiding this comment.
Not happy about all the docPrefix, but it works if someone has a better idea please let me know.
There was a problem hiding this comment.
You can't do . or or ? on module arguments directly, because they're generated from the individual module's functionArgs. (otherwise a { ... }: function is by definition strict, ie not lazy like it needs to be)
This should work though:
| docPrefix = args.docPrefix or ""; | |
| docPrefix = config._module.args.docPrefix or ""; |
|
Love the direction of this PR; I just hit the inability to merge nixpkgs config entries earlier this weeks. Won't have time to review this, though. |
|
This is super interesting. I briefly tried this and didn't get very far with my last pull request touching this area. My work did include some tests because I didn't particularly trust myself with the intricacies of this code. Did they happen to survive this change intact? (I'll look into this later, but quite busy, so no definite timescale given) |
|
As far as I can tell my tests still work. This brings me to the next question: Do you have any idea why this was not done in the first place? I always assumed that this might have something to do with importing multiple nixpkgs versions, but sharing the config object between them, and that for that reason it needed to be dumb and not part of the module system. But I did not find any documentation or comments that clarified this. |
|
As far as I can tell, the |
|
noice! Looking forward to this being merged! |
philiptaron
left a comment
There was a problem hiding this comment.
Diff looks good to me; every time we have tried to add an option in this way, we've had to do a tree wide to find every user of it and adapt them from the or null pattern. I do expect that because this allows setting the default, there's going to be a set of places that need updating in that way. The second thing that's been run into with similar PRs is that there are many doors into Nixpkgs, and not everyone has this logic.
Do you have any links / examples for this, so we can understand how this breaks or would break existing configurations? |
|
I'm on mobile so search is hard. I think this is my last comment on the matter. |
|
The 2 options added here match the previous default values of and nixpkgs/pkgs/top-level/stage.nix Line 221 in 0b721ad If there are anyother usages of thees options they are missusing this config option. |
|
@philiptaron @jopejoe1: do I get this right that options like If that is all I'm inclined to vote merge. I'm not approving this pull request yet, as I really do not feel that I understand the internals of nixpkgs well enough to confidently make that vote. (sorry @jopejoe1) |
|
I'm only not merging since I can't monitor for regressions. I think from a conceptual standpoint this is good to go. At worst we will roll it back having learned something and can refer back to it. |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
roberth
left a comment
There was a problem hiding this comment.
This doubles the module evaluation, leading to double the type checking, even in packageOverrides etc calls, as well as those unfree / insecure predicate functions.
I would prefer to let Nixpkgs to the module evaluation, by forwarding the definitions and putting apply = _nativeMergeIgnored: pkgs.config; in the option.
That way we have better a better separation of concerns, and the types are only applied once, which might matter in some corner cases.
The Nixpkgs function doesn't support accepting raw options.config.definitionsWithLocations (or similar) definitions yet.
So that would have to be added. I'd have to look into the exact details; maybe the new mkDefinition is also helpful.
| }@args: | ||
|
|
||
| let | ||
| docPrefix = args.docPrefix or ""; |
There was a problem hiding this comment.
You can't do . or or ? on module arguments directly, because they're generated from the individual module's functionArgs. (otherwise a { ... }: function is by definition strict, ie not lazy like it needs to be)
This should work though:
| docPrefix = args.docPrefix or ""; | |
| docPrefix = config._module.args.docPrefix or ""; |
|
@roberth Would you mind explaining a little bit more why this would lead to a double nixpkgs module evaluation? Do you mean of just this module, or of all modules? (Sorry for being the noob in the room) |
This makes it so that the
nixpkgs.configoptions can be merged with the module systemIt also makes the defined options show up in search and the manual.
closes #368051
closes #468647
closes #356739
closes #330627
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.