summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkgs/applications/audio/GStreamer/default.nix13
-rw-r--r--pkgs/applications/audio/aumix/default.nix24
-rw-r--r--pkgs/applications/audio/mpg321/default.nix17
-rw-r--r--pkgs/applications/audio/vorbis-tools/default.nix24
-rw-r--r--pkgs/applications/audio/vorbis-tools/ogg123-curlopt-mute.patch13
-rw-r--r--pkgs/applications/editors/emacs-22/default.nix3
-rw-r--r--pkgs/applications/editors/emacs-22/makefile-pwd.patch129
-rw-r--r--pkgs/applications/editors/emacs-modes/bbdb/builder.sh12
-rw-r--r--pkgs/applications/editors/emacs-modes/bbdb/default.nix22
-rw-r--r--pkgs/applications/editors/emacs-modes/bbdb/install-infodir.patch28
-rw-r--r--pkgs/applications/editors/nano/default.nix30
-rw-r--r--pkgs/applications/graphics/exrdisplay/default.nix2
-rw-r--r--pkgs/applications/graphics/xara/default.nix2
-rw-r--r--pkgs/applications/misc/fetchmail/default.nix4
-rw-r--r--pkgs/applications/misc/gkrellm/default.nix33
-rw-r--r--pkgs/applications/misc/pgadmin/default.nix2
-rw-r--r--pkgs/applications/misc/procmail/default.nix15
-rw-r--r--pkgs/applications/misc/rxvt_unicode/default.nix24
-rw-r--r--pkgs/applications/misc/wordnet/default.nix25
-rw-r--r--pkgs/applications/misc/xterm/default.nix11
-rw-r--r--pkgs/applications/networking/browsers/firefox/default.nix6
-rw-r--r--pkgs/applications/networking/browsers/firefox3b1/3b2.nix57
-rw-r--r--pkgs/applications/networking/browsers/firefox3b1/binary.nix55
-rw-r--r--pkgs/applications/networking/browsers/firefox3b1/builder.sh30
-rw-r--r--pkgs/applications/networking/browsers/firefox3b1/default.nix58
-rw-r--r--pkgs/applications/networking/browsers/firefox3b1/writable-copies.patch23
-rw-r--r--pkgs/applications/networking/browsers/firefox3b1/xlibs.patch10
-rw-r--r--pkgs/applications/networking/instant-messengers/bitlbee/default.nix17
-rw-r--r--pkgs/applications/version-management/arch/configure-tmpdir.patch11
-rw-r--r--pkgs/applications/version-management/arch/default.nix29
-rw-r--r--pkgs/applications/version-management/darcs_2_pre.nix16
-rw-r--r--pkgs/applications/version-management/git/default.nix24
-rw-r--r--pkgs/applications/virtualization/qemu/linux-img/0.2.nix1
-rw-r--r--pkgs/build-support/fetchurl/mirrors.nix36
-rw-r--r--pkgs/build-support/substitute/substitute-all.sh4
-rw-r--r--pkgs/data/fonts/freefont-ttf/default.nix8
-rw-r--r--pkgs/desktops/gnome/gnome-vfs.nix4
-rwxr-xr-xpkgs/desktops/kde-4/base/builder.sh12
-rw-r--r--pkgs/desktops/kde-4/base/default.nix9
-rw-r--r--pkgs/desktops/kde-4/default.nix12
-rw-r--r--pkgs/desktops/kde-4/edu/default.nix10
-rw-r--r--pkgs/desktops/kde-4/extragear/default.nix15
-rw-r--r--pkgs/desktops/kde-4/games/default.nix7
-rw-r--r--pkgs/desktops/kde-4/graphics/default.nix9
-rw-r--r--pkgs/desktops/kde-4/l10n/default.nix60
-rw-r--r--pkgs/desktops/kde-4/libs/default.nix9
-rwxr-xr-xpkgs/desktops/kde-4/libs/setup.sh9
-rw-r--r--pkgs/desktops/kde-4/multimedia/default.nix8
-rw-r--r--pkgs/desktops/kde-4/network/default.nix4
-rwxr-xr-xpkgs/desktops/kde-4/pim/builder.sh10
-rw-r--r--pkgs/desktops/kde-4/pim/default.nix6
-rw-r--r--pkgs/desktops/kde-4/pimlibs/default.nix7
-rwxr-xr-xpkgs/desktops/kde-4/runtime/builder.sh12
-rw-r--r--pkgs/desktops/kde-4/runtime/default.nix13
-rw-r--r--pkgs/desktops/kde-4/runtime/phonon.patch13
-rw-r--r--pkgs/desktops/kde-4/support/default.nix2
-rw-r--r--pkgs/desktops/kde-4/support/eigen.nix2
-rw-r--r--pkgs/desktops/kde-4/support/gmm.nix2
-rw-r--r--pkgs/desktops/kde-4/support/qca.nix2
-rw-r--r--pkgs/desktops/kde-4/support/qimageblitz.nix2
-rw-r--r--pkgs/desktops/kde-4/support/soprano.nix2
-rw-r--r--pkgs/desktops/kde-4/support/strigi.nix4
-rw-r--r--pkgs/desktops/kde-4/support/taglib.nix2
-rw-r--r--pkgs/desktops/kde-4/toys/default.nix7
-rw-r--r--pkgs/desktops/kde-4/utils/default.nix8
-rwxr-xr-xpkgs/desktops/kde-4/workspace/builder.sh12
-rw-r--r--pkgs/desktops/kde-4/workspace/default.nix12
-rw-r--r--pkgs/desktops/kde/kdelibs/default.nix5
-rw-r--r--pkgs/development/compilers/bigloo/default.nix130
-rw-r--r--pkgs/development/compilers/ghc-6.8/default.nix3
-rw-r--r--pkgs/development/compilers/ghc/boot.nix2
-rw-r--r--pkgs/development/compilers/ghc/createGhcWrapper/default.nix17
-rw-r--r--pkgs/development/compilers/ghcs/default.nix180
-rw-r--r--pkgs/development/compilers/ghcs/nix_ghc_pkg_tool.hs48
-rw-r--r--pkgs/development/compilers/ghcs/splitpackagedb.hs25
-rw-r--r--pkgs/development/compilers/gwt/builder.sh33
-rw-r--r--pkgs/development/compilers/gwt/default.nix14
-rw-r--r--pkgs/development/compilers/jdk/jdk5-sun-linux.nix2
-rw-r--r--pkgs/development/compilers/jdk/jdk6-linux.nix10
-rw-r--r--pkgs/development/compilers/ocaml/default.nix4
-rw-r--r--pkgs/development/compilers/roadsend/default.nix33
-rw-r--r--pkgs/development/guile-modules/guile-lib/default.nix38
-rw-r--r--pkgs/development/interpreters/guile/default.nix28
-rw-r--r--pkgs/development/interpreters/guile/setup-hook.sh8
-rw-r--r--pkgs/development/interpreters/perl/perl-5.10.nix21
-rw-r--r--pkgs/development/interpreters/perl/setup-hook.sh2
-rw-r--r--pkgs/development/interpreters/php_configurable/default.nix3
-rw-r--r--pkgs/development/interpreters/python/2.5/setup-hook.sh2
-rw-r--r--pkgs/development/libraries/aspell/default.nix14
-rw-r--r--pkgs/development/libraries/aspell/dict-path.patch30
-rw-r--r--pkgs/development/libraries/aspell/dictionaries.nix17
-rw-r--r--pkgs/development/libraries/aterm/2.4.2-fixes.nix1
-rw-r--r--pkgs/development/libraries/fcgi/default.nix18
-rw-r--r--pkgs/development/libraries/ffmpeg_svn_snapshot/default.nix11
-rw-r--r--pkgs/development/libraries/gettext/0.14.6.nix9
-rw-r--r--pkgs/development/libraries/gettext/0.15.nix9
-rw-r--r--pkgs/development/libraries/gettext/0.17.nix9
-rw-r--r--pkgs/development/libraries/glibc-2.7/glibc-getcwd-param-MAX.patch14
-rw-r--r--pkgs/development/libraries/glibc-2.7/glibc-pwd.patch74
-rw-r--r--pkgs/development/libraries/gpgme/default.nix2
-rw-r--r--pkgs/development/libraries/gstreamer/default.nix13
-rw-r--r--pkgs/development/libraries/gstreamer/gst-plugins-base/0.10.17.nix24
-rw-r--r--pkgs/development/libraries/gstreamer/gst-plugins-good/0.10.6.nix23
-rw-r--r--pkgs/development/libraries/gstreamer/gst-plugins-good/tag_defines.patch22
-rw-r--r--pkgs/development/libraries/gstreamer/gstreamer/0.10.17.nix20
-rw-r--r--pkgs/development/libraries/gtk-libs/2.6/atk/default.nix13
-rw-r--r--pkgs/development/libraries/gtk-libs/2.6/default.nix23
-rw-r--r--pkgs/development/libraries/gtk-libs/2.6/glib/default.nix12
-rw-r--r--pkgs/development/libraries/gtk-libs/2.6/glibmm/default.nix12
-rw-r--r--pkgs/development/libraries/gtk-libs/2.6/gtk+/default.nix21
-rw-r--r--pkgs/development/libraries/gtk-libs/2.6/gtkmm/default.nix12
-rw-r--r--pkgs/development/libraries/gtk-libs/2.6/pango/default.nix14
-rw-r--r--pkgs/development/libraries/gtk-libs/2.8/atk/default.nix13
-rw-r--r--pkgs/development/libraries/gtk-libs/2.8/default.nix26
-rw-r--r--pkgs/development/libraries/gtk-libs/2.8/glib/default.nix13
-rw-r--r--pkgs/development/libraries/gtk-libs/2.8/glibmm/default.nix12
-rw-r--r--pkgs/development/libraries/gtk-libs/2.8/gtk+/default.nix22
-rw-r--r--pkgs/development/libraries/gtk-libs/2.8/gtkmm/default.nix12
-rw-r--r--pkgs/development/libraries/gtk-libs/2.8/pango/default.nix13
-rw-r--r--pkgs/development/libraries/libao/default.nix19
-rw-r--r--pkgs/development/libraries/libdv/default.nix28
-rw-r--r--pkgs/development/libraries/libeXosip2/3.0.3.nix13
l---------pkgs/development/libraries/libeXosip2/result1
-rw-r--r--pkgs/development/libraries/libexif/default.nix7
-rw-r--r--pkgs/development/libraries/libexif/no-po.patch20
-rw-r--r--pkgs/development/libraries/libgphoto2/default.nix5
-rw-r--r--pkgs/development/libraries/libgphoto2/libgphoto2-2.2.1.patch14
-rw-r--r--pkgs/development/libraries/libid3tag/default.nix17
-rw-r--r--pkgs/development/libraries/libjingle/0.3.11.nix10
-rw-r--r--pkgs/development/libraries/libjingle/0.4.0.nix10
-rw-r--r--pkgs/development/libraries/libmad/default.nix11
-rw-r--r--pkgs/development/libraries/liboil/0.3.12.nix20
-rw-r--r--pkgs/development/libraries/liboop/default.nix17
-rw-r--r--pkgs/development/libraries/libosip2/3.0.3-2.nix12
-rw-r--r--pkgs/development/libraries/libsigsegv/2.5.nix2
-rw-r--r--pkgs/development/libraries/libxslt/default.nix8
-rw-r--r--pkgs/development/libraries/ncurses/5.6.nix22
-rw-r--r--pkgs/development/libraries/ncurses/default.nix19
-rw-r--r--pkgs/development/libraries/qt-4/default.nix6
-rw-r--r--pkgs/development/libraries/sqlite/3.5.6.nix18
-rw-r--r--pkgs/development/libraries/sqlite/default.nix (renamed from pkgs/development/libraries/sqlite/3.3.13.nix)0
-rw-r--r--pkgs/development/perl-modules/DB_File/default.nix11
-rw-r--r--pkgs/development/perl-modules/DB_File/hook.sh11
-rw-r--r--pkgs/development/tools/build-managers/cmake/2.4.7.nix3
-rw-r--r--pkgs/development/tools/build-managers/cmake/2.4.8.nix3
-rw-r--r--pkgs/development/tools/build-managers/cmake/common.nix19
-rw-r--r--pkgs/development/tools/build-managers/cmake/default.nix20
-rwxr-xr-xpkgs/development/tools/build-managers/cmake/setup-hook.sh48
-rw-r--r--pkgs/development/tools/build-managers/gnumake/log.patch27
-rw-r--r--pkgs/development/tools/guile/guile-lint/default.nix26
-rw-r--r--pkgs/development/tools/misc/automake/setup-hook.sh2
-rw-r--r--pkgs/development/tools/misc/elfutils/0.127.nix1
-rw-r--r--pkgs/development/tools/misc/elfutils/0.131.nix2
-rw-r--r--pkgs/development/tools/misc/hasktags/default.nix24
-rw-r--r--pkgs/development/tools/misc/libtool/default.nix8
-rw-r--r--pkgs/development/tools/misc/pkgconfig/setup-hook.sh2
-rw-r--r--pkgs/development/tools/parsing/flex-iputils/builder.sh10
-rw-r--r--pkgs/development/tools/parsing/flex-iputils/default.nix13
-rw-r--r--pkgs/development/tools/parsing/flex-iputils/flex-new.nix16
-rw-r--r--pkgs/development/tools/parsing/flex/flex-2.5.34.nix19
-rw-r--r--pkgs/games/wesnoth/default.nix4
-rw-r--r--pkgs/lib/annotatedDerivations.nix56
-rw-r--r--pkgs/lib/default-unstable.nix478
-rw-r--r--pkgs/lib/default.nix4
-rw-r--r--pkgs/misc/emulators/wine/default.nix22
-rw-r--r--pkgs/misc/emulators/wine/opengl-child-window.patch1286
-rw-r--r--pkgs/misc/ntfs-3g/default.nix4
-rw-r--r--pkgs/misc/screensavers/xlockmore/default.nix30
-rw-r--r--pkgs/misc/screensavers/xlockmore/makefile-libcrypt.patch11
-rw-r--r--pkgs/os-specific/linux/alsa/1.0.14.nix14
-rw-r--r--pkgs/os-specific/linux/alsa/1.0.16.nix14
-rw-r--r--pkgs/os-specific/linux/alsa/common.nix13
-rw-r--r--pkgs/os-specific/linux/alsa/library/default.nix13
-rw-r--r--pkgs/os-specific/linux/alsa/utils/default.nix14
-rw-r--r--pkgs/os-specific/linux/aufs/default.nix13
-rw-r--r--pkgs/os-specific/linux/bridge_utils/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/default.nix19
-rw-r--r--pkgs/os-specific/linux/firmware/zd1211/default.nix21
-rw-r--r--pkgs/os-specific/linux/iptables/1.4.0.nix29
-rw-r--r--pkgs/os-specific/linux/iptables/default.nix10
-rw-r--r--pkgs/os-specific/linux/kernel/2.6.20.nix37
-rw-r--r--pkgs/os-specific/linux/kernel/2.6.21-ck.nix13
-rw-r--r--pkgs/os-specific/linux/kernel/2.6.21.nix45
-rw-r--r--pkgs/os-specific/linux/kernel/2.6.22-ck.nix13
-rw-r--r--pkgs/os-specific/linux/kernel/2.6.22.nix25
-rw-r--r--pkgs/os-specific/linux/kernel/2.6.23.1.nix38
-rw-r--r--pkgs/os-specific/linux/kernel/2.6.23.12.nix38
-rw-r--r--pkgs/os-specific/linux/kernel/2.6.23.16.nix39
-rw-r--r--pkgs/os-specific/linux/kernel/2.6.23.nix17
-rw-r--r--pkgs/os-specific/linux/kernel/builder.sh3
-rw-r--r--pkgs/os-specific/linux/kernel/default.nix32
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.20.nix76
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.21.nix76
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.22.nix (renamed from pkgs/os-specific/linux/kernel/meta.nix)46
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.23.nix84
-rw-r--r--pkgs/os-specific/linux/ndiswrapper/default.nix2
-rw-r--r--pkgs/os-specific/linux/reiserfsprogs/default.nix1
-rw-r--r--pkgs/os-specific/linux/reiserfsprogs/headers-fix.patch19
-rw-r--r--pkgs/servers/ftp/vsftpd/default.nix2
-rw-r--r--pkgs/servers/http/tomcat/axis2/builder.sh9
-rw-r--r--pkgs/servers/samba/default.nix9
-rw-r--r--pkgs/servers/samba/smb.conf271
-rw-r--r--pkgs/servers/sql/mysql5/default.nix7
-rwxr-xr-xpkgs/servers/sql/postgresql/builder.sh10
-rw-r--r--pkgs/servers/sql/postgresql/default.nix25
-rw-r--r--pkgs/servers/x11/xorg/builder.sh10
-rw-r--r--pkgs/stdenv/generic/builder.sh8
-rw-r--r--pkgs/stdenv/generic/setup.sh214
-rw-r--r--pkgs/tools/X11/x11vnc/0.9.3.nix27
-rw-r--r--pkgs/tools/misc/mc/default.nix1
-rw-r--r--pkgs/tools/misc/relfs/cvs.2007.12.01.nix18
-rw-r--r--pkgs/tools/networking/lsh/default.nix17
-rw-r--r--pkgs/tools/networking/p2p/ktorrent/default.nix14
-rw-r--r--pkgs/tools/networking/vpnc/builder.sh9
-rw-r--r--pkgs/tools/networking/vpnc/default.nix20
-rw-r--r--pkgs/tools/networking/vpnc/makefile.patch22
-rw-r--r--pkgs/tools/package-management/snix/default.nix36
-rw-r--r--pkgs/tools/security/gnupg/builder.sh10
-rw-r--r--pkgs/tools/security/gnupg/default.nix (renamed from pkgs/tools/security/gnupg/1.4.8.nix)27
-rw-r--r--pkgs/tools/security/gnupg/idea.patch25
-rw-r--r--pkgs/tools/security/gnupg2/default.nix (renamed from pkgs/tools/security/gnupg/2.0.8.nix)15
-rw-r--r--pkgs/tools/system/which/default.nix6
-rwxr-xr-xpkgs/tools/typesetting/lout/builder.sh42
-rw-r--r--pkgs/tools/typesetting/lout/default.nix20
-rw-r--r--pkgs/top-level/all-packages.nix868
-rw-r--r--pkgs/top-level/build-for-release.nix286
-rw-r--r--pkgs/top-level/builder-defs.nix5
227 files changed, 3908 insertions, 3570 deletions
diff --git a/pkgs/applications/audio/GStreamer/default.nix b/pkgs/applications/audio/GStreamer/default.nix
new file mode 100644
index 00000000000..0239b29f7ee
--- /dev/null
+++ b/pkgs/applications/audio/GStreamer/default.nix
@@ -0,0 +1,13 @@
+{stdenv, fetchurl, perl
+, bison, flex, glib
+, pkgconfig, libxml2}:
+
+stdenv.mkDerivation {
+  name = "GStreamer-0.10.10";
+  src = fetchurl {
+    url = http://gstreamer.freedesktop.org/src/gstreamer/gstreamer-0.10.10.tar.bz2;
+    md5 = "6875bf0bd3cf38b9ae1362b9e644e6fc";
+  };
+
+  buildInputs = [perl bison flex glib pkgconfig libxml2];
+}
diff --git a/pkgs/applications/audio/aumix/default.nix b/pkgs/applications/audio/aumix/default.nix
new file mode 100644
index 00000000000..57c690fee9b
--- /dev/null
+++ b/pkgs/applications/audio/aumix/default.nix
@@ -0,0 +1,24 @@
+{stdenv, fetchurl, gettext, ncurses
+, gtkGUI ? false
+, pkgconfig ? null
+, gtk ? null}:
+
+assert gtkGUI -> pkgconfig != null && gtk != null;
+
+stdenv.mkDerivation {
+  name = "aumix-2.8";
+  src = fetchurl {
+    url = http://www.jpj.net/~trevor/aumix/aumix-2.8.tar.bz2;
+    sha256 = "636eef7f400c2f3df489c0d2fa21507e88692113561e75a40a26c52bc422d7fc";
+  };
+
+  buildInputs = [ gettext ncurses ]
+    ++ (if gtkGUI then [pkgconfig gtk] else []);
+
+  meta = {
+    description = ''Aumix adjusts an audio mixer from X, the console,
+    		    a terminal, the command line or a script.'';
+    homepage = http://www.jpj.net/~trevor/aumix.html;
+    license = "GPL";
+  };
+}
diff --git a/pkgs/applications/audio/mpg321/default.nix b/pkgs/applications/audio/mpg321/default.nix
new file mode 100644
index 00000000000..23cc92132b9
--- /dev/null
+++ b/pkgs/applications/audio/mpg321/default.nix
@@ -0,0 +1,17 @@
+{stdenv, fetchurl, libao, libmad, libid3tag, zlib}:
+
+stdenv.mkDerivation {
+  name = "mpg321-0.2.10";
+  src = fetchurl {
+    url = mirror://sourceforge/mpg321/mpg321-0.2.10.tar.gz;
+    sha256 = "db0c299592b8f1f704f41bd3fc3a2bf138658108588d51af61638c551af1b0d4";
+  };
+
+  buildInputs = [libao libid3tag libmad zlib];
+
+  meta = {
+    description = "Command-line MP3 player.";
+    homepage = http://mpg321.sourceforge.net/;
+    license = "GPLv2";
+  };
+}
diff --git a/pkgs/applications/audio/vorbis-tools/default.nix b/pkgs/applications/audio/vorbis-tools/default.nix
new file mode 100644
index 00000000000..626dc1c9d96
--- /dev/null
+++ b/pkgs/applications/audio/vorbis-tools/default.nix
@@ -0,0 +1,24 @@
+{stdenv, fetchurl, libogg, libvorbis, libao, pkgconfig, curl, glibc
+, speex, flac}:
+
+stdenv.mkDerivation {
+  name = "vorbis-tools-1.1.1";
+  src = fetchurl {
+    url = http://downloads.xiph.org/releases/vorbis/vorbis-tools-1.1.1.tar.gz;
+    sha256 = "617b4aa69e600c215b34fa3fd5764bc1d9d205d9d7d9fe7812bde7ec956fcaad";
+  };
+
+  # FIXME: Vorbis-tools expects `libOggFLAC', but this library was
+  # merged with `libFLAC' as of FLAC 1.1.3.
+  buildInputs = [ libogg libvorbis libao pkgconfig curl speex glibc flac ];
+
+  patches = [ ./ogg123-curlopt-mute.patch ];
+
+  meta = {
+    description = ''A set of command-line tools to manipulate Ogg Vorbis
+                    audio files, notably the `ogg123' player and the
+		    `oggenc' encoder.'';
+    homepage = http://xiph.org/vorbis/;
+    license = "GPLv2";
+  };
+}
diff --git a/pkgs/applications/audio/vorbis-tools/ogg123-curlopt-mute.patch b/pkgs/applications/audio/vorbis-tools/ogg123-curlopt-mute.patch
new file mode 100644
index 00000000000..6437909411e
--- /dev/null
+++ b/pkgs/applications/audio/vorbis-tools/ogg123-curlopt-mute.patch
@@ -0,0 +1,13 @@
+--- vorbis-tools-1.1.1/ogg123/http_transport.c	2005-06-13 15:11:44.000000000 +0200
++++ vorbis-tools-1.1.1/ogg123/http_transport.c	2008-02-12 18:38:41.000000000 +0100
+@@ -116,7 +116,9 @@ void set_curl_opts (http_private_t *priv
+   if (inputOpts.ProxyTunnel)
+     curl_easy_setopt (handle, CURLOPT_HTTPPROXYTUNNEL, inputOpts.ProxyTunnel);
+   */
++#ifdef CURLOPT_MUTE
+   curl_easy_setopt(handle, CURLOPT_MUTE, 1);
++#endif
+   curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, private->error);
+   curl_easy_setopt(handle, CURLOPT_PROGRESSFUNCTION, progress_callback);
+   curl_easy_setopt(handle, CURLOPT_PROGRESSDATA, private);
+
diff --git a/pkgs/applications/editors/emacs-22/default.nix b/pkgs/applications/editors/emacs-22/default.nix
index 0af6f95a344..d527e305154 100644
--- a/pkgs/applications/editors/emacs-22/default.nix
+++ b/pkgs/applications/editors/emacs-22/default.nix
@@ -14,12 +14,13 @@ assert gtkGUI -> pkgconfig != null && gtk != null;
 
 stdenv.mkDerivation {
   name = "emacs-22.1";
+
   builder = ./builder.sh;
   src = fetchurl {
     url = mirror://gnu/emacs/emacs-22.1.tar.gz;
     sha256 = "1l1y3il98pq3cz464p244wz2d3nga5lq8fkw5pwp5r97f7pkpi0y";
   };
-  patches = [./crt.patch];
+  patches = [./crt.patch ./makefile-pwd.patch];
   buildInputs = [
     ncurses x11
     (if xawSupport then if xaw3dSupport then Xaw3d else libXaw else null)
diff --git a/pkgs/applications/editors/emacs-22/makefile-pwd.patch b/pkgs/applications/editors/emacs-22/makefile-pwd.patch
new file mode 100644
index 00000000000..232b881c9a6
--- /dev/null
+++ b/pkgs/applications/editors/emacs-22/makefile-pwd.patch
@@ -0,0 +1,129 @@
+--- emacs-22.1/Makefile.in	2008-02-10 23:56:29.000000000 +0100
++++ emacs-22.1/Makefile.in	2008-02-10 23:55:55.000000000 +0100
+@@ -420,7 +420,7 @@
+ 	-set ${COPYDESTS} ; \
+ 	unset CDPATH; \
+ 	for dir in ${COPYDIR} ; do \
+-	  if [ `(cd $$1 && /bin/pwd)` != `(cd $${dir} && /bin/pwd)` ] ; then \
++	  if [ `(cd $$1 && pwd)` != `(cd $${dir} && pwd)` ] ; then \
+ 	    rm -rf $$1 ; \
+ 	  fi ; \
+ 	  shift ; \
+@@ -432,7 +432,7 @@
+ 	for dir in ${COPYDIR} ; do \
+ 	  dest=$$1 ; shift ; \
+ 	  [ -d $${dir} ] \
+-	  && [ `(cd $${dir} && /bin/pwd)` != `(cd $${dest} && /bin/pwd)` ] \
++	  && [ `(cd $${dir} && pwd)` != `(cd $${dest} && pwd)` ] \
+ 	  && (echo "Copying $${dir} to $${dest}..." ; \
+ 	      (cd $${dir}; tar -chf - . ) \
+ 		| (cd $${dest}; umask 022; \
+@@ -472,7 +472,7 @@
+ 	fi
+ 	-chmod a+r $(DESTDIR)${datadir}/emacs/site-lisp/subdirs.el
+ 	-unset CDPATH; \
+-	if [ `(cd ./etc; /bin/pwd)` != `(cd $(DESTDIR)${docdir}; /bin/pwd)` ]; \
++	if [ `(cd ./etc; pwd)` != `(cd $(DESTDIR)${docdir}; pwd)` ]; \
+ 	then \
+ 	   echo "Copying etc/DOC-* to $(DESTDIR)${docdir} ..." ; \
+ 	   (cd ./etc; tar -chf - DOC*) \
+@@ -483,8 +483,8 @@
+ 	-unset CDPATH; \
+ 	if [ -r ./lisp ] \
+ 	   && [ -r ./lisp/simple.el ] \
+-	   && [ x`(cd ./lisp; /bin/pwd)` != x`(cd $(DESTDIR)${lispdir}; /bin/pwd)` ] \
+-	   && [ x`(cd ${srcdir}/lisp; /bin/pwd)` != x`(cd ./lisp; /bin/pwd)` ]; \
++	   && [ x`(cd ./lisp; pwd)` != x`(cd $(DESTDIR)${lispdir}; pwd)` ] \
++	   && [ x`(cd ${srcdir}/lisp; pwd)` != x`(cd ./lisp; pwd)` ]; \
+ 	then \
+ 	   echo "Copying lisp/*.el and lisp/*.elc to $(DESTDIR)${lispdir} ..." ; \
+ 	   (cd lisp; tar -chf - *.el *.elc) \
+@@ -500,8 +500,8 @@
+ 	    done) \
+ 	else true; fi
+ 	-unset CDPATH; \
+-	thisdir=`/bin/pwd`; \
+-	if [ `(cd ${srcdir}/info && /bin/pwd)` != `(cd $(DESTDIR)${infodir} && /bin/pwd)` ]; \
++	thisdir=`pwd`; \
++	if [ `(cd ${srcdir}/info && pwd)` != `(cd $(DESTDIR)${infodir} && pwd)` ]; \
+ 	then \
+ 	  (cd $(DESTDIR)${infodir};  \
+ 	   if [ -f dir ]; then true; \
+@@ -519,8 +519,8 @@
+ 	   done); \
+ 	else true; fi
+ 	-unset CDPATH; \
+-	thisdir=`/bin/pwd`; \
+-	if [ `(cd ${srcdir}/info && /bin/pwd)` != `(cd $(DESTDIR)${infodir} && /bin/pwd)` ]; \
++	thisdir=`pwd`; \
++	if [ `(cd ${srcdir}/info && pwd)` != `(cd $(DESTDIR)${infodir} && pwd)` ]; \
+ 	then \
+ 	  for elt in $(INFO_FILES); do \
+ 	    (cd $${thisdir}; \
+@@ -528,7 +528,7 @@
+ 	  done; \
+ 	else true; fi
+ 	-chmod -R a+r $(DESTDIR)${datadir}/emacs/${version} $(DESTDIR)${datadir}/emacs/site-lisp ${COPYDESTS} $(DESTDIR)${infodir}
+-	thisdir=`/bin/pwd`; \
++	thisdir=`pwd`; \
+ 	cd ${srcdir}/etc; \
+ 	for page in emacs emacsclient etags ctags ; do \
+ 	  (cd $${thisdir}; \
+@@ -575,8 +575,8 @@
+ 	-unset CDPATH; \
+ 	for dir in $(DESTDIR)${lispdir} $(DESTDIR)${etcdir} ; do 	\
+ 	  if [ -d $${dir} ]; then			\
+-	    case `(cd $${dir} ; /bin/pwd)` in		\
+-	      `(cd ${srcdir} ; /bin/pwd)`* ) ;;		\
++	    case `(cd $${dir} ; pwd)` in		\
++	      `(cd ${srcdir} ; pwd)`* ) ;;		\
+ 	      * ) rm -rf $${dir} ;;			\
+ 	    esac ;					\
+ 	    case $${dir} in				\
+--- emacs-22.1/leim/Makefile.in	2008-02-10 23:55:31.000000000 +0100
++++ emacs-22.1/leim/Makefile.in	2008-02-10 23:55:41.000000000 +0100
+@@ -207,7 +207,7 @@
+ leim-list.el: ${SUBDIRS} ${TIT-MISC} changed.tit changed.misc ${srcdir}/leim-ext.el
+ 	${RUN-EMACS}  -l ${buildlisppath}/international/quail \
+ 	  -f batch-byte-compile-if-not-done ${TIT-MISC:.elc=.el}
+-	if [ x`(cd ${srcdir} && /bin/pwd)` = x`(/bin/pwd)` ] ; then \
++	if [ x`(cd ${srcdir} && pwd)` = x`(pwd)` ] ; then \
+ 	  ${RUN-EMACS} -l ${buildlisppath}/international/quail \
+ 	    --eval "(update-leim-list-file \".\")" ; \
+ 	else \
+@@ -220,11 +220,11 @@
+ 	if [ ! -d ${INSTALLDIR} ] ; then \
+           ${srcdir}/${dot}${dot}/mkinstalldirs ${INSTALLDIR}; \
+ 	else true; fi
+-	if [ x`(cd ${INSTALLDIR} && /bin/pwd)` != x`(/bin/pwd)` ] ; then \
++	if [ x`(cd ${INSTALLDIR} && pwd)` != x`(pwd)` ] ; then \
+ 	  rm -rf ${INSTALLDIR}/leim-list.el; \
+ 	  rm -rf ${INSTALLDIR}/quail ${INSTALLDIR}/ja-dic ; \
+ 	  echo "Copying leim files to ${INSTALLDIR} ..." ; \
+-	  if [ x`(cd ${srcdir} && /bin/pwd)` = x`(/bin/pwd)` ] ; then \
++	  if [ x`(cd ${srcdir} && pwd)` = x`(pwd)` ] ; then \
+ 	    tar -chf - leim-list.el quail ja-dic \
+ 		| (cd ${INSTALLDIR}; umask 0; tar -xvf - && cat > /dev/null) ;\
+ 	  else \
+--- emacs-22.1/lib-src/Makefile.in	2008-02-10 23:59:08.000000000 +0100
++++ emacs-22.1/lib-src/Makefile.in	2008-02-10 23:59:13.000000000 +0100
+@@ -306,7 +306,7 @@
+ 	@echo
+ 	@echo "Installing utilities run internally by Emacs."
+ 	$(top_srcdir)/mkinstalldirs $(DESTDIR)${archlibdir}
+-	if [ `(cd $(DESTDIR)${archlibdir} && /bin/pwd)` != `/bin/pwd` ]; then \
++	if [ `(cd $(DESTDIR)${archlibdir} && pwd)` != `pwd` ]; then \
+ 	  for file in ${UTILITIES}; do \
+ 	    $(INSTALL_PROGRAM) $(INSTALL_STRIP) $$file $(DESTDIR)${archlibdir}/$$file ; \
+ 	  done ; \
+@@ -321,8 +321,8 @@
+ 	  chown ${gameuser} $(DESTDIR)${gamedir}; \
+ 	  chmod u=rwx,g=rwx,o=rx $(DESTDIR)${gamedir}; \
+ 	fi
+-        if [ `(cd $(DESTDIR)${archlibdir} && /bin/pwd)` \
+-             != `(cd ${srcdir} && /bin/pwd)` ]; then \
++        if [ `(cd $(DESTDIR)${archlibdir} && pwd)` \
++             != `(cd ${srcdir} && pwd)` ]; then \
+ 	  for file in ${SCRIPTS}; do \
+ 	    $(INSTALL_SCRIPT) ${srcdir}/$$file $(DESTDIR)${archlibdir}/$$file; \
+ 	  done ; \
diff --git a/pkgs/applications/editors/emacs-modes/bbdb/builder.sh b/pkgs/applications/editors/emacs-modes/bbdb/builder.sh
new file mode 100644
index 00000000000..b860adbb745
--- /dev/null
+++ b/pkgs/applications/editors/emacs-modes/bbdb/builder.sh
@@ -0,0 +1,12 @@
+source "$stdenv/setup" || exit 1
+
+unpackPhase &&							\
+cd bbdb-*.* && patchPhase &&					\
+./configure --prefix="$out"					\
+            --with-package-dir="$out/share/emacs/site-lisp" &&	\
+make && make install-pkg &&					\
+mkdir -p "$out/info" &&						\
+make -C texinfo install-pkg &&					\
+mv "$out/share/emacs/site-lisp/lisp/bbdb/"*			\
+   "$out/share/emacs/site-lisp" &&				\
+rm -rf "$out/share/emacs/site-lisp/lisp"
diff --git a/pkgs/applications/editors/emacs-modes/bbdb/default.nix b/pkgs/applications/editors/emacs-modes/bbdb/default.nix
new file mode 100644
index 00000000000..3799d0a0f1b
--- /dev/null
+++ b/pkgs/applications/editors/emacs-modes/bbdb/default.nix
@@ -0,0 +1,22 @@
+{stdenv, fetchurl, emacs, texinfo, ctags}:
+
+stdenv.mkDerivation {
+  name = "bbdb-2.35";
+
+  src = fetchurl {
+    url = http://bbdb.sourceforge.net/bbdb-2.35.tar.gz;
+    sha256 = "3fb1316e2ed74d47ca61187fada550e58797467bd9e8ad67343ed16da769f916";
+  };
+
+  patches = [ ./install-infodir.patch ];
+
+  buildInputs = [emacs texinfo ctags];
+  builder = ./builder.sh;
+
+  meta = {
+    description = ''The Insidious Big Brother Database (BBDB), a
+                    contact management utility for Emacs.'';
+    homepage = http://bbdb.sourceforge.net/;
+    license = "GPL";
+  };
+}
diff --git a/pkgs/applications/editors/emacs-modes/bbdb/install-infodir.patch b/pkgs/applications/editors/emacs-modes/bbdb/install-infodir.patch
new file mode 100644
index 00000000000..31ae6b26698
--- /dev/null
+++ b/pkgs/applications/editors/emacs-modes/bbdb/install-infodir.patch
@@ -0,0 +1,28 @@
+--- bbdb-2.35/texinfo/Makefile.in	2001-11-20 09:00:12.000000000 +0100
++++ bbdb-2.35/texinfo/Makefile.in	2008-02-20 12:07:36.000000000 +0100
+@@ -27,22 +27,22 @@ all: info bbdb.dvi
+ install-pkg: uninstall-pkg info
+ 	@if test "x$(SYMLINKS)" = "xno" ; then                         \
+           for i in `ls bbdb.info* ` ; do                               \
+-            $(INSTALL_DATA) $$i $(PACKAGEDIR)/info/ ;                  \
++            $(INSTALL_DATA) $$i $(infodir)/ ;                  \
+           done ;                                                       \
+         else                                                           \
+           if test "x$(LINKPATH)" = "x" ; then                          \
+             for i in `ls bbdb.info* ` ; do                             \
+-              $(LN_S) `pwd`/$$i $(PACKAGEDIR)/info/$$i ;               \
++              $(LN_S) `pwd`/$$i $(infodir)/$$i ;               \
+             done ;                                                     \
+           else                                                         \
+             for i in `ls bbdb.info* ` ; do                             \
+-              $(LN_S) $(LINKPATH)/texinfo/$$i $(PACKAGEDIR)/info/$$i ; \
++              $(LN_S) $(LINKPATH)/texinfo/$$i $(infodir)/$$i ; \
+             done ;                                                     \
+           fi ;                                                         \
+         fi
+ 
+ uninstall-pkg:
+-	-$(RM) $(PACKAGEDIR)/info/bbdb.info*
++	-$(RM) $(infodir)/bbdb.info*
+ 
+ info: bbdb.info
diff --git a/pkgs/applications/editors/nano/default.nix b/pkgs/applications/editors/nano/default.nix
index a0eee03c477..5e89d8a5bcd 100644
--- a/pkgs/applications/editors/nano/default.nix
+++ b/pkgs/applications/editors/nano/default.nix
@@ -1,15 +1,29 @@
-{stdenv, fetchurl, ncurses, gettext}:
+args: with args;
+stdenv.mkDerivation (rec {
+  pname = "nano";
+  version = "2.0.7";
+
+  name = "${pname}-${version}";
 
-stdenv.mkDerivation {
-  name = "nano-2.0.6";
   src = fetchurl {
-    url = mirror://gnu/nano/nano-2.0.6.tar.gz;
-    sha256 = "0p2xfs4jzj7dvp208qdrxij7x8gbwxgnrdm7zafgpbbg1bvxh40d";
+    url = "mirror://gnu/nano/${name}.tar.gz";
+    sha256 = "5dc783c412c4d1ff463c450d2a2f9e1ea53a43d9ba1dda92bbf5182f60db532f";
   };
   buildInputs = [ncurses gettext];
-  configureFlags = "--enable-tiny";
+#  configureFlags = "--enable-tiny";
+  configureFlags = "
+    --disable-browser 
+    --disable-help 
+    --disable-justify 
+    --disable-mouse 
+    --disable-operatingdir
+    --disable-speller
+    --disable-tabcomp
+    --disable-wrapping
+  ";
 
   meta = {
-    homepage = http://www.nano-editor.org;
+    homepage = http://www.nano-editor.org/;
+    description = "A small, user-friendly console text editor";
   };
-}
+})
diff --git a/pkgs/applications/graphics/exrdisplay/default.nix b/pkgs/applications/graphics/exrdisplay/default.nix
index c4054e687f9..f82f07602f8 100644
--- a/pkgs/applications/graphics/exrdisplay/default.nix
+++ b/pkgs/applications/graphics/exrdisplay/default.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation {
 
   buildInputs = [openexr fltk pkgconfig mesa which openexr_ctl];
 
-  meta = {
+  meta = { 
       description = "tool to view OpenEXR images";
       homepage = http://openexr.com;
       license = "BSD-like";
diff --git a/pkgs/applications/graphics/xara/default.nix b/pkgs/applications/graphics/xara/default.nix
index e2fdd33c1a6..89ba789524f 100644
--- a/pkgs/applications/graphics/xara/default.nix
+++ b/pkgs/applications/graphics/xara/default.nix
@@ -7,7 +7,7 @@ stdenv.mkDerivation {
     url = http://downloads2.xara.com/opensource/XaraLX-0.7r1766.tar.bz2;
     sha256 = "1rcl7hqvcai586jky7hvzxhnq8q0ka2rsmgiq5ijwclgr5d4ah7n";
   };
-
+    
   buildInputs = [automake autoconf gettext libtool cvs wxGTK gtk pkgconfig libxml2 zip libpng libjpeg shebangfix perl];
 
   inherit freetype libpng libjpeg libxml2;
diff --git a/pkgs/applications/misc/fetchmail/default.nix b/pkgs/applications/misc/fetchmail/default.nix
index f62267c10d6..9639ff19fb0 100644
--- a/pkgs/applications/misc/fetchmail/default.nix
+++ b/pkgs/applications/misc/fetchmail/default.nix
@@ -8,10 +8,6 @@ stdenv.mkDerivation {
 
   patches = [ ./security-fix.patch ];
 
-  configureFlags = "--enable-fallback=procmail --with-ssl=${openssl}";
-
-  buildInputs = [ openssl python procmail ];
-
   meta = {
     homepage = http://www.fetchmail.info;
   };
diff --git a/pkgs/applications/misc/gkrellm/default.nix b/pkgs/applications/misc/gkrellm/default.nix
new file mode 100644
index 00000000000..ae5386dcd1e
--- /dev/null
+++ b/pkgs/applications/misc/gkrellm/default.nix
@@ -0,0 +1,33 @@
+args: with args;
+
+stdenv.mkDerivation {
+  name = "gkrellm-2.3.1";
+  src = fetchurl {
+    url = http://members.dslextreme.com/users/billw/gkrellm/gkrellm-2.3.1.tar.bz2;
+    sha256 = "1a2a7e3ee9d1f2d7305da0d33d9be71ffe5d1903ed6a9c69cf77ffe10fc95b4d";
+  };
+
+  buildInputs = [gettext pkgconfig glib gtk libX11 libSM libICE];
+
+  # Makefiles are patched to fix references to `/usr/X11R6' and to add
+  # `-lX11' to make sure libX11's store path is in the RPATH.
+  patchPhase = ''
+     echo "patching makefiles..."
+     for i in Makefile src/Makefile server/Makefile
+     do
+       cat "$i" | sed -e "s|/usr/X11R6|${libX11}|g ;
+                          s|-lICE|-lX11 -lICE|g" > ",,tmp" &&	\
+       mv ",,tmp" "$i"
+     done '';
+
+  buildPhase = ''
+     make PREFIX="$out" '';
+  installPhase = ''
+     make install PREFIX="$out" '';
+
+  meta = {
+    description = "GKrellM, a themeable process stack of system monitors.";
+    homepage = http://members.dslextreme.com/users/billw/gkrellm/gkrellm.html;
+    license = "GPL";
+  };
+}
diff --git a/pkgs/applications/misc/pgadmin/default.nix b/pkgs/applications/misc/pgadmin/default.nix
index 4b43f4bc48c..624c1dfcb61 100644
--- a/pkgs/applications/misc/pgadmin/default.nix
+++ b/pkgs/applications/misc/pgadmin/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
 
   buildInputs = [postgresql wxGTK libxml2 libxslt openssl];
 
-  meta = {
+  meta = { 
       description = "postgresql admin gui tool";
       homepage = http://www.pgadmin.org;
       license = "GPL2";
diff --git a/pkgs/applications/misc/procmail/default.nix b/pkgs/applications/misc/procmail/default.nix
index 22bdeb56da8..50767a7dde8 100644
--- a/pkgs/applications/misc/procmail/default.nix
+++ b/pkgs/applications/misc/procmail/default.nix
@@ -1,13 +1,18 @@
 args: with args;
 stdenv.mkDerivation {
   name="procmail-3.22";
-  patchPhase = "find . -type f | xargs sed -i 's@/bin/rm@rm@g' ";
-  configurePhase= "make init";
-  makeFlags = ''BASENAME=$(out) LIBS=-lm'';
-
-  postInstall = '' sed -i /^PATH/d $out/bin/mailstat '';
+  buildInputs = [stdenv.gcc.libc];
+  installPhase = "
+    ensureDir \$out/bin
+    find . -exec sed -e \"s%^RM[ \\t]*=%RM=`type -f rm | awk '{print $3;}'`%\" -i '{}' ';'
+    sed -e 's%\\(LDFLAGS = \$(LDFLAGS1) -lnsl -ldl -lc\\)%\\1 -m%' -i src/Makefile
+    sed -e \"s%^BASENAME.*%\BASENAME=$out%\" -i Makefile
+    make DESTDIR=\$out install
+   ";
+  phases ="installPhase";
   src = fetchurl {
     url = ftp://ftp.fu-berlin.de/pub/unix/mail/procmail/procmail-3.22.tar.gz;
     sha256 = "05z1c803n5cppkcq99vkyd5myff904lf9sdgynfqngfk9nrpaz08";
   };
+  o=62;
 }
diff --git a/pkgs/applications/misc/rxvt_unicode/default.nix b/pkgs/applications/misc/rxvt_unicode/default.nix
index a44530987c4..6dc6e30b815 100644
--- a/pkgs/applications/misc/rxvt_unicode/default.nix
+++ b/pkgs/applications/misc/rxvt_unicode/default.nix
@@ -1,16 +1,20 @@
 args: with args;
-stdenv.mkDerivation {
-  name = "rxvt-unicode-8.9";
- 
-  buildInputs = [ libX11 libXt libXft perl ];
- 
-  src = fetchurl {
-    url = http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-8.9.tar.bz2;
-    sha256 = "89858c5bfe72dba037cd3435b2221269580f3c699553fe24ee468ddec8831d27";
+stdenv.mkDerivation (rec {
+  pname = "rxvt-unicode";
+  version = "9.02";
+
+  name = "${pname}-${version}";
+
+ src = fetchurl {
+    url = "http://dist.schmorp.de/rxvt-unicode/Attic/${name}.tar.bz2";
+    sha256 = "234b9a3e3f88c4984b1e909f8028638fc3b61d801d8afaa9cd08154b1a480a31";
   };
- 
+
+  buildInputs = [ libX11 libXt libXft ];
+  configureFlags = "--disable-perl";
+
   meta = {
     description = "rxvt-unicode is a clone of the well known terminal emulator rxvt.";
     homepage = "http://software.schmorp.de/pkg/rxvt-unicode.html";
   };
-}
+})
diff --git a/pkgs/applications/misc/wordnet/default.nix b/pkgs/applications/misc/wordnet/default.nix
new file mode 100644
index 00000000000..7300959fde7
--- /dev/null
+++ b/pkgs/applications/misc/wordnet/default.nix
@@ -0,0 +1,25 @@
+{stdenv, fetchurl, tcl, tk, x11, makeWrapper}:
+
+stdenv.mkDerivation {
+  name = "wordnet-3.0";
+  src = fetchurl {
+    url = http://wordnet.princeton.edu/3.0/WordNet-3.0.tar.bz2;
+    sha256 = "6c492d0c7b4a40e7674d088191d3aa11f373bb1da60762e098b8ee2dda96ef22";
+  };
+
+  buildInputs = [tcl tk x11 makeWrapper];
+
+  # Needs the path to `tclConfig.sh' and `tkConfig.sh'.
+  configureFlags = "--with-tcl=" + tcl + "/lib " +
+                   "--with-tk="  + tk  + "/lib";
+
+  postInstall = ''
+    wrapProgram $out/bin/wishwn --set TK_LIBRARY "${tk}/lib/tk8.4"
+    wrapProgram $out/bin/wnb    --prefix PATH : "$out/bin"
+  '';
+
+  meta = {
+    description = "WordNet, a lexical database for the English language.";
+    homepage = http://wordnet.princeton.edu/;
+  };
+}
diff --git a/pkgs/applications/misc/xterm/default.nix b/pkgs/applications/misc/xterm/default.nix
index 02ee7acf946..30b3e6cbda8 100644
--- a/pkgs/applications/misc/xterm/default.nix
+++ b/pkgs/applications/misc/xterm/default.nix
@@ -1,16 +1,13 @@
-args: with args;
+{stdenv, fetchurl, libXaw, xproto, libXt, libX11, libSM, libICE, ncurses}:
 
 stdenv.mkDerivation rec {
   name = "xterm-231";
   src = fetchurl {
     url = "ftp://invisible-island.net/xterm/${name}.tgz";
-	sha256 = "0qlz5nkdqkahdg9kbd1ni96n69srj1pd9yggwrw3z0kghaajb2sr";
+    sha256 = "0qlz5nkdqkahdg9kbd1ni96n69srj1pd9yggwrw3z0kghaajb2sr";
   };
-  buildInputs = [libXaw xproto libXt libXext libX11 libSM libICE ncurses
-    freetype pkgconfig libXft luit];
-  configureFlags = "--enable-wide-chars --enable-256-color
-    --enable-load-vt-fonts --enable-i18n --enable-doublechars --enable-luit
-    --enable-mini-luit";
+  buildInputs = [libXaw xproto libXt libX11 libSM libICE ncurses];
+  configureFlags = ["--enable-wide-chars"];
 
   meta = {
     homepage = http://invisible-island.net/xterm;
diff --git a/pkgs/applications/networking/browsers/firefox/default.nix b/pkgs/applications/networking/browsers/firefox/default.nix
index 17c26cf8f51..81545bc5bd1 100644
--- a/pkgs/applications/networking/browsers/firefox/default.nix
+++ b/pkgs/applications/networking/browsers/firefox/default.nix
@@ -10,12 +10,12 @@
 }:
 
 stdenv.mkDerivation {
-  name = "firefox-2.0.0.11";
+  name = "firefox-2.0.0.12";
 
   builder = ./builder.sh;
   src = fetchurl {
-    url = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/2.0.0.11/source/firefox-2.0.0.11-source.tar.bz2;
-    sha1 = "6d070bf04f1a037b621237d02ef9be7802a51bf1";
+    url = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/2.0.0.12/source/firefox-2.0.0.12-source.tar.bz2;
+    sha1 = "766f3e945145d9e4d36d5eb3e551b5eb44a1d862";
   };
 
   buildInputs = [
diff --git a/pkgs/applications/networking/browsers/firefox3b1/3b2.nix b/pkgs/applications/networking/browsers/firefox3b1/3b2.nix
deleted file mode 100644
index bf812f6a7ad..00000000000
--- a/pkgs/applications/networking/browsers/firefox3b1/3b2.nix
+++ /dev/null
@@ -1,57 +0,0 @@
-args: with args;
-
-stdenv.mkDerivation {
-  name = "firefox-3b2";
-
-  src = 
-	fetchurl {
-		url = ftp://ftp.mozilla.org/pub/firefox/releases/3.0b2/source/firefox-3.0b2-source.tar.bz2;
-		sha256 = "0mszad8j35wvzi67dp3j9sznqkgb9b3in22c5790g9b9pv6xk8jp";
-	};
-
-  buildInputs = [
-    pkgconfig gtk perl zip libIDL libXi libjpeg libpng zlib cairo
-    python curl coreutils dbus.libs dbus_glib pango freetype fontconfig
-    libX11 libXrender libXft libXt
-  ];
-
-  configureFlags = [
-    "--enable-application=browser"
-    "--enable-optimize"
-    "--disable-debug"
-    "--enable-xft"
-    "--disable-freetype2"
-    "--enable-svg"
-    "--enable-canvas"
-    "--enable-strip"
-    "--enable-default-toolkit=cairo-gtk2"
-    "--with-system-jpeg"
-    "--with-system-zlib"
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-*     "--enable-system-cairo"
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-  ]
-;
-
-  postInstall = "
-    export dontPatchELF=1;
-    sed -e 's@moz_libdir=.*@&\\nexport PATH=\$PATH:${coreutils}/bin@' -i \$out/bin/firefox 
-    sed -e 's@`/bin/pwd@`${coreutils}/bin/pwd@' -i \$out/bin/firefox 
-    sed -e 's@`/bin/ls@`${coreutils}/bin/ls@' -i \$out/bin/firefox 
-
-    strip -S \$out/lib/*/* || true
-
-    libDir=\$(cd \$out/lib && ls -d firefox-[0-9]*)
-    test -n \"\$libDir\"
-
-    echo \"running firefox -register...\"
-    (cd \$out/lib/\$libDir && LD_LIBRARY_PATH=. ./firefox-bin -register) || false
-  ";
-
-  meta = {
-    description = "Mozilla Firefox - the browser, reloaded";
-  };
-
-  passthru = {inherit gtk;};
-}
-
diff --git a/pkgs/applications/networking/browsers/firefox3b1/binary.nix b/pkgs/applications/networking/browsers/firefox3b1/binary.nix
deleted file mode 100644
index 73e002435b8..00000000000
--- a/pkgs/applications/networking/browsers/firefox3b1/binary.nix
+++ /dev/null
@@ -1,55 +0,0 @@
-args: with args;
-
-assert stdenv.system == "i686-linux";
-
-stdenv.mkDerivation {
-  name = "firefox-3b1";
-
-  src = 
-	fetchurl {
-		url = ftp://ftp.mozilla.org/pub/firefox/releases/3.0b1/linux-i686/en-US/firefox-3.0b1.tar.bz2;
-		sha256 = "1cpcc5b07zdqyd5kiwhb4dqhy2mzbf97plsglcp6bc9054cmsylk";
-	};
-  buildInputs = [
-    pkgconfig gtk perl zip libIDL libXi libjpeg libpng zlib cairo
-    python curl coreutils atk pango glib libX11 libXrender 
-    freetype fontconfig libXft libXt
-  ];
-
-  buildPhase = "
-    additionalRpath='';
-    for i in \$buildInputs ${stdenv.glibc} ${stdenv.gcc.gcc}; do 
-      additionalRpath=\$additionalRpath:\$i/lib;  
-    done
-    for i in firefox-bin ; do
-      oldrpath=$(patchelf --print-rpath \$i)
-      patchelf --set-rpath \$oldrpath\$additionalRpath \$i
-      patchelf --set-interpreter ${stdenv.glibc}/lib/ld-linux.so.2 \$i
-    done
-  ";
-
-  installPhase = "
-    export dontPatchELF=1;
-    mkdir -p \$out
-    cp -r . \$out/firefox
-    mkdir -p \$out/bin
-    ln -s \$out/firefox/firefox \$out/bin/firefox
-
-    sed -e 's@moz_libdir=.*@moz_libdir='\$out'/firefox/@' -i \$out/bin/firefox 
-    sed -e 's@moz_libdir=.*@&\\nexport PATH=\$PATH:${coreutils}/bin@' -i \$out/bin/firefox 
-    sed -e 's@`/bin/pwd@`${coreutils}/bin/pwd@' -i \$out/bin/firefox 
-    sed -e 's@`/bin/ls@`${coreutils}/bin/ls@' -i \$out/bin/firefox 
-
-    strip -S \$out/firefox/*.so || true
-
-    echo \"running firefox -register...\"
-    \$out/firefox/firefox-bin -register || false
-  ";
-
-  meta = {
-    description = "Mozilla Firefox - the browser, reloaded";
-  };
-
-  passthru = {inherit gtk;};
-}
-
diff --git a/pkgs/applications/networking/browsers/firefox3b1/builder.sh b/pkgs/applications/networking/browsers/firefox3b1/builder.sh
deleted file mode 100644
index 66f1059d657..00000000000
--- a/pkgs/applications/networking/browsers/firefox3b1/builder.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-source $stdenv/setup
-
-postInstall=postInstall
-postInstall() {
-
-    # Strip some more stuff
-    strip -S $out/lib/*/* || true
-
-    # This fixes starting Firefox when there already is a running
-    # instance.  The `firefox' wrapper script actually expects to be
-    # in the same directory as `run-mozilla.sh', apparently.
-    libDir=$(cd $out/lib && ls -d firefox-*)
-    test -n "$libDir"
-    cd $out/bin
-    mv firefox ../lib/$libDir/
-    ln -s ../lib/$libDir/firefox .
-
-    # Register extensions etc.
-    echo "running firefox -register..."
-    (cd $out/lib/$libDir && LD_LIBRARY_PATH=. ./firefox-bin -register) || false
-
-    echo "running regxpcom..."
-    (cd $out/lib/$libDir && LD_LIBRARY_PATH=. ./regxpcom) || false
-
-    # Put the Firefox icon in the right place.
-    ensureDir $out/lib/$libDir/chrome/icons/default
-    ln -s ../../../icons/default.xpm  $out/lib/$libDir/chrome/icons/default/
-}
-
-genericBuild
diff --git a/pkgs/applications/networking/browsers/firefox3b1/default.nix b/pkgs/applications/networking/browsers/firefox3b1/default.nix
deleted file mode 100644
index 675f2935d2f..00000000000
--- a/pkgs/applications/networking/browsers/firefox3b1/default.nix
+++ /dev/null
@@ -1,58 +0,0 @@
-args: with args;
-
-stdenv.mkDerivation {
-  name = "firefox-3b1";
-
-  src = 
-	fetchurl {
-		url = ftp://ftp.mozilla.org/pub/firefox/releases/3.0b1/source/firefox-3.0b1-source.tar.bz2;
-		sha256 = "02mh87aidr33gp33fasq9xx23jqf7lm7yfsb2a36ijnd3bpnssn9";
-	};
-
-  buildInputs = [
-    pkgconfig gtk perl zip libIDL libXi libjpeg libpng zlib cairo
-    python curl coreutils
-  ];
-
-  configureFlags = [
-    "--enable-application=browser"
-    "--enable-optimize"
-    "--disable-debug"
-    "--enable-xft"
-    "--disable-freetype2"
-    "--enable-svg"
-    "--enable-canvas"
-    "--enable-strip"
-    "--enable-default-toolkit=cairo-gtk2"
-    "--with-system-jpeg"
-    "--with-system-zlib"
-    /*"--enable-system-cairo"*/
-  ]
-;
-
-  postConfigure = "
-	cp -r . /tmp/ff3b1-build
-  ";
-
-  postInstall = "
-    sed -e 's@moz_libdir=.*@&\\nexport PATH=\$PATH:${coreutils}/bin@' -i \$out/bin/firefox 
-    sed -e 's@`/bin/pwd@`${coreutils}/bin/pwd@' -i \$out/bin/firefox 
-    sed -e 's@`/bin/ls@`${coreutils}/bin/ls@' -i \$out/bin/firefox 
-
-    strip -S \$out/lib/*/* || true
-
-    libDir=\$(cd \$out/lib && ls -d firefox-[0-9]*)
-    test -n \"\$libDir\"
-
-    echo \"running firefox -register...\"
-    (cd \$out/lib/\$libDir && LD_LIBRARY_PATH=. ./firefox-bin -register) || false
-  ";
-
-  meta = {
-    description = "Mozilla Firefox - the browser, reloaded";
-    homepage = http://www.mozilla.com/en-US/firefox/;
-  };
-
-  passthru = {inherit gtk;};
-}
-
diff --git a/pkgs/applications/networking/browsers/firefox3b1/writable-copies.patch b/pkgs/applications/networking/browsers/firefox3b1/writable-copies.patch
deleted file mode 100644
index e3c7752c031..00000000000
--- a/pkgs/applications/networking/browsers/firefox3b1/writable-copies.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-diff -rc mozilla-orig/xpcom/io/nsLocalFileUnix.cpp mozilla/xpcom/io/nsLocalFileUnix.cpp
-*** mozilla-orig/xpcom/io/nsLocalFileUnix.cpp	2004-04-03 01:48:18.000000000 +0200
---- mozilla/xpcom/io/nsLocalFileUnix.cpp	2004-10-05 19:48:04.000000000 +0200
-***************
-*** 634,639 ****
---- 634,640 ----
-          // get the dirs old permissions
-          if (NS_FAILED(rv = GetPermissions(&oldPerms)))
-              return rv;
-+         oldPerms |= 0200;
-          if (NS_FAILED(rv = newParent->Create(DIRECTORY_TYPE, oldPerms)))
-              return rv;
-      } else {    // dir exists lets try to use leaf
-***************
-*** 758,763 ****
---- 759,765 ----
-          // get the old permissions
-          PRUint32 myPerms;
-          GetPermissions(&myPerms);
-+         myPerms |= 0200;
-  
-          // Create the new file with the old file's permissions, even if write
-          // permission is missing.  We can't create with write permission and
diff --git a/pkgs/applications/networking/browsers/firefox3b1/xlibs.patch b/pkgs/applications/networking/browsers/firefox3b1/xlibs.patch
deleted file mode 100644
index a656fbf9beb..00000000000
--- a/pkgs/applications/networking/browsers/firefox3b1/xlibs.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- mozilla/layout/build/Makefile.in.orig	2007-01-13 14:23:19.000000000 -0200
-+++ mozilla/layout/build/Makefile.in	2007-01-13 14:24:55.000000000 -0200
-@@ -282,5 +282,6 @@ LDFLAGS += -Wl,-LD_LAYOUT:lgot_buffer=50
- endif
- endif
- 
-+LDFLAGS += -lX11 -lXrender
- 
- export:: $(BUILD_DATE)
- 
\ No newline at end of file
diff --git a/pkgs/applications/networking/instant-messengers/bitlbee/default.nix b/pkgs/applications/networking/instant-messengers/bitlbee/default.nix
new file mode 100644
index 00000000000..ed36ca779b6
--- /dev/null
+++ b/pkgs/applications/networking/instant-messengers/bitlbee/default.nix
@@ -0,0 +1,17 @@
+args: with args;
+
+stdenv.mkDerivation rec {
+  name = "bitlbee-1.0.4";
+  src = fetchurl {
+    url = "mirror://bitlbee/src/" + name + ".tar.gz";
+    sha256 = "072vdpz4z3bmskm04crrkj946hj0gnnd6w0vqrb7xmj1lrzg68vg";
+  };
+
+  buildInputs = [ gnutls glib pkgconfig ];
+
+  meta = {
+    description = ''BitlBee, an IRC to other chat networks gateway.'';
+    homepage = http://www.bitlbee.org/;
+    license = "GPL";
+  };
+}
diff --git a/pkgs/applications/version-management/arch/configure-tmpdir.patch b/pkgs/applications/version-management/arch/configure-tmpdir.patch
new file mode 100644
index 00000000000..2b39322ca22
--- /dev/null
+++ b/pkgs/applications/version-management/arch/configure-tmpdir.patch
@@ -0,0 +1,11 @@
+--- tla-1.3.5/src/build-tools/auto-conf-lib/gnu-patch-test	2006-07-20 08:34:28.000000000 +0200
++++ tla-1.3.5/src/build-tools/auto-conf-lib/gnu-patch-test	2008-02-17 13:00:07.000000000 +0100
+@@ -27,7 +27,7 @@ else
+ fi
+ 
+ CMP='cmp'    # we require a working 'cmp' utility
+-TMPDIR="/tmp/,patch-test.$$"
++TMPDIR="${TMPDIR:-/tmp}/,patch-test.$$"
+ 
+ ORIG_A="$TMPDIR/to-patch_a"
+ ORIG_PRISTINE_A="$TMPDIR/to-patch_a.the-original"
diff --git a/pkgs/applications/version-management/arch/default.nix b/pkgs/applications/version-management/arch/default.nix
new file mode 100644
index 00000000000..0a54eabd595
--- /dev/null
+++ b/pkgs/applications/version-management/arch/default.nix
@@ -0,0 +1,29 @@
+args: with args;
+
+stdenv.mkDerivation rec {
+  name = "tla-1.3.5";
+  src = fetchurl {
+    url = "mirror://gnu/gnu-arch/" + name + ".tar.gz";
+    sha256 = "01mfzj1i6p4s8191cgd5850hds1zls88hkf9rb6qx1vqjv585aj0";
+  };
+
+  patches = [ ./configure-tmpdir.patch ];
+
+  buildInputs = [which];
+  propagatedBuildInputs = [diffutils gnupatch gnutar];
+
+  # Instead of GNU Autoconf, tla uses Tom Lord's now
+  # defunct `package-framework'.
+  buildPhase = ''
+    mkdir +build && cd +build &&		\
+    ../src/configure --prefix="$out" &&		\
+    make install
+  '';
+
+  meta = {
+    description = ''GNU Arch (aka. `tla'), a distributed revision
+    		    control system.'';
+    homepage = http://www.gnu.org/software/gnu-arch/;
+    license = "GPL";
+  };
+}
diff --git a/pkgs/applications/version-management/darcs_2_pre.nix b/pkgs/applications/version-management/darcs_2_pre.nix
new file mode 100644
index 00000000000..a8bd48aa336
--- /dev/null
+++ b/pkgs/applications/version-management/darcs_2_pre.nix
@@ -0,0 +1,16 @@
+{stdenv, fetchurl, ghc, zlib, ncurses, curl}:
+
+stdenv.mkDerivation {
+  name = "darcs-2.0.0pre3";
+  src = fetchurl {
+    url = http://darcs.net/darcs-2.0.0pre3.tar.gz;
+    sha256 = "";
+  };
+  buildInputs = [ghc zlib ncurses curl];
+
+  NIX_LDFLAGS = "-lz";
+
+  meta = {
+    description = "Patch-based version management system";
+  };
+}
diff --git a/pkgs/applications/version-management/git/default.nix b/pkgs/applications/version-management/git/default.nix
index c2388f8c1aa..9cd69bf9008 100644
--- a/pkgs/applications/version-management/git/default.nix
+++ b/pkgs/applications/version-management/git/default.nix
@@ -1,21 +1,31 @@
 args: with args;
 
 stdenv.mkDerivation rec {
-  name = "git-1.5.3.5";
+  name = "git-1.5.4.2";
 
   src = fetchurl {
     url = "mirror://kernel/software/scm/git/${name}.tar.bz2";
-    sha256 = "0ab63s25wzmsl5inp7bykz5ac7xjilqa0ciaz7ydhciymz6gkawj";
+    sha256 = "089n3da06k19gzhacsqgaamgx5hy5r50r2b4a626s87w44mj78sn";
   };
 
-  buildInputs = [curl openssl zlib expat];
+  buildInputs = [curl openssl zlib expat gettext emacs];
 
   makeFlags="prefix=\${out} PERL_PATH=${perl}/bin/perl SHELL_PATH=${stdenv.shell}";
 
+  postInstall = ''
+    # Install Emacs mode.
+    echo "installing Emacs mode..."
+    make install -C contrib/emacs prefix="$out"
+
+    # XXX: There are other things under `contrib' that people might want to
+    # install.
+  '';
+
   meta = {
-	  license = "GPL2";
-	  homepage = http://git.or.cz;
-	  description = "A popular version control system designed to handle very
-	  large projects with speed and efficiency";
+    license = "GPLv2";
+    homepage = http://git.or.cz;
+    description = ''Git, a popular distributed version control system
+                    designed to handle very large projects with speed
+		    and efficiency.'';
   };
 }
diff --git a/pkgs/applications/virtualization/qemu/linux-img/0.2.nix b/pkgs/applications/virtualization/qemu/linux-img/0.2.nix
index ae1933b9d1d..99d222070c2 100644
--- a/pkgs/applications/virtualization/qemu/linux-img/0.2.nix
+++ b/pkgs/applications/virtualization/qemu/linux-img/0.2.nix
@@ -1,3 +1,4 @@
+
 args : with args;
 	let localDefs = builderDefs {
 		src = /* put a fetchurl here */
diff --git a/pkgs/build-support/fetchurl/mirrors.nix b/pkgs/build-support/fetchurl/mirrors.nix
index a154be31688..d245b1ac3f8 100644
--- a/pkgs/build-support/fetchurl/mirrors.nix
+++ b/pkgs/build-support/fetchurl/mirrors.nix
@@ -68,4 +68,40 @@ rec {
     http://www.wikifusion.info/nongnu/
   ];
 
+  # BitlBee mirrors, see http://www.bitlbee.org/main.php/mirrors.html .
+  bitlbee = [
+    http://get.bitlbee.org/
+    http://get.bitlbee.be/
+    http://get.us.bitlbee.org/
+    http://ftp.snt.utwente.nl/pub/software/bitlbee/
+    http://bitlbee.intergenia.de/
+  ];
+
+  # ImageMagick mirrors, see http://www.imagemagick.org/script/download.php .
+  imagemagick = [
+    ftp://gd.tuwien.ac.at/pub/graphics/ImageMagick/
+    ftp://ftp.carnet.hr/pub/misc/imagemagick/
+    ftp://ftp.fu-berlin.de/unix/X11/graphics/ImageMagick
+    http://imagemagick.linux-mirror.org/download
+    http://image_magick.veidrodis.com/image_magick/
+    http://imagemagick.oss-mirror.org/download
+    ftp://ftp.kddlabs.co.jp/graphics/ImageMagick/
+    ftp://ftp.u-aizu.ac.jp/pub/graphics/image/ImageMagick/imagemagick.org
+    ftp://zoffy.asahi-net.or.jp/pub/graphics/ImageMagick
+    ftp://ftp.nluug.nl/pub/ImageMagick
+    http://ftp.surfnet.nl/pub/ImageMagick/
+    ftp://sunsite.icm.edu.pl/packages/ImageMagick/
+    ftp://ftp.chg.ru/packages/ImageMagick
+    http://ftp.chg.ru/packages/ImageMagick
+    http://ftp.efair.ru/pub/software/graphics/ImageMagick/
+    ftp://ftp.efair.ru/pub/software/graphics/ImageMagick/
+    ftp://ftp.sunet.se/pub/multimedia/graphics/ImageMagick
+    http://www.smudge-it.co.uk/pub/imagemagick/
+    ftp://www.rx-host.net/pub/graphics/ImageMagick
+    ftp://ftp.fifi.org/pub/ImageMagick/
+    ftp://ftp.imagemagick.org/pub/ImageMagick
+    ftp://ftp.imagemagick.net/pub/ImageMagick
+    http://imagemagick.site2nd.org/imagemagick
+  ];
+
 }
diff --git a/pkgs/build-support/substitute/substitute-all.sh b/pkgs/build-support/substitute/substitute-all.sh
index 3d3999ad520..796a1a47152 100644
--- a/pkgs/build-support/substitute/substitute-all.sh
+++ b/pkgs/build-support/substitute/substitute-all.sh
@@ -1,5 +1,7 @@
 source $stdenv/setup
 
+eval "$preInstall"
+
 args=
 
 target=$out
@@ -13,3 +15,5 @@ substituteAll $src $target
 if test -n "$isExecutable"; then
     chmod +x $target
 fi
+
+eval "$postInstall"
diff --git a/pkgs/data/fonts/freefont-ttf/default.nix b/pkgs/data/fonts/freefont-ttf/default.nix
index 19e1a21450d..e1f8c74ae62 100644
--- a/pkgs/data/fonts/freefont-ttf/default.nix
+++ b/pkgs/data/fonts/freefont-ttf/default.nix
@@ -6,6 +6,8 @@ stdenv.mkDerivation {
     url = http://download.savannah.gnu.org/releases/freefont/freefont-ttf-20060126.tar.gz;
     md5 = "822aba4e2ed065d9d3ded6e26e495854";
   };
-  buildPhase = "true";
-  installPhase = "ensureDir $out/share/fonts/truetype; cp *.ttf $out/share/fonts/truetype";
-}
\ No newline at end of file
+  installPhase = ''
+    ensureDir $out/share/fonts/truetype
+    cp *.ttf $out/share/fonts/truetype
+  '';
+}
diff --git a/pkgs/desktops/gnome/gnome-vfs.nix b/pkgs/desktops/gnome/gnome-vfs.nix
index 7f1e6a67c71..24b99fb3b83 100644
--- a/pkgs/desktops/gnome/gnome-vfs.nix
+++ b/pkgs/desktops/gnome/gnome-vfs.nix
@@ -3,11 +3,9 @@ args: with args;
 stdenv.mkDerivation {
   inherit (input) name src;
   buildInputs = [
-    pkgconfig perl gnome.glib libxml2 gnome.libbonobo
+    pkgconfig perl gnome.glib libxml2 gnome.GConf gnome.libbonobo
     gnome.gnomemimedata popt perlXMLParser gettext bzip2
     dbus_glib hal openssl samba fam
   ];
-
-  propagatedBuildInputs = [gnome.GConf];
   patches = [./no-kerberos.patch];
 }
diff --git a/pkgs/desktops/kde-4/base/builder.sh b/pkgs/desktops/kde-4/base/builder.sh
new file mode 100755
index 00000000000..99b357fcf16
--- /dev/null
+++ b/pkgs/desktops/kde-4/base/builder.sh
@@ -0,0 +1,12 @@
+source ${stdenv}/setup
+
+myPatchPhase()
+{
+	echo "Fixing dbus calls in CMakeLists.txt files"
+# Trailing slash in sed is essential
+	find .. -name CMakeLists.txt \
+	| xargs sed -e "s@\${DBUS_INTERFACES_INSTALL_DIR}/@${kdelibs}/share/dbus-1/interfaces/@" -i
+	#sed -e '/^#define HAS_RANDR_1_2 1$/d' -i ../workspace/kcontrol/randr/randr.h
+}
+patchPhase=myPatchPhase
+genericBuild
diff --git a/pkgs/desktops/kde-4/base/default.nix b/pkgs/desktops/kde-4/base/default.nix
index f6a2ca1d92b..451dd4863c3 100644
--- a/pkgs/desktops/kde-4/base/default.nix
+++ b/pkgs/desktops/kde-4/base/default.nix
@@ -2,12 +2,13 @@ args: with args;
 
 stdenv.mkDerivation {
   name = "kdebase-4.0.0";
-
+  #builder = ./builder.sh;
+  
   src = fetchurl {
-    url = mirror://kde/stable/4.0.0/src/kdebase-4.0.0.tar.bz2;
-    sha256 = "1419zijcrx6nk10nay3dbv0vi8525hzcqkm2fw8cvw11i4mk909q";
+    url = http://download.kde.org/stable/4.0.0/src/kdebase-4.0.0.tar.bz2;
+    md5 = "01d8f2f16cbd4e225efc996b0dd39769";
   };
 
   propagatedBuildInputs = [kdepimlibs libusb];
-  buildInputs = [cmake];
+  inherit kdelibs;
 }
diff --git a/pkgs/desktops/kde-4/default.nix b/pkgs/desktops/kde-4/default.nix
index 11554c9955e..9732d9e2b2b 100644
--- a/pkgs/desktops/kde-4/default.nix
+++ b/pkgs/desktops/kde-4/default.nix
@@ -2,7 +2,6 @@ args:
 rec {
   fullargs = args // { kdelibs = libs; kdepimlibs = pimlibs; kdebase = base; kderuntime = runtime; };
   libs = import ./libs (args // { kdesupport = support; });
-  l10n = import ./l10n (args // {kdelibs = libs;});
   pimlibs = import ./pimlibs (args // { kdelibs = libs; });
   graphics = import ./graphics (fullargs // { kdeworkspace = workspace; } );
   multimedia = import ./multimedia (fullargs // { kdeworkspace = workspace; } );
@@ -17,12 +16,13 @@ rec {
   extragear_plasma = import ./extragear (fullargs // { kdeworkspace = workspace; });
   support = import ./support args;
   decibel = import ./decibel fullargs;
-# kdepim is not included in KDE-4.0.0
-  #pim = import ./pim (fullargs // {kdeworkspace = workspace; });
+  pim = import ./pim (fullargs // {kdeworkspace = workspace; });
 
-  env = kde_pkgs: with args; [ (runCommand "kde-env"
+  env = with args; runCommand "kde-env"
   {
-	  KDEDIRS = lib.concatStringsSep ":" (kde_pkgs ++ support.all);
+	  KDEDIRS = lib.concatStringsSep ":" ([ libs pimlibs graphics multimedia
+	  toys network utils games edu base runtime workspace extragear_plasma pim] ++
+	  support.all);
 	  scriptName = "echo-kde-dirs";
   }
   "
@@ -31,5 +31,5 @@ rec {
   echo \"#!/bin/sh\" > \${scriptPath}
   echo \"echo -n export KDEDIRS=\${KDEDIRS}\" >> \${scriptPath}
   chmod +x \${scriptPath}
-  ")] ++ kde_pkgs ++ support.all ++ [shared_mime_info qt xprop xset];
+  ";
 }
diff --git a/pkgs/desktops/kde-4/edu/default.nix b/pkgs/desktops/kde-4/edu/default.nix
index 7f9648c6f8f..0cf140a5de9 100644
--- a/pkgs/desktops/kde-4/edu/default.nix
+++ b/pkgs/desktops/kde-4/edu/default.nix
@@ -4,17 +4,17 @@ stdenv.mkDerivation rec {
   name = "kdeedu-4.0.0";
   
   src = fetchurl {
-    url = mirror://kde/stable/4.0.0/src/kdeedu-4.0.0.tar.bz2;
-    sha256 = "1wjy1rm7aiib1lv61wx7mcbkbpkk6phcz1q6dy51x0hfrc3rdkg4";
+    url = http://download.kde.org/stable/4.0.0/src/kdeedu-4.0.0.tar.bz2;
+    md5 = "73924e158e4a2de2107be441c808251f";
   };
 
-  propagatedBuildInputs = [kdepimlibs boost readline openbabel ocaml libusb
-  facile python indilib libnova];
-  buildInputs = [cmake];
+  buildInputs = [kdelibs kdepimlibs kdeworkspace boost readline openbabel ocaml
+  libusb facile python];
   myCmakeFiles = ./myCmakeFiles;
   patchPhase = "
   cp ${myCmakeFiles}/* ../cmake/modules
   sed -e 's@+facile@\${LIBFACILE_INCLUDE_DIR}@' -i \\
   ../kalzium/src/CMakeOCamlInstructions.cmake
   ";
+  configureFlags = "--debug-trycompile";
 }
diff --git a/pkgs/desktops/kde-4/extragear/default.nix b/pkgs/desktops/kde-4/extragear/default.nix
index 8ad2ef0540f..c67d4b8682c 100644
--- a/pkgs/desktops/kde-4/extragear/default.nix
+++ b/pkgs/desktops/kde-4/extragear/default.nix
@@ -1,17 +1,14 @@
 args: with args;
 
 stdenv.mkDerivation {
-  name = "extragear-plasma-4.0.0";
+  name = "extragear-plasma-4.0beta4";
   
   src = fetchurl {
-    url = mirror://kde/stable/4.0.0/src/extragear/extragear-plasma-4.0.0.tar.bz2;
-    sha256 = "19gmvqkal11gg67gfmdivxbhwvggm2i6ad642984d97yicms7s9k";
+    url = mirror://kde/unstable/3.95/src/extragear-plasma-3.95.0.tar.bz2;
+    sha256 = "1nzfy34ig66gfpgv6kbcmcap13axcy7kvj43srbd0ic6a0giv283";
   };
 
-  buildInputs = [ kdeworkspace cmake ];
-  patchPhase = ''
-  sed -e 's@<Plasma@<KDE/Plasma@' -i ../applets/*/*.h
-  echo ${kdeworkspace}
-  fixCmakeDbusCalls ${kdeworkspace}
-  '';
+  buildInputs = [ kdeworkspace kdebase ];
+  patchPhase = "
+  sed -e 's@<Plasma@<KDE/Plasma@' -i ../applets/*/*.h";
 }
diff --git a/pkgs/desktops/kde-4/games/default.nix b/pkgs/desktops/kde-4/games/default.nix
index 0963d2837c9..8f3b6c0ec48 100644
--- a/pkgs/desktops/kde-4/games/default.nix
+++ b/pkgs/desktops/kde-4/games/default.nix
@@ -4,10 +4,9 @@ stdenv.mkDerivation {
   name = "kdegames-4.0.0";
   
   src = fetchurl {
-    url = mirror://kde/stable/4.0.0/src/kdegames-4.0.0.tar.bz2;
-    sha256 = "09ilgi6l5sq4gavskyhfrv8ra3n3r6xdn8cdc7fm2fi3zah4innn";
+    url = http://download.kde.org/stable/4.0.0/src/kdegames-4.0.0.tar.bz2;
+    md5 = "6264c0034f6389a2807a4e1723ba1c81";
   };
 
-  propagatedBuildInputs = [kdepimlibs];
-  buildInputs = [cmake];
+  buildInputs = [kdelibs kdepimlibs kdeworkspace];
 }
diff --git a/pkgs/desktops/kde-4/graphics/default.nix b/pkgs/desktops/kde-4/graphics/default.nix
index 9fe45f5aade..6ab84fd8eff 100644
--- a/pkgs/desktops/kde-4/graphics/default.nix
+++ b/pkgs/desktops/kde-4/graphics/default.nix
@@ -4,11 +4,10 @@ stdenv.mkDerivation {
   name = "kdegraphics-4.0.0";
   
   src = fetchurl {
-    url = mirror://kde/stable/4.0.0/src/kdegraphics-4.0.0.tar.bz2;
-    sha256 = "00np19mzmg8zs8j89g1f47h3kj5azgnv3nspb8lw880zg682yp2f";
+    url = http://download.kde.org/stable/4.0.0/src/kdegraphics-4.0.0.tar.bz2;
+    md5 = "6cad7b165d99c43d1a19a0350598821c";
   };
 
-  propagatedBuildInputs = [kdepimlibs libgphoto2 saneBackends djvulibre exiv2
-  poppler chmlib libXxf86vm];
-  buildInputs = [cmake];
+  buildInputs = [kdelibs kdepimlibs kdeworkspace libgphoto2 saneBackends
+  djvulibre exiv2 poppler chmlib];
 }
diff --git a/pkgs/desktops/kde-4/l10n/default.nix b/pkgs/desktops/kde-4/l10n/default.nix
deleted file mode 100644
index be34aa661f2..00000000000
--- a/pkgs/desktops/kde-4/l10n/default.nix
+++ /dev/null
@@ -1,60 +0,0 @@
-args: with args;
-let
-fun = {lc, hash} :
-stdenv.mkDerivation rec {
-	name = "kde-l10n-${lc}-4.0.0";
-	src = fetchurl {
-		url = "mirror://kde/stable/4.0.0/src/kde-l10n/${name}.tar.bz2";
-		sha256 = hash;
-	};
-	buildInputs = [kdelibs cmake];
-};
-inherit (builtins) head tail;
-in
-(stdenv.lib.listOfListsToAttrs (
-map (x : ( [ (head x) (fun { lc = head x; hash = head (tail x); }) ] ))
-[
-[ "ar" "0hpbbi0l9w2l61hcj01j22yb4vcgj09q00ckhvkhvzy4zwzdmsvh" ]
-[ "be" "0xvy4a9jjib8qqy18y48r8np7400wa7w6wj10hzdvs4gn2a4cqm8" ]
-[ "bg" "1zm44fl7r892r5rpx1v0zw5bsigqwfhyq7hyg5n3j19lfvnrk5lc" ]
-[ "ca" "0kvgin92663g7v0yk2fxa5j1cr90v4hp6255gqmhimlp1j4mzcpk" ]
-[ "csb" "0iypwx8jznadqwl73094n8ndb9xbi4ff7pj6im74r4z5jl7mnx4w" ]
-[ "de" "0dd6p43hyd7jid9yvyw6ich8x84mmg1x4qphzs4ms32j1yz1ifxz" ]
-[ "el" "0cr4fm6bnai7qcpbhl3p06zw3ggqsvaf9xhmivxpc70j4b6didni" ]
-[ "en_GB" "0apyx5yl7yi3hp77v21y5dfqlb9mbx79wjk2pnzc16j8rnalq4a1" ]
-[ "eo" "032y966j6yb1wx6c4pp41zy7jl2rviryrx069viwm2nyxnclq4lg" ]
-[ "es" "0m2ajgdbkksvhmvdrz35f60p352w1bv01dy9jsayaahkmd9jzs2h" ]
-[ "et" "17d4jm91y4glh5iphml6pg7vx7k6wbvjnp491lvs4ipg2p6kwdn4" ]
-[ "eu" "0zjlg26cfylmf6r6lrnjwnmvzqh9gavip17vpq3py6pk712p1a6z" ]
-[ "fi" "18yxf6gbiz09yn2ym20qss0y3dcggmg7qfqxz5jcb99bw2szpfl0" ]
-[ "fr" "1fx8yqjdjmgis1hm0qva54q3nl6xwyzamv8n9hzldjab4nblr9hm" ]
-[ "ga" "0j9qipqzxsnyw52fi332rdav7jxcy9dgmr5nsxbmpm8cns4g5lw6" ]
-[ "gl" "0591x9ycj35adr27wcy2slzk4iyni0gvy2f4rqaskkjmrypi284x" ]
-[ "hi" "099lihyima3fg6dvgrafy3yjzij28rx42hy0sz3z9cvy6adb4ch8" ]
-[ "hu" "01wrylzy4gly1pb8614kfc2p1wr48ikzjszn5gm376za3fhjf0wh" ]
-[ "it" "0d632q1y117zs6fibsavwx581cxbar6p3ih4q3wzlk254lr7rxyx" ]
-[ "ja" "055dqnxnn819m7fshcwpibaa750dsx1ppkf1mw8jq4sngrc8r9k0" ]
-[ "km" "01bkbw967rsb8grv9xd9nyn6ij5arr90l3x4ry0wi9syglng0dwy" ]
-[ "ko" "0c60ypydrkbic6hp4rncadmchmhn0b012kgq1w69db3w77vc20sa" ]
-[ "lv" "1b8sbr4fl2250mpf8ms4f8h9cbvgwnx0604q498i4cxs1ja5mby1" ]
-[ "mk" "1nb8f092jnwazyg6y3482gfar7rrxf0i0wisgfm7rmydblb8vd6b" ]
-[ "nb" "007n9r75ig6gx88kdj40f3rccb8z1avvp9l6g2wr85ysfj09qs8z" ]
-[ "nds" "1mhmrkkldkv8gd5rcsyjx0bckacgn2m2fbzymndagd2sp1617hjc" ]
-[ "ne" "0r1hnkk4zf111v3py4zz292d5f51wjxyscflm2fy10s0j6a282jv" ]
-[ "nl" "0rqzrnninv3y69waibi8p9haddyqqir0sagajn20k7zrapjhlwg5" ]
-[ "nn" "1s19ybg8spg3ivc5h0yqd36ry39piwb5a7q2kfbhhv843pgs1sc6" ]
-[ "pa" "00vc84gwvq0xcav28h2vv80j9p80y19mq2mfgjzdx7y63qwqbjkh" ]
-[ "pl" "1xybzvfih1m37q54ihqmcsmdqk8piyrn9crwqybslvvklqrmy51c" ]
-[ "pt" "1kl2ap044li2l48vyym4s9sjybs2vx2fadnk7wdhykzxfg54y12n" ]
-[ "pt_BR" "15ampx9rhrpqxn94ndmmgkcmmd0hxh12xiph312kf5r0xsinxdpg" ]
-[ "ru" "1hydlhcpa2wcp0zn7a3972bc8abscgvaw077vjhmvda3zwsmcfsn" ]
-[ "se" "0r3q20xxdqj5kym1hx6vz7prir3nspgbrrrk9aamhkwwicy03mf8" ]
-[ "sl" "1xa7i7mngz1gpa0hddy1cbkkxjrrb7wlhr8jbbc7n76ll05anh7h" ]
-[ "sv" "10b0f7i11wqjyizl1m6xwr0j8fh1fdap88bmvhxvj6yzmzkdrp7v" ]
-[ "th" "03a1hi6n1dv6ak3i84gd2jv199y17sq9m4rwpqwnx9zcnv4y453g" ]
-[ "tr" "19h45qxng8qy71h3z1s19j25mm9px71z15ifvq1px47xii34hzdz" ]
-[ "uk" "10fv27xh737rvp0ps1x6lm5ybajxbwy2998dsfmkq0zh3j99yn4h" ]
-[ "wa" "1sqmki4sm0mlmvqynpbjbl6xmw5h1dcp7rcmnxsfl4qnxgj3al9x" ]
-[ "zh_CN" "1h7r1bzaicvjad8k4nsmb2pyk11crpa82jhw2whk1136bjh0f9sg" ]
-[ "zh_TW" "1yhb7c9q6fkj4rj4mb6r37fhl3bz4gcsplhd17z02gryjmn4sdjc" ]
-]) // { recurseForDerivations = true; })
diff --git a/pkgs/desktops/kde-4/libs/default.nix b/pkgs/desktops/kde-4/libs/default.nix
index 1628e5d185a..91f722ec658 100644
--- a/pkgs/desktops/kde-4/libs/default.nix
+++ b/pkgs/desktops/kde-4/libs/default.nix
@@ -4,20 +4,19 @@ stdenv.mkDerivation rec {
   name = "kdelibs-4.0.0";
   
   src = fetchurl {
-    url = mirror://kde/stable/4.0.0/src/kdelibs-4.0.0.tar.bz2;
-    sha256 = "0bfcrb34kl2md77k9rbr924n5bc7chc5wkr10jjvq98742yh0rza";
+    url = http://download.kde.org/stable/4.0.0/src/kdelibs-4.0.0.tar.bz2;
+    md5 = "79d0f83ca81fc4a135663943340c0b8f";
   };
 
   propagatedBuildInputs = [
-	inputproto kbproto scrnsaverproto xextproto xf86miscproto xf86vidmodeproto
+	cmake inputproto kbproto scrnsaverproto xextproto xf86miscproto xf86vidmodeproto
 	xineramaproto xproto libICE libX11 libXau libXcomposite libXcursor
 	libXdamage libXdmcp libXext libXfixes libXft libXi libXpm libXrandr
 	libXrender libXScrnSaver libXt libXtst libXv libXxf86misc libxkbfile zlib
 	perl qt openssl pcre pkgconfig libjpeg libpng libtiff libxml2 libxslt expat
     libtool freetype bzip2 shared_mime_info alsaLib libungif cups
-	gettext enchant openexr aspell stdenv.gcc.libc jasper kerberos fam
+	gettext enchant openexr aspell stdenv.gcc.libc
   ] ++ kdesupport.all;
-  buildInputs = [ cmake ];
   patchPhase = "cp ${findIlmBase} ../cmake/modules/FindIlmBase.cmake;
   cp $findOpenEXR ../cmake/modules/FindOpenEXR.cmake;
   sed -e 's@Soprano/DummyModel@Soprano/Util/DummyModel@' -i ../nepomuk/core/resourcemanager.cpp;";
diff --git a/pkgs/desktops/kde-4/libs/setup.sh b/pkgs/desktops/kde-4/libs/setup.sh
index 851614b0d18..6f899442d27 100755
--- a/pkgs/desktops/kde-4/libs/setup.sh
+++ b/pkgs/desktops/kde-4/libs/setup.sh
@@ -2,13 +2,4 @@ addKDEDIRS()
 {
 	addToSearchPath KDEDIRS /share/kde4 /. $1
 }
-
-fixCmakeDbusCalls()
-{
-	dbusPrefix=${1:-@out@}
-	echo "Fixing dbus calls in CMakeLists.txt files"
-# Trailing slash in sed is essential
-	find .. -name CMakeLists.txt \
-	| xargs sed -e "s#\${DBUS_INTERFACES_INSTALL_DIR}/#${dbusPrefix}/share/dbus-1/interfaces/#" -i
-}
 envHooks=(${envHooks[@]} addKDEDIRS)
diff --git a/pkgs/desktops/kde-4/multimedia/default.nix b/pkgs/desktops/kde-4/multimedia/default.nix
index 0727369e042..f1f7994ce1a 100644
--- a/pkgs/desktops/kde-4/multimedia/default.nix
+++ b/pkgs/desktops/kde-4/multimedia/default.nix
@@ -4,10 +4,10 @@ stdenv.mkDerivation {
   name = "kdemultimedia-4.0.0";
   
   src = fetchurl {
-    url = mirror://kde/stable/4.0.0/src/kdemultimedia-4.0.0.tar.bz2;
-    sha256 = "14axr1x09k67vb3vaw4g9zg4mq7j14xn9d90kifwap7b76iljbi5";
+    url = http://download.kde.org/stable/4.0.0/src/kdemultimedia-4.0.0.tar.bz2;
+    md5 = "0bf1cd18a23017a37324d9f8c4902e19";
   };
 
-  propagatedBuildInputs = [kdeworkspace libogg flac cdparanoia lame libvorbis];
-  buildInputs = [cmake];
+  buildInputs = [kdelibs kdepimlibs kdeworkspace libogg flac cdparanoia lame
+  libvorbis];
 }
diff --git a/pkgs/desktops/kde-4/network/default.nix b/pkgs/desktops/kde-4/network/default.nix
index da2479bf0ee..f99f2184bca 100644
--- a/pkgs/desktops/kde-4/network/default.nix
+++ b/pkgs/desktops/kde-4/network/default.nix
@@ -4,8 +4,8 @@ stdenv.mkDerivation {
   name = "kdenetwork-4.0.0";
   
   src = fetchurl {
-    url = mirror://kde/stable/4.0.0/src/kdenetwork-4.0.0.tar.bz2;
-    sha256 = "04vigr2z0md64khjdriwslsyaf6mpqxd2iwsnr82g53x4kh0i061";
+    url = http://download.kde.org/stable/4.0.0/src/kdenetwork-4.0.0.tar.bz2;
+    md5 = "f362bd34b589800845abfb99589d4cfc";
   };
 
   buildInputs = [kdelibs kdepimlibs kdeworkspace sqlite libidn];
diff --git a/pkgs/desktops/kde-4/pim/builder.sh b/pkgs/desktops/kde-4/pim/builder.sh
new file mode 100755
index 00000000000..8963fae048c
--- /dev/null
+++ b/pkgs/desktops/kde-4/pim/builder.sh
@@ -0,0 +1,10 @@
+source ${stdenv}/setup
+
+myPatchPhase()
+{
+# They reset CMAKE_MODULE_PATH, not adding to the existing
+	sed -e '3s/)/ ${CMAKE_MODULE_PATH})/' -i ../CMakeLists.txt
+}
+patchPhase=myPatchPhase
+
+genericBuild
diff --git a/pkgs/desktops/kde-4/pim/default.nix b/pkgs/desktops/kde-4/pim/default.nix
index 0e4932bcc35..f0f4184d391 100644
--- a/pkgs/desktops/kde-4/pim/default.nix
+++ b/pkgs/desktops/kde-4/pim/default.nix
@@ -1,11 +1,11 @@
 args: with args;
 
 stdenv.mkDerivation {
-  name = "kdepim-4.0.0";
+  name = "kdepim-4.0beta4";
   
   src = fetchurl {
-    url = mirror://kde/stable/4.0.0/src/kdepim-4.0.0.tar.bz2;
-    sha256 = "kdepim is not included";
+    url = mirror://kde/unstable/3.95/src/kdepim-3.95.0.tar.bz2;
+    sha256 = "0gzvm4h6ij7i119apmh9w82raygahr18bl0i9m3ynf2mcca0aq94";
   };
 
   buildInputs = [libXinerama mesa stdenv.gcc.libc alsaLib kdelibs kdepimlibs
diff --git a/pkgs/desktops/kde-4/pimlibs/default.nix b/pkgs/desktops/kde-4/pimlibs/default.nix
index f121a8492d6..30c6ca6250b 100644
--- a/pkgs/desktops/kde-4/pimlibs/default.nix
+++ b/pkgs/desktops/kde-4/pimlibs/default.nix
@@ -1,13 +1,12 @@
 args: with args;
 
-stdenv.mkDerivation rec {
+stdenv.mkDerivation {
   name = "kdepimlibs-4.0.0";
   
   src = fetchurl {
-    url = "mirror://kde/stable/4.0.0/src/${name}.tar.bz2";
-	sha256 = "0vixx2vh7qgysnbzvykf20362p22jzvl8snpqaknay3v3b2k0br0";
+    url = http://download.kde.org/stable/4.0.0/src/kdepimlibs-4.0.0.tar.bz2;
+    md5 = "1a68662230fcd4ec8cea90bb780f920e";
   };
 
   propagatedBuildInputs = [kdelibs boost gpgme cyrus_sasl openldap];
-  buildInputs = [cmake];
 }
diff --git a/pkgs/desktops/kde-4/runtime/builder.sh b/pkgs/desktops/kde-4/runtime/builder.sh
new file mode 100755
index 00000000000..99b357fcf16
--- /dev/null
+++ b/pkgs/desktops/kde-4/runtime/builder.sh
@@ -0,0 +1,12 @@
+source ${stdenv}/setup
+
+myPatchPhase()
+{
+	echo "Fixing dbus calls in CMakeLists.txt files"
+# Trailing slash in sed is essential
+	find .. -name CMakeLists.txt \
+	| xargs sed -e "s@\${DBUS_INTERFACES_INSTALL_DIR}/@${kdelibs}/share/dbus-1/interfaces/@" -i
+	#sed -e '/^#define HAS_RANDR_1_2 1$/d' -i ../workspace/kcontrol/randr/randr.h
+}
+patchPhase=myPatchPhase
+genericBuild
diff --git a/pkgs/desktops/kde-4/runtime/default.nix b/pkgs/desktops/kde-4/runtime/default.nix
index 0be4a3bbc59..7b9d16bdc45 100644
--- a/pkgs/desktops/kde-4/runtime/default.nix
+++ b/pkgs/desktops/kde-4/runtime/default.nix
@@ -1,16 +1,15 @@
 args: with args;
 
-stdenv.mkDerivation rec {
+stdenv.mkDerivation {
   name = "kdebase-runtime-4.0.0";
+  builder = ./builder.sh;
   
   src = fetchurl {
-    url = "mirror://kde/stable/4.0.0/src/${name}.tar.bz2";
-    sha256 = "0svsn9gzg3ka77j7z71fy502a09w9gp9jd2q2y1w07ahpdil5p7h";
+    url = http://download.kde.org/stable/4.0.0/src/kdebase-runtime-4.0.0.tar.bz2;
+    md5 = "da93f59497ff90ad01bd4ab9b458f6cb";
   };
 
-  propagatedBuildInputs = [kdepimlibs libusb xineLib samba];
-  buildInputs = [cmake];
-  phononPatch = ./phonon.patch;
-  patchPhase = "fixCmakeDbusCalls; patch -p0 < ${phononPatch}";
+  propagatedBuildInputs = [kdepimlibs libusb kdebase xineLib];
+  inherit kdelibs;
 }
 
diff --git a/pkgs/desktops/kde-4/runtime/phonon.patch b/pkgs/desktops/kde-4/runtime/phonon.patch
deleted file mode 100644
index 6905eee8553..00000000000
--- a/pkgs/desktops/kde-4/runtime/phonon.patch
+++ /dev/null
@@ -1,13 +0,0 @@
---- ../phonon/CMakeLists.txt	2007/12/27 15:43:14	753486
-+++ ../phonon/CMakeLists.txt	2008/01/08 10:21:31	758568
-@@ -34,7 +34,9 @@
-                   macro_log_feature(TRUE "Xine" "xine-lib v${XINE_VERSION} was found on your system. This version is known to have problems when a device is unplugged. Consider upgrading to version 1.1.9 or above." "http://sourceforge.net/project/showfiles.php?group_id=9655&package_id=9732")
-                endif(XINE_BUGFIX_VERSION LESS 5)
-             else(XINE_BUGFIX_VERSION LESS 7)
--               macro_log_feature(TRUE "Xine" "xine-lib v${XINE_VERSION} was found on your system. This version is known to have problems when playing short sounds. Consider upgrading to version 1.1.9 or above." "http://sourceforge.net/project/showfiles.php?group_id=9655&package_id=9732")
-+               if(XINE_BUGFIX_VERSION LESS 9)
-+                  macro_log_feature(TRUE "Xine" "xine-lib v${XINE_VERSION} was found on your system. This version is known to have problems when playing short sounds. Consider upgrading to version 1.1.9 or above." "http://sourceforge.net/project/showfiles.php?group_id=9655&package_id=9732")
-+               endif(XINE_BUGFIX_VERSION LESS 9)
-             endif(XINE_BUGFIX_VERSION LESS 7)
-          else(XINE_MINOR_VERSION LESS 2 AND XINE_BUGFIX_VERSION LESS 90)
-             macro_log_feature(FALSE "Xine" "xine-lib v${XINE_VERSION} was found on your system. This version contains major changes compared to 1.1.x and has not been tested properly for use with this backend. Consider downgrading to version 1.1.9." "http://sourceforge.net/project/showfiles.php?group_id=9655&package_id=9732")
diff --git a/pkgs/desktops/kde-4/support/default.nix b/pkgs/desktops/kde-4/support/default.nix
index 4ad2143a700..426a5811bd7 100644
--- a/pkgs/desktops/kde-4/support/default.nix
+++ b/pkgs/desktops/kde-4/support/default.nix
@@ -4,7 +4,7 @@ let
 	svnSrc = name: hash:
 	oldArgs.fetchsvn {
 		url = "svn://anonsvn.kde.org/home/kde/trunk/kdesupport/${name}";
-		rev = 761061;
+		rev = 747269;
 		sha256 = hash;
 	};
 	};
diff --git a/pkgs/desktops/kde-4/support/eigen.nix b/pkgs/desktops/kde-4/support/eigen.nix
index 2b3520eb942..163683a2921 100644
--- a/pkgs/desktops/kde-4/support/eigen.nix
+++ b/pkgs/desktops/kde-4/support/eigen.nix
@@ -2,6 +2,6 @@ args: with args;
 
 stdenv.mkDerivation {
   name = "eigen-1.0.5";
-  src = svnSrc "eigen" "1wh6kdmzsxmk6byp4rq91pz4rfr7hnh17g8f415p0ywxalg6pfkg";
+  src = svnSrc "eigen" "0dr2gzrf17bdgxj4f9ibk7x5j7fqwwjsl800dzfvrhgj6v1mxm4x";
   buildInputs = [ cmake ];
 }
diff --git a/pkgs/desktops/kde-4/support/gmm.nix b/pkgs/desktops/kde-4/support/gmm.nix
index 768df83c8df..843f9f6aaed 100644
--- a/pkgs/desktops/kde-4/support/gmm.nix
+++ b/pkgs/desktops/kde-4/support/gmm.nix
@@ -2,6 +2,6 @@ args: with args;
 
 stdenv.mkDerivation {
   name = "gmm-svn";
-  src = svnSrc "gmm" "1hxc6ymrjccz4mnix44fwpkmv8fvg5y5a9j3y6liz37wj87snnxd";
+  src = svnSrc "gmm" "0qvx9jf17z0mpwy8k6w6bla94gkkslkiv5w98aajfcq34n0zxcpc";
   buildInputs = [ cmake ];
 }
diff --git a/pkgs/desktops/kde-4/support/qca.nix b/pkgs/desktops/kde-4/support/qca.nix
index a9b69787965..fda435c7bff 100644
--- a/pkgs/desktops/kde-4/support/qca.nix
+++ b/pkgs/desktops/kde-4/support/qca.nix
@@ -2,7 +2,7 @@ args: with args;
 
 stdenv.mkDerivation {
   name = "qca-2.0.0dev";
-  src = svnSrc "qca" "1dm7q9v54ps0iix55hx4y51k379gqiwai5ym7avafis9j0py28aj";
+  src = svnSrc "qca" "0dycmk8fn57mz2pfxck6d0g833fqg9zrw17789vxb4ks0xz0p3zp";
   buildInputs = [ cmake qt openssl gettext cyrus_sasl libgcrypt gnupg ];
   patchPhase = "sed -e '/set(qca_PLUGINSDIR/s@\${QT_PLUGINS_DIR}@\${CMAKE_INSTALL_PREFIX}/plugins@' -i ../CMakeLists.txt";
 }
diff --git a/pkgs/desktops/kde-4/support/qimageblitz.nix b/pkgs/desktops/kde-4/support/qimageblitz.nix
index a4a88afa7e7..3364b4eac5d 100644
--- a/pkgs/desktops/kde-4/support/qimageblitz.nix
+++ b/pkgs/desktops/kde-4/support/qimageblitz.nix
@@ -2,6 +2,6 @@ args: with args;
 
 stdenv.mkDerivation {
   name = "qimageblitz-4.0.0svn";
-  src = svnSrc "qimageblitz" "0vsan536qv8hj8l8ghmji62xzc75xm896h7fpwk48vq9f8w9fn4q";
+  src = svnSrc "qimageblitz" "0gi78bald70bc540jqcpa70x23hycywibn4raf5602hv4d5n8mnx";
   buildInputs = [cmake qt];
 }
diff --git a/pkgs/desktops/kde-4/support/soprano.nix b/pkgs/desktops/kde-4/support/soprano.nix
index 4b0e78f91cf..0cb490b9db7 100644
--- a/pkgs/desktops/kde-4/support/soprano.nix
+++ b/pkgs/desktops/kde-4/support/soprano.nix
@@ -2,7 +2,7 @@ args: with args;
 
 stdenv.mkDerivation {
   name = "soprano-1.9.0svn";
-  src = svnSrc "soprano" "1j61jf8vzamknmzmrxpwba9v7c0vnb8zmlh9n0sgawjgbzfgq2zn";
+  src = svnSrc "soprano" "02xfp7g41ahxwczkxipyi13rav6akhwgspxdhgk5gm94rg10hq2l";
   CLUCENE_HOME=cluceneCore;
   buildInputs = [ cmake qt cluceneCore redland ];
 }
diff --git a/pkgs/desktops/kde-4/support/strigi.nix b/pkgs/desktops/kde-4/support/strigi.nix
index 0ed955ed710..d1ec98ea25f 100644
--- a/pkgs/desktops/kde-4/support/strigi.nix
+++ b/pkgs/desktops/kde-4/support/strigi.nix
@@ -2,8 +2,8 @@ args: with args;
 
 stdenv.mkDerivation {
   name = "strigi-svn";
-  src = svnSrc "strigi" "0zmfy7ga4y49hl3rgw8ypqag36k78k2wfkkxka8xskrd249516ha";
+  src = svnSrc "strigi" "0dp145n93bqp91lvk2n10mghppyhdm3anh1l3a18d20hrvsm42z5";
   CLUCENE_HOME=cluceneCore;
-  buildInputs = [ cmake zlib cluceneCore bzip2 libxml2 qt dbus.libs
+  buildInputs = [ cmake zlib cluceneCore bzip2 libxml2 qt dbus
   log4cxx stdenv.gcc.libc exiv2 bison cppunit perl ];
 }
diff --git a/pkgs/desktops/kde-4/support/taglib.nix b/pkgs/desktops/kde-4/support/taglib.nix
index 5a5a26e09c3..9a2acc96636 100644
--- a/pkgs/desktops/kde-4/support/taglib.nix
+++ b/pkgs/desktops/kde-4/support/taglib.nix
@@ -2,6 +2,6 @@ args: with args;
 
 stdenv.mkDerivation {
   name = "taglib-1.4svn";
-  src = svnSrc "taglib" "1wszymg4r3mm06wbxviqmnxra120kc1rxbk0a6kjrxjpyr8qcn2k";
+  src = svnSrc "taglib" "1myfgykflbs3l1mrzg4iv8rb1mbd0vpmzl5dnnslfi9b0xg6ydip";
   buildInputs = [ cmake zlib ];
 }
diff --git a/pkgs/desktops/kde-4/toys/default.nix b/pkgs/desktops/kde-4/toys/default.nix
index 47fad5f4620..39933f0b131 100644
--- a/pkgs/desktops/kde-4/toys/default.nix
+++ b/pkgs/desktops/kde-4/toys/default.nix
@@ -4,10 +4,9 @@ stdenv.mkDerivation {
   name = "kdetoys-4.0.0";
   
   src = fetchurl {
-    url = mirror://kde/stable/4.0.0/src/kdetoys-4.0.0.tar.bz2;
-    sha256 = "0j7kk4ripg2sw4m8ym96aiyi8rsfb4p7kqp9kmik850flqighhsk";
+    url = http://download.kde.org/stable/4.0.0/src/kdetoys-4.0.0.tar.bz2;
+    md5 = "6e4e2eea3d87718f48716f975b48ada2";
   };
 
-  propagatedBuildInputs = [kdeworkspace];
-  buildInputs = [cmake];
+  buildInputs = [kdelibs kdepimlibs kdeworkspace];
 }
diff --git a/pkgs/desktops/kde-4/utils/default.nix b/pkgs/desktops/kde-4/utils/default.nix
index f9d76e3e6fc..2b256a8e768 100644
--- a/pkgs/desktops/kde-4/utils/default.nix
+++ b/pkgs/desktops/kde-4/utils/default.nix
@@ -4,12 +4,10 @@ stdenv.mkDerivation {
   name = "kdeutils-4.0.0";
   
   src = fetchurl {
-    url = mirror://kde/stable/4.0.0/src/kdeutils-4.0.0.tar.bz2;
-    sha256 = "0ha31z79ikkbknhyklihzys0w4jfz4qx8jiyja0gwh428f7mxqj4";
+    url = http://download.kde.org/stable/4.0.0/src/kdeutils-4.0.0.tar.bz2;
+    md5 = "5815625f215ff3be47a21074d2c047a0";
   };
 
-  propagatedBuildInputs = [kdeworkspace gmp libzip python libarchive];
-  buildInputs = [cmake];
+  buildInputs = [kdelibs kdepimlibs kdeworkspace gmp libzip python ];
 # TODO : tpctl
-  patchPhase="fixCmakeDbusCalls";
 }
diff --git a/pkgs/desktops/kde-4/workspace/builder.sh b/pkgs/desktops/kde-4/workspace/builder.sh
new file mode 100755
index 00000000000..648d6175f35
--- /dev/null
+++ b/pkgs/desktops/kde-4/workspace/builder.sh
@@ -0,0 +1,12 @@
+source ${stdenv}/setup
+
+myPatchPhase()
+{
+	echo "Fixing dbus calls in CMakeLists.txt files"
+# Trailing slash in sed is essential
+	find .. -name CMakeLists.txt \
+	| xargs sed -e "s@\${DBUS_INTERFACES_INSTALL_DIR}/@${kdelibs}/share/dbus-1/interfaces/@" -i
+	sed -e '/^#define HAS_RANDR_1_2 1$/d' -i ../kcontrol/randr/randr.h
+}
+patchPhase=myPatchPhase
+genericBuild
diff --git a/pkgs/desktops/kde-4/workspace/default.nix b/pkgs/desktops/kde-4/workspace/default.nix
index 5b16dee4d2e..70d2b3eddc3 100644
--- a/pkgs/desktops/kde-4/workspace/default.nix
+++ b/pkgs/desktops/kde-4/workspace/default.nix
@@ -2,14 +2,14 @@ args: with args;
 
 stdenv.mkDerivation {
   name = "kdebase-workspace-4.0.0";
+  builder = ./builder.sh;
   
   src = fetchurl {
-    url = mirror://kde/stable/4.0.0/src/kdebase-workspace-4.0.0.tar.bz2;
-    sha256 = "08sgp7jaqljdxwsgr5lyyfd6w734yv24zswps1mchmhj01vz1fcg";
+    url = http://download.kde.org/stable/4.0.0/src/kdebase-workspace-4.0.0.tar.bz2;
+    md5 = "f3d2155ff5ff7472a8884bd3f31bff16";
   };
 
-  propagatedBuildInputs = [kdelibs kdepimlibs stdenv.gcc.libc libusb
-  libpthreadstubs];
-  buildInputs = [cmake];
-  patchPhase = "fixCmakeDbusCalls";
+  buildInputs = [kdelibs kdepimlibs kdebase kderuntime stdenv.gcc.libc];
+  inherit kdelibs;
 }
+
diff --git a/pkgs/desktops/kde/kdelibs/default.nix b/pkgs/desktops/kde/kdelibs/default.nix
index 91720c9a66b..9eb6625d45a 100644
--- a/pkgs/desktops/kde/kdelibs/default.nix
+++ b/pkgs/desktops/kde/kdelibs/default.nix
@@ -1,4 +1,7 @@
-args: with args;
+{ stdenv, fetchurl, libX11, libXt, libXext, zlib, perl, qt, openssl, pcre
+, pkgconfig, libjpeg, libpng, libtiff, libxml2, libxslt, libtool, expat
+, freetype, bzip2, cups
+}:
 
 let version = "3.5.7"; in
 
diff --git a/pkgs/development/compilers/bigloo/default.nix b/pkgs/development/compilers/bigloo/default.nix
new file mode 100644
index 00000000000..2fb0b7c2276
--- /dev/null
+++ b/pkgs/development/compilers/bigloo/default.nix
@@ -0,0 +1,130 @@
+args:
+( args.mkDerivationByConfiguration {
+    flagConfig = {
+    /*
+Bigloo compiler:
+   --native=yes|no [default yes]
+   --jvm=yes|no|force [default no]
+   --dotnet=yes|no|force [default no]
+   --customgc=yes|no [default yes]
+   --bee=partial|full [default partial]
+
+API:
+   --enable-[calendar|fthread|mail|multimedia|pkgcomp|pkglib|pthread|sqlite|srfi1|ssl|web]
+   --disable-[calendar|fthread|mail|multimedia|pkgcomp|pkglib|pthread|sqlite|srfi1|ssl|web]
+
+Path:
+   --prefix=dir (sets bin, lib, zip, man, info and doc dirs)
+   --bindir=file
+   --libdir=file
+   --gcdir=dir (directory for non custom gc library)
+   --fildir=file
+   --zipdir=file
+   --dlldir=file
+   --mandir=file
+   --infodir=file
+   --docdir=file
+   --tmpdir=file (Bigloo tmp dir)
+   --tmp=file (Installation tmp dir)
+   --lispdir=file
+
+Tools and compilers:
+   --bigloo=comp [default bigloo]
+   --cc=comp [default gcc]
+   --ld=comp [default gcc]
+   --as=asm
+   --cflags=compilation flags
+   --lflags=compiler link flags
+   --coflags=optimization_flags
+   --cpicflags=pic_flags
+   --ldlibs=ld_libs
+   --ldcomplibs=ld_compiler_libs
+   --ldflags=ld_flags
+   --emacs=file
+   --xemacs=file (deprecated, use "--emacs" option)
+   --indent=file
+   --icc (configure for icc)
+
+Host configuration:
+   --arch=[i586|i686|athlon|athlon-tbird|athlon-mp|athlon-xp|k6-2|k6-3|pentium3|pentium4] (configure for specified hardware)
+   --a.out=file
+   --a.bat=file
+   --dirname=file-or-command
+   --force-posixos=operating-system
+   --os-win32
+   --os-macosx (tune for MacOSX)
+   --no-os-macosx (disable MacOSX auto configuration)
+   --cygwin-dos-path=[dos path]
+   --cygwin-dos-jvm=yes|no [default yes]
+   --no-share (disable shared libraries support)
+   --no-ldpreload
+   --sharedbde=yes|no [default no] (link Bde tools against shared libraries)
+   --sharedcompiler=yes|no [default no] (link Bigloo against shared libraries)
+
+JVM configuration:
+   --java=file
+   --javac=file
+   --javaprefix=dir
+   --javashell=shell [should be sh or msdos (default sh)]
+   --native-default-backend
+   --jvm-default-backend
+
+.NET configuration:
+   --pnet (configure for GNU pnet)
+   --mono (configure for Ximian Mono)
+   --dotnetldstyle=style [should be pnet, mono]
+   --dotnetcsccstyle=style [should be pnet, mono]
+   --dotnetclrstyle=style [should be pnet, mono]
+   --dotnetcscc=file
+   --dotnetld=file
+   --dotnetclr=file
+   --dotnetclropt=options
+   --dotnetshell=shell [should be sh or msdos (default sh)]
+   --dotnetasm=asm [optional]
+
+Misc:
+   --finalization=yes|no [default no]
+   --benchmark=yes|no [default no] (must use --arch too)
+   --stack-check=no
+
+Configuration settings:
+   --bigloo.h[=file]
+   --bigloo_gc.h[=file]
+   --bigloo_config.h[=file]
+   --bigloo_config.jvm[=file]
+   --Makefile.config=file
+   --configure.log=file
+   --no-summary
+   --bootconfig
+   --bootdir=dir
+   --configureinfo=yes|no [default no]
+
+   */
+
+    }; 
+
+    extraAttrs = co : rec {
+      name = "bigloo3.0d-alpha05Feb08"; # Thanks to Manuel Serrano for fixing the mv trouble 
+
+      # take care, modifying generated C-Code (altering string and length of string) 
+      preConfigure = 
+        "sed -i -e 's=/bin/rm -f \", 14=rm -f \", 9=' "
+         + " -e 's=/bin/mv \", 11=mv \", 6=' "
+         + "comptime/Cc/cc.c\n"
+      + "sed -i -e 's=/bin/rm=rm=' "
+           + " -e 's=/bin/mv=mv=' "
+         + "configure  gc/install-gc-*";
+
+      src = args.fetchurl {
+        url = "ftp://ftp-sop.inria.fr/mimosa/fp/Bigloo/${name}.tar.gz";
+        sha256 = "03rknb1nl3z2f86k6iazbrapmli2m8lcs21lqrri8ys8s72dm33w";
+      };
+
+    meta = { 
+      description = "scheme -> C / Java compiler (.net experimental)";
+      homepage = http://www-sop.inria.fr/mimosa/fp/Bigloo/;
+      # you can choose one of the following licenses: 
+      license = ["GPL"];
+    };
+  };
+} ) args
diff --git a/pkgs/development/compilers/ghc-6.8/default.nix b/pkgs/development/compilers/ghc-6.8/default.nix
index 6226fa2988d..518b5f391a3 100644
--- a/pkgs/development/compilers/ghc-6.8/default.nix
+++ b/pkgs/development/compilers/ghc-6.8/default.nix
@@ -1,4 +1,4 @@
-args: with args;
+{stdenv, fetchurl, readline, ghc, perl, m4, gmp, ncurses}:
 
 stdenv.mkDerivation (rec {
   name = "ghc-6.8.2";
@@ -41,7 +41,6 @@ stdenv.mkDerivation (rec {
     sed -i \"s|^\\\(ld-options.*$\\\)|\\\1 -L${ncurses}/lib|\" libraries/readline/readline.buildinfo.in
   ";
 
-  dontStrip = 1;
   inherit (stdenv) gcc;
   inherit readline gmp ncurses;
 })
diff --git a/pkgs/development/compilers/ghc/boot.nix b/pkgs/development/compilers/ghc/boot.nix
index bf096616a96..ab606d4c2ba 100644
--- a/pkgs/development/compilers/ghc/boot.nix
+++ b/pkgs/development/compilers/ghc/boot.nix
@@ -22,7 +22,6 @@ stdenv.mkDerivation {
     else throw "cannot bootstrap GHC on this platform"; 
 
   buildInputs = [perl];
-  dontStrip = 1;
 
   # On Linux, use patchelf to modify the executables so that they can
   # find readline/gmp.
@@ -53,4 +52,5 @@ stdenv.mkDerivation {
     done
 
   " else "";
+
 }
diff --git a/pkgs/development/compilers/ghc/createGhcWrapper/default.nix b/pkgs/development/compilers/ghc/createGhcWrapper/default.nix
index 5eeb4d43190..4d6094f5d72 100644
--- a/pkgs/development/compilers/ghc/createGhcWrapper/default.nix
+++ b/pkgs/development/compilers/ghc/createGhcWrapper/default.nix
@@ -1,9 +1,15 @@
-args: with args;
+args: with args; with lib; with annotatedDerivations;
 
 stdenv.mkDerivation {
   inherit suffix name ghc ;
 
-  buildInputs = libraries ++ [ghcPkgUtil];
+  buildInputs = map delAnnotation (libraries ++ [ghcPkgUtil]);
+  #tags = if (installSourceAndTags == true) then
+  #        map sourceWithTagsDerivation ( uniqList { inputList = 
+  #            ( filterAnnotated ( concatLists (map uniqAnnotatedDeps libraries ) ) ) ; } )
+  #        else [];
+  tags = map (x : sourceWithTagsDerivation (x.sourceWithTags)) 
+          (uniqList { inputList=  filter annotatedWithSourceAndTagInfo libraries; } );
 
   phases="installPhase";
 
@@ -21,5 +27,12 @@ GHC_PACKAGE_PATH=\${GHC_PACKAGE_PATH}\${g} \$ghc/bin/$app \"\\\$@\"
 EOF
       chmod +x \"\$out/bin/\$a$suffix\"
     done
+
+    ensureDir \$out/{src,tags}
+    for i in \$tags; do
+      for path in src tags; do
+        ln -s \$i/\$path/* \$out/\$path
+      done
+    done
 ";
 }
diff --git a/pkgs/development/compilers/ghcs/default.nix b/pkgs/development/compilers/ghcs/default.nix
index b4e14c9921d..6dd37576524 100644
--- a/pkgs/development/compilers/ghcs/default.nix
+++ b/pkgs/development/compilers/ghcs/default.nix
@@ -1,11 +1,13 @@
-{ ghcPkgUtil, gnum4, perl, ghcboot, stdenv, fetchurl, recurseIntoAttrs, gmp, readline, lib } : rec {
+{ ghcPkgUtil, gnum4, perl, ghcboot, stdenv, fetchurl, recurseIntoAttrs, gmp, readline, lib, annotatedDerivations, hasktags, ctags } : 
+with annotatedDerivations;
+rec {
   
   /* What's in here?
      Goal:  really pure GHC. This means put every library into its each package.conf
      and add all together using GHC_PACKAGE_PATH
 
      First I've tried separating the build of ghc from it's lib. It hase been to painful. I've failed.
-     Now there is splitpackagedb.hs which just takes the installed package.conf
+     Now there is nix_ghc_pkg_tool.hs which just takes the installed package.conf
      and creates a new package db file for each contained package.
 
      The final attribute set looks similar to this:
@@ -31,31 +33,6 @@
 
   */
 
-  # creates a nix package out of the single package.conf files created when after installing ghc (see splitpackagedb.hs)
-  packageByPackageDB = otherPkg : name : packageconfpath : propagatedBuildInputs : stdenv.mkDerivation {
-    inherit name otherPkg propagatedBuildInputs;
-    phases = "buildPhase fixupPhase";
-    buildInputs = [ghcPkgUtil];
-    buildPhase = "setupHookRegisteringPackageDatabase \"$otherPkg/${packageconfpath}\"
-      ";
-  };
-
-  # used to automatically get dependencies ( used for core_libs ) 
-  # TODO use kind of state and evaluate deps of a dep only once
-  resolveDeps = ghc : libs : 
-    let attrs = builtins.listToAttrs libs; in
-      rec {
-        # using undocumented feature that attribute can contain hyphens when using listToAttrs
-        # You should be able to get the attribute values using __getAttr
-        result = builtins.listToAttrs (map ( l : lib.nv l.name (
-                               packageByPackageDB ghc l.name 
-                                      ("lib/ghc-${ghc.version}/${l.name}.conf")
-                                      (map (n: builtins.getAttr n result) l.deps)
-                ) ) libs );
-      }.result;
-
-
-  
   #this only works for ghc-6.8 right now
   ghcAndLibraries = { version, src /* , core_libraries, extra_libraries  */
                     , extra_src }:
@@ -74,7 +51,8 @@
         sed -i \"s|^\(library-dirs.*$\)|\1 \\\"$ncurses/lib\\\"|\" libraries/readline/package.conf.in
       ";
 
-      splitpackagedb = ./splitpackagedb.hs;
+      # TODO add unique (filter duplicates?) shouldn't be there? 
+      nix_ghc_pkg_tool = ./nix_ghc_pkg_tool.hs;
 
       configurePhase = "./configure"
        +" --prefix=\$out "
@@ -89,9 +67,10 @@
       #  note : I don't know yet wether it's a good idea to have RUNGHC.. It's faster
       # but you can't pass packages, can you?
       postInstall = "
-        cp \$splitpackagedb splitpackagedb.hs
-        \$out/bin/ghc-\$version --make -o splitpackagedb  splitpackagedb.hs;
-        ./splitpackagedb \$out/lib/ghc-\$version/package.conf \$out/lib/ghc-\$version
+        cp \$nix_ghc_pkg_tool nix_ghc_pkg_tool.hs
+        \$out/bin/ghc-\$version --make -o nix_ghc_pkg_tool  nix_ghc_pkg_tool.hs;
+        ./nix_ghc_pkg_tool split \$out/lib/ghc-\$version/package.conf \$out/lib/ghc-\$version
+        cp nix_ghc_pkg_tool \$out/bin
 
         if test -x \$out/bin/runghc; then
           RUNHGHC=\$out/bin/runghc # > ghc-6.7/8 ?
@@ -106,37 +85,103 @@
       ";
     };
 
-    # Why this effort? If you want to use pretty-0.9 you can do this now without cabal choosing the 1.0 version hassle 
-    core_libs = resolveDeps ghc
-      [ { name = "Cabal-1.2.3.0"; deps = ["base-3.0.1.0" "pretty-1.0.0.0" "old-locale-1.0.0.0" "old-time-1.0.0.0" "directory-1.0.0.0" "unix-2.3.0.0" "process-1.0.0.0" "array-0.1.0.0" "containers-0.1.0.1" "rts-1.0" "filepath-1.1.0.0"];} #
-        { name = "array-0.1.0.0"; deps = ["base-3.0.1.0"];}
-        { name = "base-3.0.1.0"; deps = [];} #
-        { name = "bytestring-0.9.0.1"; deps = [ "base-3.0.1.0" "array-0.1.0.0" ];}
-        { name = "containers-0.1.0.1"; deps = [ "base-3.0.1.0" "array-0.1.0.0" ];}
-        { name = "directory-1.0.0.0"; deps = [ "base-3.0.1.0" "old-locale-1.0.0.0" "old-time-1.0.0.0" "filepath-1.1.0.0"];}
-        { name = "filepath-1.1.0.0"; deps = [ "base-3.0.1.0" ];} #
-        { name = "ghc-${version}"; deps = [ "base-3.0.1.0" "old-locale-1.0.0.0" "old-time-1.0.0.0" "filepath-1.1.0.0" "directory-1.0.0.0" "array-0.1.0.0" "containers-0.1.0.1" "hpc-0.5.0.0" "bytestring-0.9.0.1" "pretty-1.0.0.0" "packedstring-0.1.0.0" "template-haskell-2.2.0.0" "unix-2.3.0.0" "process-1.0.0.0" "readline-1.0.1.0" "Cabal-1.2.3.0" "random-1.0.0.0" "haskell98-1.0.1.0"];}
-        { name = "haskell98-1.0.1.0"; deps = [ "base-3.0.1.0" "old-locale-1.0.0.0" "old-time-1.0.0.0" "filepath-1.1.0.0" "directory-1.0.0.0" "random-1.0.0.0" "unix-2.3.0.0" "process-1.0.0.0" "array-0.1.0.0"];}
-        { name = "hpc-0.5.0.0"; deps = [ "base-3.0.1.0" "old-locale-1.0.0.0" "old-time-1.0.0.0" "filepath-1.1.0.0" "directory-1.0.0.0" "array-0.1.0.0" "containers-0.1.0.1"]; }
-        { name = "old-locale-1.0.0.0"; deps = [ "base-3.0.1.0"];}
-        { name = "old-time-1.0.0.0"; deps = [ "base-3.0.1.0" "old-locale-1.0.0.0" ];}
-        { name = "packedstring-0.1.0.0"; deps = [ "base-3.0.1.0" "array-0.1.0.0" ];}
-        { name = "pretty-1.0.0.0"; deps = [ "base-3.0.1.0" ];}
-        { name = "process-1.0.0.0"; deps = [ "base-3.0.1.0" "old-locale-1.0.0.0" "old-time-1.0.0.0" "filepath-1.1.0.0" "directory-1.0.0.0" "unix-2.3.0.0"];}
-        { name = "random-1.0.0.0"; deps = [ "base-3.0.1.0" "old-locale-1.0.0.0" "old-time-1.0.0.0"];}
-        { name = "readline-1.0.1.0"; deps = [ "base-3.0.1.0" "old-locale-1.0.0.0" "old-time-1.0.0.0" "filepath-1.1.0.0" "directory-1.0.0.0" "unix-2.3.0.0" "process-1.0.0.0" ];}
-        { name = "rts-1.0"; deps = [ "base-3.0.1.0" ];} #
-        { name = "template-haskell-2.2.0.0"; deps = [ "base-3.0.1.0" "pretty-1.0.0.0" "array-0.1.0.0" "packedstring-0.1.0.0" "containers-0.1.0.1" ];}
-        { name = "unix-2.3.0.0"; deps = [ "base-3.0.1.0" "old-locale-1.0.0.0" "old-time-1.0.0.0" "filepath-1.1.0.0" "directory-1.0.0.0" ];}
-      ];
-
-      
-
-    extra_libs = [];
-
-    #all_libs = core_libs ++ extra_libs;
-
-  } );
+    core_libs = rec {
+        #   name (using lowercase letters everywhere because using installing packages having different capitalization is discouraged) - this way there is not that much to remember?
+
+        cabal_darcs_name = "cabal-darcs";
+
+        # introducing p here to speed things up.
+        # It merges derivations (defined below) and additional inputs. I hope that using as few nix functions as possible results in greates speed?
+        # unfortunately with x; won't work because it forces nix to evaluate all attributes of x which would lead to infinite recursion
+        pkgs = let x = derivations; in {
+            # ghc extra packages 
+          cabal = { name = "Cabal-1.2.3.0"; srcDir = "libraries/Cabal";
+                          deps = [x.base x.pretty x.old_locale x.old_time
+                            x.directory x.unix x.process x.array x.containers
+                            x.rts x.filepath ]; };
+          array = { name = "array-0.1.0.0"; srcDir = "libraries/array";
+                          deps = [x.base ]; };
+          base = { name = "base-3.0.1.0"; srcDir = "libraries/base";
+                          deps = [x.rts ]; };
+          bytestring = { name = "bytestring-0.9.0.1"; srcDir = "libraries/bytestring";
+                          deps = [ x.base x.array ];};
+          containers = { name = "containers-0.1.0.1"; srcDir = "libraries/containers";
+                          deps = [ x.base x.array ];};
+          directory = { name = "directory-1.0.0.0"; srcDir = "libraries/directory";
+                          deps = [ x.base x.old_locale x.old_time x.filepath ];};
+          filepath = { name = "filepath-1.1.0.0"; srcDir = "libraries/filepath";
+                          deps = [ x.base ];};
+          ghc = { name = "ghc-${version}"; srcDir = "libraries/Cabal";
+                          deps = [ x.base x.old_locale x.old_time x.filepath
+                            x.directory x.array x.containers x.hpc x.bytestring
+                            x.pretty x.packedstring x.template_haskell x.unix
+                            x.process x.readline x.cabal x.random x.haskell98 ]; };
+          haskell98 = { name = "haskell98-1.0.1.0"; srcDir = "libraries/haskell98";
+                          deps = [ x.base x.old_locale x.old_time x.filepath
+                            x.directory x.random x.unix x.process x.array]; };
+          hpc = { name = "hpc-0.5.0.0"; srcDir = "libraries/hpc";
+                          deps = [ x.base x.old_locale x.old_time x.filepath
+                            x.directory x.array x.containers ]; };
+          old_locale = { name = "old-locale-1.0.0.0"; srcDir = "libraries/old-locale";
+                          deps = [ x.base ]; };
+          old_time = { name = "old-time-1.0.0.0"; srcDir = "libraries/old-time";
+                          deps = [ x.base x.old_locale ];};
+          packedstring = { name = "packedstring-0.1.0.0"; srcDir = "libraries/packedstring";
+                          deps = [ x.base x.array ];};
+          pretty = { name = "pretty-1.0.0.0"; srcDir = "libraries/pretty";
+                          deps = [ x.base ];};
+          process = { name = "process-1.0.0.0"; srcDir = "libraries/process";
+                          deps = [ x.base x.old_locale x.old_time x.filepath
+                            x.directory x.unix ]; };
+          random = { name = "random-1.0.0.0"; srcDir = "libraries/random";
+                          deps = [ x.base x.old_locale x.old_time ]; };
+          readline = { name = "readline-1.0.1.0"; srcDir = "libraries/readline";
+                          deps = [ x.base x.old_locale x.old_time x.filepath
+                            x.directory x.unix x.process ];};
+          rts = rec { 
+                  name = "rts-1.0"; srcDir = "rts"; # TODO: Doesn't have .hs files so I should use ctags if creating tags at all
+                  deps = [];
+                  createTagFiles = [
+                      { name = "${name}_haskell_tags";
+                        tagCmd = "${toString ctags}/bin/ctags -R .;mv tags \$TAG_FILE"; }
+                    ];
+          };
+          template_haskell = { name = "template-haskell-2.2.0.0"; srcDir = "libraries/template-haskell";
+                          deps = [ x.base x.pretty x.array x.packedstring x.containers ];};
+          unix = { name = "unix-2.3.0.0"; srcDir = "libraries/unix";
+                          deps = [ x.base x.old_locale x.old_time x.filepath x.directory ];};
+        };
+
+        toDerivation = attrs : with attrs;
+              rec {
+                inherit name;
+
+                #aDeps = concatLists ( catAttrs ( subsetmap id args [ "buildInputs" "propagatedBuildInputs" ] ) );
+                aDeps = deps;
+
+                # dummy derivation, only creates setup-hook for package database located in the ghc derivation 
+                aDeriv = stdenv.mkDerivation {
+                    inherit name;
+                    phases = "buildPhase fixupPhase";
+                    buildInputs = [ ghcPkgUtil ];
+                    propagatedBuildInputs = [ ghc ] ++ map delAnnotation  attrs.deps;
+                    buildPhase = "setupHookRegisteringPackageDatabase \"${ghc}/lib/ghc-${ghc.version}/${name}.conf\"";
+                };
+
+                sourceWithTags = {
+                  src = ghc.src;
+                  inherit srcDir;
+                  name = name + "-src-with-tags";
+                  createTagFiles = lib.maybeAttr "createTagFiles" [
+                      { name = "${name}_haskell_tags";
+                        tagCmd = "${toString hasktags}/bin/hasktags-modified --ctags `find . -type f -name \"*.*hs\"`; sort tags > \$TAG_FILE"; } 
+                    ] attrs;
+                };
+          };
+        derivations = with lib; builtins.listToAttrs (lib.concatLists ( lib.mapRecordFlatten 
+                  ( n : attrs : let d = (toDerivation attrs); in [ (nv n d) (nv attrs.name d) ] ) pkgs ) );
+    }.derivations;
+  });
 
   ghc68 = ghcAndLibraries rec {
     version = "6.8.2";
@@ -155,16 +200,5 @@
       #url = http://www.haskell.org/ghc/dist/stable/dist/ghc-6.8.20070912-src-extralibs.tar.bz2;
       #sha256 = "0py7d9nh3lkhjxr3yb3n9345d0hmzq79bi40al5rcr3sb84rnp9r";
     };
-
-    # this will change because of dependency hell :) 
-    #core_libraries = [ "Cabal" /* "Win32" */ "array" "base" "bytestring" "containers" 
-                       #"directory" "doc" "filepath" "haskell98" "hpc" "old-locale" "old-time"
-                       #"packedstring" "pretty" "process" "random" "readline" "stamp" 
-                       #"template-haskell" "unix" ];
-
-    #extra_libraries = [ "ALUT" "GLUT" "HGL" "HUnit" "ObjectIO" "OpenAL" "OpenGL" "QuickCheck" "X11" 
-                        #"arrows" "cgi" "fgl" "haskell-src" "html" "mtl" "network" "parallel" "parsec" 
-                        #"regex-base" "regex-compat" "regex-posix" "stm" "time" "xhtm" ];
-
   };
 }
diff --git a/pkgs/development/compilers/ghcs/nix_ghc_pkg_tool.hs b/pkgs/development/compilers/ghcs/nix_ghc_pkg_tool.hs
new file mode 100644
index 00000000000..494b37807fa
--- /dev/null
+++ b/pkgs/development/compilers/ghcs/nix_ghc_pkg_tool.hs
@@ -0,0 +1,48 @@
+-- packages: filepath,Cabal,directory
+{-# OPTIONS_GHC -fglasgow-exts #-}
+module Main where
+import Distribution.InstalledPackageInfo (InstalledPackageInfo (..))
+import Distribution.Package (showPackageId)
+import System.FilePath
+import System.Environment
+import System.Directory
+import System.IO
+import System.Exit
+import Data.List
+
+usage = unlines [
+    " usage a) <app-name> split in_path out_path"
+  , "       b) <app-anme> join out_path"
+  , "This small helper executable servers two purposes:"
+  , "a) split the main package db created by ghc installation into single libs"
+  , "   so that nix can add them piecwise as needed to buildInputs"
+  , "b) merge databases into one single file, so when building a library"
+  , "   we can create one db containing all dependencies passed by GHC_PACKAGE_PATH"
+  , "   I think this is a better solution than patching and mantaining cabal so"
+  , "   that it support GHC_PACKAGE_PATH (not only by accident) ?"
+  ]
+
+mySplit :: (Eq Char) => [Char] ->[[ Char ]]
+mySplit [] = []
+mySplit list = let (l, l') = span (not . (`elem` ":;")) list
+                    in l: mySplit (drop 1 l')
+
+myReadFile f = doesFileExist f >>= \fe ->
+    if fe then readFile f
+          else do hPutStrLn stderr $ "unable to read file " ++ f
+                  exitWith (ExitFailure 1)
+
+main = do
+  args <- getArgs
+  case args of
+    ["split", inFile, outDir] -> do
+      -- prior to 6.9.x (when exactly) this must be InstalledPackageInfo only (not InstalledPackageInfo_ String) 
+      -- (packagedb :: [InstalledPackageInfo_ String] ) <- fmap read $ myReadFile inFile
+      (packagedb :: [InstalledPackageInfo] ) <- fmap read $ myReadFile inFile
+      mapM_ (\pi -> let fn = outDir </> (showPackageId $ package pi) ++ ".conf"
+                    in writeFile fn (show [pi])
+            ) packagedb
+    ["join", outpath] -> do
+      getEnv "GHC_PACKAGE_PATH" >>= mapM myReadFile . nub . mySplit 
+        >>= writeFile outpath . show . concat . map (read :: String -> [InstalledPackageInfo])
+    _ -> putStrLn usage
diff --git a/pkgs/development/compilers/ghcs/splitpackagedb.hs b/pkgs/development/compilers/ghcs/splitpackagedb.hs
deleted file mode 100644
index 0f7ceb0d401..00000000000
--- a/pkgs/development/compilers/ghcs/splitpackagedb.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-{-# OPTIONS_GHC -fglasgow-exts #-}
-module Main where
-import Distribution.InstalledPackageInfo (InstalledPackageInfo (..))
-import Distribution.Package (showPackageId)
-import System.FilePath
-import System.Environment
-
-usage = unlines [
-  "<appname> in outDir"
-  , "reads package db appname"
-  , "and creates a package database for each contained package in outDir"
-  , "" 
-  , "The purpose is to be able to control availible packages to ensure purity in nix."
-  , "Separating each package from the auomated ghc build process is to painful (for me)"
-  ]
-
-main = do
-  args <- getArgs
-  case args of
-    [inFile, outDir] -> do
-      (packagedb :: [InstalledPackageInfo] ) <- fmap read $ readFile inFile
-      mapM_ (\pi -> let fn = outDir </> (showPackageId $ package pi) ++ ".conf"
-                    in writeFile fn (show [pi])
-            ) packagedb
-    _ -> putStrLn usage
diff --git a/pkgs/development/compilers/gwt/builder.sh b/pkgs/development/compilers/gwt/builder.sh
new file mode 100644
index 00000000000..f21b521382b
--- /dev/null
+++ b/pkgs/development/compilers/gwt/builder.sh
@@ -0,0 +1,33 @@
+source $stdenv/setup
+
+tar xfvj $src
+ensureDir $out
+cp -av $name $out
+
+# Create wrapper scripts so that the GWT compiler/host work
+
+libPath="$libstdcpp5/lib:$glib/lib:$gtk/lib:$atk/lib:$pango/lib:$libX11/lib:$libXt/lib:$out/$name/mozilla-1.7.12"
+
+ensureDir $out/bin
+
+cat > $out/bin/gwt-compile <<EOF
+#!/bin/sh
+
+export LD_LIBRARY_PATH=$libPath
+export APPDIR=\`dirname \$0\`
+export LIBXCB_ALLOW_SLOPPY_LOCK=1 # Workaround for bug in Java AWT implementation
+
+java  -cp "\$APPDIR/src:\$APPDIR/bin:$out/$name/gwt-user.jar:$out/$name/gwt-dev-linux.jar" com.google.gwt.dev.GWTCompiler -out "\$APPDIR/www" $@
+EOF
+chmod 755 $out/bin/gwt-compile
+
+cat > $out/bin/gwt-shell <<EOF
+#!/bin/sh
+
+export LD_LIBRARY_PATH=$libPath
+export APPDIR=\`dirname \$0\`
+export LIBXCB_ALLOW_SLOPPY_LOCK=1 # Workaround for bug in Java AWT implementation
+
+java  -cp "\$APPDIR/src:\$APPDIR/bin:$out/$name/gwt-user.jar:$out/$name/gwt-dev-linux.jar" com.google.gwt.dev.GWTShell -out "\$APPDIR/www" $@
+EOF
+chmod 755 $out/bin/gwt-shell
diff --git a/pkgs/development/compilers/gwt/default.nix b/pkgs/development/compilers/gwt/default.nix
new file mode 100644
index 00000000000..50f05e81419
--- /dev/null
+++ b/pkgs/development/compilers/gwt/default.nix
@@ -0,0 +1,14 @@
+{stdenv, fetchurl, glib, gtk, pango, atk, libX11, libXt, libstdcpp5}:
+
+stdenv.mkDerivation {
+  name = "gwt-linux-1.4.61";
+  builder = ./builder.sh;
+
+  src = fetchurl {
+    url = http://google-web-toolkit.googlecode.com/files/gwt-linux-1.4.61.tar.bz2;
+    md5 = "5aa5d630716817f7cf22dc2a36c0fcbd";
+  };
+
+  inherit glib gtk pango atk libX11 libXt libstdcpp5;
+  buildInputs = [glib gtk pango atk libX11 libXt libstdcpp5];
+}
diff --git a/pkgs/development/compilers/jdk/jdk5-sun-linux.nix b/pkgs/development/compilers/jdk/jdk5-sun-linux.nix
index 6521bb779f2..6a15b1f9ec9 100644
--- a/pkgs/development/compilers/jdk/jdk5-sun-linux.nix
+++ b/pkgs/development/compilers/jdk/jdk5-sun-linux.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation {
   builder = ./builder.sh;
   pathname = if stdenv.system == "x86_64-linux" then "/tmp/jdk-1_5_0_14-linux-amd64.bin" else "/tmp/jdk-1_5_0_14-linux-i586.bin";
   md5 = if stdenv.system == "x86_64-linux" then "9dc74d939dd42988280f2c22ab9521bf" else "32df8f2be09c3a0f39da1b3869164b55";
-
+  
   stdenv = stdenv;
   inherit unzip;
 }
diff --git a/pkgs/development/compilers/jdk/jdk6-linux.nix b/pkgs/development/compilers/jdk/jdk6-linux.nix
index 17a23c981e0..0c285c4526e 100644
--- a/pkgs/development/compilers/jdk/jdk6-linux.nix
+++ b/pkgs/development/compilers/jdk/jdk6-linux.nix
@@ -14,18 +14,18 @@ assert pluginSupport -> libstdcpp5 != null;
 
 (stdenv.mkDerivation ({
   name =
-    if installjdk then "jdk-1.6.0_3" else "jre-1.6.0_3";
+    if installjdk then "jdk-1.6.0_4" else "jre-1.6.0_4";
 
   src =
     if stdenv.system == "i686-linux" then
       fetchurl {
-        url = http://download.java.net/dlj/binaries/jdk-6u3-dlj-linux-i586.bin;
-        sha256 = "5c44208fbd5f90b3e6a0692ed9e1e98f5feb0c88aa0cfae5186dddb1f05f731b";
+        url = http://download.java.net/dlj/binaries/jdk-6u4-dlj-linux-i586.bin;
+        sha256 = "955186f497a50106cd1788fcaf032eedc560985826c8a6c3cb7ab43220cad23c";
       }
     else if stdenv.system == "x86_64-linux" then
       fetchurl {
-        url = http://download.java.net/dlj/binaries/jdk-6u3-dlj-linux-amd64.bin;
-        sha256 = "8bc80ea1bf739674c1cacdfba9987a4d15adb54f4b1462a0b48b79815f56b311";
+        url = http://download.java.net/dlj/binaries/jdk-6u4-dlj-linux-amd64.bin;
+        sha256 = "be0e21402a79c5b6cd6c96d34451bcc365619cd063930f3ca1c1abe2ee5dbf43";
       }
     else
       abort "jdk requires i686-linux or x86_64 linux";
diff --git a/pkgs/development/compilers/ocaml/default.nix b/pkgs/development/compilers/ocaml/default.nix
index 678a0a677a2..837a685198b 100644
--- a/pkgs/development/compilers/ocaml/default.nix
+++ b/pkgs/development/compilers/ocaml/default.nix
@@ -1,7 +1,7 @@
 args:
 args.stdenv.lib.listOfListsToAttrs [
-	[ "3.08.0" (import ./3.08.0.nix (args // {stdenv = args.stdenv34;})) ]
+	[ "3.08.0" (import ./3.08.0.nix args) ]
 	[ "3.09.1" (import ./3.09.1.nix args) ]
 	[ "3.10.0" (import ./3.10.0.nix args) ]
-	[ "default" (import ./3.10.0.nix args) ]
+	[ "default" (import ./3.09.1.nix args) ]
 ]
diff --git a/pkgs/development/compilers/roadsend/default.nix b/pkgs/development/compilers/roadsend/default.nix
new file mode 100644
index 00000000000..d7c693b6864
--- /dev/null
+++ b/pkgs/development/compilers/roadsend/default.nix
@@ -0,0 +1,33 @@
+args:
+let edf = args.lib.enableDisableFeature; in
+( args.mkDerivationByConfiguration {
+    flagConfig = {
+      mandatory = { buildInputs = ["bigloo" "curl"]; };
+    } // edf "pcre" "pcre" { } #support pcre extension [default=check]
+      // edf "fcgi" "fcgi" { } #support FastCGI web backend [default=check]
+      // edf "xml" "xml" { pass ="libxml2"; } #support xml extension [default=check]
+      // edf "mysql" "mysql" { pass = "mysql"; } #support mysql extension [default=check]
+      #// edf "sqlite3=[ARG]" "sqlite3=[ARG]" { } [>use SQLite 3 library [default=yes], optionally
+                                #specify the prefix for sqlite3 library
+      // edf "odbc" "odbc" { } #support ODBC extension [default=check]
+      // edf "gtk" "gtk" { } #support PHP-GTK extension [default=no]
+      // edf "gtk2" "gtk2" { }; #support PHP-GTK 2 extension [default=no]
+
+    optionals = [ "libxml2" "gettext" ];
+    extraAttrs = co : {
+      name = "roadsend-2.9.3";
+
+      src = args.fetchurl {
+        url = "http://code.roadsend.com/snaps/roadsend-php-2.9.4.tar.bz2";
+        sha256 = "0nw7rvrrwkss5cp6ws0m3q63q1mcyy27s8yjhy7kn508db1rgl9x";
+      };
+
+    meta = { 
+      description = "roadsend PHP -> C compiler";
+      homepage = http://www.roadsend.com;
+      # you can choose one of the following licenses: 
+      # Runtime license is LPGL 2.1
+      license = ["GPL2"];
+    };
+  };
+} ) args
diff --git a/pkgs/development/guile-modules/guile-lib/default.nix b/pkgs/development/guile-modules/guile-lib/default.nix
new file mode 100644
index 00000000000..cc26c458a06
--- /dev/null
+++ b/pkgs/development/guile-modules/guile-lib/default.nix
@@ -0,0 +1,38 @@
+{stdenv, fetchurl, guile}:
+
+stdenv.mkDerivation rec {
+  name = "guile-lib-0.1.6";
+  src = fetchurl {
+    url = "http://download.gna.org/guile-lib/" + name + ".tar.gz";
+    sha256 = "827744c7954078f1f37e0bf70252ec70b4d60c1482a3542a49bd09723cf65d12";
+  };
+
+  buildInputs = [guile];
+
+  postInstall = ''
+    # Remove modules already provided by Guile.
+    if "${guile}/bin/guile" -c '(use-modules (srfi srfi-34))'
+    then
+	rm -f "$out/share/guile/site/srfi/srfi-34.scm"
+    fi
+    if "${guile}/bin/guile" -c '(use-modules (srfi srfi-35))'
+    then
+	rm -f "$out/share/guile/site/srfi/srfi-35.scm"
+    fi
+
+    # Make modules available under `/lib/site-guile' to comply with Guile's
+    # setup-hook.
+    mkdir -p "$out/lib/site-guile"
+    for f in "$out/share/guile/site"/*
+    do
+      ln -s "$f" "$out/lib/site-guile/"
+    done
+  '';
+
+  meta = {
+    description = ''Guile-Library, a set of various useful
+                    Guile Scheme modules.'';
+    homepage = http://home.gna.org/guile-lib/;
+    license = "GPL";
+  };
+}
diff --git a/pkgs/development/interpreters/guile/default.nix b/pkgs/development/interpreters/guile/default.nix
index 9b12bc9a2f6..9aaa796d6b2 100644
--- a/pkgs/development/interpreters/guile/default.nix
+++ b/pkgs/development/interpreters/guile/default.nix
@@ -1,10 +1,26 @@
 args: with args; 
-stdenv.mkDerivation {
-  name = "guile-1.8.3";
+
+stdenv.mkDerivation rec {
+  name = "guile-1.8.4";
   src = fetchurl {
-		url = ftp://ftp.gnu.org/gnu/guile/guile-1.8.3.tar.gz;
-		sha256 = "2ab59099cf2d46f57cf5421c9b84aa85f61961640046e8066c6b321257517796";
-	};
+    url = "ftp://ftp.gnu.org/gnu/guile/" + name + ".tar.gz";
+    sha256 = "1cz1d4n6vzw0lfsvplsiarwqk675f12j596dzfv0h5r9cljpc0ya";
+  };
+
+  buildInputs = [ makeWrapper ];
+  propagatedBuildInputs = [readline libtool gmp gawk];
+
+  postInstall = ''
+    wrapProgram $out/bin/guile-snarf --prefix PATH : "${gawk}/bin"
+  '';
+
+  setupHook = ./setup-hook.sh;
 
-  propagatedBuildInputs = [readline libtool gmp];
+  meta = {
+    description = ''GNU Guile is an interpreter for the Scheme
+                    programming language, packaged as a library that
+		    can be embedded into programs to make them extensible.'';
+    homepage = http://www.gnu.org/software/guile/;
+    license = "LGPL";
+  };
 }
diff --git a/pkgs/development/interpreters/guile/setup-hook.sh b/pkgs/development/interpreters/guile/setup-hook.sh
new file mode 100644
index 00000000000..114bc4e87cc
--- /dev/null
+++ b/pkgs/development/interpreters/guile/setup-hook.sh
@@ -0,0 +1,8 @@
+addGuileLibPath () {
+    if test -d "$1/lib/site-guile"
+    then
+        export GUILE_LOAD_PATH="${GUILE_LOAD_PATH}${GUILE_LOAD_PATH:+:}$1/lib/site-guile"
+    fi
+}
+
+envHooks=(${envHooks[@]} addGuileLibPath)
diff --git a/pkgs/development/interpreters/perl/perl-5.10.nix b/pkgs/development/interpreters/perl/perl-5.10.nix
new file mode 100644
index 00000000000..01f314c19a4
--- /dev/null
+++ b/pkgs/development/interpreters/perl/perl-5.10.nix
@@ -0,0 +1,21 @@
+{stdenv, fetchurl}:
+
+stdenv.mkDerivation {
+  name = "perl-5.10.0";
+
+  builder = ./builder.sh;
+  src = fetchurl {
+    url = http://www.cpan.org/src/perl-5.10.0.tar.gz;
+    sha256 = "0bivbz15x02m02gqs6hs77cgjr2msfrhnvp5xqk359jg6w6llill";
+  };
+
+  # This patch does the following:
+  # 1) Do use the PATH environment variable to find the `pwd' command.
+  #    By default, Perl will only look for it in /lib and /usr/lib.
+  #    !!! what are the security implications of this?
+  # 2) Force the use of <errno.h>, not /usr/include/errno.h, on Linux
+  #    systems.  (This actually appears to be due to a bug in Perl.)
+  patches = [./no-sys-dirs.patch];
+
+  setupHook = ./setup-hook.sh;
+}
diff --git a/pkgs/development/interpreters/perl/setup-hook.sh b/pkgs/development/interpreters/perl/setup-hook.sh
index 6903bddd419..70ce2cf8b46 100644
--- a/pkgs/development/interpreters/perl/setup-hook.sh
+++ b/pkgs/development/interpreters/perl/setup-hook.sh
@@ -1,5 +1,5 @@
 addPerlLibPath () {
-	addToSearchPath PERL5LIB /lib/site_perl "" $1
+    addToSearchPath PERL5LIB /lib/site_perl "" $1
 }
 
 envHooks=(${envHooks[@]} addPerlLibPath)
diff --git a/pkgs/development/interpreters/php_configurable/default.nix b/pkgs/development/interpreters/php_configurable/default.nix
index 6b755066359..d18a2cf2b05 100644
--- a/pkgs/development/interpreters/php_configurable/default.nix
+++ b/pkgs/development/interpreters/php_configurable/default.nix
@@ -411,6 +411,7 @@ args:
 
 # Extensions 
 
+          zlib          =     { cfgOption = "--with-zlib=${args.zlib}"; pass = "zlib"; };
 
           libxml2       =     { cfgOption = "--with-libxml-dir=\$libxml2";
                                 pass = { inherit (args) libxml2; }; 
@@ -459,7 +460,7 @@ args:
     };
 
   defaults = [ "mysql" "mysqli" "pdo_mysql" "libxml2" "apxs2" ];
-  optionals = [ "libxml2" "gettext" "postgresql"];
+  optionals = [ "libxml2" "gettext" "postgresql" "zlib"];
 
   # Don't konw wether they should be default.. I use them - Marc
 
diff --git a/pkgs/development/interpreters/python/2.5/setup-hook.sh b/pkgs/development/interpreters/python/2.5/setup-hook.sh
index 27ad6226030..a11f8cbb484 100644
--- a/pkgs/development/interpreters/python/2.5/setup-hook.sh
+++ b/pkgs/development/interpreters/python/2.5/setup-hook.sh
@@ -1,5 +1,5 @@
 addPythonPath() {
-	addToSearchPathWithCustomDelimiter : PYTHONPATH /lib/python2.5/site-packages "" $1
+    addToSearchPathWithCustomDelimiter : PYTHONPATH /lib/python2.5/site-packages "" $1
 }
 
 toPythonPath() {
diff --git a/pkgs/development/libraries/aspell/default.nix b/pkgs/development/libraries/aspell/default.nix
index fdee6107716..baa95da785b 100644
--- a/pkgs/development/libraries/aspell/default.nix
+++ b/pkgs/development/libraries/aspell/default.nix
@@ -10,15 +10,15 @@ stdenv.mkDerivation {
   
   buildInputs = [perl];
 
-  patches = [
-    # A patch that allows additional dictionary directories to be set
-    # specified through the environment variable
-    # ASPELL_EXTRA_DICT_DIRS (comma-separated).
-    ./dict-path.patch
-  ];
+  # Note: Users should define the `ASPELL_CONF' environment variable to
+  # `dict-dir $HOME/.nix-profile/lib/aspell/' so that they can access
+  # dictionaries installed in their profile.
+  #
+  # We can't use `$out/etc/aspell.conf' for that purpose since Aspell
+  # doesn't expand environment variables such as `$HOME'.
 
   meta = {
-    description = "A spell checker for many languages";
+    description = "GNU Aspell, A spell checker for many languages";
     homepage = http://aspell.net/;
     license = "LGPL";
   };
diff --git a/pkgs/development/libraries/aspell/dict-path.patch b/pkgs/development/libraries/aspell/dict-path.patch
deleted file mode 100644
index c044c3d0eba..00000000000
--- a/pkgs/development/libraries/aspell/dict-path.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-diff -rc aspell-0.60.5-orig/common/info.cpp aspell-0.60.5/common/info.cpp
-*** aspell-0.60.5-orig/common/info.cpp	2004-11-10 07:18:45.000000000 +0100
---- aspell-0.60.5/common/info.cpp	2007-10-23 17:30:47.000000000 +0200
-***************
-*** 209,214 ****
---- 209,215 ----
-  					   unsigned int name_size,
-  					   IStream & in)
-    {
-+     char * extra_dict_dirs = getenv("ASPELL_EXTRA_DICT_DIRS");
-      ModuleInfoNode * * prev = &head_;
-      ModuleInfoNode * to_add = new ModuleInfoNode();
-      to_add->c_struct.name = 0;
-***************
-*** 246,251 ****
---- 247,260 ----
-  	goto RETURN_ERROR;
-        }
-      }
-+ 
-+     // Add dictionaries from directories in
-+     // $ASPELL_EXTRA_DICT_DIRS. Maybe this isn't the right place to do
-+     // this, but it works.
-+     if (extra_dict_dirs) {
-+       to_add->c_struct.dict_dirs = &(to_add->dict_dirs);
-+       itemize(extra_dict_dirs, to_add->dict_dirs);
-+     }
-    
-      while (*prev != 0 && 
-  	   (*prev)->c_struct.order_num < to_add->c_struct.order_num)
diff --git a/pkgs/development/libraries/aspell/dictionaries.nix b/pkgs/development/libraries/aspell/dictionaries.nix
index 7be7b580656..97a8e961b41 100644
--- a/pkgs/development/libraries/aspell/dictionaries.nix
+++ b/pkgs/development/libraries/aspell/dictionaries.nix
@@ -5,7 +5,7 @@ let
   /* Function to compile an Aspell dictionary.  Fortunately, they all
      build in the exact same way. */
   buildDict =
-    {shortName, fullName, src}:
+    {shortName, fullName, src, postInstall ? ""}:
 
     stdenv.mkDerivation {
       name = "aspell-dict-${shortName}";
@@ -18,6 +18,8 @@ let
 
       preBuild = "makeFlagsArray=(dictdir=$out/lib/aspell datadir=$out/lib/aspell)";
 
+      inherit postInstall;
+
       meta = {
         description = "Aspell dictionary for ${fullName}";
       };
@@ -52,6 +54,15 @@ in {
     };
   };
     
+  eo = buildDict {
+    shortName = "eo-0.50-2";
+    fullName = "Esperanto";
+    src = fetchurl {
+      url = mirror://gnu/aspell/dict/eo/aspell-eo-0.50-2.tar.bz2;
+      sha256 = "19vhdm599ng98nq8jxspgvanv5hwryp0qri1vx6zsjl0jx1acqbc";
+    };
+  };
+
   fr = buildDict {
     shortName = "fr-0.50-3";
     fullName = "French";
@@ -77,6 +88,10 @@ in {
       url = mirror://gnu/aspell/dict/nl/aspell-nl-0.50-2.tar.bz2;
       sha256 = "0ffb87yjsh211hllpc4b9khqqrblial4pzi1h9r3v465z1yhn3j4";
     };
+    # Emacs expects a language called "nederlands".
+    postInstall = ''
+      echo "add nl.rws" > $out/lib/aspell/nederlands.multi
+    '';
   };
     
   ru = buildDict {
diff --git a/pkgs/development/libraries/aterm/2.4.2-fixes.nix b/pkgs/development/libraries/aterm/2.4.2-fixes.nix
index 3144154c9e6..7c70afc621b 100644
--- a/pkgs/development/libraries/aterm/2.4.2-fixes.nix
+++ b/pkgs/development/libraries/aterm/2.4.2-fixes.nix
@@ -6,6 +6,7 @@ stdenv.mkDerivation {
     url = http://losser.st-lab.cs.uu.nl/~eelco/dist/aterm-2.4.2-fixes-r2.tar.bz2;
     sha256 = "1w3bxdpc2hz29li5ssmdcz3x0fn47r7g62ns0v8nazxwf40vff4j";
   };
+  doCheck = true;
   meta = {
     homepage = http://www.cwi.nl/htbin/sen1/twiki/bin/view/SEN1/ATerm;
     license = "LGPL";
diff --git a/pkgs/development/libraries/fcgi/default.nix b/pkgs/development/libraries/fcgi/default.nix
new file mode 100644
index 00000000000..0af3e4f5537
--- /dev/null
+++ b/pkgs/development/libraries/fcgi/default.nix
@@ -0,0 +1,18 @@
+args:
+args.stdenv.mkDerivation rec {
+  name = "fcgi-2.4.0";
+
+  src = args.fetchurl {
+    name = name + ".tar.gz";
+    url = http://www.fastcgi.com/dist/fcgi.tar.gz;
+    sha256 = "1f857wnl1d6jfrgfgfpz3zdaj8fch3vr13mnpcpvy8bang34bz36";
+  };
+
+  buildInputs =(with args; []);
+
+  meta = { 
+      description = "FastCGI  is a language independent, scalable, open extension to CG";
+      homepage = http://www.fastcgi.com/;
+      license = "FastCGI see LICENSE.TERMS";
+  };
+}
diff --git a/pkgs/development/libraries/ffmpeg_svn_snapshot/default.nix b/pkgs/development/libraries/ffmpeg_svn_snapshot/default.nix
index 1c7d07aedd8..980b04a9d61 100644
--- a/pkgs/development/libraries/ffmpeg_svn_snapshot/default.nix
+++ b/pkgs/development/libraries/ffmpeg_svn_snapshot/default.nix
@@ -1,16 +1,11 @@
-args: with args;
+{stdenv, fetchurl}:
 
 stdenv.mkDerivation {
-  name = "ffmpeg-svn-2007-12-04";
+  name = "ffmpeg-svn-pre-r11901";
   src = fetchurl {
     url = http://nix.cs.uu.nl/dist/tarballs/ffmpeg-svn-r11901.tar.bz2;
     sha256 = "0l5207gnfaz57pvlxpxyjphyz0mp9plnxzd0aghy0nz3hmqh4rs7";
   };
-
-  propagatedBuildInputs = [ a52dec lame libtheora x11 zlib SDL];
   # !!! Hm, what are the legal consequences of --enable-gpl?
-  configureFlags = "--enable-pthreads --enable-gpl --enable-pp --enable-shared
-  --disable-static --enable-x11grab  --enable-liba52 --enable-libmp3lame
-  --enable-libtheora --enable-swscaler";
+  configureFlags = "--enable-shared --enable-pp --enable-gpl --disable-ffserver --disable-ffplay";
 }
-
diff --git a/pkgs/development/libraries/gettext/0.14.6.nix b/pkgs/development/libraries/gettext/0.14.6.nix
new file mode 100644
index 00000000000..bceacd318ec
--- /dev/null
+++ b/pkgs/development/libraries/gettext/0.14.6.nix
@@ -0,0 +1,9 @@
+args: with args;
+stdenv.mkDerivation {
+  name = "gettext-0.14.6";
+  src = fetchurl {
+    url = mirror://gnu/gettext/gettext-0.14.6.tar.gz;
+    md5 = "c26fc7f0a493c5c7c39bbc4e7ed42790";
+  };
+  configureFlags = "--disable-csharp";
+}
diff --git a/pkgs/development/libraries/gettext/0.15.nix b/pkgs/development/libraries/gettext/0.15.nix
new file mode 100644
index 00000000000..0c417aafe50
--- /dev/null
+++ b/pkgs/development/libraries/gettext/0.15.nix
@@ -0,0 +1,9 @@
+args: with args;
+stdenv.mkDerivation {
+  name = "gettext-0.15";
+  src = fetchurl {
+    url = mirror://gnu/gettext/gettext-0.15.tar.gz;
+    md5 = "16bc6e4d37ac3d07495f737a2349a22b";
+  };
+  configureFlags = "--disable-csharp";
+}
diff --git a/pkgs/development/libraries/gettext/0.17.nix b/pkgs/development/libraries/gettext/0.17.nix
deleted file mode 100644
index 5fc60d9b8a6..00000000000
--- a/pkgs/development/libraries/gettext/0.17.nix
+++ /dev/null
@@ -1,9 +0,0 @@
-args: with args;
-stdenv.mkDerivation rec {
-  name = "gettext-" + version;
-  src = fetchurl {
-    url = "mirror://gnu/gettext/${name}.tar.gz";
-    sha256 = "1fipjpaxxwifdw6cbr7mkxp1yvy643i38nhlh7124bqnisxki5i0";
-  };
-  configureFlags = "--disable-csharp --enable-shared --disable-static";
-}
diff --git a/pkgs/development/libraries/glibc-2.7/glibc-getcwd-param-MAX.patch b/pkgs/development/libraries/glibc-2.7/glibc-getcwd-param-MAX.patch
new file mode 100644
index 00000000000..8543dbbf1d7
--- /dev/null
+++ b/pkgs/development/libraries/glibc-2.7/glibc-getcwd-param-MAX.patch
@@ -0,0 +1,14 @@
+2006-06-18  Mike Frysinger  <vapier@gentoo.org>
+
+	* sysdeps/unix/sysv/linux/getcwd.c: Include sys/param.h.
+
+--- glibc-old/sysdeps/unix/sysv/linux/getcwd.c
++++ glibc-new/sysdeps/unix/sysv/linux/getcwd.c
+@@ -24,6 +24,7 @@
+ #include <limits.h>
+ #include <stdlib.h>
+ #include <unistd.h>
++#include <sys/param.h>
+ 
+ #include <sysdep.h>
+ #include <sys/syscall.h>
diff --git a/pkgs/development/libraries/glibc-2.7/glibc-pwd.patch b/pkgs/development/libraries/glibc-2.7/glibc-pwd.patch
new file mode 100644
index 00000000000..07039718477
--- /dev/null
+++ b/pkgs/development/libraries/glibc-2.7/glibc-pwd.patch
@@ -0,0 +1,74 @@
+diff -ruN glibc-20050110/configure glibc-20050110.patched/configure
+--- glibc-20050110/configure	2005-01-05 10:39:53.000000000 +0100
++++ glibc-20050110.patched/configure	2005-01-18 13:33:01.000000000 +0100
+@@ -1393,7 +1393,7 @@
+ ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
+ 
+ 
+-if test "`cd $srcdir; /bin/pwd`" = "`/bin/pwd`"; then
++if test "`cd $srcdir; @PWD@`" = "`@PWD@`"; then
+   { { echo "$as_me:$LINENO: error: you must configure in a separate build directory" >&5
+ echo "$as_me: error: you must configure in a separate build directory" >&2;}
+    { (exit 1); exit 1; }; }
+diff -ruN glibc-20050110/io/ftwtest-sh glibc-20050110.patched/io/ftwtest-sh
+--- glibc-20050110/io/ftwtest-sh	2004-02-09 21:12:23.000000000 +0100
++++ glibc-20050110.patched/io/ftwtest-sh	2005-01-18 13:33:15.000000000 +0100
+@@ -120,7 +120,7 @@
+     sort > $testout
+ 
+ # perhaps $tmp involves some symlinks...
+-tmpreal=`cd $tmp; /bin/pwd 2>/dev/null || /usr/bin/pwd`
++tmpreal=`cd $tmp; @PWD@ 2>/dev/null || /usr/bin/pwd`
+ 
+ cat <<EOF | cmp $testout - || exit 1
+ base = "$tmp/", file = "ftwtest.d", flag = FTW_D, cwd = $tmpreal, level = 0
+@@ -138,7 +138,7 @@
+ EOF
+ rm $testout
+ 
+-curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
++curwd=`@PWD@ 2>/dev/null || /usr/bin/pwd`
+ cd "$tmp"
+ LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d |
+     sort > $testout
+@@ -160,7 +160,7 @@
+ EOF
+ rm $testout
+ 
+-curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
++curwd=`@PWD@ 2>/dev/null || /usr/bin/pwd`
+ cd "$tmp"
+ LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d/. |
+     sort > $testout
+@@ -182,7 +182,7 @@
+ EOF
+ rm $testout
+ 
+-curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
++curwd=`@PWD@ 2>/dev/null || /usr/bin/pwd`
+ cd "$tmp"
+ LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d/foo/lvl1/link@1 |
+     sort > $testout
+diff -ruN glibc-20050110/scripts/rellns-sh glibc-20050110.patched/scripts/rellns-sh
+--- glibc-20050110/scripts/rellns-sh	1999-12-19 00:40:25.000000000 +0100
++++ glibc-20050110.patched/scripts/rellns-sh	2005-01-18 13:35:53.245937423 +0100
+@@ -22,13 +22,13 @@
+   exit 1
+ fi
+ 
+-if test -x /bin/pwd; then
+-  pwd=/bin/pwd
+-elif test -x /usr/bin/pwd; then
+-  pwd=/usr/bin/pwd
+-else
++#if test -x /bin/pwd; then
++#  pwd=/bin/pwd
++#elif test -x /usr/bin/pwd; then
++#  pwd=/usr/bin/pwd
++#else
+   pwd='pwd'
+-fi
++#fi
+ 
+ # Make both paths absolute.
+ if test -d $1; then
diff --git a/pkgs/development/libraries/gpgme/default.nix b/pkgs/development/libraries/gpgme/default.nix
index 09ffde4512a..64f1a746b03 100644
--- a/pkgs/development/libraries/gpgme/default.nix
+++ b/pkgs/development/libraries/gpgme/default.nix
@@ -6,5 +6,5 @@ stdenv.mkDerivation {
     url = ftp://ftp.gnupg.org/gcrypt/gpgme/gpgme-1.1.4.tar.bz2;
     sha256 = "0ncrv7p33rjq1avkxpp9x0gz6wna9y3b3dmw6nv366n5mgvxmpg8";
   };
-  buildInputs = [libgpgerror gnupg pkgconfig glib pth];
+  buildInputs = [libgpgerror gnupg gnupg2 pkgconfig glib pth];
 }
diff --git a/pkgs/development/libraries/gstreamer/default.nix b/pkgs/development/libraries/gstreamer/default.nix
deleted file mode 100644
index 678fbdb137a..00000000000
--- a/pkgs/development/libraries/gstreamer/default.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-args: with args;
-rec {
-  gstreamerFun = lib.sumArgs (selectVersion ./gstreamer "0.10.17") args;
-  gstreamer = gstreamerFun null;
-
-  gstPluginsBaseFun = lib.sumArgs (selectVersion ./gst-plugins-base "0.10.17")
-    args { inherit gstreamer; };
-  gstPluginsBase = gstPluginsBaseFun null;
-
-  gstPluginsGoodFun = lib.sumArgs (selectVersion ./gst-plugins-good "0.10.6")
-    args { inherit gstPluginsBase; };
-  gstPluginsGood = gstPluginsGoodFun null;
-}
diff --git a/pkgs/development/libraries/gstreamer/gst-plugins-base/0.10.17.nix b/pkgs/development/libraries/gstreamer/gst-plugins-base/0.10.17.nix
deleted file mode 100644
index 036134c82c1..00000000000
--- a/pkgs/development/libraries/gstreamer/gst-plugins-base/0.10.17.nix
+++ /dev/null
@@ -1,24 +0,0 @@
-args: with args;
-
-stdenv.mkDerivation rec {
-  name = "gst-plugins-base-" + version;
-
-  src = fetchurl {
-    url = "${meta.homepage}/src/gst-plugins-base/${name}.tar.bz2";
-    sha256 = "03gpfhdaw7yz83y0wpq966b9dqpvw8v5kpixa1pp4mn7d5bgsb7q";
-  };
-
-  patchPhase = "sed -i 's@/bin/echo@echo@g' configure";
-
-  configureFlags = "--enable-shared --disable-static";
-
-# TODO : v4l, libvisual
-  propagatedBuildInputs = [gstreamer libX11 libXv libXext alsaLib cdparanoia
-    gnomevfs libogg libtheora libvorbis freetype pango liboil gtk];
-
-  buildInputs = [pkgconfig python];
-
-  meta = {
-    homepage = http://gstreamer.freedesktop.org;
-  };
-}
diff --git a/pkgs/development/libraries/gstreamer/gst-plugins-good/0.10.6.nix b/pkgs/development/libraries/gstreamer/gst-plugins-good/0.10.6.nix
deleted file mode 100644
index 10485330772..00000000000
--- a/pkgs/development/libraries/gstreamer/gst-plugins-good/0.10.6.nix
+++ /dev/null
@@ -1,23 +0,0 @@
-args: with args;
-
-stdenv.mkDerivation rec {
-  name = "gst-plugins-good-" + version;
-
-  src = fetchurl {
-    url = "${meta.homepage}/src/gst-plugins-good/${name}.tar.bz2";
-    sha256 = "0rid0gjj8nsk0r5yn4bz1xfsbp446r92wc6wp4099hilw6jxd74y";
-  };
-
-  propagatedBuildInputs = [gstPluginsBase aalib cairo flac hal libjpeg
-    zlib speex libpng libdv libcaca dbus.libs libiec61883 libavc1394 ladspaH
-    taglib ];
-  buildInputs = [pkgconfig];
-
-  configureFlags = "--enable-shared --disable-static --enable-ladspa";
-
-  patches = [ ./tag_defines.patch ];
-
-  meta = {
-    homepage = http://gstreamer.freedesktop.org;
-  };
-}
diff --git a/pkgs/development/libraries/gstreamer/gst-plugins-good/tag_defines.patch b/pkgs/development/libraries/gstreamer/gst-plugins-good/tag_defines.patch
deleted file mode 100644
index 0ece094229b..00000000000
--- a/pkgs/development/libraries/gstreamer/gst-plugins-good/tag_defines.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff -Nur gst-plugins-good0.10-0.10.6/ext/taglib/gstid3v2mux.cc gst-plugins-good0.10-0.10.6.new/ext/taglib/gstid3v2mux.cc
---- gst-plugins-good0.10-0.10.6/ext/taglib/gstid3v2mux.cc	2007-06-13 11:21:10.000000000 +0200
-+++ gst-plugins-good0.10-0.10.6.new/ext/taglib/gstid3v2mux.cc	2007-11-24 21:56:04.000000000 +0100
-@@ -532,6 +532,7 @@
-   GST_TAG_TITLE, add_text_tag, "TIT2"}, {
-   GST_TAG_ALBUM, add_text_tag, "TALB"}, {
-   GST_TAG_COPYRIGHT, add_text_tag, "TCOP"}, {
-+  GST_TAG_COMPOSER, add_text_tag, "TCOM"}, {
-   GST_TAG_GENRE, add_text_tag, "TCON"}, {
-   GST_TAG_COMMENT, add_comment_tag, ""}, {
-   GST_TAG_EXTENDED_COMMENT, add_comment_tag, ""}, {
-@@ -544,7 +545,9 @@
-   GST_TAG_MUSICBRAINZ_ALBUMARTISTID, add_musicbrainz_tag, "\002"}, {
-   GST_TAG_MUSICBRAINZ_TRMID, add_musicbrainz_tag, "\003"}, {
-   GST_TAG_MUSICBRAINZ_TRACKID, add_unique_file_id_tag, ""}, {
--  GST_TAG_MUSICBRAINZ_SORTNAME, add_text_tag, "TSOP"}, {
-+  GST_TAG_ARTIST_SORTNAME, add_text_tag, "TSOP"}, {
-+  GST_TAG_ALBUM_SORTNAME, add_text_tag, "TSOA"}, {
-+  GST_TAG_TITLE_SORTNAME, add_text_tag, "TSOT"}, {
-   GST_TAG_TRACK_NUMBER, add_count_or_num_tag, "TRCK"}, {
-   GST_TAG_TRACK_COUNT, add_count_or_num_tag, "TRCK"}, {
-   GST_TAG_ALBUM_VOLUME_NUMBER, add_count_or_num_tag, "TPOS"}, {
diff --git a/pkgs/development/libraries/gstreamer/gstreamer/0.10.17.nix b/pkgs/development/libraries/gstreamer/gstreamer/0.10.17.nix
deleted file mode 100644
index 3508145c22c..00000000000
--- a/pkgs/development/libraries/gstreamer/gstreamer/0.10.17.nix
+++ /dev/null
@@ -1,20 +0,0 @@
-args: with args;
-
-stdenv.mkDerivation rec {
-  name = "gstreamer-" + version;
-
-  src = fetchurl {
-    url = "${meta.homepage}/src/gstreamer/${name}.tar.bz2";
-    sha256 = "172nqf6l6mq4r1923bph53xd6h3svha3kkrvy5cald77jgf64a24";
-  };
-
-  buildInputs = [perl bison flex pkgconfig python];
-  propagatedBuildInputs = [glib libxml2];
-
-  configureFlags = "--enable-shared --disable-static --enable-failing-tests
-    --localstatedir=/var";
-
-  meta = {
-    homepage = http://gstreamer.freedesktop.org;
-  };
-}
diff --git a/pkgs/development/libraries/gtk-libs/2.6/atk/default.nix b/pkgs/development/libraries/gtk-libs/2.6/atk/default.nix
new file mode 100644
index 00000000000..66720d4dbeb
--- /dev/null
+++ b/pkgs/development/libraries/gtk-libs/2.6/atk/default.nix
@@ -0,0 +1,13 @@
+{stdenv, fetchurl, pkgconfig, glib, perl}:
+
+assert pkgconfig != null && glib != null && perl != null;
+
+stdenv.mkDerivation {
+  name = "atk-1.9.0";
+  src = fetchurl {
+    url = http://nix.cs.uu.nl/dist/tarballs/atk-1.9.0.tar.bz2;
+    md5 = "7f41bd9c6dcd83c8df391dc1805be653";
+  };
+  buildInputs = [pkgconfig perl];
+  propagatedBuildInputs = [glib];
+}
diff --git a/pkgs/development/libraries/gtk-libs/2.6/default.nix b/pkgs/development/libraries/gtk-libs/2.6/default.nix
new file mode 100644
index 00000000000..dc01a534d81
--- /dev/null
+++ b/pkgs/development/libraries/gtk-libs/2.6/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchurl, pkgconfig, gettext, perl, x11
+, libtiff, libjpeg, libpng}:
+
+rec {
+
+  glib = (import ./glib) {
+    inherit fetchurl stdenv pkgconfig gettext perl;
+  };
+
+  atk = (import ./atk) {
+    inherit fetchurl stdenv pkgconfig glib perl;
+  };
+
+  pango = (import ./pango) {
+    inherit fetchurl stdenv pkgconfig glib x11;
+  };
+
+  gtk = (import ./gtk+) {
+    inherit fetchurl stdenv pkgconfig glib atk pango perl
+            libtiff libjpeg libpng x11;
+  };
+
+}
diff --git a/pkgs/development/libraries/gtk-libs/2.6/glib/default.nix b/pkgs/development/libraries/gtk-libs/2.6/glib/default.nix
new file mode 100644
index 00000000000..1dc3407a76e
--- /dev/null
+++ b/pkgs/development/libraries/gtk-libs/2.6/glib/default.nix
@@ -0,0 +1,12 @@
+{stdenv, fetchurl, pkgconfig, gettext, perl}:
+
+assert pkgconfig != null && gettext != null && perl != null;
+
+stdenv.mkDerivation {
+  name = "glib-2.6.6";
+  src = fetchurl {
+    url = ftp://ftp.gtk.org/pub/gtk/v2.6/glib-2.6.6.tar.bz2;
+    md5 = "6e22b0639d314536f23ee118f29b43de";
+  };
+  buildInputs = [pkgconfig gettext perl];
+}
diff --git a/pkgs/development/libraries/gtk-libs/2.6/glibmm/default.nix b/pkgs/development/libraries/gtk-libs/2.6/glibmm/default.nix
new file mode 100644
index 00000000000..957c596fc7b
--- /dev/null
+++ b/pkgs/development/libraries/gtk-libs/2.6/glibmm/default.nix
@@ -0,0 +1,12 @@
+{stdenv, fetchurl, pkgconfig, glib, libsigcxx}:
+
+stdenv.mkDerivation {
+  name = "glibmm-2.6.4";
+  src = fetchurl {
+    url = http://ftp.gnome.org/pub/GNOME/sources/glibmm/2.6/glibmm-2.6.1.tar.bz2;
+    md5 = "e37da352bf581503c5866f0231fd4a74";
+  };
+
+  buildInputs = [pkgconfig glib libsigcxx];
+}
+
diff --git a/pkgs/development/libraries/gtk-libs/2.6/gtk+/default.nix b/pkgs/development/libraries/gtk-libs/2.6/gtk+/default.nix
new file mode 100644
index 00000000000..06e37f070da
--- /dev/null
+++ b/pkgs/development/libraries/gtk-libs/2.6/gtk+/default.nix
@@ -0,0 +1,21 @@
+{ stdenv, fetchurl, pkgconfig, x11, glib, atk
+, pango, perl, libtiff, libjpeg, libpng}:
+
+assert pkgconfig != null && x11 != null && glib != null && atk != null
+  && pango != null && perl != null && perl != null && libtiff != null
+  && libjpeg != null && libpng != null;
+assert x11.buildClientLibs;
+#assert glib == atk.glib;
+#assert glib == pango.glib;
+#assert x11 == pango.x11;
+
+stdenv.mkDerivation {
+  name = "gtk+-2.6.10";
+  src = fetchurl {
+    url = ftp://ftp.gtk.org/pub/gtk/v2.6/gtk+-2.6.10.tar.bz2;
+    md5 = "520090ef291e35ba93397060e20f5025";
+  };
+  buildInputs = [pkgconfig perl libtiff libjpeg libpng];
+  propagatedBuildInputs = [x11 glib atk pango];
+  inherit libtiff libjpeg libpng;
+}
diff --git a/pkgs/development/libraries/gtk-libs/2.6/gtkmm/default.nix b/pkgs/development/libraries/gtk-libs/2.6/gtkmm/default.nix
new file mode 100644
index 00000000000..ebc1e881c47
--- /dev/null
+++ b/pkgs/development/libraries/gtk-libs/2.6/gtkmm/default.nix
@@ -0,0 +1,12 @@
+{ stdenv, fetchurl, pkgconfig, gtk, atk, glibmm, libsigcxx}:
+
+stdenv.mkDerivation {
+  name = "gtkmm-2.6.4";
+  src = fetchurl {
+    url = http://ftp.gnome.org/pub/GNOME/sources/gtkmm/2.6/gtkmm-2.6.4.tar.bz2;
+    md5 = "f71d1c4a89c4f9e054400f12a82dec5f";
+  };
+
+  buildInputs = [pkgconfig gtk atk glibmm libsigcxx];
+}
+
diff --git a/pkgs/development/libraries/gtk-libs/2.6/pango/default.nix b/pkgs/development/libraries/gtk-libs/2.6/pango/default.nix
new file mode 100644
index 00000000000..6b9391e0a0b
--- /dev/null
+++ b/pkgs/development/libraries/gtk-libs/2.6/pango/default.nix
@@ -0,0 +1,14 @@
+{stdenv, fetchurl, pkgconfig, x11, glib}:
+
+assert pkgconfig != null && x11 != null && glib != null;
+assert x11.buildClientLibs;
+
+stdenv.mkDerivation {
+  name = "pango-1.8.2";
+  src = fetchurl {
+    url = ftp://ftp.gtk.org/pub/gtk/v2.6/pango-1.8.2.tar.bz2;
+    md5 = "f5b5da7a173f0566d8217ec112fde993";
+  };
+  buildInputs = [pkgconfig];
+  propagatedBuildInputs = [x11 glib];
+}
diff --git a/pkgs/development/libraries/gtk-libs/2.8/atk/default.nix b/pkgs/development/libraries/gtk-libs/2.8/atk/default.nix
new file mode 100644
index 00000000000..07537567520
--- /dev/null
+++ b/pkgs/development/libraries/gtk-libs/2.8/atk/default.nix
@@ -0,0 +1,13 @@
+{stdenv, fetchurl, pkgconfig, glib, perl}:
+
+assert pkgconfig != null && glib != null && perl != null;
+
+stdenv.mkDerivation {
+  name = "atk-1.10.3";
+  src = fetchurl {
+    url = ftp://ftp.gtk.org/pub/gtk/v2.8/atk-1.10.3.tar.bz2;
+    md5 = "c84a01fea567b365c0d44b227fead948";
+  };
+  buildInputs = [pkgconfig perl];
+  propagatedBuildInputs = [glib];
+}
diff --git a/pkgs/development/libraries/gtk-libs/2.8/default.nix b/pkgs/development/libraries/gtk-libs/2.8/default.nix
new file mode 100644
index 00000000000..ee5abd562b1
--- /dev/null
+++ b/pkgs/development/libraries/gtk-libs/2.8/default.nix
@@ -0,0 +1,26 @@
+{ xineramaSupport ? false
+, stdenv, fetchurl, pkgconfig, gettext, perl, x11
+, libtiff, libjpeg, libpng, cairo, libXinerama ? null
+}:
+
+rec {
+
+  glib = (import ./glib) {
+    inherit fetchurl stdenv pkgconfig gettext perl;
+  };
+
+  atk = (import ./atk) {
+    inherit fetchurl stdenv pkgconfig glib perl;
+  };
+
+  pango = (import ./pango) {
+    inherit fetchurl stdenv pkgconfig glib x11 cairo;
+  };
+
+  gtk = (import ./gtk+) {
+    inherit fetchurl stdenv pkgconfig glib atk pango perl
+            libtiff libjpeg libpng x11 cairo libXinerama
+            xineramaSupport;
+  };
+
+}
diff --git a/pkgs/development/libraries/gtk-libs/2.8/glib/default.nix b/pkgs/development/libraries/gtk-libs/2.8/glib/default.nix
new file mode 100644
index 00000000000..f73a1f388f4
--- /dev/null
+++ b/pkgs/development/libraries/gtk-libs/2.8/glib/default.nix
@@ -0,0 +1,13 @@
+{stdenv, fetchurl, pkgconfig, gettext, perl}:
+
+assert pkgconfig != null && gettext != null && perl != null;
+
+stdenv.mkDerivation {
+  name = "glib-2.10.3";
+  src = fetchurl {
+    url = ftp://ftp.gtk.org/pub/glib/2.10/glib-2.10.3.tar.bz2;
+    md5 = "87206e721c12d185d17dd9ecd7e30369";
+  };
+  buildInputs = [pkgconfig perl];
+  propagatedBuildInputs = [gettext];
+}
diff --git a/pkgs/development/libraries/gtk-libs/2.8/glibmm/default.nix b/pkgs/development/libraries/gtk-libs/2.8/glibmm/default.nix
new file mode 100644
index 00000000000..957c596fc7b
--- /dev/null
+++ b/pkgs/development/libraries/gtk-libs/2.8/glibmm/default.nix
@@ -0,0 +1,12 @@
+{stdenv, fetchurl, pkgconfig, glib, libsigcxx}:
+
+stdenv.mkDerivation {
+  name = "glibmm-2.6.4";
+  src = fetchurl {
+    url = http://ftp.gnome.org/pub/GNOME/sources/glibmm/2.6/glibmm-2.6.1.tar.bz2;
+    md5 = "e37da352bf581503c5866f0231fd4a74";
+  };
+
+  buildInputs = [pkgconfig glib libsigcxx];
+}
+
diff --git a/pkgs/development/libraries/gtk-libs/2.8/gtk+/default.nix b/pkgs/development/libraries/gtk-libs/2.8/gtk+/default.nix
new file mode 100644
index 00000000000..c5a012d9baa
--- /dev/null
+++ b/pkgs/development/libraries/gtk-libs/2.8/gtk+/default.nix
@@ -0,0 +1,22 @@
+{ xineramaSupport ? false
+, stdenv, fetchurl, pkgconfig, x11, glib, atk
+, pango, perl, libtiff, libjpeg, libpng, cairo, libXinerama ? null
+}:
+
+assert x11.buildClientLibs;
+assert xineramaSupport -> libXinerama != null;
+
+
+stdenv.mkDerivation {
+  name = "gtk+-2.8.20";
+  src = fetchurl {
+    url = ftp://ftp.gtk.org/pub/gtk/v2.8/gtk+-2.8.20.tar.bz2;
+    md5 = "74e7ca98194f1fadfe906e66d763d05d";
+  };
+  buildInputs = [
+    pkgconfig perl libtiff libjpeg libpng cairo
+    (if xineramaSupport then libXinerama else null)
+  ];
+  propagatedBuildInputs = [x11 glib atk pango];
+  inherit libtiff libjpeg libpng;
+}
diff --git a/pkgs/development/libraries/gtk-libs/2.8/gtkmm/default.nix b/pkgs/development/libraries/gtk-libs/2.8/gtkmm/default.nix
new file mode 100644
index 00000000000..ebc1e881c47
--- /dev/null
+++ b/pkgs/development/libraries/gtk-libs/2.8/gtkmm/default.nix
@@ -0,0 +1,12 @@
+{ stdenv, fetchurl, pkgconfig, gtk, atk, glibmm, libsigcxx}:
+
+stdenv.mkDerivation {
+  name = "gtkmm-2.6.4";
+  src = fetchurl {
+    url = http://ftp.gnome.org/pub/GNOME/sources/gtkmm/2.6/gtkmm-2.6.4.tar.bz2;
+    md5 = "f71d1c4a89c4f9e054400f12a82dec5f";
+  };
+
+  buildInputs = [pkgconfig gtk atk glibmm libsigcxx];
+}
+
diff --git a/pkgs/development/libraries/gtk-libs/2.8/pango/default.nix b/pkgs/development/libraries/gtk-libs/2.8/pango/default.nix
new file mode 100644
index 00000000000..9e3296e00a1
--- /dev/null
+++ b/pkgs/development/libraries/gtk-libs/2.8/pango/default.nix
@@ -0,0 +1,13 @@
+{stdenv, fetchurl, pkgconfig, x11, glib, cairo}:
+
+assert x11.buildClientLibs;
+
+stdenv.mkDerivation {
+  name = "pango-1.12.4";
+  src = fetchurl {
+    url = ftp://ftp.gtk.org/pub/pango/1.12/pango-1.12.4.tar.bz2;
+    md5 = "8f6749fe961e41dbeed72d1efcd55224";
+  };
+  buildInputs = [pkgconfig];
+  propagatedBuildInputs = [x11 glib cairo];
+}
diff --git a/pkgs/development/libraries/libao/default.nix b/pkgs/development/libraries/libao/default.nix
new file mode 100644
index 00000000000..cb42848585b
--- /dev/null
+++ b/pkgs/development/libraries/libao/default.nix
@@ -0,0 +1,19 @@
+{stdenv, fetchurl, pkgconfig}:
+
+stdenv.mkDerivation {
+  name = "libao-0.8.8";
+  src = fetchurl {
+    url = http://downloads.xiph.org/releases/ao/libao-0.8.8.tar.gz;
+    sha256 = "e52e05af6b10f42d2ee9845df1a581bf2b352060eabf7946aee0a600c3878954";
+  };
+
+  buildInputs = [pkgconfig];
+
+  meta = {
+    description = ''Libao is Xiph.org's cross-platform audio
+                    library that allows programs to output audio
+		    using a simple API on a wide variety of platforms.'';
+    homepage = http://xiph.org/ao/;
+    license = "GPL";
+  };
+}
diff --git a/pkgs/development/libraries/libdv/default.nix b/pkgs/development/libraries/libdv/default.nix
index cf27bfa5ef1..4b0e05acf98 100644
--- a/pkgs/development/libraries/libdv/default.nix
+++ b/pkgs/development/libraries/libdv/default.nix
@@ -1,21 +1,15 @@
 args:
 let edf = args.lib.enableDisableFeature; in
 ( args.mkDerivationByConfiguration {
-    flagConfig = {
-      mandatory = { buildInputs = [ "popt" "pkgconfig" ]; };
-      libX11 = { cfgOption = "--with-x11"; buildInputs = "libX11"; };
-      no_libX11 = { cfgOption = "--without-x11"; };
-    }
+    flagConfig = { }
       # TODO! implement flags
       # I want to get kino and cinelerra working. That's why I don't spend more time on this now
       // edf "libtool_lock" "libtool_lock" { } #avoid locking (might break parallel builds)
       // edf "asm" "asm" { } #disable use of architecture specific assembly code
-      // edf "SDL" "sdl" { buildInputs = "SDL"; } #enable use of SDL for display
-      // edf "gtk" "gtk" { buildInputs = "gtk"; } #disable use of gtk for display
-      // edf "libXv" "xv" { buildInputs = "libXv"; } #disable use of XVideo extension for display
+      // edf "sdl" "sdl" { } #enable use of SDL for display
+      // edf "gtk" "gtk" { } #disable use of gtk for display
+      // edf "xv" "xv" { } #disable use of XVideo extension for display
       // edf "gprof" "gprof" { } #enable compiler options for gprof profiling
-      // edf "shared" "shared" { }
-      // edf "static" "static" { }
     ;
 
     extraAttrs = co : {
@@ -26,13 +20,11 @@ let edf = args.lib.enableDisableFeature; in
         sha256 = "1fl96f2xh2slkv1i1ix7kqk576a0ak1d33cylm0mbhm96d0761d3";
       };
 
-      meta = {
-        description = "software decoder for DV format video, as defined by the IEC 61834 and SMPTE 314M standards";
-        homepage = http://sourceforge.net/projects/libdv/;
-        # you can choose one of the following licenses:
-        license = [];
-      };
+    meta = { 
+      description = "software decoder for DV format video, as defined by the IEC 61834 and SMPTE 314M standards";
+      homepage = http://sourceforge.net/projects/libdv/;
+      # you can choose one of the following licenses: 
+      license = [];
     };
-  optionals = [ "SDL" "gtk" "libXv" "libX11" ];
-  defaults = [ "shared" "libtool_lock" ];
+  };
 } ) args
diff --git a/pkgs/development/libraries/libeXosip2/3.0.3.nix b/pkgs/development/libraries/libeXosip2/3.0.3.nix
deleted file mode 100644
index 59eed17b417..00000000000
--- a/pkgs/development/libraries/libeXosip2/3.0.3.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-args: with args;
-
-stdenv.mkDerivation rec {
-  name = "libeXosip2-" + version;
-
-  src = fetchurl {
-    url = "http://downloa.savannah.nongnu.org/releases/exosip/${name}.tar.gz";
-    sha256 = "0jgy2mjq7r4kp8afl8zhymvca6hghp6chv36laiqz4bizcddzvxa";
-  };
-
-  propagatedBuildInputs = [libosip2];
-  configureFlags = "--enable-shared --disable-static";
-}
diff --git a/pkgs/development/libraries/libeXosip2/result b/pkgs/development/libraries/libeXosip2/result
deleted file mode 120000
index efa7575ab3a..00000000000
--- a/pkgs/development/libraries/libeXosip2/result
+++ /dev/null
@@ -1 +0,0 @@
-/nix/store/kc4kxnsi33x8a5p9xa3kv6w7dhj52w2f-libeXosip2-3.0.3
\ No newline at end of file
diff --git a/pkgs/development/libraries/libexif/default.nix b/pkgs/development/libraries/libexif/default.nix
index 9e77de0df32..76434d2c30b 100644
--- a/pkgs/development/libraries/libexif/default.nix
+++ b/pkgs/development/libraries/libexif/default.nix
@@ -8,10 +8,5 @@ stdenv.mkDerivation rec {
     sha256 = "0hxc3aik3sn8xq4mbmxxb8ycx2lwffmhi5xvz0zjffhfwkaqas6v";
   };
 
-  configureFlags = "--enable-shared --disable-static";
-
-  meta = {
-    homepage = http://libexif.sourceforge.net;
-    description = "The EXIF parsing library";
-  };
+  buildInputs = [gettext];
 }
diff --git a/pkgs/development/libraries/libexif/no-po.patch b/pkgs/development/libraries/libexif/no-po.patch
new file mode 100644
index 00000000000..77e61236939
--- /dev/null
+++ b/pkgs/development/libraries/libexif/no-po.patch
@@ -0,0 +1,20 @@
+diff -rc libexif-0.6.14/Makefile.in libexif-0.6.14.new/Makefile.in
+*** libexif-0.6.14/Makefile.in	2007-05-10 17:14:58.000000000 +0200
+--- libexif-0.6.14.new/Makefile.in	2007-05-13 23:04:05.000000000 +0200
+***************
+*** 224,230 ****
+  target_alias = @target_alias@
+  top_builddir = @top_builddir@
+  top_srcdir = @top_srcdir@
+! SUBDIRS = m4m po libexif test doc binary
+  @SHIP_BINARIES_TRUE@README_W32_XDIST = README-Win32.txt
+  EXTRA_DIST = @PACKAGE_TARNAME@.spec autogen.sh $(README_W32_XDIST)
+  ACLOCAL_AMFLAGS = -I auto-m4 -I m4m
+--- 224,230 ----
+  target_alias = @target_alias@
+  top_builddir = @top_builddir@
+  top_srcdir = @top_srcdir@
+! SUBDIRS = m4m libexif test binary
+  @SHIP_BINARIES_TRUE@README_W32_XDIST = README-Win32.txt
+  EXTRA_DIST = @PACKAGE_TARNAME@.spec autogen.sh $(README_W32_XDIST)
+  ACLOCAL_AMFLAGS = -I auto-m4 -I m4m
diff --git a/pkgs/development/libraries/libgphoto2/default.nix b/pkgs/development/libraries/libgphoto2/default.nix
index 9397530287b..6e332117a2d 100644
--- a/pkgs/development/libraries/libgphoto2/default.nix
+++ b/pkgs/development/libraries/libgphoto2/default.nix
@@ -7,10 +7,9 @@ stdenv.mkDerivation rec {
     url = "mirror://sourceforge/gphoto/${name}.tar.bz2";
     sha256 = "0yfvpgfly774jnjrfqjf89h99az3sgvzkfpb9diygpk8hmx6phhd";
   };
-  buildInputs = [pkgconfig libusb libtool libexif libjpeg];
+  buildInputs = [pkgconfig libusb libtool libexif libjpeg gettext];
 
   meta = {
-    license = "LGPL-2";
-    homepage = http://www.gphoto.org/proj/libgphoto2;
+	  license = "LGPL-2";
   };
 }
diff --git a/pkgs/development/libraries/libgphoto2/libgphoto2-2.2.1.patch b/pkgs/development/libraries/libgphoto2/libgphoto2-2.2.1.patch
new file mode 100644
index 00000000000..8d39d663719
--- /dev/null
+++ b/pkgs/development/libraries/libgphoto2/libgphoto2-2.2.1.patch
@@ -0,0 +1,14 @@
+diff -ruN libgphoto2-2.2.1/packaging/generic/print-camera-list.c libgphoto2-2.2.1.new/packaging/generic/print-camera-list.c
+--- libgphoto2-2.2.1/packaging/generic/print-camera-list.c	2006-04-19 03:54:05.000000000 +0200
++++ libgphoto2-2.2.1.new/packaging/generic/print-camera-list.c	2006-07-06 22:54:42.000000000 +0200
+@@ -48,8 +48,8 @@
+ #include <time.h>
+ #include <string.h>
+ 
+-#include <gphoto2/gphoto2-camera.h>
+-#include <gphoto2/gphoto2-port-log.h>
++#include <gphoto2-camera.h>
++#include <gphoto2-port-log.h>
+ 
+ #ifndef TRUE
+ #define TRUE  (0==0)
diff --git a/pkgs/development/libraries/libid3tag/default.nix b/pkgs/development/libraries/libid3tag/default.nix
new file mode 100644
index 00000000000..c29d3d29558
--- /dev/null
+++ b/pkgs/development/libraries/libid3tag/default.nix
@@ -0,0 +1,17 @@
+{stdenv, fetchurl, zlib}:
+
+stdenv.mkDerivation {
+  name = "libid3tag-0.15.1b";
+  src = fetchurl {
+    url = mirror://sourceforge/mad/libid3tag-0.15.1b.tar.gz;
+    sha256 = "63da4f6e7997278f8a3fef4c6a372d342f705051d1eeb6a46a86b03610e26151";
+  };
+
+  buildInputs = [zlib];
+
+  meta = {
+    description = "An ID3 tag manipulation library.";
+    homepage = http://mad.sourceforge.net/;
+    license = "GPL";
+  };
+}
diff --git a/pkgs/development/libraries/libjingle/0.3.11.nix b/pkgs/development/libraries/libjingle/0.3.11.nix
new file mode 100644
index 00000000000..b9d0b82df5e
--- /dev/null
+++ b/pkgs/development/libraries/libjingle/0.3.11.nix
@@ -0,0 +1,10 @@
+args: with args;
+stdenv.mkDerivation rec {
+	name = "libjingle-" + version;
+	src = fetchurl {
+		url = "mirror://sf/tapioca-voip/${name}.tar.gz";
+		sha256 = "1x5l2jwxpkyxvnq0cagq40p6x61v23vxngnnsxr15lyh1zwzk1yj";
+	};
+
+  propagatedBuildInputs = [ mediastreamer ];
+}
diff --git a/pkgs/development/libraries/libjingle/0.4.0.nix b/pkgs/development/libraries/libjingle/0.4.0.nix
new file mode 100644
index 00000000000..93bacd00929
--- /dev/null
+++ b/pkgs/development/libraries/libjingle/0.4.0.nix
@@ -0,0 +1,10 @@
+args: with args;
+
+stdenv.mkDerivation rec {
+  name = "libjingle-" + version;
+
+  src = fetchurl {
+    url = "mirror://sf/libjingle/${name}.tar.gz";
+    sha256 = "0izg1i4nmhysvkqmsl2xqp0x6lwz2jjyavvhv196hsdsr2w0iwvi";
+  };
+}
diff --git a/pkgs/development/libraries/libmad/default.nix b/pkgs/development/libraries/libmad/default.nix
index 6db5bf798d9..458945e102d 100644
--- a/pkgs/development/libraries/libmad/default.nix
+++ b/pkgs/development/libraries/libmad/default.nix
@@ -3,7 +3,14 @@
 stdenv.mkDerivation {
   name = "libmad-0.15.1b";
   src = fetchurl {
-    url = ftp://ftp.mars.org/pub/mpeg/libmad-0.15.1b.tar.gz;
-    md5 = "1be543bc30c56fb6bea1d7bf6a64e66c";
+    url = mirror://sourceforge/mad/libmad-0.15.1b.tar.gz;
+    sha256 = "bbfac3ed6bfbc2823d3775ebb931087371e142bb0e9bb1bee51a76a6e0078690";
+  };
+
+  buildInputs = [];
+
+  meta = {
+    description = "MAD, a high-quality, fixed-point, MPEG audio decoder
+                   supporting MPEG-1 and MPEG-2.";
   };
 }
diff --git a/pkgs/development/libraries/liboil/0.3.12.nix b/pkgs/development/libraries/liboil/0.3.12.nix
deleted file mode 100644
index 5a04892d5be..00000000000
--- a/pkgs/development/libraries/liboil/0.3.12.nix
+++ /dev/null
@@ -1,20 +0,0 @@
-args: with args;
-
-stdenv.mkDerivation rec {
-  name = "liboil-" + version;
-
-  src = fetchurl {
-    url = "${meta.homepage}/download/${name}.tar.gz";
-    sha256 = "0gdmly9sli1918pnb4ds1g38ipxikn651hdss86mp4qlfb8wvqlv";
-  };
-
-  configureFlags = "--enable-shared --disable-static";
-
-  buildInputs = [pkgconfig];
-
-  meta = {
-    homepage = http://liboil.freedesktop.org;
-    description = "Liboil is a library of simple functions that are optimized
-    for various CPUs.";
-  };
-}
diff --git a/pkgs/development/libraries/liboop/default.nix b/pkgs/development/libraries/liboop/default.nix
new file mode 100644
index 00000000000..2009e92a54d
--- /dev/null
+++ b/pkgs/development/libraries/liboop/default.nix
@@ -0,0 +1,17 @@
+{stdenv, fetchurl}:
+
+stdenv.mkDerivation {
+  name = "liboop";
+  src = fetchurl {
+    url = http://download.ofb.net/liboop/liboop.tar.gz;
+    sha256 = "34d83c6e0f09ee15cb2bc3131e219747c3b612bb57cf7d25318ab90da9a2d97c";
+  };
+
+  buildInputs = [];
+
+  meta = {
+    description = "`liboop', an event loop library.";
+    homepage = http://liboop.ofb.net/;
+    license = "LGPL";
+  };
+}
diff --git a/pkgs/development/libraries/libosip2/3.0.3-2.nix b/pkgs/development/libraries/libosip2/3.0.3-2.nix
deleted file mode 100644
index f8385807939..00000000000
--- a/pkgs/development/libraries/libosip2/3.0.3-2.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-args: with args;
-
-stdenv.mkDerivation rec {
-  name = "libosip2-" + version;
-
-  src = fetchurl {
-    url = "mirror://gnu/osip/${name}.tar.gz";
-    sha256 = "0jna6xwc42g1sh91hwzi71875mpazmnsaaq68hjirwldh39qlp69";
-  };
-
-  configureFlags = "--enable-shared --disable-static";
-}
diff --git a/pkgs/development/libraries/libsigsegv/2.5.nix b/pkgs/development/libraries/libsigsegv/2.5.nix
index a8711b3e3da..11f69753dc8 100644
--- a/pkgs/development/libraries/libsigsegv/2.5.nix
+++ b/pkgs/development/libraries/libsigsegv/2.5.nix
@@ -7,8 +7,6 @@ stdenv.mkDerivation rec {
     sha256 = "0fvcsq9msi63vrbpvks6mqkrnls5cfy6bzww063sqhk2h49vsyyg";
   };
 
-  configureFlags = "--enable-shared --disable-static";
-
   meta = {
     homepage = http://libsigsegv.sf.net;
     description = "A library for handling page faults in user mode";
diff --git a/pkgs/development/libraries/libxslt/default.nix b/pkgs/development/libraries/libxslt/default.nix
index 0d86ff615d4..896d0fc563b 100644
--- a/pkgs/development/libraries/libxslt/default.nix
+++ b/pkgs/development/libraries/libxslt/default.nix
@@ -1,4 +1,6 @@
-args: with args;
+{stdenv, fetchurl, libxml2}:
+
+assert libxml2 != null;
 
 stdenv.mkDerivation {
   name = "libxslt-1.1.22";
@@ -6,6 +8,6 @@ stdenv.mkDerivation {
     url = ftp://xmlsoft.org/libxml2/libxslt-1.1.22.tar.gz;
     sha256 = "1nj9pvn4ibhwxpl3ry9n6d7jahppcnqc7mi87nld4vsr2vp3j7sf";
   };
-  propagatedBuildInputs = [libxml2];
-  configureFlags = "--enable-shared --disable-static";
+  buildInputs = [libxml2];
+  postInstall = "ensureDir $out/nix-support; ln -s ${libxml2}/nix-support/setup-hook $out/nix-support/";
 }
diff --git a/pkgs/development/libraries/ncurses/5.6.nix b/pkgs/development/libraries/ncurses/5.6.nix
deleted file mode 100644
index d7ad5806605..00000000000
--- a/pkgs/development/libraries/ncurses/5.6.nix
+++ /dev/null
@@ -1,22 +0,0 @@
-args: with args;
-
-stdenv.mkDerivation {
-  name = "ncurses-5.6";
-  src = fetchurl {
-    url = mirror://gnu/ncurses/ncurses-5.6.tar.gz;
-    sha256 = "1m94axgq3y9c4ld0sba63rls1611fncra49ppijpv8w32srw5jpr";
-  };
-  configureFlags = [ "--with-shared" "--without-normal"
-    "--includedir=\${out}/include" "--without-debug"]
-    ++ (if unicode then ["--enable-widec"] else []);
-  postInstall= if unicode then "
-    chmod -v 644 $out/lib/libncurses++w.a
-    for lib in curses ncurses form panel menu; do
-      echo \"INPUT(-l\${lib}w)\" > $out/lib/lib\${lib}.so
-    done
-    echo \"INPUT(-lncursesw)\" > $out/lib/libcursesw.so
-  " else "
-    chmod -v 644 $out/lib/libncurses++.a
-    echo \"INPUT(-lncurses)\" > $out/lib/libcurses.so
-  ";
-}
diff --git a/pkgs/development/libraries/ncurses/default.nix b/pkgs/development/libraries/ncurses/default.nix
new file mode 100644
index 00000000000..49045546975
--- /dev/null
+++ b/pkgs/development/libraries/ncurses/default.nix
@@ -0,0 +1,19 @@
+{stdenv, fetchurl, unicode ? true}:
+
+stdenv.mkDerivation {
+  name = "ncurses-5.6";
+  src = fetchurl {
+    url = mirror://gnu/ncurses/ncurses-5.6.tar.gz;
+    md5 = "b6593abe1089d6aab1551c105c9300e3";
+  };
+  configureFlags="--with-shared --includedir=\${out}/include"+(if unicode then  " --enable-widec " else " ") +" --without-debug";
+  postInstall= if unicode then "
+    chmod -v 644 $out/lib/libncurses++w.a
+    for lib in curses ncurses form panel menu; do
+      rm -vf $out/lib/lib\${lib}.so
+      echo \"INPUT(-l\${lib}w)\" > $out/lib/lib\${lib}.so
+      ln -svf lib\${lib}w.a $out/lib/lib\${lib}.a
+      ln -svf lib\${lib}w.so.5 $out/lib/lib\${lib}.so.5
+    done;
+  " else "";
+}
diff --git a/pkgs/development/libraries/qt-4/default.nix b/pkgs/development/libraries/qt-4/default.nix
index ebb10c1aa04..046ebde99a1 100644
--- a/pkgs/development/libraries/qt-4/default.nix
+++ b/pkgs/development/libraries/qt-4/default.nix
@@ -14,7 +14,7 @@ rec {
     -opengl -xrender -xrandr -xinerama -xcursor -qt-sql-mysql
     -qdbus -cups -glib -xfixes
     -fontconfig -I${freetype}/include/freetype2";
-  patchPhase = "sed -i 's@/bin/pwd@pwd@' configure; sed -i 's@/usr@/FOO@' config.tests/*/*.test mkspecs/*/*.conf";
+  patchPhase = "sed -e 's@/bin/pwd@pwd@' -i configure; sed -e 's@/usr@/FOO@' -i config.tests/*/*.test -i mkspecs/*/*.conf";
 }; in
 rec {
 	trolltech = stdenv.mkDerivation (common // {
@@ -29,8 +29,8 @@ rec {
 	  name = "qt-kde-4.3svn";
 	  src = fetchsvn {
 		  url = svn://anonsvn.kde.org/home/kde/trunk/qt-copy;
-		  rev = "772114";
-		  sha256 = "cf8b418af39663b37726adf456ac115be5d86bdca700d65954a52042e4992acd";
+		  rev = "761061";
+		  sha256 = "0i98kh435dj29ln1lnidxwivcha1m553s4l8c1h2b3yd4950w8x4";
 	  };
 	  patchPhase = "mkdir .svn; bash apply_patches;" + common.patchPhase;
 	});
diff --git a/pkgs/development/libraries/sqlite/3.5.6.nix b/pkgs/development/libraries/sqlite/3.5.6.nix
deleted file mode 100644
index 702e5693ba0..00000000000
--- a/pkgs/development/libraries/sqlite/3.5.6.nix
+++ /dev/null
@@ -1,18 +0,0 @@
-args: with args;
-
-stdenv.mkDerivation rec {
-  name = "sqlite-" + version;
-
-  src = fetchurl {
-    url = "${meta.homepage}/${name}.tar.gz";
-    sha256 = "1fz82x3wp2h1g701w8qrsg58hc0jmrhw2593crx0c663iqhvjwqn";
-  };
-
-  configureFlags = "--enable-shared --disable-static";
-
-  propagatedBuildInputs = [readline];
-
-  meta = {
-    homepage = http://www.sqlite.org;
-  };
-}
diff --git a/pkgs/development/libraries/sqlite/3.3.13.nix b/pkgs/development/libraries/sqlite/default.nix
index 059de379fd6..059de379fd6 100644
--- a/pkgs/development/libraries/sqlite/3.3.13.nix
+++ b/pkgs/development/libraries/sqlite/default.nix
diff --git a/pkgs/development/perl-modules/DB_File/default.nix b/pkgs/development/perl-modules/DB_File/default.nix
new file mode 100644
index 00000000000..6931d5d424c
--- /dev/null
+++ b/pkgs/development/perl-modules/DB_File/default.nix
@@ -0,0 +1,11 @@
+{fetchurl, perl, db4}:
+
+import ../generic perl {
+  name = "DB_File-1.816";
+  src = fetchurl {
+    url = http://search.cpan.org/CPAN/authors/id/P/PM/PMQS/DB_File-1.816.tar.gz;
+    sha256 = "1a668hk5v0l180kbqss2hq9khl756cmrykn8fz1rl4qzsp6lq284";
+  };
+  perlPreHook = "source ${./hook.sh}";
+  inherit db4;
+}
diff --git a/pkgs/development/perl-modules/DB_File/hook.sh b/pkgs/development/perl-modules/DB_File/hook.sh
new file mode 100644
index 00000000000..033de2fd5db
--- /dev/null
+++ b/pkgs/development/perl-modules/DB_File/hook.sh
@@ -0,0 +1,11 @@
+oldPreConfigure=$preConfigure
+preConfigure=myPreConfigure
+myPreConfigure() {
+    cat > config.in <<EOF
+PREFIX = size_t
+HASH = u_int32_t
+LIB = $db4/lib
+INCLUDE = $db4/include
+EOF
+    $oldPreConfigure
+}
diff --git a/pkgs/development/tools/build-managers/cmake/2.4.7.nix b/pkgs/development/tools/build-managers/cmake/2.4.7.nix
deleted file mode 100644
index a731d0a4d7d..00000000000
--- a/pkgs/development/tools/build-managers/cmake/2.4.7.nix
+++ /dev/null
@@ -1,3 +0,0 @@
-args: (import ./common.nix) {
-  sha256 = "0mkx23s7zq48hzzzw3vbzsfzfz3rjsiwgf3i00xawcxrjjrgxm9g";
-} (args // { v = "2.4"; })
diff --git a/pkgs/development/tools/build-managers/cmake/2.4.8.nix b/pkgs/development/tools/build-managers/cmake/2.4.8.nix
deleted file mode 100644
index 27eb5ea396a..00000000000
--- a/pkgs/development/tools/build-managers/cmake/2.4.8.nix
+++ /dev/null
@@ -1,3 +0,0 @@
-args: (import ./common.nix) {
-  sha256 = "1w9i0qrbciym5ahag24xyp1x0qj6awq1cs07hdjflxikyga0f1pj";
-} (args // { v = "2.4"; })
diff --git a/pkgs/development/tools/build-managers/cmake/common.nix b/pkgs/development/tools/build-managers/cmake/common.nix
deleted file mode 100644
index ab1f01bf2d7..00000000000
--- a/pkgs/development/tools/build-managers/cmake/common.nix
+++ /dev/null
@@ -1,19 +0,0 @@
-hash: args: with args;
-stdenv.mkDerivation rec {
-  name = "cmake-" + version;
-  setupHook = ./setup-hook.sh;
-
-  src = fetchurl ({
-    url = "http://www.cmake.org/files/v${v}/${name}.tar.gz";
-  } // hash);
-
-  propagatedBuildInputs = [replace];
-
-  postUnpack = "source ${setupHook}; fixCmakeFiles \${sourceRoot}";
-
-  postInstall="fixCmakeFiles \$out/share";
-
-  meta = {
-    description = "Cross-Platform Makefile Generator";
-  };
-}
diff --git a/pkgs/development/tools/build-managers/cmake/default.nix b/pkgs/development/tools/build-managers/cmake/default.nix
new file mode 100644
index 00000000000..45311ee0e3c
--- /dev/null
+++ b/pkgs/development/tools/build-managers/cmake/default.nix
@@ -0,0 +1,20 @@
+args: with args;
+stdenv.mkDerivation {
+  name = "cmake-2.4.7";
+  setupHook = ./setup-hook.sh;
+
+  src = fetchurl {
+    url = http://www.cmake.org/files/v2.4/cmake-2.4.7.tar.gz;
+    sha256 = "0mkx23s7zq48hzzzw3vbzsfzfz3rjsiwgf3i00xawcxrjjrgxm9g";
+  };
+
+  propagatedBuildInputs = [replace];
+
+  postUnpack = "source \${setupHook}; fixCmakeFiles \${sourceRoot}";
+
+  postInstall="fixCmakeFiles \$out/share";
+
+  meta = {
+    description = "Cross-Platform Makefile Generator";
+  };
+}
diff --git a/pkgs/development/tools/build-managers/cmake/setup-hook.sh b/pkgs/development/tools/build-managers/cmake/setup-hook.sh
index 4712ef2b648..2ec77d8223e 100755
--- a/pkgs/development/tools/build-managers/cmake/setup-hook.sh
+++ b/pkgs/development/tools/build-managers/cmake/setup-hook.sh
@@ -1,49 +1,49 @@
 addCMakeParamsInclude()
 {
-	addToSearchPath CMAKE_INCLUDE_PATH /include "" $1
+    addToSearchPath CMAKE_INCLUDE_PATH /include "" $1
 }
 
 addCMakeParamsLibs()
 {
-	addToSearchPath CMAKE_LIBRARY_PATH /lib "" $1
+    addToSearchPath CMAKE_LIBRARY_PATH /lib "" $1
 }
 
 addCMakeModulePath()
 {
-	addToSearchPath CMAKE_MODULE_PATH /share/cmake-2.4/Modules "" $1
+    addToSearchPath CMAKE_MODULE_PATH /share/cmake-2.4/Modules "" $1
 }
 
 fixCmakeFiles()
 {
-	local replaceArgs;
-	echo "Fixing cmake files"
-	replaceArgs="-e -f -L -T /usr /FOO"
-   	replaceArgs="${replaceArgs}	-a NO_DEFAULT_PATH \"\" -a NO_SYSTEM_PATH \"\""
-	find $1 -type f -name "*.cmake" | xargs replace-literal ${replaceArgs}
+    local replaceArgs;
+    echo "Fixing cmake files"
+    replaceArgs="-e -f -L -T /usr /FOO"
+    replaceArgs="${replaceArgs}     -a NO_DEFAULT_PATH \"\" -a NO_SYSTEM_PATH \"\""
+    find $1 -type f -name "*.cmake" | xargs replace-literal ${replaceArgs}
 }
 
 cmakePostUnpack()
 {
-	sourceRoot=$sourceRoot/build
-	mkdir -v $sourceRoot
-	echo source root reset to $sourceRoot
-
-	if [ -z "$dontFixCmake" ]; then
-		fixCmakeFiles .
-	fi
-
-	if [ -z "$configureScript" ]; then
-		configureScript="cmake .."
-	fi
-	if [ -z "$dontAddPrefix" ]; then
-		dontAddPrefix=1
-		configureFlags="-DCMAKE_INSTALL_PREFIX=$out $configureFlags"
-	fi
+    sourceRoot=$sourceRoot/build
+    mkdir -v $sourceRoot
+    echo source root reset to $sourceRoot
+
+    if [ -z "$dontFixCmake" ]; then
+        fixCmakeFiles .
+    fi
+
+    if [ -z "$configureScript" ]; then
+        configureScript="cmake .."
+    fi
+    if [ -z "$dontAddPrefix" ]; then
+        dontAddPrefix=1
+        configureFlags="-DCMAKE_INSTALL_PREFIX=$out $configureFlags"
+    fi
 }
 
 
 if [ -z "$noCmakeTewaks" ]; then
-	postUnpack="cmakePostUnpack${postUnpack:+; }${postUnpack}"
+    postUnpack="cmakePostUnpack${postUnpack:+; }${postUnpack}"
 fi;
 
 envHooks=(${envHooks[@]} addCMakeParamsInclude addCMakeParamsLibs addCMakeModulePath)
diff --git a/pkgs/development/tools/build-managers/gnumake/log.patch b/pkgs/development/tools/build-managers/gnumake/log.patch
index 99111ca3495..3104e1f2bde 100644
--- a/pkgs/development/tools/build-managers/gnumake/log.patch
+++ b/pkgs/development/tools/build-managers/gnumake/log.patch
@@ -1,6 +1,6 @@
-diff -rc make-orig/job.c make-3.81/job.c
-*** make-orig/job.c	2006-03-20 04:03:04.000000000 +0100
---- make-3.81/job.c	2006-06-21 17:31:52.000000000 +0200
+diff -rc make-3.81-orig/job.c make-3.81/job.c
+*** make-3.81-orig/job.c	2006-03-20 04:03:04.000000000 +0100
+--- make-3.81/job.c	2008-02-20 17:41:25.000000000 +0100
 ***************
 *** 1083,1089 ****
        appear.  */
@@ -18,9 +18,9 @@ diff -rc make-orig/job.c make-3.81/job.c
   
     /* Tell update_goal_chain that a command has been started on behalf of
        this target.  It is important that this happens here and not in
-diff -rc make-orig/main.c make-3.81/main.c
-*** make-orig/main.c	2006-03-20 03:36:37.000000000 +0100
---- make-3.81/main.c	2006-06-21 17:48:43.000000000 +0200
+diff -rc make-3.81-orig/main.c make-3.81/main.c
+*** make-3.81-orig/main.c	2006-03-20 03:36:37.000000000 +0100
+--- make-3.81/main.c	2008-02-20 17:41:25.000000000 +0100
 ***************
 *** 886,891 ****
 --- 886,900 ----
@@ -83,9 +83,9 @@ diff -rc make-orig/main.c make-3.81/main.c
 + 
 + int logNestingStdout = 0;
 + int logNestingStderr = 0;
-diff -rc make-orig/make.h make-3.81/make.h
-*** make-orig/make.h	2006-02-16 00:54:43.000000000 +0100
---- make-3.81/make.h	2006-06-21 17:39:35.000000000 +0200
+diff -rc make-3.81-orig/make.h make-3.81/make.h
+*** make-3.81-orig/make.h	2006-02-16 00:54:43.000000000 +0100
+--- make-3.81/make.h	2008-02-20 17:41:25.000000000 +0100
 ***************
 *** 609,611 ****
 --- 609,613 ----
@@ -94,15 +94,16 @@ diff -rc make-orig/make.h make-3.81/make.h
   
 + extern int logNestingStdout;
 + extern int logNestingStderr;
-diff -rc make-orig/remake.c make-3.81/remake.c
-*** make-orig/remake.c	2006-03-20 03:36:37.000000000 +0100
---- make-3.81/remake.c	2006-06-21 17:31:52.000000000 +0200
+diff -rc make-3.81-orig/remake.c make-3.81/remake.c
+*** make-3.81-orig/remake.c	2006-03-20 03:36:37.000000000 +0100
+--- make-3.81/remake.c	2008-02-20 17:44:01.000000000 +0100
 ***************
 *** 1120,1126 ****
---- 1120,1130 ----
+--- 1120,1131 ----
         /* The normal case: start some commands.  */
         if (!touch_flag || file->cmds->any_recurse)
   	{
++           log_working_directory (1);
 +           fprintf(stderr, "\e[pbuilding %s\n", file->name);
 +           logNestingStderr++;
   	  execute_file_commands (file);
diff --git a/pkgs/development/tools/guile/guile-lint/default.nix b/pkgs/development/tools/guile/guile-lint/default.nix
new file mode 100644
index 00000000000..f9032dd4884
--- /dev/null
+++ b/pkgs/development/tools/guile/guile-lint/default.nix
@@ -0,0 +1,26 @@
+{stdenv, fetchurl, guile}:
+
+stdenv.mkDerivation rec {
+  name = "guile-lint-14";
+  src = fetchurl {
+    url = "http://www.geocities.com/user42_kevin/guile-lint/"
+            + name + ".tar.bz2.bin";
+    sha256 = "5bfcf7a623338b2ef81ac097e3e136eaf32856dd0730b7eeaff3161067b5d0be";
+  };
+
+  buildInputs = [ guile ];
+
+  unpackPhase = ''tar xjvf "$src" && sourceRoot="$PWD/${name}"'';
+  patchPhase = ''
+    cat guile-lint.in |						\
+    sed 's|^exec guile|exec $\{GUILE:-${guile}/bin/guile}|g' > ,,tmp &&	\
+    mv ,,tmp guile-lint.in
+  '';
+
+  meta = {
+    description = ''Guile-Lint checks syntax and semantics in a
+                    Guile program or module.'';
+    homepage = http://www.geocities.com/user42_kevin/guile-lint/index.html;
+    license = "GPL";
+  };
+}
diff --git a/pkgs/development/tools/misc/automake/setup-hook.sh b/pkgs/development/tools/misc/automake/setup-hook.sh
index 4489d343510..2b12ae3aee0 100644
--- a/pkgs/development/tools/misc/automake/setup-hook.sh
+++ b/pkgs/development/tools/misc/automake/setup-hook.sh
@@ -1,5 +1,5 @@
 addAclocals () {
-	addToSearchPathWithCustomDelimiter : ACLOCAL_PATH /share/aclocal "" $1
+    addToSearchPathWithCustomDelimiter : ACLOCAL_PATH /share/aclocal "" $1
 }
 
 envHooks=(${envHooks[@]} addAclocals)
diff --git a/pkgs/development/tools/misc/elfutils/0.127.nix b/pkgs/development/tools/misc/elfutils/0.127.nix
index 198242e2708..efa91fa637c 100644
--- a/pkgs/development/tools/misc/elfutils/0.127.nix
+++ b/pkgs/development/tools/misc/elfutils/0.127.nix
@@ -7,5 +7,4 @@ stdenv.mkDerivation {
     sha256 = "12n3h5r3c24a6l2wxz0w2dqq072bvgms0dzckivrwp5vdn22lpdv";
   };
   preBuild = "sed -e 's/-Werror//' -i */Makefile ";
-  dontAddDisableDepTrack = "true";
 }
diff --git a/pkgs/development/tools/misc/elfutils/0.131.nix b/pkgs/development/tools/misc/elfutils/0.131.nix
index f2ba07ba007..5efe046493d 100644
--- a/pkgs/development/tools/misc/elfutils/0.131.nix
+++ b/pkgs/development/tools/misc/elfutils/0.131.nix
@@ -6,6 +6,4 @@ stdenv.mkDerivation {
     url = http://ftp.de.debian.org/debian/pool/main/e/elfutils/elfutils_0.131.orig.tar.gz;
     sha256 = "0vqfjpcv81m3q0gsk78qykakhz9rbfwd65i4zsi03xr2lrk9ayll";
   };
-  dontAddDisableDepTrack = "true";
-  preBuild = "sed -e 's/-Werror//' -i */Makefile ";
 }
diff --git a/pkgs/development/tools/misc/hasktags/default.nix b/pkgs/development/tools/misc/hasktags/default.nix
new file mode 100644
index 00000000000..613d028948f
--- /dev/null
+++ b/pkgs/development/tools/misc/hasktags/default.nix
@@ -0,0 +1,24 @@
+args:
+args.stdenv.mkDerivation {
+  name = "hasktags-modified";
+
+  src = args.fetchurl {
+    url = http://mawercer.de/hasktags.hs;
+    sha256 = "112k97g6mgvwa0a9zrq840mqxxw55cn422h1c134xb0fl29llig7";
+  };
+
+  buildInputs =(with args; [ghc]);
+
+  phases = "buildPhase";
+
+  # calling it hasktags-modified to not clash with the one distributed with ghc
+  buildPhase = "
+    ensureDir \$out/bin
+    ghc --make \$src -o \$out/bin/hasktags-modified
+  ";
+
+  meta = { 
+      # this can be removed again when somone comitts my changes into the distribution
+      description = "Marc's modified hasktags";
+  };
+}
diff --git a/pkgs/development/tools/misc/libtool/default.nix b/pkgs/development/tools/misc/libtool/default.nix
index 226552b3943..b955ccbc3c8 100644
--- a/pkgs/development/tools/misc/libtool/default.nix
+++ b/pkgs/development/tools/misc/libtool/default.nix
@@ -1,10 +1,10 @@
 {stdenv, fetchurl, m4, perl}:
 
-stdenv.mkDerivation {
-  name = "libtool-1.5.22";
+stdenv.mkDerivation rec {
+  name = "libtool-1.5.26";
   src = fetchurl {
-    url = http://ftp.gnu.org/gnu/libtool/libtool-1.5.22.tar.gz;
-    md5 = "8e0ac9797b62ba4dcc8a2fb7936412b0";
+    url = "mirror://gnu/libtool/" + name + ".tar.gz";
+    sha256 = "029ggq5kri1gjn6nfqmgw4w920gyfzscjjxbsxxidal5zqsawd8w";
   };
   buildInputs = [m4 perl];
 }
diff --git a/pkgs/development/tools/misc/pkgconfig/setup-hook.sh b/pkgs/development/tools/misc/pkgconfig/setup-hook.sh
index f13a44eb999..c137fb0e96c 100644
--- a/pkgs/development/tools/misc/pkgconfig/setup-hook.sh
+++ b/pkgs/development/tools/misc/pkgconfig/setup-hook.sh
@@ -1,5 +1,5 @@
 addPkgConfigPath () {
-	addToSearchPath PKG_CONFIG_PATH /lib/pkgconfig "" $1
+    addToSearchPath PKG_CONFIG_PATH /lib/pkgconfig "" $1
 }
 
 envHooks=(${envHooks[@]} addPkgConfigPath)
diff --git a/pkgs/development/tools/parsing/flex-iputils/builder.sh b/pkgs/development/tools/parsing/flex-iputils/builder.sh
deleted file mode 100644
index 946301946ba..00000000000
--- a/pkgs/development/tools/parsing/flex-iputils/builder.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-source $stdenv/setup
-
-installPhase() {
-   make install
-   cd $out/bin; ln -s flex lex
-   cd $out/lib; ln -s libfl.a libl.a
-}
-
-installPhase=installPhase
-genericBuild
diff --git a/pkgs/development/tools/parsing/flex-iputils/default.nix b/pkgs/development/tools/parsing/flex-iputils/default.nix
deleted file mode 100644
index c680f0f5c49..00000000000
--- a/pkgs/development/tools/parsing/flex-iputils/default.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-{stdenv, fetchurl, yacc}:
-
-assert yacc != null;
-
-stdenv.mkDerivation {
-  name = "flex-2.5.4a";
-  builder = ./builder.sh;
-  src = fetchurl {
-    url = http://nix.cs.uu.nl/dist/tarballs/flex-2.5.4a.tar.gz;
-    md5 = "bd8753d0b22e1f4ec87a553a73021adf";
-  };
-  buildInputs = [yacc];
-}
diff --git a/pkgs/development/tools/parsing/flex-iputils/flex-new.nix b/pkgs/development/tools/parsing/flex-iputils/flex-new.nix
deleted file mode 100644
index 802f77a9ad6..00000000000
--- a/pkgs/development/tools/parsing/flex-iputils/flex-new.nix
+++ /dev/null
@@ -1,16 +0,0 @@
-# !!! this should be moved to default.nix eventually (but I delay
-# doing that since it would cause a rebuild of lots of stuff).
-
-{stdenv, fetchurl, yacc, m4}:
-
-assert yacc != null && m4 != null;
-
-stdenv.mkDerivation {
-  name = "flex-2.5.31";
-  src = fetchurl {
-    url = http://nix.cs.uu.nl/dist/tarballs/flex-2.5.31.tar.bz2;
-    md5 = "363dcc4afc917dc51306eb9d3de0152f";
-  };
-  buildInputs = [yacc];
-  propagatedBuildInputs = [m4];
-}
diff --git a/pkgs/development/tools/parsing/flex/flex-2.5.34.nix b/pkgs/development/tools/parsing/flex/flex-2.5.34.nix
new file mode 100644
index 00000000000..d56cf0c88a2
--- /dev/null
+++ b/pkgs/development/tools/parsing/flex/flex-2.5.34.nix
@@ -0,0 +1,19 @@
+# This should be moved to default.nix eventually (?)
+
+{stdenv, fetchurl, yacc, m4}:
+
+assert yacc != null && m4 != null;
+
+stdenv.mkDerivation {
+  name = "flex-2.5.34";
+  src = fetchurl {
+    url = mirror://sourceforge/flex/flex-2.5.34.tar.bz2;
+    sha256 = "1c8e64f32508841b0441ddfb139c4cfd25fee3728cadb63f5f351c6eb9b224a6";
+  };
+  buildInputs = [yacc];
+  propagatedBuildInputs = [m4];
+
+  meta = {
+    description = "A fast lexical analyser generator";
+  };
+}
diff --git a/pkgs/games/wesnoth/default.nix b/pkgs/games/wesnoth/default.nix
index 3e4cf07e5c5..2e132dd8889 100644
--- a/pkgs/games/wesnoth/default.nix
+++ b/pkgs/games/wesnoth/default.nix
@@ -1,13 +1,13 @@
 args: with args;
 stdenv.mkDerivation (rec {
   pname = "wesnoth";
-  version = "1.3.15";
+  version = "1.3.18";
 
   name = "${pname}-${version}";
 
   src = fetchurl {
     url = "http://surfnet.dl.sourceforge.net/sourceforge/${pname}/${name}.tar.bz2";
-    sha256 = "5c5c723bdef0b9872a20a4ee11365f050251baed375ee951db726bf82401766e";
+    sha256 = "ab2ed2cbe1daa134c453927bf0ec5d3a36f3319063b6f18c35819871f386da75";
   };
 
   buildInputs = [SDL SDL_image SDL_mixer SDL_net gettext zlib boost freetype];
diff --git a/pkgs/lib/annotatedDerivations.nix b/pkgs/lib/annotatedDerivations.nix
new file mode 100644
index 00000000000..eca97747cd8
--- /dev/null
+++ b/pkgs/lib/annotatedDerivations.nix
@@ -0,0 +1,56 @@
+{ lib } : with lib; with builtins; rec {
+  /*
+  # traversal proposal (very unstable now )
+  # goal: create tags easily (and install source files along without recompiling)
+
+  rec {
+    # encouraged: using it you can filter based on names later on? Do we ned it?
+    name = 
+
+    # required: the annotated derivation (this attr is used to identify a
+    # annotated derivation)
+    aDeriv =
+
+    # required: extra list of annotated dependencies, so we can traverse the tree
+    aDeps = <annotated deps>
+
+    # your annotation derivations 
+  };
+  */
+
+  isAnnotated = a : (a ? aDeriv); # this function serves documentation purposes 
+
+  delAnnotation = a :
+    if ((__isAttrs a) && (isAnnotated a)) then  a.aDeriv
+    else a; # most probalby a derivation without annotations.
+
+  # returns buildInputs and propagatedBuildInputs from given set after removing annotations
+  delAnnotationsFromInputs = attrs :
+    subsetmap (map delAnnotation) attrs [ "buildInputs" "propagatedBuildInputs" ];
+
+  /* so an annotated drivation function might look like this
+  args: with args;
+    let aDeps = filterDeps args;
+        deps = delAnnotation aDeps;
+    in rec {
+      name = "my-package-0.2";
+      inherit aDeps;
+
+      aDeriv = stdenv.mkDerivation {
+        inherit name;
+        buildInputs = deps;
+      };
+    };
+
+  */
+
+  filterAnnotated = lib.filter isAnnotated;
+
+  # stops when depthCounter = 0 
+  traverseByDepthCounter = depthCounter : aAttrs :
+    if (depthCounter == 0) then []
+    else [ aAttrs ] ++ map (traverseByDepthCounter (__sub depthCounter 1) ) (filterAnnotated aAttrs.aDeps);
+
+  # get all deps recursively
+  uniqAnnotatedDeps = aAttrs : uniqList { inputList = traverseByDepthCounter 10 aAttrs; };
+}
diff --git a/pkgs/lib/default-unstable.nix b/pkgs/lib/default-unstable.nix
deleted file mode 100644
index 5653508dca9..00000000000
--- a/pkgs/lib/default-unstable.nix
+++ /dev/null
@@ -1,478 +0,0 @@
-# Utility functions.
-
-let
-
-  inherit (builtins)
-    head tail isList stringLength substring lessThan sub
-    listToAttrs attrNames hasAttr;
-
-in
-
-rec {
-
-  # "Fold" a binary function `op' between successive elements of
-  # `list' with `nul' as the starting value, i.e., `fold op nul [x_1
-  # x_2 ... x_n] == op x_1 (op x_2 ... (op x_n nul))'.  (This is
-  # Haskell's foldr).
-  fold = op: nul: list:
-    if list == []
-    then nul
-    else op (head list) (fold op nul (tail list));
-    
-  # Concatenate a list of lists.
-  concatLists =
-    fold (x: y: x ++ y) [];
-
-
-  # Concatenate a list of strings.
-  concatStrings =
-    fold (x: y: x + y) "";
-
-
-  # Place an element between each element of a list, e.g.,
-  # `intersperse "," ["a" "b" "c"]' returns ["a" "," "b" "," "c"].
-  intersperse = separator: list:
-    if list == [] || tail list == []
-    then list
-    else [(head list) separator]
-         ++ (intersperse separator (tail list));
-
-  toList = x : if (__isList x) then x else [x];
-
-  concatStringsSep = separator: list:
-    concatStrings (intersperse separator list);
-
-
-  # Flatten the argument into a single list; that is, nested lists are
-  # spliced into the top-level lists.  E.g., `flatten [1 [2 [3] 4] 5]
-  # == [1 2 3 4 5]' and `flatten 1 == [1]'.
-  flatten = x:
-    if isList x
-    then fold (x: y: (flatten x) ++ y) [] x
-    else [x];
-
-
-  # Return an attribute from nested attribute sets.  For instance ["x"
-  # "y"] applied to some set e returns e.x.y, if it exists.  The
-  # default value is returned otherwise.
-  # comment: I'd rename this to getAttrRec or something like that .. (has the same name as builtin.getAttr) - Marc Weber
-  getAttr = attrPath : default : e :
-    let {
-      attr = head attrPath;
-      body =
-        if attrPath == [] then e
-        else if builtins ? hasAttr && builtins.hasAttr attr e
-        then getAttr (tail attrPath) default (builtins.getAttr attr e)
-        else default;
-    };
-  #getAttr = attrPath: default: e: getAttrMap id;
-
-  # the same as getAttr but if the element exists map the value using function f 
-  # corresponds to the maybe function of haskell
-  getAttrMap = f : attrPath : default : e :
-    let {
-      attr = head attrPath;
-      body =
-        if attrPath == [] then e
-        else if builtins ? hasAttr && builtins.hasAttr attr e
-        then f (getAttr (tail attrPath) default (builtins.getAttr attr e))
-        else default;
-    };
-
-
-
-  # Filter a list using a predicate; that is, return a list containing
-  # every element from `list' for which `pred' returns true.
-  filter = pred: list:
-    fold (x: y: if pred x then [x] ++ y else y) [] list;
-
-
-  # Return true if `list' has an element `x':
-  elem = x: list: fold (a: bs: x == a || bs) false list;
-
-
-  # Find the sole element in the list matching the specified
-  # predicate, or returns the default value.
-  findSingle = pred: default: list:
-    let found = filter pred list;
-    in if found == [] then default
-       else if tail found != [] then
-         abort "Multiple elements match predicate in findSingle."
-       else head found;
-
-
-  # Return true if each element of a list is equal, false otherwise.
-  eqLists = xs: ys:
-    if xs == [] && ys == [] then true
-    else if xs == [] || ys == [] then false
-    else head xs == head ys && eqLists (tail xs) (tail ys);
-
-
-  # Determine whether a filename ends in the given suffix.
-  hasSuffix = ext: fileName:
-    let lenFileName = stringLength fileName;
-        lenExt = stringLength ext;
-    in !(lessThan lenFileName lenExt) &&
-       substring (sub lenFileName lenExt) lenFileName fileName == ext;
-
-       
-  # Bring in a path as a source, filtering out all Subversion and CVS
-  # directories, as well as backup files (*~).
-  cleanSource =
-    let filter = name: type: let baseName = baseNameOf (toString name); in ! (
-      # Filter out Subversion and CVS directories.
-      (type == "directory" && (name == ".svn" || name == "CVS")) ||
-      # Filter out backup files.
-      (hasSuffix "~" name)
-    );
-    in src: builtins.filterSource filter src;
-
-
-  # Return a singleton list or an empty list, depending on a boolean
-  # value.  Useful when building lists with optional elements
-  # (e.g. `++ optional (system == "i686-linux") flashplayer').
-  optional = cond: elem: if (cond) then [elem] else [];
-
-  whenFlip = x : cond : if (cond) then x else "";
-
-    
-  # Return a list of integers from `first' up to and including `last'.
-  range = first: last:
-    if builtins.lessThan last first
-    then []
-    else [first] ++ range (builtins.add first 1) last;
-
-  # Return true only if there is an attribute and it is true.
-  checkFlag = attrSet: name:
-	if (name == "true") then true else
-	if (name == "false") then false else
-	if (isInList (getAttr ["flags"] [] attrSet) name) then true else
-	getAttr [name] false attrSet ;
-
-  logicalOR = x: y: x || y;
-  logicalAND = x: y: x && y;
-
-  # Input : attrSet, [ [name default] ... ], name
-  # Output : its value or default.
-  getValue = attrSet: argList: name:
-  ( getAttr [name] (if checkFlag attrSet name then true else
-	if argList == [] then null else
-	let x = builtins.head argList; in
-		if (head x) == name then 
-			(head (tail x))
-		else (getValue attrSet 
-			(tail argList) name)) attrSet );
-
-  # Input : attrSet, [[name default] ...], [ [flagname reqs..] ... ]
-  # Output : are reqs satisfied? It's asserted.
-  checkReqs = attrSet : argList : condList :
-  (
-    fold logicalAND true 
-      (map (x: let name = (head x) ; in
-	
-	((checkFlag attrSet name) -> 
-	(fold logicalAND true
-	(map (y: let val=(getValue attrSet argList y); in
-		(val!=null) && (val!=false)) 
-	(tail x))))) condList)) ;
-	
-   
-  isInList = list: x:
-	if (list == []) then false else
-	if (x == (head list)) then true else
-	isInList (tail list) x;
-  
-  uniqList = {inputList, outputList ? []}:
-	if (inputList == []) then outputList else
-	let x=head inputList; 
-	newOutputList = outputList ++
-	 (if (isInList outputList x) then [] else [x]);
-	in uniqList {outputList=newOutputList; 
-		inputList = (tail inputList);};
-
-  condConcat = name: list: checker:
-	if list == [] then name else
-	if checker (head list) then 
-		condConcat 
-			(name + (head (tail list))) 
-			(tail (tail list)) 
-			checker
-	else condConcat
-		name (tail (tail list)) checker;
-
-  # calls a function (f attr value ) for each record item. returns a list
-  mapRecordFlatten = f : r : map (attr: f attr (builtins.getAttr attr r) ) (attrNames r);
-
-  # to be used with listToAttrs (_a_ttribute _v_alue)
-  # TODO should be renamed to nv because niksnut has renamed the attribute attr to name
-  av = name : value : { inherit name value; };
-  # attribute set containing one attribute
-  avs = name : value : listToAttrs [ (av name value) ];
-  # adds / replaces an attribute of an attribute set
-  setAttr = set : name : v : set // (avs name v);
-
-  id = x : x;
-  # true if all/ at least one element(s) satisfy f
-  all = f : l : fold logicalAND true (map f l);
-  any = f : l : fold logicalOR false (map f l);
-
-  # iterates over a list of attributes collecting the attribute attr if it exists
-  catAttrs = attr : l : fold ( s : l : if (hasAttr attr s) then [(builtins.getAttr attr s)] ++ l else l) [] l;
-
-  mergeAttrs = fold ( x : y : x // y) {};
-
-  # Using f = a : b = b the result is similar to //
-  # merge attributes with custom function handling the case that the attribute
-  # exists in both sets
-  mergeAttrsWithFunc = f : set1 : set2 :
-    fold (n: set : if (__hasAttr n set) 
-                        then setAttr set n (f (__getAttr n set) (__getAttr n set2))
-                        else set )
-           set1 (__attrNames set2);
-
-  # merging two attribute set concatenating the values of same attribute names
-  # eg { a = 7; } {  a = [ 2 3 ]; } becomes { a = [ 7 2 3 ]; }
-  mergeAttrsConcatenateValues = mergeAttrsWithFunc ( a : b : (toList a) ++ (toList b) );
-
-  # returns atribute values as a list 
-  flattenAttrs = set : map ( attr : builtins.getAttr attr set) (attrNames set);
-  mapIf = cond : f :  fold ( x : l : if (cond x) then [(f x)] ++ l else l) [];
-
-# Marc 2nd proposal: (not everything has been tested in detail yet..)
-
-  # usage / example
-  # flagConfig = {
-  # } // (enableDisableFeature "flagName" "configure_feature" extraAttrs;)
-  #
-  # is equal to
-  # flagConfig = {
-  #   flagName = { cfgOption = "--enable-configure_feature"; } // extraAttrs;
-  #   no_flagName = { cfgOption = "--disable-configure_feature"; };
-  enableDisableFeature = flagName : configure_feature : extraAttrs :
-    listToAttrs [ ( av flagName ({ cfgOption = "--enable-${configure_feature}"; } // extraAttrs ) )
-                  ( av "no_${flagName}" ({ cfgOption = "--disable-${configure_feature}"; } ) )];
-
-  # calls chooseOptionsByFlags2 with some preprocessing
-  # chooseOptionsByFlags2 returns an attribute set meant to be used to create new derivaitons.
-  # see mkDerivationByConfiguration in all-packages.nix and the examples given below.
-  # You can just copy paste them into all-packages.nix to test them..
-
-  chooseOptionsByFlags = { flagConfig, args, optionals ? [], defaults ? [],
-                           collectExtraPhaseActions ? [] } :
-    let passedOptionals = filter ( x : hasAttr x args ) optionals; # these are in optionals and in args
-        # we simply merge in <optional_name> = { buildInputs = <arg.<optional_name>; pass = <arg.optional_name>; }
-        flagConfigWithOptionals = flagConfig // ( listToAttrs
-          (map ( o : av o ( { buildInputs = o; pass = avs o (builtins.getAttr o args); }
-                            // getAttr [o] {} flagConfig )
-               )
-               passedOptionals ) );
-
-    in chooseOptionsByFlags2 flagConfigWithOptionals collectExtraPhaseActions args 
-       ( (getAttr ["flags"] defaults args) ++ passedOptionals);
-
-  chooseOptionsByFlags2 = flagConfig : collectExtraPhaseActions : args : flags :
-    let   
-        # helper function
-        collectFlags = # state : flags :
-              fold ( flag : s : (
-                     if (hasAttr flag s.result) then s # this state has already been visited
-                     else if (! hasAttr flag flagConfig) then throw "unkown flag `${flag}' specified"
-                           else let fDesc = (builtins.getAttr flag flagConfig);
-                                    implied = flatten ( getAttr ["implies"] [] fDesc );
-                                    blocked = flatten ( getAttr ["blocks"] [] fDesc ); 
-                                    # add this flag
-                                    s2 =  s // { result = ( setAttr s.result flag (builtins.getAttr flag flagConfig) );
-                                                 blockedFlagsBy = s.blockedFlagsBy 
-                                                   // listToAttrs (map (b: av b flag ) blocked); };
-                                    # add implied flags
-                                in collectFlags s2 implied
-                   ));
-
-        # chosen contains flagConfig but only having those attributes elected by flags 
-        # (or by implies attributes of elected attributes)
-        options = let stateOpts = collectFlags { blockedFlagsBy = {}; result = {}; } 
-                                               (flags ++ ( if (hasAttr "mandatory" flagConfig) then ["mandatory"] else [] ));
-                      # these options have not been chosen (neither by flags nor by implies)
-                      unsetOptions = filter ( x : (! hasAttr x stateOpts.result) && (hasAttr ("no_"+x) flagConfig)) 
-                                            ( attrNames flagConfig );
-                      # no add the corresponding no_ attributes as well ..
-                      state = collectFlags stateOpts (map ( x : "no_" + x ) unsetOptions);
-                  in # check for blockings:
-                     assert ( all id ( map ( b: if (hasAttr b state.result) 
-                                             then throw "flag ${b} is blocked by flag ${__getAttr b state.blockedFlagsBy}"
-                                             else true ) 
-                                           (attrNames state.blockedFlagsBy) ) ); 
-                    state.result;
-        flatOptions = flattenAttrs options;
-
-        # helper functions :
-        collectAttrs = attr : catAttrs attr flatOptions;
-        optsConcatStrs = delimiter : attrs : concatStrings 
-                ( intersperse delimiter (flatten ( collectAttrs attrs ) ) );
-
-        ifStringGetArg = x : if (__isAttrs x) then x # ( TODO implement __isString ?)
-                             else avs x (__getAttr x args);
-          
-    in assert ( all id ( mapRecordFlatten ( attr : r : if ( all id ( flatten (getAttr ["assertion"] [] r ) ) ) 
-                                              then true else throw "assertion failed flag ${attr}" )
-                                         options) );
-      ( rec {
-
-          #foldOptions = attr: f : start: fold f start (catAttrs attr flatOptions);
-
-          # compared to flags flagsSet does also contain the implied flags.. This makes it easy to write assertions. ( assert args.
-          inherit options flatOptions collectAttrs optsConcatStrs;
-
-          buildInputs = map ( attr: if (! hasAttr attr args) then throw "argument ${attr} is missing!" else (builtins.getAttr attr args) )
-                        (flatten  (catAttrs "buildInputs" flatOptions));
-          propagatedBuildInputs = map ( attr: if (! hasAttr attr args) then throw "argument ${attr} is missing!" else (builtins.getAttr attr args) )
-                        (flatten  (catAttrs "propagatedBuildInputs" flatOptions));
-
-          configureFlags = optsConcatStrs " " "cfgOption";
-
-          #flags = listToAttrs (map ( flag: av flag (hasAttr flag options) ) (attrNames flagConfig) );
-          flags_prefixed = listToAttrs (map ( flag: av ("flag_set_"+flag) (hasAttr flag options) ) (attrNames flagConfig) );
-
-          pass = mergeAttrs ( map ifStringGetArg ( flatten (collectAttrs "pass") ) );
-      } #  now add additional phase actions (see examples)
-      // listToAttrs ( map ( x : av x (optsConcatStrs "\n" x) ) collectExtraPhaseActions ) );
-}
-
-/* 
-
-  # ###########################################################################
-  #  configuration tutorial .. examples and tests.. 
-  #  Copy this into all-packages.nix and  try
-
-  # The following derviations will all fail.. 
-  # But they will print the passed options so that you can get to know
-  # how these configurations ought to work.
-  # TODO: There is no nice way to pass an otpion yet.
-  #       I could imagine something like
-  #       flags = [ "flagA" "flagB" { flagC = 4; } ];
-
-  # They are named:
-  # simpleYes, simpleNo, 
-  # defaultsimpleYes, defaultsimpleNo
-  # optionalssimpleYes, optionalssimpleNo
-  # bitingsimpleYes can only be ran with -iA  blockingBiteMonster
-  # assertionsimpleNo
-  # of course you can use -iA and the attribute name as well to select these examples
-
-  # dummy build input
-  whoGetsTheFlagFirst = gnused;
-  whoGetsTheFlagLast = gnumake;
-
-  # simple example demonstrating containing one flag.
-  # features:
-  # * configure options are passed automatically
-  # * buildInputs are collected (they are special, see the setup script)
-  # * they can be passed by additional name as well using pass = { inherit (args) python } 
-  #                                       ( or short (value not attrs) : pass = "python" )
-  # * an attribute named the same way as the flag is added indicating 
-  #   true/ false (flag has been set/ not set)
-  # * extra phase dependend commands can be added
-  #   Its easy to add your own stuff using co.collectAttrs or co.optsConcatStrs 
-  #   ( perhaps this name will change?)
-  simpleFlagYesNoF = namePrefix : extraFlagAttrs : mkDerivationByConfiguration ( {
-    flagConfig = {
-      flag    = { name = namePrefix + "simpleYes"; 
-                  cfgOption = [ "--Yes" "--you-dont-need-a-list" ]; 
-                  buildInputs = [ "whoGetsTheFlagFirst" ]; 
-                  pass = { inherit gnumake; };
-                  extraConfigureCmd = "echo Hello, it worked! ";
-                  blocks = "bitingMonster";
-                };
-      no_flag = { name = namePrefix + "simpleNo"; 
-                  cfgOption = "--no"; 
-                  implies = ["bitingMonster"];
-                };
-      bitingMonster = {
-                  extraConfigureCmd = "echo Ill bite you";
-                };
-      gnutar = { cfgOption="--with-gnutar";
-                  # buildInputs and pass will be added automatically if gnutar is added to optionals
-               };
-      # can be used to check configure options of dependencies
-      # eg testFlag = { assertion = [ arg.desktop.flag_set_wmii (! arg.desktop.flag_set_gnome) (! arg.desktops.flag_set_kde ]; }
-      assertionFlag = { assertion = false; }; # assert is nix language keyword
-                                        
-    }; 
-
-    collectExtraPhaseActions = [ "extraConfigureCmd" ];
-
-    extraAttrs = co : {
-      name = ( __head (co.collectAttrs "name") );
-
-      unpackPhase = "
-       echo my name is 
-       echo \$name
-       echo
-       echo flag given \\(should be 1 or empty string\\) ? 
-       echo \$flag_set_flag
-       echo
-       echo my build inputs are 
-       echo \$buildInputs
-       echo
-       echo my configuration flags are 
-       echo \$configureFlags
-       echo
-       echo what about gnumake? Did it pass?
-       echo \$gnumake
-       echo 
-       echo configurePhase command is
-       echo $\configurePhase
-       echo 
-       echo gnutar passed? \\(optional test\\)
-       echo \$gnutar
-       echo
-       echo dying now
-       echo die_Hopefully_Soon
-      ";
-    configurePhase = co.extraConfigureCmd;
-    };
-  } // extraFlagAttrs ); 
-
-
-  simpleYes = simpleFlagYesNoF "" {} {
-    inherit whoGetsTheFlagFirst lib stdenv;
-    flags = ["flag"];
-  };
-  # note the "I'll bite you" because of the implies attribute
-  simpleNo = simpleFlagYesNoF "" {} {
-    inherit whoGetsTheFlagFirst lib stdenv;
-    flags = [];
-  };
-
-  # specifying defaults by adding a default attribute
-  
-  yesAgainDefault = simpleFlagYesNoF "default" { defaults = [ "flag" ];} {
-    inherit whoGetsTheFlagFirst lib stdenv;
-  };
-  noAgainOverridingDefault = simpleFlagYesNoF "default" { defaults = [ "flag" ];} {
-    inherit whoGetsTheFlagFirst lib stdenv;
-    flags = [];
-  };
-
-  # requested by Michael Raskin: activate flag automatically if dependency is passed:
-  withGnutarOptional = simpleFlagYesNoF "optionals" { optionals = [ "gnutar" ];} {
-    flags = [ "flag" ]; # I only need to pass this to trigger name optionalssimpleYes
-    inherit whoGetsTheFlagFirst lib stdenv;
-    inherit gnutar;
-  };
-  withoutGnutarOptional = simpleFlagYesNoF "optionals" { optionals = [ "gnutar" ];} {
-    inherit whoGetsTheFlagFirst lib stdenv;
-  };
-
-  # blocking example, this shouldn't even start building:
-  blockingBiteMonster = simpleFlagYesNoF "biting" {} {
-    inherit whoGetsTheFlagFirst lib stdenv;
-    flags = [ "flag" "bitingMonster" ];
-  };
-
-  # assertion example this shouldn't even start building:
-  assertion = simpleFlagYesNoF "assertion" {} {
-    inherit whoGetsTheFlagFirst lib stdenv;
-    flags = [ "assertionFlag" ];
-  };
-*/
diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix
index 4ffe50aa035..3ac24d5cfb3 100644
--- a/pkgs/lib/default.nix
+++ b/pkgs/lib/default.nix
@@ -32,6 +32,7 @@ rec {
   pairMap = innerPairMap [];
 
   
+  
   # "Fold" a binary function `op' between successive elements of
   # `list' with `nul' as the starting value, i.e., `fold op nul [x_1
   # x_2 ... x_n] == op x_1 (op x_2 ... (op x_n nul))'.  (This is
@@ -187,7 +188,7 @@ rec {
   # (e.g. `++ optional (system == "i686-linux") flashplayer').
   optional = cond: elem: if cond then [elem] else [];
 
-  
+
   # Return a list or an empty list, dependening on a boolean value.
   optionals = cond: elems: if cond then elems else [];
 
@@ -357,7 +358,6 @@ rec {
   mapRecordFlatten = f : r : map (attr: f attr (builtins.getAttr attr r) ) (attrNames r);
 
   # to be used with listToAttrs (_a_ttribute _v_alue)
-  # TODO should be renamed to nv because niksnut has renamed the attribute attr to name
   nv = name : value : { inherit name value; };
   # attribute set containing one attribute
   nvs = name : value : listToAttrs [ (nv name value) ];
diff --git a/pkgs/misc/emulators/wine/default.nix b/pkgs/misc/emulators/wine/default.nix
index 8a13c61b557..3127036d68b 100644
--- a/pkgs/misc/emulators/wine/default.nix
+++ b/pkgs/misc/emulators/wine/default.nix
@@ -1,5 +1,6 @@
 { stdenv, fetchurl, xlibs, flex, bison, mesa, alsaLib
 , ncurses, libpng, libjpeg, lcms, freetype, fontconfig, fontforge
+, libxml2, libxslt, openssl
 }:
 
 assert stdenv.isLinux;
@@ -7,28 +8,29 @@ assert stdenv.isLinux;
 let lib = import ../../../lib/default.nix; in
 
 stdenv.mkDerivation {
-  name = "wine-0.9.53";
+  name = "wine-0.9.55";
 
   src = fetchurl {
-		#url = mirror://sourceforge/wine/wine-0.9.49.tar.bz2;
-		url = mirror://sourceforge/wine/wine-0.9.53.tar.bz2;
-		#sha256 = "d41edd08cf7fd21d7350a633995107533a25f925c8859995d3a6fc131f54b3c1";
-		sha256 = "06317d78b7db39458656b6acc6b265ce97f358aefd7ded679263f397a89f1200";
-	};
+    url = mirror://sourceforge/wine/wine-0.9.55.tar.bz2;
+    sha256 = "1qsyd4k7fbv8nsv3y7zi72fakpp6z1idi7afhi87qv9xgqzy3a4d";
+  };
 
   buildInputs = [
     xlibs.xlibs flex bison xlibs.libXi mesa
     xlibs.libXcursor xlibs.libXinerama xlibs.libXrandr
-    xlibs.libXrender xlibs.libXxf86vm alsaLib ncurses
-    libpng libjpeg lcms fontforge
+    xlibs.libXrender xlibs.libXxf86vm xlibs.libXcomposite
+    alsaLib ncurses libpng libjpeg lcms fontforge
+    libxml2 libxslt openssl
   ];
 
   # Wine locates a lot of libraries dynamically through dlopen().  Add
   # them to the RPATH so that the user doesn't have to set them in
   # LD_LIBRARY_PATH.
-  NIX_LDFLAGS = map (path: "-rpath " + path + "/lib") [
+  NIX_LDFLAGS = map (path: "-rpath ${path}/lib") [
     freetype fontconfig stdenv.gcc.gcc mesa mesa.libdrm
-    xlibs.libXinerama xlibs.libXrender xlibs.libXrandr xlibs.libXcursor
+    xlibs.libXinerama xlibs.libXrender xlibs.libXrandr
+    xlibs.libXcursor xlibs.libXcomposite
+    openssl
   ];
 
   # Don't shrink the ELF RPATHs in order to keep the extra RPATH
diff --git a/pkgs/misc/emulators/wine/opengl-child-window.patch b/pkgs/misc/emulators/wine/opengl-child-window.patch
deleted file mode 100644
index 3340ecf7011..00000000000
--- a/pkgs/misc/emulators/wine/opengl-child-window.patch
+++ /dev/null
@@ -1,1286 +0,0 @@
-diff -rc wine-0.9.43-orig/dlls/winex11.drv/dce.c wine-0.9.43/dlls/winex11.drv/dce.c
-*** wine-0.9.43-orig/dlls/winex11.drv/dce.c	2007-08-10 18:18:12.000000000 +0200
---- wine-0.9.43/dlls/winex11.drv/dce.c	2007-08-21 10:20:19.000000000 +0200
-***************
-*** 639,644 ****
---- 639,656 ----
-  
-  
-  /**********************************************************************
-+  *      hwnd_from_dce
-+  *
-+  * Retrieve the HWND from a given dce
-+  */
-+ HWND hwnd_from_dce( struct dce *dce )
-+ {
-+     HWND hwnd = 0;
-+     if (dce) hwnd = dce->hwnd;
-+     return hwnd;
-+ }
-+ 
-+ /**********************************************************************
-   *		WindowFromDC   (X11DRV.@)
-   */
-  HWND X11DRV_WindowFromDC( HDC hdc )
-***************
-*** 650,656 ****
-      EnterCriticalSection( &dce_section );
-      if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape,
-                      sizeof(dce), (LPSTR)&dce )) dce = NULL;
-!     if (dce) hwnd = dce->hwnd;
-      LeaveCriticalSection( &dce_section );
-      return hwnd;
-  }
---- 662,668 ----
-      EnterCriticalSection( &dce_section );
-      if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape,
-                      sizeof(dce), (LPSTR)&dce )) dce = NULL;
-!     hwnd = hwnd_from_dce( dce );
-      LeaveCriticalSection( &dce_section );
-      return hwnd;
-  }
-diff -rc wine-0.9.43-orig/dlls/winex11.drv/event.c wine-0.9.43/dlls/winex11.drv/event.c
-*** wine-0.9.43-orig/dlls/winex11.drv/event.c	2007-08-10 18:18:12.000000000 +0200
---- wine-0.9.43/dlls/winex11.drv/event.c	2007-08-21 10:20:19.000000000 +0200
-***************
-*** 957,962 ****
---- 957,973 ----
-          return X11DRV_AcquireClipboard( hwnd );
-      case WM_X11DRV_DELETE_WINDOW:
-          return SendMessageW( hwnd, WM_SYSCOMMAND, SC_CLOSE, 0 );
-+     case WM_X11DRV_GET_PARENT_INFO:
-+         {
-+             struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
-+             if (data)
-+             {
-+                 ((void**)lp)[0] = &data->client_rect;
-+                 ((void**)lp)[1] = thread_display();
-+                 return 1;
-+             }
-+         }
-+         return 0;
-      default:
-          FIXME( "got window msg %x hwnd %p wp %lx lp %lx\n", msg, hwnd, wp, lp );
-          return 0;
-Only in wine-0.9.43/dlls/winex11.drv: event.c.orig
-diff -rc wine-0.9.43-orig/dlls/winex11.drv/init.c wine-0.9.43/dlls/winex11.drv/init.c
-*** wine-0.9.43-orig/dlls/winex11.drv/init.c	2007-08-10 18:18:12.000000000 +0200
---- wine-0.9.43/dlls/winex11.drv/init.c	2007-08-21 10:20:19.000000000 +0200
-***************
-*** 129,134 ****
---- 129,135 ----
-      if (!physDev) return FALSE;
-  
-      *pdev = physDev;
-+     physDev->display = gdi_display;
-      physDev->hdc = hdc;
-  
-      if (GetObjectType( hdc ) == OBJ_MEMDC)
-Only in wine-0.9.43/dlls/winex11.drv: init.c.orig
-diff -rc wine-0.9.43-orig/dlls/winex11.drv/opengl.c wine-0.9.43/dlls/winex11.drv/opengl.c
-*** wine-0.9.43-orig/dlls/winex11.drv/opengl.c	2007-08-10 18:18:12.000000000 +0200
---- wine-0.9.43/dlls/winex11.drv/opengl.c	2007-08-21 10:31:52.000000000 +0200
-***************
-*** 575,583 ****
-      int tmp;
-      int ctx_vis_id;
-      TRACE(" Context %p have (vis:%p):\n", ctx, ctx->vis);
-!     pglXGetFBConfigAttrib(gdi_display, ctx->fmt->fbconfig, GLX_FBCONFIG_ID, &tmp);
-      TRACE(" - FBCONFIG_ID 0x%x\n", tmp);
-!     pglXGetFBConfigAttrib(gdi_display, ctx->fmt->fbconfig, GLX_VISUAL_ID, &tmp);
-      TRACE(" - VISUAL_ID 0x%x\n", tmp);
-      ctx_vis_id = tmp;
-      return ctx_vis_id;
---- 575,583 ----
-      int tmp;
-      int ctx_vis_id;
-      TRACE(" Context %p have (vis:%p):\n", ctx, ctx->vis);
-!     pglXGetFBConfigAttrib(ctx->physDev->display, ctx->fmt->fbconfig, GLX_FBCONFIG_ID, &tmp);
-      TRACE(" - FBCONFIG_ID 0x%x\n", tmp);
-!     pglXGetFBConfigAttrib(ctx->physDev->display, ctx->fmt->fbconfig, GLX_VISUAL_ID, &tmp);
-      TRACE(" - VISUAL_ID 0x%x\n", tmp);
-      ctx_vis_id = tmp;
-      return ctx_vis_id;
-***************
-*** 595,614 ****
-      }
-  
-      TRACE(" Drawable %p have :\n", (void*) drawable);
-!     pglXQueryDrawable(gdi_display, drawable, GLX_WIDTH, (unsigned int*) &tmp);
-      TRACE(" - WIDTH as %d\n", tmp);
-!     pglXQueryDrawable(gdi_display, drawable, GLX_HEIGHT, (unsigned int*) &tmp);
-      TRACE(" - HEIGHT as %d\n", tmp);
-!     pglXQueryDrawable(gdi_display, drawable, GLX_FBCONFIG_ID, (unsigned int*) &tmp);
-      TRACE(" - FBCONFIG_ID as 0x%x\n", tmp);
-  
-      attribList[1] = tmp;
-!     fbCfgs = pglXChooseFBConfig(gdi_display, DefaultScreen(gdi_display), attribList, &nElements);
-      if (fbCfgs == NULL) {
-          return -1;
-      }
-  
-!     pglXGetFBConfigAttrib(gdi_display, fbCfgs[0], GLX_VISUAL_ID, &tmp);
-      TRACE(" - VISUAL_ID as 0x%x\n", tmp);
-  
-      XFree(fbCfgs);
---- 595,614 ----
-      }
-  
-      TRACE(" Drawable %p have :\n", (void*) drawable);
-!     pglXQueryDrawable(ctx->physDev->display, drawable, GLX_WIDTH, (unsigned int*) &tmp);
-      TRACE(" - WIDTH as %d\n", tmp);
-!     pglXQueryDrawable(ctx->physDev->display, drawable, GLX_HEIGHT, (unsigned int*) &tmp);
-      TRACE(" - HEIGHT as %d\n", tmp);
-!     pglXQueryDrawable(ctx->physDev->display, drawable, GLX_FBCONFIG_ID, (unsigned int*) &tmp);
-      TRACE(" - FBCONFIG_ID as 0x%x\n", tmp);
-  
-      attribList[1] = tmp;
-!     fbCfgs = pglXChooseFBConfig(ctx->physDev->display, DefaultScreen(gdi_display), attribList, &nElements);
-      if (fbCfgs == NULL) {
-          return -1;
-      }
-  
-!     pglXGetFBConfigAttrib(ctx->physDev->display, fbCfgs[0], GLX_VISUAL_ID, &tmp);
-      TRACE(" - VISUAL_ID as 0x%x\n", tmp);
-  
-      XFree(fbCfgs);
-***************
-*** 1236,1265 ****
-  
-    wine_tsx11_lock();
-  
-!   pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_CONFIG_CAVEAT, &value);
-    if(value == GLX_SLOW_CONFIG)
-        ppfd->dwFlags |= PFD_GENERIC_ACCELERATED;
-  
-!   pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DOUBLEBUFFER, &value); if (value) ppfd->dwFlags |= PFD_DOUBLEBUFFER;
-!   pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_STEREO, &value); if (value) ppfd->dwFlags |= PFD_STEREO;
-  
-    /* Pixel type */
-!   pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_RENDER_TYPE, &value);
-    if (value & GLX_RGBA_BIT)
-      ppfd->iPixelType = PFD_TYPE_RGBA;
-    else
-      ppfd->iPixelType = PFD_TYPE_COLORINDEX;
-  
-    /* Color bits */
-!   pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_BUFFER_SIZE, &value);
-    ppfd->cColorBits = value;
-  
-    /* Red, green, blue and alpha bits / shifts */
-    if (ppfd->iPixelType == PFD_TYPE_RGBA) {
-!     pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_RED_SIZE, &rb);
-!     pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_GREEN_SIZE, &gb);
-!     pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_BLUE_SIZE, &bb);
-!     pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_ALPHA_SIZE, &ab);
-  
-      ppfd->cRedBits = rb;
-      ppfd->cRedShift = gb + bb + ab;
---- 1236,1265 ----
-  
-    wine_tsx11_lock();
-  
-!   pglXGetFBConfigAttrib(physDev->display, fmt->fbconfig, GLX_CONFIG_CAVEAT, &value);
-    if(value == GLX_SLOW_CONFIG)
-        ppfd->dwFlags |= PFD_GENERIC_ACCELERATED;
-  
-!   pglXGetFBConfigAttrib(physDev->display, fmt->fbconfig, GLX_DOUBLEBUFFER, &value); if (value) ppfd->dwFlags |= PFD_DOUBLEBUFFER;
-!   pglXGetFBConfigAttrib(physDev->display, fmt->fbconfig, GLX_STEREO, &value); if (value) ppfd->dwFlags |= PFD_STEREO;
-  
-    /* Pixel type */
-!   pglXGetFBConfigAttrib(physDev->display, fmt->fbconfig, GLX_RENDER_TYPE, &value);
-    if (value & GLX_RGBA_BIT)
-      ppfd->iPixelType = PFD_TYPE_RGBA;
-    else
-      ppfd->iPixelType = PFD_TYPE_COLORINDEX;
-  
-    /* Color bits */
-!   pglXGetFBConfigAttrib(physDev->display, fmt->fbconfig, GLX_BUFFER_SIZE, &value);
-    ppfd->cColorBits = value;
-  
-    /* Red, green, blue and alpha bits / shifts */
-    if (ppfd->iPixelType == PFD_TYPE_RGBA) {
-!     pglXGetFBConfigAttrib(physDev->display, fmt->fbconfig, GLX_RED_SIZE, &rb);
-!     pglXGetFBConfigAttrib(physDev->display, fmt->fbconfig, GLX_GREEN_SIZE, &gb);
-!     pglXGetFBConfigAttrib(physDev->display, fmt->fbconfig, GLX_BLUE_SIZE, &bb);
-!     pglXGetFBConfigAttrib(physDev->display, fmt->fbconfig, GLX_ALPHA_SIZE, &ab);
-  
-      ppfd->cRedBits = rb;
-      ppfd->cRedShift = gb + bb + ab;
-***************
-*** 1293,1303 ****
-    ppfd->cAccumAlphaBits = ab;
-  
-    /* Depth bits */
-!   pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DEPTH_SIZE, &value);
-    ppfd->cDepthBits = value;
-  
-    /* stencil bits */
-!   pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_STENCIL_SIZE, &value);
-    ppfd->cStencilBits = value;
-  
-    wine_tsx11_unlock();
---- 1293,1303 ----
-    ppfd->cAccumAlphaBits = ab;
-  
-    /* Depth bits */
-!   pglXGetFBConfigAttrib(physDev->display, fmt->fbconfig, GLX_DEPTH_SIZE, &value);
-    ppfd->cDepthBits = value;
-  
-    /* stencil bits */
-!   pglXGetFBConfigAttrib(physDev->display, fmt->fbconfig, GLX_STENCIL_SIZE, &value);
-    ppfd->cStencilBits = value;
-  
-    wine_tsx11_unlock();
-***************
-*** 1350,1357 ****
---- 1350,1365 ----
-  BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev,
-  			   int iPixelFormat,
-  			   const PIXELFORMATDESCRIPTOR *ppfd) {
-+   XSetWindowAttributes attr;
-+   XVisualInfo *vis;
-+   XVisualInfo template;
-+   Display *display;
-+   Window gl_child;
-+   HWND main_hwnd;
-+   RECT rect;
-    WineGLPixelFormat *fmt;
-    int value;
-+   int num;
-  
-    TRACE("(%p,%d,%p)\n", physDev, iPixelFormat, ppfd);
-  
-***************
-*** 1374,1380 ****
---- 1382,1494 ----
-      return 0;
-    }
-  
-+   /* Check for an existing pixel format */
-+   if (physDev->current_pf) {
-+     if (physDev->current_pf != iPixelFormat) {
-+       ERR("Pixel format already set for physDev (cur: %d, req: %d)\n", physDev->current_pf, iPixelFormat);
-+       return 0;
-+     }
-+     /* TODO: test if the current gl_drawable is still valid */
-+   }
-+ 
-+   /* Check the window we'll be parenting from */
-+   if (!physDev->drawable) {
-+     ERR("No drawable associated with physDev %p\n", physDev);
-+     return 0;
-+   }
-+ 
-+ 
-+   /* Get the window and display for the opengl child */
-+   main_hwnd = hwnd_from_dce(physDev->dce);
-+   display = X11DRV_get_gl_display(main_hwnd);
-+ 
-+   TRACE("main_hwnd: %p\n", main_hwnd);
-+   /* Make sure this window doesn't already have a gl drawable */
-+   if (physDev->gl_drawable) {
-+         /* Check if the gl_drawable is still valid */
-+         if(X11DRV_get_gl_window(main_hwnd) == 0)
-+             physDev->gl_drawable = 0;
-+         else
-+             WARN("Window already has an opengl child (%p), possible window leak!\n", (void*)physDev->gl_drawable);
-+ 
-+     physDev->gl_drawable = 0;
-+     X11DRV_set_gl_window(main_hwnd, 0);
-+   }
-+ 
-+   /* Force semi-sane values */
-+   rect = physDev->dc_rect;
-+   if (rect.right <= rect.left) {
-+     rect.right = 0;
-+     rect.left = -16;
-+   }
-+   if (rect.bottom <= rect.top) {
-+     rect.bottom = 0;
-+     rect.top = -16;
-+   }
-+ 
-+   wine_tsx11_lock();
-+ 
-+   /* Get the visual for the X11 child window and set up a colormap for it */
-+   template.visualid = XVisualIDFromVisual(visual);
-+   vis = XGetVisualInfo(gdi_display, VisualIDMask, &template, &num);
-+   if (!vis) {
-+     wine_tsx11_unlock();
-+     ERR("No visual for pixel format %i\n", iPixelFormat);
-+     return 0;
-+   }
-+ 
-+   if ((vis->class == PseudoColor) || (vis->class == GrayScale) ||
-+       (vis->class == DirectColor)) {
-+     attr.colormap = XCreateColormap(display, physDev->drawable, vis->visual, AllocAll);
-+   }
-+   else {
-+     attr.colormap = XCreateColormap(display, physDev->drawable, vis->visual, AllocNone);
-+   }
-+   XInstallColormap(display, attr.colormap);
-+ 
-+   TRACE("Creating X11 window x=%d,y=%d,w=%d,h=%d, parent=%p\n", rect.left, rect.top,
-+         rect.right-rect.left, rect.bottom-rect.top, (void*)physDev->drawable);
-+ 
-+   /* Create the window */
-+   gl_child = XCreateWindow(display, physDev->drawable, rect.left, rect.top,
-+ //  gl_child = XCreateWindow(display, RootWindow(display, DefaultScreen(display)), rect.left, rect.top,
-+                            rect.right-rect.left, rect.bottom-rect.top, 0,
-+                            CopyFromParent, InputOutput, vis->visual,
-+                            CWColormap, &attr);
-+ 
-+   XFree(vis);
-+   wine_tsx11_unlock();
-+ 
-+   if (!gl_child) {
-+     ERR("Could not create OpenGL child window!\n");
-+     return 0;
-+   }
-+ 
-+   if(!X11DRV_set_gl_window(main_hwnd, gl_child)) {
-+     wine_tsx11_lock();
-+     XDestroyWindow(display, gl_child);
-+     wine_tsx11_unlock();
-+     ERR("Could not set OpenGL child window for hwnd %p!\n", main_hwnd);
-+     return 0;
-+   }
-+ 
-+   TRACE("Created window %p\n", (void*)gl_child);
-+ 
-    physDev->current_pf = iPixelFormat;
-+ //if(physDev->dc_rect.left != 4)
-+ //physDev->gl_drawable = 0;
-+ //else
-+   physDev->gl_drawable = gl_child;
-+   physDev->display = display;
-+ 
-+   /* Finally, map the child if the window is visible */
-+   if (X11DRV_is_window_rect_mapped(&physDev->dc_rect) &&
-+       X11DRV_get_visible(main_hwnd)) {
-+     wine_tsx11_lock();
-+ //    if(physDev->dc_rect.left == 4)
-+     XMapWindow(physDev->display, physDev->gl_drawable);
-+     wine_tsx11_unlock();
-+   }
-  
-    if (TRACE_ON(opengl)) {
-      int gl_test = 0;
-***************
-*** 1407,1412 ****
---- 1521,1527 ----
-        TRACE(" - DRAWABLE_TYPE 0x%x\n", value);
-      }
-    }
-+ 
-    return TRUE;
-  }
-  
-***************
-*** 1468,1474 ****
-      ret->fmt = fmt;
-  
-      /*ret->vis = vis;*/
-!     ret->vis = pglXGetVisualFromFBConfig(gdi_display, fmt->fbconfig);
-  
-      TRACE(" creating context %p (GL context creation delayed)\n", ret);
-      return (HGLRC) ret;
---- 1583,1589 ----
-      ret->fmt = fmt;
-  
-      /*ret->vis = vis;*/
-!     ret->vis = pglXGetVisualFromFBConfig(physDev->display, fmt->fbconfig);
-  
-      TRACE(" creating context %p (GL context creation delayed)\n", ret);
-      return (HGLRC) ret;
-***************
-*** 1496,1502 ****
-      * so make sure it is valid first */
-      if (is_valid_context( ctx ))
-      {
-!         if (ctx->ctx) pglXDestroyContext(gdi_display, ctx->ctx);
-          free_context(ctx);
-      }
-      else
---- 1611,1617 ----
-      * so make sure it is valid first */
-      if (is_valid_context( ctx ))
-      {
-!         if (ctx->ctx) pglXDestroyContext(ctx->physDev->display, ctx->ctx);
-          free_context(ctx);
-      }
-      else
-***************
-*** 1579,1584 ****
---- 1694,1700 ----
-   */
-  static void sync_current_drawable(BOOL updatedc)
-  {
-+ #if 0
-      int dy;
-      int width;
-      int height;
-***************
-*** 1616,1621 ****
---- 1732,1738 ----
-  
-          wine_tsx11_unlock();
-      }
-+ #endif
-  }
-  
-  /**
-***************
-*** 1628,1634 ****
-      HDC hdc = physDev->hdc;
-      DWORD type = GetObjectType(hdc);
-  
-!     TRACE("(%p,%p)\n", hdc, hglrc);
-  
-      if (!has_opengl()) {
-          ERR("No libGL on this box - disabling OpenGL support !\n");
---- 1745,1751 ----
-      HDC hdc = physDev->hdc;
-      DWORD type = GetObjectType(hdc);
-  
-!     TRACE("(%p %p,%p)\n", physDev, hdc, hglrc);
-  
-      if (!has_opengl()) {
-          ERR("No libGL on this box - disabling OpenGL support !\n");
-***************
-*** 1637,1643 ****
-  
-      wine_tsx11_lock();
-      if (hglrc == NULL) {
-!         ret = pglXMakeCurrent(gdi_display, None, NULL);
-          NtCurrentTeb()->glContext = NULL;
-      } else {
-          Wine_GLContext *ctx = (Wine_GLContext *) hglrc;
---- 1754,1760 ----
-  
-      wine_tsx11_lock();
-      if (hglrc == NULL) {
-!         ret = pglXMakeCurrent(physDev->display, None, NULL);
-          NtCurrentTeb()->glContext = NULL;
-      } else {
-          Wine_GLContext *ctx = (Wine_GLContext *) hglrc;
-***************
-*** 1654,1668 ****
-               */
-              TRACE(" Creating GLX Context\n");
-              if(ctx->vis)
-!                 ctx->ctx = pglXCreateContext(gdi_display, ctx->vis, NULL, type == OBJ_MEMDC ? False : True);
-              else /* Create a GLX Context for a pbuffer */
-!                 ctx->ctx = pglXCreateNewContext(gdi_display, ctx->fmt->fbconfig, ctx->fmt->render_type, NULL, True);
-  
-              TRACE(" created a delayed OpenGL context (%p)\n", ctx->ctx);
-          }
-!         TRACE(" make current for dis %p, drawable %p, ctx %p\n", gdi_display, (void*) drawable, ctx->ctx);
-!         ret = pglXMakeCurrent(gdi_display, drawable, ctx->ctx);
-          NtCurrentTeb()->glContext = ctx;
-          if(ret)
-          {
-              ctx->physDev = physDev;
---- 1771,1786 ----
-               */
-              TRACE(" Creating GLX Context\n");
-              if(ctx->vis)
-!                 ctx->ctx = pglXCreateContext(physDev->display, ctx->vis, NULL, type == OBJ_MEMDC ? False : True);
-              else /* Create a GLX Context for a pbuffer */
-!                 ctx->ctx = pglXCreateNewContext(physDev->display, ctx->fmt->fbconfig, ctx->fmt->render_type, NULL, True);
-  
-              TRACE(" created a delayed OpenGL context (%p)\n", ctx->ctx);
-          }
-!         TRACE(" make current for dis %p, drawable %p, ctx %p\n", physDev->display, (void*) drawable, ctx->ctx);
-!         ret = pglXMakeCurrent(physDev->display, drawable, ctx->ctx);
-          NtCurrentTeb()->glContext = ctx;
-+         
-          if(ret)
-          {
-              ctx->physDev = physDev;
-***************
-*** 1711,1720 ****
-              Drawable d_read = get_glxdrawable(hReadDev);
-  
-              if (ctx->ctx == NULL) {
-!                 ctx->ctx = pglXCreateContext(gdi_display, ctx->vis, NULL, GetObjectType(hDrawDev->hdc) == OBJ_MEMDC ? False : True);
-                  TRACE(" created a delayed OpenGL context (%p)\n", ctx->ctx);
-              }
-!             ret = pglXMakeContextCurrent(gdi_display, d_draw, d_read, ctx->ctx);
-              NtCurrentTeb()->glContext = ctx;
-          }
-      }
---- 1829,1838 ----
-              Drawable d_read = get_glxdrawable(hReadDev);
-  
-              if (ctx->ctx == NULL) {
-!                 ctx->ctx = pglXCreateContext(ctx->physDev->display, ctx->vis, NULL, GetObjectType(hDrawDev->hdc) == OBJ_MEMDC ? False : True);
-                  TRACE(" created a delayed OpenGL context (%p)\n", ctx->ctx);
-              }
-!             ret = pglXMakeContextCurrent(ctx->physDev->display, d_draw, d_read, ctx->ctx);
-              NtCurrentTeb()->glContext = ctx;
-          }
-      }
-***************
-*** 1749,1757 ****
-              describeContext(org);
-  
-              if(org->vis)
-!                 org->ctx = pglXCreateContext(gdi_display, org->vis, NULL, GetObjectType(org->physDev->hdc) == OBJ_MEMDC ? False : True);
-              else /* Create a GLX Context for a pbuffer */
-!                 org->ctx = pglXCreateNewContext(gdi_display, org->fmt->fbconfig, org->fmt->render_type, NULL, True);
-              wine_tsx11_unlock();
-              TRACE(" created a delayed OpenGL context (%p) for Wine context %p\n", org->ctx, org);
-          }
---- 1867,1875 ----
-              describeContext(org);
-  
-              if(org->vis)
-!                 org->ctx = pglXCreateContext(org->physDev->display, org->vis, NULL, GetObjectType(org->physDev->hdc) == OBJ_MEMDC ? False : True);
-              else /* Create a GLX Context for a pbuffer */
-!                 org->ctx = pglXCreateNewContext(org->physDev->display, org->fmt->fbconfig, org->fmt->render_type, NULL, True);
-              wine_tsx11_unlock();
-              TRACE(" created a delayed OpenGL context (%p) for Wine context %p\n", org->ctx, org);
-          }
-***************
-*** 1760,1768 ****
-              describeContext(dest);
-              /* Create the destination context with display lists shared */
-              if(dest->vis)
-!                 dest->ctx = pglXCreateContext(gdi_display, dest->vis, org->ctx, GetObjectType(org->physDev->hdc) == OBJ_MEMDC ? False : True);
-              else /* Create a GLX Context for a pbuffer */
-!                 dest->ctx = pglXCreateNewContext(gdi_display, dest->fmt->fbconfig, dest->fmt->render_type, org->ctx, True);
-              wine_tsx11_unlock();
-              TRACE(" created a delayed OpenGL context (%p) for Wine context %p sharing lists with OpenGL ctx %p\n", dest->ctx, dest, org->ctx);
-              return TRUE;
---- 1878,1886 ----
-              describeContext(dest);
-              /* Create the destination context with display lists shared */
-              if(dest->vis)
-!                 dest->ctx = pglXCreateContext(dest->physDev->display, dest->vis, org->ctx, GetObjectType(org->physDev->hdc) == OBJ_MEMDC ? False : True);
-              else /* Create a GLX Context for a pbuffer */
-!                 dest->ctx = pglXCreateNewContext(dest->physDev->display, dest->fmt->fbconfig, dest->fmt->render_type, org->ctx, True);
-              wine_tsx11_unlock();
-              TRACE(" created a delayed OpenGL context (%p) for Wine context %p sharing lists with OpenGL ctx %p\n", dest->ctx, dest, org->ctx);
-              return TRUE;
-***************
-*** 1937,1942 ****
---- 2055,2061 ----
-  
-  static void WINAPI X11DRV_wglDisable(GLenum cap)
-  {
-+ #if 0
-      if (cap == GL_SCISSOR_TEST)
-      {
-         Wine_GLContext *ctx = (Wine_GLContext *) NtCurrentTeb()->glContext;
-***************
-*** 1945,1950 ****
---- 2064,2070 ----
-            ctx->scissor_enabled = FALSE;
-      }
-      else
-+ #endif
-      {
-          wine_tsx11_lock();
-          pglDisable(cap);
-***************
-*** 1954,1959 ****
---- 2074,2080 ----
-  
-  static void WINAPI X11DRV_wglEnable(GLenum cap)
-  {
-+ #if 0
-      if (cap == GL_SCISSOR_TEST)
-      {
-         Wine_GLContext *ctx = (Wine_GLContext *) NtCurrentTeb()->glContext;
-***************
-*** 1962,1967 ****
---- 2083,2089 ----
-             ctx->scissor_enabled = TRUE;
-      }
-      else
-+ #endif
-      {
-          wine_tsx11_lock();
-          pglEnable(cap);
-***************
-*** 2012,2017 ****
---- 2134,2140 ----
-  {
-      GLboolean enabled = False;
-  
-+ #if 0
-      if (cap == GL_SCISSOR_TEST)
-      {
-         Wine_GLContext *ctx = (Wine_GLContext *) NtCurrentTeb()->glContext;
-***************
-*** 2020,2025 ****
---- 2143,2149 ----
-             enabled = ctx->scissor_enabled;
-      }
-      else
-+ #endif
-      {
-          wine_tsx11_lock();
-          enabled = pglIsEnabled(cap);
-***************
-*** 2030,2035 ****
---- 2154,2160 ----
-  
-  static void WINAPI X11DRV_wglScissor(GLint x, GLint y, GLsizei width, GLsizei height)
-  {
-+ #if 0
-      Wine_GLContext *ctx = (Wine_GLContext *) NtCurrentTeb()->glContext;
-  
-      if (ctx)
-***************
-*** 2041,2050 ****
---- 2166,2181 ----
-  
-          sync_current_drawable(TRUE);
-      }
-+ #else
-+     wine_tsx11_lock();
-+     pglScissor(x, y, width, height);
-+     wine_tsx11_unlock();
-+ #endif
-  }
-  
-  static void WINAPI X11DRV_wglViewport(GLint x, GLint y, GLsizei width, GLsizei height)
-  {
-+ #if 0
-      Wine_GLContext *ctx = (Wine_GLContext *) NtCurrentTeb()->glContext;
-  
-      if (ctx)
-***************
-*** 2056,2061 ****
---- 2187,2197 ----
-  
-          sync_current_drawable(TRUE);
-      }
-+ #else
-+     wine_tsx11_lock();
-+     pglViewport(x, y, width, height);
-+     wine_tsx11_unlock();
-+ #endif
-  }
-  
-  /**
-***************
-*** 2327,2332 ****
---- 2463,2469 ----
-  
-      /* The function wglGetPbufferDCARB returns a DC to which the pbuffer can be connected.
-       * All formats in our pixelformat list are compatible with each other and the main drawable. */
-+     physDev->display = object->display;
-      physDev->current_pf = object->fmt->iPixelFormat;
-      physDev->drawable = object->drawable;
-      SetRect( &physDev->drawable_rect, 0, 0, object->width, object->height );
-***************
-*** 3234,3241 ****
---- 3371,3381 ----
-              ret = physDev->bitmap->glxpixmap;
-          }
-      }
-+     else if(physDev->gl_drawable)
-+         ret = physDev->gl_drawable;
-      else
-          ret = physDev->drawable;
-+ 
-      return ret;
-  }
-  
-***************
-*** 3264,3270 ****
-  
-    drawable = get_glxdrawable(physDev);
-    wine_tsx11_lock();
-!   pglXSwapBuffers(gdi_display, drawable);
-    wine_tsx11_unlock();
-  
-    /* FPS support */
---- 3404,3410 ----
-  
-    drawable = get_glxdrawable(physDev);
-    wine_tsx11_lock();
-!   pglXSwapBuffers(physDev->display, drawable);
-    wine_tsx11_unlock();
-  
-    /* FPS support */
-***************
-*** 3285,3290 ****
---- 3425,3431 ----
-    return TRUE;
-  }
-  
-+ 
-  /***********************************************************************
-   *		X11DRV_setup_opengl_visual
-   *
-Only in wine-0.9.43/dlls/winex11.drv: opengl.c.orig
-Only in wine-0.9.43/dlls/winex11.drv: opengl.c.rej
-Only in wine-0.9.43/dlls/winex11.drv: opengl.c~
-diff -rc wine-0.9.43-orig/dlls/winex11.drv/window.c wine-0.9.43/dlls/winex11.drv/window.c
-*** wine-0.9.43-orig/dlls/winex11.drv/window.c	2007-08-10 18:18:12.000000000 +0200
---- wine-0.9.43/dlls/winex11.drv/window.c	2007-08-21 10:20:19.000000000 +0200
-***************
-*** 55,61 ****
---- 55,64 ----
-  
-  static const char whole_window_prop[] = "__wine_x11_whole_window";
-  static const char icon_window_prop[]  = "__wine_x11_icon_window";
-+ static const char gl_display_prop[]   = "__wine_x11_gl_display";
-+ static const char gl_winptr_prop[]    = "__wine_x11_gl_winptr";
-  static const char managed_prop[]      = "__wine_x11_managed";
-+ static const char visible_prop[]      = "__wine_x11_visible";
-  static const char visual_id_prop[]    = "__wine_x11_visual_id";
-  
-  /* for XDG systray icons */
-***************
-*** 604,632 ****
-      BOOL iconic = (style & WS_MINIMIZE) != 0;
-  
-      if (!(data = X11DRV_get_win_data( hwnd ))) return;
-!     if (!data->whole_window || data->whole_window == DefaultRootWindow(display)) return;
-  
-      GetWindowRect( hwnd, &rect );
-  
-      wine_tsx11_lock();
-  
-!     if (!(wm_hints = XGetWMHints( display, data->whole_window ))) wm_hints = XAllocWMHints();
-!     wm_hints->flags |= StateHint | IconPositionHint;
-!     wm_hints->initial_state = iconic ? IconicState : NormalState;
-!     wm_hints->icon_x = rect.left - virtual_screen_rect.left;
-!     wm_hints->icon_y = rect.top - virtual_screen_rect.top;
-!     XSetWMHints( display, data->whole_window, wm_hints );
-! 
-!     if (style & WS_VISIBLE)
-      {
-!         if (iconic)
-!             XIconifyWindow( display, data->whole_window, DefaultScreen(display) );
-!         else
-!             if (X11DRV_is_window_rect_mapped( &rect ))
-!                 XMapWindow( display, data->whole_window );
-      }
-  
-!     XFree(wm_hints);
-      wine_tsx11_unlock();
-  }
-  
---- 607,650 ----
-      BOOL iconic = (style & WS_MINIMIZE) != 0;
-  
-      if (!(data = X11DRV_get_win_data( hwnd ))) return;
-!     if ((!data->whole_window && !data->gl_window) || data->whole_window == DefaultRootWindow(display)) return;
-  
-      GetWindowRect( hwnd, &rect );
-  
-      wine_tsx11_lock();
-  
-!     if (data->gl_window)
-      {
-!         if (style & WS_VISIBLE)
-!         {
-!             if (iconic)
-!                 XUnmapWindow( data->gl_display, data->gl_window );
-!             else
-!                 if (X11DRV_is_window_rect_mapped( &rect ))
-!                     XMapWindow( data->gl_display, data->gl_window );
-!         }
-      }
-  
-!     if (data->whole_window)
-!     {
-!         if (!(wm_hints = XGetWMHints( display, data->whole_window ))) wm_hints = XAllocWMHints();
-!         wm_hints->flags |= StateHint | IconPositionHint;
-!         wm_hints->initial_state = iconic ? IconicState : NormalState;
-!         wm_hints->icon_x = rect.left - virtual_screen_rect.left;
-!         wm_hints->icon_y = rect.top - virtual_screen_rect.top;
-!         XSetWMHints( display, data->whole_window, wm_hints );
-! 
-!         if (style & WS_VISIBLE)
-!         {
-!             if (iconic)
-!                 XIconifyWindow( display, data->whole_window, DefaultScreen(display) );
-!             else
-!                 if (X11DRV_is_window_rect_mapped( &rect ))
-!                     XMapWindow( display, data->whole_window );
-!         }
-! 
-!         XFree(wm_hints);
-!     }
-      wine_tsx11_unlock();
-  }
-  
-***************
-*** 694,699 ****
---- 712,748 ----
-      data->client_rect = *new_client_rect;
-      OffsetRect( &data->client_rect, -data->whole_rect.left, -data->whole_rect.top );
-  
-+     if (data->gl_window)
-+     {
-+         changes.width = data->client_rect.right - data->client_rect.left;
-+         changes.height = data->client_rect.bottom - data->client_rect.top;
-+ 
-+         if ( changes.width > 0 && changes.height > 0 )
-+         {
-+             POINT pt;
-+             pt.x = data->gl_offset->left;
-+             pt.y = data->gl_offset->top;
-+             if (data->hwnd != data->gl_parent)
-+                 MapWindowPoints( data->hwnd, data->gl_parent, &pt, 1 );
-+ 
-+             changes.x = pt.x;
-+             changes.y = pt.y;
-+ 
-+             TRACE( "setting gl_win %lx pos %d,%d,%dx%d\n",
-+                    data->gl_window, changes.x, changes.y,
-+                    changes.width, changes.height );
-+ 
-+             wine_tsx11_lock();
-+             XReconfigureWMWindow( data->gl_display, data->gl_window,
-+                                   DefaultScreen(data->gl_display),
-+                                   CWX|CWY|CWWidth|CWHeight, &changes );
-+             wine_tsx11_unlock();
-+         }
-+ 
-+         if (!data->whole_window)
-+             return;
-+     }
-+ 
-      if (!data->whole_window || data->lock_changes) return;
-  
-      mask = get_window_changes( &changes, &old_whole_rect, &data->whole_rect );
-***************
-*** 905,910 ****
---- 954,963 ----
-      if (!(data = X11DRV_get_win_data( hwnd ))) return;
-  
-      free_window_dce( data );
-+     wine_tsx11_lock();
-+ 
-+     if (data->gl_window) XDestroyWindow( data->gl_display, data->gl_window );
-+     wine_tsx11_unlock();
-      destroy_whole_window( display, data );
-      destroy_icon_window( display, data );
-  
-***************
-*** 927,932 ****
---- 980,989 ----
-          data->hwnd          = hwnd;
-          data->whole_window  = 0;
-          data->icon_window   = 0;
-+         data->gl_window     = 0;
-+         data->gl_parent     = 0;
-+         data->gl_offset     = NULL;
-+         data->gl_display    = NULL;
-          data->xic           = 0;
-          data->managed       = FALSE;
-          data->dce           = NULL;
-***************
-*** 1056,1061 ****
---- 1113,1147 ----
-      /* get class or window DC if needed */
-      alloc_window_dce( data );
-  
-+     if (!data->whole_window)
-+     {
-+         HWND parent = hwnd;
-+         while ((parent = GetAncestor( parent, GA_PARENT )))
-+         {
-+             if (X11DRV_get_whole_window( parent ))
-+             {
-+                 void *params[2];
-+                 SendMessageW( parent, WM_X11DRV_GET_PARENT_INFO, 0, (LPARAM)params );
-+                 data->gl_parent = parent;
-+                 data->gl_offset = params[0];
-+                 data->gl_display = params[1];
-+                 break;
-+             }
-+         }
-+         if (!parent)
-+             ERR( "Could not find drawable parent for HWND %p!\n", hwnd );
-+     }
-+     else
-+     {
-+         data->gl_parent = data->hwnd;
-+         data->gl_offset = &data->client_rect;
-+         data->gl_display = thread_display();
-+     }
-+ 
-+     SetPropA( hwnd, gl_display_prop, (HANDLE)data->gl_display );
-+     SetPropA( hwnd, gl_winptr_prop, (HANDLE)&data->gl_window );
-+     SetPropA( hwnd, visible_prop, (HANDLE)!!(cs->style&WS_VISIBLE) );
-+ 
-      /* Call the WH_CBT hook */
-  
-      /* the window style passed to the hook must be the real window style,
-***************
-*** 1216,1221 ****
---- 1302,1394 ----
-  
-  
-  /***********************************************************************
-+  *		X11DRV_get_gl_display
-+  *
-+  * Return the X display associated with the full area of a window
-+  */
-+ Display *X11DRV_get_gl_display( HWND hwnd )
-+ {
-+     struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
-+ 
-+     if (!data) return (Display *)GetPropA( hwnd, gl_display_prop );
-+     return data->gl_display;
-+ }
-+ 
-+ 
-+ /***********************************************************************
-+  *		X11DRV_get_visible
-+  *
-+  * Returns if the window has the WS_VISIBLE style or not
-+  */
-+ BOOL X11DRV_get_visible( HWND hwnd )
-+ {
-+     return (BOOL)GetPropA( hwnd, visible_prop );
-+ }
-+ 
-+ 
-+ /***********************************************************************
-+  *		X11DRV_set_visible
-+  *
-+  * Stores the WS_VISIBLE style for the window in a prop
-+  */
-+ BOOL X11DRV_set_visible( HWND hwnd, BOOL is_visible )
-+ {
-+     return (BOOL)SetPropA( hwnd, visible_prop, (HANDLE)is_visible );
-+ }
-+ 
-+ 
-+ /***********************************************************************
-+  *		X11DRV_set_gl_window
-+  *
-+  * Retrieve the OpenGL child window from the HWND
-+  */
-+ Window X11DRV_get_gl_window( HWND hwnd )
-+ {
-+     struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
-+ 
-+     if (!data)
-+     {
-+         Window *WinPtr = (Window *)GetPropA( hwnd, gl_winptr_prop );
-+         return *WinPtr;
-+     }
-+     else
-+     {
-+         return data->gl_window;
-+     }
-+ 
-+     return 0;
-+ }
-+ 
-+ 
-+ /***********************************************************************
-+  *		X11DRV_set_gl_window
-+  *
-+  * Sets the OpenGL child window for the HWND
-+  */
-+ BOOL X11DRV_set_gl_window( HWND hwnd, Window window )
-+ {
-+     struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
-+ 
-+     if (!data)
-+     {
-+         Window *WinPtr = (Window *)GetPropA( hwnd, gl_winptr_prop );
-+         if (WinPtr)
-+         {
-+             *WinPtr = window;
-+             return TRUE;
-+         }
-+     }
-+     else
-+     {
-+         data->gl_window = window;
-+         return TRUE;
-+     }
-+ 
-+     return FALSE;
-+ }
-+ 
-+ 
-+ /***********************************************************************
-   *		X11DRV_get_ic
-   *
-   * Return the X input context associated with a window
-Only in wine-0.9.43/dlls/winex11.drv: window.c.orig
-diff -rc wine-0.9.43-orig/dlls/winex11.drv/winpos.c wine-0.9.43/dlls/winex11.drv/winpos.c
-*** wine-0.9.43-orig/dlls/winex11.drv/winpos.c	2007-08-10 18:18:12.000000000 +0200
---- wine-0.9.43/dlls/winex11.drv/winpos.c	2007-08-21 10:20:19.000000000 +0200
-***************
-*** 142,158 ****
-  
-      if (changed & WS_VISIBLE)
-      {
-!         if (data->whole_window && X11DRV_is_window_rect_mapped( &data->window_rect ))
-          {
-              if (new_style & WS_VISIBLE)
-              {
-                  TRACE( "mapping win %p\n", hwnd );
-!                 X11DRV_sync_window_style( display, data );
-!                 X11DRV_set_wm_hints( display, data );
-!                 wine_tsx11_lock();
-!                 XMapWindow( display, data->whole_window );
-!                 wine_tsx11_unlock();
-              }
-              /* we don't unmap windows, that causes trouble with the window manager */
-          }
-          invalidate_dce( hwnd, &data->window_rect );
---- 142,171 ----
-  
-      if (changed & WS_VISIBLE)
-      {
-!         if ((data->whole_window || data->gl_window) &&
-!             X11DRV_is_window_rect_mapped( &data->window_rect ))
-          {
-              if (new_style & WS_VISIBLE)
-              {
-                  TRACE( "mapping win %p\n", hwnd );
-!                 if (data->gl_window)
-!                 {
-!                     wine_tsx11_lock();
-!                     XMapWindow( data->gl_display, data->gl_window );
-!                     wine_tsx11_unlock();
-!                 }
-!                 if (data->whole_window)
-!                 {
-!                     X11DRV_sync_window_style( display, data );
-!                     X11DRV_set_wm_hints( display, data );
-!                     wine_tsx11_lock();
-!                     XMapWindow( display, data->whole_window );
-!                     wine_tsx11_unlock();
-!                 }
-!                 X11DRV_set_visible( hwnd, 1 );
-              }
-+             else
-+                 X11DRV_set_visible( hwnd, 0 );
-              /* we don't unmap windows, that causes trouble with the window manager */
-          }
-          invalidate_dce( hwnd, &data->window_rect );
-***************
-*** 287,292 ****
---- 300,307 ----
-      }
-      SERVER_END_REQ;
-  
-+ //needs to be cleaned up
-+ X11DRV_set_visible ( hwnd, (new_style&WS_VISIBLE)?1 : 0 );
-      if (win == WND_DESKTOP || data->whole_window == DefaultRootWindow(gdi_display))
-      {
-          data->whole_rect = data->client_rect = data->window_rect = *rectWindow;
-***************
-*** 347,360 ****
-          }
-  
-  
-!         if (data->whole_window && !data->lock_changes)
-          {
-              if ((old_style & WS_VISIBLE) && !(new_style & WS_VISIBLE))
-              {
-                  /* window got hidden, unmap it */
-                  TRACE( "unmapping win %p\n", hwnd );
-                  wine_tsx11_lock();
-!                 XUnmapWindow( display, data->whole_window );
-                  wine_tsx11_unlock();
-              }
-              else if ((new_style & WS_VISIBLE) && !X11DRV_is_window_rect_mapped( rectWindow ))
---- 362,378 ----
-          }
-  
-  
-!         if ((data->whole_window || data->gl_window) && !data->lock_changes)
-          {
-              if ((old_style & WS_VISIBLE) && !(new_style & WS_VISIBLE))
-              {
-                  /* window got hidden, unmap it */
-                  TRACE( "unmapping win %p\n", hwnd );
-                  wine_tsx11_lock();
-!                 if (data->gl_window)
-!                     XUnmapWindow( data->gl_display, data->gl_window );
-!                 if (data->whole_window)
-!                     XUnmapWindow( display, data->whole_window );
-                  wine_tsx11_unlock();
-              }
-              else if ((new_style & WS_VISIBLE) && !X11DRV_is_window_rect_mapped( rectWindow ))
-***************
-*** 362,375 ****
-                  /* resizing to zero size or off screen -> unmap */
-                  TRACE( "unmapping zero size or off-screen win %p\n", hwnd );
-                  wine_tsx11_lock();
-!                 XUnmapWindow( display, data->whole_window );
-                  wine_tsx11_unlock();
-              }
-          }
-  
-          X11DRV_sync_window_position( display, data, swp_flags, rectClient, &new_whole_rect );
-  
-!         if (data->whole_window && !data->lock_changes)
-          {
-              BOOL new_fs_state, mapped = FALSE;
-  
---- 380,396 ----
-                  /* resizing to zero size or off screen -> unmap */
-                  TRACE( "unmapping zero size or off-screen win %p\n", hwnd );
-                  wine_tsx11_lock();
-!                 if (data->gl_window)
-!                     XUnmapWindow( data->gl_display, data->gl_window );
-!                 if (data->whole_window)
-!                     XUnmapWindow( display, data->whole_window );
-                  wine_tsx11_unlock();
-              }
-          }
-  
-          X11DRV_sync_window_position( display, data, swp_flags, rectClient, &new_whole_rect );
-  
-!         if ((data->whole_window || data->gl_window) && !data->lock_changes)
-          {
-              BOOL new_fs_state, mapped = FALSE;
-  
-***************
-*** 380,402 ****
-                  {
-                      /* window got shown, map it */
-                      TRACE( "mapping win %p\n", hwnd );
-!                     X11DRV_sync_window_style( display, data );
-!                     X11DRV_set_wm_hints( display, data );
-!                     wine_tsx11_lock();
-!                     XMapWindow( display, data->whole_window );
-!                     XFlush( display );
-!                     wine_tsx11_unlock();
-!                     mapped = TRUE;
-                  }
-                  else if ((swp_flags & (SWP_NOSIZE | SWP_NOMOVE)) != (SWP_NOSIZE | SWP_NOMOVE))
-                  {
-                      /* resizing from zero size to non-zero -> map */
-                      TRACE( "mapping non zero size or off-screen win %p\n", hwnd );
-                      wine_tsx11_lock();
-!                     XMapWindow( display, data->whole_window );
-!                     XFlush( display );
-                      wine_tsx11_unlock();
--                     mapped = TRUE;
-                  }
-                  SetRect( &old_screen_rect, 0, 0, screen_width, screen_height );
-                  if (fullscreen_state_changed( data, &old_client_rect, &old_screen_rect, &new_fs_state ) || mapped)
---- 401,441 ----
-                  {
-                      /* window got shown, map it */
-                      TRACE( "mapping win %p\n", hwnd );
-!                     if (data->gl_window)
-!                     {
-!                         wine_tsx11_lock();
-!                         XMapWindow( data->gl_display, data->gl_window );
-!                         XFlush( display );
-!                         wine_tsx11_unlock();
-!                     }
-!                     if (data->whole_window)
-!                     {
-!                         X11DRV_sync_window_style( display, data );
-!                         X11DRV_set_wm_hints( display, data );
-!                         wine_tsx11_lock();
-!                         XMapWindow( display, data->whole_window );
-!                         XFlush( display );
-!                         wine_tsx11_unlock();
-!                         mapped = TRUE;
-!                     }
-                  }
-                  else if ((swp_flags & (SWP_NOSIZE | SWP_NOMOVE)) != (SWP_NOSIZE | SWP_NOMOVE))
-                  {
-                      /* resizing from zero size to non-zero -> map */
-                      TRACE( "mapping non zero size or off-screen win %p\n", hwnd );
-                      wine_tsx11_lock();
-!                     if (data->gl_window)
-!                     {
-!                         XMapWindow( data->gl_display, data->gl_window );
-!                         XFlush( data->gl_display );
-!                     }
-!                     if (data->whole_window)
-!                     {
-!                         XMapWindow( display, data->whole_window );
-!                         mapped = TRUE;
-!                         XFlush( display );
-!                     }
-                      wine_tsx11_unlock();
-                  }
-                  SetRect( &old_screen_rect, 0, 0, screen_width, screen_height );
-                  if (fullscreen_state_changed( data, &old_client_rect, &old_screen_rect, &new_fs_state ) || mapped)
-Only in wine-0.9.43/dlls/winex11.drv: winpos.c.orig
-diff -rc wine-0.9.43-orig/dlls/winex11.drv/x11drv.h wine-0.9.43/dlls/winex11.drv/x11drv.h
-*** wine-0.9.43-orig/dlls/winex11.drv/x11drv.h	2007-08-10 18:18:12.000000000 +0200
---- wine-0.9.43/dlls/winex11.drv/x11drv.h	2007-08-21 10:20:19.000000000 +0200
-***************
-*** 122,130 ****
---- 122,132 ----
-    /* X physical device */
-  typedef struct
-  {
-+     Display      *display;
-      HDC           hdc;
-      GC            gc;          /* X Window GC */
-      Drawable      drawable;
-+     Drawable      gl_drawable;
-      RECT          dc_rect;       /* DC rectangle relative to drawable */
-      RECT          drawable_rect; /* Drawable rectangle relative to screen */
-      HRGN          region;        /* Device region (visible region & clip region) */
-***************
-*** 633,639 ****
-  enum x11drv_window_messages
-  {
-      WM_X11DRV_ACQUIRE_SELECTION = 0x80001000,
-!     WM_X11DRV_DELETE_WINDOW
-  };
-  
-  /* x11drv private window data */
---- 635,642 ----
-  enum x11drv_window_messages
-  {
-      WM_X11DRV_ACQUIRE_SELECTION = 0x80001000,
-!     WM_X11DRV_DELETE_WINDOW,
-!     WM_X11DRV_GET_PARENT_INFO
-  };
-  
-  /* x11drv private window data */
-***************
-*** 642,647 ****
---- 645,654 ----
-      HWND        hwnd;           /* hwnd that this private data belongs to */
-      Window      whole_window;   /* X window for the complete window */
-      Window      icon_window;    /* X window for the icon */
-+     Window      gl_window;      /* X window for OpenGL display */
-+     HWND        gl_parent;      /* hwnd that has the drawable the OpenGL display is from */
-+     RECT       *gl_offset;      /* The OpenGL parent window's client_rect */
-+     Display    *gl_display;     /* The display the OpenGL window uses */
-      RECT        window_rect;    /* USER window rectangle relative to parent */
-      RECT        whole_rect;     /* X window rectangle for the whole window relative to parent */
-      RECT        client_rect;    /* client area relative to whole window */
-***************
-*** 655,666 ****
---- 662,679 ----
-  
-  extern struct x11drv_win_data *X11DRV_get_win_data( HWND hwnd );
-  extern Window X11DRV_get_whole_window( HWND hwnd );
-+ extern Display *X11DRV_get_gl_display( HWND hwnd );
-+ extern Window X11DRV_get_gl_window( HWND hwnd );
-+ extern BOOL X11DRV_set_gl_window( HWND hwnd, Window window );
-+ extern BOOL X11DRV_get_visible( HWND hwnd );
-+ extern BOOL X11DRV_set_visible( HWND hwnd, BOOL is_visible );
-  extern BOOL X11DRV_is_window_rect_mapped( const RECT *rect );
-  extern XIC X11DRV_get_ic( HWND hwnd );
-  
-  extern void alloc_window_dce( struct x11drv_win_data *data );
-  extern void free_window_dce( struct x11drv_win_data *data );
-  extern void invalidate_dce( HWND hwnd, const RECT *rect );
-+ extern HWND hwnd_from_dce( struct dce *dce );
-  
-  /* X context to associate a hwnd to an X window */
-  extern XContext winContext;
-Only in wine-0.9.43/dlls/winex11.drv: x11drv.h.orig
diff --git a/pkgs/misc/ntfs-3g/default.nix b/pkgs/misc/ntfs-3g/default.nix
index 1962f6764e8..5f6a0bdbc5f 100644
--- a/pkgs/misc/ntfs-3g/default.nix
+++ b/pkgs/misc/ntfs-3g/default.nix
@@ -1,9 +1,9 @@
 args: with args;
 stdenv.mkDerivation rec {
-  name = "ntfs-3g-1.2129";
+  name = "ntfs-3g-1.1104";
   src = fetchurl {
     url = "${meta.homepage}/${name}.tgz";
-    sha256 = "00fqg39m5myi46kgsssxmpya6g8y32z6ggqc2snjrv0znfg3009i";
+    sha256 = "1m96c3vxm051lpy3kyik9s0m390rj6ngm11xmahfhw61794jzbyp";
   };
   buildInputs = [fuse pkgconfig];
   preConfigure="sed -e 's:/sbin:@sbindir@:' -i src/Makefile.in";
diff --git a/pkgs/misc/screensavers/xlockmore/default.nix b/pkgs/misc/screensavers/xlockmore/default.nix
new file mode 100644
index 00000000000..025a2c044eb
--- /dev/null
+++ b/pkgs/misc/screensavers/xlockmore/default.nix
@@ -0,0 +1,30 @@
+{stdenv, fetchurl, pam, x11, freetype}:
+
+stdenv.mkDerivation {
+  # FIXME: Password authentication doesn't work!
+
+  name = "xlockmore-5.24";
+  src = fetchurl {
+    url = http://www.tux.org/~bagleyd/xlock/xlockmore-5.24.tar.bz2;
+    sha256 = "dbee7bbe35c08afcbe419603fae60aee7898bbd85a3175dc788f02ddbb9f5a39";
+  };
+
+  # Optionally, it can use GTK+ as well.
+  buildInputs = [pam x11 freetype];
+
+  # The `xlock' program needs to be linked against Glibc's
+  # `libgcrypt', which contains `crypt(3)'.
+  patches = [ ./makefile-libcrypt.patch ];
+
+  # Don't try to install `xlock' setuid.  Instead, the user should add
+  # it to `security.extraSetuidPrograms'.
+  configureFlags = 
+    "--disable-setuid " + "--enable-pam " +
+    "--enable-appdefaultdir=$out/lib/X11/app-defaults";
+
+  meta = {
+    description = "Xlockmore, a screen locker for the X Window System.";
+    homepage = http://www.tux.org/~bagleyd/xlockmore.html;
+    license = "GPL";
+  };
+}
diff --git a/pkgs/misc/screensavers/xlockmore/makefile-libcrypt.patch b/pkgs/misc/screensavers/xlockmore/makefile-libcrypt.patch
new file mode 100644
index 00000000000..df31a00a13b
--- /dev/null
+++ b/pkgs/misc/screensavers/xlockmore/makefile-libcrypt.patch
@@ -0,0 +1,11 @@
+--- xlockmore-5.24/modes/Makefile.in	2007-01-22 23:02:07.000000000 +0100
++++ xlockmore-5.24/modes/Makefile.in	2008-02-11 17:24:34.000000000 +0100
+@@ -326,7 +326,7 @@ CFLAGS = @CFLAGS@
+ CXXFLAGS = @CXXFLAGS@
+ #CFLAGS = -O
+ #CFLAGS = -g
+-XLOCKLDFLAGS = @XLOCKLDFLAGS@ $(CHECKLDFLAG)
++XLOCKLDFLAGS = @XLOCKLDFLAGS@ $(CHECKLDFLAG) -lcrypt
+ XLIBS = @XLIBS@
+ XLOCKLIBS = $(MODULELIB) @XLOCKLIBS@
+ 
diff --git a/pkgs/os-specific/linux/alsa/1.0.14.nix b/pkgs/os-specific/linux/alsa/1.0.14.nix
deleted file mode 100644
index c7799af559a..00000000000
--- a/pkgs/os-specific/linux/alsa/1.0.14.nix
+++ /dev/null
@@ -1,14 +0,0 @@
-args: with args;
-
-rec {
-  alsaLib = (import ./common.nix) {
-    aName = "lib";
-    sha256 = "18xhm53adgss20jnva2nfl9gk46kb5an6ah820pazqn0ykd97rh1";
-  } args;
-
-  alsaUtils = (import ./common.nix) {
-    aName = "utils";
-    sha256 = "1jx5bwa8abx7aih4lymx4bnrmyip2yb0rp1mza97wpni1q7n6z9h";
-    buildInputs = [alsaLib ncurses gettext];
-  } args;
-}
diff --git a/pkgs/os-specific/linux/alsa/1.0.16.nix b/pkgs/os-specific/linux/alsa/1.0.16.nix
deleted file mode 100644
index 5cac6f268aa..00000000000
--- a/pkgs/os-specific/linux/alsa/1.0.16.nix
+++ /dev/null
@@ -1,14 +0,0 @@
-args: with args;
-
-rec {
-  alsaLib = (import ./common.nix) {
-    aName = "lib";
-    sha256 = "1k96razf5h7blidh5ib54plcrfnbysvwm7vhvz28b4cy20zv66df";
-  } args;
-
-  alsaUtils = (import ./common.nix) {
-    aName = "utils";
-    sha256 = "10bj4pw2hp3f6qzkxsrlnvsxjlpqha696fn10gzdnnzym072skzb";
-    buildInputs = [alsaLib ncurses gettext];
-  } args;
-}
diff --git a/pkgs/os-specific/linux/alsa/common.nix b/pkgs/os-specific/linux/alsa/common.nix
deleted file mode 100644
index 218a4b91c8e..00000000000
--- a/pkgs/os-specific/linux/alsa/common.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-{aName, sha256, buildInputs ? [], propagatedBuildInputs ? [] } :
-args: with args; stdenv.mkDerivation rec {
-  name = "alsa-" + aName + "-" + version;
-
-  src = fetchurl {
-    url = "ftp://ftp.alsa-project.org/pub/" + aName + "/" + name + ".tar.bz2";
-    inherit sha256;
-  };
-
-  inherit buildInputs propagatedBuildInputs;
-
-  meta = { homepage = http://www.alsa-project.org; };
-}
diff --git a/pkgs/os-specific/linux/alsa/library/default.nix b/pkgs/os-specific/linux/alsa/library/default.nix
new file mode 100644
index 00000000000..6ab8143c7ab
--- /dev/null
+++ b/pkgs/os-specific/linux/alsa/library/default.nix
@@ -0,0 +1,13 @@
+{stdenv, fetchurl}:
+
+stdenv.mkDerivation {
+  name = "alsa-lib-1.0.14";
+  src = fetchurl {
+    url = ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.0.14.tar.bz2;
+	sha256 = "18xhm53adgss20jnva2nfl9gk46kb5an6ah820pazqn0ykd97rh1";
+  };
+
+  meta = {
+	  homepage = http://www.alsa-project.org;
+  };
+}
diff --git a/pkgs/os-specific/linux/alsa/utils/default.nix b/pkgs/os-specific/linux/alsa/utils/default.nix
new file mode 100644
index 00000000000..658d8d8e9f7
--- /dev/null
+++ b/pkgs/os-specific/linux/alsa/utils/default.nix
@@ -0,0 +1,14 @@
+{stdenv, fetchurl, alsaLib, ncurses, gettext}:
+
+stdenv.mkDerivation {
+  name = "alsa-utils-1.0.14";
+  src = fetchurl {
+    url = ftp://ftp.alsa-project.org/pub/utils/alsa-utils-1.0.14.tar.bz2;
+    sha256 = "1jx5bwa8abx7aih4lymx4bnrmyip2yb0rp1mza97wpni1q7n6z9h";
+  };
+  buildInputs = [alsaLib ncurses gettext];
+
+  meta = {
+	  homepage = http://www.alsa-project.org;
+  };
+}
diff --git a/pkgs/os-specific/linux/aufs/default.nix b/pkgs/os-specific/linux/aufs/default.nix
index c053a807307..2ce510a5b9b 100644
--- a/pkgs/os-specific/linux/aufs/default.nix
+++ b/pkgs/os-specific/linux/aufs/default.nix
@@ -9,12 +9,15 @@ stdenv.mkDerivation {
   };
 
   buildPhase = ''
-    mkdir kernelsrc
-    tar xvf ${kernel.src} -C kernelsrc
-  
+
     kernelVersion=$(cd ${kernel}/lib/modules && ls)
-    substituteInPlace fs/aufs/Makefile --replace srctree srctree2
-    make KDIR=${kernel}/lib/modules/$kernelVersion/build srctree2=$(pwd)/kernelsrc/* -f local.mk
+    kernelBuild=$(echo ${kernel}/lib/modules/$kernelVersion/source)
+    tar xvfj ${kernel.src}
+    kernelSource=$(echo $(pwd)/linux-*)
+    cp -prd $kernelBuild/* $kernelSource
+  
+    substituteInPlace fs/aufs/Makefile
+    make KDIR=$kernelSource -f local.mk
   '';
 
   installPhase = ''
diff --git a/pkgs/os-specific/linux/bridge_utils/default.nix b/pkgs/os-specific/linux/bridge_utils/default.nix
index 66d01a7d433..b4f5efce22f 100644
--- a/pkgs/os-specific/linux/bridge_utils/default.nix
+++ b/pkgs/os-specific/linux/bridge_utils/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
 
   preConfigure="autoreconf";
 
-  meta = {
+  meta = { 
       description = "http://sourceforge.net/projects/bridge/";
       homepage = [ "http://www.linux-foundation.org/en/Net:Bridge/" "http://sourceforge.net/projects/bridge/" ];
       license = "GPL";
diff --git a/pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/default.nix b/pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/default.nix
new file mode 100644
index 00000000000..3a87cd164cb
--- /dev/null
+++ b/pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/default.nix
@@ -0,0 +1,19 @@
+{stdenv, fetchurl}:
+
+stdenv.mkDerivation rec {
+  name = "iwlwifi-4965-ucode-4.44.17";
+  
+  src = fetchurl {
+    url = "http://intellinuxwireless.org/iwlwifi/downloads/" + name + ".tgz";
+    sha256 = "1mfnxsp58jvh0njvwaxrkbiggbzr4jd0hk314hxfwyjpjdd2hj6w";
+  };
+  
+  buildPhase = "true";
+
+  installPhase = "ensureDir $out; chmod -x *; cp * $out";
+  
+  meta = {
+    description = "Firmware for the Intel 4965ABG wireless card";
+    homepage = http://intellinuxwireless.org/;
+  };
+}
diff --git a/pkgs/os-specific/linux/firmware/zd1211/default.nix b/pkgs/os-specific/linux/firmware/zd1211/default.nix
new file mode 100644
index 00000000000..1cffb504322
--- /dev/null
+++ b/pkgs/os-specific/linux/firmware/zd1211/default.nix
@@ -0,0 +1,21 @@
+args: with args;
+stdenv.mkDerivation ( rec {
+  pname = "zd1211-firmware";
+  version = "1.4";
+
+  name = "${pname}-${version}";
+  src = fetchurl {
+    url = "http://surfnet.dl.sourceforge.net/sourceforge/zd1211/${name}.tar.bz2";
+    sha256 = "866308f6f59f7075f075d4959dff2ede47735c751251fecd1496df1ba4d338e1";
+  };
+  
+  buildPhase = "true";
+
+  installPhase = "ensureDir $out/zd1211; cp * $out/zd1211";
+  
+  meta = {
+    description = "Firmware for the ZyDAS ZD1211(b) 802.11a/b/g USB WLAN chip";
+    homepage = http://sourceforge.net/projects/zd1211/;
+    license = "GPL";
+  };
+})
diff --git a/pkgs/os-specific/linux/iptables/1.4.0.nix b/pkgs/os-specific/linux/iptables/1.4.0.nix
deleted file mode 100644
index ba4fbd06db8..00000000000
--- a/pkgs/os-specific/linux/iptables/1.4.0.nix
+++ /dev/null
@@ -1,29 +0,0 @@
-args : with args; with builderDefs {src="";} null;
-  let localDefs = builderDefs (rec {
-    src = /* put a fetchurl here */
-    fetchurl {
-      url = http://www.netfilter.org/projects/iptables/files/iptables-1.4.0.tar.bz2;
-      sha256 = "0ljxbvdlg5mfxk0y00dr0qvsri1d495ci1pr8hrzga766n09g6px";
-    };
-
-    buildInputs = [];
-    configureFlags = [];
-    makeFlags = [
-      " KERNEL_DIR=${kernelHeaders} "
-    ];
-    preBuild = FullDepEntry (''
-      sed -e 's@/usr/local@'$out'@' -i Makefile Rules.make
-    '') ["doUnpack" "minInit"];
-  }) null; /* null is a terminator for sumArgs */
-  in with localDefs;
-stdenv.mkDerivation rec {
-  name = "iptables-"+version;
-  builder = writeScript (name + "-builder")
-    (textClosure localDefs 
-      [preBuild doMakeInstall doForceShare doPropagate]);
-  meta = {
-    description = "
-     IPtables Linux firewall.
-";
-  };
-}
diff --git a/pkgs/os-specific/linux/iptables/default.nix b/pkgs/os-specific/linux/iptables/default.nix
new file mode 100644
index 00000000000..606cf7796f9
--- /dev/null
+++ b/pkgs/os-specific/linux/iptables/default.nix
@@ -0,0 +1,10 @@
+{stdenv, fetchurl}:
+
+stdenv.mkDerivation {
+  name = "iptables-1.3.7";
+  src = fetchurl {
+    url = http://www.netfilter.org/projects/iptables/files/iptables-1.3.7.tar.bz2;
+    sha256 = "00nffc03akgm5p0skz90nl29h5d8b9fjc0d9lhipkbwy0ahcw00f";
+  };
+  preBuild = "makeFlagsArray=(PREFIX=$out)";
+}
diff --git a/pkgs/os-specific/linux/kernel/2.6.20.nix b/pkgs/os-specific/linux/kernel/2.6.20.nix
deleted file mode 100644
index b6c0c70b580..00000000000
--- a/pkgs/os-specific/linux/kernel/2.6.20.nix
+++ /dev/null
@@ -1,37 +0,0 @@
-args:
-(import ./meta.nix)
-( args //
-  {
-    version = "2.6.20.12";
-    src_hash = { sha256 = "1s7vdpg2897q5pcyxxypqcnibwpbdawbimkf3pngmahj8wr9c03x"; };
-
-	systemPatches = [
-      { name = "paravirt-nvidia";
-        patch = ./2.6.20-paravirt-nvidia.patch;
-      }
-      { name = "skas-2.6.20-v9-pre9";
-        patch = args.fetchurl {
-          url = http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/skas-2.6.20-v9-pre9/skas-2.6.20-v9-pre9.patch.bz2;
-          md5 = "02e619e5b3aaf0f9768f03ac42753e74";
-        };
-        extraConfig =
-          "CONFIG_PROC_MM=y\n" +
-          "# CONFIG_PROC_MM_DUMPABLE is not set\n";
-      }
-      { name = "fbsplash-0.9.2-r5-2.6.20-rc6";
-        patch = args.fetchurl {
-          url = http://dev.gentoo.org/~spock/projects/gensplash/archive/fbsplash-0.9.2-r5-2.6.20-rc6.patch;
-          sha256 = "11v4f85f4jnh9sbhqcyn47krb7l1czgzjw3w8wgbq14jm0sp9294";
-        };
-        extraConfig = "CONFIG_FB_SPLASH=y";
-      }
-	];
-
-    config = with args;
-      if config != null then config else
-      if userModeLinux then ./config-2.6.20-uml else
-      if stdenv.system == "i686-linux" then ./config-2.6.20-i686-smp else
-      if stdenv.system == "x86_64-linux" then ./config-2.6.20-x86_64-smp else
-      abort "No kernel configuration for your platform!";
-  }
-)
diff --git a/pkgs/os-specific/linux/kernel/2.6.21-ck.nix b/pkgs/os-specific/linux/kernel/2.6.21-ck.nix
deleted file mode 100644
index 0fb902c695e..00000000000
--- a/pkgs/os-specific/linux/kernel/2.6.21-ck.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-args:
-(import ./2.6.21.nix)
-( args //
-  {
-      extraPatches = (if (args ? extraPatches) then args.extraPatches else []) ++ 
-      [
-      {
-        name = "Con Kolivas Patch";
-        patch = ./patch-2.6.21-ck1;
-      }
-      ];
-  }
-)
diff --git a/pkgs/os-specific/linux/kernel/2.6.21.nix b/pkgs/os-specific/linux/kernel/2.6.21.nix
deleted file mode 100644
index da7ef60e096..00000000000
--- a/pkgs/os-specific/linux/kernel/2.6.21.nix
+++ /dev/null
@@ -1,45 +0,0 @@
-args:
-(import ./meta.nix)
-( args //
-  {
-    version = "2.6.21.7";
-    src_hash = { sha256 = "1c8ndsz35qd8vyng3xsxjjkjv5bnzyvc9b5vd85fz5v0bjp8hx50"; };
-
-	systemPatches = [
-      { name = "ext3cow";
-        patch = ./linux-2.6.21.7-ext3cow_wouter.patch;
-        extraConfig =  
-	"CONFIG_EXT3COW_FS=m\n" +
-	"CONFIG_EXT3COW_FS_XATTR=y\n" +
-	"CONFIG_EXT3COW_FS_POSIX_ACL=y\n" +
-	"CONFIG_EXT3COW_FS_SECURITY=y\n";
-      }
-      { name = "paravirt-nvidia";
-        patch = ./2.6.20-paravirt-nvidia.patch;
-      }
-      { name = "skas-2.6.20-v9-pre9";
-        patch = args.fetchurl {
-          url = http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/skas-2.6.20-v9-pre9/skas-2.6.20-v9-pre9.patch.bz2;
-          md5 = "02e619e5b3aaf0f9768f03ac42753e74";
-        };
-        extraConfig =
-          "CONFIG_PROC_MM=y\n" +
-          "# CONFIG_PROC_MM_DUMPABLE is not set\n";
-      }
-      { name = "fbsplash-0.9.2-r5-2.6.21";
-        patch = args.fetchurl {
-          url = http://dev.gentoo.org/~dsd/genpatches/trunk/2.6.21/4200_fbsplash-0.9.2-r5.patch;
-          sha256 = "00s8074fzsly2zpir885zqkvq267qyzg6vhsn7n1z2v1z78avxd8";
-        };
-        extraConfig = "CONFIG_FB_SPLASH=y";
-      }
-	];
-
-    config = with args;
-      if config != null then config else
-      if userModeLinux then ./config-2.6.21-uml else
-      if stdenv.system == "i686-linux" then ./config-2.6.21-i686-smp else
-      if stdenv.system == "x86_64-linux" then ./config-2.6.21-x86_64-smp else
-      abort "No kernel configuration for your platform!";
-  }
-)
diff --git a/pkgs/os-specific/linux/kernel/2.6.22-ck.nix b/pkgs/os-specific/linux/kernel/2.6.22-ck.nix
deleted file mode 100644
index 23a134cfc77..00000000000
--- a/pkgs/os-specific/linux/kernel/2.6.22-ck.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-args:
-(import ./2.6.22.nix)
-( args //
-  {
-      extraPatches = (if (args ? extraPatches) then args.extraPatches else []) ++ 
-      [
-      {
-        name = "Con Kolivas Patch";
-        patch = ./patch-2.6.21-ck1;
-      }
-      ];
-  }
-)
diff --git a/pkgs/os-specific/linux/kernel/2.6.22.nix b/pkgs/os-specific/linux/kernel/2.6.22.nix
deleted file mode 100644
index 36158a955cd..00000000000
--- a/pkgs/os-specific/linux/kernel/2.6.22.nix
+++ /dev/null
@@ -1,25 +0,0 @@
-args:
-(import ./meta.nix)
-( args //
-  {
-    version = "2.6.22.10";
-    src_hash = { sha256 = "0kh196qzm54mvnbrdr9s2q86l9yn2321gnsl5xq44ai2idqp044g"; };
-
-	systemPatches = [
-      { name = "fbsplash-0.9.2-r5-2.6.21";
-        patch = args.fetchurl {
-          url = http://dev.gentoo.org/~dsd/genpatches/trunk/2.6.22/4200_fbsplash-0.9.2-r5.patch;
-          sha256 = "0822wwlf2dqsap5qslnnp0yl1nbvvvb76l73w2dd8zsyn0bqg3px";
-        };
-        extraConfig = "CONFIG_FB_SPLASH=y";
-      }
-	];
-
-    config = with args;
-      if config != null then config else
-      if userModeLinux then ./config-2.6.22-uml else
-      if stdenv.system == "i686-linux" then ./config-2.6.22-i686-smp else
-      if stdenv.system == "x86_64-linux" then ./config-2.6.22-x86_64-smp else
-      abort "No kernel configuration for your platform!";
-  }
-)
diff --git a/pkgs/os-specific/linux/kernel/2.6.23.1.nix b/pkgs/os-specific/linux/kernel/2.6.23.1.nix
deleted file mode 100644
index 5b014b2591e..00000000000
--- a/pkgs/os-specific/linux/kernel/2.6.23.1.nix
+++ /dev/null
@@ -1,38 +0,0 @@
-args:
-(import ./meta.nix)
-( args //
-  {
-    version = "2.6.23.1";
-    src_hash = { sha256 = "0737g83h7jbrlss8782b17mhc3nfn8qfbh5s71flz8pjxmbbmg1m"; };
-
-	systemPatches = [
-      { # resume with resume=swap:/dev/xx
-        name = "tux on ice"; # (swsusp2)
-        patch = args.fetchurl {
-          url = "http://www.tuxonice.net/downloads/all/tuxonice-3.0-rc2-for-2.6.23.1.patch.bz2";
-          sha256 = "ef86267b6f3d7e309221f5173a881afae1dfa57418be5b3963f2380b0633ca1a";
-        };
-        extraConfig = "
-          CONFIG_SUSPEND2=y
-          CONFIG_SUSPEND2_FILE=y
-          CONFIG_SUSPEND2_SWAP=y
-          CONFIG_CRYPTO_LZF=y
-        ";
-      }
-      { name = "fbsplash-0.9.2-r5-2.6.21";
-        patch = args.fetchurl {
-          url = http://dev.gentoo.org/~dsd/genpatches/trunk/2.6.22/4200_fbsplash-0.9.2-r5.patch;
-          sha256 = "0822wwlf2dqsap5qslnnp0yl1nbvvvb76l73w2dd8zsyn0bqg3px";
-        };
-        extraConfig = "CONFIG_FB_SPLASH=y";
-      }
-	];
-
-    config = with args;
-      if config != null then config else
-      if userModeLinux then ./config-2.6.23-uml else
-      if stdenv.system == "i686-linux" then ./config-2.6.23-i686-smp else
-      if stdenv.system == "x86_64-linux" then ./config-2.6.23-x86_64-smp else
-      abort "No kernel configuration for your platform!";
-  }
-)
diff --git a/pkgs/os-specific/linux/kernel/2.6.23.12.nix b/pkgs/os-specific/linux/kernel/2.6.23.12.nix
deleted file mode 100644
index a0e3bcbf2d8..00000000000
--- a/pkgs/os-specific/linux/kernel/2.6.23.12.nix
+++ /dev/null
@@ -1,38 +0,0 @@
-args:
-(import ./meta.nix)
-( args //
-  {
-    version = "2.6.23.12";
-    src_hash = { sha256 = "1x3ngnhyxy9rlaislm2hzijaaa2mp8v930dyp8zmmhjdpzjf3w8k"; };
-
-	systemPatches = [
-      { # resume with resume=swap:/dev/xx
-        name = "tux on ice"; # (swsusp2)
-        patch = args.fetchurl {
-          url = "http://www.tuxonice.net/downloads/all/tuxonice-3.0-rc3-for-2.6.23.9.patch.bz2";
-          sha256 = "16f61cn0mdi7yklhdx4isi7c85843fzxq2cifd05cpsl6x6ilrfk";
-        };
-        extraConfig = "
-          CONFIG_SUSPEND2=y
-          CONFIG_SUSPEND2_FILE=y
-          CONFIG_SUSPEND2_SWAP=y
-          CONFIG_CRYPTO_LZF=y
-        ";
-      }
-      { name = "fbsplash-0.9.2-r5-2.6.21";
-        patch = args.fetchurl {
-          url = http://dev.gentoo.org/~dsd/genpatches/trunk/2.6.22/4200_fbsplash-0.9.2-r5.patch;
-          sha256 = "0822wwlf2dqsap5qslnnp0yl1nbvvvb76l73w2dd8zsyn0bqg3px";
-        };
-        extraConfig = "CONFIG_FB_SPLASH=y";
-      }
-	];
-
-    config = with args;
-      if config != null then config else
-      if userModeLinux then ./config-2.6.23-uml else
-      if stdenv.system == "i686-linux" then ./config-2.6.23-i686-smp else
-      if stdenv.system == "x86_64-linux" then ./config-2.6.23-x86_64-smp else
-      abort "No kernel configuration for your platform!";
-  }
-)
diff --git a/pkgs/os-specific/linux/kernel/2.6.23.16.nix b/pkgs/os-specific/linux/kernel/2.6.23.16.nix
deleted file mode 100644
index 454ce9bf31f..00000000000
--- a/pkgs/os-specific/linux/kernel/2.6.23.16.nix
+++ /dev/null
@@ -1,39 +0,0 @@
-args:
-(import ./meta.nix)
-( args //
-  {
-    version = "2.6.23.16";
-    src_hash = { sha256 = "0drk3981rl5j16s6amb63lai9kpi0vf0kr6avhpd9nikj27bsa83"; };
-
-	systemPatches = [
-      /*{ # resume with resume=swap:/dev/xx
-        name = "tux on ice"; # (swsusp2)
-        patch = args.fetchurl {
-          url = "http://www.tuxonice.net/downloads/all/tuxonice-3.0-rc3-for-2.6.23.9.patch.bz2";
-          sha256 = "16f61cn0mdi7yklhdx4isi7c85843fzxq2cifd05cpsl6x6ilrfk";
-        };
-        extraConfig = "
-          CONFIG_SUSPEND2=y
-          CONFIG_SUSPEND2_FILE=y
-          CONFIG_SUSPEND2_SWAP=y
-          CONFIG_CRYPTO_LZF=y
-        ";
-      }*/
-      { name = "fbsplash-0.9.2-r5-2.6.21";
-        patch = args.fetchurl {
-          url = http://dev.gentoo.org/~dsd/genpatches/trunk/2.6.22/4200_fbsplash-0.9.2-r5.patch;
-          sha256 = "0822wwlf2dqsap5qslnnp0yl1nbvvvb76l73w2dd8zsyn0bqg3px";
-        };
-        extraConfig = "CONFIG_FB_SPLASH=y";
-      }
-	];
-
-    config = with args;
-      if config != null then config else
-      if userModeLinux then ./config-2.6.23-uml else
-      if stdenv.system == "i686-linux" then ./config-2.6.23-i686-smp else
-      if stdenv.system == "x86_64-linux" then ./config-2.6.23-x86_64-smp else
-      abort "No kernel configuration for your platform!";
-  }
-)
-
diff --git a/pkgs/os-specific/linux/kernel/2.6.23.nix b/pkgs/os-specific/linux/kernel/2.6.23.nix
deleted file mode 100644
index 3b8c2c469a7..00000000000
--- a/pkgs/os-specific/linux/kernel/2.6.23.nix
+++ /dev/null
@@ -1,17 +0,0 @@
-args:
-(import ./meta.nix)
-( args //
-  {
-    version = "2.6.23";
-    src_hash = { sha256 = "1nyv7004w40l4adzq2b0hrvk3f4iqwngkgrlh8as9cpz6l4prrnl"; };
-
-	systemPatches = [ ];
-
-    config = with args;
-      if config != null then config else
-      if userModeLinux then ./config-2.6.23-uml else
-      if stdenv.system == "i686-linux" then ./config-2.6.23-i686-smp else
-      if stdenv.system == "x86_64-linux" then ./config-2.6.23-x86_64-smp else
-      abort "No kernel configuration for your platform!";
-  }
-)
diff --git a/pkgs/os-specific/linux/kernel/builder.sh b/pkgs/os-specific/linux/kernel/builder.sh
index 123b65e3f07..3512a74c196 100644
--- a/pkgs/os-specific/linux/kernel/builder.sh
+++ b/pkgs/os-specific/linux/kernel/builder.sh
@@ -66,7 +66,6 @@ installPhase() {
         cp arch/$arch/boot/bzImage $out/vmlinuz
     fi
 
-	sed -e '/-b $(INSTALL_MOD_PATH)/d' -i Makefile
     # Install the modules in $out/lib/modules with matching paths
     # in modules.dep (i.e., refererring to $out/lib/modules, not
     # /lib/modules).  The depmod_opts= is to prevent the kernel
@@ -96,7 +95,7 @@ installPhase() {
     if test "$arch" != um; then
         # copy all Makefiles and Kconfig files
         ln -s $out/lib/modules/$version/build $out/lib/modules/$version/source
-        cp --parents `find  -type f -name "Makefile*" -o -name "Kconfig*"` $out/lib/modules/$version/build
+        cp --parents `find  -type f -name Makefile -o -name "Kconfig*"` $out/lib/modules/$version/build
         cp Module.symvers $out/lib/modules/$version/build
 
         # weed out unneeded stuff
diff --git a/pkgs/os-specific/linux/kernel/default.nix b/pkgs/os-specific/linux/kernel/default.nix
deleted file mode 100644
index 61e3c43aeaa..00000000000
--- a/pkgs/os-specific/linux/kernel/default.nix
+++ /dev/null
@@ -1,32 +0,0 @@
-args:
-let
-  getValue = aSet: aName: default:
-  (if (builtins.hasAttr aName aSet) then (builtins.getAttr aName aSet) else default);
-in
-
-let
-  newArgs = (args //
-  {
-    userModeLinux = getValue args "userModeLinux" false;
-  
-    localVersion = getValue args "localVersion" "";
-  
-    config = getValue args "configFile" null;
-  
-    extraPatches = getValue args "extraPatches" [];
-  
-    extraConfig = getValue args "extraConfig" [];
-  });
-in
-args.stdenv.lib.listOfListsToAttrs [
-  [ "recurseForDerivations" true ]
-  [ "2.6.20" (import ./2.6.20.nix newArgs) ]
-  [ "2.6.21" (import ./2.6.21.nix newArgs) ]
-  [ "2.6.21-ck" (import ./2.6.21-ck.nix newArgs) ]
-  [ "2.6.22" (import ./2.6.22.nix newArgs) ]
-  [ "2.6.22-ck" (import ./2.6.22-ck.nix newArgs) ]
-  [ "2.6.23" (import ./2.6.23.nix newArgs) ]
-  [ "2.6.23.1" (import ./2.6.23.1.nix newArgs) ]
-  [ "2.6.23.16" (import ./2.6.23.16.nix newArgs) ]
-  [ "default" (import ./2.6.23.16.nix newArgs) ]
-]
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.20.nix b/pkgs/os-specific/linux/kernel/linux-2.6.20.nix
new file mode 100644
index 00000000000..3299ba5a3cb
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/linux-2.6.20.nix
@@ -0,0 +1,76 @@
+{ stdenv, fetchurl, perl, mktemp, module_init_tools
+
+  # A list of patches to apply to the kernel.  Each element of this list
+  # should be an attribute set {name, patch} where `name' is a
+  # symbolic name and `patch' is the actual patch.  The patch may
+  # optionally be compressed with gzip or bzip2.
+, kernelPatches ? []
+
+, # Whether to build a User-Mode Linux kernel.
+  userModeLinux ? false
+
+, # Allows you to set your own kernel version suffix (e.g.,
+  # "-my-kernel").
+  localVersion ? ""
+
+, # Your own kernel configuration file, if you don't want to use the
+  # default. 
+  kernelConfig ? null  
+}:
+
+assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
+
+let
+
+  lib = import ../../../lib;
+
+  version = "2.6.20.12";
+
+in
+
+stdenv.mkDerivation {
+  name = if userModeLinux then "user-mode-linux-${version}" else "linux-${version}";
+  builder = ./builder.sh;
+  
+  src = fetchurl {
+    url = "mirror://kernel/linux/kernel/v2.6/linux-${version}.tar.bz2";
+    sha256 = "1s7vdpg2897q5pcyxxypqcnibwpbdawbimkf3pngmahj8wr9c03x";
+  };
+  
+  patches = map (p: p.patch) kernelPatches;
+  extraConfig = lib.concatStrings (map (p: "\n" + (if p ? extraConfig then p.extraConfig else "") + "\n") kernelPatches);
+
+  config =
+    if kernelConfig != null then kernelConfig else
+    if userModeLinux then ./config-2.6.20-uml else
+    if stdenv.system == "i686-linux" then ./config-2.6.20-i686-smp else
+    if stdenv.system == "x86_64-linux" then ./config-2.6.20-x86_64-smp else
+    abort "No kernel configuration for your platform!";
+  
+  buildInputs = [perl mktemp];
+  
+  arch =
+    if userModeLinux then "um" else
+    if stdenv.system == "i686-linux" then "i386" else
+    if stdenv.system == "x86_64-linux" then "x86_64" else
+    abort "Platform ${stdenv.system} is not supported.";
+
+  makeFlags = if userModeLinux then "ARCH=um SHELL=bash" else "";
+
+  inherit module_init_tools;
+
+  allowLocalVersion = false; # don't allow patches to set a suffix
+  inherit localVersion; # but do allow the user to set one.
+
+  meta = {
+    description =
+      (if userModeLinux then
+        "User-Mode Linux"
+       else
+        "The Linux kernel") +
+      (if kernelPatches == [] then "" else
+        " (with patches: "
+        + lib.concatStrings (lib.intersperse ", " (map (x: x.name) kernelPatches))
+        + ")");
+  };
+}
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.21.nix b/pkgs/os-specific/linux/kernel/linux-2.6.21.nix
new file mode 100644
index 00000000000..e7fc2943a5c
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/linux-2.6.21.nix
@@ -0,0 +1,76 @@
+{ stdenv, fetchurl, perl, mktemp, module_init_tools
+
+  # A list of patches to apply to the kernel.  Each element of this list
+  # should be an attribute set {name, patch} where `name' is a
+  # symbolic name and `patch' is the actual patch.  The patch may
+  # optionally be compressed with gzip or bzip2.
+, kernelPatches ? []
+
+, # Whether to build a User-Mode Linux kernel.
+  userModeLinux ? false
+
+, # Allows you to set your own kernel version suffix (e.g.,
+  # "-my-kernel").
+  localVersion ? ""
+
+, # Your own kernel configuration file, if you don't want to use the
+  # default. 
+  kernelConfig ? null  
+}:
+
+assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
+
+let
+
+  lib = import ../../../lib;
+
+  version = "2.6.21.7";
+
+in
+
+stdenv.mkDerivation {
+  name = if userModeLinux then "user-mode-linux-${version}" else "linux-${version}";
+  builder = ./builder.sh;
+  
+  src = fetchurl {
+    url = "mirror://kernel/linux/kernel/v2.6/linux-${version}.tar.bz2";
+    sha256 = "1c8ndsz35qd8vyng3xsxjjkjv5bnzyvc9b5vd85fz5v0bjp8hx50";
+  };
+  
+  patches = map (p: p.patch) kernelPatches;
+  extraConfig = lib.concatStrings (map (p: "\n" + (if p ? extraConfig then p.extraConfig else "") + "\n") kernelPatches);
+
+  config =
+    if kernelConfig != null then kernelConfig else
+    if userModeLinux then ./config-2.6.21-uml else
+    if stdenv.system == "i686-linux" then ./config-2.6.21-i686-smp else
+    if stdenv.system == "x86_64-linux" then ./config-2.6.21-x86_64-smp else
+    abort "No kernel configuration for your platform!";
+  
+  buildInputs = [perl mktemp];
+  
+  arch =
+    if userModeLinux then "um" else
+    if stdenv.system == "i686-linux" then "i386" else
+    if stdenv.system == "x86_64-linux" then "x86_64" else
+    abort "Platform ${stdenv.system} is not supported.";
+
+  makeFlags = if userModeLinux then "ARCH=um SHELL=bash" else "";
+
+  inherit module_init_tools;
+
+  allowLocalVersion = false; # don't allow patches to set a suffix
+  inherit localVersion; # but do allow the user to set one.
+
+  meta = {
+    description =
+      (if userModeLinux then
+        "User-Mode Linux"
+       else
+        "The Linux kernel") +
+      (if kernelPatches == [] then "" else
+        " (with patches: "
+        + lib.concatStrings (lib.intersperse ", " (map (x: x.name) kernelPatches))
+        + ")");
+  };
+}
diff --git a/pkgs/os-specific/linux/kernel/meta.nix b/pkgs/os-specific/linux/kernel/linux-2.6.22.nix
index 8dcdcecab52..1abc1470616 100644
--- a/pkgs/os-specific/linux/kernel/meta.nix
+++ b/pkgs/os-specific/linux/kernel/linux-2.6.22.nix
@@ -1,12 +1,34 @@
-args: with args;
+{ stdenv, fetchurl, perl, mktemp, module_init_tools
+
+  # A list of patches to apply to the kernel.  Each element of this list
+  # should be an attribute set {name, patch} where `name' is a
+  # symbolic name and `patch' is the actual patch.  The patch may
+  # optionally be compressed with gzip or bzip2.
+, kernelPatches ? []
+
+, # Whether to build a User-Mode Linux kernel.
+  userModeLinux ? false
+
+, # Allows you to set your own kernel version suffix (e.g.,
+  # "-my-kernel").
+  localVersion ? ""
+
+, # Your own kernel configuration file, if you don't want to use the
+  # default. 
+  kernelConfig ? null
+
+, # A list of additional statements to be appended to the
+  # configuration file.
+  extraConfig ? []
+}:
 
 assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
 
 let
 
-  lib = stdenv.lib;
-  addNewlines = map (s: "\n" + s + "\n");
-  kernelPatches = systemPatches ++ extraPatches;
+  lib = import ../../../lib;
+
+  version = "2.6.22.18";
 
 in
 
@@ -14,18 +36,24 @@ stdenv.mkDerivation {
   name = if userModeLinux then "user-mode-linux-${version}" else "linux-${version}";
   builder = ./builder.sh;
   
-  src = fetchurl ( {
+  src = fetchurl {
     url = "mirror://kernel/linux/kernel/v2.6/linux-${version}.tar.bz2";
-  } // src_hash );
+    sha256 = "09acj1xr16j9y91gzwzcjhanhcpyac1ah2lc42mfi7d8c0plagry";
+  };
   
   patches = map (p: p.patch) kernelPatches;
-
   extraConfig =
-    let configFromPatches =
+    let addNewlines = map (s: "\n" + s + "\n");
+        configFromPatches =
           map (p: if p ? extraConfig then p.extraConfig else "") kernelPatches;
     in lib.concatStrings (addNewlines (configFromPatches ++ extraConfig));
 
-  inherit config;
+  config =
+    if kernelConfig != null then kernelConfig else
+    if userModeLinux then ./config-2.6.22-uml else
+    if stdenv.system == "i686-linux" then ./config-2.6.22-i686-smp else
+    if stdenv.system == "x86_64-linux" then ./config-2.6.22-x86_64-smp else
+    abort "No kernel configuration for your platform!";
   
   buildInputs = [perl mktemp];
   
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.23.nix b/pkgs/os-specific/linux/kernel/linux-2.6.23.nix
new file mode 100644
index 00000000000..d4c4b688ab4
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/linux-2.6.23.nix
@@ -0,0 +1,84 @@
+{ stdenv, fetchurl, perl, mktemp, module_init_tools
+
+  # A list of patches to apply to the kernel.  Each element of this list
+  # should be an attribute set {name, patch} where `name' is a
+  # symbolic name and `patch' is the actual patch.  The patch may
+  # optionally be compressed with gzip or bzip2.
+, kernelPatches ? []
+
+, # Whether to build a User-Mode Linux kernel.
+  userModeLinux ? false
+
+, # Allows you to set your own kernel version suffix (e.g.,
+  # "-my-kernel").
+  localVersion ? ""
+
+, # Your own kernel configuration file, if you don't want to use the
+  # default. 
+  kernelConfig ? null
+
+, # A list of additional statements to be appended to the
+  # configuration file.
+  extraConfig ? []
+}:
+
+assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
+
+let
+
+  lib = import ../../../lib;
+
+  version = "2.6.23.16";
+
+in
+
+stdenv.mkDerivation {
+  name = if userModeLinux then "user-mode-linux-${version}" else "linux-${version}";
+  builder = ./builder.sh;
+  
+  src = fetchurl {
+    url = "mirror://kernel/linux/kernel/v2.6/linux-${version}.tar.bz2";
+    sha256 = "0drk3981rl5j16s6amb63lai9kpi0vf0kr6avhpd9nikj27bsa83";
+  };
+  
+  patches = map (p: p.patch) kernelPatches;
+  extraConfig =
+    let addNewlines = map (s: "\n" + s + "\n");
+        configFromPatches =
+          map (p: if p ? extraConfig then p.extraConfig else "") kernelPatches;
+    in lib.concatStrings (addNewlines (configFromPatches ++ extraConfig));
+
+  config =
+    if kernelConfig != null then kernelConfig else
+    if userModeLinux then ./config-2.6.23-uml else
+    if stdenv.system == "i686-linux" then ./config-2.6.23-i686-smp else
+    if stdenv.system == "x86_64-linux" then ./config-2.6.23-x86_64-smp else
+    abort "No kernel configuration for your platform!";
+  
+  buildInputs = [perl mktemp];
+  
+  arch =
+    if userModeLinux then "um" else
+    if stdenv.system == "i686-linux" then "i386" else
+    if stdenv.system == "x86_64-linux" then "x86_64" else
+    abort "Platform ${stdenv.system} is not supported.";
+
+  makeFlags = if userModeLinux then "ARCH=um SHELL=bash" else "";
+
+  inherit module_init_tools;
+
+  allowLocalVersion = false; # don't allow patches to set a suffix
+  inherit localVersion; # but do allow the user to set one.
+
+  meta = {
+    description =
+      (if userModeLinux then
+        "User-Mode Linux"
+       else
+        "The Linux kernel") +
+      (if kernelPatches == [] then "" else
+        " (with patches: "
+        + lib.concatStrings (lib.intersperse ", " (map (x: x.name) kernelPatches))
+        + ")");
+  };
+}
diff --git a/pkgs/os-specific/linux/ndiswrapper/default.nix b/pkgs/os-specific/linux/ndiswrapper/default.nix
index 1eed97d7c51..5138ae4f9b8 100644
--- a/pkgs/os-specific/linux/ndiswrapper/default.nix
+++ b/pkgs/os-specific/linux/ndiswrapper/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
   ";
 
   # should we use unstable? 
-  src = fetchurl {
+  src = args.fetchurl {
     url = http://kent.dl.sourceforge.net/sourceforge/ndiswrapper/ndiswrapper-1.49.tar.gz;
     sha256 = "1b9nqkk7gv6gffzj9b8mjy5myxf2afwpyr2n5wbfsylf15dvvvjr";
   };
diff --git a/pkgs/os-specific/linux/reiserfsprogs/default.nix b/pkgs/os-specific/linux/reiserfsprogs/default.nix
index 040bae1dd47..1fc4fed12d5 100644
--- a/pkgs/os-specific/linux/reiserfsprogs/default.nix
+++ b/pkgs/os-specific/linux/reiserfsprogs/default.nix
@@ -8,7 +8,6 @@ stdenv.mkDerivation {
     sha256 = "1gv8gr0l5l2j52540y2wj9c9h7fn0r3vabykf95748ydmr9jr1n0";
   };
 
-  patches = [./headers-fix.patch];
   meta = {
     homepage = http://www.namesys.com/;
     description = "Reiserfs utilities";
diff --git a/pkgs/os-specific/linux/reiserfsprogs/headers-fix.patch b/pkgs/os-specific/linux/reiserfsprogs/headers-fix.patch
deleted file mode 100644
index 2c6693dae75..00000000000
--- a/pkgs/os-specific/linux/reiserfsprogs/headers-fix.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-diff -pruN 1:3.6.19-4/include/reiserfs_fs.h 1:3.6.19-4ubuntu2/include/reiserfs_fs.h
---- 1:3.6.19-4/include/reiserfs_fs.h	2004-09-16 08:49:05.000000000 +0100
-+++ 1:3.6.19-4ubuntu2/include/reiserfs_fs.h	2006-12-14 18:08:28.000000000 +0000
-@@ -38,15 +38,10 @@
- # define extern_inline
- #endif
- 
--#include <asm/unaligned.h>
--
- #ifndef get_unaligned
--#if defined(__ppc__) || defined(ppc) || defined(__ppc) || \
--    defined(__PPC) || defined(powerpc) || defined(__powerpc__)
- #	define get_unaligned(ptr)	(*(ptr))
- #	define put_unaligned(val,ptr)	((void)(*(ptr) = (val)))
- #endif
--#endif
- 
- #define get_leXX(xx,p,field)	(le##xx##_to_cpu ((p)->field))
- #define set_leXX(xx,p,field,val) do { (p)->field = cpu_to_le##xx(val); } while (0)
diff --git a/pkgs/servers/ftp/vsftpd/default.nix b/pkgs/servers/ftp/vsftpd/default.nix
index d3a2a5a66f7..7961448428d 100644
--- a/pkgs/servers/ftp/vsftpd/default.nix
+++ b/pkgs/servers/ftp/vsftpd/default.nix
@@ -4,7 +4,7 @@ stdenv.mkDerivation rec {
   name = "vsftpd-2.0.5";
   src = fetchurl {
     url = "ftp://vsftpd.beasts.org/users/cevans/${name}.tar.gz";
-	sha256 = "0nzsxknnaqnfk853yjsmi31sl02jf5ydix9wxbldv4i7vzqfnqjl";
+    sha256 = "0nzsxknnaqnfk853yjsmi31sl02jf5ydix9wxbldv4i7vzqfnqjl";
   };
   
   NIX_LDFLAGS = "-lcrypt -lssl -lcrypto -lpam -lcap";
diff --git a/pkgs/servers/http/tomcat/axis2/builder.sh b/pkgs/servers/http/tomcat/axis2/builder.sh
index e97c8c77b60..fa58a9e5292 100644
--- a/pkgs/servers/http/tomcat/axis2/builder.sh
+++ b/pkgs/servers/http/tomcat/axis2/builder.sh
@@ -2,7 +2,14 @@ buildInputs="$unzip $apacheAnt $jdk"
 source $stdenv/setup
 
 unzip $src
-cd axis2-*/webapp
+cd axis2-*
+ensureDir $out/share/java/axis2
+cp lib/* $out/share/java/axis2
+cd webapp
 ant
 ensureDir $out/webapps
 cp ../dist/axis2.war $out/webapps
+cd $out/webapps
+mkdir axis2
+cd axis2
+unzip ../axis2.war
diff --git a/pkgs/servers/samba/default.nix b/pkgs/servers/samba/default.nix
index fab06b6540c..629ac2a31b8 100644
--- a/pkgs/servers/samba/default.nix
+++ b/pkgs/servers/samba/default.nix
@@ -12,7 +12,12 @@ stdenv.mkDerivation rec {
   configureFlags = ''--with-pam --with-smbmount --datadir=$out/share
   --with-aio-support ''
   + (if (stdenv.gcc.libc != null) then "--with-libiconv=${stdenv.gcc.libc}" else "");
-
   postUnpack = "sourceRoot=\$sourceRoot/source";
-  postInstall = ''rm -rf $out/var ; ln -s /var/samba $out/var '';
+  
+  configFile = ./smb.conf;
+  postInstall = ''
+  rm -rf $out/var
+  ln -s /var/samba $out/var
+  cp ${configFile} $out/lib/smb.conf
+  '';
 }
diff --git a/pkgs/servers/samba/smb.conf b/pkgs/servers/samba/smb.conf
new file mode 100644
index 00000000000..c9da0d2cbb5
--- /dev/null
+++ b/pkgs/servers/samba/smb.conf
@@ -0,0 +1,271 @@
+# This is the main Samba configuration file. You should read the
+# smb.conf(5) manual page in order to understand the options listed
+# here. Samba has a huge number of configurable options (perhaps too
+# many!) most of which are not shown in this example
+#
+# For a step to step guide on installing, configuring and using samba, 
+# read the Samba-HOWTO-Collection. This may be obtained from:
+#  http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf
+#
+# Many working examples of smb.conf files can be found in the 
+# Samba-Guide which is generated daily and can be downloaded from: 
+#  http://www.samba.org/samba/docs/Samba-Guide.pdf
+#
+# Any line which starts with a ; (semi-colon) or a # (hash) 
+# is a comment and is ignored. In this example we will use a #
+# for commentry and a ; for parts of the config file that you
+# may wish to enable
+#
+# NOTE: Whenever you modify this file you should run the command "testparm"
+# to check that you have not made any basic syntactic errors. 
+#
+#======================= Global Settings =====================================
+[global]
+
+# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
+   workgroup = NIXOSGROUP
+
+# server string is the equivalent of the NT Description field
+   server string = Samba Server
+
+# Security mode. Defines in which mode Samba will operate. Possible 
+# values are share, user, server, domain and ads. Most people will want 
+# user level security. See the Samba-HOWTO-Collection for details.
+   security = user
+
+# This option is important for security. It allows you to restrict
+# connections to machines which are on your local network. The
+# following example restricts access to two C class networks and
+# the "loopback" interface. For more examples of the syntax see
+# the smb.conf man page
+;   hosts allow = 192.168.1. 192.168.2. 127.
+
+# If you want to automatically load your printer list rather
+# than setting them up individually then you'll need this
+   load printers = yes
+
+# you may wish to override the location of the printcap file
+;   printcap name = /etc/printcap
+
+# on SystemV system setting printcap name to lpstat should allow
+# you to automatically obtain a printer list from the SystemV spool
+# system
+;   printcap name = lpstat
+
+# It should not be necessary to specify the print system type unless
+# it is non-standard. Currently supported print systems include:
+# bsd, cups, sysv, plp, lprng, aix, hpux, qnx
+;   printing = cups
+
+# Uncomment this if you want a guest account, you must add this to /etc/passwd
+# otherwise the user "nobody" is used
+  guest account = smbguest
+
+# this tells Samba to use a separate log file for each machine
+# that connects
+   log file = /var/samba/sambalog/log.%m
+
+# Put a capping on the size of the log files (in Kb).
+   max log size = 50
+
+# Use password server option only with security = server
+# The argument list may include:
+#   password server = My_PDC_Name [My_BDC_Name] [My_Next_BDC_Name]
+# or to auto-locate the domain controller/s
+#   password server = *
+;   password server = <NT-Server-Name>
+
+# Use the realm option only with security = ads
+# Specifies the Active Directory realm the host is part of
+;   realm = MY_REALM
+
+# Backend to store user information in. New installations should 
+# use either tdbsam or ldapsam. smbpasswd is available for backwards 
+# compatibility. tdbsam requires no further configuration.
+   passdb backend = tdbsam:/var/samba/passdb.tdb
+
+# Using the following line enables you to customise your configuration
+# on a per machine basis. The %m gets replaced with the netbios name
+# of the machine that is connecting.
+# Note: Consider carefully the location in the configuration file of
+#       this line.  The included file is read at that point.
+;   include = /usr/local/samba/lib/smb.conf.%m
+
+# Configure Samba to use multiple interfaces
+# If you have multiple network interfaces then you must list them
+# here. See the man page for details.
+;   interfaces = 192.168.12.2/24 192.168.13.2/24 
+
+# Browser Control Options:
+# set local master to no if you don't want Samba to become a master
+# browser on your network. Otherwise the normal election rules apply
+;   local master = no
+
+# OS Level determines the precedence of this server in master browser
+# elections. The default value should be reasonable
+;   os level = 33
+
+# Domain Master specifies Samba to be the Domain Master Browser. This
+# allows Samba to collate browse lists between subnets. Don't use this
+# if you already have a Windows NT domain controller doing this job
+;   domain master = yes 
+
+# Preferred Master causes Samba to force a local browser election on startup
+# and gives it a slightly higher chance of winning the election
+;   preferred master = yes
+
+# Enable this if you want Samba to be a domain logon server for 
+# Windows95 workstations. 
+;   domain logons = yes
+
+# if you enable domain logons then you may want a per-machine or
+# per user logon script
+# run a specific logon batch file per workstation (machine)
+;   logon script = %m.bat
+# run a specific logon batch file per username
+;   logon script = %U.bat
+
+# Where to store roving profiles (only for Win95 and WinNT)
+#        %L substitutes for this servers netbios name, %U is username
+#        You must uncomment the [Profiles] share below
+;   logon path = \\%L\Profiles\%U
+
+# Windows Internet Name Serving Support Section:
+# WINS Support - Tells the NMBD component of Samba to enable it's WINS Server
+;   wins support = yes
+
+# WINS Server - Tells the NMBD components of Samba to be a WINS Client
+#	Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
+;   wins server = w.x.y.z
+
+# WINS Proxy - Tells Samba to answer name resolution queries on
+# behalf of a non WINS capable client, for this to work there must be
+# at least one	WINS Server on the network. The default is NO.
+;   wins proxy = yes
+
+# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names
+# via DNS nslookups. The default is NO.
+   dns proxy = no 
+
+# These scripts are used on a domain controller or stand-alone 
+# machine to add or delete corresponding unix accounts
+;  add user script = /usr/sbin/useradd %u
+;  add group script = /usr/sbin/groupadd %g
+;  add machine script = /usr/sbin/adduser -n -g machines -c Machine -d /dev/null -s /bin/false %u
+;  delete user script = /usr/sbin/userdel %u
+;  delete user from group script = /usr/sbin/deluser %u %g
+;  delete group script = /usr/sbin/groupdel %g
+
+
+#============================ Share Definitions ==============================
+[homes]
+   comment = Home Directories
+   browseable = yes
+   writable = yes
+
+# Un-comment the following and create the netlogon directory for Domain Logons
+; [netlogon]
+;   comment = Network Logon Service
+;   path = /usr/local/samba/lib/netlogon
+;   guest ok = yes
+;   writable = no
+;   share modes = no
+
+
+# Un-comment the following to provide a specific roving profile share
+# the default is to use the user's home directory
+;[Profiles]
+;    path = /usr/local/samba/profiles
+;    browseable = no
+;    guest ok = yes
+
+
+# NOTE: If you have a BSD-style print system there is no need to 
+# specifically define each individual printer
+[printers]
+   comment = All Printers
+   path = /usr/spool/samba
+   browseable = no
+# Set public = yes to allow user 'guest account' to print
+   guest ok = no
+   writable = no
+   printable = yes
+
+# This one is useful for people to share files
+;[tmp]
+;   comment = Temporary file space
+;   path = /tmp
+;   read only = no
+;   public = yes
+
+# A publicly accessible directory, but read only, except for people in
+# the "staff" group
+;[public]
+;   comment = Public Stuff
+;   path = /home/samba
+;   public = yes
+;   writable = yes
+;   printable = no
+;   write list = @staff
+
+# Other examples. 
+#
+# A private printer, usable only by fred. Spool data will be placed in fred's
+# home directory. Note that fred must have write access to the spool directory,
+# wherever it is.
+;[fredsprn]
+;   comment = Fred's Printer
+;   valid users = fred
+;   path = /homes/fred
+;   printer = freds_printer
+;   public = no
+;   writable = no
+;   printable = yes
+
+# A private directory, usable only by fred. Note that fred requires write
+# access to the directory.
+;[fredsdir]
+;   comment = Fred's Service
+;   path = /usr/somewhere/private
+;   valid users = fred
+;   public = no
+;   writable = yes
+;   printable = no
+
+# a service which has a different directory for each machine that connects
+# this allows you to tailor configurations to incoming machines. You could
+# also use the %U option to tailor it by user name.
+# The %m gets replaced with the machine name that is connecting.
+;[pchome]
+;  comment = PC Directories
+;  path = /usr/pc/%m
+;  public = no
+;  writable = yes
+
+# A publicly accessible directory, read/write to all users. Note that all files
+# created in the directory by users will be owned by the default user, so
+# any user with access can delete any other user's files. Obviously this
+# directory must be writable by the default user. Another user could of course
+# be specified, in which case all files would be owned by that user instead.
+;[public]
+;   path = /usr/somewhere/else/public
+;   public = yes
+;   only guest = yes
+;   writable = yes
+;   printable = no
+
+# The following two entries demonstrate how to share a directory so that two
+# users can place files there that will be owned by the specific users. In this
+# setup, the directory should be writable by both users and should have the
+# sticky bit set on it to prevent abuse. Obviously this could be extended to
+# as many users as required.
+;[myshare]
+;   comment = Mary's and Fred's stuff
+;   path = /usr/somewhere/shared
+;   valid users = mary fred
+;   public = no
+;   writable = yes
+;   printable = no
+;   create mask = 0765
+
+
diff --git a/pkgs/servers/sql/mysql5/default.nix b/pkgs/servers/sql/mysql5/default.nix
index d76a81184d2..89107d10864 100644
--- a/pkgs/servers/sql/mysql5/default.nix
+++ b/pkgs/servers/sql/mysql5/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, ps, ncurses, zlib ? null, perl}:
+args: with args;
 
 # Note: zlib is not required; MySQL can use an internal zlib.
 
@@ -10,7 +10,8 @@ stdenv.mkDerivation {
     sha256 = "e4443d8dc859ed53bd9f3bef143ce30c7f5dee66a02748e9a003136be25e0060";
   };
 
-  buildInputs = [ps ncurses zlib perl];
+  buildInputs = [ps ncurses zlib perl openssl];
+  postInstall = "ln -s mysqld_safe $out/bin/mysqld";
 
-  configureFlags = "--enable-thread-safe-client";
+  configureFlags = "--enable-thread-safe-client --with-embedded-server --disable-static --with-openssl=${openssl} --with-berkeley-db";
 }
diff --git a/pkgs/servers/sql/postgresql/builder.sh b/pkgs/servers/sql/postgresql/builder.sh
new file mode 100755
index 00000000000..20e50ec1ec6
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/builder.sh
@@ -0,0 +1,10 @@
+source $stdenv/setup
+
+export LANG=en_US
+
+# configureFlags=""
+# if test "$jdbcSupport"; then
+#     configureFlags="--with-java $configureFlags"
+# fi
+
+genericBuild
diff --git a/pkgs/servers/sql/postgresql/default.nix b/pkgs/servers/sql/postgresql/default.nix
new file mode 100644
index 00000000000..d04712d3418
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/default.nix
@@ -0,0 +1,25 @@
+{stdenv, fetchurl, zlib, ncurses, readline}:
+
+assert zlib != null;
+assert ncurses != null;
+assert readline != null;
+
+stdenv.mkDerivation {
+  name = "postgresql-8.3.0";
+
+  src = fetchurl {
+    url = http://ftp2.nl.postgresql.org/source/v8.3.0/postgresql-8.3.0.tar.bz2;
+    sha256 = "19kf0q45d5zd1rxffin0iblizckk8cp6fpgb52sipqkpnmm6sdc5";
+  };
+
+  inherit readline;
+  
+  buildInputs = [zlib ncurses readline];
+
+  LANG = "en_US"; # is this needed anymore?
+
+  meta = {
+    description = "The world's most advanced open source database";
+    homepage = http://www.postgresql.org/;
+  };
+}
diff --git a/pkgs/servers/x11/xorg/builder.sh b/pkgs/servers/x11/xorg/builder.sh
index 0a145cc0a6c..8bde2867e10 100644
--- a/pkgs/servers/x11/xorg/builder.sh
+++ b/pkgs/servers/x11/xorg/builder.sh
@@ -4,13 +4,11 @@ source $stdenv/setup
 
 # After installation, automatically add all "Requires" fields in the
 # pkgconfig files (*.pc) to the propagated build inputs.
-if test -n "$postInstall"; then
-	postInstall="$postInstall; autoPropagateBuildInputs"
-else
-	postInstall=autoPropagateBuildInputs
-fi
+origPostInstall=$postInstall
+postInstall=postInstall
+postInstall() {
+    if test -n "$origPostInstall"; then eval "$origPostInstall"; fi
 
-autoPropagateBuildInputs() {
     local r p requires
     requires=$(grep "Requires:" $out/lib/pkgconfig/*.pc | \
         sed "s/Requires://" | sed "s/,/ /g")
diff --git a/pkgs/stdenv/generic/builder.sh b/pkgs/stdenv/generic/builder.sh
index f772b1cc19b..0af3210dbc9 100644
--- a/pkgs/stdenv/generic/builder.sh
+++ b/pkgs/stdenv/generic/builder.sh
@@ -3,6 +3,10 @@ p2=$param2
 p3=$param3
 p4=$param4
 p5=$param5
+_preHook="$preHook"
+_postHook="$postHook"
+preHook=
+postHook=
 
 source $stdenv/setup
 
@@ -11,8 +15,8 @@ mkdir $out
 # Can't use substitute() here, because replace may not have been
 # built yet (in the bootstrap).
 sed \
-    -e "s^@preHook@^$preHook^g" \
-    -e "s^@postHook@^$postHook^g" \
+    -e "s^@preHook@^$_preHook^g" \
+    -e "s^@postHook@^$_postHook^g" \
     -e "s^@initialPath@^$initialPath^g" \
     -e "s^@gcc@^$gcc^g" \
     -e "s^@shell@^$shell^g" \
diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh
index 4f40c3ee562..395de988e4c 100644
--- a/pkgs/stdenv/generic/setup.sh
+++ b/pkgs/stdenv/generic/setup.sh
@@ -1,8 +1,4 @@
-set -e
-
-test -z $NIX_GCC && NIX_GCC=@gcc@
-
-
+######################################################################
 # Helper functions that might be useful in setup hooks.
 
 
@@ -27,6 +23,14 @@ addToSearchPath()
 }
 
 
+######################################################################
+# Initialisation.
+
+set -e
+
+test -z $NIX_GCC && NIX_GCC=@gcc@
+
+
 # Set up the initial path.
 PATH=
 for i in $NIX_GCC @initialPath@; do
@@ -34,7 +38,7 @@ for i in $NIX_GCC @initialPath@; do
 done
 
 if test "$NIX_DEBUG" = "1"; then
-    echo "Initial path: $PATH"
+    echo "initial path: $PATH"
 fi
 
 
@@ -49,9 +53,8 @@ param2=@param2@
 param3=@param3@
 param4=@param4@
 param5=@param5@
-if test -n "@preHook@"; then
-    source @preHook@
-fi
+if test -n "@preHook@"; then source @preHook@; fi
+eval "$preHook"
 
 
 # Check that the pre-hook initialised SHELL.
@@ -206,16 +209,16 @@ if test "$useTempPrefix" = "1"; then
 fi
 
 
-# Execute the post-hook.
-if test -n "@postHook@"; then
-    source @postHook@
-fi
-
 PATH=$_PATH${_PATH:+:}$PATH
 if test "$NIX_DEBUG" = "1"; then
-    echo "Final path: $PATH"
+    echo "final path: $PATH"
 fi
 
+
+######################################################################
+# Misc. helper functions.
+
+
 stripDirs() {
     local dirs="$1"
     local stripFlags="$2"
@@ -419,12 +422,12 @@ stripHash() {
 
 
 unpackFile() {
-    local file=$1
+    local file="$1"
     local cmd
 
     header "unpacking source archive $file" 3
 
-    case $file in
+    case "$file" in
         *.tar)
             tar xvf $file || fail
             ;;
@@ -458,7 +461,7 @@ unpackFile() {
 }
 
 
-unpackW() {
+unpackPhase() {
     if test -n "$unpackPhase"; then
         eval "$unpackPhase"
         return
@@ -528,23 +531,14 @@ unpackW() {
 }
 
 
-unpackPhase() {
-    sourceRoot=. # don't change to user dir homeless shelter if custom unpackSource doesn't set sourceRoot
-    header "unpacking sources"
-    startLog "unpack"
-    unpackW
-    stopLog
-    stopNest
-    cd $sourceRoot
-}
-
-
-patchW() {
+patchPhase() {
     if test -n "$patchPhase"; then
         eval "$patchPhase"
         return
     fi
 
+    if test -z "$patchPhase" -a -z "$patches"; then return; fi
+    
     if test -z "$patchFlags"; then
         patchFlags="-p1"
     fi
@@ -566,23 +560,13 @@ patchW() {
 }
 
 
-patchPhase() {
-    if test -z "$patchPhase" -a -z "$patches"; then return; fi
-    header "patching sources"
-    startLog "patch"
-    patchW
-    stopLog
-    stopNest
-}
-
-
 fixLibtool() {
     sed 's^eval sys_lib_.*search_path=.*^^' < $1 > $1.tmp
     mv $1.tmp $1
 }
 
 
-configureW() {
+configurePhase() {
     if test -n "$configurePhase"; then
         eval "$configurePhase"
         return
@@ -623,16 +607,7 @@ configureW() {
 }
 
 
-configurePhase() {
-    header "configuring"
-    startLog "configure"
-    configureW
-    stopLog
-    stopNest
-}
-
-
-buildW() {
+buildPhase() {
     if test -n "$buildPhase"; then
         eval "$buildPhase"
         return
@@ -640,8 +615,13 @@ buildW() {
 
     eval "$preBuild"
 
+    if ! test -n "$makefile" -o -e "Makefile" -o -e "makefile" -o -e "GNUmakefile"; then
+        echo "no Makefile, doing nothing"
+        return
+    fi
+
     echo "make flags: $makeFlags ${makeFlagsArray[@]} $buildFlags ${buildFlagsArray[@]}"
-    make \
+    make ${makefile:+-f $makefile} \
         $makeFlags "${makeFlagsArray[@]}" \
         $buildFlags "${buildFlagsArray[@]}" || fail
 
@@ -649,19 +629,7 @@ buildW() {
 }
 
 
-buildPhase() {
-    if test "$dontBuild" = 1; then
-        return
-    fi
-    header "building"
-    startLog "build"
-    buildW
-    stopLog
-    stopNest
-}
-
-
-checkW() {
+checkPhase() {
     if test -n "$checkPhase"; then
         eval "$checkPhase"
         return
@@ -672,24 +640,12 @@ checkW() {
     fi
 
     echo "check flags: $makeFlags ${makeFlagsArray[@]} $checkFlags ${checkFlagsArray[@]}"
-    make \
+    make ${makefile:+-f $makefile} \
         $makeFlags "${makeFlagsArray[@]}" \
         $checkFlags "${checkFlagsArray[@]}" $checkTarget || fail
 }
 
 
-checkPhase() {
-    if test "$doCheck" != 1; then
-        return
-    fi
-    header "checking"
-    startLog "check"
-    checkW
-    stopLog
-    stopNest
-}
-
-
 patchELF() {
     # Patch all ELF executables and shared libraries.
     header "patching ELF executables and libraries"
@@ -701,7 +657,7 @@ patchELF() {
 }
 
 
-installW() {
+installPhase() {
     if test -n "$installPhase"; then
         eval "$installPhase"
         return
@@ -716,7 +672,7 @@ installW() {
             installTargets=install
         fi
         echo "install flags: $installTargets $makeFlags ${makeFlagsArray[@]} $installFlags ${installFlagsArray[@]}"
-        make $installTargets \
+        make ${makefile:+-f $makefile} $installTargets \
             $makeFlags "${makeFlagsArray[@]}" \
             $installFlags "${installFlagsArray[@]}" || fail
     else
@@ -727,22 +683,10 @@ installW() {
 }
 
 
-installPhase() {
-    if test "$dontInstall" = 1; then
-        return
-    fi
-    header "installing"
-    startLog "install"
-    installW
-    stopLog
-    stopNest
-}
-
-
 # The fixup phase performs generic, package-independent, Nix-related
 # stuff, like running patchelf and setting the
 # propagated-build-inputs.  It should rarely be overriden.
-fixupW() {
+fixupPhase() {
     if test -n "$fixupPhase"; then
         eval "$fixupPhase"
         return
@@ -756,9 +700,9 @@ fixupW() {
         for d in $forceShare; do
             if test -d "$prefix/$d"; then
                 if test -d "$prefix/share/$d"; then
-                    echo "Both $d/ and share/$d/ exists!"
+                    echo "both $d/ and share/$d/ exists!"
                 else
-                    echo Fixing location of $d/ subdirectory
+                    echo "fixing location of $d/ subdirectory"
                     ensureDir $prefix/share
                     if test -w $prefix/share; then
                         mv -v $prefix/$d $prefix/share
@@ -771,10 +715,12 @@ fixupW() {
 
     # TODO: strip _only_ ELF executables, and return || fail here...
     if test -z "$dontStrip"; then
-        echo "Stripping debuging symbols from files in"
-        stripDirs "${stripDebugList:-lib}" -S
-        echo "Stripping all symbols from files in"
-        stripDirs "${stripAllList:-bin sbin}" -s
+        stripDebugList=${stripDebugList:-lib}
+        echo "stripping debuging symbols from files in $stripDebugList"
+        stripDirs "$stripDebugList" -S
+        stripAllList=${stripAllList:-bin sbin}
+        echo "stripping all symbols from files in $stripAllList"
+        stripDirs "$stripAllList" -s
     fi
 
     if test "$havePatchELF" = 1 -a -z "$dontPatchELF"; then
@@ -795,19 +741,7 @@ fixupW() {
 }
 
 
-fixupPhase() {
-    if test "$dontFixup" = 1; then
-        return
-    fi
-    header "post-installation fixup"
-    startLog "fixup"
-    fixupW
-    stopLog
-    stopNest
-}
-
-
-distW() {
+distPhase() {
     if test -n "$distPhase"; then
         eval "$distPhase"
         return
@@ -820,7 +754,7 @@ distW() {
     fi
 
     echo "dist flags: $distFlags ${distFlagsArray[@]}"
-    make $distFlags "${distFlagsArray[@]}" $distTarget || fail
+    make ${makefile:+-f $makefile} $distFlags "${distFlagsArray[@]}" $distTarget || fail
 
     if test "$dontCopyDist" != 1; then
         ensureDir "$out/tarballs"
@@ -838,15 +772,18 @@ distW() {
 }
 
 
-distPhase() {
-    if test "$doDist" != 1; then
-        return
-    fi
-    header "creating distribution"
-    startLog "dist"
-    distW
-    stopLog
-    stopNest
+showPhaseHeader() {
+    local phase="$1"
+    case $phase in
+        unpackPhase) header "unpacking sources";;
+        patchPhase) header "patching sources";;
+        configurePhase) header "configuring";;
+        buildPhase) header "building";;
+        checkPhase) header "running tests";;
+        installPhase) header "installing";;
+        fixupPhase) header "post-installation fixup";;
+        *) header "$phase";;
+    esac
 }
 
 
@@ -860,16 +797,39 @@ genericBuild() {
 
     if test -z "$phases"; then
         phases="unpackPhase patchPhase configurePhase buildPhase checkPhase \
-            installPhase fixupPhase distPhase";
-    fi
-
-    for i in $phases; do
+            installPhase fixupPhase distPhase $extraPhases";
+    fi
+
+    for curPhase in $phases; do
+        if test "$curPhase" = buildPhase -a -n "$dontBuild"; then continue; fi
+        if test "$curPhase" = checkPhase -a -z "$doCheck"; then continue; fi
+        if test "$curPhase" = installPhase -a -n "$dontInstall"; then continue; fi
+        if test "$curPhase" = fixupPhase -a -n "$dontFixup"; then continue; fi
+        if test "$curPhase" = distPhase -a -z "$doDist"; then continue; fi
+        
+        showPhaseHeader "$curPhase"
+        startLog "$curPhase"
         dumpVars
-        eval "$i"
+        
+        # Evaluate the variable named $curPhase if it exists, otherwise the
+        # function named $curPhase.
+        eval "${!curPhase:-$curPhase}"
+
+        if test "$curPhase" = unpackPhase; then
+            cd "${sourceRoot:-.}"
+        fi
+        
+        stopLog
+        stopNest
     done
 
     stopNest
 }
 
 
+# Execute the post-hook.
+if test -n "@postHook@"; then source @postHook@; fi
+eval "$postHook"
+
+
 dumpVars
diff --git a/pkgs/tools/X11/x11vnc/0.9.3.nix b/pkgs/tools/X11/x11vnc/0.9.3.nix
deleted file mode 100644
index 6a58d5b5508..00000000000
--- a/pkgs/tools/X11/x11vnc/0.9.3.nix
+++ /dev/null
@@ -1,27 +0,0 @@
-args : with args; with builderDefs {src="";} null;
-  let localDefs = builderDefs (rec {
-    src = /* put a fetchurl here */
-    fetchurl {
-      url = mirror://sourceforge/libvncserver/x11vnc-0.9.3.tar.gz;
-      sha256 = "0sfzkbqd2d94w51czci9w5j5z67amcl1gphgg6x77dyr2h46kc0a";
-    };
-
-    buildInputs = [libXfixes fixesproto openssl libXdamage damageproto
-      zlib libX11 xproto libjpeg libXtst libXinerama xineramaproto
-      libXrandr randrproto libXext xextproto inputproto recordproto];
-    configureFlags = [];
-  }) null; /* null is a terminator for sumArgs */
-  in with localDefs;
-stdenv.mkDerivation rec {
-  name = "x11vnc-"+version;
-  builder = writeScript (name + "-builder")
-    (textClosure localDefs 
-      [doConfigure doMakeInstall doForceShare doPropagate]);
-  meta = {
-    description = "
-    X11 VNC - VNC server connected to real X11 screen.
-";
-    homepage = "http://www.karlrunge.com/x11vnc/";
-  };
-}
-
diff --git a/pkgs/tools/misc/mc/default.nix b/pkgs/tools/misc/mc/default.nix
index 344e8a5ceea..8f03756a2d3 100644
--- a/pkgs/tools/misc/mc/default.nix
+++ b/pkgs/tools/misc/mc/default.nix
@@ -17,3 +17,4 @@ stdenv.mkDerivation rec {
     homepage = http://www.ibiblio.org/mc;
   };
 }
+
diff --git a/pkgs/tools/misc/relfs/cvs.2007.12.01.nix b/pkgs/tools/misc/relfs/cvs.2007.12.01.nix
index aea97f72dfd..83beb68151f 100644
--- a/pkgs/tools/misc/relfs/cvs.2007.12.01.nix
+++ b/pkgs/tools/misc/relfs/cvs.2007.12.01.nix
@@ -25,16 +25,16 @@ let build = FullDepEntry ("
 	mkdir -p \$out/bin
 	echo '
 		createuser -A -D \$1
-		dropdb relfs_\$1 ;
-		rm -rf /tmp/relfs-\$1-tmp;
-		mkdir /tmp/relfs-\$1-tmp;
-		USER=\$1 relfs -f -s /tmp/relfs-raskin-tmp  &
-		sleep 1 &&
+		dropdb relfs_\$1 ; 
+		rm -rf /tmp/relfs-\$1-tmp;  
+		mkdir /tmp/relfs-\$1-tmp;  
+		USER=\$1 relfs -f -s /tmp/relfs-raskin-tmp  & 
+		sleep 1 && 
 		kill -15 \${!};
-		rm -rf /tmp/relfs-\$1-tmp ;
-		psql -d relfs_\$1 <<< \"ALTER DATABASE relfs_raskin OWNER TO raskin;
-			ALTER TABLE obj OWNER TO \$1;
-			ALTER TABLE obj_mimetype OWNER TO \$1;
+		rm -rf /tmp/relfs-\$1-tmp ; 
+		psql -d relfs_\$1 <<< \"ALTER DATABASE relfs_raskin OWNER TO raskin; 
+			ALTER TABLE obj OWNER TO \$1; 
+			ALTER TABLE obj_mimetype OWNER TO \$1; 
 			ALTER TABLE membership OWNER TO \$1;\"' > \$out/bin/relfs_grant;
 	chmod a+x \$out/bin/relfs_grant;
 ") [minInit doUnpack addInputs];
diff --git a/pkgs/tools/networking/lsh/default.nix b/pkgs/tools/networking/lsh/default.nix
new file mode 100644
index 00000000000..087aeddf497
--- /dev/null
+++ b/pkgs/tools/networking/lsh/default.nix
@@ -0,0 +1,17 @@
+{stdenv, fetchurl, gperf, guile, gmp, zlib, liboop, gnum4}:
+
+stdenv.mkDerivation {
+  name = "lsh-2.0.4";
+  src = fetchurl {
+    url = http://www.lysator.liu.se/~nisse/archive/lsh-2.0.4.tar.gz;
+    sha256 = "614b9d63e13ad3e162c82b6405d1f67713fc622a8bc11337e72949d613713091";
+  };
+
+  buildInputs = [gperf guile gmp zlib liboop gnum4];
+
+  meta = {
+    description = "GNU lsh, a GPL'd implementation of the SSH protocol.";
+    homepage = http://www.lysator.liu.se/~nisse/lsh/;
+    license = "GPL";
+  };
+}
diff --git a/pkgs/tools/networking/p2p/ktorrent/default.nix b/pkgs/tools/networking/p2p/ktorrent/default.nix
index a28189757b3..0c724f2ca5d 100644
--- a/pkgs/tools/networking/p2p/ktorrent/default.nix
+++ b/pkgs/tools/networking/p2p/ktorrent/default.nix
@@ -3,13 +3,21 @@
 }:
 
 stdenv.mkDerivation {
-  name = "ktorrent-2.2.1";
+  name = "ktorrent-2.2.5";
+  
   src = fetchurl {
-    url = http://ktorrent.pwsp.net/downloads/2.2.1/ktorrent-2.2.1.tar.gz;
-    sha256 = "1wv7y8p21fliys55hcbxgxndz6y7ilr3cqyz99y32sm0v6l7qpyd";
+    url = http://ktorrent.org/downloads/2.2.5/ktorrent-2.2.5.tar.bz2;
+    sha256 = "1rkblfpg4ysg4935i3l22ns553h37rn2flm4rgkqzdf67aq0akkx";
   };
+  
   buildInputs = [
     pkgconfig kdelibs kdelibs.qt xlibs.xlibs zlib libpng libjpeg perl gmp
   ];
+  
   configureFlags = "--without-arts";
+
+  meta = {
+    homepage = http://ktorrent.org/;
+    description = "A BitTorrent client for KDE";
+  };
 }
diff --git a/pkgs/tools/networking/vpnc/builder.sh b/pkgs/tools/networking/vpnc/builder.sh
new file mode 100644
index 00000000000..ecfabe2eb5e
--- /dev/null
+++ b/pkgs/tools/networking/vpnc/builder.sh
@@ -0,0 +1,9 @@
+source "$stdenv/setup"
+
+tar zxvf "$src" &&
+cd vpnc-*.*
+
+cat config.c |								\
+sed "s|/etc/vpnc/vpnc-script|$out/etc/vpnc/vpnc-script|g" > ,,tmp &&	\
+mv ,,tmp config.c &&							\
+patchPhase && buildPhase && installPhase && fixupPhase && distPhase
diff --git a/pkgs/tools/networking/vpnc/default.nix b/pkgs/tools/networking/vpnc/default.nix
new file mode 100644
index 00000000000..c11a4721cb7
--- /dev/null
+++ b/pkgs/tools/networking/vpnc/default.nix
@@ -0,0 +1,20 @@
+{stdenv, fetchurl, libgcrypt, perl}:
+
+stdenv.mkDerivation {
+  name = "vpnc-0.5.1";
+  src = fetchurl {
+    url = http://www.unix-ag.uni-kl.de/~massar/vpnc/vpnc-0.5.1.tar.gz;
+    sha256 = "f63660bd020bbe6a39e8eb67ad60c54d719046c6198a6834371d098947f9a2ed";
+  };
+
+  patches = [ ./makefile.patch ];
+
+  buildInputs = [libgcrypt perl];
+  builder = ./builder.sh;
+
+  meta = {
+    description = "VPNC, a virtual private network (VPN) client for Cisco's VPN concentrators";
+    homepage = http://www.unix-ag.uni-kl.de/~massar/vpnc/;
+    license = "GPL";
+  };
+}
diff --git a/pkgs/tools/networking/vpnc/makefile.patch b/pkgs/tools/networking/vpnc/makefile.patch
new file mode 100644
index 00000000000..89a8cd6da95
--- /dev/null
+++ b/pkgs/tools/networking/vpnc/makefile.patch
@@ -0,0 +1,22 @@
+--- vpnc-0.5.1.orig/Makefile	2008-02-10 22:22:43.000000000 +0100
++++ vpnc-0.5.1/Makefile	2008-02-10 22:22:32.000000000 +0100
+@@ -20,8 +20,8 @@
+ # $Id: Makefile 236 2007-09-05 20:40:59Z Joerg Mayer $
+ 
+ DESTDIR=
+-PREFIX=/usr/local
+-ETCDIR=/etc/vpnc
++PREFIX=$(out)
++ETCDIR=$(out)/etc/vpnc
+ BINDIR=$(PREFIX)/bin
+ SBINDIR=$(PREFIX)/sbin
+ MANDIR=$(PREFIX)/share/man
+@@ -71,7 +71,7 @@
+ 	$(CC) -o $@ $^ $(LDFLAGS)
+ 
+ vpnc.8 : vpnc.8.template makeman.pl vpnc
+-	./makeman.pl
++	perl makeman.pl
+ 
+ cisco-decrypt : cisco-decrypt.o config.o supp.o sysdep.o vpnc-debug.o
+ 	$(CC) -o $@ $^ $(LDFLAGS)
diff --git a/pkgs/tools/package-management/snix/default.nix b/pkgs/tools/package-management/snix/default.nix
new file mode 100644
index 00000000000..caf852de4e2
--- /dev/null
+++ b/pkgs/tools/package-management/snix/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, fetchurl, aterm, db4, perl, curl, bzip2, openssl ? null
+
+, ext3cowtools, e3cfsprogs, rsync
+#, libtool, docbook5, docbook5-xsl, flex, bison
+
+, ext3cow_kernel
+
+, storeDir ? "/nix/store"
+, stateDir ? "/nix/var"
+, nixStoreStateDir ? "/nix/state"
+}:
+
+stdenv.mkDerivation {
+  name = "snix-0.12rev9419";
+  
+  src = fetchurl {
+    url = http://www.denbreejen.net/public/nix/snix-0.12rev9419.tar.gz;
+    sha256 = "fe7c06a8c41f6c9c94898a5fd690ed76da397012ea4c624adac9029b23c88a1c";
+  };
+  
+  buildInputs = [perl curl openssl rsync];
+
+  configureFlags = "
+    --with-store-dir=${storeDir} --localstatedir=${stateDir}
+    --with-aterm=${aterm} --with-bdb=${db4} --with-bzip2=${bzip2}
+    --disable-init-state
+    --with-store-state-dir=${nixStoreStateDir}
+    --with-ext3cow-header=${ext3cow_kernel}/lib/modules/2.*/build/include/linux/ext3cow_fs.h
+    --with-rsync=${rsync}/bin/rsync";
+
+  meta = {
+    description = "The SNix Deployment System (Nix extended to handle state)";
+    homepage = http://nix.cs.uu.nl/;
+    license = "LGPL";
+  };
+}
diff --git a/pkgs/tools/security/gnupg/builder.sh b/pkgs/tools/security/gnupg/builder.sh
new file mode 100644
index 00000000000..c5545c7456c
--- /dev/null
+++ b/pkgs/tools/security/gnupg/builder.sh
@@ -0,0 +1,10 @@
+source $stdenv/setup
+
+preConfigure=preConfigure
+preConfigure() {
+    if test -n "$idea"; then
+        gunzip < $idea > ./cipher/idea.c
+    fi
+}
+
+genericBuild
diff --git a/pkgs/tools/security/gnupg/1.4.8.nix b/pkgs/tools/security/gnupg/default.nix
index d712f8da84a..16c86fbe804 100644
--- a/pkgs/tools/security/gnupg/1.4.8.nix
+++ b/pkgs/tools/security/gnupg/default.nix
@@ -1,20 +1,23 @@
-args: with args;
+{
+  # Support for the IDEA cipher (used by the old PGP) should only be
+  # enabled if it is legal for you to do so.
+  ideaSupport ? false
+  
+, stdenv, fetchurl, readline
+}:
 
-let
-  idea = fetchurl {
-    url = http://nix.cs.uu.nl/dist/tarballs/idea.c.gz;
-    md5 = "9dc3bc086824a8c7a331f35e09a3e57f";
-  } else null;
-in
-
-stdenv.mkDerivation rec {
-  name = "gnupg-" + version;
+stdenv.mkDerivation {
+  name = "gnupg-1.4.8";
+  builder = ./builder.sh;
   src = fetchurl {
-    url = "ftp://ftp.cert.dfn.de/pub/tools/crypt/gcrypt/gnupg/${name}.tar.bz2";
+    url = ftp://ftp.cert.dfn.de/pub/tools/crypt/gcrypt/gnupg/gnupg-1.4.8.tar.bz2;
     sha256 = "0v009vqpa4l9zwhcaaagz5sx65fjp8g0alsf8kac5s5gvrs2b78i";
   };
   buildInputs = [readline];
-  preConfigure = if ideaSupport then "gunzip < ${idea} > ./cipher/idea.c" else "";
+  idea = if ideaSupport then fetchurl {
+    url = http://nix.cs.uu.nl/dist/tarballs/idea.c.gz;
+    md5 = "9dc3bc086824a8c7a331f35e09a3e57f";
+  } else null;
 
   meta = {
     description = "A free implementation of the OpenPGP standard for encrypting and signing data";
diff --git a/pkgs/tools/security/gnupg/idea.patch b/pkgs/tools/security/gnupg/idea.patch
deleted file mode 100644
index aa65cc9f7ac..00000000000
--- a/pkgs/tools/security/gnupg/idea.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-
-This is required in order to support IDEA encrypted keys
-using gnupg-1.4.X. The raw key has two bytes which are part
-of the checksum but not part of the key.
-
-This will not get into upstream as upstream does not wish to support
-IDEA at all even for backward compatibility.
-
-Signed-off-by: Alon Bar-Lev <alonbl@gentoo.org>
-
-diff -urNp gnupg-2.0.4.org/g10/seckey-cert.c gnupg-2.0.4/g10/seckey-cert.c
---- gnupg-2.0.4.org/g10/seckey-cert.c	2006-11-21 10:26:13.000000000 +0200
-+++ gnupg-2.0.4/g10/seckey-cert.c	2007-06-22 18:08:48.000000000 +0300
-@@ -211,6 +211,11 @@ do_check( PKT_secret_key *sk, const char
-                 csum += checksum (buffer, ndata);
-                 gcry_mpi_release (sk->skey[i]);
- 
-+		if (sk->protect.algo==CIPHER_ALGO_IDEA) {
-+			buffer[0] = 0;
-+			buffer[1] = 0;
-+		}
-+
- 		err = gcry_mpi_scan( &sk->skey[i], GCRYMPI_FMT_USG,
- 				     buffer, ndata, &ndata );
- 		xfree (buffer);
diff --git a/pkgs/tools/security/gnupg/2.0.8.nix b/pkgs/tools/security/gnupg2/default.nix
index 05022e53c30..f6e22bec51d 100644
--- a/pkgs/tools/security/gnupg/2.0.8.nix
+++ b/pkgs/tools/security/gnupg2/default.nix
@@ -1,23 +1,16 @@
 args: with args;
-
-stdenv.mkDerivation rec {
-  name = "gnupg-" + version;
-
+stdenv.mkDerivation {
+  name = "gnupg-2.0.8";
   src = fetchurl {
-    url = "ftp://ftp.cert.dfn.de/pub/tools/crypt/gcrypt/gnupg/${name}.tar.bz2";
+    url = ftp://ftp.cert.dfn.de/pub/tools/crypt/gcrypt/gnupg/gnupg-2.0.8.tar.bz2;
     sha256 = "04v9s92xph1hrhac49yyrgzdwjqshs2zawvjbi3jc2klwjpi1wqn";
   };
-
   buildInputs = [ readline openldap bzip2 zlib libgpgerror pth libgcrypt
     libassuan libksba libusb curl ];
 
-  postInstall = "ln -s gpg2 $out/bin/gpg; ln -s gpgv2 $out/bin/gpgv";
-
-  patches = ./idea.patch;
-
   meta = {
     description = "A free implementation of the OpenPGP standard for encrypting
-    and signing data, v2";
+	and signing data, v2";
     homepage = http://www.gnupg.org/;
   };
 }
diff --git a/pkgs/tools/system/which/default.nix b/pkgs/tools/system/which/default.nix
index 67ddaa94295..b6c35c4fbf1 100644
--- a/pkgs/tools/system/which/default.nix
+++ b/pkgs/tools/system/which/default.nix
@@ -1,5 +1,4 @@
-args: with args;
-stdenv.mkDerivation {
+{stdenv, fetchurl, readline}: stdenv.mkDerivation {
   name = "which-2.19";
   src = fetchurl {
     url = mirror://gnu/which/which-2.19.tar.gz;
@@ -8,3 +7,6 @@ stdenv.mkDerivation {
 
   buildInputs = [readline];
 }
+
+
+
diff --git a/pkgs/tools/typesetting/lout/builder.sh b/pkgs/tools/typesetting/lout/builder.sh
new file mode 100755
index 00000000000..28788fc5227
--- /dev/null
+++ b/pkgs/tools/typesetting/lout/builder.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# Prepare a makefile specifying the appropriate output directories.
+#
+# Written by Ludovic Courtès <ludo@gnu.org>.
+
+source "$stdenv/setup" || exit 1
+
+nixMakefile="nix-makefile"
+
+# Build and install documentation, PS and PDF.
+installDoc ()
+{
+  echo "building and installing documentation..."
+  for doc in design expert slides user
+  do
+    echo "building \`$doc' document..."
+    if [ ! -f "doc/$doc/outfile.ps" ]
+    then
+      ( PATH="$PWD:$PATH" ;				\
+        cd "doc/$doc" && lout -r4 -o outfile.ps all )	\
+      || return 1
+    fi
+    cp "doc/$doc/outfile.ps" "$out/doc/lout/$doc.ps" &&		\
+    ps2pdf "doc/$doc/outfile.ps" "$out/doc/lout/$doc.pdf"
+  done
+
+  return 0
+}
+
+unpackPhase &&									\
+cd lout-*.* &&									\
+cat makefile |									\
+  sed -e "s|^PREFIX[[:blank:]]*=.*\$|PREFIX = $out|g ;				\
+          s|^LOUTLIBDIR[[:blank:]]*=.*$|LOUTLIBDIR = \$(PREFIX)/lib/lout|g ;	\
+	  s|^LOUTDOCDIR[[:blank:]]*=.*$|LOUTDOCDIR = \$(PREFIX)/doc/lout|g ;	\
+	  s|^MANDIR[[:blank:]]*=.*$|MANDIR = \$(PREFIX)/man|g"			\
+  > "$nixMakefile" &&								\
+mkdir -p "$out/bin" && mkdir -p "$out/lib"					\
+mkdir -p "$out/man" && mkdir -p "$out/doc/lout" &&				\
+make -f "$nixMakefile" install installman &&					\
+installDoc
diff --git a/pkgs/tools/typesetting/lout/default.nix b/pkgs/tools/typesetting/lout/default.nix
new file mode 100644
index 00000000000..e36cc9ad303
--- /dev/null
+++ b/pkgs/tools/typesetting/lout/default.nix
@@ -0,0 +1,20 @@
+{stdenv, fetchurl, ghostscript}:
+
+stdenv.mkDerivation {
+  name = "lout-3.36";
+  src = fetchurl {
+    url = ftp://ftp.cs.usyd.edu.au/jeff/lout/lout-3.36.tar.gz;
+    sha256 = "b689cbe12074be8817c90070b162593fc9cc51f2f8868701833ff599b24fd4ad";
+  };
+
+  buildInputs = [ ghostscript ];
+  builder = ./builder.sh;
+
+  meta = {
+    description = ''Lout is a document layout system, similar in functionality
+    		    to TeX/LaTeX, but based on a purely functional programming
+		    language.  It can produce PostScript output.'';
+    homepage = http://www.cs.usyd.edu.au/~jeff/;
+    license = "GPL";
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index acac3d50853..5a207434202 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -122,15 +122,46 @@ rec {
   useFromStdenv = it : alternative : if (builtins.hasAttr it stdenv) then
     (builtins.getAttr it stdenv) else alternative;
 
-  lib = library;
-
-  library = import ../lib;
-   # TODO remove
-   # lib_unstable = import ../lib/default-unstable.nix;
+  lib = import ../lib;
+
+  annotatedDerivations = (import ../lib/annotatedDerivations.nix) { inherit lib; };
+
+  # optional srcDir
+  annotatedWithSourceAndTagInfo = x : (x ? sourceWithTags);
+
+  # example arguments see annotatedGhcCabalDerivation
+  # tag command must create file named $TAG_FILE
+  sourceWithTagsDerivation = args: with args; 
+    let createTagFiles = (lib.maybeAttr "createTagFiles" [] args ); in
+  stdenv.mkDerivation {
+    phases = "unpackPhase buildPhase";
+    inherit (args) src name;
+    srcDir = (lib.maybeAttr "srcDir" "." args);
+    # using separate tag directory so that you don't have to glob that much files when starting your editor
+    # is this a good choice?
+    buildPhase = "
+      SRC_DEST=\$out/src/\$name
+      t=\$out/tags/\$name
+      ensureDir \$SRC_DEST \$t
+      cp -r \$srcDir \$SRC_DEST"
+      + lib.defineShList "sh_list_names" (lib.catAttrs "name" createTagFiles)
+      + lib.defineShList "sh_list_cmds" (lib.catAttrs "tagCmd" createTagFiles)
+      + "cd \$SRC_DEST
+      for a in `seq 0 \${#sh_list}`; do
+          TAG_FILE=\"\$SRC_DEST/\"\${sh_list_names[\$a]}
+          cmd=\"\${sh_list_cmds[\$a]}\"
+          echo running tag cmd \"\$cmd\" in `pwd`
+          eval \"\$cmd\";
+          ln -s \$TAG_FILE \"\$t/\"\${sh_list_names[\$a]}
+       done
+    ";
+  };
+  # example usage
+  testSourceWithTags = sourceWithTagsDerivation (ghc68_extra_libs ghcsAndLibs.ghc68).mtl.sourceWithTags;
 
   # Return an attribute from the Nixpkgs configuration file, or
   # a default value if the attribute doesn't exist.
-  getConfig = attrPath: default: library.getAttr attrPath default config;
+  getConfig = attrPath: default: lib.getAttr attrPath default config;
 
   # Return user-choosen version of given package. If you define package as
   #
@@ -257,6 +288,7 @@ rec {
         }
       else defaultStdenv;
 
+
   ### BUILD SUPPORT
 
 
@@ -311,9 +343,7 @@ rec {
   writeScript = name: text: runCommand name {inherit text;} "echo -n \"$text\" > $out; chmod +x $out";
  
   writeScriptBin = name: text: runCommand name {inherit text;} "mkdir -p \$out/bin; echo -n \"\$text\" > \$out/bin/\$name ; chmod +x \$out/bin/\$name";
-
-  stdenvNewSetupScript = stdenv;
-
+ 
   substituteAll = import ../build-support/substitute/substitute-all.nix {
     inherit stdenv;
   };
@@ -424,9 +454,10 @@ rec {
       inherit fetchurl stdenv coreutils;
     });
 
-  dosfstoolsFun = lib.sumArgs (selectVersion ../tools/misc/dosfstools "2.11deb")
+  dosfstoolsFun = lib.sumArgs (selectVersion ../tools/misc/dosfstools)
   {
     inherit builderDefs;
+    version = "2.11deb";
   };
 
   dosfstools = dosfstoolsFun null;
@@ -512,11 +543,14 @@ rec {
     inherit fetchurl stdenv;
   });
 
-  gnupg = selectVersion ../tools/security/gnupg "2.0.8" {
+  gnupg = import ../tools/security/gnupg {
+    inherit fetchurl stdenv readline;
+    ideaSupport = true; # enable for IDEA crypto support
+  };
+
+  gnupg2 = import ../tools/security/gnupg2 {
 	  inherit fetchurl stdenv readline openldap bzip2 zlib libgpgerror pth
 	    libgcrypt libassuan libksba libusb curl;
-    # enable for IDEA crypto support in  gnupg 1.4.x
-    ideaSupport = getConfig [ "gnupg" "idea" ] false;
   };
 
   gnuplot = import ../tools/graphics/gnuplot {
@@ -623,10 +657,18 @@ rec {
     inherit fetchurl stdenv ghc tetex polytable;
   };
 
+  lout = import ../tools/typesetting/lout {
+    inherit fetchurl stdenv ghostscript;
+  };
+
   lzma = import ../tools/compression/lzma {
     inherit fetchurl stdenv;
   };
 
+  lsh = import ../tools/networking/lsh {
+    inherit stdenv fetchurl gperf guile gmp zlib liboop gnum4;
+  };
+
   man = import ../tools/misc/man {
      inherit fetchurl stdenv groff less;
   };
@@ -779,7 +821,7 @@ rec {
   };
 
   shebangfix = import ../tools/misc/shebangfix {
-    inherit perl stdenv;
+    inherit stdenv perl;
   };
 
   smartmontools = import ../tools/system/smartmontools {
@@ -830,6 +872,10 @@ rec {
     inherit fetchurl stdenv ncurses;
   };
 
+  vpnc = import ../tools/networking/vpnc {
+    inherit fetchurl stdenv libgcrypt perl;
+  };
+
   testdisk = import ../tools/misc/testdisk {
     inherit fetchurl stdenv ncurses libjpeg e2fsprogs zlib openssl;
   };
@@ -939,7 +985,7 @@ rec {
     }));
 
   bashInteractive = appendToName "interactive" (import ../shells/bash {
-    inherit fetchurl ncurses stdenv;
+    inherit fetchurl stdenv ncurses;
     bison = bison23;
     interactive = true;
   });
@@ -974,6 +1020,11 @@ rec {
       inherit stdenv fetchurl jre;
     };
 
+  bigloo = import ../development/compilers/bigloo {
+    inherit fetchurl mkDerivationByConfiguration lib;
+    stdenv = overrideGCC stdenv gcc34;
+  };
+
   dylan = import ../development/compilers/gwydion-dylan {
     inherit fetchurl stdenv perl boehmgc yacc flex readline;
     dylan =
@@ -1062,9 +1113,10 @@ rec {
     profiledCompiler = true;
   });
 
-  # This new ghc stuff is under heavy development and might change ! 
+  # This new ghc stuff is under heavy development and will change ! 
+  # =========  =======================================================
 
-  # usage: see ghcPkgUtil.sh - use setup-new2 because of PATH_DELIMITER
+  # usage: see ghcPkgUtil.sh
   # depreceated -> use functions defined in builderDefs
   ghcPkgUtil = runCommand "ghcPkgUtil-internal" 
      { ghcPkgUtil = ../development/libraries/haskell/generic/ghcPkgUtil.sh; }
@@ -1073,53 +1125,236 @@ rec {
   ghcsAndLibs = 
     assert builtins ? listToAttrs;
     recurseIntoAttrs (import ../development/compilers/ghcs {
-      inherit ghcboot fetchurl recurseIntoAttrs perl gnum4 gmp readline stdenv lib;
-      inherit ghcPkgUtil;
+      inherit ghcboot fetchurl stdenv recurseIntoAttrs perl gnum4 gmp readline lib;
+      inherit ghcPkgUtil annotatedDerivations hasktags ctags;
     });
 
   # creates ghc-X-wl wich adds the passed libraries to the env var GHC_PACKAGE_PATH
   createGhcWrapper = { ghcPackagedLibs ? false, ghc, libraries, name, suffix ? "ghc_wrapper_${ghc.name}" } :
         import ../development/compilers/ghc/createGhcWrapper {
-    inherit ghcPackagedLibs ghc name suffix libraries ghcPkgUtil stdenv;
+    inherit stdenv ghcPackagedLibs ghc name suffix libraries ghcPkgUtil
+      annotatedDerivations lib sourceWithTagsDerivation annotatedWithSourceAndTagInfo;
+    installSourceAndTags = true;
+  };
+
+
+  # args must contain src name buildInputs
+  # classic expression style.. seems to work fine
+  # used now
+  #
+  # args must contain: src name buildInputs propagatedBuildInputs
+  # classic expression style.. seems to work fine
+  # used now
+  # goSrc contains source directory (containing the .cabal file)
+  ghcCabalDerivation = args : null_ : with lib; with args;
+    stdenv.mkDerivation ({
+      goSrcDir = "cd ${srcDir}";
+      inherit name src propagatedBuildInputs;
+      phases = "unpackPhase patchPhase buildPhase";
+      buildInputs = (if (args ? buildInputs) then args.buildInputs else [])
+                    ++ [ ghcPkgUtil ];
+      # TODO remove echo line
+      buildPhase ="
+          createEmptyPackageDatabaseAndSetupHook
+          export GHC_PACKAGE_PATH
+
+          \$goSrcDir
+          ghc --make Setup.*hs -o setup
+          CABAL_SETUP=./setup
+
+          nix_ghc_pkg_tool join local-pkg-db
+
+          \$CABAL_SETUP configure --package-db=local-pkg-db
+          \$CABAL_SETUP build
+          \$CABAL_SETUP copy --destdir=\$out
+          \$CABAL_SETUP register --gen-script
+          sed -e \"s=/usr/local/lib=\$out/usr/local/lib=g\" \\
+              -e \"s#bin/ghc-pkg --package-conf.*#bin/ghc-pkg --package-conf=\$PACKAGE_DB register -#\" \\
+              -i register.sh
+          ./register.sh
+          rm \${PACKAGE_DB}.old
+
+         ensureDir \"\$out/nix-support\"
+
+         echo \"\$propagatedBuildInputs\" > \"\$out/nix-support/propagated-build-inputs\"
+      ";
+  } // (subsetmap id args [ "patchPhase" ])); 
+
+  # creates annotated derivation (comments see above
+  annotatedGhcCabalDerivation = args : null_ : with lib; with args;
+  rec {
+    inherit name;
+
+    #aDeps = concatLists ( catAttrs ( subsetmap id args [ "buildInputs" "propagatedBuildInputs" ] ) );
+    aDeps = []; #TODO 
+
+    aDeriv = ghcCabalDerivation (args // (annotatedDerivations.delAnnotationsFromInputs args) ) null;
+
+   # annotation data
+
+    sourceWithTags = {
+     inherit src srcDir;
+     name = name + "-src-with-tags";
+     createTagFiles = [
+           { name = "${name}_haskell_tags";
+             # tagCmd = "${toString ghcsAndLibs.ghc68.ghc}/bin/hasktags --ctags `find . -type f -name \"*.*hs\"`; sort tags > \$TAG_FILE"; }
+             tagCmd = "${toString hasktags}/bin/hasktags-modified --ctags `find . -type f -name \"*.*hs\"`; sort tags > \$TAG_FILE"; }
+      ];
+    };
   };
 
   # this will change in the future 
-  ghc68_extra_libs = ghc:
-    let deriv = name : goSrcDir : deps : 
-        let localDefs = builderDefs {
-            inherit goSrcDir;
-            src = ghc.extra_src;
-          } null; 
-        in with localDefs;
-          stdenv.mkDerivation rec {
-            inherit name;
-            builder = writeScript (name + "-builder")
-                    (textClosure localDefs [ cabalBuild ]);
-          };
-    # using nvs to be able to use mtl-1.1.0.0 as name 
-  in lib.nvs "mtl-1.1.0.0" (deriv "mtl-1.1.0.0" "cd libraries/mtl" [ (__getAttr "base-3.0.1.0"  ghc.core_libs) ]);
+  # TODO enhance speed ! ?
+  ghc68_extra_libs = ghc: rec {
+      #   name (using lowercase letters everywhere because using installing packages having different capitalization is discouraged) - this way there is not that much to remember?
+
+      cabal_darcs_name = "cabal-darcs";
+
+      # introducing p here to speed things up.
+      # It merges derivations (defined below) and additional inputs. I hope that using as few nix functions as possible results in greates speed?
+      # unfortunately with x; won't work because it forces nix to evaluate all attributes of x which would lead to infinite recursion
+      pkgs = let x = ghc.core_libs // derivations; in {
+          # ghc extra packages 
+          mtl     = { name="mtl-1.1.0.0";     srcDir="libraries/mtl";    p_deps=[ x.base ]; src = ghc.extra_src; };
+          parsec  = { name="parsec-2.1.0.0";  srcDir="libraries/parsec"; p_deps=[ x.base ];       src = ghc.extra_src; };
+          network = { name="network-2.1.0.0"; srcDir="libraries/network"; p_deps=[ x.base x.parsec x.haskell98 ];       src = ghc.extra_src; };
+          regex_base = { name="regex-base-0.72.0.1"; srcDir="libraries/regex-base"; p_deps=[ x.base x.array x.bytestring x.haskell98 ]; src = ghc.extra_src; };
+          regex_posix = { name="regex-posix-0.72.0.2"; srcDir="libraries/regex-posix"; p_deps=[ x.regex_base x.haskell98 ]; src = ghc.extra_src; };
+          regex_compat = { name="regex-compat-0.71.0.1"; srcDir="libraries/regex-compat"; p_deps=[ x.base x.regex_posix x.regex_base x.haskell98 ]; src = ghc.extra_src; };
+          stm = { name="stm-2.1.1.0"; srcDir="libraries/stm"; p_deps=[ x.base x.array ]; src = ghc.extra_src; };
+          hunit = { name="HUnit-1.2.0.0"; srcDir="libraries/HUnit"; p_deps=[ x.base ]; src = ghc.extra_src; };
+          quickcheck = { name="QuickCheck-1.1.0.0"; srcDir="libraries/QuickCheck"; p_deps=[x.base x.random]; src = ghc.extra_src; };
+
+
+          # other pacakges  (hackage etc)
+          binary = rec { name = "binary-0.4.1"; p_deps = [ x.base x.bytestring x.containers x.array ];
+                           src = fetchurl { url = "http://hackage.haskell.org/packages/archive/binary/0.4.1/binary-0.4.1.tar.gz";
+                                        sha256 = "0jg5i1k5fz0xp1piaaf5bzhagqvfl3i73hlpdmgs4gc40r1q4x5v"; };
+                 };
+          # 1.13 is stable. There are more recent non stable versions
+          haxml = rec { name = "HaXml-1.13.3"; p_deps = [ x.base x.rts x.directory x.process x.pretty x.containers x.filepath x.haskell98 ];
+                       src = fetchurl { url = "http://www.haskell.org/HaXml/${name}.tar.gz";
+                                        sha256 = "08d9wy0rg9m66dd10x0zvkl74l25vxdakz7xp3j88s2gd31jp1v0"; };
+                 };
+          xhtml = rec { name = "xhtml-3000.0.2.2"; p_deps = [ x.base ];
+                       src = fetchurl { url = "http://hackage.haskell.org/packages/archive/xhtml/3000.0.2.2/xhtml-3000.0.2.2.tar.gz";
+                                        sha256 = "112mbq26ksh7r22y09h0xvm347kba3p4ns12vj5498fqqj333878"; };
+                 };
+          html = rec { name = "html-1.0.1.1"; p_deps = [ x.base ];
+                       src = fetchurl { url = "http://hackage.haskell.org/packages/archive/html/1.0.1.1/html-1.0.1.1.tar.gz";
+                                        sha256 = "10fayfm18p83zlkr9ikxlqgnzxg1ckdqaqvz6wp1xj95fy3p6yl1"; };
+                 };
+          crypto = rec { name = "crypto-4.1.0"; p_deps = [ x.base x.array x.pretty x.quickcheck x.random x.hunit ];
+                       src = fetchurl { url = "http://hackage.haskell.org/packages/archive/Crypto/4.1.0/Crypto-4.1.0.tar.gz";
+                                        sha256 = "13rbpbn6p1da6qa9m6f7dmkzdkmpnx6jiyyndzaz99nzqlrwi109"; };
+                 };
+          hslogger = rec { name = "hslogger-1.0.4"; p_deps = [ x.containers x.directory x.mtl x.network x.process];
+                       src = fetchurl { url = "http://hackage.haskell.org/packages/archive/hslogger/1.0.4/hslogger-1.0.4.tar.gz";
+                                        sha256 = "0kmz8xs1q41rg2xwk22fadyhxdg5mizhw0r4d74y43akkjwj96ar"; };
+                 };
+          parsep = { name = "parsep-0.1"; p_deps = [ x.base x.mtl x.bytestring ];
+                         src = fetchurl { url = "http://twan.home.fmf.nl/parsep/parsep-0.1.tar.gz";
+                                        sha256 = "1y5pbs5mzaa21127cixsamahlbvmqzyhzpwh6x0nznsgmg2dpc9q"; };
+                         patchPhase = "pwd; sed -i 's/fps/bytestring/' *.cabal";
+                 };
+
+        # HAPPS - Libraries
+          http_darcs = { name="http-darcs"; p_deps = [x.network x.parsec];
+                   src = fetchdarcs { url = "http://darcs.haskell.org/http/"; md5 = "4475f858cf94f4551b77963d08d7257c"; };
+                 };
+          syb_with_class_darcs = { name="syb-with-class-darcs"; p_deps = [x.template_haskell x.bytestring ];
+                   src = fetchdarcs { url = "http://happs.org/HAppS/syb-with-class"; md5 = "b42336907f7bfef8bea73bc36282d6ac"; };
+                 };
+
+        happs_data_darcs = { name="HAppS-Data-darcs"; p_deps=[ x.base x.mtl x.template_haskell x.syb_with_class_darcs x.haxml x.happs_util_darcs x.regex_compat x.bytestring x.pretty ];
+                    src = fetchdarcs { url = "http://happs.org/repos/HAppS-Data"; md5 = "10c505dd687e9dc999cb187090af9ba7"; };
+                    };
+        happs_util_darcs = { name="HAppS-Util-darcs"; p_deps=[ x.base x.mtl x.hslogger x.template_haskell x.array x.bytestring x.old_time x.process x.directory ];
+                    src = fetchdarcs { url = "http://happs.org/repos/HAppS-Util"; md5 = "693cb79017e522031c307ee5e59fc250"; };
+                    };
+        happs_state_darcs = { name="HAppS-State-darcs"; p_deps=[ x.base x.haxml
+                      x.mtl x.network x.stm x.template_haskell x.hslogger
+                        x.happs_util_darcs x.happs_data_darcs x.bytestring x.containers
+                        x.random x.old_time x.old_locale x.unix x.directory x.binary ];
+                      src = fetchdarcs { url = "http://happs.org/repos/HAppS-State"; 
+                                         md5 = "956e5c293b60f4a98148fedc5fa38acc"; 
+                                       };
+                    };
+        happs_plugins_darcs = { name="HAppS-plugins-darcs"; p_deps=[ x.base x.mtl x.hslogger x.happs_util_darcs x.happs_data_darcs x.happs_state_darcs ];
+                    src = fetchdarcs { url = "http://happs.org/repos/HAppS-Util"; md5 = "693cb79017e522031c307ee5e59fc250"; };
+                    };
+        # there is no .cabal yet 
+        #happs_smtp_darcs = { name="HAppS-smtp-darcs"; p_deps=[];
+                    #src = fetchdarcs { url = "http://happs.org/repos/HAppS-smtp"; md5 = "5316917e271ea1ed8ad261080bcb47db"; };
+                    #};
+
+        happs_ixset_darcs = { name="HAppS-IxSet-darcs"; p_deps=[ x.base x.mtl
+                          x.hslogger x.happs_util_darcs x.happs_state_darcs x.happs_data_darcs
+                          x.template_haskell x.syb_with_class_darcs x.containers ];
+                    src = fetchdarcs { url = "http://happs.org/repos/HAppS-IxSet"; 
+                                       #md5 = "fa6b24517f09aa16e972f087430967fd"; 
+                                       #tag = "0.9.2";
+                                        # no tag
+                                       md5 = "fa6b24517f09aa16e972f087430967fd"; 
+                                     };
+                    };
+        happs_server_darcs = { name="HAppS-Server-darcs"; p_deps=[x.haxml x.parsec x.mtl
+                x.network x.regex_compat x.hslogger x.happs_data_darcs
+                  x.happs_util_darcs x.happs_state_darcs x.happs_ixset_darcs x.http_darcs
+                  x.template_haskell x.xhtml x.html x.bytestring x.random
+                  x.containers x.old_time x.old_locale x.directory x.unix];
+                    src = fetchdarcs { url = "http://happs.org/repos/HAppS-HTTP"; md5 = "e1bb17eb30a39d30b8c34dffbf80edc2"; };
+                    };
+        # we need recent version of cabal (because only this supports --pkg-config propably) Thu Feb  7 14:54:07 CET 2008
+        # is be added to buildInputs automatically
+        cabal_darcs = { name=cabal_darcs_name; p_deps = with ghc.core_libs; [base rts directory process pretty containers filepath];
+                  src = fetchdarcs { url = "http://darcs.haskell.org/cabal"; md5 = "8b0bc3c7f2676ce642f98b1568794cd6"; };
+                };
+      };
+      toDerivation = attrs : with attrs;
+      # result is { mtl = <deriv>;
+        annotatedGhcCabalDerivation ({
+            inherit name src;
+            propagatedBuildInputs = p_deps ++ (lib.optional (attrs.name != cabal_darcs_name) derivations.cabal_darcs );
+            srcDir = if attrs ? srcDir then attrs.srcDir else ".";
+            patches = if attrs ? patches then attrs.patches else [];
+            # add cabal, take deps either from this list or from ghc.core_libs 
+        }//( lib.subsetmap lib.id attrs [ "patchPhase" ] )) null;
+      derivations = with lib; builtins.listToAttrs (lib.concatLists ( lib.mapRecordFlatten 
+                ( n : attrs : let d = (toDerivation attrs); in [ (nv n d) (nv attrs.name d) ] ) pkgs ) );
+    }.derivations;
+
 
   # the wrappers basically does one thing: It defines GHC_PACKAGE_PATH before calling ghc{i,-pkg}
   # So you can have different wrappers with different library combinations
-  # So installing ghc libraries isn't done by nix-env -i package but by adding the lib to the libraries list below
+  # So installing ghc libraries isn't done by nix-env -i package but by adding
+  # the lib to the libraries list below
+  # Doesn't create that much useless symlinks (you seldomly want to read the
+  # .hi and .o files, right?
   ghcLibraryWrapper68 = 
     let ghc = ghcsAndLibs.ghc68.ghc; in
     createGhcWrapper rec {
       ghcPackagedLibs = true;
       name = "ghc${ghc.version}_wrapper";
       suffix = "${ghc.version}wrapper";
-      libraries = map ( a : __getAttr a ghcsAndLibs.ghc68.core_libs ) [ 
-            "old-locale-1.0.0.0" "old-time-1.0.0.0" "filepath-1.1.0.0" "directory-1.0.0.0" "array-0.1.0.0" "containers-0.1.0.1" 
-            "hpc-0.5.0.0" "bytestring-0.9.0.1" "pretty-1.0.0.0" "packedstring-0.1.0.0" "template-haskell-2.2.0.0" 
-            "unix-2.3.0.0" "process-1.0.0.0" "readline-1.0.1.0" "Cabal-1.2.3.0" "random-1.0.0.0" "haskell98-1.0.1.0" "ghc-${ghc.version}"
-            "array-0.1.0.0" "bytestring-0.9.0.1" "containers-0.1.0.1" "directory-1.0.0.0" "filepath-1.1.0.0"
-            "ghc-${ghc.version}" "haskell98-1.0.1.0" "hpc-0.5.0.0" "old-locale-1.0.0.0" "old-time-1.0.0.0" 
-            "packedstring-0.1.0.0" "pretty-1.0.0.0" "process-1.0.0.0" "random-1.0.0.0"
-            "readline-1.0.1.0" "rts-1.0" "unix-2.3.0.0" "base-3.0.1.0"
-          ] ++ map ( a : __getAttr a (ghc68_extra_libs ghcsAndLibs.ghc68 ) ) [
-            "mtl-1.1.0.0"
-          ];
-        # (flatten ghcsAndLibs.ghc68.core_libs);
+      libraries = # map ( a : __getAttr a (ghc68_extra_libs ghcsAndLibs.ghc68 ) ) [ "mtl" ];
+        # core_libs  distributed with this ghc version
+        #(lib.flattenAttrs ghcsAndLibs.ghc68.core_libs)
+          map ( a : __getAttr a ghcsAndLibs.ghc68.core_libs ) [ 
+            "cabal" "array" "base" "bytestring" "containers" "containers" "directory"
+            "filepath" "ghc-${ghc.version}" "haskell98" "hpc" "old_locale" "old_time"
+            "old_time" "packedstring" "pretty" "process" "random" "readline" "rts"
+            "template_haskell" "unix" "template_haskell" ]
+        # some extra libs
+
+           ++  (lib.flattenAttrs (ghc68_extra_libs ghcsAndLibs.ghc68) );
+        # or specify the ones you want to install using this list (possible values see attributes in ghc68_extra_libs
+           #++ map ( a : __getAttr a (ghc68_extra_libs ghcsAndLibs.ghc68 ) )
+           #[ "mtl" "parsec" "cabal_darcs" "haxml" "network" "regex_base"
+           #"regex_compat" "regex_posix" "stm" "hunit" "quickcheck" "crypto"
+           #"hslogger" "http_darcs" "syb_with_class_darcs"
+           #];
+        # some additional libs
       inherit ghc;
   };
 
@@ -1166,6 +1401,13 @@ rec {
       libraries = [];
     };
   */
+  
+  gwt = import ../development/compilers/gwt {
+    inherit stdenv fetchurl;
+    inherit (gtkLibs) glib gtk pango atk;
+    inherit (xlibs) libX11 libXt;
+    libstdcpp5 = gcc33.gcc;
+  };
 
   helium = import ../development/compilers/helium {
     inherit fetchurl stdenv;
@@ -1196,7 +1438,7 @@ rec {
     import ../development/compilers/jdk/default-5.nix {
       inherit fetchurl stdenv unzip;
     };
-
+  
   jdk       = jdkdistro true  false;
   jre       = jdkdistro false false;
 
@@ -1240,7 +1482,6 @@ rec {
 
   ocaml_alts = import ../development/compilers/ocaml {
     inherit fetchurl stdenv x11 ncurses;
-	stdenv34 = overrideGCC stdenv gcc34;
   };
 
 /*
@@ -1271,6 +1512,15 @@ rec {
     inherit fetchurl stdenv mk noweb groff;
   };
 
+  roadsend = import ../development/compilers/roadsend {
+    inherit fetchurl stdenv flex bison mkDerivationByConfiguration bigloo lib curl;
+    # optional features
+    # all features pcre, fcgi xml mysql, sqlite3, (not implemented: odbc gtk gtk2)
+    flags = ["pcre" "fcgi" "xml" "mysql"];
+    inherit mysql;
+    inherit libxml2;
+  };
+
   strategoLibraries = import ../development/compilers/strategoxt/libraries/stratego-libraries-0.17pre.nix {
     inherit stdenv fetchurl pkgconfig aterm;
   };
@@ -1338,17 +1588,17 @@ rec {
 
 
   clisp = import ../development/interpreters/clisp {
-    inherit fetchurl stdenv libsigsegv gettext
-      readline ncurses coreutils pcre zlib;
+    inherit fetchurl stdenv libsigsegv gettext 
+	readline ncurses coreutils pcre zlib;
     inherit (xlibs) libX11 libXau libXt;
   };
 
   erlang = selectVersion ../development/interpreters/erlang "R12B-1" {
-    inherit fetchurl perl gnum4 ncurses openssl stdenv;
+    inherit fetchurl stdenv perl gnum4 ncurses openssl;
   };
 
   guile = import ../development/interpreters/guile {
-    inherit fetchurl stdenv ncurses readline libtool gmp;
+    inherit fetchurl stdenv ncurses readline libtool gmp gawk makeWrapper;
   };
 
   kaffe =  import ../development/interpreters/kaffe {
@@ -1381,10 +1631,14 @@ rec {
   # tell the apache module where to look for this file is using a compile time flag ;-(
   # perhaps this can be done setting php_value in apache don't have time to investigate any further ?
   # This expression is a quick hack now. But perhaps it helps you adding the configuration flags you need?
-  php = (import ../development/interpreters/php_configurable) {
-   inherit mkDerivationByConfiguration stdenv mysql lib;
-   inherit fetchurl flex bison apacheHttpd; # gettext;
-   inherit libxml2 automake autoconf postgresql;
+  php = php_unstable;
+
+  # compiling without xdebug is currenlty broken (should be easy to fix though 
+  php_unstable = (import ../development/interpreters/php_configurable) {
+   inherit stdenv mkDerivationByConfiguration autoconf automake lib;
+   # optional features
+   inherit fetchurl flex bison apacheHttpd mysql libxml2; # gettext;
+   inherit zlib;
    flags = [ "xdebug" "mysql" "mysqli" "pdo_mysql" "libxml2" "apxs2" ];
   };
 
@@ -1457,6 +1711,10 @@ rec {
     inherit fetchurl stdenv unzip;
   };
 
+  guileLib = import ../development/guile-modules/guile-lib {
+    inherit fetchurl stdenv guile;
+  };
+
   windowssdk = import ../development/misc/windows-sdk {
     inherit fetchurl stdenv cabextract;
   };
@@ -1505,6 +1763,10 @@ rec {
     inherit fetchurl stdenv perl autoconf;
   };
 
+  automake110x = import ../development/tools/misc/automake/automake-1.10.x.nix {
+    inherit fetchurl stdenv perl autoconf;
+  };
+
   # commented out because it's using the new configuration style proposal which is unstable
   #avrdude = import ../development/tools/misc/avrdude {
   #  inherit lib fetchurl stdenv flex yacc;
@@ -1533,7 +1795,7 @@ rec {
     inherit fetchurl stdenv;
   };
 
-  cmake = (selectVersion ../development/tools/build-managers/cmake "2.4.8") {
+  cmake = import ../development/tools/build-managers/cmake {
     inherit fetchurl stdenv replace;
   };
 
@@ -1550,6 +1812,10 @@ rec {
 
   flex = flex254a;
 
+  flex2534 = import ../development/tools/parsing/flex/flex-2.5.34.nix {
+    inherit fetchurl stdenv yacc m4;
+  };
+
   flex2533 = import ../development/tools/parsing/flex/flex-2.5.33.nix {
     inherit fetchurl stdenv yacc m4;
   };
@@ -1585,6 +1851,10 @@ rec {
     inherit cabal;
   };
 
+  guileLint = import ../development/tools/guile/guile-lint {
+    inherit fetchurl stdenv guile;
+  };
+
   # happy = import ../development/tools/parsing/happy {
   #   inherit fetchurl stdenv perl ghc;
   # };
@@ -1593,6 +1863,11 @@ rec {
     inherit cabal perl;
   };
 
+  hasktags = import ../development/tools/misc/hasktags {
+    inherit fetchurl stdenv;
+    ghc = ghcsAndLibs.ghc68.ghc;
+  };
+
   help2man = import ../development/tools/misc/help2man {
     inherit fetchurl stdenv perl gettext perlLocaleGettext;
   };
@@ -1907,9 +2182,13 @@ rec {
   };
 
   facile = import ../development/libraries/facile {
-	  inherit fetchurl stdenv;
-      # Actually, we don't need this version but we need native-code compilation
-	  ocaml = builtins.getAttr "3.10.0" ocaml_alts;
+    inherit fetchurl stdenv;
+    # Actually, we don't need this version but we need native-code compilation
+    ocaml = builtins.getAttr "3.10.0" ocaml_alts;
+  };
+
+  fcgi = import ../development/libraries/fcgi {
+      inherit fetchurl stdenv;
   };
 
   ffmpeg = import ../development/libraries/ffmpeg {
@@ -1917,14 +2196,13 @@ rec {
   };
 
   ffmpeg_svn = import ../development/libraries/ffmpeg_svn_snapshot {
-    inherit fetchurl stdenv a52dec libtheora x11 lame zlib SDL;
+    inherit fetchurl stdenv;
   };
 
   fftw = import ../development/libraries/fftw {
     inherit fetchurl stdenv builderDefs stringsWithDeps;
   };
 
-
   fltk20 = (import ../development/libraries/fltk) {
     inherit mkDerivationByConfiguration x11 lib;
     inherit fetchurl stdenv mesa mesaHeaders libpng libjpeg zlib ;
@@ -1970,7 +2248,7 @@ rec {
     # python / ruby support
   };
 
-  gettextFun = lib.sumArgs (selectVersion ../development/libraries/gettext "0.17") {
+  gettextFun = lib.sumArgs (selectVersion ../development/libraries/gettext "0.16.x") {
     inherit fetchurl stdenv;
   };
 
@@ -2013,16 +2291,6 @@ rec {
     inherit fetchurl stdenv gmp;
   };
 
-  gst_all = import ../development/libraries/gstreamer {
-    inherit lib selectVersion stdenv fetchurl perl bison flex pkgconfig libxml2
-      python alsaLib cdparanoia libogg libvorbis libtheora freetype liboil
-      libjpeg zlib speex libpng libdv aalib cairo libcaca flac hal libiec61883
-      dbus libavc1394 ladspaH taglib;
-    inherit (xorg) libX11 libXv libXext;
-    inherit (gtkLibs) glib pango gtk;
-    inherit (gnome) gnomevfs;
-  };
-
   gnet = import ../development/libraries/gnet {
     inherit fetchurl stdenv pkgconfig;
     inherit (gtkLibs) glib;
@@ -2033,8 +2301,8 @@ rec {
   };
 
   gpgme = import ../development/libraries/gpgme {
-    inherit fetchurl stdenv libgpgerror pkgconfig pth gnupg;
-    inherit (gtkLibs) glib;
+    inherit fetchurl stdenv libgpgerror pkgconfig pth gnupg gnupg2;
+	inherit (gtkLibs) glib;
   };
 
   # gnu scientific library
@@ -2161,6 +2429,10 @@ rec {
     inherit fetchurl stdenv;
   };
 
+  libao = import ../development/libraries/libao {
+    inherit stdenv fetchurl pkgconfig;
+  };
+
   libarchive = selectVersion ../development/libraries/libarchive "2.4.12" {
     inherit fetchurl stdenv zlib bzip2 e2fsprogs sharutils;
   };
@@ -2201,12 +2473,12 @@ rec {
   };
 
   libdbiDrivers = libdbiDriversFun {
-    inherit sqlite mysql;
+    mysql = mysql5;
+    inherit sqlite;
   } null;
 
   libdv = import ../development/libraries/libdv {
-    inherit fetchurl stdenv lib mkDerivationByConfiguration SDL popt pkgconfig;
-    inherit (xorg) libXv libX11;
+    inherit fetchurl stdenv lib mkDerivationByConfiguration;
   };
 
   libdrm = import ../development/libraries/libdrm {
@@ -2230,7 +2502,7 @@ rec {
   };
 
   libexif = import ../development/libraries/libexif {
-    inherit fetchurl stdenv;
+    inherit fetchurl stdenv gettext;
   };
 
   libextractorFun = lib.sumArgs (selectVersion ../development/libraries/libextractor "0.5.18")
@@ -2240,13 +2512,6 @@ rec {
 
   libextractor = libextractorFun null;
 
-  libeXosip2Fun = lib.sumArgs
-    (selectVersion ../development/libraries/libeXosip2 "3.0.3") {
-    inherit fetchurl stdenv libosip2;
-  };
-
-  libeXosip2 = libeXosip2Fun null;
-
   libgcrypt = import ../development/libraries/libgcrypt {
     inherit fetchurl stdenv libgpgerror;
   };
@@ -2270,6 +2535,10 @@ rec {
     inherit (gnome) glib gnomevfs libbonobo;
   };
 
+  libid3tag = import ../development/libraries/libid3tag {
+    inherit fetchurl stdenv zlib;
+  };
+
   libidn = import ../development/libraries/libidn {
 	  inherit fetchurl stdenv;
   };
@@ -2278,6 +2547,10 @@ rec {
     inherit fetchurl stdenv pkgconfig libraw1394;
   };
 
+  libjingle = selectVersion ../development/libraries/libjingle "0.3.11" {
+    inherit fetchurl stdenv mediastreamer;
+  };
+
   libjpeg = import ../development/libraries/libjpeg {
     inherit fetchurl stdenv libtool;
   };
@@ -2311,20 +2584,10 @@ rec {
     inherit fetchurl stdenv;
   };
 
-  liboilFun = lib.sumArgs
-    (selectVersion ../development/libraries/liboil "0.3.12") {
-    inherit fetchurl stdenv pkgconfig;
-  };
-
-  liboil = liboilFun null;
-
-  libosip2Fun = lib.sumArgs
-    (selectVersion ../development/libraries/libosip2 "3.0.3-2") {
+  liboop = import ../development/libraries/liboop {
     inherit fetchurl stdenv;
   };
 
-  libosip2 = libosip2Fun null;
-
   libotr = import ../development/libraries/libotr {
     inherit fetchurl stdenv libgcrypt;
   };
@@ -2479,11 +2742,11 @@ rec {
     inherit fetchurl stdenv mysql libtool zlib unixODBC;
   };
 
-  ncursesFun = lib.sumArgs (selectVersion ../development/libraries/ncurses "5.6") {
+  ncursesFun = lib.sumArgs (import ../development/libraries/ncurses) {
     inherit fetchurl stdenv;
     unicode = (system != "i686-cygwin");
   };
-
+  
   ncurses = ncursesFun null;
 
   ncursesDiet = import ../development/libraries/ncurses-diet {
@@ -2552,6 +2815,7 @@ rec {
   pcre = import ../development/libraries/pcre {
     inherit fetchurl stdenv;
     unicodeSupport = getConfig ["pcre" "unicode"] false;
+    cplusplusSupport = !stdenv ? isDietLibC;
   };
 
   poppler = import ../development/libraries/poppler {
@@ -2586,8 +2850,8 @@ rec {
 
   qt4 = getVersion "qt4" qt4_alts;
   qt4_alts = import ../development/libraries/qt-4 {
-	inherit fetchurl fetchsvn zlib libjpeg libpng which mysql mesa openssl cups dbus
-	  fontconfig freetype pkgconfig libtiff stdenv;
+    inherit fetchurl stdenv fetchsvn zlib libjpeg libpng which mysql mesa openssl cups dbus
+	  fontconfig freetype pkgconfig libtiff;
     inherit (xlibs) xextproto libXft libXrender libXrandr randrproto
 	  libXmu libXinerama xineramaproto libXcursor libICE libSM libX11 libXext
 	  inputproto fixesproto libXfixes;
@@ -2649,8 +2913,8 @@ rec {
     inherit fetchurl stdenv libogg;
   };
 
-  sqlite = selectVersion ../development/libraries/sqlite "3.5.6" {
-    inherit fetchurl stdenv readline;
+  sqlite = import ../development/libraries/sqlite {
+    inherit fetchurl stdenv;
   };
 
   t1lib = import ../development/libraries/t1lib {
@@ -2664,7 +2928,7 @@ rec {
 
   tapioca_qt = import ../development/libraries/tapioca-qt {
     inherit fetchsvn stdenv cmake telepathy_qt;
-    qt = qt4;
+	qt = qt4;
   };
 
   telepathy_gabble = import ../development/libraries/telepathy-gabble {
@@ -2922,6 +3186,14 @@ rec {
     inherit fetchurl perl;
   };
 
+  perlCryptPasswordMD5 = import ../development/perl-modules/generic perl {
+    name = "Crypt-PasswdMD5-1.3";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/L/LU/LUISMUNOZ/Crypt-PasswdMD5-1.3.tar.gz;
+      sha256 = "13j0v6ihgx80q8jhyas4k48b64gnzf202qajyn097vj8v48khk54";
+    };
+  };
+
   perlDateManip = import ../development/perl-modules/generic perl {
     name = "DateManip-5.42a";
     src = fetchurl {
@@ -2930,6 +3202,10 @@ rec {
     };
   };
 
+  perlDBFile = import ../development/perl-modules/DB_File {
+    inherit fetchurl perl db4;
+  };
+
   perlDigestSHA1 = import ../development/perl-modules/generic perl {
     name = "Digest-SHA1-2.11";
     src = fetchurl {
@@ -3024,6 +3300,14 @@ rec {
     };
   };
 
+  perlStringMkPasswd = import ../development/perl-modules/generic perl {
+    name = "String-MkPasswd-0.02";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/C/CG/CGRAU/String-MkPasswd-0.02.tar.gz;
+      sha256 = "0si4xfgf8c2pfag1cqbr9jbyvg3hak6wkmny56kn2qwa4ljp9bk6";
+    };
+  };
+
   perlTermReadKey = import ../development/perl-modules/generic perl {
     name = "TermReadKey-2.30";
     src = fetchurl {
@@ -3230,13 +3514,13 @@ rec {
     inherit fetchurl stdenv apacheHttpd jdk;
   };
 
-  mysql4 = import ../servers/sql/mysql {
+  mysql = import ../servers/sql/mysql {
     inherit fetchurl stdenv ncurses zlib perl;
     ps = procps; /* !!! Linux only */
   };
 
-  mysql = import ../servers/sql/mysql5 {
-    inherit fetchurl stdenv ncurses zlib perl;
+  mysql5 = import ../servers/sql/mysql5 {
+    inherit fetchurl stdenv ncurses zlib perl openssl;
     ps = procps; /* !!! Linux only */
   };
 
@@ -3298,7 +3582,7 @@ rec {
   # this creates a patch which can be applied to the kernel to integrate this module..
   kernel_module_acerhk = import ../os-specific/linux/kernel/acerhk {
     inherit fetchurl stdenv gnupatch;
-    kernel = builtins.getAttr "2.6.21" kernel_alts;
+    kernel = kernel_2_6_21;
     debug = true;
   };
 
@@ -3312,16 +3596,10 @@ rec {
   };
   */
 
-  alsaFun = lib.sumArgs (selectVersion ../os-specific/linux/alsa "1.0.16") {
-    inherit fetchurl stdenv ncurses gettext;
+  alsaLib = import ../os-specific/linux/alsa/library {
+    inherit fetchurl stdenv;
   };
 
-  alsa = alsaFun null;
-
-  alsaLib = alsa.alsaLib;
-
-  alsaUtils = alsa.alsaUtils;
-
   atherosFun = lib.sumArgs (selectVersion ../os-specific/linux/atheros "r3122") {
     inherit fetchurl stdenv builderDefs;
   };
@@ -3338,6 +3616,10 @@ rec {
     inherit fetchurl stdenv autoconf automake;
   };
 
+  alsaUtils = import ../os-specific/linux/alsa/utils {
+    inherit fetchurl stdenv alsaLib ncurses gettext;
+  };
+
   cramfsswap = import ../os-specific/linux/cramfsswap {
     inherit fetchurl stdenv zlib;
   };
@@ -3435,12 +3717,10 @@ rec {
     kernelHeaders = stdenv.gcc.libc.kernelHeaders;
   };
 
-  iptablesFun = lib.sumArgs (selectVersion ../os-specific/linux/iptables "1.4.0") {
-    inherit builderDefs kernelHeaders;
+  iptables = import ../os-specific/linux/iptables {
+    inherit fetchurl stdenv;
   };
 
-  iptables = iptablesFun null;
-
   ipw2200fw = import ../os-specific/linux/firmware/ipw2200 {
     inherit fetchurl stdenv;
   };
@@ -3453,6 +3733,10 @@ rec {
     inherit fetchurl stdenv;
   };
 
+  iwlwifi4965ucode = import ../os-specific/linux/firmware/iwlwifi-4965-ucode {
+    inherit fetchurl stdenv;
+  };
+
   kbd = import ../os-specific/linux/kbd {
     inherit fetchurl stdenv bison flex;
   };
@@ -3487,18 +3771,195 @@ rec {
     modules = [];
   };
 
-  systemKernel = kernel;
+  kernel = kernel_2_6_23;
+
+  systemKernel = (if (getConfig ["kernel" "version"] "2.6.21") == "2.6.22" then
+	kernel_2_6_22 else if (getConfig ["kernel" "version"] "2.6.21") == "2.6.23" then
+	kernel_2_6_23 else kernel);
+
+  kernel_2_6_20 = import ../os-specific/linux/kernel/linux-2.6.20.nix {
+    inherit fetchurl stdenv perl mktemp module_init_tools;
+    kernelPatches = [
+      { name = "paravirt-nvidia";
+        patch = ../os-specific/linux/kernel/2.6.20-paravirt-nvidia.patch;
+      }
+      { name = "skas-2.6.20-v9-pre9";
+        patch = fetchurl {
+          url = http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/skas-2.6.20-v9-pre9/skas-2.6.20-v9-pre9.patch.bz2;
+          md5 = "02e619e5b3aaf0f9768f03ac42753e74";
+        };
+        extraConfig =
+          "CONFIG_PROC_MM=y\n" +
+          "# CONFIG_PROC_MM_DUMPABLE is not set\n";
+      }
+      { name = "fbsplash-0.9.2-r5-2.6.20-rc6";
+        patch = fetchurl {
+          url = http://dev.gentoo.org/~spock/projects/gensplash/archive/fbsplash-0.9.2-r5-2.6.20-rc6.patch;
+          sha256 = "11v4f85f4jnh9sbhqcyn47krb7l1czgzjw3w8wgbq14jm0sp9294";
+        };
+        extraConfig = "CONFIG_FB_SPLASH=y";
+      }
+    ];
+  };
+
+  kernel_2_6_21 = import ../os-specific/linux/kernel/linux-2.6.21.nix {
+    inherit fetchurl stdenv perl mktemp module_init_tools;
+    kernelPatches = [
+      { name = "ext3cow";
+        patch = ../os-specific/linux/kernel/linux-2.6.21.7-ext3cow_wouter.patch;
+        extraConfig =  
+	"CONFIG_EXT3COW_FS=m\n" +
+	"CONFIG_EXT3COW_FS_XATTR=y\n" +
+	"CONFIG_EXT3COW_FS_POSIX_ACL=y\n" +
+	"CONFIG_EXT3COW_FS_SECURITY=y\n";
+      }
+      /* commented out because only acer users have need for it.. 
+         It takes quite a while to create the patch when unpacking the kernel sources only for that task
+      { name = "acerhk";
+        patch = kernel_module_acerhk + "/acerhk-patch.tar.bz2" ;
+        extraConfig =  
+	"CONFIG_ACERHK=m\n";
+      }
+      */
+      { name = "paravirt-nvidia";
+        patch = ../os-specific/linux/kernel/2.6.20-paravirt-nvidia.patch;
+      }
+      { name = "skas-2.6.20-v9-pre9";
+        patch = fetchurl {
+          url = http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/skas-2.6.20-v9-pre9/skas-2.6.20-v9-pre9.patch.bz2;
+          md5 = "02e619e5b3aaf0f9768f03ac42753e74";
+        };
+        extraConfig =
+          "CONFIG_PROC_MM=y\n" +
+          "# CONFIG_PROC_MM_DUMPABLE is not set\n";
+      }
+      { name = "fbsplash-0.9.2-r5-2.6.21";
+        patch = fetchurl {
+          url = http://dev.gentoo.org/~dsd/genpatches/trunk/2.6.21/4200_fbsplash-0.9.2-r5.patch;
+          sha256 = "00s8074fzsly2zpir885zqkvq267qyzg6vhsn7n1z2v1z78avxd8";
+        };
+        extraConfig = "CONFIG_FB_SPLASH=y";
+      }
+    ];
+  };
+
+  kernel_2_6_22 = import ../os-specific/linux/kernel/linux-2.6.22.nix {
+    inherit fetchurl stdenv perl mktemp module_init_tools;
+    kernelPatches = [
+      /*
+      { name = "ext3cow";
+        patch = ../os-specific/linux/kernel/linux-2.6.21.7-ext3cow_wouter.patch;
+        extraConfig =
+        "CONFIG_EXT3COW_FS=m\n" +
+        "CONFIG_EXT3COW_FS_XATTR=y\n" +
+        "CONFIG_EXT3COW_FS_POSIX_ACL=y\n" +
+        "CONFIG_EXT3COW_FS_SECURITY=y\n";
+      }
+      */
+      /*
+      { name = "skas-2.6.20-v9-pre9";
+        patch = fetchurl {
+          url = http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/skas-2.6.20-v9-pre9/skas-2.6.20-v9-pre9.patch.bz2;
+          md5 = "02e619e5b3aaf0f9768f03ac42753e74";
+        };
+        extraConfig =
+          "CONFIG_PROC_MM=y\n" +
+          "# CONFIG_PROC_MM_DUMPABLE is not set\n";
+      }
+      */
+      { name = "fbsplash-0.9.2-r5-2.6.21";
+        patch = fetchurl {
+          url = http://dev.gentoo.org/~dsd/genpatches/trunk/2.6.22/4200_fbsplash-0.9.2-r5.patch;
+          sha256 = "0822wwlf2dqsap5qslnnp0yl1nbvvvb76l73w2dd8zsyn0bqg3px";
+        };
+        extraConfig = "CONFIG_FB_SPLASH=y";
+      }
+    ];
+    extraConfig =
+      lib.optional (getConfig ["kernel" "no_hz"] false) "CONFIG_NO_HZ=y" ++
+      lib.optional (getConfig ["kernel" "timer_stats"] false) "CONFIG_TIMER_STATS=y" ++
+      lib.optional (getConfig ["kernel" "usb_suspend"] false) "CONFIG_USB_SUSPEND=y" ++
+      lib.optional (getConfig ["kernel" "no_irqbalance"] false) "# CONFIG_IRQBALANCE is not set" ++
+      [(getConfig ["kernel" "addConfig"] "")];
+  };
 
-  kernel = getVersion "kernel" kernel_alts;
+  kernel_2_6_21_ck = import ../os-specific/linux/kernel/linux-2.6.21_ck.nix {
+    inherit fetchurl stdenv perl mktemp module_init_tools;
+    kernelPatches = [
+      { name = "ext3cow";
+        patch = ../os-specific/linux/kernel/linux-2.6.21.7-ext3cow_wouter.patch;
+        extraConfig =
+        "CONFIG_EXT3COW_FS=m\n" +
+        "CONFIG_EXT3COW_FS_XATTR=y\n" +
+        "CONFIG_EXT3COW_FS_POSIX_ACL=y\n" +
+        "CONFIG_EXT3COW_FS_SECURITY=y\n";
+      }
+      { name = "Con Kolivas Patch";
+        patch = ../os-specific/linux/kernel/patch-2.6.21-ck1;
+      }
+      { name = "paravirt-nvidia";
+        patch = ../os-specific/linux/kernel/2.6.20-paravirt-nvidia.patch;
+      }
+      { name = "skas-2.6.20-v9-pre9";
+        patch = fetchurl {
+          url = http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/skas-2.6.20-v9-pre9/skas-2.6.20-v9-pre9.patch.bz2;
+          md5 = "02e619e5b3aaf0f9768f03ac42753e74";
+        };
+        extraConfig =
+          "CONFIG_PROC_MM=y\n" +
+          "# CONFIG_PROC_MM_DUMPABLE is not set\n";
+      }
+      { name = "fbsplash-0.9.2-r5-2.6.21";
+        patch = fetchurl {
+          url = http://dev.gentoo.org/~dsd/genpatches/trunk/2.6.21/4200_fbsplash-0.9.2-r5.patch;
+          sha256 = "00s8074fzsly2zpir885zqkvq267qyzg6vhsn7n1z2v1z78avxd8";
+        };
+        extraConfig = "CONFIG_FB_SPLASH=y";
+      }
+    ];
+  };
 
-  kernel_alts = import ../os-specific/linux/kernel {
+  kernel_2_6_23 = import ../os-specific/linux/kernel/linux-2.6.23.nix {
     inherit fetchurl stdenv perl mktemp module_init_tools;
-    extraPatches = getConfig ["kernel" "extraPatches"] [];
+    kernelPatches = [
+      /*
+      { # resume with resume=swap:/dev/xx
+        name = "tux on ice"; # (swsusp2)
+        patch = fetchurl {
+          url = "http://www.tuxonice.net/downloads/all/tuxonice-3.0-rc5-for-2.6.23.14.patch.bz2";
+          sha256 = "187190rxbn9x1c6bwv59mwy1zhff8nn5ad58cfiz23wa5wrk4mif";
+        };
+        extraConfig = "
+          CONFIG_SUSPEND2=y
+          CONFIG_SUSPEND2_FILE=y
+          CONFIG_SUSPEND2_SWAP=y
+          CONFIG_CRYPTO_LZF=y
+        ";
+      }
+      */
+      { name = "fbsplash-0.9.2-r5-2.6.21";
+        patch = fetchurl {
+          url = http://dev.gentoo.org/~dsd/genpatches/trunk/2.6.22/4200_fbsplash-0.9.2-r5.patch;
+          sha256 = "0822wwlf2dqsap5qslnnp0yl1nbvvvb76l73w2dd8zsyn0bqg3px";
+        };
+        extraConfig = "CONFIG_FB_SPLASH=y";
+      }
+      /* !!! Not needed anymore for the NixOS LiveCD - we have AUFS. */
+      { name = "unionfs-2.2.2";
+        patch = fetchurl {
+          url = http://download.filesystems.org/unionfs/unionfs-2.x/unionfs-2.2.2_for_2.6.23.13.diff.gz;
+          sha256 = "104hahp6fjpxwprcl2njw5mimyh442ma3cp5r1ww0mzq3vwrcdyz";
+        };
+        extraConfig = ''
+          CONFIG_UNION_FS=m
+          CONFIG_UNION_FS_XATTR=y
+        '';
+      }
+    ];
     extraConfig =
       lib.optional (getConfig ["kernel" "timer_stats"] false) "CONFIG_TIMER_STATS=y" ++
       lib.optional (getConfig ["kernel" "no_irqbalance"] false) "# CONFIG_IRQBALANCE is not set" ++
       [(getConfig ["kernel" "addConfig"] "")];
-	configFile = getConfig ["kernel" "configFile"] null;
   };
 
   kqemuFun = lib.sumArgs (selectVersion ../os-specific/linux/kqemu "1.3.0pre11") {
@@ -3518,6 +3979,7 @@ rec {
     inherit fetchurl stdenv;
   };
 
+ 
   libsexy = import ../development/libraries/libsexy {
     inherit stdenv fetchurl pkgconfig libxml2;
     inherit (gtkLibs) glib gtk pango;
@@ -3540,7 +4002,8 @@ rec {
   };
 
   klibc = import ../os-specific/linux/klibc {
-    inherit fetchurl stdenv perl bison mktemp kernel;
+    inherit fetchurl stdenv perl bison mktemp;
+	kernel = systemKernel;
   };
 
   kvm = kvm57;
@@ -3754,10 +4217,10 @@ rec {
     inherit fetchurl stdenv;
   };
 
-  uml = (import ../os-specific/linux/kernel {
+  uml = import ../os-specific/linux/kernel/linux-2.6.20.nix {
     inherit fetchurl stdenv perl mktemp module_init_tools;
     userModeLinux = true;
-  }).default;
+  };
 
   umlutilities = import ../os-specific/linux/uml-utilities {
     inherit fetchurl kernelHeaders stdenv;
@@ -3809,6 +4272,9 @@ rec {
     inherit stdenv xlibs expat libdrm;
   };
 
+  zd1211fw = import ../os-specific/linux/firmware/zd1211 {
+    inherit stdenv fetchurl;
+  };
 
   ### DATA
 
@@ -3934,6 +4400,12 @@ rec {
     inherit builderDefs stringsWithDeps;
   };
 
+  aumix = import ../applications/audio/aumix {
+    inherit fetchurl stdenv ncurses pkgconfig gettext;
+    inherit (gtkLibs) gtk;
+    gtkGUI = false;
+  };
+
   batik = import ../applications/graphics/batik {
     inherit fetchurl stdenv unzip;
   };
@@ -3942,6 +4414,11 @@ rec {
     inherit fetchurl stdenv python makeWrapper;
   };
 
+  bitlbee = import ../applications/networking/instant-messengers/bitlbee {
+    inherit fetchurl stdenv gnutls pkgconfig;
+    inherit (gtkLibs) glib;
+  };
+
   # commented out because it's using the new configuration style proposal which is unstable
   #biew = import ../applications/misc/biew {
   #  inherit lib stdenv fetchurl ncurses;
@@ -3953,9 +4430,10 @@ rec {
     inherit fetchurl stdenv;
     openal = openalSoft;
   };
+
   blender = import ../applications/misc/blender {
-    inherit cmake mesa gettext freetype SDL libtiff fetchurl glibc scons x11 lib
-      libjpeg libpng zlib stdenv /* smpeg  sdl */;
+    inherit stdenv cmake mesa gettext freetype SDL libtiff fetchurl glibc scons x11 lib
+      libjpeg libpng zlib /* smpeg  sdl */;
     inherit (xlibs) inputproto libXi;
     python = builtins.getAttr "2.5" python_alts;
     freealut = freealut_soft;
@@ -3981,8 +4459,6 @@ rec {
     inherit fetchurl stdenv ncurses;
   };
 
-  cdparanoia = cdparanoiaIII;
-
   cdparanoiaIII = import ../applications/audio/cdparanoia {
     inherit fetchurl stdenv;
   };
@@ -4067,6 +4543,10 @@ rec {
     inherit (gtkLibs) gtk;
   };
 
+  bbdb = import ../applications/editors/emacs-modes/bbdb {
+    inherit fetchurl stdenv emacs texinfo ctags;
+  };
+
   cua = import ../applications/editors/emacs-modes/cua {
     inherit fetchurl stdenv;
   };
@@ -4089,6 +4569,12 @@ rec {
     ghc = ghc661;
   };
 
+  # some speed bottle necks are resolved in this version I think .. perhaps you like to try it? 
+  darcs_2_pre = import ../applications/version-management/darcs_2_pre.nix {
+    inherit fetchurl stdenv zlib ncurses curl;
+    ghc = ghc661;
+  };
+
   dia = import ../applications/graphics/dia {
     inherit stdenv fetchurl pkgconfig perl perlXMLParser 
 	libxml2 gettext python libxml2Python docbook5 docbook_xsl 
@@ -4173,7 +4659,7 @@ rec {
   fbpanel = fbpanelFun null;
 
   fetchmail = import ../applications/misc/fetchmail {
-    inherit stdenv fetchurl openssl python procmail;
+    inherit stdenv fetchurl;
   };
 
   wireshark = import ../applications/networking/sniffers/wireshark {
@@ -4204,25 +4690,7 @@ rec {
     #enableOfficialBranding = true;
   });
 
-  firefox3b1 = lowPrio (import ../applications/networking/browsers/firefox3b1 {
-    inherit fetchurl stdenv pkgconfig perl zip libjpeg libpng zlib cairo
-    	python curl coreutils;
-    inherit (gtkLibs) gtk;
-    inherit (gnome) libIDL;
-    inherit (xlibs) libXi;
-    #enableOfficialBranding = true;
-  });
-
-  firefox3b2 = lowPrio (import ../applications/networking/browsers/firefox3b1/3b2.nix {
-    inherit fetchurl stdenv pkgconfig perl zip libjpeg libpng zlib cairo
-    python curl coreutils dbus dbus_glib freetype fontconfig;
-    inherit (gtkLibs) gtk pango;
-    inherit (gnome) libIDL;
-    inherit (xlibs) libXi libX11 libXrender libXft libXt;
-    #enableOfficialBranding = true;
-  });
-
-  firefox3b1Bin = lowPrio (import ../applications/networking/browsers/firefox3b1/binary.nix {
+  firefox3b1Bin = lowPrio (import ../applications/networking/browsers/firefox-3/binary.nix {
     inherit fetchurl stdenv pkgconfig perl zip libjpeg libpng zlib cairo
     	python curl coreutils freetype fontconfig;
     inherit (gtkLibs) gtk atk pango glib;
@@ -4230,7 +4698,7 @@ rec {
     inherit (xlibs) libXi libX11 libXrender libXft libXt;
   });
 
-  firefox3b1Wrapper = lowPrio (wrapFirefox firefox3b1 "");
+  firefox3Wrapper = lowPrio (wrapFirefox firefox3 "");
   firefox3b1BinWrapper = lowPrio (wrapFirefox firefox3b1Bin "");
  
   flacAlts = import ../applications/audio/flac {
@@ -4268,9 +4736,7 @@ rec {
   };
 
   pidgin = import ../applications/networking/instant-messengers/pidgin {
-    inherit fetchurl stdenv pkgconfig perl perlXMLParser libxml2 openssl nss
-      gtkspell aspell gettext ncurses;
-    GStreamer = gst_all.gstreamer;
+    inherit fetchurl stdenv pkgconfig perl perlXMLParser libxml2 openssl nss gtkspell GStreamer aspell gettext ncurses;
     inherit (gtkLibs) gtk;
     inherit (gnome) startupnotification;
     inherit (xlibs) libXScrnSaver;
@@ -4294,12 +4760,18 @@ rec {
   };
 
   git = import ../applications/version-management/git {
-    inherit fetchurl stdenv curl openssl zlib expat perl;
+    inherit fetchurl stdenv curl openssl zlib expat perl gettext emacs;
+  };
+
+  gkrellm = import ../applications/misc/gkrellm {
+    inherit fetchurl stdenv gettext pkgconfig;
+    inherit (gtkLibs) glib gtk;
+    inherit (xlibs) libX11 libICE libSM;
   };
 
   gnash = assert mesaSupported; import ../applications/video/gnash {
-    inherit fetchurl stdenv SDL SDL_mixer libogg libxml2 libjpeg mesa libpng;
-    GStreamer = gst_all.gstreamer;
+    inherit fetchurl stdenv SDL SDL_mixer GStreamer
+            libogg libxml2 libjpeg mesa libpng;
     inherit (xlibs) libX11 libXext libXi libXmu;
   };
 
@@ -4318,6 +4790,11 @@ rec {
     inherit (gtkLibs) gtk;
   };
 
+  GStreamer = import ../applications/audio/GStreamer {
+    inherit fetchurl stdenv perl bison flex pkgconfig libxml2;
+    inherit (gtkLibs) glib;
+  };
+
   gv = import ../applications/misc/gv {
     inherit fetchurl stdenv Xaw3d ghostscriptX;
   };
@@ -4374,7 +4851,7 @@ rec {
   };
 
   jedit = import ../applications/jedit {
-    inherit fetchurl ant stdenv;
+    inherit fetchurl stdenv ant;
   };
 
   joe = import ../applications/editors/joe {
@@ -4382,15 +4859,14 @@ rec {
   };
 
   kino = import ../applications/video/kino {
-    inherit fetchurl pkgconfig libxml2 perl perlXMLParser stdenv
+    inherit fetchurl stdenv pkgconfig libxml2 perl perlXMLParser 
       libdv libraw1394 libavc1394 libiec61883 x11 gettext cairo; /* libavformat */
     inherit libsamplerate ffmpeg;
     inherit (gnome) libglade gtk glib;
     inherit (xlibs) libXv libX11;
     inherit (gtkLibs) pango;
-
-  # #  optional
-  #  inherit ffmpeg2theora sox, vorbis-tools lame mjpegtools dvdauthor 'Q'dvdauthor growisofs mencoder;
+    # #  optional
+    #  inherit ffmpeg2theora sox, vorbis-tools lame mjpegtools dvdauthor 'Q'dvdauthor growisofs mencoder;
   };
 
   kuickshow = import ../applications/graphics/kuickshow {
@@ -4400,7 +4876,7 @@ rec {
   };
 
   lame = import ../applications/audio/lame {
-    inherit fetchurl stdenv ;
+    inherit fetchurl stdenv;
   };
 
   ladspaH = import ../applications/audio/ladspa-plugins/ladspah.nix {
@@ -4452,6 +4928,10 @@ rec {
     inherit (xlibs) libXi;
   };
 
+  mpg321 = import ../applications/audio/mpg321 {
+    inherit stdenv fetchurl libao libmad libid3tag zlib;
+  };
+
   MPlayer = import ../applications/video/MPlayer {
     inherit fetchurl stdenv freetype x11 zlib libtheora libcaca freefont_ttf libdvdnav;
     inherit (xlibs) libX11 libXv libXinerama libXrandr;
@@ -4621,7 +5101,7 @@ rec {
 
   # = urxvt
   rxvt_unicode = import ../applications/misc/rxvt_unicode {
-    inherit lib fetchurl stdenv perl;
+    inherit lib fetchurl stdenv;
     inherit (xlibs) libXt libX11 libXft;
   };
 
@@ -4736,6 +5216,10 @@ rec {
     inherit fetchurl stdenv alsaLib;
   };
 
+  tla = import ../applications/version-management/arch {
+    inherit fetchurl stdenv diffutils gnutar gnupatch which;
+  };
+
   unison = import ../applications/networking/sync/unison {
     inherit fetchurl stdenv ocaml lablgtk makeWrapper;
     inherit (xorg) xset fontschumachermisc;
@@ -4800,6 +5284,11 @@ rec {
     alsa = alsaLib;
   };
 
+  vorbisTools = import ../applications/audio/vorbis-tools {
+    inherit fetchurl stdenv libogg libvorbis libao pkgconfig curl glibc
+    	    speex flac;
+  };
+
   w3m = import ../applications/networking/browsers/w3m {
     inherit fetchurl stdenv ncurses openssl boehmgc gettext zlib;
     graphicsSupport = false;
@@ -4821,6 +5310,10 @@ rec {
     includeUnpack = getConfig ["stdenv" "includeUnpack"] false;
   };
 
+  wordnet = import ../applications/misc/wordnet {
+    inherit stdenv fetchurl tcl tk x11 makeWrapper;
+  };
+
   wrapFirefox = firefox: nameSuffix: import ../applications/networking/browsers/firefox-wrapper {
     inherit stdenv firefox nameSuffix;
     plugins = []
@@ -4831,15 +5324,6 @@ rec {
     ++ lib.optional (supportsJDK && getConfig ["firefox" "jre"] true && jrePlugin ? mozillaPlugin) jrePlugin;
   };
 
-  x11vncFun = lib.sumArgs (selectVersion ../tools/X11/x11vnc "0.9.3") {
-    inherit builderDefs openssl zlib libjpeg ;
-    inherit (xlibs) libXfixes fixesproto libXdamage damageproto 
-      libX11 xproto libXtst libXinerama xineramaproto libXrandr randrproto
-      libXext xextproto inputproto recordproto;
-  };
-
-  x11vnc = x11vncFun null;
-
   xara = import ../applications/graphics/xara {
     inherit fetchurl stdenv autoconf automake libtool gettext cvs wxGTK
       pkgconfig libxml2 zip libpng libjpeg shebangfix perl freetype;
@@ -4902,8 +5386,8 @@ rec {
   } null;
 
   xterm = import ../applications/misc/xterm {
-    inherit fetchurl stdenv ncurses freetype pkgconfig;
-    inherit (xlibs) libXaw xproto libXt libX11 libSM libICE libXext libXft luit;
+    inherit fetchurl stdenv ncurses;
+    inherit (xlibs) libXaw xproto libXt libX11 libSM libICE;
   };
 
   xlaunch = import ../tools/X11/xlaunch {
@@ -4933,9 +5417,9 @@ rec {
   # doesn't compile yet - in case someone else want's to continue .. 
   /*
   qgis_svn = import ../applications/misc/qgis_svn {
-    inherit mkDerivationByConfiguration fetchsvn flex lib
+    inherit mkDerivationByConfiguration fetchsvn stdenv flex lib
             ncurses fetchurl perl cmake gdal geos proj x11
-            gsl libpng zlib stdenv
+            gsl libpng zlib
             sqlite glibc fontconfig freetype / * use libc from stdenv ? - to lazy now - Marc * /;
     inherit (xlibs) libSM libXcursor libXinerama libXrandr libXrender;
     inherit (xorg) libICE;
@@ -5074,20 +5558,20 @@ rec {
     inherit
       fetchurl fetchsvn zlib perl openssl pcre pkgconfig libjpeg libpng libtiff
       libxml2 libxslt libtool libusb expat freetype bzip2 cmake cluceneCore libgcrypt gnupg
-	  cppunit cyrus_sasl openldap enchant exiv2 samba nss log4cxx aspell kerberos
+	  cppunit cyrus_sasl openldap enchant exiv2 samba nss log4cxx aspell
       shared_mime_info alsaLib libungif cups mesa boost gpgme gettext redland
-	  xineLib libgphoto2 djvulibre libogg lame libvorbis poppler readline
+	  xineLib libgphoto2 djvulibre libogg flac lame libvorbis poppler readline
 	  saneBackends chmlib python libzip gmp sqlite libidn runCommand lib
 	  openbabel ocaml facile stdenv jasper fam indilib libnova
 	  libarchive dbus;
-	flac = builtins.getAttr "1.1.2" flacAlts;
+	#flac = builtins.getAttr "1.1.2" flacAlts;
 	cdparanoia = cdparanoiaIII;
     inherit (xlibs)
       inputproto kbproto scrnsaverproto xextproto xf86miscproto
       xf86vidmodeproto xineramaproto xproto libICE libX11 libXau libXcomposite
       libXcursor libXdamage libXdmcp libXext libXfixes libXft libXi libXpm
       libXrandr libXrender libXScrnSaver libXt libXtst libXv libXxf86misc
-      libxkbfile libXinerama libpthreadstubs libXxf86vm xset xprop;
+      libxkbfile libXinerama;
     inherit (gtkLibs) glib;
     qt = qt4;
 	bison = bison23;
@@ -5252,6 +5736,10 @@ rec {
     inherit fetchurl stdenv x11 mesa;
   };
 
+  xlockmore = import ../misc/screensavers/xlockmore {
+    inherit fetchurl stdenv pam x11 freetype;
+  };
+
   saneBackends = import ../misc/sane-backends {
     inherit fetchurl stdenv libusb;
 	gt68xxFirmware = 
@@ -5265,6 +5753,16 @@ rec {
     inherit (xlibs) libX11;
   };
 
+  # State Nix
+  snix = import ../tools/package-management/snix {
+    inherit fetchurl stdenv perl curl bzip2 openssl;
+    aterm = aterm242fixes;
+    db4 = db45;
+
+    inherit ext3cowtools e3cfsprogs rsync;
+    ext3cow_kernel = kernel;
+  };
+
   synaptics = import ../misc/synaptics {
     inherit fetchurl stdenv pkgconfig;
     inherit (xlibs) libX11 libXi libXext pixman xf86inputevdev;
@@ -5311,7 +5809,7 @@ rec {
   wine = import ../misc/emulators/wine {
     inherit fetchurl stdenv flex bison mesa ncurses
       libpng libjpeg alsaLib lcms xlibs freetype
-      fontconfig fontforge;
+      fontconfig fontforge libxml2 libxslt openssl;
   };
 
   xsane = import ../misc/xsane {
diff --git a/pkgs/top-level/build-for-release.nix b/pkgs/top-level/build-for-release.nix
index 6787f91a072..bb892735edd 100644
--- a/pkgs/top-level/build-for-release.nix
+++ b/pkgs/top-level/build-for-release.nix
@@ -3,22 +3,306 @@ let {
   allPackages = import ./all-packages.nix;
 
   i686LinuxPkgs = {inherit (allPackages {system = "i686-linux";})
+    MPlayer
+    MPlayerPlugin
+    alsaUtils
+    apacheAnt
+    apacheHttpd
+    aspectj
+    aspell
+    aspellDicts
     aterm
+    autoconf
+    automake19x
+    bash
+    bashInteractive
+    batik
+    binutils
+    bison23
+    bittorrent
+    bmp
+    bmp_plugin_musepack
+    bmp_plugin_wma
+    bsdiff
+    bzip2
+    cabextract
+    cdrkit
+    chatzilla
+    cksfv
+    #compiz
+    coreutils
+    cpio
+    cron
+    cups
+    darcs
+    db4
+    dhcp
+    dietlibc
+    diffutils
+    docbook5
+    docbook5_xsl
+    docbook_xml_dtd_42
+    docbook_xml_dtd_43
+    docbook_xsl
+    e2fsprogs
+    ecj
+    eclipsesdk
+    emacs
+    emacsUnicode
+    enscript
+    exult
+    feh
+    file
+    findutils
+    firefoxWrapper
+    flex2533
+    gawk
+    gcc
+    gcc34
+    gcc42
+    gdb
+    ghc
+    ghc68
+    ghostscript
+    gimp
+    gnugrep
+    gnum4
+    gnumake
+    gnupatch
+    gnused
+    gnutar
+    gqview
+    graphviz
+    grub
+    gzip
+    hal
+    hello
+    iana_etc
+    iputils
+    irssi
+    iwlwifi
+    jakartaregexp
+    jdkPlugin
+    jetty
+    jikes
+    jing_tools
+    jrePlugin
+    jwhois
+    kbd
+    kcachegrind
+    kdebase
+    keen4
+    kernel
+    klibc
+    ktorrent
+    less
+    lhs2tex
+    libtool
+    libxml2
+    libxslt
+    lvm2
+    lynx
+    man
+    mdadm
+    mesa
+    mingetty
+    mk
+    mktemp
+    mod_python
+    module_init_tools
+    mono
+    mysql
+    #mythtv
+    nano
+    netcat
+    nix
     nixUnstable
+    nss_ldap
+    ntp    
+    nxml
+    openoffice
+    openssh
+    openssl
+    pam_console
+    pam_ldap
+    pam_login
+    pam_unix2
+    pan
+    par2cmdline
+    pciutils
+    perl
+    php
+    pidgin
+    pkgconfig
+    postgresql
+    postgresql_jdbc
+    procps
+    pwdutils
+    python
+    qt3
+    quake3demo
+    readline
+    reiserfsprogs
+    rogue
+    rsync
+    ruby
+    screen
+    sdf
+    slim
+    spidermonkey
+    splashutils
+    ssmtp
+    strace
+    strategoxt
+    strategoxtUtils
+    su
     subversion
+    sudo
+    swig
+    sylpheed 
+    sysklogd
+    syslinux
+    sysvinit
+    sysvtools
+    tetex
+    texinfo
+    thunderbird
+    tightvnc
+    time
+    udev
+    uml
+    unzip
+    upstart
+    utillinux
+    valgrind
+    vim
+    vlc
+    w3m
+    wget
+    wine
+    wirelesstools
+    wxHaskell
+    x11_ssh_askpass
+    xchm
+    xfig
+    xineUI
+    xkeyboard_config
+    xmltv
+    xmms
+    xorg_sys_opengl
+    xsel
+    xterm
+    zdelta
+    zip
+    ;
+  inherit ((allPackages {system = "i686-linux";}).xorg)
+    fontbh100dpi
+    fontbhlucidatypewriter100dpi
+    fontbhttf
+    fontcursormisc
+    fontmiscmisc
+    iceauth
+    setxkbmap
+    xauth
+    xf86inputkeyboard
+    xf86inputmouse
+    xf86videoi810
+    xf86videovesa
+    xkbcomp
+    xorgserver
+    xrandr
+    xrdb
+    xset
+    ;
+  inherit ((allPackages {system = "i686-linux";}).gnome)
+    gconfeditor
+    gnomepanel
+    gnometerminal
+    gnomeutils
+    metacity
     ;
   };
 
   x86_64LinuxPkgs = {inherit (allPackages {system = "x86_64-linux";})
-    aterm
+    aterm242fixes
+    autoconf
+    automake19x
+    bash
+    binutils
+    bison23
     gcc
+    hello
+    iwlwifi
+    kernel
+    libtool
     nixUnstable
     subversion
     ;    
   };
   
+  i686FreeBSDPkgs = {inherit (allPackages {system = "i686-freebsd";})
+    aterm
+    autoconf
+    automake19x
+    docbook5
+    docbook_xml_dtd_42
+    docbook_xml_dtd_43
+    docbook_xsl
+    docbook5_xsl
+    libtool
+    libxml2
+    libxslt
+    nxml
+    realCurl
+    subversion
+    unzip
+  ;};
+
+  powerpcDarwinPkgs = {inherit (allPackages {system = "powerpc-darwin";})
+    apacheHttpd
+    aterm
+    autoconf
+    automake19x
+    bison23
+    docbook5
+    docbook_xml_dtd_42
+    docbook_xml_dtd_43
+    docbook_xsl
+    docbook5_xsl
+    libtool
+    libxml2
+    libxslt
+    nxml
+    #php
+    subversion
+    tetex
+    unzip
+  ;};
+
+  i686DarwinPkgs = {inherit (allPackages {system = "i686-darwin";})
+    aterm
+    autoconf
+    automake19x
+    libtool
+    libxml2
+    libxslt
+    subversion
+  ;};
+
+  cygwinPkgs = {inherit (allPackages {system = "i686-cygwin";})
+    aterm
+    gnum4
+    readline
+    ncurses
+  ;};
+
   body = [
     i686LinuxPkgs
     x86_64LinuxPkgs
+    powerpcLinuxPkgs
+    i686FreeBSDPkgs
+    powerpcDarwinPkgs
+    i686DarwinPkgs
+    cygwinPkgs
   ];
 }
diff --git a/pkgs/top-level/builder-defs.nix b/pkgs/top-level/builder-defs.nix
index 5757098cf8d..6b53ba76fd4 100644
--- a/pkgs/top-level/builder-defs.nix
+++ b/pkgs/top-level/builder-defs.nix
@@ -20,12 +20,7 @@ args: with args; with stringsWithDeps; with lib;
 
 		else (abort "unknown archive type : ${s}"));
 
-	pathDelimiter = if args ? pathDelimiter then args.pathDelimiter else
-		if __currentSystem == "i686-mingw" then ";" else ":";
-
 	defAddToSearchPath = FullDepEntry ("
-		export PATH_DELIMITER='${pathDelimiter}';
-
 		addToSearchPathWithCustomDelimiter() {
 			local delimiter=\$1
 			local varName=\$2