aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2020-09-21 18:10:06 +0200
committerSilvan Mosberger <contact@infinisil.com>2020-09-21 18:24:52 +0200
commit910dfdc41e134474b605ebd1f380e1b74d1a5e40 (patch)
tree57d7dce8aeae875e1a676838755a8ceae93b8cc8 /lib
parentbdfcee2590b9eca62cfa5c45b7b774846232ee2f (diff)
lib/modules: Evaluate single defs for readOnly error
If multiple definitions are passed, this evaluates them all as if they were the only one, for a better error message. In particular this won't show module-internal properties like `_type = "override"` and co.
Diffstat (limited to 'lib')
-rw-r--r--lib/modules.nix8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index de6fadbcb91c..02a669df6593 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -449,7 +449,13 @@ 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. Definition values:${showDefs defs'}"
+ let
+ # For a better error message, evaluate all readOnly definitions as
+ # if they were the only definition.
+ separateDefs = map (def: def // {
+ value = (mergeDefinitions loc opt.type [ def ]).mergedValue;
+ }) defs';
+ in throw "The option `${showOption loc}' is read-only, but it's set multiple times. Definition values:${showDefs separateDefs}"
else
mergeDefinitions loc opt.type defs';