rose-pine-nix/modules/home-manager/gtk.nix
seth 9c304e2cd2
add support for gtk (#7)
feat(modules): add support for gtk

Co-authored-by: Sam Nystrom <sam@samnystrom.dev>
2023-04-14 22:32:44 -04:00

52 lines
1.7 KiB
Nix

{ 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;
};
};
}