How to run a NixOS on a virtual machine on MacOS with M1?

I am trying to set up NixOS on an M1 MacOS, but I have no clue where to start. As AArch64 is not supported for NixOS right now, I want to try using virtual machine instead. Is there any guide that I can follow to create NixOS on a virtual machine, like qemu or virtual box?

I don’t have an m1 mac but I believe the easiest free way to run an x86_64 OS is to use something like UTM which is an easy to use front end for QEMU. Keep in mind, performance may not be ideal since you will basically be emulating x86_64.

From a NixOS perspective, the install isn’t done any differently. You should be able to follow the NixOS installation guide once you have the VM up and running.

it should be possible and work much better to use arm64 nixos image


Aarch64 is supported by NixOS. Not that using a VM would let you use non-aarch64 anyway.

It would let you but that would be very slow because the VM would be emulated instead of virtualised.

I’ve had some success with this. I’m using VMware Fusion Tech Preview (Player Version e.x.p (18656771)). It’s technically preview software with ARM support, but I haven’t run into any issues with VMware itself.

Finding the right ISOs was a little tricky. They’re not available on the homepage anywhere, and the links in the wiki (NixOS on ARM/UEFI - NixOS Wiki) only point to unstable builds. Eventually I dug around and found Hydra - nixos:release-21.05-aarch64:nixos.iso_minimal.aarch64-linux. I should probably edit the wiki to make this more discoverable at some point.

I used my own tool, nixos-up, and after fixing a few bugs (like this and the fact that gdm doesn’t work) I was off to the races.

Unfortunately VMware guest tools are not currently supported on aarch64-linux yet. Not sure if this is an issue with nixpkgs or with the upstream builds.

Hosted by Flying Circus.