Junix¶
Turn Nix build logs into JUnit XML reports for your CI.
Junix parses the @nix JSON protocol from Nix build outputs and converts it into
standard JUnit XML reports compatible with GitLab CI, Jenkins, and other CI systems. It
also controls -v levels, so you capture exactly as much Nix log detail as you want,
and it prints a color-coded summary of what passed, failed and was cached.
Subcommands¶
| Command | What it does |
|---|---|
translate |
Reads @nix JSON lines from stdin, produces JUnit XML to stdout. No nix invoked. |
build |
Runs nix build --log-format internal-json --keep-going <attrs>, parses output, produces JUnit XML and a colorful summary. |
check |
Discovers flake checks via nix eval --json, evaluates all arches, builds local checks, produces JUnit XML and a colorful summary. |
Quick start¶
# Pipe nix build output into junix
nix build --log-format internal-json -v --print-build-logs --no-link .#pkg1 |& junix translate -o result.xml
# Or let junix drive the build
junix build .#pkg1 .#pkg2
# Or check all flake checks
junix check
Example output¶
When you run junix check on a flake with passing and failing checks, you get a
colorful summary on stderr:
$ junix check ./tests/sample-flake eval aarch64-linux ... 2 checks ✓ nix eval ./tests/sample-flake#checks.aarch64-linux.failing ✓ nix eval ./tests/sample-flake#checks.aarch64-linux.passing eval x86_64-linux ... 2 checks ✓ nix eval ./tests/sample-flake#checks.x86_64-linux.failing ✓ nix eval ./tests/sample-flake#checks.x86_64-linux.passing build x86_64-linux ... 2 checks ✗ nix build ./tests/sample-flake#checks.x86_64-linux.failing ✓ nix build ./tests/sample-flake#checks.x86_64-linux.passing (cached) FAILED (0/4 evals, 1/2 builds)
And a JUnit XML report on stdout (or to a file with -o):
<?xml version="1.0" encoding="utf-8" ?>
<testsuites>
<testsuite
name="nix-eval.aarch64-linux"
tests="2"
failures="0"
errors="0"
skipped="0"
time="0"
>
<testcase
name="nix eval ./tests/sample-flake#checks.aarch64-linux.failing"
classname="eval checks.aarch64-linux.failing"
time="0"
>
<system-out>
/nix/store/bfhm668k31wxqhgzwd1knnnlzh8rpsxc-failing-check.drv
</system-out>
</testcase>
<testcase
name="nix eval ./tests/sample-flake#checks.aarch64-linux.passing"
classname="eval checks.aarch64-linux.passing"
time="0"
>
<system-out>
/nix/store/132yfmn5jsgxxdqmqgbcl5nf05k2203z-passing-check.drv
</system-out>
</testcase>
</testsuite>
<testsuite
name="nix-eval.x86_64-linux"
tests="2"
failures="0"
errors="0"
skipped="0"
time="0"
>
<testcase
name="nix eval ./tests/sample-flake#checks.x86_64-linux.failing"
classname="eval checks.x86_64-linux.failing"
time="0"
>
<system-out>
/nix/store/8lsmx09idfa0dmyg7d03wzic50whi4x3-failing-check.drv
</system-out>
</testcase>
<testcase
name="nix eval ./tests/sample-flake#checks.x86_64-linux.passing"
classname="eval checks.x86_64-linux.passing"
time="0"
>
<system-out>
/nix/store/z203q28202sj879rz2b36c2bnxb95x1q-passing-check.drv
</system-out>
</testcase>
</testsuite>
<testsuite
name="nix-build.x86_64-linux"
tests="2"
failures="1"
errors="0"
skipped="1"
time="0"
>
<testcase
name="nix build ./tests/sample-flake#checks.x86_64-linux.failing"
classname="/nix/store/8lsmx09idfa0dmyg7d03wzic50whi4x3-failing-check.drv"
time="0"
>
<failure message="Build failed" type="failure" />
<system-out>This check fails</system-out>
<system-err
>error: Cannot build '/nix/store/8lsmx09idfa0dmyg7d03wzic50whi4x3-failing-check.drv'.
Reason: builder failed with exit code 1.
Output paths:
/nix/store/zxa2hj58grdp2j5bmnywznqwnx66qn6m-failing-check
Last 1 log lines:
> This check fails
For full logs, run:
nix log /nix/store/8lsmx09idfa0dmyg7d03wzic50whi4x3-failing-check.drv
</system-err>
</testcase>
<testcase
name="nix build ./tests/sample-flake#checks.x86_64-linux.passing"
classname="checks.x86_64-linux.passing"
time="0"
>
<skipped message="Cached / substituted" type="cached" />
</testcase>
</testsuite>
</testsuites>
Running¶
Configuration¶
Every flag accepts its value from a JUNIX_* env var. Precedence is CLI > env >
default, so CI runners can configure junix globally without wrapping every invocation:
export JUNIX_CHECK_EVAL_INDIVIDUALLY=1 # always per-check eval
export JUNIX_COLOR=no # force plain output
export JUNIX_CHECK_OUTPUT=junix-report.xml
junix check
See Environment variables for the full mapping.
Installation¶
Documentation¶
Full documentation at junix.moduon.team.
Credits¶
Junix is developed and maintained by Moduon. Need a professional Odoo partner? Contact us.