From 51e1d69f7a99446e5ef109ec5ed66b982e0434ca Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Fri, 20 Sep 2024 23:29:26 +0100 Subject: [PATCH] poweralertd: fix regression This fixes a regression introduced in 8d7e352a4b25ac2d88a881ffa3472680af916ddc. That commit made the false assumption that utils would have propagated from Nixpkgs to Home Manager. This commit copies in `escapeSystemdExecArgs` to fix the immediate issue, perhaps we can pull this in some other way later down the line. --- modules/services/poweralertd.nix | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/modules/services/poweralertd.nix b/modules/services/poweralertd.nix index 7010b0797..9c59ad3f0 100644 --- a/modules/services/poweralertd.nix +++ b/modules/services/poweralertd.nix @@ -2,8 +2,22 @@ with lib; -let cfg = config.services.poweralertd; - +let + inherit (lib.strings) toJSON; + cfg = config.services.poweralertd; + escapeSystemdExecArg = arg: + let + s = if isPath arg then + "${arg}" + else if isString arg then + arg + else if isInt arg || isFloat arg || isDerivation arg then + toString arg + else + throw + "escapeSystemdExecArg only allows strings, paths, numbers and derivations"; + in replaceStrings [ "%" "$" ] [ "%%" "$$" ] (toJSON s); + escapeSystemdExecArgs = concatMapStringsSep " " escapeSystemdExecArg; in { meta.maintainers = [ maintainers.thibautmarty ]; @@ -39,7 +53,7 @@ in { Service = { Type = "simple"; ExecStart = "${pkgs.poweralertd}/bin/poweralertd ${ - utils.escapeSystemdExecArgs cfg.extraArgs + escapeSystemdExecArgs cfg.extraArgs }"; Restart = "always"; };