2014-01-05 01:57:21 +00:00
|
|
|
{ stdenv, fetchurl, lib, patchelf, cdrkit, kernel, which, makeWrapper
|
2013-06-23 12:35:33 +00:00
|
|
|
, xorg, dbus, virtualbox }:
|
2009-10-13 13:32:00 +00:00
|
|
|
|
2013-06-23 11:57:13 +00:00
|
|
|
let
|
2013-06-23 12:35:33 +00:00
|
|
|
version = virtualbox.version;
|
2013-06-23 11:57:13 +00:00
|
|
|
xserverVListFunc = builtins.elemAt (stdenv.lib.splitString "." xorg.xorgserver.version);
|
|
|
|
xserverABI = xserverVListFunc 0 + xserverVListFunc 1;
|
|
|
|
in
|
2011-04-18 19:41:34 +00:00
|
|
|
|
2009-10-13 13:32:00 +00:00
|
|
|
stdenv.mkDerivation {
|
2014-01-05 01:57:21 +00:00
|
|
|
name = "VirtualBox-GuestAdditions-${version}-${kernel.version}";
|
2012-10-09 16:41:24 +00:00
|
|
|
|
2009-10-13 13:32:00 +00:00
|
|
|
src = fetchurl {
|
2011-04-18 19:41:34 +00:00
|
|
|
url = "http://download.virtualbox.org/virtualbox/${version}/VBoxGuestAdditions_${version}.iso";
|
2017-02-02 18:31:14 +00:00
|
|
|
sha256 = "1b206b76050dccd3ed979307230f9ddea79551e1c0aba93faee77416733cdc8a";
|
2009-10-13 13:32:00 +00:00
|
|
|
};
|
2012-10-09 16:41:24 +00:00
|
|
|
|
2014-01-05 01:57:21 +00:00
|
|
|
KERN_DIR = "${kernel.dev}/lib/modules/*/build";
|
2012-10-09 16:41:24 +00:00
|
|
|
|
2016-02-26 17:38:15 +00:00
|
|
|
hardeningDisable = [ "pic" ];
|
2016-02-07 22:43:59 +00:00
|
|
|
|
2016-09-26 12:49:11 +00:00
|
|
|
NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types";
|
|
|
|
|
2012-12-30 03:45:46 +00:00
|
|
|
buildInputs = [ patchelf cdrkit makeWrapper dbus ];
|
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 17:43:37 +00:00
|
|
|
|
2013-06-23 11:57:13 +00:00
|
|
|
buildCommand = with xorg; ''
|
2011-02-02 20:05:47 +00:00
|
|
|
${if stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux" then ''
|
|
|
|
isoinfo -J -i $src -x /VBoxLinuxAdditions.run > ./VBoxLinuxAdditions.run
|
|
|
|
chmod 755 ./VBoxLinuxAdditions.run
|
2012-08-14 17:43:37 +00:00
|
|
|
./VBoxLinuxAdditions.run --noexec --keep
|
2009-10-14 12:37:52 +00:00
|
|
|
''
|
|
|
|
else throw ("Architecture: "+stdenv.system+" not supported for VirtualBox guest additions")
|
|
|
|
}
|
2012-08-14 17:43:37 +00:00
|
|
|
|
2010-02-16 16:10:01 +00:00
|
|
|
# Unpack files
|
|
|
|
cd install
|
2011-02-02 20:05:47 +00:00
|
|
|
${if stdenv.system == "i686-linux" then ''
|
|
|
|
tar xfvj VBoxGuestAdditions-x86.tar.bz2
|
|
|
|
''
|
|
|
|
else if stdenv.system == "x86_64-linux" then ''
|
|
|
|
tar xfvj VBoxGuestAdditions-amd64.tar.bz2
|
|
|
|
''
|
|
|
|
else throw ("Architecture: "+stdenv.system+" not supported for VirtualBox guest additions")
|
|
|
|
}
|
|
|
|
|
2012-08-14 17:43:37 +00:00
|
|
|
|
|
|
|
# Build kernel modules
|
|
|
|
cd src
|
2009-10-13 13:32:00 +00:00
|
|
|
|
2010-02-16 16:10:01 +00:00
|
|
|
for i in *
|
2009-10-13 13:32:00 +00:00
|
|
|
do
|
2012-08-14 17:43:37 +00:00
|
|
|
cd $i
|
|
|
|
find . -type f | xargs sed 's/depmod -a/true/' -i
|
|
|
|
make
|
|
|
|
cd ..
|
2009-10-13 13:32:00 +00:00
|
|
|
done
|
2011-02-02 20:05:47 +00:00
|
|
|
|
2009-10-13 13:32:00 +00:00
|
|
|
cd ..
|
2012-08-14 17:43:37 +00:00
|
|
|
|
2009-10-13 13:32:00 +00:00
|
|
|
# Change the interpreter for various binaries
|
2012-12-30 03:45:46 +00:00
|
|
|
for i in sbin/VBoxService bin/{VBoxClient,VBoxControl} lib/VBoxGuestAdditions/mount.vboxsf
|
2009-10-13 13:32:00 +00:00
|
|
|
do
|
2009-10-14 12:37:52 +00:00
|
|
|
${if stdenv.system == "i686-linux" then ''
|
2015-04-26 17:54:51 +00:00
|
|
|
patchelf --set-interpreter ${stdenv.glibc.out}/lib/ld-linux.so.2 $i
|
2012-08-14 17:43:37 +00:00
|
|
|
''
|
|
|
|
else if stdenv.system == "x86_64-linux" then ''
|
2015-04-26 17:54:51 +00:00
|
|
|
patchelf --set-interpreter ${stdenv.glibc.out}/lib/ld-linux-x86-64.so.2 $i
|
2012-08-14 17:43:37 +00:00
|
|
|
''
|
|
|
|
else throw ("Architecture: "+stdenv.system+" not supported for VirtualBox guest additions")
|
|
|
|
}
|
2015-10-05 09:22:48 +00:00
|
|
|
patchelf --set-rpath ${lib.makeLibraryPath [ stdenv.cc.cc dbus libX11 libXt libXext libXmu libXfixes libXrandr libXcursor ]} $i
|
2009-10-13 13:32:00 +00:00
|
|
|
done
|
|
|
|
|
2010-02-16 16:10:01 +00:00
|
|
|
for i in lib/VBoxOGL*.so
|
2009-10-13 13:32:00 +00:00
|
|
|
do
|
2016-08-22 21:04:39 +00:00
|
|
|
patchelf --set-rpath ${lib.makeLibraryPath [ "$out" dbus libXcomposite libXdamage libXext libXfixes ]} $i
|
2009-10-13 13:32:00 +00:00
|
|
|
done
|
2012-08-14 17:43:37 +00: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:
|
|
|
|
mv lib/VBoxGuestAdditions/98vboxadd-xclient bin/VBoxClient-all
|
|
|
|
|
2009-10-13 13:32:00 +00:00
|
|
|
# Remove references to /usr from various scripts and files
|
2010-02-16 16:10:01 +00:00
|
|
|
sed -i -e "s|/usr/bin|$out/bin|" share/VBoxGuestAdditions/vboxclient.desktop
|
|
|
|
sed -i -e "s|/usr/bin|$out/bin|" bin/VBoxClient-all
|
2012-08-14 17:43:37 +00:00
|
|
|
|
2009-10-13 13:32:00 +00:00
|
|
|
# Install binaries
|
2015-08-04 01:03:24 +00:00
|
|
|
install -D -m 4755 lib/VBoxGuestAdditions/mount.vboxsf $out/bin/mount.vboxsf
|
|
|
|
install -D -m 755 sbin/VBoxService $out/bin/VBoxService
|
2009-10-13 13:32:00 +00: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 13:32:00 +00:00
|
|
|
|
2010-11-28 10:14:07 +00:00
|
|
|
wrapProgram $out/bin/VBoxClient-all \
|
|
|
|
--prefix PATH : "${which}/bin"
|
|
|
|
|
2009-10-13 13:32:00 +00: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 13:32:00 +00:00
|
|
|
ln -s $out/lib/VBoxOGL.so $out/lib/dri/vboxvideo_dri.so
|
2012-08-14 17:43:37 +00:00
|
|
|
|
2009-10-13 13:32:00 +00:00
|
|
|
# Install desktop file
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/share/autostart
|
2010-02-16 16:10:01 +00:00
|
|
|
cp -v share/VBoxGuestAdditions/vboxclient.desktop $out/share/autostart
|
2012-04-23 04:25:18 +00:00
|
|
|
|
2009-10-13 13:32:00 +00:00
|
|
|
# Install Xorg drivers
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/lib/xorg/modules/{drivers,input}
|
2013-06-23 11:57:13 +00:00
|
|
|
install -m 644 lib/VBoxGuestAdditions/vboxvideo_drv_${xserverABI}.so $out/lib/xorg/modules/drivers/vboxvideo_drv.so
|
2012-04-23 04:25:18 +00:00
|
|
|
|
2009-10-13 13:32:00 +00:00
|
|
|
# Install kernel modules
|
2010-02-16 16:10:01 +00:00
|
|
|
cd src
|
2012-08-14 17:43:37 +00: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 17:43:37 +00: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 13:32:00 +00:00
|
|
|
meta = {
|
|
|
|
description = "Guest additions for VirtualBox";
|
|
|
|
longDescriptions = ''
|
|
|
|
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 17:43:37 +00:00
|
|
|
platforms = lib.platforms.linux;
|
2009-10-13 13:32:00 +00:00
|
|
|
};
|
|
|
|
}
|