about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRobin Gloster <mail@glob.in>2016-08-16 07:54:01 +0000
committerRobin Gloster <mail@glob.in>2016-08-16 07:54:01 +0000
commit33e1c78ae3681719b389d4ead425afa4433f445d (patch)
tree015a86dbeb3b745e5daf876c184ccbd6b91f2db2
parent1747d28e5ada05ec07c4b1d35048ea5b194bde64 (diff)
parent888efed972d95e1f2bc31e4394ff841f0690d216 (diff)
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
-rw-r--r--doc/languages-frameworks/python.md4
-rw-r--r--lib/maintainers.nix3
-rw-r--r--nixos/doc/manual/configuration/grsecurity.xml5
-rw-r--r--nixos/lib/make-disk-image.nix5
-rw-r--r--nixos/modules/security/grsecurity.nix2
-rw-r--r--nixos/modules/services/backup/crashplan.nix2
-rw-r--r--nixos/modules/services/misc/autofs.nix9
-rw-r--r--nixos/modules/services/networking/ejabberd.nix29
-rw-r--r--nixos/modules/services/networking/networkmanager.nix12
-rw-r--r--nixos/modules/services/web-servers/phpfpm/default.nix2
-rw-r--r--nixos/tests/ecryptfs.nix4
-rw-r--r--pkgs/applications/audio/guitarix/default.nix22
-rw-r--r--pkgs/applications/audio/morituri/default.nix18
-rw-r--r--pkgs/applications/audio/picard/default.nix12
-rw-r--r--pkgs/applications/editors/nano/default.nix4
-rw-r--r--pkgs/applications/graphics/screencloud/default.nix6
-rw-r--r--pkgs/applications/graphics/yed/default.nix5
-rw-r--r--pkgs/applications/misc/dmenu/default.nix3
-rw-r--r--pkgs/applications/misc/gramps/default.nix9
-rw-r--r--pkgs/applications/misc/mysql-workbench/default.nix7
-rw-r--r--pkgs/applications/misc/octoprint/0001-Don-t-use-static-library.patch113
-rw-r--r--pkgs/applications/misc/octoprint/default.nix35
-rw-r--r--pkgs/applications/misc/octoprint/m33-fio-one-library.patch161
-rw-r--r--pkgs/applications/misc/octoprint/plugins.nix129
-rw-r--r--pkgs/applications/misc/rofi/default.nix16
-rw-r--r--pkgs/applications/misc/rxvt_unicode-plugins/urxvt-tabbedex/default.nix19
-rw-r--r--pkgs/applications/networking/browsers/firefox-bin/default.nix2
-rw-r--r--pkgs/applications/networking/browsers/midori/default.nix33
-rw-r--r--pkgs/applications/networking/browsers/qutebrowser/default.nix39
-rw-r--r--pkgs/applications/networking/cluster/marathon/default.nix6
-rw-r--r--pkgs/applications/networking/instant-messengers/blink/default.nix4
-rw-r--r--pkgs/applications/networking/instant-messengers/pybitmessage/default.nix6
-rw-r--r--pkgs/applications/networking/instant-messengers/telegram/tdesktop/default.nix31
-rw-r--r--pkgs/applications/networking/mailreaders/claws-mail/default.nix4
-rw-r--r--pkgs/applications/networking/syncthing/default.nix4
-rw-r--r--pkgs/applications/office/impressive/default.nix12
-rw-r--r--pkgs/applications/search/catfish/default.nix2
-rw-r--r--pkgs/applications/version-management/meld/default.nix20
-rw-r--r--pkgs/applications/version-management/reposurgeon/default.nix22
-rw-r--r--pkgs/applications/version-management/src/default.nix2
-rw-r--r--pkgs/applications/video/byzanz/default.nix5
-rw-r--r--pkgs/applications/video/miro/default.nix27
-rw-r--r--pkgs/applications/video/qarte/default.nix7
-rw-r--r--pkgs/applications/virtualization/tini/default.nix4
-rw-r--r--pkgs/build-support/kernel/modules-closure.sh2
-rw-r--r--pkgs/data/fonts/emojione/default.nix4
-rw-r--r--pkgs/data/misc/wireless-regdb/default.nix4
-rw-r--r--pkgs/desktops/gnome-3/3.20/core/gnome-control-center/default.nix1
-rw-r--r--pkgs/desktops/gnome-3/3.20/core/vte/default.nix4
-rw-r--r--pkgs/desktops/kde-4.14/applications/kate.nix4
-rw-r--r--pkgs/desktops/kde-4.14/kdebindings/pykde4.nix9
-rw-r--r--pkgs/desktops/kde-4.14/kdeutils/print-manager.nix4
-rw-r--r--pkgs/desktops/kde-5/plasma/breeze-gtk.nix1
-rw-r--r--pkgs/development/haskell-modules/configuration-common.nix3
-rw-r--r--pkgs/development/interpreters/renpy/default.nix6
-rw-r--r--pkgs/development/libraries/armadillo/default.nix7
-rw-r--r--pkgs/development/libraries/armadillo/use-OpenBLAS-as-LAPACK.patch14
-rw-r--r--pkgs/development/libraries/cppzmq/default.nix6
-rw-r--r--pkgs/development/libraries/folly/default.nix12
-rw-r--r--pkgs/development/libraries/icu/default.nix4
-rw-r--r--pkgs/development/libraries/jemalloc/default.nix5
-rw-r--r--pkgs/development/libraries/libbsd/default.nix6
-rw-r--r--pkgs/development/libraries/libdynd/default.nix28
-rw-r--r--pkgs/development/libraries/libvdpau-va-gl/default.nix4
-rw-r--r--pkgs/development/libraries/science/math/ipopt/default.nix8
-rw-r--r--pkgs/development/libraries/xgboost/default.nix8
-rw-r--r--pkgs/development/python-modules/pyqt/4.x.nix5
-rw-r--r--pkgs/development/tools/java/visualvm/default.nix42
-rw-r--r--pkgs/development/tools/pypi2nix/default.nix22
-rw-r--r--pkgs/development/tools/pypi2nix/deps.nix8
-rw-r--r--pkgs/games/crawl/default.nix6
-rw-r--r--pkgs/games/dwarf-fortress/default.nix4
-rw-r--r--pkgs/games/dwarf-fortress/dfhack/default.nix12
-rw-r--r--pkgs/games/dwarf-fortress/dfhack/use-system-libraries.patch42
-rw-r--r--pkgs/games/dwarf-fortress/game.nix24
-rw-r--r--pkgs/games/dwarf-fortress/themes/cla.nix6
-rw-r--r--pkgs/games/dwarf-fortress/themes/phoebus.nix6
-rw-r--r--pkgs/games/dwarf-fortress/unfuck.nix12
-rw-r--r--pkgs/games/factorio/fetch.nix4
-rw-r--r--pkgs/games/factorio/fetch.sh21
-rw-r--r--pkgs/games/mnemosyne/default.nix4
-rw-r--r--pkgs/games/quake3/ioquake/default.nix6
-rw-r--r--pkgs/games/steam/runtime-generated.nix18
-rw-r--r--pkgs/games/steam/runtime.nix2
-rw-r--r--pkgs/games/the-powder-toy/default.nix6
-rw-r--r--pkgs/games/wesnoth/dev.nix4
-rw-r--r--pkgs/misc/drivers/hplip/3.15.9.nix2
-rw-r--r--pkgs/misc/drivers/hplip/default.nix2
-rw-r--r--pkgs/misc/drivers/m33-linux/default.nix (renamed from pkgs/misc/drivers/m3d-linux/default.nix)10
-rw-r--r--pkgs/misc/emulators/wine/sources.nix6
-rw-r--r--pkgs/misc/frescobaldi/default.nix2
-rw-r--r--pkgs/misc/long-shebang/default.nix6
-rw-r--r--pkgs/os-specific/linux/android-udev-rules/default.nix8
-rw-r--r--pkgs/os-specific/linux/autofs/default.nix30
-rw-r--r--pkgs/os-specific/linux/btfs/default.nix6
-rw-r--r--pkgs/os-specific/linux/kernel/linux-4.5.nix19
-rw-r--r--pkgs/os-specific/linux/kernel/linux-4.6.nix4
-rw-r--r--pkgs/os-specific/linux/kernel/linux-grsecurity.nix7
-rw-r--r--pkgs/os-specific/linux/kernel/patches.nix6
-rw-r--r--pkgs/os-specific/linux/pam_pgsql/default.nix2
-rw-r--r--pkgs/os-specific/linux/spl/default.nix8
-rw-r--r--pkgs/os-specific/linux/systemd/cryptsetup-generator.nix4
-rw-r--r--pkgs/os-specific/linux/wireguard/default.nix23
-rwxr-xr-xpkgs/servers/apache-kafka/default.nix4
-rw-r--r--pkgs/servers/caddy/default.nix20
-rw-r--r--pkgs/servers/caddy/deps.json326
-rw-r--r--pkgs/servers/emby/default.nix4
-rw-r--r--pkgs/servers/mail/dspam/default.nix2
-rw-r--r--pkgs/servers/rpcbind/default.nix2
-rw-r--r--pkgs/servers/sql/mariadb/default.nix15
-rw-r--r--pkgs/servers/uwsgi/default.nix2
-rw-r--r--pkgs/servers/x11/xorg/xcb-util-xrm.nix22
-rw-r--r--pkgs/servers/xmpp/ejabberd/default.nix7
-rw-r--r--pkgs/tools/X11/primus/lib.nix4
-rw-r--r--pkgs/tools/X11/virtualgl/lib.nix2
-rw-r--r--pkgs/tools/X11/xpra/default.nix9
-rw-r--r--pkgs/tools/backup/duplicity/default.nix7
-rw-r--r--pkgs/tools/backup/obnam/default.nix6
-rw-r--r--pkgs/tools/bluetooth/blueman/default.nix2
-rw-r--r--pkgs/tools/filesystems/bcache-tools/default.nix2
-rw-r--r--pkgs/tools/graphics/imgurbash2/default.nix2
-rw-r--r--pkgs/tools/misc/debian-devscripts/default.nix11
-rw-r--r--pkgs/tools/misc/grub4dos/default.nix6
-rw-r--r--pkgs/tools/misc/svtplay-dl/default.nix10
-rw-r--r--pkgs/tools/networking/logmein-hamachi/default.nix11
-rw-r--r--pkgs/tools/networking/network-manager/default.nix2
-rw-r--r--pkgs/tools/networking/openvpn/update-resolv-conf.nix27
-rw-r--r--pkgs/tools/networking/wicd/default.nix30
-rw-r--r--pkgs/tools/security/fail2ban/default.nix5
-rw-r--r--pkgs/tools/security/gnupg/21.nix6
-rw-r--r--pkgs/tools/security/gnupg/fix-gpgsm-linking.patch11
-rw-r--r--pkgs/tools/security/knockknock/default.nix6
-rw-r--r--pkgs/tools/security/nmap/default.nix11
-rw-r--r--pkgs/tools/security/volatility/default.nix8
-rw-r--r--pkgs/tools/typesetting/tex/texlive-new/pkgs.nix2
-rw-r--r--pkgs/tools/video/mjpegtools/default.nix2
-rw-r--r--pkgs/top-level/aliases.nix6
-rw-r--r--pkgs/top-level/all-packages.nix289
-rw-r--r--pkgs/top-level/python-packages.nix119
139 files changed, 1297 insertions, 1112 deletions
diff --git a/doc/languages-frameworks/python.md b/doc/languages-frameworks/python.md
index 9bce49805174d..eb85dd59e6b95 100644
--- a/doc/languages-frameworks/python.md
+++ b/doc/languages-frameworks/python.md
@@ -566,7 +566,7 @@ running `nix-shell` with the following `shell.nix`
     with import <nixpkgs> {};
 
     (python3.buildEnv.override {
-      extraLibs = with python3Packages; [ numpy requests ];
+      extraLibs = with python3Packages; [ numpy requests2 ];
     }).env
 
 will drop you into a shell where Python will have the
@@ -605,7 +605,7 @@ attribute. The `shell.nix` file from the previous section can thus be also writt
 
     with import <nixpkgs> {};
 
-    (python33.withPackages (ps: [ps.numpy ps.requests])).env
+    (python33.withPackages (ps: [ps.numpy ps.requests2])).env
 
 In contrast to `python.buildEnv`, `python.withPackages` does not support the more advanced options
 such as `ignoreCollisions = true` or `postBuild`. If you need them, you have to use `python.buildEnv`.
diff --git a/lib/maintainers.nix b/lib/maintainers.nix
index 7f6c823d68b95..af43ae639ea6f 100644
--- a/lib/maintainers.nix
+++ b/lib/maintainers.nix
@@ -240,7 +240,7 @@
   mathnerd314 = "Mathnerd314 <mathnerd314.gph+hs@gmail.com>";
   matthiasbeyer = "Matthias Beyer <mail@beyermatthias.de>";
   maurer = "Matthew Maurer <matthew.r.maurer+nix@gmail.com>";
-  mbakke = "Marius Bakke <ymse@tuta.io>";
+  mbakke = "Marius Bakke <mbakke@fastmail.com>";
   matthewbauer = "Matthew Bauer <mjbauer95@gmail.com>";
   mbe = "Brandon Edens <brandonedens@gmail.com>";
   mboes = "Mathieu Boespflug <mboes@tweag.net>";
@@ -248,6 +248,7 @@
   meditans = "Carlo Nucera <meditans@gmail.com>";
   meisternu = "Matt Miemiec <meister@krutt.org>";
   michaelpj = "Michael Peyton Jones <michaelpj@gmail.com>";
+  michalrus = "Michal Rus <m@michalrus.com>";
   michelk = "Michel Kuhlmann <michel@kuhlmanns.info>";
   mimadrid = "Miguel Madrid <mimadrid@ucm.es>";
   mingchuan = "Ming Chuan <ming@culpring.com>";
diff --git a/nixos/doc/manual/configuration/grsecurity.xml b/nixos/doc/manual/configuration/grsecurity.xml
index 3c17fc19397ff..28415e89bfab6 100644
--- a/nixos/doc/manual/configuration/grsecurity.xml
+++ b/nixos/doc/manual/configuration/grsecurity.xml
@@ -265,6 +265,11 @@
   <sect1 xml:id="sec-grsec-issues"><title>Issues and work-arounds</title>
 
   <itemizedlist>
+    <listitem><para>User namespaces require <literal>CAP_SYS_ADMIN</literal>:
+    consequently, unprivileged namespaces are unsupported. Applications that
+    rely on namespaces for sandboxing must use a privileged helper. For chromium
+    there is <option>security.chromiumSuidSandbox.enable</option>.</para></listitem>
+
     <listitem><para>Access to EFI runtime services is disabled by default:
     this plugs a potential code injection attack vector; use
     <option>security.grsecurity.disableEfiRuntimeServices</option> to override
diff --git a/nixos/lib/make-disk-image.nix b/nixos/lib/make-disk-image.nix
index 63666c99b2308..9f8ec41925643 100644
--- a/nixos/lib/make-disk-image.nix
+++ b/nixos/lib/make-disk-image.nix
@@ -12,6 +12,9 @@
   # directly.
   partitioned ? true
 
+  # Whether to invoke switch-to-configuration boot during image creation
+, installBootLoader ? true
+
 , # The root file system type.
   fsType ? "ext4"
 
@@ -108,7 +111,7 @@ pkgs.vmTools.runInLinuxVM (
       # Generate the GRUB menu.
       ln -s vda /dev/xvda
       ln -s vda /dev/sda
-      chroot /mnt ${config.system.build.toplevel}/bin/switch-to-configuration boot
+      ${optionalString installBootLoader "chroot /mnt ${config.system.build.toplevel}/bin/switch-to-configuration boot"}
 
       umount /mnt/proc /mnt/dev /mnt/sys
       umount /mnt
diff --git a/nixos/modules/security/grsecurity.nix b/nixos/modules/security/grsecurity.nix
index 60e9058dd69e2..9a2f62a14889c 100644
--- a/nixos/modules/security/grsecurity.nix
+++ b/nixos/modules/security/grsecurity.nix
@@ -119,11 +119,13 @@ in
       "kernel.grsecurity.chroot_deny_chroot" = mkForce 0;
       "kernel.grsecurity.chroot_deny_mount" = mkForce 0;
       "kernel.grsecurity.chroot_deny_pivot" = mkForce 0;
+      "kernel.grsecurity.chroot_deny_chmod" = mkForce 0;
     } // optionalAttrs containerSupportRequired {
       # chroot(2) restrictions that conflict with NixOS lightweight containers
       "kernel.grsecurity.chroot_deny_chmod" = mkForce 0;
       "kernel.grsecurity.chroot_deny_mount" = mkForce 0;
       "kernel.grsecurity.chroot_restrict_nice" = mkForce 0;
