Revert "clan-cli: deprecate nix_shell() in favor of run_cmd()"

This reverts commit a598b878a5.
This commit is contained in:
Jörg Thalheim
2024-07-17 14:04:49 +02:00
parent 0518f875cd
commit 64956a7a0a
24 changed files with 116 additions and 104 deletions

View File

@@ -13,7 +13,7 @@ from ..dirs import module_root, user_cache_dir, vm_state_dir
from ..errors import ClanError
from ..facts.generate import generate_facts
from ..machines.machines import Machine
from ..nix import run_cmd
from ..nix import nix_shell
from .inspect import VmConfig, inspect_vm
from .qemu import qemu_command
from .virtiofsd import start_virtiofsd
@@ -82,8 +82,8 @@ def prepare_disk(
file_name: str = "disk.img",
) -> Path:
disk_img = directory / file_name
cmd = run_cmd(
["qemu"],
cmd = nix_shell(
["nixpkgs#qemu"],
[
"qemu-img",
"create",
@@ -170,11 +170,11 @@ def run_vm(
qga_socket_file=qga_socket_file,
)
packages = ["qemu"]
packages = ["nixpkgs#qemu"]
env = os.environ.copy()
if vm.graphics and not vm.waypipe:
packages.append("virt-viewer")
packages.append("nixpkgs#virt-viewer")
remote_viewer_mimetypes = module_root() / "vms" / "mimetypes"
env["XDG_DATA_DIRS"] = (
f"{remote_viewer_mimetypes}:{env.get('XDG_DATA_DIRS', '')}"
@@ -185,7 +185,7 @@ def run_vm(
start_virtiofsd(virtiofsd_socket),
):
run(
run_cmd(packages, qemu_cmd.args),
nix_shell(packages, qemu_cmd.args),
env=env,
log=Log.BOTH,
error_msg=f"Could not start vm {machine}",

View File

@@ -6,7 +6,7 @@ from collections.abc import Iterator
from pathlib import Path
from ..errors import ClanError
from ..nix import run_cmd
from ..nix import nix_shell
@contextlib.contextmanager
@@ -14,8 +14,8 @@ def start_virtiofsd(socket_path: Path) -> Iterator[None]:
sandbox = "namespace"
if shutil.which("newuidmap") is None:
sandbox = "none"
virtiofsd = run_cmd(
["virtiofsd"],
virtiofsd = nix_shell(
["nixpkgs#virtiofsd"],
[
"virtiofsd",
"--socket-path",

View File

@@ -5,7 +5,7 @@ import time
from collections.abc import Iterator
from ..errors import ClanError
from ..nix import run_cmd
from ..nix import nix_shell
VMADDR_CID_HYPERVISOR = 2
@@ -25,8 +25,8 @@ def start_waypipe(cid: int | None, title_prefix: str) -> Iterator[None]:
if cid is None:
yield
return
waypipe = run_cmd(
["waypipe"],
waypipe = nix_shell(
["nixpkgs#waypipe"],
[
"waypipe",
"--vsock",