lix/src/nix
Eelco Dolstra 8d4268d190 Improve error formatting
Changes:

* The divider lines are gone. These were in practice a bit confusing,
  in particular with --show-trace or --keep-going, since then there
  were multiple lines, suggesting a start/end which wasn't the case.

* Instead, multi-line error messages are now indented to align with
  the prefix (e.g. "error: ").

* The 'description' field is gone since we weren't really using it.

* 'hint' is renamed to 'msg' since it really wasn't a hint.

* The error is now printed *before* the location info.

* The 'name' field is no longer printed since most of the time it
  wasn't very useful since it was just the name of the exception (like
  EvalError). Ideally in the future this would be a unique, easily
  googleable error ID (like rustc).

* "trace:" is now just "…". This assumes error contexts start with
  something like "while doing X".

Example before:

  error: --- AssertionError ---------------------------------------------------------------------------------------- nix
  at: (7:7) in file: /home/eelco/Dev/nixpkgs/pkgs/applications/misc/hello/default.nix

       6|
       7|   x = assert false; 1;
        |       ^
       8|

  assertion 'false' failed
  ----------------------------------------------------- show-trace -----------------------------------------------------
  trace: while evaluating the attribute 'x' of the derivation 'hello-2.10'
  at: (192:11) in file: /home/eelco/Dev/nixpkgs/pkgs/stdenv/generic/make-derivation.nix

     191|         // (lib.optionalAttrs (!(attrs ? name) && attrs ? pname && attrs ? version)) {
     192|           name = "${attrs.pname}-${attrs.version}";
        |           ^
     193|         } // (lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform && !dontAddHostSuffix && (attrs ? name || (attrs ? pname && attrs ? version)))) {

Example after:

  error: assertion 'false' failed

         at: (7:7) in file: /home/eelco/Dev/nixpkgs/pkgs/applications/misc/hello/default.nix

              6|
              7|   x = assert false; 1;
               |       ^
              8|

         … while evaluating the attribute 'x' of the derivation 'hello-2.10'

         at: (192:11) in file: /home/eelco/Dev/nixpkgs/pkgs/stdenv/generic/make-derivation.nix

            191|         // (lib.optionalAttrs (!(attrs ? name) && attrs ? pname && attrs ? version)) {
            192|           name = "${attrs.pname}-${attrs.version}";
               |           ^
            193|         } // (lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform && !dontAddHostSuffix && (attrs ? name || (attrs ? pname && attrs ? version)))) {
