From 623ab3dc7cb4c35adf711bcb2b4a5dd5a12fdc3f Mon Sep 17 00:00:00 2001 From: wxlyyy <1556588440@qq.com> Date: Thu, 8 Jan 2026 21:43:55 +0800 Subject: [PATCH] Nix: add plugin config options --- nix/home-module.nix | 73 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/nix/home-module.nix b/nix/home-module.nix index 2d7450b5b..1d7e89d5e 100644 --- a/nix/home-module.nix +++ b/nix/home-module.nix @@ -124,6 +124,62 @@ in ''; }; + plugins = lib.mkOption { + type = + with lib.types; + oneOf [ + jsonFormat.type + str + path + ]; + default = { }; + example = lib.literalExpression '' + { + sources = [ + { + enabled = true; + name = "Official Noctalia Plugins"; + url = "https://github.com/noctalia-dev/noctalia-plugins"; + } + ]; + states = { + catwalk = { + enabled = true; + sourceUrl = "https://github.com/noctalia-dev/noctalia-plugins"; + }; + }; + version = 1; + } + ''; + description = '' + Noctalia shell plugin configuration as an attribute set, string + or filepath, to be written to ~/.config/noctalia/plugins.json. + ''; + }; + + pluginSettings = lib.mkOption { + type = + with lib.types; + attrsOf (oneOf [ + jsonFormat.type + str + path + ]); + default = { }; + example = lib.literalExpression '' + { + catwalk = { + minimumThreshold = 25; + hideBackground = true; + }; + } + ''; + description = '' + Each plugin’s settings as an attribute set, string + or filepath, to be written to ~/.config/noctalia/plugins/plugin-name/settings.json. + ''; + }; + app2unit.package = lib.mkOption { type = lib.types.package; default = pkgs.app2unit; @@ -147,9 +203,13 @@ in X-Restart-Triggers = lib.optional (cfg.settings != { }) config.xdg.configFile."noctalia/settings.json".source ++ lib.optional (cfg.colors != { }) config.xdg.configFile."noctalia/colors.json".source + ++ lib.optional (cfg.plugins != { }) config.xdg.configFile."noctalia/plugins.json".source ++ lib.optional ( cfg.user-templates != { } - ) config.xdg.configFile."noctalia/user-templates.toml".source; + ) config.xdg.configFile."noctalia/user-templates.toml".source + ++ lib.mapAttrsToList ( + name: value: config.xdg.configFile."noctalia/plugins/${name}/settings.json".source + ) cfg.pluginSettings; }; Service = { @@ -173,6 +233,9 @@ in "noctalia/colors.json" = lib.mkIf (cfg.colors != { }) { source = generateJson "colors" cfg.colors; }; + "noctalia/plugins.json" = lib.mkIf (cfg.plugins != { }) { + source = generateJson "plugins" cfg.plugins; + }; "noctalia/user-templates.toml" = lib.mkIf (cfg.user-templates != { }) { source = if lib.isString cfg.user-templates then @@ -182,7 +245,13 @@ in else tomlFormat.generate "noctalia-user-templates.toml" cfg.user-templates; }; - }; + } + // lib.mapAttrs' ( + name: value: + lib.nameValuePair "noctalia/plugins/${name}/settings.json" { + source = generateJson "${name}-settings" value; + } + ) cfg.pluginSettings; assertions = [ {