summary refs log tree commit diff
path: root/lib/modules.nix
diff options
context:
space:
mode:
authorArnout Engelen <arnout@bzzt.net>2019-12-30 16:08:03 +0100
committerArnout Engelen <arnout@bzzt.net>2020-01-05 10:22:32 +0100
commit43ef3a8d003fd64477b2eabb41e617e23e10a05f (patch)
tree687928eef111a479ae06c4cf7c0cd0a5bc1e79c2 /lib/modules.nix
parent863794cbbac2b43a174c5295542d14847799d721 (diff)
downloadnixpkgs-43ef3a8d003fd64477b2eabb41e617e23e10a05f.tar
nixpkgs-43ef3a8d003fd64477b2eabb41e617e23e10a05f.tar.gz
nixpkgs-43ef3a8d003fd64477b2eabb41e617e23e10a05f.tar.bz2
nixpkgs-43ef3a8d003fd64477b2eabb41e617e23e10a05f.tar.lz
nixpkgs-43ef3a8d003fd64477b2eabb41e617e23e10a05f.tar.xz
nixpkgs-43ef3a8d003fd64477b2eabb41e617e23e10a05f.tar.zst
nixpkgs-43ef3a8d003fd64477b2eabb41e617e23e10a05f.zip
lib/modules: clarify error message of 'assigning to top-level attribute'
If I understand correctly, the problem isn't so much that you're assigning to
that top-level attribute, but that the assignment to the attribute (or any
child of the attribute) introduces the 'config' object and prevents 'lifting'
all settings to a generated 'config' object.
Diffstat (limited to 'lib/modules.nix')
-rw-r--r--lib/modules.nix2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index 44db77b5d1c..d2489947d86 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -123,7 +123,7 @@ rec {
     if m ? config || m ? options then
       let badAttrs = removeAttrs m ["_file" "key" "disabledModules" "imports" "options" "config" "meta"]; in
       if badAttrs != {} then
-        throw "Module `${key}' has an unsupported attribute `${head (attrNames badAttrs)}'. This is caused by assignments to the top-level attributes `config' or `options'."
+        throw "Module `${key}' has an unsupported attribute `${head (attrNames badAttrs)}'. This is caused by introducing a top-level `config' or `options' attribute. Add configuration attributes immediately on the top level instead, or move all of them (namely: ${toString (attrNames badAttrs)}) into the explicit `config' attribute."
       else
         { file = m._file or file;
           key = toString m.key or key;