I want to build an image using make-disk-image.nix
for aarch64-linux
, I picked what seemed to be the simplest derivation nixos/modules/virtualisation/hyperv-image.nix
just as a test, with the following simple patch:
37c37
< system.build.hypervImage = import ../../lib/make-disk-image.nix {
---
> system.build.hypervImage = import <nixpkgs/nixos/lib/make-disk-image.nix> {
39,42d38
< postVM = ''
< ${pkgs.vmTools.qemu}/bin/qemu-img convert -f raw -o subformat=dynamic -O vhdx $diskImage $out/${cfg.vmFileName}
< rm $diskImage
< '';
69d64
< virtualisation.hypervGuest.enable = true;
I try to build it like nix-build --argstr system aarch64-linux '<nixpkgs/nixos>' -I nixos-config=./default.nix -A config.system.build.hypervImage --show-trace
.
Eventually I get to the vm booting but then something happens:
[ 1.710327] Run /init as init process
[ 1.757031] EXT4-fs (vda2): mounted filesystem with ordered data mode. Opts:
[ 2.080044] random: fast init done
[ 5.591459] random: crng init done
[ 60.658328] reboot: Restarting system
WARNING: Image format was not specified for 'nixos.raw' and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
Specify the 'raw' format explicitly to remove the restrictions.
kvm version too old
.qemu-system-aarch64-wrapped: failed to initialize kvm: Function not implemented
builder for '/nix/store/4g391kv25kwh6nc5vzc66x93ri5lzy5z-nixos-hyperv-21.11pre312229.08ef0f28e3a-aarch64-linux.drv' failed with exit code 1
error: build of '/nix/store/4g391kv25kwh6nc5vzc66x93ri5lzy5z-nixos-hyperv-21.11pre312229.08ef0f28e3a-aarch64-linux.drv' failed
I have no idea what to do. I should note I am running this not on NixOS, but on Arch with Nix installed. I had to install qemu-user-static
on my host os to get this far. KVM seems to work otherwise, I have been able to make and launch a VirtualBox-based guest with KVM as well as a “hello world” KVM application found on github. Any ideas?