1

Modules/Color: Add semantic color aliases

This commit is contained in:
2025-07-19 21:46:06 +02:00
parent 0eeb9623b2
commit 9e8b160087
2 changed files with 79 additions and 2 deletions

View File

@ -57,7 +57,18 @@ in {
# This module sets its own options to the values specified in a colorscheme file.
modules.color = let
colorDefs = import ./schemes/${color.scheme}.nix;
scheme = import ./schemes/${color.scheme}.nix;
# Add the aliases
colorDefs =
scheme
// {
bg = scheme.${color.bg};
text = scheme.${color.text};
accent = scheme.${color.accent};
accentHL = scheme.${color.accentHL};
accentText = scheme.${color.accentText};
};
mkColorAssignment = key: {${key} = colorDefs.${key};};
mkStringColorAssignment = key: {${key} = "#${colorDefs.${key}}";};

View File

@ -2,7 +2,37 @@
lib,
mylib,
...
}: {
}: let
colorKeys = [
"rosewater"
"flamingo"
"pink"
"mauve"
"red"
"maroon"
"peach"
"yellow"
"green"
"teal"
"sky"
"sapphire"
"blue"
"lavender"
"text"
"subtext1"
"subtext0"
"overlay2"
"overlay1"
"overlay0"
"surface2"
"surface1"
"surface0"
"base"
"mantle"
"crust"
];
in {
scheme = lib.mkOption {
type = lib.types.enum [
"catppuccin-latte"
@ -41,4 +71,40 @@
type = lib.types.attrs;
description = "Colors in \"RR,GG,BB\" decimal format";
};
# Some semantic aliases for colors
bg = lib.mkOption {
type = lib.types.enum colorKeys;
description = "The color to use as background";
example = "base";
default = "base";
};
text = lib.mkOption {
type = lib.types.enum colorKeys;
description = "The text color to use";
example = "text";
default = "text";
};
accent = lib.mkOption {
type = lib.types.enum colorKeys;
description = "The accent color to use";
example = "mauve";
default = "mauve";
};
accentHL = lib.mkOption {
type = lib.types.enum colorKeys;
description = "The accented accent color to use";
example = "pink";
default = "pink";
};
accentText = lib.mkOption {
type = lib.types.enum colorKeys;
description = "The text color to use for accents";
example = "base";
default = "base";
};
}