git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #112819 (mkIf in systemd units)

@thelegy writes: 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. While I personally don't like that we can't easily use pushDownProperties from the module system and need to rely on internals, we *already* use internals for the mkOverride case, so adding another case for mkIf doesn't add a hard-to-find indirection. I'm merging this, since this fixes a valid use case and it shouldn't make refactoring worse than before.

commit2d5a31a3ef2ce5b9b2aca610377e655924999000 authoraszlig <aszlig@nix.build> dateSat 13 Feb 2021, 05:24 (6 years ago) parent29dcf5397718a3
1 file changed+4−2
nixos/modules/system/boot/systemd-lib.nix+4−2
nixos/modules/system/boot/systemd-lib.nix+4−2
@@ -92,10 +92,12 @@ in rec {
9292
9393 checkUnitConfig = group: checks: attrs: let
9494 # We're applied at the top-level type (attrsOf unitOption), so the actual
95− # unit options might contain attributes from mkOverride that we need to
95+ # unit options might contain attributes from mkOverride and mkIf that we need to
9696 # convert into single values before checking them.
9797 defs = mapAttrs (const (v:
98− if v._type or "" == "override" then v.content else v
98+ if v._type or "" == "override" then v.content
99+ else if v._type or "" == "if" then v.content
100+ else v
99101 )) attrs;
100102 errors = concatMap (c: c group defs) checks;
101103 in if errors == [] then true