diff options
Diffstat (limited to 'nixos/modules/virtualisation/qemu-vm.nix')
-rw-r--r-- | nixos/modules/virtualisation/qemu-vm.nix | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index 0bb2e7f36873..bd964723d408 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -13,6 +13,8 @@ with lib; let + qemu = config.system.build.qemu or pkgs.qemu_test; + vmName = if config.networking.hostName == "" then "noname" @@ -32,7 +34,7 @@ let NIX_DISK_IMAGE=$(readlink -f ''${NIX_DISK_IMAGE:-${config.virtualisation.diskImage}}) if ! test -e "$NIX_DISK_IMAGE"; then - ${pkgs.qemu_kvm}/bin/qemu-img create -f qcow2 "$NIX_DISK_IMAGE" \ + ${qemu}/bin/qemu-img create -f qcow2 "$NIX_DISK_IMAGE" \ ${toString config.virtualisation.diskSize}M || exit 1 fi @@ -47,7 +49,7 @@ let ${if cfg.useBootLoader then '' # Create a writable copy/snapshot of the boot disk. # A writable boot disk can be booted from automatically. - ${pkgs.qemu_kvm}/bin/qemu-img create -f qcow2 -b ${bootDisk}/disk.img $TMPDIR/disk.img || exit 1 + ${qemu}/bin/qemu-img create -f qcow2 -b ${bootDisk}/disk.img $TMPDIR/disk.img || exit 1 ${if cfg.useEFIBoot then '' # VM needs a writable flash BIOS. @@ -63,14 +65,14 @@ let extraDisks="" ${flip concatMapStrings cfg.emptyDiskImages (size: '' if ! test -e "empty$idx.qcow2"; then - ${pkgs.qemu_kvm}/bin/qemu-img create -f qcow2 "empty$idx.qcow2" "${toString size}M" + ${qemu}/bin/qemu-img create -f qcow2 "empty$idx.qcow2" "${toString size}M" fi extraDisks="$extraDisks -drive index=$idx,file=$(pwd)/empty$idx.qcow2,if=${cfg.qemu.diskInterface},werror=report" idx=$((idx + 1)) '')} # Start QEMU. - exec ${pkgs.qemu_test}/bin/qemu-kvm \ + exec ${qemu}/bin/qemu-kvm \ -name ${vmName} \ -m ${toString config.virtualisation.memorySize} \ ${optionalString (pkgs.stdenv.system == "x86_64-linux") "-cpu kvm64"} \ @@ -121,7 +123,7 @@ let mkdir $out diskImage=$out/disk.img bootFlash=$out/bios.bin - ${pkgs.qemu_kvm}/bin/qemu-img create -f qcow2 $diskImage "40M" + ${qemu}/bin/qemu-img create -f qcow2 $diskImage "40M" ${if cfg.useEFIBoot then '' cp ${pkgs.OVMF-CSM}/FV/OVMF.fd $bootFlash chmod 0644 $bootFlash |