From 7b4cd0b9443fec9bd1c1f0598a314bb0ad27ea26 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Sun, 3 May 2020 15:37:56 +0100 Subject: [PATCH] Split Qemu parameters So we can re-use params for incremental install --- artiq-fast/windows/win.nix | 53 +++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/artiq-fast/windows/win.nix b/artiq-fast/windows/win.nix index 0b16d8a..77d8942 100644 --- a/artiq-fast/windows/win.nix +++ b/artiq-fast/windows/win.nix @@ -113,22 +113,34 @@ let virt-make-fs --partition --type=fat pkgs/ $out ''; + mkQemuFlags = extraFlags: [ + "-enable-kvm" + "-cpu" + "host" + "-smp" + "$NIX_BUILD_CORES" + "-m" + "${qemuMem}" + "-bios" + "${pkgs.OVMF.fd}/FV/OVMF.fd" + "-vga" + "virtio" + "-device" + "piix3-usb-uhci" # USB root hub + # "CD" drive with windows features-on-demand + # "-cdrom" "${fodIso}" + # Set the base clock inside the VM + "-rtc base=${baseRtc}" + ] ++ lib.optional (!impureMode) "-nographic" ++ extraFlags; + installScript = pkgs.writeScript "windows-install-script" ( let - qemuParams = [ - "-enable-kvm" - "-cpu" - "host" - "-smp" - "$NIX_BUILD_CORES" - "-m" - "${qemuMem}" - "-bios" - "${pkgs.OVMF.fd}/FV/OVMF.fd" - "-vga" - "virtio" + qemuParams = mkQemuFlags [ + # "CD" drive with bootstrap pkgs + "-drive" + "id=virtio-win,file=${bootstrapPkgs},if=none,format=raw,readonly=on" "-device" - "piix3-usb-uhci" # USB root hub + "usb-storage,drive=virtio-win" # USB boot "-drive" "id=win-install,file=usbimage.img,if=none,format=raw,readonly=on" @@ -137,22 +149,17 @@ let # Output image "-drive" "file=c.img,index=0,media=disk,cache=unsafe" - # "CD" drive with bootstrap pkgs - "-drive" - "id=virtio-win,file=${bootstrapPkgs},if=none,format=raw,readonly=on" - "-device" - "usb-storage,drive=virtio-win" - # "CD" drive with windows features-on-demand - # "-cdrom" "${fodIso}" - # Set the base clock inside the VM - "-rtc=$(date -Iseconds -d @${baseRtc}" - ] ++ lib.optional (!impureMode) "-nographic"; + ]; in '' #!${pkgs.runtimeShell} set -euxo pipefail export PATH=${lib.makeBinPath [ p7zip qemu libguestfs ]}:$PATH + if test -z "''${NIX_BUILD_CORES+x}"; then + export NIX_BUILD_CORES=$(nproc) + fi + # Create a bootable "USB" image # Booting in USB mode circumvents the "press any key to boot from cdrom" prompt #