summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--doc/coding-conventions.xml434
-rw-r--r--doc/language-support.xml2
-rw-r--r--doc/quick-start.xml4
-rw-r--r--maintainers/docs/classification.txt116
-rw-r--r--pkgs/applications/editors/emacs-21/builder.sh12
-rw-r--r--pkgs/applications/editors/emacs-21/crt.patch41
-rw-r--r--pkgs/applications/editors/emacs-21/default.nix28
-rw-r--r--pkgs/applications/editors/emacs-22/builder.sh27
-rw-r--r--pkgs/applications/editors/emacs-22/default.nix48
-rw-r--r--pkgs/applications/misc/qgis/1.0.1-2.nix4
-rw-r--r--pkgs/applications/networking/instant-messengers/carrier/2.5.0.nix2
-rw-r--r--pkgs/applications/networking/instant-messengers/psi/default.nix (renamed from pkgs/applications/networking/instant-messengers/psi/0.12.1.nix)15
-rw-r--r--pkgs/applications/version-management/codeville/0.8.0.nix2
-rw-r--r--pkgs/applications/version-management/monotone-viz/mtn-head.nix2
-rw-r--r--pkgs/applications/version-management/viewmtn/0.10.nix2
-rw-r--r--pkgs/applications/virtualization/qemu/linux-img/0.2.nix4
-rw-r--r--pkgs/build-support/builder-defs/builder-defs.nix4
-rwxr-xr-xpkgs/build-support/fetchgit/nix-prefetch-git14
-rw-r--r--pkgs/build-support/fetchhg/builder.sh9
-rw-r--r--pkgs/build-support/fetchhg/default.nix3
-rw-r--r--pkgs/build-support/fetchurl/default.nix3
-rw-r--r--pkgs/build-support/fetchurl/mirrors.nix11
-rw-r--r--pkgs/build-support/release/source-tarball.nix56
-rw-r--r--pkgs/build-support/trivial-builders.nix71
-rw-r--r--pkgs/build-support/vm/default.nix13
-rw-r--r--pkgs/data/fonts/clearlyU/1.9.nix2
-rw-r--r--pkgs/data/fonts/junicode/0.6.15.nix2
-rw-r--r--pkgs/data/fonts/libertine/2.7.bin.nix2
-rw-r--r--pkgs/data/fonts/libertine/2.7.nix2
-rw-r--r--pkgs/data/fonts/lmodern/0.92.nix32
-rw-r--r--pkgs/data/fonts/lmodern/default.nix (renamed from pkgs/data/fonts/lmodern/1.010.nix)18
-rw-r--r--pkgs/data/fonts/wqy_zenhei/0.4.23-1.nix2
-rw-r--r--pkgs/development/compilers/go/cgo-set-local-to-match-gcc-error-messages.patch13
-rw-r--r--pkgs/development/compilers/go/default.nix76
-rw-r--r--pkgs/development/compilers/go/disable-system-dependent-tests.patch30
-rw-r--r--pkgs/development/compilers/ikarus/0.0.3.nix21
-rw-r--r--pkgs/development/compilers/ikarus/default.nix18
-rw-r--r--pkgs/development/compilers/qi/9.1.nix2
-rw-r--r--pkgs/development/compilers/strategoxt/0.18.nix6
-rw-r--r--pkgs/development/compilers/swi-prolog/5.6.51.nix4
-rw-r--r--pkgs/development/compilers/swi-prolog/default.nix10
-rw-r--r--pkgs/development/interpreters/guile/1.9.nix10
-rw-r--r--pkgs/development/interpreters/guile/gcov-file-name.patch42
-rw-r--r--pkgs/development/libraries/enchant/default.nix (renamed from pkgs/development/libraries/enchant/1.3.0.nix)6
-rw-r--r--pkgs/development/libraries/libdbi-drivers/0.8.2-1.nix2
-rw-r--r--pkgs/development/libraries/libdbi/0.8.2.nix2
-rw-r--r--pkgs/development/libraries/libextractor/0.5.18.nix2
-rw-r--r--pkgs/development/libraries/libjingle/0.3.11.nix14
-rw-r--r--pkgs/development/libraries/mediastreamer/2.2.0-cvs20080207.nix5
-rw-r--r--pkgs/development/libraries/msilbc/default.nix (renamed from pkgs/development/libraries/msilbc/2.0.0.nix)15
-rw-r--r--pkgs/development/libraries/redland/1.0.8.nix7
-rw-r--r--pkgs/development/libraries/redland/1.0.9.nix25
-rw-r--r--pkgs/development/libraries/tk/8.4.16.nix18
-rw-r--r--pkgs/development/libraries/tk/8.4.18.nix18
-rw-r--r--pkgs/development/libraries/tk/8.5.7.nix13
-rw-r--r--pkgs/development/libraries/xapian/bindings/1.0.14.nix2
-rw-r--r--pkgs/development/libraries/xapian/default.nix (renamed from pkgs/development/libraries/xapian/1.0.14.nix)11
-rw-r--r--pkgs/development/python-modules/flup/default.nix16
-rw-r--r--pkgs/development/python-modules/flup/r2311.nix18
-rw-r--r--pkgs/development/python-modules/pyqt/4.3.3.nix5
-rw-r--r--pkgs/development/python-modules/python-sip/4.7.4.nix2
-rw-r--r--pkgs/development/tools/misc/xxdiff/3.2.nix2
-rw-r--r--pkgs/games/construo/0.2.2.nix2
-rw-r--r--pkgs/games/fsg/alt-builder.nix2
-rw-r--r--pkgs/games/fsg/default.nix2
-rw-r--r--pkgs/games/jamp/default.nix33
-rw-r--r--pkgs/games/jamp/src-for-default.nix9
-rw-r--r--pkgs/games/jamp/src-info-for-default.nix4
-rw-r--r--pkgs/games/orbit/1.01.nix2
-rw-r--r--pkgs/lib/attrsets.nix4
-rw-r--r--pkgs/lib/customisation.nix61
-rw-r--r--pkgs/lib/debug.nix7
-rw-r--r--pkgs/lib/default.nix2
-rw-r--r--pkgs/lib/maintainers.nix1
-rw-r--r--pkgs/lib/misc.nix31
-rw-r--r--pkgs/os-specific/linux/atheros/0.9.4.nix2
-rw-r--r--pkgs/os-specific/linux/jfsrec/default.nix22
-rw-r--r--pkgs/os-specific/linux/jfsrec/svn-7.nix23
-rw-r--r--pkgs/os-specific/linux/kqemu/1.4.0pre1.nix39
-rw-r--r--pkgs/servers/dict/1.9.15.nix2
-rw-r--r--pkgs/servers/dns/bind/9.5.0.nix2
-rw-r--r--pkgs/servers/gpm/1.20.6.nix22
-rw-r--r--pkgs/servers/gpm/default.nix22
-rw-r--r--pkgs/servers/http/tomcat/axis2/default.nix6
-rw-r--r--pkgs/servers/x11/xorg/overrides.nix2
-rw-r--r--pkgs/servers/xmpp/ejabberd/default.nix16
-rw-r--r--pkgs/shells/zsh/4.3.4.nix13
-rw-r--r--pkgs/shells/zsh/4.3.5.nix22
-rw-r--r--pkgs/shells/zsh/cvs.nix19
-rw-r--r--pkgs/shells/zsh/default.nix (renamed from pkgs/shells/zsh/4.3.9.nix)12
-rw-r--r--pkgs/stdenv/adapters.nix16
-rw-r--r--pkgs/stdenv/mingw/default.nix11
-rwxr-xr-xpkgs/stdenv/mingw/pkgs/default.nix20
-rwxr-xr-xpkgs/stdenv/mingw/setup.sh763
-rw-r--r--pkgs/tools/X11/x11vnc/0.9.3.nix2
-rw-r--r--pkgs/tools/X11/x2vnc/1.7.2.nix2
-rw-r--r--pkgs/tools/archivers/sharutils/4.6.3.nix7
-rw-r--r--pkgs/tools/misc/mdbtools/default.nix (renamed from pkgs/tools/misc/mdbtools/0.6-pre1.nix)16
-rw-r--r--pkgs/tools/misc/minicom/2.3.nix18
-rw-r--r--pkgs/tools/misc/minicom/default.nix18
-rw-r--r--pkgs/tools/misc/relfs/cvs.2008.03.05.nix2
-rw-r--r--pkgs/tools/misc/rlwrap/0.28.nix2
-rw-r--r--pkgs/tools/misc/uucp/default.nix (renamed from pkgs/tools/misc/uucp/1.07.nix)14
-rw-r--r--pkgs/tools/networking/nc6/1.0.nix2
-rw-r--r--pkgs/tools/networking/smbfs-fuse/0.8.7.nix2
-rw-r--r--pkgs/tools/networking/socat/1.6.0.1.nix25
-rw-r--r--pkgs/tools/networking/socat/default.nix17
-rw-r--r--pkgs/tools/security/metasploit/3.1.nix2
-rw-r--r--pkgs/tools/security/ssss/0.5.nix2
-rw-r--r--pkgs/tools/system/ddrescue/1.8.nix20
-rw-r--r--pkgs/tools/system/ddrescue/default.nix15
-rw-r--r--pkgs/tools/system/gdmap/0.8.1.nix2
-rw-r--r--pkgs/tools/text/cheetah-template/2.0.1.nix2
-rw-r--r--pkgs/tools/text/highlight/2.6.10.nix20
-rw-r--r--pkgs/tools/text/highlight/default.nix18
-rw-r--r--pkgs/top-level/all-packages.nix402
-rw-r--r--pkgs/top-level/make-tarball.nix2
-rw-r--r--pkgs/top-level/perl-packages.nix8
-rw-r--r--pkgs/top-level/release.nix6
119 files changed, 1736 insertions, 1486 deletions
diff --git a/doc/coding-conventions.xml b/doc/coding-conventions.xml
index 3e4afdc1d4f5..e55f86ae3d31 100644
--- a/doc/coding-conventions.xml
+++ b/doc/coding-conventions.xml
@@ -156,12 +156,131 @@ stdenv.mkDerivation { ...
 
   </para></listitem>
 
+  <listitem><para>Functions should list their expected arguments as
+  precisely as possible.  That is, write
+
+<programlisting>
+{ stdenv, fetchurl, perl }: <replaceable>...</replaceable>
+</programlisting>
+
+  instead of
+
+<programlisting>
+args: with args; <replaceable>...</replaceable>
+</programlisting>
+
+  or 
+  
+<programlisting>
+{ stdenv, fetchurl, perl, ... }: <replaceable>...</replaceable>
+</programlisting>
+
+  </para>
+
+  <para>For functions that are truly generic in the number of
+  arguments (such as wrappers around <varname>mkDerivation</varname>)
+  that have some required arguments, you should write them using an
+  <literal>@</literal>-pattern:
+
+<programlisting>
+{ stdenv, doCoverageAnalysis ? false, ... } @ args:
+
+stdenv.mkDerivation (args // {
+  <replaceable>...</replaceable> if doCoverageAnalysis then "bla" else "" <replaceable>...</replaceable>
+})
+</programlisting>
+
+  instead of
+
+<programlisting>
+args:
+
+args.stdenv.mkDerivation (args // {
+  <replaceable>...</replaceable> if args ? doCoverageAnalysis &amp;&amp; args.doCoverageAnalysis then "bla" else "" <replaceable>...</replaceable>
+})
+</programlisting>
+
+  </para></listitem>
+
 </itemizedlist>
 
 </section>
 
 
-<section><title>File naming and organisation</title>
+<section><title>Package naming</title>
+
+<para>In Nixpkgs, there are generally three different names associated with a package:
+
+<itemizedlist>
+
+  <listitem><para>The <varname>name</varname> attribute of the
+  derivation (excluding the version part).  This is what most users
+  see, in particular when using
+  <command>nix-env</command>.</para></listitem>
+
+  <listitem><para>The variable name used for the instantiated package
+  in <filename>all-packages.nix</filename>, and when passing it as a
+  dependency to other functions.  This is what Nix expression authors
+  see.  It can also be used when installing using <command>nix-env
+  -iA</command>.</para></listitem>
+
+  <listitem><para>The filename for (the directory containing) the Nix
+  expression.</para></listitem>
+
+</itemizedlist>
+
+Most of the time, these are the same.  For instance, the package
+<literal>e2fsprogs</literal> has a <varname>name</varname> attribute
+<literal>"e2fsprogs-<replaceable>version</replaceable>"</literal>, is
+bound to the variable name <varname>e2fsprogs</varname> in
+<filename>all-packages.nix</filename>, and the Nix expression is in
+<filename>pkgs/os-specific/linux/e2fsprogs/default.nix</filename>.
+However, identifiers in the Nix language don’t allow certain
+characters (e.g. dashes), so sometimes a different variable name
+should be used.  For instance, the
+<literal>module-init-tools</literal> package is bound to the
+<literal>module_init_tools</literal> variable in
+<filename>all-packages.nix</filename>.</para>
+
+<para>There are a few naming guidelines:
+
+<itemizedlist>
+
+  <listitem><para>Generally, try to stick to the upstream package
+  name.</para></listitem>
+
+  <listitem><para>Don’t use uppercase letters in the
+  <literal>name</literal> attribute — e.g.,
+  <literal>"mplayer-1.0rc2"</literal> instead of
+  <literal>"MPlayer-1.0rc2"</literal>.</para></listitem>
+
+  <listitem><para>The version part of the <literal>name</literal>
+  attribute <emphasis>must</emphasis> start with a digit (following a
+  dash) — e.g., <literal>"hello-0.3-pre-r3910"</literal> instead of
+  <literal>"hello-svn-r3910"</literal>, as the latter would be seen as
+  a package named <literal>hello-svn</literal> by
+  <command>nix-env</command>.</para></listitem>
+
+  <listitem><para>Dashes in the package name should be changed to
+  underscores in variable names, rather than to camel case — e.g.,
+  <varname>module_init_tools</varname> instead of
+  <varname>moduleInitTools</varname>.</para></listitem>
+
+  <listitem><para>If there are multiple versions of a package, this
+  should be reflected in the variable names in
+  <filename>all-packages.nix</filename>,
+  e.g. <varname>hello_0_3</varname> and <varname>hello_0_4</varname>.
+  If there is an obvious “default” version, make an attribute like
+  <literal>hello = hello_0_4;</literal>.</para></listitem>
+
+</itemizedlist>
+
+</para>
+
+</section>
+
+
+<section xml:id="sec-organisation"><title>File naming and organisation</title>
 
 <para>Names of files and directories should be in lowercase, with
 dashes between words — not in camel case.  For instance, it should be
@@ -169,7 +288,318 @@ dashes between words — not in camel case.  For instance, it should be
 <filename>allPackages.nix</filename> or
 <filename>AllPackages.nix</filename>.</para>
 
+<section><title>Hierachy</title>
+
+<para>Each package should be stored in its own directory somewhere in
+the <filename>pkgs/</filename> tree, i.e. in
+<filename>pkgs/<replaceable>category</replaceable>/<replaceable>subcategory</replaceable>/<replaceable>...</replaceable>/<replaceable>pkgname</replaceable></filename>.
+Below are some rules for picking the right category for a package.
+Many packages fall under several categories; what matters is the
+<emphasis>primary</emphasis> purpose of a package.  For example, the
+<literal>libxml2</literal> package builds both a library and some
+tools; but it’s a library foremost, so it goes under
+<filename>pkgs/development/libraries</filename>.</para>
+
+<para>When in doubt, consider refactoring the
+<filename>pkgs/</filename> tree, e.g. creating new categories or
+splitting up an existing category.</para>
+
+<variablelist>
+  <varlistentry>
+    <term>If it’s used to support <emphasis>software development</emphasis>:</term>
+    <listitem>
+      <variablelist>
+        <varlistentry>
+          <term>If it’s a <emphasis>library</emphasis> used by other packages:</term>
+          <listitem>
+            <para><filename>development/libraries</filename> (e.g. <filename>libxml2</filename>)</para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>If it’s a <emphasis>compiler</emphasis>:</term>
+          <listitem>
+            <para><filename>development/compilers</filename> (e.g. <filename>gcc</filename>)</para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>If it’s an <emphasis>interpreter</emphasis>:</term>
+          <listitem>
+            <para><filename>development/interpreters</filename> (e.g. <filename>guile</filename>)</para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>If it’s a (set of) development <emphasis>tool(s)</emphasis>:</term>
+          <listitem>
+            <variablelist>
+              <varlistentry>
+                <term>If it’s a <emphasis>parser generator</emphasis> (including lexers):</term>
+                <listitem>
+                  <para><filename>development/tools/parsing</filename> (e.g. <filename>bison</filename>, <filename>flex</filename>)</para>
+                </listitem>
+              </varlistentry>
+              <varlistentry>
+                <term>If it’s a <emphasis>build manager</emphasis>:</term>
+                <listitem>
+                  <para><filename>development/tools/build-managers</filename> (e.g. <filename>gnumake</filename>)</para>
+                </listitem>
+              </varlistentry>
+              <varlistentry>
+                <term>Else:</term>
+                <listitem>
+                  <para><filename>development/tools/misc</filename> (e.g. <filename>binutils</filename>)</para>
+                </listitem>
+              </varlistentry>
+            </variablelist>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>Else:</term>
+          <listitem>
+            <para><filename>development/misc</filename></para>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+    </listitem>
+  </varlistentry>
+  <varlistentry>
+    <term>If it’s a (set of) <emphasis>tool(s)</emphasis>:</term>
+    <listitem>
+      <para>(A tool is a relatively small program, especially one intented
+      to be used non-interactively.)</para>
+      <variablelist>
+        <varlistentry>
+          <term>If it’s for <emphasis>networking</emphasis>:</term>
+          <listitem>
+            <para><filename>tools/networking</filename> (e.g. <filename>wget</filename>)</para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>If it’s for <emphasis>text processing</emphasis>:</term>
+          <listitem>
+            <para><filename>tools/text</filename> (e.g. <filename>diffutils</filename>)</para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>If it’s a <emphasis>system utility</emphasis>, i.e.,
+          something related or essential to the operation of a
+          system:</term>
+          <listitem>
+            <para><filename>tools/system</filename> (e.g. <filename>cron</filename>)</para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>If it’s an <emphasis>archiver</emphasis> (which may
+          include a compression function):</term>
+          <listitem>
+            <para><filename>tools/archivers</filename> (e.g. <filename>zip</filename>, <filename>tar</filename>)</para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>If it’s a <emphasis>compression</emphasis> program:</term>
+          <listitem>
+            <para><filename>tools/compression</filename> (e.g. <filename>gzip</filename>, <filename>bzip2</filename>)</para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>If it’s a <emphasis>security</emphasis>-related program:</term>
+          <listitem>
+            <para><filename>tools/security</filename> (e.g. <filename>nmap</filename>, <filename>gnupg</filename>)</para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>Else:</term>
+          <listitem>
+            <para><filename>tools/misc</filename></para>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+    </listitem>
+  </varlistentry>
+  <varlistentry>
+    <term>If it’s a <emphasis>shell</emphasis>:</term>
+    <listitem>
+      <para><filename>shells</filename> (e.g. <filename>bash</filename>)</para>
+    </listitem>
+  </varlistentry>
+  <varlistentry>
+    <term>If it’s a <emphasis>server</emphasis>:</term>
+    <listitem>
+      <variablelist>
+        <varlistentry>
+          <term>If it’s a web server:</term>
+          <listitem>
+            <para><filename>servers/http</filename> (e.g. <filename>apache-httpd</filename>)</para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>If it’s an implementation of the X Windowing System:</term>
+          <listitem>
+            <para><filename>servers/x11</filename> (e.g. <filename>xorg</filename> — this includes the client libraries and programs)</para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>Else:</term>
+          <listitem>
+            <para><filename>servers/misc</filename></para>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+    </listitem>
+  </varlistentry>
+  <varlistentry>
+    <term>If it’s a <emphasis>desktop environment</emphasis>
+    (including <emphasis>window managers</emphasis>):</term>
+    <listitem>
+      <para><filename>desktops</filename> (e.g. <filename>kde</filename>, <filename>gnome</filename>, <filename>enlightenment</filename>)</para>
+    </listitem>
+  </varlistentry>
+  <varlistentry>
+    <term>If it’s an <emphasis>application</emphasis>:</term>
+    <listitem>
+      <para>A (typically large) program with a distinct user
+      interface, primarily used interactively.</para>
+      <variablelist>
+        <varlistentry>
+          <term>If it’s a <emphasis>version management system</emphasis>:</term>
+          <listitem>
+            <para><filename>applications/version-management</filename> (e.g. <filename>subversion</filename>)</para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>If it’s for <emphasis>video playback / editing</emphasis>:</term>
+          <listitem>
+            <para><filename>applications/video</filename> (e.g. <filename>vlc</filename>)</para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>If it’s for <emphasis>graphics viewing / editing</emphasis>:</term>
+          <listitem>
+            <para><filename>applications/graphics</filename> (e.g. <filename>gimp</filename>)</para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>If it’s for <emphasis>networking</emphasis>:</term>
+          <listitem>
+            <variablelist>
+              <varlistentry>
+                <term>If it’s a <emphasis>mailreader</emphasis>:</term>
+                <listitem>
+                  <para><filename>applications/networking/mailreaders</filename> (e.g. <filename>thunderbird</filename>)</para>
+                </listitem>
+              </varlistentry>
+              <varlistentry>
+                <term>If it’s a <emphasis>newsreader</emphasis>:</term>
+                <listitem>
+                  <para><filename>applications/networking/newsreaders</filename> (e.g. <filename>pan</filename>)</para>
+                </listitem>
+              </varlistentry>
+              <varlistentry>
+                <term>If it’s a <emphasis>web browser</emphasis>:</term>
+                <listitem>
+                  <para><filename>applications/networking/browsers</filename> (e.g. <filename>firefox</filename>)</para>
+                </listitem>
+              </varlistentry>
+              <varlistentry>
+                <term>Else:</term>
+                <listitem>
+                  <para><filename>applications/networking/misc</filename></para>
+                </listitem>
+              </varlistentry>
+            </variablelist>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>Else:</term>
+          <listitem>
+            <para><filename>applications/misc</filename></para>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+    </listitem>
+  </varlistentry>
+  <varlistentry>
+    <term>If it’s <emphasis>data</emphasis> (i.e., does not have a
+    straight-forward executable semantics):</term>
+    <listitem>
+      <variablelist>
+        <varlistentry>
+          <term>If it’s a <emphasis>font</emphasis>:</term>
+          <listitem>
+            <para><filename>data/fonts</filename></para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>If it’s related to <emphasis>SGML/XML processing</emphasis>:</term>
+          <listitem>
+            <variablelist>
+              <varlistentry>
+                <term>If it’s an <emphasis>XML DTD</emphasis>:</term>
+                <listitem>
+                  <para><filename>data/sgml+xml/schemas/xml-dtd</filename> (e.g. <filename>docbook</filename>)</para>
+                </listitem>
+              </varlistentry>
+              <varlistentry>
+                <term>If it’s an <emphasis>XSLT stylesheet</emphasis>:</term>
+                <listitem>
+                  <para>(Okay, these are executable...)</para>
+                  <para><filename>data/sgml+xml/stylesheets/xslt</filename> (e.g. <filename>docbook-xsl</filename>)</para>
+                </listitem>
+              </varlistentry>
+            </variablelist>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+    </listitem>
+  </varlistentry>
+  <varlistentry>
+    <term>If it’s a <emphasis>game</emphasis>:</term>
+    <listitem>
+      <para><filename>games</filename></para>
+    </listitem>
+  </varlistentry>
+  <varlistentry>
+    <term>Else:</term>
+    <listitem>
+      <para><filename>misc</filename></para>
+    </listitem>
+  </varlistentry>
+</variablelist>
+
+</section>
+
+<section><title>Versioning</title>
+
+<para>Because every version of a package in Nixpkgs creates a
+potential maintenance burden, old versions of a package should not be
+kept unless there is a good reason to do so.  For instance, Nixpkgs
+contains several versions of GCC because other packages don’t build
+with the latest version of GCC.  Other examples are having both the
+latest stable and latest pre-release version of a package, or to keep
+several major releases of an application that differ significantly in
+functionality.</para>
+
+<para>If there is only one version of a package, its Nix expression
+should be named <filename>e2fsprogs/default.nix</filename>.  If there
+are multiple versions, this should be reflected in the filename,
+e.g. <filename>e2fsprogs/1.41.8.nix</filename> and
+<filename>e2fsprogs/1.41.9.nix</filename>.  The version in the
+filename should leave out unnecessary detail.  For instance, if we
+keep the latest Firefox 2.0.x and 3.5.x versions in Nixpkgs, they
+should be named <filename>firefox/2.0.nix</filename> and
+<filename>firefox/3.5.nix</filename>, respectively (which, at a given
+point, might contain versions <literal>2.0.0.20</literal> and
+<literal>3.5.4</literal>).  If a version requires many auxiliary
+files, you can use a subdirectory for each version,
+e.g. <filename>firefox/2.0/default.nix</filename> and
+<filename>firefox/3.5/default.nix</filename>.</para>
+
+<para>All versions of a package <emphasis>must</emphasis> be included
+in <filename>all-packages.nix</filename> to make sure that they
+evaluate correctly.</para>
+
+</section>
+
 </section>
 
 
-</chapter>
\ No newline at end of file
+</chapter>
diff --git a/doc/language-support.xml b/doc/language-support.xml
index 364b002ea16d..806eab62ebe7 100644
--- a/doc/language-support.xml
+++ b/doc/language-support.xml
@@ -1,6 +1,6 @@
 <chapter xmlns="http://docbook.org/ns/docbook"
          xmlns:xlink="http://www.w3.org/1999/xlink"
-         xml:id="chap-meta">
+         xml:id="chap-language-support">
 
 <title>Support for specific programming languages</title>
 
diff --git a/doc/quick-start.xml b/doc/quick-start.xml
index 6f49bee4b64e..9cacb1fcccf1 100644
--- a/doc/quick-start.xml
+++ b/doc/quick-start.xml
@@ -25,8 +25,8 @@ $ cd nixpkgs</screen>
     <filename>pkgs/development/libraries/<replaceable>pkgname</replaceable></filename>,
     while a web browser goes into
     <filename>pkgs/applications/networking/browsers/<replaceable>pkgname</replaceable></filename>.
-    See Section XXX for some hints on the tree organisation.  Create a
-    directory for your package, e.g.
+    See <xref linkend="sec-organisation" /> for some hints on the tree
+    organisation.  Create a directory for your package, e.g.
 
 <screen>
 $ svn mkdir pkgs/development/libraries/libfoo</screen>
