nix_eval: add --json by default

This commit is contained in:
Jörg Thalheim
2023-09-15 13:44:04 +02:00
parent 39271fe2dc
commit 9b7b6996d6
3 changed files with 19 additions and 21 deletions

View File

@@ -100,7 +100,6 @@ def options_for_machine(machine_name: str, flake: Optional[Path] = None) -> dict
proc = subprocess.run(
nix_eval(
flags=[
"--json",
"--show-trace",
"--impure",
"--expr",
@@ -138,7 +137,6 @@ def read_machine_option_value(machine_name: str, option: str) -> str:
proc = subprocess.run(
nix_eval(
flags=[
"--json",
"--show-trace",
"--extra-experimental-features",
"nix-command flakes",

View File

@@ -45,7 +45,6 @@ def schema_for_machine(machine_name: str, flake: Optional[Path] = None) -> dict:
proc = subprocess.run(
nix_eval(
flags=[
"--json",
"--impure",
"--show-trace",
"--extra-experimental-features",

View File

@@ -41,14 +41,19 @@ def nix_build_machine(
def nix_eval(flags: list[str]) -> list[str]:
if os.environ.get("IN_NIX_SANDBOX"):
with tempfile.TemporaryDirectory() as nix_store:
return [
default_flags = [
"nix",
"eval",
"--show-trace",
"--json",
"--extra-experimental-features",
"nix-command flakes",
]
if os.environ.get("IN_NIX_SANDBOX"):
with tempfile.TemporaryDirectory() as nix_store:
return (
default_flags
+ [
"--override-input",
"nixpkgs",
str(nixpkgs_source()),
@@ -56,14 +61,10 @@ def nix_eval(flags: list[str]) -> list[str]:
# error: cannot unlink '/nix/store/6xg259477c90a229xwmb53pdfkn6ig3g-default-builder.sh': Operation not permitted
"--store",
nix_store,
] + flags
return [
"nix",
"eval",
"--show-trace",
"--extra-experimental-features",
"nix-command flakes",
] + flags
]
+ flags
)
return default_flags + flags
def nix_shell(packages: list[str], cmd: list[str]) -> list[str]: