Windows 11 VM on nixos

Hey there, what would be the cleanest, easiest and most performant way to run a Windows 11 virtual machine on NixOS? Declarative would be a bonus point, but probably not possible to do that in a simple way. System specs are no problem, I have a high end pc.

2 Likes

QEMU/KVM/libvirt is well supported.

I created a simple wrapper around QEMU called Quickemu which is in nixpkgs. Once installed you can do the following:

quickget windows 11
quickemu --vm windows-11.conf

quickget download the Windows 11 .iso and create an unattended.iso image, which makes the Windows install mostly automatic. That unattended.iso also autoruns all the VirtIO and SPICE drivers to optimise the Windows guest.

19 Likes

You can use libvirt setup with a compatible secure boot capable (not necessarily enabled) UEFI. Then make sure to add a software TPM to the virtual machine config. Windows 11 should happily install after that. Here is the snippet of my config that sets up libvirt.

You can choose a front end for libvirt to do the vm config, I use virt-manager.

@Wimpy I once tried quickemu, but quickget is just so slow for me for some reason. I have 200 mbits internet, but the download is always like 250KB /son quickget while it should be around 24MB/s. Any way to address this issue?

have you tested the command?

Works fine here, I’m getting solid 26MB/s.

Same here. Ever resolved it?

disable secureboot="on"
i can boot after that

Same here. Really unusable. It’s not the servers per-se. When I download the same URL in browser it goes fast. (Also apparently if you re-run the command.)

Thank you for this information.

1 Like

This should be much improved in the upcoming Quickemu 4.9.3

This failed for me with Error 0x80070103 - 0x40031. I found a GitHub issue that lead me to a solution. First, we want to replace drive E: with F:, e.g. using sed in-place, and start the image with a custom drive.

sed -i 's/E:/F:/g' windows-11/unattended/autounattend.xml
quickemu --vm windows-11.conf --extra_args "--drive media=cdrom,index=3,file=windows-11/virtio-win.iso"

This partly works, but does not recognize the VirtIO drivers successfully. Following the screenshot in the mentioned issue, you can install it by clicking Browse and then choosing F:\viostor\w11\amd64\. Afterwards, the installation continues unattended.

I was missing some more devices’ drivers but they could be installed by pressing Win+X, selecting Device Manager, right-clicking the device, selecting Update driver, Browse my computer for drivers and setting F: as a location. I bet there is a less painful solution, but it works.

I wanted to use a USB device within Windows so I also had to activate virtualisation.spiceUSBRedirection.enable. Calling quickemu ... --display spice changes the interface so you can now press Input > Select USB devices for redirection.

1 Like

Additional note: this is now fixed via fix: windows 11 25H2 installation by lvillani · Pull Request #1745 · quickemu-project/quickemu · GitHub (not currently included in any quickemu release).

Also as the language names have changed, the instructions are now more like quickget windows 11 "English (United States)" && quickemu --vm windows-11-English-United-States.conf for US English.