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 have not yet tried KVM support on Virtualbox on NixOS, but once I do, I will update this page…

Next Post
Cisco Packet Tracer 8 on NixOS
Docs