forked from mirrors/nixpkgs
systemd: Add support for path units.
This allows to define systemd.path(5) units, for example like this: { systemd = let description = "Set Key Permissions for xyz.key"; in { paths.set-key-perms = { inherit description; before = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; pathConfig.PathChanged = "/run/keys/xyz.key"; }; services.set-key-perms = { inherit description; serviceConfig.Type = "oneshot"; script = "chown myspecialkeyuser /run/keys/xyz.key"; }; }; } The example here is actually useful in order to set permissions for the NixOps keys target to ensure those permisisons aren't reset whenever the key file is reuploaded. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
parent
6167da54ea
commit
9d8a8126e9
|
@ -321,6 +321,23 @@ in rec {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
pathOptions = unitOptions // {
|
||||||
|
|
||||||
|
pathConfig = mkOption {
|
||||||
|
default = {};
|
||||||
|
example = { PathChanged = "/some/path"; Unit = "changedpath.service"; };
|
||||||
|
type = types.attrsOf unitOption;
|
||||||
|
description = ''
|
||||||
|
Each attribute in this set specifies an option in the
|
||||||
|
<literal>[Path]</literal> section of the unit. See
|
||||||
|
<citerefentry><refentrytitle>systemd.path</refentrytitle>
|
||||||
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
mountOptions = unitOptions // {
|
mountOptions = unitOptions // {
|
||||||
|
|
||||||
what = mkOption {
|
what = mkOption {
|
||||||
|
|
|
@ -304,6 +304,15 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pathToUnit = name: def:
|
||||||
|
{ inherit (def) wantedBy requiredBy enable;
|
||||||
|
text = commonUnitText def +
|
||||||
|
''
|
||||||
|
[Path]
|
||||||
|
${attrsToSection def.pathConfig}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
mountToUnit = name: def:
|
mountToUnit = name: def:
|
||||||
{ inherit (def) wantedBy requiredBy enable;
|
{ inherit (def) wantedBy requiredBy enable;
|
||||||
text = commonUnitText def +
|
text = commonUnitText def +
|
||||||
|
@ -472,6 +481,13 @@ in
|
||||||
description = "Definition of systemd timer units.";
|
description = "Definition of systemd timer units.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.paths = mkOption {
|
||||||
|
default = {};
|
||||||
|
type = types.attrsOf types.optionSet;
|
||||||
|
options = [ pathOptions unitConfig ];
|
||||||
|
description = "Definition of systemd path units.";
|
||||||
|
};
|
||||||
|
|
||||||
systemd.mounts = mkOption {
|
systemd.mounts = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = types.listOf types.optionSet;
|
type = types.listOf types.optionSet;
|
||||||
|
@ -657,6 +673,7 @@ in
|
||||||
// mapAttrs' (n: v: nameValuePair "${n}.service" (serviceToUnit n v)) cfg.services
|
// mapAttrs' (n: v: nameValuePair "${n}.service" (serviceToUnit n v)) cfg.services
|
||||||
// mapAttrs' (n: v: nameValuePair "${n}.socket" (socketToUnit n v)) cfg.sockets
|
// mapAttrs' (n: v: nameValuePair "${n}.socket" (socketToUnit n v)) cfg.sockets
|
||||||
// mapAttrs' (n: v: nameValuePair "${n}.timer" (timerToUnit n v)) cfg.timers
|
// mapAttrs' (n: v: nameValuePair "${n}.timer" (timerToUnit n v)) cfg.timers
|
||||||
|
// mapAttrs' (n: v: nameValuePair "${n}.path" (pathToUnit n v)) cfg.paths
|
||||||
// listToAttrs (map
|
// listToAttrs (map
|
||||||
(v: let n = escapeSystemdPath v.where;
|
(v: let n = escapeSystemdPath v.where;
|
||||||
in nameValuePair "${n}.mount" (mountToUnit n v)) cfg.mounts)
|
in nameValuePair "${n}.mount" (mountToUnit n v)) cfg.mounts)
|
||||||
|
|
Loading…
Reference in a new issue