summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--maintainers/scripts/gnu/gnupdate.scm712
-rw-r--r--pkgs/applications/editors/ed/default.nix4
-rw-r--r--pkgs/applications/misc/simgrid/default.nix59
-rw-r--r--pkgs/applications/networking/browsers/rekonq/source.nix28
-rw-r--r--pkgs/applications/version-management/git-and-tools/git/default.nix2
-rw-r--r--pkgs/build-support/fetchurl/mirrors.nix5
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/builder.sh25
-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/kde-4.4/support/phonon/phonon-4.4.1-gst-plugins-include.patch263
-rw-r--r--pkgs/development/compilers/gcc-4.3/default.nix2
-rw-r--r--pkgs/development/compilers/gcc-4.4/builder.sh35
-rw-r--r--pkgs/development/compilers/gcc-4.4/default.nix50
-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/gcc-apple/default.nix2
-rw-r--r--pkgs/development/compilers/gcc-apple64/default.nix2
-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/interpreters/perl-5.10/default.nix2
-rw-r--r--pkgs/development/interpreters/python/2.6/default.nix2
-rw-r--r--pkgs/development/libraries/acl/default.nix20
-rw-r--r--pkgs/development/libraries/attr/default.nix14
-rw-r--r--pkgs/development/libraries/cloog-ppl/default.nix24
-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/glibc-2.11/builder.sh22
-rw-r--r--pkgs/development/libraries/glibc-2.11/builder2.sh58
-rw-r--r--pkgs/development/libraries/glibc-2.11/common.nix28
-rw-r--r--pkgs/development/libraries/glibc-2.11/default.nix3
-rw-r--r--pkgs/development/libraries/glibc-2.11/gnu89-inline.patch26
-rw-r--r--pkgs/development/libraries/glibc-2.11/locale-override.patch72
-rw-r--r--pkgs/development/libraries/glibc-2.11/nix-locale-archive.patch122
-rw-r--r--pkgs/development/libraries/glibc-2.11/nss-skip-unavail.patch42
-rw-r--r--pkgs/development/libraries/glibc-2.5/builder.sh2
-rw-r--r--pkgs/development/libraries/glibc-2.5/default.nix2
-rw-r--r--pkgs/development/libraries/gmp/4.3.1.nix2
-rw-r--r--pkgs/development/libraries/gmp/4.nix59
-rw-r--r--pkgs/development/libraries/gmp/default.nix48
-rw-r--r--pkgs/development/libraries/libgcrypt/default.nix4
-rw-r--r--pkgs/development/libraries/mpfr/default.nix4
-rw-r--r--pkgs/development/libraries/mpfr/patch01.patch184
-rw-r--r--pkgs/development/libraries/mpfr/patch02.patch75
-rw-r--r--pkgs/development/libraries/ncurses/default.nix4
-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/pcre/default.nix10
-rw-r--r--pkgs/development/libraries/ppl/default.nix16
-rw-r--r--pkgs/development/libraries/qt-4.x/4.5/default.nix2
-rw-r--r--pkgs/development/libraries/qt-4.x/4.6/default.nix2
-rw-r--r--pkgs/development/libraries/qt-4.x/4.7/default.nix2
-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/gnum4/default.nix6
-rw-r--r--pkgs/development/tools/misc/patchelf/0.6.nix4
-rw-r--r--pkgs/lib/platforms.nix3
-rw-r--r--pkgs/misc/busybox/default.nix62
-rw-r--r--pkgs/misc/uboot/nanonote.nix58
-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/generic.nix3
-rw-r--r--pkgs/os-specific/linux/kernel/linux-nanonote-jz-2.6.34.nix212
-rw-r--r--pkgs/os-specific/linux/kernel/linux-nanonote-jz-2.6.35.nix212
-rw-r--r--pkgs/os-specific/linux/klibc/default.nix35
-rw-r--r--pkgs/os-specific/linux/lvm2/default.nix2
-rw-r--r--pkgs/os-specific/linux/uclibc/default.nix13
-rw-r--r--pkgs/os-specific/linux/util-linux-ng/default.nix6
-rw-r--r--pkgs/stdenv/adapters.nix4
-rw-r--r--pkgs/stdenv/default.nix1
-rw-r--r--pkgs/stdenv/generic/default.nix4
-rw-r--r--pkgs/stdenv/generic/setup.sh19
-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/default.nix17
-rw-r--r--pkgs/stdenv/linux/make-bootstrap-tools.nix2
-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/misc/coreutils/default.nix33
-rw-r--r--pkgs/tools/misc/findutils/default.nix11
-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/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/replace/default.nix4
-rw-r--r--pkgs/top-level/all-packages.nix108
-rw-r--r--pkgs/top-level/platforms.nix53
-rw-r--r--pkgs/top-level/release-lib.nix4
104 files changed, 3104 insertions, 924 deletions
diff --git a/maintainers/scripts/gnu/gnupdate.scm b/maintainers/scripts/gnu/gnupdate.scm
new file mode 100644
index 00000000000..3cf6e7cfaba
--- /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/editors/ed/default.nix b/pkgs/applications/editors/ed/default.nix
index 9f26c0a2886..905cde880ed 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/misc/simgrid/default.nix b/pkgs/applications/misc/simgrid/default.nix
new file mode 100644
index 00000000000..45b93dab830
--- /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/rekonq/source.nix b/pkgs/applications/networking/browsers/rekonq/source.nix
new file mode 100644
index 00000000000..5faeddaaf2a
--- /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/version-management/git-and-tools/git/default.nix b/pkgs/applications/version-management/git-and-tools/git/default.nix
index d548f39799a..76a8015cb15 100644
--- a/pkgs/applications/version-management/git-and-tools/git/default.nix
+++ b/pkgs/applications/version-management/git-and-tools/git/default.nix
@@ -116,6 +116,8 @@ stdenv.mkDerivation rec {
 
      '';
 
+  enableParallelBuilding = true;
+
   meta = {
     license = "GPLv2";
     homepage = http://git-scm.com/;
diff --git a/pkgs/build-support/fetchurl/mirrors.nix b/pkgs/build-support/fetchurl/mirrors.nix
index cd53f0d0d55..c27b8967e80 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 674c2b89b52..a3a4d01e3c4 100644
--- a/pkgs/build-support/gcc-cross-wrapper/builder.sh
+++ b/pkgs/build-support/gcc-cross-wrapper/builder.sh
@@ -1,5 +1,8 @@
 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/"
@@ -12,6 +15,23 @@ if test -z "$nativeLibc"; then
     if [ -n "$dlinker" ]; then
       ldflagsBefore="-dynamic-linker $dlinker"
     fi
+
+    # The same as above, but put into files, useful for the gcc builder.
+    dynamicLinker="$libc/lib/$dynamicLinker"
+    echo $dynamicLinker > $out/nix-support/dynamic-linker
+
+    if test -e $libc/lib/32/ld-linux.so.2; then
+        echo $libc/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32
+    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 "-dynamic-linker $dynamicLinker" > $out/nix-support/libc-ldflags-before
 fi
 
 if test -n "$nativeTools"; then
@@ -24,11 +44,6 @@ else
 fi
 
 
-mkdir $out
-mkdir $out/bin
-mkdir $out/nix-support
-
-
 doSubstitute() {
     local src=$1
     local dst=$2
diff --git a/pkgs/build-support/gcc-wrapper/default.nix b/pkgs/build-support/gcc-wrapper/default.nix
index c97fd4eb495..2c7ef16674b 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 == "ict_loongson-2_v0.3_fpu_v0.1-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 efade01963b..00000000000
--- 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 3ca9e815a8f..99ba3968ae3 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 99ba3968ae3..00000000000
--- 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/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 00000000000..46782840570
--- /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.3/default.nix b/pkgs/development/compilers/gcc-4.3/default.nix
index 73caa156bd0..b9d0d9bff5d 100644
--- a/pkgs/development/compilers/gcc-4.3/default.nix
+++ b/pkgs/development/compilers/gcc-4.3/default.nix
@@ -127,6 +127,8 @@ stdenv.mkDerivation ({
   passthru = { inherit langC langCC langFortran langVhdl langTreelang
       enableMultilib; };
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = "http://gcc.gnu.org/";
     license = "GPL/LGPL";
diff --git a/pkgs/development/compilers/gcc-4.4/builder.sh b/pkgs/development/compilers/gcc-4.4/builder.sh
index b9724e7ad50..abe14b457ab 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 bdf2e58bcb4..bc9c2c89e1d 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.
@@ -201,6 +247,8 @@ stdenv.mkDerivation ({
   passthru = { inherit langC langCC langAda langFortran langTreelang langVhdl
       enableMultilib version; };
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = http://gcc.gnu.org/;
     license = "GPLv3+";  # runtime support libraries are typically LGPLv3+
diff --git a/pkgs/development/compilers/gcc-4.5/builder.sh b/pkgs/development/compilers/gcc-4.5/builder.sh
index 6c3ced85d75..5d66cc09532 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 39232c4988e..c1e3d3a402a 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"}
@@ -235,6 +242,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";
@@ -289,6 +342,8 @@ stdenv.mkDerivation ({
   passthru = { inherit langC langCC langAda langFortran langTreelang langVhdl
       enableMultilib version; };
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = http://gcc.gnu.org/;
     license = "GPLv3+";  # runtime support libraries are typically LGPLv3+
@@ -314,11 +369,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 {
@@ -351,4 +408,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 6b37672ddef..00000000000
--- 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 7e2a8a9c290..00000000000
--- 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 4a9201d08eb..6059e03880b 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/gcc-apple/default.nix b/pkgs/development/compilers/gcc-apple/default.nix
index 8006bd4426d..3346a4e327a 100644
--- a/pkgs/development/compilers/gcc-apple/default.nix
+++ b/pkgs/development/compilers/gcc-apple/default.nix
@@ -21,6 +21,8 @@ stdenv.mkDerivation ({
       sha256 = "a7d8041e50e110f5a503e188a05cb217f0c99c51f248a0a1387cc07a0b6f167f";
     }) ;
 
+  enableParallelBuilding = true;
+
   sourceRoot = "gcc_42-5574/";
   patches =
     [./pass-cxxcpp.patch ./debug_list.patch]
diff --git a/pkgs/development/compilers/gcc-apple64/default.nix b/pkgs/development/compilers/gcc-apple64/default.nix
index b87cd596a5b..ec16fae7977 100644
--- a/pkgs/development/compilers/gcc-apple64/default.nix
+++ b/pkgs/development/compilers/gcc-apple64/default.nix
@@ -21,6 +21,8 @@ stdenv.mkDerivation ({
       sha256 = "1fy6j41rhxdsm19sib9wygjl5l54g8pm13c6y5x13f40mavw1mma";
     }) ;
 
+  enableParallelBuilding = true;
+
   libstdcxx = "libstdcxx-39";
   sourceRoot = "gcc-5646/";
   patches =
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 00000000000..7e7671f0da0
--- /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 8dd7953a42d..dae6a69bcb6 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/interpreters/perl-5.10/default.nix b/pkgs/development/interpreters/perl-5.10/default.nix
index 31168291e3d..76928d10448 100644
--- a/pkgs/development/interpreters/perl-5.10/default.nix
+++ b/pkgs/development/interpreters/perl-5.10/default.nix
@@ -39,6 +39,8 @@ stdenv.mkDerivation rec {
 
   dontAddPrefix = true;
 
+  enableParallelBuilding = true;
+
   preConfigure =
     ''
       configureFlags="$configureFlags -Dprefix=$out -Dman1dir=$out/share/man/man1 -Dman3dir=$out/share/man/man3"
diff --git a/pkgs/development/interpreters/python/2.6/default.nix b/pkgs/development/interpreters/python/2.6/default.nix
index 8865738b0d7..3fd035b09bb 100644
--- a/pkgs/development/interpreters/python/2.6/default.nix
+++ b/pkgs/development/interpreters/python/2.6/default.nix
@@ -88,6 +88,8 @@ stdenv.mkDerivation ( {
     libPrefix = "python${majorVersion}";
   };
 
+  enableParallelBuilding = true;
+
   meta = {
     platforms = stdenv.lib.platforms.all;
   };
diff --git a/pkgs/development/libraries/acl/default.nix b/pkgs/development/libraries/acl/default.nix
index 06dd8cb2fb9..d3a3bbd38c5 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.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 libtool];
+
+  # 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 LIBTOOL=libtool 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 532f97a9fdf..643b4cdaae5 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/cloog-ppl/default.nix b/pkgs/development/libraries/cloog-ppl/default.nix
index b1372d79cb5..ca662d30eb0 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/gdbm/default.nix b/pkgs/development/libraries/gdbm/default.nix
index d6f1d118f82..448fd04edd8 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 f7f0cb0018c..00000000000
--- 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 6b094fdc839..ddcfc327a9e 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/glibc-2.11/builder.sh b/pkgs/development/libraries/glibc-2.11/builder.sh
index f8da3b8bbe2..9a1c1490019 100644
--- a/pkgs/development/libraries/glibc-2.11/builder.sh
+++ b/pkgs/development/libraries/glibc-2.11/builder.sh
@@ -17,15 +17,29 @@ postConfigure() {
 
 postInstall() {
     if test -n "$installLocales"; then
-        make localedata/install-locales
+        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$') .)
+    # FIXME: Use `test -n $linuxHeaders' when `kernelHeaders' has been
+    # renamed.
+    if test -z "$hurdHeaders"; then
+        # Include the Linux kernel headers in Glibc, except the `scsi'
+        # subdirectory, which Glibc provides itself.
+	(cd $out/include && \
+	 ln -sv $(ls -d $kernelHeaders/include/* | grep -v 'scsi$') .)
+    fi
 
+    if test -f "$out/lib/libhurduser.so"; then
+	# libc.so, libhurduser.so, and libmachuser.so depend on each
+	# other, so add them to libc.so (a RUNPATH on libc.so.0.3
+	# would be ignored by the cross-linker.)
+	echo "adding \`libhurduser.so' and \`libmachuser.so' to the \`libc.so' linker script..."
+	sed -i "$out/lib/libc.so" \
+	    -e"s|\(libc\.so\.[^ ]\+\>\)|\1 $out/lib/libhurduser.so $out/lib/libmachuser.so|g"
+    fi
+	
     # Fix for NIXOS-54 (ldd not working on x86_64).  Make a symlink
     # "lib64" to "lib".
     if test -n "$is64bit"; then
diff --git a/pkgs/development/libraries/glibc-2.11/builder2.sh b/pkgs/development/libraries/glibc-2.11/builder2.sh
deleted file mode 100644
index f156e647e0b..00000000000
--- a/pkgs/development/libraries/glibc-2.11/builder2.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-### 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
-
-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 localedata/install-locales
-    fi
-    
-    test -f $out/etc/ld.so.cache && rm $out/etc/ld.so.cache
-
-    # FIXME: Use `test -n $linuxHeaders' when `kernelHeaders' has been
-    # renamed.
-    if test -z "$hurdHeaders"; then
-        # Include the Linux kernel headers in Glibc, except the `scsi'
-        # subdirectory, which Glibc provides itself.
-	(cd $out/include && \
-	 ln -sv $(ls -d $kernelHeaders/include/* | grep -v 'scsi$') .)
-    fi
-
-    if test -f "$out/lib/libhurduser.so"; then
-	# libc.so, libhurduser.so, and libmachuser.so depend on each
-	# other, so add them to libc.so (a RUNPATH on libc.so.0.3
-	# would be ignored by the cross-linker.)
-	echo "adding \`libhurduser.so' and \`libmachuser.so' to the \`libc.so' linker script..."
-	sed -i "$out/lib/libc.so" \
-	    -e"s|\(libc\.so\.[^ ]\+\>\)|\1 $out/lib/libhurduser.so $out/lib/libmachuser.so|g"
-    fi
-	
-    # Fix for NIXOS-54 (ldd not working on x86_64).  Make a symlink
-    # "lib64" to "lib".
-    if test -n "$is64bit"; then
-        ln -s lib $out/lib64
-    fi
-
-    # This file, that should not remain in the glibc derivation,
-    # may have not been created during the preInstall
-    rm -f $out/lib/libgcc_s.so.1
-}
-
-
-genericBuild
diff --git a/pkgs/development/libraries/glibc-2.11/common.nix b/pkgs/development/libraries/glibc-2.11/common.nix
index b792e8447e7..b2dd01690df 100644
--- a/pkgs/development/libraries/glibc-2.11/common.nix
+++ b/pkgs/development/libraries/glibc-2.11/common.nix
@@ -11,9 +11,7 @@ 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.11.2";
 in
 
 assert (cross != null) -> (gccCross != null);
@@ -30,6 +28,8 @@ stdenv.mkDerivation ({
 
   inherit (stdenv) is64bit;
 
+  enableParallelBuilding = true;
+
   patches =
     stdenv.lib.optional (fetchgit == null)
     /* Fix for NIXPKGS-79: when doing host name lookups, when
@@ -54,18 +54,19 @@ 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
-  ]
 
+    /* Fix for the check of -fgnu89-inline compiler flag */
+    ./gnu89-inline.patch
+
+    /* Allow nixos and nix handle the locale-archive. */
+    ./nix-locale-archive.patch
+  ]
   ++ stdenv.lib.optional (fetchgit == null)
     /* MOD_NANO definition, for ntp (taken from glibc upstream) */
     ./mod_nano.patch;
@@ -73,6 +74,7 @@ stdenv.mkDerivation ({
   configureFlags = [
     "-C"
     "--enable-add-ons"
+    "--localedir=/var/run/current-system/sw/lib/locale"
     (if kernelHeaders != null
      then "--with-headers=${kernelHeaders}/include"
      else "--without-headers")
@@ -89,7 +91,7 @@ stdenv.mkDerivation ({
     "--build=arm-linux-gnueabi"
     "--without-fp"
   ];
-
+  
   buildInputs = stdenv.lib.optionals (cross != null) [ gccCross ]
     ++ stdenv.lib.optional (mig != null) mig;
 
@@ -122,11 +124,11 @@ 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 = "04w74879psq961cas1amidkg8fc1h6r9yj3plfr33v9y6vp7db62";
     };
 
   srcPorts = fetchurl {
@@ -152,7 +154,7 @@ stdenv.mkDerivation ({
     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.11/default.nix
index a9d82e677b1..7063008fe91 100644
--- a/pkgs/development/libraries/glibc-2.11/default.nix
+++ b/pkgs/development/libraries/glibc-2.11/default.nix
@@ -50,9 +50,6 @@ in
        # thing.
        inherit propagatedBuildInputs;
      };
-
-     # XXX: Remove this hack in `stdenv-updates'.
-     builder = ./builder2.sh;
    }
    else { })
 
diff --git a/pkgs/development/libraries/glibc-2.11/gnu89-inline.patch b/pkgs/development/libraries/glibc-2.11/gnu89-inline.patch
new file mode 100644
index 00000000000..16d8f914a19
--- /dev/null
+++ b/pkgs/development/libraries/glibc-2.11/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/locale-override.patch b/pkgs/development/libraries/glibc-2.11/locale-override.patch
deleted file mode 100644
index 108d0e35dac..00000000000
--- 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/nix-locale-archive.patch b/pkgs/development/libraries/glibc-2.11/nix-locale-archive.patch
new file mode 100644
index 00000000000..30e05498662
--- /dev/null
+++ b/pkgs/development/libraries/glibc-2.11/nix-locale-archive.patch
@@ -0,0 +1,122 @@
+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,23 @@ 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");
++  const char *usualpath = "/usr/lib/locale/locale-archive";
++  if (path)
++    fd = open64 (path, access);
++  if (path2 && fd < 0)
++    fd = open64 (path2, access);
++  if (fd < 0)
++    fd = open64 (fname, access);
++  if (fd < 0)
++    fd = open64 (usualpath, 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,23 @@ 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");
++  const char *usualpath = "/usr/lib/locale/locale-archive";
++  if (path)
++    fd = open64 (path, access);
++  if (path2 && fd < 0)
++    fd = open64 (path2, access);
++  if (fd < 0)
++    fd = open64 (fname, access);
++  if (fd < 0)
++    fd = open64 (usualpath, 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.11/nss-skip-unavail.patch b/pkgs/development/libraries/glibc-2.11/nss-skip-unavail.patch
index dc09b509870..e48dc2bc0a6 100644
--- a/pkgs/development/libraries/glibc-2.11/nss-skip-unavail.patch
+++ b/pkgs/development/libraries/glibc-2.11/nss-skip-unavail.patch
@@ -1,25 +1,21 @@
-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)
-  	    {
+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;
-  	      nss_gethostbyname4_r fct4
-  		= __nss_lookup_function (nip, "gethostbyname4_r");
-  	      if (fct4 != NULL)
+ 	      no_data = 0;
+ 	      nss_gethostbyname4_r fct4
+ 		= __nss_lookup_function (nip, "gethostbyname4_r");
diff --git a/pkgs/development/libraries/glibc-2.5/builder.sh b/pkgs/development/libraries/glibc-2.5/builder.sh
index 695a3a1ab3d..4cd0132e370 100644
--- a/pkgs/development/libraries/glibc-2.5/builder.sh
+++ b/pkgs/development/libraries/glibc-2.5/builder.sh
@@ -38,7 +38,7 @@ postConfigure() {
 
 postInstall() {
     if test -n "$installLocales"; then
-        make localedata/install-locales
+        make -j${NIX_BUILD_CORES:-1} -l${NIX_BUILD_CORES:-1} localedata/install-locales
     fi
     rm $out/etc/ld.so.cache
     (cd $out/include && ln -s $kernelHeaders/include/* .) || exit 1
diff --git a/pkgs/development/libraries/glibc-2.5/default.nix b/pkgs/development/libraries/glibc-2.5/default.nix
index abfc3d0f439..83447d8fe8a 100644
--- a/pkgs/development/libraries/glibc-2.5/default.nix
+++ b/pkgs/development/libraries/glibc-2.5/default.nix
@@ -30,6 +30,8 @@ stdenv.mkDerivation {
   # the symbol __i686.get_pc_thunk.dx to be mangled.
   NIX_CFLAGS_COMPILE = "-U__i686";
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = http://www.gnu.org/software/libc/;
     description = "The GNU C Library";
diff --git a/pkgs/development/libraries/gmp/4.3.1.nix b/pkgs/development/libraries/gmp/4.3.1.nix
index 17455b9f1dd..5f83d9ae46d 100644
--- a/pkgs/development/libraries/gmp/4.3.1.nix
+++ b/pkgs/development/libraries/gmp/4.3.1.nix
@@ -16,6 +16,8 @@ stdenv.mkDerivation rec {
 
   doCheck = true;
 
+  enableParallelBuilding = true;
+
   meta = {
     description = "A free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers";
     homepage = http://gmplib.org/;
diff --git a/pkgs/development/libraries/gmp/4.nix b/pkgs/development/libraries/gmp/4.nix
new file mode 100644
index 00000000000..c5a59045bbe
--- /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 0b608fb4aad..338debaa81e 100644
--- a/pkgs/development/libraries/gmp/default.nix
+++ b/pkgs/development/libraries/gmp/default.nix
@@ -1,25 +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/libgcrypt/default.nix b/pkgs/development/libraries/libgcrypt/default.nix
index 438cc212b54..038fbef69e5 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/mpfr/default.nix b/pkgs/development/libraries/mpfr/default.nix
index dea0113cc69..94cf6e3cea5 100644
--- a/pkgs/development/libraries/mpfr/default.nix
+++ b/pkgs/development/libraries/mpfr/default.nix
@@ -10,8 +10,12 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ gmp ];
 
+  patches = [ ./patch01.patch ./patch02.patch ];
+
   doCheck = true;
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = http://www.mpfr.org/;
     description = "GNU MPFR, a library for multiple-precision floating-point arithmetic";
diff --git a/pkgs/development/libraries/mpfr/patch01.patch b/pkgs/development/libraries/mpfr/patch01.patch
new file mode 100644
index 00000000000..2721517c428
--- /dev/null
+++ b/pkgs/development/libraries/mpfr/patch01.patch
@@ -0,0 +1,184 @@
+diff -Naurd mpfr-2.4.2-a/PATCHES mpfr-2.4.2-b/PATCHES
+--- mpfr-2.4.2-a/PATCHES	2009-12-07 13:37:12.000000000 +0000
++++ mpfr-2.4.2-b/PATCHES	2009-12-07 13:37:12.000000000 +0000
+@@ -0,0 +1 @@
++sin_cos_underflow
+diff -Naurd mpfr-2.4.2-a/VERSION mpfr-2.4.2-b/VERSION
+--- mpfr-2.4.2-a/VERSION	2009-11-30 02:43:08.000000000 +0000
++++ mpfr-2.4.2-b/VERSION	2009-12-07 13:37:12.000000000 +0000
+@@ -1 +1 @@
+-2.4.2
++2.4.2-p1
+diff -Naurd mpfr-2.4.2-a/mpfr.h mpfr-2.4.2-b/mpfr.h
+--- mpfr-2.4.2-a/mpfr.h	2009-11-30 02:43:08.000000000 +0000
++++ mpfr-2.4.2-b/mpfr.h	2009-12-07 13:37:12.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 2
+ #define MPFR_VERSION_MINOR 4
+ #define MPFR_VERSION_PATCHLEVEL 2
+-#define MPFR_VERSION_STRING "2.4.2"
++#define MPFR_VERSION_STRING "2.4.2-p1"
+ 
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-2.4.2-a/sin_cos.c mpfr-2.4.2-b/sin_cos.c
+--- mpfr-2.4.2-a/sin_cos.c	2009-11-30 02:43:09.000000000 +0000
++++ mpfr-2.4.2-b/sin_cos.c	2009-12-07 13:37:12.000000000 +0000
+@@ -82,17 +82,19 @@
+       if (y != x)
+         /* y and x differ, thus we can safely try to compute y first */
+         {
+-          MPFR_FAST_COMPUTE_IF_SMALL_INPUT (y, x, -2 * expx, 2, 0, rnd_mode,
+-                                            { inexy = _inexact;
+-                                              goto small_input; });
++          MPFR_FAST_COMPUTE_IF_SMALL_INPUT (
++            y, x, -2 * expx, 2, 0, rnd_mode,
++            { inexy = _inexact;
++              goto small_input; });
+           if (0)
+             {
+             small_input:
+               /* we can go here only if we can round sin(x) */
+-              MPFR_FAST_COMPUTE_IF_SMALL_INPUT (z, __gmpfr_one, -2 * expx,
+-                                                1, 0, rnd_mode,
+-                                                { inexz = _inexact;
+-                                                  goto end; });
++              MPFR_FAST_COMPUTE_IF_SMALL_INPUT (
++                z, __gmpfr_one, -2 * expx, 1, 0, rnd_mode,
++                { inexz = _inexact;
++                  MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags);
++                  goto end; });
+             }
+ 
+           /* if we go here, one of the two MPFR_FAST_COMPUTE_IF_SMALL_INPUT
+@@ -101,18 +103,19 @@
+       else /* y and x are the same variable: try to compute z first, which
+               necessarily differs */
+         {
+-          MPFR_FAST_COMPUTE_IF_SMALL_INPUT (z, __gmpfr_one, -2 * expx,
+-                                            1, 0, rnd_mode,
+-                                            { inexz = _inexact;
+-                                              goto small_input2; });
++          MPFR_FAST_COMPUTE_IF_SMALL_INPUT (
++            z, __gmpfr_one, -2 * expx, 1, 0, rnd_mode,
++            { inexz = _inexact;
++              goto small_input2; });
+           if (0)
+             {
+             small_input2:
+               /* we can go here only if we can round cos(x) */
+-              MPFR_FAST_COMPUTE_IF_SMALL_INPUT (y, x, -2 * expx, 2, 0,
+-                                                rnd_mode,
+-                                                { inexy = _inexact;
+-                                                  goto end; });
++              MPFR_FAST_COMPUTE_IF_SMALL_INPUT (
++                y, x, -2 * expx, 2, 0, rnd_mode,
++                { inexy = _inexact;
++                  MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags);
++                  goto end; });
+             }
+         }
+       m += 2 * (-expx);
+@@ -207,7 +210,6 @@
+   mpfr_clear (xr);
+ 
+  end:
+-  /* FIXME: update the underflow flag if need be. */
+   MPFR_SAVE_EXPO_FREE (expo);
+   mpfr_check_range (y, inexy, rnd_mode);
+   mpfr_check_range (z, inexz, rnd_mode);
+diff -Naurd mpfr-2.4.2-a/tests/tsin_cos.c mpfr-2.4.2-b/tests/tsin_cos.c
+--- mpfr-2.4.2-a/tests/tsin_cos.c	2009-11-30 02:43:08.000000000 +0000
++++ mpfr-2.4.2-b/tests/tsin_cos.c	2009-12-07 13:37:12.000000000 +0000
+@@ -382,23 +382,56 @@
+ consistency (void)
+ {
+   mpfr_t x, s1, s2, c1, c2;
++  mp_exp_t emin, emax;
+   mp_rnd_t rnd;
++  unsigned int flags_sin, flags_cos, flags, flags_before, flags_ref;
++  int inex_sin, inex_cos, inex, inex_ref;
+   int i;
+ 
++  emin = mpfr_get_emin ();
++  emax = mpfr_get_emax ();
++
+   for (i = 0; i <= 10000; i++)
+     {
+       mpfr_init2 (x, MPFR_PREC_MIN + (randlimb () % 8));
+       mpfr_inits2 (MPFR_PREC_MIN + (randlimb () % 8), s1, s2, c1, c2,
+                    (mpfr_ptr) 0);
+-      tests_default_random (x, 256, -5, 50);
+-      rnd = RND_RAND ();
+-      mpfr_sin (s1, x, rnd);
+-      mpfr_cos (c1, x, rnd);
+-      mpfr_sin_cos (s2, c2, x, rnd);
+-      if (!(mpfr_equal_p (s1, s2) && mpfr_equal_p (c1, c2)))
++      if (i < 8 * GMP_RND_MAX)
+         {
+-          printf ("mpfr_sin_cos and mpfr_sin/mpfr_cos disagree on %s,\nx = ",
+-                  mpfr_print_rnd_mode (rnd));
++          int j = i / GMP_RND_MAX;
++          if (j & 1)
++            mpfr_set_emin (MPFR_EMIN_MIN);
++          mpfr_set_si (x, (j & 2) ? 1 : -1, GMP_RNDN);
++          mpfr_set_exp (x, mpfr_get_emin ());
++          rnd = (mpfr_rnd_t) (i % GMP_RND_MAX);
++          flags_before = 0;
++          if (j & 4)
++            mpfr_set_emax (-17);
++        }
++      else
++        {
++          tests_default_random (x, 256, -5, 50);
++          rnd = RND_RAND ();
++          flags_before = (randlimb () & 1) ?
++            (unsigned int) (MPFR_FLAGS_ALL ^ MPFR_FLAGS_ERANGE) :
++            (unsigned int) 0;
++        }
++      __gmpfr_flags = flags_before;
++      inex_sin = mpfr_sin (s1, x, rnd);
++      flags_sin = __gmpfr_flags;
++      __gmpfr_flags = flags_before;
++      inex_cos = mpfr_cos (c1, x, rnd);
++      flags_cos = __gmpfr_flags;
++      __gmpfr_flags = flags_before;
++      inex = !!mpfr_sin_cos (s2, c2, x, rnd);
++      flags = __gmpfr_flags;
++      inex_ref = inex_sin || inex_cos;
++      flags_ref = flags_sin | flags_cos;
++      if (!(mpfr_equal_p (s1, s2) && mpfr_equal_p (c1, c2)) ||
++          inex != inex_ref || flags != flags_ref)
++        {
++          printf ("mpfr_sin_cos and mpfr_sin/mpfr_cos disagree on %s,"
++                  " i = %d\nx = ", mpfr_print_rnd_mode (rnd), i);
+           mpfr_dump (x);
+           printf ("s1 = ");
+           mpfr_dump (s1);
+@@ -408,9 +441,16 @@
+           mpfr_dump (c1);
+           printf ("c2 = ");
+           mpfr_dump (c2);
++          printf ("inex_sin = %d, inex_cos = %d, inex = %d (expected %d)\n",
++                  inex_sin, inex_cos, inex, inex_ref);
++          printf ("flags_sin = 0x%x, flags_cos = 0x%x, "
++                  "flags = 0x%x (expected 0x%x)\n",
++                  flags_sin, flags_cos, flags, flags_ref);
+           exit (1);
+         }
+       mpfr_clears (x, s1, s2, c1, c2, (mpfr_ptr) 0);
++      mpfr_set_emin (emin);
++      mpfr_set_emax (emax);
+     }
+ }
+ 
+diff -Naurd mpfr-2.4.2-a/version.c mpfr-2.4.2-b/version.c
+--- mpfr-2.4.2-a/version.c	2009-11-30 02:43:08.000000000 +0000
++++ mpfr-2.4.2-b/version.c	2009-12-07 13:37:12.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+-  return "2.4.2";
++  return "2.4.2-p1";
+ }
diff --git a/pkgs/development/libraries/mpfr/patch02.patch b/pkgs/development/libraries/mpfr/patch02.patch
new file mode 100644
index 00000000000..bc2f267acc0
--- /dev/null
+++ b/pkgs/development/libraries/mpfr/patch02.patch
@@ -0,0 +1,75 @@
+From http://www.mpfr.org/mpfr-2.4.2/:
+Due to a change in GCC 4.4 internals for MIPS, the MPFR build fails on MIPS processors with GCC 4.4 and later. The longlong.h  patch (written by Aurélien Jarno) solves this problem.
+[Changeset: 6638]
+
+diff -Naurd mpfr-2.4.2-a/PATCHES mpfr-2.4.2-b/PATCHES
+--- mpfr-2.4.2-a/PATCHES	2009-12-18 12:03:30.000000000 +0000
++++ mpfr-2.4.2-b/PATCHES	2009-12-18 12:05:19.000000000 +0000
+@@ -0,0 +1 @@
++longlong.h
+diff -Naurd mpfr-2.4.2-a/VERSION mpfr-2.4.2-b/VERSION
+--- mpfr-2.4.2-a/VERSION	2009-12-07 13:37:12.000000000 +0000
++++ mpfr-2.4.2-b/VERSION	2009-12-18 12:05:09.000000000 +0000
+@@ -1 +1 @@
+-2.4.2-p1
++2.4.2-p2
+diff -Naurd mpfr-2.4.2-a/mpfr-longlong.h mpfr-2.4.2-b/mpfr-longlong.h
+--- mpfr-2.4.2-a/mpfr-longlong.h	2009-11-30 02:43:08.000000000 +0000
++++ mpfr-2.4.2-b/mpfr-longlong.h	2009-12-18 12:04:29.000000000 +0000
+@@ -1011,7 +1011,15 @@
+ #endif /* __m88000__ */
+ 
+ #if defined (__mips) && W_TYPE_SIZE == 32
+-#if __GNUC__ > 2 || __GNUC_MINOR__ >= 7
++#if (__GNUC__ >= 5) || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 4)
++#define umul_ppmm(w1, w0, u, v) \
++  do {									\
++    UDItype _r;							\
++    _r = (UDItype) u * v;						\
++    (w1) = _r >> 32;							\
++    (w0) = (USItype) _r;						\
++  } while (0)
++#elif __GNUC__ > 2 || __GNUC_MINOR__ >= 7
+ #define umul_ppmm(w1, w0, u, v) \
+   __asm__ ("multu %2,%3" : "=l" (w0), "=h" (w1) : "d" (u), "d" (v))
+ #else
+@@ -1024,7 +1032,16 @@
+ #endif /* __mips */
+ 
+ #if (defined (__mips) && __mips >= 3) && W_TYPE_SIZE == 64
+-#if __GNUC__ > 2 || __GNUC_MINOR__ >= 7
++#if (__GNUC__ >= 5) || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 4)
++typedef unsigned int UTItype __attribute__ ((mode (TI)));
++#define umul_ppmm(w1, w0, u, v) \
++  do {									\
++    UTItype _r;							\
++    _r = (UTItype) u * v;						\
++    (w1) = _r >> 64;							\
++    (w0) = (UDItype) _r;						\
++  } while (0)
++#elif __GNUC__ > 2 || __GNUC_MINOR__ >= 7
+ #define umul_ppmm(w1, w0, u, v) \
+   __asm__ ("dmultu %2,%3" : "=l" (w0), "=h" (w1) : "d" (u), "d" (v))
+ #else
+diff -Naurd mpfr-2.4.2-a/mpfr.h mpfr-2.4.2-b/mpfr.h
+--- mpfr-2.4.2-a/mpfr.h	2009-12-07 13:37:12.000000000 +0000
++++ mpfr-2.4.2-b/mpfr.h	2009-12-18 12:05:09.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 2
+ #define MPFR_VERSION_MINOR 4
+ #define MPFR_VERSION_PATCHLEVEL 2
+-#define MPFR_VERSION_STRING "2.4.2-p1"
++#define MPFR_VERSION_STRING "2.4.2-p2"
+ 
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-2.4.2-a/version.c mpfr-2.4.2-b/version.c
+--- mpfr-2.4.2-a/version.c	2009-12-07 13:37:12.000000000 +0000
++++ mpfr-2.4.2-b/version.c	2009-12-18 12:05:09.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+-  return "2.4.2-p1";
++  return "2.4.2-p2";
+ }
diff --git a/pkgs/development/libraries/ncurses/default.nix b/pkgs/development/libraries/ncurses/default.nix
index 344db123801..dd3d60e4812 100644
--- a/pkgs/development/libraries/ncurses/default.nix
+++ b/pkgs/development/libraries/ncurses/default.nix
@@ -14,7 +14,9 @@ stdenv.mkDerivation ( rec {
   '';
 
   selfBuildNativeInput = true;
-    
+
+  enableParallelBuilding = true;
+
   preBuild = ''sed -e "s@\([[:space:]]\)sh @\1''${SHELL} @" -i */Makefile Makefile'';
 
   # When building a wide-character (Unicode) build, create backward
diff --git a/pkgs/development/libraries/openssl/1.x.nix b/pkgs/development/libraries/openssl/1.x.nix
new file mode 100644
index 00000000000..eae32de30e4
--- /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 00000000000..ad8e86c6791
--- /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 ad8e86c6791..f17a40395d6 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/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix
index 3d3385c83f8..f139bce100d 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 ed4cc7f2497..677d578e242 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/qt-4.x/4.5/default.nix b/pkgs/development/libraries/qt-4.x/4.5/default.nix
index 35960c4d8ba..3b29043aeeb 100644
--- a/pkgs/development/libraries/qt-4.x/4.5/default.nix
+++ b/pkgs/development/libraries/qt-4.x/4.5/default.nix
@@ -74,6 +74,8 @@ stdenv.mkDerivation {
     ${if keepDocumentation == false then "rm -rf $out/doc" else ""}
   '';
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = http://www.qtsoftware.com/downloads/opensource/appdev/linux-x11-cpp;
     description = "A cross-platform application framework for C++";
diff --git a/pkgs/development/libraries/qt-4.x/4.6/default.nix b/pkgs/development/libraries/qt-4.x/4.6/default.nix
index 9440765d830..3253e58e7c2 100644
--- a/pkgs/development/libraries/qt-4.x/4.6/default.nix
+++ b/pkgs/development/libraries/qt-4.x/4.6/default.nix
@@ -89,6 +89,8 @@ stdenv.mkDerivation rec {
 
   postInstall = if useDocs then "rm -rf $out/share/doc/${name}/{html,src}" else "";
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = http://qt.nokia.com/products;
     description = "A cross-platform application framework for C++";
diff --git a/pkgs/development/libraries/qt-4.x/4.7/default.nix b/pkgs/development/libraries/qt-4.x/4.7/default.nix
index 2ab7c388553..cc6d3c8d513 100644
--- a/pkgs/development/libraries/qt-4.x/4.7/default.nix
+++ b/pkgs/development/libraries/qt-4.x/4.7/default.nix
@@ -99,6 +99,8 @@ stdenv.mkDerivation rec {
 
   postInstall = if useDocs then "rm -rf $out/share/doc/${name}/{html,src}" else "";
 
+  enableParallelBuilding = true;
+
   meta = with stdenv.lib; {
     homepage = http://qt.nokia.com/products;
     description = "A cross-platform application framework for C++";
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 695d3e35670..00000000000
--- 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 1bb110e35fd..3e3dedd1e83 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/gnum4/default.nix b/pkgs/development/tools/misc/gnum4/default.nix
index 0c73ba1f738..717a48f11e6 100644
--- a/pkgs/development/tools/misc/gnum4/default.nix
+++ b/pkgs/development/tools/misc/gnum4/default.nix
@@ -1,11 +1,11 @@
 {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;
diff --git a/pkgs/development/tools/misc/patchelf/0.6.nix b/pkgs/development/tools/misc/patchelf/0.6.nix
index dfd0b077411..3774c44480d 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/lib/platforms.nix b/pkgs/lib/platforms.nix
index 635b195e1d6..095281145d2 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"
+    "ict_loongson-2_v0.3_fpu_v0.1-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 1d190cf661d..1ae51d64e30 100644
--- a/pkgs/misc/busybox/default.nix
+++ b/pkgs/misc/busybox/default.nix
@@ -1,13 +1,41 @@
-{stdenv, fetchurl, enableStatic ? false}:
+{stdenv, fetchurl, enableStatic ? false, extraConfig ? null}:
 
 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
@@ -20,14 +48,24 @@ stdenv.mkDerivation {
     sha256 = "1n738zk01yi2sjrx2y36hpzxbslas8b91vzykcifr0p1j7ym0lim";
   };
 
-  configurePhase = basicConfigure;
+  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/uboot/nanonote.nix b/pkgs/misc/uboot/nanonote.nix
new file mode 100644
index 00000000000..9e39501a7a3
--- /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/kernel-headers/2.6.28.nix b/pkgs/os-specific/linux/kernel-headers/2.6.28.nix
index 82840f8a51f..a85e6f79bf1 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 936ef5ec40d..a4e86658193 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/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix
index 15811713324..fb59fa0b7d5 100644
--- a/pkgs/os-specific/linux/kernel/generic.nix
+++ b/pkgs/os-specific/linux/kernel/generic.nix
@@ -41,7 +41,7 @@
 }:
 
 assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux"
-  || stdenv.system == "armv5tel-linux";
+  || stdenv.system == "armv5tel-linux" || stdenv.system == "ict_loongson-2_v0.3_fpu_v0.1-linux";
 
 assert stdenv.platform.name == "sheevaplug" -> stdenv.platform.uboot != null;
 
@@ -96,6 +96,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 == "ict_loongson-2_v0.3_fpu_v0.1-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 00000000000..859438359c7
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/linux-nanonote-jz-2.6.34.nix
@@ -0,0 +1,212 @@
+args @ { stdenv, fetchgit, 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 = "jz-2.6.34";
+  
+    src = fetchgit {
+      url = "git://projects.qi-hardware.com/qi-kernel.git";
+      rev = "f42d987a04d6f9366c47edf794f66796151867b9";
+      sha256 = "bc9da0af30d5bf4c7be7495e052b328e72ab6a7f8a57e201720e3198cd6afb22";
+    };
+
+    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 00000000000..a5f913bc248
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/linux-nanonote-jz-2.6.35.nix
@@ -0,0 +1,212 @@
+args @ { stdenv, fetchgit, 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 = "jz-2.6.35";
+  
+    src = fetchgit {
+      url = "git://projects.qi-hardware.com/qi-kernel.git";
+      rev = "4a5edaeef89037e288d8ae6c81eca1c6bda753da";
+      sha256 = "42778cf871473bebc609eb26441591318b8396b03671360193bbe0e50cc29082";
+    };
+
+    config = configWithPlatform stdenv.platform;
+    configCross = configWithPlatform stdenv.cross.platform;
+
+    features.iwlwifi = true;
+  }
+
+  // removeAttrs args ["extraConfig"]
+)
diff --git a/pkgs/os-specific/linux/klibc/default.nix b/pkgs/os-specific/linux/klibc/default.nix
index c3967f4f1ab..5a27816472d 100644
--- a/pkgs/os-specific/linux/klibc/default.nix
+++ b/pkgs/os-specific/linux/klibc/default.nix
@@ -1,26 +1,47 @@
-{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.18";
+  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 = "0ik4ddkfzjrrhpb50i31f2zihqlcnm82yqnl5ci59wx56j5ly474";
   };
   
-  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 +53,5 @@ stdenv.mkDerivation {
     cp usr/dash/sh $dir/
   '';
   
-  buildInputs = [perl bison mktemp];
+  buildNativeInputs = [ perl bison mktemp ];
 }
diff --git a/pkgs/os-specific/linux/lvm2/default.nix b/pkgs/os-specific/linux/lvm2/default.nix
index 96b5e5b019a..da2292848dc 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/LVM2.${v}.tgz";
-    sha256 =  "2a4157b91b7ad5ea84359e8548b64947611beea01862e010be71f54b649e7ad1";
+    sha256 = "1lbskrj4pxbipq8f0qhql3p1nqa796v4i1cy6n2fmmbs3fwmfh9a";
   };
   
   configureFlags = "--disable-readline --enable-udev_rules --enable-udev_sync";
diff --git a/pkgs/os-specific/linux/uclibc/default.nix b/pkgs/os-specific/linux/uclibc/default.nix
index 83de2ae38ef..5c941f06410 100644
--- a/pkgs/os-specific/linux/uclibc/default.nix
+++ b/pkgs/os-specific/linux/uclibc/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, linuxHeaders, cross ? null, gccCross ? null}:
+{stdenv, fetchurl, linuxHeaders, libiconv, cross ? null, gccCross ? null}:
 
 assert stdenv.isLinux;
 assert cross != null -> gccCross != null;
@@ -31,15 +31,21 @@ stdenv.mkDerivation {
     sha256 = "0f1fpdwampbw7pf79i64ipj0azk4kbc9wl81ynlp19p92k4klz0h";
   };
 
+  # '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_FTW.*@UCLIBC_HAS_FTW=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@' \
+      -e 's@.*CONFIG_MIPS_ISA_1.*@#CONFIG_MIPS_ISA_1=y@' \
+      -e 's@.*CONFIG_MIPS_ISA_3.*@CONFIG_MIPS_ISA_3=y@' \
+      -e 's@.*CONFIG_MIPS_O32_ABI.*@#CONFIG_MIPS_O32_ABI=y@' \
+      -e 's@.*CONFIG_MIPS_N32_ABI.*@CONFIG_MIPS_N32_ABI=y@' \
       ${configArmEABI} \
       ${configBigEndian} \
       -i .config
@@ -59,6 +65,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 ca21deb6489..60ffeb70737 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/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix
index 0075820a5ad..16597d70c1a 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 40acb8cfece..037a60da7e6 100644
--- a/pkgs/stdenv/default.nix
+++ b/pkgs/stdenv/default.nix
@@ -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 == "ict_loongson-2_v0.3_fpu_v0.1-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 b30b9c8d4dc..4d2200d1971 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -94,7 +94,9 @@ 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 == "ict_loongson-2_v0.3_fpu_v0.1-linux";
+        isSunOS = result.system == "i386-sunos";
         isSunOS = result.system == "i386-sunos";
         isi686 = result.system == "i686-linux"
                || result.system == "i686-darwin"
diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh
index 5e2fc7b24db..948b6ca3ad6 100644
--- a/pkgs/stdenv/generic/setup.sh
+++ b/pkgs/stdenv/generic/setup.sh
@@ -269,6 +269,23 @@ fi
 export NIX_INDENT_MAKE=1
 
 
+# Normalize the NIX_BUILD_CORES variable. The value might be 0, which
+# means that we're supposed to try and auto-detect the number of
+# available CPU cores at run-time.
+
+if test -z "${NIX_BUILD_CORES:-}"; then
+  NIX_BUILD_CORES="1"
+elif test "$NIX_BUILD_CORES" -le 0; then
+  NIX_BUILD_CORES=$(nproc 2>/dev/null || true)
+  if expr >/dev/null 2>&1 "$NIX_BUILD_CORES" : "^[0-9][0-9]*$"; then
+    :
+  else
+    NIX_BUILD_CORES="1"
+  fi
+fi
+export NIX_BUILD_CORES
+
+
 ######################################################################
 # Misc. helper functions.
 
@@ -603,6 +620,7 @@ buildPhase() {
 
     echo "make flags: $makeFlags ${makeFlagsArray[@]} $buildFlags ${buildFlagsArray[@]}"
     make ${makefile:+-f $makefile} \
+        ${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}} \
         $makeFlags "${makeFlagsArray[@]}" \
         $buildFlags "${buildFlagsArray[@]}"
 
@@ -615,6 +633,7 @@ checkPhase() {
 
     echo "check flags: $makeFlags ${makeFlagsArray[@]} $checkFlags ${checkFlagsArray[@]}"
     make ${makefile:+-f $makefile} \
+        ${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}} \
         $makeFlags "${makeFlagsArray[@]}" \
         $checkFlags "${checkFlagsArray[@]}" ${checkTarget:-check}
 
diff --git a/pkgs/stdenv/linux/bootstrap/loongson2f/bzip2 b/pkgs/stdenv/linux/bootstrap/loongson2f/bzip2
new file mode 100755
index 00000000000..f86964d119c
--- /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 00000000000..bf6fd66be23
--- /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 00000000000..f227a24bf71
--- /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 00000000000..a87f07e00ce
--- /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 00000000000..d8afd276424
--- /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 00000000000..3a95ccf18d6
--- /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 00000000000..f8ef0a74d6b
--- /dev/null
+++ b/pkgs/stdenv/linux/bootstrap/loongson2f/sh
Binary files differdiff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix
index 71aee5912e7..bfeb01a7cd7 100644
--- a/pkgs/stdenv/linux/default.nix
+++ b/pkgs/stdenv/linux/default.nix
@@ -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 == "ict_loongson-2_v0.3_fpu_v0.1-linux" then import ./bootstrap/loongson2f
     else abort "unsupported platform for the pure Linux stdenv";
 
 
@@ -184,6 +185,18 @@ rec {
     bootStdenv = stdenvLinuxBoot2;
   };
 
+  gccWithStaticLibs = stdenvLinuxBoot2Pkgs.gcc.gcc.override (rec {
+        ppl = stdenvLinuxBoot2Pkgs.ppl.override {
+          static = true;
+          gmpxx = stdenvLinuxBoot2Pkgs.gmpxx.override {
+            static = true;
+          };
+        };
+        cloogppl = stdenvLinuxBoot2Pkgs.cloogppl.override {
+          inherit ppl;
+          static = true;
+        };
+      });
 
   # 6) Construct a third stdenv identical to the second, except that
   #    this one uses the dynamically linked GCC and Binutils from step
@@ -194,7 +207,7 @@ rec {
       inherit (stdenvLinuxBoot2Pkgs) binutils;
       coreutils = bootstrapTools;
       libc = stdenvLinuxGlibc;
-      gcc = stdenvLinuxBoot2Pkgs.gcc.gcc;
+      gcc = gccWithStaticLibs;
       name = "";
     };
     overrides = {
@@ -232,7 +245,7 @@ rec {
       inherit (stdenvLinuxBoot2Pkgs) binutils;
       inherit (stdenvLinuxBoot3Pkgs) coreutils;
       libc = stdenvLinuxGlibc;
-      gcc = stdenvLinuxBoot2Pkgs.gcc.gcc;
+      gcc = gccWithStaticLibs;
       shell = stdenvLinuxBoot3Pkgs.bash + "/bin/bash";
       name = "";
     };
diff --git a/pkgs/stdenv/linux/make-bootstrap-tools.nix b/pkgs/stdenv/linux/make-bootstrap-tools.nix
index 3f68738c310..9a337de9b21 100644
--- a/pkgs/stdenv/linux/make-bootstrap-tools.nix
+++ b/pkgs/stdenv/linux/make-bootstrap-tools.nix
@@ -80,7 +80,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
diff --git a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh
index 2399e48b026..b3f5dbb546d 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*; 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 a49b4de52b0..a74b60d9517 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 a3522c74350..00000000000
--- 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 0523067cbad..e8ac6c6418c 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/misc/coreutils/default.nix b/pkgs/tools/misc/coreutils/default.nix
index f4cf9fe9886..2d1052e3a0f 100644
--- a/pkgs/tools/misc/coreutils/default.nix
+++ b/pkgs/tools/misc/coreutils/default.nix
@@ -1,10 +1,8 @@
-{ 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 {
+stdenv.mkDerivation rec {
   name = "coreutils-8.4";
 
   src = fetchurl {
@@ -13,16 +11,27 @@ stdenv.mkDerivation (rec {
   };
 
   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;
 
   meta = {
     homepage = http://www.gnu.org/software/coreutils/;
@@ -40,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 2350ab26049..11ed1cf07b5 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/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 00000000000..e5c4ba1b01e
--- /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 44b7715607c..4fde88d9262 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/gnugrep/default.nix b/pkgs/tools/text/gnugrep/default.nix
index 609213aaa67..1cd73a8814c 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 00000000000..b645c64a09e
--- /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 513a98fdf07..ff469ddad25 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 cea26999be0..66fcb3d1929 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 8ef7e8b5ce4..00000000000
--- 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/replace/default.nix b/pkgs/tools/text/replace/default.nix
index 0182a3bb48d..339bf510c4b 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 f973c8d8d8e..56ed6695462 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -181,7 +181,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 {
@@ -1409,7 +1409,7 @@ let
 
   gambit = callPackage ../development/compilers/gambit { };
 
-  gcc = gcc44;
+  gcc = gcc45;
 
   gcc295 = wrapGCC (import ../development/compilers/gcc-2.95 {
     inherit fetchurl stdenv noSysDirs;
@@ -1445,8 +1445,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;
@@ -1464,7 +1462,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;
@@ -1474,6 +1472,8 @@ let
       cross = assert crossSystem != null; crossSystem;
     });
 
+  gcc45 = useFromStdenv "gcc" gcc45_real;
+
   gcc45_realCross = lib.addMetaAttrs { platforms = []; }
     (makeOverridable (import ../development/compilers/gcc-4.5) {
       inherit fetchurl stdenv texinfo gmp mpfr mpc libelf zlib
@@ -1532,17 +1532,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 =
@@ -1556,7 +1558,7 @@ let
     texinfo = texinfo49;
   });
 
-  gfortran = gfortran43;
+  gfortran = gfortran45;
 
   gfortran40 = wrapGCC (gcc40.gcc.override {
     langFortran = true;
@@ -1588,7 +1590,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;
@@ -1598,7 +1608,7 @@ let
 
   gcj = gcj45;
 
-  gcj44 = wrapGCC (gcc44_real.gcc.override {
+  gcj44 = wrapGCC (gcc44.gcc.override {
     name = "gcj";
     langJava = true;
     langFortran = false;
@@ -1626,9 +1636,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;
@@ -1825,9 +1848,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 { };
 
@@ -1953,14 +1974,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"}:
 
@@ -2587,7 +2600,6 @@ let
   clanlib = callPackage ../development/libraries/clanlib { };
 
   clapack = callPackage ../development/libraries/clapack {
-    stdenv = stdenv2;
   };
 
   classads = callPackage ../development/libraries/classads { };
@@ -2760,9 +2772,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 { };
@@ -2874,14 +2883,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;
       };
@@ -3507,7 +3518,6 @@ let
   opencv = callPackage ../development/libraries/opencv {
       inherit (gtkLibs) gtk glib;
       inherit (gst_all) gstreamer;
-      stdenv = stdenv2;
   };
 
   # this ctl version is needed by openexr_viewers
@@ -4346,7 +4356,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;
@@ -4485,6 +4495,16 @@ let
       ];
   };
 
+  linux_nanonote_jz_2_6_34 = makeOverridable
+    (import ../os-specific/linux/kernel/linux-nanonote-jz-2.6.34.nix) {
+      inherit fetchurl fetchgit 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 fetchgit stdenv perl mktemp module_init_tools ubootChooser;
+    };
+
   /* Linux kernel modules are inherently tied to a specific kernel.  So
      rather than provide specific instances of those packages for a
      specific kernel, we have a function that builds those packages
@@ -4586,6 +4606,8 @@ let
     recurseIntoAttrs (linuxPackagesFor linux_2_6_32_systemtap pkgs.linuxPackages_2_6_32_systemtap);
   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_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;
@@ -4768,16 +4790,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;
@@ -5041,7 +5066,6 @@ let
 
   avidemux = callPackage ../applications/video/avidemux {
     inherit (gtkLibs) gtk;
-    stdenv = stdenv2;
   };
 
   awesome = callPackage ../applications/window-managers/awesome {
@@ -5087,15 +5111,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 {
@@ -5584,7 +5606,6 @@ let
   };
 
   hugin = callPackage ../applications/graphics/hugin {
-    stdenv = stdenv2;
   };
 
   i810switch = callPackage ../os-specific/linux/i810switch { };
@@ -5828,7 +5849,6 @@ let
     inherit (perlPackages) ArchiveZip CompressZlib;
     inherit (gnome) GConf ORBit2;
     neon = neon029;
-    stdenv = stdenv2;
   };
 
   go_oo = callPackage ../applications/office/openoffice/go-oo.nix {
@@ -5836,7 +5856,6 @@ let
     inherit (perlPackages) ArchiveZip CompressZlib;
     inherit (gnome) GConf ORBit2;
     neon = neon029;
-    stdenv = stdenv2;
   };
 
   opera = callPackage ../applications/networking/browsers/opera {
@@ -5857,7 +5876,6 @@ let
   };
 
   paraview = callPackage ../applications/graphics/paraview {
-    stdenv = stdenv2;
   };
 
   partitionManager = callPackage ../tools/misc/partition-manager {
@@ -6547,7 +6565,7 @@ let
 
   kde44 = makeOverridable (import ../desktops/kde-4.4) (pkgs // {
     qt4 = qt46;
-    stdenv = stdenv2;
+    inherit stdenv;
   });
 
   kde45 = callPackage ../desktops/kde-4.5 {
@@ -6556,7 +6574,6 @@ let
       pyqt4 = pyqt4.override { qt4 = qt47; };
       libdbusmenu_qt = libdbusmenu_qt.override { qt4 = qt47; };
       shared_desktop_ontologies = shared_desktop_ontologies.override { v = "0.5"; };
-      stdenv = stdenv2;
     } // kde45);
   };
 
@@ -6689,9 +6706,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;
@@ -6699,7 +6714,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 cb35db579b7..f3f6acad757 100644
--- a/pkgs/top-level/platforms.nix
+++ b/pkgs/top-level/platforms.nix
@@ -152,4 +152,57 @@ rec {
     uboot = "upstream";
     ubootConfig = "integratorcp_config";
   };
+
+  fuloong2f_n32 = {
+    name = "fuloong2f_n32";
+    kernelMajor = "2.6";
+    kernelHeadersBaseConfig = "fuloong2e_defconfig";
+    kernelBaseConfig = "fuloong2f_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
+        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
+      '';
+    kernelTarget = "vmlinux";
+    uboot = null;
+  };
 }
diff --git a/pkgs/top-level/release-lib.nix b/pkgs/top-level/release-lib.nix
index a470098529f..0345ebba0c4 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