nixos/systemd-lib: allow mkIf in unitOption

`unitOption` is only used inside of `attrsOf` wich is perfectly capable of
handling the attrsets from `mkIf`, though the checkUnitConfig test
forbids it. This commit weakens that restriction to allow the usage of
`mkIf` inside of `systemd.services.<name>.serviceConfig.<something>`
etc.
This commit is contained in:
Jan Beinke 2021-02-11 22:18:21 +01:00
parent 758b29b5a2
commit 97718a3584
No known key found for this signature in database
GPG Key ID: ED675B2FE3FEA71D

View File

@ -92,10 +92,12 @@ in rec {
checkUnitConfig = group: checks: attrs: let checkUnitConfig = group: checks: attrs: let
# We're applied at the top-level type (attrsOf unitOption), so the actual # We're applied at the top-level type (attrsOf unitOption), so the actual
# unit options might contain attributes from mkOverride that we need to # unit options might contain attributes from mkOverride and mkIf that we need to
# convert into single values before checking them. # convert into single values before checking them.
defs = mapAttrs (const (v: defs = mapAttrs (const (v:
if v._type or "" == "override" then v.content else v if v._type or "" == "override" then v.content
else if v._type or "" == "if" then v.content
else v
)) attrs; )) attrs;
errors = concatMap (c: c group defs) checks; errors = concatMap (c: c group defs) checks;
in if errors == [] then true in if errors == [] then true