Show precise error messages in option merge failures
For instance, if time.timeZone is defined multiple times, you now get the error message: error: user-thrown exception: The unique option `time.timeZone' is defined multiple times, in `/etc/nixos/configurations/misc/eelco/x11vnc.nix' and `/etc/nixos/configuration.nix'. while previously you got: error: user-thrown exception: Multiple definitions of string. Only one is allowed for this option. and only an inspection of the stack trace gave a clue as to what option caused the problem.
This commit is contained in:
+2
-2
@@ -128,7 +128,7 @@ rec {
|
||||
opt.options ? apply && res ? apply ||
|
||||
opt.options ? type && res ? type
|
||||
then
|
||||
throw "The option `${showOption loc}' in `${opt.file}' is already declared in ${concatStringsSep " and " (map (d: "`${d}'") res.declarations)}."
|
||||
throw "The option `${showOption loc}' in `${opt.file}' is already declared in ${showFiles res.declarations}."
|
||||
else
|
||||
opt.options // res //
|
||||
{ declarations = [opt.file] ++ res.declarations;
|
||||
@@ -153,7 +153,7 @@ rec {
|
||||
fold (def: res:
|
||||
if opt.type.check def.value then res
|
||||
else throw "The option value `${showOption loc}' in `${def.file}' is not a ${opt.type.name}.")
|
||||
(opt.type.merge' { prefix = loc; } (map (m: m.value) defsFinal)) defsFinal;
|
||||
(opt.type.merge { prefix = loc; files = map (m: m.file) defsFinal; } (map (m: m.value) defsFinal)) defsFinal;
|
||||
# Finally, apply the ‘apply’ function to the merged
|
||||
# value. This allows options to yield a value computed
|
||||
# from the definitions.
|
||||
|
||||
Reference in New Issue
Block a user