about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xmaintainers/scripts/gnu/gnupdate1
-rw-r--r--maintainers/scripts/gnu/gnupdate.scm712
-rw-r--r--pkgs/applications/audio/mpg123/default.nix23
-rw-r--r--pkgs/applications/editors/ed/default.nix4
-rw-r--r--pkgs/applications/editors/nvi/default.nix2
-rw-r--r--pkgs/applications/editors/vim/configurable.nix10
-rw-r--r--pkgs/applications/editors/vim/default.nix15
-rw-r--r--pkgs/applications/misc/simgrid/default.nix59
-rw-r--r--pkgs/applications/networking/browsers/elinks/default.nix10
-rw-r--r--pkgs/applications/networking/browsers/firefox/3.6.nix18
-rw-r--r--pkgs/applications/networking/browsers/firefox/xulrunner-1.9.2_beta4-mips-bus-error.patch26
-rw-r--r--pkgs/applications/networking/browsers/firefox/xulrunner-chromium-mips.patch207
-rw-r--r--pkgs/applications/networking/browsers/firefox/xulrunner-mips-n32.patch764
-rw-r--r--pkgs/applications/networking/browsers/lynx/default.nix1
-rw-r--r--pkgs/applications/networking/browsers/rekonq/source.nix28
-rw-r--r--pkgs/applications/networking/browsers/w3m/default.nix4
-rw-r--r--pkgs/applications/networking/browsers/w3m/newgc.patch15
-rw-r--r--pkgs/applications/networking/p2p/mldonkey/default.nix6
-rw-r--r--pkgs/applications/networking/p2p/mldonkey/gcc44mips64.patch103
-rw-r--r--pkgs/applications/science/math/yacas/default.nix21
-rw-r--r--pkgs/applications/version-management/fossil/default.nix4
-rw-r--r--pkgs/applications/video/MPlayer/default.nix55
-rw-r--r--pkgs/applications/window-managers/icewm/default.nix13
-rw-r--r--pkgs/build-support/fetchurl/mirrors.nix5
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/builder.sh31
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/default.nix20
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh16
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/setup-hook.sh6
-rw-r--r--pkgs/build-support/gcc-wrapper/default.nix1
-rw-r--r--pkgs/build-support/gcc-wrapper/default2.nix72
-rw-r--r--pkgs/build-support/gcc-wrapper/ld-wrapper.sh30
-rw-r--r--pkgs/build-support/gcc-wrapper/ld-wrapper2.sh154
-rw-r--r--pkgs/desktops/gnome-2.28/default.nix2
-rw-r--r--pkgs/desktops/gnome-2.28/desktop/scrollkeeper/default.nix6
-rw-r--r--pkgs/desktops/kde-4.4/support/phonon/phonon-4.4.1-gst-plugins-include.patch263
-rw-r--r--pkgs/development/compilers/gcc-4.4/builder.sh35
-rw-r--r--pkgs/development/compilers/gcc-4.4/default.nix48
-rw-r--r--pkgs/development/compilers/gcc-4.5/builder.sh72
-rw-r--r--pkgs/development/compilers/gcc-4.5/default.nix73
-rw-r--r--pkgs/development/compilers/gcc-4.5/dragonegg-2.7.patch46
-rw-r--r--pkgs/development/compilers/gcc-4.5/softfp-hurd.patch32
-rw-r--r--pkgs/development/compilers/gcc-4.5/sources.nix14
-rw-r--r--pkgs/development/compilers/nasm/default.nix6
-rw-r--r--pkgs/development/compilers/ocaml/3.11.1.nix10
-rw-r--r--pkgs/development/interpreters/guile/cpp-4.5.patch24
-rw-r--r--pkgs/development/interpreters/guile/default.nix4
-rw-r--r--pkgs/development/libraries/SDL/default.nix25
-rw-r--r--pkgs/development/libraries/aalib/default.nix8
-rw-r--r--pkgs/development/libraries/acl/default.nix24
-rw-r--r--pkgs/development/libraries/attr/default.nix14
-rw-r--r--pkgs/development/libraries/boehm-gc/default.nix11
-rw-r--r--pkgs/development/libraries/cloog-ppl/default.nix24
-rw-r--r--pkgs/development/libraries/cyrus-sasl/default.nix3
-rw-r--r--pkgs/development/libraries/ffmpeg/default.nix39
-rw-r--r--pkgs/development/libraries/gdbm/default.nix7
-rw-r--r--pkgs/development/libraries/gettext/0.18.nix66
-rw-r--r--pkgs/development/libraries/gettext/default.nix14
-rw-r--r--pkgs/development/libraries/glib/2.24.x.nix3
-rw-r--r--pkgs/development/libraries/glibc-2.11/builder.sh41
-rw-r--r--pkgs/development/libraries/glibc-2.11/locale-override.patch72
-rw-r--r--pkgs/development/libraries/glibc-2.11/mod_nano.patch31
-rw-r--r--pkgs/development/libraries/glibc-2.11/nss-skip-unavail.patch25
-rw-r--r--pkgs/development/libraries/glibc-2.12/builder.sh (renamed from pkgs/development/libraries/glibc-2.11/builder2.sh)3
-rw-r--r--pkgs/development/libraries/glibc-2.12/common.nix (renamed from pkgs/development/libraries/glibc-2.11/common.nix)59
-rw-r--r--pkgs/development/libraries/glibc-2.12/default.nix (renamed from pkgs/development/libraries/glibc-2.11/default.nix)10
-rw-r--r--pkgs/development/libraries/glibc-2.12/gnu89-inline.patch26
-rw-r--r--pkgs/development/libraries/glibc-2.12/info.nix (renamed from pkgs/development/libraries/glibc-2.11/info.nix)0
-rw-r--r--pkgs/development/libraries/glibc-2.12/locales-builder.sh (renamed from pkgs/development/libraries/glibc-2.11/locales-builder.sh)0
-rw-r--r--pkgs/development/libraries/glibc-2.12/locales.nix (renamed from pkgs/development/libraries/glibc-2.11/locales.nix)4
-rw-r--r--pkgs/development/libraries/glibc-2.12/nix-locale-archive.patch116
-rw-r--r--pkgs/development/libraries/glibc-2.12/nss-skip-unavail.patch21
-rw-r--r--pkgs/development/libraries/glibc-2.12/rpcgen-path.patch (renamed from pkgs/development/libraries/glibc-2.11/rpcgen-path.patch)0
-rw-r--r--pkgs/development/libraries/glibc-2.12/stack-protector-link.patch (renamed from pkgs/development/libraries/glibc-2.11/stack-protector-link.patch)0
-rw-r--r--pkgs/development/libraries/gmp/4.nix59
-rw-r--r--pkgs/development/libraries/gmp/default.nix46
-rw-r--r--pkgs/development/libraries/gstreamer/default.nix2
-rw-r--r--pkgs/development/libraries/gstreamer/gnonlin/default.nix8
-rw-r--r--pkgs/development/libraries/gstreamer/gst-ffmpeg/default.nix4
-rw-r--r--pkgs/development/libraries/gstreamer/gst-plugins-base/default.nix9
-rw-r--r--pkgs/development/libraries/gstreamer/gst-plugins-good/default.nix4
-rw-r--r--pkgs/development/libraries/gstreamer/gstreamer/default.nix12
-rw-r--r--pkgs/development/libraries/libao/default.nix5
-rw-r--r--pkgs/development/libraries/libgcrypt/default.nix4
-rw-r--r--pkgs/development/libraries/libmad/001-mips_removal_h_constraint.patch73
-rw-r--r--pkgs/development/libraries/libmad/default.nix6
-rw-r--r--pkgs/development/libraries/libvpx/default.nix15
-rw-r--r--pkgs/development/libraries/libxcrypt/default.nix3
-rw-r--r--pkgs/development/libraries/mesa/default.nix2
-rw-r--r--pkgs/development/libraries/mpc/default.nix4
-rw-r--r--pkgs/development/libraries/mpfr/default.nix7
-rw-r--r--pkgs/development/libraries/openssl/1.x.nix45
-rw-r--r--pkgs/development/libraries/openssl/darwin-arch-1.patch16
-rw-r--r--pkgs/development/libraries/openssl/darwin-arch.patch44
-rw-r--r--pkgs/development/libraries/openssl/default.nix9
-rw-r--r--pkgs/development/libraries/pcre/default.nix10
-rw-r--r--pkgs/development/libraries/ppl/default.nix16
-rw-r--r--pkgs/development/libraries/x264/default.nix3
-rw-r--r--pkgs/development/tools/analysis/valgrind/default.nix4
-rw-r--r--pkgs/development/tools/analysis/valgrind/glibc-2.12.patch (renamed from pkgs/development/tools/analysis/valgrind/glibc-2.11.patch)25
-rw-r--r--pkgs/development/tools/analysis/valgrind/stat_h.patch53
-rw-r--r--pkgs/development/tools/build-managers/gnumake/default.nix33
-rw-r--r--pkgs/development/tools/build-managers/gnumake/log.patch4
-rw-r--r--pkgs/development/tools/misc/binutils/as-pr10856.patch83
-rw-r--r--pkgs/development/tools/misc/binutils/default.nix6
-rw-r--r--pkgs/development/tools/misc/binutils/snapshot.nix59
-rw-r--r--pkgs/development/tools/misc/cscope/default.nix8
-rw-r--r--pkgs/development/tools/misc/gnum4/default.nix9
-rw-r--r--pkgs/development/tools/misc/gnum4/s_isdir.patch14
-rw-r--r--pkgs/development/tools/misc/libtool/libtool2.nix4
-rw-r--r--pkgs/development/tools/misc/patchelf/0.6.nix4
-rw-r--r--pkgs/development/tools/misc/texinfo/default.nix12
-rw-r--r--pkgs/games/prboom/default.nix20
-rw-r--r--pkgs/games/scummvm/default.nix12
-rw-r--r--pkgs/lib/misc.nix14
-rw-r--r--pkgs/lib/platforms.nix3
-rw-r--r--pkgs/misc/busybox/default.nix72
-rw-r--r--pkgs/misc/busybox/make-3.82.patch29
-rw-r--r--pkgs/misc/uboot/nanonote.nix58
-rw-r--r--pkgs/os-specific/linux/alsa-lib/default.nix11
-rw-r--r--pkgs/os-specific/linux/alsa-lib/mips-atomic.patch39
-rw-r--r--pkgs/os-specific/linux/alsa-utils/default.nix3
-rw-r--r--pkgs/os-specific/linux/dmidecode/default.nix6
-rw-r--r--pkgs/os-specific/linux/hal/default.nix13
-rw-r--r--pkgs/os-specific/linux/kbd/default.nix15
-rw-r--r--pkgs/os-specific/linux/kernel-headers/2.6.28.nix1
-rw-r--r--pkgs/os-specific/linux/kernel-headers/2.6.32.nix1
-rw-r--r--pkgs/os-specific/linux/kernel/builder.sh143
-rw-r--r--pkgs/os-specific/linux/kernel/generic.nix6
-rw-r--r--pkgs/os-specific/linux/kernel/linux-nanonote-jz-2.6.34.nix241
-rw-r--r--pkgs/os-specific/linux/kernel/linux-nanonote-jz-2.6.35.nix241
-rw-r--r--pkgs/os-specific/linux/kernel/patches.nix4
-rw-r--r--pkgs/os-specific/linux/klibc/default.nix46
-rw-r--r--pkgs/os-specific/linux/klibc/make382.patch35
-rw-r--r--pkgs/os-specific/linux/libcap/default.nix29
-rw-r--r--pkgs/os-specific/linux/libcap/man.nix15
-rw-r--r--pkgs/os-specific/linux/libcap/pam.nix17
-rw-r--r--pkgs/os-specific/linux/libcap/progs.nix15
-rw-r--r--pkgs/os-specific/linux/lvm2/default.nix2
-rw-r--r--pkgs/os-specific/linux/mountall/default.nix6
-rw-r--r--pkgs/os-specific/linux/nfs-utils/default.nix6
-rw-r--r--pkgs/os-specific/linux/pam/default.nix4
-rw-r--r--pkgs/os-specific/linux/procps/default.nix2
-rw-r--r--pkgs/os-specific/linux/procps/gnumake3.82.patch13
-rw-r--r--pkgs/os-specific/linux/sysvinit/default.nix2
-rw-r--r--pkgs/os-specific/linux/uclibc/default.nix91
-rw-r--r--pkgs/os-specific/linux/util-linux-ng/default.nix6
-rw-r--r--pkgs/servers/http/apache-httpd/default.nix5
-rw-r--r--pkgs/stdenv/adapters.nix4
-rw-r--r--pkgs/stdenv/default.nix5
-rw-r--r--pkgs/stdenv/generic/default.nix6
-rw-r--r--pkgs/stdenv/generic/setup.sh3
-rwxr-xr-xpkgs/stdenv/linux/bootstrap/loongson2f/bzip2bin0 -> 146364 bytes
-rwxr-xr-xpkgs/stdenv/linux/bootstrap/loongson2f/cpiobin0 -> 88564 bytes
-rwxr-xr-xpkgs/stdenv/linux/bootstrap/loongson2f/curl.bz2bin0 -> 172614 bytes
-rw-r--r--pkgs/stdenv/linux/bootstrap/loongson2f/default.nix13
-rwxr-xr-xpkgs/stdenv/linux/bootstrap/loongson2f/lnbin0 -> 59552 bytes
-rwxr-xr-xpkgs/stdenv/linux/bootstrap/loongson2f/mkdirbin0 -> 59548 bytes
-rwxr-xr-xpkgs/stdenv/linux/bootstrap/loongson2f/shbin0 -> 155016 bytes
-rw-r--r--pkgs/stdenv/linux/bootstrap/x86_64/default.nix4
-rw-r--r--pkgs/stdenv/linux/default.nix117
-rw-r--r--pkgs/stdenv/linux/make-bootstrap-tools.nix71
-rw-r--r--pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh38
-rw-r--r--pkgs/tools/archivers/gnutar/default.nix13
-rw-r--r--pkgs/tools/archivers/gnutar/implausible.patch20
-rw-r--r--pkgs/tools/compression/bzip2/default.nix10
-rw-r--r--pkgs/tools/compression/gzip/default.nix6
-rw-r--r--pkgs/tools/compression/gzip/getopt.patch54
-rw-r--r--pkgs/tools/filesystems/btrfsprogs/default.nix3
-rw-r--r--pkgs/tools/filesystems/btrfsprogs/glibc212.patch12
-rw-r--r--pkgs/tools/filesystems/mtdutils/default.nix3
-rw-r--r--pkgs/tools/filesystems/xfsprogs/default.nix10
-rw-r--r--pkgs/tools/misc/coreutils/default.nix35
-rw-r--r--pkgs/tools/misc/findutils/default.nix11
-rw-r--r--pkgs/tools/networking/curl/default.nix6
-rw-r--r--pkgs/tools/networking/iftop/default.nix6
-rw-r--r--pkgs/tools/package-management/nix/0001-Added-support-for-passing-an-impure-NIX_BUILD_CORES-.patch126
-rw-r--r--pkgs/tools/text/diffutils/default.nix8
-rw-r--r--pkgs/tools/text/gawk/default.nix13
-rw-r--r--pkgs/tools/text/gnugrep/default.nix8
-rw-r--r--pkgs/tools/text/gnugrep/malloc.patch15
-rw-r--r--pkgs/tools/text/gnupatch/default.nix8
-rw-r--r--pkgs/tools/text/gnused/default.nix16
-rw-r--r--pkgs/tools/text/gnused/gettext-fix.patch32
-rw-r--r--pkgs/tools/text/groff/default.nix13
-rw-r--r--pkgs/tools/text/replace/default.nix4
-rw-r--r--pkgs/top-level/all-packages.nix181
-rw-r--r--pkgs/top-level/platforms.nix58
-rw-r--r--pkgs/top-level/release-cross.nix124
-rw-r--r--pkgs/top-level/release-lib.nix4
-rw-r--r--pkgs/top-level/release.nix2
190 files changed, 5350 insertions, 1379 deletions
diff --git a/maintainers/scripts/gnu/gnupdate b/maintainers/scripts/gnu/gnupdate
index 289fc9d079ac2..d830b3ab26c21 100755
--- a/maintainers/scripts/gnu/gnupdate
+++ b/maintainers/scripts/gnu/gnupdate
@@ -584,6 +584,7 @@ exec ${GUILE-guile} -L "$PWD" -l "$0"    \
       ("ghostscript" . "gnu-ghostscript") ;; ../ghostscript/gnu-ghoscript-X.Y.tar.gz
       ("gnum4"       . "m4")
       ("gnugrep"     . "grep")
+      ("gnumake"     . "make")
       ("gnused"      . "sed")
       ("gnutar"      . "tar")
       ("gnunet"      . "GNUnet") ;; ftp.gnu.org/gnu/gnunet/GNUnet-x.y.tar.gz
diff --git a/maintainers/scripts/gnu/gnupdate.scm b/maintainers/scripts/gnu/gnupdate.scm
new file mode 100644
index 0000000000000..3cf6e7cfaba1b
--- /dev/null
+++ b/maintainers/scripts/gnu/gnupdate.scm
@@ -0,0 +1,712 @@
+;;; GNUpdate -- Update GNU packages in Nixpkgs.     -*- coding: utf-8; -*-
+;;; Copyright (C) 2010  Ludovic Courtès <ludo@gnu.org>
+;;;
+;;; This program is free software: you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation, either version 3 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+(cond-expand (guile-2 #t)
+             (else (error "GNU Guile 2.0 is required")))
+
+(use-modules (sxml ssax)
+             (ice-9 popen)
+             (ice-9 match)
+             (ice-9 rdelim)
+             (ice-9 regex)
+             (ice-9 vlist)
+             (srfi srfi-1)
+             (srfi srfi-9)
+             (srfi srfi-11)
+             (srfi srfi-37)
+             (system foreign)
+             (rnrs bytevectors))
+
+
+;;;
+;;; SNix.
+;;;
+
+(define-record-type <location>
+  (make-location file line column)
+  location?
+  (file          location-file)
+  (line          location-line)
+  (column        location-column))
+
+(define (->loc line column path)
+  (and line column path
+       (make-location path (string->number line) (string->number column))))
+
+;; XXX: Hack to add missing exports from `(sxml ssax)' as of 1.9.10.
+(let ((ssax (resolve-module '(sxml ssax))))
+  (for-each (lambda (sym)
+              (module-add! (current-module) sym
+                           (module-variable ssax sym)))
+            '(ssax:warn ssax:skip-pi nl)))
+
+;; Nix object types visible in the XML output of `nix-instantiate' and
+;; mapping to S-expressions (we map to sexps, not records, so that we
+;; can do pattern matching):
+;;
+;;   at               (at varpat attrspat)
+;;   attr             (attribute loc name value)
+;;   attrs            (attribute-set attributes)
+;;   attrspat         (attribute-set-pattern patterns)
+;;   bool             #f|#t
+;;   derivation       (derivation drv-path out-path attributes)
+;;   ellipsis         '...
+;;   expr             (snix loc body ...)
+;;   function         (function loc at|attrspat|varpat)
+;;   int              int
+;;   list             list
+;;   null             'null
+;;   path             string
+;;   string           string
+;;   unevaluated      'unevaluated
+;;   varpat           (varpat name)
+;;
+;; Initially ATTRIBUTES in `derivation' and `attribute-set' was a promise;
+;; however, handling `repeated' nodes makes it impossible to do anything
+;; lazily because the whole SXML tree has to be traversed to maintain the
+;; list of known derivations.
+
+(define (xml-element->snix elem attributes body derivations)
+  ;; Return an SNix element corresponding to XML element ELEM.
+
+  (define (loc)
+    (->loc (assq-ref attributes 'line)
+           (assq-ref attributes 'column)
+           (assq-ref attributes 'path)))
+
+  (case elem
+    ((at)
+     (values `(at ,(car body) ,(cadr body)) derivations))
+    ((attr)
+     (let ((name (assq-ref attributes 'name)))
+       (cond ((null? body)
+              (values `(attribute-pattern ,name) derivations))
+             ((and (pair? body) (null? (cdr body)))
+              (values `(attribute ,(loc) ,name ,(car body))
+                      derivations))
+             (else
+              (error "invalid attribute body" name (loc) body)))))
+    ((attrs)
+     (values `(attribute-set ,(reverse body)) derivations))
+    ((attrspat)
+     (values `(attribute-set-pattern ,body) derivations))
+    ((bool)
+     (values (string-ci=? "true" (assq-ref attributes 'value))
+             derivations))
+    ((derivation)
+     (let ((drv-path (assq-ref attributes 'drvPath))
+           (out-path (assq-ref attributes 'outPath)))
+       (if (equal? body '(repeated))
+           (let ((body (vhash-assoc drv-path derivations)))
+             (if (pair? body)
+                 (values `(derivation ,drv-path ,out-path ,(cdr body))
+                         derivations)
+                 (error "no previous occurrence of derivation"
+                        drv-path)))
+           (values `(derivation ,drv-path ,out-path ,body)
+                   (vhash-cons drv-path body derivations)))))
+    ((ellipsis)
+     (values '... derivations))
+    ((expr)
+     (values `(snix ,(loc) ,@body) derivations))
+    ((function)
+     (values `(function ,(loc) ,body) derivations))
+    ((int)
+     (values (string->number (assq-ref attributes 'value))
+             derivations))
+    ((list)
+     (values body derivations))
+    ((null)
+     (values 'null derivations))
+    ((path)
+     (values (assq-ref attributes 'value) derivations))
+    ((repeated)
+     (values 'repeated derivations))
+    ((string)
+     (values (assq-ref attributes 'value) derivations))
+    ((unevaluated)
+     (values 'unevaluated derivations))
+    ((varpat)
+     (values `(varpat ,(assq-ref attributes 'name)) derivations))
+    (else (error "unhandled Nix XML element" elem))))
+
+(define xml->snix
+  ;; Return the SNix represention of TREE, an SXML tree as returned by
+  ;; parsing the XML output of `nix-instantiate' on Nixpkgs.
+  (let ((parse
+         (ssax:make-parser NEW-LEVEL-SEED
+                           (lambda (elem-gi attributes namespaces expected-content
+                                    seed)
+                             (cons '() (cdr seed)))
+
+                           FINISH-ELEMENT
+                           (lambda (elem-gi attributes namespaces parent-seed
+                                            seed)
+                             (let ((snix        (car seed))
+                                   (derivations (cdr seed)))
+                               (let-values (((snix derivations)
+                                             (xml-element->snix elem-gi
+                                                                attributes
+                                                                snix
+                                                                derivations)))
+                                 (cons (cons snix (car parent-seed))
+                                       derivations))))
+
+                           CHAR-DATA-HANDLER
+                           (lambda (string1 string2 seed)
+                             ;; Discard inter-node strings, which are blanks.
+                             seed))))
+    (lambda (port)
+      ;; Discard the second value returned by the parser (the derivation
+      ;; vhash).
+      (caar (parse port (cons '() vlist-null))))))
+
+(define (call-with-package snix proc)
+  (match snix
+    (('attribute _ (and attribute-name (? string?))
+                 ('derivation _ _ body))
+     ;; Ugly pattern matching.
+     (let ((meta
+            (any (lambda (attr)
+                   (match attr
+                     (('attribute _ "meta" ('attribute-set metas)) metas)
+                     (_ #f)))
+                 body))
+           (package-name
+            (any (lambda (attr)
+                   (match attr
+                     (('attribute _ "name" (and name (? string?)))
+                      name)
+                     (_ #f)))
+                 body))
+           (location
+            (any (lambda (attr)
+                   (match attr
+                     (('attribute loc "name" (? string?))
+                      loc)
+                     (_ #f)))
+                 body))
+           (src
+            (any (lambda (attr)
+                   (match attr
+                     (('attribute _ "src" src)
+                      src)
+                     (_ #f)))
+                 body)))
+       (proc attribute-name package-name location meta src)))))
+
+(define (call-with-src snix proc)
+  ;; Assume SNIX contains the SNix expression for the value of an `src'
+  ;; attribute, as returned by `call-with-package', and call PROC with the
+  ;; relevant SRC information, or #f if SNIX doesn't match.
+  (match snix
+    (('derivation _ _ body)
+     (let ((name
+            (any (lambda (attr)
+                   (match attr
+                     (('attribute _ "name" (and name (? string?)))
+                      name)
+                     (_ #f)))
+                 body))
+           (output-hash
+            (any (lambda (attr)
+                   (match attr
+                     (('attribute _ "outputHash" (and hash (? string?)))
+                      hash)
+                     (_ #f)))
+                 body))
+           (urls
+            (any (lambda (attr)
+                   (match attr
+                     (('attribute _ "urls" (and urls (? pair?)))
+                      urls)
+                     (_ #f)))
+                 body)))
+       (proc name output-hash urls)))
+    (_ (proc #f #f #f))))
+
+(define (src->values snix)
+  (call-with-src snix values))
+
+(define (open-nixpkgs nixpkgs)
+  (let ((script  (string-append nixpkgs
+                                "/maintainers/scripts/eval-release.nix")))
+    (open-pipe* OPEN_READ "nix-instantiate"
+                "--strict" "--eval-only" "--xml"
+                script)))
+
+(define (nix-prefetch-url url)
+  ;; Download URL in the Nix store and return the base32-encoded SHA256 hash
+  ;; of the file at URL
+  (let* ((pipe (open-pipe* OPEN_READ "nix-prefetch-url" url))
+         (hash (read-line pipe)))
+    (close-pipe pipe)
+    (if (eof-object? hash)
+        (values #f #f)
+        (let* ((pipe (open-pipe* OPEN_READ "nix-store" "--print-fixed-path"
+                                 "sha256" hash (basename url)))
+               (path (read-line pipe)))
+          (if (eof-object? path)
+              (values #f #f)
+              (values (string-trim-both hash) (string-trim-both path)))))))
+
+(define (update-nix-expression file
+                               old-version old-hash
+                               new-version new-hash)
+  ;; Modify FILE in-place.  Ugly: we call out to sed(1).
+  (let ((cmd (format #f "sed -i \"~a\" -e 's/~A/~a/g ; s/~A/~A/g'"
+                     file
+                     (regexp-quote old-version) new-version
+                     old-hash
+                     (or new-hash "new hash not available, check the log"))))
+    (format #t "running `~A'...~%" cmd)
+    (system cmd)))
+
+
+;;;
+;;; FTP client.
+;;;
+
+(define-record-type <ftp-connection>
+  (%make-ftp-connection socket addrinfo)
+  ftp-connection?
+  (socket    ftp-connection-socket)
+  (addrinfo  ftp-connection-addrinfo))
+
+(define %ftp-ready-rx
+  (make-regexp "^([0-9]{3}) (.+)$"))
+
+(define (%ftp-listen port)
+  (let loop ((line (read-line port)))
+    (cond ((eof-object? line) (values line #f))
+          ((regexp-exec %ftp-ready-rx line)
+           =>
+           (lambda (match)
+             (values (string->number (match:substring match 1))
+                     (match:substring match 2))))
+          (else
+           (loop (read-line port))))))
+
+(define (%ftp-command command expected-code port)
+  (format port "~A~A~A" command (string #\return) (string #\newline))
+  (let-values (((code message) (%ftp-listen port)))
+    (if (eqv? code expected-code)
+        message
+        (throw 'ftp-error port command code message))))
+
+(define (%ftp-login user pass port)
+  (let ((command (string-append "USER " user (string #\newline))))
+    (display command port)
+    (let-values (((code message) (%ftp-listen port)))
+      (case code
+        ((230)  #t)
+        ((331) (%ftp-command (string-append "PASS " pass) 230 port))
+        (else  (throw 'ftp-error port command code message))))))
+
+(define (ftp-open host)
+  (catch 'getaddrinfo-error
+    (lambda ()
+      (let* ((ai (car (getaddrinfo host "ftp")))
+             (s  (socket (addrinfo:fam ai) (addrinfo:socktype ai)
+                         (addrinfo:protocol ai))))
+        (connect s (addrinfo:addr ai))
+        (setvbuf s _IOLBF)
+        (let-values (((code message) (%ftp-listen s)))
+          (if (eqv? code 220)
+              (begin
+                ;(%ftp-command "OPTS UTF8 ON" 200 s)
+                (%ftp-login "anonymous" "ludo@example.com" s)
+                (%make-ftp-connection s ai))
+              (begin
+                (format (current-error-port) "FTP to `~a' failed: ~A: ~A~%"
+                        host code message)
+                (close s)
+                #f)))))
+    (lambda (key errcode)
+      (format (current-error-port) "failed to resolve `~a': ~a~%"
+              host (gai-strerror errcode))
+      #f)))
+
+(define (ftp-close conn)
+  (close (ftp-connection-socket conn)))
+
+(define (ftp-chdir conn dir)
+  (%ftp-command (string-append "CWD " dir) 250
+                (ftp-connection-socket conn)))
+
+(define (ftp-pasv conn)
+  (define %pasv-rx
+    (make-regexp "([0-9]+),([0-9]+),([0-9]+),([0-9]+),([0-9]+),([0-9]+)"))
+
+  (let ((message (%ftp-command "PASV" 227 (ftp-connection-socket conn))))
+    (cond ((regexp-exec %pasv-rx message)
+           =>
+           (lambda (match)
+             (+ (* (string->number (match:substring match 5)) 256)
+                (string->number (match:substring match 6)))))
+          (else
+           (throw 'ftp-error conn "PASV" 227 message)))))
+
+
+(define* (ftp-list conn #:optional directory)
+  (define (address-with-port sa port)
+    (let ((fam  (sockaddr:fam sa))
+          (addr (sockaddr:addr sa)))
+      (cond ((= fam AF_INET)
+             (make-socket-address fam addr port))
+            ((= fam AF_INET6)
+             (make-socket-address fam addr port
+                                  (sockaddr:flowinfo sa)
+                                  (sockaddr:scopeid sa)))
+            (else #f))))
+
+  (if directory
+      (ftp-chdir conn directory))
+
+  (let* ((port (ftp-pasv conn))
+         (ai   (ftp-connection-addrinfo conn))
+         (s    (socket (addrinfo:fam ai) (addrinfo:socktype ai)
+                       (addrinfo:protocol ai))))
+    (connect s (address-with-port (addrinfo:addr ai) port))
+    (setvbuf s _IOLBF)
+
+    (dynamic-wind
+      (lambda () #t)
+      (lambda ()
+        (%ftp-command "LIST" 150 (ftp-connection-socket conn))
+
+        (let loop ((line   (read-line s))
+                   (result '()))
+          (cond ((eof-object? line) (reverse result))
+                ((regexp-exec %ftp-ready-rx line)
+                 =>
+                 (lambda (match)
+                   (let ((code (string->number (match:substring match 1))))
+                     (if (= 126 code)
+                         (reverse result)
+                         (throw 'ftp-error conn "LIST" code)))))
+                (else
+                 (loop (read-line s)
+                       (let ((file (car (reverse (string-tokenize line)))))
+                         (cons file result)))))))
+      (lambda ()
+        (close s)
+        (let-values (((code message) (%ftp-listen (ftp-connection-socket conn))))
+          (or (eqv? code 226)
+              (throw 'ftp-error conn "LIST" code message)))))))
+
+
+;;;
+;;; GNU.
+;;;
+
+(define %ignored-package-attributes
+  ;; Attribute name of packages to be ignored.
+  '("bash" "bashReal" "bashInteractive" ;; the full versioned name is incorrect
+    "autoconf213"
+    "automake17x"
+    "automake19x"
+    "automake110x"
+    "automake" ;; = 1.10.x
+    "bison1875"
+    "bison23"
+    "bison" ;; = 2.3
+    "emacs22"
+    "emacsSnapshot"
+    "gcc295"
+    "gcc33"
+    "gcc34"
+    "gcc40"
+    "gcc41"
+    "gcc42"
+    "gcc43"
+    "glibc25"
+    "glibc27"
+    "glibc29"
+    "guile_1_9"
+    ))
+
+(define (gnu? package)
+  ;; Return true if PACKAGE (a snix expression) is a GNU package (according
+  ;; to a simple heuristic.)  Otherwise return #f.
+  (match package
+    (('attribute _ attribute-name ('derivation _ _ body))
+     (any (lambda (attr)
+            (match attr
+              (('attribute _ "meta" ('attribute-set metas))
+               (any (lambda (attr)
+                      (match attr
+                        (('attribute _ "description" value)
+                         (string-prefix? "GNU" value))
+                        (('attribute _ "homepage" value)
+                         (string-contains value "www.gnu.org"))
+                        (_ #f)))
+                    metas))
+              (_ #f)))
+          body))
+    (_ #f)))
+
+(define (gnu-packages packages)
+  (fold (lambda (package gnu)
+          (match package
+            (('attribute _ "emacs23Packages" emacs-packages)
+             ;; XXX: Should prepend `emacs23Packages.' to attribute names.
+             (append (gnu-packages emacs-packages) gnu))
+            (('attribute _ attribute-name ('derivation _ _ body))
+             (if (member attribute-name %ignored-package-attributes)
+                 gnu
+                 (if (gnu? package)
+                     (cons package gnu)
+                     gnu)))
+            (_ gnu)))
+        '()
+        packages))
+
+(define (ftp-server/directory project)
+  (define quirks
+    '(("commoncpp2"   "ftp.gnu.org"   "/gnu/commoncpp" #f)
+      ("libgcrypt"    "ftp.gnupg.org" "/gcrypt" #t)
+      ("libgpg-error" "ftp.gnupg.org" "/gcrypt" #t)
+      ("gnupg"        "ftp.gnupg.org" "/gcrypt" #t)
+      ("gnu-ghostscript" "ftp.gnu.org"  "/ghostscript" #f)
+      ("GNUnet"       "ftp.gnu.org" "/gnu/gnunet" #f)
+      ("mit-scheme"   "ftp.gnu.org" "/gnu/mit-scheme/stable.pkg")
+      ("icecat"       "ftp.gnu.org" "/gnu/gnuzilla" #f)
+      ("TeXmacs"      "ftp.texmacs.org" "/TeXmacs/targz" #f)))
+
+  (let ((quirk (assoc project quirks)))
+    (match quirk
+      ((_ server directory subdir?)
+       (values server (if (not subdir?)
+                          directory
+                          (string-append directory "/" project))))
+      (else
+       (values "ftp.gnu.org" (string-append "/gnu/" project))))))
+
+(define (nixpkgs->gnu-name project)
+  (define quirks
+    '(("gcc-wrapper" . "gcc")
+      ("ghostscript" . "gnu-ghostscript") ;; ../ghostscript/gnu-ghoscript-X.Y.tar.gz
+      ("gnum4"       . "m4")
+      ("gnugrep"     . "grep")
+      ("gnused"      . "sed")
+      ("gnutar"      . "tar")
+      ("gnunet"      . "GNUnet") ;; ftp.gnu.org/gnu/gnunet/GNUnet-x.y.tar.gz
+      ("mitscheme"   . "mit-scheme")
+      ("texmacs"     . "TeXmacs")))
+
+  (or (assoc-ref quirks project) project))
+
+(define (releases project)
+  ;; TODO: Handle project release trees like that of IceCat and MyServer.
+  (define release-rx
+    (make-regexp (string-append "^" project "-[0-9].*\\.tar\\.")))
+
+  (catch #t
+    (lambda ()
+      (let-values (((server directory) (ftp-server/directory project)))
+        (let* ((conn  (ftp-open server))
+               (files (ftp-list conn directory)))
+          (ftp-close conn)
+          (map (lambda (tarball)
+                 (let ((end (string-contains tarball ".tar")))
+                   (substring tarball 0 end)))
+
+               ;; Filter out signatures, deltas, and files which are potentially
+               ;; not releases of PROJECT (e.g., in /gnu/guile, filter out
+               ;; guile-oops and guile-www).
+               (filter (lambda (file)
+                         (and (not (string-suffix? ".sig" file))
+                              (regexp-exec release-rx file)))
+                       files)))))
+    (lambda (key subr message . args)
+      (format (current-error-port)
+              "failed to get release list for `~A': ~A ~A~%"
+              project message args)
+      '())))
+
+(define version-string>?
+  (let ((strverscmp
+         (let ((sym (or (dynamic-func "strverscmp" (dynamic-link))
+                        (error "could not find `strverscmp' (from GNU libc)"))))
+           (make-foreign-function int sym (list '* '*))))
+        (string->null-terminated-utf8
+         (lambda (s)
+           (let* ((utf8 (string->utf8 s))
+                  (len  (bytevector-length utf8))
+                  (nts  (make-bytevector (+ len 1))))
+             (bytevector-copy! utf8 0 nts 0 len)
+             (bytevector-u8-set! nts len 0)
+             nts))))
+    (lambda (a b)
+      (let ((a (bytevector->foreign (string->null-terminated-utf8 a)))
+            (b (bytevector->foreign (string->null-terminated-utf8 b))))
+        (> (strverscmp a b) 0)))))
+
+(define (latest-release project)
+  ;; Return "FOO-X.Y" or #f.
+  (let ((releases (releases project)))
+    (and (not (null? releases))
+         (fold (lambda (release latest)
+                 (if (version-string>? release latest)
+                     release
+                     latest))
+               ""
+               releases))))
+
+(define (package/version name+version)
+  (let ((hyphen (string-rindex name+version #\-)))
+    (if (not hyphen)
+        (values name+version #f)
+        (let ((name    (substring name+version 0 hyphen))
+              (version (substring name+version (+ hyphen 1)
+                                  (string-length name+version))))
+          (values name version)))))
+
+(define (file-extension file)
+  (let ((dot (string-rindex file #\.)))
+    (and dot (substring file (+ 1 dot) (string-length file)))))
+
+(define (packages-to-update gnu-packages)
+  (fold (lambda (pkg result)
+          (call-with-package pkg
+            (lambda (attribute name+version location meta src)
+              (let-values (((name old-version)
+                            (package/version name+version)))
+                (let ((latest (latest-release (nixpkgs->gnu-name name))))
+                  (cond ((not latest)
+                         (format #t "~A [unknown latest version]~%"
+                                 name+version)
+                         result)
+                        ((string=? name+version latest)
+                         (format #t "~A [up to date]~%" name+version)
+                         result)
+                        (else
+                         (let-values (((project new-version)
+                                       (package/version latest))
+                                      ((old-name old-hash old-urls)
+                                       (src->values src)))
+                           (format #t "~A -> ~A [~A]~%" name+version latest
+                                   (and (pair? old-urls) (car old-urls)))
+                           (let* ((url      (and (pair? old-urls)
+                                                 (car old-urls)))
+                                  (new-hash (fetch-gnu project new-version
+                                                       (if url
+                                                           (file-extension url)
+                                                           "gz"))))
+                             (cons (list name attribute
+                                         old-version old-hash
+                                         new-version new-hash
+                                         location)
+                                   result))))))))))
+        '()
+        gnu-packages))
+
+(define (fetch-gnu project version archive-type)
+  (let-values (((server directory)
+                (ftp-server/directory project)))
+    (let* ((base    (string-append project "-" version ".tar." archive-type))
+           (url     (string-append "ftp://" server "/" directory "/" base))
+           (sig     (string-append base ".sig"))
+           (sig-url (string-append url ".sig")))
+      (let-values (((hash path) (nix-prefetch-url url)))
+        (pk 'prefetch-url url hash path)
+        (and hash path
+             (begin
+               (false-if-exception (delete-file sig))
+               (system* "wget" sig-url)
+               (if (file-exists? sig)
+                   (let ((ret (system* "gpg" "--verify" sig path)))
+                     (false-if-exception (delete-file sig))
+                     (if (and ret (= 0 (status:exit-val ret)))
+                         hash
+                         (begin
+                           (format (current-error-port)
+                                   "signature verification failed for `~a'~%"
+                                   base)
+                           (format (current-error-port)
+                                   "(could be because the public key is not in your keyring)~%")
+                           #f)))
+                   (begin
+                     (format (current-error-port)
+                             "no signature for `~a'~%" base)
+                     hash))))))))
+
+
+;;;
+;;; Main program.
+;;;
+
+(define %options
+  ;; Specifications of the command-line options.
+  (list (option '(#\h "help") #f #f
+                (lambda (opt name arg result)
+                  (format #t "Usage: gnupdate [OPTIONS...]~%")
+                  (format #t "GNUpdate -- update Nix expressions of GNU packages in Nixpkgs~%")
+                  (format #t "~%")
+                  (format #t "  -x, --xml=FILE      Read XML output of `nix-instantiate'~%")
+                  (format #t "                      from FILE.~%")
+                  (format #t "  -d, --dry-run       Don't actually update Nix expressions~%")
+                  (format #t "  -h, --help          Give this help list.~%~%")
+                  (format #t "Report bugs to <ludo@gnu.org>~%")
+                  (exit 0)))
+        (option '(#\d "dry-run") #f #f
+                (lambda (opt name arg result)
+                  (alist-cons 'dry-run #t result)))
+
+        (option '(#\x "xml") #t #f
+                (lambda (opt name arg result)
+                  (alist-cons 'xml-file arg result)))))
+
+(define-public (main . args)
+  ;; Assume Nixpkgs is under $NIXPKGS or ~/src/nixpkgs.
+  (let* ((opts      (args-fold args %options
+                               (lambda (opt name arg result)
+                                 (error "unrecognized option `~A'" name))
+                               (lambda (operand result)
+                                 (error "extraneous argument `~A'" operand))
+                               '()))
+         (home      (getenv "HOME"))
+         (path      (or (getenv "NIXPKGS")
+                        (string-append home "/src/nixpkgs")))
+         (snix      (begin
+                      (format (current-error-port) "parsing XML...~%")
+                      (xml->snix
+                       (or (and=> (assoc-ref opts 'xml-file) open-input-file)
+                           (open-nixpkgs path)))))
+         (packages  (match snix
+                      (('snix _ ('attribute-set attributes))
+                       attributes)
+                      (else #f)))
+         (gnu       (gnu-packages packages))
+         (updates   (packages-to-update gnu)))
+    (format #t "~%~A packages to update...~%" (length updates))
+    (for-each (lambda (update)
+                (match update
+                  ((name attribute
+                    old-version old-hash
+                    new-version new-hash
+                    location)
+                   (if (assoc-ref opts 'dry-run)
+                       (format #t "`~a' would be updated from ~a to ~a (~a -> ~a)~%"
+                               name old-version new-version
+                               old-hash new-hash)
+                       (update-nix-expression (location-file location)
+                                              old-version old-hash
+                                              new-version new-hash)))
+                  (_ #f)))
+              updates)
+    #t))
diff --git a/pkgs/applications/audio/mpg123/default.nix b/pkgs/applications/audio/mpg123/default.nix
new file mode 100644
index 0000000000000..80de5567000d5
--- /dev/null
+++ b/pkgs/applications/audio/mpg123/default.nix
@@ -0,0 +1,23 @@
+{stdenv, fetchurl, alsaLib }:
+
+stdenv.mkDerivation {
+  name = "mpg123-1.12.3";
+
+  src = fetchurl {
+    url = mirror://sourceforge/mpg123/mpg123-1.12.3.tar.bz2;
+    sha256 = "1ij689s7jch3d4g0ja3jylaphallc8vgrsrm9b12254phnyy23xf";
+  };
+
+  buildInputs = [ alsaLib ];
+
+  crossAttrs = {
+    configureFlags = if stdenv.cross ? mpg123 then
+      "--with-cpu=${stdenv.cross.mpg123.cpu}" else "";
+  };
+
+  meta = {
+    description = "Command-line MP3 player";
+    homepage = http://mpg123.sourceforge.net/;
+    license = "LGPL";
+  };
+}
diff --git a/pkgs/applications/editors/ed/default.nix b/pkgs/applications/editors/ed/default.nix
index 9f26c0a2886eb..905cde880edd1 100644
--- a/pkgs/applications/editors/ed/default.nix
+++ b/pkgs/applications/editors/ed/default.nix
@@ -10,6 +10,10 @@ stdenv.mkDerivation rec {
 
   doCheck = true;
 
+  crossAttrs = {
+    compileFlags = [ "CC=${stdenv.cross.config}-gcc" ];
+  };
+
   meta = {
     description = "GNU ed, an implementation of the standard Unix editor";
 
diff --git a/pkgs/applications/editors/nvi/default.nix b/pkgs/applications/editors/nvi/default.nix
index f14ffe51f2ba8..ca4c0cba644b3 100644
--- a/pkgs/applications/editors/nvi/default.nix
+++ b/pkgs/applications/editors/nvi/default.nix
@@ -4,7 +4,7 @@ stdenv.mkDerivation rec {
   name = "nvi-1.79";
 
   src = fetchurl {
-    url = "https://sites.google.com/a/bostic.com/external/files/nvi-1.79.tar.gz?attredirects=0";
+    url = http://www.cpan.org/src/misc/nvi-1.79.tar.gz;
     sha256 = "0cvf56rbylz7ksny6g2256sjg8yrsxrmbpk82r64rhi53sm8fnvm";
   };
 
diff --git a/pkgs/applications/editors/vim/configurable.nix b/pkgs/applications/editors/vim/configurable.nix
index 28ce0d271cfba..7e03fd6b7b302 100644
--- a/pkgs/applications/editors/vim/configurable.nix
+++ b/pkgs/applications/editors/vim/configurable.nix
@@ -46,8 +46,14 @@ composableDerivation {} {
       ;
 
   cfg = {
-    pythonSupport = true;
-    ftNixSupport = true; # add .nix filetype detection and minimal syntax highlighting support
+    pythonSupport    = getConfig [ "vim" "python" ] true;
+    darwinSupport    = getConfig [ "vim" "darwin" ] false;
+    nlsSupport       = getConfig [ "vim" "nls" ] false;
+    tclSupport       = getConfig [ "vim" "tcl" ] false;
+    multibyteSupport = getConfig [ "vim" "multibyte" ] false;
+    cscopeSupport    = getConfig [ "vim" "cscope" ] false;
+    # add .nix filetype detection and minimal syntax highlighting support
+    ftNixSupport     = getConfig [ "vim" "ftNix" ] true;
   };
 
   #--enable-gui=OPTS     X11 GUI default=auto OPTS=auto/no/gtk/gtk2/gnome/gnome2/motif/athena/neXtaw/photon/carbon
diff --git a/pkgs/applications/editors/vim/default.nix b/pkgs/applications/editors/vim/default.nix
index 7dc9f05b17920..4920dd76bd111 100644
--- a/pkgs/applications/editors/vim/default.nix
+++ b/pkgs/applications/editors/vim/default.nix
@@ -16,6 +16,21 @@ stdenv.mkDerivation rec {
   ];
 
   postInstall = "ln -s $out/bin/vim $out/bin/vi";
+
+  crossAttrs = {
+    configureFlags = [
+      "vim_cv_toupper_broken=no"
+      "--with-tlib=ncurses"
+      "vim_cv_terminfo=yes"
+      "vim_cv_tty_group=tty"
+      "vim_cv_tty_mode=0660"
+      "vim_cv_getcwd_broken=no"
+      "vim_cv_stat_ignores_slash=yes"
+      "ac_cv_sizeof_int=4"
+      "vim_cv_memmove_handles_overlap=yes"
+      "STRIP=${stdenv.cross.config}-strip"
+    ];
+  };
   
   meta = {
     description = "The most popular clone of the VI editor";
diff --git a/pkgs/applications/misc/simgrid/default.nix b/pkgs/applications/misc/simgrid/default.nix
new file mode 100644
index 0000000000000..45b93dab83088
--- /dev/null
+++ b/pkgs/applications/misc/simgrid/default.nix
@@ -0,0 +1,59 @@
+{ fetchurl, stdenv, cmake, ruby }:
+
+stdenv.mkDerivation rec {
+  name = "simgrid-3.4.1";
+
+  src = fetchurl {
+    url = "https://gforge.inria.fr/frs/download.php/26944/${name}.tar.bz2";
+    sha256 = "acd2bb2c1abf59e9b190279b1c38582b7c1edd4b6ef4c6a9b01100740f1a6b28";
+  };
+
+  /* FIXME: Ruby currently disabled because of this:
+
+     Linking C shared library ../src/.libs/libsimgrid.so
+     ld: cannot find -lruby-1.8.7-p72
+
+   */
+  buildInputs = [ cmake /* ruby */ ];
+
+  preConfigure =
+    # Make it so that libsimgrid.so will be found when running programs from
+    # the build dir.
+    '' export LD_LIBRARY_PATH="$PWD/src/.libs"
+       export cmakeFlags="-Dprefix=$out"
+    '';
+
+  makeFlags = "VERBOSE=1";
+
+  patchPhase =
+    '' for i in "src/smpi/"*
+       do
+         sed -i "$i" -e's|/bin/bash|/bin/sh|g'
+       done
+    '';
+
+  installPhase = "make install-simgrid";
+
+  # Fixing the few tests that fail is left as an exercise to the reader.
+  doCheck = false;
+
+  meta = {
+    description = "SimGrid, a simulator for distributed applications in heterogeneous environments";
+
+    longDescription =
+      '' SimGrid is a toolkit that provides core functionalities for the
+         simulation of distributed applications in heterogeneous distributed
+         environments.  The specific goal of the project is to facilitate
+         research in the area of distributed and parallel application
+         scheduling on distributed computing platforms ranging from simple
+         network of workstations to Computational Grids.
+      '';
+
+    homepage = http://simgrid.gforge.inria.fr/;
+
+    license = "LGPLv2+";
+
+    maintainers = [ stdenv.lib.maintainers.ludo ];
+    platforms = stdenv.lib.platforms.gnu;  # arbitrary choice
+  };
+}
diff --git a/pkgs/applications/networking/browsers/elinks/default.nix b/pkgs/applications/networking/browsers/elinks/default.nix
index 9fb59fcdb86d9..e06bfe538c007 100644
--- a/pkgs/applications/networking/browsers/elinks/default.nix
+++ b/pkgs/applications/networking/browsers/elinks/default.nix
@@ -18,6 +18,16 @@ stdenv.mkDerivation rec {
       --enable-nntp --with-openssl=${openssl}
     '';
 
+  crossAttrs = {
+    propagatedBuildInputs = [ ncurses.hostDrv zlib.hostDrv openssl.hostDrv ];
+    configureFlags = ''
+      --enable-finger --enable-html-highlight
+      --enable-gopher --enable-cgi --enable-bittorrent --enable-nntp
+      --with-openssl=${openssl.hostDrv}
+      --with-bzip2=${bzip2.hostDrv}
+    '';
+  };
+
   meta = {
     description = "Full-featured text-mode web browser";
     homepage = http://elinks.or.cz;
diff --git a/pkgs/applications/networking/browsers/firefox/3.6.nix b/pkgs/applications/networking/browsers/firefox/3.6.nix
index 06f303d1c7471..fe393c428d18b 100644
--- a/pkgs/applications/networking/browsers/firefox/3.6.nix
+++ b/pkgs/applications/networking/browsers/firefox/3.6.nix
@@ -40,15 +40,21 @@ rec {
       "--disable-necko-wifi" # maybe we want to enable this at some point
     ];
 
-
   xulrunner = stdenv.mkDerivation {
     name = "xulrunner-${xulVersion}";
     
     inherit src;
 
-    # To be removed when the change gets upstream. I don't know if the patch
-    # affects xulrunner or firefox.
-    patches = [ ./symlinks-bug551152.patch ];
+    patches = [
+      # To be removed when the change gets upstream. I don't know if the patch
+      # affects xulrunner or firefox.
+      ./symlinks-bug551152.patch
+
+      # Loongson2f related patches:
+      ./xulrunner-chromium-mips.patch
+      ./xulrunner-mips-n32.patch
+      ./xulrunner-1.9.2_beta4-mips-bus-error.patch
+    ];
 
     buildInputs =
       [ pkgconfig gtk perl zip libIDL libjpeg libpng zlib cairo bzip2
@@ -57,6 +63,10 @@ rec {
         alsaLib nspr /* nss */ libnotify xlibs.pixman
       ];
 
+    preConfigure = if stdenv.isMips then ''
+      export ac_cv_thread_keyword=no
+    '' else "";
+
     configureFlags =
       [ "--enable-application=xulrunner"
         "--disable-javaxpcom"
diff --git a/pkgs/applications/networking/browsers/firefox/xulrunner-1.9.2_beta4-mips-bus-error.patch b/pkgs/applications/networking/browsers/firefox/xulrunner-1.9.2_beta4-mips-bus-error.patch
new file mode 100644
index 0000000000000..54799397f6f8c
--- /dev/null
+++ b/pkgs/applications/networking/browsers/firefox/xulrunner-1.9.2_beta4-mips-bus-error.patch
@@ -0,0 +1,26 @@
+http://www.gentoo-cn.org/gitweb/?p=loongson.git;a=blob;f=net-libs/xulrunner/files/xulrunner-1.9.2_beta4-mips-bus-error.patch;h=2bf51d77054796ffaf4f4d903dd8560bf96b7844;hb=HEAD
+
+--- ./xpcom/glue/nsTArray.h.orig	2009-04-26 01:21:58.000000000 +0800
++++ ./xpcom/glue/nsTArray.h	2009-04-26 01:21:33.000000000 +0800
+@@ -168,6 +168,7 @@
+ 
+     // The array's elements (prefixed with a Header).  This pointer is never
+     // null.  If the array is empty, then this will point to sEmptyHdr.
++    void   *padding;
+     Header *mHdr;
+ };
+
+diff --git a/layout/svg/base/src/nsSVGGlyphFrame.cpp b/layout/svg/base/src/nsSVGGlyphFrame.cpp
+index 6d452d0..3ce4193 100644
+--- a/layout/svg/base/src/nsSVGGlyphFrame.cpp
++++ b/layout/svg/base/src/nsSVGGlyphFrame.cpp
+@@ -169,8 +169,8 @@ private:
+   PRBool SetupForDirectTextRun(gfxContext *aContext, float aScale);
+   void SetupFor(gfxContext *aContext, float aScale);
+ 
+-  nsSVGGlyphFrame *mSource;
+   nsAutoTArray<CharacterPosition,80> mPositions;
++  nsSVGGlyphFrame *mSource;
+   gfxMatrix mInitialMatrix;
+   // Textrun advance width from start to mCurrentChar, in appunits
+   gfxFloat mCurrentAdvance;
diff --git a/pkgs/applications/networking/browsers/firefox/xulrunner-chromium-mips.patch b/pkgs/applications/networking/browsers/firefox/xulrunner-chromium-mips.patch
new file mode 100644
index 0000000000000..d309f5fb6e806
--- /dev/null
+++ b/pkgs/applications/networking/browsers/firefox/xulrunner-chromium-mips.patch
@@ -0,0 +1,207 @@
+http://gentoo-overlays.zugaina.org/loongson/portage/net-libs/xulrunner/files/xulrunner-chromium-mips.patch
+
+diff --git a/ipc/chromium/src/base/atomicops.h b/ipc/chromium/src/base/atomicops.h
+index 87df918..363bf63 100644
+--- a/ipc/chromium/src/base/atomicops.h
++++ b/ipc/chromium/src/base/atomicops.h
+@@ -132,6 +132,8 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
+ #include "base/atomicops_internals_x86_gcc.h"
+ #elif defined(COMPILER_GCC) && defined(ARCH_CPU_ARM_FAMILY)
+ #include "base/atomicops_internals_arm_gcc.h"
++#elif defined(COMPILER_GCC) && defined(ARCH_CPU_MIPS_FAMILY)
++#include "base/atomicops_internals_mips_gcc.h"
+ #else
+ #error "Atomic operations are not supported on your platform"
+ #endif
+diff --git a/ipc/chromium/src/base/atomicops_internals_mips_gcc.h b/ipc/chromium/src/base/atomicops_internals_mips_gcc.h
+new file mode 100644
+index 0000000..d1b87ee
+--- /dev/null
++++ b/ipc/chromium/src/base/atomicops_internals_mips_gcc.h
+@@ -0,0 +1,160 @@
++// Copyright (c) 2010 Zhang, Le <r0bertz@gentoo.org>
++// Use of this source code is governed by GPLv2.
++
++// This file is an internal atomic implementation, use base/atomicops.h instead.
++
++#ifndef BASE_ATOMICOPS_INTERNALS_MIPS_GCC_H_
++#define BASE_ATOMICOPS_INTERNALS_MIPS_GCC_H_
++
++#define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory")
++
++namespace base {
++namespace subtle {
++
++// 32-bit low-level operations on any platform.
++
++inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
++                                         Atomic32 old_value,
++                                         Atomic32 new_value) {
++  Atomic32 prev;
++   __asm__ __volatile__(
++                       " .set  push        \n"
++                       " .set  noat        \n"
++                       " .set  mips3       \n"
++                       "1: ll  %0, %2      \n"
++                       " bne %0, %z3, 2f   \n"
++                       " .set  mips0       \n"
++                       " move  $1, %z4     \n"
++                       " .set  mips3       \n"
++                       " sc  $1, %1        \n"
++                       " beqz  $1, 3f      \n"
++                       "2:                 \n"
++                       " .subsection 2     \n"
++                       "3: b 1b            \n"
++                       " .previous         \n"
++                       " .set  pop         \n"
++                       : "=&r" (prev), "=R" (*ptr)       
++                       : "R" (*ptr), "Jr" (old_value), "Jr" (new_value)     
++                       : "memory");
++  return prev;
++}
++
++inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
++                                         Atomic32 new_value) {
++  unsigned int ret_value;
++  unsigned long dummy;
++
++  __asm__ __volatile__("       .set    mips3                                   \n"
++                       "1:     ll      %0, %3                  # xchg_u32      \n"
++                       "       .set    mips0                                   \n"
++                       "       move    %2, %z4                                 \n"
++                       "       .set    mips3                                   \n"
++                       "       sc      %2, %1                                  \n"
++                       "       beqz    %2, 2f                                  \n"
++                       "       .subsection 2                                   \n"
++                       "2:     b       1b                                      \n"
++                       "       .previous                                       \n"
++                       "       .set    mips0                                   \n"
++                       : "=&r" (ret_value), "=m" (*ptr), "=&r" (dummy)
++                       : "R" (*ptr), "Jr" (new_value)
++                       : "memory");
++
++  return ret_value;  // Now it's the previous value.
++}
++
++inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
++                                          Atomic32 increment) {
++  Atomic32 temp, result;
++    __asm__ __volatile__(
++    " .set  mips3         \n"
++    "1: ll  %1, %2    # atomic_add_return \n"
++    " addu  %0, %1, %3        \n"
++    " sc  %0, %2          \n"
++    " beqz  %0, 2f          \n"
++    " addu  %0, %1, %3        \n"
++    " .subsection 2         \n"
++    "2: b 1b          \n"
++    " .previous         \n"
++    " .set  mips0         \n"
++    : "=&r" (result), "=&r" (temp), "=m" (*ptr)
++    : "Ir" (increment), "m" (*ptr)
++    : "memory");
++  return result;
++}
++
++inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
++                                        Atomic32 increment) {
++  Atomic32 temp, result;
++    __asm__ __volatile__(
++    " .set  mips3         \n"
++    "1: ll  %1, %2    # atomic_add_return \n"
++    " addu  %0, %1, %3        \n"
++    " sc  %0, %2          \n"
++    " beqz  %0, 2f          \n"
++    " addu  %0, %1, %3        \n"
++    " .subsection 2         \n"
++    "2: b 1b          \n"
++    " .previous         \n"
++    " .set  mips0         \n"
++    : "=&r" (result), "=&r" (temp), "=m" (*ptr)
++    : "Ir" (increment), "m" (*ptr)
++    : "memory");
++  __asm__ __volatile__("sync" : : : "memory");
++  return result;
++}
++
++inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
++                                       Atomic32 old_value,
++                                       Atomic32 new_value) {
++  Atomic32 x = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
++  __asm__ __volatile__("sync" : : : "memory");
++  return x;
++}
++
++inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
++                                       Atomic32 old_value,
++                                       Atomic32 new_value) {
++  return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
++}
++
++inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
++  *ptr = value;
++}
++
++inline void MemoryBarrier() {
++  __asm__ __volatile__("sync" : : : "memory");
++}
++
++inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
++  *ptr = value;
++  __asm__ __volatile__("sync" : : : "memory");
++}
++
++inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
++  ATOMICOPS_COMPILER_BARRIER();
++  *ptr = value; // An x86 store acts as a release barrier.
++  // See comments in Atomic64 version of Release_Store(), below.
++}
++
++inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
++  return *ptr;
++}
++
++inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
++  Atomic32 value = *ptr; // An x86 load acts as a acquire barrier.
++  // See comments in Atomic64 version of Release_Store(), below.
++  ATOMICOPS_COMPILER_BARRIER();
++  return value;
++}
++
++inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
++  MemoryBarrier();
++  return *ptr;
++}
++
++} // namespace base::subtle
++} // namespace base
++
++#undef ATOMICOPS_COMPILER_BARRIER
++
++#endif  // BASE_ATOMICOPS_INTERNALS_MIPS_GCC_H_
+diff --git a/ipc/chromium/src/base/debug_util_posix.cc b/ipc/chromium/src/base/debug_util_posix.cc
+index f7c58b4..50fb41d 100644
+--- a/ipc/chromium/src/base/debug_util_posix.cc
++++ b/ipc/chromium/src/base/debug_util_posix.cc
+@@ -108,7 +108,7 @@ bool DebugUtil::BeingDebugged() {
+ 
+ // static
+ void DebugUtil::BreakDebugger() {
+-#if !defined(ARCH_CPU_ARM_FAMILY)
++#if !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY)
+   asm ("int3");
+ #endif
+ }
+diff --git a/ipc/chromium/src/build/build_config.h b/ipc/chromium/src/build/build_config.h
+index 36f83e7..128bbc7 100644
+--- a/ipc/chromium/src/build/build_config.h
++++ b/ipc/chromium/src/build/build_config.h
+@@ -57,6 +57,8 @@
+ #define ARCH_CPU_ARMEL 1
+ #define ARCH_CPU_32_BITS 1
+ #define WCHAR_T_IS_UNSIGNED 1
++#elif defined(__MIPSEL__)
++#define ARCH_CPU_MIPS_FAMILY 1
+ #else
+ #error Please add support for your architecture in build/build_config.h
+ #endif
diff --git a/pkgs/applications/networking/browsers/firefox/xulrunner-mips-n32.patch b/pkgs/applications/networking/browsers/firefox/xulrunner-mips-n32.patch
new file mode 100644
index 0000000000000..8be5103526077
--- /dev/null
+++ b/pkgs/applications/networking/browsers/firefox/xulrunner-mips-n32.patch
@@ -0,0 +1,764 @@
+http://gentoo-overlays.zugaina.org/loongson/portage/net-libs/xulrunner/files/xulrunner-mips-n32.patch
+
+From 1aa3577cf7e79b574bd2cff058ea00221194869b Mon Sep 17 00:00:00 2001
+From: Zhang Le <r0bertz@gentoo.org>
+Date: Thu, 12 Mar 2009 02:24:34 +0800
+Subject: [PATCH 2/2] xulrunner mips n32 ABI patch
+
+Signed-off-by: Zhang Le <r0bertz@gentoo.org>
+---
+ xpcom/reflect/xptcall/src/md/unix/Makefile.in      |    5 +
+ .../xptcall/src/md/unix/xptcinvoke_asm_mips64.s    |  159 ++++++++++++++
+ .../xptcall/src/md/unix/xptcinvoke_mips64.cpp      |  173 ++++++++++++++++
+ .../xptcall/src/md/unix/xptcstubs_asm_mips64.s     |  149 +++++++++++++
+ .../xptcall/src/md/unix/xptcstubs_mips64.cpp       |  218 ++++++++++++++++++++
+ 5 files changed, 704 insertions(+), 0 deletions(-)
+ create mode 100644 xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_mips64.s
+ create mode 100644 xpcom/reflect/xptcall/src/md/unix/xptcinvoke_mips64.cpp
+ create mode 100644 xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_mips64.s
+ create mode 100644 xpcom/reflect/xptcall/src/md/unix/xptcstubs_mips64.cpp
+
+diff --git a/xpcom/reflect/xptcall/src/md/unix/Makefile.in b/xpcom/reflect/xptcall/src/md/unix/Makefile.in
+index 524174e..63586cf 100644
+--- a/xpcom/reflect/xptcall/src/md/unix/Makefile.in
++++ b/xpcom/reflect/xptcall/src/md/unix/Makefile.in
+@@ -274,8 +274,13 @@ endif
+ 
+ ifeq ($(OS_ARCH),Linux)
+ ifneq (,$(findstring mips, $(OS_TEST)))
++ifneq (,$(findstring mips64, $(OS_TEST)))
++CPPSRCS		:= xptcinvoke_mips64.cpp xptcstubs_mips64.cpp
++ASFILES		:= xptcinvoke_asm_mips64.s xptcstubs_asm_mips64.s
++else
+ CPPSRCS		:= xptcinvoke_mips.cpp xptcstubs_mips.cpp
+ ASFILES		:= xptcinvoke_asm_mips.s xptcstubs_asm_mips.s
++endif
+ ASFLAGS		+= -I$(DIST)/include -x assembler-with-cpp
+ endif
+ endif
+diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_mips64.s b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_mips64.s
+new file mode 100644
+index 0000000..f146ad8
+--- /dev/null
++++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_mips64.s
+@@ -0,0 +1,159 @@
++/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
++/* ***** BEGIN LICENSE BLOCK *****
++ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
++ *
++ * The contents of this file are subject to the Mozilla Public License Version
++ * 1.1 (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ * http://www.mozilla.org/MPL/
++ *
++ * Software distributed under the License is distributed on an "AS IS" basis,
++ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
++ * for the specific language governing rights and limitations under the
++ * License.
++ *
++ * The Original Code is mozilla.org code.
++ *
++ * The Initial Developer of the Original Code is
++ * Netscape Communications Corporation.
++ * Portions created by the Initial Developer are Copyright (C) 1998
++ * the Initial Developer. All Rights Reserved.
++ *
++ * Contributor(s):
++ *   ZHANG Le    <r0bertz@gentoo.org>
++ *
++ * Alternatively, the contents of this file may be used under the terms of
++ * either of the GNU General Public License Version 2 or later (the "GPL"),
++ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
++ * in which case the provisions of the GPL or the LGPL are applicable instead
++ * of those above. If you wish to allow use of your version of this file only
++ * under the terms of either the GPL or the LGPL, and not to allow others to
++ * use your version of this file under the terms of the MPL, indicate your
++ * decision by deleting the provisions above and replace them with the notice
++ * and other provisions required by the GPL or the LGPL. If you do not delete
++ * the provisions above, a recipient may use your version of this file under
++ * the terms of any one of the MPL, the GPL or the LGPL.
++ *
++ * ***** END LICENSE BLOCK ***** */
++#include <sys/regdef.h>
++#include <sys/asm.h>
++
++.text
++.globl  invoke_count_words
++.globl  invoke_copy_to_stack
++
++LOCALSZ=7		# a0, a1, a2, a3, s0, ra, gp
++FRAMESZ=(((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
++
++RAOFF=FRAMESZ-(1*SZREG)
++A0OFF=FRAMESZ-(2*SZREG)
++A1OFF=FRAMESZ-(3*SZREG)
++A2OFF=FRAMESZ-(4*SZREG)
++A3OFF=FRAMESZ-(5*SZREG)
++S0OFF=FRAMESZ-(6*SZREG)
++GPOFF=FRAMESZ-(7*SZREG)
++
++#
++# _NS_InvokeByIndex_P(that, methodIndex, paramCount, params)
++#                      a0       a1          a2         a3
++
++NESTED(_NS_InvokeByIndex_P, FRAMESZ, ra)
++	PTR_SUBU sp, FRAMESZ
++	SETUP_GP64(GPOFF, _NS_InvokeByIndex_P)
++
++	REG_S	ra, RAOFF(sp)
++	REG_S	a0, A0OFF(sp)
++	REG_S	a1, A1OFF(sp)
++	REG_S	a2, A2OFF(sp)
++	REG_S	a3, A3OFF(sp)
++	REG_S	s0, S0OFF(sp)
++
++	# invoke_count_words(paramCount, params)
++	move    a0, a2
++	move    a1, a3
++	jal     invoke_count_words
++
++	# invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount,
++	#                      nsXPTCVariant* s, PRUint32 *reg)
++
++	REG_L   a1, A2OFF(sp)   # a1 - paramCount
++	REG_L	a2, A3OFF(sp)	# a2 - params
++
++	# save sp before we copy the params to the stack
++	move	t0, sp
++
++	# assume full size of 16 bytes per param to be safe
++	sll	v0, 4		# 16 bytes * num params
++	subu	sp, sp, v0	# make room
++	move	a0, sp		# a0 - param stack address
++
++	# create temporary stack space to write int and fp regs
++	subu    sp, 64          # 64 = 8 regs of 8 bytes
++	move    a3, sp
++
++	# save the old sp and save the arg stack
++	subu	sp, sp, 16
++	REG_S	t0, 0(sp)
++	REG_S	a0, 8(sp)
++
++	# copy the param into the stack areas
++	jal	invoke_copy_to_stack
++
++	REG_L	t3, 8(sp)	# get previous a0
++	REG_L	sp, 0(sp)	# get orig sp back
++
++	REG_L	a0, A0OFF(sp)	# a0 - that
++	REG_L	a1, A1OFF(sp)	# a1 - methodIndex
++
++	# t1 = methodIndex * pow(2, PTRLOG)
++	# (use shift instead of mult)
++	sll	t1, a1, PTRLOG
++
++	# calculate the function we need to jump to,
++	# which must then be saved in t9
++	lw	t9, 0(a0)
++	addu	t9, t9, t1
++#if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 /* G++ V3 ABI */
++	lw	t9, (t9)
++#else /* not G++ V3 ABI */
++	lw	t9, 2*PTRSIZE(t9)
++#endif /* G++ V3 ABI */
++
++	# get register save area from invoke_copy_to_stack
++	subu	t1, t3, 64
++
++	# a1..a7 and f13..f19 should now be set to what
++	# invoke_copy_to_stack told us. skip a0 and f12
++	# because that's the "this" pointer
++
++	REG_L	a1,  0(t1)
++	REG_L	a2,  8(t1)
++	REG_L	a3, 16(t1)
++	REG_L	a4, 24(t1)
++	REG_L	a5, 32(t1)
++	REG_L	a6, 40(t1)
++	REG_L	a7, 48(t1)
++
++	l.d	$f13,  0(t1)
++	l.d	$f14,  8(t1)
++	l.d	$f15, 16(t1)
++	l.d	$f16, 24(t1)
++	l.d	$f17, 32(t1)
++	l.d	$f18, 40(t1)
++	l.d	$f19, 48(t1)
++
++	# save away our stack pointer and create
++	# the stack pointer for the function
++	move	s0, sp
++	move	sp, t3
++
++	jalr	t9
++
++	move	sp, s0
++
++	RESTORE_GP64
++	REG_L	ra, RAOFF(sp)
++	REG_L	s0, S0OFF(sp)
++	PTR_ADDU	sp, FRAMESZ
++	j	ra
++.end _NS_InvokeByIndex_P
+diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_mips64.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_mips64.cpp
+new file mode 100644
+index 0000000..d1d1a7d
+--- /dev/null
++++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_mips64.cpp
+@@ -0,0 +1,173 @@
++/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
++/* ***** BEGIN LICENSE BLOCK *****
++ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
++ *
++ * The contents of this file are subject to the Mozilla Public License Version
++ * 1.1 (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ * http://www.mozilla.org/MPL/
++ *
++ * Software distributed under the License is distributed on an "AS IS" basis,
++ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
++ * for the specific language governing rights and limitations under the
++ * License.
++ *
++ * The Original Code is mozilla.org code.
++ *
++ * The Initial Developer of the Original Code is
++ * Netscape Communications Corporation.
++ * Portions created by the Initial Developer are Copyright (C) 1998
++ * the Initial Developer. All Rights Reserved.
++ *
++ * Contributor(s):
++ *   ZHANG Le    <r0bertz@gentoo.org>
++ *
++ * Alternatively, the contents of this file may be used under the terms of
++ * either of the GNU General Public License Version 2 or later (the "GPL"),
++ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
++ * in which case the provisions of the GPL or the LGPL are applicable instead
++ * of those above. If you wish to allow use of your version of this file only
++ * under the terms of either the GPL or the LGPL, and not to allow others to
++ * use your version of this file under the terms of the MPL, indicate your
++ * decision by deleting the provisions above and replace them with the notice
++ * and other provisions required by the GPL or the LGPL. If you do not delete
++ * the provisions above, a recipient may use your version of this file under
++ * the terms of any one of the MPL, the GPL or the LGPL.
++ *
++ * ***** END LICENSE BLOCK ***** */
++
++/* Platform specific code to invoke XPCOM methods on native objects */
++
++#include "xptcprivate.h"
++
++#if (_MIPS_SIM != _ABIN32)
++#error "This code is for MIPS N32 only"
++#endif
++
++extern "C" uint32
++invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
++{
++    return paramCount;
++}
++
++extern "C" void
++invoke_copy_to_stack(PRUint64* d, PRUint32 paramCount,
++                     nsXPTCVariant* s, PRUint64 *regs)
++{
++#define N_ARG_REGS       7       /* 8 regs minus 1 for "this" ptr */
++
++    for (PRUint32 i = 0; i < paramCount; i++, s++)
++    {
++        if (s->IsPtrData()) {
++            if (i < N_ARG_REGS)
++               regs[i] = (PRUint64)s->ptr;
++            else
++               *d++ = (PRUint64)s->ptr;
++            continue;
++        }
++        switch (s->type) {
++        //
++        // signed types first
++        //
++        case nsXPTType::T_I8:
++           if (i < N_ARG_REGS)
++              ((PRInt64*)regs)[i] = s->val.i8;
++           else
++              *d++ = s->val.i8;
++           break;
++        case nsXPTType::T_I16:
++           if (i < N_ARG_REGS)
++              ((PRInt64*)regs)[i] = s->val.i16;
++           else
++              *d++ = s->val.i16;
++           break;
++        case nsXPTType::T_I32:
++           if (i < N_ARG_REGS)
++              ((PRInt64*)regs)[i] = s->val.i32;
++           else
++              *d++ = s->val.i32;
++           break;
++        case nsXPTType::T_I64:
++           if (i < N_ARG_REGS)
++              ((PRInt64*)regs)[i] = s->val.i64;
++           else
++              *d++ = s->val.i64;
++           break;
++        //
++        // unsigned types next
++        //
++        case nsXPTType::T_U8:
++           if (i < N_ARG_REGS)
++              regs[i] = s->val.u8;
++           else
++              *d++ = s->val.u8;
++           break;
++        case nsXPTType::T_U16:
++           if (i < N_ARG_REGS)
++              regs[i] = s->val.u16;
++           else
++              *d++ = s->val.u16;
++           break;
++        case nsXPTType::T_U32:
++           if (i < N_ARG_REGS)
++              regs[i] = s->val.u32;
++           else
++              *d++ = s->val.u32;
++           break;
++        case nsXPTType::T_U64:
++           if (i < N_ARG_REGS)
++              regs[i] = s->val.u64;
++           else
++              *d++ = s->val.u64;
++           break;
++        case nsXPTType::T_FLOAT:
++           if (i < N_ARG_REGS)
++              *(float*)&regs[i] = s->val.f;
++           else
++              *(float*)d++ = s->val.f;
++           break;
++        case nsXPTType::T_DOUBLE:
++           if (i < N_ARG_REGS)
++              *(double*)&regs[i] = s->val.d;
++           else
++              *(double*)d++ = s->val.d;
++           break;
++        case nsXPTType::T_BOOL:
++           if (i < N_ARG_REGS)
++              regs[i] = s->val.b;
++           else
++              *d++ = s->val.b;
++           break;
++        case nsXPTType::T_CHAR:
++           if (i < N_ARG_REGS)
++              regs[i] = s->val.c;
++           else
++              *d++ = s->val.c;
++           break;
++        case nsXPTType::T_WCHAR:
++           if (i < N_ARG_REGS)
++              regs[i] = s->val.wc;
++           else
++              *d++ = s->val.wc;
++           break;
++        default:
++           // all the others are plain pointer types
++           if (i < N_ARG_REGS)
++              regs[i] = (PRUint64)s->val.p;
++           else
++              *d++ = (PRUint64)s->val.p;
++           break;
++        }
++    }
++}
++
++extern "C" nsresult _NS_InvokeByIndex_P(nsISupports* that, PRUint32 methodIndex,
++                                        PRUint32 paramCount,
++                                        nsXPTCVariant* params);
++
++EXPORT_XPCOM_API(nsresult)
++NS_InvokeByIndex_P(nsISupports* that, PRUint32 methodIndex,
++                   PRUint32 paramCount, nsXPTCVariant* params)
++{
++    return _NS_InvokeByIndex_P(that, methodIndex, paramCount, params);
++}
+diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_mips64.s b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_mips64.s
+new file mode 100644
+index 0000000..dfee24b
+--- /dev/null
++++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_mips64.s
+@@ -0,0 +1,149 @@
++/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
++/* ***** BEGIN LICENSE BLOCK *****
++ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
++ *
++ * The contents of this file are subject to the Mozilla Public License Version
++ * 1.1 (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ * http://www.mozilla.org/MPL/
++ *
++ * Software distributed under the License is distributed on an "AS IS" basis,
++ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
++ * for the specific language governing rights and limitations under the
++ * License.
++ *
++ * The Original Code is mozilla.org code.
++ *
++ * The Initial Developer of the Original Code is
++ * Netscape Communications Corporation.
++ * Portions created by the Initial Developer are Copyright (C) 1998
++ * the Initial Developer. All Rights Reserved.
++ *
++ * Contributor(s):
++ *   ZHANG Le    <r0bertz@gentoo.org>
++ *
++ * Alternatively, the contents of this file may be used under the terms of
++ * either of the GNU General Public License Version 2 or later (the "GPL"),
++ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
++ * in which case the provisions of the GPL or the LGPL are applicable instead
++ * of those above. If you wish to allow use of your version of this file only
++ * under the terms of either the GPL or the LGPL, and not to allow others to
++ * use your version of this file under the terms of the MPL, indicate your
++ * decision by deleting the provisions above and replace them with the notice
++ * and other provisions required by the GPL or the LGPL. If you do not delete
++ * the provisions above, a recipient may use your version of this file under
++ * the terms of any one of the MPL, the GPL or the LGPL.
++ *
++ * ***** END LICENSE BLOCK ***** */
++#include <sys/regdef.h>
++#include <sys/asm.h>
++
++LOCALSZ=16
++FRAMESZ=(((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
++
++A1OFF=FRAMESZ-(9*SZREG)
++A2OFF=FRAMESZ-(8*SZREG)
++A3OFF=FRAMESZ-(7*SZREG)
++A4OFF=FRAMESZ-(6*SZREG)
++A5OFF=FRAMESZ-(5*SZREG)
++A6OFF=FRAMESZ-(4*SZREG)
++A7OFF=FRAMESZ-(3*SZREG)
++GPOFF=FRAMESZ-(2*SZREG)
++RAOFF=FRAMESZ-(1*SZREG)
++
++F13OFF=FRAMESZ-(16*SZREG)
++F14OFF=FRAMESZ-(15*SZREG)
++F15OFF=FRAMESZ-(14*SZREG)
++F16OFF=FRAMESZ-(13*SZREG)
++F17OFF=FRAMESZ-(12*SZREG)
++F18OFF=FRAMESZ-(11*SZREG)
++F19OFF=FRAMESZ-(10*SZREG)
++
++#define SENTINEL_ENTRY(n)         /* defined in cpp file, not here */
++
++#if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 /* G++ V3 ABI */
++#define STUB_ENTRY(x)						\
++	.if x < 10;						\
++	MAKE_STUB(x, _ZN14nsXPTCStubBase5Stub ##x ##Ev);	\
++	.elseif x < 100;					\
++	MAKE_STUB(x, _ZN14nsXPTCStubBase6Stub ##x ##Ev);	\
++	.elseif x < 1000;					\
++	MAKE_STUB(x, _ZN14nsXPTCStubBase7Stub ##x ##Ev);	\
++	.else;							\
++	.err;							\
++	.endif
++#else /* not G++ V3 ABI */
++#define STUB_ENTRY(x)						\
++	MAKE_STUB(x, Stub ##x ##__14nsXPTCStubBase)
++#endif /* G++ V3 ABI */
++
++#define MAKE_STUB(x, name)					\
++	.globl	name;		\
++	.type	name,@function;	\
++	.aent	name,0;		\
++name:;				\
++	PTR_SUBU sp,FRAMESZ;					\
++	SETUP_GP64(GPOFF, name);				\
++	li	t0,x;						\
++	b	sharedstub;					\
++
++#
++# open a dummy frame for the function entries
++#
++	.text
++	.align	2
++	.type	dummy,@function
++	.ent	dummy, 0
++dummy:
++	.frame	sp, FRAMESZ, ra
++	.mask	0x90000FF0, RAOFF-FRAMESZ
++	.fmask	0x000FF000, F19OFF-FRAMESZ
++
++#include "xptcstubsdef.inc"
++
++sharedstub:
++
++	REG_S	a1, A1OFF(sp)
++	REG_S	a2, A2OFF(sp)
++	REG_S	a3, A3OFF(sp)
++	REG_S	a4, A4OFF(sp)
++	REG_S	a5, A5OFF(sp)
++	REG_S	a6, A6OFF(sp)
++	REG_S	a7, A7OFF(sp)
++	REG_S	ra, RAOFF(sp)
++
++	s.d	$f13, F13OFF(sp)
++	s.d	$f14, F14OFF(sp)
++	s.d	$f15, F15OFF(sp)
++	s.d	$f16, F16OFF(sp)
++	s.d	$f17, F17OFF(sp)
++	s.d	$f18, F18OFF(sp)
++	s.d	$f19, F19OFF(sp)
++
++	# t0 is methodIndex
++	move	a1, t0
++
++	# a2 is stack address where extra function params
++	# are stored that do not fit in registers
++	move	a2, sp
++	addi	a2, FRAMESZ
++
++	# a3 is stack address of a1..a7
++	move	a3, sp
++	addi	a3, A1OFF
++
++	# a4 is stack address of f13..f19
++	move	a4, sp
++	addi	a4, F13OFF
++
++	# PrepareAndDispatch(that, methodIndex, args, gprArgs, fpArgs)
++	#                     a0       a1        a2     a3       a4
++	#
++	jal	PrepareAndDispatch
++
++	REG_L	ra, RAOFF(sp)
++	RESTORE_GP64
++
++	PTR_ADDU sp, FRAMESZ
++	j	ra
++	END(dummy)
+diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_mips64.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_mips64.cpp
+new file mode 100644
+index 0000000..c404065
+--- /dev/null
++++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_mips64.cpp
+@@ -0,0 +1,218 @@
++/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
++/* ***** BEGIN LICENSE BLOCK *****
++ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
++ *
++ * The contents of this file are subject to the Mozilla Public License Version
++ * 1.1 (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ * http://www.mozilla.org/MPL/
++ *
++ * Software distributed under the License is distributed on an "AS IS" basis,
++ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
++ * for the specific language governing rights and limitations under the
++ * License.
++ *
++ * The Original Code is mozilla.org code.
++ *
++ * The Initial Developer of the Original Code is
++ * Netscape Communications Corporation.
++ * Portions created by the Initial Developer are Copyright (C) 1999
++ * the Initial Developer. All Rights Reserved.
++ *
++ * Contributor(s):
++ *   ZHANG Le    <r0bertz@gentoo.org>
++ *
++ * Alternatively, the contents of this file may be used under the terms of
++ * either of the GNU General Public License Version 2 or later (the "GPL"),
++ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
++ * in which case the provisions of the GPL or the LGPL are applicable instead
++ * of those above. If you wish to allow use of your version of this file only
++ * under the terms of either the GPL or the LGPL, and not to allow others to
++ * use your version of this file under the terms of the MPL, indicate your
++ * decision by deleting the provisions above and replace them with the notice
++ * and other provisions required by the GPL or the LGPL. If you do not delete
++ * the provisions above, a recipient may use your version of this file under
++ * the terms of any one of the MPL, the GPL or the LGPL.
++ *
++ * ***** END LICENSE BLOCK ***** */
++
++#include "xptcprivate.h"
++#include "xptiprivate.h"
++
++#if (_MIPS_SIM != _ABIN32)
++#error "This code is for MIPS N32 only"
++#endif
++
++/*
++ * This is for MIPS N32 ABI
++ *
++ * When we're called, the "gp" registers are stored in gprData and
++ * the "fp" registers are stored in fprData.  There are 8 regs
++ * available which coorespond to the first 7 parameters of the
++ * function and the "this" pointer.  If there are additional parms,
++ * they are stored on the stack at address "args".
++ *
++ */
++extern "C" nsresult
++PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex, PRUint64* args,
++                   PRUint64 *gprData, double *fprData)
++{
++#define PARAM_BUFFER_COUNT		16
++#define PARAM_GPR_COUNT			7
++#define PARAM_FPR_COUNT			7
++
++    nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
++    nsXPTCMiniVariant* dispatchParams = NULL;
++    const nsXPTMethodInfo* info;
++    PRUint8 paramCount;
++    PRUint8 i;
++    nsresult result = NS_ERROR_FAILURE;
++
++    NS_ASSERTION(self,"no self");
++
++    self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
++    NS_ASSERTION(info,"no method info");
++
++    paramCount = info->GetParamCount();
++
++    // setup variant array pointer
++    if(paramCount > PARAM_BUFFER_COUNT)
++        dispatchParams = new nsXPTCMiniVariant[paramCount];
++    else
++        dispatchParams = paramBuffer;
++    NS_ASSERTION(dispatchParams,"no place for params");
++
++    PRUint64* ap = args;
++    PRUint32 iCount = 0;
++    for(i = 0; i < paramCount; i++)
++    {
++        const nsXPTParamInfo& param = info->GetParam(i);
++        const nsXPTType& type = param.GetType();
++        nsXPTCMiniVariant* dp = &dispatchParams[i];
++
++        if(param.IsOut() || !type.IsArithmetic())
++        {
++            if (iCount < PARAM_GPR_COUNT)
++            	dp->val.p = (void*)gprData[iCount++];
++            else
++            	dp->val.p = (void*)*ap++;
++            continue;
++        }
++        // else
++        switch(type)
++        {
++        case nsXPTType::T_I8:
++           if (iCount < PARAM_GPR_COUNT)
++              dp->val.i8  = (PRInt8)gprData[iCount++];
++           else
++              dp->val.i8  = (PRInt8)*ap++;
++           break;
++
++        case nsXPTType::T_I16:
++            if (iCount < PARAM_GPR_COUNT)
++               dp->val.i16  = (PRInt16)gprData[iCount++];
++            else
++               dp->val.i16  = (PRInt16)*ap++;
++            break;
++
++        case nsXPTType::T_I32:
++            if (iCount < PARAM_GPR_COUNT)
++               dp->val.i32  = (PRInt32)gprData[iCount++];
++            else
++               dp->val.i32  = (PRInt32)*ap++;
++            break;
++
++        case nsXPTType::T_I64:
++            if (iCount < PARAM_GPR_COUNT)
++               dp->val.i64  = (PRInt64)gprData[iCount++];
++            else
++               dp->val.i64  = (PRInt64)*ap++;
++            break;
++
++        case nsXPTType::T_U8:
++            if (iCount < PARAM_GPR_COUNT)
++               dp->val.u8  = (PRUint8)gprData[iCount++];
++            else
++               dp->val.u8  = (PRUint8)*ap++;
++            break;
++
++        case nsXPTType::T_U16:
++            if (iCount < PARAM_GPR_COUNT)
++               dp->val.u16  = (PRUint16)gprData[iCount++];
++            else
++                dp->val.u16  = (PRUint16)*ap++;
++            break;
++
++        case nsXPTType::T_U32:
++            if (iCount < PARAM_GPR_COUNT)
++               dp->val.u32  = (PRUint32)gprData[iCount++];
++            else
++               dp->val.u32  = (PRUint32)*ap++;
++            break;
++
++        case nsXPTType::T_U64:
++            if (iCount < PARAM_GPR_COUNT)
++               dp->val.u64  = (PRUint64)gprData[iCount++];
++            else
++               dp->val.u64  = (PRUint64)*ap++;
++            break;
++
++        case nsXPTType::T_FLOAT:
++             if (iCount < PARAM_FPR_COUNT)
++                dp->val.f  = (double)fprData[iCount++];
++             else
++                dp->val.f  = *((double*)ap++);
++             break;
++
++        case nsXPTType::T_DOUBLE:
++              if (iCount < PARAM_FPR_COUNT)
++                 dp->val.d  = (double)fprData[iCount++];
++              else
++                 dp->val.d  = *((double*)ap++);
++              break;
++
++        case nsXPTType::T_BOOL:
++           if (iCount < PARAM_GPR_COUNT)
++              dp->val.b  = (PRBool)gprData[iCount++];
++           else
++              dp->val.b  = (PRBool)*ap++;
++           break;
++
++        case nsXPTType::T_CHAR:
++           if (iCount < PARAM_GPR_COUNT)
++              dp->val.c  = (char)gprData[iCount++];
++           else
++              dp->val.c  = (char)*ap++;
++           break;
++
++        case nsXPTType::T_WCHAR:
++           if (iCount < PARAM_GPR_COUNT)
++              dp->val.wc  = (wchar_t)gprData[iCount++];
++           else
++              dp->val.wc  = (wchar_t)*ap++;
++           break;
++
++        default:
++            NS_ASSERTION(0, "bad type");
++            break;
++        }
++    }
++
++    result = self->mOuter->CallMethod((PRUint16)methodIndex, info, dispatchParams);
++
++    if(dispatchParams != paramBuffer)
++        delete [] dispatchParams;
++
++    return result;
++}
++
++#define STUB_ENTRY(n)		/* defined in the assembly file */
++
++#define SENTINEL_ENTRY(n) \
++nsresult nsXPTCStubBase::Sentinel##n() \
++{ \
++    NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
++    return NS_ERROR_NOT_IMPLEMENTED; \
++}
++
++#include "xptcstubsdef.inc"
+-- 
+1.6.2
+
diff --git a/pkgs/applications/networking/browsers/lynx/default.nix b/pkgs/applications/networking/browsers/lynx/default.nix
index c9da94258c831..97d28dd7e2f50 100644
--- a/pkgs/applications/networking/browsers/lynx/default.nix
+++ b/pkgs/applications/networking/browsers/lynx/default.nix
@@ -15,6 +15,7 @@ stdenv.mkDerivation {
   configureFlags = if sslSupport then "--with-ssl" else "";
   
   buildInputs = [ ncurses ] ++ stdenv.lib.optional sslSupport openssl;
+  buildNativeInputs = [ ncurses ];
 
   meta = {
     homepage = http://lynx.isc.org/;
diff --git a/pkgs/applications/networking/browsers/rekonq/source.nix b/pkgs/applications/networking/browsers/rekonq/source.nix
new file mode 100644
index 0000000000000..5faeddaaf2a58
--- /dev/null
+++ b/pkgs/applications/networking/browsers/rekonq/source.nix
@@ -0,0 +1,28 @@
+{ fetchurl, fetchgit }:
+
+builtins.listToAttrs
+[
+  {
+    name = "0.4.90";
+    value = rec {
+      name = "rekonq-0.4.90";
+      src = fetchurl {
+        url = "http://kde-apps.org/CONTENT/content-files/94258-${name}.tar.bz2";
+        name = "${name}.tar.bz2";
+        sha256 = "1dmdx54asv0b4xzc8p5nadn92l8pks9cl1y9j8a46lsslwsjw3ws";
+      };
+    };
+  }
+
+  {
+    name = "scm";
+    value = {
+      name = "rekonq-0.4.0-20100514";
+      src = fetchgit {
+        url = git://gitorious.org/rekonq/mainline.git;
+        rev = "6b4f4d69a3c599bc958ccddc5f7ac1c8648a7042";
+        sha256 = "1qcwf7rsrnsbnq62cl44r48bmavc2nysi2wqhy1jxmj2ndwvsxy1";
+      };
+    };
+  }
+]
diff --git a/pkgs/applications/networking/browsers/w3m/default.nix b/pkgs/applications/networking/browsers/w3m/default.nix
index 95ed08d8834c5..6844e582026c0 100644
--- a/pkgs/applications/networking/browsers/w3m/default.nix
+++ b/pkgs/applications/networking/browsers/w3m/default.nix
@@ -16,6 +16,10 @@ stdenv.mkDerivation {
     md5 = "ba06992d3207666ed1bf2dcf7c72bf58";
   };
 
+  # Patch for the newer unstable boehm-gc 7.2alpha. Not all platforms use that
+  # alpha. At the time of writing this, boehm-gc-7.1 is the last stable.
+  patches = stdenv.lib.optional (boehmgc.name != "boehm-gc-7.1") [ ./newgc.patch ];
+
   buildInputs = [ncurses boehmgc gettext zlib]
     ++ stdenv.lib.optional sslSupport openssl
     ++ stdenv.lib.optionals graphicsSupport [imlib2 x11];
diff --git a/pkgs/applications/networking/browsers/w3m/newgc.patch b/pkgs/applications/networking/browsers/w3m/newgc.patch
new file mode 100644
index 0000000000000..db25e305c8c1f
--- /dev/null
+++ b/pkgs/applications/networking/browsers/w3m/newgc.patch
@@ -0,0 +1,15 @@
+https://bugzilla.redhat.com/show_bug.cgi?id=555467
+
+--- a/main.c.old  2007-05-31 06:49:50.000000000 +0530
++++ b/main.c      2010-02-16 16:16:24.000000000 +0530
+@@ -842,7 +842,9 @@
+     mySignal(SIGPIPE, SigPipe);
+ #endif
+
+-    orig_GC_warn_proc = GC_set_warn_proc(wrap_GC_warn_proc);
++    orig_GC_warn_proc = GC_get_warn_proc();
++    GC_set_warn_proc(wrap_GC_warn_proc);
++
+     err_msg = Strnew();
+     if (load_argc == 0) {
+        /* no URL specified */
diff --git a/pkgs/applications/networking/p2p/mldonkey/default.nix b/pkgs/applications/networking/p2p/mldonkey/default.nix
index 6bc6dce38f82b..ecc2e5f77941f 100644
--- a/pkgs/applications/networking/p2p/mldonkey/default.nix
+++ b/pkgs/applications/networking/p2p/mldonkey/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl, ocaml, zlib, bzip2, ncurses, file, gd, libpng }:
 
 stdenv.mkDerivation (rec {
-  name = "mldonkey-3.0.2";
+  name = "mldonkey-3.0.4";
   
   src = fetchurl {
     url = "mirror://sourceforge/mldonkey/${name}.tar.bz2";
-    sha256 = "0l1gcgsn603l2lv5jxjjr44r7kq2hpfcy98w3y2gf5n9d4fhja84";
+    sha256 = "0wnyi2m7126dq6r5zbqplgknnypzcx0p3q2mxcdfhp94ln7vn3f6";
   };
   
   meta = {
@@ -13,6 +13,8 @@ stdenv.mkDerivation (rec {
     homepage = http://mldonkey.sourceforge.net/;
   };
 
+  patches = [ ./gcc44mips64.patch ];
+
   buildInputs = [ ocaml zlib ncurses bzip2 file gd libpng ];
   configureFlags = [ "--disable-gui" ];
 } // (if (stdenv.system != "i686-linux" && stdenv.system != "x86_64-linux") then
diff --git a/pkgs/applications/networking/p2p/mldonkey/gcc44mips64.patch b/pkgs/applications/networking/p2p/mldonkey/gcc44mips64.patch
new file mode 100644
index 0000000000000..41449dcdd05c4
--- /dev/null
+++ b/pkgs/applications/networking/p2p/mldonkey/gcc44mips64.patch
@@ -0,0 +1,103 @@
+Patch fixing CryptoPP so:
+- it builds properly in mips64 with gcc 4.4 (gcc 4.4 does not have the 'h' asm constraint)
+- it runs properly in mips64 (where lack of templated *Precision functions gave wrong numbers).
+  An assertion check failed without this.
+
+diff --git a/src/utils/lib/CryptoPP.cc b/src/utils/lib/CryptoPP.cc
+index 9208e1c..6b12b0a 100644
+--- a/src/utils/lib/CryptoPP.cc
++++ b/src/utils/lib/CryptoPP.cc
+@@ -890,35 +890,6 @@ unsigned int Parity(unsigned long value)
+ 	return (unsigned int)value&1;
+ }
+ 
+-unsigned int BytePrecision(unsigned long value)
+-{
+-	unsigned int i;
+-	for (i=sizeof(value); i; --i)
+-		if (value >> (i-1)*8)
+-			break;
+-
+-	return i;
+-}
+-
+-unsigned int BitPrecision(unsigned long value)
+-{
+-	if (!value)
+-		return 0;
+-
+-	unsigned int l=0, h=8*sizeof(value);
+-
+-	while (h-l > 1)
+-	{
+-		unsigned int t = (l+h)/2;
+-		if (value >> t)
+-			l = t;
+-		else
+-			h = t;
+-	}
+-
+-	return h;
+-}
+-
+ unsigned long Crop(unsigned long value, unsigned int size)
+ {
+ 	if (size < 8*sizeof(value))
+@@ -1880,7 +1851,10 @@ public:
+ 		#elif defined(__x86_64__)
+ 			__asm__("mulq %3" : "=d" (r.m_halfs.high), "=a" (r.m_halfs.low) : "a" (a), "rm" (b) : "cc");
+ 		#elif defined(__mips64)
+-			__asm__("dmultu %2,%3" : "=h" (r.m_halfs.high), "=l" (r.m_halfs.low) : "r" (a), "r" (b));
++      //typedef unsigned int uint128_t __attribute__((mode(TI)));
++      __uint128_t tmp = (__uint128_t) a * b;
++      r.m_halfs.high = tmp >> 64;
++      r.m_halfs.low = tmp;
+ 		#elif defined(_M_IX86)
+ 			// for testing
+ 			word64 t = (word64)a * b;
+diff --git a/src/utils/lib/CryptoPP.h b/src/utils/lib/CryptoPP.h
+index d2ec1b2..775a898 100644
+--- a/src/utils/lib/CryptoPP.h
++++ b/src/utils/lib/CryptoPP.h
+@@ -1869,10 +1869,39 @@ template <class T> inline const T& STDMAX(const T& a, const T& b)
+ // #define GETBYTE(x, y) (((byte *)&(x))[y])
+ 
+ CRYPTOPP_DLL unsigned int Parity(unsigned long);
+-CRYPTOPP_DLL unsigned int BytePrecision(unsigned long);
+-CRYPTOPP_DLL unsigned int BitPrecision(unsigned long);
+ CRYPTOPP_DLL unsigned long Crop(unsigned long, unsigned int size);
+ 
++template <typename T>
++unsigned int BitPrecision(const T &value)
++{
++	if (!value)
++		return 0;
++
++	unsigned int l=0, h=8*sizeof(value);
++
++	while (h-l > 1)
++	{
++		unsigned int t = (l+h)/2;
++		if (value >> t)
++			l = t;
++		else
++			h = t;
++	}
++
++	return h;
++}
++
++template <typename T>
++unsigned int BytePrecision(const T &value)
++{
++	unsigned int i;
++	for (i=sizeof(value); i; --i)
++		if (value >> (i-1)*8)
++			break;
++
++	return i;
++}
++
+ inline unsigned int BitsToBytes(unsigned int bitCount)
+ {
+ 	return ((bitCount+7)/(8));
diff --git a/pkgs/applications/science/math/yacas/default.nix b/pkgs/applications/science/math/yacas/default.nix
index 148e95acee06e..7b97e1a82c009 100644
--- a/pkgs/applications/science/math/yacas/default.nix
+++ b/pkgs/applications/science/math/yacas/default.nix
@@ -9,10 +9,29 @@ stdenv.mkDerivation rec {
   };
 
   # Perl is only for the documentation
-  buildInputs = [ perl ];
+  buildNativeInputs = [ perl ];
 
   patches = [ ./gcc43.patch ];
 
+  crossAttrs = {
+    # Trick to get host-built programs needed for the cross-build.
+    # If yacas had proper makefiles, this would not be needed.
+    preConfigure = ''
+      ./configure
+      pushd src
+      make mkfastprimes 
+      cp mkfastprimes ../..
+      popd
+      pushd manmake
+      make manripper removeduplicates
+      cp manripper removeduplicates ../..
+      popd
+    '';
+    preBuild = ''
+      cp ../mkfastprimes ../manripper ../removeduplicates src
+    '';
+  };
+
   meta = { 
       description = "Easy to use, general purpose Computer Algebra System";
       homepage = http://yacas.sourceforge.net/;
diff --git a/pkgs/applications/version-management/fossil/default.nix b/pkgs/applications/version-management/fossil/default.nix
index a5f6bbfcb0c3a..3cd2711581dd1 100644
--- a/pkgs/applications/version-management/fossil/default.nix
+++ b/pkgs/applications/version-management/fossil/default.nix
@@ -19,6 +19,10 @@ stdenv.mkDerivation {
     INSTALLDIR=$out/bin make install
   '';
 
+  crossAttrs = {
+    makeFlagsArray = [ "TCC=${stdenv.cross.config}-gcc" ];
+  };
+
   meta = {
     description = "Simple, high-reliability, distributed software configuration management.";
     longDescription = ''
diff --git a/pkgs/applications/video/MPlayer/default.nix b/pkgs/applications/video/MPlayer/default.nix
index ff4154e0e5f09..47c68df1ba35f 100644
--- a/pkgs/applications/video/MPlayer/default.nix
+++ b/pkgs/applications/video/MPlayer/default.nix
@@ -1,19 +1,33 @@
 { alsaSupport ? true, xvSupport ? true, theoraSupport ? true, cacaSupport ? true
 , xineramaSupport ? true, randrSupport ? true, dvdnavSupport ? true
 , stdenv, fetchurl, x11, freetype, fontconfig, zlib
-, alsaLib, libX11, libXv, libtheora, libcaca
-, libXinerama, libXrandr, libdvdnav
-, cdparanoia, cddaSupport ? true
-, pulseaudio, pulseSupport ? true
-, amrnb, amrwb, amrSupport ? false
-, jackaudioSupport ? false, jackaudio
-, x264Support ? true, x264
-, xvidSupport ? true, xvidcore
-, lameSupport ? true, lame
+, alsaLib ? null, libXv ? null, libtheora ? null, libcaca ? null
+, libXinerama ? null, libXrandr ? null, libdvdnav ? null
+, cdparanoia ? null, cddaSupport ? true
+, amrnb ? null, amrwb ? null, amrSupport ? false
+, x11Support ? true, libX11 ? null, libXext ? null
+, jackaudioSupport ? false, jackaudio ? null
+, x264Support ? false, x264 ? null
+, xvidSupport ? false, xvidcore ? null
+, lameSupport ? true, lame ? null
 , screenSaverSupport ? true, libXScrnSaver
+, pulseSupport ? false, pulseaudio
 , mesa, pkgconfig, unzip, yasm
 }:
 
+assert alsaSupport -> alsaLib != null;
+assert x11Support -> libX11 != null;
+assert xvSupport -> (libXv != null && x11Support);
+assert theoraSupport -> libtheora != null;
+assert cacaSupport -> libcaca != null;
+assert xineramaSupport -> (libXinerama != null && x11Support);
+assert randrSupport -> (libXrandr != null && x11Support);
+assert dvdnavSupport -> libdvdnav != null;
+assert cddaSupport -> cdparanoia != null;
+assert jackaudioSupport -> jackaudio != null;
+assert amrSupport -> (amrnb != null && amrwb != null);
+assert screenSaverSupport -> libXScrnSaver != null;
+
 let
 
   codecs_src =
@@ -57,7 +71,8 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs =
-    [ x11 libXv freetype zlib mesa pkgconfig yasm ]
+    [ freetype zlib pkgconfig ]
+    ++ stdenv.lib.optional x11Support [ libX11 libXext mesa ]
     ++ stdenv.lib.optional alsaSupport alsaLib
     ++ stdenv.lib.optional xvSupport libXv
     ++ stdenv.lib.optional theoraSupport libtheora
@@ -74,18 +89,32 @@ stdenv.mkDerivation rec {
     ++ stdenv.lib.optional screenSaverSupport libXScrnSaver
     ++ stdenv.lib.optional lameSupport lame;
 
+  buildNativeInputs = [ yasm ];
+
   configureFlags = ''
     ${if cacaSupport then "--enable-caca" else "--disable-caca"}
     ${if dvdnavSupport then "--enable-dvdnav --enable-dvdread --disable-dvdread-internal" else ""}
     ${if x264Support then "--enable-x264 --extra-libs=-lx264" else ""}
     ${if codecs != null then "--codecsdir=${codecs}" else ""}
-    --enable-runtime-cpudetection
-    --enable-x11
+    ${if (stdenv.isi686 || stdenv.isx86_64) then "--enable-runtime-cpudetection" else ""}
+    ${if x11Support then "--enable-x11" else ""}
     --disable-xanim
     --disable-ivtv
   '';
 
-  NIX_LDFLAGS = "-lX11 -lXext";
+  NIX_LDFLAGS = if x11Support then "-lX11 -lXext" else "";
+
+  crossAttrs = {
+    preConfigure = ''
+      configureFlags="`echo $configureFlags |
+        sed -e 's/--build[^ ]\+//' \
+        -e 's/--host[^ ]\+//' \
+        -e 's/--codecsdir[^ ]\+//' \
+        -e 's/--enable-runtime-cpudetection//' `"
+      configureFlags="$configureFlags --target=${stdenv.cross.arch}-linux
+        --cc=$crossConfig-gcc --as=$crossConfig-as"
+    '';
+  };
 
   meta = {
     description = "A movie player that supports many video formats";
diff --git a/pkgs/applications/window-managers/icewm/default.nix b/pkgs/applications/window-managers/icewm/default.nix
index 5394b7f507b20..02096cd6141f7 100644
--- a/pkgs/applications/window-managers/icewm/default.nix
+++ b/pkgs/applications/window-managers/icewm/default.nix
@@ -1,18 +1,25 @@
-{ stdenv, fetchurl, gettext, libjpeg, libtiff, libungif, libpng, imlib, xlibs }:
+{ stdenv, fetchurl, gettext, libjpeg, libtiff, libungif, libpng, imlib, xlibs, automake, pkgconfig,
+  gtk }:
 
 stdenv.mkDerivation rec {
-  name = "icewm-1.2.37";
+  name = "icewm-1.3.6";
 
   buildInputs =
     [ gettext libjpeg libtiff libungif libpng imlib
       xlibs.libX11 xlibs.libXft xlibs.libXext xlibs.libXinerama xlibs.libXrandr
+      pkgconfig gtk
     ];
 
   src = fetchurl {
     url = "mirror://sourceforge/icewm/${name}.tar.gz";
-    sha256 = "15852k96z2w19v3d02jynxyf6ld378hbkd6lpy64byysrmjh3dmz";
+    sha256 = "1pr7rc10rddwvy4ncng4mf5fpxd1nqjsw34xba9ngsg32rg57b91";
   };
 
+  # The fuloong2f is not supported by 1.3.6 still
+  preConfigure = ''
+    cp ${automake}/share/automake*/config.{sub,guess} .
+  '';
+
   meta = {
     description = "A window manager for the X Window System";
     homepage = http://www.icewm.org/;
diff --git a/pkgs/build-support/fetchurl/mirrors.nix b/pkgs/build-support/fetchurl/mirrors.nix
index cd53f0d0d5507..c27b8967e8096 100644
--- a/pkgs/build-support/fetchurl/mirrors.nix
+++ b/pkgs/build-support/fetchurl/mirrors.nix
@@ -122,14 +122,9 @@ rec {
     http://ftp.cc.uoc.gr/mirrors/nongnu.org/
     http://ftp.twaren.net/Unix/NonGNU/
     http://mirror.csclub.uwaterloo.ca/nongnu/
-    http://mirror.publicns.net/pub/nongnu/
     http://nongnu.askapache.com/
-    http://nongnu.bigsearcher.com/
     http://savannah.c3sl.ufpr.br/
     http://www.centervenus.com/mirrors/nongnu/
-    http://www.de-mirrors.de/nongnu/
-    http://www.very-clever.com/download/nongnu/
-    http://www.wikifusion.info/nongnu/
   ];
 
   # BitlBee mirrors, see http://www.bitlbee.org/main.php/mirrors.html .
diff --git a/pkgs/build-support/gcc-cross-wrapper/builder.sh b/pkgs/build-support/gcc-cross-wrapper/builder.sh
index 674c2b89b5263..fae37342940f9 100644
--- a/pkgs/build-support/gcc-cross-wrapper/builder.sh
+++ b/pkgs/build-support/gcc-cross-wrapper/builder.sh
@@ -1,34 +1,51 @@
 source $stdenv/setup
 
+mkdir $out
+mkdir $out/bin
+mkdir $out/nix-support
 
 # Force gcc to use ld-wrapper.sh when calling ld.
 cflagsCompile="-B$out/bin/"
 
 if test -z "$nativeLibc"; then
-    cflagsCompile="$cflagsCompile -B$libc/lib/ -isystem $libc/include"
+    cflagsCompile="$cflagsCompile -B$gccLibs/lib -B$libc/lib/ -isystem $libc/include"
     ldflags="$ldflags -L$libc/lib"
     # Get the proper dynamic linker for glibc and uclibc. 
     dlinker=`eval 'echo $libc/lib/ld*.so.?'`
     if [ -n "$dlinker" ]; then
       ldflagsBefore="-dynamic-linker $dlinker"
+
+      # The same as above, but put into files, useful for the gcc builder.
+      echo $dlinker > $out/nix-support/dynamic-linker
+      # This trick is to avoid dependencies on the cross-toolchain gcc
+      # for libgcc, libstdc++, ...
+      # -L is for libtool's .la files, and -rpath for the usual fixupPhase
+      # shrinking rpaths.
+      if [ -n "$gccLibs" ]; then
+        ldflagsBefore="$ldflagsBefore -rpath $gccLibs/lib"
+      fi
     fi
+
+    echo "$cflagsCompile -B$libc/lib/ -idirafter $libc/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags
+
+    echo "-L$libc/lib" > $out/nix-support/libc-ldflags
+
+    # The dynamic linker is passed in `ldflagsBefore' to allow
+    # explicit overrides of the dynamic linker by callers to gcc/ld
+    # (the *last* value counts, so ours should come first).
+    echo "$ldflagsBefore" > $out/nix-support/libc-ldflags-before
 fi
 
 if test -n "$nativeTools"; then
     gccPath="$nativePrefix/bin"
     ldPath="$nativePrefix/bin"
 else
-    ldflags="$ldflags -L$gcc/lib"
+    ldflags="$ldflags -L$gcc/lib -L$gcc/lib64"
     gccPath="$gcc/bin"
     ldPath="$binutils/$crossConfig/bin"
 fi
 
 
-mkdir $out
-mkdir $out/bin
-mkdir $out/nix-support
-
-
 doSubstitute() {
     local src=$1
     local dst=$2
diff --git a/pkgs/build-support/gcc-cross-wrapper/default.nix b/pkgs/build-support/gcc-cross-wrapper/default.nix
index 362e378273dd2..8bf820e3d3413 100644
--- a/pkgs/build-support/gcc-cross-wrapper/default.nix
+++ b/pkgs/build-support/gcc-cross-wrapper/default.nix
@@ -13,6 +13,23 @@ assert nativeTools -> nativePrefix != "";
 assert !nativeTools -> gcc != null && binutils != null;
 assert !noLibc -> (!nativeLibc -> libc != null);
 
+let
+  chosenName = if name == "" then gcc.name else name;
+  gccLibs = stdenv.mkDerivation {
+    name = chosenName + "-libs";
+    phases = [ "installPhase" ];
+    installPhase = ''
+      echo $out
+      ensureDir $out
+      cp -Rd ${gcc}/${cross.config}/lib $out/lib
+      chmod -R +w $out/lib
+      for a in $out/lib/*.la; do
+          sed -i -e s,${gcc}/${cross.config}/lib,$out/lib,g $a
+      done
+      rm -f $out/lib/*.py
+    '';
+  };
+in
 stdenv.mkDerivation {
   builder = ./builder.sh;
   setupHook = ./setup-hook.sh;
@@ -22,7 +39,8 @@ stdenv.mkDerivation {
   addFlags = ./add-flags;
   inherit nativeTools nativeLibc nativePrefix gcc libc binutils;
   crossConfig = if (cross != null) then cross.config else null;
-  name = if name == "" then gcc.name else name;
+  gccLibs = if gcc != null then gccLibs else null;
+  name = chosenName;
   langC = if nativeTools then true else gcc.langC;
   langCC = if nativeTools then true else gcc.langCC;
   langF77 = if nativeTools then false else gcc ? langFortran;
diff --git a/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh
index 491de8f7f9848..98baafb4878d9 100644
--- a/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh
+++ b/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh
@@ -75,14 +75,18 @@ if test "$dontLink" != "1"; then
     # Add the flags that should be passed to the linker (and prevent
     # `ld-wrapper' from adding NIX_CROSS_LDFLAGS again).
     for i in $NIX_CROSS_LDFLAGS_BEFORE; do
-        extraBefore=(${extraBefore[@]} "-Wl,$i")
+        if test "${i:0:3}" = "-L/"; then
+            extraBefore=(${extraBefore[@]} "$i")
+        else
+            extraBefore=(${extraBefore[@]} "-Wl,$i")
+        fi
     done
     for i in $NIX_CROSS_LDFLAGS; do
-	if test "${i:0:3}" = "-L/"; then
-	    extraAfter=(${extraAfter[@]} "$i")
-	else
-	    extraAfter=(${extraAfter[@]} "-Wl,$i")
-	fi
+        if test "${i:0:3}" = "-L/"; then
+            extraAfter=(${extraAfter[@]} "$i")
+        else
+            extraAfter=(${extraAfter[@]} "-Wl,$i")
+        fi
     done
     export NIX_CROSS_LDFLAGS_SET=1
 
diff --git a/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh b/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh
index 0c98062a2db19..a7be09283ee04 100644
--- a/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh
+++ b/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh
@@ -26,7 +26,7 @@ crossStripDirs() {
     dirs=${dirsNew}
 
     if test -n "${dirs}"; then
-        header "stripping (with flags $stripFlags) in $dirs"
+        header "cross stripping (with flags $stripFlags) in $dirs"
         # libc_nonshared.a should never be stripped, or builds will break.
         find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} $crossConfig-strip $stripFlags || true
         stopNest
@@ -68,7 +68,9 @@ if test -n "@libc@"; then
     crossAddCVars @libc@
 fi
 
-configureFlags="$configureFlags --build=$system --host=$crossConfig"
+if test "$dontSetConfigureCross" != "1"; then
+    configureFlags="$configureFlags --build=$system --host=$crossConfig"
+fi
 # Disabling the tests when cross compiling, as usually the tests are meant for
 # native compilations.
 doCheck=""
diff --git a/pkgs/build-support/gcc-wrapper/default.nix b/pkgs/build-support/gcc-wrapper/default.nix
index c97fd4eb495d0..56069ec17b3b1 100644
--- a/pkgs/build-support/gcc-wrapper/default.nix
+++ b/pkgs/build-support/gcc-wrapper/default.nix
@@ -67,6 +67,7 @@ stdenv.mkDerivation {
        if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else
        if stdenv.system == "armv5tel-linux" then "ld-linux.so.3" else
        if stdenv.system == "powerpc-linux" then "ld.so.1" else
+       if stdenv.system == "mips64-linux" then "ld.so.1" else
        abort "don't know the name of the dynamic linker for this platform")
     else "";
 }
diff --git a/pkgs/build-support/gcc-wrapper/default2.nix b/pkgs/build-support/gcc-wrapper/default2.nix
deleted file mode 100644
index efade01963b7f..0000000000000
--- a/pkgs/build-support/gcc-wrapper/default2.nix
+++ /dev/null
@@ -1,72 +0,0 @@
-# The Nix `gcc' stdenv.mkDerivation is not directly usable, since it doesn't
-# know where the C library and standard header files are.  Therefore
-# the compiler produced by that package cannot be installed directly
-# in a user environment and used from the command line.  This
-# stdenv.mkDerivation provides a wrapper that sets up the right environment
-# variables so that the compiler and the linker just "work".
-
-{ name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? ""
-, gcc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? ""
-, zlib ? null
-}:
-
-assert nativeTools -> nativePrefix != "";
-assert !nativeTools -> gcc != null && binutils != null && coreutils != null;
-assert !nativeLibc -> libc != null;
-
-# For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper
-assert (gcc != null && gcc ? langVhdl && gcc.langVhdl) -> zlib != null;
-
-let
-
-  gccVersion = (builtins.parseDrvName gcc.name).version;
-  gccName = (builtins.parseDrvName gcc.name).name;
-  
-in
-
-stdenv.mkDerivation {
-  name =
-    (if name != "" then name else gccName + "-wrapper") +
-    (if gcc != null && gccVersion != "" then "-" + gccVersion else "");
-  
-  builder = ./builder.sh;
-  setupHook = ./setup-hook.sh;
-  gccWrapper = ./gcc-wrapper.sh;
-  gnatWrapper = ./gnat-wrapper.sh;
-  gnatlinkWrapper = ./gnatlink-wrapper.sh;
-  ldWrapper = ./ld-wrapper2.sh;
-  utils = ./utils.sh;
-  addFlags = ./add-flags;
-  
-  inherit nativeTools nativeLibc nativePrefix gcc;
-  libc = if nativeLibc then null else libc;
-  binutils = if nativeTools then null else binutils;
-  # The wrapper scripts use 'cat', so we may need coreutils
-  coreutils = if nativeTools then null else coreutils;
-  
-  langC = if nativeTools then true else gcc.langC;
-  langCC = if nativeTools then true else gcc.langCC;
-  langFortran = if nativeTools then false else gcc ? langFortran;
-  langAda = if nativeTools then false else gcc ? langAda && gcc.langAda;
-  langVhdl = if nativeTools then false else gcc ? langVhdl && gcc.langVhdl;
-  zlib = if (gcc != null && gcc ? langVhdl) then zlib else null;
-  shell = if shell == "" then stdenv.shell else shell;
-  
-  meta =
-    let gcc_ = if gcc != null then gcc else {}; in
-    (if gcc_ ? meta then removeAttrs gcc.meta ["priority"] else {}) //
-    { description =
-        stdenv.lib.attrByPath ["meta" "description"] "System C compiler" gcc_
-        + " (wrapper script)";
-    };
-
-  # The dynamic linker has different names on different Linux platforms.
-  dynamicLinker =
-    if !nativeLibc then
-      (if stdenv.system == "i686-linux" then "ld-linux.so.2" else
-       if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else
-       if stdenv.system == "armv5tel-linux" then "ld-linux.so.3" else
-       if stdenv.system == "powerpc-linux" then "ld.so.1" else
-       abort "don't know the name of the dynamic linker for this platform")
-    else "";
-}
diff --git a/pkgs/build-support/gcc-wrapper/ld-wrapper.sh b/pkgs/build-support/gcc-wrapper/ld-wrapper.sh
index 3ca9e815a8f1a..99ba3968ae339 100644
--- a/pkgs/build-support/gcc-wrapper/ld-wrapper.sh
+++ b/pkgs/build-support/gcc-wrapper/ld-wrapper.sh
@@ -82,6 +82,13 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then
         rpath="$rpath $1 "
     }
 
+    libs=""
+    addToLibs() {
+        libs="$libs $1"
+    }
+
+    rpath=""
+
     # First, find all -L... switches.
     allParams=("${params[@]}" ${extra[@]})
     n=0
@@ -93,6 +100,11 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then
         elif test "$p" = "-L"; then
             addToLibPath ${p2}
             n=$((n + 1))
+        elif test "$p" = "-l"; then
+            addToLibs ${p2}
+            n=$((n + 1))
+        elif test "${p:0:2}" = "-l"; then
+            addToLibs ${p:2}
         elif [[ "$p" =~ ^[^-].*\.so($|\.) ]]; then
             # This is a direct reference to a shared library, so add
             # its directory to the rpath.
@@ -105,24 +117,14 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then
     # Second, for each directory in the library search path (-L...),
     # see if it contains a dynamic library used by a -l... flag.  If
     # so, add the directory to the rpath.
-    rpath=""
     
-    for i in $libPath; do
-        n=0
-        while test $n -lt ${#allParams[*]}; do
-            p=${allParams[n]}
-            p2=${allParams[$((n+1))]}
-            if test "${p:0:2}" = "-l" -a -f "$i/lib${p:2}.so"; then
-                addToRPath $i
-                break
-            elif test "$p" = "-l" -a -f "$i/lib${p2}"; then
-                # I haven't seen `-l foo', but you never know...
-                addToRPath $i
+    for i in $libs; do
+        for j in $libPath; do
+            if test -f "$j/lib$i.so"; then
+                addToRPath $j
                 break
             fi
-            n=$((n + 1))
         done
-            
     done
     
 
diff --git a/pkgs/build-support/gcc-wrapper/ld-wrapper2.sh b/pkgs/build-support/gcc-wrapper/ld-wrapper2.sh
deleted file mode 100644
index 99ba3968ae339..0000000000000
--- a/pkgs/build-support/gcc-wrapper/ld-wrapper2.sh
+++ /dev/null
@@ -1,154 +0,0 @@
-#! @shell@ -e
-
-if test -n "$NIX_LD_WRAPPER_START_HOOK"; then
-    source "$NIX_LD_WRAPPER_START_HOOK"
-fi
-
-if test -z "$NIX_GCC_WRAPPER_FLAGS_SET"; then
-    source @out@/nix-support/add-flags.sh
-fi
-
-source @out@/nix-support/utils.sh
-
-
-# Optionally filter out paths not refering to the store.
-params=("$@")
-if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE" \
-        -a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_LDFLAGS_SET" \); then
-    rest=()
-    n=0
-    while test $n -lt ${#params[*]}; do
-        p=${params[n]}
-        p2=${params[$((n+1))]}
-        if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
-            skip $p
-        elif test "$p" = "-L" && badPath "$p2"; then
-            n=$((n + 1)); skip $p2
-        elif test "$p" = "-rpath" && badPath "$p2"; then
-            n=$((n + 1)); skip $p2
-        elif test "$p" = "-dynamic-linker" && badPath "$p2"; then
-            n=$((n + 1)); skip $p2
-        elif test "${p:0:1}" = "/" && badPath "$p"; then
-            # We cannot skip this; barf.
-            echo "impure path \`$p' used in link" >&2
-            exit 1
-        else
-            rest=("${rest[@]}" "$p")
-        fi
-        n=$((n + 1))
-    done
-    params=("${rest[@]}")
-fi
-
-
-extra=()
-extraBefore=()
-
-if test -z "$NIX_LDFLAGS_SET"; then
-    extra=(${extra[@]} $NIX_LDFLAGS)
-    extraBefore=(${extraBefore[@]} $NIX_LDFLAGS_BEFORE)
-fi
-
-
-# Add all used dynamic libraries to the rpath.
-if test "$NIX_DONT_SET_RPATH" != "1"; then
-
-    libPath=""
-    addToLibPath() {
-        local path="$1"
-        if test "${path:0:1}" != "/"; then return 0; fi
-        case "$path" in
-            *..*|*./*|*/.*|*//*)
-                local path2
-                if path2=$(readlink -f "$path"); then
-                    path="$path2"
-                fi
-                ;;
-        esac
-        case $libPath in
-            *\ $path\ *) return 0 ;;
-        esac
-        libPath="$libPath $path "
-    }
-    
-    addToRPath() {
-        # If the path is not in the store, don't add it to the rpath.
-        # This typically happens for libraries in /tmp that are later
-        # copied to $out/lib.  If not, we're screwed.
-        if test "${1:0:${#NIX_STORE}}" != "$NIX_STORE"; then return 0; fi
-        case $rpath in
-            *\ $1\ *) return 0 ;;
-        esac
-        rpath="$rpath $1 "
-    }
-
-    libs=""
-    addToLibs() {
-        libs="$libs $1"
-    }
-
-    rpath=""
-
-    # First, find all -L... switches.
-    allParams=("${params[@]}" ${extra[@]})
-    n=0
-    while test $n -lt ${#allParams[*]}; do
-        p=${allParams[n]}
-        p2=${allParams[$((n+1))]}
-        if test "${p:0:3}" = "-L/"; then
-            addToLibPath ${p:2}
-        elif test "$p" = "-L"; then
-            addToLibPath ${p2}
-            n=$((n + 1))
-        elif test "$p" = "-l"; then
-            addToLibs ${p2}
-            n=$((n + 1))
-        elif test "${p:0:2}" = "-l"; then
-            addToLibs ${p:2}
-        elif [[ "$p" =~ ^[^-].*\.so($|\.) ]]; then
-            # This is a direct reference to a shared library, so add
-            # its directory to the rpath.
-            path="$(dirname "$p")";
-            addToRPath "${path}"
-        fi
-        n=$((n + 1))
-    done
-
-    # Second, for each directory in the library search path (-L...),
-    # see if it contains a dynamic library used by a -l... flag.  If
-    # so, add the directory to the rpath.
-    
-    for i in $libs; do
-        for j in $libPath; do
-            if test -f "$j/lib$i.so"; then
-                addToRPath $j
-                break
-            fi
-        done
-    done
-    
-
-    # Finally, add `-rpath' switches.
-    for i in $rpath; do
-        extra=(${extra[@]} -rpath $i)
-    done
-fi
-
-
-# Optionally print debug info.
-if test "$NIX_DEBUG" = "1"; then
-  echo "original flags to @ld@:" >&2
-  for i in "${params[@]}"; do
-      echo "  $i" >&2
-  done
-  echo "extra flags to @ld@:" >&2
-  for i in ${extra[@]}; do
-      echo "  $i" >&2
-  done
-fi
-
-if test -n "$NIX_LD_WRAPPER_EXEC_HOOK"; then
-    source "$NIX_LD_WRAPPER_EXEC_HOOK"
-fi
-
-exec @ld@ ${extraBefore[@]} "${params[@]}" ${extra[@]}
diff --git a/pkgs/desktops/gnome-2.28/default.nix b/pkgs/desktops/gnome-2.28/default.nix
index 0efd9d20dfa04..7e8c41920527e 100644
--- a/pkgs/desktops/gnome-2.28/default.nix
+++ b/pkgs/desktops/gnome-2.28/default.nix
@@ -228,7 +228,7 @@ pkgs.makeOverridable
 
   # Removed from recent GNOME releases, but still required
   scrollkeeper = import ./desktop/scrollkeeper {
-    inherit (pkgs) stdenv fetchurl pkgconfig perl perlXMLParser libxml2 libxslt docbook_xml_dtd_42;
+    inherit (pkgs) stdenv fetchurl pkgconfig perl perlXMLParser libxml2 libxslt docbook_xml_dtd_42 automake;
   };
 
   # scrollkeeper replacement
diff --git a/pkgs/desktops/gnome-2.28/desktop/scrollkeeper/default.nix b/pkgs/desktops/gnome-2.28/desktop/scrollkeeper/default.nix
index a63d179ff9486..97dcbf4e0041a 100644
--- a/pkgs/desktops/gnome-2.28/desktop/scrollkeeper/default.nix
+++ b/pkgs/desktops/gnome-2.28/desktop/scrollkeeper/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, pkgconfig, perl, perlXMLParser, libxml2, libxslt, docbook_xml_dtd_42}:
+{stdenv, fetchurl, pkgconfig, perl, perlXMLParser, libxml2, libxslt, docbook_xml_dtd_42, automake}:
 
 stdenv.mkDerivation {
   name = "scrollkeeper-0.3.14";
@@ -6,9 +6,13 @@ stdenv.mkDerivation {
     url = mirror://gnome/sources/scrollkeeper/0.3/scrollkeeper-0.3.14.tar.bz2;
     sha256 = "08n1xgj1f53zahwm0wpn3jid3rfbhi3iwby0ilaaldnid5qriqgc";
   };
+
+  # The fuloong2f is not supported by scrollkeeper-0.3.14 config.guess
   preConfigure = "
     substituteInPlace extract/dtds/Makefile.am --replace /usr/bin/xmlcatalog xmlcatalog
+    cp ${automake}/share/automake*/config.{sub,guess} .
   ";
+
   buildInputs = [pkgconfig perl perlXMLParser libxml2 libxslt];
   configureFlags = "--with-xml-catalog=${docbook_xml_dtd_42}/xml/dtd/docbook/docbook.cat";
 }
diff --git a/pkgs/desktops/kde-4.4/support/phonon/phonon-4.4.1-gst-plugins-include.patch b/pkgs/desktops/kde-4.4/support/phonon/phonon-4.4.1-gst-plugins-include.patch
new file mode 100644
index 0000000000000..46782840570c1
--- /dev/null
+++ b/pkgs/desktops/kde-4.4/support/phonon/phonon-4.4.1-gst-plugins-include.patch
@@ -0,0 +1,263 @@
+From 1e3a6c25bc258021899c0a31ea9b68ea656d8f6b Mon Sep 17 00:00:00 2001
+From: Yury G. Kudryashov <urkud.urkud@gmail.com>
+Date: Sat, 8 May 2010 18:42:35 +0400
+Subject: [PATCH] Find include directories as well
+
+Makes it possible to compile phonon if gstreamer and gst-plugins-base are
+installed into different prefixes. Theoretically, should work even if each
+plugin is installed into dedicated prefix, but this feature is not tested.
+---
+ cmake/FindGStreamerPlugins.cmake |  160 +++++++++++++++-----------------------
+ gstreamer/CMakeLists.txt         |    4 +-
+ gstreamer/ConfigureChecks.cmake  |   10 +-
+ 3 files changed, 72 insertions(+), 102 deletions(-)
+
+diff --git a/cmake/FindGStreamerPlugins.cmake b/cmake/FindGStreamerPlugins.cmake
+index f6d70d5..9e7a4d0 100644
+--- a/cmake/FindGStreamerPlugins.cmake
++++ b/cmake/FindGStreamerPlugins.cmake
+@@ -2,19 +2,63 @@
+ # Once done this will define
+ #
+ #  GSTREAMERPLUGINSBASE_FOUND - system has GStreamer_Plugins
+-#  GSTREAMERPLUGINSBASE_INCLUDE_DIR - the GStreamer_Plugins include directory
++#  GSTREAMERPLUGINSBASE_INCLUDE_DIRS - the GStreamer_Plugins include directories
+ #  GSTREAMERPLUGINSBASE_LIBRARIES - the libraries needed to use GStreamer_Plugins
+-#  GSTREAMERPLUGINSBASE_DEFINITIONS - Compiler switches required for using GStreamer_Plugins
++#
++# The following variables are set for each plugin PLUGINNAME:
++#
++#  GSTREAMER_PLUGIN_PLUGINNAME_FOUND - plugin is found
++#  GSTREAMER_PLUGIN_PLUGINNAME_INCLUDE_DIR - plugin include directory
++#  GSTREAMER_PLUGIN_PLUGINNAME_LIBRARY - the library needed to use plugin
+ #
+ #  (c)2009 Nokia Corporation
++#  (c)2010 Yury G. Kudryashov <urkud@ya.ru>
+ 
+ FIND_PACKAGE(PkgConfig REQUIRED)
+ 
+ IF (NOT WIN32)
+    # don't make this check required - otherwise you can't use macro_optional_find_package on this one
+-   PKG_CHECK_MODULES( PKG_GSTREAMER gstreamer-plugins-base-0.10 )
++   PKG_CHECK_MODULES( PKG_GSTREAMER_PLUGINSBASE gstreamer-plugins-base-0.10 )
+ ENDIF (NOT WIN32)
+ 
++MACRO(MACRO_FIND_GSTREAMER_PLUGIN _plugin _header)
++   STRING(TOUPPER ${_plugin} _upper)
++   IF (NOT WIN32)
++      # don't make this check required - otherwise you can't use macro_optional_find_package on this one
++      PKG_CHECK_MODULES( PKG_GSTREAMER_${_upper} gstreamer-${_plugin}-0.10 )
++   ENDIF (NOT WIN32)
++
++   FIND_LIBRARY(GSTREAMER_PLUGIN_${_upper}_LIBRARY NAMES gst${_plugin}-0.10
++      PATHS
++      ${PKG_GSTREAMER_PLUGINSBASE_LIBRARY_DIRS}
++      ${PKG_GSTREAMER_${_upper}_LIBRARY_DIRS}
++      )
++
++   FIND_PATH(GSTREAMER_PLUGIN_${_upper}_INCLUDE_DIR
++       NAMES gst/${_plugin}/${_header}
++       PATHS
++       ${PKG_GSTREAMER_PLUGINSBASE_INCLUDE_DIRS}
++       ${PKG_GSTREAMER_${_upper}_INCLUDE_DIRS}
++       )
++
++   IF(GSTREAMER_PLUGIN_${_upper}_LIBRARY AND GSTREAMER_PLUGIN_${_upper}_INCLUDE_DIR)
++      SET(GSTREAMER_PLUGIN_${_upper}_FOUND TRUE)
++      LIST(APPEND GSTREAMERPLUGINSBASE_INCLUDE_DIRS GSTREAMER_${_upper}_INCLUDE_DIR)
++      LIST(APPEND GSTREAMERPLUGINSBASE_LIBRARIES GSTREAMER_${_upper}_LIBRARY)
++   ELSE(GSTREAMER_PLUGIN_${_upper}_LIBRARY AND GSTREAMER_PLUGIN_${_upper}_INCLUDE_DIR)
++      MESSAGE(STATUS "Could not find ${_plugin} plugin")
++      MESSAGE(STATUS "${_upper} library: ${GSTREAMER_${_upper}_LIBRARY}")
++      MESSAGE(STATUS "${_upper} include dir: ${GSTREAMER_${_upper}_INCLUDE_DIR}")
++      SET(GSTREAMER_PLUGIN_${_upper}_FOUND FALSE)
++      SET(GSTREAMER_PLUGIN_${_upper}_LIBRARY GSTREAMER_${_upper}_LIBRARY-NOTFOUND)
++      SET(GSTREAMER_PLUGIN_${_upper}_INCLUDE_DIR GSTREAMER_${_upper}_INCLUDE_DIR-NOTFOUND)
++      SET(GSTREAMERPLUGINSBASE_FOUND FALSE)
++   ENDIF(GSTREAMER_PLUGIN_${_upper}_LIBRARY AND GSTREAMER_PLUGIN_${_upper}_INCLUDE_DIR)
++
++   MARK_AS_ADVANCED(GSTREAMER_PLUGIN_${_upper}_LIBRARY
++      GSTREAMER_PLUGIN_${_upper}_INCLUDE_DIR)
++ENDMACRO(MACRO_FIND_GSTREAMER_PLUGIN)
++
+ #
+ # Base plugins:
+ #  audio
+@@ -31,87 +75,21 @@ ENDIF (NOT WIN32)
+ # The gstinterfaces-0.10 library is found by FindGStreamer.cmake
+ #
+ 
+-FIND_LIBRARY(GSTREAMER_PLUGIN_AUDIO_LIBRARIES NAMES gstaudio-0.10
+-   PATHS
+-   ${PKG_GSTREAMER_LIBRARY_DIRS}
+-   )
+-FIND_LIBRARY(GSTREAMER_PLUGIN_CDDA_LIBRARIES NAMES gstcdda-0.10
+-   PATHS
+-   ${PKG_GSTREAMER_LIBRARY_DIRS}
+-   )
+-FIND_LIBRARY(GSTREAMER_PLUGIN_NETBUFFER_LIBRARIES NAMES gstnetbuffer-0.10
+-   PATHS
+-   ${PKG_GSTREAMER_LIBRARY_DIRS}
+-   )
+-FIND_LIBRARY(GSTREAMER_PLUGIN_PBUTILS_LIBRARIES NAMES gstpbutils-0.10
+-   PATHS
+-   ${PKG_GSTREAMER_LIBRARY_DIRS}
+-   )
+-FIND_LIBRARY(GSTREAMER_PLUGIN_RIFF_LIBRARIES NAMES gstriff-0.10
+-   PATHS
+-   ${PKG_GSTREAMER_LIBRARY_DIRS}
+-   )
+-FIND_LIBRARY(GSTREAMER_PLUGIN_RTP_LIBRARIES NAMES gstrtp-0.10
+-   PATHS
+-   ${PKG_GSTREAMER_LIBRARY_DIRS}
+-   )
+-FIND_LIBRARY(GSTREAMER_PLUGIN_RTSP_LIBRARIES NAMES gstrtsp-0.10
+-   PATHS
+-   ${PKG_GSTREAMER_LIBRARY_DIRS}
+-   )
+-FIND_LIBRARY(GSTREAMER_PLUGIN_SDP_LIBRARIES NAMES gstsdp-0.10
+-   PATHS
+-   ${PKG_GSTREAMER_LIBRARY_DIRS}
+-   )
+-FIND_LIBRARY(GSTREAMER_PLUGIN_TAG_LIBRARIES NAMES gsttag-0.10
+-   PATHS
+-   ${PKG_GSTREAMER_LIBRARY_DIRS}
+-   )
+-FIND_LIBRARY(GSTREAMER_PLUGIN_VIDEO_LIBRARIES NAMES gstvideo-0.10
+-   PATHS
+-   ${PKG_GSTREAMER_LIBRARY_DIRS}
+-   )
+-
+-IF (GSTREAMER_PLUGIN_AUDIO_LIBRARIES AND
+-    GSTREAMER_PLUGIN_CDDA_LIBRARIES AND
+-    GSTREAMER_PLUGIN_NETBUFFER_LIBRARIES AND
+-    GSTREAMER_PLUGIN_PBUTILS_LIBRARIES AND
+-    GSTREAMER_PLUGIN_RIFF_LIBRARIES AND
+-    GSTREAMER_PLUGIN_RTP_LIBRARIES AND
+-    GSTREAMER_PLUGIN_RTSP_LIBRARIES AND
+-    GSTREAMER_PLUGIN_SDP_LIBRARIES AND
+-    GSTREAMER_PLUGIN_TAG_LIBRARIES AND
+-    GSTREAMER_PLUGIN_VIDEO_LIBRARIES)
+-   SET(GSTREAMERPLUGINSBASE_FOUND TRUE)
+-ELSE (GSTREAMER_PLUGIN_AUDIO_LIBRARIES AND
+-    GSTREAMER_PLUGIN_CDDA_LIBRARIES AND
+-    GSTREAMER_PLUGIN_NETBUFFER_LIBRARIES AND
+-    GSTREAMER_PLUGIN_PBUTILS_LIBRARIES AND
+-    GSTREAMER_PLUGIN_RIFF_LIBRARIES AND
+-    GSTREAMER_PLUGIN_RTP_LIBRARIES AND
+-    GSTREAMER_PLUGIN_RTSP_LIBRARIES AND
+-    GSTREAMER_PLUGIN_SDP_LIBRARIES AND
+-    GSTREAMER_PLUGIN_TAG_LIBRARIES AND
+-    GSTREAMER_PLUGIN_VIDEO_LIBRARIES)
+-   SET(GSTREAMERPLUGINSBASE_FOUND FALSE)
+-ENDIF (GSTREAMER_PLUGIN_AUDIO_LIBRARIES AND
+-    GSTREAMER_PLUGIN_CDDA_LIBRARIES AND
+-    GSTREAMER_PLUGIN_NETBUFFER_LIBRARIES AND
+-    GSTREAMER_PLUGIN_PBUTILS_LIBRARIES AND
+-    GSTREAMER_PLUGIN_RIFF_LIBRARIES AND
+-    GSTREAMER_PLUGIN_RTP_LIBRARIES AND
+-    GSTREAMER_PLUGIN_RTSP_LIBRARIES AND
+-    GSTREAMER_PLUGIN_SDP_LIBRARIES AND
+-    GSTREAMER_PLUGIN_TAG_LIBRARIES AND
+-    GSTREAMER_PLUGIN_VIDEO_LIBRARIES)
++SET(GSTREAMER_PLUGINSBASE_FOUND TRUE)
++MACRO_FIND_GSTREAMER_PLUGIN(audio audio.h)
++MACRO_FIND_GSTREAMER_PLUGIN(cdda gstcddabasesrc.h)
++MACRO_FIND_GSTREAMER_PLUGIN(netbuffer gstnetbuffer.h)
++MACRO_FIND_GSTREAMER_PLUGIN(pbutils pbutils.h)
++MACRO_FIND_GSTREAMER_PLUGIN(riff riff-ids.h)
++MACRO_FIND_GSTREAMER_PLUGIN(rtp gstrtpbuffer.h)
++MACRO_FIND_GSTREAMER_PLUGIN(rtsp gstrtspdefs.h)
++MACRO_FIND_GSTREAMER_PLUGIN(sdp gstsdp.h)
++MACRO_FIND_GSTREAMER_PLUGIN(tag tag.h)
++MACRO_FIND_GSTREAMER_PLUGIN(video video.h)
+ 
+ IF (GSTREAMERPLUGINSBASE_FOUND)
+-   SET(GSTREAMERPLUGINS_FOUND TRUE)
+-ELSE (GSTREAMERPLUGINSBASE_FOUND)
+-   SET(GSTREAMERPLUGINS_FOUND FALSE)
+-ENDIF (GSTREAMERPLUGINSBASE_FOUND)
+-
+-IF (GSTREAMERPLUGINS_FOUND)
++   LIST(REMOVE_DUPLICATES GSTREAMERPLUGINSBASE_LIBRARIES)
++   LIST(REMOVE_DUPLICATES GSTREAMERPLUGINSBASE_INCLUDE_DIRS)
+    IF (NOT GStreamer_Plugins_FIND_QUIETLY)
+       MESSAGE(STATUS "Found GStreamer Plugins:
+     ${GSTREAMER_PLUGIN_AUDIO_LIBRARIES}
+@@ -125,20 +103,10 @@ IF (GSTREAMERPLUGINS_FOUND)
+     ${GSTREAMER_PLUGIN_TAG_LIBRARIES}
+     ${GSTREAMER_PLUGIN_VIDEO_LIBRARIES}")
+    ENDIF (NOT GStreamer_Plugins_FIND_QUIETLY)
+-ELSE (GSTREAMERPLUGINS_FOUND)
++ELSE (GSTREAMERPLUGINSBASE_FOUND)
++   SET(GSTREAMERPLUGINSBASE_LIBRARIES GSTREAMERPLUGINSBASE_LIBRARIES-NOTFOUND)
++   SET(GSTREAMERPLUGINSBASE_INCLUDE_DIRS GSTREAMERPLUGINSBASE_INCLUDE_DIRS-NOTFOUND)
+    IF (GStreamer_Plugins_FIND_REQUIRED)
+       MESSAGE(SEND_ERROR "Could NOT find GStreamer Plugins")
+    ENDIF (GStreamer_Plugins_FIND_REQUIRED)
+-ENDIF (GSTREAMERPLUGINS_FOUND)
+-
+-MARK_AS_ADVANCED(GSTREAMERPLUGINS_DEFINITIONS
+-    GSTREAMER_PLUGIN_AUDIO_LIBRARIES
+-    GSTREAMER_PLUGIN_CDDA_LIBRARIES
+-    GSTREAMER_PLUGIN_NETBUFFER_LIBRARIES
+-    GSTREAMER_PLUGIN_PBUTILS_LIBRARIES
+-    GSTREAMER_PLUGIN_RIFF_LIBRARIES
+-    GSTREAMER_PLUGIN_RTP_LIBRARIES
+-    GSTREAMER_PLUGIN_RTSP_LIBRARIES
+-    GSTREAMER_PLUGIN_SDP_LIBRARIES
+-    GSTREAMER_PLUGIN_TAG_LIBRARIES
+-    GSTREAMER_PLUGIN_VIDEO_LIBRARIES)
++ENDIF (GSTREAMERPLUGINSBASE_FOUND)
+diff --git a/gstreamer/CMakeLists.txt b/gstreamer/CMakeLists.txt
+index d529fb6..c42710b 100644
+--- a/gstreamer/CMakeLists.txt
++++ b/gstreamer/CMakeLists.txt
+@@ -20,6 +20,8 @@ if (BUILD_PHONON_GSTREAMER)
+    include_directories(
+ 	  ${CMAKE_CURRENT_BINARY_DIR}
+ 	  ${GSTREAMER_INCLUDE_DIR}
++	  ${GSTREAMER_PLUGIN_VIDEO_INCLUDE_DIR}
++	  ${GSTREAMER_PLUGIN_AUDIO_INCLUDE_DIR}
+ 	  ${GLIB2_INCLUDE_DIR}
+       ${LIBXML2_INCLUDE_DIR}
+ 	  ${X11_X11_INCLUDE_PATH})
+@@ -78,7 +80,7 @@ if (BUILD_PHONON_GSTREAMER)
+       ${QT_QTOPENGL_LIBRARY}
+       ${PHONON_LIBS} ${OPENGL_gl_LIBRARY}
+       ${GSTREAMER_LIBRARIES} ${GSTREAMER_BASE_LIBRARY} ${GSTREAMER_INTERFACE_LIBRARY}
+-      ${GSTREAMER_PLUGIN_VIDEO_LIBRARIES} ${GSTREAMER_PLUGIN_AUDIO_LIBRARIES}
++      ${GSTREAMER_PLUGIN_VIDEO_LIBRARY} ${GSTREAMER_PLUGIN_AUDIO_LIBRARY}
+       ${GLIB2_LIBRARIES} ${GOBJECT_LIBRARIES})
+    if(ALSA_FOUND)
+       target_link_libraries(phonon_gstreamer ${ASOUND_LIBRARY})
+diff --git a/gstreamer/ConfigureChecks.cmake b/gstreamer/ConfigureChecks.cmake
+index 095a0e9..73616fa 100644
+--- a/gstreamer/ConfigureChecks.cmake
++++ b/gstreamer/ConfigureChecks.cmake
+@@ -16,8 +16,8 @@ macro_optional_find_package(GStreamer)
+ macro_log_feature(GSTREAMER_FOUND "GStreamer" "gstreamer 0.10 is required for the multimedia backend" "http://gstreamer.freedesktop.org/modules/" FALSE "0.10")
+ 
+ macro_optional_find_package(GStreamerPlugins)
+-macro_log_feature(GSTREAMER_PLUGIN_VIDEO_LIBRARIES "GStreamer video plugin" "The gstreamer video plugin (part of gstreamer-plugins-base 0.10) is required for the multimedia gstreamer backend" "http://gstreamer.freedesktop.org/modules/" FALSE "0.10")
+-macro_log_feature(GSTREAMER_PLUGIN_AUDIO_LIBRARIES "GStreamer audio plugin" "The gstreamer audio plugin (part of gstreamer-plugins-base 0.10) is required for the multimedia gstreamer backend" "http://gstreamer.freedesktop.org/modules/" FALSE "0.10")
++macro_log_feature(GSTREAMER_PLUGIN_VIDEO_FOUND "GStreamer video plugin" "The gstreamer video plugin (part of gstreamer-plugins-base 0.10) is required for the multimedia gstreamer backend" "http://gstreamer.freedesktop.org/modules/" FALSE "0.10")
++macro_log_feature(GSTREAMER_PLUGIN_AUDIO_FOUND "GStreamer audio plugin" "The gstreamer audio plugin (part of gstreamer-plugins-base 0.10) is required for the multimedia gstreamer backend" "http://gstreamer.freedesktop.org/modules/" FALSE "0.10")
+ 
+ macro_optional_find_package(GLIB2)
+ macro_log_feature(GLIB2_FOUND "GLib2" "GLib 2 is required to compile the gstreamer backend for Phonon" "http://www.gtk.org/download/" FALSE)
+@@ -31,8 +31,8 @@ macro_log_feature(LIBXML2_FOUND "LibXml2" "LibXml2 is required to compile the gs
+ macro_optional_find_package(OpenGL)
+ macro_log_feature(OPENGL_FOUND "OpenGL" "OpenGL support is required to compile the gstreamer backend for Phonon" "" FALSE)
+ 
+-if (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GSTREAMER_PLUGIN_AUDIO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
++if (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_FOUND AND GSTREAMER_PLUGIN_AUDIO_FOUND AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
+    set(BUILD_PHONON_GSTREAMER TRUE)
+-else (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GSTREAMER_PLUGIN_AUDIO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
++else (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_FOUND AND GSTREAMER_PLUGIN_AUDIO_FOUND AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
+    set(BUILD_PHONON_GSTREAMER FALSE)
+-endif (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GSTREAMER_PLUGIN_AUDIO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
++endif (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_FOUND AND GSTREAMER_PLUGIN_AUDIO_FOUND AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
+-- 
+1.7.1
+
diff --git a/pkgs/development/compilers/gcc-4.4/builder.sh b/pkgs/development/compilers/gcc-4.4/builder.sh
index b9724e7ad50e9..abe14b457ab2e 100644
--- a/pkgs/development/compilers/gcc-4.4/builder.sh
+++ b/pkgs/development/compilers/gcc-4.4/builder.sh
@@ -61,10 +61,39 @@ if test "$noSysDirs" = "1"; then
             EXTRA_LDFLAGS_TARGET="-Wl,-L${libcCross}/lib"
         fi
     else
-        EXTRA_FLAGS_TARGET="$EXTRA_FLAGS"
-        EXTRA_LDFLAGS_TARGET="$EXTRA_LDFLAGS"
+        if test -z "$NIX_GCC_CROSS"; then
+            EXTRA_FLAGS_TARGET="$EXTRA_FLAGS"
+            EXTRA_LDFLAGS_TARGET="$EXTRA_LDFLAGS"
+        else
+            # This the case of cross-building the gcc.
+            # We need special flags for the target, different than those of the build
+            # Assertion:
+            test -e $NIX_GCC_CROSS/nix-support/orig-libc
+
+            # Figure out what extra flags to pass to the gcc compilers
+            # being generated to make sure that they use our glibc.
+            extraFlags="$(cat $NIX_GCC_CROSS/nix-support/libc-cflags)"
+            extraLDFlags="$(cat $NIX_GCC_CROSS/nix-support/libc-ldflags) $(cat $NIX_GCC_CROSS/nix-support/libc-ldflags-before)"
+
+            # Use *real* header files, otherwise a limits.h is generated
+            # that does not include Glibc's limits.h (notably missing
+            # SSIZE_MAX, which breaks the build).
+            NIX_FIXINC_DUMMY_CROSS=$(cat $NIX_GCC_CROSS/nix-support/orig-libc)/include
+
+            # The path to the Glibc binaries such as `crti.o'.
+            glibc_libdir="$(cat $NIX_GCC_CROSS/nix-support/orig-libc)/lib"
+
+            extraFlags="-g0 -O2 -I$NIX_FIXINC_DUMMY_CROSS $extraFlags"
+            extraLDFlags="--strip-debug -L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
+
+            EXTRA_FLAGS_TARGET="$extraFlags"
+            for i in $extraLDFlags; do
+                EXTRA_LDFLAGS_TARGET="$EXTRA_LDFLAGS_TARGET -Wl,$i"
+            done
+        fi
     fi
 
+
     # CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find
     # the startfiles.
     # FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx
@@ -160,7 +189,7 @@ postInstall() {
 }
 
 
-if test -z "$targetConfig"; then
+if test -z "$targetConfig" && test -z "$crossConfig"; then
     if test -z "$profiledCompiler"; then
         buildFlags="bootstrap $buildFlags"
     else    
diff --git a/pkgs/development/compilers/gcc-4.4/default.nix b/pkgs/development/compilers/gcc-4.4/default.nix
index e4206cabd8a0d..bc9c2c89e1dbc 100644
--- a/pkgs/development/compilers/gcc-4.4/default.nix
+++ b/pkgs/development/compilers/gcc-4.4/default.nix
@@ -126,7 +126,9 @@ stdenv.mkDerivation ({
   inherit noSysDirs profiledCompiler staticCompiler langJava crossStageStatic
     libcCross;
 
-  buildInputs = [ texinfo gmp mpfr gettext which ]
+  buildNativeInputs = [ texinfo which ];
+
+  buildInputs = [ gmp mpfr gettext ]
     ++ (optional (ppl != null) ppl)
     ++ (optional (cloogppl != null) cloogppl)
     ++ (optionals langTreelang [bison flex])
@@ -176,6 +178,50 @@ stdenv.mkDerivation ({
   LD = "ld";
   CC = "gcc";
 
+  crossAttrs = {
+    AR = "${stdenv.cross.config}-ar";
+    LD = "${stdenv.cross.config}-ld";
+    CC = "${stdenv.cross.config}-gcc";
+    CXX = "${stdenv.cross.config}-gcc";
+    AR_FOR_TARGET = "${stdenv.cross.config}-ar";
+    LD_FOR_TARGET = "${stdenv.cross.config}-ld";
+    CC_FOR_TARGET = "${stdenv.cross.config}-gcc";
+    NM_FOR_TARGET = "${stdenv.cross.config}-nm";
+    CXX_FOR_TARGET = "${stdenv.cross.config}-g++";
+    # If we are making a cross compiler, cross != null
+    NIX_GCC_CROSS = if cross == null then "${stdenv.gccCross}" else "";
+    configureFlags = "
+      ${if enableMultilib then "" else "--disable-multilib"}
+      ${if enableShared then "" else "--disable-shared"}
+      ${if ppl != null then "--with-ppl=${ppl.hostDrv}" else ""}
+      ${if cloogppl != null then "--with-cloog=${cloogppl.hostDrv}" else ""}
+      ${if langJava then "--with-ecj-jar=${javaEcj.hostDrv}" else ""}
+      ${if javaAwtGtk then "--enable-java-awt=gtk" else ""}
+      ${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr.hostDrv}" else ""}
+      --with-gmp=${gmp.hostDrv}
+      --with-mpfr=${mpfr.hostDrv}
+      --disable-libstdcxx-pch
+      --without-included-gettext
+      --with-system-zlib
+      --enable-languages=${
+        concatStrings (intersperse ","
+          (  optional langC        "c"
+          ++ optional langCC       "c++"
+          ++ optional langFortran  "fortran"
+          ++ optional langJava     "java"
+          ++ optional langTreelang "treelang"
+          ++ optional langAda      "ada"
+          ++ optional langVhdl     "vhdl"
+          )
+        )
+      }
+      ${if langAda then " --enable-libada" else ""}
+      ${if (cross == null && stdenv.isi686) then "--with-arch=i686" else ""}
+      ${if cross != null then crossConfigureFlags else ""}
+      --target=${stdenv.cross.config}
+    ";
+  };
+
   # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find
   # the library headers and binaries, regarless of the language being
   # compiled.
diff --git a/pkgs/development/compilers/gcc-4.5/builder.sh b/pkgs/development/compilers/gcc-4.5/builder.sh
index 6c3ced85d7545..5d66cc09532e8 100644
--- a/pkgs/development/compilers/gcc-4.5/builder.sh
+++ b/pkgs/development/compilers/gcc-4.5/builder.sh
@@ -54,11 +54,52 @@ if test "$noSysDirs" = "1"; then
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,$i"
     done
 
-    if test -z "$targetConfig"; then
-        EXTRA_TARGET_CFLAGS="$EXTRA_FLAGS"
-        EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS"
+    if test -n "$targetConfig"; then
+        # Cross-compiling, we need gcc not to read ./specs in order to build
+        # the g++ compiler (after the specs for the cross-gcc are created).
+        # Having LIBRARY_PATH= makes gcc read the specs from ., and the build
+        # breaks. Having this variable comes from the default.nix code to bring
+        # gcj in.
+        unset LIBRARY_PATH
+        unset CPATH
+        if test -z "$crossStageStatic"; then
+            EXTRA_TARGET_CFLAGS="-g0 -O2 -B${libcCross}/lib -idirafter ${libcCross}/include"
+            EXTRA_TARGET_LDFLAGS="-Wl,-L${libcCross}/lib"
+        fi
+    else
+        if test -z "$NIX_GCC_CROSS"; then
+            EXTRA_TARGET_CFLAGS="$EXTRA_FLAGS"
+            EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS"
+        else
+            # This the case of cross-building the gcc.
+            # We need special flags for the target, different than those of the build
+            # Assertion:
+            test -e $NIX_GCC_CROSS/nix-support/orig-libc
+
+            # Figure out what extra flags to pass to the gcc compilers
+            # being generated to make sure that they use our glibc.
+            extraFlags="$(cat $NIX_GCC_CROSS/nix-support/libc-cflags)"
+            extraLDFlags="$(cat $NIX_GCC_CROSS/nix-support/libc-ldflags) $(cat $NIX_GCC_CROSS/nix-support/libc-ldflags-before)"
+
+            # Use *real* header files, otherwise a limits.h is generated
+            # that does not include Glibc's limits.h (notably missing
+            # SSIZE_MAX, which breaks the build).
+            NIX_FIXINC_DUMMY_CROSS=$(cat $NIX_GCC_CROSS/nix-support/orig-libc)/include
+
+            # The path to the Glibc binaries such as `crti.o'.
+            glibc_libdir="$(cat $NIX_GCC_CROSS/nix-support/orig-libc)/lib"
+
+            extraFlags="-g0 -O2 -I$NIX_FIXINC_DUMMY_CROSS $extraFlags"
+            extraLDFlags="--strip-debug -L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
+
+            EXTRA_TARGET_CFLAGS="$extraFlags"
+            for i in $extraLDFlags; do
+                EXTRA_TARGET_LDFLAGS="$EXTRA_TARGET_LDFLAGS -Wl,$i"
+            done
+        fi
     fi
 
+
     # CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find
     # the startfiles.
     # FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx
@@ -68,17 +109,17 @@ if test "$noSysDirs" = "1"; then
         NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
         SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
         CFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
-        CFLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS" \
+        CFLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
         FLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
         LDFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
-        LDFLAGS_FOR_TARGET="$EXTRA_TARGET_LDFLAGS" \
+        LDFLAGS_FOR_TARGET="$EXTRA_TARGET_LDFLAGS $EXTRA_TARGET_LDFLAGS" \
         )
 
     if test -z "$targetConfig"; then
         makeFlagsArray=( \
             "${makeFlagsArray[@]}" \
             BOOT_CFLAGS="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
-            BOOT_LDFLAGS="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
+            BOOT_LDFLAGS="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
             )
     fi
 
@@ -102,6 +143,7 @@ if test -n "$targetConfig"; then
     dontStrip=1
 fi
 
+
 preConfigure() {
     if test -n "$newlibSrc"; then
         tar xvf "$newlibSrc" -C ..
@@ -131,6 +173,12 @@ preConfigure() {
 }
 
 
+postConfigure() {
+    # Don't store the configure flags in the resulting executables.
+    sed -e '/TOPLEVEL_CONFIGURE_ARGUMENTS=/d' -i Makefile
+}
+
+
 postInstall() {
     # Remove precompiled headers for now.  They are very big and
     # probably not very useful yet.
@@ -140,6 +188,14 @@ postInstall() {
     # previous gcc.
     rm -rf $out/libexec/gcc/*/*/install-tools
     rm -rf $out/lib/gcc/*/*/install-tools
+    
+    # More dependencies with the previous gcc or some libs (gccbug stores the build command line)
+    rm -rf $out/bin/gccbug
+    # Take out the bootstrap-tools from the rpath, as it's not needed at all having $out
+    for i in $out/libexec/gcc/*/*/*; do
+        PREV_RPATH=`patchelf --print-rpath $i`
+        patchelf --set-rpath `echo $PREV_RPATH | sed 's,:[^:]*bootstrap-tools/lib,,'` $i
+    done
 
     # Get rid of some "fixed" header files
     rm -rf $out/lib/gcc/*/*/include/root
@@ -151,7 +207,7 @@ postInstall() {
         fi
     done
 
-    for i in $out/bin/*-c++* $out/bin/*-g++*; do
+    for i in $out/bin/c++ $out/bin/*-c++* $out/bin/*-g++*; do
         if cmp -s $out/bin/g++ $i; then
             ln -sfn g++ $i
         fi
@@ -161,7 +217,7 @@ postInstall() {
 }
 
 
-if test -z "$targetConfig"; then
+if test -z "$targetConfig" && test -z "$crossConfig"; then
     if test -z "$profiledCompiler"; then
         buildFlags="bootstrap $buildFlags"
     else    
diff --git a/pkgs/development/compilers/gcc-4.5/default.nix b/pkgs/development/compilers/gcc-4.5/default.nix
index 38f4338d4ac23..91fbc666008ef 100644
--- a/pkgs/development/compilers/gcc-4.5/default.nix
+++ b/pkgs/development/compilers/gcc-4.5/default.nix
@@ -41,7 +41,7 @@ assert libelf != null -> zlib != null;
 with stdenv.lib;
 with builtins;
 
-let version = "4.5.0";
+let version = "4.5.1";
     javaEcj = fetchurl {
       # The `$(top_srcdir)/ecj.jar' file is automatically picked up at
       # `configure' time.
@@ -136,7 +136,7 @@ stdenv.mkDerivation ({
   };
 
   patches =
-    [ ./softfp-hurd.patch ./dragonegg-2.7.patch ]
+    [ ]
     ++ optional (cross != null) ./libstdc++-target.patch
     ++ optional noSysDirs ./no-sys-dirs.patch
     # The GNAT Makefiles did not pay attention to CFLAGS_FOR_TARGET for its
@@ -181,8 +181,10 @@ stdenv.mkDerivation ({
   inherit noSysDirs profiledCompiler staticCompiler langJava crossStageStatic
     libcCross crossMingw;
 
-  buildInputs = [ texinfo gmp mpfr mpc libelf gettext which ]
-    ++ (optional (perl != null) perl)
+  buildNativeInputs = [ texinfo which ]
+    ++ optional (perl != null) perl;
+    
+  buildInputs = [ gmp mpfr mpc libelf gettext ]
     ++ (optional (ppl != null) ppl)
     ++ (optional (cloogppl != null) cloogppl)
     ++ (optionals langTreelang [bison flex])
@@ -195,6 +197,11 @@ stdenv.mkDerivation ({
     ++ (optionals langVhdl [gnat])
     ;
 
+  configureFlagsArray = stdenv.lib.optionals
+    (ppl != null && ppl.dontDisableStatic == true)
+        [ "--with-host-libstdcxx=-lstdc++ -lgcc_s"
+            "--with-stage1-libs=-lstdc++ -lgcc_s" ];
+
   configureFlags = "
     ${if enableMultilib then "" else "--disable-multilib"}
     ${if enableShared then "" else "--disable-shared"}
@@ -228,6 +235,8 @@ stdenv.mkDerivation ({
         )
       )
     }
+    ${ # Trick that should be taken out once we have a mips64-linux not loongson2f
+      if cross == null && stdenv.system == "mips64-linux" then "--with-arch=loongson2f" else ""}
     ${if langAda then " --enable-libada" else ""}
     ${if (cross == null && stdenv.isi686) then "--with-arch=i686" else ""}
     ${if cross != null then crossConfigureFlags else ""}
@@ -235,6 +244,52 @@ stdenv.mkDerivation ({
 
   targetConfig = if (cross != null) then cross.config else null;
 
+  crossAttrs = {
+    AR = "${stdenv.cross.config}-ar";
+    LD = "${stdenv.cross.config}-ld";
+    CC = "${stdenv.cross.config}-gcc";
+    CXX = "${stdenv.cross.config}-gcc";
+    AR_FOR_TARGET = "${stdenv.cross.config}-ar";
+    LD_FOR_TARGET = "${stdenv.cross.config}-ld";
+    CC_FOR_TARGET = "${stdenv.cross.config}-gcc";
+    NM_FOR_TARGET = "${stdenv.cross.config}-nm";
+    CXX_FOR_TARGET = "${stdenv.cross.config}-g++";
+    # If we are making a cross compiler, cross != null
+    NIX_GCC_CROSS = if cross == null then "${stdenv.gccCross}" else "";
+    dontStrip = true;
+    configureFlags = ''
+      ${if enableMultilib then "" else "--disable-multilib"}
+      ${if enableShared then "" else "--disable-shared"}
+      ${if ppl != null then "--with-ppl=${ppl.hostDrv}" else ""}
+      ${if cloogppl != null then "--with-cloog=${cloogppl.hostDrv}" else ""}
+      ${if langJava then "--with-ecj-jar=${javaEcj.hostDrv}" else ""}
+      ${if javaAwtGtk then "--enable-java-awt=gtk" else ""}
+      ${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr.hostDrv}" else ""}
+      --with-gmp=${gmp.hostDrv}
+      --with-mpfr=${mpfr.hostDrv}
+      --disable-libstdcxx-pch
+      --without-included-gettext
+      --with-system-zlib
+      --enable-languages=${
+        concatStrings (intersperse ","
+          (  optional langC        "c"
+          ++ optional langCC       "c++"
+          ++ optional langFortran  "fortran"
+          ++ optional langJava     "java"
+          ++ optional langTreelang "treelang"
+          ++ optional langAda      "ada"
+          ++ optional langVhdl     "vhdl"
+          )
+        )
+      }
+      ${if langAda then " --enable-libada" else ""}
+      ${if (cross == null && stdenv.isi686) then "--with-arch=i686" else ""}
+      ${if cross != null then crossConfigureFlags else ""}
+      --target=${stdenv.cross.config}
+    '';
+  };
+ 
+
   # Needed for the cross compilation to work
   AR = "ar";
   LD = "ld";
@@ -316,11 +371,13 @@ stdenv.mkDerivation ({
     platforms = stdenv.lib.platforms.linux ++ optionals (langAda == false) [ "i686-darwin" ];
   };
 }
-// (if cross != null && cross.libc == "msvcrt" && crossStageStatic then rec {
+
+// optionalAttrs (cross != null && cross.libc == "msvcrt" && crossStageStatic) {
   makeFlags = [ "all-gcc" "all-target-libgcc" ];
   installTargets = "install-gcc install-target-libgcc";
-} else {})
-// (if langVhdl then rec {
+}
+
+// optionalAttrs langVhdl rec {
   name = "ghdl-0.29";
 
   ghdlSrc = fetchurl {
@@ -353,4 +410,4 @@ stdenv.mkDerivation ({
     platforms = with stdenv.lib.platforms; linux;
   };
 
-} else {}))
+})
diff --git a/pkgs/development/compilers/gcc-4.5/dragonegg-2.7.patch b/pkgs/development/compilers/gcc-4.5/dragonegg-2.7.patch
deleted file mode 100644
index 6b37672ddef07..0000000000000
--- a/pkgs/development/compilers/gcc-4.5/dragonegg-2.7.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-Index: mainline/gcc/config/i386/i386.c
-===================================================================
---- mainline.orig/gcc/config/i386/i386.c	2010-04-02 09:11:58.733574308 +0200
-+++ mainline/gcc/config/i386/i386.c	2010-04-02 09:29:11.276111437 +0200
-@@ -4992,7 +4992,8 @@
-    case, we return the original mode and warn ABI change if CUM isn't
-    NULL.  */
- 
--static enum machine_mode
-+extern enum machine_mode type_natural_mode (const_tree, CUMULATIVE_ARGS *);
-+enum machine_mode
- type_natural_mode (const_tree type, CUMULATIVE_ARGS *cum)
- {
-   enum machine_mode mode = TYPE_MODE (type);
-@@ -5123,7 +5124,9 @@
-    See the x86-64 PS ABI for details.
- */
- 
--static int
-+extern int classify_argument (enum machine_mode, const_tree,
-+                              enum x86_64_reg_class [MAX_CLASSES], int);
-+int
- classify_argument (enum machine_mode mode, const_tree type,
- 		   enum x86_64_reg_class classes[MAX_CLASSES], int bit_offset)
- {
-@@ -5504,7 +5507,9 @@
- 
- /* Examine the argument and return set number of register required in each
-    class.  Return 0 iff parameter should be passed in memory.  */
--static int
-+extern int examine_argument (enum machine_mode, const_tree, int,
-+                             int *, int *);
-+int
- examine_argument (enum machine_mode mode, const_tree type, int in_return,
- 		  int *int_nregs, int *sse_nregs)
- {
-@@ -6186,7 +6191,8 @@
- 
- /* Return true when TYPE should be 128bit aligned for 32bit argument passing
-    ABI.  */
--static bool
-+extern bool contains_aligned_value_p (tree);
-+bool
- contains_aligned_value_p (tree type)
- {
-   enum machine_mode mode = TYPE_MODE (type);
diff --git a/pkgs/development/compilers/gcc-4.5/softfp-hurd.patch b/pkgs/development/compilers/gcc-4.5/softfp-hurd.patch
deleted file mode 100644
index 7e2a8a9c2900d..0000000000000
--- a/pkgs/development/compilers/gcc-4.5/softfp-hurd.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-This patch fixes undefined references to softp symbols (__multf3, __fixunstfsi,
-__subtf3, etc.) in libgcc_s.so on GNU/Hurd.
-
-Taken from <http://gcc.gnu.org/ml/gcc-patches/2010-04/msg00602.html>, with second
-hunk adjusted so that it applies to GCC 4.5.0.
-
-diff --git a/gcc/config.gcc b/gcc/config.gcc
-index 9e499cb..9aec392 100644
---- a/gcc/config.gcc
-+++ b/gcc/config.gcc
-@@ -3070,7 +3070,9 @@ case ${target} in
- 	i[34567]86-*-darwin* | x86_64-*-darwin*)
- 		tmake_file="${tmake_file} i386/t-fprules-softfp soft-fp/t-softfp"
- 		;;
--	i[34567]86-*-linux* | x86_64-*-linux* | i[34567]86-*-kfreebsd*-gnu | x86_64-*-kfreebsd*-gnu)
-+	i[34567]86-*-linux* | x86_64-*-linux* | \
-+	  i[34567]86-*-kfreebsd*-gnu | x86_64-*-kfreebsd*-gnu | \
-+	  i[34567]86-*-gnu*)
- 		tmake_file="${tmake_file} i386/t-fprules-softfp soft-fp/t-softfp i386/t-linux"
- 		;;
- 	ia64*-*-linux*)
-diff --git a/libgcc/config.host b/libgcc/config.host
---- a/libgcc/config.host
-+++ b/libgcc/config.host
-@@ -600,6 +600,7 @@ case ${host} in
- i[34567]86-*-darwin* | x86_64-*-darwin* | \
-   i[34567]86-*-kfreebsd*-gnu | x86_64-*-kfreebsd*-gnu | \
-   i[34567]86-*-linux* | x86_64-*-linux* | \
-+  i[34567]86-*-gnu* | \
-   i[34567]86-*-solaris2* | \
-   i[34567]86-*-cygwin* | i[34567]86-*-mingw* | x86_64-*-mingw*)
- 	if test "${host_address}" = 32; then
diff --git a/pkgs/development/compilers/gcc-4.5/sources.nix b/pkgs/development/compilers/gcc-4.5/sources.nix
index 4a9201d08eb49..6059e03880b38 100644
--- a/pkgs/development/compilers/gcc-4.5/sources.nix
+++ b/pkgs/development/compilers/gcc-4.5/sources.nix
@@ -1,26 +1,26 @@
 /* Automatically generated by `update-gcc.sh', do not edit.
-   For GCC 4.5.0.  */
+   For GCC 4.5.1.  */
 { fetchurl, optional, version, langC, langCC, langFortran, langJava, langAda }:
 
-assert version == "4.5.0";
+assert version == "4.5.1";
 optional /* langC */ true (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-core-${version}.tar.bz2";
-  sha256 = "19ykzyd938d4pblsihrsalk9ch1s23z57s0r5an8sqs7acv51r0g";
+  sha256 = "0sjjw3qfcpdk0fs5d2rhl0xqcaclg86ifbq45dbk9ca072l3fyxm";
 }) ++
 optional langCC (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-g++-${version}.tar.bz2";
-  sha256 = "0hialil4v2hi7klr14x6h5z7b9ryzzy9kchr96s2p9hmsm7famlk";
+  sha256 = "0j6ffb96b3r75hrjshg52llv21ax7r8jdx44hhj0maiisnl9wd55";
 }) ++
 optional langFortran (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-fortran-${version}.tar.bz2";
-  sha256 = "0anby974dikygjmxr6h1pd9s24fdps84fki1dijzhqqvq6lr3hbb";
+  sha256 = "0xgwjc3h5fc5c100bnw24c35255il33lj5qbgpxf0zl8di2q13aw";
 }) ++
 optional langJava (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-java-${version}.tar.bz2";
-  sha256 = "0mlbxyhj7svjgby5vrpc49l2vk0k0878nlx0ap6jqq7xdyysvlcn";
+  sha256 = "0mh37q4ibg05h1hdh39pkj1hycvdg6i79m4698knw7pppm14ax8q";
 }) ++
 optional langAda (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-ada-${version}.tar.bz2";
-  sha256 = "1yar842bixmh2n9siy8s383lg8mz611xjdbbacgcznwab601czzv";
+  sha256 = "11chdbl7h046lnl83k79vj7dvgxz6kq7cnmwx94z644vaiflg153";
 }) ++
 []
diff --git a/pkgs/development/compilers/nasm/default.nix b/pkgs/development/compilers/nasm/default.nix
index b6a09d069848f..688a81f4b3e4e 100644
--- a/pkgs/development/compilers/nasm/default.nix
+++ b/pkgs/development/compilers/nasm/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation rec {
-  name = "nasm-2.05.01";
+  name = "nasm-2.09";
   
   src = fetchurl {
-    url = "mirror://sourceforge/nasm/${name}.tar.bz2";
-    sha256 = "0p2rlshd68m2h7psyjz4440grxwryxppqzchx7cbmzahqr2yy1lj";
+    url = http://www.nasm.us/pub/nasm/releasebuilds/2.09/nasm-2.09.tar.bz2;
+    sha256 = "06kv1ii8d3jwq5mczbyx6zc7k1acdwjdfjblv78mglf161i82j4m";
   };
 
   meta = {
diff --git a/pkgs/development/compilers/ocaml/3.11.1.nix b/pkgs/development/compilers/ocaml/3.11.1.nix
index 66c8319600ffe..48265f9aa3d03 100644
--- a/pkgs/development/compilers/ocaml/3.11.1.nix
+++ b/pkgs/development/compilers/ocaml/3.11.1.nix
@@ -1,8 +1,8 @@
 { stdenv, fetchurl, ncurses, x11 }:
 
 let
-   useX11 = stdenv.system != "armv5tel-linux";
-   useNativeCompilers = stdenv.system != "armv5tel-linux";
+   useX11 = stdenv.isi686 || stdenv.isx86_64;
+   useNativeCompilers = stdenv.isi686 || stdenv.isx86_64 || stdenv.isMips;
    inherit (stdenv.lib) optionals optionalString;
 in
 
@@ -15,14 +15,18 @@ stdenv.mkDerivation rec {
     sha256 = "8c36a28106d4b683a15c547dfe4cb757a53fa9247579d1cc25bd06a22cc62e50";
   };
 
+  # Needed to avoid a SIGBUS on the final executable on mips
+  NIX_CFLAGS_COMPILE = if stdenv.isMips then "-fPIC" else "";
+
   prefixKey = "-prefix ";
   configureFlags = ["-no-tk"] ++ optionals useX11 [ "-x11lib" x11 ];
   buildFlags = "world" + optionalString useNativeCompilers " bootstrap world.opt";
   buildInputs = [ncurses] ++ optionals useX11 [ x11 ];
   installTargets = "install" + optionalString useNativeCompilers " installopt";
-  patchPhase = ''
+  prePatch = ''
     CAT=$(type -tp cat)
     sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang
+    patch -p1 -l < ${./mips64.patch}
   '';
   postBuild = ''
     ensureDir $out/include
diff --git a/pkgs/development/interpreters/guile/cpp-4.5.patch b/pkgs/development/interpreters/guile/cpp-4.5.patch
new file mode 100644
index 0000000000000..7e7671f0da09b
--- /dev/null
+++ b/pkgs/development/interpreters/guile/cpp-4.5.patch
@@ -0,0 +1,24 @@
+Fix doc snarfing with GCC 4.5.
+From <http://git.savannah.gnu.org/cgit/guile.git/commit/?h=branch_release-1-8&id=aac41d28358cea594bb30f6e547afb82bb6004a6>.
+
+diff --git a/scripts/snarf-check-and-output-texi b/scripts/snarf-check-and-output-texi
+index ea33e17..8cd42e8 100755
+--- a/scripts/snarf-check-and-output-texi
++++ b/scripts/snarf-check-and-output-texi
+@@ -267,6 +267,17 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@"
+       (set! *file* file)
+       (set! *line* line))
+ 
++     ;; newer gccs like to throw around more location markers into the
++     ;; preprocessed source; these (hash . hash) bits are what they translate to
++     ;; in snarfy terms.
++     (('location ('string . file) ('int . line) ('hash . 'hash))
++      (set! *file* file)
++      (set! *line* line))
++
++     (('location ('hash . 'hash) ('string . file) ('int . line) ('hash . 'hash))
++      (set! *file* file)
++      (set! *line* line))
++
+      (('arglist rest ...)
+       (set! *args* (do-arglist rest)))
diff --git a/pkgs/development/interpreters/guile/default.nix b/pkgs/development/interpreters/guile/default.nix
index 8dd7953a42da8..dae6a69bcb649 100644
--- a/pkgs/development/interpreters/guile/default.nix
+++ b/pkgs/development/interpreters/guile/default.nix
@@ -9,6 +9,8 @@ stdenv.mkDerivation rec {
     sha256 = "1czhcrn6l63xhsw3fjmv88djflqxbdpxjhgmwwvscm8rv4wn7vmz";
   };
 
+  patches = [ ./cpp-4.5.patch ];
+
   buildNativeInputs = [ makeWrapper gawk ];
   propagatedBuildInputs = [ readline gmp libtool ];
   selfBuildNativeInput = true;
@@ -31,6 +33,8 @@ stdenv.mkDerivation rec {
 
   # One test fails.
   # ERROR: file: "libtest-asmobs", message: "file not found"
+  # This is fixed here:
+  # <http://git.savannah.gnu.org/cgit/guile.git/commit/?h=branch_release-1-8&id=a0aa1e5b69d6ef0311aeea8e4b9a94eae18a1aaf>.
   doCheck = false;
 
   setupHook = ./setup-hook.sh;
diff --git a/pkgs/development/libraries/SDL/default.nix b/pkgs/development/libraries/SDL/default.nix
index ca1b7086e393a..7205e0fa7ea80 100644
--- a/pkgs/development/libraries/SDL/default.nix
+++ b/pkgs/development/libraries/SDL/default.nix
@@ -1,6 +1,7 @@
-{ stdenv, fetchurl, x11, libXrandr, pkgconfig
+{ stdenv, fetchurl, pkgconfig
 , openglSupport ? false, mesa ? null
 , alsaSupport ? true, alsaLib ? null
+, x11Support ? true, x11 ? null, libXrandr ? null
 , pulseaudioSupport ? true, pulseaudio ? null
 }:
 
@@ -8,10 +9,18 @@
 # PulseAudio.
 assert alsaSupport || pulseaudioSupport;
 
-assert openglSupport -> mesa != null;
+assert openglSupport -> (mesa != null && x11Support);
+assert x11Support -> (x11 != null && libXrandr != null);
 assert alsaSupport -> alsaLib != null;
 assert pulseaudioSupport -> pulseaudio != null;
 
+let
+  configureFlagsFun = attrs: ''
+        --disable-oss
+        --disable-x11-shared --disable-alsa-shared --enable-rpath --disable-pulseaudio-shared
+        ${if alsaSupport then "--with-alsa-prefix=${attrs.alsaLib}/lib" else ""}
+      '';
+in
 stdenv.mkDerivation rec {
   name = "SDL-1.2.14";
 
@@ -21,7 +30,7 @@ stdenv.mkDerivation rec {
   };
 
   # Since `libpulse*.la' contain `-lgdbm', PulseAudio must be propagated.
-  propagatedBuildInputs = [ x11 libXrandr ] ++
+  propagatedBuildInputs = stdenv.lib.optionals x11Support [ x11 libXrandr ] ++
     stdenv.lib.optional pulseaudioSupport pulseaudio;
 
   buildInputs = [ pkgconfig ] ++
@@ -31,11 +40,11 @@ stdenv.mkDerivation rec {
   # XXX: By default, SDL wants to dlopen() PulseAudio, in which case
   # we must arrange to add it to its RPATH; however, `patchelf' seems
   # to fail at doing this, hence `--disable-pulseaudio-shared'.
-  configureFlags = ''
-    --disable-oss
-    --disable-x11-shared --disable-alsa-shared --enable-rpath --disable-pulseaudio-shared
-    ${if alsaSupport then "--with-alsa-prefix=${alsaLib}/lib" else ""}
-  '';
+  configureFlags = configureFlagsFun { inherit alsaLib; };
+
+  crossAttrs = {
+      configureFlags = configureFlagsFun { alsaLib = alsaLib.hostDrv; };
+  };
 
   passthru = {inherit openglSupport;};
 
diff --git a/pkgs/development/libraries/aalib/default.nix b/pkgs/development/libraries/aalib/default.nix
index d3230c1fedcd1..2da006a6cebe4 100644
--- a/pkgs/development/libraries/aalib/default.nix
+++ b/pkgs/development/libraries/aalib/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, ncurses}:
+{stdenv, fetchurl, ncurses, automake}:
 
 stdenv.mkDerivation {
   name = "aalib-1.4rc4";
@@ -7,6 +7,12 @@ stdenv.mkDerivation {
     url = mirror://sourceforge/aa-project/aalib-1.4rc4.tar.gz;
     md5 = "d5aa8e9eae07b7441298b5c30490f6a6";
   };
+
+  # The fuloong2f is not supported by aalib still
+  preConfigure = ''
+    cp ${automake}/share/automake*/config.{sub,guess} .
+  '';
+
   buildInputs = [ncurses];
   inherit ncurses;
 }
diff --git a/pkgs/development/libraries/acl/default.nix b/pkgs/development/libraries/acl/default.nix
index 06dd8cb2fb971..5ce81105fa32a 100644
--- a/pkgs/development/libraries/acl/default.nix
+++ b/pkgs/development/libraries/acl/default.nix
@@ -1,21 +1,29 @@
-{stdenv, fetchurl, gettext, attr, libtool}:
+{ stdenv, fetchurl, gettext, attr }:
 
-stdenv.mkDerivation {
-  name = "acl-2.2.47";
+stdenv.mkDerivation rec {
+  name = "acl-2.2.49";
 
   src = fetchurl {
-    url = http://nixos.org/tarballs/acl_2.2.47-1.tar.gz;
-    sha256 = "1j39g62fki0iyji9s62slgwdfskpkqy7rmjlqcnmsvsnxbxhc294";
+    url = "mirror://savannah/acl/${name}.src.tar.gz";
+    sha256 = "1mg5nxr0r9y08lmyxmm2lfss5jz1xzbs0npsc8597x2f5rsz9ixr";
   };
 
-  buildInputs = [gettext attr libtool];
+  buildNativeInputs = [gettext];
+  buildInputs = [ attr ];
 
-  configureFlags = "MAKE=make LIBTOOL=libtool MSGFMT=msgfmt MSGMERGE=msgmerge XGETTEXT=xgettext ZIP=gzip ECHO=echo SED=sed AWK=gawk";
+  # Upstream use C++-style comments in C code. Remove them.
+  # This comment breaks compilation if too strict gcc flags are used.
+  patchPhase = ''
+    echo "Removing C++-style comments from include/acl.h"
+    sed -e '/^\/\//d' -i include/acl.h
+  '';
+
+  configureFlags = "MAKE=make MSGFMT=msgfmt MSGMERGE=msgmerge XGETTEXT=xgettext ZIP=gzip ECHO=echo SED=sed AWK=gawk";
 
   installTargets = "install install-lib install-dev";
 
   meta = {
-    homepage = ftp://oss.sgi.com/projects/xfs/cmd_tars/;
+    homepage = http://savannah.nongnu.org/projects/acl;
     description = "Library and tools for manipulating access control lists";
   };
 }
diff --git a/pkgs/development/libraries/attr/default.nix b/pkgs/development/libraries/attr/default.nix
index 532f97a9fdf30..643b4cdaae551 100644
--- a/pkgs/development/libraries/attr/default.nix
+++ b/pkgs/development/libraries/attr/default.nix
@@ -1,22 +1,22 @@
 {stdenv, fetchurl, libtool, gettext}:
 
-stdenv.mkDerivation {
-  name = "attr-2.4.43";
+stdenv.mkDerivation rec {
+  name = "attr-2.4.44";
 
   src = fetchurl {
-    # The SGI site throws away old versions, so don't use it.
-    url = mirror://gentoo/distfiles/attr_2.4.43-1.tar.gz;
-    sha256 = "1gy5zspj8ynxv6q29r24d18cfvq06zirg1pxcdg27bg2ncrv4n6k";
+    url = "mirror://savannah/attr/${name}.src.tar.gz";
+    sha256 = "16244r2vrd57i5fnf7dz3yi2mcckc47jr9y539jvljrzwnw18qlz";
   };
 
-  buildInputs = [libtool gettext];
+  buildNativeInputs = [gettext];
+  buildInputs = [libtool];
 
   configureFlags = "MAKE=make LIBTOOL=libtool MSGFMT=msgfmt MSGMERGE=msgmerge XGETTEXT=xgettext ECHO=echo SED=sed AWK=gawk";
 
   installTargets = "install install-lib install-dev";
 
   meta = {
-    homepage = ftp://oss.sgi.com/projects/xfs/cmd_tars/;
+    homepage = http://savannah.nongnu.org/projects/attr/;
     description = "Library and tools for manipulating extended attributes";
   };
 }
diff --git a/pkgs/development/libraries/boehm-gc/default.nix b/pkgs/development/libraries/boehm-gc/default.nix
index 8e6f67495339d..6d1074165b5de 100644
--- a/pkgs/development/libraries/boehm-gc/default.nix
+++ b/pkgs/development/libraries/boehm-gc/default.nix
@@ -1,16 +1,19 @@
 {stdenv, fetchurl}:
 
-let version = "7.1"; in
+let
+  version = if stdenv.isMips then "7.2alpha4" else "7.1";
+in
 stdenv.mkDerivation ({
   name = "boehm-gc-${version}";
 
   src = fetchurl {
     url = "http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc-${version}.tar.gz";
-    sha256 = "0c5zrsdw0rsli06lahcqwwz0prgah340fhfg7ggfgvz3iw1gdkp3";
+    sha256 = (if version == "7.1" then "0c5zrsdw0rsli06lahcqwwz0prgah340fhfg7ggfgvz3iw1gdkp3"
+      else if version == "7.2alpha4" then "1ya9hr1wbx0hrx29q5zy2k51ml71k9mhqzqs7f505qr9s6jsfh0b"
+      else throw "Version unknown");
   };
 
-  patches =
-    stdenv.lib.optional (stdenv.system == "i686-cygwin")
+  patches = stdenv.lib.optional (stdenv.system == "i686-cygwin")
                         ./cygwin-pthread-dl.patch;
 
   doCheck = true;
diff --git a/pkgs/development/libraries/cloog-ppl/default.nix b/pkgs/development/libraries/cloog-ppl/default.nix
index b1372d79cb505..ca662d30eb0fd 100644
--- a/pkgs/development/libraries/cloog-ppl/default.nix
+++ b/pkgs/development/libraries/cloog-ppl/default.nix
@@ -1,16 +1,32 @@
-{ fetchurl, stdenv, ppl }:
+{ fetchurl, stdenv, ppl, static ? false }:
+
+let
+
+  # --with-host-libstdcxx helps when *ppl* is built statically.
+  # But I will suppose that this is statically built only when ppl is also
+  # statically built.
+  staticFlags =
+    assert static -> ppl.dontDisableStatic == true;
+    if static then " --enable-static --disable-shared --with-host-libstdcxx=-lstdc++" else "";
+    
+in
 
 stdenv.mkDerivation rec {
-  name = "cloog-ppl-0.15.7";
+  name = "cloog-ppl-0.15.9";
 
   src = fetchurl {
     url = "mirror://gcc/infrastructure/${name}.tar.gz";
-    sha256 = "0zb96524jk2l78gr5gw0wq3dnvdsmyr2av59v89zv5xcps417q55";
+    sha256 = "19a2n75k3d3n8llng25f2g88lpvd4zn0lm073rkndjw6l6yd8m4c";
   };
 
   propagatedBuildInputs = [ ppl ];
 
-  configureFlags = "--with-ppl=${ppl}";
+  configureFlags = "--with-ppl=${ppl}" + staticFlags;
+  dontDisableStatic = if static then true else false;
+
+  crossAttrs = {
+    configureFlags = "--with-ppl=${ppl.hostDrv}" + staticFlags;
+  };
 
   doCheck = true;
 
diff --git a/pkgs/development/libraries/cyrus-sasl/default.nix b/pkgs/development/libraries/cyrus-sasl/default.nix
index c9d14fe8465c1..0da4d5da3e76c 100644
--- a/pkgs/development/libraries/cyrus-sasl/default.nix
+++ b/pkgs/development/libraries/cyrus-sasl/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, openssl, db4, gettext} :
+{ stdenv, fetchurl, openssl, db4, gettext, automake} :
 
 stdenv.mkDerivation {
   name = "cyrus-sasl-2.1.23";
@@ -9,6 +9,7 @@ stdenv.mkDerivation {
   };
   preConfigure=''
     configureFlags="--with-openssl=${openssl} --with-plugindir=$out/lib/sasl2 --with-configdir=$out/lib/sasl2 --enable-login"
+    cp ${automake}/share/automake*/config.{sub,guess} config
   '';
   buildInputs = [ openssl db4 gettext ];
   patches = [ ./cyrus-sasl-2.1.22-bad-elif.patch ];
diff --git a/pkgs/development/libraries/ffmpeg/default.nix b/pkgs/development/libraries/ffmpeg/default.nix
index 01479564dd7ff..d9f9d0af01deb 100644
--- a/pkgs/development/libraries/ffmpeg/default.nix
+++ b/pkgs/development/libraries/ffmpeg/default.nix
@@ -1,5 +1,5 @@
 {stdenv, fetchurl, faad2, libtheora, speex, libvorbis, x264, pkgconfig, xvidcore, lame, yasm
-, libvpx}:
+, vpxSupport ? false, libvpx ? null}:
 
 stdenv.mkDerivation {
   name = "ffmpeg-0.6";
@@ -12,25 +12,26 @@ stdenv.mkDerivation {
   # `--enable-gpl' (as well as the `postproc' and `swscale') mean that
   # the resulting library is GPL'ed, so it can only be used in GPL'ed
   # applications.
-  configureFlags = ''
-    --enable-gpl
-    --enable-postproc
-    --enable-swscale
-    --disable-ffserver
-    --disable-ffplay
-    --enable-libfaad
-    --enable-shared
-    --enable-libtheora
-    --enable-libvorbis
-    --enable-libspeex
-    --enable-libx264
-    --enable-libxvid
-    --enable-libmp3lame
-    --enable-runtime-cpudetect
-    --enable-libvpx
-  '';
+  configureFlags = [
+    "--enable-gpl"
+    "--enable-postproc"
+    "--enable-swscale"
+    "--disable-ffserver"
+    "--disable-ffplay"
+    "--enable-libfaad"
+    "--enable-shared"
+    "--enable-libtheora"
+    "--enable-libvorbis"
+    "--enable-libspeex"
+    "--enable-libx264"
+    "--enable-libxvid"
+    "--enable-libmp3lame"
+    "--enable-runtime-cpudetect"
+  ] ++
+    stdenv.lib.optional vpxSupport "--enable-libvpx";
 
-  buildInputs = [faad2 libtheora speex libvorbis x264 pkgconfig xvidcore lame yasm libvpx];
+  buildInputs = [ faad2 libtheora speex libvorbis x264 pkgconfig xvidcore lame yasm ]
+    ++ stdenv.lib.optional vpxSupport libvpx;
 
   meta = {
     homepage = http://www.ffmpeg.org/;
diff --git a/pkgs/development/libraries/gdbm/default.nix b/pkgs/development/libraries/gdbm/default.nix
index d6f1d118f8226..448fd04edd814 100644
--- a/pkgs/development/libraries/gdbm/default.nix
+++ b/pkgs/development/libraries/gdbm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl }:
+{ stdenv, fetchurl, automake }:
 
 stdenv.mkDerivation rec {
   name = "gdbm-1.8.3";
@@ -9,6 +9,11 @@ stdenv.mkDerivation rec {
 
   patches = [ ./install.patch ];
 
+  # The fuloong2f is not supported by gdbm 1.8.3 still
+  preConfigure = ''
+    cp ${automake}/share/automake*/config.{sub,guess} .
+  '';
+
   meta = {
     description = "GNU DBM key/value database library";
     homepage = http://www.gnu.org/software/gdbm/;
diff --git a/pkgs/development/libraries/gettext/0.18.nix b/pkgs/development/libraries/gettext/0.18.nix
deleted file mode 100644
index f7f0cb0018caf..0000000000000
--- a/pkgs/development/libraries/gettext/0.18.nix
+++ /dev/null
@@ -1,66 +0,0 @@
-# XXX: Remove me when `stdenv-updates' is merged.
-
-{ stdenv, fetchurl, libiconv }:
-
-stdenv.mkDerivation (rec {
-  name = "gettext-0.18.1.1";
-  
-  src = fetchurl {
-    url = "mirror://gnu/gettext/${name}.tar.gz";
-    sha256 = "1sa3ch12qxa4h3ya6hkz119yclcccmincl9j20dhrdx5mykp3b4k";
-  };
-
-  configureFlags = "--disable-csharp";
-
-  # On cross building, gettext supposes that the wchar.h from libc
-  # does not fulfill gettext needs, so it tries to work with its
-  # own wchar.h file, which does not cope well with the system's
-  # wchar.h and stddef.h (gcc-4.3 - glibc-2.9)
-  preConfigure = ''
-    if test -n "$crossConfig"; then
-      echo gl_cv_func_wcwidth_works=yes > cachefile
-      configureFlags="$configureFlags --cache-file=`pwd`/cachefile"
-    fi
-  '';
-
-  crossAttrs = {
-    buildInputs = stdenv.lib.optional (stdenv.gccCross.libc ? libiconv)
-      stdenv.gccCross.libc.libiconv.hostDrv;
-  };
-
-  meta = {
-    description = "GNU gettext, a well integrated set of translation tools and documentation";
-
-    longDescription = ''
-      Usually, programs are written and documented in English, and use
-      English at execution time for interacting with users.  Using a common
-      language is quite handy for communication between developers,
-      maintainers and users from all countries.  On the other hand, most
-      people are less comfortable with English than with their own native
-      language, and would rather be using their mother tongue for day to
-      day's work, as far as possible.  Many would simply love seeing their
-      computer screen showing a lot less of English, and far more of their
-      own language.
-
-      GNU `gettext' is an important step for the GNU Translation Project, as
-      it is an asset on which we may build many other steps. This package
-      offers to programmers, translators, and even users, a well integrated
-      set of tools and documentation. Specifically, the GNU `gettext'
-      utilities are a set of tools that provides a framework to help other
-      GNU packages produce multi-lingual messages.
-    '';
-
-    homepage = http://www.gnu.org/software/gettext/;
-
-    maintainers = [ stdenv.lib.maintainers.ludo ];
-    platforms = stdenv.lib.platforms.all;
-  };
-}
-
-//
-
-(if (!stdenv.isLinux) # any non-GNU system
-    then {
-      buildInputs = [ libiconv ];
-    }
-    else {}))
diff --git a/pkgs/development/libraries/gettext/default.nix b/pkgs/development/libraries/gettext/default.nix
index 6b094fdc8394d..ddcfc327a9ee3 100644
--- a/pkgs/development/libraries/gettext/default.nix
+++ b/pkgs/development/libraries/gettext/default.nix
@@ -1,11 +1,13 @@
+# XXX: Remove me when `stdenv-updates' is merged.
+
 { stdenv, fetchurl, libiconv }:
 
 stdenv.mkDerivation (rec {
-  name = "gettext-0.17";
+  name = "gettext-0.18.1.1";
   
   src = fetchurl {
     url = "mirror://gnu/gettext/${name}.tar.gz";
-    sha256 = "1fipjpaxxwifdw6cbr7mkxp1yvy643i38nhlh7124bqnisxki5i0";
+    sha256 = "1sa3ch12qxa4h3ya6hkz119yclcccmincl9j20dhrdx5mykp3b4k";
   };
 
   configureFlags = "--disable-csharp";
@@ -21,6 +23,13 @@ stdenv.mkDerivation (rec {
     fi
   '';
 
+  crossAttrs = {
+    buildInputs = stdenv.lib.optional (stdenv.gccCross.libc ? libiconv)
+      stdenv.gccCross.libc.libiconv.hostDrv;
+    # Gettext fails to guess the cross compiler
+    configureFlags = "CXX=${stdenv.cross.config}-g++";
+  };
+
   meta = {
     description = "GNU gettext, a well integrated set of translation tools and documentation";
 
@@ -46,6 +55,7 @@ stdenv.mkDerivation (rec {
     homepage = http://www.gnu.org/software/gettext/;
 
     maintainers = [ stdenv.lib.maintainers.ludo ];
+    platforms = stdenv.lib.platforms.all;
   };
 }
 
diff --git a/pkgs/development/libraries/glib/2.24.x.nix b/pkgs/development/libraries/glib/2.24.x.nix
index 6fdb18e9b4dc1..0cdff4254b0fd 100644
--- a/pkgs/development/libraries/glib/2.24.x.nix
+++ b/pkgs/development/libraries/glib/2.24.x.nix
@@ -8,7 +8,8 @@ stdenv.mkDerivation rec {
     sha256 = "014c3da960bf17117371075c16495f05f36501db990851ceea658f15d2ea6d04";
   };
 
-  buildInputs = [ pkgconfig gettext perl libiconv ];
+  buildInputs = [ pkgconfig gettext libiconv ];
+  buildNativeInputs = [ perl ];
 
   propagatedBuildInputs = [ zlib ];
 
diff --git a/pkgs/development/libraries/glibc-2.11/builder.sh b/pkgs/development/libraries/glibc-2.11/builder.sh
deleted file mode 100644
index cbdb55b121b76..0000000000000
--- a/pkgs/development/libraries/glibc-2.11/builder.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-# Glibc cannot have itself in its RPATH.
-export NIX_NO_SELF_RPATH=1
-
-source $stdenv/setup
-
-postConfigure() {
-    # Hack: get rid of the `-static' flag set by the bootstrap stdenv.
-    # This has to be done *after* `configure' because it builds some
-    # test binaries.
-    export NIX_CFLAGS_LINK=
-    export NIX_LDFLAGS_BEFORE=
-
-    export NIX_DONT_SET_RPATH=1
-    unset CFLAGS
-}
-
-
-postInstall() {
-    if test -n "$installLocales"; then
-        make -j${NIX_BUILD_CORES:-1} -l${NIX_BUILD_CORES:-1} localedata/install-locales
-    fi
-    
-    test -f $out/etc/ld.so.cache && rm $out/etc/ld.so.cache
-
-    # Include the Linux kernel headers in Glibc, except the `scsi'
-    # subdirectory, which Glibc provides itself. 
-    (cd $out/include && ln -s $(ls -d $kernelHeaders/include/* | grep -v 'scsi$') .)
-
-    # Fix for NIXOS-54 (ldd not working on x86_64).  Make a symlink
-    # "lib64" to "lib".
-    if test -n "$is64bit"; then
-        ln -s lib $out/lib64
-    fi
-
-    # This file, that should not remain in the glibc derivation,
-    # may have not been created during the preInstall
-    rm -f $out/lib/libgcc_s.so.1
-}
-
-
-genericBuild
diff --git a/pkgs/development/libraries/glibc-2.11/locale-override.patch b/pkgs/development/libraries/glibc-2.11/locale-override.patch
deleted file mode 100644
index 108d0e35dacf0..0000000000000
--- a/pkgs/development/libraries/glibc-2.11/locale-override.patch
+++ /dev/null
@@ -1,72 +0,0 @@
-diff -rc glibc-2.9-20081208-orig/locale/loadarchive.c glibc-2.9-20081208/locale/loadarchive.c
-*** glibc-2.9-20081208-orig/locale/loadarchive.c	2005-09-09 18:56:52.000000000 +0200
---- glibc-2.9-20081208/locale/loadarchive.c	2009-04-19 13:54:26.000000000 +0200
-***************
-*** 124,129 ****
---- 124,142 ----
-  }
-  
-  
-+ static int
-+ open_locale_archive ()
-+ {
-+   int fd = -1;
-+   char *path = getenv ("LOCALE_ARCHIVE");
-+   if (path)
-+     fd = open_not_cancel_2 (path, O_RDONLY|O_LARGEFILE);
-+   if (fd < 0)
-+     fd = open_not_cancel_2 (archfname, O_RDONLY|O_LARGEFILE);
-+   return fd;
-+ }
-+ 
-+ 
-  /* Find the locale *NAMEP in the locale archive, and return the
-     internalized data structure for its CATEGORY data.  If this locale has
-     already been loaded from the archive, just returns the existing data
-***************
-*** 203,209 ****
-        archmapped = &headmap;
-  
-        /* The archive has never been opened.  */
-!       fd = open_not_cancel_2 (archfname, O_RDONLY|O_LARGEFILE);
-        if (fd < 0)
-  	/* Cannot open the archive, for whatever reason.  */
-  	return NULL;
---- 216,222 ----
-        archmapped = &headmap;
-  
-        /* The archive has never been opened.  */
-!       fd = open_locale_archive ();
-        if (fd < 0)
-  	/* Cannot open the archive, for whatever reason.  */
-  	return NULL;
-***************
-*** 394,400 ****
-  	  if (fd == -1)
-  	    {
-  	      struct stat64 st;
-! 	      fd = open_not_cancel_2 (archfname, O_RDONLY|O_LARGEFILE);
-  	      if (fd == -1)
-  		/* Cannot open the archive, for whatever reason.  */
-  		return NULL;
---- 407,413 ----
-  	  if (fd == -1)
-  	    {
-  	      struct stat64 st;
-! 	      fd = open_locale_archive ();
-  	      if (fd == -1)
-  		/* Cannot open the archive, for whatever reason.  */
-  		return NULL;
-diff -rc glibc-2.9-20081208-orig/sysdeps/generic/unsecvars.h glibc-2.9-20081208/sysdeps/generic/unsecvars.h
-*** glibc-2.9-20081208-orig/sysdeps/generic/unsecvars.h	2006-10-11 18:24:05.000000000 +0200
---- glibc-2.9-20081208/sysdeps/generic/unsecvars.h	2009-04-19 13:55:34.000000000 +0200
-***************
-*** 16,21 ****
---- 16,22 ----
-    "LD_SHOW_AUXV\0"							      \
-    "LD_USE_LOAD_BIAS\0"							      \
-    "LOCALDOMAIN\0"							      \
-+   "LOCALE_ARCHIVE\0"							      \
-    "LOCPATH\0"								      \
-    "MALLOC_TRACE\0"							      \
-    "NIS_PATH\0"								      \
diff --git a/pkgs/development/libraries/glibc-2.11/mod_nano.patch b/pkgs/development/libraries/glibc-2.11/mod_nano.patch
deleted file mode 100644
index 2fb35b3df38aa..0000000000000
--- a/pkgs/development/libraries/glibc-2.11/mod_nano.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-commit 89b432d7a5befb85048c97e881b2106e8df58e43
-Author: Ulrich Drepper <drepper@redhat.com>
-Date:   Sun Nov 22 10:23:12 2009 -0800
-
-    Fix up <sys/timex.h> a bit more for recent API changes.
-
-diff --git a/sysdeps/unix/sysv/linux/sys/timex.h b/sysdeps/unix/sysv/linux/sys/timex.h
-index 5f10c7f..88b87f1 100644
---- a/sysdeps/unix/sysv/linux/sys/timex.h
-+++ b/sysdeps/unix/sysv/linux/sys/timex.h
-@@ -85,6 +85,9 @@ struct timex
- #define MOD_TIMECONST	ADJ_TIMECONST
- #define MOD_CLKB	ADJ_TICK
- #define MOD_CLKA	ADJ_OFFSET_SINGLESHOT /* 0x8000 in original */
-+#define MOD_TAI		ADJ_TAI
-+#define MOD_MICRO	ADJ_MICRO
-+#define MOD_NANO	ADJ_NANO
- 
- 
- /* Status codes (timex.status) */
-@@ -108,8 +111,9 @@ struct timex
- #define STA_MODE	0x4000	/* mode (0 = PLL, 1 = FLL) (ro) */
- #define STA_CLK		0x8000	/* clock source (0 = A, 1 = B) (ro) */
- 
-+/* Read-only bits */
- #define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
--    STA_PPSERROR | STA_CLOCKERR) /* read-only bits */
-+    STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
- 
- /* Clock states (time_state) */
- #define TIME_OK		0	/* clock synchronized, no leap second */
diff --git a/pkgs/development/libraries/glibc-2.11/nss-skip-unavail.patch b/pkgs/development/libraries/glibc-2.11/nss-skip-unavail.patch
deleted file mode 100644
index dc09b5098707e..0000000000000
--- a/pkgs/development/libraries/glibc-2.11/nss-skip-unavail.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-diff -rc glibc-2.9-20081208-orig/sysdeps/posix/getaddrinfo.c glibc-2.9-20081208/sysdeps/posix/getaddrinfo.c
-*** glibc-2.9-20081208-orig/sysdeps/posix/getaddrinfo.c	2008-07-30 21:14:22.000000000 +0200
---- glibc-2.9-20081208/sysdeps/posix/getaddrinfo.c	2008-12-10 11:39:32.000000000 +0100
-***************
-*** 505,512 ****
-  	  int no_data = 0;
-  	  int no_inet6_data = 0;
-  	  service_user *nip = NULL;
-- 	  enum nss_status inet6_status = NSS_STATUS_UNAVAIL;
-- 	  enum nss_status status = NSS_STATUS_UNAVAIL;
-  	  int no_more;
-  	  int old_res_options;
-  
---- 505,510 ----
-***************
-*** 702,707 ****
---- 700,707 ----
-  
-  	  while (!no_more)
-  	    {
-+ 	      enum nss_status inet6_status = NSS_STATUS_UNAVAIL;
-+ 	      enum nss_status status = NSS_STATUS_UNAVAIL;
-  	      nss_gethostbyname4_r fct4
-  		= __nss_lookup_function (nip, "gethostbyname4_r");
-  	      if (fct4 != NULL)
diff --git a/pkgs/development/libraries/glibc-2.11/builder2.sh b/pkgs/development/libraries/glibc-2.12/builder.sh
index 7d1a05131c2ac..9a1c1490019a6 100644
--- a/pkgs/development/libraries/glibc-2.11/builder2.sh
+++ b/pkgs/development/libraries/glibc-2.12/builder.sh
@@ -1,6 +1,3 @@
-### XXX: This file should replace `builder.sh' in the `stdenv-updates'
-### branch!
-
 # Glibc cannot have itself in its RPATH.
 export NIX_NO_SELF_RPATH=1
 
diff --git a/pkgs/development/libraries/glibc-2.11/common.nix b/pkgs/development/libraries/glibc-2.12/common.nix
index 00d9b99cc519a..af36787139bff 100644
--- a/pkgs/development/libraries/glibc-2.11/common.nix
+++ b/pkgs/development/libraries/glibc-2.12/common.nix
@@ -11,9 +11,18 @@ cross :
 
 let
   # For GNU/Hurd, see below.
-  date = "20100512";
-  rev = "df4c3faf0ccc848b5a8086c222bdb42679a9798f";
-  version = if hurdHeaders != null then date else "2.11.1";
+  version = if hurdHeaders != null then "20100512" else "2.12.1";
+
+  needsPortsNative = stdenv.isMips || stdenv.isArm;
+  needsPortsCross = cross.arch == "mips" || cross.arch == "arm";
+  needsPorts = if cross == null then needsPortsNative else needsPortsCross;
+
+  srcPorts = fetchurl {
+    # A tarball I manually made from a git clone, for the tag "glibc-2.12.1".
+    url = http://vicerveza.homeunix.net/~viric/tmp/nix/glibc-ports-2.12.1.tar.gz;
+    sha256 = "160dr4v9210r6d7xp0af5kx1pljcjaa2x4ya88psjiphcr6bsy37";
+  };
+
 in
 
 assert (cross != null) -> (gccCross != null);
@@ -56,25 +65,30 @@ stdenv.mkDerivation ({
        does work because "status" will contain UNAVAIL after the
        failure to find mdns4_minimal. */
     ./nss-skip-unavail.patch
-
-    ++ [
-    /* Make it possible to override the locale-archive in NixOS. */
-    ./locale-override.patch
-
+  ++ [
     /* Have rpcgen(1) look for cpp(1) in $PATH.  */
     ./rpcgen-path.patch
 
     /* Make sure `nscd' et al. are linked against `libssp'.  */
     ./stack-protector-link.patch
-  ]
 
-  ++ stdenv.lib.optional (fetchgit == null)
-    /* MOD_NANO definition, for ntp (taken from glibc upstream) */
-    ./mod_nano.patch;
+    /* Fix for the check of -fgnu89-inline compiler flag */
+    ./gnu89-inline.patch
+
+    /* Allow nixos and nix handle the locale-archive. */
+    ./nix-locale-archive.patch
+  ];
+
+  # Needed for glibc to build with the gnumake 3.82
+  # http://comments.gmane.org/gmane.linux.lfs.support/31227
+  postPatch = ''
+    sed -i 's/ot \$/ot:\n\ttouch $@\n$/' manual/Makefile
+  '';
 
   configureFlags = [
     "-C"
     "--enable-add-ons"
+    "--localedir=/var/run/current-system/sw/lib/locale"
     (if kernelHeaders != null
      then "--with-headers=${kernelHeaders}/include"
      else "--without-headers")
@@ -91,7 +105,7 @@ stdenv.mkDerivation ({
     "--build=arm-linux-gnueabi"
     "--without-fp"
   ];
-
+  
   buildInputs = stdenv.lib.optionals (cross != null) [ gccCross ]
     ++ stdenv.lib.optional (mig != null) mig;
 
@@ -108,9 +122,9 @@ stdenv.mkDerivation ({
   NIX_CFLAGS_COMPILE = stdenv.lib.optionalString (stdenv.system == "i686-linux") "-U__i686";
 }
 
-# FIXME: This is way too broad and causes the *native* glibc to have a
-# different store path dependending on whether `cross' is null or not.
-// args //
+# Remove the `gccCross' attribute so that the *native* glibc store path
+# doesn't depend on whether `gccCross' is null or not.
+// (removeAttrs args [ "gccCross" ]) //
 
 {
   name = name + "-${version}" +
@@ -124,18 +138,13 @@ stdenv.mkDerivation ({
       # See <http://www.gnu.org/software/hurd/source_repositories/glibc.html>.
       url = "git://git.sv.gnu.org/hurd/glibc.git";
       sha256 = "f3590a54a9d897d121f91113949edbaaf3e30cdeacbb8d0a44de7b6564f6643e";
-      inherit rev;
+      rev = "df4c3faf0ccc848b5a8086c222bdb42679a9798f";
     }
     else fetchurl {
       url = "mirror://gnu/glibc/glibc-${version}.tar.bz2";
-      sha256 = "18azb6518ryqhkfmddr25p0h1s2msrmx7dblij58sjlnzh61vq34";
+      sha256 = "01vlr473skl08xpcjz0b4lw23lsnskf5kx9s8nxwa4mwa9f137vm";
     };
 
-  srcPorts = fetchurl {
-    url = "mirror://gnu/glibc/glibc-ports-2.11.tar.bz2";
-    sha256 = "12b53f5k4gcr8rr1kg2ycf2701rygqsyf9r8gz4j3l9flaqi5liq";
-  };
-
   # `fetchurl' is a function and thus should not be passed to the
   # `derivation' primitive.
   fetchurl = null;
@@ -149,12 +158,12 @@ stdenv.mkDerivation ({
         sed -i "$i" -e "s^/bin/pwd^$PWD_P^g"
     done
 
-    tar xvjf "$srcPorts"
+    ${if needsPorts then "tar xvf ${srcPorts}" else ""}
 
     mkdir ../build
     cd ../build
 
-    configureScript="../$sourceRoot/configure"
+    configureScript="`pwd`/../$sourceRoot/configure"
 
     ${preConfigure}
   '';
diff --git a/pkgs/development/libraries/glibc-2.11/default.nix b/pkgs/development/libraries/glibc-2.12/default.nix
index a9d82e677b179..31a8ef13a4fe8 100644
--- a/pkgs/development/libraries/glibc-2.11/default.nix
+++ b/pkgs/development/libraries/glibc-2.12/default.nix
@@ -50,9 +50,6 @@ in
        # thing.
        inherit propagatedBuildInputs;
      };
-
-     # XXX: Remove this hack in `stdenv-updates'.
-     builder = ./builder2.sh;
    }
    else { })
 
@@ -77,5 +74,10 @@ in
 
         dontStrip=1
       '';
-   }
+
+      # To avoid a dependency on the build system 'bash'.
+      preFixup = ''
+        rm $out/bin/{ldd,tzselect,catchsegv,xtrace}
+      '';
+    }
    else {}))
diff --git a/pkgs/development/libraries/glibc-2.12/gnu89-inline.patch b/pkgs/development/libraries/glibc-2.12/gnu89-inline.patch
new file mode 100644
index 0000000000000..16d8f914a192f
--- /dev/null
+++ b/pkgs/development/libraries/glibc-2.12/gnu89-inline.patch
@@ -0,0 +1,26 @@
+diff --git a/configure b/configure
+index ce76653..fba6de2 100755
+--- a/configure
++++ b/configure
+@@ -6891,7 +6891,7 @@ fi
+ $as_echo "$libc_cv_gnu89_inline" >&6; }
+ if test $libc_cv_gnu89_inline = yes; then
+   libc_cv_gnu89_inline=-fgnu89-inline
+-else
++elif test $libc_cv_gnu89_inline = no; then
+   libc_cv_gnu89_inline=
+ fi
+ 
+diff --git a/configure.in b/configure.in
+index 182c683..b867371 100644
+--- a/configure.in
++++ b/configure.in
+@@ -1777,7 +1777,7 @@ fi
+ rm -f conftest*])
+ if test $libc_cv_gnu89_inline = yes; then
+   libc_cv_gnu89_inline=-fgnu89-inline
+-else
++elif test $libc_cv_gnu89_inline = no; then
+   libc_cv_gnu89_inline=
+ fi
+ AC_SUBST(libc_cv_gnu89_inline)
diff --git a/pkgs/development/libraries/glibc-2.11/info.nix b/pkgs/development/libraries/glibc-2.12/info.nix
index 84a16fefce9de..84a16fefce9de 100644
--- a/pkgs/development/libraries/glibc-2.11/info.nix
+++ b/pkgs/development/libraries/glibc-2.12/info.nix
diff --git a/pkgs/development/libraries/glibc-2.11/locales-builder.sh b/pkgs/development/libraries/glibc-2.12/locales-builder.sh
index d732e208fa22a..d732e208fa22a 100644
--- a/pkgs/development/libraries/glibc-2.11/locales-builder.sh
+++ b/pkgs/development/libraries/glibc-2.12/locales-builder.sh
diff --git a/pkgs/development/libraries/glibc-2.11/locales.nix b/pkgs/development/libraries/glibc-2.12/locales.nix
index 821eddd41f0d1..38f3f0723848f 100644
--- a/pkgs/development/libraries/glibc-2.11/locales.nix
+++ b/pkgs/development/libraries/glibc-2.12/locales.nix
@@ -26,6 +26,10 @@ in
     buildPhase =
       ''
         mkdir -p $TMPDIR/"$(dirname $(readlink -f $(type -p localedef)))/../lib/locale"
+
+        # Hack to allow building of the locales (needed since glibc-2.12)
+        sed -i -e 's/^LOCALEDEF=/LOCALEDEF?=/' ../glibc-2*/localedata/Makefile
+
         make localedata/install-locales \
             LOCALEDEF="localedef --prefix=$TMPDIR" \
             localedir=$out/lib/locale \
diff --git a/pkgs/development/libraries/glibc-2.12/nix-locale-archive.patch b/pkgs/development/libraries/glibc-2.12/nix-locale-archive.patch
new file mode 100644
index 0000000000000..aca904f7ff445
--- /dev/null
+++ b/pkgs/development/libraries/glibc-2.12/nix-locale-archive.patch
@@ -0,0 +1,116 @@
+diff --git a/locale/loadarchive.c b/locale/loadarchive.c
+index d545f17..0d8638a 100644
+--- a/locale/loadarchive.c
++++ b/locale/loadarchive.c
+@@ -124,6 +124,25 @@ calculate_head_size (const struct locarhead *h)
+ }
+ 
+ 
++static int
++open_locale_archive ()
++{
++  int fd = -1;
++  char *path = getenv ("LOCALE_ARCHIVE_2_11");
++  char *path2 = getenv ("LOCALE_ARCHIVE");
++  const char *usualpath = "/usr/lib/locale/locale-archive";
++  if (path)
++    fd = open_not_cancel_2 (path, O_RDONLY|O_LARGEFILE);
++  if (path2 && fd < 0)
++    fd = open_not_cancel_2 (path2, O_RDONLY|O_LARGEFILE);
++  if (fd < 0)
++    fd = open_not_cancel_2 (archfname, O_RDONLY|O_LARGEFILE);
++  if (fd < 0)
++    fd = open_not_cancel_2 (usualpath, O_RDONLY|O_LARGEFILE);
++  return fd;
++}
++
++
+ /* Find the locale *NAMEP in the locale archive, and return the
+    internalized data structure for its CATEGORY data.  If this locale has
+    already been loaded from the archive, just returns the existing data
+@@ -203,7 +222,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
+       archmapped = &headmap;
+ 
+       /* The archive has never been opened.  */
+-      fd = open_not_cancel_2 (archfname, O_RDONLY|O_LARGEFILE);
++      fd = open_locale_archive ();
+       if (fd < 0)
+ 	/* Cannot open the archive, for whatever reason.  */
+ 	return NULL;
+@@ -394,7 +413,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
+ 	  if (fd == -1)
+ 	    {
+ 	      struct stat64 st;
+-	      fd = open_not_cancel_2 (archfname, O_RDONLY|O_LARGEFILE);
++	      fd = open_locale_archive ();
+ 	      if (fd == -1)
+ 		/* Cannot open the archive, for whatever reason.  */
+ 		return NULL;
+diff --git a/locale/programs/locale.c b/locale/programs/locale.c
+index 77262b7..fddc00d 100644
+--- a/locale/programs/locale.c
++++ b/locale/programs/locale.c
+@@ -628,6 +628,20 @@ nameentcmp (const void *a, const void *b)
+ 		  ((const struct nameent *) b)->name);
+ }
+ 
++static int
++open_nix_locale_archive (const char * fname, int access)
++{
++  int fd = -1;
++  char *path = getenv ("LOCALE_ARCHIVE_2_11");
++  char *path2 = getenv ("LOCALE_ARCHIVE");
++  if (path)
++    fd = open64 (path, access);
++  if (path2 && fd < 0)
++    fd = open64 (path2, access);
++  if (fd < 0)
++    fd = open64 (fname, access);
++  return fd;
++}
+ 
+ static int
+ write_archive_locales (void **all_datap, char *linebuf)
+@@ -641,7 +658,7 @@ write_archive_locales (void **all_datap, char *linebuf)
+   int fd, ret = 0;
+   uint32_t cnt;
+ 
+-  fd = open64 (ARCHIVE_NAME, O_RDONLY);
++  fd = open_nix_locale_archive (ARCHIVE_NAME, O_RDONLY);
+   if (fd < 0)
+     return 0;
+ 
+diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c
+index 85ba77d..3ad2af8 100644
+--- a/locale/programs/locarchive.c
++++ b/locale/programs/locarchive.c
+@@ -512,6 +512,20 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head)
+   *ah = new_ah;
+ }
+ 
++static int
++open_nix_locale_archive (const char * fname, int access)
++{
++  int fd = -1;
++  char *path = getenv ("LOCALE_ARCHIVE_2_11");
++  char *path2 = getenv ("LOCALE_ARCHIVE");
++  if (path)
++    fd = open64 (path, access);
++  if (path2 && fd < 0)
++    fd = open64 (path2, access);
++  if (fd < 0)
++    fd = open64 (fname, access);
++  return fd;
++}
+ 
+ void
+ open_archive (struct locarhandle *ah, bool readonly)
+@@ -531,7 +548,7 @@ open_archive (struct locarhandle *ah, bool readonly)
+   while (1)
+     {
+       /* Open the archive.  We must have exclusive write access.  */
+-      fd = open64 (archivefname, readonly ? O_RDONLY : O_RDWR);
++      fd = open_nix_locale_archive (archivefname, readonly ? O_RDONLY : O_RDWR);
+       if (fd == -1)
+ 	{
+ 	  /* Maybe the file does not yet exist.  */
diff --git a/pkgs/development/libraries/glibc-2.12/nss-skip-unavail.patch b/pkgs/development/libraries/glibc-2.12/nss-skip-unavail.patch
new file mode 100644
index 0000000000000..e48dc2bc0a6ed
--- /dev/null
+++ b/pkgs/development/libraries/glibc-2.12/nss-skip-unavail.patch
@@ -0,0 +1,21 @@
+diff -ru glibc-2.11.2-orig/sysdeps/posix/getaddrinfo.c glibc-2.11.2/sysdeps/posix/getaddrinfo.c
+--- glibc-2.11.2-orig/sysdeps/posix/getaddrinfo.c	2010-05-19 22:38:20.000000000 +0200
++++ glibc-2.11.2/sysdeps/posix/getaddrinfo.c	2010-08-05 18:39:54.259556327 +0200
+@@ -505,8 +505,6 @@
+ 	  int no_data = 0;
+ 	  int no_inet6_data = 0;
+ 	  service_user *nip = NULL;
+-	  enum nss_status inet6_status = NSS_STATUS_UNAVAIL;
+-	  enum nss_status status = NSS_STATUS_UNAVAIL;
+ 	  int no_more;
+ 	  int old_res_options;
+ 
+@@ -702,6 +700,8 @@
+ 
+ 	  while (!no_more)
+ 	    {
++ 	      enum nss_status inet6_status = NSS_STATUS_UNAVAIL;
++ 	      enum nss_status status = NSS_STATUS_UNAVAIL;
+ 	      no_data = 0;
+ 	      nss_gethostbyname4_r fct4
+ 		= __nss_lookup_function (nip, "gethostbyname4_r");
diff --git a/pkgs/development/libraries/glibc-2.11/rpcgen-path.patch b/pkgs/development/libraries/glibc-2.12/rpcgen-path.patch
index fbb03dd5fadee..fbb03dd5fadee 100644
--- a/pkgs/development/libraries/glibc-2.11/rpcgen-path.patch
+++ b/pkgs/development/libraries/glibc-2.12/rpcgen-path.patch
diff --git a/pkgs/development/libraries/glibc-2.11/stack-protector-link.patch b/pkgs/development/libraries/glibc-2.12/stack-protector-link.patch
index d200ece52df70..d200ece52df70 100644
--- a/pkgs/development/libraries/glibc-2.11/stack-protector-link.patch
+++ b/pkgs/development/libraries/glibc-2.12/stack-protector-link.patch
diff --git a/pkgs/development/libraries/gmp/4.nix b/pkgs/development/libraries/gmp/4.nix
new file mode 100644
index 0000000000000..c5a59045bbe99
--- /dev/null
+++ b/pkgs/development/libraries/gmp/4.nix
@@ -0,0 +1,59 @@
+{stdenv, fetchurl, m4, cxx ? true, static ? false}:
+
+let
+  staticFlags = if static then " --enable-static --disable-shared" else "";
+in
+
+stdenv.mkDerivation rec {
+  name = "gmp-4.3.2";
+
+  src = fetchurl {
+    url = "mirror://gnu/gmp/${name}.tar.bz2";
+    sha256 = "0x8prpqi9amfcmi7r4zrza609ai9529pjaq0h4aw51i867064qck";
+  };
+
+  buildNativeInputs = [m4];
+
+  # Prevent the build system from using sub-architecture-specific
+  # instructions (e.g., SSE2 on i686).
+  preConfigure = "ln -sf configfsf.guess config.guess";
+
+  configureFlags = (if cxx then "--enable-cxx" else "--disable-cxx") +
+      staticFlags;
+
+  dontDisableStatic = if static then true else false;
+
+  doCheck = true;
+
+  meta = {
+    description = "GMP, the GNU multiple precision arithmetic library";
+
+    longDescription =
+      '' GMP is a free library for arbitrary precision arithmetic, operating
+         on signed integers, rational numbers, and floating point numbers.
+         There is no practical limit to the precision except the ones implied
+         by the available memory in the machine GMP runs on.  GMP has a rich
+         set of functions, and the functions have a regular interface.
+
+         The main target applications for GMP are cryptography applications
+         and research, Internet security applications, algebra systems,
+         computational algebra research, etc.
+
+         GMP is carefully designed to be as fast as possible, both for small
+         operands and for huge operands.  The speed is achieved by using
+         fullwords as the basic arithmetic type, by using fast algorithms,
+         with highly optimised assembly code for the most common inner loops
+         for a lot of CPUs, and by a general emphasis on speed.
+
+         GMP is faster than any other bignum library.  The advantage for GMP
+         increases with the operand sizes for many operations, since GMP uses
+         asymptotically faster algorithms.
+      '';
+
+    homepage = http://gmplib.org/;
+    license = "LGPLv3+";
+
+    maintainers = [ stdenv.lib.maintainers.ludo ];
+    platforms = stdenv.lib.platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/gmp/default.nix b/pkgs/development/libraries/gmp/default.nix
index ac20bc68f4d8a..338debaa81e75 100644
--- a/pkgs/development/libraries/gmp/default.nix
+++ b/pkgs/development/libraries/gmp/default.nix
@@ -1,27 +1,61 @@
-{stdenv, fetchurl, m4, cxx ? true}:
+{stdenv, fetchurl, m4, cxx ? true, static ? false}:
+
+let
+  staticFlags = if static then " --enable-static --disable-shared" else "";
+in
 
 stdenv.mkDerivation rec {
-  name = "gmp-4.3.2";
+  name = "gmp-5.0.1";
 
   src = fetchurl {
     url = "mirror://gnu/gmp/${name}.tar.bz2";
-    sha256 = "0x8prpqi9amfcmi7r4zrza609ai9529pjaq0h4aw51i867064qck";
+    sha256 = "1yrr14l6vvhm1g27y8nb3c75j0i4ii4k1gw7ik08safk3zq119m2";
   };
 
   buildNativeInputs = [m4];
 
+  # Prevent the build system from using sub-architecture-specific
+  # instructions (e.g., SSE2 on i686).
   preConfigure = "ln -sf configfsf.guess config.guess";
 
-  configureFlags = if cxx then "--enable-cxx" else "--disable-cxx";
+  configureFlags = if cxx then "--enable-cxx" else "--disable-cxx" +
+      staticFlags;
+
+  dontDisableStatic = if static then true else false;
 
   doCheck = true;
 
   enableParallelBuilding = true;
 
   meta = {
-    description = "A free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers";
+    description = "GMP, the GNU multiple precision arithmetic library";
+
+    longDescription =
+      '' GMP is a free library for arbitrary precision arithmetic, operating
+         on signed integers, rational numbers, and floating point numbers.
+         There is no practical limit to the precision except the ones implied
+         by the available memory in the machine GMP runs on.  GMP has a rich
+         set of functions, and the functions have a regular interface.
+
+         The main target applications for GMP are cryptography applications
+         and research, Internet security applications, algebra systems,
+         computational algebra research, etc.
+
+         GMP is carefully designed to be as fast as possible, both for small
+         operands and for huge operands.  The speed is achieved by using
+         fullwords as the basic arithmetic type, by using fast algorithms,
+         with highly optimised assembly code for the most common inner loops
+         for a lot of CPUs, and by a general emphasis on speed.
+
+         GMP is faster than any other bignum library.  The advantage for GMP
+         increases with the operand sizes for many operations, since GMP uses
+         asymptotically faster algorithms.
+      '';
+
     homepage = http://gmplib.org/;
-    license = "LGPL";
+    license = "LGPLv3+";
+
+    maintainers = [ stdenv.lib.maintainers.ludo ];
     platforms = stdenv.lib.platforms.all;
   };
 }
diff --git a/pkgs/development/libraries/gstreamer/default.nix b/pkgs/development/libraries/gstreamer/default.nix
index 3bb8ea84a2af7..a41e694889214 100644
--- a/pkgs/development/libraries/gstreamer/default.nix
+++ b/pkgs/development/libraries/gstreamer/default.nix
@@ -2,7 +2,7 @@ args: with args;
 rec {
   gstreamer = makeOverridable (import ./gstreamer) {
     inherit (args) fetchurl stdenv perl bison flex
-       pkgconfig python which gtkdoc glib libxml2;
+       pkgconfig python which glib libxml2;
   };
 
   gstPluginsBase = makeOverridable (import ./gst-plugins-base) {
diff --git a/pkgs/development/libraries/gstreamer/gnonlin/default.nix b/pkgs/development/libraries/gstreamer/gnonlin/default.nix
index 35f7f3b098601..aac3889ecd712 100644
--- a/pkgs/development/libraries/gstreamer/gnonlin/default.nix
+++ b/pkgs/development/libraries/gstreamer/gnonlin/default.nix
@@ -1,14 +1,14 @@
 args: with args;
 
 stdenv.mkDerivation rec {
-  name = "gnonlin-0.10.14";
+  name = "gnonlin-0.10.15";
 
   src = fetchurl {
     urls = [
-      "http://gstreamer.freedesktop.org/src/gnonlin/${name}.tar.gz"
-      "mirror://gentoo/distfiles/${name}.tar.gz"
+      "http://gstreamer.freedesktop.org/src/gnonlin/${name}.tar.bz2"
+      "mirror://gentoo/distfiles/${name}.tar.bz2"
       ];
-    sha256 = "10gp3hz9a6hrrmdaa3i2ry79fyr402il1qr0vpsd6ayn02gcj93w";
+    sha256 = "1yz0i3vzpadz5axwdb310bypl4rm1xy2n6mgajja0w2z6afnrfv0";
   };
 
   buildInputs = [ gstPluginsBase gstreamer pkgconfig ];
diff --git a/pkgs/development/libraries/gstreamer/gst-ffmpeg/default.nix b/pkgs/development/libraries/gstreamer/gst-ffmpeg/default.nix
index c45af907aabaf..65eb2bb034f70 100644
--- a/pkgs/development/libraries/gstreamer/gst-ffmpeg/default.nix
+++ b/pkgs/development/libraries/gstreamer/gst-ffmpeg/default.nix
@@ -1,14 +1,14 @@
 { fetchurl, stdenv, pkgconfig, gstPluginsBase, bzip2 }:
 
 stdenv.mkDerivation rec {
-  name = "gst-ffmpeg-0.10.9";
+  name = "gst-ffmpeg-0.10.11";
 
   src = fetchurl {
     urls = [
       "http://gstreamer.freedesktop.org/src/gst-ffmpeg/${name}.tar.bz2"
       "mirror://gentoo/distfiles/${name}.tar.bz2"
       ];
-    sha256 = "05cg5jzl8wccsr495hgs7cgdkc6dfi1v218fsm5fv2slgly1pvb3";
+    sha256 = "0bk9k9sccx9nvhjakacvq8gd6vp63x9ddmjrqkfdhkmgwlwa2dpz";
   };
 
   propagatedBuildInputs = [ gstPluginsBase ];
diff --git a/pkgs/development/libraries/gstreamer/gst-plugins-base/default.nix b/pkgs/development/libraries/gstreamer/gst-plugins-base/default.nix
index 37d0a058ffff4..db817918e0212 100644
--- a/pkgs/development/libraries/gstreamer/gst-plugins-base/default.nix
+++ b/pkgs/development/libraries/gstreamer/gst-plugins-base/default.nix
@@ -4,17 +4,20 @@
 , liboil, gtk, which, gtkdoc }:
 
 stdenv.mkDerivation rec {
-  name = "gst-plugins-base-0.10.26";
+  name = "gst-plugins-base-0.10.30";
 
   src = fetchurl {
     urls = [
       "${meta.homepage}/src/gst-plugins-base/${name}.tar.bz2"
       "mirror://gentoo/distfiles/${name}.tar.bz2"
       ];
-    sha256 = "0znxs3ls0hgc7vmllna3bazw217q1h9lmn5vhnclfadbb3flhvg0";
+    sha256 = "1mw5n1w7l0hgyzf75srdxlh3knfgrmddbs2ah1f97s8b710qd4v3";
   };
 
-  patchPhase = "sed -i 's@/bin/echo@echo@g' configure";
+  patchPhase = ''
+    sed -i 's@/bin/echo@echo@g' configure
+    sed -i -e 's/^   /\t/' docs/{libs,plugins}/Makefile.in
+  '';
 
 # TODO : v4l, libvisual
   propagatedBuildInputs = [gstreamer libX11 libXv libXext alsaLib cdparanoia
diff --git a/pkgs/development/libraries/gstreamer/gst-plugins-good/default.nix b/pkgs/development/libraries/gstreamer/gst-plugins-good/default.nix
index 2998c89a51ea6..8256a0afd45a2 100644
--- a/pkgs/development/libraries/gstreamer/gst-plugins-good/default.nix
+++ b/pkgs/development/libraries/gstreamer/gst-plugins-good/default.nix
@@ -5,14 +5,14 @@
 }:
 
 stdenv.mkDerivation rec {
-  name = "gst-plugins-good-0.10.18";
+  name = "gst-plugins-good-0.10.24";
 
   src = fetchurl {
     urls = [
       "${meta.homepage}/src/gst-plugins-good/${name}.tar.bz2"
       "mirror://gentoo/distfiles/${name}.tar.bz2"
       ];
-    sha256 = "1fabn9h4z1p4h35nrw9fyjhcnl1z6cnikmpcb9q6fd312mr8hfqj";
+    sha256 = "1gnhw86yx0362hvmnihiq5d7i710ag9zlg636dlcdvxqqp4slx7j";
   };
 
   propagatedBuildInputs = [gstPluginsBase aalib cairo flac hal libjpeg
diff --git a/pkgs/development/libraries/gstreamer/gstreamer/default.nix b/pkgs/development/libraries/gstreamer/gstreamer/default.nix
index 91a699f564fa1..abb445b57a388 100644
--- a/pkgs/development/libraries/gstreamer/gstreamer/default.nix
+++ b/pkgs/development/libraries/gstreamer/gstreamer/default.nix
@@ -1,8 +1,8 @@
 { fetchurl, stdenv, perl, bison, flex, pkgconfig, python
-, which, gtkdoc, glib, libxml2 }:
+, which, glib, libxml2 }:
 
 stdenv.mkDerivation rec {
-  name = "gstreamer-0.10.26";
+  name = "gstreamer-0.10.30";
   # TODO: Remove gtkdoc dependency on next upgrade
 
   src = fetchurl {
@@ -10,12 +10,16 @@ stdenv.mkDerivation rec {
       "${meta.homepage}/src/gstreamer/${name}.tar.bz2"
       "mirror://gentoo/distfiles/${name}.tar.bz2"
       ];
-    sha256 = "1gah0ggfavl5z2wmwmwgs3h3ppwk6q1a6k0klk7zj1ph5n2isbc6";
+    sha256 = "0ajkfkchwpk5zlcis19laqbv84mi61cn3cqbdbrpyy93whdk1vz8";
   };
 
-  buildInputs = [perl bison flex pkgconfig python which  gtkdoc ];
+  buildInputs = [perl bison flex pkgconfig python which ];
   propagatedBuildInputs = [glib libxml2];
 
+  patchPhase = ''
+    sed -i -e 's/^   /\t/' docs/gst/Makefile.in docs/libs/Makefile.in docs/plugins/Makefile.in
+  '';
+
   configureFlags = ''
     --enable-failing-tests --localstatedir=/var --disable-gtk-doc --disable-docbook
   '';
diff --git a/pkgs/development/libraries/libao/default.nix b/pkgs/development/libraries/libao/default.nix
index 856980f102535..ae70e775dd1a2 100644
--- a/pkgs/development/libraries/libao/default.nix
+++ b/pkgs/development/libraries/libao/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, pulseaudio
+{ stdenv, fetchurl, pkgconfig, pulseaudio, alsaLib
 , usePulseAudio }:
 
 stdenv.mkDerivation {
@@ -8,7 +8,8 @@ stdenv.mkDerivation {
     sha256 = "e52e05af6b10f42d2ee9845df1a581bf2b352060eabf7946aee0a600c3878954";
   };
 
-  buildInputs = [ pkgconfig ] ++ stdenv.lib.optional usePulseAudio pulseaudio;
+  buildInputs = [ pkgconfig alsaLib ] ++ (if usePulseAudio then [ pulseaudio ]
+    else [ alsaLib ]);
 
   meta = {
     longDescription = ''
diff --git a/pkgs/development/libraries/libgcrypt/default.nix b/pkgs/development/libraries/libgcrypt/default.nix
index 438cc212b54fe..038fbef69e587 100644
--- a/pkgs/development/libraries/libgcrypt/default.nix
+++ b/pkgs/development/libraries/libgcrypt/default.nix
@@ -1,11 +1,11 @@
 { fetchurl, stdenv, libgpgerror }:
 
 stdenv.mkDerivation rec {
-  name = "libgcrypt-1.4.5";
+  name = "libgcrypt-1.4.6";
 
   src = fetchurl {
     url = "mirror://gnupg/libgcrypt/${name}.tar.bz2";
-    sha256 = "0h4ypld775rm1g15v134pkq9wc6ixszn6766gqv7bpi4ady90vs9";
+    sha256 = "11bbpjlqwp0nh4q76wmsk6z1812anqrj28nh6d9mcyrmdgd30jry";
   };
 
   propagatedBuildInputs = [ libgpgerror ];
diff --git a/pkgs/development/libraries/libmad/001-mips_removal_h_constraint.patch b/pkgs/development/libraries/libmad/001-mips_removal_h_constraint.patch
new file mode 100644
index 0000000000000..1d8b385e0c575
--- /dev/null
+++ b/pkgs/development/libraries/libmad/001-mips_removal_h_constraint.patch
@@ -0,0 +1,73 @@
+Taken from openwrt:
+https://dev.openwrt.org/browser/packages/libs/libmad/patches/001-mips_removal_h_constraint.patch?rev=18548
+
+diff -ur libmad-0.15.1b-orig/fixed.h libmad-0.15.1b/fixed.h
+--- libmad-0.15.1b-orig/fixed.h	2004-02-17 12:32:03.000000000 +1030
++++ libmad-0.15.1b/fixed.h	2009-08-05 10:46:30.000000000 +0930
+@@ -299,6 +299,23 @@
+ 
+ # elif defined(FPM_MIPS)
+ 
++/* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */
++#if defined (__GNUC__) && defined (__GNUC_MINOR__)
++#define __GNUC_PREREQ(maj, min) \
++	((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
++#else
++#define __GNUC_PREREQ(maj, min)  0
++#endif
++
++#if __GNUC_PREREQ(4,4)
++  typedef unsigned int u64_di_t __attribute__ ((mode (DI)));
++# define MAD_F_MLX(hi, lo, x, y) \
++   do { \
++      u64_di_t __ll = (u64_di_t) (x) * (y); \
++      hi = __ll >> 32; \
++      lo = __ll; \
++   } while (0) 
++#else
+ /*
+  * This MIPS version is fast and accurate; the disposition of the least
+  * significant bit depends on OPT_ACCURACY via mad_f_scale64().
+@@ -328,6 +345,7 @@
+ 	 : "%r" ((x) >> 12), "r" ((y) >> 16))
+ #  define MAD_F_MLZ(hi, lo)  ((mad_fixed_t) (lo))
+ # endif
++#endif /* __GNU_PREREQ(4,4) */
+ 
+ # if defined(OPT_SPEED)
+ #  define mad_f_scale64(hi, lo)  \
+diff -ur libmad-0.15.1b-orig/mad.h libmad-0.15.1b/mad.h
+--- libmad-0.15.1b-orig/mad.h	2004-02-17 13:25:44.000000000 +1030
++++ libmad-0.15.1b/mad.h	2009-08-05 10:42:40.000000000 +0930
+@@ -344,6 +344,23 @@
+ 
+ # elif defined(FPM_MIPS)
+ 
++/* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */
++#if defined (__GNUC__) && defined (__GNUC_MINOR__)
++#define __GNUC_PREREQ(maj, min) \
++	((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
++#else
++#define __GNUC_PREREQ(maj, min)  0
++#endif
++
++#if __GNUC_PREREQ(4,4)
++  typedef unsigned int u64_di_t __attribute__ ((mode (DI)));
++# define MAD_F_MLX(hi, lo, x, y) \
++   do { \
++      u64_di_t __ll = (u64_di_t) (x) * (y); \
++      hi = __ll >> 32; \
++      lo = __ll; \
++   } while (0) 
++#else
+ /*
+  * This MIPS version is fast and accurate; the disposition of the least
+  * significant bit depends on OPT_ACCURACY via mad_f_scale64().
+@@ -373,6 +390,7 @@
+ 	 : "%r" ((x) >> 12), "r" ((y) >> 16))
+ #  define MAD_F_MLZ(hi, lo)  ((mad_fixed_t) (lo))
+ # endif
++#endif /* __GNU_PREREQ(4,4) */
+ 
+ # if defined(OPT_SPEED)
+ #  define mad_f_scale64(hi, lo)  \
diff --git a/pkgs/development/libraries/libmad/default.nix b/pkgs/development/libraries/libmad/default.nix
index 83070b92ac64a..178e65d2506f9 100644
--- a/pkgs/development/libraries/libmad/default.nix
+++ b/pkgs/development/libraries/libmad/default.nix
@@ -8,11 +8,13 @@ stdenv.mkDerivation {
     sha256 = "bbfac3ed6bfbc2823d3775ebb931087371e142bb0e9bb1bee51a76a6e0078690";
   };
 
-  patches = [ ./pkgconfig.patch ];
+  patches = [ ./001-mips_removal_h_constraint.patch ./pkgconfig.patch ];
+
+  buildNativeInputs = [ autoconf ];
 
   # The -fforce-mem flag has been removed in GCC 4.3.
   preConfigure = ''
-    ${autoconf}/bin/autoconf
+    autoconf
     substituteInPlace configure --replace "-fforce-mem" ""
   '';
 
diff --git a/pkgs/development/libraries/libvpx/default.nix b/pkgs/development/libraries/libvpx/default.nix
index 7cd2e4d639b25..e6c8149edc091 100644
--- a/pkgs/development/libraries/libvpx/default.nix
+++ b/pkgs/development/libraries/libvpx/default.nix
@@ -11,14 +11,25 @@ stdenv.mkDerivation rec {
   patchPhase = ''
     sed -e 's,/bin/bash,${bash}/bin/bash,' -i configure build/make/version.sh \
       examples/gen_example_code.sh
+    sed -e '/enable linux/d' -i configure
   '';
 
-  configurePhase = ''
+  configureScript = "../configure";
+
+  preConfigure = ''
     mkdir -p build
     cd build
-    ../configure --disable-install-srcs --disable-examples --enable-vp8 --enable-runtime-cpu-detect --enable-shared --enable-pic
   '';
 
+  configureFlags = [
+    "--disable-install-srcs"
+    "--disable-examples"
+    "--enable-vp8"
+    "--enable-runtime-cpu-detect"
+    "--enable-shared"
+    "--enable-pic"
+  ];
+
   installPhase = ''
     make quiet=false DIST_DIR=$out install
   '';
diff --git a/pkgs/development/libraries/libxcrypt/default.nix b/pkgs/development/libraries/libxcrypt/default.nix
index 1ae5d3054f486..aea9e53eef6e5 100644
--- a/pkgs/development/libraries/libxcrypt/default.nix
+++ b/pkgs/development/libraries/libxcrypt/default.nix
@@ -1,7 +1,8 @@
 {stdenv, fetchurl}:
 
-# I could not build it in armv5tel-linux
+# I could not build it in armv5tel-linux or the fuloon2f
 assert stdenv.system != "armv5tel-linux";
+assert stdenv.system != "mips64-linux";
    
 stdenv.mkDerivation {
   name = "libxcrypt-3.0.2";
diff --git a/pkgs/development/libraries/mesa/default.nix b/pkgs/development/libraries/mesa/default.nix
index d878135923d8e..9b449be13359f 100644
--- a/pkgs/development/libraries/mesa/default.nix
+++ b/pkgs/development/libraries/mesa/default.nix
@@ -14,6 +14,8 @@ stdenv.mkDerivation {
 
   configureFlags =
     "--disable-gallium"
+    + (if stdenv.system == "mips64-linux" then
+      " --with-dri-drivers=swrast --with-driver=dri" else "")
     + (if stdenv.isDarwin then " --disable-egl" else "");
 
   buildInputs =
diff --git a/pkgs/development/libraries/mpc/default.nix b/pkgs/development/libraries/mpc/default.nix
index e5ae5b76323b7..c66c99cc576ed 100644
--- a/pkgs/development/libraries/mpc/default.nix
+++ b/pkgs/development/libraries/mpc/default.nix
@@ -1,11 +1,11 @@
 { fetchurl, stdenv, gmp, mpfr }:
 
 stdenv.mkDerivation rec {
-  name = "mpc-0.8.1";
+  name = "mpc-0.8.2";
 
   src = fetchurl {
     url = "http://www.multiprecision.org/mpc/download/${name}.tar.gz";
-    sha256 = "1r73zqw8lnf0bkfsxn0znbwbfyacg94pd0l4aaixh7r5awvn0r76";
+    sha256 = "1iw0ag28l5r88k7kpn6i89rqn3yhk2irqzk0d1mlb1la3paghydf";
   };
 
   buildInputs = [ gmp mpfr ];
diff --git a/pkgs/development/libraries/mpfr/default.nix b/pkgs/development/libraries/mpfr/default.nix
index 1bfd144820037..51d33f9593c7b 100644
--- a/pkgs/development/libraries/mpfr/default.nix
+++ b/pkgs/development/libraries/mpfr/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl, gmp}:
 
 stdenv.mkDerivation rec {
-  name = "mpfr-2.4.2";
+  name = "mpfr-3.0.0";
 
   src = fetchurl {
     url = "mirror://gnu/mpfr/${name}.tar.bz2";
-    sha256 = "1fpjphja2ridy1wfc53mcbavj4axl28ibvnawj1217flm045mry7";
+    sha256 = "07w24h8by7n319p2vwwa1xdcg7qzkd1aqm84lfcbfv2kaff5yklg";
   };
 
   buildInputs = [ gmp ];
@@ -31,5 +31,8 @@ stdenv.mkDerivation rec {
     '';
 
     license = "LGPLv2+";
+
+    maintainers = [ stdenv.lib.maintainers.ludo ];
+    platforms = stdenv.lib.platforms.all;
   };
 }
diff --git a/pkgs/development/libraries/openssl/1.x.nix b/pkgs/development/libraries/openssl/1.x.nix
new file mode 100644
index 0000000000000..eae32de30e488
--- /dev/null
+++ b/pkgs/development/libraries/openssl/1.x.nix
@@ -0,0 +1,45 @@
+{ stdenv, fetchurl, perl }:
+
+let
+  opensslCrossSystem = stdenv.lib.attrByPath [ "openssl" "system" ]
+    (throw "openssl needs its platform name cross building" null)
+    stdenv.cross;
+in
+
+stdenv.mkDerivation (rec {
+  name = "openssl-1.0.0";
+
+  src = fetchurl {
+    url = "http://www.openssl.org/source/${name}.tar.gz";
+    sha1 = "3f800ea9fa3da1c0f576d689be7dca3d55a4cb62";
+  };
+
+  buildNativeInputs = [ perl ];
+
+  configureScript = "./config";
+
+  configureFlags="--libdir=lib shared";
+
+  crossAttrs = {
+    preConfigure=''
+      export cross=$crossSystem-
+    '';
+    configureFlags="--libdir=lib ${opensslCrossSystem} shared";
+    buildPhase = ''
+      make CC=$crossConfig-gcc \
+        AR="$crossConfig-ar r" \
+        RANLIB=$crossConfig-ranlib
+    '';
+  };
+
+  meta = {
+    homepage = http://www.openssl.org/;
+    description = "A cryptographic library that implements the SSL and TLS protocols";
+  };
+}
+//
+(if stdenv.isDarwin then {
+  patches = ./darwin-arch.patch;
+}
+else { })
+)
diff --git a/pkgs/development/libraries/openssl/darwin-arch-1.patch b/pkgs/development/libraries/openssl/darwin-arch-1.patch
new file mode 100644
index 0000000000000..ad8e86c6791ea
--- /dev/null
+++ b/pkgs/development/libraries/openssl/darwin-arch-1.patch
@@ -0,0 +1,16 @@
+The patch is specific to nix: MacOS gcc supports -arch.
+--- a/Configure
++++ b/Configure
+@@ -549,9 +549,9 @@ my %table=(
+ "rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown):MACOSX_RHAPSODY::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}::",
+ "darwin-ppc-cc","cc:-arch ppc -O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+ "darwin64-ppc-cc","cc:-arch ppc64 -O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc64_asm}:osx64:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+-"darwin-i386-cc","cc:-arch i386 -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+-"debug-darwin-i386-cc","cc:-arch i386 -g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+-"darwin64-x86_64-cc","cc:-arch x86_64 -O3 -DL_ENDIAN -DMD32_REG_T=int -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
++"darwin-i386-cc","cc:-O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
++"debug-darwin-i386-cc","cc:-g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
++"darwin64-x86_64-cc","cc:-O3 -DL_ENDIAN -DMD32_REG_T=int -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+ "debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+
+ ##### A/UX
diff --git a/pkgs/development/libraries/openssl/darwin-arch.patch b/pkgs/development/libraries/openssl/darwin-arch.patch
index ad8e86c6791ea..f17a40395d626 100644
--- a/pkgs/development/libraries/openssl/darwin-arch.patch
+++ b/pkgs/development/libraries/openssl/darwin-arch.patch
@@ -1,16 +1,30 @@
-The patch is specific to nix: MacOS gcc supports -arch.
---- a/Configure
-+++ b/Configure
-@@ -549,9 +549,9 @@ my %table=(
- "rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown):MACOSX_RHAPSODY::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}::",
- "darwin-ppc-cc","cc:-arch ppc -O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
- "darwin64-ppc-cc","cc:-arch ppc64 -O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc64_asm}:osx64:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
--"darwin-i386-cc","cc:-arch i386 -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
--"debug-darwin-i386-cc","cc:-arch i386 -g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
--"darwin64-x86_64-cc","cc:-arch x86_64 -O3 -DL_ENDIAN -DMD32_REG_T=int -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
-+"darwin-i386-cc","cc:-O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
-+"debug-darwin-i386-cc","cc:-g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
-+"darwin64-x86_64-cc","cc:-O3 -DL_ENDIAN -DMD32_REG_T=int -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
- "debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+Removed -arch flags for darwin as they are not supported by gcc-darwin.
 
- ##### A/UX
+diff -rc openssl-0.9.8n/Configure openssl-0.9.8n-new/Configure
+*** openssl-0.9.8n/Configure	Mon Nov  9 15:14:26 2009
+--- openssl-0.9.8n-new/Configure	Thu Apr 29 10:16:15 2010
+***************
+*** 523,533 ****
+  
+  ##### MacOS X (a.k.a. Rhapsody or Darwin) setup
+  "rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown):MACOSX_RHAPSODY::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}::",
+! "darwin-ppc-cc","cc:-arch ppc -O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::osx_ppc32.o::::::::::dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+! "darwin64-ppc-cc","cc:-arch ppc64 -O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::osx_ppc64.o::::::::::dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+! "darwin-i386-cc","cc:-arch i386 -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+! "debug-darwin-i386-cc","cc:-arch i386 -g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+! "darwin64-x86_64-cc","cc:-arch x86_64 -O3 -fomit-frame-pointer -DL_ENDIAN -DMD32_REG_T=int -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+  "debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::osx_ppc32.o::::::::::dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+  
+  ##### A/UX
+--- 523,533 ----
+  
+  ##### MacOS X (a.k.a. Rhapsody or Darwin) setup
+  "rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown):MACOSX_RHAPSODY::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}::",
+! "darwin-ppc-cc","cc:-O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::osx_ppc32.o::::::::::dlfcn:darwin-shared:-fPIC -fno-common: -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+! "darwin64-ppc-cc","cc:-O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::osx_ppc64.o::::::::::dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+! "darwin-i386-cc","cc:-O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+! "debug-darwin-i386-cc","cc:-g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+! "darwin64-x86_64-cc","cc:-O3 -fomit-frame-pointer -DL_ENDIAN -DMD32_REG_T=int -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+  "debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::osx_ppc32.o::::::::::dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+  
+  ##### A/UX
diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix
index e483af7206e52..6b1efd7bc03da 100644
--- a/pkgs/development/libraries/openssl/default.nix
+++ b/pkgs/development/libraries/openssl/default.nix
@@ -30,6 +30,15 @@ stdenv.mkDerivation rec {
       # It's configure does not like --build or --host
       export configureFlags="--libdir=lib --cross-compile-prefix=${stdenv.cross.config}- shared ${opensslCrossSystem}"
     '';
+
+    postInstall = ''
+      # Openssl installs readonly files, which otherwise we can't strip.
+      # This could at some stdenv hash change be put out of crossAttrs, too
+      chmod -R +w $out
+
+      # Remove references to perl, to avoid depending on it at runtime
+      rm $out/bin/c_rehash $out/ssl/misc/CA.pl $out/ssl/misc/tsget
+    '';
     configureScript = "./Configure";
   };
 
diff --git a/pkgs/development/libraries/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix
index 3d3385c83f83e..f139bce100db8 100644
--- a/pkgs/development/libraries/pcre/default.nix
+++ b/pkgs/development/libraries/pcre/default.nix
@@ -1,13 +1,13 @@
 {stdenv, fetchurl, unicodeSupport ? false, cplusplusSupport ? true}:
 
 stdenv.mkDerivation {
-  name = "pcre-7.8";
-  
+  name = "pcre-8.02";
+
   src = fetchurl {
-    url = mirror://sourceforge/pcre/pcre-7.8.tar.bz2;
-    sha256 = "1zsqk352mx2zklf9bgpg9d88ckfdssbbbiyslhrycfckw8m3qpvr";
+    url = mirror://sourceforge/pcre/pcre-8.02.tar.bz2;
+    sha256 = "1gafmkmkbpdqjbdl85q2z5774gw4gfqjf238icz7gqf3v4v90xd4";
   };
-  
+
   configureFlags = ''
     ${if unicodeSupport then "--enable-unicode-properties" else ""}
     ${if !cplusplusSupport then "--disable-cpp" else ""}
diff --git a/pkgs/development/libraries/ppl/default.nix b/pkgs/development/libraries/ppl/default.nix
index ed4cc7f24978a..677d578e2425e 100644
--- a/pkgs/development/libraries/ppl/default.nix
+++ b/pkgs/development/libraries/ppl/default.nix
@@ -1,17 +1,23 @@
-{ fetchurl, stdenv, gmpxx, perl, gnum4 }:
+{ fetchurl, stdenv, gmpxx, perl, gnum4, static ? false }:
 
-let version = "0.10.2"; in
+let
+  version = "0.10.2";
+  staticFlags = if static then " --enable-static --disable-shared" else "";
+in
   stdenv.mkDerivation rec {
     name = "ppl-${version}";
 
     src = fetchurl {
-      url = "ftp://ftp.cs.unipr.it/pub/ppl/releases/${version}/${name}.tar.bz2";
-      sha256 = "0xz2f3lny4l9ji1ilg6pxv34sh4cbh535cnm68smynzp01wgnh7y";
+      url = "mirror://gcc/infrastructure/ppl-${version}.tar.gz";
+      sha256 = "0lly44sac4jd72klnhhil3wha15vak76r6gy88sh0zjsaww9hf6h";
     };
 
-    buildInputs = [ perl gnum4 ];
+    buildNativeInputs = [ perl gnum4 ];
     propagatedBuildInputs = [ gmpxx ];
 
+    dontDisableStatic = if static then true else false;
+    configureFlags = staticFlags;
+
     # Beware!  It took ~6 hours to compile PPL and run its tests on a 1.2 GHz
     # x86_64 box.  Nevertheless, being a dependency of GCC, it probably ought
     # to be tested.
diff --git a/pkgs/development/libraries/x264/default.nix b/pkgs/development/libraries/x264/default.nix
index 4bd1c97fb6cd9..9e5676e20123f 100644
--- a/pkgs/development/libraries/x264/default.nix
+++ b/pkgs/development/libraries/x264/default.nix
@@ -13,7 +13,8 @@ stdenv.mkDerivation rec {
     sed -i s,/bin/bash,${stdenv.shell}, configure version.sh
   '';
 
-  configureFlags = [ "--enable-shared" ];
+  configureFlags = [ "--enable-shared" ]
+    ++ stdenv.lib.optional (!stdenv.isi686) "--enable-pic";
 
   buildInputs = [ yasm ];
 
diff --git a/pkgs/development/tools/analysis/valgrind/default.nix b/pkgs/development/tools/analysis/valgrind/default.nix
index fdf2bf1777f2e..fa2b7b502a541 100644
--- a/pkgs/development/tools/analysis/valgrind/default.nix
+++ b/pkgs/development/tools/analysis/valgrind/default.nix
@@ -8,8 +8,8 @@ stdenv.mkDerivation rec {
     sha256 = "105s4y6h5rsfvml1dfhsjvqgsxvnclbnxbpgk8b4ghpbpcr52fkl";
   };
 
-  # Make Valgrind compile with Glibc 2.11.
-  patches = [ ./glibc-2.11.patch ];
+  # Make Valgrind compile with Glibc 2.12.
+  patches = [ ./glibc-2.12.patch ./stat_h.patch ];
   patchFlags = "-p0";
   preConfigure = "autoreconf";
 
diff --git a/pkgs/development/tools/analysis/valgrind/glibc-2.11.patch b/pkgs/development/tools/analysis/valgrind/glibc-2.12.patch
index e2ce53217c9e4..bdee0778732d9 100644
--- a/pkgs/development/tools/analysis/valgrind/glibc-2.11.patch
+++ b/pkgs/development/tools/analysis/valgrind/glibc-2.12.patch
@@ -1,3 +1,5 @@
+I changed the patch for 2.11 so it allows 2.12 too.
+
 r10941 from svn://svn.valgrind.org/valgrind/trunk
 
 ------------------------------------------------------------------------
@@ -11,7 +13,7 @@ Index: configure.in
 ===================================================================
 --- configure.in	(revision 10940)
 +++ configure.in	(revision 10941)
-@@ -656,6 +656,16 @@
+@@ -656,6 +656,26 @@
  ],
  GLIBC_VERSION="2.10")
  
@@ -25,10 +27,20 @@ Index: configure.in
 +],
 +GLIBC_VERSION="2.11")
 +
++AC_EGREP_CPP([GLIBC_212], [
++#include <features.h>
++#ifdef __GNU_LIBRARY__
++ #if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 12)
++  GLIBC_212
++ #endif
++#endif
++],
++GLIBC_VERSION="2.12")
++
  AC_EGREP_CPP([AIX5_LIBC], [
  #include <standards.h>
  #if defined(_AIXVERSION_510) || defined(_AIXVERSION_520) || defined(_AIXVERSION_530)
-@@ -742,6 +752,13 @@
+@@ -742,6 +752,20 @@
  	DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
  	DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
  	;;
@@ -39,6 +51,13 @@ Index: configure.in
 +	DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
 +	DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
 +	;;
++     2.12)
++	AC_MSG_RESULT(2.12 family)
++	AC_DEFINE([GLIBC_2_12], 1, [Define to 1 if you're using glibc 2.12.x])
++	DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
++	DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
++	DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
++	;;
       aix5)
  	AC_MSG_RESULT(AIX 5.1 or 5.2 or 5.3)
  	AC_DEFINE([AIX5_LIBC], 1, [Define to 1 if you're using AIX 5.1 or 5.2 or 5.3])
@@ -47,7 +66,7 @@ Index: configure.in
       *)
  	AC_MSG_RESULT(unsupported version)
 -	AC_MSG_ERROR([Valgrind requires glibc version 2.2 - 2.10])
-+	AC_MSG_ERROR([Valgrind requires glibc version 2.2 - 2.11])
++	AC_MSG_ERROR([Valgrind requires glibc version 2.2 - 2.12])
  	AC_MSG_ERROR([or AIX 5.1 or 5.2 or 5.3 GLIBC_VERSION])
  	AC_MSG_ERROR([or Darwin libc])
  	;;
diff --git a/pkgs/development/tools/analysis/valgrind/stat_h.patch b/pkgs/development/tools/analysis/valgrind/stat_h.patch
new file mode 100644
index 0000000000000..c191cf456984d
--- /dev/null
+++ b/pkgs/development/tools/analysis/valgrind/stat_h.patch
@@ -0,0 +1,53 @@
+Taken from gentoo:
+http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-util/valgrind/files/valgrind-3.5.0-stat_h.patch?view=markup
+
+http://cvs.fedoraproject.org/viewvc/rpms/valgrind/devel/valgrind-3.5.0-stat_h.patch?view=log
+
+--- include/vki/vki-amd64-linux.h
++++ include/vki/vki-amd64-linux.h
+@@ -310,6 +310,9 @@ struct vki_stat {
+ 	long		st_blksize;
+ 	long		st_blocks;	/* Number 512-byte blocks allocated. */
+ 
++#undef st_atime
++#undef st_mtime
++#undef st_ctime
+ 	unsigned long	st_atime;
+ 	unsigned long 	st_atime_nsec; 
+ 	unsigned long	st_mtime;
+--- include/vki/vki-x86-linux.h
++++ include/vki/vki-x86-linux.h
+@@ -348,6 +348,9 @@ struct vki_stat {
+ 	unsigned long  st_size;
+ 	unsigned long  st_blksize;
+ 	unsigned long  st_blocks;
++#undef st_atime
++#undef st_mtime
++#undef st_ctime
+ 	unsigned long  st_atime;
+ 	unsigned long  st_atime_nsec;
+ 	unsigned long  st_mtime;
+--- include/vki/vki-ppc32-linux.h
++++ include/vki/vki-ppc32-linux.h
+@@ -392,6 +392,9 @@ struct vki_stat {
+    long			st_size;
+    unsigned long	st_blksize;
+    unsigned long	st_blocks;
++#undef st_atime
++#undef st_mtime
++#undef st_ctime
+    unsigned long	st_atime;
+    unsigned long	st_atime_nsec;
+    unsigned long	st_mtime;
+--- include/vki/vki-ppc64-linux.h
++++ include/vki/vki-ppc64-linux.h
+@@ -428,6 +428,9 @@ struct vki_stat {
+   long            st_size;
+   unsigned long   st_blksize;
+   unsigned long   st_blocks;
++#undef st_atime
++#undef st_mtime
++#undef st_ctime
+   unsigned long   st_atime;
+   unsigned long   st_atime_nsec;
+   unsigned long   st_mtime;
diff --git a/pkgs/development/tools/build-managers/gnumake/default.nix b/pkgs/development/tools/build-managers/gnumake/default.nix
index 09ac6b9142e2b..12ac0275bc01e 100644
--- a/pkgs/development/tools/build-managers/gnumake/default.nix
+++ b/pkgs/development/tools/build-managers/gnumake/default.nix
@@ -1,19 +1,22 @@
 {stdenv, fetchurl}:
 
+let version = "3.82"; in
 stdenv.mkDerivation {
-  name = "gnumake-3.81";
-  
+  name = "gnumake-${version}";
+
   src = fetchurl {
-    url = mirror://gnu/make/make-3.81.tar.bz2;
-    md5 = "354853e0b2da90c527e35aabb8d6f1e6";
+    url = "mirror://gnu/make/make-${version}.tar.bz2";
+    sha256 = "0ri98385hsd7li6rh4l5afcq92v8l2lgiaz85wgcfh4w2wzsghg2";
   };
-  
+
+  doCheck = true;
+
   patches =
     [
       # Provide nested log output for subsequent pretty-printing by
       # nix-log2xml.
       ./log.patch
-      
+
       # Purity: don't look for library dependencies (of the form
       # `-lfoo') in /lib and /usr/lib.  It's a stupid feature anyway.
       # Likewise, when searching for included Makefiles, don't look in
@@ -22,8 +25,22 @@ stdenv.mkDerivation {
     ];
 
   meta = {
-    description = "A program for automatically building non-source files from sources";
+    description = "GNU Make, a program controlling the generation of non-source files from sources";
+
+    longDescription =
+      '' Make is a tool which controls the generation of executables and
+         other non-source files of a program from the program's source files.
+
+         Make gets its knowledge of how to build your program from a file
+         called the makefile, which lists each of the non-source files and
+         how to compute it from other files. When you write a program, you
+         should write a makefile for it, so that it is possible to use Make
+         to build and install the program.
+      '';
+
     homepage = http://www.gnu.org/software/make/;
-    license = "GPL";
+
+    license = "GPLv3+";
+    maintainers = [ stdenv.lib.maintainers.ludo ];
   };
 }
diff --git a/pkgs/development/tools/build-managers/gnumake/log.patch b/pkgs/development/tools/build-managers/gnumake/log.patch
index 0f3ed6d7299bf..ca0d6340790b2 100644
--- a/pkgs/development/tools/build-managers/gnumake/log.patch
+++ b/pkgs/development/tools/build-managers/gnumake/log.patch
@@ -93,9 +93,9 @@ diff -rc make-3.81-orig/make.h make-3.81/make.h
 ***************
 *** 609,611 ****
 --- 609,614 ----
-  #define ENULLLOOP(_v,_c)   do{ errno = 0; \
-                                 while (((_v)=_c)==0 && errno==EINTR); }while(0)
   
+  #define ENULLLOOP(_v,_c)   do { errno = 0; (_v) = _c; } \
+                             while((_v)==0 && errno==EINTR)
 + extern int enable_nested_output;
 + extern int stdout_nesting_level;
 + extern int stderr_nesting_level;
diff --git a/pkgs/development/tools/misc/binutils/as-pr10856.patch b/pkgs/development/tools/misc/binutils/as-pr10856.patch
deleted file mode 100644
index 695d3e3567065..0000000000000
--- a/pkgs/development/tools/misc/binutils/as-pr10856.patch
+++ /dev/null
@@ -1,83 +0,0 @@
-Fix a regression in GNU as:
-http://sourceware.org/bugzilla/show_bug.cgi?id=10856 .
-
-The bug appears to be responsible for invalid code generated for
-Crypto++:
-http://groups.google.com/group/cryptopp-users/browse_thread/thread/7ce734e479586640/29c6649b7c7adee2?#29c6649b7c7adee2 .
-
-diff -u -r1.77.2.1 -r1.77.2.2
---- a/gas/expr.c	2009/09/11 15:28:43	1.77.2.1
-+++ b/gas/expr.c	2009/10/28 08:23:48	1.77.2.2
-@@ -1997,6 +1997,7 @@
-   /* Help out with CSE.  */
-   valueT final_val = expressionP->X_add_number;
-   symbolS *add_symbol = expressionP->X_add_symbol;
-+  symbolS *orig_add_symbol = add_symbol;
-   symbolS *op_symbol = expressionP->X_op_symbol;
-   operatorT op = expressionP->X_op;
-   valueT left, right;
-@@ -2078,6 +2079,7 @@
- 	      left = right;
- 	      seg_left = seg_right;
- 	      add_symbol = op_symbol;
-+	      orig_add_symbol = expressionP->X_op_symbol;
- 	      op = O_symbol;
- 	      break;
- 	    }
-@@ -2122,18 +2124,19 @@
- 	    {
- 	      if (op == O_bit_exclusive_or || op == O_bit_inclusive_or)
- 		{
--		  if (seg_right != absolute_section || right != 0)
-+		  if (!(seg_right == absolute_section && right == 0))
- 		    {
- 		      seg_left = seg_right;
- 		      left = right;
- 		      add_symbol = op_symbol;
-+		      orig_add_symbol = expressionP->X_op_symbol;
- 		    }
- 		  op = O_symbol;
- 		  break;
- 		}
- 	      else if (op == O_left_shift || op == O_right_shift)
- 		{
--		  if (seg_left != absolute_section || left != 0)
-+		  if (!(seg_left == absolute_section && left == 0))
- 		    {
- 		      op = O_symbol;
- 		      break;
-@@ -2149,6 +2152,7 @@
- 	      seg_left = seg_right;
- 	      left = right;
- 	      add_symbol = op_symbol;
-+	      orig_add_symbol = expressionP->X_op_symbol;
- 	      op = O_symbol;
- 	      break;
- 	    }
-@@ -2158,11 +2162,11 @@
- 	      op = O_symbol;
- 	      break;
- 	    }
--	  else if (left != right
--		   || ((seg_left != reg_section || seg_right != reg_section)
--		       && (seg_left != undefined_section
--			   || seg_right != undefined_section
--			   || add_symbol != op_symbol)))
-+	  else if (!(left == right
-+		     && ((seg_left == reg_section && seg_right == reg_section)
-+			 || (seg_left == undefined_section
-+			     && seg_right == undefined_section
-+			     && add_symbol == op_symbol))))
- 	    return 0;
- 	  else if (op == O_bit_and || op == O_bit_inclusive_or)
- 	    {
-@@ -2233,7 +2237,8 @@
- 	op = O_constant;
-       else if (seg_left == reg_section && final_val == 0)
- 	op = O_register;
--      else if (add_symbol != expressionP->X_add_symbol)
-+      else if (seg_left == undefined_section
-+	       && add_symbol != orig_add_symbol)
- 	final_val += left;
-       expressionP->X_add_symbol = add_symbol;
-     }
diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix
index 1bb110e35fd32..3e3dedd1e8339 100644
--- a/pkgs/development/tools/misc/binutils/default.nix
+++ b/pkgs/development/tools/misc/binutils/default.nix
@@ -1,14 +1,14 @@
 {stdenv, fetchurl, noSysDirs, cross ? null}:
 
 let
-    basename = "binutils-2.20";
+    basename = "binutils-2.20.1";
 in
 stdenv.mkDerivation rec {
   name = basename + stdenv.lib.optionalString (cross != null) "-${cross.config}";
 
   src = fetchurl {
     url = "mirror://gnu/binutils/${basename}.tar.bz2";
-    sha256 = "1c3m789p5rwmmnck5ms4zcnc40axss3gxzivz571al1vmbq0kpz1";
+    sha256 = "1y7nwsprhr4hvx9ps2l0l0ivb6k41rcrx1invmzqxs475mr892r2";
   };
 
   patches = [
@@ -16,8 +16,6 @@ stdenv.mkDerivation rec {
     # RUNPATH instead of RPATH on binaries.  This is important because
     # RUNPATH can be overriden using LD_LIBRARY_PATH at runtime.
     ./new-dtags.patch
-
-    ./as-pr10856.patch
   ];
 
   inherit noSysDirs;
diff --git a/pkgs/development/tools/misc/binutils/snapshot.nix b/pkgs/development/tools/misc/binutils/snapshot.nix
new file mode 100644
index 0000000000000..79f01cad4ef32
--- /dev/null
+++ b/pkgs/development/tools/misc/binutils/snapshot.nix
@@ -0,0 +1,59 @@
+{stdenv, fetchurl, noSysDirs, cross ? null}:
+
+let
+    basename = "binutils-2.20.51";
+in
+stdenv.mkDerivation rec {
+  name = basename + stdenv.lib.optionalString (cross != null) "-${cross.config}";
+
+  src = fetchurl {
+    url = http://nixos.org/tarballs/binutils-2.20.51-pre-20100901.tar.bz2;
+    sha256 = "1872fdnbnq5z5svq7mvc0vyyad8pknwvx2glxq1bbk0xv7arp72y";
+  };
+
+  patches = [
+    # Turn on --enable-new-dtags by default to make the linker set
+    # RUNPATH instead of RPATH on binaries.  This is important because
+    # RUNPATH can be overriden using LD_LIBRARY_PATH at runtime.
+    ./new-dtags.patch
+  ];
+
+  inherit noSysDirs;
+
+  preConfigure = ''
+    # Clear the default library search path.
+    if test "$noSysDirs" = "1"; then
+	echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt
+    fi
+
+    # Use symlinks instead of hard links to save space ("strip" in the
+    # fixup phase strips each hard link separately).
+    for i in binutils/Makefile.in gas/Makefile.in ld/Makefile.in; do
+        substituteInPlace $i --replace 'ln ' 'ln -s '
+    done
+  '';
+
+  configureFlags = "--disable-werror" # needed for dietlibc build
+      + stdenv.lib.optionalString (stdenv.system == "mips64-linux")
+        " --enable-fix-loongson2f-nop"
+      + stdenv.lib.optionalString (cross != null) " --target=${cross.config}";
+
+  meta = {
+    description = "GNU Binutils, tools for manipulating binaries (linker, assembler, etc.)";
+
+    longDescription = ''
+      The GNU Binutils are a collection of binary tools.  The main
+      ones are `ld' (the GNU linker) and `as' (the GNU assembler).
+      They also include the BFD (Binary File Descriptor) library,
+      `gprof', `nm', `strip', etc.
+    '';
+
+    homepage = http://www.gnu.org/software/binutils/;
+
+    license = "GPLv3+";
+
+    /* Give binutils a lower priority than gcc-wrapper to prevent a
+       collision due to the ld/as wrappers/symlinks in the latter. */
+    priority = "10";
+  };
+}
diff --git a/pkgs/development/tools/misc/cscope/default.nix b/pkgs/development/tools/misc/cscope/default.nix
index 1c6d1dacc7fd6..2a9e77bd05bca 100644
--- a/pkgs/development/tools/misc/cscope/default.nix
+++ b/pkgs/development/tools/misc/cscope/default.nix
@@ -17,7 +17,8 @@ stdenv.mkDerivation rec {
 
   configureFlags = "--with-ncurses=${ncurses}";
 
-  buildInputs = [ ncurses pkgconfig emacs ];
+  buildInputs = [ ncurses emacs ];
+  buildNativeInputs = [ pkgconfig ];
 
   postInstall = ''
     # Install Emacs mode.
@@ -31,6 +32,11 @@ stdenv.mkDerivation rec {
     cp xcscope.el{,c} "$out/share/emacs/site-lisp"
   '';
 
+  crossAttrs = {
+    postInstall = "";
+    propagatedBuildInputs = [ ncurses.hostDrv ];
+  };
+
   meta = {
     description = "Cscope, a developer's tool for browsing source code";
 
diff --git a/pkgs/development/tools/misc/gnum4/default.nix b/pkgs/development/tools/misc/gnum4/default.nix
index 0c73ba1f738d5..d064c7578e065 100644
--- a/pkgs/development/tools/misc/gnum4/default.nix
+++ b/pkgs/development/tools/misc/gnum4/default.nix
@@ -1,15 +1,18 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation {
-  name = "gnum4-1.4.13";
+  name = "gnum4-1.4.14";
 
   src = fetchurl {
-    url = mirror://gnu/m4/m4-1.4.13.tar.bz2;
-    sha256 = "01pcrajrk2rqhxbrij3j07ywyxlq7ih43a8pzvhdlxhlwfazxipw";
+    url = mirror://gnu/m4/m4-1.4.14.tar.bz2;
+    sha256 = "1ljddxjqw1642b26qzk87fahkv9rsv2cn2ygn6b3ldan6alzz188";
   };
 
   doCheck = !stdenv.isDarwin;
 
+  # Upstream is aware of it; it may be in the next release.
+  patches = [ ./s_isdir.patch ];
+
   meta = {
     homepage = http://www.gnu.org/software/m4/;
     description = "GNU M4, a macro processor";
diff --git a/pkgs/development/tools/misc/gnum4/s_isdir.patch b/pkgs/development/tools/misc/gnum4/s_isdir.patch
new file mode 100644
index 0000000000000..a009a4ba44650
--- /dev/null
+++ b/pkgs/development/tools/misc/gnum4/s_isdir.patch
@@ -0,0 +1,14 @@
+Fails to build with glibc 2.12.1 without this patch.
+
+http://lists.gnu.org/archive/html/bug-m4/2010-05/msg00002.html
+
+--- a/src/path.c
++++ b/src/path.c
+@@ -22,6 +22,7 @@
+ /* Handling of path search of included files via the builtins "include"
+    and "sinclude".  */
+ 
+ #include "m4.h"
++#include "sys/stat.h"
+ 
+ struct includes
diff --git a/pkgs/development/tools/misc/libtool/libtool2.nix b/pkgs/development/tools/misc/libtool/libtool2.nix
index c89fe7e280c3c..42b518ae58e8f 100644
--- a/pkgs/development/tools/misc/libtool/libtool2.nix
+++ b/pkgs/development/tools/misc/libtool/libtool2.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, m4, perl, lzma }:
 
 stdenv.mkDerivation rec {
-  name = "libtool-2.2.6b";
+  name = "libtool-2.2.10";
 
   src = fetchurl {
     url = "mirror://gnu/libtool/${name}.tar.lzma";
-    sha256 = "1bmpp31sfjl3nzj8psvnsqrrv4gwnqzii8dxpxr6djz508yavsv6";
+    sha256 = "146lf1gas8gdpcjdn6ffad605n198ja0jqwxpixyglabczwpisba";
   };
 
   buildNativeInputs = [ lzma m4 perl ];
diff --git a/pkgs/development/tools/misc/patchelf/0.6.nix b/pkgs/development/tools/misc/patchelf/0.6.nix
index dfd0b077411fb..3774c44480dca 100644
--- a/pkgs/development/tools/misc/patchelf/0.6.nix
+++ b/pkgs/development/tools/misc/patchelf/0.6.nix
@@ -4,8 +4,8 @@ stdenv.mkDerivation rec {
   name = "patchelf-0.6pre22275";
   
   src = fetchurl {
-    url = "http://hydra.nixos.org/build/479721/download/3/patchelf-0.6pre22275.tar.gz";
-    sha256 = "ccce84285d145b300e5727b1562f4f334c53721fc7b388928c3fb5b9a90c7d80";
+    url = "http://hydra.nixos.org/build/504657/download/2/patchelf-0.6pre22813.tar.bz2";
+    sha256 = "1ml86wyl35ik3lixkcz2vlzvbcancj0dygwfh5ambjmazp2q19mh";
   };
 
   meta = {
diff --git a/pkgs/development/tools/misc/texinfo/default.nix b/pkgs/development/tools/misc/texinfo/default.nix
index 09fe6ed029c3c..111f2d1420080 100644
--- a/pkgs/development/tools/misc/texinfo/default.nix
+++ b/pkgs/development/tools/misc/texinfo/default.nix
@@ -8,16 +8,8 @@ stdenv.mkDerivation rec {
     sha256 = "1rf9ckpqwixj65bw469i634897xwlgkm5i9g2hv3avl6mv7b0a3d";
   };
 
-  buildInputs = [ ncurses lzma ];
-
-  # !!! This should be set as usual attributes - we set them as
-  # crossAttrs only not to change the usual stdenv hash
-  # (in the normal stdenv, these get mapped all to buildNativeInputs,
-  #  but unfortunately in the opposite order, thus getting a new hash)
-  crossAttrs = {
-    buildNativeInputs = [ lzma ];
-    buildInputs = [ ncurses ];
-  };
+  buildInputs = [ ncurses ];
+  buildNativeInputs = [ lzma ];
 
   # Disabled because we don't have zdiff in the stdenv bootstrap.
   #doCheck = true;
diff --git a/pkgs/games/prboom/default.nix b/pkgs/games/prboom/default.nix
new file mode 100644
index 0000000000000..f66e2295a22cc
--- /dev/null
+++ b/pkgs/games/prboom/default.nix
@@ -0,0 +1,20 @@
+{stdenv, fetchurl, SDL, SDL_mixer, SDL_net, mesa}:
+
+stdenv.mkDerivation {
+  name = "prboom-2.5.0";
+  src = fetchurl {
+    url = mirror://sourceforge/prboom/prboom-2.5.0.tar.gz;
+    sha256 = "1bjb04q8dk232956k30qlpq6q0hxb904yh1nflr87jcc1x3iqv12";
+  };
+
+  buildInputs = [ SDL SDL_mixer SDL_net mesa ];
+  crossAttrs = {
+    propagatedBuildInputs = [ SDL.hostDrv SDL_mixer.hostDrv SDL_net.hostDrv ];
+    configureFlags = "--disable-gl --disable-cpu-opt --without-x --disable-sdltest
+      ac_cv_type_uid_t=yes ac_cv_type_gid_t=yes";
+
+    postInstall = ''
+      mv $out/games/ $out/bin
+    '';
+  };
+}
diff --git a/pkgs/games/scummvm/default.nix b/pkgs/games/scummvm/default.nix
index d6912d5c3c0c8..ad03906888c03 100644
--- a/pkgs/games/scummvm/default.nix
+++ b/pkgs/games/scummvm/default.nix
@@ -10,6 +10,18 @@ stdenv.mkDerivation {
   
   buildInputs = [SDL zlib mpeg2dec];
 
+  crossAttrs = {
+    preConfigure = ''
+      # Remove the --build flag set by the gcc cross wrapper setup
+      # hook
+      export configureFlags="--host=${stdenv.cross.config}"
+    '';
+    postConfigure = ''
+      # They use 'install -s', that calls the native strip instead of the cross
+      sed -i 's/-c -s/-c/' ports.mk;
+    '';
+  };
+
   meta = {
     description = "Program to run certain classic graphical point-and-click adventure games (such as Monkey Island)";
     homepage = http://www.scummvm.org/;
diff --git a/pkgs/lib/misc.nix b/pkgs/lib/misc.nix
index 91a374947446c..7f04e7e1e581b 100644
--- a/pkgs/lib/misc.nix
+++ b/pkgs/lib/misc.nix
@@ -215,11 +215,15 @@ rec {
 
 
   innerClosePropagation = ready: list: if list == [] then ready else
-    innerClosePropagation 
-      (ready ++ [(head list)])
-      ((tail list) 
-         ++ (maybeAttrNullable "propagatedBuildInputs" [] (head list))
-         ++ (maybeAttrNullable "propagatedBuildNativeInputs" [] (head list)));
+    if ! isAttrs (head list) then
+      builtins.trace ("not an attrSet: ${lib.showVal (head list)}") 
+        innerClosePropagation ready (tail list)
+    else
+      innerClosePropagation 
+        (ready ++ [(head list)])
+        ((tail list) 
+           ++ (maybeAttrNullable "propagatedBuildInputs" [] (head list))
+           ++ (maybeAttrNullable "propagatedBuildNativeInputs" [] (head list)));
 
   closePropagation = list: (uniqList {inputList = (innerClosePropagation [] list);});
 
diff --git a/pkgs/lib/platforms.nix b/pkgs/lib/platforms.nix
index 635b195e1d640..e9ed1e226e794 100644
--- a/pkgs/lib/platforms.nix
+++ b/pkgs/lib/platforms.nix
@@ -2,7 +2,8 @@ let lists = import ./lists.nix; in
 
 rec {
   gnu = linux; /* ++ hurd ++ kfreebsd ++ ... */
-  linux = ["i686-linux" "x86_64-linux" "powerpc-linux" "armv5tel-linux" ];
+  linux = ["i686-linux" "x86_64-linux" "powerpc-linux" "armv5tel-linux"
+    "mips64-linux"];
   darwin = ["i686-darwin" "powerpc-darwin" "x86_64-darwin"];
   freebsd = ["i686-freebsd" "x86_64-freebsd" "powerpc-freebsd"];
   openbsd = ["i686-openbsd" "x86_64-openbsd"];
diff --git a/pkgs/misc/busybox/default.nix b/pkgs/misc/busybox/default.nix
index 1d190cf661d27..c40ff9b80759e 100644
--- a/pkgs/misc/busybox/default.nix
+++ b/pkgs/misc/busybox/default.nix
@@ -1,33 +1,73 @@
-{stdenv, fetchurl, enableStatic ? false}:
+{stdenv, fetchurl, enableStatic ? false, extraConfig ? ""}:
 
 let
-  basicConfigure = ''
-    make defconfig
-    sed -i 's,.*CONFIG_PREFIX.*,CONFIG_PREFIX="'$out'",' .config
-    sed -i 's,.*CONFIG_INSTALL_NO_USR.*,CONFIG_INSTALL_NO_USR=y,' .config
-  '' +
-    (if enableStatic then ''
-      sed -i 's,.*CONFIG_STATIC.*,CONFIG_STATIC=y,' .config
+  configParser = ''
+    function parseconfig {
+        set -x
+        while read LINE; do
+            NAME=`echo "$LINE" | cut -d \  -f 1`
+            OPTION=`echo "$LINE" | cut -d \  -f 2`
+
+            if test -z "$NAME"; then
+                continue
+            fi
+
+            if test "$NAME" == "CLEAR"; then
+                echo "parseconfig: CLEAR"
+                echo > .config
+            fi
+
+            echo "parseconfig: removing $NAME"
+            sed -i /^$NAME=/d .config
+
+            if test "$OPTION" != n; then
+                echo "parseconfig: setting $NAME=$OPTION"
+                echo "$NAME=$OPTION" >> .config
+            fi
+        done
+        set +x
+    }
+  '';
+
+  nixConfig = ''
+    CONFIG_PREFIX "$out"
+    CONFIG_INSTALL_NO_USR n
+  '';
+
+  staticConfig = (if enableStatic then ''
+      CONFIG_STATIC y
     '' else "");
 
 in
 
-stdenv.mkDerivation {
-  name = "busybox-1.16.0";
+stdenv.mkDerivation rec {
+  name = "busybox-1.17.1";
 
   src = fetchurl {
-    url = http://busybox.net/downloads/busybox-1.16.0.tar.bz2;
-    sha256 = "1n738zk01yi2sjrx2y36hpzxbslas8b91vzykcifr0p1j7ym0lim";
+    url = "http://busybox.net/downloads/${name}.tar.bz2";
+    sha256 = "0r6i76lad5w359pw93i9wrq2a1pxk8xw6xr4cq71n5by1n0pg4dz";
   };
 
-  configurePhase = basicConfigure;
+  patches = [ ./make-3.82.patch ];
+
+  configurePhase = ''
+    make defconfig
+    ${configParser}
+    cat << EOF | parseconfig
+    ${staticConfig}
+    ${extraConfig}
+    ${nixConfig}
+    $extraCrossConfig
+    EOF
+    make oldconfig
+  '';
 
   crossAttrs = {
-    configurePhase = basicConfigure + ''
-      sed -i 's,.*CONFIG_CROSS_COMPILER_PREFIX.*,CONFIG_CROSS_COMPILER_PREFIX="'$crossConfig-'",' .config
+    extraCrossConfig = ''
+      CONFIG_CROSS_COMPILER_PREFIX "${stdenv.cross.config}-"
     '' +
       (if (stdenv.cross.platform.kernelMajor == "2.4") then ''
-        sed -i 's,.*CONFIG_IONICE.*,CONFIG_IONICE=n,' .config
+        CONFIG_IONICE n
       '' else "");
   };
 }
diff --git a/pkgs/misc/busybox/make-3.82.patch b/pkgs/misc/busybox/make-3.82.patch
new file mode 100644
index 0000000000000..eb95ae3b833e1
--- /dev/null
+++ b/pkgs/misc/busybox/make-3.82.patch
@@ -0,0 +1,29 @@
+--- busybox/Makefile	2010-08-19 10:38:51.000000000 +0200
++++ busybox-make382/Makefile	2010-08-19 14:46:03.000000000 +0200
+@@ -433,7 +433,12 @@
+ -include $(srctree)/arch/$(ARCH)/Makefile
+ export KBUILD_DEFCONFIG
+ 
+-config %config: scripts_basic outputmakefile gen_build_files FORCE
++config: scripts_basic outputmakefile gen_build_files FORCE
++	$(Q)mkdir -p include
++	$(Q)$(MAKE) $(build)=scripts/kconfig $@
++	$(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
++
++%config: scripts_basic outputmakefile gen_build_files FORCE
+ 	$(Q)mkdir -p include
+ 	$(Q)$(MAKE) $(build)=scripts/kconfig $@
+ 	$(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
+@@ -1285,7 +1290,11 @@
+ 	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
+ 
+ # Modules
+-/ %/: prepare scripts FORCE
++%/: prepare scripts FORCE
++	$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
++	$(build)=$(build-dir)
++
++/: prepare scripts FORCE
+ 	$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
+ 	$(build)=$(build-dir)
+ %.ko: prepare scripts FORCE
diff --git a/pkgs/misc/uboot/nanonote.nix b/pkgs/misc/uboot/nanonote.nix
new file mode 100644
index 0000000000000..9e39501a7a34a
--- /dev/null
+++ b/pkgs/misc/uboot/nanonote.nix
@@ -0,0 +1,58 @@
+{stdenv, fetchurl, fetchgit}:
+
+# We should enable this check once we have the cross target system information
+# assert stdenv.system == "armv5tel-linux" || crossConfig == "armv5tel-linux";
+
+# All this file is made for the Marvell Sheevaplug
+   
+stdenv.mkDerivation {
+  name = "uboot-qb-2010.06";
+   
+  src = fetchurl {
+    url = "ftp://ftp.denx.de/pub/u-boot/u-boot-2010.06.tar.bz2";
+    sha256 = "1j0bl8x5i5m1pn62z450gbw30pbrj7sgs3fjp2l2giczv49cn33r";
+  };
+
+  srcPatches = fetchgit {
+    url = "git://projects.qi-hardware.com/openwrt-xburst.git";
+    rev = "3244d5ef9f93802f9b9b6f4405636424abf6fa83";
+    sha256 = "8ae25853028930b418fad90637e0e68f9888285ba3ad1f720be45f08823ee855";
+  };
+
+  patchPhase = ''
+    cp -R $srcPatches/package/uboot-xburst/files/* .
+    for a in $srcPatches/package/uboot-xburst/patches/*; do
+        patch -p1 < $a
+    done
+    chmod +w -R *
+  '';
+
+  # Remove the cross compiler prefix, and add reiserfs support
+  configurePhase = ''
+    make mrproper
+    make qi_lb60_config
+    sed -i /CROSS_COMPILE/d include/config.mk
+  '';
+
+  buildPhase = ''
+    # A variable named 'src' used to affect the build in some uboot...
+    unset src
+    if test -z "$crossConfig"; then
+        make clean all
+    else
+        make clean all ARCH=mips CROSS_COMPILE=$crossConfig-
+    fi
+  '';
+
+  dontStrip = true;
+  NIX_STRIP_DEBUG = false;
+
+  installPhase = ''
+    ensureDir $out
+    cp u-boot-nand.bin $out
+    cp u-boot u-boot.map $out
+
+    ensureDir $out/bin
+    cp tools/{envcrc,mkimage} $out/bin
+  '';
+}
diff --git a/pkgs/os-specific/linux/alsa-lib/default.nix b/pkgs/os-specific/linux/alsa-lib/default.nix
index 727db1c9642bc..5ebf526443986 100644
--- a/pkgs/os-specific/linux/alsa-lib/default.nix
+++ b/pkgs/os-specific/linux/alsa-lib/default.nix
@@ -14,6 +14,12 @@ stdenv.mkDerivation rec {
   postPatch = ''
     sed -i -e 's|//int snd_pcm_mixer_element(snd_pcm_t \*pcm, snd_mixer_t \*mixer, snd_mixer_elem_t \*\*elem);|/\*int snd_pcm_mixer_element(snd_pcm_t \*pcm, snd_mixer_t \*mixer, snd_mixer_elem_t \*\*elem);\*/|' include/pcm.h
   '';
+
+  crossAttrs = {
+    patchPhase = ''
+      sed -i s/extern/static/g include/iatomic.h
+    '';
+  };
   
   meta = {
     description = "ALSA, the Advanced Linux Sound Architecture libraries";
@@ -33,5 +39,10 @@ stdenv.mkDerivation rec {
        See http://thread.gmane.org/gmane.linux.distributions.nixos/3435
     */
     ./alsa-plugin-dirs.patch
+
+    /* patch provided by larsc on irc.
+       it may be a compiler problem on mips; without this, alsa does not build
+       on mips, because lacks some symbols atomic_add/atomic_sub  */
+    ./mips-atomic.patch
   ];
 }
diff --git a/pkgs/os-specific/linux/alsa-lib/mips-atomic.patch b/pkgs/os-specific/linux/alsa-lib/mips-atomic.patch
new file mode 100644
index 0000000000000..3af7c5d4debf8
--- /dev/null
+++ b/pkgs/os-specific/linux/alsa-lib/mips-atomic.patch
@@ -0,0 +1,39 @@
+diff --git a/include/iatomic.h b/include/iatomic.h
+index e92dbfd..364bc5c 100644
+--- a/include/iatomic.h
++++ b/include/iatomic.h
+@@ -720,7 +720,7 @@ typedef struct { volatile int counter; } atomic_t;
+  * Atomically adds @i to @v.  Note that the guaranteed useful range
+  * of an atomic_t is only 24 bits.
+  */
+-extern __inline__ void atomic_add(int i, atomic_t * v)
++static __inline__ void atomic_add(int i, atomic_t * v)
+ {
+ 	unsigned long temp;
+ 
+@@ -744,7 +744,7 @@ extern __inline__ void atomic_add(int i, atomic_t * v)
+  * Atomically subtracts @i from @v.  Note that the guaranteed
+  * useful range of an atomic_t is only 24 bits.
+  */
+-extern __inline__ void atomic_sub(int i, atomic_t * v)
++static __inline__ void atomic_sub(int i, atomic_t * v)
+ {
+ 	unsigned long temp;
+ 
+@@ -763,7 +763,7 @@ extern __inline__ void atomic_sub(int i, atomic_t * v)
+ /*
+  * Same as above, but return the result value
+  */
+-extern __inline__ int atomic_add_return(int i, atomic_t * v)
++static __inline__ int atomic_add_return(int i, atomic_t * v)
+ {
+ 	unsigned long temp, result;
+ 
+@@ -784,7 +784,7 @@ extern __inline__ int atomic_add_return(int i, atomic_t * v)
+ 	return result;
+ }
+ 
+-extern __inline__ int atomic_sub_return(int i, atomic_t * v)
++static __inline__ int atomic_sub_return(int i, atomic_t * v)
+ {
+ 	unsigned long temp, result;
diff --git a/pkgs/os-specific/linux/alsa-utils/default.nix b/pkgs/os-specific/linux/alsa-utils/default.nix
index e20163bfc97bf..ad092fa782145 100644
--- a/pkgs/os-specific/linux/alsa-utils/default.nix
+++ b/pkgs/os-specific/linux/alsa-utils/default.nix
@@ -8,7 +8,8 @@ stdenv.mkDerivation rec {
     sha256 = "1c7pl5k3d60wacnha8zfn2dixz7hiiaxvijis4559y15bs8mxl5p";
   };
   
-  buildInputs = [ alsaLib gettext ncurses ];
+  buildInputs = [ alsaLib ncurses ];
+  buildNativeInputs = [ gettext ];
   
   configureFlags = "--disable-xmlto";
 
diff --git a/pkgs/os-specific/linux/dmidecode/default.nix b/pkgs/os-specific/linux/dmidecode/default.nix
index 4e9c49e4f5874..7a291cba26cab 100644
--- a/pkgs/os-specific/linux/dmidecode/default.nix
+++ b/pkgs/os-specific/linux/dmidecode/default.nix
@@ -8,6 +8,12 @@ stdenv.mkDerivation rec {
     sha256 = "1h72r5scrpvgw60hif5msjg6vw2x0jd6z094lhbh6cjk6gls6x2d";
   };
 
+  # Taken from gentoo, to build with gnumake 3.82
+  # http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-apps/dmidecode/dmidecode-2.10.ebuild?r1=1.5&r2=1.6
+  patchPhase = ''
+    sed -i -e '/^PROGRAMS !=/d' Makefile
+  '';
+
   makeFlags = "prefix=$(out)";
 
   meta = {
diff --git a/pkgs/os-specific/linux/hal/default.nix b/pkgs/os-specific/linux/hal/default.nix
index 2f830ab0131a5..45a3efbfce534 100644
--- a/pkgs/os-specific/linux/hal/default.nix
+++ b/pkgs/os-specific/linux/hal/default.nix
@@ -7,6 +7,12 @@
 
 assert stdenv ? glibc;
 
+let
+  isPC = stdenv.isi686 || stdenv.isx86_64;
+  changeDmidecode = if isPC then
+    "--replace /usr/sbin/dmidecode ${dmidecode}/sbin/dmidecode"
+    else "";
+in
 stdenv.mkDerivation rec {
   name = "hal-0.5.14";
 
@@ -19,8 +25,7 @@ stdenv.mkDerivation rec {
     pkgconfig python pciutils expat libusb dbus.libs dbus_glib glib
     libuuid perl perlXMLParser gettext zlib gperf
     consolekit policykit
-    # !!! libsmbios is broken; it doesn't install headers.
-  ] ++ stdenv.lib.optional (stdenv.system != "armv5tel-linux") [ libsmbios ];
+  ];
 
   # !!! Hm, maybe the pci/usb.ids location should be in /etc, so that
   # we don't have to rebuild HAL when we update the PCI/USB IDs.
@@ -34,7 +39,7 @@ stdenv.mkDerivation rec {
   '';
 
   propagatedBuildInputs = [ libusb ]
-    ++ stdenv.lib.optionals (stdenv.system != "armv5tel-linux") [ libsmbios ];
+    ++ stdenv.lib.optional isPC libsmbios;
 
   preConfigure = ''
     for i in hald/linux/probing/probe-smbios.c hald/linux/osspec.c \
@@ -44,7 +49,7 @@ stdenv.mkDerivation rec {
              tools/linux/hal-*-linux
     do
       substituteInPlace $i \
-        --replace /usr/sbin/dmidecode ${dmidecode}/sbin/dmidecode \
+        ${changeDmidecode} \
         ${if udev != null then "--replace /sbin/udevadm ${udev}/sbin/udevadm" else ""} \
         --replace /bin/mount ${utillinuxng}/bin/mount \
         --replace /bin/umount ${utillinuxng}/bin/umount \
diff --git a/pkgs/os-specific/linux/kbd/default.nix b/pkgs/os-specific/linux/kbd/default.nix
index 77d53adeb81b7..2483a86c4864b 100644
--- a/pkgs/os-specific/linux/kbd/default.nix
+++ b/pkgs/os-specific/linux/kbd/default.nix
@@ -1,19 +1,22 @@
 { stdenv, fetchurl, bison, flex, autoconf, automake }:
 
 stdenv.mkDerivation rec {
-  name = "kbd-1.15.1";
+  name = "kbd-1.15.2";
 
   src = fetchurl {
     url = "ftp://ftp.altlinux.org/pub/people/legion/kbd/${name}.tar.gz";
-    sha256 = "1klrxas8vjikx6jm6m2lcpmn88lhxb6p3whwgdwq9d9flf1qrf4i";
+    sha256 = "0ff674y6d3b6ix08b9l2yzv8igns768biyp5y92vip7iz4xv2p2j";
   };
 
   buildInputs = [ bison flex autoconf automake  ];
 
-  # We get a warning in armv5tel-linux, so we disable -Werror in it
-  patchPhase = if (stdenv.system == "armv5tel-linux") then ''
-    sed -i s/-Werror// src/Makefile.am
-  '' else "";
+  # We get a warning in armv5tel-linux and the fuloong2f,
+  # so we disable -Werror in it
+  patchPhase = if (stdenv.system == "armv5tel-linux" ||
+    stdenv.system == "mips64-linux")
+    then ''
+      sed -i s/-Werror// src/Makefile.am
+    '' else "";
 
   # Grrr, kbd 1.15.1 doesn't include a configure script.
   preConfigure = "autoreconf";
diff --git a/pkgs/os-specific/linux/kernel-headers/2.6.28.nix b/pkgs/os-specific/linux/kernel-headers/2.6.28.nix
index 82840f8a51fe0..a85e6f79bf1be 100644
--- a/pkgs/os-specific/linux/kernel-headers/2.6.28.nix
+++ b/pkgs/os-specific/linux/kernel-headers/2.6.28.nix
@@ -20,6 +20,7 @@ stdenv.mkDerivation {
     if stdenv.system == "x86_64-linux" then "x86_64" else
     if stdenv.system == "powerpc-linux" then "powerpc" else
     if stdenv.system == "armv5tel-linux" then "arm" else
+    if stdenv.system == "mips64-linux" then "mips" else
     abort "don't know what the kernel include directory is called for this platform";
 
   buildInputs = [perl];
diff --git a/pkgs/os-specific/linux/kernel-headers/2.6.32.nix b/pkgs/os-specific/linux/kernel-headers/2.6.32.nix
index 936ef5ec40d07..a4e8665819323 100644
--- a/pkgs/os-specific/linux/kernel-headers/2.6.32.nix
+++ b/pkgs/os-specific/linux/kernel-headers/2.6.32.nix
@@ -26,6 +26,7 @@ stdenv.mkDerivation {
     if stdenv.system == "x86_64-linux" then "x86_64" else
     if stdenv.system == "powerpc-linux" then "powerpc" else
     if stdenv.system == "armv5tel-linux" then "arm" else
+    if stdenv.platform ? kernelArch then stdenv.platform.kernelArch else
     abort "don't know what the kernel include directory is called for this platform";
 
   buildInputs = [perl];
diff --git a/pkgs/os-specific/linux/kernel/builder.sh b/pkgs/os-specific/linux/kernel/builder.sh
index e7d25e8688356..bb030abaa6c9e 100644
--- a/pkgs/os-specific/linux/kernel/builder.sh
+++ b/pkgs/os-specific/linux/kernel/builder.sh
@@ -68,81 +68,88 @@ installPhase() {
     if test "$arch" = um; then
         ensureDir $out/bin
         cp linux $out/bin
-    else
+    elif test "$kernelTarget" != "vmlinux"; then
+        # In any case we copy the 'vmlinux' ELF in the next lines
         cp arch/$archDir/boot/$kernelTarget $out
     fi
 
     cp vmlinux $out
 
-    # Install the modules in $out/lib/modules with matching paths
-    # in modules.dep (i.e., refererring to $out/lib/modules, not
-    # /lib/modules).  The depmod_opts= is to prevent the kernel
-    # from passing `-b PATH' to depmod.
-    export MODULE_DIR=$out/lib/modules/
-    substituteInPlace Makefile --replace '-b $(INSTALL_MOD_PATH)' ''
-    make modules_install \
-        DEPMOD=$module_init_tools/sbin/depmod depmod_opts= \
-        $makeFlags "${makeFlagsArray[@]}" \
-        $installFlags "${installFlagsArray[@]}"
-
-    if test -z "$dontStrip"; then
-        # Strip the kernel modules.
-	echo "Stripping kernel modules..."
-	if [ -z "$crossConfig" ]; then
-            find $out -name "*.ko" -print0 | xargs -0 strip -S
-	else
-            find $out -name "*.ko" -print0 | xargs -0 $crossConfig-strip -S
-	fi
+    if grep -q "CONFIG_MODULES=y" .config; then
+        # Install the modules in $out/lib/modules with matching paths
+        # in modules.dep (i.e., refererring to $out/lib/modules, not
+        # /lib/modules).  The depmod_opts= is to prevent the kernel
+        # from passing `-b PATH' to depmod.
+        export MODULE_DIR=$out/lib/modules/
+        substituteInPlace Makefile --replace '-b $(INSTALL_MOD_PATH)' ''
+        make modules_install \
+            DEPMOD=$module_init_tools/sbin/depmod depmod_opts= \
+            $makeFlags "${makeFlagsArray[@]}" \
+            $installFlags "${installFlagsArray[@]}"
+
+        if test -z "$dontStrip"; then
+            # Strip the kernel modules.
+        echo "Stripping kernel modules..."
+        if [ -z "$crossConfig" ]; then
+                find $out -name "*.ko" -print0 | xargs -0 strip -S
+        else
+                find $out -name "*.ko" -print0 | xargs -0 $crossConfig-strip -S
+        fi
+        fi
+
+        # move this to install later on
+        # largely copied from early FC3 kernel spec files
+        version=$(cd $out/lib/modules && ls -d *)
+
+        # remove symlinks and create directories
+        rm -f $out/lib/modules/$version/build
+        rm -f $out/lib/modules/$version/source
+        mkdir $out/lib/modules/$version/build
+
+        # copy config
+        cp .config $out/lib/modules/$version/build/.config
+        ln -s $out/lib/modules/$version/build/.config $out/config
+
+        if test "$arch" != um; then
+            # copy all Makefiles and Kconfig files
+            ln -s $out/lib/modules/$version/build $out/lib/modules/$version/source
+            cp --parents `find  -type f -name Makefile -o -name "Kconfig*"` $out/lib/modules/$version/build
+            cp Module.symvers $out/lib/modules/$version/build
+
+        if test "$dontStrip" = "1"; then
+            # copy any debugging info that can be found
+            cp --parents -rv `find -name \*.debug -o -name debug.a`	\
+               "$out/lib/modules/$version/build"
+        fi
+
+            # weed out unneeded stuff
+            rm -rf $out/lib/modules/$version/build/Documentation
+            rm -rf $out/lib/modules/$version/build/scripts
+            rm -rf $out/lib/modules/$version/build/include
+
+            # copy architecture dependent files
+            cp -a arch/$archDir/scripts $out/lib/modules/$version/build/ || true
+            cp -a arch/$archDir/*lds $out/lib/modules/$version/build/ || true
+            cp -a arch/$archDir/Makefile*.cpu $out/lib/modules/$version/build/arch/$archDir/ || true
+            cp -a --parents arch/$archDir/kernel/asm-offsets.s $out/lib/modules/$version/build/arch/$archDir/kernel/ || true
+
+            # copy scripts
+            rm -f scripts/*.o
+            rm -f scripts/*/*.o
+            cp -a scripts $out/lib/modules/$version/build
+
+            # copy include files
+            includeDir=$out/lib/modules/$version/build/include
+            mkdir -p $includeDir
+            (cd include && cp -a * $includeDir)
+        (cd arch/$archDir/include && cp -a * $includeDir || true)
+        (cd arch/$archDir/include && cp -a asm/* $includeDir/asm/ || true)
+        (cd arch/$archDir/include/asm/mach-generic && cp -a * $includeDir/ || true)
+        fi
     fi
 
-    # move this to install later on
-    # largely copied from early FC3 kernel spec files
-    version=$(cd $out/lib/modules && ls -d *)
-
-    # remove symlinks and create directories
-    rm -f $out/lib/modules/$version/build
-    rm -f $out/lib/modules/$version/source
-    mkdir $out/lib/modules/$version/build
-
-    # copy config
-    cp .config $out/lib/modules/$version/build/.config
-    ln -s $out/lib/modules/$version/build/.config $out/config
-
-    if test "$arch" != um; then
-        # copy all Makefiles and Kconfig files
-        ln -s $out/lib/modules/$version/build $out/lib/modules/$version/source
-        cp --parents `find  -type f -name Makefile -o -name "Kconfig*"` $out/lib/modules/$version/build
-        cp Module.symvers $out/lib/modules/$version/build
-
-	if test "$dontStrip" = "1"; then
-	    # copy any debugging info that can be found
-	    cp --parents -rv `find -name \*.debug -o -name debug.a`	\
-	       "$out/lib/modules/$version/build"
-	fi
-
-        # weed out unneeded stuff
-        rm -rf $out/lib/modules/$version/build/Documentation
-        rm -rf $out/lib/modules/$version/build/scripts
-        rm -rf $out/lib/modules/$version/build/include
-
-        # copy architecture dependent files
-        cp -a arch/$archDir/scripts $out/lib/modules/$version/build/ || true
-        cp -a arch/$archDir/*lds $out/lib/modules/$version/build/ || true
-        cp -a arch/$archDir/Makefile*.cpu $out/lib/modules/$version/build/arch/$archDir/ || true
-        cp -a --parents arch/$archDir/kernel/asm-offsets.s $out/lib/modules/$version/build/arch/$archDir/kernel/ || true
-
-        # copy scripts
-        rm -f scripts/*.o
-        rm -f scripts/*/*.o
-        cp -a scripts $out/lib/modules/$version/build
-
-        # copy include files
-        includeDir=$out/lib/modules/$version/build/include
-        mkdir -p $includeDir
-        (cd include && cp -a * $includeDir)
-	(cd arch/$archDir/include && cp -a * $includeDir || true)
-	(cd arch/$archDir/include && cp -a asm/* $includeDir/asm/ || true)
-	(cd arch/$archDir/include/asm/mach-generic && cp -a * $includeDir/ || true)
+    if test -n "$postInstall"; then 
+        eval "$postInstall"; 
     fi
 }
 
diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix
index da3f6862a1015..42cefd5b584f1 100644
--- a/pkgs/os-specific/linux/kernel/generic.nix
+++ b/pkgs/os-specific/linux/kernel/generic.nix
@@ -34,11 +34,12 @@
 , preConfigure ? ""
 , extraMeta ? {}
 , ubootChooser ? null
+, postInstall ? ""
 , ...
 }:
 
 assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux"
-  || stdenv.system == "armv5tel-linux";
+  || stdenv.system == "armv5tel-linux" || stdenv.system == "mips64-linux";
 
 assert stdenv.platform.name == "sheevaplug" -> stdenv.platform.uboot != null;
 
@@ -69,7 +70,7 @@ stdenv.mkDerivation {
 
   generateConfig = ./generate-config.pl;
 
-  inherit preConfigure src module_init_tools localVersion;
+  inherit preConfigure src module_init_tools localVersion postInstall;
 
   patches = map (p: p.patch) kernelPatches;
 
@@ -94,6 +95,7 @@ stdenv.mkDerivation {
     if stdenv.system == "i686-linux" then "i386" else
     if stdenv.system == "x86_64-linux" then "x86_64" else
     if stdenv.system == "armv5tel-linux" then "arm" else
+    if stdenv.system == "mips64-linux" then "mips" else
     abort "Platform ${stdenv.system} is not supported.";
 
   crossAttrs = let
diff --git a/pkgs/os-specific/linux/kernel/linux-nanonote-jz-2.6.34.nix b/pkgs/os-specific/linux/kernel/linux-nanonote-jz-2.6.34.nix
new file mode 100644
index 0000000000000..0eb291d5b5532
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/linux-nanonote-jz-2.6.34.nix
@@ -0,0 +1,241 @@
+args @ { stdenv, fetchurl, fetchsvn, userModeLinux ? false, extraConfig ? ""
+, ... }:
+
+let
+  configWithPlatform = kernelPlatform :
+    ''
+      # Don't include any debug features.
+      DEBUG_KERNEL n
+
+      # Support drivers that need external firmware.
+      STANDALONE n
+
+      # Make /proc/config.gz available.
+      IKCONFIG_PROC y
+
+      # Optimize with -O2, not -Os.
+      CC_OPTIMIZE_FOR_SIZE n
+
+      # Enable the kernel's built-in memory tester.
+      MEMTEST y
+
+      # Include the CFQ I/O scheduler in the kernel, rather than as a
+      # module, so that the initrd gets a good I/O scheduler.
+      IOSCHED_CFQ y
+
+      # Disable some expensive (?) features.
+      FTRACE n
+      KPROBES n
+      NUMA? n
+      PM_TRACE_RTC n
+
+      # Enable various subsystems.
+      ACCESSIBILITY y # Accessibility support
+      AUXDISPLAY y # Auxiliary Display support
+      DONGLE y # Serial dongle support
+      HIPPI y
+      MTD_COMPLEX_MAPPINGS y # needed for many devices
+      NET_POCKET y # enable pocket and portable adapters
+      SCSI_LOWLEVEL y # enable lots of SCSI devices
+      SCSI_LOWLEVEL_PCMCIA y
+      SPI y # needed for many devices
+      SPI_MASTER y
+      WAN y
+
+      # Networking options.
+      IP_PNP n
+      IPV6_PRIVACY y
+      NETFILTER_ADVANCED y
+      IP_VS_PROTO_TCP y
+      IP_VS_PROTO_UDP y
+      IP_VS_PROTO_ESP y
+      IP_VS_PROTO_AH y
+      IP_DCCP_CCID3 n # experimental
+      CLS_U32_PERF y
+      CLS_U32_MARK y
+
+      # Wireless networking.
+      IPW2100_MONITOR y # support promiscuous mode
+      IPW2200_MONITOR y # support promiscuous mode
+      IWL4965 y # Intel Wireless WiFi 4965AGN
+      IWL5000 y # Intel Wireless WiFi 5000AGN
+      HOSTAP_FIRMWARE y # Support downloading firmware images with Host AP driver
+      HOSTAP_FIRMWARE_NVRAM y
+
+      # Some settings to make sure that fbcondecor works - in particular,
+      # disable tileblitting and the drivers that need it.
+
+      # Enable various FB devices.
+      FB y
+      FB_EFI y
+      FB_NVIDIA_I2C y # Enable DDC Support
+      FB_RIVA_I2C y
+      FB_ATY_CT y # Mach64 CT/VT/GT/LT (incl. 3D RAGE) support
+      FB_ATY_GX y # Mach64 GX support
+      FB_SAVAGE_I2C y
+      FB_SAVAGE_ACCEL y
+      FB_SIS_300 y
+      FB_SIS_315 y
+      FB_3DFX_ACCEL y
+      FB_GEODE y
+
+      # Video configuration
+      # The intel drivers already require KMS
+      DRM_I915_KMS y
+
+      # Sound.
+      SND_AC97_POWER_SAVE y # AC97 Power-Saving Mode
+      SND_HDA_INPUT_BEEP y # Support digital beep via input layer
+      SND_USB_CAIAQ_INPUT y
+      PSS_MIXER y # Enable PSS mixer (Beethoven ADSP-16 and other compatible)
+
+      # USB serial devices.
+      USB_SERIAL_GENERIC y # USB Generic Serial Driver
+      USB_SERIAL_KEYSPAN_MPR y # include firmware for various USB serial devices
+      USB_SERIAL_KEYSPAN_USA28 y
+      USB_SERIAL_KEYSPAN_USA28X y
+      USB_SERIAL_KEYSPAN_USA28XA y
+      USB_SERIAL_KEYSPAN_USA28XB y
+      USB_SERIAL_KEYSPAN_USA19 y
+      USB_SERIAL_KEYSPAN_USA18X y
+      USB_SERIAL_KEYSPAN_USA19W y
+      USB_SERIAL_KEYSPAN_USA19QW y
+      USB_SERIAL_KEYSPAN_USA19QI y
+      USB_SERIAL_KEYSPAN_USA49W y
+      USB_SERIAL_KEYSPAN_USA49WLC y
+
+      # Filesystem options - in particular, enable extended attributes and
+      # ACLs for all filesystems that support them.
+      EXT2_FS_XATTR y # Ext2 extended attributes
+      EXT2_FS_POSIX_ACL y # Ext2 POSIX Access Control Lists
+      EXT2_FS_SECURITY y # Ext2 Security Labels
+      EXT2_FS_XIP y # Ext2 execute in place support
+      EXT4_FS_POSIX_ACL y
+      EXT4_FS_SECURITY y
+      REISERFS_FS_XATTR y
+      REISERFS_FS_POSIX_ACL y
+      REISERFS_FS_SECURITY y
+      JFS_POSIX_ACL y
+      JFS_SECURITY y
+      XFS_QUOTA y
+      XFS_POSIX_ACL y
+      XFS_RT y # XFS Realtime subvolume support
+      OCFS2_DEBUG_MASKLOG n
+      BTRFS_FS_POSIX_ACL y
+      UBIFS_FS_XATTR y
+      UBIFS_FS_ADVANCED_COMPR y
+      NFSD_V2_ACL y
+      NFSD_V3 y
+      NFSD_V3_ACL y
+      NFSD_V4 y
+      CIFS_XATTR y
+      CIFS_POSIX y
+
+      # Security related features.
+      STRICT_DEVMEM y # Filter access to /dev/mem
+      SECURITY_SELINUX_BOOTPARAM_VALUE 0 # disable SELinux by default
+
+      # Misc. options.
+      8139TOO_8129 y
+      8139TOO_PIO n # PIO is slower
+      AIC79XX_DEBUG_ENABLE n
+      AIC7XXX_DEBUG_ENABLE n
+      AIC94XX_DEBUG n
+      B43_PCMCIA y
+      BLK_DEV_BSG n
+      BLK_DEV_CMD640_ENHANCED y # CMD640 enhanced support
+      BLK_DEV_IDEACPI y # IDE ACPI support
+      BLK_DEV_INTEGRITY y
+      BSD_PROCESS_ACCT_V3 y
+      BT_HCIUART_BCSP y
+      BT_HCIUART_H4 y # UART (H4) protocol support
+      BT_HCIUART_LL y
+      BT_RFCOMM_TTY y # RFCOMM TTY support
+      CPU_FREQ_DEBUG n
+      CRASH_DUMP n
+      DMAR? n # experimental
+      DVB_DYNAMIC_MINORS y # we use udev
+      FUSION y # Fusion MPT device support
+      IDE_GD_ATAPI y # ATAPI floppy support
+      IRDA_ULTRA y # Ultra (connectionless) protocol
+      JOYSTICK_IFORCE_232 y # I-Force Serial joysticks and wheels
+      JOYSTICK_IFORCE_USB y # I-Force USB joysticks and wheels
+      JOYSTICK_XPAD_FF y # X-Box gamepad rumble support
+      JOYSTICK_XPAD_LEDS y # LED Support for Xbox360 controller 'BigX' LED
+      KALLSYMS_EXTRA_PASS n
+      LDM_PARTITION y # Windows Logical Disk Manager (Dynamic Disk) support
+      LEDS_TRIGGER_IDE_DISK y # LED IDE Disk Trigger
+      LOGIRUMBLEPAD2_FF y # Logitech Rumblepad 2 force feedback
+      LOGO n # not needed
+      MEDIA_ATTACH y
+      MEGARAID_NEWGEN y
+      MICROCODE_AMD y
+      MODVERSIONS y
+      MOUSE_PS2_ELANTECH y # Elantech PS/2 protocol extension
+      MTRR_SANITIZER y
+      NET_FC y # Fibre Channel driver support
+      PPP_MULTILINK y # PPP multilink support
+      REGULATOR y # Voltage and Current Regulator Support
+      SCSI_LOGGING y # SCSI logging facility
+      SERIAL_8250 y # 8250/16550 and compatible serial support
+      SLIP_COMPRESSED y # CSLIP compressed headers
+      SLIP_SMART y
+      THERMAL_HWMON y # Hardware monitoring support
+      USB_DEBUG n
+      USB_EHCI_ROOT_HUB_TT y # Root Hub Transaction Translators
+      X86_CHECK_BIOS_CORRUPTION y
+      X86_MCE y
+
+      ${if kernelPlatform ? kernelExtraConfig then kernelPlatform.kernelExtraConfig else ""}
+      ${extraConfig}
+    '';
+in
+
+import ./generic.nix (
+
+  rec {
+    version = "qi_lb60-2.6.34.1-openwrt-22513";
+  
+    src = fetchurl {
+      url = "mirror://kernel/linux/kernel/v2.6/linux-2.6.34.1.tar.bz2";
+      sha256 = "0v78yvkwr100v7bnrkkabxmpv5hjg1ngrjbr5d0kkzsw4d7bmm5x";
+    };
+
+    srcPatch = fetchsvn {
+      url = "svn://svn.openwrt.org/openwrt/trunk/target/linux";
+      rev = 22513;
+      sha256 = "0b7wzgqnbq8sq32z9ik08n1b7fnc9v9d91zwvb6qz7vj3dlrxw3g";
+    };
+
+    preConfigure = ''
+      cp -R ${srcPatch}/generic/files/* .
+      chmod +w -R *
+      GLOBIGNORE='.:..:*preinit_as_init*'
+      for a in ${srcPatch}/generic/patches-2.6.34/* ${srcPatch}/xburst/patches-2.6.34/* ; do
+        echo applying patch $a
+        patch -p1 < $a
+      done
+      unset GLOBIGNORE
+      cat ${srcPatch}/generic/config-2.6.34 ${srcPatch}/xburst/config-2.6.34 \
+          ${srcPatch}/xburst/qi_lb60/config-2.6.34 > arch/mips/configs/qi_lb60_defconfig
+    '';
+
+    postInstall = ''
+      set -x
+      gzip -9 -c $out/vmlinux.bin > $out/vmlinux.bin.gz
+      KERNEL_ENTRY="0x`$crossConfig-nm $out/vmlinux 2>/dev/null |
+        grep " kernel_entry" | cut -f1 -d ' '`"
+      mkimage -A mips -O linux -T kernel -a 0x80010000 -C gzip \
+          -e $KERNEL_ENTRY -n "MIPS Nix Linux-2.6.34" \
+          -d $out/vmlinux.bin.gz $out/uImage
+      set +x
+    '';
+
+    config = configWithPlatform stdenv.platform;
+    configCross = configWithPlatform stdenv.cross.platform;
+
+    features.iwlwifi = true;
+  }
+
+  // removeAttrs args ["extraConfig"]
+)
diff --git a/pkgs/os-specific/linux/kernel/linux-nanonote-jz-2.6.35.nix b/pkgs/os-specific/linux/kernel/linux-nanonote-jz-2.6.35.nix
new file mode 100644
index 0000000000000..ac0b000f9cd4d
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/linux-nanonote-jz-2.6.35.nix
@@ -0,0 +1,241 @@
+args @ { stdenv, fetchurl, fetchsvn, userModeLinux ? false, extraConfig ? ""
+, ... }:
+
+let
+  configWithPlatform = kernelPlatform :
+    ''
+      # Don't include any debug features.
+      DEBUG_KERNEL n
+
+      # Support drivers that need external firmware.
+      STANDALONE n
+
+      # Make /proc/config.gz available.
+      IKCONFIG_PROC y
+
+      # Optimize with -O2, not -Os.
+      CC_OPTIMIZE_FOR_SIZE n
+
+      # Enable the kernel's built-in memory tester.
+      MEMTEST y
+
+      # Include the CFQ I/O scheduler in the kernel, rather than as a
+      # module, so that the initrd gets a good I/O scheduler.
+      IOSCHED_CFQ y
+
+      # Disable some expensive (?) features.
+      FTRACE n
+      KPROBES n
+      NUMA? n
+      PM_TRACE_RTC n
+
+      # Enable various subsystems.
+      ACCESSIBILITY y # Accessibility support
+      AUXDISPLAY y # Auxiliary Display support
+      DONGLE y # Serial dongle support
+      HIPPI y
+      MTD_COMPLEX_MAPPINGS y # needed for many devices
+      NET_POCKET y # enable pocket and portable adapters
+      SCSI_LOWLEVEL y # enable lots of SCSI devices
+      SCSI_LOWLEVEL_PCMCIA y
+      SPI y # needed for many devices
+      SPI_MASTER y
+      WAN y
+
+      # Networking options.
+      IP_PNP n
+      IPV6_PRIVACY y
+      NETFILTER_ADVANCED y
+      IP_VS_PROTO_TCP y
+      IP_VS_PROTO_UDP y
+      IP_VS_PROTO_ESP y
+      IP_VS_PROTO_AH y
+      IP_DCCP_CCID3 n # experimental
+      CLS_U32_PERF y
+      CLS_U32_MARK y
+
+      # Wireless networking.
+      IPW2100_MONITOR y # support promiscuous mode
+      IPW2200_MONITOR y # support promiscuous mode
+      IWL4965 y # Intel Wireless WiFi 4965AGN
+      IWL5000 y # Intel Wireless WiFi 5000AGN
+      HOSTAP_FIRMWARE y # Support downloading firmware images with Host AP driver
+      HOSTAP_FIRMWARE_NVRAM y
+
+      # Some settings to make sure that fbcondecor works - in particular,
+      # disable tileblitting and the drivers that need it.
+
+      # Enable various FB devices.
+      FB y
+      FB_EFI y
+      FB_NVIDIA_I2C y # Enable DDC Support
+      FB_RIVA_I2C y
+      FB_ATY_CT y # Mach64 CT/VT/GT/LT (incl. 3D RAGE) support
+      FB_ATY_GX y # Mach64 GX support
+      FB_SAVAGE_I2C y
+      FB_SAVAGE_ACCEL y
+      FB_SIS_300 y
+      FB_SIS_315 y
+      FB_3DFX_ACCEL y
+      FB_GEODE y
+
+      # Video configuration
+      # The intel drivers already require KMS
+      DRM_I915_KMS y
+
+      # Sound.
+      SND_AC97_POWER_SAVE y # AC97 Power-Saving Mode
+      SND_HDA_INPUT_BEEP y # Support digital beep via input layer
+      SND_USB_CAIAQ_INPUT y
+      PSS_MIXER y # Enable PSS mixer (Beethoven ADSP-16 and other compatible)
+
+      # USB serial devices.
+      USB_SERIAL_GENERIC y # USB Generic Serial Driver
+      USB_SERIAL_KEYSPAN_MPR y # include firmware for various USB serial devices
+      USB_SERIAL_KEYSPAN_USA28 y
+      USB_SERIAL_KEYSPAN_USA28X y
+      USB_SERIAL_KEYSPAN_USA28XA y
+      USB_SERIAL_KEYSPAN_USA28XB y
+      USB_SERIAL_KEYSPAN_USA19 y
+      USB_SERIAL_KEYSPAN_USA18X y
+      USB_SERIAL_KEYSPAN_USA19W y
+      USB_SERIAL_KEYSPAN_USA19QW y
+      USB_SERIAL_KEYSPAN_USA19QI y
+      USB_SERIAL_KEYSPAN_USA49W y
+      USB_SERIAL_KEYSPAN_USA49WLC y
+
+      # Filesystem options - in particular, enable extended attributes and
+      # ACLs for all filesystems that support them.
+      EXT2_FS_XATTR y # Ext2 extended attributes
+      EXT2_FS_POSIX_ACL y # Ext2 POSIX Access Control Lists
+      EXT2_FS_SECURITY y # Ext2 Security Labels
+      EXT2_FS_XIP y # Ext2 execute in place support
+      EXT4_FS_POSIX_ACL y
+      EXT4_FS_SECURITY y
+      REISERFS_FS_XATTR y
+      REISERFS_FS_POSIX_ACL y
+      REISERFS_FS_SECURITY y
+      JFS_POSIX_ACL y
+      JFS_SECURITY y
+      XFS_QUOTA y
+      XFS_POSIX_ACL y
+      XFS_RT y # XFS Realtime subvolume support
+      OCFS2_DEBUG_MASKLOG n
+      BTRFS_FS_POSIX_ACL y
+      UBIFS_FS_XATTR y
+      UBIFS_FS_ADVANCED_COMPR y
+      NFSD_V2_ACL y
+      NFSD_V3 y
+      NFSD_V3_ACL y
+      NFSD_V4 y
+      CIFS_XATTR y
+      CIFS_POSIX y
+
+      # Security related features.
+      STRICT_DEVMEM y # Filter access to /dev/mem
+      SECURITY_SELINUX_BOOTPARAM_VALUE 0 # disable SELinux by default
+
+      # Misc. options.
+      8139TOO_8129 y
+      8139TOO_PIO n # PIO is slower
+      AIC79XX_DEBUG_ENABLE n
+      AIC7XXX_DEBUG_ENABLE n
+      AIC94XX_DEBUG n
+      B43_PCMCIA y
+      BLK_DEV_BSG n
+      BLK_DEV_CMD640_ENHANCED y # CMD640 enhanced support
+      BLK_DEV_IDEACPI y # IDE ACPI support
+      BLK_DEV_INTEGRITY y
+      BSD_PROCESS_ACCT_V3 y
+      BT_HCIUART_BCSP y
+      BT_HCIUART_H4 y # UART (H4) protocol support
+      BT_HCIUART_LL y
+      BT_RFCOMM_TTY y # RFCOMM TTY support
+      CPU_FREQ_DEBUG n
+      CRASH_DUMP n
+      DMAR? n # experimental
+      DVB_DYNAMIC_MINORS y # we use udev
+      FUSION y # Fusion MPT device support
+      IDE_GD_ATAPI y # ATAPI floppy support
+      IRDA_ULTRA y # Ultra (connectionless) protocol
+      JOYSTICK_IFORCE_232 y # I-Force Serial joysticks and wheels
+      JOYSTICK_IFORCE_USB y # I-Force USB joysticks and wheels
+      JOYSTICK_XPAD_FF y # X-Box gamepad rumble support
+      JOYSTICK_XPAD_LEDS y # LED Support for Xbox360 controller 'BigX' LED
+      KALLSYMS_EXTRA_PASS n
+      LDM_PARTITION y # Windows Logical Disk Manager (Dynamic Disk) support
+      LEDS_TRIGGER_IDE_DISK y # LED IDE Disk Trigger
+      LOGIRUMBLEPAD2_FF y # Logitech Rumblepad 2 force feedback
+      LOGO n # not needed
+      MEDIA_ATTACH y
+      MEGARAID_NEWGEN y
+      MICROCODE_AMD y
+      MODVERSIONS y
+      MOUSE_PS2_ELANTECH y # Elantech PS/2 protocol extension
+      MTRR_SANITIZER y
+      NET_FC y # Fibre Channel driver support
+      PPP_MULTILINK y # PPP multilink support
+      REGULATOR y # Voltage and Current Regulator Support
+      SCSI_LOGGING y # SCSI logging facility
+      SERIAL_8250 y # 8250/16550 and compatible serial support
+      SLIP_COMPRESSED y # CSLIP compressed headers
+      SLIP_SMART y
+      THERMAL_HWMON y # Hardware monitoring support
+      USB_DEBUG n
+      USB_EHCI_ROOT_HUB_TT y # Root Hub Transaction Translators
+      X86_CHECK_BIOS_CORRUPTION y
+      X86_MCE y
+
+      ${if kernelPlatform ? kernelExtraConfig then kernelPlatform.kernelExtraConfig else ""}
+      ${extraConfig}
+    '';
+in
+
+import ./generic.nix (
+
+  rec {
+    version = "qi_lb60-2.6.35-openwrt-22513";
+  
+    src = fetchurl {
+      url = "mirror://kernel/linux/kernel/v2.6/linux-2.6.35.tar.bz2";
+      sha256 = "1kxz87nwksx4hvq1i45i9w1zq1fb09rvf8i6jin3cbh36v1y5chq";
+    };
+
+    srcPatch = fetchsvn {
+      url = "svn://svn.openwrt.org/openwrt/trunk/target/linux";
+      rev = 22530;
+      sha256 = "1j5ls7dg0pvdxh6isczmq4r0lkwhz1c1s46mvdkcjsm3qq633fpc";
+    };
+
+    preConfigure = ''
+      cp -R ${srcPatch}/generic/files/* .
+      chmod +w -R *
+      GLOBIGNORE='.:..:*preinit_as_init*'
+      for a in ${srcPatch}/generic/patches-2.6.35/* ${srcPatch}/xburst/patches-2.6.35/* ; do
+        echo applying patch $a
+        patch -p1 < $a
+      done
+      unset GLOBIGNORE
+      cat ${srcPatch}/generic/config-2.6.35 ${srcPatch}/xburst/config-2.6.35 \
+          ${srcPatch}/xburst/qi_lb60/config-2.6.35 > arch/mips/configs/qi_lb60_defconfig
+    '';
+
+    postInstall = ''
+      set -x
+      gzip -9 -c $out/vmlinux.bin > $out/vmlinux.bin.gz
+      KERNEL_ENTRY="0x`$crossConfig-nm $out/vmlinux 2>/dev/null |
+        grep " kernel_entry" | cut -f1 -d ' '`"
+      mkimage -A mips -O linux -T kernel -a 0x80010000 -C gzip \
+          -e $KERNEL_ENTRY -n "MIPS Nix Linux-2.6.35" \
+          -d $out/vmlinux.bin.gz $out/uImage
+      set +x
+    '';
+
+    config = configWithPlatform stdenv.platform;
+    configCross = configWithPlatform stdenv.cross.platform;
+
+    features.iwlwifi = true;
+  }
+
+  // removeAttrs args ["extraConfig"]
+)
diff --git a/pkgs/os-specific/linux/kernel/patches.nix b/pkgs/os-specific/linux/kernel/patches.nix
index 694f6699b4f6b..a1229912b38f3 100644
--- a/pkgs/os-specific/linux/kernel/patches.nix
+++ b/pkgs/os-specific/linux/kernel/patches.nix
@@ -186,9 +186,9 @@ in
   no_xsave =
     { name = "no-xsave";
       patch = fetchurl {
-        url = "http://cvs.fedoraproject.org/viewvc/devel/kernel/fix_xen_guest_on_old_EC2.patch?revision=1.1&view=co";
+        url = "http://kernel.ubuntu.com/git?p=rtg/ubuntu-maverick.git;a=blobdiff_plain;f=arch/x86/xen/enlighten.c;h=f7ff4c7d22954ab5eda464320241300bd5a32ee5;hp=1ea06f842a921557e958110e22941d53a2822f3c;hb=1a30f99;hpb=8f2ff69dce18ed856a8d1b93176f768b47eeed86";
         name = "no-xsave.patch";
-        sha256 = "02f51f9b636b105c81a3ed62145abdc0ecb043b8114eb10257854577f617f894";
+        sha256 = "18732s3vmav5rpg6zqpiw2i0ll83pcc4gw266h6545pmbh9p7hky";
       };
       features.noXsave = true;
     };
diff --git a/pkgs/os-specific/linux/klibc/default.nix b/pkgs/os-specific/linux/klibc/default.nix
index c3967f4f1ab9c..b8cd2b18bc7c4 100644
--- a/pkgs/os-specific/linux/klibc/default.nix
+++ b/pkgs/os-specific/linux/klibc/default.nix
@@ -1,26 +1,58 @@
-{stdenv, fetchurl, perl, bison, mktemp, linuxHeaders}:
+{stdenv, fetchurl, perl, bison, mktemp, linuxHeaders, linuxHeadersCross}:
 
 assert stdenv.isLinux;
 
-let version = "1.5.15"; in
+let
+  version = "1.5.20";
+  baseMakeFlags = ["V=1" "prefix=$out" "SHLIBDIR=$out/lib"];
+in
 
 stdenv.mkDerivation {
   name = "klibc-${version}";
 
   src = fetchurl {
-    url = "mirror://kernel/linux/libs/klibc/klibc-${version}.tar.bz2";
-    sha256 = "1x401wmjca6zkyikf9xz45b3wb1hnj0m2s9in1sg6xdhi3pk8lwb";
+    url = "mirror://kernel/linux/libs/klibc/1.5/klibc-${version}.tar.bz2";
+    sha256 = "07683dn18r3k35d6pp0sn88pqcx7dldqx3m6f2gz45i1j094qp7m";
   };
+
+  patches = [ ./make382.patch ];
+
+  # Trick to make this build on nix. It expects to have the kernel sources
+  # instead of only the linux kernel headers.
+  # So it cannot run the 'make headers_install' it wants to run.
+  # We don't install the headers, so klibc will not be useful as libc, but
+  # usually in nixpkgs we only use the userspace tools comming with klibc.
+  prePatch = ''
+    sed -i -e /headers_install/d scripts/Kbuild.install
+  '';
   
-  makeFlags = ["V=1" "prefix=$out" "SHLIBDIR=$out/lib"];
+  makeFlags = baseMakeFlags;
+
+  inherit linuxHeaders;
+
+  crossAttrs = {
+    makeFlags = baseMakeFlags ++ [ "CROSS_COMPILE=${stdenv.cross.config}-"
+        "KLIBCARCH=${stdenv.cross.arch}" ];
+
+    patchPhase = ''
+      sed -i 's/-fno-pic -mno-abicalls/& -mabi=32/' usr/klibc/arch/mips/MCONFIG
+      sed -i /KLIBCKERNELSRC/d scripts/Kbuild.install
+      # Wrong check for __mips64 in klibc
+      sed -i s/__mips64__/__mips64/ usr/include/fcntl.h
+    '';
+
+    linuxHeaders = linuxHeadersCross;
+  };
   
+  # The AEABI option concerns only arm systems, and does not affect the build for
+  # other systems.
   preBuild = ''
     sed -i /CONFIG_AEABI/d defconfig
     echo "CONFIG_AEABI=y" >> defconfig
     makeFlags=$(eval "echo $makeFlags")
 
     mkdir linux
-    cp -prsd ${linuxHeaders}/include linux/
+    cp -prsd $linuxHeaders/include linux/
     chmod -R u+w linux/include/
   ''; # */
   
@@ -32,5 +64,5 @@ stdenv.mkDerivation {
     cp usr/dash/sh $dir/
   '';
   
-  buildInputs = [perl bison mktemp];
+  buildNativeInputs = [ perl bison mktemp ];
 }
diff --git a/pkgs/os-specific/linux/klibc/make382.patch b/pkgs/os-specific/linux/klibc/make382.patch
new file mode 100644
index 0000000000000..e9e9aba4e7921
--- /dev/null
+++ b/pkgs/os-specific/linux/klibc/make382.patch
@@ -0,0 +1,35 @@
+To avoid an endless loop with gnumake 3.82
+http://www.mail-archive.com/pld-cvs-commit@lists.pld-linux.org/msg228690.html
+
+Index: packages/klibc/klibc-make.patch
+--- klibc-1.5.19/scripts/Kbuild.include.orig   2010-08-19 09:39:45.986816591 
+0200
++++ klibc-1.5.19/scripts/Kbuild.include        2010-08-19 09:49:15.010816591 
+0200
+@@ -127,7 +127,7 @@
+ # >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file
+ # note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars
+ #
+-if_changed = $(if $(strip $(filter-out $(PHONY),$?)          \
++if_changed = $(if $(strip $(filter-out $(PHONY) FORCE,$?)          \
+ 		$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
+ 	@set -e; \
+ 	$(echo-cmd) $(cmd_$(1)); \
+@@ -135,7 +135,7 @@
+ 
+ # execute the command and also postprocess generated .d dependencies
+ # file
+-if_changed_dep = $(if $(strip $(filter-out $(PHONY),$?)  \
++if_changed_dep = $(if $(strip $(filter-out $(PHONY) FORCE,$?)  \
+ 		$(filter-out FORCE $(wildcard $^),$^)    \
+ 	$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),     \
+ 	@set -e; \
+@@ -147,7 +147,7 @@
+ # Usage: $(call if_changed_rule,foo)
+ # will check if $(cmd_foo) changed, or any of the prequisites changed,
+ # and if so will execute $(rule_foo)
+-if_changed_rule = $(if $(strip $(filter-out $(PHONY),$?)            \
++if_changed_rule = $(if $(strip $(filter-out $(PHONY) FORCE,$?)            \
+ 			$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\
+ 			@set -e; \
+ 			$(rule_$(1)))
diff --git a/pkgs/os-specific/linux/libcap/default.nix b/pkgs/os-specific/linux/libcap/default.nix
index 46f40167a7eb7..d8cb393ac38be 100644
--- a/pkgs/os-specific/linux/libcap/default.nix
+++ b/pkgs/os-specific/linux/libcap/default.nix
@@ -1,18 +1,29 @@
-{stdenv, fetchurl, attr}:
+{stdenv, fetchurl, attr, perl}:
 
 assert stdenv.isLinux;
 
-stdenv.mkDerivation {
-  name = "libcap-2.09";
+stdenv.mkDerivation rec {
+  name = "libcap-${version}";
+  version = "2.19";
   
   src = fetchurl {
-    url = mirror://kernel/linux/libs/security/linux-privs/kernel-2.6/libcap-2.09.tar.bz2;
-    sha256 = "0sq15y8yfm7knf6jhqcycb9wz52n3r1sriii66xk0djvd4hw69jr";
+    url = "mirror://kernel/linux/libs/security/linux-privs/kernel-2.6/${name}.tar.gz";
+    sha256 = "0fdsz9j741npvh222f8p1y6l516z9liibiwdpdr3a4zg53m0pw45";
   };
   
-  buildInputs = [attr];
+  buildNativeInputs = [perl];
+  propagatedBuildInputs = [attr];
 
-  preBuild = ''
-    makeFlagsArray=(LIBDIR=$out/lib INCDIR=$out/include SBINDIR=$out/sbin MANDIR=$out/man PAM_CAP=no)
-  '';
+  preConfigure = "cd libcap";
+
+  makeFlags = "lib=lib prefix=$(out)";
+
+  passthru = {
+    postinst = n : ''
+      ensureDir $out/share/doc/${n}
+      cp ../License $out/share/doc/${n}/License
+    '';
+  };
+
+  postInstall = passthru.postinst name;
 }
diff --git a/pkgs/os-specific/linux/libcap/man.nix b/pkgs/os-specific/linux/libcap/man.nix
new file mode 100644
index 0000000000000..9aac3c4e1f5a0
--- /dev/null
+++ b/pkgs/os-specific/linux/libcap/man.nix
@@ -0,0 +1,15 @@
+{stdenv, libcap}:
+
+assert stdenv.isLinux;
+
+stdenv.mkDerivation rec {
+  name = "libcap-docs-${libcap.version}";
+
+  inherit (libcap) src;
+
+  makeFlags = "MANDIR=$(out)/share/man";
+
+  preConfigure = "cd doc";
+
+  postInstall = libcap.postinst name;
+}
diff --git a/pkgs/os-specific/linux/libcap/pam.nix b/pkgs/os-specific/linux/libcap/pam.nix
new file mode 100644
index 0000000000000..4cefa825c8a7b
--- /dev/null
+++ b/pkgs/os-specific/linux/libcap/pam.nix
@@ -0,0 +1,17 @@
+{stdenv, pam, libcap}:
+
+assert stdenv.isLinux;
+
+stdenv.mkDerivation rec {
+  name = "cap_pam.so-${libcap.version}";
+
+  inherit (libcap) src;
+
+  buildInputs = [ libcap pam ];
+
+  preConfigure = "cd pam_cap";
+
+  makeFlags = "${libcap.makeFlags} PAM_CAP=yes";
+
+  postInstall = libcap.postinst name;
+}
diff --git a/pkgs/os-specific/linux/libcap/progs.nix b/pkgs/os-specific/linux/libcap/progs.nix
new file mode 100644
index 0000000000000..1b38848e77efb
--- /dev/null
+++ b/pkgs/os-specific/linux/libcap/progs.nix
@@ -0,0 +1,15 @@
+{stdenv, libcap}:
+
+assert stdenv.isLinux;
+
+stdenv.mkDerivation rec {
+  name = "libcap-progs-${libcap.version}";
+
+  inherit (libcap) src makeFlags;
+
+  buildInputs = [ libcap ];
+
+  preConfigure = "cd progs";
+
+  postInstall = libcap.postinst name;
+}
diff --git a/pkgs/os-specific/linux/lvm2/default.nix b/pkgs/os-specific/linux/lvm2/default.nix
index cffb7e8353d03..9a2dc2d28ace4 100644
--- a/pkgs/os-specific/linux/lvm2/default.nix
+++ b/pkgs/os-specific/linux/lvm2/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation {
   
   src = fetchurl {
     url = "ftp://sources.redhat.com/pub/lvm2/old/LVM2.${v}.tgz";
-    sha256 =  "2a4157b91b7ad5ea84359e8548b64947611beea01862e010be71f54b649e7ad1";
+    sha256 = "1lbskrj4pxbipq8f0qhql3p1nqa796v4i1cy6n2fmmbs3fwmfh9a";
   };
   
   configureFlags = "--disable-readline --enable-udev_rules --enable-udev_sync";
diff --git a/pkgs/os-specific/linux/mountall/default.nix b/pkgs/os-specific/linux/mountall/default.nix
index 360a7d80c126b..134f7577c96da 100644
--- a/pkgs/os-specific/linux/mountall/default.nix
+++ b/pkgs/os-specific/linux/mountall/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, libnih, dbus, udev, autoconf, automake, libtool }:
+{ stdenv, fetchurl, pkgconfig, libnih, dbus, udev, autoconf, automake, libtool, gettext }:
    
 stdenv.mkDerivation {
   name = "mountall-2.15";
@@ -10,9 +10,9 @@ stdenv.mkDerivation {
 
   patches = [ ./no-plymouth.patch ];
 
-  preConfigure = "autoreconf";
+  preConfigure = "rm -R aclocal.m4; gettextize -f; autoreconf -vfi";
 
-  buildInputs = [ pkgconfig libnih dbus.libs udev autoconf automake libtool ];
+  buildInputs = [ pkgconfig libnih dbus.libs udev autoconf automake libtool gettext ];
 
   meta = {
     homepage = https://launchpad.net/ubuntu/+source/mountall;
diff --git a/pkgs/os-specific/linux/nfs-utils/default.nix b/pkgs/os-specific/linux/nfs-utils/default.nix
index b651d39b8887d..0234a7a2649ba 100644
--- a/pkgs/os-specific/linux/nfs-utils/default.nix
+++ b/pkgs/os-specific/linux/nfs-utils/default.nix
@@ -15,7 +15,8 @@ stdenv.mkDerivation rec {
   configureFlags =
     [ "--disable-gss" "--disable-nfsv4" "--disable-nfsv41" "--disable-tirpc"
       "--with-statedir=/var/lib/nfs"
-    ];
+    ]
+    ++ stdenv.lib.optional (stdenv ? glibc) "--with-rpcgen=${stdenv.glibc}/bin/rpcgen";
 
   patchPhase =
     ''
@@ -33,7 +34,8 @@ stdenv.mkDerivation rec {
       installFlags="statedir=$TMPDIR" # hack to make `make install' work
     '';
 
-  doCheck = true;
+  # One test fails on mips.
+  doCheck = if stdenv.isMips then false else true;
 
   meta = {
     description = "Linux user-space NFS utilities";
diff --git a/pkgs/os-specific/linux/pam/default.nix b/pkgs/os-specific/linux/pam/default.nix
index f27c6af31bb5b..692643505e181 100644
--- a/pkgs/os-specific/linux/pam/default.nix
+++ b/pkgs/os-specific/linux/pam/default.nix
@@ -9,7 +9,9 @@ stdenv.mkDerivation {
   };
 
   buildInputs = [ flex cracklib ]
-    ++ stdenv.lib.optional (stdenv.system != "armv5tel-linux") libxcrypt;
+    ++ stdenv.lib.optional
+      (stdenv.system != "armv5tel-linux" && stdenv.system != "mips64-linux")
+      libxcrypt;
 
   postInstall = ''
     mv -v $out/sbin/unix_chkpwd{,.orig}
diff --git a/pkgs/os-specific/linux/procps/default.nix b/pkgs/os-specific/linux/procps/default.nix
index 4a74218aa3691..9270e4c6c0e18 100644
--- a/pkgs/os-specific/linux/procps/default.nix
+++ b/pkgs/os-specific/linux/procps/default.nix
@@ -7,6 +7,6 @@ stdenv.mkDerivation {
     url = http://procps.sourceforge.net/procps-3.2.8.tar.gz;
     sha256 = "0d8mki0q4yamnkk4533kx8mc0jd879573srxhg6r2fs3lkc6iv8i";
   };
-  patches = [./makefile.patch ./procps-build.patch];
+  patches = [./makefile.patch ./procps-build.patch ./gnumake3.82.patch];
   buildInputs = [ncurses];
 }
diff --git a/pkgs/os-specific/linux/procps/gnumake3.82.patch b/pkgs/os-specific/linux/procps/gnumake3.82.patch
new file mode 100644
index 0000000000000..2b1f28d4bce72
--- /dev/null
+++ b/pkgs/os-specific/linux/procps/gnumake3.82.patch
@@ -0,0 +1,13 @@
+diff --git a/Makefile b/Makefile
+index 09fb3ed..59eba16 100644
+--- a/Makefile
++++ b/Makefile
+@@ -174,7 +174,7 @@ INSTALL := $(BINFILES) $(MANFILES)
+ # want this rule first, use := on ALL, and ALL not filled in yet
+ all: do_all
+ 
+--include */module.mk
++-include proc/module.mk ps/module.mk
+ 
+ do_all:    $(ALL)
+ 
diff --git a/pkgs/os-specific/linux/sysvinit/default.nix b/pkgs/os-specific/linux/sysvinit/default.nix
index 8315ee4835d39..a05638dcb77cb 100644
--- a/pkgs/os-specific/linux/sysvinit/default.nix
+++ b/pkgs/os-specific/linux/sysvinit/default.nix
@@ -6,7 +6,7 @@ stdenv.mkDerivation {
   name = (if withoutInitTools then "sysvtools" else "sysvinit") + "-" + version;
   
   src = fetchurl {
-    url = "http://www.very-clever.com/download/nongnu/sysvinit/sysvinit-${version}.tar.bz2";
+    url = "mirror://savannah/sysvinit/sysvinit-${version}.tar.bz2";
     sha256 = "068mvzaz808a673zigyaqb63xc8bndh2klk16zi5c83rw70wifv0";
   };
   
diff --git a/pkgs/os-specific/linux/uclibc/default.nix b/pkgs/os-specific/linux/uclibc/default.nix
index 83de2ae38ef2f..ce95dbaba922f 100644
--- a/pkgs/os-specific/linux/uclibc/default.nix
+++ b/pkgs/os-specific/linux/uclibc/default.nix
@@ -1,48 +1,72 @@
-{stdenv, fetchurl, linuxHeaders, cross ? null, gccCross ? null}:
+{stdenv, fetchurl, linuxHeaders, libiconv, cross ? null, gccCross ? null,
+extraConfig ? ""}:
 
 assert stdenv.isLinux;
 assert cross != null -> gccCross != null;
 
 let
-    enableArmEABI = (cross == null && stdenv.platform.kernelArch == "arm")
-      || (cross != null && cross.arch == "arm");
-
-    configArmEABI = if enableArmEABI then
-        ''-e 's/.*CONFIG_ARM_OABI.*//' \
-        -e 's/.*CONFIG_ARM_EABI.*/CONFIG_ARM_EABI=y/' '' else "";
-
-    enableBigEndian = (cross != null && cross.bigEndian);
-    
-    configBigEndian = if enableBigEndian then ""
-      else
-        ''-e 's/.*ARCH_BIG_ENDIAN.*/#ARCH_BIG_ENDIAN=y/' \
-        -e 's/.*ARCH_WANTS_BIG_ENDIAN.*/#ARCH_WANTS_BIG_ENDIAN=y/' \
-        -e 's/.*ARCH_WANTS_LITTLE_ENDIAN.*/ARCH_WANTS_LITTLE_ENDIAN=y/' '';
-
-    archMakeFlag = if (cross != null) then "ARCH=${cross.arch}" else "";
-    crossMakeFlag = if (cross != null) then "CROSS=${cross.config}-" else "";
+  configParser = ''
+    function parseconfig {
+        set -x
+        while read LINE; do
+            NAME=`echo "$LINE" | cut -d \  -f 1`
+            OPTION=`echo "$LINE" | cut -d \  -f 2`
+
+            if test -z "$NAME"; then
+                continue
+            fi
+
+            if test "$NAME" == "CLEAR"; then
+                echo "parseconfig: CLEAR"
+                echo > .config
+            fi
+
+            echo "parseconfig: removing $NAME"
+            sed -i /^$NAME=/d .config
+
+            if test "$OPTION" != n; then
+                echo "parseconfig: setting $NAME=$OPTION"
+                echo "$NAME=$OPTION" >> .config
+            fi
+        done
+        set +x
+    }
+  '';
+
+  archMakeFlag = if (cross != null) then "ARCH=${cross.arch}" else "";
+  crossMakeFlag = if (cross != null) then "CROSS=${cross.config}-" else "";
+
+  nixConfig = ''
+    RUNTIME_PREFIX "/"
+    DEVEL_PREFIX "/"
+    UCLIBC_HAS_WCHAR y
+    UCLIBC_HAS_FTW y
+    UCLIBC_HAS_RPC y
+    DO_C99_MATH y
+    UCLIBC_HAS_PROGRAM_INVOCATION_NAME y
+    KERNEL_HEADERS "${linuxHeaders}/include"
+  '';
+
 in
 stdenv.mkDerivation {
-  name = "uclibc-0.9.30.3" + stdenv.lib.optionalString (cross != null)
+  name = "uclibc-0.9.31" + stdenv.lib.optionalString (cross != null)
     ("-" + cross.config);
 
   src = fetchurl {
-    url = http://www.uclibc.org/downloads/uClibc-0.9.30.3.tar.bz2;
-    sha256 = "0f1fpdwampbw7pf79i64ipj0azk4kbc9wl81ynlp19p92k4klz0h";
+    url = http://www.uclibc.org/downloads/uClibc-0.9.31.tar.bz2;
+    sha256 = "1yk328fnz0abgh2vm2r68y65ckfkx97rdp8hbg4xvmx5s94kblw0";
   };
 
+  # 'ftw' needed to build acl, a coreutils dependency
   configurePhase = ''
     make defconfig ${archMakeFlag}
-    sed -e s@/usr/include@${linuxHeaders}/include@ \
-      -e 's@^RUNTIME_PREFIX.*@RUNTIME_PREFIX="/"@' \
-      -e 's@^DEVEL_PREFIX.*@DEVEL_PREFIX="/"@' \
-      -e 's@.*UCLIBC_HAS_WCHAR.*@UCLIBC_HAS_WCHAR=y@' \
-      -e 's@.*UCLIBC_HAS_RPC.*@UCLIBC_HAS_RPC=y@' \
-      -e 's@.*DO_C99_MATH.*@DO_C99_MATH=y@' \
-      -e 's@.*UCLIBC_HAS_PROGRAM_INVOCATION_NAME.*@UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y@' \
-      ${configArmEABI} \
-      ${configBigEndian} \
-      -i .config
+    ${configParser}
+    cat << EOF | parseconfig
+    ${nixConfig}
+    ${extraConfig}
+    ${if cross != null then stdenv.lib.attrByPath [ "uclibc" "extraConfig" ] "" cross else ""}
+    $extraCrossConfig
+    EOF
     make oldconfig
   '';
 
@@ -59,6 +83,11 @@ stdenv.mkDerivation {
     (cd $out/include && ln -s $(ls -d ${linuxHeaders}/include/* | grep -v "scsi$") .)
     sed -i s@/lib/@$out/lib/@g $out/lib/libc.so
   '';
+
+  passthru = {
+    # Derivations may check for the existance of this attribute, to know what to link to.
+    inherit libiconv;
+  };
   
   meta = {
     homepage = http://www.uclibc.org/;
diff --git a/pkgs/os-specific/linux/util-linux-ng/default.nix b/pkgs/os-specific/linux/util-linux-ng/default.nix
index ca21deb648903..60ffeb7073763 100644
--- a/pkgs/os-specific/linux/util-linux-ng/default.nix
+++ b/pkgs/os-specific/linux/util-linux-ng/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, ncurses ? null }:
 
 stdenv.mkDerivation rec {
-  name = "util-linux-ng-2.17.2";
+  name = "util-linux-ng-2.18";
 
   src = fetchurl {
-    url = "mirror://kernel/linux/utils/util-linux-ng/v2.17/${name}.tar.bz2";
-    sha256 = "13qifk3i1x59q45fpdz8qnnm7vrhd2zshy5295vhpcjsd8dq1bn9";
+    url = "mirror://kernel/linux/utils/util-linux-ng/v2.18/${name}.tar.bz2";
+    sha256 = "1k1in1ba9kvh0kplri9765wh0yk68qrkk1a55dqsm21qfryc1idq";
   };
 
   configureFlags = ''
diff --git a/pkgs/servers/http/apache-httpd/default.nix b/pkgs/servers/http/apache-httpd/default.nix
index 6048a2fa81b04..962cefd097409 100644
--- a/pkgs/servers/http/apache-httpd/default.nix
+++ b/pkgs/servers/http/apache-httpd/default.nix
@@ -19,6 +19,11 @@ stdenv.mkDerivation rec {
   buildInputs = [perl apr aprutil pcre] ++
     stdenv.lib.optional sslSupport openssl;
 
+  # An apr-util header file includes an apr header file
+  # through #include "" (quotes)
+  # passing simply CFLAGS did not help, then I go by NIX_CFLAGS_COMPILE
+  NIX_CFLAGS_COMPILE = "-iquote ${apr}/include/apr-1";
+
   configureFlags = ''
     --with-z=${zlib}
     --with-pcre=${pcre}
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix
index 0075820a5adc7..16597d70c1ac7 100644
--- a/pkgs/stdenv/adapters.nix
+++ b/pkgs/stdenv/adapters.nix
@@ -179,7 +179,9 @@ rec {
         in buildDrv // {
             inherit hostDrv buildDrv;
         };
-    } // { inherit cross; };
+    } // {
+      inherit cross gccCross binutilsCross;
+    };
 
     
   /* Modify a stdenv so that the specified attributes are added to
diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix
index 40acb8cfece49..11af6d371cdcb 100644
--- a/pkgs/stdenv/default.nix
+++ b/pkgs/stdenv/default.nix
@@ -10,7 +10,7 @@
 # system, e.g., cygwin and mingw builds on i686-cygwin.  Most people
 # can ignore it.
 
-{system, stdenvType ? system, allPackages ? import ../..}:
+{system, stdenvType ? system, allPackages ? import ../.., platform}:
 
 assert system != "i686-cygwin" -> system == stdenvType;
 
@@ -41,7 +41,7 @@ rec {
 
 
   # Linux standard environment.
-  stdenvLinux = (import ./linux {inherit system allPackages;}).stdenvLinux;
+  stdenvLinux = (import ./linux {inherit system allPackages platform;}).stdenvLinux;
 
     
   # MinGW/MSYS standard environment.
@@ -55,6 +55,7 @@ rec {
     if stdenvType == "i686-linux" then stdenvLinux else
     if stdenvType == "x86_64-linux" then stdenvLinux else
     if stdenvType == "armv5tel-linux" then stdenvLinux else
+    if stdenvType == "mips64-linux" then stdenvLinux else
     if stdenvType == "powerpc-linux" then /* stdenvLinux */ stdenvNative else
     if stdenvType == "i686-mingw" then stdenvMinGW else
     if stdenvType == "i686-darwin" then stdenvNix else
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index f19addc8a51d2..c4d6a3666d0d4 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -96,7 +96,8 @@ let
         isLinux = result.system == "i686-linux"
                || result.system == "x86_64-linux"
                || result.system == "powerpc-linux"
-               || result.system == "armv5tel-linux";
+               || result.system == "armv5tel-linux"
+               || result.system == "mips64-linux";
         isSunOS = result.system == "i386-sunos";
         isCygwin = result.system == "i686-cygwin";
 	isFreeBSD = result.system == "i686-freebsd"
@@ -118,6 +119,9 @@ let
                || result.system == "x86_64-openbsd";
         is64bit = result.system == "x86_64-linux"
                 || result.system == "x86_64-darwin";
+        isMips = result.system == "mips-linux"
+                || result.system == "mips64-linux";
+        isArm = result.system == "armv5tel-linux";
 
         # Utility function: allow stdenv to be easily regenerated with
         # a different setup script.  (See all-packages.nix for an
diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh
index 948b6ca3ad667..ba06666ca8987 100644
--- a/pkgs/stdenv/generic/setup.sh
+++ b/pkgs/stdenv/generic/setup.sh
@@ -231,6 +231,9 @@ if test "$NIX_NO_SELF_RPATH" != "1"; then
     if test -n "$NIX_LIB64_IN_SELF_RPATH"; then
         export NIX_LDFLAGS="-rpath $out/lib64 $NIX_LDFLAGS"
     fi
+    if test -n "$NIX_LIB32_IN_SELF_RPATH"; then
+        export NIX_LDFLAGS="-rpath $out/lib32 $NIX_LDFLAGS"
+    fi
 fi
 
 
diff --git a/pkgs/stdenv/linux/bootstrap/loongson2f/bzip2 b/pkgs/stdenv/linux/bootstrap/loongson2f/bzip2
new file mode 100755
index 0000000000000..f86964d119c28
--- /dev/null
+++ b/pkgs/stdenv/linux/bootstrap/loongson2f/bzip2
Binary files differdiff --git a/pkgs/stdenv/linux/bootstrap/loongson2f/cpio b/pkgs/stdenv/linux/bootstrap/loongson2f/cpio
new file mode 100755
index 0000000000000..bf6fd66be2383
--- /dev/null
+++ b/pkgs/stdenv/linux/bootstrap/loongson2f/cpio
Binary files differdiff --git a/pkgs/stdenv/linux/bootstrap/loongson2f/curl.bz2 b/pkgs/stdenv/linux/bootstrap/loongson2f/curl.bz2
new file mode 100755
index 0000000000000..f227a24bf7188
--- /dev/null
+++ b/pkgs/stdenv/linux/bootstrap/loongson2f/curl.bz2
Binary files differdiff --git a/pkgs/stdenv/linux/bootstrap/loongson2f/default.nix b/pkgs/stdenv/linux/bootstrap/loongson2f/default.nix
new file mode 100644
index 0000000000000..a87f07e00cebc
--- /dev/null
+++ b/pkgs/stdenv/linux/bootstrap/loongson2f/default.nix
@@ -0,0 +1,13 @@
+{
+  sh = ./sh;
+  bzip2 = ./bzip2;
+  mkdir = ./mkdir;
+  cpio = ./cpio;
+  ln = ./ln;
+  curl = ./curl.bz2;
+
+  bootstrapTools = {
+    url = "file:///root/cross-bootstrap-tools.cpio.bz2";
+    sha256 = "00aavbk76qjj2gdlmpaaj66r8nzl4d7pyl8cv1gigyzgpbr5vv3j";
+  };
+}
diff --git a/pkgs/stdenv/linux/bootstrap/loongson2f/ln b/pkgs/stdenv/linux/bootstrap/loongson2f/ln
new file mode 100755
index 0000000000000..d8afd276424f1
--- /dev/null
+++ b/pkgs/stdenv/linux/bootstrap/loongson2f/ln
Binary files differdiff --git a/pkgs/stdenv/linux/bootstrap/loongson2f/mkdir b/pkgs/stdenv/linux/bootstrap/loongson2f/mkdir
new file mode 100755
index 0000000000000..3a95ccf18d6e5
--- /dev/null
+++ b/pkgs/stdenv/linux/bootstrap/loongson2f/mkdir
Binary files differdiff --git a/pkgs/stdenv/linux/bootstrap/loongson2f/sh b/pkgs/stdenv/linux/bootstrap/loongson2f/sh
new file mode 100755
index 0000000000000..f8ef0a74d6bf9
--- /dev/null
+++ b/pkgs/stdenv/linux/bootstrap/loongson2f/sh
Binary files differdiff --git a/pkgs/stdenv/linux/bootstrap/x86_64/default.nix b/pkgs/stdenv/linux/bootstrap/x86_64/default.nix
index ffd23a8660390..d9b9b460db244 100644
--- a/pkgs/stdenv/linux/bootstrap/x86_64/default.nix
+++ b/pkgs/stdenv/linux/bootstrap/x86_64/default.nix
@@ -4,7 +4,7 @@
 
 {
   bootstrapTools = {
-    url = http://nixos.org/tarballs/stdenv-linux/x86_64/r16022/bootstrap-tools.cpio.bz2;
-    sha256 = "1hwmyd9x9lhmb1ckwap2lvf7wi34p1j23v5bw41drym4mfp97ynz";
+    url = http://nixos.org/tarballs/stdenv-linux/x86_64/r23302/bootstrap-tools.cpio.bz2;
+    sha256 = "0w89kqhx47yl0jifp2vffp073pyrqha5f312kp971smi4h41drna";
   };
 }
diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix
index 71aee5912e7fd..af98fd98b74d4 100644
--- a/pkgs/stdenv/linux/default.nix
+++ b/pkgs/stdenv/linux/default.nix
@@ -5,7 +5,7 @@
 # ensuring purity of components produced by it.
 
 # The function defaults are for easy testing.
-{system ? "i686-linux", allPackages ? import ../../top-level/all-packages.nix}:
+{system ? "i686-linux", allPackages ? import ../../top-level/all-packages.nix, platform}:
 
 rec {
 
@@ -14,6 +14,7 @@ rec {
     else if system == "x86_64-linux" then import ./bootstrap/x86_64
     else if system == "powerpc-linux" then import ./bootstrap/powerpc
     else if system == "armv5tel-linux" then import ./bootstrap/armv5tel
+    else if system == "mips64-linux" then import ./bootstrap/loongson2f
     else abort "unsupported platform for the pure Linux stdenv";
 
 
@@ -22,6 +23,7 @@ rec {
       export NIX_ENFORCE_PURITY=1
       havePatchELF=1
       ${if system == "x86_64-linux" then "NIX_LIB64_IN_SELF_RPATH=1" else ""}
+      ${if system == "mips64-linux" then "NIX_LIB32_IN_SELF_RPATH=1" else ""}
     '';
 
 
@@ -89,7 +91,10 @@ rec {
       shell = "${bootstrapTools}/bin/sh";
       initialPath = [bootstrapTools] ++ extraPath;
       fetchurlBoot = fetchurl;
-      inherit gcc extraAttrs;
+      inherit gcc;
+      # Having the proper 'platform' in all the stdenvs allows getting proper
+      # linuxHeaders for example.
+      extraAttrs = extraAttrs // { inherit platform; };
       overrides = overrides // {
         inherit fetchurl;
       };
@@ -149,24 +154,46 @@ rec {
   
 
   # 2) These are the packages that we can build with the first
-  #    stdenv.  We only need Glibc (in step 3).
+  #    stdenv.  We only need binutils, because recent glibcs
+  #    require recent binutils, and those in bootstrap-tools may
+  #    be too old. (in step 3).
   stdenvLinuxBoot1Pkgs = allPackages {
-    inherit system;
+    inherit system platform;
     bootStdenv = stdenvLinuxBoot1;
   };
 
+  firstBinutils = stdenvLinuxBoot1Pkgs.binutils;
+
+  # 3) 2nd stdenv that we will use to build only the glibc.
+  stdenvLinuxBoot2 = stdenvBootFun {
+    gcc = wrapGCC {
+      libc = bootstrapGlibc;
+      binutils = firstBinutils;
+      coreutils = bootstrapTools;
+    };
+    inherit fetchurl;
+  };
+
+
+  # 4) These are the packages that we can build with the 2nd
+  #    stdenv.  We only need Glibc (in step 5).
+  stdenvLinuxBoot2Pkgs = allPackages {
+    inherit system platform;
+    bootStdenv = stdenvLinuxBoot2;
+  };
+
   
-  # 3) Build Glibc with the bootstrap tools.  The result is the full,
+  # 5) Build Glibc with the bootstrap tools.  The result is the full,
   #    dynamically linked, final Glibc.
-  stdenvLinuxGlibc = stdenvLinuxBoot1Pkgs.glibc;
+  stdenvLinuxGlibc = stdenvLinuxBoot2Pkgs.glibc;
 
   
-  # 4) Construct a second stdenv identical to the first, except that
+  # 6) Construct a third stdenv identical to the 2nd, except that
   #    this one uses the Glibc built in step 3.  It still uses
-  #    the rest of the bootstrap tools, including GCC.
-  stdenvLinuxBoot2 = removeAttrs (stdenvBootFun {
+  #    the recent binutils and rest of the bootstrap tools, including GCC.
+  stdenvLinuxBoot3 = removeAttrs (stdenvBootFun {
     gcc = wrapGCC {
-      binutils = bootstrapTools;
+      binutils = stdenvLinuxBoot1Pkgs.binutils;
       coreutils = bootstrapTools;
       libc = stdenvLinuxGlibc;
     };
@@ -178,23 +205,35 @@ rec {
   }) ["gcc" "binutils"];
 
   
-  # 5) The packages that can be built using the second stdenv.
-  stdenvLinuxBoot2Pkgs = allPackages {
-    inherit system;
-    bootStdenv = stdenvLinuxBoot2;
+  # 7) The packages that can be built using the third stdenv.
+  stdenvLinuxBoot3Pkgs = allPackages {
+    inherit system platform;
+    bootStdenv = stdenvLinuxBoot3;
   };
 
-
-  # 6) Construct a third stdenv identical to the second, except that
+  gccWithStaticLibs = stdenvLinuxBoot3Pkgs.gcc.gcc.override (rec {
+        ppl = stdenvLinuxBoot3Pkgs.ppl.override {
+          static = true;
+          gmpxx = stdenvLinuxBoot3Pkgs.gmpxx.override {
+            static = true;
+          };
+        };
+        cloogppl = stdenvLinuxBoot3Pkgs.cloogppl.override {
+          inherit ppl;
+          static = true;
+        };
+      });
+
+  # 8) Construct a fourth stdenv identical to the second, except that
   #    this one uses the dynamically linked GCC and Binutils from step
   #    5.  The other tools (e.g. coreutils) are still from the
   #    bootstrap tools.
-  stdenvLinuxBoot3 = stdenvBootFun {
+  stdenvLinuxBoot4 = stdenvBootFun {
     gcc = wrapGCC rec {
-      inherit (stdenvLinuxBoot2Pkgs) binutils;
+      inherit (stdenvLinuxBoot3Pkgs) binutils;
       coreutils = bootstrapTools;
       libc = stdenvLinuxGlibc;
-      gcc = stdenvLinuxBoot2Pkgs.gcc.gcc;
+      gcc = gccWithStaticLibs;
       name = "";
     };
     overrides = {
@@ -204,19 +243,20 @@ rec {
   };
 
   
-  # 7) The packages that can be built using the third stdenv.
-  stdenvLinuxBoot3Pkgs = allPackages {
-    inherit system;
-    bootStdenv = stdenvLinuxBoot3;
+  # 9) The packages that can be built using the fourth stdenv.
+  stdenvLinuxBoot4Pkgs = allPackages {
+    inherit system platform;
+    bootStdenv = stdenvLinuxBoot4;
   };
 
   
-  # 8) Construct the final stdenv.  It uses the Glibc, GCC and
-  #    Binutils built above, and adds in dynamically linked versions
-  #    of all other tools.
+  # 10) Construct the final stdenv.  It uses the Glibc, GCC and
+  #     Binutils built above, and adds in dynamically linked versions
+  #     of all other tools.
   #
-  #    When updating stdenvLinux, make sure that the result has no
-  #    dependency (`nix-store -qR') on bootstrapTools.
+  #     When updating stdenvLinux, make sure that the result has no
+  #     dependency (`nix-store -qR') on bootstrapTools or the
+  #     first binutils built.
   stdenvLinux = import ../generic rec {
     name = "stdenv-linux";
     
@@ -225,30 +265,31 @@ rec {
     preHook = builtins.toFile "prehook.sh" commonPreHook;
     
     initialPath = 
-      ((import ../common-path.nix) {pkgs = stdenvLinuxBoot3Pkgs;})
-      ++ [stdenvLinuxBoot3Pkgs.patchelf];
+      ((import ../common-path.nix) {pkgs = stdenvLinuxBoot4Pkgs;})
+      ++ [stdenvLinuxBoot4Pkgs.patchelf];
 
     gcc = wrapGCC rec {
-      inherit (stdenvLinuxBoot2Pkgs) binutils;
-      inherit (stdenvLinuxBoot3Pkgs) coreutils;
+      inherit (stdenvLinuxBoot3Pkgs) binutils;
+      inherit (stdenvLinuxBoot4Pkgs) coreutils;
       libc = stdenvLinuxGlibc;
-      gcc = stdenvLinuxBoot2Pkgs.gcc.gcc;
-      shell = stdenvLinuxBoot3Pkgs.bash + "/bin/bash";
+      gcc = gccWithStaticLibs;
+      shell = stdenvLinuxBoot4Pkgs.bash + "/bin/bash";
       name = "";
     };
 
-    shell = stdenvLinuxBoot3Pkgs.bash + "/bin/bash";
+    shell = stdenvLinuxBoot4Pkgs.bash + "/bin/bash";
     
     fetchurlBoot = fetchurl;
     
     extraAttrs = {
-      inherit (stdenvLinuxBoot2Pkgs) glibc;
+      inherit (stdenvLinuxBoot3Pkgs) glibc;
+      inherit platform;
     };
 
     overrides = {
       inherit gcc;
-      inherit (stdenvLinuxBoot2Pkgs) binutils glibc;
-      inherit (stdenvLinuxBoot3Pkgs)
+      inherit (stdenvLinuxBoot3Pkgs) binutils glibc;
+      inherit (stdenvLinuxBoot4Pkgs)
         gzip bzip2 bash coreutils diffutils findutils gawk
         gnumake gnused gnutar gnugrep gnupatch patchelf
         attr acl;
diff --git a/pkgs/stdenv/linux/make-bootstrap-tools.nix b/pkgs/stdenv/linux/make-bootstrap-tools.nix
index 3f68738c3108b..b89523cbc853b 100644
--- a/pkgs/stdenv/linux/make-bootstrap-tools.nix
+++ b/pkgs/stdenv/linux/make-bootstrap-tools.nix
@@ -10,7 +10,15 @@ rec {
     aclSupport = false;
   });
 
-  gccLinkStatic = wrapGCCWith (import ../../build-support/gcc-wrapper) uclibc
+  # bzip2 wants utime.h, a header 'legacy' in uclibc
+  uclibcForBzip2 = uclibc.override {
+    extraConfig = ''
+        UCLIBC_SUSV3_LEGACY y
+        UCLIBC_SUSV4_LEGACY y
+    '';
+  };
+
+  gccLinkStatic = wrapGCCWith (import ../../build-support/gcc-wrapper) uclibcForBzip2
     stdenv.gcc.gcc;
   stdenvLinkStatic = overrideGCC stdenv gccLinkStatic;
 
@@ -31,6 +39,49 @@ rec {
 
   #gccNoShared = wrapGCC ( gcc.gcc.override { enableShared = false; } );
 
+  busyboxStaticSh = busybox.override {
+    extraConfig = ''
+      CLEAR
+      CONFIG_STATIC y
+
+      CONFIG_ASH y
+      CONFIG_BASH_COMPAT y
+      CONFIG_ASH_ALIAS y
+      CONFIG_ASH_GETOPTS y
+      CONFIG_ASH_CMDCMD y
+      CONFIG_ASH_JOB_CONTROL y
+      CONFIG_ASH_BUILTIN_ECHO y
+      CONFIG_ASH_BUILTIN_PRINTF y
+      CONFIG_ASH_BUILTIN_TEST y
+    '';
+  };
+
+  busyboxStaticLn = busybox.override {
+    extraConfig = ''
+      CLEAR
+      CONFIG_STATIC y
+      CONFIG_LN y
+    '';
+  };
+
+  busyboxStaticMkdir = busybox.override {
+    extraConfig = ''
+      CLEAR
+      CONFIG_STATIC y
+      CONFIG_MKDIR y
+    '';
+  };
+
+  busyboxStaticCpio = busybox.override {
+    extraConfig = ''
+      CLEAR
+      CONFIG_STATIC y
+      CONFIG_CPIO y
+      CONFIG_FEATURE_CPIO_O y
+      CONFIG_FEATURE_CPIO_P y
+    '';
+  };
+
   build = 
 
     stdenv.mkDerivation {
@@ -43,7 +94,7 @@ rec {
         ensureDir $out/bin $out/lib $out/libexec
 
         # Copy what we need of Glibc.
-        cp -d ${glibc}/lib/ld-*.so* $out/lib
+        cp -d ${glibc}/lib/ld*.so* $out/lib
         cp -d ${glibc}/lib/libc*.so* $out/lib
         cp -d ${glibc}/lib/libc_nonshared.a $out/lib
         cp -d ${glibc}/lib/libm*.so* $out/lib
@@ -80,7 +131,7 @@ rec {
         cp ${bzip2}/bin/bzip2 $out/bin
         cp -d ${gnumake}/bin/* $out/bin
         cp -d ${patch}/bin/* $out/bin
-        cp ${patchelf05}/bin/* $out/bin
+        cp ${patchelf}/bin/* $out/bin
         cp ${replace}/bin/* $out/bin
 
         cp -d ${gnugrep.pcre}/lib/libpcre*.so* $out/lib # needed by grep
@@ -97,6 +148,7 @@ rec {
         rm -f $out/lib/gcc/*/*/include*/sound
         rm -rf $out/lib/gcc/*/*/include*/root
         rm -f $out/lib/gcc/*/*/include-fixed/asm
+        rm -rf $out/lib/gcc/*/*/plugin
         #rm -f $out/lib/gcc/*/*/*.a
         cp -rd ${gcc.gcc}/libexec/* $out/libexec
         mkdir $out/include
@@ -105,10 +157,13 @@ rec {
         rm -rf $out/include/c++/*/ext/pb_ds
         rm -rf $out/include/c++/*/ext/parallel
 
-        cp -d ${gmp}/lib/libgmp*.so* $out/lib
+        cp -d ${gmpxx}/lib/libgmp*.so* $out/lib
         cp -d ${mpfr}/lib/libmpfr*.so* $out/lib
         cp -d ${ppl}/lib/libppl*.so* $out/lib
         cp -d ${cloogppl}/lib/libcloog*.so* $out/lib
+        cp -d ${mpc}/lib/libmpc*.so* $out/lib
+        cp -d ${zlib}/lib/libz.so* $out/lib
+        cp -d ${libelf}/lib/libelf.so* $out/lib
         
         # Copy binutils.
         for i in as ld ar ranlib nm strip readelf objdump; do
@@ -137,10 +192,10 @@ rec {
         (cd $out/pack && (find | cpio -o -H newc)) | bzip2 > $out/on-server/bootstrap-tools.cpio.bz2
 
         mkdir $out/in-nixpkgs
-        cp ${klibc}/lib/klibc/bin.static/sh $out/in-nixpkgs
-        cp ${klibc}/lib/klibc/bin.static/cpio $out/in-nixpkgs
-        cp ${klibc}/lib/klibc/bin.static/mkdir $out/in-nixpkgs
-        cp ${klibc}/lib/klibc/bin.static/ln $out/in-nixpkgs
+        cp ${busyboxStaticSh}/bin/busybox $out/in-nixpkgs/sh
+        cp ${busyboxStaticCpio}/bin/busybox $out/in-nixpkgs/cpio
+        cp ${busyboxStaticMkdir}/bin/busybox $out/in-nixpkgs/mkdir
+        cp ${busyboxStaticLn}/bin/busybox $out/in-nixpkgs/ln
         cp ${curlStatic}/bin/curl $out/in-nixpkgs
         cp ${bzip2Static}/bin/bzip2 $out/in-nixpkgs
         chmod u+w $out/in-nixpkgs/*
diff --git a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh
index 2399e48b026fe..422dc6dd5feff 100644
--- a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh
+++ b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh
@@ -3,31 +3,49 @@ set -e
 # Unpack the bootstrap tools tarball.
 echo Unpacking the bootstrap tools...
 $mkdir $out
-$bzip2 -d < $tarball | (cd $out && $cpio -V -i)
+$bzip2 -d < $tarball | (cd $out && $cpio -i)
 
 # Set the ELF interpreter / RPATH in the bootstrap binaries.
 echo Patching the bootstrap tools...
 
+if test -f $out/lib/ld.so.?; then
+   # MIPS case
+   LD_BINARY=$out/lib/ld.so.?
+else
+   # i686, x86_64 and armv5tel
+   LD_BINARY=$out/lib/ld-*so.?
+fi
+
 # On x86_64, ld-linux-x86-64.so.2 barfs on patchelf'ed programs.  So
 # use a copy of patchelf.
-LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? $out/bin/cp $out/bin/patchelf .
+LD_LIBRARY_PATH=$out/lib $LD_BINARY $out/bin/cp $out/bin/patchelf .
 
 for i in $out/bin/* $out/libexec/gcc/*/*/*; do
     echo patching $i
     if ! test -L $i; then
-         LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \
-             $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i
-         LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \
-             $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i
+         LD_LIBRARY_PATH=$out/lib $LD_BINARY \
+             $out/bin/patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath $i
+         LD_LIBRARY_PATH=$out/lib $LD_BINARY \
+             $out/bin/patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath $i
     fi
 done
 for i in $out/lib/librt* ; do
     echo patching $i
     if ! test -L $i; then
-         LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \
-             $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i
-         LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \
-             $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i
+         LD_LIBRARY_PATH=$out/lib $LD_BINARY \
+             $out/bin/patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath $i
+         LD_LIBRARY_PATH=$out/lib $LD_BINARY \
+             $out/bin/patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath $i
+    fi
+done
+
+for i in $out/lib/libgmp* $out/lib/libppl* $out/lib/libcloog* $out/lib/libmpc* $out/lib/libpcre* $out/lib/libstdc++*.so.*[0-9]; do
+    echo trying to patch $i
+    if test -f $i -a ! -L $i; then
+         LD_LIBRARY_PATH=$out/lib $LD_BINARY \
+             $out/bin/patchelf --set-rpath $out/lib --force-rpath $i
+         LD_LIBRARY_PATH=$out/lib $LD_BINARY \
+             $out/bin/patchelf --set-rpath $out/lib --force-rpath $i
     fi
 done
 
diff --git a/pkgs/tools/archivers/gnutar/default.nix b/pkgs/tools/archivers/gnutar/default.nix
index a49b4de52b0fd..a74b60d951746 100644
--- a/pkgs/tools/archivers/gnutar/default.nix
+++ b/pkgs/tools/archivers/gnutar/default.nix
@@ -1,14 +1,12 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation rec {
-  name = "gnutar-1.22";
-  
+  name = "gnutar-1.23";
+
   src = fetchurl {
-    url = "mirror://gnu/tar/tar-1.22.tar.bz2";
-    sha256 = "0kdaadflxa6wznbbrp0xlxk9926hrr4yg7wr6m98ygvs35zvdvrw";
+    url = "mirror://gnu/tar/tar-1.23.tar.bz2";
+    sha256 = "0dmyxsh0171m6nv8aw74dps1l4b1r7pkqkly9kcv3yv2vdr86cn9";
   };
-  
-  patches = [./implausible.patch];
 
   meta = {
     homepage = http://www.gnu.org/software/tar/;
@@ -30,5 +28,8 @@ stdenv.mkDerivation rec {
     '';
 
     license = "GPLv3+";
+
+    maintainers = [ stdenv.lib.maintainers.ludo ];
+    platforms = stdenv.lib.platforms.all;
   };
 }
diff --git a/pkgs/tools/archivers/gnutar/implausible.patch b/pkgs/tools/archivers/gnutar/implausible.patch
deleted file mode 100644
index a3522c7435056..0000000000000
--- a/pkgs/tools/archivers/gnutar/implausible.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-diff -rc tar-1.16.1-orig/src/extract.c tar-1.16.1/src/extract.c
-*** tar-1.16.1-orig/src/extract.c	2006-12-07 14:26:00.000000000 +0100
---- tar-1.16.1/src/extract.c	2007-05-24 11:39:47.000000000 +0200
-***************
-*** 194,200 ****
-  static void
-  check_time (char const *file_name, struct timespec t)
-  {
-!   if (t.tv_sec <= 0)
-      WARN ((0, 0, _("%s: implausibly old time stamp %s"),
-  	   file_name, tartime (t, true)));
-    else if (timespec_cmp (volume_start_time, t) < 0)
---- 194,200 ----
-  static void
-  check_time (char const *file_name, struct timespec t)
-  {
-!   if (0 /* t.tv_sec <= 0 */)
-      WARN ((0, 0, _("%s: implausibly old time stamp %s"),
-  	   file_name, tartime (t, true)));
-    else if (timespec_cmp (volume_start_time, t) < 0)
diff --git a/pkgs/tools/compression/bzip2/default.nix b/pkgs/tools/compression/bzip2/default.nix
index 0523067cbade6..e8ac6c6418cb6 100644
--- a/pkgs/tools/compression/bzip2/default.nix
+++ b/pkgs/tools/compression/bzip2/default.nix
@@ -10,6 +10,16 @@ stdenv.mkDerivation {
     sha256 = "08py2s9vw6dgw457lbklh1vsr3b8x8dlv7d8ygdfaxlx61l57gzp";
   };
 
+  crossAttrs = {
+    patchPhase = ''
+      sed -i -e 's/CC=gcc/CC=${stdenv.cross.config}-gcc/' \
+        -e 's/AR=ar/AR=${stdenv.cross.config}-ar/' \
+        -e 's/RANLIB=ranlib/RANLIB=${stdenv.cross.config}-ranlib/' \
+        -e 's/bzip2recover test/bzip2recover/' \
+        Makefile*
+    '';
+  };
+
   sharedLibrary =
     !stdenv.isDarwin && !(stdenv ? isDietLibC) && !(stdenv ? isStatic) && stdenv.system != "i686-cygwin" && !linkStatic;
 
diff --git a/pkgs/tools/compression/gzip/default.nix b/pkgs/tools/compression/gzip/default.nix
index 7a25b69c013d7..b32bbb932e843 100644
--- a/pkgs/tools/compression/gzip/default.nix
+++ b/pkgs/tools/compression/gzip/default.nix
@@ -1,15 +1,13 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation rec {
-  name = "gzip-1.3.13";
+  name = "gzip-1.4";
 
   src = fetchurl {
     url = "mirror://gnu/gzip/${name}.tar.gz";
-    sha256 = "18vwa7x0b1sql9bs2d15n94fx3him1m6xpnwsfz52djjbjgzy1hx";
+    sha256 = "1vhiyzls60fws48scw48wvwn8mpv1f4yhcsnafys239qvb9wyrni";
   };
 
-  patches = [ ./getopt.patch ];
-
   doCheck = true;
 
   meta = {
diff --git a/pkgs/tools/compression/gzip/getopt.patch b/pkgs/tools/compression/gzip/getopt.patch
deleted file mode 100644
index e61dd97781079..0000000000000
--- a/pkgs/tools/compression/gzip/getopt.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-See http://lists.gnu.org/archive/html/bug-gnulib/2009-10/msg00089.html .
-
-From dd0ebefe4fe761f6f422a400430db53c64dbffd7 Mon Sep 17 00:00:00 2001
-From: Eric Blake <ebb9@byu.net>
-Date: Tue, 6 Oct 2009 20:44:13 -0600
-Subject: [PATCH] getopt: fix compilation on darwin
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-* lib/getopt.in.h (includes): Leave breadcrumbs during system
-include.
-* lib/unistd.in.h (getopt): Use them to avoid recursive include.
-Reported by Ludovic Courtès.
-
-Signed-off-by: Eric Blake <ebb9@byu.net>
----
- ChangeLog       |    5 +++++
- lib/getopt.in.h |    6 +++++-
- lib/unistd.in.h |    2 +-
- 3 files changed, 11 insertions(+), 2 deletions(-)
-
-diff --git a/lib/getopt.in.h b/lib/getopt.in.h
-index 9de467a..7377f3c 100644
---- a/lib/getopt.in.h
-+++ b/lib/getopt.in.h
-@@ -22,9 +22,13 @@
- @PRAGMA_SYSTEM_HEADER@
- #endif
-
--/* The include_next requires a split double-inclusion guard.  */
-+/* The include_next requires a split double-inclusion guard.  We must
-+   also inform the replacement unistd.h to not recursively use
-+   <getopt.h>; our definitions will be present soon enough.  */
- #if @HAVE_GETOPT_H@
-+# define _GL_SYSTEM_GETOPT
- # @INCLUDE_NEXT@ @NEXT_GETOPT_H@
-+# undef _GL_SYSTEM_GETOPT
- #endif
-
- #ifndef _GL_GETOPT_H
-diff --git a/lib/unistd.in.h b/lib/unistd.in.h
-index 38e2e13..b6ea889 100644
---- a/lib/unistd.in.h
-+++ b/lib/unistd.in.h
-@@ -49,7 +49,7 @@
- #endif
-
- /* Get getopt(), optarg, optind, opterr, optopt.  */
--#if @GNULIB_UNISTD_H_GETOPT@
-+#if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
- # include <getopt.h>
- #endif
-
diff --git a/pkgs/tools/filesystems/btrfsprogs/default.nix b/pkgs/tools/filesystems/btrfsprogs/default.nix
index 377f959197525..2a5574a829e35 100644
--- a/pkgs/tools/filesystems/btrfsprogs/default.nix
+++ b/pkgs/tools/filesystems/btrfsprogs/default.nix
@@ -20,7 +20,8 @@ rec {
   configureFlags = [];
   makeFlags = ["prefix=$out"];
 
-  phaseNames = ["doEnsureBtrfsImage" "doMakeInstall"];
+  patches = [ ./glibc212.patch ];
+  phaseNames = ["doPatch" "doEnsureBtrfsImage" "doMakeInstall"];
       
   doEnsureBtrfsImage = a.fullDepEntry (''
     if ! grep 'progs = ' Makefile | grep btrfs-image; then 
diff --git a/pkgs/tools/filesystems/btrfsprogs/glibc212.patch b/pkgs/tools/filesystems/btrfsprogs/glibc212.patch
new file mode 100644
index 0000000000000..8bc1873f5404f
--- /dev/null
+++ b/pkgs/tools/filesystems/btrfsprogs/glibc212.patch
@@ -0,0 +1,12 @@
+diff --git a/btrfsck.c b/btrfsck.c
+index 73f1836..c1f47a1 100644
+--- a/btrfsck.c
++++ b/btrfsck.c
+@@ -21,6 +21,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <fcntl.h>
++#include <sys/stat.h>
+ #include "kerncompat.h"
+ #include "ctree.h"
+ #include "disk-io.h"
diff --git a/pkgs/tools/filesystems/mtdutils/default.nix b/pkgs/tools/filesystems/mtdutils/default.nix
index 4dbd9fe4439f8..f2ce1b452cdf3 100644
--- a/pkgs/tools/filesystems/mtdutils/default.nix
+++ b/pkgs/tools/filesystems/mtdutils/default.nix
@@ -14,6 +14,9 @@ stdenv.mkDerivation {
 
   patchPhase = ''
     sed -i -e s,/usr/local,, -e s,/usr,$out, common.mk
+
+    # gcc 4.5.1 issues a warning where 4.4.3 did not
+    sed -i -e s/-Werror// ubi-utils/old-utils/Makefile
   '';
 
   buildInputs = [ libuuid lzo zlib acl ];
diff --git a/pkgs/tools/filesystems/xfsprogs/default.nix b/pkgs/tools/filesystems/xfsprogs/default.nix
index 4e2cb448eabeb..16aefe1828312 100644
--- a/pkgs/tools/filesystems/xfsprogs/default.nix
+++ b/pkgs/tools/filesystems/xfsprogs/default.nix
@@ -1,16 +1,20 @@
 { stdenv, fetchurl, libtool, gettext, libuuid }:
 
 stdenv.mkDerivation rec {
-  name = "xfsprogs-3.0.3";
+  name = "xfsprogs-3.1.3";
 
   src = fetchurl {
-    url = "ftp://oss.sgi.com/projects/xfs/previous/${name}.tar.gz";
-    sha256 = "158ddibsnwcihfvskwc9rknd28p81jk8z463slafp1gf355kmcsq";
+    urls = [ "ftp://oss.sgi.com/projects/xfs/cmd_tars/${name}.tar.gz" "ftp://oss.sgi.com/projects/xfs/previous/${name}.tar.gz" ];
+    sha256 = "1mazg6sl4gbm204ndgw585xvcsxg3hg22d989ww6lgmycp635l7s";
   };
 
   buildInputs = [ libtool gettext libuuid ];
 
   configureFlags = "MAKE=make MSGFMT=msgfmt MSGMERGE=msgmerge XGETTEXT=xgettext ZIP=gzip AWK=gawk --disable-shared";
+  preConfigure = ''
+    configureFlags="$configureFlags root_sbindir=$out/sbin root_libdir=$out/lib"
+  '';
+  disableStatic = false;
 
   meta = {
     description = "SGI XFS utilities";
diff --git a/pkgs/tools/misc/coreutils/default.nix b/pkgs/tools/misc/coreutils/default.nix
index 8052ce9fa56ab..adf7b955410c6 100644
--- a/pkgs/tools/misc/coreutils/default.nix
+++ b/pkgs/tools/misc/coreutils/default.nix
@@ -1,28 +1,35 @@
-{ stdenv, fetchurl, aclSupport ? false, acl ? null, perl, gmp ? null
-, cross ? null, gccCross ? null }:
+{ stdenv, fetchurl, aclSupport ? false, acl ? null, perl, gmp ? null}:
 
 assert aclSupport -> acl != null;
-assert cross != null -> gccCross != null;
 
-stdenv.mkDerivation (rec {
-  name = "coreutils-8.4";
+stdenv.mkDerivation rec {
+  name = "coreutils-8.5";
 
   src = fetchurl {
     url = "mirror://gnu/coreutils/${name}.tar.gz";
-    sha256 = "0zq11lykc7hfs9nsdnb8gqk354l82hswqj38607mvwj3b0zqvc4b";
+    sha256 = "184cz98a9a6fw5db9hpy05srwxs3jqlvikqf2wxj1vfhqwm3w96x";
   };
 
   buildNativeInputs = [ perl ];
-  buildInputs =
-       stdenv.lib.optional (gmp != null) gmp
-    ++ stdenv.lib.optional aclSupport acl
-    ++ stdenv.lib.optional (gccCross != null) gccCross;
+  buildInputs = [ gmp ] ++ stdenv.lib.optional aclSupport acl;
+
+  crossAttrs = {
+    buildInputs = [ gmp ]
+      ++ stdenv.lib.optional aclSupport acl.hostDrv
+      ++ stdenv.lib.optional (stdenv.gccCross.libc ? libiconv)
+        stdenv.gccCross.libc.libiconv.hostDrv;
+
+    # Needed for fstatfs()
+    # I don't know why it is not properly detected cross building with glibc.
+    configureFlags = [ "fu_cv_sys_stat_statfs2_bsize=yes" ];
+    doCheck = false;
+  };
 
   # The tests are known broken on Cygwin
   # (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19025),
   # Darwin (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19351),
   # and {Open,Free}BSD.
-  doCheck = (stdenv ? glibc) && (cross == null);
+  doCheck = (stdenv ? glibc);
 
   enableParallelBuilding = true;
 
@@ -42,9 +49,3 @@ stdenv.mkDerivation (rec {
     maintainers = [ stdenv.lib.maintainers.ludo ];
   };
 }
-
-//
-
-(if cross != null
- then { crossConfig = cross.config; }
- else { }))
diff --git a/pkgs/tools/misc/findutils/default.nix b/pkgs/tools/misc/findutils/default.nix
index 2350ab2604920..11ed1cf07b56a 100644
--- a/pkgs/tools/misc/findutils/default.nix
+++ b/pkgs/tools/misc/findutils/default.nix
@@ -1,14 +1,14 @@
 {stdenv, fetchurl, coreutils}:
 
 stdenv.mkDerivation rec {
-  name = "findutils-4.4.1";
+  name = "findutils-4.4.2";
 
   src = fetchurl {
     url = "mirror://gnu/findutils/${name}.tar.gz";
-    sha256 = "0f61phan4q8w5i1lz768q973c1spfqgvc470jc89rpg0gxfvi9bp";
+    sha256 = "0amn0bbwqvsvvsh6drfwz20ydc2czk374lzw5kksbh6bf78k4ks3";
   };
 
-  buildInputs = [coreutils];
+  buildNativeInputs = [coreutils];
 
   patches = [ ./findutils-path.patch ./change_echo_path.patch ]
     # Note: the dietlibc patch is just to get findutils to compile.
@@ -17,6 +17,11 @@ stdenv.mkDerivation rec {
 
   doCheck = true;
 
+  crossAttrs = {
+    # http://osdir.com/ml/bug-findutils-gnu/2009-08/msg00026.html
+    configureFlags = [ "gl_cv_func_wcwidth_works=yes" ];
+  };
+
   meta = {
     homepage = http://www.gnu.org/software/findutils/;
     description = "GNU Find Utilities, the basic directory searching utilities of the GNU operating system";
diff --git a/pkgs/tools/networking/curl/default.nix b/pkgs/tools/networking/curl/default.nix
index 33f11cdede578..57ce663080a27 100644
--- a/pkgs/tools/networking/curl/default.nix
+++ b/pkgs/tools/networking/curl/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl
-, zlibSupport ? false, zlib
-, sslSupport ? false, openssl
-, scpSupport ? false, libssh2
+, zlibSupport ? false, zlib ? null
+, sslSupport ? false, openssl ? null
+, scpSupport ? false, libssh2 ? null
 , linkStatic ? false
 }:
 
diff --git a/pkgs/tools/networking/iftop/default.nix b/pkgs/tools/networking/iftop/default.nix
index 79e8f4426cb6e..730b60c7aec2a 100644
--- a/pkgs/tools/networking/iftop/default.nix
+++ b/pkgs/tools/networking/iftop/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, ncurses, libpcap}:
+{stdenv, fetchurl, ncurses, libpcap, automake}:
 
 stdenv.mkDerivation rec {
   name = "iftop-0.17";
@@ -8,6 +8,10 @@ stdenv.mkDerivation rec {
     sha256 = "1b0fis53280qx85gldhmqfcpgyiwplzg43gxyngia1w3f1y58cnh";
   };
 
+  preConfigure = ''
+    cp ${automake}/share/automake*/config.{sub,guess} config
+  '';
+
   buildInputs = [ncurses libpcap];
 
   meta = {
diff --git a/pkgs/tools/package-management/nix/0001-Added-support-for-passing-an-impure-NIX_BUILD_CORES-.patch b/pkgs/tools/package-management/nix/0001-Added-support-for-passing-an-impure-NIX_BUILD_CORES-.patch
new file mode 100644
index 0000000000000..e5c4ba1b01e09
--- /dev/null
+++ b/pkgs/tools/package-management/nix/0001-Added-support-for-passing-an-impure-NIX_BUILD_CORES-.patch
@@ -0,0 +1,126 @@
+From 9c655f52be055d06cbeb3144e14d6135a8d408e0 Mon Sep 17 00:00:00 2001
+From: Peter Simons <simons@cryp.to>
+Date: Tue, 22 Jun 2010 16:59:03 +0200
+Subject: [PATCH] Added support for passing an (impure) NIX_BUILD_CORES variable to build expressions.
+
+This patch adds the configuration file variable "build-cores" and the
+command line argument "--cores". These settings specify the number of
+CPU cores to utilize for parallel building within a job, i.e. by passing
+an appropriate "-j" flag to GNU Make. The default value is 1, which
+means that parallel building is *disabled*. If the number of build cores
+is specified as 0 (synonymously: "guess" or "auto"), then the actual
+value is supposed to be auto-detected by builders at run-time, i.e by
+calling the nproc(1) utility from coreutils.
+
+The environment variable $NIX_BUILD_CORES is available to builders, but
+the contents of that variable does *not* influence the hash that goes
+into the $out store path, i.e. the number of build cores to be utilized
+can be changed at will without requiring any re-builds.
+---
+ nix.conf.example        |   12 ++++++++++++
+ src/libmain/shared.cc   |   14 ++++++++++++++
+ src/libstore/build.cc   |    3 +++
+ src/libstore/globals.cc |    1 +
+ src/libstore/globals.hh |    5 +++++
+ 5 files changed, 35 insertions(+), 0 deletions(-)
+
+diff --git a/nix.conf.example b/nix.conf.example
+index e17cf3c..6175d86 100644
+--- a/nix.conf.example
++++ b/nix.conf.example
+@@ -59,6 +59,18 @@
+ #build-max-jobs = 1
+ 
+ 
++### Option `build-cores'
++#
++# This option defines the number of CPU cores to utilize in parallel
++# within a build job, i.e. by passing an appropriate `-jN' flag to
++# GNU make. The default is 1, meaning that parallel building within
++# jobs is disabled. Passing the special values `0', `auto', or
++# `guess' causes Nix to try and auto-detect the number of available
++# cores on the local host. This setting can be overridden using the
++# `--cores' command line switch.
++#build-cores = 1
++
++
+ ### Option `build-max-silent-time'
+ #
+ # This option defines the maximum number of seconds that a builder can
+diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
+index 3fbec4b..19aa1e7 100644
+--- a/src/libmain/shared.cc
++++ b/src/libmain/shared.cc
+@@ -135,6 +135,12 @@ static void initAndRun(int argc, char * * argv)
+     /* Get some settings from the configuration file. */
+     thisSystem = querySetting("system", SYSTEM);
+     maxBuildJobs = queryIntSetting("build-max-jobs", 1);
++    string tmp = querySetting("build-cores", "/UNDEFINED");
++    std::transform(tmp.begin(), tmp.end(), tmp.begin(), tolower);
++    if (tmp == "auto" || tmp == "guess")
++      buildCores = 0;
++    else
++      buildCores = queryIntSetting("build-cores", 1);
+     maxSilentTime = queryIntSetting("build-max-silent-time", 0);
+ 
+     /* Catch SIGINT. */
+@@ -226,6 +232,14 @@ static void initAndRun(int argc, char * * argv)
+             tryFallback = true;
+         else if (arg == "--max-jobs" || arg == "-j")
+             maxBuildJobs = getIntArg<unsigned int>(arg, i, args.end());
++        else if (arg == "--cores") {
++            string tmp = *(++i);
++            std::transform(tmp.begin(), tmp.end(), tmp.begin(), tolower);
++            if (tmp == "auto" || tmp == "guess")
++              buildCores = 0u;
++            else
++              buildCores = getIntArg<unsigned int>(arg, --i, args.end());
++        }
+         else if (arg == "--readonly-mode")
+             readOnlyMode = true;
+         else if (arg == "--max-silent-time")
+diff --git a/src/libstore/build.cc b/src/libstore/build.cc
+index f901c1f..a53c23b 100644
+--- a/src/libstore/build.cc
++++ b/src/libstore/build.cc
+@@ -1411,6 +1411,9 @@ void DerivationGoal::startBuilder()
+        in the store or in the build directory). */
+     env["NIX_STORE"] = nixStore;
+ 
++    /* The maximum number of cores to utilize for parallel building. */
++    env["NIX_BUILD_CORES"] = (format("%d") % buildCores).str();
++
+     /* Add all bindings specified in the derivation. */
+     foreach (StringPairs::iterator, i, drv.env)
+         env[i->first] = i->second;
+diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc
+index cc0e44e..75d2f69 100644
+--- a/src/libstore/globals.cc
++++ b/src/libstore/globals.cc
+@@ -22,6 +22,7 @@ bool keepGoing = false;
+ bool tryFallback = false;
+ Verbosity buildVerbosity = lvlInfo;
+ unsigned int maxBuildJobs = 1;
++unsigned int buildCores = 1;
+ bool readOnlyMode = false;
+ string thisSystem = "unset";
+ time_t maxSilentTime = 0;
+diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh
+index d3388e3..a74a741 100644
+--- a/src/libstore/globals.hh
++++ b/src/libstore/globals.hh
+@@ -55,6 +55,11 @@ extern Verbosity buildVerbosity;
+ /* Maximum number of parallel build jobs.  0 means unlimited. */
+ extern unsigned int maxBuildJobs;
+ 
++/* Number of CPU cores to utilize in parallel within a build, i.e. by passing
++   this number to Make via '-j'. 0 means that the number of actual CPU cores on
++   the local host ought to be auto-detected. */
++extern unsigned int buildCores;
++
+ /* Read-only mode.  Don't copy stuff to the store, don't change the
+    database. */
+ extern bool readOnlyMode;
+-- 
+1.7.1
+
diff --git a/pkgs/tools/text/diffutils/default.nix b/pkgs/tools/text/diffutils/default.nix
index 44b7715607c84..4fde88d92626f 100644
--- a/pkgs/tools/text/diffutils/default.nix
+++ b/pkgs/tools/text/diffutils/default.nix
@@ -1,15 +1,15 @@
 {stdenv, fetchurl, coreutils ? null}:
 
 stdenv.mkDerivation {
-  name = "diffutils-2.8.1";
+  name = "diffutils-3.0";
   
   src = fetchurl {
-    url = mirror://gnu/diffutils/diffutils-2.8.1.tar.gz;
-    md5 = "71f9c5ae19b60608f6c7f162da86a428";
+    url = mirror://gnu/diffutils/diffutils-3.0.tar.gz;
+    sha256 = "02g8i6jv0j0vr5nl13ns50lv2dbjy9kkk8jvp11n0g5fpdjizf9g";
   };
   
   /* If no explicit coreutils is given, use the one from stdenv. */
-  buildInputs = [coreutils];
+  buildNativeInputs = [coreutils];
 
   meta = {
     homepage = http://www.gnu.org/software/diffutils/diffutils.html;
diff --git a/pkgs/tools/text/gawk/default.nix b/pkgs/tools/text/gawk/default.nix
index 839364ddb5bbc..c4f37f922c740 100644
--- a/pkgs/tools/text/gawk/default.nix
+++ b/pkgs/tools/text/gawk/default.nix
@@ -1,19 +1,18 @@
-{stdenv, fetchurl}:
+{ stdenv, fetchurl, libsigsegv }:
 
 stdenv.mkDerivation rec {
-  name = "gawk-3.1.7";
+  name = "gawk-3.1.8";
 
   src = fetchurl {
     url = "mirror://gnu/gawk/${name}.tar.bz2";
-    sha256 = "0wfyiqc28cxb5wjbdph4y33h1fdf56nj6cm7as546niwjsw7cazi";
+    sha256 = "1d0jfh319w4h8l1zzqv248916wrc2add1b1aghri31rj9hn7pg2x";
   };
 
   doCheck = true;
 
-  # The libsigsegv provided with gawk has failing tests:
-  # I did like in Fedora:
-  # http://rpmfind.net//linux/RPM/fedora/devel/i386/gawk-3.1.7-2.fc13.i686.html
-  configureFlags = "--disable-libsigsegv";
+  buildInputs = [ libsigsegv ];
+
+  configureFlags = [ "--with-libsigsegv-prefix=${libsigsegv}" ];
 
   meta = {
     homepage = http://www.gnu.org/software/gawk/;
diff --git a/pkgs/tools/text/gnugrep/default.nix b/pkgs/tools/text/gnugrep/default.nix
index 609213aaa6772..1cd73a8814ce6 100644
--- a/pkgs/tools/text/gnugrep/default.nix
+++ b/pkgs/tools/text/gnugrep/default.nix
@@ -1,13 +1,15 @@
 {stdenv, fetchurl, pcre}:
 
-let version = "2.5.4"; in
+let version = "2.6.3"; in
 
 stdenv.mkDerivation {
   name = "gnugrep-${version}";
   
+  patches = [ ./malloc.patch ];
+  
   src = fetchurl {
-    url = "mirror://gnu/grep/grep-${version}.tar.bz2";
-    sha256 = "0800lj1ywf43x5jnjyga56araak0f601sd9k5q1vv3s5057cdgha";
+    url = "mirror://gnu/grep/grep-${version}.tar.gz";
+    sha256 = "0rnnljzcpb2sl5zabww7gbzk9r6kp8kycsqrf909d6jdak8yah53";
   };
   
   buildInputs = [pcre];
diff --git a/pkgs/tools/text/gnugrep/malloc.patch b/pkgs/tools/text/gnugrep/malloc.patch
new file mode 100644
index 0000000000000..b645c64a09e14
--- /dev/null
+++ b/pkgs/tools/text/gnugrep/malloc.patch
@@ -0,0 +1,15 @@
+http://www.mail-archive.com/bug-grep@gnu.org/msg02537.html
+
+diff --git a/src/kwset.c b/src/kwset.c
+index 050562e..995be79 100644
+--- a/src/kwset.c
++++ b/src/kwset.c
+@@ -40,7 +40,7 @@
+ #ifdef GREP
+ # include "xalloc.h"
+ # undef malloc
+-# define malloc(s) xmalloc(s)
++# define malloc xmalloc
+ #endif
+
+ #define NCHAR (UCHAR_MAX + 1)
diff --git a/pkgs/tools/text/gnupatch/default.nix b/pkgs/tools/text/gnupatch/default.nix
index 513a98fdf0705..ff469ddad25be 100644
--- a/pkgs/tools/text/gnupatch/default.nix
+++ b/pkgs/tools/text/gnupatch/default.nix
@@ -8,8 +8,8 @@ stdenv.mkDerivation rec {
     then fetchurl {
       # Temporary fix for
       # http://lists.gnu.org/archive/html/bug-patch/2010-01/msg00004.html .
-      url = "http://nixos.org/tarballs/patch-2.6.1-2-g2c4e3ec.tar.gz";
-      sha256 = "1rspyzrik5cnav3m2fxr8146bsq4mc0yw4x0r8nkl2x7i052yr2c";
+      url = "ftp://alpha.gnu.org/gnu/patch/patch-2.6.1.87-94d8.tar.gz";
+      sha256 = "0jnw8p0nvkmwi1a2z56bssqik8fvkb71zd2cpzl1sklnrg1g3b6p";
     } else fetchurl {
       url = "mirror://gnu/patch/${name}.tar.gz";
       sha256 = "1fc1jyq80nswkf492fiqdbl2bhvlw2wb44ghqlfd3zngx4qkfmni";
@@ -17,6 +17,10 @@ stdenv.mkDerivation rec {
 
   buildInputs = (stdenv.lib.optional doCheck ed);
 
+  crossAttrs = {
+    configureFlags = [ "ac_cv_func_strnlen_working=yes" ];
+  };
+
   doCheck = true;
 
   meta = {
diff --git a/pkgs/tools/text/gnused/default.nix b/pkgs/tools/text/gnused/default.nix
index cea26999be086..66fcb3d192904 100644
--- a/pkgs/tools/text/gnused/default.nix
+++ b/pkgs/tools/text/gnused/default.nix
@@ -1,15 +1,12 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation {
-  name = "gnused-4.1.5";
-  
+  name = "gnused-4.2.1";
+
   src = fetchurl {
-    url = mirror://gnu/sed/sed-4.1.5.tar.gz;
-    md5 = "7a1cbbbb3341287308e140bd4834c3ba";
+    url = mirror://gnu/sed/sed-4.2.1.tar.gz;
+    sha256 = "0q1hzjvr6pzhaagidg7pj76k1fzz5nl15np7p72w9zcpw0f58ww7";
   };
-  
-  # !!! hack: this should go away in gnused > 4.1.5
-  patches = [./gettext-fix.patch];
 
   meta = {
     homepage = http://www.gnu.org/software/sed/;
@@ -24,6 +21,9 @@ stdenv.mkDerivation {
       multiple occurrences of a string within a file.
     '';
 
-    license = "GPLv2+";
+    license = "GPLv3+";
+
+    platforms = stdenv.lib.platforms.all;
+    maintainers = [ stdenv.lib.maintainers.ludo ];
   };
 }
diff --git a/pkgs/tools/text/gnused/gettext-fix.patch b/pkgs/tools/text/gnused/gettext-fix.patch
deleted file mode 100644
index 8ef7e8b5ce472..0000000000000
--- a/pkgs/tools/text/gnused/gettext-fix.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-diff -rc sed-4.1.5-orig/configure sed-4.1.5/configure
-*** sed-4.1.5-orig/configure	Fri Feb  3 10:24:40 2006
---- sed-4.1.5/configure	Fri Jul 14 12:50:13 2006
-***************
-*** 11265,11277 ****
-        esac
-      done ;;
-      gettext-fix )
-!   sed -e '/^mkinstalldirs *=/a\' \
-!       -e "install_sh=$install_sh" \
-        -e 's/^mkinstalldirs *=.*/mkinstalldirs=$(MKINSTALLDIRS)/' \
-        intl/Makefile > intl/Makefile.tmp
-    mv intl/Makefile.tmp intl/Makefile
-!   sed -e '/^mkinstalldirs *=/a\' \
-!       -e "install_sh=$install_sh" \
-        -e 's/^mkinstalldirs *=.*/mkinstalldirs=$(MKINSTALLDIRS)/' \
-        po/Makefile > po/Makefile.tmp
-    mv po/Makefile.tmp po/Makefile ;;
---- 11265,11277 ----
-        esac
-      done ;;
-      gettext-fix )
-!   sed -e "/^mkinstalldirs *=/a\\
-! install_sh=$install_sh" \
-        -e 's/^mkinstalldirs *=.*/mkinstalldirs=$(MKINSTALLDIRS)/' \
-        intl/Makefile > intl/Makefile.tmp
-    mv intl/Makefile.tmp intl/Makefile
-!   sed -e "/^mkinstalldirs *=/a\\
-! install_sh=$install_sh" \
-        -e 's/^mkinstalldirs *=.*/mkinstalldirs=$(MKINSTALLDIRS)/' \
-        po/Makefile > po/Makefile.tmp
-    mv po/Makefile.tmp po/Makefile ;;
diff --git a/pkgs/tools/text/groff/default.nix b/pkgs/tools/text/groff/default.nix
index 060e5d5e2c70b..243fe8dcab810 100644
--- a/pkgs/tools/text/groff/default.nix
+++ b/pkgs/tools/text/groff/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ghostscript, perl }:
+{ stdenv, fetchurl, ghostscript, perl, groff }:
 
 stdenv.mkDerivation rec {
   name = "groff-1.20.1";
@@ -8,10 +8,19 @@ stdenv.mkDerivation rec {
     sha256 = "01fq5i68p4s4fc6m8i90y5d28wk1x6zh2mkw85n0qqnb6n0qfidn";
   };
 
-  buildInputs = [ ghostscript perl ];
+  buildInputs = [ ghostscript ];
+  buildNativeInputs = [ perl ];
 
   doCheck = true;
 
+  crossAttrs = {
+    # Trick to get the build system find the proper 'native' groff
+    # http://www.mail-archive.com/bug-groff@gnu.org/msg01335.html
+    preBuild = ''
+      makeFlags="GROFF_BIN_PATH=${groff}/bin GROFFBIN=${groff}/bin/groff"
+    '';
+  };
+
   meta = {
     description = "GNU Troff, a typesetting package that reads plain text and produces formatted output";
 
diff --git a/pkgs/tools/text/replace/default.nix b/pkgs/tools/text/replace/default.nix
index 0182a3bb48df5..339bf510c4b26 100644
--- a/pkgs/tools/text/replace/default.nix
+++ b/pkgs/tools/text/replace/default.nix
@@ -10,6 +10,10 @@ stdenv.mkDerivation {
 
   makeFlags = ["TREE=\$(out)"];
 
+  crossAttrs = {
+    makeFlags = [ "TREE=\$(out)" "CC=${stdenv.cross.config}-gcc" ];
+  };
+
   postInstall = "mv \$out/bin/replace \$out/bin/replace-literal";
 
   patches = [./malloc.patch];
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 29e8871c21480..1e383ebb573d7 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -32,11 +32,11 @@
   config ? null
 
 , crossSystem ? null
-, platform ? (import ./platforms.nix).pc
+, platform ? null
 }:
 
 
-let config_ = config; in # rename the function argument
+let config_ = config; platform_ = platform; in # rename the function arguments
 
 let
 
@@ -70,6 +70,10 @@ let
         then configExpr { inherit pkgs; }
         else configExpr;
 
+  # Allow setting the platform in the config file. Otherwise, let's use a reasonable default (pc)
+  platform = if platform_ != null then platform_ 
+    else getConfig [ "platform" ] (import ./platforms.nix).pc;
+
   # Return an attribute from the Nixpkgs configuration file, or
   # a default value if the attribute doesn't exist.
   getConfig = attrPath: default: lib.attrByPath attrPath default config;
@@ -191,7 +195,7 @@ let
 
 
   allStdenvs = import ../stdenv {
-    inherit system stdenvType;
+    inherit system stdenvType platform;
     allPackages = args: import ./all-packages.nix ({ inherit config; } // args);
   };
 
@@ -201,7 +205,7 @@ let
     gccCrossStageFinal;
 
   stdenv =
-    if bootStdenv != null then bootStdenv else
+    if bootStdenv != null then (bootStdenv // {inherit platform;}) else
       let changer = getConfig ["replaceStdenv"] null;
       in if changer != null then
         changer {
@@ -1443,7 +1447,7 @@ let
 
   gambit = callPackage ../development/compilers/gambit { };
 
-  gcc = gcc44;
+  gcc = gcc45;
 
   gcc295 = wrapGCC (import ../development/compilers/gcc-2.95 {
     inherit fetchurl stdenv noSysDirs;
@@ -1479,8 +1483,6 @@ let
     profiledCompiler = false;
   });
 
-  gcc44 = gcc44_real;
-
   gcc43 = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc-4.3) {
     inherit stdenv fetchurl texinfo gmp mpfr noSysDirs;
     profiledCompiler = true;
@@ -1498,7 +1500,7 @@ let
 
   gcc44_realCross = lib.addMetaAttrs { platforms = []; }
     (makeOverridable (import ../development/compilers/gcc-4.4) {
-      inherit stdenv fetchurl texinfo gmp mpfr ppl cloogppl noSysDirs
+      inherit stdenv fetchurl texinfo gmp mpfr /* ppl cloogppl */ noSysDirs
           gettext which;
       binutilsCross = binutilsCross;
       libcCross = libcCross;
@@ -1508,6 +1510,8 @@ let
       cross = assert crossSystem != null; crossSystem;
     });
 
+  gcc45 = gcc45_real;
+
   gcc45_realCross = lib.addMetaAttrs { platforms = []; }
     (makeOverridable (import ../development/compilers/gcc-4.5) {
       inherit fetchurl stdenv texinfo gmp mpfr mpc libelf zlib
@@ -1566,17 +1570,19 @@ let
     enableMultilib = true;
   }));
 
-  gcc44_real = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc-4.4) {
+  gcc44 = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc-4.4) {
     inherit fetchurl stdenv texinfo gmp mpfr /* ppl cloogppl */
       gettext which noSysDirs;
     profiledCompiler = true;
   }));
 
-  gcc45 = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc-4.5) {
+  gcc45_real = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc-4.5) {
     inherit fetchurl stdenv texinfo gmp mpfr mpc libelf zlib perl
       ppl cloogppl
       gettext which noSysDirs;
-    profiledCompiler = true;
+    # bootstrapping a profiled compiler does not work in the sheevaplug:
+    # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43944
+    profiledCompiler = if stdenv.system == "armv5tel-linux" then false else true;
   }));
 
   gccApple =
@@ -1590,7 +1596,7 @@ let
     texinfo = texinfo49;
   });
 
-  gfortran = gfortran43;
+  gfortran = gfortran45;
 
   gfortran40 = wrapGCC (gcc40.gcc.override {
     langFortran = true;
@@ -1622,7 +1628,15 @@ let
     profiledCompiler = false;
   });
 
-  gfortran44 = wrapGCC (gcc44_real.gcc.override {
+  gfortran44 = wrapGCC (gcc44.gcc.override {
+    name = "gfortran";
+    langFortran = true;
+    langCC = false;
+    langC = false;
+    profiledCompiler = false;
+  });
+
+  gfortran45 = wrapGCC (gcc45_real.gcc.override {
     name = "gfortran";
     langFortran = true;
     langCC = false;
@@ -1632,7 +1646,7 @@ let
 
   gcj = gcj45;
 
-  gcj44 = wrapGCC (gcc44_real.gcc.override {
+  gcj44 = wrapGCC (gcc44.gcc.override {
     name = "gcj";
     langJava = true;
     langFortran = false;
@@ -1660,9 +1674,22 @@ let
       libXrandr xproto renderproto xextproto inputproto randrproto;
   });
 
-  gnat = gnat44;
+  gnat = gnat45;
 
-  gnat44 = wrapGCC (gcc44_real.gcc.override {
+  gnat44 = wrapGCC (gcc44.gcc.override {
+    name = "gnat";
+    langCC = false;
+    langC = true;
+    langAda = true;
+    profiledCompiler = false;
+    inherit gnatboot;
+    # We can't use the ppl stuff, because we would have
+    # libstdc++ problems.
+    cloogppl = null;
+    ppl = null;
+  });
+
+  gnat45 = wrapGCC (gcc45_real.gcc.override {
     name = "gnat";
     langCC = false;
     langC = true;
@@ -1848,9 +1875,7 @@ let
   # commented out because it's using the new configuration style proposal which is unstable
   hugs = callPackage ../development/compilers/hugs { };
 
-  path64 = callPackage ../development/compilers/path64 {
-    stdenv = stdenv2;
-  };
+  path64 = callPackage ../development/compilers/path64 { };
 
   openjdkDarwin = callPackage ../development/compilers/openjdk-darwin { };
 
@@ -1978,14 +2003,6 @@ let
 
   wrapGCC = wrapGCCWith (import ../build-support/gcc-wrapper) glibc;
 
-  # To be removed on stdenv-updates
-  # By now this has at least the fix of setting the proper rpath when a file "libbla.so"
-  # is passed directly to the linker.
-  # This is of interest to programs built by cmake, because this is a common practice
-  # in cmake builds.
-  wrapGCC2 = wrapGCCWith (import ../build-support/gcc-wrapper/default2.nix) glibc;
-  stdenv2 = if (gcc.nativeTools) then stdenv else (overrideGCC stdenv (wrapGCC2 gcc.gcc));
-
   wrapGCCCross =
     {gcc, libc, binutils, cross, shell ? "", name ? "gcc-cross-wrapper"}:
 
@@ -2260,14 +2277,23 @@ let
 
   automake110x = callPackage ../development/tools/misc/automake/automake-1.10.x.nix { };
 
-  automake111x = callPackage ../development/tools/misc/automake/automake-1.11.x.nix { };
+  automake111x = callPackage ../development/tools/misc/automake/automake-1.11.x.nix {
+    doCheck = if stdenv.isArm then false else true;
+  };
 
   avrdude = callPackage ../development/tools/misc/avrdude { };
 
-  binutils = callPackage ../development/tools/misc/binutils {
+  binutils_release = callPackage ../development/tools/misc/binutils {
+    inherit noSysDirs;
+  };
+
+  binutils_snapshot = callPackage ../development/tools/misc/binutils/snapshot.nix {
     inherit noSysDirs;
   };
 
+  # We are waiting for a release. Meanwhile, sysvinit and the loongson2f need it.
+  binutils = binutils_snapshot;
+
   binutilsCross = forceBuildDrv (import ../development/tools/misc/binutils {
       inherit stdenv fetchurl;
       noSysDirs = true;
@@ -2611,7 +2637,6 @@ let
   clanlib = callPackage ../development/libraries/clanlib { };
 
   clapack = callPackage ../development/libraries/clapack {
-    stdenv = stdenv2;
   };
 
   classads = callPackage ../development/libraries/classads { };
@@ -2721,7 +2746,9 @@ let
 
   fcgi = callPackage ../development/libraries/fcgi { };
 
-  ffmpeg = callPackage ../development/libraries/ffmpeg { };
+  ffmpeg = callPackage ../development/libraries/ffmpeg {
+    vpxSupport = if !stdenv.isMips then true else false;
+  };
 
   fftw = callPackage ../development/libraries/fftw {
     singlePrecision = false;
@@ -2787,9 +2814,6 @@ let
 
   gettext = callPackage ../development/libraries/gettext { };
 
-  # XXX: Remove me when `stdenv-updates' is merged.
-  gettext_0_18 = callPackage ../development/libraries/gettext/0.18.nix { };
-
   gd = callPackage ../development/libraries/gd { };
 
   gdal = callPackage ../development/libraries/gdal { };
@@ -2800,7 +2824,7 @@ let
 
   glfw = callPackage ../development/libraries/glfw { };
 
-  glibc = glibc211;
+  glibc = glibc212;
 
   glibc25 = callPackage ../development/libraries/glibc-2.5 {
     kernelHeaders = linuxHeaders;
@@ -2824,7 +2848,7 @@ let
     installLocales = getPkgConfig "glibc" "locales" false;
   });
 
-  glibc211 = callPackage ../development/libraries/glibc-2.11 {
+  glibc212 = callPackage ../development/libraries/glibc-2.12 {
     kernelHeaders = linuxHeaders;
     installLocales = getPkgConfig "glibc" "locales" false;
     machHeaders = null;
@@ -2832,7 +2856,7 @@ let
     gccCross = null;
   };
 
-  glibc211Cross = forceBuildDrv (makeOverridable (import ../development/libraries/glibc-2.11)
+  glibc212Cross = forceBuildDrv (makeOverridable (import ../development/libraries/glibc-2.12)
     (let crossGNU = (crossSystem != null && crossSystem.config == "i586-pc-gnu");
      in ({
        inherit stdenv fetchurl;
@@ -2847,7 +2871,7 @@ let
       then { inherit machHeaders hurdHeaders mig fetchgit; }
       else { }))));
 
-  glibcCross = glibc211Cross;
+  glibcCross = glibc212Cross;
 
   # We can choose:
   libcCrossChooser = name : if (name == "glibc") then glibcCross
@@ -2868,9 +2892,9 @@ let
     installLocales = getPkgConfig "glibc" "locales" false;
   };
 
-  glibcLocales = callPackage ../development/libraries/glibc-2.11/locales.nix { };
+  glibcLocales = callPackage ../development/libraries/glibc-2.12/locales.nix { };
 
-  glibcInfo = callPackage ../development/libraries/glibc-2.11/info.nix { };
+  glibcInfo = callPackage ../development/libraries/glibc-2.12/info.nix { };
 
   glibc_multi =
       runCommand "${glibc.name}-multi"
@@ -2903,14 +2927,16 @@ let
   gmm = callPackage ../development/libraries/gmm { };
 
   gmp =
-    if stdenv.system == "i686-darwin" then
+    if false then # XXX: stdenv.system == "i686-darwin" then
       # GMP 4.3.2 is broken on Darwin, so use 4.3.1.
       makeOverridable (import ../development/libraries/gmp/4.3.1.nix) {
         inherit stdenv fetchurl m4;
         cxx = false;
       }
     else
-      makeOverridable (import ../development/libraries/gmp) {
+      # We temporarily leave gmp 4 here, waiting for a new ppl/cloog-ppl that
+      # would build well with gmp 5.
+      makeOverridable (import ../development/libraries/gmp/4.nix) {
         inherit stdenv fetchurl m4;
         cxx = false;
       };
@@ -3273,7 +3299,7 @@ let
     inherit (gnome) glib;
   };
 
-  libplist = callPackage ../development/libraries/libplist { stdenv = stdenv2; };
+  libplist = callPackage ../development/libraries/libplist { };
 
   libQGLViewer = callPackage ../development/libraries/libqglviewer { };
 
@@ -3602,8 +3628,7 @@ let
   openct = callPackage ../development/libraries/openct { };
 
   opencv = callPackage ../development/libraries/opencv {
-    inherit (gst_all) gstreamer;
-    stdenv = stdenv2;
+      inherit (gst_all) gstreamer;
   };
 
   # this ctl version is needed by openexr_viewers
@@ -3650,9 +3675,7 @@ let
 
   plib = callPackage ../development/libraries/plib { };
 
-  podofo = callPackage ../development/libraries/podofo {
-    stdenv = stdenv2;
-  };
+  podofo = callPackage ../development/libraries/podofo { };
 
   polkit = callPackage ../development/libraries/polkit { };
 
@@ -3758,8 +3781,9 @@ let
   schroedinger = callPackage ../development/libraries/schroedinger { };
 
   SDL = callPackage ../development/libraries/SDL {
-    openglSupport = mesaSupported;
+    openglSupport = false; #mesaSupported;
     alsaSupport = true;
+    x11Support = false;
     pulseaudioSupport = false; # better go through ALSA
   };
 
@@ -4198,7 +4222,7 @@ let
     ps = procps; /* !!! Linux only */
   };
 
-  mysql = mysql5;
+  mysql = mysql51;
 
   mysql_jdbc = callPackage ../servers/sql/mysql/jdbc { };
 
@@ -4467,7 +4491,7 @@ let
 
   libcroup = callPackage ../os-specific/linux/libcg { };
 
-  linuxHeaders = linuxHeaders_2_6_28;
+  linuxHeaders = linuxHeaders_2_6_32;
 
   linuxHeaders26Cross = forceBuildDrv (import ../os-specific/linux/kernel-headers/2.6.32.nix {
     inherit stdenv fetchurl perl;
@@ -4634,6 +4658,16 @@ let
       ];
   };
 
+  linux_nanonote_jz_2_6_34 = makeOverridable
+    (import ../os-specific/linux/kernel/linux-nanonote-jz-2.6.34.nix) {
+      inherit fetchurl fetchsvn stdenv perl mktemp module_init_tools ubootChooser;
+    };
+
+  linux_nanonote_jz_2_6_35 = makeOverridable
+    (import ../os-specific/linux/kernel/linux-nanonote-jz-2.6.35.nix) {
+      inherit fetchurl fetchsvn stdenv perl mktemp module_init_tools ubootChooser;
+    };
+
   linux_2_6_35_oldI686 = linux_2_6_35.override {
       extraConfig = ''
           HIGHMEM64G? n
@@ -4754,6 +4788,8 @@ let
   linuxPackages_2_6_33 = recurseIntoAttrs (linuxPackagesFor linux_2_6_33 pkgs.linuxPackages_2_6_33);
   linuxPackages_2_6_34 = recurseIntoAttrs (linuxPackagesFor linux_2_6_34 pkgs.linuxPackages_2_6_34);
   linuxPackages_2_6_35 = recurseIntoAttrs (linuxPackagesFor linux_2_6_35 pkgs.linuxPackages_2_6_35);
+  linuxPackages_nanonote_jz_2_6_34 = recurseIntoAttrs (linuxPackagesFor linux_nanonote_jz_2_6_34 pkgs.linuxPackages_nanonote_jz_2_6_34); 
+  linuxPackages_nanonote_jz_2_6_35 = recurseIntoAttrs (linuxPackagesFor linux_nanonote_jz_2_6_35 pkgs.linuxPackages_nanonote_jz_2_6_35); 
 
   # The current default kernel / kernel modules.
   linux = linux_2_6_32;
@@ -4789,6 +4825,12 @@ let
 
   libcap = callPackage ../os-specific/linux/libcap { };
 
+  libcap_progs = callPackage ../os-specific/linux/libcap/progs.nix { };
+
+  libcap_pam = callPackage ../os-specific/linux/libcap/pam.nix { };
+
+  libcap_manpages = callPackage ../os-specific/linux/libcap/man.nix { };
+
   libnscd = callPackage ../os-specific/linux/libnscd { };
 
   libnotify = callPackage ../development/libraries/libnotify { };
@@ -4932,16 +4974,19 @@ let
 
   ubootChooser = name : if (name == "upstream") then ubootUpstream
     else if (name == "sheevaplug") then ubootSheevaplug
+    else if (name == "nanonote") then ubootNanonote
     else throw "Unknown uboot";
 
   ubootUpstream = callPackage ../misc/uboot { };
 
   ubootSheevaplug = callPackage ../misc/uboot/sheevaplug.nix { };
 
+  ubootNanonote = callPackage ../misc/uboot/nanonote.nix { };
+
   uclibc = callPackage ../os-specific/linux/uclibc { };
 
   uclibcCross = import ../os-specific/linux/uclibc {
-    inherit fetchurl stdenv;
+    inherit fetchurl stdenv libiconv;
     linuxHeaders = linuxHeadersCross;
     gccCross = gccCrossStageStatic;
     cross = assert crossSystem != null; crossSystem;
@@ -5190,7 +5235,6 @@ let
   autopanosiftc = callPackage ../applications/graphics/autopanosiftc { };
 
   avidemux = callPackage ../applications/video/avidemux {
-    stdenv = stdenv2;
   };
 
   awesome = callPackage ../applications/window-managers/awesome {
@@ -5231,15 +5275,13 @@ let
 
   blender = callPackage ../applications/misc/blender/2.49.nix {
     python = python26Base;
-    stdenv = stdenv2;
   };
 
   blender_2_50 = lowPrio (import ../applications/misc/blender {
-    inherit fetchurl cmake mesa gettext libjpeg libpng zlib openal SDL openexr
+    inherit stdenv fetchurl cmake mesa gettext libjpeg libpng zlib openal SDL openexr
       libsamplerate libtiff ilmbase;
     inherit (xlibs) libXi;
     python = python31Base;
-    stdenv = stdenv2;
   });
 
   bmp = callPackage ../applications/audio/bmp {
@@ -5699,7 +5741,6 @@ let
   };
 
   hugin = callPackage ../applications/graphics/hugin {
-    stdenv = stdenv2;
   };
 
   i810switch = callPackage ../os-specific/linux/i810switch { };
@@ -5730,7 +5771,9 @@ let
 
   icecatWrapper = wrapFirefox icecat3Xul "icecat" "";
 
-  icewm = callPackage ../applications/window-managers/icewm { };
+  icewm = callPackage ../applications/window-managers/icewm {
+    inherit (gtkLibs) gtk;
+  };
 
   id3v2 = callPackage ../applications/audio/id3v2 { };
 
@@ -5781,7 +5824,6 @@ let
   jwm = callPackage ../applications/window-managers/jwm { };
 
   kadu = callPackage ../applications/networking/instant-messengers/kadu {
-    stdenv = stdenv2;
     qt = qt4;
     inherit fetchurl cmake libgadu bash libsndfile wget alsaLib;
     inherit (xlibs) libXScrnSaver libX11;
@@ -5907,6 +5949,8 @@ let
 
   mpc123 = callPackage ../applications/audio/mpc123 { };
 
+  mpg123 = callPackage ../applications/audio/mpg123 { };
+
   mpg321 = callPackage ../applications/audio/mpg321 { };
 
   MPlayer = callPackage ../applications/video/MPlayer { };
@@ -5958,14 +6002,12 @@ let
     inherit (perlPackages) ArchiveZip CompressZlib;
     inherit (gnome) GConf ORBit2;
     neon = neon029;
-    stdenv = stdenv2;
   };
 
   go_oo = callPackage ../applications/office/openoffice/go-oo.nix {
     inherit (perlPackages) ArchiveZip CompressZlib;
     inherit (gnome) GConf ORBit2;
     neon = neon029;
-    stdenv = stdenv2;
   };
 
   opera = callPackage ../applications/networking/browsers/opera {
@@ -5985,7 +6027,6 @@ let
   };
 
   paraview = callPackage ../applications/graphics/paraview {
-    stdenv = stdenv2;
   };
 
   partitionManager = newScope pkgs.kde4 ../tools/misc/partition-manager { };
@@ -6228,7 +6269,8 @@ let
   vimHugeX = vim_configurable;
 
   vim_configurable = import ../applications/editors/vim/configurable.nix {
-    inherit (pkgs) fetchurl stdenv ncurses pkgconfig gettext composableDerivation lib;
+    inherit (pkgs) fetchurl stdenv ncurses pkgconfig gettext composableDerivation lib
+      getConfig;
     inherit (pkgs.xlibs) libX11 libXext libSM libXpm
         libXt libXaw libXau libXmu libICE;
     inherit (pkgs.gtkLibs) glib gtk;
@@ -6512,6 +6554,8 @@ let
 
   pioneers = callPackage ../games/pioneers { };
 
+  prboom = callPackage ../games/prboom { };
+
   quake3demo = callPackage ../games/quake3/wrapper {
     name = "quake3-demo-${quake3game.name}";
     description = "Demo of Quake 3 Arena, a classic first-person shooter";
@@ -6664,7 +6708,6 @@ let
 
   kde44 = makeOverridable (import ../desktops/kde-4.4) (pkgs // {
     qt4 = pkgs.qt46;
-    stdenv = pkgs.stdenv2;
   });
 
   kde45 = callPackage ../desktops/kde-4.5 {
@@ -6676,7 +6719,6 @@ let
         inherit (pkgs.kde45) qt4 kdelibs;
       };
       shared_desktop_ontologies = pkgs.shared_desktop_ontologies.override { v = "0.5"; };
-      stdenv = pkgs.stdenv2;
     } // pkgs.kde45);
   };
 
@@ -6793,9 +6835,7 @@ let
 
   ### SCIENCE / ELECTRONICS
 
-  kicad = callPackage ../applications/science/electronics/kicad {
-    stdenv = stdenv2;
-  };
+  kicad = callPackage ../applications/science/electronics/kicad { };
 
   ngspice = callPackage ../applications/science/electronics/ngspice { };
 
@@ -6824,9 +6864,7 @@ let
 
   golly = callPackage ../applications/science/misc/golly { };
 
-  simgrid = callPackage ../applications/science/misc/simgrid {
-    stdenv = stdenv2;
-  };
+  simgrid = callPackage ../applications/science/misc/simgrid { };
 
   tulip = callPackage ../applications/science/misc/tulip {
     qt = qt4;
@@ -6834,7 +6872,6 @@ let
 
   vite = callPackage ../applications/science/misc/vite {
     qt = qt4;
-    stdenv = stdenv2;
   };
 
   ### MISC
diff --git a/pkgs/top-level/platforms.nix b/pkgs/top-level/platforms.nix
index 7bd27ebf4f9a8..f443067857091 100644
--- a/pkgs/top-level/platforms.nix
+++ b/pkgs/top-level/platforms.nix
@@ -162,4 +162,62 @@ rec {
     uboot = "upstream";
     ubootConfig = "integratorcp_config";
   };
+
+  fuloong2f_n32 = {
+    name = "fuloong2f_n32";
+    kernelMajor = "2.6";
+    kernelHeadersBaseConfig = "fuloong2e_defconfig";
+    kernelBaseConfig = "lemote2f_defconfig";
+    kernelArch = "mips";
+    kernelAutoModules = false;
+    kernelExtraConfig =
+      ''
+        BLK_DEV_RAM y
+        BLK_DEV_INITRD y
+        BLK_DEV_CRYPTOLOOP m
+        BLK_DEV_DM m
+        DM_CRYPT m
+        MD y
+        REISERFS_FS m
+        EXT4_FS m
+        USB_STORAGE_CYPRESS_ATACB m
+
+        IP_PNP y
+        IP_PNP_DHCP y
+        IP_PNP_BOOTP y
+        NFS_FS y
+        ROOT_NFS y
+        TUN m
+        NFS_V4 y
+        NFS_V4_1 y
+        NFS_FSCACHE y
+        NFSD m
+        NFSD_V2_ACL y
+        NFSD_V3 y
+        NFSD_V3_ACL y
+        NFSD_V4 y
+
+        # Fail to build
+        DRM n
+        SCSI_ADVANSYS n
+        USB_ISP1362_HCD n
+        SND_SOC n
+        SND_ALI5451 n
+        FB_SAVAGE n
+        SCSI_NSP32 n
+        ATA_SFF n
+        SUNGEM n
+        IRDA n
+        ATM_HE n
+        SCSI_ACARD n
+        BLK_DEV_CMD640_ENHANCED n
+
+        FUSE_FS m
+
+        # Needed for udev >= 150
+        SYSFS_DEPRECATED_V2 n
+      '';
+    kernelTarget = "vmlinux";
+    uboot = null;
+  };
 }
diff --git a/pkgs/top-level/release-cross.nix b/pkgs/top-level/release-cross.nix
index b2dc475e12a23..d9a5369bd6ac7 100644
--- a/pkgs/top-level/release-cross.nix
+++ b/pkgs/top-level/release-cross.nix
@@ -4,10 +4,12 @@ let
 
   /* Basic list of packages to cross-build */
   basicHostDrv = {
+    gccCrossStageFinal = nativePlatforms;
     bison.hostDrv = nativePlatforms;
     busybox.hostDrv = nativePlatforms;
+    coreutils.hostDrv = nativePlatforms;
     dropbear.hostDrv = nativePlatforms;
-    tightvnc.hostDrv = nativePlatforms;
+    tigervnc.hostDrv = nativePlatforms;
     #openoffice.hostDrv = nativePlatforms;
     wxGTK.hostDrv = nativePlatforms;
     #firefox = nativePlatforms;
@@ -17,6 +19,8 @@ let
     nixUnstable.hostDrv = nativePlatforms;
     linuxPackages_2_6_32.kernel.hostDrv = linux;
     linuxPackages_2_6_33.kernel.hostDrv = linux;
+    linuxPackages_2_6_34.kernel.hostDrv = linux;
+    linuxPackages_2_6_35.kernel.hostDrv = linux;
   };
 
   /* Basic list of packages to be natively built,
@@ -62,6 +66,14 @@ let
     platform = pkgs.platforms.sheevaplug;
     libc = "uclibc";
     openssl.system = "linux-generic32";
+    uclibc.extraConfig = ''
+      CONFIG_ARM_OABI n
+      CONFIG_ARM_EABI y
+      ARCH_BIG_ENDIAN n
+      ARCH_WANTS_BIG_ENDIAN n
+      ARCH_WANTS_LITTLE_ENDIAN y
+      LINUXTHREADS_OLD y
+    '';
   };
 
 in {
@@ -84,7 +96,7 @@ let
     platform = {
       name = "malta";
       kernelMajor = "2.4";
-      kernelBaseConfig = "malta_defconfig";
+      kernelBaseConfig = "defconfig-malta";
       kernelHeadersBaseConfig = "defconfig-malta";
       uboot = null;
       kernelArch = "mips";
@@ -92,6 +104,15 @@ let
       kernelTarget = "vmlinux";
     };
     openssl.system = "linux-generic32";
+    uclibc.extraConfig = ''
+      ARCH_BIG_ENDIAN n
+      ARCH_WANTS_BIG_ENDIAN n
+      ARCH_WANTS_LITTLE_ENDIAN y
+      LINUXTHREADS_OLD y
+
+      # Without this, it does not build for linux 2.4
+      UCLIBC_SUSV4_LEGACY y
+    '';
   };
 in {
   crossMipselLinux24 = mapTestOnCross crossSystem basic;
@@ -134,7 +155,6 @@ let
 in {
   crossMingw32 = mapTestOnCross crossSystem {
     windows.wxMSW.hostDrv = nativePlatforms;
-    gccCrossStageFinal = nativePlatforms;
   };
 }) // (
 
@@ -152,7 +172,6 @@ let
   };
 in {
   crossGNU = mapTestOnCross crossSystem {
-    gccCrossStageFinal = nativePlatforms;
     hurdCross = nativePlatforms;
     mach.hostDrv = nativePlatforms;
 
@@ -164,4 +183,101 @@ in {
     patch.hostDrv = nativePlatforms;
     zile.hostDrv = nativePlatforms;
   };
+}) // (
+
+/* Linux on the fuloong */
+let
+  crossSystem = {
+    config = "mips64el-unknown-linux";  
+    bigEndian = false;
+    arch = "mips";
+    float = "hard";
+    withTLS = true;
+    libc = "glibc";
+    platform = {
+      name = "fuloong-minipc";
+      kernelMajor = "2.6";
+      kernelBaseConfig = "lemote2f_defconfig";
+      kernelHeadersBaseConfig = "fuloong2e_defconfig";
+      uboot = null;
+      kernelArch = "mips";
+      kernelAutoModules = false;
+      kernelTarget = "vmlinux";
+    };
+    openssl.system = "linux-generic32";
+    gcc = {
+      arch = "loongson2f";
+      abi = "n32";
+    };
+  };
+in {
+  fuloongminipc = mapTestOnCross crossSystem {
+
+    coreutils_real.hostDrv = nativePlatforms;
+    ed.hostDrv = nativePlatforms;
+    grub2.hostDrv = nativePlatforms;
+    inetutils.hostDrv = nativePlatforms;
+    nixUnstable.hostDrv = nativePlatforms;
+    patch.hostDrv = nativePlatforms;
+    zile.hostDrv = nativePlatforms;
+  };
+}) // (
+
+/* Linux on the Ben Nanonote */
+let
+  crossSystem = {
+    config = "mipsel-unknown-linux";  
+    bigEndian = false;
+    arch = "mips";
+    float = "soft";
+    withTLS = true;
+    libc = "glibc";
+    platform = {
+      name = "ben_nanonote";
+      kernelMajor = "2.6";
+      kernelBaseConfig = "qi_lb60_defconfig";
+      kernelHeadersBaseConfig = "malta_defconfig";
+      uboot = "nanonote";
+      kernelArch = "mips";
+      kernelAutoModules = false;
+      kernelTarget = "vmlinux.bin";
+      kernelExtraConfig = ''
+        SOUND y
+        SND y
+        SND_MIPS y
+        SND_SOC y
+        SND_JZ4740_SOC y
+        SND_JZ4740_SOC_QI_LB60 y
+        FUSE_FS m
+        MIPS_FPU_EMU y
+      '';
+    };
+    openssl.system = "linux-generic32";
+    perl.arch = "mipsel-unknown";
+    uclibc.extraConfig = ''
+      CONFIG_MIPS_ISA_1 n
+      CONFIG_MIPS_ISA_MIPS32 y
+      CONFIG_MIPS_N32_ABI n
+      CONFIG_MIPS_O32_ABI y
+      ARCH_BIG_ENDIAN n
+      ARCH_WANTS_BIG_ENDIAN n
+      ARCH_WANTS_LITTLE_ENDIAN y
+      LINUXTHREADS_OLD y
+    '';
+    gcc = {
+      abi = "32";
+      arch = "mips32";
+    };
+    mpg123.cpu = "generic_nofpu";
+  };
+in {
+  nanonote = mapTestOnCross crossSystem {
+
+    coreutils_real.hostDrv = nativePlatforms;
+    ed.hostDrv = nativePlatforms;
+    inetutils.hostDrv = nativePlatforms;
+    nixUnstable.hostDrv = nativePlatforms;
+    patch.hostDrv = nativePlatforms;
+    zile.hostDrv = nativePlatforms;
+  };
 })
diff --git a/pkgs/top-level/release-lib.nix b/pkgs/top-level/release-lib.nix
index a470098529f56..0345ebba0c4e0 100644
--- a/pkgs/top-level/release-lib.nix
+++ b/pkgs/top-level/release-lib.nix
@@ -28,14 +28,14 @@ rec {
   crossMaintainers = with pkgs.lib.maintainers; [ viric ];
 
   /* Set the Hydra scheduling priority for a job.  The default
-     priority (100) should be used for most jobs.  A different
+     priority (10) should be used for most jobs.  A different
      priority should only be used for a few particularly interesting
      jobs (in terms of giving feedback to developers), such as stdenv.
   */
   prio = level: job: toJob job // { schedulingPriority = level; };
 
   toJob = x: if builtins.isAttrs x then x else
-    { type = "job"; systems = x; schedulingPriority = 10; };
+    { type = "job"; systems = x; schedulingPriority = 5; };
 
   /* Perform a job on the given set of platforms.  The function `f' is
      called by Hydra for each platform, and should return some job
diff --git a/pkgs/top-level/release.nix b/pkgs/top-level/release.nix
index b27f984d28fb3..f385e9a069af6 100644
--- a/pkgs/top-level/release.nix
+++ b/pkgs/top-level/release.nix
@@ -165,7 +165,7 @@ with (import ./release-lib.nix);
   jwhois = linux;
   kbd = linux;
   keen4 = ["i686-linux"];
-  klibc = linux;
+#  klibc = linux;
   ktorrent = linux;
   kvm = linux;
   qemu = linux;