Split Qemu parameters

So we can re-use params for incremental install
This commit is contained in:
adisbladis 2020-05-03 15:37:56 +01:00 committed by Stephan Maka
parent 6bbbd41ece
commit 7b4cd0b944
1 changed files with 30 additions and 23 deletions

View File

@ -113,9 +113,7 @@ let
virt-make-fs --partition --type=fat pkgs/ $out virt-make-fs --partition --type=fat pkgs/ $out
''; '';
installScript = pkgs.writeScript "windows-install-script" ( mkQemuFlags = extraFlags: [
let
qemuParams = [
"-enable-kvm" "-enable-kvm"
"-cpu" "-cpu"
"host" "host"
@ -129,6 +127,20 @@ let
"virtio" "virtio"
"-device" "-device"
"piix3-usb-uhci" # USB root hub "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 = mkQemuFlags [
# "CD" drive with bootstrap pkgs
"-drive"
"id=virtio-win,file=${bootstrapPkgs},if=none,format=raw,readonly=on"
"-device"
"usb-storage,drive=virtio-win"
# USB boot # USB boot
"-drive" "-drive"
"id=win-install,file=usbimage.img,if=none,format=raw,readonly=on" "id=win-install,file=usbimage.img,if=none,format=raw,readonly=on"
@ -137,22 +149,17 @@ let
# Output image # Output image
"-drive" "-drive"
"file=c.img,index=0,media=disk,cache=unsafe" "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 in
'' ''
#!${pkgs.runtimeShell} #!${pkgs.runtimeShell}
set -euxo pipefail set -euxo pipefail
export PATH=${lib.makeBinPath [ p7zip qemu libguestfs ]}:$PATH 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 # Create a bootable "USB" image
# Booting in USB mode circumvents the "press any key to boot from cdrom" prompt # Booting in USB mode circumvents the "press any key to boot from cdrom" prompt
# #