virtualbox: add headless build (without Qt dependency) (#18026)
This commit is contained in:
parent
8a7afae58b
commit
78cd9f8ebc
|
@ -5,7 +5,7 @@ with lib;
|
||||||
let
|
let
|
||||||
cfg = config.virtualisation.virtualbox.host;
|
cfg = config.virtualisation.virtualbox.host;
|
||||||
virtualbox = config.boot.kernelPackages.virtualbox.override {
|
virtualbox = config.boot.kernelPackages.virtualbox.override {
|
||||||
inherit (cfg) enableHardening;
|
inherit (cfg) enableHardening headless;
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
|
@ -47,6 +47,15 @@ in
|
||||||
</para></important>
|
</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 [{
|
config = mkIf cfg.enable (mkMerge [{
|
||||||
|
|
|
@ -314,6 +314,9 @@ let
|
||||||
|
|
||||||
test2.vmFlags = hostonlyVMFlags;
|
test2.vmFlags = hostonlyVMFlags;
|
||||||
test2.vmScript = dhcpScript;
|
test2.vmScript = dhcpScript;
|
||||||
|
|
||||||
|
headless.virtualisation.virtualbox.headless = true;
|
||||||
|
headless.services.xserver.enable = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
mkVBoxTest = name: testScript: makeTest {
|
mkVBoxTest = name: testScript: makeTest {
|
||||||
|
@ -402,6 +405,14 @@ in mapAttrs mkVBoxTest {
|
||||||
shutdownVM_simple;
|
shutdownVM_simple;
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
headless = ''
|
||||||
|
createVM_headless;
|
||||||
|
$machine->succeed(ru("VBoxHeadless --startvm headless & disown %1"));
|
||||||
|
waitForStartup_headless;
|
||||||
|
waitForVMBoot_headless;
|
||||||
|
shutdownVM_headless;
|
||||||
|
'';
|
||||||
|
|
||||||
host-usb-permissions = ''
|
host-usb-permissions = ''
|
||||||
my $userUSB = removeUUIDs vbm("list usbhost");
|
my $userUSB = removeUUIDs vbm("list usbhost");
|
||||||
print STDERR $userUSB;
|
print STDERR $userUSB;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{ stdenv, fetchurl, lib, iasl, dev86, pam, libxslt, libxml2, libX11, xproto, libXext
|
{ stdenv, fetchurl, lib, iasl, dev86, pam, libxslt, libxml2, libX11, xproto, libXext
|
||||||
, libXcursor, libXmu, qt4, libIDL, SDL, libcap, zlib, libpng, glib, kernel, lvm2
|
, libXcursor, libXmu, qt4, libIDL, SDL, libcap, zlib, libpng, glib, kernel, lvm2
|
||||||
|
, libXrandr
|
||||||
, which, alsaLib, curl, libvpx, gawk, nettools, dbus
|
, which, alsaLib, curl, libvpx, gawk, nettools, dbus
|
||||||
, xorriso, makeself, perl, pkgconfig, nukeReferences
|
, xorriso, makeself, perl, pkgconfig, nukeReferences
|
||||||
, javaBindings ? false, jdk ? null
|
, javaBindings ? false, jdk ? null
|
||||||
|
@ -7,6 +8,7 @@
|
||||||
, enableExtensionPack ? false, requireFile ? null, patchelf ? null, fakeroot ? null
|
, enableExtensionPack ? false, requireFile ? null, patchelf ? null, fakeroot ? null
|
||||||
, pulseSupport ? false, libpulseaudio ? null
|
, pulseSupport ? false, libpulseaudio ? null
|
||||||
, enableHardening ? false
|
, enableHardening ? false
|
||||||
|
, headless ? false
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with stdenv.lib;
|
with stdenv.lib;
|
||||||
|
@ -67,12 +69,14 @@ in stdenv.mkDerivation {
|
||||||
};
|
};
|
||||||
|
|
||||||
buildInputs =
|
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
|
libcap glib lvm2 python alsaLib curl libvpx pam xorriso makeself perl
|
||||||
pkgconfig which libXmu nukeReferences ]
|
pkgconfig which libXmu nukeReferences ]
|
||||||
++ optional javaBindings jdk
|
++ optional javaBindings jdk
|
||||||
++ optional pythonBindings python
|
++ optional pythonBindings python
|
||||||
++ optional pulseSupport libpulseaudio;
|
++ optional pulseSupport libpulseaudio
|
||||||
|
++ optionals (headless) [ libXrandr libpng ]
|
||||||
|
++ optionals (!headless) [ qt4 SDL ];
|
||||||
|
|
||||||
hardeningDisable = [ "fortify" "pic" "stackprotector" ];
|
hardeningDisable = [ "fortify" "pic" "stackprotector" ];
|
||||||
|
|
||||||
|
@ -129,7 +133,9 @@ in stdenv.mkDerivation {
|
||||||
''}
|
''}
|
||||||
LOCAL_CONFIG
|
LOCAL_CONFIG
|
||||||
|
|
||||||
./configure --with-qt4-dir=${qt4} \
|
./configure \
|
||||||
|
${optionalString headless "--build-headless"} \
|
||||||
|
${optionalString (!headless) "--with-qt4-dir=${qt4}"} \
|
||||||
${optionalString (!javaBindings) "--disable-java"} \
|
${optionalString (!javaBindings) "--disable-java"} \
|
||||||
${optionalString (!pythonBindings) "--disable-python"} \
|
${optionalString (!pythonBindings) "--disable-python"} \
|
||||||
${optionalString (!pulseSupport) "--disable-pulse"} \
|
${optionalString (!pulseSupport) "--disable-pulse"} \
|
||||||
|
@ -180,16 +186,18 @@ in stdenv.mkDerivation {
|
||||||
EXTHELPER
|
EXTHELPER
|
||||||
''}
|
''}
|
||||||
|
|
||||||
# Create and fix desktop item
|
${optionalString (!headless) ''
|
||||||
mkdir -p $out/share/applications
|
# Create and fix desktop item
|
||||||
sed -i -e "s|Icon=VBox|Icon=$libexec/VBox.png|" $libexec/virtualbox.desktop
|
mkdir -p $out/share/applications
|
||||||
ln -sfv $libexec/virtualbox.desktop $out/share/applications
|
sed -i -e "s|Icon=VBox|Icon=$libexec/VBox.png|" $libexec/virtualbox.desktop
|
||||||
# Icons
|
ln -sfv $libexec/virtualbox.desktop $out/share/applications
|
||||||
mkdir -p $out/share/icons/hicolor
|
# Icons
|
||||||
for size in `ls -1 $libexec/icons`; do
|
mkdir -p $out/share/icons/hicolor
|
||||||
mkdir -p $out/share/icons/hicolor/$size/apps
|
for size in `ls -1 $libexec/icons`; do
|
||||||
ln -s $libexec/icons/$size/*.png $out/share/icons/hicolor/$size/apps
|
mkdir -p $out/share/icons/hicolor/$size/apps
|
||||||
done
|
ln -s $libexec/icons/$size/*.png $out/share/icons/hicolor/$size/apps
|
||||||
|
done
|
||||||
|
''}
|
||||||
|
|
||||||
# Get rid of a reference to linux.dev.
|
# Get rid of a reference to linux.dev.
|
||||||
nuke-refs $out/lib/modules/*/misc/*.ko
|
nuke-refs $out/lib/modules/*/misc/*.ko
|
||||||
|
|
|
@ -11345,6 +11345,11 @@ in
|
||||||
enableHardening = true;
|
enableHardening = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
virtualboxHeadless = lowPrio (virtualbox.override {
|
||||||
|
enableHardening = true;
|
||||||
|
headless = true;
|
||||||
|
});
|
||||||
|
|
||||||
virtualboxGuestAdditions = callPackage ../applications/virtualization/virtualbox/guest-additions { };
|
virtualboxGuestAdditions = callPackage ../applications/virtualization/virtualbox/guest-additions { };
|
||||||
|
|
||||||
wireguard = callPackage ../os-specific/linux/wireguard { };
|
wireguard = callPackage ../os-specific/linux/wireguard { };
|
||||||
|
|
Loading…
Reference in New Issue