diff --git a/nixos/modules/virtualisation/virtualbox-host.nix b/nixos/modules/virtualisation/virtualbox-host.nix index 6c742ad371cdb3..2acf54aae2ef66 100644 --- a/nixos/modules/virtualisation/virtualbox-host.nix +++ b/nixos/modules/virtualisation/virtualbox-host.nix @@ -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; }; @@ -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 [{ diff --git a/pkgs/applications/virtualization/virtualbox/default.nix b/pkgs/applications/virtualization/virtualbox/default.nix index 98c7f80df8ad5f..0dcebb71cc5f20 100644 --- a/pkgs/applications/virtualization/virtualbox/default.nix +++ b/pkgs/applications/virtualization/virtualbox/default.nix @@ -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 @@ -14,6 +14,7 @@ , enableHardening ? false , headless ? false , enable32bitGuests ? true +, enableWebService ? false }: with lib; @@ -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" ]; @@ -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 \ @@ -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@' \ @@ -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