From b909a4ce765082248eac1fa4c60352ed818d3fa9 Mon Sep 17 00:00:00 2001
From: Evgeny Egorochkin <phreedom.stdin@gmail.com>
Date: Sun, 28 Nov 2010 10:14:07 +0000
Subject: [PATCH] Virtualbox guest additions: fix runtime dep on which. Patch
 by Rohan Hart.

svn path=/nixpkgs/trunk/; revision=24903
---
 .../virtualbox/guest-additions/default.nix         | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix b/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix
index bb9b8eea08c4..eb8a91551426 100644
--- a/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix
+++ b/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, lib, patchelf, cdrkit, kernel
+{ stdenv, fetchurl, lib, patchelf, cdrkit, kernel, which, makeWrapper
 , libX11, libXt, libXext, libXmu, libXcomposite, libXfixes, libXrandr, libXcursor}:
 
 stdenv.mkDerivation {
@@ -8,7 +8,14 @@ stdenv.mkDerivation {
     sha256 = "1pyfgrcdmw6zf3yxgzcd8c5qzqqn62bz4085ka453gfmi9d65lys";
   };
   KERN_DIR = "${kernel}/lib/modules/*/build";
-  buildInputs = [ patchelf cdrkit ];
+  buildInputs = [ patchelf cdrkit makeWrapper ];
+
+  installPhase = ''
+    ensureDir $out
+    cp -r install/* $out
+
+  '';
+  
   buildCommand = ''
     ${if stdenv.system == "i686-linux" then ''
         isoinfo -J -i $src -x /VBoxLinuxAdditions-x86.run > ./VBoxLinuxAdditions-x86.run
@@ -73,6 +80,9 @@ stdenv.mkDerivation {
     install -m 755 bin/VBoxControl $out/bin
     install -m 755 bin/VBoxClient-all $out/bin
 
+    wrapProgram $out/bin/VBoxClient-all \
+            --prefix PATH : "${which}/bin"
+
     # Install OpenGL libraries
     ensureDir $out/lib
     cp -v lib/VBoxOGL*.so $out/lib