Skip to content

Commit d572d95

Browse files
authored
lib.types.anything: remove custom logic for lists (#340202)
2 parents 631a4db + e5e69b7 commit d572d95

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

lib/tests/modules.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,15 +429,16 @@ checkConfigOutput '^null$' config.value.l1.l2.foo ./types-anything/nested-attrs.
429429
checkConfigOutput '^null$' config.value.l1.l2.l3.foo ./types-anything/nested-attrs.nix
430430
# Attribute sets that are coercible to strings shouldn't be recursed into
431431
checkConfigOutput '^"foo"$' config.value.outPath ./types-anything/attrs-coercible.nix
432-
# Multiple lists aren't concatenated together
433-
checkConfigError 'The option .* has conflicting definitions' config.value ./types-anything/lists.nix
432+
# Multiple lists aren't concatenated together if their definitions are not equal
433+
checkConfigError 'The option .* has conflicting definition values' config.value ./types-anything/lists.nix
434434
# Check that all equalizable atoms can be used as long as all definitions are equal
435435
checkConfigOutput '^0$' config.value.int ./types-anything/equal-atoms.nix
436436
checkConfigOutput '^false$' config.value.bool ./types-anything/equal-atoms.nix
437437
checkConfigOutput '^""$' config.value.string ./types-anything/equal-atoms.nix
438438
checkConfigOutput '^"/[^"]+"$' config.value.path ./types-anything/equal-atoms.nix
439439
checkConfigOutput '^null$' config.value.null ./types-anything/equal-atoms.nix
440440
checkConfigOutput '^0.1$' config.value.float ./types-anything/equal-atoms.nix
441+
checkConfigOutput '^\[1,"a",{"x":null}\]$' config.value.list ./types-anything/equal-atoms.nix
441442
# Functions can't be merged together
442443
checkConfigError "The option .value.multiple-lambdas.<function body>. has conflicting option types" config.applied.multiple-lambdas ./types-anything/functions.nix
443444
checkConfigOutput '^true$' config.valueIsFunction.single-lambda ./types-anything/functions.nix

lib/tests/modules/types-anything/equal-atoms.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
value.path = ./.;
1313
value.null = null;
1414
value.float = 0.1;
15+
value.list = [1 "a" {x=null;}];
1516
}
1617
{
1718
value.int = 0;
@@ -20,6 +21,7 @@
2021
value.path = ./.;
2122
value.null = null;
2223
value.float = 0.1;
24+
value.list = [1 "a" {x=null;}];
2325
}
2426
];
2527

lib/tests/modules/types-anything/lists.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
config = lib.mkMerge [
88
{
9-
value = [ null ];
9+
value = [ "a value" ];
1010
}
1111
{
12-
value = [ null ];
12+
value = [ "another value" ];
1313
}
1414
];
1515

lib/types.nix

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,6 @@ rec {
253253
mergeFunction = {
254254
# Recursively merge attribute sets
255255
set = (attrsOf anything).merge;
256-
# Safe and deterministic behavior for lists is to only accept one definition
257-
# listOf only used to apply mkIf and co.
258-
list =
259-
if length defs > 1
260-
then throw "The option `${showOption loc}' has conflicting definitions, in ${showFiles (getFiles defs)}."
261-
else (listOf anything).merge;
262256
# This is the type of packages, only accept a single definition
263257
stringCoercibleSet = mergeOneOption;
264258
lambda = loc: defs: arg: anything.merge

0 commit comments

Comments
 (0)