diff options
author | Silvan Mosberger <contact@infinisil.com> | 2020-09-21 18:10:06 +0200 |
---|---|---|
committer | Silvan Mosberger <contact@infinisil.com> | 2020-09-21 18:24:52 +0200 |
commit | 910dfdc41e134474b605ebd1f380e1b74d1a5e40 (patch) | |
tree | 57d7dce8aeae875e1a676838755a8ceae93b8cc8 | |
parent | bdfcee2590b9eca62cfa5c45b7b774846232ee2f (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.
-rw-r--r-- | lib/modules.nix | 8 |
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'; |