about summary refs log tree commit diff
path: root/lib/options.nix
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2020-09-16 20:05:53 +0200
committerSilvan Mosberger <contact@infinisil.com>2020-09-21 18:24:52 +0200
commitbdfcee2590b9eca62cfa5c45b7b774846232ee2f (patch)
treecc0bbc87c7db06f688f59e318e4feba655032aa9 /lib/options.nix
parent7c20e68f6be7b7421d8717cc8d0ad1dadef76c67 (diff)
downloadnixlib-bdfcee2590b9eca62cfa5c45b7b774846232ee2f.tar
nixlib-bdfcee2590b9eca62cfa5c45b7b774846232ee2f.tar.gz
nixlib-bdfcee2590b9eca62cfa5c45b7b774846232ee2f.tar.bz2
nixlib-bdfcee2590b9eca62cfa5c45b7b774846232ee2f.tar.lz
nixlib-bdfcee2590b9eca62cfa5c45b7b774846232ee2f.tar.xz
nixlib-bdfcee2590b9eca62cfa5c45b7b774846232ee2f.tar.zst
nixlib-bdfcee2590b9eca62cfa5c45b7b774846232ee2f.zip
lib/modules: Improve error messages using showDefs
Diffstat (limited to 'lib/options.nix')
-rw-r--r--lib/options.nix12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/options.nix b/lib/options.nix
index 73856573a5d1..5b7482c80937 100644
--- a/lib/options.nix
+++ b/lib/options.nix
@@ -96,12 +96,12 @@ rec {
     else if all isBool list then foldl' lib.or false list
     else if all isString list then lib.concatStrings list
     else if all isInt list && all (x: x == head list) list then head list
-    else throw "Cannot merge definitions of `${showOption loc}' given in ${showFiles (getFiles defs)}.";
+    else throw "Cannot merge definitions of `${showOption loc}'. Definition values:${showDefs defs}";
 
   mergeOneOption = loc: defs:
     if defs == [] then abort "This case should never happen."
     else if length defs != 1 then
-      throw "The unique option `${showOption loc}' is defined multiple times, in:\n - ${concatStringsSep "\n - " (getFiles defs)}."
+      throw "The unique option `${showOption loc}' is defined multiple times. Definition values:${showDefs defs}"
     else (head defs).value;
 
   /* "Merge" option definitions by checking that they all have the same value. */
@@ -111,11 +111,11 @@ rec {
     # This also makes it work for functions, because the foldl' below would try
     # to compare the first element with itself, which is false for functions
     else if length defs == 1 then (elemAt defs 0).value
-    else foldl' (val: def:
-      if def.value != val then
-        throw "The option `${showOption loc}' has conflicting definitions, in ${showFiles (getFiles defs)}."
+    else (foldl' (first: def:
+      if def.value != first.value then
+        throw "The option `${showOption loc}' has conflicting definition values:${showDefs [ first def ]}"
       else
-        val) (head defs).value defs;
+        first) (head defs) defs).value;
 
   /* Extracts values of all "value" keys of the given list.