lib/modules: Fix nonexistant option error
The refactoring in https://github.com/NixOS/nixpkgs/commit/fd75dc876586bde8cdb683a6952a41132e8db166
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
commitd5700d626ceef8ba509f822ee6e3b0a41a5da89f
authorSilvan Mosberger <contact@infinisil.com>
dateTue 18 Aug 2020, 00:12 (6 years ago)
parent1e3f09f
lib/modules.nix+2−2
@@ -115,8 +115,8 @@ rec {
115115
116116 checkUnmatched =
117117 if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
118− let inherit (head merged.unmatchedDefns) file prefix;
119− in throw "The option `${showOption prefix}' defined in `${file}' does not exist."
118+ let firstDef = head merged.unmatchedDefns;
119+ in throw "The option `${showOption (prefix ++ firstDef.prefix)}' defined in `${firstDef.file}' does not exist."
120120 else null;
121121
122122 result = builtins.seq checkUnmatched {