Skip to content

internal-json logger improvements: dedicated error types for failed drv builds vs. nix evaluation error #13910

@qknight

Description

@qknight

Is your feature request related to a problem?

Using the internal-json there is no clear concept if the error is a nix evaluation error or a mkDerivation error, like a rustc error related to the rust lanauge.

mkDerivation installPhase error:

@nix {"action":"msg","column":null,"file":null,"level":0,"line":null,"msg":"\u001b[31;1merror:\u001b[0m \u001b[0mbuilder for '\u001b[35;1m/nix/store/0y0jz1i6sia87lh1z70g0b8w8737imb9-asdf-b.drv\u001b[0m' failed with exit code 1;\n       last 1 log lines:\n       > Running phase: installPhase\n       For full logs, run:\n         \u001b[1mnix log /nix/store/0y0jz1i6sia87lh1z70g0b8w8737imb9-asdf-b.drv\u001b[0m","raw_msg":"\u001b[0mbuilder for '\u001b[35;1m/nix/store/0y0jz1i6sia87lh1z70g0b8w8737imb9-asdf-b.drv\u001b[0m' failed with exit code 1;\nlast 1 log lines:\n> Running phase: installPhase\nFor full logs, run:\n  \u001b[1mnix log /nix/store/0y0jz1i6sia87lh1z70g0b8w8737imb9-asdf-b.drv\u001b[0m"}

nix syntax error:

nix build --file default.nix -L --keep-going --log-format internal-json
@nix {"action":"msg","column":3,"file":"/home/nixos/cargo/default.nix:4:3","level":0,"line":4,"msg":"\u001b[31;1merror:\u001b[0m syntax error, unexpected ID, expecting '.' or '='\n       \u001b[34;1mat \u001b[35;1m/home/nixos/cargo/default.nix:4:3\u001b[0m:\n            3| asdf\n            4|   b = pkgs.stdenv.mkDerivation {\n             |   \u001b[31;1m^\u001b[0m\n            5|   name=\"asdf b\";","raw_msg":"syntax error, unexpected ID, expecting '.' or '='"}

Proposed solution

As mentioned in #13909

  • it would be helpful to know error codes, i.e. to know if it is a nix evaluation error or a mkDerivation internal error.
  • Ideally pin nix build to "id": 0 and merge the output message with: @nix {"action":"stop","id":0, "code": 0}. This would probably be the last message in the json stream.

"code" could be:

  • 0: no error
  • 1: nix error
  • 2: one or more mkDerivation error(s)

Additional context

For my current libnix project: Integrating nix into cargo build I can only guess that if "file": null is given it was not a nix error. It would be helpful if this "action":"msg" would be merged into @nix {"action":"stop","id":0} which does not exist yet.

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeature request or proposal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions