2010-11-28 10:14:07 +00:00
|
|
|
{ stdenv, fetchurl, lib, patchelf, cdrkit, kernel, which, makeWrapper
|
2010-09-07 13:08:24 +01:00
|
|
|
, libX11, libXt, libXext, libXmu, libXcomposite, libXfixes, libXrandr, libXcursor}:
|
2009-10-13 14:32:00 +01:00
|
|
|
|
2011-08-08 13:11:57 +01:00
|
|
|
let version = "4.1.0"; in
|
2011-04-18 20:41:34 +01:00
|
|
|
|
2009-10-13 14:32:00 +01:00
|
|
|
stdenv.mkDerivation {
|
2011-04-18 20:41:34 +01:00
|
|
|
name = "VirtualBox-GuestAdditions-${version}";
|
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";
|
2011-08-08 13:11:57 +01:00
|
|
|
sha256 = "0azj08l0457cjl5v2ddgb5kz8gblsi7cgjgdmyiszvlqpyfbh98w";
|
2009-10-13 14:32:00 +01:00
|
|
|
};
|
|
|
|
KERN_DIR = "${kernel}/lib/modules/*/build";
|
2010-11-28 10:14:07 +00:00
|
|
|
buildInputs = [ patchelf cdrkit makeWrapper ];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
ensureDir $out
|
|
|
|
cp -r install/* $out
|
|
|
|
|
|
|
|
'';
|
|
|
|
|
2009-10-13 14:32:00 +01:00
|
|
|
buildCommand = ''
|
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
|
|
|
|
./VBoxLinuxAdditions.run --noexec --keep
|
2009-10-14 13:37:52 +01:00
|
|
|
''
|
|
|
|
else throw ("Architecture: "+stdenv.system+" not supported for VirtualBox guest additions")
|
|
|
|
}
|
|
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
2010-02-16 16:10:01 +00:00
|
|
|
|
|
|
|
# Build kernel modules
|
|
|
|
cd src
|
2009-10-13 14:32:00 +01:00
|
|
|
|
2010-02-16 16:10:01 +00:00
|
|
|
for i in *
|
2009-10-13 14:32:00 +01:00
|
|
|
do
|
2010-02-16 16:10:01 +00:00
|
|
|
cd $i
|
2011-08-09 10:07:29 +01:00
|
|
|
find . -type f | xargs sed 's/depmod -a/true/' -i
|
2010-02-16 16:10:01 +00:00
|
|
|
make
|
|
|
|
cd ..
|
2009-10-13 14:32:00 +01:00
|
|
|
done
|
2011-02-02 20:05:47 +00:00
|
|
|
|
2009-10-13 14:32:00 +01:00
|
|
|
cd ..
|
2010-02-16 16:10:01 +00:00
|
|
|
|
2009-10-13 14:32:00 +01:00
|
|
|
# Change the interpreter for various binaries
|
2010-02-16 16:10:01 +00:00
|
|
|
for i in sbin/VBoxService bin/{VBoxClient,VBoxControl}
|
2009-10-13 14:32:00 +01:00
|
|
|
do
|
2009-10-14 13:37:52 +01:00
|
|
|
${if stdenv.system == "i686-linux" then ''
|
|
|
|
patchelf --set-interpreter ${stdenv.glibc}/lib/ld-linux.so.2 $i
|
|
|
|
''
|
|
|
|
else if stdenv.system == "x86_64-linux" then ''
|
|
|
|
patchelf --set-interpreter ${stdenv.glibc}/lib/ld-linux-x86-64.so.2 $i
|
|
|
|
''
|
|
|
|
else throw ("Architecture: "+stdenv.system+" not supported for VirtualBox guest additions")
|
|
|
|
}
|
2009-10-13 14:32:00 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
# Change rpath for various binaries and libraries
|
2010-09-07 13:08:24 +01:00
|
|
|
patchelf --set-rpath ${stdenv.gcc.gcc}/lib:${libX11}/lib:${libXt}/lib:${libXext}/lib:${libXmu}/lib:${libXfixes}/lib:${libXrandr}/lib:${libXcursor}/lib bin/VBoxClient
|
2009-10-13 14:32:00 +01:00
|
|
|
|
2010-02-16 16:10:01 +00:00
|
|
|
for i in lib/VBoxOGL*.so
|
2009-10-13 14:32:00 +01:00
|
|
|
do
|
|
|
|
patchelf --set-rpath $out/lib $i
|
|
|
|
done
|
2010-02-16 16:10:01 +00:00
|
|
|
|
2009-10-13 14:32:00 +01: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
|
|
|
|
|
2009-10-13 14:32:00 +01:00
|
|
|
# Install binaries
|
|
|
|
ensureDir $out/sbin
|
2010-02-16 16:10:01 +00:00
|
|
|
install -m 755 sbin/VBoxService $out/sbin
|
2009-10-13 14:32:00 +01:00
|
|
|
|
|
|
|
ensureDir $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
|
|
|
|
ensureDir $out/lib
|
2010-02-16 16:10:01 +00:00
|
|
|
cp -v lib/VBoxOGL*.so $out/lib
|
2009-10-13 14:32:00 +01:00
|
|
|
ensureDir $out/lib/dri
|
|
|
|
ln -s $out/lib/VBoxOGL.so $out/lib/dri/vboxvideo_dri.so
|
|
|
|
|
|
|
|
# Install desktop file
|
2009-10-13 16:04:43 +01:00
|
|
|
ensureDir $out/share/autostart
|
2010-02-16 16:10:01 +00:00
|
|
|
cp -v share/VBoxGuestAdditions/vboxclient.desktop $out/share/autostart
|
2009-10-13 14:32:00 +01:00
|
|
|
|
2009-10-13 15:29:38 +01:00
|
|
|
# Install HAL FDI file
|
|
|
|
ensureDir $out/share/hal/fdi/policy
|
2010-02-16 16:10:01 +00:00
|
|
|
install -m 644 share/VBoxGuestAdditions/90-vboxguest.fdi $out/share/hal/fdi/policy
|
2009-10-13 15:29:38 +01:00
|
|
|
|
2009-10-13 14:32:00 +01:00
|
|
|
# Install Xorg drivers
|
|
|
|
ensureDir $out/lib/xorg/modules/{drivers,input}
|
2011-08-12 15:27:28 +01:00
|
|
|
install -m 644 lib/VBoxGuestAdditions/vboxvideo_drv_19.so $out/lib/xorg/modules/drivers/vboxvideo_drv.so
|
|
|
|
install -m 644 lib/VBoxGuestAdditions/vboxmouse_drv_19.so $out/lib/xorg/modules/input/vboxmouse_drv.so
|
2009-10-13 14:32:00 +01:00
|
|
|
|
|
|
|
# Install kernel modules
|
2010-02-16 16:10:01 +00:00
|
|
|
cd src
|
|
|
|
|
|
|
|
for i in *
|
|
|
|
do
|
|
|
|
cd $i
|
|
|
|
kernelVersion=$(cd ${kernel}/lib/modules; ls)
|
|
|
|
export MODULE_DIR=$out/lib/modules/$kernelVersion/misc
|
2011-08-09 10:07:29 +01:00
|
|
|
find . -type f | xargs sed -i -e "s|-o root||g" \
|
|
|
|
-e "s|-g root||g"
|
2010-02-16 16:10:01 +00:00
|
|
|
make install
|
|
|
|
cd ..
|
2010-02-18 13:09:49 +00:00
|
|
|
done
|
2009-10-13 14:32:00 +01: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 ];
|
|
|
|
};
|
|
|
|
}
|