commit a13716f72b8087bffc75a4f4629cbea8ac2ff693
Author: Marc Weber <marco-oweber@gmx.de>
Date:   Sun Jun 12 06:04:32 2011 +0200

    improve vbox networking. Without vbox knowing about ifconfig location you can't test pxe boot proberly for whatever reason

diff --git a/pkgs/applications/virtualization/virtualbox/default.nix b/pkgs/applications/virtualization/virtualbox/default.nix
index 727cea4..3c665d4 100644
--- a/pkgs/applications/virtualization/virtualbox/default.nix
+++ b/pkgs/applications/virtualization/virtualbox/default.nix
@@ -2,6 +2,7 @@
 , libXcursor, qt4, libIDL, SDL, hal, libcap, zlib, libpng, glib, kernel
 , python, which, alsaLib, curl, gawk
 , xorriso, makeself, perl, jdk
+, nettools
 }:
 
 let version = "4.0.4"; in
@@ -16,6 +17,16 @@ stdenv.mkDerivation {
 
   buildInputs = [iasl dev86 libxslt libxml2 xproto libX11 libXext libXcursor qt4 libIDL SDL hal libcap glib kernel python alsaLib curl pam xorriso makeself perl jdk ];
 
+
+  /* create patch:
+    find -type f | xargs sed -i \
+      -e 's@/sbin/ifconfig@IFCONFIG_BASE/sbin/ifconfig@g' \
+      > path.patch
+
+    without this patch vboxnet0 is not setup correctly so bridge and host only
+    networking setups can't be listened on by eg dhcpd (PXE boot does not work)
+  */
+
   patchPhase = "
     set -x
     MODULES_BUILD_DIR=`echo ${kernel}/lib/modules/*/build`
@@ -26,6 +37,9 @@ stdenv.mkDerivation {
     ls kBuild/bin/linux.amd64/k* tools/linux.amd64/bin/* | xargs -n 1 patchelf --set-interpreter ${stdenv.glibc}/lib/ld-linux-x86-64.so.2 
     export USER=nix
     set +x
+    cp ${./path.patch} patch.patch
+    sed -i 's@IFCONFIG_BASE@${nettools}@g' patch.patch
+    patch -p1 < patch.patch
   ";
 
   configurePhase = ''
diff --git a/pkgs/applications/virtualization/virtualbox/path.patch b/pkgs/applications/virtualization/virtualbox/path.patch
new file mode 100644
index 0000000..4196b91
--- /dev/null
+++ b/pkgs/applications/virtualization/virtualbox/path.patch
@@ -0,0 +1,54 @@
+diff --git a/src/VBox/Devices/Network/solaris/vnicinit_solaris.sh b/src/VBox/Devices/Network/solaris/vnicinit_solaris.sh
+index 74d8c1d..01b35be 100755
+--- a/src/VBox/Devices/Network/solaris/vnicinit_solaris.sh
++++ b/src/VBox/Devices/Network/solaris/vnicinit_solaris.sh
+@@ -101,8 +101,8 @@ fi
+ netmask="255.255.255.0"
+ 
+ if [ -z "$2" ]; then
+-    /sbin/ifconfig $vnic_name plumb
+-    /sbin/ifconfig $vnic_name $host_ip destination $guest_ip netmask $netmask up
++    IFCONFIG_BASE/sbin/ifconfig $vnic_name plumb
++    IFCONFIG_BASE/sbin/ifconfig $vnic_name $host_ip destination $guest_ip netmask $netmask up
+ #else
+ #   Do existing VNIC configuration here if needed...
+ fi
+diff --git a/src/VBox/Devices/Network/solaris/vnicterm_solaris.sh b/src/VBox/Devices/Network/solaris/vnicterm_solaris.sh
+index 1d629b8..0cde95c 100755
+--- a/src/VBox/Devices/Network/solaris/vnicterm_solaris.sh
++++ b/src/VBox/Devices/Network/solaris/vnicterm_solaris.sh
+@@ -20,7 +20,7 @@ if [ -z "$1" ]; then
+     exit 1
+ fi
+ 
+-/sbin/ifconfig $1 unplumb
++IFCONFIG_BASE/sbin/ifconfig $1 unplumb
+ vnic_id=${1##*[a-z]}
+ /usr/lib/vna ${vnic_id}
+ exit $?
+diff --git a/src/VBox/Installer/solaris/vboxconfig.sh b/src/VBox/Installer/solaris/vboxconfig.sh
+index d305b4f..f92c525 100755
+--- a/src/VBox/Installer/solaris/vboxconfig.sh
++++ b/src/VBox/Installer/solaris/vboxconfig.sh
+@@ -38,7 +38,7 @@ BIN_DEVFSADM=/usr/sbin/devfsadm
+ BIN_BOOTADM=/sbin/bootadm
+ BIN_SVCADM=/usr/sbin/svcadm
+ BIN_SVCCFG=/usr/sbin/svccfg
+-BIN_IFCONFIG=/sbin/ifconfig
++BIN_IFCONFIG=IFCONFIG_BASE/sbin/ifconfig
+ BIN_SVCS=/usr/bin/svcs
+ BIN_ID=/usr/bin/id
+ BIN_PKILL=/usr/bin/pkill
+diff --git a/src/apps/adpctl/VBoxNetAdpCtl.cpp b/src/apps/adpctl/VBoxNetAdpCtl.cpp
+index b0c2c9d..731645b 100644
+--- a/src/apps/adpctl/VBoxNetAdpCtl.cpp
++++ b/src/apps/adpctl/VBoxNetAdpCtl.cpp
+@@ -49,7 +49,7 @@ typedef struct VBoxNetAdpReq
+ typedef VBOXNETADPREQ *PVBOXNETADPREQ;
+ 
+ 
+-#define VBOXADPCTL_IFCONFIG_PATH "/sbin/ifconfig"
++#define VBOXADPCTL_IFCONFIG_PATH "IFCONFIG_BASE/sbin/ifconfig"
+ 
+ #if defined(RT_OS_LINUX)
+ # define VBOXADPCTL_DEL_CMD "del"
