From 97718a3584377f9bce2f2b653c1b927c5d0f9286 Mon Sep 17 00:00:00 2001 From: Jan Beinke Date: Thu, 11 Feb 2021 22:18:21 +0100 Subject: [PATCH] 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..serviceConfig.` etc. --- nixos/modules/system/boot/systemd-lib.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nixos/modules/system/boot/systemd-lib.nix b/nixos/modules/system/boot/systemd-lib.nix index fa109394fedb..2dbf15031a08 100644 --- a/nixos/modules/system/boot/systemd-lib.nix +++ b/nixos/modules/system/boot/systemd-lib.nix @@ -92,10 +92,12 @@ in rec { checkUnitConfig = group: checks: attrs: let # 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. 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; errors = concatMap (c: c group defs) checks; in if errors == [] then true