diff options
author | Robert Hensing <robert@roberthensing.nl> | 2022-12-10 23:23:42 +0100 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2022-12-10 23:23:42 +0100 |
commit | 5fb20d2f8cad7a6332baafbb2986ac0ef16c6fc7 (patch) | |
tree | 81611de2a9224bfe6575c9683000c7f0d0a05c5c /lib/options.nix | |
parent | 1dba7adaf38be385effb1fdc9d7001dd4c455cfa (diff) |
lib.modules: Add error context to rendered default and example attrs
Diffstat (limited to 'lib/options.nix')
-rw-r--r-- | lib/options.nix | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/options.nix b/lib/options.nix index b13687576e810..0fd5b64a65d14 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -221,9 +221,10 @@ rec { optionAttrSetToDocList' = _: options: concatMap (opt: let + name = showOption opt.loc; docOption = rec { loc = opt.loc; - name = showOption opt.loc; + inherit name; description = opt.description or null; declarations = filter (x: x != unknownModule) opt.declarations; internal = opt.internal or false; @@ -234,8 +235,18 @@ rec { readOnly = opt.readOnly or false; type = opt.type.description or "unspecified"; } - // optionalAttrs (opt ? example) { example = renderOptionValue opt.example; } - // optionalAttrs (opt ? default) { default = renderOptionValue (opt.defaultText or opt.default); } + // optionalAttrs (opt ? example) { + example = + builtins.addErrorContext "while evaluating the example of option `${name}`" ( + renderOptionValue opt.example + ); + } + // optionalAttrs (opt ? default) { + default = + builtins.addErrorContext "while evaluating the default value of option `${name}`" ( + renderOptionValue (opt.defaultText or opt.default) + ); + } // optionalAttrs (opt ? relatedPackages && opt.relatedPackages != null) { inherit (opt) relatedPackages; }; subOptions = |