+      "kernel.grsecurity.chroot_caps" = mkForce 0;
     };
 
     assertions = [
diff --git a/nixos/modules/services/backup/crashplan.nix b/nixos/modules/services/backup/crashplan.nix
index a69526f968b06..38cf8eb72fb83 100644
--- a/nixos/modules/services/backup/crashplan.nix
+++ b/nixos/modules/services/backup/crashplan.nix
@@ -28,7 +28,7 @@ with lib;
       description = "CrashPlan Backup Engine";
 
       wantedBy = [ "multi-user.target" ];
-      after    = [ "network.target" ];
+      after    = [ "network.target" "local-fs.target" ];
 
       preStart = ''
         ensureDir() {
diff --git a/nixos/modules/services/misc/autofs.nix b/nixos/modules/services/misc/autofs.nix
index 8913030e0ea2f..18f0c3eb83d57 100644
--- a/nixos/modules/services/misc/autofs.nix
+++ b/nixos/modules/services/misc/autofs.nix
@@ -75,9 +75,10 @@ in
     boot.kernelModules = [ "autofs4" ];
 
     systemd.services.autofs =
-      { description = "Filesystem automounter";
+      { description = "Automounts filesystems on demand";
+        after = [ "network.target" "ypbind.service" "sssd.service" "network-online.target" ];
+        wants = [ "network-online.target" ];
         wantedBy = [ "multi-user.target" ];
-        after = [ "network.target" ];
 
         preStart = ''
           # There should be only one autofs service managed by systemd, so this should be safe.
@@ -85,7 +86,9 @@ in
         '';
 
         serviceConfig = {
-          ExecStart = "${pkgs.autofs5}/sbin/automount ${if cfg.debug then "-d" else ""} -f -t ${builtins.toString cfg.timeout} ${autoMaster} ${if cfg.debug then "-l7" else ""}";
+          Type = "forking";
+          PIDFile = "/run/autofs.pid";
+          ExecStart = "${pkgs.autofs5}/bin/automount ${optionalString cfg.debug "-d"} -p /run/autofs.pid -t ${builtins.toString cfg.timeout} ${autoMaster}";
           ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
         };
       };
diff --git a/nixos/modules/services/networking/ejabberd.nix b/nixos/modules/services/networking/ejabberd.nix
index 8ecc16257db81..82ed7fc4a8377 100644
--- a/nixos/modules/services/networking/ejabberd.nix
+++ b/nixos/modules/services/networking/ejabberd.nix
@@ -111,10 +111,10 @@ in {
       description = "ejabberd server";
       wantedBy = [ "multi-user.target" ];
       after = [ "network.target" ];
-      path = [ pkgs.findutils pkgs.coreutils ] ++ lib.optional cfg.imagemagick pkgs.imagemagick;
+      path = [ pkgs.findutils pkgs.coreutils pkgs.runit ] ++ lib.optional cfg.imagemagick pkgs.imagemagick;
 
       serviceConfig = {
-        Type = "forking";
+        ExecStart = ''${ectl} foreground'';
         # FIXME: runit is used for `chpst` -- can we get rid of this?
         ExecStop = ''${pkgs.runit}/bin/chpst -u "${cfg.user}:${cfg.group}" ${ectl} stop'';
         ExecReload = ''${pkgs.runit}/bin/chpst -u "${cfg.user}:${cfg.group}" ${ectl} reload_config'';
@@ -132,29 +132,24 @@ in {
 
         mkdir -p -m750 "${cfg.spoolDir}"
         chown -R "${cfg.user}:${cfg.group}" "${cfg.spoolDir}"
-      '';
-
-      script = ''
-        [ -z "$(ls -A '${cfg.spoolDir}')" ] && firstRun=1
 
-        ${ectl} start
+        if [ -z "$(ls -A '${cfg.spoolDir}')" ]; then
+          touch "${cfg.spoolDir}/.firstRun"
+        fi
+      '';
 
-        count=0
+      postStart = ''
         while ! ${ectl} status >/dev/null 2>&1; do
-          if [ $count -eq 30 ]; then
-            echo "ejabberd server hasn't started in 30 seconds, giving up"
-            exit 1
-          fi
-
-          count=$((count++))
-          sleep 1
+          if ! kill -0 "$MAINPID"; then exit 1; fi
+          sleep 0.1
         done
 
-        if [ -n "$firstRun" ]; then
+        if [ -e "${cfg.spoolDir}/.firstRun" ]; then
+          rm "${cfg.spoolDir}/.firstRun"
           for src in ${dumps}; do
             find "$src" -type f | while read dump; do
               echo "Loading configuration dump at $dump"
-              ${ectl} load "$dump"
+              chpst -u "${cfg.user}:${cfg.group}" ${ectl} load "$dump"
             done
           done
         fi
diff --git a/nixos/modules/services/networking/networkmanager.nix b/nixos/modules/services/networking/networkmanager.nix
index 8aac1360526f7..d198e3bfc02c3 100644
--- a/nixos/modules/services/networking/networkmanager.nix
+++ b/nixos/modules/services/networking/networkmanager.nix
@@ -235,19 +235,13 @@ in {
 
     systemd.packages = cfg.packages;
 
-    # Create an initialisation service that both starts
-    # NetworkManager when network.target is reached,
-    # and sets up necessary directories for NM.
-    systemd.services."networkmanager-init" = {
-      description = "NetworkManager initialisation";
+    systemd.services."network-manager" = {
       wantedBy = [ "network.target" ];
-      wants = [ "network-manager.service" ];
-      before = [ "network-manager.service" ];
-      script = ''
+
+      preStart = ''
         mkdir -m 700 -p /etc/NetworkManager/system-connections
         mkdir -m 755 -p ${stateDirs}
       '';
-      serviceConfig.Type = "oneshot";
     };
 
     # Turn off NixOS' network management
diff --git a/nixos/modules/services/web-servers/phpfpm/default.nix b/nixos/modules/services/web-servers/phpfpm/default.nix
index 819d0c251bf32..29cfbb8e9a088 100644
--- a/nixos/modules/services/web-servers/phpfpm/default.nix
+++ b/nixos/modules/services/web-servers/phpfpm/default.nix
@@ -105,7 +105,7 @@ in {
     };
   };
 
-  config = mkIf (cfg.pools != {}) {
+  config = mkIf (cfg.pools != {} || cfg.poolConfigs != {}) {
 
     systemd.services.phpfpm = {
       wantedBy = [ "multi-user.target" ];
diff --git a/nixos/tests/ecryptfs.nix b/nixos/tests/ecryptfs.nix
index eceb25a0deac5..db800c7bb2c25 100644
--- a/nixos/tests/ecryptfs.nix
+++ b/nixos/tests/ecryptfs.nix
@@ -30,7 +30,7 @@ import ./make-test.nix ({ pkgs, ... }:
     $machine->sleep(2);
 
     # Why do I need to do this??
-    $machine->succeed("su alice -c ecryptfs-umount-private");
+    $machine->succeed("su alice -c ecryptfs-umount-private || true");
     $machine->sleep(1);
     $machine->fail("mount | grep ecryptfs"); # check that encrypted home is not mounted
 
@@ -53,7 +53,7 @@ import ./make-test.nix ({ pkgs, ... }:
     $machine->sleep(2);
 
     # Why do I need to do this??
-    $machine->succeed("su alice -c ecryptfs-umount-private");
+    $machine->succeed("su alice -c ecryptfs-umount-private || true");
     $machine->sleep(1);
 
     # Check that the filesystem is not accessible
diff --git a/pkgs/applications/audio/guitarix/default.nix b/pkgs/applications/audio/guitarix/default.nix
index 7af7fbb4a2598..af213f1a8354e 100644
--- a/pkgs/applications/audio/guitarix/default.nix
+++ b/pkgs/applications/audio/guitarix/default.nix
@@ -1,7 +1,8 @@
 { stdenv, fetchurl, gettext, intltool, pkgconfig, python
-, avahi, bluez, boost, eigen, fftw, glib, glibmm, gtk, gtkmm, libjack2
+, avahi, bluez, boost, eigen, fftw, glib, glib_networking
+, glibmm, gsettings_desktop_schemas, gtk, gtkmm, libjack2
 , ladspaH, librdf, libsndfile, lilv, lv2, serd, sord, sratom
-, webkitgtk2, zita-convolver, zita-resampler
+, webkitgtk2, wrapGAppsHook, zita-convolver, zita-resampler
 , optimizationSupport ? false # Enable support for native CPU extensions
 }:
 
@@ -11,19 +12,20 @@ in
 
 stdenv.mkDerivation rec {
   name = "guitarix-${version}";
-  version = "0.34.0";
+  version = "0.35.1";
 
   src = fetchurl {
-    url = "mirror://sourceforge/guitarix/guitarix2-${version}.tar.bz2";
-    sha256 = "0pamaq8iybsaglq6y1m1rlmz4wgbs2r6m24bj7x4fwg4grjvzjl8";
+    url = "mirror://sourceforge/guitarix/guitarix2-${version}.tar.xz";
+    sha256 = "066qva1zk63qw60s0vbi9g9jh22ljw67p91pk82kv11gw24h3vg6";
   };
 
-  nativeBuildInputs = [ gettext intltool pkgconfig python ];
+  nativeBuildInputs = [ gettext intltool wrapGAppsHook pkgconfig python ];
 
   buildInputs = [
-    avahi bluez boost eigen fftw glib glibmm gtk gtkmm libjack2
-    ladspaH librdf libsndfile lilv lv2 serd sord sratom
-    webkitgtk2 zita-convolver zita-resampler
+    avahi bluez boost eigen fftw glib glibmm glib_networking.out
+    gsettings_desktop_schemas gtk gtkmm libjack2 ladspaH librdf
+    libsndfile lilv lv2 serd sord sratom webkitgtk2 zita-convolver
+    zita-resampler
   ];
 
   configureFlags = [
@@ -39,7 +41,7 @@ stdenv.mkDerivation rec {
 
   installPhase = ''python waf install'';
 
-  meta = with stdenv.lib; { 
+  meta = with stdenv.lib; {
     description = "A virtual guitar amplifier for Linux running with JACK";
     longDescription = ''
         guitarix is a virtual guitar amplifier for Linux running with
diff --git a/pkgs/applications/audio/morituri/default.nix b/pkgs/applications/audio/morituri/default.nix
index 7d7b4e47fad6b..b9a38ab9d03b0 100644
--- a/pkgs/applications/audio/morituri/default.nix
+++ b/pkgs/applications/audio/morituri/default.nix
@@ -1,8 +1,10 @@
-{ stdenv, fetchgit, python, pythonPackages, cdparanoia, cdrdao
-, pygobject, gst_python, gst_plugins_base, gst_plugins_good
-, setuptools, utillinux, makeWrapper, substituteAll, autoreconfHook }:
+{ stdenv, fetchgit, pythonPackages, cdparanoia, cdrdao
+, gst_python, gst_plugins_base, gst_plugins_good
+, utillinux, makeWrapper, substituteAll, autoreconfHook }:
 
-stdenv.mkDerivation rec {
+let
+  inherit (pythonPackages) python;
+in stdenv.mkDerivation rec {
   name = "morituri-${version}";
   version = "0.2.3.20151109";
   namePrefix = "";
@@ -14,10 +16,10 @@ stdenv.mkDerivation rec {
     sha256 = "1sl5y5j3gdbynf2v0gf9dwd2hzawj8lm8ywadid7qm34yn8lx12k";
   };
 
-  pythonPath = [
-    pygobject gst_python pythonPackages.musicbrainzngs
-    pythonPackages.pycdio pythonPackages.pyxdg setuptools
-    pythonPackages.CDDB
+  pythonPath = with pythonPackages; [
+    pygobject gst_python musicbrainzngs
+    pycdio pyxdg setuptools
+    CDDB
   ];
 
   nativeBuildInputs = [ autoreconfHook ];
diff --git a/pkgs/applications/audio/picard/default.nix b/pkgs/applications/audio/picard/default.nix
index 2373bbc549d57..046789119ec67 100644
--- a/pkgs/applications/audio/picard/default.nix
+++ b/pkgs/applications/audio/picard/default.nix
@@ -1,10 +1,10 @@
-{ stdenv, buildPythonApplication, fetchurl, gettext
+{ stdenv, pythonPackages, fetchurl, gettext
 , pkgconfig, libofa, ffmpeg, chromaprint
-, pyqt4, mutagen, python-libdiscid
 }:
 
-let version = "1.3.2"; in
-buildPythonApplication {
+let
+  version = "1.3.2";
+in pythonPackages.buildPythonApplication {
   name = "picard-${version}";
   namePrefix = "";
 
@@ -20,10 +20,10 @@ buildPythonApplication {
     gettext
   ];
 
-  propagatedBuildInputs = [
+  propagatedBuildInputs = with pythonPackages; [
     pyqt4
     mutagen
-    python-libdiscid
+    discid
   ];
 
   installPhase = ''
diff --git a/pkgs/applications/editors/nano/default.nix b/pkgs/applications/editors/nano/default.nix
index 62da04577f70b..dee2d6f0dff33 100644
--- a/pkgs/applications/editors/nano/default.nix
+++ b/pkgs/applications/editors/nano/default.nix
@@ -12,10 +12,10 @@ with stdenv.lib;
 
 stdenv.mkDerivation rec {
   name = "nano-${version}";
-  version = "2.6.2";
+  version = "2.6.3";
   src = fetchurl {
     url = "https://nano-editor.org/dist/v2.6/${name}.tar.gz";
-    sha256 = "11c9iqiah4q7q3ndn7z9192a796vp4fffkg27s6q1dn8avp06dj5";
+    sha256 = "00ym3zws1vdds726drgr5wj14mjn18d96ghn6vjci0915zhm8h2g";
   };
   nativeBuildInputs = [ texinfo ] ++ optional enableNls gettext;
   buildInputs = [ ncurses ];
diff --git a/pkgs/applications/graphics/screencloud/default.nix b/pkgs/applications/graphics/screencloud/default.nix
index 5934febb99996..6f2b0e34cbb34 100644
--- a/pkgs/applications/graphics/screencloud/default.nix
+++ b/pkgs/applications/graphics/screencloud/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchFromGitHub, cmake, qt4, quazip, qt-mobility, qxt, python, pycrypto, glib }:
+{ stdenv, fetchurl, fetchFromGitHub, cmake, qt4, quazip, qt-mobility, qxt, pythonPackages, glib }:
 
 with stdenv.lib;
 stdenv.mkDerivation rec {
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
     sha256 = "1s0dxa1sa37nvna5nfqdsp294810favj68qb7ghl78qna7zw0cim";
   };
 
-  buildInputs = [ cmake qt4 quazip qt-mobility qxt python pycrypto ];
+  buildInputs = [ cmake qt4 quazip qt-mobility qxt pythonPackages.python pythonPackages.pycrypto ];
 
   patchPhase = ''
     # Required to make the configure script work. Normally, screencloud's
@@ -58,7 +58,7 @@ stdenv.mkDerivation rec {
   postInstall = ''
     patchShebangs $prefix/opt/screencloud/screencloud.sh
     substituteInPlace "$prefix/opt/screencloud/screencloud.sh" --replace "/opt" "$prefix/opt"
-    sed -i "2 i\export PYTHONPATH=$(toPythonPath ${pycrypto}):\$PYTHONPATH" "$prefix/opt/screencloud/screencloud.sh"
+    sed -i "2 i\export PYTHONPATH=$(toPythonPath ${pythonPackages.pycrypto}):\$PYTHONPATH" "$prefix/opt/screencloud/screencloud.sh"
     mkdir $prefix/bin
     mkdir $prefix/lib
     ln -s $prefix/opt/screencloud/screencloud.sh $prefix/bin/screencloud
diff --git a/pkgs/applications/graphics/yed/default.nix b/pkgs/applications/graphics/yed/default.nix
index 0dad1238876d8..afb48c697b5c8 100644
--- a/pkgs/applications/graphics/yed/default.nix
+++ b/pkgs/applications/graphics/yed/default.nix
@@ -1,12 +1,13 @@
 { stdenv, fetchurl, requireFile, makeWrapper, unzip, jre }:
 
 stdenv.mkDerivation rec {
-  name = "yEd-3.15.0.2";
+  name = "yEd-${version}";
+  version = "3.16.1";
 
   src = requireFile {
     name = "${name}.zip";
     url = "https://www.yworks.com/en/products/yfiles/yed/";
-    sha256 = "c60e4868f267303ee8b6fc2587beb4cc846f32bd8a6a557b77e01f0d8039aa4d";
+    sha256 = "0h7ykcpvsikjfap51hpcz6z814riiwyps585j2i1yv9dmsbqdi7j";
   };
 
   nativeBuildInputs = [ unzip makeWrapper ];
diff --git a/pkgs/applications/misc/dmenu/default.nix b/pkgs/applications/misc/dmenu/default.nix
index b0879599833b6..1dc9fe5e2026e 100644
--- a/pkgs/applications/misc/dmenu/default.nix
+++ b/pkgs/applications/misc/dmenu/default.nix
@@ -13,7 +13,8 @@ stdenv.mkDerivation rec {
   inherit patches;
 
   postPatch = ''
-    sed -ri -e 's!\<(dmenu|stest)\>!'"$out/bin"'/&!g' dmenu_run
+    sed -ri -e 's!\<(dmenu|dmenu_path|stest)\>!'"$out/bin"'/&!g' dmenu_run
+    sed -ri -e 's!\<stest\>!'"$out/bin"'/&!g' dmenu_path
   '';
 
   preConfigure = ''
diff --git a/pkgs/applications/misc/gramps/default.nix b/pkgs/applications/misc/gramps/default.nix
index 79393eee7f11e..d750aea01ef0c 100644
--- a/pkgs/applications/misc/gramps/default.nix
+++ b/pkgs/applications/misc/gramps/default.nix
@@ -1,10 +1,11 @@
-{ stdenv, fetchurl, gtk3, pythonPackages, python, pycairo, pygobject3, intltool,
+{ stdenv, fetchurl, gtk3, pythonPackages, intltool,
   pango, gsettings_desktop_schemas }:
 
-pythonPackages.buildPythonApplication rec {
+let
+  inherit (pythonPackages) python buildPythonApplication;
+in buildPythonApplication rec {
   version = "4.1.1";
   name = "gramps-${version}";
-  namePrefix = "";
 
   buildInputs = [ intltool gtk3 ];
 
@@ -16,7 +17,7 @@ pythonPackages.buildPythonApplication rec {
     sha256 = "0jdps7yx2mlma1hdj64wssvnqd824xdvw0bmn2dnal5fn3h7h060";
   };
 
-  pythonPath = [ pygobject3 pango pycairo pythonPackages.bsddb ];
+  pythonPath = with pythonPackages; [ pygobject3 pycairo bsddb ] ++ [ pango ];
 
   # Same installPhase as in buildPythonApplication but without --old-and-unmanageble
   # install flag.
diff --git a/pkgs/applications/misc/mysql-workbench/default.nix b/pkgs/applications/misc/mysql-workbench/default.nix
index 056edd801c074..775d344643e37 100644
--- a/pkgs/applications/misc/mysql-workbench/default.nix
+++ b/pkgs/applications/misc/mysql-workbench/default.nix
@@ -3,10 +3,13 @@
 , libctemplate, libglade
 , libiodbc
 , libgnome, libsigcxx, libuuid, libxml2, libzip, lua, mesa, mysql
-, pango, paramiko, pcre, pexpect, pkgconfig, pycrypto, python, sqlite, sudo
+, pango, pcre, pkgconfig, sqlite, sudo
+, pythonPackages
 }:
 
-stdenv.mkDerivation rec {
+let
+  inherit (pythonPackages) pexpect pycrypto python paramiko;
+in stdenv.mkDerivation rec {
   pname = "mysql-workbench";
   version = "5.2.47";
   name = "${pname}-${version}";
diff --git a/pkgs/applications/misc/octoprint/0001-Don-t-use-static-library.patch b/pkgs/applications/misc/octoprint/0001-Don-t-use-static-library.patch
deleted file mode 100644
index 54116b80a6e89..0000000000000
--- a/pkgs/applications/misc/octoprint/0001-Don-t-use-static-library.patch
+++ /dev/null
@@ -1,113 +0,0 @@
-From 0be3198cccf753226758684955f49a32d8d920c0 Mon Sep 17 00:00:00 2001
-From: Nikolay Amiantov <ab@fmap.me>
-Date: Wed, 17 Feb 2016 14:37:31 +0300
-Subject: [PATCH] Don't use static library
-
----
- octoprint_m3dfio/__init__.py   | 67 +-----------------------------------------
- shared library source/Makefile |  6 ++--
- 2 files changed, 5 insertions(+), 68 deletions(-)
-
-diff --git a/octoprint_m3dfio/__init__.py b/octoprint_m3dfio/__init__.py
-index a2ca533..43f178a 100644
---- a/octoprint_m3dfio/__init__.py
-+++ b/octoprint_m3dfio/__init__.py
-@@ -793,72 +793,7 @@ class M3DFioPlugin(
- 		# Set file locations
- 		self.setFileLocations()
- 		
--		# Check if running on Linux
--		if platform.uname()[0].startswith("Linux") :
--		
--			# Check if running on a Raspberry Pi 1
--			if platform.uname()[4].startswith("armv6l") and self.getCpuHardware() == "BCM2708" :
--			
--				# Set shared library
--				self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_arm1176jzf-s.so")
--			
--			# Otherwise check if running on a Raspberry Pi 2 or Raspberry Pi 3
--			elif platform.uname()[4].startswith("armv7l") and self.getCpuHardware() == "BCM2709" :
--			
--				# Set shared library
--				self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_arm_cortex-a7.so")
--			
--			# Otherwise check if running on an ARM7 device
--			elif platform.uname()[4].startswith("armv7") :
--			
--				# Set shared library
--				self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_arm7.so")
--			
--			# Otherwise check if using an i386 or x86-64 device
--			elif platform.uname()[4].endswith("86") or platform.uname()[4].endswith("64") :
--		
--				# Check if Python is running as 32-bit
--				if platform.architecture()[0].startswith("32") :
--				
--					# Set shared library
--					self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_i386.so")
--			
--				# Otherwise check if Python is running as 64-bit
--				elif platform.architecture()[0].startswith("64") :
--				
--					# Set shared library
--					self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_x86-64.so")
--		
--		# Otherwise check if running on Windows and using an i386 or x86-64 device
--		elif platform.uname()[0].startswith("Windows") and (platform.uname()[4].endswith("86") or platform.uname()[4].endswith("64")) :
--		
--			# Check if Python is running as 32-bit
--			if platform.architecture()[0].startswith("32") :
--			
--				# Set shared library
--				self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_i386.dll")
--		
--			# Otherwise check if Python is running as 64-bit
--			elif platform.architecture()[0].startswith("64") :
--			
--				# Set shared library
--				self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_x86-64.dll")
--		
--		# Otherwise check if running on OS X and using an i386 or x86-64 device
--		elif platform.uname()[0].startswith("Darwin") and (platform.uname()[4].endswith("86") or platform.uname()[4].endswith("64")) :
--		
--			# Check if Python is running as 32-bit
--			if platform.architecture()[0].startswith("32") :
--			
--				# Set shared library
--				self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_i386.dylib")
--		
--			# Otherwise check if Python is running as 64-bit
--			elif platform.architecture()[0].startswith("64") :
--			
--				# Set shared library
--				self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_x86-64.dylib")
--		
-+		self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/../../../libpreprocessor.so")
- 		# Check if shared library was set
- 		if self.sharedLibrary :
- 		
-diff --git a/shared library source/Makefile b/shared library source/Makefile
-index 9d015a1..a24f134 100644
---- a/shared library source/Makefile	
-+++ b/shared library source/Makefile	
-@@ -58,13 +58,15 @@ ifeq ($(TARGET_PLATFORM), OSX64)
- 	CFLAGS = -fPIC -m64 -stdlib=libc++ -O3 -Wl,-install_name,$(PROG)$(VER)
- endif
- 
-+PROG = lib$(LIBRARY_NAME).so
-+CC = g++
- SRCS = preprocessor.cpp gcode.cpp vector.cpp
--CFLAGS += -Wall -std=c++11 -fvisibility=hidden -shared
-+CFLAGS = -O3 -fPIC -Wall -std=c++11 -fvisibility=hidden -shared
- 
- all: $(PROG)
- 
- $(PROG):   $(SRCS)
--	$(CC) $(CFLAGS) -o ../octoprint_m3dfio/static/libraries/$(PROG) $(SRCS)
-+	$(CC) $(CFLAGS) -o $(PROG) $(SRCS)
- 
- clean:
- 	rm -f ../octoprint_m3dfio/static/libraries/$(PROG)
--- 
-2.7.1
-
diff --git a/pkgs/applications/misc/octoprint/default.nix b/pkgs/applications/misc/octoprint/default.nix
index 3178ea5684d8f..b39b73c830ffb 100644
--- a/pkgs/applications/misc/octoprint/default.nix
+++ b/pkgs/applications/misc/octoprint/default.nix
@@ -2,41 +2,44 @@
 
 pythonPackages.buildPythonApplication rec {
   name = "OctoPrint-${version}";
-  version = "1.2.10";
+  version = "1.2.15";
 
   src = fetchFromGitHub {
     owner = "foosel";
     repo = "OctoPrint";
     rev = version;
-    sha256 = "1ips1083c4qrfnkssvp1lxrs92svlid29l225ifsymrinpbjawav";
+    sha256 = "0qfragp7n8m7l5l30s5fz1x7xzini2sdh2y3m1ahs7ay8zp4xk56";
   };
 
   # We need old Tornado
   propagatedBuildInputs = with pythonPackages; [
-    awesome-slugify flask_assets watchdog rsa requests2 pkginfo pylru
-    semantic-version flask_principal sarge tornado_4_0_1 werkzeug netaddr flaskbabel
-    netifaces psutil pyserial flask_login pyyaml sockjs-tornado
+    awesome-slugify flask_assets rsa requests2 pkginfo watchdog
+    semantic-version flask_principal werkzeug flaskbabel tornado_4_0_1
+    psutil pyserial flask_login netaddr markdown sockjs-tornado
+    pylru pyyaml sarge feedparser netifaces
   ];
 
+  # Jailbreak dependencies.
+  # Currently broken for new: tornado, pyserial, flask_login
   postPatch = ''
-    # Jailbreak dependencies
     sed -i \
-      -e 's,rsa==,rsa>=,g' \
-      -e 's,sockjs-tornado==,sockjs-tornado>=,g' \
-      -e 's,Flask-Principal==,Flask-Principal>=,g' \
-      -e 's,werkzeug==,werkzeug>=,g' \
-      -e 's,netaddr==,netaddr>=,g' \
-      -e 's,requests==,requests>=,g' \
-      -e 's,netifaces==,netifaces>=,g' \
-      -e 's,psutil==,psutil>=,g' \
-      -e 's,PyYAML==,PyYAML>=,g' \
+      -e 's,werkzeug>=[^"]*,werkzeug,g' \
+      -e 's,requests>=[^"]*,requests,g' \
+      -e 's,pkginfo>=[^"]*,pkginfo,g' \
+      -e 's,semantic_version>=[^"]*,semantic_version,g' \
+      -e 's,psutil>=[^"]*,psutil,g' \
+      -e 's,Flask-Babel>=[^"]*,Flask-Babel,g' \
+      -e 's,Flask-Principal>=[^"]*,Flask-Principal,g' \
+      -e 's,markdown>=[^"]*,markdown,g' \
+      -e 's,Flask-Assets>=[^"]*,Flask-Assets,g' \
+      -e 's,rsa>=[^"]*,rsa,g' \
+      -e 's,PyYAML>=[^"]*,PyYAML,g' \
       setup.py
   '';
 
   meta = with stdenv.lib; {
     homepage = "http://octoprint.org/";
     description = "The snappy web interface for your 3D printer";
-    platforms = platforms.all;
     license = licenses.agpl3;
     maintainers = with maintainers; [ abbradar ];
   };
diff --git a/pkgs/applications/misc/octoprint/m33-fio-one-library.patch b/pkgs/applications/misc/octoprint/m33-fio-one-library.patch
new file mode 100644
index 0000000000000..968983696feb2
--- /dev/null
+++ b/pkgs/applications/misc/octoprint/m33-fio-one-library.patch
@@ -0,0 +1,161 @@
+From 62b4fabd1d4ee7a584a565d48c7eaec6e80fe0bd Mon Sep 17 00:00:00 2001
+From: Nikolay Amiantov <ab@fmap.me>
+Date: Fri, 12 Aug 2016 23:41:22 +0300
+Subject: [PATCH] Build and use one version of preprocessor library
+
+---
+ octoprint_m33fio/__init__.py   | 66 +-----------------------------------------
+ shared library source/Makefile | 59 +++----------------------------------
+ 2 files changed, 5 insertions(+), 120 deletions(-)
+
+diff --git a/octoprint_m33fio/__init__.py b/octoprint_m33fio/__init__.py
+index da539f5..b0a17ad 100755
+--- a/octoprint_m33fio/__init__.py
++++ b/octoprint_m33fio/__init__.py
+@@ -979,71 +979,7 @@ class M33FioPlugin(
+ 		# Check if using shared library or checking if it is usable
+ 		if self._settings.get_boolean(["UseSharedLibrary"]) or isUsable :
+ 	
+-			# Check if running on Linux
+-			if platform.uname()[0].startswith("Linux") :
+-
+-				# Check if running on a Raspberry Pi 1
+-				if platform.uname()[4].startswith("armv6l") and self.getCpuHardware() == "BCM2708" :
+-	
+-					# Set shared library
+-					self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_arm1176jzf-s.so")
+-	
+-				# Otherwise check if running on a Raspberry Pi 2 or Raspberry Pi 3
+-				elif platform.uname()[4].startswith("armv7l") and self.getCpuHardware() == "BCM2709" :
+-	
+-					# Set shared library
+-					self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_arm_cortex-a7.so")
+-	
+-				# Otherwise check if running on an ARM7 device
+-				elif platform.uname()[4].startswith("armv7") :
+-	
+-					# Set shared library
+-					self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_arm7.so")
+-	
+-				# Otherwise check if using an i386 or x86-64 device
+-				elif platform.uname()[4].endswith("86") or platform.uname()[4].endswith("64") :
+-
+-					# Check if Python is running as 32-bit
+-					if platform.architecture()[0].startswith("32") :
+-		
+-						# Set shared library
+-						self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_i386.so")
+-	
+-					# Otherwise check if Python is running as 64-bit
+-					elif platform.architecture()[0].startswith("64") :
+-		
+-						# Set shared library
+-						self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_x86-64.so")
+-
+-			# Otherwise check if running on Windows and using an i386 or x86-64 device
+-			elif platform.uname()[0].startswith("Windows") and (platform.uname()[4].endswith("86") or platform.uname()[4].endswith("64")) :
+-
+-				# Check if Python is running as 32-bit
+-				if platform.architecture()[0].startswith("32") :
+-	
+-					# Set shared library
+-					self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_i386.dll")
+-
+-				# Otherwise check if Python is running as 64-bit
+-				elif platform.architecture()[0].startswith("64") :
+-	
+-					# Set shared library
+-					self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_x86-64.dll")
+-
+-			# Otherwise check if running on OS X and using an i386 or x86-64 device
+-			elif platform.uname()[0].startswith("Darwin") and (platform.uname()[4].endswith("86") or platform.uname()[4].endswith("64")) :
+-
+-				# Check if Python is running as 32-bit
+-				if platform.architecture()[0].startswith("32") :
+-	
+-					# Set shared library
+-					self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_i386.dylib")
+-
+-				# Otherwise check if Python is running as 64-bit
+-				elif platform.architecture()[0].startswith("64") :
+-	
+-					# Set shared library
+-					self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_x86-64.dylib")
++			self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/libpreprocessor.so")
+ 
+ 			# Check if shared library was set
+ 			if self.sharedLibrary :
+diff --git a/shared library source/Makefile b/shared library source/Makefile
+index a43d657..0b254aa 100755
+--- a/shared library source/Makefile	
++++ b/shared library source/Makefile	
+@@ -1,62 +1,11 @@
+ # Target platform options: LINUX32, LINUX64, WINDOWS32, WINDOWS64, PI, PI2, ARM7, OSX32, OSX64
+-LIBRARY_NAME = preprocessor
++LIBRARY_NAME = libpreprocessor
+ TARGET_PLATFORM = LINUX64
+ VER = .1
+ 
+-ifeq ($(TARGET_PLATFORM), LINUX32)
+-	PROG = $(LIBRARY_NAME)_i386.so
+-	CC = g++
+-	CFLAGS = -fPIC -m32 -static-libgcc -O3 -Wl,-soname,$(PROG)$(VER) -static-libstdc++
+-endif
+-
+-ifeq ($(TARGET_PLATFORM), LINUX64)
+-	PROG = $(LIBRARY_NAME)_x86-64.so
+-	CC = g++
+-	CFLAGS = -fPIC -m64 -static-libgcc -O3 -Wl,-soname,$(PROG)$(VER) -static-libstdc++
+-endif
+-
+-ifeq ($(TARGET_PLATFORM), WINDOWS32)
+-	PROG = $(LIBRARY_NAME)_i386.dll
+-	CC = i686-w64-mingw32-g++
+-	CFLAGS = -static-libgcc -O3 -Wl,-soname,$(PROG)$(VER) -static-libstdc++
+-endif
+-
+-ifeq ($(TARGET_PLATFORM), WINDOWS64)
+-	PROG = $(LIBRARY_NAME)_x86-64.dll
+-	CC = x86_64-w64-mingw32-g++
+-	CFLAGS = -static-libgcc -O3 -Wl,-soname,$(PROG)$(VER) -static-libstdc++
+-endif
+-
+-ifeq ($(TARGET_PLATFORM), PI)
+-	PROG = $(LIBRARY_NAME)_arm1176jzf-s.so
+-	CC = ~/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
+-	CFLAGS = -fPIC -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -static-libgcc -O3 -Wl,-soname,$(PROG)$(VER) -static-libstdc++
+-endif
+-
+-ifeq ($(TARGET_PLATFORM), PI2)
+-	PROG = $(LIBRARY_NAME)_arm_cortex-a7.so
+-	CC = ~/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
+-	CFLAGS = -fPIC -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -static-libgcc -O3 -Wl,-soname,$(PROG)$(VER) -static-libstdc++
+-endif
+-
+-ifeq ($(TARGET_PLATFORM), ARM7)
+-	PROG = $(LIBRARY_NAME)_arm7.so
+-	CC = ~/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++
+-	CFLAGS = -fPIC -mcpu=generic-armv7-a -mfpu=vfp -mfloat-abi=hard -static-libgcc -O3 -Wl,-soname,$(PROG)$(VER) -static-libstdc++
+-endif
+-
+-ifeq ($(TARGET_PLATFORM), OSX32)
+-	PROG = $(LIBRARY_NAME)_i386.dylib
+-	CC = clang++
+-	CFLAGS = -fPIC -m32 -stdlib=libc++ -O3 -Wl,-install_name,$(PROG)$(VER)
+-
+-endif
+-
+-ifeq ($(TARGET_PLATFORM), OSX64)
+-	PROG = $(LIBRARY_NAME)_x86-64.dylib
+-	CC = clang++
+-	CFLAGS = -fPIC -m64 -stdlib=libc++ -O3 -Wl,-install_name,$(PROG)$(VER)
+-endif
++PROG = $(LIBRARY_NAME).so
++CC = g++
++CFLAGS = -fPIC -O3 -Wl,-soname,$(PROG)$(VER)
+ 
+ SRCS = preprocessor.cpp gcode.cpp vector.cpp
+ CFLAGS += -Wall -std=c++11 -fvisibility=hidden -shared
+-- 
+2.9.2
+
diff --git a/pkgs/applications/misc/octoprint/plugins.nix b/pkgs/applications/misc/octoprint/plugins.nix
index 852ec5b444dcf..3c07bfa80e807 100644
--- a/pkgs/applications/misc/octoprint/plugins.nix
+++ b/pkgs/applications/misc/octoprint/plugins.nix
@@ -4,79 +4,84 @@ let
   buildPlugin = args: pythonPackages.buildPythonApplication (args // {
     buildInputs = (args.buildInputs or []) ++ [ octoprint ];
   });
-in {
 
-  m3d-fio = buildPlugin rec {
-    name = "M3D-Fio-${version}";
-    version = "0.32";
+  self = {
 
-    src = fetchFromGitHub {
-      owner = "donovan6000";
-      repo = "M3D-Fio";
-      rev = "V${version}";
-      sha256 = "1s15nx6v56yjwd88b19fx0gk1l0abp76nz10yicspdn91fpr1sf4";
-    };
+    # Deprecated alias
+    m3d-fio = self.m33-fio; # added 2016-08-13
 
-    patches = [
-      ./0001-Don-t-use-static-library.patch
-    ];
-
-    postInstall = ''
-    (
-      cd 'shared library source'
-      make
-      install -Dm755 libpreprocessor.so $out/lib/libpreprocessor.so
-    )
-    rm -rf $out/${pythonPackages.python.sitePackages}/octoprint_m3dfio/static/libraries
-    '';
-
-    meta = with stdenv.lib; {
-      homepage = "https://github.com/donovan6000/M3D-Fio";
-      description = "OctoPrint plugin for the Micro 3D printer";
-      platforms = platforms.all;
-      license = licenses.gpl3;
-      maintainers = with maintainers; [ abbradar ];
-    };
-  };
+    m33-fio = buildPlugin rec {
+      name = "M33-Fio-${version}";
+      version = "1.5";
 
-  titlestatus = buildPlugin rec {
-    name = "OctoPrint-TitleStatus-${version}";
-    version = "0.0.4";
+      src = fetchFromGitHub {
+        owner = "donovan6000";
+        repo = "M33-Fio";
+        rev = "V${version}";
+        sha256 = "0ss8ic9l5srb5wj2mj0qafam0z4d6zv0cixhxgghh03fp0lvwjyq";
+      };
 
-    src = fetchFromGitHub {
-      owner = "MoonshineSG";
-      repo = "OctoPrint-TitleStatus";
-      rev = version;
-      sha256 = "1l78xrabn5hcly2mgxwi17nwgnp2s6jxi9iy4wnw8k8icv74ag7k";
-    };
+      patches = [
+        ./m33-fio-one-library.patch
+      ];
+
+      postPatch = ''
+        rm -rf octoprint_m33fio/static/libraries/*
+        (
+          cd 'shared library source'
+          make
+        )
+      '';
 
-    meta = with stdenv.lib; {
-      homepage = https://github.com/MoonshineSG/OctoPrint-TitleStatus;
-      description = "Show printers status in window title";
-      platforms = platforms.all;
-      license = licenses.agpl3;
-      maintainers = with maintainers; [ abbradar ];
+      meta = with stdenv.lib; {
+        homepage = "https://github.com/donovan6000/M3D-Fio";
+        description = "OctoPrint plugin for the Micro 3D printer";
+        platforms = platforms.all;
+        license = licenses.gpl3;
+        maintainers = with maintainers; [ abbradar ];
+      };
     };
-  };
 
-  stlviewer = buildPlugin rec {
-    name = "OctoPrint-STLViewer-${version}";
-    version = "0.3.0";
+    titlestatus = buildPlugin rec {
+      name = "OctoPrint-TitleStatus-${version}";
+      version = "0.0.4";
+
+      src = fetchFromGitHub {
+        owner = "MoonshineSG";
+        repo = "OctoPrint-TitleStatus";
+        rev = version;
+        sha256 = "1l78xrabn5hcly2mgxwi17nwgnp2s6jxi9iy4wnw8k8icv74ag7k";
+      };
 
-    src = fetchFromGitHub {
-      owner = "jneilliii";
-      repo = "OctoPrint-STLViewer";
-      rev = "v${version}";
-      sha256 = "1a6sa8pw9ay7x27pfwr3nzb22x3jaw0c9vwyz4mrj76zkiw6svfi";
+      meta = with stdenv.lib; {
+        homepage = "https://github.com/MoonshineSG/OctoPrint-TitleStatus";
+        description = "Show printers status in window title";
+        platforms = platforms.all;
+        license = licenses.agpl3;
+        maintainers = with maintainers; [ abbradar ];
+      };
     };
 
-    meta = with stdenv.lib; {
-      homepage = https://github.com/jneilliii/Octoprint-STLViewer;
-      description = "A simple stl viewer tab for OctoPrint";
-      platforms = platforms.all;
-      license = licenses.agpl3;
-      maintainers = with maintainers; [ abbradar ];
+    stlviewer = buildPlugin rec {
+      name = "OctoPrint-STLViewer-${version}";
+      version = "0.3.0";
+
+      src = fetchFromGitHub {
+        owner = "jneilliii";
+        repo = "OctoPrint-STLViewer";
+        rev = "v${version}";
+        sha256 = "1a6sa8pw9ay7x27pfwr3nzb22x3jaw0c9vwyz4mrj76zkiw6svfi";
+      };
+
+      meta = with stdenv.lib; {
+        homepage = "https://github.com/jneilliii/Octoprint-STLViewer";
+        description = "A simple stl viewer tab for OctoPrint";
+        platforms = platforms.all;
+        license = licenses.agpl3;
+        maintainers = with maintainers; [ abbradar ];
+      };
     };
+
   };
 
-}
+in self
diff --git a/pkgs/applications/misc/rofi/default.nix b/pkgs/applications/misc/rofi/default.nix
index 491f09943b549..d6ff999b23d47 100644
--- a/pkgs/applications/misc/rofi/default.nix
+++ b/pkgs/applications/misc/rofi/default.nix
@@ -1,15 +1,14 @@
-{ stdenv, fetchurl, autoreconfHook, pkgconfig, libX11, libxkbcommon, pango
-, cairo, glib, libxcb, xcbutil, xcbutilwm, libstartup_notification
-, i3Support ? false, i3
+{ stdenv, fetchurl, autoreconfHook, pkgconfig, libxkbcommon, pango
+, cairo, glib, libxcb, xcbutil, xcbutilwm, xcbutilxrm, libstartup_notification
 }:
 
 stdenv.mkDerivation rec {
-  version = "1.1.0";
+  version = "1.2.0";
   name = "rofi-${version}";
 
   src = fetchurl {
     url = "https://github.com/DaveDavenport/rofi/releases/download/${version}/${name}.tar.xz";
-    sha256 = "1l8vl0mh7i0b1ycifqpg6392f5i4qxlv003m126skfk6fnlfq8hn";
+    sha256 = "0xxx0xpxhrhlhi2axq9867zqrhwqavc1qrr833k1xr0pvm5m0aqc";
   };
 
   preConfigure = ''
@@ -18,9 +17,10 @@ stdenv.mkDerivation rec {
     sed -i 's/~root/~nobody/g' test/helper-expand.c
   '';
 
-  buildInputs = [ autoreconfHook pkgconfig libX11 libxkbcommon pango
-    cairo libstartup_notification libxcb xcbutil xcbutilwm
-  ] ++ stdenv.lib.optional i3Support i3;
+  buildInputs = [ autoreconfHook pkgconfig libxkbcommon pango cairo
+    libstartup_notification libxcb xcbutil xcbutilwm xcbutilxrm
+  ];
+  doCheck = true;
 
   meta = with stdenv.lib; {
     description = "Window switcher, run dialog and dmenu replacement";
diff --git a/pkgs/applications/misc/rxvt_unicode-plugins/urxvt-tabbedex/default.nix b/pkgs/applications/misc/rxvt_unicode-plugins/urxvt-tabbedex/default.nix
index 5dc6ed65070f7..901afab78bca1 100644
--- a/pkgs/applications/misc/rxvt_unicode-plugins/urxvt-tabbedex/default.nix
+++ b/pkgs/applications/misc/rxvt_unicode-plugins/urxvt-tabbedex/default.nix
@@ -1,17 +1,18 @@
-{ stdenv, fetchgit }:
+{ stdenv, fetchFromGitHub, perl }:
 
 stdenv.mkDerivation {
-  name = "urxvt-tabbedex-2015-03-03";
+  name = "urxvt-tabbedex-2016-08-09";
 
-  src = fetchgit {
-    url = "https://github.com/mina86/urxvt-tabbedex";
-    rev = "b0a02018b1cbaaba2a0c8ea7af9368db0adf3363";
-    sha256 = "f0025f2741d424736620147d9fc39faac68193cb9f74bde0fb6e02a6f1ae61c3";
+  src = fetchFromGitHub {
+    owner = "mina86";
+    repo = "urxvt-tabbedex";
+    rev = "ac220eb3984e151ba14dce08f446bc7bc8ca29a2";
+    sha256 = "1b5mff5137jb5ysklsmfp5ql3m4g1z3bdhk0nwhz2hgwz40ap6k8";
   };
 
-  installPhase = ''
-    install -D tabbedex $out/lib/urxvt/perl/tabbedex
-  '';
+  nativeBuildInputs = [ perl ];
+
+  installFlags = [ "PREFIX=$(out)" ];
 
   meta = with stdenv.lib; {
     description = "Tabbed plugin for rxvt-unicode with many enhancements (mina86's fork)";
diff --git a/pkgs/applications/networking/browsers/firefox-bin/default.nix b/pkgs/applications/networking/browsers/firefox-bin/default.nix
index e1e603b28fd70..d782f4a7b5369 100644
--- a/pkgs/applications/networking/browsers/firefox-bin/default.nix
+++ b/pkgs/applications/networking/browsers/firefox-bin/default.nix
@@ -17,6 +17,7 @@
 , gtk3
 , libX11
 , libXScrnSaver
+, libxcb
 , libXcomposite
 , libXdamage
 , libXext
@@ -90,6 +91,7 @@ stdenv.mkDerivation {
       libX11
       libXScrnSaver
       libXcomposite
+      libxcb
       libXdamage
       libXext
       libXfixes
diff --git a/pkgs/applications/networking/browsers/midori/default.nix b/pkgs/applications/networking/browsers/midori/default.nix
index 476137581cc81..70968b97c3cb3 100644
--- a/pkgs/applications/networking/browsers/midori/default.nix
+++ b/pkgs/applications/networking/browsers/midori/default.nix
@@ -1,19 +1,21 @@
-{ stdenv, fetchurl, cmake, pkgconfig, intltool, vala, makeWrapper
+{ stdenv, fetchurl, cmake, pkgconfig, intltool, vala, wrapGAppsHook
 , gtk3, webkitgtk, librsvg, libnotify, sqlite
 , glib_networking, gsettings_desktop_schemas, libsoup, pcre, gnome3
+, libxcb, libpthreadstubs, libXdmcp, libxkbcommon, epoxy, at_spi2_core
+, zeitgeistSupport ? false, zeitgeist ? null
 }:
 
-let
-  version = "0.5.11";
-in
+assert zeitgeistSupport -> zeitgeist != null;
+
 stdenv.mkDerivation rec {
   name = "midori-${version}";
+  version = "0.5.11";
 
   meta = with stdenv.lib; {
     description = "Lightweight WebKitGTK+ web browser";
     homepage = "http://midori-browser.org";
-    license = licenses.lgpl21Plus;
-    platforms = platforms.linux;
+    license = with licenses; [ lgpl21Plus ];
+    platforms = with platforms; linux;
     maintainers = with maintainers; [ raskin ramkromberg ];
   };
 
@@ -26,24 +28,29 @@ stdenv.mkDerivation rec {
     sha256 = "0gcwqkcyliqz10i33ww3wl02mmfnl7jzl2d493l4l53ipsb1l6cn";
   };
 
+  nativeBuildInputs = [
+    pkgconfig wrapGAppsHook cmake intltool
+  ];
+
   buildInputs = [
-    cmake pkgconfig intltool vala makeWrapper
-    webkitgtk librsvg libnotify sqlite gsettings_desktop_schemas pcre gnome3.gcr
+    vala
+    gtk3 webkitgtk librsvg libnotify sqlite gsettings_desktop_schemas pcre gnome3.gcr
+    libxcb libpthreadstubs libXdmcp libxkbcommon epoxy at_spi2_core
     (libsoup.override {gnomeSupport = true; valaSupport = true;})
+  ] ++ stdenv.lib.optionals zeitgeistSupport [
+    zeitgeist
   ];
 
   cmakeFlags = [ 
     "-DCMAKE_BUILD_TYPE=Release"
-    "-DUSE_ZEITGEIST=OFF"
-    "-DHALF_BRO_INCOM_WEBKIT2=OFF"
+    "-DUSE_ZEITGEIST=${if zeitgeistSupport then "ON" else "OFF"}"
+    "-DHALF_BRO_INCOM_WEBKIT2=ON"
     "-DUSE_GTK3=1"
   ];
 
   NIX_LDFLAGS="-lX11";
 
   preFixup = ''
-    wrapProgram $out/bin/midori \
-      --prefix GIO_EXTRA_MODULES : "${glib_networking.out}/lib/gio/modules" \
-      --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH"
+    gappsWrapperArgs+=(--prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" --prefix GIO_EXTRA_MODULES : "${glib_networking.out}/lib/gio/modules")
   '';
 }
diff --git a/pkgs/applications/networking/browsers/qutebrowser/default.nix b/pkgs/applications/networking/browsers/qutebrowser/default.nix
index c8a719b194ad7..6c4dcc4e119f1 100644
--- a/pkgs/applications/networking/browsers/qutebrowser/default.nix
+++ b/pkgs/applications/networking/browsers/qutebrowser/default.nix
@@ -1,6 +1,7 @@
-{ stdenv, fetchurl, python, buildPythonApplication, qtmultimedia, pyqt5
-, jinja2, pygments, pyyaml, pypeg2, gst-plugins-base, gst-plugins-good
-, gst-plugins-bad, gst-libav, wrapGAppsHook, glib_networking, makeQtWrapper }:
+{ stdenv, fetchurl, buildPythonApplication, makeQtWrapper, wrapGAppsHook
+, qtmultimedia, pyqt5, jinja2, pygments, pyyaml, pypeg2, glib_networking
+, asciidoc, docbook_xml_dtd_45, docbook_xsl, libxml2, libxslt
+, gst-plugins-base, gst-plugins-good, gst-plugins-bad, gst-plugins-ugly, gst-libav }:
 
 let version = "0.8.2"; in
 
@@ -16,18 +17,42 @@ buildPythonApplication rec {
   # Needs tox
   doCheck = false;
 
-  buildInputs = [ wrapGAppsHook makeQtWrapper
+  buildInputs = [
     qtmultimedia
-    gst-plugins-base gst-plugins-good gst-plugins-bad gst-libav
-    glib_networking ];
+    gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav
+    glib_networking
+  ];
+
+  nativeBuildInputs = [
+    makeQtWrapper wrapGAppsHook asciidoc docbook_xml_dtd_45 docbook_xsl libxml2 libxslt
+  ];
 
   propagatedBuildInputs = [
-    python pyyaml pyqt5 jinja2 pygments pypeg2
+    pyyaml pyqt5 jinja2 pygments pypeg2
   ];
 
+  postPatch = ''
+    sed -i "s,/usr/share/qutebrowser,$out/share/qutebrowser,g" qutebrowser/utils/standarddir.py
+  '';
+
+  postBuild = ''
+    a2x -f manpage doc/qutebrowser.1.asciidoc
+  '';
+
   postInstall = ''
     mv $out/bin/qutebrowser $out/bin/.qutebrowser-noqtpath
     makeQtWrapper $out/bin/.qutebrowser-noqtpath $out/bin/qutebrowser
+
+    install -Dm644 doc/qutebrowser.1 "$out/share/man/man1/qutebrowser.1"
+    install -Dm644 qutebrowser.desktop \
+        "$out/share/applications/qutebrowser.desktop"
+    for i in 16 24 32 48 64 128 256 512; do
+        install -Dm644 "icons/qutebrowser-''${i}x''${i}.png" \
+            "$out/share/icons/hicolor/''${i}x''${i}/apps/qutebrowser.png"
+    done
+    install -Dm644 icons/qutebrowser.svg \
+        "$out/share/icons/hicolor/scalable/apps/qutebrowser.svg"
+    install -Dm755 -t "$out/share/qutebrowser/userscripts/" misc/userscripts/*
   '';
 
   meta = {
diff --git a/pkgs/applications/networking/cluster/marathon/default.nix b/pkgs/applications/networking/cluster/marathon/default.nix
index 11c275c9f4904..f737d4e04bd55 100644
--- a/pkgs/applications/networking/cluster/marathon/default.nix
+++ b/pkgs/applications/networking/cluster/marathon/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "marathon-${version}";
-  version = "0.15.3";
+  version = "1.1.1";
 
   src = fetchurl {
-    url = "https://downloads.mesosphere.io/marathon/v${version}/marathon-${version}.tgz";
-    sha256 = "1br4k596sjp4cf5l2nyaqhlsfdr443n08fvdyf4kilhr803x2rjq";
+    url = "https://downloads.mesosphere.com/marathon/v${version}/marathon-${version}.tgz";
+    sha256 = "35a80401383f6551c45c676beed30b3c1af6d3ad027f44735c208abe8eaca93d";
   };
 
   buildInputs = [ makeWrapper jdk mesos ];
diff --git a/pkgs/applications/networking/instant-messengers/blink/default.nix b/pkgs/applications/networking/instant-messengers/blink/default.nix
index d2a08b98c0760..e771db3795b50 100644
--- a/pkgs/applications/networking/instant-messengers/blink/default.nix
+++ b/pkgs/applications/networking/instant-messengers/blink/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pythonPackages, pyqt4, cython, libvncserver, zlib, twisted
+{ stdenv, fetchurl, pythonPackages, libvncserver, zlib
 , gnutls, libvpx, makeDesktopItem }:
 
 pythonPackages.buildPythonApplication rec {
@@ -18,7 +18,7 @@ pythonPackages.buildPythonApplication rec {
   propagatedBuildInputs = with pythonPackages;[ pyqt4 cjson sipsimple twisted
     ];
 
-  buildInputs = [ cython zlib libvncserver libvpx ];
+  buildInputs = [ pythonPackages.cython zlib libvncserver libvpx ];
 
   desktopItem = makeDesktopItem {
     name = "Blink";
diff --git a/pkgs/applications/networking/instant-messengers/pybitmessage/default.nix b/pkgs/applications/networking/instant-messengers/pybitmessage/default.nix
index 703447594edb8..9675b5d5315a6 100644
--- a/pkgs/applications/networking/instant-messengers/pybitmessage/default.nix
+++ b/pkgs/applications/networking/instant-messengers/pybitmessage/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, python, pythonPackages, pyqt4, openssl }:
+{ stdenv, fetchFromGitHub, pythonPackages, openssl }:
 
 stdenv.mkDerivation rec {
   name = "pybitmessage-${version}";
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
     sha256 = "1f4h0yc1mfjnxzvxiv9hxgak59mgr3a5ykv50vlyiay82za20jax";
   };
 
-  buildInputs = [ python pyqt4 openssl pythonPackages.wrapPython pythonPackages.sqlite3 ];
+  buildInputs = with pythonPackages; [ python pyqt4 wrapPython sqlite3 ] ++ [ openssl ];
 
   preConfigure = ''
     substituteInPlace Makefile \
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
 
   postInstall = ''
     substituteInPlace $out/bin/pybitmessage \
-      --replace "exec python2" "exec ${python}/bin/python" \
+      --replace "exec python2" "exec ${pythonPackages.python}/bin/python" \
       --replace "/opt/openssl-compat-bitcoin/lib/" "${openssl.out}/lib/"
     wrapProgram $out/bin/pybitmessage \
       --prefix PYTHONPATH : "$(toPythonPath $out):$PYTHONPATH"
diff --git a/pkgs/applications/networking/instant-messengers/telegram/tdesktop/default.nix b/pkgs/applications/networking/instant-messengers/telegram/tdesktop/default.nix
index 461e755505c01..130fe644143e3 100644
--- a/pkgs/applications/networking/instant-messengers/telegram/tdesktop/default.nix
+++ b/pkgs/applications/networking/instant-messengers/telegram/tdesktop/default.nix
@@ -16,20 +16,20 @@ let
 
 in stdenv.mkDerivation rec {
   name = "telegram-desktop-${version}";
-  version = "0.9.56";
+  version = "0.10.1";
   qtVersion = lib.replaceStrings ["."] ["_"] packagedQt;
 
   src = fetchFromGitHub {
     owner = "telegramdesktop";
     repo = "tdesktop";
     rev = "v${version}";
-    sha256 = "000ngg6arfb6mif0hvin099f83q3sn7mw4vfvrikskczblw3a5lc";
+    sha256 = "08isxwif6zllglkpd9i7ypxm2s4bibzqris48607bafr88ylksdk";
   };
 
   tgaur = fetchgit {
     url = "https://aur.archlinux.org/telegram-desktop.git";
-    rev = "f8907d1ccaf8345c06232238342921213270e3d8";
-    sha256 = "04jh0fsrh4iwg188d20z15qkxv05wa5lpd8h21yxx3jxqljpdkws";
+    rev = "9ce7be9efed501f988bb099956fa63729f2c25ea";
+    sha256 = "1wp6lqscpm2byizchm0bj48dg9bga02r9r69ns10zxk0gk0qvvdn";
   };
 
   buildInputs = [
@@ -50,22 +50,8 @@ in stdenv.mkDerivation rec {
     "CONFIG+=release"
     "DEFINES+=TDESKTOP_DISABLE_AUTOUPDATE"
     "DEFINES+=TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME"
-    "INCLUDEPATH+=${gtk2.dev}/include/gtk-2.0"
-    "INCLUDEPATH+=${glib.dev}/include/glib-2.0"
-    "INCLUDEPATH+=${glib.out}/lib/glib-2.0/include"
-    "INCLUDEPATH+=${cairo.dev}/include/cairo"
-    "INCLUDEPATH+=${pango.dev}/include/pango-1.0"
-    "INCLUDEPATH+=${gtk2.out}/lib/gtk-2.0/include"
-    "INCLUDEPATH+=${gdk_pixbuf.dev}/include/gdk-pixbuf-2.0"
-    "INCLUDEPATH+=${atk.dev}/include/atk-1.0"
-    "INCLUDEPATH+=${libappindicator-gtk2}/include/libappindicator-0.1"
-    "INCLUDEPATH+=${libunity}/include/unity"
-    "INCLUDEPATH+=${dee}/include/dee-1.0"
-    "INCLUDEPATH+=${libdbusmenu-glib}/include/libdbusmenu-glib-0.4"
     "INCLUDEPATH+=${breakpad}/include/breakpad"
     "QT_TDESKTOP_VERSION=${systemQt}"
-    "LIBS+=-lcrypto"
-    "LIBS+=-lssl"
   ];
 
   qtSrcs = [ qtbase.src qtimageformats.src ];
@@ -79,11 +65,10 @@ in stdenv.mkDerivation rec {
     sed -i 'Telegram/Telegram.pro' \
       -e 's,CUSTOM_API_ID,,g' \
       -e 's,/usr,/does-not-exist,g' \
-      -e '/LIBS += .*libxkbcommon.a/d' \
-      -e 's,LIBS += .*libz.a,LIBS += -lz,' \
-      -e 's,LIBS += .*libbreakpad_client.a,LIBS += ${breakpad}/lib/libbreakpad_client.a,' \
       -e 's, -flto,,g' \
-      -e 's, -static-libstdc++,,g'
+      -e 's,LIBS += .*libbreakpad_client.a,LIBS += ${breakpad}/lib/libbreakpad_client.a,' \
+      -e 's, -static-libstdc++,,g' \
+      -e '/LIBS += .*libxkbcommon.a/d'
 
     export qmakeFlags="$qmakeFlags QT_TDESKTOP_PATH=$PWD/../qt"
 
@@ -105,7 +90,7 @@ in stdenv.mkDerivation rec {
       export configureFlags="-prefix "$PWD/../qt" -release -opensource -confirm-license -system-zlib \
         -system-libpng -system-libjpeg -system-freetype -system-harfbuzz -system-pcre -system-xcb \
         -system-xkbcommon-x11 -no-opengl -static -nomake examples -nomake tests \
-        -openssl-linked -dbus-linked -system-sqlite -verbose \
+        -openssl-linked -dbus-linked -system-sqlite -verbose -no-gtkstyle \
         ${lib.optionalString (!system-x86_64) "-no-sse2"} -no-sse3 -no-ssse3 \
         -no-sse4.1 -no-sse4.2 -no-avx -no-avx2 -no-mips_dsp -no-mips_dspr2"
       export dontAddPrefix=1
diff --git a/pkgs/applications/networking/mailreaders/claws-mail/default.nix b/pkgs/applications/networking/mailreaders/claws-mail/default.nix
index 86bf0b2e14b80..62a58c42cd43c 100644
--- a/pkgs/applications/networking/mailreaders/claws-mail/default.nix
+++ b/pkgs/applications/networking/mailreaders/claws-mail/default.nix
@@ -32,7 +32,7 @@ with stdenv.lib;
 
 stdenv.mkDerivation rec {
   name = "claws-mail-${version}";
-  version = "3.13.2";
+  version = "3.14.0";
 
   meta = {
     description = "The user-friendly, lightweight, and fast email client";
@@ -44,7 +44,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "http://www.claws-mail.org/download.php?file=releases/claws-mail-${version}.tar.xz";
-    sha256 = "1l8ankx0qpq1ix1an8viphcf11ksh53jsrm1xjmq8cjbh5910wva";
+    sha256 = "0nfchgga3ir91s8rky0a0vnz8cgj2f6h716wh3cmb466a01xfss6";
   };
 
   patches = [ ./mime.patch ];
diff --git a/pkgs/applications/networking/syncthing/default.nix b/pkgs/applications/networking/syncthing/default.nix
index 2a02e0e657c8d..bd156680d4bf4 100644
--- a/pkgs/applications/networking/syncthing/default.nix
+++ b/pkgs/applications/networking/syncthing/default.nix
@@ -1,14 +1,14 @@
 { stdenv, fetchFromGitHub, go }:
 
 stdenv.mkDerivation rec {
-  version = "0.14.3";
+  version = "0.14.4";
   name = "syncthing-${version}";
 
   src = fetchFromGitHub {
     owner = "syncthing";
     repo = "syncthing";
     rev = "v${version}";
-    sha256 = "114i0911h3q6dn3j9x2qcm5lzpqclvrpf5vk87qpqp9qy62jp3az";
+    sha256 = "0i1pgwy7vn2hfcqa7dvrrc40hzrzn47alvnxm058f2hhxjis3fdw";
   };
 
   buildInputs = [ go ];
diff --git a/pkgs/applications/office/impressive/default.nix b/pkgs/applications/office/impressive/default.nix
index 1c921925cea34..1422369d20efd 100644
--- a/pkgs/applications/office/impressive/default.nix
+++ b/pkgs/applications/office/impressive/default.nix
@@ -1,10 +1,10 @@
-{ fetchurl, stdenv, python, makeWrapper, lib
-, xpdf, pillow, pyopengl, pygame
-, setuptools, mesa, freeglut }:
+{ fetchurl, stdenv, pythonPackages, makeWrapper, lib
+, xpdf, mesa, freeglut }:
 
-let version = "0.10.5";
-in
- stdenv.mkDerivation {
+let
+  inherit (pythonPackages) python pyopengl pygame setuptools pillow;
+  version = "0.10.5";
+in stdenv.mkDerivation {
     # This project was formerly known as KeyJNote.
     # See http://keyj.s2000.ws/?p=77 for details.
 
diff --git a/pkgs/applications/search/catfish/default.nix b/pkgs/applications/search/catfish/default.nix
index bad10a8607a60..f6df5fc496d79 100644
--- a/pkgs/applications/search/catfish/default.nix
+++ b/pkgs/applications/search/catfish/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, file, which, intltool, findutils, xdg_utils, pycairo,
+{ stdenv, fetchurl, file, which, intltool, findutils, xdg_utils,
   gnome3, pythonPackages, wrapGAppsHook }:
 
 pythonPackages.buildPythonApplication rec {
diff --git a/pkgs/applications/version-management/meld/default.nix b/pkgs/applications/version-management/meld/default.nix
index 99e45438984d0..503ae4e90b9cd 100644
--- a/pkgs/applications/version-management/meld/default.nix
+++ b/pkgs/applications/version-management/meld/default.nix
@@ -1,16 +1,14 @@
-{ stdenv, fetchurl, itstool, buildPythonApplication, python27, intltool, wrapGAppsHook
-, libxml2, pygobject3, gobjectIntrospection, gtk3, gnome3, pycairo, cairo, file
+{ stdenv, fetchurl, itstool, pythonPackages, intltool, wrapGAppsHook
+, libxml2, gobjectIntrospection, gtk3, gnome3, cairo, file
 }:
 
 
 let
   minor = "3.16";
   version = "${minor}.2";
-in
-
-buildPythonApplication rec {
+  inherit (pythonPackages) python buildPythonApplication pycairo pygobject3;
+in buildPythonApplication rec {
   name = "meld-${version}";
-  namePrefix = "";
 
   src = fetchurl {
     url = "mirror://gnome/sources/meld/${minor}/meld-${version}.tar.xz";
@@ -18,19 +16,19 @@ buildPythonApplication rec {
   };
 
   buildInputs = [
-    python27 intltool wrapGAppsHook itstool libxml2
+    intltool wrapGAppsHook itstool libxml2
     gnome3.gtksourceview gnome3.gsettings_desktop_schemas pycairo cairo
     gnome3.defaultIconTheme gnome3.dconf file
   ];
   propagatedBuildInputs = [ gobjectIntrospection pygobject3 gtk3 ];
 
   installPhase = ''
-    mkdir -p "$out/lib/${python27.libPrefix}/site-packages"
+    mkdir -p "$out/lib/${python.libPrefix}/site-packages"
 
-    export PYTHONPATH="$out/lib/${python27.libPrefix}/site-packages:$PYTHONPATH"
+    export PYTHONPATH="$out/lib/${python.libPrefix}/site-packages:$PYTHONPATH"
 
-    ${python27}/bin/${python27.executable} setup.py install \
-      --install-lib=$out/lib/${python27.libPrefix}/site-packages \
+    ${python}/bin/${python.executable} setup.py install \
+      --install-lib=$out/lib/${python.libPrefix}/site-packages \
       --prefix="$out"
 
     mkdir -p $out/share/gsettings-schemas/$name
diff --git a/pkgs/applications/version-management/reposurgeon/default.nix b/pkgs/applications/version-management/reposurgeon/default.nix
index 55858034b1c4e..2408621b9cf90 100644
--- a/pkgs/applications/version-management/reposurgeon/default.nix
+++ b/pkgs/applications/version-management/reposurgeon/default.nix
@@ -1,11 +1,13 @@
-{stdenv, fetchurl, makeWrapper, python27, python27Packages, git,
- docbook_xml_dtd_412, docbook_xml_xslt, asciidoc, xmlto,
- cython ? null,
- bazaar ? null, cvs ? null, darcs ? null, fossil ? null,
- mercurial ? null, monotone ? null, rcs ? null, src ? null,
- subversion ? null, cvs_fast_export ? null }:
+{ stdenv, fetchurl, makeWrapper, python27Packages, git
+, docbook_xml_dtd_412, docbook_xml_xslt, asciidoc, xmlto
+, bazaar ? null, cvs ? null, darcs ? null, fossil ? null
+, mercurial ? null, monotone ? null, rcs ? null, src ? null
+, subversion ? null, cvs_fast_export ? null }:
+
 with stdenv; with lib;
-mkDerivation rec {
+let
+  inherit (python27Packages) python cython;
+in mkDerivation rec {
   name = "reposurgeon-${meta.version}";
   meta = {
     description = "A tool for editing version-control repository history";
@@ -33,8 +35,8 @@ mkDerivation rec {
     makeFlagsArray=(
       XML_CATALOG_FILES="${docbook_xml_dtd_412}/xml/dtd/docbook/catalog.xml ${docbook_xml_xslt}/xml/xsl/docbook/catalog.xml"
       prefix="$out"
-      pyinclude="-I${python27}/include/python2.7"
-      pylib="-L${python27}/lib -lpython2.7"
+      pyinclude="-I${python}/include/python2.7"
+      pylib="-L${python}/lib -lpython2.7"
     )
   '';
 
@@ -51,7 +53,7 @@ mkDerivation rec {
         [ out git bazaar cvs darcs fossil mercurial
           monotone rcs src subversion cvs_fast_export ]
       );
-      pythonpath = makeSearchPathOutput "lib" python27.sitePackages (
+      pythonpath = makeSearchPathOutput "lib" python.sitePackages (
         filter (x: x != null)
         [ python27Packages.readline or null python27Packages.hglib or null ]
       );
diff --git a/pkgs/applications/version-management/src/default.nix b/pkgs/applications/version-management/src/default.nix
index cfecd96107bfc..2bff15adc69d9 100644
--- a/pkgs/applications/version-management/src/default.nix
+++ b/pkgs/applications/version-management/src/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, python, rcs, git, pylint }:
+{ stdenv, fetchurl, python, rcs, git }:
 
 stdenv.mkDerivation rec {
   name = "src-1.11";
diff --git a/pkgs/applications/video/byzanz/default.nix b/pkgs/applications/video/byzanz/default.nix
index 2d94cea0db9f8..872ac098f000a 100644
--- a/pkgs/applications/video/byzanz/default.nix
+++ b/pkgs/applications/video/byzanz/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchgit, which, gnome3, glib, intltool, pkgconfig, libtool, cairo, gtk3, gst_all_1 }:
+{ stdenv, fetchgit, wrapGAppsHook, which, gnome3, glib, intltool, pkgconfig, libtool, cairo, gtk3, gst_all_1, xorg }:
 
 stdenv.mkDerivation rec {
   version = "0.2.3.alpha";
@@ -18,7 +18,8 @@ stdenv.mkDerivation rec {
 
   NIX_CFLAGS_COMPILE = "-Wno-error=deprecated-declarations";
 
-  buildInputs = [ which gnome3.gnome_common glib intltool pkgconfig libtool cairo gtk3 gst_all_1.gstreamer gst_all_1.gst-plugins-base ];
+  buildInputs = [ which gnome3.gnome_common glib intltool pkgconfig libtool cairo gtk3 xorg.xwininfo ]
+  ++ (with gst_all_1; [ gstreamer gst-plugins-base gst-plugins-bad gst-plugins-good gst-plugins-ugly gst-libav wrapGAppsHook ]);
 
   meta = with stdenv.lib; {
     description = "Tool to record a running X desktop to an animation suitable for presentation in a web browser";
diff --git a/pkgs/applications/video/miro/default.nix b/pkgs/applications/video/miro/default.nix
index 07d60fe4764bc..266f3978b9921 100644
--- a/pkgs/applications/video/miro/default.nix
+++ b/pkgs/applications/video/miro/default.nix
@@ -1,6 +1,6 @@
-{ stdenv, fetchurl, python, buildPythonApplication, pythonPackages, pkgconfig
-, pyrex096, ffmpeg, boost, glib, pygobject, gtk2, webkitgtk2, libsoup, pygtk
-, taglib, sqlite, pycurl, mutagen, pycairo, pythonDBus, pywebkitgtk
+{ stdenv, fetchurl, pkgconfig
+, pythonPackages, pyrex096, ffmpeg, boost, glib, gtk2, webkitgtk2, libsoup
+, taglib, sqlite
 , libtorrentRasterbar, glib_networking, gsettings_desktop_schemas
 , gst_python, gst_plugins_base, gst_plugins_good, gst_ffmpeg
 , enableBonjour ? false, avahi ? null
@@ -10,10 +10,11 @@ assert enableBonjour -> avahi != null;
 
 with stdenv.lib;
 
-buildPythonApplication rec {
-  name = "miro-${version}";
-  namePrefix = "";
+let
+  inherit (pythonPackages) python buildPythonApplication;
   version = "6.0";
+in buildPythonApplication rec {
+  name = "miro-${version}";
 
   src = fetchurl {
     url = "http://ftp.osuosl.org/pub/pculture.org/miro/src/${name}.tar.gz";
@@ -56,7 +57,7 @@ buildPythonApplication rec {
 
   preInstall = ''
     # see https://bitbucket.org/pypa/setuptools/issue/130/install_data-doesnt-respect-prefix
-    ${python}/bin/${python.executable} setup.py install_data --root=$out
+    ${python.interpreter} setup.py install_data --root=$out
     sed -i '/data_files=data_files/d' setup.py
   '';
 
@@ -68,14 +69,14 @@ buildPythonApplication rec {
       --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH:$out/share"
   '';
 
-  buildInputs = [
-    pkgconfig pyrex096 ffmpeg boost glib pygobject gtk2 webkitgtk2 libsoup
-    pygtk taglib gsettings_desktop_schemas sqlite
+  buildInputs = with pythonPackages; [ pygtk pygobject ] ++ [
+    pkgconfig pyrex096 ffmpeg boost glib gtk2 webkitgtk2 libsoup
+    taglib gsettings_desktop_schemas sqlite
   ];
 
-  propagatedBuildInputs = [
-    pygobject pygtk pycurl python.modules.sqlite3 mutagen pycairo pythonDBus
-    pywebkitgtk libtorrentRasterbar
+  propagatedBuildInputs = with pythonPackages; [
+    pygobject pygtk pycurl sqlite3 mutagen pycairo dbus
+    pywebkitgtk] ++ [ libtorrentRasterbar
     gst_python gst_plugins_base gst_plugins_good gst_ffmpeg
   ] ++ optional enableBonjour avahi;
 
diff --git a/pkgs/applications/video/qarte/default.nix b/pkgs/applications/video/qarte/default.nix
index d4221e8f57eb1..b7da48ef000c6 100644
--- a/pkgs/applications/video/qarte/default.nix
+++ b/pkgs/applications/video/qarte/default.nix
@@ -1,6 +1,9 @@
-{ stdenv, fetchbzr, python, pyqt4, sip, rtmpdump, makeWrapper }:
+{ stdenv, fetchbzr, pythonPackages, rtmpdump, makeWrapper }:
 
-stdenv.mkDerivation {
+let
+  inherit (pythonPackages) python pyqt4;
+  sip = pythonPackages.sip_4_16;
+in stdenv.mkDerivation {
   name = "qarte-2.4.0";
   src = fetchbzr {
     url = http://bazaar.launchpad.net/~vincent-vandevyvre/qarte/trunk;
diff --git a/pkgs/applications/virtualization/tini/default.nix b/pkgs/applications/virtualization/tini/default.nix
index fe016da6e58a0..535ca551785fa 100644
--- a/pkgs/applications/virtualization/tini/default.nix
+++ b/pkgs/applications/virtualization/tini/default.nix
@@ -7,14 +7,12 @@ stdenv.mkDerivation rec {
     url = "https://github.com/krallin/tini/archive/v0.8.3.tar.gz";
     sha256 ="1w7rj4crrcyv25idmh4asbp2sxzwyihy5mbpw384bzxjzaxn9xpa";
   };
+  patchPhase = "sed -i /tini-static/d CMakeLists.txt";
   NIX_CFLAGS_COMPILE = [
     "-DPR_SET_CHILD_SUBREAPER=36"
     "-DPR_GET_CHILD_SUBREAPER=37"
   ];
   buildInputs = [ cmake ];
-  postInstall = ''
-    rm $out/bin/tini-static
-  '';
   meta = with stdenv.lib; {
     description = "A tiny but valid init for containers";
     homepage = https://github.com/krallin/tini;
diff --git a/pkgs/build-support/kernel/modules-closure.sh b/pkgs/build-support/kernel/modules-closure.sh
index 71d507b1e2b13..8a31c760da07a 100644
--- a/pkgs/build-support/kernel/modules-closure.sh
+++ b/pkgs/build-support/kernel/modules-closure.sh
@@ -1,7 +1,5 @@
 source $stdenv/setup
 
-set -o pipefail
-
 version=$(cd $kernel/lib/modules && ls -d *)
 
 echo "kernel version is $version"
diff --git a/pkgs/data/fonts/emojione/default.nix b/pkgs/data/fonts/emojione/default.nix
index 3e74ca9270a52..e19734c191360 100644
--- a/pkgs/data/fonts/emojione/default.nix
+++ b/pkgs/data/fonts/emojione/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "emojione-${version}";
-  version = "1.2";
+  version = "1.3";
 
   src = fetchFromGitHub {
     owner = "eosrei";
     repo = "emojione-color-font";
     rev = "v${version}";
-    sha256 = "001c2bph4jcdg9arfmyxrscf1i09gvg44kqy28chjmhxzq99hpcg";
+    sha256 = "0hgs661g1j91lkafhrfx5ix7ymarh5bzcx34r2id6jl7dc3j41l3";
   };
 
   preBuild = ''
diff --git a/pkgs/data/misc/wireless-regdb/default.nix b/pkgs/data/misc/wireless-regdb/default.nix
index d7dfd60c27fcf..3aae3adf2a809 100644
--- a/pkgs/data/misc/wireless-regdb/default.nix
+++ b/pkgs/data/misc/wireless-regdb/default.nix
@@ -2,10 +2,10 @@
 
 stdenv.mkDerivation rec {
   name = "wireless-regdb-${version}";
-  version = "2016-05-02";
+  version = "2016-06-10";
 
   src = fetchgit {
-    sha256 = "1qa741an242wi6gdikkr4ahanphfhwnjg8q2z3rsv8wdha91k895";
+    sha256 = "0im9likzpziircl96pql2jpyl8pfcqc5v0wgqy705j4ga5sx8pmn";
     url = https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git;
     rev = "refs/tags/master-${version}";
   };
diff --git a/pkgs/desktops/gnome-3/3.20/core/gnome-control-center/default.nix b/pkgs/desktops/gnome-3/3.20/core/gnome-control-center/default.nix
index 1b83bc061b7ac..e77e9e19970cd 100644
--- a/pkgs/desktops/gnome-3/3.20/core/gnome-control-center/default.nix
+++ b/pkgs/desktops/gnome-3/3.20/core/gnome-control-center/default.nix
@@ -30,7 +30,6 @@ stdenv.mkDerivation rec {
       networkmanager modemmanager makeWrapper gnome3.gnome-bluetooth grilo ];
 
   preBuild = ''
-    substituteInPlace tz.h --replace "/usr/share/zoneinfo/zone.tab" "${tzdata}/share/zoneinfo/zone.tab"
     substituteInPlace panels/datetime/tz.h --replace "/usr/share/zoneinfo/zone.tab" "${tzdata}/share/zoneinfo/zone.tab"
 
     # hack to make test-endianess happy
diff --git a/pkgs/desktops/gnome-3/3.20/core/vte/default.nix b/pkgs/desktops/gnome-3/3.20/core/vte/default.nix
index 38850f0fe761b..6b7eb8040082e 100644
--- a/pkgs/desktops/gnome-3/3.20/core/vte/default.nix
+++ b/pkgs/desktops/gnome-3/3.20/core/vte/default.nix
@@ -19,10 +19,6 @@ let baseAttrs = rec {
 
   enableParallelBuilding = true;
 
-  postInstall = ''
-    substituteInPlace $out/lib/libvte2_90.la --replace "-lncurses" "-L${ncurses.out}/lib -lncurses"
-  '';
-
   meta = with stdenv.lib; {
     homepage = http://www.gnome.org/;
     description = "A library implementing a terminal emulator widget for GTK+";
diff --git a/pkgs/desktops/kde-4.14/applications/kate.nix b/pkgs/desktops/kde-4.14/applications/kate.nix
index 2440d73e7e8e0..ddeb89063e50b 100644
--- a/pkgs/desktops/kde-4.14/applications/kate.nix
+++ b/pkgs/desktops/kde-4.14/applications/kate.nix
@@ -1,8 +1,8 @@
-{ stdenv, kde, kdelibs, kactivities, qjson, pyqt4, python, pykde4}:
+{ stdenv, kde, kdelibs, kactivities, qjson, pythonPackages, pykde4}:
 
 kde {
 
-  buildInputs = [ kdelibs kactivities qjson pyqt4 python pykde4 ];
+  buildInputs = [ kdelibs kactivities qjson pythonPackages.pyqt4 pythonPackages.python pykde4 ];
 
   meta = {
     description = "Kate, the KDE Advanced Text Editor, as well as KWrite";
diff --git a/pkgs/desktops/kde-4.14/kdebindings/pykde4.nix b/pkgs/desktops/kde-4.14/kdebindings/pykde4.nix
index 5a911d4b3ea31..48d457e10a7f3 100644
--- a/pkgs/desktops/kde-4.14/kdebindings/pykde4.nix
+++ b/pkgs/desktops/kde-4.14/kdebindings/pykde4.nix
@@ -1,9 +1,10 @@
-{ kde, kdelibs, python, pyqt4, kdepimlibs, shared_desktop_ontologies,
+{ kde, kdelibs, pythonPackages, kdepimlibs, shared_desktop_ontologies,
   polkit_qt4, boost, lndir, pkgconfig }:
 
-let pydir = "lib/python${python.majorVersion}"; in
-
-kde {
+let
+  inherit (pythonPackages) python pyqt4;
+  pydir = "lib/python${python.majorVersion}";
+in kde {
 
   patches = [ ./pykde4-gcc-5.patch ];
 
diff --git a/pkgs/desktops/kde-4.14/kdeutils/print-manager.nix b/pkgs/desktops/kde-4.14/kdeutils/print-manager.nix
index d12c261a728de..b53946fae25de 100644
--- a/pkgs/desktops/kde-4.14/kdeutils/print-manager.nix
+++ b/pkgs/desktops/kde-4.14/kdeutils/print-manager.nix
@@ -1,5 +1,5 @@
 { kde, kdelibs
-, pythonPackages, cups, pyqt4, pykde4, pycups, system-config-printer }:
+, pythonPackages, cups, pykde4, system-config-printer }:
 
 let s_c_p = system-config-printer.override { withGUI = false; }; in
 
@@ -7,7 +7,7 @@ kde rec {
   buildInputs = [ kdelibs pythonPackages.python pythonPackages.wrapPython
     ] ++ pythonPath;
 
-  pythonPath = [ cups pyqt4 pykde4 pycups s_c_p ];
+  pythonPath = [ cups pythonPackages.pyqt4 pykde4 pythonPackages.pycups s_c_p ];
 
   # system-config-printer supplies some D-Bus policy that we need.
   propagatedUserEnvPkgs = [ s_c_p ];
diff --git a/pkgs/desktops/kde-5/plasma/breeze-gtk.nix b/pkgs/desktops/kde-5/plasma/breeze-gtk.nix
index 664387de1707e..57de2fa2d474a 100644
--- a/pkgs/desktops/kde-5/plasma/breeze-gtk.nix
+++ b/pkgs/desktops/kde-5/plasma/breeze-gtk.nix
@@ -5,4 +5,5 @@
 plasmaPackage {
   name = "breeze-gtk";
   nativeBuildInputs = [ ecm ];
+  cmakeFlags = [ "-DWITH_GTK3_VERSION=3.20" ];
 }
diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix
index 8177afc037b5c..1e7e02f35109b 100644
--- a/pkgs/development/haskell-modules/configuration-common.nix
+++ b/pkgs/development/haskell-modules/configuration-common.nix
@@ -30,6 +30,9 @@ self: super: {
     hardeningDisable = [ "format" ];
   });
 
+  # This test keeps being aborted because it runs too quietly for too long
+  Lazy-Pbkdf2 = if pkgs.stdenv.isi686 then dontCheck super.Lazy-Pbkdf2 else super.Lazy-Pbkdf2;
+
   # Use the default version of mysql to build this package (which is actually mariadb).
   mysql = super.mysql.override { mysql = pkgs.mysql.lib; };
 
diff --git a/pkgs/development/interpreters/renpy/default.nix b/pkgs/development/interpreters/renpy/default.nix
index 355723ba3375e..dd735876435cc 100644
--- a/pkgs/development/interpreters/renpy/default.nix
+++ b/pkgs/development/interpreters/renpy/default.nix
@@ -1,7 +1,9 @@
-{ stdenv, fetchurl, python, cython, pkgconfig, wrapPython
-, pygame, SDL, libpng, ffmpeg, freetype, glew, mesa, fribidi, zlib
+{ stdenv, fetchurl, pythonPackages, pkgconfig, SDL
+, libpng, ffmpeg, freetype, glew, mesa, fribidi, zlib
 }:
 
+with pythonPackages;
+
 stdenv.mkDerivation {
   name = "renpy-6.17.6";
 
diff --git a/pkgs/development/libraries/armadillo/default.nix b/pkgs/development/libraries/armadillo/default.nix
index 937275b6528a1..62b5ddf8011a4 100644
--- a/pkgs/development/libraries/armadillo/default.nix
+++ b/pkgs/development/libraries/armadillo/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cmake, openblasCompat, superlu, hdf5 }:
+{ stdenv, fetchurl, cmake, openblasCompat, superlu, hdf5-cpp }:
 
 stdenv.mkDerivation rec {
   version = "7.200.2";
@@ -9,12 +9,11 @@ stdenv.mkDerivation rec {
     sha256 = "1yvx75caks477jqwx5gspi6946jialddk00wdvg6dnh5wdi2xasm";
   };
 
-  buildInputs = [ cmake openblasCompat superlu hdf5 ];
+  buildInputs = [ cmake openblasCompat superlu hdf5-cpp ];
 
   cmakeFlags = [ "-DDETECT_HDF5=ON" ];
 
-  patches = [ ./use-unix-config-on-OS-X.patch
-              ./use-OpenBLAS-as-LAPACK.patch ];
+  patches = [ ./use-unix-config-on-OS-X.patch ];
   
   meta = with stdenv.lib; {
     description = "C++ linear algebra library";
diff --git a/pkgs/development/libraries/armadillo/use-OpenBLAS-as-LAPACK.patch b/pkgs/development/libraries/armadillo/use-OpenBLAS-as-LAPACK.patch
deleted file mode 100644
index e4c77d2cc2e3e..0000000000000
--- a/pkgs/development/libraries/armadillo/use-OpenBLAS-as-LAPACK.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-diff --git a/cmake_aux/Modules/ARMA_FindLAPACK.cmake b/cmake_aux/Modules/ARMA_FindLAPACK.cmake
-index 5395afb..a203c93 100644
---- a/cmake_aux/Modules/ARMA_FindLAPACK.cmake
-+++ b/cmake_aux/Modules/ARMA_FindLAPACK.cmake
-@@ -5,7 +5,7 @@
- # also defined, but not for general use are
- #  LAPACK_LIBRARY, where to find the LAPACK library.
- 
--SET(LAPACK_NAMES ${LAPACK_NAMES} lapack)
-+SET(LAPACK_NAMES ${LAPACK_NAMES} openblas)
- FIND_LIBRARY(LAPACK_LIBRARY
-   NAMES ${LAPACK_NAMES}
-   PATHS /usr/lib64/atlas /usr/lib/atlas /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib
-
diff --git a/pkgs/development/libraries/cppzmq/default.nix b/pkgs/development/libraries/cppzmq/default.nix
index 62563cfb968ac..9da83ca913e71 100644
--- a/pkgs/development/libraries/cppzmq/default.nix
+++ b/pkgs/development/libraries/cppzmq/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "cppzmq-${version}";
-  version = "2016-01-20";
+  version = "2016-07-18";
 
   src = fetchFromGitHub {
     owner = "zeromq";
     repo = "cppzmq";
-    rev = "68a7b09cfce01c4c279fba2cf91686fcfc566848";
-    sha256 = "00dsqqlm8mxhm8kfdspxfln0wzwkyywscnf264afw02k6xf28ndm";
+    rev = "92d2af6def80a01b76d5e73f073c439ad00ab757";
+    sha256 = "0lnwh314hh5ifad2sa2nz1g1ld1jc4vplm7clyvx304sjjvbvl27";
   };
 
   installPhase = ''
diff --git a/pkgs/development/libraries/folly/default.nix b/pkgs/development/libraries/folly/default.nix
index dc07c481b10bc..f4ab12e3c7f1e 100644
--- a/pkgs/development/libraries/folly/default.nix
+++ b/pkgs/development/libraries/folly/default.nix
@@ -1,18 +1,18 @@
-{ stdenv, fetchFromGitHub, fetchpatch, autoreconfHook, boost, libevent, double_conversion, glog
-, google-gflags, python, libiberty, openssl }:
+{ stdenv, fetchFromGitHub, fetchpatch, autoreconfHook, pkgconfig, boost, libevent
+, double_conversion, glog, google-gflags, python, libiberty, openssl }:
 
 stdenv.mkDerivation rec {
   name = "folly-${version}";
-  version = "2016-04-29";
+  version = "2016.08.08.00";
 
   src = fetchFromGitHub {
     owner = "facebook";
     repo = "folly";
-    rev = "b31eb722e444ab0293a73fe9de3f94e657ca6de9";
-    sha256 = "0s95y0wnz4xbrkzbiksnb0n0d0qrkcsbssznng57kwlq8jlfka24";
+    rev = "v${version}";
+    sha256 = "0f9xdi8w2mbn6gxjfvpzh8i22ca8p11a2ss6qkw31yhdgd3s9087";
   };
 
-  nativeBuildInputs = [ autoreconfHook python ];
+  nativeBuildInputs = [ autoreconfHook python pkgconfig ];
   buildInputs = [ libiberty boost libevent double_conversion glog google-gflags openssl ];
 
   postPatch = "cd folly";
diff --git a/pkgs/development/libraries/icu/default.nix b/pkgs/development/libraries/icu/default.nix
index d2604b03f74f8..2f7c42c72b7c3 100644
--- a/pkgs/development/libraries/icu/default.nix
+++ b/pkgs/development/libraries/icu/default.nix
@@ -2,7 +2,7 @@
 
 let
   pname = "icu4c";
-  version = "56.1";
+  version = "57.1";
 in
 stdenv.mkDerivation ({
   name = pname + "-" + version;
@@ -10,7 +10,7 @@ stdenv.mkDerivation ({
   src = fetchurl {
     url = "http://download.icu-project.org/files/${pname}/${version}/${pname}-"
       + (stdenv.lib.replaceChars ["."] ["_"] version) + "-src.tgz";
-    sha256 = "05j86714qaj0lvhvyr2s1xncw6sk0h2dcghb3iiwykbkbh8fjr1s";
+    sha256 = "10cmkqigxh9f73y7q3p991q6j8pph0mrydgj11w1x6wlcp5ng37z";
   };
 
   outputs = [ "dev" "out" ];
diff --git a/pkgs/development/libraries/jemalloc/default.nix b/pkgs/development/libraries/jemalloc/default.nix
index 9b54ce482394a..a332487d4edf2 100644
--- a/pkgs/development/libraries/jemalloc/default.nix
+++ b/pkgs/development/libraries/jemalloc/default.nix
@@ -8,6 +8,11 @@ stdenv.mkDerivation rec {
     sha256 = "1bmdr51wxiir595k2r6z9a7rcgm42kkgnr586xir7vdcndr3pwf8";
   };
 
+  # By default, jemalloc puts a je_ prefix onto all its symbols on OSX, which
+  # then stops downstream builds (mariadb in particular) from detecting it. This
+  # option should remove the prefix and give us a working jemalloc.
+  configureFlags = stdenv.lib.optional stdenv.isDarwin "--with-jemalloc-prefix=";
+
   meta = with stdenv.lib; {
     homepage = http://www.canonware.com/jemalloc/index.html;
     description = "General purpose malloc(3) implementation";
diff --git a/pkgs/development/libraries/libbsd/default.nix b/pkgs/development/libraries/libbsd/default.nix
index 8597e0d9cf1f3..b7ec75338801e 100644
--- a/pkgs/development/libraries/libbsd/default.nix
+++ b/pkgs/development/libraries/libbsd/default.nix
@@ -9,12 +9,6 @@ in stdenv.mkDerivation {
     sha256 = "02i5brb2007sxq3mn862mr7yxxm0g6nj172417hjyvjax7549xmj";
   };
 
-  patchPhase = ''
-    substituteInPlace Makefile \
-      --replace "/usr" "$out" \
-      --replace "{exec_prefix}" "{prefix}"
-  '';
-
   meta = {
     description = "Common functions found on BSD systems";
     homepage = http://libbsd.freedesktop.org/;
diff --git a/pkgs/development/libraries/libdynd/default.nix b/pkgs/development/libraries/libdynd/default.nix
new file mode 100644
index 0000000000000..119c92d690de0
--- /dev/null
+++ b/pkgs/development/libraries/libdynd/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchFromGitHub, cmake }:
+
+let version = "0.7.2"; in
+stdenv.mkDerivation {
+  name = "libdynd-${version}";
+
+  src = fetchFromGitHub {
+    owner = "libdynd";
+    repo = "libdynd";
+    rev = "v${version}";
+    sha256 = "0fkd5rawqni1cq51fmr76iw7ll4fmbahfwv4rglnsabbkylf73pr";
+  };
+
+  cmakeFlags = [
+    "-DDYND_BUILD_BENCHMARKS=OFF"
+  ];
+
+  buildInputs = [ cmake ];
+
+  outputs = [ "dev" "out" ];
+  outputDoc = "dev";
+
+  meta = with stdenv.lib; {
+    description = "C++ dynamic ndarray library, with Python exposure.";
+    homepage = http://libdynd.org;
+    license = licenses.bsd2;
+  };
+}
diff --git a/pkgs/development/libraries/libvdpau-va-gl/default.nix b/pkgs/development/libraries/libvdpau-va-gl/default.nix
index 0cbac567a4521..8065df5c5b520 100644
--- a/pkgs/development/libraries/libvdpau-va-gl/default.nix
+++ b/pkgs/development/libraries/libvdpau-va-gl/default.nix
@@ -3,13 +3,13 @@
 
 stdenv.mkDerivation rec {
   name = "libvdpau-va-gl-${version}";
-  version = "0.3.6";
+  version = "0.4.0";
 
   src = fetchFromGitHub {
     owner = "i-rinat";
     repo = "libvdpau-va-gl";
     rev = "v${version}";
-    sha256 = "06lcg6zfj6mn17svz7s0y6ijdah55l9rnp9r440lcbixivjbgyn5";
+    sha256 = "1y511jxs0df1fqzjcvb6zln7nbmchv1g6z3lw0z9nsf64ziycj8k";
   };
 
   nativeBuildInputs = [ cmake pkgconfig ];
diff --git a/pkgs/development/libraries/science/math/ipopt/default.nix b/pkgs/development/libraries/science/math/ipopt/default.nix
index f9897e4add348..9ea3a54f2b0bd 100644
--- a/pkgs/development/libraries/science/math/ipopt/default.nix
+++ b/pkgs/development/libraries/science/math/ipopt/default.nix
@@ -1,17 +1,15 @@
 { stdenv, fetchurl, unzip, openblas, gfortran }:
 
 stdenv.mkDerivation rec {
-  version = "3.12.4";
+  version = "3.12.6";
   name = "ipopt-${version}";
 
   src = fetchurl {
     url = "http://www.coin-or.org/download/source/Ipopt/Ipopt-${version}.zip";
-    sha256 = "0hxmpi3zx5zgv2ijscdvc40xf88hx5if0d9sgch155z70g15wx0l";
+    sha256 = "0lx09h1757s5jppwnxwblcjk0biqjxy7yaf3z4vfqbl4rl93avs0";
   };
 
-  preConfigure = ''
-     export CXXDEFS="-DHAVE_RAND -DHAVE_CSTRING -DHAVE_CSTDIO"
-  '';
+  CXXDEFS = [ "-DHAVE_RAND" "-DHAVE_CSTRING" "-DHAVE_CSTDIO" ];
 
   configureFlags = [
     "--with-blas-lib=-lopenblas"
diff --git a/pkgs/development/libraries/xgboost/default.nix b/pkgs/development/libraries/xgboost/default.nix
index 4ba366be56f01..bdc21d72ac334 100644
--- a/pkgs/development/libraries/xgboost/default.nix
+++ b/pkgs/development/libraries/xgboost/default.nix
@@ -2,17 +2,15 @@
 
 stdenv.mkDerivation rec {
   name = "xgboost-${version}";
-  version = "2016-05-14";
+  version = "0.60";
 
   # needs submodules
   src = fetchgit {
     url = "https://github.com/dmlc/xgboost";
-    rev = "9c26566eb09733423f821f139938ff4105c3775d";
-    sha256 = "1d7lnbwxwakclqqfjwyk9w3wd2clkihdr6ljs5z08ydiaspri093";
+    rev = "refs/tags/v${version}";
+    sha256 = "0536vfl59n9vlagl1cpdl06c9y19dscwhwdzvi27zk5nc5qb6rdq";
   };
 
-  postPatch = "sed '1i#include <cmath>' -i src/tree/param.h";
-
   enableParallelBuilding = true;
 
   installPhase = ''
diff --git a/pkgs/development/python-modules/pyqt/4.x.nix b/pkgs/development/python-modules/pyqt/4.x.nix
index 746cc747d72d0..ead5c4ffe9d29 100644
--- a/pkgs/development/python-modules/pyqt/4.x.nix
+++ b/pkgs/development/python-modules/pyqt/4.x.nix
@@ -40,7 +40,10 @@ stdenv.mkDerivation {
 
   enableParallelBuilding = true;
 
-  passthru.pythonPath = [];
+  passthru = {
+    pythonPath = [];
+    qt = qt4;
+  };
 
   meta = {
     description = "Python bindings for Qt";
diff --git a/pkgs/development/tools/java/visualvm/default.nix b/pkgs/development/tools/java/visualvm/default.nix
new file mode 100644
index 0000000000000..2620a5b7741ac
--- /dev/null
+++ b/pkgs/development/tools/java/visualvm/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchzip, lib, makeWrapper, jdk, gtk }:
+
+stdenv.mkDerivation rec {
+  name = "visualvm-1.3.8";
+
+  src = fetchzip {
+    url = "https://java.net/projects/visualvm/downloads/download/release138/visualvm_138.zip";
+    sha256 = "09wsi85z1g7bwyfhb37vw0gy3wl0j1cy35aj59rg7067q262gy1y";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  installPhase = ''
+    rm bin/visualvm.exe
+
+    substituteInPlace etc/visualvm.conf \
+      --replace "#visualvm_jdkhome=" "visualvm_jdkhome=" \
+      --replace "/path/to/jdk" "${jdk.home}" \
+      --replace 'visualvm_default_options="' 'visualvm_default_options="--laf com.sun.java.swing.plaf.gtk.GTKLookAndFeel -J-Dawt.useSystemAAFontSettings=lcd -J-Dswing.aatext=true '
+
+    cp -r . $out
+
+    # To get the native LAF, JVM needs to see GTK’s .so-s.
+    wrapProgram $out/bin/visualvm \
+      --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ gtk ]}"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A visual interface for viewing information about Java applications";
+    longDescription = ''
+      VisualVM is a visual tool integrating several commandline JDK
+      tools and lightweight profiling capabilities. Designed for both
+      production and development time use, it further enhances the
+      capability of monitoring and performance analysis for the Java
+      SE platform.
+    '';
+    homepage = https://visualvm.java.net/;
+    license = licenses.gpl2ClasspathPlus;
+    platforms = platforms.all;
+    maintainers = with maintainers; [ michalrus ];
+  };
+}
diff --git a/pkgs/development/tools/pypi2nix/default.nix b/pkgs/development/tools/pypi2nix/default.nix
index 2884b23049ab4..01fe4b73d6ca2 100644
--- a/pkgs/development/tools/pypi2nix/default.nix
+++ b/pkgs/development/tools/pypi2nix/default.nix
@@ -3,21 +3,16 @@
 
 let
   deps = import ./deps.nix { inherit fetchurl; };
-  version = "1.3.0";
+  version = "1.4.0";
   src = fetchurl {
     url = "https://github.com/garbas/pypi2nix/archive/v${version}.tar.gz";
-    sha256 = "0mk9v4s51jdrrcs78v3cm131pz3fdhjkd4cmmfn1kkcfcpqzw6j8";
-    
+    sha256 = "0w5f10p4d4ppwg2plbbrmqwmi1ycgpaidyajza11c9svka014zrb";
   };
 in stdenv.mkDerivation rec {
   name = "pypi2nix-${version}";
   srcs = with deps; [
     src
-    pip
     click
-    setuptools
-    zcbuildout
-    zcrecipeegg
     requests
   ];  # six attrs effect ];
   buildInputs = [ python zip makeWrapper ];
@@ -26,17 +21,13 @@ in stdenv.mkDerivation rec {
   postUnpack = ''
     mkdir -p $out/pkgs
 
-    mv pip-*/pip                        $out/pkgs/pip
     mv click-*/click                    $out/pkgs/click
-    mv setuptools-*/setuptools          $out/pkgs/setuptools
-    mv zc.buildout-*/src/zc             $out/pkgs/zc
-    mv zc.recipe.egg-*/src/zc/recipe    $out/pkgs/zc/recipe
     # mv six-*/six.py                    $out/pkgs/
     # mv attrs-*/src/attr                $out/pkgs/attrs
     # mv effect-*/effect                 $out/pkgs/effect
     mv requests-*/requests              $out/pkgs/
 
-    if [ -z "$IN_NIX_SHELL" ]; then
+    if [ "$IN_NIX_SHELL" != "1" ]; then
       if [ -e git-export ]; then
         mv git-export/src/pypi2nix      $out/pkgs/pypi2nix
       else
@@ -48,9 +39,9 @@ in stdenv.mkDerivation rec {
   commonPhase = ''
     mkdir -p $out/bin
 
-    echo "#!${python}/bin/python3"       >  $out/bin/pypi2nix
-    echo "import pypi2nix.cli"          >> $out/bin/pypi2nix
-    echo "pypi2nix.cli.main()"          >> $out/bin/pypi2nix
+    echo "#!${python.interpreter}" >  $out/bin/pypi2nix
+    echo "import pypi2nix.cli" >> $out/bin/pypi2nix
+    echo "pypi2nix.cli.main()" >> $out/bin/pypi2nix
 
     chmod +x $out/bin/pypi2nix
 
@@ -81,6 +72,5 @@ in stdenv.mkDerivation rec {
     homepage = https://github.com/garbas/pypi2nix;
     description = "A tool that generates nix expressions for your python packages, so you don't have to.";
     maintainers = with stdenv.lib.maintainers; [ garbas ];
-    platforms = with stdenv.lib.platforms; unix;
   };
 }
diff --git a/pkgs/development/tools/pypi2nix/deps.nix b/pkgs/development/tools/pypi2nix/deps.nix
index 5d6f23c26c037..e67cb51c67c77 100644
--- a/pkgs/development/tools/pypi2nix/deps.nix
+++ b/pkgs/development/tools/pypi2nix/deps.nix
@@ -17,6 +17,9 @@ rec {
   zcrecipeeggVersion = "2.0.3";
   zcrecipeeggHash = "69a8ce276029390a36008150444aa0b4";
 
+  buildoutrequirementsVersion = "0.2.2";
+  buildoutrequirementsHash = "0b4e53d871b167eaac0846942221af00";
+
   wheelVersion = "0.29.0";
   wheelHash = "555a67e4507cedee23a0deb9651e452f";
 
@@ -71,6 +74,11 @@ rec {
     md5 = zcrecipeeggHash;
   };
 
+  buildoutrequirements = fetchurl {
+    url = "https://github.com/garbas/buildout.requirements/archive/1e2977e2d254184399401746736d2b17c912b350.tar.gz";
+    md5 = buildoutrequirementsHash;
+  };
+
   wheel = fetchurl {
     url = "https://pypi.python.org/packages/c9/1d/bd19e691fd4cfe908c76c429fe6e4436c9e83583c4414b54f6c85471954a/wheel-${wheelVersion}.tar.gz";
     md5 = wheelHash;
diff --git a/pkgs/games/crawl/default.nix b/pkgs/games/crawl/default.nix
index 32f9afaacf27d..edaa3ef1fccf6 100644
--- a/pkgs/games/crawl/default.nix
+++ b/pkgs/games/crawl/default.nix
@@ -3,15 +3,15 @@
 , tileMode ? false
 }:
 
-let version = "0.18.0";
-in
 stdenv.mkDerivation rec {
   name = "crawl-${version}" + (if tileMode then "-tiles" else "");
+  version = "0.18.1";
+
   src = fetchFromGitHub {
     owner = "crawl-ref";
     repo = "crawl-ref";
     rev = version;
-    sha256 = "0mgg9lzy7lp5bhp8340a6c6qyz7yiz80wb39gknls8hvv0f6i0si";
+    sha256 = "1cg5mxhx0lfhadls6n8avcpkjx08nqf1y085li97zqxl3gjaj64j";
   };
 
   patches = [ ./crawl_purify.patch ];
diff --git a/pkgs/games/dwarf-fortress/default.nix b/pkgs/games/dwarf-fortress/default.nix
index 4eab8290933e4..64109279060a8 100644
--- a/pkgs/games/dwarf-fortress/default.nix
+++ b/pkgs/games/dwarf-fortress/default.nix
@@ -5,7 +5,7 @@ let
   callPackage_i686 = pkgsi686Linux.newScope self;
 
   self = rec {
-    dwarf-fortress-original = callPackage_i686 ./game.nix { };
+    dwarf-fortress-original = callPackage ./game.nix { };
 
     dfhack = callPackage_i686 ./dfhack {
       inherit (pkgsi686Linux.perlPackages) XMLLibXML XMLLibXSLT;
@@ -14,7 +14,7 @@ let
       };
     };
 
-    dwarf-fortress-unfuck = callPackage_i686 ./unfuck.nix { };
+    dwarf-fortress-unfuck = callPackage ./unfuck.nix { };
 
     dwarf-fortress = callPackage ./wrapper {
       themes = {
diff --git a/pkgs/games/dwarf-fortress/dfhack/default.nix b/pkgs/games/dwarf-fortress/dfhack/default.nix
index 1ee0f829571db..176971920071b 100644
--- a/pkgs/games/dwarf-fortress/dfhack/default.nix
+++ b/pkgs/games/dwarf-fortress/dfhack/default.nix
@@ -5,8 +5,9 @@
 }:
 
 let
-  dfVersion = "0.42.06";
+  dfVersion = "0.43.03";
   version = "${dfVersion}-r1";
+
   rev = "refs/tags/${version}";
   # revision of library/xml submodule
   xmlRev = "98cc1e01886aaea161d651cf97229ad08e9782b0";
@@ -14,7 +15,7 @@ let
   fakegit = writeScriptBin "git" ''
     #! ${stdenv.shell}
     if [ "$*" = "describe --tags --long" ]; then
-      echo "${dfVersion}-unknown"
+      echo "${version}-unknown"
     elif [ "$*" = "rev-parse HEAD" ]; then
       if [ "$(dirname "$(pwd)")" = "xml" ]; then
         echo "${xmlRev}"
@@ -35,19 +36,20 @@ in stdenv.mkDerivation rec {
   src = fetchgit {
     url = "https://github.com/DFHack/dfhack";
     inherit rev;
-    sha256 = "1p234m8r84cdr4bx622hcd13mshnjc5bw7hdxhv18waaxvdpv6jh";
+    sha256 = "0m5kqpaz0ypji4c32w0hhbsicvgvnjh56pqvq7af6pqqnyg1nzcx";
   };
 
   patches = [ ./use-system-libraries.patch ];
-  postPatch = "sed '1i#include <math.h>' -i plugins/3dveins.cpp";
 
   nativeBuildInputs = [ cmake perl XMLLibXML XMLLibXSLT fakegit ];
   # we can't use native Lua; upstream uses private headers
   buildInputs = [ zlib jsoncpp protobuf tinyxml ];
 
+  cmakeFlags = [ "-DEXTERNAL_TINYXML=ON" ];
+
   enableParallelBuilding = true;
 
-  passthru = { inherit dfVersion; };
+  passthru = { inherit version dfVersion; };
 
   meta = with stdenv.lib; {
     description = "Memory hacking library for Dwarf Fortress and a set of tools that use it";
diff --git a/pkgs/games/dwarf-fortress/dfhack/use-system-libraries.patch b/pkgs/games/dwarf-fortress/dfhack/use-system-libraries.patch
index b6ff92398a54c..e33fec9f87ece 100644
--- a/pkgs/games/dwarf-fortress/dfhack/use-system-libraries.patch
+++ b/pkgs/games/dwarf-fortress/dfhack/use-system-libraries.patch
@@ -1,5 +1,5 @@
 diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 46fd565..254c3c0 100644
+index 956edfc..fb0e6bc 100644
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
 @@ -160,8 +160,6 @@ ELSEIF(MSVC)
@@ -11,7 +11,7 @@ index 46fd565..254c3c0 100644
  ADD_DEFINITIONS(-DLUA_BUILD_AS_DLL)
  
  if(APPLE)
-@@ -182,11 +180,8 @@ else()
+@@ -182,10 +180,8 @@ else()
      set(ZLIB_ROOT /usr/lib/i386-linux-gnu)
  endif()
  find_package(ZLIB REQUIRED)
@@ -19,27 +19,31 @@ index 46fd565..254c3c0 100644
  include_directories(depends/lua/include)
  include_directories(depends/md5)
 -include_directories(depends/jsoncpp)
--include_directories(depends/tinyxml)
- include_directories(depends/tthread)
- include_directories(${ZLIB_INCLUDE_DIRS})
- include_directories(depends/clsocket/src)
+ 
+ # Support linking against external tinyxml
+ # If we find an external tinyxml, set the DFHACK_TINYXML variable to "tinyxml"
 diff --git a/depends/CMakeLists.txt b/depends/CMakeLists.txt
-index bf0345b..2a1a852 100644
+index d8442b1..b47dc2a 100644
 --- a/depends/CMakeLists.txt
 +++ b/depends/CMakeLists.txt
-@@ -1,10 +1,7 @@
+@@ -1,7 +1,6 @@
  #list depends here.
  add_subdirectory(lua)
  add_subdirectory(md5)
 -add_subdirectory(protobuf)
--add_subdirectory(tinyxml)
+ 
+ # Don't build tinyxml if it's being externally linked against.
+ if(NOT TinyXML_FOUND)
+@@ -9,7 +8,6 @@ if(NOT TinyXML_FOUND)
+ endif()
+ 
  add_subdirectory(tthread)
 -add_subdirectory(jsoncpp)
  # build clsocket static and only as a dependency. Setting those options here overrides its own default settings.
  OPTION(CLSOCKET_SHARED "Build clsocket lib as shared." OFF)
  OPTION(CLSOCKET_DEP_ONLY "Build for use inside other CMake projects as dependency." ON)
 diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
-index 54300ec..128bfd1 100644
+index d3e3480..5d4b572 100644
 --- a/library/CMakeLists.txt
 +++ b/library/CMakeLists.txt
 @@ -223,10 +223,10 @@ LIST(APPEND PROJECT_SOURCES ${PROJECT_PROTO_SRCS})
@@ -55,24 +59,8 @@ index 54300ec..128bfd1 100644
  )
  
  # Merge headers into sources
-@@ -269,12 +269,12 @@ IF(UNIX)
- ENDIF()
- 
- IF(APPLE)
--  SET(PROJECT_LIBS dl dfhack-md5 dfhack-tinyxml dfhack-tinythread)
-+  SET(PROJECT_LIBS dl dfhack-md5 tinyxml dfhack-tinythread)
- ELSEIF(UNIX)
--  SET(PROJECT_LIBS rt dl dfhack-md5 dfhack-tinyxml dfhack-tinythread)
-+  SET(PROJECT_LIBS rt dl dfhack-md5 tinyxml dfhack-tinythread)
- ELSE(WIN32)
-   #FIXME: do we really need psapi?
--  SET(PROJECT_LIBS psapi dfhack-md5 dfhack-tinyxml dfhack-tinythread)
-+  SET(PROJECT_LIBS psapi dfhack-md5 tinyxml dfhack-tinythread)
- ENDIF()
- 
- ADD_LIBRARY(dfhack-version STATIC DFHackVersion.cpp)
 diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
-index dd1c634..7bd8c17 100644
+index c24b940..afeb888 100644
 --- a/plugins/CMakeLists.txt
 +++ b/plugins/CMakeLists.txt
 @@ -47,11 +47,11 @@ STRING(REPLACE ".proto" ".pb.h" PROJECT_PROTO_HDRS "${PROJECT_PROTOS}")
diff --git a/pkgs/games/dwarf-fortress/game.nix b/pkgs/games/dwarf-fortress/game.nix
index 0665075356c44..740125bf4426d 100644
--- a/pkgs/games/dwarf-fortress/game.nix
+++ b/pkgs/games/dwarf-fortress/game.nix
@@ -3,10 +3,18 @@
 }:
 
 let
-  baseVersion = "42";
-  patchVersion = "06";
+  baseVersion = "43";
+  patchVersion = "05";
   dfVersion = "0.${baseVersion}.${patchVersion}";
   libpath = lib.makeLibraryPath [ stdenv.cc.cc stdenv.glibc dwarf-fortress-unfuck SDL ];
+  platform =
+    if stdenv.system == "x86_64-linux" then "linux"
+    else if stdenv.system == "i686-linux" then "linux32"
+    else throw "Unsupported platform";
+  sha256 =
+    if stdenv.system == "x86_64-linux" then "1r0b96yrdf24m9476k5x7rmp3faxr0kfwwdf35agpvlb1qbi6v45"
+    else if stdenv.system == "i686-linux" then "16l1lydpkbnl3zhz4i2snmjk7pps8vmw3zv0bjgr8dncbsrycd03"
+    else throw "Unsupported platform";
 
 in
 
@@ -16,8 +24,8 @@ stdenv.mkDerivation {
   name = "dwarf-fortress-original-${dfVersion}";
 
   src = fetchurl {
-    url = "http://www.bay12games.com/dwarves/df_${baseVersion}_${patchVersion}_linux.tar.bz2";
-    sha256 = "17y9zq9xn1g0a501w4vkinb0n2yjiczsi2g7r6zggr41pxrqxpq3";
+    url = "http://www.bay12games.com/dwarves/df_${baseVersion}_${patchVersion}_${platform}.tar.bz2";
+    inherit sha256;
   };
 
   installPhase = ''
@@ -39,11 +47,11 @@ stdenv.mkDerivation {
 
   passthru = { inherit baseVersion patchVersion dfVersion; };
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "A single-player fantasy game with a randomly generated adventure world";
     homepage = http://www.bay12games.com/dwarves;
-    license = lib.licenses.unfreeRedistributable;
-    platforms = [ "i686-linux" ];
-    maintainers = with lib.maintainers; [ a1russell robbinch roconnor the-kenny abbradar ];
+    license = licenses.unfreeRedistributable;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ a1russell robbinch roconnor the-kenny abbradar ];
   };
 }
diff --git a/pkgs/games/dwarf-fortress/themes/cla.nix b/pkgs/games/dwarf-fortress/themes/cla.nix
index b1a27c7e47bac..3933d62b1d386 100644
--- a/pkgs/games/dwarf-fortress/themes/cla.nix
+++ b/pkgs/games/dwarf-fortress/themes/cla.nix
@@ -5,13 +5,13 @@
 
 stdenv.mkDerivation rec {
   name = "cla-theme-${version}";
-  version = "42.06-v22";
+  version = "43.04-v23";
 
   src = fetchFromGitHub {
     owner = "DFgraphics";
     repo = "CLA";
     rev = version;
-    sha256 = "1rr52j1wns17axc27fab0wn0338axzwkqp7cpa690kb3bl1y0pf5";
+    sha256 = "0a88jkcli9iq0prg5w0xh1cyms0b7dnc9rdahn7wy7fyakyp7s27";
   };
 
   installPhase = ''
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
     cp -r data raw $out
   '';
 
-  passthru.dfVersion = "0.42.06";
+  passthru.dfVersion = "0.43.05";
 
   preferLocalBuild = true;
 
diff --git a/pkgs/games/dwarf-fortress/themes/phoebus.nix b/pkgs/games/dwarf-fortress/themes/phoebus.nix
index 0022f9dc1c735..01ae192e75e6b 100644
--- a/pkgs/games/dwarf-fortress/themes/phoebus.nix
+++ b/pkgs/games/dwarf-fortress/themes/phoebus.nix
@@ -5,13 +5,13 @@
 
 stdenv.mkDerivation rec {
   name = "phoebus-theme-${version}";
-  version = "42.06a";
+  version = "43.03";
 
   src = fetchFromGitHub {
     owner = "DFgraphics";
     repo = "Phoebus";
     rev = version;
-    sha256 = "1mkj882mf1lvjs2b7jxfazym9fl1y20slbfi1lgqzbp1872aaxi0";
+    sha256 = "1mga5w3mks3bm6qch7azffr51g3q26za7hnas4qmxfs3m56bjav7";
   };
 
   installPhase = ''
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
     cp -r data raw $out
   '';
 
-  passthru.dfVersion = "0.42.06";
+  passthru.dfVersion = "0.43.05";
 
   preferLocalBuild = true;
 
diff --git a/pkgs/games/dwarf-fortress/unfuck.nix b/pkgs/games/dwarf-fortress/unfuck.nix
index 5b2327c2ff54f..5e299c5316ba6 100644
--- a/pkgs/games/dwarf-fortress/unfuck.nix
+++ b/pkgs/games/dwarf-fortress/unfuck.nix
@@ -4,17 +4,15 @@
 }:
 
 stdenv.mkDerivation {
-  name = "dwarf_fortress_unfuck-2016-04-22";
+  name = "dwarf_fortress_unfuck-2016-07-13";
 
   src = fetchFromGitHub {
     owner = "svenstaro";
     repo = "dwarf_fortress_unfuck";
-    rev = "dde40a2c619eac119b6db1bcd0c8d8612472f866";
-    sha256 = "12bqh3k4wsk1c0bz2zly8h0ilbsdmsbwr9cdjc6i7liwg9906g7i";
+    rev = "d6a4ee67e7b41bec1caa87548640643db35a6080";
+    sha256 = "17p7jzmwd5z54wn6bxmic0i8y8mma3q359zcy3r9x2mp2wv1yd7p";
   };
 
-  postPatch = "sed '1i#include <math.h>' -i g_src/ttf_manager.cpp";
-
   cmakeFlags = [
     "-DGTK2_GLIBCONFIG_INCLUDE_DIR=${glib.out}/lib/glib-2.0/include"
     "-DGTK2_GDKCONFIG_INCLUDE_DIR=${gtk2.out}/lib/gtk-2.0/include"
@@ -32,13 +30,13 @@ stdenv.mkDerivation {
 
   enableParallelBuilding = true;
 
-  passthru.dfVersion = "0.42.06";
+  passthru.dfVersion = "0.43.05";
 
   meta = with stdenv.lib; {
     description = "Unfucked multimedia layer for Dwarf Fortress";
     homepage = https://github.com/svenstaro/dwarf_fortress_unfuck;
     license = licenses.free;
-    platforms = [ "i686-linux" ];
+    platforms = platforms.linux;
     maintainers = with maintainers; [ abbradar ];
   };
 }
diff --git a/pkgs/games/factorio/fetch.nix b/pkgs/games/factorio/fetch.nix
index 78c7faf018cea..04b31ac10d35d 100644
--- a/pkgs/games/factorio/fetch.nix
+++ b/pkgs/games/factorio/fetch.nix
@@ -1,4 +1,4 @@
-{ stdenv, curl, cacert
+{ stdenv, curl, xidel, cacert
 # Begin download parameters
 , username ? ""
 , password ? ""
@@ -18,7 +18,7 @@
 stdenv.mkDerivation {
   name = "factorio.tar.gz";
 
-  buildInputs = [ curl ];
+  buildInputs = [ curl xidel ];
 
   inherit url loginUrl username password cacert;
 
diff --git a/pkgs/games/factorio/fetch.sh b/pkgs/games/factorio/fetch.sh
index d6549c0a67688..30d9c9fdefe04 100644
--- a/pkgs/games/factorio/fetch.sh
+++ b/pkgs/games/factorio/fetch.sh
@@ -9,23 +9,34 @@ curl="curl \
  --max-redirs 20 \
  --retry 3 \
  --cacert $cacert/etc/ssl/certs/ca-bundle.crt \
+ -b cookies \
+ -c cookies \
  $curlOpts \
  $NIX_CURL_FLAGS"
 
 # We don't want the password to be on any program's argv, as it may be
 # visible in /proc. Writing it to file with echo should be safe, since
 # it's a shell builtin.
-echo "password=$password" > password
+echo -n "$password" > password
 # Might as well hide the username as well.
-echo "username-or-email=$username" > username
+echo -n "$username" > username
+
+# Get a CSRF token.
+csrf=$($curl $loginUrl | xidel - -e '//input[@id="csrf_token"]/@value')
 
 # Log in. We don't especially care about the result, but let's check if login failed.
-$curl -c cookies -d @username -d @password $loginUrl -D headers > /dev/null
+$curl --data-urlencode csrf_token="$csrf" \
+      --data-urlencode username_or_email@username \
+      --data-urlencode password@password \
+      -d action=Login \
+      $loginUrl -D headers > /dev/null
 
-if grep -q 'Location: /' headers; then
+if grep -q 'Location: https://' headers; then
     # Now download. We need --insecure for this, but the sha256 should cover us.
-    $curl -b cookies --insecure --location $url > $out
+    $curl --insecure --location $url > $out
+    set +x
 else
+    set +x
     echo 'Login failed'
     echo 'Please set username and password with config.nix,'
     echo 'or /etc/nix/nixpkgs-config.nix if on NixOS.'
diff --git a/pkgs/games/mnemosyne/default.nix b/pkgs/games/mnemosyne/default.nix
index d4f90a906d801..0d419c08b006c 100644
--- a/pkgs/games/mnemosyne/default.nix
+++ b/pkgs/games/mnemosyne/default.nix
@@ -1,12 +1,10 @@
 { stdenv
 , fetchurl
-, buildPythonApplication
-, pyqt4
 , pythonPackages
 }:
 let
   version = "2.3.2";
-in buildPythonApplication rec {
+in pythonPackages.buildPythonApplication rec {
   name = "mnemosyne-${version}";
   src = fetchurl {
     url    = "http://sourceforge.net/projects/mnemosyne-proj/files/mnemosyne/${name}/Mnemosyne-${version}.tar.gz";
diff --git a/pkgs/games/quake3/ioquake/default.nix b/pkgs/games/quake3/ioquake/default.nix
index 2fff7e7a02602..f03b8dde13e86 100644
--- a/pkgs/games/quake3/ioquake/default.nix
+++ b/pkgs/games/quake3/ioquake/default.nix
@@ -4,13 +4,13 @@
 
 stdenv.mkDerivation rec {
   name = "ioquake3-git-${version}";
-  version = "2016-04-05";
+  version = "2016-08-11";
 
   src = fetchFromGitHub {
     owner = "ioquake";
     repo = "ioq3";
-    rev = "1f6703821f11be9c711c6ee42371ab290dd12776";
-    sha256 = "0jbn4lv85khfcmn1dc3mrx7zxldj3p4cggx85hdfpiwmnsjl4w67";
+    rev = "1cf0b21cda562bade9152958f1525e5ac281ab9c";
+    sha256 = "104yrgi9dnfb493pm9wvk2kn80nazcr1nllb5vd7di66jnvcjks0";
   };
 
   nativeBuildInputs = [ which pkgconfig ];
diff --git a/pkgs/games/steam/runtime-generated.nix b/pkgs/games/steam/runtime-generated.nix
index 854796cac3e84..260b7a9b8d83b 100644
--- a/pkgs/games/steam/runtime-generated.nix
+++ b/pkgs/games/steam/runtime-generated.nix
@@ -1255,6 +1255,15 @@
       };
     }
     rec {
+      name = "libvulkan1_1.0.3~git20160215-0.1+steamos5+srt1_amd64";
+      md5 = "4d9ac7966de8160a13817291206b51a4";
+      url = "mirror://steamrt/pool/main/v/vulkan-loader/libvulkan1_1.0.3~git20160215-0.1+steamos5+srt1_amd64.deb";
+      source = fetchurl {
+        inherit url md5;
+        name = "libvulkan1.deb";
+      };
+    }
+    rec {
       name = "libwind0-heimdal_1.6~git20120311.dfsg.1-2+srt4_amd64";
       md5 = "a1e5b4a8f8200feef82dab976f1b4e5d";
       url = "mirror://steamrt/pool/main/h/heimdal/libwind0-heimdal_1.6~git20120311.dfsg.1-2+srt4_amd64.deb";
@@ -2994,6 +3003,15 @@
       };
     }
     rec {
+      name = "libvulkan1_1.0.3~git20160215-0.1+steamos5+srt1_i386";
+      md5 = "de2c787fcc443fb989b1862367a2e0c7";
+      url = "mirror://steamrt/pool/main/v/vulkan-loader/libvulkan1_1.0.3~git20160215-0.1+steamos5+srt1_i386.deb";
+      source = fetchurl {
+        inherit url md5;
+        name = "libvulkan1.deb";
+      };
+    }
+    rec {
       name = "libwind0-heimdal_1.6~git20120311.dfsg.1-2+srt4_i386";
       md5 = "6265aab9d541aea8aad3496ebcc5908e";
       url = "mirror://steamrt/pool/main/h/heimdal/libwind0-heimdal_1.6~git20120311.dfsg.1-2+srt4_i386.deb";
diff --git a/pkgs/games/steam/runtime.nix b/pkgs/games/steam/runtime.nix
index 9236243427a23..fa1da47919634 100644
--- a/pkgs/games/steam/runtime.nix
+++ b/pkgs/games/steam/runtime.nix
@@ -9,7 +9,7 @@ let arch = if stdenv.system == "x86_64-linux" then "amd64"
     inputFile = writeText "steam-runtime.json" (builtins.toJSON input);
 
 in stdenv.mkDerivation {
-  name = "steam-runtime-2016-03-03";
+  name = "steam-runtime-2016-08-13";
 
   nativeBuildInputs = [ python2 dpkg binutils ];
 
diff --git a/pkgs/games/the-powder-toy/default.nix b/pkgs/games/the-powder-toy/default.nix
index 14f05f8f1a887..142fbb2b71ad5 100644
--- a/pkgs/games/the-powder-toy/default.nix
+++ b/pkgs/games/the-powder-toy/default.nix
@@ -1,14 +1,14 @@
 { stdenv, fetchFromGitHub, scons, pkgconfig, SDL, lua, fftwFloat }:
 
-let version = "91.3.328";
-in
 stdenv.mkDerivation rec {
   name = "the-powder-toy-${version}";
+  version = "91.5.330";
+
   src = fetchFromGitHub {
     owner = "simtr";
     repo = "The-Powder-Toy";
     rev = "v${version}";
-    sha256 = "0krg4d2m8cnfabm5qq7wr1y53h21i49xjcggzg98xjd0972zvfrk";
+    sha256 = "19m7jyg3pnppymvr6lz454mjiw18hvldpdhi33596m9ji3nrq8x7";
   };
 
   patches = [ ./fix-env.patch ];
diff --git a/pkgs/games/wesnoth/dev.nix b/pkgs/games/wesnoth/dev.nix
index 84b135a5df8e1..a7e621460b66e 100644
--- a/pkgs/games/wesnoth/dev.nix
+++ b/pkgs/games/wesnoth/dev.nix
@@ -5,13 +5,13 @@
 
 stdenv.mkDerivation rec {
   pname = "wesnoth";
-  version = "1.13.4";
+  version = "1.13.5";
 
   name = "${pname}-${version}";
 
   src = fetchurl {
     url = "mirror://sourceforge/sourceforge/${pname}/${name}.tar.bz2";
-    sha256 = "1ys25ijwphld11002cad9iz5mc5rqazmjn8866l8gcdfrrhk943s";
+    sha256 = "15hvf06r7086plwmagh89plcxal2zql8k4mg0yf1zgwjvdz284dx";
   };
 
   nativeBuildInputs = [ cmake pkgconfig ];
diff --git a/pkgs/misc/drivers/hplip/3.15.9.nix b/pkgs/misc/drivers/hplip/3.15.9.nix
index 5c989594b3bcf..298cba88a9f1a 100644
--- a/pkgs/misc/drivers/hplip/3.15.9.nix
+++ b/pkgs/misc/drivers/hplip/3.15.9.nix
@@ -3,7 +3,7 @@
 , cups, zlib, libjpeg, libusb1, pythonPackages, sane-backends, dbus, usbutils
 , net_snmp, polkit
 , bash, coreutils, utillinux
-, qtSupport ? true, qt4, pyqt4
+, qtSupport ? true, qt4
 , withPlugin ? false
 }:
 
diff --git a/pkgs/misc/drivers/hplip/default.nix b/pkgs/misc/drivers/hplip/default.nix
index 32997f98b217f..74204cd4e5479 100644
--- a/pkgs/misc/drivers/hplip/default.nix
+++ b/pkgs/misc/drivers/hplip/default.nix
@@ -3,7 +3,7 @@
 , cups, zlib, libjpeg, libusb1, pythonPackages, sane-backends, dbus, usbutils
 , net_snmp, openssl, polkit
 , bash, coreutils, utillinux
-, qtSupport ? true, qt4, pyqt4
+, qtSupport ? true, qt4
 , withPlugin ? false
 }:
 
diff --git a/pkgs/misc/drivers/m3d-linux/default.nix b/pkgs/misc/drivers/m33-linux/default.nix
index 0e970e30d5891..492488f675f2d 100644
--- a/pkgs/misc/drivers/m3d-linux/default.nix
+++ b/pkgs/misc/drivers/m33-linux/default.nix
@@ -1,18 +1,18 @@
 { stdenv, fetchFromGitHub }:
 
 stdenv.mkDerivation {
-  name = "M3D-Linux-2016-01-20";
+  name = "M33-Linux-2016-06-23";
 
   src = fetchFromGitHub {
     owner = "donovan6000";
     repo = "M3D-Linux";
-    rev = "d0bbb0379c52a88af55740a937edc92af162cdf6";
-    sha256 = "0fwzb9mf04bw5wxabh3js7nir60kfq8iz7kcigw6c233aadwg03i";
+    rev = "5c1b90c13d260771dac970b49fdc9f840fee5f4a";
+    sha256 = "1bvbclkyfcv23vxb4s1zssvygklks1nhp4iwi4v90c1fvyz0356f";
   };
 
   installPhase = ''
-    install -Dm755 m3d-linux $out/bin/m3d-linux
-    install -Dm755 90-m3d-local.rules $out/lib/udev/rules.d/90-m3d-local.rules
+    install -Dm755 m33-linux $out/bin/m33-linux
+    install -Dm755 90-micro-3d-local.rules $out/lib/udev/rules.d/90-micro-3d-local.rules
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/misc/emulators/wine/sources.nix b/pkgs/misc/emulators/wine/sources.nix
index 9a437971e4266..92ed55be2de87 100644
--- a/pkgs/misc/emulators/wine/sources.nix
+++ b/pkgs/misc/emulators/wine/sources.nix
@@ -30,9 +30,9 @@ in rec {
   };
 
   unstable = fetchurl rec {
-    version = "1.9.14";
+    version = "1.9.16";
     url = "mirror://sourceforge/wine/wine-${version}.tar.bz2";
-    sha256 = "0b65j8lc2axyc7lpa5rjr7vbjz4y78gkd7hhmvhra78pmwf9dgkz";
+    sha256 = "010gjib4nhrn9j9q12v5irda8df8xp17a6v6qqskkadd79kxc871";
     inherit (stable) mono;
     gecko32 = fetchurl rec {
       version = "2.44";
@@ -48,7 +48,7 @@ in rec {
 
   staging = fetchFromGitHub rec {
     inherit (unstable) version;
-    sha256 = "0582ylrvl7racpb0il3wmbivb2d7lh6n3mymh19yw94qzgifwqrw";
+    sha256 = "0rcy0i36jxv2akczd4sfrdmlsqxmj5v0wzvqb3xl8p2mldk9i8yl";
     owner = "wine-compholio";
     repo = "wine-staging";
     rev = "v${version}";
diff --git a/pkgs/misc/frescobaldi/default.nix b/pkgs/misc/frescobaldi/default.nix
index 04370424abb72..84272992f2bbd 100644
--- a/pkgs/misc/frescobaldi/default.nix
+++ b/pkgs/misc/frescobaldi/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pythonPackages, lilypond, pyqt4, pygame }:
+{ stdenv, fetchurl, pythonPackages, lilypond}:
 
 pythonPackages.buildPythonApplication rec {
   name = "frescobaldi-${version}";
diff --git a/pkgs/misc/long-shebang/default.nix b/pkgs/misc/long-shebang/default.nix
index 17bf0e95feebf..2aac5556e2f52 100644
--- a/pkgs/misc/long-shebang/default.nix
+++ b/pkgs/misc/long-shebang/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl }: let
-  version = "1.0.0";
+  version = "1.1.0";
 in stdenv.mkDerivation {
   name = "long-shebang-${version}";
 
   src = fetchurl {
-    url = "https://github.com/shlevy/long-shebang/releases/download/v1.0.0/long-shebang-1.0.0.tar.xz";
-    sha256 = "15f5rmihj3r53rmalix1bn1agybbzrc3g2a9xzjyd4v3vfd2vckr";
+    url = "https://github.com/shlevy/long-shebang/releases/download/v${version}/long-shebang-${version}.tar.xz";
+    sha256 = "0rlyibf7pczjfsi91nl1n5vri2vqibmvyyy070jaw3wb0wjm565a";
   };
 
   meta = {
diff --git a/pkgs/os-specific/linux/android-udev-rules/default.nix b/pkgs/os-specific/linux/android-udev-rules/default.nix
index be2b8026817ae..677eb890a5ba7 100644
--- a/pkgs/os-specific/linux/android-udev-rules/default.nix
+++ b/pkgs/os-specific/linux/android-udev-rules/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "android-udev-rules-${version}";
-  version = "2016-04-26";
+  version = "20160805";
 
   src = fetchFromGitHub {
     owner = "M0Rf30";
     repo = "android-udev-rules";
-    rev = "9af6e552016392db35191142b599a5199cf8a9fa";
-    sha256 = "1lvh7md6qz91q8jy9phnfxlb19s104lvsk75a5r07d8bjc4w9pxb";
+    rev = version;
+    sha256 = "0sdf3insqs73cdzmwl3lqy7nj82f1lprxd3vm0jh3qpf0sd1k93c";
   };
 
   installPhase = ''
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
   '';
 
   meta = with stdenv.lib; {
-    homepage = https://github.com/M0Rf30/android-udev-rules;
+    homepage = "https://github.com/M0Rf30/android-udev-rules";
     description = "Android udev rules list aimed to be the most comprehensive on the net";
     platforms = platforms.linux;
     license = licenses.gpl3;
diff --git a/pkgs/os-specific/linux/autofs/default.nix b/pkgs/os-specific/linux/autofs/default.nix
index 6ae9d8d266790..4401eb24cb480 100644
--- a/pkgs/os-specific/linux/autofs/default.nix
+++ b/pkgs/os-specific/linux/autofs/default.nix
@@ -1,27 +1,27 @@
-{ stdenv, fetchurl, flex, bison, linuxHeaders }:
+{ stdenv, lib, fetchurl, flex, bison, linuxHeaders, libtirpc, utillinux, nfs-utils, e2fsprogs
+, libxml2 }:
 
 let
-  version = "5.1.1";
+  version = "5.1.2";
   name = "autofs-${version}";
 in stdenv.mkDerivation {
   inherit name;
 
   src = fetchurl {
     url = "mirror://kernel/linux/daemons/autofs/v5/${name}.tar.xz";
-    sha256 = "1hr1f11wp538h7r298wpa5khfkhfs8va3p1kdixxhrgkkzpz13z0";
+    sha256 = "031z64hmbzyllgvi72cw87755vnmafvsfwi0w21xksla10wxxdw8";
   };
 
   preConfigure = ''
-    configureFlags="--disable-move-mount --with-path=$PATH"
-    export MOUNT=/var/run/current-system/sw/bin/mount
-    export UMOUNT=/var/run/current-system/sw/bin/umount
-    export MODPROBE=/var/run/current-system/sw/bin/modprobe
-    # Grrr, rpcgen can't find cpp. (NIXPKGS-48)
-    mkdir rpcgen
-    echo "#! $shell" > rpcgen/rpcgen
-    echo "exec $(type -tp rpcgen) -Y $(dirname $(type -tp cpp)) \"\$@\"" >> rpcgen/rpcgen
-    chmod +x rpcgen/rpcgen
-    export RPCGEN=$(pwd)/rpcgen/rpcgen
+    configureFlags="--enable-force-shutdown --enable-ignore-busy --with-path=$PATH"
+
+    export MOUNT=${lib.getBin utillinux}/bin/mount
+    export MOUNT_NFS=${lib.getBin nfs-utils}/bin/mount.nfs
+    export UMOUNT=${lib.getBin utillinux}/bin/umount
+    export MODPROBE=${lib.getBin utillinux}/bin/modprobe
+    export E2FSCK=${lib.getBin e2fsprogs}/bin/fsck.ext2
+    export E3FSCK=${lib.getBin e2fsprogs}/bin/fsck.ext3
+    export E4FSCK=${lib.getBin e2fsprogs}/bin/fsck.ext4
   '';
 
   installPhase = ''
@@ -29,7 +29,9 @@ in stdenv.mkDerivation {
     #make install SUBDIRS="samples" # impure!
   '';
 
-  buildInputs = [ flex bison linuxHeaders ];
+  buildInputs = [ linuxHeaders libtirpc libxml2 ];
+
+  nativeBuildInputs = [ flex bison ];
 
   meta = {
     inherit version;
diff --git a/pkgs/os-specific/linux/btfs/default.nix b/pkgs/os-specific/linux/btfs/default.nix
index f0d1b3d73570e..f6b3839c6bce3 100644
--- a/pkgs/os-specific/linux/btfs/default.nix
+++ b/pkgs/os-specific/linux/btfs/default.nix
@@ -3,13 +3,13 @@
 
 stdenv.mkDerivation rec {
   name = "btfs-${version}";
-  version = "2.10";
+  version = "2.11";
 
   src = fetchFromGitHub {
     owner = "johang";
     repo = "btfs";
-    rev = "2eac5e70a1ed22fa0761b6357c54fd90eea02de6";
-    sha256 = "146vgwn79dnbkkn35safga55lkwhvarkmilparmr26hjb56cs1dk";
+    rev = "fe585ca285690579db50b1624cec81ae76279ba2";
+    sha256 = "1vqya2k8cx5x7jfapl9vmmb002brwbsz4j5xs4417kzv3j2bsms9";
   };
 
   buildInputs = [
diff --git a/pkgs/os-specific/linux/kernel/linux-4.5.nix b/pkgs/os-specific/linux/kernel/linux-4.5.nix
deleted file mode 100644
index 63db177901479..0000000000000
--- a/pkgs/os-specific/linux/kernel/linux-4.5.nix
+++ /dev/null
@@ -1,19 +0,0 @@
-{ stdenv, fetchurl, perl, buildLinux, ... } @ args:
-
-import ./generic.nix (args // rec {
-  version = "4.5.7";
-  extraMeta.branch = "4.5";
-
-  src = fetchurl {
-    url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz";
-    sha256 = "0azvh7lf9kak1xcs5f9smlvx4gkf45vyandizmxhx0zyjlhacw60";
-  };
-
-  kernelPatches = args.kernelPatches;
-
-  features.iwlwifi = true;
-  features.efiBootStub = true;
-  features.needsCifsUtils = true;
-  features.canDisableNetfilterConntrackHelpers = true;
-  features.netfilterRPFilter = true;
-} // (args.argsOverride or {}))
diff --git a/pkgs/os-specific/linux/kernel/linux-4.6.nix b/pkgs/os-specific/linux/kernel/linux-4.6.nix
index 0559df72ae6d5..c7ea0a95f81c6 100644
--- a/pkgs/os-specific/linux/kernel/linux-4.6.nix
+++ b/pkgs/os-specific/linux/kernel/linux-4.6.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, perl, buildLinux, ... } @ args:
 
 import ./generic.nix (args // rec {
-  version = "4.6.5";
+  version = "4.6.6";
   extraMeta.branch = "4.6";
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz";
-    sha256 = "1i8ksv8w6dn86q54gzk230gxrylqx3m55x789d29q5balg456bby";
+    sha256 = "1lx00j0z0rasmc87mcvqd1h6r4znb9c2q22jbs2mrissr5w05vgm";
   };
 
   kernelPatches = args.kernelPatches;
diff --git a/pkgs/os-specific/linux/kernel/linux-grsecurity.nix b/pkgs/os-specific/linux/kernel/linux-grsecurity.nix
index 0559df72ae6d5..be84d5f76da1b 100644
--- a/pkgs/os-specific/linux/kernel/linux-grsecurity.nix
+++ b/pkgs/os-specific/linux/kernel/linux-grsecurity.nix
@@ -1,12 +1,13 @@
 { stdenv, fetchurl, perl, buildLinux, ... } @ args:
 
 import ./generic.nix (args // rec {
-  version = "4.6.5";
-  extraMeta.branch = "4.6";
+  version = "4.7";
+  modDirVersion = "4.7.0";
+  extraMeta.branch = "4.7";
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz";
-    sha256 = "1i8ksv8w6dn86q54gzk230gxrylqx3m55x789d29q5balg456bby";
+    sha256 = "042z53ik3mqaqlfrn5b70kw882fwd42zanqld10s1vcs438w742i";
   };
 
   kernelPatches = args.kernelPatches;
diff --git a/pkgs/os-specific/linux/kernel/patches.nix b/pkgs/os-specific/linux/kernel/patches.nix
index f0aa4c92b3c5a..62b70ac67c2a2 100644
--- a/pkgs/os-specific/linux/kernel/patches.nix
+++ b/pkgs/os-specific/linux/kernel/patches.nix
@@ -93,9 +93,9 @@ rec {
   grsecurity_4_4 = throw "grsecurity stable is no longer supported";
 
   grsecurity_testing = grsecPatch
-    { kver   = "4.6.5";
-      grrev  = "201607312210";
-      sha256 = "17dnp6w092kvqxqxbdgjpl4mrsn2wkb7z8q5d8ck7dfanpmqap0w";
+    { kver   = "4.7";
+      grrev  = "201608131240";
+      sha256 = "0bcng47xk5nf4xwcl1l6a2nfb54b8v5piwg42nf3d99hy4si8fvd";
     };
 
   # This patch relaxes grsec constraints on the location of usermode helpers,
diff --git a/pkgs/os-specific/linux/pam_pgsql/default.nix b/pkgs/os-specific/linux/pam_pgsql/default.nix
index 8e34028e07832..42949a3557a65 100644
--- a/pkgs/os-specific/linux/pam_pgsql/default.nix
+++ b/pkgs/os-specific/linux/pam_pgsql/default.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "Support to authenticate against PostgreSQL for PAM-enabled appliations";
-    homepage = https://github.com/pam-pgsql/pam-pgsql;
+    homepage = "https://github.com/pam-pgsql/pam-pgsql";
     license = licenses.gpl2Plus;
     platforms = platforms.linux;
     maintainers = with maintainers; [ abbradar ];
diff --git a/pkgs/os-specific/linux/spl/default.nix b/pkgs/os-specific/linux/spl/default.nix
index 61fe17c3df763..d5a235084d4d9 100644
--- a/pkgs/os-specific/linux/spl/default.nix
+++ b/pkgs/os-specific/linux/spl/default.nix
@@ -1,4 +1,4 @@
-{ fetchFromGitHub, stdenv, autoconf, automake, libtool, coreutils, gawk
+{ fetchFromGitHub, stdenv, autoreconfHook, coreutils, gawk
 , configFile ? "all"
 
 # Kernel dependencies
@@ -28,16 +28,12 @@ stdenv.mkDerivation rec {
 
   patches = [ ./const.patch ./install_prefix.patch ];
 
-  buildInputs = [ autoconf automake libtool ];
+  nativeBuildInputs = [ autoreconfHook ];
 
   hardeningDisable = [ "pic" ];
 
   preConfigure = ''
-    ./autogen.sh
-
     substituteInPlace ./module/spl/spl-generic.c --replace /usr/bin/hostid hostid
-    substituteInPlace ./module/spl/spl-module.c  --replace /bin/mknod mknod
-
     substituteInPlace ./module/spl/spl-generic.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:${gawk}:/bin"
     substituteInPlace ./module/splat/splat-vnode.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:/bin"
     substituteInPlace ./module/splat/splat-linux.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:/bin"
diff --git a/pkgs/os-specific/linux/systemd/cryptsetup-generator.nix b/pkgs/os-specific/linux/systemd/cryptsetup-generator.nix
index 3d617ece1c008..dc0a23be98fea 100644
--- a/pkgs/os-specific/linux/systemd/cryptsetup-generator.nix
+++ b/pkgs/os-specific/linux/systemd/cryptsetup-generator.nix
@@ -18,10 +18,10 @@ stdenv.lib.overrideDerivation systemd (p: {
   # For some reason systemd-cryptsetup-generator is a wrapper-script
   # with the current release of systemd. We want the real one.
 
-  # TODO: Revert 3efadce when the wrapper-script is gone
+  # TODO: Remove `.libs` prefix when the wrapper-script is gone
   installPhase = ''
     mkdir -p $out/lib/systemd/
-    cp systemd-cryptsetup $out/lib/systemd/systemd-cryptsetup
+    cp .libs/systemd-cryptsetup $out/lib/systemd/systemd-cryptsetup
     cp .libs/*.so $out/lib/
 
     mkdir -p $out/lib/systemd/system-generators/
diff --git a/pkgs/os-specific/linux/wireguard/default.nix b/pkgs/os-specific/linux/wireguard/default.nix
index ab34796137585..3264194f1256f 100644
--- a/pkgs/os-specific/linux/wireguard/default.nix
+++ b/pkgs/os-specific/linux/wireguard/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchgit, libmnl, kernel ? null }:
+{ stdenv, fetchurl, libmnl, kernel ? null }:
 
 # module requires Linux >= 4.1 https://www.wireguard.io/install/#kernel-requirements
 assert kernel != null -> stdenv.lib.versionAtLeast kernel.version "4.1";
@@ -6,19 +6,20 @@ assert kernel != null -> stdenv.lib.versionAtLeast kernel.version "4.1";
 let
   name = "wireguard-unstable-${version}";
 
-  version = "2016-07-22";
+  version = "2016-08-08";
 
-  src = fetchgit {
-    url    = "https://git.zx2c4.com/WireGuard";
-    rev    = "8e8bf6f848c324603827c0e57f0856d5866ac32d";
-    sha256 = "11qrf9fxm6mkwjnjq7dgbisdric5w22cyfkqc6zx9fla2dz99mxk";
+  src = fetchurl {
+    url    = "https://git.zx2c4.com/WireGuard/snapshot/WireGuard-experimental-0.0.20160808.tar.xz";
+    sha256 = "0z9s9xi8dzkmjnki7ialf2haxb0mn2x5676sjwmjij1jfi9ypxhw";
   };
 
   meta = with stdenv.lib; {
-    homepage    = https://www.wireguard.io/;
-    description = "Fast, modern, secure VPN tunnel";
-    license     = licenses.gpl2;
-    platforms   = platforms.linux;
+    homepage     = https://www.wireguard.io/;
+    downloadPage = https://git.zx2c4.com/WireGuard/refs/;
+    description  = "Fast, modern, secure VPN tunnel";
+    maintainers  = with maintainers; [ ericsagnes ];
+    license      = licenses.gpl2;
+    platforms    = platforms.linux;
   };
 
   module = stdenv.mkDerivation {
@@ -35,7 +36,6 @@ let
     INSTALL_MOD_PATH = "\${out}";
 
     buildPhase = "make module";
-
   };
 
   tools = stdenv.mkDerivation {
@@ -52,7 +52,6 @@ let
     ];
 
     buildPhase = "make tools";
-
   };
 
 in if kernel == null
diff --git a/pkgs/servers/apache-kafka/default.nix b/pkgs/servers/apache-kafka/default.nix
index be9410d304803..418286d81f64b 100755
--- a/pkgs/servers/apache-kafka/default.nix
+++ b/pkgs/servers/apache-kafka/default.nix
@@ -11,6 +11,10 @@ let
               scalaVersion = "2.11";
               sha256 = "0ykcjv5dz9i5bws9my2d60pww1g9v2p2nqr67h0i2xrjm7az8a6v";
             };
+    "0.10" = { kafkaVersion = "0.10.0.1";
+               scalaVersion = "2.11";
+               sha256 = "0bdhzbhmm87a47162hyazcjmfibqg9r3ryzfjag7r0nxxmd64wrd";
+             };
   };
 in
 
diff --git a/pkgs/servers/caddy/default.nix b/pkgs/servers/caddy/default.nix
index 68ce9440f4f4d..4e5703bc531ab 100644
--- a/pkgs/servers/caddy/default.nix
+++ b/pkgs/servers/caddy/default.nix
@@ -1,18 +1,24 @@
-{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
+{ stdenv, buildGoPackage, fetchgit, fetchhg, fetchbzr, fetchsvn }:
 
 buildGoPackage rec {
   name = "caddy-${version}";
-  version = "0.8.3";
-  rev = "e2234497b79603388b58ba226abb157aa4aaf065";
+  version = "v0.9.0";
+  rev = "f28af637327a4f12ae745284c519cfdeca5502ef";
 
   goPackagePath = "github.com/mholt/caddy";
 
-  src = fetchFromGitHub {
+  subPackages = [ "caddy" ];
+
+  src = fetchgit {
     inherit rev;
-    owner = "mholt";
-    repo = "caddy";
-    sha256 = "1snijkbz02yr7wij7bcmrj4257709sbklb3nhb5qmy95b9ssffm6";
+    url = "https://github.com/mholt/caddy.git";
+    sha256 = "1s7z0xbcw516i37pyj1wgxd9diqrifdghf97vs31ilbqs6z0nyls";
   };
 
+  buildFlagsArray = ''
+    -ldflags=
+      -X github.com/mholt/caddy/caddy/caddymain.gitTag=${version}
+  '';
+
   goDeps = ./deps.json;
 }
diff --git a/pkgs/servers/caddy/deps.json b/pkgs/servers/caddy/deps.json
index e026c7c636993..3ed975cab7628 100644
--- a/pkgs/servers/caddy/deps.json
+++ b/pkgs/servers/caddy/deps.json
@@ -1,146 +1,182 @@
 [
-    {
-        "goPackagePath": "gopkg.in/yaml.v2",
-        "fetch": {
-            "type": "git",
-            "url": "https://gopkg.in/yaml.v2",
-            "rev": "a83829b6f1293c91addabc89d0571c246397bbf4",
-            "sha256": "1m4dsmk90sbi17571h6pld44zxz7jc4lrnl4f27dpd1l8g5xvjhh"
-        }
-    },
-    {
-        "goPackagePath": "golang.org/x/crypto",
-        "fetch": {
-            "type": "git",
-            "url": "https://go.googlesource.com/crypto",
-            "rev": "575fdbe86e5dd89229707ebec0575ce7d088a4a6",
-            "sha256": "1kgv1mkw9y404pk3lcwbs0vgl133mwyp294i18jg9hp10s5d56xa"
-        }
-    },
-    {
-        "goPackagePath": "golang.org/x/net",
-        "fetch": {
-            "type": "git",
-            "url": "https://go.googlesource.com/net",
-            "rev": "62ac18b461605b4be188bbc7300e9aa2bc836cd4",
-            "sha256": "0lwwvbbwbf3yshxkfhn6z20gd45dkvnmw2ms36diiy34krgy402p"
-        }
-    },
-    {
-        "goPackagePath": "github.com/gorilla/websocket",
-        "fetch": {
-            "type": "git",
-            "url": "https://github.com/gorilla/websocket",
-            "rev": "a622679ebd7a3b813862379232f645f8e690e43f",
-            "sha256": "1nc9jbcmgya1i6dmf6sbcqsnxi9hbjg6dz1z0k7zmc6xdwlq0y4q"
-        }
-    },
-    {
-        "goPackagePath": "github.com/miekg/dns",
-        "fetch": {
-            "type": "git",
-            "url": "https://github.com/miekg/dns",
-            "rev": "7e024ce8ce18b21b475ac6baf8fa3c42536bf2fa",
-            "sha256": "0hlwb52lnnj3c6papjk9i5w5cjdw6r7c891v4xksnfvk1f9cy9kl"
-        }
-    },
-    {
-        "goPackagePath": "github.com/BurntSushi/toml",
-        "fetch": {
-            "type": "git",
-            "url": "https://github.com/BurntSushi/toml",
-            "rev": "056c9bc7be7190eaa7715723883caffa5f8fa3e4",
-            "sha256": "0gkgkw04ndr5y7hrdy0r4v2drs5srwfcw2bs1gyas066hwl84xyw"
-        }
-    },
-    {
-        "goPackagePath": "github.com/hashicorp/go-syslog",
-        "fetch": {
-            "type": "git",
-            "url": "https://github.com/hashicorp/go-syslog",
-            "rev": "42a2b573b664dbf281bd48c3cc12c086b17a39ba",
-            "sha256": "1j53m2wjyczm9m55znfycdvm4c8vfniqgk93dvzwy8vpj5gm6sb3"
-        }
-    },
-    {
-        "goPackagePath": "github.com/flynn/go-shlex",
-        "fetch": {
-            "type": "git",
-            "url": "https://github.com/flynn/go-shlex",
-            "rev": "3f9db97f856818214da2e1057f8ad84803971cff",
-            "sha256": "1j743lysygkpa2s2gii2xr32j7bxgc15zv4113b0q9jhn676ysia"
-        }
-    },
-    {
-        "goPackagePath": "github.com/xenolf/lego",
-        "fetch": {
-            "type": "git",
-            "url": "https://github.com/xenolf/lego",
-            "rev": "ca19a90028e242e878585941c2a27c8f3b3efc25",
-            "sha256": "1zkcsbdzbmfzk3kqmcj9l13li8sz228xhrw2wj3ab4a0w6drbw3x"
-        }
-    },
-    {
-        "goPackagePath": "gopkg.in/natefinch/lumberjack.v2",
-        "fetch": {
-            "type": "git",
-            "url": "https://gopkg.in/natefinch/lumberjack.v2",
-            "rev": "514cbda263a734ae8caac038dadf05f8f3f9f738",
-            "sha256": "1v92v8vkip36l2fs6l5dpp655151hrijjc781cif658r8nf7xr82"
-        }
-    },
-    {
-        "goPackagePath": "github.com/shurcooL/sanitized_anchor_name",
-        "fetch": {
-            "type": "git",
-            "url": "https://github.com/shurcooL/sanitized_anchor_name",
-            "rev": "10ef21a441db47d8b13ebcc5fd2310f636973c77",
-            "sha256": "1cnbzcf47cn796rcjpph1s64qrabhkv5dn9sbynsy7m9zdwr5f01"
-        }
-    },
-    {
-        "goPackagePath": "gopkg.in/square/go-jose.v1",
-        "fetch": {
-            "type": "git",
-            "url": "https://gopkg.in/square/go-jose.v1",
-            "rev": "40d457b439244b546f023d056628e5184136899b",
-            "sha256": "0asa1kl1qbx0cyayk44jhxxff0awpkwiw6va7yzrzjzhfc5kvg7p"
-        }
-    },
-    {
-        "goPackagePath": "github.com/mholt/archiver",
-        "fetch": {
-            "type": "git",
-            "url": "https://github.com/mholt/archiver",
-            "rev": "85f054813ed511646b0ce5e047697e0651b8e1a4",
-            "sha256": "0b38mrfm3rwgdi7hrp4gjhf0y0f6bw73qjkfrkafxjrdpdg7nyly"
-        }
-    },
-    {
-        "goPackagePath": "github.com/dustin/go-humanize",
-        "fetch": {
-            "type": "git",
-            "url": "https://github.com/dustin/go-humanize",
-            "rev": "8929fe90cee4b2cb9deb468b51fb34eba64d1bf0",
-            "sha256": "1g155kxjh6hd3ibx41nbpj6f7h5bh54zgl9dr53xzg2xlxljgjy0"
-        }
-    },
-    {
-        "goPackagePath": "github.com/jimstudt/http-authentication",
-        "fetch": {
-            "type": "git",
-            "url": "https://github.com/jimstudt/http-authentication",
-            "rev": "3eca13d6893afd7ecabe15f4445f5d2872a1b012",
-            "sha256": "1drw3bhrxpjzwryqz9nq5s0yyjqyd42iym3bh1zjs5qsh401cq08"
-        }
-    },
-    {
-        "goPackagePath": "github.com/russross/blackfriday",
-        "fetch": {
-            "type": "git",
-            "url": "https://github.com/russross/blackfriday",
-            "rev": "d18b67ae0afd61dae240896eae1785f00709aa31",
-            "sha256": "1l78hz8k1ixry5fjw29834jz1q5ysjcpf6kx2ggjj1s6xh0bfzvf"
-        }
-    }
-]
+  {
+    "goPackagePath": "github.com/BurntSushi/toml",
+    "fetch": {
+      "type": "git",
+      "url": "https://github.com/BurntSushi/toml",
+      "rev": "99064174e013895bbd9b025c31100bd1d9b590ca",
+      "sha256": "058qrar8rvw3wb0ci1mf1axnqq2729cvv9zmdr4ms2nn9s97yiz9"
+    }
+  },
+  {
+    "goPackagePath": "github.com/dustin/go-humanize",
+    "fetch": {
+      "type": "git",
+      "url": "https://github.com/dustin/go-humanize",
+      "rev": "2fcb5204cdc65b4bec9fd0a87606bb0d0e3c54e8",
+      "sha256": "1m2qgn5vh5m66ggmclgikvwc05np2r7sxgpvlj2jip5d61x29j5k"
+    }
+  },
+  {
+    "goPackagePath": "github.com/flynn/go-shlex",
+    "fetch": {
+      "type": "git",
+      "url": "https://github.com/flynn/go-shlex",
+      "rev": "3f9db97f856818214da2e1057f8ad84803971cff",
+      "sha256": "1j743lysygkpa2s2gii2xr32j7bxgc15zv4113b0q9jhn676ysia"
+    }
+  },
+  {
+    "goPackagePath": "github.com/gorilla/websocket",
+    "fetch": {
+      "type": "git",
+      "url": "https://github.com/gorilla/websocket",
+      "rev": "a69d25be2fe2923a97c2af6849b2f52426f68fc0",
+      "sha256": "1z09mff5yfdrw8vbylrgrick5m5hczjy8m2x6swdq8v062s45g3v"
+    }
+  },
+  {
+    "goPackagePath": "github.com/hashicorp/go-syslog",
+    "fetch": {
+      "type": "git",
+      "url": "https://github.com/hashicorp/go-syslog",
+      "rev": "42a2b573b664dbf281bd48c3cc12c086b17a39ba",
+      "sha256": "1j53m2wjyczm9m55znfycdvm4c8vfniqgk93dvzwy8vpj5gm6sb3"
+    }
+  },
+  {
+    "goPackagePath": "github.com/jimstudt/http-authentication",
+    "fetch": {
+      "type": "git",
+      "url": "https://github.com/jimstudt/http-authentication",
+      "rev": "3eca13d6893afd7ecabe15f4445f5d2872a1b012",
+      "sha256": "1drw3bhrxpjzwryqz9nq5s0yyjqyd42iym3bh1zjs5qsh401cq08"
+    }
+  },
+  {
+    "goPackagePath": "github.com/lucas-clemente/aes12",
+    "fetch": {
+      "type": "git",
+      "url": "https://github.com/lucas-clemente/aes12",
+      "rev": "5a3c52721c1e81aa8162601ac2342486525156d5",
+      "sha256": "16z4h752na2d4sskjvbgi9bpwx874lpnzn6i13n33xjz599nps4y"
+    }
+  },
+  {
+    "goPackagePath": "github.com/lucas-clemente/fnv128a",
+    "fetch": {
+      "type": "git",
+      "url": "https://github.com/lucas-clemente/fnv128a",
+      "rev": "393af48d391698c6ae4219566bfbdfef67269997",
+      "sha256": "1cvq0p0k86p668yz9rb3z98fz3f9phvbvqp6ilbasiy4y2x5w184"
+    }
+  },
+  {
+    "goPackagePath": "github.com/lucas-clemente/quic-go",
+    "fetch": {
+      "type": "git",
+      "url": "https://github.com/lucas-clemente/quic-go",
+      "rev": "61454ac85f1209c41ffcc000213a42f3e76346e5",
+      "sha256": "0y7qmwlb93r0aq5m5qarc86550d75yx86pwv31wd2m0474yv7jk9"
+    }
+  },
+  {
+    "goPackagePath": "github.com/lucas-clemente/quic-go-certificates",
+    "fetch": {
+      "type": "git",
+      "url": "https://github.com/lucas-clemente/quic-go-certificates",
+      "rev": "9bb36d3159787cca26dcfa15e23049615e307ef8",
+      "sha256": "146674p0rg0m4j8p33r5idn5j5k4a277fz1yzf87v5m8wf4694q5"
+    }
+  },
+  {
+    "goPackagePath": "github.com/mholt/caddy",
+    "fetch": {
+      "type": "git",
+      "url": "https://github.com/mholt/caddy.git",
+      "rev": "f28af637327a4f12ae745284c519cfdeca5502ef",
+      "sha256": "1s7z0xbcw516i37pyj1wgxd9diqrifdghf97vs31ilbqs6z0nyls"
+    }
+  },
+  {
+    "goPackagePath": "github.com/miekg/dns",
+    "fetch": {
+      "type": "git",
+      "url": "https://github.com/miekg/dns",
+      "rev": "db96a2b759cdef4f11a34506a42eb8d1290c598e",
+      "sha256": "0h5n4psd0p7q55jadgsgz2a1aj791yanrfj76avalh6aawvdpcm6"
+    }
+  },
+  {
+    "goPackagePath": "github.com/russross/blackfriday",
+    "fetch": {
+      "type": "git",
+      "url": "https://github.com/russross/blackfriday",
+      "rev": "93622da34e54fb6529bfb7c57e710f37a8d9cbd8",
+      "sha256": "19y4cx4afm3fjj7w83g0wklbzqdjm7m1j5nq64l4yq8bi50y2iv2"
+    }
+  },
+  {
+    "goPackagePath": "github.com/shurcooL/sanitized_anchor_name",
+    "fetch": {
+      "type": "git",
+      "url": "https://github.com/shurcooL/sanitized_anchor_name",
+      "rev": "10ef21a441db47d8b13ebcc5fd2310f636973c77",
+      "sha256": "1cnbzcf47cn796rcjpph1s64qrabhkv5dn9sbynsy7m9zdwr5f01"
+    }
+  },
+  {
+    "goPackagePath": "github.com/xenolf/lego",
+    "fetch": {
+      "type": "git",
+      "url": "https://github.com/xenolf/lego",
+      "rev": "4c33bee13d438d72ea22be3ff806f8093fb8d072",
+      "sha256": "191wx4jmi2hs2m233da0c7j1l80alf2493wmnixfphwwdik7qdvw"
+    }
+  },
+  {
+    "goPackagePath": "golang.org/x/crypto",
+    "fetch": {
+      "type": "git",
+      "url": "https://go.googlesource.com/crypto",
+      "rev": "7a1054f3ac58191481dc500077c6b060f5d6c7e5",
+      "sha256": "1n34nalvan3mydjzi48hxa30mz0i3zcb2rynw07s39m457ab1412"
+    }
+  },
+  {
+    "goPackagePath": "golang.org/x/net",
+    "fetch": {
+      "type": "git",
+      "url": "https://go.googlesource.com/net",
+      "rev": "57bfaa875b96fb91b4766077f34470528d4b03e9",
+      "sha256": "17gfka5dv1n7v0z49clyl3h0xm5w2qcaldyyzlar6rh6l14g2dq5"
+    }
+  },
+  {
+    "goPackagePath": "gopkg.in/natefinch/lumberjack.v2",
+    "fetch": {
+      "type": "git",
+      "url": "https://gopkg.in/natefinch/lumberjack.v2",
+      "rev": "514cbda263a734ae8caac038dadf05f8f3f9f738",
+      "sha256": "1v92v8vkip36l2fs6l5dpp655151hrijjc781cif658r8nf7xr82"
+    }
+  },
+  {
+    "goPackagePath": "gopkg.in/square/go-jose.v1",
+    "fetch": {
+      "type": "git",
+      "url": "https://gopkg.in/square/go-jose.v1",
+      "rev": "e3f973b66b91445ec816dd7411ad1b6495a5a2fc",
+      "sha256": "18icclnws5bz4xmlyybkxl38nhvyr990h88rvp4lp9n4r1fk3lhb"
+    }
+  },
+  {
+    "goPackagePath": "gopkg.in/yaml.v2",
+    "fetch": {
+      "type": "git",
+      "url": "https://gopkg.in/yaml.v2",
+      "rev": "e4d366fc3c7938e2958e662b4258c7a89e1f0e3e",
+      "sha256": "1himz6569rcgn27q6sdrwvdldx45q2spgjb5cfihgb80zww8di8x"
+    }
+  }
+]
\ No newline at end of file
diff --git a/pkgs/servers/emby/default.nix b/pkgs/servers/emby/default.nix
index 1cad76bbf203c..899c4a13502bc 100644
--- a/pkgs/servers/emby/default.nix
+++ b/pkgs/servers/emby/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "emby-${version}";
-  version = "3.0.6030";
+  version = "3.0.6060";
 
   src = fetchurl {
     url = "https://github.com/MediaBrowser/Emby/archive/${version}.tar.gz";
-    sha256 = "14fmgb8pwj11n57c1rm002ylwqapdqywbpsv7z6skairbaf6ny09";
+    sha256 = "1s895198x3kiqfznhp56vj67wld9fgh2wd7k8hw69mrasby0kmp3";
   };
 
   propagatedBuildInputs = with pkgs; [
diff --git a/pkgs/servers/mail/dspam/default.nix b/pkgs/servers/mail/dspam/default.nix
index 6f52e62aab755..0c3ed84deff96 100644
--- a/pkgs/servers/mail/dspam/default.nix
+++ b/pkgs/servers/mail/dspam/default.nix
@@ -99,7 +99,7 @@ in stdenv.mkDerivation rec {
   '';
 
   meta = with lib; {
-    homepage = http://dspam.nuclearelephant.com/;
+    homepage = "http://nuclearelephant.com/";
     description = "Community Driven Antispam Filter";
     license = licenses.agpl3;
     platforms = platforms.linux;
diff --git a/pkgs/servers/rpcbind/default.nix b/pkgs/servers/rpcbind/default.nix
index 7cb2c5a0c3818..ba2e1447ffe59 100644
--- a/pkgs/servers/rpcbind/default.nix
+++ b/pkgs/servers/rpcbind/default.nix
@@ -26,7 +26,7 @@ in stdenv.mkDerivation rec {
     description = "ONC RPC portmapper";
     license = licenses.bsd3;
     platforms = platforms.unix;
-    homepage = http://sourceforge.net/projects/rpcbind/;
+    homepage = "http://sourceforge.net/projects/rpcbind/";
     maintainers = with maintainers; [ abbradar ];
     longDescription = ''
       Universal addresses to RPC program number mapper.
diff --git a/pkgs/servers/sql/mariadb/default.nix b/pkgs/servers/sql/mariadb/default.nix
index 76a7755f39570..97b7a90892a7d 100644
--- a/pkgs/servers/sql/mariadb/default.nix
+++ b/pkgs/servers/sql/mariadb/default.nix
@@ -32,8 +32,8 @@ common = rec { # attributes common to both builds
   nativeBuildInputs = [ cmake pkgconfig ];
 
   buildInputs = [
-    ncurses openssl zlib pcre
-  ] ++ stdenv.lib.optionals stdenv.isLinux [ jemalloc libaio systemd ]
+    ncurses openssl zlib pcre jemalloc
+  ] ++ stdenv.lib.optionals stdenv.isLinux [ libaio systemd ]
     ++ stdenv.lib.optionals stdenv.isDarwin [ perl fixDarwinDylibNames cctools CoreServices ];
 
   cmakeFlags = [
@@ -49,9 +49,18 @@ common = rec { # attributes common to both builds
     "-DWITH_ZLIB=system"
     "-DWITH_SSL=system"
     "-DWITH_PCRE=system"
+
+    # On Darwin without sandbox, CMake will find the system java and attempt to build with java support, but
+    # then it will fail during the actual build. Let's just disable the flag explicitly until someone decides
+    # to pass in java explicitly. This should have no effect on Linux.
+    "-DCONNECT_WITH_JDBC=OFF"
+
+    # Same as above. Somehow on Darwin CMake decides that we support GSS even though we aren't provding the
+    # library through Nix, and then breaks later on. This should have no effect on Linux.
+    "-DPLUGIN_AUTH_GSSAPI=NO"
+    "-DPLUGIN_AUTH_GSSAPI_CLIENT=NO"
   ]
     ++ optional stdenv.isDarwin "-DCURSES_LIBRARY=${ncurses.out}/lib/libncurses.dylib"
-    ++ optional (!stdenv.isLinux) "-DWITH_JEMALLOC=no" # bad build at least on Darwin
     ;
 
   preConfigure = ''
diff --git a/pkgs/servers/uwsgi/default.nix b/pkgs/servers/uwsgi/default.nix
index 3bec62ebe0395..dd6eeff616f08 100644
--- a/pkgs/servers/uwsgi/default.nix
+++ b/pkgs/servers/uwsgi/default.nix
@@ -81,7 +81,7 @@ stdenv.mkDerivation rec {
   NIX_CFLAGS_LINK = [ "-lsystemd" ];
 
   meta = with stdenv.lib; {
-    homepage = http://uwsgi-docs.readthedocs.org/en/latest/;
+    homepage = "http://uwsgi-docs.readthedocs.org/en/latest/";
     description = "A fast, self-healing and developer/sysadmin-friendly application container server coded in pure C";
     license = licenses.gpl2;
     maintainers = with maintainers; [ abbradar ];
diff --git a/pkgs/servers/x11/xorg/xcb-util-xrm.nix b/pkgs/servers/x11/xorg/xcb-util-xrm.nix
new file mode 100644
index 0000000000000..9eb8add6856ec
--- /dev/null
+++ b/pkgs/servers/x11/xorg/xcb-util-xrm.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, pkgconfig, m4, libxcb, xcbutil, libX11 }:
+
+stdenv.mkDerivation rec {
+  version = "1.0";
+  name = "xcb-util-xrm-${version}";
+
+  src = fetchurl {
+    url = "https://github.com/Airblader/xcb-util-xrm/releases/download/v${version}/${name}.tar.bz2";
+    sha256 = "1h5vxwpd37dqfw9yj1l4zd9c5dj30r3g0szgysr6kd7xrqgaq04l";
+  };
+
+  buildInputs = [ pkgconfig m4 libxcb xcbutil ]
+    ++ stdenv.lib.optional doCheck [ libX11 ];
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "XCB utility functions for the X resource manager";
+    homepage = https://github.com/Airblader/xcb-util-xrm;
+    license = licenses.mit; # X11 variant
+    platforms = with platforms; unix;
+  };
+}
diff --git a/pkgs/servers/xmpp/ejabberd/default.nix b/pkgs/servers/xmpp/ejabberd/default.nix
index b830567e30360..5b4a22d562e72 100644
--- a/pkgs/servers/xmpp/ejabberd/default.nix
+++ b/pkgs/servers/xmpp/ejabberd/default.nix
@@ -23,12 +23,12 @@ let
   ctlpath = lib.makeBinPath [ bash gnused gnugrep coreutils utillinux procps ];
 
 in stdenv.mkDerivation rec {
-  version = "16.04";
+  version = "16.08";
   name = "ejabberd-${version}";
 
   src = fetchurl {
     url = "http://www.process-one.net/downloads/ejabberd/${version}/${name}.tgz";
-    sha256 = "1hrcswk03x5x6f6xy8sac4ihhi6jcmsfp6449k3570j39vklz5ix";
+    sha256 = "0dqikg0xgph8xjvaxc9r6cyq7k7c8l5jiqr3kyhricziyak9hmdl";
   };
 
   nativeBuildInputs = [ fakegit ];
@@ -74,7 +74,7 @@ in stdenv.mkDerivation rec {
 
     outputHashMode = "recursive";
     outputHashAlgo = "sha256";
-    outputHash = "08s1j0xa65xkrqw810wzgssngs67sz722jsvj7p02v4ra8jcl31f";
+    outputHash = "040l336570lwxsvlli7kqaa18pz92jbf9105mx394ib62z72vvlp";
   };
 
   configureFlags =
@@ -95,6 +95,7 @@ in stdenv.mkDerivation rec {
   preBuild = ''
     cp -r $deps deps
     chmod -R +w deps
+    patchShebangs deps
   '';
 
   postInstall = ''
diff --git a/pkgs/tools/X11/primus/lib.nix b/pkgs/tools/X11/primus/lib.nix
index 2ecf91edba56c..fccd01eaeaddb 100644
--- a/pkgs/tools/X11/primus/lib.nix
+++ b/pkgs/tools/X11/primus/lib.nix
@@ -5,7 +5,7 @@
 }:
 
 stdenv.mkDerivation {
-  name = "primus-lib-20151204";
+  name = "primus-lib-2015-04-28";
 
   src = fetchFromGitHub {
     owner = "amonakov";
@@ -28,7 +28,7 @@ stdenv.mkDerivation {
 
   meta = with stdenv.lib; {
     description = "Low-overhead client-side GPU offloading";
-    homepage = https://github.com/amonakov/primus;
+    homepage = "https://github.com/amonakov/primus";
     platforms = platforms.linux;
     license = licenses.bsd2;
     maintainers = with maintainers; [ abbradar ];
diff --git a/pkgs/tools/X11/virtualgl/lib.nix b/pkgs/tools/X11/virtualgl/lib.nix
index 6b93c6432c334..5707679c03c1d 100644
--- a/pkgs/tools/X11/virtualgl/lib.nix
+++ b/pkgs/tools/X11/virtualgl/lib.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
   enableParallelBuilding = true;
 
   meta = with stdenv.lib; {
-    homepage = http://www.virtualgl.org/;
+    homepage = "http://www.virtualgl.org/";
     description = "X11 GL rendering in a remote computer with full 3D hw acceleration";
     license = licenses.free; # many parts under different free licenses
     platforms = platforms.linux;
diff --git a/pkgs/tools/X11/xpra/default.nix b/pkgs/tools/X11/xpra/default.nix
index d75e3a16313f5..27a3deca73681 100644
--- a/pkgs/tools/X11/xpra/default.nix
+++ b/pkgs/tools/X11/xpra/default.nix
@@ -1,11 +1,12 @@
-{ stdenv, fetchurl, buildPythonApplication, pythonPackages
-, python, cython, pkgconfig
-, xorg, gtk, glib, pango, cairo, gdk_pixbuf, atk, pycairo
+{ stdenv, fetchurl, pythonPackages, pkgconfig
+, xorg, gtk, glib, pango, cairo, gdk_pixbuf, atk
 , makeWrapper, xkbcomp, xorgserver, getopt, xauth, utillinux, which, fontsConf, xkeyboard_config
 , ffmpeg, x264, libvpx, libwebp
 , libfakeXinerama }:
 
-buildPythonApplication rec {
+let
+  inherit (pythonPackages) python cython buildPythonApplication;
+in buildPythonApplication rec {
   name = "xpra-0.17.4";
   namePrefix = "";
   src = fetchurl {
diff --git a/pkgs/tools/backup/duplicity/default.nix b/pkgs/tools/backup/duplicity/default.nix
index da847c0d31b06..27fc11946aad5 100644
--- a/pkgs/tools/backup/duplicity/default.nix
+++ b/pkgs/tools/backup/duplicity/default.nix
@@ -1,11 +1,10 @@
-{ stdenv, fetchurl, python, librsync, ncftp, gnupg, boto, makeWrapper
-, lockfile, setuptools, paramiko, pycrypto, ecdsa
+{ stdenv, fetchurl, pythonPackages, librsync, ncftp, gnupg, makeWrapper
 }:
 
 let
   version = "0.7.07.1";
-in
-stdenv.mkDerivation {
+  inherit (pythonPackages) boto ecdsa lockfile paramiko pycrypto python setuptools;
+in stdenv.mkDerivation {
   name = "duplicity-${version}";
 
   src = fetchurl {
diff --git a/pkgs/tools/backup/obnam/default.nix b/pkgs/tools/backup/obnam/default.nix
index 0df9fa9d39f0b..048321ea2e534 100644
--- a/pkgs/tools/backup/obnam/default.nix
+++ b/pkgs/tools/backup/obnam/default.nix
@@ -1,18 +1,16 @@
-{ stdenv, fetchurl, python, pythonPackages, pycrypto, attr }:
+{ stdenv, fetchurl, pythonPackages, attr }:
 
 pythonPackages.buildPythonApplication rec {
   name = "obnam-${version}";
   version = "1.19.1";
 
-  namePrefix = "";
-
   src = fetchurl rec {
     url = "http://code.liw.fi/debian/pool/main/o/obnam/obnam_${version}.orig.tar.xz";
     sha256 = "096abbvz2c9vm8r7zm82yqrd7zj04pb1xzlv6z0dspkngd0cfdqc";
   };
 
   buildInputs = [ pythonPackages.sphinx attr ];
-  propagatedBuildInputs = [ pycrypto pythonPackages.paramiko pythonPackages.tracing pythonPackages.ttystatus pythonPackages.cliapp pythonPackages.larch pythonPackages.pyyaml pythonPackages.fuse ];
+  propagatedBuildInputs = with pythonPackages; [ pycrypto paramiko tracing ttystatus cliapp larch pyyaml fuse ];
 
   doCheck = false;
 
diff --git a/pkgs/tools/bluetooth/blueman/default.nix b/pkgs/tools/bluetooth/blueman/default.nix
index def096a571d7f..31020656867bb 100644
--- a/pkgs/tools/bluetooth/blueman/default.nix
+++ b/pkgs/tools/bluetooth/blueman/default.nix
@@ -40,7 +40,7 @@ in stdenv.mkDerivation rec {
   '';
 
   meta = with lib; {
-    homepage = https://github.com/blueman-project;
+    homepage = "https://github.com/blueman-project/blueman";
     description = "GTK+-based Bluetooth Manager";
     license = licenses.gpl3;
     platforms = platforms.linux;
diff --git a/pkgs/tools/filesystems/bcache-tools/default.nix b/pkgs/tools/filesystems/bcache-tools/default.nix
index 14d8d282c81cd..288cd14c16bb6 100644
--- a/pkgs/tools/filesystems/bcache-tools/default.nix
+++ b/pkgs/tools/filesystems/bcache-tools/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, utillinux, kmod }:
+{ stdenv, fetchurl, pkgconfig, utillinux }:
 
 stdenv.mkDerivation rec {
   name = "bcache-tools-${version}";
diff --git a/pkgs/tools/graphics/imgurbash2/default.nix b/pkgs/tools/graphics/imgurbash2/default.nix
index 5a655b9ff162d..847b3b81749f0 100644
--- a/pkgs/tools/graphics/imgurbash2/default.nix
+++ b/pkgs/tools/graphics/imgurbash2/default.nix
@@ -26,6 +26,6 @@ stdenv.mkDerivation rec {
     license = licenses.mit;
     platforms = platforms.linux;
     maintainers = with maintainers; [ abbradar ];
-    homepage = https://github.com/ram-on/imgurbash2;
+    homepage = "https://github.com/ram-on/imgurbash2";
   };
 }
diff --git a/pkgs/tools/misc/debian-devscripts/default.nix b/pkgs/tools/misc/debian-devscripts/default.nix
index ea56e59ba8948..ece9c5ed38244 100644
--- a/pkgs/tools/misc/debian-devscripts/default.nix
+++ b/pkgs/tools/misc/debian-devscripts/default.nix
@@ -1,10 +1,13 @@
 {stdenv, fetchurl, perl, CryptSSLeay, LWP, unzip, xz, dpkg, TimeDate, DBFile
-, FileDesktopEntry, libxslt, docbook_xsl, python3, setuptools, makeWrapper
+, FileDesktopEntry, libxslt, docbook_xsl, makeWrapper
+, python3Packages
 , perlPackages, curl, gnupg, diffutils
 , sendmailPath ? "/var/setuid-wrappers/sendmail"
 }:
 
-stdenv.mkDerivation rec {
+let
+  inherit (python3Packages) python setuptools;
+in stdenv.mkDerivation rec {
   version = "2.16.6";
   name = "debian-devscripts-${version}";
 
@@ -14,13 +17,13 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs = [ perl CryptSSLeay LWP unzip xz dpkg TimeDate DBFile 
-    FileDesktopEntry libxslt python3 setuptools makeWrapper
+    FileDesktopEntry libxslt python setuptools makeWrapper
     perlPackages.ParseDebControl perlPackages.LWPProtocolHttps
     curl gnupg diffutils ];
 
   preConfigure = ''
     export PERL5LIB="$PERL5LIB''${PERL5LIB:+:}${dpkg}";
-    tgtpy="$out/lib/${python3.libPrefix}/site-packages"
+    tgtpy="$out/lib/${python.libPrefix}/site-packages"
     mkdir -p "$tgtpy"
     export PYTHONPATH="$PYTHONPATH''${PYTHONPATH:+:}$tgtpy"
     find po4a scripts -type f -exec sed -r \
diff --git a/pkgs/tools/misc/grub4dos/default.nix b/pkgs/tools/misc/grub4dos/default.nix
index 3c9af75aab921..7e9b82a6a3f9c 100644
--- a/pkgs/tools/misc/grub4dos/default.nix
+++ b/pkgs/tools/misc/grub4dos/default.nix
@@ -6,13 +6,13 @@ let arch =
   else abort "Unknown architecture";
 in stdenv.mkDerivation rec {
   name = "grub4dos-${version}";
-  version = "0.4.6a-2016-04-26";
+  version = "0.4.6a-2016-08-06";
 
   src = fetchFromGitHub {
     owner = "chenall";
     repo = "grub4dos";
-    rev = "61d8229375c679436d56376518456723b2025e1a";
-    sha256 = "1r4jmvykk5cvpf1kysykvksa9vfy7p29q20x72inw2pbhipj0f10";
+    rev = "99d6ddbe7611f942d2708d77a620d6aa94a284d1";
+    sha256 = "0gnllk0qkx6d0azf7v9cr0b23gp577avksz0f4dl3v3ldgi0dksq";
   };
 
   nativeBuildInputs = [ nasm ];
diff --git a/pkgs/tools/misc/svtplay-dl/default.nix b/pkgs/tools/misc/svtplay-dl/default.nix
index 7848abcf14dcd..1169752b9cac0 100644
--- a/pkgs/tools/misc/svtplay-dl/default.nix
+++ b/pkgs/tools/misc/svtplay-dl/default.nix
@@ -1,7 +1,9 @@
-{ stdenv, fetchFromGitHub, makeWrapper, python, perl, zip
-, rtmpdump, nose, mock, pycrypto, requests2, substituteAll }:
+{ stdenv, fetchFromGitHub, makeWrapper, pythonPackages, perl, zip
+, rtmpdump, substituteAll }:
 
-stdenv.mkDerivation rec {
+let
+  inherit (pythonPackages) python nose pycrypto requests2 mock;
+in stdenv.mkDerivation rec {
   name = "svtplay-dl-${version}";
   version = "1.1";
 
@@ -24,7 +26,7 @@ stdenv.mkDerivation rec {
       --replace 'PYTHONPATH=lib' 'PYTHONPATH=lib:$PYTHONPATH'
   '';
 
-  makeFlags = "PREFIX=$(out) SYSCONFDIR=$(out)/etc PYTHON=${python}/bin/python";
+  makeFlags = "PREFIX=$(out) SYSCONFDIR=$(out)/etc PYTHON=${python.interpreter}";
 
   postInstall = ''
     wrapProgram "$out/bin/svtplay-dl" \
diff --git a/pkgs/tools/networking/logmein-hamachi/default.nix b/pkgs/tools/networking/logmein-hamachi/default.nix
index 28fb39db5719f..7b441c72cbf4b 100644
--- a/pkgs/tools/networking/logmein-hamachi/default.nix
+++ b/pkgs/tools/networking/logmein-hamachi/default.nix
@@ -10,16 +10,17 @@ let
     else if stdenv.system == "i686-linux" then "x86"
     else abort "Unsupported architecture";
   sha256 =
-    if stdenv.system == "x86_64-linux" then "1j9sba5prpihlmxr98ss3vls2qjfc6hypzlakr1k97z0a8433nif"
-    else if stdenv.system == "i686-linux" then "100x6gib2np72wrvcn1yhdyn4fplf5x8xm4x0g77izyfdb3yjg8h"
+    if stdenv.system == "x86_64-linux" then "0l8y8z8fqvxrypx3dp83mm3qr9shgpcn5h7x2k2z13gp4aq0yw6g"
+    else if stdenv.system == "i686-linux" then "00nl442k4pij9fm8inlk4qrcvbnz55fbwf3sm3dgbzvd5jcgsa0f"
     else abort "Unsupported architecture";
   libraries = stdenv.lib.makeLibraryPath [ stdenv.cc.cc ];
 
 in stdenv.mkDerivation rec {
-  name = "logmein-hamachi-2.1.0.139";
+  name = "logmein-hamachi-${version}";
+  version = "2.1.0.165";
 
   src = fetchurl {
-    url = "https://secure.logmein.com/labs/${name}-${arch}.tgz";
+    url = "https://www.vpn.net/installers/${name}-${arch}.tgz";
     inherit sha256;
   };
 
@@ -37,7 +38,7 @@ in stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "A hosted VPN service that lets you securely extend LAN-like networks to distributed teams";
-    homepage = https://secure.logmein.com/products/hamachi/;
+    homepage = "https://secure.logmein.com/products/hamachi/";
     license = licenses.unfreeRedistributable;
     maintainers = with maintainers; [ abbradar ];
     platforms = platforms.linux;
diff --git a/pkgs/tools/networking/network-manager/default.nix b/pkgs/tools/networking/network-manager/default.nix
index 63740558a27fb..66a261c7cf64c 100644
--- a/pkgs/tools/networking/network-manager/default.nix
+++ b/pkgs/tools/networking/network-manager/default.nix
@@ -26,6 +26,8 @@ stdenv.mkDerivation rec {
       --replace /bin/sh ${stdenv.shell} \
       --replace /usr/sbin/ethtool ${ethtool}/sbin/ethtool \
       --replace /bin/sed ${gnused}/bin/sed
+    substituteInPlace data/NetworkManager.service.in \
+      --replace /bin/kill ${coreutils}/bin/kill
     # to enable link-local connections
     configureFlags="$configureFlags --with-udev-dir=$out/lib/udev"
   '';
diff --git a/pkgs/tools/networking/openvpn/update-resolv-conf.nix b/pkgs/tools/networking/openvpn/update-resolv-conf.nix
index 80f7d149b7f48..f59e70ed31879 100644
--- a/pkgs/tools/networking/openvpn/update-resolv-conf.nix
+++ b/pkgs/tools/networking/openvpn/update-resolv-conf.nix
@@ -1,27 +1,32 @@
-{ stdenv, fetchgit, makeWrapper, openresolv, coreutils }:
+{ stdenv, lib, fetchFromGitHub, makeWrapper, openresolv, coreutils, which, systemd }:
 
-stdenv.mkDerivation rec {
-  name = "update-resolv-conf-20141003";
+let
+  binPath = lib.makeBinPath [ coreutils openresolv which systemd ];
 
-  src = fetchgit {
-    url = https://github.com/masterkorp/openvpn-update-resolv-conf/;
-    rev = "dd968419373bce71b22bbd26de962e89eb470670";
-    sha256 = "0j7mg66lqhgvhybgbn98y7i5skj1ify41hmb0yhkx2xrli8027b9";
+in stdenv.mkDerivation rec {
+  name = "update-resolv-conf-2016-04-24";
+
+  src = fetchFromGitHub {
+    owner = "masterkorp";
+    repo = "openvpn-update-resolv-conf";
+    rev = "994574f36b9147cc78674a5f13874d503a625c98";
+    sha256 = "1rvzlaj53k8s09phg4clsyzlmf44dmwwyvg0nbg966sxp3xsqlxc";
   };
 
   nativeBuildInputs = [ makeWrapper ];
 
   installPhase = ''
     install -Dm555 update-resolv-conf.sh $out/libexec/openvpn/update-resolv-conf
-    sed -i 's,^\(RESOLVCONF=\).*,\1resolvconf,' $out/libexec/openvpn/update-resolv-conf
+    install -Dm555 update-systemd-network.sh $out/libexec/openvpn/update-systemd-network
 
-    wrapProgram $out/libexec/openvpn/update-resolv-conf \
-        --prefix PATH : ${coreutils}/bin:${openresolv}/sbin
+    for i in $out/libexec/openvpn/*; do
+      wrapProgram $i --prefix PATH : ${binPath}
+    done
   '';
 
   meta = with stdenv.lib; {
     description = "Script to update your /etc/resolv.conf with DNS settings that come from the received push dhcp-options";
-    homepage = https://github.com/masterkorp/openvpn-update-resolv-conf/;
+    homepage = "https://github.com/masterkorp/openvpn-update-resolv-conf/";
     maintainers = with maintainers; [ abbradar ];
     license = licenses.gpl2;
     platforms = platforms.unix;
diff --git a/pkgs/tools/networking/wicd/default.nix b/pkgs/tools/networking/wicd/default.nix
index 8013e6d00cd60..fe6ad74c2362d 100644
--- a/pkgs/tools/networking/wicd/default.nix
+++ b/pkgs/tools/networking/wicd/default.nix
@@ -1,8 +1,11 @@
-{stdenv, fetchurl, python, pygobject, pycairo, pyGtkGlade, pythonDBus, 
- wpa_supplicant, dhcp, dhcpcd, wirelesstools, nettools, openresolv, iproute, iputils,
- pythonPackages, locale ? "C" }:
+{ stdenv, fetchurl, pythonPackages
+, wpa_supplicant, dhcp, dhcpcd, wirelesstools
+, nettools, openresolv, iproute, iputils
+, locale ? "C" }:
 
-stdenv.mkDerivation rec {
+let
+  inherit (pythonPackages) python pygobject dbus pyGtkGlade pycairo;
+in stdenv.mkDerivation rec {
   name = "wicd-${version}";
   version = "1.7.2.4";
   
@@ -11,9 +14,8 @@ stdenv.mkDerivation rec {
     sha256 = "15ywgh60xzmp5z8l1kzics7yi95isrjg1paz42dvp7dlpdfzpzfw";
   };
 
-  buildInputs = [
-    python pythonPackages.Babel
-    pythonPackages.urwid pythonPackages.notify
+  buildInputs = with pythonPackages; [
+    python Babel urwid notify
   ];
 
   patches = [
@@ -31,20 +33,20 @@ stdenv.mkDerivation rec {
   # !!! Should use makeWrapper.
   postPatch = ''
     # We don't have "python2".
-    substituteInPlace wicd/wicd-daemon.py --replace 'misc.find_path("python2")' "'${python}/bin/python'"
+    substituteInPlace wicd/wicd-daemon.py --replace 'misc.find_path("python2")' "'${python.interpreter}'"
     
     substituteInPlace in/scripts=wicd.in --subst-var-by TEMPLATE-DEFAULT $out/share/other/dhclient.conf.template.default
 
     sed -i "2iexport PATH=${python}/bin:${wpa_supplicant}/sbin:${dhcpcd}/sbin:${dhcp}/sbin:${wirelesstools}/sbin:${nettools}/sbin:${nettools}/bin:${iputils}/bin:${openresolv}/sbin:${iproute}/sbin\$\{PATH:+:\}\$PATH" in/scripts=wicd.in
-    sed -i "3iexport PYTHONPATH=$(toPythonPath $out):$(toPythonPath ${pygobject}):$(toPythonPath ${pythonDBus})\$\{PYTHONPATH:+:\}\$PYTHONPATH" in/scripts=wicd.in
+    sed -i "3iexport PYTHONPATH=$(toPythonPath $out):$(toPythonPath ${pygobject}):$(toPythonPath ${dbus})\$\{PYTHONPATH:+:\}\$PYTHONPATH" in/scripts=wicd.in
     sed -i "2iexport PATH=${python}/bin\$\{PATH:+:\}\$PATH" in/scripts=wicd-client.in
-    sed -i "3iexport PYTHONPATH=$(toPythonPath $out):$(toPythonPath ${pyGtkGlade})/gtk-2.0:$(toPythonPath ${pygobject}):$(toPythonPath ${pygobject})/gtk-2.0:$(toPythonPath ${pycairo}):$(toPythonPath ${pythonDBus})\$\{PYTHONPATH:+:\}\$PYTHONPATH" in/scripts=wicd-client.in
+    sed -i "3iexport PYTHONPATH=$(toPythonPath $out):$(toPythonPath ${pyGtkGlade})/gtk-2.0:$(toPythonPath ${pygobject}):$(toPythonPath ${pygobject})/gtk-2.0:$(toPythonPath ${pycairo}):$(toPythonPath ${dbus})\$\{PYTHONPATH:+:\}\$PYTHONPATH" in/scripts=wicd-client.in
     sed -i "2iexport PATH=${python}/bin\$\{PATH:+:\}\$PATH" in/scripts=wicd-gtk.in
-    sed -i "3iexport PYTHONPATH=$(toPythonPath $out):$(toPythonPath ${pyGtkGlade})/gtk-2.0:$(toPythonPath ${pygobject}):$(toPythonPath ${pygobject})/gtk-2.0:$(toPythonPath ${pycairo}):$(toPythonPath ${pythonDBus}):$(toPythonPath ${pythonPackages.notify})\$\{PYTHONPATH:+:\}\$PYTHONPATH" in/scripts=wicd-gtk.in
+    sed -i "3iexport PYTHONPATH=$(toPythonPath $out):$(toPythonPath ${pyGtkGlade})/gtk-2.0:$(toPythonPath ${pygobject}):$(toPythonPath ${pygobject})/gtk-2.0:$(toPythonPath ${pycairo}):$(toPythonPath ${dbus}):$(toPythonPath ${pythonPackages.notify})\$\{PYTHONPATH:+:\}\$PYTHONPATH" in/scripts=wicd-gtk.in
     sed -i "2iexport PATH=${python}/bin\$\{PATH:+:\}\$PATH" in/scripts=wicd-cli.in
-    sed -i "3iexport PYTHONPATH=$(toPythonPath $out):$(toPythonPath ${pyGtkGlade})/gtk-2.0:$(toPythonPath ${pygobject}):$(toPythonPath ${pycairo}):$(toPythonPath ${pythonDBus})\$\{PYTHONPATH:+:\}\$PYTHONPATH" in/scripts=wicd-cli.in
+    sed -i "3iexport PYTHONPATH=$(toPythonPath $out):$(toPythonPath ${pyGtkGlade})/gtk-2.0:$(toPythonPath ${pygobject}):$(toPythonPath ${pycairo}):$(toPythonPath ${dbus})\$\{PYTHONPATH:+:\}\$PYTHONPATH" in/scripts=wicd-cli.in
     sed -i "2iexport PATH=${python}/bin\$\{PATH:+:\}\$PATH" in/scripts=wicd-curses.in
-    sed -i "3iexport PYTHONPATH=$(toPythonPath $out):$(toPythonPath ${pyGtkGlade})/gtk-2.0:$(toPythonPath ${pygobject}):$(toPythonPath ${pycairo}):$(toPythonPath ${pythonDBus}):$(toPythonPath ${pythonPackages.urwid}):$(toPythonPath ${pythonPackages.curses})\$\{PYTHONPATH:+:\}\$PYTHONPATH" in/scripts=wicd-curses.in
+    sed -i "3iexport PYTHONPATH=$(toPythonPath $out):$(toPythonPath ${pyGtkGlade})/gtk-2.0:$(toPythonPath ${pygobject}):$(toPythonPath ${pycairo}):$(toPythonPath ${dbus}):$(toPythonPath ${pythonPackages.urwid}):$(toPythonPath ${pythonPackages.curses})\$\{PYTHONPATH:+:\}\$PYTHONPATH" in/scripts=wicd-curses.in
     rm po/ast.po
   '';
 
@@ -90,7 +92,7 @@ stdenv.mkDerivation rec {
   '';
 
   installPhase = ''
-    python setup.py install --prefix=$out --install-lib=$out/lib/${python.libPrefix}/site-packages
+    python setup.py install --prefix=$out --install-lib=$out/${python.sitePackages}
     mkdir -p $out/share/other
     cp other/dhclient.conf.template.default $out/share/other/dhclient.conf.template.default
 
diff --git a/pkgs/tools/security/fail2ban/default.nix b/pkgs/tools/security/fail2ban/default.nix
index c886b10e2201a..70dfb9e82c6b4 100644
--- a/pkgs/tools/security/fail2ban/default.nix
+++ b/pkgs/tools/security/fail2ban/default.nix
@@ -17,11 +17,6 @@ pythonPackages.buildPythonApplication {
     ++ (stdenv.lib.optional stdenv.isLinux pythonPackages.systemd);
 
   preConfigure = ''
-    for i in fail2ban-client fail2ban-regex fail2ban-server; do
-      substituteInPlace $i \
-        --replace /usr/share/fail2ban $out/share/fail2ban
-    done
-
     for i in config/action.d/sendmail*.conf; do
       substituteInPlace $i \
         --replace /usr/sbin/sendmail sendmail \
diff --git a/pkgs/tools/security/gnupg/21.nix b/pkgs/tools/security/gnupg/21.nix
index 30ce33bd6a511..418f622fafdb6 100644
--- a/pkgs/tools/security/gnupg/21.nix
+++ b/pkgs/tools/security/gnupg/21.nix
@@ -27,14 +27,16 @@ stdenv.mkDerivation rec {
     readline libusb gnutls adns openldap zlib bzip2
   ];
 
+  # gpgsm-linking is fixed by commit (c49c43d7) in the gnupg master branch;
+  # fix-gpgsm-linking.patch should be dropped after gnupg 2.1.15 is released
+  patches = [ ./fix-gpgsm-linking.patch ];
+
   postPatch = stdenv.lib.optionalString stdenv.isLinux ''
     sed -i 's,"libpcsclite\.so[^"]*","${pcsclite}/lib/libpcsclite.so",g' scd/scdaemon.c
   ''; #" fix Emacs syntax highlighting :-(
 
   configureFlags = optional x11Support "--with-pinentry-pgm=${pinentry}/bin/pinentry";
 
-  postConfigure = "substituteAllInPlace tools/gpgkey2ssh.c";
-
   meta = with stdenv.lib; {
     homepage = http://gnupg.org;
     description = "A complete and free implementation of the OpenPGP standard";
diff --git a/pkgs/tools/security/gnupg/fix-gpgsm-linking.patch b/pkgs/tools/security/gnupg/fix-gpgsm-linking.patch
new file mode 100644
index 0000000000000..290d43f5b0d40
--- /dev/null
+++ b/pkgs/tools/security/gnupg/fix-gpgsm-linking.patch
@@ -0,0 +1,11 @@
+--- a/tests/gpgscm/Makefile.in
++++ b/tests/gpgscm/Makefile.in
+@@ -457,7 +457,7 @@
+ 	scheme-config.h opdefines.h scheme.c scheme.h scheme-private.h
+ 
+ gpgscm_LDADD = $(LDADD) $(common_libs) \
+-	$(NETLIBS) $(LIBICONV) $(LIBREADLINE) \
++	$(NETLIBS) $(LIBICONV) $(LIBREADLINE) $(LIBINTL) \
+ 	$(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS)
+ 
+ t_child_SOURCES = t-child.c
diff --git a/pkgs/tools/security/knockknock/default.nix b/pkgs/tools/security/knockknock/default.nix
index 089dd0de2bdad..7e4ff32e88054 100644
--- a/pkgs/tools/security/knockknock/default.nix
+++ b/pkgs/tools/security/knockknock/default.nix
@@ -1,6 +1,6 @@
-{ stdenv, fetchFromGitHub, buildPythonApplication, python, pycrypto, hping }:
+{ stdenv, fetchFromGitHub, pythonPackages, buildPythonApplication, hping }:
 
-buildPythonApplication rec {
+pythonPackages.buildPythonApplication rec {
   rev  = "bf14bbff";
   name = "knockknock-r${rev}";
 
@@ -11,7 +11,7 @@ buildPythonApplication rec {
     sha256 = "1chpfs3w2vkjrgay69pbdr116z1jldv53fi768a1i05fdqhy1px4";
   };
 
-  propagatedBuildInputs = [ pycrypto ];
+  propagatedBuildInputs = [ pythonPackages.pycrypto ];
 
   patchPhase = ''
     sed -i '/build\//d' setup.py
diff --git a/pkgs/tools/security/nmap/default.nix b/pkgs/tools/security/nmap/default.nix
index 415f8f52a475e..f9c7dba5660bf 100644
--- a/pkgs/tools/security/nmap/default.nix
+++ b/pkgs/tools/security/nmap/default.nix
@@ -2,16 +2,15 @@
 , graphicalSupport ? false
 , libX11 ? null
 , gtk ? null
-, python ? null
-, pygtk ? null
+, pythonPackages
 , makeWrapper ? null
-, pygobject ? null
-, pycairo ? null
-, pysqlite ? null
 }:
 
 with stdenv.lib;
-stdenv.mkDerivation rec {
+
+let
+  inherit (pythonPackages) python pygtk pygobject pycairo pysqlite;
+in stdenv.mkDerivation rec {
   name = "nmap${optionalString graphicalSupport "-graphical"}-${version}";
   version = "7.12";
 
diff --git a/pkgs/tools/security/volatility/default.nix b/pkgs/tools/security/volatility/default.nix
index 511da154c5079..6f1b7fe6ef473 100644
--- a/pkgs/tools/security/volatility/default.nix
+++ b/pkgs/tools/security/volatility/default.nix
@@ -1,10 +1,8 @@
-{ stdenv, fetchurl, buildPythonApplication, pycrypto }:
+{ stdenv, fetchurl, pythonPackages }:
 
-buildPythonApplication rec {
-  namePrefix = "";
+pythonPackages.buildPythonApplication rec {
   name = "volatility-2.4";
 
-
   src = fetchurl {
     url = "http://downloads.volatilityfoundation.org/releases/2.4/${name}.tar.gz";
     sha256 = "1wffrkvj2lrkqhwamyix9fy05y6g6w8h1sz2iqlm6i6ag7yxykv8";
@@ -12,7 +10,7 @@ buildPythonApplication rec {
 
   doCheck = false;
 
-  propagatedBuildInputs = [ pycrypto ];
+  propagatedBuildInputs = [ pythonPackages.pycrypto ];
 
   meta = with stdenv.lib; {
     homepage = https://code.google.com/p/volatility;
diff --git a/pkgs/tools/typesetting/tex/texlive-new/pkgs.nix b/pkgs/tools/typesetting/tex/texlive-new/pkgs.nix
index aa0e4690248c4..4345e9744b7af 100644
--- a/pkgs/tools/typesetting/tex/texlive-new/pkgs.nix
+++ b/pkgs/tools/typesetting/tex/texlive-new/pkgs.nix
@@ -22857,7 +22857,7 @@ tl: { # no indentation
   version = "prot2.5";
 };
 "xdvi" = {
-  md5.run = "ada6dc1ceffd19a5fdd33d0536c8f82a";
+  md5.run = "0d66ffa281d713e3395ee0f5db93c9bd";
   md5.doc = "eda28e06fbd79ed2bb26aff4d4d2fd22";
   hasRunfiles = true;
   version = "22.87";
diff --git a/pkgs/tools/video/mjpegtools/default.nix b/pkgs/tools/video/mjpegtools/default.nix
index 0da9453235956..489b67f483ba3 100644
--- a/pkgs/tools/video/mjpegtools/default.nix
+++ b/pkgs/tools/video/mjpegtools/default.nix
@@ -30,7 +30,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "A suite of programs for processing MPEG or MJPEG video";
-    homepage = http://mjpeg.sourceforge.net/;
+    homepage = "http://mjpeg.sourceforge.net/";
     license = licenses.gpl2;
     platforms = platforms.unix;
     maintainers = with maintainers; [ abbradar ];
diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix
index dd458deb289e2..a8e18f2bb46b5 100644
--- a/pkgs/top-level/aliases.nix
+++ b/pkgs/top-level/aliases.nix
@@ -79,11 +79,6 @@ doNotDisplayTwice rec {
   qca-qt5 = qt5.qca-qt5;  # added 2015-12-19
   QmidiNet = qmidinet;  # added 2016-05-22
   quake3game = ioquake3; # added 2016-01-14
-  quassel_kf5 = kde5.quassel; # added 2015-09-30
-  quassel_qt5 = kde5.quassel_qt5; # added 2015-09-30
-  quasselClient_kf5 = kde5.quasselClient; # added 2015-09-30
-  quasselClient_qt5 = kde5.quasselClient_qt5; # added 2015-09-30
-  quasselDaemon_qt5 = kde5.quasselDaemon; # added 2015-09-30
   qwt6 = qt5.qwt;  # added 2015-12-19
   rdiff_backup = rdiff-backup;  # added 2014-11-23
   rekonqWrapper = rekonq; # added 2015-01
@@ -111,4 +106,5 @@ doNotDisplayTwice rec {
   xf86_video_nouveau = xorg.xf86videonouveau; # added 2015-09
   xlibs = xorg; # added 2015-09
   youtubeDL = youtube-dl;  # added 2014-10-26
+  m3d-linux = m33-linux; # added 2016-08-13
 }
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index a970b4744140c..8e57aca9503e4 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -646,9 +646,7 @@ in
     sha256 = "0p2sxrpzd0vsk11zf3kb5h12yl1nq4yypb5mpjrm8ww0cfaijck2";
   };
 
-  btfs = callPackage ../os-specific/linux/btfs {
-    libtorrentRasterbar = libtorrentRasterbar_1_09;
-  };
+  btfs = callPackage ../os-specific/linux/btfs { };
 
   cabal2nix = self.haskell.lib.overrideCabal self.haskellPackages.cabal2nix (drv: {
     isLibrary = false;
@@ -666,6 +664,12 @@ in
 
   caddy = callPackage ../servers/caddy { };
 
+  calamares = qt5.callPackage ../tools/misc/calamares rec {
+    python = python3;
+    boost = pkgs.boost.override { python=python3; };
+    libyamlcpp = callPackage ../development/libraries/libyaml-cpp { makePIC=true; boost=boost; };
+  };
+
   capstone = callPackage ../development/libraries/capstone { };
 
   catch = callPackage ../development/libraries/catch { };
@@ -700,6 +704,8 @@ in
 
   clib = callPackage ../tools/package-management/clib { };
 
+  colord-kde = qt5.callPackage ../tools/misc/colord-kde/0.5.nix {};
+
   consul = callPackage ../servers/consul { };
 
   consul-ui = callPackage ../servers/consul/ui.nix { };
@@ -734,8 +740,6 @@ in
 
   deis = callPackage ../development/tools/deis {};
 
-  dfilemanager = self.kde5.dfilemanager;
-
   diagrams-builder = callPackage ../tools/graphics/diagrams-builder {
     inherit (haskellPackages) ghcWithPackages diagrams-builder;
   };
@@ -1394,7 +1398,6 @@ in
   duo-unix = callPackage ../tools/security/duo-unix { };
 
   duplicity = callPackage ../tools/backup/duplicity {
-    inherit (pythonPackages) boto lockfile paramiko ecdsa pycrypto;
     gnupg = gnupg1;
   };
 
@@ -1527,7 +1530,7 @@ in
     hangul = callPackage ../tools/inputmethods/fcitx-engines/fcitx-hangul { };
 
     unikey = callPackage ../tools/inputmethods/fcitx-engines/fcitx-unikey { };
-    
+
     m17n = callPackage ../tools/inputmethods/fcitx-engines/fcitx-m17n { };
 
     mozc = callPackage ../tools/inputmethods/fcitx-engines/fcitx-mozc {
@@ -2216,6 +2219,8 @@ in
 
   kpcli = callPackage ../tools/security/kpcli { };
 
+  kronometer = qt5.callPackage ../tools/misc/kronometer { };
+
   kst = qt5.callPackage ../tools/graphics/kst { gsl = gsl_1; };
 
   leocad = callPackage ../applications/graphics/leocad { };
@@ -2768,7 +2773,6 @@ in
   nmap = callPackage ../tools/security/nmap { };
 
   nmap_graphical = callPackage ../tools/security/nmap {
-    inherit (pythonPackages) pysqlite;
     graphicalSupport = true;
   };
 
@@ -3212,9 +3216,7 @@ in
 
   openmodelica = callPackage ../applications/science/misc/openmodelica { };
 
-  qarte = callPackage ../applications/video/qarte {
-    sip = pythonPackages.sip_4_16;
-  };
+  qarte = callPackage ../applications/video/qarte { };
 
   qnial = callPackage ../development/interpreters/qnial {};
 
@@ -3620,9 +3622,7 @@ in
 
   svnfs = callPackage ../tools/filesystems/svnfs { };
 
-  svtplay-dl = callPackage ../tools/misc/svtplay-dl {
-    inherit (pythonPackages) nose mock requests2;
-  };
+  svtplay-dl = callPackage ../tools/misc/svtplay-dl { };
 
   sysbench = callPackage ../development/tools/misc/sysbench {};
 
@@ -4387,9 +4387,6 @@ in
 
   cryptol = self.haskell.packages.lts.cryptol;
 
-  cython = pythonPackages.cython;
-  cython3 = python3Packages.cython;
-
   devpi-client = callPackage ../development/tools/devpi-client {};
 
   drumstick = callPackage ../development/libraries/drumstick { };
@@ -5940,7 +5937,6 @@ in
   regina = callPackage ../development/interpreters/regina { };
 
   renpy = callPackage ../development/interpreters/renpy {
-    wrapPython = pythonPackages.wrapPython;
     ffmpeg = ffmpeg_2;
   };
 
@@ -6092,9 +6088,10 @@ in
 
   apacheAnt = callPackage ../development/tools/build-managers/apache-ant { };
 
-  apacheKafka = apacheKafka_0_9;
+  apacheKafka = apacheKafka_0_10;
   apacheKafka_0_8 = callPackage ../servers/apache-kafka { majorVersion = "0.8"; };
   apacheKafka_0_9 = callPackage ../servers/apache-kafka { majorVersion = "0.9"; };
+  apacheKafka_0_10 = callPackage ../servers/apache-kafka { majorVersion = "0.10"; };
 
   astyle = callPackage ../development/tools/misc/astyle { };
 
@@ -6398,6 +6395,8 @@ in
     inherit (xorg) libX11 libXext libXi libXtst;
   };
 
+  github-release = callPackage ../development/tools/github/github-release { };
+
   global = callPackage ../development/tools/misc/global { };
 
   gnome_doc_utils = callPackage ../development/tools/documentation/gnome-doc-utils {};
@@ -6567,6 +6566,8 @@ in
 
   oprofile = callPackage ../development/tools/profiling/oprofile { };
 
+  pahole = callPackage ../development/tools/misc/pahole {};
+
   parse-cli-bin = callPackage ../development/tools/parse-cli-bin { };
 
   patchelf = callPackage ../development/tools/misc/patchelf { };
@@ -6772,6 +6773,8 @@ in
     ocamlPackages = ocamlPackages_4_02;
   });
 
+  visualvm = callPackage ../development/tools/java/visualvm { };
+
   xc3sprog = callPackage ../development/tools/misc/xc3sprog { };
 
   xmlindent = callPackage ../development/web/xmlindent {};
@@ -8728,7 +8731,6 @@ in
   minmay = callPackage ../development/libraries/minmay { };
 
   miro = callPackage ../applications/video/miro {
-    inherit (pythonPackages) pywebkitgtk pycurl mutagen;
     avahi = avahi.override {
       withLibdnssdCompat = true;
     };
@@ -9720,6 +9722,8 @@ in
   xcb-util-cursor = xorg.xcbutilcursor;
   xcb-util-cursor-HEAD = callPackage ../development/libraries/xcb-util-cursor/HEAD.nix { };
 
+  xcbutilxrm = callPackage ../servers/x11/xorg/xcb-util-xrm.nix { };
+
   xdo = callPackage ../tools/misc/xdo { };
 
   xineLib = callPackage ../development/libraries/xine-lib {
@@ -9775,6 +9779,8 @@ in
     fetchurl = fetchurlBoot;
   };
 
+  libdynd = callPackage ../development/libraries/libdynd { };
+
   zlog = callPackage ../development/libraries/zlog { };
 
   zlibStatic = lowPrio (appendToName "static" (callPackage ../development/libraries/zlib {
@@ -10019,22 +10025,10 @@ in
     self = pypyPackages;
   };
 
-  bsddb3 = pythonPackages.bsddb3;
-
-  ecdsa = pythonPackages.ecdsa;
-
-  pycairo = pythonPackages.pycairo;
-
   pycapnp = pythonPackages.pycapnp;
 
-  pycrypto = pythonPackages.pycrypto;
-
-  pycups = pythonPackages.pycups;
-
   pyexiv2 = pythonPackages.pyexiv2;
 
-  pygame = pythonPackages.pygame;
-
   pygobject = pythonPackages.pygobject;
 
   pygobject3 = pythonPackages.pygobject3;
@@ -10045,14 +10039,8 @@ in
 
   pyGtkGlade = pythonPackages.pyGtkGlade;
 
-  pylint = pythonPackages.pylint;
-
-  pyopenssl = pythonPackages.pyopenssl;
-
   rhpl = pythonPackages.rhpl;
 
-  pyqt4 = pythonPackages.pyqt4;
-
   pysideApiextractor = pythonPackages.pysideApiextractor;
 
   pysideGeneratorrunner = pythonPackages.pysideGeneratorrunner;
@@ -10069,12 +10057,8 @@ in
 
   rebol =  callPackage ../development/interpreters/rebol { };
 
-  setuptools = pythonPackages.setuptools;
-
   slowaes = pythonPackages.slowaes;
 
-  twisted = pythonPackages.twisted;
-
   yolk = callPackage ../development/python-modules/yolk {};
 
   ZopeInterface = pythonPackages.zope_interface;
@@ -10896,7 +10880,9 @@ in
 
   fatrace = callPackage ../os-specific/linux/fatrace { };
 
-  ffadoFull = callPackage ../os-specific/linux/ffado { };
+  ffadoFull = callPackage ../os-specific/linux/ffado {
+    inherit (pythonPackages) python pyqt4;
+  };
   libffado = self.ffadoFull.override { prefix = "lib"; };
 
   fbterm = callPackage ../os-specific/linux/fbterm { };
@@ -11119,18 +11105,6 @@ in
       ];
   };
 
-  linux_4_5 = callPackage ../os-specific/linux/kernel/linux-4.5.nix {
-    kernelPatches =
-      [ kernelPatches.bridge_stp_helper
-        kernelPatches.hiddev_CVE_2016_5829
-      ]
-      ++ lib.optionals ((platform.kernelArch or null) == "mips")
-      [ kernelPatches.mips_fpureg_emu
-        kernelPatches.mips_fpu_sigill
-        kernelPatches.mips_ext3_n32
-      ];
-  };
-
   linux_4_6 = callPackage ../os-specific/linux/kernel/linux-4.6.nix {
     kernelPatches =
       [ kernelPatches.bridge_stp_helper
@@ -11320,7 +11294,6 @@ in
   linuxPackages_3_18 = recurseIntoAttrs (self.linuxPackagesFor self.linux_3_18 linuxPackages_3_18);
   linuxPackages_4_1 = recurseIntoAttrs (self.linuxPackagesFor self.linux_4_1 linuxPackages_4_1);
   linuxPackages_4_4 = recurseIntoAttrs (self.linuxPackagesFor self.linux_4_4 linuxPackages_4_4);
-  linuxPackages_4_5 = recurseIntoAttrs (self.linuxPackagesFor self.linux_4_5 linuxPackages_4_5);
   linuxPackages_4_6 = recurseIntoAttrs (self.linuxPackagesFor self.linux_4_6 linuxPackages_4_6);
   linuxPackages_4_7 = recurseIntoAttrs (self.linuxPackagesFor self.linux_4_7 linuxPackages_4_7);
   # Don't forget to update linuxPackages_latest!
@@ -12241,9 +12214,6 @@ in
   alpine = callPackage ../applications/networking/mailreaders/alpine {
     tcl = tcl-8_5;
   };
-  realpine = callPackage ../applications/networking/mailreaders/realpine {
-    tcl = tcl-8_5;
-  };
 
   AMB-plugins = callPackage ../applications/audio/AMB-plugins { };
 
@@ -12635,6 +12605,8 @@ in
 
   dfasma = qt5.callPackage ../applications/audio/dfasma { };
 
+  dfilemanager = qt5.callPackage ../applications/misc/dfilemanager { };
+
   dia = callPackage ../applications/graphics/dia {
     inherit (pkgs.gnome) libart_lgpl libgnomeui;
   };
@@ -13035,7 +13007,7 @@ in
   gksu = callPackage ../applications/misc/gksu { };
 
   gnuradio = callPackage ../applications/misc/gnuradio {
-    inherit (pythonPackages) lxml numpy scipy matplotlib pyopengl wxPython;
+    inherit (pythonPackages) lxml matplotlib numpy python pyopengl pyqt4 scipy wxPython;
     fftw = fftwFloat;
   };
 
@@ -13214,6 +13186,16 @@ in
 
   gimpPlugins = recurseIntoAttrs (callPackage ../applications/graphics/gimp/plugins {});
 
+  girara = callPackage ../applications/misc/girara {
+    gtk = gtk3;
+  };
+
+  girara-light = callPackage ../applications/misc/girara {
+    gtk = gtk3;
+    withBuildColors = false;
+    ncurses = null;
+  };
+
   gitAndTools = recurseIntoAttrs (callPackage ../applications/version-management/git-and-tools {});
 
   inherit (self.gitAndTools) git gitFull gitSVN git-cola svn2git git-radar transcrypt git-crypt;
@@ -13522,11 +13504,7 @@ in
   imagemagickBig = callPackage ../applications/graphics/ImageMagick { };
 
   # Impressive, formerly known as "KeyJNote".
-  impressive = callPackage ../applications/office/impressive {
-    # XXX These are the PyOpenGL dependencies, which we need here.
-    inherit (pythonPackages) pyopengl;
-    inherit (pythonPackages) pillow;
-  };
+  impressive = callPackage ../applications/office/impressive { };
 
   inferno = callPackage_i686 ../applications/inferno { };
 
@@ -13607,6 +13585,10 @@ in
     boost = boost155;
   };
 
+  k9copy = qt5.callPackage ../applications/video/k9copy {};
+
+  kdeconnect = qt5.callPackage ../applications/misc/kdeconnect { };
+
   keepnote = callPackage ../applications/office/keepnote {
     pygtk = pyGtkGlade;
   };
@@ -13627,6 +13609,8 @@ in
     qt = qt4;
   };
 
+  kile = kde5.callPackage ../applications/editors/kile/frameworks.nix { };
+
   kino = callPackage ../applications/video/kino {
     inherit (gnome) libglade;
     ffmpeg = ffmpeg_2;
@@ -13636,6 +13620,13 @@ in
 
   koji = callPackage ../tools/package-management/koji { };
 
+  konversation = qt5.callPackage ../applications/networking/irc/konversation/1.6.nix { };
+
+  krita = qt5.callPackage ../applications/graphics/krita {
+    vc = vc_0_7;
+    openjpeg = openjpeg_1;
+  };
+
   ksuperkey = callPackage ../tools/X11/ksuperkey { };
 
   kubernetes = callPackage ../applications/networking/cluster/kubernetes {
@@ -13843,9 +13834,7 @@ in
 
   mid2key = callPackage ../applications/audio/mid2key { };
 
-  midori-unwrapped = callPackage ../applications/networking/browsers/midori {
-    webkitgtk = webkitgtk24x;
-  };
+  midori-unwrapped = callPackage ../applications/networking/browsers/midori { };
   midori = wrapFirefox midori-unwrapped { };
 
   mikmod = callPackage ../applications/audio/mikmod { };
@@ -14254,10 +14243,7 @@ in
 
   pianobooster = callPackage ../applications/audio/pianobooster { };
 
-  picard = callPackage ../applications/audio/picard {
-    python-libdiscid = pythonPackages.discid;
-    mutagen = pythonPackages.mutagen;
-  };
+  picard = callPackage ../applications/audio/picard { };
 
   picocom = callPackage ../tools/misc/picocom { };
 
@@ -14374,6 +14360,10 @@ in
     inherit (darwin.stubs) rez setfile;
   };
 
+  qgis = callPackage ../applications/gis/qgis {};
+
+  qgroundcontrol = qt55.callPackage ../applications/science/robotics/qgroundcontrol { };
+
   qjackctl = callPackage ../applications/audio/qjackctl { };
 
   qmidinet = callPackage ../applications/audio/qmidinet { };
@@ -14394,6 +14384,8 @@ in
 
   qsynth = callPackage ../applications/audio/qsynth { };
 
+  qtbitcointrader = callPackage ../applications/misc/qtbitcointrader { };
+
   qtox = qt5.callPackage ../applications/networking/instant-messengers/qtox { };
 
   qtpass = qt5.callPackage ../applications/misc/qtpass { };
@@ -14404,6 +14396,28 @@ in
 
   qtscrobbler = callPackage ../applications/audio/qtscrobbler { };
 
+  quassel = qt5.callPackage ../applications/networking/irc/quassel/qt-5.nix {
+    monolithic = true;
+    daemon = false;
+    client = false;
+    withKDE = true;
+    dconf = gnome3.dconf;
+    tag = "-kf5";
+  };
+
+  quasselClient = quassel.override {
+    monolithic = false;
+    client = true;
+    tag = "-client-kf5";
+  };
+
+  quasselDaemon = quassel.override {
+    monolithic = false;
+    daemon = true;
+    tag = "-daemon-qt5";
+    withKDE = false;
+  };
+
   quirc = callPackage ../tools/graphics/quirc {};
 
   quodlibet = callPackage ../applications/audio/quodlibet {
@@ -14416,9 +14430,9 @@ in
     gst_plugins_bad = null;
   };
 
-  qutebrowser = qt55.callPackage ../applications/networking/browsers/qutebrowser {
-    inherit (python34Packages) buildPythonApplication python pyqt5 jinja2 pygments pyyaml pypeg2;
-    inherit (gst_all_1) gst-plugins-base gst-plugins-good gst-plugins-bad gst-libav;
+  qutebrowser = qt5.callPackage ../applications/networking/browsers/qutebrowser {
+    inherit (python3Packages) buildPythonApplication pyqt5 jinja2 pygments pyyaml pypeg2;
+    inherit (gst_all_1) gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav;
   };
 
   rabbitvcs = callPackage ../applications/version-management/rabbitvcs {};
@@ -14452,6 +14466,10 @@ in
 
   rdup = callPackage ../tools/backup/rdup { };
 
+  realpine = callPackage ../applications/networking/mailreaders/realpine {
+    tcl = tcl-8_5;
+  };
+
   recode = callPackage ../tools/text/recode { };
 
   remotebox = callPackage ../applications/virtualization/remotebox { };
@@ -14657,7 +14675,9 @@ in
 
   printrun = callPackage ../applications/misc/printrun { };
 
-  sddm = kde5.sddm;
+  sddm = qt5.callPackage ../applications/display-managers/sddm {
+    themes = [];  # extra themes, etc.
+  };
 
   slim = callPackage ../applications/display-managers/slim {
     libpng = libpng12;
@@ -14917,7 +14937,8 @@ in
 
   tribler = callPackage ../applications/networking/p2p/tribler { };
 
-  github-release = callPackage ../development/tools/github/github-release { };
+  # We need QtWebkit which was deprecated in Qt 5.6 although it can still be build
+  trojita = with qt55; callPackage ../applications/networking/mailreaders/trojita { };
 
   tudu = callPackage ../applications/office/tudu { };
 
@@ -15415,30 +15436,24 @@ in
 
   yabar = callPackage ../applications/window-managers/yabar { };
 
-  yate = callPackage ../applications/misc/yate { };
-
-  inherit (gnome3) yelp;
-
-  inherit (python3Packages) you-get;
-
-  inherit (pythonPackages) youtube-dl;
-
-  qgis = callPackage ../applications/gis/qgis {};
-
-  qgroundcontrol = qt55.callPackage ../applications/science/robotics/qgroundcontrol { };
-
-  qtbitcointrader = callPackage ../applications/misc/qtbitcointrader { };
-
-  pahole = callPackage ../development/tools/misc/pahole {};
+  yakuake = kde5.callPackage ../applications/misc/yakuake/3.0.nix {};
 
   yarp = callPackage ../applications/science/robotics/yarp {};
 
+  yate = callPackage ../applications/misc/yate { };
+
   yed = callPackage ../applications/graphics/yed {};
 
+  inherit (gnome3) yelp;
+
   ykpers = callPackage ../applications/misc/ykpers {};
 
   yoshimi = callPackage ../applications/audio/yoshimi { };
 
+  inherit (python3Packages) you-get;
+
+  inherit (pythonPackages) youtube-dl;
+
   zam-plugins = callPackage ../applications/audio/zam-plugins { };
 
   zathuraCollection = recurseIntoAttrs
@@ -15455,16 +15470,6 @@ in
 
   zexy = callPackage ../applications/audio/pd-plugins/zexy  { };
 
-  girara = callPackage ../applications/misc/girara {
-    gtk = gtk3;
-  };
-
-  girara-light = callPackage ../applications/misc/girara {
-    gtk = gtk3;
-    withBuildColors = false;
-    ncurses = null;
-  };
-
   zgrviewer = callPackage ../applications/graphics/zgrviewer {};
 
   zgv = callPackage ../applications/graphics/zgv {
@@ -15503,7 +15508,7 @@ in
   angband = callPackage ../games/angband { };
 
   anki = callPackage ../games/anki {
-    inherit (pythonPackages) wrapPython pysqlite sqlalchemy pyaudio beautifulsoup httplib2 matplotlib;
+    inherit (pythonPackages) wrapPython pysqlite sqlalchemy pyaudio beautifulsoup httplib2 matplotlib pyqt4;
   };
 
   armagetronad = callPackage ../games/armagetronad { };
@@ -16344,78 +16349,6 @@ in
 
   numix-gtk-theme = callPackage ../misc/themes/numix { };
 
-  # We need QtWebkit which was deprecated in Qt 5.6 although it can still be build
-  trojita = with qt55; callPackage ../applications/networking/mailreaders/trojita { };
-
-  kde5PackagesFun = self: with self; {
-
-    calamares = callPackage ../tools/misc/calamares rec {
-      python = python3;
-      boost = pkgs.boost.override { python = python3; };
-      libyamlcpp = callPackage ../development/libraries/libyaml-cpp { boost = boost; };
-    };
-
-    colord-kde = callPackage ../tools/misc/colord-kde/0.5.nix {};
-
-    dfilemanager = callPackage ../applications/misc/dfilemanager { };
-
-    fcitx-qt5 = callPackage ../tools/inputmethods/fcitx/fcitx-qt5.nix { };
-
-    k9copy = callPackage ../applications/video/k9copy { };
-
-    kdeconnect = callPackage ../applications/misc/kdeconnect { };
-
-    kile = callPackage ../applications/editors/kile/frameworks.nix { };
-
-    konversation = callPackage ../applications/networking/irc/konversation/1.6.nix { };
-
-    kronometer = callPackage ../tools/misc/kronometer { };
-
-    krita = callPackage ../applications/graphics/krita {
-      vc = vc_0_7;
-      openjpeg = openjpeg_1;
-    };
-
-    quassel = callPackage ../applications/networking/irc/quassel/qt-5.nix {
-      monolithic = true;
-      daemon = false;
-      client = false;
-      withKDE = true;
-      dconf = gnome3.dconf;
-      tag = "-kf5";
-    };
-
-    quasselClient = quassel.override {
-      monolithic = false;
-      client = true;
-      tag = "-client-kf5";
-    };
-
-    quassel_qt5 = quassel.override {
-      withKDE = false;
-      tag = "-qt5";
-    };
-
-    quasselClient_qt5 = quasselClient.override {
-      withKDE = false;
-      tag = "-client-qt5";
-    };
-
-    quasselDaemon = quassel.override {
-      monolithic = false;
-      daemon = true;
-      tag = "-daemon-qt5";
-      withKDE = false;
-    };
-
-    sddm = callPackage ../applications/display-managers/sddm {
-      themes = [];  # extra themes, etc.
-    };
-
-    yakuake = callPackage ../applications/misc/yakuake/3.0.nix {};
-
-  };
-
   kde5 =
     let
       plasma = import ../desktops/kde-5/plasma { inherit pkgs; };
@@ -16426,8 +16359,7 @@ in
           applications = applications self; }
         // qt5.kdeFrameworks
         // plasma self
-        // applications self
-        // kde5PackagesFun self;
+        // applications self;
     in
       recurseIntoAttrs (lib.makeScope qt5.newScope merged);
 
@@ -17222,14 +17154,13 @@ in
 
   lkproof = callPackage ../tools/typesetting/tex/lkproof { };
 
-  m3d-linux = callPackage ../misc/drivers/m3d-linux { };
+  m33-linux = callPackage ../misc/drivers/m33-linux { };
 
   mnemonicode = callPackage ../misc/mnemonicode { };
 
   mysqlWorkbench = newScope gnome ../applications/misc/mysql-workbench {
     lua = lua5_1;
     libctemplate = libctemplate_2_2;
-    inherit (pythonPackages) pexpect paramiko;
   };
 
   redis-desktop-manager = qt55.callPackage ../applications/misc/redis-desktop-manager { };
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 37d1be553e0c2..b064618520abe 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -240,8 +240,7 @@ in modules // {
 
   pyatspi = if isPy3k then callPackage ../development/python-modules/pyatspi { } else throw "pyatspi not supported for interpreter ${python.executable}";
 
-  pycairo = callPackage ../development/python-modules/pycairo {
-  };
+  pycairo = callPackage ../development/python-modules/pycairo { };
 
   pycangjie = if isPy3k then callPackage ../development/python-modules/pycangjie { } else throw "pycangjie not supported for interpreter ${python.executable}";
 
@@ -1941,7 +1940,7 @@ in modules // {
       sha256 = "0grid93yz6i6jb2zggrqncp5awdf7qi88j5y2k7dq0k9r6b8zydw";
     };
 
-    propagatedBuildInputs = with stdenv.lib; with pkgs; [ modules.curses zlib xz ncompress gzip bzip2 gnutar p7zip cabextract lzma pycrypto ]
+    propagatedBuildInputs = with stdenv.lib; with pkgs; [ modules.curses zlib xz ncompress gzip bzip2 gnutar p7zip cabextract lzma self.pycrypto ]
       ++ optional visualizationSupport [ pyqtgraph ];
 
     meta = with stdenv.lib; {
@@ -4338,12 +4337,12 @@ in modules // {
 
 
   pkginfo = buildPythonPackage rec {
-    version = "1.2.1";
+    version = "1.3.2";
     name = "pkginfo-${version}";
 
     src = pkgs.fetchurl {
       url = "mirror://pypi/p/pkginfo/${name}.tar.gz";
-      sha256 = "0g0g6avplfqw1adzqybbrh1a2z0kfjl8qn3annkrc7w3ibz6sgxd";
+      sha256 = "0qg4sq3m0pxvjahc3sncwhw42z5rfw22k0ybskmdqkl2agykay7q";
     };
 
     doCheck = false; # I don't know why, but with doCheck = true it fails.
@@ -5753,10 +5752,6 @@ in modules // {
       sha256 = "1ikj72kd4cdcq7pmmcd5p6s9dvp7wi0zw01635v4xzkid5vi598f";
     };
 
-    preConfigure = ''
-      substituteInPlace test-requirements.txt --replace 'nose==1.3' 'nose'
-    '';
-
     doCheck = !isPy3k;  # lots of transient failures
     checkPhase = ''
       # Not worth the trouble
@@ -5769,7 +5764,6 @@ in modules // {
       nosetests -v --cover-min-percentage 1
     '';
 
-
     buildInputs = with self; [ coverage tornado mock nose ];
 
     meta = {
@@ -7744,7 +7738,7 @@ in modules // {
       sha256 = "00e3f89f4e23a844844d082918a89c2cbb1e8231ecb011b81d592e7e3c33a74c";
     };
 
-    propagatedBuildInputs = [ pkgs.pyqt4 pkgs.pkgconfig pkgs.poppler_qt4 ];
+    propagatedBuildInputs = [ self.pyqt4 pkgs.pkgconfig pkgs.poppler_qt4 ];
 
     preBuild = "${python}/bin/${python.executable} setup.py build_ext" +
                " --include-dirs=${pkgs.poppler_qt4.dev}/include/poppler/";
@@ -10124,11 +10118,11 @@ in modules // {
 
   flask_assets = buildPythonPackage rec {
     name = "Flask-Assets-${version}";
-    version = "0.10";
+    version = "0.11";
 
     src = pkgs.fetchurl {
       url = "mirror://pypi/F/Flask-Assets/${name}.tar.gz";
-      sha256 = "1v6ika3ias21xzhg7kglki99nwfx1i33rdhnw9kdqbwxkpwbwkyl";
+      sha256 = "1vs59gygwhwqj37if8hiw6vd2rns09xkblaz4qkmpp6hpy3shrvf";
     };
 
     propagatedBuildInputs = with self; [ flask webassets flask_script nose ];
@@ -10137,7 +10131,6 @@ in modules // {
       homepage = http://github.com/miracle2k/flask-assets;
       description = "Asset management for Flask, to compress and merge CSS and Javascript files";
       license = licenses.bsd2;
-      platforms = platforms.all;
       maintainers = with maintainers; [ abbradar ];
     };
   };
@@ -10836,7 +10829,7 @@ in modules // {
     # FAIL: test_sanitize_remove_src_javascript (genshi.filters.tests.html.HTMLSanitizerTestCase)
     doCheck = false;
 
-    buildInputs = with self; [ pkgs.setuptools ];
+    buildInputs = with self; [ setuptools ];
 
     meta = {
       description = "Python components for parsing HTML, XML and other textual content";
@@ -10930,7 +10923,7 @@ in modules // {
       sha256 = "c77d007cc32cdff836ecf8df6192371767976c108a75b055e057bb6f4a09cd42";
     };
 
-    buildInputs = with self; [ pkgs.setuptools ] ++ (optional isPy26 argparse);
+    buildInputs = with self; [ setuptools ] ++ (optional isPy26 argparse);
 
     meta = {
       description = "Automatically generated zsh completion function for Python's option parser modules";
@@ -14849,6 +14842,39 @@ in modules // {
     };
   };
 
+  dynd = buildPythonPackage rec {
+    version = "0.7.2";
+    name = "dynd-${version}";
+    disabled = isPyPy;
+
+    src = pkgs.fetchFromGitHub {
+      owner = "libdynd";
+      repo = "dynd-python";
+      rev = "v${version}";
+      sha256 = "19igd6ibf9araqhq9bxmzbzdz05vp089zxvddkiik3b5gb7l17nh";
+    };
+
+    # setup.py invokes git on build but we're fetching a tarball, so
+    # can't retrieve git version. We hardcode:
+    preConfigure = ''
+      substituteInPlace setup.py --replace "ver = check_output(['git', 'describe', '--dirty'," "ver = '${version}'"
+      substituteInPlace setup.py --replace "'--always', '--match', 'v*']).decode('ascii').strip('\n')" ""
+    '';
+
+    # Python 3 works but has a broken import test that I couldn't
+    # figure out.
+    doCheck = !isPy3k;
+    buildInputs = with pkgs; [ cmake libdynd.dev self.cython ];
+    propagatedBuildInputs = with self; [ numpy pkgs.libdynd ];
+
+    meta = {
+      homepage = http://libdynd.org;
+      license = licenses.bsd2;
+      description = "Python exposure of dynd";
+      maintainers = with maintainers; [ teh ];
+    };
+  };
+
   livestreamer = buildPythonPackage rec {
     version = "1.12.2";
     name = "livestreamer-${version}";
@@ -17796,17 +17822,13 @@ in modules // {
 
   psutil = buildPythonPackage rec {
     name = "psutil-${version}";
-    version = "3.4.2";
+    version = "4.3.0";
 
     src = pkgs.fetchurl {
       url = "mirror://pypi/p/psutil/${name}.tar.gz";
-      sha256 = "b17fa01aa766daa388362d0eda5c215d77e03a8d37676b68971f37bf3913b725";
+      sha256 = "1w4r09fvn6kd80m5mx4ws1wz100brkaq6hzzpwrns8cgjzjpl6c6";
     };
 
-    # Certain tests fail due to being in a chroot.
-    # See also the older issue: https://code.google.com/p/psutil/issues/detail?id=434
-    doCheck = false;
-
     buildInputs = with self; [ mock ] ++ optionals stdenv.isDarwin [ pkgs.darwin.IOKit ];
 
     meta = {
@@ -18146,11 +18168,11 @@ in modules // {
 
 
   Babel = buildPythonPackage (rec {
-    name = "Babel-2.2.0";
+    name = "Babel-2.3.4";
 
     src = pkgs.fetchurl {
       url = "mirror://pypi/B/Babel/${name}.tar.gz";
-      sha256 = "d8cb4c0e78148aee89560f9fe21587aa57739c975bb89ff66b1e842cc697428f";
+      sha256 = "0x98qqqw35xllpcama013a9788ly84z8dm1w2wwfpxh2710c8df5";
     };
 
     buildInputs = with self; [ pytest ];
@@ -20296,14 +20318,14 @@ in modules // {
 
   requests2 = buildPythonPackage rec {
     name = "requests-${version}";
-    version = "2.9.1";
+    version = "2.11.0";
 
     src = pkgs.fetchurl {
       url = "mirror://pypi/r/requests/${name}.tar.gz";
-      sha256 = "0zsqrzlybf25xscgi7ja4s48y2abf9wvjkn47wh984qgs1fq2xy5";
+      sha256 = "11d3vrbiqrz30qbplv80y72y9i47hihs35p5n04fl4ggjcz0bzxj";
     };
 
-    buildInputs = [ self.pytest ];
+    nativeBuildInputs = [ self.pytest ];
     # sadly, tests require networking
     doCheck = false;
 
@@ -20376,11 +20398,11 @@ in modules // {
 
       src = pkgs.qscintilla.src;
 
-      buildInputs = with pkgs; [ xorg.lndir qt4 pyqt4 python ];
+      buildInputs = with self; [ pkgs.xorg.lndir pyqt4.qt pyqt4 python ];
 
       preConfigure = ''
         mkdir -p $out
-        lndir ${pkgs.pyqt4} $out
+        lndir ${self.pyqt4} $out
         cd Python
         ${python.executable} ./configure-old.py \
             --destdir $out/lib/${python.libPrefix}/site-packages/PyQt4 \
@@ -20712,7 +20734,7 @@ in modules // {
 
     doCheck = false;  # too much
 
-    buildInputs = with self; [ mock tox pkgs.pylint ];
+    buildInputs = with self; [ mock tox pylint ];
     meta = with stdenv.lib; {
       homepage = "https://github.com/geopy/geopy";
     };
@@ -21027,7 +21049,7 @@ in modules // {
     patches = [ ../development/python-modules/rpkg-buildfix.diff ];
 
     propagatedBuildInputs = with self; [ pycurl pkgs.koji GitPython pkgs.git
-                              pkgs.rpm pkgs.pyopenssl ];
+                              pkgs.rpm pyopenssl ];
 
   });
 
@@ -21073,22 +21095,18 @@ in modules // {
 
   rsa = buildPythonPackage rec {
     name = "rsa-${version}";
-    version = "3.3";
+    version = "3.4.2";
 
     src = pkgs.fetchurl {
       url = "mirror://pypi/r/rsa/${name}.tar.gz";
-      sha256 = "03f3d9bebad06681771016b8752a40b12f615ff32363c7aa19b3798e73ccd615";
+      sha256 = "1dcxvszbikgzh99ybdc7jq0zb9wspy2ds8z9mjsqiyv3q884xpr5";
     };
 
     nativeBuildInputs = with self; [ unittest2 ];
     propagatedBuildInputs = with self; [ pyasn1 ];
 
-    checkPhase = ''
-      ${python.interpreter} run_tests.py
-    '';
-
     meta = {
-      homepage = http://stuvel.eu/rsa;
+      homepage = "http://stuvel.eu/rsa";
       license = licenses.asl20;
       description = "A pure-Python RSA implementation";
     };
@@ -21361,7 +21379,7 @@ in modules // {
       sha256 = "768e568f3299966c294b7eb8cd114fc648f7bfaef422ee9cc750dd8d9d09e44b";
     };
 
-    buildInputs = with self; [ pkgs.cython nose numpy six ];
+    buildInputs = with self; [ cython nose numpy six ];
 
     propagatedBuildInputs = with self; [ pillow matplotlib networkx scipy ];
 
@@ -22835,7 +22853,7 @@ in modules // {
       sha256 = "00z0lzjs4ksr9yr31zs26csyacjvavhpz6r74xaw1r89kk75qg7q";
     };
 
-    buildInputs = with self; [ unittest2 scripttest pytz pkgs.pylint tempest-lib mock testtools ];
+    buildInputs = with self; [ unittest2 scripttest pytz pylint tempest-lib mock testtools ];
     propagatedBuildInputs = with self; [ pbr tempita decorator sqlalchemy six sqlparse ];
 
     checkPhase = ''
@@ -23705,7 +23723,7 @@ in modules // {
 
     PYTHON_EGG_CACHE = "`pwd`/.egg-cache";
 
-    propagatedBuildInputs = with self; [ genshi pkgs.setuptools modules.sqlite3 ];
+    propagatedBuildInputs = with self; [ genshi setuptools modules.sqlite3 ];
 
     meta = {
       description = "Enhanced wiki and issue tracking system for software development projects";
@@ -24640,21 +24658,20 @@ in modules // {
 
 
   werkzeug = buildPythonPackage rec {
-    name = "Werkzeug-0.10.4";
+    name = "Werkzeug-0.11.10";
 
     src = pkgs.fetchurl {
       url = "mirror://pypi/W/Werkzeug/${name}.tar.gz";
-      sha256 = "9d2771e4c89be127bc4bac056ab7ceaf0e0064c723d6b6e195739c3af4fd5c1d";
+      sha256 = "1vpf98k4jp4yhbv2jbyq8dj5fdasrd26rkq34pacs5n7mkxxlr6c";
     };
 
     propagatedBuildInputs = with self; [ itsdangerous ];
-
-    doCheck = false;            # tests fail, not sure why
+    nativeBuildInputs = with self; [ pytest requests ];
 
     meta = {
       homepage = http://werkzeug.pocoo.org/;
       description = "A WSGI utility library for Python";
-      license = "BSD";
+      license = licenses.bsd3;
     };
   };
 
@@ -26219,7 +26236,7 @@ in modules // {
       sha256 = "472a4403fd5b5364939aee10e78f171b1489e5f6bfe6f150ed9cae8476410114";
     };
 
-    propagatedBuildInputs = with self; [ django_1_5 django_tagging modules.sqlite3 whisper pkgs.pycairo ldap memcached ];
+    propagatedBuildInputs = with self; [ django_1_5 django_tagging modules.sqlite3 whisper pycairo ldap memcached ];
 
     postInstall = ''
       wrapProgram $out/bin/run-graphite-devel-server.py \
@@ -26592,11 +26609,11 @@ in modules // {
   };
 
   flaskbabel = buildPythonPackage rec {
-    name = "Flask-Babel-0.9";
+    name = "Flask-Babel-0.11.1";
 
     src = pkgs.fetchurl {
       url = "mirror://pypi/F/Flask-Babel/${name}.tar.gz";
-      sha256 = "0k7vk4k54y55ma0nx2k5s0phfqbriwslhy5shh3b0d046q7ibzaa";
+      sha256 = "16b80cipdba9xj3jlaiaq6wgrgpjb70w3j01jjy9hbp4k71kd6yj";
     };
 
     propagatedBuildInputs = with self; [ flask jinja2 speaklater Babel pytz ];
@@ -26893,7 +26910,7 @@ in modules // {
       url = mirror://pypi/g/gcs-oauth2-boto-plugin/gcs-oauth2-boto-plugin-1.8.tar.gz;
       sha256 = "0jy62y5bmaf1mb735lqwry1s5nx2qqrxvl5sxip9yg4miih3qkyb";
     };
-    propagatedBuildInputs = with self; [ boto-230 httplib2 google_api_python_client retry_decorator pkgs.pyopenssl socksipy-branch ];
+    propagatedBuildInputs = with self; [ boto-230 httplib2 google_api_python_client retry_decorator pyopenssl socksipy-branch ];
     meta = {
       homepage = https://developers.google.com/storage/docs/gspythonlibrary;
       description = "Provides OAuth 2.0 credentials that can be used with Google Cloud Storage";
@@ -26918,7 +26935,7 @@ in modules // {
     };
 
     propagatedBuildInputs = with self; [ boto-230 crcmod httplib2 gcs-oauth2-boto-plugin google_api_python_client gflags
-                                         retry_decorator pkgs.pyopenssl socksipy-branch crcmod ];
+                                         retry_decorator pyopenssl socksipy-branch crcmod ];
   };
 
   svg2tikz = self.buildPythonPackage {