about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2017-12-11 09:49:56 +0100
committerVladimír Čunát <vcunat@gmail.com>2017-12-11 09:49:56 +0100
commite9c12f6936b877eb707203f12170bac85255db50 (patch)
treeaeaa4249ddf5e1a0094d7d32e5f503a8363b8d4c /pkgs
parentd1c9beebdbf22aa04419a1fe412c43160552aef7 (diff)
parent2309acf72337b49eef43d1dfc90d850d2682a4a5 (diff)
downloadnixlib-e9c12f6936b877eb707203f12170bac85255db50.tar
nixlib-e9c12f6936b877eb707203f12170bac85255db50.tar.gz
nixlib-e9c12f6936b877eb707203f12170bac85255db50.tar.bz2
nixlib-e9c12f6936b877eb707203f12170bac85255db50.tar.lz
nixlib-e9c12f6936b877eb707203f12170bac85255db50.tar.xz
nixlib-e9c12f6936b877eb707203f12170bac85255db50.tar.zst
nixlib-e9c12f6936b877eb707203f12170bac85255db50.zip
Merge older staging
There are some regressions, but not that many and I want
the security update of openssl fast.
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/applications/altcoins/memorycoin.nix4
-rw-r--r--pkgs/applications/altcoins/primecoin.nix4
-rw-r--r--pkgs/applications/gis/qgis/default.nix3
-rw-r--r--pkgs/applications/graphics/awesomebump/default.nix5
-rw-r--r--pkgs/applications/graphics/awesomebump/qtnproperty-parallel-building.patch9
-rw-r--r--pkgs/applications/misc/golden-cheetah/default.nix4
-rw-r--r--pkgs/applications/networking/instant-messengers/dino/default.nix3
-rw-r--r--pkgs/applications/networking/instant-messengers/ricochet/default.nix3
-rw-r--r--pkgs/applications/networking/ostinato/default.nix4
-rw-r--r--pkgs/applications/science/logic/stp/default.nix4
-rw-r--r--pkgs/applications/science/machine-learning/shogun/default.nix8
-rw-r--r--pkgs/applications/version-management/guitone/default.nix3
-rw-r--r--pkgs/applications/version-management/guitone/parallel-building.patch7
-rw-r--r--pkgs/desktops/gnome-3/apps/gedit/src.nix6
-rw-r--r--pkgs/desktops/gnome-3/apps/glade/default.nix20
-rw-r--r--pkgs/desktops/gnome-3/apps/glade/src.nix6
-rw-r--r--pkgs/desktops/gnome-3/core/adwaita-icon-theme/src.nix6
-rw-r--r--pkgs/desktops/gnome-3/core/dconf/default.nix4
-rw-r--r--pkgs/desktops/gnome-3/core/gsettings-desktop-schemas/src.nix6
-rw-r--r--pkgs/desktops/gnome-3/core/gtksourceview/src.nix6
-rw-r--r--pkgs/desktops/gnome-3/core/gucharmap/src.nix6
-rw-r--r--pkgs/desktops/gnome-3/core/libgweather/src.nix6
-rw-r--r--pkgs/desktops/gnome-3/core/rest/default.nix4
-rw-r--r--pkgs/desktops/gnome-3/core/totem-pl-parser/src.nix2
-rw-r--r--pkgs/desktops/gnome-3/core/totem/default.nix2
-rw-r--r--pkgs/desktops/gnome-3/core/tracker-miners/src.nix6
-rw-r--r--pkgs/desktops/gnome-3/core/tracker/default.nix2
-rw-r--r--pkgs/desktops/gnome-3/core/tracker/src.nix6
-rw-r--r--pkgs/desktops/gnome-3/games/aisleriot/src.nix6
-rw-r--r--pkgs/desktops/gnome-3/games/four-in-a-row/src.nix6
-rw-r--r--pkgs/desktops/gnome-3/games/gnome-robots/src.nix6
-rw-r--r--pkgs/desktops/gnome-3/games/hitori/src.nix6
-rw-r--r--pkgs/desktops/gnome-3/misc/gspell/default.nix4
-rw-r--r--pkgs/desktops/gnome-3/misc/gspell/src.nix12
-rw-r--r--pkgs/desktops/gnome-3/misc/libgit2-glib/src.nix6
-rw-r--r--pkgs/desktops/gnome-3/misc/libmediaart/default.nix8
-rw-r--r--pkgs/development/compilers/gcc/4.5/default.nix75
-rw-r--r--pkgs/development/compilers/gcc/4.8/default.nix83
-rw-r--r--pkgs/development/compilers/gcc/4.9/default.nix83
-rw-r--r--pkgs/development/compilers/gcc/5/default.nix82
-rw-r--r--pkgs/development/compilers/gcc/6/default.nix83
-rw-r--r--pkgs/development/compilers/gcc/7/default.nix83
-rw-r--r--pkgs/development/compilers/gcc/builder.sh202
-rw-r--r--pkgs/development/compilers/gcc/snapshot/default.nix83
-rw-r--r--pkgs/development/interpreters/perl/default.nix6
-rw-r--r--pkgs/development/libraries/at-spi2-atk/default.nix8
-rw-r--r--pkgs/development/libraries/at-spi2-core/default.nix11
-rw-r--r--pkgs/development/libraries/atk/default.nix13
-rw-r--r--pkgs/development/libraries/babl/default.nix9
-rw-r--r--pkgs/development/libraries/cairomm/default.nix8
-rw-r--r--pkgs/development/libraries/fftw/default.nix4
-rw-r--r--pkgs/development/libraries/gegl/3.0.nix18
-rw-r--r--pkgs/development/libraries/glib-networking/default.nix4
-rw-r--r--pkgs/development/libraries/gstreamer/bad/default.nix8
-rw-r--r--pkgs/development/libraries/gstreamer/base/default.nix4
-rw-r--r--pkgs/development/libraries/gstreamer/core/default.nix4
-rw-r--r--pkgs/development/libraries/gstreamer/ges/default.nix2
-rw-r--r--pkgs/development/libraries/gstreamer/good/default.nix4
-rw-r--r--pkgs/development/libraries/gstreamer/libav/default.nix4
-rw-r--r--pkgs/development/libraries/gstreamer/ugly/default.nix4
-rw-r--r--pkgs/development/libraries/gstreamer/vaapi/default.nix2
-rw-r--r--pkgs/development/libraries/gstreamer/validate/default.nix2
-rw-r--r--pkgs/development/libraries/libaccounts-glib/default.nix6
-rw-r--r--pkgs/development/libraries/libinput/default.nix4
-rw-r--r--pkgs/development/libraries/libmicrohttpd/default.nix4
-rw-r--r--pkgs/development/libraries/openssl/default.nix4
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/qmake-hook.sh5
-rw-r--r--pkgs/development/libraries/qt-5/hooks/qmake-hook.sh5
-rw-r--r--pkgs/development/python-modules/TurboCheetah/default.nix26
-rw-r--r--pkgs/development/python-modules/backports_shutil_get_terminal_size/default.nix26
-rw-r--r--pkgs/development/python-modules/bootstrapped-pip/default.nix4
-rw-r--r--pkgs/development/python-modules/cheetah/default.nix33
-rw-r--r--pkgs/development/python-modules/contextlib2/default.nix5
-rw-r--r--pkgs/development/python-modules/gst-python/default.nix2
-rw-r--r--pkgs/development/python-modules/pathlib2/default.nix31
-rw-r--r--pkgs/development/python-modules/setuptools/default.nix4
-rwxr-xr-xpkgs/development/tools/build-managers/cmake/setup-hook.sh9
-rw-r--r--pkgs/development/tools/build-managers/meson/setup-hook.sh5
-rw-r--r--pkgs/development/tools/build-managers/ninja/setup-hook.sh9
-rw-r--r--pkgs/development/tools/misc/editorconfig-core-c/default.nix4
-rw-r--r--pkgs/games/chessx/default.nix2
-rw-r--r--pkgs/misc/cups/default.nix67
-rw-r--r--pkgs/os-specific/linux/conky/default.nix4
-rw-r--r--pkgs/tools/misc/desktop-file-utils/default.nix4
-rw-r--r--pkgs/tools/misc/rockbox-utility/default.nix6
-rw-r--r--pkgs/top-level/python-packages.nix54
86 files changed, 791 insertions, 624 deletions
diff --git a/pkgs/applications/altcoins/memorycoin.nix b/pkgs/applications/altcoins/memorycoin.nix
index 24b891d60eb2..a14276d4fa2d 100644
--- a/pkgs/applications/altcoins/memorycoin.nix
+++ b/pkgs/applications/altcoins/memorycoin.nix
@@ -31,6 +31,10 @@ stdenv.mkDerivation rec{
     then "install -D bitcoin-qt $out/bin/memorycoin-qt"
     else "install -D bitcoind $out/bin/memorycoind";
 
+  # `make build/version.o`:
+  # make: *** No rule to make target 'build/build.h', needed by 'build/version.o'.  Stop.
+  enableParallelBuilding = false;
+
   meta = {
     description = "Peer-to-peer, CPU-based electronic cash system";
     longDescription= ''
diff --git a/pkgs/applications/altcoins/primecoin.nix b/pkgs/applications/altcoins/primecoin.nix
index b1e3dc2dd93d..f79d54d0ce26 100644
--- a/pkgs/applications/altcoins/primecoin.nix
+++ b/pkgs/applications/altcoins/primecoin.nix
@@ -31,6 +31,10 @@ stdenv.mkDerivation rec{
     then "install -D bitcoin-qt $out/bin/primecoin-qt"
     else "install -D bitcoind $out/bin/primecoind";
 
+  # `make build/version.o`:
+  # make: *** No rule to make target 'build/build.h', needed by 'build/version.o'.  Stop.
+  enableParallelBuilding = false;
+
   meta = {
     description = "A new type cryptocurrency which is proof-of-work based on searching for prime numbers";
     longDescription= ''
diff --git a/pkgs/applications/gis/qgis/default.nix b/pkgs/applications/gis/qgis/default.nix
index f64845f6e43a..e33b2dba3fa7 100644
--- a/pkgs/applications/gis/qgis/default.nix
+++ b/pkgs/applications/gis/qgis/default.nix
@@ -14,8 +14,9 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake makeWrapper ];
 
+  # `make -f src/providers/wms/CMakeFiles/wmsprovider_a.dir/build.make src/providers/wms/CMakeFiles/wmsprovider_a.dir/qgswmssourceselect.cpp.o`:
   # fatal error: ui_qgsdelimitedtextsourceselectbase.h: No such file or directory
-  #enableParallelBuilding = true;
+  enableParallelBuilding = false;
 
   # To handle the lack of 'local' RPATH; required, as they call one of
   # their built binaries requiring their libs, in the build process.
diff --git a/pkgs/applications/graphics/awesomebump/default.nix b/pkgs/applications/graphics/awesomebump/default.nix
index f190b421b056..f7a813f36061 100644
--- a/pkgs/applications/graphics/awesomebump/default.nix
+++ b/pkgs/applications/graphics/awesomebump/default.nix
@@ -15,6 +15,7 @@ let
     name = "qtnproperty";
     inherit src;
     sourceRoot = "AwesomeBump/Sources/utils/QtnProperty";
+    patches = [ ./qtnproperty-parallel-building.patch ];
     buildInputs = [ qtscript qtbase qtdeclarative ];
     nativeBuildInputs = [ qmake flex bison ];
     postInstall = ''
@@ -46,6 +47,10 @@ in stdenv.mkDerivation rec {
         --run "cd $d"
   '';
 
+  # $ cd Sources; qmake; make ../workdir/linux-g++-dgb-gl4/obj/glwidget.o
+  # fatal error: properties/ImageProperties.peg.h: No such file or directory
+  enableParallelBuilding = false;
+
   meta = {
     homepage = https://github.com/kmkolasinski/AwesomeBump;
     description = "A program to generate normal, height, specular or ambient occlusion textures from a single image";
diff --git a/pkgs/applications/graphics/awesomebump/qtnproperty-parallel-building.patch b/pkgs/applications/graphics/awesomebump/qtnproperty-parallel-building.patch
new file mode 100644
index 000000000000..b3f8e68dd1ad
--- /dev/null
+++ b/pkgs/applications/graphics/awesomebump/qtnproperty-parallel-building.patch
@@ -0,0 +1,9 @@
+--- a/PEG/Flex.pri
++++ b/PEG/Flex.pri
+@@ -1,5 +1,6 @@
+ flex.name = Flex ${QMAKE_FILE_IN}
+ flex.input = FLEX_SOURCES
++flex.depends = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.parser.cpp
+ flex.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.lexer.cpp
+ 
+ win32:flex.commands = win_flex --wincompat -o ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.lexer.cpp ${QMAKE_FILE_IN}
diff --git a/pkgs/applications/misc/golden-cheetah/default.nix b/pkgs/applications/misc/golden-cheetah/default.nix
index 358d9dff44a6..efd3bfe73dd9 100644
--- a/pkgs/applications/misc/golden-cheetah/default.nix
+++ b/pkgs/applications/misc/golden-cheetah/default.nix
@@ -30,6 +30,10 @@ stdenv.mkDerivation rec {
 
     runHook postInstall
   '';
+
+  # RCC: Error in 'Resources/application.qrc': Cannot find file 'translations/gc_fr.qm'
+  enableParallelBuilding = false;
+
   meta = {
     description = "Performance software for cyclists, runners and triathletes";
     platforms = stdenv.lib.platforms.linux;
diff --git a/pkgs/applications/networking/instant-messengers/dino/default.nix b/pkgs/applications/networking/instant-messengers/dino/default.nix
index ca7f717810fa..bfe4e9708e3d 100644
--- a/pkgs/applications/networking/instant-messengers/dino/default.nix
+++ b/pkgs/applications/networking/instant-messengers/dino/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchFromGitHub
-, vala, cmake, wrapGAppsHook, pkgconfig, gettext
+, vala, cmake, ninja, wrapGAppsHook, pkgconfig, gettext
 , gobjectIntrospection, gnome3, glib, gdk_pixbuf, gtk3, glib_networking
 , xorg, libXdmcp, libxkbcommon
 , libnotify, libsoup
@@ -26,6 +26,7 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [
     vala
     cmake
+    ninja
     pkgconfig
     wrapGAppsHook
   ];
diff --git a/pkgs/applications/networking/instant-messengers/ricochet/default.nix b/pkgs/applications/networking/instant-messengers/ricochet/default.nix
index 050eb7765906..c99130f28a39 100644
--- a/pkgs/applications/networking/instant-messengers/ricochet/default.nix
+++ b/pkgs/applications/networking/instant-messengers/ricochet/default.nix
@@ -46,6 +46,9 @@ stdenv.mkDerivation rec {
     cp icons/ricochet.png $out/share/pixmaps/ricochet.png
   '';
 
+  # RCC: Error in 'translation/embedded.qrc': Cannot find file 'ricochet_en.qm'
+  enableParallelBuilding = false;
+
   meta = with stdenv.lib; {
     description = "Anonymous peer-to-peer instant messaging";
     homepage = https://ricochet.im;
diff --git a/pkgs/applications/networking/ostinato/default.nix b/pkgs/applications/networking/ostinato/default.nix
index 41e64d7b721f..f2b7a4a4e999 100644
--- a/pkgs/applications/networking/ostinato/default.nix
+++ b/pkgs/applications/networking/ostinato/default.nix
@@ -54,6 +54,10 @@ stdenv.mkDerivation rec {
     EOF
   '';
 
+  # `cd common; qmake ostproto.pro; make pdmlreader.o`:
+  # pdmlprotocol.h:23:25: fatal error: protocol.pb.h: No such file or directory
+  enableParallelBuilding = false;
+
   meta = with stdenv.lib; {
     description = "A packet traffic generator and analyzer";
     homepage    = http://ostinato.org;
diff --git a/pkgs/applications/science/logic/stp/default.nix b/pkgs/applications/science/logic/stp/default.nix
index 8c0b82cc549c..367449f44f38 100644
--- a/pkgs/applications/science/logic/stp/default.nix
+++ b/pkgs/applications/science/logic/stp/default.nix
@@ -23,6 +23,10 @@ stdenv.mkDerivation rec {
     )
   '';
 
+  # `make -f lib/Interface/CMakeFiles/cppinterface.dir/build.make lib/Interface/CMakeFiles/cppinterface.dir/cpp_interface.cpp.o`:
+  # include/stp/AST/UsefulDefs.h:41:29: fatal error: stp/AST/ASTKind.h: No such file or directory
+  enableParallelBuilding = false;
+
   meta = with stdenv.lib; {
     description = "Simple Theorem Prover";
     maintainers = with maintainers; [ mornfall ];
diff --git a/pkgs/applications/science/machine-learning/shogun/default.nix b/pkgs/applications/science/machine-learning/shogun/default.nix
index 9d736694cbdc..ae272284bcdc 100644
--- a/pkgs/applications/science/machine-learning/shogun/default.nix
+++ b/pkgs/applications/science/machine-learning/shogun/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchFromGitHub, ccache, cmake, ctags, swig
+{ stdenv, lib, fetchFromGitHub, fetchpatch, ccache, cmake, ctags, swig
 # data, compression
 , bzip2, curl, hdf5, json_c, lzma, lzo, protobuf, snappy
 # maths
@@ -27,6 +27,12 @@ stdenv.mkDerivation rec {
     fetchSubmodules = true;
   };
 
+  patches = fetchpatch {
+    name = "Fix-meta-example-parser-bug-in-parallel-builds.patch";
+    url = "https://github.com/shogun-toolbox/shogun/commit/ecd6a8f11ac52748e89d27c7fab7f43c1de39f05.patch";
+    sha256 = "1hrwwrj78sxhwcvgaz7n4kvh5y9snfcc4jf5xpgji5hjymnl311n";
+  };
+
   CCACHE_DIR=".ccache";
 
   buildInputs = with lib; [
diff --git a/pkgs/applications/version-management/guitone/default.nix b/pkgs/applications/version-management/guitone/default.nix
index bfaa62ebb66d..ded0d5e39863 100644
--- a/pkgs/applications/version-management/guitone/default.nix
+++ b/pkgs/applications/version-management/guitone/default.nix
@@ -16,6 +16,8 @@ stdenv.mkDerivation rec {
     branch = "net.venge.monotone.guitone";
   };
 
+  patches = [ ./parallel-building.patch ];
+
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ qt4 qmake4Hook graphviz ];
 
@@ -24,6 +26,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Qt4 based GUI for monotone";
     homepage = http://guitone.thomaskeller.biz;
+    downloadPage = https://code.monotone.ca/p/guitone/;
     inherit (qt4.meta) platforms;
   };
 }
diff --git a/pkgs/applications/version-management/guitone/parallel-building.patch b/pkgs/applications/version-management/guitone/parallel-building.patch
new file mode 100644
index 000000000000..f0e924cbfb81
--- /dev/null
+++ b/pkgs/applications/version-management/guitone/parallel-building.patch
@@ -0,0 +1,7 @@
+Without this `make tmp/AttributesView.o` fails with
+src/view/dialogs/AddEditAttribute.h:22:35: fatal error: ui_add_edit_attribute.h: No such file or directory
+--- a/guitone.pro
++++ b/guitone.pro
+@@ -215 +215,2 @@ help.commands = @echo Available targets: $${QMAKE_EXTRA_TARGETS}
+ QMAKE_EXTRA_TARGETS += help
++CONFIG += depend_includepath
diff --git a/pkgs/desktops/gnome-3/apps/gedit/src.nix b/pkgs/desktops/gnome-3/apps/gedit/src.nix
index 3fdc6cfaa685..7a68b75eb2a7 100644
--- a/pkgs/desktops/gnome-3/apps/gedit/src.nix
+++ b/pkgs/desktops/gnome-3/apps/gedit/src.nix
@@ -1,10 +1,10 @@
 # Autogenerated by maintainers/scripts/gnome.sh update
 
 fetchurl: {
-  name = "gedit-3.22.0";
+  name = "gedit-3.22.1";
 
   src = fetchurl {
-    url = mirror://gnome/sources/gedit/3.22/gedit-3.22.0.tar.xz;
-    sha256 = "063b5a0b5dcc8f540f6e8c3ea1c22cf8a3a19edffc25315a1b6bc51d462b3f45";
+    url = mirror://gnome/sources/gedit/3.22/gedit-3.22.1.tar.xz;
+    sha256 = "aa7bc3618fffa92fdb7daf2f57152e1eb7962e68561a9c92813d7bbb7fc9492b";
   };
 }
diff --git a/pkgs/desktops/gnome-3/apps/glade/default.nix b/pkgs/desktops/gnome-3/apps/glade/default.nix
index e48d15e6abfe..accd66933aad 100644
--- a/pkgs/desktops/gnome-3/apps/glade/default.nix
+++ b/pkgs/desktops/gnome-3/apps/glade/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, intltool, fetchurl, python, autoreconfHook
+{ stdenv, intltool, fetchurl, python
 , pkgconfig, gtk3, glib, gobjectIntrospection
 , wrapGAppsHook, itstool, libxml2, docbook_xsl
 , gnome3, gdk_pixbuf, libxslt }:
@@ -6,12 +6,8 @@
 stdenv.mkDerivation rec {
   inherit (import ./src.nix fetchurl) name src;
 
-  propagatedUserEnvPkgs = [ gnome3.gnome_themes_standard ];
-
   nativeBuildInputs = [
     pkgconfig intltool itstool wrapGAppsHook docbook_xsl libxslt gobjectIntrospection
-    # reconfiguration
-    autoreconfHook gnome3.gnome_common gnome3.yelp_tools
   ];
   buildInputs = [ gtk3 glib libxml2 python
                   gnome3.gsettings_desktop_schemas
@@ -19,20 +15,6 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  patches = [
-    # https://bugzilla.gnome.org/show_bug.cgi?id=782161
-    (fetchurl {
-      url = https://bugzilla.gnome.org/attachment.cgi?id=351054;
-      sha256 = "093wjjj40027pkqqnm14jb2dp2i2m8p1bayqx1lw18pq66c8fahn";
-    })
-  ];
-
-  preFixup = ''
-    wrapProgram "$out/bin/glade" \
-      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
-      --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
-  '';
-
   meta = with stdenv.lib; {
     homepage = https://wiki.gnome.org/Apps/Glade;
     description = "User interface designer for GTK+ applications";
diff --git a/pkgs/desktops/gnome-3/apps/glade/src.nix b/pkgs/desktops/gnome-3/apps/glade/src.nix
index d32dbd94d059..b244d2434c9e 100644
--- a/pkgs/desktops/gnome-3/apps/glade/src.nix
+++ b/pkgs/desktops/gnome-3/apps/glade/src.nix
@@ -1,10 +1,10 @@
 # Autogenerated by maintainers/scripts/gnome.sh update
 
 fetchurl: {
-  name = "glade-3.20.0";
+  name = "glade-3.20.2";
 
   src = fetchurl {
-    url = mirror://gnome/sources/glade/3.20/glade-3.20.0.tar.xz;
-    sha256 = "82d96dca5dec40ee34e2f41d49c13b4ea50da8f32a3a49ca2da802ff14dc18fe";
+    url = mirror://gnome/sources/glade/3.20/glade-3.20.2.tar.xz;
+    sha256 = "07d1545570951aeded20e9fdc6d3d8a56aeefe2538734568c5335be336c6abed";
   };
 }
diff --git a/pkgs/desktops/gnome-3/core/adwaita-icon-theme/src.nix b/pkgs/desktops/gnome-3/core/adwaita-icon-theme/src.nix
index 1a388505674c..24f0955659ec 100644
--- a/pkgs/desktops/gnome-3/core/adwaita-icon-theme/src.nix
+++ b/pkgs/desktops/gnome-3/core/adwaita-icon-theme/src.nix
@@ -1,10 +1,10 @@
 # Autogenerated by maintainers/scripts/gnome.sh update
 
 fetchurl: {
-  name = "adwaita-icon-theme-3.26.0";
+  name = "adwaita-icon-theme-3.26.1";
 
   src = fetchurl {
-    url = mirror://gnome/sources/adwaita-icon-theme/3.26/adwaita-icon-theme-3.26.0.tar.xz;
-    sha256 = "9cad85de19313f5885497aceab0acbb3f08c60fcd5fa5610aeafff37a1d12212";
+    url = mirror://gnome/sources/adwaita-icon-theme/3.26/adwaita-icon-theme-3.26.1.tar.xz;
+    sha256 = "28ba7392c7761996efd780779167ea6c940eedfb1bf37cfe9bccb7021f54d79d";
   };
 }
diff --git a/pkgs/desktops/gnome-3/core/dconf/default.nix b/pkgs/desktops/gnome-3/core/dconf/default.nix
index 130e8255edca..9a836869ec6e 100644
--- a/pkgs/desktops/gnome-3/core/dconf/default.nix
+++ b/pkgs/desktops/gnome-3/core/dconf/default.nix
@@ -6,11 +6,11 @@ let
 in
 stdenv.mkDerivation rec {
   name = "dconf-${version}";
-  version = "${majorVersion}.0";
+  version = "${majorVersion}.1";
 
   src = fetchurl {
     url = "mirror://gnome/sources/dconf/${majorVersion}/${name}.tar.xz";
-    sha256 = "1jaqsr1r0grpd25rbsc2v3vb0sc51lia9w31wlqswgqsncp2k0w6";
+    sha256 = "0da587hpiqy8h3pswn1102h4b905x8k6mk3ajpi7kf4kzkvv30ym";
   };
 
   outputs = [ "out" "lib" "dev" ];
diff --git a/pkgs/desktops/gnome-3/core/gsettings-desktop-schemas/src.nix b/pkgs/desktops/gnome-3/core/gsettings-desktop-schemas/src.nix
index 22760d2be113..1eca56c509bf 100644
--- a/pkgs/desktops/gnome-3/core/gsettings-desktop-schemas/src.nix
+++ b/pkgs/desktops/gnome-3/core/gsettings-desktop-schemas/src.nix
@@ -1,10 +1,10 @@
 # Autogenerated by maintainers/scripts/gnome.sh update
 
 fetchurl: {
-  name = "gsettings-desktop-schemas-3.24.0";
+  name = "gsettings-desktop-schemas-3.24.1";
 
   src = fetchurl {
-    url = mirror://gnome/sources/gsettings-desktop-schemas/3.24/gsettings-desktop-schemas-3.24.0.tar.xz;
-    sha256 = "f6573a3f661d22ff8a001cc2421d8647717f1c0e697e342d03c6102f29bbbb90";
+    url = mirror://gnome/sources/gsettings-desktop-schemas/3.24/gsettings-desktop-schemas-3.24.1.tar.xz;
+    sha256 = "76a3fa309f9de6074d66848987214f0b128124ba7184c958c15ac78a8ac7eea7";
   };
 }
diff --git a/pkgs/desktops/gnome-3/core/gtksourceview/src.nix b/pkgs/desktops/gnome-3/core/gtksourceview/src.nix
index 8648c595bb96..a8cdf8906d45 100644
--- a/pkgs/desktops/gnome-3/core/gtksourceview/src.nix
+++ b/pkgs/desktops/gnome-3/core/gtksourceview/src.nix
@@ -1,10 +1,10 @@
 # Autogenerated by maintainers/scripts/gnome.sh update
 
 fetchurl: {
-  name = "gtksourceview-3.24.3";
+  name = "gtksourceview-3.24.5";
 
   src = fetchurl {
-    url = mirror://gnome/sources/gtksourceview/3.24/gtksourceview-3.24.3.tar.xz;
-    sha256 = "3eed05486a6420c3e2fdda0bbb19a0d905ed09ebf442302a026ab7e574204cbd";
+    url = mirror://gnome/sources/gtksourceview/3.24/gtksourceview-3.24.5.tar.xz;
+    sha256 = "0246185fcc20c4734d01419a83f58f251a82e2a902fe60bb0335187fcf658181";
   };
 }
diff --git a/pkgs/desktops/gnome-3/core/gucharmap/src.nix b/pkgs/desktops/gnome-3/core/gucharmap/src.nix
index 67d00c269f53..fb38e3bf386b 100644
--- a/pkgs/desktops/gnome-3/core/gucharmap/src.nix
+++ b/pkgs/desktops/gnome-3/core/gucharmap/src.nix
@@ -1,10 +1,10 @@
 # Autogenerated by maintainers/scripts/gnome.sh update
 
 fetchurl: {
-  name = "gucharmap-10.0.1";
+  name = "gucharmap-10.0.3";
 
   src = fetchurl {
-    url = mirror://gnome/sources/gucharmap/10.0/gucharmap-10.0.1.tar.xz;
-    sha256 = "51a2bf91c4590ea2159f828156864f088a0bd4c12e7a1c396002a23d48b2d5e2";
+    url = mirror://gnome/sources/gucharmap/10.0/gucharmap-10.0.3.tar.xz;
+    sha256 = "ac07d75924e2d8f436d9492e8f7d54cf109404d34de06886a3967563cd1726a4";
   };
 }
diff --git a/pkgs/desktops/gnome-3/core/libgweather/src.nix b/pkgs/desktops/gnome-3/core/libgweather/src.nix
index f2cb4c310afc..799713c28a4a 100644
--- a/pkgs/desktops/gnome-3/core/libgweather/src.nix
+++ b/pkgs/desktops/gnome-3/core/libgweather/src.nix
@@ -1,10 +1,10 @@
 # Autogenerated by maintainers/scripts/gnome.sh update
 
 fetchurl: {
-  name = "libgweather-3.26.0";
+  name = "libgweather-3.26.1";
 
   src = fetchurl {
-    url = mirror://gnome/sources/libgweather/3.26/libgweather-3.26.0.tar.xz;
-    sha256 = "5b84badc0b3ecffff5db1bb9a7cc4dd4e400a8eb3f1282348f8ee6ba33626b6e";
+    url = mirror://gnome/sources/libgweather/3.26/libgweather-3.26.1.tar.xz;
+    sha256 = "fca78470b345bce948e0333cab0a7c52c32562fc4a75de37061248a64e8fc4b8";
   };
 }
diff --git a/pkgs/desktops/gnome-3/core/rest/default.nix b/pkgs/desktops/gnome-3/core/rest/default.nix
index 154e7221cc20..59f7a53e3e3e 100644
--- a/pkgs/desktops/gnome-3/core/rest/default.nix
+++ b/pkgs/desktops/gnome-3/core/rest/default.nix
@@ -3,11 +3,11 @@
 stdenv.mkDerivation rec {
   name = "rest-${version}";
   major = "0.8";
-  version = "${major}.0";
+  version = "${major}.1";
 
   src = fetchurl {
     url = "mirror://gnome/sources/rest/${major}/${name}.tar.xz";
-    sha256 = "e7b89b200c1417073aef739e8a27ff2ab578056c27796ec74f5886a5e0dff647";
+    sha256 = "0513aad38e5d3cedd4ae3c551634e3be1b9baaa79775e53b2dba9456f15b01c9";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/desktops/gnome-3/core/totem-pl-parser/src.nix b/pkgs/desktops/gnome-3/core/totem-pl-parser/src.nix
index 58e2ad07532e..2935111df27d 100644
--- a/pkgs/desktops/gnome-3/core/totem-pl-parser/src.nix
+++ b/pkgs/desktops/gnome-3/core/totem-pl-parser/src.nix
@@ -5,6 +5,6 @@ fetchurl: {
 
   src = fetchurl {
     url = mirror://gnome/sources/totem-pl-parser/3.26/totem-pl-parser-3.26.0.tar.xz;
-    sha256 = "1jzvq7s6qdsdpbc58jpcwvyj7qsq58r65kmnbknjzd79j4rsalzi";
+    sha256 = "f153a53391e9b42fed5cb6ce62322a58e323fde6ec4a54d8ba4d376cf4c1fbcb";
   };
 }
diff --git a/pkgs/desktops/gnome-3/core/totem/default.nix b/pkgs/desktops/gnome-3/core/totem/default.nix
index c74f9d5bdba2..651b7cff226d 100644
--- a/pkgs/desktops/gnome-3/core/totem/default.nix
+++ b/pkgs/desktops/gnome-3/core/totem/default.nix
@@ -10,6 +10,8 @@ stdenv.mkDerivation rec {
   doCheck = true;
 
   # https://bugs.launchpad.net/ubuntu/+source/totem/+bug/1712021
+  # https://bugzilla.gnome.org/show_bug.cgi?id=784236
+  # https://github.com/mesonbuild/meson/issues/1994
   enableParallelBuilding = false;
 
   NIX_CFLAGS_COMPILE = "-I${gnome3.glib.dev}/include/gio-unix-2.0";
diff --git a/pkgs/desktops/gnome-3/core/tracker-miners/src.nix b/pkgs/desktops/gnome-3/core/tracker-miners/src.nix
index 2b309161fd19..1c5ee9b35fa1 100644
--- a/pkgs/desktops/gnome-3/core/tracker-miners/src.nix
+++ b/pkgs/desktops/gnome-3/core/tracker-miners/src.nix
@@ -1,10 +1,10 @@
 # Autogenerated by maintainers/scripts/gnome.sh update
 
 fetchurl: {
-  name = "tracker-miners-2.0.2";
+  name = "tracker-miners-2.0.3";
 
   src = fetchurl {
-    url = mirror://gnome/sources/tracker-miners/2.0/tracker-miners-2.0.2.tar.xz;
-    sha256 = "cf417ece944c997f630dda41a7f5c449d609fa53dbb34fae7caa4c7af1e0e8ef";
+    url = mirror://gnome/sources/tracker-miners/2.0/tracker-miners-2.0.3.tar.xz;
+    sha256 = "12413a9f8dfa705a48a2697dcbb3eef12ee91bb98f392a23ba4bda7813e41d1b";
   };
 }
diff --git a/pkgs/desktops/gnome-3/core/tracker/default.nix b/pkgs/desktops/gnome-3/core/tracker/default.nix
index bf3438db338a..59455f320b53 100644
--- a/pkgs/desktops/gnome-3/core/tracker/default.nix
+++ b/pkgs/desktops/gnome-3/core/tracker/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, intltool, pkgconfig
+{ stdenv, fetchurl, intltool, pkgconfig
 , libxml2, upower, glib, wrapGAppsHook, vala, sqlite, libxslt
 , gnome3, icu, libuuid, networkmanager, libsoup, json_glib }:
 
diff --git a/pkgs/desktops/gnome-3/core/tracker/src.nix b/pkgs/desktops/gnome-3/core/tracker/src.nix
index afec65a4f633..887ae9a865a9 100644
--- a/pkgs/desktops/gnome-3/core/tracker/src.nix
+++ b/pkgs/desktops/gnome-3/core/tracker/src.nix
@@ -1,10 +1,10 @@
 # Autogenerated by maintainers/scripts/gnome.sh update
 
 fetchurl: {
-  name = "tracker-2.0.1";
+  name = "tracker-2.0.2";
 
   src = fetchurl {
-    url = mirror://gnome/sources/tracker/2.0/tracker-2.0.1.tar.xz;
-    sha256 = "ac5c9f4dbb0741af5877ae2818d8c053aa9a431477a924a17976bb7e44411e47";
+    url = mirror://gnome/sources/tracker/2.0/tracker-2.0.2.tar.xz;
+    sha256 = "ece71a56c29151a76fc1b6e43c15dd1b657b37162dc948fa2487faf5ddb47fda";
   };
 }
diff --git a/pkgs/desktops/gnome-3/games/aisleriot/src.nix b/pkgs/desktops/gnome-3/games/aisleriot/src.nix
index fbe6505b9a06..7fee97bae1df 100644
--- a/pkgs/desktops/gnome-3/games/aisleriot/src.nix
+++ b/pkgs/desktops/gnome-3/games/aisleriot/src.nix
@@ -1,10 +1,10 @@
 # Autogenerated by maintainers/scripts/gnome.sh update
 
 fetchurl: {
-  name = "aisleriot-3.22.0";
+  name = "aisleriot-3.22.4";
 
   src = fetchurl {
-    url = mirror://gnome/sources/aisleriot/3.22/aisleriot-3.22.0.tar.xz;
-    sha256 = "e7b603df0a482bdd0ab8083efc096a24a46aea1b36cc8608846e568b7a353eb7";
+    url = mirror://gnome/sources/aisleriot/3.22/aisleriot-3.22.4.tar.xz;
+    sha256 = "fe8dee3ad771ab778d37740a26410778aa5c61e8eb75dd42b9a5e5719c6e34fb";
   };
 }
diff --git a/pkgs/desktops/gnome-3/games/four-in-a-row/src.nix b/pkgs/desktops/gnome-3/games/four-in-a-row/src.nix
index e0e11bc2124c..9e2b23f3996b 100644
--- a/pkgs/desktops/gnome-3/games/four-in-a-row/src.nix
+++ b/pkgs/desktops/gnome-3/games/four-in-a-row/src.nix
@@ -1,10 +1,10 @@
 # Autogenerated by maintainers/scripts/gnome.sh update
 
 fetchurl: {
-  name = "four-in-a-row-3.22.0";
+  name = "four-in-a-row-3.22.2";
 
   src = fetchurl {
-    url = mirror://gnome/sources/four-in-a-row/3.22/four-in-a-row-3.22.0.tar.xz;
-    sha256 = "c2e26630f7b4e81cff087314edc0f39cd645dfbf4b31f826232bd8e9d57a7ff7";
+    url = mirror://gnome/sources/four-in-a-row/3.22/four-in-a-row-3.22.2.tar.xz;
+    sha256 = "bc4194e8ab6d1d2a6a63a2e91945cd5465f49ebf0dae2eecacc66e69db56a420";
   };
 }
diff --git a/pkgs/desktops/gnome-3/games/gnome-robots/src.nix b/pkgs/desktops/gnome-3/games/gnome-robots/src.nix
index 17fabe2de26b..09e4ad6c9673 100644
--- a/pkgs/desktops/gnome-3/games/gnome-robots/src.nix
+++ b/pkgs/desktops/gnome-3/games/gnome-robots/src.nix
@@ -1,10 +1,10 @@
 # Autogenerated by maintainers/scripts/gnome.sh update
 
 fetchurl: {
-  name = "gnome-robots-3.22.0";
+  name = "gnome-robots-3.22.2";
 
   src = fetchurl {
-    url = mirror://gnome/sources/gnome-robots/3.22/gnome-robots-3.22.0.tar.xz;
-    sha256 = "ddb02f9d04c970354d1836813f8c0d9ffc3ff509091d2580384e2275663e6f73";
+    url = mirror://gnome/sources/gnome-robots/3.22/gnome-robots-3.22.2.tar.xz;
+    sha256 = "c5d63f0fcae66d0df9b10e39387d09875555909f0aa7e57ef8552621d852082f";
   };
 }
diff --git a/pkgs/desktops/gnome-3/games/hitori/src.nix b/pkgs/desktops/gnome-3/games/hitori/src.nix
index 47989cf2eae5..93dcd5de62e3 100644
--- a/pkgs/desktops/gnome-3/games/hitori/src.nix
+++ b/pkgs/desktops/gnome-3/games/hitori/src.nix
@@ -1,10 +1,10 @@
 # Autogenerated by maintainers/scripts/gnome.sh update
 
 fetchurl: {
-  name = "hitori-3.22.0";
+  name = "hitori-3.22.4";
 
   src = fetchurl {
-    url = mirror://gnome/sources/hitori/3.22/hitori-3.22.0.tar.xz;
-    sha256 = "f70521c9a7a7c3e16b3951b64780eb0c5bce1bb1bb29de4482be06fb5e41adaa";
+    url = mirror://gnome/sources/hitori/3.22/hitori-3.22.4.tar.xz;
+    sha256 = "dcac6909b6007857ee425ac8c65fed179f2c71da138d5e5300cd62c8b9ea15d3";
   };
 }
diff --git a/pkgs/desktops/gnome-3/misc/gspell/default.nix b/pkgs/desktops/gnome-3/misc/gspell/default.nix
index 71e3ff19dc3f..e8c299685f70 100644
--- a/pkgs/desktops/gnome-3/misc/gspell/default.nix
+++ b/pkgs/desktops/gnome-3/misc/gspell/default.nix
@@ -5,8 +5,8 @@ stdenv.mkDerivation rec {
 
   propagatedBuildInputs = [ enchant ]; # required for pkgconfig
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ glib gtk3 isocodes vala ];
+  nativeBuildInputs = [ pkgconfig vala ];
+  buildInputs = [ glib gtk3 isocodes ];
 
   meta = with stdenv.lib; {
     platforms = platforms.linux;
diff --git a/pkgs/desktops/gnome-3/misc/gspell/src.nix b/pkgs/desktops/gnome-3/misc/gspell/src.nix
index fd55e654d551..9ae78f39e4e1 100644
--- a/pkgs/desktops/gnome-3/misc/gspell/src.nix
+++ b/pkgs/desktops/gnome-3/misc/gspell/src.nix
@@ -1,10 +1,10 @@
-fetchurl: rec {
-  major = "1.4";
-  minor = "1";
-  name = "gspell-${major}.${minor}";
+# Autogenerated by maintainers/scripts/gnome.sh update
+
+fetchurl: {
+  name = "gspell-1.6.1";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/gspell/${major}/${name}.tar.xz";
-    sha256 = "1ghh1xdzf04mfgb13zqpj88krpa44xv2vbyhm6k017kzrpz8hbs4";
+    url = mirror://gnome/sources/gspell/1.6/gspell-1.6.1.tar.xz;
+    sha256 = "f4d329348775374eec18158f8dcbbacf76f85be5ce002a92d93054ece70ec4de";
   };
 }
diff --git a/pkgs/desktops/gnome-3/misc/libgit2-glib/src.nix b/pkgs/desktops/gnome-3/misc/libgit2-glib/src.nix
index 00e747500c61..d233dc3a4015 100644
--- a/pkgs/desktops/gnome-3/misc/libgit2-glib/src.nix
+++ b/pkgs/desktops/gnome-3/misc/libgit2-glib/src.nix
@@ -1,10 +1,10 @@
 # Autogenerated by maintainers/scripts/gnome.sh update
 
 fetchurl: {
-  name = "libgit2-glib-0.26.0";
+  name = "libgit2-glib-0.26.2";
 
   src = fetchurl {
-    url = mirror://gnome/sources/libgit2-glib/0.26/libgit2-glib-0.26.0.tar.xz;
-    sha256 = "06b16cfcc3a53d9804858618d690e5509e9af2e2245b75f0479cadbbe39745c3";
+    url = mirror://gnome/sources/libgit2-glib/0.26/libgit2-glib-0.26.2.tar.xz;
+    sha256 = "2ad6f20db2e38bbfdb6cb452704fe8a911036b86de82dc75bb0f3b20db40ce9c";
   };
 }
diff --git a/pkgs/desktops/gnome-3/misc/libmediaart/default.nix b/pkgs/desktops/gnome-3/misc/libmediaart/default.nix
index abdcdef99379..2ea7a58ab665 100644
--- a/pkgs/desktops/gnome-3/misc/libmediaart/default.nix
+++ b/pkgs/desktops/gnome-3/misc/libmediaart/default.nix
@@ -4,15 +4,15 @@ let
   majorVersion = "1.9";
 in
 stdenv.mkDerivation rec {
-  name = "libmediaart-${majorVersion}.1";
+  name = "libmediaart-${majorVersion}.4";
 
   src = fetchurl {
     url = "mirror://gnome/sources/libmediaart/${majorVersion}/${name}.tar.xz";
-    sha256 = "0jg9gwxmhdxcbwb5svgkxkd3yl1d14wqzckcgg2swkn81i7al52v";
+    sha256 = "a57be017257e4815389afe4f58fdacb6a50e74fd185452b23a652ee56b04813d";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ glib gdk_pixbuf gobjectIntrospection ];
+  nativeBuildInputs = [ pkgconfig gobjectIntrospection ];
+  buildInputs = [ glib gdk_pixbuf ];
 
   meta = with stdenv.lib; {
     description = "Library tasked with managing, extracting and handling media art caches";
diff --git a/pkgs/development/compilers/gcc/4.5/default.nix b/pkgs/development/compilers/gcc/4.5/default.nix
index 12739682292b..b41d22f4f539 100644
--- a/pkgs/development/compilers/gcc/4.5/default.nix
+++ b/pkgs/development/compilers/gcc/4.5/default.nix
@@ -25,6 +25,7 @@
 , libpthread ? null, libpthreadCross ? null  # required for GNU/Hurd
 , stripped ? true
 , buildPlatform, hostPlatform, targetPlatform
+, buildPackages
 }:
 
 assert langJava     -> zip != null && unzip != null
@@ -258,6 +259,8 @@ stdenv.mkDerivation ({
       "--with-mpc=${libmpc}"
     ] ++
     optional (libelf != null) "--with-libelf=${libelf}" ++
+    optional (!(crossMingw && crossStageStatic))
+      "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++
 
     # Basic configuration
     [
@@ -349,29 +352,32 @@ stdenv.mkDerivation ({
     STRIP_FOR_TARGET = "${targetPlatform.config}-strip";
     CC_FOR_TARGET = "${targetPlatform.config}-gcc";
     CXX_FOR_TARGET = "${targetPlatform.config}-g++";
-    # If we are making a cross compiler, cross != null
-    NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
+
     dontStrip = true;
   };
 
+  NIX_BUILD_CC = buildPackages.stdenv.cc;
 
   # Needed for the cross compilation to work
   AR = "ar";
   LD = "ld";
   CC = "gcc";
 
-  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find
-  # the library headers and binaries, regarless of the language being
-  # compiled.
-
-  # Note: When building the Java AWT GTK+ peer, the build system doesn't
-  # honor `--with-gmp' et al., e.g., when building
-  # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just
-  # add them to $CPATH and $LIBRARY_PATH in this case.
+  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the
+  # library headers and binaries, regarless of the language being compiled.
+  #
+  # Note: When building the Java AWT GTK+ peer, the build system doesn't honor
+  # `--with-gmp' et al., e.g., when building
+  # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add
+  # them to $CPATH and $LIBRARY_PATH in this case.
   #
   # Likewise, the LTO code doesn't find zlib.
+  #
+  # 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.
 
-  CPATH = makeSearchPathOutput "dev" "include" ([]
+  CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([]
     ++ optional (zlib != null) zlib
     ++ optional langJava boehmgc
     ++ optionals javaAwtGtk xlibs
@@ -382,39 +388,38 @@ stdenv.mkDerivation ({
     # On GNU/Hurd glibc refers to Mach & Hurd
     # headers.
     ++ optionals (libcCross != null && libcCross ? propagatedBuildInputs)
-                 libcCross.propagatedBuildInputs);
+                 libcCross.propagatedBuildInputs
+  ));
 
-  LIBRARY_PATH = makeLibraryPath ([]
+  LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([]
     ++ optional (zlib != null) zlib
     ++ optional langJava boehmgc
     ++ optionals javaAwtGtk xlibs
     ++ optionals javaAwtGtk [ gmp mpfr ]
-    ++ optional (libpthread != null) libpthread);
-
-  EXTRA_TARGET_CFLAGS =
-    if targetPlatform != hostPlatform && libcCross != null then [
-        "-idirafter ${libcCross.dev}/include"
-      ]
-      ++ optionals (! crossStageStatic) [
-        "-B${libcCross.out}/lib"
-      ]
-    else null;
-
-  EXTRA_TARGET_LDFLAGS =
-    if targetPlatform != hostPlatform && libcCross != null then [
-        "-Wl,-L${libcCross.out}/lib"
-      ]
-      ++ (if crossStageStatic then [
+    ++ optional (libpthread != null) libpthread)
+  );
+
+  EXTRA_TARGET_FLAGS = optionals
+    (targetPlatform != hostPlatform && libcCross != null)
+    ([
+      "-idirafter ${libcCross.dev}/include"
+    ] ++ optionals (! crossStageStatic) [
+      "-B${libcCross.out}/lib"
+    ]);
+
+  EXTRA_TARGET_LDFLAGS = optionals
+    (targetPlatform != hostPlatform && libcCross != null)
+    ([
+      "-Wl,-L${libcCross.out}/lib"
+    ] ++ (if crossStageStatic then [
         "-B${libcCross.out}/lib"
       ] else [
         "-Wl,-rpath,${libcCross.out}/lib"
         "-Wl,-rpath-link,${libcCross.out}/lib"
-      ])
-      ++ optionals (libpthreadCross != null) [
-        "-L${libpthreadCross}/lib"
-        "-Wl,${libpthreadCross.TARGET_LDFLAGS}"
-      ]
-    else null;
+    ]) ++ optionals (libpthreadCross != null) [
+      "-L${libpthreadCross}/lib"
+      "-Wl,${libpthreadCross.TARGET_LDFLAGS}"
+    ]);
 
   passthru = { inherit langC langCC langAda langFortran langVhdl
       enableMultilib version; isGNU = true; };
diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix
index 51fb1a1c9a1e..8713c174d5a6 100644
--- a/pkgs/development/compilers/gcc/4.8/default.nix
+++ b/pkgs/development/compilers/gcc/4.8/default.nix
@@ -33,6 +33,7 @@
 , gnused ? null
 , darwin ? null
 , buildPlatform, hostPlatform, targetPlatform
+, buildPackages
 }:
 
 assert langJava     -> zip != null && unzip != null
@@ -316,6 +317,8 @@ stdenv.mkDerivation ({
       "--with-mpc=${libmpc}"
     ] ++
     optional (libelf != null) "--with-libelf=${libelf}" ++
+    optional (!(crossMingw && crossStageStatic))
+      "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++
 
     # Basic configuration
     [
@@ -372,14 +375,6 @@ stdenv.mkDerivation ({
     # Ada
     optional langAda "--enable-libada" ++
 
-    # Cross-compilation
-    optional (targetPlatform == hostPlatform) (
-      let incDir = if hostPlatform.isDarwin
-                     then "${darwin.usr-include}"
-                     else "${getDev stdenv.cc.libc}/include";
-      in "--with-native-system-header-dir=${incDir}"
-    ) ++
-
     platformFlags ++
     optional (targetPlatform != hostPlatform) crossConfigureFlags ++
     optional (!bootstrap) "--disable-bootstrap" ++
@@ -444,12 +439,12 @@ stdenv.mkDerivation ({
     STRIP_FOR_TARGET = "${targetPlatform.config}-strip";
     CC_FOR_TARGET = "${targetPlatform.config}-gcc";
     CXX_FOR_TARGET = "${targetPlatform.config}-g++";
-    # If we are making a cross compiler, targetPlatform != hostPlatform
-    NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
+
     dontStrip = true;
     buildFlags = "";
   };
 
+  NIX_BUILD_CC = buildPackages.stdenv.cc;
 
   # Needed for the cross compilation to work
   AR = "ar";
@@ -457,18 +452,21 @@ stdenv.mkDerivation ({
   # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
   CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc";
 
-  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find
-  # the library headers and binaries, regarless of the language being
-  # compiled.
-
-  # Note: When building the Java AWT GTK+ peer, the build system doesn't
-  # honor `--with-gmp' et al., e.g., when building
-  # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just
-  # add them to $CPATH and $LIBRARY_PATH in this case.
+  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the
+  # library headers and binaries, regarless of the language being compiled.
+  #
+  # Note: When building the Java AWT GTK+ peer, the build system doesn't honor
+  # `--with-gmp' et al., e.g., when building
+  # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add
+  # them to $CPATH and $LIBRARY_PATH in this case.
   #
   # Likewise, the LTO code doesn't find zlib.
+  #
+  # 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.
 
-  CPATH = makeSearchPathOutput "dev" "include" ([]
+  CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([]
     ++ optional (zlib != null) zlib
     ++ optional langJava boehmgc
     ++ optionals javaAwtGtk xlibs
@@ -479,39 +477,38 @@ stdenv.mkDerivation ({
     # On GNU/Hurd glibc refers to Mach & Hurd
     # headers.
     ++ optionals (libcCross != null && libcCross ? propagatedBuildInputs)
-                 libcCross.propagatedBuildInputs);
+                 libcCross.propagatedBuildInputs
+  ));
 
-  LIBRARY_PATH = makeLibraryPath ([]
+  LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([]
     ++ optional (zlib != null) zlib
     ++ optional langJava boehmgc
     ++ optionals javaAwtGtk xlibs
     ++ optionals javaAwtGtk [ gmp mpfr ]
-    ++ optional (libpthread != null) libpthread);
-
-  EXTRA_TARGET_CFLAGS =
-    if targetPlatform != hostPlatform && libcCross != null then [
-        "-idirafter ${getDev libcCross}/include"
-      ]
-      ++ optionals (! crossStageStatic) [
-        "-B${libcCross.out}/lib"
-      ]
-    else null;
-
-  EXTRA_TARGET_LDFLAGS =
-    if targetPlatform != hostPlatform && libcCross != null then [
-        "-Wl,-L${libcCross.out}/lib"
-      ]
-      ++ (if crossStageStatic then [
+    ++ optional (libpthread != null) libpthread)
+  );
+
+  EXTRA_TARGET_FLAGS = optionals
+    (targetPlatform != hostPlatform && libcCross != null)
+    ([
+      "-idirafter ${libcCross.dev}/include"
+    ] ++ optionals (! crossStageStatic) [
+      "-B${libcCross.out}/lib"
+    ]);
+
+  EXTRA_TARGET_LDFLAGS = optionals
+    (targetPlatform != hostPlatform && libcCross != null)
+    ([
+      "-Wl,-L${libcCross.out}/lib"
+    ] ++ (if crossStageStatic then [
         "-B${libcCross.out}/lib"
       ] else [
         "-Wl,-rpath,${libcCross.out}/lib"
         "-Wl,-rpath-link,${libcCross.out}/lib"
-      ])
-      ++ optionals (libpthreadCross != null) [
-        "-L${libpthreadCross}/lib"
-        "-Wl,${libpthreadCross.TARGET_LDFLAGS}"
-      ]
-    else null;
+    ]) ++ optionals (libpthreadCross != null) [
+      "-L${libpthreadCross}/lib"
+      "-Wl,${libpthreadCross.TARGET_LDFLAGS}"
+    ]);
 
   passthru =
     { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; };
diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix
index 57d173c3a144..c338f9c641ee 100644
--- a/pkgs/development/compilers/gcc/4.9/default.nix
+++ b/pkgs/development/compilers/gcc/4.9/default.nix
@@ -33,6 +33,7 @@
 , gnused ? null
 , darwin ? null
 , buildPlatform, hostPlatform, targetPlatform
+, buildPackages
 }:
 
 assert langJava     -> zip != null && unzip != null
@@ -314,6 +315,8 @@ stdenv.mkDerivation ({
       "--with-mpc=${libmpc}"
     ] ++
     optional (libelf != null) "--with-libelf=${libelf}" ++
+    optional (!(crossMingw && crossStageStatic))
+      "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++
 
     # Basic configuration
     [
@@ -370,14 +373,6 @@ stdenv.mkDerivation ({
     # Ada
     optional langAda "--enable-libada" ++
 
-    # Cross-compilation
-    optional (targetPlatform == hostPlatform) (
-      let incDir = if hostPlatform.isDarwin
-                     then "${darwin.usr-include}"
-                     else "${getDev stdenv.cc.libc}/include";
-      in "--with-native-system-header-dir=${incDir}"
-    ) ++
-
     platformFlags ++
     optional (targetPlatform != hostPlatform) crossConfigureFlags ++
     optional (!bootstrap) "--disable-bootstrap" ++
@@ -442,12 +437,12 @@ stdenv.mkDerivation ({
     STRIP_FOR_TARGET = "${targetPlatform.config}-strip";
     CC_FOR_TARGET = "${targetPlatform.config}-gcc";
     CXX_FOR_TARGET = "${targetPlatform.config}-g++";
-    # If we are making a cross compiler, targetPlatform != hostPlatform
-    NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
+
     dontStrip = true;
     buildFlags = "";
   };
 
+  NIX_BUILD_CC = buildPackages.stdenv.cc;
 
   # Needed for the cross compilation to work
   AR = "ar";
@@ -455,18 +450,21 @@ stdenv.mkDerivation ({
   # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
   CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc";
 
-  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find
-  # the library headers and binaries, regarless of the language being
-  # compiled.
-
-  # Note: When building the Java AWT GTK+ peer, the build system doesn't
-  # honor `--with-gmp' et al., e.g., when building
-  # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just
-  # add them to $CPATH and $LIBRARY_PATH in this case.
+  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the
+  # library headers and binaries, regarless of the language being compiled.
+  #
+  # Note: When building the Java AWT GTK+ peer, the build system doesn't honor
+  # `--with-gmp' et al., e.g., when building
+  # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add
+  # them to $CPATH and $LIBRARY_PATH in this case.
   #
   # Likewise, the LTO code doesn't find zlib.
+  #
+  # 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.
 
-  CPATH = makeSearchPathOutput "dev" "include" ([]
+  CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([]
     ++ optional (zlib != null) zlib
     ++ optional langJava boehmgc
     ++ optionals javaAwtGtk xlibs
@@ -477,39 +475,38 @@ stdenv.mkDerivation ({
     # On GNU/Hurd glibc refers to Mach & Hurd
     # headers.
     ++ optionals (libcCross != null && libcCross ? propagatedBuildInputs)
-                 libcCross.propagatedBuildInputs);
+                 libcCross.propagatedBuildInputs
+  ));
 
-  LIBRARY_PATH = makeLibraryPath ([]
+  LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([]
     ++ optional (zlib != null) zlib
     ++ optional langJava boehmgc
     ++ optionals javaAwtGtk xlibs
     ++ optionals javaAwtGtk [ gmp mpfr ]
-    ++ optional (libpthread != null) libpthread);
-
-  EXTRA_TARGET_CFLAGS =
-    if targetPlatform != hostPlatform && libcCross != null then [
-        "-idirafter ${getDev libcCross}/include"
-      ]
-      ++ optionals (! crossStageStatic) [
-        "-B${libcCross.out}/lib"
-      ]
-    else null;
-
-  EXTRA_TARGET_LDFLAGS =
-    if targetPlatform != hostPlatform && libcCross != null then [
-        "-Wl,-L${libcCross.out}/lib"
-      ]
-      ++ (if crossStageStatic then [
+    ++ optional (libpthread != null) libpthread)
+  );
+
+  EXTRA_TARGET_FLAGS = optionals
+    (targetPlatform != hostPlatform && libcCross != null)
+    ([
+      "-idirafter ${getDev libcCross}/include"
+    ] ++ optionals (! crossStageStatic) [
+      "-B${libcCross.out}/lib"
+    ]);
+
+  EXTRA_TARGET_LDFLAGS = optionals
+    (targetPlatform != hostPlatform && libcCross != null)
+    ([
+      "-Wl,-L${libcCross.out}/lib"
+    ] ++ (if crossStageStatic then [
         "-B${libcCross.out}/lib"
       ] else [
         "-Wl,-rpath,${libcCross.out}/lib"
         "-Wl,-rpath-link,${libcCross.out}/lib"
-      ])
-      ++ optionals (libpthreadCross != null) [
-        "-L${libpthreadCross}/lib"
-        "-Wl,${libpthreadCross.TARGET_LDFLAGS}"
-      ]
-    else null;
+    ]) ++ optionals (libpthreadCross != null) [
+      "-L${libpthreadCross}/lib"
+      "-Wl,${libpthreadCross.TARGET_LDFLAGS}"
+    ]);
 
   passthru =
     { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; };
diff --git a/pkgs/development/compilers/gcc/5/default.nix b/pkgs/development/compilers/gcc/5/default.nix
index a34d14e88021..552e827ec366 100644
--- a/pkgs/development/compilers/gcc/5/default.nix
+++ b/pkgs/development/compilers/gcc/5/default.nix
@@ -329,6 +329,8 @@ stdenv.mkDerivation ({
       "--with-mpc=${libmpc}"
     ] ++
     optional (libelf != null) "--with-libelf=${libelf}" ++
+    optional (!(crossMingw && crossStageStatic))
+      "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++ 
 
     # Basic configuration
     [
@@ -380,14 +382,6 @@ stdenv.mkDerivation ({
     # Ada
     optional langAda "--enable-libada" ++
 
-    # Cross-compilation
-    optional (targetPlatform == hostPlatform) (
-      let incDir = if hostPlatform.isDarwin
-                     then "${darwin.usr-include}"
-                     else "${getDev stdenv.cc.libc}/include";
-      in "--with-native-system-header-dir=${incDir}"
-    ) ++
-
     platformFlags ++
     optional (targetPlatform != hostPlatform) crossConfigureFlags ++
     optional (!bootstrap) "--disable-bootstrap" ++
@@ -452,12 +446,12 @@ stdenv.mkDerivation ({
     STRIP_FOR_TARGET = "${targetPlatform.config}-strip";
     CC_FOR_TARGET = "${targetPlatform.config}-gcc";
     CXX_FOR_TARGET = "${targetPlatform.config}-g++";
-    # If we are making a cross compiler, targetPlatform != hostPlatform
-    NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
+
     dontStrip = true;
     buildFlags = "";
   };
 
+  NIX_BUILD_CC = buildPackages.stdenv.cc;
 
   # Needed for the cross compilation to work
   AR = "ar";
@@ -465,18 +459,21 @@ stdenv.mkDerivation ({
   # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
   CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc";
 
-  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find
-  # the library headers and binaries, regarless of the language being
-  # compiled.
-
-  # Note: When building the Java AWT GTK+ peer, the build system doesn't
-  # honor `--with-gmp' et al., e.g., when building
-  # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just
-  # add them to $CPATH and $LIBRARY_PATH in this case.
+  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the
+  # library headers and binaries, regarless of the language being compiled.
+  #
+  # Note: When building the Java AWT GTK+ peer, the build system doesn't honor
+  # `--with-gmp' et al., e.g., when building
+  # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add
+  # them to $CPATH and $LIBRARY_PATH in this case.
   #
   # Likewise, the LTO code doesn't find zlib.
+  #
+  # 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.
 
-  CPATH = makeSearchPathOutput "dev" "include" ([]
+  CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([]
     ++ optional (zlib != null) zlib
     ++ optional langJava boehmgc
     ++ optionals javaAwtGtk xlibs
@@ -487,39 +484,38 @@ stdenv.mkDerivation ({
     # On GNU/Hurd glibc refers to Mach & Hurd
     # headers.
     ++ optionals (libcCross != null && libcCross ? propagatedBuildInputs)
-                 libcCross.propagatedBuildInputs);
+                 libcCross.propagatedBuildInputs
+  ));
 
-  LIBRARY_PATH = makeLibraryPath ([]
+  LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([]
     ++ optional (zlib != null) zlib
     ++ optional langJava boehmgc
     ++ optionals javaAwtGtk xlibs
     ++ optionals javaAwtGtk [ gmp mpfr ]
-    ++ optional (libpthread != null) libpthread);
-
-  EXTRA_TARGET_CFLAGS =
-    if targetPlatform != hostPlatform && libcCross != null then [
-        "-idirafter ${getDev libcCross}/include"
-      ]
-      ++ optionals (! crossStageStatic) [
-        "-B${libcCross.out}/lib"
-      ]
-    else null;
-
-  EXTRA_TARGET_LDFLAGS =
-    if targetPlatform != hostPlatform && libcCross != null then [
-        "-Wl,-L${libcCross.out}/lib"
-      ]
-      ++ (if crossStageStatic then [
+    ++ optional (libpthread != null) libpthread)
+  );
+
+  EXTRA_TARGET_FLAGS = optionals
+    (targetPlatform != hostPlatform && libcCross != null)
+    ([
+      "-idirafter ${getDev libcCross}/include"
+    ] ++ optionals (! crossStageStatic) [
+      "-B${libcCross.out}/lib"
+    ]);
+
+  EXTRA_TARGET_LDFLAGS = optionals
+    (targetPlatform != hostPlatform && libcCross != null)
+    ([
+      "-Wl,-L${libcCross.out}/lib"
+    ] ++ (if crossStageStatic then [
         "-B${libcCross.out}/lib"
       ] else [
         "-Wl,-rpath,${libcCross.out}/lib"
         "-Wl,-rpath-link,${libcCross.out}/lib"
-      ])
-      ++ optionals (libpthreadCross != null) [
-        "-L${libpthreadCross}/lib"
-        "-Wl,${libpthreadCross.TARGET_LDFLAGS}"
-      ]
-    else null;
+    ]) ++ optionals (libpthreadCross != null) [
+      "-L${libpthreadCross}/lib"
+      "-Wl,${libpthreadCross.TARGET_LDFLAGS}"
+    ]);
 
   passthru =
     { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; };
diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix
index 61e7647f968f..fbc490026067 100644
--- a/pkgs/development/compilers/gcc/6/default.nix
+++ b/pkgs/development/compilers/gcc/6/default.nix
@@ -34,6 +34,7 @@
 , cloog # unused; just for compat with gcc4, as we override the parameter on some places
 , darwin ? null
 , buildPlatform, hostPlatform, targetPlatform
+, buildPackages
 }:
 
 assert langJava     -> zip != null && unzip != null
@@ -330,6 +331,8 @@ stdenv.mkDerivation ({
       "--with-mpc=${libmpc}"
     ] ++
     optional (libelf != null) "--with-libelf=${libelf}" ++
+    optional (!(crossMingw && crossStageStatic))
+      "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++
 
     # Basic configuration
     [
@@ -381,14 +384,6 @@ stdenv.mkDerivation ({
     # Ada
     optional langAda "--enable-libada" ++
 
-    # Cross-compilation
-    optional (targetPlatform == hostPlatform) (
-      let incDir = if hostPlatform.isDarwin
-                     then "${darwin.usr-include}"
-                     else "${getDev stdenv.cc.libc}/include";
-      in "--with-native-system-header-dir=${incDir}"
-    ) ++
-
     platformFlags ++
     optional (targetPlatform != hostPlatform) crossConfigureFlags ++
     optional (!bootstrap) "--disable-bootstrap" ++
@@ -452,12 +447,12 @@ stdenv.mkDerivation ({
     STRIP_FOR_TARGET = "${targetPlatform.config}-strip";
     CC_FOR_TARGET = "${targetPlatform.config}-gcc";
     CXX_FOR_TARGET = "${targetPlatform.config}-g++";
-    # If we are making a cross compiler, targetPlatform != hostPlatform
-    NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
+
     dontStrip = true;
     buildFlags = "";
   };
 
+  NIX_BUILD_CC = buildPackages.stdenv.cc;
 
   # Needed for the cross compilation to work
   AR = "ar";
@@ -465,18 +460,21 @@ stdenv.mkDerivation ({
   # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
   CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc";
 
-  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find
-  # the library headers and binaries, regarless of the language being
-  # compiled.
-
-  # Note: When building the Java AWT GTK+ peer, the build system doesn't
-  # honor `--with-gmp' et al., e.g., when building
-  # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just
-  # add them to $CPATH and $LIBRARY_PATH in this case.
+  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the
+  # library headers and binaries, regarless of the language being compiled.
+  #
+  # Note: When building the Java AWT GTK+ peer, the build system doesn't honor
+  # `--with-gmp' et al., e.g., when building
+  # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add
+  # them to $CPATH and $LIBRARY_PATH in this case.
   #
   # Likewise, the LTO code doesn't find zlib.
+  #
+  # 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.
 
-  CPATH = makeSearchPathOutput "dev" "include" ([]
+  CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([]
     ++ optional (zlib != null) zlib
     ++ optional langJava boehmgc
     ++ optionals javaAwtGtk xlibs
@@ -487,39 +485,38 @@ stdenv.mkDerivation ({
     # On GNU/Hurd glibc refers to Mach & Hurd
     # headers.
     ++ optionals (libcCross != null && libcCross ? propagatedBuildInputs)
-                 libcCross.propagatedBuildInputs);
+                 libcCross.propagatedBuildInputs
+  ));
 
-  LIBRARY_PATH = makeLibraryPath ([]
+  LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([]
     ++ optional (zlib != null) zlib
     ++ optional langJava boehmgc
     ++ optionals javaAwtGtk xlibs
     ++ optionals javaAwtGtk [ gmp mpfr ]
-    ++ optional (libpthread != null) libpthread);
-
-  EXTRA_TARGET_CFLAGS =
-    if targetPlatform != hostPlatform && libcCross != null then [
-        "-idirafter ${getDev libcCross}/include"
-      ]
-      ++ optionals (! crossStageStatic) [
-        "-B${libcCross.out}/lib"
-      ]
-    else null;
-
-  EXTRA_TARGET_LDFLAGS =
-    if targetPlatform != hostPlatform && libcCross != null then [
-        "-Wl,-L${libcCross.out}/lib"
-      ]
-      ++ (if crossStageStatic then [
+    ++ optional (libpthread != null) libpthread)
+  );
+
+  EXTRA_TARGET_FLAGS = optionals
+    (targetPlatform != hostPlatform && libcCross != null)
+    ([
+      "-idirafter ${getDev libcCross}/include"
+    ] ++ optionals (! crossStageStatic) [
+      "-B${libcCross.out}/lib"
+    ]);
+
+  EXTRA_TARGET_LDFLAGS = optionals
+    (targetPlatform != hostPlatform && libcCross != null)
+    ([
+      "-Wl,-L${libcCross.out}/lib"
+    ] ++ (if crossStageStatic then [
         "-B${libcCross.out}/lib"
       ] else [
         "-Wl,-rpath,${libcCross.out}/lib"
         "-Wl,-rpath-link,${libcCross.out}/lib"
-      ])
-      ++ optionals (libpthreadCross != null) [
-        "-L${libpthreadCross}/lib"
-        "-Wl,${libpthreadCross.TARGET_LDFLAGS}"
-      ]
-    else null;
+    ]) ++ optionals (libpthreadCross != null) [
+      "-L${libpthreadCross}/lib"
+      "-Wl,${libpthreadCross.TARGET_LDFLAGS}"
+    ]);
 
   passthru =
     { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; };
diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix
index 48b245c1006f..032a20271ee0 100644
--- a/pkgs/development/compilers/gcc/7/default.nix
+++ b/pkgs/development/compilers/gcc/7/default.nix
@@ -35,6 +35,7 @@
 , darwin ? null
 , flex ? null
 , buildPlatform, hostPlatform, targetPlatform
+, buildPackages
 }:
 
 assert langJava     -> zip != null && unzip != null
@@ -323,6 +324,8 @@ stdenv.mkDerivation ({
       "--with-mpc=${libmpc}"
     ] ++
     optional (libelf != null) "--with-libelf=${libelf}" ++
+    optional (!(crossMingw && crossStageStatic))
+      "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++
 
     # Basic configuration
     [
@@ -374,14 +377,6 @@ stdenv.mkDerivation ({
     # Ada
     optional langAda "--enable-libada" ++
 
-    # Cross-compilation
-    optional (targetPlatform == hostPlatform) (
-      let incDir = if hostPlatform.isDarwin
-                     then "${darwin.usr-include}"
-                     else "${getDev stdenv.cc.libc}/include";
-      in "--with-native-system-header-dir=${incDir}"
-    ) ++
-
     platformFlags ++
     optional (targetPlatform != hostPlatform) crossConfigureFlags ++
     optional (!bootstrap) "--disable-bootstrap" ++
@@ -446,12 +441,12 @@ stdenv.mkDerivation ({
     STRIP_FOR_TARGET = "${targetPlatform.config}-strip";
     CC_FOR_TARGET = "${targetPlatform.config}-gcc";
     CXX_FOR_TARGET = "${targetPlatform.config}-g++";
-    # If we are making a cross compiler, targetPlatform != hostPlatform
-    NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
+
     dontStrip = true;
     buildFlags = "";
   };
 
+  NIX_BUILD_CC = buildPackages.stdenv.cc;
 
   # Needed for the cross compilation to work
   AR = "ar";
@@ -459,18 +454,21 @@ stdenv.mkDerivation ({
   # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
   CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc";
 
-  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find
-  # the library headers and binaries, regarless of the language being
-  # compiled.
-
-  # Note: When building the Java AWT GTK+ peer, the build system doesn't
-  # honor `--with-gmp' et al., e.g., when building
-  # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just
-  # add them to $CPATH and $LIBRARY_PATH in this case.
+  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the
+  # library headers and binaries, regarless of the language being compiled.
+  #
+  # Note: When building the Java AWT GTK+ peer, the build system doesn't honor
+  # `--with-gmp' et al., e.g., when building
+  # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add
+  # them to $CPATH and $LIBRARY_PATH in this case.
   #
   # Likewise, the LTO code doesn't find zlib.
+  #
+  # 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.
 
-  CPATH = makeSearchPathOutput "dev" "include" ([]
+  CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([]
     ++ optional (zlib != null) zlib
     ++ optional langJava boehmgc
     ++ optionals javaAwtGtk xlibs
@@ -481,39 +479,38 @@ stdenv.mkDerivation ({
     # On GNU/Hurd glibc refers to Mach & Hurd
     # headers.
     ++ optionals (libcCross != null && libcCross ? propagatedBuildInputs)
-                 libcCross.propagatedBuildInputs);
+                 libcCross.propagatedBuildInputs
+  ));
 
-  LIBRARY_PATH = makeLibraryPath ([]
+  LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([]
     ++ optional (zlib != null) zlib
     ++ optional langJava boehmgc
     ++ optionals javaAwtGtk xlibs
     ++ optionals javaAwtGtk [ gmp mpfr ]
-    ++ optional (libpthread != null) libpthread);
-
-  EXTRA_TARGET_CFLAGS =
-    if targetPlatform != hostPlatform && libcCross != null then [
-        "-idirafter ${getDev libcCross}/include"
-      ]
-      ++ optionals (! crossStageStatic) [
-        "-B${libcCross.out}/lib"
-      ]
-    else null;
-
-  EXTRA_TARGET_LDFLAGS =
-    if targetPlatform != hostPlatform && libcCross != null then [
-        "-Wl,-L${libcCross.out}/lib"
-      ]
-      ++ (if crossStageStatic then [
+    ++ optional (libpthread != null) libpthread)
+  );
+
+  EXTRA_TARGET_FLAGS = optionals
+    (targetPlatform != hostPlatform && libcCross != null)
+    ([
+      "-idirafter ${getDev libcCross}/include"
+    ] ++ optionals (! crossStageStatic) [
+      "-B${libcCross.out}/lib"
+    ]);
+
+  EXTRA_TARGET_LDFLAGS = optionals
+    (targetPlatform != hostPlatform && libcCross != null)
+    ([
+      "-Wl,-L${libcCross.out}/lib"
+    ] ++ (if crossStageStatic then [
         "-B${libcCross.out}/lib"
       ] else [
         "-Wl,-rpath,${libcCross.out}/lib"
         "-Wl,-rpath-link,${libcCross.out}/lib"
-      ])
-      ++ optionals (libpthreadCross != null) [
-        "-L${libpthreadCross}/lib"
-        "-Wl,${libpthreadCross.TARGET_LDFLAGS}"
-      ]
-    else null;
+    ]) ++ optionals (libpthreadCross != null) [
+      "-L${libpthreadCross}/lib"
+      "-Wl,${libpthreadCross.TARGET_LDFLAGS}"
+    ]);
 
   passthru =
     { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; };
diff --git a/pkgs/development/compilers/gcc/builder.sh b/pkgs/development/compilers/gcc/builder.sh
index ee56425f00b4..d21755d7b1dc 100644
--- a/pkgs/development/compilers/gcc/builder.sh
+++ b/pkgs/development/compilers/gcc/builder.sh
@@ -1,8 +1,12 @@
 source $stdenv/setup
 
 
-export NIX_FIXINC_DUMMY=$NIX_BUILD_TOP/dummy
-mkdir $NIX_FIXINC_DUMMY
+oldOpts="$(shopt -po nounset)" || true
+set -euo pipefail
+
+
+export NIX_FIXINC_DUMMY="$NIX_BUILD_TOP/dummy"
+mkdir "$NIX_FIXINC_DUMMY"
 
 
 if test "$staticCompiler" = "1"; then
@@ -13,141 +17,125 @@ fi
 
 
 # GCC interprets empty paths as ".", which we don't want.
-if test -z "$CPATH"; then unset CPATH; fi
-if test -z "$LIBRARY_PATH"; then unset LIBRARY_PATH; fi
-echo "\$CPATH is \`$CPATH'"
-echo "\$LIBRARY_PATH is \`$LIBRARY_PATH'"
+if test -z "${CPATH-}"; then unset CPATH; fi
+if test -z "${LIBRARY_PATH-}"; then unset LIBRARY_PATH; fi
+echo "\$CPATH is \`${CPATH-}'"
+echo "\$LIBRARY_PATH is \`${LIBRARY_PATH-}'"
 
 if test "$noSysDirs" = "1"; then
 
-    if test -e $NIX_CC/nix-support/orig-libc; then
-
-        # Figure out what extra flags to pass to the gcc compilers
-        # being generated to make sure that they use our glibc.
-        extraFlags="$(cat $NIX_CC/nix-support/libc-cflags)"
-        extraLDFlags="$(cat $NIX_CC/nix-support/libc-ldflags) $(cat $NIX_CC/nix-support/libc-ldflags-before || true)"
+    declare \
+        EXTRA_BUILD_FLAGS EXTRA_FLAGS EXTRA_TARGET_FLAGS \
+        EXTRA_BUILD_LDFLAGS EXTRA_TARGET_LDFLAGS
 
-        # 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).
-        export NIX_FIXINC_DUMMY=$libc_dev/include
-
-        # The path to the Glibc binaries such as `crti.o'.
-        glibc_libdir="$(cat $NIX_CC/nix-support/orig-libc)/lib"
-
-    else
-        # Hack: support impure environments.
-        extraFlags="-isystem /usr/include"
-        extraLDFlags="-L/usr/lib64 -L/usr/lib"
-        glibc_libdir="/usr/lib"
-        export NIX_FIXINC_DUMMY=/usr/include
-    fi
+    for pre in 'BUILD_' ''; do
+        curCC="NIX_${pre}CC"
+        curFIXINC="NIX_${pre}FIXINC_DUMMY"
 
-    extraFlags="-I$NIX_FIXINC_DUMMY $extraFlags"
-    extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
+        declare -a extraFlags=() extraLDFlags=()
+        if [[ -e "${!curCC}/nix-support/orig-libc" ]]; then
+            # Figure out what extra flags to pass to the gcc compilers being
+            # generated to make sure that they use our glibc.
+            extraFlags=($(cat "${!curCC}/nix-support/libc-cflags"))
+            extraLDFlags=($(cat "${!curCC}/nix-support/libc-ldflags") $(cat "${!curCC}/nix-support/libc-ldflags-before" || true))
 
-    # BOOT_CFLAGS defaults to `-g -O2'; since we override it below,
-    # make sure to explictly add them so that files compiled with the
-    # bootstrap compiler are optimized and (optionally) contain
-    # debugging information (info "(gccinstall) Building").
-    if test -n "$dontStrip"; then
-        extraFlags="-O2 -g $extraFlags"
-    else
-        # Don't pass `-g' at all; this saves space while building.
-        extraFlags="-O2 $extraFlags"
-    fi
+            # The path to the Glibc binaries such as `crti.o'.
+            glibc_libdir="$(cat "${!curCC}/nix-support/orig-libc")/lib"
+            glibc_devdir="$(cat "${!curCC}/nix-support/orig-libc-dev")"
 
-    EXTRA_FLAGS="$extraFlags"
-    for i in $extraLDFlags; do
-        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,$i"
-    done
+            # 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).
+            declare NIX_${pre}FIXINC_DUMMY="$glibc_devdir/include"
+        else
+            # Hack: support impure environments.
+            extraFlags=("-isystem" "/usr/include")
+            extraLDFlags=("-L/usr/lib64" "-L/usr/lib")
+            glibc_libdir="/usr/lib"
+            declare NIX_${pre}FIXINC_DUMMY=/usr/include
+        fi
 
-    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
-    else
-        if test -z "$NIX_CC_CROSS"; then
-            EXTRA_TARGET_CFLAGS="$EXTRA_FLAGS"
-            EXTRA_TARGET_CXXFLAGS="$EXTRA_FLAGS"
-            EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS"
+        extraFlags=("-I${!curFIXINC}"
+                    "${extraFlags[@]}")
+        extraLDFlags=("-L$glibc_libdir" "-rpath" "$glibc_libdir"
+                      "${extraLDFlags[@]}")
+
+        # BOOT_CFLAGS defaults to `-g -O2'; since we override it below, make
+        # sure to explictly add them so that files compiled with the bootstrap
+        # compiler are optimized and (optionally) contain debugging information
+        # (info "(gccinstall) Building").
+        if test -n "${dontStrip-}"; then
+            extraFlags=("-O2" "-g" "${extraFlags[@]}")
         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_CC_CROSS/nix-support/orig-libc
+            # Don't pass `-g' at all; this saves space while building.
+            extraFlags=("-O2" "${extraFlags[@]}")
+        fi
 
-            # Figure out what extra flags to pass to the gcc compilers
-            # being generated to make sure that they use our glibc.
-            extraFlags="$(cat $NIX_CC_CROSS/nix-support/libc-cflags)"
-            extraLDFlags="$(cat $NIX_CC_CROSS/nix-support/libc-ldflags) $(cat $NIX_CC_CROSS/nix-support/libc-ldflags-before)"
+        declare EXTRA_${pre}FLAGS="${extraFlags[*]}"
+        for i in "${extraLDFlags[@]}"; do
+            declare EXTRA_${pre}LDFLAGS+=" -Wl,$i"
+        done
+    done
 
-            # The path to the Glibc binaries such as `crti.o'.
-            glibc_dir="$(cat $NIX_CC_CROSS/nix-support/orig-libc)"
-            glibc_libdir="$glibc_dir/lib"
-            glibc_devdir="$(cat $NIX_CC_CROSS/nix-support/orig-libc-dev)"
-            configureFlags="$configureFlags --with-native-system-header-dir=$glibc_devdir/include"
-
-            # 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="$glibc_devdir/include"
-
-            extraFlags="-I$NIX_FIXINC_DUMMY_CROSS $extraFlags"
-            extraLDFlags="-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
+    if test -z "${targetConfig-}"; then
+        # host = target, so the flags are the same
+        EXTRA_TARGET_FLAGS="$EXTRA_FLAGS"
+        EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS"
     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
     # for the startfiles.
-    makeFlagsArray+=( \
-        NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
-        SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
-        CFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
-        CXXFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
-        CFLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
-        CXXFLAGS_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 $EXTRA_TARGET_LDFLAGS" \
+    makeFlagsArray+=(
+        "BUILD_SYSTEM_HEADER_DIR=$NIX_BUILD_FIXINC_DUMMY"
+        "SYSTEM_HEADER_DIR=$NIX_BUILD_FIXINC_DUMMY"
+        "NATIVE_SYSTEM_HEADER_DIR=$NIX_FIXINC_DUMMY"
+
+        "LDFLAGS_FOR_BUILD=$EXTRA_BUILD_LDFLAGS"
+        #"LDFLAGS=$EXTRA_LDFLAGS"
+        "LDFLAGS_FOR_TARGET=$EXTRA_TARGET_LDFLAGS"
+
+        "CFLAGS_FOR_BUILD=$EXTRA_BUILD_FLAGS $EXTRA_BUILD_LDFLAGS"
+        "CXXFLAGS_FOR_BUILD=$EXTRA_BUILD_FLAGS $EXTRA_BUILD_LDFLAGS"
+        "FLAGS_FOR_BUILD=$EXTRA_BUILD_FLAGS $EXTRA_BUILD_LDFLAGS"
+
+        # It seems there is a bug in GCC 5
+        #"CFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS"
+        #"CXXFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS"
+
+        "CFLAGS_FOR_TARGET=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS"
+        "CXXFLAGS_FOR_TARGET=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS"
+        "FLAGS_FOR_TARGET=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS"
+    )
+
+    if test -z "${targetConfig-}"; then
+        makeFlagsArray+=(
+            "BOOT_CFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS"
+            "BOOT_LDFLAGS=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS"
         )
-
-    if test -z "$targetConfig"; then
-        makeFlagsArray+=( \
-            BOOT_CFLAGS="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
-            BOOT_LDFLAGS="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
-            )
     fi
 
-    if test -n "$targetConfig" -a "$crossStageStatic" == 1; then
+    if test -n "${targetConfig-}" -a "$crossStageStatic" == 1; then
         # We don't want the gcc build to assume there will be a libc providing
         # limits.h in this stagae
-        makeFlagsArray+=( \
-            LIMITS_H_TEST=false \
-            )
+        makeFlagsArray+=(
+            'LIMITS_H_TEST=false'
+        )
     else
-        makeFlagsArray+=( \
-            LIMITS_H_TEST=true \
-            )
+        makeFlagsArray+=(
+            'LIMITS_H_TEST=true'
+        )
     fi
 fi
 
-if test -n "$targetConfig"; then
+if test -n "${targetConfig-}"; then
     # The host strip will destroy some important details of the objects
     dontStrip=1
 fi
 
+eval "$oldOpts"
+
 providedPreConfigure="$preConfigure";
 preConfigure() {
     if test -n "$newlibSrc"; then
diff --git a/pkgs/development/compilers/gcc/snapshot/default.nix b/pkgs/development/compilers/gcc/snapshot/default.nix
index 981ac44d1b19..f2f8eeb09a5e 100644
--- a/pkgs/development/compilers/gcc/snapshot/default.nix
+++ b/pkgs/development/compilers/gcc/snapshot/default.nix
@@ -35,6 +35,7 @@
 , darwin ? null
 , flex ? null
 , buildPlatform, hostPlatform, targetPlatform
+, buildPackages
 }:
 
 assert langJava     -> zip != null && unzip != null
@@ -310,6 +311,8 @@ stdenv.mkDerivation ({
       "--with-mpc=${libmpc}"
     ] ++
     optional (libelf != null) "--with-libelf=${libelf}" ++
+    optional (!(crossMingw && crossStageStatic))
+      "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++
 
     # Basic configuration
     [
@@ -361,14 +364,6 @@ stdenv.mkDerivation ({
     # Ada
     optional langAda "--enable-libada" ++
 
-    # Cross-compilation
-    optional (targetPlatform == hostPlatform) (
-      let incDir = if hostPlatform.isDarwin
-                     then "${darwin.usr-include}"
-                     else "${getDev stdenv.cc.libc}/include";
-      in "--with-native-system-header-dir=${incDir}"
-    ) ++
-
     platformFlags ++
     optional (targetPlatform != hostPlatform) crossConfigureFlags ++
     optional (!bootstrap) "--disable-bootstrap" ++
@@ -433,12 +428,12 @@ stdenv.mkDerivation ({
     STRIP_FOR_TARGET = "${targetPlatform.config}-strip";
     CC_FOR_TARGET = "${targetPlatform.config}-gcc";
     CXX_FOR_TARGET = "${targetPlatform.config}-g++";
-    # If we are making a cross compiler, targetPlatform != hostPlatform
-    NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
+
     dontStrip = true;
     buildFlags = "";
   };
 
+  NIX_BUILD_CC = buildPackages.stdenv.cc;
 
   # Needed for the cross compilation to work
   AR = "ar";
@@ -446,18 +441,21 @@ stdenv.mkDerivation ({
   # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
   CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc";
 
-  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find
-  # the library headers and binaries, regarless of the language being
-  # compiled.
-
-  # Note: When building the Java AWT GTK+ peer, the build system doesn't
-  # honor `--with-gmp' et al., e.g., when building
-  # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just
-  # add them to $CPATH and $LIBRARY_PATH in this case.
+  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the
+  # library headers and binaries, regarless of the language being compiled.
+  #
+  # Note: When building the Java AWT GTK+ peer, the build system doesn't honor
+  # `--with-gmp' et al., e.g., when building
+  # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add
+  # them to $CPATH and $LIBRARY_PATH in this case.
   #
   # Likewise, the LTO code doesn't find zlib.
+  #
+  # 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.
 
-  CPATH = makeSearchPathOutput "dev" "include" ([]
+  CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([]
     ++ optional (zlib != null) zlib
     ++ optional langJava boehmgc
     ++ optionals javaAwtGtk xlibs
@@ -468,39 +466,38 @@ stdenv.mkDerivation ({
     # On GNU/Hurd glibc refers to Mach & Hurd
     # headers.
     ++ optionals (libcCross != null && libcCross ? propagatedBuildInputs)
-                 libcCross.propagatedBuildInputs);
+                 libcCross.propagatedBuildInputs
+  ));
 
-  LIBRARY_PATH = makeLibraryPath ([]
+  LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([]
     ++ optional (zlib != null) zlib
     ++ optional langJava boehmgc
     ++ optionals javaAwtGtk xlibs
     ++ optionals javaAwtGtk [ gmp mpfr ]
-    ++ optional (libpthread != null) libpthread);
-
-  EXTRA_TARGET_CFLAGS =
-    if targetPlatform != hostPlatform && libcCross != null then [
-        "-idirafter ${getDev libcCross}/include"
-      ]
-      ++ optionals (! crossStageStatic) [
-        "-B${libcCross.out}/lib"
-      ]
-    else null;
-
-  EXTRA_TARGET_LDFLAGS =
-    if targetPlatform != hostPlatform && libcCross != null then [
-        "-Wl,-L${libcCross.out}/lib"
-      ]
-      ++ (if crossStageStatic then [
+    ++ optional (libpthread != null) libpthread)
+  );
+
+  EXTRA_TARGET_FLAGS = optionals
+    (targetPlatform != hostPlatform && libcCross != null)
+    ([
+      "-idirafter ${getDev libcCross}/include"
+    ] ++ optionals (! crossStageStatic) [
+      "-B${libcCross.out}/lib"
+    ]);
+
+  EXTRA_TARGET_LDFLAGS = optionals
+    (targetPlatform != hostPlatform && libcCross != null)
+    ([
+      "-Wl,-L${libcCross.out}/lib"
+    ] ++ (if crossStageStatic then [
         "-B${libcCross.out}/lib"
       ] else [
         "-Wl,-rpath,${libcCross.out}/lib"
         "-Wl,-rpath-link,${libcCross.out}/lib"
-      ])
-      ++ optionals (libpthreadCross != null) [
-        "-L${libpthreadCross}/lib"
-        "-Wl,${libpthreadCross.TARGET_LDFLAGS}"
-      ]
-    else null;
+    ]) ++ optionals (libpthreadCross != null) [
+      "-L${libpthreadCross}/lib"
+      "-Wl,${libpthreadCross.TARGET_LDFLAGS}"
+    ]);
 
   passthru =
     { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; };
diff --git a/pkgs/development/interpreters/perl/default.nix b/pkgs/development/interpreters/perl/default.nix
index d2fff13e2ee4..7b0ecee1922d 100644
--- a/pkgs/development/interpreters/perl/default.nix
+++ b/pkgs/development/interpreters/perl/default.nix
@@ -35,6 +35,12 @@ let
       [ # Do not look in /usr etc. for dependencies.
         ./no-sys-dirs.patch
       ]
+      ++ optional (versionAtLeast version "5.24") (
+        # Fix parallel building: https://rt.perl.org/Public/Bug/Display.html?id=132360
+        fetchurlBoot {
+          url = "https://rt.perl.org/Public/Ticket/Attachment/1502646/807252/0001-Fix-missing-build-dependency-for-pods.patch";
+          sha256 = "1bb4mldfp8kq1scv480wm64n2jdsqa3ar46cjp1mjpby8h5dr2r0";
+        })
       ++ optional stdenv.isSunOS ./ld-shared.patch
       ++ optional stdenv.isDarwin ./cpp-precomp.patch
       ++ optional (stdenv.isDarwin && versionAtLeast version "5.24") ./sw_vers.patch;
diff --git a/pkgs/development/libraries/at-spi2-atk/default.nix b/pkgs/development/libraries/at-spi2-atk/default.nix
index e2350cf2cd13..52c3a5f8c076 100644
--- a/pkgs/development/libraries/at-spi2-atk/default.nix
+++ b/pkgs/development/libraries/at-spi2-atk/default.nix
@@ -3,18 +3,18 @@
 
 stdenv.mkDerivation rec {
   versionMajor = "2.26";
-  versionMinor = "0";
+  versionMinor = "1";
   moduleName   = "at-spi2-atk";
   name = "${moduleName}-${versionMajor}.${versionMinor}";
 
   src = fetchurl {
     url = "mirror://gnome/sources/${moduleName}/${versionMajor}/${name}.tar.xz";
-    sha256 = "d25e528e1406a10c7d9b675aa15e638bcbf0a122ca3681f655a30cce83272fb9";
+    sha256 = "0x9vc99ni46fg5dzlx67vbw0zqffr24gz8jvbdxbmzyvc5xw5w5l";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig intltool ];
   buildInputs = [ python popt atk libX11 libICE xorg.libXtst libXi
-                  intltool dbus_glib at_spi2_core libSM ];
+                  dbus_glib at_spi2_core libSM ];
 
   meta = with stdenv.lib; {
     platforms = platforms.unix;
diff --git a/pkgs/development/libraries/at-spi2-core/default.nix b/pkgs/development/libraries/at-spi2-core/default.nix
index 95de186a29a3..1743faafa687 100644
--- a/pkgs/development/libraries/at-spi2-core/default.nix
+++ b/pkgs/development/libraries/at-spi2-core/default.nix
@@ -1,24 +1,23 @@
-{ stdenv, fetchurl, python, pkgconfig, popt, intltool, dbus_glib
+{ stdenv, fetchurl, python, pkgconfig, popt, gettext, dbus_glib
 , libX11, xextproto, libSM, libICE, libXtst, libXi, gobjectIntrospection }:
 
 stdenv.mkDerivation rec {
   versionMajor = "2.26";
-  versionMinor = "0";
+  versionMinor = "2";
   moduleName   = "at-spi2-core";
   name = "${moduleName}-${versionMajor}.${versionMinor}";
 
   src = fetchurl {
     url = "mirror://gnome/sources/${moduleName}/${versionMajor}/${name}.tar.xz";
-    sha256 = "511568a65fda11fdd5ba5d4adfd48d5d76810d0e6ba4f7460f1b2ec0dbbbc337";
+    sha256 = "0596ghkamkxgv08r4a1pdhm06qd5zzgcfqsv64038w9xbvghq3n8";
   };
 
   outputs = [ "out" "dev" ];
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig gettext gobjectIntrospection ];
   buildInputs = [
-    python popt  intltool dbus_glib
+    python popt dbus_glib
     libX11 xextproto libSM libICE libXtst libXi
-    gobjectIntrospection
   ];
 
   # ToDo: on non-NixOS we create a symlink from there?
diff --git a/pkgs/development/libraries/atk/default.nix b/pkgs/development/libraries/atk/default.nix
index 1574d8d037c7..61c18837782d 100644
--- a/pkgs/development/libraries/atk/default.nix
+++ b/pkgs/development/libraries/atk/default.nix
@@ -2,14 +2,14 @@
 
 let
   ver_maj = "2.26";
-  ver_min = "0";
+  ver_min = "1";
 in
 stdenv.mkDerivation rec {
   name = "atk-${ver_maj}.${ver_min}";
 
   src = fetchurl {
     url = "mirror://gnome/sources/atk/${ver_maj}/${name}.tar.xz";
-    sha256 = "eafe49d5c4546cb723ec98053290d7e0b8d85b3fdb123938213acb7bb4178827";
+    sha256 = "1jwpx8az0iifw176dc2hl4mmg6gvxzxdkd1qvg4ds7c5hdmzy07g";
   };
 
   enableParallelBuilding = true;
@@ -20,9 +20,14 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ pkgconfig perl ];
 
-  propagatedBuildInputs = [ glib gobjectIntrospection /*ToDo: why propagate*/ ];
+  propagatedBuildInputs = [
+    # Required by atk.pc
+    glib
+    # TODO: Why propagate?
+    gobjectIntrospection
+  ];
 
-  #doCheck = true; # no checks in there (2.22.0)
+  doCheck = true;
 
   meta = {
     description = "Accessibility toolkit";
diff --git a/pkgs/development/libraries/babl/default.nix b/pkgs/development/libraries/babl/default.nix
index 133b39d07974..04e714f886ef 100644
--- a/pkgs/development/libraries/babl/default.nix
+++ b/pkgs/development/libraries/babl/default.nix
@@ -1,17 +1,20 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "babl-0.1.34";
+  name = "babl-0.1.38";
 
   src = fetchurl {
     url = "http://ftp.gtk.org/pub/babl/0.1/${name}.tar.bz2";
-    sha256 = "0nwakj313l2dh5npx18avkg4z17i2prkxbl6vj547a08n6ry1gsy";
+    sha256 = "11pfbyzq20596p9sgwraxspg3djg1jzz6wvz4bapf0yyr97jiyd0";
   };
 
-  meta = with stdenv.lib; { 
+  doCheck = true;
+
+  meta = with stdenv.lib; {
     description = "Image pixel format conversion library";
     homepage = http://gegl.org/babl/;
     license = licenses.gpl3;
+    maintainers = with stdenv.lib.maintainers; [ jtojnar ];
     platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/cairomm/default.nix b/pkgs/development/libraries/cairomm/default.nix
index b1ee0b8d2736..09d162db8532 100644
--- a/pkgs/development/libraries/cairomm/default.nix
+++ b/pkgs/development/libraries/cairomm/default.nix
@@ -1,16 +1,16 @@
 { fetchurl, stdenv, pkgconfig, darwin, cairo, xlibsWrapper, fontconfig, freetype, libsigcxx }:
 let
   ver_maj = "1.12";
-  ver_min = "0";
+  ver_min = "2";
 in
 stdenv.mkDerivation rec {
   name = "cairomm-${ver_maj}.${ver_min}";
 
   src = fetchurl {
-    #url = "http://www.cairographics.org/releases/${name}.tar.gz";
+    url = "http://www.cairographics.org/releases/${name}.tar.gz";
     # gnome doesn't have the latest version ATM; beware: same name but different hash
-    url = "mirror://gnome/sources/cairomm/${ver_maj}/${name}.tar.xz";
-    sha256 = "a54ada8394a86182525c0762e6f50db6b9212a2109280d13ec6a0b29bfd1afe6";
+    # url = "mirror://gnome/sources/cairomm/${ver_maj}/${name}.tar.xz";
+    sha256 = "16fmigxsaz85c3lgcls7biwyz8zy8c8h3jndfm54cxxas3a7zi25";
   };
 
   outputs = [ "out" "dev" ];
diff --git a/pkgs/development/libraries/fftw/default.nix b/pkgs/development/libraries/fftw/default.nix
index 5cf83752aa70..36c824c75287 100644
--- a/pkgs/development/libraries/fftw/default.nix
+++ b/pkgs/development/libraries/fftw/default.nix
@@ -5,7 +5,7 @@ with lib;
 assert elem precision [ "single" "double" "long-double" "quad-precision" ];
 
 let
-  version = "3.3.6-pl1";
+  version = "3.3.7";
   withDoc = stdenv.cc.isGNU;
 in
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "ftp://ftp.fftw.org/pub/fftw/fftw-${version}.tar.gz";
-    sha256 = "0g8qk98lgq770ixdf7n36yd5xjsgm2v3wzvnphwmhy6r4y2amx0y";
+    sha256 = "0wsms8narnbhfsa8chdflv2j9hzspvflblnqdn7hw8x5xdzrnq1v";
   };
 
   outputs = [ "out" "dev" "man" ]
diff --git a/pkgs/development/libraries/gegl/3.0.nix b/pkgs/development/libraries/gegl/3.0.nix
index 48b1e47e0edc..4acb6047f8a1 100644
--- a/pkgs/development/libraries/gegl/3.0.nix
+++ b/pkgs/development/libraries/gegl/3.0.nix
@@ -1,12 +1,13 @@
 { stdenv, fetchurl, pkgconfig, glib, babl, libpng, cairo, libjpeg, which
-, librsvg, pango, gtk, bzip2, json_glib, intltool, autoreconfHook, libraw }:
+, librsvg, pango, gtk, bzip2, json_glib, intltool, autoreconfHook, libraw
+, libwebp, gnome3 }:
 
 stdenv.mkDerivation rec {
-  name = "gegl-0.3.18";
+  name = "gegl-0.3.24";
 
   src = fetchurl {
     url = "http://download.gimp.org/pub/gegl/0.3/${name}.tar.bz2";
-    sha256 = "1ywihjav9yhmsvbrdyx9c5q71rqdkjg8l66ywca6s4yydvr8x1fp";
+    sha256 = "0x4xjca05fbncy49vjs5nq3ria6j8wlpiq6yldkv0r6qcb18p80s";
   };
 
   hardeningDisable = [ "format" ];
@@ -14,17 +15,22 @@ stdenv.mkDerivation rec {
   # needs fonts otherwise  don't know how to pass them
   configureFlags = "--disable-docs";
 
+  enableParallelBuilding = true;
+
+  doCheck = true;
+
   buildInputs = [
-    babl libpng cairo libjpeg librsvg pango gtk bzip2 which json_glib intltool
-    libraw
+    babl libpng cairo libjpeg librsvg pango gtk bzip2 json_glib
+    libraw libwebp gnome3.gexiv2
   ];
 
-  nativeBuildInputs = [ pkgconfig autoreconfHook ];
+  nativeBuildInputs = [ pkgconfig intltool which autoreconfHook ];
 
   meta = {
     description = "Graph-based image processing framework";
     homepage = http://www.gegl.org;
     license = stdenv.lib.licenses.gpl3;
+    maintainers = with stdenv.lib.maintainers; [ jtojnar ];
     platforms = stdenv.lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/glib-networking/default.nix b/pkgs/development/libraries/glib-networking/default.nix
index fd8055fd0b39..87f3c78a82e8 100644
--- a/pkgs/development/libraries/glib-networking/default.nix
+++ b/pkgs/development/libraries/glib-networking/default.nix
@@ -3,14 +3,14 @@
 
 let
   ver_maj = "2.54";
-  ver_min = "0";
+  ver_min = "1";
 in
 stdenv.mkDerivation rec {
   name = "glib-networking-${ver_maj}.${ver_min}";
 
   src = fetchurl {
     url = "mirror://gnome/sources/glib-networking/${ver_maj}/${name}.tar.xz";
-    sha256 = "5961b3779080b72314b373ff5d4790eb7e41b75ca91816ad7a81ef32922f7096";
+    sha256 = "0bq16m9nh3gcz9x2fvygr0iwxd2pxcbrm3lj3kihsnh1afv8g9za";
   };
 
   outputs = [ "out" "dev" ]; # to deal with propagatedBuildInputs
diff --git a/pkgs/development/libraries/gstreamer/bad/default.nix b/pkgs/development/libraries/gstreamer/bad/default.nix
index c68c7a50cc48..c033140d8dc3 100644
--- a/pkgs/development/libraries/gstreamer/bad/default.nix
+++ b/pkgs/development/libraries/gstreamer/bad/default.nix
@@ -23,7 +23,7 @@ let
 
 in
 stdenv.mkDerivation rec {
-  name = "gst-plugins-bad-1.12.2";
+  name = "gst-plugins-bad-1.12.3";
 
   meta = with stdenv.lib; {
     description = "Gstreamer Bad Plugins";
@@ -39,12 +39,12 @@ stdenv.mkDerivation rec {
   };
 
   patchPhase = ''
-    sed -i 's/openjpeg-2.1/openjpeg-${openJpegVersion}/' ext/openjpeg/*
+    sed -i 's/openjpeg-2.2/openjpeg-${openJpegVersion}/' ext/openjpeg/*
   '';
 
   src = fetchurl {
     url = "${meta.homepage}/src/gst-plugins-bad/${name}.tar.xz";
-    sha256 = "0dwyq03g2m0p16dwx8q5qvjn5x9ia72h21sf87mp97gmwkfpwb4w";
+    sha256 = "1v5z3i5ha20gmbb3r9dwsaaspv5fm1jfzlzwlzqx1gjj31v5kl1n";
   };
 
   outputs = [ "out" "dev" ];
@@ -70,4 +70,6 @@ stdenv.mkDerivation rec {
     ++ optional (!stdenv.isDarwin) wildmidi;
 
   LDFLAGS = optionalString stdenv.isDarwin "-lintl";
+
+  enableParallelBuilding = true;
 }
diff --git a/pkgs/development/libraries/gstreamer/base/default.nix b/pkgs/development/libraries/gstreamer/base/default.nix
index 2ff429179642..2cd0c14c1f34 100644
--- a/pkgs/development/libraries/gstreamer/base/default.nix
+++ b/pkgs/development/libraries/gstreamer/base/default.nix
@@ -4,7 +4,7 @@
 }:
 
 stdenv.mkDerivation rec {
-  name = "gst-plugins-base-1.12.2";
+  name = "gst-plugins-base-1.12.3";
 
   meta = {
     description = "Base plugins and helper libraries";
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gst-plugins-base/${name}.tar.xz";
-    sha256 = "0x86a7aph0y6gyq178plvwvbbyhkfb3hf0gadx9sk5z1mzixqrsh";
+    sha256 = "19ffwdch7m777ragmwpy6prqmfb742ym1n3ki40s0zyki627plyk";
   };
 
   outputs = [ "out" "dev" ];
diff --git a/pkgs/development/libraries/gstreamer/core/default.nix b/pkgs/development/libraries/gstreamer/core/default.nix
index fa69d358394c..ee9438d3c29b 100644
--- a/pkgs/development/libraries/gstreamer/core/default.nix
+++ b/pkgs/development/libraries/gstreamer/core/default.nix
@@ -4,7 +4,7 @@
 }:
 
 stdenv.mkDerivation rec {
-  name = "gstreamer-1.12.2";
+  name = "gstreamer-1.12.3";
 
   meta = {
     description = "Open source multimedia framework";
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gstreamer/${name}.tar.xz";
-    sha256 = "1fllz7n58lavyy4nh64xc7izd4ffhl12a2ff0yg4z67al8wkzplz";
+    sha256 = "0vi1g8rmmsnd630ds3jwv2iph46ll8y07fzf04mz15q88j9g926k";
   };
 
   outputs = [ "out" "dev" ];
diff --git a/pkgs/development/libraries/gstreamer/ges/default.nix b/pkgs/development/libraries/gstreamer/ges/default.nix
index e206f317d4ba..da8318890f6f 100644
--- a/pkgs/development/libraries/gstreamer/ges/default.nix
+++ b/pkgs/development/libraries/gstreamer/ges/default.nix
@@ -3,7 +3,7 @@
 }:
 
 stdenv.mkDerivation rec {
-  name = "gstreamer-editing-services-1.12.2";
+  name = "gstreamer-editing-services-1.12.3";
 
   meta = with stdenv.lib; {
     description = "Library for creation of audio/video non-linear editors";
diff --git a/pkgs/development/libraries/gstreamer/good/default.nix b/pkgs/development/libraries/gstreamer/good/default.nix
index 1c7f7951e916..e4e4f3b394db 100644
--- a/pkgs/development/libraries/gstreamer/good/default.nix
+++ b/pkgs/development/libraries/gstreamer/good/default.nix
@@ -11,7 +11,7 @@ let
   inherit (stdenv.lib) optionals optionalString;
 in
 stdenv.mkDerivation rec {
-  name = "gst-plugins-good-1.12.2";
+  name = "gst-plugins-good-1.12.3";
 
   meta = with stdenv.lib; {
     description = "Gstreamer Good Plugins";
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gst-plugins-good/${name}.tar.xz";
-    sha256 = "15pfw54fsh9s9xwrnbap4z4njwgqdfvq52k562d2hc5b11rfx4am";
+    sha256 = "00sznj1sl97fqpn6j8ngps04clvxp8h8yhw6lvszx4b855wz9rqk";
   };
 
   outputs = [ "out" "dev" ];
diff --git a/pkgs/development/libraries/gstreamer/libav/default.nix b/pkgs/development/libraries/gstreamer/libav/default.nix
index 7c0a05f8202b..9969c5e604ff 100644
--- a/pkgs/development/libraries/gstreamer/libav/default.nix
+++ b/pkgs/development/libraries/gstreamer/libav/default.nix
@@ -9,7 +9,7 @@
 assert withSystemLibav -> libav != null;
 
 stdenv.mkDerivation rec {
-  name = "gst-libav-1.12.2";
+  name = "gst-libav-1.12.3";
 
   meta = {
     homepage = https://gstreamer.freedesktop.org;
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gst-libav/${name}.tar.xz";
-    sha256 = "1crdahkjm23byg1awcrjkmgfbalfpvvac7h7whm6b2r1pfwkbdsv";
+    sha256 = "0l4nc6ikdx49l7bdrk3bd9p3pzry8a328r22zg48gyzpnv5ghph1";
   };
 
   outputs = [ "out" "dev" ];
diff --git a/pkgs/development/libraries/gstreamer/ugly/default.nix b/pkgs/development/libraries/gstreamer/ugly/default.nix
index 610f10075a8d..3aa8eb886d79 100644
--- a/pkgs/development/libraries/gstreamer/ugly/default.nix
+++ b/pkgs/development/libraries/gstreamer/ugly/default.nix
@@ -5,7 +5,7 @@
 }:
 
 stdenv.mkDerivation rec {
-  name = "gst-plugins-ugly-1.12.2";
+  name = "gst-plugins-ugly-1.12.3";
 
   meta = with stdenv.lib; {
     description = "Gstreamer Ugly Plugins";
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gst-plugins-ugly/${name}.tar.xz";
-    sha256 = "0rplyp1qk359c97ig9i2vc1v34g92khd8dslwfipva1ypwmr9hqw";
+    sha256 = "0lh00rg26iy5lr5al23lxsyncjqkgzph1bzkrgp8x9sfr62ab378";
   };
 
   outputs = [ "out" "dev" ];
diff --git a/pkgs/development/libraries/gstreamer/vaapi/default.nix b/pkgs/development/libraries/gstreamer/vaapi/default.nix
index becd4cf0d921..10df09b0a686 100644
--- a/pkgs/development/libraries/gstreamer/vaapi/default.nix
+++ b/pkgs/development/libraries/gstreamer/vaapi/default.nix
@@ -5,7 +5,7 @@
 
 stdenv.mkDerivation rec {
   name = "gst-vaapi-${version}";
-  version = "1.12.2";
+  version = "1.12.3";
 
   src = fetchurl {
     url = "${meta.homepage}/src/gstreamer-vaapi/gstreamer-vaapi-${version}.tar.xz";
diff --git a/pkgs/development/libraries/gstreamer/validate/default.nix b/pkgs/development/libraries/gstreamer/validate/default.nix
index 9704ca1d743c..d2c26b607571 100644
--- a/pkgs/development/libraries/gstreamer/validate/default.nix
+++ b/pkgs/development/libraries/gstreamer/validate/default.nix
@@ -3,7 +3,7 @@
 }:
 
 stdenv.mkDerivation rec {
-  name = "gst-validate-1.12.2";
+  name = "gst-validate-1.12.3";
 
   meta = {
     description = "Integration testing infrastructure for the GStreamer framework";
diff --git a/pkgs/development/libraries/libaccounts-glib/default.nix b/pkgs/development/libraries/libaccounts-glib/default.nix
index e410b6d4aa52..70d0e9faf845 100644
--- a/pkgs/development/libraries/libaccounts-glib/default.nix
+++ b/pkgs/development/libraries/libaccounts-glib/default.nix
@@ -1,13 +1,13 @@
 { stdenv, fetchFromGitLab, autoconf, automake, glib
 , gtk_doc, libtool, libxml2, libxslt, pkgconfig, sqlite }:
 
-let version = "1.18"; in
+let version = "1.23"; in
 stdenv.mkDerivation rec {
   name = "libaccounts-glib-${version}";
 
   src = fetchFromGitLab {
-    sha256 = "02p23vrqhw2l2w6nrwlk4bqxf7z9kplkc2d43716x9xakxr291km";
-    rev = version;
+    sha256 = "11cvl3ch0y93756k90mw1swqv0ylr8qgalmvcn5yari8z4sg6cgg";
+    rev = "VERSION_${version}";
     repo = "libaccounts-glib";
     owner = "accounts-sso";
   };
diff --git a/pkgs/development/libraries/libinput/default.nix b/pkgs/development/libraries/libinput/default.nix
index 9bf54a115ffd..db4c0c7738de 100644
--- a/pkgs/development/libraries/libinput/default.nix
+++ b/pkgs/development/libraries/libinput/default.nix
@@ -16,11 +16,11 @@ in
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "libinput-${version}";
-  version = "1.9.2";
+  version = "1.9.3";
 
   src = fetchurl {
     url = "http://www.freedesktop.org/software/libinput/${name}.tar.xz";
-    sha256 = "0fyy050hzk47g7305lx5pgyh2abvq7qs4xd3nn1is7zy3wj56s6x";
+    sha256 = "09wkc5qqk1k2a68cwfy4x853z8z35wf2qkijh66kacsvc2fjq394";
   };
 
   outputs = [ "out" "dev" ];
diff --git a/pkgs/development/libraries/libmicrohttpd/default.nix b/pkgs/development/libraries/libmicrohttpd/default.nix
index fe3f40ece737..35928e6dbf96 100644
--- a/pkgs/development/libraries/libmicrohttpd/default.nix
+++ b/pkgs/development/libraries/libmicrohttpd/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libmicrohttpd-${version}";
-  version = "0.9.57";
+  version = "0.9.58";
 
   src = fetchurl {
     url = "mirror://gnu/libmicrohttpd/${name}.tar.gz";
-    sha256 = "0kmgkk9sjg1n3q7rbzw5y4qmgh51zn5qi2j69gbqmr6phxjaghfy";
+    sha256 = "1wq17qvizis7bsyvyw1gnfycvivssncngziddnyrbzv2dhvy24bs";
   };
 
   outputs = [ "out" "dev" "devdoc" "info" ];
diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix
index 68e88cc57d06..78792e5b8dc4 100644
--- a/pkgs/development/libraries/openssl/default.nix
+++ b/pkgs/development/libraries/openssl/default.nix
@@ -107,8 +107,8 @@ let
 in {
 
   openssl_1_0_2 = common {
-    version = "1.0.2m";
-    sha256 = "03vvlfnxx4lhxc83ikfdl6jqph4h52y7lb7li03va6dkqrgg2vwc";
+    version = "1.0.2n";
+    sha256 = "1zm82pyq5a9jm10q6iv7d3dih3xwjds4x30fqph3k317byvsn2rp";
   };
 
   openssl_1_1_0 = common {
diff --git a/pkgs/development/libraries/qt-4.x/4.8/qmake-hook.sh b/pkgs/development/libraries/qt-4.x/4.8/qmake-hook.sh
index bf716a72d0fc..f288e99dd12a 100644
--- a/pkgs/development/libraries/qt-4.x/4.8/qmake-hook.sh
+++ b/pkgs/development/libraries/qt-4.x/4.8/qmake-hook.sh
@@ -3,6 +3,11 @@ qmakeConfigurePhase() {
 
     $QMAKE PREFIX=$out $qmakeFlags
 
+    if ! [[ -v enableParallelBuilding ]]; then
+        enableParallelBuilding=1
+        echo "qmake4Hook: enabled parallel building"
+    fi
+
     runHook postConfigure
 }
 
diff --git a/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh b/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh
index 17d3db65849e..eef2c7d24dfc 100644
--- a/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh
+++ b/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh
@@ -10,6 +10,11 @@ qmakeConfigurePhase() {
           NIX_OUTPUT_PLUGIN=${!outputBin}/${qtPluginPrefix:?} \
           $qmakeFlags
 
+    if ! [[ -v enableParallelBuilding ]]; then
+        enableParallelBuilding=1
+        echo "qmake: enabled parallel building"
+    fi
+
     runHook postConfigure
 }
 
diff --git a/pkgs/development/python-modules/TurboCheetah/default.nix b/pkgs/development/python-modules/TurboCheetah/default.nix
new file mode 100644
index 000000000000..45c42a7b43f9
--- /dev/null
+++ b/pkgs/development/python-modules/TurboCheetah/default.nix
@@ -0,0 +1,26 @@
+{ lib
+, buildPythonPackage
+, fetchPypi
+, cheetah
+, nose
+}:
+
+buildPythonPackage rec {
+  pname = "TurboCheetah";
+  version = "1.0";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "9e4c7ecb0d061bfb58281363ee1b09337083f013a8b4d0355326a5d8668f450c";
+  };
+
+  propagatedBuildInputs = [ cheetah ];
+
+  checkInputs = [ nose ];
+
+  meta = {
+    description = "TurboGears plugin to support use of Cheetah templates";
+    homepage = http://docs.turbogears.org/TurboCheetah;
+    license = lib.licenses.mit;
+  };
+}
\ No newline at end of file
diff --git a/pkgs/development/python-modules/backports_shutil_get_terminal_size/default.nix b/pkgs/development/python-modules/backports_shutil_get_terminal_size/default.nix
new file mode 100644
index 000000000000..7f4faa8a8b47
--- /dev/null
+++ b/pkgs/development/python-modules/backports_shutil_get_terminal_size/default.nix
@@ -0,0 +1,26 @@
+{ lib
+, buildPythonPackage
+, fetchPypi
+, pytest
+, pythonOlder
+}:
+
+if !(pythonOlder "3.3") then null else buildPythonPackage rec {
+  pname = "backports.shutil_get_terminal_size";
+  version = "1.0.0";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "713e7a8228ae80341c70586d1cc0a8caa5207346927e23d09dcbcaf18eadec80";
+  };
+
+  checkInputs = [
+    pytest
+  ];
+
+  meta = {
+    description = "A backport of the get_terminal_size function from Python 3.3’s shutil.";
+    homepage = https://github.com/chrippa/backports.shutil_get_terminal_size;
+    license = with lib.licenses; [ mit ];
+  };
+}
\ No newline at end of file
diff --git a/pkgs/development/python-modules/bootstrapped-pip/default.nix b/pkgs/development/python-modules/bootstrapped-pip/default.nix
index 9ff0b144f100..ef12e39f23bc 100644
--- a/pkgs/development/python-modules/bootstrapped-pip/default.nix
+++ b/pkgs/development/python-modules/bootstrapped-pip/default.nix
@@ -9,9 +9,9 @@ let
   };
   setuptools_source = fetchPypi {
     pname = "setuptools";
-    version = "36.7.1";
+    version = "38.2.3";
     format = "wheel";
-    sha256 = "eaacfa35eb11199d0b017df416421781a75209817bff3f94820556e36c49bd77";
+    sha256 = "0c4j3jiiwc0h1bdv4xklinp90spgvgiv5fsxp119hif9934nfxfs";
   };
 
   # TODO: Shouldn't be necessary anymore for pip > 9.0.1!
diff --git a/pkgs/development/python-modules/cheetah/default.nix b/pkgs/development/python-modules/cheetah/default.nix
new file mode 100644
index 000000000000..98af2f10a0bb
--- /dev/null
+++ b/pkgs/development/python-modules/cheetah/default.nix
@@ -0,0 +1,33 @@
+{ lib
+, buildPythonPackage
+, fetchPypi
+, markdown
+, isPy3k
+, TurboCheetah
+}:
+
+buildPythonPackage rec {
+  pname = "cheetah";
+  version = "2.4.4";
+
+  disabled = isPy3k;
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "be308229f0c1e5e5af4f27d7ee06d90bb19e6af3059794e5fd536a6f29a9b550";
+  };
+
+  propagatedBuildInputs = [ markdown ];
+
+  doCheck = false; # Circular dependency
+
+  checkInputs = [
+    TurboCheetah
+  ];
+
+  meta = {
+    homepage = http://www.cheetahtemplate.org/;
+    description = "A template engine and code generation tool";
+    license = lib.licenses.mit;
+  };
+}
\ No newline at end of file
diff --git a/pkgs/development/python-modules/contextlib2/default.nix b/pkgs/development/python-modules/contextlib2/default.nix
index cadaa8914b21..a056ba450a88 100644
--- a/pkgs/development/python-modules/contextlib2/default.nix
+++ b/pkgs/development/python-modules/contextlib2/default.nix
@@ -1,6 +1,7 @@
 { lib
 , buildPythonPackage
 , fetchPypi
+, unittest2
 }:
 
 buildPythonPackage rec {
@@ -13,9 +14,11 @@ buildPythonPackage rec {
     sha256 = "509f9419ee91cdd00ba34443217d5ca51f5a364a404e1dce9e8979cea969ca48";
   };
 
+  checkInputs = [ unittest2 ];
+
   meta = {
     description = "Backports and enhancements for the contextlib module";
     homepage = http://contextlib2.readthedocs.org/;
     license = lib.licenses.psfl;
   };
-}
\ No newline at end of file
+}
diff --git a/pkgs/development/python-modules/gst-python/default.nix b/pkgs/development/python-modules/gst-python/default.nix
index 71d77c283b84..4039d165a4f3 100644
--- a/pkgs/development/python-modules/gst-python/default.nix
+++ b/pkgs/development/python-modules/gst-python/default.nix
@@ -4,7 +4,7 @@
 
 stdenv.mkDerivation rec {
   pname = "gst-python";
-  version = "1.12.2";
+  version = "1.12.3";
   name = "${pname}-${version}";
 
   src = fetchurl {
diff --git a/pkgs/development/python-modules/pathlib2/default.nix b/pkgs/development/python-modules/pathlib2/default.nix
new file mode 100644
index 000000000000..62d5c43a4b3b
--- /dev/null
+++ b/pkgs/development/python-modules/pathlib2/default.nix
@@ -0,0 +1,31 @@
+{ lib
+, buildPythonPackage
+, fetchPypi
+, six
+, pythonOlder
+, scandir
+, glibcLocales
+}:
+
+if !(pythonOlder "3.4") then null else buildPythonPackage rec {
+  pname = "pathlib2";
+  version = "2.2.1";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "ce9007df617ef6b7bd8a31cd2089ed0c1fed1f7c23cf2bf1ba140b3dd563175d";
+  };
+
+  propagatedBuildInputs = [ six ] ++ lib.optional (pythonOlder "3.5") scandir;
+  checkInputs = [ glibcLocales ];
+
+  preCheck = ''
+    export LC_ALL="en_US.UTF-8"
+  '';
+
+  meta = {
+    description = "This module offers classes representing filesystem paths with semantics appropriate for different operating systems.";
+    homepage = https://pypi.python.org/pypi/pathlib2/;
+    license = with lib.licenses; [ mit ];
+  };
+}
\ No newline at end of file
diff --git a/pkgs/development/python-modules/setuptools/default.nix b/pkgs/development/python-modules/setuptools/default.nix
index 3c919db42f4a..1c53f3cd4372 100644
--- a/pkgs/development/python-modules/setuptools/default.nix
+++ b/pkgs/development/python-modules/setuptools/default.nix
@@ -8,13 +8,13 @@
 # Should use buildPythonPackage here somehow
 stdenv.mkDerivation rec {
   pname = "setuptools";
-  version = "36.7.1";
+  version = "38.2.3";
   name = "${python.libPrefix}-${pname}-${version}";
 
   src = fetchPypi {
     inherit pname version;
     extension = "zip";
-    sha256 = "543becf5d33d8989dc5222403997488e9dc3872bdecdabb0f57184ca253ec1e8";
+    sha256 = "124jlg72bbk2xxv5wqbwcl4h5cdslslzk92rxjxiplg79l499hv3";
   };
 
   buildInputs = [ python wrapPython unzip ];
diff --git a/pkgs/development/tools/build-managers/cmake/setup-hook.sh b/pkgs/development/tools/build-managers/cmake/setup-hook.sh
index 331f907ae612..614e00314212 100755
--- a/pkgs/development/tools/build-managers/cmake/setup-hook.sh
+++ b/pkgs/development/tools/build-managers/cmake/setup-hook.sh
@@ -51,10 +51,19 @@ cmakeConfigurePhase() {
     # And build always Release, to ensure optimisation flags
     cmakeFlags="-DCMAKE_BUILD_TYPE=${cmakeBuildType:-Release} -DCMAKE_SKIP_BUILD_RPATH=ON $cmakeFlags"
 
+    if [ "$buildPhase" = ninjaBuildPhase ]; then
+        cmakeFlags="-GNinja $cmakeFlags"
+    fi
+
     echo "cmake flags: $cmakeFlags ${cmakeFlagsArray[@]}"
 
     cmake ${cmakeDir:-.} $cmakeFlags "${cmakeFlagsArray[@]}"
 
+    if ! [[ -v enableParallelBuilding ]]; then
+        enableParallelBuilding=1
+        echo "cmake: enabled parallel building"
+    fi
+
     runHook postConfigure
 }
 
diff --git a/pkgs/development/tools/build-managers/meson/setup-hook.sh b/pkgs/development/tools/build-managers/meson/setup-hook.sh
index dacad017ede0..25e2e69ef315 100644
--- a/pkgs/development/tools/build-managers/meson/setup-hook.sh
+++ b/pkgs/development/tools/build-managers/meson/setup-hook.sh
@@ -13,6 +13,11 @@ mesonConfigurePhase() {
     meson build $mesonFlags "${mesonFlagsArray[@]}"
     cd build
 
+    if ! [[ -v enableParallelBuilding ]]; then
+        enableParallelBuilding=1
+        echo "meson: enabled parallel building"
+    fi
+
     runHook postConfigure
 }
 
diff --git a/pkgs/development/tools/build-managers/ninja/setup-hook.sh b/pkgs/development/tools/build-managers/ninja/setup-hook.sh
index 9ea6549a8243..d9ad74609316 100644
--- a/pkgs/development/tools/build-managers/ninja/setup-hook.sh
+++ b/pkgs/development/tools/build-managers/ninja/setup-hook.sh
@@ -4,9 +4,16 @@ ninjaBuildPhase() {
     if [[ -z "$ninjaFlags" && ! ( -e build.ninja ) ]]; then
         echo "no build.ninja, doing nothing"
     else
+        local buildCores=1
+
+        # Parallel building is enabled by default.
+        if [ "${enableParallelBuilding-1}" ]; then
+            buildCores="$NIX_BUILD_CORES"
+        fi
+
         # shellcheck disable=SC2086
         local flagsArray=( \
-            ${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}} \
+            -j"$buildCores" -l"$NIX_BUILD_CORES" \
             $ninjaFlags "${ninjaFlagsArray[@]}" \
             $buildFlags "${buildFlagsArray[@]}")
 
diff --git a/pkgs/development/tools/misc/editorconfig-core-c/default.nix b/pkgs/development/tools/misc/editorconfig-core-c/default.nix
index 5509ededb070..a0d6e49c0258 100644
--- a/pkgs/development/tools/misc/editorconfig-core-c/default.nix
+++ b/pkgs/development/tools/misc/editorconfig-core-c/default.nix
@@ -14,6 +14,10 @@ stdenv.mkDerivation rec {
   buildInputs = [ pcre ];
   nativeBuildInputs = [ cmake doxygen ];
 
+  # Multiple doxygen can not generate man pages in the same base directory in
+  # parallel: https://bugzilla.gnome.org/show_bug.cgi?id=791153
+  enableParallelBuilding = false;
+
   meta = with stdenv.lib; {
     homepage = http://editorconfig.org/;
     description = "EditorConfig core library written in C";
diff --git a/pkgs/games/chessx/default.nix b/pkgs/games/chessx/default.nix
index e8daca26ef7d..b8a4d4e06dc0 100644
--- a/pkgs/games/chessx/default.nix
+++ b/pkgs/games/chessx/default.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ pkgconfig qmake ];
 
   # RCC: Error in 'resources.qrc': Cannot find file 'i18n/chessx_da.qm'
-  #enableParallelBuilding = true;
+  enableParallelBuilding = false;
 
   installPhase = ''
       runHook preInstall
diff --git a/pkgs/misc/cups/default.nix b/pkgs/misc/cups/default.nix
index d005f6becadb..db344b32d218 100644
--- a/pkgs/misc/cups/default.nix
+++ b/pkgs/misc/cups/default.nix
@@ -1,5 +1,5 @@
-{ stdenv, fetchurl, pkgconfig, zlib, libjpeg, libpng, libtiff, pam
-, dbus, systemd, acl, gmp, darwin
+{ stdenv, fetchurl, fetchpatch, pkgconfig, removeReferencesTo
+, zlib, libjpeg, libpng, libtiff, pam, dbus, systemd, acl, gmp, darwin
 , libusb ? null, gnutls ? null, avahi ? null, libpaper ? null
 }:
 
@@ -9,18 +9,26 @@
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "cups-${version}";
-  version = "2.2.2";
+  version = "2.2.6";
 
   passthru = { inherit version; };
 
   src = fetchurl {
     url = "https://github.com/apple/cups/releases/download/v${version}/cups-${version}-source.tar.gz";
-    sha256 = "1xp4ji4rz3xffsz6w6nd60ajxvvihn02pkyp2l4smhqxbmyvp2gm";
+    sha256 = "16qn41b84xz6khrr2pa2wdwlqxr29rrrkjfi618gbgdkq9w5ff20";
   };
 
   outputs = [ "out" "lib" "dev" "man" ];
 
-  nativeBuildInputs = [ pkgconfig ];
+  patches = [
+    (fetchpatch {
+      url = "https://git.archlinux.org/svntogit/packages.git/plain/trunk/cups-systemd-socket.patch?h=packages/cups";
+      sha256 = "1ddgdlg9s0l2ph6l8lx1m1lx6k50gyxqi3qiwr44ppq1rxs80ny5";
+    })
+  ];
+
+  nativeBuildInputs = [ pkgconfig removeReferencesTo ];
+
   buildInputs = [ zlib libjpeg libpng libtiff libusb gnutls libpaper ]
     ++ optionals stdenv.isLinux [ avahi pam dbus systemd acl ]
     ++ optionals stdenv.isDarwin (with darwin; [
@@ -30,16 +38,9 @@ stdenv.mkDerivation rec {
   propagatedBuildInputs = [ gmp ];
 
   configureFlags = [
-    # Put just lib/* and locale into $lib; this didn't work directly.
-    # lib/cups is moved back to $out in postInstall.
-    # Beware: some parts of cups probably don't fully respect these.
-    "--prefix=$(lib)"
-    "--datadir=$(out)/share"
-    "--localedir=$(lib)/share/locale"
-
     "--localstatedir=/var"
     "--sysconfdir=/etc"
-    "--with-systemd=\${out}/lib/systemd/system"
+    "--with-rundir=/run"
     "--enable-raw-printing"
     "--enable-threads"
   ] ++ optionals stdenv.isLinux [
@@ -49,15 +50,24 @@ stdenv.mkDerivation rec {
     ++ optional (gnutls != null) "--enable-ssl"
     ++ optional (avahi != null) "--enable-avahi"
     ++ optional (libpaper != null) "--enable-libpaper"
-    ++ optionals stdenv.isDarwin [
-    "--with-bundledir=$out"
-    "--disable-launchd"
-  ];
+    ++ optional stdenv.isDarwin "--disable-launchd";
+
+  preConfigure = ''
+    configureFlagsArray+=(
+      # Put just lib/* and locale into $lib; this didn't work directly.
+      # lib/cups is moved back to $out in postInstall.
+      # Beware: some parts of cups probably don't fully respect these.
+      "--prefix=$lib"
+      "--datadir=$out/share"
+      "--localedir=$lib/share/locale"
 
-  # XXX: Hackery until https://github.com/NixOS/nixpkgs/issues/24693
-  preBuild = if stdenv.isDarwin then ''
-    export DYLD_FRAMEWORK_PATH=/System/Library/Frameworks
-  '' else null;
+      "--with-systemd=$out/lib/systemd/system"
+
+      ${optionalString stdenv.isDarwin ''
+        "--with-bundledir=$out"
+      ''}
+    )
+  '';
 
   installFlags =
     [ # Don't try to write in /var at build time.
@@ -80,21 +90,26 @@ stdenv.mkDerivation rec {
   enableParallelBuilding = true;
 
   postInstall = ''
-      moveToOutput lib/cups "$out"
+      libexec=${if stdenv.isDarwin then "libexec/cups" else "lib/cups"}
+      moveToOutput $libexec "$out"
+
+      # $lib contains references to $out/share/cups.
+      # CUPS is working without them, so they are not vital.
+      find "$lib" -type f -exec grep -q "$out" {} \; \
+           -printf "removing references from %p\n" \
+           -exec remove-references-to -t "$out" {} +
 
       # Delete obsolete stuff that conflicts with cups-filters.
       rm -rf $out/share/cups/banners $out/share/cups/data/testprint
 
-      # Some outputs in cups-config were unexpanded and some even wrong.
       moveToOutput bin/cups-config "$dev"
-      sed -e "/^cups_serverbin=/s|\$(lib)|$out|" \
-          -e "s|\$(out)|$out|" \
-          -e "s|\$(lib)|$lib|" \
+      sed -e "/^cups_serverbin=/s|$lib|$out|" \
           -i "$dev/bin/cups-config"
 
       # Rename systemd files provided by CUPS
       for f in "$out"/lib/systemd/system/*; do
         substituteInPlace "$f" \
+          --replace "$lib/$libexec" "$out/$libexec" \
           --replace "org.cups.cupsd" "cups" \
           --replace "org.cups." ""
 
diff --git a/pkgs/os-specific/linux/conky/default.nix b/pkgs/os-specific/linux/conky/default.nix
index fd585515cf02..b7a8dc23a787 100644
--- a/pkgs/os-specific/linux/conky/default.nix
+++ b/pkgs/os-specific/linux/conky/default.nix
@@ -131,6 +131,10 @@ stdenv.mkDerivation rec {
     ++ optional nvidiaSupport       "-DBUILD_NVIDIA=ON"
     ;
 
+  # `make -f src/CMakeFiles/conky.dir/build.make src/CMakeFiles/conky.dir/conky.cc.o`:
+  # src/conky.cc:137:23: fatal error: defconfig.h: No such file or directory
+  enableParallelBuilding = false;
+
   meta = with stdenv.lib; {
     homepage = http://conky.sourceforge.net/;
     description = "Advanced, highly configurable system monitor based on torsmo";
diff --git a/pkgs/tools/misc/desktop-file-utils/default.nix b/pkgs/tools/misc/desktop-file-utils/default.nix
index e5e3815481f1..6e2f6548722e 100644
--- a/pkgs/tools/misc/desktop-file-utils/default.nix
+++ b/pkgs/tools/misc/desktop-file-utils/default.nix
@@ -3,11 +3,11 @@
 with stdenv.lib;
 
 stdenv.mkDerivation rec {
-  name = "desktop-file-utils-0.22";
+  name = "desktop-file-utils-0.23";
 
   src = fetchurl {
     url = "http://www.freedesktop.org/software/desktop-file-utils/releases/${name}.tar.xz";
-    sha256 = "1ianvr2a69yjv4rpyv30w7yjsmnsb23crrka5ndqxycj4rkk4dc4";
+    sha256 = "119kj2w0rrxkhg4f9cf5waa55jz1hj8933vh47vcjipcplql02bc";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/tools/misc/rockbox-utility/default.nix b/pkgs/tools/misc/rockbox-utility/default.nix
index 32f5a551dfe3..e9ed5c0450af 100644
--- a/pkgs/tools/misc/rockbox-utility/default.nix
+++ b/pkgs/tools/misc/rockbox-utility/default.nix
@@ -39,6 +39,12 @@ stdenv.mkDerivation  rec {
     runHook postInstall
   '';
 
+  # `make build/rcc/qrc_rbutilqt-lang.cpp` fails with
+  #      RCC: Error in 'rbutilqt-lang.qrc': Cannot find file 'lang/rbutil_cs.qm'
+  # Do not add `lrelease rbutilqt.pro` into preConfigure, otherwise `make lrelease`
+  # may clobber the files read by the parallel `make build/rcc/qrc_rbutilqt-lang.cpp`.
+  enableParallelBuilding = false;
+
   meta = with stdenv.lib; {
     description = "Open source firmware for mp3 players";
     homepage = http://www.rockbox.org;
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 950f78fe9761..188fe7440db7 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -1051,21 +1051,7 @@ in {
     };
   };
 
-  backports_shutil_get_terminal_size = if !(pythonOlder "3.3") then null else buildPythonPackage rec {
-    name = "backports.shutil_get_terminal_size-${version}";
-    version = "1.0.0";
-
-    src = pkgs.fetchurl {
-      url = "mirror://pypi/b/backports.shutil_get_terminal_size/${name}.tar.gz";
-      sha256 = "713e7a8228ae80341c70586d1cc0a8caa5207346927e23d09dcbcaf18eadec80";
-    };
-
-    meta = {
-      description = "A backport of the get_terminal_size function from Python 3.3’s shutil.";
-      homepage = https://github.com/chrippa/backports.shutil_get_terminal_size;
-      license = with licenses; [ mit ];
-    };
-  };
+  backports_shutil_get_terminal_size = callPackage ../development/python-modules/backports_shutil_get_terminal_size { };
 
   backports_ssl_match_hostname_3_4_0_2 = self.buildPythonPackage rec {
     name = "backports.ssl_match_hostname-3.4.0.2";
@@ -2464,23 +2450,7 @@ in {
 
   characteristic = callPackage ../development/python-modules/characteristic { };
 
-  cheetah = buildPythonPackage rec {
-    version = "2.4.4";
-    name = "cheetah-${version}";
-    disabled = isPy3k;
-
-    src = pkgs.fetchurl {
-      url = "mirror://pypi/C/Cheetah/Cheetah-${version}.tar.gz";
-      sha256 = "be308229f0c1e5e5af4f27d7ee06d90bb19e6af3059794e5fd536a6f29a9b550";
-    };
-
-    propagatedBuildInputs = with self; [ self.markdown ];
-
-    meta = {
-      homepage = http://www.cheetahtemplate.org/;
-      description = "A template engine and code generation tool";
-    };
-  };
+  cheetah = callPackage ../development/python-modules/cheetah { };
 
   cherrypy = callPackage ../development/python-modules/cherrypy {};
 
@@ -14309,24 +14279,7 @@ in {
     };
   };
 
-  pathlib2 = if !(pythonOlder "3.4") then null else buildPythonPackage rec {
-    name = "pathlib2-${version}";
-    version = "2.2.1";
-
-    src = pkgs.fetchurl {
-      url = "mirror://pypi/p/pathlib2/${name}.tar.gz";
-      sha256 = "ce9007df617ef6b7bd8a31cd2089ed0c1fed1f7c23cf2bf1ba140b3dd563175d";
-    };
-
-    propagatedBuildInputs = with self; [ six ] ++ optional (pythonOlder "3.5") scandir;
-
-    meta = {
-      description = "This module offers classes representing filesystem paths with semantics appropriate for different operating systems.";
-      homepage = https://pypi.python.org/pypi/pathlib2/;
-      license = with licenses; [ mit ];
-    };
-
-  };
+  pathlib2 = callPackage ../development/python-modules/pathlib2 { };
 
   pathpy = callPackage ../development/python-modules/path.py { };
 
@@ -19691,6 +19644,7 @@ in {
      };
    };
 
+  TurboCheetah = callPackage ../development/python-modules/TurboCheetah { };
 
   tweepy = buildPythonPackage (rec {
     name = "tweepy-3.5.0";