1

Color: Add different color representations

RgbString: e.g. "24,155,213"
Rgb:       e.g. [24 155 213]
This commit is contained in:
2024-10-14 17:34:43 +02:00
parent 4e346fe42f
commit 83e8ecc8e3
2 changed files with 47 additions and 10 deletions

View File

@ -45,20 +45,47 @@ in {
lightDefs = import ./schemes/${color.lightScheme}.nix;
darkDefs = import ./schemes/${color.darkScheme}.nix;
mkLightColorAssignment = key: {${key} = lightDefs.${key};};
mkDarkColorAssignment = key: {${key} = darkDefs.${key};};
mkColorAssignment = defs: key: {${key} = defs.${key};};
mkRgbColorAssignment = defs: key: {${key} = mylib.color.hexToRGB defs.${key};};
mkRgbStringColorAssignment = defs: key: {${key} = mylib.color.hexToRGBString "," defs.${key};};
in
lib.mkIf color.enable {
# This module sets its own options
# to the values specified in a colorscheme file.
modules.color.light = lib.pipe colorKeys [
(builtins.map mkLightColorAssignment)
modules.color = {
light = lib.pipe colorKeys [
(builtins.map (mkColorAssignment lightDefs))
lib.mergeAttrsList
];
modules.color.dark = lib.pipe colorKeys [
(builtins.map mkDarkColorAssignment)
dark = lib.pipe colorKeys [
(builtins.map (mkColorAssignment darkDefs))
lib.mergeAttrsList
];
rgb = {
light = lib.pipe colorKeys [
(builtins.map (mkRgbColorAssignment lightDefs))
lib.mergeAttrsList
];
dark = lib.pipe colorKeys [
(builtins.map (mkRgbColorAssignment darkDefs))
lib.mergeAttrsList
];
};
rgbString = {
light = lib.pipe colorKeys [
(builtins.map (mkRgbStringColorAssignment lightDefs))
lib.mergeAttrsList
];
dark = lib.pipe colorKeys [
(builtins.map (mkRgbStringColorAssignment darkDefs))
lib.mergeAttrsList
];
};
};
};
}

View File

@ -62,4 +62,14 @@ in
type = types.attrs;
description = "Colors belonging to the selected dark scheme";
};
rgbString = mkOption {
type = types.attrs;
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";
};
}