Merge pull request 'vms: rename wayland attrs to waypipe' (#789) from a-kenji-rename-wayland-to-waypipe into main
All checks were successful
checks / test (push) Successful in 30s
checks-impure / test (push) Successful in 1m30s

This commit is contained in:
clan-bot 2024-02-01 03:17:12 +00:00
commit cc21108c59
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; type = lib.types.bool;
default = false; default = false;
description = lib.mdDoc '' 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 whether to enable graphics for the vm
''; '';
}; };
wayland = lib.mkOption { waypipe = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
internal = true; internal = true;
readOnly = true; readOnly = true;
description = '' 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 = { clanCore.vm.inspect = {
clan_name = config.clanCore.clanName; clan_name = config.clanCore.clanName;
memory_size = config.clan.virtualisation.memorySize; memory_size = config.clan.virtualisation.memorySize;
inherit (config.clan.virtualisation) cores graphics wayland; inherit (config.clan.virtualisation) cores graphics waypipe;
}; };
# for clan vm create # for clan vm create
system.clan.vm = { system.clan.vm = {

View File

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

View File

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