summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--TODO.txt9
-rw-r--r--doc/stdenv.xml23
-rw-r--r--maintainers/docs/cross.txt6
-rw-r--r--maintainers/scripts/eval-release.nix2
-rw-r--r--pkgs/applications/audio/ardour/default.nix2
-rw-r--r--pkgs/applications/audio/gmu/default.nix2
-rw-r--r--pkgs/applications/audio/id3v2/default.nix2
-rw-r--r--pkgs/applications/audio/ladspa-plugins/default.nix2
-rw-r--r--pkgs/applications/audio/ladspa-plugins/ladspah.nix2
-rw-r--r--pkgs/applications/audio/mp3info/default.nix4
-rw-r--r--pkgs/applications/audio/mpc123/default.nix2
-rw-r--r--pkgs/applications/audio/snd/default.nix2
-rw-r--r--pkgs/applications/audio/sonic-visualiser/default.nix2
-rw-r--r--pkgs/applications/audio/vkeybd/default.nix2
-rw-r--r--pkgs/applications/audio/xsynth-dssi/default.nix4
-rw-r--r--pkgs/applications/editors/eclipse/default.nix4
-rw-r--r--pkgs/applications/editors/ed/default.nix4
-rw-r--r--pkgs/applications/editors/elvis/default.nix6
-rw-r--r--pkgs/applications/editors/emacs-modes/bbdb/default.nix2
-rw-r--r--pkgs/applications/editors/emacs-modes/cedet/default.nix4
-rw-r--r--pkgs/applications/editors/emacs-modes/ecb/default.nix4
-rw-r--r--pkgs/applications/editors/emacs-modes/emms/default.nix4
-rw-r--r--pkgs/applications/editors/emacs-modes/haskell/default.nix2
-rw-r--r--pkgs/applications/editors/emacs-modes/hol_light/default.nix2
-rw-r--r--pkgs/applications/editors/emacs-modes/jdee/default.nix4
-rw-r--r--pkgs/applications/editors/emacs-modes/org/default.nix4
-rw-r--r--pkgs/applications/editors/emacs-modes/quack/default.nix2
-rw-r--r--pkgs/applications/editors/emacs-modes/rudel/default.nix2
-rw-r--r--pkgs/applications/editors/emacs-modes/scala-mode/default.nix2
-rw-r--r--pkgs/applications/editors/emacs-modes/session-management-for-emacs/default.nix2
-rw-r--r--pkgs/applications/editors/jedit/default.nix14
-rw-r--r--pkgs/applications/editors/jedit/wrapper.nix2
-rw-r--r--pkgs/applications/editors/nedit/builder.sh2
-rw-r--r--pkgs/applications/editors/nvi/default.nix4
-rw-r--r--pkgs/applications/graphics/ImageMagick/default.nix7
-rw-r--r--pkgs/applications/graphics/dia/default.nix4
-rw-r--r--pkgs/applications/graphics/gimp/plugins/default.nix10
-rw-r--r--pkgs/applications/graphics/jbrout/default.nix2
-rw-r--r--pkgs/applications/graphics/meshlab/default.nix2
-rw-r--r--pkgs/applications/graphics/minidjvu/default.nix2
-rw-r--r--pkgs/applications/graphics/pinta/default.nix2
-rw-r--r--pkgs/applications/graphics/rawtherapee/default.nix2
-rw-r--r--pkgs/applications/graphics/wings/default.nix2
-rw-r--r--pkgs/applications/graphics/xaos/default.nix2
-rw-r--r--pkgs/applications/misc/adobe-reader/builder.sh4
-rw-r--r--pkgs/applications/misc/audio/wavesurfer/default.nix2
-rw-r--r--pkgs/applications/misc/bitcoin/default.nix2
-rw-r--r--pkgs/applications/misc/calibre/default.nix2
-rw-r--r--pkgs/applications/misc/djvulibre/default.nix11
-rw-r--r--pkgs/applications/misc/djvulibre/gcc-4.6.patch658
-rw-r--r--pkgs/applications/misc/freemind/default.nix2
-rw-r--r--pkgs/applications/misc/get_iplayer/default.nix2
-rw-r--r--pkgs/applications/misc/googleearth/default.nix2
-rw-r--r--pkgs/applications/misc/jbidwatcher/default.nix2
-rw-r--r--pkgs/applications/misc/lyx/default.nix4
-rw-r--r--pkgs/applications/misc/makeself/default.nix2
-rw-r--r--pkgs/applications/misc/navipowm/default.nix2
-rw-r--r--pkgs/applications/misc/openjump/default.nix2
-rw-r--r--pkgs/applications/misc/procmail/default.nix2
-rw-r--r--pkgs/applications/misc/pstree/default.nix2
-rw-r--r--pkgs/applications/misc/qcad/default.nix2
-rw-r--r--pkgs/applications/misc/rxvt_unicode/default.nix2
-rw-r--r--pkgs/applications/misc/sbagen/default.nix2
-rw-r--r--pkgs/applications/misc/thinking-rock/default.nix2
-rw-r--r--pkgs/applications/misc/vue/default.nix2
-rw-r--r--pkgs/applications/misc/xpdf/libxpdf.nix8
-rw-r--r--pkgs/applications/networking/browsers/chromium/default.nix4
-rw-r--r--pkgs/applications/networking/browsers/firefox/3.6.nix9
-rw-r--r--pkgs/applications/networking/browsers/firefox/gcc-4.6.patch13
-rw-r--r--pkgs/applications/networking/browsers/firefox/wrapper.nix2
-rw-r--r--pkgs/applications/networking/browsers/icecat-3/default.nix6
-rw-r--r--pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-10/builder.sh2
-rw-r--r--pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-11/builder.sh2
-rw-r--r--pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-9/builder.sh2
-rw-r--r--pkgs/applications/networking/browsers/mozilla-plugins/mozplugger/default.nix2
-rw-r--r--pkgs/applications/networking/browsers/mozilla-plugins/mplayerplug-in/default.nix2
-rw-r--r--pkgs/applications/networking/browsers/opera/default.nix2
-rw-r--r--pkgs/applications/networking/instant-messengers/carrier/2.4.2.nix2
-rw-r--r--pkgs/applications/networking/instant-messengers/carrier/2.5.0.nix2
-rw-r--r--pkgs/applications/networking/instant-messengers/oneteam/default.nix6
-rw-r--r--pkgs/applications/networking/instant-messengers/pidgin-plugins/msn-pecan/default.nix2
-rw-r--r--pkgs/applications/networking/instant-messengers/pidgin-plugins/pidgin-latex/pidgin-latex-sf.nix6
-rw-r--r--pkgs/applications/networking/instant-messengers/psi/default.nix4
-rw-r--r--pkgs/applications/networking/instant-messengers/psi/psimedia.nix2
-rw-r--r--pkgs/applications/networking/instant-messengers/torchat/default.nix2
-rw-r--r--pkgs/applications/networking/iptraf/default.nix2
-rw-r--r--pkgs/applications/networking/mailreaders/thunderbird/9.x.nix2
-rw-r--r--pkgs/applications/networking/mumble/default.nix2
-rw-r--r--pkgs/applications/networking/offrss/default.nix2
-rw-r--r--pkgs/applications/networking/p2p/ldcpp/default.nix2
-rw-r--r--pkgs/applications/networking/p2p/mldonkey/default.nix4
-rw-r--r--pkgs/applications/networking/p2p/mldonkey/gcc44mips64.patch103
-rw-r--r--pkgs/applications/networking/p2p/tribler/default.nix2
-rw-r--r--pkgs/applications/networking/pjsip/default.nix4
-rw-r--r--pkgs/applications/networking/skype/default.nix4
-rw-r--r--pkgs/applications/networking/sync/unison/default.nix2
-rw-r--r--pkgs/applications/networking/vnstat/default.nix2
-rw-r--r--pkgs/applications/office/impressive/default.nix2
-rw-r--r--pkgs/applications/office/mmex/default.nix2
-rw-r--r--pkgs/applications/office/openoffice/builder.sh4
-rw-r--r--pkgs/applications/office/openoffice/get-go-src.nix2
-rw-r--r--pkgs/applications/office/openoffice/go-oo.nix2
-rw-r--r--pkgs/applications/science/biology/arb/default.nix8
-rw-r--r--pkgs/applications/science/biology/pal2nal/default.nix4
-rw-r--r--pkgs/applications/science/biology/slr/default.nix2
-rw-r--r--pkgs/applications/science/electronics/caneda/default.nix2
-rw-r--r--pkgs/applications/science/electronics/gtkwave/default.nix4
-rw-r--r--pkgs/applications/science/geometry/tetgen/default.nix2
-rw-r--r--pkgs/applications/science/logic/coq/default.nix2
-rw-r--r--pkgs/applications/science/logic/hol/default.nix4
-rw-r--r--pkgs/applications/science/logic/hol_light/default.nix2
-rw-r--r--pkgs/applications/science/logic/iprover/default.nix4
-rw-r--r--pkgs/applications/science/logic/isabelle/default.nix2
-rw-r--r--pkgs/applications/science/logic/leo2/default.nix6
-rw-r--r--pkgs/applications/science/logic/matita/default.nix2
-rw-r--r--pkgs/applications/science/logic/minisat/default.nix2
-rw-r--r--pkgs/applications/science/logic/picosat/default.nix6
-rw-r--r--pkgs/applications/science/logic/prover9/default.nix2
-rw-r--r--pkgs/applications/science/logic/satallax/default.nix6
-rw-r--r--pkgs/applications/science/logic/ssreflect/default.nix2
-rw-r--r--pkgs/applications/science/logic/tptp/default.nix4
-rw-r--r--pkgs/applications/science/math/content/default.nix2
-rw-r--r--pkgs/applications/science/math/eukleides/default.nix2
-rw-r--r--pkgs/applications/science/math/maxima/default.nix2
-rw-r--r--pkgs/applications/science/math/msieve/default.nix2
-rw-r--r--pkgs/applications/science/math/singular/default.nix2
-rw-r--r--pkgs/applications/taxes/aangifte-2005/builder.sh2
-rw-r--r--pkgs/applications/taxes/aangifte-2006/builder.sh2
-rw-r--r--pkgs/applications/taxes/aangifte-2007/builder.sh2
-rw-r--r--pkgs/applications/taxes/aangifte-2008/builder.sh2
-rw-r--r--pkgs/applications/taxes/aangifte-2009/default.nix2
-rw-r--r--pkgs/applications/taxes/aangifte-2010/default.nix2
-rw-r--r--pkgs/applications/version-management/bazaar/default.nix2
-rw-r--r--pkgs/applications/version-management/fossil/default.nix2
-rw-r--r--pkgs/applications/version-management/git-and-tools/fast-export/default.nix2
-rw-r--r--pkgs/applications/version-management/git-and-tools/git/default.nix6
-rw-r--r--pkgs/applications/version-management/git-and-tools/git/git-git.nix4
-rw-r--r--pkgs/applications/version-management/git-and-tools/stgit/default.nix2
-rw-r--r--pkgs/applications/version-management/git-and-tools/topgit/default.nix4
-rw-r--r--pkgs/applications/version-management/meld/default.nix4
-rw-r--r--pkgs/applications/version-management/mercurial/default.nix10
-rw-r--r--pkgs/applications/version-management/monotone/default.nix4
-rw-r--r--pkgs/applications/version-management/veracity/default.nix10
-rw-r--r--pkgs/applications/version-management/viewmtn/0.10.nix6
-rw-r--r--pkgs/applications/video/RealPlayer/builder.sh4
-rw-r--r--pkgs/applications/video/gnash/default.nix2
-rw-r--r--pkgs/applications/video/lxdvdrip/default.nix2
-rw-r--r--pkgs/applications/video/mythtv/builder.sh2
-rw-r--r--pkgs/applications/video/vlc/default.nix6
-rw-r--r--pkgs/applications/video/vlc/zlib.patch35
-rw-r--r--pkgs/applications/video/xine-ui/default.nix4
-rw-r--r--pkgs/applications/virtualization/nova/client.nix2
-rw-r--r--pkgs/applications/virtualization/qemu/linux-img/default.nix2
-rw-r--r--pkgs/applications/virtualization/virtualbox/guest-additions/default.nix16
-rw-r--r--pkgs/applications/virtualization/xen/default.nix4
-rw-r--r--pkgs/applications/window-managers/awesome/default.nix4
-rw-r--r--pkgs/applications/window-managers/stumpwm/default.nix8
-rw-r--r--pkgs/applications/window-managers/vwm/default.nix2
-rw-r--r--pkgs/applications/window-managers/wmii31/default.nix2
-rw-r--r--pkgs/build-support/builder-defs/builder-defs.nix42
-rw-r--r--pkgs/build-support/clang-wrapper/builder.sh4
-rw-r--r--pkgs/build-support/clang-wrapper/clang-wrapper.sh5
-rw-r--r--pkgs/build-support/dotnetenv/build-solution.nix4
-rw-r--r--pkgs/build-support/fetchcvs/builder.sh2
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/default.nix2
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh5
-rw-r--r--pkgs/build-support/gcc-upc-wrapper/builder.sh4
-rw-r--r--pkgs/build-support/gcc-upc-wrapper/gcc-wrapper.sh5
-rw-r--r--pkgs/build-support/gcc-wrapper/builder.sh4
-rw-r--r--pkgs/build-support/gcc-wrapper/gcc-wrapper.sh5
-rw-r--r--pkgs/build-support/kernel/make-initrd.sh2
-rw-r--r--pkgs/build-support/kernel/modules-closure.sh3
-rw-r--r--pkgs/build-support/make-desktopitem/default.nix2
-rw-r--r--pkgs/build-support/make-wrapper/make-wrapper.sh2
-rw-r--r--pkgs/build-support/native-darwin-cctools-wrapper/builder.sh2
-rw-r--r--pkgs/build-support/nuke-references/builder.sh2
-rw-r--r--pkgs/build-support/release/ant-build.nix6
-rw-r--r--pkgs/build-support/release/binary-tarball.nix4
-rw-r--r--pkgs/build-support/release/debian-build.nix4
-rw-r--r--pkgs/build-support/release/maven-build.nix4
-rw-r--r--pkgs/build-support/release/nix-build.nix4
-rw-r--r--pkgs/build-support/release/rpm-build.nix2
-rw-r--r--pkgs/build-support/release/source-tarball.nix4
-rw-r--r--pkgs/build-support/substitute/substitute-all.sh2
-rw-r--r--pkgs/build-support/trivial-builders.nix2
-rw-r--r--pkgs/build-support/upstream-updater/attrset-to-dir.nix2
-rw-r--r--pkgs/build-support/vm/default.nix18
-rw-r--r--pkgs/build-support/vsenv/build-solution.nix2
-rw-r--r--pkgs/data/documentation/pthread-man-pages/default.nix2
-rw-r--r--pkgs/data/documentation/rnrs/builder.sh4
-rw-r--r--pkgs/data/documentation/std-man-pages/default.nix2
-rw-r--r--pkgs/data/fonts/andagii/default.nix2
-rw-r--r--pkgs/data/fonts/bakoma-ttf/default.nix2
-rw-r--r--pkgs/data/fonts/cantarell-fonts/default.nix4
-rw-r--r--pkgs/data/fonts/clearlyU/default.nix2
-rw-r--r--pkgs/data/fonts/corefonts/default.nix2
-rw-r--r--pkgs/data/fonts/dejavu-fonts/default.nix4
-rw-r--r--pkgs/data/fonts/fontWrap/default.nix2
-rw-r--r--pkgs/data/fonts/freefont-ttf/default.nix2
-rw-r--r--pkgs/data/fonts/junicode/default.nix2
-rw-r--r--pkgs/data/fonts/lmodern/default.nix4
-rw-r--r--pkgs/data/fonts/mph-2b-damase/default.nix2
-rw-r--r--pkgs/data/fonts/redhat-liberation-fonts/default.nix4
-rw-r--r--pkgs/data/fonts/ttf-bitstream-vera/default.nix2
-rw-r--r--pkgs/data/fonts/unifont/default.nix2
-rw-r--r--pkgs/data/fonts/vista-fonts/default.nix2
-rw-r--r--pkgs/data/fonts/wqy-zenhei/default.nix2
-rw-r--r--pkgs/data/misc/cacert/default.nix2
-rw-r--r--pkgs/data/sgml+xml/schemas/docbook-5.0/builder.sh8
-rw-r--r--pkgs/data/sgml+xml/schemas/xml-dtd/xhtml1/default.nix2
-rw-r--r--pkgs/data/sgml+xml/stylesheets/xslt/docbook-xsl-ns/default.nix2
-rw-r--r--pkgs/data/sgml+xml/stylesheets/xslt/docbook-xsl/builder.sh2
-rw-r--r--pkgs/desktops/gnome-2/platform/audiofile/default.nix4
-rw-r--r--pkgs/desktops/gnome-2/platform/gtk-doc/default.nix2
-rw-r--r--pkgs/desktops/gnome-2/platform/libgnome-keyring/default.nix4
-rw-r--r--pkgs/desktops/gnome-3/platform/GConf.nix4
-rw-r--r--pkgs/desktops/gnome-3/platform/clutter.nix4
-rw-r--r--pkgs/desktops/gnome-3/platform/glib-networking.nix4
-rw-r--r--pkgs/desktops/gnome-3/platform/gnome-user-docs.nix4
-rw-r--r--pkgs/desktops/gnome-3/platform/gsettings-desktop-schemas.nix4
-rw-r--r--pkgs/desktops/gnome-3/platform/libgnome-keyring.nix4
-rw-r--r--pkgs/desktops/gnome-3/platform/libsoup.nix2
-rw-r--r--pkgs/desktops/kde-4.7/kde-runtime.nix4
-rw-r--r--pkgs/desktops/kde-4.7/kde-workspace.nix8
-rw-r--r--pkgs/desktops/kde-4.7/kdelibs.nix9
-rw-r--r--pkgs/desktops/kde-4.7/kdeutils/ark.nix4
-rw-r--r--pkgs/desktops/kde-4.8/kde-runtime.nix4
-rw-r--r--pkgs/desktops/kde-4.8/kdelibs.nix9
-rw-r--r--pkgs/desktops/kde-4.8/kdeutils/ark.nix4
-rw-r--r--pkgs/development/compilers/abc/builder-binjar.sh2
-rw-r--r--pkgs/development/compilers/abc/builder.sh4
-rw-r--r--pkgs/development/compilers/abc/jasmin/builder.sh2
-rw-r--r--pkgs/development/compilers/abc/polyglot/builder.sh2
-rw-r--r--pkgs/development/compilers/abc/soot/builder.sh2
-rw-r--r--pkgs/development/compilers/adobe-flex-sdk/default.nix2
-rwxr-xr-xpkgs/development/compilers/aspectj/builder.sh2
-rw-r--r--pkgs/development/compilers/ccl/default.nix4
-rw-r--r--pkgs/development/compilers/cmucl/binary.nix2
-rw-r--r--pkgs/development/compilers/eql/default.nix2
-rw-r--r--pkgs/development/compilers/fpc/lazarus.nix2
l---------pkgs/development/compilers/gcc-4.5/update-gcc.sh1
l---------pkgs/development/compilers/gcc-4.6/update-gcc.sh1
-rw-r--r--pkgs/development/compilers/gcc-upc-4.0/default.nix20
-rw-r--r--pkgs/development/compilers/gcc/2.95/builder.sh (renamed from pkgs/development/compilers/gcc-2.95/builder.sh)0
-rw-r--r--pkgs/development/compilers/gcc/2.95/default.nix (renamed from pkgs/development/compilers/gcc-2.95/default.nix)0
-rw-r--r--pkgs/development/compilers/gcc/2.95/no-sys-dirs.patch (renamed from pkgs/development/compilers/gcc-2.95/no-sys-dirs.patch)0
-rw-r--r--pkgs/development/compilers/gcc/3.3/builder.sh (renamed from pkgs/development/compilers/gcc-3.3/builder.sh)0
-rw-r--r--pkgs/development/compilers/gcc/3.3/default.nix (renamed from pkgs/development/compilers/gcc-3.3/default.nix)0
-rw-r--r--pkgs/development/compilers/gcc/3.4/builder.sh (renamed from pkgs/development/compilers/gcc-3.4/builder.sh)0
-rw-r--r--pkgs/development/compilers/gcc/3.4/default.nix (renamed from pkgs/development/compilers/gcc-3.4/default.nix)2
-rw-r--r--pkgs/development/compilers/gcc/3.4/no-sys-dirs.patch (renamed from pkgs/development/compilers/gcc-3.4/no-sys-dirs.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.0/builder.sh (renamed from pkgs/development/compilers/gcc-4.0/builder.sh)0
-rw-r--r--pkgs/development/compilers/gcc/4.0/default.nix (renamed from pkgs/development/compilers/gcc-4.0/default.nix)2
-rw-r--r--pkgs/development/compilers/gcc/4.0/gcc-4.0.2-cxx.patch (renamed from pkgs/development/compilers/gcc-4.0/gcc-4.0.2-cxx.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.0/no-sys-dirs.patch (renamed from pkgs/development/compilers/gcc-4.0/no-sys-dirs.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.1/builder.sh (renamed from pkgs/development/compilers/gcc-4.1/builder.sh)0
-rw-r--r--pkgs/development/compilers/gcc/4.1/default.nix (renamed from pkgs/development/compilers/gcc-4.1/default.nix)2
-rw-r--r--pkgs/development/compilers/gcc/4.1/no-sys-dirs.patch (renamed from pkgs/development/compilers/gcc-4.1/no-sys-dirs.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.2-apple32/builder.sh (renamed from pkgs/development/compilers/gcc-apple/builder.sh)0
-rw-r--r--pkgs/development/compilers/gcc/4.2-apple32/debug_list.patch (renamed from pkgs/development/compilers/gcc-apple/debug_list.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.2-apple32/default.nix (renamed from pkgs/development/compilers/gcc-apple/default.nix)0
-rw-r--r--pkgs/development/compilers/gcc/4.2-apple32/no-sys-dirs.patch (renamed from pkgs/development/compilers/gcc-apple/no-sys-dirs.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.2-apple32/pass-cxxcpp.patch (renamed from pkgs/development/compilers/gcc-apple/pass-cxxcpp.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.2-apple64/builder.sh (renamed from pkgs/development/compilers/gcc-apple64/builder.sh)27
-rw-r--r--pkgs/development/compilers/gcc/4.2-apple64/debug_list.patch (renamed from pkgs/development/compilers/gcc-apple64/debug_list.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.2-apple64/default.nix (renamed from pkgs/development/compilers/gcc-apple64/default.nix)26
-rw-r--r--pkgs/development/compilers/gcc/4.2-apple64/fix-libstdc++-link.patch17
-rw-r--r--pkgs/development/compilers/gcc/4.2-apple64/no-sys-dirs.patch (renamed from pkgs/development/compilers/gcc-apple64/no-sys-dirs.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.2-apple64/pass-cxxcpp.patch (renamed from pkgs/development/compilers/gcc-apple64/pass-cxxcpp.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.2/builder.sh (renamed from pkgs/development/compilers/gcc-4.2/builder.sh)0
-rw-r--r--pkgs/development/compilers/gcc/4.2/default.nix (renamed from pkgs/development/compilers/gcc-4.2/default.nix)0
-rw-r--r--pkgs/development/compilers/gcc/4.2/no-sys-dirs.patch (renamed from pkgs/development/compilers/gcc-4.2/no-sys-dirs.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.2/pass-cxxcpp.patch (renamed from pkgs/development/compilers/gcc-4.2/pass-cxxcpp.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.3/builder.sh (renamed from pkgs/development/compilers/gcc-4.3/builder.sh)0
-rw-r--r--pkgs/development/compilers/gcc/4.3/default.nix (renamed from pkgs/development/compilers/gcc-4.3/default.nix)0
-rw-r--r--pkgs/development/compilers/gcc/4.3/ghdl-ortho-cflags.patch (renamed from pkgs/development/compilers/gcc-4.3/ghdl-ortho-cflags.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.3/java-jvgenmain-link.patch (renamed from pkgs/development/compilers/gcc-4.3/java-jvgenmain-link.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.3/libmudflap-cpp.patch (renamed from pkgs/development/compilers/gcc-4.3/libmudflap-cpp.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.3/no-sys-dirs-fortran.patch (renamed from pkgs/development/compilers/gcc-4.3/no-sys-dirs-fortran.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.3/no-sys-dirs.patch (renamed from pkgs/development/compilers/gcc-4.3/no-sys-dirs.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.3/pass-cxxcpp.patch (renamed from pkgs/development/compilers/gcc-4.3/pass-cxxcpp.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.4/builder.sh (renamed from pkgs/development/compilers/gcc-4.4/builder.sh)0
-rw-r--r--pkgs/development/compilers/gcc/4.4/default.nix (renamed from pkgs/development/compilers/gcc-4.4/default.nix)11
-rw-r--r--pkgs/development/compilers/gcc/4.4/ghdl-ortho-cflags.patch (renamed from pkgs/development/compilers/gcc-4.4/ghdl-ortho-cflags.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.4/gnat-cflags.patch (renamed from pkgs/development/compilers/gcc-4.4/gnat-cflags.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.4/java-jvgenmain-link.patch (renamed from pkgs/development/compilers/gcc-4.4/java-jvgenmain-link.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.4/libstdc++-target.patch (renamed from pkgs/development/compilers/gcc-4.4/libstdc++-target.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.4/no-sys-dirs.patch (renamed from pkgs/development/compilers/gcc-4.4/no-sys-dirs.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.4/pass-cxxcpp.patch (renamed from pkgs/development/compilers/gcc-4.4/pass-cxxcpp.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.4/pr41818.patch (renamed from pkgs/development/compilers/gcc-4.4/pr41818.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.4/sources.nix (renamed from pkgs/development/compilers/gcc-4.4/sources.nix)0
-rw-r--r--pkgs/development/compilers/gcc/4.4/target-cpp.patch (renamed from pkgs/development/compilers/gcc-4.4/target-cpp.patch)0
-rwxr-xr-xpkgs/development/compilers/gcc/4.4/update-gcc.sh (renamed from pkgs/development/compilers/gcc-4.4/update-gcc.sh)0
-rw-r--r--pkgs/development/compilers/gcc/4.5/builder.sh (renamed from pkgs/development/compilers/gcc-4.5/builder.sh)10
-rw-r--r--pkgs/development/compilers/gcc/4.5/default.nix (renamed from pkgs/development/compilers/gcc-4.5/default.nix)28
-rw-r--r--pkgs/development/compilers/gcc/4.5/ghdl-ortho-cflags.patch (renamed from pkgs/development/compilers/gcc-4.5/ghdl-ortho-cflags.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.5/gnat-cflags.patch (renamed from pkgs/development/compilers/gcc-4.5/gnat-cflags.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.5/java-jvgenmain-link.patch (renamed from pkgs/development/compilers/gcc-4.5/java-jvgenmain-link.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.5/libstdc++-target.patch (renamed from pkgs/development/compilers/gcc-4.5/libstdc++-target.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.5/no-sys-dirs.patch (renamed from pkgs/development/compilers/gcc-4.5/no-sys-dirs.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.5/sources.nix (renamed from pkgs/development/compilers/gcc-4.5/sources.nix)14
l---------pkgs/development/compilers/gcc/4.5/update-gcc.sh1
-rw-r--r--pkgs/development/compilers/gcc/4.6/builder.sh (renamed from pkgs/development/compilers/gcc-4.6/builder.sh)0
-rw-r--r--pkgs/development/compilers/gcc/4.6/default.nix (renamed from pkgs/development/compilers/gcc-4.6/default.nix)33
-rw-r--r--pkgs/development/compilers/gcc/4.6/ghdl-ortho-cflags.patch (renamed from pkgs/development/compilers/gcc-4.6/ghdl-ortho-cflags.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.6/gnat-cflags.patch (renamed from pkgs/development/compilers/gcc-4.6/gnat-cflags.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.6/java-jvgenmain-link.patch (renamed from pkgs/development/compilers/gcc-4.6/java-jvgenmain-link.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.6/libstdc++-target.patch (renamed from pkgs/development/compilers/gcc-4.6/libstdc++-target.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.6/no-sys-dirs.patch (renamed from pkgs/development/compilers/gcc-4.6/no-sys-dirs.patch)0
-rw-r--r--pkgs/development/compilers/gcc/4.6/sources.nix (renamed from pkgs/development/compilers/gcc-4.6/sources.nix)16
l---------pkgs/development/compilers/gcc/4.6/update-gcc.sh1
-rw-r--r--pkgs/development/compilers/ghc/6.10.2-binary.nix4
-rw-r--r--pkgs/development/compilers/ghc/6.12.1-binary.nix2
-rw-r--r--pkgs/development/compilers/ghc/6.4.2-binary.nix4
-rw-r--r--pkgs/development/compilers/ghc/6.6.1.nix2
-rw-r--r--pkgs/development/compilers/ghc/with-packages.nix6
-rw-r--r--pkgs/development/compilers/ghc/wrapper.nix4
-rw-r--r--pkgs/development/compilers/gnatboot/default.nix2
-rw-r--r--pkgs/development/compilers/go/default.nix6
-rw-r--r--pkgs/development/compilers/gwt/builder.sh4
-rw-r--r--pkgs/development/compilers/haxe/default.nix4
-rw-r--r--pkgs/development/compilers/jdk/builder.sh2
-rw-r--r--pkgs/development/compilers/jdk/dlj-bundle-builder.sh2
-rw-r--r--pkgs/development/compilers/jdk/ibm-builder.sh2
-rw-r--r--pkgs/development/compilers/llvm/dragonegg.nix2
-rw-r--r--pkgs/development/compilers/neko/default.nix2
-rw-r--r--pkgs/development/compilers/nvidia-cg-toolkit/default.nix10
-rw-r--r--pkgs/development/compilers/ocaml/3.10.0.nix2
-rw-r--r--pkgs/development/compilers/ocaml/3.11.1.nix68
-rw-r--r--pkgs/development/compilers/ocaml/3.12.1.nix2
-rw-r--r--pkgs/development/compilers/ocaml/ber-metaocaml-003.nix2
-rw-r--r--pkgs/development/compilers/ocaml/metaocaml-3.09.nix2
-rw-r--r--pkgs/development/compilers/opa/default.nix2
-rw-r--r--pkgs/development/compilers/openjdk-darwin/default.nix2
-rw-r--r--pkgs/development/compilers/openjdk/default.nix6
-rw-r--r--pkgs/development/compilers/pakcs/default.nix2
-rw-r--r--pkgs/development/compilers/qi/default.nix4
-rw-r--r--pkgs/development/compilers/scala/default.nix2
-rw-r--r--pkgs/development/compilers/stalin/default.nix10
-rw-r--r--pkgs/development/compilers/tinycc/default.nix2
-rw-r--r--pkgs/development/compilers/visual-c++/builder.sh4
-rw-r--r--pkgs/development/compilers/visual-c++/test/builder.sh2
-rw-r--r--pkgs/development/compilers/vs90wrapper/default.nix2
-rw-r--r--pkgs/development/interpreters/acl2/default.nix2
-rw-r--r--pkgs/development/interpreters/angelscript/default.nix4
-rw-r--r--pkgs/development/interpreters/clojure/binary.nix2
-rw-r--r--pkgs/development/interpreters/clojure/clooj.nix2
-rw-r--r--pkgs/development/interpreters/clojure/default.nix2
-rw-r--r--pkgs/development/interpreters/groovy/default.nix2
-rw-r--r--pkgs/development/interpreters/guile/1.8.nix3
-rw-r--r--pkgs/development/interpreters/guile/default.nix4
-rw-r--r--pkgs/development/interpreters/j/default.nix4
-rw-r--r--pkgs/development/interpreters/jruby/default.nix2
-rw-r--r--pkgs/development/interpreters/kona/default.nix2
-rw-r--r--pkgs/development/interpreters/lua-5/default.nix2
-rw-r--r--pkgs/development/interpreters/maude/default.nix2
-rw-r--r--pkgs/development/interpreters/perl/5.10/default.nix (renamed from pkgs/development/interpreters/perl-5.10/default.nix)0
-rw-r--r--pkgs/development/interpreters/perl/5.10/no-sys-dirs.patch (renamed from pkgs/development/interpreters/perl-5.10/no-sys-dirs.patch)0
-rw-r--r--pkgs/development/interpreters/perl/5.10/setup-hook.sh (renamed from pkgs/development/interpreters/perl-5.10/setup-hook.sh)0
-rw-r--r--pkgs/development/interpreters/perl/5.14/default.nix61
-rw-r--r--pkgs/development/interpreters/perl/5.14/no-libutil.patch12
-rw-r--r--pkgs/development/interpreters/perl/5.14/no-sys-dirs.patch152
-rw-r--r--pkgs/development/interpreters/perl/5.14/setup-hook.sh5
-rw-r--r--pkgs/development/interpreters/perl/5.8/default.nix (renamed from pkgs/development/interpreters/perl-5.8/default.nix)2
-rw-r--r--pkgs/development/interpreters/perl/5.8/gcc-4.2.patch (renamed from pkgs/development/interpreters/perl-5.8/gcc-4.2.patch)0
-rw-r--r--pkgs/development/interpreters/perl/5.8/no-sys-dirs.patch (renamed from pkgs/development/interpreters/perl-5.8/no-sys-dirs.patch)0
-rw-r--r--pkgs/development/interpreters/perl/5.8/setup-hook.sh (renamed from pkgs/development/interpreters/perl-5.8/setup-hook.sh)0
-rw-r--r--pkgs/development/interpreters/php-xdebug/default.nix2
-rw-r--r--pkgs/development/interpreters/picolisp/default.nix2
-rw-r--r--pkgs/development/interpreters/python/2.6/default.nix10
-rw-r--r--pkgs/development/interpreters/python/2.7/default.nix17
-rw-r--r--pkgs/development/interpreters/python/3.1/default.nix5
-rw-r--r--pkgs/development/interpreters/python/3.2/default.nix4
-rw-r--r--pkgs/development/interpreters/python/pythonhome-wrapper.nix2
-rw-r--r--pkgs/development/interpreters/python/wrapper.nix7
-rw-r--r--pkgs/development/interpreters/spidermonkey/builder.sh6
-rw-r--r--pkgs/development/libraries/Xaw3d/builder.sh2
-rw-r--r--pkgs/development/libraries/acl/default.nix6
-rw-r--r--pkgs/development/libraries/atk/2.2.x.nix4
-rw-r--r--pkgs/development/libraries/atkmm/2.22.x.nix3
-rw-r--r--pkgs/development/libraries/attr/default.nix6
-rw-r--r--pkgs/development/libraries/box2d/2.0.1.nix6
-rw-r--r--pkgs/development/libraries/chipmunk/default.nix2
-rw-r--r--pkgs/development/libraries/cloog-ppl/default.nix22
-rw-r--r--pkgs/development/libraries/cloog/default.nix9
-rw-r--r--pkgs/development/libraries/cminpack/default.nix2
-rw-r--r--pkgs/development/libraries/cogl/default.nix4
-rw-r--r--pkgs/development/libraries/crypto++/default.nix6
-rw-r--r--pkgs/development/libraries/crypto++/salsa-gcc4.6.patch62
-rw-r--r--pkgs/development/libraries/dbus-glib/0.94.nix23
-rw-r--r--pkgs/development/libraries/dbus-glib/default.nix20
-rw-r--r--pkgs/development/libraries/dbus/1.5.6.nix61
-rw-r--r--pkgs/development/libraries/dbus/default.nix14
-rw-r--r--pkgs/development/libraries/dotnetfx35/default.nix2
-rw-r--r--pkgs/development/libraries/dotnetfx40/default.nix2
-rw-r--r--pkgs/development/libraries/eglibc/builder.sh2
-rw-r--r--pkgs/development/libraries/gdk-pixbuf/2.24.x.nix2
-rw-r--r--pkgs/development/libraries/geoclue/default.nix6
-rw-r--r--pkgs/development/libraries/gettext/0.17.nix14
-rw-r--r--pkgs/development/libraries/gettext/default.nix16
-rw-r--r--pkgs/development/libraries/glfw/default.nix2
-rw-r--r--pkgs/development/libraries/glib/2.28.x.nix4
-rw-r--r--pkgs/development/libraries/glib/2.30.x.nix4
-rw-r--r--pkgs/development/libraries/glibc/2.13/builder.sh (renamed from pkgs/development/libraries/glibc-2.12/builder.sh)0
-rw-r--r--pkgs/development/libraries/glibc/2.13/common.nix (renamed from pkgs/development/libraries/glibc-2.12/common.nix)19
-rw-r--r--pkgs/development/libraries/glibc/2.13/default.nix (renamed from pkgs/development/libraries/glibc-2.12/default.nix)2
-rw-r--r--pkgs/development/libraries/glibc/2.13/glibc-elf-localscope.patch82
-rw-r--r--pkgs/development/libraries/glibc/2.13/info.nix (renamed from pkgs/development/libraries/glibc-2.12/info.nix)2
-rw-r--r--pkgs/development/libraries/glibc/2.13/locales-builder.sh (renamed from pkgs/development/libraries/glibc-2.12/locales-builder.sh)0
-rw-r--r--pkgs/development/libraries/glibc/2.13/locales.nix (renamed from pkgs/development/libraries/glibc-2.12/locales.nix)4
-rw-r--r--pkgs/development/libraries/glibc/2.13/nix-locale-archive.patch (renamed from pkgs/development/libraries/glibc-2.12/nix-locale-archive.patch)0
-rw-r--r--pkgs/development/libraries/glibc/2.13/nss-skip-unavail.patch (renamed from pkgs/development/libraries/glibc-2.12/nss-skip-unavail.patch)0
-rw-r--r--pkgs/development/libraries/glibc/2.13/rpcgen-path.patch (renamed from pkgs/development/libraries/glibc-2.12/rpcgen-path.patch)0
-rw-r--r--pkgs/development/libraries/glibc/2.14/builder.sh55
-rw-r--r--pkgs/development/libraries/glibc/2.14/common.nix219
-rw-r--r--pkgs/development/libraries/glibc/2.14/default.nix97
-rw-r--r--pkgs/development/libraries/glibc/2.14/glibc-elf-localscope.patch82
-rw-r--r--pkgs/development/libraries/glibc/2.14/info.nix26
-rw-r--r--pkgs/development/libraries/glibc/2.14/locales-builder.sh17
-rw-r--r--pkgs/development/libraries/glibc/2.14/locales.nix47
-rw-r--r--pkgs/development/libraries/glibc/2.14/nix-locale-archive.patch116
-rw-r--r--pkgs/development/libraries/glibc/2.14/nss-skip-unavail.patch21
-rw-r--r--pkgs/development/libraries/glibc/2.14/rpcgen-path.patch (renamed from pkgs/development/libraries/glibc-2.9/rpcgen-path.patch)0
-rw-r--r--pkgs/development/libraries/glibc/2.5/binutils-ld.patch (renamed from pkgs/development/libraries/glibc-2.5/binutils-ld.patch)0
-rw-r--r--pkgs/development/libraries/glibc/2.5/builder.sh (renamed from pkgs/development/libraries/glibc-2.5/builder.sh)0
-rw-r--r--pkgs/development/libraries/glibc/2.5/default.nix (renamed from pkgs/development/libraries/glibc-2.5/default.nix)0
-rw-r--r--pkgs/development/libraries/glibc/2.5/glibc-getcwd-param-MAX.patch (renamed from pkgs/development/libraries/glibc-2.5/glibc-getcwd-param-MAX.patch)0
-rw-r--r--pkgs/development/libraries/glibc/2.5/glibc-inline.patch (renamed from pkgs/development/libraries/glibc-2.5/glibc-inline.patch)0
-rw-r--r--pkgs/development/libraries/glibc/2.5/glibc-pwd.patch (renamed from pkgs/development/libraries/glibc-2.5/glibc-pwd.patch)0
-rw-r--r--pkgs/development/libraries/glibc/2.5/make-3-82-fix.patch (renamed from pkgs/development/libraries/glibc-2.5/make-3-82-fix.patch)0
-rw-r--r--pkgs/development/libraries/glibc/2.5/x86-fnstsw.patch (renamed from pkgs/development/libraries/glibc-2.5/x86-fnstsw.patch)0
-rw-r--r--pkgs/development/libraries/glibc/2.7/builder.sh (renamed from pkgs/development/libraries/glibc-2.7/builder.sh)0
-rw-r--r--pkgs/development/libraries/glibc/2.7/default.nix (renamed from pkgs/development/libraries/glibc-2.7/default.nix)0
-rw-r--r--pkgs/development/libraries/glibc/2.7/nss-skip-unavail.patch (renamed from pkgs/development/libraries/glibc-2.7/nss-skip-unavail.patch)0
-rw-r--r--pkgs/development/libraries/glibc/2.9/binutils-2.20.patch (renamed from pkgs/development/libraries/glibc-2.9/binutils-2.20.patch)0
-rw-r--r--pkgs/development/libraries/glibc/2.9/binutils-ld.patch (renamed from pkgs/development/libraries/glibc-2.9/binutils-ld.patch)0
-rw-r--r--pkgs/development/libraries/glibc/2.9/builder.sh (renamed from pkgs/development/libraries/glibc-2.9/builder.sh)0
-rw-r--r--pkgs/development/libraries/glibc/2.9/default.nix (renamed from pkgs/development/libraries/glibc-2.9/default.nix)2
-rw-r--r--pkgs/development/libraries/glibc/2.9/headers.nix (renamed from pkgs/development/libraries/glibc-2.9/headers.nix)0
-rw-r--r--pkgs/development/libraries/glibc/2.9/headersbuilder.sh (renamed from pkgs/development/libraries/glibc-2.9/headersbuilder.sh)0
-rw-r--r--pkgs/development/libraries/glibc/2.9/info.nix (renamed from pkgs/development/libraries/glibc-2.9/info.nix)2
-rw-r--r--pkgs/development/libraries/glibc/2.9/locale-override.patch (renamed from pkgs/development/libraries/glibc-2.9/locale-override.patch)0
-rw-r--r--pkgs/development/libraries/glibc/2.9/locales.nix (renamed from pkgs/development/libraries/glibc-2.9/locales.nix)2
-rw-r--r--pkgs/development/libraries/glibc/2.9/localesbuilder.sh (renamed from pkgs/development/libraries/glibc-2.9/localesbuilder.sh)0
-rw-r--r--pkgs/development/libraries/glibc/2.9/nss-skip-unavail.patch (renamed from pkgs/development/libraries/glibc-2.9/nss-skip-unavail.patch)0
-rw-r--r--pkgs/development/libraries/glibc/2.9/rpcgen-path.patch72
-rw-r--r--pkgs/development/libraries/glibmm/2.28.x.nix4
-rw-r--r--pkgs/development/libraries/glibmm/2.30.x.nix4
-rw-r--r--pkgs/development/libraries/gmp/4.3.2.nix22
-rw-r--r--pkgs/development/libraries/gmp/5.0.3.nix20
-rw-r--r--pkgs/development/libraries/gnutls/default.nix4
-rw-r--r--pkgs/development/libraries/gsm/default.nix2
-rw-r--r--pkgs/development/libraries/gtk+/2.24.x.nix2
-rw-r--r--pkgs/development/libraries/gtk+/3.2.x.nix2
-rw-r--r--pkgs/development/libraries/gtkmm/2.24.x.nix4
-rw-r--r--pkgs/development/libraries/haskell/network/2.3.0.7.nix18
-rw-r--r--pkgs/development/libraries/haskell/syb/0.3.5.nix17
-rw-r--r--pkgs/development/libraries/hawknl/default.nix2
-rw-r--r--pkgs/development/libraries/iniparser/default.nix6
-rw-r--r--pkgs/development/libraries/irrlicht/default.nix4
-rw-r--r--pkgs/development/libraries/isl/default.nix15
-rw-r--r--pkgs/development/libraries/java/geoipjava/default.nix2
-rw-r--r--pkgs/development/libraries/java/gwt-dragdrop/builder.sh2
-rw-r--r--pkgs/development/libraries/java/gwt-widgets/builder.sh2
-rwxr-xr-xpkgs/development/libraries/java/hsqldb/builder.sh2
-rw-r--r--pkgs/development/libraries/java/hydra-ant-logger/default.nix2
-rw-r--r--pkgs/development/libraries/java/jetty-gwt/default.nix2
-rw-r--r--pkgs/development/libraries/java/jetty-util/default.nix2
-rw-r--r--pkgs/development/libraries/java/rhino/default.nix4
-rw-r--r--pkgs/development/libraries/java/saxon/default8.nix2
-rw-r--r--pkgs/development/libraries/java/smack/builder.sh2
-rw-r--r--pkgs/development/libraries/java/swt/builder.sh4
-rw-r--r--pkgs/development/libraries/java/xalanj/default.nix2
-rw-r--r--pkgs/development/libraries/java/xerces/default.nix2
-rw-r--r--pkgs/development/libraries/json-glib/default.nix4
-rw-r--r--pkgs/development/libraries/levmar/default.nix2
-rw-r--r--pkgs/development/libraries/libarchive/default.nix4
-rw-r--r--pkgs/development/libraries/libav/default.nix2
-rw-r--r--pkgs/development/libraries/libdmtx/default.nix4
-rw-r--r--pkgs/development/libraries/libdvdnav/default.nix2
-rw-r--r--pkgs/development/libraries/libdvdread/default.nix2
-rw-r--r--pkgs/development/libraries/libf2c/default.nix2
-rw-r--r--pkgs/development/libraries/libgsf/default.nix2
-rw-r--r--pkgs/development/libraries/libmilter/default.nix2
-rw-r--r--pkgs/development/libraries/libopensc-dnie/default.nix2
-rw-r--r--pkgs/development/libraries/libpcap/default.nix2
-rw-r--r--pkgs/development/libraries/libpng/default.nix4
-rw-r--r--pkgs/development/libraries/libpseudo/default.nix4
-rw-r--r--pkgs/development/libraries/libsigcxx/default.nix10
-rw-r--r--pkgs/development/libraries/libsigsegv/default.nix4
-rw-r--r--pkgs/development/libraries/libtirpc/default.nix22
-rw-r--r--pkgs/development/libraries/libviper/default.nix4
-rw-r--r--pkgs/development/libraries/libvirt/default.nix2
-rw-r--r--pkgs/development/libraries/libvterm/default.nix4
-rw-r--r--pkgs/development/libraries/libwpd/default.nix4
-rw-r--r--pkgs/development/libraries/libwpg/default.nix4
-rw-r--r--pkgs/development/libraries/libxcrypt/default.nix3
-rw-r--r--pkgs/development/libraries/libxcrypt/gcc46.patch18
-rw-r--r--pkgs/development/libraries/libxslt/default.nix2
-rw-r--r--pkgs/development/libraries/mpc/default.nix4
-rw-r--r--pkgs/development/libraries/mpfr/default.nix4
-rw-r--r--pkgs/development/libraries/ncbi/default.nix2
-rw-r--r--pkgs/development/libraries/ncurses/default.nix8
-rw-r--r--pkgs/development/libraries/ncurses/wint_t.patch14
-rw-r--r--pkgs/development/libraries/opencascade/default.nix2
-rw-r--r--pkgs/development/libraries/opencv/changeset_r3190.diff20
-rw-r--r--pkgs/development/libraries/opencv/default.nix4
-rw-r--r--pkgs/development/libraries/opencv/default.nix.edited27
-rw-r--r--pkgs/development/libraries/openssl/darwin-arch.patch22
-rw-r--r--pkgs/development/libraries/openssl/default.nix16
-rw-r--r--pkgs/development/libraries/pango/1.29.x.nix4
-rw-r--r--pkgs/development/libraries/pangomm/2.28.x.nix3
-rw-r--r--pkgs/development/libraries/pcre/default.nix10
-rw-r--r--pkgs/development/libraries/pdf2xml/default.nix2
-rw-r--r--pkgs/development/libraries/phonon/default.nix4
-rw-r--r--pkgs/development/libraries/postgis/default.nix2
-rw-r--r--pkgs/development/libraries/ppl/0.11.nix50
-rw-r--r--pkgs/development/libraries/ppl/default.nix99
-rw-r--r--pkgs/development/libraries/qt-3/default.nix3
-rw-r--r--pkgs/development/libraries/qt-3/qt3-gcc4.6.0.patch23
-rw-r--r--pkgs/development/libraries/qtscriptgenerator/default.nix2
-rw-r--r--pkgs/development/libraries/readline/readline-6.2-patches.nix6
-rw-r--r--pkgs/development/libraries/readline/readline-patches.nix4
-rw-r--r--pkgs/development/libraries/readline/readline6.nix8
-rw-r--r--pkgs/development/libraries/rubberband/default.nix6
-rw-r--r--pkgs/development/libraries/scmccid/default.nix2
-rw-r--r--pkgs/development/libraries/slib/default.nix2
-rw-r--r--pkgs/development/libraries/snack/default.nix2
-rw-r--r--pkgs/development/libraries/speech-tools/default.nix2
-rw-r--r--pkgs/development/libraries/sphinxbase/default.nix4
-rw-r--r--pkgs/development/libraries/suitesparse/default.nix4
-rw-r--r--pkgs/development/libraries/tcp-wrappers/default.nix2
-rw-r--r--pkgs/development/libraries/ti-rpc/default.nix2
-rw-r--r--pkgs/development/libraries/v8/default.nix4
-rw-r--r--pkgs/development/libraries/webkit/default.nix2
-rw-r--r--pkgs/development/libraries/webkit/svn.nix2
-rw-r--r--pkgs/development/libraries/wtk/builder.sh2
-rw-r--r--pkgs/development/libraries/xapian/bindings/1.0.x.nix4
-rw-r--r--pkgs/development/libraries/xapian/bindings/default.nix4
-rw-r--r--pkgs/development/libraries/xine-lib/default.nix1
-rw-r--r--pkgs/development/libraries/xine-lib/zlib126.patch52
-rw-r--r--pkgs/development/libraries/xlibs-wrapper/default.nix2
-rw-r--r--pkgs/development/libraries/zlib/default.nix24
-rw-r--r--pkgs/development/libraries/zlib/no-shared.patch14
-rw-r--r--pkgs/development/libraries/zziplib/default.nix4
-rw-r--r--pkgs/development/misc/avr8-burn-omat/default.nix2
-rw-r--r--pkgs/development/misc/windows-sdk/builder.sh4
-rw-r--r--pkgs/development/ocaml-modules/batteries/default.nix2
-rw-r--r--pkgs/development/ocaml-modules/cryptokit/default.nix2
-rw-r--r--pkgs/development/ocaml-modules/lablgtkmathview/default.nix2
-rw-r--r--pkgs/development/ocaml-modules/sqlite3/default.nix2
-rw-r--r--pkgs/development/perl-modules/DB_File/default.nix2
-rw-r--r--pkgs/development/python-modules/generic/default.nix2
-rw-r--r--pkgs/development/python-modules/xmpppy/default.nix2
-rw-r--r--pkgs/development/ruby-modules/rake/default.nix4
-rw-r--r--pkgs/development/ruby-modules/sqlite3/default.nix2
-rw-r--r--pkgs/development/tools/analysis/checkstyle/default.nix2
-rw-r--r--pkgs/development/tools/analysis/emma/default.nix2
-rw-r--r--pkgs/development/tools/analysis/findbugs/default.nix2
-rw-r--r--pkgs/development/tools/analysis/jdepend/default.nix2
-rw-r--r--pkgs/development/tools/analysis/pmd/default.nix2
-rw-r--r--pkgs/development/tools/analysis/spin/default.nix2
-rw-r--r--pkgs/development/tools/build-managers/apache-ant/from-source.nix4
-rw-r--r--pkgs/development/tools/build-managers/bam/default.nix4
-rw-r--r--pkgs/development/tools/build-managers/buildbot/default.nix2
-rw-r--r--pkgs/development/tools/build-managers/cmake/default.nix14
-rwxr-xr-xpkgs/development/tools/build-managers/cmake/setup-hook.sh36
-rw-r--r--pkgs/development/tools/build-managers/gradle/default.nix2
-rw-r--r--pkgs/development/tools/build-managers/jam/default.nix2
-rw-r--r--pkgs/development/tools/misc/binutils/default.nix32
-rw-r--r--pkgs/development/tools/misc/cbrowser/default.nix2
-rw-r--r--pkgs/development/tools/misc/cppi/default.nix4
-rw-r--r--pkgs/development/tools/misc/cscope/default.nix4
-rw-r--r--pkgs/development/tools/misc/elfutils/default.nix4
-rw-r--r--pkgs/development/tools/misc/global/default.nix2
-rw-r--r--pkgs/development/tools/misc/gnum4/default.nix8
-rw-r--r--pkgs/development/tools/misc/gnum4/readlink-EINVAL.patch18
-rw-r--r--pkgs/development/tools/misc/lsof/default.nix2
-rw-r--r--pkgs/development/tools/misc/ninka/default.nix4
-rw-r--r--pkgs/development/tools/misc/patchelf/0.6.nix16
-rw-r--r--pkgs/development/tools/misc/patchelf/default.nix8
-rw-r--r--pkgs/development/tools/misc/sloccount/default.nix6
-rw-r--r--pkgs/development/tools/misc/strace/default.nix4
-rw-r--r--pkgs/development/tools/misc/unifdef/default.nix2
-rw-r--r--pkgs/development/tools/misc/usb-modeswitch/default.nix2
-rw-r--r--pkgs/development/tools/ocaml/camlidl/default.nix2
-rw-r--r--pkgs/development/tools/ocaml/findlib/default.nix2
-rw-r--r--pkgs/development/tools/parsing/antlr/builder.sh4
-rw-r--r--pkgs/development/tools/parsing/bison/bison-2.5.nix3
-rw-r--r--pkgs/development/tools/parsing/jikespg/builder.sh2
-rw-r--r--pkgs/development/tools/selenium/remote-control/default.nix4
-rw-r--r--pkgs/development/web/csslint/default.nix2
-rw-r--r--pkgs/games/banner/default.nix2
-rw-r--r--pkgs/games/beret/default.nix4
-rw-r--r--pkgs/games/blackshades/default.nix2
-rw-r--r--pkgs/games/blackshadeselite/default.nix2
-rw-r--r--pkgs/games/castle-combat/default.nix2
-rw-r--r--pkgs/games/dwarf-fortress/default.nix4
-rw-r--r--pkgs/games/eduke32/default.nix4
-rw-r--r--pkgs/games/egoboo/default.nix2
-rw-r--r--pkgs/games/exult/default.nix2
-rw-r--r--pkgs/games/flightgear/default.nix2
-rw-r--r--pkgs/games/fsg/default.nix2
-rw-r--r--pkgs/games/icbm3d/default.nix2
-rw-r--r--pkgs/games/instead/default.nix2
-rw-r--r--pkgs/games/keen4/builder.sh4
-rw-r--r--pkgs/games/mars/default.nix4
-rw-r--r--pkgs/games/naev/default.nix2
-rw-r--r--pkgs/games/nethack/default.nix2
-rw-r--r--pkgs/games/neverball/default.nix2
-rw-r--r--pkgs/games/openlierox/default.nix2
-rw-r--r--pkgs/games/orbit/default.nix2
-rw-r--r--pkgs/games/pong3d/default.nix2
-rw-r--r--pkgs/games/privateer/default.nix2
-rw-r--r--pkgs/games/quake3/demo/builder.sh2
-rw-r--r--pkgs/games/quake3/game/default.nix5
-rw-r--r--pkgs/games/quake3/wrapper/builder.sh2
-rw-r--r--pkgs/games/rigsofrods/default.nix4
-rw-r--r--pkgs/games/sauerbraten/default.nix4
-rw-r--r--pkgs/games/simutrans/default.nix4
-rw-r--r--pkgs/games/teetertorture/default.nix2
-rw-r--r--pkgs/games/teeworlds/default.nix6
-rw-r--r--pkgs/games/the-butterfly-effect/default.nix4
-rw-r--r--pkgs/games/thePenguinMachine/default.nix4
-rw-r--r--pkgs/games/trackballs/default.nix21
-rw-r--r--pkgs/games/tremulous/default.nix4
-rw-r--r--pkgs/games/trigger/default.nix2
-rw-r--r--pkgs/games/urbanterror/default.nix4
-rw-r--r--pkgs/games/ut2004demo/make-wrapper.sh2
-rw-r--r--pkgs/games/vectoroids/default.nix2
-rw-r--r--pkgs/games/warsow/default.nix6
-rw-r--r--pkgs/games/xonotic/default.nix4
-rw-r--r--pkgs/games/xsokoban/default.nix2
-rw-r--r--pkgs/games/zangband/default.nix6
-rw-r--r--pkgs/games/zod/default.nix2
-rw-r--r--pkgs/lib/licenses.nix6
-rw-r--r--pkgs/lib/lists.nix5
-rw-r--r--pkgs/misc/cups/default.nix6
-rw-r--r--pkgs/misc/drivers/gutenprint/bin.nix2
-rw-r--r--pkgs/misc/emulators/atari800/builder.sh2
-rw-r--r--pkgs/misc/emulators/darcnes/default.nix2
-rw-r--r--pkgs/misc/emulators/dosbox/default.nix12
-rw-r--r--pkgs/misc/emulators/fakenes/default.nix2
-rw-r--r--pkgs/misc/emulators/mess/default.nix2
-rw-r--r--pkgs/misc/emulators/vice/default.nix2
-rw-r--r--pkgs/misc/foldingathome/default.nix2
-rw-r--r--pkgs/misc/gxemul/default.nix6
-rw-r--r--pkgs/misc/jackaudio/jack1.nix2
-rw-r--r--pkgs/misc/misc.nix3
-rw-r--r--pkgs/misc/my-env/default.nix2
-rw-r--r--pkgs/misc/sane-backends/default.nix2
-rw-r--r--pkgs/misc/sane-backends/snapshot.nix2
-rw-r--r--pkgs/misc/screensavers/electricsheep/default.nix2
-rw-r--r--pkgs/misc/screensavers/rss-glx/builder.sh6
-rw-r--r--pkgs/misc/source-and-tags/default.nix4
-rw-r--r--pkgs/misc/uboot/default.nix5
-rw-r--r--pkgs/misc/uboot/guruplug.nix5
-rw-r--r--pkgs/misc/uboot/nanonote.nix5
-rw-r--r--pkgs/misc/uboot/sheevaplug.nix5
-rw-r--r--pkgs/os-specific/linux/915resolution/default.nix2
-rw-r--r--pkgs/os-specific/linux/acpi-call/default.nix4
-rw-r--r--pkgs/os-specific/linux/ati-drivers/builder.sh6
-rw-r--r--pkgs/os-specific/linux/aufs/2.1.nix2
-rw-r--r--pkgs/os-specific/linux/aufs/2.nix2
-rw-r--r--pkgs/os-specific/linux/aufs/3.nix4
-rw-r--r--pkgs/os-specific/linux/broadcom-sta/default.nix2
-rw-r--r--pkgs/os-specific/linux/cramfsswap/builder.sh2
-rw-r--r--pkgs/os-specific/linux/exmap/default.nix4
-rw-r--r--pkgs/os-specific/linux/firmware/firmware-linux-nonfree/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/ipw2100/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/ipw2200/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/iwlwifi-1000-ucode/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/iwlwifi-3945-ucode/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/version-2.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/iwlwifi-5000-ucode/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/iwlwifi-5150-ucode/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/iwlwifi-6000-ucode/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/iwlwifi-6000g2a-ucode/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/iwlwifi-6000g2b-ucode/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/ralink/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/rt2860/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/rt2870/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/rt73/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/rtl8192c/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/zd1211/default.nix2
-rw-r--r--pkgs/os-specific/linux/fxload/default.nix6
-rw-r--r--pkgs/os-specific/linux/hal/default.nix6
-rw-r--r--pkgs/os-specific/linux/kernel-headers/2.4.nix2
-rw-r--r--pkgs/os-specific/linux/kernel-headers/2.6.18.5.nix25
-rw-r--r--pkgs/os-specific/linux/kernel-headers/2.6.28.nix2
-rw-r--r--pkgs/os-specific/linux/kernel-headers/2.6.32.nix2
-rw-r--r--pkgs/os-specific/linux/kernel-headers/builder.sh9
-rw-r--r--pkgs/os-specific/linux/kernel-headers/default.nix62
-rw-r--r--pkgs/os-specific/linux/kernel/aufs2-33.patch82
-rw-r--r--pkgs/os-specific/linux/kernel/aufs2.1-37.patch368
-rw-r--r--pkgs/os-specific/linux/kernel/builder.sh4
-rw-r--r--pkgs/os-specific/linux/kernel/getline.patch34
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.25.nix163
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.26.nix177
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.27.nix4
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.28.nix227
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.29.nix230
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.31.nix214
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.32.nix4
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.33.nix214
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.34.nix211
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.36.nix209
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.37.nix208
-rw-r--r--pkgs/os-specific/linux/kernel/patches.nix78
-rw-r--r--pkgs/os-specific/linux/klibc/shrunk.nix2
-rw-r--r--pkgs/os-specific/linux/kudzu/builder.sh8
-rw-r--r--pkgs/os-specific/linux/libcap/default.nix2
-rw-r--r--pkgs/os-specific/linux/lsiutil/default.nix2
-rw-r--r--pkgs/os-specific/linux/mingetty/default.nix2
-rw-r--r--pkgs/os-specific/linux/module-init-tools/default.nix21
-rw-r--r--pkgs/os-specific/linux/module-init-tools/module-dir.patch120
-rw-r--r--pkgs/os-specific/linux/nfs-utils/default.nix4
-rw-r--r--pkgs/os-specific/linux/nss_ldap/default.nix2
-rw-r--r--pkgs/os-specific/linux/numactl/default.nix2
-rwxr-xr-xpkgs/os-specific/linux/nvidia-x11/builder-legacy.sh8
-rwxr-xr-xpkgs/os-specific/linux/nvidia-x11/builder.sh20
-rw-r--r--pkgs/os-specific/linux/opengl/xorg-sys/builder.sh2
-rw-r--r--pkgs/os-specific/linux/ov511/ov511-2.30-builder.sh2
-rw-r--r--pkgs/os-specific/linux/ov511/ov511-2.32-builder.sh2
-rw-r--r--pkgs/os-specific/linux/pcmciautils/default.nix2
-rw-r--r--pkgs/os-specific/linux/pmount/default.nix8
-rw-r--r--pkgs/os-specific/linux/qc-usb/builder.sh2
-rw-r--r--pkgs/os-specific/linux/radeontools/default.nix2
-rw-r--r--pkgs/os-specific/linux/sysklogd/builder.sh6
-rw-r--r--pkgs/os-specific/linux/tcp-wrapper/builder.sh10
-rw-r--r--pkgs/os-specific/linux/tunctl/default.nix2
-rw-r--r--pkgs/os-specific/linux/udisks/default.nix25
-rw-r--r--pkgs/os-specific/linux/udisks/purity.patch23
-rw-r--r--pkgs/os-specific/linux/upower/default.nix4
-rw-r--r--pkgs/os-specific/linux/util-linux/default.nix (renamed from pkgs/os-specific/linux/util-linux-ng/default.nix)12
-rw-r--r--pkgs/os-specific/linux/wis-go7007/default.nix8
-rw-r--r--pkgs/os-specific/linux/wpa_supplicant/default.nix4
-rw-r--r--pkgs/os-specific/linux/xf86-input-multitouch/default.nix2
-rw-r--r--pkgs/os-specific/linux/xf86-input-wacom/default.nix2
-rw-r--r--pkgs/os-specific/linux/zen-kernel/2.6.32-zen4.nix75
-rw-r--r--pkgs/os-specific/linux/zen-kernel/2.6.33-zen1.nix78
-rw-r--r--pkgs/os-specific/linux/zen-kernel/config-blocks.nix263
-rw-r--r--pkgs/os-specific/windows/mingw-headers/default.nix2
-rw-r--r--pkgs/os-specific/windows/mingwrt/default.nix2
-rw-r--r--pkgs/os-specific/windows/w32api/default.nix2
-rw-r--r--pkgs/servers/dict/dictd-db-collector.nix2
-rw-r--r--pkgs/servers/dict/dictd-db.nix2
-rw-r--r--pkgs/servers/felix/default.nix2
-rw-r--r--pkgs/servers/felix/remoteshell.nix2
-rw-r--r--pkgs/servers/fingerd/bsd-fingerd/default.nix2
-rw-r--r--pkgs/servers/games/ghost-one/default.nix8
-rw-r--r--pkgs/servers/http/apache-modules/mod_python/default.nix2
-rw-r--r--pkgs/servers/http/apache-modules/tomcat-connectors/builder.sh2
-rw-r--r--pkgs/servers/http/jboss/default.nix2
-rw-r--r--pkgs/servers/http/jboss/jdbc/mysql/builder.sh2
-rw-r--r--pkgs/servers/http/jetty/6.1/bin-builder.sh2
-rw-r--r--pkgs/servers/http/joseki/default.nix4
-rw-r--r--pkgs/servers/http/myserver/default.nix4
-rw-r--r--pkgs/servers/http/tomcat/axis2/builder.sh4
-rw-r--r--pkgs/servers/http/tomcat/jdbc/mysql/builder.sh2
-rw-r--r--pkgs/servers/mail/postfix/default.nix2
-rw-r--r--pkgs/servers/monitoring/zabbix/default.nix6
-rw-r--r--pkgs/servers/portmap/default.nix2
-rw-r--r--pkgs/servers/pulseaudio/default.nix4
-rw-r--r--pkgs/servers/sql/mysql/jdbc/builder.sh2
-rwxr-xr-xpkgs/servers/sql/postgresql/jdbc/builder.sh2
-rw-r--r--pkgs/servers/x11/xorg/builder.sh2
-rw-r--r--pkgs/servers/x11/xorg/imake.sh2
-rw-r--r--pkgs/servers/x11/xorg/overrides.nix2
-rw-r--r--pkgs/servers/xmpp/pyIRCt/default.nix2
-rw-r--r--pkgs/servers/xmpp/pyMAILt/default.nix2
-rw-r--r--pkgs/shells/bash/4.1.nix89
-rw-r--r--pkgs/shells/bash/bash-4.1-patches.nix6
-rw-r--r--pkgs/shells/bash/bash-4.2-patches.nix10
-rw-r--r--pkgs/shells/bash/default.nix (renamed from pkgs/shells/bash/4.2.nix)0
-rw-r--r--pkgs/shells/zsh/default.nix4
-rw-r--r--pkgs/stdenv/adapters.nix15
-rw-r--r--pkgs/stdenv/common-path.nix2
-rw-r--r--pkgs/stdenv/generic/builder.sh30
-rw-r--r--pkgs/stdenv/generic/default.nix30
-rw-r--r--pkgs/stdenv/generic/docs.txt93
-rw-r--r--pkgs/stdenv/generic/setup.sh249
-rw-r--r--pkgs/stdenv/linux/default.nix77
-rw-r--r--pkgs/stdenv/linux/make-bootstrap-tools.nix3
-rw-r--r--pkgs/stdenv/linux/scripts/prehook.sh3
-rwxr-xr-xpkgs/stdenv/mingw/setup.sh21
-rw-r--r--pkgs/stdenv/native/default.nix39
-rw-r--r--pkgs/stdenv/nix/default.nix28
-rw-r--r--pkgs/stdenv/nix/prehook.sh11
-rw-r--r--pkgs/tools/X11/x2vnc/default.nix2
-rw-r--r--pkgs/tools/X11/x2x/default.nix4
-rw-r--r--pkgs/tools/X11/xpra/default.nix2
-rw-r--r--pkgs/tools/admin/tightvnc/builder.sh6
-rw-r--r--pkgs/tools/archivers/cromfs/default.nix25
-rw-r--r--pkgs/tools/archivers/gnutar/default.nix6
-rw-r--r--pkgs/tools/archivers/unarj/default.nix2
-rw-r--r--pkgs/tools/archivers/unzip/5.52.nix18
-rw-r--r--pkgs/tools/archivers/unzip/default.nix (renamed from pkgs/tools/archivers/unzip/6.0.nix)4
-rw-r--r--pkgs/tools/cd-dvd/unetbootin/default.nix6
-rw-r--r--pkgs/tools/compression/bsdiff/builder.sh4
-rw-r--r--pkgs/tools/compression/bzip2/builder.sh2
-rw-r--r--pkgs/tools/compression/bzip2/default.nix10
-rw-r--r--pkgs/tools/compression/upx/default.nix2
-rw-r--r--pkgs/tools/compression/xz/default.nix44
-rw-r--r--pkgs/tools/compression/zdelta/builder.sh2
-rw-r--r--pkgs/tools/filesystems/fsfs/default.nix2
-rw-r--r--pkgs/tools/filesystems/fusesmb/default.nix2
-rw-r--r--pkgs/tools/filesystems/httpfs/default.nix4
-rw-r--r--pkgs/tools/filesystems/squashfs/default.nix19
-rw-r--r--pkgs/tools/filesystems/sshfs-fuse/default.nix2
-rw-r--r--pkgs/tools/graphics/cfdg/default.nix4
-rw-r--r--pkgs/tools/graphics/cuneiform/default.nix2
-rw-r--r--pkgs/tools/graphics/dcraw/default.nix2
-rw-r--r--pkgs/tools/graphics/exiftags/default.nix2
-rw-r--r--pkgs/tools/graphics/glxinfo/default.nix2
-rw-r--r--pkgs/tools/graphics/jhead/default.nix2
-rw-r--r--pkgs/tools/graphics/pdfread/default.nix4
-rw-r--r--pkgs/tools/graphics/ploticus/builder.sh4
-rw-r--r--pkgs/tools/graphics/pngcrush/default.nix3
-rw-r--r--pkgs/tools/graphics/qrdecode/default.nix2
-rw-r--r--pkgs/tools/graphics/transfig/builder.sh4
-rw-r--r--pkgs/tools/graphics/welkin/default.nix2
-rw-r--r--pkgs/tools/misc/autojump/default.nix4
-rw-r--r--pkgs/tools/misc/coreutils/default.nix15
-rw-r--r--pkgs/tools/misc/debootstrap/default.nix4
-rw-r--r--pkgs/tools/misc/dmg2img/default.nix2
-rw-r--r--pkgs/tools/misc/dtach/default.nix2
-rw-r--r--pkgs/tools/misc/expect/default.nix2
-rw-r--r--pkgs/tools/misc/fdupes/default.nix2
-rw-r--r--pkgs/tools/misc/figlet/default.nix2
-rw-r--r--pkgs/tools/misc/grub/1.9x.nix4
-rw-r--r--pkgs/tools/misc/hddtemp/default.nix2
-rw-r--r--pkgs/tools/misc/jdiskreport/builder.sh4
-rw-r--r--pkgs/tools/misc/kermit/default.nix6
-rw-r--r--pkgs/tools/misc/man/conf.patch14
-rw-r--r--pkgs/tools/misc/man/default.nix24
-rw-r--r--pkgs/tools/misc/memtest86/default.nix2
-rw-r--r--pkgs/tools/misc/most/default.nix11
-rw-r--r--pkgs/tools/misc/myhasktags/default.nix2
-rw-r--r--pkgs/tools/misc/parted/2.3.nix5
-rw-r--r--pkgs/tools/misc/parted/default.nix5
-rw-r--r--pkgs/tools/misc/pk2cmd/default.nix2
-rw-r--r--pkgs/tools/misc/qjoypad/default.nix2
-rw-r--r--pkgs/tools/misc/rockbox-utility/default.nix2
-rw-r--r--pkgs/tools/misc/shebangfix/default.nix2
-rw-r--r--pkgs/tools/misc/system-config-printer/default.nix4
-rw-r--r--pkgs/tools/misc/ttf2pt1/default.nix2
-rw-r--r--pkgs/tools/misc/ttmkfdir/default.nix2
-rw-r--r--pkgs/tools/misc/vfdecrypt/default.nix2
-rw-r--r--pkgs/tools/misc/w3c-css-validator/default.nix2
-rw-r--r--pkgs/tools/misc/xdaliclock/default.nix2
-rw-r--r--pkgs/tools/networking/altermime/default.nix2
-rw-r--r--pkgs/tools/networking/bsd-finger/default.nix2
-rw-r--r--pkgs/tools/networking/cntlm/default.nix6
-rw-r--r--pkgs/tools/networking/curl/default.nix2
-rw-r--r--pkgs/tools/networking/ddclient/default.nix2
-rw-r--r--pkgs/tools/networking/dnstop/default.nix2
-rw-r--r--pkgs/tools/networking/eggdrop/default.nix2
-rw-r--r--pkgs/tools/networking/flvstreamer/default.nix2
-rw-r--r--pkgs/tools/networking/getmail/default.nix4
-rw-r--r--pkgs/tools/networking/host/default.nix4
-rw-r--r--pkgs/tools/networking/lftp/default.nix2
-rw-r--r--pkgs/tools/networking/miniupnpc/default.nix2
-rw-r--r--pkgs/tools/networking/miniupnpd/default.nix2
-rw-r--r--pkgs/tools/networking/modemmanager/default.nix4
-rw-r--r--pkgs/tools/networking/netboot/default.nix2
-rw-r--r--pkgs/tools/networking/netkit/tftp/default.nix2
-rw-r--r--pkgs/tools/networking/network-manager-applet/default.nix4
-rw-r--r--pkgs/tools/networking/network-manager/pptp.nix4
-rw-r--r--pkgs/tools/networking/offlineimap/default.nix4
-rw-r--r--pkgs/tools/networking/openssh/default.nix4
-rw-r--r--pkgs/tools/networking/p2p/azureus/builder.sh4
-rw-r--r--pkgs/tools/networking/p2p/bit-tornado/default.nix5
-rw-r--r--pkgs/tools/networking/p2p/rtorrent/default.nix2
-rw-r--r--pkgs/tools/networking/p2p/tahoe-lafs/default.nix2
-rw-r--r--pkgs/tools/networking/philter/default.nix2
-rw-r--r--pkgs/tools/networking/ripmime/default.nix2
-rw-r--r--pkgs/tools/networking/rp-pppoe/default.nix2
-rw-r--r--pkgs/tools/networking/s3cmd/default.nix2
-rw-r--r--pkgs/tools/networking/s3sync/default.nix4
-rw-r--r--pkgs/tools/networking/siege/default.nix2
-rw-r--r--pkgs/tools/networking/slimrat/default.nix2
-rw-r--r--pkgs/tools/networking/stun/default.nix2
-rw-r--r--pkgs/tools/networking/swec/default.nix2
-rw-r--r--pkgs/tools/networking/tcng/default.nix2
-rw-r--r--pkgs/tools/networking/uwimap/default.nix2
-rw-r--r--pkgs/tools/networking/wakelan/default.nix2
-rw-r--r--pkgs/tools/networking/wicd/default.nix2
-rw-r--r--pkgs/tools/package-management/disnix/default.nix6
-rw-r--r--pkgs/tools/package-management/disnix/disnixos/default.nix6
-rw-r--r--pkgs/tools/package-management/nix/default.nix2
-rw-r--r--pkgs/tools/package-management/rpm/default.nix4
-rw-r--r--pkgs/tools/security/bmrsa/11.nix2
-rw-r--r--pkgs/tools/security/chkrootkit/default.nix2
-rw-r--r--pkgs/tools/security/metasploit/3.1.nix4
-rw-r--r--pkgs/tools/security/opensc-dnie-wrapper/default.nix2
-rw-r--r--pkgs/tools/security/pius/default.nix4
-rw-r--r--pkgs/tools/security/seccure/0.4.nix2
-rw-r--r--pkgs/tools/security/ssss/default.nix2
-rw-r--r--pkgs/tools/system/bootchart/default.nix2
-rw-r--r--pkgs/tools/system/cron/default.nix2
-rw-r--r--pkgs/tools/system/dd_rescue/default.nix2
-rw-r--r--pkgs/tools/system/gptfdisk/default.nix4
-rw-r--r--pkgs/tools/system/plan9port/builder.sh2
-rw-r--r--pkgs/tools/system/which/default.nix4
-rw-r--r--pkgs/tools/text/convertlit/default.nix2
-rw-r--r--pkgs/tools/text/dadadodo/default.nix2
-rw-r--r--pkgs/tools/text/diffutils/default.nix6
-rw-r--r--pkgs/tools/text/gawk/default.nix4
-rw-r--r--pkgs/tools/text/gnugrep/default.nix8
-rw-r--r--pkgs/tools/text/qshowdiff/default.nix2
-rw-r--r--pkgs/tools/text/replace/default.nix2
-rw-r--r--pkgs/tools/text/xml/jing/script-builder.sh2
-rw-r--r--pkgs/tools/text/xml/rxp/default.nix2
-rw-r--r--pkgs/tools/text/xml/trang/builder.sh4
-rw-r--r--pkgs/tools/typesetting/asciidoc/default.nix2
-rw-r--r--pkgs/tools/typesetting/halibut/default.nix4
-rw-r--r--pkgs/tools/typesetting/lhs2tex/default.nix4
-rw-r--r--pkgs/tools/typesetting/pdfjam/builder.sh4
-rw-r--r--pkgs/tools/typesetting/pdftk/default.nix2
-rw-r--r--pkgs/tools/typesetting/tex/lazylist/builder.sh2
-rw-r--r--pkgs/tools/typesetting/tex/lkproof/default.nix2
-rw-r--r--pkgs/tools/typesetting/tex/nix/animatedot.sh2
-rw-r--r--pkgs/tools/typesetting/tex/nix/default.nix2
-rw-r--r--pkgs/tools/typesetting/tex/nix/dot2pdf.sh2
-rw-r--r--pkgs/tools/typesetting/tex/nix/dot2ps.sh2
-rw-r--r--pkgs/tools/typesetting/tex/nix/lhs2tex.sh2
-rw-r--r--pkgs/tools/typesetting/tex/nix/run-latex.sh2
-rw-r--r--pkgs/tools/typesetting/tex/pgf/1.x.nix2
-rw-r--r--pkgs/tools/typesetting/tex/pgf/2.x.nix2
-rw-r--r--pkgs/tools/typesetting/tex/polytable/builder.sh6
-rw-r--r--pkgs/tools/typesetting/tex/tetex/default.nix4
-rw-r--r--pkgs/tools/typesetting/tex/tex4ht/default.nix4
-rw-r--r--pkgs/tools/typesetting/tex/texlive/aggregate.nix6
-rw-r--r--pkgs/tools/typesetting/tex/texlive/beamer.nix4
-rw-r--r--pkgs/tools/typesetting/tex/texlive/cm-super.nix12
-rw-r--r--pkgs/tools/typesetting/tex/texlive/context.nix4
-rw-r--r--pkgs/tools/typesetting/tex/texlive/default.nix10
-rw-r--r--pkgs/tools/typesetting/tex/texlive/extra.nix2
-rw-r--r--pkgs/tools/typesetting/tex/texlive/moderncv.nix2
-rw-r--r--pkgs/tools/typesetting/tex/texlive/pgf.nix4
-rw-r--r--pkgs/tools/typesetting/tex/texlive/xcolor.nix8
-rw-r--r--pkgs/tools/virtualization/amazon-ec2-ami-tools/default.nix2
-rw-r--r--pkgs/tools/virtualization/amazon-ec2-api-tools/default.nix2
-rw-r--r--pkgs/tools/virtualization/euca2ools/default.nix2
-rw-r--r--pkgs/top-level/all-packages.nix441
-rw-r--r--pkgs/top-level/make-tarball.nix6
-rw-r--r--pkgs/top-level/python-packages.nix8
-rw-r--r--pkgs/top-level/release-small.nix224
-rw-r--r--pkgs/top-level/release.nix52
951 files changed, 4574 insertions, 5673 deletions
diff --git a/TODO.txt b/TODO.txt
new file mode 100644
index 0000000000000..76f062745156c
--- /dev/null
+++ b/TODO.txt
@@ -0,0 +1,9 @@
+This file contains list of tasks that should be done before merging
+stdenv-updates back into trunk. Notation:
+- TODO
+* In progress
++ Done
+
+urkud:
+- Introduce libiconvOrNull and libiconvOrLibc instead of current 'magic'
+
diff --git a/doc/stdenv.xml b/doc/stdenv.xml
index d8d106e54ad41..1ecf72351f256 100644
--- a/doc/stdenv.xml
+++ b/doc/stdenv.xml
@@ -70,7 +70,7 @@ stdenv.mkDerivation {
     gcc foo.c -o foo
   '';
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp foo $out/bin
   '';
 }</programlisting>
@@ -112,7 +112,7 @@ buildPhase() {
 }
 
 installPhase() {
-  ensureDir $out/bin
+  mkdir -p $out/bin
   cp foo $out/bin
 }
 
@@ -939,14 +939,6 @@ functions.</para>
 <variablelist>
 
   
-  <varlistentry xml:id='fun-ensureDir'>
-    <term><function>ensureDir</function> <replaceable>args</replaceable></term>
-    <listitem><para>Creates the specified directories, including all
-    necessary parent directories, if they do not already
-    exist.</para></listitem>
-  </varlistentry>
-  
-
   <varlistentry xml:id='fun-substitute'>
     <term><function>substitute</function>
     <replaceable>infile</replaceable>
@@ -1062,7 +1054,16 @@ echo @foo@
     That is, no substitution is performed for undefined variables.</para></listitem>
   </varlistentry>
 
-  
+
+  <varlistentry xml:id='fun-substituteAllInPlace'>
+    <term><function>substituteAllInPlace</function>
+    <replaceable>file</replaceable></term>
+    <listitem><para>Like <function>substituteAll</function>, but performs
+    the substitutions in place on the file
+    <replaceable>file</replaceable>.</para></listitem>
+  </varlistentry>
+
+
   <varlistentry xml:id='fun-stripHash'>
     <term><function>stripHash</function>
     <replaceable>path</replaceable></term>
diff --git a/maintainers/docs/cross.txt b/maintainers/docs/cross.txt
index 5ae2787d7998c..32e09086b87e8 100644
--- a/maintainers/docs/cross.txt
+++ b/maintainers/docs/cross.txt
@@ -233,9 +233,9 @@ preConfigure() {
     fi
 
     # Cross compiler evilness
-    ensureDir $out
-    ensureDir $out/arm-linux
-    ensureDir $out/arm-linux/bin
+    mkdir -p $out
+    mkdir -p $out/arm-linux
+    mkdir -p $out/arm-linux/bin
     ln -s $binutilsArm/arm-linux/bin/as $out/arm-linux/bin/as
     ln -s $binutilsArm/arm-linux/bin/ld $out/arm-linux/bin/ld
     ln -s $binutilsArm/arm-linux/bin/ar $out/arm-linux/bin/ar
diff --git a/maintainers/scripts/eval-release.nix b/maintainers/scripts/eval-release.nix
index 7fac2a1c2ef5a..7af2b5b5bd92f 100644
--- a/maintainers/scripts/eval-release.nix
+++ b/maintainers/scripts/eval-release.nix
@@ -17,7 +17,7 @@ let
 
   call = attrs: flip mapAttrs attrs
     (n: v: trace n (
-      if builtins.isFunction v then maybe (v { system = "i686-linux"; })
+      if builtins.isFunction v then maybe (v { system = "x86_64-linux"; })
       else if builtins.isAttrs v then call v
       else null
     ));
diff --git a/pkgs/applications/audio/ardour/default.nix b/pkgs/applications/audio/ardour/default.nix
index c9f0fb98af73e..2a0caf930015a 100644
--- a/pkgs/applications/audio/ardour/default.nix
+++ b/pkgs/applications/audio/ardour/default.nix
@@ -23,7 +23,7 @@ stdenv.mkDerivation {
   ];
 
   buildPhase = ''
-    ensureDir $out
+    mkdir -p $out
     export CXX=g++
     scons PREFIX=$out install
   '';
diff --git a/pkgs/applications/audio/gmu/default.nix b/pkgs/applications/audio/gmu/default.nix
index bdda1c6d8d96c..e75be3e2c2bef 100644
--- a/pkgs/applications/audio/gmu/default.nix
+++ b/pkgs/applications/audio/gmu/default.nix
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
   postInstall = ''
     cp ${keymap}.keymap $out/share/gmu/default.keymap
     cp gmuinput.${conf}.conf $out/share/gmu/gmuinput.conf
-    ensureDir $out/etc/gmu
+    mkdir -p $out/etc/gmu
     cp gmu.${conf}.conf $out/etc/gmu/gmu.conf
   '';
 
diff --git a/pkgs/applications/audio/id3v2/default.nix b/pkgs/applications/audio/id3v2/default.nix
index 7f062b1799fae..8e7f573cc8499 100644
--- a/pkgs/applications/audio/id3v2/default.nix
+++ b/pkgs/applications/audio/id3v2/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
   '';
 
   preInstall = ''
-    ensureDir $out/bin $out/man/man1
+    mkdir -p $out/bin $out/man/man1
   '';
 
   meta = {
diff --git a/pkgs/applications/audio/ladspa-plugins/default.nix b/pkgs/applications/audio/ladspa-plugins/default.nix
index 1557913f40172..b563c850d5286 100644
--- a/pkgs/applications/audio/ladspa-plugins/default.nix
+++ b/pkgs/applications/audio/ladspa-plugins/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation {
 
   postInstall =
     ''
-      ensureDir $out/share/ladspa/
+      mkdir -p $out/share/ladspa/
       ln -sv $out/lib/ladspa $out/share/ladspa/lib
     '';
 
diff --git a/pkgs/applications/audio/ladspa-plugins/ladspah.nix b/pkgs/applications/audio/ladspa-plugins/ladspah.nix
index 8cd3dcc1bfbaa..30ba34af16c52 100644
--- a/pkgs/applications/audio/ladspa-plugins/ladspah.nix
+++ b/pkgs/applications/audio/ladspa-plugins/ladspah.nix
@@ -13,7 +13,7 @@ in
   in with localDefs;
 let
   copyFile = fullDepEntry ("
-    ensureDir \$out/include
+    mkdir -p \$out/include
     cp ${src} \$out/include/ladspa.h
   ") [minInit defEnsureDir];
 in
diff --git a/pkgs/applications/audio/mp3info/default.nix b/pkgs/applications/audio/mp3info/default.nix
index 86ffca4242fa2..d5a8138a50014 100644
--- a/pkgs/applications/audio/mp3info/default.nix
+++ b/pkgs/applications/audio/mp3info/default.nix
@@ -18,8 +18,8 @@ stdenv.mkDerivation rec {
     '';
 
   preInstall =
-    '' ensureDir "$out/bin"
-       ensureDir "$out/man/man1"
+    '' mkdir -p "$out/bin"
+       mkdir -p "$out/man/man1"
     '';
 
   meta = {
diff --git a/pkgs/applications/audio/mpc123/default.nix b/pkgs/applications/audio/mpc123/default.nix
index 4ea26b458a7c0..ccaa428a3f41e 100644
--- a/pkgs/applications/audio/mpc123/default.nix
+++ b/pkgs/applications/audio/mpc123/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
 
   installPhase =
     # XXX: Should install locales too (though there's only 1 available).
-    '' ensureDir "$out/bin"
+    '' mkdir -p "$out/bin"
        cp -v mpc123 "$out/bin"
     '';
 
diff --git a/pkgs/applications/audio/snd/default.nix b/pkgs/applications/audio/snd/default.nix
index e7957e866f1a0..c295767687f6e 100644
--- a/pkgs/applications/audio/snd/default.nix
+++ b/pkgs/applications/audio/snd/default.nix
@@ -40,7 +40,7 @@ rec {
 
   makeDocsWork = fullDepEntry ''
                 # hackish way to make html docs work
-                h="$out/share/snd/html"; ensureDir "$h"; cp *.html "$h"
+                h="$out/share/snd/html"; mkdir -p "$h"; cp *.html "$h"
                 patch -p1 < ${./doc.patch}
                 sed "s@HTML-DIR@$h@" -i index.scm snd-help.c
             '' ["defEnsureDir"];
diff --git a/pkgs/applications/audio/sonic-visualiser/default.nix b/pkgs/applications/audio/sonic-visualiser/default.nix
index d3ac4c4168c8f..3a2beff041332 100644
--- a/pkgs/applications/audio/sonic-visualiser/default.nix
+++ b/pkgs/applications/audio/sonic-visualiser/default.nix
@@ -36,7 +36,7 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out/{bin,share/sonic-visualiser}
+    mkdir -p $out/{bin,share/sonic-visualiser}
     cp sonic-visualiser/sonic-visualiser $out/bin
     cp -r sonic-visualiser/samples $out/share/sonic-visualiser/samples
     wrapProgram $out/bin/sonic-visualiser --prefix LD_LIBRARY_PATH : ${libX11}/lib
diff --git a/pkgs/applications/audio/vkeybd/default.nix b/pkgs/applications/audio/vkeybd/default.nix
index b751e4da33ed1..279820a723fb1 100644
--- a/pkgs/applications/audio/vkeybd/default.nix
+++ b/pkgs/applications/audio/vkeybd/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation  rec {
   buildInputs = [ alsaLib libX11 makeWrapper tcl tk ];
 
   configurePhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     sed -e "s@/usr/local@$out@" -i Makefile
   '';
 
diff --git a/pkgs/applications/audio/xsynth-dssi/default.nix b/pkgs/applications/audio/xsynth-dssi/default.nix
index 528f0b3412c18..0cfbfb4c9bd16 100644
--- a/pkgs/applications/audio/xsynth-dssi/default.nix
+++ b/pkgs/applications/audio/xsynth-dssi/default.nix
@@ -14,8 +14,8 @@ stdenv.mkDerivation  rec {
     ladspaPlugins liblo pkgconfig ];
 
   installPhase = ''
-    ensureDir $out/bin
-    ensureDir $out/lib
+    mkdir -p $out/bin
+    mkdir -p $out/lib
     cp src/Xsynth_gtk $out/bin
     cp src/.libs/* $out/lib
   '';
diff --git a/pkgs/applications/editors/eclipse/default.nix b/pkgs/applications/editors/eclipse/default.nix
index bc53dfc70f329..801efc166daa5 100644
--- a/pkgs/applications/editors/eclipse/default.nix
+++ b/pkgs/applications/editors/eclipse/default.nix
@@ -27,7 +27,7 @@ let
 
       buildCommand = ''
         # Unpack tarball.
-        ensureDir $out
+        mkdir -p $out
         tar xfvz $src -C $out
 
         # Patch binaries.
@@ -47,7 +47,7 @@ let
           --add-flags "-configuration \$HOME/.eclipse/''${productId}_$productVersion/configuration"
 
         # Create desktop item.
-        ensureDir $out/share/applications
+        mkdir -p $out/share/applications
         cp ${desktopItem}/share/applications/* $out/share/applications
       ''; # */
 
diff --git a/pkgs/applications/editors/ed/default.nix b/pkgs/applications/editors/ed/default.nix
index 905cde880edd1..1b3e4e27f5bce 100644
--- a/pkgs/applications/editors/ed/default.nix
+++ b/pkgs/applications/editors/ed/default.nix
@@ -1,11 +1,11 @@
 { fetchurl, stdenv }:
 
 stdenv.mkDerivation rec {
-  name = "ed-1.4";
+  name = "ed-1.5";
 
   src = fetchurl {
     url = "mirror://gnu/ed/${name}.tar.gz";
-    sha256 = "1njgcghms1377csldi1yqjhcpghiii6bshdhnjpqp78sxs2xldnv";
+    sha256 = "18gvhyhwpabmgv4lh21lg8vl3z7acdyhh2mr2kj9g75wksj39pcp";
   };
 
   doCheck = true;
diff --git a/pkgs/applications/editors/elvis/default.nix b/pkgs/applications/editors/elvis/default.nix
index 511e284ed39e0..e1d2ad69b1dd6 100644
--- a/pkgs/applications/editors/elvis/default.nix
+++ b/pkgs/applications/editors/elvis/default.nix
@@ -15,16 +15,16 @@ stdenv.mkDerivation rec {
   '';
 
   preConfigure = ''
-    ensureDir $out/share/man/man1
+    mkdir -p $out/share/man/man1
   '';
 
   installPhase = ''
-    ensureDir $out/bin $out/share/elvis $out/share/elvis/doc
+    mkdir -p $out/bin $out/share/elvis $out/share/elvis/doc
     cp elvis ref elvtags elvfmt $out/bin
     cp -R data/* $out/share/elvis
     cp doc/* $out/share/elvis/doc
 
-    ensureDir $out/share/man/man1
+    mkdir -p $out/share/man/man1
     for a in doc/*.man; do
       cp $a $out/share/man/man1/`basename $a .man`.1
     done
diff --git a/pkgs/applications/editors/emacs-modes/bbdb/default.nix b/pkgs/applications/editors/emacs-modes/bbdb/default.nix
index 52afebc6297bb..ec7a3e8e6002e 100644
--- a/pkgs/applications/editors/emacs-modes/bbdb/default.nix
+++ b/pkgs/applications/editors/emacs-modes/bbdb/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation {
 
   buildInputs = [emacs texinfo ctags];
   configureFlags = "--with-package-dir=$$out/share/emacs/site-lisp";
-  preInstall = "ensureDir $out/info";
+  preInstall = "mkdir -p $out/info";
   installTargets = "install-pkg texinfo";
   postInstall = ''
     mv  $out/info $out/share/
diff --git a/pkgs/applications/editors/emacs-modes/cedet/default.nix b/pkgs/applications/editors/emacs-modes/cedet/default.nix
index 6a91ac496517c..46381dfc648d7 100644
--- a/pkgs/applications/editors/emacs-modes/cedet/default.nix
+++ b/pkgs/applications/editors/emacs-modes/cedet/default.nix
@@ -14,11 +14,11 @@ stdenv.mkDerivation rec {
   checkPhase = "make utest";
 
   installPhase = ''
-    ensureDir "$out/share/emacs/site-lisp"
+    mkdir -p "$out/share/emacs/site-lisp"
     cp -v */*.el */*/*.el */*.elc */*/*.elc "$out/share/emacs/site-lisp"
     chmod a-x "$out/share/emacs/site-lisp/"*
 
-    ensureDir "$out/share/info"
+    mkdir -p "$out/share/info"
     cp -v */*.info* */*/*.info* "$out/share/info"
   '';
 
diff --git a/pkgs/applications/editors/emacs-modes/ecb/default.nix b/pkgs/applications/editors/emacs-modes/ecb/default.nix
index 258c13b8eb70e..f94d594519ced 100644
--- a/pkgs/applications/editors/emacs-modes/ecb/default.nix
+++ b/pkgs/applications/editors/emacs-modes/ecb/default.nix
@@ -21,10 +21,10 @@ stdenv.mkDerivation rec {
   '';
 
   installPhase = ''
-    ensureDir "$out/share/emacs/site-lisp"
+    mkdir -p "$out/share/emacs/site-lisp"
     cp -rv *.el *.elc ecb-images "$out/share/emacs/site-lisp"
 
-    ensureDir "$out/share/info"
+    mkdir -p "$out/share/info"
     cp -v info-help/*.info* "$out/share/info"
   '';
 
diff --git a/pkgs/applications/editors/emacs-modes/emms/default.nix b/pkgs/applications/editors/emacs-modes/emms/default.nix
index 3a97703143663..5439ba9e4d6eb 100644
--- a/pkgs/applications/editors/emacs-modes/emms/default.nix
+++ b/pkgs/applications/editors/emacs-modes/emms/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
                           s|/usr/include/taglib|${taglib}/include/taglib|g ;
                           s|/usr/lib|${taglib}/lib|g ;
                           s|^all:\(.*\)\$|all:\1 emms-print-metadata|g"
-    ensureDir "$out/share/man/man1"
+    mkdir -p "$out/share/man/man1"
 
     sed -i "emms-player-mpg321-remote.el" \
         -e 's|emms-player-mpg321-remote-command[[:blank:]]\+"mpg321"|emms-player-mpg321-remote-command "${mpg321}/bin/mpg321"|g'
@@ -45,7 +45,7 @@ stdenv.mkDerivation rec {
   '';
 
   postInstall = ''
-    ensureDir "$out/bin" && cp emms-print-metadata "$out/bin"
+    mkdir -p "$out/bin" && cp emms-print-metadata "$out/bin"
   '';
 
   meta = {
diff --git a/pkgs/applications/editors/emacs-modes/haskell/default.nix b/pkgs/applications/editors/emacs-modes/haskell/default.nix
index 5813fde815f8c..b73d91b611c83 100644
--- a/pkgs/applications/editors/emacs-modes/haskell/default.nix
+++ b/pkgs/applications/editors/emacs-modes/haskell/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   buildInputs = [emacs];
 
   installPhase = ''
-    ensureDir "$out/share/emacs/site-lisp"
+    mkdir -p "$out/share/emacs/site-lisp"
     cp *.el *.elc *.hs "$out/share/emacs/site-lisp/"
   '';
 
diff --git a/pkgs/applications/editors/emacs-modes/hol_light/default.nix b/pkgs/applications/editors/emacs-modes/hol_light/default.nix
index 9dba1d599fff4..24eba20be6cc5 100644
--- a/pkgs/applications/editors/emacs-modes/hol_light/default.nix
+++ b/pkgs/applications/editors/emacs-modes/hol_light/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation {
 
   installPhase = ''
     DEST=$out/share/emacs/site-lisp
-    ensureDir $DEST
+    mkdir -p $DEST
     cp -a * $DEST
   '';
 
diff --git a/pkgs/applications/editors/emacs-modes/jdee/default.nix b/pkgs/applications/editors/emacs-modes/jdee/default.nix
index 2d93e782048a6..02f60d0d698d5 100644
--- a/pkgs/applications/editors/emacs-modes/jdee/default.nix
+++ b/pkgs/applications/editors/emacs-modes/jdee/default.nix
@@ -23,7 +23,7 @@ in
     ];
 
     configurePhase = ''
-      ensureDir "dist"
+      mkdir -p "dist"
       cat > build.properties <<EOF
         dist.lisp.dir = dist/share/emacs/site-lisp
         dist.java.lib.dir = dist/lib/java
@@ -50,7 +50,7 @@ in
     installPhase = ''
       ant install
 
-      ensureDir "$out/share/${name}"
+      mkdir -p "$out/share/${name}"
       cp -rv java/bsh-commands "$out/share/${name}"
 
       # Move everything that's not a JAR to $datadir.  This includes
diff --git a/pkgs/applications/editors/emacs-modes/org/default.nix b/pkgs/applications/editors/emacs-modes/org/default.nix
index f3843dc51697c..fb4de650ee01f 100644
--- a/pkgs/applications/editors/emacs-modes/org/default.nix
+++ b/pkgs/applications/editors/emacs-modes/org/default.nix
@@ -29,10 +29,10 @@ stdenv.mkDerivation rec {
   installPhase =
     '' make install install-info
 
-       ensureDir "$out/share/doc/${name}"
+       mkdir -p "$out/share/doc/${name}"
        cp -v doc/org*.{html,pdf,txt} "$out/share/doc/${name}"
 
-       ensureDir "$out/share/org"
+       mkdir -p "$out/share/org"
        cp -R contrib "$out/share/org/contrib"
     '';
 
diff --git a/pkgs/applications/editors/emacs-modes/quack/default.nix b/pkgs/applications/editors/emacs-modes/quack/default.nix
index 317f121f36488..86371890db153 100644
--- a/pkgs/applications/editors/emacs-modes/quack/default.nix
+++ b/pkgs/applications/editors/emacs-modes/quack/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation {
   buildPhase = ''
     emacsDir="$out/share/emacs/site-lisp"
 
-    ensureDir "$emacsDir"
+    mkdir -p "$emacsDir"
     cp -v "$src" "$emacsDir/quack.el"
     emacs --batch -f batch-byte-compile "$emacsDir/quack.el"
   '';
diff --git a/pkgs/applications/editors/emacs-modes/rudel/default.nix b/pkgs/applications/editors/emacs-modes/rudel/default.nix
index 9bb7870fb5a12..787f5df6eb049 100644
--- a/pkgs/applications/editors/emacs-modes/rudel/default.nix
+++ b/pkgs/applications/editors/emacs-modes/rudel/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation
 
   installPhase = ''
     for n in . obby zeroconf jupiter; do
-      ensureDir "$out/share/emacs/site-lisp/$n";
+      mkdir -p "$out/share/emacs/site-lisp/$n";
       cp $n/*.el "$out/share/emacs/site-lisp/$n/";
     done
     install -D -m444 doc/card.pdf "$out/share/doc/rudel/card.pdf"
diff --git a/pkgs/applications/editors/emacs-modes/scala-mode/default.nix b/pkgs/applications/editors/emacs-modes/scala-mode/default.nix
index 3b6361b9ef76d..71a2993aba818 100644
--- a/pkgs/applications/editors/emacs-modes/scala-mode/default.nix
+++ b/pkgs/applications/editors/emacs-modes/scala-mode/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ emacs ];
 
   installPhase =
-    '' ensureDir "$out/share/emacs/site-lisp"
+    '' mkdir -p "$out/share/emacs/site-lisp"
        cp -v *.el *.elc "$out/share/emacs/site-lisp"
     '';
 
diff --git a/pkgs/applications/editors/emacs-modes/session-management-for-emacs/default.nix b/pkgs/applications/editors/emacs-modes/session-management-for-emacs/default.nix
index c78d40bcb5fe8..08fb64002a097 100644
--- a/pkgs/applications/editors/emacs-modes/session-management-for-emacs/default.nix
+++ b/pkgs/applications/editors/emacs-modes/session-management-for-emacs/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   buildInputs = [emacs];
   
   installPhase = ''
-    ensureDir "$out/share/emacs/site-lisp"
+    mkdir -p "$out/share/emacs/site-lisp"
     cp lisp/*.el "$out/share/emacs/site-lisp/"
   '';
 
diff --git a/pkgs/applications/editors/jedit/default.nix b/pkgs/applications/editors/jedit/default.nix
index 5349f10c0c36d..194f13a090cd8 100644
--- a/pkgs/applications/editors/jedit/default.nix
+++ b/pkgs/applications/editors/jedit/default.nix
@@ -17,19 +17,19 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out/share/jEdit
+    mkdir -p $out/share/jEdit
     cp build/jedit.jar $out/share/jEdit
-    ensureDir $out/share/jEdit/modes
+    mkdir -p $out/share/jEdit/modes
     cp -r modes/* $out/share/jEdit/modes
-    ensureDir $out/share/jEdit/icons
+    mkdir -p $out/share/jEdit/icons
     cp -r icons/* $out/share/jEdit/icons
-    ensureDir $out/share/jEdit/macros
+    mkdir -p $out/share/jEdit/macros
     cp -r macros/* $out/share/jEdit/macros
-    ensureDir $out/share/jEdit/doc
+    mkdir -p $out/share/jEdit/doc
     cp -r doc/* $out/share/jEdit/doc
     
     sed -i "s|Icon=.*|Icon=$out/share/jEdit/icons/jedit-icon48.png|g" package-files/linux/deb/jedit.desktop
-    ensureDir $out/share/applications
+    mkdir -p $out/share/applications
     mv package-files/linux/deb/jedit.desktop $out/share/applications/jedit.desktop
 
     patch package-files/linux/jedit << EOF
@@ -39,7 +39,7 @@ stdenv.mkDerivation {
     > 
     EOF
     sed -i "s|/usr/share/jEdit/@jar.filename@|$out/share/jEdit/jedit.jar|g" package-files/linux/jedit
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp package-files/linux/jedit $out/bin/jedit
     chmod +x $out/bin/jedit
   '';
diff --git a/pkgs/applications/editors/jedit/wrapper.nix b/pkgs/applications/editors/jedit/wrapper.nix
index 8af3d96918d8f..1126a7278d6cd 100644
--- a/pkgs/applications/editors/jedit/wrapper.nix
+++ b/pkgs/applications/editors/jedit/wrapper.nix
@@ -8,7 +8,7 @@ stdenv.mkDerivation {
     phases = "buildPhase";
 
     buildPhase = "
-ensureDir \$out/bin
+mkdir -p \$out/bin
 cat > \$out/bin/${jedit.name} << EOF
 #!/bin/sh
 exec $java -jar $jeditjar \\$*
diff --git a/pkgs/applications/editors/nedit/builder.sh b/pkgs/applications/editors/nedit/builder.sh
index 51b5f1836546b..15706b0c37dd2 100644
--- a/pkgs/applications/editors/nedit/builder.sh
+++ b/pkgs/applications/editors/nedit/builder.sh
@@ -3,7 +3,7 @@ source $stdenv/setup
 export NIX_CFLAGS_COMPILE="-DBUILD_UNTESTED_NEDIT -L$motif/lib $NIX_CFLAGS_COMPILE"
 
 installPhase() {
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp -p source/nedit source/nc $out/bin
 }
 
diff --git a/pkgs/applications/editors/nvi/default.nix b/pkgs/applications/editors/nvi/default.nix
index c759f977b0d48..81e0dd35db950 100644
--- a/pkgs/applications/editors/nvi/default.nix
+++ b/pkgs/applications/editors/nvi/default.nix
@@ -29,7 +29,7 @@ stdenv.mkDerivation rec {
   '';
 
   installPhase = ''
-    ensureDir $out/bin $out/share/vi/catalog
+    mkdir -p $out/bin $out/share/vi/catalog
     for a in dutch english french german ru_SU.KOI8-R spanish swedish; do
       cp ../catalog/$a $out/share/vi/catalog
     done
@@ -38,7 +38,7 @@ stdenv.mkDerivation rec {
     ln -s $out/bin/nvi $out/bin/ex
     ln -s $out/bin/nvi $out/bin/view
 
-    ensureDir $out/share/man/man1
+    mkdir -p $out/share/man/man1
     cp ../docs/USD.doc/vi.man/vi.1 $out/share/man/man1/nvi.1
     ln -s $out/share/man/man1/nvi.1 $out/share/man/man1/vi
     ln -s $out/share/man/man1/nvi.1 $out/share/man/man1/ex
diff --git a/pkgs/applications/graphics/ImageMagick/default.nix b/pkgs/applications/graphics/ImageMagick/default.nix
index a4bd960655cd4..cbab2da551a97 100644
--- a/pkgs/applications/graphics/ImageMagick/default.nix
+++ b/pkgs/applications/graphics/ImageMagick/default.nix
@@ -12,20 +12,19 @@
 , libtool
 , jasper
 , libX11
-, xz
 , tetex ? null
 , librsvg ? null
 }:
 
 let
-  version = "6.6.9-4";
+  version = "6.7.5-3";
 in
 stdenv.mkDerivation rec {
   name = "ImageMagick-${version}";
 
   src = fetchurl {
     url = "mirror://imagemagick/${name}.tar.xz";
-    sha256 = "035j3i3cm29bwc9lipn838gznswrc69g7mwh8h9jj24ss2dmqrf1";
+    sha256 = "0m0sa4jxsvm8pf9nfvkzlbzq13d1lj15lfz6jif12l6ywyh2c1cs";
   };
 
   configureFlags = ''
@@ -41,8 +40,6 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ tetex graphviz ];
 
-  buildNativeInputs = [ xz ];
-
   preConfigure = if tetex != null then
     ''
       export DVIDecodeDelegate=${tetex}/bin/dvips
diff --git a/pkgs/applications/graphics/dia/default.nix b/pkgs/applications/graphics/dia/default.nix
index f9579336d2cd9..f0c666b14ea0d 100644
--- a/pkgs/applications/graphics/dia/default.nix
+++ b/pkgs/applications/graphics/dia/default.nix
@@ -1,6 +1,6 @@
 {stdenv, fetchurl_gnome, gtk, pkgconfig, perl, perlXMLParser, libxml2, gettext
 , python, libxml2Python, docbook5, docbook_xsl, libxslt, intltool, libart_lgpl
-, withGNOME ? false, libgnomeui, xz }:
+, withGNOME ? false, libgnomeui }:
 
 stdenv.mkDerivation rec {
   name = src.pkgname;
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
       libxslt docbook_xsl libart_lgpl
     ] ++ stdenv.lib.optional withGNOME libgnomeui;
 
-  buildNativeInputs = [ pkgconfig intltool perl xz ];
+  buildNativeInputs = [ pkgconfig intltool perl ];
 
   configureFlags = stdenv.lib.optionalString withGNOME "--enable-gnome";
 
diff --git a/pkgs/applications/graphics/gimp/plugins/default.nix b/pkgs/applications/graphics/gimp/plugins/default.nix
index 3c900ca1eba24..b80d27bfcf9b3 100644
--- a/pkgs/applications/graphics/gimp/plugins/default.nix
+++ b/pkgs/applications/graphics/gimp/plugins/default.nix
@@ -15,11 +15,11 @@ let
     prePhases = "extraLib";
     extraLib = ''
       installScripts(){
-        ensureDir ${targetScriptDir};
+        mkdir -p ${targetScriptDir};
         for p in "$@"; do cp "$p" ${targetScriptDir}; done
       }
       installPlugins(){
-        ensureDir ${targetPluginDir};
+        mkdir -p ${targetPluginDir};
         for p in "$@"; do cp "$p" ${targetPluginDir}; done
       }
     '';
@@ -137,7 +137,7 @@ rec {
       url = http://registry.gimp.org/files/gimp-lqr-plugin-0.6.1.tar.bz2;
       sha256 = "00hklkpcimcbpjly4rjhfipaw096cpy768g9wixglwrsyqhil7l9";
     };
-    #postInstall = ''ensureDir $out/nix-support; echo "${libLQR}" > "$out/nix-support/propagated-user-env-packages"'';
+    #postInstall = ''mkdir -p $out/nix-support; echo "${libLQR}" > "$out/nix-support/propagated-user-env-packages"'';
     installPhase = "installPlugins src/gimp-lqr-plugin";
   };
 
@@ -190,7 +190,7 @@ rec {
     };
     installPhase = "
       installPlugins ufraw-gimp
-      ensureDir $out/bin
+      mkdir -p $out/bin
       cp ufraw $out/bin
     ";
   };
@@ -209,7 +209,7 @@ rec {
 
     installPhase = "
       installPlugins gimplensfun
-      ensureDir $out/bin
+      mkdir -p $out/bin
       cp gimplensfun $out/bin
     ";
 
diff --git a/pkgs/applications/graphics/jbrout/default.nix b/pkgs/applications/graphics/jbrout/default.nix
index 7c3826369ee98..dc397a614d3d5 100644
--- a/pkgs/applications/graphics/jbrout/default.nix
+++ b/pkgs/applications/graphics/jbrout/default.nix
@@ -20,7 +20,7 @@ buildPythonPackage {
   '';
 
   postInstall = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     echo '#!/bin/sh' > $out/bin/jbrout
     echo "python $out/lib/python2.7/site-packages/jbrout-src-py2.7.egg/jbrout/jbrout.py" >> $out/bin/jbrout
     chmod +x $out/bin/jbrout
diff --git a/pkgs/applications/graphics/meshlab/default.nix b/pkgs/applications/graphics/meshlab/default.nix
index 8ddaf9bc2792a..9b39d8e8f1f7b 100644
--- a/pkgs/applications/graphics/meshlab/default.nix
+++ b/pkgs/applications/graphics/meshlab/default.nix
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
   '';
 
   installPhase = ''
-    ensureDir $out/opt/meshlab $out/bin $out/lib
+    mkdir -p $out/opt/meshlab $out/bin $out/lib
     pushd distrib
     cp -R * $out/opt/meshlab
     popd
diff --git a/pkgs/applications/graphics/minidjvu/default.nix b/pkgs/applications/graphics/minidjvu/default.nix
index 8f7ba7929147a..e3c6deddb2954 100644
--- a/pkgs/applications/graphics/minidjvu/default.nix
+++ b/pkgs/applications/graphics/minidjvu/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
   buildInputs = [ libtiff gettext];
 
   preInstall = ''
-    ensureDir $out/lib
+    mkdir -p $out/lib
   '';
 
   meta = {
diff --git a/pkgs/applications/graphics/pinta/default.nix b/pkgs/applications/graphics/pinta/default.nix
index 12f01adc83005..349982bc24cb3 100644
--- a/pkgs/applications/graphics/pinta/default.nix
+++ b/pkgs/applications/graphics/pinta/default.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation {
 
   # Very ugly - I don't know enough Mono to improve this. Isn't there any rpath in binaries?
   installPhase = ''
-    ensureDir $out/lib/pinta $out/bin
+    mkdir -p $out/lib/pinta $out/bin
     cp bin/*.{dll,exe} $out/lib/pinta
     cat > $out/bin/pinta << EOF
     #!/bin/sh
diff --git a/pkgs/applications/graphics/rawtherapee/default.nix b/pkgs/applications/graphics/rawtherapee/default.nix
index eda187cbf2358..4b61ac740cb90 100644
--- a/pkgs/applications/graphics/rawtherapee/default.nix
+++ b/pkgs/applications/graphics/rawtherapee/default.nix
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
   cmakeFlags = [ "-DWITH_RAWZOR=OFF" ];
 
   installPhase = ''
-    ensureDir $out/bin $out/lib
+    mkdir -p $out/bin $out/lib
     cp rtgui/rt $out/bin
     # Weird kind of path reference
     cp -r ../release/* $out/bin
diff --git a/pkgs/applications/graphics/wings/default.nix b/pkgs/applications/graphics/wings/default.nix
index de9bc1dd7d4f8..9e6d6fe492a3e 100644
--- a/pkgs/applications/graphics/wings/default.nix
+++ b/pkgs/applications/graphics/wings/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ erlang esdl ];
 
   installPhase = ''
-    ensureDir $out/bin $out/lib/${name}/ebin
+    mkdir -p $out/bin $out/lib/${name}/ebin
     cp ebin/* $out/lib/${name}/ebin
     cp -R fonts textures shaders plugins $out/lib/$name
     cat << EOF > $out/bin/wings
diff --git a/pkgs/applications/graphics/xaos/default.nix b/pkgs/applications/graphics/xaos/default.nix
index a746eb86b940e..307c947792961 100644
--- a/pkgs/applications/graphics/xaos/default.nix
+++ b/pkgs/applications/graphics/xaos/default.nix
@@ -22,7 +22,7 @@ rec {
 
   preConfigure = a.fullDepEntry (''
     sed -e s@/usr/@"$out/"@g -i configure $(find . -name 'Makefile*')
-    ensureDir $out/share/locale
+    mkdir -p $out/share/locale
   '') ["doUnpack" "minInit" "defEnsureDir"];
       
   name = "xaos-" + version;
diff --git a/pkgs/applications/misc/adobe-reader/builder.sh b/pkgs/applications/misc/adobe-reader/builder.sh
index cd4bebfe9ad0f..1f4844a22c46e 100644
--- a/pkgs/applications/misc/adobe-reader/builder.sh
+++ b/pkgs/applications/misc/adobe-reader/builder.sh
@@ -3,7 +3,7 @@ source $stdenv/setup
 echo "unpacking $src..."
 tar xvfa $src
 
-ensureDir $out/Adobe/Reader9
+mkdir -p $out/Adobe/Reader9
 
 echo "unpacking reader..."
 set +e
@@ -24,5 +24,5 @@ substituteInPlace $out/Adobe/Reader*/bin/acroread \
     --replace /bin/ls $(type -P ls) \
     --replace xargs "xargs -r"
 
-ensureDir $out/bin
+mkdir -p $out/bin
 ln -s $out/Adobe/Reader*/bin/acroread $out/bin/acroread
diff --git a/pkgs/applications/misc/audio/wavesurfer/default.nix b/pkgs/applications/misc/audio/wavesurfer/default.nix
index ab22312e9033f..caaa5133c754e 100644
--- a/pkgs/applications/misc/audio/wavesurfer/default.nix
+++ b/pkgs/applications/misc/audio/wavesurfer/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
   buildInputs = [ snack tcl tk makeWrapper ];
 
   installPhase = ''
-    ensureDir $out/{bin,nix-support,share/wavesurfer/}
+    mkdir -p $out/{bin,nix-support,share/wavesurfer/}
     mv doc $out/share/wavesurfer
     mv * $out/nix-support
     ln -s $out/{nix-support,bin}/wavesurfer.tcl
diff --git a/pkgs/applications/misc/bitcoin/default.nix b/pkgs/applications/misc/bitcoin/default.nix
index d56ebe6b17f1e..de74cd6abd9a6 100644
--- a/pkgs/applications/misc/bitcoin/default.nix
+++ b/pkgs/applications/misc/bitcoin/default.nix
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
   '';
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp bitcoin-qt $out/bin
     cp src/bitcoind $out/bin
   '';
diff --git a/pkgs/applications/misc/calibre/default.nix b/pkgs/applications/misc/calibre/default.nix
index b8100fbd70937..9ee87fe306256 100644
--- a/pkgs/applications/misc/calibre/default.nix
+++ b/pkgs/applications/misc/calibre/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
 
   inherit python;
 
-  buildNativeInputs = [ makeWrapper xz pkgconfig ];
+  buildNativeInputs = [ makeWrapper pkgconfig ];
 
   buildInputs =
     [ python pyqt4 sip popplerQt4 libpng imagemagick libjpeg
diff --git a/pkgs/applications/misc/djvulibre/default.nix b/pkgs/applications/misc/djvulibre/default.nix
index b1001976ea042..e22dce72b6289 100644
--- a/pkgs/applications/misc/djvulibre/default.nix
+++ b/pkgs/applications/misc/djvulibre/default.nix
@@ -1,5 +1,4 @@
-{ stdenv, fetchurl, lib, useQt3 ? false, libjpeg, libtiff, libpng, ghostscript
-, libungif, zlib, x11, libX11, mesa, qt3 }:
+{ stdenv, fetchurl, libjpeg, libtiff, libpng, ghostscript, libungif, zlib }:
 
 stdenv.mkDerivation rec {
   name = "djvulibre-3.5.24";
@@ -9,12 +8,14 @@ stdenv.mkDerivation rec {
     sha256 = "0d1592cmc7scg2jzah47mnvbqldhxb1x9vxm7y64a3iasa0lqwy0";
   };
 
-  buildInputs = [ libjpeg libtiff libpng ghostscript zlib libungif ] ++
-    stdenv.lib.optionals useQt3 [qt3 libX11 x11 mesa];
+  buildInputs = [ libjpeg libtiff libpng ghostscript zlib libungif ];
+
+  patches = [ ./gcc-4.6.patch ];
 
   meta = {
     description = "A library and viewer for the DJVU file format for scanned images";
     homepage = http://djvu.sourceforge.net;
-    maintainers = [ lib.maintainers.urkud ];
+    maintainers = [ stdenv.lib.maintainers.urkud ];
+    platforms = stdenv.lib.platforms.all;
   };
 }
diff --git a/pkgs/applications/misc/djvulibre/gcc-4.6.patch b/pkgs/applications/misc/djvulibre/gcc-4.6.patch
new file mode 100644
index 0000000000000..48fbc2bc7acac
--- /dev/null
+++ b/pkgs/applications/misc/djvulibre/gcc-4.6.patch
@@ -0,0 +1,658 @@
+commit 3341545edba359b292a8ef6db1b7d342caf3dcf1
+Author: Leon Bottou <leon@bottou.org>
+Date:   Wed May 4 21:25:35 2011 -0700
+
+    Added include <stddef.h> for gcc-4.6
+
+diff --git a/libdjvu/BSByteStream.cpp b/libdjvu/BSByteStream.cpp
+index b762ccf..d662ab0 100644
+--- a/libdjvu/BSByteStream.cpp
++++ b/libdjvu/BSByteStream.cpp
+@@ -62,6 +62,7 @@
+ 
+ // - Author: Leon Bottou, 07/1998
+ 
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+diff --git a/libdjvu/BSEncodeByteStream.cpp b/libdjvu/BSEncodeByteStream.cpp
+index 5d80e51..68bc3e3 100644
+--- a/libdjvu/BSEncodeByteStream.cpp
++++ b/libdjvu/BSEncodeByteStream.cpp
+@@ -71,6 +71,7 @@
+ #include "GOS.h"
+ #endif
+ 
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+diff --git a/libdjvu/ByteStream.cpp b/libdjvu/ByteStream.cpp
+index 158c33c..be01847 100644
+--- a/libdjvu/ByteStream.cpp
++++ b/libdjvu/ByteStream.cpp
+@@ -73,6 +73,7 @@
+ #include "GOS.h"
+ #include "GURL.h"
+ #include "DjVuMessage.h"
++#include <stddef.h>
+ #include <fcntl.h>
+ #if defined(WIN32) || defined(__CYGWIN32__)
+ # include <io.h>
+diff --git a/libdjvu/DjVuFileCache.cpp b/libdjvu/DjVuFileCache.cpp
+index 6b1e85d..7d7a192 100644
+--- a/libdjvu/DjVuFileCache.cpp
++++ b/libdjvu/DjVuFileCache.cpp
+@@ -63,6 +63,7 @@
+ #include "DjVuFileCache.h"
+ #include "debug.h"
+ 
++#include <stddef.h>
+ #include <stdlib.h>
+ 
+ 
+diff --git a/libdjvu/DjVuGlobal.cpp b/libdjvu/DjVuGlobal.cpp
+index e6d3cec..df9278e 100644
+--- a/libdjvu/DjVuGlobal.cpp
++++ b/libdjvu/DjVuGlobal.cpp
+@@ -76,6 +76,8 @@
+ #include "GThreads.h"
+ #include "GException.h"
+ #include "GContainer.h"
++
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+diff --git a/libdjvu/DjVuGlobalMemory.cpp b/libdjvu/DjVuGlobalMemory.cpp
+index 3c6012c..c8ba309 100644
+--- a/libdjvu/DjVuGlobalMemory.cpp
++++ b/libdjvu/DjVuGlobalMemory.cpp
+@@ -67,6 +67,8 @@
+ 
+ #include "DjVuGlobal.h"
+ #include "GException.h"
++
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include "debug.h"
+diff --git a/libdjvu/DjVuMessage.cpp b/libdjvu/DjVuMessage.cpp
+index 6f5a735..1726025 100644
+--- a/libdjvu/DjVuMessage.cpp
++++ b/libdjvu/DjVuMessage.cpp
+@@ -71,6 +71,7 @@
+ #include "debug.h"
+ #include <ctype.h>
+ #include <string.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ #ifdef WIN32
+ # include <tchar.h>
+diff --git a/libdjvu/DjVuMessageLite.cpp b/libdjvu/DjVuMessageLite.cpp
+index b8c1010..5daa9d9 100644
+--- a/libdjvu/DjVuMessageLite.cpp
++++ b/libdjvu/DjVuMessageLite.cpp
+@@ -73,8 +73,8 @@
+ #include "debug.h"
+ #include <ctype.h>
+ #include <string.h>
++#include <stddef.h>
+ #include <stdlib.h>
+-// #include <stdio.h>
+ #ifdef WIN32
+ #include <tchar.h>
+ #include <windows.h>
+diff --git a/libdjvu/DjVuPalette.cpp b/libdjvu/DjVuPalette.cpp
+index c489f7b..76b0bf4 100644
+--- a/libdjvu/DjVuPalette.cpp
++++ b/libdjvu/DjVuPalette.cpp
+@@ -64,6 +64,8 @@
+ #include "ByteStream.h"
+ #include "BSByteStream.h"
+ #include "DjVuPalette.h"
++
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <math.h>
+ 
+diff --git a/libdjvu/DjVuPort.h b/libdjvu/DjVuPort.h
+index f6a92f6..e2b3125 100644
+--- a/libdjvu/DjVuPort.h
++++ b/libdjvu/DjVuPort.h
+@@ -65,6 +65,7 @@
+ 
+ #include "GThreads.h"
+ #include "GURL.h"
++#include "stddef.h"
+ 
+ #ifdef HAVE_NAMESPACES
+ namespace DJVU {
+diff --git a/libdjvu/DjVuToPS.cpp b/libdjvu/DjVuToPS.cpp
+index 5517bf3..6914ff9 100644
+--- a/libdjvu/DjVuToPS.cpp
++++ b/libdjvu/DjVuToPS.cpp
+@@ -72,6 +72,7 @@
+ #include "GPixmap.h"
+ #include "debug.h"
+ #include <stdarg.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <time.h>
+diff --git a/libdjvu/GBitmap.cpp b/libdjvu/GBitmap.cpp
+index ab5c0de..797edcc 100644
+--- a/libdjvu/GBitmap.cpp
++++ b/libdjvu/GBitmap.cpp
+@@ -66,6 +66,8 @@
+ #include "GString.h"
+ #include "GThreads.h"
+ #include "GException.h"
++#include <stddef.h>
++#include <stdlib.h>
+ #include <string.h>
+ 
+ // - Author: Leon Bottou, 05/1997
+diff --git a/libdjvu/GException.cpp b/libdjvu/GException.cpp
+index 2ea179a..89da70f 100644
+--- a/libdjvu/GException.cpp
++++ b/libdjvu/GException.cpp
+@@ -60,6 +60,7 @@
+ # pragma implementation
+ #endif
+ 
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+diff --git a/libdjvu/GOS.cpp b/libdjvu/GOS.cpp
+index e784932..d2088e2 100644
+--- a/libdjvu/GOS.cpp
++++ b/libdjvu/GOS.cpp
+@@ -65,6 +65,7 @@
+ #include "GOS.h"
+ #include "GURL.h"
+ 
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <ctype.h>
+diff --git a/libdjvu/GPixmap.cpp b/libdjvu/GPixmap.cpp
+index 392df54..4bf6f57 100644
+--- a/libdjvu/GPixmap.cpp
++++ b/libdjvu/GPixmap.cpp
+@@ -75,6 +75,8 @@
+ #include "GThreads.h"
+ #include "Arrays.h"
+ #include "JPEGDecoder.h"
++
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <math.h>
+ #include <assert.h>
+diff --git a/libdjvu/GSmartPointer.cpp b/libdjvu/GSmartPointer.cpp
+index 6e523e7..58aef5b 100644
+--- a/libdjvu/GSmartPointer.cpp
++++ b/libdjvu/GSmartPointer.cpp
+@@ -67,6 +67,7 @@
+ // Our original implementation consisted of multiple classes.
+ // <http://prdownloads.sourceforge.net/djvu/DjVu2_2b-src.tgz>.
+ 
++#include <stddef.h>
+ #include <string.h>
+ #if PARANOID_DEBUG
+ # include <assert.h>
+diff --git a/libdjvu/GSmartPointer.h b/libdjvu/GSmartPointer.h
+index 82781bd..8a8bb8a 100644
+--- a/libdjvu/GSmartPointer.h
++++ b/libdjvu/GSmartPointer.h
+@@ -97,6 +97,8 @@
+ #include "DjVuGlobal.h"
+ #include "atomic.h"
+ 
++#include <stddef.h>
++
+ #ifdef HAVE_NAMESPACES
+ namespace DJVU {
+ # ifdef NOT_DEFINED // Just to fool emacs c++ mode
+diff --git a/libdjvu/GString.cpp b/libdjvu/GString.cpp
+index 03f6226..350b11b 100644
+--- a/libdjvu/GString.cpp
++++ b/libdjvu/GString.cpp
+@@ -73,6 +73,7 @@
+ #include "GThreads.h"
+ #include "debug.h"
+ 
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+diff --git a/libdjvu/GString.h b/libdjvu/GString.h
+index b63b753..3aa1f76 100644
+--- a/libdjvu/GString.h
++++ b/libdjvu/GString.h
+@@ -108,6 +108,7 @@
+ #include "DjVuGlobal.h"
+ #include "GContainer.h"
+ 
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdarg.h>
+ #ifdef WIN32
+diff --git a/libdjvu/GThreads.cpp b/libdjvu/GThreads.cpp
+index d81f3c3..253fed8 100644
+--- a/libdjvu/GThreads.cpp
++++ b/libdjvu/GThreads.cpp
+@@ -71,6 +71,8 @@
+ #include "GThreads.h"
+ #include "GException.h"
+ #include "DjVuMessageLite.h"
++
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ 
+diff --git a/libdjvu/GURL.cpp b/libdjvu/GURL.cpp
+index c37bf52..a80078c 100644
+--- a/libdjvu/GURL.cpp
++++ b/libdjvu/GURL.cpp
+@@ -72,6 +72,7 @@
+ #include "GURL.h"
+ #include "debug.h"
+ 
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <ctype.h>
+diff --git a/libdjvu/GUnicode.cpp b/libdjvu/GUnicode.cpp
+index 415c081..a8b25b8 100644
+--- a/libdjvu/GUnicode.cpp
++++ b/libdjvu/GUnicode.cpp
+@@ -62,6 +62,8 @@
+ 
+ #include "GString.h"
+ 
++#include <stddef.h>
++
+ #if HAS_ICONV
+ #include <iconv.h>
+ #endif
+diff --git a/libdjvu/IFFByteStream.h b/libdjvu/IFFByteStream.h
+index a653f8c..e31b216 100644
+--- a/libdjvu/IFFByteStream.h
++++ b/libdjvu/IFFByteStream.h
+@@ -124,6 +124,7 @@
+ 
+ 
+ #include "DjVuGlobal.h"
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+diff --git a/libdjvu/IW44EncodeCodec.cpp b/libdjvu/IW44EncodeCodec.cpp
+index 8d7b12c..49081b7 100644
+--- a/libdjvu/IW44EncodeCodec.cpp
++++ b/libdjvu/IW44EncodeCodec.cpp
+@@ -76,6 +76,7 @@
+ #include "IFFByteStream.h"
+ #include "GRect.h"
+ 
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <math.h>
+diff --git a/libdjvu/IW44Image.cpp b/libdjvu/IW44Image.cpp
+index 9476726..4a19fb5 100644
+--- a/libdjvu/IW44Image.cpp
++++ b/libdjvu/IW44Image.cpp
+@@ -76,6 +76,7 @@
+ #include "IFFByteStream.h"
+ #include "GRect.h"
+ 
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <math.h>
+diff --git a/libdjvu/JPEGDecoder.h b/libdjvu/JPEGDecoder.h
+index bd430a0..fad1d4c 100644
+--- a/libdjvu/JPEGDecoder.h
++++ b/libdjvu/JPEGDecoder.h
+@@ -64,6 +64,7 @@
+ 
+ #ifdef NEED_JPEG_DECODER
+ 
++#include <stddef.h>
+ #include <string.h>
+ #include <setjmp.h>
+ 
+diff --git a/libdjvu/MMX.cpp b/libdjvu/MMX.cpp
+index 5ab60bb..528dab6 100644
+--- a/libdjvu/MMX.cpp
++++ b/libdjvu/MMX.cpp
+@@ -62,6 +62,7 @@
+ 
+ #include "MMX.h"
+ #include <stdio.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ 
+ 
+diff --git a/libdjvu/UnicodeByteStream.h b/libdjvu/UnicodeByteStream.h
+index 0ae112b..9b49a17 100644
+--- a/libdjvu/UnicodeByteStream.h
++++ b/libdjvu/UnicodeByteStream.h
+@@ -88,6 +88,7 @@
+ #include "GString.h"
+ #include "ByteStream.h"
+ 
++#include <stddef.h>
+ 
+ #ifdef HAVE_NAMESPACES
+ namespace DJVU {
+diff --git a/libdjvu/XMLParser.cpp b/libdjvu/XMLParser.cpp
+index 84386c5..7da923a 100644
+--- a/libdjvu/XMLParser.cpp
++++ b/libdjvu/XMLParser.cpp
+@@ -75,6 +75,7 @@
+ #include "debug.h"
+ #include <stdio.h>
+ #include <ctype.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ 
+ 
+diff --git a/libdjvu/ZPCodec.cpp b/libdjvu/ZPCodec.cpp
+index f6e971d..ff5b9bf 100644
+--- a/libdjvu/ZPCodec.cpp
++++ b/libdjvu/ZPCodec.cpp
+@@ -66,6 +66,8 @@
+ #include "ZPCodec.h"
+ #include "ByteStream.h"
+ #include "GException.h"
++
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <assert.h>
+ #include <math.h>
+diff --git a/libdjvu/atomic.cpp b/libdjvu/atomic.cpp
+index bdc193e..63fd483 100644
+--- a/libdjvu/atomic.cpp
++++ b/libdjvu/atomic.cpp
+@@ -28,6 +28,7 @@
+ # include "config.h"
+ #endif
+ 
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <assert.h>
+ #include "atomic.h"
+diff --git a/libdjvu/ddjvuapi.cpp b/libdjvu/ddjvuapi.cpp
+index b18b84b..f40f5aa 100644
+--- a/libdjvu/ddjvuapi.cpp
++++ b/libdjvu/ddjvuapi.cpp
+@@ -60,6 +60,7 @@
+ # pragma implementation "ddjvuapi.h"
+ #endif
+ 
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+diff --git a/libdjvu/ddjvuapi.h b/libdjvu/ddjvuapi.h
+index d0ed48f..841f223 100644
+--- a/libdjvu/ddjvuapi.h
++++ b/libdjvu/ddjvuapi.h
+@@ -64,6 +64,7 @@ extern "C" {
+ }
+ #endif
+ 
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ 
+diff --git a/libdjvu/miniexp.cpp b/libdjvu/miniexp.cpp
+index e0fb087..fc51297 100644
+--- a/libdjvu/miniexp.cpp
++++ b/libdjvu/miniexp.cpp
+@@ -23,6 +23,7 @@
+ # pragma implementation "miniexp.h"
+ #endif
+ 
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <ctype.h>
+diff --git a/libdjvu/miniexp.h b/libdjvu/miniexp.h
+index 91e345d..993005b 100644
+--- a/libdjvu/miniexp.h
++++ b/libdjvu/miniexp.h
+@@ -38,7 +38,8 @@ extern "C" {
+ #ifndef MINILISPAPI
+ # define MINILISPAPI /**/
+ #endif
+-  
++
++#include <stddef.h>  
+ 
+ /* -------------------------------------------------- */
+ /* LISP EXPRESSIONS                                   */
+diff --git a/tools/bzz.cpp b/tools/bzz.cpp
+index ca092e1..2ebc7b9 100644
+--- a/tools/bzz.cpp
++++ b/tools/bzz.cpp
+@@ -94,6 +94,7 @@
+ #include "GURL.h"
+ #include "DjVuMessage.h"
+ #include <locale.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ 
+ static const char *program = "(unknown)";
+diff --git a/tools/c44.cpp b/tools/c44.cpp
+index 6f23b53..855504b 100644
+--- a/tools/c44.cpp
++++ b/tools/c44.cpp
+@@ -226,6 +226,7 @@
+ #include <locale.h>
+ #include <stdio.h>
+ #include <string.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ 
+ // command line data
+diff --git a/tools/cjb2.cpp b/tools/cjb2.cpp
+index 8cf89b9..11eb662 100644
+--- a/tools/cjb2.cpp
++++ b/tools/cjb2.cpp
+@@ -120,6 +120,7 @@
+ #include "jb2tune.h"
+ 
+ #include <locale.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ #if HAVE_TIFF
+ #include <tiffio.h>
+diff --git a/tools/cpaldjvu.cpp b/tools/cpaldjvu.cpp
+index 111cbd3..b640a7a 100644
+--- a/tools/cpaldjvu.cpp
++++ b/tools/cpaldjvu.cpp
+@@ -118,6 +118,7 @@
+ #include "jb2tune.h"
+ 
+ #include <locale.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <math.h>
+ 
+diff --git a/tools/csepdjvu.cpp b/tools/csepdjvu.cpp
+index cd721f8..d5203d5 100644
+--- a/tools/csepdjvu.cpp
++++ b/tools/csepdjvu.cpp
+@@ -162,6 +162,7 @@
+ #include "jb2tune.h"
+ 
+ #include <locale.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ 
+ #undef MIN
+diff --git a/tools/ddjvu.cpp b/tools/ddjvu.cpp
+index 817e045..981a270 100644
+--- a/tools/ddjvu.cpp
++++ b/tools/ddjvu.cpp
+@@ -62,6 +62,7 @@
+ # include "config.h"
+ #endif
+ 
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <stdarg.h>
+diff --git a/tools/djvm.cpp b/tools/djvm.cpp
+index 951bd66..6ea88c2 100644
+--- a/tools/djvm.cpp
++++ b/tools/djvm.cpp
+@@ -135,9 +135,9 @@
+ #include "DjVuMessage.h"
+ 
+ #include <locale.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+-#include <stdlib.h>
+ 
+ static const char * progname;
+ 
+diff --git a/tools/djvmcvt.cpp b/tools/djvmcvt.cpp
+index 9ca1c54..20b468a 100644
+--- a/tools/djvmcvt.cpp
++++ b/tools/djvmcvt.cpp
+@@ -144,6 +144,7 @@
+ 
+ #include <locale.h>
+ #include <stdio.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ 
+ static const char * progname;
+diff --git a/tools/djvudump.cpp b/tools/djvudump.cpp
+index 6a0215a..2dddbdf 100644
+--- a/tools/djvudump.cpp
++++ b/tools/djvudump.cpp
+@@ -119,6 +119,7 @@ xxx
+ #include <locale.h>
+ #include <stdio.h>
+ #include <ctype.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ 
+ void
+diff --git a/tools/djvuextract.cpp b/tools/djvuextract.cpp
+index 4a9f381..907b99c 100644
+--- a/tools/djvuextract.cpp
++++ b/tools/djvuextract.cpp
+@@ -105,6 +105,7 @@
+ #include "GOS.h"
+ #include "DjVuMessage.h"
+ #include <locale.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ 
+ 
+diff --git a/tools/djvumake.cpp b/tools/djvumake.cpp
+index 7020484..4c5fc0f 100644
+--- a/tools/djvumake.cpp
++++ b/tools/djvumake.cpp
+@@ -153,6 +153,7 @@
+ 
+ #include <locale.h>
+ #include <stdio.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <ctype.h>
+ 
+diff --git a/tools/djvups.cpp b/tools/djvups.cpp
+index 51aa999..632b832 100644
+--- a/tools/djvups.cpp
++++ b/tools/djvups.cpp
+@@ -57,6 +57,7 @@
+ # include "config.h"
+ #endif
+ 
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <stdarg.h>
+diff --git a/tools/djvused.cpp b/tools/djvused.cpp
+index de84dcd..687fdca 100644
+--- a/tools/djvused.cpp
++++ b/tools/djvused.cpp
+@@ -61,6 +61,7 @@
+ #endif
+ 
+ #include <stdio.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdarg.h>
+ #include <errno.h>
+diff --git a/tools/djvuserve.cpp b/tools/djvuserve.cpp
+index 19a17da..818fe78 100644
+--- a/tools/djvuserve.cpp
++++ b/tools/djvuserve.cpp
+@@ -73,6 +73,7 @@
+ 
+ #include <locale.h>
+ #include <stdio.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <sys/stat.h>
+ #include <time.h>
+diff --git a/tools/djvutxt.cpp b/tools/djvutxt.cpp
+index ba2c745..9e9124c 100644
+--- a/tools/djvutxt.cpp
++++ b/tools/djvutxt.cpp
+@@ -61,6 +61,7 @@
+ # include "config.h"
+ #endif
+ 
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <stdarg.h>
+diff --git a/tools/tiff2pdf.h b/tools/tiff2pdf.h
+index 082f5fb..656dc43 100644
+--- a/tools/tiff2pdf.h
++++ b/tools/tiff2pdf.h
+@@ -22,6 +22,7 @@
+ # endif
+ # if HAVE_TIFF
+ #  include <stdio.h>
++#  include <stddef.h>
+ #  include <stdlib.h>
+ #  include <tiff.h>
+ #  include <tiffio.h>
+diff --git a/xmltools/djvutoxml.cpp b/xmltools/djvutoxml.cpp
+index 17c769b..b40535e 100644
+--- a/xmltools/djvutoxml.cpp
++++ b/xmltools/djvutoxml.cpp
+@@ -71,6 +71,7 @@
+ 
+ #include <locale.h>
+ #include <stdio.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ #include <sys/stat.h>
+ #include <assert.h>
+diff --git a/xmltools/djvuxmlparser.cpp b/xmltools/djvuxmlparser.cpp
+index bdc5768..6679a9d 100644
+--- a/xmltools/djvuxmlparser.cpp
++++ b/xmltools/djvuxmlparser.cpp
+@@ -70,6 +70,7 @@
+ #include <stdio.h>
+ #include <ctype.h>
+ #include <locale.h>
++#include <stddef.h>
+ #include <stdlib.h>
+ 
+ static void 
diff --git a/pkgs/applications/misc/freemind/default.nix b/pkgs/applications/misc/freemind/default.nix
index 24071d3c68380..f67138e66a771 100644
--- a/pkgs/applications/misc/freemind/default.nix
+++ b/pkgs/applications/misc/freemind/default.nix
@@ -29,7 +29,7 @@ stdenv.mkDerivation {
   # JDK 7 beta seems to have fixed this (bug ?)
 
   installPhase = ''
-    ensureDir $out/{bin,nix-support}
+    mkdir -p $out/{bin,nix-support}
     cp -r ../bin/dist $out/nix-support
     sed -i 's/which/type -p/' $out/nix-support/dist/freemind.sh
     cat > $out/bin/freemind << EOF
diff --git a/pkgs/applications/misc/get_iplayer/default.nix b/pkgs/applications/misc/get_iplayer/default.nix
index 1a0453797ccd5..0e222366729f4 100644
--- a/pkgs/applications/misc/get_iplayer/default.nix
+++ b/pkgs/applications/misc/get_iplayer/default.nix
@@ -6,7 +6,7 @@ stdenv.mkDerivation {
   buildInputs = [makeWrapper perl];
 
   installPhase = '' 
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp get_iplayer $out/bin
     wrapProgram $out/bin/get_iplayer --suffix PATH ${ffmpeg}/bin:${flvstreamer}/bin
   '';  
diff --git a/pkgs/applications/misc/googleearth/default.nix b/pkgs/applications/misc/googleearth/default.nix
index aa4807a34f5ae..8da4e9de8fd63 100644
--- a/pkgs/applications/misc/googleearth/default.nix
+++ b/pkgs/applications/misc/googleearth/default.nix
@@ -43,7 +43,7 @@ stdenv.mkDerivation {
   '';
   
   installPhase =''
-    ensureDir $out/{opt/googleearth/,bin};
+    mkdir -p $out/{opt/googleearth/,bin};
     tar xf googleearth-data.tar -C $out/opt/googleearth
     tar xf googleearth-linux-x86.tar -C $out/opt/googleearth
     cp bin/googleearth $out/opt/googleearth
diff --git a/pkgs/applications/misc/jbidwatcher/default.nix b/pkgs/applications/misc/jbidwatcher/default.nix
index 56c547ce43570..70cd5d3faf4b3 100644
--- a/pkgs/applications/misc/jbidwatcher/default.nix
+++ b/pkgs/applications/misc/jbidwatcher/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
   buildPhase = "true";
 
   installPhase = ''
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     echo > "$out/bin/${pname}" "#!/bin/sh"
     echo >>"$out/bin/${pname}" "${java}/bin/java -Xmx512m -jar ${jarfile}"
     chmod +x "$out/bin/${pname}"
diff --git a/pkgs/applications/misc/lyx/default.nix b/pkgs/applications/misc/lyx/default.nix
index 9d48008af36d7..64ff3142ef170 100644
--- a/pkgs/applications/misc/lyx/default.nix
+++ b/pkgs/applications/misc/lyx/default.nix
@@ -1,6 +1,6 @@
 # I haven't put much effort into this expressions .. so some optional depencencies may be missing - Marc
 { fetchurl, stdenv, texLive, python, makeWrapper, pkgconfig
-, libX11, qt, xz
+, libX11, qt
 }:
 
 stdenv.mkDerivation rec {
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
     sha256 = "a790951d6ed660b254e82d682b478665f119dd522ab4759fdeb5cd8d42f66f61";
   };
 
-  buildInputs = [texLive qt python makeWrapper xz pkgconfig ];
+  buildInputs = [texLive qt python makeWrapper pkgconfig ];
 
   # don't ask me why it can't find libX11.so.6
   postInstall = ''
diff --git a/pkgs/applications/misc/makeself/default.nix b/pkgs/applications/misc/makeself/default.nix
index 08edc32e87e14..9ea5f18ee6297 100644
--- a/pkgs/applications/misc/makeself/default.nix
+++ b/pkgs/applications/misc/makeself/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
   unpackPhase = "sh ${src}";
   installPhase = ''
     cd ${name}
-    ensureDir $out/{bin,share/{${name},man/man1}}
+    mkdir -p $out/{bin,share/{${name},man/man1}}
     mv makeself.lsm README $out/share/${name}
     mv makeself.sh $out/bin/makeself
     mv makeself.1  $out/share/man/man1/
diff --git a/pkgs/applications/misc/navipowm/default.nix b/pkgs/applications/misc/navipowm/default.nix
index e308ebe04774c..a526774d48ecf 100644
--- a/pkgs/applications/misc/navipowm/default.nix
+++ b/pkgs/applications/misc/navipowm/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   '';
 
   installPhase = ''
-    ensureDir $out/bin $out/share/${name}/Icons
+    mkdir -p $out/bin $out/share/${name}/Icons
     cp bin/NaviPOWM $out/bin
     cp ../../common/Config/navipowm.ini $out/share/${name}
     cp ../../common/Images/* $out/share/${name}
diff --git a/pkgs/applications/misc/openjump/default.nix b/pkgs/applications/misc/openjump/default.nix
index 3b42f0f33221a..74f657ee02a78 100644
--- a/pkgs/applications/misc/openjump/default.nix
+++ b/pkgs/applications/misc/openjump/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation {
   # error. Still this is better than getting it always.
   # TODO: build from source and patch this
   unpackPhase = ''
-    ensureDir $out/bin;
+    mkdir -p $out/bin;
     cd $out; unzip $src
     s=$out/bin/OpenJump
     dir=$(echo $out/openjump-*)
diff --git a/pkgs/applications/misc/procmail/default.nix b/pkgs/applications/misc/procmail/default.nix
index 15bcc477bdd31..7b25f9fc5c773 100644
--- a/pkgs/applications/misc/procmail/default.nix
+++ b/pkgs/applications/misc/procmail/default.nix
@@ -7,7 +7,7 @@ stdenv.mkDerivation {
 
   # getline is defined differently in glibc now. So rename it.
   installPhase = "
-    ensureDir \$out/bin
+    mkdir -p \$out/bin
     sed -e \"s%^RM.*$%RM=`type -f rm | awk '{print $3;}'` -f%\" -i Makefile
     sed -e \"s%^BASENAME.*%\BASENAME=$out%\" -i Makefile
     sed -e \"s%^LIBS=.*%LIBS=-lm%\" -i Makefile
diff --git a/pkgs/applications/misc/pstree/default.nix b/pkgs/applications/misc/pstree/default.nix
index 67d3f32d53feb..6f5c775cfb335 100644
--- a/pkgs/applications/misc/pstree/default.nix
+++ b/pkgs/applications/misc/pstree/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   unpackPhase = "unpackFile \$src; sourceRoot=.";
 
   buildPhase = "pwd; gcc -o pstree pstree.c";
-  installPhase = "ensureDir \$out/bin; cp pstree \$out/bin";
+  installPhase = "mkdir -p \$out/bin; cp pstree \$out/bin";
 
   meta = {
     description = "Show the set of running processes as a tree";
diff --git a/pkgs/applications/misc/qcad/default.nix b/pkgs/applications/misc/qcad/default.nix
index 233ee0e655107..ee8876e6b334c 100644
--- a/pkgs/applications/misc/qcad/default.nix
+++ b/pkgs/applications/misc/qcad/default.nix
@@ -32,7 +32,7 @@ stdenv.mkDerivation {
 
   # probably there is more to be done. But this seems to work for now (eg see gentoo ebuild)
   installPhase = ''
-    ensureDir $out/{bin,share}
+    mkdir -p $out/{bin,share}
     cp -r qcad $out/share
 
     # The compilation does not fail with error code. But qcad will not exist
diff --git a/pkgs/applications/misc/rxvt_unicode/default.nix b/pkgs/applications/misc/rxvt_unicode/default.nix
index 89bce3ff99f25..aa8b1b2b29f4a 100644
--- a/pkgs/applications/misc/rxvt_unicode/default.nix
+++ b/pkgs/applications/misc/rxvt_unicode/default.nix
@@ -30,7 +30,7 @@ stdenv.mkDerivation (rec {
     ''
     # make urxvt find its perl file lib/perl5/site_perl is added to PERL5LIB automatically
     + stdenv.lib.optionalString perlSupport ''
-      ensureDir $out/lib/perl5
+      mkdir -p $out/lib/perl5
       ln -s $out/{lib/urxvt,lib/perl5/site_perl}
     '';
 
diff --git a/pkgs/applications/misc/sbagen/default.nix b/pkgs/applications/misc/sbagen/default.nix
index c14f6080b8ca1..495f37de2f40a 100644
--- a/pkgs/applications/misc/sbagen/default.nix
+++ b/pkgs/applications/misc/sbagen/default.nix
@@ -8,7 +8,7 @@ stdenv.mkDerivation {
   buildPhase = "./mk";
 
   installPhase = ''
-    ensureDir $out/{bin,share/sbagen/doc}
+    mkdir -p $out/{bin,share/sbagen/doc}
     cp -r --target-directory=$out/share/sbagen examples scripts river1.ogg river2.ogg
     cp sbagen $out/bin
     cp --target-directory=$out/share/sbagen/doc README.txt SBAGEN.txt theory{,2}.txt {wave,holosync,focus,TODO}.txt
diff --git a/pkgs/applications/misc/thinking-rock/default.nix b/pkgs/applications/misc/thinking-rock/default.nix
index 2faed53b7a585..7b55f39c11916 100644
--- a/pkgs/applications/misc/thinking-rock/default.nix
+++ b/pkgs/applications/misc/thinking-rock/default.nix
@@ -21,7 +21,7 @@ stdenv.mkDerivation {
     ls -1 bin/* | grep -ve  'bin/tr''$' | xargs rm
     # don't keep the other .exe file either
     find . -iname "*.exe" | xargs -n1 rm
-    ensureDir $out/{nix-support/tr-files,bin}
+    mkdir -p $out/{nix-support/tr-files,bin}
     cp -r . $out/nix-support/tr-files
     cat >> $out/bin/thinkingrock << EOF
     #!/bin/sh
diff --git a/pkgs/applications/misc/vue/default.nix b/pkgs/applications/misc/vue/default.nix
index 3f536ec21c171..8caa86a71cbe3 100644
--- a/pkgs/applications/misc/vue/default.nix
+++ b/pkgs/applications/misc/vue/default.nix
@@ -31,7 +31,7 @@ rec {
 
   doDeploy = a.fullDepEntry ''
     unzip ${src}
-    ensureDir "$out"/{share/vue,bin}
+    mkdir -p "$out"/{share/vue,bin}
     cp VUE.jar "$out/share/vue/vue.jar"
     echo '#!${a.stdenv.shell}' >> "$out/bin/vue" 
     echo '${a.jre}/bin/java -jar "'"$out/share/vue/vue.jar"'" "$@"' >> "$out/bin/vue" 
diff --git a/pkgs/applications/misc/xpdf/libxpdf.nix b/pkgs/applications/misc/xpdf/libxpdf.nix
index 589fbf497866d..7987d26946d51 100644
--- a/pkgs/applications/misc/xpdf/libxpdf.nix
+++ b/pkgs/applications/misc/xpdf/libxpdf.nix
@@ -31,10 +31,10 @@ stdenv.mkDerivation {
   ];
 
   installPhase = ''
-    ensureDir $out/lib/goo
-    ensureDir $out/lib/fofi
-    ensureDir $out/lib/xpdf
-    ensureDir $out/include
+    mkdir -p $out/lib/goo
+    mkdir -p $out/lib/fofi
+    mkdir -p $out/lib/xpdf
+    mkdir -p $out/include
 
     cp -v goo/libGoo.a $out/lib/goo
     cp -v fofi/libfofi.a $out/lib/fofi
diff --git a/pkgs/applications/networking/browsers/chromium/default.nix b/pkgs/applications/networking/browsers/chromium/default.nix
index 8fe7395b5a9b5..3fffc68b6b2e8 100644
--- a/pkgs/applications/networking/browsers/chromium/default.nix
+++ b/pkgs/applications/networking/browsers/chromium/default.nix
@@ -42,8 +42,8 @@ stdenv.mkDerivation rec {
        ];
 
   installPhase = ''
-    ensureDir $out/bin
-    ensureDir $out/libexec/chrome
+    mkdir -p $out/bin
+    mkdir -p $out/libexec/chrome
 
     cp -R * $out/libexec/chrome
 
diff --git a/pkgs/applications/networking/browsers/firefox/3.6.nix b/pkgs/applications/networking/browsers/firefox/3.6.nix
index 47754d67f3c86..40b7959139d2b 100644
--- a/pkgs/applications/networking/browsers/firefox/3.6.nix
+++ b/pkgs/applications/networking/browsers/firefox/3.6.nix
@@ -12,14 +12,14 @@
 
 rec {
 
-  firefoxVersion = "3.6.21";
+  firefoxVersion = "3.6.27";
   
-  xulVersion = "1.9.2.21"; # this attribute is used by other packages
+  xulVersion = "1.9.2.27"; # this attribute is used by other packages
 
   
   src = fetchurl {
     url = "http://releases.mozilla.org/pub/mozilla.org/firefox/releases/${firefoxVersion}/source/firefox-${firefoxVersion}.source.tar.bz2";
-    sha1 = "3c1f001ad22d93b48e191999f548b4382db3d36c";
+    sha1 = "dd472a10e4ef5b017f00074d0325be13e832d610";
   };
 
 
@@ -50,6 +50,9 @@ rec {
       ./xulrunner-chromium-mips.patch
       ./xulrunner-mips-n32.patch
       ./xulrunner-1.9.2_beta4-mips-bus-error.patch
+
+      # Fix building on GCC 4.6.
+      ./gcc-4.6.patch
     ];
 
     buildInputs =
diff --git a/pkgs/applications/networking/browsers/firefox/gcc-4.6.patch b/pkgs/applications/networking/browsers/firefox/gcc-4.6.patch
new file mode 100644
index 0000000000000..f5f685951ef4d
--- /dev/null
+++ b/pkgs/applications/networking/browsers/firefox/gcc-4.6.patch
@@ -0,0 +1,13 @@
+https://346825.bugs.gentoo.org/attachment.cgi?id=270163
+
+--- a/gfx/ots/src/os2.cc
++++ b/gfx/ots/src/os2.cc
+@@ -2,6 +2,8 @@
+ // Use of this source code is governed by a BSD-style license that can be
+ // found in the LICENSE file.
+ 
++#include <cstddef>
++
+ #include "os2.h"
+ 
+ #include "head.h"
diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix
index b6ec69ee38886..1b8fb796badd6 100644
--- a/pkgs/applications/networking/browsers/firefox/wrapper.nix
+++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix
@@ -30,7 +30,7 @@ stdenv.mkDerivation {
         --suffix-each LD_LIBRARY_PATH ':' "$libs" \
         --prefix-contents PATH ':' "$(filterExisting $(addSuffix /extra-bin-path $plugins))"
 
-    ensureDir $out/share/applications
+    mkdir -p $out/share/applications
     cp $desktopItem/share/applications/* $out/share/applications
   '';
 
diff --git a/pkgs/applications/networking/browsers/icecat-3/default.nix b/pkgs/applications/networking/browsers/icecat-3/default.nix
index 99f135c6d7b45..e916c34631e5a 100644
--- a/pkgs/applications/networking/browsers/icecat-3/default.nix
+++ b/pkgs/applications/networking/browsers/icecat-3/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, xz, pkgconfig, gtk, pango, perl, python, ply, zip, libIDL
+{ fetchurl, stdenv, pkgconfig, gtk, pango, perl, python, ply, zip, libIDL
 , libjpeg, libpng, zlib, cairo, dbus, dbus_glib, bzip2, xlibs, alsaLib
 , libnotify, gnome_vfs, libgnomeui
 , freetype, fontconfig, wirelesstools ? null, pixman
@@ -19,7 +19,7 @@ stdenv.mkDerivation {
   };
 
   buildInputs =
-    [ xz libgnomeui libnotify gnome_vfs alsaLib
+    [ libgnomeui libnotify gnome_vfs alsaLib
       pkgconfig gtk perl zip libIDL libjpeg libpng zlib cairo bzip2 pixman
       python ply dbus dbus_glib pango freetype fontconfig
       xlibs.libXi xlibs.libX11 xlibs.libXrender xlibs.libXft xlibs.libXt
@@ -84,7 +84,7 @@ stdenv.mkDerivation {
     fi
 
     # Put the GNU IceCat icon in the right place.
-    ensureDir "$out/lib/$libDir/chrome/icons/default"
+    mkdir -p "$out/lib/$libDir/chrome/icons/default"
     ln -s ../../../icons/default.xpm  "$out/lib/$libDir/chrome/icons/default/"
   '';
 
diff --git a/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-10/builder.sh b/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-10/builder.sh
index 4db487f5c51c0..b0f8a2638c188 100644
--- a/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-10/builder.sh
+++ b/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-10/builder.sh
@@ -15,7 +15,7 @@ unpackPhase() {
 }
 
 installPhase() {
-    ensureDir $out/lib/mozilla/plugins
+    mkdir -p $out/lib/mozilla/plugins
     cp -pv libflashplayer.so $out/lib/mozilla/plugins
     patchelf --set-rpath "$rpath" $out/lib/mozilla/plugins/libflashplayer.so
 }
diff --git a/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-11/builder.sh b/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-11/builder.sh
index 4db487f5c51c0..b0f8a2638c188 100644
--- a/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-11/builder.sh
+++ b/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-11/builder.sh
@@ -15,7 +15,7 @@ unpackPhase() {
 }
 
 installPhase() {
-    ensureDir $out/lib/mozilla/plugins
+    mkdir -p $out/lib/mozilla/plugins
     cp -pv libflashplayer.so $out/lib/mozilla/plugins
     patchelf --set-rpath "$rpath" $out/lib/mozilla/plugins/libflashplayer.so
 }
diff --git a/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-9/builder.sh b/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-9/builder.sh
index 0f738eb9cccc8..86ecd2c334537 100644
--- a/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-9/builder.sh
+++ b/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-9/builder.sh
@@ -6,7 +6,7 @@ dontPatchELF=1
 sourceRoot=.
 
 installPhase() {
-    ensureDir $out/lib/mozilla/plugins
+    mkdir -p $out/lib/mozilla/plugins
     cp -p libflashplayer.so $out/lib/mozilla/plugins
     patchelf --set-rpath $rpath $out/lib/mozilla/plugins/libflashplayer.so
 }
diff --git a/pkgs/applications/networking/browsers/mozilla-plugins/mozplugger/default.nix b/pkgs/applications/networking/browsers/mozilla-plugins/mozplugger/default.nix
index 890021b33d6e1..37d5cbe039f1f 100644
--- a/pkgs/applications/networking/browsers/mozilla-plugins/mozplugger/default.nix
+++ b/pkgs/applications/networking/browsers/mozilla-plugins/mozplugger/default.nix
@@ -22,7 +22,7 @@ rec {
   '') ["doUnpack" "minInit"];
 
   postInstall = a.fullDepEntry(''
-    ensureDir $out/share/${name}/plugin
+    mkdir -p $out/share/${name}/plugin
     ln -s $out/lib/mozilla/plugins/mozplugger.so $out/share/${name}/plugin
   '') ["doMakeInstall" "minInit" "defEnsureDir"];
 
diff --git a/pkgs/applications/networking/browsers/mozilla-plugins/mplayerplug-in/default.nix b/pkgs/applications/networking/browsers/mozilla-plugins/mplayerplug-in/default.nix
index 330fac098620f..6ee1735f76c76 100644
--- a/pkgs/applications/networking/browsers/mozilla-plugins/mplayerplug-in/default.nix
+++ b/pkgs/applications/networking/browsers/mozilla-plugins/mplayerplug-in/default.nix
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ pkgconfig browser (browser.gtk) libXpm gettext ];
   
   installPhase = ''
-    ensureDir $out/lib/mozilla/plugins
+    mkdir -p $out/lib/mozilla/plugins
     cp -p mplayerplug-in*.so mplayerplug-in*.xpt $out/lib/mozilla/plugins
   '';
 
diff --git a/pkgs/applications/networking/browsers/opera/default.nix b/pkgs/applications/networking/browsers/opera/default.nix
index 3dddc8569637e..19a55c0f89cd7 100644
--- a/pkgs/applications/networking/browsers/opera/default.nix
+++ b/pkgs/applications/networking/browsers/opera/default.nix
@@ -15,8 +15,6 @@ in
 stdenv.mkDerivation rec {
   name = "opera-11.51-1087";
 
-  buildNativeInputs = [ xz ];
-  
   src =
     if stdenv.system == "i686-linux" then
       fetchurl {
diff --git a/pkgs/applications/networking/instant-messengers/carrier/2.4.2.nix b/pkgs/applications/networking/instant-messengers/carrier/2.4.2.nix
index 7728f7abcfc52..6a86774226d38 100644
--- a/pkgs/applications/networking/instant-messengers/carrier/2.4.2.nix
+++ b/pkgs/applications/networking/instant-messengers/carrier/2.4.2.nix
@@ -46,7 +46,7 @@ rec {
   };
 } // (if externalPurple2 then {
   postInstall = fullDepEntry (''
-      ensureDir $out/lib/purple-2
+      mkdir -p $out/lib/purple-2
       cp ${args.purple2Source}/lib/purple-2/* $out/lib/purple-2/
     '') ["minInit" "defEnsureDir"]; }
   else {})
diff --git a/pkgs/applications/networking/instant-messengers/carrier/2.5.0.nix b/pkgs/applications/networking/instant-messengers/carrier/2.5.0.nix
index 0428ccdc7f32c..58f65a2709ec2 100644
--- a/pkgs/applications/networking/instant-messengers/carrier/2.5.0.nix
+++ b/pkgs/applications/networking/instant-messengers/carrier/2.5.0.nix
@@ -46,7 +46,7 @@ rec {
   };
 } // (if externalPurple2 then {
   postInstall = fullDepEntry (''
-      ensureDir $out/lib/purple-2
+      mkdir -p $out/lib/purple-2
       cp ${args.purple2Source}/lib/purple-2/* $out/lib/purple-2/
     '') ["minInit" "defEnsureDir"]; }
   else {})
diff --git a/pkgs/applications/networking/instant-messengers/oneteam/default.nix b/pkgs/applications/networking/instant-messengers/oneteam/default.nix
index 37f56a6380681..026ab3fff1c5c 100644
--- a/pkgs/applications/networking/instant-messengers/oneteam/default.nix
+++ b/pkgs/applications/networking/instant-messengers/oneteam/default.nix
@@ -59,14 +59,14 @@ rec {
   doDeploy = a.fullDepEntry ''
     TARGET_DIR="$out/share/oneteam/app"
     BUILD_DIR="$PWD"
-    ensureDir "$TARGET_DIR"
+    mkdir -p "$TARGET_DIR"
     cd "$TARGET_DIR"
     unzip "$BUILD_DIR/oneteam.xulapp"
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     echo "#! ${a.stdenv.shell}" > "$out/bin/oneteam"
     echo "\"${xulrunner}/bin/xulrunner\" \"$TARGET_DIR/application.ini\"" > "$out/bin/oneteam"
     chmod a+x "$out/bin/oneteam"
-    ensureDir "$out/share/doc"
+    mkdir -p "$out/share/doc"
     cp -r "$BUILD_DIR/docs" "$out/share/doc/oneteam"
   '' ["defEnsureDir"];
 
diff --git a/pkgs/applications/networking/instant-messengers/pidgin-plugins/msn-pecan/default.nix b/pkgs/applications/networking/instant-messengers/pidgin-plugins/msn-pecan/default.nix
index 5e5cf311712a1..cdbf63dbd9f13 100644
--- a/pkgs/applications/networking/instant-messengers/pidgin-plugins/msn-pecan/default.nix
+++ b/pkgs/applications/networking/instant-messengers/pidgin-plugins/msn-pecan/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
   };
 
   makeFlags = "PURPLE_LIBDIR=lib PURPLE_DATADIR=share/data DESTDIR=$$out";
-  preInstall = "ensureDir \$out/share";
+  preInstall = "mkdir -p \$out/share";
   postInstall = "ln -s \$out/lib/purple-2 \$out/share/pidgin-msn-pecan";
 
   buildInputs = [pidgin];
diff --git a/pkgs/applications/networking/instant-messengers/pidgin-plugins/pidgin-latex/pidgin-latex-sf.nix b/pkgs/applications/networking/instant-messengers/pidgin-plugins/pidgin-latex/pidgin-latex-sf.nix
index cc6901c0384dd..868b5dbb342b8 100644
--- a/pkgs/applications/networking/instant-messengers/pidgin-plugins/pidgin-latex/pidgin-latex-sf.nix
+++ b/pkgs/applications/networking/instant-messengers/pidgin-plugins/pidgin-latex/pidgin-latex-sf.nix
@@ -12,7 +12,7 @@ rec {
   ];
 
   preBuild = fullDepEntry (''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     ln -s $(which convert) $out/bin
     ln -s $(which xelatex) $out/bin
     ln -s $(which dvips) $out/bin
@@ -26,8 +26,8 @@ rec {
   '') ["minInit" "addInputs" "defEnsureDir" "doUnpack"];
 
   postInstall = fullDepEntry (''
-    ensureDir $out/lib
-    ensureDir $out/share/pidgin-latex
+    mkdir -p $out/lib
+    mkdir -p $out/share/pidgin-latex
     ln -s ../../lib/pidgin/LaTeX.so  $out/share/pidgin-latex 
   '') ["minInit" "defEnsureDir" "doMakeInstall"];
 
diff --git a/pkgs/applications/networking/instant-messengers/psi/default.nix b/pkgs/applications/networking/instant-messengers/psi/default.nix
index b4c4c1f476f6c..66dbddece3ccc 100644
--- a/pkgs/applications/networking/instant-messengers/psi/default.nix
+++ b/pkgs/applications/networking/instant-messengers/psi/default.nix
@@ -27,10 +27,10 @@ stdenv.mkDerivation rec {
 
   postInstall = ''
     PSI_PLUGINS="$out/lib/psi/plugins"
-    ensureDir "$PSI_PLUGINS"
+    mkdir -p "$PSI_PLUGINS"
     ln -s "${psiMedia}"/share/psi/plugins/*.so "$PSI_PLUGINS"
     PSI_QT_PLUGINS="$out/share/psi"
-    ensureDir "$PSI_QT_PLUGINS"/crypto
+    mkdir -p "$PSI_QT_PLUGINS"/crypto
     ln -s "${qca2_ossl}"/lib/qt4/plugins/crypto/*.so "$PSI_QT_PLUGINS"/crypto
   '';
 
diff --git a/pkgs/applications/networking/instant-messengers/psi/psimedia.nix b/pkgs/applications/networking/instant-messengers/psi/psimedia.nix
index 9b41d38d41239..c7cee2f2c6659 100644
--- a/pkgs/applications/networking/instant-messengers/psi/psimedia.nix
+++ b/pkgs/applications/networking/instant-messengers/psi/psimedia.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
 
   postBuild = ''
     TARGET="$out/share/psi/plugins"
-    ensureDir "$TARGET"
+    mkdir -p "$TARGET"
     cp gstprovider/*.so "$TARGET"/
   '';
 
diff --git a/pkgs/applications/networking/instant-messengers/torchat/default.nix b/pkgs/applications/networking/instant-messengers/torchat/default.nix
index 440ab624a6233..5a82cf9d6407e 100644
--- a/pkgs/applications/networking/instant-messengers/torchat/default.nix
+++ b/pkgs/applications/networking/instant-messengers/torchat/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
 
     wrapPythonPrograms
 
-    ensureDir $out/lib/torchat
+    mkdir -p $out/lib/torchat
     cp -rf * $out/lib/torchat
     makeWrapper ${python}/bin/python $out/bin/torchat \
         --set PYTHONPATH $out/lib/torchat:$program_PYTHONPATH \
diff --git a/pkgs/applications/networking/iptraf/default.nix b/pkgs/applications/networking/iptraf/default.nix
index ce9e84fd5724d..8ddf784adc04f 100644
--- a/pkgs/applications/networking/iptraf/default.nix
+++ b/pkgs/applications/networking/iptraf/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   preConfigure = "cd src";
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp iptraf $out/bin
   '';
   
diff --git a/pkgs/applications/networking/mailreaders/thunderbird/9.x.nix b/pkgs/applications/networking/mailreaders/thunderbird/9.x.nix
index 62b4d91de587c..717d4012645d0 100644
--- a/pkgs/applications/networking/mailreaders/thunderbird/9.x.nix
+++ b/pkgs/applications/networking/mailreaders/thunderbird/9.x.nix
@@ -90,7 +90,7 @@ stdenv.mkDerivation {
           --replace /bin/ls "$(type -tP ls)"
 
       # Create a desktop item.
-      ensureDir $out/share/applications
+      mkdir -p $out/share/applications
       cat > $out/share/applications/thunderbird.desktop <<EOF
       [Desktop Entry]
       Type=Application
diff --git a/pkgs/applications/networking/mumble/default.nix b/pkgs/applications/networking/mumble/default.nix
index 5c9e215f87644..e736d561cb412 100644
--- a/pkgs/applications/networking/mumble/default.nix
+++ b/pkgs/applications/networking/mumble/default.nix
@@ -33,7 +33,7 @@ stdenv.mkDerivation rec {
     ++ (stdenv.lib.optional jackSupport jackaudio);
 
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp -r ./release $out/bin
   '';
 
diff --git a/pkgs/applications/networking/offrss/default.nix b/pkgs/applications/networking/offrss/default.nix
index 9784d36927100..ea994c889e2ff 100644
--- a/pkgs/applications/networking/offrss/default.nix
+++ b/pkgs/applications/networking/offrss/default.nix
@@ -4,7 +4,7 @@ stdenv.mkDerivation {
   name = "offrss-1.1";
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp offrss $out/bin
   '';
 
diff --git a/pkgs/applications/networking/p2p/ldcpp/default.nix b/pkgs/applications/networking/p2p/ldcpp/default.nix
index f189d2eb7813f..1b601992aa6f0 100644
--- a/pkgs/applications/networking/p2p/ldcpp/default.nix
+++ b/pkgs/applications/networking/p2p/ldcpp/default.nix
@@ -12,7 +12,7 @@ with builderDefs;
       openssl libX11 boost];
     configureFlags = [];
     doScons = fullDepEntry (''
-      ensureDir $out
+      mkdir -p $out
       export NIX_LDFLAGS="$NIX_LDFLAGS -lX11";
       
       for i in gettext xgettext msgfmt msgcat; do
diff --git a/pkgs/applications/networking/p2p/mldonkey/default.nix b/pkgs/applications/networking/p2p/mldonkey/default.nix
index 16ce0d3504d48..145414e5c3d32 100644
--- a/pkgs/applications/networking/p2p/mldonkey/default.nix
+++ b/pkgs/applications/networking/p2p/mldonkey/default.nix
@@ -13,6 +13,8 @@ stdenv.mkDerivation (rec {
     homepage = http://mldonkey.sourceforge.net/;
   };
 
+  patches = [ ./gcc44mips64.patch ];
+
   buildInputs = [ ocaml zlib ncurses bzip2 file gd libpng ];
   configureFlags = [ "--disable-gui" ];
 } // (if (stdenv.system != "i686-linux" && stdenv.system != "x86_64-linux") then
@@ -20,7 +22,7 @@ stdenv.mkDerivation (rec {
   # Byte code compilation (the ocaml opt compiler is not supported in many platforms)
   buildPhase = "make mlnet.byte";
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp mlnet.byte $out/bin/mlnet
   '';
 
diff --git a/pkgs/applications/networking/p2p/mldonkey/gcc44mips64.patch b/pkgs/applications/networking/p2p/mldonkey/gcc44mips64.patch
new file mode 100644
index 0000000000000..41449dcdd05c4
--- /dev/null
+++ b/pkgs/applications/networking/p2p/mldonkey/gcc44mips64.patch
@@ -0,0 +1,103 @@
+Patch fixing CryptoPP so:
+- it builds properly in mips64 with gcc 4.4 (gcc 4.4 does not have the 'h' asm constraint)
+- it runs properly in mips64 (where lack of templated *Precision functions gave wrong numbers).
+  An assertion check failed without this.
+
+diff --git a/src/utils/lib/CryptoPP.cc b/src/utils/lib/CryptoPP.cc
+index 9208e1c..6b12b0a 100644
+--- a/src/utils/lib/CryptoPP.cc
++++ b/src/utils/lib/CryptoPP.cc
+@@ -890,35 +890,6 @@ unsigned int Parity(unsigned long value)
+ 	return (unsigned int)value&1;
+ }
+ 
+-unsigned int BytePrecision(unsigned long value)
+-{
+-	unsigned int i;
+-	for (i=sizeof(value); i; --i)
+-		if (value >> (i-1)*8)
+-			break;
+-
+-	return i;
+-}
+-
+-unsigned int BitPrecision(unsigned long value)
+-{
+-	if (!value)
+-		return 0;
+-
+-	unsigned int l=0, h=8*sizeof(value);
+-
+-	while (h-l > 1)
+-	{
+-		unsigned int t = (l+h)/2;
+-		if (value >> t)
+-			l = t;
+-		else
+-			h = t;
+-	}
+-
+-	return h;
+-}
+-
+ unsigned long Crop(unsigned long value, unsigned int size)
+ {
+ 	if (size < 8*sizeof(value))
+@@ -1880,7 +1851,10 @@ public:
+ 		#elif defined(__x86_64__)
+ 			__asm__("mulq %3" : "=d" (r.m_halfs.high), "=a" (r.m_halfs.low) : "a" (a), "rm" (b) : "cc");
+ 		#elif defined(__mips64)
+-			__asm__("dmultu %2,%3" : "=h" (r.m_halfs.high), "=l" (r.m_halfs.low) : "r" (a), "r" (b));
++      //typedef unsigned int uint128_t __attribute__((mode(TI)));
++      __uint128_t tmp = (__uint128_t) a * b;
++      r.m_halfs.high = tmp >> 64;
++      r.m_halfs.low = tmp;
+ 		#elif defined(_M_IX86)
+ 			// for testing
+ 			word64 t = (word64)a * b;
+diff --git a/src/utils/lib/CryptoPP.h b/src/utils/lib/CryptoPP.h
+index d2ec1b2..775a898 100644
+--- a/src/utils/lib/CryptoPP.h
++++ b/src/utils/lib/CryptoPP.h
+@@ -1869,10 +1869,39 @@ template <class T> inline const T& STDMAX(const T& a, const T& b)
+ // #define GETBYTE(x, y) (((byte *)&(x))[y])
+ 
+ CRYPTOPP_DLL unsigned int Parity(unsigned long);
+-CRYPTOPP_DLL unsigned int BytePrecision(unsigned long);
+-CRYPTOPP_DLL unsigned int BitPrecision(unsigned long);
+ CRYPTOPP_DLL unsigned long Crop(unsigned long, unsigned int size);
+ 
++template <typename T>
++unsigned int BitPrecision(const T &value)
++{
++	if (!value)
++		return 0;
++
++	unsigned int l=0, h=8*sizeof(value);
++
++	while (h-l > 1)
++	{
++		unsigned int t = (l+h)/2;
++		if (value >> t)
++			l = t;
++		else
++			h = t;
++	}
++
++	return h;
++}
++
++template <typename T>
++unsigned int BytePrecision(const T &value)
++{
++	unsigned int i;
++	for (i=sizeof(value); i; --i)
++		if (value >> (i-1)*8)
++			break;
++
++	return i;
++}
++
+ inline unsigned int BitsToBytes(unsigned int bitCount)
+ {
+ 	return ((bitCount+7)/(8));
diff --git a/pkgs/applications/networking/p2p/tribler/default.nix b/pkgs/applications/networking/p2p/tribler/default.nix
index 4e02eb9f1e6aa..a834c443bf780 100644
--- a/pkgs/applications/networking/p2p/tribler/default.nix
+++ b/pkgs/applications/networking/p2p/tribler/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation {
   buildInputs = [ pythonPackages.python pythonPackages.wrapPython makeWrapper ];
 
   pythonPath =
-    [ pythonPackages.wxPython pythonPackages.ssl pythonPackages.curses pythonPackages.apsw
+    [ pythonPackages.wxPython pythonPackages.curses pythonPackages.apsw
       pythonPackages.setuptools pythonPackages.m2crypto pythonPackages.sqlite3
     ];
 
diff --git a/pkgs/applications/networking/pjsip/default.nix b/pkgs/applications/networking/pjsip/default.nix
index 14bc1ead49b28..2dc909ca91577 100644
--- a/pkgs/applications/networking/pjsip/default.nix
+++ b/pkgs/applications/networking/pjsip/default.nix
@@ -11,9 +11,9 @@ stdenv.mkDerivation rec {
   buildInputs = [ openssl libsamplerate ];
 
   postInstall = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp pjsip-apps/bin/pjsua-* $out/bin/pjsua
-    ensureDir $out/share/${name}/samples
+    mkdir -p $out/share/${name}/samples
     cp pjsip-apps/bin/samples/*/* $out/share/${name}/samples
   '';
 
diff --git a/pkgs/applications/networking/skype/default.nix b/pkgs/applications/networking/skype/default.nix
index 45e225496ebb5..f94d7e125f65a 100644
--- a/pkgs/applications/networking/skype/default.nix
+++ b/pkgs/applications/networking/skype/default.nix
@@ -36,7 +36,7 @@ stdenv.mkDerivation rec {
   phases = "unpackPhase installPhase";
 
   installPhase = ''
-    ensureDir $out/{opt/skype/,bin}
+    mkdir -p $out/{opt/skype/,bin}
     cp -r * $out/opt/skype/
 
     fullPath=
@@ -61,7 +61,7 @@ stdenv.mkDerivation rec {
     ---
     > Icon=$out/opt/skype/icons/SkypeBlue_48x48.png
     EOF
-    ensureDir $out/share/applications
+    mkdir -p $out/share/applications
     mv skype.desktop $out/share/applications
   '';
 
diff --git a/pkgs/applications/networking/sync/unison/default.nix b/pkgs/applications/networking/sync/unison/default.nix
index 06bab807ebdd4..e3b042aa810e1 100644
--- a/pkgs/applications/networking/sync/unison/default.nix
+++ b/pkgs/applications/networking/sync/unison/default.nix
@@ -21,7 +21,7 @@ stdenv.mkDerivation (rec {
   makeFlags = "INSTALLDIR=$(out)/bin/" + (if enableX11 then " UISTYLE=gtk2" else "")
     + (if ! nativeCode then " NATIVE=false" else "");
 
-  preInstall = "ensureDir $out/bin";
+  preInstall = "mkdir -p $out/bin";
 
   postInstall = if enableX11 then ''
     for i in $(cd $out/bin && ls); do
diff --git a/pkgs/applications/networking/vnstat/default.nix b/pkgs/applications/networking/vnstat/default.nix
index b20f862842c8b..69a0a7efde83c 100644
--- a/pkgs/applications/networking/vnstat/default.nix
+++ b/pkgs/applications/networking/vnstat/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
   };
 
   installPhase = ''
-    ensureDir $out/{bin,sbin} $out/share/man/{man1,man5}
+    mkdir -p $out/{bin,sbin} $out/share/man/{man1,man5}
     cp src/vnstat $out/bin
     cp src/vnstatd $out/sbin
     cp man/vnstat.1 man/vnstatd.1 $out/share/man/man1
diff --git a/pkgs/applications/office/impressive/default.nix b/pkgs/applications/office/impressive/default.nix
index aa09b48ab2785..f1de422fa249b 100644
--- a/pkgs/applications/office/impressive/default.nix
+++ b/pkgs/applications/office/impressive/default.nix
@@ -25,7 +25,7 @@ in
     '';
 
     installPhase = ''
-      ensureDir "$out/bin" "$out/share/doc/impressive"
+      mkdir -p "$out/bin" "$out/share/doc/impressive"
       mv impressive.py "$out/bin/impressive"
       mv * "$out/share/doc/impressive"
 
diff --git a/pkgs/applications/office/mmex/default.nix b/pkgs/applications/office/mmex/default.nix
index 1e7aa756471f1..d56f4bed0ce9e 100644
--- a/pkgs/applications/office/mmex/default.nix
+++ b/pkgs/applications/office/mmex/default.nix
@@ -19,7 +19,7 @@ in
     '';
 
     installPhase = ''
-      ensureDir $out/opt/mmex
+      mkdir -p $out/opt/mmex
       cp -r mmex runtime/{*.txt,*.png,*.db3,en,help,*.wav,*.ico} $out/opt/mmex
     '';
 
diff --git a/pkgs/applications/office/openoffice/builder.sh b/pkgs/applications/office/openoffice/builder.sh
index 131e85de5bf66..2c6e04e049be5 100644
--- a/pkgs/applications/office/openoffice/builder.sh
+++ b/pkgs/applications/office/openoffice/builder.sh
@@ -70,7 +70,7 @@ installPhase() {
 	-f openoffice.lst -l en-US -p OpenOffice \
 	-buildid $BUILD -simple $ooFiles)
 
-    ensureDir $out/bin
+    mkdir -p $out/bin
     for i in soffice ooffice; do wrapSOffice $i; done
     
     # Create some wrappers to start individual OpenOffice components.
@@ -78,7 +78,7 @@ installPhase() {
     
     # Create symlinks to desktop files, so that openoffice.org apps can be picked from
     # the application menu in KDE and GNOME
-    ensureDir $out/share
+    mkdir -p $out/share
     ln -s $out/lib/openoffice/openoffice.org3/share/xdg $out/share/applications
 
     # Apply a minor correction to the *.desktop files in order to correctly address the icons
diff --git a/pkgs/applications/office/openoffice/get-go-src.nix b/pkgs/applications/office/openoffice/get-go-src.nix
index ebdb586bd47a4..439da36638103 100644
--- a/pkgs/applications/office/openoffice/get-go-src.nix
+++ b/pkgs/applications/office/openoffice/get-go-src.nix
@@ -28,7 +28,7 @@ lib.overrideDerivation go_oo (attrs: {
 
   makesh = ''
     sed -i -e '/-x $WG/d' -e "s/WGET='''/WGET='echo XXX'/" download
-    ensureDir $out
+    mkdir -p $out
 
     set +e
     ./download --all | grep XXX | 
diff --git a/pkgs/applications/office/openoffice/go-oo.nix b/pkgs/applications/office/openoffice/go-oo.nix
index 241c2ff2a130e..59cd517b55cd7 100644
--- a/pkgs/applications/office/openoffice/go-oo.nix
+++ b/pkgs/applications/office/openoffice/go-oo.nix
@@ -77,7 +77,7 @@ stdenv.mkDerivation rec {
 
   installPhase = ''
     bin/ooinstall $out
-    ensureDir $out/bin
+    mkdir -p $out/bin
     for a in $out/program/{sbase,scalc,sdraw,simpress,smath,soffice,swriter,soffice.bin}; do
       ln -s $a $out/bin
     done
diff --git a/pkgs/applications/science/biology/arb/default.nix b/pkgs/applications/science/biology/arb/default.nix
index 4543fce48160b..1b4563555c468 100644
--- a/pkgs/applications/science/biology/arb/default.nix
+++ b/pkgs/applications/science/biology/arb/default.nix
@@ -33,22 +33,22 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out/lib
+    mkdir -p $out/lib
     shareddir=/nix/var/lib/arb
     # link out writable shared location lib/pts
-    ensureDir $shareddir/lib/pts
+    mkdir -p $shareddir/lib/pts
     cp -vau lib/pts $shareddir/lib
     rm -vrf lib/pts
     ln -vs $shareddir/lib/pts $out/lib/pts
     chmod a+rwx $shareddir/lib/pts
     # link out writable shared location lib/nas/
-    ensureDir $shareddir/lib/nas
+    mkdir -p $shareddir/lib/nas
     cp -vau lib/nas $shareddir/lib
     rm -vrf lib/nas
     ln -vs $shareddir/lib/nas $out/lib/nas
     chmod a+rwx $shareddir/lib/nas
     # link out shared lib/pixmaps (not sure about this, yet):
-    ensureDir $shareddir/lib/pixmaps
+    mkdir -p $shareddir/lib/pixmaps
     cp -vau lib/pixmaps $shareddir/lib
     rm -vrf lib/pixmaps
     ln -vs $shareddir/lib/pixmaps $out/lib/pixmaps
diff --git a/pkgs/applications/science/biology/pal2nal/default.nix b/pkgs/applications/science/biology/pal2nal/default.nix
index ff9e35d921644..956f8b07e9898 100644
--- a/pkgs/applications/science/biology/pal2nal/default.nix
+++ b/pkgs/applications/science/biology/pal2nal/default.nix
@@ -8,11 +8,11 @@ stdenv.mkDerivation {
   };
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
 
     cp -v pal2nal.pl $out/bin 
 
-    ensureDir $out/doc
+    mkdir -p $out/doc
 
     cp -v README $out/doc
   '';
diff --git a/pkgs/applications/science/biology/slr/default.nix b/pkgs/applications/science/biology/slr/default.nix
index 981cf2a670316..629c10aecdff6 100644
--- a/pkgs/applications/science/biology/slr/default.nix
+++ b/pkgs/applications/science/biology/slr/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
     make -fMakefile.linux
   '';
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp -v ../Slr $out/bin 
   '';
 
diff --git a/pkgs/applications/science/electronics/caneda/default.nix b/pkgs/applications/science/electronics/caneda/default.nix
index 6f930f84f7be9..d135fb0943457 100644
--- a/pkgs/applications/science/electronics/caneda/default.nix
+++ b/pkgs/applications/science/electronics/caneda/default.nix
@@ -11,7 +11,7 @@ let
 in
 
 stdenv.mkDerivation rec {
-  name = "caneda-git-2010-10-24";
+  name = "caneda-git-2012-02-16";
 
   src = fetchgit {
     url = git://caneda.git.sourceforge.net/gitroot/caneda/caneda;
diff --git a/pkgs/applications/science/electronics/gtkwave/default.nix b/pkgs/applications/science/electronics/gtkwave/default.nix
index e1bf95700c9b4..697d0e925cde4 100644
--- a/pkgs/applications/science/electronics/gtkwave/default.nix
+++ b/pkgs/applications/science/electronics/gtkwave/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, gtk, gperf, pkgconfig, bzip2, xz, tcl, tk, judy} :
+{stdenv, fetchurl, gtk, gperf, pkgconfig, bzip2, tcl, tk, judy, xz}:
 stdenv.mkDerivation rec {
   name = "gtkwave-3.3.28";
 
@@ -7,7 +7,7 @@ stdenv.mkDerivation rec {
     sha256 = "0y3dmx39xwc3m23fwjkxvp9gqxpckk8s5814nhs8fnxa384z5cz0";
   };
 
-  buildInputs = [ gtk gperf pkgconfig bzip2 xz tcl tk judy];
+  buildInputs = [ gtk gperf pkgconfig bzip2 tcl tk judy xz ];
 
   configureFlags = [ "--with-tcl=${tcl}/lib" "--with-tk=${tk}/lib" "--enable-judy" ];
 
diff --git a/pkgs/applications/science/geometry/tetgen/default.nix b/pkgs/applications/science/geometry/tetgen/default.nix
index a5c3466d57bce..a43ec3b0eb9f6 100644
--- a/pkgs/applications/science/geometry/tetgen/default.nix
+++ b/pkgs/applications/science/geometry/tetgen/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
   };
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp tetgen $out/bin
   '';
 
diff --git a/pkgs/applications/science/logic/coq/default.nix b/pkgs/applications/science/logic/coq/default.nix
index fcd342e0b594b..35395bd25d1ed 100644
--- a/pkgs/applications/science/logic/coq/default.nix
+++ b/pkgs/applications/science/logic/coq/default.nix
@@ -29,7 +29,7 @@ stdenv.mkDerivation {
 
   buildFlags = "world"; # Debug with "world VERBOSE=1";
 
-  patches = [ ./configure.patch ];
+  patches = [ ./configure.patch ./coq-8.3-make-3.82-compat.patch ];
 
   postPatch = ''
     UNAME=$(type -tp uname)
diff --git a/pkgs/applications/science/logic/hol/default.nix b/pkgs/applications/science/logic/hol/default.nix
index 63040b7fdd52b..5552fadc55598 100644
--- a/pkgs/applications/science/logic/hol/default.nix
+++ b/pkgs/applications/science/logic/hol/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation {
   buildInputs = [polyml];
 
   buildCommand = ''
-    ensureDir "$out/src"
+    mkdir -p "$out/src"
     cd  "$out/src"
 
     tar -xzf "$src"
@@ -28,7 +28,7 @@ stdenv.mkDerivation {
     
     bin/build -expk -symlink
 
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     ln -st $out/bin  $out/src/hol/bin/*
     # ln -s $out/src/hol/bin $out/bin
   '';
diff --git a/pkgs/applications/science/logic/hol_light/default.nix b/pkgs/applications/science/logic/hol_light/default.nix
index 06d349ad3c8b9..88f3f788376c0 100644
--- a/pkgs/applications/science/logic/hol_light/default.nix
+++ b/pkgs/applications/science/logic/hol_light/default.nix
@@ -27,7 +27,7 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir "$out/lib/hol_light" "$out/bin"
+    mkdir -p "$out/lib/hol_light" "$out/bin"
     cp -a  . $out/lib/hol_light
     echo "${start_script}" > "$out/bin/hol_light"
     chmod a+x "$out/bin/hol_light"
diff --git a/pkgs/applications/science/logic/iprover/default.nix b/pkgs/applications/science/logic/iprover/default.nix
index 7bfd8dff12e30..91d8c122a8d4f 100644
--- a/pkgs/applications/science/logic/iprover/default.nix
+++ b/pkgs/applications/science/logic/iprover/default.nix
@@ -30,10 +30,10 @@ rec {
   phaseNames = ["doConfigure" "doMake" "doDeploy"];
   configureCommand = "sh configure";
   doDeploy = a.fullDepEntry (''
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     cp iproveropt "$out/bin"
 
-    ensureDir "$out/share/${name}"
+    mkdir -p "$out/share/${name}"
     cp *.p "$out/share/${name}"
     echo -e "#! /bin/sh\\n$out/bin/iproveropt --clausifier \"${eprover}/bin/eprover\" --clausifier_options \" --tstp-format --silent --cnf \" \"\$@\"" > "$out"/bin/iprover
     chmod a+x  "$out"/bin/iprover
diff --git a/pkgs/applications/science/logic/isabelle/default.nix b/pkgs/applications/science/logic/isabelle/default.nix
index 7cfe5f927363e..4a268cac64557 100644
--- a/pkgs/applications/science/logic/isabelle/default.nix
+++ b/pkgs/applications/science/logic/isabelle/default.nix
@@ -41,7 +41,7 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     mv $TMP/$name $out
     cd $out/$name
     bin/isabelle install -p $out/bin
diff --git a/pkgs/applications/science/logic/leo2/default.nix b/pkgs/applications/science/logic/leo2/default.nix
index 04ab9a5b5ab3a..6b17d7e8f50a6 100644
--- a/pkgs/applications/science/logic/leo2/default.nix
+++ b/pkgs/applications/science/logic/leo2/default.nix
@@ -29,17 +29,17 @@ rec {
   phaseNames = ["makeInstallationDir" "doUnpack" "doMake" "doFinalize"];
 
   makeInstallationDir = a.fullDepEntry (''
-    ensureDir "$out/share/leo2/build-dir"
+    mkdir -p "$out/share/leo2/build-dir"
     cd "$out/share/leo2/build-dir"
   '') ["minInit" "defEnsureDir"];
 
   goSrcDir = "cd src/";
 
   doFinalize = a.fullDepEntry (''
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     echo -e "#! /bin/sh\\n$PWD/../bin/leo --atprc $out/etc/leoatprc \"\$@\"\\n" > "$out/bin/leo"
     chmod a+x "$out/bin/leo"
-    ensureDir "$out/etc"
+    mkdir -p "$out/etc"
     echo -e "e = ${eprover}/bin/eprover\\nepclextract = ${eprover}/bin/epclextract" > "$out/etc/leoatprc"
   '') ["minInit" "doMake" "defEnsureDir"];
 
diff --git a/pkgs/applications/science/logic/matita/default.nix b/pkgs/applications/science/logic/matita/default.nix
index 92e9479d9a442..0713ff09e9299 100644
--- a/pkgs/applications/science/logic/matita/default.nix
+++ b/pkgs/applications/science/logic/matita/default.nix
@@ -41,7 +41,7 @@ stdenv.mkDerivation {
   '';
 
   postInstall = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     ln -vs $RTDIR/matita $RTDIR/matitac $RTDIR/matitaclean $RTDIR/matitadep $RTDIR/matitawiki $out/bin
   '';
 
diff --git a/pkgs/applications/science/logic/minisat/default.nix b/pkgs/applications/science/logic/minisat/default.nix
index 34a6bd7ceff34..1f29b3aa1a112 100644
--- a/pkgs/applications/science/logic/minisat/default.nix
+++ b/pkgs/applications/science/logic/minisat/default.nix
@@ -29,7 +29,7 @@ rec {
   phaseNames = ["setVars" "doMake" "doDeploy"];
   goSrcDir = "cd simp";
   doDeploy = a.fullDepEntry (''
-    ensureDir "$out"/bin
+    mkdir -p "$out"/bin
     cp minisat_static "$out/bin"/minisat
   '') ["minInit" "defEnsureDir"];
   makeFlags = ["rs"];
diff --git a/pkgs/applications/science/logic/picosat/default.nix b/pkgs/applications/science/logic/picosat/default.nix
index 5a92c103961c1..970daf739fca8 100644
--- a/pkgs/applications/science/logic/picosat/default.nix
+++ b/pkgs/applications/science/logic/picosat/default.nix
@@ -22,13 +22,13 @@ stdenv.mkDerivation rec {
   '';
 
   installPhase = ''
-   ensureDir "$out"/bin
+   mkdir -p "$out"/bin
    cp picomus "$out"/bin
    cp picosat "$out"/bin
-   ensureDir "$out"/lib
+   mkdir -p "$out"/lib
    cp libpicosat.a "$out"/lib
    cp libpicosat.so "$out"/lib
-   ensureDir "$out"/include/picosat
+   mkdir -p "$out"/include/picosat
    cp picosat.h "$out"/include/picosat
   '';
 
diff --git a/pkgs/applications/science/logic/prover9/default.nix b/pkgs/applications/science/logic/prover9/default.nix
index 129abef0b3d74..7ac3831f6a560 100644
--- a/pkgs/applications/science/logic/prover9/default.nix
+++ b/pkgs/applications/science/logic/prover9/default.nix
@@ -24,7 +24,7 @@ stdenv.mkDerivation {
   buildFlags = "all";
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp bin/* $out/bin
   '';
 
diff --git a/pkgs/applications/science/logic/satallax/default.nix b/pkgs/applications/science/logic/satallax/default.nix
index 4bf6e53737e94..2126a4d76d635 100644
--- a/pkgs/applications/science/logic/satallax/default.nix
+++ b/pkgs/applications/science/logic/satallax/default.nix
@@ -34,21 +34,21 @@ rec {
       make
     )
 
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     cp minisat/simp/minisat "$out/bin"
 
     echo "(setq *minisat-binary* \"$out/bin/minisat\")" > config.lisp
 
   '') ["defEnsureDir" "minInit" "addInputs" "doUnpack"];
   doDeploy = a.fullDepEntry (''
-    ensureDir "$out/share/satallax/build-dir"
+    mkdir -p "$out/share/satallax/build-dir"
     cp -r * "$out/share/satallax/build-dir"
     cd  "$out/share/satallax/build-dir"
 
     sbcl --load make.lisp
     ! ( ./test | grep ERROR )
     
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     cp bin/satallax "$out/bin"
   '') ["defEnsureDir" "minInit" "addInputs" "doUnpack"];
       
diff --git a/pkgs/applications/science/logic/ssreflect/default.nix b/pkgs/applications/science/logic/ssreflect/default.nix
index 5a51fe2136a1f..8443974a0a0aa 100644
--- a/pkgs/applications/science/logic/ssreflect/default.nix
+++ b/pkgs/applications/science/logic/ssreflect/default.nix
@@ -31,7 +31,7 @@ stdenv.mkDerivation {
 
   installPhase = ''
     COQLIB=$out/lib/coq make -f Makefile.coq install -e
-    ensureDir $out/bin
+    mkdir -p $out/bin
   '';
 
   meta = {
diff --git a/pkgs/applications/science/logic/tptp/default.nix b/pkgs/applications/science/logic/tptp/default.nix
index 3211b6ebdc01e..11b8f7ce535a5 100644
--- a/pkgs/applications/science/logic/tptp/default.nix
+++ b/pkgs/applications/science/logic/tptp/default.nix
@@ -31,7 +31,7 @@ rec {
     "patchBinaries" "makeLinks"];
 
   goTarget = a.fullDepEntry ''
-    ensureDir "$out"/share/
+    mkdir -p "$out"/share/
     cd "$out"/share/
   '' ["defEnsureDir" "minInit"];
 
@@ -54,7 +54,7 @@ rec {
   '' ["addInputs"];
 
   makeLinks = a.fullDepEntry ''
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     ln -s "../share/tptp/TPTP2X/tptp2X" "$out/bin"
     ln -s "../share/tptp/Scripts/tptp2T" "$out/bin"
     ln -s "../share/tptp/Scripts/tptp4X" "$out/bin"
diff --git a/pkgs/applications/science/math/content/default.nix b/pkgs/applications/science/math/content/default.nix
index 15abc928f0fb3..87c047c299573 100644
--- a/pkgs/applications/science/math/content/default.nix
+++ b/pkgs/applications/science/math/content/default.nix
@@ -77,7 +77,7 @@ rec {
   '') ["addInputs" "buildVibrant" "setPlatform"];
 
   install = a.fullDepEntry (''
-    ensureDir $out/share/${name}/build-snapshot $out/bin $out/lib $out/share/${name}/doc
+    mkdir -p $out/share/${name}/build-snapshot $out/bin $out/lib $out/share/${name}/doc
     find . -name '*.o' -exec cp '{}' $out/lib ';'
     find . -name '*.so' -exec cp '{}' $out/lib ';'
     find . -name '*.txt' -exec cp '{}' $out/share/${name}/doc ';'
diff --git a/pkgs/applications/science/math/eukleides/default.nix b/pkgs/applications/science/math/eukleides/default.nix
index 9f65bcb8c1480..d15bed8476e7a 100644
--- a/pkgs/applications/science/math/eukleides/default.nix
+++ b/pkgs/applications/science/math/eukleides/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation {
   buildInputs = [bison flex texinfo readline texLive];
 
   preConfigure = "sed -i 's/ginstall-info/install-info/g' doc/Makefile";
-  installPhase = "ensureDir $out/bin ; make PREFIX=$out install";
+  installPhase = "mkdir -p $out/bin ; make PREFIX=$out install";
 
   meta = {
     description = "Geometry Drawing Language";
diff --git a/pkgs/applications/science/math/maxima/default.nix b/pkgs/applications/science/math/maxima/default.nix
index 02b7017d2953f..0d3a12b38c288 100644
--- a/pkgs/applications/science/math/maxima/default.nix
+++ b/pkgs/applications/science/math/maxima/default.nix
@@ -24,7 +24,7 @@ stdenv.mkDerivation {
       wrapProgram "$prog" --prefix PATH ":" "${searchPath}"
     done
     # Move emacs modules and documentation into the right place.
-    ensureDir $out/share/emacs $out/share/doc
+    mkdir -p $out/share/emacs $out/share/doc
     ln -s ../maxima/${version}/emacs $out/share/emacs/site-lisp
     ln -s ../maxima/${version}/doc $out/share/doc/maxima
   '';
diff --git a/pkgs/applications/science/math/msieve/default.nix b/pkgs/applications/science/math/msieve/default.nix
index baee2f23d4ca6..c8b388a06b78a 100644
--- a/pkgs/applications/science/math/msieve/default.nix
+++ b/pkgs/applications/science/math/msieve/default.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation {
                else if stdenv.system == "i686-linux" then "x86"
                else "generic";
 
-  installPhase = ''ensureDir $out/bin/
+  installPhase = ''mkdir -p $out/bin/
                    cp msieve $out/bin/'';
 
   meta = {
diff --git a/pkgs/applications/science/math/singular/default.nix b/pkgs/applications/science/math/singular/default.nix
index dfc97eca8ebeb..5c5dfae8200f7 100644
--- a/pkgs/applications/science/math/singular/default.nix
+++ b/pkgs/applications/science/math/singular/default.nix
@@ -37,7 +37,7 @@ rec {
   fixInstall = a.fullDepEntry (''
     rm -rf "$out/LIB"
     cp -r Singular/LIB "$out"
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     ln -s "$out"/*/Singular "$out/bin"
   '') ["minInit" "defEnsureDir"];
       
diff --git a/pkgs/applications/taxes/aangifte-2005/builder.sh b/pkgs/applications/taxes/aangifte-2005/builder.sh
index e6b2bb8787ec3..8d284176d4447 100644
--- a/pkgs/applications/taxes/aangifte-2005/builder.sh
+++ b/pkgs/applications/taxes/aangifte-2005/builder.sh
@@ -10,7 +10,7 @@ buildPhase() {
 }
 
 installPhase() {
-    ensureDir $out
+    mkdir -p $out
     cp -prvd * $out/
 }
 
diff --git a/pkgs/applications/taxes/aangifte-2006/builder.sh b/pkgs/applications/taxes/aangifte-2006/builder.sh
index e6b2bb8787ec3..8d284176d4447 100644
--- a/pkgs/applications/taxes/aangifte-2006/builder.sh
+++ b/pkgs/applications/taxes/aangifte-2006/builder.sh
@@ -10,7 +10,7 @@ buildPhase() {
 }
 
 installPhase() {
-    ensureDir $out
+    mkdir -p $out
     cp -prvd * $out/
 }
 
diff --git a/pkgs/applications/taxes/aangifte-2007/builder.sh b/pkgs/applications/taxes/aangifte-2007/builder.sh
index e89ba5ae36ff9..f400f1b8855bd 100644
--- a/pkgs/applications/taxes/aangifte-2007/builder.sh
+++ b/pkgs/applications/taxes/aangifte-2007/builder.sh
@@ -12,7 +12,7 @@ buildPhase() {
 }
 
 installPhase() {
-    ensureDir $out
+    mkdir -p $out
     cp -prvd * $out/
 }
 
diff --git a/pkgs/applications/taxes/aangifte-2008/builder.sh b/pkgs/applications/taxes/aangifte-2008/builder.sh
index e89ba5ae36ff9..f400f1b8855bd 100644
--- a/pkgs/applications/taxes/aangifte-2008/builder.sh
+++ b/pkgs/applications/taxes/aangifte-2008/builder.sh
@@ -12,7 +12,7 @@ buildPhase() {
 }
 
 installPhase() {
-    ensureDir $out
+    mkdir -p $out
     cp -prvd * $out/
 }
 
diff --git a/pkgs/applications/taxes/aangifte-2009/default.nix b/pkgs/applications/taxes/aangifte-2009/default.nix
index 231670d263b5e..eeeb4a1d1e535 100644
--- a/pkgs/applications/taxes/aangifte-2009/default.nix
+++ b/pkgs/applications/taxes/aangifte-2009/default.nix
@@ -25,7 +25,7 @@ stdenv.mkDerivation {
 
   installPhase =
     ''
-      ensureDir $out
+      mkdir -p $out
       cp -prvd * $out/
       wrapProgram $out/bin/ib2009ux --prefix PATH : ${xdg_utils}/bin
     '';
diff --git a/pkgs/applications/taxes/aangifte-2010/default.nix b/pkgs/applications/taxes/aangifte-2010/default.nix
index cd8a3b62269b8..65ff561ee9ef6 100644
--- a/pkgs/applications/taxes/aangifte-2010/default.nix
+++ b/pkgs/applications/taxes/aangifte-2010/default.nix
@@ -25,7 +25,7 @@ stdenv.mkDerivation {
 
   installPhase =
     ''
-      ensureDir $out
+      mkdir -p $out
       cp -prvd * $out/
       wrapProgram $out/bin/ib2010ux --prefix PATH : ${xdg_utils}/bin
     '';
diff --git a/pkgs/applications/version-management/bazaar/default.nix b/pkgs/applications/version-management/bazaar/default.nix
index 8eb28ea04c734..462aede3b1c78 100644
--- a/pkgs/applications/version-management/bazaar/default.nix
+++ b/pkgs/applications/version-management/bazaar/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ pythonPackages.python pythonPackages.wrapPython ];
 
   # Readline support is needed by bzrtools.
-  pythonPath = [ pythonPackages.ssl pythonPackages.readline ];
+  pythonPath = [ pythonPackages.readline ];
 
   installPhase = ''
     python setup.py install --prefix=$out
diff --git a/pkgs/applications/version-management/fossil/default.nix b/pkgs/applications/version-management/fossil/default.nix
index 7b84dcecb6384..325d2e77e1a34 100644
--- a/pkgs/applications/version-management/fossil/default.nix
+++ b/pkgs/applications/version-management/fossil/default.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation {
   checkTarget = "test";
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     INSTALLDIR=$out/bin make install
   '';
 
diff --git a/pkgs/applications/version-management/git-and-tools/fast-export/default.nix b/pkgs/applications/version-management/git-and-tools/fast-export/default.nix
index 45860362433f4..44e9cd535be6f 100644
--- a/pkgs/applications/version-management/git-and-tools/fast-export/default.nix
+++ b/pkgs/applications/version-management/git-and-tools/fast-export/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation {
   installPhase = ''
     sed -i "s@/usr/bin/env.*@$(type -p python)@" *.py
     l=$out/libexec/git-fast-export
-    ensureDir $out/{bin,doc/git-fast-export} $l
+    mkdir -p $out/{bin,doc/git-fast-export} $l
     mv *.txt $out/doc/git-fast-export
     sed -i "s@ROOT=.*@ROOT=$l@" *.sh
     mv *.sh $out/bin
diff --git a/pkgs/applications/version-management/git-and-tools/git/default.nix b/pkgs/applications/version-management/git-and-tools/git/default.nix
index 24390bc39084f..62f7d6d3574a8 100644
--- a/pkgs/applications/version-management/git-and-tools/git/default.nix
+++ b/pkgs/applications/version-management/git-and-tools/git/default.nix
@@ -42,11 +42,11 @@ stdenv.mkDerivation {
       }
 
       # Install contrib stuff.
-      ensureDir $out/share/git
+      mkdir -p $out/share/git
       mv contrib $out/share/git/
-      ensureDir $out/share/emacs/site-lisp
+      mkdir -p $out/share/emacs/site-lisp
       ln -s "$out/share/git/contrib/emacs/"*.el $out/share/emacs/site-lisp/
-      ensureDir $out/etc/bash_completion.d
+      mkdir -p $out/etc/bash_completion.d
       ln -s $out/share/git/contrib/completion/git-completion.bash $out/etc/bash_completion.d/
 
       # grep is a runtime dependence, need to patch so that it's found
diff --git a/pkgs/applications/version-management/git-and-tools/git/git-git.nix b/pkgs/applications/version-management/git-and-tools/git/git-git.nix
index a3b2a60953a59..6371e504bfb26 100644
--- a/pkgs/applications/version-management/git-and-tools/git/git-git.nix
+++ b/pkgs/applications/version-management/git-and-tools/git/git-git.nix
@@ -48,7 +48,7 @@ stdenv.mkDerivation rec {
     ''
       # Install Emacs mode.
       echo "installing Emacs mode..."
-      ensureDir $out/share/emacs/site-lisp
+      mkdir -p $out/share/emacs/site-lisp
       cp -p contrib/emacs/*.el $out/share/emacs/site-lisp
 
       wrapArgs=
@@ -86,7 +86,7 @@ stdenv.mkDerivation rec {
 
    + ''# install bash completion script
       d="$out/etc/bash_completion.d"
-      ensureDir $d; cp contrib/completion/git-completion.bash "$d"
+      mkdir -p $d; cp contrib/completion/git-completion.bash "$d"
      '';
 
   meta = {
diff --git a/pkgs/applications/version-management/git-and-tools/stgit/default.nix b/pkgs/applications/version-management/git-and-tools/stgit/default.nix
index 7d622c4067c15..a933ae84e603d 100644
--- a/pkgs/applications/version-management/git-and-tools/stgit/default.nix
+++ b/pkgs/applications/version-management/git-and-tools/stgit/default.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation {
   makeFlags = "prefix=$$out";
 
   postInstall = ''
-    ensureDir "$out/etc/bash_completion.d/"
+    mkdir -p "$out/etc/bash_completion.d/"
     ln -s ../../share/stgit/completion/stgit-completion.bash "$out/etc/bash_completion.d/"
   '';
 
diff --git a/pkgs/applications/version-management/git-and-tools/topgit/default.nix b/pkgs/applications/version-management/git-and-tools/topgit/default.nix
index ef8bb1b4dcfde..4b19260518223 100644
--- a/pkgs/applications/version-management/git-and-tools/topgit/default.nix
+++ b/pkgs/applications/version-management/git-and-tools/topgit/default.nix
@@ -16,9 +16,9 @@ stdenv.mkDerivation {
   configurePhase = "export prefix=$out";
 
   postInstall = ''
-    ensureDir "$out/share/doc/topgit-${version}"
+    mkdir -p "$out/share/doc/topgit-${version}"
     cp README "$out/share/doc/topgit-${version}/"
-    ensureDir "$out/etc/bash_completion.d"
+    mkdir -p "$out/etc/bash_completion.d"
     make prefix="$out" install
     mv "contrib/tg-completion.bash" "$out/etc/bash_completion.d/"
   '';
diff --git a/pkgs/applications/version-management/meld/default.nix b/pkgs/applications/version-management/meld/default.nix
index 4775a419fd146..42650b3afb30e 100644
--- a/pkgs/applications/version-management/meld/default.nix
+++ b/pkgs/applications/version-management/meld/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, xz, pygtk, python, intltool, scrollkeeper, makeWrapper }:
+{stdenv, fetchurl, pygtk, python, intltool, scrollkeeper, makeWrapper }:
 
 let
   minor = "1.5";
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
     sha256 = "05rbkqflbqnh2c4682d2fmidhwz2bvlggrhp1p7xbi3z8ci87pdx";
   };
 
-  buildInputs = [ pygtk python intltool scrollkeeper makeWrapper xz ];
+  buildInputs = [ pygtk python intltool scrollkeeper makeWrapper ];
 
   patchPhase = ''
     sed -e s,/usr/local,$out, -i INSTALL
diff --git a/pkgs/applications/version-management/mercurial/default.nix b/pkgs/applications/version-management/mercurial/default.nix
index 976963e684bd2..19c7c0e9f910c 100644
--- a/pkgs/applications/version-management/mercurial/default.nix
+++ b/pkgs/applications/version-management/mercurial/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, python, makeWrapper, docutils, unzip
-, guiSupport ? false, tk ? null, ssl, curses }:
+, guiSupport ? false, tk ? null, curses }:
 
 let
   name = "mercurial-2.0.2";
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
   };
 
   inherit python; # pass it so that the same version can be used in hg2git
-  pythonPackages = [ ssl curses ];
+  pythonPackages = [ curses ];
 
   buildInputs = [ python makeWrapper docutils unzip ];
 
@@ -21,7 +21,7 @@ stdenv.mkDerivation {
 
   postInstall = (stdenv.lib.optionalString guiSupport
     ''
-      ensureDir $out/etc/mercurial
+      mkdir -p $out/etc/mercurial
       cp contrib/hgk $out/bin
       cat >> $out/etc/mercurial/hgrc << EOF
       [extensions]
@@ -35,12 +35,12 @@ stdenv.mkDerivation {
     ''
       for i in $(cd $out/bin && ls); do
         wrapProgram $out/bin/$i \
-          --prefix PYTHONPATH : "$(toPythonPath "$out ${ssl} ${curses}")" \
+          --prefix PYTHONPATH : "$(toPythonPath "$out ${curses}")" \
           $WRAP_TK
       done
 
       # copy hgweb.cgi to allow use in apache
-      ensureDir $out/share/cgi-bin
+      mkdir -p $out/share/cgi-bin
       cp -v hgweb.cgi $out/share/cgi-bin
       chmod u+x $out/share/cgi-bin/hgweb.cgi
     '';
diff --git a/pkgs/applications/version-management/monotone/default.nix b/pkgs/applications/version-management/monotone/default.nix
index 70dd669e30fd3..cde31b5cef97b 100644
--- a/pkgs/applications/version-management/monotone/default.nix
+++ b/pkgs/applications/version-management/monotone/default.nix
@@ -19,9 +19,9 @@ stdenv.mkDerivation rec {
   buildInputs = [boost zlib botan libidn lua pcre sqlite pkgconfig];
 
   postInstall = ''
-    ensureDir $out/share/${name}
+    mkdir -p $out/share/${name}
     cp -rv contrib/ $out/share/${name}/contrib
-    ensureDir $out/lib/perl5/site_perl/${perlVersion}
+    mkdir -p $out/lib/perl5/site_perl/${perlVersion}
     cp -v contrib/Monotone.pm $out/lib/perl5/site_perl/${perlVersion}
   '';
 
diff --git a/pkgs/applications/version-management/veracity/default.nix b/pkgs/applications/version-management/veracity/default.nix
index b4aa63ed01480..91650deb077d3 100644
--- a/pkgs/applications/version-management/veracity/default.nix
+++ b/pkgs/applications/version-management/veracity/default.nix
@@ -37,10 +37,10 @@ rec {
   '' else "") ["doMake" "minInit"];
 
   prepare_sgneeds = a.fullDepEntry (''
-    ensureDir "$out/sgneeds/include/spidermonkey"
+    mkdir -p "$out/sgneeds/include/spidermonkey"
     for d in bin include lib; do 
-      ensureDir "$out/sgneeds/$d"
-      ensureDir "$out/sgneeds/$d"
+      mkdir -p "$out/sgneeds/$d"
+      mkdir -p "$out/sgneeds/$d"
       for p in "${spidermonkey_1_8_0rc1}"; do
         for f in "$p"/"$d"/*; do
 	  ln -sf "$f" "$out"/sgneeds/"$d"
@@ -53,7 +53,7 @@ rec {
 	done
       done
 
-    ensureDir "$out/sgneeds/include/sgbrings"
+    mkdir -p "$out/sgneeds/include/sgbrings"
     ln -s "$out/sgneeds/include/js" "$out/sgneeds/include/sgbrings/js"
     for f in "$out/sgneeds/lib/"libjs*; do
       bn="$(basename "$f")"
@@ -84,7 +84,7 @@ rec {
   '' ["minInit"];
 
   doDeploy = a.fullDepEntry ''
-    ensureDir "$out/bin" "$out/share/veracity/"
+    mkdir -p "$out/bin" "$out/share/veracity/"
     cp -r .. "$out/share/veracity/build-dir"
     ln -s "$out/share/veracity/build-dir/build/src/cmd/vv" "$out/bin"
     ln -s "$out/share/veracity/build-dir/build/src/script/vscript" "$out/bin"
diff --git a/pkgs/applications/version-management/viewmtn/0.10.nix b/pkgs/applications/version-management/viewmtn/0.10.nix
index a8ced15b58c50..d5e7d1e7c83aa 100644
--- a/pkgs/applications/version-management/viewmtn/0.10.nix
+++ b/pkgs/applications/version-management/viewmtn/0.10.nix
@@ -26,9 +26,9 @@ rec {
 
     fullOut=$(toPythonPath $out)
     
-    ensureDir $fullOut
-    ensureDir $out/bin
-    ensureDir $out/share/viewmtn
+    mkdir -p $fullOut
+    mkdir -p $out/bin
+    mkdir -p $out/share/viewmtn
     
     cp -r * $fullOut
     cp $fullOut/viewmtn.py $out/bin
diff --git a/pkgs/applications/video/RealPlayer/builder.sh b/pkgs/applications/video/RealPlayer/builder.sh
index 6a0276d01e4cb..9929634921cb5 100644
--- a/pkgs/applications/video/RealPlayer/builder.sh
+++ b/pkgs/applications/video/RealPlayer/builder.sh
@@ -1,7 +1,7 @@
 source $stdenv/setup
 source $makeWrapper
 
-ensureDir $out/real
+mkdir -p $out/real
 
 skip=143273 # Look for "BZh91" in the executable. 
 
@@ -11,7 +11,7 @@ rm -rf $out/real/Bin $out/real/postinst
 
 patchelf --interpreter $(cat $NIX_GCC/nix-support/dynamic-linker) $out/real/realplay.bin
 
-ensureDir $out/bin
+mkdir -p $out/bin
 makeWrapper "$out/real/realplay.bin" "$out/bin/realplay" \
     --set HELIX_LIBS "$out/real" \
     --suffix-each LD_LIBRARY_PATH ':' "$(addSuffix /lib $libPath)"
diff --git a/pkgs/applications/video/gnash/default.nix b/pkgs/applications/video/gnash/default.nix
index 81b33849887c2..5e6d1d8f942a8 100644
--- a/pkgs/applications/video/gnash/default.nix
+++ b/pkgs/applications/video/gnash/default.nix
@@ -78,7 +78,7 @@ stdenv.mkDerivation rec {
   # XXX: Tests currently fail.
   doCheck = false;
 
-  preInstall = ''ensureDir $out/plugins'';
+  preInstall = ''mkdir -p $out/plugins'';
   postInstall = ''
     make install-plugins
 
diff --git a/pkgs/applications/video/lxdvdrip/default.nix b/pkgs/applications/video/lxdvdrip/default.nix
index 5a2c6287c6f58..9323a1cbd32a6 100644
--- a/pkgs/applications/video/lxdvdrip/default.nix
+++ b/pkgs/applications/video/lxdvdrip/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation {
   '';
 
   preInstall = ''
-    ensureDir $out/man/man1 $out/bin $out/share $out/etc
+    mkdir -p $out/man/man1 $out/bin $out/share $out/etc
   '';
 
   buildInputs = [ libdvdread ];
diff --git a/pkgs/applications/video/mythtv/builder.sh b/pkgs/applications/video/mythtv/builder.sh
index c73132b47bcc1..31edf87641bbc 100644
--- a/pkgs/applications/video/mythtv/builder.sh
+++ b/pkgs/applications/video/mythtv/builder.sh
@@ -17,7 +17,7 @@ buildPhase() {
 
 postInstall() {
     sqlDir="$out/share/mythtv/sql"
-    ensureDir $sqlDir
+    mkdir -p $sqlDir
     cp -p ./database/mc.sql $sqlDir/
 }
 
diff --git a/pkgs/applications/video/vlc/default.nix b/pkgs/applications/video/vlc/default.nix
index a728059beff0f..43e41bd840d8b 100644
--- a/pkgs/applications/video/vlc/default.nix
+++ b/pkgs/applications/video/vlc/default.nix
@@ -12,13 +12,13 @@ stdenv.mkDerivation rec {
   name = "vlc-${version}";
   version = "2.0.0";
 
-  patchPhase = ''sed -e "s@/bin/echo@echo@g" -i configure'';
-
   src = fetchurl {
     url = "http://download.videolan.org/pub/videolan/vlc/${version}/${name}.tar.xz";
     sha256 = "455fc04b5f7ce3d7294ed71a9dd172ff4eb97875cfc30b554ef4ce55ec6f5106";
   };
 
+  patches = [ ./zlib.patch ];
+
   buildInputs =
     [ xz bzip2 perl zlib a52dec libmad faad2 ffmpeg alsaLib libdvdnav libdvdnav.libdvdread
       libbluray dbus fribidi qt4 libvorbis libtheora speex lua5 libgcrypt
@@ -35,6 +35,8 @@ stdenv.mkDerivation rec {
       "--with-kde-solid=$out/share/apps/solid/actions"
     ];
 
+  preConfigure = ''sed -e "s@/bin/echo@echo@g" -i configure'';
+
   enableParallelBuilding = true;
 
   preBuild = ''
diff --git a/pkgs/applications/video/vlc/zlib.patch b/pkgs/applications/video/vlc/zlib.patch
new file mode 100644
index 0000000000000..b94f7de9332a4
--- /dev/null
+++ b/pkgs/applications/video/vlc/zlib.patch
@@ -0,0 +1,35 @@
+From https://401629.bugs.gentoo.org/attachment.cgi?id=300539
+Fix building VLC against zlib 1.2.6.
+
+http://bugs.gentoo.org/401629
+http://trac.videolan.org/vlc/ticket/5964
+
+--- a/modules/gui/skins2/src/theme_loader.cpp
++++ b/modules/gui/skins2/src/theme_loader.cpp
+@@ -768,7 +768,7 @@
+     {
+         void *toClose = currentGzVp;
+         currentGzVp = NULL;  currentGzFd = -1;
+-        return gzclose( toClose );
++        return gzclose( (gzFile) toClose );
+     }
+     return -1;
+ }
+@@ -777,7 +777,7 @@
+ {
+     if( currentGzVp != NULL && fd != -1 )
+     {
+-        return gzread( currentGzVp, p_buffer, i_length );
++        return gzread( (gzFile) currentGzVp, p_buffer, i_length );
+     }
+     return -1;
+ }
+@@ -786,7 +786,7 @@
+ {
+     if( currentGzVp != NULL && fd != -1 )
+     {
+-        return gzwrite( currentGzVp, const_cast<void*>(p_buffer), i_length );
++        return gzwrite( (gzFile) currentGzVp, const_cast<void*>(p_buffer), i_length );
+     }
+     return -1;
+ }
diff --git a/pkgs/applications/video/xine-ui/default.nix b/pkgs/applications/video/xine-ui/default.nix
index 7faa572a0c989..38bacb2511772 100644
--- a/pkgs/applications/video/xine-ui/default.nix
+++ b/pkgs/applications/video/xine-ui/default.nix
@@ -1,5 +1,5 @@
 {stdenv, fetchurl, pkgconfig, xlibs, xineLib, libpng12, readline, ncurses, curl
-, lirc, xz, shared_mime_info }:
+, lirc, shared_mime_info }:
 
 stdenv.mkDerivation rec {
   name = "xine-ui-0.99.6";
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
     sha256 = "1wwylnckm5kfq5fi154w8jqf5cwvp7c1ani15q7sgfrfdkmy7caf";
   };
   
-  buildNativeInputs = [ xz pkgconfig shared_mime_info ];
+  buildNativeInputs = [ pkgconfig shared_mime_info ];
 
   buildInputs =
     [ xineLib libpng12 readline ncurses curl lirc
diff --git a/pkgs/applications/virtualization/nova/client.nix b/pkgs/applications/virtualization/nova/client.nix
index 4a3c730c3ccdf..bb65f80d20660 100644
--- a/pkgs/applications/virtualization/nova/client.nix
+++ b/pkgs/applications/virtualization/nova/client.nix
@@ -9,7 +9,7 @@ pythonPackages.buildPythonPackage rec {
     md5 = "8f53a308e08b2af4645281917be77ffc";
   };
 
-  pythonPath = [ pythonPackages.prettytable pythonPackages.argparse pythonPackages.httplib2 pythonPackages.ssl ];
+  pythonPath = [ pythonPackages.prettytable pythonPackages.argparse pythonPackages.httplib2 ];
 
   buildInputs = [ pythonPackages.mock pythonPackages.nose ];
 
diff --git a/pkgs/applications/virtualization/qemu/linux-img/default.nix b/pkgs/applications/virtualization/qemu/linux-img/default.nix
index 23e2ab174771b..58a2b29c2597b 100644
--- a/pkgs/applications/virtualization/qemu/linux-img/default.nix
+++ b/pkgs/applications/virtualization/qemu/linux-img/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
 
   installPhase =
     ''
-      ensureDir $out/share/qemu-images
+      mkdir -p $out/share/qemu-images
       bunzip2 < $src > $out/share/qemu-images/linux-0.2.img
     '';
 
diff --git a/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix b/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix
index 9dfe9c26c0de7..f9adf6132f5da 100644
--- a/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix
+++ b/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
   buildInputs = [ patchelf cdrkit makeWrapper ];
 
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp -r install/* $out
 
   '';
@@ -78,10 +78,10 @@ stdenv.mkDerivation {
     sed -i -e "s|/usr/bin|$out/bin|" bin/VBoxClient-all
     
     # Install binaries
-    ensureDir $out/sbin
+    mkdir -p $out/sbin
     install -m 755 sbin/VBoxService $out/sbin
 
-    ensureDir $out/bin
+    mkdir -p $out/bin
     install -m 755 bin/VBoxClient $out/bin
     install -m 755 bin/VBoxControl $out/bin
     install -m 755 bin/VBoxClient-all $out/bin
@@ -90,21 +90,21 @@ stdenv.mkDerivation {
             --prefix PATH : "${which}/bin"
 
     # Install OpenGL libraries
-    ensureDir $out/lib
+    mkdir -p $out/lib
     cp -v lib/VBoxOGL*.so $out/lib
-    ensureDir $out/lib/dri
+    mkdir -p $out/lib/dri
     ln -s $out/lib/VBoxOGL.so $out/lib/dri/vboxvideo_dri.so
     
     # Install desktop file
-    ensureDir $out/share/autostart
+    mkdir -p $out/share/autostart
     cp -v share/VBoxGuestAdditions/vboxclient.desktop $out/share/autostart
     
     # Install HAL FDI file
-    ensureDir $out/share/hal/fdi/policy
+    mkdir -p $out/share/hal/fdi/policy
     install -m 644 share/VBoxGuestAdditions/90-vboxguest.fdi $out/share/hal/fdi/policy
     
     # Install Xorg drivers
-    ensureDir $out/lib/xorg/modules/{drivers,input}
+    mkdir -p $out/lib/xorg/modules/{drivers,input}
     install -m 644 lib/VBoxGuestAdditions/vboxvideo_drv_19.so $out/lib/xorg/modules/drivers/vboxvideo_drv.so
     install -m 644 lib/VBoxGuestAdditions/vboxmouse_drv_19.so $out/lib/xorg/modules/input/vboxmouse_drv.so
     
diff --git a/pkgs/applications/virtualization/xen/default.nix b/pkgs/applications/virtualization/xen/default.nix
index 9b8cff7d9c65b..ce799242e12e6 100644
--- a/pkgs/applications/virtualization/xen/default.nix
+++ b/pkgs/applications/virtualization/xen/default.nix
@@ -6,7 +6,7 @@ with stdenv.lib;
 
 let
 
-  version = "4.0.1";
+  version = "4.0.3";
 
   libDir = if stdenv.is64bit then "lib64" else "lib";
 
@@ -37,7 +37,7 @@ stdenv.mkDerivation {
 
   src = fetchurl {
     url = "http://bits.xensource.com/oss-xen/release/${version}/xen-${version}.tar.gz";
-    sha256 = "0ww8j5fa2jxg0zyx7d7z9jyv2j47m8w420sy16w3rf8d80lisvbf";
+    sha256 = "0p4i7mm8cdsr8i9z3dij6nriyvz6la2rhm7jkyk2n8h62nnxi1b5";
   };
 
   patches =
diff --git a/pkgs/applications/window-managers/awesome/default.nix b/pkgs/applications/window-managers/awesome/default.nix
index b44f6d9f3aa8c..5110e42fb1831 100644
--- a/pkgs/applications/window-managers/awesome/default.nix
+++ b/pkgs/applications/window-managers/awesome/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, xz, cmake, gperf, imagemagick, pkgconfig, lua
+{stdenv, fetchurl, cmake, gperf, imagemagick, pkgconfig, lua
 , glib, cairo, pango, imlib2, libxcb, libxdg_basedir, xcbutil
 , xcbutilimage, xcbutilkeysyms, xcbutilwm, libpthreadstubs, libXau
 , libXdmcp, pixman, doxygen
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
     sha256 = "576b4f6d2c3f56dfbe52ad92f2eecece111f0f05816e32126cd03d4b4387761d";
   };
  
-  buildInputs = [ xz cmake gperf imagemagick pkgconfig lua glib cairo pango
+  buildInputs = [ cmake gperf imagemagick pkgconfig lua glib cairo pango
     imlib2 libxcb libxdg_basedir xcbutil xcbutilimage xcbutilkeysyms xcbutilwm
     libstartup_notification libev libpthreadstubs libXau libXdmcp pixman doxygen
     asciidoc xmlto dbus docbook_xsl docbook_xml_dtd_45 libxslt ];
diff --git a/pkgs/applications/window-managers/stumpwm/default.nix b/pkgs/applications/window-managers/stumpwm/default.nix
index 47ad4ec7aaf0f..db0b6e1037c37 100644
--- a/pkgs/applications/window-managers/stumpwm/default.nix
+++ b/pkgs/applications/window-managers/stumpwm/default.nix
@@ -23,10 +23,10 @@ rec {
   '');
 
   installation = fullDepEntry (''
-    ensureDir $out/bin 
-    ensureDir $out/share/stumpwm/doc
-    ensureDir $out/share/info 
-    ensureDir $out/share/stumpwm/lisp
+    mkdir -p $out/bin 
+    mkdir -p $out/share/stumpwm/doc
+    mkdir -p $out/share/info 
+    mkdir -p $out/share/stumpwm/lisp
 
     cp stumpwm $out/bin
     cp contrib/stumpish $out/bin || true
diff --git a/pkgs/applications/window-managers/vwm/default.nix b/pkgs/applications/window-managers/vwm/default.nix
index 7329c48f41d3b..3613bb21ff623 100644
--- a/pkgs/applications/window-managers/vwm/default.nix
+++ b/pkgs/applications/window-managers/vwm/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
   '';
 
   preInstall = ''
-    ensureDir $out/bin $out/include
+    mkdir -p $out/bin $out/include
   '';
  
   buildInputs = [ ncurses pkgconfig glib libviper libpseudo gpm libvterm ];
diff --git a/pkgs/applications/window-managers/wmii31/default.nix b/pkgs/applications/window-managers/wmii31/default.nix
index d5705af5ce180..50655a851e2a0 100644
--- a/pkgs/applications/window-managers/wmii31/default.nix
+++ b/pkgs/applications/window-managers/wmii31/default.nix
@@ -25,7 +25,7 @@ args: with args; stdenv.mkDerivation {
      set +e
      make &> /dev/null
      set -e
-     ensureDir \$out/bin
+     mkdir -p \$out/bin
      cp cmd/wmiimenu \$out/bin
   ";
   meta = { homepage = "www.suckless.org";
diff --git a/pkgs/build-support/builder-defs/builder-defs.nix b/pkgs/build-support/builder-defs/builder-defs.nix
index ba13a0911f7af..7d0f138880dcb 100644
--- a/pkgs/build-support/builder-defs/builder-defs.nix
+++ b/pkgs/build-support/builder-defs/builder-defs.nix
@@ -97,20 +97,13 @@ let inherit (builtins) head tail trace; in
 
         # changing this ? see [1]
         minInit = fullDepEntry ("
+                ${stdenv.preHook}
+                
                 set -e
                 NIX_GCC=${stdenv.gcc}
                 export SHELL=${stdenv.shell}
                 PATH_DELIMITER=':'
-        " + (if stdenv ? preHook && stdenv.preHook != null && toString stdenv.preHook != "" then 
-                "
-                param1=${stdenv.param1}
-                param2=${stdenv.param2}
-                param3=${stdenv.param3}
-                param4=${stdenv.param4}
-                param5=${stdenv.param5}
-                source ${stdenv.preHook}
-        " +         
-                "
+                
                 # Set up the initial path.
                 PATH=
                 for i in \$NIX_GCC ${toString stdenv.initialPath}; do
@@ -121,8 +114,7 @@ let inherit (builtins) head tail trace; in
 
                 prefix=${if args ? prefix then (toString args.prefix) else "\$out"}
 
-                "
-        else "")) ["defNest" "defAddToSearchPath"];
+                ") ["defNest" "defAddToSearchPath"];
                 
         # if you change this rewrite using '' instead of "" to get rid of indentation in builder scripts
         addInputs = fullDepEntry ("
@@ -320,7 +312,7 @@ let inherit (builtins) head tail trace; in
 
         # changing this ? see [1]
         doForceShare = fullDepEntry (" 
-                ensureDir \"\$prefix/share\"
+                mkdir -p \"\$prefix/share\"
                 for d in ${toString forceShare}; do
                         if [ -d \"\$prefix/\$d\" -a ! -d \"\$prefix/share/\$d\" ]; then
                                 mv -v \"\$prefix/\$d\" \"\$prefix/share\"
@@ -332,7 +324,7 @@ let inherit (builtins) head tail trace; in
         doForceCopy = fullDepEntry (''
                 name="$(basename $out)"
                 name="''${name#*-}"
-                ensureDir "$prefix/share/$name"
+                mkdir -p "$prefix/share/$name"
                 for f in ${toString forceCopy}; do
                         cp -r "$f" "$prefix/share/$name/$f" || true
                 done;
@@ -393,7 +385,7 @@ let inherit (builtins) head tail trace; in
         preservePathWrapperArguments = ''''${PATH:+ --prefix PATH : $PATH }'';
 
         doPropagate = fullDepEntry ("
-                ensureDir \$out/nix-support
+                mkdir -p \$out/nix-support
                 echo '${toString (attrByPath ["propagatedBuildInputs"] [] args)}' >\$out/nix-support/propagated-build-inputs
         ") ["minInit" "defEnsureDir"];
 
@@ -410,7 +402,7 @@ let inherit (builtins) head tail trace; in
 	'') ["minInit" "addInputs" "doUnpack"];
 
 	doScons = fullDepEntry (''
-		ensureDir $out
+		mkdir -p $out
 		${if (attrByPath ["sconsCleanEnv"] false args)
 		 then ""
 		 else ''
@@ -462,13 +454,13 @@ let inherit (builtins) head tail trace; in
                 x.text + "\n" + after ;};
 
 	createDirs = fullDepEntry (concatStringsSep ";"
-		(map (x: "ensureDir ${x}") (attrByPath ["neededDirs"] [] args))
+		(map (x: "mkdir -p ${x}") (attrByPath ["neededDirs"] [] args))
 	) ["minInit" "defEnsureDir"];
 
 	copyExtraDoc = fullDepEntry (''
           name="$(basename $out)"
           name="''${name#*-}"
-          ensureDir "$out/share/doc/$name"
+          mkdir -p "$out/share/doc/$name"
 	'' + (concatStringsSep ";"
                (map 
 	         (x: ''cp "${x}" "$out/share/doc/$name" || true;'') 
@@ -547,11 +539,11 @@ let inherit (builtins) head tail trace; in
    installFonts = 
       let retrievedName = (if args ? name then args.name else ""); in
    fullDepEntry (''
-           ensureDir $out/share/fonts/truetype/public/${retrievedName}
-           ensureDir $out/share/fonts/opentype/public/${retrievedName}
-           ensureDir $out/share/fonts/type1/public/${retrievedName}
-           ensureDir $out/share/texmf/fonts/enc/${retrievedName}
-           ensureDir $out/share/texmf/fonts/map/${retrievedName}
+           mkdir -p $out/share/fonts/truetype/public/${retrievedName}
+           mkdir -p $out/share/fonts/opentype/public/${retrievedName}
+           mkdir -p $out/share/fonts/type1/public/${retrievedName}
+           mkdir -p $out/share/texmf/fonts/enc/${retrievedName}
+           mkdir -p $out/share/texmf/fonts/map/${retrievedName}
 
         cp *.ttf $out/share/fonts/truetype/public/${retrievedName} || echo No TrueType fonts
         cp *.otf $out/share/fonts/opentype/public/${retrievedName} || echo No OpenType fonts
@@ -561,7 +553,7 @@ let inherit (builtins) head tail trace; in
    '') ["minInit" "defEnsureDir"];
 
    simplyShare = shareName: fullDepEntry (''
-     ensureDir $out/share
+     mkdir -p $out/share
      cp -r . $out/share/${shareName}
    '') ["doUnpack" "defEnsureDir"];
 
@@ -588,7 +580,7 @@ let inherit (builtins) head tail trace; in
    '') ["minInit"];
 
    createPythonInstallationTarget = fullDepEntry (''
-     ensureDir $(toPythonPath $out)
+     mkdir -p $(toPythonPath $out)
      export PYTHONPATH=$PYTHONPATH''${PYTHONPATH:+:}$(toPythonPath $out)
    '') ["minInit" "addInputs" "defEnsureDir"];
 
diff --git a/pkgs/build-support/clang-wrapper/builder.sh b/pkgs/build-support/clang-wrapper/builder.sh
index fe714a0719a11..9f1542e041135 100644
--- a/pkgs/build-support/clang-wrapper/builder.sh
+++ b/pkgs/build-support/clang-wrapper/builder.sh
@@ -1,8 +1,8 @@
 source $stdenv/setup
 
 
-ensureDir $out/bin
-ensureDir $out/nix-support
+mkdir -p $out/bin
+mkdir -p $out/nix-support
 
 
 if test -z "$nativeLibc"; then
diff --git a/pkgs/build-support/clang-wrapper/clang-wrapper.sh b/pkgs/build-support/clang-wrapper/clang-wrapper.sh
index 473adba862710..2052d2c2eb4cb 100644
--- a/pkgs/build-support/clang-wrapper/clang-wrapper.sh
+++ b/pkgs/build-support/clang-wrapper/clang-wrapper.sh
@@ -103,11 +103,6 @@ if test "$dontLink" != "1"; then
 	fi
     done
     export NIX_LDFLAGS_SET=1
-
-    if test "$NIX_STRIP_DEBUG" = "1"; then
-        # Add executable-stripping flags.
-        extraAfter=(${extraAfter[@]} $NIX_CFLAGS_STRIP)
-    fi
 fi
 
 # As a very special hack, if the arguments are just `-v', then don't
diff --git a/pkgs/build-support/dotnetenv/build-solution.nix b/pkgs/build-support/dotnetenv/build-solution.nix
index 07f1f89c67ce1..b1853bf73641a 100644
--- a/pkgs/build-support/dotnetenv/build-solution.nix
+++ b/pkgs/build-support/dotnetenv/build-solution.nix
@@ -71,14 +71,14 @@ stdenv.mkDerivation {
 	export AssemblySearchPaths=$assemblySearchPaths
     fi
     
-    ensureDir $out
+    mkdir -p $out
     MSBuild.exe ${toString slnFile} /nologo /t:${targets} /p:IntermediateOutputPath=$(cygpath --windows $out)\\ /p:OutputPath=$(cygpath --windows $out)\\ /verbosity:${verbosity} ${options}
     
     # Because .NET assemblies store strings as UTF-16 internally, we cannot detect
     # hashes. Therefore a text files containing the proper paths is created
     # We can also use this file the propagate transitive dependencies.
     
-    ensureDir $out/nix-support
+    mkdir -p $out/nix-support
     
     for i in ${toString assemblyInputs}
     do
diff --git a/pkgs/build-support/fetchcvs/builder.sh b/pkgs/build-support/fetchcvs/builder.sh
index 3a1df2553e152..6ee594b33b274 100644
--- a/pkgs/build-support/fetchcvs/builder.sh
+++ b/pkgs/build-support/fetchcvs/builder.sh
@@ -6,7 +6,7 @@ source $stdenv/setup
 # should work (but didn't - got no response on #cvs)
 # See als man Page for those options
 
-ensureDir export
+mkdir -p export
 if [ -n "$tag" ]; then
     tag="-r $tag"
 else
diff --git a/pkgs/build-support/gcc-cross-wrapper/default.nix b/pkgs/build-support/gcc-cross-wrapper/default.nix
index 8bf820e3d3413..ab879c1841fc0 100644
--- a/pkgs/build-support/gcc-cross-wrapper/default.nix
+++ b/pkgs/build-support/gcc-cross-wrapper/default.nix
@@ -20,7 +20,7 @@ let
     phases = [ "installPhase" ];
     installPhase = ''
       echo $out
-      ensureDir $out
+      mkdir -p $out
       cp -Rd ${gcc}/${cross.config}/lib $out/lib
       chmod -R +w $out/lib
       for a in $out/lib/*.la; do
diff --git a/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh
index 98baafb4878d9..f954cae05d86c 100644
--- a/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh
+++ b/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh
@@ -89,11 +89,6 @@ if test "$dontLink" != "1"; then
         fi
     done
     export NIX_CROSS_LDFLAGS_SET=1
-
-    if test "$NIX_STRIP_DEBUG" = "1"; then
-        # Add executable-stripping flags.
-        extraAfter=(${extraAfter[@]} $NIX_CFLAGS_STRIP)
-    fi
 fi
 
 # Optionally print debug info.
diff --git a/pkgs/build-support/gcc-upc-wrapper/builder.sh b/pkgs/build-support/gcc-upc-wrapper/builder.sh
index 0c9dccf6edb39..af121afe155a1 100644
--- a/pkgs/build-support/gcc-upc-wrapper/builder.sh
+++ b/pkgs/build-support/gcc-upc-wrapper/builder.sh
@@ -1,8 +1,8 @@
 source $stdenv/setup
 
 
-ensureDir $out/bin
-ensureDir $out/nix-support
+mkdir -p $out/bin
+mkdir -p $out/nix-support
 
 
 if test -z "$nativeLibc"; then
diff --git a/pkgs/build-support/gcc-upc-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-upc-wrapper/gcc-wrapper.sh
index a76684806b887..23117694767d1 100644
--- a/pkgs/build-support/gcc-upc-wrapper/gcc-wrapper.sh
+++ b/pkgs/build-support/gcc-upc-wrapper/gcc-wrapper.sh
@@ -95,11 +95,6 @@ if test "$dontLink" != "1"; then
 	fi
     done
     export NIX_LDFLAGS_SET=1
-
-    if test "$NIX_STRIP_DEBUG" = "1"; then
-        # Add executable-stripping flags.
-        extraAfter=(${extraAfter[@]} $NIX_CFLAGS_STRIP)
-    fi
 fi
 
 # As a very special hack, if the arguments are just `-v', then don't
diff --git a/pkgs/build-support/gcc-wrapper/builder.sh b/pkgs/build-support/gcc-wrapper/builder.sh
index 2e87d82f52cd1..ad2b8003f090d 100644
--- a/pkgs/build-support/gcc-wrapper/builder.sh
+++ b/pkgs/build-support/gcc-wrapper/builder.sh
@@ -1,8 +1,8 @@
 source $stdenv/setup
 
 
-ensureDir $out/bin
-ensureDir $out/nix-support
+mkdir -p $out/bin
+mkdir -p $out/nix-support
 
 
 if test -z "$nativeLibc"; then
diff --git a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh
index f1b394a1f540d..2ad7783a442c4 100644
--- a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh
+++ b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh
@@ -103,11 +103,6 @@ if test "$dontLink" != "1"; then
 	fi
     done
     export NIX_LDFLAGS_SET=1
-
-    if test "$NIX_STRIP_DEBUG" = "1"; then
-        # Add executable-stripping flags.
-        extraAfter=(${extraAfter[@]} $NIX_CFLAGS_STRIP)
-    fi
 fi
 
 # As a very special hack, if the arguments are just `-v', then don't
diff --git a/pkgs/build-support/kernel/make-initrd.sh b/pkgs/build-support/kernel/make-initrd.sh
index 69931bad113cf..8d334447b6dd8 100644
--- a/pkgs/build-support/kernel/make-initrd.sh
+++ b/pkgs/build-support/kernel/make-initrd.sh
@@ -35,7 +35,7 @@ storePaths=$(perl $pathsFromGraph closure-*)
 
 
 # Put the closure in a gzipped cpio archive.
-ensureDir $out
+mkdir -p $out
 (cd root && find * -print0 | cpio -ov -H newc --null | gzip -9 > $out/initrd)
 
 if [ -n "$makeUInitrd" ]; then
diff --git a/pkgs/build-support/kernel/modules-closure.sh b/pkgs/build-support/kernel/modules-closure.sh
index 7faaa0122cd28..aa2615eb578dc 100644
--- a/pkgs/build-support/kernel/modules-closure.sh
+++ b/pkgs/build-support/kernel/modules-closure.sh
@@ -25,10 +25,11 @@ for module in $rootModules; do
 done
 
 echo "closure:"
-ensureDir $out/lib/modules/"$version"
+mkdir -p $out/lib/modules/"$version"
 for module in $closure; do
     target=$(echo $module | sed "s^$NIX_STORE.*/lib/modules/^$out/lib/modules/^")
     if test -e "$target"; then continue; fi
+    if test \! -e "$module"; then continue; fi # XXX: to avoid error with "cp builtin builtin"
     mkdir -p $(dirname $target)
     echo $module
     cp $module $target
diff --git a/pkgs/build-support/make-desktopitem/default.nix b/pkgs/build-support/make-desktopitem/default.nix
index 7f3b97a33b79a..c7f2aea233937 100644
--- a/pkgs/build-support/make-desktopitem/default.nix
+++ b/pkgs/build-support/make-desktopitem/default.nix
@@ -15,7 +15,7 @@
 stdenv.mkDerivation {
   inherit name;
   buildCommand = ''
-    ensureDir $out/share/applications
+    mkdir -p $out/share/applications
     cat > $out/share/applications/$name.desktop <<EOF
     [Desktop Entry]
     Type=${type}
diff --git a/pkgs/build-support/make-wrapper/make-wrapper.sh b/pkgs/build-support/make-wrapper/make-wrapper.sh
index 08146f3789787..41f2a59246d1a 100644
--- a/pkgs/build-support/make-wrapper/make-wrapper.sh
+++ b/pkgs/build-support/make-wrapper/make-wrapper.sh
@@ -4,7 +4,7 @@ makeWrapper() {
     local params varName value command separator n fileNames
     local flagsBefore flags
 
-    ensureDir "$(dirname $wrapper)"
+    mkdir -p "$(dirname $wrapper)"
 
     echo "#! $SHELL -e" > $wrapper
 
diff --git a/pkgs/build-support/native-darwin-cctools-wrapper/builder.sh b/pkgs/build-support/native-darwin-cctools-wrapper/builder.sh
index c79b3709ee8b4..2e2e125c6495e 100644
--- a/pkgs/build-support/native-darwin-cctools-wrapper/builder.sh
+++ b/pkgs/build-support/native-darwin-cctools-wrapper/builder.sh
@@ -1,6 +1,6 @@
 source $stdenv/setup
 
-ensureDir $out/bin
+mkdir -p $out/bin
 for i in ar as c++filt gprof ld nm nmedit ranlib size strings strip dsymutil libtool; do 
     ln -s /usr/bin/$i $out/bin/
 done
diff --git a/pkgs/build-support/nuke-references/builder.sh b/pkgs/build-support/nuke-references/builder.sh
index 3b9324073ef88..9e8c464d8288c 100644
--- a/pkgs/build-support/nuke-references/builder.sh
+++ b/pkgs/build-support/nuke-references/builder.sh
@@ -1,6 +1,6 @@
 source $stdenv/setup
 
-ensureDir $out/bin
+mkdir -p $out/bin
 cat > $out/bin/nuke-refs <<EOF
 #! $SHELL -e
 for i in \$*; do
diff --git a/pkgs/build-support/release/ant-build.nix b/pkgs/build-support/release/ant-build.nix
index 2aa08ee27dec0..fe15f93a8fe29 100644
--- a/pkgs/build-support/release/ant-build.nix
+++ b/pkgs/build-support/release/ant-build.nix
@@ -39,7 +39,7 @@ stdenv.mkDerivation (
     '';
 
     installPhase = ''
-      ensureDir $out/lib/java
+      mkdir -p $out/lib/java
       ${ if jars == [] then '' 
            find . -name "*.jar" | xargs -I{} cp -v {} $out/lib/java
          '' else stdenv.lib.concatMapStrings (j: ''
@@ -58,7 +58,7 @@ stdenv.mkDerivation (
       header "Generating jar wrappers"
     '' + (stdenv.lib.concatMapStrings (w: ''
 
-      ensureDir $out/bin
+      mkdir -p $out/bin
       cat >> $out/bin/${w.name} <<EOF
       #! /bin/sh
       export JAVA_HOME=$jre
@@ -98,7 +98,7 @@ stdenv.mkDerivation (
     buildInputs = [ant jre] ++ stdenv.lib.optional (args ? buildInputs) args.buildInputs ;
 
     postHook = ''
-      ensureDir $out/nix-support
+      mkdir -p $out/nix-support
       echo "$system" > $out/nix-support/system
 
       # If `src' is the result of a call to `makeSourceTarball', then it
diff --git a/pkgs/build-support/release/binary-tarball.nix b/pkgs/build-support/release/binary-tarball.nix
index f8bb5282ee2f1..6901c9f5555f4 100644
--- a/pkgs/build-support/release/binary-tarball.nix
+++ b/pkgs/build-support/release/binary-tarball.nix
@@ -33,7 +33,7 @@ stdenv.mkDerivation (
     name = name + (if src ? version then "-" + src.version else "");
   
     postHook = ''
-      ensureDir $out/nix-support
+      mkdir -p $out/nix-support
       echo "$system" > $out/nix-support/system
 
       # If `src' is the result of a call to `makeSourceTarball', then it
@@ -62,7 +62,7 @@ stdenv.mkDerivation (
 
     distPhase =
       ''
-        ensureDir $out/tarballs
+        mkdir -p $out/tarballs
         tar cvfj $out/tarballs/''${releaseName:-binary-dist}.tar.bz2 -C $TMPDIR/inst .
       '';
 
diff --git a/pkgs/build-support/release/debian-build.nix b/pkgs/build-support/release/debian-build.nix
index 070a54fc945cc..8d2ea849a09f8 100644
--- a/pkgs/build-support/release/debian-build.nix
+++ b/pkgs/build-support/release/debian-build.nix
@@ -30,7 +30,7 @@ vmTools.runInLinuxImage (stdenv.mkDerivation (
 
     # !!! cut&paste from rpm-build.nix
     postHook = ''
-      ensureDir $out/nix-support
+      mkdir -p $out/nix-support
       cat "$diskImage"/nix-support/full-name > $out/nix-support/full-name
 
       # If `src' is the result of a call to `makeSourceTarball', then it
@@ -67,7 +67,7 @@ vmTools.runInLinuxImage (stdenv.mkDerivation (
         --provides="${concatStringsSep "," debProvides}" \
         make install
 
-      ensureDir $out/debs
+      mkdir -p $out/debs
       find . -name "*.deb" -exec cp {} $out/debs \;
 
       [ "$(echo $out/debs/*.deb)" != "" ]
diff --git a/pkgs/build-support/release/maven-build.nix b/pkgs/build-support/release/maven-build.nix
index 66dd10005f20e..39f069cd57f05 100644
--- a/pkgs/build-support/release/maven-build.nix
+++ b/pkgs/build-support/release/maven-build.nix
@@ -22,7 +22,7 @@ stdenv.mkDerivation ( rec {
   setupPhase = ''
     runHook preSetupPhase
 
-    ensureDir $out/nix-support
+    mkdir -p $out/nix-support
     export LANG="en_US.UTF-8"
     export LOCALE_ARCHIVE=$glibcLocales/lib/locale/locale-archive
     export M2_REPO=$TMPDIR/repository
@@ -74,7 +74,7 @@ stdenv.mkDerivation ( rec {
   '';
 
   mvnRelease = ''
-    ensureDir $out/release
+    mkdir -p $out/release
 
     zip=$(ls target/*.zip| head -1)
     releaseName=$(basename $zip .zip)
diff --git a/pkgs/build-support/release/nix-build.nix b/pkgs/build-support/release/nix-build.nix
index f734e1eefe5a7..7e2a0d4f03b9b 100644
--- a/pkgs/build-support/release/nix-build.nix
+++ b/pkgs/build-support/release/nix-build.nix
@@ -44,7 +44,7 @@ stdenv.mkDerivation (
           if test -n "$keepBuildDirectory"; then
               KEEPBUILDDIR="$out/`basename $TMPDIR`"
               header "Copying build directory to $KEEPBUILDDIR"
-              ensureDir $KEEPBUILDDIR
+              mkdir -p $KEEPBUILDDIR
               cp -R $TMPDIR/* $KEEPBUILDDIR
               stopNest 
           fi
@@ -58,7 +58,7 @@ stdenv.mkDerivation (
     name = name + (if src ? version then "-" + src.version else "");
   
     postHook = ''
-      ensureDir $out/nix-support
+      mkdir -p $out/nix-support
       echo "$system" > $out/nix-support/system
 
       if test -z "${toString doCoverageAnalysis}"; then
diff --git a/pkgs/build-support/release/rpm-build.nix b/pkgs/build-support/release/rpm-build.nix
index 326ccbe9c4284..26b120e5b1d06 100644
--- a/pkgs/build-support/release/rpm-build.nix
+++ b/pkgs/build-support/release/rpm-build.nix
@@ -14,7 +14,7 @@ vmTools.buildRPM (
     name = name + "-" + diskImage.name + (if src ? version then "-" + src.version else "");
 
     preBuild = ''
-      ensureDir $out/nix-support
+      mkdir -p $out/nix-support
       cat "$diskImage"/nix-support/full-name > $out/nix-support/full-name
 
       # If `src' is the result of a call to `makeSourceTarball', then it
diff --git a/pkgs/build-support/release/source-tarball.nix b/pkgs/build-support/release/source-tarball.nix
index 0475cdf76b773..45a871567482b 100644
--- a/pkgs/build-support/release/source-tarball.nix
+++ b/pkgs/build-support/release/source-tarball.nix
@@ -73,7 +73,7 @@ stdenv.mkDerivation (
           if test -n "$keepBuildDirectory"; then
               KEEPBUILDDIR="$out/`basename $TMPDIR`"
               header "Copying build directory to $KEEPBUILDDIR"
-              ensureDir $KEEPBUILDDIR
+              mkdir -p $KEEPBUILDDIR
               cp -R $TMPDIR/* $KEEPBUILDDIR
               stopNest
           fi
@@ -91,7 +91,7 @@ stdenv.mkDerivation (
     buildInputs = buildInputs ++ bootstrapBuildInputs;
     
     postHook = ''
-      ensureDir $out/nix-support
+      mkdir -p $out/nix-support
     '';  
 
     postUnpack = ''
diff --git a/pkgs/build-support/substitute/substitute-all.sh b/pkgs/build-support/substitute/substitute-all.sh
index 796a1a471529f..ec220481fcc09 100644
--- a/pkgs/build-support/substitute/substitute-all.sh
+++ b/pkgs/build-support/substitute/substitute-all.sh
@@ -7,7 +7,7 @@ args=
 target=$out
 if test -n "$dir"; then
     target=$out/$dir/$name
-    ensureDir $out/$dir
+    mkdir -p $out/$dir
 fi
 
 substituteAll $src $target
diff --git a/pkgs/build-support/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix
index 5defdb55b9595..1815c99a9f4b7 100644
--- a/pkgs/build-support/trivial-builders.nix
+++ b/pkgs/build-support/trivial-builders.nix
@@ -48,7 +48,7 @@ rec {
   makeSetupHook = { deps ? [], substitutions ? {} }: script:
     runCommand "hook" substitutions
       (''
-        ensureDir $out/nix-support
+        mkdir -p $out/nix-support
         cp ${script} $out/nix-support/setup-hook
       '' + stdenv.lib.optionalString (deps != []) ''
         echo ${toString deps} > $out/nix-support/propagated-build-native-inputs
diff --git a/pkgs/build-support/upstream-updater/attrset-to-dir.nix b/pkgs/build-support/upstream-updater/attrset-to-dir.nix
index a05f80da085a8..bdf44b7a5bf30 100644
--- a/pkgs/build-support/upstream-updater/attrset-to-dir.nix
+++ b/pkgs/build-support/upstream-updater/attrset-to-dir.nix
@@ -1,7 +1,7 @@
 a :  
 a.stdenv.mkDerivation rec {
   buildCommand = ''
-    ensureDir "$out/attributes"
+    mkdir -p "$out/attributes"
     
   '' + (a.lib.concatStrings (map
     (n: ''
diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix
index 737e57217ba3e..eaea4d190f19a 100644
--- a/pkgs/build-support/vm/default.nix
+++ b/pkgs/build-support/vm/default.nix
@@ -29,8 +29,8 @@ rec {
       allowedReferences = [ "out" modulesClosure ]; # prevent accidents like glibc being included in the initrd
     }
     ''
-      ensureDir $out/bin
-      ensureDir $out/lib
+      mkdir -p $out/bin
+      mkdir -p $out/lib
       
       # Copy what we need from Glibc.
       cp -p ${glibc}/lib/ld-linux*.so.? $out/lib
@@ -352,7 +352,7 @@ rec {
     with pkgs; runInLinuxVM (
     stdenv.mkDerivation {
       name = "extract-file";
-      buildInputs = [utillinuxng];
+      buildInputs = [ utillinux ];
       buildCommand = ''
         ln -s ${linux}/lib /lib
         ${module_init_tools}/sbin/modprobe loop
@@ -365,8 +365,8 @@ rec {
         ${module_init_tools}/sbin/modprobe cramfs
         mknod /dev/loop0 b 7 0
 
-        ensureDir $out
-        ensureDir tmp
+        mkdir -p $out
+        mkdir -p tmp
         mount -o loop,ro,ufstype=44bsd ${lib.optionalString (fs != null) "-t ${fs} "}${file} tmp ||
           mount -o loop,ro ${lib.optionalString (fs != null) "-t ${fs} "}${file} tmp
         cp -Rv tmp/* $out/ || exit 0
@@ -377,7 +377,7 @@ rec {
     with pkgs; runInLinuxVM (
     stdenv.mkDerivation {
       name = "extract-file-mtd";
-      buildInputs = [utillinuxng mtdutils];
+      buildInputs = [ utillinux mtdutils ];
       buildCommand = ''
         ln -s ${linux}/lib /lib
         ${module_init_tools}/sbin/modprobe mtd
@@ -389,8 +389,8 @@ rec {
         mknod /dev/mtd0 c 90 0
         mknod /dev/mtdblock0 b 31 0
 
-        ensureDir $out
-        ensureDir tmp
+        mkdir -p $out
+        mkdir -p tmp
 
         dd if=${file} of=/dev/mtd0
         mount ${lib.optionalString (fs != null) "-t ${fs} "}/dev/mtdblock0 tmp
@@ -611,7 +611,7 @@ rec {
     installPhase = ''
       eval "$preInstall"
 
-      ensureDir $out/$outDir
+      mkdir -p $out/$outDir
       find $rpmout -name "*.rpm" -exec cp {} $out/$outDir \;
 
       for i in $out/$outDir/*.rpm; do
diff --git a/pkgs/build-support/vsenv/build-solution.nix b/pkgs/build-support/vsenv/build-solution.nix
index 7d7d6a86e1f35..32dd06abfaf39 100644
--- a/pkgs/build-support/vsenv/build-solution.nix
+++ b/pkgs/build-support/vsenv/build-solution.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
   installPhase = ''
     cd ${baseDir}
     vcbuild.exe /rebuild ${slnFile}
-    ensureDir $out
+    mkdir -p $out
     cp Debug/* $out
   '';
   buildInputs = [ vs ] ++ extraBuildInputs;
diff --git a/pkgs/data/documentation/pthread-man-pages/default.nix b/pkgs/data/documentation/pthread-man-pages/default.nix
index a19c8bf8e9a38..296ba982b8a46 100644
--- a/pkgs/data/documentation/pthread-man-pages/default.nix
+++ b/pkgs/data/documentation/pthread-man-pages/default.nix
@@ -27,7 +27,7 @@ in
     '';
 
     patchPhase = ''
-      ensureDir "$out/share/man/man3"
+      mkdir -p "$out/share/man/man3"
 
       sed -i "linuxthreads/man/Makefile" \
           -e "s|MANDIR *=.*$|MANDIR = $out/share/man/man3| ;
diff --git a/pkgs/data/documentation/rnrs/builder.sh b/pkgs/data/documentation/rnrs/builder.sh
index 096dd2a8ca75f..6ec5c855ababe 100644
--- a/pkgs/data/documentation/rnrs/builder.sh
+++ b/pkgs/data/documentation/rnrs/builder.sh
@@ -4,9 +4,9 @@ source "$stdenv/setup" || exit 1
 
 echo "source is \`$src', report name is \`$reportName'"
 
-ensureDir "$out/share/info" &&					\
+mkdir -p "$out/share/info" &&					\
 makeinfo -o "$out/share/info/${reportName}.info" "$src"
 
 # XXX: HTML output is apparently broken.
-#ensureDir "$out/share/doc/${reportName}" &&			\
+#mkdir -p "$out/share/doc/${reportName}" &&			\
 #makeinfo -o "$out/share/doc/${reportName}/html" --html --force "$src"
diff --git a/pkgs/data/documentation/std-man-pages/default.nix b/pkgs/data/documentation/std-man-pages/default.nix
index 221f76c36fa76..3b45da914d25a 100644
--- a/pkgs/data/documentation/std-man-pages/default.nix
+++ b/pkgs/data/documentation/std-man-pages/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
   };
 
   installPhase = ''
-    ensureDir $out/share/man
+    mkdir -p $out/share/man
     cp -R * $out/share/man
   '';
 
diff --git a/pkgs/data/fonts/andagii/default.nix b/pkgs/data/fonts/andagii/default.nix
index 8c2803c26d70b..742f0bd0b4aaf 100644
--- a/pkgs/data/fonts/andagii/default.nix
+++ b/pkgs/data/fonts/andagii/default.nix
@@ -32,7 +32,7 @@ rec {
   '' ["addInputs"];
 
   doInstall = a.fullDepEntry (''
-    ensureDir "$out"/share/fonts/ttf/
+    mkdir -p "$out"/share/fonts/ttf/
     cp ANDAGII_.TTF "$out"/share/fonts/ttf/andagii.ttf
   '') ["defEnsureDir" "minInit"];
       
diff --git a/pkgs/data/fonts/bakoma-ttf/default.nix b/pkgs/data/fonts/bakoma-ttf/default.nix
index c7f1ad38f47c7..5f9cbec7a97ae 100644
--- a/pkgs/data/fonts/bakoma-ttf/default.nix
+++ b/pkgs/data/fonts/bakoma-ttf/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation {
   };
   
   buildPhase = "true";
-  installPhase = "ensureDir $out/share/fonts/truetype; cp ttf/*.ttf $out/share/fonts/truetype";
+  installPhase = "mkdir -p $out/share/fonts/truetype; cp ttf/*.ttf $out/share/fonts/truetype";
 
   meta = {
     description = "TrueType versions of the Computer Modern and AMS TeX Fonts";
diff --git a/pkgs/data/fonts/cantarell-fonts/default.nix b/pkgs/data/fonts/cantarell-fonts/default.nix
index c7697c4f07284..70a8b2bc9f470 100644
--- a/pkgs/data/fonts/cantarell-fonts/default.nix
+++ b/pkgs/data/fonts/cantarell-fonts/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, xz }:
+{ stdenv, fetchurl }:
 
 stdenv.mkDerivation {
   name = "cantarell-fonts-0.0.7";
@@ -8,8 +8,6 @@ stdenv.mkDerivation {
     sha256 = "1410ywvi951ngmx58g339phzsaf1rgjja6i0xvg49r4ds90zh8ba";
   };
 
-  buildNativeInputs = [ xz ];
-
   meta = {
     maintainers = [ stdenv.lib.maintainers.urkud ];
     platforms = stdenv.lib.platforms.all;
diff --git a/pkgs/data/fonts/clearlyU/default.nix b/pkgs/data/fonts/clearlyU/default.nix
index 32050ac5c28f9..2761ed6f3e691 100644
--- a/pkgs/data/fonts/clearlyU/default.nix
+++ b/pkgs/data/fonts/clearlyU/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation {
 
   installPhase =
     ''
-      ensureDir $out/share/fonts
+      mkdir -p $out/share/fonts
       cp *.bdf $out/share/fonts
       cd $out/share/fonts
       mkfontdir 
diff --git a/pkgs/data/fonts/corefonts/default.nix b/pkgs/data/fonts/corefonts/default.nix
index 75896e059bf49..b26d3bd8c1d6f 100644
--- a/pkgs/data/fonts/corefonts/default.nix
+++ b/pkgs/data/fonts/corefonts/default.nix
@@ -42,7 +42,7 @@ stdenv.mkDerivation {
     cabextract --lowercase viewer1.cab
   
     fontDir=$out/share/fonts/truetype
-    ensureDir $fontDir
+    mkdir -p $fontDir
     cp *.ttf $fontDir
 
     # Also put the EULA there to be on the safe side.
diff --git a/pkgs/data/fonts/dejavu-fonts/default.nix b/pkgs/data/fonts/dejavu-fonts/default.nix
index fb952f39604e3..505746b3edfce 100644
--- a/pkgs/data/fonts/dejavu-fonts/default.nix
+++ b/pkgs/data/fonts/dejavu-fonts/default.nix
@@ -19,11 +19,11 @@ stdenv.mkDerivation {
     ln -s ${perl}/lib/*/*/unicore/* -t resources/
   '';
   installPhase = '' 
-    ensureDir $out/share/fonts/truetype
+    mkdir -p $out/share/fonts/truetype
     for i in $(find build -name '*.ttf'); do 
         cp $i $out/share/fonts/truetype; 
     done;
-    ensureDir $out/share/dejavu-fonts
+    mkdir -p $out/share/dejavu-fonts
     cp -r build/* $out/share/dejavu-fonts
   '';
 }
diff --git a/pkgs/data/fonts/fontWrap/default.nix b/pkgs/data/fonts/fontWrap/default.nix
index 927cc48575d08..0d6750614d478 100644
--- a/pkgs/data/fonts/fontWrap/default.nix
+++ b/pkgs/data/fonts/fontWrap/default.nix
@@ -7,7 +7,7 @@ args : with args;
 	in with localDefs;
 let
 	doInstall = fullDepEntry ("
-		ensureDir \$out/share/fonts/
+		mkdir -p \$out/share/fonts/
 		cd \$out/share/fonts
 		for i in ${toString paths}; do
 			find \$i -type f -exec ln -s '{}' . ';' ;
diff --git a/pkgs/data/fonts/freefont-ttf/default.nix b/pkgs/data/fonts/freefont-ttf/default.nix
index e1427a79f0d52..0ff2ec7ba1660 100644
--- a/pkgs/data/fonts/freefont-ttf/default.nix
+++ b/pkgs/data/fonts/freefont-ttf/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
   };
 
   installPhase = ''
-    ensureDir $out/share/fonts/truetype
+    mkdir -p $out/share/fonts/truetype
     cp *.ttf $out/share/fonts/truetype
   '';
 
diff --git a/pkgs/data/fonts/junicode/default.nix b/pkgs/data/fonts/junicode/default.nix
index eb7547e628f7d..1690f82aa37d0 100644
--- a/pkgs/data/fonts/junicode/default.nix
+++ b/pkgs/data/fonts/junicode/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
 
   installPhase =
     ''
-      ensureDir $out/share/fonts/junicode-ttf
+      mkdir -p $out/share/fonts/junicode-ttf
       cp *.ttf $out/share/fonts/junicode-ttf
     '';
 
diff --git a/pkgs/data/fonts/lmodern/default.nix b/pkgs/data/fonts/lmodern/default.nix
index a5dc014d8b4a5..831a3ddbd09cc 100644
--- a/pkgs/data/fonts/lmodern/default.nix
+++ b/pkgs/data/fonts/lmodern/default.nix
@@ -9,8 +9,8 @@ stdenv.mkDerivation {
   };
 
   installPhase = ''
-    ensureDir $out/texmf/
-    ensureDir $out/share/fonts/
+    mkdir -p $out/texmf/
+    mkdir -p $out/share/fonts/
 
     cp -r ./* $out/texmf/
     cp -r fonts/{opentype,type1} $out/share/fonts/
diff --git a/pkgs/data/fonts/mph-2b-damase/default.nix b/pkgs/data/fonts/mph-2b-damase/default.nix
index ceca85a0d2313..7fe56987ad365 100644
--- a/pkgs/data/fonts/mph-2b-damase/default.nix
+++ b/pkgs/data/fonts/mph-2b-damase/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
     unzip $src;
   '';
   installPhase = ''
-    ensureDir $out/share/fonts/truetype
+    mkdir -p $out/share/fonts/truetype
     cp *.ttf $out/share/fonts/truetype
   '';
 }
diff --git a/pkgs/data/fonts/redhat-liberation-fonts/default.nix b/pkgs/data/fonts/redhat-liberation-fonts/default.nix
index cb1225763fd0c..c331b85029d93 100644
--- a/pkgs/data/fonts/redhat-liberation-fonts/default.nix
+++ b/pkgs/data/fonts/redhat-liberation-fonts/default.nix
@@ -8,10 +8,10 @@ stdenv.mkDerivation rec {
   };
   
   installPhase = ''
-    ensureDir $out/share/fonts/truetype
+    mkdir -p $out/share/fonts/truetype
     cp -v *.ttf $out/share/fonts/truetype
 
-    ensureDir "$out/doc/${name}"
+    mkdir -p "$out/doc/${name}"
     cp -v AUTHORS ChangeLog COPYING License.txt README "$out/doc/${name}"
   '';
 
diff --git a/pkgs/data/fonts/ttf-bitstream-vera/default.nix b/pkgs/data/fonts/ttf-bitstream-vera/default.nix
index 57f463ba64c7a..64b18ffdaaab6 100644
--- a/pkgs/data/fonts/ttf-bitstream-vera/default.nix
+++ b/pkgs/data/fonts/ttf-bitstream-vera/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation {
   buildPhase = "true";
   installPhase = "
     fontDir=$out/share/fonts/truetype
-    ensureDir $fontDir
+    mkdir -p $fontDir
     cp *.ttf $fontDir
   ";
 }
diff --git a/pkgs/data/fonts/unifont/default.nix b/pkgs/data/fonts/unifont/default.nix
index 76d2f3b28c1a1..79d1a0909058c 100644
--- a/pkgs/data/fonts/unifont/default.nix
+++ b/pkgs/data/fonts/unifont/default.nix
@@ -23,7 +23,7 @@ stdenv.mkDerivation {
   
   installPhase =
     ''
-      ensureDir $out/share/fonts $out/share/fonts/truetype
+      mkdir -p $out/share/fonts $out/share/fonts/truetype
       cp ${pcf} $out/share/fonts/unifont.pcf.gz
       gunzip < ${ttf} > $out/share/fonts/truetype/unifont.ttf
       cd $out/share/fonts
diff --git a/pkgs/data/fonts/vista-fonts/default.nix b/pkgs/data/fonts/vista-fonts/default.nix
index 73dcf368d72a7..19996f3f1a310 100644
--- a/pkgs/data/fonts/vista-fonts/default.nix
+++ b/pkgs/data/fonts/vista-fonts/default.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation {
   buildPhase = "true";
   
   installPhase = "
-    ensureDir $out/share/fonts/truetype; cp *.ttf $out/share/fonts/truetype
+    mkdir -p $out/share/fonts/truetype; cp *.ttf $out/share/fonts/truetype
   ";
 
   meta = {
diff --git a/pkgs/data/fonts/wqy-zenhei/default.nix b/pkgs/data/fonts/wqy-zenhei/default.nix
index ba38d8dc1abbb..698ecc5304626 100644
--- a/pkgs/data/fonts/wqy-zenhei/default.nix
+++ b/pkgs/data/fonts/wqy-zenhei/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
 
   installPhase =
     ''
-      ensureDir $out/share/fonts
+      mkdir -p $out/share/fonts
       cp *.ttf $out/share/fonts
     '';
 
diff --git a/pkgs/data/misc/cacert/default.nix b/pkgs/data/misc/cacert/default.nix
index 6156cf17f1698..4db1e84b48530 100644
--- a/pkgs/data/misc/cacert/default.nix
+++ b/pkgs/data/misc/cacert/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
 
   installPhase =
     ''
-      ensureDir $out/etc
+      mkdir -p $out/etc
       bunzip2 < $src > $out/etc/ca-bundle.crt
     '';
 
diff --git a/pkgs/data/sgml+xml/schemas/docbook-5.0/builder.sh b/pkgs/data/sgml+xml/schemas/docbook-5.0/builder.sh
index e0cdb22e23c39..96ad77eaa57c7 100644
--- a/pkgs/data/sgml+xml/schemas/docbook-5.0/builder.sh
+++ b/pkgs/data/sgml+xml/schemas/docbook-5.0/builder.sh
@@ -4,14 +4,14 @@ unpackFile $src
 
 cd docbook-*
 
-ensureDir $out/xml/rng
+mkdir -p $out/xml/rng
 cp -prv rng $out/xml/rng/docbook
 
-ensureDir $out/xml/dtd
+mkdir -p $out/xml/dtd
 cp -prv dtd $out/xml/dtd/docbook
 
-ensureDir $out/share/doc
+mkdir -p $out/share/doc
 cp -prv docs $out/share/doc/docbook
 
-ensureDir $out/share/docbook
+mkdir -p $out/share/docbook
 cp -prv tools $out/share/docbook/
diff --git a/pkgs/data/sgml+xml/schemas/xml-dtd/xhtml1/default.nix b/pkgs/data/sgml+xml/schemas/xml-dtd/xhtml1/default.nix
index cdcf62467dba9..8e626e3bc5243 100644
--- a/pkgs/data/sgml+xml/schemas/xml-dtd/xhtml1/default.nix
+++ b/pkgs/data/sgml+xml/schemas/xml-dtd/xhtml1/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation {
 
   installPhase =
     ''
-      ensureDir $out/xml/dtd/xhtml1
+      mkdir -p $out/xml/dtd/xhtml1
       cp DTD/*.ent DTD/*.dtd $out/xml/dtd/xhtml1
 
       # Generate an XML catalog.
diff --git a/pkgs/data/sgml+xml/stylesheets/xslt/docbook-xsl-ns/default.nix b/pkgs/data/sgml+xml/stylesheets/xslt/docbook-xsl-ns/default.nix
index 978bbcbd5a7fa..c143ce1669833 100644
--- a/pkgs/data/sgml+xml/stylesheets/xslt/docbook-xsl-ns/default.nix
+++ b/pkgs/data/sgml+xml/stylesheets/xslt/docbook-xsl-ns/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
 
   installPhase =
     ''
-      ensureDir $out/xml/xsl
+      mkdir -p $out/xml/xsl
       cd ..
       mv docbook-xsl-ns-* $out/xml/xsl/docbook
     '';
diff --git a/pkgs/data/sgml+xml/stylesheets/xslt/docbook-xsl/builder.sh b/pkgs/data/sgml+xml/stylesheets/xslt/docbook-xsl/builder.sh
index 1534806895cd6..9ac8e74d93a36 100644
--- a/pkgs/data/sgml+xml/stylesheets/xslt/docbook-xsl/builder.sh
+++ b/pkgs/data/sgml+xml/stylesheets/xslt/docbook-xsl/builder.sh
@@ -1,6 +1,6 @@
 source $stdenv/setup
 
-ensureDir $out
+mkdir -p $out
 cd $out
 unpackFile $src
 mkdir xml
diff --git a/pkgs/desktops/gnome-2/platform/audiofile/default.nix b/pkgs/desktops/gnome-2/platform/audiofile/default.nix
index c39178cdf1788..74007218347d3 100644
--- a/pkgs/desktops/gnome-2/platform/audiofile/default.nix
+++ b/pkgs/desktops/gnome-2/platform/audiofile/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, xz, alsaLib}:
+{stdenv, fetchurl, alsaLib}:
 
 stdenv.mkDerivation {
   name = "audiofile-0.3.2";
@@ -8,7 +8,5 @@ stdenv.mkDerivation {
     sha256 = "185j69j6b0vp6h6bb4j4ipvcyysxf63ghxnvdhh8kbc7ixm71hgs";
   };
 
-  buildNativeInputs = [ xz ];
-
   buildInputs = [ alsaLib ];
 }
diff --git a/pkgs/desktops/gnome-2/platform/gtk-doc/default.nix b/pkgs/desktops/gnome-2/platform/gtk-doc/default.nix
index 90a9088d45626..c5086accc0db8 100644
--- a/pkgs/desktops/gnome-2/platform/gtk-doc/default.nix
+++ b/pkgs/desktops/gnome-2/platform/gtk-doc/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation {
   # maybe there is a better way to pass the needed dtd and xsl files
   # "-//OASIS//DTD DocBook XML V4.1.2//EN" and "http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl"
   preConfigure = ''
-    ensureDir $out/nix-support
+    mkdir -p $out/nix-support
     cat > $out/nix-support/catalog.xml << EOF
     <?xml version="1.0"?>
     <!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
diff --git a/pkgs/desktops/gnome-2/platform/libgnome-keyring/default.nix b/pkgs/desktops/gnome-2/platform/libgnome-keyring/default.nix
index f937ce26018cf..05a21f3c82e20 100644
--- a/pkgs/desktops/gnome-2/platform/libgnome-keyring/default.nix
+++ b/pkgs/desktops/gnome-2/platform/libgnome-keyring/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, glib, dbus_libs, libgcrypt, pkgconfig, xz,
+{ stdenv, fetchurl, glib, dbus_libs, libgcrypt, pkgconfig,
 intltool }:
 
 stdenv.mkDerivation {
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
   };
 
   propagatedBuildInputs = [ glib dbus_libs libgcrypt ];
-  buildNativeInputs = [ pkgconfig xz intltool ];
+  buildNativeInputs = [ pkgconfig intltool ];
 
   meta = {
     inherit (glib.meta) platforms maintainers;
diff --git a/pkgs/desktops/gnome-3/platform/GConf.nix b/pkgs/desktops/gnome-3/platform/GConf.nix
index 637d619d022bc..52f3cba7bdb70 100644
--- a/pkgs/desktops/gnome-3/platform/GConf.nix
+++ b/pkgs/desktops/gnome-3/platform/GConf.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl_gnome, glib, dbus_glib, pkgconfig, xz, libxml2, gtk, intltool }:
+{ stdenv, fetchurl_gnome, glib, dbus_glib, pkgconfig, libxml2, gtk, intltool }:
 
 stdenv.mkDerivation rec {
   name = src.pkgname;
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
   };
 
   propagatedBuildInputs = [ glib dbus_glib libxml2 gtk ];
-  buildNativeInputs = [ pkgconfig xz intltool ];
+  buildNativeInputs = [ pkgconfig intltool ];
 
   configureFlags = "--disable-orbit";
 
diff --git a/pkgs/desktops/gnome-3/platform/clutter.nix b/pkgs/desktops/gnome-3/platform/clutter.nix
index 4e7bc54c1295f..b2ee5539008a3 100644
--- a/pkgs/desktops/gnome-3/platform/clutter.nix
+++ b/pkgs/desktops/gnome-3/platform/clutter.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, glib, xz, pkgconfig, mesa, libX11, libXext, libXfixes
+{ stdenv, fetchurl, glib, pkgconfig, mesa, libX11, libXext, libXfixes
 , libXdamage, libXcomposite, libXi, cogl, pango, atk, json_glib }:
 
 stdenv.mkDerivation {
@@ -9,7 +9,7 @@ stdenv.mkDerivation {
     sha256 = "0bzsvnharawfg525lpavrp55mq4aih5nb01dwwqwnccg8hk9z2fw";
   };
 
-  buildNativeInputs = [ xz pkgconfig ];
+  buildNativeInputs = [ pkgconfig ];
   buildInputs =
     [ libX11 mesa libXext libXfixes libXdamage libXcomposite libXi cogl pango
       atk json_glib
diff --git a/pkgs/desktops/gnome-3/platform/glib-networking.nix b/pkgs/desktops/gnome-3/platform/glib-networking.nix
index 7fa0295fe742a..37537b274e14b 100644
--- a/pkgs/desktops/gnome-3/platform/glib-networking.nix
+++ b/pkgs/desktops/gnome-3/platform/glib-networking.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, glib, xz, pkgconfig, intltool, gnutls, libgcrypt
+{ stdenv, fetchurl, glib, pkgconfig, intltool, gnutls, libgcrypt
 , gsettings_desktop_schemas }:
 
 stdenv.mkDerivation {
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
 
   propagatedBuildInputs = [ glib gnutls libgcrypt ];
   buildInputs = [ gsettings_desktop_schemas ];
-  buildNativeInputs = [ xz pkgconfig intltool ];
+  buildNativeInputs = [ pkgconfig intltool ];
 
   configureFlags = "--without-ca-certificates";
   postConfigure = "export makeFlags=GIO_MODULE_DIR=$out/${glib.gioModuleDir}";
diff --git a/pkgs/desktops/gnome-3/platform/gnome-user-docs.nix b/pkgs/desktops/gnome-3/platform/gnome-user-docs.nix
index f434b5c155c5e..f92882b9a832e 100644
--- a/pkgs/desktops/gnome-3/platform/gnome-user-docs.nix
+++ b/pkgs/desktops/gnome-3/platform/gnome-user-docs.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, xz, itstool, libxml2, gettext }:
+{ stdenv, fetchurl, itstool, libxml2, gettext }:
 
 stdenv.mkDerivation {
   name = "gnome-user-docs-3.2.2";
@@ -8,5 +8,5 @@ stdenv.mkDerivation {
     sha256 = "1ka0nw2kc85p10y8x31v0wv06a88k7qrgafp4ys04y9fzz0rkcjj";
   };
 
-  buildNativeInputs = [ xz itstool libxml2 gettext ];
+  buildNativeInputs = [ itstool libxml2 gettext ];
 }
diff --git a/pkgs/desktops/gnome-3/platform/gsettings-desktop-schemas.nix b/pkgs/desktops/gnome-3/platform/gsettings-desktop-schemas.nix
index db6453a53c351..4527b2fec0b1c 100644
--- a/pkgs/desktops/gnome-3/platform/gsettings-desktop-schemas.nix
+++ b/pkgs/desktops/gnome-3/platform/gsettings-desktop-schemas.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, xz, glib, pkgconfig, intltool }:
+{ stdenv, fetchurl, glib, pkgconfig, intltool }:
 
 stdenv.mkDerivation {
   name = "gsettings-desktop-schemas-3.2.0";
@@ -9,7 +9,7 @@ stdenv.mkDerivation {
   };
 
   buildInputs = [ glib ];
-  buildNativeInputs = [ pkgconfig xz intltool ];
+  buildNativeInputs = [ pkgconfig intltool ];
 
   meta = {
     inherit (glib.meta) maintainers platforms;
diff --git a/pkgs/desktops/gnome-3/platform/libgnome-keyring.nix b/pkgs/desktops/gnome-3/platform/libgnome-keyring.nix
index b3ceb6df3d504..a8b8e98ced99b 100644
--- a/pkgs/desktops/gnome-3/platform/libgnome-keyring.nix
+++ b/pkgs/desktops/gnome-3/platform/libgnome-keyring.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, glib, dbus_libs, libgcrypt, pkgconfig, xz,
+{ stdenv, fetchurl, glib, dbus_libs, libgcrypt, pkgconfig,
 intltool }:
 
 stdenv.mkDerivation {
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
   };
 
   propagatedBuildInputs = [ glib dbus_libs libgcrypt ];
-  buildNativeInputs = [ pkgconfig xz intltool ];
+  buildNativeInputs = [ pkgconfig intltool ];
 
   meta = {
     inherit (glib.meta) platforms maintainers;
diff --git a/pkgs/desktops/gnome-3/platform/libsoup.nix b/pkgs/desktops/gnome-3/platform/libsoup.nix
index 1827d5c9cd732..fdf9e5bd9fee7 100644
--- a/pkgs/desktops/gnome-3/platform/libsoup.nix
+++ b/pkgs/desktops/gnome-3/platform/libsoup.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
   };
 
 
-  buildNativeInputs = [ pkgconfig xz ];
+  buildNativeInputs = [ pkgconfig ];
   propagatedBuildInputs = [ glib libxml2 ]
     ++ stdenv.lib.optionals gnomeSupport [ libgnome_keyring sqlite ];
   passthru.propagatedUserEnvPackages = [ glib_networking ];
diff --git a/pkgs/desktops/kde-4.7/kde-runtime.nix b/pkgs/desktops/kde-4.7/kde-runtime.nix
index d827802bb090d..9b25e77b0835a 100644
--- a/pkgs/desktops/kde-4.7/kde-runtime.nix
+++ b/pkgs/desktops/kde-4.7/kde-runtime.nix
@@ -1,10 +1,10 @@
-{ kde, kdelibs, shared_desktop_ontologies, bzip2, xz, libssh, exiv2, attica
+{ kde, kdelibs, shared_desktop_ontologies, bzip2, libssh, exiv2, attica
 , libcanberra, virtuoso, samba, ntrack, libjpeg
 }:
 
 kde {
   buildInputs =
-    [ kdelibs shared_desktop_ontologies bzip2 xz libssh exiv2 attica
+    [ kdelibs shared_desktop_ontologies bzip2 libssh exiv2 attica
       samba (libcanberra.override { gtk = null; }) ntrack libjpeg
     ];
 
diff --git a/pkgs/desktops/kde-4.7/kde-workspace.nix b/pkgs/desktops/kde-4.7/kde-workspace.nix
index fe51032f7576b..20fc5b5645549 100644
--- a/pkgs/desktops/kde-4.7/kde-workspace.nix
+++ b/pkgs/desktops/kde-4.7/kde-workspace.nix
@@ -1,7 +1,7 @@
-{ kde, kdelibs, qimageblitz, libdbusmenu_qt, xorg, shared_desktop_ontologies,
-  lm_sensors, pciutils, libraw1394, libusb, libxklavier, python, libqalculate,
-  consolekit, xkeyboard_config, kdepimlibs, pam, boost, gpsd, prison, akonadi,
-  pykde4, libjpeg, pkgconfig, libXft, libXxf86misc
+{ kde, kdelibs, qimageblitz, libdbusmenu_qt, xorg, shared_desktop_ontologies
+, lm_sensors, pciutils, libraw1394, libusb, libxklavier, python, libqalculate
+, consolekit, xkeyboard_config, kdepimlibs, pam, boost, gpsd, prison, akonadi
+, pykde4, libjpeg, pkgconfig, libXft, libXxf86misc
 }:
 
 kde {
diff --git a/pkgs/desktops/kde-4.7/kdelibs.nix b/pkgs/desktops/kde-4.7/kdelibs.nix
index 106909ac3dbb2..31df83e5ee921 100644
--- a/pkgs/desktops/kde-4.7/kdelibs.nix
+++ b/pkgs/desktops/kde-4.7/kdelibs.nix
@@ -1,17 +1,16 @@
 { kde, gcc, cmake, perl
 , qt4, bzip2, pcre, fam, libxml2, libxslt, shared_mime_info, giflib, jasper
-, xz, openexr, avahi, kerberos, acl, attr, shared_desktop_ontologies, libXScrnSaver
+, openexr, avahi, kerberos, acl, attr, shared_desktop_ontologies, libXScrnSaver
 , automoc4, strigi, soprano, qca2, attica, enchant, libdbusmenu_qt
 , docbook_xml_dtd_42, docbook_xsl, polkit_qt_1
-, getopt, udev, herqq, phonon, libjpeg
+, getopt, udev, herqq, phonon, libjpeg, xz
 }:
 
 kde {
   buildInputs =
-    [
-      acl attr attica avahi bzip2 enchant fam getopt giflib herqq jasper
+    [ acl attr attica avahi bzip2 enchant fam getopt giflib herqq jasper
       libdbusmenu_qt libXScrnSaver libxslt pcre polkit_qt_1 qca2
-      shared_desktop_ontologies udev xz libxml2 libjpeg kerberos
+      shared_desktop_ontologies xz udev libxml2 libjpeg kerberos
     ];
 
   propagatedBuildInputs = [ qt4 soprano strigi phonon ];
diff --git a/pkgs/desktops/kde-4.7/kdeutils/ark.nix b/pkgs/desktops/kde-4.7/kdeutils/ark.nix
index 4449dd8228f25..7fbdaf586d668 100644
--- a/pkgs/desktops/kde-4.7/kdeutils/ark.nix
+++ b/pkgs/desktops/kde-4.7/kdeutils/ark.nix
@@ -1,7 +1,7 @@
-{ kde, kdelibs, libarchive, xz, bzip2, kde_baseapps }:
+{ kde, kdelibs, libarchive, bzip2, kde_baseapps }:
 
 kde {
-  buildInputs = [ kdelibs kde_baseapps libarchive xz bzip2 ];
+  buildInputs = [ kdelibs kde_baseapps libarchive bzip2 ];
 
   meta = {
     description = "KDE Archiving Tool";
diff --git a/pkgs/desktops/kde-4.8/kde-runtime.nix b/pkgs/desktops/kde-4.8/kde-runtime.nix
index d827802bb090d..9b25e77b0835a 100644
--- a/pkgs/desktops/kde-4.8/kde-runtime.nix
+++ b/pkgs/desktops/kde-4.8/kde-runtime.nix
@@ -1,10 +1,10 @@
-{ kde, kdelibs, shared_desktop_ontologies, bzip2, xz, libssh, exiv2, attica
+{ kde, kdelibs, shared_desktop_ontologies, bzip2, libssh, exiv2, attica
 , libcanberra, virtuoso, samba, ntrack, libjpeg
 }:
 
 kde {
   buildInputs =
-    [ kdelibs shared_desktop_ontologies bzip2 xz libssh exiv2 attica
+    [ kdelibs shared_desktop_ontologies bzip2 libssh exiv2 attica
       samba (libcanberra.override { gtk = null; }) ntrack libjpeg
     ];
 
diff --git a/pkgs/desktops/kde-4.8/kdelibs.nix b/pkgs/desktops/kde-4.8/kdelibs.nix
index 106909ac3dbb2..31df83e5ee921 100644
--- a/pkgs/desktops/kde-4.8/kdelibs.nix
+++ b/pkgs/desktops/kde-4.8/kdelibs.nix
@@ -1,17 +1,16 @@
 { kde, gcc, cmake, perl
 , qt4, bzip2, pcre, fam, libxml2, libxslt, shared_mime_info, giflib, jasper
-, xz, openexr, avahi, kerberos, acl, attr, shared_desktop_ontologies, libXScrnSaver
+, openexr, avahi, kerberos, acl, attr, shared_desktop_ontologies, libXScrnSaver
 , automoc4, strigi, soprano, qca2, attica, enchant, libdbusmenu_qt
 , docbook_xml_dtd_42, docbook_xsl, polkit_qt_1
-, getopt, udev, herqq, phonon, libjpeg
+, getopt, udev, herqq, phonon, libjpeg, xz
 }:
 
 kde {
   buildInputs =
-    [
-      acl attr attica avahi bzip2 enchant fam getopt giflib herqq jasper
+    [ acl attr attica avahi bzip2 enchant fam getopt giflib herqq jasper
       libdbusmenu_qt libXScrnSaver libxslt pcre polkit_qt_1 qca2
-      shared_desktop_ontologies udev xz libxml2 libjpeg kerberos
+      shared_desktop_ontologies xz udev libxml2 libjpeg kerberos
     ];
 
   propagatedBuildInputs = [ qt4 soprano strigi phonon ];
diff --git a/pkgs/desktops/kde-4.8/kdeutils/ark.nix b/pkgs/desktops/kde-4.8/kdeutils/ark.nix
index 4449dd8228f25..7fbdaf586d668 100644
--- a/pkgs/desktops/kde-4.8/kdeutils/ark.nix
+++ b/pkgs/desktops/kde-4.8/kdeutils/ark.nix
@@ -1,7 +1,7 @@
-{ kde, kdelibs, libarchive, xz, bzip2, kde_baseapps }:
+{ kde, kdelibs, libarchive, bzip2, kde_baseapps }:
 
 kde {
-  buildInputs = [ kdelibs kde_baseapps libarchive xz bzip2 ];
+  buildInputs = [ kdelibs kde_baseapps libarchive bzip2 ];
 
   meta = {
     description = "KDE Archiving Tool";
diff --git a/pkgs/development/compilers/abc/builder-binjar.sh b/pkgs/development/compilers/abc/builder-binjar.sh
index 9faa0541c6c32..a954c49aa3f63 100644
--- a/pkgs/development/compilers/abc/builder-binjar.sh
+++ b/pkgs/development/compilers/abc/builder-binjar.sh
@@ -1,4 +1,4 @@
 source $stdenv/setup
 
-ensureDir $out/jars
+mkdir -p $out/jars
 cp $src $out/jars/$jarname.jar
diff --git a/pkgs/development/compilers/abc/builder.sh b/pkgs/development/compilers/abc/builder.sh
index 36d2e4e68e1ce..ba59402384267 100644
--- a/pkgs/development/compilers/abc/builder.sh
+++ b/pkgs/development/compilers/abc/builder.sh
@@ -23,7 +23,7 @@ EOF
 
 $apacheAnt/bin/ant jars
 
-ensureDir $out/jars
+mkdir -p $out/jars
 
 cp lib/abc.jar $out/jars
 cp lib/abc-runtime.jar $out/jars
@@ -31,7 +31,7 @@ cp lib/abc-testing.jar $out/jars
 cp lib/abc-complete.jar $out/jars
 
 # Create the executable abc script
-ensureDir $out/bin
+mkdir -p $out/bin
 cat > $out/bin/abc <<EOF
 #! $SHELL -e
 
diff --git a/pkgs/development/compilers/abc/jasmin/builder.sh b/pkgs/development/compilers/abc/jasmin/builder.sh
index c30f86fb7f5e1..81b150b952785 100644
--- a/pkgs/development/compilers/abc/jasmin/builder.sh
+++ b/pkgs/development/compilers/abc/jasmin/builder.sh
@@ -20,5 +20,5 @@ EOF
 
 ant jasmin-jar
 
-ensureDir $out/jars/
+mkdir -p $out/jars/
 mv lib/jasminclasses-foo.jar $out/jars/jasmin.jar
diff --git a/pkgs/development/compilers/abc/polyglot/builder.sh b/pkgs/development/compilers/abc/polyglot/builder.sh
index 81acfde1d4f7e..babae49ae557f 100644
--- a/pkgs/development/compilers/abc/polyglot/builder.sh
+++ b/pkgs/development/compilers/abc/polyglot/builder.sh
@@ -6,6 +6,6 @@ cd polyglot-*
 ant polyglot-jar
 ant cup
 
-ensureDir $out/jars/
+mkdir -p $out/jars/
 mv lib/java_cup.jar $out/jars/
 mv lib/polyglot*.jar $out/jars/
diff --git a/pkgs/development/compilers/abc/soot/builder.sh b/pkgs/development/compilers/abc/soot/builder.sh
index 18718943077fe..adc27161e4e28 100644
--- a/pkgs/development/compilers/abc/soot/builder.sh
+++ b/pkgs/development/compilers/abc/soot/builder.sh
@@ -15,5 +15,5 @@ EOF
 
 ant classesjar
 
-ensureDir $out/jars/
+mkdir -p $out/jars/
 mv lib/sootclasses-foo.jar $out/jars/soot.jar
diff --git a/pkgs/development/compilers/adobe-flex-sdk/default.nix b/pkgs/development/compilers/adobe-flex-sdk/default.nix
index 190da87227846..fc4511d896e27 100644
--- a/pkgs/development/compilers/adobe-flex-sdk/default.nix
+++ b/pkgs/development/compilers/adobe-flex-sdk/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
   installPhase = ''
     unzip ${src}
     t=$out/opt/flex-sdk
-    ensureDir $t $out/bin
+    mkdir -p $t $out/bin
     mv * $t
     rm $t/bin/*.exe $t/bin/*.bat
     sed 's/
$//' -i $t/bin/*
diff --git a/pkgs/development/compilers/aspectj/builder.sh b/pkgs/development/compilers/aspectj/builder.sh
index 7b82f7f2a9ecb..3b43937200423 100755
--- a/pkgs/development/compilers/aspectj/builder.sh
+++ b/pkgs/development/compilers/aspectj/builder.sh
@@ -7,7 +7,7 @@ output.dir=$out
 context.javaPath=$jre
 EOF
 
-ensureDir $out
+mkdir -p $out
 $jre/bin/java -jar $src -text props
 
 echo "Removing files at top level"
diff --git a/pkgs/development/compilers/ccl/default.nix b/pkgs/development/compilers/ccl/default.nix
index 404c0fce52325..54628fa509d90 100644
--- a/pkgs/development/compilers/ccl/default.nix
+++ b/pkgs/development/compilers/ccl/default.nix
@@ -21,10 +21,10 @@ rec {
   phaseNames = ["doUnpack" "doPatchElf" "doCopy"];
 
   doCopy = a.fullDepEntry ''
-    ensureDir "$out/share"
+    mkdir -p "$out/share"
     cp -r . "$out/share/ccl-installation"
 
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     for i in $(find . -maxdepth 1 -type f -perm +111); do
       echo -e '#! /bin/sh\n'"$out/share/ccl-installation/$(basename "$i")"'"$@"\n' > "$out"/bin/"$(basename "$i")"
       chmod a+x "$out"/bin/"$(basename "$i")"
diff --git a/pkgs/development/compilers/cmucl/binary.nix b/pkgs/development/compilers/cmucl/binary.nix
index 1e5c7d4febc82..11d0b723ce459 100644
--- a/pkgs/development/compilers/cmucl/binary.nix
+++ b/pkgs/development/compilers/cmucl/binary.nix
@@ -26,7 +26,7 @@ stdenv.mkDerivation {
   name = "cmucl-binary-${version}";
 
   buildCommand = ''
-    ensureDir $out
+    mkdir -p $out
     tar -C $out -xjf ${dist}
     patchelf --set-interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" \
       $out/bin/lisp
diff --git a/pkgs/development/compilers/eql/default.nix b/pkgs/development/compilers/eql/default.nix
index 70d309472243d..4e288824713d7 100644
--- a/pkgs/development/compilers/eql/default.nix
+++ b/pkgs/development/compilers/eql/default.nix
@@ -64,7 +64,7 @@ rec {
 
   doDeploy = a.fullDepEntry (''
     cd ..
-    ensureDir $out/bin $out/lib/eql/ $out/include $out/include/gen $out/lib
+    mkdir -p $out/bin $out/lib/eql/ $out/include $out/include/gen $out/lib
     cp -r . $out/lib/eql/build-dir
     ln -s $out/lib/eql/build-dir/eql $out/bin
     ln -s $out/lib/eql/build-dir/src/*.h $out/include
diff --git a/pkgs/development/compilers/fpc/lazarus.nix b/pkgs/development/compilers/fpc/lazarus.nix
index d8830c4e24969..1cb4e479e37cf 100644
--- a/pkgs/development/compilers/fpc/lazarus.nix
+++ b/pkgs/development/compilers/fpc/lazarus.nix
@@ -23,7 +23,7 @@ rec {
   preBuild = fullDepEntry (''
     export NIX_LDFLAGS='-lXi -lX11 -lglib-2.0 -lgtk-x11-2.0 -lgdk-x11-2.0 -lc -lXext -lpango-1.0 -latk-1.0 -lgdk_pixbuf-2.0 -lcairo'
     export LCL_PLATFORM=gtk2
-    ensureDir $out/share
+    mkdir -p $out/share
     tar xf ${fpc.src} --strip-components=1 -C $out/share -m
     sed -e 's@/usr/fpcsrc@'"$out/share/fpcsrc@" -i ide/include/unix/lazbaseconf.inc
   '') 
diff --git a/pkgs/development/compilers/gcc-4.5/update-gcc.sh b/pkgs/development/compilers/gcc-4.5/update-gcc.sh
deleted file mode 120000
index dd7bcd60c1b41..0000000000000
--- a/pkgs/development/compilers/gcc-4.5/update-gcc.sh
+++ /dev/null
@@ -1 +0,0 @@
-../gcc-4.4/update-gcc.sh
\ No newline at end of file
diff --git a/pkgs/development/compilers/gcc-4.6/update-gcc.sh b/pkgs/development/compilers/gcc-4.6/update-gcc.sh
deleted file mode 120000
index dd7bcd60c1b41..0000000000000
--- a/pkgs/development/compilers/gcc-4.6/update-gcc.sh
+++ /dev/null
@@ -1 +0,0 @@
-../gcc-4.4/update-gcc.sh
\ No newline at end of file
diff --git a/pkgs/development/compilers/gcc-upc-4.0/default.nix b/pkgs/development/compilers/gcc-upc-4.0/default.nix
index 68ae49b152a18..b3b458aae1fac 100644
--- a/pkgs/development/compilers/gcc-upc-4.0/default.nix
+++ b/pkgs/development/compilers/gcc-upc-4.0/default.nix
@@ -6,14 +6,16 @@
 , texinfo ? null
 }:
 
-with import ../../../lib;
+with stdenv.lib;
 
 # GCC-UPC apparently doesn't support GCov and friends.
 assert profiledCompiler == false;
 
 stdenv.mkDerivation {
   name = "gcc-upc-4.0.3.5";
-  builder = ../gcc-4.0/builder.sh;
+  
+  builder = ../gcc/4.0/builder.sh;
+  
   src = fetchurl {
     url = "ftp://ftp.intrepid.com/pub/upc/rls/upc-4.0.3.5/upc-4.0.3.5.src.tar.gz";
     sha256 = "0afnz1bz0kknhl18205bbwncyza08983ivfaagj5yl7x3nwy7prv";
@@ -30,13 +32,13 @@ stdenv.mkDerivation {
   langF77 = false;
   langUPC = true;    # unused
 
-  buildInputs = [gmp mpfr texinfo
-
-                 # Bison is needed to build the parsers.
-                 bison
-
-		 # For some reason, `autoheader' and `m4' are needed.
-		 autoconf gnum4];
+  buildInputs =
+    [ gmp mpfr texinfo
+      # Bison is needed to build the parsers.
+      bison
+      # For some reason, `autoheader' and `m4' are needed.
+      autoconf gnum4
+    ];
 
   # Note: We use `--enable-maintainer-mode' so that `bison' is actually
   # run when needed.
diff --git a/pkgs/development/compilers/gcc-2.95/builder.sh b/pkgs/development/compilers/gcc/2.95/builder.sh
index 5244d986da088..5244d986da088 100644
--- a/pkgs/development/compilers/gcc-2.95/builder.sh
+++ b/pkgs/development/compilers/gcc/2.95/builder.sh
diff --git a/pkgs/development/compilers/gcc-2.95/default.nix b/pkgs/development/compilers/gcc/2.95/default.nix
index d1f20dd230ffb..d1f20dd230ffb 100644
--- a/pkgs/development/compilers/gcc-2.95/default.nix
+++ b/pkgs/development/compilers/gcc/2.95/default.nix
diff --git a/pkgs/development/compilers/gcc-2.95/no-sys-dirs.patch b/pkgs/development/compilers/gcc/2.95/no-sys-dirs.patch
index 886b7cb37c3cd..886b7cb37c3cd 100644
--- a/pkgs/development/compilers/gcc-2.95/no-sys-dirs.patch
+++ b/pkgs/development/compilers/gcc/2.95/no-sys-dirs.patch
diff --git a/pkgs/development/compilers/gcc-3.3/builder.sh b/pkgs/development/compilers/gcc/3.3/builder.sh
index 5b80215cffb51..5b80215cffb51 100644
--- a/pkgs/development/compilers/gcc-3.3/builder.sh
+++ b/pkgs/development/compilers/gcc/3.3/builder.sh
diff --git a/pkgs/development/compilers/gcc-3.3/default.nix b/pkgs/development/compilers/gcc/3.3/default.nix
index 9aa9e27ac6f7e..9aa9e27ac6f7e 100644
--- a/pkgs/development/compilers/gcc-3.3/default.nix
+++ b/pkgs/development/compilers/gcc/3.3/default.nix
diff --git a/pkgs/development/compilers/gcc-3.4/builder.sh b/pkgs/development/compilers/gcc/3.4/builder.sh
index 5a43d600a5034..5a43d600a5034 100644
--- a/pkgs/development/compilers/gcc-3.4/builder.sh
+++ b/pkgs/development/compilers/gcc/3.4/builder.sh
diff --git a/pkgs/development/compilers/gcc-3.4/default.nix b/pkgs/development/compilers/gcc/3.4/default.nix
index de7f079b2d90b..6cadf58d2ce69 100644
--- a/pkgs/development/compilers/gcc-3.4/default.nix
+++ b/pkgs/development/compilers/gcc/3.4/default.nix
@@ -5,7 +5,7 @@
 
 assert langC;
 
-with import ../../../lib;
+with stdenv.lib;
 
 stdenv.mkDerivation {
   name = "gcc-3.4.6";
diff --git a/pkgs/development/compilers/gcc-3.4/no-sys-dirs.patch b/pkgs/development/compilers/gcc/3.4/no-sys-dirs.patch
index 2159893cde2b7..2159893cde2b7 100644
--- a/pkgs/development/compilers/gcc-3.4/no-sys-dirs.patch
+++ b/pkgs/development/compilers/gcc/3.4/no-sys-dirs.patch
diff --git a/pkgs/development/compilers/gcc-4.0/builder.sh b/pkgs/development/compilers/gcc/4.0/builder.sh
index 08622c1899ed3..08622c1899ed3 100644
--- a/pkgs/development/compilers/gcc-4.0/builder.sh
+++ b/pkgs/development/compilers/gcc/4.0/builder.sh
diff --git a/pkgs/development/compilers/gcc-4.0/default.nix b/pkgs/development/compilers/gcc/4.0/default.nix
index 45c5bedd99b4a..4e51681a533a3 100644
--- a/pkgs/development/compilers/gcc-4.0/default.nix
+++ b/pkgs/development/compilers/gcc/4.0/default.nix
@@ -8,7 +8,7 @@
 
 assert langC;
 
-with import ../../../lib;
+with stdenv.lib;
 
 stdenv.mkDerivation {
   name = "${name}-4.0.4";
diff --git a/pkgs/development/compilers/gcc-4.0/gcc-4.0.2-cxx.patch b/pkgs/development/compilers/gcc/4.0/gcc-4.0.2-cxx.patch
index b9d558d5c1756..b9d558d5c1756 100644
--- a/pkgs/development/compilers/gcc-4.0/gcc-4.0.2-cxx.patch
+++ b/pkgs/development/compilers/gcc/4.0/gcc-4.0.2-cxx.patch
diff --git a/pkgs/development/compilers/gcc-4.0/no-sys-dirs.patch b/pkgs/development/compilers/gcc/4.0/no-sys-dirs.patch
index 74ef6056b1fd6..74ef6056b1fd6 100644
--- a/pkgs/development/compilers/gcc-4.0/no-sys-dirs.patch
+++ b/pkgs/development/compilers/gcc/4.0/no-sys-dirs.patch
diff --git a/pkgs/development/compilers/gcc-4.1/builder.sh b/pkgs/development/compilers/gcc/4.1/builder.sh
index f8abca122570d..f8abca122570d 100644
--- a/pkgs/development/compilers/gcc-4.1/builder.sh
+++ b/pkgs/development/compilers/gcc/4.1/builder.sh
diff --git a/pkgs/development/compilers/gcc-4.1/default.nix b/pkgs/development/compilers/gcc/4.1/default.nix
index 66bf48cb6e12a..b460ad813f810 100644
--- a/pkgs/development/compilers/gcc-4.1/default.nix
+++ b/pkgs/development/compilers/gcc/4.1/default.nix
@@ -10,7 +10,7 @@
 
 assert langC || langFortran;
 
-with import ../../../lib;
+with stdenv.lib;
 
 stdenv.mkDerivation {
   name = "${name}-4.1.2";
diff --git a/pkgs/development/compilers/gcc-4.1/no-sys-dirs.patch b/pkgs/development/compilers/gcc/4.1/no-sys-dirs.patch
index 7872e4901ef5b..7872e4901ef5b 100644
--- a/pkgs/development/compilers/gcc-4.1/no-sys-dirs.patch
+++ b/pkgs/development/compilers/gcc/4.1/no-sys-dirs.patch
diff --git a/pkgs/development/compilers/gcc-apple/builder.sh b/pkgs/development/compilers/gcc/4.2-apple32/builder.sh
index 1e4eccafbb2e0..1e4eccafbb2e0 100644
--- a/pkgs/development/compilers/gcc-apple/builder.sh
+++ b/pkgs/development/compilers/gcc/4.2-apple32/builder.sh
diff --git a/pkgs/development/compilers/gcc-apple/debug_list.patch b/pkgs/development/compilers/gcc/4.2-apple32/debug_list.patch
index b26f15e6512f1..b26f15e6512f1 100644
--- a/pkgs/development/compilers/gcc-apple/debug_list.patch
+++ b/pkgs/development/compilers/gcc/4.2-apple32/debug_list.patch
diff --git a/pkgs/development/compilers/gcc-apple/default.nix b/pkgs/development/compilers/gcc/4.2-apple32/default.nix
index 3346a4e327a5a..3346a4e327a5a 100644
--- a/pkgs/development/compilers/gcc-apple/default.nix
+++ b/pkgs/development/compilers/gcc/4.2-apple32/default.nix
diff --git a/pkgs/development/compilers/gcc-apple/no-sys-dirs.patch b/pkgs/development/compilers/gcc/4.2-apple32/no-sys-dirs.patch
index b7b93d6944cc4..b7b93d6944cc4 100644
--- a/pkgs/development/compilers/gcc-apple/no-sys-dirs.patch
+++ b/pkgs/development/compilers/gcc/4.2-apple32/no-sys-dirs.patch
diff --git a/pkgs/development/compilers/gcc-apple/pass-cxxcpp.patch b/pkgs/development/compilers/gcc/4.2-apple32/pass-cxxcpp.patch
index 4f9a29ae51bb1..4f9a29ae51bb1 100644
--- a/pkgs/development/compilers/gcc-apple/pass-cxxcpp.patch
+++ b/pkgs/development/compilers/gcc/4.2-apple32/pass-cxxcpp.patch
diff --git a/pkgs/development/compilers/gcc-apple64/builder.sh b/pkgs/development/compilers/gcc/4.2-apple64/builder.sh
index 6072aef9d5911..036678460d60a 100644
--- a/pkgs/development/compilers/gcc-apple64/builder.sh
+++ b/pkgs/development/compilers/gcc/4.2-apple64/builder.sh
@@ -84,22 +84,32 @@ postInstall() {
     rm -rf $out/libexec/gcc/*/*/install-tools
 }
 
+
 postUnpack() {
-  mv $libstdcxx/libstdcxx $sourceRoot/
+    mv $libstdcxx/libstdcxx $sourceRoot/
 }
 
+
 STDCXX_INCDIR="$out/include/c++/4.2.1"
 
 genericBuild
 
 
 echo '-------------------------------------------------------------------------------------------------------------------------'
-echo 'libstdcxx-16'
+echo 'libstdcxx'
 echo '-------------------------------------------------------------------------------------------------------------------------'
 
 cd ..
 pwd
 
+unpackPhase () {
+    true
+}
+
+patchPhase() {
+    true
+}
+
 preConfigure() {
     # Perform the build in a different directory.
     mkdir ../build_libstdcxx
@@ -111,18 +121,9 @@ preConfigure() {
     configureFlags="--disable-libstdcxx-pch --disable-libstdcxx-debug --disable-multilib --with-gxx-include-dir=${STDCXX_INCDIR}"
 }
 
-unpackPhase () {
-  echo '-'
-}
-
 postInstall() {
-  echo '-'
-  echo "cp -v ${STDCXX_INCDIR}/*/bits/* ${STDCXX_INCDIR}/bits/"
-  cp -v ${STDCXX_INCDIR}/*/bits/* ${STDCXX_INCDIR}/bits/
-}
-
-patchPhase() {
-  echo '-'
+    echo "cp -v ${STDCXX_INCDIR}/*/bits/* ${STDCXX_INCDIR}/bits/"
+    cp -v ${STDCXX_INCDIR}/*/bits/* ${STDCXX_INCDIR}/bits/
 }
 
 genericBuild
diff --git a/pkgs/development/compilers/gcc-apple64/debug_list.patch b/pkgs/development/compilers/gcc/4.2-apple64/debug_list.patch
index b26f15e6512f1..b26f15e6512f1 100644
--- a/pkgs/development/compilers/gcc-apple64/debug_list.patch
+++ b/pkgs/development/compilers/gcc/4.2-apple64/debug_list.patch
diff --git a/pkgs/development/compilers/gcc-apple64/default.nix b/pkgs/development/compilers/gcc/4.2-apple64/default.nix
index e2f70fbc1f568..9f46f1da1e4c2 100644
--- a/pkgs/development/compilers/gcc-apple64/default.nix
+++ b/pkgs/development/compilers/gcc/4.2-apple64/default.nix
@@ -1,10 +1,9 @@
 { stdenv, fetchurl, noSysDirs
-, langC ? true, langCC ? true, langObjC ? true, langF77 ? false
+, langCC ? true, langObjC ? true, langF77 ? false
 , profiledCompiler ? false
 , gmp ? null, mpfr ? null, bison ? null, flex ? null
 }:
 
-assert langC;
 assert stdenv.isDarwin;
 assert langF77 -> gmp != null;
 
@@ -12,27 +11,34 @@ let
   version  = "4.2.1";   # Upstream GCC version, from `gcc/BASE-VER'.
   revision = "5666.3";  # Apple's fork revision number.
 in
-stdenv.mkDerivation ({
+
+stdenv.mkDerivation {
   name = "gcc-apple-${version}.${revision}";
 
   builder = ./builder.sh;
 
   src =
-    stdenv.lib.optional /*langC*/ true (fetchurl {
+    stdenv.lib.optional true (fetchurl {
       url = "http://www.opensource.apple.com/tarballs/gcc/gcc-${revision}.tar.gz";
       sha256 = "0nq1szgqx9ryh1qsn5n6yd55gpvf56wr8f7w1jzabb8idlvz8ikc";
     }) ++
     stdenv.lib.optional langCC (fetchurl {
-      url = http://www.opensource.apple.com/tarballs/libstdcxx/libstdcxx-39.tar.gz ;
+      url = http://www.opensource.apple.com/tarballs/libstdcxx/libstdcxx-39.tar.gz;
       sha256 = "ccf4cf432c142778c766affbbf66b61001b6c4f1107bc2b2c77ce45598786b6d";
-    }) ;
+    });
 
   enableParallelBuilding = true;
 
   libstdcxx = "libstdcxx-39";
+
   sourceRoot = "gcc-${revision}/";
+
   patches =
-    [./pass-cxxcpp.patch ]
-    ++ (if noSysDirs then [./no-sys-dirs.patch] else []);
-  inherit noSysDirs langC langCC langF77 langObjC profiledCompiler;
-} // (if langF77 then {buildInputs = [gmp mpfr bison flex];} else {}))
+    [ ./pass-cxxcpp.patch ./fix-libstdc++-link.patch ]
+    ++ stdenv.lib.optional noSysDirs [ ./no-sys-dirs.patch ];
+
+  inherit noSysDirs langCC langF77 langObjC;
+  langC = true;
+
+  buildInputs = stdenv.lib.optionals langF77 [ gmp mpfr bison flex ];
+}
diff --git a/pkgs/development/compilers/gcc/4.2-apple64/fix-libstdc++-link.patch b/pkgs/development/compilers/gcc/4.2-apple64/fix-libstdc++-link.patch
new file mode 100644
index 0000000000000..e7b8a55a29afa
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.2-apple64/fix-libstdc++-link.patch
@@ -0,0 +1,17 @@
+Prevent our libstdc++.dylib from having a runtime dependency on
+/usr/lib/libstdc++.dylib.  This is caused by the implicit -lstdc++
+passed by g++ when it links libstdc++.dylib.  Adding "-nostdlib" to
+the g++ invocation prevents this.
+
+diff -ru -x '*~' libstdcxx-39-orig/libstdcxx/libstdc++-v3/src/Makefile.in libstdcxx-39/libstdcxx/libstdc++-v3/src/Makefile.in
+--- x/libstdcxx/libstdc++-v3/src/Makefile.in	2006-10-16 21:08:22.000000000 +0200
++++ y/libstdcxx/libstdc++-v3/src/Makefile.in	2012-02-17 18:44:05.210570590 +0100
+@@ -388,7 +388,7 @@
+ 
+ libstdc___la_DEPENDENCIES = ${version_dep} $(libstdc___la_LIBADD)
+ libstdc___la_LDFLAGS = \
+-	-version-info $(libtool_VERSION) ${version_arg} -lm 
++	-version-info $(libtool_VERSION) ${version_arg} -lm -Wc,-nostdlib
+ 
+ 
+ # Use special rules for the deprecated source files so that they find
diff --git a/pkgs/development/compilers/gcc-apple64/no-sys-dirs.patch b/pkgs/development/compilers/gcc/4.2-apple64/no-sys-dirs.patch
index b7b93d6944cc4..b7b93d6944cc4 100644
--- a/pkgs/development/compilers/gcc-apple64/no-sys-dirs.patch
+++ b/pkgs/development/compilers/gcc/4.2-apple64/no-sys-dirs.patch
diff --git a/pkgs/development/compilers/gcc-apple64/pass-cxxcpp.patch b/pkgs/development/compilers/gcc/4.2-apple64/pass-cxxcpp.patch
index 4f9a29ae51bb1..4f9a29ae51bb1 100644
--- a/pkgs/development/compilers/gcc-apple64/pass-cxxcpp.patch
+++ b/pkgs/development/compilers/gcc/4.2-apple64/pass-cxxcpp.patch
diff --git a/pkgs/development/compilers/gcc-4.2/builder.sh b/pkgs/development/compilers/gcc/4.2/builder.sh
index d749fc08d2a06..d749fc08d2a06 100644
--- a/pkgs/development/compilers/gcc-4.2/builder.sh
+++ b/pkgs/development/compilers/gcc/4.2/builder.sh
diff --git a/pkgs/development/compilers/gcc-4.2/default.nix b/pkgs/development/compilers/gcc/4.2/default.nix
index 68a174cc5797a..68a174cc5797a 100644
--- a/pkgs/development/compilers/gcc-4.2/default.nix
+++ b/pkgs/development/compilers/gcc/4.2/default.nix
diff --git a/pkgs/development/compilers/gcc-4.2/no-sys-dirs.patch b/pkgs/development/compilers/gcc/4.2/no-sys-dirs.patch
index f1d429e274a0b..f1d429e274a0b 100644
--- a/pkgs/development/compilers/gcc-4.2/no-sys-dirs.patch
+++ b/pkgs/development/compilers/gcc/4.2/no-sys-dirs.patch
diff --git a/pkgs/development/compilers/gcc-4.2/pass-cxxcpp.patch b/pkgs/development/compilers/gcc/4.2/pass-cxxcpp.patch
index 9b0676d4fdc95..9b0676d4fdc95 100644
--- a/pkgs/development/compilers/gcc-4.2/pass-cxxcpp.patch
+++ b/pkgs/development/compilers/gcc/4.2/pass-cxxcpp.patch
diff --git a/pkgs/development/compilers/gcc-4.3/builder.sh b/pkgs/development/compilers/gcc/4.3/builder.sh
index aaf0c54d99bfc..aaf0c54d99bfc 100644
--- a/pkgs/development/compilers/gcc-4.3/builder.sh
+++ b/pkgs/development/compilers/gcc/4.3/builder.sh
diff --git a/pkgs/development/compilers/gcc-4.3/default.nix b/pkgs/development/compilers/gcc/4.3/default.nix
index 57fc0f805c47c..57fc0f805c47c 100644
--- a/pkgs/development/compilers/gcc-4.3/default.nix
+++ b/pkgs/development/compilers/gcc/4.3/default.nix
diff --git a/pkgs/development/compilers/gcc-4.3/ghdl-ortho-cflags.patch b/pkgs/development/compilers/gcc/4.3/ghdl-ortho-cflags.patch
index 14188083f7619..14188083f7619 100644
--- a/pkgs/development/compilers/gcc-4.3/ghdl-ortho-cflags.patch
+++ b/pkgs/development/compilers/gcc/4.3/ghdl-ortho-cflags.patch
diff --git a/pkgs/development/compilers/gcc-4.3/java-jvgenmain-link.patch b/pkgs/development/compilers/gcc/4.3/java-jvgenmain-link.patch
index 2612e8bfbbbcd..2612e8bfbbbcd 100644
--- a/pkgs/development/compilers/gcc-4.3/java-jvgenmain-link.patch
+++ b/pkgs/development/compilers/gcc/4.3/java-jvgenmain-link.patch
diff --git a/pkgs/development/compilers/gcc-4.3/libmudflap-cpp.patch b/pkgs/development/compilers/gcc/4.3/libmudflap-cpp.patch
index 09dfb26b20db8..09dfb26b20db8 100644
--- a/pkgs/development/compilers/gcc-4.3/libmudflap-cpp.patch
+++ b/pkgs/development/compilers/gcc/4.3/libmudflap-cpp.patch
diff --git a/pkgs/development/compilers/gcc-4.3/no-sys-dirs-fortran.patch b/pkgs/development/compilers/gcc/4.3/no-sys-dirs-fortran.patch
index 4568e57819b20..4568e57819b20 100644
--- a/pkgs/development/compilers/gcc-4.3/no-sys-dirs-fortran.patch
+++ b/pkgs/development/compilers/gcc/4.3/no-sys-dirs-fortran.patch
diff --git a/pkgs/development/compilers/gcc-4.3/no-sys-dirs.patch b/pkgs/development/compilers/gcc/4.3/no-sys-dirs.patch
index 69fa2c7de8287..69fa2c7de8287 100644
--- a/pkgs/development/compilers/gcc-4.3/no-sys-dirs.patch
+++ b/pkgs/development/compilers/gcc/4.3/no-sys-dirs.patch
diff --git a/pkgs/development/compilers/gcc-4.3/pass-cxxcpp.patch b/pkgs/development/compilers/gcc/4.3/pass-cxxcpp.patch
index 9b0676d4fdc95..9b0676d4fdc95 100644
--- a/pkgs/development/compilers/gcc-4.3/pass-cxxcpp.patch
+++ b/pkgs/development/compilers/gcc/4.3/pass-cxxcpp.patch
diff --git a/pkgs/development/compilers/gcc-4.4/builder.sh b/pkgs/development/compilers/gcc/4.4/builder.sh
index abe14b457ab2e..abe14b457ab2e 100644
--- a/pkgs/development/compilers/gcc-4.4/builder.sh
+++ b/pkgs/development/compilers/gcc/4.4/builder.sh
diff --git a/pkgs/development/compilers/gcc-4.4/default.nix b/pkgs/development/compilers/gcc/4.4/default.nix
index fa34364912e92..d962d4ac3471a 100644
--- a/pkgs/development/compilers/gcc-4.4/default.nix
+++ b/pkgs/development/compilers/gcc/4.4/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, noSysDirs
-, langC ? true, langCC ? true, langFortran ? false, langTreelang ? false
+, langC ? true, langCC ? true, langFortran ? false
 , langJava ? false
 , langAda ? false
 , langVhdl ? false
@@ -9,7 +9,6 @@
 , texinfo ? null
 , gmp, mpfr, gettext, which
 , ppl ? null, cloogppl ? null  # used by the Graphite optimization framework
-, bison ? null, flex ? null
 , zlib ? null, boehmgc ? null
 , zip ? null, unzip ? null, pkgconfig ? null, gtk ? null, libart_lgpl ? null
 , libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null
@@ -25,7 +24,6 @@
 , gnat ? null
 }:
 
-assert langTreelang -> bison != null && flex != null;
 assert langJava     -> zip != null && unzip != null
                        && zlib != null && boehmgc != null;
 assert langAda      -> gnatboot != null;
@@ -131,11 +129,10 @@ stdenv.mkDerivation ({
   buildInputs = [ gmp mpfr gettext ]
     ++ (optional (ppl != null) ppl)
     ++ (optional (cloogppl != null) cloogppl)
-    ++ (optionals langTreelang [bison flex])
     ++ (optional (zlib != null) zlib)
     ++ (optional (boehmgc != null) boehmgc)
     ++ (optionals langJava [zip unzip])
-    ++ (optionals javaAwtGtk [gtk pkgconfig libart_lgpl] ++ xlibs)
+    ++ (optionals javaAwtGtk ([gtk pkgconfig libart_lgpl] ++ xlibs))
     ++ (optionals (cross != null) [binutilsCross])
     ++ (optionals langAda [gnatboot])
     ++ (optionals langVhdl [gnat])
@@ -160,7 +157,6 @@ stdenv.mkDerivation ({
         ++ optional langCC       "c++"
         ++ optional langFortran  "fortran"
         ++ optional langJava     "java"
-        ++ optional langTreelang "treelang"
         ++ optional langAda      "ada"
         ++ optional langVhdl     "vhdl"
         )
@@ -209,7 +205,6 @@ stdenv.mkDerivation ({
           ++ optional langCC       "c++"
           ++ optional langFortran  "fortran"
           ++ optional langJava     "java"
-          ++ optional langTreelang "treelang"
           ++ optional langAda      "ada"
           ++ optional langVhdl     "vhdl"
           )
@@ -244,7 +239,7 @@ stdenv.mkDerivation ({
                                           ++ optionals javaAwtGtk [ gmp mpfr ])));
 
 
-  passthru = { inherit langC langCC langAda langFortran langTreelang langVhdl
+  passthru = { inherit langC langCC langAda langFortran langVhdl
       enableMultilib version; };
 
   # ghdl does not build fine with parallel building
diff --git a/pkgs/development/compilers/gcc-4.4/ghdl-ortho-cflags.patch b/pkgs/development/compilers/gcc/4.4/ghdl-ortho-cflags.patch
index 901534591c8f1..901534591c8f1 100644
--- a/pkgs/development/compilers/gcc-4.4/ghdl-ortho-cflags.patch
+++ b/pkgs/development/compilers/gcc/4.4/ghdl-ortho-cflags.patch
diff --git a/pkgs/development/compilers/gcc-4.4/gnat-cflags.patch b/pkgs/development/compilers/gcc/4.4/gnat-cflags.patch
index e85e5076be695..e85e5076be695 100644
--- a/pkgs/development/compilers/gcc-4.4/gnat-cflags.patch
+++ b/pkgs/development/compilers/gcc/4.4/gnat-cflags.patch
diff --git a/pkgs/development/compilers/gcc-4.4/java-jvgenmain-link.patch b/pkgs/development/compilers/gcc/4.4/java-jvgenmain-link.patch
index 2612e8bfbbbcd..2612e8bfbbbcd 100644
--- a/pkgs/development/compilers/gcc-4.4/java-jvgenmain-link.patch
+++ b/pkgs/development/compilers/gcc/4.4/java-jvgenmain-link.patch
diff --git a/pkgs/development/compilers/gcc-4.4/libstdc++-target.patch b/pkgs/development/compilers/gcc/4.4/libstdc++-target.patch
index 0b04b83d08d54..0b04b83d08d54 100644
--- a/pkgs/development/compilers/gcc-4.4/libstdc++-target.patch
+++ b/pkgs/development/compilers/gcc/4.4/libstdc++-target.patch
diff --git a/pkgs/development/compilers/gcc-4.4/no-sys-dirs.patch b/pkgs/development/compilers/gcc/4.4/no-sys-dirs.patch
index 7eaf421cc402b..7eaf421cc402b 100644
--- a/pkgs/development/compilers/gcc-4.4/no-sys-dirs.patch
+++ b/pkgs/development/compilers/gcc/4.4/no-sys-dirs.patch
diff --git a/pkgs/development/compilers/gcc-4.4/pass-cxxcpp.patch b/pkgs/development/compilers/gcc/4.4/pass-cxxcpp.patch
index 9b0676d4fdc95..9b0676d4fdc95 100644
--- a/pkgs/development/compilers/gcc-4.4/pass-cxxcpp.patch
+++ b/pkgs/development/compilers/gcc/4.4/pass-cxxcpp.patch
diff --git a/pkgs/development/compilers/gcc-4.4/pr41818.patch b/pkgs/development/compilers/gcc/4.4/pr41818.patch
index 98731c4606799..98731c4606799 100644
--- a/pkgs/development/compilers/gcc-4.4/pr41818.patch
+++ b/pkgs/development/compilers/gcc/4.4/pr41818.patch
diff --git a/pkgs/development/compilers/gcc-4.4/sources.nix b/pkgs/development/compilers/gcc/4.4/sources.nix
index 357cc2634edc7..357cc2634edc7 100644
--- a/pkgs/development/compilers/gcc-4.4/sources.nix
+++ b/pkgs/development/compilers/gcc/4.4/sources.nix
diff --git a/pkgs/development/compilers/gcc-4.4/target-cpp.patch b/pkgs/development/compilers/gcc/4.4/target-cpp.patch
index ab0f0ee51aaae..ab0f0ee51aaae 100644
--- a/pkgs/development/compilers/gcc-4.4/target-cpp.patch
+++ b/pkgs/development/compilers/gcc/4.4/target-cpp.patch
diff --git a/pkgs/development/compilers/gcc-4.4/update-gcc.sh b/pkgs/development/compilers/gcc/4.4/update-gcc.sh
index 6b0bbb993309a..6b0bbb993309a 100755
--- a/pkgs/development/compilers/gcc-4.4/update-gcc.sh
+++ b/pkgs/development/compilers/gcc/4.4/update-gcc.sh
diff --git a/pkgs/development/compilers/gcc-4.5/builder.sh b/pkgs/development/compilers/gcc/4.5/builder.sh
index aedd5b46b121e..e1e56c8574ac2 100644
--- a/pkgs/development/compilers/gcc-4.5/builder.sh
+++ b/pkgs/development/compilers/gcc/4.5/builder.sh
@@ -46,8 +46,8 @@ if test "$noSysDirs" = "1"; then
         export NIX_FIXINC_DUMMY=/usr/include
     fi
 
-    extraFlags="-g0 -O2 -I$NIX_FIXINC_DUMMY $extraFlags"
-    extraLDFlags="--strip-debug -L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
+    extraFlags="-I$NIX_FIXINC_DUMMY $extraFlags"
+    extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
 
     EXTRA_FLAGS="$extraFlags"
     for i in $extraLDFlags; do
@@ -63,7 +63,7 @@ if test "$noSysDirs" = "1"; then
         unset LIBRARY_PATH
         unset CPATH
         if test -z "$crossStageStatic"; then
-            EXTRA_TARGET_CFLAGS="-g0 -O2 -B${libcCross}/lib -idirafter ${libcCross}/include"
+            EXTRA_TARGET_CFLAGS="-B${libcCross}/lib -idirafter ${libcCross}/include"
             EXTRA_TARGET_LDFLAGS="-Wl,-L${libcCross}/lib"
         fi
     else
@@ -89,8 +89,8 @@ if test "$noSysDirs" = "1"; then
             # The path to the Glibc binaries such as `crti.o'.
             glibc_libdir="$(cat $NIX_GCC_CROSS/nix-support/orig-libc)/lib"
 
-            extraFlags="-g0 -O2 -I$NIX_FIXINC_DUMMY_CROSS $extraFlags"
-            extraLDFlags="--strip-debug -L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
+            extraFlags="-I$NIX_FIXINC_DUMMY_CROSS $extraFlags"
+            extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
 
             EXTRA_TARGET_CFLAGS="$extraFlags"
             for i in $extraLDFlags; do
diff --git a/pkgs/development/compilers/gcc-4.5/default.nix b/pkgs/development/compilers/gcc/4.5/default.nix
index 5dddef522fbdb..b3c639c6f0ae4 100644
--- a/pkgs/development/compilers/gcc-4.5/default.nix
+++ b/pkgs/development/compilers/gcc/4.5/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, noSysDirs
-, langC ? true, langCC ? true, langFortran ? false, langTreelang ? false
+, langC ? true, langCC ? true, langFortran ? false
 , langJava ? false
 , langAda ? false
 , langVhdl ? false
@@ -11,7 +11,6 @@
 , gmp, mpfr, mpc, gettext, which
 , libelf                      # optional, for link-time optimizations (LTO)
 , ppl ? null, cloogppl ? null # optional, for the Graphite optimization framework
-, bison ? null, flex ? null
 , zlib ? null, boehmgc ? null
 , zip ? null, unzip ? null, pkgconfig ? null, gtk ? null, libart_lgpl ? null
 , libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null
@@ -26,9 +25,9 @@
 , crossStageStatic ? true
 , gnat ? null
 , libpthread ? null, libpthreadCross ? null  # required for GNU/Hurd
+, stripped ? true
 }:
 
-assert langTreelang -> bison != null && flex != null;
 assert langJava     -> zip != null && unzip != null
                        && zlib != null && boehmgc != null
                        && perl != null;  # for `--enable-java-home'
@@ -41,7 +40,7 @@ assert libelf != null -> zlib != null;
 with stdenv.lib;
 with builtins;
 
-let version = "4.5.1";
+let version = "4.5.3";
     javaEcj = fetchurl {
       # The `$(top_srcdir)/ecj.jar' file is automatically picked up at
       # `configure' time.
@@ -212,21 +211,15 @@ stdenv.mkDerivation ({
   buildInputs = [ gmp mpfr mpc libelf gettext ]
     ++ (optional (ppl != null) ppl)
     ++ (optional (cloogppl != null) cloogppl)
-    ++ (optionals langTreelang [bison flex])
     ++ (optional (zlib != null) zlib)
     ++ (optional (boehmgc != null) boehmgc)
     ++ (optionals langJava [zip unzip])
-    ++ (optionals javaAwtGtk [gtk pkgconfig libart_lgpl] ++ xlibs)
+    ++ (optionals javaAwtGtk ([gtk pkgconfig libart_lgpl] ++ xlibs))
     ++ (optionals (cross != null) [binutilsCross])
     ++ (optionals langAda [gnatboot])
     ++ (optionals langVhdl [gnat])
     ;
 
-  configureFlagsArray = stdenv.lib.optionals
-    (ppl != null && ppl.dontDisableStatic == true)
-        [ "--with-host-libstdcxx=-lstdc++ -lgcc_s"
-            "--with-stage1-libs=-lstdc++ -lgcc_s" ];
-
   configureFlags = "
     ${if enableMultilib then "" else "--disable-multilib"}
     ${if enableShared then "" else "--disable-shared"}
@@ -254,7 +247,6 @@ stdenv.mkDerivation ({
         ++ optional langCC       "c++"
         ++ optional langFortran  "fortran"
         ++ optional langJava     "java"
-        ++ optional langTreelang "treelang"
         ++ optional langAda      "ada"
         ++ optional langVhdl     "vhdl"
         )
@@ -301,7 +293,6 @@ stdenv.mkDerivation ({
           ++ optional langCC       "c++"
           ++ optional langFortran  "fortran"
           ++ optional langJava     "java"
-          ++ optional langTreelang "treelang"
           ++ optional langAda      "ada"
           ++ optional langVhdl     "vhdl"
           )
@@ -356,7 +347,7 @@ stdenv.mkDerivation ({
 
   EXTRA_TARGET_CFLAGS =
     if cross != null && libcCross != null
-    then "-g0 -O2 -idirafter ${libcCross}/include"
+    then "-idirafter ${libcCross}/include"
     else null;
 
   EXTRA_TARGET_LDFLAGS =
@@ -366,7 +357,7 @@ stdenv.mkDerivation ({
            " -L${libpthreadCross}/lib -Wl,${libpthreadCross.TARGET_LDFLAGS}")
     else null;
 
-  passthru = { inherit langC langCC langAda langFortran langTreelang langVhdl
+  passthru = { inherit langC langCC langAda langFortran langVhdl
       enableMultilib version; };
 
   enableParallelBuilding = true;
@@ -374,7 +365,8 @@ stdenv.mkDerivation ({
   meta = {
     homepage = http://gcc.gnu.org/;
     license = "GPLv3+";  # runtime support libraries are typically LGPLv3+
-    description = "GNU Compiler Collection, version ${version}";
+    description = "GNU Compiler Collection, version ${version}"
+      + (if stripped then "" else " (with debugging info)");
 
     longDescription = ''
       The GNU Compiler Collection includes compiler front ends for C, C++,
@@ -409,6 +401,10 @@ stdenv.mkDerivation ({
   installTargets = "install-gcc install-target-libgcc";
 }
 
+# GCC 4.5.2 doesn't support the `install-strip' target, so let `stdenv' do
+# the stripping by default.
+// optionalAttrs (!stripped) { dontStrip = true; }
+
 // optionalAttrs langVhdl rec {
   name = "ghdl-0.29";
 
diff --git a/pkgs/development/compilers/gcc-4.5/ghdl-ortho-cflags.patch b/pkgs/development/compilers/gcc/4.5/ghdl-ortho-cflags.patch
index 901534591c8f1..901534591c8f1 100644
--- a/pkgs/development/compilers/gcc-4.5/ghdl-ortho-cflags.patch
+++ b/pkgs/development/compilers/gcc/4.5/ghdl-ortho-cflags.patch
diff --git a/pkgs/development/compilers/gcc-4.5/gnat-cflags.patch b/pkgs/development/compilers/gcc/4.5/gnat-cflags.patch
index bf2acf065e9b9..bf2acf065e9b9 100644
--- a/pkgs/development/compilers/gcc-4.5/gnat-cflags.patch
+++ b/pkgs/development/compilers/gcc/4.5/gnat-cflags.patch
diff --git a/pkgs/development/compilers/gcc-4.5/java-jvgenmain-link.patch b/pkgs/development/compilers/gcc/4.5/java-jvgenmain-link.patch
index 2612e8bfbbbcd..2612e8bfbbbcd 100644
--- a/pkgs/development/compilers/gcc-4.5/java-jvgenmain-link.patch
+++ b/pkgs/development/compilers/gcc/4.5/java-jvgenmain-link.patch
diff --git a/pkgs/development/compilers/gcc-4.5/libstdc++-target.patch b/pkgs/development/compilers/gcc/4.5/libstdc++-target.patch
index fb622b3958062..fb622b3958062 100644
--- a/pkgs/development/compilers/gcc-4.5/libstdc++-target.patch
+++ b/pkgs/development/compilers/gcc/4.5/libstdc++-target.patch
diff --git a/pkgs/development/compilers/gcc-4.5/no-sys-dirs.patch b/pkgs/development/compilers/gcc/4.5/no-sys-dirs.patch
index 8128fa87da5fd..8128fa87da5fd 100644
--- a/pkgs/development/compilers/gcc-4.5/no-sys-dirs.patch
+++ b/pkgs/development/compilers/gcc/4.5/no-sys-dirs.patch
diff --git a/pkgs/development/compilers/gcc-4.5/sources.nix b/pkgs/development/compilers/gcc/4.5/sources.nix
index 6059e03880b38..acf1ec2971cb6 100644
--- a/pkgs/development/compilers/gcc-4.5/sources.nix
+++ b/pkgs/development/compilers/gcc/4.5/sources.nix
@@ -1,26 +1,26 @@
 /* Automatically generated by `update-gcc.sh', do not edit.
-   For GCC 4.5.1.  */
+   For GCC 4.5.3.  */
 { fetchurl, optional, version, langC, langCC, langFortran, langJava, langAda }:
 
-assert version == "4.5.1";
+assert version == "4.5.3";
 optional /* langC */ true (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-core-${version}.tar.bz2";
-  sha256 = "0sjjw3qfcpdk0fs5d2rhl0xqcaclg86ifbq45dbk9ca072l3fyxm";
+  sha256 = "fef7ef1396d41f4af2dacbea8826a895060a8a72d9f05546c091085b036f1f87";
 }) ++
 optional langCC (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-g++-${version}.tar.bz2";
-  sha256 = "0j6ffb96b3r75hrjshg52llv21ax7r8jdx44hhj0maiisnl9wd55";
+  sha256 = "e088b9fe0016070da921f353ef8c0c2f81fd11d21e3aeb09210ab7bad080804b";
 }) ++
 optional langFortran (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-fortran-${version}.tar.bz2";
-  sha256 = "0xgwjc3h5fc5c100bnw24c35255il33lj5qbgpxf0zl8di2q13aw";
+  sha256 = "618e8a2334eb3e2baf00891e9b2da47f32e797520e230acddb5f02fada0006cd";
 }) ++
 optional langJava (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-java-${version}.tar.bz2";
-  sha256 = "0mh37q4ibg05h1hdh39pkj1hycvdg6i79m4698knw7pppm14ax8q";
+  sha256 = "c687198d4882c9d505eeb406595dad041602a5b6c67da5cf15d4941b34d20144";
 }) ++
 optional langAda (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-ada-${version}.tar.bz2";
-  sha256 = "11chdbl7h046lnl83k79vj7dvgxz6kq7cnmwx94z644vaiflg153";
+  sha256 = "686a6d2453bc325f32ddc90edf86502dc68320c7cd6948d60d93d0b0f5965b8f";
 }) ++
 []
diff --git a/pkgs/development/compilers/gcc/4.5/update-gcc.sh b/pkgs/development/compilers/gcc/4.5/update-gcc.sh
new file mode 120000
index 0000000000000..907772b2af8af
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.5/update-gcc.sh
@@ -0,0 +1 @@
+../4.4/update-gcc.sh
\ No newline at end of file
diff --git a/pkgs/development/compilers/gcc-4.6/builder.sh b/pkgs/development/compilers/gcc/4.6/builder.sh
index 6cd64bc58f209..6cd64bc58f209 100644
--- a/pkgs/development/compilers/gcc-4.6/builder.sh
+++ b/pkgs/development/compilers/gcc/4.6/builder.sh
diff --git a/pkgs/development/compilers/gcc-4.6/default.nix b/pkgs/development/compilers/gcc/4.6/default.nix
index 7160f530a0981..d630f5562c577 100644
--- a/pkgs/development/compilers/gcc-4.6/default.nix
+++ b/pkgs/development/compilers/gcc/4.6/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, noSysDirs
-, langC ? true, langCC ? true, langFortran ? false, langTreelang ? false
+, langC ? true, langCC ? true, langFortran ? false
 , langJava ? false
 , langAda ? false
 , langVhdl ? false
@@ -11,8 +11,7 @@
 , perl ? null # optional, for texi2pod (then pod2man); required for Java
 , gmp, mpfr, mpc, gettext, which
 , libelf                      # optional, for link-time optimizations (LTO)
-, ppl ? null, cloogppl ? null, cloog ? null # optional, for the Graphite optimization framework. Cannot pass both cloog and cloogppl
-, bison ? null, flex ? null
+, ppl ? null, cloog ? null # optional, for the Graphite optimization framework.
 , zlib ? null, boehmgc ? null
 , zip ? null, unzip ? null, pkgconfig ? null, gtk ? null, libart_lgpl ? null
 , libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null
@@ -20,6 +19,7 @@
 , libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null
 , gnatboot ? null
 , enableMultilib ? false
+, enablePlugin ? true             # whether to support user-supplied plug-ins
 , name ? "gcc"
 , cross ? null
 , binutilsCross ? null
@@ -30,7 +30,6 @@
 , stripped ? true
 }:
 
-assert langTreelang -> bison != null && flex != null;
 assert langJava     -> zip != null && unzip != null
                        && zlib != null && boehmgc != null
                        && perl != null;  # for `--enable-java-home'
@@ -40,13 +39,10 @@ assert langVhdl     -> gnat != null;
 # LTO needs libelf and zlib.
 assert libelf != null -> zlib != null;
 
-# Cannot use both cloog and cloog-ppl
-assert cloog != null -> cloogppl == null;
-
 with stdenv.lib;
 with builtins;
 
-let version = "4.6.2";
+let version = "4.6.3";
     javaEcj = fetchurl {
       # The `$(top_srcdir)/ecj.jar' file is automatically picked up at
       # `configure' time.
@@ -214,12 +210,10 @@ stdenv.mkDerivation ({
 
   buildNativeInputs = [ texinfo which gettext ]
     ++ (optional (perl != null) perl)
-    ++ (optional javaAwtGtk pkgconfig)
-    ++ (optionals langTreelang [bison flex]);
+    ++ (optional javaAwtGtk pkgconfig);
 
   buildInputs = [ gmp mpfr mpc libelf ]
     ++ (optional (ppl != null) ppl)
-    ++ (optional (cloogppl != null) cloogppl)
     ++ (optional (cloog != null) cloog)
     ++ (optional (zlib != null) zlib)
     ++ (optionals langJava [ boehmgc zip unzip ])
@@ -230,16 +224,16 @@ stdenv.mkDerivation ({
     ;
 
   configureFlagsArray = stdenv.lib.optionals
-    (ppl != null && ppl.dontDisableStatic == true)
+    (ppl != null && ppl ? dontDisableStatic && ppl.dontDisableStatic)
         [ "--with-host-libstdcxx=-lstdc++ -lgcc_s" ];
 
   configureFlags = "
     ${if enableMultilib then "" else "--disable-multilib"}
     ${if enableShared then "" else "--disable-shared"}
+    ${if enablePlugin then "--enable-plugin" else ""}
     ${if ppl != null then "--with-ppl=${ppl}" else ""}
-    ${if cloogppl != null then "--with-cloog=${cloogppl}" else ""}
-    ${if cloog != null then 
-      "--with-cloog=${cloog} --enable-cloog-backend=isl" 
+    ${if cloog != null then
+      "--with-cloog=${cloog} --enable-cloog-backend=isl"
       else ""}
     ${if langJava then
       "--with-ecj-jar=${javaEcj} " +
@@ -263,7 +257,6 @@ stdenv.mkDerivation ({
         ++ optional langCC       "c++"
         ++ optional langFortran  "fortran"
         ++ optional langJava     "java"
-        ++ optional langTreelang "treelang"
         ++ optional langAda      "ada"
         ++ optional langVhdl     "vhdl"
         ++ optional langGo       "go"
@@ -301,7 +294,6 @@ stdenv.mkDerivation ({
       ${if enableMultilib then "" else "--disable-multilib"}
       ${if enableShared then "" else "--disable-shared"}
       ${if ppl != null then "--with-ppl=${ppl.hostDrv}" else ""}
-      ${if cloogppl != null then "--with-cloog=${cloogppl.hostDrv}" else ""}
       ${if cloog != null then "--with-cloog=${cloog.hostDrv} --enable-cloog-backend=isl" else ""}
       ${if langJava then "--with-ecj-jar=${javaEcj.hostDrv}" else ""}
       ${if javaAwtGtk then "--enable-java-awt=gtk" else ""}
@@ -317,7 +309,6 @@ stdenv.mkDerivation ({
           ++ optional langCC       "c++"
           ++ optional langFortran  "fortran"
           ++ optional langJava     "java"
-          ++ optional langTreelang "treelang"
           ++ optional langAda      "ada"
           ++ optional langVhdl     "vhdl"
           ++ optional langGo       "go"
@@ -330,7 +321,7 @@ stdenv.mkDerivation ({
       --target=${stdenv.cross.config}
     '';
   };
- 
+
 
   # Needed for the cross compilation to work
   AR = "ar";
@@ -383,7 +374,7 @@ stdenv.mkDerivation ({
            " -L${libpthreadCross}/lib -Wl,${libpthreadCross.TARGET_LDFLAGS}")
     else null;
 
-  passthru = { inherit langC langCC langAda langFortran langTreelang langVhdl
+  passthru = { inherit langC langCC langAda langFortran langVhdl
       langGo enableMultilib version; };
 
   enableParallelBuilding = true;
@@ -421,7 +412,7 @@ stdenv.mkDerivation ({
   installTargets = "install-gcc install-target-libgcc";
 }
 
-// optionalAttrs (!stripped) { dontStrip = true; NIX_STRIP_DEBUG = false; }
+// optionalAttrs (!stripped) { dontStrip = true; NIX_STRIP_DEBUG = 0; }
 
 // optionalAttrs langVhdl rec {
   name = "ghdl-0.29";
diff --git a/pkgs/development/compilers/gcc-4.6/ghdl-ortho-cflags.patch b/pkgs/development/compilers/gcc/4.6/ghdl-ortho-cflags.patch
index 901534591c8f1..901534591c8f1 100644
--- a/pkgs/development/compilers/gcc-4.6/ghdl-ortho-cflags.patch
+++ b/pkgs/development/compilers/gcc/4.6/ghdl-ortho-cflags.patch
diff --git a/pkgs/development/compilers/gcc-4.6/gnat-cflags.patch b/pkgs/development/compilers/gcc/4.6/gnat-cflags.patch
index bf2acf065e9b9..bf2acf065e9b9 100644
--- a/pkgs/development/compilers/gcc-4.6/gnat-cflags.patch
+++ b/pkgs/development/compilers/gcc/4.6/gnat-cflags.patch
diff --git a/pkgs/development/compilers/gcc-4.6/java-jvgenmain-link.patch b/pkgs/development/compilers/gcc/4.6/java-jvgenmain-link.patch
index 2612e8bfbbbcd..2612e8bfbbbcd 100644
--- a/pkgs/development/compilers/gcc-4.6/java-jvgenmain-link.patch
+++ b/pkgs/development/compilers/gcc/4.6/java-jvgenmain-link.patch
diff --git a/pkgs/development/compilers/gcc-4.6/libstdc++-target.patch b/pkgs/development/compilers/gcc/4.6/libstdc++-target.patch
index fb622b3958062..fb622b3958062 100644
--- a/pkgs/development/compilers/gcc-4.6/libstdc++-target.patch
+++ b/pkgs/development/compilers/gcc/4.6/libstdc++-target.patch
diff --git a/pkgs/development/compilers/gcc-4.6/no-sys-dirs.patch b/pkgs/development/compilers/gcc/4.6/no-sys-dirs.patch
index 8128fa87da5fd..8128fa87da5fd 100644
--- a/pkgs/development/compilers/gcc-4.6/no-sys-dirs.patch
+++ b/pkgs/development/compilers/gcc/4.6/no-sys-dirs.patch
diff --git a/pkgs/development/compilers/gcc-4.6/sources.nix b/pkgs/development/compilers/gcc/4.6/sources.nix
index dc85ff10b51cd..fd347aa8bda29 100644
--- a/pkgs/development/compilers/gcc-4.6/sources.nix
+++ b/pkgs/development/compilers/gcc/4.6/sources.nix
@@ -1,31 +1,31 @@
 /* Automatically generated by `update-gcc.sh', do not edit.
-   For GCC 4.6.2.  */
+   For GCC 4.6.3.  */
 { fetchurl, optional, version, langC, langCC, langFortran, langJava, langAda,
   langGo }:
 
-assert version == "4.6.2";
+assert version == "4.6.3";
 optional /* langC */ true (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-core-${version}.tar.bz2";
-  sha256 = "dcbf391f05277b7e09d14d54f3bdaba5515a3a8e7dd1d8af93af3f6f68455e10";
+  sha256 = "283e00881c0de258fafc5170843e4d9b14ee2a7dc4426f0d426e6be0400251c1";
 }) ++
 optional langCC (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-g++-${version}.tar.bz2";
-  sha256 = "5470bea8093438cf5840fbbef3546b6dba7b0153ef6a16e142c1fba1fac6e598";
+  sha256 = "b3e0c733e900e99096b0c5480f57e22e3e583ec3d83596cc2cb9986bd64b29e8";
 }) ++
 optional langFortran (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-fortran-${version}.tar.bz2";
-  sha256 = "492becd732662349eaa5e7c4e458ac009df0ccb8904df54ae295d277c4d6be6f";
+  sha256 = "fe1bdf3485f33e6d0a998ff7bcb42526fbf3083dbfc107c3d95a88c00739eadb";
 }) ++
 optional langJava (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-java-${version}.tar.bz2";
-  sha256 = "d021a16816daeb5db9a3280909d846b38cbdb4cc0d9aa47714c49b08a81d11f1";
+  sha256 = "d0f9aafbd8fe95fdee5797cd02a9a734de0078aa62a9a249b0752adabf76d6e6";
 }) ++
 optional langAda (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-ada-${version}.tar.bz2";
-  sha256 = "9ac26821ad900d02ed251b62e6a0506ee12417b506a7bb9b02ec9f09e5d9c84f";
+  sha256 = "7bb213ec3948646df72720580fcba3489c84aa452bd0e4238712607ef83cbdf6";
 }) ++
 optional langGo (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-go-${version}.tar.bz2";
-  sha256 = "1cafbb254d70f60c39a62a39a3b236674e02c875a1775057ddd33ffafe0fd4e1";
+  sha256 = "7589c16f33ad383769510bb5b9c1aeb7f865f3ae0b89b07b2370d988a4c1fe6d";
 }) ++
 []
diff --git a/pkgs/development/compilers/gcc/4.6/update-gcc.sh b/pkgs/development/compilers/gcc/4.6/update-gcc.sh
new file mode 120000
index 0000000000000..907772b2af8af
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.6/update-gcc.sh
@@ -0,0 +1 @@
+../4.4/update-gcc.sh
\ No newline at end of file
diff --git a/pkgs/development/compilers/ghc/6.10.2-binary.nix b/pkgs/development/compilers/ghc/6.10.2-binary.nix
index bda8372e6c46f..616c9de7edeb6 100644
--- a/pkgs/development/compilers/ghc/6.10.2-binary.nix
+++ b/pkgs/development/compilers/ghc/6.10.2-binary.nix
@@ -70,11 +70,11 @@ stdenv.mkDerivation rec {
   postInstall =
     (if stdenv.isDarwin then
       ''
-        ensureDir $out/frameworks/GMP.framework/Versions/A
+        mkdir -p $out/frameworks/GMP.framework/Versions/A
         ln -s ${gmp}/lib/libgmp.dylib $out/frameworks/GMP.framework/GMP
         ln -s ${gmp}/lib/libgmp.dylib $out/frameworks/GMP.framework/Versions/A/GMP
         # !!! fix this
-        ensureDir $out/frameworks/GNUeditline.framework/Versions/A
+        mkdir -p $out/frameworks/GNUeditline.framework/Versions/A
         ln -s ${libedit}/lib/libeditline.dylib $out/frameworks/GNUeditline.framework/GNUeditline
         ln -s ${libedit}/lib/libeditline.dylib $out/frameworks/GNUeditline.framework/Versions/A/GNUeditline
 
diff --git a/pkgs/development/compilers/ghc/6.12.1-binary.nix b/pkgs/development/compilers/ghc/6.12.1-binary.nix
index 6394780eb68ca..a84b75d705b1b 100644
--- a/pkgs/development/compilers/ghc/6.12.1-binary.nix
+++ b/pkgs/development/compilers/ghc/6.12.1-binary.nix
@@ -75,7 +75,7 @@ stdenv.mkDerivation rec {
   postInstall =
     (if stdenv.isDarwin then
       ''
-        ensureDir $out/frameworks/GMP.framework/Versions/A
+        mkdir -p $out/frameworks/GMP.framework/Versions/A
         ln -s ${gmp}/lib/libgmp.dylib $out/frameworks/GMP.framework/GMP
         ln -s ${gmp}/lib/libgmp.dylib $out/frameworks/GMP.framework/Versions/A/GMP
         # !!! fix this
diff --git a/pkgs/development/compilers/ghc/6.4.2-binary.nix b/pkgs/development/compilers/ghc/6.4.2-binary.nix
index 63cc08db34b12..2ed6f2be4fe46 100644
--- a/pkgs/development/compilers/ghc/6.4.2-binary.nix
+++ b/pkgs/development/compilers/ghc/6.4.2-binary.nix
@@ -49,10 +49,10 @@ stdenv.mkDerivation {
   # that the executables work with no special setup.
   postInstall = if stdenv.isDarwin then ''
 
-    ensureDir $out/frameworks/GMP.framework/Versions/A
+    mkdir -p $out/frameworks/GMP.framework/Versions/A
     ln -s ${gmp}/lib/libgmp.dylib $out/frameworks/GMP.framework/GMP
     ln -s ${gmp}/lib/libgmp.dylib $out/frameworks/GMP.framework/Versions/A/GMP
-    ensureDir $out/frameworks/GNUreadline.framework/Versions/A
+    mkdir -p $out/frameworks/GNUreadline.framework/Versions/A
     ln -s ${readline}/lib/libreadline.dylib $out/frameworks/GNUreadline.framework/GNUreadline
     ln -s ${readline}/lib/libreadline.dylib $out/frameworks/GNUreadline.framework/Versions/A/GNUreadline
 
diff --git a/pkgs/development/compilers/ghc/6.6.1.nix b/pkgs/development/compilers/ghc/6.6.1.nix
index c54c32bfab0cc..994ebc286c30e 100644
--- a/pkgs/development/compilers/ghc/6.6.1.nix
+++ b/pkgs/development/compilers/ghc/6.6.1.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation (rec {
   };
 
   postInstall = ''
-    ensureDir "$out/nix-support"
+    mkdir -p "$out/nix-support"
     echo "# Path to the GHC compiler directory in the store" > $out/nix-support/setup-hook
     echo "ghc=$out" >> $out/nix-support/setup-hook
     echo ""         >> $out/nix-support/setup-hook
diff --git a/pkgs/development/compilers/ghc/with-packages.nix b/pkgs/development/compilers/ghc/with-packages.nix
index 19ce4eabf423e..63427ea82782a 100644
--- a/pkgs/development/compilers/ghc/with-packages.nix
+++ b/pkgs/development/compilers/ghc/with-packages.nix
@@ -15,9 +15,9 @@ stdenv.mkDerivation rec {
     linkedTopDir="$out/lib"
     linkedPkgDir="$linkedTopDir/package.conf.d"
 
-    ensureDir $out/bin
-    ensureDir $linkedTopDir
-    ensureDir $linkedPkgDir
+    mkdir -p $out/bin
+    mkdir -p $linkedTopDir
+    mkdir -p $linkedPkgDir
 
     echo "Linking GHC core libraries:"
 
diff --git a/pkgs/development/compilers/ghc/wrapper.nix b/pkgs/development/compilers/ghc/wrapper.nix
index 60342a14a61fc..b04cd18fb46cb 100644
--- a/pkgs/development/compilers/ghc/wrapper.nix
+++ b/pkgs/development/compilers/ghc/wrapper.nix
@@ -8,7 +8,7 @@ stdenv.mkDerivation {
 
   unpackPhase = "true";
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp $GHCGetPackages $out/bin/ghc-get-packages.sh
     chmod 755 $out/bin/ghc-get-packages.sh
     for prg in ghc ghci ghc-${ghc.version} ghci-${ghc.version}; do
@@ -41,7 +41,7 @@ stdenv.mkDerivation {
     done
     EOF
     chmod +x $out/bin/ghc-packages
-    ensureDir $out/nix-support
+    mkdir -p $out/nix-support
     ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages
   '';
 
diff --git a/pkgs/development/compilers/gnatboot/default.nix b/pkgs/development/compilers/gnatboot/default.nix
index 954fb6bf594fd..79208743ae42a 100644
--- a/pkgs/development/compilers/gnatboot/default.nix
+++ b/pkgs/development/compilers/gnatboot/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation {
   dontStrip=1;
 
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp -R * $out
     set +e
     for a in $out/bin/* ; do
diff --git a/pkgs/development/compilers/go/default.nix b/pkgs/development/compilers/go/default.nix
index 3f2c327482215..143c091a1dc07 100644
--- a/pkgs/development/compilers/go/default.nix
+++ b/pkgs/development/compilers/go/default.nix
@@ -47,7 +47,7 @@ stdenv.mkDerivation {
           else throw "Unsupported system";
 
   installPhase = ''
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     export GOROOT="$(pwd)/"
     export GOBIN="$out/bin"
     export PATH="$GOBIN:$PATH"
@@ -57,7 +57,7 @@ stdenv.mkDerivation {
 
     # Handle Libraries and make them availabale under /share/go.
     export GOLIB="pkg/"$GOOS"_"$GOARCH
-    ensureDir "$out/lib/go/$GOLIB"
+    mkdir -p "$out/lib/go/$GOLIB"
     cp -r ./$GOLIB $out/lib/go/pkg/
 
     # this line set $AS $CC $GC $LD
@@ -75,7 +75,7 @@ stdenv.mkDerivation {
       --set "GOARCH" "$GOARCH"
 
     # Copy the emacs configuration for Go files.
-    ensureDir "$out/share/emacs/site-lisp"
+    mkdir -p "$out/share/emacs/site-lisp"
     cp ./misc/emacs/* $out/share/emacs/site-lisp/ # */
   '';
 
diff --git a/pkgs/development/compilers/gwt/builder.sh b/pkgs/development/compilers/gwt/builder.sh
index d260bd559dc77..b14a0432ea58f 100644
--- a/pkgs/development/compilers/gwt/builder.sh
+++ b/pkgs/development/compilers/gwt/builder.sh
@@ -1,14 +1,14 @@
 source $stdenv/setup
 
 tar xfvj $src
-ensureDir $out
+mkdir -p $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
+mkdir -p $out/bin
 
 cat > $out/bin/gwt-compile <<EOF
 #!/bin/sh
diff --git a/pkgs/development/compilers/haxe/default.nix b/pkgs/development/compilers/haxe/default.nix
index 33260cd5469ae..8018b478e809d 100644
--- a/pkgs/development/compilers/haxe/default.nix
+++ b/pkgs/development/compilers/haxe/default.nix
@@ -79,7 +79,7 @@ let
 
       # probably rpath should be set properly
       installPhase = ''
-        ensureDir $out/lib/haxe
+        mkdir -p $out/lib/haxe
         cp -r bin $out/bin
         wrapProgram "$out/bin/haxe" \
           --set "LD_LIBRARY_PATH" $zlib/lib \
@@ -107,7 +107,7 @@ let
         buildPhase = ''
           cd std/tools/${name};
           haxe *.hxml
-          ensureDir $out/bin
+          mkdir -p $out/bin
           mv ${name} $out/bin/
         '';
 
diff --git a/pkgs/development/compilers/jdk/builder.sh b/pkgs/development/compilers/jdk/builder.sh
index 7f402dab1588c..ccfe2838d1b65 100644
--- a/pkgs/development/compilers/jdk/builder.sh
+++ b/pkgs/development/compilers/jdk/builder.sh
@@ -3,7 +3,7 @@ source $stdenv/setup
 
 unzip $src || true
 
-ensureDir $out
+mkdir -p $out
 mv $dirname/* $out/
 
 # Remove crap in the root directory.
diff --git a/pkgs/development/compilers/jdk/dlj-bundle-builder.sh b/pkgs/development/compilers/jdk/dlj-bundle-builder.sh
index ee58ce9127ca2..f0d36347ab0b4 100644
--- a/pkgs/development/compilers/jdk/dlj-bundle-builder.sh
+++ b/pkgs/development/compilers/jdk/dlj-bundle-builder.sh
@@ -10,7 +10,7 @@ patchelf --interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" --set-rpath
 echo "constructing JDK and JRE installations"
 if test -z "$installjdk"; then
   sh ${construct} . tmp-linux-jdk tmp-linux-jre
-  ensureDir $out
+  mkdir -p $out
   cp -R tmp-linux-jre/* $out
 else
   sh ${construct} . $out tmp-linux-jre
diff --git a/pkgs/development/compilers/jdk/ibm-builder.sh b/pkgs/development/compilers/jdk/ibm-builder.sh
index b78dac6163be1..2ff3a71322a62 100644
--- a/pkgs/development/compilers/jdk/ibm-builder.sh
+++ b/pkgs/development/compilers/jdk/ibm-builder.sh
@@ -17,7 +17,7 @@ fi
 
 tar zxf $pathname || true
 
-ensureDir $out
+mkdir -p $out
 mv $dirname/* $out/
 
 # Remove crap in the root directory.
diff --git a/pkgs/development/compilers/llvm/dragonegg.nix b/pkgs/development/compilers/llvm/dragonegg.nix
index 70098a19a066e..fbaa80c115dfb 100644
--- a/pkgs/development/compilers/llvm/dragonegg.nix
+++ b/pkgs/development/compilers/llvm/dragonegg.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ llvm gmp mpfr mpc ];
 
   installPhase = ''
-    ensureDir $out/lib $out/share/doc/${name}
+    mkdir -p $out/lib $out/share/doc/${name}
     cp -d dragonegg.so $out/lib
     cp README COPYING $out/share/doc/${name}
   '';
diff --git a/pkgs/development/compilers/neko/default.nix b/pkgs/development/compilers/neko/default.nix
index 060d59476cf2d..28a98fe1e258b 100644
--- a/pkgs/development/compilers/neko/default.nix
+++ b/pkgs/development/compilers/neko/default.nix
@@ -31,7 +31,7 @@ composableDerivation.composableDerivation {} ( fixed : {
       src/tools/install.neko
     sed -i "s@/usr/local@$out@" Makefile vm/load.c
     # make sure that nekotools boot finds the neko executable and not our wrapper:
-    ensureDir $out/{bin,lib}
+    mkdir -p $out/{bin,lib}
 
     sed -i "s@\"neko\"@\".neko-wrapped\"@" src/tools/nekoboot.neko
     ln -s ./neko bin/.neko-wrapped
diff --git a/pkgs/development/compilers/nvidia-cg-toolkit/default.nix b/pkgs/development/compilers/nvidia-cg-toolkit/default.nix
index d6b7d70100bf4..23b5883c0098d 100644
--- a/pkgs/development/compilers/nvidia-cg-toolkit/default.nix
+++ b/pkgs/development/compilers/nvidia-cg-toolkit/default.nix
@@ -28,19 +28,19 @@ stdenv.mkDerivation rec {
         patchelf --set-interpreter ${stdenv.glibc}/lib/ld-linux*.so.? "bin/$b"
     done
     # FIXME: cgfxcat and cginfo need more patchelf
-    ensureDir "$out/bin/"
+    mkdir -p "$out/bin/"
     cp -v bin/* "$out/bin/"
-    ensureDir "$out/include/"
+    mkdir -p "$out/include/"
     cp -v -r include/Cg/ "$out/include/"
-    ensureDir "$out/lib/"
+    mkdir -p "$out/lib/"
     [ "$system" == "x86_64-linux" ] && cp -v lib64/* "$out/lib/"
     [ "$system" == "i686-linux" ] && cp -v lib/* "$out/lib/"
     for mandir in man1 man3 manCg manCgFX
     do
-        ensureDir "$out/share/man/$mandir/"
+        mkdir -p "$out/share/man/$mandir/"
         cp -v share/man/$mandir/* "$out/share/man/$mandir/"
     done
-    ensureDir "$out/share/doc/$name/"
+    mkdir -p "$out/share/doc/$name/"
     cp -v -r local/Cg/* "$out/share/doc/$name/"
   '';
   
diff --git a/pkgs/development/compilers/ocaml/3.10.0.nix b/pkgs/development/compilers/ocaml/3.10.0.nix
index fdd95db544062..281aa1a9de6f1 100644
--- a/pkgs/development/compilers/ocaml/3.10.0.nix
+++ b/pkgs/development/compilers/ocaml/3.10.0.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation (rec {
     sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang
   '';
   postBuild = ''
-    ensureDir $out/include
+    mkdir -p $out/include
     ln -sv $out/lib/ocaml/caml $out/include/caml
   '';
 
diff --git a/pkgs/development/compilers/ocaml/3.11.1.nix b/pkgs/development/compilers/ocaml/3.11.1.nix
deleted file mode 100644
index 0add40dcd68fe..0000000000000
--- a/pkgs/development/compilers/ocaml/3.11.1.nix
+++ /dev/null
@@ -1,68 +0,0 @@
-{ stdenv, fetchurl, ncurses, x11 }:
-
-let
-   useX11 = stdenv.isi686 || stdenv.isx86_64;
-   useNativeCompilers = stdenv.isi686 || stdenv.isx86_64 || stdenv.isMips;
-   inherit (stdenv.lib) optionals optionalString;
-in
-
-stdenv.mkDerivation rec {
-  
-  name = "ocaml-3.11.1";
-  
-  src = fetchurl {
-    url = "http://caml.inria.fr/pub/distrib/ocaml-3.11/${name}.tar.bz2";
-    sha256 = "8c36a28106d4b683a15c547dfe4cb757a53fa9247579d1cc25bd06a22cc62e50";
-  };
-
-  # Needed to avoid a SIGBUS on the final executable on mips
-  NIX_CFLAGS_COMPILE = if stdenv.isMips then "-fPIC" else "";
-
-  patches = optionals stdenv.isDarwin [ ./gnused-on-osx-fix.patch ];
-
-  prefixKey = "-prefix ";
-  configureFlags = ["-no-tk"] ++ optionals useX11 [ "-x11lib" x11 ];
-  buildFlags = "world" + optionalString useNativeCompilers " bootstrap world.opt";
-  buildInputs = [ncurses] ++ optionals useX11 [ x11 ];
-  installTargets = "install" + optionalString useNativeCompilers " installopt";
-  prePatch = ''
-    CAT=$(type -tp cat)
-    sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang
-    patch -p0 < ${./mips64.patch}
-  '';
-  postBuild = ''
-    ensureDir $out/include
-    ln -sv $out/lib/ocaml/caml $out/include/caml
-  '';
-
-  meta = {
-    homepage = http://caml.inria.fr/ocaml;
-    licenses = [ "QPL" /* compiler */ "LGPLv2" /* library */ ];
-    description = "Objective Caml, the most popular variant of the Caml language";
-
-    longDescription =
-      '' Objective Caml is the most popular variant of the Caml language.
-         From a language standpoint, it extends the core Caml language with a
-         fully-fledged object-oriented layer, as well as a powerful module
-         system, all connected by a sound, polymorphic type system featuring
-         type inference.
-
-         The Objective Caml system is an industrial-strength implementation
-         of this language, featuring a high-performance native-code compiler
-         (ocamlopt) for 9 processor architectures (IA32, PowerPC, AMD64,
-         Alpha, Sparc, Mips, IA64, HPPA, StrongArm), as well as a bytecode
-         compiler (ocamlc) and an interactive read-eval-print loop (ocaml)
-         for quick development and portability.  The Objective Caml
-         distribution includes a comprehensive standard library, a replay
-         debugger (ocamldebug), lexer (ocamllex) and parser (ocamlyacc)
-         generators, a pre-processor pretty-printer (camlp4) and a
-         documentation generator (ocamldoc).
-       '';
-
-    platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
-    maintainers = [
-      stdenv.lib.maintainers.z77z
-    ];
-  };
-
-}
diff --git a/pkgs/development/compilers/ocaml/3.12.1.nix b/pkgs/development/compilers/ocaml/3.12.1.nix
index eaf1f55e281bc..155523ebe5600 100644
--- a/pkgs/development/compilers/ocaml/3.12.1.nix
+++ b/pkgs/development/compilers/ocaml/3.12.1.nix
@@ -25,7 +25,7 @@ stdenv.mkDerivation rec {
     sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang
   '';
   postBuild = ''
-    ensureDir $out/include
+    mkdir -p $out/include
     ln -sv $out/lib/ocaml/caml $out/include/caml
   '';
 
diff --git a/pkgs/development/compilers/ocaml/ber-metaocaml-003.nix b/pkgs/development/compilers/ocaml/ber-metaocaml-003.nix
index 5b3052b544ab4..df3e9e73af59d 100644
--- a/pkgs/development/compilers/ocaml/ber-metaocaml-003.nix
+++ b/pkgs/development/compilers/ocaml/ber-metaocaml-003.nix
@@ -43,7 +43,7 @@ stdenv.mkDerivation rec {
     cd ..
   '';
   postBuild = ''
-    ensureDir $out/include
+    mkdir -p $out/include
     ln -sv $out/lib/ocaml/caml $out/include/caml
   '';
   postInstall = ''
diff --git a/pkgs/development/compilers/ocaml/metaocaml-3.09.nix b/pkgs/development/compilers/ocaml/metaocaml-3.09.nix
index b115a8fedcfb4..4313dcd7537e5 100644
--- a/pkgs/development/compilers/ocaml/metaocaml-3.09.nix
+++ b/pkgs/development/compilers/ocaml/metaocaml-3.09.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation (rec {
     sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang
   '';
   postBuild = ''
-    ensureDir $out/include
+    mkdir -p $out/include
     ln -sv $out/lib/ocaml/caml $out/include/caml
   '';
 
diff --git a/pkgs/development/compilers/opa/default.nix b/pkgs/development/compilers/opa/default.nix
index 6df16e44c3d44..2a54b90dda982 100644
--- a/pkgs/development/compilers/opa/default.nix
+++ b/pkgs/development/compilers/opa/default.nix
@@ -43,7 +43,7 @@ stdenv.mkDerivation rec {
     done
 
     # Install emacs mode.
-    ensureDir $out/share/emacs/site-lisp/opa
+    mkdir -p $out/share/emacs/site-lisp/opa
     install -m 0644 -v ./utils/emacs/{opa-mode.el,site-start.el} $out/share/emacs/site-lisp/opa
   '';
 
diff --git a/pkgs/development/compilers/openjdk-darwin/default.nix b/pkgs/development/compilers/openjdk-darwin/default.nix
index 88099a90949cc..cbd41033bfca6 100644
--- a/pkgs/development/compilers/openjdk-darwin/default.nix
+++ b/pkgs/development/compilers/openjdk-darwin/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation {
   };
 
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp -vR * $out/
   '';
 
diff --git a/pkgs/development/compilers/openjdk/default.nix b/pkgs/development/compilers/openjdk/default.nix
index 0ea08071aaa0c..cf85c1706a8a6 100644
--- a/pkgs/development/compilers/openjdk/default.nix
+++ b/pkgs/development/compilers/openjdk/default.nix
@@ -70,7 +70,7 @@ stdenv.mkDerivation rec {
   ];
 
   postUnpack = ''
-    ensureDir drops
+    mkdir -p drops
     cp ${jaxp_src} drops/${jaxp_src_name}
     cp ${jaxws_src} drops/${jaxws_src_name}
     cp ${jaf_src} drops/${jaf_src_name}
@@ -114,14 +114,14 @@ stdenv.mkDerivation rec {
   '';
 
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp -av build/*/j2${if jreOnly then "re" else "sdk"}-image/* $out
   '';
 #  '' + (if jreOnly then "" else ''
 #    if [ -z $jre ]; then
 #      exit 0
 #    fi
-#    ensureDir $jre
+#    mkdir -p $jre
 #    cp -av build/*/j2re-image/* $jre
 #  '');
 
diff --git a/pkgs/development/compilers/pakcs/default.nix b/pkgs/development/compilers/pakcs/default.nix
index 3c4723a88fb1a..6bec1925f0b89 100644
--- a/pkgs/development/compilers/pakcs/default.nix
+++ b/pkgs/development/compilers/pakcs/default.nix
@@ -41,7 +41,7 @@ stdenv.mkDerivation {
     # The Prolog sources must be built in their final directory.
     (cd $out/curry2prolog/ ; make)
 
-    ensureDir $out/share/emacs/site-lisp/curry-pakcs
+    mkdir -p $out/share/emacs/site-lisp/curry-pakcs
     for e in "$out/tools/emacs/"*.el ; do
       ln -s $out/tools/emacs/$e $out/share/emacs/site-lisp/curry-pakcs/;
     done
diff --git a/pkgs/development/compilers/qi/default.nix b/pkgs/development/compilers/qi/default.nix
index f1f34f87d6920..ae01725585493 100644
--- a/pkgs/development/compilers/qi/default.nix
+++ b/pkgs/development/compilers/qi/default.nix
@@ -16,8 +16,8 @@ let
 	allBuild = fullDepEntry ("
 		(sleep 0.1; echo ) | clisp install.txt;
 		(sleep 0.1; echo -e '1\n(quit)\n' ) | sh Qi-Linux-CLisp 
-		ensureDir \$out/share
-		ensureDir \$out/bin
+		mkdir -p \$out/share
+		mkdir -p \$out/bin
 		cp -r . \$out/share/Qi-9.1
 		echo -e '#! ${shell}
 		arg1=\${1:-'\$out'/share/Qi-9.1/startup.txt}
diff --git a/pkgs/development/compilers/scala/default.nix b/pkgs/development/compilers/scala/default.nix
index 9ce9eaebc1237..f50c15a3a0b81 100644
--- a/pkgs/development/compilers/scala/default.nix
+++ b/pkgs/development/compilers/scala/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   };
 
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     rm bin/*.bat
     mv * $out
   '';
diff --git a/pkgs/development/compilers/stalin/default.nix b/pkgs/development/compilers/stalin/default.nix
index acae45626a09a..a45217a331adf 100644
--- a/pkgs/development/compilers/stalin/default.nix
+++ b/pkgs/development/compilers/stalin/default.nix
@@ -13,19 +13,19 @@ stdenv.mkDerivation rec {
   buildPhase = '' ./build '';
 
   installPhase = ''
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     cp stalin "$out/bin"
 
-    ensureDir "$out/man/man1"
+    mkdir -p "$out/man/man1"
     cp stalin.1 "$out/man/man1"
 
-    ensureDir "$out/share/emacs/site-lisp"
+    mkdir -p "$out/share/emacs/site-lisp"
     cp stalin.el "$out/share/emacs/site-lisp"
 
-    ensureDir "$out/doc/${name}"
+    mkdir -p "$out/doc/${name}"
     cp README "$out/doc/${name}"
 
-    ensureDir "$out/share/${name}/include"
+    mkdir -p "$out/share/${name}/include"
     cp "include/"* "$out/share/${name}/include"
 
     substituteInPlace "$out/bin/stalin" \
diff --git a/pkgs/development/compilers/tinycc/default.nix b/pkgs/development/compilers/tinycc/default.nix
index 7ece90e8601f6..058d84a12de8d 100644
--- a/pkgs/development/compilers/tinycc/default.nix
+++ b/pkgs/development/compilers/tinycc/default.nix
@@ -50,7 +50,7 @@ let version = "0.9.25"; in
     postInstall = ''
       makeinfo --force tcc-doc.texi || true
 
-      ensureDir "$out/share/info"
+      mkdir -p "$out/share/info"
       mv tcc-doc.info* "$out/share/info"
 
       echo 'int main () { printf ("it works!\n"); exit(0); }' | \
diff --git a/pkgs/development/compilers/visual-c++/builder.sh b/pkgs/development/compilers/visual-c++/builder.sh
index 137db50fb6298..5469f3760ca04 100644
--- a/pkgs/development/compilers/visual-c++/builder.sh
+++ b/pkgs/development/compilers/visual-c++/builder.sh
@@ -1,6 +1,6 @@
 source $stdenv/setup
 
-ensureDir $out
+mkdir -p $out
 
 cabextract $src
 
@@ -12,7 +12,7 @@ rm ../vc* # reduce temporary disk usage a bit
 while read target; do
     read source
     echo "$source -> $target"
-    ensureDir $out/$(dirname $target)
+    mkdir -p $out/$(dirname $target)
     cp -p "$source" $out/"$target"
 done < $filemap
 
diff --git a/pkgs/development/compilers/visual-c++/test/builder.sh b/pkgs/development/compilers/visual-c++/test/builder.sh
index 8adb7e466ee03..c11ffc574a86e 100644
--- a/pkgs/development/compilers/visual-c++/test/builder.sh
+++ b/pkgs/development/compilers/visual-c++/test/builder.sh
@@ -2,5 +2,5 @@ source $stdenv/setup
 source $visualcpp/setup
 source $windowssdk/setup
 
-ensureDir $out/bin
+mkdir -p $out/bin
 cl "$(cygpath -w $src)" /Fe"$(cygpath -w $out/bin/hello.exe)" user32.lib
diff --git a/pkgs/development/compilers/vs90wrapper/default.nix b/pkgs/development/compilers/vs90wrapper/default.nix
index 47d7c2654a181..341833fdf4724 100644
--- a/pkgs/development/compilers/vs90wrapper/default.nix
+++ b/pkgs/development/compilers/vs90wrapper/default.nix
@@ -3,7 +3,7 @@
 stdenv.mkDerivation {
   name = "visual-studio-9.0";
   buildCommand = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     ln -s "/cygdrive/c/Program Files/Microsoft Visual Studio 9.0/VC/vcpackages/vcbuild.exe" $out/bin/vcbuild.exe
   '';
 }
diff --git a/pkgs/development/interpreters/acl2/default.nix b/pkgs/development/interpreters/acl2/default.nix
index 6cad083ac8539..6d074ac9f279e 100644
--- a/pkgs/development/interpreters/acl2/default.nix
+++ b/pkgs/development/interpreters/acl2/default.nix
@@ -28,7 +28,7 @@ rec {
     cd $out/share/${installSuffix}
     make LISP=${a.sbcl}/bin/sbcl
     make LISP=${a.sbcl}/bin/sbcl regression
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     cp saved_acl2 "$out/bin/acl2"
   '') ["doDeploy" "addInputs" "defEnsureDir"];
       
diff --git a/pkgs/development/interpreters/angelscript/default.nix b/pkgs/development/interpreters/angelscript/default.nix
index fa53071d306af..a092172c8ca78 100644
--- a/pkgs/development/interpreters/angelscript/default.nix
+++ b/pkgs/development/interpreters/angelscript/default.nix
@@ -32,7 +32,7 @@ rec {
   prepareBuild = a.fullDepEntry ''
     cd angelscript/projects/gnuc
     sed -i makefile -e "s@LOCAL = .*@LOCAL = $out@"
-    ensureDir "$out/lib" "$out/bin" "$out/share" "$out/include"
+    mkdir -p "$out/lib" "$out/bin" "$out/share" "$out/include"
     export SHARED=1 
     export VERSION="${version}"
   '' ["minInit" "addInputs" "doUnpack" "defEnsureDir"];
@@ -42,7 +42,7 @@ rec {
   '' ["minInit"];
 
   installDocs = a.fullDepEntry ''
-    ensureDir "$out/share/angelscript"
+    mkdir -p "$out/share/angelscript"
     cp -r ../../../docs  "$out/share/angelscript"
   '' ["defEnsureDir" "prepareBuild"];
       
diff --git a/pkgs/development/interpreters/clojure/binary.nix b/pkgs/development/interpreters/clojure/binary.nix
index 7b53ea9022d68..8cf350e7e972a 100644
--- a/pkgs/development/interpreters/clojure/binary.nix
+++ b/pkgs/development/interpreters/clojure/binary.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
   phases = "unpackPhase installPhase";
 
   installPhase = "
-    ensureDir $out/lib/java
+    mkdir -p $out/lib/java
     install -t $out/lib/java clojure.jar
   ";
 
diff --git a/pkgs/development/interpreters/clojure/clooj.nix b/pkgs/development/interpreters/clojure/clooj.nix
index 23bf9ad03b783..2ad6f751f2bdd 100644
--- a/pkgs/development/interpreters/clojure/clooj.nix
+++ b/pkgs/development/interpreters/clojure/clooj.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
   phases = "installPhase";
 
   installPhase = ''
-    ensureDir $out/lib/java
+    mkdir -p $out/lib/java
     ln -s ${jar} $out/lib/java/clooj.jar
   '';
 
diff --git a/pkgs/development/interpreters/clojure/default.nix b/pkgs/development/interpreters/clojure/default.nix
index f829beda7bab5..f68b89f039803 100644
--- a/pkgs/development/interpreters/clojure/default.nix
+++ b/pkgs/development/interpreters/clojure/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
   buildPhase = "ant";
 
   installPhase = "
-    ensureDir $out/lib/java
+    mkdir -p $out/lib/java
     install -t $out/lib/java clojure.jar
   ";
 
diff --git a/pkgs/development/interpreters/groovy/default.nix b/pkgs/development/interpreters/groovy/default.nix
index cc994aeea34b5..593cc61dc4107 100644
--- a/pkgs/development/interpreters/groovy/default.nix
+++ b/pkgs/development/interpreters/groovy/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   };
 
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     rm bin/*.bat
     mv * $out
   '';
diff --git a/pkgs/development/interpreters/guile/1.8.nix b/pkgs/development/interpreters/guile/1.8.nix
index 7cb5d3e536428..bf1efbbb1a95e 100644
--- a/pkgs/development/interpreters/guile/1.8.nix
+++ b/pkgs/development/interpreters/guile/1.8.nix
@@ -11,6 +11,9 @@ stdenv.mkDerivation rec {
 
   patches = [ ./cpp-4.5.patch ];
 
+  # GCC 4.6 raises a number of set-but-unused warnings.
+  configureFlags = [ "--disable-error-on-warning" ];
+
   buildNativeInputs = [ makeWrapper gawk ];
   propagatedBuildInputs = [ readline gmp libtool ];
   selfBuildNativeInput = true;
diff --git a/pkgs/development/interpreters/guile/default.nix b/pkgs/development/interpreters/guile/default.nix
index a4cf2605d4912..19b9d26c7deb2 100644
--- a/pkgs/development/interpreters/guile/default.nix
+++ b/pkgs/development/interpreters/guile/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, xz, libtool, readline, gmp, pkgconfig, boehmgc, libunistring
+{ fetchurl, stdenv, libtool, readline, gmp, pkgconfig, boehmgc, libunistring
 , libffi, gawk, makeWrapper, coverageAnalysis ? null }:
 
 # Do either a coverage analysis build or a standard build.
@@ -14,7 +14,7 @@
     sha256 = "1lycm10x316jzlv1nyag7x9gisn4d3dz8jcmbi6lbdn0z6a9skc2";
   };
 
-  buildNativeInputs = [ xz makeWrapper gawk pkgconfig ];
+  buildNativeInputs = [ makeWrapper gawk pkgconfig ];
   buildInputs = [ readline libtool libunistring libffi ];
   propagatedBuildInputs = [ gmp boehmgc ]
 
diff --git a/pkgs/development/interpreters/j/default.nix b/pkgs/development/interpreters/j/default.nix
index 3be0e8aa1174d..d4a1ab85b1397 100644
--- a/pkgs/development/interpreters/j/default.nix
+++ b/pkgs/development/interpreters/j/default.nix
@@ -53,11 +53,11 @@ rec {
   '' ["doUnpack" "addInputs" "minInit"];
 
   doDeploy = a.fullDepEntry ''
-    ensureDir "$out"
+    mkdir -p "$out"
     cp -r j/bin "$out/bin"
     rm "$out/bin/profilex_template.ijs"
     
-    ensureDir "$out/share/j"
+    mkdir -p "$out/share/j"
 
     cp -r docs j/addons j/system "$out/share/j"
   '' ["doUnpack" "doBuildJ" "minInit" "defEnsureDir"];
diff --git a/pkgs/development/interpreters/jruby/default.nix b/pkgs/development/interpreters/jruby/default.nix
index da2e0b65f0088..b171492d78cbf 100644
--- a/pkgs/development/interpreters/jruby/default.nix
+++ b/pkgs/development/interpreters/jruby/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
   buildInputs = [ makeWrapper ];
 
   installPhase = ''
-     ensureDir $out
+     mkdir -pv $out
      mv * $out
      rm $out/bin/*.{bat,dll,exe,sh}
      mv $out/README $out/docs
diff --git a/pkgs/development/interpreters/kona/default.nix b/pkgs/development/interpreters/kona/default.nix
index 2e433e11033f1..7e4f1e408b44a 100644
--- a/pkgs/development/interpreters/kona/default.nix
+++ b/pkgs/development/interpreters/kona/default.nix
@@ -29,7 +29,7 @@ rec {
   makeFlags = ["PREFIX=\$out"];
 
   prepareOut = a.fullDepEntry ''
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
   '' ["minInit" "defEnsureDir"];
       
   meta = {
diff --git a/pkgs/development/interpreters/lua-5/default.nix b/pkgs/development/interpreters/lua-5/default.nix
index 06703e12210d9..c11a9d10d7b39 100644
--- a/pkgs/development/interpreters/lua-5/default.nix
+++ b/pkgs/development/interpreters/lua-5/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation {
   postInstall = ''
     sed -i -e "s@/usr/local@$out@" etc/lua.pc
     sed -i -e "s@-llua -lm@-llua -lm -ldl@" etc/lua.pc
-    ensureDir "$out/lib/pkgconfig"
+    mkdir -p "$out/lib/pkgconfig"
     install -m 644 etc/lua.pc $out/lib/pkgconfig/lua.pc
   '';
   buildInputs = [ ncurses readline ];
diff --git a/pkgs/development/interpreters/maude/default.nix b/pkgs/development/interpreters/maude/default.nix
index f5d4fd0901594..de1a14b522b24 100644
--- a/pkgs/development/interpreters/maude/default.nix
+++ b/pkgs/development/interpreters/maude/default.nix
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
   postInstall =
   ''
     for n in "$out/bin/"*; do wrapProgram "$n" --suffix MAUDE_LIB ':' "$out/share/maude"; done
-    ensureDir $out/share/maude
+    mkdir -p $out/share/maude
     cp ${fullMaude} $out/share/maude/full-maude.maude
   '';
 
diff --git a/pkgs/development/interpreters/perl-5.10/default.nix b/pkgs/development/interpreters/perl/5.10/default.nix
index 76928d1044814..76928d1044814 100644
--- a/pkgs/development/interpreters/perl-5.10/default.nix
+++ b/pkgs/development/interpreters/perl/5.10/default.nix
diff --git a/pkgs/development/interpreters/perl-5.10/no-sys-dirs.patch b/pkgs/development/interpreters/perl/5.10/no-sys-dirs.patch
index 29edf68bb6477..29edf68bb6477 100644
--- a/pkgs/development/interpreters/perl-5.10/no-sys-dirs.patch
+++ b/pkgs/development/interpreters/perl/5.10/no-sys-dirs.patch
diff --git a/pkgs/development/interpreters/perl-5.10/setup-hook.sh b/pkgs/development/interpreters/perl/5.10/setup-hook.sh
index 6a144a7f7804d..6a144a7f7804d 100644
--- a/pkgs/development/interpreters/perl-5.10/setup-hook.sh
+++ b/pkgs/development/interpreters/perl/5.10/setup-hook.sh
diff --git a/pkgs/development/interpreters/perl/5.14/default.nix b/pkgs/development/interpreters/perl/5.14/default.nix
new file mode 100644
index 0000000000000..75b15da3efd0b
--- /dev/null
+++ b/pkgs/development/interpreters/perl/5.14/default.nix
@@ -0,0 +1,61 @@
+{ stdenv, fetchurl }:
+
+let 
+  
+  libc = if stdenv ? gcc && stdenv.gcc.libc != null then stdenv.gcc.libc else "/usr";
+
+in
+
+stdenv.mkDerivation rec {
+  name = "perl-5.14.2";
+
+  src = fetchurl {
+    url = "mirror://cpan/src/${name}.tar.gz";
+    sha256 = "1ls8cpbgnlaxfydyyqgr7pxj1hkxh9pzcdgr3dv42zdxffakb234";
+  };
+
+  patches = 
+    [ # Do not look in /usr etc. for dependencies.
+      ./no-sys-dirs.patch
+    ] 
+    ++ stdenv.lib.optional stdenv.isDarwin ./no-libutil.patch;
+
+  # Build a thread-safe Perl with a dynamic libperls.o.  We need the
+  # "installstyle" option to ensure that modules are put under
+  # $out/lib/perl5 - this is the general default, but because $out
+  # contains the string "perl", Configure would select $out/lib.
+  # Miniperl needs -lm. perl needs -lrt.
+  configureFlags = 
+    [ "-de"
+      "-Dcc=gcc"
+      "-Uinstallusrbinperl"
+      "-Dinstallstyle=lib/perl5"
+      "-Duseshrplib"
+      "-Dlocincpth=${libc}/include"
+      "-Dloclibpth=${libc}/lib"
+    ] 
+    ++ stdenv.lib.optional (stdenv ? glibc) "-Dusethreads";
+
+  configureScript = "${stdenv.shell} ./Configure";
+
+  dontAddPrefix = true;
+
+  enableParallelBuilding = true;
+
+  preConfigure =
+    ''
+      configureFlags="$configureFlags -Dprefix=$out -Dman1dir=$out/share/man/man1 -Dman3dir=$out/share/man/man3"
+
+      ${stdenv.lib.optionalString (stdenv.system == "armv5tel-linux") ''
+        configureFlagsArray=(-Dldflags="-lm -lrt")
+      ''}
+    '';
+
+  preBuild = stdenv.lib.optionalString (!(stdenv ? gcc && stdenv.gcc.nativeTools))
+    ''
+      # Make Cwd work on NixOS (where we don't have a /bin/pwd).
+      substituteInPlace dist/Cwd/Cwd.pm --replace "'/bin/pwd'" "'$(type -tP pwd)'"
+    '';
+
+  setupHook = ./setup-hook.sh;
+}
diff --git a/pkgs/development/interpreters/perl/5.14/no-libutil.patch b/pkgs/development/interpreters/perl/5.14/no-libutil.patch
new file mode 100644
index 0000000000000..9b749bccf32cd
--- /dev/null
+++ b/pkgs/development/interpreters/perl/5.14/no-libutil.patch
@@ -0,0 +1,12 @@
+diff -ru -x '*~' perl-5.14.2-orig/Configure perl-5.14.2/Configure
+--- perl-5.14.2-orig/Configure	2011-09-26 11:44:34.000000000 +0200
++++ perl-5.14.2/Configure	2012-02-16 17:24:50.779839039 +0100
+@@ -1368,7 +1368,7 @@
+ : List of libraries we want.
+ : If anyone needs extra -lxxx, put those in a hint file.
+ libswanted="sfio socket bind inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun"
+-libswanted="$libswanted m crypt sec util c cposix posix ucb bsd BSD"
++libswanted="$libswanted m crypt sec c cposix posix ucb bsd BSD"
+ : We probably want to search /usr/shlib before most other libraries.
+ : This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
+ glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
diff --git a/pkgs/development/interpreters/perl/5.14/no-sys-dirs.patch b/pkgs/development/interpreters/perl/5.14/no-sys-dirs.patch
new file mode 100644
index 0000000000000..54ffb28e2065e
--- /dev/null
+++ b/pkgs/development/interpreters/perl/5.14/no-sys-dirs.patch
@@ -0,0 +1,152 @@
+diff -ru -x '*~' perl-5.14.2-orig/Configure perl-5.14.2/Configure
+--- perl-5.14.2-orig/Configure	2011-09-26 11:44:34.000000000 +0200
++++ perl-5.14.2/Configure	2012-01-20 17:05:23.089223129 +0100
+@@ -106,15 +106,7 @@
+ fi
+ 
+ : Proper PATH setting
+-paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
+-paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin"
+-paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin"
+-paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin"
+-paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb"
+-paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /opt/ansic/bin /usr/ccs/bin"
+-paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib"
+-paths="$paths /sbin /usr/sbin /usr/libexec"
+-paths="$paths /system/gnu_library/bin"
++paths=''
+ 
+ for p in $paths
+ do
+@@ -1311,8 +1303,7 @@
+ archname=''
+ : Possible local include directories to search.
+ : Set locincpth to "" in a hint file to defeat local include searches.
+-locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
+-locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
++locincpth=""
+ :
+ : no include file wanted by default
+ inclwanted=''
+@@ -1328,17 +1319,12 @@
+ archobjs=''
+ libnames=''
+ : change the next line if compiling for Xenix/286 on Xenix/386
+-xlibpth='/usr/lib/386 /lib/386'
++xlibpth=''
+ : Possible local library directories to search.
+-loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
+-loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
++loclibpth=""
+ 
+ : general looking path for locating libraries
+-glibpth="/lib /usr/lib $xlibpth"
+-glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
+-test -f /usr/shlib/libc.so && glibpth="/usr/shlib $glibpth"
+-test -f /shlib/libc.so     && glibpth="/shlib $glibpth"
+-test -d /usr/lib64         && glibpth="$glibpth /lib64 /usr/lib64 /usr/local/lib64"
++glibpth=""
+ 
+ : Private path used by Configure to find libraries.  Its value
+ : is prepended to libpth. This variable takes care of special
+@@ -1371,8 +1357,6 @@
+ libswanted="$libswanted m crypt sec util c cposix posix ucb bsd BSD"
+ : We probably want to search /usr/shlib before most other libraries.
+ : This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
+-glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
+-glibpth="/usr/shlib $glibpth"
+ : Do not use vfork unless overridden by a hint file.
+ usevfork=false
+ 
+@@ -2380,7 +2364,6 @@
+ zip
+ "
+ pth=`echo $PATH | sed -e "s/$p_/ /g"`
+-pth="$pth /lib /usr/lib"
+ for file in $loclist; do
+ 	eval xxx=\$$file
+ 	case "$xxx" in
+@@ -4785,7 +4768,7 @@
+ : Set private lib path
+ case "$plibpth" in
+ '') if ./mips; then
+-		plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
++		plibpth="$incpath/usr/lib"
+ 	fi;;
+ esac
+ case "$libpth" in
+@@ -8390,13 +8373,8 @@
+ echo " "
+ case "$sysman" in
+ '') 
+-	syspath='/usr/share/man/man1 /usr/man/man1'
+-	syspath="$syspath /usr/man/mann /usr/man/manl /usr/man/local/man1"
+-	syspath="$syspath /usr/man/u_man/man1"
+-	syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
+-	syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
+-	syspath="$syspath /usr/man/man.L /local/man/man1 /usr/local/man/man1"
+-	sysman=`./loc . /usr/man/man1 $syspath`
++	syspath=''
++	sysman=''
+ 	;;
+ esac
+ if $test -d "$sysman"; then
+@@ -19721,9 +19699,10 @@
+ case "$full_ar" in
+ '') full_ar=$ar ;;
+ esac
++full_ar=ar
+ 
+ : Store the full pathname to the sed program for use in the C program
+-full_sed=$sed
++full_sed=sed
+ 
+ : see what type gids are declared as in the kernel
+ echo " "
+diff -ru -x '*~' perl-5.14.2-orig/ext/Errno/Errno_pm.PL perl-5.14.2/ext/Errno/Errno_pm.PL
+--- perl-5.14.2-orig/ext/Errno/Errno_pm.PL	2011-09-26 11:44:34.000000000 +0200
++++ perl-5.14.2/ext/Errno/Errno_pm.PL	2012-01-20 17:02:07.938138311 +0100
+@@ -137,11 +137,7 @@
+ 	if ($dep =~ /(\S+errno\.h)/) {
+ 	     $file{$1} = 1;
+ 	}
+-    } elsif ($^O eq 'linux' &&
+-	      $Config{gccversion} ne '' && 
+-	      $Config{gccversion} !~ /intel/i
+-	      # might be using, say, Intel's icc
+-	     ) {
++    } elsif (0) {
+ 	# Some Linuxes have weird errno.hs which generate
+ 	# no #file or #line directives
+ 	my $linux_errno_h = -e '/usr/include/errno.h' ?
+diff -ru -x '*~' perl-5.14.2-orig/hints/freebsd.sh perl-5.14.2/hints/freebsd.sh
+--- perl-5.14.2-orig/hints/freebsd.sh	2011-09-19 15:18:22.000000000 +0200
++++ perl-5.14.2/hints/freebsd.sh	2012-01-20 17:10:37.267924044 +0100
+@@ -118,21 +118,21 @@
+         objformat=`/usr/bin/objformat`
+         if [ x$objformat = xaout ]; then
+             if [ -e /usr/lib/aout ]; then
+-                libpth="/usr/lib/aout /usr/local/lib /usr/lib"
+-                glibpth="/usr/lib/aout /usr/local/lib /usr/lib"
++                libpth=""
++                glibpth=""
+             fi
+             lddlflags='-Bshareable'
+         else
+-            libpth="/usr/lib /usr/local/lib"
+-            glibpth="/usr/lib /usr/local/lib"
++            libpth=""
++            glibpth=""
+             ldflags="-Wl,-E "
+             lddlflags="-shared "
+         fi
+         cccdlflags='-DPIC -fPIC'
+         ;;
+ *)
+-       libpth="/usr/lib /usr/local/lib"
+-       glibpth="/usr/lib /usr/local/lib"
++       libpth=""
++       glibpth=""
+        ldflags="-Wl,-E "
+         lddlflags="-shared "
+         cccdlflags='-DPIC -fPIC'
diff --git a/pkgs/development/interpreters/perl/5.14/setup-hook.sh b/pkgs/development/interpreters/perl/5.14/setup-hook.sh
new file mode 100644
index 0000000000000..6a144a7f7804d
--- /dev/null
+++ b/pkgs/development/interpreters/perl/5.14/setup-hook.sh
@@ -0,0 +1,5 @@
+addPerlLibPath () {
+    addToSearchPath PERL5LIB $1/lib/perl5/site_perl
+}
+
+envHooks=(${envHooks[@]} addPerlLibPath)
diff --git a/pkgs/development/interpreters/perl-5.8/default.nix b/pkgs/development/interpreters/perl/5.8/default.nix
index 4b965999910c6..c421e2768cdc8 100644
--- a/pkgs/development/interpreters/perl-5.8/default.nix
+++ b/pkgs/development/interpreters/perl/5.8/default.nix
@@ -25,7 +25,7 @@ preBuild() {
 }
 
 postInstall() {
-    ensureDir "$out/nix-support"
+    mkdir -p "$out/nix-support"
     cp $setupHook $out/nix-support/setup-hook
 }
 
diff --git a/pkgs/development/interpreters/perl-5.8/gcc-4.2.patch b/pkgs/development/interpreters/perl/5.8/gcc-4.2.patch
index 679a7abde3b62..679a7abde3b62 100644
--- a/pkgs/development/interpreters/perl-5.8/gcc-4.2.patch
+++ b/pkgs/development/interpreters/perl/5.8/gcc-4.2.patch
diff --git a/pkgs/development/interpreters/perl-5.8/no-sys-dirs.patch b/pkgs/development/interpreters/perl/5.8/no-sys-dirs.patch
index 48588d5a4291d..48588d5a4291d 100644
--- a/pkgs/development/interpreters/perl-5.8/no-sys-dirs.patch
+++ b/pkgs/development/interpreters/perl/5.8/no-sys-dirs.patch
diff --git a/pkgs/development/interpreters/perl-5.8/setup-hook.sh b/pkgs/development/interpreters/perl/5.8/setup-hook.sh
index d61ec82f4f080..d61ec82f4f080 100644
--- a/pkgs/development/interpreters/perl-5.8/setup-hook.sh
+++ b/pkgs/development/interpreters/perl/5.8/setup-hook.sh
diff --git a/pkgs/development/interpreters/php-xdebug/default.nix b/pkgs/development/interpreters/php-xdebug/default.nix
index 74aba643ee7d1..5a242f3c85a41 100644
--- a/pkgs/development/interpreters/php-xdebug/default.nix
+++ b/pkgs/development/interpreters/php-xdebug/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out/lib/xdebug
+    mkdir -p $out/lib/xdebug
     cp modules/xdebug.so $out/lib
     cp LICENSE $out/lib/xdebug
   '';
diff --git a/pkgs/development/interpreters/picolisp/default.nix b/pkgs/development/interpreters/picolisp/default.nix
index 298c12d271a40..196e7068e146d 100644
--- a/pkgs/development/interpreters/picolisp/default.nix
+++ b/pkgs/development/interpreters/picolisp/default.nix
@@ -41,7 +41,7 @@ rec {
 
     sed -e "s@/usr/@$out/@g" -i bin/pil
 
-    ensureDir "$out/share/picolisp" "$out/lib" "$out/bin"
+    mkdir -p "$out/share/picolisp" "$out/lib" "$out/bin"
     cp -r . "$out/share/picolisp/build-dir"
     ln -s "$out/share/picolisp/build-dir" "$out/lib/picolisp"
     ln -s "$out/lib/picolisp/bin/picolisp" "$out/bin/picolisp"
diff --git a/pkgs/development/interpreters/python/2.6/default.nix b/pkgs/development/interpreters/python/2.6/default.nix
index 4a3c292412f17..4e36bfa174288 100644
--- a/pkgs/development/interpreters/python/2.6/default.nix
+++ b/pkgs/development/interpreters/python/2.6/default.nix
@@ -12,11 +12,11 @@ with stdenv.lib;
 let
 
   majorVersion = "2.6";
-  version = "${majorVersion}.6";
+  version = "${majorVersion}.7";
 
   src = fetchurl {
     url = "http://www.python.org/ftp/python/${version}/Python-${version}.tar.bz2";
-    md5 = "cf4e6881bb84a7ce6089e4a307f71f14";
+    sha256 = "0p0fd8i533zsdm6gc0jmhmdifccx4v064mh0i1hl2s6fcjhc20j5";
   };
   
   patches =
@@ -75,7 +75,7 @@ let
 
     meta = {
       homepage = "http://python.org";
-      description = "Python -- a high-level dynamically-typed programming language";
+      description = "a high-level dynamically-typed programming language";
       longDescription = ''
         Python is a remarkably powerful dynamic programming language that
         is used in a wide variety of application domains. Some of its key
@@ -85,9 +85,9 @@ let
         hierarchical packages; exception-based error handling; and very
         high level dynamic data types.
       '';
-      license = "GPLv2";
+      license = stdenv.lib.licenses.psfl;
       platforms = stdenv.lib.platforms.all;
-      maintainers = [ stdenv.lib.maintainers.simons ];
+      maintainers = with stdenv.lib.maintainers; [ simons chaoflow ];
     };
   };
 
diff --git a/pkgs/development/interpreters/python/2.7/default.nix b/pkgs/development/interpreters/python/2.7/default.nix
index 1c8ae0cf171a4..986937376767e 100644
--- a/pkgs/development/interpreters/python/2.7/default.nix
+++ b/pkgs/development/interpreters/python/2.7/default.nix
@@ -12,11 +12,11 @@ with stdenv.lib;
 let
 
   majorVersion = "2.7";
-  version = "${majorVersion}.1";
+  version = "${majorVersion}.2";
 
   src = fetchurl {
     url = "http://www.python.org/ftp/python/${version}/Python-${version}.tar.bz2";
-    sha256 = "14i2c7yqa7ljmx2i2bb827n61q33zn23ax96czi8rbkyyny8gqw0";
+    sha256 = "1axx9h1r157fanldmnj1q2gdw2sm0sg8h3mx1l2adddmgq3fnmsh";
   };
 
   patches =
@@ -38,7 +38,7 @@ let
 
   buildInputs =
     optional (stdenv ? gcc && stdenv.gcc.libc != null) stdenv.gcc.libc ++
-    [ bzip2 ]
+    [ bzip2 openssl ]
     ++ optional zlibSupport zlib
     ++ optionals stdenv.isDarwin [ darwinArchUtility darwinSwVersUtility ];
 
@@ -89,7 +89,7 @@ let
 
     meta = {
       homepage = "http://python.org";
-      description = "Python -- a high-level dynamically-typed programming language";
+      description = "a high-level dynamically-typed programming language";
       longDescription = ''
         Python is a remarkably powerful dynamic programming language that
         is used in a wide variety of application domains. Some of its key
@@ -99,9 +99,9 @@ let
         hierarchical packages; exception-based error handling; and very
         high level dynamic data types.
       '';
-      license = "GPLv2";
+      license = stdenv.lib.licenses.psfl;
       platforms = stdenv.lib.platforms.all;
-      maintainers = [ stdenv.lib.maintainers.simons ];
+      maintainers = with stdenv.lib.maintainers; [ simons chaoflow ];
     };
   };
 
@@ -172,11 +172,6 @@ let
       deps = [ sqlite ];
     };
 
-    ssl = buildInternalPythonModule {
-      moduleName = "ssl";
-      deps = [ openssl ];
-    };
-
     tkinter = buildInternalPythonModule {
       moduleName = "tkinter";
       deps = [ tcl tk x11 ];
diff --git a/pkgs/development/interpreters/python/3.1/default.nix b/pkgs/development/interpreters/python/3.1/default.nix
index e0c8ac0e1c3a2..892af52a91976 100644
--- a/pkgs/development/interpreters/python/3.1/default.nix
+++ b/pkgs/development/interpreters/python/3.1/default.nix
@@ -80,8 +80,9 @@ stdenv.mkDerivation {
       hierarchical packages; exception-based error handling; and very
       high level dynamic data types.
     '';
-    license = "GPLv2";
+    license = stdenv.lib.licenses.psfl;
     platforms = stdenv.lib.platforms.all;
-    maintainers = [ stdenv.lib.maintainers.simons ];
+    maintainers = with stdenv.lib.maintainers; [ simons chaoflow ];
   };
+
 }
diff --git a/pkgs/development/interpreters/python/3.2/default.nix b/pkgs/development/interpreters/python/3.2/default.nix
index c0c2a6e422af1..1ab115f046962 100644
--- a/pkgs/development/interpreters/python/3.2/default.nix
+++ b/pkgs/development/interpreters/python/3.2/default.nix
@@ -79,8 +79,8 @@ stdenv.mkDerivation {
       hierarchical packages; exception-based error handling; and very
       high level dynamic data types.
     '';
-    license = "GPLv2";
+    license = stdenv.lib.licenses.psfl;
     platforms = stdenv.lib.platforms.all;
-    maintainers = [ stdenv.lib.maintainers.simons ];
+    maintainers = with stdenv.lib.maintainers; [ simons chaoflow ];
   };
 }
diff --git a/pkgs/development/interpreters/python/pythonhome-wrapper.nix b/pkgs/development/interpreters/python/pythonhome-wrapper.nix
index 2afbafe7b9141..c9cf6277b244f 100644
--- a/pkgs/development/interpreters/python/pythonhome-wrapper.nix
+++ b/pkgs/development/interpreters/python/pythonhome-wrapper.nix
@@ -5,7 +5,7 @@ stdenv.mkDerivation {
 
   unpackPhase = "true";
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     echo '
 #!/bin/sh
 
diff --git a/pkgs/development/interpreters/python/wrapper.nix b/pkgs/development/interpreters/python/wrapper.nix
index 6f29f79e2c168..e8e343976bc34 100644
--- a/pkgs/development/interpreters/python/wrapper.nix
+++ b/pkgs/development/interpreters/python/wrapper.nix
@@ -1,3 +1,6 @@
+# Create a python that knows about additional python packages via
+# PYTHONPATH
+
 {stdenv, python, makeWrapper, extraLibs ? []}:
 
 stdenv.mkDerivation {
@@ -7,10 +10,12 @@ stdenv.mkDerivation {
 
   unpackPhase = "true";
   installPhase = ''
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     for prg in 2to3 idle pydoc python python-config python${python.majorVersion} python${python.majorVersion}-config smtpd.py; do
       makeWrapper "$python/bin/$prg" "$out/bin/$prg" --suffix PYTHONPATH : "$PYTHONPATH"
     done
+    ensureDir "$out/share"
+    ln "$python/share/man" "$out/share/man" -s
   '';
 
   inherit python;
diff --git a/pkgs/development/interpreters/spidermonkey/builder.sh b/pkgs/development/interpreters/spidermonkey/builder.sh
index b0cfe6c9ed624..91110159665c0 100644
--- a/pkgs/development/interpreters/spidermonkey/builder.sh
+++ b/pkgs/development/interpreters/spidermonkey/builder.sh
@@ -22,9 +22,9 @@ $MAKE printlibraries
 $MAKE printprograms
 $MAKE
 
-ensureDir $out
-ensureDir $out/bin
-ensureDir $out/lib
+mkdir -p $out
+mkdir -p $out/bin
+mkdir -p $out/lib
 
 # Install the binaries that have been created.
 install $(cat PROGRAMS) $out/bin
diff --git a/pkgs/development/libraries/Xaw3d/builder.sh b/pkgs/development/libraries/Xaw3d/builder.sh
index afd640b625d61..ff42e47ea56bf 100644
--- a/pkgs/development/libraries/Xaw3d/builder.sh
+++ b/pkgs/development/libraries/Xaw3d/builder.sh
@@ -15,7 +15,7 @@ installPhase() {
     make install SHLIBDIR=$out/lib USRLIBDIR=$out/lib INCDIR=$out/include
     cd $out/include/X11 && ln -s Xaw3d Xaw
 
-    ensureDir "$out/nix-support"
+    mkdir -p "$out/nix-support"
     echo "$propagatedBuildInputs" > "$out/nix-support/propagated-build-inputs"
 }
 
diff --git a/pkgs/development/libraries/acl/default.nix b/pkgs/development/libraries/acl/default.nix
index 5ce81105fa32a..3ccb569198000 100644
--- a/pkgs/development/libraries/acl/default.nix
+++ b/pkgs/development/libraries/acl/default.nix
@@ -1,14 +1,14 @@
 { stdenv, fetchurl, gettext, attr }:
 
 stdenv.mkDerivation rec {
-  name = "acl-2.2.49";
+  name = "acl-2.2.51";
 
   src = fetchurl {
     url = "mirror://savannah/acl/${name}.src.tar.gz";
-    sha256 = "1mg5nxr0r9y08lmyxmm2lfss5jz1xzbs0npsc8597x2f5rsz9ixr";
+    sha256 = "09aj30m49ivycl3irram8c3givc0crivjm3ymw0nhfaxrwhlb186";
   };
 
-  buildNativeInputs = [gettext];
+  buildNativeInputs = [ gettext ];
   buildInputs = [ attr ];
 
   # Upstream use C++-style comments in C code. Remove them.
diff --git a/pkgs/development/libraries/atk/2.2.x.nix b/pkgs/development/libraries/atk/2.2.x.nix
index 8f49532c025ed..d0f7e10979532 100644
--- a/pkgs/development/libraries/atk/2.2.x.nix
+++ b/pkgs/development/libraries/atk/2.2.x.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, perl, glib, xz }:
+{ stdenv, fetchurl, pkgconfig, perl, glib }:
 
 stdenv.mkDerivation rec {
   name = "atk-2.2.0";
@@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
     sha256 = "17bkqg89l9hxbkgc76cxlin1bwczk7m6ikbccx677lrxh3kz08lb";
   };
 
-  buildNativeInputs = [ pkgconfig perl xz ];
+  buildNativeInputs = [ pkgconfig perl ];
 
   propagatedBuildInputs = [ glib ];
 
diff --git a/pkgs/development/libraries/atkmm/2.22.x.nix b/pkgs/development/libraries/atkmm/2.22.x.nix
index 2d415821fc58c..66237c4c7b993 100644
--- a/pkgs/development/libraries/atkmm/2.22.x.nix
+++ b/pkgs/development/libraries/atkmm/2.22.x.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, atk, glibmm, pkgconfig, xz }:
+{ stdenv, fetchurl, atk, glibmm, pkgconfig }:
 
 stdenv.mkDerivation rec {
   name = "atkmm-2.22.6";
@@ -8,7 +8,6 @@ stdenv.mkDerivation rec {
     sha256 = "1dmf72i7jv2a2gavjiah2722bf5qk3hb97hn5dasxqxr0r8jjx0a";
   };
 
-  buildInputs = [ xz ];
   propagatedBuildInputs = [ atk glibmm ];
 
   buildNativeInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/attr/default.nix b/pkgs/development/libraries/attr/default.nix
index 6477b443dcf8b..adc530863068a 100644
--- a/pkgs/development/libraries/attr/default.nix
+++ b/pkgs/development/libraries/attr/default.nix
@@ -1,14 +1,14 @@
 { stdenv, fetchurl, gettext }:
 
 stdenv.mkDerivation rec {
-  name = "attr-2.4.44";
+  name = "attr-2.4.46";
 
   src = fetchurl {
     url = "mirror://savannah/attr/${name}.src.tar.gz";
-    sha256 = "16244r2vrd57i5fnf7dz3yi2mcckc47jr9y539jvljrzwnw18qlz";
+    sha256 = "07qf6kb2zk512az481bbnsk9jycn477xpva1a726n5pzlzf9pmnw";
   };
 
-  buildNativeInputs = [gettext];
+  buildNativeInputs = [ gettext ];
 
   configureFlags = "MAKE=make MSGFMT=msgfmt MSGMERGE=msgmerge XGETTEXT=xgettext ECHO=echo SED=sed AWK=gawk";
 
diff --git a/pkgs/development/libraries/box2d/2.0.1.nix b/pkgs/development/libraries/box2d/2.0.1.nix
index 9aa08caf00f4c..c15e27695ac90 100644
--- a/pkgs/development/libraries/box2d/2.0.1.nix
+++ b/pkgs/development/libraries/box2d/2.0.1.nix
@@ -48,14 +48,14 @@ rec {
   '';
 
   doDeploy = a.fullDepEntry ''
-    ensureDir "$out"/lib
-    ensureDir "$out"/include/Box2D
+    mkdir -p "$out"/lib
+    mkdir -p "$out"/include/Box2D
     cp Library/* Source/Gen/float/lib*.{a,so} "$out"/lib
     cp -r Source "$out"/include/Box2D/Source
     find "$out"/include/Box2D/Source ! -name '*.h' -exec rm '{}' ';'
     sed -e s@../Source@Box2D/Source@ -i Include/Box2D.h
     cp Include/Box2D.h "$out"/include/Box2D
-    ensureDir "$out/share"
+    mkdir -p "$out/share"
     cp -r Examples "$out/share"
   '' ["minInit" "addInputs" "doMake" "defEnsureDir"];
 
diff --git a/pkgs/development/libraries/chipmunk/default.nix b/pkgs/development/libraries/chipmunk/default.nix
index 5dbb31e9bceff..d5471b9be75f3 100644
--- a/pkgs/development/libraries/chipmunk/default.nix
+++ b/pkgs/development/libraries/chipmunk/default.nix
@@ -28,7 +28,7 @@ rec {
   '' ["minInit" "addInputs" "doUnpack"];
 
   demoInstall = fullDepEntry(''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp Demo/chipmunk_demos $out/bin
   '') ["doMakeInstall" "defEnsureDir"];
       
diff --git a/pkgs/development/libraries/cloog-ppl/default.nix b/pkgs/development/libraries/cloog-ppl/default.nix
index ca662d30eb0fd..d9dae7bfd41fc 100644
--- a/pkgs/development/libraries/cloog-ppl/default.nix
+++ b/pkgs/development/libraries/cloog-ppl/default.nix
@@ -1,31 +1,19 @@
-{ fetchurl, stdenv, ppl, static ? false }:
-
-let
-
-  # --with-host-libstdcxx helps when *ppl* is built statically.
-  # But I will suppose that this is statically built only when ppl is also
-  # statically built.
-  staticFlags =
-    assert static -> ppl.dontDisableStatic == true;
-    if static then " --enable-static --disable-shared --with-host-libstdcxx=-lstdc++" else "";
-    
-in
+{ fetchurl, stdenv, ppl }:
 
 stdenv.mkDerivation rec {
-  name = "cloog-ppl-0.15.9";
+  name = "cloog-ppl-0.15.11";
 
   src = fetchurl {
     url = "mirror://gcc/infrastructure/${name}.tar.gz";
-    sha256 = "19a2n75k3d3n8llng25f2g88lpvd4zn0lm073rkndjw6l6yd8m4c";
+    sha256 = "0psdm0bn5gx60glfh955x5b3b23zqrd92idmjr0b00dlnb839mkw";
   };
 
   propagatedBuildInputs = [ ppl ];
 
-  configureFlags = "--with-ppl=${ppl}" + staticFlags;
-  dontDisableStatic = if static then true else false;
+  configureFlags = "--with-ppl=${ppl}";
 
   crossAttrs = {
-    configureFlags = "--with-ppl=${ppl.hostDrv}" + staticFlags;
+    configureFlags = "--with-ppl=${ppl.hostDrv}";
   };
 
   doCheck = true;
diff --git a/pkgs/development/libraries/cloog/default.nix b/pkgs/development/libraries/cloog/default.nix
index 7bd0d68c3ec2e..ab5737b20edee 100644
--- a/pkgs/development/libraries/cloog/default.nix
+++ b/pkgs/development/libraries/cloog/default.nix
@@ -1,6 +1,4 @@
-{ fetchurl, stdenv, gmp, isl, static ? false }:
-
-assert static -> isl.dontDisableStatic;
+{ fetchurl, stdenv, gmp, isl }:
 
 stdenv.mkDerivation rec {
   name = "cloog-0.16.3";
@@ -14,10 +12,7 @@ stdenv.mkDerivation rec {
 
   propagatedBuildInputs = [ isl ];
 
-  configureFlags = [ "--with-isl=system" ]
-    ++ (stdenv.lib.optionals static [ "--enable-static" "--disable-shared" ]);
-
-  dontDisableStatic = static;
+  configureFlags = [ "--with-isl=system" ];
 
   doCheck = true;
 
diff --git a/pkgs/development/libraries/cminpack/default.nix b/pkgs/development/libraries/cminpack/default.nix
index f070f2dfaef29..121f41a0f3c5f 100644
--- a/pkgs/development/libraries/cminpack/default.nix
+++ b/pkgs/development/libraries/cminpack/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
   '';
 
   preInstall = ''
-    ensureDir $out/lib $out/include
+    mkdir -p $out/lib $out/include
   '';
 
   meta = {
diff --git a/pkgs/development/libraries/cogl/default.nix b/pkgs/development/libraries/cogl/default.nix
index 6b517b9181022..11a6e374e2e4b 100644
--- a/pkgs/development/libraries/cogl/default.nix
+++ b/pkgs/development/libraries/cogl/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, pkgconfig, mesa, glib, gdk_pixbuf
 , pangoSupport ? true, pango, cairo
-, libXfixes, libXcomposite, libXdamage, xz }:
+, libXfixes, libXcomposite, libXdamage }:
 
 stdenv.mkDerivation rec {
   name = "cogl-1.8.2";
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
     sha256 = "1ix87hz3qxqysqwx58wbc46lzchlmfs08fjzbf3l6mmsqj8gs9pc";
   };
 
-  buildNativeInputs = [ xz pkgconfig ];
+  buildNativeInputs = [ pkgconfig ];
 
   propagatedBuildInputs =
     [ mesa glib gdk_pixbuf libXfixes libXcomposite libXdamage ];
diff --git a/pkgs/development/libraries/crypto++/default.nix b/pkgs/development/libraries/crypto++/default.nix
index 138ee6eb27f50..8f39de41e55b2 100644
--- a/pkgs/development/libraries/crypto++/default.nix
+++ b/pkgs/development/libraries/crypto++/default.nix
@@ -8,8 +8,10 @@ stdenv.mkDerivation rec {
     sha256 = "0s7jhvnfihikqp1iwpdz03fad62xkjxci6jiahrh6f3sn664vrwq";
   };
 
-  patches = [ ./pic.patch ]
-    ++ stdenv.lib.optional (stdenv.system != "i686-cygwin") ./dll.patch;
+  patches = [
+    ./pic.patch
+    ./salsa-gcc4.6.patch
+  ] ++ stdenv.lib.optional (stdenv.system != "i686-cygwin") ./dll.patch;
 
 
   buildInputs = [ unzip ]
diff --git a/pkgs/development/libraries/crypto++/salsa-gcc4.6.patch b/pkgs/development/libraries/crypto++/salsa-gcc4.6.patch
new file mode 100644
index 0000000000000..609d2f55d2231
--- /dev/null
+++ b/pkgs/development/libraries/crypto++/salsa-gcc4.6.patch
@@ -0,0 +1,62 @@
+From fbccde3578feddb16f07be981da1d0f26209fd04 Mon Sep 17 00:00:00 2001
+From: weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>
+Date: Sun, 5 Jun 2011 21:07:11 +0000
+Subject: [PATCH 1/4] fix Salsa validation failure when compiling with GCC 4.6
+ (https://sourceforge.net/apps/trac/cryptopp/ticket/12)
+
+git-svn-id: https://cryptopp.svn.sourceforge.net/svnroot/cryptopp/trunk@529 57ff6487-cd31-0410-9ec3-f628ee90f5f0
+---
+ c5/salsa.cpp |   21 +++++++++++----------
+ 1 file changed, 11 insertions(+), 10 deletions(-)
+
+# NOTE: remove the c5 path component
+
+diff --git a/salsa.cpp b/salsa.cpp
+index bd216ee..bdc5d75 100755
+--- a/salsa.cpp
++++ b/salsa.cpp
+@@ -122,17 +122,17 @@ void Salsa20_Policy::OperateKeystream(KeystreamOperation operation, byte *output
+ 	if (HasSSE2())
+ 	{
+ 	#if CRYPTOPP_BOOL_X64
+-		#define REG_output			%4
+-		#define REG_input			%1
++		#define REG_output			%1
++		#define REG_input			%0
+ 		#define REG_iterationCount	%2
+-		#define REG_state			%3
+-		#define REG_rounds			%0
++		#define REG_state			%4		/* constant */
++		#define REG_rounds			%3		/* constant */
+ 		#define REG_roundsLeft		eax
+ 		#define REG_temp32			edx
+ 		#define REG_temp			rdx
+-		#define SSE2_WORKSPACE		%5
++		#define SSE2_WORKSPACE		%5		/* constant */
+ 
+-		FixedSizeAlignedSecBlock<byte, 32*16> workspace;
++		CRYPTOPP_ALIGN_DATA(16) byte workspace[16*32];
+ 	#else
+ 		#define REG_output			edi
+ 		#define REG_input			eax
+@@ -457,12 +457,13 @@ void Salsa20_Policy::OperateKeystream(KeystreamOperation operation, byte *output
+ #ifdef __GNUC__
+ 		AS_POP_IF86(	bx)
+ 		".att_syntax prefix;"
+-			: 
+ 	#if CRYPTOPP_BOOL_X64
+-			: "r" (m_rounds), "r" (input), "r" (iterationCount), "r" (m_state.data()), "r" (output), "r" (workspace.m_ptr)
+-			: "%eax", "%edx", "memory", "cc", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "%xmm8", "%xmm9", "%xmm10", "%xmm11", "%xmm12", "%xmm13", "%xmm14", "%xmm15"
++			: "+r" (input), "+r" (output), "+r" (iterationCount)
++			: "r" (m_rounds), "r" (m_state.m_ptr), "r" (workspace)
++			: "%eax", "%rdx", "memory", "cc", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "%xmm8", "%xmm9", "%xmm10", "%xmm11", "%xmm12", "%xmm13", "%xmm14", "%xmm15"
+ 	#else
+-			: "d" (m_rounds), "a" (input), "c" (iterationCount), "S" (m_state.data()), "D" (output)
++			: "+a" (input), "+D" (output), "+c" (iterationCount)
++			: "d" (m_rounds), "S" (m_state.m_ptr)
+ 			: "memory", "cc"
+ 	#endif
+ 		);
+-- 
+1.7.9.2
+
diff --git a/pkgs/development/libraries/dbus-glib/0.94.nix b/pkgs/development/libraries/dbus-glib/0.94.nix
deleted file mode 100644
index 83c1693d80f7d..0000000000000
--- a/pkgs/development/libraries/dbus-glib/0.94.nix
+++ /dev/null
@@ -1,23 +0,0 @@
-{ stdenv, fetchurl, pkgconfig, expat, gettext, libiconv, dbus, glib }:
-
-stdenv.mkDerivation rec {
-  name = "dbus-glib-0.94";
-
-  src = fetchurl {
-    url = "${meta.homepage}/releases/dbus-glib/${name}.tar.gz";
-    sha256 = "16yk106bp58in6vz2li2s3iwk1si65f0n22m8c2mplzh2j9zlq74";
-  };
-
-  buildInputs = [ pkgconfig expat gettext ]
-                ++ stdenv.lib.optional (!stdenv.isLinux) libiconv;
-
-  propagatedBuildInputs = [ dbus glib ];
-
-  passthru = { inherit dbus glib; };
-
-  meta = {
-    homepage = http://dbus.freedesktop.org;
-    license = "AFL-2.1 or GPL-2";
-    description = "GLib bindings for D-Bus lightweight IPC mechanism";
-  };
-}
diff --git a/pkgs/development/libraries/dbus-glib/default.nix b/pkgs/development/libraries/dbus-glib/default.nix
index 467b9c4d506a7..5fccc7ad66b75 100644
--- a/pkgs/development/libraries/dbus-glib/default.nix
+++ b/pkgs/development/libraries/dbus-glib/default.nix
@@ -1,23 +1,25 @@
 { stdenv, fetchurl, pkgconfig, expat, gettext, libiconv, dbus, glib }:
 
 stdenv.mkDerivation rec {
-  name = "dbus-glib-0.86";
+  name = "dbus-glib-0.98";
 
   src = fetchurl {
     url = "${meta.homepage}/releases/dbus-glib/${name}.tar.gz";
-    sha256 = "1p0bm5p8g8h0mimhj0d58dqdrhfipvcwv95l6hf69z4gygksclak";
+    sha256 = "04fiwld5yaxyggxlvdmbaqkngh4fn8gfkkqckcp3274bpgb82z19";
   };
-  
-  buildInputs = [ pkgconfig expat gettext ]
-                ++ stdenv.lib.optional (!stdenv.isLinux) libiconv;
-  
-  propagatedBuildInputs = [ dbus.libs glib ];
-  
+
+  buildNativeInputs = [ pkgconfig gettext ];
+
+  buildInputs = [ expat ] ++ stdenv.lib.optional (!stdenv.isLinux) libiconv;
+
+  propagatedBuildInputs = [ dbus glib ];
+
   passthru = { inherit dbus glib; };
 
   meta = {
     homepage = http://dbus.freedesktop.org;
     license = "AFL-2.1 or GPL-2";
-    description = "GLib bindings for D-Bus lightweight IPC mechanism";
+    description = "Obsolete glib bindings for D-Bus lightweight IPC mechanism";
+    maintainers = [ stdenv.lib.maintainers.urkud ];
   };
 }
diff --git a/pkgs/development/libraries/dbus/1.5.6.nix b/pkgs/development/libraries/dbus/1.5.6.nix
deleted file mode 100644
index 9c158933cb055..0000000000000
--- a/pkgs/development/libraries/dbus/1.5.6.nix
+++ /dev/null
@@ -1,61 +0,0 @@
-{ stdenv, fetchurl, pkgconfig, expat, libX11, libICE, libSM, useX11 ? true }:
-
-let
-  version = "1.5.6";
-
-  src = fetchurl {
-    url = "http://dbus.freedesktop.org/releases/dbus/dbus-${version}.tar.gz";
-    sha256 = "18g5328wnh25p0hihv5gg55q5l019zzwr04shvp67myvwy07m851";
-  };
-
-  patches = [ ./ignore-missing-includedirs.patch ];
-
-  configureFlags = "--localstatedir=/var --sysconfdir=/etc --with-session-socket-dir=/tmp";
-
-in rec {
-
-  libs = stdenv.mkDerivation {
-    name = "dbus-library-" + version;
-
-    buildInputs = [ pkgconfig expat ];
-
-    inherit src patches configureFlags;
-
-    preConfigure =
-      ''
-        sed -i '/mkinstalldirs.*localstatedir/d' bus/Makefile.in
-        sed -i '/SUBDIRS/s/ tools//' Makefile.in
-      '';
-
-    # Enable X11 autolaunch support in libdbus.  This doesn't actually
-    # depend on X11 (it just execs dbus-launch in dbus.tools),
-    # contrary to what the configure script demands.
-    NIX_CFLAGS_COMPILE = "-DDBUS_ENABLE_X11_AUTOLAUNCH=1";
-
-    installFlags = "sysconfdir=$(out)/etc";
-  };
-
-  tools = stdenv.mkDerivation {
-    name = "dbus-tools-" + version;
-
-    inherit src patches;
-
-    configureFlags = "${configureFlags} --with-dbus-daemondir=${daemon}/bin";
-
-    buildInputs = [ pkgconfig expat libs ]
-      ++ stdenv.lib.optionals useX11 [ libX11 libICE libSM ];
-
-    NIX_LDFLAGS = "-ldbus-1";
-
-    preConfigure =
-      ''
-        sed -i 's@$(top_builddir)/dbus/libdbus-1.la@@' tools/Makefile.in
-        substituteInPlace tools/Makefile.in --replace 'install-localstatelibDATA:' 'disabled:'
-      '';
-
-    postConfigure = "cd tools";
-  };
-
-  # I'm too lazy to separate daemon and libs now.
-  daemon = libs;
-}
diff --git a/pkgs/development/libraries/dbus/default.nix b/pkgs/development/libraries/dbus/default.nix
index 1d0bcc111460e..c943fe87fb383 100644
--- a/pkgs/development/libraries/dbus/default.nix
+++ b/pkgs/development/libraries/dbus/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, pkgconfig, expat, libX11, libICE, libSM, useX11 ? true }:
 
 let
-  version = "1.4.14";
+  version = "1.4.16";
 
   src = fetchurl {
     url = "http://dbus.freedesktop.org/releases/dbus/dbus-${version}.tar.gz";
-    sha256 = "0xsqkq2q2hb09dcdsw0y359zvml480h79qvl9g31r7da57y7xwj7";
+    sha256 = "1ii93d0lzj5xm564dcq6ca4s0nvm5i9fx3jp0s7i9hlc5wkfd3hx";
   };
 
   patches = [ ./ignore-missing-includedirs.patch ];
@@ -17,7 +17,9 @@ in rec {
   libs = stdenv.mkDerivation {
     name = "dbus-library-" + version;
 
-    buildInputs = [ pkgconfig expat ];
+    buildNativeInputs = [ pkgconfig ];
+
+    buildInputs = [ expat ];
 
     inherit src patches configureFlags;
 
@@ -42,14 +44,16 @@ in rec {
 
     configureFlags = "${configureFlags} --with-dbus-daemondir=${daemon}/bin";
 
-    buildInputs = [ pkgconfig expat libs ]
+    buildNativeInputs = [ pkgconfig ];
+
+    buildInputs = [ expat libs ]
       ++ stdenv.lib.optionals useX11 [ libX11 libICE libSM ];
 
     NIX_LDFLAGS = "-ldbus-1";
 
     preConfigure =
       ''
-        sed -i 's@ $(top_builddir)/dbus/libdbus-1.la@@' tools/Makefile.in
+        sed -i 's@$(top_builddir)/dbus/libdbus-1.la@@' tools/Makefile.in
         substituteInPlace tools/Makefile.in --replace 'install-localstatelibDATA:' 'disabled:'
       '';
 
diff --git a/pkgs/development/libraries/dotnetfx35/default.nix b/pkgs/development/libraries/dotnetfx35/default.nix
index 7ac4568a4e133..e1c59846aec53 100644
--- a/pkgs/development/libraries/dotnetfx35/default.nix
+++ b/pkgs/development/libraries/dotnetfx35/default.nix
@@ -8,7 +8,7 @@ in
     name = "dotnetfx-3.5";
     src = "${windir}/Microsoft.NET/Framework/v3.5";
     buildCommand = ''
-      ensureDir $out/bin
+      mkdir -p $out/bin
       ln -s $src/MSBuild.exe $out/bin
     '';
   };
diff --git a/pkgs/development/libraries/dotnetfx40/default.nix b/pkgs/development/libraries/dotnetfx40/default.nix
index b9ce4738d129c..701464071d032 100644
--- a/pkgs/development/libraries/dotnetfx40/default.nix
+++ b/pkgs/development/libraries/dotnetfx40/default.nix
@@ -8,7 +8,7 @@ in
     name = "dotnetfx-4.0";
     src = "${windir}/Microsoft.NET/Framework/v4.0.30319";
     buildCommand = ''
-      ensureDir $out/bin
+      mkdir -p $out/bin
       ln -s $src/MSBuild.exe $out/bin
     '';
   };
diff --git a/pkgs/development/libraries/eglibc/builder.sh b/pkgs/development/libraries/eglibc/builder.sh
index 47cd1b5e252f7..6ac1d223b47e1 100644
--- a/pkgs/development/libraries/eglibc/builder.sh
+++ b/pkgs/development/libraries/eglibc/builder.sh
@@ -20,7 +20,7 @@ preConfigure() {
     done
 
     # Include source for debugging
-    ensureDir $out/src
+    mkdir -p $out/src
     cp -R libc ports $out/src
     ln -s $out/src/ports $out/src/libc/ports
     # glibc wants -O2 minimum
diff --git a/pkgs/development/libraries/gdk-pixbuf/2.24.x.nix b/pkgs/development/libraries/gdk-pixbuf/2.24.x.nix
index eb7eaf91bb07b..5c0860196d396 100644
--- a/pkgs/development/libraries/gdk-pixbuf/2.24.x.nix
+++ b/pkgs/development/libraries/gdk-pixbuf/2.24.x.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation {
   # !!! We might want to factor out the gdk-pixbuf-xlib subpackage.
   buildInputs = [ libX11 ];
 
-  buildNativeInputs = [ pkgconfig xz ];
+  buildNativeInputs = [ pkgconfig ];
 
   propagatedBuildInputs = [ glib libtiff libjpeg libpng jasper ];
 
diff --git a/pkgs/development/libraries/geoclue/default.nix b/pkgs/development/libraries/geoclue/default.nix
index 076c821ca9539..c5c8b694ba9ca 100644
--- a/pkgs/development/libraries/geoclue/default.nix
+++ b/pkgs/development/libraries/geoclue/default.nix
@@ -30,8 +30,12 @@ rec {
   propagatedBuildInputs = [a.dbus a.glib a.dbus_glib];
 
   /* doConfigure should be removed if not needed */
-  phaseNames = ["doConfigure" "doMakeInstall"];
+  phaseNames = ["fixConfigure" "doConfigure" "doMakeInstall"];
       
+  fixConfigure = a.fullDepEntry ''
+    sed -e 's@-Werror@@' -i configure
+  '' ["minInit" "doUnpack"];
+
   meta = {
     description = "Geolocation framework and some data providers";
     maintainers = with a.lib.maintainers;
diff --git a/pkgs/development/libraries/gettext/0.17.nix b/pkgs/development/libraries/gettext/0.17.nix
index 6b094fdc8394d..bee2042f11669 100644
--- a/pkgs/development/libraries/gettext/0.17.nix
+++ b/pkgs/development/libraries/gettext/0.17.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, libiconv }:
 
-stdenv.mkDerivation (rec {
+stdenv.mkDerivation rec {
   name = "gettext-0.17";
   
   src = fetchurl {
@@ -21,6 +21,8 @@ stdenv.mkDerivation (rec {
     fi
   '';
 
+  buildInputs = stdenv.lib.optional (!stdenv.isLinux) libiconv;
+  
   meta = {
     description = "GNU gettext, a well integrated set of translation tools and documentation";
 
@@ -47,12 +49,4 @@ stdenv.mkDerivation (rec {
 
     maintainers = [ stdenv.lib.maintainers.ludo ];
   };
-}
-
-//
-
-(if (!stdenv.isLinux) # any non-GNU system
-    then {
-      buildInputs = [ libiconv ];
-    }
-    else {}))
+}
\ No newline at end of file
diff --git a/pkgs/development/libraries/gettext/default.nix b/pkgs/development/libraries/gettext/default.nix
index ddcfc327a9ee3..f7b31139b562e 100644
--- a/pkgs/development/libraries/gettext/default.nix
+++ b/pkgs/development/libraries/gettext/default.nix
@@ -1,8 +1,6 @@
-# XXX: Remove me when `stdenv-updates' is merged.
-
 { stdenv, fetchurl, libiconv }:
 
-stdenv.mkDerivation (rec {
+stdenv.mkDerivation rec {
   name = "gettext-0.18.1.1";
   
   src = fetchurl {
@@ -23,6 +21,10 @@ stdenv.mkDerivation (rec {
     fi
   '';
 
+  buildInputs = stdenv.lib.optional (!stdenv.isLinux) libiconv;
+  
+  enableParallelBuilding = true;
+      
   crossAttrs = {
     buildInputs = stdenv.lib.optional (stdenv.gccCross.libc ? libiconv)
       stdenv.gccCross.libc.libiconv.hostDrv;
@@ -58,11 +60,3 @@ stdenv.mkDerivation (rec {
     platforms = stdenv.lib.platforms.all;
   };
 }
-
-//
-
-(if (!stdenv.isLinux) # any non-GNU system
-    then {
-      buildInputs = [ libiconv ];
-    }
-    else {}))
diff --git a/pkgs/development/libraries/glfw/default.nix b/pkgs/development/libraries/glfw/default.nix
index 1454d2ec94a9a..1f4df39408e81 100644
--- a/pkgs/development/libraries/glfw/default.nix
+++ b/pkgs/development/libraries/glfw/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
   buildInputs = [ mesa libX11 libXext ];
 
   buildPhase = ''
-    ensureDir $out
+    mkdir -p $out
     make x11-install PREFIX=$out
   '';
   
diff --git a/pkgs/development/libraries/glib/2.28.x.nix b/pkgs/development/libraries/glib/2.28.x.nix
index 31ebe207a3951..e41917b3fe46a 100644
--- a/pkgs/development/libraries/glib/2.28.x.nix
+++ b/pkgs/development/libraries/glib/2.28.x.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl_gnome, pkgconfig, gettext, perl, libiconv, zlib, xz }:
+{ stdenv, fetchurl_gnome, pkgconfig, gettext, perl, libiconv, zlib }:
 
 # TODO:
 # * Add gio-module-fam
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
 
   # configure script looks for d-bus but it is only needed for tests
   buildInputs = stdenv.lib.optional (!stdenv.isLinux) libiconv;
-  buildNativeInputs = [ perl pkgconfig gettext xz ];
+  buildNativeInputs = [ perl pkgconfig gettext ];
 
   propagatedBuildInputs = [ zlib ]
     ++ stdenv.lib.optional (!stdenv.isLinux) gettext;
diff --git a/pkgs/development/libraries/glib/2.30.x.nix b/pkgs/development/libraries/glib/2.30.x.nix
index a0d8ac0eff7b6..0f1812b4ec56e 100644
--- a/pkgs/development/libraries/glib/2.30.x.nix
+++ b/pkgs/development/libraries/glib/2.30.x.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, gettext, perl, libiconv, zlib, xz, libffi
+{ stdenv, fetchurl, pkgconfig, gettext, perl, libiconv, zlib, libffi
 , python }:
 
 # TODO:
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
 
   # configure script looks for d-bus but it is only needed for tests
   buildInputs = stdenv.lib.optional (!stdenv.isLinux) libiconv;
-  buildNativeInputs = [ perl pkgconfig gettext xz python ];
+  buildNativeInputs = [ perl pkgconfig gettext python ];
 
   propagatedBuildInputs = [ zlib libffi ];
 
diff --git a/pkgs/development/libraries/glibc-2.12/builder.sh b/pkgs/development/libraries/glibc/2.13/builder.sh
index 9a1c1490019a6..9a1c1490019a6 100644
--- a/pkgs/development/libraries/glibc-2.12/builder.sh
+++ b/pkgs/development/libraries/glibc/2.13/builder.sh
diff --git a/pkgs/development/libraries/glibc-2.12/common.nix b/pkgs/development/libraries/glibc/2.13/common.nix
index 6a68077ab348b..1c8f142553fad 100644
--- a/pkgs/development/libraries/glibc-2.12/common.nix
+++ b/pkgs/development/libraries/glibc/2.13/common.nix
@@ -12,7 +12,7 @@ cross :
 
 let
   # For GNU/Hurd, see below.
-  version = if hurdHeaders != null then "20120223" else "2.12.2";
+  version = if hurdHeaders != null then "20111025" else "2.13";
 
   needsPortsNative = stdenv.isMips || stdenv.isArm;
   needsPortsCross = cross.arch == "mips" || cross.arch == "arm";
@@ -21,9 +21,8 @@ let
     else needsPortsCross;
 
   srcPorts = fetchurl {
-    # These should work equally well for 2.12.2
-    url = "mirror://gnu/glibc/glibc-ports-2.12.1.tar.bz2";
-    sha256 = "041ix0nq7nc5r7jf80jsdlw4idah2mjp5nf7khybhc4cs1kc31ir";
+    url = "mirror://gnu/glibc/glibc-ports-2.13.tar.bz2";
+    sha256 = "0npffql62m1xba15l1wkaqf2p0l2bvb33720gx28764jmq0la75i";
   };
 
 in
@@ -75,6 +74,9 @@ stdenv.mkDerivation ({
 
     /* Allow nixos and nix handle the locale-archive. */
     ./nix-locale-archive.patch
+
+    /* Without this patch many KDE binaries crash. */
+    ./glibc-elf-localscope.patch
   ];
 
   postPatch = ''
@@ -90,6 +92,7 @@ stdenv.mkDerivation ({
   configureFlags = [
     "-C"
     "--enable-add-ons"
+    "--sysconfdir=/etc"
     "--localedir=/var/run/current-system/sw/lib/locale"
     (if kernelHeaders != null
      then "--with-headers=${kernelHeaders}/include"
@@ -111,6 +114,8 @@ stdenv.mkDerivation ({
     # so the glibc does not depend on its compiler store path
     "libc_cv_as_needed=no"
   ];
+
+  installFlags = [ "sysconfdir=$(out)/etc" ];
   
   buildInputs = stdenv.lib.optionals (cross != null) [ gccCross ]
     ++ stdenv.lib.optional (mig != null) mig;
@@ -143,12 +148,12 @@ stdenv.mkDerivation ({
       # maintained by the Hurd folks, `tschwinge/Roger_Whittaker' branch.
       # See <http://www.gnu.org/software/hurd/source_repositories/glibc.html>.
       url = "git://git.sv.gnu.org/hurd/glibc.git";
-      sha256 = "cecec9dd5a2bafc875c56b058b6d7628a22b250b53747513dec304f31ffdb82d";
-      rev = "d3cdecf18e6550b0984a42b43ed48c5fb26501e1";
+      sha256 = "3fb3dd7030a4b6d3e144fa94c32a0c4f46f17f94e2dfbc6bef41cfc3198725ca";
+      rev = "d740cf9d201dc9ecb0335b0a585828dea9cce793";
     }
     else fetchurl {
       url = "mirror://gnu/glibc/glibc-${version}.tar.bz2";
-      sha256 = "05hjz816a2hmzc44gxxi9vrdx6l9f23az794zj45xsxr94yfpy12";
+      sha256 = "1cnv319ysc8nkwpqw6f6ymb6b8hbl0nyvyx48sddkrj50lmcjwq1";
     };
 
   # `fetchurl' is a function and thus should not be passed to the
diff --git a/pkgs/development/libraries/glibc-2.12/default.nix b/pkgs/development/libraries/glibc/2.13/default.nix
index 89e8c60b7dadb..1b4e43b1013a5 100644
--- a/pkgs/development/libraries/glibc-2.12/default.nix
+++ b/pkgs/development/libraries/glibc/2.13/default.nix
@@ -30,7 +30,7 @@ in
     # any special hack.
     preInstall = ''
       if [ -f ${stdenv.gcc.gcc}/lib/libgcc_s.so.1 ]; then
-          ensureDir $out/lib
+          mkdir -p $out/lib
           ln -s ${stdenv.gcc.gcc}/lib/libgcc_s.so.1 $out/lib/libgcc_s.so.1
       fi
     '';
diff --git a/pkgs/development/libraries/glibc/2.13/glibc-elf-localscope.patch b/pkgs/development/libraries/glibc/2.13/glibc-elf-localscope.patch
new file mode 100644
index 0000000000000..98f7f81087bb3
--- /dev/null
+++ b/pkgs/development/libraries/glibc/2.13/glibc-elf-localscope.patch
@@ -0,0 +1,82 @@
+diff -ru a/elf/dl-close.c b/elf/dl-close.c
+--- a/elf/dl-close.c	2011-02-04 00:35:03.000000000 +0100
++++ b/elf/dl-close.c	2011-02-22 02:16:12.367883000 +0100
+@@ -180,24 +186,28 @@
+       /* Signal the object is still needed.  */
+       l->l_idx = IDX_STILL_USED;
+ 
++#define mark_used(dmap) \
++  do {								\
++    if ((dmap)->l_idx != IDX_STILL_USED)			\
++      {								\
++	assert ((dmap)->l_idx >= 0 && (dmap)->l_idx < nloaded);	\
++								\
++	if (!used[(dmap)->l_idx])				\
++	  {							\
++	    used[(dmap)->l_idx] = 1;				\
++	    if ((dmap)->l_idx - 1 < done_index)			\
++	      done_index = (dmap)->l_idx - 1;			\
++	  }							\
++      }								\
++  } while (0)
++
+       /* Mark all dependencies as used.  */
+       if (l->l_initfini != NULL)
+ 	{
+ 	  struct link_map **lp = &l->l_initfini[1];
+ 	  while (*lp != NULL)
+ 	    {
+-	      if ((*lp)->l_idx != IDX_STILL_USED)
+-		{
+-		  assert ((*lp)->l_idx >= 0 && (*lp)->l_idx < nloaded);
+-
+-		  if (!used[(*lp)->l_idx])
+-		    {
+-		      used[(*lp)->l_idx] = 1;
+-		      if ((*lp)->l_idx - 1 < done_index)
+-			done_index = (*lp)->l_idx - 1;
+-		    }
+-		}
+-
++	      mark_used(*lp);
+ 	      ++lp;
+ 	    }
+ 	}
+@@ -206,19 +216,25 @@
+ 	for (unsigned int j = 0; j < l->l_reldeps->act; ++j)
+ 	  {
+ 	    struct link_map *jmap = l->l_reldeps->list[j];
+-
+-	    if (jmap->l_idx != IDX_STILL_USED)
+-	      {
+-		assert (jmap->l_idx >= 0 && jmap->l_idx < nloaded);
+-
+-		if (!used[jmap->l_idx])
+-		  {
+-		    used[jmap->l_idx] = 1;
+-		    if (jmap->l_idx - 1 < done_index)
+-		      done_index = jmap->l_idx - 1;
+-		  }
+-	      }
++	    mark_used(jmap);
+ 	  }
++      /* And the same for owners of our scopes; normally, our last
++	 scope provider would render us unused, but this can be
++	 prevented by the NODELETE flag. */
++      if (__builtin_expect(l->l_type == lt_loaded
++	                   && (l->l_flags_1 & DF_1_NODELETE), 0))
++	for (size_t cnt = 0; l->l_scope[cnt] != NULL; ++cnt)
++	  /* This relies on l_scope[] entries being always set either
++	     to its own l_symbolic_searchlist address, or some map's
++	     l_searchlist address.  */
++	  if (l->l_scope[cnt] != &l->l_symbolic_searchlist)
++	    {
++	      struct link_map *ls = (struct link_map *)
++		((char *) l->l_scope[cnt]
++		 - offsetof (struct link_map, l_searchlist));
++	      assert (ls->l_ns == nsid);
++	      mark_used(ls);
++	    }
+     }
+ 
+   /* Sort the entries.  */
diff --git a/pkgs/development/libraries/glibc-2.12/info.nix b/pkgs/development/libraries/glibc/2.13/info.nix
index 84a16fefce9de..75bd996d9bc51 100644
--- a/pkgs/development/libraries/glibc-2.12/info.nix
+++ b/pkgs/development/libraries/glibc/2.13/info.nix
@@ -18,7 +18,7 @@ in
     # Somehow building the info still does not work, because the final
     # libc.info hasn't a Top node.
     installPhase = ''
-      ensureDir "$out/share/info"
+      mkdir -p "$out/share/info"
       cp -v "../$sourceRoot/manual/"*.info* "$out/share/info"
     '';
 
diff --git a/pkgs/development/libraries/glibc-2.12/locales-builder.sh b/pkgs/development/libraries/glibc/2.13/locales-builder.sh
index d732e208fa22a..d732e208fa22a 100644
--- a/pkgs/development/libraries/glibc-2.12/locales-builder.sh
+++ b/pkgs/development/libraries/glibc/2.13/locales-builder.sh
diff --git a/pkgs/development/libraries/glibc-2.12/locales.nix b/pkgs/development/libraries/glibc/2.13/locales.nix
index 31a03c48d8562..b7eae50ca385c 100644
--- a/pkgs/development/libraries/glibc-2.12/locales.nix
+++ b/pkgs/development/libraries/glibc/2.13/locales.nix
@@ -39,8 +39,8 @@ in
 
     installPhase =
       ''
-        ensureDir "$out/lib/locale"
-        cp -v "$TMPDIR/$NIX_STORE/"*"/lib/locale/locale-archive" "$out/lib/locale"
+        mkdir -p "$out/lib/locale"
+        cp -v "$TMPDIR/nix/store/"*"/lib/locale/locale-archive" "$out/lib/locale"
       '';
 
     meta.description = "Locale information for the GNU C Library";
diff --git a/pkgs/development/libraries/glibc-2.12/nix-locale-archive.patch b/pkgs/development/libraries/glibc/2.13/nix-locale-archive.patch
index aca904f7ff445..aca904f7ff445 100644
--- a/pkgs/development/libraries/glibc-2.12/nix-locale-archive.patch
+++ b/pkgs/development/libraries/glibc/2.13/nix-locale-archive.patch
diff --git a/pkgs/development/libraries/glibc-2.12/nss-skip-unavail.patch b/pkgs/development/libraries/glibc/2.13/nss-skip-unavail.patch
index e48dc2bc0a6ed..e48dc2bc0a6ed 100644
--- a/pkgs/development/libraries/glibc-2.12/nss-skip-unavail.patch
+++ b/pkgs/development/libraries/glibc/2.13/nss-skip-unavail.patch
diff --git a/pkgs/development/libraries/glibc-2.12/rpcgen-path.patch b/pkgs/development/libraries/glibc/2.13/rpcgen-path.patch
index fbb03dd5fadee..fbb03dd5fadee 100644
--- a/pkgs/development/libraries/glibc-2.12/rpcgen-path.patch
+++ b/pkgs/development/libraries/glibc/2.13/rpcgen-path.patch
diff --git a/pkgs/development/libraries/glibc/2.14/builder.sh b/pkgs/development/libraries/glibc/2.14/builder.sh
new file mode 100644
index 0000000000000..9a1c1490019a6
--- /dev/null
+++ b/pkgs/development/libraries/glibc/2.14/builder.sh
@@ -0,0 +1,55 @@
+# Glibc cannot have itself in its RPATH.
+export NIX_NO_SELF_RPATH=1
+
+source $stdenv/setup
+
+postConfigure() {
+    # Hack: get rid of the `-static' flag set by the bootstrap stdenv.
+    # This has to be done *after* `configure' because it builds some
+    # test binaries.
+    export NIX_CFLAGS_LINK=
+    export NIX_LDFLAGS_BEFORE=
+
+    export NIX_DONT_SET_RPATH=1
+    unset CFLAGS
+}
+
+
+postInstall() {
+    if test -n "$installLocales"; then
+        make -j${NIX_BUILD_CORES:-1} -l${NIX_BUILD_CORES:-1} localedata/install-locales
+    fi
+    
+    test -f $out/etc/ld.so.cache && rm $out/etc/ld.so.cache
+
+    # FIXME: Use `test -n $linuxHeaders' when `kernelHeaders' has been
+    # renamed.
+    if test -z "$hurdHeaders"; then
+        # Include the Linux kernel headers in Glibc, except the `scsi'
+        # subdirectory, which Glibc provides itself.
+	(cd $out/include && \
+	 ln -sv $(ls -d $kernelHeaders/include/* | grep -v 'scsi$') .)
+    fi
+
+    if test -f "$out/lib/libhurduser.so"; then
+	# libc.so, libhurduser.so, and libmachuser.so depend on each
+	# other, so add them to libc.so (a RUNPATH on libc.so.0.3
+	# would be ignored by the cross-linker.)
+	echo "adding \`libhurduser.so' and \`libmachuser.so' to the \`libc.so' linker script..."
+	sed -i "$out/lib/libc.so" \
+	    -e"s|\(libc\.so\.[^ ]\+\>\)|\1 $out/lib/libhurduser.so $out/lib/libmachuser.so|g"
+    fi
+	
+    # Fix for NIXOS-54 (ldd not working on x86_64).  Make a symlink
+    # "lib64" to "lib".
+    if test -n "$is64bit"; then
+        ln -s lib $out/lib64
+    fi
+
+    # This file, that should not remain in the glibc derivation,
+    # may have not been created during the preInstall
+    rm -f $out/lib/libgcc_s.so.1
+}
+
+
+genericBuild
diff --git a/pkgs/development/libraries/glibc/2.14/common.nix b/pkgs/development/libraries/glibc/2.14/common.nix
new file mode 100644
index 0000000000000..488503d901200
--- /dev/null
+++ b/pkgs/development/libraries/glibc/2.14/common.nix
@@ -0,0 +1,219 @@
+/* Build configuration used to build glibc, Info files, and locale
+   information.  */
+
+cross :
+
+{ name, fetchurl, stdenv, installLocales ? false
+, gccCross ? null, kernelHeaders ? null
+, machHeaders ? null, hurdHeaders ? null, libpthreadHeaders ? null
+, mig ? null, fetchgit ? null
+, profilingLibraries ? false, meta
+, preConfigure ? "", ... }@args :
+
+let
+  # For GNU/Hurd, see below.
+  version = if hurdHeaders != null then "20111025" else "2.14.1";
+
+  needsPortsNative = stdenv.isMips || stdenv.isArm;
+  needsPortsCross = cross.arch == "mips" || cross.arch == "arm";
+  needsPorts = if (stdenv ? cross) && stdenv.cross != null then true
+    else if cross == null then needsPortsNative
+    else needsPortsCross;
+
+  srcPorts = fetchurl {
+    url = "mirror://gnu/glibc/glibc-ports-2.14.1.tar.bz2";
+    sha256 = "1acs4sd5mjzmssmd0md6dfqwnziph2am7v09mbnnd8aadpxhm0qw";
+  };
+
+in
+
+assert (cross != null) -> (gccCross != null);
+
+assert (mig != null) -> (machHeaders != null);
+assert (machHeaders != null) -> (hurdHeaders != null);
+assert (hurdHeaders != null) -> (libpthreadHeaders != null);
+assert (hurdHeaders != null) -> (fetchgit != null);
+
+stdenv.mkDerivation ({
+  inherit kernelHeaders installLocales;
+
+  # The host/target system.
+  crossConfig = if (cross != null) then cross.config else null;
+
+  inherit (stdenv) is64bit;
+
+  enableParallelBuilding = true;
+
+  patches =
+    stdenv.lib.optional (fetchgit == null)
+    /* Fix for NIXPKGS-79: when doing host name lookups, when
+       nsswitch.conf contains a line like
+
+         hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
+
+       don't return an error when mdns4_minimal can't be found.  This
+       is a bug in Glibc: when a service can't be found, NSS should
+       continue to the next service unless "UNAVAIL=return" is set.
+       ("NOTFOUND=return" refers to the service returning a NOTFOUND
+       error, not the service itself not being found.)  The reason is
+       that the "status" variable (while initialised to UNAVAIL) is
+       outside of the loop that iterates over the services, the
+       "files" service sets status to NOTFOUND.  So when the call to
+       find "mdns4_minimal" fails, "status" will still be NOTFOUND,
+       and it will return instead of continuing to "dns".  Thus, the
+       line
+
+         hosts: mdns4_minimal [NOTFOUND=return] dns mdns4
+
+       does work because "status" will contain UNAVAIL after the
+       failure to find mdns4_minimal. */
+    ./nss-skip-unavail.patch
+  ++ [
+    /* Have rpcgen(1) look for cpp(1) in $PATH.  */
+    ./rpcgen-path.patch
+
+    /* Allow nixos and nix handle the locale-archive. */
+    ./nix-locale-archive.patch
+
+    /* Without this patch many KDE binaries crash. */
+    ./glibc-elf-localscope.patch
+  ];
+
+  postPatch = ''
+    # Needed for glibc to build with the gnumake 3.82
+    # http://comments.gmane.org/gmane.linux.lfs.support/31227
+    sed -i 's/ot \$/ot:\n\ttouch $@\n$/' manual/Makefile
+
+    # nscd needs libgcc, and we don't want it dynamically linked
+    # because we don't want it to depend on bootstrap-tools libs.
+    echo "LDFLAGS-nscd += -static-libgcc" >> nscd/Makefile
+  '';
+
+  configureFlags = [
+    "-C"
+    "--enable-add-ons"
+    "--sysconfdir=/etc"
+    "--localedir=/var/run/current-system/sw/lib/locale"
+    (if kernelHeaders != null
+     then "--with-headers=${kernelHeaders}/include"
+     else "--without-headers")
+    (if profilingLibraries
+     then "--enable-profile"
+     else "--disable-profile")
+  ] ++ stdenv.lib.optionals (cross != null) [
+    (if cross.withTLS then "--with-tls" else "--without-tls")
+    (if cross.float == "soft" then "--without-fp" else "--with-fp")
+    "--enable-kernel=2.6.0"
+    "--with-__thread"
+  ] ++ stdenv.lib.optionals (stdenv.system == "armv5tel-linux") [
+    "--host=arm-linux-gnueabi"
+    "--build=arm-linux-gnueabi"
+    "--without-fp"
+
+    # To avoid linking with -lgcc_s (dynamic link)
+    # so the glibc does not depend on its compiler store path
+    "libc_cv_as_needed=no"
+  ];
+
+  installFlags = [ "sysconfdir=$(out)/etc" ];
+  
+  buildInputs = stdenv.lib.optionals (cross != null) [ gccCross ]
+    ++ stdenv.lib.optional (mig != null) mig;
+
+  # Needed to install share/zoneinfo/zone.tab.  Set to impure /bin/sh to
+  # prevent a retained dependency on the bootstrap tools in the stdenv-linux
+  # bootstrap.
+  BASH_SHELL = "/bin/sh";
+
+  # Workaround for this bug:
+  #   http://sourceware.org/bugzilla/show_bug.cgi?id=411
+  # I.e. when gcc is compiled with --with-arch=i686, then the
+  # preprocessor symbol `__i686' will be defined to `1'.  This causes
+  # the symbol __i686.get_pc_thunk.dx to be mangled.
+  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString (stdenv.system == "i686-linux") "-U__i686";
+}
+
+# Remove the `gccCross' attribute so that the *native* glibc store path
+# doesn't depend on whether `gccCross' is null or not.
+// (removeAttrs args [ "gccCross" ]) //
+
+{
+  name = name + "-${version}" +
+    stdenv.lib.optionalString (cross != null) "-${cross.config}";
+
+  src =
+    if hurdHeaders != null
+    then fetchgit {
+      # Shamefully the "official" glibc won't build on GNU, so use the one
+      # maintained by the Hurd folks, `tschwinge/Roger_Whittaker' branch.
+      # See <http://www.gnu.org/software/hurd/source_repositories/glibc.html>.
+      url = "git://git.sv.gnu.org/hurd/glibc.git";
+      sha256 = "3fb3dd7030a4b6d3e144fa94c32a0c4f46f17f94e2dfbc6bef41cfc3198725ca";
+      rev = "d740cf9d201dc9ecb0335b0a585828dea9cce793";
+    }
+    else fetchurl {
+      url = "mirror://gnu/glibc/glibc-${version}.tar.bz2";
+      sha256 = "0fsvf5d6sib483rp7asdy8hs0dysxqkrvw316c82hsxy7vxa51bf";
+    };
+
+  # `fetchurl' is a function and thus should not be passed to the
+  # `derivation' primitive.
+  fetchurl = null;
+
+  # Remove absolute paths from `configure' & co.; build out-of-tree.
+  preConfigure = ''
+    export PWD_P=$(type -tP pwd)
+    for i in configure io/ftwtest-sh; do
+        # Can't use substituteInPlace here because replace hasn't been
+        # built yet in the bootstrap.
+        sed -i "$i" -e "s^/bin/pwd^$PWD_P^g"
+    done
+
+    ${if needsPorts then "tar xvf ${srcPorts}" else ""}
+
+    mkdir ../build
+    cd ../build
+
+    configureScript="`pwd`/../$sourceRoot/configure"
+
+    ${preConfigure}
+  '';
+
+  meta = {
+    homepage = http://www.gnu.org/software/libc/;
+    description = "The GNU C Library";
+
+    longDescription =
+      '' Any Unix-like operating system needs a C library: the library which
+         defines the "system calls" and other basic facilities such as
+         open, malloc, printf, exit...
+
+         The GNU C library is used as the C library in the GNU system and
+         most systems with the Linux kernel.
+      '';
+
+    license = "LGPLv2+";
+
+    maintainers = [ stdenv.lib.maintainers.ludo ];
+    platforms = stdenv.lib.platforms.linux;
+  } // meta;
+}
+
+//
+
+(if hurdHeaders != null
+ then {
+   # Work around the fact that the configure snippet that looks for
+   # <hurd/version.h> does not honor `--with-headers=$sysheaders' and that
+   # glibc expects Mach, Hurd, and pthread headers to be in the same place.
+   CPATH = "${hurdHeaders}/include:${machHeaders}/include:${libpthreadHeaders}/include";
+
+   # `fetchgit' is a function and thus should not be passed to the
+   # `derivation' primitive.
+   fetchgit = null;
+
+   # Install NSS stuff in the right place.
+   # XXX: This will be needed for all new glibcs and isn't Hurd-specific.
+   makeFlags = ''vardbdir="$out/var/db"'';
+ }
+ else { }))
diff --git a/pkgs/development/libraries/glibc/2.14/default.nix b/pkgs/development/libraries/glibc/2.14/default.nix
new file mode 100644
index 0000000000000..1b4e43b1013a5
--- /dev/null
+++ b/pkgs/development/libraries/glibc/2.14/default.nix
@@ -0,0 +1,97 @@
+{ stdenv, fetchurl, kernelHeaders
+, machHeaders ? null, hurdHeaders ? null, libpthreadHeaders ? null
+, mig ? null, fetchgit ? null
+, installLocales ? true
+, profilingLibraries ? false
+, gccCross ? null
+, debugSymbols ? false
+}:
+
+assert stdenv.gcc.gcc != null;
+
+let
+  build = import ./common.nix;
+  cross = if gccCross != null then gccCross.target else null;
+in
+  build cross ({
+    name = "glibc${if debugSymbols then "-debug" else ""}";
+
+    inherit fetchurl stdenv kernelHeaders installLocales profilingLibraries
+      gccCross;
+
+    builder = ./builder.sh;
+
+    # When building glibc from bootstrap-tools, we need libgcc_s at RPATH for
+    # any program we run, because the gcc will have been placed at a new
+    # store path than that determined when built (as a source for the
+    # bootstrap-tools tarball)
+    # Building from a proper gcc staying in the path where it was installed,
+    # libgcc_s will not be at {gcc}/lib, and gcc's libgcc will be found without
+    # any special hack.
+    preInstall = ''
+      if [ -f ${stdenv.gcc.gcc}/lib/libgcc_s.so.1 ]; then
+          mkdir -p $out/lib
+          ln -s ${stdenv.gcc.gcc}/lib/libgcc_s.so.1 $out/lib/libgcc_s.so.1
+      fi
+    '';
+
+    meta.description = "The GNU C Library";
+  }
+
+  //
+
+  (if debugSymbols
+   then {
+     # Build with debugging symbols, but leave optimizations on and don't
+     # attempt to keep the build tree.
+     dontStrip = true;
+     dontCrossStrip = true;
+     NIX_STRIP_DEBUG = 0;
+   }
+   else {})
+
+  //
+
+  (if hurdHeaders != null
+   then rec {
+     inherit machHeaders hurdHeaders libpthreadHeaders mig fetchgit;
+
+     propagatedBuildInputs = [ machHeaders hurdHeaders libpthreadHeaders ];
+
+     passthru = {
+       # When building GCC itself `propagatedBuildInputs' above is not
+       # honored, so we pass it here so that the GCC builder can do the right
+       # thing.
+       inherit propagatedBuildInputs;
+     };
+   }
+   else { })
+
+  //
+
+  (if cross != null
+   then {
+      preConfigure = ''
+        sed -i s/-lgcc_eh//g "../$sourceRoot/Makeconfig"
+
+        cat > config.cache << "EOF"
+        libc_cv_forced_unwind=yes
+        libc_cv_c_cleanup=yes
+        libc_cv_gnu89_inline=yes
+        # Only due to a problem in gcc configure scripts:
+        libc_cv_sparc64_tls=${if cross.withTLS then "yes" else "no"}
+        EOF
+        export BUILD_CC=gcc
+        export CC="$crossConfig-gcc"
+        export AR="$crossConfig-ar"
+        export RANLIB="$crossConfig-ranlib"
+
+        dontStrip=1
+      '';
+
+      # To avoid a dependency on the build system 'bash'.
+      preFixup = ''
+        rm $out/bin/{ldd,tzselect,catchsegv,xtrace}
+      '';
+    }
+   else {}))
diff --git a/pkgs/development/libraries/glibc/2.14/glibc-elf-localscope.patch b/pkgs/development/libraries/glibc/2.14/glibc-elf-localscope.patch
new file mode 100644
index 0000000000000..98f7f81087bb3
--- /dev/null
+++ b/pkgs/development/libraries/glibc/2.14/glibc-elf-localscope.patch
@@ -0,0 +1,82 @@
+diff -ru a/elf/dl-close.c b/elf/dl-close.c
+--- a/elf/dl-close.c	2011-02-04 00:35:03.000000000 +0100
++++ b/elf/dl-close.c	2011-02-22 02:16:12.367883000 +0100
+@@ -180,24 +186,28 @@
+       /* Signal the object is still needed.  */
+       l->l_idx = IDX_STILL_USED;
+ 
++#define mark_used(dmap) \
++  do {								\
++    if ((dmap)->l_idx != IDX_STILL_USED)			\
++      {								\
++	assert ((dmap)->l_idx >= 0 && (dmap)->l_idx < nloaded);	\
++								\
++	if (!used[(dmap)->l_idx])				\
++	  {							\
++	    used[(dmap)->l_idx] = 1;				\
++	    if ((dmap)->l_idx - 1 < done_index)			\
++	      done_index = (dmap)->l_idx - 1;			\
++	  }							\
++      }								\
++  } while (0)
++
+       /* Mark all dependencies as used.  */
+       if (l->l_initfini != NULL)
+ 	{
+ 	  struct link_map **lp = &l->l_initfini[1];
+ 	  while (*lp != NULL)
+ 	    {
+-	      if ((*lp)->l_idx != IDX_STILL_USED)
+-		{
+-		  assert ((*lp)->l_idx >= 0 && (*lp)->l_idx < nloaded);
+-
+-		  if (!used[(*lp)->l_idx])
+-		    {
+-		      used[(*lp)->l_idx] = 1;
+-		      if ((*lp)->l_idx - 1 < done_index)
+-			done_index = (*lp)->l_idx - 1;
+-		    }
+-		}
+-
++	      mark_used(*lp);
+ 	      ++lp;
+ 	    }
+ 	}
+@@ -206,19 +216,25 @@
+ 	for (unsigned int j = 0; j < l->l_reldeps->act; ++j)
+ 	  {
+ 	    struct link_map *jmap = l->l_reldeps->list[j];
+-
+-	    if (jmap->l_idx != IDX_STILL_USED)
+-	      {
+-		assert (jmap->l_idx >= 0 && jmap->l_idx < nloaded);
+-
+-		if (!used[jmap->l_idx])
+-		  {
+-		    used[jmap->l_idx] = 1;
+-		    if (jmap->l_idx - 1 < done_index)
+-		      done_index = jmap->l_idx - 1;
+-		  }
+-	      }
++	    mark_used(jmap);
+ 	  }
++      /* And the same for owners of our scopes; normally, our last
++	 scope provider would render us unused, but this can be
++	 prevented by the NODELETE flag. */
++      if (__builtin_expect(l->l_type == lt_loaded
++	                   && (l->l_flags_1 & DF_1_NODELETE), 0))
++	for (size_t cnt = 0; l->l_scope[cnt] != NULL; ++cnt)
++	  /* This relies on l_scope[] entries being always set either
++	     to its own l_symbolic_searchlist address, or some map's
++	     l_searchlist address.  */
++	  if (l->l_scope[cnt] != &l->l_symbolic_searchlist)
++	    {
++	      struct link_map *ls = (struct link_map *)
++		((char *) l->l_scope[cnt]
++		 - offsetof (struct link_map, l_searchlist));
++	      assert (ls->l_ns == nsid);
++	      mark_used(ls);
++	    }
+     }
+ 
+   /* Sort the entries.  */
diff --git a/pkgs/development/libraries/glibc/2.14/info.nix b/pkgs/development/libraries/glibc/2.14/info.nix
new file mode 100644
index 0000000000000..75bd996d9bc51
--- /dev/null
+++ b/pkgs/development/libraries/glibc/2.14/info.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchurl, texinfo, perl }:
+
+let build = import ./common.nix;
+in
+  /* null cross builder */
+  build null {
+    name = "glibc-info";
+
+    inherit fetchurl stdenv;
+
+    configureFlags = [ "--enable-add-ons" ];
+
+    buildInputs = [ texinfo perl ];
+
+    buildPhase = "make info";
+
+    # I don't know why the info is not generated in 'build'
+    # Somehow building the info still does not work, because the final
+    # libc.info hasn't a Top node.
+    installPhase = ''
+      mkdir -p "$out/share/info"
+      cp -v "../$sourceRoot/manual/"*.info* "$out/share/info"
+    '';
+
+    meta.description = "GNU Info manual of the GNU C Library";
+  }
diff --git a/pkgs/development/libraries/glibc/2.14/locales-builder.sh b/pkgs/development/libraries/glibc/2.14/locales-builder.sh
new file mode 100644
index 0000000000000..d732e208fa22a
--- /dev/null
+++ b/pkgs/development/libraries/glibc/2.14/locales-builder.sh
@@ -0,0 +1,17 @@
+# Glibc cannot have itself in its RPATH.
+export NIX_NO_SELF_RPATH=1
+
+source $stdenv/setup
+
+postConfigure() {
+    # Hack: get rid of the `-static' flag set by the bootstrap stdenv.
+    # This has to be done *after* `configure' because it builds some
+    # test binaries.
+    export NIX_CFLAGS_LINK=
+    export NIX_LDFLAGS_BEFORE=
+
+    export NIX_DONT_SET_RPATH=1
+    unset CFLAGS
+}
+
+genericBuild
diff --git a/pkgs/development/libraries/glibc/2.14/locales.nix b/pkgs/development/libraries/glibc/2.14/locales.nix
new file mode 100644
index 0000000000000..b7eae50ca385c
--- /dev/null
+++ b/pkgs/development/libraries/glibc/2.14/locales.nix
@@ -0,0 +1,47 @@
+/* This function builds just the `lib/locale/locale-archive' file from
+   Glibc and nothing else.  If `allLocales' is true, all supported
+   locales are included; otherwise, just the locales listed in
+   `locales'.  See localedata/SUPPORTED in the Glibc source tree for
+   the list of all supported locales:
+   http://sourceware.org/cgi-bin/cvsweb.cgi/libc/localedata/SUPPORTED?cvsroot=glibc
+*/
+
+{ stdenv, fetchurl, allLocales ? true, locales ? ["en_US.UTF-8/UTF-8"] }:
+
+let build = import ./common.nix;
+in
+  build null {
+    name = "glibc-locales";
+
+    inherit fetchurl stdenv;
+    installLocales = true;
+
+    builder = ./locales-builder.sh;
+
+    # Awful hack: `localedef' doesn't allow the path to `locale-archive'
+    # to be overriden, but you *can* specify a prefix, i.e. it will use
+    # <prefix>/<path-to-glibc>/lib/locale/locale-archive.  So we use
+    # $TMPDIR as a prefix, meaning that the locale-archive is placed in
+    # $TMPDIR/nix/store/...-glibc-.../lib/locale/locale-archive.
+    buildPhase =
+      ''
+        mkdir -p $TMPDIR/"$(dirname $(readlink -f $(type -p localedef)))/../lib/locale"
+
+        # Hack to allow building of the locales (needed since glibc-2.12)
+        sed -i -e "s,^LOCALEDEF=.*,LOCALEDEF=localedef --prefix=$TMPDIR," -e \
+            /library-path/d ../glibc-2*/localedata/Makefile
+        ${if allLocales then "" else
+            "echo SUPPORTED-LOCALES=\"${toString locales}\" > ../glibc-2*/localedata/SUPPORTED"}
+
+        make localedata/install-locales \
+            localedir=$out/lib/locale \
+      '';
+
+    installPhase =
+      ''
+        mkdir -p "$out/lib/locale"
+        cp -v "$TMPDIR/nix/store/"*"/lib/locale/locale-archive" "$out/lib/locale"
+      '';
+
+    meta.description = "Locale information for the GNU C Library";
+  }
diff --git a/pkgs/development/libraries/glibc/2.14/nix-locale-archive.patch b/pkgs/development/libraries/glibc/2.14/nix-locale-archive.patch
new file mode 100644
index 0000000000000..aca904f7ff445
--- /dev/null
+++ b/pkgs/development/libraries/glibc/2.14/nix-locale-archive.patch
@@ -0,0 +1,116 @@
+diff --git a/locale/loadarchive.c b/locale/loadarchive.c
+index d545f17..0d8638a 100644
+--- a/locale/loadarchive.c
++++ b/locale/loadarchive.c
+@@ -124,6 +124,25 @@ calculate_head_size (const struct locarhead *h)
+ }
+ 
+ 
++static int
++open_locale_archive ()
++{
++  int fd = -1;
++  char *path = getenv ("LOCALE_ARCHIVE_2_11");
++  char *path2 = getenv ("LOCALE_ARCHIVE");
++  const char *usualpath = "/usr/lib/locale/locale-archive";
++  if (path)
++    fd = open_not_cancel_2 (path, O_RDONLY|O_LARGEFILE);
++  if (path2 && fd < 0)
++    fd = open_not_cancel_2 (path2, O_RDONLY|O_LARGEFILE);
++  if (fd < 0)
++    fd = open_not_cancel_2 (archfname, O_RDONLY|O_LARGEFILE);
++  if (fd < 0)
++    fd = open_not_cancel_2 (usualpath, O_RDONLY|O_LARGEFILE);
++  return fd;
++}
++
++
+ /* Find the locale *NAMEP in the locale archive, and return the
+    internalized data structure for its CATEGORY data.  If this locale has
+    already been loaded from the archive, just returns the existing data
+@@ -203,7 +222,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
+       archmapped = &headmap;
+ 
+       /* The archive has never been opened.  */
+-      fd = open_not_cancel_2 (archfname, O_RDONLY|O_LARGEFILE);
++      fd = open_locale_archive ();
+       if (fd < 0)
+ 	/* Cannot open the archive, for whatever reason.  */
+ 	return NULL;
+@@ -394,7 +413,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
+ 	  if (fd == -1)
+ 	    {
+ 	      struct stat64 st;
+-	      fd = open_not_cancel_2 (archfname, O_RDONLY|O_LARGEFILE);
++	      fd = open_locale_archive ();
+ 	      if (fd == -1)
+ 		/* Cannot open the archive, for whatever reason.  */
+ 		return NULL;
+diff --git a/locale/programs/locale.c b/locale/programs/locale.c
+index 77262b7..fddc00d 100644
+--- a/locale/programs/locale.c
++++ b/locale/programs/locale.c
+@@ -628,6 +628,20 @@ nameentcmp (const void *a, const void *b)
+ 		  ((const struct nameent *) b)->name);
+ }
+ 
++static int
++open_nix_locale_archive (const char * fname, int access)
++{
++  int fd = -1;
++  char *path = getenv ("LOCALE_ARCHIVE_2_11");
++  char *path2 = getenv ("LOCALE_ARCHIVE");
++  if (path)
++    fd = open64 (path, access);
++  if (path2 && fd < 0)
++    fd = open64 (path2, access);
++  if (fd < 0)
++    fd = open64 (fname, access);
++  return fd;
++}
+ 
+ static int
+ write_archive_locales (void **all_datap, char *linebuf)
+@@ -641,7 +658,7 @@ write_archive_locales (void **all_datap, char *linebuf)
+   int fd, ret = 0;
+   uint32_t cnt;
+ 
+-  fd = open64 (ARCHIVE_NAME, O_RDONLY);
++  fd = open_nix_locale_archive (ARCHIVE_NAME, O_RDONLY);
+   if (fd < 0)
+     return 0;
+ 
+diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c
+index 85ba77d..3ad2af8 100644
+--- a/locale/programs/locarchive.c
++++ b/locale/programs/locarchive.c
+@@ -512,6 +512,20 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head)
+   *ah = new_ah;
+ }
+ 
++static int
++open_nix_locale_archive (const char * fname, int access)
++{
++  int fd = -1;
++  char *path = getenv ("LOCALE_ARCHIVE_2_11");
++  char *path2 = getenv ("LOCALE_ARCHIVE");
++  if (path)
++    fd = open64 (path, access);
++  if (path2 && fd < 0)
++    fd = open64 (path2, access);
++  if (fd < 0)
++    fd = open64 (fname, access);
++  return fd;
++}
+ 
+ void
+ open_archive (struct locarhandle *ah, bool readonly)
+@@ -531,7 +548,7 @@ open_archive (struct locarhandle *ah, bool readonly)
+   while (1)
+     {
+       /* Open the archive.  We must have exclusive write access.  */
+-      fd = open64 (archivefname, readonly ? O_RDONLY : O_RDWR);
++      fd = open_nix_locale_archive (archivefname, readonly ? O_RDONLY : O_RDWR);
+       if (fd == -1)
+ 	{
+ 	  /* Maybe the file does not yet exist.  */
diff --git a/pkgs/development/libraries/glibc/2.14/nss-skip-unavail.patch b/pkgs/development/libraries/glibc/2.14/nss-skip-unavail.patch
new file mode 100644
index 0000000000000..e48dc2bc0a6ed
--- /dev/null
+++ b/pkgs/development/libraries/glibc/2.14/nss-skip-unavail.patch
@@ -0,0 +1,21 @@
+diff -ru glibc-2.11.2-orig/sysdeps/posix/getaddrinfo.c glibc-2.11.2/sysdeps/posix/getaddrinfo.c
+--- glibc-2.11.2-orig/sysdeps/posix/getaddrinfo.c	2010-05-19 22:38:20.000000000 +0200
++++ glibc-2.11.2/sysdeps/posix/getaddrinfo.c	2010-08-05 18:39:54.259556327 +0200
+@@ -505,8 +505,6 @@
+ 	  int no_data = 0;
+ 	  int no_inet6_data = 0;
+ 	  service_user *nip = NULL;
+-	  enum nss_status inet6_status = NSS_STATUS_UNAVAIL;
+-	  enum nss_status status = NSS_STATUS_UNAVAIL;
+ 	  int no_more;
+ 	  int old_res_options;
+ 
+@@ -702,6 +700,8 @@
+ 
+ 	  while (!no_more)
+ 	    {
++ 	      enum nss_status inet6_status = NSS_STATUS_UNAVAIL;
++ 	      enum nss_status status = NSS_STATUS_UNAVAIL;
+ 	      no_data = 0;
+ 	      nss_gethostbyname4_r fct4
+ 		= __nss_lookup_function (nip, "gethostbyname4_r");
diff --git a/pkgs/development/libraries/glibc-2.9/rpcgen-path.patch b/pkgs/development/libraries/glibc/2.14/rpcgen-path.patch
index fbb03dd5fadee..fbb03dd5fadee 100644
--- a/pkgs/development/libraries/glibc-2.9/rpcgen-path.patch
+++ b/pkgs/development/libraries/glibc/2.14/rpcgen-path.patch
diff --git a/pkgs/development/libraries/glibc-2.5/binutils-ld.patch b/pkgs/development/libraries/glibc/2.5/binutils-ld.patch
index 4cd7ab3cec34d..4cd7ab3cec34d 100644
--- a/pkgs/development/libraries/glibc-2.5/binutils-ld.patch
+++ b/pkgs/development/libraries/glibc/2.5/binutils-ld.patch
diff --git a/pkgs/development/libraries/glibc-2.5/builder.sh b/pkgs/development/libraries/glibc/2.5/builder.sh
index bc80af83b9265..bc80af83b9265 100644
--- a/pkgs/development/libraries/glibc-2.5/builder.sh
+++ b/pkgs/development/libraries/glibc/2.5/builder.sh
diff --git a/pkgs/development/libraries/glibc-2.5/default.nix b/pkgs/development/libraries/glibc/2.5/default.nix
index 8b8c204a4803d..8b8c204a4803d 100644
--- a/pkgs/development/libraries/glibc-2.5/default.nix
+++ b/pkgs/development/libraries/glibc/2.5/default.nix
diff --git a/pkgs/development/libraries/glibc-2.5/glibc-getcwd-param-MAX.patch b/pkgs/development/libraries/glibc/2.5/glibc-getcwd-param-MAX.patch
index 8543dbbf1d76d..8543dbbf1d76d 100644
--- a/pkgs/development/libraries/glibc-2.5/glibc-getcwd-param-MAX.patch
+++ b/pkgs/development/libraries/glibc/2.5/glibc-getcwd-param-MAX.patch
diff --git a/pkgs/development/libraries/glibc-2.5/glibc-inline.patch b/pkgs/development/libraries/glibc/2.5/glibc-inline.patch
index 19e400e0d50f7..19e400e0d50f7 100644
--- a/pkgs/development/libraries/glibc-2.5/glibc-inline.patch
+++ b/pkgs/development/libraries/glibc/2.5/glibc-inline.patch
diff --git a/pkgs/development/libraries/glibc-2.5/glibc-pwd.patch b/pkgs/development/libraries/glibc/2.5/glibc-pwd.patch
index 07039718477fe..07039718477fe 100644
--- a/pkgs/development/libraries/glibc-2.5/glibc-pwd.patch
+++ b/pkgs/development/libraries/glibc/2.5/glibc-pwd.patch
diff --git a/pkgs/development/libraries/glibc-2.5/make-3-82-fix.patch b/pkgs/development/libraries/glibc/2.5/make-3-82-fix.patch
index 816e0aa528be3..816e0aa528be3 100644
--- a/pkgs/development/libraries/glibc-2.5/make-3-82-fix.patch
+++ b/pkgs/development/libraries/glibc/2.5/make-3-82-fix.patch
diff --git a/pkgs/development/libraries/glibc-2.5/x86-fnstsw.patch b/pkgs/development/libraries/glibc/2.5/x86-fnstsw.patch
index 45deb1d2d7192..45deb1d2d7192 100644
--- a/pkgs/development/libraries/glibc-2.5/x86-fnstsw.patch
+++ b/pkgs/development/libraries/glibc/2.5/x86-fnstsw.patch
diff --git a/pkgs/development/libraries/glibc-2.7/builder.sh b/pkgs/development/libraries/glibc/2.7/builder.sh
index d5a43229bfaf2..d5a43229bfaf2 100644
--- a/pkgs/development/libraries/glibc-2.7/builder.sh
+++ b/pkgs/development/libraries/glibc/2.7/builder.sh
diff --git a/pkgs/development/libraries/glibc-2.7/default.nix b/pkgs/development/libraries/glibc/2.7/default.nix
index 7eb34e88899ae..7eb34e88899ae 100644
--- a/pkgs/development/libraries/glibc-2.7/default.nix
+++ b/pkgs/development/libraries/glibc/2.7/default.nix
diff --git a/pkgs/development/libraries/glibc-2.7/nss-skip-unavail.patch b/pkgs/development/libraries/glibc/2.7/nss-skip-unavail.patch
index 4d29082f94196..4d29082f94196 100644
--- a/pkgs/development/libraries/glibc-2.7/nss-skip-unavail.patch
+++ b/pkgs/development/libraries/glibc/2.7/nss-skip-unavail.patch
diff --git a/pkgs/development/libraries/glibc-2.9/binutils-2.20.patch b/pkgs/development/libraries/glibc/2.9/binutils-2.20.patch
index ab3d6144d6eef..ab3d6144d6eef 100644
--- a/pkgs/development/libraries/glibc-2.9/binutils-2.20.patch
+++ b/pkgs/development/libraries/glibc/2.9/binutils-2.20.patch
diff --git a/pkgs/development/libraries/glibc-2.9/binutils-ld.patch b/pkgs/development/libraries/glibc/2.9/binutils-ld.patch
index ae70f145ce0d3..ae70f145ce0d3 100644
--- a/pkgs/development/libraries/glibc-2.9/binutils-ld.patch
+++ b/pkgs/development/libraries/glibc/2.9/binutils-ld.patch
diff --git a/pkgs/development/libraries/glibc-2.9/builder.sh b/pkgs/development/libraries/glibc/2.9/builder.sh
index c81a3ac2a9e90..c81a3ac2a9e90 100644
--- a/pkgs/development/libraries/glibc-2.9/builder.sh
+++ b/pkgs/development/libraries/glibc/2.9/builder.sh
diff --git a/pkgs/development/libraries/glibc-2.9/default.nix b/pkgs/development/libraries/glibc/2.9/default.nix
index 0cfad2990383f..b778743147e67 100644
--- a/pkgs/development/libraries/glibc-2.9/default.nix
+++ b/pkgs/development/libraries/glibc/2.9/default.nix
@@ -81,7 +81,7 @@ stdenv.mkDerivation rec {
   buildNativeInputs = stdenv.lib.optionals (cross != null) [ gccCross ];
 
   preInstall = if (cross != null) then ''
-    ensureDir $out/lib
+    mkdir -p $out/lib
     ln -s ${stdenv.gcc.gcc}/lib/libgcc_s.so.1 $out/lib/libgcc_s.so.1
   '' else "";
 
diff --git a/pkgs/development/libraries/glibc-2.9/headers.nix b/pkgs/development/libraries/glibc/2.9/headers.nix
index adb9a22f4810a..adb9a22f4810a 100644
--- a/pkgs/development/libraries/glibc-2.9/headers.nix
+++ b/pkgs/development/libraries/glibc/2.9/headers.nix
diff --git a/pkgs/development/libraries/glibc-2.9/headersbuilder.sh b/pkgs/development/libraries/glibc/2.9/headersbuilder.sh
index 23f4bd4cc6190..23f4bd4cc6190 100644
--- a/pkgs/development/libraries/glibc-2.9/headersbuilder.sh
+++ b/pkgs/development/libraries/glibc/2.9/headersbuilder.sh
diff --git a/pkgs/development/libraries/glibc-2.9/info.nix b/pkgs/development/libraries/glibc/2.9/info.nix
index 3201bb4744055..cc79bbece3d2e 100644
--- a/pkgs/development/libraries/glibc-2.9/info.nix
+++ b/pkgs/development/libraries/glibc/2.9/info.nix
@@ -36,7 +36,7 @@ stdenv.mkDerivation rec {
   # Somehow building the info still does not work, because the final
   # libc.info hasn't a Top node.
   installPhase = ''
-    ensureDir $out/share/info
+    mkdir -p $out/share/info
     cp ../$sourceRoot/manual/*.info $out/share/info
   '';
 
diff --git a/pkgs/development/libraries/glibc-2.9/locale-override.patch b/pkgs/development/libraries/glibc/2.9/locale-override.patch
index 108d0e35dacf0..108d0e35dacf0 100644
--- a/pkgs/development/libraries/glibc-2.9/locale-override.patch
+++ b/pkgs/development/libraries/glibc/2.9/locale-override.patch
diff --git a/pkgs/development/libraries/glibc-2.9/locales.nix b/pkgs/development/libraries/glibc/2.9/locales.nix
index 3046374ca3457..c7b1bb2bff0a1 100644
--- a/pkgs/development/libraries/glibc-2.9/locales.nix
+++ b/pkgs/development/libraries/glibc/2.9/locales.nix
@@ -56,7 +56,7 @@ stdenv.mkDerivation rec {
 
   installPhase =
     ''
-      ensureDir $out/lib/locale
+      mkdir -p $out/lib/locale
       cp $TMPDIR/nix/store/*/lib/locale/locale-archive $out/lib/locale/
     '';
 
diff --git a/pkgs/development/libraries/glibc-2.9/localesbuilder.sh b/pkgs/development/libraries/glibc/2.9/localesbuilder.sh
index a28f6bcbaeb37..a28f6bcbaeb37 100644
--- a/pkgs/development/libraries/glibc-2.9/localesbuilder.sh
+++ b/pkgs/development/libraries/glibc/2.9/localesbuilder.sh
diff --git a/pkgs/development/libraries/glibc-2.9/nss-skip-unavail.patch b/pkgs/development/libraries/glibc/2.9/nss-skip-unavail.patch
index dc09b5098707e..dc09b5098707e 100644
--- a/pkgs/development/libraries/glibc-2.9/nss-skip-unavail.patch
+++ b/pkgs/development/libraries/glibc/2.9/nss-skip-unavail.patch
diff --git a/pkgs/development/libraries/glibc/2.9/rpcgen-path.patch b/pkgs/development/libraries/glibc/2.9/rpcgen-path.patch
new file mode 100644
index 0000000000000..fbb03dd5fadee
--- /dev/null
+++ b/pkgs/development/libraries/glibc/2.9/rpcgen-path.patch
@@ -0,0 +1,72 @@
+By default, rpcgen(1) looks for cpp(1) from a list of fixed absolute paths
+(`/lib/cpp', etc.), which may only be overrided with the `-Y' option.  This
+patch makes it run any `cpp' command found in $PATH.
+
+--- glibc-2.7/sunrpc/rpc_main.c	2006-11-10 21:54:46.000000000 +0100
++++ glibc-2.7/sunrpc/rpc_main.c	2009-04-22 14:32:10.000000000 +0200
+@@ -79,7 +79,7 @@ static const char *cmdname;
+ 
+ static const char *svcclosetime = "120";
+ static int cppDefined;	/* explicit path for C preprocessor */
+-static const char *CPP = SUNOS_CPP;
++static const char *CPP = "cpp";
+ static const char CPPFLAGS[] = "-C";
+ static char *pathbuf;
+ static int cpp_pid;
+@@ -108,7 +108,6 @@ static char *extendfile (const char *fil
+ static void open_output (const char *infile, const char *outfile);
+ static void add_warning (void);
+ static void clear_args (void);
+-static void find_cpp (void);
+ static void open_input (const char *infile, const char *define);
+ static int check_nettype (const char *name, const char *list_to_check[]);
+ static void c_output (const char *infile, const char *define,
+@@ -327,31 +326,6 @@ clear_args (void)
+   argcount = FIXEDARGS;
+ }
+ 
+-/* make sure that a CPP exists */
+-static void
+-find_cpp (void)
+-{
+-  struct stat buf;
+-
+-  if (stat (CPP, &buf) < 0)
+-    {				/* /lib/cpp or explicit cpp does not exist */
+-      if (cppDefined)
+-	{
+-	  fprintf (stderr, _ ("cannot find C preprocessor: %s \n"), CPP);
+-	  crash ();
+-	}
+-      else
+-	{			/* try the other one */
+-	  CPP = SVR4_CPP;
+-	  if (stat (CPP, &buf) < 0)
+-	    {			/* can't find any cpp */
+-	      fputs (_ ("cannot find any C preprocessor (cpp)\n"), stdout);
+-	      crash ();
+-	    }
+-	}
+-    }
+-}
+-
+ /*
+  * Open input file with given define for C-preprocessor
+  */
+@@ -370,7 +344,6 @@ open_input (const char *infile, const ch
+   switch (cpp_pid)
+     {
+     case 0:
+-      find_cpp ();
+       putarg (0, CPP);
+       putarg (1, CPPFLAGS);
+       addarg (define);
+@@ -380,7 +353,7 @@ open_input (const char *infile, const ch
+       close (1);
+       dup2 (pd[1], 1);
+       close (pd[0]);
+-      execv (arglist[0], (char **) arglist);
++      execvp (arglist[0], (char **) arglist);
+       perror ("execv");
+       exit (1);
+     case -1:
diff --git a/pkgs/development/libraries/glibmm/2.28.x.nix b/pkgs/development/libraries/glibmm/2.28.x.nix
index 3c2c1fbadce4d..2c1d9a45c8d39 100644
--- a/pkgs/development/libraries/glibmm/2.28.x.nix
+++ b/pkgs/development/libraries/glibmm/2.28.x.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl_gnome, pkgconfig, glib, libsigcxx, xz }:
+{ stdenv, fetchurl_gnome, pkgconfig, glib, libsigcxx }:
 
 stdenv.mkDerivation rec {
   name = src.pkgname;
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
     sha256 = "1qyb8jb9avfzcdyhldxx7qljjhf30czwnh7c2r9p0x4nin2rjkpq";
   };
 
-  buildNativeInputs = [pkgconfig xz];
+  buildNativeInputs = [pkgconfig];
   propagatedBuildInputs = [glib libsigcxx];
 
   meta = {
diff --git a/pkgs/development/libraries/glibmm/2.30.x.nix b/pkgs/development/libraries/glibmm/2.30.x.nix
index e3565a4e61469..1ed2d0ede6252 100644
--- a/pkgs/development/libraries/glibmm/2.30.x.nix
+++ b/pkgs/development/libraries/glibmm/2.30.x.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl_gnome, pkgconfig, glib, libsigcxx, xz }:
+{ stdenv, fetchurl_gnome, pkgconfig, glib, libsigcxx }:
 
 stdenv.mkDerivation rec {
   name = src.pkgname;
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
     sha256 = "1d0dxq4iamch8igrnbvbfwkfpvcnjfzyr9iq2x8hi89b9k1kzbd7";
   };
 
-  buildNativeInputs = [pkgconfig xz];
+  buildNativeInputs = [pkgconfig];
   propagatedBuildInputs = [glib libsigcxx];
 
   meta = {
diff --git a/pkgs/development/libraries/gmp/4.3.2.nix b/pkgs/development/libraries/gmp/4.3.2.nix
index 4473e28585d94..d25b694115387 100644
--- a/pkgs/development/libraries/gmp/4.3.2.nix
+++ b/pkgs/development/libraries/gmp/4.3.2.nix
@@ -1,10 +1,6 @@
-{stdenv, fetchurl, m4, cxx ? true, static ? false}:
+{ stdenv, fetchurl, m4, cxx ? true }:
 
-let
-  staticFlags = if static then " --enable-static --disable-shared" else "";
-in
-
-stdenv.mkDerivation (rec {
+stdenv.mkDerivation rec {
   name = "gmp-4.3.2";
 
   src = fetchurl {
@@ -12,7 +8,7 @@ stdenv.mkDerivation (rec {
     sha256 = "0x8prpqi9amfcmi7r4zrza609ai9529pjaq0h4aw51i867064qck";
   };
 
-  buildNativeInputs = [m4];
+  buildNativeInputs = [ m4 ];
 
   # Prevent the build system from using sub-architecture-specific
   # instructions (e.g., SSE2 on i686).
@@ -25,10 +21,7 @@ stdenv.mkDerivation (rec {
     then "ln -sf configfsf.guess config.guess"
     else ''echo "Darwin host is `./config.guess`."'';
 
-  configureFlags = (if cxx then "--enable-cxx" else "--disable-cxx") +
-      staticFlags;
-
-  dontDisableStatic = if static then true else false;
+  configureFlags = if cxx then "--enable-cxx" else "--disable-cxx";
 
   doCheck = true;
 
@@ -64,10 +57,3 @@ stdenv.mkDerivation (rec {
     platforms = stdenv.lib.platforms.all;
   };
 }
-
-//
-
-# Don't run the native `strip' when cross-compiling.
-(if (stdenv ? cross)
- then { dontStrip = true; }
- else { }))
diff --git a/pkgs/development/libraries/gmp/5.0.3.nix b/pkgs/development/libraries/gmp/5.0.3.nix
index be2753c835228..8c3d24d2d113c 100644
--- a/pkgs/development/libraries/gmp/5.0.3.nix
+++ b/pkgs/development/libraries/gmp/5.0.3.nix
@@ -1,8 +1,4 @@
-{stdenv, fetchurl, m4, cxx ? true, static ? false}:
-
-let
-  staticFlags = if static then " --enable-static --disable-shared" else "";
-in
+{ stdenv, fetchurl, m4, cxx ? true }:
 
 stdenv.mkDerivation rec {
   name = "gmp-5.0.3";
@@ -12,16 +8,12 @@ stdenv.mkDerivation rec {
     sha256 = "dcafe9989c7f332b373e1f766af8e9cd790fc802fdec422a1910a6ef783480e3";
   };
 
-  buildNativeInputs = [m4];
-
-  # Prevent the build system from using sub-architecture-specific
-  # instructions (e.g., SSE2 on i686).
-  preConfigure = "ln -sf configfsf.guess config.guess";
-
-  configureFlags = if cxx then "--enable-cxx" else "--disable-cxx" +
-      staticFlags;
+  buildNativeInputs = [ m4 ];
 
-  dontDisableStatic = if static then true else false;
+  configureFlags =
+    # Build a "fat binary", with routines for several sub-architectures (x86).
+    [ "--enable-fat" ]
+    ++ (if cxx then [ "--enable-cxx" ] else [ "--disable-cxx" ]);
 
   doCheck = true;
 
diff --git a/pkgs/development/libraries/gnutls/default.nix b/pkgs/development/libraries/gnutls/default.nix
index 4c0dbb0298393..243b4b0191d03 100644
--- a/pkgs/development/libraries/gnutls/default.nix
+++ b/pkgs/development/libraries/gnutls/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, xz, zlib, lzo, libtasn1, nettle
+{ fetchurl, stdenv, zlib, lzo, libtasn1, nettle
 , guileBindings, guile, perl }:
 
 assert guileBindings -> guile != null;
@@ -25,7 +25,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ zlib lzo ]
     ++ stdenv.lib.optional guileBindings guile;
 
-  buildNativeInputs = [ xz perl ];
+  buildNativeInputs = [ perl ];
 
   propagatedBuildInputs = [ nettle libtasn1 ];
 
diff --git a/pkgs/development/libraries/gsm/default.nix b/pkgs/development/libraries/gsm/default.nix
index c01987bcc59d3..04fbb01a3bfcb 100644
--- a/pkgs/development/libraries/gsm/default.nix
+++ b/pkgs/development/libraries/gsm/default.nix
@@ -29,7 +29,7 @@ rec {
   phaseNames = ["createDirs" "setVars" "doMakeInstall"];
 
   createDirs = a.fullDepEntry ''
-    ensureDir "$out/"{bin,lib,share/man,share/info,include/gsm}
+    mkdir -p "$out/"{bin,lib,share/man,share/info,include/gsm}
   '' ["minInit" "defEnsureDir"];
 
   setVars = a.noDepEntry ''
diff --git a/pkgs/development/libraries/gtk+/2.24.x.nix b/pkgs/development/libraries/gtk+/2.24.x.nix
index e3908b2ba371b..c9e95ecc9c36f 100644
--- a/pkgs/development/libraries/gtk+/2.24.x.nix
+++ b/pkgs/development/libraries/gtk+/2.24.x.nix
@@ -23,7 +23,7 @@ stdenv.mkDerivation {
 
   enableParallelBuilding = true;
   
-  buildNativeInputs = [ perl pkgconfig xz ];
+  buildNativeInputs = [ perl pkgconfig ];
   
   propagatedBuildInputs =
     [ xlibs.xlibs glib atk pango gdk_pixbuf cairo
diff --git a/pkgs/development/libraries/gtk+/3.2.x.nix b/pkgs/development/libraries/gtk+/3.2.x.nix
index 826fb81cf8751..1fbd7f739362c 100644
--- a/pkgs/development/libraries/gtk+/3.2.x.nix
+++ b/pkgs/development/libraries/gtk+/3.2.x.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  buildNativeInputs = [ perl pkgconfig xz ];
+  buildNativeInputs = [ perl pkgconfig ];
 
   propagatedBuildInputs =
     [ xlibs.xlibs glib atk pango129 gdk_pixbuf cairo
diff --git a/pkgs/development/libraries/gtkmm/2.24.x.nix b/pkgs/development/libraries/gtkmm/2.24.x.nix
index 89e12bc4c1c69..56d151101c5d3 100644
--- a/pkgs/development/libraries/gtkmm/2.24.x.nix
+++ b/pkgs/development/libraries/gtkmm/2.24.x.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl_gnome, pkgconfig, gtk, glibmm, cairomm, pangomm, atkmm, xz }:
+{ stdenv, fetchurl_gnome, pkgconfig, gtk, glibmm, cairomm, pangomm, atkmm }:
 
 stdenv.mkDerivation rec {
   name = src.pkgname;
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
     sha256 = "0gcm91sc1a05c56kzh74l370ggj0zz8nmmjvjaaxgmhdq8lpl369";
   };
 
-  buildNativeInputs = [pkgconfig xz];
+  buildNativeInputs = [pkgconfig];
 
   propagatedBuildInputs = [ glibmm gtk atkmm cairomm pangomm ];
 
diff --git a/pkgs/development/libraries/haskell/network/2.3.0.7.nix b/pkgs/development/libraries/haskell/network/2.3.0.7.nix
new file mode 100644
index 0000000000000..3c0e0065ed9d7
--- /dev/null
+++ b/pkgs/development/libraries/haskell/network/2.3.0.7.nix
@@ -0,0 +1,18 @@
+{ cabal, parsec }:
+
+cabal.mkDerivation (self: {
+  pname = "network";
+  version = "2.3.0.7";
+  sha256 = "1rlzdacgaq8nv0bwczsrkw47rw4aamf9y4ynm3xjw0r3w1xcg9yv";
+  buildDepends = [ parsec ];
+  meta = {
+    homepage = "http://github.com/haskell/network";
+    description = "Low-level networking interface";
+    license = self.stdenv.lib.licenses.bsd3;
+    platforms = self.ghc.meta.platforms;
+    maintainers = [
+      self.stdenv.lib.maintainers.andres
+      self.stdenv.lib.maintainers.simons
+    ];
+  };
+})
diff --git a/pkgs/development/libraries/haskell/syb/0.3.5.nix b/pkgs/development/libraries/haskell/syb/0.3.5.nix
new file mode 100644
index 0000000000000..f15911c08bdc0
--- /dev/null
+++ b/pkgs/development/libraries/haskell/syb/0.3.5.nix
@@ -0,0 +1,17 @@
+{ cabal }:
+
+cabal.mkDerivation (self: {
+  pname = "syb";
+  version = "0.3.5";
+  sha256 = "17gwhn0rqjf9zkx1dsmsaj41qdjlk4mq5lzpqkgy3slq30nwwwbr";
+  meta = {
+    homepage = "http://www.cs.uu.nl/wiki/GenericProgramming/SYB";
+    description = "Scrap Your Boilerplate";
+    license = self.stdenv.lib.licenses.bsd3;
+    platforms = self.ghc.meta.platforms;
+    maintainers = [
+      self.stdenv.lib.maintainers.andres
+      self.stdenv.lib.maintainers.simons
+    ];
+  };
+})
diff --git a/pkgs/development/libraries/hawknl/default.nix b/pkgs/development/libraries/hawknl/default.nix
index 76f4a5a7dae05..78206de9f1417 100644
--- a/pkgs/development/libraries/hawknl/default.nix
+++ b/pkgs/development/libraries/hawknl/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation {
 
   preInstall = ''
     sed -i s,/usr/local,$out, src/makefile.linux
-    ensureDir $out/lib $out/include
+    mkdir -p $out/lib $out/include
   '';
 
   meta = {
diff --git a/pkgs/development/libraries/iniparser/default.nix b/pkgs/development/libraries/iniparser/default.nix
index 9b45dbb91ec8c..55c4dbff29605 100644
--- a/pkgs/development/libraries/iniparser/default.nix
+++ b/pkgs/development/libraries/iniparser/default.nix
@@ -13,14 +13,14 @@ stdenv.mkDerivation rec{
   buildFlags = "libiniparser.so";
 
   installPhase = ''
-    ensureDir $out/lib
+    mkdir -p $out/lib
     cp libiniparser.so.0 $out/lib
     ln -s libiniparser.so.0 $out/lib/libiniparser.so
 
-    ensureDir $out/include
+    mkdir -p $out/include
     cp src/*.h $out/include
 
-    ensureDir $out/share/doc/${name}
+    mkdir -p $out/share/doc/${name}
     for i in AUTHORS INSTALL LICENSE README; do
       bzip2 -c -9 $i > $out/share/doc/${name}/$i.bz2;
     done;
diff --git a/pkgs/development/libraries/irrlicht/default.nix b/pkgs/development/libraries/irrlicht/default.nix
index ccc088816c6ab..760ad096fd0b6 100644
--- a/pkgs/development/libraries/irrlicht/default.nix
+++ b/pkgs/development/libraries/irrlicht/default.nix
@@ -11,6 +11,10 @@ stdenv.mkDerivation rec {
     sha256 = "0v31l3k0fzy7isdsx2sh0baaixzlml1m7vgz6cd0015d9f5n99vl";
   };
 
+  patchPhase = ''
+    sed -i /stdcall-alias/d source/Irrlicht/Makefile
+  '';
+
   preConfigure = ''
     cd source/Irrlicht
   '';
diff --git a/pkgs/development/libraries/isl/default.nix b/pkgs/development/libraries/isl/default.nix
index 2261baba0309c..aaec37eae8f25 100644
--- a/pkgs/development/libraries/isl/default.nix
+++ b/pkgs/development/libraries/isl/default.nix
@@ -1,23 +1,22 @@
-{stdenv, fetchurl, gmp, static ? false}:
+{ stdenv, fetchurl, gmp }:
 
 stdenv.mkDerivation rec {
-  name = "isl-0.07";             # CLooG 0.16.3 fails to build with ISL 0.08.
+  name = "isl-0.07"; # CLooG 0.16.3 fails to build with ISL 0.08.
 
   src = fetchurl {
-    url = "http://www.kotnet.org/~skimo/isl/${name}.tar.bz2";
+    urls = [
+        "http://www.kotnet.org/~skimo/isl/${name}.tar.bz2"
+        "ftp://ftp.linux.student.kuleuven.be/pub/people/skimo/isl/${name}.tar.bz2"
+      ];
     sha256 = "0kpxmvhrwwdygqqafqzjf9xiksq7paac2x24g9jhr3f9ajj3zkyx";
   };
 
   buildInputs = [ gmp ];
 
-  dontDisableStatic = static;
-  configureFlags =
-    stdenv.lib.optionals static [ " --enable-static" "--disable-shared" ];
-
   meta = {
     homepage = http://www.kotnet.org/~skimo/isl/;
     license = "LGPLv2.1";
-    description = "A library for manipulating sets and relations of integer points bounded by linear constraints.";
+    description = "A library for manipulating sets and relations of integer points bounded by linear constraints";
     maintainers = [ stdenv.lib.maintainers.shlevy ];
     platforms = stdenv.lib.platforms.all;
   };
diff --git a/pkgs/development/libraries/java/geoipjava/default.nix b/pkgs/development/libraries/java/geoipjava/default.nix
index 1420d4f2a42e2..a924e2adfa639 100644
--- a/pkgs/development/libraries/java/geoipjava/default.nix
+++ b/pkgs/development/libraries/java/geoipjava/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation {
     '';
   installPhase =
     ''
-      ensureDir $out/share/java
+      mkdir -p $out/share/java
       cp maxmindgeoip.jar $out/share/java
     '';
   meta = {
diff --git a/pkgs/development/libraries/java/gwt-dragdrop/builder.sh b/pkgs/development/libraries/java/gwt-dragdrop/builder.sh
index 605daff0cc85c..d37e110011e8b 100644
--- a/pkgs/development/libraries/java/gwt-dragdrop/builder.sh
+++ b/pkgs/development/libraries/java/gwt-dragdrop/builder.sh
@@ -1,4 +1,4 @@
 source $stdenv/setup
 
-ensureDir $out/share/java
+mkdir -p $out/share/java
 cp $src $out/share/java/$name.jar
diff --git a/pkgs/development/libraries/java/gwt-widgets/builder.sh b/pkgs/development/libraries/java/gwt-widgets/builder.sh
index f8961eb4f0481..8c2502385f2b5 100644
--- a/pkgs/development/libraries/java/gwt-widgets/builder.sh
+++ b/pkgs/development/libraries/java/gwt-widgets/builder.sh
@@ -2,5 +2,5 @@ source $stdenv/setup
 
 tar xfvz $src
 cd gwt-widgets-*
-ensureDir $out/share/java
+mkdir -p $out/share/java
 cp gwt-widgets-*.jar $out/share/java
diff --git a/pkgs/development/libraries/java/hsqldb/builder.sh b/pkgs/development/libraries/java/hsqldb/builder.sh
index 2f146a5234875..d7de23ab95eba 100755
--- a/pkgs/development/libraries/java/hsqldb/builder.sh
+++ b/pkgs/development/libraries/java/hsqldb/builder.sh
@@ -2,5 +2,5 @@ source $stdenv/setup
 
 unzip $src
 cd hsqldb*
-ensureDir $out
+mkdir -p $out
 cp -R * $out/
diff --git a/pkgs/development/libraries/java/hydra-ant-logger/default.nix b/pkgs/development/libraries/java/hydra-ant-logger/default.nix
index bb8c67285c5ab..1439c6101ab94 100644
--- a/pkgs/development/libraries/java/hydra-ant-logger/default.nix
+++ b/pkgs/development/libraries/java/hydra-ant-logger/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
   '';
 
   installPhase = '' 
-    ensureDir "$out/lib/java"
+    mkdir -p "$out/lib/java"
     cp -v *.jar "$out/lib/java"
   '';
 }
diff --git a/pkgs/development/libraries/java/jetty-gwt/default.nix b/pkgs/development/libraries/java/jetty-gwt/default.nix
index e384e35b23fa9..03433048270fb 100644
--- a/pkgs/development/libraries/java/jetty-gwt/default.nix
+++ b/pkgs/development/libraries/java/jetty-gwt/default.nix
@@ -7,7 +7,7 @@ stdenv.mkDerivation {
     sha256 = "17x8ss75rx9xjn93rq861mdn9d6gw87rbrf24blawa6ahhb56ppf";
   };
   buildCommand = ''
-    ensureDir $out/share/java
+    mkdir -p $out/share/java
     cp $src $out/share/java/$name.jar
   '';
 }
diff --git a/pkgs/development/libraries/java/jetty-util/default.nix b/pkgs/development/libraries/java/jetty-util/default.nix
index 8f1f676c10708..349339aad440c 100644
--- a/pkgs/development/libraries/java/jetty-util/default.nix
+++ b/pkgs/development/libraries/java/jetty-util/default.nix
@@ -7,7 +7,7 @@ stdenv.mkDerivation {
     sha256 = "1ld94lb5dk7y6sjg1rq8zdk97wiy56ik5vbgy7yjj4f6rz5pxbyq";
   };
   buildCommand = ''
-    ensureDir $out/share/java
+    mkdir -p $out/share/java
     cp $src $out/share/java/$name.jar
   '';
 }
diff --git a/pkgs/development/libraries/java/rhino/default.nix b/pkgs/development/libraries/java/rhino/default.nix
index 300266fff5c0a..800ae7ba71858 100644
--- a/pkgs/development/libraries/java/rhino/default.nix
+++ b/pkgs/development/libraries/java/rhino/default.nix
@@ -23,7 +23,7 @@ in
       '' find -name \*.jar -or -name \*.class -exec rm -v {} \;
 
          # The build process tries to download it by itself.
-         ensureDir "build/tmp-xbean"
+         mkdir -p "build/tmp-xbean"
          ln -sv "${xbeans}" "build/tmp-xbean/xbean.zip"
       '';
 
@@ -34,7 +34,7 @@ in
 
     # FIXME: Install javadoc as well.
     installPhase =
-      '' ensureDir "$out/lib/java"
+      '' mkdir -p "$out/lib/java"
          cp -v *.jar "$out/lib/java"
       '';
 
diff --git a/pkgs/development/libraries/java/saxon/default8.nix b/pkgs/development/libraries/java/saxon/default8.nix
index ab67fc6b89340..bf1ee340d46f8 100644
--- a/pkgs/development/libraries/java/saxon/default8.nix
+++ b/pkgs/development/libraries/java/saxon/default8.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
 
   buildCommand = "
     unzip $src -d $out
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cat > $out/bin/saxon8 <<EOF
 #! $shell
 export JAVA_HOME=${jre}
diff --git a/pkgs/development/libraries/java/smack/builder.sh b/pkgs/development/libraries/java/smack/builder.sh
index 276e3f6e6a912..bf86d59497e46 100644
--- a/pkgs/development/libraries/java/smack/builder.sh
+++ b/pkgs/development/libraries/java/smack/builder.sh
@@ -2,5 +2,5 @@ source $stdenv/setup
 
 tar xfvz $src
 cd smack*
-ensureDir $out/share/java
+mkdir -p $out/share/java
 cp *.jar $out/share/java
diff --git a/pkgs/development/libraries/java/swt/builder.sh b/pkgs/development/libraries/java/swt/builder.sh
index 0a2f304801ecf..9f678d7158bb9 100644
--- a/pkgs/development/libraries/java/swt/builder.sh
+++ b/pkgs/development/libraries/java/swt/builder.sh
@@ -7,12 +7,12 @@ export JAVA_HOME=${jdk}
 echo $JAVA_HOME=${jdk}
 sh ./build.sh make_swt make_atk
 
-ensureDir $out/lib
+mkdir -p $out/lib
 cp *.so $out/lib
 
 mkdir out
 javac -d out/ $(find org/ -name "*.java")
 
-ensureDir $out/jars
+mkdir -p $out/jars
 cp version.txt out/
 cd out && jar -c * > $out/jars/swt.jar
diff --git a/pkgs/development/libraries/java/xalanj/default.nix b/pkgs/development/libraries/java/xalanj/default.nix
index ededecdf0e510..0aee98d27bdab 100644
--- a/pkgs/development/libraries/java/xalanj/default.nix
+++ b/pkgs/development/libraries/java/xalanj/default.nix
@@ -24,7 +24,7 @@ in
 
     # FIXME: Install javadoc as well.
     installPhase =
-      '' ensureDir "$out/lib/java"
+      '' mkdir -p "$out/lib/java"
          cp -v build/x*.jar "$out/lib/java"
       '';
 
diff --git a/pkgs/development/libraries/java/xerces/default.nix b/pkgs/development/libraries/java/xerces/default.nix
index 545bb21508c83..a40c30ae6c720 100644
--- a/pkgs/development/libraries/java/xerces/default.nix
+++ b/pkgs/development/libraries/java/xerces/default.nix
@@ -26,7 +26,7 @@ in
 
     # FIXME: Install javadoc as well.
     installPhase =
-      '' ensureDir "$out/lib/java"
+      '' mkdir -p "$out/lib/java"
          cp -v build/xerces*.jar "$out/lib/java"
       '';
 
diff --git a/pkgs/development/libraries/json-glib/default.nix b/pkgs/development/libraries/json-glib/default.nix
index 25d2f1c443556..ace271b7a3577 100644
--- a/pkgs/development/libraries/json-glib/default.nix
+++ b/pkgs/development/libraries/json-glib/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl_gnome, glib, pkgconfig, xz }:
+{ stdenv, fetchurl_gnome, glib, pkgconfig }:
 
 stdenv.mkDerivation rec {
   name = src.pkgname;
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
   };
 
   propagatedBuildInputs = [ glib ];
-  buildNativeInputs = [ pkgconfig xz ];
+  buildNativeInputs = [ pkgconfig ];
 
   meta = {
     homepage = http://live.gnome.org/JsonGlib;
diff --git a/pkgs/development/libraries/levmar/default.nix b/pkgs/development/libraries/levmar/default.nix
index a17cdf0b4d586..3028ba7367cb4 100644
--- a/pkgs/development/libraries/levmar/default.nix
+++ b/pkgs/development/libraries/levmar/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   '';
 
   installPhase = ''
-    ensureDir $out/include $out/lib
+    mkdir -p $out/include $out/lib
     cp lm.h $out/include
     cp liblevmar.a $out/lib
   '';
diff --git a/pkgs/development/libraries/libarchive/default.nix b/pkgs/development/libraries/libarchive/default.nix
index ab862fd56f0f9..36e345043e3c1 100644
--- a/pkgs/development/libraries/libarchive/default.nix
+++ b/pkgs/development/libraries/libarchive/default.nix
@@ -1,4 +1,4 @@
-{fetchurl, stdenv, acl, openssl, libxml2, attr, zlib, bzip2, xz, e2fsprogs
+{fetchurl, stdenv, acl, openssl, libxml2, attr, zlib, bzip2, e2fsprogs
 , sharutils}:
 
 stdenv.mkDerivation rec {
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
     sha256 = "16095d15334b3c8dbb02db5af3d415f12c1c3bdd4eb43af7bbc36ab7572c0b7a";
   };
 
-  propagatedBuildInputs = [libxml2 zlib bzip2 xz openssl] ++
+  propagatedBuildInputs = [libxml2 zlib bzip2 openssl] ++
     (if stdenv.isLinux then [e2fsprogs attr acl] else []);
 
   buildInputs = [sharutils];
diff --git a/pkgs/development/libraries/libav/default.nix b/pkgs/development/libraries/libav/default.nix
index 0d6637d6116be..3fb1650bf46fe 100644
--- a/pkgs/development/libraries/libav/default.nix
+++ b/pkgs/development/libraries/libav/default.nix
@@ -45,7 +45,7 @@ stdenv.mkDerivation rec {
     ++ stdenv.lib.optional xvidSupport "--enable-libxvid"
     ++ stdenv.lib.optional faacSupport "--enable-libfaac --enable-nonfree";
 
-  buildInputs = [ pkgconfig lame yasm xz ]
+  buildInputs = [ pkgconfig lame yasm ]
     ++ stdenv.lib.optional mp3Support lame
     ++ stdenv.lib.optional speexSupport speex
     ++ stdenv.lib.optional theoraSupport libtheora
diff --git a/pkgs/development/libraries/libdmtx/default.nix b/pkgs/development/libraries/libdmtx/default.nix
index f9b864143ec52..97622bb7b24b1 100644
--- a/pkgs/development/libraries/libdmtx/default.nix
+++ b/pkgs/development/libraries/libdmtx/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, imagemagick, xz }:
+{ stdenv, fetchurl, pkgconfig, imagemagick }:
 
 stdenv.mkDerivation rec {
   name = "libdmtx-0.7.2";
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
 
   buildNativeInputs = [ pkgconfig ];
 
-  propagatedBuildInputs = [ imagemagick xz ];
+  propagatedBuildInputs = [ imagemagick ];
 
   meta = {
     description = "An open source software for reading and writing Data Matrix barcodes";
diff --git a/pkgs/development/libraries/libdvdnav/default.nix b/pkgs/development/libraries/libdvdnav/default.nix
index 7d6ddd61581fe..4ba938911a41e 100644
--- a/pkgs/development/libraries/libdvdnav/default.nix
+++ b/pkgs/development/libraries/libdvdnav/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
   configureScript = "./configure2"; # wtf?
 
   preConfigure = ''
-    ensureDir $out
+    mkdir -p $out
   '';
 
   meta = {
diff --git a/pkgs/development/libraries/libdvdread/default.nix b/pkgs/development/libraries/libdvdread/default.nix
index 30fd6835dfbb2..ee5d2e5e50e01 100644
--- a/pkgs/development/libraries/libdvdread/default.nix
+++ b/pkgs/development/libraries/libdvdread/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation {
   configureScript = "./configure2"; # wtf?
 
   preConfigure = ''
-    ensureDir $out
+    mkdir -p $out
   '';
 
   postInstall = ''
diff --git a/pkgs/development/libraries/libf2c/default.nix b/pkgs/development/libraries/libf2c/default.nix
index b14809d47bf85..edcf177add7fe 100644
--- a/pkgs/development/libraries/libf2c/default.nix
+++ b/pkgs/development/libraries/libf2c/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
   makeFlags = "-f makefile.u";
 
   installPhase = ''
-    ensureDir $out/include $out/lib
+    mkdir -p $out/include $out/lib
     cp libf2c.a $out/lib
     cp f2c.h $out/include
   '';
diff --git a/pkgs/development/libraries/libgsf/default.nix b/pkgs/development/libraries/libgsf/default.nix
index 3f6de4cfb1d72..168a2e7381eff 100644
--- a/pkgs/development/libraries/libgsf/default.nix
+++ b/pkgs/development/libraries/libgsf/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
     sha256 = "0gvq1gbbcl078s3kgdc508jp7p3a3ps34fj4pf8vsamprbikpwm5";
   };
 
-  buildNativeInputs = [ xz intltool pkgconfig ];
+  buildNativeInputs = [ intltool pkgconfig ];
   buildInputs =
     [ perl perlXMLParser gettext bzip2 gnome_vfs python ];
 
diff --git a/pkgs/development/libraries/libmilter/default.nix b/pkgs/development/libraries/libmilter/default.nix
index 508827b9b3d50..c8fa978534d9c 100644
--- a/pkgs/development/libraries/libmilter/default.nix
+++ b/pkgs/development/libraries/libmilter/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
   };
 
   buildPhase = '' 
-    ensureDir $out/lib
+    mkdir -p $out/lib
     cd libmilter
     cat > a.m4 <<EOF
       define(\`confEBINDIR', \`$out/libexec')
diff --git a/pkgs/development/libraries/libopensc-dnie/default.nix b/pkgs/development/libraries/libopensc-dnie/default.nix
index a3a6a6423d875..ad524c21ff10e 100644
--- a/pkgs/development/libraries/libopensc-dnie/default.nix
+++ b/pkgs/development/libraries/libopensc-dnie/default.nix
@@ -34,7 +34,7 @@ stdenv.mkDerivation rec {
 
     sed -i s,/usr,$out, usr/lib/pkgconfig/*
    
-    ensureDir $out
+    mkdir -p $out
     cp -R usr/lib $out
     cp -R usr/share $out
   '';
diff --git a/pkgs/development/libraries/libpcap/default.nix b/pkgs/development/libraries/libpcap/default.nix
index 7ec95f03eff7c..c6446ab27a542 100644
--- a/pkgs/development/libraries/libpcap/default.nix
+++ b/pkgs/development/libraries/libpcap/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
   
   configureFlags = "--with-pcap=linux";
 
-  preInstall = ''ensureDir $out/bin'';
+  preInstall = ''mkdir -p $out/bin'';
   
   patches = [ ./libpcap_amd64.patch ];
 
diff --git a/pkgs/development/libraries/libpng/default.nix b/pkgs/development/libraries/libpng/default.nix
index 5a584e54af0ab..a79f05ab093de 100644
--- a/pkgs/development/libraries/libpng/default.nix
+++ b/pkgs/development/libraries/libpng/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, zlib, xz }:
+{ stdenv, fetchurl, zlib }:
 
 assert zlib != null;
 
@@ -12,8 +12,6 @@ stdenv.mkDerivation rec {
 
   propagatedBuildInputs = [ zlib ];
 
-  buildNativeInputs = [ xz ];
-
   passthru = { inherit zlib; };
 
   meta = {
diff --git a/pkgs/development/libraries/libpseudo/default.nix b/pkgs/development/libraries/libpseudo/default.nix
index 4e13e5768f869..29a8c459c34cd 100644
--- a/pkgs/development/libraries/libpseudo/default.nix
+++ b/pkgs/development/libraries/libpseudo/default.nix
@@ -12,8 +12,8 @@ stdenv.mkDerivation rec {
   '';
 
   preInstall = ''
-    ensureDir $out/include
-    ensureDir $out/lib
+    mkdir -p $out/include
+    mkdir -p $out/lib
   '';
 
   buildInputs = [pkgconfig glib ncurses];
diff --git a/pkgs/development/libraries/libsigcxx/default.nix b/pkgs/development/libraries/libsigcxx/default.nix
index 6d19ce55d3d03..c8aa87b26e0c3 100644
--- a/pkgs/development/libraries/libsigcxx/default.nix
+++ b/pkgs/development/libraries/libsigcxx/default.nix
@@ -1,14 +1,14 @@
-{stdenv, fetchurl, pkgconfig}:
+{ stdenv, fetchurl, pkgconfig, gnum4 }:
 
 stdenv.mkDerivation rec {
-  name = "libsigc++-2.2.3";
+  name = "libsigc++-2.2.10";
   
   src = fetchurl {
-    url = "http://ftp.gnome.org/pub/GNOME/sources/libsigc++/2.2/${name}.tar.bz2";
-    sha256 = "0hjh7834mbp2n5qnc7n1r3l70j9g06ibv7kbmhix9b101w6ypnak";
+    url = "http://ftp.gnome.org/pub/GNOME/sources/libsigc++/2.2/${name}.tar.xz";
+    sha256 = "8ceb6f2732f5399ef50d5b70f433d49945a12e0900b8f9f43c135866a2e5bf47";
   };
 
-  buildInputs = [pkgconfig];
+  buildInputs = [ pkgconfig gnum4 ];
 
   meta = {
     homepage = http://libsigc.sourceforge.net/;
diff --git a/pkgs/development/libraries/libsigsegv/default.nix b/pkgs/development/libraries/libsigsegv/default.nix
index 8987797ca8b2b..b0a726ed7f35b 100644
--- a/pkgs/development/libraries/libsigsegv/default.nix
+++ b/pkgs/development/libraries/libsigsegv/default.nix
@@ -1,11 +1,11 @@
 { fetchurl, stdenv }:
 
 stdenv.mkDerivation rec {
-  name = "libsigsegv-2.8";
+  name = "libsigsegv-2.10";
 
   src = fetchurl {
     url = "mirror://gnu/libsigsegv/${name}.tar.gz";
-    sha256 = "052vcxgajdlvc77dqcs48axjz698r1g2gyagz2qcr6zvkyw304w6";
+    sha256 = "16hrs8k3nmc7a8jam5j1fpspd6sdpkamskvsdpcw6m29vnis8q44";
   };
 
   doCheck = true;
diff --git a/pkgs/development/libraries/libtirpc/default.nix b/pkgs/development/libraries/libtirpc/default.nix
new file mode 100644
index 0000000000000..d9678f646b8c8
--- /dev/null
+++ b/pkgs/development/libraries/libtirpc/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl }:
+
+let
+  version = "0.2.2";
+in
+stdenv.mkDerivation {
+  name = "libtirpc-${version}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/libtirpc/libtirpc-${version}.tar.bz2";
+    sha256 = "f05eb17c85d62423858b8f74512cfe66a9ae1cedf93f03c2a0a32e04f0a33705";
+  };
+
+  meta = {
+    homepage = "http://sourceforge.net/projects/libtirpc/";
+    description = "a port of Suns Transport-Independent RPC library to Linux";
+    license = stdenv.lib.licenses.bsd3;
+
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.lib.maintainers.simons ];
+  };
+}
diff --git a/pkgs/development/libraries/libviper/default.nix b/pkgs/development/libraries/libviper/default.nix
index b9dbaf23512d3..b292580e70524 100644
--- a/pkgs/development/libraries/libviper/default.nix
+++ b/pkgs/development/libraries/libviper/default.nix
@@ -12,8 +12,8 @@ stdenv.mkDerivation rec {
   '';
 
   preInstall = ''
-    ensureDir $out/include
-    ensureDir $out/lib
+    mkdir -p $out/include
+    mkdir -p $out/lib
   '';
 
   buildInputs = [pkgconfig glib ncurses gpm];
diff --git a/pkgs/development/libraries/libvirt/default.nix b/pkgs/development/libraries/libvirt/default.nix
index bf4d858f023f3..2e7e4a57e9f8d 100644
--- a/pkgs/development/libraries/libvirt/default.nix
+++ b/pkgs/development/libraries/libvirt/default.nix
@@ -24,7 +24,7 @@ stdenv.mkDerivation {
       patchShebangs . # fixes /usr/bin/python references
     '';
 
-  configureFlags = "--localstatedir=/var --sysconfdir=/etc --with-init-script=redhat";
+  configureFlags = "--localstatedir=/var --sysconfdir=/etc --with-init-script=redhat --without-macvtap";
 
   installFlags = "localstatedir=$(TMPDIR)/var sysconfdir=$(out)/etc";
 
diff --git a/pkgs/development/libraries/libvterm/default.nix b/pkgs/development/libraries/libvterm/default.nix
index b449d9c3ed38f..20433ab145882 100644
--- a/pkgs/development/libraries/libvterm/default.nix
+++ b/pkgs/development/libraries/libvterm/default.nix
@@ -12,8 +12,8 @@ stdenv.mkDerivation rec {
   '';
 
   preInstall = ''
-    ensureDir $out/include
-    ensureDir $out/lib
+    mkdir -p $out/include
+    mkdir -p $out/lib
   '';
 
   buildInputs = [pkgconfig glib ncurses];
diff --git a/pkgs/development/libraries/libwpd/default.nix b/pkgs/development/libraries/libwpd/default.nix
index dc3f8b5352de2..d857b6e17ea41 100644
--- a/pkgs/development/libraries/libwpd/default.nix
+++ b/pkgs/development/libraries/libwpd/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, glib, libgsf, libxml2, xz }:
+{ stdenv, fetchurl, pkgconfig, glib, libgsf, libxml2 }:
 
 stdenv.mkDerivation rec {
   name = "libwpd-0.9.4";
@@ -10,5 +10,5 @@ stdenv.mkDerivation rec {
   
   buildInputs = [ glib libgsf libxml2 ];
 
-  buildNativeInputs = [ pkgconfig xz ];
+  buildNativeInputs = [ pkgconfig ];
 }
diff --git a/pkgs/development/libraries/libwpg/default.nix b/pkgs/development/libraries/libwpg/default.nix
index 3da153c3dc5ab..d140b8b8a0cdf 100644
--- a/pkgs/development/libraries/libwpg/default.nix
+++ b/pkgs/development/libraries/libwpg/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, libwpd, xz }:
+{ stdenv, fetchurl, pkgconfig, libwpd }:
 
 stdenv.mkDerivation rec {
   name = "libwpg-0.2.1";
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs = [ libwpd ];
-  buildNativeInputs = [ pkgconfig xz ];
+  buildNativeInputs = [ pkgconfig ];
 
   meta = {
     homepage = http://libwpg.sourceforge.net;
diff --git a/pkgs/development/libraries/libxcrypt/default.nix b/pkgs/development/libraries/libxcrypt/default.nix
index 1f45207382eeb..9122335b34ac2 100644
--- a/pkgs/development/libraries/libxcrypt/default.nix
+++ b/pkgs/development/libraries/libxcrypt/default.nix
@@ -11,4 +11,7 @@ stdenv.mkDerivation {
     url = ftp://ftp.suse.com/pub/people/kukuk/libxcrypt/libxcrypt-3.0.2.tar.bz2;
     sha256 = "15l2xvhi3r3b40x4665c101ikylh5xsbpw03gnszypfjgn1jkcii";
   };
+
+  patches = [ ./gcc46.patch ];
+
 }
diff --git a/pkgs/development/libraries/libxcrypt/gcc46.patch b/pkgs/development/libraries/libxcrypt/gcc46.patch
new file mode 100644
index 0000000000000..0664f96aa6888
--- /dev/null
+++ b/pkgs/development/libraries/libxcrypt/gcc46.patch
@@ -0,0 +1,18 @@
+For gcc 4.6 to build this. Otherwise it says 's unused variable', and it's built
+with -Werror.
+
+diff --git a/src/cert.c b/src/cert.c
+index 28c7b11..34570a4 100644
+--- a/src/cert.c
++++ b/src/cert.c
+@@ -87,9 +87,7 @@ char *cp;
+ 	int i,j,t;
+ 
+ 	for(i=0;i<8;i++){
+-		int s;
+-                  
+-                s = scanf("%2x",&t);
++                scanf("%2x",&t);
+ 		if(feof(stdin))
+ 		  good_bye();
+ 		for(j=0; j<8 ; j++) {
diff --git a/pkgs/development/libraries/libxslt/default.nix b/pkgs/development/libraries/libxslt/default.nix
index 46dc1435bcd0c..05ce8019c4ec1 100644
--- a/pkgs/development/libraries/libxslt/default.nix
+++ b/pkgs/development/libraries/libxslt/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   buildInputs = [libxml2];
   
   postInstall = ''
-    ensureDir $out/nix-support
+    mkdir -p $out/nix-support
     ln -s ${libxml2}/nix-support/setup-hook $out/nix-support/
   '';
 
diff --git a/pkgs/development/libraries/mpc/default.nix b/pkgs/development/libraries/mpc/default.nix
index 88c18565b78cf..3824e3d3755ba 100644
--- a/pkgs/development/libraries/mpc/default.nix
+++ b/pkgs/development/libraries/mpc/default.nix
@@ -1,11 +1,11 @@
 { fetchurl, stdenv, gmp, mpfr }:
 
 stdenv.mkDerivation rec {
-  name = "mpc-0.8.2";
+  name = "mpc-0.9";
 
   src = fetchurl {
     url = "http://www.multiprecision.org/mpc/download/${name}.tar.gz";
-    sha256 = "1iw0ag28l5r88k7kpn6i89rqn3yhk2irqzk0d1mlb1la3paghydf";
+    sha1 = "229722d553030734d49731844abfef7617b64f1a";
   };
 
   buildInputs = [ gmp mpfr ];
diff --git a/pkgs/development/libraries/mpfr/default.nix b/pkgs/development/libraries/mpfr/default.nix
index 51d33f9593c7b..0ab745879aca4 100644
--- a/pkgs/development/libraries/mpfr/default.nix
+++ b/pkgs/development/libraries/mpfr/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl, gmp}:
 
 stdenv.mkDerivation rec {
-  name = "mpfr-3.0.0";
+  name = "mpfr-3.1.0";
 
   src = fetchurl {
     url = "mirror://gnu/mpfr/${name}.tar.bz2";
-    sha256 = "07w24h8by7n319p2vwwa1xdcg7qzkd1aqm84lfcbfv2kaff5yklg";
+    sha256 = "105nx8qqx5x8f4rlplr2wk4cyv61iw5j3jgi2k21rpb8s6xbp9vl";
   };
 
   buildInputs = [ gmp ];
diff --git a/pkgs/development/libraries/ncbi/default.nix b/pkgs/development/libraries/ncbi/default.nix
index dd0dab46b76d5..0b795e78ad501 100644
--- a/pkgs/development/libraries/ncbi/default.nix
+++ b/pkgs/development/libraries/ncbi/default.nix
@@ -33,7 +33,7 @@ rec {
   '') ["preBuild" "addInputs"];
 
   deploy = a.fullDepEntry (''
-    ensureDir $out/bin $out/lib $out/include $out/source $out/share/${name}/build-snapshot
+    mkdir -p $out/bin $out/lib $out/include $out/source $out/share/${name}/build-snapshot
     cd ncbi/build
     cp *.o *.so $out/lib
     cp -r . $out/share/${name}/build-snapshot
diff --git a/pkgs/development/libraries/ncurses/default.nix b/pkgs/development/libraries/ncurses/default.nix
index b503493ac88e2..0278f62f65d89 100644
--- a/pkgs/development/libraries/ncurses/default.nix
+++ b/pkgs/development/libraries/ncurses/default.nix
@@ -11,15 +11,11 @@ let
   cxx = stdenv.system != "i686-solaris";
 in
 stdenv.mkDerivation (rec {
-  name = "ncurses-5.7";
+  name = "ncurses-5.9";
 
   src = fetchurl {
     url = "mirror://gnu/ncurses/${name}.tar.gz";
-    sha256 = "1x4q6kma6zgg438llbgiac3kik7j2lln9v97jdffv3fyqyjxx6qa";
-  };
-
-  crossAttrs = {
-    patches = [ ./wint_t.patch ];
+    sha256 = "0fsn7xis81za62afan0vvm38bvgzg5wfmv1m86flqcj0nj7jjilh";
   };
 
   configureFlags = ''
diff --git a/pkgs/development/libraries/ncurses/wint_t.patch b/pkgs/development/libraries/ncurses/wint_t.patch
deleted file mode 100644
index c9b34efd0bd99..0000000000000
--- a/pkgs/development/libraries/ncurses/wint_t.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-http://www.mail-archive.com/freewrt-developers@freewrt.org/msg01326.html
---- ncurses-5.6.orig/ncurses/curses.priv.h     2006-12-10 01:55:14.000000000 0100
-+++ ncurses-5.6/ncurses/curses.priv.h  2008-02-11 13:12:04.000000000 +0100
-@@ -253,6 +253,10 @@ color_t;
- #include <term_entry.h>
- #include <nc_tparm.h>
-
-+#ifndef _WINT_T
-+#include <wchar.h>
-+#endif
-+
- #if NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT
- #define if_EXT_COLORS(stmt)   stmt
- #define NetPair(value,p)      (value).ext_color = (p), \
diff --git a/pkgs/development/libraries/opencascade/default.nix b/pkgs/development/libraries/opencascade/default.nix
index 2118da3aa73de..87bbd112758bd 100644
--- a/pkgs/development/libraries/opencascade/default.nix
+++ b/pkgs/development/libraries/opencascade/default.nix
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
 
   postInstall = ''
     mv $out/inc $out/include
-    ensureDir $out/share/doc/${name}
+    mkdir -p $out/share/doc/${name}
     cp -R ../doc $out/share/doc/${name}
   '';
 
diff --git a/pkgs/development/libraries/opencv/changeset_r3190.diff b/pkgs/development/libraries/opencv/changeset_r3190.diff
new file mode 100644
index 0000000000000..4a614659e7239
--- /dev/null
+++ b/pkgs/development/libraries/opencv/changeset_r3190.diff
@@ -0,0 +1,20 @@
+--- opencv/src/highgui/cvcap_ffmpeg.cpp

++++ opencv/src/highgui/cvcap_ffmpeg.cpp

+@@ -49,6 +49,15 @@

+ #if !defined(WIN32) || defined(__MINGW32__)

+ // some versions of FFMPEG assume a C99 compiler, and don't define INT64_C

+-#ifndef INT64_C

+-#define INT64_C

++#if !defined INT64_C || !defined UINT64_C

++# if __WORDSIZE == 64

++#  define INT64_C(c)	c ## UL

++# else

++#  define INT64_C(c)	c ## ULL

++# endif

++# if __WORDSIZE == 64

++#  define UINT64_C(c)	c ## UL

++# else

++#  define UINT64_C(c)	c ## ULL

++# endif

+ #define __STDC_CONSTANT_MACROS

+ // force re-inclusion of stdint.h to get INT64_C macro

diff --git a/pkgs/development/libraries/opencv/default.nix b/pkgs/development/libraries/opencv/default.nix
index 05db48095c3c3..46c170d33f991 100644
--- a/pkgs/development/libraries/opencv/default.nix
+++ b/pkgs/development/libraries/opencv/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, cmake, gtk, libjpeg, libpng, libtiff, jasper, ffmpeg
-, pkgconfig, gstreamer }:
+, pkgconfig, gstreamer, xineLib, glib }:
 
 let v = "2.3.1a"; in
 
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
     sha256 = "0325s7pa2npcw2gc06pr6q5ik4xdyf08rvkfc0myn10w20lzb8m9";
   };
 
-  buildInputs = [ gtk libjpeg libpng libtiff jasper ffmpeg gstreamer ];
+  buildInputs = [ gtk glib libjpeg libpng libtiff jasper ffmpeg xineLib gstreamer ];
 
   buildNativeInputs = [ cmake pkgconfig ];
 
diff --git a/pkgs/development/libraries/opencv/default.nix.edited b/pkgs/development/libraries/opencv/default.nix.edited
new file mode 100644
index 0000000000000..05db48095c3c3
--- /dev/null
+++ b/pkgs/development/libraries/opencv/default.nix.edited
@@ -0,0 +1,27 @@
+{ stdenv, fetchurl, cmake, gtk, libjpeg, libpng, libtiff, jasper, ffmpeg
+, pkgconfig, gstreamer }:
+
+let v = "2.3.1a"; in
+
+stdenv.mkDerivation rec {
+  name = "opencv-${v}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/opencvlibrary/OpenCV-${v}.tar.bz2";
+    sha256 = "0325s7pa2npcw2gc06pr6q5ik4xdyf08rvkfc0myn10w20lzb8m9";
+  };
+
+  buildInputs = [ gtk libjpeg libpng libtiff jasper ffmpeg gstreamer ];
+
+  buildNativeInputs = [ cmake pkgconfig ];
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "Open Computer Vision Library with more than 500 algorithms";
+    homepage = http://opencv.willowgarage.com/;
+    license = "BSD";
+    maintainers = with stdenv.lib.maintainers; [viric];
+    platforms = with stdenv.lib.platforms; linux;
+  };
+}
diff --git a/pkgs/development/libraries/openssl/darwin-arch.patch b/pkgs/development/libraries/openssl/darwin-arch.patch
index ad8e86c6791ea..5d5a3afdd1d8f 100644
--- a/pkgs/development/libraries/openssl/darwin-arch.patch
+++ b/pkgs/development/libraries/openssl/darwin-arch.patch
@@ -1,16 +1,20 @@
-The patch is specific to nix: MacOS gcc supports -arch.
---- a/Configure
-+++ b/Configure
-@@ -549,9 +549,9 @@ my %table=(
+diff -ru openssl-1.0.0g-orig/Configure openssl-1.0.0g/Configure
+--- openssl-1.0.0g-orig/Configure	2011-12-19 18:04:38.000000000 +0100
++++ openssl-1.0.0g/Configure	2012-01-23 13:45:23.644170171 +0100
+@@ -549,11 +549,11 @@
+ 
+ ##### MacOS X (a.k.a. Rhapsody or Darwin) setup
  "rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown):MACOSX_RHAPSODY::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}::",
- "darwin-ppc-cc","cc:-arch ppc -O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
- "darwin64-ppc-cc","cc:-arch ppc64 -O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc64_asm}:osx64:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+-"darwin-ppc-cc","cc:-arch ppc -O3 -DB_ENDIAN -Wa,-force_cpusubtype_ALL::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+-"darwin64-ppc-cc","cc:-arch ppc64 -O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc64_asm}:osx64:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
 -"darwin-i386-cc","cc:-arch i386 -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
 -"debug-darwin-i386-cc","cc:-arch i386 -g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
--"darwin64-x86_64-cc","cc:-arch x86_64 -O3 -DL_ENDIAN -DMD32_REG_T=int -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+-"darwin64-x86_64-cc","cc:-arch x86_64 -O3 -DL_ENDIAN -DMD32_REG_T=int -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
++"darwin-ppc-cc","cc:-O3 -DB_ENDIAN -Wa,-force_cpusubtype_ALL::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
++"darwin64-ppc-cc","cc:-O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc64_asm}:osx64:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
 +"darwin-i386-cc","cc:-O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
 +"debug-darwin-i386-cc","cc:-g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
-+"darwin64-x86_64-cc","cc:-O3 -DL_ENDIAN -DMD32_REG_T=int -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
++"darwin64-x86_64-cc","cc:-O3 -DL_ENDIAN -DMD32_REG_T=int -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
  "debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
-
+ 
  ##### A/UX
diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix
index 633e43ac6a689..1a4767916f8f9 100644
--- a/pkgs/development/libraries/openssl/default.nix
+++ b/pkgs/development/libraries/openssl/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, perl }:
 
 let
-  name = "openssl-1.0.0e";
+  name = "openssl-1.0.0g";
 
   opensslCrossSystem = stdenv.lib.attrByPath [ "openssl" "system" ]
     (throw "openssl needs its platform name cross building" null)
@@ -18,12 +18,13 @@ let
       ./cert-file.patch
     ]
 
-    ++ (stdenv.lib.optionals (isCross && opensslCrossSystem == "hurd-x86")
+    ++ stdenv.lib.optionals (isCross && opensslCrossSystem == "hurd-x86")
          [ ./cert-file-path-max.patch # merge with `cert-file.patch' eventually
            ./gnu.patch                # submitted upstream
-         ])
+         ]
 
-    ++ (stdenv.lib.optional stdenv.isDarwin ./darwin-arch.patch);
+    ++ stdenv.lib.optional stdenv.isDarwin ./darwin-arch.patch
+    ++ stdenv.lib.optional (stdenv.system == "x86_64-freebsd") ./freebsd-x86_64-asm.patch;
   
 in
 
@@ -31,8 +32,11 @@ stdenv.mkDerivation {
   inherit name;
 
   src = fetchurl {
-    url = "http://www.openssl.org/source/${name}.tar.gz";
-    sha256 = "1xw0ffzmr4wbnb0glywgks375dvq8x87pgxmwx6vhgvkflkxqqg3";
+    urls = [
+      "http://www.openssl.org/source/${name}.tar.gz"
+      "http://openssl.linux-mirror.org/source/${name}.tar.gz"
+    ];
+    sha1 = "2b517baada2338663c27314cb922f9755e73e07f";
   };
 
   patches = patchesCross false;
diff --git a/pkgs/development/libraries/pango/1.29.x.nix b/pkgs/development/libraries/pango/1.29.x.nix
index 0b1c44f30b864..4d6e5411e24c2 100644
--- a/pkgs/development/libraries/pango/1.29.x.nix
+++ b/pkgs/development/libraries/pango/1.29.x.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, gettext, x11, glib, cairo, libpng, xz }:
+{ stdenv, fetchurl, pkgconfig, gettext, x11, glib, cairo, libpng }:
 
 stdenv.mkDerivation rec {
   name = "pango-1.29.4";
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
 
   buildInputs = stdenv.lib.optional stdenv.isDarwin gettext;
 
-  buildNativeInputs = [ pkgconfig xz ];
+  buildNativeInputs = [ pkgconfig ];
 
   propagatedBuildInputs = [ x11 glib cairo libpng ];
 
diff --git a/pkgs/development/libraries/pangomm/2.28.x.nix b/pkgs/development/libraries/pangomm/2.28.x.nix
index c004b7160f20a..5cd4744fed38b 100644
--- a/pkgs/development/libraries/pangomm/2.28.x.nix
+++ b/pkgs/development/libraries/pangomm/2.28.x.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, pango, glibmm, cairomm, libpng, xz }:
+{ stdenv, fetchurl, pkgconfig, pango, glibmm, cairomm, libpng }:
 
 stdenv.mkDerivation rec {
   name = "pangomm-2.28.4";
@@ -8,7 +8,6 @@ stdenv.mkDerivation rec {
     sha256 = "10kcdpg080m393f1vz0km41kd3483fkyabprm59gvjwklxkcp3bp";
   };
 
-  buildInputs = [ xz];
   buildNativeInputs = [ pkgconfig ];
   propagatedBuildInputs = [ pango glibmm cairomm libpng ];
 
diff --git a/pkgs/development/libraries/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix
index 65eb51af9b003..7802f89807d30 100644
--- a/pkgs/development/libraries/pcre/default.nix
+++ b/pkgs/development/libraries/pcre/default.nix
@@ -1,11 +1,11 @@
-{stdenv, fetchurl, unicodeSupport ? false, cplusplusSupport ? true}:
+{ stdenv, fetchurl, unicodeSupport ? true, cplusplusSupport ? true }:
 
-stdenv.mkDerivation {
-  name = "pcre-8.10";
+stdenv.mkDerivation rec {
+  name = "pcre-8.21";
 
   src = fetchurl {
-    url = mirror://sourceforge/pcre/pcre-8.10.tar.bz2;
-    sha256 = "7ac4e016f6bad8c7d990e6de9bce58c04ff5dd8838be0c5ada0afad1d6a07480";
+    url = "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/${name}.tar.bz2";
+    sha256 = "1qwrqldbwszbmr4cw4f0xmcl889cmmjbf58l9vxn89zw26fm1f54";
   };
 
   # The compiler on Darwin crashes with an internal error while building the
diff --git a/pkgs/development/libraries/pdf2xml/default.nix b/pkgs/development/libraries/pdf2xml/default.nix
index 6179742b42f7c..0f9a3dc2b2dad 100644
--- a/pkgs/development/libraries/pdf2xml/default.nix
+++ b/pkgs/development/libraries/pdf2xml/default.nix
@@ -24,7 +24,7 @@ stdenv.mkDerivation {
   '';
   
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp exe/* $out/bin
   '';
 }
diff --git a/pkgs/development/libraries/phonon/default.nix b/pkgs/development/libraries/phonon/default.nix
index 440c775adb2a5..2c70957746d27 100644
--- a/pkgs/development/libraries/phonon/default.nix
+++ b/pkgs/development/libraries/phonon/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cmake, automoc4, qt4, xz, pulseaudio }:
+{ stdenv, fetchurl, cmake, automoc4, qt4, pulseaudio }:
 
 let
   v = "4.6.0";
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ qt4 pulseaudio ];
 
-  buildNativeInputs = [ cmake automoc4 xz ];
+  buildNativeInputs = [ cmake automoc4 ];
 
   meta = {
     homepage = http://phonon.kde.org/;
diff --git a/pkgs/development/libraries/postgis/default.nix b/pkgs/development/libraries/postgis/default.nix
index 016bd23cf1ca4..b4c8a7f17890e 100644
--- a/pkgs/development/libraries/postgis/default.nix
+++ b/pkgs/development/libraries/postgis/default.nix
@@ -74,7 +74,7 @@ let
       s=$out/bin/pg_db_postgis_enable
 
       sql_comments=$out/share/postgis-${version}/comments.sql
-      ensureDir $(dirname $sql_comments)
+      mkdir -p $(dirname $sql_comments)
       cp $(find -iname ${fix.fixed.sql_comments}) $sql_comments
 
       for script in $scriptNames; do
diff --git a/pkgs/development/libraries/ppl/0.11.nix b/pkgs/development/libraries/ppl/0.11.nix
deleted file mode 100644
index d8ffde644de1a..0000000000000
--- a/pkgs/development/libraries/ppl/0.11.nix
+++ /dev/null
@@ -1,50 +0,0 @@
-{ fetchurl, stdenv, gmpxx, perl, gnum4, static ? false }:
-
-let
-  version = "0.11";
-  staticFlags = if static then " --enable-static --disable-shared --disable-watchdog" else "";
-in
-  stdenv.mkDerivation rec {
-    name = "ppl-${version}";
-
-    src = fetchurl {
-      url = "mirror://gcc/infrastructure/ppl-${version}.tar.gz";
-      sha256 = "0xqwyaj232gi0pgm6z2rihk6p8l1rngbbibnhmcrbq4jq550clrl";
-    };
-
-    buildNativeInputs = [ perl gnum4 ];
-    propagatedBuildInputs = [ gmpxx ];
-
-    dontDisableStatic = if static then true else false;
-    configureFlags = staticFlags;
-
-    # Beware!  It took ~6 hours to compile PPL and run its tests on a 1.2 GHz
-    # x86_64 box.  Nevertheless, being a dependency of GCC, it probably ought
-    # to be tested.
-    doCheck = false;
-
-    meta = {
-      description = "PPL: The Parma Polyhedra Library";
-
-      longDescription = ''
-        The Parma Polyhedra Library (PPL) provides numerical abstractions
-        especially targeted at applications in the field of analysis and
-        verification of complex systems.  These abstractions include convex
-        polyhedra, defined as the intersection of a finite number of (open or
-        closed) halfspaces, each described by a linear inequality (strict or
-        non-strict) with rational coefficients; some special classes of
-        polyhedra shapes that offer interesting complexity/precision tradeoffs;
-        and grids which represent regularly spaced points that satisfy a set of
-        linear congruence relations.  The library also supports finite
-        powersets and products of (any kind of) polyhedra and grids and a mixed
-        integer linear programming problem solver using an exact-arithmetic
-        version of the simplex algorithm.
-      '';
-
-      homepage = http://www.cs.unipr.it/ppl/;
-
-      license = "GPLv3+";
-
-      maintainers = [ stdenv.lib.maintainers.ludo ];
-    };
-  }
diff --git a/pkgs/development/libraries/ppl/default.nix b/pkgs/development/libraries/ppl/default.nix
index 677d578e2425e..8cad9022d911d 100644
--- a/pkgs/development/libraries/ppl/default.nix
+++ b/pkgs/development/libraries/ppl/default.nix
@@ -1,50 +1,49 @@
-{ fetchurl, stdenv, gmpxx, perl, gnum4, static ? false }:
-
-let
-  version = "0.10.2";
-  staticFlags = if static then " --enable-static --disable-shared" else "";
-in
-  stdenv.mkDerivation rec {
-    name = "ppl-${version}";
-
-    src = fetchurl {
-      url = "mirror://gcc/infrastructure/ppl-${version}.tar.gz";
-      sha256 = "0lly44sac4jd72klnhhil3wha15vak76r6gy88sh0zjsaww9hf6h";
-    };
-
-    buildNativeInputs = [ perl gnum4 ];
-    propagatedBuildInputs = [ gmpxx ];
-
-    dontDisableStatic = if static then true else false;
-    configureFlags = staticFlags;
-
-    # Beware!  It took ~6 hours to compile PPL and run its tests on a 1.2 GHz
-    # x86_64 box.  Nevertheless, being a dependency of GCC, it probably ought
-    # to be tested.
-    doCheck = false;
-
-    meta = {
-      description = "PPL: The Parma Polyhedra Library";
-
-      longDescription = ''
-        The Parma Polyhedra Library (PPL) provides numerical abstractions
-        especially targeted at applications in the field of analysis and
-        verification of complex systems.  These abstractions include convex
-        polyhedra, defined as the intersection of a finite number of (open or
-        closed) halfspaces, each described by a linear inequality (strict or
-        non-strict) with rational coefficients; some special classes of
-        polyhedra shapes that offer interesting complexity/precision tradeoffs;
-        and grids which represent regularly spaced points that satisfy a set of
-        linear congruence relations.  The library also supports finite
-        powersets and products of (any kind of) polyhedra and grids and a mixed
-        integer linear programming problem solver using an exact-arithmetic
-        version of the simplex algorithm.
-      '';
-
-      homepage = http://www.cs.unipr.it/ppl/;
-
-      license = "GPLv3+";
-
-      maintainers = [ stdenv.lib.maintainers.ludo ];
-    };
-  }
+{ fetchurl, stdenv, gmpxx, perl, gnum4 }:
+
+let version = "0.11.2"; in
+
+stdenv.mkDerivation rec {
+  name = "ppl-${version}";
+
+  src = fetchurl {
+    url = "http://bugseng.com/products/ppl/download/ftp/releases/${version}/ppl-${version}.tar.bz2";
+    sha256 = "1sxviip4yk6gp453pid5scy1ba66dzdpr02i1416yk7lkv0x3yz3";
+  };
+
+  buildNativeInputs = [ perl gnum4 ];
+  propagatedBuildInputs = [ gmpxx ];
+
+  configureFlags = "--disable-watchdog";
+
+  # Beware!  It took ~6 hours to compile PPL and run its tests on a 1.2 GHz
+  # x86_64 box.  Nevertheless, being a dependency of GCC, it probably ought
+  # to be tested.
+  doCheck = false;
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "PPL: The Parma Polyhedra Library";
+
+    longDescription = ''
+      The Parma Polyhedra Library (PPL) provides numerical abstractions
+      especially targeted at applications in the field of analysis and
+      verification of complex systems.  These abstractions include convex
+      polyhedra, defined as the intersection of a finite number of (open or
+      closed) halfspaces, each described by a linear inequality (strict or
+      non-strict) with rational coefficients; some special classes of
+      polyhedra shapes that offer interesting complexity/precision tradeoffs;
+      and grids which represent regularly spaced points that satisfy a set of
+      linear congruence relations.  The library also supports finite
+      powersets and products of (any kind of) polyhedra and grids and a mixed
+      integer linear programming problem solver using an exact-arithmetic
+      version of the simplex algorithm.
+    '';
+
+    homepage = http://www.cs.unipr.it/ppl/;
+
+    license = "GPLv3+";
+
+    maintainers = [ stdenv.lib.maintainers.ludo ];
+  };
+}
diff --git a/pkgs/development/libraries/qt-3/default.nix b/pkgs/development/libraries/qt-3/default.nix
index fa6857c1284fc..ba796259f7033 100644
--- a/pkgs/development/libraries/qt-3/default.nix
+++ b/pkgs/development/libraries/qt-3/default.nix
@@ -65,6 +65,9 @@ stdenv.mkDerivation {
     
     # randr.h and Xrandr.h need not be in the same prefix.
     ./xrandr.patch
+
+    # Make it build with gcc 4.6.0
+    ./qt3-gcc4.6.0.patch
   ];
 
   passthru = {inherit mysqlSupport;};
diff --git a/pkgs/development/libraries/qt-3/qt3-gcc4.6.0.patch b/pkgs/development/libraries/qt-3/qt3-gcc4.6.0.patch
new file mode 100644
index 0000000000000..c1a903c130c7d
--- /dev/null
+++ b/pkgs/development/libraries/qt-3/qt3-gcc4.6.0.patch
@@ -0,0 +1,23 @@
+I picked it here:
+https://bugs.archlinux.org/task/23915
+
+--- qt-x11-free-3.3.8b/src/tools/qmap.h~	2008-01-15 19:09:13.000000000 +0000
++++ qt-x11-free-3.3.8b/src/tools/qmap.h	2011-04-11 00:16:04.000000000 +0100
+@@ -50,6 +50,7 @@
+ #endif // QT_H
+ 
+ #ifndef QT_NO_STL
++#include <cstddef>
+ #include <iterator>
+ #include <map>
+ #endif
+--- qt-x11-free-3.3.8b/src/tools/qvaluelist.h~	2008-01-15 19:09:13.000000000 +0000
++++ qt-x11-free-3.3.8b/src/tools/qvaluelist.h	2011-04-11 00:16:49.000000000 +0100
+@@ -48,6 +48,7 @@
+ #endif // QT_H
+ 
+ #ifndef QT_NO_STL
++#include <cstddef>
+ #include <iterator>
+ #include <list>
+ #endif
diff --git a/pkgs/development/libraries/qtscriptgenerator/default.nix b/pkgs/development/libraries/qtscriptgenerator/default.nix
index 64e535bf27287..b8ed81de487b0 100644
--- a/pkgs/development/libraries/qtscriptgenerator/default.nix
+++ b/pkgs/development/libraries/qtscriptgenerator/default.nix
@@ -28,7 +28,7 @@ stdenv.mkDerivation {
   
   installPhase = ''
     cd ..
-    ensureDir $out/lib/qt4/plugins/script
+    mkdir -p $out/lib/qt4/plugins/script
     cp -av plugins/script/* $out/lib/qt4/plugins/script
   '';
 
diff --git a/pkgs/development/libraries/readline/readline-6.2-patches.nix b/pkgs/development/libraries/readline/readline-6.2-patches.nix
new file mode 100644
index 0000000000000..4e0ff2135271a
--- /dev/null
+++ b/pkgs/development/libraries/readline/readline-6.2-patches.nix
@@ -0,0 +1,6 @@
+# Automatically generated by `update-patch-set.sh'; do not edit.
+
+patch: [
+(patch "001" "1qxl74f4n0hv4a807byrgbk4ixd8m50apj3922q2ss9pfi0nra1q")
+(patch "002" "1m670g2xzib6r81315q9r24nh9brmxkpq07acch1fwxmih94jqqy")
+]
diff --git a/pkgs/development/libraries/readline/readline-patches.nix b/pkgs/development/libraries/readline/readline-patches.nix
deleted file mode 100644
index b8019fb335024..0000000000000
--- a/pkgs/development/libraries/readline/readline-patches.nix
+++ /dev/null
@@ -1,4 +0,0 @@
-# Automatically generated by `update-patch-set.sh'; do not edit.
-
-patch: [
-]
diff --git a/pkgs/development/libraries/readline/readline6.nix b/pkgs/development/libraries/readline/readline6.nix
index 1bd88069127f0..0826e6c5f7cb1 100644
--- a/pkgs/development/libraries/readline/readline6.nix
+++ b/pkgs/development/libraries/readline/readline6.nix
@@ -1,11 +1,11 @@
 { fetchurl, stdenv, ncurses }:
 
 stdenv.mkDerivation (rec {
-  name = "readline-6.1";
+  name = "readline-6.2";
 
   src = fetchurl {
     url = "mirror://gnu/readline/${name}.tar.gz";
-    sha256 = "0sd97zqdh4fc0zzgzpskkczwa2fmb0s89qdyndb6vkbcq04gdjph";
+    sha256 = "10ckm2bd2rkxhvdmj7nmbsylmihw0abwcsnxf8y27305183rd9kr";
   };
 
   propagatedBuildInputs = [ncurses];
@@ -17,11 +17,11 @@ stdenv.mkDerivation (rec {
     (let
        patch = nr: sha256:
          fetchurl {
-           url = "mirror://gnu/readline/${name}-patches/readline61-${nr}";
+           url = "mirror://gnu/readline/${name}-patches/readline62-${nr}";
            inherit sha256;
          };
      in
-       import ./readline-patches.nix patch);
+       import ./readline-6.2-patches.nix patch);
 
   meta = {
     description = "GNU Readline, a library for interactive line editing";
diff --git a/pkgs/development/libraries/rubberband/default.nix b/pkgs/development/libraries/rubberband/default.nix
index c8e3c53885cb0..9e606967ab116 100644
--- a/pkgs/development/libraries/rubberband/default.nix
+++ b/pkgs/development/libraries/rubberband/default.nix
@@ -2,11 +2,11 @@
 , vampSDK, ladspaH }:
 
 stdenv.mkDerivation {
-  name = "rubberband-1.6.0";
+  name = "rubberband-1.7.0";
 
   src = fetchurl {
-    url = http://code.breakfastquay.com/attachments/download/16/rubberband-1.6.0.tar.bz2;
-    sha256 = "15n875x3bbg7nbnqbl33v5jp2p6yw779124xz4la8ysclvikklsv";
+    url = http://code.breakfastquay.com/attachments/download/23/rubberband-1.7.0.tar.bz2;
+    sha256 = "10pnfzaiws6bi17qlyj3r0alj2nvm11pkd14nms6yxas8c7gwdw0";
   };
 
   buildInputs = [ pkgconfig libsamplerate libsndfile fftw vampSDK ladspaH ];
diff --git a/pkgs/development/libraries/scmccid/default.nix b/pkgs/development/libraries/scmccid/default.nix
index 01dc63353d668..f18107c48a5eb 100644
--- a/pkgs/development/libraries/scmccid/default.nix
+++ b/pkgs/development/libraries/scmccid/default.nix
@@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
         fi
     done
 
-    ensureDir $out/pcsc/drivers
+    mkdir -p $out/pcsc/drivers
     cp -R proprietary/* $out/pcsc/drivers
   '';
 
diff --git a/pkgs/development/libraries/slib/default.nix b/pkgs/development/libraries/slib/default.nix
index 952d4ba9f2550..4c615b81552fd 100644
--- a/pkgs/development/libraries/slib/default.nix
+++ b/pkgs/development/libraries/slib/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ unzip scheme texinfo ];
 
   configurePhase = ''
-    ensureDir "$out"
+    mkdir -p "$out"
     sed -i "Makefile" \
         -e "s|^[[:blank:]]*prefix[[:blank:]]*=.*$|prefix = $out/|g"
   '';
diff --git a/pkgs/development/libraries/snack/default.nix b/pkgs/development/libraries/snack/default.nix
index 7776b4d025940..4e1187aa0f762 100644
--- a/pkgs/development/libraries/snack/default.nix
+++ b/pkgs/development/libraries/snack/default.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation {
   postInstall = "aoeu";
 
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     make install DESTDIR="$out" 
   '';
 
diff --git a/pkgs/development/libraries/speech-tools/default.nix b/pkgs/development/libraries/speech-tools/default.nix
index 211eecde4e435..8874a672ead0b 100644
--- a/pkgs/development/libraries/speech-tools/default.nix
+++ b/pkgs/development/libraries/speech-tools/default.nix
@@ -35,7 +35,7 @@ rec {
   '' ["minInit" "doUnpack"];
 
   doDeploy = a.fullDepEntry ''
-    ensureDir "$out"/{bin,lib}
+    mkdir -p "$out"/{bin,lib}
     for d in bin lib; do
       for i in ./$d/*; do
         test "$(basename "$i")" = "Makefile" ||
diff --git a/pkgs/development/libraries/sphinxbase/default.nix b/pkgs/development/libraries/sphinxbase/default.nix
index b025e9a68a9b3..dafa82bad3479 100644
--- a/pkgs/development/libraries/sphinxbase/default.nix
+++ b/pkgs/development/libraries/sphinxbase/default.nix
@@ -25,10 +25,10 @@ stdenv.mkDerivation (rec {
   outputs = [ "out" "lib" "headers" ];
 
   postInstall = ''
-    ensureDir $lib
+    mkdir -p $lib
     cp -av $out/lib* $lib
 
-    ensureDir $headers
+    mkdir -p $headers
     cp -av $out/include $headers
   '';
 }))
diff --git a/pkgs/development/libraries/suitesparse/default.nix b/pkgs/development/libraries/suitesparse/default.nix
index 00558fc52e9d5..d1611cda623a7 100644
--- a/pkgs/development/libraries/suitesparse/default.nix
+++ b/pkgs/development/libraries/suitesparse/default.nix
@@ -14,8 +14,8 @@ stdenv.mkDerivation {
 
   preConfigure = ''
     export PREFIX=$out
-    ensureDir $out/lib
-    ensureDir $out/include
+    mkdir -p $out/lib
+    mkdir -p $out/include
   '';
 
   NIX_CFLAGS = "-fPIC";
diff --git a/pkgs/development/libraries/tcp-wrappers/default.nix b/pkgs/development/libraries/tcp-wrappers/default.nix
index 1cb6472971c47..14335e6a3adb6 100644
--- a/pkgs/development/libraries/tcp-wrappers/default.nix
+++ b/pkgs/development/libraries/tcp-wrappers/default.nix
@@ -50,7 +50,7 @@ rec {
   '' ["minInit"];
 
   doDeploy = a.fullDepEntry ''
-    ensureDir "$out"/{sbin,lib}
+    mkdir -p "$out"/{sbin,lib}
     make libwrap.so
     cp libwrap.{a,so} "$out/lib"
     find . -perm +111 -a ! -name '*.*' -exec cp '{}' "$out/sbin" ';'
diff --git a/pkgs/development/libraries/ti-rpc/default.nix b/pkgs/development/libraries/ti-rpc/default.nix
index 1fbfdc58fceb9..e669f8a254f1c 100644
--- a/pkgs/development/libraries/ti-rpc/default.nix
+++ b/pkgs/development/libraries/ti-rpc/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   preConfigure =
     '' sed -es"|/etc/netconfig|$out/etc/netconfig|g" -i "Makefile.in"
     '';
-  preInstall = "ensureDir $out/etc";
+  preInstall = "mkdir -p $out/etc";
 
   doCheck = true;
 
diff --git a/pkgs/development/libraries/v8/default.nix b/pkgs/development/libraries/v8/default.nix
index 8aa342186c05c..68215c555b7af 100644
--- a/pkgs/development/libraries/v8/default.nix
+++ b/pkgs/development/libraries/v8/default.nix
@@ -25,8 +25,8 @@ stdenv.mkDerivation rec {
     '';
 
     installPhase = ''
-      ensureDir $out/bin
-      ensureDir $out/lib
+      mkdir -p $out/bin
+      mkdir -p $out/lib
 
       cp -v libv8.* $out/lib
       cp -v d8 $out/bin/d8
diff --git a/pkgs/development/libraries/webkit/default.nix b/pkgs/development/libraries/webkit/default.nix
index 63c6574d32ad5..2daa1796318f1 100644
--- a/pkgs/development/libraries/webkit/default.nix
+++ b/pkgs/development/libraries/webkit/default.nix
@@ -69,7 +69,7 @@ rec {
   '') ["minInit" "doUnpack"];
 
   doAddPrograms = fullDepEntry (''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     for i in Programs/.libs/* Programs/*; do 
         cp $i $out/bin/webkit-program-$(basename $i) || true
     done
diff --git a/pkgs/development/libraries/webkit/svn.nix b/pkgs/development/libraries/webkit/svn.nix
index 5eaaeec3d168a..d41d4683d6e98 100644
--- a/pkgs/development/libraries/webkit/svn.nix
+++ b/pkgs/development/libraries/webkit/svn.nix
@@ -70,7 +70,7 @@ rec {
   '') ["minInit" "doUnpack"];
 
   doAddPrograms = fullDepEntry (''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     for i in Programs/.libs/* Programs/*; do 
         cp $i $out/bin/webkit-program-$(basename $i) || true
     done
diff --git a/pkgs/development/libraries/wtk/builder.sh b/pkgs/development/libraries/wtk/builder.sh
index 5ccfc1a7391fd..6db9469e46d2f 100644
--- a/pkgs/development/libraries/wtk/builder.sh
+++ b/pkgs/development/libraries/wtk/builder.sh
@@ -5,7 +5,7 @@ pushd unzipped
 unzip $src || true
 popd
 
-ensureDir $out
+mkdir -p $out
 mv unzipped/* $out/
 
 # Remove crap in the root directory.
diff --git a/pkgs/development/libraries/xapian/bindings/1.0.x.nix b/pkgs/development/libraries/xapian/bindings/1.0.x.nix
index 3417596c3930d..b6bc94814e643 100644
--- a/pkgs/development/libraries/xapian/bindings/1.0.x.nix
+++ b/pkgs/development/libraries/xapian/bindings/1.0.x.nix
@@ -23,7 +23,7 @@ composableDerivation.composableDerivation {} rec {
             # export same env vars as in pythonNew
             preConfigure = ''
               export PYTHON_LIB=$out/lib/${python.libPrefix}/site-packages
-              ensureDir $out/nix-support
+              mkdir -p $out/nix-support
               echo "export NIX_PYTHON_SITES=\"$out:\$NIX_PYTHON_SITES\"" >> $out/nix-support/setup-hook 
               echo "export PYTHONPATH=\"$PYTHON_LIB:\$PYTHONPATH\"" >> $out/nix-support/setup-hook 
             '';
@@ -46,7 +46,7 @@ composableDerivation.composableDerivation {} rec {
              preConfigure = ''
                export RUBY_LIB=$out/${ruby.libPath}
                export RUBY_LIB_ARCH=$RUBY_LIB
-               ensureDir $out/nix-support
+               mkdir -p $out/nix-support
                echo "export RUBYLIB=\"$RUBY_LIB:\$RUBYLIB\"" >> $out/nix-support/setup-hook 
                echo "export GEM_PATH=\"$out:\$GEM_PATH\"" >> $out/nix-support/setup-hook 
              '';
diff --git a/pkgs/development/libraries/xapian/bindings/default.nix b/pkgs/development/libraries/xapian/bindings/default.nix
index fc46088833b98..789d9a65308a3 100644
--- a/pkgs/development/libraries/xapian/bindings/default.nix
+++ b/pkgs/development/libraries/xapian/bindings/default.nix
@@ -23,7 +23,7 @@ composableDerivation.composableDerivation {} rec {
             # export same env vars as in pythonNew
             preConfigure = ''
               export PYTHON_LIB=$out/lib/${python.libPrefix}/site-packages
-              ensureDir $out/nix-support
+              mkdir -p $out/nix-support
               echo "export NIX_PYTHON_SITES=\"$out:\$NIX_PYTHON_SITES\"" >> $out/nix-support/setup-hook 
               echo "export PYTHONPATH=\"$PYTHON_LIB:\$PYTHONPATH\"" >> $out/nix-support/setup-hook 
             '';
@@ -46,7 +46,7 @@ composableDerivation.composableDerivation {} rec {
              preConfigure = ''
                export RUBY_LIB=$out/${ruby.libPath}
                export RUBY_LIB_ARCH=$RUBY_LIB
-               ensureDir $out/nix-support
+               mkdir -p $out/nix-support
                echo "export RUBYLIB=\"$RUBY_LIB:\$RUBYLIB\"" >> $out/nix-support/setup-hook 
                echo "export GEM_PATH=\"$out:\$GEM_PATH\"" >> $out/nix-support/setup-hook 
              '';
diff --git a/pkgs/development/libraries/xine-lib/default.nix b/pkgs/development/libraries/xine-lib/default.nix
index f8866e807a4d0..13b2fdce45827 100644
--- a/pkgs/development/libraries/xine-lib/default.nix
+++ b/pkgs/development/libraries/xine-lib/default.nix
@@ -12,6 +12,7 @@ stdenv.mkDerivation rec {
     sha256 = "1yss9cxxkcb6dzrv78xvi845ls6lhhbv6g8yfm6zjjl07v7jbm6c";
   };
 
+  patches = [ ./zlib126.patch ];
 #  patches =
 #    [ (fetchurl {
 #        url = "http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/media-libs/xine-lib/files/xine-lib-1.1.19-ffmpeg.patch?revision=1.1";
diff --git a/pkgs/development/libraries/xine-lib/zlib126.patch b/pkgs/development/libraries/xine-lib/zlib126.patch
new file mode 100644
index 0000000000000..f48063e038b5b
--- /dev/null
+++ b/pkgs/development/libraries/xine-lib/zlib126.patch
@@ -0,0 +1,52 @@
+http://anonscm.debian.org/hg/xine-lib/xine-lib/rev/24d09421ed09
+
+# HG changeset patch
+# User Ulrich Müller <ulm@gentoo.org>
+# Date 1327945720 0
+# Node ID 24d09421ed09d3a78efeab5c9b8ab31daaaba4fd
+# Parent  da296856c52e654cf599248de3a01bb754363c79
+Compile failure in osd.c with sys-libs/zlib-1.2.6
+
+diff -r da296856c52e -r 24d09421ed09 misc/xine-fontconv.c
+--- a/misc/xine-fontconv.c	Wed Jan 18 22:01:28 2012 +0000
++++ b/misc/xine-fontconv.c	Mon Jan 30 17:48:40 2012 +0000
+@@ -109,7 +109,7 @@
+ osd_font_t     font;
+ 
+ 
+-static int gzwrite_i16(gzFile *fp, uint16_t number) {
++static int gzwrite_i16(gzFile fp, uint16_t number) {
+   return gzputc(fp, number & 0xFF) != -1 &&
+          gzputc(fp, (number >> 8) & 0xFF) != -1;
+ }
+@@ -341,7 +341,7 @@
+ 
+   char                filename[1024];
+   FT_Bitmap          *out_bitmap;
+-  gzFile             *fp;
++  gzFile              fp;
+   int                 error;
+   int                 error_counter;
+   int                 glyph_index;
+diff -r da296856c52e -r 24d09421ed09 src/xine-engine/osd.c
+--- a/src/xine-engine/osd.c	Wed Jan 18 22:01:28 2012 +0000
++++ b/src/xine-engine/osd.c	Mon Jan 30 17:48:40 2012 +0000
+@@ -650,7 +650,7 @@
+   osd->display_y = y;
+ }
+ 
+-static uint16_t gzread_i16(gzFile *fp) {
++static uint16_t gzread_i16(gzFile fp) {
+   uint16_t ret;
+   ret = gzgetc(fp);
+   ret |= (gzgetc(fp)<<8);
+@@ -663,7 +663,7 @@
+ 
+ static int osd_renderer_load_font(osd_renderer_t *this, char *filename) {
+ 
+-  gzFile      *fp;
++  gzFile       fp;
+   osd_font_t  *font = NULL;
+   int          i, ret = 0;
+ 
+
diff --git a/pkgs/development/libraries/xlibs-wrapper/default.nix b/pkgs/development/libraries/xlibs-wrapper/default.nix
index d8bc32350fb96..07220d6e1a65d 100644
--- a/pkgs/development/libraries/xlibs-wrapper/default.nix
+++ b/pkgs/development/libraries/xlibs-wrapper/default.nix
@@ -3,7 +3,7 @@
 stdenv.mkDerivation {
   name = "xlibs-wrapper";
   buildPhase = "true";
-  installPhase = "ensureDir $out";
+  installPhase = "mkdir -p $out";
   unpackPhase = "sourceRoot=.";
   propagatedBuildInputs = packages;
 } // {
diff --git a/pkgs/development/libraries/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix
index 1e8d5642edb6e..eecdc80da5e8e 100644
--- a/pkgs/development/libraries/zlib/default.nix
+++ b/pkgs/development/libraries/zlib/default.nix
@@ -1,15 +1,16 @@
-{stdenv, fetchurl, static ? false}:
+{ stdenv, fetchurl, static ? false }:
 
-let version = "1.2.5"; in
-stdenv.mkDerivation (rec {
-  name = "zlib-${version}";
+let version = "1.2.6"; in
 
+stdenv.mkDerivation rec {
+  name = "zlib-${version}";
+  
   src = fetchurl {
     urls =
       [ "http://www.zlib.net/${name}.tar.gz"  # old versions vanish from here
         "mirror://sourceforge/libpng/zlib/${version}/${name}.tar.gz"
       ];
-    sha256 = "0n7rlgvjn73pyil3s1l6p77m7wkc809n934rnzxv1b1za4pfar30";
+    sha256 = "06x6m33ls1606ni7275q5z392csvh18dgs55kshfnvrfal45w8r1";
   };
 
   configureFlags = if static then "" else "--shared";
@@ -21,9 +22,13 @@ stdenv.mkDerivation (rec {
     fi
   '';
 
+  # As zlib takes part in the stdenv building, we don't want references
+  # to the bootstrap-tools libgcc (as uses to happen on arm/mips)
+  NIX_CFLAGS_COMPILE = "-static-libgcc";
+
   crossAttrs = {
     dontStrip = if static then true else false;
-  } // (if stdenv.cross.libc == "msvcrt" then {
+  } // stdenv.lib.optionalAttrs (stdenv.cross.libc == "msvcrt") {
     configurePhase=''
       installFlags="BINARY_PATH=$out/bin INCLUDE_PATH=$out/include LIBRARY_PATH=$out/lib"
     '';
@@ -31,11 +36,8 @@ stdenv.mkDerivation (rec {
       "-f" "win32/Makefile.gcc"
       "PREFIX=${stdenv.cross.config}-"
     ] ++ (if static then [] else [ "SHARED_MODE=1" ]);
-  } else {});
+  };
 
   # zlib doesn't like the automatic --disable-shared from the Cygwin stdenv.
   cygwinConfigureEnableShared = true;
-  
-} // stdenv.lib.optionalAttrs (stdenv.system == "i686-cygwin") {
-  patches = [ ./no-shared.patch ];
-})
+}
diff --git a/pkgs/development/libraries/zlib/no-shared.patch b/pkgs/development/libraries/zlib/no-shared.patch
deleted file mode 100644
index e26449ffd9f06..0000000000000
--- a/pkgs/development/libraries/zlib/no-shared.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-Support building the static library only.
-
-diff -ru -x '*~' zlib-1.2.5-orig/Makefile.in zlib-1.2.5/Makefile.in
---- zlib-1.2.5-orig/Makefile.in	2010-04-20 06:12:21.000000000 +0200
-+++ zlib-1.2.5/Makefile.in	2010-07-27 13:25:02.176322291 +0200
-@@ -168,7 +168,7 @@
- 	-@if [ ! -d $(DESTDIR)$(man3dir)      ]; then mkdir -p $(DESTDIR)$(man3dir); fi
- 	-@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
- 	cp $(STATICLIB) $(DESTDIR)$(libdir)
--	cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)
-+	test -z "$(SHAREDLIBV)" || cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)
- 	cd $(DESTDIR)$(libdir); chmod u=rw,go=r $(STATICLIB)
- 	-@(cd $(DESTDIR)$(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
- 	-@cd $(DESTDIR)$(sharedlibdir); if test "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
diff --git a/pkgs/development/libraries/zziplib/default.nix b/pkgs/development/libraries/zziplib/default.nix
index a7d246d34fbf3..e9de92fb3ced6 100644
--- a/pkgs/development/libraries/zziplib/default.nix
+++ b/pkgs/development/libraries/zziplib/default.nix
@@ -8,6 +8,10 @@ stdenv.mkDerivation rec {
     sha256 = "13j9f6i8rx0qd5m96iwrcha78h34qpfk5qzi7cv098pms6gq022m";
   };
 
+  patchPhase = ''
+    sed -i -e s,--export-dynamic,, configure
+  '';
+
   buildInputs = [ perl python zip xmlto zlib ];
 
   doCheck = true;
diff --git a/pkgs/development/misc/avr8-burn-omat/default.nix b/pkgs/development/misc/avr8-burn-omat/default.nix
index 7c9fb19c27543..f79483874f6bd 100644
--- a/pkgs/development/misc/avr8-burn-omat/default.nix
+++ b/pkgs/development/misc/avr8-burn-omat/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation {
   # move to nix-support to not create that many symlinks..
   # TODO burnomat tries to read /usr/local/etc/avrdude.conf (but you can edit it within the settings dialog)
   installPhase = ''
-    ensureDir $out/{nix-support,bin}
+    mkdir -p $out/{nix-support,bin}
     mv *.jar license_gpl-3.0.txt lib *.xml *.png $out/nix-support
     cat >> $out/bin/avr8-burn-omat << EOF
       #!/bin/sh
diff --git a/pkgs/development/misc/windows-sdk/builder.sh b/pkgs/development/misc/windows-sdk/builder.sh
index e834479882670..8f1eaffbcaf9b 100644
--- a/pkgs/development/misc/windows-sdk/builder.sh
+++ b/pkgs/development/misc/windows-sdk/builder.sh
@@ -1,6 +1,6 @@
 source $stdenv/setup
 
-ensureDir $out
+mkdir -p $out
 
 n=1
 for p in $srcs; do
@@ -21,7 +21,7 @@ done
 while read target; do
     read source
     echo "$source -> $target"
-    ensureDir "$out/$(dirname "$target")"
+    mkdir -p "$out/$(dirname "$target")"
     cp "$source" "$out/$target"
 done < $filemap
 
diff --git a/pkgs/development/ocaml-modules/batteries/default.nix b/pkgs/development/ocaml-modules/batteries/default.nix
index a7c96f1d2ea78..3ecf2ae46994a 100644
--- a/pkgs/development/ocaml-modules/batteries/default.nix
+++ b/pkgs/development/ocaml-modules/batteries/default.nix
@@ -21,7 +21,7 @@ stdenv.mkDerivation {
   configurePhase = "true"; 	# Skip configure
 
   preInstall = ''
-    ensureDir "$out/lib/ocaml/${ocaml_version}/site-lib"
+    mkdir -p "$out/lib/ocaml/${ocaml_version}/site-lib"
   '';
 
   doCheck = true;
diff --git a/pkgs/development/ocaml-modules/cryptokit/default.nix b/pkgs/development/ocaml-modules/cryptokit/default.nix
index 8aa3f2ba77e79..48e86ed9a68ff 100644
--- a/pkgs/development/ocaml-modules/cryptokit/default.nix
+++ b/pkgs/development/ocaml-modules/cryptokit/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation {
 
   buildFlags = "setup.data build";
 
-  preBuild = "ensureDir $out/lib/ocaml/${ocaml_version}/site-lib/cryptokit";
+  preBuild = "mkdir -p $out/lib/ocaml/${ocaml_version}/site-lib/cryptokit";
 
   meta = {
     homepage = "http://pauillac.inria.fr/~xleroy/software.html";
diff --git a/pkgs/development/ocaml-modules/lablgtkmathview/default.nix b/pkgs/development/ocaml-modules/lablgtkmathview/default.nix
index 13c25495cdc6d..976910aae29aa 100644
--- a/pkgs/development/ocaml-modules/lablgtkmathview/default.nix
+++ b/pkgs/development/ocaml-modules/lablgtkmathview/default.nix
@@ -26,7 +26,7 @@ stdenv.mkDerivation {
   '';
 
   buildPhase = ''
-    ensureDir .test
+    mkdir -p .test
     make
     make opt
   '';
diff --git a/pkgs/development/ocaml-modules/sqlite3/default.nix b/pkgs/development/ocaml-modules/sqlite3/default.nix
index 9b477fed85173..1903068bb0b2f 100644
--- a/pkgs/development/ocaml-modules/sqlite3/default.nix
+++ b/pkgs/development/ocaml-modules/sqlite3/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation {
 
   preConfigure = ''
     export OCAMLPATH=$OCAMLPATH:$OCAMLFIND_DESTDIR
-    ensureDir $out/bin
+    mkdir -p $out/bin
   '';
 
   createFindlibDestdir = true;
diff --git a/pkgs/development/perl-modules/DB_File/default.nix b/pkgs/development/perl-modules/DB_File/default.nix
index adf66a4480655..858d459f5ca17 100644
--- a/pkgs/development/perl-modules/DB_File/default.nix
+++ b/pkgs/development/perl-modules/DB_File/default.nix
@@ -21,7 +21,7 @@ buildPerlPackage {
   # lib/perl5/site_perl, and the *.pm should be inside lib/perl5/site_perl/...
   # for other packages to get that in the PERL5LIB env var.
   postInstall = ''
-    ensureDir $out/lib/perl5/site_perl/
+    mkdir -p $out/lib/perl5/site_perl/
     cp -R $out/lib/perl5/5* $out/lib/perl5/site_perl
   '';
 }
diff --git a/pkgs/development/python-modules/generic/default.nix b/pkgs/development/python-modules/generic/default.nix
index 46149177320d9..4e0b610023167 100644
--- a/pkgs/development/python-modules/generic/default.nix
+++ b/pkgs/development/python-modules/generic/default.nix
@@ -50,7 +50,7 @@ python.stdenv.mkDerivation (attrs // {
   # XXX: Should we run `easy_install --always-unzip'?  It doesn't seem
   # to have a noticeable impact on small scripts.
   installPhase = ''
-    ensureDir "$out/lib/${python.libPrefix}/site-packages"
+    mkdir -p "$out/lib/${python.libPrefix}/site-packages"
 
     echo "installing \`${name}' with \`easy_install'..."
     export PYTHONPATH="$out/lib/${python.libPrefix}/site-packages:$PYTHONPATH"
diff --git a/pkgs/development/python-modules/xmpppy/default.nix b/pkgs/development/python-modules/xmpppy/default.nix
index 3fc8058dfb2a3..df5d37853f72c 100644
--- a/pkgs/development/python-modules/xmpppy/default.nix
+++ b/pkgs/development/python-modules/xmpppy/default.nix
@@ -19,7 +19,7 @@ rec {
   /* doConfigure should be removed if not needed */
   phaseNames = ["mkDirs" "installPythonPackage"];
   mkDirs = a.fullDepEntry(''
-    ensureDir $out/bin $out/lib $out/share $(toPythonPath $out)
+    mkdir -p $out/bin $out/lib $out/share $(toPythonPath $out)
     export PYTHONPATH=$PYTHONPATH:$(toPythonPath $out)
   '') ["defEnsureDir" "addInputs"];
       
diff --git a/pkgs/development/ruby-modules/rake/default.nix b/pkgs/development/ruby-modules/rake/default.nix
index 00bad68b695e1..e1cec53aaa061 100644
--- a/pkgs/development/ruby-modules/rake/default.nix
+++ b/pkgs/development/ruby-modules/rake/default.nix
@@ -14,8 +14,8 @@ stdenv.mkDerivation {
   '';
   buildPhase = "true";
   installPhase = ''
-    ensureDir $out/lib
-    ensureDir $out/bin
+    mkdir -p $out/lib
+    mkdir -p $out/bin
     export DESTDIR=$out
     ruby install.rb
   '';
diff --git a/pkgs/development/ruby-modules/sqlite3/default.nix b/pkgs/development/ruby-modules/sqlite3/default.nix
index a37e91c488ff7..33a8951921e7a 100644
--- a/pkgs/development/ruby-modules/sqlite3/default.nix
+++ b/pkgs/development/ruby-modules/sqlite3/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation {
   buildInputs = [ruby sqlite];
   buildPhase = "true";
   installPhase = ''
-    ensureDir $out/lib
+    mkdir -p $out/lib
     ruby setup.rb config --prefix=$out 
     # --bindir $out/bin --libdir $out/lib
     ruby setup.rb setup
diff --git a/pkgs/development/tools/analysis/checkstyle/default.nix b/pkgs/development/tools/analysis/checkstyle/default.nix
index 17fc8de8c95ca..09656dc520a85 100644
--- a/pkgs/development/tools/analysis/checkstyle/default.nix
+++ b/pkgs/development/tools/analysis/checkstyle/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
   };
 
   installPhase = ''
-    ensureDir $out/checkstyle
+    mkdir -p $out/checkstyle
     cp -R * $out/checkstyle
   '';
 
diff --git a/pkgs/development/tools/analysis/emma/default.nix b/pkgs/development/tools/analysis/emma/default.nix
index 97e061d6b3f59..8275beff88d0c 100644
--- a/pkgs/development/tools/analysis/emma/default.nix
+++ b/pkgs/development/tools/analysis/emma/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
   buildInputs = [unzip];
 
   installPhase = ''
-    ensureDir $out/lib/jars
+    mkdir -p $out/lib/jars
     cp lib/*.jar $out/lib/jars/
   '';
 
diff --git a/pkgs/development/tools/analysis/findbugs/default.nix b/pkgs/development/tools/analysis/findbugs/default.nix
index cf4f87f528e12..0623632936d75 100644
--- a/pkgs/development/tools/analysis/findbugs/default.nix
+++ b/pkgs/development/tools/analysis/findbugs/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp -prd bin lib plugin doc $out/
     rm $out/bin/*.bat
   '';
diff --git a/pkgs/development/tools/analysis/jdepend/default.nix b/pkgs/development/tools/analysis/jdepend/default.nix
index 6973fbad9e7c3..7498d3b652ac8 100644
--- a/pkgs/development/tools/analysis/jdepend/default.nix
+++ b/pkgs/development/tools/analysis/jdepend/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
   };
 
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp -R * $out
   '';
 
diff --git a/pkgs/development/tools/analysis/pmd/default.nix b/pkgs/development/tools/analysis/pmd/default.nix
index 7f50431c8d9a7..b830ee008389f 100644
--- a/pkgs/development/tools/analysis/pmd/default.nix
+++ b/pkgs/development/tools/analysis/pmd/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
   };
 
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp -R * $out
   '';
 
diff --git a/pkgs/development/tools/analysis/spin/default.nix b/pkgs/development/tools/analysis/spin/default.nix
index cedd9584414fb..b4fdd4c09d4de 100644
--- a/pkgs/development/tools/analysis/spin/default.nix
+++ b/pkgs/development/tools/analysis/spin/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation {
     sed -i -e 's/-DNXT/-DNXT -DCPP="\\"gcc -E -x c\\""/' makefile
   '';
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp ../Xspin*/xsp* $out/bin/xspin
     sed -i -e '1s@^#!/bin/sh@#!${tk}/bin/wish@' \
       -e '/exec wish/d' $out/bin/xspin
diff --git a/pkgs/development/tools/build-managers/apache-ant/from-source.nix b/pkgs/development/tools/build-managers/apache-ant/from-source.nix
index a5a19a6714368..ef6763a0fa28a 100644
--- a/pkgs/development/tools/build-managers/apache-ant/from-source.nix
+++ b/pkgs/development/tools/build-managers/apache-ant/from-source.nix
@@ -39,7 +39,7 @@ EOF
 
   # Note: We don't build the javadoc.
   buildPhase = ''
-    ensureDir "$out"
+    mkdir -p "$out"
     ./build.sh -Dant.install="$out" install-lite
   '';
 
@@ -48,7 +48,7 @@ EOF
     # rearrange a few things.
     rm -v "$out/bin/"*.bat
 
-    ensureDir "$out/lib/java"
+    mkdir -p "$out/lib/java"
     mv -v "$out/lib/"*.jar "$out/lib/java"
     sed -i "$out/bin/ant" \
         -e "s|^ANT_LIB=.*$|ANT_LIB=$out/lib/java|g ;
diff --git a/pkgs/development/tools/build-managers/bam/default.nix b/pkgs/development/tools/build-managers/bam/default.nix
index ef5aed1f26edb..e7e4b6d090922 100644
--- a/pkgs/development/tools/build-managers/bam/default.nix
+++ b/pkgs/development/tools/build-managers/bam/default.nix
@@ -38,9 +38,9 @@ rec {
   '' ["build" "addInputs"];
 
   doDeploy = a.fullDepEntry ''
-    ensureDir "$out/share/bam"
+    mkdir -p "$out/share/bam"
     cp -r docs examples tests  "$out/share/bam"
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     cp bam "$out/bin"
   '' ["minInit" "defEnsureDir" "build"];
       
diff --git a/pkgs/development/tools/build-managers/buildbot/default.nix b/pkgs/development/tools/build-managers/buildbot/default.nix
index 92b63869f33be..71862ec1cf75e 100644
--- a/pkgs/development/tools/build-managers/buildbot/default.nix
+++ b/pkgs/development/tools/build-managers/buildbot/default.nix
@@ -26,7 +26,7 @@ buildPythonPackage (rec {
   doCheck = false;
 
   postInstall =
-    '' ensureDir "$out/share/info"
+    '' mkdir -p "$out/share/info"
        make -C docs buildbot.info
        cp -v "docs/buildbot.info"* "$out/share/info"
     '';
diff --git a/pkgs/development/tools/build-managers/cmake/default.nix b/pkgs/development/tools/build-managers/cmake/default.nix
index a3a10525c0857..51d6d9a741202 100644
--- a/pkgs/development/tools/build-managers/cmake/default.nix
+++ b/pkgs/development/tools/build-managers/cmake/default.nix
@@ -7,11 +7,10 @@ with stdenv.lib;
 let
   os = stdenv.lib.optionalString;
   majorVersion = "2.8";
-  minorVersion = "4";
+  minorVersion = "7";
   version = "${majorVersion}.${minorVersion}";
 in
 
-# WARNING: Do NOT upgrade cmake in trunk: it fails to build on i686-linux
 stdenv.mkDerivation rec {
   name = "cmake-${os useNcurses "cursesUI-"}${os useQt4 "qt4UI-"}${version}";
 
@@ -19,7 +18,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}files/v${majorVersion}/cmake-${version}.tar.gz";
-    sha256 = "1k2kjaj3vfifb329ff7fr4hcbpbaqb66l97pshq70h7m0zwajznr";
+    sha256 = "17zmxh0gyis6w05d2km0swlvy94h3w10jgra0fpa5qcg7l2j628k";
   };
 
   patches =
@@ -40,15 +39,12 @@ stdenv.mkDerivation rec {
 
   setupHook = ./setup-hook.sh;
 
-  postUnpack =
-    ''
-      dontUseCmakeConfigure=1
-      source $setupHook
-      fixCmakeFiles $sourceRoot
-    '';
+  dontUseCmakeConfigure = true;
 
   preConfigure = optionalString (stdenv ? glibc)
     ''
+      source $setupHook
+      fixCmakeFiles .
       substituteInPlace Modules/Platform/UnixPaths.cmake --subst-var-by glibc ${stdenv.glibc}
     '';
 
diff --git a/pkgs/development/tools/build-managers/cmake/setup-hook.sh b/pkgs/development/tools/build-managers/cmake/setup-hook.sh
index c523e849fc152..32e0b76f608a4 100755
--- a/pkgs/development/tools/build-managers/cmake/setup-hook.sh
+++ b/pkgs/development/tools/build-managers/cmake/setup-hook.sh
@@ -1,36 +1,35 @@
-addCMakeParams()
-{
+addCMakeParams() {
     addToSearchPath CMAKE_PREFIX_PATH $1
 }
 
-fixCmakeFiles()
-{
-    local replaceArgs
-    echo "fixing cmake files"
-    replaceArgs="-e -f -L -T /usr /var/empty -a /opt /var/empty"
-    find $1 -type f -name "*.cmake" -o -name "*.cmake.in" -o -name CMakeLists.txt -print0 |
-        xargs -0 replace-literal ${replaceArgs}
+fixCmakeFiles() {
+    # Replace occurences of /usr and /opt by /var/empty.
+    echo "fixing cmake files..."
+    find "$1" \( -type f -name "*.cmake" -o -name "*.cmake.in" -o -name CMakeLists.txt \) -print |
+        while read fn; do
+            sed -e 's^/usr\([ /]\|$\)^/var/empty\1^g' -e 's^/opt\([ /]\|$\)^/var/empty\1^g' < "$fn" > "$fn.tmp"
+            mv "$fn.tmp" "$fn"
+        done
 }
 
-cmakeConfigurePhase()
-{
+cmakeConfigurePhase() {
     eval "$preConfigure"
 
-    if test -z "$dontFixCmake"; then
+    if [ -z "$dontFixCmake" ]; then
         fixCmakeFiles .
     fi
 
-    if test -z "$dontUseCmakeBuildDir"; then
+    if [ -z "$dontUseCmakeBuildDir" ]; then
         mkdir -p build
         cd build
         cmakeDir=..
     fi
 
-    if test -z "$dontAddPrefix"; then
+    if [ -z "$dontAddPrefix" ]; then
         cmakeFlags="-DCMAKE_INSTALL_PREFIX=$prefix $cmakeFlags"
     fi
 
-    if test -n "$crossConfig"; then
+    if [ -n "$crossConfig" ]; then
         # By now it supports linux builds only. We should set the proper
         # CMAKE_SYSTEM_NAME otherwise.
         # http://www.cmake.org/Wiki/CMake_Cross_Compiling
@@ -38,7 +37,8 @@ cmakeConfigurePhase()
     fi
 
     # Avoid cmake resetting the rpath of binaries, on make install
-    cmakeFlags="-DCMAKE_SKIP_BUILD_RPATH=ON $cmakeFlags"
+    # And build always Release, to ensure optimisation flags
+    cmakeFlags="-DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_BUILD_RPATH=ON $cmakeFlags"
 
     echo "cmake flags: $cmakeFlags ${cmakeFlagsArray[@]}"
 
@@ -47,11 +47,11 @@ cmakeConfigurePhase()
     eval "$postConfigure"
 }
 
-if test -z "$dontUseCmakeConfigure"; then
+if [ -z "$dontUseCmakeConfigure" ]; then
     configurePhase=cmakeConfigurePhase
 fi
 
-if test -n "$crossConfig"; then
+if [ -n "$crossConfig" ]; then
     crossEnvHooks+=(addCMakeParams)
 else
     envHooks+=(addCMakeParams)
diff --git a/pkgs/development/tools/build-managers/gradle/default.nix b/pkgs/development/tools/build-managers/gradle/default.nix
index 9fc25aad64d21..576d8e357f4b8 100644
--- a/pkgs/development/tools/build-managers/gradle/default.nix
+++ b/pkgs/development/tools/build-managers/gradle/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   };
 
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     rm bin/*.bat
     mv * $out
   '';
diff --git a/pkgs/development/tools/build-managers/jam/default.nix b/pkgs/development/tools/build-managers/jam/default.nix
index 6e2d79c6400d8..434e23d9b9901 100644
--- a/pkgs/development/tools/build-managers/jam/default.nix
+++ b/pkgs/development/tools/build-managers/jam/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
   };
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp ${bindir}/jam $out/bin
   '';
 
diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix
index b4238a99ab5c6..353cd9f40bce0 100644
--- a/pkgs/development/tools/misc/binutils/default.nix
+++ b/pkgs/development/tools/misc/binutils/default.nix
@@ -1,30 +1,12 @@
 { stdenv, fetchurl, noSysDirs, zlib, cross ? null, gold ? false, bison ? null, flex2535 ? null, bc ? null, dejagnu ? null }:
 
-let
-    basename = "binutils-2.21";
-in
+let basename = "binutils-2.21.1a"; in
 stdenv.mkDerivation rec {
   name = basename + stdenv.lib.optionalString (cross != null) "-${cross.config}";
 
-  # WARNING: Upstream made a mistake in packaging that may mean anyone
-  # but the FSF hosting this tarball is accidentally in violation of
-  # the GPL. We can't update binutils until the next stdenv-updates,
-  # so we are stuck with this version. The issue is discussed in
-  # this email: http://sourceware.org/ml/binutils/2011-08/msg00198.html
-  # The tarball for this minor version will not be fixed, as only the
-  # tarballs for the latest minor version of each major version will
-  # be repackaged. The fixed sources for the closest version to this one
-  # can be found at mirror://gnu/binutils/binutils-2.21.1a.tar.bz2
-  # or http://ftp.gnu.org/gnu/binutils/binutils-2.21.1a.tar.bz2
-  # The sources missing from this tarball come from cgen. It is unclear
-  # WHICH sources should be included, but the cvs tree can be checked out
-  # by:
-  # cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src login
-  # {enter "anoncvs" as the password}
-  # cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src co cgen
   src = fetchurl {
-    url = "http://nixos.org/tarballs/${basename}.tar.bz2";
-    sha256 = "1iyhc42zfa0j2gaxy4zvpk47sdqj4rqvib0mb8597ss8yidyrav0";
+    url = "mirror://gnu/binutils/${basename}.tar.bz2";
+    sha256 = "0m7nmd7gc9d9md43wbrv65hz6lbi2crqwryzpigv19ray1lzmv6d";
   };
 
   patches = [
@@ -49,16 +31,22 @@ stdenv.mkDerivation rec {
     # Use symlinks instead of hard links to save space ("strip" in the
     # fixup phase strips each hard link separately).
     for i in binutils/Makefile.in gas/Makefile.in ld/Makefile.in; do
-        substituteInPlace $i --replace 'ln ' 'ln -s '
+        sed -i "$i" -e 's|ln |ln -s |'
     done
   '';
 
+  # As binutils takes part in the stdenv building, we don't want references
+  # to the bootstrap-tools libgcc (as uses to happen on arm/mips)
+  NIX_CFLAGS_COMPILE = "-static-libgcc";
+
   configureFlags = "--disable-werror" # needed for dietlibc build
       + stdenv.lib.optionalString (stdenv.system == "mips64el-linux")
         " --enable-fix-loongson2f-nop"
       + stdenv.lib.optionalString (cross != null) " --target=${cross.config}"
       + stdenv.lib.optionalString gold " --enable-gold";
 
+  enableParallelBuilding = true;
+      
   meta = {
     description = "GNU Binutils, tools for manipulating binaries (linker, assembler, etc.)";
 
diff --git a/pkgs/development/tools/misc/cbrowser/default.nix b/pkgs/development/tools/misc/cbrowser/default.nix
index 50dc907a78043..bf927db2793c4 100644
--- a/pkgs/development/tools/misc/cbrowser/default.nix
+++ b/pkgs/development/tools/misc/cbrowser/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ tk makeWrapper ];
 
   installPhase = ''
-    ensureDir $out/bin $out/share/${name}
+    mkdir -p $out/bin $out/share/${name}
     cp -R * $out/share/${name}/
 
     makeWrapper $out/share/${name}/cbrowser $out/bin/cbrowser \
diff --git a/pkgs/development/tools/misc/cppi/default.nix b/pkgs/development/tools/misc/cppi/default.nix
index b6c0e9a99b45c..c72aa02a88a05 100644
--- a/pkgs/development/tools/misc/cppi/default.nix
+++ b/pkgs/development/tools/misc/cppi/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, xz, stdenv }:
+{ fetchurl, stdenv }:
 
 stdenv.mkDerivation rec {
   name = "cppi-1.15";
@@ -8,8 +8,6 @@ stdenv.mkDerivation rec {
     sha256 = "1avwwpcwx6rvk9j4id8jq58n5kk756dwnd0wqw4a4p3smvby7gw2";
   };
 
-  buildInputs = [ xz ];
-
   doCheck = true;
 
   meta = {
diff --git a/pkgs/development/tools/misc/cscope/default.nix b/pkgs/development/tools/misc/cscope/default.nix
index c27c7ab291a29..3cba5cd2e76a2 100644
--- a/pkgs/development/tools/misc/cscope/default.nix
+++ b/pkgs/development/tools/misc/cscope/default.nix
@@ -24,10 +24,10 @@ stdenv.mkDerivation rec {
     # Install Emacs mode.
     cd "contrib/xcscope"
 
-    ensureDir "$out/libexec/cscope"
+    mkdir -p "$out/libexec/cscope"
     cp "cscope-indexer" "$out/libexec/cscope"
 
-    ensureDir "$out/share/emacs/site-lisp"
+    mkdir -p "$out/share/emacs/site-lisp"
     emacs --batch --eval '(byte-compile-file "xcscope.el")'
     cp xcscope.el{,c} "$out/share/emacs/site-lisp"
   '';
diff --git a/pkgs/development/tools/misc/elfutils/default.nix b/pkgs/development/tools/misc/elfutils/default.nix
index 6254b955a239a..61b4647552d55 100644
--- a/pkgs/development/tools/misc/elfutils/default.nix
+++ b/pkgs/development/tools/misc/elfutils/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, m4, zlib, bzip2, xz, bison, flex, gettext}:
+{stdenv, fetchurl, m4, zlib, bzip2, bison, flex, gettext}:
 
 # TODO: Look at the hardcoded paths to kernel, modules etc.
 stdenv.mkDerivation rec {
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
   # We need bzip2 in NativeInputs because otherwise we can't unpack the src,
   # as the host-bzip2 will be in the path.
   buildNativeInputs = [m4 bison flex gettext bzip2];
-  buildInputs = [zlib bzip2 xz];
+  buildInputs = [zlib bzip2];
 
   crossAttrs = {
 
diff --git a/pkgs/development/tools/misc/global/default.nix b/pkgs/development/tools/misc/global/default.nix
index fef5a71201ab7..6e6464a590beb 100644
--- a/pkgs/development/tools/misc/global/default.nix
+++ b/pkgs/development/tools/misc/global/default.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
   doCheck = true;
 
   postInstall = ''
-    ensureDir "$out/share/emacs/site-lisp"
+    mkdir -p "$out/share/emacs/site-lisp"
     cp -v *.el "$out/share/emacs/site-lisp"
   '';
 
diff --git a/pkgs/development/tools/misc/gnum4/default.nix b/pkgs/development/tools/misc/gnum4/default.nix
index df417c3e55e82..12cc50a37a00e 100644
--- a/pkgs/development/tools/misc/gnum4/default.nix
+++ b/pkgs/development/tools/misc/gnum4/default.nix
@@ -1,17 +1,17 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation {
-  name = "gnum4-1.4.15";
+  name = "gnum4-1.4.16";
 
   src = fetchurl {
-    url = mirror://gnu/m4/m4-1.4.15.tar.bz2;
-    sha256 = "1ygzshj4h6l6wh52vjqczkyahmv67r3yzi1m6nkh94qgndffmbqa";
+    url = mirror://gnu/m4/m4-1.4.16.tar.bz2;
+    sha256 = "035r7ma272j2cwni2961jp22k6bn3n9xwn3b3qbcn2yrvlghql22";
   };
 
   doCheck = !stdenv.isDarwin;
 
   # Upstream is aware of it; it may be in the next release.
-  patches = [ ./s_isdir.patch ];
+  patches = [ ./s_isdir.patch ./readlink-EINVAL.patch ];
 
   meta = {
     homepage = http://www.gnu.org/software/m4/;
diff --git a/pkgs/development/tools/misc/gnum4/readlink-EINVAL.patch b/pkgs/development/tools/misc/gnum4/readlink-EINVAL.patch
new file mode 100644
index 0000000000000..dd371584a798f
--- /dev/null
+++ b/pkgs/development/tools/misc/gnum4/readlink-EINVAL.patch
@@ -0,0 +1,18 @@
+Newer Linux kernels would return EINVAL instead of ENOENT.
+The patch below, taken from Gnulib, allows the test to pass when
+these Linux versions are in use:
+https://lists.gnu.org/archive/html/bug-gnulib/2011-03/msg00308.html .
+
+diff --git a/tests/test-readlink.h b/tests/test-readlink.h
+index 08d5662..7247fc4 100644
+--- a/tests/test-readlink.h
++++ b/tests/test-readlink.h
+@@ -38,7 +38,7 @@ test_readlink (ssize_t (*func) (char const *, char *, size_t), bool print)
+   ASSERT (errno == ENOENT);
+   errno = 0;
+   ASSERT (func ("", buf, sizeof buf) == -1);
+-  ASSERT (errno == ENOENT);
++  ASSERT (errno == ENOENT || errno == EINVAL);
+   errno = 0;
+   ASSERT (func (".", buf, sizeof buf) == -1);
+   ASSERT (errno == EINVAL);
diff --git a/pkgs/development/tools/misc/lsof/default.nix b/pkgs/development/tools/misc/lsof/default.nix
index f679577a3f1a0..69503782d6efc 100644
--- a/pkgs/development/tools/misc/lsof/default.nix
+++ b/pkgs/development/tools/misc/lsof/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation {
   configurePhase = "./Configure -n linux;";
   
   installPhase = ''
-    ensureDir $out/bin $out/man/man8
+    mkdir -p $out/bin $out/man/man8
     cp lsof.8 $out/man/man8/
     cp lsof $out/bin
   '';
diff --git a/pkgs/development/tools/misc/ninka/default.nix b/pkgs/development/tools/misc/ninka/default.nix
index dddb577edbf31..1cb491df8d1ec 100644
--- a/pkgs/development/tools/misc/ninka/default.nix
+++ b/pkgs/development/tools/misc/ninka/default.nix
@@ -25,12 +25,12 @@ stdenv.mkDerivation {
   
   installPhase = ''
     cd ../..
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp ninka.pl $out/bin
     cp -av {extComments,splitter,filter,senttok,matcher} $out/bin
     
     cd comments/comments    
-    ensureDir $out/{bin,share/man/man1}
+    mkdir -p $out/{bin,share/man/man1}
     make install    
   '';
   
diff --git a/pkgs/development/tools/misc/patchelf/0.6.nix b/pkgs/development/tools/misc/patchelf/0.6.nix
deleted file mode 100644
index 857aa1cabcf95..0000000000000
--- a/pkgs/development/tools/misc/patchelf/0.6.nix
+++ /dev/null
@@ -1,16 +0,0 @@
-{ stdenv, fetchurl }:
-
-stdenv.mkDerivation rec {
-  name = "patchelf-0.6";
-
-  src = fetchurl {
-    url = "http://nixos.org/releases/patchelf/${name}/${name}.tar.bz2";
-    sha256 = "fc7e7fa95f282fc37a591a802629e0e1ed07bc2a8bf162228d9a69dd76127c01";
-  };
-
-  meta = {
-    homepage = http://nixos.org/patchelf.html;
-    license = "GPL";
-    description = "A small utility to modify the dynamic linker and RPATH of ELF executables";
-  };
-}
diff --git a/pkgs/development/tools/misc/patchelf/default.nix b/pkgs/development/tools/misc/patchelf/default.nix
index 43944ca9acd36..857aa1cabcf95 100644
--- a/pkgs/development/tools/misc/patchelf/default.nix
+++ b/pkgs/development/tools/misc/patchelf/default.nix
@@ -1,11 +1,11 @@
-{stdenv, fetchurl}:
+{ stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "patchelf-0.5";
-  
+  name = "patchelf-0.6";
+
   src = fetchurl {
     url = "http://nixos.org/releases/patchelf/${name}/${name}.tar.bz2";
-    sha256 = "24b9a850af45e1a277e234b9eb090b52305a2e1c6b02addeb3ae98b4b49d37ce";
+    sha256 = "fc7e7fa95f282fc37a591a802629e0e1ed07bc2a8bf162228d9a69dd76127c01";
   };
 
   meta = {
diff --git a/pkgs/development/tools/misc/sloccount/default.nix b/pkgs/development/tools/misc/sloccount/default.nix
index 906770e90665d..e7adb30d3166c 100644
--- a/pkgs/development/tools/misc/sloccount/default.nix
+++ b/pkgs/development/tools/misc/sloccount/default.nix
@@ -37,9 +37,9 @@ stdenv.mkDerivation rec {
   checkPhase = ''HOME="$TMPDIR" PATH="$PWD:$PATH" make test'';
 
   preInstall = ''
-    ensureDir "$out/bin"
-    ensureDir "$out/share/man/man1"
-    ensureDir "$out/share/doc"
+    mkdir -p "$out/bin"
+    mkdir -p "$out/share/man/man1"
+    mkdir -p "$out/share/doc"
   '';
 
   meta = {
diff --git a/pkgs/development/tools/misc/strace/default.nix b/pkgs/development/tools/misc/strace/default.nix
index 6bd2619e4d322..b3cf2fcbddae4 100644
--- a/pkgs/development/tools/misc/strace/default.nix
+++ b/pkgs/development/tools/misc/strace/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, xz, perl }:
+{ stdenv, fetchurl, perl }:
 
 stdenv.mkDerivation rec {
   name = "strace-4.6";
@@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
     sha256 = "12n2faqq7whmszpjhv2lcb06r7900j53p0zl7vipi18inr0smycy";
   };
 
-  buildNativeInputs = [ xz perl ];
+  buildNativeInputs = [ perl ];
 
   meta = {
     homepage = http://strace.sourceforge.net/;
diff --git a/pkgs/development/tools/misc/unifdef/default.nix b/pkgs/development/tools/misc/unifdef/default.nix
index 30afee4586b05..f4b38f4f7abcd 100644
--- a/pkgs/development/tools/misc/unifdef/default.nix
+++ b/pkgs/development/tools/misc/unifdef/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp unifdef $out/bin
   '';
 
diff --git a/pkgs/development/tools/misc/usb-modeswitch/default.nix b/pkgs/development/tools/misc/usb-modeswitch/default.nix
index a883024690aee..48a823c3c6569 100644
--- a/pkgs/development/tools/misc/usb-modeswitch/default.nix
+++ b/pkgs/development/tools/misc/usb-modeswitch/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation {
   preConfigure = ''
     find -type f | xargs sed 's@/bin/rm@rm@g' -i
     make clean
-    ensureDir $out/{etc,lib/udev,share/man/man1}
+    mkdir -p $out/{etc,lib/udev,share/man/man1}
     makeFlags="DESTDIR=$out PREFIX=$out"
   '';
 
diff --git a/pkgs/development/tools/ocaml/camlidl/default.nix b/pkgs/development/tools/ocaml/camlidl/default.nix
index 8f77c0c6fc0d1..d049377ea9494 100644
--- a/pkgs/development/tools/ocaml/camlidl/default.nix
+++ b/pkgs/development/tools/ocaml/camlidl/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation {
     mv config/Makefile.unix config/Makefile
     substituteInPlace config/Makefile --replace BINDIR=/usr/local/bin BINDIR=$out
     substituteInPlace config/Makefile --replace OCAMLLIB=/usr/local/lib/ocaml OCAMLLIB=$out/lib/ocaml/${ocaml_version}/site-lib/camlidl
-    ensureDir $out/lib/ocaml/${ocaml_version}/site-lib/camlidl/caml
+    mkdir -p $out/lib/ocaml/${ocaml_version}/site-lib/camlidl/caml
   '';
 
   meta = {
diff --git a/pkgs/development/tools/ocaml/findlib/default.nix b/pkgs/development/tools/ocaml/findlib/default.nix
index 70fb45a197958..c89af03097d7b 100644
--- a/pkgs/development/tools/ocaml/findlib/default.nix
+++ b/pkgs/development/tools/ocaml/findlib/default.nix
@@ -40,7 +40,7 @@ stdenv.mkDerivation {
         fi
         export OCAMLFIND_DESTDIR="''$out/lib/ocaml/${ocaml_version}/site-lib/"
         if test -n "$createFindlibDestdir"; then
-          ensureDir $OCAMLFIND_DESTDIR
+          mkdir -p $OCAMLFIND_DESTDIR
         fi
     }
     
diff --git a/pkgs/development/tools/parsing/antlr/builder.sh b/pkgs/development/tools/parsing/antlr/builder.sh
index 1d9f352c56989..b8e7791b6fc9b 100644
--- a/pkgs/development/tools/parsing/antlr/builder.sh
+++ b/pkgs/development/tools/parsing/antlr/builder.sh
@@ -4,8 +4,8 @@ tar zxvf $src
 cd antlr-*
 cd lib
 
-ensureDir $out/lib/antlr
-ensureDir $out/bin
+mkdir -p $out/lib/antlr
+mkdir -p $out/bin
 
 cp *.jar $out/lib/antlr
 
diff --git a/pkgs/development/tools/parsing/bison/bison-2.5.nix b/pkgs/development/tools/parsing/bison/bison-2.5.nix
index 24fc0d1bbb355..98c465a185cfb 100644
--- a/pkgs/development/tools/parsing/bison/bison-2.5.nix
+++ b/pkgs/development/tools/parsing/bison/bison-2.5.nix
@@ -10,6 +10,9 @@ stdenv.mkDerivation rec {
 
   buildNativeInputs = [ m4 ]
     ++ stdenv.lib.optional doCheck perl;
+  propagatedBuildInputs = [ m4 ];
+
+  M4 = "m4";
 
   doCheck = true;
 
diff --git a/pkgs/development/tools/parsing/jikespg/builder.sh b/pkgs/development/tools/parsing/jikespg/builder.sh
index 090def7c46434..e63ec9808f23a 100644
--- a/pkgs/development/tools/parsing/jikespg/builder.sh
+++ b/pkgs/development/tools/parsing/jikespg/builder.sh
@@ -8,7 +8,7 @@ configurePhase() {
 }
 
 installPhase() {
-  ensureDir $out/bin
+  mkdir -p $out/bin
   cp jikespg $out/bin
 }
 
diff --git a/pkgs/development/tools/selenium/remote-control/default.nix b/pkgs/development/tools/selenium/remote-control/default.nix
index 0a7a12a6e1711..fbe11ed2bc040 100644
--- a/pkgs/development/tools/selenium/remote-control/default.nix
+++ b/pkgs/development/tools/selenium/remote-control/default.nix
@@ -16,7 +16,7 @@ in stdenv.mkDerivation {
     buildInputs = [unzip];
     phases = "unpackPhase buildPhase";
     buildPhase = ''
-      ensureDir $out/{bin,lib}
+      mkdir -p $out/{bin,lib}
       mv * $out/lib
       bin="$out/bin/selenium-remote-control"
       cat >> "$bin" << EOF
@@ -37,7 +37,7 @@ in stdenv.mkDerivation {
     };
     phases = "buildPhase";
     buildPhase = ''
-      ensureDir $out/{bin,lib}
+      mkdir -p $out/{bin,lib}
       cp $src $out/lib/
       bin="$out/bin/selenium-remote-control"
       cat >> "$bin" << EOF
diff --git a/pkgs/development/web/csslint/default.nix b/pkgs/development/web/csslint/default.nix
index 6f09603b2d56b..668ff6a7f4ae9 100644
--- a/pkgs/development/web/csslint/default.nix
+++ b/pkgs/development/web/csslint/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
 
   installPhase = ''
     sed -i "s/path\.join/path\.resolve/g" cli.js # fixes csslint issue #167
-    ensureDir $out/bin;
+    mkdir -p $out/bin;
     cp -r * $out/bin
     mv $out/bin/cli.js $out/bin/csslint
   '';
diff --git a/pkgs/games/banner/default.nix b/pkgs/games/banner/default.nix
index 73d08fda79f6d..3bb17b3e02f90 100644
--- a/pkgs/games/banner/default.nix
+++ b/pkgs/games/banner/default.nix
@@ -19,7 +19,7 @@ let
     installPhase = ''
       make INSTBASEDIR=$out install
       if [ -d $out/man ]; then
-        ensureDir $out/share
+        mkdir -p $out/share
 	mv -v $out/man $out/share/
       fi
     '';
diff --git a/pkgs/games/beret/default.nix b/pkgs/games/beret/default.nix
index e41e88fc1b066..2e252a5cd540a 100644
--- a/pkgs/games/beret/default.nix
+++ b/pkgs/games/beret/default.nix
@@ -22,9 +22,9 @@ stdenv.mkDerivation {
   };
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     install -v -m755 beret $out/bin
-    ensureDir $out/share
+    mkdir -p $out/share
     cp -av tahoma.ttf images music rooms sfx $out/share
   '';
 
diff --git a/pkgs/games/blackshades/default.nix b/pkgs/games/blackshades/default.nix
index 8a79326bdead5..61e8571c47669 100644
--- a/pkgs/games/blackshades/default.nix
+++ b/pkgs/games/blackshades/default.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
   '';
 
   installPhase = ''
-    ensureDir $out/bin $out/opt/$name
+    mkdir -p $out/bin $out/opt/$name
     cp objs/blackshades $out/bin
     cp -R Data IF* Readme $out/opt/$name/
   '';
diff --git a/pkgs/games/blackshadeselite/default.nix b/pkgs/games/blackshadeselite/default.nix
index 64d94196c64db..63139872cf9ca 100644
--- a/pkgs/games/blackshadeselite/default.nix
+++ b/pkgs/games/blackshadeselite/default.nix
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
   '';
 
   installPhase = ''
-    ensureDir $out/bin $out/opt/$name
+    mkdir -p $out/bin $out/opt/$name
     cp objs/blackshades $out/bin/blackshadeselite
     cp -R Data IF* Readme $out/opt/$name/
   '';
diff --git a/pkgs/games/castle-combat/default.nix b/pkgs/games/castle-combat/default.nix
index 07778363fd544..6e1af276c1fa3 100644
--- a/pkgs/games/castle-combat/default.nix
+++ b/pkgs/games/castle-combat/default.nix
@@ -28,7 +28,7 @@ buildPythonPackage rec {
   '';
 
   postInstall = ''
-    ensureDir "$out/share/${name}"
+    mkdir -p "$out/share/${name}"
     cp -rv "data/"* "$out/share/${name}"
 
     mv -v "$out/bin/castle-combat.py" "$out/bin/castle-combat"
diff --git a/pkgs/games/dwarf-fortress/default.nix b/pkgs/games/dwarf-fortress/default.nix
index f12caaae53f73..9d363851148dd 100644
--- a/pkgs/games/dwarf-fortress/default.nix
+++ b/pkgs/games/dwarf-fortress/default.nix
@@ -18,8 +18,8 @@ stdenv.mkDerivation rec {
 
   installPhase = ''
     set -x
-    ensureDir $out/bin
-    ensureDir $out/share/df_linux
+    mkdir -p $out/bin
+    mkdir -p $out/share/df_linux
     cp -r * $out/share/df_linux
     cp $permission $out/share/df_linux/nix_permission
  
diff --git a/pkgs/games/eduke32/default.nix b/pkgs/games/eduke32/default.nix
index b99f8b09b9de6..6eab8acce7517 100644
--- a/pkgs/games/eduke32/default.nix
+++ b/pkgs/games/eduke32/default.nix
@@ -33,7 +33,7 @@ stdenv.mkDerivation rec {
 
   installPhase = ''
     # Install binaries
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp eduke32 mapster32 $out/bin 
     
     # Make wrapper script
@@ -55,7 +55,7 @@ stdenv.mkDerivation rec {
     chmod 755 $out/bin/eduke32-wrapper
     
     # Install desktop item
-    ensureDir $out/share/applications
+    mkdir -p $out/share/applications
     cp ${desktopItem}/share/applications/* $out/share/applications
   '';
   
diff --git a/pkgs/games/egoboo/default.nix b/pkgs/games/egoboo/default.nix
index a1b7262f3b97d..1f879393868f1 100644
--- a/pkgs/games/egoboo/default.nix
+++ b/pkgs/games/egoboo/default.nix
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
   # The user will need to have all the files in '.' to run egoboo, with
   # writeable controls.txt and setup.txt
   installPhase = ''
-    ensureDir $out/share/${name}
+    mkdir -p $out/share/${name}
     cp -v game/egoboo $out/share/${name}
     cd ..
     cp -v -Rd controls.txt setup.txt players modules basicdat $out/share/${name}
diff --git a/pkgs/games/exult/default.nix b/pkgs/games/exult/default.nix
index 4d71260143590..e784cc109f53e 100644
--- a/pkgs/games/exult/default.nix
+++ b/pkgs/games/exult/default.nix
@@ -42,7 +42,7 @@ stdenv.mkDerivation {
 
   postInstall =
     ''
-      ensureDir $out/share/exult/music
+      mkdir -p $out/share/exult/music
       for i in $musicFiles; do
           unzip -o -d $out/share/exult/music $i
       done
diff --git a/pkgs/games/flightgear/default.nix b/pkgs/games/flightgear/default.nix
index a7d906ed9b8ed..fe90156d84cf2 100644
--- a/pkgs/games/flightgear/default.nix
+++ b/pkgs/games/flightgear/default.nix
@@ -38,7 +38,7 @@ rec {
   phaseNames = ["doConfigure" "doMakeInstall" "deployData"];
 
   deployData = a.fullDepEntry ''
-    ensureDir "$out/share/FlightGear"
+    mkdir -p "$out/share/FlightGear"
     cd "$out/share/FlightGear"
     tar xvf ${datasrc}
   '' ["minInit" "defEnsureDir"];
diff --git a/pkgs/games/fsg/default.nix b/pkgs/games/fsg/default.nix
index 2752e565c58cc..ba6b65d602b4b 100644
--- a/pkgs/games/fsg/default.nix
+++ b/pkgs/games/fsg/default.nix
@@ -36,7 +36,7 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out/bin $out/libexec
+    mkdir -p $out/bin $out/libexec
     cp sand $out/libexec
     echo -e '#! /bin/sh\nLC_ALL=C '$out'/libexec/sand "$@"' >$out/bin/fsg
     chmod a+x $out/bin/fsg
diff --git a/pkgs/games/icbm3d/default.nix b/pkgs/games/icbm3d/default.nix
index e5e5c94d4603a..ee792ef1e4d93 100644
--- a/pkgs/games/icbm3d/default.nix
+++ b/pkgs/games/icbm3d/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
   buildInputs = [ libX11 ];
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp icbm3d $out/bin
   '';
 
diff --git a/pkgs/games/instead/default.nix b/pkgs/games/instead/default.nix
index d7fcb7a3f4e50..0d46e187d7b6e 100644
--- a/pkgs/games/instead/default.nix
+++ b/pkgs/games/instead/default.nix
@@ -47,7 +47,7 @@ stdenv.mkDerivation rec {
   inherit games;
 
   installPhase = ''
-    ensureDir $out/bin $out/share/${name}
+    mkdir -p $out/bin $out/share/${name}
     cp sdl-instead $out/bin
     cp -R games languages stead themes $out/share/${name}
     pushd $out/share/${name}/games
diff --git a/pkgs/games/keen4/builder.sh b/pkgs/games/keen4/builder.sh
index f9c62c83ddd35..50d261db8651a 100644
--- a/pkgs/games/keen4/builder.sh
+++ b/pkgs/games/keen4/builder.sh
@@ -1,9 +1,9 @@
 source $stdenv/setup
 
-ensureDir $out/share/keen4
+mkdir -p $out/share/keen4
 unzip -j $dist -d $out/share/keen4
 
-ensureDir $out/bin
+mkdir -p $out/bin
 cat > $out/bin/keen4 <<EOF
 #! $SHELL -e
 if test -z "\$HOME"; then
diff --git a/pkgs/games/mars/default.nix b/pkgs/games/mars/default.nix
index 991afca6180c1..34094b637fce3 100644
--- a/pkgs/games/mars/default.nix
+++ b/pkgs/games/mars/default.nix
@@ -10,8 +10,8 @@ stdenv.mkDerivation rec {
   installPhase = ''
     cd ..
     find -name '*.svn' -exec rm -rf {} \;
-    ensureDir "$out/share/mars/"
-    ensureDir "$out/bin/"
+    mkdir -p "$out/share/mars/"
+    mkdir -p "$out/bin/"
     cp -rv data resources credits.txt license.txt "$out/share/mars/"
     cp -v mars "$out/bin/mars.bin"
     cat << EOF > "$out/bin/mars"
diff --git a/pkgs/games/naev/default.nix b/pkgs/games/naev/default.nix
index f6e571404d6e5..36ccbf98274f9 100644
--- a/pkgs/games/naev/default.nix
+++ b/pkgs/games/naev/default.nix
@@ -26,7 +26,7 @@ stdenv.mkDerivation {
   NIX_CFLAGS_COMPILE="-include ${zlib}/include/zlib.h";
 
   postInstall = ''
-    ensureDir $out/share/naev
+    mkdir -p $out/share/naev
     cp -v $srcData $out/share/naev/ndata
     wrapProgram $out/bin/naev --add-flags $out/share/naev/ndata
   '';
diff --git a/pkgs/games/nethack/default.nix b/pkgs/games/nethack/default.nix
index 0d68b681ba553..d817cf6432385 100644
--- a/pkgs/games/nethack/default.nix
+++ b/pkgs/games/nethack/default.nix
@@ -36,7 +36,7 @@ rec {
   '') ["minInit" "doUnpack"];
 
   postInstall = a.fullDepEntry (''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     ln -s $out/games/nethack $out/bin/nethack
     sed -i $out/bin/nethack -e '5aNEWHACKDIR="$HOME/.nethack"'
     sed -i $out/bin/nethack -e '6amkdir -p "$NEWHACKDIR/save"'
diff --git a/pkgs/games/neverball/default.nix b/pkgs/games/neverball/default.nix
index 7e2df42a2931d..1ebb4b69b6e11 100644
--- a/pkgs/games/neverball/default.nix
+++ b/pkgs/games/neverball/default.nix
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
   preConfigure = "export HOME=$TMPDIR";
 
   installPhase = ''
-    ensureDir $out/bin $out
+    mkdir -p $out/bin $out
     cp -R data locale $out
     cp neverball $out/bin
     cp neverputt $out/bin
diff --git a/pkgs/games/openlierox/default.nix b/pkgs/games/openlierox/default.nix
index fd2a2f18f39d3..751941bdfc1e8 100644
--- a/pkgs/games/openlierox/default.nix
+++ b/pkgs/games/openlierox/default.nix
@@ -43,7 +43,7 @@ rec {
   '') ["doUnpack" "addInputs" "setParams"];
 
   doInstall = a.fullDepEntry (''
-    ensureDir $BIN_DIR $SYSTEM_DATA_DIR $DOC_DIR $PIXMAP_DIR
+    mkdir -p $BIN_DIR $SYSTEM_DATA_DIR $DOC_DIR $PIXMAP_DIR
     bash install.sh
   '') ["doBuild" "addInputs" "setParams" "defEnsureDir"];
       
diff --git a/pkgs/games/orbit/default.nix b/pkgs/games/orbit/default.nix
index 65e394f60bb24..9769e6f5d670a 100644
--- a/pkgs/games/orbit/default.nix
+++ b/pkgs/games/orbit/default.nix
@@ -22,7 +22,7 @@ with builderDefs;
 			sed -e 's@/usr/share/games/orbit/@'$out'/dump/@g' -i *.c
                         sed -e '/DIR=/d; s/-lesd//; s/-DESD//;' -i Makefile 
                         make 
-                        ensureDir $out/bin
+                        mkdir -p $out/bin
                         cp -r .. $out/dump
                         cat >$out/bin/space-orbit <<EOF
 #! /bin/sh
diff --git a/pkgs/games/pong3d/default.nix b/pkgs/games/pong3d/default.nix
index 281bd8966f6fb..24baff5394a89 100644
--- a/pkgs/games/pong3d/default.nix
+++ b/pkgs/games/pong3d/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
 
   preConfigure = ''
     sed -i s,/usr/local,$out, Makefile
-    ensureDir $out/bin
+    mkdir -p $out/bin
   '';
 
   meta = {
diff --git a/pkgs/games/privateer/default.nix b/pkgs/games/privateer/default.nix
index 1fe925e31b6ad..bb67f422c9dfc 100644
--- a/pkgs/games/privateer/default.nix
+++ b/pkgs/games/privateer/default.nix
@@ -24,7 +24,7 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp vegastrike $out/bin
     cp vegaserver $out/bin
   '';
diff --git a/pkgs/games/quake3/demo/builder.sh b/pkgs/games/quake3/demo/builder.sh
index 640401a0ec85a..40b0a547243b2 100644
--- a/pkgs/games/quake3/demo/builder.sh
+++ b/pkgs/games/quake3/demo/builder.sh
@@ -5,5 +5,5 @@ chmod -R +w .
 tail -n +175 $update | tar xvfz -
 chmod -R +w .
 
-ensureDir $out/baseq3
+mkdir -p $out/baseq3
 cp demoq3/*.pk3 baseq3/*.pk3 $out/baseq3
diff --git a/pkgs/games/quake3/game/default.nix b/pkgs/games/quake3/game/default.nix
index 3b82ebb83a8d9..6a05ab7f2bd7b 100644
--- a/pkgs/games/quake3/game/default.nix
+++ b/pkgs/games/quake3/game/default.nix
@@ -24,8 +24,11 @@ stdenv.mkDerivation {
   
   buildInputs = [x11 SDL mesa openal];
 
+  # Fix building on GCC 4.6.
+  NIX_CFLAGS_COMPILE = "-Wno-error";
+
   preInstall = ''
-    ensureDir $out/baseq3
+    mkdir -p $out/baseq3
     installTargets=copyfiles
     installFlags="COPYDIR=$out"
   '';
diff --git a/pkgs/games/quake3/wrapper/builder.sh b/pkgs/games/quake3/wrapper/builder.sh
index 57d6bc6a5ba24..6b5bd7450c570 100644
--- a/pkgs/games/quake3/wrapper/builder.sh
+++ b/pkgs/games/quake3/wrapper/builder.sh
@@ -1,6 +1,6 @@
 source $stdenv/setup
 
-ensureDir $out/baseq3
+mkdir -p $out/baseq3
 for i in $paks; do
     if test -d "$paks/baseq3"; then
         ln -s $paks/baseq3/* $out/baseq3/
diff --git a/pkgs/games/rigsofrods/default.nix b/pkgs/games/rigsofrods/default.nix
index 4fa8979830651..f92b5775ab723 100644
--- a/pkgs/games/rigsofrods/default.nix
+++ b/pkgs/games/rigsofrods/default.nix
@@ -32,10 +32,10 @@ stdenv.mkDerivation rec {
 
   installPhase = ''
     sed -e "s@/usr/local/lib/OGRE@${ogre}/lib/OGRE@" -i ../tools/linux/binaries/plugins.cfg
-    ensureDir $out/share/rigsofrods
+    mkdir -p $out/share/rigsofrods
     cp -r ../bin/* $out/share/rigsofrods
     cp ../tools/linux/binaries/plugins.cfg $out/share/rigsofrods
-    ensureDir $out/bin
+    mkdir -p $out/bin
     ln -s $out/share/rigsofrods/{RoR,rorconfig} $out/bin
     cd $out/share/rigsofrods
     mkdir packs
diff --git a/pkgs/games/sauerbraten/default.nix b/pkgs/games/sauerbraten/default.nix
index aca16d14e36c7..ff99b428cef7a 100644
--- a/pkgs/games/sauerbraten/default.nix
+++ b/pkgs/games/sauerbraten/default.nix
@@ -37,7 +37,7 @@ rec {
   '';
 
   doUnpack = a.fullDepEntry ''
-    ensureDir $out/share/sauerbraten/build-dir
+    mkdir -p $out/share/sauerbraten/build-dir
     ln -s  $out/share/sauerbraten/build-dir
     cd $out/share/sauerbraten/build-dir
     (cd ${src}; find . -type d) | tail -n +2 | xargs -L 1 mkdir
@@ -50,7 +50,7 @@ rec {
 
   doCreateScripts = a.fullDepEntry ''
     cd ..
-    ensureDir $out/bin
+    mkdir -p $out/bin
     echo '#! /bin/sh' >> $out/bin/sauerbraten_server
     echo 'cd "'"$out"'/share/sauerbraten/build-dir"' >> $out/bin/sauerbraten_server
     echo './bin_unix/native_server "$@"' >> $out/bin/sauerbraten_server
diff --git a/pkgs/games/simutrans/default.nix b/pkgs/games/simutrans/default.nix
index 511aa850ff93e..c0f9d213762bd 100644
--- a/pkgs/games/simutrans/default.nix
+++ b/pkgs/games/simutrans/default.nix
@@ -54,10 +54,10 @@ stdenv.mkDerivation rec {
 
     mv sim simutrans/
 
-    ensureDir $out/simutrans
+    mkdir -p $out/simutrans
     cp -r simutrans $out
 
-    ensureDir $out/bin
+    mkdir -p $out/bin
     ln -s $out/simutrans/sim $out/bin/simutrans
   '';
 
diff --git a/pkgs/games/teetertorture/default.nix b/pkgs/games/teetertorture/default.nix
index 45b5988e88cf1..18a911d563bd8 100644
--- a/pkgs/games/teetertorture/default.nix
+++ b/pkgs/games/teetertorture/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out/bin $out/share/teetertorture
+    mkdir -p $out/bin $out/share/teetertorture
     cp teetertorture $out/bin
     cp -R data/* $out/share/teetertorture
   '';
diff --git a/pkgs/games/teeworlds/default.nix b/pkgs/games/teeworlds/default.nix
index 7824fbd9bdf05..c685f11c4c161 100644
--- a/pkgs/games/teeworlds/default.nix
+++ b/pkgs/games/teeworlds/default.nix
@@ -18,11 +18,11 @@ stdenv.mkDerivation rec {
 
   installPhase = ''
     # Copy the graphics, sounds, etc.
-    ensureDir "$out/share/${name}"
+    mkdir -p "$out/share/${name}"
     cp -rv data other/icons "$out/share/${name}"
 
     # Copy the executables (client, server, etc.).
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     executables=""
     for file in *
     do
@@ -46,7 +46,7 @@ EOF
     done
 
     # Copy the documentation.
-    ensureDir "$out/doc/${name}"
+    mkdir -p "$out/doc/${name}"
     cp -v *.txt "$out/doc/${name}"
   '';
 
diff --git a/pkgs/games/the-butterfly-effect/default.nix b/pkgs/games/the-butterfly-effect/default.nix
index caea5b4bb4fb2..5fc5e9be84e88 100644
--- a/pkgs/games/the-butterfly-effect/default.nix
+++ b/pkgs/games/the-butterfly-effect/default.nix
@@ -38,9 +38,9 @@ rec {
   '';
 
   doDeploy = a.fullDepEntry ''
-    ensureDir "$out/share/tbe"
+    mkdir -p "$out/share/tbe"
     cp -r . "$out/share/tbe/build-dir"
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     echo '#! /bin/sh' >> "$out/bin/tbe"
     echo "$out/share/tbe/build-dir/tbe \"\$@\"" >> "$out/bin/tbe"
     chmod a+x "$out/bin/tbe"
diff --git a/pkgs/games/thePenguinMachine/default.nix b/pkgs/games/thePenguinMachine/default.nix
index 68d44364f5982..04438cf70addf 100644
--- a/pkgs/games/thePenguinMachine/default.nix
+++ b/pkgs/games/thePenguinMachine/default.nix
@@ -26,9 +26,9 @@ stdenv.mkDerivation {
 		'';
   installPhase = ''
 		python setup.py install --prefix=$out
-		ensureDir "$out"/share/tpm/
+		mkdir -p "$out"/share/tpm/
 		cp -r .  "$out"/share/tpm/build-dir
-		ensureDir "$out/bin"
+		mkdir -p "$out/bin"
 		echo "#! /bin/sh" >> "$out/bin/tpm"
 		echo "export PYTHONPATH=\"\$PYTHONPATH:$PYTHONPATH:$(echo ${pil}/lib/python*/site-packages/PIL)\"" >> "$out/bin/tpm"
 		echo "cd \"$out/share/tpm/build-dir\"" >> "$out/bin/tpm"
diff --git a/pkgs/games/trackballs/default.nix b/pkgs/games/trackballs/default.nix
index bdac6cddf2d2b..22d8c944fa8bf 100644
--- a/pkgs/games/trackballs/default.nix
+++ b/pkgs/games/trackballs/default.nix
@@ -1,8 +1,11 @@
-{stdenv, fetchurl, SDL, mesa, SDL_ttf, gettext, zlib, SDL_mixer, SDL_image, guile,
-  debug ? false } :
+{ stdenv, fetchurl, SDL, mesa, SDL_ttf, gettext, zlib, SDL_mixer, SDL_image, guile
+, debug ? false }:
+
+with stdenv.lib;
 
 stdenv.mkDerivation rec {
   name = "trackballs-1.1.4";
+  
   src = fetchurl {
     url = mirror://sourceforge/trackballs/trackballs-1.1.4.tar.gz;
     sha256 = "19ilnif59sxa8xmfisk90wngrd11pj8s86ixzypv8krm4znbm7a5";
@@ -10,16 +13,14 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ zlib mesa SDL SDL_ttf SDL_mixer SDL_image guile gettext ];
 
-  CFLAGS = if debug then "-g -O0" else null;
+  CFLAGS = optionalString debug "-g -O0";
   CXXFLAGS = CFLAGS;
-  NIX_STRIP_DEBUG = if debug then "0" else "1";
-  dontStrip = if debug then true else false;
-  postUnpack = if debug then
-    "ensureDir $out/src; cp -R * $out/src ; cd $out/src"
-    else null;
+  dontStrip = debug;
+  postUnpack = optionalString debug
+    "mkdir -p $out/src; cp -R * $out/src ; cd $out/src";
 
-  NIX_CFLAGS_COMPILE="-iquote ${SDL}/include/SDL";
-  configureFlags = if debug then "--enable-debug" else null;
+  NIX_CFLAGS_COMPILE = "-iquote ${SDL}/include/SDL";
+  configureFlags = optionalString debug "--enable-debug";
 
   patchPhase = ''
     sed -i -e 's/images icons music/images music/' share/Makefile.in
diff --git a/pkgs/games/tremulous/default.nix b/pkgs/games/tremulous/default.nix
index a4a887e2ed3d7..bef4b63b0cc8f 100644
--- a/pkgs/games/tremulous/default.nix
+++ b/pkgs/games/tremulous/default.nix
@@ -41,11 +41,11 @@ stdenv.mkDerivation rec {
   '';
   installPhase = ''
     arch=$(uname -m | sed -e s/i.86/x86/)
-    ensureDir $out/opt/tremulous
+    mkdir -p $out/opt/tremulous
     cp -v Release_1.011/build/release-linux-$arch/tremulous.$arch $out/opt/tremulous/
     cp -v mg_tremded_source/build/release-linux-$arch/tremded.$arch $out/opt/tremulous/
     cp -rv base $out/opt/tremulous
-    ensureDir $out/bin
+    mkdir -p $out/bin
     for b in tremulous tremded
     do
         cat << EOF > $out/bin/$b
diff --git a/pkgs/games/trigger/default.nix b/pkgs/games/trigger/default.nix
index f958897cd401a..2a25c290b2d83 100644
--- a/pkgs/games/trigger/default.nix
+++ b/pkgs/games/trigger/default.nix
@@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
 
   installPhase = ''
     jam install
-    ensureDir $out/share
+    mkdir -p $out/share
     pushd $out/share
     tar xf $srcData
   '';
diff --git a/pkgs/games/urbanterror/default.nix b/pkgs/games/urbanterror/default.nix
index dc870c79aba10..74448cdad76f7 100644
--- a/pkgs/games/urbanterror/default.nix
+++ b/pkgs/games/urbanterror/default.nix
@@ -35,8 +35,8 @@ stdenv.mkDerivation rec {
   '';
   installPhase = ''
     destDir="$out/opt/urbanterror"
-    ensureDir "$destDir"
-    ensureDir "$out/bin"
+    mkdir -p "$destDir"
+    mkdir -p "$out/bin"
     cp -v ioUrbanTerrorClientSource/build/release-linux-*/ioUrbanTerror.* \
           "$destDir/ioUrbanTerror"
     cp -v ioUrbanTerrorServerSource/build/release-linux-*/ioUrTded.* \
diff --git a/pkgs/games/ut2004demo/make-wrapper.sh b/pkgs/games/ut2004demo/make-wrapper.sh
index 5dbb451272adc..53ef90a615b06 100644
--- a/pkgs/games/ut2004demo/make-wrapper.sh
+++ b/pkgs/games/ut2004demo/make-wrapper.sh
@@ -1,6 +1,6 @@
 source $stdenv/setup
 
-ensureDir $out/bin
+mkdir -p $out/bin
 
 cat > $out/bin/ut2004demo <<EOF
 #! $SHELL -e
diff --git a/pkgs/games/vectoroids/default.nix b/pkgs/games/vectoroids/default.nix
index 5f9031ceeaa81..6f0fb48f0a5f9 100644
--- a/pkgs/games/vectoroids/default.nix
+++ b/pkgs/games/vectoroids/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
 
   preConfigure = ''
     sed -i s,/usr/local,$out, Makefile
-    ensureDir $out/bin
+    mkdir -p $out/bin
   '';
 
   meta = {
diff --git a/pkgs/games/warsow/default.nix b/pkgs/games/warsow/default.nix
index c70b6f6f22e66..c584319bdc9b9 100644
--- a/pkgs/games/warsow/default.nix
+++ b/pkgs/games/warsow/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
     cd warsow_${version}_sdk
     unzip $src1
     unzip $src2
-    ensureDir source/release/
+    mkdir -p source/release/
     mv warsow_${mversion}_unified/basewsw source/release/
     cd source
   '';
@@ -33,8 +33,8 @@ stdenv.mkDerivation rec {
     for f in warsow wsw_server wswtv_server; do
         substituteInPlace $f --replace BINARY_DIR= BINARY_DIR=$dest
     done
-    ensureDir $dest
-    ensureDir $out/bin
+    mkdir -p $dest
+    mkdir -p $out/bin
     cp -v {warsow,wsw_server,wswtv_server}.* $dest
     cp -rv basewsw libs $dest
     cp -v warsow wsw_server wswtv_server $out/bin
diff --git a/pkgs/games/xonotic/default.nix b/pkgs/games/xonotic/default.nix
index 8ac05d9ef72c1..3553649dccb81 100644
--- a/pkgs/games/xonotic/default.nix
+++ b/pkgs/games/xonotic/default.nix
@@ -25,11 +25,11 @@ stdenv.mkDerivation rec {
     make DP_FS_BASEDIR=$DP_FS_BASEDIR sv-release
   '';
   installPhase = ''
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     cp darkplaces-dedicated "$out/bin/xonotic-dedicated"
     cp darkplaces-sdl "$out/bin/xonotic-sdl"
     cd ../..
-    ensureDir "$out/share/xonotic"
+    mkdir -p "$out/share/xonotic"
     mv data "$out/share/xonotic"
   '';
   dontPatchELF = true;
diff --git a/pkgs/games/xsokoban/default.nix b/pkgs/games/xsokoban/default.nix
index b3b3954da8cfa..b8917b4d41c9b 100644
--- a/pkgs/games/xsokoban/default.nix
+++ b/pkgs/games/xsokoban/default.nix
@@ -38,7 +38,7 @@ rec {
   preBuild = a.fullDepEntry (''
     sed -e "s@/usr/local/@$out/@" -i Makefile
     sed -e "s@ /bin/@ @" -i Makefile 
-    ensureDir $out/bin $out/share $out/man/man1 $out/lib
+    mkdir -p $out/bin $out/share $out/man/man1 $out/lib
   '') ["minInit" "doConfigure" "defEnsureDir"];
 
   name = "xsokoban-" + version;
diff --git a/pkgs/games/zangband/default.nix b/pkgs/games/zangband/default.nix
index dd654edcfe199..b94633d8d3a6f 100644
--- a/pkgs/games/zangband/default.nix
+++ b/pkgs/games/zangband/default.nix
@@ -21,9 +21,9 @@ rec {
     sed -re 's/ch(own|grp|mod)/true/' -i lib/*/makefile.zb makefile.in
     sed -e '/FIXED_PATHS/d' -i src/z-config.h
     ./bootstrap
-    ensureDir $out/share/games/zangband
-    ensureDir $out/share/man
-    ensureDir $out/bin
+    mkdir -p $out/share/games/zangband
+    mkdir -p $out/share/man
+    mkdir -p $out/bin
   '') ["minInit" "doUnpack" "addInputs" "defEnsureDir"];
 
   postInstall = a.fullDepEntry (''
diff --git a/pkgs/games/zod/default.nix b/pkgs/games/zod/default.nix
index 731a5e40fd808..d9fcb47bcc36e 100644
--- a/pkgs/games/zod/default.nix
+++ b/pkgs/games/zod/default.nix
@@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
   NIX_LDFLAGS="-L${mysql}/lib/mysql";
 
   installPhase = ''
-    ensureDir $out/bin $out/share/zod
+    mkdir -p $out/bin $out/share/zod
     pushd $out/share/zod
     unrar x $srcAssets
     popd
diff --git a/pkgs/lib/licenses.nix b/pkgs/lib/licenses.nix
index edfa057be7bec..dc88f887cc796 100644
--- a/pkgs/lib/licenses.nix
+++ b/pkgs/lib/licenses.nix
@@ -165,6 +165,12 @@
     fullname = "Public Domain";
   };
   
+  psfl = {
+    shortName = "PSFL";
+    fullName = "Python Software Foundation License";
+    url = http://docs.python.org/license.html;
+  };
+
   proprietary = {
     shortName = "Proprietary";
     fullName = "Proprietary (non redistributable) license";
diff --git a/pkgs/lib/lists.nix b/pkgs/lib/lists.nix
index 6adda85a087e5..e5b47f0d9ce79 100644
--- a/pkgs/lib/lists.nix
+++ b/pkgs/lib/lists.nix
@@ -54,6 +54,11 @@ rec {
   filter = pred: list:
     fold (x: y: if pred x then [x] ++ y else y) [] list;
 
+  # Remove elements 'e' from a list. Useful for buildInputs
+  remove = e: filter (x: x != e);
+
+  # Given two lists, removes all elements of the first list from the second list
+  removeList = l: filter (x: elem x l);
 
   # Return true if `list' has an element `x':
   elem = x: list: fold (a: bs: x == a || bs) false list;
diff --git a/pkgs/misc/cups/default.nix b/pkgs/misc/cups/default.nix
index 34367f0e011d3..d8dfd95502ed9 100644
--- a/pkgs/misc/cups/default.nix
+++ b/pkgs/misc/cups/default.nix
@@ -2,7 +2,7 @@
 , dbus, libusb, acl }:
 
 let
-  version = "1.4.7";
+  version = "1.5.0";
 in
 stdenv.mkDerivation {
   name = "cups-${version}";
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
 
   src = fetchurl {
     url = "http://ftp.easysw.com/pub/cups/${version}/cups-${version}-source.tar.bz2";
-    sha256 = "1xlnkdqldq81pdqgisqbyh92k249bzz35m1f5bp4la06p00ksvjf";
+    sha256 = "0czc0bmrm31jy03inm6w2mbr5s9q9xk6s1x5x4kddx2qlml9pyf6";
   };
 
   # The following code looks strange, but it had to be arranged like
@@ -48,7 +48,7 @@ stdenv.mkDerivation {
   meta = {
     homepage = http://www.cups.org/;
     description = "A standards-based printing system for UNIX";
-    license = "GPLv2"; # actually LGPL for the library and GPL for the rest
+    license = stdenv.lib.licenses.gpl2; # actually LGPL for the library and GPL for the rest
     maintainers = [ stdenv.lib.maintainers.urkud stdenv.lib.maintainers.simons ];
     platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
   };
diff --git a/pkgs/misc/drivers/gutenprint/bin.nix b/pkgs/misc/drivers/gutenprint/bin.nix
index feb42296c9d8b..d78e1674d871c 100644
--- a/pkgs/misc/drivers/gutenprint/bin.nix
+++ b/pkgs/misc/drivers/gutenprint/bin.nix
@@ -11,7 +11,7 @@ add the following lines to bindirCmds property of  printing/cupsd.nix:
 
   ln -s ${pkgs.gutenprintBin}/lib/cups/backend/* $out/lib/cups/backend/
   ln -s ${pkgs.gutenprintBin}/lib/cups/filter/* $out/lib/cups/filter/
-  ensureDir $out/lib/cups/model
+  mkdir -p $out/lib/cups/model
   cat ${pkgs.gutenprintBin}/ppds/Canon/Canon-PIXMA_iP4000-gutenprint.5.0.sim-en.ppd.gz |gunzip > $out/lib/cups/model/Canon-PIXMA_iP4000-gutenprint.5.0.sim-en.ppd
   sed -i 's@/opt/gutenprint/cups@${pkgs.gutenprintBin}/cups@' $out/lib/cups/model/Canon-PIXMA_iP4000-gutenprint.5.0.sim-en.ppd
 
diff --git a/pkgs/misc/emulators/atari800/builder.sh b/pkgs/misc/emulators/atari800/builder.sh
index f0fcb5150c886..afb9404657ae5 100644
--- a/pkgs/misc/emulators/atari800/builder.sh
+++ b/pkgs/misc/emulators/atari800/builder.sh
@@ -6,7 +6,7 @@ preConfigure() {
 
 postInstall() {
     romsDir=$out/share/atari800/roms
-    ensureDir $romsDir
+    mkdir -p $romsDir
     unzip $rom -d $romsDir
 }
 
diff --git a/pkgs/misc/emulators/darcnes/default.nix b/pkgs/misc/emulators/darcnes/default.nix
index 5ce5512119d3a..15ab18495d271 100644
--- a/pkgs/misc/emulators/darcnes/default.nix
+++ b/pkgs/misc/emulators/darcnes/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation {
   buildInputs = [ libX11 libXt libXext libXaw ];
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp darcnes $out/bin
   '';
 
diff --git a/pkgs/misc/emulators/dosbox/default.nix b/pkgs/misc/emulators/dosbox/default.nix
index 8a7bff6f7e483..2525cafc28b6d 100644
--- a/pkgs/misc/emulators/dosbox/default.nix
+++ b/pkgs/misc/emulators/dosbox/default.nix
@@ -7,6 +7,16 @@ stdenv.mkDerivation rec {
     url = "mirror://sourceforge/dosbox/${name}.tar.gz";
     sha256 = "01cfjc5bs08m4w79nbxyv7rnvzq2yckmgrbq36njn06lw8b4kxqk";
   };
+
+  patches =
+    [ # Fix building with GCC 4.6.
+      (fetchurl {
+        url = "http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/games-emulation/dosbox/files/dosbox-0.74-gcc46.patch?revision=1.1";
+        sha256 = "03iv1ph7fccfw327ngnhvzwyiix7fsbdb5mmpxivzkidhlrssxq9";
+      })
+    ];
+
+  patchFlags = "-p0";
   
   buildInputs = [ SDL ];
     
@@ -20,7 +30,7 @@ stdenv.mkDerivation rec {
   };
 
   postInstall = ''
-     ensureDir $out/share/applications
+     mkdir -p $out/share/applications
      cp ${desktopItem}/share/applications/* $out/share/applications
   '';
 
diff --git a/pkgs/misc/emulators/fakenes/default.nix b/pkgs/misc/emulators/fakenes/default.nix
index 62ecb6e4156d0..e3c9dbc84e5d6 100644
--- a/pkgs/misc/emulators/fakenes/default.nix
+++ b/pkgs/misc/emulators/fakenes/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation {
     libXxf86vm libXcursor libXpm ];
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp fakenes $out/bin
   '';
 
diff --git a/pkgs/misc/emulators/mess/default.nix b/pkgs/misc/emulators/mess/default.nix
index b3897154e9acc..150042ad7963e 100644
--- a/pkgs/misc/emulators/mess/default.nix
+++ b/pkgs/misc/emulators/mess/default.nix
@@ -36,7 +36,7 @@ stdenv.mkDerivation {
 
   installPhase =
     ''
-      ensureDir $out/bin
+      mkdir -p $out/bin
       cp mess* $out/bin/mess 
     '';
     
diff --git a/pkgs/misc/emulators/vice/default.nix b/pkgs/misc/emulators/vice/default.nix
index 425080d7c6253..12f1222553efa 100644
--- a/pkgs/misc/emulators/vice/default.nix
+++ b/pkgs/misc/emulators/vice/default.nix
@@ -29,7 +29,7 @@ stdenv.mkDerivation rec {
   '';
   
   postInstall = ''
-    ensureDir $out/share/applications
+    mkdir -p $out/share/applications
     cp ${desktopItem}/share/applications/* $out/share/applications
   '';
   
diff --git a/pkgs/misc/foldingathome/default.nix b/pkgs/misc/foldingathome/default.nix
index ca4fe2657bff8..ef8cb7d0a927f 100644
--- a/pkgs/misc/foldingathome/default.nix
+++ b/pkgs/misc/foldingathome/default.nix
@@ -25,7 +25,7 @@ stdenv.mkDerivation {
     for a in $BINFILES; do 
       patchelf --set-interpreter $(cat $NIX_GCC/nix-support/dynamic-linker) $a
     done
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp $BINFILES $out/bin
   '';
 
diff --git a/pkgs/misc/gxemul/default.nix b/pkgs/misc/gxemul/default.nix
index ad126b45daa41..5cad3c964e45c 100644
--- a/pkgs/misc/gxemul/default.nix
+++ b/pkgs/misc/gxemul/default.nix
@@ -8,8 +8,8 @@ composableDerivation.composableDerivation {} {
   inherit name;
   
   flags = {
-    doc   = { installPhase = "ensureDir \$out/share/${name}; cp -r doc \$out/share/${name};"; implies = "man"; };
-    demos = { installPhase = "ensureDir \$out/share/${name}; cp -r demos \$out/share/${name};"; };
+    doc   = { installPhase = "mkdir -p \$out/share/${name}; cp -r doc \$out/share/${name};"; implies = "man"; };
+    demos = { installPhase = "mkdir -p \$out/share/${name}; cp -r demos \$out/share/${name};"; };
     man   = { installPhase = "cp -r ./man \$out/;";};
   };
 
@@ -19,7 +19,7 @@ composableDerivation.composableDerivation {} {
     manSupport = true;
   };
 
-  installPhase = "ensureDir \$out/bin; cp gxemul \$out/bin;";
+  installPhase = "mkdir -p \$out/bin; cp gxemul \$out/bin;";
 
   src = fetchurl {
     url = http://gavare.se/gxemul/src/gxemul-0.4.6.tar.gz;
diff --git a/pkgs/misc/jackaudio/jack1.nix b/pkgs/misc/jackaudio/jack1.nix
index 88bc4dff54041..bb11e5d5f043b 100644
--- a/pkgs/misc/jackaudio/jack1.nix
+++ b/pkgs/misc/jackaudio/jack1.nix
@@ -36,7 +36,7 @@ composableDerivation.composableDerivation {} {
   
   # make sure the jackaudio is found by symlinking lib64 to lib
   postInstall = ''
-    ensureDir $out/lib
+    mkdir -p $out/lib
     ln -s $out/lib{64,}/pkgconfig
   '';
   
diff --git a/pkgs/misc/misc.nix b/pkgs/misc/misc.nix
index 15ea4f8bcc1ec..de23d6fa2c8d7 100644
--- a/pkgs/misc/misc.nix
+++ b/pkgs/misc/misc.nix
@@ -95,7 +95,7 @@ in
         )
       }
 
-      ensureDir $target/{include,lib}
+      mkdir -p $target/{include,lib}
       link $target/lib "$(echo "''${!LIB_PATHS[@]}")"
       link $target/include "$(echo "''${!INCLUDE_PATHS[@]}")"
       echo "''${!LIBS[@]}" > $target/libs
@@ -113,7 +113,6 @@ in
 
     dontStrip = true;
 
-    NIX_STRIP_DEBUG=0;
     CFLAGS="-ggdb -O0";
     CXXFLAGS="-ggdb -O0";
 
diff --git a/pkgs/misc/my-env/default.nix b/pkgs/misc/my-env/default.nix
index 8485346e67b9f..eb319b1c9b34b 100644
--- a/pkgs/misc/my-env/default.nix
+++ b/pkgs/misc/my-env/default.nix
@@ -48,8 +48,6 @@ mkDerivation {
   phases = [ "buildPhase" "fixupPhase" ];
   setupNew = substituteAll {
     src = ../../stdenv/generic/setup.sh;
-    preHook="";
-    postHook="";
     initialPath= (import ../../stdenv/common-path.nix) { inherit pkgs; };
     gcc = stdenv.gcc;
   };
diff --git a/pkgs/misc/sane-backends/default.nix b/pkgs/misc/sane-backends/default.nix
index 458985c61f733..3f9ecdccb408f 100644
--- a/pkgs/misc/sane-backends/default.nix
+++ b/pkgs/misc/sane-backends/default.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation {
 
   postInstall = ''
     if test "$udevSupport" = "1"; then
-      ensureDir $out/etc/udev/rules.d/
+      mkdir -p $out/etc/udev/rules.d/
       ./tools/sane-desc -m udev > $out/etc/udev/rules.d/60-libsane.rules || \
       cp tools/udev/libsane.rules $out/etc/udev/rules.d/60-libsane.rules
     fi
diff --git a/pkgs/misc/sane-backends/snapshot.nix b/pkgs/misc/sane-backends/snapshot.nix
index 8725206ddce35..636ae37ec05b6 100644
--- a/pkgs/misc/sane-backends/snapshot.nix
+++ b/pkgs/misc/sane-backends/snapshot.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation {
 
   postInstall = ''
     if test "$udevSupport" = "1"; then
-      ensureDir $out/etc/udev/rules.d/
+      mkdir -p $out/etc/udev/rules.d/
       ./tools/sane-desc -m udev > $out/etc/udev/rules.d/60-libsane.rules || \
       cp tools/udev/libsane.rules $out/etc/udev/rules.d/60-libsane.rules
     fi
diff --git a/pkgs/misc/screensavers/electricsheep/default.nix b/pkgs/misc/screensavers/electricsheep/default.nix
index 64674d78ac77b..dca60f55af036 100644
--- a/pkgs/misc/screensavers/electricsheep/default.nix
+++ b/pkgs/misc/screensavers/electricsheep/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
 
   preInstall = ''
     installFlags=GNOME_DATADIR=$out
-    ensureDir $out/control-center/screensavers
+    mkdir -p $out/control-center/screensavers
   '';
 
   meta = {
diff --git a/pkgs/misc/screensavers/rss-glx/builder.sh b/pkgs/misc/screensavers/rss-glx/builder.sh
index 00ec2e065bd20..a0c138d5e0475 100644
--- a/pkgs/misc/screensavers/rss-glx/builder.sh
+++ b/pkgs/misc/screensavers/rss-glx/builder.sh
@@ -2,9 +2,9 @@ source $stdenv/setup
 
 # This is a very dirty hack to prevent the binaries from putting the
 # Mesa libraries in their RPATHs.
-ensureDir $out/tmp
+mkdir -p $out/tmp
 ln -s $mesa/lib/* $out/tmp/
-ensureDir $out/lib
+mkdir -p $out/lib
 ln -s $mesa/lib/libGLU* $out/lib/
 export NIX_LDFLAGS="-L$out/tmp $NIX_LDFLAGS"
 
@@ -14,7 +14,7 @@ rm -rf $out/tmp
 
 
 # Add a wrapper around each program to use the appropriate OpenGL driver.
-ensureDir $out/bin/.orig
+mkdir -p $out/bin/.orig
 
 for i in $(cd $out/bin && ls); do
     mv $out/bin/$i $out/bin/.orig/$i
diff --git a/pkgs/misc/source-and-tags/default.nix b/pkgs/misc/source-and-tags/default.nix
index 42101fa6ffe48..e3993d0daeac4 100644
--- a/pkgs/misc/source-and-tags/default.nix
+++ b/pkgs/misc/source-and-tags/default.nix
@@ -28,13 +28,13 @@ args: with args; {
            '') createTagFiles );
       in ''
       SRC_DEST=$out/src/$name
-      ensureDir $SRC_DEST
+      mkdir -p $SRC_DEST
       pwd; ls
       cp -r $srcDir $SRC_DEST
       cd $SRC_DEST
       ${createTags}
 
-      ensureDir $out/nix-support
+      mkdir -p $out/nix-support
       echo "TAG_FILES=\"\$TAG_FILES\''${TAG_FILES:+:}$TAG_FILES\"" >> $out/nix-support/setup-hook
     '';
   };
diff --git a/pkgs/misc/uboot/default.nix b/pkgs/misc/uboot/default.nix
index ffd40673b2f32..7525c28e740e6 100644
--- a/pkgs/misc/uboot/default.nix
+++ b/pkgs/misc/uboot/default.nix
@@ -30,14 +30,13 @@ stdenv.mkDerivation {
   buildNativeInputs = [ unzip ];
 
   dontStrip = true;
-  NIX_STRIP_DEBUG = false;
 
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp u-boot.bin $out
     cp u-boot u-boot.map $out
 
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp tools/{envcrc,mkimage} $out/bin
   '';
 
diff --git a/pkgs/misc/uboot/guruplug.nix b/pkgs/misc/uboot/guruplug.nix
index f8048bbe0f4e0..0e63a56073b6b 100644
--- a/pkgs/misc/uboot/guruplug.nix
+++ b/pkgs/misc/uboot/guruplug.nix
@@ -42,13 +42,12 @@ stdenv.mkDerivation {
   buildNativeInputs = [ unzip ];
 
   dontStrip = true;
-  NIX_STRIP_DEBUG = false;
 
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp -v u-boot u-boot.{kwb,map} $out
 
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp tools/{envcrc,mkimage} $out/bin
   '';
 }
diff --git a/pkgs/misc/uboot/nanonote.nix b/pkgs/misc/uboot/nanonote.nix
index ad8237bc8e4f6..b8261979ec0c0 100644
--- a/pkgs/misc/uboot/nanonote.nix
+++ b/pkgs/misc/uboot/nanonote.nix
@@ -48,14 +48,13 @@ stdenv.mkDerivation {
   '';
 
   dontStrip = true;
-  NIX_STRIP_DEBUG = false;
 
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp u-boot-nand.bin $out
     cp u-boot u-boot.map $out
 
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp tools/{envcrc,mkimage} $out/bin
   '';
 }
diff --git a/pkgs/misc/uboot/sheevaplug.nix b/pkgs/misc/uboot/sheevaplug.nix
index 5c38f1d053bb3..5eb8d7d7bf876 100644
--- a/pkgs/misc/uboot/sheevaplug.nix
+++ b/pkgs/misc/uboot/sheevaplug.nix
@@ -45,14 +45,13 @@ stdenv.mkDerivation {
   buildNativeInputs = [ unzip ];
 
   dontStrip = true;
-  NIX_STRIP_DEBUG = false;
 
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp u-boot-rd88f6281Sheevaplug_400db_nand.bin $out
     cp u-boot u-boot.map $out
 
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp tools/{envcrc,mkimage} $out/bin
   '';
 }
diff --git a/pkgs/os-specific/linux/915resolution/default.nix b/pkgs/os-specific/linux/915resolution/default.nix
index 48ab97d910644..cfb71690ad5d9 100644
--- a/pkgs/os-specific/linux/915resolution/default.nix
+++ b/pkgs/os-specific/linux/915resolution/default.nix
@@ -7,5 +7,5 @@ stdenv.mkDerivation {
     sha256 = "1m5nfzgwaglqabpm2l2mjqvigz1z0dj87cmj2pjbbzxmmpapv0lq";
   };
   buildPhase = "rm *.o 915resolution; make";
-  installPhase = "ensureDir $out/sbin; cp 915resolution $out/sbin/";
+  installPhase = "mkdir -p $out/sbin; cp 915resolution $out/sbin/";
 }
diff --git a/pkgs/os-specific/linux/acpi-call/default.nix b/pkgs/os-specific/linux/acpi-call/default.nix
index f9615da0c2f69..301a8054557cc 100644
--- a/pkgs/os-specific/linux/acpi-call/default.nix
+++ b/pkgs/os-specific/linux/acpi-call/default.nix
@@ -16,9 +16,9 @@ stdenv.mkDerivation {
   '';
  
   installPhase = ''
-    ensureDir $out/lib/modules/${kernel.version}/misc
+    mkdir -p $out/lib/modules/${kernel.version}/misc
     cp acpi_call.ko $out/lib/modules/${kernel.version}/misc
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp test_off.sh $out/bin/test_discrete_video_off.sh
   '';
 
diff --git a/pkgs/os-specific/linux/ati-drivers/builder.sh b/pkgs/os-specific/linux/ati-drivers/builder.sh
index 1fd6234b48e2b..b05093d891575 100644
--- a/pkgs/os-specific/linux/ati-drivers/builder.sh
+++ b/pkgs/os-specific/linux/ati-drivers/builder.sh
@@ -136,7 +136,7 @@ GCC_MAJOR="`gcc --version | grep -o -e ") ." | head -1 | cut -d " " -f 2`"
 
 { # install
 
-  ensureDir $out/lib/xorg
+  mkdir -p $out/lib/xorg
 
   cp -r common/usr/include $out
   cp -r common/usr/sbin $out
@@ -152,7 +152,7 @@ GCC_MAJOR="`gcc --version | grep -o -e ") ." | head -1 | cut -d " " -f 2`"
   cp -r $DIR_DEPENDING_ON_XORG_VERSION/usr/X11R6/$lib_arch/* $out/lib/xorg
 
   t=$out/lib/modules/${kernelVersion}/kernel/drivers/misc
-  ensureDir $t
+  mkdir -p $t
 
   cp ./common/lib/modules/fglrx/build_mod/2.6.x/fglrx.ko $t
 
@@ -174,7 +174,7 @@ GCC_MAJOR="`gcc --version | grep -o -e ") ." | head -1 | cut -d " " -f 2`"
 }
 
 { # build samples
-  ensureDir $out/bin
+  mkdir -p $out/bin
 
   mkdir -p samples
   cd samples
diff --git a/pkgs/os-specific/linux/aufs/2.1.nix b/pkgs/os-specific/linux/aufs/2.1.nix
index f6a3a6dffc262..1539775a2a17d 100644
--- a/pkgs/os-specific/linux/aufs/2.1.nix
+++ b/pkgs/os-specific/linux/aufs/2.1.nix
@@ -31,7 +31,7 @@ stdenv.mkDerivation {
 
   installPhase =
     ''
-      ensureDir $out/lib/modules/${kernel.version}/misc
+      mkdir -p $out/lib/modules/${kernel.version}/misc
       cp -v aufs.ko $out/lib/modules/${kernel.version}/misc
 
       # Install the headers because aufs2.1-util requires them.
diff --git a/pkgs/os-specific/linux/aufs/2.nix b/pkgs/os-specific/linux/aufs/2.nix
index 696ed57b86036..4d80ddae0b871 100644
--- a/pkgs/os-specific/linux/aufs/2.nix
+++ b/pkgs/os-specific/linux/aufs/2.nix
@@ -26,7 +26,7 @@ stdenv.mkDerivation {
 
   installPhase =
     ''
-      ensureDir $out/lib/modules/${kernel.version}/misc
+      mkdir -p $out/lib/modules/${kernel.version}/misc
       cp aufs.ko $out/lib/modules/${kernel.version}/misc
 
       # Install the headers because aufs2-util requires them.
diff --git a/pkgs/os-specific/linux/aufs/3.nix b/pkgs/os-specific/linux/aufs/3.nix
index ec3c5aec85ba9..731098134b585 100644
--- a/pkgs/os-specific/linux/aufs/3.nix
+++ b/pkgs/os-specific/linux/aufs/3.nix
@@ -22,11 +22,11 @@ stdenv.mkDerivation {
 
   installPhase =
     ''
-      ensureDir $out/lib/modules/${kernel.modDirVersion}/misc
+      mkdir -p $out/lib/modules/${kernel.modDirVersion}/misc
       cp -v aufs.ko $out/lib/modules/${kernel.modDirVersion}/misc
 
       # Install the headers because aufs3-util requires them.
-      ensureDir $out/include/linux
+      mkdir -p $out/include/linux
       cp -v usr/include/linux/aufs_type.h $out/include/linux
     '';
 
diff --git a/pkgs/os-specific/linux/broadcom-sta/default.nix b/pkgs/os-specific/linux/broadcom-sta/default.nix
index e03e4a5cda467..1c55730172999 100644
--- a/pkgs/os-specific/linux/broadcom-sta/default.nix
+++ b/pkgs/os-specific/linux/broadcom-sta/default.nix
@@ -34,7 +34,7 @@ stdenv.mkDerivation {
     ''
       binDir="$out/lib/modules/${kernel.modDirVersion}/kernel/net/wireless/"
       docDir="$out/share/doc/broadcom-sta/"
-      ensureDir "$binDir" "$docDir"
+      mkdir -p "$binDir" "$docDir"
       cp wl.ko "$binDir"
       cp lib/LICENSE.txt "$docDir"
     '';
diff --git a/pkgs/os-specific/linux/cramfsswap/builder.sh b/pkgs/os-specific/linux/cramfsswap/builder.sh
index 14e6a11f9d053..51a5b11dda699 100644
--- a/pkgs/os-specific/linux/cramfsswap/builder.sh
+++ b/pkgs/os-specific/linux/cramfsswap/builder.sh
@@ -1,6 +1,6 @@
 source $stdenv/setup
 
 export DESTDIR=$out
-ensureDir $out/usr/bin
+mkdir -p $out/usr/bin
 
 genericBuild
diff --git a/pkgs/os-specific/linux/exmap/default.nix b/pkgs/os-specific/linux/exmap/default.nix
index 4f9f85e648a0e..c39b2acf4e1bc 100644
--- a/pkgs/os-specific/linux/exmap/default.nix
+++ b/pkgs/os-specific/linux/exmap/default.nix
@@ -31,10 +31,10 @@ stdenv.mkDerivation rec {
   #checkPhase = "make test"
 
   installPhase = ''
-    ensureDir "$out/share/${name}"
+    mkdir -p "$out/share/${name}"
     cp kernel/*.ko "$out/share/${name}"
 
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     cp src/{gexmap,exmtool,elftool,showproc} "$out/bin"
   '';
 
diff --git a/pkgs/os-specific/linux/firmware/firmware-linux-nonfree/default.nix b/pkgs/os-specific/linux/firmware/firmware-linux-nonfree/default.nix
index c35f6c2d9bdb6..e2ba47abb9a06 100644
--- a/pkgs/os-specific/linux/firmware/firmware-linux-nonfree/default.nix
+++ b/pkgs/os-specific/linux/firmware/firmware-linux-nonfree/default.nix
@@ -53,7 +53,7 @@ in stdenv.mkDerivation {
   buildInputs = [ dpkg ];
 
   installPhase = ''
-    ensureDir "$out/"
+    mkdir -p "$out/"
     cp -r lib/firmware/* "$out/"
   '';
 
diff --git a/pkgs/os-specific/linux/firmware/ipw2100/default.nix b/pkgs/os-specific/linux/firmware/ipw2100/default.nix
index 2ffa8c3e83757..3548a841aab0a 100644
--- a/pkgs/os-specific/linux/firmware/ipw2100/default.nix
+++ b/pkgs/os-specific/linux/firmware/ipw2100/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
   # says: "Your rights to redistribute the Software shall be
   # contingent upon your installation of this Agreement in its
   # entirety in the same directory as the Software."
-  installPhase = "ensureDir $out; cp * $out";
+  installPhase = "mkdir -p $out; cp * $out";
   
   meta = {
     # "... you may transfer a copy of the Software ... provided such
diff --git a/pkgs/os-specific/linux/firmware/ipw2200/default.nix b/pkgs/os-specific/linux/firmware/ipw2200/default.nix
index ed6a82e0df7bc..402636862ecab 100644
--- a/pkgs/os-specific/linux/firmware/ipw2200/default.nix
+++ b/pkgs/os-specific/linux/firmware/ipw2200/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
   # says: "Your rights to redistribute the Software shall be
   # contingent upon your installation of this Agreement in its
   # entirety in the same directory as the Software."
-  installPhase = "ensureDir $out; cp * $out";
+  installPhase = "mkdir -p $out; cp * $out";
   
   meta = {
     # "... you may transfer a copy of the Software ... provided such
diff --git a/pkgs/os-specific/linux/firmware/iwlwifi-1000-ucode/default.nix b/pkgs/os-specific/linux/firmware/iwlwifi-1000-ucode/default.nix
index c09bd5c5aca91..2660c0b2493dc 100644
--- a/pkgs/os-specific/linux/firmware/iwlwifi-1000-ucode/default.nix
+++ b/pkgs/os-specific/linux/firmware/iwlwifi-1000-ucode/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   buildPhase = "true";
 
   installPhase = ''
-    ensureDir "$out"
+    mkdir -p "$out"
     chmod -x *
     cp * "$out"
   '';
diff --git a/pkgs/os-specific/linux/firmware/iwlwifi-3945-ucode/default.nix b/pkgs/os-specific/linux/firmware/iwlwifi-3945-ucode/default.nix
index 389d416f2a5df..afe2357995c2b 100644
--- a/pkgs/os-specific/linux/firmware/iwlwifi-3945-ucode/default.nix
+++ b/pkgs/os-specific/linux/firmware/iwlwifi-3945-ucode/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
   
   buildPhase = "true";
 
-  installPhase = "ensureDir $out; chmod -x *; cp * $out";
+  installPhase = "mkdir -p $out; chmod -x *; cp * $out";
   
   meta = {
     description = "Firmware for the Intel 3945ABG wireless card";
diff --git a/pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/default.nix b/pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/default.nix
index b75eae6acf217..3e3ad74adb346 100644
--- a/pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/default.nix
+++ b/pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   buildPhase = "true";
 
   installPhase = ''
-    ensureDir "$out"
+    mkdir -p "$out"
     chmod -x *
     cp * "$out"
 
diff --git a/pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/version-2.nix b/pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/version-2.nix
index 0948d381f7f15..e1771c7a5cfb6 100644
--- a/pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/version-2.nix
+++ b/pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/version-2.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   buildPhase = "true";
 
   installPhase = ''
-    ensureDir "$out"
+    mkdir -p "$out"
     chmod -x *
     cp * "$out"
   '';
diff --git a/pkgs/os-specific/linux/firmware/iwlwifi-5000-ucode/default.nix b/pkgs/os-specific/linux/firmware/iwlwifi-5000-ucode/default.nix
index 8dc69e0a6a3c2..b8ee5f388d194 100644
--- a/pkgs/os-specific/linux/firmware/iwlwifi-5000-ucode/default.nix
+++ b/pkgs/os-specific/linux/firmware/iwlwifi-5000-ucode/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   buildPhase = "true";
 
   installPhase = ''
-    ensureDir "$out"
+    mkdir -p "$out"
     chmod -x *
     cp * "$out"
   '';
diff --git a/pkgs/os-specific/linux/firmware/iwlwifi-5150-ucode/default.nix b/pkgs/os-specific/linux/firmware/iwlwifi-5150-ucode/default.nix
index 0505a940d2637..0d409bd8427cf 100644
--- a/pkgs/os-specific/linux/firmware/iwlwifi-5150-ucode/default.nix
+++ b/pkgs/os-specific/linux/firmware/iwlwifi-5150-ucode/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   buildPhase = "true";
 
   installPhase = ''
-    ensureDir "$out"
+    mkdir -p "$out"
     chmod -x *
     cp * "$out"
   '';
diff --git a/pkgs/os-specific/linux/firmware/iwlwifi-6000-ucode/default.nix b/pkgs/os-specific/linux/firmware/iwlwifi-6000-ucode/default.nix
index 5b7e2dc7b5e40..e5f3effa4b736 100644
--- a/pkgs/os-specific/linux/firmware/iwlwifi-6000-ucode/default.nix
+++ b/pkgs/os-specific/linux/firmware/iwlwifi-6000-ucode/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   buildPhase = "true";
 
   installPhase = ''
-    ensureDir "$out"
+    mkdir -p "$out"
     chmod -x *
     cp * "$out"
   '';
diff --git a/pkgs/os-specific/linux/firmware/iwlwifi-6000g2a-ucode/default.nix b/pkgs/os-specific/linux/firmware/iwlwifi-6000g2a-ucode/default.nix
index 80aa6d367be75..e5fe73ca4984b 100644
--- a/pkgs/os-specific/linux/firmware/iwlwifi-6000g2a-ucode/default.nix
+++ b/pkgs/os-specific/linux/firmware/iwlwifi-6000g2a-ucode/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   buildPhase = "true";
 
   installPhase = ''
-    ensureDir "$out"
+    mkdir -p "$out"
     chmod -x *
     cp * "$out"
   '';
diff --git a/pkgs/os-specific/linux/firmware/iwlwifi-6000g2b-ucode/default.nix b/pkgs/os-specific/linux/firmware/iwlwifi-6000g2b-ucode/default.nix
index 580af83ea9def..b3a2a810bf7d3 100644
--- a/pkgs/os-specific/linux/firmware/iwlwifi-6000g2b-ucode/default.nix
+++ b/pkgs/os-specific/linux/firmware/iwlwifi-6000g2b-ucode/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   buildPhase = "true";
 
   installPhase = ''
-    ensureDir "$out"
+    mkdir -p "$out"
     chmod -x *
     cp * "$out"
   '';
diff --git a/pkgs/os-specific/linux/firmware/ralink/default.nix b/pkgs/os-specific/linux/firmware/ralink/default.nix
index 23513d2bf8854..abf12fd672b71 100644
--- a/pkgs/os-specific/linux/firmware/ralink/default.nix
+++ b/pkgs/os-specific/linux/firmware/ralink/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation {
   # contingent upon your installation of this Agreement in its
   # entirety in the same directory as the Software."
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp $src/*.bin $out
     cp $src/LICENSE $out/ralink.LICENSE
   '';
diff --git a/pkgs/os-specific/linux/firmware/rt2860/default.nix b/pkgs/os-specific/linux/firmware/rt2860/default.nix
index 0c8accd2f6c5c..0a1cb6555726b 100644
--- a/pkgs/os-specific/linux/firmware/rt2860/default.nix
+++ b/pkgs/os-specific/linux/firmware/rt2860/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation {
   # contingent upon your installation of this Agreement in its
   # entirety in the same directory as the Software."
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp $src/rt2860.bin $out
     cp $src/LICENSE $out/rt2860.LICENSE
   '';
diff --git a/pkgs/os-specific/linux/firmware/rt2870/default.nix b/pkgs/os-specific/linux/firmware/rt2870/default.nix
index 388d3a5034366..15de7c30586b4 100644
--- a/pkgs/os-specific/linux/firmware/rt2870/default.nix
+++ b/pkgs/os-specific/linux/firmware/rt2870/default.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
   # says: "Your rights to redistribute the Software shall be
   # contingent upon your installation of this Agreement in its
   # entirety in the same directory as the Software."
-  installPhase = "ensureDir $out/${name}; cp *.bin $out; cp *.txt $out/${name}";
+  installPhase = "mkdir -p $out/${name}; cp *.bin $out; cp *.txt $out/${name}";
   
   meta = {
     description = "Firmware for the Ralink RT2870 wireless cards";
diff --git a/pkgs/os-specific/linux/firmware/rt73/default.nix b/pkgs/os-specific/linux/firmware/rt73/default.nix
index 32c097a62df9e..9539310013940 100644
--- a/pkgs/os-specific/linux/firmware/rt73/default.nix
+++ b/pkgs/os-specific/linux/firmware/rt73/default.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
   # says: "Your rights to redistribute the Software shall be
   # contingent upon your installation of this Agreement in its
   # entirety in the same directory as the Software."
-  installPhase = "ensureDir $out/${name}; cp *.bin $out; cp *.txt $out/${name}";
+  installPhase = "mkdir -p $out/${name}; cp *.bin $out; cp *.txt $out/${name}";
   
   meta = {
     description = "Firmware for the Ralink RT73 wireless card";
diff --git a/pkgs/os-specific/linux/firmware/rtl8192c/default.nix b/pkgs/os-specific/linux/firmware/rtl8192c/default.nix
index ab8749c153698..f06fcb149e866 100644
--- a/pkgs/os-specific/linux/firmware/rtl8192c/default.nix
+++ b/pkgs/os-specific/linux/firmware/rtl8192c/default.nix
@@ -5,7 +5,7 @@ stdenv.mkDerivation {
 
   phases = [ "installPhase" ];
   installPhase = ''
-    ensureDir $out/rtlwifi
+    mkdir -p $out/rtlwifi
     cp "$src/rtlwifi/rtl8192cfw.bin" "$out/rtlwifi/rtl8192cfw.bin"
   '';
 
diff --git a/pkgs/os-specific/linux/firmware/zd1211/default.nix b/pkgs/os-specific/linux/firmware/zd1211/default.nix
index dfc384b7adb62..a717bd9e1171b 100644
--- a/pkgs/os-specific/linux/firmware/zd1211/default.nix
+++ b/pkgs/os-specific/linux/firmware/zd1211/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   
   buildPhase = "true";
 
-  installPhase = "ensureDir $out/zd1211; cp * $out/zd1211";
+  installPhase = "mkdir -p $out/zd1211; cp * $out/zd1211";
   
   meta = {
     description = "Firmware for the ZyDAS ZD1211(b) 802.11a/b/g USB WLAN chip";
diff --git a/pkgs/os-specific/linux/fxload/default.nix b/pkgs/os-specific/linux/fxload/default.nix
index 455c11cb0a979..d21cdd78daf14 100644
--- a/pkgs/os-specific/linux/fxload/default.nix
+++ b/pkgs/os-specific/linux/fxload/default.nix
@@ -22,9 +22,9 @@ stdenv.mkDerivation {
   '';
 
   preInstall = ''
-    ensureDir $out/sbin
-    ensureDir $out/share/man/man8
-    ensureDir $out/share/usb
+    mkdir -p $out/sbin
+    mkdir -p $out/share/man/man8
+    mkdir -p $out/share/usb
   '';
 
   meta = {
diff --git a/pkgs/os-specific/linux/hal/default.nix b/pkgs/os-specific/linux/hal/default.nix
index 718d54f3106e2..f1757be94cf04 100644
--- a/pkgs/os-specific/linux/hal/default.nix
+++ b/pkgs/os-specific/linux/hal/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, pkgconfig, python, pciutils, expat
 , libusb, dbus, dbus_glib, glib, libuuid, perl
 , perlXMLParser, gettext, zlib, gperf, consolekit, policykit
-, libsmbios, dmidecode, udev, utillinuxng, pmutils, usbutils
+, libsmbios, dmidecode, udev, utillinux, pmutils, usbutils
 , eject, upstart
 }:
 
@@ -51,8 +51,8 @@ stdenv.mkDerivation rec {
       substituteInPlace $i \
         ${changeDmidecode} \
         ${if udev != null then "--replace /sbin/udevadm ${udev}/sbin/udevadm" else ""} \
-        --replace /bin/mount ${utillinuxng}/bin/mount \
-        --replace /bin/umount ${utillinuxng}/bin/umount \
+        --replace /bin/mount ${utillinux}/bin/mount \
+        --replace /bin/umount ${utillinux}/bin/umount \
         --replace /usr/bin/pm-is-supported ${pmutils}/bin/pm-is-supported \
         --replace /usr/sbin/pm ${pmutils}/sbin/pm \
         --replace /sbin/shutdown ${upstart}/sbin/shutdown
diff --git a/pkgs/os-specific/linux/kernel-headers/2.4.nix b/pkgs/os-specific/linux/kernel-headers/2.4.nix
index c179801ca5531..32daf5633f79e 100644
--- a/pkgs/os-specific/linux/kernel-headers/2.4.nix
+++ b/pkgs/os-specific/linux/kernel-headers/2.4.nix
@@ -47,7 +47,7 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out/include
+    mkdir -p $out/include
     cp -a include/{asm,asm-$platform,acpi,linux,pcmcia,scsi,video} \
       $out/include
   '';
diff --git a/pkgs/os-specific/linux/kernel-headers/2.6.18.5.nix b/pkgs/os-specific/linux/kernel-headers/2.6.18.5.nix
deleted file mode 100644
index 5ecdd77fb873b..0000000000000
--- a/pkgs/os-specific/linux/kernel-headers/2.6.18.5.nix
+++ /dev/null
@@ -1,25 +0,0 @@
-{stdenv, fetchurl, unifdef}:
-
-assert stdenv.isLinux;
-
-stdenv.mkDerivation {
-  name = "linux-headers-2.6.18.5";
-  builder = ./builder.sh;
-  src = fetchurl {
-    url = "mirror://kernel/linux/kernel/v2.6/linux-2.6.18.5.tar.bz2";
-    sha256 = "24f0e0011cdae42e3dba56107bb6a60c57c46d1d688a9b0300fec53e80fd1e53";
-  };
-
-  patches = [ ./unifdef-getline.patch ];
-
-  buildInputs = [ unifdef ];
-
-  platform = 
-    if stdenv.system == "i686-linux" then "i386" else
-    if stdenv.system == "x86_64-linux" then "x86_64" else
-    if stdenv.system == "powerpc-linux" then "powerpc" else
-    abort "don't know what the kernel include directory is called for this platform";
-
-  extraIncludeDirs =
-    if stdenv.system == "powerpc-linux" then ["ppc"] else [];
-}
diff --git a/pkgs/os-specific/linux/kernel-headers/2.6.28.nix b/pkgs/os-specific/linux/kernel-headers/2.6.28.nix
index 0b811ae812679..fdbe6cf1bce66 100644
--- a/pkgs/os-specific/linux/kernel-headers/2.6.28.nix
+++ b/pkgs/os-specific/linux/kernel-headers/2.6.28.nix
@@ -47,7 +47,7 @@ stdenv.mkDerivation {
     make INSTALL_HDR_PATH=$out headers_install
 
     # Some builds (e.g. KVM) want a kernel.release.
-    ensureDir $out/include/config
+    mkdir -p $out/include/config
     echo "${version}-default" > $out/include/config/kernel.release
   '';
 
diff --git a/pkgs/os-specific/linux/kernel-headers/2.6.32.nix b/pkgs/os-specific/linux/kernel-headers/2.6.32.nix
index a4e8665819323..a7ec522b3d661 100644
--- a/pkgs/os-specific/linux/kernel-headers/2.6.32.nix
+++ b/pkgs/os-specific/linux/kernel-headers/2.6.32.nix
@@ -48,7 +48,7 @@ stdenv.mkDerivation {
     make INSTALL_HDR_PATH=$out headers_install
 
     # Some builds (e.g. KVM) want a kernel.release.
-    ensureDir $out/include/config
+    mkdir -p $out/include/config
     echo "${version}-default" > $out/include/config/kernel.release
   '';
 
diff --git a/pkgs/os-specific/linux/kernel-headers/builder.sh b/pkgs/os-specific/linux/kernel-headers/builder.sh
deleted file mode 100644
index 05392d5fe24b6..0000000000000
--- a/pkgs/os-specific/linux/kernel-headers/builder.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-source $stdenv/setup
-
-patchPhase="sed -i '/scsi/d' include/Kbuild"
-
-buildPhase="make mrproper headers_check";
-
-installPhase="make INSTALL_HDR_PATH=$out headers_install"
-
-genericBuild
diff --git a/pkgs/os-specific/linux/kernel-headers/default.nix b/pkgs/os-specific/linux/kernel-headers/default.nix
new file mode 100644
index 0000000000000..f5fec3d8620c0
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel-headers/default.nix
@@ -0,0 +1,62 @@
+{ stdenv, fetchurl, perl, cross ? null }:
+
+assert cross == null -> stdenv.isLinux;
+
+let
+  version = "2.6.35.14";
+  kernelHeadersBaseConfig = if cross == null then
+      stdenv.platform.kernelHeadersBaseConfig
+    else
+      cross.platform.kernelHeadersBaseConfig;
+in
+
+stdenv.mkDerivation {
+  name = "linux-headers-${version}";
+
+  src = fetchurl {
+    url = "mirror://kernel/linux/kernel/v2.6/longterm/v2.6.35/linux-${version}.tar.bz2";
+    sha256 = "1wzml7s9karfbk2yi36g1r8fyaq4d4f16yizc68zgchv0xzj39zl";
+  };
+
+  targetConfig = if (cross != null) then cross.config else null;
+
+  platform =
+    if cross != null then cross.platform.kernelArch else
+    if stdenv.system == "i686-linux" then "i386" else
+    if stdenv.system == "x86_64-linux" then "x86_64" else
+    if stdenv.system == "powerpc-linux" then "powerpc" else
+    if stdenv.system == "armv5tel-linux" then "arm" else
+    if stdenv.platform ? kernelArch then stdenv.platform.kernelArch else
+    abort "don't know what the kernel include directory is called for this platform";
+
+  buildInputs = [perl];
+
+  extraIncludeDirs =
+    if cross != null then
+	(if cross.arch == "powerpc" then ["ppc"] else [])
+    else if stdenv.system == "powerpc-linux" then ["ppc"] else [];
+
+  buildPhase = ''
+    if test -n "$targetConfig"; then
+       export ARCH=$platform
+    fi
+    make ${kernelHeadersBaseConfig}
+    make mrproper headers_check
+  '';
+
+  installPhase = ''
+    make INSTALL_HDR_PATH=$out headers_install
+
+    # Some builds (e.g. KVM) want a kernel.release.
+    mkdir -p $out/include/config
+    echo "${version}-default" > $out/include/config/kernel.release
+  '';
+
+  # !!! hacky
+  fixupPhase = ''
+    ln -s asm $out/include/asm-$platform
+    if test "$platform" = "i386" -o "$platform" = "x86_64"; then
+      ln -s asm $out/include/asm-x86
+    fi
+  '';
+}
diff --git a/pkgs/os-specific/linux/kernel/aufs2-33.patch b/pkgs/os-specific/linux/kernel/aufs2-33.patch
deleted file mode 100644
index 49a660b0c9e86..0000000000000
--- a/pkgs/os-specific/linux/kernel/aufs2-33.patch
+++ /dev/null
@@ -1,82 +0,0 @@
-ufs2 base patch for linux-2.6.33
-
-diff --git a/fs/namei.c b/fs/namei.c
-index a4855af..1d12d37 100644
---- a/fs/namei.c
-+++ b/fs/namei.c
-@@ -1207,7 +1207,7 @@ out:
-  * needs parent already locked. Doesn't follow mounts.
-  * SMP-safe.
-  */
--static struct dentry *lookup_hash(struct nameidata *nd)
-+struct dentry *lookup_hash(struct nameidata *nd)
- {
-        int err;
- 
-@@ -1217,7 +1217,7 @@ static struct dentry *lookup_hash(struct nameidata *nd)
-        return __lookup_hash(&nd->last, nd->path.dentry, nd);
- }
- 
--static int __lookup_one_len(const char *name, struct qstr *this,
-+int __lookup_one_len(const char *name, struct qstr *this,
-                struct dentry *base, int len)
- {
-        unsigned long hash;
-diff --git a/fs/splice.c b/fs/splice.c
-index 3920866..b13a9a2 100644
---- a/fs/splice.c
-+++ b/fs/splice.c
-@@ -1053,8 +1053,8 @@ EXPORT_SYMBOL(generic_splice_sendpage);
- /*
-  * Attempt to initiate a splice from pipe to file.
-  */
--static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
--                          loff_t *ppos, size_t len, unsigned int flags)
-+long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
-+                   loff_t *ppos, size_t len, unsigned int flags)
- {
-        ssize_t (*splice_write)(struct pipe_inode_info *, struct file *,
-                                loff_t *, size_t, unsigned int);
-@@ -1081,9 +1081,9 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
- /*
-  * Attempt to initiate a splice from a file to a pipe.
-  */
--static long do_splice_to(struct file *in, loff_t *ppos,
--                        struct pipe_inode_info *pipe, size_t len,
--                        unsigned int flags)
-+long do_splice_to(struct file *in, loff_t *ppos,
-+                 struct pipe_inode_info *pipe, size_t len,
-+                 unsigned int flags)
- {
-        ssize_t (*splice_read)(struct file *, loff_t *,
-                               struct pipe_inode_info *, size_t, unsigned int);
-diff --git a/include/linux/namei.h b/include/linux/namei.h
-index 05b441d..91bc74e 100644
---- a/include/linux/namei.h
-+++ b/include/linux/namei.h
-@@ -73,6 +73,9 @@ extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
- extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
-                int (*open)(struct inode *, struct file *));
- 
-+extern struct dentry *lookup_hash(struct nameidata *nd);
-+extern int __lookup_one_len(const char *name, struct qstr *this,
-+                           struct dentry *base, int len);
- extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
- 
- extern int follow_down(struct path *);
-diff --git a/include/linux/splice.h b/include/linux/splice.h
-index 18e7c7c..8393b5c 100644
---- a/include/linux/splice.h
-+++ b/include/linux/splice.h
-@@ -82,4 +82,10 @@ extern ssize_t splice_to_pipe(struct pipe_inode_info *,
- extern ssize_t splice_direct_to_actor(struct file *, struct splice_desc *,
-                                      splice_direct_actor *);
- 
-+extern long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
-+                          loff_t *ppos, size_t len, unsigned int flags);
-+extern long do_splice_to(struct file *in, loff_t *ppos,
-+                        struct pipe_inode_info *pipe, size_t len,
-+                        unsigned int flags);
-+
- #endif
-
diff --git a/pkgs/os-specific/linux/kernel/aufs2.1-37.patch b/pkgs/os-specific/linux/kernel/aufs2.1-37.patch
deleted file mode 100644
index 4cb58ad8a57a2..0000000000000
--- a/pkgs/os-specific/linux/kernel/aufs2.1-37.patch
+++ /dev/null
@@ -1,368 +0,0 @@
-aufs2.1 base patch for linux-2.6.37
-
-diff --git a/fs/namei.c b/fs/namei.c
-index 4ff7ca5..a8c583f 100644
---- a/fs/namei.c
-+++ b/fs/namei.c
-@@ -1161,12 +1161,12 @@ out:
-  * needs parent already locked. Doesn't follow mounts.
-  * SMP-safe.
-  */
--static struct dentry *lookup_hash(struct nameidata *nd)
-+struct dentry *lookup_hash(struct nameidata *nd)
- {
- 	return __lookup_hash(&nd->last, nd->path.dentry, nd);
- }
- 
--static int __lookup_one_len(const char *name, struct qstr *this,
-+int __lookup_one_len(const char *name, struct qstr *this,
- 		struct dentry *base, int len)
- {
- 	unsigned long hash;
-diff --git a/fs/splice.c b/fs/splice.c
-index ce2f025..ff0ae69 100644
---- a/fs/splice.c
-+++ b/fs/splice.c
-@@ -1092,8 +1092,8 @@ EXPORT_SYMBOL(generic_splice_sendpage);
- /*
-  * Attempt to initiate a splice from pipe to file.
-  */
--static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
--			   loff_t *ppos, size_t len, unsigned int flags)
-+long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
-+		    loff_t *ppos, size_t len, unsigned int flags)
- {
- 	ssize_t (*splice_write)(struct pipe_inode_info *, struct file *,
- 				loff_t *, size_t, unsigned int);
-@@ -1120,9 +1120,9 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
- /*
-  * Attempt to initiate a splice from a file to a pipe.
-  */
--static long do_splice_to(struct file *in, loff_t *ppos,
--			 struct pipe_inode_info *pipe, size_t len,
--			 unsigned int flags)
-+long do_splice_to(struct file *in, loff_t *ppos,
-+		  struct pipe_inode_info *pipe, size_t len,
-+		  unsigned int flags)
- {
- 	ssize_t (*splice_read)(struct file *, loff_t *,
- 			       struct pipe_inode_info *, size_t, unsigned int);
-diff --git a/include/linux/namei.h b/include/linux/namei.h
-index 05b441d..91bc74e 100644
---- a/include/linux/namei.h
-+++ b/include/linux/namei.h
-@@ -73,6 +73,9 @@ extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
- extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
- 		int (*open)(struct inode *, struct file *));
- 
-+extern struct dentry *lookup_hash(struct nameidata *nd);
-+extern int __lookup_one_len(const char *name, struct qstr *this,
-+			    struct dentry *base, int len);
- extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
- 
- extern int follow_down(struct path *);
-diff --git a/include/linux/splice.h b/include/linux/splice.h
-index 997c3b4..be9a153 100644
---- a/include/linux/splice.h
-+++ b/include/linux/splice.h
-@@ -89,4 +89,10 @@ extern int splice_grow_spd(struct pipe_inode_info *, struct splice_pipe_desc *);
- extern void splice_shrink_spd(struct pipe_inode_info *,
- 				struct splice_pipe_desc *);
- 
-+extern long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
-+			   loff_t *ppos, size_t len, unsigned int flags);
-+extern long do_splice_to(struct file *in, loff_t *ppos,
-+			 struct pipe_inode_info *pipe, size_t len,
-+			 unsigned int flags);
-+
- #endif
-aufs2.1 standalone patch for linux-2.6.37
-
-diff --git a/fs/file_table.c b/fs/file_table.c
-index c3dee38..f529e4d 100644
---- a/fs/file_table.c
-+++ b/fs/file_table.c
-@@ -393,6 +393,8 @@ void file_sb_list_del(struct file *file)
- 	}
- }
- 
-+EXPORT_SYMBOL(file_sb_list_del);
-+
- #ifdef CONFIG_SMP
- 
- /*
-diff --git a/fs/inode.c b/fs/inode.c
-index ae2727a..2c8071a 100644
---- a/fs/inode.c
-+++ b/fs/inode.c
-@@ -82,6 +82,7 @@ static struct hlist_head *inode_hashtable __read_mostly;
-  * the i_state of an inode while it is in use..
-  */
- DEFINE_SPINLOCK(inode_lock);
-+EXPORT_SYMBOL(inode_lock);
- 
- /*
-  * iprune_sem provides exclusion between the kswapd or try_to_free_pages
-diff --git a/fs/namei.c b/fs/namei.c
-index a8c583f..b020c45 100644
---- a/fs/namei.c
-+++ b/fs/namei.c
-@@ -347,6 +347,7 @@ int deny_write_access(struct file * file)
- 
- 	return 0;
- }
-+EXPORT_SYMBOL(deny_write_access);
- 
- /**
-  * path_get - get a reference to a path
-@@ -1165,6 +1166,7 @@ struct dentry *lookup_hash(struct nameidata *nd)
- {
- 	return __lookup_hash(&nd->last, nd->path.dentry, nd);
- }
-+EXPORT_SYMBOL(lookup_hash);
- 
- int __lookup_one_len(const char *name, struct qstr *this,
- 		struct dentry *base, int len)
-@@ -1187,6 +1189,7 @@ int __lookup_one_len(const char *name, struct qstr *this,
- 	this->hash = end_name_hash(hash);
- 	return 0;
- }
-+EXPORT_SYMBOL(__lookup_one_len);
- 
- /**
-  * lookup_one_len - filesystem helper to lookup single pathname component
-diff --git a/fs/namespace.c b/fs/namespace.c
-index 3dbfc07..3998762 100644
---- a/fs/namespace.c
-+++ b/fs/namespace.c
-@@ -1321,6 +1321,7 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
- 	}
- 	return 0;
- }
-+EXPORT_SYMBOL(iterate_mounts);
- 
- static void cleanup_group_ids(struct vfsmount *mnt, struct vfsmount *end)
- {
-diff --git a/fs/notify/group.c b/fs/notify/group.c
-index d309f38..f0e9568 100644
---- a/fs/notify/group.c
-+++ b/fs/notify/group.c
-@@ -22,6 +22,7 @@
- #include <linux/srcu.h>
- #include <linux/rculist.h>
- #include <linux/wait.h>
-+#include <linux/module.h>
- 
- #include <linux/fsnotify_backend.h>
- #include "fsnotify.h"
-@@ -70,6 +71,7 @@ void fsnotify_put_group(struct fsnotify_group *group)
- 	if (atomic_dec_and_test(&group->refcnt))
- 		fsnotify_destroy_group(group);
- }
-+EXPORT_SYMBOL(fsnotify_put_group);
- 
- /*
-  * Create a new fsnotify_group and hold a reference for the group returned.
-@@ -102,3 +104,4 @@ struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops)
- 
- 	return group;
- }
-+EXPORT_SYMBOL(fsnotify_alloc_group);
-diff --git a/fs/notify/mark.c b/fs/notify/mark.c
-index 325185e..adede09 100644
---- a/fs/notify/mark.c
-+++ b/fs/notify/mark.c
-@@ -113,6 +113,7 @@ void fsnotify_put_mark(struct fsnotify_mark *mark)
- 	if (atomic_dec_and_test(&mark->refcnt))
- 		mark->free_mark(mark);
- }
-+EXPORT_SYMBOL(fsnotify_put_mark);
- 
- /*
-  * Any time a mark is getting freed we end up here.
-@@ -190,6 +191,7 @@ void fsnotify_destroy_mark(struct fsnotify_mark *mark)
- 	if (unlikely(atomic_dec_and_test(&group->num_marks)))
- 		fsnotify_final_destroy_group(group);
- }
-+EXPORT_SYMBOL(fsnotify_destroy_mark);
- 
- void fsnotify_set_mark_mask_locked(struct fsnotify_mark *mark, __u32 mask)
- {
-@@ -277,6 +279,7 @@ err:
- 
- 	return ret;
- }
-+EXPORT_SYMBOL(fsnotify_add_mark);
- 
- /*
-  * clear any marks in a group in which mark->flags & flags is true
-@@ -332,6 +335,7 @@ void fsnotify_init_mark(struct fsnotify_mark *mark,
- 	atomic_set(&mark->refcnt, 1);
- 	mark->free_mark = free_mark;
- }
-+EXPORT_SYMBOL(fsnotify_init_mark);
- 
- static int fsnotify_mark_destroy(void *ignored)
- {
-diff --git a/fs/open.c b/fs/open.c
-index 4197b9e..912817a 100644
---- a/fs/open.c
-+++ b/fs/open.c
-@@ -60,6 +60,7 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
- 	mutex_unlock(&dentry->d_inode->i_mutex);
- 	return ret;
- }
-+EXPORT_SYMBOL(do_truncate);
- 
- static long do_sys_truncate(const char __user *pathname, loff_t length)
- {
-diff --git a/fs/splice.c b/fs/splice.c
-index ff0ae69..1c9e9b0 100644
---- a/fs/splice.c
-+++ b/fs/splice.c
-@@ -1116,6 +1116,7 @@ long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
- 
- 	return splice_write(pipe, out, ppos, len, flags);
- }
-+EXPORT_SYMBOL(do_splice_from);
- 
- /*
-  * Attempt to initiate a splice from a file to a pipe.
-@@ -1142,6 +1143,7 @@ long do_splice_to(struct file *in, loff_t *ppos,
- 
- 	return splice_read(in, ppos, pipe, len, flags);
- }
-+EXPORT_SYMBOL(do_splice_to);
- 
- /**
-  * splice_direct_to_actor - splices data directly between two non-pipes
-diff --git a/security/commoncap.c b/security/commoncap.c
-index 64c2ed9..e58b5d8 100644
---- a/security/commoncap.c
-+++ b/security/commoncap.c
-@@ -929,3 +929,4 @@ int cap_file_mmap(struct file *file, unsigned long reqprot,
- 	}
- 	return ret;
- }
-+EXPORT_SYMBOL(cap_file_mmap);
-diff --git a/security/device_cgroup.c b/security/device_cgroup.c
-index 8d9c48f..29108aa 100644
---- a/security/device_cgroup.c
-+++ b/security/device_cgroup.c
-@@ -515,6 +515,7 @@ found:
- 
- 	return -EPERM;
- }
-+EXPORT_SYMBOL(devcgroup_inode_permission);
- 
- int devcgroup_inode_mknod(int mode, dev_t dev)
- {
-diff --git a/security/security.c b/security/security.c
-index 1b798d3..3b7d2ca 100644
---- a/security/security.c
-+++ b/security/security.c
-@@ -360,6 +360,7 @@ int security_path_mkdir(struct path *dir, struct dentry *dentry, int mode)
- 		return 0;
- 	return security_ops->path_mkdir(dir, dentry, mode);
- }
-+EXPORT_SYMBOL(security_path_mkdir);
- 
- int security_path_rmdir(struct path *dir, struct dentry *dentry)
- {
-@@ -367,6 +368,7 @@ int security_path_rmdir(struct path *dir, struct dentry *dentry)
- 		return 0;
- 	return security_ops->path_rmdir(dir, dentry);
- }
-+EXPORT_SYMBOL(security_path_rmdir);
- 
- int security_path_unlink(struct path *dir, struct dentry *dentry)
- {
-@@ -374,6 +376,7 @@ int security_path_unlink(struct path *dir, struct dentry *dentry)
- 		return 0;
- 	return security_ops->path_unlink(dir, dentry);
- }
-+EXPORT_SYMBOL(security_path_unlink);
- 
- int security_path_symlink(struct path *dir, struct dentry *dentry,
- 			  const char *old_name)
-@@ -382,6 +385,7 @@ int security_path_symlink(struct path *dir, struct dentry *dentry,
- 		return 0;
- 	return security_ops->path_symlink(dir, dentry, old_name);
- }
-+EXPORT_SYMBOL(security_path_symlink);
- 
- int security_path_link(struct dentry *old_dentry, struct path *new_dir,
- 		       struct dentry *new_dentry)
-@@ -390,6 +394,7 @@ int security_path_link(struct dentry *old_dentry, struct path *new_dir,
- 		return 0;
- 	return security_ops->path_link(old_dentry, new_dir, new_dentry);
- }
-+EXPORT_SYMBOL(security_path_link);
- 
- int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
- 			 struct path *new_dir, struct dentry *new_dentry)
-@@ -400,6 +405,7 @@ int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
- 	return security_ops->path_rename(old_dir, old_dentry, new_dir,
- 					 new_dentry);
- }
-+EXPORT_SYMBOL(security_path_rename);
- 
- int security_path_truncate(struct path *path)
- {
-@@ -407,6 +413,7 @@ int security_path_truncate(struct path *path)
- 		return 0;
- 	return security_ops->path_truncate(path);
- }
-+EXPORT_SYMBOL(security_path_truncate);
- 
- int security_path_chmod(struct dentry *dentry, struct vfsmount *mnt,
- 			mode_t mode)
-@@ -415,6 +422,7 @@ int security_path_chmod(struct dentry *dentry, struct vfsmount *mnt,
- 		return 0;
- 	return security_ops->path_chmod(dentry, mnt, mode);
- }
-+EXPORT_SYMBOL(security_path_chmod);
- 
- int security_path_chown(struct path *path, uid_t uid, gid_t gid)
- {
-@@ -422,6 +430,7 @@ int security_path_chown(struct path *path, uid_t uid, gid_t gid)
- 		return 0;
- 	return security_ops->path_chown(path, uid, gid);
- }
-+EXPORT_SYMBOL(security_path_chown);
- 
- int security_path_chroot(struct path *path)
- {
-@@ -498,6 +507,7 @@ int security_inode_readlink(struct dentry *dentry)
- 		return 0;
- 	return security_ops->inode_readlink(dentry);
- }
-+EXPORT_SYMBOL(security_inode_readlink);
- 
- int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd)
- {
-@@ -512,6 +522,7 @@ int security_inode_permission(struct inode *inode, int mask)
- 		return 0;
- 	return security_ops->inode_permission(inode, mask);
- }
-+EXPORT_SYMBOL(security_inode_permission);
- 
- int security_inode_setattr(struct dentry *dentry, struct iattr *attr)
- {
-@@ -611,6 +622,7 @@ int security_file_permission(struct file *file, int mask)
- 
- 	return fsnotify_perm(file, mask);
- }
-+EXPORT_SYMBOL(security_file_permission);
- 
- int security_file_alloc(struct file *file)
- {
-@@ -638,6 +650,7 @@ int security_file_mmap(struct file *file, unsigned long reqprot,
- 		return ret;
- 	return ima_file_mmap(file, prot);
- }
-+EXPORT_SYMBOL(security_file_mmap);
- 
- int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
- 			    unsigned long prot)
-
diff --git a/pkgs/os-specific/linux/kernel/builder.sh b/pkgs/os-specific/linux/kernel/builder.sh
index 61cb8f2808102..5d6d48d2fc3d6 100644
--- a/pkgs/os-specific/linux/kernel/builder.sh
+++ b/pkgs/os-specific/linux/kernel/builder.sh
@@ -48,7 +48,7 @@ configurePhase() {
 
 installPhase() {
 
-    ensureDir $out
+    mkdir -p $out
 
     # New kernel versions have a combined tree for i386 and x86_64.
     archDir=$arch
@@ -60,7 +60,7 @@ installPhase() {
     # Copy the bzImage and System.map.
     cp System.map $out
     if test "$arch" = um; then
-        ensureDir $out/bin
+        mkdir -p $out/bin
         cp linux $out/bin
     elif test "$kernelTarget" != "vmlinux"; then
         # In any case we copy the 'vmlinux' ELF in the next lines
diff --git a/pkgs/os-specific/linux/kernel/getline.patch b/pkgs/os-specific/linux/kernel/getline.patch
deleted file mode 100644
index 6ac768b9d865b..0000000000000
--- a/pkgs/os-specific/linux/kernel/getline.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-Allow compilation with recent versions of Glibc.
-From https://patchwork.kernel.org/patch/11166/.
-
-diff --git a/scripts/unifdef.c b/scripts/unifdef.c
-index 552025e..977e682 100644
---- a/scripts/unifdef.c
-+++ b/scripts/unifdef.c
-@@ -206,7 +206,7 @@  static void             done(void);
- static void             error(const char *);
- static int              findsym(const char *);
- static void             flushline(bool);
--static Linetype         getline(void);
-+static Linetype         parseline(void);
- static Linetype         ifeval(const char **);
- static void             ignoreoff(void);
- static void             ignoreon(void);
-@@ -512,7 +512,7 @@  process(void)
- 
- 	for (;;) {
- 		linenum++;
--		lineval = getline();
-+		lineval = parseline();
- 		trans_table[ifstate[depth]][lineval]();
- 		debug("process %s -> %s depth %d",
- 		    linetype_name[lineval],
-@@ -526,7 +526,7 @@  process(void)
-  * help from skipcomment().
-  */
- static Linetype
--getline(void)
-+parseline(void)
- {
- 	const char *cp;
- 	int cursym;
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.25.nix b/pkgs/os-specific/linux/kernel/linux-2.6.25.nix
deleted file mode 100644
index 69e5ef641398e..0000000000000
--- a/pkgs/os-specific/linux/kernel/linux-2.6.25.nix
+++ /dev/null
@@ -1,163 +0,0 @@
-args @ { stdenv, fetchurl, userModeLinux ? false, extraConfig ? "", ... }:
-
-import ./generic.nix (
-
-  rec {
-    version = "2.6.25.20";
-  
-    src = fetchurl {
-      url = "mirror://kernel/linux/kernel/v2.6/linux-${version}.tar.bz2";
-      sha256 = "07knyjhvanvclk6xdwi07vfvsmiqciqaj26cn78ayiqqqr9d4f6y";
-    };
-
-    features.iwlwifi = true;
-
-    config =
-      ''
-        # Don't include any debug features.
-        DEBUG_KERNEL n
-
-        # Support drivers that need external firmware.
-        STANDALONE n
-
-        # Make /proc/config.gz available.
-        IKCONFIG_PROC y
-
-        # Optimize with -O2, not -Os.
-        CC_OPTIMIZE_FOR_SIZE n
-
-        # Include the CFQ I/O scheduler in the kernel, rather than as a
-        # module, so that the initrd gets a good I/O scheduler.
-        IOSCHED_CFQ y
-
-        # Disable some expensive (?) features.
-        MARKERS n
-        KPROBES n
-        NUMA? n
-
-        # Enable various subsystems.
-        AUXDISPLAY y # Auxiliary Display support
-        DONGLE y # Serial dongle support
-        HIPPI y
-        MTD_COMPLEX_MAPPINGS y # needed for many devices
-        NET_POCKET y # enable pocket and portable adapters
-        SCSI_LOWLEVEL y # enable lots of SCSI devices
-        SCSI_LOWLEVEL_PCMCIA y
-        SPI y # needed for many devices
-        SPI_MASTER y
-        WAN y
-
-        # Networking options.
-        IP_PNP n
-        IPV6_PRIVACY y
-        IP_DCCP_CCID3 n # experimental
-
-        # Some settings to make sure that fbcondecor works - in particular,
-        # disable tileblitting and the drivers that need it.
-
-        # Enable various FB devices.
-        FB_EFI y
-        FB_NVIDIA_I2C y # Enable DDC Support
-        FB_RIVA_I2C y
-        FB_ATY_CT y # Mach64 CT/VT/GT/LT (incl. 3D RAGE) support
-        FB_ATY_GX y # Mach64 GX support
-        FB_SAVAGE_I2C y
-        FB_SAVAGE_ACCEL y
-        FB_SIS_300 y
-        FB_SIS_315 y
-        FB_3DFX_ACCEL y
-        FB_TRIDENT_ACCEL y
-        FB_GEODE y
-
-        # Sound.
-        SND_AC97_POWER_SAVE y # AC97 Power-Saving Mode
-        SND_USB_CAIAQ_INPUT y
-        PSS_MIXER y # Enable PSS mixer (Beethoven ADSP-16 and other compatible)
-
-        # Enable a bunch of USB storage devices.
-        USB_STORAGE_DATAFAB y
-        USB_STORAGE_FREECOM y
-        USB_STORAGE_ISD200 y
-        USB_STORAGE_USBAT y
-        USB_STORAGE_SDDR09 y
-        USB_STORAGE_SDDR55 y
-        USB_STORAGE_JUMPSHOT y
-        USB_STORAGE_KARMA y
-
-        # USB serial devices.
-        USB_SERIAL_GENERIC y # USB Generic Serial Driver
-        USB_SERIAL_KEYSPAN_MPR y # include firmware for various USB serial devices
-        USB_SERIAL_KEYSPAN_USA28 y
-        USB_SERIAL_KEYSPAN_USA28X y
-        USB_SERIAL_KEYSPAN_USA28XA y
-        USB_SERIAL_KEYSPAN_USA28XB y
-        USB_SERIAL_KEYSPAN_USA19 y
-        USB_SERIAL_KEYSPAN_USA18X y
-        USB_SERIAL_KEYSPAN_USA19W y
-        USB_SERIAL_KEYSPAN_USA19QW y
-        USB_SERIAL_KEYSPAN_USA19QI y
-        USB_SERIAL_KEYSPAN_USA49W y
-        USB_SERIAL_KEYSPAN_USA49WLC y
-
-        # Filesystem options - in particular, enable extended attributes and
-        # ACLs for all filesystems that support them.
-        EXT2_FS_XATTR y # Ext2 extended attributes
-        EXT2_FS_POSIX_ACL y # Ext2 POSIX Access Control Lists
-        EXT2_FS_SECURITY y # Ext2 Security Labels
-        EXT2_FS_XIP y # Ext2 execute in place support
-        REISERFS_FS_XATTR y
-        REISERFS_FS_POSIX_ACL y
-        REISERFS_FS_SECURITY y
-        JFS_POSIX_ACL y
-        JFS_SECURITY y
-        XFS_QUOTA y
-        XFS_POSIX_ACL y
-        XFS_RT y # XFS Realtime subvolume support
-        OCFS2_DEBUG_MASKLOG n
-        NFSD_V2_ACL y
-        NFSD_V3 y
-        NFSD_V3_ACL y
-        NFSD_V4 y
-        CIFS_XATTR y
-        CIFS_POSIX y
-
-        # Misc. options.
-        8139TOO_8129 y
-        8139TOO_PIO n # PIO is slower
-        AIC79XX_DEBUG_ENABLE n
-        AIC7XXX_DEBUG_ENABLE n
-        AIC94XX_DEBUG n
-        BLK_DEV_BSG n
-        BLK_DEV_CMD640_ENHANCED y # CMD640 enhanced support
-        BLK_DEV_IDEACPI y # IDE ACPI support
-        BLK_DEV_IO_TRACE n
-        BT_HCIUART_BCSP y
-        BT_HCIUART_H4 y # UART (H4) protocol support
-        BT_HCIUART_LL y
-        BT_RFCOMM_TTY y # RFCOMM TTY support
-        CPU_FREQ_DEBUG n
-        CRASH_DUMP n
-        DMAR? n # experimental
-        FUSION y # Fusion MPT device support
-        IRDA_ULTRA y # Ultra (connectionless) protocol
-        KALLSYMS_EXTRA_PASS n
-        LOGO n # not needed
-        MEGARAID_NEWGEN y
-        MODVERSIONS y
-        NET_FC y # Fibre Channel driver support
-        PCI_LEGACY y
-        PPP_MULTILINK y # PPP multilink support
-        SCSI_LOGGING y # SCSI logging facility
-        SERIAL_8250 y # 8250/16550 and compatible serial support
-        SLIP_COMPRESSED y # CSLIP compressed headers
-        SLIP_SMART y
-        USB_DEBUG n
-        USB_EHCI_ROOT_HUB_TT y # Root Hub Transaction Translators
-        X86_MCE y
-
-        ${extraConfig}
-      '';
-  }
-
-  // args
-)
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.26.nix b/pkgs/os-specific/linux/kernel/linux-2.6.26.nix
deleted file mode 100644
index b402cdea74269..0000000000000
--- a/pkgs/os-specific/linux/kernel/linux-2.6.26.nix
+++ /dev/null
@@ -1,177 +0,0 @@
-{ stdenv, fetchurl, extraConfig ? "", ... } @ args:
-
-let
-  configWithPlatform = kernelPlatform :
-    ''
-        # Don't include any debug features.
-        DEBUG_KERNEL n
-
-	# Activate /proc/sys/kernel/modprobe
-	KMOD y
-
-        # Support drivers that need external firmware.
-        STANDALONE n
-
-        # Make /proc/config.gz available.
-        IKCONFIG_PROC y
-
-        # Optimize with -O2, not -Os.
-        CC_OPTIMIZE_FOR_SIZE n
-
-        # Virtualisation (KVM, Xen...).
-        PARAVIRT_GUEST y
-        KVM_CLOCK y
-        KVM_GUEST y
-
-        # Include the CFQ I/O scheduler in the kernel, rather than as a
-        # module, so that the initrd gets a good I/O scheduler.
-        IOSCHED_CFQ y
-
-        # Disable some expensive (?) features.
-        MARKERS n
-        KPROBES n
-        NUMA? n
-
-        # Enable various subsystems.
-        ACCESSIBILITY y # Accessibility support
-        AUXDISPLAY y # Auxiliary Display support
-        DONGLE y # Serial dongle support
-        HIPPI y
-        MTD_COMPLEX_MAPPINGS y # needed for many devices
-        NET_POCKET y # enable pocket and portable adapters
-        SCSI_LOWLEVEL y # enable lots of SCSI devices
-        SCSI_LOWLEVEL_PCMCIA y
-        SPI y # needed for many devices
-        SPI_MASTER y
-        WAN y
-
-        # Networking options.
-        IP_PNP n
-        IPV6_PRIVACY y
-
-        # Some settings to make sure that fbcondecor works - in particular,
-        # disable tileblitting and the drivers that need it.
-
-        # Enable various FB devices.
-        FB_EFI y
-        FB_NVIDIA_I2C y # Enable DDC Support
-        FB_RIVA_I2C y
-        FB_ATY_CT y # ach64 CT/VT/GT/LT (incl. 3D RAGE) support
-        FB_ATY_GX y # Mach64 GX support
-        FB_SAVAGE_I2C y
-        FB_SAVAGE_ACCEL y
-        FB_SIS_300 y
-        FB_SIS_315 y
-        FB_3DFX_ACCEL y
-        FB_TRIDENT_ACCEL y
-        FB_GEODE y
-
-        # Sound.
-        SND_AC97_POWER_SAVE y # AC97 Power-Saving Mode
-        SND_USB_CAIAQ_INPUT y
-        PSS_MIXER y # Enable PSS mixer (Beethoven ADSP-16 and other compatible)
-
-        # Enable a bunch of USB storage devices.
-        USB_STORAGE_DATAFAB y
-        USB_STORAGE_FREECOM y
-        USB_STORAGE_ISD200 y
-        USB_STORAGE_USBAT y
-        USB_STORAGE_SDDR09 y
-        USB_STORAGE_SDDR55 y
-        USB_STORAGE_JUMPSHOT y
-        USB_STORAGE_ONETOUCH y
-        USB_STORAGE_KARMA y
-        USB_STORAGE_CYPRESS_ATACB y
-
-        # USB serial devices.
-        USB_SERIAL_GENERIC y # USB Generic Serial Driver
-        USB_SERIAL_KEYSPAN_MPR y # include firmware for various USB serial devices
-        USB_SERIAL_KEYSPAN_USA28 y
-        USB_SERIAL_KEYSPAN_USA28X y
-        USB_SERIAL_KEYSPAN_USA28XA y
-        USB_SERIAL_KEYSPAN_USA28XB y
-        USB_SERIAL_KEYSPAN_USA19 y
-        USB_SERIAL_KEYSPAN_USA18X y
-        USB_SERIAL_KEYSPAN_USA19W y
-        USB_SERIAL_KEYSPAN_USA19QW y
-        USB_SERIAL_KEYSPAN_USA19QI y
-        USB_SERIAL_KEYSPAN_USA49W y
-        USB_SERIAL_KEYSPAN_USA49WLC y
-
-        # Filesystem options - in particular, enable extended attributes and
-        # ACLs for all filesystems that support them.
-        EXT2_FS_XATTR y # Ext2 extended attributes
-        EXT2_FS_POSIX_ACL y # Ext2 POSIX Access Control Lists
-        EXT2_FS_SECURITY y # Ext2 Security Labels
-        EXT2_FS_XIP y # Ext2 execute in place support
-        REISERFS_FS_XATTR y
-        REISERFS_FS_POSIX_ACL y
-        REISERFS_FS_SECURITY y
-        JFS_POSIX_ACL y
-        JFS_SECURITY y
-        XFS_QUOTA y
-        XFS_POSIX_ACL y
-        XFS_RT y # XFS Realtime subvolume support
-        OCFS2_DEBUG_MASKLOG n
-        NFSD_V2_ACL y
-        NFSD_V3 y
-        NFSD_V3_ACL y
-        NFSD_V4 y
-        CIFS_XATTR y
-        CIFS_POSIX y
-
-        # Misc. options.
-        8139TOO_8129 y
-        8139TOO_PIO n # PIO is slower
-        AIC79XX_DEBUG_ENABLE n
-        AIC7XXX_DEBUG_ENABLE n
-        AIC94XX_DEBUG n
-        BLK_DEV_BSG n
-        BLK_DEV_IDEACPI y # IDE ACPI support
-        BLK_DEV_IO_TRACE n
-        BT_HCIUART_BCSP y
-        BT_HCIUART_H4 y # UART (H4) protocol support
-        BT_HCIUART_LL y
-        BT_RFCOMM_TTY y # RFCOMM TTY support
-        CPU_FREQ_DEBUG n
-        CRASH_DUMP n
-        DMAR? n # experimental
-        FUSION y # Fusion MPT device support
-        IRDA_ULTRA y # Ultra (connectionless) protocol
-        KALLSYMS_EXTRA_PASS n
-        LOGO n # not needed
-        MEDIA_ATTACH y
-        MEGARAID_NEWGEN y
-        MODVERSIONS y
-        NET_FC y # Fibre Channel driver support
-        PCI_LEGACY y
-        PPP_MULTILINK y # PPP multilink support
-        SCSI_LOGGING y # SCSI logging facility
-        SERIAL_8250 y # 8250/16550 and compatible serial support
-        SLIP_COMPRESSED y # CSLIP compressed headers
-        SLIP_SMART y
-        THERMAL_HWMON y # Hardware monitoring support
-        USB_DEBUG n
-        USB_EHCI_ROOT_HUB_TT y # Root Hub Transaction Translators
-        X86_MCE y
-
-      ${extraConfig}
-   '';
-in
-
-import ./generic.nix (
-
-  rec {
-    version = "2.6.26.8";
-
-    src = fetchurl {
-      url = "ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-${version}.tar.bz2";
-      sha256 = "4f2991378a09bd4ba916236cba200052c18e52e44c9d7e4100337f7df2788dc9";
-    };
-
-    config = configWithPlatform stdenv.platform;
-    configCross = configWithPlatform stdenv.cross.platform;
-  }
-
-  // removeAttrs args ["extraConfig"]
-)
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.27.nix b/pkgs/os-specific/linux/kernel/linux-2.6.27.nix
index 083948fd345be..046b07b9e6471 100644
--- a/pkgs/os-specific/linux/kernel/linux-2.6.27.nix
+++ b/pkgs/os-specific/linux/kernel/linux-2.6.27.nix
@@ -3,11 +3,11 @@ args @ { stdenv, fetchurl, userModeLinux ? false, extraConfig ? "", ... }:
 import ./generic.nix (
 
   rec {
-    version = "2.6.27.59";
+    version = "2.6.27.61";
   
     src = fetchurl {
       url = "mirror://kernel/linux/kernel/v2.6/longterm/v2.6.27/linux-${version}.tar.bz2";
-      sha256 = "0gvp9djj3s8h1375xdjv6ycd0mgmcbvfmswxkpwxdlplly5hr1kf";
+      sha256 = "1lian4fj84fry3yanammawzsqi7ix9pvic6qfr578xnvsbf5pbi7";
     };
 
     features.iwlwifi = true;
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.28.nix b/pkgs/os-specific/linux/kernel/linux-2.6.28.nix
deleted file mode 100644
index d8e051a529c63..0000000000000
--- a/pkgs/os-specific/linux/kernel/linux-2.6.28.nix
+++ /dev/null
@@ -1,227 +0,0 @@
-args @ { stdenv, fetchurl, userModeLinux ? false, extraConfig ? "", ... }:
-
-import ./generic.nix (
-
-  rec {
-    version = "2.6.28.10";
-  
-    src = fetchurl {
-      url = "mirror://kernel/linux/kernel/v2.6/linux-${version}.tar.bz2";
-      sha256 = "10vryshzpgk7vqmb3f0z981r5nci722kfqbjd274qwjyanxlj60b";
-    };
-
-    features.iwlwifi = true;
- 
-    config =
-      ''
-        # Don't include any debug features.
-        DEBUG_KERNEL n
-
-        # Support drivers that need external firmware.
-        STANDALONE n
-
-        # Make /proc/config.gz available.
-        IKCONFIG_PROC y
-
-        # Optimize with -O2, not -Os.
-        CC_OPTIMIZE_FOR_SIZE n
-
-        # Virtualisation (KVM, Xen...).
-        PARAVIRT_GUEST y
-        KVM_CLOCK y
-        KVM_GUEST y
-        XEN n
-
-        # We need 64 GB (PAE) support for Xen guest support.
-        HIGHMEM64G? y
-
-        # Enable the kernel's built-in memory tester.
-        MEMTEST y
-
-        # Include the CFQ I/O scheduler in the kernel, rather than as a
-        # module, so that the initrd gets a good I/O scheduler.
-        IOSCHED_CFQ y
-
-        # Disable some expensive (?) features.
-        MARKERS n
-        KPROBES n
-        NUMA? n
-        PM_TRACE_RTC n
-
-        # Enable various subsystems.
-        ACCESSIBILITY y # Accessibility support
-        AUXDISPLAY y # Auxiliary Display support
-        DONGLE y # Serial dongle support
-        HIPPI y
-        MTD_COMPLEX_MAPPINGS y # needed for many devices
-        NET_POCKET y # enable pocket and portable adapters
-        SCSI_LOWLEVEL y # enable lots of SCSI devices
-        SCSI_LOWLEVEL_PCMCIA y
-        SPI y # needed for many devices
-        SPI_MASTER y
-        WAN y
-
-        # Networking options.
-        IP_PNP n
-        IPV6_PRIVACY y
-        NETFILTER_ADVANCED y
-        IP_VS_PROTO_TCP y
-        IP_VS_PROTO_UDP y
-        IP_VS_PROTO_ESP y
-        IP_VS_PROTO_AH y
-        IP_DCCP_CCID3 n # experimental
-        CLS_U32_PERF y
-        CLS_U32_MARK y
-
-        # Wireless networking.
-        IPW2100_MONITOR y # support promiscuous mode
-        IPW2200_MONITOR y # support promiscuous mode
-        IWLWIFI_LEDS? y
-        IWLWIFI_RFKILL y
-        IWLAGN_SPECTRUM_MEASUREMENT y
-        IWLAGN_LEDS y
-        IWL4965 y # Intel Wireless WiFi 4965AGN
-        IWL5000 y # Intel Wireless WiFi 5000AGN
-        IWL3945_RFKILL y
-        IWL3945_LEDS y
-        HOSTAP_FIRMWARE y # Support downloading firmware images with Host AP driver
-        HOSTAP_FIRMWARE_NVRAM y
-
-        # Some settings to make sure that fbcondecor works - in particular,
-        # disable tileblitting and the drivers that need it.
-
-        # Enable various FB devices.
-        FB_EFI y
-        FB_NVIDIA_I2C y # Enable DDC Support
-        FB_RIVA_I2C y
-        FB_ATY_CT y # Mach64 CT/VT/GT/LT (incl. 3D RAGE) support
-        FB_ATY_GX y # Mach64 GX support
-        FB_SAVAGE_I2C y
-        FB_SAVAGE_ACCEL y
-        FB_SIS_300 y
-        FB_SIS_315 y
-        FB_3DFX_ACCEL y
-        FB_TRIDENT_ACCEL y
-        FB_GEODE y
-
-        # Sound.
-        SND_AC97_POWER_SAVE y # AC97 Power-Saving Mode
-        SND_HDA_INPUT_BEEP y # Support digital beep via input layer
-        SND_USB_CAIAQ_INPUT y
-        PSS_MIXER y # Enable PSS mixer (Beethoven ADSP-16 and other compatible)
-
-        # Enable a bunch of USB storage devices.
-        USB_STORAGE_DATAFAB y
-        USB_STORAGE_FREECOM y
-        USB_STORAGE_ISD200 y
-        USB_STORAGE_USBAT y
-        USB_STORAGE_SDDR09 y
-        USB_STORAGE_SDDR55 y
-        USB_STORAGE_JUMPSHOT y
-        USB_STORAGE_ONETOUCH y
-        USB_STORAGE_KARMA y
-        USB_STORAGE_CYPRESS_ATACB y
-
-        # USB serial devices.
-        USB_SERIAL_GENERIC y # USB Generic Serial Driver
-        USB_SERIAL_KEYSPAN_MPR y # include firmware for various USB serial devices
-        USB_SERIAL_KEYSPAN_USA28 y
-        USB_SERIAL_KEYSPAN_USA28X y
-        USB_SERIAL_KEYSPAN_USA28XA y
-        USB_SERIAL_KEYSPAN_USA28XB y
-        USB_SERIAL_KEYSPAN_USA19 y
-        USB_SERIAL_KEYSPAN_USA18X y
-        USB_SERIAL_KEYSPAN_USA19W y
-        USB_SERIAL_KEYSPAN_USA19QW y
-        USB_SERIAL_KEYSPAN_USA19QI y
-        USB_SERIAL_KEYSPAN_USA49W y
-        USB_SERIAL_KEYSPAN_USA49WLC y
-
-        # Filesystem options - in particular, enable extended attributes and
-        # ACLs for all filesystems that support them.
-        EXT2_FS_XATTR y # Ext2 extended attributes
-        EXT2_FS_POSIX_ACL y # Ext2 POSIX Access Control Lists
-        EXT2_FS_SECURITY y # Ext2 Security Labels
-        EXT2_FS_XIP y # Ext2 execute in place support
-        EXT4_FS_POSIX_ACL y
-        EXT4_FS_SECURITY y
-        REISERFS_FS_XATTR y
-        REISERFS_FS_POSIX_ACL y
-        REISERFS_FS_SECURITY y
-        JFS_POSIX_ACL y
-        JFS_SECURITY y
-        XFS_QUOTA y
-        XFS_POSIX_ACL y
-        XFS_RT y # XFS Realtime subvolume support
-        OCFS2_DEBUG_MASKLOG n
-        UBIFS_FS_XATTR y
-        UBIFS_FS_ADVANCED_COMPR y
-        NFSD_V2_ACL y
-        NFSD_V3 y
-        NFSD_V3_ACL y
-        NFSD_V4 y
-        CIFS_XATTR y
-        CIFS_POSIX y
-
-        # Security related features.
-        STRICT_DEVMEM y # Filter access to /dev/mem
-        SECURITY_SELINUX_BOOTPARAM_VALUE 0 # disable SELinux by default
-
-        # Misc. options.
-        8139TOO_8129 y
-        8139TOO_PIO n # PIO is slower
-        AIC79XX_DEBUG_ENABLE n
-        AIC7XXX_DEBUG_ENABLE n
-        AIC94XX_DEBUG n
-        B43_PCMCIA y
-        BLK_DEV_BSG n
-        BLK_DEV_CMD640_ENHANCED y # CMD640 enhanced support
-        BLK_DEV_IDEACPI y # IDE ACPI support
-        BLK_DEV_INTEGRITY y
-        BLK_DEV_IO_TRACE n
-        BSD_PROCESS_ACCT_V3 y
-        BT_HCIUART_BCSP y
-        BT_HCIUART_H4 y # UART (H4) protocol support
-        BT_HCIUART_LL y
-        BT_RFCOMM_TTY y # RFCOMM TTY support
-        CPU_FREQ_DEBUG n
-        CRASH_DUMP n
-        DMAR? n # experimental
-        FUSION y # Fusion MPT device support
-        IDE_GD_ATAPI y # ATAPI floppy support
-        IRDA_ULTRA y # Ultra (connectionless) protocol
-        JOYSTICK_IFORCE_232 y # I-Force Serial joysticks and wheels
-        JOYSTICK_IFORCE_USB y # I-Force USB joysticks and wheels
-        JOYSTICK_XPAD_FF y # X-Box gamepad rumble support
-        JOYSTICK_XPAD_LEDS y # LED Support for Xbox360 controller 'BigX' LED
-        KALLSYMS_EXTRA_PASS n
-        LDM_PARTITION y # Windows Logical Disk Manager (Dynamic Disk) support
-        LEDS_TRIGGER_IDE_DISK y # LED IDE Disk Trigger
-        LOGIRUMBLEPAD2_FF y # Logitech Rumblepad 2 force feedback
-        LOGO n # not needed
-        MEDIA_ATTACH y
-        MEGARAID_NEWGEN y
-        MICROCODE_AMD y
-        MODVERSIONS y
-        MOUSE_PS2_ELANTECH y # Elantech PS/2 protocol extension
-        MTRR_SANITIZER y
-        NET_FC y # Fibre Channel driver support
-        PCI_LEGACY y
-        PPP_MULTILINK y # PPP multilink support
-        REGULATOR y # Voltage and Current Regulator Support
-        SCSI_LOGGING y # SCSI logging facility
-        SERIAL_8250 y # 8250/16550 and compatible serial support
-        SLIP_COMPRESSED y # CSLIP compressed headers
-        SLIP_SMART y
-        THERMAL_HWMON y # Hardware monitoring support
-        USB_DEBUG n
-        USB_EHCI_ROOT_HUB_TT y # Root Hub Transaction Translators
-        X86_CHECK_BIOS_CORRUPTION y
-        X86_MCE y
-
-        ${extraConfig}
-      '';
-  }
-
-  // args
-)
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.29.nix b/pkgs/os-specific/linux/kernel/linux-2.6.29.nix
deleted file mode 100644
index 99354c23045d6..0000000000000
--- a/pkgs/os-specific/linux/kernel/linux-2.6.29.nix
+++ /dev/null
@@ -1,230 +0,0 @@
-args @ { stdenv, fetchurl, userModeLinux ? false, extraConfig ? "", ... }:
-
-import ./generic.nix (
-
-  rec {
-    version = "2.6.29.6";
-  
-    src = fetchurl {
-      url = "mirror://kernel/linux/kernel/v2.6/linux-${version}.tar.bz2";
-      sha256 = "1yf5xhdnpcyhw4y78v35wyidlsyzxvbbnzw6jd31zni7ira6jvjk";
-    };
-
-    features.iwlwifi = true;
- 
-    config =
-      ''
-        # Don't include any debug features.
-        DEBUG_KERNEL n
-
-        # Support drivers that need external firmware.
-        STANDALONE n
-
-        # Make /proc/config.gz available.
-        IKCONFIG_PROC y
-
-        # Optimize with -O2, not -Os.
-        CC_OPTIMIZE_FOR_SIZE n
-
-        # Virtualisation (KVM, Xen...).
-        PARAVIRT_GUEST y
-        KVM_CLOCK y
-        KVM_GUEST y
-        XEN n
-
-        # We need 64 GB (PAE) support for Xen guest support.
-        HIGHMEM64G? y
-
-        # Enable the kernel's built-in memory tester.
-        MEMTEST y
-
-        # Include the CFQ I/O scheduler in the kernel, rather than as a
-        # module, so that the initrd gets a good I/O scheduler.
-        IOSCHED_CFQ y
-
-        # Disable some expensive (?) features.
-        MARKERS n
-        KPROBES n
-        NUMA? n
-        PM_TRACE_RTC n
-
-        # Enable various subsystems.
-        ACCESSIBILITY y # Accessibility support
-        AUXDISPLAY y # Auxiliary Display support
-        DONGLE y # Serial dongle support
-        HIPPI y
-        MTD_COMPLEX_MAPPINGS y # needed for many devices
-        NET_POCKET y # enable pocket and portable adapters
-        SCSI_LOWLEVEL y # enable lots of SCSI devices
-        SCSI_LOWLEVEL_PCMCIA y
-        SPI y # needed for many devices
-        SPI_MASTER y
-        WAN y
-
-        # Networking options.
-        IP_PNP n
-        IPV6_PRIVACY y
-        NETFILTER_ADVANCED y
-        IP_VS_PROTO_TCP y
-        IP_VS_PROTO_UDP y
-        IP_VS_PROTO_ESP y
-        IP_VS_PROTO_AH y
-        IP_DCCP_CCID3 n # experimental
-        CLS_U32_PERF y
-        CLS_U32_MARK y
-
-        # Wireless networking.
-        IPW2100_MONITOR y # support promiscuous mode
-        IPW2200_MONITOR y # support promiscuous mode
-        IWLWIFI_LEDS? y
-        IWLWIFI_RFKILL y
-        IWLAGN_SPECTRUM_MEASUREMENT y
-        IWLAGN_LEDS y
-        IWL4965 y # Intel Wireless WiFi 4965AGN
-        IWL5000 y # Intel Wireless WiFi 5000AGN
-        IWL3945_RFKILL y
-        IWL3945_LEDS y
-        HOSTAP_FIRMWARE y # Support downloading firmware images with Host AP driver
-        HOSTAP_FIRMWARE_NVRAM y
-
-        # Some settings to make sure that fbcondecor works - in particular,
-        # disable tileblitting and the drivers that need it.
-
-        # Enable various FB devices.
-        FB_EFI y
-        FB_NVIDIA_I2C y # Enable DDC Support
-        FB_RIVA_I2C y
-        FB_ATY_CT y # Mach64 CT/VT/GT/LT (incl. 3D RAGE) support
-        FB_ATY_GX y # Mach64 GX support
-        FB_SAVAGE_I2C y
-        FB_SAVAGE_ACCEL y
-        FB_SIS_300 y
-        FB_SIS_315 y
-        FB_3DFX_ACCEL y
-        FB_TRIDENT_ACCEL y
-        FB_GEODE y
-
-        # Sound.
-        SND_AC97_POWER_SAVE y # AC97 Power-Saving Mode
-        SND_HDA_INPUT_BEEP y # Support digital beep via input layer
-        SND_USB_CAIAQ_INPUT y
-        PSS_MIXER y # Enable PSS mixer (Beethoven ADSP-16 and other compatible)
-
-        # Enable a bunch of USB storage devices.
-        USB_STORAGE_DATAFAB y
-        USB_STORAGE_FREECOM y
-        USB_STORAGE_ISD200 y
-        USB_STORAGE_USBAT y
-        USB_STORAGE_SDDR09 y
-        USB_STORAGE_SDDR55 y
-        USB_STORAGE_JUMPSHOT y
-        USB_STORAGE_ONETOUCH y
-        USB_STORAGE_KARMA y
-        USB_STORAGE_CYPRESS_ATACB y
-
-        # USB serial devices.
-        USB_SERIAL_GENERIC y # USB Generic Serial Driver
-        USB_SERIAL_KEYSPAN_MPR y # include firmware for various USB serial devices
-        USB_SERIAL_KEYSPAN_USA28 y
-        USB_SERIAL_KEYSPAN_USA28X y
-        USB_SERIAL_KEYSPAN_USA28XA y
-        USB_SERIAL_KEYSPAN_USA28XB y
-        USB_SERIAL_KEYSPAN_USA19 y
-        USB_SERIAL_KEYSPAN_USA18X y
-        USB_SERIAL_KEYSPAN_USA19W y
-        USB_SERIAL_KEYSPAN_USA19QW y
-        USB_SERIAL_KEYSPAN_USA19QI y
-        USB_SERIAL_KEYSPAN_USA49W y
-        USB_SERIAL_KEYSPAN_USA49WLC y
-
-        # Filesystem options - in particular, enable extended attributes and
-        # ACLs for all filesystems that support them.
-        EXT2_FS_XATTR y # Ext2 extended attributes
-        EXT2_FS_POSIX_ACL y # Ext2 POSIX Access Control Lists
-        EXT2_FS_SECURITY y # Ext2 Security Labels
-        EXT2_FS_XIP y # Ext2 execute in place support
-        EXT4_FS_POSIX_ACL y
-        EXT4_FS_SECURITY y
-        REISERFS_FS_XATTR y
-        REISERFS_FS_POSIX_ACL y
-        REISERFS_FS_SECURITY y
-        JFS_POSIX_ACL y
-        JFS_SECURITY y
-        XFS_QUOTA y
-        XFS_POSIX_ACL y
-        XFS_RT y # XFS Realtime subvolume support
-        OCFS2_DEBUG_MASKLOG n
-        OCFS2_FS_POSIX_ACL y
-        BTRFS_FS_POSIX_ACL y
-        UBIFS_FS_XATTR y
-        UBIFS_FS_ADVANCED_COMPR y
-        NFSD_V2_ACL y
-        NFSD_V3 y
-        NFSD_V3_ACL y
-        NFSD_V4 y
-        CIFS_XATTR y
-        CIFS_POSIX y
-
-        # Security related features.
-        STRICT_DEVMEM y # Filter access to /dev/mem
-        SECURITY_SELINUX_BOOTPARAM_VALUE 0 # disable SELinux by default
-
-        # Misc. options.
-        8139TOO_8129 y
-        8139TOO_PIO n # PIO is slower
-        AIC79XX_DEBUG_ENABLE n
-        AIC7XXX_DEBUG_ENABLE n
-        AIC94XX_DEBUG n
-        B43_PCMCIA y
-        BLK_DEV_BSG n
-        BLK_DEV_CMD640_ENHANCED y # CMD640 enhanced support
-        BLK_DEV_IDEACPI y # IDE ACPI support
-        BLK_DEV_INTEGRITY y
-        BLK_DEV_IO_TRACE n
-        BSD_PROCESS_ACCT_V3 y
-        BT_HCIUART_BCSP y
-        BT_HCIUART_H4 y # UART (H4) protocol support
-        BT_HCIUART_LL y
-        BT_RFCOMM_TTY y # RFCOMM TTY support
-        CPU_FREQ_DEBUG n
-        CRASH_DUMP n
-        DMAR? n # experimental
-        DVB_DYNAMIC_MINORS y # we use udev
-        FUSION y # Fusion MPT device support
-        IDE_GD_ATAPI y # ATAPI floppy support
-        IRDA_ULTRA y # Ultra (connectionless) protocol
-        JOYSTICK_IFORCE_232 y # I-Force Serial joysticks and wheels
-        JOYSTICK_IFORCE_USB y # I-Force USB joysticks and wheels
-        JOYSTICK_XPAD_FF y # X-Box gamepad rumble support
-        JOYSTICK_XPAD_LEDS y # LED Support for Xbox360 controller 'BigX' LED
-        KALLSYMS_EXTRA_PASS n
-        LDM_PARTITION y # Windows Logical Disk Manager (Dynamic Disk) support
-        LEDS_TRIGGER_IDE_DISK y # LED IDE Disk Trigger
-        LOGIRUMBLEPAD2_FF y # Logitech Rumblepad 2 force feedback
-        LOGO n # not needed
-        MEDIA_ATTACH y
-        MEGARAID_NEWGEN y
-        MICROCODE_AMD y
-        MODVERSIONS y
-        MOUSE_PS2_ELANTECH y # Elantech PS/2 protocol extension
-        MTRR_SANITIZER y
-        NET_FC y # Fibre Channel driver support
-        PCI_LEGACY y
-        PPP_MULTILINK y # PPP multilink support
-        REGULATOR y # Voltage and Current Regulator Support
-        SCSI_LOGGING y # SCSI logging facility
-        SERIAL_8250 y # 8250/16550 and compatible serial support
-        SLIP_COMPRESSED y # CSLIP compressed headers
-        SLIP_SMART y
-        THERMAL_HWMON y # Hardware monitoring support
-        USB_DEBUG n
-        USB_EHCI_ROOT_HUB_TT y # Root Hub Transaction Translators
-        X86_CHECK_BIOS_CORRUPTION y
-        X86_MCE y
-
-        ${extraConfig}
-      '';
-  }
-
-  // args
-)
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.31.nix b/pkgs/os-specific/linux/kernel/linux-2.6.31.nix
deleted file mode 100644
index 523f3c9ceb5cb..0000000000000
--- a/pkgs/os-specific/linux/kernel/linux-2.6.31.nix
+++ /dev/null
@@ -1,214 +0,0 @@
-{ stdenv, fetchurl, extraConfig ? "", ... } @ args:
-
-let
-  configWithPlatform = kernelPlatform:
-    ''
-      # Don't include any debug features.
-      DEBUG_KERNEL n
-
-      # Support drivers that need external firmware.
-      STANDALONE n
-
-      # Make /proc/config.gz available.
-      IKCONFIG_PROC y
-
-      # Optimize with -O2, not -Os.
-      CC_OPTIMIZE_FOR_SIZE n
-
-      # Enable the kernel's built-in memory tester.
-      MEMTEST y
-
-      # Include the CFQ I/O scheduler in the kernel, rather than as a
-      # module, so that the initrd gets a good I/O scheduler.
-      IOSCHED_CFQ y
-
-      # Disable some expensive (?) features.
-      FTRACE n
-      KPROBES n
-      NUMA? n
-      PM_TRACE_RTC n
-
-      # Enable various subsystems.
-      ACCESSIBILITY y # Accessibility support
-      AUXDISPLAY y # Auxiliary Display support
-      DONGLE y # Serial dongle support
-      HIPPI y
-      MTD_COMPLEX_MAPPINGS y # needed for many devices
-      NET_POCKET y # enable pocket and portable adapters
-      SCSI_LOWLEVEL y # enable lots of SCSI devices
-      SCSI_LOWLEVEL_PCMCIA y
-      SPI y # needed for many devices
-      SPI_MASTER y
-      WAN y
-
-      # Networking options.
-      IP_PNP n
-      IPV6_PRIVACY y
-      NETFILTER_ADVANCED y
-      IP_VS_PROTO_TCP y
-      IP_VS_PROTO_UDP y
-      IP_VS_PROTO_ESP y
-      IP_VS_PROTO_AH y
-      IP_DCCP_CCID3 n # experimental
-      CLS_U32_PERF y
-      CLS_U32_MARK y
-
-      # Wireless networking.
-      IPW2100_MONITOR y # support promiscuous mode
-      IPW2200_MONITOR y # support promiscuous mode
-      IWLWIFI_LEDS? y
-      IWLWIFI_SPECTRUM_MEASUREMENT y
-      IWL3945_SPECTRUM_MEASUREMENT y
-      IWL4965 y # Intel Wireless WiFi 4965AGN
-      IWL5000 y # Intel Wireless WiFi 5000AGN
-      HOSTAP_FIRMWARE y # Support downloading firmware images with Host AP driver
-      HOSTAP_FIRMWARE_NVRAM y
-
-      # Some settings to make sure that fbcondecor works - in particular,
-      # disable tileblitting and the drivers that need it.
-
-      # Enable various FB devices.
-      FB y
-      FB_EFI y
-      FB_NVIDIA_I2C y # Enable DDC Support
-      FB_RIVA_I2C y
-      FB_ATY_CT y # Mach64 CT/VT/GT/LT (incl. 3D RAGE) support
-      FB_ATY_GX y # Mach64 GX support
-      FB_SAVAGE_I2C y
-      FB_SAVAGE_ACCEL y
-      FB_SIS_300 y
-      FB_SIS_315 y
-      FB_3DFX_ACCEL y
-      FB_GEODE y
-
-      # Video configuration
-      # The intel drivers already require KMS
-      DRM_I915_KMS y
-
-      # Sound.
-      SND_AC97_POWER_SAVE y # AC97 Power-Saving Mode
-      SND_HDA_INPUT_BEEP y # Support digital beep via input layer
-      SND_USB_CAIAQ_INPUT y
-      PSS_MIXER y # Enable PSS mixer (Beethoven ADSP-16 and other compatible)
-
-      # USB serial devices.
-      USB_SERIAL_GENERIC y # USB Generic Serial Driver
-      USB_SERIAL_KEYSPAN_MPR y # include firmware for various USB serial devices
-      USB_SERIAL_KEYSPAN_USA28 y
-      USB_SERIAL_KEYSPAN_USA28X y
-      USB_SERIAL_KEYSPAN_USA28XA y
-      USB_SERIAL_KEYSPAN_USA28XB y
-      USB_SERIAL_KEYSPAN_USA19 y
-      USB_SERIAL_KEYSPAN_USA18X y
-      USB_SERIAL_KEYSPAN_USA19W y
-      USB_SERIAL_KEYSPAN_USA19QW y
-      USB_SERIAL_KEYSPAN_USA19QI y
-      USB_SERIAL_KEYSPAN_USA49W y
-      USB_SERIAL_KEYSPAN_USA49WLC y
-
-      # Filesystem options - in particular, enable extended attributes and
-      # ACLs for all filesystems that support them.
-      EXT2_FS_XATTR y # Ext2 extended attributes
-      EXT2_FS_POSIX_ACL y # Ext2 POSIX Access Control Lists
-      EXT2_FS_SECURITY y # Ext2 Security Labels
-      EXT2_FS_XIP y # Ext2 execute in place support
-      EXT4_FS_POSIX_ACL y
-      EXT4_FS_SECURITY y
-      REISERFS_FS_XATTR y
-      REISERFS_FS_POSIX_ACL y
-      REISERFS_FS_SECURITY y
-      JFS_POSIX_ACL y
-      JFS_SECURITY y
-      XFS_QUOTA y
-      XFS_POSIX_ACL y
-      XFS_RT y # XFS Realtime subvolume support
-      OCFS2_DEBUG_MASKLOG n
-      OCFS2_FS_POSIX_ACL y
-      BTRFS_FS_POSIX_ACL y
-      UBIFS_FS_XATTR y
-      UBIFS_FS_ADVANCED_COMPR y
-      NFSD_V2_ACL y
-      NFSD_V3 y
-      NFSD_V3_ACL y
-      NFSD_V4 y
-      CIFS_XATTR y
-      CIFS_POSIX y
-
-      # Security related features.
-      STRICT_DEVMEM y # Filter access to /dev/mem
-      SECURITY_SELINUX_BOOTPARAM_VALUE 0 # disable SELinux by default
-
-      # Misc. options.
-      8139TOO_8129 y
-      8139TOO_PIO n # PIO is slower
-      AIC79XX_DEBUG_ENABLE n
-      AIC7XXX_DEBUG_ENABLE n
-      AIC94XX_DEBUG n
-      B43_PCMCIA y
-      BLK_DEV_BSG n
-      BLK_DEV_CMD640_ENHANCED y # CMD640 enhanced support
-      BLK_DEV_IDEACPI y # IDE ACPI support
-      BLK_DEV_INTEGRITY y
-      BSD_PROCESS_ACCT_V3 y
-      BT_HCIUART_BCSP y
-      BT_HCIUART_H4 y # UART (H4) protocol support
-      BT_HCIUART_LL y
-      BT_RFCOMM_TTY y # RFCOMM TTY support
-      CPU_FREQ_DEBUG n
-      CRASH_DUMP n
-      DMAR? n # experimental
-      DVB_DYNAMIC_MINORS y # we use udev
-      FUSION y # Fusion MPT device support
-      IDE_GD_ATAPI y # ATAPI floppy support
-      IRDA_ULTRA y # Ultra (connectionless) protocol
-      JOYSTICK_IFORCE_232 y # I-Force Serial joysticks and wheels
-      JOYSTICK_IFORCE_USB y # I-Force USB joysticks and wheels
-      JOYSTICK_XPAD_FF y # X-Box gamepad rumble support
-      JOYSTICK_XPAD_LEDS y # LED Support for Xbox360 controller 'BigX' LED
-      KALLSYMS_EXTRA_PASS n
-      LDM_PARTITION y # Windows Logical Disk Manager (Dynamic Disk) support
-      LEDS_TRIGGER_IDE_DISK y # LED IDE Disk Trigger
-      LOGIRUMBLEPAD2_FF y # Logitech Rumblepad 2 force feedback
-      LOGO n # not needed
-      MEDIA_ATTACH y
-      MEGARAID_NEWGEN y
-      MICROCODE_AMD y
-      MODVERSIONS y
-      MOUSE_PS2_ELANTECH y # Elantech PS/2 protocol extension
-      MTRR_SANITIZER y
-      NET_FC y # Fibre Channel driver support
-      PCI_LEGACY y
-      PPP_MULTILINK y # PPP multilink support
-      REGULATOR y # Voltage and Current Regulator Support
-      SCSI_LOGGING y # SCSI logging facility
-      SERIAL_8250 y # 8250/16550 and compatible serial support
-      SLIP_COMPRESSED y # CSLIP compressed headers
-      SLIP_SMART y
-      THERMAL_HWMON y # Hardware monitoring support
-      USB_DEBUG n
-      USB_EHCI_ROOT_HUB_TT y # Root Hub Transaction Translators
-      X86_CHECK_BIOS_CORRUPTION y
-      X86_MCE y
-
-      ${extraConfig}
-    '';
-in
-
-import ./generic.nix (
-
-  rec {
-    version = "2.6.31.14";
-
-    src = fetchurl {
-      url = "mirror://kernel/linux/kernel/v2.6/linux-${version}.tar.bz2";
-      sha256 = "1c6ivcjgns4gbx04mhnhndqikm3prqhhfm2a5zrb1mfyvvishqpp";
-    };
-
-    config = configWithPlatform stdenv.platform;
-    configCross = configWithPlatform stdenv.cross.platform;
-
-    features.iwlwifi = true;
-  }
-
-  // removeAttrs args ["extraConfig"]
-)
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.32.nix b/pkgs/os-specific/linux/kernel/linux-2.6.32.nix
index d47ad8f65ce65..a7cb499a9931b 100644
--- a/pkgs/os-specific/linux/kernel/linux-2.6.32.nix
+++ b/pkgs/os-specific/linux/kernel/linux-2.6.32.nix
@@ -198,11 +198,11 @@ in
 import ./generic.nix (
 
   rec {
-    version = "2.6.32.52";
+    version = "2.6.32.57";
   
     src = fetchurl {
       url = "mirror://kernel/linux/kernel/v2.6/longterm/v2.6.32/linux-${version}.tar.bz2";
-      sha256 = "0a3ws6m8942p972jjlixr5v0sh6ll0hlzxwdikb666nppjcgqiz7";
+      sha256 = "1pbwjdignv5qdzpiv3ijs5g95l86ss7jrslak12jfxly13lanzzh";
     };
 
     config = configWithPlatform stdenv.platform;
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.33.nix b/pkgs/os-specific/linux/kernel/linux-2.6.33.nix
deleted file mode 100644
index e473faa16a80d..0000000000000
--- a/pkgs/os-specific/linux/kernel/linux-2.6.33.nix
+++ /dev/null
@@ -1,214 +0,0 @@
-args @ { stdenv, fetchurl, userModeLinux ? false, extraConfig ? ""
-, ... }:
-
-let
-  configWithPlatform = kernelPlatform :
-    ''
-      # Don't include any debug features.
-      DEBUG_KERNEL n
-
-      # Support drivers that need external firmware.
-      STANDALONE n
-
-      # Make /proc/config.gz available.
-      IKCONFIG_PROC y
-
-      # Optimize with -O2, not -Os.
-      CC_OPTIMIZE_FOR_SIZE n
-
-      # Enable the kernel's built-in memory tester.
-      MEMTEST y
-
-      # Include the CFQ I/O scheduler in the kernel, rather than as a
-      # module, so that the initrd gets a good I/O scheduler.
-      IOSCHED_CFQ y
-
-      # Disable some expensive (?) features.
-      FTRACE n
-      KPROBES n
-      NUMA? n
-      PM_TRACE_RTC n
-
-      # Enable various subsystems.
-      ACCESSIBILITY y # Accessibility support
-      AUXDISPLAY y # Auxiliary Display support
-      DONGLE y # Serial dongle support
-      HIPPI y
-      MTD_COMPLEX_MAPPINGS y # needed for many devices
-      NET_POCKET y # enable pocket and portable adapters
-      SCSI_LOWLEVEL y # enable lots of SCSI devices
-      SCSI_LOWLEVEL_PCMCIA y
-      SPI y # needed for many devices
-      SPI_MASTER y
-      WAN y
-
-      # Networking options.
-      IP_PNP n
-      IPV6_PRIVACY y
-      NETFILTER_ADVANCED y
-      IP_VS_PROTO_TCP y
-      IP_VS_PROTO_UDP y
-      IP_VS_PROTO_ESP y
-      IP_VS_PROTO_AH y
-      IP_DCCP_CCID3 n # experimental
-      CLS_U32_PERF y
-      CLS_U32_MARK y
-
-      # Wireless networking.
-      IPW2100_MONITOR y # support promiscuous mode
-      IPW2200_MONITOR y # support promiscuous mode
-      IWLWIFI_SPECTRUM_MEASUREMENT y
-      IWL3945_SPECTRUM_MEASUREMENT y
-      IWL4965 y # Intel Wireless WiFi 4965AGN
-      IWL5000 y # Intel Wireless WiFi 5000AGN
-      HOSTAP_FIRMWARE y # Support downloading firmware images with Host AP driver
-      HOSTAP_FIRMWARE_NVRAM y
-
-      # Some settings to make sure that fbcondecor works - in particular,
-      # disable tileblitting and the drivers that need it.
-
-      # Enable various FB devices.
-      FB y
-      FB_EFI y
-      FB_NVIDIA_I2C y # Enable DDC Support
-      FB_RIVA_I2C y
-      FB_ATY_CT y # Mach64 CT/VT/GT/LT (incl. 3D RAGE) support
-      FB_ATY_GX y # Mach64 GX support
-      FB_SAVAGE_I2C y
-      FB_SAVAGE_ACCEL y
-      FB_SIS_300 y
-      FB_SIS_315 y
-      FB_3DFX_ACCEL y
-      FB_GEODE y
-
-      # Video configuration
-      # The intel drivers already require KMS
-      DRM_I915_KMS y
-
-      # Sound.
-      SND_AC97_POWER_SAVE y # AC97 Power-Saving Mode
-      SND_HDA_INPUT_BEEP y # Support digital beep via input layer
-      SND_USB_CAIAQ_INPUT y
-      PSS_MIXER y # Enable PSS mixer (Beethoven ADSP-16 and other compatible)
-
-      # USB serial devices.
-      USB_SERIAL_GENERIC y # USB Generic Serial Driver
-      USB_SERIAL_KEYSPAN_MPR y # include firmware for various USB serial devices
-      USB_SERIAL_KEYSPAN_USA28 y
-      USB_SERIAL_KEYSPAN_USA28X y
-      USB_SERIAL_KEYSPAN_USA28XA y
-      USB_SERIAL_KEYSPAN_USA28XB y
-      USB_SERIAL_KEYSPAN_USA19 y
-      USB_SERIAL_KEYSPAN_USA18X y
-      USB_SERIAL_KEYSPAN_USA19W y
-      USB_SERIAL_KEYSPAN_USA19QW y
-      USB_SERIAL_KEYSPAN_USA19QI y
-      USB_SERIAL_KEYSPAN_USA49W y
-      USB_SERIAL_KEYSPAN_USA49WLC y
-
-      # Filesystem options - in particular, enable extended attributes and
-      # ACLs for all filesystems that support them.
-      EXT2_FS_XATTR y # Ext2 extended attributes
-      EXT2_FS_POSIX_ACL y # Ext2 POSIX Access Control Lists
-      EXT2_FS_SECURITY y # Ext2 Security Labels
-      EXT2_FS_XIP y # Ext2 execute in place support
-      EXT4_FS_POSIX_ACL y
-      EXT4_FS_SECURITY y
-      REISERFS_FS_XATTR y
-      REISERFS_FS_POSIX_ACL y
-      REISERFS_FS_SECURITY y
-      JFS_POSIX_ACL y
-      JFS_SECURITY y
-      XFS_QUOTA y
-      XFS_POSIX_ACL y
-      XFS_RT y # XFS Realtime subvolume support
-      OCFS2_DEBUG_MASKLOG n
-      BTRFS_FS_POSIX_ACL y
-      UBIFS_FS_XATTR y
-      UBIFS_FS_ADVANCED_COMPR y
-      NFSD_V2_ACL y
-      NFSD_V3 y
-      NFSD_V3_ACL y
-      NFSD_V4 y
-      CIFS_XATTR y
-      CIFS_POSIX y
-
-      # Security related features.
-      STRICT_DEVMEM y # Filter access to /dev/mem
-      SECURITY_SELINUX_BOOTPARAM_VALUE 0 # disable SELinux by default
-
-      # Misc. options.
-      8139TOO_8129 y
-      8139TOO_PIO n # PIO is slower
-      AIC79XX_DEBUG_ENABLE n
-      AIC7XXX_DEBUG_ENABLE n
-      AIC94XX_DEBUG n
-      B43_PCMCIA y
-      BLK_DEV_BSG n
-      BLK_DEV_CMD640_ENHANCED y # CMD640 enhanced support
-      BLK_DEV_IDEACPI y # IDE ACPI support
-      BLK_DEV_INTEGRITY y
-      BSD_PROCESS_ACCT_V3 y
-      BT_HCIUART_BCSP y
-      BT_HCIUART_H4 y # UART (H4) protocol support
-      BT_HCIUART_LL y
-      BT_RFCOMM_TTY y # RFCOMM TTY support
-      CPU_FREQ_DEBUG n
-      CRASH_DUMP n
-      DMAR? n # experimental
-      DVB_DYNAMIC_MINORS y # we use udev
-      FUSION y # Fusion MPT device support
-      IDE_GD_ATAPI y # ATAPI floppy support
-      IRDA_ULTRA y # Ultra (connectionless) protocol
-      JOYSTICK_IFORCE_232 y # I-Force Serial joysticks and wheels
-      JOYSTICK_IFORCE_USB y # I-Force USB joysticks and wheels
-      JOYSTICK_XPAD_FF y # X-Box gamepad rumble support
-      JOYSTICK_XPAD_LEDS y # LED Support for Xbox360 controller 'BigX' LED
-      KALLSYMS_EXTRA_PASS n
-      LDM_PARTITION y # Windows Logical Disk Manager (Dynamic Disk) support
-      LEDS_TRIGGER_IDE_DISK y # LED IDE Disk Trigger
-      LOGIRUMBLEPAD2_FF y # Logitech Rumblepad 2 force feedback
-      LOGO n # not needed
-      MEDIA_ATTACH y
-      MEGARAID_NEWGEN y
-      MICROCODE_AMD y
-      MODVERSIONS y
-      MOUSE_PS2_ELANTECH y # Elantech PS/2 protocol extension
-      MTRR_SANITIZER y
-      NET_FC y # Fibre Channel driver support
-      PCI_LEGACY y
-      PPP_MULTILINK y # PPP multilink support
-      REGULATOR y # Voltage and Current Regulator Support
-      SCSI_LOGGING y # SCSI logging facility
-      SERIAL_8250 y # 8250/16550 and compatible serial support
-      SLIP_COMPRESSED y # CSLIP compressed headers
-      SLIP_SMART y
-      THERMAL_HWMON y # Hardware monitoring support
-      USB_DEBUG n
-      USB_EHCI_ROOT_HUB_TT y # Root Hub Transaction Translators
-      X86_CHECK_BIOS_CORRUPTION y
-      X86_MCE y
-
-      ${if kernelPlatform ? kernelExtraConfig then kernelPlatform.kernelExtraConfig else ""}
-      ${extraConfig}
-    '';
-in
-
-import ./generic.nix (
-
-  rec {
-    version = "2.6.33.17";
-  
-    src = fetchurl {
-      url = "mirror://kernel/linux/kernel/v2.6/longterm/v2.6.33/linux-${version}.tar.bz2";
-      sha256 = "06z6r2jip781bxvrfc12gkckzig9s65pnhb3cg2c7c637phc6ky0";
-    };
-
-    config = configWithPlatform stdenv.platform;
-    configCross = configWithPlatform stdenv.cross.platform;
-
-    features.iwlwifi = true;
-  }
-
-  // removeAttrs args ["extraConfig"]
-)
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.34.nix b/pkgs/os-specific/linux/kernel/linux-2.6.34.nix
deleted file mode 100644
index d36a76864833c..0000000000000
--- a/pkgs/os-specific/linux/kernel/linux-2.6.34.nix
+++ /dev/null
@@ -1,211 +0,0 @@
-args @ { stdenv, fetchurl, userModeLinux ? false, extraConfig ? ""
-, ... }:
-
-let
-  configWithPlatform = kernelPlatform :
-    ''
-      # Don't include any debug features.
-      DEBUG_KERNEL n
-
-      # Support drivers that need external firmware.
-      STANDALONE n
-
-      # Make /proc/config.gz available.
-      IKCONFIG_PROC y
-
-      # Optimize with -O2, not -Os.
-      CC_OPTIMIZE_FOR_SIZE n
-
-      # Enable the kernel's built-in memory tester.
-      MEMTEST y
-
-      # Include the CFQ I/O scheduler in the kernel, rather than as a
-      # module, so that the initrd gets a good I/O scheduler.
-      IOSCHED_CFQ y
-
-      # Disable some expensive (?) features.
-      FTRACE n
-      KPROBES n
-      NUMA? n
-      PM_TRACE_RTC n
-
-      # Enable various subsystems.
-      ACCESSIBILITY y # Accessibility support
-      AUXDISPLAY y # Auxiliary Display support
-      DONGLE y # Serial dongle support
-      HIPPI y
-      MTD_COMPLEX_MAPPINGS y # needed for many devices
-      NET_POCKET y # enable pocket and portable adapters
-      SCSI_LOWLEVEL y # enable lots of SCSI devices
-      SCSI_LOWLEVEL_PCMCIA y
-      SPI y # needed for many devices
-      SPI_MASTER y
-      WAN y
-
-      # Networking options.
-      IP_PNP n
-      IPV6_PRIVACY y
-      NETFILTER_ADVANCED y
-      IP_VS_PROTO_TCP y
-      IP_VS_PROTO_UDP y
-      IP_VS_PROTO_ESP y
-      IP_VS_PROTO_AH y
-      IP_DCCP_CCID3 n # experimental
-      CLS_U32_PERF y
-      CLS_U32_MARK y
-
-      # Wireless networking.
-      IPW2100_MONITOR y # support promiscuous mode
-      IPW2200_MONITOR y # support promiscuous mode
-      IWL4965 y # Intel Wireless WiFi 4965AGN
-      IWL5000 y # Intel Wireless WiFi 5000AGN
-      HOSTAP_FIRMWARE y # Support downloading firmware images with Host AP driver
-      HOSTAP_FIRMWARE_NVRAM y
-
-      # Some settings to make sure that fbcondecor works - in particular,
-      # disable tileblitting and the drivers that need it.
-
-      # Enable various FB devices.
-      FB y
-      FB_EFI y
-      FB_NVIDIA_I2C y # Enable DDC Support
-      FB_RIVA_I2C y
-      FB_ATY_CT y # Mach64 CT/VT/GT/LT (incl. 3D RAGE) support
-      FB_ATY_GX y # Mach64 GX support
-      FB_SAVAGE_I2C y
-      FB_SAVAGE_ACCEL y
-      FB_SIS_300 y
-      FB_SIS_315 y
-      FB_3DFX_ACCEL y
-      FB_GEODE y
-
-      # Video configuration
-      # The intel drivers already require KMS
-      DRM_I915_KMS y
-
-      # Sound.
-      SND_AC97_POWER_SAVE y # AC97 Power-Saving Mode
-      SND_HDA_INPUT_BEEP y # Support digital beep via input layer
-      SND_USB_CAIAQ_INPUT y
-      PSS_MIXER y # Enable PSS mixer (Beethoven ADSP-16 and other compatible)
-
-      # USB serial devices.
-      USB_SERIAL_GENERIC y # USB Generic Serial Driver
-      USB_SERIAL_KEYSPAN_MPR y # include firmware for various USB serial devices
-      USB_SERIAL_KEYSPAN_USA28 y
-      USB_SERIAL_KEYSPAN_USA28X y
-      USB_SERIAL_KEYSPAN_USA28XA y
-      USB_SERIAL_KEYSPAN_USA28XB y
-      USB_SERIAL_KEYSPAN_USA19 y
-      USB_SERIAL_KEYSPAN_USA18X y
-      USB_SERIAL_KEYSPAN_USA19W y
-      USB_SERIAL_KEYSPAN_USA19QW y
-      USB_SERIAL_KEYSPAN_USA19QI y
-      USB_SERIAL_KEYSPAN_USA49W y
-      USB_SERIAL_KEYSPAN_USA49WLC y
-
-      # Filesystem options - in particular, enable extended attributes and
-      # ACLs for all filesystems that support them.
-      EXT2_FS_XATTR y # Ext2 extended attributes
-      EXT2_FS_POSIX_ACL y # Ext2 POSIX Access Control Lists
-      EXT2_FS_SECURITY y # Ext2 Security Labels
-      EXT2_FS_XIP y # Ext2 execute in place support
-      EXT4_FS_POSIX_ACL y
-      EXT4_FS_SECURITY y
-      REISERFS_FS_XATTR y
-      REISERFS_FS_POSIX_ACL y
-      REISERFS_FS_SECURITY y
-      JFS_POSIX_ACL y
-      JFS_SECURITY y
-      XFS_QUOTA y
-      XFS_POSIX_ACL y
-      XFS_RT y # XFS Realtime subvolume support
-      OCFS2_DEBUG_MASKLOG n
-      BTRFS_FS_POSIX_ACL y
-      UBIFS_FS_XATTR y
-      UBIFS_FS_ADVANCED_COMPR y
-      NFSD_V2_ACL y
-      NFSD_V3 y
-      NFSD_V3_ACL y
-      NFSD_V4 y
-      CIFS_XATTR y
-      CIFS_POSIX y
-
-      # Security related features.
-      STRICT_DEVMEM y # Filter access to /dev/mem
-      SECURITY_SELINUX_BOOTPARAM_VALUE 0 # disable SELinux by default
-
-      # Misc. options.
-      8139TOO_8129 y
-      8139TOO_PIO n # PIO is slower
-      AIC79XX_DEBUG_ENABLE n
-      AIC7XXX_DEBUG_ENABLE n
-      AIC94XX_DEBUG n
-      B43_PCMCIA y
-      BLK_DEV_BSG n
-      BLK_DEV_CMD640_ENHANCED y # CMD640 enhanced support
-      BLK_DEV_IDEACPI y # IDE ACPI support
-      BLK_DEV_INTEGRITY y
-      BSD_PROCESS_ACCT_V3 y
-      BT_HCIUART_BCSP y
-      BT_HCIUART_H4 y # UART (H4) protocol support
-      BT_HCIUART_LL y
-      BT_RFCOMM_TTY y # RFCOMM TTY support
-      CPU_FREQ_DEBUG n
-      CRASH_DUMP n
-      DMAR? n # experimental
-      DVB_DYNAMIC_MINORS y # we use udev
-      FUSION y # Fusion MPT device support
-      IDE_GD_ATAPI y # ATAPI floppy support
-      IRDA_ULTRA y # Ultra (connectionless) protocol
-      JOYSTICK_IFORCE_232 y # I-Force Serial joysticks and wheels
-      JOYSTICK_IFORCE_USB y # I-Force USB joysticks and wheels
-      JOYSTICK_XPAD_FF y # X-Box gamepad rumble support
-      JOYSTICK_XPAD_LEDS y # LED Support for Xbox360 controller 'BigX' LED
-      KALLSYMS_EXTRA_PASS n
-      LDM_PARTITION y # Windows Logical Disk Manager (Dynamic Disk) support
-      LEDS_TRIGGER_IDE_DISK y # LED IDE Disk Trigger
-      LOGIRUMBLEPAD2_FF y # Logitech Rumblepad 2 force feedback
-      LOGO n # not needed
-      MEDIA_ATTACH y
-      MEGARAID_NEWGEN y
-      MICROCODE_AMD y
-      MODVERSIONS y
-      MOUSE_PS2_ELANTECH y # Elantech PS/2 protocol extension
-      MTRR_SANITIZER y
-      NET_FC y # Fibre Channel driver support
-      PPP_MULTILINK y # PPP multilink support
-      REGULATOR y # Voltage and Current Regulator Support
-      SCSI_LOGGING y # SCSI logging facility
-      SERIAL_8250 y # 8250/16550 and compatible serial support
-      SLIP_COMPRESSED y # CSLIP compressed headers
-      SLIP_SMART y
-      THERMAL_HWMON y # Hardware monitoring support
-      USB_DEBUG n
-      USB_EHCI_ROOT_HUB_TT y # Root Hub Transaction Translators
-      X86_CHECK_BIOS_CORRUPTION y
-      X86_MCE y
-
-      ${if kernelPlatform ? kernelExtraConfig then kernelPlatform.kernelExtraConfig else ""}
-      ${extraConfig}
-    '';
-in
-
-import ./generic.nix (
-
-  rec {
-    version = "2.6.34.10";
-  
-    src = fetchurl {
-      url = "mirror://kernel/linux/kernel/v2.6/longterm/v2.6.34/linux-${version}.tar.bz2";
-      sha256 = "1sm3n5wxz1amql0ini5mspiaa4kvw9macsp5qyq1dhhfv06i2j31";
-    };
-
-    config = configWithPlatform stdenv.platform;
-    configCross = configWithPlatform stdenv.cross.platform;
-
-    features.iwlwifi = true;
-  }
-
-  // removeAttrs args ["extraConfig"]
-)
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.36.nix b/pkgs/os-specific/linux/kernel/linux-2.6.36.nix
deleted file mode 100644
index 4fa11413cabe8..0000000000000
--- a/pkgs/os-specific/linux/kernel/linux-2.6.36.nix
+++ /dev/null
@@ -1,209 +0,0 @@
-args @ { stdenv, fetchurl, userModeLinux ? false, extraConfig ? ""
-, ... }:
-
-let
-  configWithPlatform = kernelPlatform :
-    ''
-      # Don't include any debug features.
-      DEBUG_KERNEL n
-
-      # Support drivers that need external firmware.
-      STANDALONE n
-
-      # Make /proc/config.gz available.
-      IKCONFIG_PROC y
-
-      # Optimize with -O2, not -Os.
-      CC_OPTIMIZE_FOR_SIZE n
-
-      # Enable the kernel's built-in memory tester.
-      MEMTEST y
-
-      # Disable some expensive (?) features.
-      FTRACE n
-      KPROBES n
-      NUMA? n
-      PM_TRACE_RTC n
-
-      # Enable various subsystems.
-      ACCESSIBILITY y # Accessibility support
-      AUXDISPLAY y # Auxiliary Display support
-      DONGLE y # Serial dongle support
-      HIPPI y
-      MTD_COMPLEX_MAPPINGS y # needed for many devices
-      NET_POCKET y # enable pocket and portable adapters
-      SCSI_LOWLEVEL y # enable lots of SCSI devices
-      SCSI_LOWLEVEL_PCMCIA y
-      SPI y # needed for many devices
-      SPI_MASTER y
-      WAN y
-
-      # Networking options.
-      IP_PNP n
-      IPV6_PRIVACY y
-      NETFILTER_ADVANCED y
-      IP_VS_PROTO_TCP y
-      IP_VS_PROTO_UDP y
-      IP_VS_PROTO_ESP y
-      IP_VS_PROTO_AH y
-      IP_DCCP_CCID3 n # experimental
-      CLS_U32_PERF y
-      CLS_U32_MARK y
-
-      # Wireless networking.
-      IPW2100_MONITOR y # support promiscuous mode
-      IPW2200_MONITOR y # support promiscuous mode
-      IWL4965 y # Intel Wireless WiFi 4965AGN
-      IWL5000 y # Intel Wireless WiFi 5000AGN
-      HOSTAP_FIRMWARE y # Support downloading firmware images with Host AP driver
-      HOSTAP_FIRMWARE_NVRAM y
-
-      # Some settings to make sure that fbcondecor works - in particular,
-      # disable tileblitting and the drivers that need it.
-
-      # Enable various FB devices.
-      FB y
-      FB_EFI y
-      FB_NVIDIA_I2C y # Enable DDC Support
-      FB_RIVA_I2C y
-      FB_ATY_CT y # Mach64 CT/VT/GT/LT (incl. 3D RAGE) support
-      FB_ATY_GX y # Mach64 GX support
-      FB_SAVAGE_I2C y
-      FB_SAVAGE_ACCEL y
-      FB_SIS_300 y
-      FB_SIS_315 y
-      FB_3DFX_ACCEL y
-      FB_GEODE y
-
-      # Video configuration
-      # The intel drivers already require KMS
-      DRM_I915_KMS y
-      # Hybrid graphics support
-      VGA_SWITCHEROO y
-
-      # Sound.
-      SND_AC97_POWER_SAVE y # AC97 Power-Saving Mode
-      SND_HDA_INPUT_BEEP y # Support digital beep via input layer
-      SND_USB_CAIAQ_INPUT y
-      PSS_MIXER y # Enable PSS mixer (Beethoven ADSP-16 and other compatible)
-
-      # USB serial devices.
-      USB_SERIAL_GENERIC y # USB Generic Serial Driver
-      USB_SERIAL_KEYSPAN_MPR y # include firmware for various USB serial devices
-      USB_SERIAL_KEYSPAN_USA28 y
-      USB_SERIAL_KEYSPAN_USA28X y
-      USB_SERIAL_KEYSPAN_USA28XA y
-      USB_SERIAL_KEYSPAN_USA28XB y
-      USB_SERIAL_KEYSPAN_USA19 y
-      USB_SERIAL_KEYSPAN_USA18X y
-      USB_SERIAL_KEYSPAN_USA19W y
-      USB_SERIAL_KEYSPAN_USA19QW y
-      USB_SERIAL_KEYSPAN_USA19QI y
-      USB_SERIAL_KEYSPAN_USA49W y
-      USB_SERIAL_KEYSPAN_USA49WLC y
-
-      # Filesystem options - in particular, enable extended attributes and
-      # ACLs for all filesystems that support them.
-      EXT2_FS_XATTR y # Ext2 extended attributes
-      EXT2_FS_POSIX_ACL y # Ext2 POSIX Access Control Lists
-      EXT2_FS_SECURITY y # Ext2 Security Labels
-      EXT2_FS_XIP y # Ext2 execute in place support
-      EXT4_FS_POSIX_ACL y
-      EXT4_FS_SECURITY y
-      REISERFS_FS_XATTR y
-      REISERFS_FS_POSIX_ACL y
-      REISERFS_FS_SECURITY y
-      JFS_POSIX_ACL y
-      JFS_SECURITY y
-      XFS_QUOTA y
-      XFS_POSIX_ACL y
-      XFS_RT y # XFS Realtime subvolume support
-      OCFS2_DEBUG_MASKLOG n
-      BTRFS_FS_POSIX_ACL y
-      UBIFS_FS_XATTR y
-      UBIFS_FS_ADVANCED_COMPR y
-      NFSD_V2_ACL y
-      NFSD_V3 y
-      NFSD_V3_ACL y
-      NFSD_V4 y
-      CIFS_XATTR y
-      CIFS_POSIX y
-
-      # Security related features.
-      STRICT_DEVMEM y # Filter access to /dev/mem
-      SECURITY_SELINUX_BOOTPARAM_VALUE 0 # disable SELinux by default
-
-      # Misc. options.
-      8139TOO_8129 y
-      8139TOO_PIO n # PIO is slower
-      AIC79XX_DEBUG_ENABLE n
-      AIC7XXX_DEBUG_ENABLE n
-      AIC94XX_DEBUG n
-      B43_PCMCIA y
-      BLK_DEV_BSG n
-      BLK_DEV_CMD640_ENHANCED y # CMD640 enhanced support
-      BLK_DEV_IDEACPI y # IDE ACPI support
-      BLK_DEV_INTEGRITY y
-      BSD_PROCESS_ACCT_V3 y
-      BT_HCIUART_BCSP y
-      BT_HCIUART_H4 y # UART (H4) protocol support
-      BT_HCIUART_LL y
-      BT_RFCOMM_TTY y # RFCOMM TTY support
-      CPU_FREQ_DEBUG n
-      CRASH_DUMP n
-      DMAR? n # experimental
-      DVB_DYNAMIC_MINORS y # we use udev
-      FUSION y # Fusion MPT device support
-      IDE_GD_ATAPI y # ATAPI floppy support
-      IRDA_ULTRA y # Ultra (connectionless) protocol
-      JOYSTICK_IFORCE_232 y # I-Force Serial joysticks and wheels
-      JOYSTICK_IFORCE_USB y # I-Force USB joysticks and wheels
-      JOYSTICK_XPAD_FF y # X-Box gamepad rumble support
-      JOYSTICK_XPAD_LEDS y # LED Support for Xbox360 controller 'BigX' LED
-      KALLSYMS_EXTRA_PASS n
-      LDM_PARTITION y # Windows Logical Disk Manager (Dynamic Disk) support
-      LEDS_TRIGGER_IDE_DISK y # LED IDE Disk Trigger
-      LOGIRUMBLEPAD2_FF y # Logitech Rumblepad 2 force feedback
-      LOGO n # not needed
-      MEDIA_ATTACH y
-      MEGARAID_NEWGEN y
-      MICROCODE_AMD y
-      MODVERSIONS y
-      MOUSE_PS2_ELANTECH y # Elantech PS/2 protocol extension
-      MTRR_SANITIZER y
-      NET_FC y # Fibre Channel driver support
-      PPP_MULTILINK y # PPP multilink support
-      REGULATOR y # Voltage and Current Regulator Support
-      SCSI_LOGGING y # SCSI logging facility
-      SERIAL_8250 y # 8250/16550 and compatible serial support
-      SLIP_COMPRESSED y # CSLIP compressed headers
-      SLIP_SMART y
-      THERMAL_HWMON y # Hardware monitoring support
-      USB_DEBUG n
-      USB_EHCI_ROOT_HUB_TT y # Root Hub Transaction Translators
-      X86_CHECK_BIOS_CORRUPTION y
-      X86_MCE y
-
-      ${if kernelPlatform ? kernelExtraConfig then kernelPlatform.kernelExtraConfig else ""}
-      ${extraConfig}
-    '';
-in
-
-import ./generic.nix (
-
-  rec {
-    version = "2.6.36.4";
-  
-    src = fetchurl {
-      url = "mirror://kernel/linux/kernel/v2.6/linux-${version}.tar.bz2";
-      sha256 = "16pqjz3dgvaghfi0jqp2d0nqyz5fgbbxzs914vxslh2xxdxql0cg";
-    };
-
-    config = configWithPlatform stdenv.platform;
-    configCross = configWithPlatform stdenv.cross.platform;
-
-    features.iwlwifi = true;
-  }
-
-  // removeAttrs args ["extraConfig"]
-)
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.37.nix b/pkgs/os-specific/linux/kernel/linux-2.6.37.nix
deleted file mode 100644
index 3da1e27eb2492..0000000000000
--- a/pkgs/os-specific/linux/kernel/linux-2.6.37.nix
+++ /dev/null
@@ -1,208 +0,0 @@
-args @ { stdenv, fetchurl, userModeLinux ? false, extraConfig ? ""
-, ... }:
-
-let
-  configWithPlatform = kernelPlatform :
-    ''
-      # Don't include any debug features.
-      DEBUG_KERNEL n
-
-      # Support drivers that need external firmware.
-      STANDALONE n
-
-      # Make /proc/config.gz available.
-      IKCONFIG_PROC y
-
-      # Optimize with -O2, not -Os.
-      CC_OPTIMIZE_FOR_SIZE n
-
-      # Enable the kernel's built-in memory tester.
-      MEMTEST y
-
-      # Disable some expensive (?) features.
-      FTRACE n
-      KPROBES n
-      NUMA? n
-      PM_TRACE_RTC n
-
-      # Enable various subsystems.
-      ACCESSIBILITY y # Accessibility support
-      AUXDISPLAY y # Auxiliary Display support
-      DONGLE y # Serial dongle support
-      HIPPI y
-      MTD_COMPLEX_MAPPINGS y # needed for many devices
-      NET_POCKET y # enable pocket and portable adapters
-      SCSI_LOWLEVEL y # enable lots of SCSI devices
-      SCSI_LOWLEVEL_PCMCIA y
-      SPI y # needed for many devices
-      SPI_MASTER y
-      WAN y
-
-      # Networking options.
-      IP_PNP n
-      IPV6_PRIVACY y
-      NETFILTER_ADVANCED y
-      IP_VS_PROTO_TCP y
-      IP_VS_PROTO_UDP y
-      IP_VS_PROTO_ESP y
-      IP_VS_PROTO_AH y
-      IP_DCCP_CCID3 n # experimental
-      CLS_U32_PERF y
-      CLS_U32_MARK y
-
-      # Wireless networking.
-      IPW2100_MONITOR y # support promiscuous mode
-      IPW2200_MONITOR y # support promiscuous mode
-      IWL4965 y # Intel Wireless WiFi 4965AGN
-      IWL5000 y # Intel Wireless WiFi 5000AGN
-      HOSTAP_FIRMWARE y # Support downloading firmware images with Host AP driver
-      HOSTAP_FIRMWARE_NVRAM y
-
-      # Some settings to make sure that fbcondecor works - in particular,
-      # disable tileblitting and the drivers that need it.
-
-      # Enable various FB devices.
-      FB y
-      FB_EFI y
-      FB_NVIDIA_I2C y # Enable DDC Support
-      FB_RIVA_I2C y
-      FB_ATY_CT y # Mach64 CT/VT/GT/LT (incl. 3D RAGE) support
-      FB_ATY_GX y # Mach64 GX support
-      FB_SAVAGE_I2C y
-      FB_SAVAGE_ACCEL y
-      FB_SIS_300 y
-      FB_SIS_315 y
-      FB_3DFX_ACCEL y
-      FB_GEODE y
-
-      # Video configuration
-      # The intel drivers already require KMS
-      DRM_I915_KMS y
-      # Hybrid graphics support
-      VGA_SWITCHEROO y
-
-      # Sound.
-      SND_AC97_POWER_SAVE y # AC97 Power-Saving Mode
-      SND_HDA_INPUT_BEEP y # Support digital beep via input layer
-      SND_USB_CAIAQ_INPUT y
-      PSS_MIXER y # Enable PSS mixer (Beethoven ADSP-16 and other compatible)
-
-      # USB serial devices.
-      USB_SERIAL_GENERIC y # USB Generic Serial Driver
-      USB_SERIAL_KEYSPAN_MPR y # include firmware for various USB serial devices
-      USB_SERIAL_KEYSPAN_USA28 y
-      USB_SERIAL_KEYSPAN_USA28X y
-      USB_SERIAL_KEYSPAN_USA28XA y
-      USB_SERIAL_KEYSPAN_USA28XB y
-      USB_SERIAL_KEYSPAN_USA19 y
-      USB_SERIAL_KEYSPAN_USA18X y
-      USB_SERIAL_KEYSPAN_USA19W y
-      USB_SERIAL_KEYSPAN_USA19QW y
-      USB_SERIAL_KEYSPAN_USA19QI y
-      USB_SERIAL_KEYSPAN_USA49W y
-      USB_SERIAL_KEYSPAN_USA49WLC y
-
-      # Filesystem options - in particular, enable extended attributes and
-      # ACLs for all filesystems that support them.
-      EXT2_FS_XATTR y # Ext2 extended attributes
-      EXT2_FS_POSIX_ACL y # Ext2 POSIX Access Control Lists
-      EXT2_FS_SECURITY y # Ext2 Security Labels
-      EXT2_FS_XIP y # Ext2 execute in place support
-      EXT4_FS_POSIX_ACL y
-      EXT4_FS_SECURITY y
-      REISERFS_FS_XATTR y
-      REISERFS_FS_POSIX_ACL y
-      REISERFS_FS_SECURITY y
-      JFS_POSIX_ACL y
-      JFS_SECURITY y
-      XFS_QUOTA y
-      XFS_POSIX_ACL y
-      XFS_RT y # XFS Realtime subvolume support
-      OCFS2_DEBUG_MASKLOG n
-      BTRFS_FS_POSIX_ACL y
-      UBIFS_FS_XATTR y
-      UBIFS_FS_ADVANCED_COMPR y
-      NFSD_V2_ACL y
-      NFSD_V3 y
-      NFSD_V3_ACL y
-      NFSD_V4 y
-      CIFS_XATTR y
-      CIFS_POSIX y
-
-      # Security related features.
-      STRICT_DEVMEM y # Filter access to /dev/mem
-      SECURITY_SELINUX_BOOTPARAM_VALUE 0 # disable SELinux by default
-
-      # Misc. options.
-      8139TOO_8129 y
-      8139TOO_PIO n # PIO is slower
-      AIC79XX_DEBUG_ENABLE n
-      AIC7XXX_DEBUG_ENABLE n
-      AIC94XX_DEBUG n
-      B43_PCMCIA y
-      BLK_DEV_CMD640_ENHANCED y # CMD640 enhanced support
-      BLK_DEV_IDEACPI y # IDE ACPI support
-      BLK_DEV_INTEGRITY y
-      BSD_PROCESS_ACCT_V3 y
-      BT_HCIUART_BCSP y
-      BT_HCIUART_H4 y # UART (H4) protocol support
-      BT_HCIUART_LL y
-      BT_RFCOMM_TTY y # RFCOMM TTY support
-      CPU_FREQ_DEBUG n
-      CRASH_DUMP n
-      DMAR? n # experimental
-      DVB_DYNAMIC_MINORS y # we use udev
-      FUSION y # Fusion MPT device support
-      IDE_GD_ATAPI y # ATAPI floppy support
-      IRDA_ULTRA y # Ultra (connectionless) protocol
-      JOYSTICK_IFORCE_232 y # I-Force Serial joysticks and wheels
-      JOYSTICK_IFORCE_USB y # I-Force USB joysticks and wheels
-      JOYSTICK_XPAD_FF y # X-Box gamepad rumble support
-      JOYSTICK_XPAD_LEDS y # LED Support for Xbox360 controller 'BigX' LED
-      KALLSYMS_EXTRA_PASS n
-      LDM_PARTITION y # Windows Logical Disk Manager (Dynamic Disk) support
-      LEDS_TRIGGER_IDE_DISK y # LED IDE Disk Trigger
-      LOGIRUMBLEPAD2_FF y # Logitech Rumblepad 2 force feedback
-      LOGO n # not needed
-      MEDIA_ATTACH y
-      MEGARAID_NEWGEN y
-      MICROCODE_AMD y
-      MODVERSIONS y
-      MOUSE_PS2_ELANTECH y # Elantech PS/2 protocol extension
-      MTRR_SANITIZER y
-      NET_FC y # Fibre Channel driver support
-      PPP_MULTILINK y # PPP multilink support
-      REGULATOR y # Voltage and Current Regulator Support
-      SCSI_LOGGING y # SCSI logging facility
-      SERIAL_8250 y # 8250/16550 and compatible serial support
-      SLIP_COMPRESSED y # CSLIP compressed headers
-      SLIP_SMART y
-      THERMAL_HWMON y # Hardware monitoring support
-      USB_DEBUG n
-      USB_EHCI_ROOT_HUB_TT y # Root Hub Transaction Translators
-      X86_CHECK_BIOS_CORRUPTION y
-      X86_MCE y
-
-      ${if kernelPlatform ? kernelExtraConfig then kernelPlatform.kernelExtraConfig else ""}
-      ${extraConfig}
-    '';
-in
-
-import ./generic.nix (
-
-  rec {
-    version = "2.6.37.6";
-  
-    src = fetchurl {
-      url = "mirror://kernel/linux/kernel/v2.6/linux-${version}.tar.bz2";
-      sha256 = "07khv9z27l5ny37c7malgkg4q65r1g83i4m9rb74p17y15rsv8ad";
-    };
-
-    config = configWithPlatform stdenv.platform;
-    configCross = configWithPlatform stdenv.cross.platform;
-
-    features.iwlwifi = true;
-  }
-
-  // removeAttrs args ["extraConfig"]
-)
diff --git a/pkgs/os-specific/linux/kernel/patches.nix b/pkgs/os-specific/linux/kernel/patches.nix
index 59a8f794e174c..42c99f0d56cde 100644
--- a/pkgs/os-specific/linux/kernel/patches.nix
+++ b/pkgs/os-specific/linux/kernel/patches.nix
@@ -84,26 +84,6 @@ rec {
       features.fbConDecor = true;
     };
 
-  fbcondecor_2_6_28 =
-    { name = "fbcondecor-0.9.5-2.6.28";
-      patch = fetchurl {
-        url = http://dev.gentoo.org/~spock/projects/fbcondecor/archive/fbcondecor-0.9.5-2.6.28.patch;
-        sha256 = "105q2dwrwi863r7nhlrvljim37aqv67mjc3lgg529jzqgny3fjds";
-      };
-      extraConfig = fbcondecorConfig;
-      features.fbConDecor = true;
-    };
-
-  fbcondecor_2_6_29 =
-    { name = "fbcondecor-0.9.6-2.6.29.2";
-      patch = fetchurl {
-        url = http://dev.gentoo.org/~spock/projects/fbcondecor/archive/fbcondecor-0.9.6-2.6.29.2.patch;
-        sha256 = "1yppvji13sgnql62h4wmskzl9l198pp1pbixpbymji7mr4a0ylx1";
-      };
-      extraConfig = fbcondecorConfig;
-      features.fbConDecor = true;
-    };
-
   fbcondecor_2_6_31 =
     { name = "fbcondecor-0.9.6-2.6.31.2";
       patch = fetchurl {
@@ -114,16 +94,6 @@ rec {
       features.fbConDecor = true;
     };
 
-  fbcondecor_2_6_33 =
-    { name = "fbcondecor-0.9.6-2.6.33-rc7";
-      patch = fetchurl {
-        url = http://dev.gentoo.org/~spock/projects/fbcondecor/archive/fbcondecor-0.9.6-2.6.33-rc7.patch;
-        sha256 = "1v9lg3bgva0xry0s09drpw3n139s8hln8slayaf6i26vg4l4xdz6";
-      };
-      extraConfig = fbcondecorConfig;
-      features.fbConDecor = true;
-    };
-
   fbcondecor_2_6_35 =
     rec {
       name = "fbcondecor-0.9.6-2.6.35-rc4";
@@ -135,17 +105,6 @@ rec {
       features.fbConDecor = true;
     };
 
-  fbcondecor_2_6_37 =
-    rec {
-      name = "fbcondecor-0.9.6-2.6.37";
-      patch = fetchurl {
-        url = "http://dev.gentoo.org/~spock/projects/fbcondecor/archive/${name}.patch";
-        sha256 = "1yap9q6mp15jhsysry4x17cpm5dj35g8l2d0p0vn1xq25x3jfkqk";
-      };
-      extraConfig = fbcondecorConfig;
-      features.fbConDecor = true;
-    };
-
   fbcondecor_2_6_38 =
     rec {
       name = "fbcondecor-0.9.6-2.6.38";
@@ -157,15 +116,6 @@ rec {
       features.fbConDecor = true;
     };
 
-  # From http://patchwork.kernel.org/patch/19495/
-  ext4_softlockups_2_6_28 =
-    { name = "ext4-softlockups-fix";
-      patch = fetchurl {
-        url = http://patchwork.kernel.org/patch/19495/raw;
-        sha256 = "0vqcj9qs7jajlvmwm97z8cljr4vb277aqhsjqrakbxfdiwlhrzzf";
-      };
-    };
-
   gcov_2_6_28 =
     { name = "gcov";
       patch = fetchurl {
@@ -214,16 +164,6 @@ rec {
       features.aufs2 = true;
     };
 
-  aufs2_2_6_33 =
-    { # From http://git.c3sl.ufpr.br/gitweb?p=aufs/aufs2-standalone.git;a=tree;h=refs/heads/aufs2-33;hb=aufs2-33
-      # Note that this merely the patch needed to build AUFS2 as a
-      # standalone package.
-      name = "aufs2";
-      patch = ./aufs2-33.patch;
-      features.aufsBase = true;
-      features.aufs2 = true;
-    };
-
   aufs2_2_6_34 =
     { # From http://git.c3sl.ufpr.br/gitweb?p=aufs/aufs2-standalone.git;a=tree;h=refs/heads/aufs2-34;hb=aufs2-34
       # Note that this merely the patch needed to build AUFS2 as a
@@ -254,16 +194,6 @@ rec {
       features.aufs2_1 = true;
     };
 
-  aufs2_1_2_6_37 =
-    { # From http://git.c3sl.ufpr.br/gitweb?p=aufs/aufs2-standalone.git;a=tree;h=refs/heads/aufs2.1-37;hb=refs/heads/aufs2.1-37
-      # Note that this merely the patch needed to build AUFS2.1 as a
-      # standalone package.
-      name = "aufs2.1";
-      patch = ./aufs2.1-37.patch;
-      features.aufsBase = true;
-      features.aufs2_1 = true;
-    };
-
   aufs2_1_2_6_38 =
     { # From http://aufs.git.sourceforge.net/git/gitweb.cgi?p=aufs/aufs2-standalone.git;a=tree;h=refs/heads/aufs2.1-38;hb=refs/heads/aufs2.1-38
       # Note that this merely the patch needed to build AUFS2.1 as a
@@ -410,12 +340,4 @@ rec {
       name = "guruplug-arch-number";
       patch = ./guruplug-mach-type.patch;
     };
-
-  glibc_getline =
-    {
-      # Patch to work around conflicting types for the `getline' function
-      # with recent Glibcs (2009).
-      name = "glibc-getline";
-      patch = ./getline.patch;
-    };
 }
diff --git a/pkgs/os-specific/linux/klibc/shrunk.nix b/pkgs/os-specific/linux/klibc/shrunk.nix
index ff72d1f72b845..066b4fcb4e063 100644
--- a/pkgs/os-specific/linux/klibc/shrunk.nix
+++ b/pkgs/os-specific/linux/klibc/shrunk.nix
@@ -7,7 +7,7 @@ stdenv.mkDerivation {
   #name = "${klibc.name}-shrunk";
   name = "${klibc.name}";
   buildCommand = ''
-    ensureDir $out/lib
+    mkdir -p $out/lib
     cp -prd ${klibc}/lib/klibc/bin $out/
     cp -p ${klibc}/lib/*.so $out/lib/
     chmod +w $out/*
diff --git a/pkgs/os-specific/linux/kudzu/builder.sh b/pkgs/os-specific/linux/kudzu/builder.sh
index 744d1d516a332..002bac8a1db85 100644
--- a/pkgs/os-specific/linux/kudzu/builder.sh
+++ b/pkgs/os-specific/linux/kudzu/builder.sh
@@ -3,10 +3,10 @@ source $stdenv/setup
 export DESTDIR=$out
 
 preInstall() {
-  ensureDir $out
-  ensureDir $out/etc
-  ensureDir $out/sbin
-  ensureDir $out/usr
+  mkdir -p $out
+  mkdir -p $out/etc
+  mkdir -p $out/sbin
+  mkdir -p $out/usr
   make install-program
 }
 
diff --git a/pkgs/os-specific/linux/libcap/default.nix b/pkgs/os-specific/linux/libcap/default.nix
index d8cb393ac38be..c279393d7a407 100644
--- a/pkgs/os-specific/linux/libcap/default.nix
+++ b/pkgs/os-specific/linux/libcap/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
 
   passthru = {
     postinst = n : ''
-      ensureDir $out/share/doc/${n}
+      mkdir -p $out/share/doc/${n}
       cp ../License $out/share/doc/${n}/License
     '';
   };
diff --git a/pkgs/os-specific/linux/lsiutil/default.nix b/pkgs/os-specific/linux/lsiutil/default.nix
index 09cd4ab037c91..700455d5f8b95 100644
--- a/pkgs/os-specific/linux/lsiutil/default.nix
+++ b/pkgs/os-specific/linux/lsiutil/default.nix
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
 
   preBuild =
     ''
-      ensureDir $out/bin
+      mkdir -p $out/bin
       substituteInPlace Makefile --replace /usr/bin $out/bin
       substituteInPlace lsiutil.c \
         --replace /sbin/modprobe modprobe \
diff --git a/pkgs/os-specific/linux/mingetty/default.nix b/pkgs/os-specific/linux/mingetty/default.nix
index b27baa5480b90..192e2c7ac5f96 100644
--- a/pkgs/os-specific/linux/mingetty/default.nix
+++ b/pkgs/os-specific/linux/mingetty/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
   };
 
   preInstall = ''
-    ensureDir $out/sbin $out/share/man/man8
+    mkdir -p $out/sbin $out/share/man/man8
     makeFlagsArray=(SBINDIR=$out/sbin MANDIR=$out/share/man/man8)
   '';
 
diff --git a/pkgs/os-specific/linux/module-init-tools/default.nix b/pkgs/os-specific/linux/module-init-tools/default.nix
index 79e1111d40d6e..077d08f899daf 100644
--- a/pkgs/os-specific/linux/module-init-tools/default.nix
+++ b/pkgs/os-specific/linux/module-init-tools/default.nix
@@ -1,19 +1,26 @@
 { stdenv, fetchurl, docbook2x, docbook_sgml_dtd_41 }:
 
-stdenv.mkDerivation rec {
+stdenv.mkDerivation {
   name = "module-init-tools-3.16";
 
-  src = fetchurl {
-    url = "mirror://kernel/linux/utils/kernel/module-init-tools/${name}.tar.bz2";
-    sha256 = "0jxnz9ahfic79rp93l5wxcbgh4pkv85mwnjlbv1gz3jawv5cvwp1";
-  };
+  src = [
+    (fetchurl {
+      url = mirror://kernel/linux/utils/kernel/module-init-tools/module-init-tools-3.16.tar.bz2;
+      sha256 = "0jxnz9ahfic79rp93l5wxcbgh4pkv85mwnjlbv1gz3jawv5cvwp1";
+    })
 
-  buildInputs = [ docbook2x ];
+    # Upstream forgot to include the generated manpages.  Thankfully
+    # the Gentoo people fixed this for us :-)
+    (fetchurl {
+      url = mirror://gentoo/distfiles/module-init-tools-3.16-man.tar.bz2;
+      sha256 = "1j1nzi87kgsh4scl645fhwhjvljxj83cmdasa4n4p5krhasgw358";
+    })
+  ];
 
   SGML_CATALOG_FILES = "${docbook_sgml_dtd_41}/sgml/dtd/docbook-4.1/docbook.cat";
 
   patches = [ ./module-dir.patch ./docbook2man.patch ];
-  
+
   postInstall = "rm $out/sbin/insmod.static"; # don't need it
 
   # We don't want bash (and therefore glibc) in the closure of the
diff --git a/pkgs/os-specific/linux/module-init-tools/module-dir.patch b/pkgs/os-specific/linux/module-init-tools/module-dir.patch
index 90805b00c3cfa..95c7559604dd8 100644
--- a/pkgs/os-specific/linux/module-init-tools/module-dir.patch
+++ b/pkgs/os-specific/linux/module-init-tools/module-dir.patch
@@ -1,36 +1,43 @@
-diff -Naur module-init-tools-3.16-orig/depmod.c module-init-tools-3.16/depmod.c
---- module-init-tools-3.16-orig/depmod.c	2011-06-02 13:55:01.000000000 -0400
-+++ module-init-tools-3.16/depmod.c	2011-10-01 23:30:14.947293695 -0400
-@@ -48,10 +48,6 @@
+commit cf2c95edb7918bc658f6cae93793c1949fc9cb6e
+Author: David Guibert <david.guibert@gmail.com>
+Date:   Fri Aug 5 14:20:12 2011 +0200
+
+    introduce module-dir
+
+diff --git a/depmod.c b/depmod.c
+index a1d2f8c..9362a35 100644
+--- a/depmod.c
++++ b/depmod.c
+@@ -48,9 +48,6 @@
  
  #include "testing.h"
  
 -#ifndef MODULE_DIR
 -#define MODULE_DIR "/lib/modules/"
 -#endif
--
+ 
  #ifndef MODULE_BUILTIN_KEY
  #define MODULE_BUILTIN_KEY "built-in"
- #endif
-@@ -1514,6 +1510,7 @@
- 			     struct module_overrides **overrides)
- {
+@@ -1516,6 +1513,7 @@ static int parse_config_file(const char *filename,
  	char *line;
-+	char *module_dir;
  	unsigned int linenum = 0;
  	FILE *cfile;
++ 	char *module_dir;
  
-@@ -1536,6 +1533,9 @@
- 			continue;
- 		}
+ 	cfile = fopen(filename, "r");
+ 	if (!cfile) {
+@@ -1525,6 +1523,10 @@ static int parse_config_file(const char *filename,
+ 		return 0;
+ 	}
  
-+		if((module_dir = getenv("MODULE_DIR")) == NULL)
-+			module_dir = "/lib/modules/";
++        if((module_dir = getenv("MODULE_DIR")) == NULL) {
++                module_dir = "/lib/modules/";
++        }
 +
- 		if (streq(cmd, "search")) {
- 			char *search_path;
- 			
-@@ -1550,7 +1550,7 @@
+ 	while ((line = getline_wrapped(cfile, &linenum)) != NULL) {
+ 		char *ptr = line;
+ 		char *cmd, *modname;
+@@ -1550,7 +1552,7 @@ static int parse_config_file(const char *filename,
  					continue;
  				}
  				nofail_asprintf(&dirname, "%s%s%s/%s", basedir,
@@ -39,7 +46,7 @@ diff -Naur module-init-tools-3.16-orig/depmod.c module-init-tools-3.16/depmod.c
  				len = strlen(dirname);
  				*search = add_search(dirname, len, *search);
  				free(dirname);
-@@ -1565,7 +1565,7 @@
+@@ -1565,7 +1567,7 @@ static int parse_config_file(const char *filename,
  				continue;
  
  			nofail_asprintf(&pathname, "%s%s%s/%s/%s.ko", basedir,
@@ -48,27 +55,28 @@ diff -Naur module-init-tools-3.16-orig/depmod.c module-init-tools-3.16/depmod.c
  
  			*overrides = add_override(pathname, *overrides);
  			free(pathname);
-@@ -1737,6 +1737,7 @@
+@@ -1737,6 +1739,7 @@ int main(int argc, char *argv[])
  	char *basedir = "", *dirname, *version;
  	char *system_map = NULL, *module_symvers = NULL;
  	int i;
-+	char *module_dir;
++ 	char *module_dir;
  	const char *config = NULL;
  
  	if (native_endianness() == 0)
-@@ -1832,7 +1833,10 @@
+@@ -1832,7 +1835,11 @@ int main(int argc, char *argv[])
  	if (optind == argc)
  		all = 1;
  
 -	nofail_asprintf(&dirname, "%s%s%s", basedir, MODULE_DIR, version);
-+	if((module_dir = getenv("MODULE_DIR")) == NULL)
-+		module_dir = "/lib/modules/";
++        if((module_dir = getenv("MODULE_DIR")) == NULL) {
++                module_dir = "/lib/modules/";
++        }
 +
 +	nofail_asprintf(&dirname, "%s%s%s", basedir, module_dir, version);
  
  	if (maybe_all) {
  		if (!doing_stdout && !depfile_out_of_date(dirname))
-@@ -1850,7 +1854,7 @@
+@@ -1850,7 +1857,7 @@ int main(int argc, char *argv[])
  		size_t len;
  
  		nofail_asprintf(&dirname, "%s%s%s/updates", basedir,
@@ -77,36 +85,35 @@ diff -Naur module-init-tools-3.16-orig/depmod.c module-init-tools-3.16/depmod.c
  		len = strlen(dirname);
  		search = add_search(dirname, len, search);
  	}
-diff -Naur module-init-tools-3.16-orig/modinfo.c module-init-tools-3.16/modinfo.c
---- module-init-tools-3.16-orig/modinfo.c	2011-06-02 13:55:01.000000000 -0400
-+++ module-init-tools-3.16/modinfo.c	2011-10-01 23:32:15.335093548 -0400
-@@ -19,10 +19,6 @@
+diff --git a/modinfo.c b/modinfo.c
+index 1dd8469..67b1041 100644
+--- a/modinfo.c
++++ b/modinfo.c
+@@ -19,9 +19,6 @@
  #include "zlibsupport.h"
  #include "testing.h"
  
 -#ifndef MODULE_DIR
 -#define MODULE_DIR "/lib/modules"
 -#endif
--
+ 
  struct param
  {
- 	struct param *next;
-@@ -192,6 +188,7 @@
- 	unsigned long size;
+@@ -193,6 +190,11 @@ static struct elf_file *grab_module(const char *name,
  	struct utsname buf;
  	char *depname, *p, *moddir;
-+	char *module_dir;
  	struct elf_file *module;
++ 	char *module_dir;
++
++        if((module_dir = getenv("MODULE_DIR")) == NULL) {
++                module_dir = "/lib/modules/";
++        }
  
  	if (strchr(name, '.') || strchr(name, '/')) {
-@@ -206,10 +203,14 @@
- 		uname(&buf);
+ 		module = grab_elf_file(name);
+@@ -207,9 +209,9 @@ static struct elf_file *grab_module(const char *name,
  		kernel = buf.release;
  	}
-+
-+	if((module_dir = getenv("MODULE_DIR")) == NULL)
-+		module_dir = "/lib/modules/";
-+
  	if (strlen(basedir))
 -		nofail_asprintf(&moddir, "%s/%s/%s", basedir, MODULE_DIR, kernel);
 +		nofail_asprintf(&moddir, "%s/%s/%s", basedir, module_dir, kernel);
@@ -116,10 +123,11 @@ diff -Naur module-init-tools-3.16-orig/modinfo.c module-init-tools-3.16/modinfo.
  
  	/* Search for it in modules.dep. */
  	nofail_asprintf(&depname, "%s/%s", moddir, "modules.dep");
-diff -Naur module-init-tools-3.16-orig/modprobe.c module-init-tools-3.16/modprobe.c
---- module-init-tools-3.16-orig/modprobe.c	2011-06-02 13:55:01.000000000 -0400
-+++ module-init-tools-3.16/modprobe.c	2011-10-01 23:34:04.111913368 -0400
-@@ -86,10 +86,6 @@
+diff --git a/modprobe.c b/modprobe.c
+index 5464f45..d9fbf9d 100644
+--- a/modprobe.c
++++ b/modprobe.c
+@@ -86,10 +86,6 @@ typedef enum
  
  } modprobe_flags_t;
  
@@ -130,24 +138,24 @@ diff -Naur module-init-tools-3.16-orig/modprobe.c module-init-tools-3.16/modprob
  /**
   * print_usage - output the prefered program usage
   *
-@@ -2131,6 +2127,7 @@
- 	char *cmdline_opts = NULL;
- 	char *dirname;
- 	errfn_t error = fatal;
-+	char *module_dir;
- 	int failed = 0;
- 	modprobe_flags_t flags = 0;
+@@ -2136,6 +2132,7 @@ int main(int argc, char *argv[])
  	struct modprobe_conf conf = {};
-@@ -2233,7 +2230,10 @@
+ 
+ 	recursion_depth = 0;
++ 	char *module_dir = NULL;
+ 
+ 	/* Prepend options from environment. */
+ 	argv = merge_args(getenv("MODPROBE_OPTIONS"), argv, &argc);
+@@ -2233,7 +2230,11 @@ int main(int argc, char *argv[])
  	if (argc < optind + 1 && !dump_config && !list_only)
  		print_usage(argv[0]);
  
 -	nofail_asprintf(&dirname, "%s%s/%s", basedir, MODULE_DIR, buf.release);
-+	if((module_dir = getenv("MODULE_DIR")) == NULL)
-+		module_dir = "/lib/modules/";
++	if((module_dir = getenv("MODULE_DIR")) == NULL) {
++		module_dir = "/lib/modules";
++	}
 +
 +	nofail_asprintf(&dirname, "%s%s/%s", basedir, module_dir, buf.release);
  
  	/* Old-style -t xxx wildcard?  Only with -l. */
  	if (list_only) {
-
diff --git a/pkgs/os-specific/linux/nfs-utils/default.nix b/pkgs/os-specific/linux/nfs-utils/default.nix
index cf05d0fbaed49..cdadcb05849ab 100644
--- a/pkgs/os-specific/linux/nfs-utils/default.nix
+++ b/pkgs/os-specific/linux/nfs-utils/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, tcpWrapper, utillinuxng, libcap }:
+{ fetchurl, stdenv, tcpWrapper, utillinux, libcap }:
 
 stdenv.mkDerivation rec {
   name = "nfs-utils-1.2.3";
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
   };
 
   # Needs `libblkid' and `libcomerr' from `e2fsprogs' or `util-linux-ng'.
-  buildInputs = [ tcpWrapper utillinuxng libcap ];
+  buildInputs = [ tcpWrapper utillinux libcap ];
 
   # FIXME: Add the dependencies needed for NFSv4 and TI-RPC.
   configureFlags =
diff --git a/pkgs/os-specific/linux/nss_ldap/default.nix b/pkgs/os-specific/linux/nss_ldap/default.nix
index 34de51081648d..7c8b526b4c378 100644
--- a/pkgs/os-specific/linux/nss_ldap/default.nix
+++ b/pkgs/os-specific/linux/nss_ldap/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
     substituteInPlace Makefile \
       --replace '/usr$(libdir)' $TMPDIR \
       --replace 'install-data-local:' 'install-data-local-disabled:'
-    ensureDir $out/etc
+    mkdir -p $out/etc
   '';
 
   buildInputs = [openldap];
diff --git a/pkgs/os-specific/linux/numactl/default.nix b/pkgs/os-specific/linux/numactl/default.nix
index f329db90cb20a..b92408058657e 100644
--- a/pkgs/os-specific/linux/numactl/default.nix
+++ b/pkgs/os-specific/linux/numactl/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
 
   preInstall = ''
     # The `install' rule expects this directory to be available.
-    ensureDir "$out/share/man/man5"
+    mkdir -p "$out/share/man/man5"
   '';
 
   meta = {
diff --git a/pkgs/os-specific/linux/nvidia-x11/builder-legacy.sh b/pkgs/os-specific/linux/nvidia-x11/builder-legacy.sh
index 6941288b3903f..e0af21759c9d7 100755
--- a/pkgs/os-specific/linux/nvidia-x11/builder-legacy.sh
+++ b/pkgs/os-specific/linux/nvidia-x11/builder-legacy.sh
@@ -36,7 +36,7 @@ buildPhase() {
 installPhase() {
 
     # Install libGL and friends.
-    ensureDir $out/lib
+    mkdir -p $out/lib
     cp -prd usr/lib/* usr/X11R6/lib/libXv* $out/lib/
 
     ln -snf libGLcore.so.$versionNumber $out/lib/libGLcore.so
@@ -59,11 +59,11 @@ installPhase() {
     if test -z "$libsOnly"; then
         
         # Install the kernel module.
-        ensureDir $out/lib/modules/$kernelVersion/misc
+        mkdir -p $out/lib/modules/$kernelVersion/misc
         cp usr/src/nv/nvidia.ko $out/lib/modules/$kernelVersion/misc
 
         # Install the X driver.
-        ensureDir $out/lib/xorg/modules
+        mkdir -p $out/lib/xorg/modules
         cp -prd usr/X11R6/lib/modules/* $out/lib/xorg/modules/
 
         ln -snf libnvidia-wfb.so.$versionNumber $out/lib/xorg/modules/libnvidia-wfb.so.1
@@ -72,7 +72,7 @@ installPhase() {
         patchelf --set-rpath $out/lib $out/lib/xorg/modules/extensions/libglx.so.*.*
 
         # Install the programs.
-        ensureDir $out/bin
+        mkdir -p $out/bin
 
         for i in nvidia-settings nvidia-xconfig; do
 	    cp usr/bin/$i $out/bin/$i
diff --git a/pkgs/os-specific/linux/nvidia-x11/builder.sh b/pkgs/os-specific/linux/nvidia-x11/builder.sh
index 180eb84e5e4f0..b0d2bf35c52a8 100755
--- a/pkgs/os-specific/linux/nvidia-x11/builder.sh
+++ b/pkgs/os-specific/linux/nvidia-x11/builder.sh
@@ -27,7 +27,7 @@ buildPhase() {
 installPhase() {
 
     # Install libGL and friends.
-    ensureDir $out/lib
+    mkdir -p $out/lib
     cp -prd libcuda.* libGL.* libnvidia-cfg.* libnvidia-compiler.* libnvidia-tls.* libnvidia-glcore.* libOpenCL.* libXv* libvdpau_nvidia* tls $out/lib/
     
     ln -snf libnvidia-glcore.so.$versionNumber $out/lib/libnvidia-glcore.so
@@ -50,15 +50,15 @@ installPhase() {
     if test -z "$libsOnly"; then
         
         # Install the kernel module.
-        ensureDir $out/lib/modules/$kernelVersion/misc
+        mkdir -p $out/lib/modules/$kernelVersion/misc
         cp kernel/nvidia.ko $out/lib/modules/$kernelVersion/misc
 
         # Install the X driver.
-        ensureDir $out/lib/xorg/modules
+        mkdir -p $out/lib/xorg/modules
         cp -p libnvidia-wfb.* $out/lib/xorg/modules/
-        ensureDir $out/lib/xorg/modules/drivers
+        mkdir -p $out/lib/xorg/modules/drivers
         cp -p nvidia_drv.so $out/lib/xorg/modules/drivers
-        ensureDir $out/lib/xorg/modules/extensions
+        mkdir -p $out/lib/xorg/modules/extensions
         cp -p libglx.so.* $out/lib/xorg/modules/extensions
 
         ln -snf libnvidia-wfb.so.$versionNumber $out/lib/xorg/modules/libnvidia-wfb.so.1
@@ -67,7 +67,7 @@ installPhase() {
         patchelf --set-rpath $out/lib $out/lib/xorg/modules/extensions/libglx.so.*.*
 
         # Install the programs.
-        ensureDir $out/bin
+        mkdir -p $out/bin
 
         for i in nvidia-settings nvidia-xconfig; do
 	    cp $i $out/bin/$i
@@ -76,16 +76,16 @@ installPhase() {
         done
     
         # Header files etc.
-        ensureDir $out/include/nvidia
+        mkdir -p $out/include/nvidia
         cp -p *.h $out/include/nvidia
 
-        ensureDir $out/share/man/man1
+        mkdir -p $out/share/man/man1
         cp -p *.1.gz $out/share/man/man1
 
-        ensureDir $out/share/applications
+        mkdir -p $out/share/applications
         cp -p *.desktop $out/share/applications
 
-        ensureDir $out/share/pixmaps
+        mkdir -p $out/share/pixmaps
         cp -p nvidia-settings.png $out/share/pixmaps
 
         # Patch the `nvidia-settings.desktop' file.
diff --git a/pkgs/os-specific/linux/opengl/xorg-sys/builder.sh b/pkgs/os-specific/linux/opengl/xorg-sys/builder.sh
index 7ab20855bd315..cd21899e60e7d 100644
--- a/pkgs/os-specific/linux/opengl/xorg-sys/builder.sh
+++ b/pkgs/os-specific/linux/opengl/xorg-sys/builder.sh
@@ -1,6 +1,6 @@
 source $stdenv/setup
 
-ensureDir $out/lib
+mkdir -p $out/lib
 
 ln -s /usr/lib/libGL.so.1 $out/lib/
 ln -s /usr/lib/libGLU.so.1 $out/lib/
diff --git a/pkgs/os-specific/linux/ov511/ov511-2.30-builder.sh b/pkgs/os-specific/linux/ov511/ov511-2.30-builder.sh
index 8bb282cacf757..21a2ac725ca7c 100644
--- a/pkgs/os-specific/linux/ov511/ov511-2.30-builder.sh
+++ b/pkgs/os-specific/linux/ov511/ov511-2.30-builder.sh
@@ -13,6 +13,6 @@ echo "version $version"
 
 export version
 
-ensureDir $out/lib/modules/$version/kernel/drivers/usb/media/
+mkdir -p $out/lib/modules/$version/kernel/drivers/usb/media/
 
 genericBuild
diff --git a/pkgs/os-specific/linux/ov511/ov511-2.32-builder.sh b/pkgs/os-specific/linux/ov511/ov511-2.32-builder.sh
index c189c2e17068a..636b19a95af22 100644
--- a/pkgs/os-specific/linux/ov511/ov511-2.32-builder.sh
+++ b/pkgs/os-specific/linux/ov511/ov511-2.32-builder.sh
@@ -13,7 +13,7 @@ echo "version $version"
 
 export version
 
-ensureDir $out/lib/modules/$version/kernel/drivers/usb/media/
+mkdir -p $out/lib/modules/$version/kernel/drivers/usb/media/
 
 genericBuild
 
diff --git a/pkgs/os-specific/linux/pcmciautils/default.nix b/pkgs/os-specific/linux/pcmciautils/default.nix
index a8b885d8a9447..b53c61c754ae2 100644
--- a/pkgs/os-specific/linux/pcmciautils/default.nix
+++ b/pkgs/os-specific/linux/pcmciautils/default.nix
@@ -38,7 +38,7 @@ stdenv.mkDerivation rec {
     lib.concatMapStrings (path: ''
       for f in : $(find ${path} -type f); do
         test "$f" == ":" && continue;
-        ensureDir $(dirname $out/lib/firmware/$\{f#${path}});
+        mkdir -p $(dirname $out/lib/firmware/$\{f#${path}});
         ln -s $f $out/lib/firmware/$\{f#${path}};
       done;
     '') firmware;
diff --git a/pkgs/os-specific/linux/pmount/default.nix b/pkgs/os-specific/linux/pmount/default.nix
index 9366c2cf95f2c..4d555f59c37e7 100644
--- a/pkgs/os-specific/linux/pmount/default.nix
+++ b/pkgs/os-specific/linux/pmount/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, cryptsetup, dbus, dbus_glib, intltool, ntfs3g, utillinuxng
+{ stdenv, fetchurl, cryptsetup, dbus, dbus_glib, intltool, ntfs3g, utillinux
 , mediaDir ? "/media/"
 , lockDir ? "/var/lock/pmount"
 , whiteList ? "/etc/pmount.allow"
@@ -15,14 +15,14 @@ stdenv.mkDerivation rec {
     sha256 = "db38fc290b710e8e9e9d442da2fb627d41e13b3ee80326c15cc2595ba00ea036";
   };
 
-  buildInputs = [ intltool utillinuxng ];
+  buildInputs = [ intltool utillinux ];
 
   configureFlags = ""
   + " --with-media-dir=${mediaDir}"
   + " --with-lock-dir=${lockDir}"
   + " --with-whitelist=${whiteList}"
-  + " --with-mount-prog=${utillinuxng}/bin/mount"
-  + " --with-umount-prog=${utillinuxng}/bin/umount"
+  + " --with-mount-prog=${utillinux}/bin/mount"
+  + " --with-umount-prog=${utillinux}/bin/umount"
   + " --with-mount-ntfs3g=${ntfs3g}/sbin/mount.ntfs-3g";
 
   postConfigure = ''
diff --git a/pkgs/os-specific/linux/qc-usb/builder.sh b/pkgs/os-specific/linux/qc-usb/builder.sh
index a43138fa84fea..041be11532856 100644
--- a/pkgs/os-specific/linux/qc-usb/builder.sh
+++ b/pkgs/os-specific/linux/qc-usb/builder.sh
@@ -13,7 +13,7 @@ echo "version $version"
 
 export version
 
-ensureDir $out/lib/modules/$version/misc
+mkdir -p $out/lib/modules/$version/misc
 
 LINUX_DIR=$kernel/lib/modules/$version/build
 PREFIX=$out
diff --git a/pkgs/os-specific/linux/radeontools/default.nix b/pkgs/os-specific/linux/radeontools/default.nix
index ff3cad3fe98fd..4dbe7e54247a0 100644
--- a/pkgs/os-specific/linux/radeontools/default.nix
+++ b/pkgs/os-specific/linux/radeontools/default.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation {
   };
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     chmod +x lightwatch.pl
     cp radeontool lightwatch.pl $out/bin
   '';
diff --git a/pkgs/os-specific/linux/sysklogd/builder.sh b/pkgs/os-specific/linux/sysklogd/builder.sh
index 62df45ea7c95f..d466f075652c0 100644
--- a/pkgs/os-specific/linux/sysklogd/builder.sh
+++ b/pkgs/os-specific/linux/sysklogd/builder.sh
@@ -6,8 +6,8 @@ export prefix
 installFlags="BINDIR=$out/sbin MANDIR=$out/share/man INSTALL=install"
 patchPhase="sed -e 's@-o \${MAN_USER} -g \${MAN_GROUP} -m \${MAN_PERMS} @@' -i Makefile"
 
-ensureDir "$out/share/man/man8/"
-ensureDir "$out/share/man/man5/"
-ensureDir "$out/sbin"
+mkdir -p "$out/share/man/man8/"
+mkdir -p "$out/share/man/man5/"
+mkdir -p "$out/sbin"
 
 genericBuild
diff --git a/pkgs/os-specific/linux/tcp-wrapper/builder.sh b/pkgs/os-specific/linux/tcp-wrapper/builder.sh
index 58bc1d4409d13..7ea574fcf2327 100644
--- a/pkgs/os-specific/linux/tcp-wrapper/builder.sh
+++ b/pkgs/os-specific/linux/tcp-wrapper/builder.sh
@@ -22,18 +22,18 @@ echo "building..."
 make REAL_DAEMON_DIR="$out/sbin" linux
 
 # Install
-ensureDir "$out/sbin"
+mkdir -p "$out/sbin"
 cp -v safe_finger tcpd tcpdchk tcpdmatch try-from "$out/sbin"
 
-ensureDir "$out/lib"
+mkdir -p "$out/lib"
 cp -v shared/lib*.so* "$out/lib"
 
-ensureDir "$out/include"
+mkdir -p "$out/include"
 cp -v *.h "$out/include"
 
-ensureDir "$out/man"
+mkdir -p "$out/man"
 for i in 3 5 8;
 do
-  ensureDir "$out/man/man$i"
+  mkdir -p "$out/man/man$i"
   cp *.$i "$out/man/man$i" ;
 done
diff --git a/pkgs/os-specific/linux/tunctl/default.nix b/pkgs/os-specific/linux/tunctl/default.nix
index f4c3aad938f2c..8ea3599ff1984 100644
--- a/pkgs/os-specific/linux/tunctl/default.nix
+++ b/pkgs/os-specific/linux/tunctl/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation {
 
   makeFlags = [ "tunctl" ];
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp tunctl $out/bin
   '';
 
diff --git a/pkgs/os-specific/linux/udisks/default.nix b/pkgs/os-specific/linux/udisks/default.nix
index 30353be390c2a..4987e90429cee 100644
--- a/pkgs/os-specific/linux/udisks/default.nix
+++ b/pkgs/os-specific/linux/udisks/default.nix
@@ -1,7 +1,6 @@
 { stdenv, fetchurl, pkgconfig, sg3_utils, udev, glib, dbus, dbus_glib
 , polkit, parted, lvm2, libatasmart, intltool, libuuid, mdadm
-, libxslt, docbook_xsl, utillinux
-, automake, autoconf, libtool, gtkdoc }:
+, libxslt, docbook_xsl, utillinux }:
 
 stdenv.mkDerivation rec {
   name = "udisks-1.0.4";
@@ -11,33 +10,29 @@ stdenv.mkDerivation rec {
     sha256 = "1xgqifddwaavmjc8c30i0mdffyirsld7c6qhfyjw7f9khwv8jjw5";
   };
 
-  # Move 80-udisks.rules manually to make the patch smaller
-  prePatch = "mv -v data/80-udisks.rules{,.in}";
+  patches = [ ./purity.patch ];
 
-  # Not written a patch that can be accepted upstream yet
-  postPatch = "sed -e 's@/sbin/mdadm@${mdadm}&@' -i data/80-udisks.rules.in";
+  postPatch =
+    ''
+      sed -e 's,/sbin/mdadm,${mdadm}&,g' -e "s,@slashlibdir@,$out/lib,g" -i data/80-udisks.rules
 
-  patches = [ ./purity.patch ];
+      substituteInPlace src/main.c --replace \
+        "/sbin:/bin:/usr/sbin:/usr/bin" \
+        "${utillinux}/bin:${mdadm}/sbin:/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin"
+    '';
 
   buildInputs =
     [ sg3_utils udev glib dbus dbus_glib polkit parted
       lvm2 libatasmart intltool libuuid libxslt docbook_xsl
     ];
 
-  buildNativeInputs = [ automake autoconf libtool gtkdoc pkgconfig ];
+  buildNativeInputs = [ pkgconfig ];
 
   configureFlags = "--localstatedir=/var --enable-lvm2";
 
   preConfigure =
     ''
       # Ensure that udisks can find the necessary programs.
-      substituteInPlace src/main.c --replace \
-        "/sbin:/bin:/usr/sbin:/usr/bin" \
-        "${utillinux}/bin:${mdadm}/sbin:/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin"
-
-      # The patch above modifies Makefile.am, so redo the whole thing.
-      # FIXME: Remove that ASAP---e.g., by writing the patch differently.
-      autoreconf -vfi
     '';
 
   meta = {
diff --git a/pkgs/os-specific/linux/udisks/purity.patch b/pkgs/os-specific/linux/udisks/purity.patch
index 1896c757557a8..bf1121ddb6590 100644
--- a/pkgs/os-specific/linux/udisks/purity.patch
+++ b/pkgs/os-specific/linux/udisks/purity.patch
@@ -1,7 +1,7 @@
-diff --git a/data/80-udisks.rules.in b/data/80-udisks.rules.in
+diff --git a/data/80-udisks.rules b/data/80-udisks.rules
 index 6720394..60b67ed 100644
---- a/data/80-udisks.rules.in
-+++ b/data/80-udisks.rules.in
+--- a/data/80-udisks.rules
++++ b/data/80-udisks.rules
 @@ -23,7 +23,7 @@ LABEL="ata_port_cardbus_end"
  #  this is the case we can trigger a 'change' on the sas_expander device
  #  when the bsg device appears)
@@ -55,20 +55,3 @@ index 6720394..60b67ed 100644
  
  
  # Example rule for tagging a device with a specific media type. Where and
-diff --git a/data/Makefile.am b/data/Makefile.am
-index ca6d8ac..ed9faa3 100644
---- a/data/Makefile.am
-+++ b/data/Makefile.am
-@@ -25,7 +25,11 @@ $(dbusconf_DATA): $(dbusconf_in_files) Makefile
- 	cp $< $@
- 
- udevrulesdir = $(slashlibdir)/udev/rules.d
--udevrules_DATA = 80-udisks.rules
-+udevrules_in_files = 80-udisks.rules.in
-+udevrules_DATA =  $(udevrules_in_files:.rules.in=.rules)
-+
-+$(udevrules_DATA): $(udevrules_in_files) Makefile
-+	@sed -e "s|\@slashlibdir\@|$(slashlibdir)|g" $< > $@
- 
- pkgconfigdir = $(datadir)/pkgconfig
- pkgconfig_DATA = udisks.pc
diff --git a/pkgs/os-specific/linux/upower/default.nix b/pkgs/os-specific/linux/upower/default.nix
index 32698ac4efbe1..2679d23d76e16 100644
--- a/pkgs/os-specific/linux/upower/default.nix
+++ b/pkgs/os-specific/linux/upower/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, xz, pkgconfig, glib, dbus, dbus_glib, polkit
+{ stdenv, fetchurl, pkgconfig, glib, dbus, dbus_glib, polkit
 , intltool, libxslt, docbook_xsl, udev, libusb1, pmutils }:
 
 assert stdenv.isLinux;
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ dbus_glib polkit intltool libxslt docbook_xsl udev libusb1 ];
 
-  buildNativeInputs = [ xz pkgconfig ];
+  buildNativeInputs = [ pkgconfig ];
 
   configureFlags = "--with-backend=linux --localstatedir=/var";
 
diff --git a/pkgs/os-specific/linux/util-linux-ng/default.nix b/pkgs/os-specific/linux/util-linux/default.nix
index 4e62be4ff32dd..bd6f26dc58b23 100644
--- a/pkgs/os-specific/linux/util-linux-ng/default.nix
+++ b/pkgs/os-specific/linux/util-linux/default.nix
@@ -1,11 +1,13 @@
-{ stdenv, fetchurl, ncurses ? null, perl ? null }:
+{ stdenv, fetchurl, zlib, ncurses ? null, perl ? null }:
 
 stdenv.mkDerivation rec {
-  name = "util-linux-ng-2.18";
+  name = "util-linux-2.20.1";
 
   src = fetchurl {
-    url = "mirror://kernel/linux/utils/util-linux-ng/v2.18/${name}.tar.bz2";
-    sha256 = "1k1in1ba9kvh0kplri9765wh0yk68qrkk1a55dqsm21qfryc1idq";
+    # This used to be mirror://kernel/linux/utils/util-linux, but it
+    # disappeared in the kernel.org meltdown.
+    url = "mirror://gentoo/distfiles/${name}.tar.bz2";
+    sha256 = "1q5vjcvw4f067c63vj2n3xggvk5prm11571x6vnqiav47vdbqvni";
   };
 
   # !!! It would be better to obtain the path to the mount helpers
@@ -19,6 +21,6 @@ stdenv.mkDerivation rec {
     ${if ncurses == null then "--without-ncurses" else ""}
   '';
 
-  buildInputs = stdenv.lib.optional (ncurses != null) ncurses
+  buildInputs = [ zlib ] ++ stdenv.lib.optional (ncurses != null) ncurses
              ++ stdenv.lib.optional (perl != null) perl;
 }
diff --git a/pkgs/os-specific/linux/wis-go7007/default.nix b/pkgs/os-specific/linux/wis-go7007/default.nix
index 73e5694572af9..4fff3ed37c0c1 100644
--- a/pkgs/os-specific/linux/wis-go7007/default.nix
+++ b/pkgs/os-specific/linux/wis-go7007/default.nix
@@ -61,9 +61,9 @@ stdenv.mkDerivation {
     substituteInPlace Makefile \
         --replace '$(DESTDIR)$(KSRC)/include/linux' $includeDir \
         --replace '$(DESTDIR)$(FIRMWARE_DIR)' '$(FIRMWARE_DIR)'
-    ensureDir $includeDir
-    ensureDir $out/etc/hotplug/usb
-    ensureDir $out/etc/udev/rules.d
+    mkdir -p $includeDir
+    mkdir -p $out/etc/hotplug/usb
+    mkdir -p $out/etc/udev/rules.d
  
     makeFlagsArray=(KERNELSRC=$kernelSource \
         FIRMWARE_DIR=$out/firmware FXLOAD=${fxload}/sbin/fxload \
@@ -72,7 +72,7 @@ stdenv.mkDerivation {
   ''; # */
 
   postInstall = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp apps/gorecord apps/modet $out/bin/
   '';
 
diff --git a/pkgs/os-specific/linux/wpa_supplicant/default.nix b/pkgs/os-specific/linux/wpa_supplicant/default.nix
index b99f36c950a50..522478ed5b774 100644
--- a/pkgs/os-specific/linux/wpa_supplicant/default.nix
+++ b/pkgs/os-specific/linux/wpa_supplicant/default.nix
@@ -42,10 +42,10 @@ stdenv.mkDerivation rec {
     ];
 
   postInstall = ''
-    ensureDir $out/share/man/man5 $out/share/man/man8
+    mkdir -p $out/share/man/man5 $out/share/man/man8
     cp -v doc/docbook/*.5 $out/share/man/man5/
     cp -v doc/docbook/*.8 $out/share/man/man8/
-    ensureDir $out/etc/dbus-1/system.d $out/share/dbus-1/system-services
+    mkdir -p $out/etc/dbus-1/system.d $out/share/dbus-1/system-services
     cp -v dbus/*service $out/share/dbus-1/system-services
     sed -e "s@/sbin/wpa_supplicant@$out&@" -i $out/share/dbus-1/system-services/*
     cp -v dbus/dbus-wpa_supplicant.conf $out/etc/dbus-1/system.d
diff --git a/pkgs/os-specific/linux/xf86-input-multitouch/default.nix b/pkgs/os-specific/linux/xf86-input-multitouch/default.nix
index f04297096d2f8..c5cc5f3b68f0c 100644
--- a/pkgs/os-specific/linux/xf86-input-multitouch/default.nix
+++ b/pkgs/os-specific/linux/xf86-input-multitouch/default.nix
@@ -36,7 +36,7 @@ stdenv.mkDerivation {
 
   installPhase = ''
     make DESTDIR="$out" LIBDIR="lib" install
-    ensureDir $out/include/xorg
+    mkdir -p $out/include/xorg
     echo -n "$confFile" > $out/include/xorg/10-multitouch.conf
   '';
 
diff --git a/pkgs/os-specific/linux/xf86-input-wacom/default.nix b/pkgs/os-specific/linux/xf86-input-wacom/default.nix
index 9cc25174c51fb..98446c708671c 100644
--- a/pkgs/os-specific/linux/xf86-input-wacom/default.nix
+++ b/pkgs/os-specific/linux/xf86-input-wacom/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
     ncurses pkgconfig randrproto xorgserver xproto udev ];
 
   preConfigure = ''
-    ensureDir $out/share/X11/xorg.conf.d
+    mkdir -p $out/share/X11/xorg.conf.d
     configureFlags="--with-xorg-module-dir=$out/lib/xorg/modules
     --with-sdkdir=$out/include/xorg --with-xorg-conf-dir=$out/share/X11/xorg.conf.d"
   '';
diff --git a/pkgs/os-specific/linux/zen-kernel/2.6.32-zen4.nix b/pkgs/os-specific/linux/zen-kernel/2.6.32-zen4.nix
deleted file mode 100644
index 78a36c73ca558..0000000000000
--- a/pkgs/os-specific/linux/zen-kernel/2.6.32-zen4.nix
+++ /dev/null
@@ -1,75 +0,0 @@
-args @ {stdenv, fetchurl, xz, runCommand, userModeLinux ? false, extraConfig ? "", 
-  kernelPatches ? [], extraMeta ? {}, 
-  features ? {}, preConfigure ? "",
-  ...}:
-
-let 
-  conf = import ./config-blocks.nix; 
-
-in
-
-import ../kernel/generic.nix (
-  rec {
-    version = "2.6.32-zen4";
-
-    src = fetchurl {
-      url = "mirror://kernel/linux/kernel/v2.6/linux-2.6.32.tar.bz2";
-      sha256 = "0kjhnkf2ldivagczs16q49zm2lr3khh01pqrlsc7sh5qh1npi6ah";
-    };
-
-    kernelPatches = [
-      {
-         name = "zen4"; 
-         patch = runCommand "2.6.32-zen4.patch" {} "${xz}/bin/lzma -d < ${ fetchurl {
-	   name = "2.6.32-zen4";
-           url = "http://downloads.zen-kernel.org/2.6.32/2.6.32-zen4.patch.lzma";
-           sha256 = "1dyp9sfigqjfqw1c94010c521bhcy1xnzp91kkhg3dwgzfpsp2k2";
-         } } > $out";
-      }
-    ]
-    ++
-    stdenv.lib.attrByPath ["kernelPatches"] [] args;
-
-    features = {
-      iwlwifi = true;
-      zen = true;
-      fbConDecor = true;
-      aufs = true;
-    } // (stdenv.lib.attrByPath ["features"] {} args);
-
-    config = with conf;
-    ''
-      ${generalOptions}
-      ${noDebug}
-      ${virtualisation}
-      ${if stdenv.lib.attrByPath ["features" "oldI686"] false args then noPAE else ""}
-      ${usefulSubsystems}
-      ${cfq}
-      ${noNUMA}
-      ${networking}
-      ${wireless}
-      ${fb}
-      ${fbConDecor}
-      ${sound}
-      ${usbserial}
-      ${fsXattr}
-      ${security}
-      ${blockDevices}
-      ${bluetooth}
-      ${misc}
-      ${if stdenv.lib.attrByPath ["features" "ckSched"] false args then bfsched else forceCFSched}
-    '';
-
-    preConfigure = ''
-      mv README.zen README-zen
-    '' + stdenv.lib.attrByPath ["preConfigure"] "" args;
-
-    extraMeta = {
-      maintainers = [stdenv.lib.maintainers.raskin];
-      platforms = with stdenv.lib.platforms;
-        linux;
-    } // stdenv.lib.attrByPath ["extraMeta"] {} args;
-  } 
-  // removeAttrs args ["extraConfig" "extraMeta" "features" "kernelPatches" 
-                        "xz" "runCommand" "preConfigure"]
-)
diff --git a/pkgs/os-specific/linux/zen-kernel/2.6.33-zen1.nix b/pkgs/os-specific/linux/zen-kernel/2.6.33-zen1.nix
deleted file mode 100644
index 5c1a315cb387d..0000000000000
--- a/pkgs/os-specific/linux/zen-kernel/2.6.33-zen1.nix
+++ /dev/null
@@ -1,78 +0,0 @@
-args @ {stdenv, fetchurl, xz, runCommand, userModeLinux ? false, extraConfig ? "", 
-  kernelPatches ? [], extraMeta ? {}, 
-  features ? {}, preConfigure ? "",
-  ...}:
-
-let 
-  conf = import ./config-blocks.nix; 
-
-  baseKernelVersion = "2.6.33";
-  ZenSuffix = "zen1";
-
-in
-
-import ../kernel/generic.nix (
-  rec {
-    version = "${baseKernelVersion}-${ZenSuffix}";
-
-    src = fetchurl {
-      url = "mirror://kernel/linux/kernel/v2.6/linux-${baseKernelVersion}.tar.bz2";
-      sha256 = "1inmam21w13nyf5imgdb5palhiap41zcxf9k32i4ck1w7gg3gqk3";
-    };
-
-    kernelPatches = [
-      {
-         name = "${ZenSuffix}"; 
-         patch = runCommand "${baseKernelVersion}-${ZenSuffix}.patch" {} "${xz}/bin/lzma -d < ${ fetchurl {
-	   name = "${baseKernelVersion}-${ZenSuffix}.patch.lzma";
-           url = "http://downloads.zen-kernel.org/${baseKernelVersion}/${baseKernelVersion}-${ZenSuffix}.patch.lzma";
-           sha256 = "0a72d8allr4qi4p6hbbjh33kmcgbg84as0dfb50gsffvaj2d3kwf";
-         } } > $out";
-      }
-    ]
-    ++
-    stdenv.lib.attrByPath ["kernelPatches"] [] args;
-
-    features = {
-      iwlwifi = true;
-      zen = true;
-      fbConDecor = true;
-      aufs = true;
-    } // (stdenv.lib.attrByPath ["features"] {} args);
-
-    config = with conf;
-    ''
-      ${generalOptions}
-      ${noDebug}
-      ${virtualisation}
-      ${if stdenv.lib.attrByPath ["features" "oldI686"] false args then noPAE else ""}
-      ${usefulSubsystems}
-      ${cfq}
-      ${noNUMA}
-      ${networking}
-      ${wireless}
-      ${fb}
-      ${fbConDecor}
-      ${sound}
-      ${usbserial}
-      ${fsXattr}
-      ${security}
-      ${blockDevices}
-      ${bluetooth}
-      ${misc}
-      ${if stdenv.lib.attrByPath ["features" "ckSched"] false args then bfsched else forceCFSched}
-    '';
-
-    preConfigure = ''
-      mv README.zen README-zen
-    '' + stdenv.lib.attrByPath ["preConfigure"] "" args;
-
-    extraMeta = {
-      maintainers = [stdenv.lib.maintainers.raskin];
-      platforms = with stdenv.lib.platforms;
-        linux;
-    } // stdenv.lib.attrByPath ["extraMeta"] {} args;
-  } 
-  // removeAttrs args ["extraConfig" "extraMeta" "features" "kernelPatches" 
-                        "xz" "runCommand" "preConfigure"]
-)
diff --git a/pkgs/os-specific/linux/zen-kernel/config-blocks.nix b/pkgs/os-specific/linux/zen-kernel/config-blocks.nix
deleted file mode 100644
index f330325c91b16..0000000000000
--- a/pkgs/os-specific/linux/zen-kernel/config-blocks.nix
+++ /dev/null
@@ -1,263 +0,0 @@
-rec {
-      generalOptions = ''
-        # Don't include any debug features.
-        DEBUG_KERNEL n
-
-        # Support drivers that need external firmware.
-        STANDALONE n
-
-        # Make /proc/config.gz available.
-        IKCONFIG_PROC y
-
-        # Optimize with -O2, not -Os.
-        CC_OPTIMIZE_FOR_SIZE n
-
-        # Enable the kernel's built-in memory tester.
-        MEMTEST y
-
-        KALLSYMS_EXTRA_PASS n
-      '';
-      
-      virtualisation = ''
-        # Virtualisation (KVM, Xen...).
-        PARAVIRT_GUEST y
-        KVM_CLOCK y
-        KVM_GUEST y
-        XEN? y
-        KSM y
-
-        # We need 64 GB (PAE) support for Xen guest support.
-        HIGHMEM64G? y
-      '';
-
-      noPAE = ''
-        HIGHMEM64G? n
-        PAE? n
-      '';
-
-      usefulSubsystems = ''
-        # Enable various subsystems.
-        ACCESSIBILITY y # Accessibility support
-        AUXDISPLAY y # Auxiliary Display support
-        DONGLE y # Serial dongle support
-        HIPPI y
-        MTD_COMPLEX_MAPPINGS y # needed for many devices
-        NET_POCKET y # enable pocket and portable adapters
-        SCSI_LOWLEVEL y # enable lots of SCSI devices
-        SCSI_LOWLEVEL_PCMCIA y
-        SPI y # needed for many devices
-        SPI_MASTER y
-        WAN y
-      '';
-
-      cfq = ''
-        # Include the CFQ I/O scheduler in the kernel, rather than as a
-        # module, so that the initrd gets a good I/O scheduler.
-        IOSCHED_CFQ y
-      '';
-
-      noDebug = ''
-        # Disable some expensive (?) features.
-        FTRACE n
-        KPROBES n
-        PM_TRACE_RTC n
-
-        AIC79XX_DEBUG_ENABLE n
-        AIC7XXX_DEBUG_ENABLE n
-        AIC94XX_DEBUG n
-        USB_DEBUG n
-        CPU_FREQ_DEBUG n
-      '';
-
-      noNUMA = ''
-        NUMA? n
-      '';
-
-      networking = ''
-        # Networking options.
-        IP_PNP n
-        IPV6_PRIVACY y
-        NETFILTER_ADVANCED y
-        IP_VS_PROTO_TCP y
-        IP_VS_PROTO_UDP y
-        IP_VS_PROTO_ESP y
-        IP_VS_PROTO_AH y
-        IP_DCCP_CCID3 n # experimental
-        CLS_U32_PERF y
-        CLS_U32_MARK y
-      '';
-
-      wireless = ''
-        # Wireless networking.
-        IPW2100_MONITOR y # support promiscuous mode
-        IPW2200_MONITOR y # support promiscuous mode
-        IWLWIFI_LEDS? y
-        IWLWIFI_SPECTRUM_MEASUREMENT y
-        IWL3945_SPECTRUM_MEASUREMENT y
-        IWL4965 y # Intel Wireless WiFi 4965AGN
-        IWL5000 y # Intel Wireless WiFi 5000AGN
-        HOSTAP_FIRMWARE y # Support downloading firmware images with Host AP driver
-        HOSTAP_FIRMWARE_NVRAM y
-      '';
-
-      fb = ''
-        # Enable various FB devices.
-        FB y
-        FB_EFI y
-        FB_NVIDIA_I2C y # Enable DDC Support
-        FB_RIVA_I2C y
-        FB_ATY_CT y # Mach64 CT/VT/GT/LT (incl. 3D RAGE) support
-        FB_ATY_GX y # Mach64 GX support
-        FB_SAVAGE_I2C y
-        FB_SAVAGE_ACCEL y
-        FB_SIS_300 y
-        FB_SIS_315 y
-        FB_3DFX_ACCEL y
-        FB_GEODE y
-      '';
-
-      fbNoTileBlit = ''
-        # Disable tileblitting
-        FB_TILEBLITTING n
-        FB_S3 n
-        FB_VT8623 n
-        FB_ARK n
-      '';
-
-      fbConDecor = ''
-        ${fb}
-        ${fbNoTileBlit}
-        FRAMEBUFFER_CONSOLE y
-        FB_VESA y
-        FB_CON_DECOR y
-      '';
-
-      sound = ''
-        # Sound.
-        SND_AC97_POWER_SAVE y # AC97 Power-Saving Mode
-        SND_HDA_INPUT_BEEP y # Support digital beep via input layer
-        SND_USB_CAIAQ_INPUT y
-        PSS_MIXER y # Enable PSS mixer (Beethoven ADSP-16 and other compatible)
-      '';
-
-      usbserial = ''
-        # USB serial devices.
-        USB_SERIAL_GENERIC y # USB Generic Serial Driver
-        USB_SERIAL_KEYSPAN_MPR y # include firmware for various USB serial devices
-        USB_SERIAL_KEYSPAN_USA28 y
-        USB_SERIAL_KEYSPAN_USA28X y
-        USB_SERIAL_KEYSPAN_USA28XA y
-        USB_SERIAL_KEYSPAN_USA28XB y
-        USB_SERIAL_KEYSPAN_USA19 y
-        USB_SERIAL_KEYSPAN_USA18X y
-        USB_SERIAL_KEYSPAN_USA19W y
-        USB_SERIAL_KEYSPAN_USA19QW y
-        USB_SERIAL_KEYSPAN_USA19QI y
-        USB_SERIAL_KEYSPAN_USA49W y
-        USB_SERIAL_KEYSPAN_USA49WLC y
-      '';
-
-      fsXattr = ''
-        # Filesystem options - in particular, enable extended attributes and
-        # ACLs for all filesystems that support them.
-        EXT2_FS_XATTR y # Ext2 extended attributes
-        EXT2_FS_POSIX_ACL y # Ext2 POSIX Access Control Lists
-        EXT2_FS_SECURITY y # Ext2 Security Labels
-        EXT2_FS_XIP y # Ext2 execute in place support
-        EXT4_FS_POSIX_ACL y
-        EXT4_FS_SECURITY y
-        REISERFS_FS_XATTR y
-        REISERFS_FS_POSIX_ACL y
-        REISERFS_FS_SECURITY y
-        JFS_POSIX_ACL y
-        JFS_SECURITY y
-        XFS_QUOTA y
-        XFS_POSIX_ACL y
-        XFS_RT y # XFS Realtime subvolume support
-        OCFS2_DEBUG_MASKLOG n
-        OCFS2_FS_POSIX_ACL? y
-        BTRFS_FS_POSIX_ACL y
-        UBIFS_FS_XATTR y
-        UBIFS_FS_ADVANCED_COMPR y
-        NFSD_V2_ACL y
-        NFSD_V3 y
-        NFSD_V3_ACL y
-        NFSD_V4 y
-        CIFS_XATTR y
-        CIFS_POSIX y
-      '';
-
-      security = ''
-        # Security related features.
-        STRICT_DEVMEM y # Filter access to /dev/mem
-        SECURITY_SELINUX_BOOTPARAM_VALUE 0 # disable SELinux by default
-      '';
-
-      blockDevices = ''
-        BLK_DEV_BSG n
-        BLK_DEV_CMD640_ENHANCED y # CMD640 enhanced support
-        BLK_DEV_IDEACPI y # IDE ACPI support
-        BLK_DEV_INTEGRITY y
-      '';
-
-      bluetooth = ''
-        BT_HCIUART_BCSP y
-        BT_HCIUART_H4 y # UART (H4) protocol support
-        BT_HCIUART_LL y
-        BT_RFCOMM_TTY y # RFCOMM TTY support
-      '';
-
-      misc = ''
-        # Misc. options.
-        8139TOO_8129 y
-        8139TOO_PIO n # PIO is slower
-        B43_PCMCIA y
-        BSD_PROCESS_ACCT_V3 y
-        CRASH_DUMP n
-        DMAR? n # experimental
-        DVB_DYNAMIC_MINORS y # we use udev
-        FUSION y # Fusion MPT device support
-        IDE_GD_ATAPI y # ATAPI floppy support
-        IRDA_ULTRA y # Ultra (connectionless) protocol
-        JOYSTICK_IFORCE_232 y # I-Force Serial joysticks and wheels
-        JOYSTICK_IFORCE_USB y # I-Force USB joysticks and wheels
-        JOYSTICK_XPAD_FF y # X-Box gamepad rumble support
-        JOYSTICK_XPAD_LEDS y # LED Support for Xbox360 controller 'BigX' LED
-        LDM_PARTITION y # Windows Logical Disk Manager (Dynamic Disk) support
-        LEDS_TRIGGER_IDE_DISK y # LED IDE Disk Trigger
-        LOGIRUMBLEPAD2_FF y # Logitech Rumblepad 2 force feedback
-        LOGO n # not needed
-        MEDIA_ATTACH y
-        MEGARAID_NEWGEN y
-        MICROCODE_AMD y
-        MODVERSIONS y
-        MOUSE_PS2_ELANTECH y # Elantech PS/2 protocol extension
-        MTRR_SANITIZER y
-        NET_FC y # Fibre Channel driver support
-        PCI_LEGACY y
-        PPP_MULTILINK y # PPP multilink support
-        REGULATOR y # Voltage and Current Regulator Support
-        SCSI_LOGGING y # SCSI logging facility
-        SERIAL_8250 y # 8250/16550 and compatible serial support
-        SLIP_COMPRESSED y # CSLIP compressed headers
-        SLIP_SMART y
-        THERMAL_HWMON y # Hardware monitoring support
-        USB_EHCI_ROOT_HUB_TT y # Root Hub Transaction Translators
-        X86_CHECK_BIOS_CORRUPTION y
-        X86_MCE y
-      '';
-
-      bfsched = ''
-        SCHED_BFS y
-        NO_HZ n
-        HZ_1000 n
-        HZ_300 y
-        HZ 300
-      '';
-
-      forceCFSched = ''
-        SCHED_CFS? y
-        SCHED_BFS? n
-        NO_HZ? y
-      '';
-}
diff --git a/pkgs/os-specific/windows/mingw-headers/default.nix b/pkgs/os-specific/windows/mingw-headers/default.nix
index c4e0063feecb8..c6941ef01f0a7 100644
--- a/pkgs/os-specific/windows/mingw-headers/default.nix
+++ b/pkgs/os-specific/windows/mingw-headers/default.nix
@@ -6,7 +6,7 @@ stdenv.mkDerivation {
   phases = [ "installPhase" ];
 
   installPhase = ''
-    ensureDir $out/include
+    mkdir -p $out/include
     cp -R ${mingw_runtime_headers}/include/* $out/include
     cp -R ${w32api_headers}/include/* $out/include
   '';
diff --git a/pkgs/os-specific/windows/mingwrt/default.nix b/pkgs/os-specific/windows/mingwrt/default.nix
index e5b42c29467a7..286c63d01637f 100644
--- a/pkgs/os-specific/windows/mingwrt/default.nix
+++ b/pkgs/os-specific/windows/mingwrt/default.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation (rec {
   name = name + "-headers";
   phases = [ "unpackPhase" "installPhase" ];
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp -R include $out
   '';
 } else {
diff --git a/pkgs/os-specific/windows/w32api/default.nix b/pkgs/os-specific/windows/w32api/default.nix
index 09484911bc1a6..a4f4245125d90 100644
--- a/pkgs/os-specific/windows/w32api/default.nix
+++ b/pkgs/os-specific/windows/w32api/default.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation ({
   name = name + "-headers";
   phases = [ "unpackPhase" "installPhase" ];
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp -R include $out
   '';
 } else {
diff --git a/pkgs/servers/dict/dictd-db-collector.nix b/pkgs/servers/dict/dictd-db-collector.nix
index 299bfc8ac2f75..f635c98602d96 100644
--- a/pkgs/servers/dict/dictd-db-collector.nix
+++ b/pkgs/servers/dict/dictd-db-collector.nix
@@ -25,7 +25,7 @@ let
 		}
 	";
 	installPhase = ''  
-  	ensureDir $out/share/dictd
+  	mkdir -p $out/share/dictd
 	cd $out/share/dictd
 	echo "${databases}" >databases.names 
 	echo "${accessSection}" > dictd.conf
diff --git a/pkgs/servers/dict/dictd-db.nix b/pkgs/servers/dict/dictd-db.nix
index 553b371d24c3a..c6c0bc73a08a3 100644
--- a/pkgs/servers/dict/dictd-db.nix
+++ b/pkgs/servers/dict/dictd-db.nix
@@ -5,7 +5,7 @@ with builderDefs;
 	let localDefs = builderDefs.passthru.function (rec {
 		src=_src;
 		doInstall = fullDepEntry (''
-			ensureDir $out/share/dictd
+			mkdir -p $out/share/dictd
 			tar xf  ${src}
 			cp $(ls ./${_subdir}/*.{dict*,index} || true) $out/share/dictd 
 			echo "${_locale}" >$out/share/dictd/locale
diff --git a/pkgs/servers/felix/default.nix b/pkgs/servers/felix/default.nix
index c600573ba86e2..aa40365e8deaf 100644
--- a/pkgs/servers/felix/default.nix
+++ b/pkgs/servers/felix/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
   ''
     tar xfvz $src
     cd felix-framework-*
-    ensureDir $out
+    mkdir -p $out
     cp -av * $out
   '';
   meta = {
diff --git a/pkgs/servers/felix/remoteshell.nix b/pkgs/servers/felix/remoteshell.nix
index 4d6a8d8318f7e..6e8089d32e977 100644
--- a/pkgs/servers/felix/remoteshell.nix
+++ b/pkgs/servers/felix/remoteshell.nix
@@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
   };
   buildCommand = 
   ''
-    ensureDir $out/bundle
+    mkdir -p $out/bundle
     cp ${src} $out/bundle/org.apache.felix.shell.remote-1.0.4.jar
   '';
 }
diff --git a/pkgs/servers/fingerd/bsd-fingerd/default.nix b/pkgs/servers/fingerd/bsd-fingerd/default.nix
index 5e5d91fa82051..2fab0fd9910cc 100644
--- a/pkgs/servers/fingerd/bsd-fingerd/default.nix
+++ b/pkgs/servers/fingerd/bsd-fingerd/default.nix
@@ -16,5 +16,5 @@ stdenv.mkDerivation rec {
 
   preBuild = "cd fingerd";
 
-  preInstall = '' ensureDir $out/man/man8 $out/sbin '';
+  preInstall = '' mkdir -p $out/man/man8 $out/sbin '';
 }
diff --git a/pkgs/servers/games/ghost-one/default.nix b/pkgs/servers/games/ghost-one/default.nix
index 2fd9a45dfc0ec..f90b5e4099734 100644
--- a/pkgs/servers/games/ghost-one/default.nix
+++ b/pkgs/servers/games/ghost-one/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
     make
     cd ../../../StormLib/stormlib/
     make
-    ensureDir $out/lib
+    mkdir -p $out/lib
     cd ../..
 #    cp bncsutil/src/bncsutil/libbncutil.so $out/lib
 #    cp StormLib/stormlib/libStorm.so $out/lib
@@ -30,14 +30,14 @@ stdenv.mkDerivation rec {
   '';
 
   installPhase = ''
-    ensureDir $out/lib
+    mkdir -p $out/lib
     cp bncsutil/src/bncsutil/libbncsutil.so $out/lib
     cp StormLib/stormlib/libStorm.so $out/lib
 
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp ghost/ghost++ $out/bin
 
-    ensureDir $out/share/ghost-one/languages
+    mkdir -p $out/share/ghost-one/languages
     cp -r mapcfgs $out/share/ghost-one
     cp Languages/*.cfg $out/share/ghost-one/languages
     cp language.cfg $out/share/ghost-one/languages/English.cfg
diff --git a/pkgs/servers/http/apache-modules/mod_python/default.nix b/pkgs/servers/http/apache-modules/mod_python/default.nix
index a59fa60c4c7b0..b36327ff5205e 100644
--- a/pkgs/servers/http/apache-modules/mod_python/default.nix
+++ b/pkgs/servers/http/apache-modules/mod_python/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation {
 
   preInstall = ''
     installFlags="LIBEXECDIR=$out/modules $installFlags"
-    ensureDir $out/modules
+    mkdir -p $out/modules
   '';
 
   passthru = { inherit apacheHttpd; };
diff --git a/pkgs/servers/http/apache-modules/tomcat-connectors/builder.sh b/pkgs/servers/http/apache-modules/tomcat-connectors/builder.sh
index 70b609e64656a..52efe537c9bda 100644
--- a/pkgs/servers/http/apache-modules/tomcat-connectors/builder.sh
+++ b/pkgs/servers/http/apache-modules/tomcat-connectors/builder.sh
@@ -4,5 +4,5 @@ tar xfvz $src
 cd tomcat-connectors-*-src/native
 ./configure --with-apxs=$apacheHttpd/bin/apxs --with-java-home=$jdk
 make
-ensureDir $out/modules
+mkdir -p $out/modules
 cp apache-2.0/mod_jk.so $out/modules
diff --git a/pkgs/servers/http/jboss/default.nix b/pkgs/servers/http/jboss/default.nix
index 41eff4cf967f1..2f0b9be96b04d 100644
--- a/pkgs/servers/http/jboss/default.nix
+++ b/pkgs/servers/http/jboss/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
   '';
   
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp -av * $out
   '';
   
diff --git a/pkgs/servers/http/jboss/jdbc/mysql/builder.sh b/pkgs/servers/http/jboss/jdbc/mysql/builder.sh
index 06d60fc5e126b..6af39a0cb6338 100644
--- a/pkgs/servers/http/jboss/jdbc/mysql/builder.sh
+++ b/pkgs/servers/http/jboss/jdbc/mysql/builder.sh
@@ -1,5 +1,5 @@
 buildInputs="$mysql_jdbc"
 source $stdenv/setup
 
-ensureDir $out/server/default/lib
+mkdir -p $out/server/default/lib
 ln -s $mysql_jdbc/share/java/mysql-connector-java.jar $out/server/default/lib/mysql-connector-java.jar
diff --git a/pkgs/servers/http/jetty/6.1/bin-builder.sh b/pkgs/servers/http/jetty/6.1/bin-builder.sh
index d19f42eb45cdd..bec0663bee78c 100644
--- a/pkgs/servers/http/jetty/6.1/bin-builder.sh
+++ b/pkgs/servers/http/jetty/6.1/bin-builder.sh
@@ -3,5 +3,5 @@ set -e
 source $stdenv/setup
 
 unzip $src
-ensureDir $out/$name
+mkdir -p $out/$name
 mv jetty*/* $out/$name
diff --git a/pkgs/servers/http/joseki/default.nix b/pkgs/servers/http/joseki/default.nix
index 0a83dd09601f5..1a7e6f6d16c24 100644
--- a/pkgs/servers/http/joseki/default.nix
+++ b/pkgs/servers/http/joseki/default.nix
@@ -72,12 +72,12 @@ rec {
 
     mv lib/slf4j-simple-*.jar lib/obsolete
 
-    ensureDir "$out/share"
+    mkdir -p "$out/share"
     TARGET="$out/share/${name}-dist"
     cp -r . "$TARGET"
     ln -s  "$TARGET/lib" "$out/lib"
     chmod a+x "$TARGET/bin/"*
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
 
     echo -e '#! /bin/sh\nls "'"$TARGET"'"/bin' > "$out/bin/jena-list-commands"
     echo '#! /bin/sh' >> "$out/bin/jena-command"
diff --git a/pkgs/servers/http/myserver/default.nix b/pkgs/servers/http/myserver/default.nix
index 32526ddf65de4..b6aff880e62ed 100644
--- a/pkgs/servers/http/myserver/default.nix
+++ b/pkgs/servers/http/myserver/default.nix
@@ -1,5 +1,5 @@
 { fetchurl, stdenv, libgcrypt, libevent, libidn, gnutls
-, libxml2, zlib, guile, texinfo, cppunit, xz, psmisc }:
+, libxml2, zlib, guile, texinfo, cppunit, psmisc }:
 
 let version = "0.11"; in
   stdenv.mkDerivation (rec {
@@ -14,7 +14,7 @@ let version = "0.11"; in
       [ ./disable-dns-lookup-in-chroot.patch ];
 
     buildInputs =
-      [ libgcrypt libevent libidn gnutls libxml2 zlib guile texinfo xz ]
+      [ libgcrypt libevent libidn gnutls libxml2 zlib guile texinfo ]
       ++ stdenv.lib.optional doCheck cppunit;
 
     makeFlags = [ "V=1" ];
diff --git a/pkgs/servers/http/tomcat/axis2/builder.sh b/pkgs/servers/http/tomcat/axis2/builder.sh
index 91d300822a770..2e36367e9dcf5 100644
--- a/pkgs/servers/http/tomcat/axis2/builder.sh
+++ b/pkgs/servers/http/tomcat/axis2/builder.sh
@@ -2,12 +2,12 @@ source $stdenv/setup
 
 unzip $src
 cd axis2-*
-ensureDir $out
+mkdir -p $out
 cp -av * $out
 cd webapp
 ant
 cd ..
-ensureDir $out/webapps
+mkdir -p $out/webapps
 cp dist/axis2.war $out/webapps
 cd $out/webapps
 mkdir axis2
diff --git a/pkgs/servers/http/tomcat/jdbc/mysql/builder.sh b/pkgs/servers/http/tomcat/jdbc/mysql/builder.sh
index 4a7248dfc8d50..14829c5e85d81 100644
--- a/pkgs/servers/http/tomcat/jdbc/mysql/builder.sh
+++ b/pkgs/servers/http/tomcat/jdbc/mysql/builder.sh
@@ -1,4 +1,4 @@
 source $stdenv/setup
 
-ensureDir $out/lib
+mkdir -p $out/lib
 ln -s $mysql_jdbc/share/java/mysql-connector-java.jar $out/lib/mysql-connector-java.jar
diff --git a/pkgs/servers/mail/postfix/default.nix b/pkgs/servers/mail/postfix/default.nix
index 0fa2bf821a4e8..16d9127e5561c 100644
--- a/pkgs/servers/mail/postfix/default.nix
+++ b/pkgs/servers/mail/postfix/default.nix
@@ -21,7 +21,7 @@ stdenv.mkDerivation {
   '';
   
   postInstall = ''
-    ensureDir $out
+    mkdir -p $out
     mv ut/$out/* $out/
 
     mkdir $out/share/postfix/conf
diff --git a/pkgs/servers/monitoring/zabbix/default.nix b/pkgs/servers/monitoring/zabbix/default.nix
index 0e695c6c107af..864f11bee3ed4 100644
--- a/pkgs/servers/monitoring/zabbix/default.nix
+++ b/pkgs/servers/monitoring/zabbix/default.nix
@@ -33,11 +33,11 @@ in
 
     postInstall =
       ''
-        ensureDir $out/share/zabbix
+        mkdir -p $out/share/zabbix
         cp -prvd frontends/php $out/share/zabbix/php
-        ensureDir $out/share/zabbix/db/data
+        mkdir -p $out/share/zabbix/db/data
         cp -prvd create/data/*.sql $out/share/zabbix/db/data
-        ensureDir $out/share/zabbix/db/schema
+        mkdir -p $out/share/zabbix/db/schema
         cp -prvd create/schema/*.sql $out/share/zabbix/db/schema
       '';
 
diff --git a/pkgs/servers/portmap/default.nix b/pkgs/servers/portmap/default.nix
index 9d8a641b4a8a4..aaa9bb684f4e9 100644
--- a/pkgs/servers/portmap/default.nix
+++ b/pkgs/servers/portmap/default.nix
@@ -25,7 +25,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ tcpWrapper ];
 
   installPhase = ''
-    ensureDir "$out/sbin" && ensureDir "$out/man/man8" && \
+    mkdir -p "$out/sbin" && ensureDir "$out/man/man8" && \
     make install BASEDIR=$out
   '';
 
diff --git a/pkgs/servers/pulseaudio/default.nix b/pkgs/servers/pulseaudio/default.nix
index 13d0af8987ce9..2111225059756 100644
--- a/pkgs/servers/pulseaudio/default.nix
+++ b/pkgs/servers/pulseaudio/default.nix
@@ -3,7 +3,7 @@
 , alsaLib, libsamplerate, libsndfile, speex, bluez, udev
 , jackaudioSupport ? false, jackaudio ? null
 , x11Support ? false, xlibs
-, xz, json_c
+, json_c
 }:
 
 assert jackaudioSupport -> jackaudio != null;
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
   buildInputs =
     [ pkgconfig gnum4 libtool intltool glib dbus avahi
       libsamplerate libsndfile speex alsaLib bluez udev
-      xz json_c
+      json_c
       #gtk gconf 
     ]
     ++ stdenv.lib.optional jackaudioSupport jackaudio
diff --git a/pkgs/servers/sql/mysql/jdbc/builder.sh b/pkgs/servers/sql/mysql/jdbc/builder.sh
index 29ecbc1aebe3d..56336e041356f 100644
--- a/pkgs/servers/sql/mysql/jdbc/builder.sh
+++ b/pkgs/servers/sql/mysql/jdbc/builder.sh
@@ -5,5 +5,5 @@ set -e
 unzip $src
 cd mysql-connector-java-*
 
-ensureDir $out/share/java
+mkdir -p $out/share/java
 cp mysql-connector-java-*-bin.jar $out/share/java/mysql-connector-java.jar
diff --git a/pkgs/servers/sql/postgresql/jdbc/builder.sh b/pkgs/servers/sql/postgresql/jdbc/builder.sh
index 318a4e637a0e8..2fccb68662901 100755
--- a/pkgs/servers/sql/postgresql/jdbc/builder.sh
+++ b/pkgs/servers/sql/postgresql/jdbc/builder.sh
@@ -6,5 +6,5 @@ tar zxvf $src
 cd postgresql-jdbc-*
 ant
 
-ensureDir $out/share/java
+mkdir -p $out/share/java
 cp jars/*.jar $out/share/java
diff --git a/pkgs/servers/x11/xorg/builder.sh b/pkgs/servers/x11/xorg/builder.sh
index c33d1806fd602..bb776a5051bd0 100644
--- a/pkgs/servers/x11/xorg/builder.sh
+++ b/pkgs/servers/x11/xorg/builder.sh
@@ -32,7 +32,7 @@ postInstall() {
         fi
     done
 
-    ensureDir "$out/nix-support"
+    mkdir -p "$out/nix-support"
     echo "$propagatedBuildInputs" > "$out/nix-support/propagated-build-inputs"
     echo "$propagatedBuildNativeInputs" > "$out/nix-support/propagated-build-native-inputs"
 }
diff --git a/pkgs/servers/x11/xorg/imake.sh b/pkgs/servers/x11/xorg/imake.sh
index 131ce0e832ca8..4ab5e2ae160ba 100644
--- a/pkgs/servers/x11/xorg/imake.sh
+++ b/pkgs/servers/x11/xorg/imake.sh
@@ -1,5 +1,5 @@
 preInstall() {
-    ensureDir $out/lib/X11/config
+    mkdir -p $out/lib/X11/config
     ln -s $xorgcffiles/lib/X11/config/* $out/lib/X11/config
     #touch $out/lib/X11/config/host.def # !!! hack
     #touch $out/lib/X11/config/date.def # !!! hack
diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix
index f260ce90cb541..a1d2040483d0b 100644
--- a/pkgs/servers/x11/xorg/overrides.nix
+++ b/pkgs/servers/x11/xorg/overrides.nix
@@ -114,7 +114,7 @@ in
   setxkbmap = attrs: attrs // {
     postInstall =
       ''
-        ensureDir $out/share
+        mkdir -p $out/share
         ln -sfn ${args.xkeyboard_config}/etc/X11 $out/share/X11
       '';
   };
diff --git a/pkgs/servers/xmpp/pyIRCt/default.nix b/pkgs/servers/xmpp/pyIRCt/default.nix
index 161942519e809..27982601f73a9 100644
--- a/pkgs/servers/xmpp/pyIRCt/default.nix
+++ b/pkgs/servers/xmpp/pyIRCt/default.nix
@@ -19,7 +19,7 @@ rec {
   /* doConfigure should be removed if not needed */
   phaseNames = ["deploy" (a.makeManyWrappers "$out/share/${name}/irc.py" a.pythonWrapperArguments)];
   deploy = a.fullDepEntry (''
-    ensureDir $out/bin $out/share/${name}
+    mkdir -p $out/bin $out/share/${name}
     sed -e 's@/usr/bin/@${a.python}/bin/@' -i irc.py
     sed -e '/configFiles/aconfigFiles += [os.getenv("HOME")+"/.pyIRCt.xml"]' -i config.py
     sed -e '/configFiles/aconfigFiles += [os.getenv("HOME")+"/.python-irc-transport.xml"]' -i config.py
diff --git a/pkgs/servers/xmpp/pyMAILt/default.nix b/pkgs/servers/xmpp/pyMAILt/default.nix
index a4dcd5a481273..e763d2dce5b12 100644
--- a/pkgs/servers/xmpp/pyMAILt/default.nix
+++ b/pkgs/servers/xmpp/pyMAILt/default.nix
@@ -21,7 +21,7 @@ rec {
   phaseNames = ["deploy" (a.makeManyWrappers "$out/share/${name}/mail.py" a.pythonWrapperArguments)];
   deploy = a.fullDepEntry (''
     cd mail-transport
-    ensureDir $out/bin $out/share/${name}
+    mkdir -p $out/bin $out/share/${name}
     sed -e 's@/usr/bin/@${a.python}/bin/@' -i mail.py
     sed -e '/configFiles/aconfigFiles += [os.getenv("HOME")+"/.pyMAILt.xml"]' -i config.py
     sed -e '/configFiles/aconfigFiles += [os.getenv("HOME")+"/.python-mail-transport.xml"]' -i config.py
diff --git a/pkgs/shells/bash/4.1.nix b/pkgs/shells/bash/4.1.nix
deleted file mode 100644
index 02fb29c5dabae..0000000000000
--- a/pkgs/shells/bash/4.1.nix
+++ /dev/null
@@ -1,89 +0,0 @@
-{ stdenv, fetchurl, readline ? null, interactive ? false, texinfo ? null, bison }:
-
-assert interactive -> readline != null;
-
-let
-  realName = "bash-4.1";
-  baseConfigureFlags = if interactive then "--with-installed-readline" else "--disable-readline";
-in
-
-stdenv.mkDerivation rec {
-  name = "${realName}-p${toString (builtins.length patches)}";
-
-  src = fetchurl {
-    url = "mirror://gnu/bash/${realName}.tar.gz";
-    sha256 = "1np1ggp1lv8idwfx3mcxl9rhadqdf4h3x4isa3dk8v9wm0j72qiz";
-  };
-
-  NIX_CFLAGS_COMPILE = ''
-    -DSYS_BASHRC="/etc/bashrc"
-    -DSYS_BASH_LOGOUT="/etc/bash_logout"
-    -DDEFAULT_PATH_VALUE="/no-such-path"
-    -DSTANDARD_UTILS_PATH="/no-such-path"
-    -DNON_INTERACTIVE_LOGIN_SHELLS
-    -DSSH_SOURCE_BASHRC
-  '';
-
-  patchFlags = "-p0";
-
-  patches =
-    let
-      patch = nr: sha256:
-        fetchurl {
-          url = "mirror://gnu/bash/bash-4.1-patches/bash41-${nr}";
-          inherit sha256;
-        };
-    in
-      import ./bash-4.1-patches.nix patch;
-
-  crossAttrs = {
-    configureFlags = baseConfigureFlags +
-      " bash_cv_job_control_missing=nomissing bash_cv_sys_named_pipes=nomissing";
-  };
-
-  configureFlags = baseConfigureFlags;
-
-  # Note: Bison is needed because the patches above modify parse.y.
-  buildNativeInputs = [bison]
-    ++ stdenv.lib.optional (texinfo != null) texinfo
-    ++ stdenv.lib.optional interactive readline;
-
-  postInstall = ''
-    # Add an `sh' -> `bash' symlink.
-    ln -s bash "$out/bin/sh"
-
-  '' + (if interactive then "" else ''
-    # Install the completion examples.
-    ensureDir "$out/etc"
-    cp -v "examples/complete/bash_completion" "$out/etc"
-
-    ensureDir "$out/etc/bash_completion.d"
-    cp -v "examples/complete/complete.gnu-longopt" "$out/etc/bash_completion.d"
-  '');
-
-  meta = {
-    homepage = http://www.gnu.org/software/bash/;
-    description =
-      "GNU Bourne-Again Shell, the de facto standard shell on Linux" +
-        (if interactive then " (for interactive use)" else "");
-
-    longDescription = ''
-      Bash is the shell, or command language interpreter, that will
-      appear in the GNU operating system.  Bash is an sh-compatible
-      shell that incorporates useful features from the Korn shell
-      (ksh) and C shell (csh).  It is intended to conform to the IEEE
-      POSIX P1003.2/ISO 9945.2 Shell and Tools standard.  It offers
-      functional improvements over sh for both programming and
-      interactive use.  In addition, most sh scripts can be run by
-      Bash without modification.
-    '';
-
-    license = "GPLv3+";
-
-    maintainers = [ stdenv.lib.maintainers.ludo stdenv.lib.maintainers.simons ];
-  };
-
-  passthru = {
-    shellPath = "/bin/bash";
-  };
-}
diff --git a/pkgs/shells/bash/bash-4.1-patches.nix b/pkgs/shells/bash/bash-4.1-patches.nix
deleted file mode 100644
index d22435744ccc9..0000000000000
--- a/pkgs/shells/bash/bash-4.1-patches.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-# Automatically generated by `update-patch-set.sh'; do not edit.
-
-patch: [
-(patch "001" "0y02cbfnc5s3dnwr4fw2nz43f3b826f5084mk7qd0lzq12hpzr56")
-(patch "002" "1y3qzw6lx16vnb8hrw3zx01z25k773cbmgysvs3vvcw6w6fj4bij")
-]
diff --git a/pkgs/shells/bash/bash-4.2-patches.nix b/pkgs/shells/bash/bash-4.2-patches.nix
index 7f4957c500c30..0a21018653204 100644
--- a/pkgs/shells/bash/bash-4.2-patches.nix
+++ b/pkgs/shells/bash/bash-4.2-patches.nix
@@ -11,4 +11,14 @@ patch: [
 (patch "008" "0dr4p83m2xpxhvd61yny0gdlasq6r9mpyiz220998y0alq8hs213")
 (patch "009" "086b9jkyjgf2zhwln72d7s5x759iskgg3r4hdrw6b5y1ni059vg7")
 (patch "010" "1p23m9kssdmpnjfp96bjmmshzf25cdzlyjygdw8j6sayqa159z5c")
+(patch "011" "0chm4r6zv2kafq1g8xs7r0gixmw9h9r63rgd38rdgfvyk8ssx4d4")
+(patch "012" "1f5pp64rv4mx3r34577pmb15pyxvhmdhmliccnwz20nssbqk6i1m")
+(patch "013" "1sl5rxl3kz39xbnbaf0085jcx0l19l2yqjk0ja2wirmwrg3ca4il")
+(patch "014" "0cwb5ilgx1gcbvnfk93pcpyhvq5wzasyvyllbxrk51c517k7i9mm")
+(patch "015" "164afkc75534x1ad1h6qkl511k2cpirqs2kyx1jddwxx0j1nm1rd")
+(patch "016" "19p20g7h7563m79vvy0adkpzlaxg192affzsm1rxm67wyyycr598")
+(patch "017" "0zzfva20hxfrj5njd321pcjfydiv0kzcqryxfdh1sxlc95228mbk")
+(patch "018" "0ka9pfnjmdak8lvmbryv2r1kkrlffnxbqjxq656la39pf9qlbag2")
+(patch "019" "0mpb0whacppwcdx7pcnf0ah5vjvkw14ang6r2rh9fmkn401cvdx8")
+(patch "020" "0vrwv9wpbr692kf427npmsxzvn007d9alk6jf99v7307s3q76is9")
 ]
diff --git a/pkgs/shells/bash/4.2.nix b/pkgs/shells/bash/default.nix
index 98fe43b0122a5..98fe43b0122a5 100644
--- a/pkgs/shells/bash/4.2.nix
+++ b/pkgs/shells/bash/default.nix
diff --git a/pkgs/shells/zsh/default.nix b/pkgs/shells/zsh/default.nix
index 6b199e165d0dc..4fd717fa936de 100644
--- a/pkgs/shells/zsh/default.nix
+++ b/pkgs/shells/zsh/default.nix
@@ -27,9 +27,9 @@ stdenv.mkDerivation {
 
   # XXX: think/discuss about this, also with respect to nixos vs nix-on-X
   postInstall = ''
-    ensureDir $out/share/
+    mkdir -p $out/share/
     tar xf ${documentation} -C $out/share
-    ensureDir $out/etc/
+    mkdir -p $out/etc/
     cat > $out/etc/zprofile <<EOF
 if test -e /etc/NIXOS; then
   if test -r /etc/zprofile; then
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix
index a1e8aafd7bc6d..dc9314f6885c3 100644
--- a/pkgs/stdenv/adapters.nix
+++ b/pkgs/stdenv/adapters.nix
@@ -83,10 +83,10 @@ rec {
           + " --disable-shared"; # brrr...
 
         NIX_GCC = runCommand "klibc-wrapper" {} ''
-          ensureDir $out/bin
+          mkdir -p $out/bin
           ln -s ${klibc}/bin/klcc $out/bin/gcc
           ln -s ${klibc}/bin/klcc $out/bin/cc
-          ensureDir $out/nix-support
+          mkdir -p $out/nix-support
           echo 'PATH=$PATH:${stdenv.gcc.binutils}/bin' > $out/nix-support/setup-hook
         '';
       });
@@ -109,13 +109,14 @@ rec {
     } // {inherit fetchurl;};
 
     
-  # Return a modified stdenv that enables building static libraries.
-  enableStaticLibraries = stdenv: stdenv //
+  # Return a modified stdenv that builds static libraries instead of
+  # shared libraries.
+  makeStaticLibraries = stdenv: stdenv //
     { mkDerivation = args: stdenv.mkDerivation (args // {
         dontDisableStatic = true;
         configureFlags =
-          (if args ? configureFlags then args.configureFlags else "")
-          + " --enable-static";
+          (if args ? configureFlags then toString args.configureFlags else "")
+          + " --enable-static --disable-shared";
       });
     } // {inherit fetchurl;};
 
@@ -208,7 +209,7 @@ rec {
 
         moveBuildDir =
           ''
-            ensureDir $out/.build
+            mkdir -p $out/.build
             cd $out/.build
           '';
       } stdenv;
diff --git a/pkgs/stdenv/common-path.nix b/pkgs/stdenv/common-path.nix
index 3b267a543c664..cff6fd0a3eed1 100644
--- a/pkgs/stdenv/common-path.nix
+++ b/pkgs/stdenv/common-path.nix
@@ -11,5 +11,5 @@
   pkgs.gnumake
   pkgs.bash
   pkgs.patch
-  pkgs.replace
+  pkgs.xz
 ]
diff --git a/pkgs/stdenv/generic/builder.sh b/pkgs/stdenv/generic/builder.sh
index 23cc2a0775f5b..fd4c17ca25191 100644
--- a/pkgs/stdenv/generic/builder.sh
+++ b/pkgs/stdenv/generic/builder.sh
@@ -1,35 +1,19 @@
-p1=$param1
-p2=$param2
-p3=$param3
-p4=$param4
-p5=$param5
-_preHook="$preHook"
-_postHook="$postHook"
-preHook=
-postHook=
-
 export PATH=
 for i in $initialPath; do
-    if test "$i" = /; then i=; fi
+    if [ "$i" = / ]; then i=; fi
     PATH=$PATH${PATH:+:}$i/bin
 done
 
 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^@initialPath@^$initialPath^g" \
+echo "$preHook" > $out/setup
+cat "$setup" >> $out/setup
+
+sed -e "s^@initialPath@^$initialPath^g" \
     -e "s^@gcc@^$gcc^g" \
     -e "s^@shell@^$shell^g" \
-    -e "s^@param1@^$p1^g" \
-    -e "s^@param2@^$p2^g" \
-    -e "s^@param3@^$p3^g" \
-    -e "s^@param4@^$p4^g" \
-    -e "s^@param5@^$p5^g" \
-    < "$setup" > "$out/setup"
+    < $out/setup > $out/setup.tmp
+mv $out/setup.tmp $out/setup
 
 # Allow the user to install stdenv using nix-env and get the packages
 # in stdenv.
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index 6ffdaa91c62df..f2abf294de13d 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -1,6 +1,5 @@
-{ system, name, preHook ? null, postHook ? null, initialPath, gcc, shell
-, param1 ? "", param2 ? "", param3 ? "", param4 ? "", param5 ? ""
-, extraAttrs ? {}, overrides ? {}
+{ system, name ? "stdenv", preHook ? "", initialPath, gcc, shell
+, extraAttrs ? {}, overrides ? (pkgs: {})
 
 , # The `fetchurl' to use for downloading curl and its dependencies
   # (see all-packages.nix).
@@ -25,10 +24,7 @@ let
 
         setup = setupScript;
 
-        inherit preHook postHook initialPath gcc shell;
-
-        # TODO: make this more elegant.
-        inherit param1 param2 param3 param4 param5;
+        inherit preHook initialPath gcc shell;
 
         propagatedUserEnvPkgs = [gcc] ++
           lib.filter lib.isDerivation initialPath;
@@ -91,8 +87,8 @@ let
 
         # Utility flags to test the type of platform.
         isDarwin = result.system == "i686-darwin"
-	       || result.system == "powerpc-darwin"
-	       || result.system == "x86_64-darwin";
+               || result.system == "powerpc-darwin"
+               || result.system == "x86_64-darwin";
         isLinux = result.system == "i686-linux"
                || result.system == "x86_64-linux"
                || result.system == "powerpc-linux"
@@ -101,14 +97,14 @@ let
         isSunOS = result.system == "i686-solaris"
                || result.system == "x86_64-solaris";
         isCygwin = result.system == "i686-cygwin";
-	isFreeBSD = result.system == "i686-freebsd"
-	       || result.system == "x86_64-freebsd";
-	isOpenBSD = result.system == "i686-openbsd"
-	       || result.system == "x86_64-openbsd";
-	isBSD = result.system == "i686-freebsd"
-	       || result.system == "x86_64-freebsd"
-	       || result.system == "i686-openbsd"
-	       || result.system == "x86_64-openbsd";
+        isFreeBSD = result.system == "i686-freebsd"
+               || result.system == "x86_64-freebsd";
+        isOpenBSD = result.system == "i686-openbsd"
+               || result.system == "x86_64-openbsd";
+        isBSD = result.system == "i686-freebsd"
+               || result.system == "x86_64-freebsd"
+               || result.system == "i686-openbsd"
+               || result.system == "x86_64-openbsd";
         isi686 = result.system == "i686-linux"
                || result.system == "i686-darwin"
                || result.system == "i686-freebsd"
diff --git a/pkgs/stdenv/generic/docs.txt b/pkgs/stdenv/generic/docs.txt
deleted file mode 100644
index 060f3cd154b9d..0000000000000
--- a/pkgs/stdenv/generic/docs.txt
+++ /dev/null
@@ -1,93 +0,0 @@
-* genericBuild performs a generic build of (typically) autotool-style
-  packages
-
-  
-* unpack phase
-
-** may be overriden by setting $unpackPhase to point at a function that
-   unpacks the source (which should set $sourceRoot)
-
-** the generic unpacker unpacks all sources specified by $srcs, or
-   $src if $srcs is empty
-
-** supports tar, bzipped tar, gzipped tar, compressed tar, zip
-
-** zip must be in scope (in $buildinputs)
-
-** additional file types may be supported by setting $findUnpacker,
-   which is called with a single argument specifying the file to be
-   unpacked
-
-** $findUnpacker should set $unpackCmd, specifying the full command to
-   unpack the file (must include the file name)
-
-** alternatively, $unpackCmd can be set before calling the generic
-   builder (e.g., 'unpackCmd="unrar x $src"'); this only works if
-   there is a single source file
-
-** the generic unpacker then sets $sourceRoot to the name of the
-   directory created by unpacking the source archives
-
-** the source archives should produce only one directory
-
-** alternatively, $setSourceRoot may be set to a function that sets
-   $sourceRoot
-
-
-* the generic builder then chdirs to $sourceRoot
-
-
-* patch phase (skipped if neither $patchPhase nor $patches are set)
-
-** may be overriden by setting $patchPhase to point at a function that
-   unpacks the source (which should set $sourceRoot)
-
-** if the $patches variable is set, it runs `patch -p1 < ...' in
-   $sourceRoot for each element in $patches (the `patch' command
-   should be in $PATH; note that it isn't in the standard environment)
-
-
-* configuration phase
-
-** may be overriden by setting $configurePhase to point at a function
-
-** calls $preConfigurer first, if set (useful for running
-   autoconf/automake)
-
-** the configure script is specified by $configureScript, which
-   defaults to ./configure
-   
-** if no executable file exists at $configureScript, does nothing
-
-** if a file ./ltmain.sh exists and $dontFixLibtool is not set, calls
-   function fixLibtool to remove its default search path (/usr etc.)
-
-** adds "--prefix=$out" to $configureFlags unless $dontAddPrefix is
-   set
-
-** calls $configureScript with $configureFlags
-
-** calls $postConfigurer, if set (useful for any last-minute patches
-   prior to building)
-
-
-* build phase
-
-** may be overriden by setting $buildPhase to point at a function
-
-** runs make with flags $makeFlags
-
-
-* install phase
-
-** may be overriden by setting $installPhase to point at a function
-
-** runs make with flags $installFlags
-
-** unless $dontStrip is set or $NIX_STRIP_DEBUG is not 1, finds all *.a
-   files in $out and runs "strip -S" on them (executables and dynamic
-   libraries can be stripped automatically by setting NIX_STRIP_DEBUG
-   to 1 (default))
-
-** if $propagatedBuildInputs is set, its contents are written to
-   $out/nix-support/propagated-build-inputs
diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh
index ba06666ca8987..655b7f9404764 100644
--- a/pkgs/stdenv/generic/setup.sh
+++ b/pkgs/stdenv/generic/setup.sh
@@ -19,7 +19,7 @@ exitHandler() {
 
     closeNest
 
-    if test -n "$showBuildStats"; then
+    if [ -n "$showBuildStats" ]; then
         times > "$NIX_BUILD_TOP/.times"
         local -a times=($(cat "$NIX_BUILD_TOP/.times"))
         # Print the following statistics:
@@ -30,16 +30,16 @@ exitHandler() {
         echo "build time elapsed: " ${times[*]}
     fi
     
-    if test $exitCode != 0; then
+    if [ $exitCode != 0 ]; then
         runHook failureHook
     
         # If the builder had a non-zero exit code and
         # $succeedOnFailure is set, create the file
         # `$out/nix-support/failed' to signal failure, and exit
         # normally.  Otherwise, return the original exit code.
-        if test -n "$succeedOnFailure"; then
+        if [ -n "$succeedOnFailure" ]; then
             echo "build failed with exit code $exitCode (ignored)"
-            ensureDir "$out/nix-support"
+            mkdir -p "$out/nix-support"
             echo -n $exitCode > "$out/nix-support/failed"
             exit 0
         fi
@@ -79,11 +79,7 @@ addToSearchPath() {
 
 set -e
 
-# Check that the directory pointed by HOME, usually '/homeless-shelter',
-# does not exist, as it may be a good source for impurities.
-! test -e $HOME
-
-test -z $NIX_GCC && NIX_GCC=@gcc@
+[ -z $NIX_GCC ] && NIX_GCC=@gcc@
 
 
 # Wildcard expansions that don't match should expand to an empty list.
@@ -95,37 +91,29 @@ shopt -s nullglob
 # Set up the initial path.
 PATH=
 for i in $NIX_GCC @initialPath@; do
-    if test "$i" = /; then i=; fi
+    if [ "$i" = / ]; then i=; fi
     addToSearchPath PATH $i/bin
 done
 
-if test "$NIX_DEBUG" = "1"; then
+if [ "$NIX_DEBUG" = 1 ]; then
     echo "initial path: $PATH"
 fi
 
 
 # Execute the pre-hook.
 export SHELL=@shell@
-if test -z "$shell"; then
-    export shell=@shell@
-fi
-param1=@param1@
-param2=@param2@
-param3=@param3@
-param4=@param4@
-param5=@param5@
-if test -n "@preHook@"; then source @preHook@; fi
+if [ -z "$shell" ]; then export shell=@shell@; fi
 runHook preHook
 
 
 # Check that the pre-hook initialised SHELL.
-if test -z "$SHELL"; then echo "SHELL not set"; exit 1; fi
+if [ -z "$SHELL" ]; then echo "SHELL not set"; exit 1; fi
 
 
 # Hack: run gcc's setup hook.
 envHooks=()
 crossEnvHooks=()
-if test -f $NIX_GCC/nix-support/setup-hook; then
+if [ -f $NIX_GCC/nix-support/setup-hook ]; then
     source $NIX_GCC/nix-support/setup-hook
 fi
 
@@ -134,12 +122,12 @@ fi
 ensureDir() {
     local dir
     for dir in "$@"; do
-        if ! test -x "$dir"; then mkdir -p "$dir"; fi
+        if ! [ -x "$dir" ]; then mkdir -p "$dir"; fi
     done
 }
 
 installBin() {
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp "$@" $out/bin
 }
 
@@ -164,11 +152,11 @@ findInputs() {
 
     eval $var="'${!var} $pkg '"
 
-    if test -f $pkg/nix-support/setup-hook; then
+    if [ -f $pkg/nix-support/setup-hook ]; then
         source $pkg/nix-support/setup-hook
     fi
 
-    if test -f $pkg/nix-support/$propagatedBuildInputsFile; then
+    if [ -f $pkg/nix-support/$propagatedBuildInputsFile ]; then
         for i in $(cat $pkg/nix-support/$propagatedBuildInputsFile); do
             findInputs $i $var $propagatedBuildInputsFile
         done
@@ -185,12 +173,13 @@ for i in $buildNativeInputs $propagatedBuildNativeInputs; do
     findInputs $i nativePkgs propagated-build-native-inputs
 done
 
+
 # Set the relevant environment variables to point to the build inputs
 # found above.
 addToNativeEnv() {
     local pkg=$1
 
-    if test -d $1/bin; then
+    if [ -d $1/bin ]; then
         addToSearchPath _PATH $1/bin
     fi
 
@@ -210,7 +199,7 @@ addToCrossEnv() {
     # Some programs put important build scripts (freetype-config and similar)
     # into their hostDrv bin path. Intentionally these should go after
     # the nativePkgs in PATH.
-    if test -d $1/bin; then
+    if [ -d $1/bin ]; then
         addToSearchPath _PATH $1/bin
     fi
 
@@ -226,24 +215,17 @@ done
 
 
 # Add the output as an rpath.
-if test "$NIX_NO_SELF_RPATH" != "1"; then
+if [ "$NIX_NO_SELF_RPATH" != 1 ]; then
     export NIX_LDFLAGS="-rpath $out/lib $NIX_LDFLAGS"
-    if test -n "$NIX_LIB64_IN_SELF_RPATH"; then
+    if [ -n "$NIX_LIB64_IN_SELF_RPATH" ]; then
         export NIX_LDFLAGS="-rpath $out/lib64 $NIX_LDFLAGS"
     fi
-    if test -n "$NIX_LIB32_IN_SELF_RPATH"; then
+    if [ -n "$NIX_LIB32_IN_SELF_RPATH" ]; then
         export NIX_LDFLAGS="-rpath $out/lib32 $NIX_LDFLAGS"
     fi
 fi
 
 
-# Strip debug information by default.
-if test -z "$NIX_STRIP_DEBUG"; then
-    export NIX_STRIP_DEBUG=1
-    export NIX_CFLAGS_STRIP="-g0 -Wl,--strip-debug"
-fi
-
-
 # Set the TZ (timezone) environment variable, otherwise commands like
 # `date' will complain (e.g., `Tue Mar 9 10:01:47 Local time zone must
 # be set--see zic manual page 2004').
@@ -253,17 +235,17 @@ export TZ=UTC
 # Set the prefix.  This is generally $out, but it can be overriden,
 # for instance if we just want to perform a test build/install to a
 # temporary location and write a build report to $out.
-if test -z "$prefix"; then
+if [ -z "$prefix" ]; then
     prefix="$out";
 fi
 
-if test "$useTempPrefix" = "1"; then
+if [ "$useTempPrefix" = 1 ]; then
     prefix="$NIX_BUILD_TOP/tmp_prefix";
 fi
 
 
 PATH=$_PATH${_PATH:+:}$PATH
-if test "$NIX_DEBUG" = "1"; then
+if [ "$NIX_DEBUG" = 1 ]; then
     echo "final path: $PATH"
 fi
 
@@ -276,9 +258,9 @@ export NIX_INDENT_MAKE=1
 # means that we're supposed to try and auto-detect the number of
 # available CPU cores at run-time.
 
-if test -z "${NIX_BUILD_CORES:-}"; then
+if [ -z "${NIX_BUILD_CORES:-}" ]; then
   NIX_BUILD_CORES="1"
-elif test "$NIX_BUILD_CORES" -le 0; then
+elif [ "$NIX_BUILD_CORES" -le 0 ]; then
   NIX_BUILD_CORES=$(nproc 2>/dev/null || true)
   if expr >/dev/null 2>&1 "$NIX_BUILD_CORES" : "^[0-9][0-9]*$"; then
     :
@@ -299,13 +281,13 @@ stripDirs() {
     local dirsNew=
 
     for d in ${dirs}; do
-        if test -d "$prefix/$d"; then
+        if [ -d "$prefix/$d" ]; then
             dirsNew="${dirsNew} $prefix/$d "
         fi
     done
     dirs=${dirsNew}
 
-    if test -n "${dirs}"; then
+    if [ -n "${dirs}" ]; then
         header "stripping (with flags $stripFlags) in $dirs"
         find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} strip $stripFlags || true
         stopNest
@@ -322,43 +304,39 @@ substitute() {
     local output="$2"
 
     local -a params=("$@")
-    local -a args=()
 
     local n p pattern replacement varName
 
+    local content="$(cat $input)"
+
     for ((n = 2; n < ${#params[*]}; n += 1)); do
         p=${params[$n]}
 
-        if test "$p" = "--replace"; then
+        if [ "$p" = --replace ]; then
             pattern="${params[$((n + 1))]}"
             replacement="${params[$((n + 2))]}"
             n=$((n + 2))
         fi
 
-        if test "$p" = "--subst-var"; then
+        if [ "$p" = --subst-var ]; then
             varName="${params[$((n + 1))]}"
             pattern="@$varName@"
             replacement="${!varName}"
             n=$((n + 1))
         fi
 
-        if test "$p" = "--subst-var-by"; then
+        if [ "$p" = --subst-var-by ]; then
             pattern="@${params[$((n + 1))]}@"
             replacement="${params[$((n + 2))]}"
             n=$((n + 2))
         fi
 
-        if test ${#args[@]} != 0; then
-            args[${#args[@]}]="-a"
-        fi
-        args[${#args[@]}]="$pattern"
-        args[${#args[@]}]="$replacement"
+        content="${content//"$pattern"/$replacement}"
     done
 
-    replace-literal -e -s -- "${args[@]}" < "$input" > "$output".tmp
-    if test -x "$output"; then
-        chmod +x "$output".tmp
-    fi
+    # !!! This doesn't work properly if $content is "-n".
+    echo -n "$content" > "$output".tmp
+    if [ -x "$output" ]; then chmod +x "$output".tmp; fi
     mv -f "$output".tmp "$output"
 }
 
@@ -376,7 +354,7 @@ substituteAll() {
 
     # Select all environment variables that start with a lowercase character.
     for envVar in $(env | sed "s/^[^a-z].*//" | sed "s/^\([^=]*\)=.*/\1/"); do
-        if test "$NIX_DEBUG" = "1"; then
+        if [ "$NIX_DEBUG" = "1" ]; then
             echo "$envVar -> ${!envVar}"
         fi
         args="$args --subst-var $envVar"
@@ -386,6 +364,13 @@ substituteAll() {
 }
 
 
+substituteAllInPlace() {
+    local fileName="$1"
+    shift
+    substituteAll "$fileName" "$fileName" "$@"
+}
+
+
 ######################################################################
 # What follows is the generic builder.
 
@@ -394,12 +379,12 @@ nestingLevel=0
 
 startNest() {
     nestingLevel=$(($nestingLevel + 1))
-    echo -en "\e[$1p"
+    echo -en "\033[$1p"
 }
 
 stopNest() {
     nestingLevel=$(($nestingLevel - 1))
-    echo -en "\e[q"
+    echo -en "\033[q"
 }
 
 header() {
@@ -410,7 +395,7 @@ header() {
 # Make sure that even when we exit abnormally, the original nesting
 # level is properly restored.
 closeNest() {
-    while test $nestingLevel -gt 0; do
+    while [ $nestingLevel -gt 0 ]; do
         stopNest
     done
 }
@@ -422,7 +407,7 @@ closeNest() {
 # then go to the build directory and source in `env-vars' to reproduce
 # the environment used for building.
 dumpVars() {
-    if test "$noDumpEnvVars" != "1"; then
+    if [ "$noDumpEnvVars" != 1 ]; then
         export > "$NIX_BUILD_TOP/env-vars"
     fi
 }
@@ -445,20 +430,24 @@ unpackFile() {
     header "unpacking source archive $curSrc" 3
 
     case "$curSrc" in
+        *.tar.xz | *.tar.lzma)
+            # Don't rely on tar knowing about .xz.
+            xz -d < $curSrc | tar xvf -
+            ;;
         *.tar | *.tar.* | *.tgz | *.tbz2)
-	    # GNU tar can automatically select the decompression method
-	    # (info "(tar) gzip").
+            # GNU tar can automatically select the decompression method
+            # (info "(tar) gzip").
             tar xvf $curSrc
             ;;
         *.zip)
             unzip $curSrc
             ;;
         *)
-            if test -d "$curSrc"; then
+            if [ -d "$curSrc" ]; then
                 stripHash $curSrc
                 cp -prvd $curSrc $strippedName
             else
-                if test -z "$unpackCmd"; then
+                if [ -z "$unpackCmd" ]; then
                     echo "source archive $curSrc has unknown type"
                     exit 1
                 fi
@@ -474,8 +463,8 @@ unpackFile() {
 unpackPhase() {
     runHook preUnpack
     
-    if test -z "$srcs"; then
-        if test -z "$src"; then
+    if [ -z "$srcs" ]; then
+        if [ -z "$src" ]; then
             echo 'variable $src or $srcs should point to the source'
             exit 1
         fi
@@ -488,7 +477,7 @@ unpackPhase() {
     # it's rather hacky.
     local dirsBefore=""
     for i in *; do
-        if test -d "$i"; then
+        if [ -d "$i" ]; then
             dirsBefore="$dirsBefore $i "
         fi
     done
@@ -499,17 +488,17 @@ unpackPhase() {
     done
 
     # Find the source directory.
-    if test -n "$setSourceRoot"; then
+    if [ -n "$setSourceRoot" ]; then
         runHook setSourceRoot
-    elif test -z "$sourceRoot"; then
+    elif [ -z "$sourceRoot" ]; then
         sourceRoot=
         for i in *; do
-            if test -d "$i"; then
+            if [ -d "$i" ]; then
                 case $dirsBefore in
                     *\ $i\ *)
                         ;;
                     *)
-                        if test -n "$sourceRoot"; then
+                        if [ -n "$sourceRoot" ]; then
                             echo "unpacker produced multiple directories"
                             exit 1
                         fi
@@ -520,7 +509,7 @@ unpackPhase() {
         done
     fi
 
-    if test -z "$sourceRoot"; then
+    if [ -z "$sourceRoot" ]; then
         echo "unpacker appears to have produced no directories"
         exit 1
     fi
@@ -530,7 +519,7 @@ unpackPhase() {
     # By default, add write permission to the sources.  This is often
     # necessary when sources have been copied from other store
     # locations.
-    if test "$dontMakeSourcesWritable" != 1; then
+    if [ "$dontMakeSourcesWritable" != 1 ]; then
         chmod -R u+w "$sourceRoot"
     fi
 
@@ -541,7 +530,7 @@ unpackPhase() {
 patchPhase() {
     runHook prePatch
     
-    if test -z "$patchPhase" -a -z "$patches"; then return; fi
+    if [ -z "$patchPhase" -a -z "$patches" ]; then return; fi
     
     for i in $patches; do
         header "applying patch $i" 3
@@ -573,34 +562,34 @@ fixLibtool() {
 configurePhase() {
     runHook preConfigure
 
-    if test -z "$configureScript"; then
+    if [ -z "$configureScript" ]; then
         configureScript=./configure
-        if ! test -x $configureScript; then
+        if ! [ -x $configureScript ]; then
             echo "no configure script, doing nothing"
             return
         fi
     fi
 
-    if test -z "$dontFixLibtool"; then
+    if [ -z "$dontFixLibtool" ]; then
         for i in $(find . -name "ltmain.sh"); do
             echo "fixing libtool script $i"
             fixLibtool $i
         done
     fi
 
-    if test -z "$dontAddPrefix"; then
+    if [ -z "$dontAddPrefix" ]; then
         configureFlags="${prefixKey:---prefix=}$prefix $configureFlags"
     fi
 
     # Add --disable-dependency-tracking to speed up some builds.
-    if test -z "$dontAddDisableDepTrack"; then
+    if [ -z "$dontAddDisableDepTrack" ]; then
         if grep -q dependency-tracking $configureScript; then
             configureFlags="--disable-dependency-tracking $configureFlags"
         fi
     fi
 
     # By default, disable static builds.
-    if test -z "$dontDisableStatic"; then
+    if [ -z "$dontDisableStatic" ]; then
         if grep -q enable-static $configureScript; then
             configureFlags="--disable-static $configureFlags"
         fi
@@ -616,7 +605,7 @@ configurePhase() {
 buildPhase() {
     runHook preBuild
 
-    if test -z "$makeFlags" && ! test -n "$makefile" -o -e "Makefile" -o -e "makefile" -o -e "GNUmakefile"; then
+    if [ -z "$makeFlags" ] && ! [ -n "$makefile" -o -e "Makefile" -o -e "makefile" -o -e "GNUmakefile" ]; then
         echo "no Makefile, doing nothing"
         return
     fi
@@ -647,7 +636,7 @@ checkPhase() {
 patchELF() {
     # Patch all ELF executables and shared libraries.
     header "patching ELF executables and libraries"
-    if test -e "$prefix"; then
+    if [ -e "$prefix" ]; then
         find "$prefix" \( \
             \( -type f -a -name "*.so*" \) -o \
             \( -type f -a -perm +0100 \) \
@@ -667,9 +656,9 @@ patchShebangs() {
     local f
     for f in $(find "$dir" -type f -perm +0100); do
         local oldPath=$(sed -ne '1 s,^#![ ]*\([^ ]*\).*$,\1,p' "$f")
-        if test -n "$oldPath" -a "${oldPath:0:${#NIX_STORE}}" != "$NIX_STORE"; then
+        if [ -n "$oldPath" -a "${oldPath:0:${#NIX_STORE}}" != "$NIX_STORE" ]; then
             local newPath=$(type -P $(basename $oldPath) || true)
-            if test -n "$newPath" -a "$newPath" != "$oldPath"; then
+            if [ -n "$newPath" -a "$newPath" != "$oldPath" ]; then
                 echo "$f: interpreter changed from $oldPath to $newPath"
                 sed -i -e "1 s,$oldPath,$newPath," "$f"
             fi
@@ -682,7 +671,7 @@ patchShebangs() {
 installPhase() {
     runHook preInstall
 
-    ensureDir "$prefix"
+    mkdir -p "$prefix"
 
     installTargets=${installTargets:-install}
     echo "install flags: $installTargets $makeFlags ${makeFlagsArray[@]} $installFlags ${installFlagsArray[@]}"
@@ -702,15 +691,15 @@ fixupPhase() {
 
     # Put man/doc/info under $out/share.
     forceShare=${forceShare:=man doc info}
-    if test -n "$forceShare"; then
+    if [ -n "$forceShare" ]; then
         for d in $forceShare; do
-            if test -d "$prefix/$d"; then
-                if test -d "$prefix/share/$d"; then
+            if [ -d "$prefix/$d" ]; then
+                if [ -d "$prefix/share/$d" ]; then
                     echo "both $d/ and share/$d/ exists!"
                 else
                     echo "fixing location of $d/ subdirectory"
-                    ensureDir $prefix/share
-                    if test -w $prefix/share; then
+                    mkdir -p $prefix/share
+                    if [ -w $prefix/share ]; then
                         mv -v $prefix/$d $prefix/share
                         ln -sv share/$d $prefix
                     fi
@@ -719,39 +708,58 @@ fixupPhase() {
         done;
     fi
 
+    if [ -z "$dontGzipMan" ]; then
+        GLOBIGNORE=.:..:*.gz:*.bz2
+        for f in $out/share/man/*/* $out/share/man/*/*/*; do
+            if [ -f $f ]; then
+                if gzip -c $f > $f.gz; then
+                    rm $f
+                else
+                    rm $f.gz
+                fi
+            fi
+        done
+        unset GLOBIGNORE
+    fi
+
     # TODO: strip _only_ ELF executables, and return || fail here...
-    if test -z "$dontStrip"; then
+    if [ -z "$dontStrip" ]; then
         stripDebugList=${stripDebugList:-lib lib64 libexec bin sbin}
-        if test -n "$stripDebugList"; then
+        if [ -n "$stripDebugList" ]; then
             stripDirs "$stripDebugList" "${stripDebugFlags:--S}"
         fi
         
         stripAllList=${stripAllList:-}
-        if test -n "$stripAllList"; then
+        if [ -n "$stripAllList" ]; then
             stripDirs "$stripAllList" "${stripAllFlags:--s}"
         fi
     fi
 
-    if test "$havePatchELF" = 1 -a -z "$dontPatchELF"; then
+    if [ "$havePatchELF" = 1 -a -z "$dontPatchELF" ]; then
         patchELF "$prefix"
     fi
 
-    if test -z "$dontPatchShebangs"; then
+    if [ -z "$dontPatchShebangs" ]; then
         patchShebangs "$prefix"
     fi
 
-    if test -n "$propagatedBuildInputs"; then
-        ensureDir "$out/nix-support"
+    if [ -n "$propagatedBuildInputs" ]; then
+        mkdir -p "$out/nix-support"
         echo "$propagatedBuildInputs" > "$out/nix-support/propagated-build-inputs"
     fi
 
-    if test -n "$propagatedBuildNativeInputs"; then
-        ensureDir "$out/nix-support"
+    if [ -n "$propagatedBuildNativeInputs" ]; then
+        mkdir -p "$out/nix-support"
         echo "$propagatedBuildNativeInputs" > "$out/nix-support/propagated-build-native-inputs"
     fi
 
-    if test -n "$setupHook"; then
-        ensureDir "$out/nix-support"
+    if [ -n "$propagatedUserEnvPkgs" ]; then
+        mkdir -p "$out/nix-support"
+        echo "$propagatedUserEnvPkgs" > "$out/nix-support/propagated-user-env-packages"
+    fi
+
+    if [ -n "$setupHook" ]; then
+        mkdir -p "$out/nix-support"
         substituteAll "$setupHook" "$out/nix-support/setup-hook"
     fi
 
@@ -765,8 +773,8 @@ distPhase() {
     echo "dist flags: $distFlags ${distFlagsArray[@]}"
     make ${makefile:+-f $makefile} $distFlags "${distFlagsArray[@]}" ${distTarget:-dist}
 
-    if test "$dontCopyDist" != 1; then
-        ensureDir "$out/tarballs"
+    if [ "$dontCopyDist" != 1 ]; then
+        mkdir -p "$out/tarballs"
 
         # Note: don't quote $tarballs, since we explicitly permit
         # wildcards in there.
@@ -795,12 +803,12 @@ showPhaseHeader() {
 genericBuild() {
     header "building $out"
 
-    if test -n "$buildCommand"; then
+    if [ -n "$buildCommand" ]; then
         eval "$buildCommand"
         return
     fi
 
-    if test -z "$phases"; then
+    if [ -z "$phases" ]; then
         phases="$prePhases unpackPhase patchPhase $preConfigurePhases \
             configurePhase $preBuildPhases buildPhase checkPhase \
             $preInstallPhases installPhase fixupPhase \
@@ -808,12 +816,17 @@ genericBuild() {
     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
-        
+        if [ "$curPhase" = buildPhase -a -n "$dontBuild" ]; then continue; fi
+        if [ "$curPhase" = checkPhase -a -z "$doCheck" ]; then continue; fi
+        if [ "$curPhase" = installPhase -a -n "$dontInstall" ]; then continue; fi
+        if [ "$curPhase" = fixupPhase -a -n "$dontFixup" ]; then continue; fi
+        if [ "$curPhase" = distPhase -a -z "$doDist" ]; then continue; fi
+
+        if [ -n "$tracePhases" ]; then
+            echo
+            echo "@ phase-started $out $curPhase"
+        fi
+
         showPhaseHeader "$curPhase"
         dumpVars
         
@@ -821,10 +834,15 @@ genericBuild() {
         # function named $curPhase.
         eval "${!curPhase:-$curPhase}"
 
-        if test "$curPhase" = unpackPhase; then
+        if [ "$curPhase" = unpackPhase ]; then
             cd "${sourceRoot:-.}"
         fi
         
+        if [ -n "$tracePhases" ]; then
+            echo
+            echo "@ phase-succeeded $out $curPhase"
+        fi
+
         stopNest
     done
 
@@ -833,7 +851,6 @@ genericBuild() {
 
 
 # Execute the post-hook.
-if test -n "@postHook@"; then source @postHook@; fi
 runHook postHook
 
 
diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix
index 91a9689e8fb32..8b6599e6bc034 100644
--- a/pkgs/stdenv/linux/default.nix
+++ b/pkgs/stdenv/linux/default.nix
@@ -5,7 +5,9 @@
 # ensuring purity of components produced by it.
 
 # The function defaults are for easy testing.
-{system ? "i686-linux", allPackages ? import ../../top-level/all-packages.nix, platform}:
+{ system ? builtins.currentSystem
+, allPackages ? import ../../top-level/all-packages.nix
+, platform ? null }:
 
 rec {
 
@@ -53,10 +55,10 @@ rec {
     
     builder = bootstrapFiles.sh;
     
-    args = if (system == "armv5tel-linux") then
-      ([ ./scripts/unpack-bootstrap-tools-arm.sh ])
-      else 
-      ([ ./scripts/unpack-bootstrap-tools.sh ]);
+    args =
+      if system == "armv5tel-linux"
+      then [ ./scripts/unpack-bootstrap-tools-arm.sh ]
+      else [ ./scripts/unpack-bootstrap-tools.sh ];
     
     inherit (bootstrapFiles) bzip2 mkdir curl cpio;
     
@@ -75,13 +77,12 @@ rec {
   # This function builds the various standard environments used during
   # the bootstrap.
   stdenvBootFun =
-    {gcc, extraAttrs ? {}, overrides ? {}, extraPath ? [], fetchurl}:
+    {gcc, extraAttrs ? {}, overrides ? (pkgs: {}), extraPath ? [], fetchurl}:
 
     import ../generic {
       inherit system;
       name = "stdenv-linux-boot";
-      param1 = bootstrapTools;
-      preHook = builtins.toFile "prehook.sh"
+      preHook =
         ''
           # Don't patch #!/interpreter because it leads to retained
           # dependencies on the bootstrapTools in the final stdenv.
@@ -95,7 +96,7 @@ rec {
       # Having the proper 'platform' in all the stdenvs allows getting proper
       # linuxHeaders for example.
       extraAttrs = extraAttrs // { inherit platform; };
-      overrides = overrides // {
+      overrides = pkgs: (overrides pkgs) // {
         inherit fetchurl;
       };
     };
@@ -121,7 +122,7 @@ rec {
   bootstrapGlibc = stdenvLinuxBoot0.mkDerivation {
     name = "bootstrap-glibc";
     buildCommand = ''
-      ensureDir $out
+      mkdir -p $out
       ln -s ${bootstrapTools}/lib $out/lib
       ln -s ${bootstrapTools}/include-glibc $out/include
     '';
@@ -154,23 +155,25 @@ rec {
   
 
   # 2) These are the packages that we can build with the first
-  #    stdenv.  We only need binutils, because recent glibcs
-  #    require recent binutils, and those in bootstrap-tools may
-  #    be too old. (in step 3).
+  #    stdenv.  We only need binutils, because recent Glibcs
+  #    require recent Binutils, and those in bootstrap-tools may
+  #    be too old.
   stdenvLinuxBoot1Pkgs = allPackages {
     inherit system platform;
     bootStdenv = stdenvLinuxBoot1;
   };
 
-  firstBinutils = stdenvLinuxBoot1Pkgs.binutils;
-
+  
   # 3) 2nd stdenv that we will use to build only the glibc.
   stdenvLinuxBoot2 = stdenvBootFun {
     gcc = wrapGCC {
       libc = bootstrapGlibc;
-      binutils = firstBinutils;
+      binutils = stdenvLinuxBoot1Pkgs.binutils;
       coreutils = bootstrapTools;
     };
+    overrides = pkgs: {
+      inherit (stdenvLinuxBoot1Pkgs) perl;
+    };
     inherit fetchurl;
   };
 
@@ -197,9 +200,18 @@ rec {
       coreutils = bootstrapTools;
       libc = stdenvLinuxGlibc;
     };
-    overrides = {
+    overrides = pkgs: {
       glibc = stdenvLinuxGlibc;
       inherit (stdenvLinuxBoot1Pkgs) perl;
+      # Link GCC statically against GMP etc.  This makes sense because
+      # these builds of the libraries are only used by GCC, so it
+      # reduces the size of the stdenv closure.
+      gmp = pkgs.gmp.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
+      mpfr = pkgs.mpfr.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
+      mpc = pkgs.mpc.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
+      isl = pkgs.isl.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
+      cloog = pkgs.cloog.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
+      ppl = pkgs.ppl.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
     };
     inherit fetchurl;
   };
@@ -211,20 +223,7 @@ rec {
     bootStdenv = stdenvLinuxBoot3;
   };
 
-  gccWithStaticLibs = stdenvLinuxBoot3Pkgs.gcc.gcc.override (rec {
-    ppl = stdenvLinuxBoot3Pkgs.ppl.override {
-      static = true;
-      gmpxx = stdenvLinuxBoot3Pkgs.gmpxx.override {
-        static = true;
-      };
-    };
-    cloogppl = stdenvLinuxBoot3Pkgs.cloogppl.override {
-      inherit ppl;
-      static = true;
-    };
-  });
-
-
+  
   # 8) Construct a fourth stdenv identical to the second, except that
   #    this one uses the dynamically linked GCC and Binutils from step
   #    5.  The other tools (e.g. coreutils) are still from the
@@ -234,11 +233,13 @@ rec {
       inherit (stdenvLinuxBoot3Pkgs) binutils;
       coreutils = bootstrapTools;
       libc = stdenvLinuxGlibc;
-      gcc = gccWithStaticLibs;
+      gcc = stdenvLinuxBoot3Pkgs.gcc.gcc;
       name = "";
     };
-    overrides = {
+    extraPath = [ stdenvLinuxBoot3Pkgs.xz ];
+    overrides = pkgs: {
       inherit (stdenvLinuxBoot1Pkgs) perl;
+      inherit (stdenvLinuxBoot3Pkgs) gettext gnum4 xz gmp;
     };
     inherit fetchurl;
   };
@@ -259,11 +260,9 @@ rec {
   #     dependency (`nix-store -qR') on bootstrapTools or the
   #     first binutils built.
   stdenvLinux = import ../generic rec {
-    name = "stdenv-linux";
-    
     inherit system;
     
-    preHook = builtins.toFile "prehook.sh" commonPreHook;
+    preHook = commonPreHook;
     
     initialPath = 
       ((import ../common-path.nix) {pkgs = stdenvLinuxBoot4Pkgs;})
@@ -273,7 +272,7 @@ rec {
       inherit (stdenvLinuxBoot3Pkgs) binutils;
       inherit (stdenvLinuxBoot4Pkgs) coreutils;
       libc = stdenvLinuxGlibc;
-      gcc = gccWithStaticLibs;
+      gcc = stdenvLinuxBoot3Pkgs.gcc.gcc;
       shell = stdenvLinuxBoot4Pkgs.bash + "/bin/bash";
       name = "";
     };
@@ -287,11 +286,11 @@ rec {
       inherit platform;
     };
 
-    overrides = {
+    overrides = pkgs: {
       inherit gcc;
       inherit (stdenvLinuxBoot3Pkgs) binutils glibc;
       inherit (stdenvLinuxBoot4Pkgs)
-        gzip bzip2 bash coreutils diffutils findutils gawk
+        gzip bzip2 xz bash coreutils diffutils findutils gawk
         gnumake gnused gnutar gnugrep gnupatch patchelf
         attr acl;
     };
diff --git a/pkgs/stdenv/linux/make-bootstrap-tools.nix b/pkgs/stdenv/linux/make-bootstrap-tools.nix
index ba2a953a457fc..9116b2225690a 100644
--- a/pkgs/stdenv/linux/make-bootstrap-tools.nix
+++ b/pkgs/stdenv/linux/make-bootstrap-tools.nix
@@ -92,7 +92,7 @@ rec {
 
       buildCommand = ''
 	set -x
-        ensureDir $out/bin $out/lib $out/libexec
+        mkdir -p $out/bin $out/lib $out/libexec
 
         # Copy what we need of Glibc.
         cp -d ${glibc}/lib/ld*.so* $out/lib
@@ -133,7 +133,6 @@ rec {
         cp -d ${gnumake}/bin/* $out/bin
         cp -d ${patch}/bin/* $out/bin
         cp ${patchelf}/bin/* $out/bin
-        cp ${replace}/bin/* $out/bin
 
         cp -d ${gnugrep.pcre}/lib/libpcre*.so* $out/lib # needed by grep
         
diff --git a/pkgs/stdenv/linux/scripts/prehook.sh b/pkgs/stdenv/linux/scripts/prehook.sh
deleted file mode 100644
index 29c02e2eaf2e4..0000000000000
--- a/pkgs/stdenv/linux/scripts/prehook.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-export NIX_ENFORCE_PURITY=1
-
-havePatchELF=1
diff --git a/pkgs/stdenv/mingw/setup.sh b/pkgs/stdenv/mingw/setup.sh
index 058d8cb189182..4de3c0ddc9b4a 100755
--- a/pkgs/stdenv/mingw/setup.sh
+++ b/pkgs/stdenv/mingw/setup.sh
@@ -38,7 +38,7 @@ exitHandler() {
         # normally.  Otherwise, return the original exit code.
         if test -n "$succeedOnFailure"; then
             echo "build failed with exit code $exitCode (ignored)"
-            ensureDir "$out/nix-support"
+            mkdir -p "$out/nix-support"
             echo -n $exitCode > "$out/nix-support/failed"
             exit 0
         fi
@@ -133,7 +133,7 @@ ensureDir() {
 }
 
 installBin() {
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp "$@" $out/bin
 }
 
@@ -202,13 +202,6 @@ if test "$NIX_NO_SELF_RPATH" != "1"; then
 fi
 
 
-# Strip debug information by default.
-if test -z "$NIX_STRIP_DEBUG"; then
-    export NIX_STRIP_DEBUG=1
-    export NIX_CFLAGS_STRIP="-g0 -Wl,--strip-debug"
-fi
-
-
 # Set the TZ (timezone) environment variable, otherwise commands like
 # `date' will complain (e.g., `Tue Mar 9 10:01:47 Local time zone must
 # be set--see zic manual page 2004').
@@ -618,7 +611,7 @@ patchShebangs() {
 installPhase() {
     runHook preInstall
 
-    ensureDir "$prefix"
+    mkdir -p "$prefix"
 
     installTargets=${installTargets:-install}
     echo "install flags: $installTargets $makeFlags ${makeFlagsArray[@]} $installFlags ${installFlagsArray[@]}"
@@ -645,7 +638,7 @@ fixupPhase() {
                     echo "both $d/ and share/$d/ exists!"
                 else
                     echo "fixing location of $d/ subdirectory"
-                    ensureDir $prefix/share
+                    mkdir -p $prefix/share
                     if test -w $prefix/share; then
                         mv -v $prefix/$d $prefix/share
                         ln -sv $prefix/share/$d $prefix/$d
@@ -677,12 +670,12 @@ fixupPhase() {
     fi
 
     if test -n "$propagatedBuildInputs"; then
-        ensureDir "$out/nix-support"
+        mkdir -p "$out/nix-support"
         echo "$propagatedBuildInputs" > "$out/nix-support/propagated-build-inputs"
     fi
 
     if test -n "$setupHook"; then
-        ensureDir "$out/nix-support"
+        mkdir -p "$out/nix-support"
         substituteAll "$setupHook" "$out/nix-support/setup-hook"
     fi
 
@@ -697,7 +690,7 @@ distPhase() {
     make ${makefile:+-f $makefile} $distFlags "${distFlagsArray[@]}" ${distTarget:-dist}
 
     if test "$dontCopyDist" != 1; then
-        ensureDir "$out/tarballs"
+        mkdir -p "$out/tarballs"
 
         # Note: don't quote $tarballs, since we explicitly permit
         # wildcards in there.
diff --git a/pkgs/stdenv/native/default.nix b/pkgs/stdenv/native/default.nix
index bdf342b2c64a7..c0da8f2b0c193 100644
--- a/pkgs/stdenv/native/default.nix
+++ b/pkgs/stdenv/native/default.nix
@@ -11,23 +11,23 @@ rec {
     (if system == "i686-netbsd" then [ "/usr/pkg" ] else []) ++
     ["/" "/usr" "/usr/local"];
 
-  prehookBase = builtins.toFile "prehook-base.sh" ''
+  prehookBase = ''
     # Disable purity tests; it's allowed (even needed) to link to
     # libraries outside the Nix store (like the C library).
     export NIX_ENFORCE_PURITY=
   '';
 
-  prehookDarwin = builtins.toFile "prehook-darwin.sh" ''
-    source ${prehookBase}
+  prehookDarwin = ''
+    ${prehookBase}
     export NIX_DONT_SET_RPATH=1
     export NIX_NO_SELF_RPATH=1
     dontFixLibtool=1
-    NIX_STRIP_DEBUG=0
     stripAllFlags=" " # the Darwin "strip" command doesn't know "-s" 
+    xargsFlags=" "
   '';
 
-  prehookFreeBSD = builtins.toFile "prehook-freebsd.sh" ''
-    source ${prehookBase}
+  prehookFreeBSD = ''
+    ${prehookBase}
     
     alias make=gmake
     alias tar=gtar
@@ -39,8 +39,8 @@ rec {
     export NIX_GCC_NEEDS_GREP=1
   '';
 
-  prehookOpenBSD = builtins.toFile "prehook-openbsd.sh" ''
-    source ${prehookBase}
+  prehookOpenBSD = ''
+    ${prehookBase}
     
     alias make=gmake
     alias grep=ggrep
@@ -56,8 +56,8 @@ rec {
     export NIX_GCC_NEEDS_GREP=1
   '';
 
-  prehookNetBSD = builtins.toFile "prehook-netbsd.sh" ''
-    source ${prehookBase}
+  prehookNetBSD = ''
+    ${prehookBase}
     
     alias make=gmake
     alias sed=gsed
@@ -69,8 +69,8 @@ rec {
     export NIX_GCC_NEEDS_GREP=1
   '';
 
-  prehookCygwin = builtins.toFile "prehook-cygwin.sh" ''
-    source ${prehookBase}
+  prehookCygwin = ''
+    ${prehookBase}
     
     if test -z "$cygwinConfigureEnableShared"; then
       export configureFlags="$configureFlags --disable-shared"
@@ -83,11 +83,9 @@ rec {
   # A function that builds a "native" stdenv (one that uses tools in
   # /usr etc.).  
   makeStdenv =
-    {gcc, fetchurl, extraPath ? []}:
+    { gcc, fetchurl, extraPath ? [], overrides ? (pkgs: { }) }:
 
     import ../generic {
-      name = "stdenv-native";
-
       preHook =
         if system == "i686-darwin" || system == "powerpc-darwin" || system == "x86_64-darwin" then prehookDarwin else
         if system == "i686-freebsd" then prehookFreeBSD else
@@ -100,7 +98,7 @@ rec {
 
       fetchurlBoot = fetchurl;
 
-      inherit system shell gcc;
+      inherit system shell gcc overrides;
     };
 
 
@@ -137,12 +135,13 @@ rec {
   };
 
 
-  # Using that, build a stdenv that adds the `replace' command (which
-  # most systems don't have, so we mustn't rely on the native
-  # environment providing it).
+  # Using that, build a stdenv that adds the ‘xz’ command (which most
+  # systems don't have, so we mustn't rely on the native environment
+  # providing it).
   stdenvBoot2 = makeStdenv {
     inherit gcc fetchurl;
-    extraPath = [stdenvBoot1Pkgs.replace];
+    extraPath = [ stdenvBoot1Pkgs.xz ];
+    overrides = pkgs: { inherit (stdenvBoot1Pkgs) xz; };
   };
 
 
diff --git a/pkgs/stdenv/nix/default.nix b/pkgs/stdenv/nix/default.nix
index 5b1b2af8285fa..473bb5af0afd7 100644
--- a/pkgs/stdenv/nix/default.nix
+++ b/pkgs/stdenv/nix/default.nix
@@ -1,8 +1,20 @@
-{stdenv, pkgs}:
+{ stdenv, pkgs }:
+
+import ../generic rec {
+  preHook =
+    ''
+      export NIX_ENFORCE_PURITY=1
+      export NIX_IGNORE_LD_THROUGH_GCC=1
+
+      if [ "$system" = "i686-darwin" -o "$system" = "powerpc-darwin" -o "$system" = "x86_64-darwin" ]; then
+        export NIX_DONT_SET_RPATH=1
+        export NIX_NO_SELF_RPATH=1
+        dontFixLibtool=1
+        stripAllFlags=" " # the Darwin "strip" command doesn't know "-s" 
+        xargsFlags=" "
+      fi
+    '';
 
-import ../generic {
-  name = "stdenv-nix";
-  preHook = ./prehook.sh;
   initialPath = (import ../common-path.nix) {pkgs = pkgs;};
 
   system = stdenv.system;
@@ -24,4 +36,12 @@ import ../generic {
   shell = pkgs.bash + "/bin/sh";
 
   fetchurlBoot = stdenv.fetchurlBoot;
+
+  overrides = pkgs_: {
+    inherit gcc;
+    inherit (gcc) binutils;
+    inherit (pkgs) 
+      gzip bzip2 xz bash coreutils diffutils findutils gawk
+      gnumake gnused gnutar gnugrep gnupatch perl;
+  };
 }
diff --git a/pkgs/stdenv/nix/prehook.sh b/pkgs/stdenv/nix/prehook.sh
deleted file mode 100644
index 55389b7d77168..0000000000000
--- a/pkgs/stdenv/nix/prehook.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-export NIX_ENFORCE_PURITY=1
-export NIX_IGNORE_LD_THROUGH_GCC=1
-
-if test "$system" = "i686-darwin" -o "$system" = "powerpc-darwin" -o "$system" = "x86_64-darwin"; then
-    export NIX_DONT_SET_RPATH=1
-    export NIX_NO_SELF_RPATH=1
-    dontFixLibtool=1
-    NIX_STRIP_DEBUG=0 # !!! do we still need this?
-    stripAllFlags=" " # the Darwin "strip" command doesn't know "-s" 
-    xargsFlags=" "
-fi
diff --git a/pkgs/tools/X11/x2vnc/default.nix b/pkgs/tools/X11/x2vnc/default.nix
index a3d21ab1800e9..adc04b629444a 100644
--- a/pkgs/tools/X11/x2vnc/default.nix
+++ b/pkgs/tools/X11/x2vnc/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
       xorg.libXrandr xorg.randrproto
     ];
 
-  preInstall = "ensureDir $out";
+  preInstall = "mkdir -p $out";
 
   meta = {
     homepahe = http://fredrik.hubbe.net/x2vnc.html;
diff --git a/pkgs/tools/X11/x2x/default.nix b/pkgs/tools/X11/x2x/default.nix
index abe5c9b59d600..5d68e1da1ba9c 100644
--- a/pkgs/tools/X11/x2x/default.nix
+++ b/pkgs/tools/X11/x2x/default.nix
@@ -16,8 +16,8 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out/bin
-    ensureDir $out/man/man1
+    mkdir -p $out/bin
+    mkdir -p $out/man/man1
     cp x2x $out/bin/
     cp x2x.1 $out/man/man1/
   '';
diff --git a/pkgs/tools/X11/xpra/default.nix b/pkgs/tools/X11/xpra/default.nix
index 0691521e44cf4..cf7692cc58acc 100644
--- a/pkgs/tools/X11/xpra/default.nix
+++ b/pkgs/tools/X11/xpra/default.nix
@@ -22,7 +22,7 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp -r install/* $out
 
     for i in $(cd $out/bin && ls); do
diff --git a/pkgs/tools/admin/tightvnc/builder.sh b/pkgs/tools/admin/tightvnc/builder.sh
index 72fced3772862..10590bbfcf1ed 100644
--- a/pkgs/tools/admin/tightvnc/builder.sh
+++ b/pkgs/tools/admin/tightvnc/builder.sh
@@ -31,13 +31,13 @@ buildPhase() {
 }
 
 installPhase() {
-    ensureDir $out/bin
-    ensureDir $out/share/man/man1
+    mkdir -p $out/bin
+    mkdir -p $out/share/man/man1
     ./vncinstall $out/bin $out/share/man
 
     # fix HTTP client:
     t=$out/share/tightvnc
-    ensureDir $t
+    mkdir -p $t
     sed -i "s@/usr/local/vnc/classes@$out/vnc/classes@g" $out/bin/vncserver
     cp -r classes $t
 }
diff --git a/pkgs/tools/archivers/cromfs/default.nix b/pkgs/tools/archivers/cromfs/default.nix
index 943525d3853c6..3512d62223f45 100644
--- a/pkgs/tools/archivers/cromfs/default.nix
+++ b/pkgs/tools/archivers/cromfs/default.nix
@@ -1,20 +1,14 @@
-{stdenv, fetchurl, pkgconfig, fuse, perl}:
+{ stdenv, fetchurl, pkgconfig, fuse, perl }:
 
 stdenv.mkDerivation rec {
-  name = "cromfs-1.5.9.1";
+  name = "cromfs-1.5.10";
+  
   src = fetchurl {
     url = "http://bisqwit.iki.fi/src/arch/${name}.tar.bz2";
-    sha256 = "02k0nd7zvcksn7vjxlynsdgdvkayfzzhv622n9zkka94756lr0fk";
+    sha256 = "1w079zb5scv6bj919ndr0fkiirq2bkyjrnmwqrr9yzwbyinzg73j";
   };
 
-  patchPhase = ''sed -i 's@/bin/bash@/bin/sh@g' configure; set -x'';
-
-  meta = {
-    description = "FUSE Compressed ROM filesystem with lzma"  ;
-	  homepage = http://bisqwit.iki.fi/source/cromfs.html;
-    maintainers = with stdenv.lib.maintainers; [viric];
-    platforms = with stdenv.lib.platforms; linux;
-  };
+  patchPhase = ''sed -i 's@/bin/bash@/bin/sh@g' configure'';
 
   # Removing the static linking, as it doesn't compile in x86_64.
   makeFlags = "cromfs-driver util/mkcromfs util/unmkcromfs util/cvcromfs";
@@ -27,5 +21,12 @@ stdenv.mkDerivation rec {
     install util/unmkcromfs $out/bin
   '';
 
-  buildInputs = [pkgconfig fuse perl];
+  buildInputs = [ pkgconfig fuse perl ];
+
+  meta = {
+    description = "FUSE Compressed ROM filesystem with lzma";
+    homepage = http://bisqwit.iki.fi/source/cromfs.html;
+    maintainers = [ stdenv.lib.maintainers.viric ];
+    platforms = stdenv.lib.platforms.linux;
+  };
 }
diff --git a/pkgs/tools/archivers/gnutar/default.nix b/pkgs/tools/archivers/gnutar/default.nix
index fddd8db088677..cb322e82f3986 100644
--- a/pkgs/tools/archivers/gnutar/default.nix
+++ b/pkgs/tools/archivers/gnutar/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "gnutar-1.25";
+  name = "gnutar-1.26";
 
   src = fetchurl {
-    url = "mirror://gnu/tar/tar-1.25.tar.bz2";
-    sha256 = "0js9b1jd93kjk6dgf40y2fpgpnix247rk5aws2mjgwz0p10wxxpk";
+    url = "mirror://gnu/tar/tar-1.26.tar.bz2";
+    sha256 = "0hbdkzmchq9ycr2x1pxqdcgdbaxksh8c6ac0jf75jajhcks6jlss";
   };
 
   meta = {
diff --git a/pkgs/tools/archivers/unarj/default.nix b/pkgs/tools/archivers/unarj/default.nix
index 7a15514a7287a..0852674e8c89c 100644
--- a/pkgs/tools/archivers/unarj/default.nix
+++ b/pkgs/tools/archivers/unarj/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
   };
 
   preInstall = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     sed -i -e s,/usr/local/bin,$out/bin, Makefile
   '';
 
diff --git a/pkgs/tools/archivers/unzip/5.52.nix b/pkgs/tools/archivers/unzip/5.52.nix
deleted file mode 100644
index c72def3731a30..0000000000000
--- a/pkgs/tools/archivers/unzip/5.52.nix
+++ /dev/null
@@ -1,18 +0,0 @@
-{stdenv, fetchurl}:
-
-stdenv.mkDerivation {
-  name = "unzip-5.52";
-  
-  src = fetchurl {
-    url = http://nixos.org/tarballs/unzip552.tar.gz;
-    md5 = "9d23919999d6eac9217d1f41472034a9";
-  };
-
-  buildPhase = "make -f unix/Makefile generic";
-
-  installPhase = "make -f unix/Makefile prefix=$out install";
-
-  meta = {
-    homepage = http://www.info-zip.org;
-  };
-}
diff --git a/pkgs/tools/archivers/unzip/6.0.nix b/pkgs/tools/archivers/unzip/default.nix
index face504fa32c1..8309a2102ab45 100644
--- a/pkgs/tools/archivers/unzip/6.0.nix
+++ b/pkgs/tools/archivers/unzip/default.nix
@@ -17,6 +17,10 @@ stdenv.mkDerivation ({
 
   buildFlags = "generic D_USE_BZ2=-DUSE_BZIP2 L_BZ2=-lbz2";
 
+  preConfigure = ''
+    sed -i -e 's@CF="-O3 -Wall -I. -DASM_CRC $(LOC)"@CF="-O3 -Wall -I. -DASM_CRC -DLARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(LOC)"@' unix/Makefile
+  '';
+
   installFlags = "prefix=$(out)";
 
   meta = {
diff --git a/pkgs/tools/cd-dvd/unetbootin/default.nix b/pkgs/tools/cd-dvd/unetbootin/default.nix
index 20d5ae7715e5b..b1fd5a10c2b46 100644
--- a/pkgs/tools/cd-dvd/unetbootin/default.nix
+++ b/pkgs/tools/cd-dvd/unetbootin/default.nix
@@ -41,13 +41,13 @@ stdenv.mkDerivation rec {
 
   installPhase =
     ''
-      ensureDir $out/bin
+      mkdir -p $out/bin
       cp unetbootin $out/bin
 
-      ensureDir $out/share/unetbootin
+      mkdir -p $out/share/unetbootin
       cp unetbootin_*.qm  $out/share/unetbootin
 
-      ensureDir $out/share/applications
+      mkdir -p $out/share/applications
       cp unetbootin.desktop $out/share/applications
 
       wrapProgram $out/bin/unetbootin \
diff --git a/pkgs/tools/compression/bsdiff/builder.sh b/pkgs/tools/compression/bsdiff/builder.sh
index 1acb10cb7946b..f2792a40a60c9 100644
--- a/pkgs/tools/compression/bsdiff/builder.sh
+++ b/pkgs/tools/compression/bsdiff/builder.sh
@@ -2,7 +2,7 @@ source $stdenv/setup
 
 installFlags="PREFIX=$out INSTALL=install"
 
-ensureDir "$out/bin"
-ensureDir "$out/man/man1"
+mkdir -p "$out/bin"
+mkdir -p "$out/man/man1"
 
 genericBuild
diff --git a/pkgs/tools/compression/bzip2/builder.sh b/pkgs/tools/compression/bzip2/builder.sh
index ea2ebc4c2db05..4610bdd40850e 100644
--- a/pkgs/tools/compression/bzip2/builder.sh
+++ b/pkgs/tools/compression/bzip2/builder.sh
@@ -8,7 +8,7 @@ if test -n "$sharedLibrary"; then
     }
 
     preInstall() {
-        ensureDir $out/lib
+        mkdir -p $out/lib
         mv libbz2.so* $out/lib
         ln -s libbz2.so.1.0 $out/lib/libbz2.so
     }
diff --git a/pkgs/tools/compression/bzip2/default.nix b/pkgs/tools/compression/bzip2/default.nix
index ff13c1a2ed013..a431cd30a21f6 100644
--- a/pkgs/tools/compression/bzip2/default.nix
+++ b/pkgs/tools/compression/bzip2/default.nix
@@ -1,13 +1,15 @@
-{stdenv, fetchurl, linkStatic ? false}:
+{ stdenv, fetchurl, linkStatic ? false }:
+
+let version = "1.0.6"; in
 
 stdenv.mkDerivation {
-  name = "bzip2-1.0.5";
+  name = "bzip2-${version}";
 
   builder = ./builder.sh;
 
   src = fetchurl {
-    url = http://www.bzip.org/1.0.5/bzip2-1.0.5.tar.gz;
-    sha256 = "08py2s9vw6dgw457lbklh1vsr3b8x8dlv7d8ygdfaxlx61l57gzp";
+    url = "http://www.bzip.org/${version}/bzip2-${version}.tar.gz";
+    sha256 = "1kfrc7f0ja9fdn6j1y6yir6li818npy6217hvr3wzmnmzhs8z152";
   };
 
   crossAttrs = {
diff --git a/pkgs/tools/compression/upx/default.nix b/pkgs/tools/compression/upx/default.nix
index c3fd01d5c88b3..f3b8037a9f192 100644
--- a/pkgs/tools/compression/upx/default.nix
+++ b/pkgs/tools/compression/upx/default.nix
@@ -24,7 +24,7 @@ stdenv.mkDerivation {
     cd src
   ";
 
-  installPhase = "ensureDir $out/bin ; cp upx.out $out/bin/upx";
+  installPhase = "mkdir -p $out/bin ; cp upx.out $out/bin/upx";
 
   meta = {
     homepage = http://upx.sourceforge.net/;
diff --git a/pkgs/tools/compression/xz/default.nix b/pkgs/tools/compression/xz/default.nix
index b6aa8e96013f8..78a8ed95a4e91 100644
--- a/pkgs/tools/compression/xz/default.nix
+++ b/pkgs/tools/compression/xz/default.nix
@@ -1,25 +1,35 @@
-{stdenv, fetchurl, lib}:
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "xz-5.0.3";
 
-stdenv.mkDerivation ({
-  name = "xz-5.0.0";
-  
   src = fetchurl {
-    url = http://tukaani.org/xz/xz-5.0.0.tar.bz2;
-    sha256 = "1n2nc00d83di0jl5d9qwpngkmlk3wqhs4w9q2ah680v9qijrxa27";
+    url = "http://tukaani.org/xz/${name}.tar.bz2";
+    sha256 = "1sgaq4gdh8llz3gnlgvd65x610fwc8h4m32skhqn5npwgghvj4as";
   };
 
+  doCheck = true;
+
   meta = {
     homepage = http://tukaani.org/xz/;
-    description = "Successor of the LZMA Utils package";
-    license = "GPL/LGPL";
-    maintainers = [ lib.maintainers.sander ];
-  };
-}
+    description = "XZ, general-purpose data compression software, successor of LZMA";
 
-//
+    longDescription =
+      '' XZ Utils is free general-purpose data compression software with high
+         compression ratio.  XZ Utils were written for POSIX-like systems,
+         but also work on some not-so-POSIX systems.  XZ Utils are the
+         successor to LZMA Utils.
 
-(if stdenv.system == "x86_64-darwin"
- # Work around assembler misconfiguration as `x86'.  This appears to be fixed
- # by commit b9b5c54cd438b3ae47b44cc211b71f3bc53e35ef (Nov 22 12:00:30 2009 # +0200).
- then { configureFlags = "--enable-assembler=x86_64"; }
- else {}))
+         The core of the XZ Utils compression code is based on LZMA SDK, but
+         it has been modified quite a lot to be suitable for XZ Utils.  The
+         primary compression algorithm is currently LZMA2, which is used
+         inside the .xz container format.  With typical files, XZ Utils
+         create 30 % smaller output than gzip and 15 % smaller output than
+         bzip2.
+      '';
+
+    licenses = [ "GPLv2+" "LGPLv2.1+" ];
+    maintainers = with stdenv.lib.maintainers; [ sander ludo ];
+    platforms = stdenv.lib.platforms.all;
+  };
+}
diff --git a/pkgs/tools/compression/zdelta/builder.sh b/pkgs/tools/compression/zdelta/builder.sh
index 376c0bf4f39c4..03db413181d74 100644
--- a/pkgs/tools/compression/zdelta/builder.sh
+++ b/pkgs/tools/compression/zdelta/builder.sh
@@ -1,7 +1,7 @@
 source $stdenv/setup
 
 installPhase() {
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp -p zdc zdu $out/bin
 }
 
diff --git a/pkgs/tools/filesystems/fsfs/default.nix b/pkgs/tools/filesystems/fsfs/default.nix
index 622424c302fba..0e72c45e31ad1 100644
--- a/pkgs/tools/filesystems/fsfs/default.nix
+++ b/pkgs/tools/filesystems/fsfs/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation {
   '';
 
   preInstall = ''
-    ensureDir $out/etc $out/var/lib
+    mkdir -p $out/etc $out/var/lib
     makeFlags="$makeFlags prefix=$out"
   '';
 
diff --git a/pkgs/tools/filesystems/fusesmb/default.nix b/pkgs/tools/filesystems/fusesmb/default.nix
index d6d5c3a48aaf7..4ddab385a4274 100644
--- a/pkgs/tools/filesystems/fusesmb/default.nix
+++ b/pkgs/tools/filesystems/fusesmb/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
 
   postInstall =
     ''
-      ensureDir $out/lib
+      mkdir -p $out/lib
       ln -fs ${samba}/lib/libsmbclient.so $out/lib/libsmbclient.so.0
     '';
 
diff --git a/pkgs/tools/filesystems/httpfs/default.nix b/pkgs/tools/filesystems/httpfs/default.nix
index afa4be345a942..717b08acc5f90 100644
--- a/pkgs/tools/filesystems/httpfs/default.nix
+++ b/pkgs/tools/filesystems/httpfs/default.nix
@@ -15,10 +15,10 @@ stdenv.mkDerivation rec {
     ];
 
   installPhase =
-    '' ensureDir "$out/bin"
+    '' mkdir -p "$out/bin"
        cp -v httpfs2 "$out/bin"
 
-       ensureDir "$out/share/man/man1"
+       mkdir -p "$out/share/man/man1"
        cp -v *.1 "$out/share/man/man1"
     '';
 
diff --git a/pkgs/tools/filesystems/squashfs/default.nix b/pkgs/tools/filesystems/squashfs/default.nix
index a7eb9eb0a1f25..f66c54cc9e1bd 100644
--- a/pkgs/tools/filesystems/squashfs/default.nix
+++ b/pkgs/tools/filesystems/squashfs/default.nix
@@ -1,24 +1,23 @@
-{stdenv, fetchurl, zlib, attr, xz}:
+{ stdenv, fetchurl, zlib, xz }:
 
 stdenv.mkDerivation rec {
-  name = "squashfs-4.1";
+  name = "squashfs-4.2";
 
   src = fetchurl {
-    url = mirror://sourceforge/squashfs/squashfs4.1.tar.gz;
-    sha256 = "0sh40r7gz81fg7ivgr7rld8spvqb6hsfvnf6gd3gbcr5b830v1rs";
+    url = mirror://sourceforge/squashfs/squashfs4.2.tar.gz;
+    sha256 = "15if08j0pl5hmnz9pwshwrp4fjp0jsm9larjxmjvdnr2m5d1kq6r";
   };
   
-  buildInputs = [zlib attr xz];
-
-  preBuild = ''
-    cd squashfs-tools
-  '';
-  IUSE="+gzip +lzma";
+  buildInputs = [ zlib xz ];
 
+  preBuild = "cd squashfs-tools";
+  
   NIX_LDFLAGS = "-lgcc_s"; # for pthread_cancel
 
   installFlags = "INSTALL_DIR=\${out}/bin";
+  
   makeFlags = "XZ_SUPPORT=1";
+  
   meta = {
     homepage = http://squashfs.sourceforge.net/;
     description = "Tool for creating and unpacking squashfs filesystems";
diff --git a/pkgs/tools/filesystems/sshfs-fuse/default.nix b/pkgs/tools/filesystems/sshfs-fuse/default.nix
index 606914cd976ea..fcb3c23ed1d39 100644
--- a/pkgs/tools/filesystems/sshfs-fuse/default.nix
+++ b/pkgs/tools/filesystems/sshfs-fuse/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
   
   buildInputs = [ pkgconfig glib fuse ];
   postInstall = ''
-    ensureDir $out/sbin
+    mkdir -p $out/sbin
     ln -sf $out/bin/sshfs $out/sbin/mount.sshfs
   '';
 
diff --git a/pkgs/tools/graphics/cfdg/default.nix b/pkgs/tools/graphics/cfdg/default.nix
index 435305f1e2af8..26df8818b2b6e 100644
--- a/pkgs/tools/graphics/cfdg/default.nix
+++ b/pkgs/tools/graphics/cfdg/default.nix
@@ -16,10 +16,10 @@ rec {
   phaseNames = ["doMake" "copyFiles"];
 
   copyFiles = a.fullDepEntry ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp cfdg $out/bin/
 
-    ensureDir $out/share/doc/${name}
+    mkdir -p $out/share/doc/${name}
     cp *.txt $out/share/doc/${name}
   '' ["defEnsureDir" "doMake"];
       
diff --git a/pkgs/tools/graphics/cuneiform/default.nix b/pkgs/tools/graphics/cuneiform/default.nix
index 232b6c5464a96..13f7d4b7f6fc4 100644
--- a/pkgs/tools/graphics/cuneiform/default.nix
+++ b/pkgs/tools/graphics/cuneiform/default.nix
@@ -22,7 +22,7 @@ rec {
   libc = if a.stdenv ? glibc then a.stdenv.glibc else "";
 
   doCmake = a.fullDepEntry(''
-    ensureDir $PWD/builddir
+    mkdir -p $PWD/builddir
     cd builddir
     export NIX_LDFLAGS="$NIX_LDFLAGS -ldl -L$out/lib"
     cmake .. -DCMAKE_BUILD_TYPE=debug -DCMAKE_INSTALL_PREFIX=$out -DDL_LIB=${libc}/lib
diff --git a/pkgs/tools/graphics/dcraw/default.nix b/pkgs/tools/graphics/dcraw/default.nix
index 8ee02710b05fd..959241d30abf2 100644
--- a/pkgs/tools/graphics/dcraw/default.nix
+++ b/pkgs/tools/graphics/dcraw/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
   '';
 
   buildPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     set +e
     sh install
     set -e
diff --git a/pkgs/tools/graphics/exiftags/default.nix b/pkgs/tools/graphics/exiftags/default.nix
index 32048db4154ea..531e17b92cbb6 100644
--- a/pkgs/tools/graphics/exiftags/default.nix
+++ b/pkgs/tools/graphics/exiftags/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
   '';
 
   preInstall = ''
-    ensureDir $out/bin $out/man/man1
+    mkdir -p $out/bin $out/man/man1
   '';
 
   meta = {
diff --git a/pkgs/tools/graphics/glxinfo/default.nix b/pkgs/tools/graphics/glxinfo/default.nix
index 02db33f92cb19..ed29b743d546f 100644
--- a/pkgs/tools/graphics/glxinfo/default.nix
+++ b/pkgs/tools/graphics/glxinfo/default.nix
@@ -21,7 +21,7 @@ stdenv.mkDerivation {
   ";
 
   installPhase = "
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp glxinfo glxgears $out/bin/
   ";
 }
diff --git a/pkgs/tools/graphics/jhead/default.nix b/pkgs/tools/graphics/jhead/default.nix
index 2d98a1efdce11..c497d60aef9a1 100644
--- a/pkgs/tools/graphics/jhead/default.nix
+++ b/pkgs/tools/graphics/jhead/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
   '';
 
   preInstall = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
   '';
 
   meta = {
diff --git a/pkgs/tools/graphics/pdfread/default.nix b/pkgs/tools/graphics/pdfread/default.nix
index 1fc14445bbdbb..fd26174f197a2 100644
--- a/pkgs/tools/graphics/pdfread/default.nix
+++ b/pkgs/tools/graphics/pdfread/default.nix
@@ -27,13 +27,13 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp pdfread.py $out/bin
     chmod +x $out/bin/pdfread.py
 
     LIBSUFFIX=lib/${python.libPrefix}/site-packages/
     PYDIR=$out/$LIBSUFFIX
-    ensureDir $PYDIR
+    mkdir -p $PYDIR
     cp -R *.py pylrs $PYDIR
 
     wrapProgram $out/bin/pdfread.py --prefix PYTHONPATH : $PYTHONPATH:${pil}/$LIBSUFFIX/PIL:$PYDIR \
diff --git a/pkgs/tools/graphics/ploticus/builder.sh b/pkgs/tools/graphics/ploticus/builder.sh
index 89d4e3b98eaf0..2fb16b259bdcf 100644
--- a/pkgs/tools/graphics/ploticus/builder.sh
+++ b/pkgs/tools/graphics/ploticus/builder.sh
@@ -5,12 +5,12 @@ preBuild() {
 }
 
 preInstall() {
-  ensureDir $out/bin
+  mkdir -p $out/bin
 }
 
 postInstall() {
   # Install the "prefabs".
-  ensureDir $out/share/ploticus/prefabs &&		\
+  mkdir -p $out/share/ploticus/prefabs &&		\
   cd .. &&						\
   cp -rv prefabs/* $out/share/ploticus/prefabs
 
diff --git a/pkgs/tools/graphics/pngcrush/default.nix b/pkgs/tools/graphics/pngcrush/default.nix
index 8e58b8d1903e5..7293c0db66d66 100644
--- a/pkgs/tools/graphics/pngcrush/default.nix
+++ b/pkgs/tools/graphics/pngcrush/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, libpng, xz }:
+{ stdenv, fetchurl, libpng }:
 
 stdenv.mkDerivation rec {
   name = "pngcrush-1.7.22";
@@ -13,7 +13,6 @@ stdenv.mkDerivation rec {
   '';
 
   buildInputs = [ libpng ];
-  buildNativeInputs = [ xz ];
 
   meta = {
     homepage = http://pmt.sourceforge.net/pngcrush;
diff --git a/pkgs/tools/graphics/qrdecode/default.nix b/pkgs/tools/graphics/qrdecode/default.nix
index 16c91720964a5..edd0a96c689f2 100644
--- a/pkgs/tools/graphics/qrdecode/default.nix
+++ b/pkgs/tools/graphics/qrdecode/default.nix
@@ -34,7 +34,7 @@ rec {
     cd ..
   '' ["doMake"];
   createDirs = fullDepEntry ''
-    ensureDir $out/bin $out/lib $out/include $out/share
+    mkdir -p $out/bin $out/lib $out/include $out/share
   '' ["defEnsureDir"];
 
   name = "libdecodeqr-" + version;
diff --git a/pkgs/tools/graphics/transfig/builder.sh b/pkgs/tools/graphics/transfig/builder.sh
index f128c4ce36487..c466f759446ce 100644
--- a/pkgs/tools/graphics/transfig/builder.sh
+++ b/pkgs/tools/graphics/transfig/builder.sh
@@ -31,8 +31,8 @@ buildPhase() {
 }
 
 preInstall() {
-    ensureDir $out
-    ensureDir $out/lib
+    mkdir -p $out
+    mkdir -p $out/lib
 }
 
 genericBuild
diff --git a/pkgs/tools/graphics/welkin/default.nix b/pkgs/tools/graphics/welkin/default.nix
index 0076b2a4a8622..d02b38b41279b 100644
--- a/pkgs/tools/graphics/welkin/default.nix
+++ b/pkgs/tools/graphics/welkin/default.nix
@@ -32,7 +32,7 @@ rec {
   doDeploy = a.simplyShare "welkin";
 
   createBin = a.fullDepEntry ''
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     echo "#! ${a.stdenv.shell}" > "$out/bin/welkin"
     echo "export JAVA_HOME=${jre}" >> "$out/bin/welkin"
     echo "\"$out/share/welkin/welkin.sh\" \"\$@\"" >> "$out/bin/welkin"
diff --git a/pkgs/tools/misc/autojump/default.nix b/pkgs/tools/misc/autojump/default.nix
index ac3aa5a6b1e34..397e80a745ecd 100644
--- a/pkgs/tools/misc/autojump/default.nix
+++ b/pkgs/tools/misc/autojump/default.nix
@@ -21,10 +21,10 @@ let version = "4"; in
     buildInputs = [ python ];
 
     installPhase = ''
-      ensureDir "$out/bin" "$out/share/man/man1"
+      mkdir -p "$out/bin" "$out/share/man/man1"
       yes no | sh ./install.sh
 
-      ensureDir "$out/etc/bash_completion.d"
+      mkdir -p "$out/etc/bash_completion.d"
       cp -v autojump.bash "$out/etc/bash_completion.d"
 
       echo "Bash users: Make sure to source \`$out/etc/bash_completion.d/autojump.bash'"
diff --git a/pkgs/tools/misc/coreutils/default.nix b/pkgs/tools/misc/coreutils/default.nix
index c4295e7b47a8e..597ab802d74e2 100644
--- a/pkgs/tools/misc/coreutils/default.nix
+++ b/pkgs/tools/misc/coreutils/default.nix
@@ -1,16 +1,17 @@
 { stdenv, fetchurl, perl, gmp ? null
 , aclSupport ? false, acl ? null
-, selinuxSupport? false, libselinux ? null, libsepol ? null }:
+, selinuxSupport? false, libselinux ? null, libsepol ? null
+}:
 
 assert aclSupport -> acl != null;
 assert selinuxSupport -> ( (libselinux != null) && (libsepol != null) );
 
-stdenv.mkDerivation (rec {
-  name = "coreutils-8.7";
+stdenv.mkDerivation rec {
+  name = "coreutils-8.15";
 
   src = fetchurl {
-    url = "mirror://gnu/coreutils/${name}.tar.gz";
-    sha256 = "11ykd7glys6lcfb2mwgmkqmmffv1pan70j6sl9vcjpnlf9dvk7bw";
+    url = "mirror://gnu/coreutils/${name}.tar.xz";
+    sha256 = "176lgw810xw84c6fz5xwhydxggkndmzggl0pxqzldbjf85vv6zl3";
   };
 
   buildNativeInputs = [ perl ];
@@ -41,6 +42,8 @@ stdenv.mkDerivation (rec {
 
   enableParallelBuilding = true;
 
+  NIX_LDFLAGS = stdenv.lib.optionalString selinuxSupport "-lsepol";
+
   meta = {
     homepage = http://www.gnu.org/software/coreutils/;
     description = "The basic file, shell and text manipulation utilities of the GNU operating system";
@@ -56,5 +59,5 @@ stdenv.mkDerivation (rec {
 
     maintainers = [ stdenv.lib.maintainers.ludo ];
   };
-} // (if selinuxSupport then { NIX_LDFLAGS = "-lsepol"; } else { } ) )
+}
 
diff --git a/pkgs/tools/misc/debootstrap/default.nix b/pkgs/tools/misc/debootstrap/default.nix
index 53027246b7f2a..33a1fc839ce09 100644
--- a/pkgs/tools/misc/debootstrap/default.nix
+++ b/pkgs/tools/misc/debootstrap/default.nix
@@ -36,7 +36,7 @@ stdenv.mkDerivation {
   installPhase = ''
     cp -r . $out; cd $out
     t=bin/debootstrap
-    ensureDir bin man/man8
+    mkdir -p bin man/man8
     cat >> $t << EOF
     #!/bin/sh
     export DEBOOTSTRAP_DIR=$out/usr/share/debootstrap
@@ -66,7 +66,7 @@ stdenv.mkDerivation {
   /* build from source:
   installPhase = ''
     cp ${devices} devices.tar.gz
-    ensureDir $out/{bin,man/man8};
+    mkdir -p $out/{bin,man/man8};
     cp debootstrap.8 $out/man/man8
     sed -i  \
       -e 's@-o root@@'   \
diff --git a/pkgs/tools/misc/dmg2img/default.nix b/pkgs/tools/misc/dmg2img/default.nix
index 72e368e709e1b..b9a15ac6a2045 100644
--- a/pkgs/tools/misc/dmg2img/default.nix
+++ b/pkgs/tools/misc/dmg2img/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   buildInputs = [zlib bzip2 openssl];
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp dmg2img $out/bin
   '';
 }
diff --git a/pkgs/tools/misc/dtach/default.nix b/pkgs/tools/misc/dtach/default.nix
index d203419cd69a3..7ceecc3690ab9 100644
--- a/pkgs/tools/misc/dtach/default.nix
+++ b/pkgs/tools/misc/dtach/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
   };
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp dtach $out/bin/dtach
   '';
 
diff --git a/pkgs/tools/misc/expect/default.nix b/pkgs/tools/misc/expect/default.nix
index f72452f60798e..d9f9b09271b5e 100644
--- a/pkgs/tools/misc/expect/default.nix
+++ b/pkgs/tools/misc/expect/default.nix
@@ -32,5 +32,5 @@ stdenv.mkDerivation {
     description = "A tool for automating interactive applications";
     homepage = http://expect.nist.gov/;
   };
-  postInstall="cp expect{,k} $out/bin; ensureDir $out/lib; cp *.so $out/lib";
+  postInstall="cp expect{,k} $out/bin; mkdir -p $out/lib; cp *.so $out/lib";
 }
diff --git a/pkgs/tools/misc/fdupes/default.nix b/pkgs/tools/misc/fdupes/default.nix
index 04a0662a3b6e1..2de9efdac58a4 100644
--- a/pkgs/tools/misc/fdupes/default.nix
+++ b/pkgs/tools/misc/fdupes/default.nix
@@ -8,7 +8,7 @@ stdenv.mkDerivation {
   };
 
   # workaround: otherwise make install fails (should be fixed in trunk)
-  preInstall = "ensureDir $out/bin $out/man/man1";
+  preInstall = "mkdir -p $out/bin $out/man/man1";
 
   makeFlags = "PREFIX=\${out}";
 
diff --git a/pkgs/tools/misc/figlet/default.nix b/pkgs/tools/misc/figlet/default.nix
index 00265d1f31d4c..3f89713918fcd 100644
--- a/pkgs/tools/misc/figlet/default.nix
+++ b/pkgs/tools/misc/figlet/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
   };
 
   preConfigure = ''
-    ensureDir $out/{man/man6,bin}
+    mkdir -p $out/{man/man6,bin}
     makeFlags="DESTDIR=$out/bin MANDIR=$out/man/man6 DEFAULTFONTDIR=$out/share/figlet"
   '';
 
diff --git a/pkgs/tools/misc/grub/1.9x.nix b/pkgs/tools/misc/grub/1.9x.nix
index 14a4932f10034..49cc4884e6365 100644
--- a/pkgs/tools/misc/grub/1.9x.nix
+++ b/pkgs/tools/misc/grub/1.9x.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, xz, flex, bison, gettext, ncurses, libusb, freetype, qemu
+{ fetchurl, stdenv, flex, bison, gettext, ncurses, libusb, freetype, qemu
 , EFIsupport ? false }:
 
 let
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
     sha256 = "06q2a7bg1mbsms604a89fkdnwrc1jg9hr2mmfdmg3il39j6i827k";
   };
 
-  buildNativeInputs = [ xz flex bison ];
+  buildNativeInputs = [ flex bison ];
   buildInputs = [ ncurses libusb freetype gettext ]
     ++ stdenv.lib.optional doCheck qemu;
 
diff --git a/pkgs/tools/misc/hddtemp/default.nix b/pkgs/tools/misc/hddtemp/default.nix
index 202d28684d0c8..7db9324c2813a 100644
--- a/pkgs/tools/misc/hddtemp/default.nix
+++ b/pkgs/tools/misc/hddtemp/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation {
 
   configurePhase =
     ''
-      ensureDir $out/nix-support
+      mkdir -p $out/nix-support
       cp $db $out/nix-support/hddtemp.db
       ./configure --prefix=$out --with-db-path=$out/nix-support/hddtemp.db
     ''; 
diff --git a/pkgs/tools/misc/jdiskreport/builder.sh b/pkgs/tools/misc/jdiskreport/builder.sh
index aa4ba13963cd3..1e73b674c157d 100644
--- a/pkgs/tools/misc/jdiskreport/builder.sh
+++ b/pkgs/tools/misc/jdiskreport/builder.sh
@@ -2,11 +2,11 @@ source $stdenv/setup
 
 unzip $src
 
-ensureDir $out/jars
+mkdir -p $out/jars
 mv */*.jar $out/jars
 jar=$(ls $out/jars/jdiskreport-*.jar)
 
-ensureDir $out/bin
+mkdir -p $out/bin
 cat > $out/bin/jdiskreport <<EOF
 #! $SHELL -e
 exec $jdk/bin/java -jar $jar
diff --git a/pkgs/tools/misc/kermit/default.nix b/pkgs/tools/misc/kermit/default.nix
index b664e9d92b6af..db2d6cffc4089 100644
--- a/pkgs/tools/misc/kermit/default.nix
+++ b/pkgs/tools/misc/kermit/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
   buildInputs = [ ncurses ];
 
   unpackPhase = ''
-    ensureDir src
+    mkdir -p src
     pushd src
     tar xvzf $src
   '';
@@ -22,8 +22,8 @@ stdenv.mkDerivation {
   '';
   buildPhase = "make -f makefile linux";
   installPhase = ''
-    ensureDir $out/bin
-    ensureDir $out/man/man1
+    mkdir -p $out/bin
+    mkdir -p $out/man/man1
     make -f makefile install
   '';
 
diff --git a/pkgs/tools/misc/man/conf.patch b/pkgs/tools/misc/man/conf.patch
new file mode 100644
index 0000000000000..43e8642fb34a3
--- /dev/null
+++ b/pkgs/tools/misc/man/conf.patch
@@ -0,0 +1,14 @@
+diff -ru -x '*~' man-1.6g-orig/src/man-config.c man-1.6g/src/man-config.c
+--- man-1.6g-orig/src/man-config.c	2005-08-21 01:26:06.000000000 +0200
++++ man-1.6g/src/man-config.c	2012-03-06 11:11:28.159050524 +0100
+@@ -214,8 +214,9 @@
+ const char *configuration_file = "[no configuration file]";
+ 
+ char *default_config_files[] = {
++    "/etc/man.conf",
+      CONFIG_FILE,		/* compiled-in default */
+-     "/etc/man.conf", "/etc/man.config",
++     "/etc/man.config",
+      "/usr/lib/man.conf", "/usr/lib/man.config",
+      "/usr/share/misc/man.conf", "/usr/share/misc/man.config"
+ };
diff --git a/pkgs/tools/misc/man/default.nix b/pkgs/tools/misc/man/default.nix
index 9e80cc691791c..12e888813fb95 100644
--- a/pkgs/tools/misc/man/default.nix
+++ b/pkgs/tools/misc/man/default.nix
@@ -1,14 +1,14 @@
-{stdenv, fetchurl, groff, less}:
+{ stdenv, fetchurl, groff, less }:
  
-stdenv.mkDerivation {
-  name = "man-1.6f";
-  
+stdenv.mkDerivation rec {
+  name = "man-1.6g";
+
   src = fetchurl {
-    url = http://primates.ximian.com/~flucifredi/man/man-1.6f.tar.gz;
-    sha256 = "0v2z6ywhy8kd2fa3ywkqayhjdivbaqn6qvhx93a1ldw135z8q84z";
+    url = "http://primates.ximian.com/~flucifredi/man/${name}.tar.gz";
+    sha256 = "17wmp2ahkhl72cvfzshmck22dnq2lbjg0678swihj270yk1vip6c";
   };
   
-  buildInputs = [groff less];
+  buildInputs = [ groff less ];
 
   preBuild = ''
     makeFlagsArray=(bindir=$out/bin sbindir=$out/sbin libdir=$out/lib mandir=$out/share/man)
@@ -17,6 +17,11 @@ stdenv.mkDerivation {
   patches = [
     # Search in "share/man" relative to each path in $PATH (in addition to "man").
     ./share.patch
+
+    # Prefer /etc/man.conf over $out/lib/man.conf.  Man only reads the
+    # first file that exists, so this is necessary to allow the
+    # builtin config to be overriden.
+    ./conf.patch
   ];
 
   preConfigure = ''
@@ -30,6 +35,11 @@ stdenv.mkDerivation {
       substituteInPlace $out/lib/man.conf \
         --replace "nroff -Tlatin1" "nroff" \
         --replace "eqn -Tlatin1" "eqn -Tutf8"
+
+      # Work around a bug in substituteInPlace.  It loses the final
+      # newline, and man requires every line in man.conf to be
+      # terminated by a newline.
+      echo >> $out/lib/man.conf
     '';
 
   meta = {
diff --git a/pkgs/tools/misc/memtest86/default.nix b/pkgs/tools/misc/memtest86/default.nix
index 1e744afdf409c..633d08e4c6660 100644
--- a/pkgs/tools/misc/memtest86/default.nix
+++ b/pkgs/tools/misc/memtest86/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation {
   NIX_CFLAGS_COMPILE = "-I.";
   
   installPhase = ''
-    ensureDir $out
+    mkdir -p $out
     cp memtest.bin $out/
   '';
 
diff --git a/pkgs/tools/misc/most/default.nix b/pkgs/tools/misc/most/default.nix
index 98e5d5c25af5a..941d805a6ffb2 100644
--- a/pkgs/tools/misc/most/default.nix
+++ b/pkgs/tools/misc/most/default.nix
@@ -1,22 +1,23 @@
-{stdenv, fetchurl, slang}:
+{ stdenv, fetchurl, slang, ncurses }:
 
 stdenv.mkDerivation {
   name = "most-5.0.0";
 
   src = fetchurl {
-      url = ftp://space.mit.edu/pub/davis/most/most-5.0.0.tar.bz2;
-      sha256 = "1f5x7rvjg89b5klfqs1gb91jmbnd3fy08d8rwgdvgg0plqkxr7ja";
+    url = ftp://space.mit.edu/pub/davis/most/most-5.0.0.tar.bz2;
+    sha256 = "1f5x7rvjg89b5klfqs1gb91jmbnd3fy08d8rwgdvgg0plqkxr7ja";
   };
 
   preConfigure = ''
-    sed -i -e "s|-ltermcap|-ncurses|" configure
+    sed -i -e "s|-ltermcap|-lncurses|" configure
     sed -i autoconf/Makefile.in src/Makefile.in \
       -e "s|/bin/cp|cp|"  \
       -e "s|/bin/rm|rm|"
   '';
+  
   configureFlags = "--with-slang=${slang}";
 
-  buildInputs = [ slang ];
+  buildInputs = [ slang ncurses ];
 
   meta = {
     description = ''
diff --git a/pkgs/tools/misc/myhasktags/default.nix b/pkgs/tools/misc/myhasktags/default.nix
index 8c5eb24af484f..62d4ee2579f0d 100644
--- a/pkgs/tools/misc/myhasktags/default.nix
+++ b/pkgs/tools/misc/myhasktags/default.nix
@@ -26,7 +26,7 @@ stdenv.mkDerivation {
   };
   phases="buildPhase";
   buildPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     ghc --make $src -o $out/bin/hasktags-modified
   '';
   buildInputs = [ ghcPlain ];
diff --git a/pkgs/tools/misc/parted/2.3.nix b/pkgs/tools/misc/parted/2.3.nix
index 622753e2303ab..649def691155e 100644
--- a/pkgs/tools/misc/parted/2.3.nix
+++ b/pkgs/tools/misc/parted/2.3.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, devicemapper, libuuid, gettext, readline
-, utillinuxng, xz, enableStatic ? false, hurd ? null }:
+, utillinux, enableStatic ? false, hurd ? null }:
 
 stdenv.mkDerivation rec {
   name = "parted-2.3";
@@ -9,7 +9,6 @@ stdenv.mkDerivation rec {
     sha256 = "0sabj81nawcjm8ww34lxg65ka8crv3w2ab4crh8ypw5agg681836";
   };
 
-  buildNativeInputs = [ xz ];
   buildInputs = [ libuuid ]
     ++ stdenv.lib.optional (readline != null) readline
     ++ stdenv.lib.optional (gettext != null) gettext
@@ -28,7 +27,7 @@ stdenv.mkDerivation rec {
   preCheck =
     stdenv.lib.optionalString doCheck
       # The `t0400-loop-clobber-infloop.sh' test wants `mkswap'.
-      "export PATH=\"${utillinuxng}/sbin:$PATH\"";
+      "export PATH=\"${utillinux}/sbin:$PATH\"";
 
   meta = {
     description = "GNU Parted, a tool to create, destroy, resize, check, and copy partitions";
diff --git a/pkgs/tools/misc/parted/default.nix b/pkgs/tools/misc/parted/default.nix
index 8ceab316be924..3d217d2660c57 100644
--- a/pkgs/tools/misc/parted/default.nix
+++ b/pkgs/tools/misc/parted/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, devicemapper, libuuid, gettext, readline
-, utillinuxng, xz, check, enableStatic ? false, hurd ? null }:
+, utillinux, check, enableStatic ? false, hurd ? null }:
 
 stdenv.mkDerivation rec {
   name = "parted-3.0";
@@ -9,7 +9,6 @@ stdenv.mkDerivation rec {
     sha256 = "054ybvjkj1mbm4mpn1rl12jzhvqg37b0xwwr4ly1zisvzrjhi11a";
   };
 
-  buildNativeInputs = [ xz ];
   buildInputs = [ libuuid ]
     ++ stdenv.lib.optional (readline != null) readline
     ++ stdenv.lib.optional (gettext != null) gettext
@@ -29,7 +28,7 @@ stdenv.mkDerivation rec {
   preCheck =
     stdenv.lib.optionalString doCheck
       # The `t0400-loop-clobber-infloop.sh' test wants `mkswap'.
-      "export PATH=\"${utillinuxng}/sbin:$PATH\"";
+      "export PATH=\"${utillinux}/sbin:$PATH\"";
 
   meta = {
     description = "GNU Parted, a tool to create, destroy, resize, check, and copy partitions";
diff --git a/pkgs/tools/misc/pk2cmd/default.nix b/pkgs/tools/misc/pk2cmd/default.nix
index e3a9e7b87c3d9..37636da723506 100644
--- a/pkgs/tools/misc/pk2cmd/default.nix
+++ b/pkgs/tools/misc/pk2cmd/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation {
   makeFlags = [ "LIBUSB=${libusb}" "linux" ];
 
   installPhase = ''
-    ensureDir $out/bin $out/share/pk2
+    mkdir -p $out/bin $out/share/pk2
     cp pk2cmd $out/bin
     cp PK2DeviceFile.dat $out/share/pk2
     wrapProgram $out/bin/pk2cmd --prefix PATH : $out/share/pk2
diff --git a/pkgs/tools/misc/qjoypad/default.nix b/pkgs/tools/misc/qjoypad/default.nix
index b6c69be2f09ed..a3a34d95fb5b3 100644
--- a/pkgs/tools/misc/qjoypad/default.nix
+++ b/pkgs/tools/misc/qjoypad/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
   patchPhase = ''
     cd src
     substituteInPlace config --replace /bin/bash /bin/sh
-    ensureDir $out
+    mkdir -p $out
     export NIX_LDFLAGS="$NIX_LDFLAGS -rpath ${libX11}/lib"
   '';
   meta = {
diff --git a/pkgs/tools/misc/rockbox-utility/default.nix b/pkgs/tools/misc/rockbox-utility/default.nix
index d2fa91d3fe80e..4f271bcd6237e 100644
--- a/pkgs/tools/misc/rockbox-utility/default.nix
+++ b/pkgs/tools/misc/rockbox-utility/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation  rec {
   '';
 
   installPhase = ''
-    ensureDir $out/bin 
+    mkdir -p $out/bin 
     cp RockboxUtility $out/bin
   '';
 
diff --git a/pkgs/tools/misc/shebangfix/default.nix b/pkgs/tools/misc/shebangfix/default.nix
index 082b04b95d783..68f20df057765 100644
--- a/pkgs/tools/misc/shebangfix/default.nix
+++ b/pkgs/tools/misc/shebangfix/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
   phases = "buildPhase";
 
   buildPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     s=$out/bin/shebangfix
     cp $file $s
     chmod +wx $s
diff --git a/pkgs/tools/misc/system-config-printer/default.nix b/pkgs/tools/misc/system-config-printer/default.nix
index a7a08f291872f..8923637bbdbf7 100644
--- a/pkgs/tools/misc/system-config-printer/default.nix
+++ b/pkgs/tools/misc/system-config-printer/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, udev, intltool, pkgconfig, glib, xmlto
 , makeWrapper, pygobject, pygtk, docbook_xml_dtd_412, docbook_xsl
 , pythonDBus, libxml2, desktop_file_utils, libusb, cups, pycups
-, xz, pythonPackages
+, pythonPackages
 , withGUI ? true
 }:
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs =
-    [ xz intltool pkgconfig glib udev libusb cups xmlto
+    [ intltool pkgconfig glib udev libusb cups xmlto
       libxml2 docbook_xml_dtd_412 docbook_xsl desktop_file_utils
       pythonPackages.python pythonPackages.wrapPython
     ];
diff --git a/pkgs/tools/misc/ttf2pt1/default.nix b/pkgs/tools/misc/ttf2pt1/default.nix
index c112afaee0f43..2deb8893f4e06 100644
--- a/pkgs/tools/misc/ttf2pt1/default.nix
+++ b/pkgs/tools/misc/ttf2pt1/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
 
   preConfigure = ''
     find -type f | xargs sed -i 's@/usr/bin/perl@${perl}/bin/perl@'
-    ensureDir $out
+    mkdir -p $out
     sed -e 's/chown/true/' \
         -e 's/chgrp/true/' \
         -e 's@^CFLAGS_FT =.*@CFLAGS_FT=-DUSE_FREETYPE -I${freetype}/include/freetype2@' \
diff --git a/pkgs/tools/misc/ttmkfdir/default.nix b/pkgs/tools/misc/ttmkfdir/default.nix
index e4e8d3c3e9b54..3f05d600944bc 100644
--- a/pkgs/tools/misc/ttmkfdir/default.nix
+++ b/pkgs/tools/misc/ttmkfdir/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation {
     ];
 
   preInstall = ''
-    ensureDir $out; makeFlags="DESTDIR=$out BINDIR=/bin"
+    mkdir -p $out; makeFlags="DESTDIR=$out BINDIR=/bin"
   '';
 
   buildInputs = [freetype fontconfig libunwind libtool flex bison];
diff --git a/pkgs/tools/misc/vfdecrypt/default.nix b/pkgs/tools/misc/vfdecrypt/default.nix
index 46a841113a171..5692aecebbf0e 100644
--- a/pkgs/tools/misc/vfdecrypt/default.nix
+++ b/pkgs/tools/misc/vfdecrypt/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
   };
   buildInputs = [openssl];
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp vfdecrypt $out/bin
   '';
 }
diff --git a/pkgs/tools/misc/w3c-css-validator/default.nix b/pkgs/tools/misc/w3c-css-validator/default.nix
index 93231397feb57..5cfe873763888 100644
--- a/pkgs/tools/misc/w3c-css-validator/default.nix
+++ b/pkgs/tools/misc/w3c-css-validator/default.nix
@@ -53,7 +53,7 @@ stdenv.mkDerivation {
           -e '/untar/d' \
           build.xml
     ant
-    ensureDir $out/{bin,lib}
+    mkdir -p $out/{bin,lib}
     JAR=$out/lib/css-validator.jar
     cat >> $out/bin/css-validator << EOF
     #!/bin/sh
diff --git a/pkgs/tools/misc/xdaliclock/default.nix b/pkgs/tools/misc/xdaliclock/default.nix
index cb2631bd5d84b..74ee8b5b54844 100644
--- a/pkgs/tools/misc/xdaliclock/default.nix
+++ b/pkgs/tools/misc/xdaliclock/default.nix
@@ -32,7 +32,7 @@ rec {
   phaseNames = ["doConfigure" "prepareDirs" "doMakeInstall"];
 
   prepareDirs = a.fullDepEntry ''
-    ensureDir "$out/bin" "$out/share" "$out/share/man/man1"
+    mkdir -p "$out/bin" "$out/share" "$out/share/man/man1"
   '' ["minInit" "defEnsureDir"];
 
   goSrcDir = "cd X11";
diff --git a/pkgs/tools/networking/altermime/default.nix b/pkgs/tools/networking/altermime/default.nix
index a98f307c77dc9..8335b0eb8db32 100644
--- a/pkgs/tools/networking/altermime/default.nix
+++ b/pkgs/tools/networking/altermime/default.nix
@@ -31,7 +31,7 @@ rec {
   phaseNames = ["doPatch" "fixTarget" "doMakeInstall"];
   fixTarget = a.fullDepEntry (''
     sed -i Makefile -e "s@/usr/local@$out@"
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
   '') ["doUnpack" "minInit" "defEnsureDir"];
       
   meta = {
diff --git a/pkgs/tools/networking/bsd-finger/default.nix b/pkgs/tools/networking/bsd-finger/default.nix
index fc29af989ceab..808c738110e0d 100644
--- a/pkgs/tools/networking/bsd-finger/default.nix
+++ b/pkgs/tools/networking/bsd-finger/default.nix
@@ -16,5 +16,5 @@ stdenv.mkDerivation rec {
 
   preBuild = "cd finger";
 
-  preInstall = '' ensureDir $out/man/man1 $out/bin '';
+  preInstall = '' mkdir -p $out/man/man1 $out/bin '';
 }
diff --git a/pkgs/tools/networking/cntlm/default.nix b/pkgs/tools/networking/cntlm/default.nix
index f586502078544..cd3ae12a11b8e 100644
--- a/pkgs/tools/networking/cntlm/default.nix
+++ b/pkgs/tools/networking/cntlm/default.nix
@@ -11,9 +11,9 @@ stdenv.mkDerivation {
   buildInputs = [ which ];
 
   installPhase = ''
-    ensureDir $out/bin; cp cntlm $out/bin/;
-    ensureDir $out/share/; cp COPYRIGHT README VERSION doc/cntlm.conf $out/share/;
-    ensureDir $out/man/; cp doc/cntlm.1 $out/man/;
+    mkdir -p $out/bin; cp cntlm $out/bin/;
+    mkdir -p $out/share/; cp COPYRIGHT README VERSION doc/cntlm.conf $out/share/;
+    mkdir -p $out/man/; cp doc/cntlm.1 $out/man/;
   '';
 
   meta = {
diff --git a/pkgs/tools/networking/curl/default.nix b/pkgs/tools/networking/curl/default.nix
index 7aee342f4a31c..cd83ede9df490 100644
--- a/pkgs/tools/networking/curl/default.nix
+++ b/pkgs/tools/networking/curl/default.nix
@@ -56,7 +56,7 @@ stdenv.mkDerivation rec {
   };
 
   preConfigure = ''
-    substituteInPlace configure --replace /usr/bin /no-such-path
+    sed -e 's|/usr/bin|/no-such-path|g' -i.bak configure
   '';
 
   meta = {
diff --git a/pkgs/tools/networking/ddclient/default.nix b/pkgs/tools/networking/ddclient/default.nix
index 7c1e89083b870..e57ba489450fb 100644
--- a/pkgs/tools/networking/ddclient/default.nix
+++ b/pkgs/tools/networking/ddclient/default.nix
@@ -15,7 +15,7 @@ buildPerlPackage {
   ''; 
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp ddclient $out/bin
   '';
 
diff --git a/pkgs/tools/networking/dnstop/default.nix b/pkgs/tools/networking/dnstop/default.nix
index cdab68f22ea9d..c9e1b58d2d2c5 100644
--- a/pkgs/tools/networking/dnstop/default.nix
+++ b/pkgs/tools/networking/dnstop/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
   buildInputs = [ libpcap ncurses ];
 
   preInstall = ''
-    ensureDir $out/share/man/man8 $out/bin
+    mkdir -p $out/share/man/man8 $out/bin
   '';
 
   meta = { 
diff --git a/pkgs/tools/networking/eggdrop/default.nix b/pkgs/tools/networking/eggdrop/default.nix
index c55688d5060a1..8649eda4bf716 100644
--- a/pkgs/tools/networking/eggdrop/default.nix
+++ b/pkgs/tools/networking/eggdrop/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation {
 
   preConfigure = ''
     prefix=$out/eggdrop
-    ensureDir $prefix
+    mkdir -p $prefix
   '';
 
   postConfigure = ''
diff --git a/pkgs/tools/networking/flvstreamer/default.nix b/pkgs/tools/networking/flvstreamer/default.nix
index c3ac4e205ae22..cbc07522019a3 100644
--- a/pkgs/tools/networking/flvstreamer/default.nix
+++ b/pkgs/tools/networking/flvstreamer/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   '';
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp flvstreamer $out/bin
     cp streams $out/bin
     cp rtmpsrv $out/bin
diff --git a/pkgs/tools/networking/getmail/default.nix b/pkgs/tools/networking/getmail/default.nix
index 23fe3ad367403..147a9673abf6d 100644
--- a/pkgs/tools/networking/getmail/default.nix
+++ b/pkgs/tools/networking/getmail/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, buildPythonPackage, pythonPackages }:
+{ stdenv, fetchurl, buildPythonPackage }:
 
 buildPythonPackage rec {
   name = "getmail-4.20.0";
@@ -9,8 +9,6 @@ buildPythonPackage rec {
     sha256 = "17cpyra61virk1d223w8pdwhv2qzhbwdbnrr1ab1znf4cv9m3knn";
   };
 
-  pythonPath = [ pythonPackages.ssl ];
-
   doCheck = false;
 
   installCommand = "python setup.py install --prefix=\"\$prefix\"";
diff --git a/pkgs/tools/networking/host/default.nix b/pkgs/tools/networking/host/default.nix
index 9383b857a3a74..c74dbe5282903 100644
--- a/pkgs/tools/networking/host/default.nix
+++ b/pkgs/tools/networking/host/default.nix
@@ -11,8 +11,8 @@ let version = "20000331"; in
 
     preConfigure = ''
       makeFlagsArray=(DESTBIN=$out/bin DESTMAN=$out/share/man OWNER=$(id -u) GROUP=$(id -g))
-      ensureDir "$out/bin"
-      ensureDir "$out/share/man/man1"
+      mkdir -p "$out/bin"
+      mkdir -p "$out/share/man/man1"
     '';
 
     installTargets = "install man";
diff --git a/pkgs/tools/networking/lftp/default.nix b/pkgs/tools/networking/lftp/default.nix
index 1b651cab996ce..64e7ac50bc0f9 100644
--- a/pkgs/tools/networking/lftp/default.nix
+++ b/pkgs/tools/networking/lftp/default.nix
@@ -8,5 +8,5 @@ stdenv.mkDerivation rec {
     sha256 = "0v3591fknmimarzk5icm0qxdcfzfckwi2drh165vsiggmj590iyx";
   };
 
-  buildInputs = [gnutls libtasn1 pkgconfig readline zlib xz];
+  buildInputs = [gnutls libtasn1 pkgconfig readline zlib];
 }
diff --git a/pkgs/tools/networking/miniupnpc/default.nix b/pkgs/tools/networking/miniupnpc/default.nix
index 1039cadb3ee55..34ec8eed90ea5 100644
--- a/pkgs/tools/networking/miniupnpc/default.nix
+++ b/pkgs/tools/networking/miniupnpc/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
 
   postInstall =
     ''
-      ensureDir $out/share/man/man3
+      mkdir -p $out/share/man/man3
       cp man3/miniupnpc.3 $out/share/man/man3/
     '';
 
diff --git a/pkgs/tools/networking/miniupnpd/default.nix b/pkgs/tools/networking/miniupnpd/default.nix
index 5d62222d1419b..6db47f8e079fc 100644
--- a/pkgs/tools/networking/miniupnpd/default.nix
+++ b/pkgs/tools/networking/miniupnpd/default.nix
@@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
 
   postInstall =
     ''
-      ensureDir $out/share/man/man1
+      mkdir -p $out/share/man/man1
       cp miniupnpd.1 $out/share/man/man1/
     '';
 
diff --git a/pkgs/tools/networking/modemmanager/default.nix b/pkgs/tools/networking/modemmanager/default.nix
index b17894edfabc5..c9c975d557c65 100644
--- a/pkgs/tools/networking/modemmanager/default.nix
+++ b/pkgs/tools/networking/modemmanager/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl_gnome, udev, polkit, dbus_glib, ppp, intltool, pkgconfig, xz }:
+{ stdenv, fetchurl_gnome, udev, polkit, dbus_glib, ppp, intltool, pkgconfig }:
 
 stdenv.mkDerivation rec {
   name = src.pkgname;
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
     sha256 = "0zvwrni4l21d856nq28khigrhwgrq5cc7nh45zidwjj8q7bsxiz7";
   };
 
-  buildNativeInputs = [ xz intltool pkgconfig ];
+  buildNativeInputs = [ intltool pkgconfig ];
 
   buildInputs = [ udev polkit dbus_glib ppp ];
 
diff --git a/pkgs/tools/networking/netboot/default.nix b/pkgs/tools/networking/netboot/default.nix
index a834ffc37396e..684507a1d2e0c 100644
--- a/pkgs/tools/networking/netboot/default.nix
+++ b/pkgs/tools/networking/netboot/default.nix
@@ -37,7 +37,7 @@ rec {
   '' ["doUnpack" "addInputs"];
 
   doDeploy = a.fullDepEntry ''
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     cp netboot "$out/bin"
   '' ["defEnsureDir" "minInit"];
       
diff --git a/pkgs/tools/networking/netkit/tftp/default.nix b/pkgs/tools/networking/netkit/tftp/default.nix
index adf85a981d1b7..6b9763972dfb4 100644
--- a/pkgs/tools/networking/netkit/tftp/default.nix
+++ b/pkgs/tools/networking/netkit/tftp/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
   };
 
   preInstall = "
-    ensureDir $out/man/man{1,8} $out/sbin $out/bin
+    mkdir -p $out/man/man{1,8} $out/sbin $out/bin
   ";
 
   meta = {
diff --git a/pkgs/tools/networking/network-manager-applet/default.nix b/pkgs/tools/networking/network-manager-applet/default.nix
index 0a8832f4b5198..ba743722e3b8e 100644
--- a/pkgs/tools/networking/network-manager-applet/default.nix
+++ b/pkgs/tools/networking/network-manager-applet/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, intltool, pkgconfig, gtk, glib, libglade
 , networkmanager, GConf, libnotify, gnome_keyring, dbus_glib
-, polkit, isocodes, xz }:
+, polkit, isocodes }:
 
 let
   pn = "network-manager-applet";
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ gtk libglade networkmanager GConf libnotify gnome_keyring
     polkit isocodes ];
 
-  buildNativeInputs = [ intltool pkgconfig xz ];
+  buildNativeInputs = [ intltool pkgconfig ];
 
   meta = with stdenv.lib; {
     homepage = http://projects.gnome.org/NetworkManager/;
diff --git a/pkgs/tools/networking/network-manager/pptp.nix b/pkgs/tools/networking/network-manager/pptp.nix
index dbb66a43d3802..3abea68366dc0 100644
--- a/pkgs/tools/networking/network-manager/pptp.nix
+++ b/pkgs/tools/networking/network-manager/pptp.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, networkmanager, pptp, ppp, xz, intltool, pkgconfig }:
+{ stdenv, fetchurl, networkmanager, pptp, ppp, intltool, pkgconfig }:
 
 let
   pn = "networkmanager-pptp";
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ networkmanager pptp ppp ];
 
-  buildNativeInputs = [ xz intltool pkgconfig ];
+  buildNativeInputs = [ intltool pkgconfig ];
 
   configureFlags = "--without-gnome --disable-nls";
 }
diff --git a/pkgs/tools/networking/offlineimap/default.nix b/pkgs/tools/networking/offlineimap/default.nix
index 8f0dd8e9a6cb4..007c8f7c6e076 100644
--- a/pkgs/tools/networking/offlineimap/default.nix
+++ b/pkgs/tools/networking/offlineimap/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, buildPythonPackage, ssl }:
+{ fetchurl, buildPythonPackage }:
 
 buildPythonPackage {
   name = "offlineimap-6.2.0.2";
@@ -8,8 +8,6 @@ buildPythonPackage {
     sha256 = "1w69qv1dm37m53k8cd068lk5z3qjlscnjxr397gs8kdsfds67v7c";
   };
 
-  propagatedBuildInputs = [ ssl ];
-
   doCheck = false;
 
   meta = {
diff --git a/pkgs/tools/networking/openssh/default.nix b/pkgs/tools/networking/openssh/default.nix
index 7ea15198f1690..b41bd432848ed 100644
--- a/pkgs/tools/networking/openssh/default.nix
+++ b/pkgs/tools/networking/openssh/default.nix
@@ -45,7 +45,7 @@ stdenv.mkDerivation rec {
   preConfigure =
     ''
       configureFlags="$configureFlags --with-privsep-path=$out/empty"
-      ensureDir $out/empty
+      mkdir -p $out/empty
     '';
 
   postInstall =
@@ -55,7 +55,7 @@ stdenv.mkDerivation rec {
       chmod +x $out/bin/ssh-copy-id
       cp contrib/ssh-copy-id.1 $out/share/man/man1/
 
-      ensureDir $out/etc/ssh
+      mkdir -p $out/etc/ssh
       cp moduli $out/etc/ssh/
     '';
 
diff --git a/pkgs/tools/networking/p2p/azureus/builder.sh b/pkgs/tools/networking/p2p/azureus/builder.sh
index 13b7a48319277..9d41dba2e439e 100644
--- a/pkgs/tools/networking/p2p/azureus/builder.sh
+++ b/pkgs/tools/networking/p2p/azureus/builder.sh
@@ -1,9 +1,9 @@
 source $stdenv/setup
 
-ensureDir $out/jars
+mkdir -p $out/jars
 cp $src $out/jars/azureus.jar
 
-ensureDir $out/bin
+mkdir -p $out/bin
 cat > $out/bin/azureus <<EOF
 #! $SHELL -e
 azureusHome=$out
diff --git a/pkgs/tools/networking/p2p/bit-tornado/default.nix b/pkgs/tools/networking/p2p/bit-tornado/default.nix
index 52f4e0d7138b3..14e13a17559f1 100644
--- a/pkgs/tools/networking/p2p/bit-tornado/default.nix
+++ b/pkgs/tools/networking/p2p/bit-tornado/default.nix
@@ -1,5 +1,4 @@
-{stdenv,fetchurl,python, wxPython, makeWrapper, 
-  ssl}:
+{ stdenv,fetchurl,python, wxPython, makeWrapper }:
 stdenv.mkDerivation {
   name = "bit-tornado-0.3.18";
 
@@ -8,7 +7,7 @@ stdenv.mkDerivation {
     sha256 = "1q6rapidnizy8wawasirgyjl9s4lrm7mm740mc5q5sdjyl5svrnr";
   };
 
-  buildInputs = [python wxPython makeWrapper ssl];
+  buildInputs = [ python wxPython makeWrapper ];
 
   buildPhase = '' '';
   installPhase = ''
diff --git a/pkgs/tools/networking/p2p/rtorrent/default.nix b/pkgs/tools/networking/p2p/rtorrent/default.nix
index 4056c6429b061..ae52865eace84 100644
--- a/pkgs/tools/networking/p2p/rtorrent/default.nix
+++ b/pkgs/tools/networking/p2p/rtorrent/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation {
   buildInputs = [ libtorrent ncurses pkgconfig libsigcxx curl zlib openssl ];
 
   postInstall = ''
-    ensureDir $out/share/man/man1
+    mkdir -p $out/share/man/man1
     mv doc/rtorrent.1 $out/share/man/man1/rtorrent.1
   '';
 
diff --git a/pkgs/tools/networking/p2p/tahoe-lafs/default.nix b/pkgs/tools/networking/p2p/tahoe-lafs/default.nix
index b48600a9f9961..5ef4a640d2a04 100644
--- a/pkgs/tools/networking/p2p/tahoe-lafs/default.nix
+++ b/pkgs/tools/networking/p2p/tahoe-lafs/default.nix
@@ -66,7 +66,7 @@ buildPythonPackage {
     # something writable doesn't help; providing $FONTCONFIG_FILE doesn't
     # help either.  So we just don't run `make' under `docs/'.
 
-    ensureDir "$out/share/doc/${name}"
+    mkdir -p "$out/share/doc/${name}"
     cp -rv "docs/"* "$out/share/doc/${name}"
     find "$out/share/doc/${name}" -name Makefile -exec rm -v {} \;
 
diff --git a/pkgs/tools/networking/philter/default.nix b/pkgs/tools/networking/philter/default.nix
index 8ade37976b6a8..7457a72b5d50d 100644
--- a/pkgs/tools/networking/philter/default.nix
+++ b/pkgs/tools/networking/philter/default.nix
@@ -32,7 +32,7 @@ rec {
 
   installProgram = a.fullDepEntry(''
     mv "$out/share/philter/".*rc "$out/share/philter/philterrc"
-    ensureDir "$out/bin"
+    mkdir -p "$out/bin"
     cp "$out/share/philter/src/philter.py" "$out/bin/philter"
     chmod a+x "$out/bin/philter"
   '') ["addInputs" "copyToShare" "minInit"];
diff --git a/pkgs/tools/networking/ripmime/default.nix b/pkgs/tools/networking/ripmime/default.nix
index 895b2c4be4fd3..07196b77d0a2a 100644
--- a/pkgs/tools/networking/ripmime/default.nix
+++ b/pkgs/tools/networking/ripmime/default.nix
@@ -30,7 +30,7 @@ rec {
   phaseNames = ["fixTarget" "doMakeInstall"];
   fixTarget = a.fullDepEntry (''
     sed -i Makefile -e "s@LOCATION=.*@LOCATION=$out@"
-    ensureDir "$out/bin" "$out/man/man1"
+    mkdir -p "$out/bin" "$out/man/man1"
   '') ["doUnpack" "minInit" "defEnsureDir"];
       
   meta = {
diff --git a/pkgs/tools/networking/rp-pppoe/default.nix b/pkgs/tools/networking/rp-pppoe/default.nix
index 8a704bb571184..5079b951a6452 100644
--- a/pkgs/tools/networking/rp-pppoe/default.nix
+++ b/pkgs/tools/networking/rp-pppoe/default.nix
@@ -32,7 +32,7 @@ rec {
   '') ["minInit" "doUnpack"];
 
   makeDirs = a.fullDepEntry(''
-    ensureDir $out/share/${name}/etc/ppp
+    mkdir -p $out/share/${name}/etc/ppp
   '') ["minInit" "defEnsureDir"];
 
   name = "rp-pppoe-" + version;
diff --git a/pkgs/tools/networking/s3cmd/default.nix b/pkgs/tools/networking/s3cmd/default.nix
index 4b12ce4c59868..83a8b4cafef02 100644
--- a/pkgs/tools/networking/s3cmd/default.nix
+++ b/pkgs/tools/networking/s3cmd/default.nix
@@ -10,8 +10,6 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ pythonPackages.python pythonPackages.wrapPython ];
 
-  pythonPath = [ pythonPackages.ssl ];
-  
   installPhase =
     ''
       python setup.py install --prefix=$out
diff --git a/pkgs/tools/networking/s3sync/default.nix b/pkgs/tools/networking/s3sync/default.nix
index 8ed71c3452346..48788d36884cb 100644
--- a/pkgs/tools/networking/s3sync/default.nix
+++ b/pkgs/tools/networking/s3sync/default.nix
@@ -12,12 +12,12 @@ stdenv.mkDerivation {
 
   installPhase =
     ''
-      ensureDir $out/libexec/s3sync
+      mkdir -p $out/libexec/s3sync
       cp *.rb $out/libexec/s3sync
       makeWrapper "${ruby}/bin/ruby $out/libexec/s3sync/s3cmd.rb" $out/bin/s3cmd
       makeWrapper "${ruby}/bin/ruby $out/libexec/s3sync/s3sync.rb" $out/bin/s3sync
 
-      ensureDir $out/share/doc/s3sync
+      mkdir -p $out/share/doc/s3sync
       cp README* $out/share/doc/s3sync/
     ''; # */
 
diff --git a/pkgs/tools/networking/siege/default.nix b/pkgs/tools/networking/siege/default.nix
index bb588f3659992..ebbfcb5d36081 100644
--- a/pkgs/tools/networking/siege/default.nix
+++ b/pkgs/tools/networking/siege/default.nix
@@ -29,7 +29,7 @@ rec {
   phaseNames = ["doConfigure" "createDirs" "doMakeInstall"];
 
   createDirs = a.fullDepEntry ''
-    ensureDir "$out/"{bin,lib,share/man,etc}
+    mkdir -p "$out/"{bin,lib,share/man,etc}
   '' ["defEnsureDir"];
 
   meta = {
diff --git a/pkgs/tools/networking/slimrat/default.nix b/pkgs/tools/networking/slimrat/default.nix
index 38b7c27b6fde3..9006fadfcdb98 100644
--- a/pkgs/tools/networking/slimrat/default.nix
+++ b/pkgs/tools/networking/slimrat/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out/share/slimrat $out/bin
+    mkdir -p $out/share/slimrat $out/bin
     cp -R src/* $out/share/slimrat
     # slimrat-gui does not work (it needs the Gtk2 perl package)
     for i in slimrat; do
diff --git a/pkgs/tools/networking/stun/default.nix b/pkgs/tools/networking/stun/default.nix
index 65a1d241c0bd2..795c0cfc8ccb4 100644
--- a/pkgs/tools/networking/stun/default.nix
+++ b/pkgs/tools/networking/stun/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out/{bin,man/man8,man/man1}
+    mkdir -p $out/{bin,man/man8,man/man1}
     cp client $out/bin/stun
     cp server $out/bin/stund
     cp debian/manpages/stund.8 $out/man/man8
diff --git a/pkgs/tools/networking/swec/default.nix b/pkgs/tools/networking/swec/default.nix
index 4cb47fada0616..007efa42827aa 100644
--- a/pkgs/tools/networking/swec/default.nix
+++ b/pkgs/tools/networking/swec/default.nix
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
   installPhase =
     '' make install prefix="$out"
 
-       ensureDir "$out/share/${name}"
+       mkdir -p "$out/share/${name}"
        cp -v default.sdf "$out/share/${name}"
        sed -i "$out/bin/swec" -e"s|realpath(\$0)|'$out/share/${name}/swec'|g"
 
diff --git a/pkgs/tools/networking/tcng/default.nix b/pkgs/tools/networking/tcng/default.nix
index dd2082d30b245..062977b455c3a 100644
--- a/pkgs/tools/networking/tcng/default.nix
+++ b/pkgs/tools/networking/tcng/default.nix
@@ -64,7 +64,7 @@ stdenv.mkDerivation {
 
   # manually copy tcc and include files.. see comment above
   installPhase = ''
-    ensureDir $out{,/sbin,/lib/tcng/include}
+    mkdir -p $out{,/sbin,/lib/tcng/include}
     make DESTDIR=$out install
     cp tcc/tcc $out/sbin
     cp tcc/*.tc $out/lib/tcng/include
diff --git a/pkgs/tools/networking/uwimap/default.nix b/pkgs/tools/networking/uwimap/default.nix
index 7d72016cfe278..8c8c024120494 100644
--- a/pkgs/tools/networking/uwimap/default.nix
+++ b/pkgs/tools/networking/uwimap/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out/bin $out/lib $out/include
+    mkdir -p $out/bin $out/lib $out/include
     cp c-client/*.h c-client/linkage.c $out/include
     cp c-client/c-client.a $out/lib/libc-client.a
     cp mailutil/mailutil imapd/imapd dmail/dmail mlock/mlock mtest/mtest tmail/tmail \
diff --git a/pkgs/tools/networking/wakelan/default.nix b/pkgs/tools/networking/wakelan/default.nix
index 6cc18ec8678f1..837ab3627faf7 100644
--- a/pkgs/tools/networking/wakelan/default.nix
+++ b/pkgs/tools/networking/wakelan/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
   };
 
   preInstall = ''
-    ensureDir $out/man/man1 $out/bin
+    mkdir -p $out/man/man1 $out/bin
   '';
 
   meta = {
diff --git a/pkgs/tools/networking/wicd/default.nix b/pkgs/tools/networking/wicd/default.nix
index 317dec365a1dd..1f3240997d967 100644
--- a/pkgs/tools/networking/wicd/default.nix
+++ b/pkgs/tools/networking/wicd/default.nix
@@ -77,7 +77,7 @@ stdenv.mkDerivation rec {
 
   installPhase = ''
     python setup.py install --prefix=$out
-    ensureDir $out/share/other
+    mkdir -p $out/share/other
     cp other/dhclient.conf.template.default $out/share/other/dhclient.conf.template.default
 
     # Add a template for "WPA2 Enterprise" encryption as used, e.g., by the
diff --git a/pkgs/tools/package-management/disnix/default.nix b/pkgs/tools/package-management/disnix/default.nix
index 912d5659ea416..13534b7dbd4bd 100644
--- a/pkgs/tools/package-management/disnix/default.nix
+++ b/pkgs/tools/package-management/disnix/default.nix
@@ -1,16 +1,18 @@
-{stdenv, fetchurl, pkgconfig, dbus_glib, libxml2, libxslt, getopt, nixUnstable, gettext, libiconv}:
+{ stdenv, fetchurl, pkgconfig, dbus_glib, libxml2, libxslt, getopt, nixUnstable, gettext, libiconv }:
 
 stdenv.mkDerivation {
   name = "disnix-0.3pre30527";
+  
   src = fetchurl {
     url = http://hydra.nixos.org/build/1926928/download/4/disnix-0.3pre30527.tar.gz;
     sha256 = "1mdcxyrz60nxcyn116i41nhh94r9hacvyilkjyjfiyf8d58pji1y";
   };
+  
   buildInputs = [ pkgconfig dbus_glib libxml2 libxslt getopt nixUnstable ]
                 ++ stdenv.lib.optional (!stdenv.isLinux) libiconv
                 ++ stdenv.lib.optional (!stdenv.isLinux) gettext;
+                
   dontStrip = true;
-  NIX_STRIP_DEBUG = true;
   
   meta = {
     description = "A distributed deployment extension for Nix";
diff --git a/pkgs/tools/package-management/disnix/disnixos/default.nix b/pkgs/tools/package-management/disnix/disnixos/default.nix
index f581c6a110f92..f9c9aa8c593eb 100644
--- a/pkgs/tools/package-management/disnix/disnixos/default.nix
+++ b/pkgs/tools/package-management/disnix/disnixos/default.nix
@@ -1,14 +1,16 @@
-{stdenv, fetchurl, disnix, socat, pkgconfig}:
+{ stdenv, fetchurl, disnix, socat, pkgconfig }:
 
 stdenv.mkDerivation {
   name = "disnixos-0.2pre31830";
+  
   src = fetchurl {
     url = http://hydra.nixos.org/build/1934498/download/3/disnixos-0.2pre31830.tar.gz;
     sha256 = "02f2b4lk1gr24rqs56az82b3h3mnqrk1m48bcj21x109g4vrlpmm";
   };
+  
   buildInputs = [ socat pkgconfig disnix ];
+  
   dontStrip = true;
-  NIX_STRIP_DEBUG = true;
   
   meta = {
     description = "Provides complementary NixOS infrastructure deployment to Disnix";
diff --git a/pkgs/tools/package-management/nix/default.nix b/pkgs/tools/package-management/nix/default.nix
index c75fa1ed60cda..64387d678398d 100644
--- a/pkgs/tools/package-management/nix/default.nix
+++ b/pkgs/tools/package-management/nix/default.nix
@@ -33,7 +33,7 @@ stdenv.mkDerivation rec {
     doCheck = false;
   };
 
-  doCheck = true;
+  #doCheck = true;
 
   meta = {
     description = "The Nix Deployment System";
diff --git a/pkgs/tools/package-management/rpm/default.nix b/pkgs/tools/package-management/rpm/default.nix
index 50f495ec8a621..f9c942f333ea9 100644
--- a/pkgs/tools/package-management/rpm/default.nix
+++ b/pkgs/tools/package-management/rpm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cpio, zlib, bzip2, xz, file, elfutils, nspr, nss, popt, db4 }:
+{ stdenv, fetchurl, cpio, zlib, bzip2, file, elfutils, nspr, nss, popt, db4 }:
 
 stdenv.mkDerivation rec {
   name = "rpm-4.7.2";
@@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
     sha1 = "07b90f653775329ea726ce0005c4c82f56167ca0";
   };
 
-  buildInputs = [ cpio zlib bzip2 xz file nspr nss popt db4 ];
+  buildInputs = [ cpio zlib bzip2 file nspr nss popt db4 ];
 
   # Note: we don't add elfutils to buildInputs, since it provides a
   # bad `ld' and other stuff.
diff --git a/pkgs/tools/security/bmrsa/11.nix b/pkgs/tools/security/bmrsa/11.nix
index 0a830e75d8043..3200d27c004b3 100644
--- a/pkgs/tools/security/bmrsa/11.nix
+++ b/pkgs/tools/security/bmrsa/11.nix
@@ -26,7 +26,7 @@ rec {
     cd bmrsa 
     unzip ${src}
     sed -e 's/gcc/g++/' -i Makefile
-    ensureDir $out/bin
+    mkdir -p $out/bin
     echo -e 'install:\n\tcp bmrsa '$out'/bin' >> Makefile
   '') ["minInit" "addInputs" "defEnsureDir"];
       
diff --git a/pkgs/tools/security/chkrootkit/default.nix b/pkgs/tools/security/chkrootkit/default.nix
index e7545ac8cd6a8..73f7f8c9ae5ef 100644
--- a/pkgs/tools/security/chkrootkit/default.nix
+++ b/pkgs/tools/security/chkrootkit/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation {
   };
 
   installPhase = "
-    ensureDir $out/sbin
+    mkdir -p $out/sbin
     cp check_wtmpx chkdirs chklastlog chkproc chkrootkit chkutmp chkwtmp ifpromisc strings-static $out/sbin
   ";
   
diff --git a/pkgs/tools/security/metasploit/3.1.nix b/pkgs/tools/security/metasploit/3.1.nix
index 94bc009080df9..e02ce1316ba97 100644
--- a/pkgs/tools/security/metasploit/3.1.nix
+++ b/pkgs/tools/security/metasploit/3.1.nix
@@ -9,8 +9,8 @@ rec {
   configureFlags = [];
 
   doInstall = fullDepEntry(''
-    ensureDir $out/share/msf
-    ensureDir $out/bin
+    mkdir -p $out/share/msf
+    mkdir -p $out/bin
 
     cp -r * $out/share/msf
 
diff --git a/pkgs/tools/security/opensc-dnie-wrapper/default.nix b/pkgs/tools/security/opensc-dnie-wrapper/default.nix
index ec649790e6778..b36d99f8ebf02 100644
--- a/pkgs/tools/security/opensc-dnie-wrapper/default.nix
+++ b/pkgs/tools/security/opensc-dnie-wrapper/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   phases = [ "installPhase" ];
 
   installPhase = ''
-    ensureDir $out/etc
+    mkdir -p $out/etc
     cp ${opensc}/etc/opensc.conf $out/etc
     chmod +w $out/etc/opensc.conf
 
diff --git a/pkgs/tools/security/pius/default.nix b/pkgs/tools/security/pius/default.nix
index d5462a1120ae1..3ca410328152f 100644
--- a/pkgs/tools/security/pius/default.nix
+++ b/pkgs/tools/security/pius/default.nix
@@ -19,10 +19,10 @@ stdenv.mkDerivation {
   buildPhase = "true";
 
   installPhase =
-    '' ensureDir "$out/bin"
+    '' mkdir -p "$out/bin"
        cp -v pius "$out/bin"
 
-       ensureDir "$out/doc/pius-${version}"
+       mkdir -p "$out/doc/pius-${version}"
        cp -v README "$out/doc/pius-${version}"
     '';
 
diff --git a/pkgs/tools/security/seccure/0.4.nix b/pkgs/tools/security/seccure/0.4.nix
index 0a1452e535567..33a77c078446f 100644
--- a/pkgs/tools/security/seccure/0.4.nix
+++ b/pkgs/tools/security/seccure/0.4.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   preConfigure = ''
     sed -e s@/usr/@$out/@g -i Makefile
     sed -e 's@ln -f@ln -sf@g' -i Makefile
-    ensureDir $out/bin $out/share/man/man1
+    mkdir -p $out/bin $out/share/man/man1
   '';
 
   meta = {
diff --git a/pkgs/tools/security/ssss/default.nix b/pkgs/tools/security/ssss/default.nix
index 3816df415c695..74682d00d0334 100644
--- a/pkgs/tools/security/ssss/default.nix
+++ b/pkgs/tools/security/ssss/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
       sed -e s@/usr/@$out/@g -i Makefile
       cp ssss.manpage.xml ssss.1
       cp ssss.manpage.xml ssss.1.html
-      ensureDir $out/bin $out/share/man/man1
+      mkdir -p $out/bin $out/share/man/man1
       echo -e 'install:\n\tcp ssss-combine ssss-split '"$out"'/bin' >>Makefile
     '';
 
diff --git a/pkgs/tools/system/bootchart/default.nix b/pkgs/tools/system/bootchart/default.nix
index 24a1558e901d3..bb3f9d72e8280 100644
--- a/pkgs/tools/system/bootchart/default.nix
+++ b/pkgs/tools/system/bootchart/default.nix
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
   '';
 
   installPhase = ''
-    ensureDir $out/sbin $out/etc
+    mkdir -p $out/sbin $out/etc
     cp script/bootchartd $out/sbin
     cp script/bootchartd.conf $out/etc
     chmod +x $out/sbin/bootchartd
diff --git a/pkgs/tools/system/cron/default.nix b/pkgs/tools/system/cron/default.nix
index 17583f612dc02..6132abc087903 100644
--- a/pkgs/tools/system/cron/default.nix
+++ b/pkgs/tools/system/cron/default.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation {
     echo '#define _PATH_SENDMAIL "${sendmailPath}"' >> pathnames.h
   '';
 
-  preInstall = "ensureDir $out/bin $out/sbin $out/share/man/man1 $out/share/man/man5 $out/share/man/man8";
+  preInstall = "mkdir -p $out/bin $out/sbin $out/share/man/man1 $out/share/man/man5 $out/share/man/man8";
   
   meta = {
     description = "Vixie Cron, a daemon for running commands at specific times";
diff --git a/pkgs/tools/system/dd_rescue/default.nix b/pkgs/tools/system/dd_rescue/default.nix
index b018de88f4647..57f9a1a57d519 100644
--- a/pkgs/tools/system/dd_rescue/default.nix
+++ b/pkgs/tools/system/dd_rescue/default.nix
@@ -40,7 +40,7 @@ rec {
   fixPaths = a.doPatchShebangs ''$out/bin'';
 
   install_dd_rhelp = a.fullDepEntry (''
-    ensureDir "$out/share/dd_rescue" "$out/bin"
+    mkdir -p "$out/share/dd_rescue" "$out/bin"
     tar xf "${dd_rhelp_src}" -C "$out/share/dd_rescue"
     cp "$out/share/dd_rescue"/dd_rhelp*/dd_rhelp "$out/bin"
   '') ["minInit" "defEnsureDir"];
diff --git a/pkgs/tools/system/gptfdisk/default.nix b/pkgs/tools/system/gptfdisk/default.nix
index 35c510f625c9c..f82c94c0a726f 100644
--- a/pkgs/tools/system/gptfdisk/default.nix
+++ b/pkgs/tools/system/gptfdisk/default.nix
@@ -11,8 +11,8 @@ stdenv.mkDerivation rec {
   buildInputs = [ libuuid popt icu ncurses ];
 
   installPhase = ''
-    ensureDir $out/sbin
-    ensureDir $out/share/man/man8
+    mkdir -p $out/sbin
+    mkdir -p $out/share/man/man8
     install -v -m755 gdisk sgdisk fixparts $out/sbin
     install -v -m644 gdisk.8 sgdisk.8 fixparts.8 \
         $out/share/man/man8
diff --git a/pkgs/tools/system/plan9port/builder.sh b/pkgs/tools/system/plan9port/builder.sh
index f33dc7227fba1..bf5e6eeffa5a9 100644
--- a/pkgs/tools/system/plan9port/builder.sh
+++ b/pkgs/tools/system/plan9port/builder.sh
@@ -40,7 +40,7 @@ popd
 
 # Installation
 export PLAN9=$out
-ensureDir $PLAN9
+mkdir -p $PLAN9
 GLOBIGNORE='src:.*'
 cp -R * $PLAN9
 GLOBIGNORE=
diff --git a/pkgs/tools/system/which/default.nix b/pkgs/tools/system/which/default.nix
index 3721c0f0be1ac..fc40cd4722bb7 100644
--- a/pkgs/tools/system/which/default.nix
+++ b/pkgs/tools/system/which/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, readline}:
+{ stdenv, fetchurl }:
 
 stdenv.mkDerivation {
   name = "which-2.20";
@@ -8,8 +8,6 @@ stdenv.mkDerivation {
     sha256 = "1y2p50zadb36izzh2zw4dm5hvdiydqf3qa88l8kav20dcmfbc5yl";
   };
 
-  buildInputs = [readline];
-
   meta = {
     homepage = http://ftp.gnu.org/gnu/which/;
   };
diff --git a/pkgs/tools/text/convertlit/default.nix b/pkgs/tools/text/convertlit/default.nix
index 02654cd892288..05494e54a3ecf 100644
--- a/pkgs/tools/text/convertlit/default.nix
+++ b/pkgs/tools/text/convertlit/default.nix
@@ -21,7 +21,7 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp clit $out/bin
   '';
 
diff --git a/pkgs/tools/text/dadadodo/default.nix b/pkgs/tools/text/dadadodo/default.nix
index 3beb47b069635..1485bbcd46745 100644
--- a/pkgs/tools/text/dadadodo/default.nix
+++ b/pkgs/tools/text/dadadodo/default.nix
@@ -21,7 +21,7 @@ rec {
   installFlags = "PREFIX=$out";
 
   doDeploy = a.fullDepEntry (''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp dadadodo $out/bin
   '') [ "minInit" "doMake" "defEnsureDir"];
       
diff --git a/pkgs/tools/text/diffutils/default.nix b/pkgs/tools/text/diffutils/default.nix
index 4fde88d92626f..eae48f2e3a47c 100644
--- a/pkgs/tools/text/diffutils/default.nix
+++ b/pkgs/tools/text/diffutils/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl, coreutils ? null}:
 
 stdenv.mkDerivation {
-  name = "diffutils-3.0";
+  name = "diffutils-3.2";
   
   src = fetchurl {
-    url = mirror://gnu/diffutils/diffutils-3.0.tar.gz;
-    sha256 = "02g8i6jv0j0vr5nl13ns50lv2dbjy9kkk8jvp11n0g5fpdjizf9g";
+    url = mirror://gnu/diffutils/diffutils-3.2.tar.gz;
+    sha256 = "1lsf0ln0h3mnm2y0mwgrfk0lyfi7bnm4r886acvdrrsvc7pypaia";
   };
   
   /* If no explicit coreutils is given, use the one from stdenv. */
diff --git a/pkgs/tools/text/gawk/default.nix b/pkgs/tools/text/gawk/default.nix
index c4f37f922c740..0c7e85cce4f20 100644
--- a/pkgs/tools/text/gawk/default.nix
+++ b/pkgs/tools/text/gawk/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, libsigsegv }:
 
 stdenv.mkDerivation rec {
-  name = "gawk-3.1.8";
+  name = "gawk-4.0.0";
 
   src = fetchurl {
     url = "mirror://gnu/gawk/${name}.tar.bz2";
-    sha256 = "1d0jfh319w4h8l1zzqv248916wrc2add1b1aghri31rj9hn7pg2x";
+    sha256 = "0sss7rhpvizi2a88h6giv0i7w5h07s2fxkw3s6n1hqvcnhrfgbb0";
   };
 
   doCheck = true;
diff --git a/pkgs/tools/text/gnugrep/default.nix b/pkgs/tools/text/gnugrep/default.nix
index f06be1b7336eb..8368edef6563e 100644
--- a/pkgs/tools/text/gnugrep/default.nix
+++ b/pkgs/tools/text/gnugrep/default.nix
@@ -1,13 +1,13 @@
-{ stdenv, fetchurl, pcre, libiconv ? null}:
+{ stdenv, fetchurl, pcre, libiconv ? null }:
 
-let version = "2.7"; in
+let version = "2.10"; in
 
 stdenv.mkDerivation ({
   name = "gnugrep-${version}";
 
   src = fetchurl {
-    url = "mirror://gnu/grep/grep-${version}.tar.gz";
-    sha256 = "1b8vksfd1ngharac3ygaqim3lrf0yqap992sg0vfm7572l88655d";
+    url = "mirror://gnu/grep/grep-${version}.tar.xz";
+    sha256 = "1cvsqyfzk1p38fcaav22dn76fkd02g7bjnqna6vrpk9vy9rnfybc";
   };
 
   buildInputs = [ pcre ]
diff --git a/pkgs/tools/text/qshowdiff/default.nix b/pkgs/tools/text/qshowdiff/default.nix
index d033cf4ba6f66..7c76c7f1bca23 100644
--- a/pkgs/tools/text/qshowdiff/default.nix
+++ b/pkgs/tools/text/qshowdiff/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ qt4 perl ];
 
   configurePhase = ''
-    ensureDir $out/{bin,man/man1}
+    mkdir -p $out/{bin,man/man1}
     makeFlags="PREFIX=$out"
   '';
 
diff --git a/pkgs/tools/text/replace/default.nix b/pkgs/tools/text/replace/default.nix
index 01e58146ed8fc..72dbdbf647f5c 100644
--- a/pkgs/tools/text/replace/default.nix
+++ b/pkgs/tools/text/replace/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
     makeFlags = "TREE=\$(out) MANTREE=\$(TREE)/share/man CC=${stdenv.cross.config}-gcc";
   };
 
-  preInstall = "ensureDir \$out/share/man";
+  preInstall = "mkdir -p \$out/share/man";
   postInstall = "mv \$out/bin/replace \$out/bin/replace-literal";
 
   patches = [./malloc.patch];
diff --git a/pkgs/tools/text/xml/jing/script-builder.sh b/pkgs/tools/text/xml/jing/script-builder.sh
index 0a7cdc5b8a865..d9cc884927692 100644
--- a/pkgs/tools/text/xml/jing/script-builder.sh
+++ b/pkgs/tools/text/xml/jing/script-builder.sh
@@ -1,6 +1,6 @@
 source $stdenv/setup
 
-ensureDir $out/bin
+mkdir -p $out/bin
 
 cat >> $out/bin/jing <<EOF
 #! $SHELL
diff --git a/pkgs/tools/text/xml/rxp/default.nix b/pkgs/tools/text/xml/rxp/default.nix
index 3ec035c105e29..ee66cf9237744 100644
--- a/pkgs/tools/text/xml/rxp/default.nix
+++ b/pkgs/tools/text/xml/rxp/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation {
   NIX_CFLAGS_COMPILE = "-D_GNU_SOURCE";
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     cp rxp $out/bin
   '';
   meta = {
diff --git a/pkgs/tools/text/xml/trang/builder.sh b/pkgs/tools/text/xml/trang/builder.sh
index 9ae7f7bfe9293..9fe712360babb 100644
--- a/pkgs/tools/text/xml/trang/builder.sh
+++ b/pkgs/tools/text/xml/trang/builder.sh
@@ -1,10 +1,10 @@
 source $stdenv/setup
 
-ensureDir $out/jars
+mkdir -p $out/jars
 unzip -j $src '*/trang.jar'
 cp -p *.jar $out/jars
 
-ensureDir $out/bin
+mkdir -p $out/bin
 
 cat >> $out/bin/trang <<EOF
 #! $SHELL
diff --git a/pkgs/tools/typesetting/asciidoc/default.nix b/pkgs/tools/typesetting/asciidoc/default.nix
index 31c5785028508..a4b9d375bcede 100644
--- a/pkgs/tools/typesetting/asciidoc/default.nix
+++ b/pkgs/tools/typesetting/asciidoc/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
     sed -i -e "s,/etc/vim,,g" Makefile.in
   '';
 
-  preInstall = "ensureDir $out/etc/vim";
+  preInstall = "mkdir -p $out/etc/vim";
 
   buildInputs = [ python ];
 
diff --git a/pkgs/tools/typesetting/halibut/default.nix b/pkgs/tools/typesetting/halibut/default.nix
index 68c09f86e1187..5a2c5fb2e067e 100644
--- a/pkgs/tools/typesetting/halibut/default.nix
+++ b/pkgs/tools/typesetting/halibut/default.nix
@@ -16,8 +16,8 @@ stdenv.mkDerivation {
   '';
 
   installPhase = ''
-    ensureDir $out/bin
-    ensureDir $out/share/man/man1
+    mkdir -p $out/bin
+    mkdir -p $out/share/man/man1
     pushd doc
     make halibut.1
     popd
diff --git a/pkgs/tools/typesetting/lhs2tex/default.nix b/pkgs/tools/typesetting/lhs2tex/default.nix
index 61e1dfb9d8759..a78feaadb18f6 100644
--- a/pkgs/tools/typesetting/lhs2tex/default.nix
+++ b/pkgs/tools/typesetting/lhs2tex/default.nix
@@ -8,9 +8,9 @@ cabal.mkDerivation (self: {
   extraBuildInputs = [regexCompat texLive];
 
   postInstall = ''
-    ensureDir "$out/share/doc/$name"
+    mkdir -p "$out/share/doc/$name"
     cp doc/Guide2.pdf $out/share/doc/$name
-    ensureDir "$out/nix-support"
+    mkdir -p "$out/nix-support"
   '';
 
   meta = {
diff --git a/pkgs/tools/typesetting/pdfjam/builder.sh b/pkgs/tools/typesetting/pdfjam/builder.sh
index a710bc120230d..9fcb80f68668e 100644
--- a/pkgs/tools/typesetting/pdfjam/builder.sh
+++ b/pkgs/tools/typesetting/pdfjam/builder.sh
@@ -2,8 +2,8 @@ source $stdenv/setup
 
 tar zxvf $src
 
-ensureDir $out/bin
+mkdir -p $out/bin
 cp pdfjam/scripts/* $out/bin
 
-ensureDir $out/man/man1
+mkdir -p $out/man/man1
 cp pdfjam/man1/* $out/man/man1
diff --git a/pkgs/tools/typesetting/pdftk/default.nix b/pkgs/tools/typesetting/pdftk/default.nix
index 3a6c934928dc6..28a43e69598c8 100644
--- a/pkgs/tools/typesetting/pdftk/default.nix
+++ b/pkgs/tools/typesetting/pdftk/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation {
   preBuild = "cd pdftk";
 
   installPhase = ''
-    ensureDir $out/bin $out/share/man/man1
+    mkdir -p $out/bin $out/share/man/man1
     cp pdftk $out/bin
     cp ../debian/pdftk.1 $out/share/man/man1
   '';
diff --git a/pkgs/tools/typesetting/tex/lazylist/builder.sh b/pkgs/tools/typesetting/tex/lazylist/builder.sh
index 140b07f7be70e..cdab5bb8c9788 100644
--- a/pkgs/tools/typesetting/tex/lazylist/builder.sh
+++ b/pkgs/tools/typesetting/tex/lazylist/builder.sh
@@ -4,7 +4,7 @@ buildPhase=true
 
 installPhase=myInstallPhase
 myInstallPhase() {
-  ensureDir "$out/share/texmf-nix/tex/latex/lazylist"
+  mkdir -p "$out/share/texmf-nix/tex/latex/lazylist"
   cp lazylist.sty "$out/share/texmf-nix/tex/latex/lazylist"
 }
 
diff --git a/pkgs/tools/typesetting/tex/lkproof/default.nix b/pkgs/tools/typesetting/tex/lkproof/default.nix
index 2d3a1e5f19cc2..936e4a31af123 100644
--- a/pkgs/tools/typesetting/tex/lkproof/default.nix
+++ b/pkgs/tools/typesetting/tex/lkproof/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
   buildInputs = [ unzip ];
 
   installPhase = "
-    ensureDir $out/share/texmf-nix/tex/generic/lkproof
+    mkdir -p $out/share/texmf-nix/tex/generic/lkproof
     cp -prd *.sty $out/share/texmf-nix/tex/generic/lkproof
   ";
 }
diff --git a/pkgs/tools/typesetting/tex/nix/animatedot.sh b/pkgs/tools/typesetting/tex/nix/animatedot.sh
index 2e1868d4bebdd..46a2c515e03ae 100644
--- a/pkgs/tools/typesetting/tex/nix/animatedot.sh
+++ b/pkgs/tools/typesetting/tex/nix/animatedot.sh
@@ -1,6 +1,6 @@
 source $stdenv/setup
 
-ensureDir $out
+mkdir -p $out
 
 for ((i = 1; i <= $nrFrames; i++)); do
     echo "producing frame $i...";
diff --git a/pkgs/tools/typesetting/tex/nix/default.nix b/pkgs/tools/typesetting/tex/nix/default.nix
index f5a34fb67a2c3..9ae567e635b76 100644
--- a/pkgs/tools/typesetting/tex/nix/default.nix
+++ b/pkgs/tools/typesetting/tex/nix/default.nix
@@ -182,7 +182,7 @@ rec {
           ln -s $postscript $input
         fi
 
-        ensureDir $out
+        mkdir -p $out
         convert -units PixelsPerInch \
           -density 600 \
           -trim \
diff --git a/pkgs/tools/typesetting/tex/nix/dot2pdf.sh b/pkgs/tools/typesetting/tex/nix/dot2pdf.sh
index 0a9610c00ff21..c416bf235a14a 100644
--- a/pkgs/tools/typesetting/tex/nix/dot2pdf.sh
+++ b/pkgs/tools/typesetting/tex/nix/dot2pdf.sh
@@ -1,6 +1,6 @@
 source $stdenv/setup
 
-ensureDir $out
+mkdir -p $out
 
 dot2pdf() {
     sourceFile=$1
diff --git a/pkgs/tools/typesetting/tex/nix/dot2ps.sh b/pkgs/tools/typesetting/tex/nix/dot2ps.sh
index 1269108d6f521..c70e76ce4c734 100644
--- a/pkgs/tools/typesetting/tex/nix/dot2ps.sh
+++ b/pkgs/tools/typesetting/tex/nix/dot2ps.sh
@@ -1,6 +1,6 @@
 source $stdenv/setup
 
-ensureDir $out
+mkdir -p $out
 
 dot2ps() {
     sourceFile=$1
diff --git a/pkgs/tools/typesetting/tex/nix/lhs2tex.sh b/pkgs/tools/typesetting/tex/nix/lhs2tex.sh
index 6edca4baf8a02..f34b3944c8ef1 100644
--- a/pkgs/tools/typesetting/tex/nix/lhs2tex.sh
+++ b/pkgs/tools/typesetting/tex/nix/lhs2tex.sh
@@ -1,6 +1,6 @@
 source $stdenv/setup
 
-ensureDir $out
+mkdir -p $out
 
 mkdir root
 cd root
diff --git a/pkgs/tools/typesetting/tex/nix/run-latex.sh b/pkgs/tools/typesetting/tex/nix/run-latex.sh
index 6c18721eed6ba..2886057c8945c 100644
--- a/pkgs/tools/typesetting/tex/nix/run-latex.sh
+++ b/pkgs/tools/typesetting/tex/nix/run-latex.sh
@@ -1,6 +1,6 @@
 source $stdenv/setup
 
-ensureDir $out
+mkdir -p $out
 
 export TEXMFCNF=$TMPDIR:
 echo 'max_print_line = 8192' >> $TMPDIR/texmf.cnf
diff --git a/pkgs/tools/typesetting/tex/pgf/1.x.nix b/pkgs/tools/typesetting/tex/pgf/1.x.nix
index 672ae6fdfce4d..91948f995a0e2 100644
--- a/pkgs/tools/typesetting/tex/pgf/1.x.nix
+++ b/pkgs/tools/typesetting/tex/pgf/1.x.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
 
   buildPhase = "true";
   installPhase = "
-    ensureDir $out/share/texmf-nix
+    mkdir -p $out/share/texmf-nix
     cp -prd * $out/share/texmf-nix
   ";
 }
diff --git a/pkgs/tools/typesetting/tex/pgf/2.x.nix b/pkgs/tools/typesetting/tex/pgf/2.x.nix
index 5e73d12959c6d..09ec1729cfd47 100644
--- a/pkgs/tools/typesetting/tex/pgf/2.x.nix
+++ b/pkgs/tools/typesetting/tex/pgf/2.x.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
   buildPhase = "true";
   
   installPhase = "
-    ensureDir $out/share/texmf-nix
+    mkdir -p $out/share/texmf-nix
     cp -prd * $out/share/texmf-nix
   ";
 }
diff --git a/pkgs/tools/typesetting/tex/polytable/builder.sh b/pkgs/tools/typesetting/tex/polytable/builder.sh
index 1138b8e67896d..68f653ccec05b 100644
--- a/pkgs/tools/typesetting/tex/polytable/builder.sh
+++ b/pkgs/tools/typesetting/tex/polytable/builder.sh
@@ -4,14 +4,14 @@ buildPhase=true
 
 installPhase=myInstallPhase
 myInstallPhase() {
-  ensureDir "$out/share/texmf-nix/tex/latex/polytable"
-  ensureDir "$out/share/texmf-nix/doc/latex/polytable"
+  mkdir -p "$out/share/texmf-nix/tex/latex/polytable"
+  mkdir -p "$out/share/texmf-nix/doc/latex/polytable"
   latex polytable.ins
   pdflatex polytable.dtx
   pdflatex polytable.dtx
   cp polytable.sty "$out/share/texmf-nix/tex/latex/polytable"
   cp polytable.pdf "$out/share/texmf-nix/doc/latex/polytable"
-  ensureDir "$out/nix-support"
+  mkdir -p "$out/nix-support"
   echo "$propagatedUserEnvPackages" > "$out/nix-support/propagated-user-env-packages"
 }
 
diff --git a/pkgs/tools/typesetting/tex/tetex/default.nix b/pkgs/tools/typesetting/tex/tetex/default.nix
index 5e0fb38c3bd50..bb1e3f8b4b037 100644
--- a/pkgs/tools/typesetting/tex/tetex/default.nix
+++ b/pkgs/tools/typesetting/tex/tetex/default.nix
@@ -33,8 +33,8 @@ stdenv.mkDerivation {
 
   postUnpack =
     ''
-      ensureDir $out/share/texmf
-      ensureDir $out/share/texmf-dist
+      mkdir -p $out/share/texmf
+      mkdir -p $out/share/texmf-dist
       gunzip < $texmf | (cd $out/share/texmf-dist && tar xvf -)
     '';
 
diff --git a/pkgs/tools/typesetting/tex/tex4ht/default.nix b/pkgs/tools/typesetting/tex/tex4ht/default.nix
index 90d134fcd4e7f..5d5d85d3c1d95 100644
--- a/pkgs/tools/typesetting/tex/tex4ht/default.nix
+++ b/pkgs/tools/typesetting/tex/tex4ht/default.nix
@@ -21,12 +21,12 @@ stdenv.mkDerivation rec {
   '';
 
   installPhase = ''
-    ensureDir $out/bin
+    mkdir -p $out/bin
     for f in src/tex4ht src/t4ht src/htcmd bin/unix/*; do # */
       mv $f $out/bin/.
     done
 
-    ensureDir $out/share
+    mkdir -p $out/share
     cp -r texmf $out/share/.
   '';
 
diff --git a/pkgs/tools/typesetting/tex/texlive/aggregate.nix b/pkgs/tools/typesetting/tex/texlive/aggregate.nix
index 1723f48190625..c018d2da0d3d9 100644
--- a/pkgs/tools/typesetting/tex/texlive/aggregate.nix
+++ b/pkgs/tools/typesetting/tex/texlive/aggregate.nix
@@ -7,12 +7,12 @@ rec {
 
   doAggregate = fullDepEntry (''
 
-    ensureDir $out/bin
+    mkdir -p $out/bin
     for currentPath in ${lib.concatStringsSep " " buildInputs}; do
         echo Symlinking "$currentPath"
         find $currentPath/share/info $currentPath/share/man $(echo $currentPath/texmf*/) ! -type d | while read; do
             REPLY="''${REPLY#$currentPath}"
-            ensureDir $out/"$(dirname "$REPLY")"
+            mkdir -p $out/"$(dirname "$REPLY")"
             ln -fs $currentPath/"$REPLY" $out/"$REPLY"
             echo
         done | while read; do head -n 99 >/dev/null; echo -n .; done
@@ -33,7 +33,7 @@ rec {
     rm -r $out/texmf-config
     find $out/texmf/ -type d | while read; do
       REPLY="''${REPLY#$out/texmf}"
-      ensureDir $out/texmf-config/"$REPLY"
+      mkdir -p $out/texmf-config/"$REPLY"
     done
 
     for i in $out/libexec/*/* :; do
diff --git a/pkgs/tools/typesetting/tex/texlive/beamer.nix b/pkgs/tools/typesetting/tex/texlive/beamer.nix
index 5ff2c89316a10..851ad0707a1da 100644
--- a/pkgs/tools/typesetting/tex/texlive/beamer.nix
+++ b/pkgs/tools/typesetting/tex/texlive/beamer.nix
@@ -10,9 +10,9 @@ rec {
   propagatedBuildInputs = [texLiveLatexXColor texLivePGF];
   phaseNames = ["doCopy"];
   doCopy = fullDepEntry (''
-    ensureDir $out/share/
+    mkdir -p $out/share/
 
-    ensureDir $out/texmf-dist/tex/latex/beamer
+    mkdir -p $out/texmf-dist/tex/latex/beamer
     cp -r * $out/texmf-dist/tex/latex/beamer 
 
     ln -s $out/texmf* $out/share/
diff --git a/pkgs/tools/typesetting/tex/texlive/cm-super.nix b/pkgs/tools/typesetting/tex/texlive/cm-super.nix
index 4f15afdc38141..e23b393685071 100644
--- a/pkgs/tools/typesetting/tex/texlive/cm-super.nix
+++ b/pkgs/tools/typesetting/tex/texlive/cm-super.nix
@@ -8,17 +8,17 @@ rec {
 
   phaseNames = ["doCopy"];
   doCopy = fullDepEntry (''
-    ensureDir $out/share/
+    mkdir -p $out/share/
 
-    ensureDir $out/texmf/fonts/enc
-    ensureDir $out/texmf/fonts/map
-    ensureDir $out/texmf/fonts/type1/public/cm-super
+    mkdir -p $out/texmf/fonts/enc
+    mkdir -p $out/texmf/fonts/map
+    mkdir -p $out/texmf/fonts/type1/public/cm-super
     cp pfb/*.pfb $out/texmf/fonts/type1/public/cm-super
-    ensureDir $out/texmf/dvips/cm-super
+    mkdir -p $out/texmf/dvips/cm-super
     cp dvips/*.{map,enc}  $out/texmf/dvips/cm-super
     cp dvips/*.enc  $out/texmf/fonts/enc
     cp dvips/*.map  $out/texmf/fonts/map
-    ensureDir $out/texmf/dvipdfm/config
+    mkdir -p $out/texmf/dvipdfm/config
     cp dvipdfm/*.map  $out/texmf/dvipdfm/config
 
     ln -s $out/texmf* $out/share/
diff --git a/pkgs/tools/typesetting/tex/texlive/context.nix b/pkgs/tools/typesetting/tex/texlive/context.nix
index b502b0f2108aa..a7161cea4c1bc 100644
--- a/pkgs/tools/typesetting/tex/texlive/context.nix
+++ b/pkgs/tools/typesetting/tex/texlive/context.nix
@@ -9,9 +9,9 @@ rec {
   buildInputs = [texLive];
   phaseNames = ["doCopy"];
   doCopy = fullDepEntry (''
-    ensureDir $out/share/
+    mkdir -p $out/share/
 
-    ensureDir $out/texmf
+    mkdir -p $out/texmf
     cp -r * $out/texmf
 
     ln -s $out/texmf* $out/share/
diff --git a/pkgs/tools/typesetting/tex/texlive/default.nix b/pkgs/tools/typesetting/tex/texlive/default.nix
index 69fb5d7e415f2..30e59849d32fa 100644
--- a/pkgs/tools/typesetting/tex/texlive/default.nix
+++ b/pkgs/tools/typesetting/tex/texlive/default.nix
@@ -18,10 +18,10 @@ rec {
   setupHook = ./setup-hook.sh;
 
   doMainBuild = fullDepEntry (''
-    ensureDir $out
-    ensureDir $out/nix-support
+    mkdir -p $out
+    mkdir -p $out/nix-support
     cp ${setupHook} $out/nix-support/setup-hook.sh
-    ensureDir $out/share
+    mkdir -p $out/share
     tar xf ${texmfSrc} -C $out --strip-components=1
     tar xf ${langTexmfSrc} -C $out --strip-components=1
 
@@ -45,7 +45,7 @@ rec {
 
   doPostInstall = fullDepEntry(''
     mv $out/bin $out/libexec
-    ensureDir $out/bin
+    mkdir -p $out/bin
     for i in "$out/libexec/"*"/"*; do
         test \( \! -d "$i" \) -a -x "$i" || continue
         echo -ne "#! $SHELL\\nexec $i \"\$@\"" >$out/bin/$(basename $i)
@@ -69,7 +69,7 @@ rec {
     #
     # I find it acceptable, hence the "|| true".
     echo "building format files..."
-    ensureDir "$out/texmf-var/web2c"
+    mkdir -p "$out/texmf-var/web2c"
     PATH="$PATH:$out/bin" fmtutil-sys --all || true
 
     PATH=$PATH:$out/bin mktexlsr $out/texmf*
diff --git a/pkgs/tools/typesetting/tex/texlive/extra.nix b/pkgs/tools/typesetting/tex/texlive/extra.nix
index 598bdd08aef5d..1ecec91a68565 100644
--- a/pkgs/tools/typesetting/tex/texlive/extra.nix
+++ b/pkgs/tools/typesetting/tex/texlive/extra.nix
@@ -9,7 +9,7 @@ rec {
   buildInputs = [texLive];
   phaseNames = ["doCopy"];
   doCopy = fullDepEntry (''
-    ensureDir $out/share
+    mkdir -p $out/share
     cp -r texmf* $out/
     ln -s $out/texmf* $out/share
   '') ["minInit" "doUnpack" "defEnsureDir" "addInputs"];
diff --git a/pkgs/tools/typesetting/tex/texlive/moderncv.nix b/pkgs/tools/typesetting/tex/texlive/moderncv.nix
index f93724e4af103..021983370e1dc 100644
--- a/pkgs/tools/typesetting/tex/texlive/moderncv.nix
+++ b/pkgs/tools/typesetting/tex/texlive/moderncv.nix
@@ -9,7 +9,7 @@ rec {
   buildInputs = [texLive unzip];
   phaseNames = ["doCopy"];
   doCopy = fullDepEntry (''
-    ensureDir $out/texmf/tex/latex/moderncv $out/texmf/doc $out/share
+    mkdir -p $out/texmf/tex/latex/moderncv $out/texmf/doc $out/share
     mv *.cls *.sty $out/texmf/tex/latex/moderncv/
     mv examples $out/texmf/doc/moderncv
     ln -s $out/texmf* $out/share/
diff --git a/pkgs/tools/typesetting/tex/texlive/pgf.nix b/pkgs/tools/typesetting/tex/texlive/pgf.nix
index fac520290f003..61e2eb26c68ae 100644
--- a/pkgs/tools/typesetting/tex/texlive/pgf.nix
+++ b/pkgs/tools/typesetting/tex/texlive/pgf.nix
@@ -12,8 +12,8 @@ rec {
 
   phaseNames = ["doCopy"];
   doCopy = fullDepEntry (''
-    ensureDir $out/share/
-    ensureDir $out/texmf/tex/generic/pgf
+    mkdir -p $out/share/
+    mkdir -p $out/texmf/tex/generic/pgf
     cp -r * $out/texmf/tex/generic/pgf
     ln -s $out/texmf* $out/share/
   '') ["minInit" "doUnpack" "defEnsureDir" "addInputs"];
diff --git a/pkgs/tools/typesetting/tex/texlive/xcolor.nix b/pkgs/tools/typesetting/tex/texlive/xcolor.nix
index 4e8d5eeb30b39..e59a58ce9b26c 100644
--- a/pkgs/tools/typesetting/tex/texlive/xcolor.nix
+++ b/pkgs/tools/typesetting/tex/texlive/xcolor.nix
@@ -10,10 +10,10 @@ rec {
   phaseNames = ["doCopy"];
   doCopy = fullDepEntry (''
     export HOME=$PWD
-    ensureDir $out/share/
+    mkdir -p $out/share/
 
-    ensureDir $out/texmf/tex/latex/xcolor
-    ensureDir $out/texmf/dvips/xcolor
+    mkdir -p $out/texmf/tex/latex/xcolor
+    mkdir -p $out/texmf/dvips/xcolor
     latex xcolor.ins 
     cp *.sty *.def $out/texmf/tex/latex/xcolor
     cp *.pro $out/texmf/dvips/xcolor
@@ -25,7 +25,7 @@ rec {
     #latex xcolor.dtx
 
     rm *.sty *.pro *.ins *.def *.dtx
-    ensureDir $out/texmf/doc/latex-xcolor
+    mkdir -p $out/texmf/doc/latex-xcolor
     cp *  $out/texmf/doc/latex-xcolor
 
     ln -s $out/texmf* $out/share/
diff --git a/pkgs/tools/virtualization/amazon-ec2-ami-tools/default.nix b/pkgs/tools/virtualization/amazon-ec2-ami-tools/default.nix
index 36dc77bcd2d73..d40fec073a70f 100644
--- a/pkgs/tools/virtualization/amazon-ec2-ami-tools/default.nix
+++ b/pkgs/tools/virtualization/amazon-ec2-ami-tools/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation {
 
   installPhase =
     ''
-      ensureDir $out
+      mkdir -p $out
       mv * $out
       rm $out/*.txt
 
diff --git a/pkgs/tools/virtualization/amazon-ec2-api-tools/default.nix b/pkgs/tools/virtualization/amazon-ec2-api-tools/default.nix
index d79afe7e90f4a..73b65a7e0fc9c 100644
--- a/pkgs/tools/virtualization/amazon-ec2-api-tools/default.nix
+++ b/pkgs/tools/virtualization/amazon-ec2-api-tools/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation {
 
   installPhase =
     ''
-      ensureDir $out
+      mkdir -p $out
       mv * $out
       rm $out/bin/*.cmd # Windows stuff
 
diff --git a/pkgs/tools/virtualization/euca2ools/default.nix b/pkgs/tools/virtualization/euca2ools/default.nix
index b82f7de1b2a96..7992ced6d0cc9 100644
--- a/pkgs/tools/virtualization/euca2ools/default.nix
+++ b/pkgs/tools/virtualization/euca2ools/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ which pythonPackages.python pythonPackages.wrapPython ];
 
   # We need boto 1.9 for now.  See https://bugs.launchpad.net/euca2ools/devel/+bug/623888
-  pythonPath = [ pythonPackages.setuptools pythonPackages.boto_1_9 pythonPackages.m2crypto pythonPackages.ssl ];
+  pythonPath = [ pythonPackages.setuptools pythonPackages.boto_1_9 pythonPackages.m2crypto ];
 
   preBuild =
     ''
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 5607cd20365b8..f631179be4c33 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -108,7 +108,7 @@ let
       # overrided packages will not be built with the crossStdenv
       # adapter.
       overrides = overrider pkgsOrig //
-        (lib.optionalAttrs (pkgsOrig.stdenv ? overrides && crossSystem == null) pkgsOrig.stdenv.overrides);
+        (lib.optionalAttrs (pkgsOrig.stdenv ? overrides && crossSystem == null) (pkgsOrig.stdenv.overrides pkgsOrig));
 
       # The un-overriden packages, passed to `overrider'.
       pkgsOrig = pkgsFun pkgs {};
@@ -241,7 +241,7 @@ let
   };
 
   buildEnv = import ../build-support/buildenv {
-    inherit runCommand perl;
+    inherit (pkgs) runCommand perl;
   };
 
   dotnetenv = import ../build-support/dotnetenv {
@@ -460,9 +460,7 @@ let
     gui = true;
   };
 
-  bittornado = callPackage ../tools/networking/p2p/bit-tornado {
-    inherit (pythonPackages) ssl;
-  };
+  bittornado = callPackage ../tools/networking/p2p/bit-tornado { };
 
   blueman = callPackage ../tools/bluetooth/blueman {
     inherit (pythonPackages) notify;
@@ -1110,9 +1108,7 @@ let
 
   odt2txt = callPackage ../tools/text/odt2txt { };
 
-  offlineimap = callPackage ../tools/networking/offlineimap {
-    ssl = pythonPackages.ssl;
-  };
+  offlineimap = callPackage ../tools/networking/offlineimap { };
 
   opendbx = callPackage ../development/libraries/opendbx { };
 
@@ -1234,8 +1230,6 @@ let
 
   ppl = callPackage ../development/libraries/ppl { };
 
-  ppl0_11 = callPackage ../development/libraries/ppl/0.11.nix { };
-
   ppp = callPackage ../tools/networking/ppp { };
 
   pptp = callPackage ../tools/networking/pptp {};
@@ -1426,7 +1420,7 @@ let
   tcpdump = callPackage ../tools/networking/tcpdump { };
 
   tcng = callPackage ../tools/networking/tcng {
-    kernel = linux_2_6_28;
+    kernel = linux_2_6_27;
   };
 
   telnet = callPackage ../tools/networking/telnet { };
@@ -1542,14 +1536,10 @@ let
 
   unshield = callPackage ../tools/archivers/unshield { };
 
-  unzip = unzip60;
+  unzip = callPackage ../tools/archivers/unzip { };
 
   unzipNLS = unzip.override { enableNLS = true; };
 
-  unzip552 = callPackage ../tools/archivers/unzip/5.52.nix { };
-
-  unzip60 = callPackage ../tools/archivers/unzip/6.0.nix { };
-
   uptimed = callPackage ../tools/system/uptimed { };
 
   vlan = callPackage ../tools/networking/vlan { };
@@ -1669,11 +1659,11 @@ let
   ### SHELLS
 
 
-  bash = lowPrio (callPackage ../shells/bash/4.1.nix {
+  bash = lowPrio (callPackage ../shells/bash {
     texinfo = null;
   });
 
-  bashInteractive = appendToName "interactive" (callPackage ../shells/bash/4.2.nix {
+  bashInteractive = appendToName "interactive" (callPackage ../shells/bash {
     interactive = true;
   });
 
@@ -1740,17 +1730,17 @@ let
 
   gambit = callPackage ../development/compilers/gambit { };
 
-  gcc = gcc45;
+  gcc = gcc46;
 
-  gcc295 = wrapGCC (import ../development/compilers/gcc-2.95 {
+  gcc295 = wrapGCC (import ../development/compilers/gcc/2.95 {
     inherit fetchurl stdenv noSysDirs;
   });
 
-  gcc33 = wrapGCC (import ../development/compilers/gcc-3.3 {
+  gcc33 = wrapGCC (import ../development/compilers/gcc/3.3 {
     inherit fetchurl stdenv noSysDirs;
   });
 
-  gcc34 = wrapGCC (import ../development/compilers/gcc-3.4 {
+  gcc34 = wrapGCC (import ../development/compilers/gcc/3.4 {
     inherit fetchurl stdenv noSysDirs;
   });
 
@@ -1759,30 +1749,30 @@ let
   # expects a single digit after the dot.  As a workaround, we feed
   # GCC with Texinfo 4.9.  Stupid bug, hackish workaround.
 
-  gcc40 = wrapGCC (makeOverridable (import ../development/compilers/gcc-4.0) {
+  gcc40 = wrapGCC (makeOverridable (import ../development/compilers/gcc/4.0) {
     inherit fetchurl stdenv noSysDirs;
     texinfo = texinfo49;
     profiledCompiler = true;
   });
 
-  gcc41 = wrapGCC (makeOverridable (import ../development/compilers/gcc-4.1) {
+  gcc41 = wrapGCC (makeOverridable (import ../development/compilers/gcc/4.1) {
     inherit fetchurl noSysDirs gmp mpfr;
     stdenv = overrideGCC stdenv gcc42;
     texinfo = texinfo49;
     profiledCompiler = false;
   });
 
-  gcc42 = wrapGCC (makeOverridable (import ../development/compilers/gcc-4.2) {
+  gcc42 = wrapGCC (makeOverridable (import ../development/compilers/gcc/4.2) {
     inherit fetchurl stdenv noSysDirs;
     profiledCompiler = false;
   });
 
-  gcc43 = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc-4.3) {
+  gcc43 = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc/4.3) {
     inherit stdenv fetchurl texinfo gmp mpfr noSysDirs;
     profiledCompiler = true;
   }));
 
-  gcc43_realCross = makeOverridable (import ../development/compilers/gcc-4.3) {
+  gcc43_realCross = makeOverridable (import ../development/compilers/gcc/4.3) {
     inherit stdenv fetchurl texinfo gmp mpfr noSysDirs;
     binutilsCross = binutilsCross;
     libcCross = libcCross;
@@ -1793,7 +1783,7 @@ let
   };
 
   gcc44_realCross = lib.addMetaAttrs { platforms = []; }
-    (makeOverridable (import ../development/compilers/gcc-4.4) {
+    (makeOverridable (import ../development/compilers/gcc/4.4) {
       inherit stdenv fetchurl texinfo gmp mpfr /* ppl cloogppl */ noSysDirs
           gettext which;
       binutilsCross = binutilsCross;
@@ -1806,34 +1796,10 @@ let
 
   gcc45 = gcc45_real;
 
-  gcc45_debug =
-    let gcc = lib.overrideDerivation gcc45.gcc (attrs:
-      # GCC 4.5's builder.sh contains hard-coded `-g0' flags, so patch it to
-      # remove them.
-      # TODO: Remove those `-g0' and this hack on the next stdenv update.
-      let
-        orig_builder = builtins.head (builtins.tail attrs.args);
-        new_builder = stdenv.mkDerivation {
-          name = "builder-gcc-4.5-debug";
-          phases = "buildPhase";
-          buildPhase =
-            '' cp -v "${orig_builder}" "$out"
-               sed -i "$out" -e 's/-g0//g ; s/--strip-debug//g'
-               chmod +x "$out"
-            '';
-        };
-      in {
-        args = [ "-e" "${new_builder}" ];
-        postHook = '' rm -rf "$out/src/build" '';
-      });
-   in
-     lowPrio (wrapGCC (misc.debugVersion gcc));
-
-
   gcc46 = gcc46_real;
 
   gcc45_realCross = lib.addMetaAttrs { platforms = []; }
-    (makeOverridable (import ../development/compilers/gcc-4.5) {
+    (makeOverridable (import ../development/compilers/gcc/4.5) {
       inherit fetchurl stdenv texinfo gmp mpfr mpc libelf zlib
         ppl cloogppl gettext which noSysDirs;
       binutilsCross = binutilsCross;
@@ -1845,10 +1811,9 @@ let
     });
 
   gcc46_realCross = lib.addMetaAttrs { platforms = []; }
-    (makeOverridable (import ../development/compilers/gcc-4.6) {
+    (makeOverridable (import ../development/compilers/gcc/4.6) {
       inherit fetchurl stdenv texinfo gmp mpfr mpc libelf zlib
-        cloog gettext which noSysDirs;
-      ppl = ppl0_11;
+        cloog ppl gettext which noSysDirs;
       binutilsCross = binutilsCross;
       libcCross = libcCross;
       profiledCompiler = false;
@@ -1903,13 +1868,13 @@ let
     enableMultilib = true;
   }));
 
-  gcc44 = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc-4.4) {
+  gcc44 = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc/4.4) {
     inherit fetchurl stdenv texinfo gmp mpfr /* ppl cloogppl */
       gettext which noSysDirs;
     profiledCompiler = true;
   }));
 
-  gcc45_real = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc-4.5) {
+  gcc45_real = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc/4.5) {
     inherit fetchurl stdenv texinfo gmp mpfr mpc libelf zlib perl
       ppl cloogppl
       gettext which noSysDirs;
@@ -1928,11 +1893,19 @@ let
       else null;
   }));
 
-  gcc46_real = lowPrio (wrapGCC (callPackage ../development/compilers/gcc-4.6 {
+  # A non-stripped version of GCC.
+  gcc45_debug = lowPrio (wrapGCC (callPackage ../development/compilers/gcc/4.5 {
+    stripped = false;
+
     inherit noSysDirs;
 
-    ppl = ppl0_11;
-    cloogppl = null;
+    # bootstrapping a profiled compiler does not work in the sheevaplug:
+    # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43944
+    profiledCompiler = if stdenv.system == "armv5tel-linux" then false else true;
+  }));
+
+  gcc46_real = lowPrio (wrapGCC (callPackage ../development/compilers/gcc/4.6 {
+    inherit noSysDirs;
 
     # bootstrapping a profiled compiler does not work in the sheevaplug:
     # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43944
@@ -1950,23 +1923,20 @@ let
   }));
 
   # A non-stripped version of GCC.
-  gcc46_debug = lowPrio (wrapGCC (callPackage ../development/compilers/gcc-4.6 {
+  gcc46_debug = lowPrio (wrapGCC (callPackage ../development/compilers/gcc/4.6 {
     stripped = false;
 
     inherit noSysDirs;
     cross = null;
     libcCross = null;
     binutilsCross = null;
-
-    ppl = ppl0_11;
-    cloogppl = null;
   }));
 
   gccApple =
-    wrapGCC ( (if stdenv.system == "i686-darwin" then import ../development/compilers/gcc-apple else import ../development/compilers/gcc-apple64) {
+    wrapGCC ( (if stdenv.system == "i686-darwin" then import ../development/compilers/gcc/4.2-apple32 else import ../development/compilers/gcc/4.2-apple64) {
       inherit fetchurl stdenv noSysDirs;
       profiledCompiler = true;
-    }) ;
+    });
 
   gccupc40 = wrapGCCUPC (import ../development/compilers/gcc-upc-4.0 {
     inherit fetchurl stdenv bison autoconf gnum4 noSysDirs;
@@ -2110,7 +2080,6 @@ let
     gnatboot = gnat45;
     # We can't use the ppl stuff, because we would have
     # libstdc++ problems.
-    cloogppl = null;
     ppl = null;
     cloog = null;
   });
@@ -2128,7 +2097,7 @@ let
     langGo = true;
   });
 
-  ghdl = wrapGCC (import ../development/compilers/gcc-4.3 {
+  ghdl = wrapGCC (import ../development/compilers/gcc/4.3 {
     inherit stdenv fetchurl texinfo gmp mpfr noSysDirs gnat;
     name = "ghdl";
     langVhdl = true;
@@ -2139,7 +2108,7 @@ let
   });
 
   # Not officially supported version for ghdl
-  ghdl_gcc44 = lowPrio (wrapGCC (import ../development/compilers/gcc-4.4 {
+  ghdl_gcc44 = lowPrio (wrapGCC (import ../development/compilers/gcc/4.4 {
     inherit stdenv fetchurl texinfo gmp mpfr noSysDirs gnat gettext which
       ppl cloogppl;
     name = "ghdl";
@@ -2177,20 +2146,20 @@ let
   });
   */
 
-  ghc6101Binary = lowPrio (import ../development/compilers/ghc/6.10.1-binary.nix {
-    inherit fetchurl stdenv perl ncurses gmp libedit;
+  ghc6101Binary = lowPrio (callPackage ../development/compilers/ghc/6.10.1-binary.nix {
+    gmp = gmp4;
   });
 
-  ghc6102Binary = lowPrio (import ../development/compilers/ghc/6.10.2-binary.nix {
-    inherit fetchurl stdenv perl ncurses gmp libedit;
+  ghc6102Binary = lowPrio (callPackage ../development/compilers/ghc/6.10.2-binary.nix {
+    gmp = gmp4;
   });
 
-  ghc6121Binary = lowPrio (import ../development/compilers/ghc/6.12.1-binary.nix {
-    inherit fetchurl stdenv perl ncurses gmp;
+  ghc6121Binary = lowPrio (callPackage ../development/compilers/ghc/6.12.1-binary.nix {
+    gmp = gmp4;
   });
 
-  ghc704Binary = lowPrio (import ../development/compilers/ghc/7.0.4-binary.nix {
-    inherit fetchurl stdenv perl ncurses gmp;
+  ghc704Binary = lowPrio (callPackage ../development/compilers/ghc/7.0.4-binary.nix {
+    gmp = gmp4;
   });
 
   # For several compiler versions, we export a large set of Haskell-related
@@ -2404,14 +2373,12 @@ let
 
   nvidia_cg_toolkit = callPackage ../development/compilers/nvidia-cg-toolkit { };
 
-  ocaml = ocaml_3_11_1;
+  ocaml = ocaml_3_12_1;
 
   ocaml_3_08_0 = callPackage ../development/compilers/ocaml/3.08.0.nix { };
 
   ocaml_3_10_0 = callPackage ../development/compilers/ocaml/3.10.0.nix { };
 
-  ocaml_3_11_1 = callPackage ../development/compilers/ocaml/3.11.1.nix { };
-
   ocaml_3_12_1 = lowPrio (callPackage ../development/compilers/ocaml/3.12.1.nix { });
 
   metaocaml_3_09 = callPackage ../development/compilers/ocaml/metaocaml-3.09.nix { };
@@ -2505,9 +2472,8 @@ let
     pycaml = callPackage ../development/ocaml-modules/pycaml { };
   };
 
-  ocamlPackages = recurseIntoAttrs ocamlPackages_3_11_1;
+  ocamlPackages = recurseIntoAttrs ocamlPackages_3_12_1;
   ocamlPackages_3_10_0 = mkOcamlPackages ocaml_3_10_0 pkgs.ocamlPackages_3_10_0;
-  ocamlPackages_3_11_1 = mkOcamlPackages ocaml_3_11_1 pkgs.ocamlPackages_3_11_1;
   ocamlPackages_3_12_1 = mkOcamlPackages ocaml_3_12_1 pkgs.ocamlPackages_3_12_1;
 
   ocaml_make = callPackage ../development/ocaml-modules/ocamlmake { };
@@ -2633,7 +2599,8 @@ let
   # compatibility issues in 2.47 - at list 2.44.1 is known good
   # for sbcl bootstrap
   clisp_2_44_1 = callPackage ../development/interpreters/clisp/2.44.1.nix {
-    libsigsegv = libsigsegv_25;  };
+    libsigsegv = libsigsegv_25;
+  };
 
   clojure = callPackage ../development/interpreters/clojure { };
 
@@ -2686,15 +2653,17 @@ let
   # mercurial (hg) bleeding edge version
   octaveHG = callPackage ../development/interpreters/octave/hg.nix { };
 
-  perl58 = callPackage ../development/interpreters/perl-5.8 {
+  perl58 = callPackage ../development/interpreters/perl/5.8 {
     impureLibcPath = if stdenv.isLinux then null else "/usr";
   };
 
-  perl510 = callPackage ../development/interpreters/perl-5.10 {
+  perl510 = callPackage ../development/interpreters/perl/5.10 { };
+
+  perl514 = callPackage ../development/interpreters/perl/5.14 {
     fetchurl = fetchurlBoot;
   };
 
-  perl = if system != "i686-cygwin" then perl510 else sysPerl;
+  perl = if system != "i686-cygwin" then perl514 else sysPerl;
 
   php = php5_3;
 
@@ -2926,7 +2895,7 @@ let
     cross = assert crossSystem != null; crossSystem;
   });
 
-  bison = bison24;
+  bison = bison25;
 
   bison1875 = callPackage ../development/tools/parsing/bison/bison-1.875.nix { };
 
@@ -3124,8 +3093,6 @@ let
 
   patchelf = callPackage ../development/tools/misc/patchelf { };
 
-  patchelf06 = callPackage ../development/tools/misc/patchelf/0.6.nix { };
-
   peg = callPackage ../development/tools/parsing/peg { };
 
   pmccabe = callPackage ../development/tools/misc/pmccabe { };
@@ -3337,8 +3304,7 @@ let
 
   cln = callPackage ../development/libraries/cln { };
 
-  clppcre = builderDefsPackage (import ../development/libraries/cl-ppcre) {
-  };
+  clppcre = builderDefsPackage (import ../development/libraries/cl-ppcre) { };
 
   clucene_core = callPackage ../development/libraries/clucene-core { };
 
@@ -3402,14 +3368,6 @@ let
     useX11 = true;
   };
 
-  dbus_all_1_5_6 = callPackage ../development/libraries/dbus/1.5.6.nix {
-    useX11 = true;
-  };
-
-  dbus_glib_0_94 = callPackage ../development/libraries/dbus-glib/0.94.nix {
-    dbus = pkgs.dbus_all_1_5_6.libs;
-  };
-
   dbus_glib = callPackage ../development/libraries/dbus-glib { };
 
   dbus_java = callPackage ../development/libraries/java/dbus-java { };
@@ -3559,57 +3517,73 @@ let
 
   glfw = callPackage ../development/libraries/glfw { };
 
-  glibc = glibc212;
+  glibc = glibc213;
+
+  glibcCross = glibc213Cross;
 
-  glibc25 = callPackage ../development/libraries/glibc-2.5 {
+  glibc25 = callPackage ../development/libraries/glibc/2.5 {
     kernelHeaders = linuxHeaders_2_6_28;
     installLocales = false;
   };
 
-  glibc27 = callPackage ../development/libraries/glibc-2.7 {
+  glibc27 = callPackage ../development/libraries/glibc/2.7 {
     kernelHeaders = linuxHeaders;
     #installLocales = false;
   };
 
-  glibc29 = callPackage ../development/libraries/glibc-2.9 {
+  glibc29 = callPackage ../development/libraries/glibc/2.9 {
     kernelHeaders = linuxHeaders;
     installLocales = getConfig [ "glibc" "locales" ] false;
   };
 
-  glibc29Cross = forceBuildDrv (makeOverridable (import ../development/libraries/glibc-2.9) {
+  glibc29Cross = forceBuildDrv (makeOverridable (import ../development/libraries/glibc/2.9) {
     inherit stdenv fetchurl;
     gccCross = gccCrossStageStatic;
     kernelHeaders = linuxHeadersCross;
     installLocales = getConfig [ "glibc" "locales" ] false;
   });
 
-  glibc212 = (callPackage ../development/libraries/glibc-2.12 {
+  glibc213 = (callPackage ../development/libraries/glibc/2.13 {
     kernelHeaders = linuxHeaders;
     installLocales = getConfig [ "glibc" "locales" ] false;
     machHeaders = null;
     hurdHeaders = null;
     gccCross = null;
-  }) // (if crossSystem != null then { hostDrv = glibc212Cross; } else {});
+  }) // (if crossSystem != null then { hostDrv = glibc213Cross; } else {});
 
-  glibc212Cross = forceBuildDrv (makeOverridable (import ../development/libraries/glibc-2.12)
-    (let crossGNU = (crossSystem != null && crossSystem.config == "i586-pc-gnu");
-     in ({
+  glibc213Cross = forceBuildDrv (makeOverridable (import ../development/libraries/glibc/2.13)
+    (let crossGNU = crossSystem != null && crossSystem.config == "i586-pc-gnu";
+     in {
        inherit stdenv fetchurl;
        gccCross = gccCrossStageStatic;
        kernelHeaders = if crossGNU then gnu.hurdHeaders else linuxHeadersCross;
        installLocales = getConfig [ "glibc" "locales" ] false;
      }
+     // lib.optionalAttrs crossGNU {
+        inherit (gnu) machHeaders hurdHeaders libpthreadHeaders mig;
+        inherit fetchgit;
+      }));
 
-     //
+  glibc214 = (callPackage ../development/libraries/glibc/2.14 {
+    kernelHeaders = linuxHeaders;
+    installLocales = getConfig [ "glibc" "locales" ] false;
+    machHeaders = null;
+    hurdHeaders = null;
+    gccCross = null;
+  }) // (lib.optionalAttrs (crossSystem != null) { hostDrv = glibc214Cross; });
 
-     (if crossGNU
-      then {
+  glibc214Cross = forceBuildDrv (makeOverridable (import ../development/libraries/glibc/2.14)
+    (let crossGNU = (crossSystem != null && crossSystem.config == "i586-pc-gnu");
+     in {
+       inherit stdenv fetchurl;
+       gccCross = gccCrossStageStatic;
+       kernelHeaders = if crossGNU then gnu.hurdHeaders else linuxHeadersCross;
+       installLocales = getConfig [ "glibc" "locales" ] false;
+     }
+     // lib.optionalAttrs crossGNU {
         inherit (gnu) machHeaders hurdHeaders libpthreadHeaders mig;
         inherit fetchgit;
-      }
-      else { }))));
-
-  glibcCross = glibc212Cross;
+      }));
 
   # We can choose:
   libcCrossChooser = name : if (name == "glibc") then glibcCross
@@ -3624,9 +3598,9 @@ let
     installLocales = getConfig [ "glibc" "locales" ] false;
   };
 
-  glibcLocales = callPackage ../development/libraries/glibc-2.12/locales.nix { };
+  glibcLocales = callPackage ../development/libraries/glibc/2.14/locales.nix { };
 
-  glibcInfo = callPackage ../development/libraries/glibc-2.12/info.nix { };
+  glibcInfo = callPackage ../development/libraries/glibc/2.14/info.nix { };
 
   glibc_multi =
       runCommand "${glibc.name}-multi"
@@ -3634,11 +3608,11 @@ let
           glibc32 = (import ./all-packages.nix {system = "i686-linux";}).glibc;
         }
         ''
-          ensureDir $out
+          mkdir -p $out
           ln -s $glibc64/* $out/
 
           rm $out/lib $out/lib64
-          ensureDir $out/lib
+          mkdir -p $out/lib
           ln -s $glibc64/lib/* $out/lib
           ln -s $glibc32/lib $out/lib/32
           ln -s lib $out/lib64
@@ -3659,22 +3633,20 @@ let
   gmp =
     if stdenv.system == "i686-darwin" then
       # GMP 4.3.2 is broken on Darwin, so use 4.3.1.
-      makeOverridable (import ../development/libraries/gmp/4.3.1.nix) {
-        inherit stdenv fetchurl m4;
-        cxx = false;
-      }
+      callPackage ../development/libraries/gmp/4.3.1.nix { }
     else
-      # We temporarily leave gmp 4 here, waiting for a new ppl/cloog-ppl that
-      # would build well with gmp 5.
-      makeOverridable (import ../development/libraries/gmp/4.3.2.nix) {
-        inherit stdenv fetchurl m4;
-        cxx = false;
-      };
-
-  gmp5 = callPackage ../development/libraries/gmp/5.0.3.nix { };
+      callPackage ../development/libraries/gmp/5.0.3.nix { };
 
   gmpxx = appendToName "with-cxx" (gmp.override { cxx = true; });
 
+  # The GHC bootstrap binaries link against libgmp.so.3, which is in GMP 4.x.
+  gmp4 =
+    if stdenv.system == "i686-darwin" then
+      # GMP 4.3.2 is broken on Darwin, so use 4.3.1.
+      callPackage ../development/libraries/gmp/4.3.1.nix { }
+    else
+      callPackage ../development/libraries/gmp/4.3.2.nix { };
+  
   gobjectIntrospection = callPackage ../development/libraries/gobject-introspection { };
 
   goffice = callPackage ../development/libraries/goffice {
@@ -4504,7 +4476,7 @@ let
   };
 
   pcre = callPackage ../development/libraries/pcre {
-    unicodeSupport = getConfig ["pcre" "unicode"] false;
+    unicodeSupport = getConfig ["pcre" "unicode"] true;
     cplusplusSupport = !stdenv ? isDietLibC;
   };
 
@@ -5366,12 +5338,12 @@ let
 
   libuuid =
     if crossSystem != null && crossSystem.config == "i586-pc-gnu"
-    then (utillinuxng // {
-      hostDrv = lib.overrideDerivation utillinuxng.hostDrv (args: {
+    then (utillinux // {
+      hostDrv = lib.overrideDerivation utillinux.hostDrv (args: {
         # `libblkid' fails to build on GNU/Hurd.
         configureFlags = args.configureFlags
           + " --disable-libblkid --disable-mount --disable-libmount"
-          + " --disable-fsck --enable-static";
+          + " --disable-fsck --enable-static --disable-partx";
         doCheck = false;
         CPPFLAGS =                    # ugly hack for ugly software!
           lib.concatStringsSep " "
@@ -5380,7 +5352,7 @@ let
       });
     })
     else if stdenv.isLinux
-    then utillinuxng
+    then utillinux
     else null;
 
   e3cfsprogs = callPackage ../os-specific/linux/e3cfsprogs { };
@@ -5473,7 +5445,7 @@ let
 
   libnl1 = callPackage ../os-specific/linux/libnl/v1.nix { };
 
-  linuxHeaders = linuxHeaders_2_6_32;
+  linuxHeaders = callPackage ../os-specific/linux/kernel-headers { };
 
   linuxHeaders26Cross = forceBuildDrv (import ../os-specific/linux/kernel-headers/2.6.32.nix {
     inherit stdenv fetchurl perl;
@@ -5493,48 +5465,21 @@ let
   linuxHeadersCross = assert crossSystem != null;
     linuxHeadersCrossChooser crossSystem.platform.kernelMajor;
 
-  linuxHeaders_2_6_18 = callPackage ../os-specific/linux/kernel-headers/2.6.18.5.nix { };
-
   linuxHeaders_2_6_28 = callPackage ../os-specific/linux/kernel-headers/2.6.28.nix { };
 
-  linuxHeaders_2_6_32 = callPackage ../os-specific/linux/kernel-headers/2.6.32.nix { };
-
   kernelPatches = callPackage ../os-specific/linux/kernel/patches.nix { };
 
   linux_2_6_15 = makeOverridable (import ../os-specific/linux/kernel/linux-2.6.15.nix) {
     inherit fetchurl perl mktemp module_init_tools;
-    stdenv = overrideInStdenv stdenv [gcc34 gnumake381];
+    stdenv = overrideInStdenv stdenv [ gcc34 gnumake381 ];
     kernelPatches =
       [ kernelPatches.cifs_timeout_2_6_15
       ];
   };
 
-  linux_2_6_25 = makeOverridable (import ../os-specific/linux/kernel/linux-2.6.25.nix) {
-    inherit fetchurl perl mktemp module_init_tools;
-    extraConfig = "KMOD y";
-    stdenv = overrideInStdenv stdenv [gnumake381];
-    kernelPatches =
-      [ kernelPatches.fbcondecor_2_6_25
-        kernelPatches.sec_perm_2_6_24
-        kernelPatches.glibc_getline
-        kernelPatches.cifs_timeout_2_6_25
-      ];
-  };
-
-  linux_2_6_26 = makeOverridable (import ../os-specific/linux/kernel/linux-2.6.26.nix) {
-    inherit fetchurl perl mktemp module_init_tools;
-    stdenv = overrideInStdenv stdenv [gnumake381];
-    kernelPatches =
-      [ kernelPatches.fbcondecor_2_6_25
-        kernelPatches.sec_perm_2_6_24
-        kernelPatches.glibc_getline
-        kernelPatches.cifs_timeout_2_6_25
-      ];
-  };
-
   linux_2_6_27 = makeOverridable (import ../os-specific/linux/kernel/linux-2.6.27.nix) {
     inherit fetchurl perl mktemp module_init_tools;
-    stdenv = overrideInStdenv stdenv [gnumake381];
+    stdenv = overrideGCC (overrideInStdenv stdenv [ gnumake381 ]) gcc45;
     kernelPatches =
       [ kernelPatches.fbcondecor_2_6_27
         kernelPatches.sec_perm_2_6_24
@@ -5542,34 +5487,6 @@ let
       ];
   };
 
-  linux_2_6_28 = makeOverridable (import ../os-specific/linux/kernel/linux-2.6.28.nix) {
-    inherit fetchurl perl mktemp module_init_tools;
-    stdenv = overrideInStdenv stdenv [gnumake381];
-    kernelPatches =
-      [ kernelPatches.fbcondecor_2_6_28
-        kernelPatches.sec_perm_2_6_24
-        kernelPatches.ext4_softlockups_2_6_28
-        kernelPatches.glibc_getline
-        kernelPatches.cifs_timeout_2_6_25
-      ];
-  };
-
-  linux_2_6_29 = makeOverridable (import ../os-specific/linux/kernel/linux-2.6.29.nix) {
-    inherit fetchurl stdenv perl mktemp module_init_tools;
-    kernelPatches =
-      [ kernelPatches.fbcondecor_2_6_29
-        kernelPatches.sec_perm_2_6_24
-        kernelPatches.cifs_timeout_2_6_29
-      ];
-  };
-
-  linux_2_6_31 = makeOverridable (import ../os-specific/linux/kernel/linux-2.6.31.nix) {
-    inherit fetchurl stdenv perl mktemp module_init_tools platform;
-    kernelPatches =
-      [ kernelPatches.cifs_timeout_2_6_29
-      ];
-  };
-
   linux_2_6_32 = makeOverridable (import ../os-specific/linux/kernel/linux-2.6.32.nix) {
     inherit fetchurl stdenv perl mktemp module_init_tools ubootChooser;
     kernelPatches =
@@ -5614,58 +5531,6 @@ let
       ];
   };
 
-  linux_2_6_32_zen4 = makeOverridable (import ../os-specific/linux/zen-kernel/2.6.32-zen4.nix) {
-    inherit fetchurl stdenv perl mktemp module_init_tools runCommand xz;
-  };
-
-  linux_2_6_32_zen4_oldi686 = linux_2_6_32_zen4.override {
-    features = {
-      oldI686 = true;
-    };
-  };
-
-  linux_2_6_32_zen4_bfs = linux_2_6_32_zen4.override {
-    features = {
-      ckSched = true;
-    };
-  };
-
-  linux_2_6_33 = makeOverridable (import ../os-specific/linux/kernel/linux-2.6.33.nix) {
-    inherit fetchurl stdenv perl mktemp module_init_tools ubootChooser;
-    kernelPatches =
-      [ kernelPatches.fbcondecor_2_6_33
-        kernelPatches.aufs2_2_6_33
-        kernelPatches.sec_perm_2_6_24
-        kernelPatches.cifs_timeout_2_6_29
-      ];
-  };
-
-  linux_2_6_33_zen1 = makeOverridable (import ../os-specific/linux/zen-kernel/2.6.33-zen1.nix) {
-    inherit fetchurl stdenv perl mktemp module_init_tools runCommand xz;
-  };
-
-  linux_2_6_33_zen1_oldi686 = linux_2_6_33_zen1.override {
-    features = {
-      oldI686 = true;
-    };
-  };
-
-  linux_2_6_33_zen1_bfs = linux_2_6_33_zen1.override {
-    features = {
-      ckSched = true;
-    };
-  };
-
-  linux_2_6_34 = makeOverridable (import ../os-specific/linux/kernel/linux-2.6.34.nix) {
-    inherit fetchurl stdenv perl mktemp module_init_tools ubootChooser;
-    kernelPatches =
-      [ /*kernelPatches.fbcondecor_2_6_33*/
-        kernelPatches.sec_perm_2_6_24
-        kernelPatches.aufs2_2_6_34
-        kernelPatches.cifs_timeout_2_6_29
-      ];
-  };
-
   linux_2_6_35 = makeOverridable (import ../os-specific/linux/kernel/linux-2.6.35.nix) {
     inherit fetchurl stdenv perl mktemp module_init_tools ubootChooser;
     kernelPatches =
@@ -5706,36 +5571,14 @@ let
     };
 
   linux_2_6_35_oldI686 = linux_2_6_35.override {
-      extraConfig = ''
-          HIGHMEM64G? n
-          XEN? n
-      '';
-      extraMeta = {
-        platforms = ["i686-linux"];
-        maintainers = [lib.maintainers.raskin];
-      };
-  };
-
-  linux_2_6_36 = makeOverridable (import ../os-specific/linux/kernel/linux-2.6.36.nix) {
-    inherit fetchurl stdenv perl mktemp module_init_tools ubootChooser;
-    kernelPatches =
-      [ #kernelPatches.fbcondecor_2_6_35
-        kernelPatches.sec_perm_2_6_24
-        kernelPatches.aufs2_2_6_36
-        kernelPatches.mips_restart_2_6_36
-        kernelPatches.cifs_timeout_2_6_35
-      ];
-  };
-
-  linux_2_6_37 = makeOverridable (import ../os-specific/linux/kernel/linux-2.6.37.nix) {
-    inherit fetchurl stdenv perl mktemp module_init_tools ubootChooser;
-    kernelPatches =
-      [ kernelPatches.fbcondecor_2_6_37
-        kernelPatches.sec_perm_2_6_24
-        kernelPatches.aufs2_1_2_6_37
-        kernelPatches.cifs_timeout_2_6_35
-        #kernelPatches.mips_restart_2_6_36
-      ];
+    extraConfig = ''
+      HIGHMEM64G? n
+      XEN? n
+    '';
+    extraMeta = {
+      platforms = ["i686-linux"];
+      maintainers = [lib.maintainers.raskin];
+    };
   };
 
   linux_2_6_38 = makeOverridable (import ../os-specific/linux/kernel/linux-2.6.38.nix) {
@@ -5852,6 +5695,8 @@ let
 
     broadcom_sta = callPackage ../os-specific/linux/broadcom-sta/default.nix { };
 
+    kernelHeaders = callPackage ../os-specific/linux/kernel-headers { };
+
     nvidia_x11 = callPackage ../os-specific/linux/nvidia-x11 { };
 
     nvidia_x11_legacy96 = callPackage ../os-specific/linux/nvidia-x11/legacy96.nix { };
@@ -5903,21 +5748,13 @@ let
   };
 
   # Build the kernel modules for the some of the kernels.
-  linuxPackages_2_6_25 = recurseIntoAttrs (linuxPackagesFor linux_2_6_25 pkgs.linuxPackages_2_6_25);
   linuxPackages_2_6_27 = recurseIntoAttrs (linuxPackagesFor linux_2_6_27 pkgs.linuxPackages_2_6_27);
-  linuxPackages_2_6_28 = recurseIntoAttrs (linuxPackagesFor linux_2_6_28 pkgs.linuxPackages_2_6_28);
-  linuxPackages_2_6_29 = recurseIntoAttrs (linuxPackagesFor linux_2_6_29 pkgs.linuxPackages_2_6_29);
-  linuxPackages_2_6_31 = recurseIntoAttrs (linuxPackagesFor linux_2_6_31 pkgs.linuxPackages_2_6_31);
   linuxPackages_2_6_32 = recurseIntoAttrs (linuxPackagesFor linux_2_6_32 pkgs.linuxPackages_2_6_32);
   linuxPackages_2_6_32_systemtap =
     recurseIntoAttrs (linuxPackagesFor linux_2_6_32_systemtap pkgs.linuxPackages_2_6_32_systemtap);
   linuxPackages_2_6_32_xen =
     recurseIntoAttrs (linuxPackagesFor linux_2_6_32_xen pkgs.linuxPackages_2_6_32_xen);
-  linuxPackages_2_6_33 = recurseIntoAttrs (linuxPackagesFor linux_2_6_33 pkgs.linuxPackages_2_6_33);
-  linuxPackages_2_6_34 = recurseIntoAttrs (linuxPackagesFor linux_2_6_34 pkgs.linuxPackages_2_6_34);
   linuxPackages_2_6_35 = recurseIntoAttrs (linuxPackagesFor linux_2_6_35 pkgs.linuxPackages_2_6_35);
-  linuxPackages_2_6_36 = recurseIntoAttrs (linuxPackagesFor linux_2_6_36 pkgs.linuxPackages_2_6_36);
-  linuxPackages_2_6_37 = recurseIntoAttrs (linuxPackagesFor linux_2_6_37 pkgs.linuxPackages_2_6_37);
   linuxPackages_2_6_38 = recurseIntoAttrs (linuxPackagesFor linux_2_6_38 pkgs.linuxPackages_2_6_38);
   linuxPackages_2_6_38_ati = recurseIntoAttrs (linuxPackagesFor linux_2_6_38_ati pkgs.linuxPackages_2_6_38);
   linuxPackages_2_6_39 = recurseIntoAttrs (linuxPackagesFor linux_2_6_39 pkgs.linuxPackages_2_6_39);
@@ -6159,12 +5996,9 @@ let
   udev173 = callPackage ../os-specific/linux/udev/173.nix { };
   udev = pkgs.udev173;
 
-  udisks = callPackage ../os-specific/linux/udisks {
-    inherit (gnome) gtkdoc;
-  };
+  udisks = callPackage ../os-specific/linux/udisks { };
 
-  uml = import ../os-specific/linux/kernel/linux-2.6.29.nix {
-    inherit fetchurl stdenv perl mktemp module_init_tools;
+  uml = linux.override {
     userModeLinux = true;
   };
 
@@ -6174,24 +6008,18 @@ let
 
   untie = callPackage ../os-specific/linux/untie { };
 
-  upower = callPackage ../os-specific/linux/upower {
-    dbus_glib = pkgs.dbus_glib_0_94;
-  };
+  upower = callPackage ../os-specific/linux/upower { };
 
   upstart = callPackage ../os-specific/linux/upstart { };
 
   usbutils = callPackage ../os-specific/linux/usbutils { };
 
-  utillinux = utillinuxng;
-
-  utillinuxCurses = utillinuxngCurses;
-
-  utillinuxng = lowPrio (callPackage ../os-specific/linux/util-linux-ng {
+  utillinux = lowPrio (callPackage ../os-specific/linux/util-linux {
     ncurses = null;
     perl = null;
   });
 
-  utillinuxngCurses = utillinuxng.override {
+  utillinuxCurses = utillinux.override {
     inherit ncurses perl;
   };
 
@@ -6515,7 +6343,6 @@ let
   chrome = lowPrio (callPackage ../applications/networking/browsers/chromium {
     inherit (gnome) GConf;
     libpng = libpng12;
-    patchelf = patchelf06;
   });
 
   chromeWrapper = wrapFirefox
@@ -7012,20 +6839,14 @@ let
 
   i810switch = callPackage ../os-specific/linux/i810switch { };
 
-  icecat3 = lowPrio (import ../applications/networking/browsers/icecat-3 {
-    inherit fetchurl stdenv xz pkgconfig perl zip libjpeg libpng zlib cairo
-      python dbus dbus_glib freetype fontconfig bzip2 xlibs alsaLib libnotify
-      wirelesstools;
+  icecat3 = lowPrio (callPackage ../applications/networking/browsers/icecat-3 {
     inherit (gnome) libIDL libgnomeui gnome_vfs gtk pango;
     inherit (xlibs) pixman;
     inherit (pythonPackages) ply;
   });
 
-  icecatXulrunner3 = lowPrio (import ../applications/networking/browsers/icecat-3 {
+  icecatXulrunner3 = lowPrio (callPackage ../applications/networking/browsers/icecat-3 {
     application = "xulrunner";
-    inherit fetchurl stdenv xz pkgconfig perl zip libjpeg libpng zlib cairo
-      python dbus dbus_glib freetype fontconfig bzip2 xlibs alsaLib libnotify
-      wirelesstools;
     inherit (gnome) libIDL libgnomeui gnome_vfs gtk pango;
     inherit (xlibs) pixman;
     inherit (pythonPackages) ply;
@@ -7166,7 +6987,7 @@ let
   };
 
   mercurial = callPackage ../applications/version-management/mercurial {
-    inherit (pythonPackages) ssl curses;
+    inherit (pythonPackages) curses;
     guiSupport = false;		# use mercurialFull to get hgk GUI
   };
 
diff --git a/pkgs/top-level/make-tarball.nix b/pkgs/top-level/make-tarball.nix
index fb9c772d9ac05..fad3993ddc127 100644
--- a/pkgs/top-level/make-tarball.nix
+++ b/pkgs/top-level/make-tarball.nix
@@ -66,18 +66,18 @@ releaseTools.makeSourceTarball {
   distPhase = ''
     find . -name "\.svn" -exec rm -rvf {} \; -prune
   
-    ensureDir $out/tarballs
+    mkdir -p $out/tarballs
     mkdir ../$releaseName
     cp -prd . ../$releaseName
     (cd .. && tar cfa $out/tarballs/$releaseName.tar.bz2 $releaseName) || false
     (cd .. && tar cfa $out/tarballs/$releaseName.tar.lzma $releaseName) || false
 
-    ensureDir $out/release-notes
+    mkdir -p $out/release-notes
     cp doc/NEWS.html $out/release-notes/index.html
     cp doc/style.css $out/release-notes/
     echo "doc release-notes $out/release-notes" >> $out/nix-support/hydra-build-products
 
-    ensureDir $out/manual
+    mkdir -p $out/manual
     cp doc/manual.html $out/manual/index.html
     cp doc/style.css $out/manual/
     echo "doc manual $out/manual" >> $out/nix-support/hydra-build-products
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 4feeaa316e0d7..0e8b8b9f8ac2f 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -554,7 +554,7 @@ let pythonPackages = python.modules // rec {
 
     buildInputs = [ nose mox ];
 
-    propagatedBuildInputs = [ gflags sqlalchemy webob routes eventlet python.modules.ssl ];
+    propagatedBuildInputs = [ gflags sqlalchemy webob routes eventlet ];
 
     PYTHON_EGG_CACHE = "`pwd`/.egg-cache";
 
@@ -1051,7 +1051,7 @@ let pythonPackages = python.modules // rec {
 
     installCommand = ''
       dest=$(toPythonPath $out)/optfunc
-      ensureDir $dest
+      mkdir -p $dest
       cp * $dest/
     '';
 
@@ -1559,10 +1559,10 @@ let pythonPackages = python.modules // rec {
 
     installPhase = ''
       dest=$(toPythonPath $out)/pysvn
-      ensureDir $dest
+      mkdir -p $dest
       cp pysvn/__init__.py $dest/
       cp pysvn/_pysvn*.so $dest/
-      ensureDir $out/share/doc
+      mkdir -p $out/share/doc
       mv -v ../Docs $out/share/doc/pysvn-1.7.2
       rm -v $out/share/doc/pysvn-1.7.2/generate_cpp_docs_from_html_docs.py
     '';
diff --git a/pkgs/top-level/release-small.nix b/pkgs/top-level/release-small.nix
new file mode 100644
index 0000000000000..f56f6cf357d75
--- /dev/null
+++ b/pkgs/top-level/release-small.nix
@@ -0,0 +1,224 @@
+/* A small release file, with few packages to be built.  The aim is to reduce
+   the load on Hydra when testing the `stdenv-updates' branch.
+
+
+   This file will be evaluated by hydra with a call like this:
+   hydra_eval_jobs --gc-roots-dir \
+     /nix/var/nix/gcroots/per-user/hydra/hydra-roots --argstr \
+     system i686-linux --argstr system x86_64-linux --arg \
+     nixpkgs "{outPath = ./}" .... release.nix
+
+   Hydra can be installed with "nix-env -i hydra".  */
+with (import ./release-lib.nix);
+
+{
+
+  tarball = import ./make-tarball.nix;
+
+} // (mapTestOn (rec {
+
+  aspell = all;
+  at = linux;
+  aterm25 = all;
+  aterm28 = all;
+  autoconf = all;
+  automake110x = all;
+  automake111x = all;
+  automake19x = all;
+  avahi = allBut "i686-cygwin";  # Cygwin builds fail
+  bash = all;
+  bashInteractive = all;
+  bc = all;
+  binutils = linux;
+  bind = linux;
+  bison24 = all;
+  boostFull = all;
+  bsdiff = all;
+  bzip2 = all;
+  classpath = linux;
+  cmake = all;
+  coreutils = all;
+  cpio = all;
+  cron = linux;
+  cups = linux;
+  dhcp = linux;
+  diffutils = all;
+  e2fsprogs = linux;
+  emacs23 = gtkSupported;
+  enscript = all;
+  file = all;
+  findutils = all;
+  flex = all;
+  flex2535 = all;
+  gcc = all;
+  gcc33 = linux;
+  gcc34 = linux;
+  gcc41 = linux;
+  gcc42 = linux;
+  gcc43_multi = ["x86_64-linux"];
+  gcc44 = linux;
+  gcj44 = linux;
+  ghdl = linux;
+  glibc = linux;
+  glibcLocales = linux;
+  gnat44 = linux;
+  gnugrep = all;
+  gnum4 = all;
+  gnumake = all;
+  gnupatch = all;
+  gnupg = linux;
+  gnuplot = allBut "i686-cygwin";
+  gnused = all;
+  gnutar = all;
+  gnutls = linux;
+  grub = linux;
+  grub2 = linux;
+  gsl = linux;
+  guile = linux;  # tests fail on Cygwin
+  gw6c = linux;
+  gzip = all;
+  hal = linux;
+  hal_info = linux;
+  hddtemp = linux;
+  hdparm = linux;
+  hello = all;
+  host = linux;
+  iana_etc = linux;
+  icecat3Xul = linux;
+  icewm = linux;
+  idutils = all;
+  ifplugd = linux;
+  inetutils = linux;
+  iputils = linux;
+  jnettop = linux;
+  jwhois = linux;
+  kbd = linux;
+  keen4 = ["i686-linux"];
+  kvm = linux;
+  qemu = linux;
+  qemu_kvm = linux;
+  less = all;
+  lftp = all;
+  libtool = all;
+  libtool_2 = all;
+  libxml2 = all;
+  libxslt = all;
+  lout = linux;
+  lsh = linux;
+  lsof = linux;
+  ltrace = linux;
+  lvm2 = linux;
+  lynx = linux;
+  lzma = linux;
+  man = linux;
+  manpages = linux;
+  mc = all;
+  mcabber = linux;
+  mcron = linux;
+  mdadm = linux;
+  mesa = mesaPlatforms;
+  midori = linux;
+  mingetty = linux;
+  mk = linux;
+  mktemp = all;
+  module_init_tools = linux;
+  mono = linux;
+  monotone = linux;
+  mpg321 = linux;
+  mutt = linux;
+  mysql = linux;
+  mysql51 = linux;
+  ncat = linux;
+  netcat = all;
+  nfsUtils = linux;
+  nix = all;
+  nixUnstable = all;
+  nixSqlite = all;
+  nss_ldap = linux;
+  nssmdns = linux;
+  ntfs3g = linux;
+  ntp = linux;
+  openssh = linux;
+  openssl = all;
+  pam_console = linux;
+  pam_login = linux;
+  pam_unix2 = linux;
+  pan = gtkSupported;
+  par2cmdline = all;
+  pciutils = linux;
+  pdf2xml = all;
+  perl = all;
+  pkgconfig = all;
+  pmccabe = linux;
+  policykit = linux;
+  portmap = linux;
+  procps = linux;
+  pwdutils = linux;
+  python = allBut "i686-cygwin";
+  pythonFull = linux;
+  readline = all;
+  rlwrap = all;
+  rpm = linux;
+  rsync = linux;
+  screen = linux ++ darwin;
+  scrot = linux;
+  sdparm = linux;
+  sharutils = all;
+  sloccount = allBut "i686-cygwin";
+  smartmontools = all;
+  splashutils = linux;
+  sqlite = allBut "i686-cygwin";
+  squid = linux;
+  ssmtp = linux;
+  stdenv = prio 175 all;
+  strace = linux;
+  su = linux;
+  sudo = linux;
+  sysklogd = linux;
+  syslinux = ["i686-linux"];
+  sysvinit = linux;
+  sysvtools = linux;
+  tcl = linux;
+  tcpdump = linux;
+  tetex = linux;
+  texLive = linux;
+  texLiveBeamer = linux;
+  texLiveExtra = linux;
+  texinfo = all;
+  time = linux;
+  tinycc = ["i686-linux"];
+  udev = linux;
+  uml = ["i686-linux"];
+  unrar = linux;
+  unzip = all;
+  upstart = linux;
+  usbutils = linux;
+  utillinux = linux;
+  utillinuxCurses = linux;
+  w3m = all;
+  webkit = linux;
+  wget = all;
+  which = all;
+  wicd = linux;
+  wireshark = linux;
+  wirelesstools = linux;
+  wpa_supplicant = linux;
+  xfsprogs = linux;
+  xkeyboard_config = linux;
+  zile = linux;
+  zip = all;
+
+  dbus_all = {
+    libs = linux;
+    tools = linux;
+  };
+
+  emacs23Packages = {
+    bbdb = linux;
+    cedet = linux;
+    ecb = linux;
+    emacsw3m = linux;
+    emms = linux;
+    nxml = all;
+  };
+} ))
diff --git a/pkgs/top-level/release.nix b/pkgs/top-level/release.nix
index 7e548a9b5c622..da127e617ad93 100644
--- a/pkgs/top-level/release.nix
+++ b/pkgs/top-level/release.nix
@@ -410,58 +410,6 @@ with (import ./release-lib.nix);
   };
   */
 
-  linuxPackages_2_6_25 = {
-    kernel = linux;
-  };
-
-  linuxPackages_2_6_27 = {
-    kernel = linux;
-    virtualbox = linux;
-    virtualboxGuestAdditions = linux;
-  };
-
-  linuxPackages_2_6_28 = {
-    kernel = linux;
-  };
-
-  linuxPackages_2_6_29 = {
-    kernel = linux;
-  };
-
-  linuxPackages_2_6_31 = {
-    kernel = linux;
-  };
-
-  linuxPackages_2_6_32 = {
-    kernel = linux;
-    virtualbox = linux;
-    virtualboxGuestAdditions = linux;
-  };
-
-  linuxPackages_2_6_35 = {
-    kernel = linux;
-    virtualbox = linux;
-    virtualboxGuestAdditions = linux;
-  };
-
-  linuxPackages_2_6_36 = {
-    kernel = linux;
-    virtualbox = linux;
-    virtualboxGuestAdditions = linux;
-  };
-
-  linuxPackages_2_6_37 = {
-    kernel = linux;
-    virtualbox = linux;
-    virtualboxGuestAdditions = linux;
-  };
-
-  linuxPackages_2_6_38 = {
-    kernel = linux;
-    virtualbox = linux;
-    virtualboxGuestAdditions = linux;
-  };
-
   strategoPackages = {
     sdf = all;
     strategoxt = all;