Skip to content

Commit

Permalink
Merge pull request #103127 from Magicloud/vboxwebsrv
Browse files Browse the repository at this point in the history
  • Loading branch information
mkg20001 committed Nov 7, 2021
2 parents 83c93c8 + 40c83d1 commit c69c653
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
10 changes: 9 additions & 1 deletion nixos/modules/virtualisation/virtualbox-host.nix
Expand Up @@ -6,7 +6,7 @@ let
cfg = config.virtualisation.virtualbox.host;

virtualbox = cfg.package.override {
inherit (cfg) enableHardening headless;
inherit (cfg) enableHardening headless enableWebService;
extensionPack = if cfg.enableExtensionPack then pkgs.virtualboxExtpack else null;
};

Expand Down Expand Up @@ -80,6 +80,14 @@ in
and when virtual machines are controlled only via SSH.
'';
};

enableWebService = mkOption {
type = types.bool;
default = false;
description = ''
Build VirtualBox web service tool (vboxwebsrv) to allow managing VMs via other webpage frontend tools. Useful for headless servers.
'';
};
};

config = mkIf cfg.enable (mkMerge [{
Expand Down
13 changes: 10 additions & 3 deletions pkgs/applications/virtualization/virtualbox/default.nix
Expand Up @@ -2,7 +2,7 @@
, libX11, xorgproto, libXext, libXcursor, libXmu, libIDL, SDL, libcap, libGL
, libpng, glib, lvm2, libXrandr, libXinerama, libopus, qtbase, qtx11extras
, qttools, qtsvg, qtwayland, pkg-config, which, docbook_xsl, docbook_xml_dtd_43
, alsa-lib, curl, libvpx, nettools, dbus, substituteAll
, alsa-lib, curl, libvpx, nettools, dbus, substituteAll, gsoap, zlib
# If open-watcom-bin is not passed, VirtualBox will fall back to use
# the shipped alternative sources (assembly).
, open-watcom-bin ? null
Expand All @@ -14,6 +14,7 @@
, enableHardening ? false
, headless ? false
, enable32bitGuests ? true
, enableWebService ? false
}:

with lib;
Expand Down Expand Up @@ -49,7 +50,8 @@ in stdenv.mkDerivation {
++ optional pythonBindings python # Python is needed even when not building bindings
++ optional pulseSupport libpulseaudio
++ optionals (headless) [ libXrandr libGL ]
++ optionals (!headless) [ qtbase qtx11extras libXinerama SDL ];
++ optionals (!headless) [ qtbase qtx11extras libXinerama SDL ]
++ optionals (enableWebService) [ gsoap zlib ];

hardeningDisable = [ "format" "fortify" "pic" "stackprotector" ];

Expand Down Expand Up @@ -133,6 +135,10 @@ in stdenv.mkDerivation {
PATH_QT5_X11_EXTRAS_INC := ${getDev qtx11extras}/include
TOOL_QT5_LRC := ${getDev qttools}/bin/lrelease
''}
${optionalString (enableWebService) ''
# fix gsoap missing zlib include and produce errors with --as-needed
VBOX_GSOAP_CXX_LIBS := gsoapssl++ z
''}
LOCAL_CONFIG
./configure \
Expand All @@ -142,6 +148,7 @@ in stdenv.mkDerivation {
${optionalString (!pulseSupport) "--disable-pulse"} \
${optionalString (!enableHardening) "--disable-hardening"} \
${optionalString (!enable32bitGuests) "--disable-vmmraw"} \
${optionalString (enableWebService) "--enable-webservice"} \
${optionalString (open-watcom-bin != null) "--with-ow-dir=${open-watcom-bin}"} \
--disable-kmods
sed -e 's@PKG_CONFIG_PATH=.*@PKG_CONFIG_PATH=${libIDL}/lib/pkgconfig:${glib.dev}/lib/pkgconfig ${libIDL}/bin/libIDL-config-2@' \
Expand All @@ -168,7 +175,7 @@ in stdenv.mkDerivation {
-name src -o -exec cp -avt "$libexec" {} +
mkdir -p $out/bin
for file in ${optionalString (!headless) "VirtualBox VBoxSDL rdesktop-vrdp"} VBoxManage VBoxBalloonCtrl VBoxHeadless; do
for file in ${optionalString (!headless) "VirtualBox VBoxSDL rdesktop-vrdp"} ${optionalString (enableWebService) "vboxwebsrv"} VBoxManage VBoxBalloonCtrl VBoxHeadless; do
echo "Linking $file to /bin"
test -x "$libexec/$file"
ln -s "$libexec/$file" $out/bin/$file
Expand Down

0 comments on commit c69c653

Please sign in to comment.