Optionalize mkTarget's 'humanName' and 'name' arguments by inferring 'humanName' from the 'name' attribute in the /modules/<MODULE>/meta.nix file, and 'name' from the /modules/<NAME>/ directory name. Inferring the 'humanName' and 'name' arguments ensures consistency and reduces boilerplate. The 'humanName' and 'name' arguments are optionalized instead of removed because complex modules generating target derivations need to distinguish between them. Closes: https://github.com/nix-community/stylix/issues/1661
36 lines
758 B
Nix
36 lines
758 B
Nix
{ mkTarget, lib, ... }:
|
|
mkTarget {
|
|
options.rainbow.enable = lib.mkEnableOption "rainbow gradient theming";
|
|
|
|
config =
|
|
{ cfg, colors }:
|
|
let
|
|
mkGradient =
|
|
colors:
|
|
builtins.listToAttrs (
|
|
lib.imap0 (
|
|
i: c: lib.nameValuePair "gradient_color_${toString (i + 1)}" "'#${c}'"
|
|
) colors
|
|
)
|
|
// {
|
|
gradient = 1;
|
|
gradient_count = builtins.length colors;
|
|
};
|
|
in
|
|
{
|
|
programs.cava.settings.color = lib.mkIf cfg.rainbow.enable (
|
|
mkGradient (
|
|
with colors;
|
|
[
|
|
base0E
|
|
base0D
|
|
base0C
|
|
base0B
|
|
base0A
|
|
base09
|
|
base08
|
|
]
|
|
)
|
|
);
|
|
};
|
|
}
|