From 5c891e28bf02c00ca0762c873bab86db1b40cfcd Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 30 Jul 2017 19:32:57 +0200 Subject: refactor --- custom/unit-status-mail.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/custom/unit-status-mail.nix b/custom/unit-status-mail.nix index 13717ce9..4ad08667 100644 --- a/custom/unit-status-mail.nix +++ b/custom/unit-status-mail.nix @@ -4,8 +4,6 @@ with lib; let cfg = config.systemd.status-mail; - - serviceCfg = attrs: unitName: attrs // (setAttrByPath ["systemd" "services" unitName "onFailure"] ["unit-status-mail@%n.service"]); in { options = { systemd.status-mail = { @@ -27,7 +25,11 @@ in { }; }; - config = mkIf (cfg.onFailure != []) (foldl serviceCfg { + config = mkIf (cfg.onFailure != []) { + systemd.services = let + singleServiceCfg = attrs: unitName: attrs // (setAttrByPath [unitName "onFailure"] ["unit-status-mail@%n.service"]); + in foldl singleServiceCfg {} cfg.onFailure; + systemd.services."unit-status-mail@" = { serviceConfig = { Type = "oneshot"; @@ -58,5 +60,5 @@ in { EOF ''; }; - } cfg.onFailure); + }; } -- cgit v1.2.3