Skip to content

Commit

Permalink
fix(home-manager/waybar): make prependImport and createLink mutually …
Browse files Browse the repository at this point in the history
…exclusive
  • Loading branch information
Lichthagel committed Apr 23, 2024
1 parent 0d1a53a commit 9d9fdb6
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions modules/home-manager/waybar.nix
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
{
config,
lib,
sources,
...
{ config
, lib
, sources
, ...
}:
let
cfg = config.programs.waybar.catppuccin;
enable = cfg.enable && config.programs.waybar.enable;
in
{
options.programs.waybar.catppuccin = (lib.ctp.mkCatppuccinOpt "waybar") // {
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`.";
mode = lib.mkOption {
type = lib.types.enum [
"prependImport"
"createLink"
];
default = "prependImport";
description = "Whether to prepend an `@import` (requires that `programs.waybar.style` is set to a string) or to create a symlink `~/.config/waybar/catppuccin.css` (requires you to import manually).";
};
};

Expand All @@ -28,13 +24,15 @@ in
styleFile = "${sources.waybar}/themes/${cfg.flavour}.css";
in
{
programs.waybar.style = lib.mkIf cfg.prependImport (
programs.waybar.style = lib.mkIf (cfg.mode == "prependImport") (
lib.mkBefore ''
@import "${styleFile}";
''
);

xdg.configFile."waybar/catppuccin.css" = lib.mkIf cfg.createLink { source = styleFile; };
xdg.configFile."waybar/catppuccin.css" = lib.mkIf (cfg.mode == "createLink") {
source = styleFile;
};
}
);
}

0 comments on commit 9d9fdb6

Please sign in to comment.