From 0dc4a6fa21ec216cc3145a5867025117eea8e8ce Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 30 Jul 2017 19:29:50 +0200 Subject: refactor --- custom/unit-status-mail.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/custom/unit-status-mail.nix b/custom/unit-status-mail.nix index c1947063..e43706ea 100644 --- a/custom/unit-status-mail.nix +++ b/custom/unit-status-mail.nix @@ -5,8 +5,7 @@ with lib; let cfg = config.systemd.status-mail; - systemdCfg = foldr singleCfg {} cfg.onFailure; - singleCfg = unitName: attrs: attrs // (setAttrByPath ["systemd" "services" unitName "onFailure"] ["unit-status-mail@%n.service"]); + serviceCfg = unitName: attrs: attrs // (setAttrByPath ["systemd" "services" unitName "onFailure"] ["unit-status-mail@%n.service"]); in { options = { systemd.status-mail = { @@ -28,7 +27,7 @@ in { }; }; - config = mkIf (cfg.onFailure != []) { + config = mkIf (cfg.onFailure != []) (foldr serviceCfg { systemd.services."unit-status-mail@" = { serviceConfig = { Type = "oneshot"; @@ -59,5 +58,5 @@ in { EOF ''; }; - }; + } cfg.onFailure); } -- cgit v1.2.3