vms: rename wayland attrs to waypipe
All checks were successful
checks / test (pull_request) Successful in 1m2s
checks-impure / test (pull_request) Successful in 1m34s

And remove the options from the cli interface.
This commit is contained in:
a-kenji 2024-02-01 09:52:20 +07:00
parent cdeb409c53
commit 533012af7d
3 changed files with 10 additions and 15 deletions

View File

@ -120,11 +120,11 @@ in
'';
};
wayland = lib.mkOption {
waypipe = lib.mkOption {
type = lib.types.bool;
default = false;
description = lib.mdDoc ''
Whether to run QEMU with a native wayland window, or not.
Whether to use waypipe for native wayland passthrough, or not.
'';
};
};
@ -164,12 +164,12 @@ in
whether to enable graphics for the vm
'';
};
wayland = lib.mkOption {
waypipe = lib.mkOption {
type = lib.types.bool;
internal = true;
readOnly = true;
description = ''
whether to enable native wayland window passthrough for the vm
whether to enable native wayland window passthrough with waypipe for the vm
'';
};
};
@ -180,7 +180,7 @@ in
clanCore.vm.inspect = {
clan_name = config.clanCore.clanName;
memory_size = config.clan.virtualisation.memorySize;
inherit (config.clan.virtualisation) cores graphics wayland;
inherit (config.clan.virtualisation) cores graphics waypipe;
};
# for clan vm create
system.clan.vm = {

View File

@ -15,7 +15,7 @@ class VmConfig:
cores: int
memory_size: int
graphics: bool
wayland: bool = False
waypipe: bool = False
def inspect_vm(machine: Machine) -> VmConfig:

View File

@ -37,7 +37,7 @@ def graphics_options(vm: VmConfig) -> GraphicOptions:
"driver=pa,model=virtio",
]
if vm.wayland:
if vm.waypipe:
# FIXME: check for collisions
cid = random.randint(1, 2**32)
# fmt: off
@ -101,7 +101,7 @@ def qemu_command(
f'regInfo={nixos_config["regInfo"]}/registration',
"console=ttyS0,115200n8",
]
if not vm.wayland:
if not vm.waypipe:
kernel_cmdline.append("console=tty0")
# fmt: off
command = [
@ -343,7 +343,7 @@ def run_vm(
packages = ["nixpkgs#qemu"]
env = os.environ.copy()
if vm.graphics and not vm.wayland:
if vm.graphics and not vm.waypipe:
packages.append("nixpkgs#virt-viewer")
remote_viewer_mimetypes = module_root() / "vms" / "mimetypes"
env[
@ -364,7 +364,7 @@ class RunOptions:
machine: str
flake: Path
nix_options: list[str] = field(default_factory=list)
wayland: bool = False
waypipe: bool = False
def run_command(args: argparse.Namespace) -> None:
@ -372,21 +372,16 @@ def run_command(args: argparse.Namespace) -> None:
machine=args.machine,
flake=args.flake,
nix_options=args.option,
wayland=args.wayland,
)
machine = Machine(run_options.machine, run_options.flake)
vm = inspect_vm(machine=machine)
if run_options.wayland:
vm.wayland = run_options.wayland
run_vm(vm, run_options.nix_options)
def register_run_parser(parser: argparse.ArgumentParser) -> None:
parser.add_argument("machine", type=str, help="machine in the flake to run")
parser.add_argument("--flake-url", type=str, help="flake url")
parser.add_argument("--wayland", action="store_true", help="use wayland")
parser.set_defaults(func=run_command)