From 457abcbb2425c6402295162f42cfff332b25b705 Mon Sep 17 00:00:00 2001 From: punkfairie Date: Sun, 12 Jan 2025 15:59:03 -0800 Subject: [PATCH] feat(swaync): Add swaync --- .sources/sources.json | 12 +++++++++ modules/home-manager/swaync.nix | 43 +++++++++++++++++++++++++++++++++ tests/home.nix | 1 + 3 files changed, 56 insertions(+) create mode 100644 modules/home-manager/swaync.nix diff --git a/.sources/sources.json b/.sources/sources.json index 45f53d4..f7d7a19 100644 --- a/.sources/sources.json +++ b/.sources/sources.json @@ -335,6 +335,18 @@ "url": "https://github.com/catppuccin/sway/archive/5f9da99a43336583c7d5ebddf78d7b615911e5ea.tar.gz", "hash": "0n3fpb9pkmis932jv5b1gz045xyhw9cqybild20hsv45lr3r5f1q" }, + "swaync": { + "type": "Git", + "repository": { + "type": "GitHub", + "owner": "rose-pine", + "repo": "swaync" + }, + "branch": "main", + "revision": "fc17ee01916a5e4424af5c5b29272383fcdfc4f3", + "url": "https://github.com/rose-pine/swaync/archive/fc17ee01916a5e4424af5c5b29272383fcdfc4f3.tar.gz", + "hash": "13fq0qv009q80pfrwzgnk6ads4b4z82q2g7fala7rmh1nypl5ch4" + }, "tm-theme": { "type": "Git", "repository": { diff --git a/modules/home-manager/swaync.nix b/modules/home-manager/swaync.nix new file mode 100644 index 0000000..37435b7 --- /dev/null +++ b/modules/home-manager/swaync.nix @@ -0,0 +1,43 @@ +{ + config, + lib, + ... +}: let + inherit (config.rose-pine) sources; + + cfg = config.services.swaync.rose-pine; + enable = cfg.enable && config.services.swaync.enable; + + styleFile = "${sources.swaync}/${lib.rp.getKebabTheme cfg.flavor}.css"; +in { + options.services.swaync.rose-pine = + lib.rp.mkRosePineOpt {name = "swaync";} + // { + mode = lib.mkOption { + type = lib.types.enum [ + "prependImport" + "createLink" + ]; + default = "prependImport"; + description = '' + Defines how to include the Rosé Pine 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/rose-pine.css`, which needs to be included in the waybar stylesheet. + ''; + }; + }; + + config = lib.mkIf enable ( + lib.mkMerge [ + (lib.mkIf (cfg.mode == "prependImport") { + services.swaync.style = lib.mkBefore '' + @import "${styleFile}"; + ''; + }) + (lib.mkIf (cfg.mode == "createLink") { + xdg.configFile."swaync/rose-pine.css".source = styleFile; + }) + ] + ); +} diff --git a/tests/home.nix b/tests/home.nix index 8b24d7e..c3a75b0 100644 --- a/tests/home.nix +++ b/tests/home.nix @@ -46,6 +46,7 @@ polybar top & ''; }; + swaync.enable = true; }; wayland.windowManager.sway.enable = true;