Compiling Vagrant project

I am trying to compile a project that uses Vagrant for its build system (Mastodon). It has been a… process. I have been hitting quite a lot of issues and have been able to track them down mostly thanks to posts on this forum. Unfortunately, I’ve not hit an issue that I’ve been unable to track down a solution for.

I have done the following so far:

# configuration.nix
{
  # install vagrant
  users.users.apropos.packages = with pkgs; [ vagrant ];
  # enable virtualbox
  virtualisation.virtualbox.host.enable = true;
  # resolve weird NFS issues
  services.nfs.server.enable = true;
  # resolve weird host errors
  environment.etc."vbox/networks.conf".text = ''
    * 192.168.0.0/16
  '';
  # already disabled, likely relevant
  networking.firewall.enable = false;
  # already enabled, likely relevant
  nixpkgs.config.allowUnfree = true;
  # already generated by hardware config, likely relevant
  boot.kernelModules = [ "kvm-amd" ];
}

In the Vagrant project, I have run vagrant plugin install vagrant-hostsupdater successfully (after configuring the above). However, when I run vagrant up, I get the following:

~/mastodon> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/focal64' version '20240809.0.0' is up to date...
==> default: Clearing any previously set network interfaces...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["hostonlyif", "create"]

Stderr: 0%...NS_ERROR_FAILURE
VBoxManage: error: Failed to create the host-only adapter
VBoxManage: error: VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: No such file or directory
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component HostNetworkInterfaceWrap, interface IHostNetworkInterface
VBoxManage: error: Context: "RTEXITCODE handleCreate(HandlerArg*)" at line 105 of file VBoxManageHostonly.cpp

What is this error and how can I fix it? I thought it might have been a missing VirtualBox component so I added virtualisation.virtualbox.host.enableExtensionPack = true; and users.extraGroups.vboxusers.members = [ "apropos" ]; to configuration.nix to no avail.

I have found a similar issue on the Arch forums, but I do not know how to adapt their solution to NixOS (in particular: I don’t know how to install vboxdrv nor do I have the vboxreload binary available).

(also: i doubt it exists, but if anyone has a nix build config for mastodon i’d love to see it… the only reason i’m trying to set this up on my nixos machine instead of my main arch machine is because i hit errors-from-hell trying to get the vagrant build system to work over there)

This fixed itself after a reboot… :person_facepalming:

I did also have to enable virtualization in the BIOS, and put the hosts Vagrant wanted in configuration.nix manually. But vagrant up has now succeeded.