From 4b98726102678d880c4f7097bc55d8fc1df3f594 Mon Sep 17 00:00:00 2001 From: EnzioKam Date: Thu, 18 Apr 2024 23:02:10 +0800 Subject: [PATCH] fix(home-manager): link GTK 4.0 files (#114) * fix(home-manager): link GTK 4.0 files * fix(home-manager): add xdg assertion for gtk * fix(home-manager): fix gtk missing enable check for xdg assert * fix(home-manager): use string interpolation for gtk directory * fix(home-manager): fix formatting for gtk.nix --- modules/home-manager/gtk.nix | 70 ++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/modules/home-manager/gtk.nix b/modules/home-manager/gtk.nix index 0bad6fc..e06611f 100644 --- a/modules/home-manager/gtk.nix +++ b/modules/home-manager/gtk.nix @@ -30,36 +30,52 @@ in }; }; - config.gtk = lib.mkIf enable { - theme = - let - flavourUpper = ctp.mkUpper cfg.flavour; - accentUpper = ctp.mkUpper cfg.accent; - sizeUpper = ctp.mkUpper cfg.size; + config = lib.mkIf enable { + assertions = [ + (lib.ctp.assertXdgEnabled "gtk") + ]; - # use the light gtk theme for latte - gtkTheme = - if cfg.flavour == "latte" - then "Light" - else "Dark"; + gtk = { + theme = + let + flavourUpper = ctp.mkUpper cfg.flavour; + accentUpper = ctp.mkUpper cfg.accent; + sizeUpper = ctp.mkUpper cfg.size; + + # use the light gtk theme for latte + gtkTheme = + if cfg.flavour == "latte" + then "Light" + else "Dark"; + in + { + name = "Catppuccin-${flavourUpper}-${sizeUpper}-${accentUpper}-${gtkTheme}"; + package = pkgs.catppuccin-gtk.override { + inherit (cfg) size tweaks; + accents = [ cfg.accent ]; + variant = cfg.flavour; + }; + }; + + cursorTheme = + let + flavourUpper = ctp.mkUpper cfg.cursor.flavour; + accentUpper = ctp.mkUpper cfg.cursor.accent; + in + lib.mkIf cfg.cursor.enable { + name = "Catppuccin-${flavourUpper}-${accentUpper}-Cursors"; + package = pkgs.catppuccin-cursors.${cfg.cursor.flavour + accentUpper}; + }; + }; + + xdg.configFile = + let + gtk4Dir = "${config.gtk.theme.package}/share/themes/${config.gtk.theme.name}/gtk-4.0"; in { - name = "Catppuccin-${flavourUpper}-${sizeUpper}-${accentUpper}-${gtkTheme}"; - package = pkgs.catppuccin-gtk.override { - inherit (cfg) size tweaks; - accents = [ cfg.accent ]; - variant = cfg.flavour; - }; - }; - - cursorTheme = - let - flavourUpper = ctp.mkUpper cfg.cursor.flavour; - accentUpper = ctp.mkUpper cfg.cursor.accent; - in - lib.mkIf cfg.cursor.enable { - name = "Catppuccin-${flavourUpper}-${accentUpper}-Cursors"; - package = pkgs.catppuccin-cursors.${cfg.cursor.flavour + accentUpper}; + "gtk-4.0/assets".source = "${gtk4Dir}/assets"; + "gtk-4.0/gtk.css".source = "${gtk4Dir}/gtk.css"; + "gtk-4.0/gtk-dark.css".source = "${gtk4Dir}/gtk-dark.css"; }; }; }