From 24a0fca4a94387d1745c9b4759748267525861a7 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 24 Sep 2024 20:25:11 +0300 Subject: [PATCH 1/2] hosts/caesar: disable graphics; add resize script --- hosts/caesar/virt.nix | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/hosts/caesar/virt.nix b/hosts/caesar/virt.nix index 26ac384..ab850b2 100644 --- a/hosts/caesar/virt.nix +++ b/hosts/caesar/virt.nix @@ -1,15 +1,36 @@ { - config, modulesPath, + config, + pkgs, ... -}: { +}: let + # https://unix.stackexchange.com/questions/16578/resizable-serial-console-window + resize = pkgs.writeScriptBin "resize" '' + if [ -e /dev/tty ]; then + old=$(stty -g) + stty raw -echo min 0 time 5 + printf '\033[18t' > /dev/tty + IFS=';t' read -r _ rows cols _ < /dev/tty + stty "$old" + stty cols "$cols" rows "$rows" + fi + ''; +in { imports = [(modulesPath + "/virtualisation/qemu-vm.nix")]; + environment = { + systemPackages = [resize]; + loginShellInit = "${resize}/bin/resize"; + }; + virtualisation = { memorySize = 8000; diskSize = 200000; cores = 8; + # Try to make this bootable. + useBootLoader = true; + # fs useDefaultFilesystems = false; rootDevice = "/dev/disk/by-label/NIXOS_ROOT"; @@ -25,6 +46,9 @@ vm0.vlan = 1; }; + # The VM will run on a headless machine. + graphics = false; + # mac addr can be anything, especially the last 3 bytes # the OUI is specific to QEMU qemu.networkingOptions = [ From 080212f237c51cf8f9e47838f62f217934f83bbf Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 24 Sep 2024 20:25:43 +0300 Subject: [PATCH 2/2] hosts/ceasar: explicitly enable grub --- hosts/caesar/default.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hosts/caesar/default.nix b/hosts/caesar/default.nix index d84f8bf..4f96f8d 100644 --- a/hosts/caesar/default.nix +++ b/hosts/caesar/default.nix @@ -14,8 +14,13 @@ in { boot = { initrd.supportedFilesystems = ["ext4"]; - kernelPackages = lib.mkOverride 0 pkgs.linuxPackages_latest; + + loader.grub = { + efiSupport = true; + efiInstallAsRemovable = true; + device = "nodev"; + }; }; programs.zsh = {