HomeThat World

lib/modules.nix: Add file context to unmerged values in mergeDefinitions

Authored by Robert Hensing <robert@roberthensing.nl> on Feb 23 2020, 11:15 PM.

Description

lib/modules.nix: Add file context to unmerged values in mergeDefinitions

This helps with troubleshooting exceptions in config values, which were hard
to track down for options with many definitions.
The trace will look like:

error: while evaluating the attribute 'config.foo' at undefined position:
[...]
while evaluating the option `foo':
[...]
while evaluating definitions from `/home/user/mymod.nix':
while evaluating 'dischargeProperties' at /home/user/nixpkgs/lib/modules.nix:464:25, called from /home/user/nixpkgs/lib/modules.nix:392:137:
while evaluating the attribute 'value' at /home/user/nixpkgs/lib/modules.nix:277:44:
Value error!

where the /home/user/mymod.nix module is

{ lib, ... }: {
  options.foo = lib.mkOption {
    type = lib.types.lines;
  };
  config.foo = builtins.throw "Value error!";
}

Details

Committed
Robert Hensing <robert@roberthensing.nl>Feb 23 2020, 11:15 PM
Pushed
sorpaasSun, Mar 22, 6:16 PM
sorpaasSun, Mar 22, 6:14 PM
Parents
rNIXPKGSa9b0ccd68e7a: diffoscope: 136 -> 137
Branches
Unknown
Tags
Unknown

Event Timeline

Robert Hensing <robert@roberthensing.nl> committed rNIXPKGS9c0ab2f26db2: lib/modules.nix: Add file context to unmerged values in mergeDefinitions (authored by Robert Hensing <robert@roberthensing.nl>).Feb 23 2020, 11:15 PM