Getting NixOS to work MacOS M1/2/3 (aarch64-darwin)

I’m trying to run integration tests on macOS M2 (aarch64-darwin) using NixOS tests. I can get NixOS VMs running with nixpkgs.lib.nixosSystem, but when trying to use nixpkgs.lib.runTest, I started hitting this error:

nix run .\#integrationTest                                                
Failed to find a machine for remote build!
derivation: 3d07hsqd9hlk27izi0zr1lasqmarm2hz-vm-test-run-hello.drv
required (system, features): (aarch64-darwin, [kvm, nixos-test])
1 available machine:
(systems, maxjobs, supportedFeatures, mandatoryFeatures)
([aarch64-linux], 10, [benchmark, big-parallel, kvm, nixos-test], [])
error: an 'aarch64-darwin' with features {kvm, nixos-test} is required to build '/nix/store/3d07hsqd9hlk27izi0zr1lasqmarm2hz-vm-test-run-hello.drv', but I am an 'aarch64-darwin' with features {benchmark, big-parallel, nixos-test}

This error expects to find kvm on aarch64-darwin. Forcing the addition of it to my host machine gets the VM to start, but it hangs (maybe it’s missing acceleration and it’s just too slow):

  nix = {
    extraOptions = ''
      system-features = kvm nixos-test
    '';
  };

I know kvm is not supported on Apple Silicon, but I also tried to add the new apple-virt feature, but it’s still hanging/slow. Perhaps that is already being addressed in macOS support for NixOS tests, but that is not clear to me yet. Does anyone know how to get this working?

I got it working thanks to PR @Gabriel439 is working on! Hopefully that PR will be soon merged and we can call this fully resolved. For anyone looking for a reference, here is what I did: feat: nixsify by lostbean · Pull Request #2092 · kurtosis-tech/kurtosis · GitHub

1 Like