2014-01-05 01:57:21 +00:00
|
|
|
{ stdenv, fetchurl, lib, patchelf, cdrkit, kernel, which, makeWrapper
|
2013-06-23 13:35:33 +01:00
|
|
|
, xorg, dbus, virtualbox }:
|
2009-10-13 14:32:00 +01:00
|
|
|
|
2013-06-23 12:57:13 +01:00
|
|
|
let
|
2013-06-23 13:35:33 +01:00
|
|
|
version = virtualbox.version;
|
2013-06-23 12:57:13 +01:00
|
|
|
xserverVListFunc = builtins.elemAt (stdenv.lib.splitString "." xorg.xorgserver.version);
|
2017-02-12 20:06:59 +00:00
|
|
|
|
|
|
|
# Forced to 1.18 in <nixpkgs/nixos/modules/services/x11/xserver.nix>
|
|
|
|
# as it even fails to build otherwise. Still, override this even here,
|
|
|
|
# in case someone does just a standalone build
|
|
|
|
# (not via videoDrivers = ["vboxvideo"]).
|
|
|
|
# It's likely to work again in some future update.
|
|
|
|
xserverABI = let abi = xserverVListFunc 0 + xserverVListFunc 1;
|
|
|
|
in if abi == "119" then "118" else abi;
|
2013-06-23 12:57:13 +01:00
|
|
|
in
|
2011-04-18 20:41:34 +01:00
|
|
|
|
2009-10-13 14:32:00 +01:00
|
|
|
stdenv.mkDerivation {
|
2014-01-05 01:57:21 +00:00
|
|
|
name = "VirtualBox-GuestAdditions-${version}-${kernel.version}";
|
2012-10-09 17:41:24 +01:00
|
|
|
|
2009-10-13 14:32:00 +01:00
|
|
|
src = fetchurl {
|
2011-04-18 20:41:34 +01:00
|
|
|
url = "http://download.virtualbox.org/virtualbox/${version}/VBoxGuestAdditions_${version}.iso";
|
2018-07-17 11:40:20 +01:00
|
|
|
sha256 = "e149ff0876242204fe924763f9272f691242d6a6ad4538a128fb7dba770781de";
|
2009-10-13 14:32:00 +01:00
|
|
|
};
|
2012-10-09 17:41:24 +01:00
|
|
|
|
2017-11-15 15:03:44 +00:00
|
|
|
KERN_DIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
|
|
|
|
KERN_INCL = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/source/include";
|
|
|
|
|
2017-11-24 19:20:38 +00:00
|
|
|
patchFlags = [ "-p1" "-d" "install/src/vboxguest-${version}" ];
|
|
|
|
|
2017-11-15 15:03:44 +00:00
|
|
|
patches = [
|
|
|
|
./fix_kerndir.patch
|
|
|
|
./fix_kernincl.patch
|
|
|
|
];
|
2012-10-09 17:41:24 +01:00
|
|
|
|
2016-02-26 17:38:15 +00:00
|
|
|
hardeningDisable = [ "pic" ];
|
2016-02-07 22:43:59 +00:00
|
|
|
|
2017-11-15 15:03:44 +00:00
|
|
|
NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration";
|
2016-09-26 13:49:11 +01:00
|
|
|
|
2018-09-27 22:38:10 +01:00
|
|
|
nativeBuildInputs = [ patchelf makeWrapper ];
|
|
|
|
buildInputs = [ cdrkit dbus ] ++ kernel.moduleBuildDependencies;
|
2010-11-28 10:14:07 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out
|
2010-11-28 10:14:07 +00:00
|
|
|
cp -r install/* $out
|
|
|
|
'';
|
2012-08-14 18:43:37 +01:00
|
|
|
|
2013-06-23 12:57:13 +01:00
|
|
|
buildCommand = with xorg; ''
|
2018-08-20 20:11:29 +01:00
|
|
|
${if stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux" then ''
|
2011-02-02 20:05:47 +00:00
|
|
|
isoinfo -J -i $src -x /VBoxLinuxAdditions.run > ./VBoxLinuxAdditions.run
|
|
|
|
chmod 755 ./VBoxLinuxAdditions.run
|
2012-08-14 18:43:37 +01:00
|
|
|
./VBoxLinuxAdditions.run --noexec --keep
|
2009-10-14 13:37:52 +01:00
|
|
|
''
|
2018-08-20 20:11:29 +01:00
|
|
|
else throw ("Architecture: "+stdenv.hostPlatform.system+" not supported for VirtualBox guest additions")
|
2009-10-14 13:37:52 +01:00
|
|
|
}
|
2012-08-14 18:43:37 +01:00
|
|
|
|
2010-02-16 16:10:01 +00:00
|
|
|
# Unpack files
|
|
|
|
cd install
|
2018-08-20 20:11:29 +01:00
|
|
|
${if stdenv.hostPlatform.system == "i686-linux" then ''
|
2011-02-02 20:05:47 +00:00
|
|
|
tar xfvj VBoxGuestAdditions-x86.tar.bz2
|
|
|
|
''
|
2018-08-20 20:11:29 +01:00
|
|
|
else if stdenv.hostPlatform.system == "x86_64-linux" then ''
|
2011-02-02 20:05:47 +00:00
|
|
|
tar xfvj VBoxGuestAdditions-amd64.tar.bz2
|
|
|
|
''
|
2018-08-20 20:11:29 +01:00
|
|
|
else throw ("Architecture: "+stdenv.hostPlatform.system+" not supported for VirtualBox guest additions")
|
2011-02-02 20:05:47 +00:00
|
|
|
}
|
|
|
|
|
2017-11-15 15:03:44 +00:00
|
|
|
cd ../
|
|
|
|
patchPhase
|
|
|
|
cd install/src
|
2012-08-14 18:43:37 +01:00
|
|
|
|
|
|
|
# Build kernel modules
|
2017-11-15 15:03:44 +00:00
|
|
|
export INSTALL_MOD_PATH=$out
|
2009-10-13 14:32:00 +01:00
|
|
|
|
2017-11-15 15:03:44 +00:00
|
|
|
find . -type f | xargs sed 's/depmod -a/true/' -i
|
|
|
|
|
|
|
|
cd vboxguest-${version}
|
|
|
|
|
|
|
|
make
|
2011-02-02 20:05:47 +00:00
|
|
|
|
2017-11-15 15:03:44 +00:00
|
|
|
cd ../..
|
2012-08-14 18:43:37 +01:00
|
|
|
|
2009-10-13 14:32:00 +01:00
|
|
|
# Change the interpreter for various binaries
|
2017-11-15 15:03:44 +00:00
|
|
|
for i in sbin/VBoxService bin/{VBoxClient,VBoxControl} other/mount.vboxsf
|
2009-10-13 14:32:00 +01:00
|
|
|
do
|
2018-08-20 20:11:29 +01:00
|
|
|
${if stdenv.hostPlatform.system == "i686-linux" then ''
|
2015-04-26 18:54:51 +01:00
|
|
|
patchelf --set-interpreter ${stdenv.glibc.out}/lib/ld-linux.so.2 $i
|
2012-08-14 18:43:37 +01:00
|
|
|
''
|
2018-08-20 20:11:29 +01:00
|
|
|
else if stdenv.hostPlatform.system == "x86_64-linux" then ''
|
2015-04-26 18:54:51 +01:00
|
|
|
patchelf --set-interpreter ${stdenv.glibc.out}/lib/ld-linux-x86-64.so.2 $i
|
2012-08-14 18:43:37 +01:00
|
|
|
''
|
2018-08-20 20:11:29 +01:00
|
|
|
else throw ("Architecture: "+stdenv.hostPlatform.system+" not supported for VirtualBox guest additions")
|
2012-08-14 18:43:37 +01:00
|
|
|
}
|
2015-10-05 10:22:48 +01:00
|
|
|
patchelf --set-rpath ${lib.makeLibraryPath [ stdenv.cc.cc dbus libX11 libXt libXext libXmu libXfixes libXrandr libXcursor ]} $i
|
2009-10-13 14:32:00 +01:00
|
|
|
done
|
|
|
|
|
2010-02-16 16:10:01 +00:00
|
|
|
for i in lib/VBoxOGL*.so
|
2009-10-13 14:32:00 +01:00
|
|
|
do
|
2016-08-22 22:04:39 +01:00
|
|
|
patchelf --set-rpath ${lib.makeLibraryPath [ "$out" dbus libXcomposite libXdamage libXext libXfixes ]} $i
|
2009-10-13 14:32:00 +01:00
|
|
|
done
|
2012-08-14 18:43:37 +01:00
|
|
|
|
2015-03-02 14:56:32 +00:00
|
|
|
# FIXME: Virtualbox 4.3.22 moved VBoxClient-all (required by Guest Additions
|
|
|
|
# NixOS module) to 98vboxadd-xclient. For now, just work around it:
|
2017-11-15 15:03:44 +00:00
|
|
|
mv other/98vboxadd-xclient bin/VBoxClient-all
|
2015-03-02 14:56:32 +00:00
|
|
|
|
2009-10-13 14:32:00 +01:00
|
|
|
# Remove references to /usr from various scripts and files
|
2017-11-15 15:03:44 +00:00
|
|
|
sed -i -e "s|/usr/bin|$out/bin|" other/vboxclient.desktop
|
2010-02-16 16:10:01 +00:00
|
|
|
sed -i -e "s|/usr/bin|$out/bin|" bin/VBoxClient-all
|
2012-08-14 18:43:37 +01:00
|
|
|
|
2009-10-13 14:32:00 +01:00
|
|
|
# Install binaries
|
2017-11-15 15:03:44 +00:00
|
|
|
install -D -m 755 other/mount.vboxsf $out/bin/mount.vboxsf
|
2015-08-04 02:03:24 +01:00
|
|
|
install -D -m 755 sbin/VBoxService $out/bin/VBoxService
|
2009-10-13 14:32:00 +01:00
|
|
|
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/bin
|
2010-02-16 16:10:01 +00:00
|
|
|
install -m 755 bin/VBoxClient $out/bin
|
|
|
|
install -m 755 bin/VBoxControl $out/bin
|
|
|
|
install -m 755 bin/VBoxClient-all $out/bin
|
2009-10-13 14:32:00 +01:00
|
|
|
|
2010-11-28 10:14:07 +00:00
|
|
|
wrapProgram $out/bin/VBoxClient-all \
|
|
|
|
--prefix PATH : "${which}/bin"
|
|
|
|
|
2009-10-13 14:32:00 +01:00
|
|
|
# Install OpenGL libraries
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/lib
|
2010-02-16 16:10:01 +00:00
|
|
|
cp -v lib/VBoxOGL*.so $out/lib
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/lib/dri
|
2009-10-13 14:32:00 +01:00
|
|
|
ln -s $out/lib/VBoxOGL.so $out/lib/dri/vboxvideo_dri.so
|
2012-08-14 18:43:37 +01:00
|
|
|
|
2009-10-13 14:32:00 +01:00
|
|
|
# Install desktop file
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/share/autostart
|
2017-11-15 15:03:44 +00:00
|
|
|
cp -v other/vboxclient.desktop $out/share/autostart
|
2012-04-23 05:25:18 +01:00
|
|
|
|
2009-10-13 14:32:00 +01:00
|
|
|
# Install Xorg drivers
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/lib/xorg/modules/{drivers,input}
|
2017-11-15 15:03:44 +00:00
|
|
|
install -m 644 other/vboxvideo_drv_${xserverABI}.so $out/lib/xorg/modules/drivers/vboxvideo_drv.so
|
2012-04-23 05:25:18 +01:00
|
|
|
|
2009-10-13 14:32:00 +01:00
|
|
|
# Install kernel modules
|
2010-02-16 16:10:01 +00:00
|
|
|
cd src
|
2012-08-14 18:43:37 +01:00
|
|
|
|
2010-02-16 16:10:01 +00:00
|
|
|
for i in *
|
|
|
|
do
|
|
|
|
cd $i
|
2014-01-05 01:57:21 +00:00
|
|
|
kernelVersion=$(cd ${kernel.dev}/lib/modules; ls)
|
2012-08-14 18:43:37 +01:00
|
|
|
export MODULE_DIR=$out/lib/modules/$kernelVersion/misc
|
|
|
|
find . -type f | xargs sed -i -e "s|-o root||g" \
|
|
|
|
-e "s|-g root||g"
|
|
|
|
make install
|
|
|
|
cd ..
|
|
|
|
done
|
|
|
|
''; # */
|
|
|
|
|
2009-10-13 14:32:00 +01:00
|
|
|
meta = {
|
|
|
|
description = "Guest additions for VirtualBox";
|
2017-04-29 22:12:20 +01:00
|
|
|
longDescription = ''
|
2009-10-13 14:32:00 +01:00
|
|
|
Various add-ons which makes NixOS work better as guest OS inside VirtualBox.
|
|
|
|
This add-on provides support for dynamic resizing of the X Display, shared
|
|
|
|
host/guest clipboard support and guest OpenGL support.
|
|
|
|
'';
|
|
|
|
license = "GPL";
|
|
|
|
maintainers = [ lib.maintainers.sander ];
|
2012-08-14 18:43:37 +01:00
|
|
|
platforms = lib.platforms.linux;
|
2009-10-13 14:32:00 +01:00
|
|
|
};
|
|
|
|
}
|