From c88c5482386c6cec9f8a5b7fe30c6e7d51dcd164 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Sat, 19 Jul 2025 21:46:06 +0200 Subject: [PATCH] Modules/Color: Add semantic color aliases --- home/modules/color/default.nix | 13 ++++++- home/modules/color/options.nix | 68 +++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/home/modules/color/default.nix b/home/modules/color/default.nix index fcb3e0db..2492fb01 100644 --- a/home/modules/color/default.nix +++ b/home/modules/color/default.nix @@ -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}}";}; diff --git a/home/modules/color/options.nix b/home/modules/color/options.nix index 144edc04..2d1f4bd5 100644 --- a/home/modules/color/options.nix +++ b/home/modules/color/options.nix @@ -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"; + }; }