Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

Improve types.listOf error message

If an option value is not a list, you now get

The option value `bla' in `file.nix' is not a list.

rather than

value is a string while a list was expected, at .../nixpkgs/lib/lists.nix:49:56

(cherry picked from commit b056948c005c642c68220c4d45a6273eeafc36c2)

+11 -7
+11 -7
lib/types.nix
··· 114 114 name = "list of ${elemType.name}s"; 115 115 check = isList; 116 116 merge = loc: defs: 117 - map (x: x.value) (filter (x: x ? value) (concatLists (imap (n: def: imap (m: def': 118 - (mergeDefinitions 119 - (loc ++ ["[definition ${toString n}-entry ${toString m}]"]) 120 - elemType 121 - [{ inherit (def) file; value = def'; }] 122 - ).optionalValue 123 - ) def.value) defs))); 117 + map (x: x.value) (filter (x: x ? value) (concatLists (imap (n: def: 118 + if isList def.value then 119 + imap (m: def': 120 + (mergeDefinitions 121 + (loc ++ ["[definition ${toString n}-entry ${toString m}]"]) 122 + elemType 123 + [{ inherit (def) file; value = def'; }] 124 + ).optionalValue 125 + ) def.value 126 + else 127 + throw "The option value `${showOption loc}' in `${def.file}' is not a list.") defs))); 124 128 getSubOptions = prefix: elemType.getSubOptions (prefix ++ ["*"]); 125 129 getSubModules = elemType.getSubModules; 126 130 substSubModules = m: listOf (elemType.substSubModules m);