about summary refs log tree commit diff
path: root/lib/modules.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-28 19:48:30 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-28 22:45:57 +0100
commit73f32d03758a53ad1baac31795cfd99e325032f3 (patch)
tree8df21c7319e758a85a4916890714b0d90c631a67 /lib/modules.nix
parentdbefab9cf42c09444dd2554380104096969c0728 (diff)
downloadnixlib-73f32d03758a53ad1baac31795cfd99e325032f3.tar
nixlib-73f32d03758a53ad1baac31795cfd99e325032f3.tar.gz
nixlib-73f32d03758a53ad1baac31795cfd99e325032f3.tar.bz2
nixlib-73f32d03758a53ad1baac31795cfd99e325032f3.tar.lz
nixlib-73f32d03758a53ad1baac31795cfd99e325032f3.tar.xz
nixlib-73f32d03758a53ad1baac31795cfd99e325032f3.tar.zst
nixlib-73f32d03758a53ad1baac31795cfd99e325032f3.zip
Show precise error messages in option merge failures
For instance, if time.timeZone is defined multiple times, you now get
the error message:

  error: user-thrown exception: The unique option `time.timeZone' is defined multiple times, in `/etc/nixos/configurations/misc/eelco/x11vnc.nix' and `/etc/nixos/configuration.nix'.

while previously you got:

  error: user-thrown exception: Multiple definitions of string. Only one is allowed for this option.

and only an inspection of the stack trace gave a clue as to what
option caused the problem.
Diffstat (limited to 'lib/modules.nix')
-rw-r--r--lib/modules.nix4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index d141838d466c..d2b747339449 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -128,7 +128,7 @@ rec {
          opt.options ? apply && res ? apply ||
          opt.options ? type && res ? type
       then
-        throw "The option `${showOption loc}' in `${opt.file}' is already declared in ${concatStringsSep " and " (map (d: "`${d}'") res.declarations)}."
+        throw "The option `${showOption loc}' in `${opt.file}' is already declared in ${showFiles res.declarations}."
       else
         opt.options // res //
           { declarations = [opt.file] ++ res.declarations;
@@ -153,7 +153,7 @@ rec {
           fold (def: res:
             if opt.type.check def.value then res
             else throw "The option value `${showOption loc}' in `${def.file}' is not a ${opt.type.name}.")
-            (opt.type.merge' { prefix = loc; } (map (m: m.value) defsFinal)) defsFinal;
+            (opt.type.merge { prefix = loc; files = map (m: m.file) defsFinal; } (map (m: m.value) defsFinal)) defsFinal;
       # Finally, apply the ‘apply’ function to the merged
       # value.  This allows options to yield a value computed
       # from the definitions.