quatquatt / nixos

My NixOS config
3 stars 1 forks source link

Make a `nix` issue to improve the `error: attribute 'myAttribute' missing` output #50

Open quatquatt opened 4 days ago

quatquatt commented 4 days ago

Currently, it shows an output like this:

       … while evaluating definitions from `/nix/store/60kla6jvfigdkad148k73v162s693y1v-source/base/features/virtualization.nix':

       … while evaluating the module argument `hostVars' in "/nix/store/60kla6jvfigdkad148k73v162s693y1v-source/base/features/virtualization.nix":

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: attribute 'hostVars' missing
       at /nix/store/2vmkhm30kdnics1bnj9zgblh9yr4cpyw-source/lib/modules.nix:508:28:
          507|         builtins.addErrorContext (context name)
          508|           (args.${name} or config._module.args.${name})
             |                            ^
          509|       ) (lib.functionArgs f);

You'll see that the actual error message isn't that useful. What's really useful is the stack trace above it. Nix traditionally tries to pack important info into the actual error message, so it'd be nice to reference the actual file within the error message.

quatquatt commented 3 days ago

also should make a PR to improve the head and tail documentation, and go back to the existing nix issue now that we found the relevant code.