summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--lib/maintainers.nix1
-rw-r--r--nixos/lib/test-driver/Machine.pm11
-rw-r--r--nixos/modules/services/monitoring/graphite.nix54
-rw-r--r--nixos/release.nix1
-rw-r--r--nixos/tests/graphite.nix26
-rw-r--r--pkgs/applications/altcoins/default.nix3
-rw-r--r--pkgs/applications/editors/eclipse/default.nix23
-rw-r--r--pkgs/applications/editors/eclipse/plugins.nix6
-rw-r--r--pkgs/applications/editors/rstudio/default.nix8
-rw-r--r--pkgs/applications/editors/vscode/default.nix8
-rw-r--r--pkgs/applications/graphics/digikam/0001-Disable-fno-operator-names.patch25
-rw-r--r--pkgs/applications/graphics/digikam/default.nix22
-rw-r--r--pkgs/applications/misc/blender/default.nix9
-rw-r--r--pkgs/applications/misc/playonlinux/default.nix4
-rw-r--r--pkgs/applications/networking/browsers/tor-browser-bundle/extensions.nix12
-rw-r--r--pkgs/applications/science/math/caffe/default.nix23
-rw-r--r--pkgs/applications/science/math/cntk/default.nix98
-rw-r--r--pkgs/applications/virtualization/lkl/default.nix6
-rw-r--r--pkgs/development/compilers/cudatoolkit/default.nix68
-rw-r--r--pkgs/development/compilers/oraclejdk/jdk8cpu-linux.nix6
-rw-r--r--pkgs/development/compilers/oraclejdk/jdk8psu-linux.nix6
-rw-r--r--pkgs/development/compilers/oraclejdk/jdk9-linux.nix8
-rw-r--r--pkgs/development/compilers/tinycc/default.nix6
-rw-r--r--pkgs/development/coq-modules/flocq/default.nix6
-rw-r--r--pkgs/development/libraries/boost/1.65.nix12
-rw-r--r--pkgs/development/libraries/boost/generic.nix15
-rw-r--r--pkgs/development/libraries/libdrm/default.nix4
-rw-r--r--pkgs/development/libraries/libqtav/default.nix16
-rw-r--r--pkgs/development/libraries/libtorrent-rasterbar/1.0.nix13
-rw-r--r--pkgs/development/libraries/libtorrent-rasterbar/default.nix10
-rw-r--r--pkgs/development/libraries/libtorrent-rasterbar/generic.nix8
-rw-r--r--pkgs/development/libraries/opencv/3.x.nix10
-rw-r--r--pkgs/development/libraries/opensubdiv/default.nix10
-rw-r--r--pkgs/development/libraries/science/math/clblas/cuda/default.nix73
-rw-r--r--pkgs/development/libraries/science/math/clblas/default.nix62
-rw-r--r--pkgs/development/libraries/science/math/clblas/platform.patch (renamed from pkgs/development/libraries/science/math/clblas/cuda/platform.patch)0
-rw-r--r--pkgs/development/libraries/science/math/cudnn/7.5-5.0/default.nix46
-rw-r--r--pkgs/development/libraries/science/math/cudnn/8.0-5.1/default.nix40
-rw-r--r--pkgs/development/libraries/science/math/cudnn/8.0-6.0/default.nix40
-rw-r--r--pkgs/development/libraries/science/math/cudnn/default.nix57
-rw-r--r--pkgs/development/libraries/science/math/cudnn/generic.nix (renamed from pkgs/development/libraries/science/math/cudnn/8.0-5.0/default.nix)27
-rw-r--r--pkgs/development/ocaml-modules/lablgtk/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/ocamlgraph/default.nix4
-rw-r--r--pkgs/development/python-modules/Theano/default.nix75
-rw-r--r--pkgs/development/python-modules/Theano/theano-with-cuda/default.nix65
-rw-r--r--pkgs/development/python-modules/Theano/theano-without-cuda/default.nix44
-rw-r--r--pkgs/development/python-modules/libgpuarray/cuda/default.nix129
-rw-r--r--pkgs/development/python-modules/libgpuarray/default.nix81
-rw-r--r--pkgs/development/python-modules/pyftgl/default.nix6
-rw-r--r--pkgs/development/python-modules/tensorflow/default.nix303
-rw-r--r--pkgs/development/python-modules/waitress-django/default.nix8
-rw-r--r--pkgs/development/python-modules/waitress-django/setup.py12
-rwxr-xr-xpkgs/development/python-modules/waitress-django/src/waitress-serve-django14
-rw-r--r--pkgs/development/tools/build-managers/bazel/0.4.nix32
-rw-r--r--pkgs/development/tools/build-managers/bazel/nix-hacks.patch51
-rw-r--r--pkgs/games/bastet/default.nix10
-rw-r--r--pkgs/games/openrct2/default.nix70
-rw-r--r--pkgs/os-specific/linux/kernel/linux-4.13.nix4
-rw-r--r--pkgs/os-specific/linux/kernel/linux-4.9.nix4
-rw-r--r--pkgs/os-specific/linux/kexectools/default.nix4
-rw-r--r--pkgs/os-specific/linux/wireguard/default.nix4
-rw-r--r--pkgs/servers/atlassian/confluence.nix4
-rw-r--r--pkgs/servers/atlassian/jira.nix4
-rw-r--r--pkgs/servers/dns/knot-dns/default.nix7
-rw-r--r--pkgs/servers/monitoring/telegraf/default.nix4
-rw-r--r--pkgs/servers/monitoring/telegraf/deps-1.4.2.nix (renamed from pkgs/servers/monitoring/telegraf/deps-1.4.1.nix)0
-rw-r--r--pkgs/tools/graphics/povray/default.nix4
-rw-r--r--pkgs/tools/misc/snapper/default.nix10
-rw-r--r--pkgs/tools/networking/isync/default.nix8
-rw-r--r--pkgs/top-level/all-packages.nix83
-rw-r--r--pkgs/top-level/perl-packages.nix4
-rw-r--r--pkgs/top-level/python-packages.nix126
72 files changed, 1167 insertions, 894 deletions
diff --git a/lib/maintainers.nix b/lib/maintainers.nix
index 3116336db902..3565303dca49 100644
--- a/lib/maintainers.nix
+++ b/lib/maintainers.nix
@@ -323,6 +323,7 @@
   konimex = "Muhammad Herdiansyah <herdiansyah@netc.eu>";
   koral = "Koral <koral@mailoo.org>";
   kovirobi = "Kovacsics Robert <kovirobi@gmail.com>";
+  kquick = "Kevin Quick <quick@sparq.org>";
   kragniz = "Louis Taylor <louis@kragniz.eu>";
   kristoff3r = "Kristoffer Søholm <k.soeholm@gmail.com>";
   ktosiek = "Tomasz Kontusz <tomasz.kontusz@gmail.com>";
diff --git a/nixos/lib/test-driver/Machine.pm b/nixos/lib/test-driver/Machine.pm
index cd375352c4ca..a7ed5d1faa38 100644
--- a/nixos/lib/test-driver/Machine.pm
+++ b/nixos/lib/test-driver/Machine.pm
@@ -372,6 +372,17 @@ sub getUnitInfo {
     return $info;
 }
 
+# Fail if the given systemd unit is not in the "active" state.
+sub requireActiveUnit {
+    my ($self, $unit) = @_;
+    $self->nest("checking if unit ‘$unit’ has reached state 'active'", sub {
+        my $info = $self->getUnitInfo($unit);
+        my $state = $info->{ActiveState};
+        if ($state ne "active") {
+            die "Expected unit ‘$unit’ to to be in state 'active' but it is in state ‘$state’\n";
+        };
+    });
+}
 
 # Wait for a systemd unit to reach the "active" state.
 sub waitForUnit {
diff --git a/nixos/modules/services/monitoring/graphite.nix b/nixos/modules/services/monitoring/graphite.nix
index 332a04634d06..01b4aca91731 100644
--- a/nixos/modules/services/monitoring/graphite.nix
+++ b/nixos/modules/services/monitoring/graphite.nix
@@ -7,6 +7,19 @@ let
   writeTextOrNull = f: t: mapNullable (pkgs.writeTextDir f) t;
 
   dataDir = cfg.dataDir;
+  staticDir = cfg.dataDir + "/static";
+
+  graphiteLocalSettingsDir = pkgs.runCommand "graphite_local_settings"
+    {inherit graphiteLocalSettings;} ''
+    mkdir -p $out
+    ln -s $graphiteLocalSettings $out/graphite_local_settings.py
+  '';
+
+  graphiteLocalSettings = pkgs.writeText "graphite_local_settings.py" (
+    "STATIC_ROOT = '${staticDir}'\n" +
+    optionalString (! isNull config.time.timeZone) "TIME_ZONE = '${config.time.timeZone}'\n"
+    + cfg.web.extraConfig
+  );
 
   graphiteApiConfig = pkgs.writeText "graphite-api.yaml" ''
     time_zone: ${config.time.timeZone}
@@ -94,6 +107,15 @@ in {
         default = 8080;
         type = types.int;
       };
+
+      extraConfig = mkOption {
+        type = types.str;
+        default = "";
+        description = ''
+          Graphite webapp settings. See:
+          <link xlink:href="http://graphite.readthedocs.io/en/latest/config-local-settings.html"/>
+        '';
+      };
     };
 
     api = {
@@ -460,9 +482,13 @@ in {
                 ];
               };
               penvPack = "${penv}/${pkgs.python.sitePackages}";
-              # opt/graphite/webapp contains graphite/settings.py
-              # explicitly adding pycairo in path because it cannot be imported via buildEnv
-            in "${penvPack}/opt/graphite/webapp:${penvPack}:${pkgs.pythonPackages.pycairo}/${pkgs.python.sitePackages}";
+            in concatStringsSep ":" [
+                 "${graphiteLocalSettingsDir}"
+                 "${penvPack}/opt/graphite/webapp"
+                 "${penvPack}"
+                 # explicitly adding pycairo in path because it cannot be imported via buildEnv
+                 "${pkgs.pythonPackages.pycairo}/${pkgs.python.sitePackages}"
+               ];
           DJANGO_SETTINGS_MODULE = "graphite.settings";
           GRAPHITE_CONF_DIR = configDir;
           GRAPHITE_STORAGE_DIR = dataDir;
