VirtualBox

From NixOS Wiki
Revision as of 09:29, 8 August 2024 by Martin von Wittich (talk | contribs) (Added a warning not to include virtualbox in environment.systemPackages)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

VirtualBox is a virtualisation hypervisor. It has powerful a GUI included for managing virtual machines.

NixOS Installation

VirtualBox can be installed on NixOS without problems, put this snippet in your configuration.nix

{
   virtualisation.virtualbox.host.enable = true;
   users.extraGroups.vboxusers.members = [ "user-with-access-to-virtualbox" ];
}

Adding users to the group vboxusers allows them to use the virtualbox functionality.

Warning: Ensure that you do not put virtualbox into your environment.systemPackages when you've enabled it with virtualisation.virtualbox.host.enable = true. If you put virtualbox into your environment.systemPackages, VirtualBox won't be able to access it's driver, and attempting to start a VM will fail with the error NS_ERROR_FAILURE (0X80004005).

VirtualBox Oracle Extensions

Note: This package is unfree and requires extra steps to install.

Oracle VirtualBox Extensions are required if you want to forward usb2 or usb3 to your guests. The Extensions are unfree.

{
   nixpkgs.config.allowUnfree = true;
   virtualisation.virtualbox.host.enable = true;
   virtualisation.virtualbox.host.enableExtensionPack = true;
}
Warning: Host extensions cause frequent recompilation.

Possible solutions:

VirtualBox Guest Additions

{
  virtualisation.virtualbox.guest.enable = true;
  virtualisation.virtualbox.guest.dragAndDrop = true;
}

See also