cli¶
CLI application definition for junix.
Build
¶
Bases: Application
Build flake attributes and produce JUnit XML.
Takes one or more flake attributes (e.g. nixpkgs#hello or
.#packages.x86_64-linux.default), not a bare flake path -- unlike
check, build has no default and does not discover attributes
for you.
Pass -- followed by extra flags to forward them to nix build::
junix build nixpkgs#hello -- --no-link --rebuild
Source code in src/junix/cli.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | |
Check
¶
Bases: Application
Evaluate and build all checks of a flake.
Takes an optional flake path (default: .), e.g. junix check
./path/to/flake or junix check github:owner/repo.
Pass -- followed by extra flags to forward them to nix build::
junix check -- --no-link --rebuild
Source code in src/junix/cli.py
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 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 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 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 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 | |
_build_build_suite_events(ac, eval_result_path)
staticmethod
¶
Build the build suite BuildEvents and targets for one architecture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ac
|
ArchChecks
|
The ArchChecks for this architecture. |
required |
eval_result_path
|
str
|
The flake path as the user wrote it. Used only for the reproducer command names, since the build itself targets store paths. |
required |
Returns:
| Type | Description |
|---|---|
list[BuildEvent]
|
Tuple of (build_builds, build_targets, expected_names, |
list[str]
|
expected_drv_paths). |
list[str]
|
|
list[str | None]
|
|
tuple[list[BuildEvent], list[str], list[str], list[str | None]]
|
is parallel to |
tuple[list[BuildEvent], list[str], list[str], list[str | None]]
|
|
tuple[list[BuildEvent], list[str], list[str], list[str | None]]
|
by |
tuple[list[BuildEvent], list[str], list[str], list[str | None]]
|
|
tuple[list[BuildEvent], list[str], list[str], list[str | None]]
|
pairing) and to mark dep-failed targets as failures instead of |
tuple[list[BuildEvent], list[str], list[str], list[str | None]]
|
cached/skipped. |
Source code in src/junix/cli.py
_build_eval_suite(ac, path)
staticmethod
¶
Build the eval suite BuildEvents for one architecture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ac
|
ArchChecks
|
The ArchChecks for this architecture. |
required |
path
|
str
|
The flake path as the user wrote it, used in reproducer
commands ( |
required |
Returns:
| Type | Description |
|---|---|
tuple[list[BuildEvent], bool]
|
Tuple of (eval_builds, has_errors). |
Source code in src/junix/cli.py
Junix
¶
Bases: Application
Turn Nix build logs into JUnit XML reports for your CI.
Source code in src/junix/cli.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
_nix_log_level
property
¶
_show_unknown_logs
property
¶
Whether to forward non-@nix lines (e.g. SSH builder output).
_validate_args(swfuncs, tailargs)
¶
Resolve verbose switch before plumbum short-circuits version.
Source code in src/junix/cli.py
log(message, level=1)
¶
Print a log message to stderr if verbosity is high enough.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The message to print. |
required |
level
|
int
|
Minimum verbosity level required to print (default 1). |
1
|
Source code in src/junix/cli.py
main(*_args)
¶
Resolve env-var defaults for global flags before subcommands run.
Plumbum calls this before the subcommand's main(), so by the
time a subcommand reads self.parent._verbose / self.parent
._color, the env vars have been applied (CLI > env > default).
Source code in src/junix/cli.py
version()
¶
Prints the program's version and quits.
Source code in src/junix/cli.py
Translate
¶
Bases: Application
Read @nix JSON lines from stdin and produce JUnit XML.
Source code in src/junix/cli.py
_env(name)
¶
Read a JUNIX_* env var, returning None when unset or empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The env var name (e.g. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The value, or |
Source code in src/junix/cli.py
_env_bool(name)
¶
Read a JUNIX_* env var as a bool.
Truthy: 1, true, yes, on (case-insensitive).
Falsy: 0, false, no, off, empty, or unset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The env var name (e.g. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
The boolean value. |
Source code in src/junix/cli.py
_env_int(name)
¶
Read a JUNIX_* env var as a positive int.
Returns None rather than a default so the caller can tell "the user
asked for a number" from "nobody said anything" -- which matters when the
default depends on the other flags.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The env var name (e.g. |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
The parsed value, or |
int | None
|
integer. |
Source code in src/junix/cli.py
_env_list(name)
¶
Read a JUNIX_* env var as a list, splitting on commas and whitespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The env var name (e.g. |
required |
Returns:
| Type | Description |
|---|---|
list[str] | None
|
The split list of tokens, or |
Source code in src/junix/cli.py
_plumbum_async_main(main_method)
¶
Wrap an async main() so plumbum can call it synchronously.
Plumbum 2's Application.run calls inst.main() synchronously. This decorator bridges that gap by running the coroutine inside asyncio.run().
Important: does not use functools.wraps because plumbum 2 introspects self.main with inspect.getfullargspec() and get_type_hints(). wraps would copy the original's annotations but the wrapper has args, *kwargs, causing a mismatch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
main_method
|
Callable[..., Awaitable[int]]
|
The async main() coroutine function to wrap. |
required |
Returns:
| Type | Description |
|---|---|
Callable[..., int]
|
A sync wrapper function that runs the coroutine via asyncio.run(). |
Source code in src/junix/cli.py
_print_version_diagnostics()
¶
Print extra diagnostic information alongside verbose --version.
Emits the full path to the junix binary, the output of nix --version,
and the full path to the nix binary, all to stderr. Paths fall back to
the bare command name when the executable cannot be located.
Source code in src/junix/cli.py
_resolve_eval_jobs(cli_value)
¶
Decide how many nix eval processes may run at once.
Both eval paths spawn whole-flake evaluations -- the per-check mode
obviously, and the bulk mode through its --show-trace recovery, which
re-evaluates once per failing check. Neither has a memory budget junix can
guess, so neither gets parallelised without being asked. See
junix.lib.DEFAULT_EVAL_JOBS for why.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cli_value
|
int | None
|
Value of |
required |
Returns:
| Type | Description |
|---|---|
int
|
The concurrency limit to use (always at least 1). |
Source code in src/junix/cli.py
_resolve_junix_path()
¶
Return the best-effort absolute path to the running junix binary.
When invoked as python -m junix, sys.argv[0] points at the
module file (.../__main__.py). We prefer sys.executable in
that case, but fall back to the bare argv[0] / which('junix')
when the interpreter itself was used to launch the module.
Returns:
| Type | Description |
|---|---|
str
|
Absolute path, or the original command name if it cannot be resolved. |
Source code in src/junix/cli.py
_split_extra_flags(args)
¶
Split args into attrs and extra flags for nix.
Plumbum 2 consumes the -- end-of-options marker before our
main() ever sees it (it just sticks everything from that
point on into the positional *args). So we can't rely on
finding a literal -- in args — we have to detect the
boundary ourselves. Heuristic: every arg that doesn't start
with - is a flake attribute, every arg that does is a
nix flag. Splitting at the first flag-shaped arg works
because flake attrs cannot legitimately start with -
(Nix itself rejects them, so users don't pass them).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
tuple[str, ...]
|
Positional arguments from the CLI, in order. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Tuple of (attrs, extra_flags). |
list[str] | None
|
when no extra flags were passed. |