From 94d2ff1ebbde5bcc14e6ef2fbbe570a53599d158 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Sun, 13 Oct 2024 16:07:26 +0200 Subject: [PATCH] Color: Add catppuccin latte and mocha schemes --- home/christoph/default.nix | 6 +++ home/modules/color/0_template.nix | 29 +++++++++++++ home/modules/color/catppuccin-latte.nix | 30 +++++++++++-- home/modules/color/catppuccin-mocha.nix | 29 +++++++++++++ home/modules/color/default.nix | 58 +++++++++++++++++++++++-- home/modules/color/options.nix | 57 +++++++++++++++++++++--- 6 files changed, 197 insertions(+), 12 deletions(-) create mode 100644 home/modules/color/0_template.nix create mode 100644 home/modules/color/catppuccin-mocha.nix diff --git a/home/christoph/default.nix b/home/christoph/default.nix index 3b2ca728..e146e973 100644 --- a/home/christoph/default.nix +++ b/home/christoph/default.nix @@ -38,6 +38,12 @@ rec { google = false; }; + color = { + enable = true; # You can't disable this + lightScheme = "catppuccin-latte"; + darkScheme = "catppuccin-mocha"; + }; + firefox = { enable = true; wayland = true; diff --git a/home/modules/color/0_template.nix b/home/modules/color/0_template.nix new file mode 100644 index 00000000..31690c27 --- /dev/null +++ b/home/modules/color/0_template.nix @@ -0,0 +1,29 @@ +{ + 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 = ""; +} diff --git a/home/modules/color/catppuccin-latte.nix b/home/modules/color/catppuccin-latte.nix index 683b8035..7daa0d68 100644 --- a/home/modules/color/catppuccin-latte.nix +++ b/home/modules/color/catppuccin-latte.nix @@ -1,5 +1,29 @@ { - rosewater = { - hex = "#dc8a78"; - }; + rosewater = "dc8a78"; + flamingo = "dd7878"; + pink = "ea76cb"; + mauve = "8839ef"; + red = "d20f39"; + maroon = "e64553"; + peach = "fe640b"; + yellow = "df8e1d"; + green = "40a02b"; + teal = "179299"; + sky = "04a5e5"; + sapphire = "209fb5"; + blue = "1e66f5"; + lavender = "7287fd"; + + text = "4c4f69"; + subtext1 = "5c5f77"; + subtext0 = "6c6f85"; + overlay2 = "7c7f93"; + overlay1 = "8c8fa1"; + overlay0 = "9ca0b0"; + surface2 = "acb0be"; + surface1 = "bcc0cc"; + surface0 = "ccd0da"; + base = "eff1f5"; + mantle = "e6e9ef"; + crust = "dce0e8"; } diff --git a/home/modules/color/catppuccin-mocha.nix b/home/modules/color/catppuccin-mocha.nix new file mode 100644 index 00000000..a9f2d725 --- /dev/null +++ b/home/modules/color/catppuccin-mocha.nix @@ -0,0 +1,29 @@ +{ + rosewater = "f5e0dc"; + flamingo = "f2cdcd"; + pink = "f5c2e7"; + mauve = "cba6f7"; + red = "f38ba8"; + maroon = "eba0ac"; + peach = "fab387"; + yellow = "f9e2af"; + green = "a6e3a1"; + teal = "94e2d5"; + sky = "89dceb"; + sapphire = "74c7ec"; + blue = "89b4fa"; + lavender = "b4befe"; + + text = "cdd6f4"; + subtext1 = "bac2de"; + subtext0 = "a6adc8"; + overlay2 = "9399b2"; + overlay1 = "7f849c"; + overlay0 = "6c7086"; + surface2 = "585b70"; + surface1 = "45475a"; + surface0 = "313244"; + base = "1e1e2e"; + mantle = "181825"; + crust = "11111b"; +} diff --git a/home/modules/color/default.nix b/home/modules/color/default.nix index e2c1c4d3..5255a70d 100644 --- a/home/modules/color/default.nix +++ b/home/modules/color/default.nix @@ -7,8 +7,60 @@ with lib; with mylib.modules; let cfg = config.modules.color; -in { - options.modules.color = import ./options.nix {inherit lib mylib;}; - config = {}; + # Options and assignments will be generated from those keys + colorKeys = [ + # Colors + "rosewater" + "flamingo" + "pink" + "mauve" + "red" + "maroon" + "peach" + "yellow" + "green" + "teal" + "sky" + "sapphire" + "blue" + "lavender" + + # 50 shades of gray + "text" + "subtext1" + "subtext0" + "overlay2" + "overlay1" + "overlay0" + "surface2" + "surface1" + "surface0" + "base" + "mantle" + "crust" + ]; +in { + options.modules.color = import ./options.nix {inherit lib mylib colorKeys;}; + + config = let + lightDefs = import ./${cfg.lightScheme}.nix; + darkDefs = import ./${cfg.darkScheme}.nix; + + mkLightColorAssignment = key: {${key} = lightDefs.${key};}; + mkDarkColorAssignment = key: {${key} = darkDefs.${key};}; + in + mkIf cfg.enable { + # This module sets its own options + # to the values specified in a colorscheme file. + modules.color.light = lib.pipe colorKeys [ + (builtins.map mkLightColorAssignment) + lib.mergeAttrsList + ]; + + modules.color.dark = lib.pipe colorKeys [ + (builtins.map mkDarkColorAssignment) + lib.mergeAttrsList + ]; + }; } diff --git a/home/modules/color/options.nix b/home/modules/color/options.nix index 65ff0a32..a7ec9a33 100644 --- a/home/modules/color/options.nix +++ b/home/modules/color/options.nix @@ -1,13 +1,58 @@ { lib, mylib, + colorKeys, ... }: with lib; -with mylib.modules; { - scheme = mkOption { - type = types.str; - description = "The color scheme to use"; - example = "catppuccin-latte"; +with mylib.modules; let + mkColorOption = key: { + light.${key} = mkOption { + type = types.str; + description = "The RGB hex color value for ${key} in the light scheme"; + example = "EEEEEE"; + }; + dark.${key} = mkOption { + 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 { + type = types.str; + description = "The color scheme to use for light colors"; + example = "catppuccin-latte"; + default = "catppuccin-latte"; + }; + + darkScheme = mkOption { + type = types.str; + description = "The color scheme to use for dark colors"; + example = "catppuccin-mocha"; + default = "catppuccin-mocha"; + }; + + keys = mkOption { + type = types.listOf types.str; + description = "The names of all possible colors"; + default = colorKeys; + }; + + light = mkOption { + type = types.attrs; + description = "Colors belonging to the selected light scheme"; + }; + + dark = mkOption { + type = types.attrs; + description = "Colors belonging to the selected dark scheme"; + }; + }