feat(swaylock): Catppuccin -> Rose Pine

This commit is contained in:
punkfairie 2024-10-20 12:59:09 -07:00
parent 6bc895a1f6
commit 1530686ee7
Signed by: punkfairie
GPG key ID: 01823C057725C266
2 changed files with 52 additions and 28 deletions

View file

@ -288,6 +288,18 @@
"url": "https://github.com/d2718nis/rose-pine-dunst/archive/496499eaed38a07ce4f79ec91baaf6e1e4c28bc5.tar.gz", "url": "https://github.com/d2718nis/rose-pine-dunst/archive/496499eaed38a07ce4f79ec91baaf6e1e4c28bc5.tar.gz",
"hash": "0x7cqbcn7zygab9xbmbarz06wxkj3wxxffwmka33ljhm8gk3x0ay" "hash": "0x7cqbcn7zygab9xbmbarz06wxkj3wxxffwmka33ljhm8gk3x0ay"
}, },
"rose-pine-swaylock": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "d2718nis",
"repo": "rose-pine-swaylock"
},
"branch": "main",
"revision": "8a2aefbc9996941535bb10f0df5357687c43c06a",
"url": "https://github.com/d2718nis/rose-pine-swaylock/archive/8a2aefbc9996941535bb10f0df5357687c43c06a.tar.gz",
"hash": "15inlf8j6vn5k9d71lzmxsrqn55qha1idmpxbk4v1ji0sywrw1f6"
},
"starship": { "starship": {
"type": "Git", "type": "Git",
"repository": { "repository": {

View file

@ -1,39 +1,51 @@
{ config, lib, ... }:
let
inherit (config.catppuccin) sources;
cfg = config.programs.swaylock.catppuccin;
in
{ {
options.programs.swaylock.catppuccin = { config,
enable = lib.mkEnableOption "Catppuccin theme" // { lib,
...
}: let
inherit (config.rose-pine) sources;
cfg = config.programs.swaylock.rose-pine;
themeName =
if (cfg.flavor == "main")
then "rose-pine"
else "rose-pine-${cfg.flavor}";
in {
options.programs.swaylock.rose-pine = {
enable =
lib.mkEnableOption "Rosé Pine theme"
// {
/* /*
global `catppuccin.enable` purposefully doesn't work here in configurations with a `home.stateVersion` global `rose-pine.enable` purposefully doesn't work here in
that is >= 23.05 configurations with a `home.stateVersion` that is >= 23.05
this is because the upstream module will automatically enable itself if `programs.swaylock.settings` this is because the upstream module will automatically enable itself if
is set in configurations with a `home.stateVersion` that is < 23.05. so, we can't use the `programs.swaylock.settings` is set in configurations with a
`programs.swaylock.enable` option to guard against defining this like we usually do, as when the `home.stateVersion` that is < 23.05. so, we can't use the
upstream `enable` option is unset on these systems it checks that same `settings` option we would be `programs.swaylock.enable` option to guard against defining this like we
defining if *our* and the upstream's `enable` option is `true` ...leading to a case of infinite usually do, as when the upstream `enable` option is unset on these
recursion where `programs.swaylock.settings` is only being defined if `programs.swaylock.settings` is systems it checks that same `settings` option we would be defining if
defined *our* and the upstream's `enable` option is `true` ...leading to a case
of infinite recursion where `programs.swaylock.settings` is only being
defined if `programs.swaylock.settings` is defined
debugging this was the most confusing and horrifying thing i've had to deal with throughout working on debugging this was the most confusing and horrifying thing i've had to
this project. deal with throughout working on this project.
- @getchoo - @getchoo
*/ */
default = lib.versionAtLeast config.home.stateVersion "23.05" && config.catppuccin.enable; default = lib.versionAtLeast config.home.stateVersion "23.05" && config.rose-pine.enable;
defaultText = lib.literalExpression '' defaultText = lib.literalExpression ''
`catppuccin.enable` if `home.stateVersion` is >= 23.05, false otherwise `rose-pine.enable` if `home.stateVersion` is >= 23.05, false otherwise.
Yes this is weird, and there's a funny story about it in the code comments Yes this is weird, and there's a funny story about it in the code comments.
''; '';
}; };
flavor = lib.ctp.mkFlavorOpt "swaylock"; flavor = lib.rp.mkFlavorOpt "swaylock";
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.swaylock.settings = lib.ctp.fromINI (sources.swaylock + "/themes/${cfg.flavor}.conf"); programs.swaylock.settings = lib.rp.fromINI (sources.swaylock + "/${themeName}");
}; };
} }