1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

mako: remove criteria

No longer serves a purpose, was short lived and most people are either
using `settings` or will use `extraConfig`

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman 2025-05-27 11:16:30 -05:00
parent 654b686536
commit 6861cfa165
4 changed files with 18 additions and 143 deletions

View file

@ -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
<https://github.com/emersion/mako/blob/master/doc/mako.5.scd>.
'';
};
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;
};
};
}

View file

@ -1,5 +1,4 @@
{
mako-example-config = ./example-config.nix;
mako-deprecated-criteria = ./deprecated-criteria.nix;
mako-renamed-options = ./renamed-options.nix;
}

View file

@ -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}
'';
}

View file

@ -24,4 +24,4 @@ padding=5,10
progress-color=#4C7899
sort=-time
text-color=#FFFFFF
width=300
width=300