diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 9ba6b77..2a68ca2 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -2,6 +2,7 @@ imports = [ ./bat.nix ./starship.nix + ./gtk.nix ]; options.catppuccin = { flavour = lib.mkOption { @@ -9,5 +10,10 @@ default = "latte"; description = "Global Catppuccin flavour"; }; + accent = lib.mkOption { + type = lib.types.enum [ "blue" "flamingo" "green" "lavender" "maroon" "mauve" "peach" "pink" "red" "rosewater" "sapphire" "sky" "teal" "yellow" ]; + default = "teal"; + description = "Global Catppuccin accent"; + }; }; } diff --git a/modules/home-manager/gtk.nix b/modules/home-manager/gtk.nix new file mode 100644 index 0000000..9c7d8c8 --- /dev/null +++ b/modules/home-manager/gtk.nix @@ -0,0 +1,52 @@ +{ config, pkgs, lib, ... }: +let cfg = config.gtk.catppuccin; +in { + options.gtk.catppuccin = with lib; { + enable = mkEnableOption "Catppuccin theme"; + flavour = mkOption { + type = types.enum [ "latte" "frappe" "macchiato" "mocha" ]; + default = config.catppuccin.flavour; + description = "Catppuccin flavour for gtk"; + }; + accent = mkOption { + type = types.enum [ "blue" "flamingo" "green" "lavender" "maroon" "mauve" "peach" "pink" "red" "rosewater" "sapphire" "sky" "teal" "yellow" ]; + default = config.catppuccin.accent; + description = "Catppuccin accents for gtk"; + }; + size = mkOption { + type = types.enum [ "standard" "compact" ]; + default = "standard"; + description = "Catppuccin size variant for gtk"; + }; + tweaks = mkOption { + type = types.listOf (types.enum [ "black" "rimless" "normal" ]); + default = [ "normal" ]; + description = "Catppuccin tweaks for gtk"; + }; + }; + + config.gtk.theme = with lib; + with builtins; + let + # string -> string + # this capitalizes the first letter in a string + # it's used to set the theme name correctly here + mkUpper = word: (toUpper (substring 0 1 word)) + (substring 1 (stringLength word) word); + + flavourUpper = mkUpper cfg.flavour; + accentUpper = mkUpper cfg.accent; + sizeUpper = mkUpper cfg.size; + + # use the light gtk theme for latte + gtkTheme = if cfg.flavour == "latte" then "Light" else "Dark"; + + in mkIf cfg.enable { + name = + "Catppuccin-${flavourUpper}-${sizeUpper}-${accentUpper}-${gtkTheme}"; + package = pkgs.catppuccin-gtk.override { + inherit (cfg) size tweaks; + accents = [ cfg.accent ]; + variant = cfg.flavour; + }; + }; +}