Simple Virtualbox Setup on NixOS

Posted: 2025 Mar 17

TLDR

Two ways: importing a module to your flake (if you are using flakes for system configuration) OR just adding the same lines to configuration.nix

{ config, lib, pkgs, ... }: {
  virtualisation.virtualbox.host = {
    enable = true;
    enableExtensionPack = true;
    addNetworkInterface = true;
  };
}

Problems…

DO NOT add virtualbox to your environment.systemPackages. I spent about half an hour building my system after changing my config AND making sure I didn’t add virtualbox to my environment.systemPackages only to find it there after checking for every other problem highlighted in the forums. It might feel stupid, but just run

grep virtualbox /etc/nixos/configuration.nix 

and you will feel a hundred times less stupid if you don’t waste an hour of your life first building your system, searching for the error, finding it and then building your system again.

my face when in this moment

KVM..?

I am currently working on VirtualBox version 7.1.10 and kernel version 6.12 and when I try to start a Windows 11 VM, I get an error that VirtualBox cannot operate in VMX root mode (or something similar with KVM enabled). Adding

boot.kernelParams = [ "kvm.enable_virt_at_load=0" ];

to your configuration.nix seems to solve the issue as highlighted in this GitHub issue.

Next Post
Cisco Packet Tracer 8 on NixOS
Docs