-
-
Notifications
You must be signed in to change notification settings - Fork 15k
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
Introduce types.optionType
and use it for freeformType
#149689
Conversation
Does it make |
@domenkozar Not this PR, but #97119 and #132448 do! Same for |
lib/types.nix
Outdated
type = mkOptionType { | ||
name = "type"; | ||
description = "type"; | ||
check = isAttrs; |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 freeformType
types.optionType
and use it for freeformType
28b484c
to
7b53fea
Compare
lib/types.nix
Outdated
optionType = mkOptionType { | ||
name = "optionType"; | ||
description = "optionType"; | ||
check = value: value ? _type && value._type == "option-type"; |
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.
check = value: value ? _type && value._type == "option-type"; | |
check = value: value._type or null == "option-type"; |
slightly simpler
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.
Applied
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.optionType
and using it forfreeformType
, we can fix #132085, making sure that the declaration location of submodules infreeformType
s are shown in the manual, because this new type properly propagates file locations.In addition however, this also allows declaring multiple
freeformType
s using the normal type merging behavior which can merge submodules together.This also removes awkwardness regarding what type the option
freeformType
should be.Ping @ncfavier, thanks for the issue!
Ping @roberth for review
Things done
nix-build nixos/release.nix -A manualHTML.x86_64-linux
and verified that the optionservices.wordpress.<name>.package
newly shows where it was declared.freeformType
submodules having declaration locationsfreeformType
s and them being merged together