2021-01-21 11:02:09 +01:00
..
add-file.md Split 'nix store add-to-store' into 'add-path' and 'add-file' 2020-12-04 00:59:24 +01:00
add-path.md Split 'nix store add-to-store' into 'add-path' and 'add-file' 2020-12-04 00:59:24 +01:00
add-to-store.cc Convert option descriptions to Markdown 2021-01-13 14:18:04 +01:00
app.cc Make --no-eval-cache a global setting 2020-08-07 14:13:24 +02:00
build.cc Fix clang build 2021-01-21 10:29:51 +01:00
build.md Add 'nix build' manpage 2020-12-21 13:32:27 +01:00
bundle.cc Convert option descriptions to Markdown 2021-01-13 14:18:04 +01:00
bundle.md Add TODO 2020-12-23 18:26:40 +01:00
cat.cc Add 'nix store' NAR-related manpages 2020-12-21 13:32:28 +01:00
command.cc Convert option descriptions to Markdown 2021-01-13 14:18:04 +01:00
command.hh Add 'nix daemon' command 2021-01-14 00:05:04 +01:00
copy.cc Convert option descriptions to Markdown 2021-01-13 14:18:04 +01:00
copy.md Add 'nix copy' manpage 2020-12-21 13:32:27 +01:00
daemon.cc Improve error formatting 2021-01-21 11:02:09 +01:00
daemon.md Add 'nix daemon' command 2021-01-14 00:05:04 +01:00
describe-stores.cc Remove static variable name clashes 2020-10-06 13:49:20 +02:00
develop.cc Convert option descriptions to Markdown 2021-01-13 14:18:04 +01:00
develop.md Typo 2020-12-21 13:32:27 +01:00
diff-closures.cc Add 'nix store diff-closures' manpage 2020-12-21 13:32:29 +01:00
diff-closures.md Add 'nix store diff-closures' manpage 2020-12-21 13:32:29 +01:00
doctor.cc Split out local-fs-store.hh 2020-10-09 20:18:08 +00:00
dump-path.cc Add 'nix store' NAR-related manpages 2020-12-21 13:32:28 +01:00
edit.cc Add 'nix edit' manpage 2020-12-21 13:32:28 +01:00
edit.md Add 'nix edit' manpage 2020-12-21 13:32:28 +01:00
eval.cc Convert option descriptions to Markdown 2021-01-13 14:18:04 +01:00
eval.md Add 'nix eval' manpage 2020-12-21 13:32:28 +01:00
flake-archive.md Add 'nix flake' manpages 2020-12-23 18:26:40 +01:00
flake-check.md Add 'nix flake' manpages 2020-12-23 18:26:40 +01:00
flake-clone.md Add 'nix flake' manpages 2020-12-23 18:26:40 +01:00
flake-info.md Add 'nix flake' manpages 2020-12-23 18:26:40 +01:00
flake-init.md Add 'nix flake' manpages 2020-12-23 18:26:40 +01:00
flake-list-inputs.md Add 'nix flake' manpages 2020-12-23 18:26:40 +01:00
flake-new.md Add 'nix flake' manpages 2020-12-23 18:26:40 +01:00
flake-prefetch.md nix store prefetch-tarball -> nix flake prefetch 2021-01-11 12:36:39 +01:00
flake-show.md Add 'nix flake' manpages 2020-12-23 18:26:40 +01:00
flake-update.md Add 'nix flake' manpages 2020-12-23 18:26:40 +01:00
flake.cc Convert option descriptions to Markdown 2021-01-13 14:18:04 +01:00
flake.md Add 'nix flake' manpages 2020-12-23 18:26:40 +01:00
get-env.sh nix develop: Set output paths to writable locations 2020-08-28 18:16:03 +02:00
hash.cc Convert option descriptions to Markdown 2021-01-13 14:18:04 +01:00
help.md Add 'nix help' manpage 2020-12-21 13:32:29 +01:00
installables.cc Fix content-addressed flake outputs 2021-01-18 11:31:59 +01:00
installables.hh Print built derivations as json for build 2020-11-11 10:27:02 -06:00
key-convert-secret-to-public.md Add commands for generating secret/public keys 2021-01-06 17:49:31 +01:00
key-generate-secret.md Rename 'nix store sign-paths' to 'nix store sign' 2021-01-13 23:32:37 +01:00
legacy.cc Start of new Nix command-line interface 2016-02-09 21:28:29 +01:00
legacy.hh Fix Darwin build 2016-03-15 12:11:27 +01:00
local.mk Add 'nix store prefetch-{file,tarball}' 2021-01-07 21:51:46 +01:00
log.cc Add 'nix log' manpage 2020-12-21 13:32:28 +01:00
log.md Tweak 2020-12-21 13:32:28 +01:00
ls.cc Convert option descriptions to Markdown 2021-01-13 14:18:04 +01:00
main.cc --refresh: Imply setting .narinfo disk cache TTL to 0 2021-01-18 14:38:31 +01:00
make-content-addressable.cc Add 'nix store make-content-addressable' manpage 2020-12-21 13:32:29 +01:00
make-content-addressable.md Add 'nix store make-content-addressable' manpage 2020-12-21 13:32:29 +01:00
markdown.cc nix repl ':doc': Render using lowdown 2020-08-24 18:10:33 +02:00
markdown.hh nix repl ':doc': Render using lowdown 2020-08-24 18:10:33 +02:00
nar-cat.md Add 'nix nar' manpages 2020-12-21 13:32:28 +01:00
nar-dump-path.md Add 'nix nar' manpages 2020-12-21 13:32:28 +01:00
nar-ls.md Add 'nix nar' manpages 2020-12-21 13:32:28 +01:00
nar.cc Add 'nix nar' manpages 2020-12-21 13:32:28 +01:00
nar.md Add 'nix nar' manpages 2020-12-21 13:32:28 +01:00
nix.md Add 'nix' manpage 2020-12-23 18:33:42 +01:00
optimise-store.cc Add 'nix store optimise' manpage 2020-12-21 13:32:28 +01:00
optimise-store.md Add 'nix store optimise' manpage 2020-12-21 13:32:28 +01:00
path-info.cc Convert option descriptions to Markdown 2021-01-13 14:18:04 +01:00
path-info.md Doh 2020-12-21 13:32:29 +01:00
ping-store.cc Add 'nix store ping' manpage 2020-12-21 13:32:28 +01:00
ping-store.md Tweak 2021-01-17 19:49:28 +01:00
prefetch.cc Convert option descriptions to Markdown 2021-01-13 14:18:04 +01:00
print-dev-env.md Add 'nix develop' and `nix print-dev-env' manpages 2020-12-21 13:32:27 +01:00
profile-diff-closures.md Add 'nix profile' manpage 2020-12-21 13:32:29 +01:00
profile-history.md Add 'nix profile history' command 2021-01-12 23:53:53 +01:00
profile-install.md Add 'nix profile' manpage 2020-12-21 13:32:29 +01:00
profile-list.md nix profile info -> nix profile list 2021-01-12 19:57:05 +01:00
profile-remove.md Add 'nix profile' manpage 2020-12-21 13:32:29 +01:00
profile-upgrade.md Add 'nix profile' manpage 2020-12-21 13:32:29 +01:00
profile.cc nix profile install: Support installing non-flakes 2021-01-18 23:08:58 +01:00
profile.md Add 'nix profile' manpage 2020-12-21 13:32:29 +01:00
registry-add.md Add 'nix registry' manpages 2020-12-21 13:32:27 +01:00
registry-list.md Add 'nix registry' manpages 2020-12-21 13:32:27 +01:00
registry-pin.md Add 'nix registry' manpages 2020-12-21 13:32:27 +01:00
registry-remove.md Add 'nix registry' manpages 2020-12-21 13:32:27 +01:00
registry.cc Add 'nix registry' manpages 2020-12-21 13:32:27 +01:00
registry.md Add 'nix registry' manpages 2020-12-21 13:32:27 +01:00
repl.cc Add 'nix repl' manpage 2020-12-21 13:32:28 +01:00
repl.md Add 'nix repl' manpage 2020-12-21 13:32:28 +01:00
run.cc Convert option descriptions to Markdown 2021-01-13 14:18:04 +01:00
run.md Add 'nix run' and 'nix shell' manpages 2020-12-21 13:32:27 +01:00
search.cc Add 'nix search' manpage 2020-12-21 13:32:27 +01:00
search.md Add 'nix search' manpage 2020-12-21 13:32:27 +01:00
shell.md Add 'nix run' and 'nix shell' manpages 2020-12-21 13:32:27 +01:00
show-config.cc Merge remote-tracking branch 'upstream/master' into fix-and-ci-static-builds 2020-10-09 18:26:47 +00:00
show-derivation.cc Convert option descriptions to Markdown 2021-01-13 14:18:04 +01:00
show-derivation.md Add 'nix show-derivation' manpage 2020-12-21 13:32:29 +01:00
sigs.cc Rename 'nix store sign-paths' to 'nix store sign' 2021-01-13 23:32:37 +01:00
store-cat.md Add 'nix store' NAR-related manpages 2020-12-21 13:32:28 +01:00
store-delete.cc Add 'nix store repair' command 2021-01-13 23:27:39 +01:00
store-delete.md Add 'nix store delete' command 2021-01-11 19:46:59 +01:00
store-dump-path.md Add 'nix store' NAR-related manpages 2020-12-21 13:32:28 +01:00
store-gc.cc Convert option descriptions to Markdown 2021-01-13 14:18:04 +01:00
store-gc.md Add 'nix store gc' command 2021-01-10 23:29:14 +01:00
store-ls.md Add 'nix store' NAR-related manpages 2020-12-21 13:32:28 +01:00
store-prefetch-file.md Add 'nix store prefetch-{file,tarball}' 2021-01-07 21:51:46 +01:00
store-repair.cc Add 'nix store repair' command 2021-01-13 23:27:39 +01:00
store-repair.md Add 'nix store repair' command 2021-01-13 23:27:39 +01:00
store.cc Introduce 'nix store' command 2020-12-03 18:07:13 +01:00
upgrade-nix.cc Improve error formatting 2021-01-21 11:02:09 +01:00
upgrade-nix.md Add 'nix upgrade-nix' manpage 2020-12-21 13:32:28 +01:00
verify.cc Improve error formatting 2021-01-21 11:02:09 +01:00
verify.md Add 'nix store verify' manpage 2020-12-21 13:32:28 +01:00
why-depends.cc Convert option descriptions to Markdown 2021-01-13 14:18:04 +01:00
why-depends.md Add 'nix why-depends' manpage 2020-12-21 13:32:28 +01:00