rose-pine-nix/modules/home-manager/kvantum.nix
seth 1adbfeb44a
fix(home-manager): assert qt.style.name for kvantum theme (#242)
while having `qt.enable` be a prerequisite for this option applying
makes sense, the requirement on a specific `style.name` is not. this
make it more clear by moving that check to an assertion rather than an
internal comparison
2024-06-25 06:29:50 -04:00

54 lines
1.3 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
cfg = config.qt.style.catppuccin;
enable = cfg.enable && config.qt.enable;
flavorCapitalized = lib.ctp.mkUpper cfg.flavor;
accentCapitalized = lib.ctp.mkUpper cfg.accent;
theme = pkgs.catppuccin-kvantum.override {
accent = accentCapitalized;
variant = flavorCapitalized;
};
themeName = "Catppuccin-${flavorCapitalized}-${accentCapitalized}";
in
{
options.qt.style.catppuccin = lib.ctp.mkCatppuccinOpt "Kvantum" // {
accent = lib.ctp.mkAccentOpt "Kvantum";
apply = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Applies the theme by overwriting `$XDG_CONFIG_HOME/Kvantum/kvantum.kvconfig`.
If this is disabled, you must manually set the theme (e.g. by using `kvantummanager`).
'';
};
};
config = lib.mkIf enable {
assertions = [
{
assertion = lib.elem config.qt.style.name [
"kvantum"
"Kvantum"
];
message = ''`qt.style.name` must be `"kvantum"` to use `qt.style.catppuccin`'';
}
];
xdg.configFile = {
"Kvantum/${themeName}".source = "${theme}/share/Kvantum/${themeName}";
"Kvantum/kvantum.kvconfig" = lib.mkIf cfg.apply {
text = ''
[General]
theme=${themeName}
'';
};
};
};
}