about summary refs log tree commit diff
path: root/pkgs/applications/virtualization/virtualbox/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/virtualization/virtualbox/default.nix')
-rw-r--r--pkgs/applications/virtualization/virtualbox/default.nix63
1 files changed, 35 insertions, 28 deletions
diff --git a/pkgs/applications/virtualization/virtualbox/default.nix b/pkgs/applications/virtualization/virtualbox/default.nix
index 314d8136b852c..9690ee757c0d5 100644
--- a/pkgs/applications/virtualization/virtualbox/default.nix
+++ b/pkgs/applications/virtualization/virtualbox/default.nix
@@ -5,6 +5,7 @@
 , 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
@@ -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.14";
+  virtualboxSha256 = "45860d834804a24a163c1bb264a6b1cb802a5bc7ce7e01128072f8d6a4617ca9";
+
+  kvmPatchVersion = "20240502";
+  kvmPatchHash = "sha256-KokIrrAoJutHzPg6e5YAJgDGs+nQoVjapmyn9kG5tV0=";
 
   # 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,14 +126,11 @@ 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 = "20240325";
-    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-D1ua8X5Iyw/I89PtskiGdnGr4NhdFtI93ThltiOcu8w=";
-    }))
+  ++ 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
@@ -135,10 +142,6 @@ in stdenv.mkDerivation {
   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 +162,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 +198,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 +214,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 +252,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) ''
@@ -265,6 +271,7 @@ in stdenv.mkDerivation {
 
   passthru = {
     inherit extensionPack; # for inclusion in profile to prevent gc
+    tests = nixosTests.virtualbox;
     updateScript = ./update.sh;
   };
 
@@ -280,10 +287,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";
   };
-}
+})