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