@@ -1,8 +1,8 @@
11{ stdenv, fetchurl, lib, iasl, dev86, pam, libxslt, libxml2, libX11, xproto, libXext
2−, libXcursor, libXmu, qt4, libIDL, SDL, libcap, zlib, libpng, glib, kernel, lvm2
3−, libXrandr
2+, libXcursor, libXmu, qt5, libIDL, SDL, libcap, zlib, libpng, glib, lvm2
3+, libXrandr, libXinerama
44, which, alsaLib, curl, libvpx, gawk, nettools, dbus
5−, xorriso, makeself, perl, pkgconfig, nukeReferences
5+, xorriso, makeself, perl, pkgconfig
66, javaBindings ? false, jdk ? null
77, pythonBindings ? false, python ? null
88, enableExtensionPack ? false, requireFile ? null, patchelf ? null, fakeroot ? null
@@ -16,37 +16,12 @@ with stdenv.lib;
1616let
1717 buildType = "release";
1818
19− # When changing this, update ./guest-additions and the extpack
20− # revision/hash as well. See
21− # http://download.virtualbox.org/virtualbox/${version}/SHA256SUMS
22− # for hashes.
23− version = "5.0.26";
24−
25− forEachModule = action: ''
26− for mod in \
27− out/linux.*/${buildType}/bin/src/vboxdrv \
28− out/linux.*/${buildType}/bin/src/vboxpci \
29− out/linux.*/${buildType}/bin/src/vboxnetadp \
30− out/linux.*/${buildType}/bin/src/vboxnetflt
31− do
32− if [ "x$(basename "$mod")" != xvboxdrv -a ! -e "$mod/Module.symvers" ]
33− then
34− cp -v out/linux.*/${buildType}/bin/src/vboxdrv/Module.symvers \
35− "$mod/Module.symvers"
36− fi
37− INSTALL_MOD_PATH="$out" INSTALL_MOD_DIR=misc \
38− make -j $NIX_BUILD_CORES -C "$MODULES_BUILD_DIR" DEPMOD=/do_not_use_depmod \
39− "M=\$(PWD)/$mod" BUILD_TYPE="${buildType}" ${action}
40− done
41− '';
19+ inherit (importJSON ./upstream-info.json) version extpackRev extpack main;
4220
4321 # See https://github.com/NixOS/nixpkgs/issues/672 for details
44− extpackRevision = "108824";
4522 extensionPack = requireFile rec {
46− name = "Oracle_VM_VirtualBox_Extension_Pack-${version}-${extpackRevision}.vbox-extpack";
47− # IMPORTANT: Hash must be base16 encoded because it's used as an input to
48− # VBoxExtPackHelperApp!
49− sha256 = "2f2302c7ba3d00a1258fe8e7767a6eb08dccdc3c31f6e3eeb74063c2c268b104";
23+ name = "Oracle_VM_VirtualBox_Extension_Pack-${version}-${extpackRev}.vbox-extpack";
24+ sha256 = extpack;
5025 message = ''
5126 In order to use the extension pack, you need to comply with the VirtualBox Personal Use
5227 and Evaluation License (PUEL) available at:
@@ -61,35 +36,36 @@ let
6136 };
6237
6338in stdenv.mkDerivation {
64− name = "virtualbox-${version}-${kernel.version}";
39+ name = "virtualbox-${version}";
6540
6641 src = fetchurl {
6742 url = "http://download.virtualbox.org/virtualbox/${version}/VirtualBox-${version}.tar.bz2";
68− sha256 = "78dec1369d2c8feefea3c682d95e76c0e99414c56626388035cf4061d4dad62e";
43+ sha256 = main;
6944 };
7045
46+ outputs = [ "out" "modsrc" ];
47+
7148 buildInputs =
7249 [ iasl dev86 libxslt libxml2 xproto libX11 libXext libXcursor libIDL
7350 libcap glib lvm2 python alsaLib curl libvpx pam xorriso makeself perl
74− pkgconfig which libXmu nukeReferences ]
51+ pkgconfig which libXmu libpng ]
7552 ++ optional javaBindings jdk
7653 ++ optional pythonBindings python
7754 ++ optional pulseSupport libpulseaudio
78− ++ optionals (headless) [ libXrandr libpng ]
79− ++ optionals (!headless) [ qt4 SDL ];
55+ ++ optionals (headless) [ libXrandr ]
56+ ++ optionals (!headless) [ qt5.qtbase qt5.qtx11extras libXinerama SDL ];
8057
8158 hardeningDisable = [ "fortify" "pic" "stackprotector" ];
8259
8360 prePatch = ''
8461 set -x
85− MODULES_BUILD_DIR=`echo ${kernel.dev}/lib/modules/*/build`
86− sed -e 's@/lib/modules/`uname -r`/build@'$MODULES_BUILD_DIR@ \
87− -e 's@MKISOFS --version@MKISOFS -version@' \
62+ sed -e 's@MKISOFS --version@MKISOFS -version@' \
8863 -e 's@PYTHONDIR=.*@PYTHONDIR=${if pythonBindings then python else ""}@' \
89− -i configure
64+ ${optionalString (!headless) ''
65+ -e 's@TOOLQT5BIN=.*@TOOLQT5BIN="${getDev qt5.qtbase}/bin"@' \
66+ ''} -i configure
9067 ls kBuild/bin/linux.x86/k* tools/linux.x86/bin/* | xargs -n 1 patchelf --set-interpreter ${stdenv.glibc.out}/lib/ld-linux.so.2
9168 ls kBuild/bin/linux.amd64/k* tools/linux.amd64/bin/* | xargs -n 1 patchelf --set-interpreter ${stdenv.glibc.out}/lib/ld-linux-x86-64.so.2
92− find . -type f -iname '*makefile*' -exec sed -i -e 's/depmod -a/:/g' {} +
9369 sed -i -e '
9470 s@"libdbus-1\.so\.3"@"${dbus.lib}/lib/libdbus-1.so.3"@g
9571 s@"libasound\.so\.2"@"${alsaLib.out}/lib/libasound.so.2"@g
@@ -103,11 +79,12 @@ in stdenv.mkDerivation {
10379 set +x
10480 '';
10581
106− patches = optional enableHardening ./hardened.patch;
82+ patches = optional enableHardening ./hardened.patch
83+ ++ [ ./libressl.patch ./qtx11extras.patch ];
10784
10885 postPatch = ''
10986 sed -i -e 's|/sbin/ifconfig|${nettools}/bin/ifconfig|' \
110− src/apps/adpctl/VBoxNetAdpCtl.cpp
87+ src/VBox/HostDrivers/adpctl/VBoxNetAdpCtl.cpp
11188 '';
11289
11390 # first line: ugly hack, and it isn't yet clear why it's a problem
@@ -131,11 +108,15 @@ in stdenv.mkDerivation {
131108 ${optionalString javaBindings ''
132109 VBOX_JAVA_HOME := ${jdk}
133110 ''}
111+ ${optionalString (!headless) ''
112+ PATH_QT5_X11_EXTRAS_LIB := ${getLib qt5.qtx11extras}/lib
113+ PATH_QT5_X11_EXTRAS_INC := ${getDev qt5.qtx11extras}/include
114+ TOOL_QT5_LRC := ${getDev qt5.qttools}/bin/lrelease
115+ ''}
134116 LOCAL_CONFIG
135117
136118 ./configure \
137119 ${optionalString headless "--build-headless"} \
138− ${optionalString (!headless) "--with-qt4-dir=${qt4}"} \
139120 ${optionalString (!javaBindings) "--disable-java"} \
140121 ${optionalString (!pythonBindings) "--disable-python"} \
141122 ${optionalString (!pulseSupport) "--disable-pulse"} \
@@ -153,7 +134,6 @@ in stdenv.mkDerivation {
153134 buildPhase = ''
154135 source env.sh
155136 kmk -j $NIX_BUILD_CORES BUILD_TYPE="${buildType}"
156− ${forEachModule "modules"}
157137 '';
158138
159139 installPhase = ''
@@ -165,9 +145,6 @@ in stdenv.mkDerivation {
165145 find out/linux.*/${buildType}/bin -mindepth 1 -maxdepth 1 \
166146 -name src -o -exec cp -avt "$libexec" {} +
167147
168− # Install kernel modules
169− ${forEachModule "modules_install"}
170−
171148 # Create wrapper script
172149 mkdir -p $out/bin
173150 for file in VirtualBox VBoxManage VBoxSDL VBoxBalloonCtrl VBoxBFE VBoxHeadless; do
@@ -199,8 +176,7 @@ in stdenv.mkDerivation {
199176 done
200177 ''}
201178
202− # Get rid of a reference to linux.dev.
203− nuke-refs $out/lib/modules/*/misc/*.ko
179+ cp -rv out/linux.*/${buildType}/bin/src "$modsrc"
204180 '';
205181
206182 passthru = { inherit version; /* for guest additions */ };