diff --git a/modules/services/mako.nix b/modules/services/mako.nix index 8bf6a8fc3..49be40034 100644 --- a/modules/services/mako.nix +++ b/modules/services/mako.nix @@ -33,10 +33,13 @@ let sectionLines = lib.concatStringsSep "\n" (lib.mapAttrsToList formatSection sectionSettings); in - if sectionSettings != { } then globalLines + "\n" + sectionLines + "\n" else globalLines + "\n"; + lib.mkMerge [ + globalLines + (lib.mkIf (sectionSettings != { }) sectionLines) + (lib.mkIf (cfg.extraConfig != "") ("\n" + cfg.extraConfig)) + ]; iniFormat = pkgs.formats.ini { }; - iniType = iniFormat.type; iniAtomType = iniFormat.lib.types.atom; in { @@ -82,9 +85,13 @@ in (lib.mkRemovedOptionModule [ "services" "mako" - "extraConfig" - ] "Use services.mako.settings instead.") - (lib.mkRenamedOptionModule [ "services" "mako" "criterias" ] [ "services" "mako" "criteria" ]) + "criterias" + ] "Use services.mako.settings instead. If order is important, use `services.mako.extraConfig`.") + (lib.mkRemovedOptionModule [ + "services" + "mako" + "criteria" + ] "Use services.mako.settings instead. If order is important, use `services.mako.extraConfig`.") ] ++ lib.hm.deprecations.mkSettingsRenamedOptionModules basePath (basePath ++ [ "settings" ]) { transform = lib.hm.strings.toKebabCase; @@ -130,41 +137,6 @@ in . ''; }; - criteria = mkOption { - visible = false; - type = iniType; - default = { }; - example = { - "actionable=true" = { - anchor = "top-left"; - }; - - "app-name=Google\\ Chrome" = { - max-visible = "5"; - }; - - "field1=value field2=value" = { - text-alignment = "left"; - }; - }; - description = '' - Criteria for mako's config. All the details can be found in the - CRITERIA section in the official documentation. - - *Deprecated*: Use `settings` with nested attributes instead. For example: - ```nix - settings = { - # Global settings - anchor = "top-right"; - - # Criteria sections - "actionable=true" = { - anchor = "top-left"; - }; - }; - ``` - ''; - }; extraConfig = mkOption { default = ""; type = lib.types.lines; @@ -172,7 +144,7 @@ in [urgency=low] border-color=#b8bb26 ''; - description = "Additional configuration."; + description = "Additional configuration lines to inject directly into the generated config file."; }; }; @@ -181,44 +153,13 @@ in (lib.hm.assertions.assertPlatform "services.mako" pkgs lib.platforms.linux) ]; - warnings = lib.optional (cfg.criteria != { }) '' - The option `services.mako.criteria` is deprecated and will be removed in a future release. - Please use `services.mako.settings` with nested attributes instead. - - For example, instead of: - criteria = { - "actionable=true" = { - anchor = "top-left"; - }; - }; - - Use: - settings = { - # Global settings here... - - # Criteria sections - "actionable=true" = { - anchor = "top-left"; - }; - }; - ''; - home.packages = [ cfg.package ]; dbus.packages = [ cfg.package ]; - xdg.configFile."mako/config" = - mkIf (cfg.settings != { } || cfg.criteria != { } || cfg.extraConfig != "") - { - onChange = "${cfg.package}/bin/makoctl reload || true"; - text = - let - # Merge settings and criteria into a single attribute set - # where settings are at the top level and criteria are nested attributes - mergedConfig = cfg.settings // cfg.criteria; - generatedConfig = generateConfig mergedConfig; - in - if cfg.extraConfig != "" then generatedConfig + cfg.extraConfig + "\n" else generatedConfig; - }; + xdg.configFile."mako/config" = mkIf (cfg.settings != { } || cfg.extraConfig != "") { + onChange = "${cfg.package}/bin/makoctl reload || true"; + text = generateConfig cfg.settings; + }; }; } diff --git a/tests/modules/services/mako/default.nix b/tests/modules/services/mako/default.nix index 30940a679..eab99cc5a 100644 --- a/tests/modules/services/mako/default.nix +++ b/tests/modules/services/mako/default.nix @@ -1,5 +1,4 @@ { mako-example-config = ./example-config.nix; - mako-deprecated-criteria = ./deprecated-criteria.nix; mako-renamed-options = ./renamed-options.nix; } diff --git a/tests/modules/services/mako/deprecated-criteria.nix b/tests/modules/services/mako/deprecated-criteria.nix deleted file mode 100644 index 57d57d4dd..000000000 --- a/tests/modules/services/mako/deprecated-criteria.nix +++ /dev/null @@ -1,65 +0,0 @@ -{ - services.mako = { - enable = true; - # Global settings - settings = { - actions = true; - anchor = "top-right"; - background-color = "#000000"; - border-color = "#FFFFFF"; - border-radius = 0; - default-timeout = 0; - font = "monospace 10"; - height = 100; - width = 300; - icons = true; - ignore-timeout = false; - layer = "top"; - margin = 10; - markup = true; - }; - - # Using deprecated criteria option - criteria = { - "actionable=true" = { - anchor = "top-left"; - }; - "app-name=Google\\ Chrome" = { - max-visible = 5; - }; - "field1=value field2=value" = { - text-alignment = "left"; - }; - }; - }; - - test.asserts.warnings.expected = [ - '' - The option `services.mako.criteria` is deprecated and will be removed in a future release. - Please use `services.mako.settings` with nested attributes instead. - - For example, instead of: - criteria = { - "actionable=true" = { - anchor = "top-left"; - }; - }; - - Use: - settings = { - # Global settings here... - - # Criteria sections - "actionable=true" = { - anchor = "top-left"; - }; - }; - '' - ]; - - nmt.script = '' - assertFileExists home-files/.config/mako/config - assertFileContent home-files/.config/mako/config \ - ${./config} - ''; -} diff --git a/tests/modules/services/mako/renamed-options-config b/tests/modules/services/mako/renamed-options-config index 1a5481834..215cce6af 100644 --- a/tests/modules/services/mako/renamed-options-config +++ b/tests/modules/services/mako/renamed-options-config @@ -24,4 +24,4 @@ padding=5,10 progress-color=#4C7899 sort=-time text-color=#FFFFFF -width=300 +width=300 \ No newline at end of file