@@ -470,9 +496,9 @@ in {
         };
         serviceConfig = {
           ExecStart = ''
-            ${pkgs.python27Packages.waitress}/bin/waitress-serve \
-            --host=${cfg.web.listenAddress} --port=${toString cfg.web.port} \
-            --call django.core.handlers.wsgi:WSGIHandler'';
+            ${pkgs.python27Packages.waitress-django}/bin/waitress-serve-django \
+              --host=${cfg.web.listenAddress} --port=${toString cfg.web.port}
+          '';
           User = "graphite";
           Group = "graphite";
           PermissionsStartOnly = true;
@@ -482,16 +508,20 @@ in {
             mkdir -p ${dataDir}/{whisper/,log/webapp/}
             chmod 0700 ${dataDir}/{whisper/,log/webapp/}
 
-            # populate database
-            ${pkgs.python27Packages.graphite_web}/bin/manage-graphite.py syncdb --noinput
+            ${pkgs.pythonPackages.django_1_8}/bin/django-admin.py migrate --noinput
 
-            # create index
-            ${pkgs.python27Packages.graphite_web}/bin/build-index.sh
-
-            chown -R graphite:graphite ${cfg.dataDir}
+            chown -R graphite:graphite ${dataDir}
 
             touch ${dataDir}/db-created
           fi
+
+          # Only collect static files when graphite_web changes.
+          if ! [ "${dataDir}/current_graphite_web" -ef "${pkgs.python27Packages.graphite_web}" ]; then
+            mkdir -p ${staticDir}
+            ${pkgs.pythonPackages.django_1_8}/bin/django-admin.py collectstatic  --noinput --clear
+            chown -R graphite:graphite ${staticDir}
+            ln -sfT "${pkgs.python27Packages.graphite_web}" "${dataDir}/current_graphite_web"
+          fi
         '';
       };
 
diff --git a/nixos/release.nix b/nixos/release.nix
index 63f739e8e896..3016b1ef9442 100644
--- a/nixos/release.nix
+++ b/nixos/release.nix
@@ -257,6 +257,7 @@ in rec {
   tests.gnome3 = callTest tests/gnome3.nix {};
   tests.gnome3-gdm = callTest tests/gnome3-gdm.nix {};
   tests.grafama = callTest tests/grafana.nix {};
+  tests.graphite = callTest tests/graphite.nix {};
   tests.hardened = callTest tests/hardened.nix { };
   tests.hibernate = callTest tests/hibernate.nix {};
   tests.hound = callTest tests/hound.nix {};
diff --git a/nixos/tests/graphite.nix b/nixos/tests/graphite.nix
new file mode 100644
index 000000000000..4fd7de192d55
--- /dev/null
+++ b/nixos/tests/graphite.nix
@@ -0,0 +1,26 @@
+import ./make-test.nix ({ pkgs, ...} :
+{
+  name = "graphite";
+  nodes = {
+    one =
+      { config, pkgs, ... }: {
+        services.graphite = {
+          web = {
+            enable = true;
+          };
+          carbon = {
+            enableCache = true;
+          };
+        };
+      };
+    };
+
+  testScript = ''
+    startAll;
+    $one->waitForUnit("default.target");
+    $one->requireActiveUnit("graphiteWeb.service");
+    $one->requireActiveUnit("carbonCache.service");
+    $one->succeed("echo \"foo 1 `date +%s`\" | nc -q0 localhost 2003");
+    $one->waitUntilSucceeds("curl 'http://localhost:8080/metrics/find/?query=foo&format=treejson' --silent | grep foo")
+  '';
+})
diff --git a/pkgs/applications/altcoins/default.nix b/pkgs/applications/altcoins/default.nix
index 0264ce397762..1a21efc32322 100644
--- a/pkgs/applications/altcoins/default.nix
+++ b/pkgs/applications/altcoins/default.nix
@@ -1,4 +1,4 @@
-{ callPackage, boost155, boost162, boost163, openssl_1_1_0, haskellPackages, darwin, libsForQt5 }:
+{ callPackage, boost155, boost162, openssl_1_1_0, haskellPackages, darwin, libsForQt5 }:
 
 rec {
 
@@ -59,6 +59,5 @@ rec {
   zcash = callPackage ./zcash {
     withGui = false;
     openssl = openssl_1_1_0;
-    boost = boost163;
   };
 }
diff --git a/pkgs/applications/editors/eclipse/default.nix b/pkgs/applications/editors/eclipse/default.nix
index b039bd168d87..5ef29081cf01 100644
--- a/pkgs/applications/editors/eclipse/default.nix
+++ b/pkgs/applications/editors/eclipse/default.nix
@@ -8,6 +8,9 @@
 
 assert stdenv ? glibc;
 
+# http://download.eclipse.org/eclipse/downloads/ is the main place to
+# find the downloads needed for new versions
+
 rec {
 
   buildEclipse = import ./build-eclipse.nix {
@@ -111,16 +114,16 @@ rec {
   };
 
   eclipse-platform-47 = buildEclipse {
-    name = "eclipse-platform-4.7";
+    name = "eclipse-platform-4.7.1a";
     description = "Eclipse Platform Oxygen";
     sources = {
       "x86_64-linux" = fetchurl {
-          url = https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/eclipse/downloads/drops4/R-4.7-201706120950/eclipse-platform-4.7-linux-gtk-x86_64.tar.gz;
-          sha256 = "0hrgijydxvd2zz1npv5qw8d79f48a6lsdw3qy1wqf7k59aqyg2fq";
+          url = https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/eclipse/downloads/drops4/R-4.7.1a-201710090410/eclipse-platform-4.7.1a-linux-gtk-x86_64.tar.gz;
+          sha256 = "13gyrnhyhdpsrbi5nl0fhpwrqz3gdyqq3r0m1f2z3y6yr75sgw33";
         };
       "i686-linux" = fetchurl {
-          url = https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/eclipse/downloads/drops4/R-4.7-201706120950/eclipse-platform-4.7-linux-gtk.tar.gz;
-          sha256 = "00m89j26m8nj190q144wx8d88mldx1z6i797p8isg3rhbz3x5dbc";
+          url = https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/eclipse/downloads/drops4/R-4.7.1a-201710090410/eclipse-platform-4.7.1a-linux-gtk.tar.gz;
+          sha256 = "013dfk23wa4jy177ywrkkr16wdjf6jxzjcz6mkl4ygki47yj9c5s";
         };
     };
   };
@@ -165,16 +168,16 @@ rec {
   };
 
   eclipse-sdk-47 = buildEclipse {
-    name = "eclipse-sdk-4.7";
+    name = "eclipse-sdk-4.7.1a";
     description = "Eclipse Oxygen Classic";
     sources = {
       "x86_64-linux" = fetchurl {
-          url = https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/eclipse/downloads/drops4/R-4.7-201706120950/eclipse-SDK-4.7-linux-gtk-x86_64.tar.gz;
-          sha256 = "1nz0hl0gg4a8iffnaggbhdw0ra8a7wljlimvijbbybh0nhvfd9n3";
+          url = https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/eclipse/downloads/drops4/R-4.7.1a-201710090410/eclipse-SDK-4.7.1a-linux-gtk-x86_64.tar.gz;
+          sha256 = "05xpdbig170rw7k5dx33dlyz187wv62mma8s5wxrqi7f4117sx4y";
         };
       "i686-linux" = fetchurl {
-          url = https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/eclipse/downloads/drops4/R-4.7-201706120950/eclipse-SDK-4.7-linux-gtk.tar.gz;
-          sha256 = "0dar69v7d7bkl18si45bccvil809a85ghb7k88m1q2cq1kd2r8z5";
+          url = https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/eclipse/downloads/drops4/R-4.7.1a-201710090410/eclipse-SDK-4.7.1a-linux-gtk.tar.gz;
+          sha256 = "09c9m88k1cm9bhd900p5yf2q9pijrymgjcbhmagz0fcwhldrv0ys";
         };
     };
   };
diff --git a/pkgs/applications/editors/eclipse/plugins.nix b/pkgs/applications/editors/eclipse/plugins.nix
index b9b0ee61c0b0..f3459e57d9b2 100644
--- a/pkgs/applications/editors/eclipse/plugins.nix
+++ b/pkgs/applications/editors/eclipse/plugins.nix
@@ -364,12 +364,12 @@ rec {
 
   jdt = buildEclipseUpdateSite rec {
     name = "jdt-${version}";
-    version = "4.7";
+    version = "4.7.1a";
 
     src = fetchzip {
       stripRoot = false;
-      url = "https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/eclipse/downloads/drops4/R-4.7-201706120950/org.eclipse.jdt-4.7.zip";
-      sha256 = "0y17shnlh90gg9226lraknvdnp2i71ck91dnxbbzvxl8b64v8v1p";
+      url = https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/eclipse/downloads/drops4/R-4.7.1a-201710090410/org.eclipse.jdt-4.7.1a.zip;
+      sha256 = "1hpvpj8ghfk8aqbzfrpcxw3wxrczq6zd3bpx4sxjrsi926jsjaf4";
     };
 
     meta = with stdenv.lib; {
diff --git a/pkgs/applications/editors/rstudio/default.nix b/pkgs/applications/editors/rstudio/default.nix
index bf8374fdaaa1..a5049e4236b3 100644
--- a/pkgs/applications/editors/rstudio/default.nix
+++ b/pkgs/applications/editors/rstudio/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, makeDesktopItem, cmake, boost163, zlib, openssl,
+{ stdenv, fetchurl, fetchpatch, makeDesktopItem, cmake, boost, zlib, openssl,
 R, qt5, libuuid, hunspellDicts, unzip, ant, jdk, gnumake, makeWrapper, pandoc
 }:
 
@@ -10,7 +10,9 @@ in
 stdenv.mkDerivation rec {
   name = "RStudio-${version}";
 
-  buildInputs = [ cmake boost163 zlib openssl R qt5.full qt5.qtwebkit qt5.qtwebchannel libuuid unzip ant jdk makeWrapper pandoc ];
+  nativeBuildInputs = [ cmake unzip ant jdk makeWrapper pandoc ];
+
+  buildInputs = [ boost zlib openssl R qt5.full qt5.qtwebkit qt5.qtwebchannel libuuid ];
 
   src = fetchurl {
     url = "https://github.com/rstudio/rstudio/archive/v${version}.tar.gz";
@@ -96,6 +98,8 @@ stdenv.mkDerivation rec {
       cp ${pandoc}/bin/pandoc dependencies/common/pandoc/
     '';
 
+  enableParallelBuilding = true;
+
   cmakeFlags = [ "-DRSTUDIO_TARGET=Desktop" "-DQT_QMAKE_EXECUTABLE=$NIX_QT5_TMP/bin/qmake" ];
 
   desktopItem = makeDesktopItem {
diff --git a/pkgs/applications/editors/vscode/default.nix b/pkgs/applications/editors/vscode/default.nix
index b5b2a49c42b6..23bcdae5fb21 100644
--- a/pkgs/applications/editors/vscode/default.nix
+++ b/pkgs/applications/editors/vscode/default.nix
@@ -2,7 +2,7 @@
   makeWrapper, libXScrnSaver, libxkbfile, libsecret }:
 
 let
-  version = "1.17.1";
+  version = "1.17.2";
   channel = "stable";
 
   plat = {
@@ -12,9 +12,9 @@ let
   }.${stdenv.system};
 
   sha256 = {
-    "i686-linux" = "09nvibfn2z5cxjcdxqa2xy63jqwpvfgk7hdy1pc0mnpszz6kn4v7";
-    "x86_64-linux" = "1fb3hil7dggnz7hks1i806ckd3wl5g0a2syjdbh9dx5iqarp2782";
-    "x86_64-darwin" = "1vgbsmbcsdxc0h0ny61a3rhbwxzrfzkxl47sy3w410xcqlv8ad2v";
+    "i686-linux" = "04mnj74pqkgfgdacq4643qrd7ybka1366lr7mwn0f70lk05wb2h2";
+    "x86_64-linux" = "0y37wwvq6flaa2fh2r6b9cplbcszq726zrx6b8slzq6s5wl2lgmr";
+    "x86_64-darwin" = "1cqyir7ijwafy68d5vbw47cs1x2lqs1wjnvhhw15yi2d7c14fq7q";
   }.${stdenv.system};
 
   archive_fmt = if stdenv.system == "x86_64-darwin" then "zip" else "tar.gz";
diff --git a/pkgs/applications/graphics/digikam/0001-Disable-fno-operator-names.patch b/pkgs/applications/graphics/digikam/0001-Disable-fno-operator-names.patch
deleted file mode 100644
index 149a2b2b1aca..000000000000
--- a/pkgs/applications/graphics/digikam/0001-Disable-fno-operator-names.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From beb9ad0149adfe448acfa650fb3e171d5fdd7e27 Mon Sep 17 00:00:00 2001
-From: Moritz Ulrich <moritz@tarn-vedra.de>
-Date: Wed, 22 Feb 2017 15:28:11 +0100
-Subject: [PATCH] Disable `-fno-operator-names`
-
----
- core/CMakeLists.txt | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
-index 89e06827e6..01d0c88ea9 100644
---- a/core/CMakeLists.txt
-+++ b/core/CMakeLists.txt
-@@ -98,6 +98,8 @@ include(MacroOpenCV)
- include(MacroJPEG)
- include(MacroBoolTo01)
- 
-+string(REPLACE "-fno-operator-names" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
-+
- # ==================================================================================================
- 
- option(ENABLE_OPENCV3               "Build digiKam with OpenCV3 instead OpenCV2 (default=OFF)"                           OFF)
--- 
-2.11.1
-
diff --git a/pkgs/applications/graphics/digikam/default.nix b/pkgs/applications/graphics/digikam/default.nix
index 96b1ca54d558..44ee807fe984 100644
--- a/pkgs/applications/graphics/digikam/default.nix
+++ b/pkgs/applications/graphics/digikam/default.nix
@@ -8,6 +8,7 @@
 , qtsvg
 , qtwebkit
 
+, kcalcore
 , kconfigwidgets
 , kcoreaddons
 , kdoctools
@@ -28,12 +29,15 @@
 , lensfun
 , libgphoto2
 , libkipi
+, libksane
 , liblqr1
 , libqtav
 , libusb1
+, mesa
 , marble
 , mysql
-, opencv
+, opencv3
+, pcre
 , threadweaver
 
 # For panorama and focus stacking
@@ -46,17 +50,15 @@
 
 mkDerivation rec {
   name    = "digikam-${version}";
-  version = "5.4.0";
+  version = "5.7.0";
 
   src = fetchurl {
     url = "http://download.kde.org/stable/digikam/${name}.tar.xz";
-    sha256 = "0dgsgji14l5zvxny36hrfsp889fsfrsbbn9bg57m18404xp903kg";
+    sha256 = "1xah079g47fih8l9qy1ifppfvmq5yms5y1z54nvxdyz8nsszy19n";
   };
 
   nativeBuildInputs = [ cmake extra-cmake-modules kdoctools wrapGAppsHook ];
 
-  patches = [ ./0001-Disable-fno-operator-names.patch ];
-
   buildInputs = [
     bison
     boost
@@ -68,19 +70,21 @@ mkDerivation rec {
     lensfun
     libgphoto2
     libkipi
+    libksane
     liblqr1
     libqtav
     libusb1
+    mesa
     mysql
-    opencv
-  ];
+    opencv3
+    pcre
 
-  propagatedBuildInputs = [
     qtbase
     qtxmlpatterns
     qtsvg
     qtwebkit
 
+    kcalcore
     kconfigwidgets
     kcoreaddons
     kfilemetadata
@@ -98,8 +102,6 @@ mkDerivation rec {
   enableParallelBuilding = true;
 
   cmakeFlags = [
-    "-DLIBUSB_LIBRARIES=${libusb1.out}/lib"
-    "-DLIBUSB_INCLUDE_DIR=${libusb1.dev}/include/libusb-1.0"
     "-DENABLE_MYSQLSUPPORT=1"
     "-DENABLE_INTERNALMYSQL=1"
     "-DENABLE_MEDIAPLAYER=1"
diff --git a/pkgs/applications/misc/blender/default.nix b/pkgs/applications/misc/blender/default.nix
index 86b2ab6eb1ca..b348f253b350 100644
--- a/pkgs/applications/misc/blender/default.nix
+++ b/pkgs/applications/misc/blender/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, stdenv_gcc5, lib, fetchurl, boost, cmake, ffmpeg, gettext, glew
+{ stdenv, lib, fetchurl, boost, cmake, ffmpeg, gettext, glew
 , ilmbase, libXi, libX11, libXext, libXrender
 , libjpeg, libpng, libsamplerate, libsndfile
 , libtiff, mesa, openal, opencolorio, openexr, openimageio, openjpeg_1, python
@@ -10,7 +10,7 @@
 
 with lib;
 
-(if cudaSupport then stdenv_gcc5 else stdenv).mkDerivation rec {
+stdenv.mkDerivation rec {
   name = "blender-2.79";
 
   src = fetchurl {
@@ -57,9 +57,8 @@ with lib;
     ++ optional jackaudioSupport "-DWITH_JACK=ON"
     ++ optionals cudaSupport
       [ "-DWITH_CYCLES_CUDA_BINARIES=ON"
-        # Disable the sm_20 architecture to work around a segfault in
-        # ptxas, as suggested on #blendercoders.
-        "-DCYCLES_CUDA_BINARIES_ARCH=sm_21;sm_30;sm_35;sm_37;sm_50;sm_52;sm_60;sm_61"
+        # Disable architectures before sm_30 to support new CUDA toolkits.
+        "-DCYCLES_CUDA_BINARIES_ARCH=sm_30;sm_35;sm_37;sm_50;sm_52;sm_60;sm_61"
       ]
     ++ optional colladaSupport "-DWITH_OPENCOLLADA=ON";
 
diff --git a/pkgs/applications/misc/playonlinux/default.nix b/pkgs/applications/misc/playonlinux/default.nix
index b604905320b2..3f39a356312e 100644
--- a/pkgs/applications/misc/playonlinux/default.nix
+++ b/pkgs/applications/misc/playonlinux/default.nix
@@ -24,7 +24,7 @@
 assert stdenv.isLinux;
 
 let
-  version = "4.2.10";
+  version = "4.2.12";
 
   binpath = stdenv.lib.makeBinPath
     [ cabextract
@@ -57,7 +57,7 @@ in stdenv.mkDerivation {
 
   src = fetchurl {
     url = "https://www.playonlinux.com/script_files/PlayOnLinux/${version}/PlayOnLinux_${version}.tar.gz";
-    sha256 = "0ws94hgxajaww450q8ivrp28ypv39mashs29ak41faxf29cr097m";
+    sha256 = "03k8v9dknc5hfrfzqw1nkpifz7wkixv3mvjl1vnp4fx8rj2xrjrq";
   };
 
   nativeBuildInputs = [ makeWrapper ];
diff --git a/pkgs/applications/networking/browsers/tor-browser-bundle/extensions.nix b/pkgs/applications/networking/browsers/tor-browser-bundle/extensions.nix
index 53c278bc0650..86c2f53b9add 100644
--- a/pkgs/applications/networking/browsers/tor-browser-bundle/extensions.nix
+++ b/pkgs/applications/networking/browsers/tor-browser-bundle/extensions.nix
@@ -16,14 +16,14 @@
 {
   https-everywhere = stdenv.mkDerivation rec {
     name = "https-everywhere-${version}";
-    version = "2017.9.12";
+    version = "2017.10.4";
 
     extid = "https-everywhere-eff@eff.org";
 
     src = fetchgit {
       url = "https://git.torproject.org/https-everywhere.git";
       rev = "refs/tags/${version}";
-      sha256 = "179429pngyksp9xkr86nf2m5q6zmg19c7ng1dhqjfb1vsncwgw66";
+      sha256 = "1g7971xygnhagnb25xjdf6mli6091ai9igx42d0ww88g8i0cqfzj";
       fetchSubmodules = true; # for translations, TODO: remove
     };
 
@@ -47,13 +47,13 @@
 
   noscript = stdenv.mkDerivation rec {
     name = "noscript-${version}";
-    version = "5.0.10";
+    version = "5.1.2";
 
     extid = "{73a6fe31-595d-460b-a920-fcc0f8843232}";
 
     src = fetchurl {
       url = "https://secure.informaction.com/download/releases/noscript-${version}.xpi";
-      sha256 = "18k5karbaj5mhd9cyjbqgik6044bw88rjalkh6anjanxbn503j6g";
+      sha256 = "1fzspdiwhjabwz1yxb3gzj7giz9jbc1xxm65i93rvhzcp537cs42";
     };
 
     unpackPhase = ":";
@@ -88,14 +88,14 @@
 
   tor-launcher = stdenv.mkDerivation rec {
     name = "tor-launcher-${version}";
-    version = "0.2.12.3";
+    version = "0.2.13";
 
     extid = "tor-launcher@torproject.org";
 
     src = fetchgit {
       url = "https://git.torproject.org/tor-launcher.git";
       rev = "refs/tags/${version}";
-      sha256 = "0126x48pjiy2zm4l8jzhk70w24hviaz560ffp4lb9x0ar615bc9q";
+      sha256 = "1f98v88y2clwvjiw77kxqc9cacp5h0489a540nc2wmsx7vnskrq0";
     };
 
     nativeBuildInputs = [ zip ];
diff --git a/pkgs/applications/science/math/caffe/default.nix b/pkgs/applications/science/math/caffe/default.nix
index cb28d38bf1d0..8dc3e3ce43dc 100644
--- a/pkgs/applications/science/math/caffe/default.nix
+++ b/pkgs/applications/science/math/caffe/default.nix
@@ -22,22 +22,23 @@ assert pythonSupport -> (python != null && numpy != null);
 
 stdenv.mkDerivation rec {
   name = "caffe-${version}";
-  version = "1.0-rc5";
+  version = "1.0";
 
   src = fetchFromGitHub {
     owner = "BVLC";
     repo = "caffe";
-    rev = "rc5";
-    sha256 = "0lfmmc0n6xvkpygvxclzrvd0zigb4yfc5612anv2ahlxpfi9031c";
+    rev = version;
+    sha256 = "104jp3cm823i3cdph7hgsnj6l77ygbwsy35mdmzhmsi4jxprd9j3";
   };
 
   enableParallelBuilding = true;
 
   nativeBuildInputs = [ cmake doxygen ];
 
-  cmakeFlags = [ "-DCUDA_ARCH_NAME=All" ]
-               ++ lib.optional (!cudaSupport) "-DCPU_ONLY=ON"
-               ++ lib.optional (!pythonSupport) "-DBUILD_python=OFF";
+  cmakeFlags = [
+    "-DCUDA_ARCH_NAME=All"
+    (if pythonSupport then "-Dpython_version=${python.version}" else "-DBUILD_python=OFF")
+  ] ++ lib.optional (!cudaSupport) "-DCPU_ONLY=ON";
 
   buildInputs = [ boost google-gflags glog protobuf hdf5-cpp lmdb leveldb snappy opencv atlas ]
                 ++ lib.optional cudaSupport cudatoolkit
@@ -49,6 +50,16 @@ stdenv.mkDerivation rec {
   outputs = [ "bin" "out"];
   propagatedBuildOutputs = []; # otherwise propagates out -> bin cycle
 
+  preConfigure = lib.optionalString (cudaSupport && lib.versionAtLeast cudatoolkit.version "9.0") ''
+    # CUDA 9.0 doesn't support sm_20
+    sed -i 's,20 21(20) ,,' cmake/Cuda.cmake
+  '' + lib.optionalString (python.isPy3 or false) ''
+    sed -i \
+      -e 's,"python-py''${boost_py_version}",python3,g' \
+      -e 's,''${Boost_PYTHON-PY''${boost_py_version}_FOUND},''${Boost_PYTHON3_FOUND},g' \
+      cmake/Dependencies.cmake
+  '';
+
   postInstall = ''
     # Internal static library.
     rm $out/lib/libproto.a
diff --git a/pkgs/applications/science/math/cntk/default.nix b/pkgs/applications/science/math/cntk/default.nix
new file mode 100644
index 000000000000..80a5f6f032b7
--- /dev/null
+++ b/pkgs/applications/science/math/cntk/default.nix
@@ -0,0 +1,98 @@
+{ lib, stdenv, fetchgit, fetchFromGitHub, fetchpatch, cmake
+, openblas, opencv3, libzip, boost, protobuf, openmpi
+, onebitSGDSupport ? false
+, cudaSupport ? false, cudatoolkit, nvidia_x11
+, cudnnSupport ? false, cudnn
+}:
+
+assert cudnnSupport -> cudaSupport;
+
+let
+  # Old specific version required for CNTK.
+  cub = fetchFromGitHub {
+    owner = "NVlabs";
+    repo = "cub";
+    rev = "1.4.1";
+    sha256 = "1lcdwblz03c0yq1lxndg566kg14b5qm14x5qixjbmz6wq85kgmqc";
+  };
+
+in stdenv.mkDerivation rec {
+  name = "CNTK-${version}";
+  version = "2.2";
+
+  # Submodules
+  src = fetchgit {
+    url = "https://github.com/Microsoft/CNTK";
+    rev = "v${version}";
+    sha256 = "0q4knrwiyphb2fbqf9jzqvkz2jzj6jmbmang3lavdvsh7z0n8zz9";
+  };
+
+  patches = [
+    # Fix "'exp' was not declared"
+    (fetchpatch {
+      url = "https://github.com/imriss/CNTK/commit/ef1cca6df95cc507deb8471df2c0dd8cbfeef23b.patch";
+      sha256 = "0z7xyrxwric0c4h7rfs05f544mcq6d10wgs0vvfcyd2pcf410hy7";
+    })
+  ];
+
+  nativeBuildInputs = [ cmake ];
+
+  buildInputs = [ openblas opencv3 libzip boost protobuf openmpi ]
+             ++ lib.optional cudaSupport cudatoolkit
+             ++ lib.optional cudnnSupport cudnn;
+
+  configureFlags = [
+    "--with-opencv=${opencv3}"
+    "--with-libzip=${libzip.dev}"
+    "--with-openblas=${openblas}"
+    "--with-boost=${boost.dev}"
+    "--with-protobuf=${protobuf}"
+    "--with-mpi=${openmpi}"
+  ] ++ lib.optionals cudaSupport [
+    "--cuda=yes"
+    "--with-cuda=${cudatoolkit}"
+    "--with-gdk-include=${cudatoolkit}/include"
+    "--with-gdk-nvml-lib=${nvidia_x11}/lib"
+    "--with-cub=${cub}"
+  ] ++ lib.optional onebitSGDSupport "--1bitsgd=yes";
+
+  configurePhase = ''
+    sed -i \
+      -e 's,^GIT_STATUS=.*,GIT_STATUS=,' \
+      -e 's,^GIT_COMMIT=.*,GIT_COMMIT=v${version},' \
+      -e 's,^GIT_BRANCH=.*,GIT_BRANCH=v${version},' \
+      -e 's,^BUILDER=.*,BUILDER=nixbld,' \
+      -e 's,^BUILDMACHINE=.*,BUILDMACHINE=machine,' \
+      -e 's,^BUILDPATH=.*,BUILDPATH=/homeless-shelter,' \
+      -e '/git does not exist/d' \
+      Tools/generate_build_info
+
+    patchShebangs .
+    mkdir build
+    cd build
+    ${lib.optionalString cudnnSupport ''
+      mkdir cuda
+      ln -s ${cudnn}/include cuda
+      export configureFlags="$configureFlags --with-cudnn=$PWD"
+    ''}
+    ../configure $configureFlags
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    # Moving to make patchelf remove references later.
+    mv lib $out
+    cp bin/cntk $out/bin
+  '';
+
+  hardeningDisable = [ "format" ];
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    homepage = "https://github.com/Microsoft/CNTK";
+    description = "An open source deep-learning toolkit";
+    license = if onebitSGDSupport then licenses.unfreeRedistributable else licenses.mit;
+    maintainers = with maintainers; [ abbradar ];
+  };
+}
diff --git a/pkgs/applications/virtualization/lkl/default.nix b/pkgs/applications/virtualization/lkl/default.nix
index b790a15e607f..c62fa63ea594 100644
--- a/pkgs/applications/virtualization/lkl/default.nix
+++ b/pkgs/applications/virtualization/lkl/default.nix
@@ -1,8 +1,8 @@
 { stdenv, fetchFromGitHub, bc, python, fuse, libarchive }:
 
 stdenv.mkDerivation rec {
-  name = "lkl-2017-08-09";
-  rev  = "083cdeece0577635d523244dcf0da86074e23e4e";
+  name = "lkl-2017-10-18";
+  rev  = "bfb315c4612c38427e3239d0a427a125d9ba0ede";
 
   outputs = [ "dev" "lib" "out" ];
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
     inherit rev;
     owner  = "lkl";
     repo   = "linux";
-    sha256 = "1fyh0p54jgsqywswj40zbw64jbqx2w10wax1k3j2szzlhjrv9x1a";
+    sha256 = "172ccn2gsybnji7giiqq63bvp9nsw8kri88pjlvinwpwsv7x81aa";
   };
 
   # Fix a /usr/bin/env reference in here that breaks sandboxed builds
diff --git a/pkgs/development/compilers/cudatoolkit/default.nix b/pkgs/development/compilers/cudatoolkit/default.nix
index f6e52a59fe59..62b2e7c18508 100644
--- a/pkgs/development/compilers/cudatoolkit/default.nix
+++ b/pkgs/development/compilers/cudatoolkit/default.nix
@@ -1,30 +1,44 @@
-{ lib, stdenv, fetchurl, patchelf, perl, ncurses, expat, python27, zlib
+{ lib, stdenv, makeWrapper, fetchurl, requireFile, patchelf, perl, ncurses, expat, python27, zlib
+, gcc48, gcc49, gcc5, gcc6
 , xorg, gtk2, glib, fontconfig, freetype, unixODBC, alsaLib, glibc
 }:
 
 let
 
   common =
-    { version, url, sha256
+    args@{ gcc, version, sha256
+    , url ? ""
+    , name ? ""
+    , developerProgram ? false
     , python ? python27
     }:
 
     stdenv.mkDerivation rec {
       name = "cudatoolkit-${version}";
+      inherit (args) version;
 
       dontPatchELF = true;
       dontStrip = true;
 
       src =
-        if stdenv.system == "x86_64-linux" then
-          fetchurl {
-            inherit url sha256;
+        if developerProgram then
+          requireFile {
+            message = ''
+              This nix expression requires that ${args.name} is already part of the store.
+              Register yourself to NVIDIA Accelerated Computing Developer Program, retrieve the CUDA toolkit
+              at https://developer.nvidia.com/cuda-toolkit, and run the following command in the download directory:
+              nix-prefetch-url file://${args.name}
+            '';
+            inherit (args) name sha256;
           }
-        else throw "cudatoolkit does not support platform ${stdenv.system}";
+        else
+          fetchurl {
+            inherit (args) url sha256;
+          };
 
       outputs = [ "out" "lib" "doc" ];
 
-      buildInputs = [ perl ];
+      nativeBuildInputs = [ perl makeWrapper ];
 
       runtimeDependencies = [
         ncurses expat python zlib glibc
@@ -37,8 +51,8 @@ let
       unpackPhase = ''
         sh $src --keep --noexec
         cd pkg/run_files
-        sh cuda-linux64-rel-${version}-*.run --keep --noexec
-        sh cuda-samples-linux-${version}-*.run --keep --noexec
+        sh cuda-linux*.run --keep --noexec
+        sh cuda-samples*.run --keep --noexec
         cd pkg
       '';
 
@@ -92,15 +106,25 @@ let
         # Remove OpenCL libraries as they are provided by ocl-icd and driver.
         rm -f $out/lib64/libOpenCL*
 
+        # Set compiler for NVCC.
+        wrapProgram $out/bin/nvcc \
+          --prefix PATH : ${gcc}/bin
       '' + lib.optionalString (lib.versionOlder version "8.0") ''
         # Hack to fix building against recent Glibc/GCC.
         echo "NIX_CFLAGS_COMPILE+=' -D_FORCE_INLINES'" >> $out/nix-support/setup-hook
       '';
 
+      passthru = {
+        cc = gcc;
+        majorVersion =
+          let versionParts = lib.splitString "." version;
+          in "${lib.elemAt versionParts 0}.${lib.elemAt versionParts 1}";
+      };
+
       meta = with stdenv.lib; {
         description = "A compiler for NVIDIA GPUs, math libraries, and tools";
-        homepage = https://developer.nvidia.com/cuda-toolkit;
-        platforms = platforms.linux;
+        homepage = "https://developer.nvidia.com/cuda-toolkit";
+        platforms = [ "x86_64-linux" ];
         license = licenses.unfree;
       };
     };
@@ -109,32 +133,44 @@ in {
 
   cudatoolkit6 = common {
     version = "6.0.37";
-    url = http://developer.download.nvidia.com/compute/cuda/6_0/rel/installers/cuda_6.0.37_linux_64.run;
+    url = "http://developer.download.nvidia.com/compute/cuda/6_0/rel/installers/cuda_6.0.37_linux_64.run";
     sha256 = "991e436c7a6c94ec67cf44204d136adfef87baa3ded270544fa211179779bc40";
+    gcc = gcc48;
   };
 
   cudatoolkit65 = common {
     version = "6.5.19";
-    url = http://developer.download.nvidia.com/compute/cuda/6_5/rel/installers/cuda_6.5.19_linux_64.run;
+    url = "http://developer.download.nvidia.com/compute/cuda/6_5/rel/installers/cuda_6.5.19_linux_64.run";
     sha256 = "1x9zdmk8z784d3d35vr2ak1l4h5v4jfjhpxfi9fl9dvjkcavqyaj";
+    gcc = gcc48;
   };
 
   cudatoolkit7 = common {
     version = "7.0.28";
-    url = http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/cuda_7.0.28_linux.run;
+    url = "http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/cuda_7.0.28_linux.run";
     sha256 = "1km5hpiimx11jcazg0h3mjzk220klwahs2vfqhjavpds5ff2wafi";
+    gcc = gcc49;
   };
 
   cudatoolkit75 = common {
     version = "7.5.18";
-    url = http://developer.download.nvidia.com/compute/cuda/7.5/Prod/local_installers/cuda_7.5.18_linux.run;
+    url = "http://developer.download.nvidia.com/compute/cuda/7.5/Prod/local_installers/cuda_7.5.18_linux.run";
     sha256 = "1v2ylzp34ijyhcxyh5p6i0cwawwbbdhni2l5l4qm21s1cx9ish88";
+    gcc = gcc49;
   };
 
   cudatoolkit8 = common {
     version = "8.0.61";
-    url = https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run;
+    url = "https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run";
     sha256 = "1i4xrsqbad283qffvysn88w2pmxzxbbby41lw0j1113z771akv4w";
+    gcc = gcc5;
+  };
+
+  cudatoolkit9 = common {
+    version = "9.0.176";
+    url = "https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run";
+    sha256 = "0308rmmychxfa4inb1ird9bpgfppgr9yrfg1qp0val5azqik91ln";
+    gcc = gcc6;
   };
 
 }
diff --git a/pkgs/development/compilers/oraclejdk/jdk8cpu-linux.nix b/pkgs/development/compilers/oraclejdk/jdk8cpu-linux.nix
index 0d12b3ac89b0..f8f37160a26f 100644
--- a/pkgs/development/compilers/oraclejdk/jdk8cpu-linux.nix
+++ b/pkgs/development/compilers/oraclejdk/jdk8cpu-linux.nix
@@ -1,9 +1,9 @@
 import ./jdk-linux-base.nix {
   productVersion = "8";
-  patchVersion = "144";
+  patchVersion = "151";
   downloadUrl = http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html;
-  sha256_i686 = "1i5pginc65xl5vxzwid21ykakmfkqn59v3g01vpr94v28w30jk32";
-  sha256_x86_64 = "1r5axvr8dg2qmr4zjanj73sk9x50m7p0w3vddz8c6ckgav7438z8";
+  sha256_i686 = "0w1snn9hxwvdnk77frhdzbsm6v30v99dy5zmpy8ij7yxd57z6ql0";
+  sha256_x86_64 = "0zq2dxbxmshz080yskhc8y2wbqi0y0kl9girxjbb4rwk837010n7";
   sha256_armv7l = "10r3nyssx8piyjaspravwgj2bnq4537041pn0lz4fk5b3473kgfb";
   jceName = "jce_policy-8.zip";
   jceDownloadUrl = http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html;
diff --git a/pkgs/development/compilers/oraclejdk/jdk8psu-linux.nix b/pkgs/development/compilers/oraclejdk/jdk8psu-linux.nix
index 0d12b3ac89b0..863621bf6b07 100644
--- a/pkgs/development/compilers/oraclejdk/jdk8psu-linux.nix
+++ b/pkgs/development/compilers/oraclejdk/jdk8psu-linux.nix
@@ -1,9 +1,9 @@
 import ./jdk-linux-base.nix {
   productVersion = "8";
-  patchVersion = "144";
+  patchVersion = "152";
   downloadUrl = http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html;
-  sha256_i686 = "1i5pginc65xl5vxzwid21ykakmfkqn59v3g01vpr94v28w30jk32";
-  sha256_x86_64 = "1r5axvr8dg2qmr4zjanj73sk9x50m7p0w3vddz8c6ckgav7438z8";
+  sha256_i686 = "0gjc7kcfx40f43z1w1qsn1fqxdz8d46wml2g11qgm55ishhv2q7w";
+  sha256_x86_64 = "1gv1348hrgna9l3sssv3g9jzs37y1lkx05xq83chav9z1hs3p2r1";
   sha256_armv7l = "10r3nyssx8piyjaspravwgj2bnq4537041pn0lz4fk5b3473kgfb";
   jceName = "jce_policy-8.zip";
   jceDownloadUrl = http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html;
diff --git a/pkgs/development/compilers/oraclejdk/jdk9-linux.nix b/pkgs/development/compilers/oraclejdk/jdk9-linux.nix
index 7f0a5750c0e8..fbda96e14258 100644
--- a/pkgs/development/compilers/oraclejdk/jdk9-linux.nix
+++ b/pkgs/development/compilers/oraclejdk/jdk9-linux.nix
@@ -30,7 +30,7 @@ assert stdenv.system == "x86_64-linux";
 assert swingSupport -> xorg != null;
 
 let
-  version = "9";
+  version = "9.0.1";
 
   downloadUrlBase = http://www.oracle.com/technetwork/java/javase/downloads;
 
@@ -63,19 +63,19 @@ let result = stdenv.mkDerivation rec {
       requireFile {
         name = "jdk-${version}_linux-x64_bin.tar.gz";
         url =  "${downloadUrlBase}/jdk9-downloads-3848520.html";
-        sha256 = "0vbgy7h9h089l3xh6sl57v57g28x1djyiigqs4z6gh7wahx7hv8w";
+        sha256 = "0560dc3icrwb0ifykshvzkr04b1jr153m26x1r8rp0nhjbzz1nic";
       }
     else if packageType == "JRE" then
       requireFile {
         name = "jre-${version}_linux-x64_bin.tar.gz";
         url = "${downloadUrlBase}/jre9-downloads-3848532.html";
-        sha256 = "18i4jjb6sby67xg5ql6dkk3ja1nackbb23g1bnp522450nclpxdb";
+        sha256 = "11pfcck8am48yv7riaj10g6h79xdiy8lm5a9wjqbm3g9cls9ar1w";
       }
     else if packageType == "ServerJRE" then
       requireFile {
         name = "serverjre-${version}_linux-x64_bin.tar.gz";
         url = "${downloadUrlBase}/server-jre9-downloads-3848530.html";
-        sha256 = "01bxi7lx13lhlpbifw93b6r7a9bayiykw8kzwlyyqi8pz3pw8c5h";
+        sha256 = "1biyks6jy0a2kksaj9qbsjifv34ym5mdw8akibmkwr1xh0wavygc";
       }
     else abort "unknown package Type ${packageType}";
 
diff --git a/pkgs/development/compilers/tinycc/default.nix b/pkgs/development/compilers/tinycc/default.nix
index 4d6555213345..e88246ecb939 100644
--- a/pkgs/development/compilers/tinycc/default.nix
+++ b/pkgs/development/compilers/tinycc/default.nix
@@ -2,9 +2,9 @@
 with stdenv.lib;
 
 let
-  date = "20170924";
-  rev = "1443039416dd02750765efde1af35e31c8d41be3";
-  sha256 = "060l0f77hirq3i5bg294gxcszlvyn89ds2q21jwgy3ryrapfbl8i";
+  date = "20171016";
+  rev = "da8c62f75d893449e232944fc62566c020b4d010";
+  sha256 = "0pdvyhrx7g9imxpc7gr75116imi6ifn0ihsl4fbffsji2dpi61y2";
   version = "0.9.27pre-${date}";
 in
 
diff --git a/pkgs/development/coq-modules/flocq/default.nix b/pkgs/development/coq-modules/flocq/default.nix
index 30ec69ba6537..092337125a4d 100644
--- a/pkgs/development/coq-modules/flocq/default.nix
+++ b/pkgs/development/coq-modules/flocq/default.nix
@@ -3,11 +3,11 @@
 stdenv.mkDerivation rec {
 
   name = "coq${coq.coq-version}-flocq-${version}";
-  version = "2.5.2";
+  version = "2.6.0";
 
   src = fetchurl {
-    url = https://gforge.inria.fr/frs/download.php/file/36199/flocq-2.5.2.tar.gz;
-    sha256 = "0h5mlasirfzc0wwn2isg4kahk384n73145akkpinrxq5jsn5d22h";
+    url = https://gforge.inria.fr/frs/download.php/file/37054/flocq-2.6.0.tar.gz;
+    sha256 = "13fv150dcwnjrk00d7zj2c5x9jwmxgrq0ay440gkr730l8mvk3l3";
   };
 
   buildInputs = [ coq.ocaml coq.camlp5 bash which autoconf automake ];
diff --git a/pkgs/development/libraries/boost/1.65.nix b/pkgs/development/libraries/boost/1.65.nix
new file mode 100644
index 000000000000..9837e1c69193
--- /dev/null
+++ b/pkgs/development/libraries/boost/1.65.nix
@@ -0,0 +1,12 @@
+{ stdenv, callPackage, fetchurl, ... } @ args:
+
+callPackage ./generic.nix (args // rec {
+  version = "1.65.1";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/boost/boost_1_65_1.tar.bz2";
+    # SHA256 from http://www.boost.org/users/history/version_1_65_1.html
+    sha256 = "9807a5d16566c57fd74fb522764e0b134a8bbe6b6e8967b83afefd30dcd3be81";
+  };
+
+})
diff --git a/pkgs/development/libraries/boost/generic.nix b/pkgs/development/libraries/boost/generic.nix
index 22ef02023f88..3f9ae113f849 100644
--- a/pkgs/development/libraries/boost/generic.nix
+++ b/pkgs/development/libraries/boost/generic.nix
@@ -9,6 +9,8 @@
 , enableStatic ? !enableShared
 , enablePIC ? false
 , enableExceptions ? false
+, enablePython ? hostPlatform == buildPlatform
+, enableNumpy ? false, numpy ? null
 , taggedLayout ? ((enableRelease && enableDebug) || (enableSingleThreaded && enableMultiThreaded) || (enableShared && enableStatic))
 , patches ? null
 , mpi ? null
@@ -21,6 +23,9 @@
 # We must build at least one type of libraries
 assert !enableShared -> enableStatic;
 
+assert enablePython -> hostPlatform == buildPlatform;
+assert enableNumpy -> enablePython;
+
 with stdenv.lib;
 let
 
@@ -62,7 +67,8 @@ let
   ] ++ optional (link != "static") "runtime-link=${runtime-link}" ++ [
     "link=${link}"
     "${cflags}"
-  ] ++ optional (variant == "release") "debug-symbols=off";
+  ] ++ optional (variant == "release") "debug-symbols=off"
+    ++ optional (!enablePython) "--without-python";
 
   nativeB2Flags = [
     "-sEXPAT_INCLUDE=${expat.dev}/include"
@@ -76,7 +82,6 @@ let
     "-sEXPAT_LIBPATH=${expat.crossDrv}/lib"
     "--user-config=user-config.jam"
     "toolset=gcc-cross"
-    "--without-python"
   ] ++ optionals (hostPlatform.libc == "msvcrt") [
     "target-os=windows"
     "threadapi=win32"
@@ -148,8 +153,10 @@ stdenv.mkDerivation {
   enableParallelBuilding = true;
 
   buildInputs = [ expat zlib bzip2 libiconv ]
-    ++ stdenv.lib.optionals (hostPlatform == buildPlatform) [ python icu ]
-    ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
+    ++ optional (hostPlatform == buildPlatform) icu
+    ++ optional stdenv.isDarwin fixDarwinDylibNames
+    ++ optional enablePython python
+    ++ optional enableNumpy numpy;
 
   configureScript = "./bootstrap.sh";
   configureFlags = commonConfigureFlags
diff --git a/pkgs/development/libraries/libdrm/default.nix b/pkgs/development/libraries/libdrm/default.nix
index 4903d8e66dfe..992b1ea70dca 100644
--- a/pkgs/development/libraries/libdrm/default.nix
+++ b/pkgs/development/libraries/libdrm/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, pkgconfig, libpthreadstubs, libpciaccess, valgrind-light }:
 
 stdenv.mkDerivation rec {
-  name = "libdrm-2.4.83";
+  name = "libdrm-2.4.84";
 
   src = fetchurl {
     url = "http://dri.freedesktop.org/libdrm/${name}.tar.bz2";
-    sha256 = "1minzvsyz5hgm6ixpj8ysa6jsv7vm8qc8nx390jxdsk0v9ljd983";
+    sha256 = "7ae9c24d91139ac9a2cdee06fe46dbe1c401a1eda1c0bd2a6d1ecf72f479e0aa";
   };
 
   outputs = [ "out" "dev" "bin" ];
diff --git a/pkgs/development/libraries/libqtav/default.nix b/pkgs/development/libraries/libqtav/default.nix
index a79e6d903842..93d8ced49cea 100644
--- a/pkgs/development/libraries/libqtav/default.nix
+++ b/pkgs/development/libraries/libqtav/default.nix
@@ -9,13 +9,10 @@ with lib;
 
 mkDerivation rec {
   name = "libqtav-${version}";
-
-  # Awaiting upcoming `v1.12.0` release. `v1.11.0` is not supporting cmake which is the
-  # the reason behind taking an unstable git rev. 
-  version = "unstable-2017-03-30";
+  version = "1.12.0";
 
   nativeBuildInputs = [ extra-cmake-modules qttools ];
-  buildInputs = [ 
+  buildInputs = [
     qtbase qtmultimedia qtquick1
     mesa libX11
     libass openal ffmpeg libuchardet
@@ -23,18 +20,13 @@ mkDerivation rec {
   ];
 
   src = fetchFromGitHub {
-    sha256 = "1xw0ynm9w501651rna3ppf8p336ag1p60i9dxhghzm543l7as93v";
-    rev = "4b4ae3b470b2fcbbcf1b541c2537fb270ee0bcfa";
+    sha256 = "03ii9l38l3fsr27g42fx4151ipzkip2kr4akdr8x28sx5r9rr5m2";
+    rev = "v${version}";
     repo = "QtAV";
     owner = "wang-bin";
     fetchSubmodules = true;
   };
 
-  patchPhase = ''
-    sed -i -e 's#CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT#TRUE#g' ./CMakeLists.txt
-    sed -i -e 's#DESTINATION ''${QT_INSTALL_LIBS}/cmake#DESTINATION ''${QTAV_INSTALL_LIBS}/cmake#g' ./CMakeLists.txt
-  '';
-
   # Make sure libqtav finds its libGL dependancy at both link and run time
   # by adding mesa to rpath. Not sure why it wasn't done automatically like
   # the other libraries as `mesa` is part of our `buildInputs`.
diff --git a/pkgs/development/libraries/libtorrent-rasterbar/1.0.nix b/pkgs/development/libraries/libtorrent-rasterbar/1.0.nix
index 877d8ed434c6..fbd30ac04f76 100644
--- a/pkgs/development/libraries/libtorrent-rasterbar/1.0.nix
+++ b/pkgs/development/libraries/libtorrent-rasterbar/1.0.nix
@@ -1,6 +1,13 @@
-{ callPackage, ... } @ args:
+args@{ callPackage, fetchpatch, ... }:
 
-callPackage ./generic.nix (args // {
+callPackage (import ./generic.nix {
   version = "1.0.11";
   sha256 = "17p34d3n29q04pvz975gfl1fyj3sg9cl5l6j673xqfq3fpyis58i";
-})
+  patches = [
+    # Compatibility with new Boost
+    (fetchpatch {
+      url = "https://github.com/arvidn/libtorrent/commit/7eb3cf6bc6dbada3fa7bb7ff4d5981182813a0e2.patch";
+      sha256 = "07agbrii6i8q4wmgpqbln7ldhhadaf5npcinvi6hnyipsr48jbj5";
+    })
+  ];
+}) args
diff --git a/pkgs/development/libraries/libtorrent-rasterbar/default.nix b/pkgs/development/libraries/libtorrent-rasterbar/default.nix
index ed52902938db..ff5027fd472e 100644
--- a/pkgs/development/libraries/libtorrent-rasterbar/default.nix
+++ b/pkgs/development/libraries/libtorrent-rasterbar/default.nix
@@ -1,6 +1,6 @@
-{ callPackage, ... } @ args:
+args@{ callPackage, ... }:
 
-callPackage ./generic.nix (args // {
-  version = "1.1.4";
-  sha256 = "1rrp4b7zfz0fnjvax2r9r5rrh6z1s4xqb9dx20gzr4gs8x5v5jws";
-})
+callPackage (import ./generic.nix {
+  version = "1.1.5";
+  sha256 = "1ifpcqw5mj2dwk23lhc2vpb47mg3j573v5z4zp8dkczpz7wg5jxq";
+}) args
diff --git a/pkgs/development/libraries/libtorrent-rasterbar/generic.nix b/pkgs/development/libraries/libtorrent-rasterbar/generic.nix
index 351ec3e77331..315385cba6c8 100644
--- a/pkgs/development/libraries/libtorrent-rasterbar/generic.nix
+++ b/pkgs/development/libraries/libtorrent-rasterbar/generic.nix
@@ -1,7 +1,7 @@
-{ stdenv, fetchurl, automake, autoconf, boost, openssl, lib, libtool, pkgconfig, zlib, python, libiconv, geoip
 # Version specific options
-, version, sha256
-, ... }:
+{ version, sha256, patches ? [] }:
+
+{ stdenv, fetchurl, automake, autoconf, boost, openssl, lib, libtool, pkgconfig, zlib, python, libiconv, geoip, ... }:
 
 let formattedVersion = lib.replaceChars ["."] ["_"] version;
 
@@ -15,6 +15,8 @@ stdenv.mkDerivation rec {
     inherit sha256;
   };
 
+  inherit patches;
+
   nativeBuildInputs = [ automake autoconf libtool pkgconfig ];
   buildInputs = [ boost openssl zlib python libiconv geoip ];
 
diff --git a/pkgs/development/libraries/opencv/3.x.nix b/pkgs/development/libraries/opencv/3.x.nix
index 8596ab6de88f..ecb7bf78b206 100644
--- a/pkgs/development/libraries/opencv/3.x.nix
+++ b/pkgs/development/libraries/opencv/3.x.nix
@@ -16,7 +16,7 @@
 , enableGStreamer ? false, gst_all_1
 , enableEigen     ? true, eigen
 , enableOpenblas  ? true, openblas
-, enableCuda      ? false, cudatoolkit, gcc5
+, enableCuda      ? false, cudatoolkit
 , enableTesseract ? false, tesseract, leptonica
 , AVFoundation, Cocoa, QTKit
 }:
@@ -145,7 +145,7 @@ stdenv.mkDerivation rec {
     # simply enabled automatically if contrib is built, and it detects
     # tesseract & leptonica.
     ++ lib.optionals enableTesseract [ tesseract leptonica ]
-    ++ lib.optionals enableCuda [ cudatoolkit gcc5 ]
+    ++ lib.optional enableCuda cudatoolkit
     ++ lib.optional buildContrib protobuf
     ++ lib.optionals stdenv.isDarwin [ AVFoundation Cocoa QTKit ];
 
@@ -165,8 +165,10 @@ stdenv.mkDerivation rec {
     (opencvFlag "OPENEXR" enableEXR)
     (opencvFlag "CUDA" enableCuda)
     (opencvFlag "CUBLAS" enableCuda)
-  ] ++ lib.optionals enableCuda [ "-DCUDA_FAST_MATH=ON" ]
-    ++ lib.optional buildContrib "-DBUILD_PROTOBUF=off"
+  ] ++ lib.optionals enableCuda [
+    "-DCUDA_FAST_MATH=ON"
+    "-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/gcc"
+  ] ++ lib.optional buildContrib "-DBUILD_PROTOBUF=off"
     ++ lib.optionals stdenv.isDarwin ["-DWITH_OPENCL=OFF" "-DWITH_LAPACK=OFF"];
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/opensubdiv/default.nix b/pkgs/development/libraries/opensubdiv/default.nix
index 442a8444942a..91899ad8da43 100644
--- a/pkgs/development/libraries/opensubdiv/default.nix
+++ b/pkgs/development/libraries/opensubdiv/default.nix
@@ -1,17 +1,17 @@
-{ lib, stdenv, stdenv_gcc5, fetchurl, fetchFromGitHub, cmake, pkgconfig, xorg, mesa_glu
+{ lib, stdenv, fetchurl, fetchFromGitHub, cmake, pkgconfig, xorg, mesa_glu
 , mesa_noglu, glew, ocl-icd, python3
 , cudaSupport ? false, cudatoolkit
 }:
 
-(if cudaSupport then stdenv_gcc5 else stdenv).mkDerivation rec {
+stdenv.mkDerivation rec {
   name = "opensubdiv-${version}";
-  version = "3.2.0";
+  version = "3.3.0";
 
   src = fetchFromGitHub {
     owner = "PixarAnimationStudios";
     repo = "OpenSubdiv";
     rev = "v${lib.replaceChars ["."] ["_"] version}";
-    sha256 = "0wk12n1s8za3sz8d6bmfm3rfjyx20j48gy1xp57dvbnjvlvzqy3w";
+    sha256 = "0wpjwfik4q9s4r30hndhzmfyzv968mmg5lgng0123l07mn47d2yl";
   };
 
   outputs = [ "out" "dev" ];
@@ -30,7 +30,7 @@
       "-DNO_EXAMPLES=1"
       "-DGLEW_INCLUDE_DIR=${glew.dev}/include"
       "-DGLEW_LIBRARY=${glew.dev}/lib"
-    ];
+    ] ++ lib.optional cudaSupport "-DOSD_CUDA_NVCC_FLAGS=--gpu-architecture=compute_30";
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/science/math/clblas/cuda/default.nix b/pkgs/development/libraries/science/math/clblas/cuda/default.nix
deleted file mode 100644
index ae568bc6db17..000000000000
--- a/pkgs/development/libraries/science/math/clblas/cuda/default.nix
+++ /dev/null
@@ -1,73 +0,0 @@
-{ stdenv
-, fetchFromGitHub
-, cmake
-, gfortran
-, blas
-, boost
-, python
-, ocl-icd
-, cudatoolkit
-, nvidia_x11
-, gtest
-}:
-
-stdenv.mkDerivation rec {
-  name = "clblas-cuda-${version}"; 
-  version = "git-20160505"; 
-
-  src = fetchFromGitHub {
-    owner = "clMathLibraries"; 
-    repo = "clBLAS";
-    rev = "d20977ec4389c6b3751e318779410007c5e272f8";
-    sha256 = "1jna176cxznv7iz43svd6cjrbbf0fc2lrbpfpg4s08vc7xnwp0n4";
-  }; 
-
-  patches = [ ./platform.patch ]; 
-
-  postPatch = ''
-    sed -i -re 's/(set\(\s*Boost_USE_STATIC_LIBS\s+).*/\1OFF\ \)/g' src/CMakeLists.txt
-  '';
-
-  configurePhase = ''
-    findInputs ${boost.dev} boost_dirs propagated-native-build-inputs
-
-    export BOOST_INCLUDEDIR=$(echo $boost_dirs | sed -e s/\ /\\n/g - | grep '\-dev')/include
-    export BOOST_LIBRARYDIR=$(echo $boost_dirs | sed -e s/\ /\\n/g - | grep -v '\-dev')/lib
-
-    mkdir -p Build
-    pushd Build
-
-    export LD_LIBRARY_PATH="${stdenv.lib.makeLibraryPath [ blas nvidia_x11 ]}"
-
-    cmake ../src -DCMAKE_INSTALL_PREFIX=$out \
-                 -DCMAKE_BUILD_TYPE=Release \
-                 -DOPENCL_ROOT=${cudatoolkit} \
-                 -DUSE_SYSTEM_GTEST=ON
-  '';
-
-  dontStrip = true; 
-
-  buildInputs = [
-    cmake
-    gfortran
-    blas
-    python
-    ocl-icd
-    cudatoolkit
-    nvidia_x11
-    gtest
-  ]; 
-
-  meta = with stdenv.lib; {
-    homepage = https://github.com/clMathLibraries/clBLAS;
-    description = "A software library containing BLAS functions written in OpenCL";
-    longDescription = ''
-      This package contains a library of BLAS functions on top of OpenCL. 
-      The current version is linked to the NVIDIA OpenCL implementation provided by the CUDA toolkit. 
-    '';
-    license = licenses.asl20;
-    maintainers = with maintainers; [ artuuge ];
-    platforms = platforms.linux;
-  };
-
-}
diff --git a/pkgs/development/libraries/science/math/clblas/default.nix b/pkgs/development/libraries/science/math/clblas/default.nix
new file mode 100644
index 000000000000..40b02d303417
--- /dev/null
+++ b/pkgs/development/libraries/science/math/clblas/default.nix
@@ -0,0 +1,62 @@
+{ stdenv
+, fetchFromGitHub
+, cmake
+, gfortran
+, blas
+, boost
+, python
+, ocl-icd
+, opencl-headers
+, gtest
+}:
+
+stdenv.mkDerivation rec {
+  name = "clblas-${version}"; 
+  version = "2.12";
+
+  src = fetchFromGitHub {
+    owner = "clMathLibraries"; 
+    repo = "clBLAS";
+    rev = "v${version}";
+    sha256 = "154mz52r5hm0jrp5fqrirzzbki14c1jkacj75flplnykbl36ibjs";
+  }; 
+
+  patches = [ ./platform.patch ]; 
+
+  postPatch = ''
+    sed -i -re 's/(set\(\s*Boost_USE_STATIC_LIBS\s+).*/\1OFF\ \)/g' src/CMakeLists.txt
+  '';
+
+  preConfigure = ''
+    cd src
+  '';
+
+  cmakeFlags = [
+    "-DUSE_SYSTEM_GTEST=ON"
+  ];
+
+  buildInputs = [
+    cmake
+    gfortran
+    blas
+    python
+    ocl-icd
+    opencl-headers
+    boost
+    gtest
+  ]; 
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/clMathLibraries/clBLAS";
+    description = "A software library containing BLAS functions written in OpenCL";
+    longDescription = ''
+      This package contains a library of BLAS functions on top of OpenCL. 
+    '';
+    license = licenses.asl20;
+    maintainers = with maintainers; [ artuuge ];
+    platforms = platforms.linux;
+  };
+
+}
diff --git a/pkgs/development/libraries/science/math/clblas/cuda/platform.patch b/pkgs/development/libraries/science/math/clblas/platform.patch
index 87404a426a4b..87404a426a4b 100644
--- a/pkgs/development/libraries/science/math/clblas/cuda/platform.patch
+++ b/pkgs/development/libraries/science/math/clblas/platform.patch
diff --git a/pkgs/development/libraries/science/math/cudnn/7.5-5.0/default.nix b/pkgs/development/libraries/science/math/cudnn/7.5-5.0/default.nix
deleted file mode 100644
index 2e0b98496f3c..000000000000
--- a/pkgs/development/libraries/science/math/cudnn/7.5-5.0/default.nix
+++ /dev/null
@@ -1,46 +0,0 @@
-{ stdenv
-, requireFile
-, cudatoolkit
-}:
-
-stdenv.mkDerivation rec {
-  version = "5.0";
-  cudatoolkit_version = "7.5";
-
-  name = "cudatoolkit-${cudatoolkit_version}-cudnn-${version}";
-
-  src = requireFile rec {
-    name = "cudnn-${cudatoolkit_version}-linux-x64-v${version}-ga.tgz";
-    message = ''
-      This nix expression requires that ${name} is already part of the store.
-      Register yourself to NVIDIA Accelerated Computing Developer Program, retrieve the cuDNN library
-      at https://developer.nvidia.com/cudnn, and run the following command in the download directory:
-      nix-prefetch-url file://${name}
-    '';
-    sha256 = "c4739a00608c3b66a004a74fc8e721848f9112c5cb15f730c1be4964b3a23b3a";
-  };
-
-  phases = "unpackPhase installPhase fixupPhase";
-
-  installPhase = ''
-    function fixRunPath {
-      p=$(patchelf --print-rpath $1)
-      patchelf --set-rpath "$p:${stdenv.lib.makeLibraryPath [ stdenv.cc.cc ]}" $1
-    }
-    fixRunPath lib64/libcudnn.so
-
-    mkdir -p $out
-    cp -a include $out/include
-    cp -a lib64 $out/lib64
-  '';
-
-  propagatedBuildInputs = [
-    cudatoolkit
-  ];
-
-  meta = {
-    description = "NVIDIA CUDA Deep Neural Network library (cuDNN)";
-    homepage = https://developer.nvidia.com/cudnn;
-    license = stdenv.lib.licenses.unfree;
-  };
-}
diff --git a/pkgs/development/libraries/science/math/cudnn/8.0-5.1/default.nix b/pkgs/development/libraries/science/math/cudnn/8.0-5.1/default.nix
deleted file mode 100644
index fd98001da82b..000000000000
--- a/pkgs/development/libraries/science/math/cudnn/8.0-5.1/default.nix
+++ /dev/null
@@ -1,40 +0,0 @@
-{ stdenv
-, requireFile
-, cudatoolkit
-, fetchurl
-}:
-
-stdenv.mkDerivation rec {
-  version = "5.1";
-  cudatoolkit_version = "8.0";
-
-  name = "cudatoolkit-${cudatoolkit_version}-cudnn-${version}";
-
-  src = fetchurl {
-    url = "http://developer.download.nvidia.com/compute/redist/cudnn/v5.1/cudnn-8.0-linux-x64-v5.1.tgz";
-    sha256 = "1kj50smlkm347wfbfqvy09ylvad1zapqjc9yqvfykmiddyrij1y1";
-  };
-
-  installPhase = ''
-    function fixRunPath {
-      p=$(patchelf --print-rpath $1)
-      patchelf --set-rpath "$p:${stdenv.lib.makeLibraryPath [ stdenv.cc.cc ]}" $1
-    }
-    fixRunPath lib64/libcudnn.so
-
-    mkdir -p $out
-    cp -a include $out/include
-    cp -a lib64 $out/lib64
-  '';
-
-  propagatedBuildInputs = [
-    cudatoolkit
-  ];
-
-  meta = with stdenv.lib; {
-    description = "NVIDIA CUDA Deep Neural Network library (cuDNN)";
-    homepage = https://developer.nvidia.com/cudnn;
-    license = stdenv.lib.licenses.unfree;
-    maintainers = with maintainers; [ mdaiter ];
-  };
-}
diff --git a/pkgs/development/libraries/science/math/cudnn/8.0-6.0/default.nix b/pkgs/development/libraries/science/math/cudnn/8.0-6.0/default.nix
deleted file mode 100644
index f0cfb906b1fe..000000000000
--- a/pkgs/development/libraries/science/math/cudnn/8.0-6.0/default.nix
+++ /dev/null
@@ -1,40 +0,0 @@
-{ stdenv
-, requireFile
-, cudatoolkit
-, fetchurl
-}:
-
-stdenv.mkDerivation rec {
-  version = "6.0";
-  cudatoolkit_version = "8.0";
-
-  name = "cudatoolkit-${cudatoolkit_version}-cudnn-${version}";
-
-  src = fetchurl {
-    url = "http://developer.download.nvidia.com/compute/redist/cudnn/v6.0/cudnn-8.0-linux-x64-v6.0.tgz";
-    sha256 = "173zpgrk55ri8if7s5yngsc89ajd6hz4pss4cdxlv6lcyh5122cv";
-  };
-
-  installPhase = ''
-    function fixRunPath {
-      p=$(patchelf --print-rpath $1)
-      patchelf --set-rpath "$p:${stdenv.lib.makeLibraryPath [ stdenv.cc.cc ]}" $1
-    }
-    fixRunPath lib64/libcudnn.so
-
-    mkdir -p $out
-    cp -a include $out/include
-    cp -a lib64 $out/lib64
-  '';
-
-  propagatedBuildInputs = [
-    cudatoolkit
-  ];
-
-  meta = with stdenv.lib; {
-    description = "NVIDIA CUDA Deep Neural Network library (cuDNN)";
-    homepage = https://developer.nvidia.com/cudnn;
-    license = stdenv.lib.licenses.unfree;
-    maintainers = with maintainers; [ jyp ];
-  };
-}
diff --git a/pkgs/development/libraries/science/math/cudnn/default.nix b/pkgs/development/libraries/science/math/cudnn/default.nix
index 1e1a37af2f0e..db66d8545883 100644
--- a/pkgs/development/libraries/science/math/cudnn/default.nix
+++ b/pkgs/development/libraries/science/math/cudnn/default.nix
@@ -1,34 +1,45 @@
-{ stdenv, requireFile, cudatoolkit }:
+{ callPackage, cudatoolkit7, cudatoolkit75, cudatoolkit8, cudatoolkit9 }:
 
-stdenv.mkDerivation rec {
-  version = "4.0";
+let
+  generic = args: callPackage (import ./generic.nix (removeAttrs args ["cudatoolkit"])) {
+    inherit (args) cudatoolkit;
+  };
 
-  name = "cudnn-${version}";
+in
 
-  src = requireFile rec {
-    name = "cudnn-7.0-linux-x64-v${version}-prod.tgz";
-    message = '' 
-      This nix expression requires that ${name} is
-      already part of the store. Register yourself to NVIDIA Accelerated Computing Developer Program
-      and download cuDNN library at https://developer.nvidia.com/cudnn, and store it to the nix store with nix-store --add-fixed sha256 <FILE>.
-    '';
+{
+  cudnn_cudatoolkit7 = generic rec {
+    version = "4.0";
+    cudatoolkit = cudatoolkit7;
+    srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v${version}-prod.tgz";
     sha256 = "0zgr6qdbc29qw6sikhrh6diwwz7150rqc8a49f2qf37j2rvyyr2f";
-
   };
 
-  phases = "unpackPhase installPhase fixupPhase";
+  cudnn_cudatoolkit75 = generic rec {
+    version = "6.0";
+    cudatoolkit = cudatoolkit75;
+    srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v${version}.tgz";
+    sha256 = "0b68hv8pqcvh7z8xlgm4cxr9rfbjs0yvg1xj2n5ap4az1h3lp3an";
+  };
 
-  propagatedBuildInputs = [ cudatoolkit ];
+  cudnn6_cudatoolkit8 = generic rec {
+    version = "6.0";
+    cudatoolkit = cudatoolkit8;
+    srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v${version}.tgz";
+    sha256 = "173zpgrk55ri8if7s5yngsc89ajd6hz4pss4cdxlv6lcyh5122cv";
+  };
 
-  installPhase = ''
-    mkdir -p $out
-    cp -a include $out/include
-    cp -a lib64 $out/lib64
-  '';
+  cudnn_cudatoolkit8 = generic rec {
+    version = "7.0";
+    cudatoolkit = cudatoolkit8;
+    srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v7.tgz";
+    sha256 = "19yjdslrslwv5ic4vgpzb0fa0mqbgi6a66b7gc66vdc9n9589398";
+  };
 
-  meta = {
-    description = "NVIDIA CUDA Deep Neural Network library (cuDNN)";
-    homepage = https://developer.nvidia.com/cudnn;
-    license = stdenv.lib.licenses.unfree;
+  cudnn_cudatoolkit9 = generic rec {
+    version = "7.0";
+    cudatoolkit = cudatoolkit9;
+    srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v7.tgz";
+    sha256 = "1ld5x819vya6p2ppmr7i3lz9ac2y81kssgbzgd0lsign7r2qjapc";
   };
 }
diff --git a/pkgs/development/libraries/science/math/cudnn/8.0-5.0/default.nix b/pkgs/development/libraries/science/math/cudnn/generic.nix
index a0d8baae78fd..663b741e4748 100644
--- a/pkgs/development/libraries/science/math/cudnn/8.0-5.0/default.nix
+++ b/pkgs/development/libraries/science/math/cudnn/generic.nix
@@ -1,29 +1,34 @@
+{ version
+, srcName
+, sha256
+}:
+
 { stdenv
+, lib
 , requireFile
 , cudatoolkit
 }:
 
 stdenv.mkDerivation rec {
-  version = "5.0";
-  cudatoolkit_version = "8.0";
+  name = "cudatoolkit-${cudatoolkit.majorVersion}-cudnn-${version}";
 
-  name = "cudatoolkit-${cudatoolkit_version}-cudnn-${version}";
+  inherit version;
 
   src = requireFile rec {
-    name = "cudnn-${cudatoolkit_version}-linux-x64-v${version}-ga.tgz";
+    name = srcName;
+    inherit sha256;
     message = ''
       This nix expression requires that ${name} is already part of the store.
       Register yourself to NVIDIA Accelerated Computing Developer Program, retrieve the cuDNN library
       at https://developer.nvidia.com/cudnn, and run the following command in the download directory:
       nix-prefetch-url file://${name}
     '';
-    sha256 = "af80eb1ce0cb51e6a734b2bdc599e6d50b676eab3921e5bddfe5443485df86b6";
   };
 
   installPhase = ''
     function fixRunPath {
       p=$(patchelf --print-rpath $1)
-      patchelf --set-rpath "$p:${stdenv.lib.makeLibraryPath [ stdenv.cc.cc ]}" $1
+      patchelf --set-rpath "$p:${lib.makeLibraryPath [ stdenv.cc.cc ]}" $1
     }
     fixRunPath lib64/libcudnn.so
 
@@ -36,10 +41,16 @@ stdenv.mkDerivation rec {
     cudatoolkit
   ];
 
+  passthru = {
+    inherit cudatoolkit;
+    majorVersion = lib.head (lib.splitString "." version);
+  };
+
   meta = with stdenv.lib; {
     description = "NVIDIA CUDA Deep Neural Network library (cuDNN)";
-    homepage = https://developer.nvidia.com/cudnn;
-    license = stdenv.lib.licenses.unfree;
+    homepage = "https://developer.nvidia.com/cudnn";
+    license = licenses.unfree;
+    platforms = [ "x86_64-linux" ];
     maintainers = with maintainers; [ mdaiter ];
   };
 }
diff --git a/pkgs/development/ocaml-modules/lablgtk/default.nix b/pkgs/development/ocaml-modules/lablgtk/default.nix
index d6e56126018c..9d01b73479a4 100644
--- a/pkgs/development/ocaml-modules/lablgtk/default.nix
+++ b/pkgs/development/ocaml-modules/lablgtk/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, ocaml, findlib, pkgconfig, gtk2, libgnomecanvas, libglade, gtksourceview, camlp4}:
+{ stdenv, fetchurl, ocaml, findlib, pkgconfig, gtk2, libgnomecanvas, libglade, gtksourceview }:
 
 let
   pname = "lablgtk";
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ocaml findlib gtk2 libgnomecanvas libglade gtksourceview camlp4];
+  buildInputs = [ ocaml findlib gtk2 libgnomecanvas libglade gtksourceview ];
 
   configureFlags = "--with-libdir=$(out)/lib/ocaml/${ocaml.version}/site-lib";
   buildFlags = "world";
diff --git a/pkgs/development/ocaml-modules/ocamlgraph/default.nix b/pkgs/development/ocaml-modules/ocamlgraph/default.nix
index f6379c8b5a75..e005024d2225 100644
--- a/pkgs/development/ocaml-modules/ocamlgraph/default.nix
+++ b/pkgs/development/ocaml-modules/ocamlgraph/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "ocamlgraph-${version}";
-  version = "1.8.7";
+  version = "1.8.8";
 
   src = fetchurl {
     url = "http://ocamlgraph.lri.fr/download/ocamlgraph-${version}.tar.gz";
-    sha256 = "1845r537swjil2fcj7lgbibc2zybfwqqasrd2s7bncajs83cl1nz";
+    sha256 = "0m9g16wrrr86gw4fz2fazrh8nkqms0n863w7ndcvrmyafgxvxsnr";
   };
 
   buildInputs = [ ocaml findlib lablgtk ];
diff --git a/pkgs/development/python-modules/Theano/default.nix b/pkgs/development/python-modules/Theano/default.nix
new file mode 100644
index 000000000000..e0ff839ce1b7
--- /dev/null
+++ b/pkgs/development/python-modules/Theano/default.nix
@@ -0,0 +1,75 @@
+{ stdenv
+, lib
+, fetchPypi
+, gcc
+, writeScriptBin
+, buildPythonPackage
+, isPyPy
+, pythonOlder
+, isPy3k
+, nose
+, numpy
+, pydot_ng
+, scipy
+, six
+, libgpuarray
+, cudaSupport ? false, cudatoolkit
+, cudnnSupport ? false, cudnn
+}:
+
+assert cudnnSupport -> cudaSupport;
+
+let
+  extraFlags =
+    lib.optionals cudaSupport [ "-I ${cudatoolkit}/include" "-L ${cudatoolkit}/lib" ]
+    ++ lib.optionals cudnnSupport [ "-I ${cudnn}/include" "-L ${cudnn}/lib" ];
+
+  gcc_ = writeScriptBin "g++" ''
+    #!${stdenv.shell}
+    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE ${toString extraFlags}"
+    exec ${gcc}/bin/g++ "$@"
+  '';
+
+  libgpuarray_ = libgpuarray.override { inherit cudaSupport; };
+
+in buildPythonPackage rec {
+  name = "${pname}-${version}";
+  pname = "Theano";
+  version = "0.9.0";
+
+  disabled = isPyPy || pythonOlder "2.6" || (isPy3k && pythonOlder "3.3");
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "05xwg00da8smkvkh6ywbywqzj8dw7x840jr74wqhdy9icmqncpbl";
+  };
+
+  postPatch = ''
+    sed -i 's,g++,${gcc_}/bin/g++,g' theano/configdefaults.py
+  '' + lib.optionalString cudnnSupport ''
+    sed -i \
+      -e "s,ctypes.util.find_library('cudnn'),'${cudnn}/lib/libcudnn.so',g" \
+      -e "s/= _dnn_check_compile()/= (True, None)/g" \
+      theano/gpuarray/dnn.py
+  '';
+
+  preCheck = ''
+    mkdir -p check-phase
+    export HOME=$(pwd)/check-phase
+  '';
+  doCheck = false;
+  # takes far too long, also throws "TypeError: sort() missing 1 required positional argument: 'a'"
+  # when run from the installer, and testing with Python 3.5 hits github.com/Theano/Theano/issues/4276,
+  # the fix for which hasn't been merged yet.
+
+  # keep Nose around since running the tests by hand is possible from Python or bash
+  checkInputs = [ nose ];
+  propagatedBuildInputs = [ numpy numpy.blas scipy six libgpuarray_ ];
+
+  meta = with stdenv.lib; {
+    homepage = http://deeplearning.net/software/theano/;
+    description = "A Python library for large-scale array computation";
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ maintainers.bcdarwin ];
+  };
+}
diff --git a/pkgs/development/python-modules/Theano/theano-with-cuda/default.nix b/pkgs/development/python-modules/Theano/theano-with-cuda/default.nix
deleted file mode 100644
index f8b7a713d08e..000000000000
--- a/pkgs/development/python-modules/Theano/theano-with-cuda/default.nix
+++ /dev/null
@@ -1,65 +0,0 @@
-{ buildPythonPackage
-, fetchFromGitHub
-, pythonOlder
-, future
-, numpy
-, six
-, scipy
-, nose
-, nose-parameterized
-, pydot_ng
-, sphinx
-, pygments
-, libgpuarray
-, python
-, pycuda
-, cudatoolkit
-, cudnn
-, stdenv
-}:
-
-buildPythonPackage rec {
-  name = "Theano-cuda-${version}";
-  version = "0.8.2";
-
-  src = fetchFromGitHub {
-    owner = "Theano";
-    repo = "Theano";
-    rev = "46fbfeb628220b5e42bf8277a5955c52d153e874";
-    sha256 = "1sl91gli3jaw5gpjqqab4fiq4x6282spqciaid1s65pjsf3k55sc";
-  };
-
-  doCheck = false;
-
-  patchPhase = ''
-    pushd theano/sandbox/gpuarray
-    sed -i -re '2s/^/from builtins import bytes\n/g' subtensor.py
-    sed -i -re "s/(b'2')/int(bytes(\1))/g" subtensor.py
-    sed -i -re "s/(ctx.bin_id\[\-2\])/int(\1)/g" subtensor.py
-
-    sed -i -re '2s/^/from builtins import bytes\n/g' dnn.py
-    sed -i -re "s/(b'30')/int(bytes(\1))/g" dnn.py
-    sed -i -re "s/(ctx.bin_id\[\-2:\])/int(\1)/g" dnn.py
-    popd
-  '';
-
-  dontStrip = true;
-
-  propagatedBuildInputs = [
-    numpy.blas
-    numpy
-    six
-    scipy
-    nose
-    nose-parameterized
-    pydot_ng
-    sphinx
-    pygments
-    pycuda
-    cudatoolkit
-    libgpuarray
-    cudnn
-  ] ++ (stdenv.lib.optional (pythonOlder "3.0") future);
-
-  passthru.cudaSupport = true;
-}
diff --git a/pkgs/development/python-modules/Theano/theano-without-cuda/default.nix b/pkgs/development/python-modules/Theano/theano-without-cuda/default.nix
deleted file mode 100644
index e93af7436190..000000000000
--- a/pkgs/development/python-modules/Theano/theano-without-cuda/default.nix
+++ /dev/null
@@ -1,44 +0,0 @@
-{ stdenv
-, fetchurl
-, buildPythonPackage
-, isPyPy
-, pythonOlder
-, isPy3k
-, nose
-, numpy
-, pydot_ng
-, scipy
-, six
-}:
-
-buildPythonPackage rec {
-  name = "Theano-0.9.0";
-
-  disabled = isPyPy || pythonOlder "2.6" || (isPy3k && pythonOlder "3.3");
-
-  src = fetchurl {
-    url = "mirror://pypi/T/Theano/${name}.tar.gz";
-    sha256 = "05xwg00da8smkvkh6ywbywqzj8dw7x840jr74wqhdy9icmqncpbl";
-  };
-
-  #preCheck = ''
-  #  mkdir -p check-phase
-  #  export HOME=$(pwd)/check-phase
-  #'';
-  doCheck = false;
-  # takes far too long, also throws "TypeError: sort() missing 1 required positional argument: 'a'"
-  # when run from the installer, and testing with Python 3.5 hits github.com/Theano/Theano/issues/4276,
-  # the fix for which hasn't been merged yet.
-
-  # keep Nose around since running the tests by hand is possible from Python or bash
-  propagatedBuildInputs = [ nose numpy numpy.blas pydot_ng scipy six ];
-
-  meta = {
-    homepage = http://deeplearning.net/software/theano/;
-    description = "A Python library for large-scale array computation";
-    license = stdenv.lib.licenses.bsd3;
-    maintainers = [ stdenv.lib.maintainers.bcdarwin ];
-  };
-
-  passthru.cudaSupport = false;
-}
diff --git a/pkgs/development/python-modules/libgpuarray/cuda/default.nix b/pkgs/development/python-modules/libgpuarray/cuda/default.nix
deleted file mode 100644
index a9c64cd7d7f8..000000000000
--- a/pkgs/development/python-modules/libgpuarray/cuda/default.nix
+++ /dev/null
@@ -1,129 +0,0 @@
-{ stdenv 
-, buildPythonPackage
-, fetchFromGitHub
-, cmake
-, cython
-, numpy
-, Mako
-, six
-, nose
-, beaker
-, memcached
-, pkgconfig
-, glibc
-, clblas
-, Babel
-, pygments
-, scipy
-, python
-, cudatoolkit
-, nvidia_x11
-}: 
-buildPythonPackage rec {
-  name = "libgpuarray-cuda-${version}";
-  version = "-9998.0"; 
-
-  src = fetchFromGitHub {
-    owner = "Theano"; 
-    repo = "libgpuarray";
-    rev = "fc36a40526c0a8303ace6c574ffdefba7feafe17"; 
-    sha256 = "1kb0k42addqjxiahlcbv6v6271yhsmz71j12186fpy60870i7zm7"; 
-  }; 
-
-  doCheck = true;
-
-  configurePhase = ''
-    mkdir -p Build/Install
-    pushd Build
-
-    cmake .. -DCMAKE_BUILD_TYPE=Release \
-             -DCMAKE_INSTALL_PREFIX=./Install \
-             -DCLBLAS_ROOT_DIR=${clblas}
-
-    popd
-  ''; 
-
-  preBuild = ''
-    pushd Build
-    make 
-    make install
-
-    function fixRunPath {
-      p=$(patchelf --print-rpath $1)
-      patchelf --set-rpath "$p:${stdenv.lib.makeLibraryPath [ cudatoolkit clblas nvidia_x11 ]}" $1
-    }
-
-    fixRunPath Install/lib/libgpuarray.so
-
-    popd
-  ''; 
-
-  setupPyBuildFlags = [ "-L $(pwd)/Build/Install/lib" "-I $(pwd)/Build/Install/include" ];
-
-  preInstall = ''
-    cp -r Build/Install $out
-  '';
-
-  postInstall = ''
-    pushd $out/${python.sitePackages}/pygpu
-    for f in $(find $out/pygpu -name "*.h"); do
-      ln -s $f $(basename $f)
-    done
-    popd
-  ''; 
-  checkPhase = ''
-    mkdir -p my_bin
-    pushd my_bin
-
-    cat > libgpuarray_run_tests << EOF
-#!/bin/sh
-if [ \$# -eq 0 ]; then 
-  echo "No argument provided."
-  echo "Available tests:"
-  ls $out/${python.sitePackages}/pygpu/tests | grep "test_"
-  exit 1
-else
-  nosetests -v "$out/${python.sitePackages}/pygpu/tests/\$@"
-fi
-EOF
-
-    chmod +x libgpuarray_run_tests
-    popd
-
-    cp -r my_bin $out/bin
-  '';
-
-  dontStrip = true; 
-
-  propagatedBuildInputs = [
-    numpy
-    scipy
-    nose
-    six
-    Mako
-  ];
-
-  buildInputs = [ 
-    cmake 
-    cython 
-    beaker 
-    memcached 
-    pkgconfig 
-    glibc 
-    Babel 
-    pygments 
-    numpy.blas 
-    cudatoolkit
-    nvidia_x11
-    clblas
-  ]; 
-
-  meta = with stdenv.lib; {
-    homepage = https://github.com/Theano/libgpuarray;
-    description = "Library to manipulate tensors on GPU.";
-    license = licenses.free;
-    maintainers = with maintainers; [ artuuge ];
-    platforms = platforms.linux;
-  };
-
-}
diff --git a/pkgs/development/python-modules/libgpuarray/default.nix b/pkgs/development/python-modules/libgpuarray/default.nix
new file mode 100644
index 000000000000..3c24c2ed24cb
--- /dev/null
+++ b/pkgs/development/python-modules/libgpuarray/default.nix
@@ -0,0 +1,81 @@
+{ stdenv 
+, lib
+, buildPythonPackage
+, fetchFromGitHub
+, cmake
+, cython
+, numpy
+, six
+, nose
+, Mako
+, python
+, cudaSupport ? false, cudatoolkit
+, openclSupport ? true, ocl-icd, clblas
+}: 
+
+buildPythonPackage rec {
+  name = "libgpuarray-${version}";
+  version = "0.6.9";
+
+  src = fetchFromGitHub {
+    owner = "Theano"; 
+    repo = "libgpuarray";
+    rev = "v${version}";
+    sha256 = "06z47ls42a37gbv0x7f3l1qvils7q0hvy02s95l530klgibp19s0";
+  }; 
+
+  # requires a GPU
+  doCheck = false;
+
+  configurePhase = "cmakeConfigurePhase";
+
+  libraryPath = lib.makeLibraryPath (
+    []
+    ++ lib.optionals cudaSupport [ cudatoolkit.lib cudatoolkit.out ]
+    ++ lib.optionals openclSupport [ ocl-icd clblas ]
+  );
+
+  preBuild = ''
+    make -j$NIX_BUILD_CORES
+    make install
+
+    ls $out/lib
+    export NIX_CFLAGS_COMPILE="-L $out/lib -I $out/include $NIX_CFLAGS_COMPILE"
+
+    cd ..
+  ''; 
+
+  postFixup = ''
+    rm $out/lib/libgpuarray-static.a
+
+    function fixRunPath {
+      p=$(patchelf --print-rpath $1)
+      patchelf --set-rpath "$p:$libraryPath" $1
+    }
+
+    fixRunPath $out/lib/libgpuarray.so
+  '';
+
+  propagatedBuildInputs = [
+    numpy
+    six
+    Mako
+  ];
+
+  enableParallelBuilding = true;
+
+  buildInputs = [ 
+    cmake 
+    cython 
+    nose
+  ]; 
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/Theano/libgpuarray";
+    description = "Library to manipulate tensors on GPU.";
+    license = licenses.free;
+    maintainers = with maintainers; [ artuuge ];
+    platforms = platforms.linux;
+  };
+
+}
diff --git a/pkgs/development/python-modules/pyftgl/default.nix b/pkgs/development/python-modules/pyftgl/default.nix
index 51de5e8fad5c..a02aa94576e5 100644
--- a/pkgs/development/python-modules/pyftgl/default.nix
+++ b/pkgs/development/python-modules/pyftgl/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildPythonPackage, fetchFromGitHub
+{ stdenv, buildPythonPackage, fetchFromGitHub, isPy3k
 , boost, freetype, ftgl, mesa }:
 
 buildPythonPackage rec {
@@ -11,6 +11,10 @@ buildPythonPackage rec {
     sha256 = "12zcjv4cwwjihiaf74kslrdmmk4bs47h7006gyqfwdfchfjdgg4r";
   };
 
+  postPatch = stdenv.lib.optional isPy3k ''
+    sed -i "s,'boost_python','boost_python3',g" setup.py
+  '';
+
   buildInputs = [ boost freetype ftgl mesa ];
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/python-modules/tensorflow/default.nix b/pkgs/development/python-modules/tensorflow/default.nix
index 00a5df843c5e..a0a2f3a24afc 100644
--- a/pkgs/development/python-modules/tensorflow/default.nix
+++ b/pkgs/development/python-modules/tensorflow/default.nix
@@ -1,156 +1,179 @@
-{ stdenv
-, symlinkJoin
-, lib
-, fetchurl
-, buildPythonPackage
-, isPy3k, isPy35, isPy36, isPy27
-, cudaSupport ? false
-, cudatoolkit ? null
-, cudnn ? null
-, linuxPackages ? null
-, numpy
-, six
-, protobuf
-, mock
-, backports_weakref
-, zlib
-, tensorflow-tensorboard
+{ stdenv, lib, fetchFromGitHub, fetchpatch, symlinkJoin, buildPythonPackage, isPy3k, pythonOlder
+, bazel, which, swig, binutils, glibcLocales
+, python, jemalloc, openmpi
+, numpy, six, protobuf, tensorflow-tensorboard, backports_weakref
+, wheel, mock, scipy
+, xlaSupport ? true
+, cudaSupport ? false, nvidia_x11 ? null, cudatoolkit ? null, cudnn ? null
+# Default from ./configure script
+, cudaCapabilities ? [ "3.5" "5.2" ]
 }:
 
 assert cudaSupport -> cudatoolkit != null
-                   && cudnn != null
-                   && linuxPackages != null;
+                   && cudnn != null;
 
 # unsupported combination
 assert ! (stdenv.isDarwin && cudaSupport);
 
-# tensorflow is built from a downloaded wheel, because the upstream
-# project's build system is an arcane beast based on
-# bazel. Untangling it and building the wheel from source is an open
-# problem.
+let
 
-buildPythonPackage rec {
-  pname = "tensorflow";
-  version = "1.3.0";
-  name = "${pname}-${version}";
-  format = "wheel";
-  disabled = ! (isPy35 || isPy36 || isPy27);
+  withTensorboard = pythonOlder "3.6";
 
-  # cudatoolkit is split (see https://github.com/NixOS/nixpkgs/commit/bb1c9b027d343f2ce263496582d6b56af8af92e6)
-  # However this means that libcusolver is not loadable by tensor flow. So we undo the split here.
   cudatoolkit_joined = symlinkJoin {
-    name = "unsplit_cudatoolkit";
-    paths = [ cudatoolkit.out
-              cudatoolkit.lib ];};
-
-  src = let
-      tfurl = sys: proc: pykind:
-        let
-          tfpref = if proc == "gpu"
-            then "gpu/tensorflow_gpu"
-            else "cpu/tensorflow";
-        in
-        "https://storage.googleapis.com/tensorflow/${sys}/${tfpref}-${version}-${pykind}.whl";
-      dls =
-        {
-        darwin.cpu = {
-          py2 = {
-            url = tfurl "mac" "cpu" "py2-none-any" ;
-            sha256 = "0nkymqbqjx8rsmc8vkc26cfsg4hpr6lj9zrwhjnfizvkzbbsh5z4";
-          };
-          py3 = {
-            url = tfurl "mac" "cpu" "py3-none-any" ;
-            sha256 = "1rj4m817w3lajnb1lgn3bwfwwk3qwvypyx11dim1ybakbmsc1j20";
-          };
-        };
-        linux-x86_64.cpu = {
-          py2 = {
-            url = tfurl "linux" "cpu" "cp27-none-linux_x86_64";
-            sha256 = "09pcyx0yfil4dm6cij8n3907pfgva07a38avrbai4qk5h6hxm8w9";
-          };
-          py35 = {
-            url = tfurl "linux" "cpu" "cp35-cp35m-linux_x86_64";
-            sha256 = "0p10zcf41pi33bi025fibqkq9rpd3v0rrbdmc9i9yd7igy076a07";
-          };
-          py36 = {
-            url = tfurl "linux" "cpu" "cp36-cp36m-linux_x86_64";
-            sha256 = "1qm8lm2f6bf9d462ybgwrz0dn9i6cnisgwdvyq9ssmy2f1gp8hxk";
-          };
-        };
-        linux-x86_64.cuda = {
-          py2 = {
-            url = tfurl "linux" "gpu" "cp27-none-linux_x86_64";
-            sha256 = "10yyyn4g2fsv1xgmw99bbr0fg7jvykay4gb5pxrrylh7h38h6wah";
-          };
-          py35 = {
-            url = tfurl "linux" "gpu" "cp35-cp35m-linux_x86_64";
-            sha256 = "0icwnhkcf3fxr6bmbihqzipnn4pxybd06qv7l3k0p4xdgycwzmzk";
-          };
-          py36 = {
-            url = tfurl "linux" "gpu" "cp36-cp36m-linux_x86_64";
-            sha256 = "12g3akkr083gs3sisjbmm0lpsk8phn3dvy7jjfadfxshqc7za14i";
-          };
-        };
-      };
-    in
-    fetchurl (
-      if stdenv.isDarwin then
-        if isPy3k then
-          dls.darwin.cpu.py3
-        else
-          dls.darwin.cpu.py2
-      else
-        if isPy35 then
-          if cudaSupport then
-            dls.linux-x86_64.cuda.py35
-          else
-            dls.linux-x86_64.cpu.py35
-        else if isPy36 then
-          if cudaSupport then
-            dls.linux-x86_64.cuda.py36
-          else
-            dls.linux-x86_64.cpu.py36
-        else
-          if cudaSupport then
-            dls.linux-x86_64.cuda.py2
-          else
-            dls.linux-x86_64.cpu.py2
-    );
-
-  propagatedBuildInputs =
-    [ numpy six protobuf mock backports_weakref ]
-    ++ lib.optional (!isPy36) tensorflow-tensorboard
-    ++ lib.optionals cudaSupport [ cudatoolkit_joined cudnn stdenv.cc ];
-
-  # tensorflow-gpu depends on tensorflow_tensorboard, which cannot be
+    name = "${cudatoolkit.name}-unsplit";
+    paths = [ cudatoolkit.out cudatoolkit.lib ];
+  };
+
+  cudaLibPath = lib.makeLibraryPath [ cudatoolkit.out cudatoolkit.lib nvidia_x11 cudnn ];
+
+  tfFeature = x: if x then "1" else "0";
+
+  common = rec {
+    version = "1.3.1";
+
+    src = fetchFromGitHub {
+      owner = "tensorflow";
+      repo = "tensorflow";
+      rev = "v${version}";
+      sha256 = "0gvi32dvv4ynr05p0gg5i0a6c55pig48k5qm7zslcqnp4sifwx0i";
+    };
+
+    nativeBuildInputs = [ swig which wheel scipy ];
+
+    buildInputs = [ python jemalloc openmpi glibcLocales ]
+      ++ lib.optionals cudaSupport [ cudatoolkit cudnn ];
+
+    propagatedBuildInputs = [ numpy six protobuf ]
+                            ++ lib.optional (!isPy3k) mock
+                            ++ lib.optional (pythonOlder "3.4") backports_weakref
+                            ++ lib.optional withTensorboard tensorflow-tensorboard;
+
+    preConfigure = ''
+      patchShebangs configure
+      export HOME="$NIX_BUILD_TOP"
+
+      export PYTHON_BIN_PATH="${python.interpreter}"
+      export TF_NEED_GCP=1
+      export TF_NEED_HDFS=1
+      export TF_NEED_CUDA=${tfFeature cudaSupport}
+      export TF_NEED_MPI=1
+      export TF_ENABLE_XLA=${tfFeature xlaSupport}
+      ${lib.optionalString cudaSupport ''
+        export CUDA_TOOLKIT_PATH=${cudatoolkit_joined}
+        export TF_CUDA_VERSION=${cudatoolkit.majorVersion}
+        export CUDNN_INSTALL_PATH=${cudnn}
+        export TF_CUDNN_VERSION=${cudnn.majorVersion}
+        export GCC_HOST_COMPILER_PATH=${cudatoolkit.cc}/bin/gcc
+        export TF_CUDA_COMPUTE_CAPABILITIES=${lib.concatStringsSep "," cudaCapabilities}
+      ''}
+
+      # There is _no_ non-interactive mode of configure.
+      sed -i \
+        -e 's,read -p,echo,g' \
+        -e 's,lib64,lib,g' \
+        configure
+    '';
+
+    hardeningDisable = [ "all" ];
+
+    bazelFlags = [ "--config=opt" ]
+                 ++ lib.optional cudaSupport "--config=cuda";
+
+    bazelTarget = "//tensorflow/tools/pip_package:build_pip_package";
+
+    meta = with stdenv.lib; {
+      description = "Computation using data flow graphs for scalable machine learning";
+      homepage = "http://tensorflow.org";
+      license = licenses.asl20;
+      maintainers = with maintainers; [ jyp abbradar ];
+      platforms = with platforms; if cudaSupport then linux else linux ++ darwin;
+    };
+  };
+
+in buildPythonPackage (common // {
+  name = "tensorflow-${common.version}";
+
+  deps = stdenv.mkDerivation (common // {
+    name = "tensorflow-external-${common.version}";
+
+    nativeBuildInputs = common.nativeBuildInputs ++ [ bazel ];
+
+    preConfigure = common.preConfigure + ''
+      export PYTHON_LIB_PATH="$(pwd)/site-packages"
+    '';
+
+    buildPhase = ''
+      mkdir site-packages
+      bazel --output_base="$(pwd)/output" fetch $bazelFlags $bazelTarget
+    '';
+
+    installPhase = ''
+      rm -rf output/external/{bazel_tools,\@bazel_tools.marker,local_*,\@local_*}
+      # Patching markers to make them deterministic
+      for i in output/external/\@*.marker; do
+        sed -i 's, -\?[0-9][0-9]*$, 1,' "$i"
+      done
+      # Patching symlinks to remove build directory reference
+      find output/external -type l | while read symlink; do
+        ln -sf $(readlink "$symlink" | sed "s,$NIX_BUILD_TOP,NIX_BUILD_TOP,") "$symlink"
+      done
+
+      cp -r output/external $out
+    '';
+
+    dontFixup = true;
+
+    outputHashMode = "recursive";
+    outputHashAlgo = "sha256";
+    outputHash = "0xs2n061gnpizfcnhs5jjpfk2av634j1l2l17zhy10bbmrwn3vrp";
+  });
+
+  nativeBuildInputs = common.nativeBuildInputs ++ [ (bazel.override { enableNixHacks = true; }) ];
+
+  configurePhase = ''
+    runHook preConfigure
+    export PYTHON_LIB_PATH="$out/${python.sitePackages}"
+    ./configure
+    runHook postConfigure
+  '';
+
+  buildPhase = ''
+    mkdir -p output/external
+    cp -r $deps/* output/external
+    chmod -R +w output
+    find output -type l | while read symlink; do
+      ln -sf $(readlink "$symlink" | sed "s,NIX_BUILD_TOP,$NIX_BUILD_TOP,") "$symlink"
+    done
+
+    patchShebangs .
+    find -type f -name CROSSTOOL\* -exec sed -i \
+      -e 's,/usr/bin/ar,${binutils}/bin/ar,g' \
+      {} \;
+
+    mkdir -p $out/${python.sitePackages}
+    bazel --output_base="$(pwd)/output" build $bazelFlags $bazelTarget
+
+    bazel-bin/tensorflow/tools/pip_package/build_pip_package $PWD/dist
+  '';
+
+  # tensorflow depends on tensorflow_tensorboard, which cannot be
   # built at the moment (some of its dependencies do not build
   # [htlm5lib9999999 (seven nines) -> tensorboard], and it depends on an old version of
   # bleach) Hence we disable dependency checking for now.
-  installFlags = lib.optional isPy36 "--no-dependencies";
-
-  # Note that we need to run *after* the fixup phase because the
-  # libraries are loaded at runtime. If we run in preFixup then
-  # patchelf --shrink-rpath will remove the cuda libraries.
-  postFixup = let
-    rpath = stdenv.lib.makeLibraryPath
-      (if cudaSupport then
-        [ stdenv.cc.cc.lib zlib cudatoolkit_joined cudnn
-          linuxPackages.nvidia_x11 ]
-      else
-        [ stdenv.cc.cc.lib zlib ]
-      );
-  in
-  ''
-    find $out -name '*.so' -exec patchelf --set-rpath "${rpath}" {} \;
-  '';
+  installFlags = lib.optional (!withTensorboard) "--no-dependencies";
 
+  # Tests are slow and impure.
   doCheck = false;
 
-  meta = with stdenv.lib; {
-    description = "TensorFlow helps the tensors flow";
-    homepage = http://tensorflow.org;
-    license = licenses.asl20;
-    maintainers = with maintainers; [ jyp ];
-    platforms = with platforms; if cudaSupport then linux else linux ++ darwin;
-  };
-}
+  # For some reason, CUDA is not retained in RPATH.
+  postFixup = lib.optionalString cudaSupport ''
+    libPath="$out/${python.sitePackages}/tensorflow/python/_pywrap_tensorflow_internal.so"
+    patchelf --set-rpath "$(patchelf --print-rpath "$libPath"):${cudaLibPath}" "$libPath"
+  '';
+
+  doInstallCheck = true;
+  installCheckPhase = ''
+    cd $NIX_BUILD_TOP
+    ${python.interpreter} -c "import tensorflow"
+  '';
+})
diff --git a/pkgs/development/python-modules/waitress-django/default.nix b/pkgs/development/python-modules/waitress-django/default.nix
new file mode 100644
index 000000000000..6efaf800b3cd
--- /dev/null
+++ b/pkgs/development/python-modules/waitress-django/default.nix
@@ -0,0 +1,8 @@
+{ buildPythonPackage, django_1_8, waitress }:
+buildPythonPackage {
+  name = "waitress-django";
+  src = ./.;
+  pythonPath = [ django_1_8 waitress ];
+  doCheck = false;
+  meta.description = "A waitress WSGI server serving django";
+}
diff --git a/pkgs/development/python-modules/waitress-django/setup.py b/pkgs/development/python-modules/waitress-django/setup.py
new file mode 100644
index 000000000000..07f7b326fdaf
--- /dev/null
+++ b/pkgs/development/python-modules/waitress-django/setup.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+
+from distutils.core import setup
+
+setup( name         = "waitress-django"
+     , version      = "0.0.0"
+     , description  = "A waitress WSGI server serving django"
+     , author       = "Bas van Dijk"
+     , author_email = "v.dijk.bas@gmail.com"
+     , package_dir  = {"" : "src"}
+     , scripts      = ["src/waitress-serve-django"]
+     )
diff --git a/pkgs/development/python-modules/waitress-django/src/waitress-serve-django b/pkgs/development/python-modules/waitress-django/src/waitress-serve-django
new file mode 100755
index 000000000000..b710086c22b9
--- /dev/null
+++ b/pkgs/development/python-modules/waitress-django/src/waitress-serve-django
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+import sys
+from waitress import serve
+from waitress.adjustments import Adjustments
+import django
+from django.core.handlers.wsgi import WSGIHandler
+from django.contrib.staticfiles.handlers import StaticFilesHandler
+
+if __name__ == "__main__":
+  kw, args = Adjustments.parse_args(sys.argv[1:])
+  django.setup()
+  # These arguments are specific to the runner, not waitress itself.
+  del kw['call'], kw['help']
+  serve(StaticFilesHandler(WSGIHandler()), **kw)
diff --git a/pkgs/development/tools/build-managers/bazel/0.4.nix b/pkgs/development/tools/build-managers/bazel/0.4.nix
index 2137c5c1497b..467ce6a17897 100644
--- a/pkgs/development/tools/build-managers/bazel/0.4.nix
+++ b/pkgs/development/tools/build-managers/bazel/0.4.nix
@@ -1,4 +1,8 @@
-{ stdenv, fetchurl, jdk, zip, unzip, bash, makeWrapper, which }:
+{ stdenv, lib, fetchurl, jdk, zip, unzip, bash, makeWrapper, which, coreutils
+# Always assume all markers valid (don't redownload dependencies).
+# Also, don't clean up environment variables.
+, enableNixHacks ? false
+}:
 
 stdenv.mkDerivation rec {
 
@@ -19,25 +23,24 @@ stdenv.mkDerivation rec {
     sha256 = "0asmq3kxnl4326zhgh13mvcrc8jvmiswjj4ymrq0943q4vj7nwrb";
   };
 
+  preUnpack = ''
+    mkdir bazel
+    cd bazel
+  '';
   sourceRoot = ".";
 
+  patches = lib.optional enableNixHacks ./nix-hacks.patch;
+
   postPatch = ''
-    for f in $(grep -l -r '#!/bin/bash'); do
-      substituteInPlace "$f" --replace '#!/bin/bash' '#!${bash}/bin/bash'
+    for f in $(grep -l -r '/bin/bash'); do
+      substituteInPlace "$f" --replace '/bin/bash' '${bash}/bin/bash'
     done
-    for f in \
-      src/main/java/com/google/devtools/build/lib/analysis/CommandHelper.java \
-      src/main/java/com/google/devtools/build/lib/bazel/rules/BazelConfiguration.java \
-      src/main/java/com/google/devtools/build/lib/bazel/rules/sh/BazelShRuleClasses.java \
-      src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java \
-      ; do
-      substituteInPlace "$f" --replace /bin/bash ${bash}/bin/bash
+    for f in $(grep -l -r '/usr/bin/env'); do
+      substituteInPlace "$f" --replace '/usr/bin/env' '${coreutils}/bin/env'
     done
   '';
 
   buildInputs = [
-    stdenv.cc
-    stdenv.cc.cc.lib
     jdk
     zip
     unzip
@@ -52,12 +55,7 @@ stdenv.mkDerivation rec {
     bash
   ];
 
-  # If TMPDIR is in the unpack dir we run afoul of blaze's infinite symlink
-  # detector (see com.google.devtools.build.lib.skyframe.FileFunction).
-  # Change this to $(mktemp -d) as soon as we figure out why.
-
   buildPhase = ''
-    export TMPDIR=/tmp
     ./compile.sh
     ./output/bazel --output_user_root=/tmp/.bazel build //scripts:bash_completion \
       --spawn_strategy=standalone \
diff --git a/pkgs/development/tools/build-managers/bazel/nix-hacks.patch b/pkgs/development/tools/build-managers/bazel/nix-hacks.patch
new file mode 100644
index 000000000000..563fe635e6b0
--- /dev/null
+++ b/pkgs/development/tools/build-managers/bazel/nix-hacks.patch
@@ -0,0 +1,51 @@
+diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java
+index eafa09fb5..d2d5e40e8 100644
+--- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java
++++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java
+@@ -287,21 +287,8 @@ public final class RepositoryDelegatorFunction implements SkyFunction {
+           markerData.put(key, value);
+         }
+       }
+-      boolean result = false;
+-      if (markerRuleKey.equals(ruleKey)) {
+-        result = handler.verifyMarkerData(rule, markerData, env);
+-        if (env.valuesMissing()) {
+-          return null;
+-        }
+-      }
+ 
+-      if (result) {
+-        return new Fingerprint().addString(content).digestAndReset();
+-      } else {
+-        // So that we are in a consistent state if something happens while fetching the repository
+-        markerPath.delete();
+-        return null;
+-      }
++      return new Fingerprint().addString(content).digestAndReset();
+ 
+     } catch (IOException e) {
+       throw new RepositoryFunctionException(e, Transience.TRANSIENT);
+diff --git a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
+index a7ebc8f7a..40f2049fa 100644
+--- a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
++++ b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
+@@ -129,7 +129,6 @@ public class JavaSubprocessFactory implements SubprocessFactory {
+     ProcessBuilder builder = new ProcessBuilder();
+     builder.command(params.getArgv());
+     if (params.getEnv() != null) {
+-      builder.environment().clear();
+       builder.environment().putAll(params.getEnv());
+     }
+ 
+diff --git a/src/main/java/com/google/devtools/build/lib/worker/Worker.java b/src/main/java/com/google/devtools/build/lib/worker/Worker.java
+index 0268d1b2b..637364657 100644
+--- a/src/main/java/com/google/devtools/build/lib/worker/Worker.java
++++ b/src/main/java/com/google/devtools/build/lib/worker/Worker.java
+@@ -77,7 +77,6 @@ class Worker {
+         new ProcessBuilder(command)
+             .directory(workDir.getPathFile())
+             .redirectError(Redirect.appendTo(logFile.getPathFile()));
+-    processBuilder.environment().clear();
+     processBuilder.environment().putAll(workerKey.getEnv());
+ 
+     this.process = processBuilder.start();
diff --git a/pkgs/games/bastet/default.nix b/pkgs/games/bastet/default.nix
index 4c55d571bd51..27ddec616bc8 100644
--- a/pkgs/games/bastet/default.nix
+++ b/pkgs/games/bastet/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, ncurses, boost }:
+{ stdenv, fetchFromGitHub, fetchpatch, ncurses, boost }:
 
 stdenv.mkDerivation rec {
   name = "bastet-${version}";
@@ -12,6 +12,14 @@ stdenv.mkDerivation rec {
     sha256 = "09kamxapm9jw9przpsgjfg33n9k94bccv65w95dakj0br33a75wn";
   };
 
+  patches = [
+    # Compatibility with new Boost
+    (fetchpatch {
+      url = "https://github.com/fph/bastet/commit/0e03f8d4d6bc6949cf1c447e632ce0d1b98c4be1.patch";
+      sha256 = "1475hisbm44jirsrhdlnddppsyn83xmvcx09gfkm9drcix05alzj";
+    })
+  ];
+
   installPhase = ''
     mkdir -p "$out"/bin
     cp bastet "$out"/bin/
diff --git a/pkgs/games/openrct2/default.nix b/pkgs/games/openrct2/default.nix
new file mode 100644
index 000000000000..a54d3a45ae81
--- /dev/null
+++ b/pkgs/games/openrct2/default.nix
@@ -0,0 +1,70 @@
+{ stdenv, fetchurl, fetchFromGitHub,
+  SDL2, cmake, curl, fontconfig, freetype, jansson, libiconv, libpng,
+  libpthreadstubs, libzip, mesa_glu, openssl, pkgconfig, speexdsp, zlib
+}:
+
+let
+  name = "openrct2-${version}";
+  version = "0.1.1";
+
+  openrct2-src = fetchFromGitHub {
+    owner = "OpenRCT2";
+    repo = "OpenRCT2";
+    rev = "v${version}";
+    sha256 = "1xxwqx2gzvsdrsy76rz3sys9m4pyn9q25nbnkba3cw1z4l2b73lg";
+  };
+
+  title-sequences-src = fetchFromGitHub {
+    owner = "OpenRCT2";
+    repo = "title-sequences";
+    rev = "v0.1.0";
+    sha256 = "17c926lhby90ilvyyl6jsiy0df8dw5jws97xigp3x8hddhvv7c16";
+  };
+in
+stdenv.mkDerivation rec {
+  inherit name;
+
+  srcs = [ openrct2-src title-sequences-src ];
+  sourceRoot = ".";
+
+  buildInputs = [
+    SDL2
+    cmake
+    curl
+    fontconfig
+    freetype
+    jansson
+    libiconv
+    libpng
+    libpthreadstubs
+    libzip
+    mesa_glu
+    openssl
+    pkgconfig
+    speexdsp
+    zlib
+  ];
+
+  postUnpack = ''
+    cp -r ${openrct2-src}/* ${sourceRoot}
+    cp -r ${title-sequences-src} ${sourceRoot}/title
+
+    # creating temporary files in fixCmakeFiles fails otherwise
+    chmod -R u+w ${sourceRoot}
+  '';
+
+  cmakeFlags = [
+    "-DCMAKE_BUILD_TYPE=RELWITHDEBINFO" "-DDOWNLOAD_TITLE_SEQUENCES=OFF"];
+
+  makeFlags = ["all" "g2"];
+
+  preFixup = "ln -s $out/share/openrct2 $out/bin/data";
+
+  meta = with stdenv.lib; {
+    description = "An open source re-implementation of RollerCoaster Tycoon 2 (original game required)";
+    homepage = https://openrct2.website/;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ geistesk ];
+  };
+}
diff --git a/pkgs/os-specific/linux/kernel/linux-4.13.nix b/pkgs/os-specific/linux/kernel/linux-4.13.nix
index d54586c5f4f5..ee1aa79f5404 100644
--- a/pkgs/os-specific/linux/kernel/linux-4.13.nix
+++ b/pkgs/os-specific/linux/kernel/linux-4.13.nix
@@ -1,11 +1,11 @@
 { stdenv, hostPlatform, fetchurl, perl, buildLinux, ... } @ args:
 
 import ./generic.nix (args // rec {
-  version = "4.13.7";
+  version = "4.13.8";
   extraMeta.branch = "4.13";
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz";
-    sha256 = "16vjjl3qw0a8ci6xbnywhb8bpr3ccbs0i6xa54lc094cd5gvx4v3";
+    sha256 = "09zl4gpw9j4xn6p78s6ba6qjjxpsy8whhvn19wnjhr9w4al8rrk4";
   };
 } // (args.argsOverride or {}))
diff --git a/pkgs/os-specific/linux/kernel/linux-4.9.nix b/pkgs/os-specific/linux/kernel/linux-4.9.nix
index b820b6a917b4..8a1ad7ca9ddc 100644
--- a/pkgs/os-specific/linux/kernel/linux-4.9.nix
+++ b/pkgs/os-specific/linux/kernel/linux-4.9.nix
@@ -1,11 +1,11 @@
 { stdenv, hostPlatform, fetchurl, perl, buildLinux, ... } @ args:
 
 import ./generic.nix (args // rec {
-  version = "4.9.56";
+  version = "4.9.57";
   extraMeta.branch = "4.9";
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz";
-    sha256 = "1jnkf0ir42xkandx1lnqrxmskzwl6j46aqmzrxilddx9pkdjplhi";
+    sha256 = "19lndirbyryx0qdwqqhn1g4rng7d79rk4sra5lpa2d3axia0a8q9";
   };
 } // (args.argsOverride or {}))
diff --git a/pkgs/os-specific/linux/kexectools/default.nix b/pkgs/os-specific/linux/kexectools/default.nix
index 206dc6889e8b..4a68160ce05a 100644
--- a/pkgs/os-specific/linux/kexectools/default.nix
+++ b/pkgs/os-specific/linux/kexectools/default.nix
@@ -2,14 +2,14 @@
 
 stdenv.mkDerivation rec {
   name = "kexec-tools-${version}";
-  version = "2.0.14";
+  version = "2.0.15";
 
   src = fetchurl {
     urls = [
       "mirror://kernel/linux/utils/kernel/kexec/${name}.tar.xz"
       "http://horms.net/projects/kexec/kexec-tools/${name}.tar.xz"
     ];
-    sha256 = "1ihd3kzw8xnc5skq4pb633rr80007knjm4n1dd67a24xkplygcpz";
+    sha256 = "1rwl04y1mpb28yq5ynnk8j124dmhj5p8c4hcdn453sri2j37p6w9";
   };
 
   hardeningDisable = [ "format" "pic" "relro" ];
diff --git a/pkgs/os-specific/linux/wireguard/default.nix b/pkgs/os-specific/linux/wireguard/default.nix
index b6d294836c28..18ed3287edc4 100644
--- a/pkgs/os-specific/linux/wireguard/default.nix
+++ b/pkgs/os-specific/linux/wireguard/default.nix
@@ -6,11 +6,11 @@ assert kernel != null -> stdenv.lib.versionAtLeast kernel.version "3.10";
 let
   name = "wireguard-${version}";
 
-  version = "0.0.20171011";
+  version = "0.0.20171017";
 
   src = fetchurl {
     url    = "https://git.zx2c4.com/WireGuard/snapshot/WireGuard-${version}.tar.xz";
-    sha256 = "15hby5fi85r7h7adr8kva26w9b2sz3147d7nl2y0fdblb3v4zr72";
+    sha256 = "1k9m980d7zmnhpj9kanyfavqrn7ryva16iblk9jrk6sdhxi9mdsp";
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/servers/atlassian/confluence.nix b/pkgs/servers/atlassian/confluence.nix
index a4cc5c8780da..8b107e74f3f2 100644
--- a/pkgs/servers/atlassian/confluence.nix
+++ b/pkgs/servers/atlassian/confluence.nix
@@ -5,11 +5,11 @@
 
 stdenv.mkDerivation rec {
   name = "atlassian-confluence-${version}";
-  version = "6.4.0";
+  version = "6.4.2";
 
   src = fetchurl {
     url = "https://www.atlassian.com/software/confluence/downloads/binary/${name}.tar.gz";
-    sha256 = "1ba8zpcywnnanzqxjaqiyfc6j5qr6jk6laryz8npiqz4grv3qk61";
+    sha256 = "1akwbgbks6k63m22vrcvvz9jz4wqz380j8gb8lzbzm4yk8y7f4p9";
   };
 
   phases = [ "unpackPhase" "buildPhase" "installPhase" ];
diff --git a/pkgs/servers/atlassian/jira.nix b/pkgs/servers/atlassian/jira.nix
index f2ccb523e2ff..c8b9978a9edc 100644
--- a/pkgs/servers/atlassian/jira.nix
+++ b/pkgs/servers/atlassian/jira.nix
@@ -5,11 +5,11 @@
 
 stdenv.mkDerivation rec {
   name = "atlassian-jira-${version}";
-  version = "7.5.0";
+  version = "7.5.1";
 
   src = fetchurl {
     url = "https://downloads.atlassian.com/software/jira/downloads/atlassian-jira-software-${version}.tar.gz";
-    sha256 = "12pf0q1ixsf9ld0569mbwvjz5v9bhh7ad3bd8x9qx188vq5cz381";
+    sha256 = "0dl9sjp1z7h340phmfhwha2j7hj5zcspk8v7n6vhsrfsjbkm80vy";
   };
 
   phases = [ "unpackPhase" "buildPhase" "installPhase" "fixupPhase" ];
diff --git a/pkgs/servers/dns/knot-dns/default.nix b/pkgs/servers/dns/knot-dns/default.nix
index cdbdf04f4454..00d1c5c568d0 100644
--- a/pkgs/servers/dns/knot-dns/default.nix
+++ b/pkgs/servers/dns/knot-dns/default.nix
@@ -1,5 +1,6 @@
 { stdenv, fetchurl, pkgconfig, gnutls, jansson, liburcu, lmdb, libcap_ng, libidn
 , systemd, nettle, libedit, zlib, libiconv, libintlOrEmpty
+, fetchpatch
 }:
 
 let inherit (stdenv.lib) optional optionals; in
@@ -14,6 +15,12 @@ stdenv.mkDerivation rec {
     sha256 = "68e04961d0bf6ba193cb7ec658b295c4ff6e60b3754d64bcd77ebdcee0f283fd";
   };
 
+  patches = [(fetchpatch { # remove for >= 2.6.1
+    name = "kdig-tls.patch";
+    url = "https://gitlab.labs.nic.cz/knot/knot-dns/commit/b72d5cd032795.diff";
+    sha256 = "0ig31rp82j49jh8n3s0dcf5abhh35mcp2k2wii7bh0c60ngb29k6";
+  })];
+
   outputs = [ "bin" "out" "dev" ];
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/servers/monitoring/telegraf/default.nix b/pkgs/servers/monitoring/telegraf/default.nix
index 8e11fe877c83..59b27efba568 100644
--- a/pkgs/servers/monitoring/telegraf/default.nix
+++ b/pkgs/servers/monitoring/telegraf/default.nix
@@ -2,7 +2,7 @@
 
 buildGoPackage rec {
   name = "telegraf-${version}";
-  version = "1.4.1";
+  version = "1.4.2";
 
   goPackagePath = "github.com/influxdata/telegraf";
 
@@ -12,7 +12,7 @@ buildGoPackage rec {
     owner = "influxdata";
     repo = "telegraf";
     rev = "${version}";
-    sha256 = "1q0xl599zyqyralsl6mml1xl0h2206564sa2azivjmg48z7blcll";
+    sha256 = "1lmk0czqbr4mn1zf99403r8s6nyyk3bxwgvxfx7w4apvxl433iw4";
   };
 
   buildFlagsArray = [ ''-ldflags=
diff --git a/pkgs/servers/monitoring/telegraf/deps-1.4.1.nix b/pkgs/servers/monitoring/telegraf/deps-1.4.2.nix
index 4391d58164f0..4391d58164f0 100644
--- a/pkgs/servers/monitoring/telegraf/deps-1.4.1.nix
+++ b/pkgs/servers/monitoring/telegraf/deps-1.4.2.nix
diff --git a/pkgs/tools/graphics/povray/default.nix b/pkgs/tools/graphics/povray/default.nix
index 6bdff06699b9..7284ee95a909 100644
--- a/pkgs/tools/graphics/povray/default.nix
+++ b/pkgs/tools/graphics/povray/default.nix
@@ -4,13 +4,13 @@
 
 stdenv.mkDerivation rec {
   name = "povray-${version}";
-  version = "3.7.0.3";
+  version = "3.7.0.4";
 
   src = fetchFromGitHub {
     owner = "POV-Ray";
     repo = "povray";
     rev = "v${version}";
-    sha256 = "0mzkgk3gn8jfrw1fq0z3kqbysdfq8nwdl8a28l18v8gzb31bblhq";
+    sha256 = "1wkwb43w5r9pa79yazy4w4s8n6g280igag97hgl7dyi289q39n0q";
   };
 
 
diff --git a/pkgs/tools/misc/snapper/default.nix b/pkgs/tools/misc/snapper/default.nix
index 9895fff3ba8f..4b7857d60e7b 100644
--- a/pkgs/tools/misc/snapper/default.nix
+++ b/pkgs/tools/misc/snapper/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub
+{ stdenv, fetchFromGitHub, fetchpatch
 , autoreconfHook, pkgconfig, docbook_xsl, libxslt, docbook_xml_dtd_45
 , acl, attr, boost, btrfs-progs, dbus_libs, diffutils, e2fsprogs, libxml2
 , lvm2, pam, python, utillinux }:
@@ -14,6 +14,14 @@ stdenv.mkDerivation rec {
     sha256 = "14hrv23film4iihyclcvc2r2dgxl8w3as50r81xjjc85iyp6yxkm";
   };
 
+  patches = [
+    # Fix build with new Boost
+    (fetchpatch {
+      url = "https://github.com/openSUSE/snapper/commit/2e3812d2c1d1f54861fb79f5c2b0197de96a00a3.patch";
+      sha256 = "0yrzss1v7lmcvkajmchz917yqsvlsdfz871szzw790v6pql1322s";
+    })
+  ];
+
   nativeBuildInputs = [
     autoreconfHook pkgconfig
     docbook_xsl libxslt docbook_xml_dtd_45
diff --git a/pkgs/tools/networking/isync/default.nix b/pkgs/tools/networking/isync/default.nix
index 8b81e0696c23..7dcfc6b512fb 100644
--- a/pkgs/tools/networking/isync/default.nix
+++ b/pkgs/tools/networking/isync/default.nix
@@ -1,14 +1,14 @@
-{ fetchurl, stdenv, openssl, pkgconfig, db, cyrus_sasl }:
+{ fetchurl, stdenv, openssl, pkgconfig, db, cyrus_sasl, perl }:
 
 stdenv.mkDerivation rec {
-  name = "isync-1.2.1";
+  name = "isync-1.3.0";
 
   src = fetchurl {
     url = "mirror://sourceforge/isync/${name}.tar.gz";
-    sha256 = "1bij6nm06ghkg98n2pdyacam2fyg5y8f7ajw0d5653m0r4ldw5p7";
+    sha256 = "173wd7x8y5sp94slzwlnb7zhgs32r57zl9xspl2rf4g3fqwmhpwd";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig perl ];
   buildInputs = [ openssl db cyrus_sasl ];
 
   meta = with stdenv.lib; {
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 6bef03ff8365..90890e0f2d07 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -645,9 +645,7 @@ with pkgs;
   };
   aria = aria2;
 
-  aspcud = callPackage ../tools/misc/aspcud {
-    boost = boost163;
-  };
+  aspcud = callPackage ../tools/misc/aspcud { };
 
   at = callPackage ../tools/system/at { };
 
@@ -1402,9 +1400,7 @@ with pkgs;
 
   citrix_receiver = callPackage ../applications/networking/remote/citrix-receiver { };
 
-  citra = libsForQt5.callPackage ../misc/emulators/citra {
-    boost = boost163;
-  };
+  citra = libsForQt5.callPackage ../misc/emulators/citra { };
 
   cmst = libsForQt5.callPackage ../tools/networking/cmst { };
 
@@ -1581,27 +1577,19 @@ with pkgs;
     cudatoolkit65
     cudatoolkit7
     cudatoolkit75
-    cudatoolkit8;
-
-  cudatoolkit = cudatoolkit8;
+    cudatoolkit8
+    cudatoolkit9;
 
-  cudnn = callPackage ../development/libraries/science/math/cudnn/default.nix {};
+  cudatoolkit = cudatoolkit9;
 
-  cudnn5_cudatoolkit75 = callPackage ../development/libraries/science/math/cudnn/7.5-5.0 {
-    cudatoolkit = cudatoolkit75;
-  };
+  inherit (callPackages ../development/libraries/science/math/cudnn { })
+    cudnn_cudatoolkit7
+    cudnn_cudatoolkit75
+    cudnn6_cudatoolkit8
+    cudnn_cudatoolkit8
+    cudnn_cudatoolkit9;
 
-  cudnn5_cudatoolkit80 = callPackage ../development/libraries/science/math/cudnn/8.0-5.0 {
-    cudatoolkit = cudatoolkit8;
-  };
-
-  cudnn51_cudatoolkit80 = callPackage ../development/libraries/science/math/cudnn/8.0-5.1 {
-    cudatoolkit = cudatoolkit8;
-  };
-
-  cudnn60_cudatoolkit80 = callPackage ../development/libraries/science/math/cudnn/8.0-6.0 {
-    cudatoolkit = cudatoolkit8;
-  };
+  cudnn = cudnn_cudatoolkit9;
 
   curlFull = curl.override {
     idnSupport = true;
@@ -7825,8 +7813,9 @@ with pkgs;
   boost162 = callPackage ../development/libraries/boost/1.62.nix { };
   boost163 = callPackage ../development/libraries/boost/1.63.nix { };
   boost164 = callPackage ../development/libraries/boost/1.64.nix { };
-  boost16x = boost164;
-  boost = boost162;
+  boost165 = callPackage ../development/libraries/boost/1.65.nix { };
+  boost16x = boost165;
+  boost = boost16x;
 
   boost_process = callPackage ../development/libraries/boost-process { };
 
@@ -8032,6 +8021,18 @@ with pkgs;
 
   dotconf = callPackage ../development/libraries/dotconf { };
 
+  # Multi-arch "drivers" which we want to build for i686.
+  driversi686Linux = recurseIntoAttrs {
+    inherit (pkgsi686Linux)
+      mesa_noglu
+      vaapiIntel
+      libvdpau-va-gl
+      vaapiVdpau
+      beignet
+      glxinfo
+      vdpauinfo;
+  };
+
   dssi = callPackage ../development/libraries/dssi {};
 
   dxflib = callPackage ../development/libraries/dxflib {};
@@ -10024,6 +10025,8 @@ with pkgs;
   };
 
   opencv3 = callPackage ../development/libraries/opencv/3.x.nix {
+    enableCuda = config.cudaSupport or false;
+    cudatoolkit = cudatoolkit8;
     inherit (darwin.apple_sdk.frameworks) AVFoundation Cocoa QTKit;
   };
 
@@ -10086,7 +10089,7 @@ with pkgs;
   };
 
   opensubdiv = callPackage ../development/libraries/opensubdiv {
-    stdenv_gcc5 = overrideCC stdenv gcc5;
+    cudaSupport = config.cudaSupport or false;
     cmake = cmake_2_8;
   };
 
@@ -10096,6 +10099,8 @@ with pkgs;
 
   ortp = callPackage ../development/libraries/ortp { };
 
+  openrct2 = callPackage ../games/openrct2/default.nix { };
+
   osm-gps-map = callPackage ../development/libraries/osm-gps-map { };
 
   p11_kit = callPackage ../development/libraries/p11-kit { };
@@ -12928,7 +12933,6 @@ with pkgs;
 
   systemd = callPackage ../os-specific/linux/systemd {
     utillinux = utillinuxMinimal; # break the cyclic dependency
-    gperf = gperf_3_0; # fix build until v233
   }
     // {
       udev.bin = systemd;     # ${systemd.udev.bin}/bin/udevadm
@@ -13822,7 +13826,7 @@ with pkgs;
   bleachbit = callPackage ../applications/misc/bleachbit { };
 
   blender = callPackage  ../applications/misc/blender {
-    stdenv_gcc5 = overrideCC stdenv gcc5;
+    cudaSupport = config.cudaSupport or false;
     python = python35;
   };
 
@@ -17574,6 +17578,7 @@ with pkgs;
 
   digikam = libsForQt5.callPackage ../applications/graphics/digikam {
     inherit (plasma5) oxygen;
+    inherit (kdeApplications) kcalcore;
     boost = boost160;
   };
 
@@ -18354,10 +18359,7 @@ with pkgs;
 
   blas = callPackage ../development/libraries/science/math/blas { };
 
-  clblas-cuda = callPackage ../development/libraries/science/math/clblas/cuda {
-    cudatoolkit = pkgs.cudatoolkit75;
-    inherit (linuxPackages) nvidia_x11;
-  };
+  clblas = callPackage ../development/libraries/science/math/clblas { };
 
   jags = callPackage ../applications/science/math/jags { };
 
@@ -18739,8 +18741,15 @@ with pkgs;
 
   caffe = callPackage ../applications/science/math/caffe rec {
     cudaSupport = config.caffe.cudaSupport or config.cudaSupport or false;
-    # CUDA 8 doesn't support GCC 6.
-    stdenv = if cudaSupport then overrideCC pkgs.stdenv gcc5 else pkgs.stdenv;
+    cudnnSupport = cudaSupport;
+  };
+
+  cntk = callPackage ../applications/science/math/cntk rec {
+    cudaSupport = pkgs.config.cudaSupport or false;
+    cudnnSupport = cudaSupport;
+    inherit (linuxPackages) nvidia_x11;
+    cudatoolkit = cudatoolkit8;
+    cudnn = cudnn6_cudatoolkit8;
   };
 
   ecm = callPackage ../applications/science/math/ecm { };
@@ -18764,7 +18773,9 @@ with pkgs;
     sbcl = null;
   };
 
-  mxnet = callPackage ../applications/science/math/mxnet {
+  mxnet = callPackage ../applications/science/math/mxnet rec {
+    cudaSupport = config.cudaSupport or false;
+    cudnnSupport = cudaSupport;
     inherit (linuxPackages) nvidia_x11;
   };
 
diff --git a/pkgs/top-level/perl-packages.nix b/pkgs/top-level/perl-packages.nix
index 69c89c2529d3..9f1423c65c1c 100644
--- a/pkgs/top-level/perl-packages.nix
+++ b/pkgs/top-level/perl-packages.nix
@@ -2917,10 +2917,10 @@ let self = _self // overrides; _self = with self; {
   };
 
   CryptX = buildPerlPackage rec {
-    name = "CryptX-0.050";
+    name = "CryptX-0.054";
     src = fetchurl {
       url = "mirror://cpan/authors/id/M/MI/MIK/${name}.tar.gz";
-      sha256 = "c1de040779d9f5482d0a2f17a9a5aa6b069c7c58c07fbe26ab62bc689a5c9161";
+      sha256 = "f084a706f6ff032ca5c46ec6f90ba5b6a26ae8752584911830f6535bf76d8e57";
     };
     propagatedBuildInputs = [ JSONMaybeXS ];
     meta = {
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 43e6ad64e81f..4f3952320059 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -60,7 +60,7 @@ let
 
   buildPythonApplication = args: buildPythonPackage ({namePrefix="";} // args );
 
-  graphiteVersion = "0.9.15";
+  graphiteVersion = "1.0.2";
 
   fetchPypi = makeOverridable( {format ? "setuptools", ... } @attrs:
     let
@@ -1476,7 +1476,10 @@ in {
 
   # Build boost for this specific Python version
   # TODO: use separate output for libboost_python.so
-  boost = pkgs.boost.override {inherit python;};
+  boost = pkgs.boost.override {
+    inherit (self) python numpy;
+    enablePython = true;
+  };
 
   buttersink = buildPythonPackage rec {
     name = "buttersink-0.6.8";
@@ -1531,7 +1534,6 @@ in {
     python = self.python;
     boost = self.boost;
     numpy = self.numpy;
-    pythonSupport = true;
   };
 
   capstone = buildPythonPackage rec {
@@ -2576,6 +2578,27 @@ in {
     };
   };
 
+  cntk = buildPythonPackage rec {
+    inherit (pkgs.cntk) name version src meta;
+
+    buildInputs = [ pkgs.cntk pkgs.swig pkgs.openmpi ];
+    propagatedBuildInputs = with self; [ numpy scipy enum34 protobuf pip ];
+
+    CNTK_LIB_PATH = "${pkgs.cntk}/lib";
+    CNTK_COMPONENT_VERSION = pkgs.cntk.version;
+
+    postPatch = ''
+      cd bindings/python
+    '';
+
+    postInstall = ''
+      rm -rf $out/${python.sitePackages}/cntk/libs
+      ln -s ${pkgs.cntk}/lib $out/${python.sitePackages}/cntk/libs
+      # It's not installed for some reason.
+      cp cntk/cntk_py.py $out/${python.sitePackages}/cntk
+    '';
+  };
+
   celery = buildPythonPackage rec {
     name = "celery-${version}";
     version = "4.0.2";
@@ -8286,14 +8309,14 @@ in {
 
   django_tagging = callPackage ../development/python-modules/django_tagging { };
 
-  django_tagging_0_3 = self.django_tagging.overrideAttrs (attrs: rec {
-    name = "django-tagging-0.3.6";
+  django_tagging_0_4_3 = self.django_tagging.overrideAttrs (attrs: rec {
+    name = "django-tagging-0.4.3";
 
     src = pkgs.fetchurl {
       url = "mirror://pypi/d/django-tagging/${name}.tar.gz";
-      sha256 = "03zlbq13rydfh28wh0jk3x3cjk9x6jjmqnx1i3ngjmfwbxf8x6j1";
+      sha256 = "0617azpmp6jpg3d88v2ir97qrc9aqcs2s9gyvv9bgf2cp55khxhs";
     };
-    propagatedBuildInputs = with self; [ django ];
+    propagatedBuildInputs = with self; [ django_1_8 ];
   });
 
   django_classytags = buildPythonPackage rec {
@@ -11127,14 +11150,12 @@ in {
     };
   });
 
-  libgpuarray-cuda = callPackage ../development/python-modules/libgpuarray/cuda/default.nix rec {
-    inherit (self) numpy scipy;
-    inherit (pkgs.linuxPackages) nvidia_x11;
-    cudatoolkit = pkgs.cudatoolkit75;
-    clblas = pkgs.clblas-cuda;
+  libgpuarray = callPackage ../development/python-modules/libgpuarray {
+    clblas = pkgs.clblas.override { boost = self.boost; };
+    cudaSupport = pkgs.config.cudaSupport or false;
   };
 
-  libnacl = callPackage ../development/python-modules/libnacl/default.nix {
+  libnacl = callPackage ../development/python-modules/libnacl {
     inherit (pkgs) libsodium;
   };
 
@@ -19833,24 +19854,20 @@ in {
 
   stevedore = callPackage ../development/python-modules/stevedore {};
 
-  Theano = self.TheanoWithoutCuda;
+  Theano = callPackage ../development/python-modules/Theano rec {
+    cudaSupport = pkgs.config.cudaSupport or false;
+    cudnnSupport = cudaSupport;
+  };
 
-  TheanoWithoutCuda = callPackage ../development/python-modules/Theano/theano-without-cuda { };
+  TheanoWithoutCuda = self.Theano.override {
+    cudaSupport = true;
+    cudnnSupport = true;
+  };
 
-  TheanoWithCuda = callPackage ../development/python-modules/Theano/theano-with-cuda (
-  let
-    boost = pkgs.boost159.override {
-      inherit (self) python numpy scipy;
-    };
-  in rec {
-    cudatoolkit = pkgs.cudatoolkit75;
-    cudnn = pkgs.cudnn5_cudatoolkit75;
-    inherit (self) numpy scipy;
-    pycuda = self.pycuda.override { inherit boost; };
-    libgpuarray = self.libgpuarray-cuda.override {
-      clblas = pkgs.clblas-cuda.override { inherit boost; };
-    };
-  });
+  TheanoWithCuda = self.Theano.override {
+    cudaSupport = false;
+    cudnnSupport = false;
+  };
 
   tidylib = buildPythonPackage rec {
     version = "0.2.4";
@@ -22250,11 +22267,11 @@ EOF
   };
 
   waitress = buildPythonPackage rec {
-    name = "waitress-0.8.9";
+    name = "waitress-1.0.2";
 
     src = pkgs.fetchurl {
       url = "mirror://pypi/w/waitress/${name}.tar.gz";
-      sha256 = "826527dc9d334ed4ed76cdae672fdcbbccf614186657db71679ab58df869458a";
+      sha256 = "0pw6yyxi348r2xpq3ykqnf7gwi881azv2422d2ixb0xi5jws2ky7";
     };
 
     doCheck = false;
@@ -22265,6 +22282,8 @@ EOF
     };
   };
 
+  waitress-django = callPackage ../development/python-modules/waitress-django { };
+
   webassets = buildPythonPackage rec {
     name = "webassets-${version}";
     version = "0.12.1";
@@ -23457,7 +23476,7 @@ EOF
 
     src = pkgs.fetchurl {
       url = "mirror://pypi/w/whisper/${name}.tar.gz";
-      sha256 = "1chkphxwnwvy2cs7jc2h2i0lqqvi9jx6vqj3ly88lwk7m35r4ss2";
+      sha256 = "1v1bi3fl1i6p4z4ki692bykrkw6907dn3mfq0151f70lvi3zpns3";
     };
 
     # error: invalid command 'test'
@@ -23524,7 +23543,7 @@ EOF
 
     src = pkgs.fetchurl {
       url = "mirror://pypi/c/carbon/${name}.tar.gz";
-      sha256 = "f01db6d37726c6fc0a8aaa66a7bf14436b0dd0d62ef3c20ecb31605a4d365d2e";
+      sha256 = "142smpmgbnjinvfb6s4ijazish4vfgzyd8zcmdkh55y051fkixkn";
     };
 
     propagatedBuildInputs = with self; [ whisper txamqp zope_interface twisted ];
@@ -23739,10 +23758,13 @@ EOF
 
     src = pkgs.fetchurl rec {
       url = "mirror://pypi/g/graphite-web/${name}.tar.gz";
-      sha256 = "1c0kclbv8shv9nvjx19wqm4asia58s3qmd9fapchc6y9fjpjax6q";
+      sha256 = "0q8bwlj75jqyzmazfsi5sa26xl58ssa8wdxm2l4j0jqyn8xpfnmc";
     };
 
-    propagatedBuildInputs = with self; [ django django_tagging_0_3 whisper pycairo ldap memcached pytz ];
+    propagatedBuildInputs = with self; [
+      django_1_8 django_tagging_0_4_3 whisper pycairo cairocffi
+      ldap memcached pytz urllib3 scandir
+    ];
 
     postInstall = ''
       wrapProgram $out/bin/run-graphite-devel-server.py \
@@ -23750,10 +23772,20 @@ EOF
     '';
 
     preConfigure = ''
-      substituteInPlace webapp/graphite/thirdparty/pytz/__init__.py --replace '/usr/share/zoneinfo' '/etc/zoneinfo'
-      substituteInPlace webapp/graphite/settings.py --replace "join(WEBAPP_DIR, 'content')" "join('$out', 'webapp', 'content')"
-      cp webapp/graphite/manage.py bin/manage-graphite.py
-      substituteInPlace bin/manage-graphite.py --replace 'settings' 'graphite.settings'
+      # graphite is configured by storing a local_settings.py file inside the
+      # graphite python package. Since that package is stored in the immutable
+      # Nix store we can't modify it. So how do we configure graphite?
+      #
+      # First of all we rename "graphite.local_settings" to
+      # "graphite_local_settings" so that the settings are not looked up in the
+      # graphite package anymore. Secondly we place a directory containing a
+      # graphite_local_settings.py on the PYTHONPATH in the graphite module
+      # <nixpkgs/nixos/modules/services/monitoring/graphite.nix>.
+      substituteInPlace webapp/graphite/settings.py \
+        --replace "graphite.local_settings" " graphite_local_settings"
+
+      substituteInPlace webapp/graphite/settings.py \
+        --replace "join(WEBAPP_DIR, 'content')" "join('$out', 'webapp', 'content')"
     '';
 
     # error: invalid command 'test'
@@ -25963,14 +25995,20 @@ EOF
 
   tensorflow-tensorboard = callPackage ../development/python-modules/tensorflow-tensorboard { };
 
-  tensorflow = self.tensorflowWithoutCuda;
+  tensorflow = callPackage ../development/python-modules/tensorflow rec {
+    bazel = pkgs.bazel_0_4;
+    cudaSupport = pkgs.config.cudaSupport or false;
+    inherit (pkgs.linuxPackages) nvidia_x11;
+    cudatoolkit = pkgs.cudatoolkit8;
+    cudnn = pkgs.cudnn6_cudatoolkit8;
+  };
 
-  tensorflowWithoutCuda = callPackage ../development/python-modules/tensorflow { };
+  tensorflowWithoutCuda = self.tensorflow.override {
+    cudaSupport = false;
+  };
 
-  tensorflowWithCuda = callPackage ../development/python-modules/tensorflow {
+  tensorflowWithCuda = self.tensorflow.override {
     cudaSupport = true;
-    cudatoolkit = pkgs.cudatoolkit8;
-    cudnn = pkgs.cudnn60_cudatoolkit80;
   };
 
   tflearn = buildPythonPackage rec {