add support for gtk (#7)

feat(modules): add support for gtk

Co-authored-by: Sam Nystrom <sam@samnystrom.dev>
This commit is contained in:
seth 2023-04-14 22:32:44 -04:00 committed by GitHub
parent f3adc020b5
commit 9c304e2cd2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 0 deletions

View file

@ -2,6 +2,7 @@
imports = [ imports = [
./bat.nix ./bat.nix
./starship.nix ./starship.nix
./gtk.nix
]; ];
options.catppuccin = { options.catppuccin = {
flavour = lib.mkOption { flavour = lib.mkOption {
@ -9,5 +10,10 @@
default = "latte"; default = "latte";
description = "Global Catppuccin flavour"; 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";
};
}; };
} }

View file

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