1

Color: Don't generate unnecessary sub-options

This commit is contained in:
2024-10-14 20:29:23 +02:00
parent 506a2b833a
commit 0a39fe41f9

View File

@ -5,71 +5,53 @@
... ...
}: }:
with lib; with lib;
with mylib.modules; let with mylib.modules; {
mkColorOption = key: { enable = mkEnableOption "Enable color schemes";
light.${key} = mkOption {
type = types.str; lightScheme = mkOption {
description = "The RGB hex color value for ${key} in the light scheme"; type = types.str;
example = "EEEEEE"; description = "The color scheme to use for light colors";
}; example = "catppuccin-latte";
dark.${key} = mkOption { default = "catppuccin-latte";
type = types.str;
description = "The RGB hex color value for ${key} in the dark scheme";
example = "111111";
};
}; };
in
(lib.pipe colorKeys [
(builtins.map mkColorOption)
lib.mergeAttrsList
])
// {
enable = mkEnableOption "Enable color schemes";
lightScheme = mkOption { darkScheme = mkOption {
type = types.str; type = types.str;
description = "The color scheme to use for light colors"; description = "The color scheme to use for dark colors";
example = "catppuccin-latte"; example = "catppuccin-mocha";
default = "catppuccin-latte"; default = "catppuccin-mocha";
}; };
darkScheme = mkOption { font = mkOption {
type = types.str; type = types.str;
description = "The color scheme to use for dark colors"; description = "The font to use";
example = "catppuccin-mocha"; example = "JetBrainsMono Nerd Font Mono";
default = "catppuccin-mocha"; default = "JetBrainsMono Nerd Font Mono";
}; };
font = mkOption { keys = mkOption {
type = types.str; type = types.listOf types.str;
description = "The font to use"; description = "The names of all possible colors";
example = "JetBrainsMono Nerd Font Mono"; default = colorKeys;
default = "JetBrainsMono Nerd Font Mono"; };
};
keys = mkOption { light = mkOption {
type = types.listOf types.str; type = types.attrs;
description = "The names of all possible colors"; description = "Colors belonging to the selected light scheme";
default = colorKeys; };
};
light = mkOption { dark = mkOption {
type = types.attrs; type = types.attrs;
description = "Colors belonging to the selected light scheme"; description = "Colors belonging to the selected dark scheme";
}; };
dark = mkOption { rgbString = mkOption {
type = types.attrs; type = types.attrs;
description = "Colors belonging to the selected dark scheme"; description = "Colors belonging to the selected light scheme in 'RR,GG,BB' format";
}; };
rgbString = mkOption { rgb = mkOption {
type = types.attrs; type = types.attrs;
description = "Colors belonging to the selected light scheme in 'RR,GG,BB' format"; description = "Colors belonging to the selected light scheme in '[RR GG BB]' format";
}; };
}
rgb = mkOption {
type = types.attrs;
description = "Colors belonging to the selected light scheme in '[RR GG BB]' format";
};
}