diff options
author | Silvan Mosberger <contact@infinisil.com> | 2020-08-04 00:08:43 +0200 |
---|---|---|
committer | Silvan Mosberger <contact@infinisil.com> | 2020-08-10 17:27:33 +0200 |
commit | e0ded8f4ba1529fdde28ff027d370c883864fcc8 (patch) | |
tree | cc4074076db653bdfa106d1a93a0ad90211eac64 /lib | |
parent | 446d80d28deb9929aca2a70699b3f32c2f1297d5 (diff) |
lib/modules: Fix freeform modules when there's no definitions
Diffstat (limited to 'lib')
-rw-r--r-- | lib/modules.nix | 3 | ||||
-rwxr-xr-x | lib/tests/modules.sh | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/modules.nix b/lib/modules.nix index daffe5224ab2..1d2c4a1acbb5 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -104,7 +104,8 @@ rec { file = def.file; value = setAttrByPath def.prefix def.value; }) merged.unmatchedDefns; - in declaredConfig._module.freeformType.merge prefix defs; + in if defs == [] then {} + else declaredConfig._module.freeformType.merge prefix defs; in if declaredConfig._module.freeformType == null then declaredConfig # Because all definitions that had an associated option ended in diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index 848b10e17f67..943deebe3c09 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -213,6 +213,8 @@ checkConfigError 'The option value .* in .* is not of type .*' \ ## Freeform modules # Assigning without a declared option should work checkConfigOutput 24 config.value ./freeform-attrsOf.nix ./define-value-string.nix +# No freeform assigments shouldn't make it error +checkConfigOutput '{ }' config ./freeform-attrsOf.nix # but only if the type matches checkConfigError 'The option value .* in .* is not of type .*' config.value ./freeform-attrsOf.nix ./define-value-list.nix # and properties should be applied |