From 9c304e2cd21aad827659cafd922b3849ca78bf1f Mon Sep 17 00:00:00 2001 From: seth Date: Fri, 14 Apr 2023 22:32:44 -0400 Subject: [PATCH] add support for gtk (#7) feat(modules): add support for gtk Co-authored-by: Sam Nystrom --- modules/home-manager/default.nix | 6 ++++ modules/home-manager/gtk.nix | 52 ++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 modules/home-manager/gtk.nix 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; + }; + }; +}