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