I am testing the nix package manager. I installed ubuntu in a virtualbox and try to install the guest additions. My ~/.nixpkgs/config.nix is

  allowUnfree = true;
  packageOverrides = pkgs_: with pkgs_; {
    all = with pkgs; buildEnv {
      name = "all";
      paths = [

However nix-env -i all tells me virtualbox-guest is a undefined variable.

Also nix-env -qaP '.*virtualbox.*' has no match, even though I know there is a virtualbox-guest.nix.


So you installed Ubuntu in a virtual machine, you installed the Nix package manager on it, and you would like VirtualBox's guest additions installed thanks to the Nix package manager.

The attribute name of the package you are looking for is linuxPackages.virtualboxGuestAdditions. Thus, you can install it by issuing:

nix-env -iA linuxPackages.virtualboxGuestAdditions -f '<nixpkgs>'

I'm not sure though if the package will actually work on Ubuntu, because it's description hints that it is a NixOS-only package:

Various add-ons which makes NixOS work better as guest OS inside VirtualBox. This add-on provides support for dynamic resizing of the X Display, shared host/guest clipboard support and guest OpenGL support.

Indeed, the Nix package manager is useful to install userspace applications on other distributions but if you also want Nix to handle system modules, you have to switch to NixOS for that (then the correct way to enable guest additions is through virtualisation.virtualbox.guest.enable option which you can set in your /etc/nixos/configuration.nix as is described in the manual).

As a side-note, what you put in ~/.nixpkgs/config.nix does not make much sense. This file is for configuring the Nix package manager itself, allowing non-free packages or overriding existing package. You won't need to override any package in your case. And you don't need either to allow non-free packages because VirtualBox's guest additions is registered as GPL.

  • To clarify: I don't want to install nixos, but use the nix package manager with ubuntu. I would to test this in a vm. So everything I am talking about is within the virtual-box. – Manuel Schmidt Mar 14 '17 at 8:25
  • @ManuelSchmidt Thanks for the clarification. See my updated answer. – Zimm i48 Mar 14 '17 at 8:51
  • @ManuelSchmidt I'm wondering if it worked for you? – BAR Jan 9 '18 at 9:53
  • When running the command, I get an error of attribute 'nixpkgs' in selection path 'nixpkgs.linuxPackages.virtualboxGuestAdditions' not found. – Chris Stryczynski May 6 '18 at 10:49
  • 1
    @ChrisStryczynski I fixed the answer to use a more generic form that should avoid this error. – Zimm i48 Aug 2 '18 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.