Jump to content

VirtualBox: Difference between revisions

From NixOS Wiki
imported>Alizter
Add tip about changing audio driver
DoggoBit (talk | contribs)
No edit summary
 
(6 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{cleanup|reason=Too many notices; they should be refactored into natural flowing sections.}}
[https://www.virtualbox.org/ VirtualBox] is a virtualisation hypervisor. It has powerful a GUI included for managing virtual machines.
== NixOS Installation ==
== NixOS Installation ==
VirtualBox can be installed on NixOS without problems, put this snippet in your <code>configuration.nix</code>
VirtualBox can be installed on NixOS without problems, put this snippet in your <code>configuration.nix</code>
Line 14: Line 18:
</syntaxHighlight>
</syntaxHighlight>
In this case, the audio driver causes a crash. This can be fixed by switching to another driver such as PULSE.}}
In this case, the audio driver causes a crash. This can be fixed by switching to another driver such as PULSE.}}
{{Warning|Ensure that you do not put <code>virtualbox</code> into your <code>environment.systemPackages</code> when you've enabled it with <code>virtualisation.virtualbox.host.enable {{=}} true</code>. If you put <code>virtualbox</code> into your <code>environment.systemPackages</code>, 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 ==
== VirtualBox Oracle Extensions ==
{{unfree}}
{{tip/unfree}}


Oracle VirtualBox Extensions are required if you want to forward  usb2 or usb3 to your guests. The Extensions are unfree.
Oracle VirtualBox Extensions are required if you want to forward  usb2 or usb3 to your guests. The Extensions are unfree.
Line 28: Line 34:
</syntaxHighlight>
</syntaxHighlight>


{{Tip|If USB forwarding is only advanced feature used in virtualization, then consider using an open-source virtualization solution such as GNOME Boxes or Virt-Manager to avoid frequent recompilations..}}
{{Tip|If USB forwarding is only advanced feature used in virtualization, then consider using an open-source virtualization solution such as GNOME Boxes or [[Virt-manager]] to avoid frequent recompilations..}}
{{Warning|Host extensions cause frequent recompilation.}}
{{Warning|Host extensions cause frequent recompilation.}}


Line 36: Line 42:
* Also see  https://stackoverflow.com/questions/48838411/install-virtualbox-modules-from-nixos-unstable-in-configuration-nix
* Also see  https://stackoverflow.com/questions/48838411/install-virtualbox-modules-from-nixos-unstable-in-configuration-nix
* Use module from https://github.com/NixOS/nixpkgs/pull/71127 (unsafe) if you'd like to avoid recompilation.
* Use module from https://github.com/NixOS/nixpkgs/pull/71127 (unsafe) if you'd like to avoid recompilation.
* Use [[Virt-manager]] instead of VirtualBox


== VirtualBox Guest Additions ==
== VirtualBox Guest Additions ==


<syntaxHighlight lang=nix>
<syntaxhighlight lang="nix">
{
{
   virtualisation.virtualbox.guest.enable = true;
   virtualisation.virtualbox.guest.enable = true;
   virtualisation.virtualbox.guest.x11 = true;
   virtualisation.virtualbox.guest.dragAndDrop = true;
}
}
</syntaxHighlight>
</syntaxhighlight>


== See also ==
== See also ==

Latest revision as of 20:05, 5 June 2025

⚟︎
This article or section needs cleanup. Too many notices; they should be refactored into natural flowing sections. Please edit the article, paying special attention to fixing any formatting issues, inconsistencies, grammar, or phrasing. Make sure to consult the Manual of Style for guidance.

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.

🟆︎
Tip: In order to affect your NixOS system by your nix-language-specific changes you must first evaluate it:
$ nixos-rebuild switch --sudo
🟆︎
Tip: When starting a VM, you may run into NS_ERROR_FAILURE. If you check the log you might see something like
  00:00:00.616892 Audio: Initializing ALSA driver

In this case, the audio driver causes a crash. This can be fixed by switching to another driver such as PULSE.

⚠︎
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

🟆︎
Tip: This package is unfree, and will require extra steps to install. You can read more about allowing unfree software in the Nixpkgs Manual.

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;
}
🟆︎
Tip: If USB forwarding is only advanced feature used in virtualization, then consider using an open-source virtualization solution such as GNOME Boxes or Virt-manager to avoid frequent recompilations..
⚠︎
Warning: Host extensions cause frequent recompilation.

Possible solutions:

VirtualBox Guest Additions

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

See also