diff options
author | Robert Helgesson <robert@rycee.net> | 2019-04-10 00:40:45 +0200 |
---|---|---|
committer | Robert Helgesson <robert@rycee.net> | 2019-04-12 01:02:12 +0200 |
commit | 12cb82af912c3aa1c664c018c8f08cf17bc34c08 (patch) | |
tree | 568d594b51e585f83a046ec10e77fd14bc03d6f9 /modules/systemd.nix | |
parent | d49b514aa610f7412e4d030b159daf978ee2281e (diff) |
systemd: make the unit option type more robust
This should allow more sensible merging behavior. In particular, with
this change it is possible to use, for example, `mkForce` for greater
control of merging.
Fixes #543
Diffstat (limited to 'modules/systemd.nix')
-rw-r--r-- | modules/systemd.nix | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/modules/systemd.nix b/modules/systemd.nix index 051aee94180..2a67bb31848 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -58,9 +58,14 @@ let servicesStartTimeoutMs = builtins.toString cfg.servicesStartTimeoutMs; - attrsRecursivelyMerged = types.attrs // { - merge = loc: foldl' (res: def: recursiveUpdate res def.value) {}; - }; + unitType = unitKind: with types; + let + primitive = either bool (either int str); + in + attrsOf (attrsOf (attrsOf (either primitive (listOf primitive)))) + // { + description = "systemd ${unitKind} unit configuration"; + }; unitDescription = type: '' Definition of systemd per-user ${type} units. Attributes are @@ -78,6 +83,7 @@ let { Unit = { Description = "Example description"; + Documentation = [ "man:example(1)" "man:example(5)" ]; }; ${type} = { @@ -113,35 +119,35 @@ in services = mkOption { default = {}; - type = attrsRecursivelyMerged; + type = unitType "service"; description = unitDescription "service"; example = unitExample "Service"; }; sockets = mkOption { default = {}; - type = attrsRecursivelyMerged; + type = unitType "socket"; description = unitDescription "socket"; example = unitExample "Socket"; }; targets = mkOption { default = {}; - type = attrsRecursivelyMerged; + type = unitType "target"; description = unitDescription "target"; example = unitExample "Target"; }; timers = mkOption { default = {}; - type = attrsRecursivelyMerged; + type = unitType "timer"; description = unitDescription "timer"; example = unitExample "Timer"; }; paths = mkOption { default = {}; - type = attrsRecursivelyMerged; + type = unitType "path"; description = unitDescription "path"; example = unitExample "Path"; }; |