cli¶
CLI application definition for junix.
Build
¶
Bases: Application
Build flake attributes and produce JUnit XML.
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
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 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 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 | |
Check
¶
Bases: Application
Evaluate and build all checks of a flake.
Pass -- followed by extra flags to forward them to nix build::
junix check -- --no-link --rebuild
Source code in src/junix/cli.py
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 459 460 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 | |
_build_build_suite_events(ac, eval_result_path)
staticmethod
¶
Build the build suite BuildEvents and attrs 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 to construct the build URIs and the reproducer command names. |
required |
Returns:
| Type | Description |
|---|---|
list[BuildEvent]
|
Tuple of (build_builds, build_attrs, expected_names, |
list[str]
|
expected_drv_paths). |
list[str]
|
|
list[str | None]
|
.drv`` path for each buildable check, as reported by |
tuple[list[BuildEvent], list[str], list[str], list[str | None]]
|
|
tuple[list[BuildEvent], list[str], list[str], list[str | None]]
|
|
tuple[list[BuildEvent], list[str], list[str], list[str | None]]
|
positional pairing) and to mark dep-failed targets as |
tuple[list[BuildEvent], list[str], list[str], list[str | None]]
|
failures instead of 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
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 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 | |
_nix_log_level
property
¶
_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_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_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. |