summary refs log tree commit diff
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2023-07-11 12:48:16 +0200
committerRobert Hensing <robert@roberthensing.nl>2023-07-11 13:03:52 +0200
commit8014460c4dbf26d6f962c01920b2c25fc00e0d03 (patch)
tree4fad240637c258d519f2b7595d4e0e9ff01f2ffe
parent8f700580b984290adefa4b32ce1abafda04af6cf (diff)
downloadnixpkgs-8014460c4dbf26d6f962c01920b2c25fc00e0d03.tar
nixpkgs-8014460c4dbf26d6f962c01920b2c25fc00e0d03.tar.gz
nixpkgs-8014460c4dbf26d6f962c01920b2c25fc00e0d03.tar.bz2
nixpkgs-8014460c4dbf26d6f962c01920b2c25fc00e0d03.tar.lz
nixpkgs-8014460c4dbf26d6f962c01920b2c25fc00e0d03.tar.xz
nixpkgs-8014460c4dbf26d6f962c01920b2c25fc00e0d03.tar.zst
nixpkgs-8014460c4dbf26d6f962c01920b2c25fc00e0d03.zip
lib.mergeModules: Add context to error message
-rw-r--r--lib/modules.nix5
-rwxr-xr-xlib/tests/modules.sh2
2 files changed, 5 insertions, 2 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index de0fcce6ef4..f16df20425e 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -565,8 +565,11 @@ let
         assert
           lib.all
             (c:
+              # TODO: I have my doubts that this error would occur when option definitions are not matched.
+              #       The implementation of this check used to be tied to a superficially similar check for
+              #       options, so maybe that's why this is here.
               isAttrs c.config || throw ''
-                You're trying to define a value of type `${builtins.typeOf c.config}'
+                In module `${c.file}', you're trying to define a value of type `${builtins.typeOf c.config}'
                 rather than an attribute set for the option
                 `${builtins.concatStringsSep "." prefix}'!
 
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh
index f5f0701c63a..50f24c09ca4 100755
--- a/lib/tests/modules.sh
+++ b/lib/tests/modules.sh
@@ -207,7 +207,7 @@ checkConfigOutput '^"foo"$' config.submodule.foo ./declare-submoduleWith-special
 ## shorthandOnlyDefines config behaves as expected
 checkConfigOutput '^true$' config.submodule.config ./declare-submoduleWith-shorthand.nix ./define-submoduleWith-shorthand.nix
 checkConfigError 'is not of type `boolean' config.submodule.config ./declare-submoduleWith-shorthand.nix ./define-submoduleWith-noshorthand.nix
-checkConfigError "You're trying to define a value of type \`bool'\n\s*rather than an attribute set for the option" config.submodule.config ./declare-submoduleWith-noshorthand.nix ./define-submoduleWith-shorthand.nix
+checkConfigError "In module ..*define-submoduleWith-shorthand.nix., you're trying to define a value of type \`bool'\n\s*rather than an attribute set for the option" config.submodule.config ./declare-submoduleWith-noshorthand.nix ./define-submoduleWith-shorthand.nix
 checkConfigOutput '^true$' config.submodule.config ./declare-submoduleWith-noshorthand.nix ./define-submoduleWith-noshorthand.nix
 
 ## submoduleWith should merge all modules in one swoop