From d97ea69a81a7cadd42893c59d81f6a4f12ba9988 Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Thu, 14 Mar 2013 16:50:13 +0100 Subject: [PATCH] systemd: check service.name.Type and service.name.Restart --- modules/system/boot/systemd-unit-options.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/system/boot/systemd-unit-options.nix b/modules/system/boot/systemd-unit-options.nix index fd4d19d1dd0..e3542ce9225 100644 --- a/modules/system/boot/systemd-unit-options.nix +++ b/modules/system/boot/systemd-unit-options.nix @@ -145,6 +145,16 @@ rec { systemd.service 5 for details. ''; + + check = v: + let assertValueOneOf = name: values: attr: + let val = getAttr name attr; + in optional ( hasAttr name attr && !elem val values) "${name} ${val} not known to systemd"; + checkType = assertValueOneOf "Type" ["simple" "forking" "oneshot" "dbus" "notify" "idle"]; + checkRestart = assertValueOneOf "Restart" ["no" "on-success" "on-failure" "on-abort" "always"]; + errors = concatMap (c: c v) [checkType checkRestart]; + in if errors == [] then true + else builtins.trace (concatStringsSep "\n" errors) false; }; script = mkOption {