Add override option

This commit is contained in:
benvonh
2024-12-26 23:59:46 +10:00
parent 32c028167e
commit 60de63c5ad

View File

@@ -52,7 +52,7 @@ let
in in
"{ " + inner + " }" "{ " + inner + " }"
else else
abort "Unexpected error! Please post a new issue..."; abort "Unexpected error! Please post a new issue and @benvonh...";
toNestedObject = attrSet: toNestedObject = attrSet:
let let
@@ -72,7 +72,21 @@ in
type = types.str; type = types.str;
default = ""; default = "";
example = "catppuccin_mocha"; example = "catppuccin_mocha";
description = "Theme to import (see ./themes/*.json)"; description = "Theme to import (see ../themes/*.json)";
};
override = mkOption {
type = types.attrs;
default = {};
example = ''
{
theme.bar.menus.text = "#123ABC";
}
'';
description = ''
An arbitrary set to override the final config with.
Useful for overriding colors in your selected theme.
'';
}; };
layout = mkOption { layout = mkOption {
@@ -538,8 +552,7 @@ in
(if pkgs ? nerd-fonts.jetbrains-mono (if pkgs ? nerd-fonts.jetbrains-mono
then pkgs.nerd-fonts.jetbrains-mono then pkgs.nerd-fonts.jetbrains-mono
# NOTE:(benvonh) Remove after next release 25.05 # NOTE:(benvonh) Remove after next release 25.05
else pkgs.nerdfonts.override { fonts = [ "JetBrainsMono" ]; } else pkgs.nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
)
]; ];
# NOTE:(benvonh) # NOTE:(benvonh)
@@ -556,12 +569,15 @@ in
}; };
xdg.configFile.hyprpanel = let xdg.configFile.hyprpanel = let
theme = if cfg.theme != "" then builtins.fromJSON (builtins.readFile ../themes/${cfg.theme}.json) else {}; theme = if cfg.theme != ""
then builtins.fromJSON (builtins.readFile ../themes/${cfg.theme}.json)
else {};
flatSet = flattenAttrs (lib.attrsets.recursiveUpdate cfg.settings theme) ""; flatSet = flattenAttrs (lib.attrsets.recursiveUpdate cfg.settings theme) "";
mergeSet = if cfg.layout == null then flatSet else flatSet // cfg.layout; mergeSet = flatSet // (flattenAttrs cfg.override "");
fullSet = if cfg.layout == null then mergeSet else mergeSet // cfg.layout;
in { in {
target = "hyprpanel/config.json"; target = "hyprpanel/config.json";
text = toNestedObject mergeSet; text = toNestedObject fullSet;
onChange = "${pkgs.procps}/bin/pkill -u $USER -USR1 hyprpanel || true"; onChange = "${pkgs.procps}/bin/pkill -u $USER -USR1 hyprpanel || true";
}; };