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:
Skyler Grey 2025-06-03 13:11:02 +00:00
parent c95ca1a881
commit 7b154aae01

View file

@ -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.