From 29699c86c4132e446b23af2bfc48a73b1a75f508 Mon Sep 17 00:00:00 2001 From: Lichthagel Date: Sat, 20 Apr 2024 10:38:18 +0200 Subject: [PATCH] feat(home-manager/waybar): add prependImport & createLink options --- modules/home-manager/waybar.nix | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/modules/home-manager/waybar.nix b/modules/home-manager/waybar.nix index c58e9491..0d24c03e 100644 --- a/modules/home-manager/waybar.nix +++ b/modules/home-manager/waybar.nix @@ -8,11 +8,33 @@ let enable = cfg.enable && config.programs.waybar.enable; in { - options.programs.waybar.catppuccin = lib.ctp.mkCatppuccinOpt "waybar"; + options.programs.waybar.catppuccin = (lib.ctp.mkCatppuccinOpt "waybar") // { + styleFile = lib.mkOption { + type = lib.types.path; + default = "${sources.waybar}/themes/${cfg.flavour}.css"; + description = "Path to CSS file containing color variable definitions"; + }; - config.programs.waybar = lib.mkIf enable { - style = lib.mkBefore '' - @import "${sources.waybar}/themes/${cfg.flavour}.css"; - ''; + prependImport = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Whether to prepend `@import \"$${styleFile}\";` when `programs.waybar.style` is set to a string."; + }; + + createLink = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Whether to create a symlink `~/.config/waybar/catppuccin.css` pointing to `styleFile`."; + }; + }; + + config = lib.mkIf enable { + programs.waybar.style = lib.mkIf cfg.prependImport ( + lib.mkBefore '' + @import "${cfg.styleFile}"; + '' + ); + + xdg.configFile."waybar/catppuccin.css" = lib.mkIf cfg.createLink { source = cfg.styleFile; }; }; }