Skip to content

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

Closed
wants to merge 1 commit into from

3 participants

@MarcWeber

No description provided.

@nbp nbp commented on the diff Mar 23, 2013
modules/system/boot/systemd-unit-options.nix
@@ -139,6 +139,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"];
@nbp
Official Nix/Nixpkgs/NixOS member
nbp added a note Mar 23, 2013

This sounds to me that we should make a type of of this and enable the syntax:

type = types.attrsOf {
Type = types.anyOf ["simple" "forking" …];
Restart = types.anyOf ["no" "on-success" …];
};

what do you think?

@MarcWeber
MarcWeber added a note Mar 24, 2013

Keep in mind that you may want to check both: mandatory and optional names. That's why mkOption would be a bad option here. Except that types.attrsOf sounds like a good idea - if its documented properly :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Phreedom
Official Nix/Nixpkgs/NixOS member
Phreedom commented May 5, 2013

Any objections to merging the original proposal for now?

@Phreedom Phreedom was assigned May 5, 2013
@Phreedom
Official Nix/Nixpkgs/NixOS member

cherry-picked to avoid ugly branch mess: d97ea69

@Phreedom Phreedom closed this Aug 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.