diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-05-25 11:02:38 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-05-25 11:39:17 +0200 |
commit | b056948c005c642c68220c4d45a6273eeafc36c2 (patch) | |
tree | 8309090ca6bdf036177a440216924a0499256a3c /lib/types.nix | |
parent | 32bed83b1804de5e905a2459603dde2b958bb847 (diff) |
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
Diffstat (limited to 'lib/types.nix')
-rw-r--r-- | lib/types.nix | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/types.nix b/lib/types.nix index b4d29ac84d28..91b39f3a9cf8 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -114,13 +114,17 @@ rec { name = "list of ${elemType.name}s"; check = isList; merge = loc: defs: - map (x: x.value) (filter (x: x ? value) (concatLists (imap (n: def: imap (m: def': - (mergeDefinitions - (loc ++ ["[definition ${toString n}-entry ${toString m}]"]) - elemType - [{ inherit (def) file; value = def'; }] - ).optionalValue - ) def.value) defs))); + map (x: x.value) (filter (x: x ? value) (concatLists (imap (n: def: + if isList def.value then + imap (m: def': + (mergeDefinitions + (loc ++ ["[definition ${toString n}-entry ${toString m}]"]) + elemType + [{ inherit (def) file; value = def'; }] + ).optionalValue + ) def.value + else + throw "The option value `${showOption loc}' in `${def.file}' is not a list.") defs))); getSubOptions = prefix: elemType.getSubOptions (prefix ++ ["*"]); getSubModules = elemType.getSubModules; substSubModules = m: listOf (elemType.substSubModules m); |