rose-pine-nix/modules/home-manager/waybar.nix
Jens Gatzweiler 2788becbb5
feat(home-manager): add support for waybar (#133)
* feat(home-manager): add support for waybar

* feat(home-manager/waybar): add prependImport & createLink options

* fix(home-manager/waybar): inline styleFile

* fix(home-manager/waybar): make prependImport and createLink mutually exclusive

* feat(home-manager/waybar): warn if prependImport has no effect

* style(waybar): use mkMerge

* fix(waybar): update description for mode option

* refactor(home-manager/waybar): remove warning
2024-05-01 19:08:50 -04:00

41 lines
1.1 KiB
Nix

{ config
, options
, lib
, sources
, ...
}:
let
cfg = config.programs.waybar.catppuccin;
enable = cfg.enable && config.programs.waybar.enable;
styleFile = "${sources.waybar}/themes/${cfg.flavour}.css";
in
{
options.programs.waybar.catppuccin = (lib.ctp.mkCatppuccinOpt "waybar") // {
mode = lib.mkOption {
type = lib.types.enum [
"prependImport"
"createLink"
];
default = "prependImport";
description = ''
Defines how to include the catppuccin theme css file:
- `prependImport`: Prepends the import statement, if `programs.waybar.style` is a string (with default override priority).
- `createLink`: Creates a symbolic link `~/.config/waybar/catppuccin.css`, which needs to be included in the waybar stylesheet.
'';
};
};
config = lib.mkIf enable (
lib.mkMerge [
(lib.mkIf (cfg.mode == "prependImport") {
programs.waybar.style = lib.mkBefore ''
@import "${styleFile}";
'';
})
(lib.mkIf (cfg.mode == "createLink") {
xdg.configFile."waybar/catppuccin.css".source = styleFile;
})
]
);
}