forked from clan/clan-core
add: serial option
This commit is contained in:
parent
7b5fffdaf4
commit
80c70873ad
30
flake.lock
30
flake.lock
@ -7,11 +7,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1700927249,
|
"lastModified": 1702563877,
|
||||||
"narHash": "sha256-iqmIWiEng890/ru7ZBf4nUezFPyRm2fjRTvuwwxqk2o=",
|
"narHash": "sha256-7x2vXhN8HeKsTK8fhoeZgSXRMlMx1GjQvh7ittgXHOo=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "disko",
|
"repo": "disko",
|
||||||
"rev": "3cb78c93e6a02f494aaf6aeb37481c27a2e2ee22",
|
"rev": "4c4634bbcb299248efe300b37d1624649fd59477",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -83,11 +83,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1696058303,
|
"lastModified": 1701689616,
|
||||||
"narHash": "sha256-eNqKWpF5zG0SrgbbtljFOrRgFgRzCc4++TMFADBMLnc=",
|
"narHash": "sha256-ewnfgvRy73HoP5KnYmy1Rcr4m4yShvsb6TCCaKoW8pc=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "nixos-generators",
|
"repo": "nixos-generators",
|
||||||
"rev": "150f38bd1e09e20987feacb1b0d5991357532fb5",
|
"rev": "246219bc21b943c6f6812bb7744218ba0df08600",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -98,11 +98,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1701609850,
|
"lastModified": 1702483393,
|
||||||
"narHash": "sha256-6oxM84kaQT0H/+aurIcj2ON+asWYQ96zlMUIsfhKpFE=",
|
"narHash": "sha256-xdZ+69I2z5ywVtJHW3+BQ99rKFDPkyaPNznstw+gfS8=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "0b62f5adfd6635f8013d800ceb0cf39411a8216f",
|
"rev": "224b3a5ad9a960e4a6e3cd59233c1616164c5ef5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -148,11 +148,11 @@
|
|||||||
"nixpkgs-stable": []
|
"nixpkgs-stable": []
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1701572436,
|
"lastModified": 1702177193,
|
||||||
"narHash": "sha256-0anfOQqDend6kSuF8CmOSAZsiAS1nwOsin5VQukh6Q4=",
|
"narHash": "sha256-J2409SyXROoUHYXVy9h4Pj0VU8ReLuy/mzBc9iK4DBg=",
|
||||||
"owner": "Mic92",
|
"owner": "Mic92",
|
||||||
"repo": "sops-nix",
|
"repo": "sops-nix",
|
||||||
"rev": "8bca48cb9a12bbd8766f359ad00336924e91b7f7",
|
"rev": "d806e546f96c88cd9f7d91c1c19ebc99ba6277d9",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -168,11 +168,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1699786194,
|
"lastModified": 1702461037,
|
||||||
"narHash": "sha256-3h3EH1FXQkIeAuzaWB+nK0XK54uSD46pp+dMD3gAcB4=",
|
"narHash": "sha256-ssyGxfGHRuuLHuMex+vV6RMOt7nAo07nwufg9L5GkLg=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "treefmt-nix",
|
"repo": "treefmt-nix",
|
||||||
"rev": "e82f32aa7f06bbbd56d7b12186d555223dc399d1",
|
"rev": "d06b70e5163a903f19009c3f97770014787a080f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -19,6 +19,7 @@ class VmConfig:
|
|||||||
memory_size: int
|
memory_size: int
|
||||||
graphics: bool
|
graphics: bool
|
||||||
wayland: bool = False
|
wayland: bool = False
|
||||||
|
serial: bool = False
|
||||||
|
|
||||||
|
|
||||||
def inspect_vm(flake_url: str | Path, flake_attr: str) -> VmConfig:
|
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",
|
"-audiodev", "spice,id=audio0",
|
||||||
"-device", "intel-hda",
|
"-device", "intel-hda",
|
||||||
"-device", "hda-duplex,audiodev=audio0",
|
"-device", "hda-duplex,audiodev=audio0",
|
||||||
"-vga", "none",
|
|
||||||
"-display", "gtk,gl=on",
|
"-display", "gtk,gl=on",
|
||||||
"-device", "virtio-gpu-gl",
|
"-device", "virtio-gpu-gl",
|
||||||
"-display", "spice-app,gl=on",
|
"-display", "spice-app,gl=on",
|
||||||
@ -66,10 +65,16 @@ def qemu_command(
|
|||||||
(Path(nixos_config["toplevel"]) / "kernel-params").read_text(),
|
(Path(nixos_config["toplevel"]) / "kernel-params").read_text(),
|
||||||
f'init={nixos_config["toplevel"]}/init',
|
f'init={nixos_config["toplevel"]}/init',
|
||||||
f'regInfo={nixos_config["regInfo"]}/registration',
|
f'regInfo={nixos_config["regInfo"]}/registration',
|
||||||
"console=ttyS0,115200n8",
|
# "console=hvc0,115200n8",
|
||||||
|
# "console=ttyS0,115200n8", # serial
|
||||||
|
# console=hvc0
|
||||||
]
|
]
|
||||||
if not wayland:
|
if vm.serial:
|
||||||
kernel_cmdline.append("console=tty0")
|
kernel_cmdline.append("console=hvc0,115200n8")
|
||||||
|
print("HUUUI")
|
||||||
|
exit()
|
||||||
|
# if not wayland:
|
||||||
|
# kernel_cmdline.append("console=tty0")
|
||||||
# fmt: off
|
# fmt: off
|
||||||
command = [
|
command = [
|
||||||
"qemu-kvm",
|
"qemu-kvm",
|
||||||
@ -96,8 +101,22 @@ def qemu_command(
|
|||||||
|
|
||||||
if vm.graphics:
|
if vm.graphics:
|
||||||
command.extend(graphics_options(vm))
|
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
|
return command
|
||||||
|
|
||||||
|
|
||||||
@ -256,7 +275,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.wayland or vm.serial):
|
||||||
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[
|
||||||
@ -305,4 +324,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("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.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)
|
parser.set_defaults(func=run_command)
|
||||||
|
Loading…
Reference in New Issue
Block a user