only enable show-trace if we run in debug mode
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
@@ -8,6 +9,8 @@ from clan_cli.cmd import run, run_no_stdout
|
||||
from clan_cli.dirs import nixpkgs_flake, nixpkgs_source
|
||||
from clan_cli.errors import ClanError
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def nix_command(flags: list[str]) -> list[str]:
|
||||
args = ["nix", "--extra-experimental-features", "nix-command flakes", *flags]
|
||||
@@ -23,39 +26,23 @@ def nix_flake_show(flake_url: str | Path) -> list[str]:
|
||||
"flake",
|
||||
"show",
|
||||
"--json",
|
||||
"--show-trace",
|
||||
f"{flake_url}",
|
||||
*(["--show-trace"] if log.isEnabledFor(logging.DEBUG) else []),
|
||||
str(flake_url),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def nix_build(flags: list[str], gcroot: Path | None = None) -> list[str]:
|
||||
if gcroot is not None:
|
||||
return (
|
||||
nix_command(
|
||||
return nix_command(
|
||||
[
|
||||
"build",
|
||||
"--out-link",
|
||||
str(gcroot),
|
||||
"--print-out-paths",
|
||||
"--show-trace",
|
||||
"--print-build-logs",
|
||||
*(["--show-trace"] if log.isEnabledFor(logging.DEBUG) else []),
|
||||
*(["--out-root", str(gcroot)] if gcroot is not None else []),
|
||||
*flags,
|
||||
]
|
||||
)
|
||||
+ flags
|
||||
)
|
||||
return (
|
||||
nix_command(
|
||||
[
|
||||
"build",
|
||||
"--no-link",
|
||||
"--print-out-paths",
|
||||
"--show-trace",
|
||||
"--print-build-logs",
|
||||
]
|
||||
)
|
||||
+ flags
|
||||
)
|
||||
|
||||
|
||||
def nix_add_to_gcroots(nix_path: Path, dest: Path) -> None:
|
||||
@@ -77,7 +64,7 @@ def nix_eval(flags: list[str]) -> list[str]:
|
||||
default_flags = nix_command(
|
||||
[
|
||||
"eval",
|
||||
"--show-trace",
|
||||
*(["--show-trace"] if log.isEnabledFor(logging.DEBUG) else []),
|
||||
"--json",
|
||||
"--print-build-logs",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user