1 { stdenv, kernel, fetchurl, lib, pam, libxslt
2 , libXext, libXcursor, libXmu
3 , glib, libXrandr, dbus, xz
4 , pkg-config, which, xorg
5 , yasm, patchelf, makeself
6 , linuxHeaders, openssl}:
11 in stdenv.mkDerivation (finalAttrs: {
12 pname = "VirtualBox-GuestAdditions-builder-${kernel.version}";
16 url = "https://download.virtualbox.org/virtualbox/${finalAttrs.version}/VirtualBox-${finalAttrs.version}.tar.bz2";
17 sha256 = "5cf5979bef66ebab3fcd495796b215a940e8a07c469d4bc56d064de44222dd02";
20 env.NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration";
22 nativeBuildInputs = [ patchelf pkg-config which yasm makeself xorg.xorgserver openssl linuxHeaders xz ] ++ kernel.moduleBuildDependencies;
23 buildInputs = [ dbus libxslt libXext libXcursor pam libXmu libXrandr ];
25 KERN_DIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
26 KERN_INCL = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/source/include";
29 rm -r src/VBox/Additions/x11/x11include/
30 rm -r src/VBox/Additions/3D/mesa/mesa-*/
31 rm -r src/libs/openssl-*/
32 rm -r src/libs/curl-*/
33 rm -r src/libs/libpng-*/
34 rm -r src/libs/libxml2-*/
35 rm -r src/libs/liblzma-*/
40 ## https://www.virtualbox.org/changeset/100258/vbox
41 ./no-legacy-xorg.patch
46 sed -e 's@MKISOFS --version@MKISOFS -version@' \
47 -e 's@CXX_FLAGS="\(.*\)"@CXX_FLAGS="-std=c++17 \1"@' \
49 ls kBuild/bin/linux.x86/k* tools/linux.x86/bin/* | xargs -n 1 patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux.so.2
50 ls kBuild/bin/linux.amd64/k* tools/linux.amd64/bin/* | xargs -n 1 patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2
52 substituteInPlace ./include/VBox/dbus-calls.h --replace-fail libdbus-1.so.3 ${dbus.lib}/lib/libdbus-1.so.3
54 substituteInPlace ./src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibDrmClient.cpp --replace-fail /usr/bin/VBoxDRMClient /run/current-system/sw/bin/VBoxDRMClient
55 substituteInPlace ./src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibDrmClient.cpp --replace-fail /usr/bin/VBoxClient /run/current-system/sw/bin/VBoxClient
56 substituteInPlace ./src/VBox/Additions/x11/VBoxClient/display.cpp --replace-fail /usr/X11/bin/xrandr ${xorg.xrandr}/bin/xrandr
57 substituteInPlace ./src/VBox/Additions/x11/vboxvideo/Makefile.kmk --replace-fail /usr/include/xorg "${xorg.xorgserver.dev}/include/xorg "
61 NIX_CFLAGS_COMPILE=$(echo "$NIX_CFLAGS_COMPILE" | sed 's,\-isystem ${lib.getDev stdenv.cc.libc}/include,,g')
63 cat >> LocalConfig.kmk <<LOCAL_CONFIG
64 VBOX_WITH_TESTCASES :=
65 VBOX_WITH_TESTSUITE :=
66 VBOX_WITH_VALIDATIONKIT :=
68 VBOX_WITH_WARNINGS_AS_ERRORS :=
71 VBOX_PATH_APP_PRIVATE_ARCH_TOP := $out/share/virtualbox
72 VBOX_PATH_APP_PRIVATE_ARCH := $out/libexec/virtualbox
73 VBOX_PATH_SHARED_LIBS := $out/libexec/virtualbox
74 VBOX_WITH_RUNPATH := $out/libexec/virtualbox
75 VBOX_PATH_APP_PRIVATE := $out/share/virtualbox
76 VBOX_PATH_APP_DOCS := $out/doc
78 VBOX_USE_SYSTEM_XORG_HEADERS := 1
79 VBOX_USE_SYSTEM_GL_HEADERS := 1
80 VBOX_NO_LEGACY_XORG_X11 := 1
81 SDK_VBoxLibPng_INCS :=
82 SDK_VBoxLibXml2_INCS :=
83 SDK_VBoxLibLzma_INCS := ${xz.dev}/include
84 SDK_VBoxLibLzma_LIBS := ${xz.out}/lib
86 SDK_VBoxOpenSslStatic_INCS := ${openssl.dev}/include/ssl
88 VBOX_ONLY_ADDITIONS := 1
89 VBOX_WITH_SHARED_CLIPBOARD := 1
90 VBOX_WITH_GUEST_PROPS := 1
92 VBOX_WITH_SHARED_FOLDERS := 1
93 VBOX_WITH_GUEST_CONTROL := 1
94 VBOX_WITHOUT_LINUX_GUEST_PACKAGE := 1
96 VBOX_WITH_UPDATE_AGENT :=
97 VBOX_WITH_AUDIO_ALSA :=
98 VBOX_WITH_AUDIO_PULSE :=
100 VBOX_BUILD_PUBLISHER := _NixOS
105 --with-linux=${kernel.dev} \
108 sed -e 's@PKG_CONFIG_PATH=.*@PKG_CONFIG_PATH=${glib.dev}/lib/pkgconfig @' \
110 sed -e 's@arch/x86/@@' \
117 enableParallelBuilding = true;
123 VBOX_ONLY_ADDITIONS=1 VBOX_ONLY_BUILD=1 kmk -j $NIX_BUILD_CORES BUILD_TYPE="${buildType}"
124 VBOX_ONLY_ADDITIONS=1 VBOX_ONLY_BUILD=1 kmk packing
133 cp -rv ./out/linux.${if stdenv.hostPlatform.is32bit then "x86" else "amd64"}/${buildType}/bin/additions/VBoxGuestAdditions-${if stdenv.hostPlatform.is32bit then "x86" else "amd64"}.tar.bz2 $out/