Errors in configurations files (such as mistyping an option name, using an option that has been removed, type errors, multiple definitions, etc.) give inscrutable error messages such as:

error: user-thrown exception: Used without option declaration.
(use `–show-trace’ to show detailed location information)

Passing –show-trace gives some context, buried between dozens of other stack trace lines:


while evaluating the attribute <let-body>' at/etc/nixos/nixpkgs/pkgs/lib/options.nix:201:12’:
while evaluating the function at /etc/nixos/nixpkgs/pkgs/lib/options.nix:202:36': while evaluating the function at/etc/nixos/nixpkgs/pkgs/lib/options.nix:198:72’:
while evaluating services.httpd.experimental:
while evaluating the function at `/etc/nixos/nixpkgs/pkgs/lib/options.nix:247:23’:

It would be better if the name of the offending option was included in the “abort” error messages, e.g.

error: user-thrown exception: Undeclared option `services.httpd.experimental’.

I.e. instead of using addErrorContext, the name of the option should be passed down the recursive option handling functions. (It might still be useful to use addErrorContext to deal with other kinds of errors.)

Submitted on 7 August 2009 at 13:53

Log in to post comments