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
This commit is contained in:
Jens Gatzweiler 2024-05-02 01:08:50 +02:00 committed by GitHub
parent f46dffa334
commit 2788becbb5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 79 additions and 1 deletions

View file

@ -659,6 +659,26 @@
},
"version": "2e74ddba0c582b2ca2d9d06f67f5a902c3a093fb"
},
"waybar": {
"cargoLocks": null,
"date": "2024-03-31",
"extract": null,
"name": "waybar",
"passthru": null,
"pinned": false,
"src": {
"deepClone": false,
"fetchSubmodules": false,
"leaveDotGit": false,
"name": null,
"owner": "catppuccin",
"repo": "waybar",
"rev": "0830796af6aa64ce8bc7453d42876a628777ac68",
"sha256": "sha256-9lY+v1CTbpw2lREG/h65mLLw5KuT8OJdEPOb+NNC6Fo=",
"type": "github"
},
"version": "0830796af6aa64ce8bc7453d42876a628777ac68"
},
"yazi": {
"cargoLocks": null,
"date": "2024-02-21",
@ -699,4 +719,4 @@
},
"version": "0adc53028d81bf047461bc61c43a484d11b15220"
}
}
}

View file

@ -397,6 +397,18 @@
};
date = "2023-09-30";
};
waybar = {
pname = "waybar";
version = "0830796af6aa64ce8bc7453d42876a628777ac68";
src = fetchFromGitHub {
owner = "catppuccin";
repo = "waybar";
rev = "0830796af6aa64ce8bc7453d42876a628777ac68";
fetchSubmodules = false;
sha256 = "sha256-9lY+v1CTbpw2lREG/h65mLLw5KuT8OJdEPOb+NNC6Fo=";
};
date = "2024-03-31";
};
yazi = {
pname = "yazi";
version = "0846aed69b2a62d29c98e100af0cf55ca729723d";

View file

@ -0,0 +1,41 @@
{ 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;
})
]
);
}

View file

@ -130,6 +130,10 @@ fetch.github = "catppuccin/tmux"
src.git = "https://github.com/catppuccin/tofi.git"
fetch.github = "catppuccin/tofi"
[waybar]
src.git = "https://github.com/catppuccin/waybar.git"
fetch.github = "catppuccin/waybar"
[yazi]
src.git = "https://github.com/catppuccin/yazi.git"
fetch.github = "catppuccin/yazi"

View file

@ -84,6 +84,7 @@ testers.runNixOSTest {
swaylock = enable;
tmux = enable;
tofi = enable;
waybar = enable;
yazi = enable;
zathura = enable;
zellij = enable;