installing NixOS on VirtualBox

I downloaded the 24.05 NixOS ISO image from https://nixos.org/download/.

Issues encountered

VM does not start ✅

When trying to install NixOS in virtualbox (installed in my ArchCraft OS), I got the following error:

WARNING: The vboxdrv kernel module is not loaded. Either there is no module
         available for the current kernel (arch-xxx-amd64) or it failed to
         load. Please recompile the kernel module and install it by

           sudo /etc/init.d/vboxdrv setup

         You will not be able to start VMs until this problem is fixed.

According to https://stackoverflow.com/a/50375429/3612053, I had to:

yay -S virtualbox-host-modules-arch
sudo modprobe vboxdrv

However, it was not enough, as I got another issue:

modprobe: ERROR: could not insert 'vboxdrv': Required key not available

So I had to install the following:

yay -S linux-headers
 
# then I had to reboot my computer
shutdown -r now

Black screen with blinking cursor ✅

I started the ISO, there were a bunch of logs, and then it stopped at a black screen with a blinking cursor.

I changed the settings of the OS in Settings > System > Motherboard, checked Enable EFI (special OSes only). However, it seems, it’s not enough as I’m now stuck at a black screen.

I changed the settings of the OS in Settings > System > Processor, checked Enable Nested VT-x/AMD-V.

It should be related to https://forums.virtualbox.org/viewtopic.php?f=1&t=62339.

Display not refreshed ✅

After installing NixOS, the display is not refreshed after I insert inputs or click. Only when I go out of the virtualbox (right Ctrl) did it refresh.

Tried https://www.virtualbox.org/ticket/18205: Settings > Display > Graphic controller set to VMSVGA instead of VBoxVGA.

Changed resolution to 1920x1080 ✅

When change the resolution to the same as my host, I got a black screen…

Reboot and changed to 1280x720 did the trick.