systemd: check service.name.Type and service.name.Restart

This commit is contained in:
Marc Weber 2013-03-14 16:50:13 +01:00 committed by Evgeny Egorochkin
parent 1cb8c090e7
commit d97ea69a81

View File

@ -145,6 +145,16 @@ rec {
<citerefentry><refentrytitle>systemd.service</refentrytitle>
<manvolnum>5</manvolnum></citerefentry> 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 {