about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/tests/modules.sh5
-rw-r--r--lib/tests/modules/types-anything/equal-atoms.nix2
-rw-r--r--lib/tests/modules/types-anything/lists.nix4
-rw-r--r--lib/types.nix6
4 files changed, 7 insertions, 10 deletions
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh
index a14fe8cb30a5..a46434560d13 100755
--- a/lib/tests/modules.sh
+++ b/lib/tests/modules.sh
@@ -426,8 +426,8 @@ checkConfigOutput '^null$' config.value.l1.l2.foo ./types-anything/nested-attrs.
 checkConfigOutput '^null$' config.value.l1.l2.l3.foo ./types-anything/nested-attrs.nix
 # Attribute sets that are coercible to strings shouldn't be recursed into
 checkConfigOutput '^"foo"$' config.value.outPath ./types-anything/attrs-coercible.nix
-# Multiple lists aren't concatenated together
-checkConfigError 'The option .* has conflicting definitions' config.value ./types-anything/lists.nix
+# Multiple lists aren't concatenated together if their definitions are not equal
+checkConfigError 'The option .* has conflicting definition values' config.value ./types-anything/lists.nix
 # Check that all equalizable atoms can be used as long as all definitions are equal
 checkConfigOutput '^0$' config.value.int ./types-anything/equal-atoms.nix
 checkConfigOutput '^false$' config.value.bool ./types-anything/equal-atoms.nix
@@ -435,6 +435,7 @@ checkConfigOutput '^""$' config.value.string ./types-anything/equal-atoms.nix
 checkConfigOutput '^"/[^"]+"$' config.value.path ./types-anything/equal-atoms.nix
 checkConfigOutput '^null$' config.value.null ./types-anything/equal-atoms.nix
 checkConfigOutput '^0.1$' config.value.float ./types-anything/equal-atoms.nix
+checkConfigOutput '^\[1,"a",{"x":null}\]$' config.value.list ./types-anything/equal-atoms.nix
 # Functions can't be merged together
 checkConfigError "The option .value.multiple-lambdas.<function body>. has conflicting option types" config.applied.multiple-lambdas ./types-anything/functions.nix
 checkConfigOutput '^true$' config.valueIsFunction.single-lambda ./types-anything/functions.nix
diff --git a/lib/tests/modules/types-anything/equal-atoms.nix b/lib/tests/modules/types-anything/equal-atoms.nix
index 9925cfd60892..28d2b53ceee3 100644
--- a/lib/tests/modules/types-anything/equal-atoms.nix
+++ b/lib/tests/modules/types-anything/equal-atoms.nix
@@ -12,6 +12,7 @@
       value.path = ./.;
       value.null = null;
       value.float = 0.1;
+      value.list = [1 "a" {x=null;}];
     }
     {
       value.int = 0;
@@ -20,6 +21,7 @@
       value.path = ./.;
       value.null = null;
       value.float = 0.1;
+      value.list = [1 "a" {x=null;}];
     }
   ];
 
diff --git a/lib/tests/modules/types-anything/lists.nix b/lib/tests/modules/types-anything/lists.nix
index bd846afd3d18..21ca9d24f7a8 100644
--- a/lib/tests/modules/types-anything/lists.nix
+++ b/lib/tests/modules/types-anything/lists.nix
@@ -6,10 +6,10 @@
 
   config = lib.mkMerge [
     {
-      value = [ null ];
+      value = [ "a value" ];
     }
     {
-      value = [ null ];
+      value = [ "another value" ];
     }
   ];
 
diff --git a/lib/types.nix b/lib/types.nix
index 8b1d19ff2c61..06c4397cda2e 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -253,12 +253,6 @@ rec {
           mergeFunction = {
             # Recursively merge attribute sets
             set = (attrsOf anything).merge;
-            # Safe and deterministic behavior for lists is to only accept one definition
-            # listOf only used to apply mkIf and co.
-            list =
-              if length defs > 1
-              then throw "The option `${showOption loc}' has conflicting definitions, in ${showFiles (getFiles defs)}."
-              else (listOf anything).merge;
             # This is the type of packages, only accept a single definition
             stringCoercibleSet = mergeOneOption;
             lambda = loc: defs: arg: anything.merge