From 0cb131183486edba86aeafac852a42466ba683fd Mon Sep 17 00:00:00 2001 From: Lichthagel Date: Fri, 19 Apr 2024 14:26:50 +0200 Subject: [PATCH 1/8] feat(home-manager): add support for waybar --- _sources/generated.json | 22 +++++++++++++++++++++- _sources/generated.nix | 12 ++++++++++++ modules/home-manager/waybar.nix | 18 ++++++++++++++++++ nvfetcher.toml | 4 ++++ test.nix | 1 + 5 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 modules/home-manager/waybar.nix diff --git a/_sources/generated.json b/_sources/generated.json index 6eabaf83..255e89d8 100644 --- a/_sources/generated.json +++ b/_sources/generated.json @@ -679,6 +679,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", @@ -719,4 +739,4 @@ }, "version": "0adc53028d81bf047461bc61c43a484d11b15220" } -} \ No newline at end of file +} diff --git a/_sources/generated.nix b/_sources/generated.nix index 18fcd1bc..3a0431eb 100644 --- a/_sources/generated.nix +++ b/_sources/generated.nix @@ -409,6 +409,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"; diff --git a/modules/home-manager/waybar.nix b/modules/home-manager/waybar.nix new file mode 100644 index 00000000..c58e9491 --- /dev/null +++ b/modules/home-manager/waybar.nix @@ -0,0 +1,18 @@ +{ 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"; + + config.programs.waybar = lib.mkIf enable { + style = lib.mkBefore '' + @import "${sources.waybar}/themes/${cfg.flavour}.css"; + ''; + }; +} diff --git a/nvfetcher.toml b/nvfetcher.toml index 9ca792a5..13c31d21 100644 --- a/nvfetcher.toml +++ b/nvfetcher.toml @@ -134,6 +134,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" diff --git a/test.nix b/test.nix index 12bb5ca4..5b59716c 100644 --- a/test.nix +++ b/test.nix @@ -87,6 +87,7 @@ in swaylock = enable; tmux = enable; tofi = enable; + waybar = enable; yazi = enable; zathura = enable; zellij = enable; From 7bac8a8386be264122583840f545713e6cd31f12 Mon Sep 17 00:00:00 2001 From: Lichthagel Date: Sat, 20 Apr 2024 10:38:18 +0200 Subject: [PATCH 2/8] 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; }; }; } From 61adcefb4956dbd62e8abcbeede2f623062976c2 Mon Sep 17 00:00:00 2001 From: Lichthagel Date: Tue, 23 Apr 2024 23:28:59 +0200 Subject: [PATCH 3/8] fix(home-manager/waybar): inline styleFile --- modules/home-manager/waybar.nix | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/home-manager/waybar.nix b/modules/home-manager/waybar.nix index 0d24c03e..c0cebbf3 100644 --- a/modules/home-manager/waybar.nix +++ b/modules/home-manager/waybar.nix @@ -1,7 +1,8 @@ -{ config -, lib -, sources -, ... +{ + config, + lib, + sources, + ... }: let cfg = config.programs.waybar.catppuccin; @@ -9,12 +10,6 @@ let in { 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"; - }; - prependImport = lib.mkOption { type = lib.types.bool; default = false; @@ -28,13 +23,18 @@ in }; }; - config = lib.mkIf enable { - programs.waybar.style = lib.mkIf cfg.prependImport ( - lib.mkBefore '' - @import "${cfg.styleFile}"; - '' - ); + config = lib.mkIf enable ( + let + styleFile = "${sources.waybar}/themes/${cfg.flavour}.css"; + in + { + programs.waybar.style = lib.mkIf cfg.prependImport ( + lib.mkBefore '' + @import "${styleFile}"; + '' + ); - xdg.configFile."waybar/catppuccin.css" = lib.mkIf cfg.createLink { source = cfg.styleFile; }; - }; + xdg.configFile."waybar/catppuccin.css" = lib.mkIf cfg.createLink { source = styleFile; }; + } + ); } From 65ee90f53b24eff03b2bcf833213ac046284ba1e Mon Sep 17 00:00:00 2001 From: Lichthagel Date: Tue, 23 Apr 2024 23:30:10 +0200 Subject: [PATCH 4/8] fix(home-manager/waybar): make prependImport and createLink mutually exclusive --- modules/home-manager/waybar.nix | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/modules/home-manager/waybar.nix b/modules/home-manager/waybar.nix index c0cebbf3..d6f4fcd9 100644 --- a/modules/home-manager/waybar.nix +++ b/modules/home-manager/waybar.nix @@ -1,8 +1,7 @@ -{ - config, - lib, - sources, - ... +{ config +, lib +, sources +, ... }: let cfg = config.programs.waybar.catppuccin; @@ -10,16 +9,13 @@ let 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)."; }; }; @@ -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; + }; } ); } From e2752dfcd630a89abb3193a99c1a0e4c84c0e97f Mon Sep 17 00:00:00 2001 From: Lichthagel Date: Tue, 23 Apr 2024 23:40:55 +0200 Subject: [PATCH 5/8] feat(home-manager/waybar): warn if prependImport has no effect --- modules/home-manager/waybar.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/home-manager/waybar.nix b/modules/home-manager/waybar.nix index d6f4fcd9..ca67af7d 100644 --- a/modules/home-manager/waybar.nix +++ b/modules/home-manager/waybar.nix @@ -1,4 +1,5 @@ { config +, options , lib , sources , ... @@ -24,6 +25,14 @@ in styleFile = "${sources.waybar}/themes/${cfg.flavour}.css"; in { + warnings = + lib.optional + ( + cfg.mode == "prependImport" + && options.programs.waybar.style.highestPrio < lib.modules.defaultOverridePriority + ) + "`programs.waybar.style` is set to a string with a lower priority value than the default ${toString lib.modules.defaultOverridePriority}. `programs.waybar.catppucccin.mode = \"prependImport\"` will have no effect."; + programs.waybar.style = lib.mkIf (cfg.mode == "prependImport") ( lib.mkBefore '' @import "${styleFile}"; From 84ec24ab5d9aec95441c1041bd4c8e15124d5ab6 Mon Sep 17 00:00:00 2001 From: Lichthagel Date: Thu, 25 Apr 2024 09:32:44 +0200 Subject: [PATCH 6/8] style(waybar): use mkMerge --- modules/home-manager/waybar.nix | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/modules/home-manager/waybar.nix b/modules/home-manager/waybar.nix index ca67af7d..912bcda8 100644 --- a/modules/home-manager/waybar.nix +++ b/modules/home-manager/waybar.nix @@ -7,6 +7,7 @@ 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") // { @@ -21,27 +22,19 @@ in }; config = lib.mkIf enable ( - let - styleFile = "${sources.waybar}/themes/${cfg.flavour}.css"; - in - { - warnings = - lib.optional - ( - cfg.mode == "prependImport" - && options.programs.waybar.style.highestPrio < lib.modules.defaultOverridePriority - ) - "`programs.waybar.style` is set to a string with a lower priority value than the default ${toString lib.modules.defaultOverridePriority}. `programs.waybar.catppucccin.mode = \"prependImport\"` will have no effect."; + lib.mkMerge [ + (lib.mkIf (cfg.mode == "prependImport") { + warnings = + lib.optional (options.programs.waybar.style.highestPrio < lib.modules.defaultOverridePriority) + "`programs.waybar.style` is set to a string with a lower priority value than the default ${toString lib.modules.defaultOverridePriority}. `programs.waybar.catppucccin.mode = \"prependImport\"` will have no effect."; - programs.waybar.style = lib.mkIf (cfg.mode == "prependImport") ( - lib.mkBefore '' + programs.waybar.style = lib.mkBefore '' @import "${styleFile}"; - '' - ); - - xdg.configFile."waybar/catppuccin.css" = lib.mkIf (cfg.mode == "createLink") { - source = styleFile; - }; - } + ''; + }) + (lib.mkIf (cfg.mode == "createLink") { + xdg.configFile."waybar/catppuccin.css".source = styleFile; + }) + ] ); } From 9e3443646bdea06a91f35700646891ef6bf5839c Mon Sep 17 00:00:00 2001 From: Lichthagel Date: Thu, 25 Apr 2024 09:37:49 +0200 Subject: [PATCH 7/8] fix(waybar): update description for mode option --- modules/home-manager/waybar.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/home-manager/waybar.nix b/modules/home-manager/waybar.nix index 912bcda8..5cdc7de8 100644 --- a/modules/home-manager/waybar.nix +++ b/modules/home-manager/waybar.nix @@ -17,7 +17,12 @@ in "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)."; + 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. + ''; }; }; From 992f1c37ab3a21c24e241740b699d8e702ea9fbf Mon Sep 17 00:00:00 2001 From: Lichthagel Date: Mon, 29 Apr 2024 20:20:47 +0200 Subject: [PATCH 8/8] refactor(home-manager/waybar): remove warning --- modules/home-manager/waybar.nix | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/home-manager/waybar.nix b/modules/home-manager/waybar.nix index 5cdc7de8..684e3bb4 100644 --- a/modules/home-manager/waybar.nix +++ b/modules/home-manager/waybar.nix @@ -29,10 +29,6 @@ in config = lib.mkIf enable ( lib.mkMerge [ (lib.mkIf (cfg.mode == "prependImport") { - warnings = - lib.optional (options.programs.waybar.style.highestPrio < lib.modules.defaultOverridePriority) - "`programs.waybar.style` is set to a string with a lower priority value than the default ${toString lib.modules.defaultOverridePriority}. `programs.waybar.catppucccin.mode = \"prependImport\"` will have no effect."; - programs.waybar.style = lib.mkBefore '' @import "${styleFile}"; '';