nix_build_machine: escape json
This commit is contained in:
@@ -1,26 +1,31 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from .dirs import get_clan_flake_toplevel, nixpkgs_flake, nixpkgs_source, unfree_nixpkgs
|
from .dirs import get_clan_flake_toplevel, nixpkgs_flake, nixpkgs_source, unfree_nixpkgs
|
||||||
|
|
||||||
|
|
||||||
def nix_build_machine(machine: str, attr: list[str]) -> list[str]:
|
def nix_build_machine(
|
||||||
clan_flake = get_clan_flake_toplevel()
|
machine: str, attr: list[str], flake_url: Path | None = None
|
||||||
|
) -> list[str]:
|
||||||
|
if flake_url is None:
|
||||||
|
flake_url = get_clan_flake_toplevel()
|
||||||
payload = json.dumps(
|
payload = json.dumps(
|
||||||
dict(
|
dict(
|
||||||
clan_flake=clan_flake,
|
clan_flake=flake_url,
|
||||||
machine=machine,
|
machine=machine,
|
||||||
attr=attr,
|
attr=attr,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
escaped_payload = json.dumps(payload)
|
||||||
return [
|
return [
|
||||||
"nix",
|
"nix",
|
||||||
"build",
|
"build",
|
||||||
"--impure",
|
"--impure",
|
||||||
"--print-out-paths",
|
"--print-out-paths",
|
||||||
"--expr",
|
"--expr",
|
||||||
f'let args = builtins.fromJSON "{payload}"; in '
|
f"let args = builtins.fromJSON {escaped_payload}; in "
|
||||||
"""
|
"""
|
||||||
let
|
let
|
||||||
flake = builtins.getFlake args.clan_flake;
|
flake = builtins.getFlake args.clan_flake;
|
||||||
|
|||||||
Reference in New Issue
Block a user