about summary refs log tree commit diff
path: root/lib/modules.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/modules.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/modules.nix')
-rw-r--r--lib/modules.nix8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index 412c7f1df712..de6fadbcb91c 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -117,7 +117,7 @@ rec {
         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
           let
             firstDef = head merged.unmatchedDefns;
-            baseMsg = "The option `${showOption (prefix ++ firstDef.prefix)}' defined in `${firstDef.file}' does not exist.";
+            baseMsg = "The option `${showOption (prefix ++ firstDef.prefix)}' does not exist. Definition values:${showDefs [ firstDef ]}";
           in
             if attrNames options == [ "_module" ]
               then throw ''
@@ -449,7 +449,7 @@ rec {
       # Handle properties, check types, and merge everything together.
       res =
         if opt.readOnly or false && length defs' > 1 then
-          throw "The option `${showOption loc}' is read-only, but it's set multiple times."
+          throw "The option `${showOption loc}' is read-only, but it's set multiple times. Definition values:${showDefs defs'}"
         else
           mergeDefinitions loc opt.type defs';
 
@@ -497,8 +497,8 @@ rec {
     mergedValue =
       if isDefined then
         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
-        else let firstInvalid = findFirst (def: ! type.check def.value) null defsFinal;
-        in throw "The option value `${showOption loc}' in `${firstInvalid.file}' is not of type `${type.description}'."
+        else let allInvalid = filter (def: ! type.check def.value) defsFinal;
+        in throw "A definition for option `${showOption loc}' is not of type `${type.description}'. Definition values:${showDefs allInvalid}"
       else
         # (nixos-option detects this specific error message and gives it special
         # handling.  If changed here, please change it there too.)