From 6d3a046d17675db57114dcfcd20e36eedb597967 Mon Sep 17 00:00:00 2001 From: Daniel Thwaites Date: Tue, 7 Mar 2023 11:22:50 +0000 Subject: [PATCH] Add `extraCss` option for GTK :sparkles: --- modules/gtk/hm.nix | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/modules/gtk/hm.nix b/modules/gtk/hm.nix index 71729d10..44776b2b 100644 --- a/modules/gtk/hm.nix +++ b/modules/gtk/hm.nix @@ -1,16 +1,40 @@ { pkgs, config, lib, ... }: +with lib; + let - css = config.lib.stylix.colors { + cfg = config.stylix.targets.gtk; + + baseCss = config.lib.stylix.colors { template = builtins.readFile ./gtk.mustache; extension = "css"; }; - -in { - options.stylix.targets.gtk.enable = - config.lib.stylix.mkEnableTarget "all GTK3, GTK4 and Libadwaita apps" true; - config = lib.mkIf config.stylix.targets.gtk.enable { + finalCss = pkgs.runCommandLocal "gtk.css" {} '' + echo ${escapeShellArg cfg.extraCss} >>$out + cat ${baseCss} >>$out + ''; + +in { + options.stylix.targets.gtk = { + enable = config.lib.stylix.mkEnableTarget + "all GTK3, GTK4 and Libadwaita apps" true; + + extraCss = mkOption { + description = '' + Extra code added to gtk-3.0/gtk.css + and gtk-4.0/gtk.css. + ''; + type = types.lines; + default = ""; + example = '' + // Remove rounded corners + window.background { border-radius: 0; } + ''; + }; + }; + + config = lib.mkIf cfg.enable { # programs.dconf.enable = true; required in system config gtk = { enable = true; @@ -22,8 +46,8 @@ in { }; xdg.configFile = { - "gtk-3.0/gtk.css".source = css; - "gtk-4.0/gtk.css".source = css; + "gtk-3.0/gtk.css".source = finalCss; + "gtk-4.0/gtk.css".source = finalCss; }; }; }