mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-26 12:53:59 +03:00
systemd: check service.name.Type and service.name.Restart
This commit is contained in:
parent
1cb8c090e7
commit
d97ea69a81
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user