Compare commits
2 Commits
main
...
add-serial
Author | SHA1 | Date | |
---|---|---|---|
828f0f5d27 | |||
80c70873ad |
30
flake.lock
30
flake.lock
@ -7,11 +7,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1700927249,
|
||||
"narHash": "sha256-iqmIWiEng890/ru7ZBf4nUezFPyRm2fjRTvuwwxqk2o=",
|
||||
"lastModified": 1702563877,
|
||||
"narHash": "sha256-7x2vXhN8HeKsTK8fhoeZgSXRMlMx1GjQvh7ittgXHOo=",
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"rev": "3cb78c93e6a02f494aaf6aeb37481c27a2e2ee22",
|
||||
"rev": "4c4634bbcb299248efe300b37d1624649fd59477",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -83,11 +83,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1696058303,
|
||||
"narHash": "sha256-eNqKWpF5zG0SrgbbtljFOrRgFgRzCc4++TMFADBMLnc=",
|
||||
"lastModified": 1701689616,
|
||||
"narHash": "sha256-ewnfgvRy73HoP5KnYmy1Rcr4m4yShvsb6TCCaKoW8pc=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixos-generators",
|
||||
"rev": "150f38bd1e09e20987feacb1b0d5991357532fb5",
|
||||
"rev": "246219bc21b943c6f6812bb7744218ba0df08600",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -98,11 +98,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1701609850,
|
||||
"narHash": "sha256-6oxM84kaQT0H/+aurIcj2ON+asWYQ96zlMUIsfhKpFE=",
|
||||
"lastModified": 1702483393,
|
||||
"narHash": "sha256-xdZ+69I2z5ywVtJHW3+BQ99rKFDPkyaPNznstw+gfS8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0b62f5adfd6635f8013d800ceb0cf39411a8216f",
|
||||
"rev": "224b3a5ad9a960e4a6e3cd59233c1616164c5ef5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -148,11 +148,11 @@
|
||||
"nixpkgs-stable": []
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1701572436,
|
||||
"narHash": "sha256-0anfOQqDend6kSuF8CmOSAZsiAS1nwOsin5VQukh6Q4=",
|
||||
"lastModified": 1702177193,
|
||||
"narHash": "sha256-J2409SyXROoUHYXVy9h4Pj0VU8ReLuy/mzBc9iK4DBg=",
|
||||
"owner": "Mic92",
|
||||
"repo": "sops-nix",
|
||||
"rev": "8bca48cb9a12bbd8766f359ad00336924e91b7f7",
|
||||
"rev": "d806e546f96c88cd9f7d91c1c19ebc99ba6277d9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -168,11 +168,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1699786194,
|
||||
"narHash": "sha256-3h3EH1FXQkIeAuzaWB+nK0XK54uSD46pp+dMD3gAcB4=",
|
||||
"lastModified": 1702461037,
|
||||
"narHash": "sha256-ssyGxfGHRuuLHuMex+vV6RMOt7nAo07nwufg9L5GkLg=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "e82f32aa7f06bbbd56d7b12186d555223dc399d1",
|
||||
"rev": "d06b70e5163a903f19009c3f97770014787a080f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -19,6 +19,7 @@ class VmConfig:
|
||||
memory_size: int
|
||||
graphics: bool
|
||||
wayland: bool = False
|
||||
serial: bool = False
|
||||
|
||||
|
||||
def inspect_vm(flake_url: str | Path, flake_attr: str) -> VmConfig:
|
||||
|
@ -33,7 +33,6 @@ def graphics_options(vm: VmConfig) -> list[str]:
|
||||
"-audiodev", "spice,id=audio0",
|
||||
"-device", "intel-hda",
|
||||
"-device", "hda-duplex,audiodev=audio0",
|
||||
"-vga", "none",
|
||||
"-display", "gtk,gl=on",
|
||||
"-device", "virtio-gpu-gl",
|
||||
"-display", "spice-app,gl=on",
|
||||
@ -66,10 +65,16 @@ def qemu_command(
|
||||
(Path(nixos_config["toplevel"]) / "kernel-params").read_text(),
|
||||
f'init={nixos_config["toplevel"]}/init',
|
||||
f'regInfo={nixos_config["regInfo"]}/registration',
|
||||
"console=ttyS0,115200n8",
|
||||
# "console=hvc0,115200n8",
|
||||
"console=ttyS0,115200n8", # serial
|
||||
# console=hvc0
|
||||
]
|
||||
if not wayland:
|
||||
kernel_cmdline.append("console=tty0")
|
||||
if vm.serial:
|
||||
# kernel_cmdline.append("console=tty0")
|
||||
kernel_cmdline.append("console=hvc0")
|
||||
|
||||
# if not wayland or not vm.serial:
|
||||
# kernel_cmdline.append("console=tty0")
|
||||
# fmt: off
|
||||
command = [
|
||||
"qemu-kvm",
|
||||
@ -96,8 +101,22 @@ def qemu_command(
|
||||
|
||||
if vm.graphics:
|
||||
command.extend(graphics_options(vm))
|
||||
else:
|
||||
command.append("-nographic")
|
||||
|
||||
if vm.serial:
|
||||
# command.append("-nographic") # weglassen?? kommt auf modus drauf an
|
||||
command.extend([
|
||||
"-serial", "null",
|
||||
"-device", "virtio-serial",
|
||||
"-chardev", "stdio,mux=on,id=char0,signal=off",
|
||||
"-mon", "chardev=char0,mode=readline",
|
||||
]) # weglassen?? kommt auf modus drauf an
|
||||
#-serial null \
|
||||
# -device virtio-serial \
|
||||
# -chardev stdio,mux=on,id=char0,signal=off \
|
||||
# -mon chardev=char0,mode=readline \
|
||||
# terminal heisst dann anders
|
||||
# console=hvc0
|
||||
# statt ttyS0
|
||||
return command
|
||||
|
||||
|
||||
@ -263,7 +282,9 @@ def run_vm(
|
||||
"XDG_DATA_DIRS"
|
||||
] = f"{remote_viewer_mimetypes}:{env.get('XDG_DATA_DIRS', '')}"
|
||||
|
||||
print("$ " + shlex.join(qemu_cmd))
|
||||
import textwrap
|
||||
|
||||
print("$ " + "\n".join(textwrap.wrap(shlex.join(qemu_cmd))))
|
||||
res = subprocess.run(
|
||||
nix_shell(packages, qemu_cmd),
|
||||
env=env,
|
||||
@ -282,6 +303,7 @@ class RunOptions:
|
||||
flake: Path
|
||||
nix_options: list[str] = field(default_factory=list)
|
||||
wayland: bool = False
|
||||
serial: bool = False
|
||||
|
||||
|
||||
def run_command(args: argparse.Namespace) -> None:
|
||||
@ -291,12 +313,14 @@ def run_command(args: argparse.Namespace) -> None:
|
||||
flake=args.flake or Path.cwd(),
|
||||
nix_options=args.option,
|
||||
wayland=args.wayland,
|
||||
serial=args.serial,
|
||||
)
|
||||
|
||||
flake_url = run_options.flake_url or run_options.flake
|
||||
vm = inspect_vm(flake_url=flake_url, flake_attr=run_options.machine)
|
||||
# TODO: allow to set this in the config
|
||||
vm.wayland = run_options.wayland
|
||||
vm.serial = run_options.serial
|
||||
|
||||
run_vm(vm, run_options.nix_options)
|
||||
|
||||
@ -305,4 +329,5 @@ 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.add_argument("--serial", action="store_true", help="use serial")
|
||||
parser.set_defaults(func=run_command)
|
||||
|
Loading…
Reference in New Issue
Block a user