feat: make modules.apply.fixup handle overrides
We're about to add overriding to make it so we can merge more things in modules. Before using any of these things (although after merging), we need to strip out the overrides We can hijack the modules.apply.fixup function to do this, as it is called in places where things are merged
This commit is contained in:
parent
c95ca1a881
commit
7b154aae01
1 changed files with 22 additions and 4 deletions
|
|
@ -94,20 +94,38 @@ lib: {
|
|||
in
|
||||
builtins.sort compare normalized;
|
||||
|
||||
## Normalize the type of an option. This will set a default type if none
|
||||
## was provided.
|
||||
## Normalize an option. This will set a default type if none was
|
||||
## provided, and remove any property override wrapping
|
||||
##
|
||||
## @type List String -> Option -> Option
|
||||
fixup =
|
||||
location: option:
|
||||
let
|
||||
normalize =
|
||||
value:
|
||||
if lib.types.is "override" value then
|
||||
value.content
|
||||
else
|
||||
value;
|
||||
getNormalized = name: if option ? ${name} then { ${name} = normalize option.${name}; } else {};
|
||||
in
|
||||
if option.type.submodules or null == null then
|
||||
option // { type = option.type or lib.types.unspecified; }
|
||||
option
|
||||
// { type = option.type or lib.types.unspecified; }
|
||||
// getNormalized "default"
|
||||
// getNormalized "example"
|
||||
// getNormalized "description"
|
||||
// getNormalized "apply"
|
||||
else
|
||||
option
|
||||
// {
|
||||
type = option.type.withSubModules option.options;
|
||||
options = [ ];
|
||||
};
|
||||
}
|
||||
// getNormalized "default"
|
||||
// getNormalized "example"
|
||||
// getNormalized "description"
|
||||
// getNormalized "apply";
|
||||
|
||||
## Invert the structure of `merge`, `when`, and `override` definitions so
|
||||
## that they apply to each individual attribute in their respective sets.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue