diff options
author | Данило Глинський (Danylo Hlynskyi) <abcz2.uprola@gmail.com> | 2016-09-01 18:54:58 +0000 |
---|---|---|
committer | Domen Kožar <domen@dev.si> | 2016-09-01 20:54:58 +0200 |
commit | 78cd9f8ebc36a387fc75ebb03317707a283f43a4 (patch) | |
tree | 6d0f0df64ccb9ed03cdc68339b04e5f3980238ca | |
parent | 8a7afae58b55bbb51dd11d610c72cdc2b4142931 (diff) |
virtualbox: add headless build (without Qt dependency) (#18026)
-rw-r--r-- | nixos/modules/virtualisation/virtualbox-host.nix | 11 | ||||
-rw-r--r-- | nixos/tests/virtualbox.nix | 11 | ||||
-rw-r--r-- | pkgs/applications/virtualization/virtualbox/default.nix | 34 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 5 |
4 files changed, 47 insertions, 14 deletions
diff --git a/nixos/modules/virtualisation/virtualbox-host.nix b/nixos/modules/virtualisation/virtualbox-host.nix index 5fb472ebfc32a..ce4abecd6762b 100644 --- a/nixos/modules/virtualisation/virtualbox-host.nix +++ b/nixos/modules/virtualisation/virtualbox-host.nix @@ -5,7 +5,7 @@ with lib; let cfg = config.virtualisation.virtualbox.host; virtualbox = config.boot.kernelPackages.virtualbox.override { - inherit (cfg) enableHardening; + inherit (cfg) enableHardening headless; }; in @@ -47,6 +47,15 @@ in </para></important> ''; }; + + headless = mkOption { + type = types.bool; + default = false; + description = '' + Use VirtualBox installation without GUI and Qt dependency. Useful to enable on servers + and when virtual machines are controlled only via SSH. + ''; + }; }; config = mkIf cfg.enable (mkMerge [{ diff --git a/nixos/tests/virtualbox.nix b/nixos/tests/virtualbox.nix index e85ff2380893e..ab4d46ab7e154 100644 --- a/nixos/tests/virtualbox.nix +++ b/nixos/tests/virtualbox.nix @@ -314,6 +314,9 @@ let test2.vmFlags = hostonlyVMFlags; test2.vmScript = dhcpScript; + + headless.virtualisation.virtualbox.headless = true; + headless.services.xserver.enable = false; }; mkVBoxTest = name: testScript: makeTest { @@ -402,6 +405,14 @@ in mapAttrs mkVBoxTest { shutdownVM_simple; ''; + headless = '' + createVM_headless; + $machine->succeed(ru("VBoxHeadless --startvm headless & disown %1")); + waitForStartup_headless; + waitForVMBoot_headless; + shutdownVM_headless; + ''; + host-usb-permissions = '' my $userUSB = removeUUIDs vbm("list usbhost"); print STDERR $userUSB; diff --git a/pkgs/applications/virtualization/virtualbox/default.nix b/pkgs/applications/virtualization/virtualbox/default.nix index 6ef014f457f91..8bcf122132e3b 100644 --- a/pkgs/applications/virtualization/virtualbox/default.nix +++ b/pkgs/applications/virtualization/virtualbox/default.nix @@ -1,5 +1,6 @@ { stdenv, fetchurl, lib, iasl, dev86, pam, libxslt, libxml2, libX11, xproto, libXext , libXcursor, libXmu, qt4, libIDL, SDL, libcap, zlib, libpng, glib, kernel, lvm2 +, libXrandr , which, alsaLib, curl, libvpx, gawk, nettools, dbus , xorriso, makeself, perl, pkgconfig, nukeReferences , javaBindings ? false, jdk ? null @@ -7,6 +8,7 @@ , enableExtensionPack ? false, requireFile ? null, patchelf ? null, fakeroot ? null , pulseSupport ? false, libpulseaudio ? null , enableHardening ? false +, headless ? false }: with stdenv.lib; @@ -67,12 +69,14 @@ in stdenv.mkDerivation { }; buildInputs = - [ iasl dev86 libxslt libxml2 xproto libX11 libXext libXcursor qt4 libIDL SDL + [ iasl dev86 libxslt libxml2 xproto libX11 libXext libXcursor libIDL libcap glib lvm2 python alsaLib curl libvpx pam xorriso makeself perl pkgconfig which libXmu nukeReferences ] ++ optional javaBindings jdk ++ optional pythonBindings python - ++ optional pulseSupport libpulseaudio; + ++ optional pulseSupport libpulseaudio + ++ optionals (headless) [ libXrandr libpng ] + ++ optionals (!headless) [ qt4 SDL ]; hardeningDisable = [ "fortify" "pic" "stackprotector" ]; @@ -129,7 +133,9 @@ in stdenv.mkDerivation { ''} LOCAL_CONFIG - ./configure --with-qt4-dir=${qt4} \ + ./configure \ + ${optionalString headless "--build-headless"} \ + ${optionalString (!headless) "--with-qt4-dir=${qt4}"} \ ${optionalString (!javaBindings) "--disable-java"} \ ${optionalString (!pythonBindings) "--disable-python"} \ ${optionalString (!pulseSupport) "--disable-pulse"} \ @@ -180,16 +186,18 @@ in stdenv.mkDerivation { EXTHELPER ''} - # Create and fix desktop item - mkdir -p $out/share/applications - sed -i -e "s|Icon=VBox|Icon=$libexec/VBox.png|" $libexec/virtualbox.desktop - ln -sfv $libexec/virtualbox.desktop $out/share/applications - # Icons - mkdir -p $out/share/icons/hicolor - for size in `ls -1 $libexec/icons`; do - mkdir -p $out/share/icons/hicolor/$size/apps - ln -s $libexec/icons/$size/*.png $out/share/icons/hicolor/$size/apps - done + ${optionalString (!headless) '' + # Create and fix desktop item + mkdir -p $out/share/applications + sed -i -e "s|Icon=VBox|Icon=$libexec/VBox.png|" $libexec/virtualbox.desktop + ln -sfv $libexec/virtualbox.desktop $out/share/applications + # Icons + mkdir -p $out/share/icons/hicolor + for size in `ls -1 $libexec/icons`; do + mkdir -p $out/share/icons/hicolor/$size/apps + ln -s $libexec/icons/$size/*.png $out/share/icons/hicolor/$size/apps + done + ''} # Get rid of a reference to linux.dev. nuke-refs $out/lib/modules/*/misc/*.ko diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7f1c4aebae35b..9c53f2208a112 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11345,6 +11345,11 @@ in enableHardening = true; }); + virtualboxHeadless = lowPrio (virtualbox.override { + enableHardening = true; + headless = true; + }); + virtualboxGuestAdditions = callPackage ../applications/virtualization/virtualbox/guest-additions { }; wireguard = callPackage ../os-specific/linux/wireguard { }; |