Introduce types.optionType and use it for freeformType#149689
Introduce types.optionType and use it for freeformType#149689infinisil merged 2 commits intoNixOS:masterfrom
types.optionType and use it for freeformType#149689Conversation
|
Does it make |
|
@domenkozar Not this PR, but #97119 and #132448 do! Same for |
lib/types.nix
Outdated
There was a problem hiding this comment.
This should check at least _type = "option-type";
Naming isn't quite consistent: mkOptionType/"option-type"/types.type. "Option type" currently wins, but I do think it's a bit verbose. Renaming mkOptionType -> mkType would also be ok. Just don't deprecate immediately.
There was a problem hiding this comment.
I think it's fine to be a bit on the verbose side, especially also because types.type is kind of weird to see, aligning that with mkOptionType should make it a bit more obvious. I'll improve the check and change the name to types.optionType
There was a problem hiding this comment.
Also in the module system there's other "types" than just option types, see the other values that _type can have. So I think naming this types.optionType is very fitting.
2d02e72 to
567d549
Compare
567d549 to
28b484c
Compare
types.type and use it for freeformTypetypes.optionType and use it for freeformType
28b484c to
7b53fea
Compare
lib/types.nix
Outdated
There was a problem hiding this comment.
| check = value: value ? _type && value._type == "option-type"; | |
| check = value: value._type or null == "option-type"; |
slightly simpler
This type correctly merges multiple option types together while also annotating them with file information. In a future commit this will be used for `_module.freeformType`
This ensures that the module file locations are propagated to the freeform type, which makes it so that submodules in freeform types now have their declaration location shown in the manual, fixing NixOS#132085. In addition, this also newly allows freeformTypes to be declared multiple times and all declarations being merged together according to normal option merging. This also removes some awkwardness regarding the type of `freeformType`
|
Small regression: #163597 |
Motivation for this change
By introducing
types.optionTypeand using it forfreeformType, we can fix #132085, making sure that the declaration location of submodules infreeformTypes are shown in the manual, because this new type properly propagates file locations.In addition however, this also allows declaring multiple
freeformTypes using the normal type merging behavior which can merge submodules together.This also removes awkwardness regarding what type the option
freeformTypeshould be.Ping @ncfavier, thanks for the issue!
Ping @roberth for review
Things done
nix-build nixos/release.nix -A manualHTML.x86_64-linuxand verified that the optionservices.wordpress.<name>.packagenewly shows where it was declared.freeformTypesubmodules having declaration locationsfreeformTypes and them being merged together