diff options
Diffstat (limited to 'pkgs/applications/virtualization/virtualbox/default.nix')
-rw-r--r-- | pkgs/applications/virtualization/virtualbox/default.nix | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/pkgs/applications/virtualization/virtualbox/default.nix b/pkgs/applications/virtualization/virtualbox/default.nix index 3b0783a1509b5..dd9b99f7f9bc9 100644 --- a/pkgs/applications/virtualization/virtualbox/default.nix +++ b/pkgs/applications/virtualization/virtualbox/default.nix @@ -4,11 +4,12 @@ , qttools, qtsvg, qtwayland, pkg-config, which, docbook_xsl, docbook_xml_dtd_43 , alsa-lib, curl, libvpx, nettools, dbus, substituteAll, gsoap, zlib, xz , yasm, glslang -, linuxPackages +, nixosTests # If open-watcom-bin is not passed, VirtualBox will fall back to use # the shipped alternative sources (assembly). , open-watcom-bin , makeself, perl +, vulkan-loader , javaBindings ? true, jdk # Almost doesn't affect closure size , pythonBindings ? false, python3 , extensionPack ? null, fakeroot @@ -24,26 +25,35 @@ # See https://github.com/cyberus-technology/virtualbox-kvm/issues/12 assert enableKvm -> !enableHardening; -with lib; +# The web services use Java infrastructure. +assert enableWebService -> javaBindings; let buildType = "release"; # Use maintainers/scripts/update.nix to update the version and all related hashes or # change the hashes in extpack.nix and guest-additions/default.nix as well manually. - version = "7.0.14"; + virtualboxVersion = "7.0.18"; + virtualboxSha256 = "d999513533631674a024762668de999411d8197060c51e68c5faf0a2c0eea1a5"; + + kvmPatchVersion = "20240515"; + kvmPatchHash = "sha256-Kh/tlPScdf7CbEEpL54iqMpeUIdmnJL2r/mxnlEzLd0="; # The KVM build is not compatible to VirtualBox's kernel modules. So don't export # modsrc at all. withModsrc = !enableKvm; virtualboxGuestAdditionsIso = callPackage guest-additions-iso/default.nix { }; -in stdenv.mkDerivation { + + inherit (lib) optional optionals optionalString getDev getLib; +in stdenv.mkDerivation (finalAttrs: { pname = "virtualbox"; - inherit version; + version = finalAttrs.virtualboxVersion; + + inherit buildType virtualboxVersion virtualboxSha256 kvmPatchVersion kvmPatchHash virtualboxGuestAdditionsIso; src = fetchurl { - url = "https://download.virtualbox.org/virtualbox/${version}/VirtualBox-${version}.tar.bz2"; - sha256 = "45860d834804a24a163c1bb264a6b1cb802a5bc7ce7e01128072f8d6a4617ca9"; + url = "https://download.virtualbox.org/virtualbox/${finalAttrs.virtualboxVersion}/VirtualBox-${finalAttrs.virtualboxVersion}.tar.bz2"; + sha256 = finalAttrs.virtualboxSha256; }; outputs = [ "out" ] ++ optional withModsrc "modsrc"; @@ -70,7 +80,7 @@ in stdenv.mkDerivation { prePatch = '' set -x sed -e 's@MKISOFS --version@MKISOFS -version@' \ - -e 's@PYTHONDIR=.*@PYTHONDIR=${lib.optionalString pythonBindings python3}@' \ + -e 's@PYTHONDIR=.*@PYTHONDIR=${optionalString pythonBindings python3}@' \ -e 's@CXX_FLAGS="\(.*\)"@CXX_FLAGS="-std=c++11 \1"@' \ ${optionalString (!headless) '' -e 's@TOOLQT5BIN=.*@TOOLQT5BIN="${getDev qtbase}/bin"@' \ @@ -99,7 +109,7 @@ in stdenv.mkDerivation { # No update patch disables check for update function # https://bugs.launchpad.net/ubuntu/+source/virtualbox-ose/+bug/272212 (fetchpatch { - url = "https://salsa.debian.org/pkg-virtualbox-team/virtualbox/-/raw/debian/${version}-dfsg-1/debian/patches/16-no-update.patch"; + url = "https://salsa.debian.org/pkg-virtualbox-team/virtualbox/-/raw/debian/7.0.14-dfsg-1/debian/patches/16-no-update.patch"; hash = "sha256-UJHpuB6QB/BbxJorlqZXUF12lgq8gbLMRHRMsbyqRpY="; })] ++ [ ./extra_symbols.patch ] @@ -116,29 +126,20 @@ in stdenv.mkDerivation { }) # While the KVM patch should not break any other behavior if --with-kvm is not specified, # we don't take any chances and only apply it if people actually want to use KVM support. - ++ optional enableKvm (fetchpatch - (let - patchVersion = "20240502"; - in { - name = "virtualbox-${version}-kvm-dev-${patchVersion}.patch"; - url = "https://github.com/cyberus-technology/virtualbox-kvm/releases/download/dev-${patchVersion}/kvm-backend-${version}-dev-${patchVersion}.patch"; - hash = "sha256-KokIrrAoJutHzPg6e5YAJgDGs+nQoVjapmyn9kG5tV0="; - })) + ++ optional enableKvm (fetchpatch { + name = "virtualbox-${finalAttrs.virtualboxVersion}-kvm-dev-${finalAttrs.kvmPatchVersion}.patch"; + url = "https://github.com/cyberus-technology/virtualbox-kvm/releases/download/dev-${finalAttrs.kvmPatchVersion}/kvm-backend-${finalAttrs.virtualboxVersion}-dev-${finalAttrs.kvmPatchVersion}.patch"; + hash = finalAttrs.kvmPatchHash; + }) ++ [ ./qt-dependency-paths.patch # https://github.com/NixOS/nixpkgs/issues/123851 ./fix-audio-driver-loading.patch - ./libxml-2.12.patch - ./gcc-13.patch ]; postPatch = '' sed -i -e 's|/sbin/ifconfig|${nettools}/bin/ifconfig|' \ src/VBox/HostDrivers/adpctl/VBoxNetAdpCtl.cpp - '' + optionalString headless '' - # Fix compile error in version 6.1.6 - substituteInPlace src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11-stubs.cpp \ - --replace PSHCLFORMATDATA PSHCLFORMATS ''; # first line: ugly hack, and it isn't yet clear why it's a problem @@ -159,6 +160,9 @@ in stdenv.mkDerivation { VBOX_WITH_RUNPATH := $out/libexec/virtualbox VBOX_PATH_APP_PRIVATE := $out/share/virtualbox VBOX_PATH_APP_DOCS := $out/doc + + VBOX_WITH_UPDATE_AGENT := + ${optionalString javaBindings '' VBOX_JAVA_HOME := ${jdk} ''} @@ -192,14 +196,14 @@ in stdenv.mkDerivation { -i AutoConfig.kmk sed -e 's@arch/x86/@@' \ -i Config.kmk - substituteInPlace Config.kmk --replace "VBOX_WITH_TESTCASES = 1" "#" + substituteInPlace Config.kmk --replace-fail "VBOX_WITH_TESTCASES = 1" "#" ''; enableParallelBuilding = true; buildPhase = '' source env.sh - kmk -j $NIX_BUILD_CORES BUILD_TYPE="${buildType}" + kmk -j $NIX_BUILD_CORES BUILD_TYPE="${finalAttrs.buildType}" ''; installPhase = '' @@ -208,7 +212,7 @@ in stdenv.mkDerivation { # Install VirtualBox files mkdir -p "$libexec" - find out/linux.*/${buildType}/bin -mindepth 1 -maxdepth 1 \ + find out/linux.*/${finalAttrs.buildType}/bin -mindepth 1 -maxdepth 1 \ -name src -o -exec cp -avt "$libexec" {} + mkdir -p $out/bin @@ -246,12 +250,12 @@ in stdenv.mkDerivation { ''} ${optionalString withModsrc '' - cp -rv out/linux.*/${buildType}/bin/src "$modsrc" + cp -rv out/linux.*/${finalAttrs.buildType}/bin/src "$modsrc" ''} mkdir -p "$out/share/virtualbox" cp -rv src/VBox/Main/UnattendedTemplates "$out/share/virtualbox" - ln -s "${virtualboxGuestAdditionsIso}/VBoxGuestAdditions_${version}.iso" "$out/share/virtualbox/VBoxGuestAdditions.iso" + ln -s "${finalAttrs.virtualboxGuestAdditionsIso}" "$out/share/virtualbox/VBoxGuestAdditions.iso" ''; preFixup = optionalString (!headless) '' @@ -260,11 +264,13 @@ in stdenv.mkDerivation { # If hardening is disabled, wrap the VirtualBoxVM binary instead of patching # the source code (see postPatch). + optionalString (!headless && !enableHardening) '' - wrapQtApp $out/libexec/virtualbox/VirtualBoxVM + wrapQtApp $out/libexec/virtualbox/VirtualBoxVM \ + --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ vulkan-loader ]}" ''; passthru = { inherit extensionPack; # for inclusion in profile to prevent gc + tests = nixosTests.virtualbox; updateScript = ./update.sh; }; @@ -280,10 +286,10 @@ in stdenv.mkDerivation { fromSource binaryNativeCode ]; - license = licenses.gpl2; + license = lib.licenses.gpl2; homepage = "https://www.virtualbox.org/"; - maintainers = with maintainers; [ sander friedrichaltheide blitz ]; + maintainers = with lib.maintainers; [ sander friedrichaltheide blitz ]; platforms = [ "x86_64-linux" ]; mainProgram = "VirtualBox"; }; -} +}) |