lib¶
Reusable functions for parsing @nix protocol and running nix commands.
ArchChecks
dataclass
¶
Checks discovered for a single architecture.
Attributes:
| Name | Type | Description |
|---|---|---|
arch |
str
|
Architecture identifier (e.g. |
checks |
list[CheckResult]
|
One CheckResult per check in this arch. |
error |
str | None
|
Error message if the entire arch eval failed, else None. |
Source code in src/junix/lib.py
CheckResult
dataclass
¶
Result of evaluating a single check.
Attributes:
| Name | Type | Description |
|---|---|---|
arch |
str
|
Architecture identifier (e.g. |
name |
str
|
Check name (e.g. |
drv_path |
str | None
|
Derivation path (or |
error |
str | None
|
Error message (or |
output_name |
str
|
Which output of |
Source code in src/junix/lib.py
EvalResult
dataclass
¶
Result of evaluating flake checks across architectures.
Attributes:
| Name | Type | Description |
|---|---|---|
arches |
list[ArchChecks]
|
Per-architecture results, one entry per evaluated arch. |
path |
str
|
Normalised flake path used for building URIs. |
Source code in src/junix/lib.py
all_attrs
property
¶
Flatten all successful check attrs across all arches.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of flake attribute URIs (e.g. |
has_errors
property
¶
Whether any arch evaluation failed.
Returns:
| Type | Description |
|---|---|
bool
|
True if at least one arch has an error. |
_apply_color_mode(mode)
¶
Apply the resolved color mode to plumbum's ANSIStyle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
One of |
required |
Source code in src/junix/lib.py
_attribute_eval_time(arches, eval_elapsed, re_eval_seconds)
¶
Split the eval phase wall-clock across per-arch suite times.
Failing checks triggered a per-check nix eval --show-trace
round trip; those round trips are measured and assigned to the
arch where the check lives. The remaining bulk-eval time is
split evenly across the healthy checks in all arches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arches
|
list[ArchChecks]
|
Per-architecture check lists, post-recovery. |
required |
eval_elapsed
|
float
|
Wall-clock of the bulk |
required |
re_eval_seconds
|
dict[tuple[str, str], float]
|
Map of |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Per-arch seconds to assign to that arch's eval suite |
dict[str, float]
|
attribute. |
Source code in src/junix/lib.py
_current_nix_system()
cached
¶
Return the Nix system identifier for the current host machine.
Delegates to nix eval --impure --json --expr builtins.currentSystem.
The result is cached because it never changes during a process lifetime.
Returns:
| Type | Description |
|---|---|
str
|
Nix system string (e.g. |
Source code in src/junix/lib.py
_ensure_builds(builds, process_successful, default_name='nix build', expected_count=0, expected_names=None, expected_pairs=None, unbuildable_drv_paths=None, real_failure_drv_paths=None)
¶
Ensure the build list has at least expected_count entries.
Nix only emits actBuild protocol activities when it actually
compiles something. Cached/substituted builds produce no actBuild
events, so the build list may be shorter than the number of
attributes requested. This helper pads with synthetic skipped
builds so the JUnit report reflects every requested attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
builds
|
list[BuildEvent]
|
Collected build events from the protocol handler. |
required |
process_successful
|
bool
|
Whether the overall Nix process succeeded. |
required |
default_name
|
str
|
Name to use for the synthetic build when no builds exist and no expected_count is given. |
'nix build'
|
expected_count
|
int
|
Minimum number of builds to return. When 0 (default), at least one build is guaranteed. |
0
|
expected_names
|
list[str] | None
|
Names for synthetic entries. When provided,
padded entries use these names instead of |
None
|
expected_pairs
|
list[tuple[str, str]] | None
|
|
None
|
unbuildable_drv_paths
|
set[str] | None
|
Drv paths that Nix explicitly reported
as "Cannot build" (either real failure or dep-failed).
Synthetic entries whose |
None
|
real_failure_drv_paths
|
list[str] | None
|
Drv paths of builds that failed for
their own reasons (e.g. builder exit code, output
rejected). When |
None
|
Returns:
| Type | Description |
|---|---|
list[BuildEvent]
|
Build list padded to at least |
Source code in src/junix/lib.py
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 | |
_eval_check_trace(path, arch, name, flags=None)
async
¶
Re-evaluate a single failing check to capture its Nix error trace.
builtins.tryEval swallows the error message, so the bulk
nix eval --json ...#checks call only ever reports a generic
"evaluation failed" placeholder for failing checks. This helper
runs nix eval --show-trace <path>#checks.<arch>.<name>.drvPath
and returns the stderr verbatim so the JUnit report can show the
real trace to the user. The round-trip wall-clock is also returned
so the CLI can include it in the per-arch suite time — this is
the only honest per-check timing available, since @nix carries
no timestamps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Flake path the user passed (e.g. |
required |
arch
|
str
|
Architecture (e.g. |
required |
name
|
str
|
Check name (e.g. |
required |
flags
|
list[str] | None
|
Already-filtered user flags to forward to |
None
|
Returns:
| Type | Description |
|---|---|
str | None
|
Tuple of (Nix error trace or None, elapsed_seconds). The trace |
float
|
is the stderr stripped, or |
tuple[str | None, float]
|
produced no useful output. Callers should keep the original |
tuple[str | None, float]
|
bulk error in that case. |
Source code in src/junix/lib.py
_eval_flags(extra_flags)
¶
Keep the user's -- flags that nix eval can also accept.
The flags after -- describe how this run should talk to Nix, and that
applies just as much to evaluation as to building: a CI job passing
--eval-store auto --builders "" --store ssh-ng://… means it for the
whole run. Dropping them from the eval phase silently sends
import-from-derivation builds to the local machine instead of the remote
builder -- slower, and on a small runner, fatal.
Filtering is a deny-list rather than an allow-list so an unanticipated
store setting still reaches evaluation. The cost is that an unknown
build-only flag makes nix eval fail loudly, which is the better failure:
the alternative is evaluating against the wrong store and never saying so.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extra_flags
|
list[str] | None
|
Flags the user passed after |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
The subset to append to a |
Source code in src/junix/lib.py
_gather_limited(jobs, coros)
async
¶
Await coroutines with at most jobs running concurrently.
Results come back in the order the coroutines were passed in, so callers can zip them against the inputs they were built from.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jobs
|
int
|
Maximum number in flight. Values below 1 are treated as 1. |
required |
coros
|
list[Any]
|
Coroutines to await. |
required |
Returns:
| Type | Description |
|---|---|
list[Any]
|
Each coroutine's result, in input order. |
Source code in src/junix/lib.py
_overall_success(builds)
¶
Return True when every build completed successfully.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
builds
|
list[BuildEvent]
|
List of build events to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if all builds stopped and succeeded. |
Source code in src/junix/lib.py
_phase_count(events, overall_success, label)
¶
Build the "N evals" or "F/T evals" fragment for one phase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
events
|
list[BuildEvent]
|
Phase's BuildEvents. |
required |
overall_success
|
bool
|
Whether everything passed. |
required |
label
|
str
|
The phase label ( |
required |
Returns:
| Type | Description |
|---|---|
str
|
A string like |
Source code in src/junix/lib.py
_print_build_list(builds, downloaded=0, header=None)
¶
Print the downloaded line, a header (if any), and one line per build.
Used by subcommands that have no per-arch sections (i.e. build).
For multi-arch flows (check), the per-arch :func:_print_build_results
and :func:_print_eval_results already print the listing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
builds
|
list[BuildEvent]
|
Build events to list individually. |
required |
downloaded
|
int
|
Number of paths downloaded from binary caches. |
0
|
header
|
str | None
|
Optional info line to print before the listing, e.g.
|
None
|
Source code in src/junix/lib.py
_print_build_results(arch, build_builds, color_mode='auto')
¶
Print build phase results for one architecture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arch
|
str
|
Architecture identifier. |
required |
build_builds
|
list[BuildEvent]
|
Build events (real + synthetic) for this arch. |
required |
color_mode
|
str
|
One of |
'auto'
|
Source code in src/junix/lib.py
_print_check_summary(evals=None, builds=None, overall_success=True, color_mode='auto')
¶
Print the final summary line used by every junix subcommand.
The format is consistent across commands: PASSED (...) or
FAILED (...) with separate counts for evals and builds. Each
phase is only mentioned if it has entries, in the order
evals, builds.
The per-phase listing (with ✓/✗/(cached)) is the caller's
responsibility — check uses :func:_print_eval_results and
:func:_print_build_results per arch, and build uses
:func:_print_build_list directly. This keeps the visual layout
consistent with how each subcommand presents its per-arch sections.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evals
|
list[BuildEvent] | None
|
Synthetic BuildEvents from the eval phase. Pass an empty
list (or |
None
|
builds
|
list[BuildEvent] | None
|
BuildEvents from the build phase. Pass an empty list
(or |
None
|
overall_success
|
bool
|
Whether everything passed. Drives the PASS/FAIL prefix. |
True
|
color_mode
|
str
|
One of |
'auto'
|
Source code in src/junix/lib.py
_print_eval_results(eval_result, color_mode='auto')
¶
Print eval phase results in pytest style.
Each check is printed with the exact nix eval command that would
reproduce it, so CI failures are copy-pasteable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
eval_result
|
EvalResult
|
The result from discover_checks(). |
required |
color_mode
|
str
|
One of |
'auto'
|
Source code in src/junix/lib.py
_rename_builds(builds_list, attrs, drv_to_name, expected_names, expected_drv_paths)
¶
Rename actBuild events and build the expected (name, drv) pairs.
The renames happen on the BuildEvent objects in place
(mutating b.name) so _ensure_builds sees the right names
and does not create duplicate synthetic entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
builds_list
|
list[BuildEvent]
|
Collected |
required |
attrs
|
list[str]
|
Original attrs the user passed to |
required |
drv_to_name
|
dict[str, str] | None
|
Caller-supplied drv_path → name map (e.g. from
|
required |
expected_names
|
list[str] | None
|
User-facing testcase names parallel to
|
required |
expected_drv_paths
|
list[str] | list[str | None] | None
|
Real |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[str, str]]
|
|
list[tuple[str, str]]
|
|
list[tuple[str, str]]
|
entries stripped out (since those attrs have no drv path to |
list[tuple[str, str]]
|
match against |
list[tuple[str, str]]
|
resolved drv paths are available, so the caller falls back |
list[tuple[str, str]]
|
to positional pairing. |
Source code in src/junix/lib.py
822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 | |
_resolve_color_mode(cli_value)
¶
Resolve the effective color mode from the CLI value.
This is a no-op pass-through: the precedence (CLI > JUNIX_COLOR >
"auto") is handled by the --color switch's default= in
cli.py, which feeds the resolved value here. This function exists
only for historical symmetry with the call sites.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cli_value
|
str | None
|
The raw CLI value (one of |
required |
Returns:
| Type | Description |
|---|---|
str
|
The resolved color mode, always one of |
Source code in src/junix/lib.py
_resolve_drv_paths(attrs)
async
¶
Resolve the drv path of each requested attr via nix eval.
Used by junix build so run_nix_build can pair
actBuild events with the user's attrs by drv path (more
reliable than positional pairing) and mark dep-failed targets as
failures instead of cached/skipped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attrs
|
list[str]
|
Flake attribute paths the user passed to
|
required |
Returns:
| Type | Description |
|---|---|
list[str | None] | None
|
List parallel to |
list[str | None] | None
|
(resolved successfully) or |
list[str | None] | None
|
attr — e.g. not a flake attr, or no |
list[str | None] | None
|
|
list[str | None] | None
|
|
Source code in src/junix/lib.py
_stream_nix(cmd, handler, log_level=0, show_unknown=False)
async
¶
Run nix and consume its stderr line by line while it runs.
plumbum's AsyncCommand.run() is only async in name: it hands the
synchronous command to a thread executor, which buffers the whole of stdout
and stderr and returns them once the process has exited. For a nix build
that is fine for a one-second build and wrong for everything else:
- the user sees nothing until the build is over -- a cached 41-check flake spends eight minutes looking hung;
- the entire
internal-jsonlog (every log line of every derivation) is held in memory as one string; BuildEvent.durationis meaningless, becauseNixEventHandlerstampstime.monotonic()as it parses, and parsing happens after the process has already exited. Every testcase ends up withtime="0".
Reading the pipe as nix writes to it fixes all three at once.
stderr is read in fixed-size chunks rather than with readline() because
StreamReader.readline() raises once a line exceeds its 64 KiB limit, and
nix build logs do contain lines that long. plumbum's popen() gives
us no way to raise that limit, so we split on newlines ourselves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmd
|
list[str]
|
Arguments for the |
required |
handler
|
NixEventHandler
|
Event handler fed with each line as it arrives. |
required |
log_level
|
int
|
Maximum Nix log level to forward to stderr (default 0 = errors only; higher = more verbose). |
0
|
show_unknown
|
bool
|
Forward non- |
False
|
Returns:
| Type | Description |
|---|---|
int
|
The process exit code. |
Source code in src/junix/lib.py
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 | |
_write_report(xml, output_path)
¶
Write the JUnit XML to output_path or stdout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xml
|
str
|
The JUnit XML string to write. |
required |
output_path
|
str | None
|
Path to write to, or None for stdout. |
required |
Source code in src/junix/lib.py
discover_checks(path, eval_arch=None, on_trace_recovery=None, eval_jobs=DEFAULT_EVAL_JOBS, extra_flags=None)
async
¶
Discover flake check attribute URIs for path.
Uses a single nix eval invocation with --apply to evaluate
each check with builtins.tryEval, returning a list of objects
with arch, name, drvPath and error fields. When
eval_arch is not provided, all architectures are returned.
Per-arch wall-clock attribution (seconds) is returned for the
CLI to populate <testsuite time="...">. Each arch's value
includes the wall-clock of any per-check nix eval --show-trace
round trips fired for failing checks plus a proportional share
of the bulk nix eval for its healthy checks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Flake path (e.g. |
required |
eval_arch
|
list[str] | None
|
Architectures to evaluate (default: all). |
None
|
on_trace_recovery
|
Callable[[str], None] | None
|
Optional callback invoked once per failing
check just before the second |
None
|
eval_jobs
|
int
|
How many trace-recovery |
DEFAULT_EVAL_JOBS
|
extra_flags
|
list[str] | None
|
Flags the user passed after |
None
|
Returns:
| Type | Description |
|---|---|
EvalResult
|
Tuple of (EvalResult, eval_elapsed_per_arch). The |
dict[str, float]
|
|
tuple[EvalResult, dict[str, float]]
|
tuple element is a |
Source code in src/junix/lib.py
1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 | |
discover_checks_individually(path, eval_arch=None, on_progress=None, eval_jobs=DEFAULT_EVAL_JOBS, extra_flags=None)
async
¶
Discover flake checks by running one nix eval per check.
The bulk :func:discover_checks evaluates every check × arch of
the flake in a single Nix process, which is memory-efficient for
small flakes but blows the RAM budget of CI runners on large ones
(e.g. flakes that pull in Odoo's full closure across four
architectures).
This helper trades that for per-check isolation: each check
runs in its own nix eval <path>#checks.<arch>.<name>.drvPath
process, so the RAM peak per process is bounded by the closure
of that single check — not the sum of all checks. Cost: one Nix
process per check (~hundreds of milliseconds each), so a flake
with hundreds of checks pays noticeable wall-clock overhead. Use
this only when the bulk path OOMs.
Steps 2 and 3 run eval_jobs processes concurrently. Those
processes spend most of their life waiting (store queries,
substituter round trips, import-from-derivation builds), so running
them one at a time left the machine idle: on a 41-check flake the
phase went from 2m59s serial to 1m05s at 8 jobs. Concurrency costs
RAM in exact proportion -- N in flight is roughly N times the peak
RSS -- which is why the default is low and the knob is exposed.
Algorithm (cheap listing, then per-check eval):
- List arches. One cheap
nix eval --json <path>#checks --apply builtins.attrNamesto enumerate the flake's check architectures. Skipped ifeval_archis provided by the caller. - List checks per arch. One
nix eval --json <path>#checks.<arch> --apply builtins.attrNamesper arch. This is the second-cheapest Nix call (just attribute names, no closure evaluation). - Per-check drvPath. One
nix eval --raw <path>#checks.<arch>.<name>.drvPathper check. This is the step that actually loads the check's closure — but each call only sees its own check.
Each per-check call surfaces the real Nix error trace in stderr on
failure, so unlike the bulk path no second nix eval --show-trace
round trip is needed to recover the trace.
Total nix eval invocations: 1 + A + A·C (no -e) or
A + A·C (-e given), where A = arches, C = checks
per arch. Bulk path: 1 + F (bulk + per-failing-check
trace). Per-check path is slower in wall-clock but bounded in
memory by the largest single check.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Flake path (e.g. |
required |
eval_arch
|
list[str] | None
|
Architectures to evaluate (default: all). When provided, the arch-listing step is skipped. |
None
|
on_progress
|
Callable[[str], None] | None
|
Optional callback invoked once per check just
before its per-check eval fires, receiving
|
None
|
eval_jobs
|
int
|
How many |
DEFAULT_EVAL_JOBS
|
extra_flags
|
list[str] | None
|
Flags the user passed after |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
EvalResult
|
Tuple of (EvalResult, eval_elapsed_per_arch) — same shape |
|
as |
dict[str, float]
|
func: |
tuple[EvalResult, dict[str, float]]
|
(suite structure, JUnit, summary) is unchanged. |
Source code in src/junix/lib.py
1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 | |
print_summary(builds, downloaded=0, color_mode='auto')
¶
Print a human-readable, color-coded summary of build results to stderr.
Output includes the number of paths downloaded from cache, cached builds, passed builds, and failed builds. On failure the names of failing builds are listed individually.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
builds
|
list[BuildEvent]
|
List of build events to summarize. |
required |
downloaded
|
int
|
Number of paths downloaded from binary caches. |
0
|
color_mode
|
str
|
One of |
'auto'
|
Source code in src/junix/lib.py
run_nix_build(attrs, store=None, default_name='nix build', log_level=0, expected_count=0, expected_names=None, expected_drv_paths=None, drv_to_name=None, extra_flags=None, show_unknown=False)
async
¶
Run nix build and return collected build events.
Uses --keep-going so Nix attempts every attribute even if some
fail. Cached/substituted builds produce no actBuild protocol
events; when expected_count is set, the report is padded with
synthetic skipped entries so every requested attribute is accounted
for.
Per-build wall-clock duration is measured by
NixEventHandler between each actBuild start and
stop event as the protocol stream is consumed, so each
returned BuildEvent.duration reflects the real build
wall-clock. The <testsuite time="..."> and
<testcase time="..."> attributes in the JUnit report come
from those per-build measurements (summed for the suite total).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attrs
|
list[str]
|
Flake attribute paths to build (e.g. |
required |
store
|
str | None
|
Remote store URL (e.g. |
None
|
default_name
|
str
|
Name for the synthetic build when no |
'nix build'
|
log_level
|
int
|
Maximum Nix log level to forward to stderr (default 0 = errors only; higher = more verbose). |
0
|
expected_count
|
int
|
Minimum number of builds to report. When Nix caches some builds they produce no protocol events, so this pads the report with synthetic skipped entries. |
0
|
expected_names
|
list[str] | None
|
Names for synthetic entries. When provided,
padded entries use these names instead of |
None
|
expected_drv_paths
|
list[str] | list[str | None] | None
|
Real |
None
|
drv_to_name
|
dict[str, str] | None
|
Mapping from drv_path to check name. When provided, build events are renamed before padding so that synthetic entries don't duplicate real ones. |
None
|
extra_flags
|
list[str] | None
|
Extra flags to pass to |
None
|
show_unknown
|
bool
|
Forward non- |
False
|
Returns:
| Type | Description |
|---|---|
list[BuildEvent]
|
Tuple of (builds, error_messages, exit_code, downloaded_count). |
list[str]
|
|
int
|
binary caches during this build. |
Source code in src/junix/lib.py
916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 | |
translate_stream(stream, suite_name='nix', process_successful=False, default_name='nix build', log_level=0, color_mode='auto', show_unknown=False)
¶
Read @nix JSON lines from stream and produce JUnit XML.
Nix log messages (and, with show_unknown, non-@nix lines) are
forwarded to stderr.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stream
|
IO[str]
|
Text stream to read (e.g. sys.stdin). |
required |
suite_name
|
str
|
Value for the |
'nix'
|
process_successful
|
bool
|
Passed to NixEventHandler.finalize. |
False
|
default_name
|
str
|
Name for the synthetic build when no |
'nix build'
|
log_level
|
int
|
Maximum Nix log level to forward to stderr (default 0 = errors only; higher = more verbose). |
0
|
color_mode
|
str
|
One of |
'auto'
|
show_unknown
|
bool
|
Forward non- |
False
|
Returns:
| Type | Description |
|---|---|
tuple[str, int]
|
Tuple of (xml_string, exit_code). |