3
0
Fork 0
forked from mirrors/nixpkgs

lib/modules: Fix nonexistant option error

The refactoring in fd75dc8765
introduced a mistake in the error message that doesn't show the full
context anymore. E.g. with this module:

  options.foo.bar = lib.mkOption {
    type = lib.types.submodule {
      baz = 10;
    };
    default = {};
  };

You'd get the error

  The option `baz' defined in `/home/infinisil/src/nixpkgs/config.nix' does not exist.

instead of the previous

  The option `foo.bar.baz' defined in `/home/infinisil/src/nixpkgs/config.nix' does not exist.

This commit undoes this regression
This commit is contained in:
Silvan Mosberger 2020-08-18 00:12:36 +02:00
parent 1e3f09feaa
commit d5700d626c
No known key found for this signature in database
GPG key ID: E8F1E9EAD284E17D

View file

@ -115,8 +115,8 @@ rec {
checkUnmatched =
if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
let inherit (head merged.unmatchedDefns) file prefix;
in throw "The option `${showOption prefix}' defined in `${file}' does not exist."
let firstDef = head merged.unmatchedDefns;
in throw "The option `${showOption (prefix ++ firstDef.prefix)}' defined in `${firstDef.file}' does not exist."
else null;
result = builtins.seq checkUnmatched {