diff --git a/maintainers/docs/classification.txt b/maintainers/docs/classification.txt
deleted file mode 100644
index a4de2ecdb50a..000000000000
--- a/maintainers/docs/classification.txt
+++ /dev/null
@@ -1,116 +0,0 @@
-* Classification scheme for packages
-
-- many packages fall under several categories; what matters is the
-  *primary* purpose of a package.  For example, the libxml2 package
-  builds both a library and some tools; but it's a library foremost,
-  so it goes under ./development/libraries. 
-
-- when in doubt, refactor.
-
-IF it's used to support SOFTWARE DEVELOPMENT:
-
-  IF it's a LIBRARY used by other packages:
-    IF it's directly related to GTK:
-      ./development/libraries/gtk+
-    ELSE
-      ./development/libraries
-      (e.g., libxml2)
-  ELSE IF it's a COMPILER:
-    ./development/compilers
-    (e.g., gcc)
-  ELSE IF it's an INTERPRETER:
-    ./development/interpreters
-  ELSE IF it's a development TOOL (or set of):
-    IF it's a PARSER GENERATOR (incl. lexers):
-      ./development/tools/parsing
-      (e.g., bison, flex)
-    ELSE IF it's a BUILD MANAGER:
-      ./development/tools/build-managers
-      (e.g., gnumake
-    ELSE
-      ./development/tools/misc
-      (e.g., binutils)
-  ELSE
-    ./development/misc
-
-ELSE IF it's a TOOL (or set of):
-  # a tool is a relatively *small* program, esp. one intented to be
-  # used non-interactively
-
-  IF it's for NETWORKING:
-    ./tools/networking
-    (e.g., wget)
-  ELSE IF it's for TEXT PROCESSING:
-    ./tools/text
-    (e.g., diffutils)
-  ELSE IF it's a SYSTEM utility, i.e., something related or essential
-    to the operation of a system:
-    ./tools/system
-    (e.g., init)
-  ELSE IF it's an ARCHIVER (which may include a compression function):
-    ./tools/archivers
-    (e.g., zip, tar)
-  ELSE IF it's a COMPRESSION program:
-    ./tools/compression
-    (e.g., gzip, bzip2)
-  ELSE IF it's a SECURITY program:
-    ./tools/security
-    (e.g., nmap, gnupg)
-  ELSE
-    ./tools/misc
-
-ELSE IF it's a SHELL:
-
-  ./shells
-
-ELSE IF it's a SERVER:
-
-  IF it's a HTTP server:
-    ./servers/http
-    (e.g., apache)
-  IF it's a X11 server:
-    ./servers/x11
-    (e.g., xfree86)
-  ELSE
-    ./servers/misc
-
-ELSE IF it's a DESKTOP ENVIRONMENT (incl. WINDOW MANAGERS):
-
-  ./desktops
-  (e.g., kde, gnome, fvwm)
-
-ELSE IF it's an APPLICATION:
-  # a (typically large) program with a distinct user interface,
-  # primarily used interactively
-
-  IF it's a VERSION MANAGEMENT system:
-    ./applications/version-management
-  ELSE IF it's for VIDEO playback/etc:
-    ./applications/video
-  ELSE IF it's for GRAPHICS viewing/editing/etc:
-    ./applications/graphics
-  ELSE IF it's for NETWORKING:
-    IF it's a MAILREADER:
-      ./applications/networking/mailreaders
-    IF it's a NEWSREADER:
-      ./applications/networking/newsreaders
-    ELSE
-      ./applications/networking/misc
-  ELSE
-    ./applications/misc
-
-ELSE IF it's DATA (i.e., does not have a straight-forward executable semantics):
-
-  IF it's related to SGML/XML processing:
-    IF it's a XML DTD:
-      ./data/sgml+xml/schemas/xml-dtd
-    ELSE IF it's an XSLT stylesheet (okay, these are executable...):
-      ./data/sgml+xml/stylesheets/xslt
-
-ELSE IF it's a GAME:
-
-  ./games
-
-ELSE:
-
-  ./misc
diff --git a/pkgs/applications/editors/emacs-21/builder.sh b/pkgs/applications/editors/emacs-21/builder.sh
deleted file mode 100644
index acd98aefd048..000000000000
--- a/pkgs/applications/editors/emacs-21/builder.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-source $stdenv/setup
-
-myglibc=`cat ${NIX_GCC}/nix-support/orig-libc`
-echo "glibc: $myglibc" 
-
-postConfigure() {
-  cp $myglibc/lib/crt1.o src
-  cp $myglibc/lib/crti.o src
-  cp $myglibc/lib/crtn.o src
-}
-
-genericBuild
diff --git a/pkgs/applications/editors/emacs-21/crt.patch b/pkgs/applications/editors/emacs-21/crt.patch
deleted file mode 100644
index 93f17643a1af..000000000000
--- a/pkgs/applications/editors/emacs-21/crt.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-Only in emacs-21.3: configure.in~
-Only in emacs-21.3: patchfile
-Only in emacs-21.3/src: Makefile.in~
-diff -rc emacs-orig/src/s/gnu-linux.h emacs-21.3/src/s/gnu-linux.h
-*** emacs-orig/src/s/gnu-linux.h	2001-09-28 17:50:04.000000000 +0200
---- emacs-21.3/src/s/gnu-linux.h	2004-10-06 13:13:19.000000000 +0200
-***************
-*** 173,179 ****
-  /* GNU/Linux usually has crt0.o in a non-standard place */
-  #define START_FILES pre-crt0.o /usr/lib/crt0.o
-  #else
-! #define START_FILES pre-crt0.o /usr/lib/crt1.o /usr/lib/crti.o
-  #endif
-  
-  #ifdef __ELF__
---- 173,179 ----
-  /* GNU/Linux usually has crt0.o in a non-standard place */
-  #define START_FILES pre-crt0.o /usr/lib/crt0.o
-  #else
-! #define START_FILES pre-crt0.o crt1.o crti.o
-  #endif
-  
-  #ifdef __ELF__
-***************
-*** 225,231 ****
-  #else
-  #undef LIB_GCC
-  #define LIB_GCC
-! #define LIB_STANDARD -lgcc -lc -lgcc /usr/lib/crtn.o
-  #endif
-  
-  /* Don't use -g in test compiles in configure.
---- 225,231 ----
-  #else
-  #undef LIB_GCC
-  #define LIB_GCC
-! #define LIB_STANDARD -lgcc -lc -lgcc crtn.o
-  #endif
-  
-  /* Don't use -g in test compiles in configure.
-Only in emacs-21.3/src/s: gnu-linux.h~
diff --git a/pkgs/applications/editors/emacs-21/default.nix b/pkgs/applications/editors/emacs-21/default.nix
deleted file mode 100644
index 9fc16594e26f..000000000000
--- a/pkgs/applications/editors/emacs-21/default.nix
+++ /dev/null
@@ -1,28 +0,0 @@
-{ xawSupport ? true
-, xpmSupport ? true
-, xaw3dSupport ? false
-, stdenv, fetchurl, ncurses, x11, libXaw ? null, libXpm ? null, Xaw3d ? null
-}:
-
-assert xawSupport && !xaw3dSupport -> libXaw != null;
-assert xawSupport && xaw3dSupport -> Xaw3d != null;
-assert xpmSupport -> libXpm != null;
-
-stdenv.mkDerivation {
-  name = "emacs-21.4a";
-  builder = ./builder.sh;
-  src = fetchurl {
-    url = http://nixos.org/tarballs/emacs-21.4a.tar.gz;
-    md5 = "8f9d97cbd126121bd5d97e5e31168a87";
-  };
-  patches = [./crt.patch];
-  buildInputs = [
-    ncurses x11
-    (if xawSupport then if xaw3dSupport then Xaw3d else libXaw else null)
-    (if xpmSupport then libXpm else null)
-  ];
-
-  meta = {
-    description = "All Hail Emacs, the ultimate editor";
-  };
-}
diff --git a/pkgs/applications/editors/emacs-22/builder.sh b/pkgs/applications/editors/emacs-22/builder.sh
deleted file mode 100644
index 7a82f6552efc..000000000000
--- a/pkgs/applications/editors/emacs-22/builder.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-source $stdenv/setup
-
-preConfigure() {
-    libc=$(cat ${NIX_GCC}/nix-support/orig-libc)
-    echo "libc: $libc"
-
-    case "${system}" in
-	x86_64-*)	glibclibdir=lib64 ;;
-	*)		glibclibdir=lib ;;
-    esac
-
-    for i in src/s/*.h src/m/*.h; do
-        substituteInPlace $i \
-            --replace /usr/${glibclibdir}/crt1.o $libc/${glibclibdir}/crt1.o \
-            --replace /usr/${glibclibdir}/crti.o $libc/${glibclibdir}/crti.o \
-            --replace /usr/${glibclibdir}/crtn.o $libc/${glibclibdir}/crtn.o \
-            --replace /usr/lib/crt1.o $libc/${glibclibdir}/crt1.o \
-            --replace /usr/lib/crti.o $libc/${glibclibdir}/crti.o \
-            --replace /usr/lib/crtn.o $libc/${glibclibdir}/crtn.o
-    done
-
-    for i in Makefile.in ./src/Makefile.in ./lib-src/Makefile.in ./leim/Makefile.in; do
-        substituteInPlace $i --replace /bin/pwd pwd
-    done
-}
-
-genericBuild
diff --git a/pkgs/applications/editors/emacs-22/default.nix b/pkgs/applications/editors/emacs-22/default.nix
deleted file mode 100644
index da3c4babbf6b..000000000000
--- a/pkgs/applications/editors/emacs-22/default.nix
+++ /dev/null
@@ -1,48 +0,0 @@
-{ xawSupport ? true
-, xpmSupport ? true
-, xaw3dSupport ? false
-, gtkGUI ? false
-, stdenv, fetchurl, x11, libXaw ? null, libXpm ? null, Xaw3d ? null
-, pkgconfig ? null, gtk ? null
-, ncurses
-}:
-
-assert xawSupport && !xaw3dSupport -> libXaw != null;
-assert xawSupport && xaw3dSupport -> Xaw3d != null;
-assert xpmSupport -> libXpm != null;
-assert gtkGUI -> pkgconfig != null && gtk != null;
-
-stdenv.mkDerivation rec {
-  name = "emacs-22.3";
-
-  builder = ./builder.sh;
-  
-  src = fetchurl {
-    url = "mirror://gnu/emacs/${name}.tar.gz";
-    sha256 = "05hd89bchcpwzcx5la0alcp0wb7xywvnf98dxrshrqlfvccvgnbv";
-  };
-  
-  buildInputs = [ncurses x11]
-    ++ stdenv.lib.optional xawSupport (if xaw3dSupport then Xaw3d else libXaw)
-    ++ stdenv.lib.optional xpmSupport libXpm
-    ++ stdenv.lib.optionals gtkGUI [pkgconfig gtk];
-  
-  configureFlags =
-    stdenv.lib.optional gtkGUI "--with-x-toolkit=gtk";
-
-  meta = {
-    description = "GNU Emacs, *the* text editor";
-
-    longDescription = ''
-      GNU Emacs is an extensible, customizable text editor—and more.
-      At its core is an interpreter for Emacs Lisp, a dialect of the
-      Lisp programming language with extensions to support text
-      editing.
-    '';
-
-    homepage = http://www.gnu.org/software/emacs/;
-    license = "GPLv3+";
-
-    platforms = stdenv.lib.platforms.linux;  # GTK & co. are needed.
-  };
-}
diff --git a/pkgs/applications/misc/qgis/1.0.1-2.nix b/pkgs/applications/misc/qgis/1.0.1-2.nix
index 142e3b65013c..af28a381fba0 100644
--- a/pkgs/applications/misc/qgis/1.0.1-2.nix
+++ b/pkgs/applications/misc/qgis/1.0.1-2.nix
@@ -12,12 +12,12 @@ composableDerivation.composableDerivation {} {
                   "-DWITH_INTERNAL_SQLITE3=TRUE"
                 ];
 
-  name = "qgis-${version}";
+  name = "qgis-1.0.1-2";
 
   # src = args.fetchsvn { url=https://svn.qgis.org/repos/qgis/trunk/qgis;
   #                md5="ac0560e0a2d4e6258c8639f1e9b56df3"; rev="7704"; };
   src = fetchurl {
-    url = "http://download.osgeo.org/qgis/src/qgis_${version}.tar.gz";
+    url = "http://download.osgeo.org/qgis/src/qgis_1.0.1-2.tar.gz";
     sha256 = "07yyic9sn1pz20wjk7k560jwqz6b19rhf2gawybz38xq1f8rjwd4";
   };
 
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 257d3d09f71b..0428ccdc7f32 100644
--- a/pkgs/applications/networking/instant-messengers/carrier/2.5.0.nix
+++ b/pkgs/applications/networking/instant-messengers/carrier/2.5.0.nix
@@ -39,7 +39,7 @@ rec {
     ++ (lib.optional externalPurple2 "postInstall")
   ;
       
-  name = "carrier-" + version;
+  name = "carrier-2.5.0";
   meta = {
     description = "Carrier - PidginIM GUI fork with user-friendly development model";
     homepage = http://funpidgin.sf.net; 
diff --git a/pkgs/applications/networking/instant-messengers/psi/0.12.1.nix b/pkgs/applications/networking/instant-messengers/psi/default.nix
index 110189598f6c..0db1af883cb8 100644
--- a/pkgs/applications/networking/instant-messengers/psi/0.12.1.nix
+++ b/pkgs/applications/networking/instant-messengers/psi/default.nix
@@ -1,19 +1,24 @@
-args : with args;
+{ stdenv, fetchurl, aspell, qt4, zlib, sox, libX11, xproto, libSM, libICE, qca2 }:
+
 stdenv.mkDerivation rec {
+  name = "psi-0.12.1";
+  
   src = fetchurl {
-    url = mirror://sourceforge/psi/psi-0.12.1.tar.bz2;
+    url = "mirror://sourceforge/psi/${name}.tar.bz2";
     sha256 = "0zi71fcia9amcasa6zrvfyghdpqa821iv2rkj53bq5dyvfm2y0m8";
   };
 
   buildInputs = [aspell qt4 zlib sox libX11 xproto libSM libICE qca2];
 
   NIX_CFLAGS_COMPILE="-I${qca2}/include/QtCrypto";
+  
   NIX_LDFLAGS="-lqca";
 
-  configureFlags = [ " --with-zlib-inc=${zlib}/include "
-    " --disable-bundled-qca" ];
+  configureFlags =
+    [ " --with-zlib-inc=${zlib}/include "
+      " --disable-bundled-qca"
+    ];
 
-  name = "psi-" + version;
   meta = {
     description = "Psi, an XMPP (Jabber) client";
   };
diff --git a/pkgs/applications/version-management/codeville/0.8.0.nix b/pkgs/applications/version-management/codeville/0.8.0.nix
index 57552bac2fca..d72f753a26e0 100644
--- a/pkgs/applications/version-management/codeville/0.8.0.nix
+++ b/pkgs/applications/version-management/codeville/0.8.0.nix
@@ -16,7 +16,7 @@ rec {
   /* doConfigure should be specified separately */
   phaseNames = ["installPythonPackage" (makeManyWrappers ''$out/bin/*'' ''--prefix PYTHONPATH : $(toPythonPath $out)'')];
       
-  name = "codeville-" + version;
+  name = "codeville-0.8.0";
   meta = {
     description = "Codeville - RCS with powerful merge.";
   };
diff --git a/pkgs/applications/version-management/monotone-viz/mtn-head.nix b/pkgs/applications/version-management/monotone-viz/mtn-head.nix
index 6693795edd90..eb5228e09fdb 100644
--- a/pkgs/applications/version-management/monotone-viz/mtn-head.nix
+++ b/pkgs/applications/version-management/monotone-viz/mtn-head.nix
@@ -20,7 +20,7 @@ rec {
     autoconf -I .
   '') ["minInit" "addInputs" "doUnpack"];
       
-  name = "monotone-viz-" + version;
+  name = "monotone-viz-mtn-head";
   meta = {
     description = "Monotone commit tree visualizer";
     maintainers = [args.lib.maintainers.raskin];
diff --git a/pkgs/applications/version-management/viewmtn/0.10.nix b/pkgs/applications/version-management/viewmtn/0.10.nix
index 08351ffa91dc..169bd407b7d7 100644
--- a/pkgs/applications/version-management/viewmtn/0.10.nix
+++ b/pkgs/applications/version-management/viewmtn/0.10.nix
@@ -38,7 +38,7 @@ rec {
     ln -s $fullOut/static $out/share/viewmtn/
   '') ["minInit" "defEnsureDir" "addInputs" "doUnpack"];
 
-  name = "viewmtn-" + version;
+  name = "viewmtn-0.10";
   meta = {
     description = "Monotone web interface";
   };
diff --git a/pkgs/applications/virtualization/qemu/linux-img/0.2.nix b/pkgs/applications/virtualization/qemu/linux-img/0.2.nix
index 0d5e94ded959..748f67c7448e 100644
--- a/pkgs/applications/virtualization/qemu/linux-img/0.2.nix
+++ b/pkgs/applications/virtualization/qemu/linux-img/0.2.nix
@@ -13,11 +13,11 @@ args : with args;
 let 
 doCopy = fullDepEntry ("
   ensureDir \$out/share/qemu-images
-  cp linux-${version}.img  \$out/share/qemu-images/
+  cp linux-0.2.img \$out/share/qemu-images/
 ") [minInit doUnpack defEnsureDir];
 in
 stdenv.mkDerivation rec {
-	name = "QEmu-Linux-Image-"+version;
+	name = "QEmu-Linux-Image-0.2";
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs [doCopy doForceShare doPropagate]);
 	meta = {
diff --git a/pkgs/build-support/builder-defs/builder-defs.nix b/pkgs/build-support/builder-defs/builder-defs.nix
index 814ce460794c..5eaa40c61118 100644
--- a/pkgs/build-support/builder-defs/builder-defs.nix
+++ b/pkgs/build-support/builder-defs/builder-defs.nix
@@ -373,10 +373,6 @@ let inherit (builtins) head tail trace; in
         /*debug = x:(trace x x);
         debugX = x:(trace (toXML x) x);*/
 
-        replaceScriptVar = file: name: value: "sed -e 's`^${name}=.*`${name}='\\''${value}'\\''`' -i ${file}";
-        replaceInScript = file: l: concatStringsSep "\n" ((pairMap (replaceScriptVar file) l));
-        replaceScripts = l: concatStringsSep "\n" (pairMap replaceInScript l);
-        doReplaceScripts = fullDepEntry (replaceScripts (attrByPath ["shellReplacements"] [] args)) ["minInit"];
         makeNest = x: if x == defNest.text then x else "startNest\n" + x + "\nstopNest\n";
         textClosure = a: steps: textClosureMap makeNest a (["defNest"] ++ steps);
 
diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git
index d14f13bfa11a..9f2eb4b3a4c0 100755
--- a/pkgs/build-support/fetchgit/nix-prefetch-git
+++ b/pkgs/build-support/fetchgit/nix-prefetch-git
@@ -6,7 +6,7 @@ expHash=$3
 
 hashType=$NIX_HASH_ALGO
 if test -z "$hashType"; then
-    hashType=md5
+    hashType=sha256
 fi
 
 if test -z "$url"; then
@@ -36,15 +36,19 @@ if test -z "$finalPath"; then
     trap "rm -rf $tmpPath" EXIT
 
     # Perform the checkout.
-    git clone --depth 1 "$url" $tmpFile
+    git clone "$url" $tmpFile 1>&2
     if test -n "$rev"; then
       cd $tmpFile
-      echo $tmpFile
-      git checkout $rev
+      echo $tmpFile >&2
+      git checkout $rev 1>&2
     fi
     # Allow doing additional processing before .git removal
     eval "$NIX_PREFETCH_GIT_CHECKOUT_HOOK"
-    find $tmpFile -name .git\* | xargs rm -rf
+    if test "$NIX_PREFETCH_GIT_LEAVE_DOT_GIT" != 1
+    then
+	echo "removing \`.git'..." >&2
+	rm -rf .git
+    fi
 
     # Compute the hash.
     hash=$(nix-hash --type $hashType $hashFormat $tmpFile)
diff --git a/pkgs/build-support/fetchhg/builder.sh b/pkgs/build-support/fetchhg/builder.sh
new file mode 100644
index 000000000000..fbdd12b4f055
--- /dev/null
+++ b/pkgs/build-support/fetchhg/builder.sh
@@ -0,0 +1,9 @@
+source $stdenv/setup
+
+header "getting $url${tag:+ ($tag)} into $out"
+
+hg clone ${tag:+-r "$tag"} "$url" "$out"
+
+rm -rf "$out/.hg"
+
+stopNest
diff --git a/pkgs/build-support/fetchhg/default.nix b/pkgs/build-support/fetchhg/default.nix
index a7696458856c..a80835cc71fb 100644
--- a/pkgs/build-support/fetchhg/default.nix
+++ b/pkgs/build-support/fetchhg/default.nix
@@ -1,7 +1,8 @@
 {stdenv, mercurial, nix}: {url, tag ? null, md5}:
 
+# TODO: statically check if mercurial as the https support if the url starts woth https.
 stdenv.mkDerivation {
-  name = "fetchdarcs";
+  name = "fetchhg";
   builder = ./builder.sh;
   buildInputs = [mercurial nix];
 
diff --git a/pkgs/build-support/fetchurl/default.nix b/pkgs/build-support/fetchurl/default.nix
index 00b7f3cc0794..1ba9124027d4 100644
--- a/pkgs/build-support/fetchurl/default.nix
+++ b/pkgs/build-support/fetchurl/default.nix
@@ -1,6 +1,3 @@
-# Argh, this thing is duplicated (more-or-less) in Nix (in corepkgs).
-# Need to find a way to combine them.
-
 {stdenv, curl}: # Note that `curl' may be `null', in case of the native stdenv.
 
 let
diff --git a/pkgs/build-support/fetchurl/mirrors.nix b/pkgs/build-support/fetchurl/mirrors.nix
index 3e8675b2168c..88f4e064fa13 100644
--- a/pkgs/build-support/fetchurl/mirrors.nix
+++ b/pkgs/build-support/fetchurl/mirrors.nix
@@ -22,10 +22,18 @@ rec {
 
   sf = sourceforge;
 
-  # GNU.
+  # GNU (http://www.gnu.org/prep/ftp.html).
   gnu = [
+    # This one redirects to a (supposedly) nearby and (supposedly) up-to-date
+    # mirror.
+    http://ftpmirror.gnu.org/
+
     http://ftp.nluug.nl/pub/gnu/
     http://mirrors.kernel.org/gnu/
+    ftp://mirror.cict.fr/gnu/
+    ftp://ftp.cs.tu-berlin.de/pub/gnu/
+    ftp://ftp.chg.ru/pub/gnu/
+
     http://ftp.gnu.org/pub/gnu/
   ];
 
@@ -209,6 +217,7 @@ rec {
     http://ftp.funet.fi/pub/linux/mirrors/opensuse/
     http://ftp5.gwdg.de/pub/opensuse/
     http://ftp.opensuse.org/pub/opensuse/
+    http://ftp5.gwdg.de/pub/opensuse/discontinued/
   ];
 
   # Gnome (see http://ftp.gnome.org/pub/GNOME/MIRRORS).
diff --git a/pkgs/build-support/release/source-tarball.nix b/pkgs/build-support/release/source-tarball.nix
index 579127f3a4d6..7cd3208d105c 100644
--- a/pkgs/build-support/release/source-tarball.nix
+++ b/pkgs/build-support/release/source-tarball.nix
@@ -36,6 +36,32 @@ stdenv.mkDerivation (
 
     preConfigurePhases = "autoconfPhase";
     postPhases = "finalPhase";
+
+    # Autoconfiscate the sources.
+    autoconfPhase = ''
+      export VERSION=${version}
+      export VERSION_SUFFIX=${versionSuffix}
+
+      # `svn-revision' is set for backwards compatibility with the old
+      # Nix buildfarm.  (Stratego/XT's autoxt uses it.  We should
+      # update it eventually.)
+      echo ${versionSuffix} | sed -e s/pre// > svn-revision
+
+      eval "$preAutoconf"
+
+      if test -x ./bootstrap; then ./bootstrap
+      elif test -x ./bootstrap.sh; then ./bootstrap.sh
+      elif test -x ./autogen.sh; then ./autogen.sh
+      elif test -x ./autogen ; then ./autogen
+      elif test -x ./reconf; then ./reconf
+      elif test -f ./configure.in || test -f ./configure.ac; then
+          autoreconf --install --force --verbose
+      else
+          echo "No bootstrap, bootstrap.sh, configure.in or configure.ac. Assuming this is not an GNU Autotools package."
+      fi
+
+      eval "$postAutoconf"
+    '';
   }
 
   # Then, the caller-supplied attributes.
@@ -64,42 +90,18 @@ stdenv.mkDerivation (
 
     nextPostUnpack = if args ? postUnpack then args.postUnpack else "";
 
-    # Autoconfiscate the sources.
-    autoconfPhase = ''
-      export VERSION=${version}
-      export VERSION_SUFFIX=${versionSuffix}
-
-      # `svn-revision' is set for backwards compatibility with the old
-      # Nix buildfarm.  (Stratego/XT's autoxt uses it.  We should
-      # update it eventually.)
-      echo ${versionSuffix} | sed -e s/pre// > svn-revision
-    
-      eval "$preAutoconf"
-    
-      if test -f ./bootstrap; then ./bootstrap
-      elif test -f ./bootstrap.sh; then ./bootstrap.sh
-      elif test -f ./reconf; then ./reconf
-      elif test -f ./configure.in || test -f ./configure.ac; then
-          autoreconf --install --force --verbose
-      else
-          echo "No bootstrap, bootstrap.sh, configure.in or configure.ac. Assuming this is not an GNU Autotools package."
-      fi
-    
-      eval "$postAutoconf"
-    '';
-
     # Cause distPhase to copy tar.bz2 in addition to tar.gz.
-    tarballs = "*.tar.gz *.tar.bz2";
+    tarballs = "*.tar.gz *.tar.bz2 *.tar.xz";
 
     finalPhase = ''
-      for i in $out/tarballs/*; do
+      for i in "$out/tarballs/"*; do
           echo "file source-dist $i" >> $out/nix-support/hydra-build-products
       done
 
       # Try to figure out the release name.
       releaseName=$( (cd $out/tarballs && ls) | head -n 1 | sed -e 's^\.[a-z].*^^')
       test -n "$releaseName" && (echo "$releaseName" >> $out/nix-support/hydra-release-name)
-    ''; # */
+    '';
 
     passthru = {
       inherit src;
diff --git a/pkgs/build-support/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix
new file mode 100644
index 000000000000..1c9e7fc49f28
--- /dev/null
+++ b/pkgs/build-support/trivial-builders.nix
@@ -0,0 +1,71 @@
+{ stdenv, lndir }:
+
+rec {
+
+  # Run the shell command `buildCommand' to produce a store path named
+  # `name'.  The attributes in `env' are added to the environment
+  # prior to running the command.
+  runCommand = name: env: buildCommand:
+    stdenv.mkDerivation ({
+      inherit name buildCommand;
+    } // env);
+
+
+  # Create a single file.
+  writeTextFile =
+    { name # the name of the derivation
+    , text
+    , executable ? false # run chmod +x ?
+    , destination ? ""   # relative path appended to $out eg "/bin/foo"
+    }:
+    runCommand name {inherit text executable; }
+      ''
+        n=$out${destination}
+        mkdir -p "$(dirname "$n")"
+        echo -n "$text" > "$n"
+        (test -n "$executable" && chmod +x "$n") || true
+      '';
+
+    
+  # Shorthands for `writeTextFile'.
+  writeText = name: text: writeTextFile {inherit name text;};
+  writeScript = name: text: writeTextFile {inherit name text; executable = true;};
+  writeScriptBin = name: text: writeTextFile {inherit name text; executable = true; destination = "/bin/${name}";};
+
+
+  # Create a forest of symlinks to the files in `paths'.
+  symlinkJoin = name: paths:
+    runCommand name { inherit paths; }
+      ''
+        mkdir -p $out
+        for i in $paths; do
+          ${lndir}/bin/lndir $i $out
+        done
+      '';
+
+
+  # Make a package that just contains a setup hook with the given contents.
+  makeSetupHook = script:
+    runCommand "hook" {}
+      ''
+        ensureDir $out/nix-support
+        cp ${script} $out/nix-support/setup-hook
+      '';
+
+
+  # Write the references (i.e. the runtime dependencies in the Nix store) of `path' to a file.
+  writeReferencesToFile = path: runCommand "runtime-deps"
+    {
+      exportReferencesGraph = ["graph" path];
+    }
+    ''
+      touch $out
+      while read path; do
+        echo $path >> $out
+        read dummy
+        read nrRefs
+        for ((i = 0; i < nrRefs; i++)); do read ref; done
+      done < graph
+    '';
+
+}
diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix
index 88ef284fa3b6..1a8e584d65f8 100644
--- a/pkgs/build-support/vm/default.nix
+++ b/pkgs/build-support/vm/default.nix
@@ -252,15 +252,6 @@ rec {
   '';
 
 
-  modifyDerivation = f: attrs:
-    let attrsCleaned = removeAttrs attrs ["meta" "passthru" "outPath" "drvPath"];
-        newDrv = derivation (attrsCleaned // (f attrs));
-    in newDrv //
-      { meta = if attrs ? meta then attrs.meta else {};
-        passthru = if attrs ? passthru then attrs.passthru else {};
-      };
-
-
   /* Run a derivation in a Linux virtual machine (using Qemu/KVM).  By
      default, there is no disk image; the root filesystem is a tmpfs,
      and /nix/store is shared with the host (via the CIFS protocol to
@@ -282,7 +273,7 @@ rec {
      `run-vm' will be left behind in the temporary build directory
      that allows you to boot into the VM and debug it interactively. */
      
-  runInLinuxVM = modifyDerivation (attrs: {
+  runInLinuxVM = drv: lib.overrideDerivation drv (attrs: {
     builder = "${bash}/bin/sh";
     args = ["-e" (vmRunCommand qemuCommandLinux)];
     origArgs = attrs.args;
@@ -317,7 +308,7 @@ rec {
      - Reboot to shutdown the machine (because Qemu doesn't seem
        capable of a APM/ACPI VM shutdown).
   */
-  runInGenericVM = modifyDerivation (attrs: {
+  runInGenericVM = drv: lib.overrideDerivation drv (attrs: {
     system = "i686-linux";
     builder = "${bash}/bin/sh";
     args = ["-e" (vmRunCommand qemuCommandGeneric)];
diff --git a/pkgs/data/fonts/clearlyU/1.9.nix b/pkgs/data/fonts/clearlyU/1.9.nix
index 6d2b9ffb812b..69296a45c249 100644
--- a/pkgs/data/fonts/clearlyU/1.9.nix
+++ b/pkgs/data/fonts/clearlyU/1.9.nix
@@ -18,7 +18,7 @@ args : with args; with builderDefs;
 	});
 	in with localDefs;
 stdenv.mkDerivation rec {
-	name = "clearlyU-12-"+version;
+	name = "clearlyU-12-1.9";
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs 
 			[doInstall doForceShare doPropagate]);
diff --git a/pkgs/data/fonts/junicode/0.6.15.nix b/pkgs/data/fonts/junicode/0.6.15.nix
index 1a8497bebb73..f991a387976e 100644
--- a/pkgs/data/fonts/junicode/0.6.15.nix
+++ b/pkgs/data/fonts/junicode/0.6.15.nix
@@ -16,7 +16,7 @@ args : with args; with builderDefs;
 	});
 	in with localDefs;
 stdenv.mkDerivation rec {
-	name = "junicode-"+version;
+	name = "junicode-0.6.15";
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs 
 			[doInstall doForceShare doPropagate]);
diff --git a/pkgs/data/fonts/libertine/2.7.bin.nix b/pkgs/data/fonts/libertine/2.7.bin.nix
index c88659e4371a..b4e8bb9b6d12 100644
--- a/pkgs/data/fonts/libertine/2.7.bin.nix
+++ b/pkgs/data/fonts/libertine/2.7.bin.nix
@@ -8,7 +8,7 @@ rec{
   buildInputs = [];
   phaseNames = ["doUnpack" "installFonts"];
 
-  name = "linux-libertine-" + version;
+  name = "linux-libertine-2.7";
   meta = {
     description = "Linux Libertine Fonts";
     homepage = http://linuxlibertine.sf.net;
diff --git a/pkgs/data/fonts/libertine/2.7.nix b/pkgs/data/fonts/libertine/2.7.nix
index 546a4bdacec0..a5c212aff864 100644
--- a/pkgs/data/fonts/libertine/2.7.nix
+++ b/pkgs/data/fonts/libertine/2.7.nix
@@ -15,7 +15,7 @@ rec {
     ScaleToEm(1000);
   '';
 
-  name = "linux-libertine-" + version;
+  name = "linux-libertine-2.7";
   meta = {
     description = "Linux Libertine Fonts";
     homepage = http://linuxlibertine.sf.net;
diff --git a/pkgs/data/fonts/lmodern/0.92.nix b/pkgs/data/fonts/lmodern/0.92.nix
deleted file mode 100644
index 556b9f998765..000000000000
--- a/pkgs/data/fonts/lmodern/0.92.nix
+++ /dev/null
@@ -1,32 +0,0 @@
-args : with args; 
-rec {
-  src = fetchurl {
-    url = http://ftp.de.debian.org/debian/pool/main/l/lmodern/lmodern_0.92.orig.tar.gz;
-    sha256 = "0ak3n7fsi2va94gsn0pfmyby2b4g7wz9h5a0prpbx24ax1xwinls";
-  };
-
-  buildInputs = [];
-  configureFlags = [];
-
-  /* doConfigure should be specified separately */
-  phaseNames = ["doCopy"];
-
-  doCopy = fullDepEntry(''
-    ensureDir $out/share/texmf/fonts/enc 
-    ensureDir $out/share/texmf/fonts/map 
-    ensureDir $out/share/texmf/fonts/type1/public/lm 
-    ensureDir $out/share/texmf/dvips/lm 
-    ensureDir $out/share/texmf/dvipdfm/config
-
-    cp -r ./* $out/share/texmf/
-
-    cp dvips/lm/*.enc $out/share/texmf/fonts/enc
-    cp dvips/lm/*.map $out/share/texmf/fonts/map
-    cp dvips/lm/*.map $out/share/texmf/dvipdfm/config
-  '') ["minInit" "defEnsureDir" "doUnpack"];
-
-  name = "lmodern-" + version;
-  meta = {
-    description = "Latin Modern font";
-  };
-}
diff --git a/pkgs/data/fonts/lmodern/1.010.nix b/pkgs/data/fonts/lmodern/default.nix
index 6948fa4cbbe5..c95b409ed8e4 100644
--- a/pkgs/data/fonts/lmodern/1.010.nix
+++ b/pkgs/data/fonts/lmodern/default.nix
@@ -1,25 +1,21 @@
-args : with args; 
-rec {
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation {
+  name = "lmodern-1.010x";
+  
   src = fetchurl {
     url = http://ftp.de.debian.org/debian/pool/main/l/lmodern/lmodern_1.010x.orig.tar.gz;
     sha256 = "0nwxj1ng7rvnp16jxcs25hbc5in65mdk4a3g3rlaq91i5qpq7mxj";
   };
 
-  buildInputs = [];
-  configureFlags = [];
-
-  /* doConfigure should be specified separately */
-  phaseNames = ["doCopy"];
-
-  doCopy = fullDepEntry(''
+  installPhase = ''
     ensureDir $out/share/texmf/
     ensureDir $out/share/fonts/
 
     cp -r ./* $out/share/texmf/
     cp -r fonts/{opentype,type1} $out/share/fonts/
-  '') ["minInit" "defEnsureDir" "doUnpack"];
+  '';
 
-  name = "lmodern-" + version;
   meta = {
     description = "Latin Modern font";
   };
diff --git a/pkgs/data/fonts/wqy_zenhei/0.4.23-1.nix b/pkgs/data/fonts/wqy_zenhei/0.4.23-1.nix
index edf9f8c40ffe..4b6120ad1083 100644
--- a/pkgs/data/fonts/wqy_zenhei/0.4.23-1.nix
+++ b/pkgs/data/fonts/wqy_zenhei/0.4.23-1.nix
@@ -15,7 +15,7 @@ args : with args; with builderDefs;
 	});
 	in with localDefs;
 stdenv.mkDerivation rec {
-	name = "wqy-zenhei-"+version;
+	name = "wqy-zenhei-0.4.23-1";
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs 
 			[doInstall doForceShare doPropagate]);
diff --git a/pkgs/development/compilers/go/cgo-set-local-to-match-gcc-error-messages.patch b/pkgs/development/compilers/go/cgo-set-local-to-match-gcc-error-messages.patch
new file mode 100644
index 000000000000..c0da4541a67d
--- /dev/null
+++ b/pkgs/development/compilers/go/cgo-set-local-to-match-gcc-error-messages.patch
@@ -0,0 +1,13 @@
+diff -r 21cae7efdcc6 src/cmd/cgo/main.go
+--- a/src/cmd/cgo/main.go	Sat Nov 14 12:23:24 2009 -0800
++++ b/src/cmd/cgo/main.go	Sun Nov 15 00:00:09 2009 +0100
+@@ -52,6 +52,9 @@
+ 		fatal("unknown architecture %s", arch)
+ 	}
+ 
++	// Define the language of gcc error messages.
++	os.Setenv("LC_ALL", "C");
++
+ 	p := openProg(input);
+ 	for _, cref := range p.Crefs {
+ 		// Convert C.ulong to C.unsigned long, etc.
diff --git a/pkgs/development/compilers/go/default.nix b/pkgs/development/compilers/go/default.nix
new file mode 100644
index 000000000000..d5314a976a23
--- /dev/null
+++ b/pkgs/development/compilers/go/default.nix
@@ -0,0 +1,76 @@
+{stdenv, fetchhg, bison, glibc, ed, which, bash, makeWrapper, ...}:
+
+let
+  version = "2009-11-12";
+  md5 = "66e5803c8dc2855b339151918b6b0de5";
+in
+
+stdenv.mkDerivation {
+  name = "Go-" + version;
+
+  # No tarball yet.
+  src = fetchhg {
+    url = https://go.googlecode.com/hg/;
+    tag = "release." + version;
+    inherit md5;
+  };
+
+  buildInputs = [ bison glibc ed which bash makeWrapper ];
+
+  patches = [
+    ./disable-system-dependent-tests.patch
+    ./cgo-set-local-to-match-gcc-error-messages.patch
+  ];
+
+  prePatch = ''
+    patchShebangs ./ # replace /bin/bash
+    # only for 386 build
+    # !!! substituteInPlace does not seems to be effective.
+    sed -i 's,/lib/ld-linux.so.2,${glibc}/lib/ld-linux.so.2,' src/cmd/8l/asm.c
+    sed -i 's,/usr/share/zoneinfo/,${glibc}/share/zoneinfo/,' src/pkg/time/zoneinfo.go
+  '';
+
+  GOOS = "linux";
+  GOARCH = "386";
+
+  installPhase = ''
+    ensureDir "$out/bin"
+    export GOROOT="$(pwd)/"
+    export GOBIN="$out/bin"
+    export PATH="$GOBIN:$PATH"
+    cd ./src
+    ./all.bash
+    cd -
+
+    # Handle Libraries and make them availabale under /share/go.
+    export GOLIB="pkg/"$GOOS"_"$GOARCH
+    ensureDir "$out/lib/go/$GOLIB"
+    cp -r ./$GOLIB $out/lib/go/pkg/
+
+    # this line set $AS $CC $GC $LD
+    source ./src/Make.$GOARCH
+
+    # Wrap the compiler and the linker to define the location of the
+    # libraries.
+    wrapProgram "$out/bin/$GC" \
+      --add-flags "-I" \
+      --add-flags "$out/lib/go/$GOLIB"
+
+    wrapProgram "$out/bin/$LD" \
+      --set "GOROOT" "$out/lib/go/" \
+      --set "GOOS" "$GOOS" \
+      --set "GOARCH" "$GOARCH"
+
+    # Copy the emacs configuration for Go files.
+    ensureDir "$out/share/emacs/site-lisp"
+    cp ./misc/emacs/* $out/share/emacs/site-lisp/ # */
+
+  '';
+
+  meta = {
+    homepage = http://golang.org/;
+    description = "The Go Programming language";
+    license = "BSD";
+    maintainers = with stdenv.lib.maintainers; [ pierron ];
+  };
+}
diff --git a/pkgs/development/compilers/go/disable-system-dependent-tests.patch b/pkgs/development/compilers/go/disable-system-dependent-tests.patch
new file mode 100644
index 000000000000..d9e7fa48c1fa
--- /dev/null
+++ b/pkgs/development/compilers/go/disable-system-dependent-tests.patch
@@ -0,0 +1,30 @@
+diff -r cb140bac9ab0 src/pkg/Makefile
+--- a/src/pkg/Makefile	Thu Nov 12 14:55:26 2009 -0800
++++ b/src/pkg/Makefile	Mon Nov 16 11:50:34 2009 +0100
+@@ -100,12 +100,15 @@
+ 
+ NOTEST=\
+ 	debug/proc\
++	exec\
+ 	go/ast\
+ 	go/doc\
+ 	go/token\
+ 	hash\
+ 	image\
++	log\
+ 	malloc\
++	os\
+ 	rand\
+ 	runtime\
+ 	syscall\
+diff -r cb140bac9ab0 src/run.bash
+--- a/src/run.bash	Thu Nov 12 14:55:26 2009 -0800
++++ b/src/run.bash	Mon Nov 16 11:50:34 2009 +0100
+@@ -69,7 +69,3 @@
+ ./timing.sh -test
+ ) || exit $?
+ 
+-(xcd ../test
+-./run
+-) || exit $?
+-
diff --git a/pkgs/development/compilers/ikarus/0.0.3.nix b/pkgs/development/compilers/ikarus/0.0.3.nix
deleted file mode 100644
index 1976df7b7422..000000000000
--- a/pkgs/development/compilers/ikarus/0.0.3.nix
+++ /dev/null
@@ -1,21 +0,0 @@
-
-args : with args; 
-rec {
-  src = fetchurl {
-    url = http://www.cs.indiana.edu/~aghuloum/ikarus/ikarus-0.0.3.tar.gz;
-    sha256 = "0d4vqwqfnj39l0gar2di021kcf6bfpkc6g40yapkmxm6sxpdcvjv";
-  };
-
-  buildInputs = [gmp];
-  configureFlags = [];
-
-  /* doConfigure should be specified separately */
-  phaseNames = ["doConfigure" "doMakeInstall"];
-      
-  name = "ikarus-" + version;
-  meta = {
-    description = "Ikarus - a Scheme compiler, aiming at R6RS";
-    homepage = http://www.cs.indiana.edu/~aghuloum/ikarus/;
-    license = "GPL3";
-  };
-}
diff --git a/pkgs/development/compilers/ikarus/default.nix b/pkgs/development/compilers/ikarus/default.nix
new file mode 100644
index 000000000000..7e14d13b7dff
--- /dev/null
+++ b/pkgs/development/compilers/ikarus/default.nix
@@ -0,0 +1,18 @@
+{ stdenv, fetchurl, gmp }:
+        
+stdenv.mkDerivation rec {
+  name = "ikarus-0.0.3";
+  
+  src = fetchurl {
+    url = "http://www.cs.indiana.edu/~aghuloum/ikarus/${name}.tar.gz";
+    sha256 = "0d4vqwqfnj39l0gar2di021kcf6bfpkc6g40yapkmxm6sxpdcvjv";
+  };
+
+  buildInputs = [ gmp ];
+      
+  meta = {
+    description = "Ikarus - a Scheme compiler, aiming at R6RS";
+    homepage = http://www.cs.indiana.edu/~aghuloum/ikarus/;
+    license = "GPL3";
+  };
+}
diff --git a/pkgs/development/compilers/qi/9.1.nix b/pkgs/development/compilers/qi/9.1.nix
index 8b218d499c53..8f094f9965a8 100644
--- a/pkgs/development/compilers/qi/9.1.nix
+++ b/pkgs/development/compilers/qi/9.1.nix
@@ -27,7 +27,7 @@ let
 	") [ addInputs minInit doUnpack defEnsureDir];
 in
 stdenv.mkDerivation rec {
-	name = "Qi-"+version;
+	name = "Qi-9.1";
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs [allBuild doForceShare doPropagate]);
 	meta = {
diff --git a/pkgs/development/compilers/strategoxt/0.18.nix b/pkgs/development/compilers/strategoxt/0.18.nix
index fc94f30044b6..44fff034ba34 100644
--- a/pkgs/development/compilers/strategoxt/0.18.nix
+++ b/pkgs/development/compilers/strategoxt/0.18.nix
@@ -41,11 +41,11 @@ rec {
 
   
   strategoxt = stdenv.mkDerivation rec {
-    name = "strategoxt-0.18pre20033";
+    name = "strategoxt-0.18pre20227";
 
     src = fetchurl {
-      url = "ftp://ftp.strategoxt.org/pub/stratego/StrategoXT/strategoxt-0.18pre20033.tar.gz";
-      sha256 = "070052cff1fd27b2ca4bed8b6aa0238574a18922b21feae2506e6df5d2201c1c";
+      url = "http://hydra.nixos.org/build/124117/download/1/strategoxt-0.18pre20227.tar.gz";
+      sha256 = "c2c7a68f76c6dfaf470ed9f7bad71cddebb620b709f20b01231c3a6fd93d8150";
     };
 
     buildInputs = [pkgconfig aterm sdf getopt];
diff --git a/pkgs/development/compilers/swi-prolog/5.6.51.nix b/pkgs/development/compilers/swi-prolog/5.6.51.nix
deleted file mode 100644
index cd640e5f26bc..000000000000
--- a/pkgs/development/compilers/swi-prolog/5.6.51.nix
+++ /dev/null
@@ -1,4 +0,0 @@
-args: import ./default.nix {
-  args = args;
-  sha256 = "d43862606284e659ec3acba9cddea53b772f9afb67d12aa36391d26fe1a05ad8";
-}
diff --git a/pkgs/development/compilers/swi-prolog/default.nix b/pkgs/development/compilers/swi-prolog/default.nix
index 23682db364fb..da61adb22996 100644
--- a/pkgs/development/compilers/swi-prolog/default.nix
+++ b/pkgs/development/compilers/swi-prolog/default.nix
@@ -1,16 +1,16 @@
-{args, sha256}: with args;
+{ stdenv, fetchurl }:
 
 stdenv.mkDerivation {
-  name = "swi-prolog-${version}";
+  name = "swi-prolog-5.6.51";
 
   src = fetchurl {
-    url = "http://gollem.science.uva.nl/cgi-bin/nph-download/SWI-Prolog/pl-${version}.tar.gz";
-    inherit sha256;
+    url = "http://gollem.science.uva.nl/cgi-bin/nph-download/SWI-Prolog/pl-5.6.51.tar.gz";
+    sha256 = "d43862606284e659ec3acba9cddea53b772f9afb67d12aa36391d26fe1a05ad8";
   };
 
   meta = {
     homepage = http://www.swi-prolog.org/;
-    description = "A Prolog compiler and interpreter.";
+    description = "A Prolog compiler and interpreter";
     license = "LGPL";
   };
 }
diff --git a/pkgs/development/interpreters/guile/1.9.nix b/pkgs/development/interpreters/guile/1.9.nix
index 0290567c1fff..253b299af392 100644
--- a/pkgs/development/interpreters/guile/1.9.nix
+++ b/pkgs/development/interpreters/guile/1.9.nix
@@ -7,18 +7,20 @@
  else stdenv.mkDerivation)
 
 rec {
-  name = "guile-1.9.4";  # This is an alpha release!
+  name = "guile-1.9.5";  # This is an alpha release!
   src = fetchurl {
     url = "ftp://alpha.gnu.org/gnu/guile/${name}.tar.gz";
-    sha256 = "1p136fb0s46q1cycfsnd7nny14ji43xva58cz39szvq36p9kjbbg";
+    sha256 = "0plzdpm22fk2n5m1pjjlckfvksy13aj7n45lx1nw4334i87d6sll";
   };
 
+  /* 1.9.5 has funny directory names, which contain "GNU Guile"!  */
+
   buildInputs = [ makeWrapper gawk readline libtool libunistring pkgconfig ];
   propagatedBuildInputs = [ gmp boehmgc ];
 
   patches =
-    stdenv.lib.optionals (coverageAnalysis != null)
-      [ ./gcov-file-name.patch ./disable-gc-sensitive-tests.patch ];
+    stdenv.lib.optional (coverageAnalysis != null)
+      ./disable-gc-sensitive-tests.patch;
 
   postInstall = ''
     wrapProgram $out/bin/guile-snarf --prefix PATH : "${gawk}/bin"
diff --git a/pkgs/development/interpreters/guile/gcov-file-name.patch b/pkgs/development/interpreters/guile/gcov-file-name.patch
deleted file mode 100644
index f144296170ed..000000000000
--- a/pkgs/development/interpreters/guile/gcov-file-name.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-This patch arranges so that we don't end up, with profiling builds, with a
-file named `<stdout>.gcov' since that confuses lcov:
-
-  <stdout>:cannot open source file
-  geninfo: ERROR: cannot read <stdout>.gcov!
-
---- guile/libguile/c-tokenize.c	2009-09-13 13:05:15.000000000 +0200
-+++ guile/libguile/c-tokenize.c	2009-10-28 16:24:15.000000000 +0100
-@@ -1,5 +1,5 @@
- 
--#line 3 "<stdout>"
-+#line 3 "c-tokenize.c"
- 
- #define  YY_INT_ALIGNED short int
- 
-@@ -616,7 +616,7 @@ int cookie_was_last = 0; 
- #define IS_COOKIE cookie_was_last = 1
- #define IS_NOT_COOKIE cookie_was_last = 0
-  
--#line 620 "<stdout>"
-+#line 620 "c-tokenize.c"
- 
- #define INITIAL 0
- 
-@@ -799,7 +799,7 @@ YY_DECL
- #line 65 "./c-tokenize.lex"
- 
- 
--#line 803 "<stdout>"
-+#line 803 "c-tokenize.c"
- 
- 	if ( !(yy_init) )
- 		{
-@@ -1235,7 +1235,7 @@ YY_RULE_SETUP
- #line 181 "./c-tokenize.lex"
- ECHO;
- 	YY_BREAK
--#line 1239 "<stdout>"
-+#line 1239 "c-tokenize.c"
- case YY_STATE_EOF(INITIAL):
- 	yyterminate();
- 
diff --git a/pkgs/development/libraries/enchant/1.3.0.nix b/pkgs/development/libraries/enchant/default.nix
index 0e3f92881e90..388d042d3aca 100644
--- a/pkgs/development/libraries/enchant/1.3.0.nix
+++ b/pkgs/development/libraries/enchant/default.nix
@@ -1,10 +1,10 @@
-args: with args;
+{ stdenv, fetchurl, aspell, pkgconfig, glib }:
 
 stdenv.mkDerivation rec {
-  name = "enchant-" + version;
+  name = "enchant-1.3.0";
   
   src = fetchurl {
-    url = "http://www.abisource.com/downloads/enchant/${version}/${name}.tar.gz";
+    url = "http://www.abisource.com/downloads/enchant/1.3.0/${name}.tar.gz";
     sha256 = "1vwqwsadnp4rf8wj7d4rglvszjzlcli0jyxh06h8inka1sm1al76";
   };
   
diff --git a/pkgs/development/libraries/libdbi-drivers/0.8.2-1.nix b/pkgs/development/libraries/libdbi-drivers/0.8.2-1.nix
index add438d07f1a..bb146a5cddff 100644
--- a/pkgs/development/libraries/libdbi-drivers/0.8.2-1.nix
+++ b/pkgs/development/libraries/libdbi-drivers/0.8.2-1.nix
@@ -29,7 +29,7 @@ args : with args;
 	};
 	in with localDefs;
 stdenv.mkDerivation rec {
-	name = "libdbi-"+version;
+	name = "libdbi-0.8.2-1";
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs [doConfigure doMakeInstall doForceShare doPropagate]);
 	meta = {
diff --git a/pkgs/development/libraries/libdbi/0.8.2.nix b/pkgs/development/libraries/libdbi/0.8.2.nix
index dd0f2ec1c5f9..b908c76fa78c 100644
--- a/pkgs/development/libraries/libdbi/0.8.2.nix
+++ b/pkgs/development/libraries/libdbi/0.8.2.nix
@@ -11,7 +11,7 @@ args : with args;
 	};
 	in with localDefs;
 stdenv.mkDerivation rec {
-	name = "libdbi-"+version;
+	name = "libdbi-0.8.2";
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs [doConfigure doMakeInstall doForceShare doPropagate]);
 	meta = {
diff --git a/pkgs/development/libraries/libextractor/0.5.18.nix b/pkgs/development/libraries/libextractor/0.5.18.nix
index ed56e5ce4feb..557369bd76c7 100644
--- a/pkgs/development/libraries/libextractor/0.5.18.nix
+++ b/pkgs/development/libraries/libextractor/0.5.18.nix
@@ -11,7 +11,7 @@ args : with args;
 	};
 	in with localDefs;
 stdenv.mkDerivation rec {
-	name = "libextractor-"+version;
+	name = "libextractor-0.5.18";
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs [doConfigure doMakeInstall doForceShare doPropagate]);
 	meta = {
diff --git a/pkgs/development/libraries/libjingle/0.3.11.nix b/pkgs/development/libraries/libjingle/0.3.11.nix
index b9d0b82df5eb..3fa8c99c4304 100644
--- a/pkgs/development/libraries/libjingle/0.3.11.nix
+++ b/pkgs/development/libraries/libjingle/0.3.11.nix
@@ -1,10 +1,12 @@
-args: with args;
+{ stdenv, fetchurl, mediastreamer }:
+
 stdenv.mkDerivation rec {
-	name = "libjingle-" + version;
-	src = fetchurl {
-		url = "mirror://sf/tapioca-voip/${name}.tar.gz";
-		sha256 = "1x5l2jwxpkyxvnq0cagq40p6x61v23vxngnnsxr15lyh1zwzk1yj";
-	};
+  name = "libjingle-0.3.11";
+  
+  src = fetchurl {
+    url = "mirror://sourceforge/tapioca-voip/${name}.tar.gz";
+    sha256 = "1x5l2jwxpkyxvnq0cagq40p6x61v23vxngnnsxr15lyh1zwzk1yj";
+  };
 
   propagatedBuildInputs = [ mediastreamer ];
 }
diff --git a/pkgs/development/libraries/mediastreamer/2.2.0-cvs20080207.nix b/pkgs/development/libraries/mediastreamer/2.2.0-cvs20080207.nix
index 0d2cefee200b..2b4a6a35f832 100644
--- a/pkgs/development/libraries/mediastreamer/2.2.0-cvs20080207.nix
+++ b/pkgs/development/libraries/mediastreamer/2.2.0-cvs20080207.nix
@@ -1,7 +1,8 @@
-args: with args;
+{ stdenv, fetchurl, autoconf, automake, libtool
+, pkgconfig, alsaLib, ffmpeg, speex, ortp }:
 
 stdenv.mkDerivation rec {
-  name = "mediastreamer2-" + version;
+  name = "mediastreamer2-2.2.0-cvs20080207";
 
 # This url is not related to mediastreamer. fetchcvs doesn't work on my laptop,
 # so I've created cvs snapshot and put it to my server.
diff --git a/pkgs/development/libraries/msilbc/2.0.0.nix b/pkgs/development/libraries/msilbc/default.nix
index 8bc8f2a6c1db..2978f0808c18 100644
--- a/pkgs/development/libraries/msilbc/2.0.0.nix
+++ b/pkgs/development/libraries/msilbc/default.nix
@@ -1,6 +1,8 @@
-args: with args;
+{ stdenv, fetchurl, ilbc, mediastreamer, pkgconfig }:
+
 stdenv.mkDerivation rec {
-  name = "msilbc-" + version;
+  name = "msilbc-2.0.0";
+  
   src = fetchurl {
     url = "http://download.savannah.gnu.org/releases/linphone/plugins/sources/${name}.tar.gz";
     sha256 = "0ifydb7qmpync56l4hbrp36n5wrb7gadb76isp643s6wsg7l743j";
@@ -9,6 +11,7 @@ stdenv.mkDerivation rec {
   patchPhase = "sed -i /MS_FILTER_SET_FMTP/d ilbc.c";
 
   propagatedBuildInputs = [ilbc mediastreamer];
+  
   buildInputs = [pkgconfig];
 
   buildPhase = ''
@@ -17,8 +20,8 @@ stdenv.mkDerivation rec {
     cc `pkg-config --libs mediastreamer` -shared -pthread -o libilbc.so
   '';
 
-  installPhase = "
-    ensureDir \${out}/lib/mediastreamer/plugins
-    cp libilbc.so \${out}/lib/mediastreamer/plugins
-  ";
+  installPhase = ''
+    ensureDir $out/lib/mediastreamer/plugins
+    cp libilbc.so $out/lib/mediastreamer/plugins
+  '';
 }
diff --git a/pkgs/development/libraries/redland/1.0.8.nix b/pkgs/development/libraries/redland/1.0.8.nix
index 9b065043178a..f0c2300b1693 100644
--- a/pkgs/development/libraries/redland/1.0.8.nix
+++ b/pkgs/development/libraries/redland/1.0.8.nix
@@ -1,10 +1,7 @@
 args: with args;
 
-let name = "redland-${version}";
-in 
-
-stdenv.mkDerivation {
-  inherit name;
+stdenv.mkDerivation rec {
+  name = "redland-1.0.8";
 
   src = fetchurl {
     url = "mirror://sf/librdf/${name}.tar.gz";
diff --git a/pkgs/development/libraries/redland/1.0.9.nix b/pkgs/development/libraries/redland/1.0.9.nix
index 93606ad0eb58..231e64a00aee 100644
--- a/pkgs/development/libraries/redland/1.0.9.nix
+++ b/pkgs/development/libraries/redland/1.0.9.nix
@@ -1,10 +1,7 @@
 args: with args;
 
-let name = "redland-${version}";
-in
-
-stdenv.mkDerivation {
-  inherit name;
+stdenv.mkDerivation rec {
+  name = "redland-1.0.9";  
 
   src = fetchurl {
     url = "mirror://sf/librdf/${name}.tar.gz";
@@ -21,13 +18,13 @@ stdenv.mkDerivation {
   configureFlags = "--with-threads --with-bdb=${bdb}";
 
   patchPhase =
-  ''
-    sed -e 1s@/usr@${perl}@ -i utils/touch-mtime.pl
-
-    # Redland 1.0.9 uses an internal pre-processor symbol SQLITE_API
-    # that collides with a symbol of the same name in sqlite 3.6.19.
-    # This is a quick fix for the problem. A real solution needs to be
-    # implemented upstream, though.
-    find . -type f -exec sed -i -e 's/SQLITE_API/REDLAND_SQLITE_API/g' {} \;
-  '';
+    ''
+      sed -e 1s@/usr@${perl}@ -i utils/touch-mtime.pl
+
+      # Redland 1.0.9 uses an internal pre-processor symbol SQLITE_API
+      # that collides with a symbol of the same name in sqlite 3.6.19.
+      # This is a quick fix for the problem. A real solution needs to be
+      # implemented upstream, though.
+      find . -type f -exec sed -i -e 's/SQLITE_API/REDLAND_SQLITE_API/g' {} \;
+    '';
 }
diff --git a/pkgs/development/libraries/tk/8.4.16.nix b/pkgs/development/libraries/tk/8.4.16.nix
deleted file mode 100644
index 38b7ec857495..000000000000
--- a/pkgs/development/libraries/tk/8.4.16.nix
+++ /dev/null
@@ -1,18 +0,0 @@
-args: with args;
-
-stdenv.mkDerivation {
-  name = "tk-${version}";
-  src = fetchurl {
-    url = "mirror://sourceforge/tcl/tk${version}-src.tar.gz";
-    sha256 = "0cciavzd05bpm5yfppid0s0vsf8kabwia9620vgvi26sv1gjgwhb";
-  };
-  postInstall = ''
-    echo -e '#! /bin/sh \n $( readlink -f $( type -tP wish${builtins.substring 0 3 version}) ) "$@"' >$out/bin/wish
-    chmod a+x $out/bin/wish
-  ''; 
-  configureFlags="--with-tcl=${tcl}/lib";
-  preConfigure = "cd unix";
-
-  buildInputs = [tcl x11];
-  inherit tcl;
-}
diff --git a/pkgs/development/libraries/tk/8.4.18.nix b/pkgs/development/libraries/tk/8.4.18.nix
deleted file mode 100644
index f09303ade459..000000000000
--- a/pkgs/development/libraries/tk/8.4.18.nix
+++ /dev/null
@@ -1,18 +0,0 @@
-args: with args;
-
-stdenv.mkDerivation {
-  name = "tk-${version}";
-  src = fetchurl {
-    url = "mirror://sourceforge/tcl/tk${version}-src.tar.gz";
-    sha256 = "065cbs82a8nklmj4867744skb3l3mqv14s8jwribk2wazzdb0mqp";
-  };
-  postInstall = ''
-    echo -e '#! /bin/sh \n $( readlink -f $( type -tP wish${__substring 0 3 version}) ) "$@"' >$out/bin/wish
-    chmod a+x $out/bin/wish
-  '';
-  configureFlags="--with-tcl=${tcl}/lib";
-  preConfigure = "cd unix";
-
-  buildInputs = [tcl x11];
-  inherit tcl;
-}
diff --git a/pkgs/development/libraries/tk/8.5.7.nix b/pkgs/development/libraries/tk/8.5.7.nix
index 56a757c8c7c8..bf6da7b65982 100644
--- a/pkgs/development/libraries/tk/8.5.7.nix
+++ b/pkgs/development/libraries/tk/8.5.7.nix
@@ -1,17 +1,22 @@
-args: with args;
+{ stdenv, fetchurl, tcl, x11 }:
 
 stdenv.mkDerivation {
-  name = "tk-${version}";
+  name = "tk-8.5.7";
+  
   src = fetchurl {
-    url = "mirror://sourceforge/tcl/tk${version}-src.tar.gz";
+    url = "mirror://sourceforge/tcl/tk8.5.7-src.tar.gz";
     sha256 = "0c5gsy3nlwl0wn9swz4k4v7phy7nzjl317gca1jykgf4jz9nwdnr";
   };
+  
   postInstall = ''
     ln -s $out/bin/wish* $out/bin/wish
   '';
-  configureFlags="--with-tcl=${tcl}/lib";
+  
+  configureFlags = "--with-tcl=${tcl}/lib";
+  
   preConfigure = "cd unix";
 
   buildInputs = [tcl x11];
+  
   inherit tcl;
 }
diff --git a/pkgs/development/libraries/xapian/bindings/1.0.14.nix b/pkgs/development/libraries/xapian/bindings/1.0.14.nix
index 9761c6834474..28eacd4e4e41 100644
--- a/pkgs/development/libraries/xapian/bindings/1.0.14.nix
+++ b/pkgs/development/libraries/xapian/bindings/1.0.14.nix
@@ -3,7 +3,7 @@ args: with args;
 let inherit (args.composableDerivation) composableDerivation wwf; in
 composableDerivation {} {
 
-    name = "xapian-bindings-${version}";
+    name = "xapian-bindings-1.0.14";
 
     src = fetchurl {
       url = http://oligarchy.co.uk/xapian/1.0.14/xapian-bindings-1.0.14.tar.gz;
diff --git a/pkgs/development/libraries/xapian/1.0.14.nix b/pkgs/development/libraries/xapian/default.nix
index b4ce74640ea0..6b2966ee7e25 100644
--- a/pkgs/development/libraries/xapian/1.0.14.nix
+++ b/pkgs/development/libraries/xapian/default.nix
@@ -1,6 +1,7 @@
-args: with args;
+{ stdenv, fetchurl, zlib }:
+
 stdenv.mkDerivation {
-  name = "xapian-${version}";
+  name = "xapian-1.0.14";
 
   src = fetchurl {
     url = http://oligarchy.co.uk/xapian/1.0.14/xapian-core-1.0.14.tar.gz;
@@ -10,8 +11,8 @@ stdenv.mkDerivation {
   buildInputs = [zlib];
 
   meta = { 
-      description = "Xapian Probabilistic Information Retrieval library";
-      homepage = "http://xapian.org";
-      license = "GPLv2";
+    description = "Xapian Probabilistic Information Retrieval library";
+    homepage = "http://xapian.org";
+    license = "GPLv2";
   };
 }
diff --git a/pkgs/development/python-modules/flup/default.nix b/pkgs/development/python-modules/flup/default.nix
new file mode 100644
index 000000000000..be9fd84d1fd9
--- /dev/null
+++ b/pkgs/development/python-modules/flup/default.nix
@@ -0,0 +1,16 @@
+{ stdenv, fetchurl, python, setuptools }:
+
+stdenv.mkDerivation rec {
+  name = "flup-r2311";
+
+  src = fetchurl {
+    url = "http://www.saddi.com/software/flup/dist/${name}.tar.gz";
+    sha256 = "15wyn6d6wla1ag91yxmlh9b4m0w1i0c2lm8ka4qfv4ijqcqakdx3";
+  };
+
+  buildInputs = [ python setuptools ];
+
+  meta = {
+    description = "FastCGI Python module set";
+  };
+}
diff --git a/pkgs/development/python-modules/flup/r2311.nix b/pkgs/development/python-modules/flup/r2311.nix
deleted file mode 100644
index 1334a7e7539b..000000000000
--- a/pkgs/development/python-modules/flup/r2311.nix
+++ /dev/null
@@ -1,18 +0,0 @@
-args : with args; 
-rec {
-  src = fetchurl {
-    url = http://www.saddi.com/software/flup/dist/flup-r2311.tar.gz;
-    sha256 = "15wyn6d6wla1ag91yxmlh9b4m0w1i0c2lm8ka4qfv4ijqcqakdx3";
-  };
-
-  buildInputs = [python setuptools];
-  configureFlags = [];
-
-  /* doConfigure should be specified separately */
-  phaseNames = ["addInputs" "createPythonInstallationTarget" (doDump "0") "installPythonPackage"];
-      
-  name = "flup-" + version;
-  meta = {
-    description = "FastCGI Python module set";
-  };
-}
diff --git a/pkgs/development/python-modules/pyqt/4.3.3.nix b/pkgs/development/python-modules/pyqt/4.3.3.nix
index 23bed9c9c0aa..370366ba0e0b 100644
--- a/pkgs/development/python-modules/pyqt/4.3.3.nix
+++ b/pkgs/development/python-modules/pyqt/4.3.3.nix
@@ -1,4 +1,5 @@
-args : with args; 
+args : with args;
+
 rec {
   src = fetchurl {
     url = mirror://debian/pool/main/p/python-qt4/python-qt4_4.3.3.orig.tar.gz;
@@ -12,7 +13,7 @@ rec {
   phaseNames = ["doPythonConfigure" "doMakeInstall"];
   extraPythonConfigureCommand = ''echo yes | \'';
 
-  name = "python-qt-" + version;
+  name = "python-qt-4.3.3";
   meta = {
     description = "Qt bindings for Python";
     license = "GPL";
diff --git a/pkgs/development/python-modules/python-sip/4.7.4.nix b/pkgs/development/python-modules/python-sip/4.7.4.nix
index bc4437a27955..759246ebf0d4 100644
--- a/pkgs/development/python-modules/python-sip/4.7.4.nix
+++ b/pkgs/development/python-modules/python-sip/4.7.4.nix
@@ -11,7 +11,7 @@ rec {
   /* doConfigure should be specified separately */
   phaseNames = ["doPythonConfigure" "doMakeInstall"];
       
-  name = "python-sip-" + version;
+  name = "python-sip-4.7.4";
   meta = {
     description = "Python/C++ bindings generator";
   };
diff --git a/pkgs/development/tools/misc/xxdiff/3.2.nix b/pkgs/development/tools/misc/xxdiff/3.2.nix
index 8100972d6eab..44d869c107ee 100644
--- a/pkgs/development/tools/misc/xxdiff/3.2.nix
+++ b/pkgs/development/tools/misc/xxdiff/3.2.nix
@@ -34,7 +34,7 @@ rec {
     cd ..
   '') ["minInit" "doMake" "defEnsureDir" "addInputs"];
       
-  name = "xxdiff-" + version;
+  name = "xxdiff-3.2";
   meta = {
     description = "Interactive merge tool";
   };
diff --git a/pkgs/games/construo/0.2.2.nix b/pkgs/games/construo/0.2.2.nix
index 578e233cbd75..2b32020d8e9d 100644
--- a/pkgs/games/construo/0.2.2.nix
+++ b/pkgs/games/construo/0.2.2.nix
@@ -20,7 +20,7 @@ args : with args;
 	};
 	in with localDefs;
 stdenv.mkDerivation rec {
-	name = "construo-"+version;
+	name = "construo-0.2.2";
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs ["preConfigure" "doConfigure" "doMakeInstall" "doForceShare" "doPropagate"]);
 	meta = {
diff --git a/pkgs/games/fsg/alt-builder.nix b/pkgs/games/fsg/alt-builder.nix
index c2b68a6c7462..837685db2d9f 100644
--- a/pkgs/games/fsg/alt-builder.nix
+++ b/pkgs/games/fsg/alt-builder.nix
@@ -1,6 +1,6 @@
 args: with args; 
 	let localDefs = builderDefs.passthru.function {
-  		buildInputs =[mesa (wxGTK null) libX11 xproto];
+  		buildInputs =[mesa wxGTK libX11 xproto];
 		  src = 
 			fetchurl {
 				url = http://www.piettes.com/fallingsandgame/fsg-src-4.4.tar.gz;
diff --git a/pkgs/games/fsg/default.nix b/pkgs/games/fsg/default.nix
index b67b1bcfc5f8..029c93d6690e 100644
--- a/pkgs/games/fsg/default.nix
+++ b/pkgs/games/fsg/default.nix
@@ -8,7 +8,7 @@ stdenv.mkDerivation {
     sha256 = "1756y01rkvd3f1pkj88jqh83fqcfl2fy0c48mcq53pjzln9ycv8c";
   };
 
-  buildInputs = [gtk glib pkgconfig mesa (wxGTK null) libX11 xproto];
+  buildInputs = [gtk glib pkgconfig mesa wxGTK libX11 xproto];
 
 /*  
 #	One day Unicode will overcome?
diff --git a/pkgs/games/jamp/default.nix b/pkgs/games/jamp/default.nix
new file mode 100644
index 000000000000..b551b9b6dfce
--- /dev/null
+++ b/pkgs/games/jamp/default.nix
@@ -0,0 +1,33 @@
+a :  
+let 
+  s = import ./src-for-default.nix;
+  buildInputs = with a; [
+    mesa SDL SDL_mixer SDL_image
+
+  ];
+in
+rec {
+  src = a.fetchUrlFromSrcInfo s;
+
+  inherit (s) name;
+  inherit buildInputs;
+  configureFlags = [];
+
+  preBuild = a.fullDepEntry (''
+    sed -e "s@/usr/games@$out/bin@g" -i Makefile
+    sed -e "s@/usr/@$out/@g" -i Makefile
+    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${a.SDL}/include/SDL"
+  '') ["minInit" "addInputs" "doUnpack"];
+
+  /* doConfigure should be removed if not needed */
+  phaseNames = ["preBuild" "doMakeInstall"];
+      
+  meta = {
+    description = "A physics-based game";
+    maintainers = [
+      a.lib.maintainers.raskin
+    ];
+    platforms = with a.lib.platforms; 
+      linux ++ darwin;
+  };
+}
diff --git a/pkgs/games/jamp/src-for-default.nix b/pkgs/games/jamp/src-for-default.nix
new file mode 100644
index 000000000000..c5980b251c0a
--- /dev/null
+++ b/pkgs/games/jamp/src-for-default.nix
@@ -0,0 +1,9 @@
+rec {
+   version="1.0.2";
+   name="jamp-1.0.2";
+   hash="13cjggyx63wmlcvpyllmd7aknfd4vzhxnwm030mas7z3h6wcsmk7";
+   url="http://perre.noud.ch/jamp/download.php?file=jamp-${version}.tar.gz";
+   advertisedUrl="http://perre.noud.ch/jamp/download.php?file=jamp-1.0.2.tar.gz";
+  
+  
+}
diff --git a/pkgs/games/jamp/src-info-for-default.nix b/pkgs/games/jamp/src-info-for-default.nix
new file mode 100644
index 000000000000..9fb4ab9dbcc2
--- /dev/null
+++ b/pkgs/games/jamp/src-info-for-default.nix
@@ -0,0 +1,4 @@
+{
+  downloadPage = "http://perre.noud.ch/jamp/";
+  baseName = "jamp";
+}
diff --git a/pkgs/games/orbit/1.01.nix b/pkgs/games/orbit/1.01.nix
index a8cd48d99e6f..84a699d1a14d 100644
--- a/pkgs/games/orbit/1.01.nix
+++ b/pkgs/games/orbit/1.01.nix
@@ -30,7 +30,7 @@ EOF
 	});
 	in with localDefs;
 stdenv.mkDerivation rec {
-	name = "space-orbit-"+version;
+	name = "space-orbit-1.01";
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs 
 			[ customBuild doForceShare doPropagate]);
diff --git a/pkgs/lib/attrsets.nix b/pkgs/lib/attrsets.nix
index 4b2496c19874..4be944d8494f 100644
--- a/pkgs/lib/attrsets.nix
+++ b/pkgs/lib/attrsets.nix
@@ -15,7 +15,7 @@ rec {
 
   /* Return an attribute from nested attribute sets.  For instance
      ["x" "y"] applied to some set e returns e.x.y, if it exists.  The
-     default value is returned otherwise.  */
+     default value is returned otherwise. */
   attrByPath = attrPath: default: e:
     let attr = head attrPath;
     in
@@ -200,7 +200,7 @@ rec {
 
   /* Does the same as the update operator '//' except that attributes are
      merged until the given pedicate is verified.  The predicate should
-     except 3 arguments which are the path to reach the attribute, a part of
+     accept 3 arguments which are the path to reach the attribute, a part of
      the first attribute set and a part of the second attribute set.  When
      the predicate is verified, the value of the first attribute set is
      replaced by the value of the second attribute set.
diff --git a/pkgs/lib/customisation.nix b/pkgs/lib/customisation.nix
new file mode 100644
index 000000000000..76d019a73c20
--- /dev/null
+++ b/pkgs/lib/customisation.nix
@@ -0,0 +1,61 @@
+let lib = import ./default.nix; in
+
+rec {
+
+
+  /* `overrideDerivation drv f' takes a derivation (i.e., the result
+     of a call to the builtin function `derivation') and returns a new
+     derivation in which the attributes of the original are overriden
+     according to the function `f'.  The function `f' is called with
+     the original derivation attributes.
+
+     `overrideDerivation' allows certain "ad-hoc" customisation
+     scenarios (e.g. in ~/.nixpkgs/config.nix).  For instance, if you
+     want to "patch" the derivation returned by a package function in
+     Nixpkgs to build another version than what the function itself
+     provides, you can do something like this:
+
+       mySed = overrideDerivation pkgs.gnused (oldAttrs: {
+         name = "sed-4.2.2-pre";
+         src = fetchurl {
+           url = ftp://alpha.gnu.org/gnu/sed/sed-4.2.2-pre.tar.bz2;
+           sha256 = "11nq06d131y4wmf3drm0yk502d2xc6n5qy82cg88rb9nqd2lj41k";
+         };
+         patches = [];
+       });
+
+     For another application, see build-support/vm, where this
+     function is used to build arbitrary derivations inside a QEMU
+     virtual machine. */
+     
+  overrideDerivation = drv: f:
+    let
+      # Filter out special attributes.
+      attrs = removeAttrs drv ["meta" "passthru" "outPath" "drvPath"];
+      newDrv = derivation (attrs // (f drv));
+    in newDrv //
+      { meta = if drv ? meta then drv.meta else {};
+        passthru = if drv ? passthru then drv.passthru else {};
+      };
+
+
+  # usage: (you can use override multiple times)
+  # let d = makeOverridable stdenv.mkDerivation { name = ..; buildInputs; }
+  #     noBuildInputs = d.override { buildInputs = []; }
+  #     additionalBuildInputs = d.override ( args : args // { buildInputs = args.buildInputs ++ [ additional ]; } )
+  makeOverridable = f: origArgs: f origArgs //
+    { override = newArgs:
+        makeOverridable f (origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs));
+      deepOverride = newArgs:
+        makeOverridable f ((lib.mapAttrs (deepOverride newArgs) origArgs) // newArgs);
+      origArgs = origArgs;
+    };
+
+
+  deepOverride = newArgs: name: x: if builtins.isAttrs x then (
+    if x ? deepOverride then (x.deepOverride newArgs) else
+    if x ? override then (x.override newArgs) else
+    x) else x;
+    
+        
+}
diff --git a/pkgs/lib/debug.nix b/pkgs/lib/debug.nix
index 4f757653bc05..5d411b864ece 100644
--- a/pkgs/lib/debug.nix
+++ b/pkgs/lib/debug.nix
@@ -1,6 +1,6 @@
 let lib = import ./default.nix;
 
-inherit (builtins) trace attrNamesToStr isAttrs isFunction isList head substring attrNames;
+inherit (builtins) trace attrNamesToStr isAttrs isFunction isList isInt isString head substring attrNames;
 
 in
 
@@ -37,7 +37,10 @@ rec {
       else if x == true then "x is boolean true"
       else if x == false then "x is boolean false"
       else if x == null then "x is null"
-      else "x is probably a string `${substring 0 50 x}...'";
+      else if isInt x then "x is an integer `${toString x}'"
+      else if isString x then "x is a string `${substring 0 50 x}...'"
+      else "x is probably a path `${substring 0 50 (toString x)}'";
+
   # trace the arguments passed to function and its result 
   traceCall  = n : f : a : let t = n2 : x : traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a));
   traceCall2 = n : f : a : b : let t = n2 : x : traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a) (t "arg 2" b));
diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix
index 86c45fe83340..6276009ec190 100644
--- a/pkgs/lib/default.nix
+++ b/pkgs/lib/default.nix
@@ -16,6 +16,7 @@ let
   maintainers = import ./maintainers.nix;
   platforms = import ./platforms.nix;
   systems = import ./systems.nix;
+  customisation = import ./customisation.nix;
 
 in
   { inherit trivial lists strings stringsWithDeps attrsets sources options
@@ -26,3 +27,4 @@ in
   // trivial // lists // strings // stringsWithDeps // attrsets // sources
   // properties // options // types // meta // debug // misc // modules
   // systems
+  // customisation
diff --git a/pkgs/lib/maintainers.nix b/pkgs/lib/maintainers.nix
index 892b3e210445..9127c8c73089 100644
--- a/pkgs/lib/maintainers.nix
+++ b/pkgs/lib/maintainers.nix
@@ -8,6 +8,7 @@
   eelco = "Eelco Dolstra <e.dolstra@tudelft.nl>";
   ludo = "Ludovic Courtès <ludo@gnu.org>";
   marcweber = "Marc Weber <marco-oweber@gmx.de>";
+  pierron = "Nicolas B. Pierron <nixos@nbp.name>";
   raskin = "Michael Raskin <7c6f434c@mail.ru>";
   sander = "Sander van der Burg <s.vanderburg@tudelft.nl>";
   viric = "Lluís Batlle i Rossell <viriketo@gmail.com>";
diff --git a/pkgs/lib/misc.nix b/pkgs/lib/misc.nix
index ba7488ff70e8..c1fee190268c 100644
--- a/pkgs/lib/misc.nix
+++ b/pkgs/lib/misc.nix
@@ -9,23 +9,6 @@ with import ./strings.nix;
 
 rec {
 
-
-  # accumulates / merges all attr sets until null is fed.
-  # example: sumArgs id { a = 'a'; x = 'x'; } { y = 'y'; x = 'X'; } null
-  # result : { a = 'a'; x = 'X'; y = 'Y'; }
-  innerSumArgs = f : x : y : (if y == null then (f x)
-	else (innerSumArgs f (x // y)));
-  sumArgs = f : innerSumArgs f {};
-
-  # Advanced sumArgs version. Hm, twice as slow, I'm afraid.
-  # composedArgs id (x:x//{a="b";}) (x:x//{b=x.a + "c";}) null;
-  # {a="b" ; b="bc";};
-  innerComposedArgs = f : x : y : (if y==null then (f x)
-  	else (if (builtins.isAttrs y) then 
-		(innerComposedArgs f (x//y))
-	else (innerComposedArgs f (y x))));
-  composedArgs = f: innerComposedArgs f {};
-
   defaultMergeArg = x : y: if builtins.isAttrs y then
     y
   else 
@@ -105,14 +88,6 @@ rec {
   # }
   composedArgsAndFun = f: foldArgs defaultMerge f {};
 
-  # example a = pairMap (x : y : x + y) ["a" "b" "c" "d"];
-  # result: ["ab" "cd"]
-  innerPairMap = acc: f: l: 
-  	if l == [] then acc else
-	innerPairMap (acc ++ [(f (head l)(head (tail l)))])
-		f (tail (tail l));
-  pairMap = innerPairMap [];
-
   
   # shortcut for attrByPath ["name"] default attrs
   maybeAttr = name: default: attrs:
@@ -321,12 +296,6 @@ rec {
   flattenAttrs = set : map ( attr : builtins.getAttr attr set) (attrNames set);
   mapIf = cond : f :  fold ( x : l : if (cond x) then [(f x)] ++ l else l) [];
 
-  # pick attrs subset_attr_names and apply f 
-  subsetmap = f : attrs : subset_attr_names : 
-    listToAttrs (fold ( attr : r : if hasAttr attr attrs
-          then r ++ [ ( nameValuePair attr ( f (getAttr attr attrs) ) ) ] else r ) []
-      subset_attr_names );
-
   # prepareDerivationArgs tries to make writing configurable derivations easier
   # example:
   #  prepareDerivationArgs {
diff --git a/pkgs/os-specific/linux/atheros/0.9.4.nix b/pkgs/os-specific/linux/atheros/0.9.4.nix
index c2d39072750d..780e19757b29 100644
--- a/pkgs/os-specific/linux/atheros/0.9.4.nix
+++ b/pkgs/os-specific/linux/atheros/0.9.4.nix
@@ -17,7 +17,7 @@ postInstall = fullDepEntry (''
 '') [minInit doMakeInstall];
 in
 stdenv.mkDerivation rec {
-	name = "atheros-"+version;
+	name = "atheros-0.9.4";
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs [doMakeInstall 
 			postInstall doForceShare doPropagate]);
diff --git a/pkgs/os-specific/linux/jfsrec/default.nix b/pkgs/os-specific/linux/jfsrec/default.nix
new file mode 100644
index 000000000000..a805e86f0dd6
--- /dev/null
+++ b/pkgs/os-specific/linux/jfsrec/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, boost }:
+
+stdenv.mkDerivation {
+  name = "jfsrec-pre-svn-7";
+  
+  src = fetchurl {
+    url = http://downloads.sourceforge.net/jfsrec/jfsrec-svn-7.tar.gz;
+    sha256 = "163z6ljr05vw2k5mj4fim2nlg4khjyibrii95370pvn474mg28vg";
+  };
+
+  buildInputs = [ boost ];
+
+  preConfigure =
+    ''
+      sed -e '/[#]include [<]config.h[>]/a\#include <string.h>' -i src/unicode_to_utf8.cpp
+      cat src/unicode_to_utf8.cpp
+    '';
+
+  meta = {
+    description = "JFS recovery tool";
+  };
+}
diff --git a/pkgs/os-specific/linux/jfsrec/svn-7.nix b/pkgs/os-specific/linux/jfsrec/svn-7.nix
deleted file mode 100644
index 2516a505848a..000000000000
--- a/pkgs/os-specific/linux/jfsrec/svn-7.nix
+++ /dev/null
@@ -1,23 +0,0 @@
-args : with args; 
-rec {
-  src = fetchurl {
-    url = http://downloads.sourceforge.net/jfsrec/jfsrec-svn-7.tar.gz;
-    sha256 = "163z6ljr05vw2k5mj4fim2nlg4khjyibrii95370pvn474mg28vg";
-  };
-
-  buildInputs = [boost];
-  configureFlags = [];
-
-  doFixInc = fullDepEntry (''
-    sed -e '/[#]include [<]config.h[>]/a\#include <string.h>' -i src/unicode_to_utf8.cpp
-    cat src/unicode_to_utf8.cpp
-  '') ["minInit" "doUnpack"];
-
-  /* doConfigure should be specified separately */
-  phaseNames = ["doFixInc" "doConfigure" "doMakeInstall"];
-      
-  name = "jfsrec-" + version;
-  meta = {
-    description = "JFS recovery tool";
-  };
-}
diff --git a/pkgs/os-specific/linux/kqemu/1.4.0pre1.nix b/pkgs/os-specific/linux/kqemu/1.4.0pre1.nix
index 75d7483e33b9..ba5cf2e1d0f0 100644
--- a/pkgs/os-specific/linux/kqemu/1.4.0pre1.nix
+++ b/pkgs/os-specific/linux/kqemu/1.4.0pre1.nix
@@ -1,37 +1,28 @@
-args : with args;
-rec {
-  name = "kqemu-"+version;
+{ stdenv, fetchurl, kernel, perl }:
+
+stdenv.mkDerivation rec {
+  name = "kqemu-1.4.0pre1";
+  
   src = fetchurl {
-    url = http://www.nongnu.org/qemu/kqemu-1.4.0pre1.tar.gz;
+    url = "http://www.nongnu.org/qemu/${name}.tar.gz";
     sha256 = "14dlmawn3gia1j401ag5si5k1a1vav7jpv86rl37p1hwmr7fihxs";
   };
 
   buildInputs = [perl];
+  
   configureFlags = [''--PREFIx=$out'' ''--kernel-path=$(ls -d ${kernel}/lib/modules/*/build)''];
-  debugStep = fullDepEntry (''
-  	cat config-host.mak
-  '') ["minInit"];
-  preConfigure = fullDepEntry ('' 
+  
+  preConfigure = '' 
+    sed -e '/#include/i#include <linux/sched.h>' -i kqemu-linux.c
+
+    sed -e 's/memset/mymemset/g; s/memcpy/mymemcpy/g; s/void [*]my/static void *my/g' -i common/kern        
     sed -e 's/`uname -r`/'"$(basename ${kernel}/lib/modules/*)"'/' -i install.sh
     sed -e '/kernel_path=/akernel_path=$out$kernel_path' -i install.sh
     sed -e '/depmod/d' -i install.sh
     cat install.sh
-  '') ["minInit" "doUnpack"];
-  fixInc = {
-    text = ''
-      sed -e '/#include/i#include <linux/sched.h>' -i kqemu-linux.c
-    '';
-    deps = ["minInit" "doUnpack"];
-  };
-  fixMemFunc = {
-    text=''
-      sed -e 's/memset/mymemset/g; s/memcpy/mymemcpy/g; s/void [*]my/static void *my/g' -i common/kernel.c
-    '';
-    deps = ["minInit" "doUnpack"];
-  };
-  phaseNames = ["fixInc" "fixMemFunc" "preConfigure" "doConfigure" "debugStep" "doMakeInstall"];
-
+  ''; # */
+  
   meta = {
-    description = " Kernel module for Qemu acceleration ";
+    description = "Kernel module for Qemu acceleration";
   }; 
 }
diff --git a/pkgs/servers/dict/1.9.15.nix b/pkgs/servers/dict/1.9.15.nix
index 9eb0fe3dff9d..de9c4f7eeae8 100644
--- a/pkgs/servers/dict/1.9.15.nix
+++ b/pkgs/servers/dict/1.9.15.nix
@@ -11,7 +11,7 @@ args : with args; with builderDefs;
         }) // args);
         in with localDefs;
 stdenv.mkDerivation rec {
-        name = "dict-"+version;
+        name = "dict-1.9.15";
         builder = writeScript (name + "-builder")
                 (textClosure localDefs 
                         [doConfigure doMakeInstall doForceShare doPropagate]);
diff --git a/pkgs/servers/dns/bind/9.5.0.nix b/pkgs/servers/dns/bind/9.5.0.nix
index 9e73895d8d91..b6361864d10b 100644
--- a/pkgs/servers/dns/bind/9.5.0.nix
+++ b/pkgs/servers/dns/bind/9.5.0.nix
@@ -12,7 +12,7 @@ rec {
   /* doConfigure should be specified separately */
   phaseNames = ["doConfigure" "doMakeInstall"];
       
-  name = "bind-" + version;
+  name = "bind-9.5.0";
   meta = {
     description = "ISC BIND: a domain name server";
   };
diff --git a/pkgs/servers/gpm/1.20.6.nix b/pkgs/servers/gpm/1.20.6.nix
deleted file mode 100644
index 6e9e6e64d518..000000000000
--- a/pkgs/servers/gpm/1.20.6.nix
+++ /dev/null
@@ -1,22 +0,0 @@
-args : with args; 
-rec {
-  src = fetchurl {
-    url = http://linux.schottelius.org/gpm/archives/gpm-1.20.6.tar.lzma;
-    sha256 = "13w61bh9nyjaa0n5a7qq1rvbqxjbxpqz5qmdmqqpqgrd2jlviar7";
-  };
-
-  buildInputs = [lzma flex bison ncurses];
-  configureFlags = [];
-
-  /* doConfigure should be specified separately */
-  phaseNames = ["preConfigure" "doConfigure" "doMakeInstall"];
-
-  preConfigure = fullDepEntry (''
-    sed -e 's/[$](MKDIR)/mkdir -p /' -i doc/Makefile.in
-  '') ["addInputs" "doUnpack" "minInit"];
-      
-  name = "gpm-" + version;
-  meta = {
-    description = "Mouse daemon";
-  };
-}
diff --git a/pkgs/servers/gpm/default.nix b/pkgs/servers/gpm/default.nix
new file mode 100644
index 000000000000..5ab57b2cb3ef
--- /dev/null
+++ b/pkgs/servers/gpm/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, flex, bison, ncurses }:
+
+stdenv.mkDerivation rec {
+  name = "gpm-1.20.6";
+  
+  src = fetchurl {
+    url = "http://www.nico.schottelius.org/software/gpm/archives/${name}.tar.bz2";
+    sha256 = "1990i19ddzn8gg5xwm53yn7d0mya885f48sd2hyvr7dvzyaw7ch8";
+  };
+
+  buildInputs = [ flex bison ncurses ];
+
+  preConfigure =
+    ''
+      sed -e 's/[$](MKDIR)/mkdir -p /' -i doc/Makefile.in
+    '';
+      
+  meta = {
+    homepage = http://www.nico.schottelius.org/software/gpm/;
+    description = "A daemon that provides mouse support on the Linux console";
+  };
+}
diff --git a/pkgs/servers/http/tomcat/axis2/default.nix b/pkgs/servers/http/tomcat/axis2/default.nix
index c35295245756..066dfff36a73 100644
--- a/pkgs/servers/http/tomcat/axis2/default.nix
+++ b/pkgs/servers/http/tomcat/axis2/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl, apacheAnt, jdk, unzip}:
 
 stdenv.mkDerivation {
-  name = "axis2-1.5";
+  name = "axis2-1.5.1";
 
   src = fetchurl {
-    url = http://apache.mirror.easycolocate.nl/ws/axis2/1_5/axis2-1.5-bin.zip;
-    sha256 = "0f0a471xfsjx7s3i9awhajl1kli8y8pd8aiki7cwb9n4g467rwmc";
+    url = http://www.bizdirusa.com/mirrors/apache/ws/axis2/1_5_1/axis2-1.5.1-bin.zip;
+    sha256 = "04zcn9g4r7pxfpp5g5rpjjlddr5mibqmsz4lfbkz2vjf3jrldgy5";
   };
 
   buildInputs = [ unzip apacheAnt jdk ];
diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix
index 33bf8e4aa806..5986a937c477 100644
--- a/pkgs/servers/x11/xorg/overrides.nix
+++ b/pkgs/servers/x11/xorg/overrides.nix
@@ -100,7 +100,7 @@
       [ args.zlib xorg.xf86bigfontproto xorg.glproto args.mesa xorg.xf86driproto
         xorg.compositeproto xorg.scrnsaverproto xorg.resourceproto
         xorg.xineramaproto xorg.dri2proto xorg.xf86dgaproto xorg.dmxproto
-        xorg.libdmx xorg.xf86vidmodeproto
+        xorg.libdmx xorg.xf86vidmodeproto xorg.libXext 
       ];
     propagatedBuildInputs =
       [ xorg.libpciaccess xorg.inputproto xorg.xextproto xorg.randrproto ];
diff --git a/pkgs/servers/xmpp/ejabberd/default.nix b/pkgs/servers/xmpp/ejabberd/default.nix
index 405afc189c2e..7d81dd0accfd 100644
--- a/pkgs/servers/xmpp/ejabberd/default.nix
+++ b/pkgs/servers/xmpp/ejabberd/default.nix
@@ -1,15 +1,10 @@
-{stdenv, fetchurl, fetchsvn, expat, erlang, zlib, openssl, pam}:
+{stdenv, fetchurl, expat, erlang, zlib, openssl, pam, lib}:
 
 stdenv.mkDerivation rec {
-  name = "ejabberd-2.0.5";
-  #src = fetchurl {
-  #  url = http://www.process-one.net/downloads/ejabberd/2.0.5/ejabberd-2.0.5.tar.gz;
-  #  sha256 = "130rjl93l54c7p4glsfn3j7xwpwdyinhj6pp1di3mdx2mzi91vrp";
-  #};
-  src = fetchsvn {
-    url = http://svn.process-one.net/ejabberd/trunk;
-    rev = "2666";
-    sha256 = "c927ddc08c9cd748db93f48bcae96f9bd1c36e1ce107c9b4774e5423574ab7cb";
+  name = "ejabberd-2.1.0";
+  src = fetchurl {
+    url = http://www.process-one.net/downloads/ejabberd/2.1.0/ejabberd-2.1.0.tar.gz;
+    sha256 = "16gn5ag3zyv578bqbz134l13cy1gl1xfa5y7dnqxgpr9gkdyrp5q";
   };
   buildInputs = [ expat erlang zlib openssl pam ];
   patchPhase = ''
@@ -24,5 +19,6 @@ stdenv.mkDerivation rec {
     description = "Open-source XMPP application server written in Erlang";
     license = "GPLv2";
     homepage = http://www.ejabberd.im;
+    maintainers = [ lib.maintainers.sander ];
   };
 }
diff --git a/pkgs/shells/zsh/4.3.4.nix b/pkgs/shells/zsh/4.3.4.nix
deleted file mode 100644
index ea9a82cf6839..000000000000
--- a/pkgs/shells/zsh/4.3.4.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-args: with args;
-stdenv.mkDerivation {
-  name = "zsh-4.3.4";
-
-  src = fetchurl {
-    url = mirror://sourceforge/zsh/zsh-4.3.4.tar.bz2;
-    sha256 = "1inypy60h7hir8hwidid85pbajrb5w09fl222p0h4fnsn0nf583g";
-  };
-
-  configureFlags = "--with-tcsetpgrp --enable-maildir-support --enable-multibyte";
-
-  buildInputs = [ncurses coreutils];
-}
diff --git a/pkgs/shells/zsh/4.3.5.nix b/pkgs/shells/zsh/4.3.5.nix
deleted file mode 100644
index c626db491075..000000000000
--- a/pkgs/shells/zsh/4.3.5.nix
+++ /dev/null
@@ -1,22 +0,0 @@
-args: with args;
-let documentation = fetchurl {
-    url = mirror://sourceforge/zsh/zsh-4.3.5-doc.tar.bz2;
-    sha256 = "0jf35xibp8wfka7rdk9q8spkwprlhjx1sp7vp6img8wks12cvlkx";
-  };
-in
-stdenv.mkDerivation {
-  name = "zsh-${version}";
-
-  src = fetchurl {
-    url = mirror://sourceforge/zsh/zsh-4.3.5.tar.bz2;
-    sha256 = "0191j3liflkjrj39i2yrs3ab9jcx4zd93rirx3j17dymfgqlvrzb";
-  };
-  configureFlags = "--with-tcsetpgrp --enable-maildir-support --enable-multibyte";
-
-  postInstall = ''
-    ensureDir $out/share/
-    tar xf ${documentation} -C $out/share
-  '';
-
-  buildInputs = [ncurses coreutils];
-}
diff --git a/pkgs/shells/zsh/cvs.nix b/pkgs/shells/zsh/cvs.nix
deleted file mode 100644
index db34f0666d50..000000000000
--- a/pkgs/shells/zsh/cvs.nix
+++ /dev/null
@@ -1,19 +0,0 @@
-args: with args;
-# cvs does include docs
-# the cvs snapshot is updated occasionally. see bleedingEdgeRepos
-
-stdenv.mkDerivation {
-  name = "zsh-${version}";
-
-  src = sourceByName "zsh";
-  configureFlags = "--with-tcsetpgrp --enable-maildir-support --enable-multibyte";
-
-  preConfigure = "autoconf; autoheader";
-
-  postInstall = ''
-    ensureDir $out/share/
-    cp -R Doc $out/share
-  '';
-
-  buildInputs = [ncurses coreutils autoconf yodl ];
-}
diff --git a/pkgs/shells/zsh/4.3.9.nix b/pkgs/shells/zsh/default.nix
index 6a1d0d14dee9..eacda19a8de2 100644
--- a/pkgs/shells/zsh/4.3.9.nix
+++ b/pkgs/shells/zsh/default.nix
@@ -1,9 +1,16 @@
-args: with args;
-let documentation = fetchurl {
+{ stdenv, fetchurl, ncurses, coreutils }:
+
+let
+
+  version = "4.3.9";
+
+  documentation = fetchurl {
     url = "mirror://sourceforge/zsh/zsh-${version}-doc.tar.bz2";
     sha256 = "0rc19q5r8x2yln7synpqzxngm7g4g6idrpgc1i0jsawc48m7dbhm";
   };
+  
 in
+
 stdenv.mkDerivation {
   name = "zsh-${version}";
 
@@ -11,6 +18,7 @@ stdenv.mkDerivation {
     url = "mirror://sourceforge/zsh/zsh-${version}.tar.bz2";
     sha256 = "1aw28c5w83vl2ckbvf6ljj00s36icyrnxcm1r6q63863dmn6vpcg";
   };
+  
   configureFlags = "--with-tcsetpgrp --enable-maildir-support --enable-multibyte";
 
   postInstall = ''
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix
index 85ff46a339df..1b739f851686 100644
--- a/pkgs/stdenv/adapters.nix
+++ b/pkgs/stdenv/adapters.nix
@@ -211,4 +211,20 @@ rec {
       # `keepBuildTree' adapter as well.
       (cleanupBuildTree (keepBuildTree stdenv));
       
+
+  /* Replace the meta.maintainers field of a derivation.  This is useful
+     when you want to fork to update some packages without disturbing other
+     developers.
+
+     e.g.:  in all-packages.nix:
+
+     # remove all maintainers.
+     defaultStdenv = replaceMaintainersField allStdenvs.stdenv pkgs [];
+  */
+  replaceMaintainersField = stdenv: pkgs: maintainers: stdenv //
+    { mkDerivation = args:
+        pkgs.lib.recursiveUpdate
+          (stdenv.mkDerivation args)
+          { meta.maintainers = maintainers; };
+    };
 }
diff --git a/pkgs/stdenv/mingw/default.nix b/pkgs/stdenv/mingw/default.nix
index adbae2615370..bedf3986d170 100644
--- a/pkgs/stdenv/mingw/default.nix
+++ b/pkgs/stdenv/mingw/default.nix
@@ -38,6 +38,7 @@ let {
       shell = msysShell;
       path = [
         (make + "/bin")
+        (tar + "/bin")
         (binutils + "/bin")
         (gccFull + "/bin")
         (mingwRuntimeBin + "/bin")
@@ -77,7 +78,7 @@ let {
            * binutils is on the path because it contains dlltool, which
            * is invoked on the PATH by some packages.
            */
-          initialPath = [make binutils gccFull mingwRuntimeSrc w32apiSrc msys];
+          initialPath = [make tar binutils gccFull mingwRuntimeSrc w32apiSrc msys];
           gcc = gccFull;
           shell = msysShell;
           inherit curl;
@@ -152,7 +153,7 @@ let {
       src =
         fetchurlInit1 {
           url = ftp://ftp.strategoxt.org/pub/mingw/msys-1.0.11.tar.gz;
-          md5 = "85ce547934797019d2d642ec3b53934b";
+          sha256 = "08qp4jk279i66q6ngksg58fx3cfv1r6p5n394h2kfrs56qs9zvz4";
         };
     };
 
@@ -179,6 +180,12 @@ let {
      inherit fetchurl;
    };
 
+  tar =
+   (import ./pkgs).tar {
+     stdenv = stdenvInit2;
+     inherit fetchurl;
+   };
+
   binutils =
    (import ./pkgs).binutils {
      stdenv = stdenvInit2;
diff --git a/pkgs/stdenv/mingw/pkgs/default.nix b/pkgs/stdenv/mingw/pkgs/default.nix
index 4110e250b0eb..5add5b6546e8 100755
--- a/pkgs/stdenv/mingw/pkgs/default.nix
+++ b/pkgs/stdenv/mingw/pkgs/default.nix
@@ -29,6 +29,20 @@ rec {
     };
 
   /**
+   * Tar
+   */
+  tar = {stdenv, fetchurl} :
+    stdenv.mkDerivation {
+      name = "mingw-tar";
+      builder = ./bin-builder.sh;
+      src = 
+        fetchurl {
+          url = ftp://ftp.strategoxt.org/pub/mingw/tar-1.22-1-msys-1.0.11-bin.tar.gz;
+          sha256 = "17rbv159g56q3bp8rh5vzv8hw8clxs7vk731cgqg0vy1fzls6yfq";
+        };
+    };
+
+  /**
    * GCC. Binary
    */
   gccFull =  {stdenv, fetchurl} :
@@ -111,13 +125,13 @@ rec {
    */
   pkgconfigBin =  {stdenv, fetchurl} :
     stdenv.mkDerivation {
-      name = "pkgconfig-0.20";
+      name = "pkgconfig-0.23";
       builder = ./pkgconfig-builder.sh;
       setupHook = ../../../development/tools/misc/pkgconfig/setup-hook.sh;
       src =
         fetchurl {
-          url = http://www.cs.uu.nl/people/martin/pkg-config-0.20-bin.tar.gz;
-          md5 = "71f9595a022619b8e8b0f7853790c4c7";
+          url = ftp://ftp.strategoxt.org/pub/mingw/pkg-config-0.23.tar.gz;
+          sha256 = "1vab3rdnw16nhma1bln41bbrn6phbpcv9wiz79map8y5znaiv6mq";
         };
     };
 
diff --git a/pkgs/stdenv/mingw/setup.sh b/pkgs/stdenv/mingw/setup.sh
index 11705f8310fe..058d8cb18918 100755
--- a/pkgs/stdenv/mingw/setup.sh
+++ b/pkgs/stdenv/mingw/setup.sh
@@ -1,11 +1,97 @@
+# Run the named hook, either by calling the function with that name or
+# by evaluating the variable with that name.  This allows convenient
+# setting of hooks both from Nix expressions (as attributes /
+# environment variables) and from shell scripts (as functions). 
+runHook() {
+    local hookName="$1"
+    if test "$(type -t $hookName)" = function; then
+        $hookName
+    else
+        eval "${!hookName}"
+    fi
+}
+
+
+exitHandler() {
+    exitCode=$?
+    set +e
+
+    closeNest
+
+    if test -n "$showBuildStats"; then
+        times > "$NIX_BUILD_TOP/.times"
+        local -a times=($(cat "$NIX_BUILD_TOP/.times"))
+        # Print the following statistics:
+        # - user time for the shell
+        # - system time for the shell
+        # - user time for all child processes
+        # - system time for all child processes
+        echo "build time elapsed: " ${times[*]}
+    fi
+    
+    if test $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
+            echo "build failed with exit code $exitCode (ignored)"
+            ensureDir "$out/nix-support"
+            echo -n $exitCode > "$out/nix-support/failed"
+            exit 0
+        fi
+        
+    else
+        runHook exitHook
+    fi
+    
+    exit $exitCode
+}
+
+trap "exitHandler" EXIT
+
+
+######################################################################
+# Helper functions that might be useful in setup hooks.
+
+
+addToSearchPathWithCustomDelimiter() {
+    local delimiter=$1
+    local varName=$2
+    local dir=$3
+    if [ -d "$dir" ]; then
+        eval export ${varName}=${!varName}${!varName:+$delimiter}${dir}
+    fi
+}
+
+PATH_DELIMITER=':'
+
+addToSearchPath() {
+    addToSearchPathWithCustomDelimiter "${PATH_DELIMITER}" "$@"
+}
+
+
+######################################################################
+# Initialisation.
+
 set -e
 
 test -z $NIX_GCC && NIX_GCC=@GCC@
 
+
+# Wildcard expansions that don't match should expand to an empty list.
+# This ensures that, for instance, "for i in *; do ...; done" does the
+# right thing.
+shopt -s nullglob
+
+
 # Set up the initial path.
 PATH=
 for i in $NIX_GCC @INITIALPATH@; do
-    PATH=$PATH${PATH:+:}$i/bin
+    if test "$i" = /; then i=; fi
+    addToSearchPath PATH $i/bin
 done
 
 # Hack: the /tmp of Cygwin is different from the /tmp in MSYS
@@ -17,12 +103,15 @@ else
 fi
 
 if test "$NIX_DEBUG" = "1"; then
-    echo "Initial path: $PATH"
-    echo "$buildInputs"
+    echo "initial path: $PATH"
 fi
 
+
 # Execute the pre-hook.
 export SHELL=@SHELL@
+if test -z "$shell"; then
+    export shell=@SHELL@
+fi
 
 # Check that the pre-hook initialised SHELL.
 if test -z "$SHELL"; then echo "SHELL not set"; exit 1; fi
@@ -34,40 +123,29 @@ if test -f $NIX_GCC/nix-support/setup-hook; then
     source $NIX_GCC/nix-support/setup-hook
 fi
 
-    
-# Ensure that the given directory exists.
+
+# Ensure that the given directories exists.
 ensureDir() {
-    local dir=$1
-    if ! test -x "$dir"; then mkdir -p "$dir"; fi
+    local dir
+    for dir in "$@"; do
+        if ! test -x "$dir"; then mkdir -p "$dir"; fi
+    done
 }
 
-
-# Called when some build action fails.  If $succeedOnFailure is set,
-# create the file `$out/nix-support/failed' to signal failure, and
-# exit normally.  Otherwise, exit with failure.
-fail() {
-    exitCode=$?
-    if test "$succeedOnFailure" = 1; then
-        ensureDir "$out/nix-support"
-        touch "$out/nix-support/failed"
-        exit 0
-    else
-        exit $?
-    fi
+installBin() {
+    ensureDir $out/bin
+    cp "$@" $out/bin
 }
 
 
 # Allow the caller to augment buildInputs (it's not always possible to
 # do this before the call to setup.sh, since the PATH is empty at that
 # point; here we have a basic Unix environment).
-if test -n "$addInputsHook"; then
-    $addInputsHook
-fi
+runHook addInputsHook
 
 
 # Recursively find all build inputs.
-findInputs()
-{
+findInputs() {
     local pkg=$1
 
     case $pkgs in
@@ -75,13 +153,13 @@ findInputs()
             return 0
             ;;
     esac
-    
+
     pkgs="$pkgs $pkg "
 
     if test -f $pkg/nix-support/setup-hook; then
         source $pkg/nix-support/setup-hook
     fi
-    
+
     if test -f $pkg/nix-support/propagated-build-inputs; then
         for i in $(cat $pkg/nix-support/propagated-build-inputs); do
             findInputs $i
@@ -90,9 +168,6 @@ findInputs()
 }
 
 pkgs=""
-if test -n "$buildinputs"; then
-    buildInputs="$buildinputs" # compatibility
-fi
 for i in $buildInputs $propagatedBuildInputs; do
     findInputs $i
 done
@@ -100,19 +175,14 @@ done
 
 # Set the relevant environment variables to point to the build inputs
 # found above.
-addToEnv()
-{
+addToEnv() {
     local pkg=$1
 
-    if test "$ignoreFailedInputs" != "1" -a -e $1/nix-support/failed; then
-        echo "failed input $1" >&2
-        fail
-    fi
-
     if test -d $1/bin; then
-        export _PATH=$_PATH${_PATH:+:}$1/bin
+        addToSearchPath _PATH $1/bin
     fi
 
+    # Run the package-specific hooks set by the setup-hook scripts.
     for i in "${envHooks[@]}"; do
         $i $pkg
     done
@@ -126,6 +196,9 @@ done
 # Add the output as an rpath.
 if test "$NIX_NO_SELF_RPATH" != "1"; then
     export NIX_LDFLAGS="-rpath $out/lib $NIX_LDFLAGS"
+    if test -n "$NIX_LIB64_IN_SELF_RPATH"; then
+        export NIX_LDFLAGS="-rpath $out/lib64 $NIX_LDFLAGS"
+    fi
 fi
 
 
@@ -136,33 +209,131 @@ if test -z "$NIX_STRIP_DEBUG"; then
 fi
 
 
-# Do we know where the store is?  This is required for purity checking.
-if test -z "$NIX_STORE"; then
-    echo "Error: you have an old version of Nix that does not set the" \
-        "NIX_STORE variable.  Please upgrade." >&2
-    exit 1
-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').
+export TZ=UTC
 
 
-# We also need to know the root of the build directory for purity checking.
-if test -z "$NIX_BUILD_TOP"; then
-    echo "Error: you have an old version of Nix that does not set the" \
-        "NIX_BUILD_TOP variable.  Please upgrade." >&2
-    exit 1
+# 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
+    prefix="$out";
 fi
 
+if test "$useTempPrefix" = "1"; then
+    prefix="$NIX_BUILD_TOP/tmp_prefix";
+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').
-export TZ=UTC
 
 PATH=$_PATH${_PATH:+:}$PATH
 if test "$NIX_DEBUG" = "1"; then
-    echo "Final path: $PATH"
+    echo "final path: $PATH"
 fi
 
 
+# Make GNU Make produce nested output.
+export NIX_INDENT_MAKE=1
+
+
+######################################################################
+# Misc. helper functions.
+
+
+stripDirs() {
+    local dirs="$1"
+    local stripFlags="$2"
+    local dirsNew=
+
+    for d in ${dirs}; do
+        if test -d "$prefix/$d"; then
+            dirsNew="${dirsNew} $prefix/$d "
+        fi
+    done
+    dirs=${dirsNew}
+
+    if test -n "${dirs}"; then
+        header "stripping (with flags $stripFlags) in $dirs"
+        find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} strip $stripFlags || true
+        stopNest
+    fi
+}
+
+
+######################################################################
+# Textual substitution functions.
+
+
+substitute() {
+    local input="$1"
+    local output="$2"
+
+    local -a params=("$@")
+    local -a args=()
+
+    local n p pattern replacement varName
+
+    for ((n = 2; n < ${#params[*]}; n += 1)); do
+        p=${params[$n]}
+
+        if test "$p" = "--replace"; then
+            pattern="${params[$((n + 1))]}"
+            replacement="${params[$((n + 2))]}"
+            n=$((n + 2))
+        fi
+
+        if test "$p" = "--subst-var"; then
+            varName="${params[$((n + 1))]}"
+            pattern="@$varName@"
+            replacement="${!varName}"
+            n=$((n + 1))
+        fi
+
+        if test "$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"
+    done
+
+    replace-literal -e -s -- "${args[@]}" < "$input" > "$output".tmp
+    if test -x "$output"; then
+        chmod +x "$output".tmp
+    fi
+    mv -f "$output".tmp "$output"
+}
+
+
+substituteInPlace() {
+    local fileName="$1"
+    shift
+    substitute "$fileName" "$fileName" "$@"
+}
+
+
+substituteAll() {
+    local input="$1"
+    local output="$2"
+
+    # 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
+            echo "$envVar -> ${!envVar}"
+        fi
+        args="$args --subst-var $envVar"
+    done
+
+    substitute "$input" "$output" $args
+}
+
+
 ######################################################################
 # What follows is the generic builder.
 
@@ -192,69 +363,16 @@ closeNest() {
     done
 }
 
-trap "closeNest" EXIT
-
 
 # This function is useful for debugging broken Nix builds.  It dumps
 # all environment variables to a file `env-vars' in the build
 # directory.  If the build fails and the `-K' option is used, you can
 # then go to the build directory and source in `env-vars' to reproduce
 # the environment used for building.
-dumpVars() {
+dumpVars() {  
+    echo  "Dumping env-vars to $NIX_BUILD_TOP/env-vars"
     if test "$noDumpEnvVars" != "1"; then
-        export > $NIX_BUILD_TOP/env-vars
-    fi
-}
-
-
-# Redirect stdout/stderr to a named pipe connected to a `tee' process
-# that writes the specified file (and also to our original stdout).
-# The original stdout is saved in descriptor 3.
-startLog() {
-    local logFile=${logNr}_$1
-    logNr=$((logNr + 1))
-    if test "$logPhases" = 1; then
-        ensureDir $logDir
-
-        exec 3>&1
-
-        if test "$dontLogThroughTee" != 1; then
-            # This required named pipes (fifos).
-            logFifo=$NIX_BUILD_TOP/log_fifo
-            test -p $logFifo || mkfifo $logFifo
-            startLogWrite "$logDir/$logFile" "$logFifo"
-            exec > $logFifo 2>&1
-        else
-            exec > $logDir/$logFile 2>&1
-        fi
-    fi
-}
-
-# Factored into a separate function so that it can be overriden.
-startLogWrite() {
-    tee "$1" < "$2" &
-    logWriterPid=$!
-}
-
-
-if test -z "$logDir"; then
-    logDir=$out/log
-fi
-
-logNr=0
-
-# Restore the original stdout/stderr.
-stopLog() {
-    if test "$logPhases" = 1; then
-        exec >&3 2>&1
-
-        # Wait until the tee process has died.  Otherwise output from
-        # different phases may be mixed up.
-        if test -n "$logWriterPid"; then
-            wait $logWriterPid
-            logWriterPid=
-            rm $logFifo
-        fi
+        export > "$NIX_BUILD_TOP/env-vars"
     fi
 }
 
@@ -270,43 +388,45 @@ stripHash() {
 
 
 unpackFile() {
-    local file=$1
+    curSrc="$1"
     local cmd
 
-    case $file in
-        *.tar) cmd="tar xvf $file";;
-        *.tar.gz | *.tgz | *.tar.Z) cmd="tar xvfz $file";;
-        *.tar.bz2 | *.tbz2) cmd="tar xvfj $file";;
-        *.zip) cmd="unzip $file";;
+    header "unpacking source archive $curSrc" 3
+
+    case "$curSrc" in
+        *.tar)
+            tar xvf $curSrc
+            ;;
+        *.tar.gz | *.tgz | *.tar.Z)
+            gzip -d < $curSrc | tar xvf -
+            ;;
+        *.tar.bz2 | *.tbz2)
+            bzip2 -d < $curSrc | tar xvf -
+            ;;
+        *.zip)
+            unzip $curSrc
+            ;;
         *)
-            if test -d "$file"; then
-                stripHash $file
-                cmd="cp -prvd $file $strippedName"
+            if test -d "$curSrc"; then
+                stripHash $curSrc
+                cp -prvd $curSrc $strippedName
             else
-                if test -n "$findUnpacker"; then
-                    $findUnpacker $1;
-                fi
                 if test -z "$unpackCmd"; then
-                    echo "source archive $file has unknown type"
+                    echo "source archive $curSrc has unknown type"
                     exit 1
                 fi
-                cmd=$unpackCmd
+                runHook unpackCmd
             fi
             ;;
     esac
 
-    header "unpacking source archive $file (using $cmd)" 3
-    $cmd || fail
     stopNest
 }
 
 
-unpackW() {
-    if test -n "$unpackPhase"; then
-        $unpackPhase
-        return
-    fi
-
+unpackPhase() {
+    runHook preUnpack
+    
     if test -z "$srcs"; then
         if test -z "$src"; then
             echo 'variable $src or $srcs should point to the source'
@@ -333,8 +453,8 @@ unpackW() {
 
     # Find the source directory.
     if test -n "$setSourceRoot"; then
-        $setSourceRoot
-    else
+        runHook setSourceRoot
+    elif test -z "$sourceRoot"; then
         sourceRoot=
         for i in *; do
             if test -d "$i"; then
@@ -346,7 +466,7 @@ unpackW() {
                             echo "unpacker produced multiple directories"
                             exit 1
                         fi
-                        sourceRoot=$i
+                        sourceRoot="$i"
                         ;;
                 esac
             fi
@@ -363,72 +483,40 @@ unpackW() {
     # 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
-        chmod -R +w $sourceRoot
-    fi
-    
-    if test -n "$postUnpack"; then
-        $postUnpack
+    if test "$dontMakeSourcesWritable" != 1; then
+        chmod -R u+w "$sourceRoot"
     fi
-}
-
 
-unpackPhase() {
-    header "unpacking sources"
-    startLog "unpack"
-    unpackW
-    stopLog
-    stopNest
+    runHook postUnpack
 }
 
 
-patchW() {
-    if test -n "$patchPhase"; then
-        $patchPhase
-        return
-    fi
-
+patchPhase() {
+    runHook prePatch
+    
+    if test -z "$patchPhase" -a -z "$patches"; then return; fi
+    
     for i in $patches; do
         header "applying patch $i" 3
-        patch -p1 < $i || fail
+        local uncompress=cat
+        case $i in
+            *.gz)
+                uncompress="gzip -d"
+                ;;
+            *.bz2)
+                uncompress="bzip2 -d"
+                ;;
+        esac
+        $uncompress < $i | patch ${patchFlags:--p1}
         stopNest
     done
-}
 
-
-patchPhase() {
-    if test -z "$patchPhase" -a -z "$patches"; then return; fi
-    header "patching sources"
-    startLog "patch"
-    patchW
-    stopLog
-    stopNest
+    runHook postPatch
 }
 
 
-fixLibtool() {
-    sed 's^eval sys_lib_.*search_path=.*^^' < $1 > $1.tmp
-    mv $1.tmp $1
-}
-
-
-configureW() {
-    if test -n "$configurePhase"; then
-        $configurePhase
-        return
-    fi
-
-    if test -n "$preConfigure"; then
-        $preConfigure
-    fi
-
-    if test -z "$prefix"; then
-        prefix="$out";
-    fi
-
-    if test "$useTempPrefix" = "1"; then
-        prefix="$NIX_BUILD_TOP/tmp_prefix";
-    fi
+configurePhase() {
+    runHook preConfigure
 
     if test -z "$configureScript"; then
         configureScript=./configure
@@ -438,218 +526,243 @@ configureW() {
         fi
     fi
 
-    if test -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
-        configureFlags="--prefix=$prefix $configureFlags"
+        configureFlags="${prefixKey:---prefix=}$prefix $configureFlags"
     fi
 
-    echo "configure flags: $configureFlags"
-    $configureScript $configureFlags || fail
-
-    if test -n "$postConfigure"; then
-        $postConfigure
+    # Add --disable-dependency-tracking to speed up some builds.
+    if test -z "$dontAddDisableDepTrack"; then
+        if grep -q dependency-tracking $configureScript; then
+            configureFlags="--disable-dependency-tracking $configureFlags"
+        fi
     fi
-}
 
-
-configurePhase() {
-    header "configuring"
-    startLog "configure"
-    configureW
-    stopLog
-    stopNest
-}
-
-
-buildW() {
-    if test -n "$buildPhase"; then
-        $buildPhase
-        return
+    # By default, disable static builds.
+    if test -z "$dontDisableStatic"; then
+        if grep -q enable-static $configureScript; then
+            configureFlags="--disable-static $configureFlags"
+        fi
     fi
 
-    if test -n "$preBuild"; then
-        $preBuild
-    fi
-    
-    echo "make flags: $makeFlags"
-    make $makeFlags || fail
+    echo "configure flags: $configureFlags ${configureFlagsArray[@]}"
+    $configureScript $configureFlags "${configureFlagsArray[@]}"
 
-    if test -n "$postBuild"; then
-        $postBuild
-    fi
+    runHook postConfigure
 }
 
 
 buildPhase() {
-    if test "$dontBuild" = 1; then
-        return
-    fi
-    header "building"
-    startLog "build"
-    buildW
-    stopLog
-    stopNest
-}
-
+    runHook preBuild
 
-checkW() {
-    if test -n "$checkPhase"; then
-        $checkPhase
+    if test -z "$makeFlags" && ! test -n "$makefile" -o -e "Makefile" -o -e "makefile" -o -e "GNUmakefile"; then
+        echo "no Makefile, doing nothing"
         return
     fi
 
-    if test -z "$checkTarget"; then
-        checkTarget="check"
-    fi
+    echo "make flags: $makeFlags ${makeFlagsArray[@]} $buildFlags ${buildFlagsArray[@]}"
+    make ${makefile:+-f $makefile} \
+        $makeFlags "${makeFlagsArray[@]}" \
+        $buildFlags "${buildFlagsArray[@]}"
 
-    echo "check flags: $checkFlags"
-    make $checkFlags $checkTarget || fail
+    runHook postBuild
 }
 
 
 checkPhase() {
-    if test "$doCheck" != 1; then
-        return
-    fi
-    header "checking"
-    startLog "check"
-    checkW
-    stopLog
-    stopNest
+    runHook preCheck
+
+    echo "check flags: $makeFlags ${makeFlagsArray[@]} $checkFlags ${checkFlagsArray[@]}"
+    make ${makefile:+-f $makefile} \
+        $makeFlags "${makeFlagsArray[@]}" \
+        $checkFlags "${checkFlagsArray[@]}" ${checkTarget:-check}
+
+    runHook postCheck
 }
 
 
 patchELF() {
     # Patch all ELF executables and shared libraries.
     header "patching ELF executables and libraries"
-    find "$prefix" \( \
-        \( -type f -a -name "*.so*" \) -o \
-        \( -type f -a -perm +0100 \) \
-        \) -print -exec patchelf --shrink-rpath {} \;
+    if test -e "$prefix"; then
+        find "$prefix" \( \
+            \( -type f -a -name "*.so*" \) -o \
+            \( -type f -a -perm +0100 \) \
+            \) -print -exec patchelf --shrink-rpath {} \;
+    fi
     stopNest
 }
 
 
-installW() {
-    if test -n "$installPhase"; then
-        $installPhase
-        return
-    fi
-    
-    if test -n "$preInstall"; then
-        $preInstall
-    fi
+patchShebangs() {
+    # Rewrite all script interpreter file names (`#! /path') under the
+    # specified  directory tree to paths found in $PATH.  E.g.,
+    # /bin/sh will be rewritten to /nix/store/<hash>-some-bash/bin/sh.
+    # Interpreters that are already in the store are left untouched.
+    header "patching script interpreter paths"
+    local dir="$1"
+    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
+            local newPath=$(type -P $(basename $oldPath) || true)
+            if test -n "$newPath" -a "$newPath" != "$oldPath"; then
+                echo "$f: interpreter changed from $oldPath to $newPath"
+                sed -i -e "1 s,$oldPath,$newPath," "$f"
+            fi
+        fi
+    done
+    stopNest
+}
+
+
+installPhase() {
+    runHook preInstall
 
     ensureDir "$prefix"
-    
-    if test -z "$dontMakeInstall"; then
-        echo "install flags: $installFlags"
-        make install $installFlags || fail
+
+    installTargets=${installTargets:-install}
+    echo "install flags: $installTargets $makeFlags ${makeFlagsArray[@]} $installFlags ${installFlagsArray[@]}"
+    make ${makefile:+-f $makefile} $installTargets \
+        $makeFlags "${makeFlagsArray[@]}" \
+        $installFlags "${installFlagsArray[@]}"
+
+    runHook postInstall
+}
+
+
+# The fixup phase performs generic, package-independent, Nix-related
+# stuff, like running patchelf and setting the
+# propagated-build-inputs.  It should rarely be overriden.
+fixupPhase() {
+    runHook preFixup
+
+    # Put man/doc/info under $out/share.
+    forceShare=${forceShare:=man doc info}
+    if test -n "$forceShare"; then
+        for d in $forceShare; do
+            if test -d "$prefix/$d"; then
+                if test -d "$prefix/share/$d"; then
+                    echo "both $d/ and share/$d/ exists!"
+                else
+                    echo "fixing location of $d/ subdirectory"
+                    ensureDir $prefix/share
+                    if test -w $prefix/share; then
+                        mv -v $prefix/$d $prefix/share
+                        ln -sv $prefix/share/$d $prefix/$d
+                    fi
+                fi
+            fi
+        done;
     fi
 
-    if test -z "$dontStrip" -a "$NIX_STRIP_DEBUG" = 1; then
-        find "$prefix" -name "*.a" -exec echo stripping {} \; \
-            -exec strip -S {} \; || fail
+    # TODO: strip _only_ ELF executables, and return || fail here...
+    if test -z "$dontStrip"; then
+        stripDebugList=${stripDebugList:-lib lib64 libexec bin sbin}
+        if test -n "$stripDebugList"; then
+            stripDirs "$stripDebugList" "${stripDebugFlags:--S}"
+        fi
+        
+        stripAllList=${stripAllList:-}
+        if test -n "$stripAllList"; then
+            stripDirs "$stripAllList" "${stripAllFlags:--s}"
+        fi
     fi
 
     if test "$havePatchELF" = 1 -a -z "$dontPatchELF"; then
         patchELF "$prefix"
     fi
 
+    if test -z "$dontPatchShebangs"; then
+        patchShebangs "$prefix"
+    fi
+
     if test -n "$propagatedBuildInputs"; then
         ensureDir "$out/nix-support"
         echo "$propagatedBuildInputs" > "$out/nix-support/propagated-build-inputs"
     fi
 
-    if test -n "$postInstall"; then
-        $postInstall
+    if test -n "$setupHook"; then
+        ensureDir "$out/nix-support"
+        substituteAll "$setupHook" "$out/nix-support/setup-hook"
     fi
-}
 
-
-installPhase() {
-    if test "$dontInstall" = 1; then
-        return
-    fi
-    header "installing"
-    startLog "install"
-    installW
-    stopLog
-    stopNest
+    runHook postFixup
 }
 
 
-distW() {
-    if test -n "$distPhase"; then
-        $distPhase
-        return
-    fi
-
-    if test -n "$preDist"; then
-        $preDist
-    fi
-    
-    if test -z "$distTarget"; then
-        distTarget="dist"
-    fi
+distPhase() {
+    runHook preDist
 
-    echo "dist flags: $distFlags"
-    make $distFlags $distTarget || fail
+    echo "dist flags: $distFlags ${distFlagsArray[@]}"
+    make ${makefile:+-f $makefile} $distFlags "${distFlagsArray[@]}" ${distTarget:-dist}
 
     if test "$dontCopyDist" != 1; then
         ensureDir "$out/tarballs"
 
-        if test -z "$tarballs"; then
-            tarballs="*.tar.gz"
-        fi
-
         # Note: don't quote $tarballs, since we explicitly permit
         # wildcards in there.
-        cp -pvd $tarballs $out/tarballs
+        cp -pvd ${tarballs:-*.tar.gz} $out/tarballs
     fi
 
-    if test -n "$postDist"; then
-        $postDist
-    fi
+    runHook postDist
 }
 
 
-distPhase() {
-    if test "$doDist" != 1; then
-        return
-    fi
-    header "creating distribution"
-    startLog "dist"
-    distW
-    stopLog
-    stopNest
+showPhaseHeader() {
+    local phase="$1"
+    case $phase in
+        unpackPhase) header "unpacking sources";;
+        patchPhase) header "patching sources";;
+        configurePhase) header "configuring";;
+        buildPhase) header "building";;
+        checkPhase) header "running tests";;
+        installPhase) header "installing";;
+        fixupPhase) header "post-installation fixup";;
+        *) header "$phase";;
+    esac
 }
 
 
 genericBuild() {
     header "building $out"
 
-    unpackPhase
-    cd $sourceRoot
-
-    if test -z "$phases"; then
-        phases="patchPhase configurePhase buildPhase checkPhase \
-            installPhase distPhase";
+    if test -n "$buildCommand"; then
+        eval "$buildCommand"
+        return
     fi
 
-    for i in $phases; do
+    if test -z "$phases"; then
+        phases="$prePhases unpackPhase patchPhase $preConfigurePhases \
+            configurePhase $preBuildPhases buildPhase checkPhase \
+            $preInstallPhases installPhase fixupPhase \
+            $preDistPhases distPhase $postPhases";
+    fi
+
+    for curPhase in $phases; do
+        if test "$curPhase" = buildPhase -a -n "$dontBuild"; then continue; fi
+        if test "$curPhase" = checkPhase -a -z "$doCheck"; then continue; fi
+        if test "$curPhase" = installPhase -a -n "$dontInstall"; then continue; fi
+        if test "$curPhase" = fixupPhase -a -n "$dontFixup"; then continue; fi
+        if test "$curPhase" = distPhase -a -z "$doDist"; then continue; fi
+        
+        showPhaseHeader "$curPhase"
         dumpVars
-        $i
+        
+        # Evaluate the variable named $curPhase if it exists, otherwise the
+        # function named $curPhase.
+        eval "${!curPhase:-$curPhase}"
+
+        if test "$curPhase" = unpackPhase; then
+            cd "${sourceRoot:-.}"
+        fi
+        
+        stopNest
     done
-    
+
     stopNest
 }
 
 
+
+
 dumpVars
diff --git a/pkgs/tools/X11/x11vnc/0.9.3.nix b/pkgs/tools/X11/x11vnc/0.9.3.nix
index f37a98a43d40..b8587ed223f2 100644
--- a/pkgs/tools/X11/x11vnc/0.9.3.nix
+++ b/pkgs/tools/X11/x11vnc/0.9.3.nix
@@ -14,7 +14,7 @@ args : with args; with builderDefs;
   });
   in with localDefs;
 stdenv.mkDerivation rec {
-  name = "x11vnc-"+version;
+  name = "x11vnc-0.9.3";
   builder = writeScript (name + "-builder")
     (textClosure localDefs 
       [doConfigure doMakeInstall doForceShare doPropagate]);
diff --git a/pkgs/tools/X11/x2vnc/1.7.2.nix b/pkgs/tools/X11/x2vnc/1.7.2.nix
index 9c7e024551d3..c65105e47960 100644
--- a/pkgs/tools/X11/x2vnc/1.7.2.nix
+++ b/pkgs/tools/X11/x2vnc/1.7.2.nix
@@ -15,7 +15,7 @@ args : with args; with builderDefs.passthru.function {src="";};
 	}) // args); /* null is a terminator for sumArgs */
 	in with localDefs;
 stdenv.mkDerivation rec {
-	name = "x2vnc-"+version;
+	name = "x2vnc-1.7.2";
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs 
 			[doConfigure doCreatePrefix doMakeInstall doForceShare doPropagate]);
diff --git a/pkgs/tools/archivers/sharutils/4.6.3.nix b/pkgs/tools/archivers/sharutils/4.6.3.nix
index 830c2a072b6e..cd70550117a5 100644
--- a/pkgs/tools/archivers/sharutils/4.6.3.nix
+++ b/pkgs/tools/archivers/sharutils/4.6.3.nix
@@ -1,9 +1,10 @@
-args: with args;
+{ stdenv, fetchurl }:
+
 stdenv.mkDerivation rec {
-  name = "sharutils-" + version;
+  name = "sharutils-4.6.3";
 
   src = fetchurl {
-    url = "mirror://gnu/sharutils/REL-${version}/${name}.tar.bz2";
+    url = "mirror://gnu/sharutils/REL-4.6.3/${name}.tar.bz2";
     sha256 = "1sirrzas8llcsd8gnh56pns39wa1f803vff1kmy5islfi1p9vqk8";
   };
 
diff --git a/pkgs/tools/misc/mdbtools/0.6-pre1.nix b/pkgs/tools/misc/mdbtools/default.nix
index 9478ef1286b9..9b1968c6fd1f 100644
--- a/pkgs/tools/misc/mdbtools/0.6-pre1.nix
+++ b/pkgs/tools/misc/mdbtools/default.nix
@@ -1,21 +1,19 @@
-args : with args; 
-rec {
+{ stdenv, fetchurl, glib, readline, bison, flex, pkgconfig }:
+
+stdenv.mkDerivation {
+  name = "mdbtools-0.6pre1";
+
   src = fetchurl {
     url = http://prdownloads.sourceforge.net/mdbtools/mdbtools-0.6pre1.tar.gz;
     sha256 = "1lz33lmqifjszad7rl1r7rpxbziprrm5rkb27wmswyl5v98dqsbi";
   };
 
   buildInputs = [glib readline bison flex pkgconfig];
-  configureFlags = [];
 
-  preConfigure = fullDepEntry (''
+  preConfigure = ''
     sed -e 's@static \(GHashTable [*]mdb_backends;\)@\1@' -i src/libmdb/backend.c
-  '') ["doUnpack" "minInit"];
+  '';
 
-  /* doConfigure should be specified separately */
-  phaseNames = ["preConfigure" "doConfigure" "doMakeInstall"];
-      
-  name = "mdbtools-" + version;
   meta = {
     description = ".mdb (MS Access) format tools";
   };
diff --git a/pkgs/tools/misc/minicom/2.3.nix b/pkgs/tools/misc/minicom/2.3.nix
deleted file mode 100644
index 9be249231c37..000000000000
--- a/pkgs/tools/misc/minicom/2.3.nix
+++ /dev/null
@@ -1,18 +0,0 @@
-args : with args; 
-rec {
-  src = fetchurl {
-    url = http://alioth.debian.org/frs/download.php/2332/minicom-2.3.tar.gz;
-    sha256 = "1ysn0crdhvwyvdlbw0ms5nq06xy2pd2glwjs53p384byl3ac7jra";
-  };
-
-  buildInputs = [ncurses];
-  configureFlags = [ "--sysconfdir=/etc" ];
-
-  /* doConfigure should be specified separately */
-  phaseNames = [ "doConfigure" "doMakeInstall"];
-      
-  name = "minicom-" + version;
-  meta = {
-    description = "Serial console";
-  };
-}
diff --git a/pkgs/tools/misc/minicom/default.nix b/pkgs/tools/misc/minicom/default.nix
new file mode 100644
index 000000000000..2cd383bd6989
--- /dev/null
+++ b/pkgs/tools/misc/minicom/default.nix
@@ -0,0 +1,18 @@
+{ stdenv, fetchurl, ncurses }:
+
+stdenv.mkDerivation rec {
+  name = "minicom-2.3";
+  
+  src = fetchurl {
+    url = "http://alioth.debian.org/frs/download.php/2332/${name}.tar.gz";
+    sha256 = "1ysn0crdhvwyvdlbw0ms5nq06xy2pd2glwjs53p384byl3ac7jra";
+  };
+
+  buildInputs = [ncurses];
+  
+  configureFlags = [ "--sysconfdir=/etc" ];
+
+  meta = {
+    description = "Serial console";
+  };
+}
diff --git a/pkgs/tools/misc/relfs/cvs.2008.03.05.nix b/pkgs/tools/misc/relfs/cvs.2008.03.05.nix
index 640e46d54f10..178aa700fa5e 100644
--- a/pkgs/tools/misc/relfs/cvs.2008.03.05.nix
+++ b/pkgs/tools/misc/relfs/cvs.2008.03.05.nix
@@ -43,7 +43,7 @@ args : with args;
 assert args.libuuid != null;
         
 stdenv.mkDerivation rec {
-	name = "relfs-"+version;
+	name = "relfs-2008.03.05";
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs ["build" "doMakeInstall" "doForceShare" "doPropagate"]);
 	meta = {
diff --git a/pkgs/tools/misc/rlwrap/0.28.nix b/pkgs/tools/misc/rlwrap/0.28.nix
index 1bd453755102..1b9bbb995acd 100644
--- a/pkgs/tools/misc/rlwrap/0.28.nix
+++ b/pkgs/tools/misc/rlwrap/0.28.nix
@@ -11,7 +11,7 @@ args : with args; with builderDefs;
 	};
 	in with localDefs;
 stdenv.mkDerivation rec {
-	name = "rlwrap-"+version;
+	name = "rlwrap-0.28";
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs 
 			[doConfigure doMakeInstall doForceShare doPropagate]);
diff --git a/pkgs/tools/misc/uucp/1.07.nix b/pkgs/tools/misc/uucp/default.nix
index 7ac48f396649..b0741311dff7 100644
--- a/pkgs/tools/misc/uucp/1.07.nix
+++ b/pkgs/tools/misc/uucp/default.nix
@@ -1,17 +1,13 @@
-args : with args; 
-rec {
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation {
+  name = "uucp-1.07";
+
   src = fetchurl {
     url = http://ftp.de.debian.org/debian/pool/main/u/uucp/uucp_1.07.orig.tar.gz;
     sha256 = "0b5nhl9vvif1w3wdipjsk8ckw49jj1w85xw1mmqi3zbcpazia306";
   };
 
-  buildInputs = [];
-  configureFlags = [];
-
-  /* doConfigure should be specified separately */
-  phaseNames = ["doConfigure" "doMakeInstall"];
-      
-  name = "uucp-" + version;
   meta = {
     description = "Unix-unix cp over serial line, also includes cu program";
   };
diff --git a/pkgs/tools/networking/nc6/1.0.nix b/pkgs/tools/networking/nc6/1.0.nix
index b6155c7a053f..5cba3ae017c8 100644
--- a/pkgs/tools/networking/nc6/1.0.nix
+++ b/pkgs/tools/networking/nc6/1.0.nix
@@ -11,7 +11,7 @@ let localDefs = builderDefs.passthru.function (rec {
     });
 in with localDefs;
 stdenv.mkDerivation rec {
-  name = "nc6-"+version;
+  name = "nc6-1.0";
   builder = writeScript (name + "-builder")
     (textClosure localDefs 
      [doConfigure doMakeInstall doForceShare doPropagate]);
diff --git a/pkgs/tools/networking/smbfs-fuse/0.8.7.nix b/pkgs/tools/networking/smbfs-fuse/0.8.7.nix
index dbd6bfc2c8c8..4b656b70388b 100644
--- a/pkgs/tools/networking/smbfs-fuse/0.8.7.nix
+++ b/pkgs/tools/networking/smbfs-fuse/0.8.7.nix
@@ -17,7 +17,7 @@ args : with args; with builderDefs;
 	};
 	in with localDefs;
 stdenv.mkDerivation rec {
-	name = "smbfs-fuse-"+version;
+	name = "smbfs-fuse-0.8.7";
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs 
 			[doConfigure doMakeInstall postInstall doForceShare doPropagate]);
diff --git a/pkgs/tools/networking/socat/1.6.0.1.nix b/pkgs/tools/networking/socat/1.6.0.1.nix
deleted file mode 100644
index 8840d134773f..000000000000
--- a/pkgs/tools/networking/socat/1.6.0.1.nix
+++ /dev/null
@@ -1,25 +0,0 @@
-args : with args; 
-rec {
-  src = /* Here a fetchurl expression goes */
-  fetchurl {
-    url = http://www.dest-unreach.org/socat/download/socat-1.6.0.1.tar.bz2;
-    sha256 = "1cl7kf0rnbvjxz8vdkmdh1crd069qmz1jjw40r8bydgpn0nsh6qd";
-  };
-
-  buildInputs = [openssl];
-  configureFlags = [];
-
-  /* doConfigure should be specified separately */
-  phaseNames = ["doPatch" "doConfigure" "doMakeInstall"];
-      
-  name = "socat-" + version;
-  meta = {
-    description = "Socat - a different replacement for netcat";
-    longDesc = "
-        Socat, one more analogue of netcat, but not mimicking it.
-	'netcat++' (extended design, new implementation)
-";
-        homepage = "http://www.dest-unreach.org/socat/";
-	srcs = patches;
-  };
-}
diff --git a/pkgs/tools/networking/socat/default.nix b/pkgs/tools/networking/socat/default.nix
new file mode 100644
index 000000000000..7669a9b2d320
--- /dev/null
+++ b/pkgs/tools/networking/socat/default.nix
@@ -0,0 +1,17 @@
+{ stdenv, fetchurl, openssl }:
+
+stdenv.mkDerivation rec {
+  name = "socat-1.6.0.1";
+  
+  src = fetchurl {
+    url = "http://www.dest-unreach.org/socat/download/${name}.tar.bz2";
+    sha256 = "1cl7kf0rnbvjxz8vdkmdh1crd069qmz1jjw40r8bydgpn0nsh6qd";
+  };
+
+  buildInputs = [openssl];
+      
+  meta = {
+    description = "Socat - a different replacement for netcat";
+    homepage = "http://www.dest-unreach.org/socat/";
+  };
+}
diff --git a/pkgs/tools/security/metasploit/3.1.nix b/pkgs/tools/security/metasploit/3.1.nix
index db4dcf3a8350..94bc009080df 100644
--- a/pkgs/tools/security/metasploit/3.1.nix
+++ b/pkgs/tools/security/metasploit/3.1.nix
@@ -22,7 +22,7 @@ rec {
   /* doConfigure should be specified separately */
   phaseNames = ["doInstall" (doPatchShebangs "$out/share/msf")];
       
-  name = "metasploit-framework" + version;
+  name = "metasploit-framework-3.1";
   meta = {
     description = "Metasploit Framework - a collection of exploits";
     homepage = "http://framework.metasploit.org/";
diff --git a/pkgs/tools/security/ssss/0.5.nix b/pkgs/tools/security/ssss/0.5.nix
index 9b460d0226c1..15288361baf4 100644
--- a/pkgs/tools/security/ssss/0.5.nix
+++ b/pkgs/tools/security/ssss/0.5.nix
@@ -18,7 +18,7 @@ args : with args; with builderDefs;
 	});
 	in with localDefs;
 stdenv.mkDerivation rec {
-	name = "ssss-"+version;
+	name = "ssss-0.5";
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs 
 			["doPatch" doMakeInstall doForceShare doPropagate]);
diff --git a/pkgs/tools/system/ddrescue/1.8.nix b/pkgs/tools/system/ddrescue/1.8.nix
deleted file mode 100644
index 01d1927573bd..000000000000
--- a/pkgs/tools/system/ddrescue/1.8.nix
+++ /dev/null
@@ -1,20 +0,0 @@
-
-args : with args; 
-rec {
-  src = fetchurl {
-    url = http://ftp.gnu.org/gnu/ddrescue/ddrescue-1.8.tar.bz2;
-    sha256 = "080k1s4knh9baw3dxr5vqjjph6dqzkfpk0kpld0a3qc07vsxmhbz";
-  };
-
-  buildInputs = [];
-  configureFlags = [];
-
-  /* doConfigure should be specified separately */
-  phaseNames = ["doConfigure" "doMakeInstall"];
-      
-  name = "ddrescue-" + version;
-  meta = {
-    description = "GNU ddrescue - advanced dd for corrupted media";
-  };
-}
-  
diff --git a/pkgs/tools/system/ddrescue/default.nix b/pkgs/tools/system/ddrescue/default.nix
new file mode 100644
index 000000000000..4ab848ad6e91
--- /dev/null
+++ b/pkgs/tools/system/ddrescue/default.nix
@@ -0,0 +1,15 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "ddrescue-1.8";
+  
+  src = fetchurl {
+    url = "http://ftp.gnu.org/gnu/ddrescue/${name}.tar.bz2";
+    sha256 = "080k1s4knh9baw3dxr5vqjjph6dqzkfpk0kpld0a3qc07vsxmhbz";
+  };
+
+  meta = {
+    description = "GNU ddrescue - advanced dd for corrupted media";
+  };
+}
+  
diff --git a/pkgs/tools/system/gdmap/0.8.1.nix b/pkgs/tools/system/gdmap/0.8.1.nix
index 982d5651f652..73d3ff923233 100644
--- a/pkgs/tools/system/gdmap/0.8.1.nix
+++ b/pkgs/tools/system/gdmap/0.8.1.nix
@@ -11,7 +11,7 @@ args : with args;
 	};
 	in with localDefs;
 stdenv.mkDerivation rec {
-	name = "gdmap-"+version;
+	name = "gdmap-0.8.1";
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs [doConfigure doMakeInstall doForceShare doPropagate]);
 	meta = {
diff --git a/pkgs/tools/text/cheetah-template/2.0.1.nix b/pkgs/tools/text/cheetah-template/2.0.1.nix
index 117e0f88a8be..c20f5db97984 100644
--- a/pkgs/tools/text/cheetah-template/2.0.1.nix
+++ b/pkgs/tools/text/cheetah-template/2.0.1.nix
@@ -11,7 +11,7 @@ rec {
   /* doConfigure should be specified separately */
   phaseNames = ["installPythonPackage" (makeManyWrappers ''$out/bin/*'' ''--prefix PYTHONPATH : $(toPythonPath $out)'')];
       
-  name = "cheetah-template-" + version;
+  name = "cheetah-template-2.0.1";
   meta = {
     description = "Templating engine";
   };
diff --git a/pkgs/tools/text/highlight/2.6.10.nix b/pkgs/tools/text/highlight/2.6.10.nix
deleted file mode 100644
index 675a996445f4..000000000000
--- a/pkgs/tools/text/highlight/2.6.10.nix
+++ /dev/null
@@ -1,20 +0,0 @@
-
-args : with args; 
-rec {
-  src = fetchurl {
-    url = http://www.andre-simon.de/zip/highlight-2.6.10.tar.bz2;
-    sha256 = "18f2ki9pajxlp0aq4ingxj7m0cp7wlbc40xm25pnxc1yis9vlira";
-  };
-
-  buildInputs = [getopt];
-  configureFlags = [];
-  makeFlags = ["PREFIX=$out"];
-
-  /* doConfigure should be specified separately */
-  phaseNames = ["doMakeInstall"];
-      
-  name = "highlight-" + version;
-  meta = {
-    description = "Source code highlighting tool";
-  };
-}
diff --git a/pkgs/tools/text/highlight/default.nix b/pkgs/tools/text/highlight/default.nix
new file mode 100644
index 000000000000..dc4c0647f41f
--- /dev/null
+++ b/pkgs/tools/text/highlight/default.nix
@@ -0,0 +1,18 @@
+{ stdenv, fetchurl, getopt }:
+        
+stdenv.mkDerivation rec {
+  name = "highlight-2.6.10";
+
+  src = fetchurl {
+    url = "http://www.andre-simon.de/zip/${name}.tar.bz2";
+    sha256 = "18f2ki9pajxlp0aq4ingxj7m0cp7wlbc40xm25pnxc1yis9vlira";
+  };
+
+  buildInputs = [getopt];
+
+  makeFlags = ["PREFIX=$out"];
+
+  meta = {
+    description = "Source code highlighting tool";
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 57d4061c7c4e..a5466a9b116e 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -76,6 +76,12 @@ let
   getConfig = attrPath: default: lib.attrByPath attrPath default config;
 
 
+  # Helper functions that are exported through `pkgs'.
+  helperFunctions = 
+    (import ../stdenv/adapters.nix { inherit (pkgs) dietlibc fetchurl runCommand; }) //
+    (import ../build-support/trivial-builders.nix { inherit (pkgs) stdenv; inherit (pkgs.xorg) lndir; });
+
+
   # Allow packages to be overriden globally via the `packageOverrides'
   # configuration option, which must be a function that takes `pkgs'
   # as an argument and returns a set of new or overriden packages.
@@ -89,11 +95,11 @@ let
 
   pkgsOrig = pkgsFun {}; # the un-overriden packages, passed to packageOverrides
   pkgsOverriden = pkgsFun __overrides; # the overriden, final packages
-  pkgs = pkgsOverriden;
+  pkgs = pkgsOverriden // helperFunctions;
 
 
   # The package compositions.  Yes, this isn't properly indented.
-  pkgsFun = __overrides: rec {
+  pkgsFun = __overrides: with helperFunctions; rec {
 
 
   inherit __overrides;
@@ -120,7 +126,7 @@ let
 
   inherit lib config getConfig;
 
-  inherit (lib) lowPrio appendToName;
+  inherit (lib) lowPrio appendToName makeOverridable;
 
   # Applying this to an attribute set will cause nix-env to look
   # inside the set for derivations.
@@ -132,29 +138,6 @@ let
   # Return the first available value in the order: pkg.val, val, or default.
   getPkgConfig = pkg : val : default : (getConfig [ pkg val ] (getConfig [ val ] default));
 
-  # Return user-choosen version of given package. If you define package as
-  #
-  # pkgname_alts =
-  # {
-  #   v_0_1 = ();
-  #   v_0_2 = ();
-  #   default = v_0_1;
-  #   recurseForDerivations = true;
-  # };
-  # pkgname = getVersion "name" pkgname_alts;
-  #
-  # user will be able to write in his configuration.nix something like
-  # name = { version = "0.2"; }; and pkgname will be equal
-  # to getAttr pkgname_alts "0.2". Using alts.default by default.
-  getVersion = name: alts: builtins.getAttr
-    (getConfig [ name "version" ] "default") alts;
-
-  # The same, another syntax.
-  # Warning: syntax for configuration.nix changed too
-  useVersion = name: f: f {
-    version = getConfig [ "environment" "versions" name ];
-  };
-
   # Check absence of non-used options
   checker = x: flag: opts: config:
     (if flag then let result=(
@@ -175,36 +158,6 @@ let
 
   stringsWithDeps = lib.stringsWithDeps;
 
-  # Call a specific version of a Nix expression, that is,
-  # `selectVersion ./foo {version = "0.1.2"; args...}' evaluates to
-  # `import ./foo/0.1.2.nix args'.
-  selectVersion = dir: defVersion: args:
-    let
-      pVersion =
-        if (args ? version && args.version != "") then
-          args.version
-        else
-          getConfig [ (baseNameOf (toString dir)) "version" ] defVersion;
-    in
-      import (dir + "/${pVersion}.nix") (args // { version = pVersion; });
-
-  deepOverride = newArgs: name: x: if builtins.isAttrs x then (
-    if x ? deepOverride then (x.deepOverride newArgs) else
-    if x ? override then (x.override newArgs) else
-    x) else x;
-    
-  # usage: (you can use override multiple times)
-  # let d = makeOverridable stdenv.mkDerivation { name = ..; buildInputs; }
-  #     noBuildInputs = d.override { buildInputs = []; }
-  #     additionalBuildInputs = d.override ( args : args // { buildInputs = args.buildInputs ++ [ additional ]; } )
-  makeOverridable = f: origArgs: f origArgs //
-    { override = newArgs:
-        makeOverridable f (origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs));
-      deepOverride = newArgs:
-        makeOverridable f ((lib.mapAttrs (deepOverride newArgs) origArgs) // newArgs);
-      origArgs = origArgs;
-    };
-
 
   ### STANDARD ENVIRONMENT
 
@@ -238,12 +191,6 @@ let
     else
       stdenv;
 
-  inherit (import ../stdenv/adapters.nix {inherit (pkgs) dietlibc fetchurl runCommand;})
-    overrideGCC overrideInStdenv overrideSetup
-    useDietLibC useKlibc makeStaticBinaries addAttrsToDerivation
-    keepBuildTree cleanupBuildTree addCoverageInstrumentation makeStdenvCross;
-
-
   ### BUILD SUPPORT
 
   attrSetToDir = arg : import ../build-support/upstream-updater/attrset-to-dir.nix {
@@ -294,7 +241,6 @@ let
     sshSupport = true;
   };
 
-  # TODO do some testing
   fetchhg = import ../build-support/fetchhg {
     inherit stdenv mercurial nix;
   };
@@ -329,11 +275,6 @@ let
     inherit stdenv perl cpio contents platform;
   };
 
-  makeSetupHook = script: runCommand "hook" {} ''
-    ensureDir $out/nix-support
-    cp ${script} $out/nix-support/setup-hook
-  '';
-
   makeWrapper = makeSetupHook ../build-support/make-wrapper/make-wrapper.sh;
 
   makeModulesClosure = {kernel, rootModules, allowMissing ? false}:
@@ -344,38 +285,6 @@ let
 
   pathsFromGraph = ../build-support/kernel/paths-from-graph.pl;
 
-  # Run the shell command `buildCommand' to produce a store object
-  # named `name'.  The attributes in `env' are added to the
-  # environment prior to running the command.
-  runCommand = name: env: buildCommand: stdenv.mkDerivation ({
-    inherit name buildCommand;
-  } // env);
-
-  symlinkJoin = name: paths: runCommand name {inherit paths;} "mkdir -p $out; for i in $paths; do ${xorg.lndir}/bin/lndir $i $out; done";
-
-  # Create a single file.
-  writeTextFile =
-    { name # the name of the derivation
-    , text
-    , executable ? false # run chmod +x ?
-    , destination ? ""   # relative path appended to $out eg "/bin/foo"
-    }:
-    runCommand name {inherit text executable; } ''
-      n=$out${destination}
-      mkdir -p "$(dirname "$n")"
-      echo -n "$text" > "$n"
-      (test -n "$executable" && chmod +x "$n") || true
-    '';
-
-  # Shorthands for `writeTextFile'.
-  writeText = name: text: writeTextFile {inherit name text;};
-  writeScript = name: text: writeTextFile {inherit name text; executable = true;};
-  writeScriptBin = name: text: writeTextFile {inherit name text; executable = true; destination = "/bin/${name}";};
-
-  # entries is a list of attribute sets like { name = "name" ; path = "/nix/store/..."; }
-  linkFarm = name: entries: runCommand name {} ("mkdir -p $out; cd $out; \n" +
-    (lib.concatMapStrings (x: "ln -s '${x.path}' '${x.name}';\n") entries));
-
   srcOnly = args: (import ../build-support/src-only) ({inherit stdenv; } // args);
 
   substituteAll = import ../build-support/substitute/substitute-all.nix {
@@ -398,21 +307,6 @@ let
     inherit pkgs lib;
   };
 
-  # Write the references (i.e. the runtime dependencies in the Nix store) of `path' to a file.
-  writeReferencesToFile = path: runCommand "runtime-deps"
-    {
-      exportReferencesGraph = ["graph" path];
-    }
-    ''
-      touch $out
-      while read path; do
-        echo $path >> $out
-        read dummy
-        read nrRefs
-        for ((i = 0; i < nrRefs; i++)); do read ref; done
-      done < graph
-    '';
-
 
   platformPC = assert system == "i686-linux" || system == "x86_64-linux"; {
     name = "pc";
@@ -545,7 +439,7 @@ let
     inherit fetchurl stdenv python wxPython26;
   };
 
-  bmrsa = builderDefsPackage (selectVersion ../tools/security/bmrsa "11") {
+  bmrsa = builderDefsPackage (import ../tools/security/bmrsa/11.nix) {
     inherit unzip;
   };
 
@@ -587,7 +481,7 @@ let
     inherit fetchurl stdenv gettext;
   };
 
-  cheetahTemplate = builderDefsPackage (selectVersion ../tools/text/cheetah-template "2.0.1") {
+  cheetahTemplate = builderDefsPackage (import ../tools/text/cheetah-template/2.0.1.nix) {
     inherit makeWrapper python;
   };
 
@@ -670,7 +564,9 @@ let
     inherit fetchurl buildPerlPackage perl;
   };
 
-  ddrescue = builderDefsPackage (selectVersion ../tools/system/ddrescue "1.8") {};
+  ddrescue = import ../tools/system/ddrescue {
+    inherit fetchurl stdenv;
+  };
 
   desktop_file_utils = import ../tools/misc/desktop-file-utils {
     inherit stdenv fetchurl pkgconfig glib;
@@ -808,7 +704,7 @@ let
       inherit fetchurl stdenv;
     });
 
-  gdmap = composedArgsAndFun (selectVersion ../tools/system/gdmap "0.8.1") {
+  gdmap = composedArgsAndFun (import ../tools/system/gdmap/0.8.1.nix) {
     inherit stdenv fetchurl builderDefs pkgconfig libxml2 intltool
       gettext;
     inherit (gtkLibs) gtk;
@@ -960,22 +856,14 @@ let
     inherit fetchurl stdenv ocaml;
   };
 
-  highlight = builderDefsPackage (selectVersion ../tools/text/highlight "2.6.10") {
-    inherit getopt;
+  highlight = import ../tools/text/highlight {
+    inherit fetchurl stdenv getopt;
   };
 
   host = import ../tools/networking/host {
     inherit fetchurl stdenv;
   };
 
-  /*
-  hyppocampusFun = lib.sumArgs ( selectVersion ../tools/misc/hyppocampus "0.3rc1") {
-    inherit builderDefs stdenv fetchurl libdbi libdbiDrivers fuse
-      pkgconfig perl gettext dbus dbus_glib pcre libscd bison glib;
-    flex = flex2533;
-  };
-  */
-
   iasl = import ../development/compilers/iasl {
     inherit fetchurl stdenv bison flex;
   };
@@ -1111,8 +999,8 @@ let
     inherit fetchurl stdenv guile which ed;
   };
 
-  mdbtools = builderDefsPackage (selectVersion ../tools/misc/mdbtools "0.6-pre1") {
-    inherit readline pkgconfig bison glib;
+  mdbtools = import ../tools/misc/mdbtools {
+    inherit fetchurl stdenv readline pkgconfig bison glib;
     flex = flex2535;
   };
 
@@ -1139,7 +1027,7 @@ let
     inherit fetchurl stdenv;
   };
 
-  msf = builderDefsPackage (selectVersion ../tools/security/metasploit "3.1") {
+  msf = builderDefsPackage (import ../tools/security/metasploit/3.1.nix) {
     inherit ruby makeWrapper;
   };
 
@@ -1187,7 +1075,7 @@ let
     inherit fetchurl stdenv pkgconfig glib;
   };
 
-  nc6 = composedArgsAndFun (selectVersion ../tools/networking/nc6 "1.0") {
+  nc6 = composedArgsAndFun (import ../tools/networking/nc6/1.0.nix) {
     inherit builderDefs;
   };
 
@@ -1410,7 +1298,7 @@ let
     inherit stdenv fetchurl;
   };
 
-  relfs = composedArgsAndFun (selectVersion ../tools/misc/relfs "cvs.2008.03.05") {
+  relfs = composedArgsAndFun (import ../tools/misc/relfs/cvs.2008.03.05.nix) {
     inherit fetchcvs stdenv ocaml postgresql fuse pcre
       builderDefs pkgconfig libuuid;
     inherit (gnome) gnomevfs GConf;
@@ -1439,7 +1327,7 @@ let
     logger = inetutils;
   };
 
-  rlwrap = composedArgsAndFun (selectVersion ../tools/misc/rlwrap "0.28") {
+  rlwrap = composedArgsAndFun (import ../tools/misc/rlwrap/0.28.nix) {
     inherit builderDefs readline;
   };
 
@@ -1492,7 +1380,7 @@ let
     inherit groff;
   };
 
-  sharutils = selectVersion ../tools/archivers/sharutils "4.6.3" {
+  sharutils = import ../tools/archivers/sharutils/4.6.3.nix {
     inherit fetchurl stdenv;
   };
 
@@ -1508,12 +1396,12 @@ let
     inherit fetchurl stdenv;
   };
 
-  smbfsFuse = composedArgsAndFun (selectVersion ../tools/networking/smbfs-fuse "0.8.7") {
+  smbfsFuse = composedArgsAndFun (import ../tools/networking/smbfs-fuse/0.8.7.nix) {
     inherit builderDefs samba fuse;
   };
 
-  socat = builderDefsPackage (selectVersion ../tools/networking/socat "1.6.0.1") {
-    inherit openssl;
+  socat = import ../tools/networking/socat {
+    inherit fetchurl stdenv openssl;
   };
 
   sudo = import ../tools/security/sudo {
@@ -1538,7 +1426,7 @@ let
     tlsSupport = true;
   };
 
-  ssss = composedArgsAndFun (selectVersion ../tools/security/ssss "0.5") {
+  ssss = composedArgsAndFun (import ../tools/security/ssss/0.5.nix) {
     inherit builderDefs gmp;
   };
 
@@ -1799,11 +1687,8 @@ let
     inherit fetchurl stdenv ncurses;
   };
 
-  zsh = composedArgsAndFun (selectVersion ../shells/zsh "4.3.9") {
+  zsh = import ../shells/zsh {
     inherit fetchurl stdenv ncurses coreutils;
-    # for CVS:
-    inherit (bleedingEdgeRepos) sourceByName;
-    inherit autoconf yodl;
   };
 
 
@@ -2119,6 +2004,10 @@ let
     inherit cmake;
   };
 
+  go = import ../development/compilers/go {
+    inherit stdenv fetchhg glibc bison ed which bash makeWrapper;
+  };
+
   gprolog = import ../development/compilers/gprolog {
     inherit fetchurl stdenv;
   };
@@ -2130,8 +2019,8 @@ let
     libstdcpp5 = gcc33.gcc;
   };
 
-  ikarus = builderDefsPackage (selectVersion ../development/compilers/ikarus "0.0.3") {
-    inherit gmp;
+  ikarus = import ../development/compilers/ikarus {
+    inherit stdenv fetchurl gmp;
   };
 
   #TODO add packages http://cvs.haskell.org/Hugs/downloads/2006-09/packages/ and test
@@ -2206,12 +2095,12 @@ let
     lua = lua5;
   };
 
-  monotoneViz = builderDefsPackage (selectVersion ../applications/version-management/monotone-viz "mtn-head") {
+  monotoneViz = builderDefsPackage (import ../applications/version-management/monotone-viz/mtn-head.nix) {
     inherit ocaml lablgtk graphviz pkgconfig autoconf automake libtool;
     inherit (gnome) gtk libgnomecanvas glib;
   };
 
-  viewMtn = builderDefsPackage (selectVersion ../applications/version-management/viewmtn "0.10")
+  viewMtn = builderDefsPackage (import ../applications/version-management/viewmtn/0.10.nix)
   {
     inherit monotone flup cheetahTemplate highlight ctags
       makeWrapper graphviz which python;
@@ -2288,10 +2177,10 @@ let
   };
 
   metaBuildEnv = import ../development/compilers/meta-environment/meta-build-env {
-    inherit fetchurl stdenv ;
+    inherit fetchurl stdenv;
   };
 
-  swiProlog = composedArgsAndFun (selectVersion ../development/compilers/swi-prolog "5.6.51") {
+  swiProlog = import ../development/compilers/swi-prolog {
     inherit fetchurl stdenv;
   };
 
@@ -2523,7 +2412,7 @@ let
     inherit fetchurl stdenv stringsWithDeps lib builderDefs python;
   };
 
-  Qi = composedArgsAndFun (selectVersion ../development/compilers/qi "9.1") {
+  Qi = composedArgsAndFun (import ../development/compilers/qi/9.1.nix) {
     inherit clisp stdenv fetchurl builderDefs unzip;
   };
 
@@ -2935,7 +2824,7 @@ let
     inherit fetchurl stdenv;
   };
 
-  ltrace = composedArgsAndFun (selectVersion ../development/tools/misc/ltrace "0.5-3deb") {
+  ltrace = composedArgsAndFun (import ../development/tools/misc/ltrace/0.5-3deb.nix) {
     inherit fetchurl stdenv builderDefs stringsWithDeps lib elfutils;
   };
 
@@ -3068,7 +2957,7 @@ let
     inherit fetchurl stdenv perl gdb;
   };
 
-  xxdiff = builderDefsPackage (selectVersion ../development/tools/misc/xxdiff "3.2") {
+  xxdiff = builderDefsPackage (import ../development/tools/misc/xxdiff/3.2.nix) {
     flex = flex2535;
     qt = qt3;
     inherit pkgconfig makeWrapper bison python;
@@ -3098,7 +2987,7 @@ let
       inherit stdenv fetchurl gettext attr libtool;
     });
 
-  adns = selectVersion ../development/libraries/adns "1.4" {
+  adns = import ../development/libraries/adns/1.4.nix {
     inherit stdenv fetchurl;
     static = getPkgConfig "adns" "static" (stdenv ? isStatic || stdenv ? isDietLibC);
   };
@@ -3328,9 +3217,7 @@ let
       libXrender;
   };
 
-  enchant = makeOverridable
-      (selectVersion ../development/libraries/enchant "1.3.0")
-  {
+  enchant = makeOverridable (import ../development/libraries/enchant) {
     inherit fetchurl stdenv aspell pkgconfig;
     inherit (gnome) glib;
   };
@@ -3605,7 +3492,7 @@ let
   };
 
   gst_all = recurseIntoAttrs (import ../development/libraries/gstreamer {
-    inherit lib selectVersion stdenv fetchurl perl bison pkgconfig libxml2
+    inherit lib stdenv fetchurl perl bison pkgconfig libxml2
       python alsaLib cdparanoia libogg libvorbis libtheora freetype liboil
       libjpeg zlib speex libpng libdv aalib cairo libcaca flac hal libiec61883
       dbus libavc1394 ladspaH taglib pulseaudio gdbm bzip2 which makeOverridable;
@@ -3808,6 +3695,10 @@ let
     inherit stdenv fetchurl gettext python;
   };
 
+  jamp = builderDefsPackage ../games/jamp {
+    inherit mesa SDL SDL_image SDL_mixer;
+  };
+
   jasper = import ../development/libraries/jasper {
     inherit fetchurl stdenv unzip xlibs libjpeg;
   };
@@ -3903,15 +3794,13 @@ let
     inherit fetchurl stdenv;
   };
 
-  libdbi = composedArgsAndFun (selectVersion ../development/libraries/libdbi "0.8.2") {
+  libdbi = composedArgsAndFun (import ../development/libraries/libdbi/0.8.2.nix) {
     inherit stdenv fetchurl builderDefs;
   };
 
-  libdbiDriversBase = composedArgsAndFun
-    (selectVersion ../development/libraries/libdbi-drivers "0.8.2-1")
-    {
-      inherit stdenv fetchurl builderDefs libdbi;
-    };
+  libdbiDriversBase = composedArgsAndFun (import ../development/libraries/libdbi-drivers/0.8.2-1.nix) {
+    inherit stdenv fetchurl builderDefs libdbi;
+  };
 
   libdbiDrivers = libdbiDriversBase.passthru.function {
     inherit sqlite mysql;
@@ -3961,7 +3850,7 @@ let
     inherit fetchurl stdenv gettext;
   };
 
-  libextractor = composedArgsAndFun (selectVersion ../development/libraries/libextractor "0.5.18") {
+  libextractor = composedArgsAndFun (import ../development/libraries/libextractor/0.5.18.nix) {
     inherit fetchurl stdenv builderDefs zlib;
   };
 
@@ -4037,7 +3926,7 @@ let
     inherit fetchurl stdenv pkgconfig libraw1394;
   };
 
-  libjingle = selectVersion ../development/libraries/libjingle "0.3.11" {
+  libjingle = import ../development/libraries/libjingle/0.3.11.nix {
     inherit fetchurl stdenv mediastreamer;
   };
 
@@ -4122,12 +4011,6 @@ let
     inherit fetchurl stdenv pkgconfig ncurses glib;
   };
 
-  /*libscdFun = lib.sumArgs (selectVersion ../development/libraries/libscd "0.4.2") {
-    inherit stdenv fetchurl builderDefs libextractor perl pkgconfig;
-  };
-
-  libscd = libscdFun null;*/
-
   libsigcxx = import ../development/libraries/libsigcxx {
     inherit fetchurl stdenv pkgconfig;
   };
@@ -4272,8 +4155,7 @@ let
   };
 
   # failed to build
-  mediastreamer = composedArgsAndFun (selectVersion
-      ../development/libraries/mediastreamer "2.2.0-cvs20080207") {
+  mediastreamer = composedArgsAndFun (import ../development/libraries/mediastreamer/2.2.0-cvs20080207.nix) {
     inherit fetchurl stdenv automake libtool autoconf alsaLib pkgconfig speex
       ortp ffmpeg;
   };
@@ -4300,7 +4182,7 @@ let
     inherit fetchurl stdenv;
   };
 
-  msilbc = selectVersion ../development/libraries/msilbc "2.0.0" {
+  msilbc = import ../development/libraries/msilbc {
     inherit fetchurl stdenv ilbc mediastreamer pkgconfig;
   };
 
@@ -4526,12 +4408,17 @@ let
   };
 
   # Also known as librdf, includes raptor and rasqal
-  redland = composedArgsAndFun (selectVersion ../development/libraries/redland "1.0.9") {
+  redland = composedArgsAndFun (import ../development/libraries/redland/1.0.9.nix) {
+    inherit fetchurl stdenv openssl libxml2 pkgconfig perl postgresql sqlite
+      mysql libxslt curl pcre librdf_rasqal librdf_raptor;
+    bdb = db4;
+  };
+
+  redland_1_0_8 = composedArgsAndFun (import ../development/libraries/redland/1.0.8.nix) {
     inherit fetchurl stdenv openssl libxml2 pkgconfig perl postgresql sqlite
       mysql libxslt curl pcre librdf_rasqal librdf_raptor;
     bdb = db4;
   };
-  redland_1_0_8 = redland.passthru.function { version = "1.0.8"; };
 
   rhino = import ../development/libraries/java/rhino {
     inherit fetchurl stdenv unzip;
@@ -4639,7 +4526,7 @@ let
     inherit stdenv fetchurl cmake qt4;
   };
 
-  tk = composedArgsAndFun (selectVersion ../development/libraries/tk "8.5.7") {
+  tk = import ../development/libraries/tk/8.5.7.nix {
     inherit fetchurl stdenv tcl x11;
   };
 
@@ -4686,16 +4573,12 @@ let
     inherit (xlibs) libXinerama libSM libXxf86vm xf86vidmodeproto;
   };
 
-  wxGTK28fun = lib.sumArgs (import ../development/libraries/wxGTK-2.8);
-
-  wxGTK28deps = wxGTK28fun {
+  wxGTK28 = makeOverridable (import ../development/libraries/wxGTK-2.8) {
     inherit fetchurl stdenv pkgconfig mesa;
     inherit (gtkLibs216) gtk;
     inherit (xlibs) libXinerama libSM libXxf86vm xf86vidmodeproto;
   };
 
-  wxGTK28 = wxGTK28deps null;
-
   wtk = import ../development/libraries/wtk {
       inherit fetchurl stdenv unzip xlibs;
     };
@@ -4704,12 +4587,11 @@ let
     inherit fetchurl stdenv;
   };
 
-
-  xapian = makeOverridable (selectVersion ../development/libraries/xapian "1.0.14") {
+  xapian = makeOverridable (import ../development/libraries/xapian) {
     inherit fetchurl stdenv zlib;
   };
 
-  xapianBindings = (selectVersion ../development/libraries/xapian/bindings "1.0.14") {
+  xapianBindings = (import ../development/libraries/xapian/bindings/1.0.14.nix) {
     inherit fetchurl stdenv xapian composableDerivation pkgconfig;
     inherit ruby perl php tcl python; # TODO perl php Java, tcl, C#, python
   };
@@ -4909,12 +4791,11 @@ let
     inherit fetchurl stdenv python db4;
   };
 
-  flup = builderDefsPackage (selectVersion ../development/python-modules/flup "r2311")
-  (let python=python25; in
-  {
-    inherit python;
-    setuptools = setuptools.passthru.function {inherit python;};
-  });
+  flup = import ../development/python-modules/flup {
+    inherit fetchurl stdenv;
+    python = python25;
+    setuptools = setuptools.passthru.function {python = python25;};
+  };
 
   numeric = import ../development/python-modules/numeric {
     inherit fetchurl stdenv python;
@@ -4968,7 +4849,7 @@ let
     inherit python openssl;
   };
 
-  pythonSip = builderDefsPackage (selectVersion ../development/python-modules/python-sip "4.7.4") {
+  pythonSip = builderDefsPackage (import ../development/python-modules/python-sip/4.7.4.nix) {
     inherit python;
   };
 
@@ -4980,7 +4861,7 @@ let
     inherit stdenv fetchurl lib python;
   };
 
-  pyqt = builderDefsPackage (selectVersion ../development/python-modules/pyqt "4.3.3") {
+  pyqt = builderDefsPackage (import ../development/python-modules/pyqt/4.3.3.nix) {
     inherit pkgconfig python pythonSip glib;
     inherit (xlibs) libX11 libXext;
     qt = qt4;
@@ -5038,7 +4919,7 @@ let
     inherit fetchurl stdenv python cheetahTemplate makeWrapper par2cmdline unzip unrar;
   };
 
-  bind = builderDefsPackage (selectVersion ../servers/dns/bind "9.5.0") {
+  bind = builderDefsPackage (import ../servers/dns/bind/9.5.0.nix) {
     inherit openssl libtool;
   };
 
@@ -5046,7 +4927,7 @@ let
     inherit fetchurl stdenv libtool gettext zlib readline guile python;
   };
 
-  dict = composedArgsAndFun (selectVersion ../servers/dict "1.9.15") {
+  dict = composedArgsAndFun (import ../servers/dict/1.9.15.nix) {
     inherit builderDefs which bison;
     flex=flex2534;
   };
@@ -5067,8 +4948,7 @@ let
   };
 
   ejabberd = import ../servers/xmpp/ejabberd {
-    inherit fetchurl stdenv expat erlang zlib openssl
-      pam fetchsvn;
+    inherit fetchurl stdenv expat erlang zlib openssl pam lib;
   };
 
   couchdb = import ../servers/http/couchdb {
@@ -5307,18 +5187,6 @@ let
     inherit stdenv fetchurl alsaLib gettext ncurses;
   };
 
-  /*
-  # Will maybe move to kernelPackages properly later.
-
-  blcr = builderDefsPackage (selectVersion ../os-specific/linux/blcr "0.6.5"){
-    inherit perl;
-  };
-
-  blcrCurrent = kernel : (blcr.passthru.function {
-    inherit kernel;
-  });
-  */
-
   bluez = import ../os-specific/linux/bluez {
     inherit fetchurl stdenv pkgconfig dbus libusb alsaLib glib;
   };
@@ -5380,7 +5248,7 @@ let
 
   libuuid = if stdenv.system != "i686-darwin" then utillinuxng else null;
 
-  e2fsprogs = import ../os-specific/linux/e2fsprogs/default.nix {
+  e2fsprogs = import ../os-specific/linux/e2fsprogs {
     inherit fetchurl stdenv pkgconfig libuuid;
   };
 
@@ -5408,8 +5276,8 @@ let
     inherit fetchurl stdenv;
   };
 
-  gpm = builderDefsPackage (selectVersion ../servers/gpm "1.20.6") {
-    inherit lzma ncurses bison;
+  gpm = import ../servers/gpm {
+    inherit fetchurl stdenv ncurses bison;
     flex = flex2535;
   };
 
@@ -5487,8 +5355,8 @@ let
     inherit fetchurl stdenv;
   };
 
-  jfsrec = builderDefsPackage (selectVersion ../os-specific/linux/jfsrec "svn-7"){
-    inherit boost;
+  jfsrec = import ../os-specific/linux/jfsrec {
+    inherit fetchurl stdenv boost;
   };
 
   jfsutils = import ../os-specific/linux/jfsutils/default.nix {
@@ -5720,7 +5588,7 @@ let
        then iwlwifi4965ucodeV2
        else iwlwifi4965ucodeV1);
 
-    atheros = composedArgsAndFun (selectVersion ../os-specific/linux/atheros "0.9.4") {
+    atheros = composedArgsAndFun (import ../os-specific/linux/atheros/0.9.4.nix) {
       inherit fetchurl stdenv builderDefs kernel lib;
     };
 
@@ -5736,8 +5604,8 @@ let
       inherit fetchurl stdenv kernel ncurses fxload;
     };
 
-    kqemu = builderDefsPackage (selectVersion ../os-specific/linux/kqemu "1.4.0pre1") {
-      inherit kernel perl;
+    kqemu = import ../os-specific/linux/kqemu/1.4.0pre1.nix {
+      inherit fetchurl stdenv kernel perl;
     };
 
     splashutils =
@@ -6193,7 +6061,7 @@ let
     inherit (xorg) mkfontdir mkfontscale;
   });
 
-  clearlyU = composedArgsAndFun (selectVersion ../data/fonts/clearlyU "1.9") {
+  clearlyU = composedArgsAndFun (import ../data/fonts/clearlyU/1.9.nix) {
     inherit builderDefs;
     inherit (xorg) mkfontdir mkfontscale;
   };
@@ -6239,7 +6107,7 @@ let
     inherit fetchurl stdenv;
   };
 
-  junicode = composedArgsAndFun (selectVersion ../data/fonts/junicode "0.6.15") {
+  junicode = composedArgsAndFun (import ../data/fonts/junicode/0.6.15.nix) {
     inherit builderDefs fontforge unzip;
     inherit (xorg) mkfontdir mkfontscale;
   };
@@ -6252,13 +6120,14 @@ let
     inherit fetchurl stdenv;
   };
 
-  libertine = builderDefsPackage (selectVersion ../data/fonts/libertine "2.7") {
+  libertine = builderDefsPackage (import ../data/fonts/libertine/2.7.nix) {
     inherit fontforge;
   };
-  libertineBin = builderDefsPackage (selectVersion ../data/fonts/libertine "2.7.bin") {
+  libertineBin = builderDefsPackage (import ../data/fonts/libertine/2.7.bin.nix) {
   };
 
-  lmodern = builderDefsPackage (selectVersion ../data/fonts/lmodern "1.010") {
+  lmodern = import ../data/fonts/lmodern {
+    inherit fetchurl stdenv;
   };
 
   manpages = import ../data/documentation/man-pages {
@@ -6327,7 +6196,7 @@ let
     inherit fetchurl stdenv cabextract;
   };
 
-  wqy_zenhei = composedArgsAndFun (selectVersion ../data/fonts/wqy_zenhei "0.4.23-1") {
+  wqy_zenhei = composedArgsAndFun (import ../data/fonts/wqy_zenhei/0.4.23-1.nix) {
     inherit builderDefs;
   };
 
@@ -6497,7 +6366,7 @@ let
     inherit fetchurl stdenv ncurses;
   };
 
-  carrier = builderDefsPackage (selectVersion ../applications/networking/instant-messengers/carrier "2.5.0") {
+  carrier = builderDefsPackage (import ../applications/networking/instant-messengers/carrier/2.5.0.nix) {
     inherit fetchurl stdenv pkgconfig perl perlXMLParser libxml2 openssl nss
       gtkspell aspell gettext ncurses avahi dbus dbus_glib python
       libtool automake autoconf;
@@ -6614,7 +6483,7 @@ let
     fltk = fltk11;
   };
 
-  codeville = builderDefsPackage (selectVersion ../applications/version-management/codeville "0.8.0") {
+  codeville = builderDefsPackage (import ../applications/version-management/codeville/0.8.0.nix) {
     inherit makeWrapper;
     python = pythonFull;
   };
@@ -6718,13 +6587,13 @@ let
   #      p.viPlugin # vim keybindings (see license)
   #   ];
   #};
-  eclipseNew = (selectVersion ../applications/editors/eclipse-new "3.3.1.1" {
+  eclipseNew = import ../applications/editors/eclipse-new/3.3.1.1.nix {
     # outdated, but 3.3.1.1 does already compile on nix, feel free to work 3.4
-    inherit fetchurl stdenv makeWrapper jdk unzip ant selectVersion buildEnv
+    inherit fetchurl stdenv makeWrapper jdk unzip ant buildEnv
     getConfig lib zip writeTextFile runCommand;
     inherit (gtkLibs) gtk glib;
     inherit (xlibs) libXtst;
-  });
+  };
 
 
   eclipse = plugins:
@@ -6764,21 +6633,7 @@ let
     inherit fetchurl stdenv ncurses;
   };
 
-  emacs = emacs22;
-
-  emacs21 = import ../applications/editors/emacs-21 {
-    inherit fetchurl stdenv ncurses x11 Xaw3d;
-    inherit (xlibs) libXaw libXpm;
-    xaw3dSupport = true;
-  };
-
-  emacs22 = import ../applications/editors/emacs-22 {
-    inherit fetchurl stdenv ncurses pkgconfig x11 Xaw3d;
-    inherit (xlibs) libXaw libXpm;
-    inherit (gtkLibs) gtk;
-    xaw3dSupport = getPkgConfig "emacs" "xaw3dSupport" false;
-    gtkGUI = getPkgConfig "emacs" "gtkSupport" true;
-  };
+  emacs = emacs23;
 
   emacs23 = import ../applications/editors/emacs-23 {
     inherit fetchurl stdenv ncurses pkgconfig x11 Xaw3d
@@ -6873,12 +6728,8 @@ let
     };
   });
 
-  emacs22Packages = emacsPackages emacs22;
   emacs23Packages = emacsPackages emacs23;
 
-  # The forthcoming GNU Emacs 23 used to be referred to as `emacsUnicode' here.
-  emacsUnicode = emacs23;
-
   evince = makeOverridable (import ../applications/misc/evince) {
     inherit fetchurl stdenv perl perlXMLParser gettext intltool
       pkgconfig poppler libspectre djvulibre libxslt
@@ -6893,7 +6744,7 @@ let
     openexr = openexr_1_6_1;
   };
 
-  fbpanel = composedArgsAndFun (selectVersion ../applications/window-managers/fbpanel "4.12") {
+  fbpanel = composedArgsAndFun (import ../applications/window-managers/fbpanel/4.12.nix) {
     inherit fetchurl stdenv builderDefs pkgconfig libpng libjpeg libtiff librsvg;
     inherit (gtkLibs) gtk;
     inherit (xlibs) libX11 libXmu libXpm;
@@ -7076,7 +6927,7 @@ let
     gtkSupport = getConfig [ "gnunet" "gtkSupport" ] true;
   };
 
-  gocr = composedArgsAndFun (selectVersion ../applications/graphics/gocr "0.44") {
+  gocr = composedArgsAndFun (import ../applications/graphics/gocr/0.44.nix) {
     inherit builderDefs fetchurl stdenv;
   };
 
@@ -7290,14 +7141,6 @@ let
     qt = qt3;
   };
 
-  /*kiwixBuilderFun = lib.sumArgs (import ../applications/misc/kiwixbuilder) {
-    inherit builderDefs;
-    inherit (gnome) glib;
-    zlib = zlibStatic;
-  };
-
-  kiwixBuilder = kiwixBuilderFun null;*/
-
   konversation = import ../applications/networking/irc/konversation {
     inherit fetchurl stdenv perl arts kdelibs zlib libpng libjpeg expat;
     inherit (xlibs) libX11 libXt libXext libXrender libXft;
@@ -7360,8 +7203,12 @@ let
   };
 
   mercurial = import ../applications/version-management/mercurial {
-    inherit fetchurl stdenv python makeWrapper getConfig tk;
+    inherit fetchurl stdenv makeWrapper getConfig tk;
     guiSupport = getConfig ["mercurial" "guiSupport"] false; # for hgk (gitk gui for hg)
+    python = # allow cloning sources from https servers.
+      if getConfig ["mercurial" "httpsSupport"] true
+      then pythonFull
+      else pythonBase;
   };
 
   meshlab = import ../applications/graphics/meshlab {
@@ -7376,8 +7223,8 @@ let
     inherit (gnome28) gtksourceview libsoup;
   };
 
-  minicom = builderDefsPackage (selectVersion ../tools/misc/minicom "2.3") {
-    inherit ncurses;
+  minicom = import ../tools/misc/minicom {
+    inherit fetchurl stdenv ncurses;
   };
 
   monodevelop = import ../applications/editors/monodevelop {
@@ -7589,8 +7436,7 @@ let
     inherit fetchsvn SDL zlib which stdenv;
   };
 
-  qemuImage = composedArgsAndFun
-    (selectVersion ../applications/virtualization/qemu/linux-img "0.2") {
+  qemuImage = composedArgsAndFun (import ../applications/virtualization/qemu/linux-img/0.2.nix) {
     inherit builderDefs fetchurl stdenv;
   };
 
@@ -7813,7 +7659,8 @@ let
     inherit (xorg) xset fontschumachermisc;
   };
 
-  uucp = builderDefsPackage (selectVersion ../tools/misc/uucp "1.07") {
+  uucp = import ../tools/misc/uucp {
+    inherit fetchurl stdenv;
   };
 
   uzbl = builderDefsPackage (import ../applications/networking/browsers/uzbl) {
@@ -7924,7 +7771,7 @@ let
        );
   };
 
-  x11vnc = composedArgsAndFun (selectVersion ../tools/X11/x11vnc "0.9.3") {
+  x11vnc = composedArgsAndFun (import ../tools/X11/x11vnc/0.9.3.nix) {
     inherit builderDefs openssl zlib libjpeg ;
     inherit (xlibs) libXfixes fixesproto libXdamage damageproto
       libX11 xproto libXtst libXinerama xineramaproto libXrandr randrproto
@@ -7932,7 +7779,7 @@ let
       libXrender;
   };
 
-  x2vnc = composedArgsAndFun (selectVersion ../tools/X11/x2vnc "1.7.2") {
+  x2vnc = composedArgsAndFun (import ../tools/X11/x2vnc/1.7.2.nix) {
     inherit builderDefs;
     inherit (xlibs) libX11 xproto xextproto libXext libXrandr randrproto;
   };
@@ -8080,7 +7927,7 @@ let
   };
 
   # doesn't compile yet - in case someone else want's to continue ..
-  qgis =  (selectVersion ../applications/misc/qgis "1.0.1-2") {
+  qgis = (import ../applications/misc/qgis/1.0.1-2.nix) {
     inherit composableDerivation fetchsvn stdenv flex lib
             ncurses fetchurl perl cmake gdal geos proj x11
             gsl libpng zlib bison
@@ -8120,7 +7967,7 @@ let
     inherit fetchurl stdenv python pygame twisted lib numeric makeWrapper;
   };
 
-  construoBase = composedArgsAndFun (selectVersion ../games/construo "0.2.2") {
+  construoBase = composedArgsAndFun (import ../games/construo/0.2.2.nix) {
     inherit stdenv fetchurl builderDefs
       zlib;
     inherit (xlibs) libX11 xproto;
@@ -8151,12 +7998,12 @@ let
     inherit stdenv fetchurl pkgconfig mesa;
     inherit (gtkLibs) glib gtk;
     inherit (xlibs) libX11 xproto;
-    wxGTK = wxGTK28deps {unicode = false;};
+    wxGTK = wxGTK28.override {unicode = false;};
   };
 
   fsgAltBuild = import ../games/fsg/alt-builder.nix {
     inherit stdenv fetchurl mesa;
-    wxGTK = wxGTK28deps {unicode = false;};
+    wxGTK = wxGTK28.override {unicode = false;};
     inherit (xlibs) libX11 xproto;
     inherit stringsWithDeps builderDefs;
   };
@@ -8236,7 +8083,7 @@ let
   };
 
   # You still can override by passing more arguments.
-  spaceOrbit = composedArgsAndFun (selectVersion ../games/orbit "1.01") {
+  spaceOrbit = composedArgsAndFun (import ../games/orbit/1.01.nix) {
     inherit fetchurl stdenv builderDefs mesa freeglut;
     inherit (gnome) esound;
     inherit (xlibs) libXt libX11 libXmu libXi libXext;
@@ -8579,7 +8426,7 @@ let
     inherit fetchurl stdenv unzip;
   };
 
-  nix = import ../tools/package-management/nix {
+  nix = makeOverridable (import ../tools/package-management/nix) {
     inherit fetchurl stdenv perl curl bzip2 openssl;
     aterm = aterm242fixes;
     db4 = db45;
@@ -8652,12 +8499,11 @@ let
     inherit fetchurl stdenv tetex lazylist;
   };
 
-  psi = (selectVersion ../applications/networking/instant-messengers/psi "0.12.1")
-    {
-      inherit stdenv fetchurl zlib aspell sox openssl qt4;
-      inherit (xlibs) xproto libX11 libSM libICE;
-      qca2 = kde4.qca2;
-    };
+  psi = (import ../applications/networking/instant-messengers/psi) {
+    inherit stdenv fetchurl zlib aspell sox qt4;
+    inherit (xlibs) xproto libX11 libSM libICE;
+    qca2 = kde4.qca2;
+  };
 
   putty = import ../applications/networking/remote/putty {
     inherit stdenv fetchurl ncurses;
diff --git a/pkgs/top-level/make-tarball.nix b/pkgs/top-level/make-tarball.nix
index e4257ed243b3..1b04e68c2b6c 100644
--- a/pkgs/top-level/make-tarball.nix
+++ b/pkgs/top-level/make-tarball.nix
@@ -18,7 +18,7 @@ releaseTools.makeSourceTarball {
     libxml2 # Needed for the release notes.
     libxslt
     w3m
-    nixUnstable # Needed to check whether the expressions are valid.
+    nix # Needed to check whether the expressions are valid.
     tetex dblatex
   ];
 
diff --git a/pkgs/top-level/perl-packages.nix b/pkgs/top-level/perl-packages.nix
index f880a691b42b..7dc0af1d5326 100644
--- a/pkgs/top-level/perl-packages.nix
+++ b/pkgs/top-level/perl-packages.nix
@@ -939,6 +939,14 @@ rec {
     propagatedBuildInputs = [DigestSHA1];
   };
 
+  DigestSHA = buildPerlPackage rec {
+    name = "Digest-SHA-5.47";
+    src = fetchurl {
+      url = "mirror://cpan/authors/id/M/MS/MSHELOR/${name}.tar.gz";
+      sha256 = "1xk9hdds4dk5iklxr8fdfbgfvd8cwgcjh5jqmjxhaw57ss2dh5wx";
+    };
+  };
+
   DigestSHA1 = buildPerlPackage {
     name = "Digest-SHA1-2.11";
     src = fetchurl {
diff --git a/pkgs/top-level/release.nix b/pkgs/top-level/release.nix
index 060f389e9e04..83891984096d 100644
--- a/pkgs/top-level/release.nix
+++ b/pkgs/top-level/release.nix
@@ -146,7 +146,6 @@ in {
   e2fsprogs = linux;
   ejabberd = linux;
   elinks = linux;
-  emacs22 = gtkSupported;
   emacs23 = gtkSupported;
   enscript = all;
   eprover = linux;
@@ -436,16 +435,13 @@ in {
     tools = linux;
   };
 
-  emacs22Packages = {
+  emacs23Packages = {
     bbdb = linux;
     cedet = linux;
     ecb = linux;
     emacsw3m = linux;
     emms = linux;
     nxml = all;
-  };
-
-  emacs23Packages = emacs22Packages // {
     jdee = linux;
   };