From f86de05ca6a4975cffbd6031af2f9a2a72c4d525 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 8 Feb 2022 12:50:06 +0100 Subject: [PATCH] nixos/systemd: Custom error when mixing list/non-list defs --- nixos/lib/systemd-unit-options.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/nixos/lib/systemd-unit-options.nix b/nixos/lib/systemd-unit-options.nix index 520f2e982a26..f536c976d90d 100644 --- a/nixos/lib/systemd-unit-options.nix +++ b/nixos/lib/systemd-unit-options.nix @@ -20,10 +20,15 @@ in rec { merge = loc: defs: let defs' = filterOverrides defs; - defs'' = getValues defs'; in - if isList (head defs'') - then concatLists defs'' + if isList (head defs').value + then concatMap (def: + if builtins.typeOf def.value == "list" + then def.value + else + throw "The definitions for systemd unit options should be either all lists, representing repeatable options, or all non-lists, but for the option ${showOption loc}, the definitions are a mix of list and non-list ${lib.options.showDefs defs'}" + ) defs' + else mergeEqualOption loc defs'; };