stylix/mk-target: normalize options argument identically to config

Normalize the options argument identically to config to provide a
coherent and extensible options interface.
This commit is contained in:
NAHO 2025-07-19 18:40:26 +02:00
parent 953c3fb01e
commit 6153df31ce
No known key found for this signature in database
GPG key ID: BFB5D5E3F4C95185

View file

@ -111,9 +111,9 @@
  `imports` (List)
  : The `imports` option forwarded to the Nixpkgs module system.
`options` (Attribute set)
: Additional options to be added in the `stylix.targets.${name}` namespace
along the `stylix.targets.${name}.enable` option.
`options` (List or attribute set or function or path)
: Additional options to be added in the `stylix.targets.${name}` namespace,
normalized identically to `config`.
For example, an extension guard used in the configuration can be declared
as follows:
@ -181,7 +181,7 @@ in
humanName ? humanName',
imports ? [ ],
name ? name',
options ? { },
options ? [ ],
unconditionalConfig ? { },
}@args:
let
@ -276,6 +276,7 @@ let
)) (lib.toList config);
normalizedConfig = normalizeConfig mkTargetConfig;
normalizedOptions = normalizeConfig options;
in
{
imports =
@ -289,7 +290,7 @@ let
)
builtins.attrNames
(lib.remove "cfg")
]) (normalizedConfig ++ normalizeConfig options)
]) (normalizedConfig ++ normalizedOptions)
))
(
argument:
@ -321,7 +322,9 @@ let
);
}
++ imports
++ lib.singleton { options.stylix.targets.${name} = callModule false options; };
++ map (option: {
options.stylix.targets.${name} = callModule false option;
}) normalizedOptions;
options.stylix.targets.${name}.enable =
let