Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Override Option to Nix Home Manager module #633

Merged
merged 6 commits into from
Dec 27, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions nix/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ let
in
"{ " + inner + " }"
else
abort "Unexpected error! Please post a new issue...";
abort "Unexpected error! Please post a new issue and @benvonh...";

toNestedObject = attrSet:
let
Expand All @@ -72,7 +72,21 @@ in
type = types.str;
default = "";
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 {
Expand Down Expand Up @@ -538,8 +552,7 @@ in
(if pkgs ? nerd-fonts.jetbrains-mono
then pkgs.nerd-fonts.jetbrains-mono
# NOTE:(benvonh) Remove after next release 25.05
else pkgs.nerdfonts.override { fonts = [ "JetBrainsMono" ]; }
)
else pkgs.nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
];

# NOTE:(benvonh)
Expand All @@ -556,12 +569,15 @@ in
};

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) "";
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 {
target = "hyprpanel/config.json";
text = toNestedObject mergeSet;
text = toNestedObject fullSet;
onChange = "${pkgs.procps}/bin/pkill -u $USER -USR1 hyprpanel || true";
};

Expand Down
Loading