diff options
author | Robert Hensing <robert@roberthensing.nl> | 2023-08-18 11:36:51 +0200 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2023-08-18 11:36:51 +0200 |
commit | 5ad01f1b6f1c3a9b0ebe0d81b51761cc80291f82 (patch) | |
tree | 76bd4303332501758d9101cba8d2bd4817c270df /lib/modules.nix | |
parent | ed9af6d93e7b1ae78cfae4cbfd2118cea7490c63 (diff) | |
download | nixpkgs-5ad01f1b6f1c3a9b0ebe0d81b51761cc80291f82.tar nixpkgs-5ad01f1b6f1c3a9b0ebe0d81b51761cc80291f82.tar.gz nixpkgs-5ad01f1b6f1c3a9b0ebe0d81b51761cc80291f82.tar.bz2 nixpkgs-5ad01f1b6f1c3a9b0ebe0d81b51761cc80291f82.tar.lz nixpkgs-5ad01f1b6f1c3a9b0ebe0d81b51761cc80291f82.tar.xz nixpkgs-5ad01f1b6f1c3a9b0ebe0d81b51761cc80291f82.tar.zst nixpkgs-5ad01f1b6f1c3a9b0ebe0d81b51761cc80291f82.zip |
lib/modules: Report a better error when option tree has bare type
Improves on 0d472a62012364d064f0b75f1da491242c6ae9c6 - https://github.com/NixOS/nixpkgs/pull/242339 We actually do have the file name. Thanks Shawn8901 for the [feedback]! feedback: https://github.com/NixOS/nixpkgs/pull/242339#issuecomment-1683107055
Diffstat (limited to 'lib/modules.nix')
-rw-r--r-- | lib/modules.nix | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/modules.nix b/lib/modules.nix index 9371ba4b27a..5c2fb48868c 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -633,7 +633,7 @@ let optionDecls = filter (m: m.options?_type && (m.options._type == "option" - || throwDeclarationTypeError loc m.options._type + || throwDeclarationTypeError loc m.options._type m._file ) ) decls; @@ -698,14 +698,14 @@ let ) unmatchedDefnsByName); }; - throwDeclarationTypeError = loc: actualTag: + throwDeclarationTypeError = loc: actualTag: file: let name = lib.strings.escapeNixIdentifier (lib.lists.last loc); path = showOption loc; depth = length loc; paragraphs = [ - "Expected an option declaration at option path `${path}` but got an attribute set with type ${actualTag}" + "In module ${file}: expected an option declaration at option path `${path}` but got an attribute set with type ${actualTag}" ] ++ optional (actualTag == "option-type") '' When declaring an option, you must wrap the type in a `mkOption` call. It should look somewhat like: ${comment} |