about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/applications/audio/sisco.lv2/default.nix2
-rw-r--r--pkgs/applications/graphics/feh/default.nix4
-rw-r--r--pkgs/applications/misc/buku/default.nix33
-rw-r--r--pkgs/applications/misc/krusader/default.nix4
-rw-r--r--pkgs/applications/networking/browsers/firefox/wrapper.nix3
-rw-r--r--pkgs/applications/networking/browsers/qutebrowser/default.nix8
-rw-r--r--pkgs/applications/networking/corebird/default.nix4
-rw-r--r--pkgs/applications/science/logic/poly/default.nix22
-rw-r--r--pkgs/applications/science/logic/yices/default.nix16
-rw-r--r--pkgs/build-support/cc-wrapper/default.nix18
-rw-r--r--pkgs/build-support/cc-wrapper/expand-response-params.c84
-rw-r--r--pkgs/build-support/cc-wrapper/utils.sh56
-rw-r--r--pkgs/build-support/fetchgit/gitrepotoname.nix19
-rwxr-xr-xpkgs/build-support/fetchgit/nix-prefetch-git4
-rw-r--r--pkgs/development/beam-modules/default.nix22
-rw-r--r--pkgs/development/beam-modules/lib.nix31
-rw-r--r--pkgs/development/compilers/llvm/4/clang/default.nix2
-rw-r--r--pkgs/development/compilers/llvm/4/default.nix6
-rw-r--r--pkgs/development/compilers/llvm/4/libc++/default.nix2
-rw-r--r--pkgs/development/compilers/llvm/4/libc++abi.nix2
-rw-r--r--pkgs/development/compilers/llvm/4/lld.nix2
-rw-r--r--pkgs/development/compilers/llvm/4/lldb.nix2
-rw-r--r--pkgs/development/compilers/llvm/4/llvm.nix9
-rw-r--r--pkgs/development/compilers/llvm/4/openmp.nix2
-rw-r--r--pkgs/development/compilers/swift/patches/build-script-pax.patch3
-rw-r--r--pkgs/development/interpreters/elixir/1.3.nix7
-rw-r--r--pkgs/development/interpreters/elixir/1.4.nix7
-rw-r--r--pkgs/development/interpreters/elixir/1.5.nix7
-rw-r--r--pkgs/development/interpreters/elixir/default.nix71
-rw-r--r--pkgs/development/interpreters/elixir/generic-builder.nix77
-rw-r--r--pkgs/development/interpreters/ruby/default.nix2
-rw-r--r--pkgs/development/libraries/aws-sdk-cpp/default.nix1
-rw-r--r--pkgs/development/libraries/boehm-gc/default.nix1
-rw-r--r--pkgs/development/libraries/glibc/common.nix3
-rw-r--r--pkgs/development/libraries/glibc/fix-x64-abi.patch35
-rw-r--r--pkgs/development/libraries/gnutls/3.5.nix4
-rw-r--r--pkgs/development/libraries/libsodium/default.nix1
-rw-r--r--pkgs/development/libraries/ncurses/default.nix3
-rw-r--r--pkgs/development/libraries/openssl/default.nix1
-rw-r--r--pkgs/development/libraries/sqlite/default.nix1
-rw-r--r--pkgs/development/tools/continuous-integration/gitlab-runner/v1.nix8
-rw-r--r--pkgs/development/tools/parsing/re2c/default.nix16
-rw-r--r--pkgs/misc/emulators/dolphin-emu/master.nix28
-rw-r--r--pkgs/misc/emulators/wine/base.nix1
-rw-r--r--pkgs/os-specific/darwin/ios-cross/default.nix6
-rw-r--r--pkgs/servers/caddy/default.nix8
-rw-r--r--pkgs/servers/caddy/deps.nix201
-rw-r--r--pkgs/servers/mail/postfix/pfixtools.nix2
-rw-r--r--pkgs/shells/ion/default.nix25
-rw-r--r--pkgs/stdenv/darwin/default.nix20
-rw-r--r--pkgs/stdenv/generic/setup.sh12
-rw-r--r--pkgs/stdenv/linux/default.nix10
-rw-r--r--pkgs/tools/archivers/unzip/default.nix2
-rw-r--r--pkgs/tools/audio/ezstream/default.nix33
-rw-r--r--pkgs/tools/filesystems/btrfs-progs/default.nix4
-rw-r--r--pkgs/tools/misc/kronometer/default.nix4
-rw-r--r--pkgs/tools/misc/partition-manager/default.nix4
-rw-r--r--pkgs/tools/misc/peruse/default.nix4
-rw-r--r--pkgs/tools/networking/curl/default.nix1
-rw-r--r--pkgs/tools/networking/email/default.nix2
-rw-r--r--pkgs/tools/networking/network-manager/default.nix4
-rw-r--r--pkgs/tools/networking/network-manager/modprobe.patch11
-rw-r--r--pkgs/tools/package-management/gx/default.nix13
-rw-r--r--pkgs/tools/package-management/gx/deps.nix286
-rw-r--r--pkgs/tools/package-management/gx/go/default.nix6
-rw-r--r--pkgs/tools/security/sshuttle/default.nix17
-rw-r--r--pkgs/tools/text/groff/default.nix7
-rw-r--r--pkgs/tools/text/groff/site.tmac16
-rw-r--r--pkgs/top-level/all-packages.nix30
-rw-r--r--pkgs/top-level/beam-packages.nix3
-rw-r--r--pkgs/top-level/lua-packages.nix14
71 files changed, 846 insertions, 533 deletions
diff --git a/pkgs/applications/audio/sisco.lv2/default.nix b/pkgs/applications/audio/sisco.lv2/default.nix
index d429d5452345..8ac7a9115ca8 100644
--- a/pkgs/applications/audio/sisco.lv2/default.nix
+++ b/pkgs/applications/audio/sisco.lv2/default.nix
@@ -25,7 +25,7 @@ stdenv.mkDerivation rec {
   inherit name;
 
   srcs = [ src robtkSrc ];
-  sourceRoot = "sisco.lv2-${src.rev}-src";
+  sourceRoot = src.name;
 
   buildInputs = [ pkgconfig lv2 pango cairo libjack2 mesa ];
 
diff --git a/pkgs/applications/graphics/feh/default.nix b/pkgs/applications/graphics/feh/default.nix
index b7949b4d4f97..5de8e7892abe 100644
--- a/pkgs/applications/graphics/feh/default.nix
+++ b/pkgs/applications/graphics/feh/default.nix
@@ -6,11 +6,11 @@ with stdenv.lib;
 
 stdenv.mkDerivation rec {
   name = "feh-${version}";
-  version = "2.18.2";
+  version = "2.19";
 
   src = fetchurl {
     url = "http://feh.finalrewind.org/${name}.tar.bz2";
-    sha256 = "09f5rfzls4h5jcrp7ylwbiljp5qzc2nbw9p2csv0pnlaixj69gil";
+    sha256 = "1sfhr6628xpj9p6bqihdq35y139x2gmrpydjlrwsl1rs77c2bgnf";
   };
 
   outputs = [ "out" "man" "doc" ];
diff --git a/pkgs/applications/misc/buku/default.nix b/pkgs/applications/misc/buku/default.nix
index 72ba96ad701f..ea3ca107d24d 100644
--- a/pkgs/applications/misc/buku/default.nix
+++ b/pkgs/applications/misc/buku/default.nix
@@ -1,8 +1,7 @@
-{ stdenv, pythonPackages, fetchFromGitHub,
-}:
+{ stdenv, pythonPackages, fetchFromGitHub }:
 
 with pythonPackages; buildPythonApplication rec {
-  version = "3.0";
+  version = "3.0"; # When updating to 3.1, make sure to remove the marked line in preCheck
   name = "buku-${version}";
 
   src = fetchFromGitHub {
@@ -12,6 +11,13 @@ with pythonPackages; buildPythonApplication rec {
     sha256 = "1a33x3197vi5s8rq5fvhy021jdlsc8ww8zc4kysss6r9mvdlk7ax";
   };
 
+  nativeBuildInputs = [
+    pytestcov
+    pytest-catchlog
+    hypothesis
+    pytest
+  ];
+
   propagatedBuildInputs = [
     cryptography
     beautifulsoup4
@@ -19,13 +25,28 @@ with pythonPackages; buildPythonApplication rec {
     urllib3
   ];
 
-  phases = [ "unpackPhase" "installPhase" "fixupPhase" ];
+  preCheck = ''
+    # Fixes two tests for wrong encoding
+    export PYTHONIOENCODING=utf-8
+
+    ### Remove this for 3.1 ###
+    # See https://github.com/jarun/Buku/pull/167 (merged)
+    substituteInPlace setup.py \
+      --replace "hypothesis==3.7.0" "hypothesis>=3.7.0"
+
+    # Disables a test which requires internet
+    substituteInPlace tests/test_bukuDb.py \
+      --replace "@pytest.mark.slowtest" "@unittest.skip('skipping')"
+  '';
 
   installPhase = ''
     make install PREFIX=$out
-  '';
 
-  doCheck = false;
+    mkdir -p $out/share/zsh/site-functions $out/share/bash-completion/completions $out/share/fish/vendor_completions.d
+    cp auto-completion/zsh/* $out/share/zsh/site-functions
+    cp auto-completion/bash/* $out/share/bash-completion/completions
+    cp auto-completion/fish/* $out/share/fish/vendor_completions.d
+  '';
 
   meta = with stdenv.lib; {
     description = "Private cmdline bookmark manager";
diff --git a/pkgs/applications/misc/krusader/default.nix b/pkgs/applications/misc/krusader/default.nix
index 7f5dad62d264..bcf351ff46ae 100644
--- a/pkgs/applications/misc/krusader/default.nix
+++ b/pkgs/applications/misc/krusader/default.nix
@@ -1,7 +1,7 @@
 {
   mkDerivation, fetchurl, lib,
   extra-cmake-modules, kdoctools, wrapGAppsHook,
-  kconfig, kinit, kparts
+  karchive, kconfig, kcrash, kguiaddons, kinit, kparts, kwindowsystem
 }:
 
 let
@@ -23,5 +23,5 @@ in mkDerivation rec {
   };
 
   nativeBuildInputs = [ extra-cmake-modules kdoctools wrapGAppsHook ];
-  propagatedBuildInputs = [ kconfig kinit kparts ];
+  propagatedBuildInputs = [ karchive kconfig kcrash kguiaddons kinit kparts kwindowsystem ];
 }
diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix
index cffdfa7a97dd..1dd5c9191f00 100644
--- a/pkgs/applications/networking/browsers/firefox/wrapper.nix
+++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix
@@ -8,6 +8,7 @@
 , google_talk_plugin, fribid, gnome3/*.gnome_shell*/
 , esteidfirefoxplugin
 , vlc_npapi
+, libudev
 }:
 
 ## configurability of the wrapper itself
@@ -46,7 +47,7 @@ let
      );
   libs = (if ffmpegSupport then [ ffmpeg ] else with gst_all; [ gstreamer gst-plugins-base ])
          ++ lib.optionals (cfg.enableQuakeLive or false)
-         (with xorg; [ stdenv.cc libX11 libXxf86dga libXxf86vm libXext libXt alsaLib zlib ])
+         (with xorg; [ stdenv.cc libX11 libXxf86dga libXxf86vm libXext libXt alsaLib zlib libudev ])
          ++ lib.optional (enableAdobeFlash && (cfg.enableAdobeFlashDRM or false)) hal-flash
          ++ lib.optional (config.pulseaudio or false) libpulseaudio;
   gst-plugins = with gst_all; [ gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-ffmpeg ];
diff --git a/pkgs/applications/networking/browsers/qutebrowser/default.nix b/pkgs/applications/networking/browsers/qutebrowser/default.nix
index 614473d39eec..5ec4340dba78 100644
--- a/pkgs/applications/networking/browsers/qutebrowser/default.nix
+++ b/pkgs/applications/networking/browsers/qutebrowser/default.nix
@@ -1,5 +1,5 @@
 { stdenv, lib, fetchurl, unzip, buildPythonApplication, makeWrapper, wrapGAppsHook
-, qtbase, pyqt5, jinja2, pygments, pyyaml, pypeg2, cssutils, glib_networking
+, qtbase, pyqt5, jinja2, pygments, pyyaml, pypeg2, pyopengl, cssutils, 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
 , qtwebkit-plugins
@@ -26,12 +26,12 @@ let
 
 in buildPythonApplication rec {
   name = "qutebrowser-${version}";
-  version = "0.10.1";
+  version = "0.11.0";
   namePrefix = "";
 
   src = fetchurl {
     url = "https://github.com/The-Compiler/qutebrowser/releases/download/v${version}/${name}.tar.gz";
-    sha256 = "57f4915f0f2b1509f3aa1cb9c47117fdaad35b4c895e9223c4eb0a6e8af51917";
+    sha256 = "13ihx66jm1dd6vx8px7pm0kbzf2sf9x43hhivc1rp17kahnxxdyv";
   };
 
   # Needs tox
@@ -48,7 +48,7 @@ in buildPythonApplication rec {
   ];
 
   propagatedBuildInputs = [
-    pyyaml pyqt5 jinja2 pygments pypeg2 cssutils
+    pyyaml pyqt5 jinja2 pygments pypeg2 cssutils pyopengl
   ];
 
   postPatch = ''
diff --git a/pkgs/applications/networking/corebird/default.nix b/pkgs/applications/networking/corebird/default.nix
index 7b67ad235e3a..86a93309b1f6 100644
--- a/pkgs/applications/networking/corebird/default.nix
+++ b/pkgs/applications/networking/corebird/default.nix
@@ -3,14 +3,14 @@
 , glib_networking }:
 
 stdenv.mkDerivation rec {
-  version = "1.5";
+  version = "1.5.1";
   name = "corebird-${version}";
 
   src = fetchFromGitHub {
     owner = "baedert";
     repo = "corebird";
     rev = version;
-    sha256 = "0nll3ns1riylxg33w6myz5x8h6ai39k5fw2bkf96g5rgmi6zsjma";
+    sha256 = "1qajb4xms3vsfm5sg91z9ka0nrzgfi0fjgjxqm7snhkfgxlkph7w";
   };
 
   preConfigure = ''
diff --git a/pkgs/applications/science/logic/poly/default.nix b/pkgs/applications/science/logic/poly/default.nix
new file mode 100644
index 000000000000..2fdbd87a275c
--- /dev/null
+++ b/pkgs/applications/science/logic/poly/default.nix
@@ -0,0 +1,22 @@
+{stdenv, fetchurl, gmp, cmake, python}:
+
+let version = "0.1.3";
+in
+
+stdenv.mkDerivation {
+  name = "libpoly-${version}";
+
+  src = fetchurl {
+    url = "https://github.com/SRI-CSL/libpoly/archive/v${version}.tar.gz";
+    sha256 = "0nd90585imnznyp04vg6a5ixxkd3bavhv1437397aj2k3dfc0y2k";
+  };
+
+  buildInputs = [ cmake gmp python ];
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/SRI-CSL/libpoly;
+    description = "C library for manipulating polynomials";
+    license = licenses.lgpl3;
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/applications/science/logic/yices/default.nix b/pkgs/applications/science/logic/yices/default.nix
index cf5114b4a417..0ec7f93d26f5 100644
--- a/pkgs/applications/science/logic/yices/default.nix
+++ b/pkgs/applications/science/logic/yices/default.nix
@@ -1,12 +1,12 @@
-{ stdenv, fetchurl, gmp-static, gperf, autoreconfHook }:
+{ stdenv, fetchurl, gmp-static, gperf, autoreconfHook, libpoly }:
 
 stdenv.mkDerivation rec {
   name    = "yices-${version}";
   version = "2.5.1";
 
   src = fetchurl {
-    url = "http://yices.csl.sri.com/cgi-bin/yices2-newnewdownload.cgi?file=yices-${version}-src.tar.gz&accept=I+Agree";
-    name = "yices-${version}-src.tar.gz";
+    url = "http://yices.csl.sri.com/cgi-bin/yices2-newnewdownload.cgi?file=${name}-src.tar.gz&accept=I+Agree";
+    name = "${name}-src.tar.gz";
     sha256 = "1wfq6hcm54h0mqmbs1ip63i0ywlwnciav86sbzk3gafxyzg1nd0c";
   };
 
@@ -14,13 +14,19 @@ stdenv.mkDerivation rec {
 
   configureFlags = [ "--with-static-gmp=${gmp-static.out}/lib/libgmp.a"
                      "--with-static-gmp-include-dir=${gmp-static.dev}/include"
+                     "--enable-mcsat"
                    ];
-  buildInputs = [ gmp-static gperf autoreconfHook ];
+  buildInputs = [ gmp-static gperf autoreconfHook libpoly ];
 
   enableParallelBuilding = true;
   doCheck = true;
 
-  installPhase = ''make install LDCONFIG=true'';
+  # Includes a fix for the embedded soname being libyices.so.2.5, but
+  # only installing the libyices.so.2.5.1 file.
+  installPhase = ''
+      make install LDCONFIG=true
+      (cd $out/lib && ln -s -f libyices.so.2.5.1 libyices.so.2.5)
+  '';
 
   meta = with stdenv.lib; {
     description = "A high-performance theorem prover and SMT solver";
diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix
index e6576e5a3894..676fbd006881 100644
--- a/pkgs/build-support/cc-wrapper/default.nix
+++ b/pkgs/build-support/cc-wrapper/default.nix
@@ -10,6 +10,7 @@
 , zlib ? null, extraPackages ? [], extraBuildCommands ? ""
 , dyld ? null # TODO: should this be a setup-hook on dyld?
 , isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
+, buildPackages ? {}, hostPlatform, targetPlatform
 , runCommand ? null
 }:
 
@@ -121,6 +122,17 @@ let
          null)
     else "";
 
+  expand-response-params = if buildPackages.stdenv.cc or null != null && buildPackages.stdenv.cc != "/dev/null"
+  then buildPackages.stdenv.mkDerivation {
+    name = "expand-response-params";
+    src = ./expand-response-params.c;
+    buildCommand = ''
+      # Work around "stdenv-darwin-boot-2 is not allowed to refer to path /nix/store/...-expand-response-params.c"
+      cp "$src" expand-response-params.c
+      "$CC" -std=c99 -O3 -o "$out" expand-response-params.c
+    '';
+  } else "";
+
 in
 
 stdenv.mkDerivation {
@@ -369,11 +381,13 @@ stdenv.mkDerivation {
     + ''
       substituteAll ${preWrap ./add-flags.sh} $out/nix-support/add-flags.sh
       substituteAll ${preWrap ./add-hardening.sh} $out/nix-support/add-hardening.sh
-      cp -p ${preWrap ./utils.sh} $out/nix-support/utils.sh
+      substituteAll ${preWrap ./utils.sh} $out/nix-support/utils.sh
     ''
     + extraBuildCommands;
 
-  inherit dynamicLinker;
+  inherit dynamicLinker expand-response-params;
+
+  expandResponseParams = expand-response-params; # for substitution in utils.sh
 
   crossAttrs = {
     shell = shell.crossDrv + shell.crossDrv.shellPath;
diff --git a/pkgs/build-support/cc-wrapper/expand-response-params.c b/pkgs/build-support/cc-wrapper/expand-response-params.c
new file mode 100644
index 000000000000..05b9c62b1e8d
--- /dev/null
+++ b/pkgs/build-support/cc-wrapper/expand-response-params.c
@@ -0,0 +1,84 @@
+#include <assert.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct { char *data; size_t len, cap; } String;
+
+void resize(String *s, size_t len) {
+    s->len = len;
+    if (s->cap < s->len) {
+        s->cap = s->len * 2;
+        s->data = (char *)realloc(s->data, s->cap);
+        assert(s->data);
+    }
+}
+
+void append(String *s, const char *data, size_t len) {
+    resize(s, s->len + len);
+    memcpy(s->data + s->len - len, data, len);
+}
+
+typedef enum { space = 0, other = 1, backslash = 2, apostrophe = 3, quotation_mark = 4 } CharClass;
+typedef enum { outside, unq, unq_esc, sq, sq_esc, dq, dq_esc } State;
+
+// current State -> CharClass -> next State
+const State transitions[][5] = {
+    [outside] = {outside, unq, unq_esc, sq,  dq},
+    [unq]     = {outside, unq, unq_esc, sq,  dq},
+    [unq_esc] = {unq,     unq, unq,     unq, unq},
+    [sq]      = {sq,      sq,  sq_esc,  unq, sq},
+    [sq_esc]  = {sq,      sq,  sq,      sq,  sq},
+    [dq]      = {dq,      dq,  dq_esc,  dq,  unq},
+    [dq_esc]  = {dq,      dq,  dq,      dq,  dq},
+};
+
+CharClass charClass(int c) {
+    return c == '\\' ? backslash : c == '\'' ? apostrophe : c == '"' ? quotation_mark :
+            isspace(c) ? space : other;
+}
+
+// expandArg writes NULL-terminated expansions of `arg', a NULL-terminated
+// string, to stdout.  If arg does not begin with `@' or does not refer to a
+// file, it is written as is.  Otherwise the contents of the file are
+// recursively expanded.  On unexpected EOF in malformed response files an
+// incomplete final argument is written, even if it is empty, to parse like GCC.
+void expandArg(String *arg) {
+    FILE *f;
+    if (arg->data[0] != '@' || !(f = fopen(&arg->data[1], "r"))) {
+        fwrite(arg->data, 1, arg->len, stdout);
+        return;
+    }
+
+    resize(arg, 0);
+    State cur = outside;
+    int c;
+    do {
+        c = fgetc(f);
+        State next = transitions[cur][charClass(c)];
+        if ((cur == unq && next == outside) || (cur != outside && c == EOF)) {
+            append(arg, "", 1);
+            expandArg(arg);
+            resize(arg, 0);
+        } else if (cur == unq_esc || cur == sq_esc || cur == dq_esc ||
+                   (cur == outside ? next == unq : cur == next)) {
+            char s = c;
+            append(arg, &s, 1);
+        }
+        cur = next;
+    } while (c != EOF);
+
+    fclose(f);
+}
+
+int main(int argc, char **argv) {
+    String arg = { 0 };
+    while (*++argv) {
+        resize(&arg, 0);
+        append(&arg, *argv, strlen(*argv) + 1);
+        expandArg(&arg);
+    }
+    free(arg.data);
+    return EXIT_SUCCESS;
+}
diff --git a/pkgs/build-support/cc-wrapper/utils.sh b/pkgs/build-support/cc-wrapper/utils.sh
index 8cefc47816f8..87e48da9c8d5 100644
--- a/pkgs/build-support/cc-wrapper/utils.sh
+++ b/pkgs/build-support/cc-wrapper/utils.sh
@@ -23,52 +23,18 @@ badPath() {
         "${p:0:${#NIX_BUILD_TOP}}" != "$NIX_BUILD_TOP"
 }
 
-# @args.rsp parser.
-# Char classes: space, other, backslash, single quote, double quote.
-# States: 0 - outside, 1/2 - unquoted arg/slash, 3/4 - 'arg'/slash, 5/6 - "arg"/slash.
-# State transitions:
-rspT=(01235 01235 11111 33413 33333 55651 55555)
-# Push (a) arg or (c) char on transition:
-rspP[10]=a rspP[01]=c rspP[11]=c rspP[21]=c rspP[33]=c rspP[43]=c rspP[55]=c rspP[65]=c
-
-rspParse() {
-    rsp=()
-    local state=0
-    local arg=''
-    local c
-
-    while read -r -N1 c; do
-        local cls=1
-        case "$c" in
-            ' ' | $'\t' | $'\r' | $'\n') cls=0 ;;
-            '\') cls=2 ;;
-            "'") cls=3 ;;
-            '"') cls=4 ;;
-        esac
-        local nextstates="${rspT[$state]}"
-        local nextstate="${nextstates:$cls:1}"
-        case "${rspP[$state$nextstate]}" in
-            'c') arg+="$c" ;;
-            'a') rsp+=("$arg"); arg='' ;;
-        esac
-        state="$nextstate"
-    done
-
-    if [ "$state" -ne 0 ]; then
-        rsp+=("$arg")
-    fi
-}
-
 expandResponseParams() {
-    params=()
-    while [ $# -gt 0 ]; do
-        local p="$1"
-        shift
-        if [ "${p:0:1}" = '@' -a -e "${p:1}" ]; then
-            rspParse <"${p:1}"
-            set -- "${rsp[@]}" "$@"
-        else
-            params+=("$p")
+    params=("$@")
+    local arg
+    for arg in "$@"; do
+        if [[ "$arg" == @* ]]; then
+            if [ -n "@expandResponseParams@" ]; then
+                readarray -d '' params < <("@expandResponseParams@" "$@")
+                return 0
+            else
+                echo "Response files aren't supported during bootstrapping" >&2
+                return 1
+            fi
         fi
     done
 }
diff --git a/pkgs/build-support/fetchgit/gitrepotoname.nix b/pkgs/build-support/fetchgit/gitrepotoname.nix
new file mode 100644
index 000000000000..90005b545692
--- /dev/null
+++ b/pkgs/build-support/fetchgit/gitrepotoname.nix
@@ -0,0 +1,19 @@
+{ lib }:
+
+let
+  inherit (lib) removeSuffix hasPrefix removePrefix splitString stringToCharacters concatMapStrings last elem;
+
+  allowedChars = stringToCharacters "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-._?=";
+  sanitizeStoreName = s:
+    let
+      s' = concatMapStrings (c: if elem c allowedChars then c else "") (stringToCharacters s);
+      s'' = if hasPrefix "." s' then "_${removePrefix "." s'}" else s';
+    in
+      s'';
+in
+  urlOrRepo: rev:
+    let
+      repo' = last (splitString ":" (baseNameOf (removeSuffix ".git" (removeSuffix "/" urlOrRepo))));
+      rev' = baseNameOf rev;
+    in
+     "${sanitizeStoreName repo'}-${sanitizeStoreName rev'}-src"
diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git
index fa66a1f55406..a180509a3265 100755
--- a/pkgs/build-support/fetchgit/nix-prefetch-git
+++ b/pkgs/build-support/fetchgit/nix-prefetch-git
@@ -283,8 +283,8 @@ _clone_user_rev() {
             if test -z "$(echo "$rev" | tr -d 0123456789abcdef)"; then
                 clone "$dir" "$url" "$rev" "" 1>&2
             else
-                echo 1>&2 "Bad commit hash or bad reference."
-                exit 1
+                # if revision is not hexadecimal it might be a tag
+                clone "$dir" "$url" "" "refs/tags/$rev" 1>&2
             fi;;
     esac
 
diff --git a/pkgs/development/beam-modules/default.nix b/pkgs/development/beam-modules/default.nix
index d1a2a785a9c9..f0a049bb4b23 100644
--- a/pkgs/development/beam-modules/default.nix
+++ b/pkgs/development/beam-modules/default.nix
@@ -16,7 +16,7 @@ let
     in
       import ./hex-packages.nix {
         inherit pkgs stdenv callPackage;
-      } // {
+      } // rec {
         inherit callPackage erlang;
         beamPackages = self;
 
@@ -37,9 +37,23 @@ let
         buildMix = callPackage ./build-mix.nix {};
 
         # BEAM-based languages.
-        elixir = if versionAtLeast (lib.getVersion erlang) "18"
-                 then callPackage ../interpreters/elixir { debugInfo = true; }
-                 else throw "Elixir requires at least Erlang/OTP R18.";
+        elixir = elixir_1_4;
+
+        elixir_1_5_rc = lib.callElixir ../interpreters/elixir/1.5.nix {
+                       inherit rebar erlang;
+                       debugInfo = true;
+                     };
+
+        elixir_1_4 = lib.callElixir ../interpreters/elixir/1.4.nix {
+                       inherit rebar erlang;
+                       debugInfo = true;
+                     };
+
+        elixir_1_3 = lib.callElixir ../interpreters/elixir/1.3.nix {
+                       inherit rebar erlang;
+                       debugInfo = true;
+                     };
+
         lfe = callPackage ../interpreters/lfe { };
 
         # Non hex packages
diff --git a/pkgs/development/beam-modules/lib.nix b/pkgs/development/beam-modules/lib.nix
index 009bfb4975b6..dd4ed5e1bbf8 100644
--- a/pkgs/development/beam-modules/lib.nix
+++ b/pkgs/development/beam-modules/lib.nix
@@ -12,15 +12,6 @@ rec {
 
   callPackage = callPackageWith pkgs;
 
-  /* Erlang/OTP-specific version retrieval, returns 19 for OTP R19 */
-  getVersion = x:
-   let
-     parse = drv: (builtins.parseDrvName drv).version;
-   in builtins.replaceStrings ["B" "-"] ["." "."] (
-      if builtins.isString x
-      then parse x
-      else x.version or (parse x.name));
-
   /* Uses generic-builder to evaluate provided drv containing OTP-version
   specific data.
 
@@ -43,4 +34,26 @@ rec {
         mkDerivation = pkgs.makeOverridable builder;
       };
 
+  /* Uses generic-builder to evaluate provided drv containing Elixir version
+  specific data.
+
+  drv: package containing version-specific args;
+  builder: generic builder for all Erlang versions;
+  args: arguments merged into version-specific args, used mostly to customize
+        dependencies;
+
+  Arguments passed to the generic-builder are overridable.
+
+  Please note that "mkDerivation" defined here is the one called from 1.4.nix
+  and similar files.
+  */
+  callElixir = drv: args:
+    let
+      inherit (stdenv.lib) versionAtLeast;
+      builder = callPackage ../interpreters/elixir/generic-builder.nix args;
+    in
+      callPackage drv {
+        mkDerivation = pkgs.makeOverridable builder;
+      };
+
 }
diff --git a/pkgs/development/compilers/llvm/4/clang/default.nix b/pkgs/development/compilers/llvm/4/clang/default.nix
index 276db7a7b416..8d40ee3c8aa2 100644
--- a/pkgs/development/compilers/llvm/4/clang/default.nix
+++ b/pkgs/development/compilers/llvm/4/clang/default.nix
@@ -9,7 +9,7 @@ let
     name = "clang-${version}";
 
     unpackPhase = ''
-      unpackFile ${fetch "cfe" "12n99m60aa680cir3ql56s1jsv6lp61hq4w9rabf4c6vpn7gi9ff"}
+      unpackFile ${fetch "cfe" "16vnv3msnvx33dydd17k2cq0icndi1a06bg5vcxkrhjjb1rqlwv1"}
       mv cfe-${version}* clang
       sourceRoot=$PWD/clang
       unpackFile ${clang-tools-extra_src}
diff --git a/pkgs/development/compilers/llvm/4/default.nix b/pkgs/development/compilers/llvm/4/default.nix
index 20e9d8d4d978..8fee3f4a87ce 100644
--- a/pkgs/development/compilers/llvm/4/default.nix
+++ b/pkgs/development/compilers/llvm/4/default.nix
@@ -2,7 +2,7 @@
 let
   callPackage = newScope (self // { inherit stdenv cmake libxml2 python2 isl release_version version fetch; });
 
-  release_version = "4.0.0";
+  release_version = "4.0.1";
   version = release_version; # differentiating these is important for rc's
 
   fetch = name: sha256: fetchurl {
@@ -10,8 +10,8 @@ let
     inherit sha256;
   };
 
-  compiler-rt_src = fetch "compiler-rt" "059ipqq27gd928ay06f1ck3vw6y5h5z4zd766x8k0k7jpqimpwnk";
-  clang-tools-extra_src = fetch "clang-tools-extra" "16bwckgcxfn56mbqjlxi7fxja0zm9hjfa6s3ncm3dz98n5zd7ds1";
+  compiler-rt_src = fetch "compiler-rt" "0h5lpv1z554szi4r4blbskhwrkd78ir50v3ng8xvk1s86fa7gj53";
+  clang-tools-extra_src = fetch "clang-tools-extra" "1dhmp7ccfpr42bmvk3kp37ngjpf3a9m5d4kkpsn7d00hzi7fdl9m";
 
   # Add man output without introducing extra dependencies.
   overrideManOutput = drv:
diff --git a/pkgs/development/compilers/llvm/4/libc++/default.nix b/pkgs/development/compilers/llvm/4/libc++/default.nix
index a43826d7a310..b74d2fb89dcd 100644
--- a/pkgs/development/compilers/llvm/4/libc++/default.nix
+++ b/pkgs/development/compilers/llvm/4/libc++/default.nix
@@ -3,7 +3,7 @@
 stdenv.mkDerivation rec {
   name = "libc++-${version}";
 
-  src = fetch "libcxx" "15ngfcjc3pjakpwfq7d4n546jj0rgfdv5rpb1qv9xgv9mp236kag";
+  src = fetch "libcxx" "0k6cmjcxnp2pyl8xwy1wkyyckkmdrjddim94yf1gzjbjy9qi22jj";
 
   postUnpack = ''
     unpackFile ${libcxxabi.src}
diff --git a/pkgs/development/compilers/llvm/4/libc++abi.nix b/pkgs/development/compilers/llvm/4/libc++abi.nix
index 3a0e996fb9a0..6a3d91101360 100644
--- a/pkgs/development/compilers/llvm/4/libc++abi.nix
+++ b/pkgs/development/compilers/llvm/4/libc++abi.nix
@@ -3,7 +3,7 @@
 stdenv.mkDerivation {
   name = "libc++abi-${version}";
 
-  src = fetch "libcxxabi" "1n416kv27anabg9jsw6331r28ic30xk46p381lx2vbb2jrhwpafw";
+  src = fetch "libcxxabi" "0cqvzallxh0nwiijsf6i4d5ds9m5ijfzywg7376ncv50i64if24g";
 
   nativeBuildInputs = [ cmake ];
   buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind;
diff --git a/pkgs/development/compilers/llvm/4/lld.nix b/pkgs/development/compilers/llvm/4/lld.nix
index f9cd72b4200c..776109ee74d1 100644
--- a/pkgs/development/compilers/llvm/4/lld.nix
+++ b/pkgs/development/compilers/llvm/4/lld.nix
@@ -10,7 +10,7 @@
 stdenv.mkDerivation {
   name = "lld-${version}";
 
-  src = fetch "lld" "00km1qawk146pyjqa6aphcdzgkzrmg6cgk0ikg4661ffp5bn9q1k";
+  src = fetch "lld" "1v9nkpr158j4yd4zmi6rpnfxkp78r1fapr8wji9s6v176gji1kk3";
 
   nativeBuildInputs = [ cmake ];
   buildInputs = [ llvm ];
diff --git a/pkgs/development/compilers/llvm/4/lldb.nix b/pkgs/development/compilers/llvm/4/lldb.nix
index a3c46a4c7e94..7d33179913be 100644
--- a/pkgs/development/compilers/llvm/4/lldb.nix
+++ b/pkgs/development/compilers/llvm/4/lldb.nix
@@ -17,7 +17,7 @@
 stdenv.mkDerivation {
   name = "lldb-${version}";
 
-  src = fetch "lldb" "0g83hbw1r4gd0z8hlph9i34xs6dlcc69vz3h2bqwkhb2qq2qzg9d";
+  src = fetch "lldb" "0yy43a27zx3r51b6gkv3v2mdiqcq3mf0ngki47ya0i30v3gx4cl4";
 
   patches = [ ./lldb-libedit.patch ];
   postPatch = ''
diff --git a/pkgs/development/compilers/llvm/4/llvm.nix b/pkgs/development/compilers/llvm/4/llvm.nix
index c5d22825f301..da40a42d9856 100644
--- a/pkgs/development/compilers/llvm/4/llvm.nix
+++ b/pkgs/development/compilers/llvm/4/llvm.nix
@@ -22,7 +22,7 @@
 }:
 
 let
-  src = fetch "llvm" "1giklnw71wzsgbqg9wb5x7dxnbj39m6zpfvskvzvhwvfz4fm244d";
+  src = fetch "llvm" "0l9bf7kdwhlj0kq1hawpyxhna1062z3h7qcz2y8nfl9dz2qksy6s";
   shlib = if stdenv.isDarwin then "dylib" else "so";
 
   # Used when creating a version-suffixed symlink of libLLVM.dylib
@@ -64,13 +64,6 @@ in stdenv.mkDerivation rec {
   + stdenv.lib.optionalString (enableSharedLibraries) ''
     substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib
     patch -p1 < ./llvm-outputs.patch
-  ''
-  # Remove broken tests: (https://bugs.llvm.org//show_bug.cgi?id=31610)
-  + ''
-    rm test/CodeGen/AMDGPU/invalid-opencl-version-metadata1.ll
-    rm test/CodeGen/AMDGPU/invalid-opencl-version-metadata2.ll
-    rm test/CodeGen/AMDGPU/invalid-opencl-version-metadata3.ll
-    rm test/CodeGen/AMDGPU/runtime-metadata.ll
   '';
 
   # hacky fix: created binaries need to be run before installation
diff --git a/pkgs/development/compilers/llvm/4/openmp.nix b/pkgs/development/compilers/llvm/4/openmp.nix
index 197e9a784653..0bdf5c71e1f3 100644
--- a/pkgs/development/compilers/llvm/4/openmp.nix
+++ b/pkgs/development/compilers/llvm/4/openmp.nix
@@ -10,7 +10,7 @@
 stdenv.mkDerivation {
   name = "openmp-${version}";
 
-  src = fetch "openmp" "09kf41zgv551fnv628kqhlwgqkd2bkiwii9gqi6q12djgdddhmfv";
+  src = fetch "openmp" "195dykamd39yhi5az7nqj3ksqhb3wq30l93jnfkxl0061qbknsgc";
 
   nativeBuildInputs = [ cmake perl ];
   buildInputs = [ llvm ];
diff --git a/pkgs/development/compilers/swift/patches/build-script-pax.patch b/pkgs/development/compilers/swift/patches/build-script-pax.patch
index 9f1976a2d88d..fa2ccdf9d5c6 100644
--- a/pkgs/development/compilers/swift/patches/build-script-pax.patch
+++ b/pkgs/development/compilers/swift/patches/build-script-pax.patch
@@ -1,12 +1,13 @@
 --- swift/utils/build-script-impl	2017-01-23 12:47:20.401326309 -0600
 +++ swift-pax/utils/build-script-impl	2017-01-23 13:24:10.339366996 -0600
-@@ -1823,6 +1823,16 @@ function set_lldb_xcodebuild_options() {
+@@ -1823,6 +1823,17 @@ function set_lldb_xcodebuild_options() {
      fi
  }
  
 +## XXX: Taken from nixpkgs /pkgs/stdenv/generic/setup.sh
 +isELF() {
 +    local fn="$1"
++    local fd
 +    local magic
 +    exec {fd}< "$fn"
 +    read -n 4 -u $fd magic
diff --git a/pkgs/development/interpreters/elixir/1.3.nix b/pkgs/development/interpreters/elixir/1.3.nix
new file mode 100644
index 000000000000..43d48e2cf7cd
--- /dev/null
+++ b/pkgs/development/interpreters/elixir/1.3.nix
@@ -0,0 +1,7 @@
+{ mkDerivation }:
+
+mkDerivation rec {
+  version = "1.3.4";
+  sha256 = "01qqv1ghvfadcwcr5p88w8j217cgaf094pmpqllij3l0q1yg104l";
+  minimumOTPVersion = "18";
+}
diff --git a/pkgs/development/interpreters/elixir/1.4.nix b/pkgs/development/interpreters/elixir/1.4.nix
new file mode 100644
index 000000000000..9ddd9062acd9
--- /dev/null
+++ b/pkgs/development/interpreters/elixir/1.4.nix
@@ -0,0 +1,7 @@
+{ mkDerivation }:
+
+mkDerivation rec {
+  version = "1.4.5";
+  sha256 = "18ivcxmh5bak13k3rjy7jjzin57rgb2nffhwnqb2wl7bpi8mrarw";
+  minimumOTPVersion = "18";
+}
diff --git a/pkgs/development/interpreters/elixir/1.5.nix b/pkgs/development/interpreters/elixir/1.5.nix
new file mode 100644
index 000000000000..d9e2e9c16c62
--- /dev/null
+++ b/pkgs/development/interpreters/elixir/1.5.nix
@@ -0,0 +1,7 @@
+{ mkDerivation }:
+
+mkDerivation rec {
+  version = "1.5.0-rc.0";
+  sha256 = "1p0sawz86w9na56c42ivdacqxzldjb9s9cvl2isj3sy4nwsa0l0j";
+  minimumOTPVersion = "18";
+}
diff --git a/pkgs/development/interpreters/elixir/default.nix b/pkgs/development/interpreters/elixir/default.nix
deleted file mode 100644
index 0e77b2af2524..000000000000
--- a/pkgs/development/interpreters/elixir/default.nix
+++ /dev/null
@@ -1,71 +0,0 @@
-{ stdenv, fetchFromGitHub, erlang, rebar, makeWrapper, coreutils, curl, bash,
-  debugInfo ? false }:
-
-stdenv.mkDerivation rec {
-  name = "elixir-${version}";
-  version = "1.4.4";
-
-  src = fetchFromGitHub {
-    owner = "elixir-lang";
-    repo = "elixir";
-    rev = "v${version}";
-    sha256 = "0m51cirkv1dahw4z2jlmz58cwmpy0dya88myx4wykq0v5bh1xbq8";
-  };
-
-  buildInputs = [ erlang rebar makeWrapper ];
-
-  # Elixir expects that UTF-8 locale to be set (see https://github.com/elixir-lang/elixir/issues/3548).
-  # In other cases there is warnings during compilation.
-  LANG = "en_US.UTF-8";
-  LC_TYPE = "en_US.UTF-8";
-
-  setupHook = ./setup-hook.sh;
-
-  inherit debugInfo;
-
-  buildFlags = if debugInfo
-   then "ERL_COMPILER_OPTIONS=debug_info"
-   else "";
-
-  preBuild = ''
-    # The build process uses ./rebar. Link it to the nixpkgs rebar
-    rm -v rebar
-    ln -s ${rebar}/bin/rebar rebar
-
-    substituteInPlace Makefile \
-      --replace "/usr/local" $out
-  '';
-
-  postFixup = ''
-    # Elixir binaries are shell scripts which run erl. Add some stuff
-    # to PATH so the scripts can run without problems.
-
-    for f in $out/bin/*; do
-     b=$(basename $f)
-      if [ $b == "mix" ]; then continue; fi
-      wrapProgram $f \
-        --prefix PATH ":" "${stdenv.lib.makeBinPath [ erlang coreutils curl bash ]}" \
-        --set CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt
-    done
-
-    substituteInPlace $out/bin/mix \
-          --replace "/usr/bin/env elixir" "${coreutils}/bin/env elixir"
-  '';
-
-  meta = with stdenv.lib; {
-    homepage = "http://elixir-lang.org/";
-    description = "A functional, meta-programming aware language built on top of the Erlang VM";
-
-    longDescription = ''
-      Elixir is a functional, meta-programming aware language built on
-      top of the Erlang VM. It is a dynamic language with flexible
-      syntax and macro support that leverages Erlang's abilities to
-      build concurrent, distributed and fault-tolerant applications
-      with hot code upgrades.
-    '';
-
-    license = licenses.epl10;
-    platforms = platforms.unix;
-    maintainers = with maintainers; [ the-kenny havvy couchemar ];
-  };
-}
diff --git a/pkgs/development/interpreters/elixir/generic-builder.nix b/pkgs/development/interpreters/elixir/generic-builder.nix
new file mode 100644
index 000000000000..ff63406aea36
--- /dev/null
+++ b/pkgs/development/interpreters/elixir/generic-builder.nix
@@ -0,0 +1,77 @@
+{ pkgs, stdenv, fetchFromGitHub, erlang, rebar, makeWrapper,
+  coreutils, curl, bash, debugInfo ? false }:
+
+{ baseName ? "elixir"
+, version
+, minimumOTPVersion
+, sha256 ? null
+, rev ? "v${version}"
+, src ? fetchFromGitHub { inherit rev sha256; owner = "elixir-lang"; repo = "elixir"; }
+}:
+
+let
+  inherit (stdenv.lib) getVersion versionAtLeast;
+
+in
+  assert versionAtLeast (getVersion erlang) minimumOTPVersion;
+
+  stdenv.mkDerivation ({
+    name = "${baseName}-${version}";
+
+    inherit src version;
+
+    buildInputs = [ erlang rebar makeWrapper ];
+
+    LANG = "en_US.UTF-8";
+    LC_TYPE = "en_US.UTF-8";
+
+    setupHook = ./setup-hook.sh;
+
+    inherit debugInfo;
+
+    buildFlags = if debugInfo
+     then "ERL_COMPILER_OPTIONS=debug_info"
+     else "";
+
+    preBuild = ''
+      # The build process uses ./rebar. Link it to the nixpkgs rebar
+      rm -v rebar
+      ln -s ${rebar}/bin/rebar rebar
+
+      substituteInPlace Makefile \
+        --replace "/usr/local" $out
+    '';
+
+    postFixup = ''
+      # Elixir binaries are shell scripts which run erl. Add some stuff
+      # to PATH so the scripts can run without problems.
+
+      for f in $out/bin/*; do
+       b=$(basename $f)
+        if [ "$b" = mix ]; then continue; fi
+        wrapProgram $f \
+          --prefix PATH ":" "${stdenv.lib.makeBinPath [ erlang coreutils curl bash ]}" \
+          --set CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt
+      done
+
+      substituteInPlace $out/bin/mix \
+            --replace "/usr/bin/env elixir" "${coreutils}/bin/env elixir"
+    '';
+
+    meta = with stdenv.lib; {
+      homepage = "http://elixir-lang.org/";
+      description = "A functional, meta-programming aware language built on top of the Erlang VM";
+
+      longDescription = ''
+        Elixir is a functional, meta-programming aware language built on
+        top of the Erlang VM. It is a dynamic language with flexible
+        syntax and macro support that leverages Erlang's abilities to
+        build concurrent, distributed and fault-tolerant applications
+        with hot code upgrades.
+      '';
+
+      license = licenses.epl10;
+      platforms = platforms.unix;
+      maintainers = with maintainers; [ the-kenny havvy couchemar ankhers ];
+    };
+  })
diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix
index a552b2719bb2..f3d4ae4bb00e 100644
--- a/pkgs/development/interpreters/ruby/default.nix
+++ b/pkgs/development/interpreters/ruby/default.nix
@@ -59,7 +59,7 @@ let
         srcs = [ rubySrc rubygemsSrc ];
         sourceRoot =
           if useRailsExpress then
-            "ruby-${tag}-src"
+            rubySrc.name
           else
             unpackdir rubySrc;
 
diff --git a/pkgs/development/libraries/aws-sdk-cpp/default.nix b/pkgs/development/libraries/aws-sdk-cpp/default.nix
index 974989dc24bf..9f97b18b4d77 100644
--- a/pkgs/development/libraries/aws-sdk-cpp/default.nix
+++ b/pkgs/development/libraries/aws-sdk-cpp/default.nix
@@ -26,6 +26,7 @@ in stdenv.mkDerivation rec {
   # FIXME: might be nice to put different APIs in different outputs
   # (e.g. libaws-cpp-sdk-s3.so in output "s3").
   outputs = [ "out" "dev" ];
+  separateDebugInfo = stdenv.isLinux;
 
   buildInputs = [ cmake curl ];
 
diff --git a/pkgs/development/libraries/boehm-gc/default.nix b/pkgs/development/libraries/boehm-gc/default.nix
index d32ec6cbf58b..e4311c0a5e9c 100644
--- a/pkgs/development/libraries/boehm-gc/default.nix
+++ b/pkgs/development/libraries/boehm-gc/default.nix
@@ -14,6 +14,7 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ pkgconfig ];
 
   outputs = [ "out" "dev" "doc" ];
+  separateDebugInfo = stdenv.isLinux;
 
   configureFlags =
     [ "--enable-cplusplus" ]
diff --git a/pkgs/development/libraries/glibc/common.nix b/pkgs/development/libraries/glibc/common.nix
index 647a34e95dba..1b53acf12b17 100644
--- a/pkgs/development/libraries/glibc/common.nix
+++ b/pkgs/development/libraries/glibc/common.nix
@@ -68,7 +68,8 @@ stdenv.mkDerivation ({
     ++ lib.optionals stdenv.isi686 [
       ./fix-i686-memchr.patch
       ./i686-fix-vectorized-strcspn.patch
-    ];
+    ]
+    ++ lib.optional stdenv.isx86_64 ./fix-x64-abi.patch;
 
   postPatch =
     # Needed for glibc to build with the gnumake 3.82
diff --git a/pkgs/development/libraries/glibc/fix-x64-abi.patch b/pkgs/development/libraries/glibc/fix-x64-abi.patch
new file mode 100644
index 000000000000..1d60dcd7988b
--- /dev/null
+++ b/pkgs/development/libraries/glibc/fix-x64-abi.patch
@@ -0,0 +1,35 @@
+From 3288c6da64add3b4561b8c10fff522027caea01c Mon Sep 17 00:00:00 2001
+From: Nicholas Miell <nmiell@gmail.com>
+Date: Sat, 17 Jun 2017 18:21:07 -0700
+Subject: [PATCH] Align the stack on entry to __tls_get_addr()
+
+Old versions of gcc (4 & 5) didn't align the stack according to the
+AMD64 psABI when calling __tls_get_addr(). Apparently new versions of
+gcc (7) got much more aggressive about vectorizing and generating MOVAPS
+instructions, which means old binaries built with the buggy versions of
+gcc are much more likely to crash when using versions of glibc built
+using gcc 7.
+
+For example, a large number of Linux games built using the Unity game
+engine and available for purchase on Steam.
+---
+ elf/dl-tls.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/elf/dl-tls.c b/elf/dl-tls.c
+index 5aba33b3fa..3f3cb917de 100644
+--- a/elf/dl-tls.c
++++ b/elf/dl-tls.c
+@@ -827,6 +827,10 @@ rtld_hidden_proto (__tls_get_addr)
+ rtld_hidden_def (__tls_get_addr)
+ #endif
+
++#ifdef __x86_64__
++/* Old versions of gcc didn't align the stack. */
++__attribute__((force_align_arg_pointer))
++#endif
+ /* The generic dynamic and local dynamic model cannot be used in
+    statically linked applications.  */
+ void *
+--
+2.13.0
diff --git a/pkgs/development/libraries/gnutls/3.5.nix b/pkgs/development/libraries/gnutls/3.5.nix
index e47537c64a9c..62ff25475694 100644
--- a/pkgs/development/libraries/gnutls/3.5.nix
+++ b/pkgs/development/libraries/gnutls/3.5.nix
@@ -1,11 +1,11 @@
 { callPackage, fetchurl, ... } @ args:
 
 callPackage ./generic.nix (args // rec {
-  version = "3.5.13";
+  version = "3.5.14";
 
   src = fetchurl {
     url = "ftp://ftp.gnutls.org/gcrypt/gnutls/v3.5/gnutls-${version}.tar.xz";
-    sha256 = "15ihq6p0hnnhs8cnjrkj40dmlcaa1jjg8xg0g2ydbnlqs454ixbr";
+    sha256 = "1nhv0mf3apz65ljh335l8xds7wpn08ywljkrvws08apljbn2v8aa";
   };
 
   # Skip two tests introduced in 3.5.11.  Probable reasons of failure:
diff --git a/pkgs/development/libraries/libsodium/default.nix b/pkgs/development/libraries/libsodium/default.nix
index bfe224d28cd6..b508b2fea0eb 100644
--- a/pkgs/development/libraries/libsodium/default.nix
+++ b/pkgs/development/libraries/libsodium/default.nix
@@ -9,6 +9,7 @@ stdenv.mkDerivation rec {
   };
 
   outputs = [ "out" "dev" ];
+  separateDebugInfo = stdenv.isLinux;
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/ncurses/default.nix b/pkgs/development/libraries/ncurses/default.nix
index e6db7af6ee2d..827a556a4688 100644
--- a/pkgs/development/libraries/ncurses/default.nix
+++ b/pkgs/development/libraries/ncurses/default.nix
@@ -46,9 +46,6 @@ stdenv.mkDerivation rec {
   buildInputs = lib.optional (mouseSupport && stdenv.isLinux) gpm;
 
   preConfigure = ''
-    # These paths end up in the default lookup chain.
-    export TERMINFO_DIRS=/etc/terminfo
-
     export PKG_CONFIG_LIBDIR="$dev/lib/pkgconfig"
     mkdir -p "$PKG_CONFIG_LIBDIR"
     configureFlagsArray+=(
diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix
index 2120e60ec6aa..c0296f42406d 100644
--- a/pkgs/development/libraries/openssl/default.nix
+++ b/pkgs/development/libraries/openssl/default.nix
@@ -29,6 +29,7 @@ let
 
     outputs = [ "bin" "dev" "out" "man" ];
     setOutputFlags = false;
+    separateDebugInfo = stdenv.isLinux;
 
     nativeBuildInputs = [ perl ];
     buildInputs = stdenv.lib.optional withCryptodev cryptodevHeaders;
diff --git a/pkgs/development/libraries/sqlite/default.nix b/pkgs/development/libraries/sqlite/default.nix
index 5230df995242..21d89c49e7c7 100644
--- a/pkgs/development/libraries/sqlite/default.nix
+++ b/pkgs/development/libraries/sqlite/default.nix
@@ -11,6 +11,7 @@ stdenv.mkDerivation {
   };
 
   outputs = [ "bin" "dev" "out" ];
+  separateDebugInfo = stdenv.isLinux;
 
   buildInputs = lib.optionals interactive [ readline ncurses ];
 
diff --git a/pkgs/development/tools/continuous-integration/gitlab-runner/v1.nix b/pkgs/development/tools/continuous-integration/gitlab-runner/v1.nix
index d51a32705923..a3e6a063596b 100644
--- a/pkgs/development/tools/continuous-integration/gitlab-runner/v1.nix
+++ b/pkgs/development/tools/continuous-integration/gitlab-runner/v1.nix
@@ -1,16 +1,16 @@
 { lib, buildGoPackage, fetchFromGitLab, fetchurl, go-bindata }:
 
 let
-  version = "1.11.4";
+  version = "1.11.5";
   # Gitlab runner embeds some docker images these are prebuilt for arm and x86_64
   docker_x86_64 = fetchurl {
     url = "https://gitlab-ci-multi-runner-downloads.s3.amazonaws.com/v${version}/docker/prebuilt-x86_64.tar.xz";
-    sha256 = "1ijkzn8jkzx1dzxhkf17987ligyf758xzas6ysix5b781jnkdm8z";
+    sha256 = "0qy3xrq574c1lhkqw1zrkcn32w0ky3f4fppzdjhb5zwqvnaz7kx0";
   };
 
   docker_arm = fetchurl {
     url = "https://gitlab-ci-multi-runner-downloads.s3.amazonaws.com/v${version}/docker/prebuilt-arm.tar.xz";
-    sha256 = "0sq2nndnkzqv2yjljg08xwa3ppddn6vqcivhfh43zwwmansvb9ha";
+    sha256 = "12clc28yc157s2kaa8239p0g086vq062jfjh2m1bxqmaypw9pyla";
   };
 in
 buildGoPackage rec {
@@ -29,7 +29,7 @@ buildGoPackage rec {
     owner = "gitlab-org";
     repo = "gitlab-ci-multi-runner";
     rev = "v${version}";
-    sha256 = "1pm88546cijmrrcvvrajp2g6rsrzxhy83cwwwky8jjkl5w4hhmz4";
+    sha256 = "1xgx8jbgcc3ga7dkjxa2i8nj4afsdavzpfrgpdzma03jkcq1g2sv";
   };
 
   patches = [ ./fix-shell-path.patch ];
diff --git a/pkgs/development/tools/parsing/re2c/default.nix b/pkgs/development/tools/parsing/re2c/default.nix
index a70afe511798..dcf89d1604d9 100644
--- a/pkgs/development/tools/parsing/re2c/default.nix
+++ b/pkgs/development/tools/parsing/re2c/default.nix
@@ -4,22 +4,22 @@ stdenv.mkDerivation rec {
   name = "re2c-${version}";
   version = "0.16";
 
-  sourceRoot = "${name}-src/re2c";
+  sourceRoot = "${src.name}/re2c";
 
   src = fetchFromGitHub {
-    owner = "skvadrik";
-    repo = "re2c";
-    rev = version;
+    owner  = "skvadrik";
+    repo   = "re2c";
+    rev    = version;
     sha256 = "0cijgmbyx34nwl2jmsswggkgvzy364871rkbxz8biq9x8xrhhjw5";
   };
 
   nativeBuildInputs = [ autoreconfHook ];
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "Tool for writing very fast and very flexible scanners";
     homepage    = "http://re2c.org";
-    license     = stdenv.lib.licenses.publicDomain;
-    platforms   = stdenv.lib.platforms.all;
-    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
+    license     = licenses.publicDomain;
+    platforms   = platforms.all;
+    maintainers = with maintainers; [ thoughtpolice ];
   };
 }
diff --git a/pkgs/misc/emulators/dolphin-emu/master.nix b/pkgs/misc/emulators/dolphin-emu/master.nix
index 499e1177c3ea..ed44ea593119 100644
--- a/pkgs/misc/emulators/dolphin-emu/master.nix
+++ b/pkgs/misc/emulators/dolphin-emu/master.nix
@@ -1,23 +1,17 @@
 { stdenv, gcc, pkgconfig, cmake, bluez, ffmpeg, libao, mesa, gtk2, glib
-, gettext, git, libpthreadstubs, libXrandr, libXext, readline
-, openal, libXdmcp, portaudio, fetchgit, libusb, libevdev
+, pcre, gettext, libpthreadstubs, libXrandr, libXext, libSM, readline
+, openal, libXdmcp, portaudio, fetchFromGitHub, libusb, libevdev
 , libpulseaudio ? null }:
 
 stdenv.mkDerivation rec {
-  name = "dolphin-emu-20150802";
-  src = fetchgit {
-    url = git://github.com/dolphin-emu/dolphin.git;
-    rev = "5097a22844b850b429872f4de390bd958b11a616";
-    sha256 = "09jx61cxvfimnq1snkv6w3m9qidrgp0j0w81c7pbkpmcwysz8xya";
-    fetchSubmodules = false;
+  name = "dolphin-emu-20170705";
+  src = fetchFromGitHub {
+    owner = "dolphin-emu";
+    repo = "dolphin";
+    rev = "29cc009706f133aac39ebaa7003d37555b926109";
+    sha256 = "0axd2z14lyqlaxrjssc0dkqnjdk3ccxh2fqrhya0jc2rsm8ighlz";
   };
 
-  postPatch = ''
-    for f in Source/Core/VideoBackends/{Software,OGL}/RasterFont.{h,cpp}; do
-      substituteInPlace "$f" --replace " CHAR_WIDTH " " CHARWIDTH "
-    done
-  '';
-
   cmakeFlags = ''
     -DGTK2_GLIBCONFIG_INCLUDE_DIR=${glib.out}/lib/glib-2.0/include
     -DGTK2_GDKCONFIG_INCLUDE_DIR=${gtk2.out}/lib/gtk-2.0/include
@@ -27,9 +21,9 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  buildInputs = [ gcc pkgconfig cmake bluez ffmpeg libao mesa gtk2 glib
-                  gettext libpthreadstubs libXrandr libXext readline openal
-                  libevdev git libXdmcp portaudio libusb libpulseaudio ];
+  buildInputs = [ gcc pkgconfig cmake bluez ffmpeg libao mesa gtk2 glib pcre
+                  gettext libpthreadstubs libXrandr libXext libSM readline openal
+                  libevdev libXdmcp portaudio libusb libpulseaudio ];
 
   meta = {
     homepage = http://dolphin-emu.org/;
diff --git a/pkgs/misc/emulators/wine/base.nix b/pkgs/misc/emulators/wine/base.nix
index 92815ffaa0af..348b52dd492e 100644
--- a/pkgs/misc/emulators/wine/base.nix
+++ b/pkgs/misc/emulators/wine/base.nix
@@ -22,6 +22,7 @@ stdenv.mkDerivation ((lib.optionalAttrs (! isNull buildScript) {
 
   buildInputs = toBuildInputs pkgArches (with supportFlags; (pkgs:
   [ pkgs.freetype ]
+  ++ lib.optional stdenv.isLinux         pkgs.libcap
   ++ lib.optional pngSupport             pkgs.libpng
   ++ lib.optional jpegSupport            pkgs.libjpeg
   ++ lib.optional cupsSupport            pkgs.cups
diff --git a/pkgs/os-specific/darwin/ios-cross/default.nix b/pkgs/os-specific/darwin/ios-cross/default.nix
index e0981d48c8c9..f56c8148317d 100644
--- a/pkgs/os-specific/darwin/ios-cross/default.nix
+++ b/pkgs/os-specific/darwin/ios-cross/default.nix
@@ -6,7 +6,9 @@
 , stdenv
 , coreutils
 , gnugrep
-, hostPlatform, targetPlatform
+, buildPackages
+, hostPlatform
+, targetPlatform
 }:
 
 /* As of this writing, known-good prefix/arch/simulator triples:
@@ -29,7 +31,7 @@ let
   sdk = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhone${sdkType}.platform/Developer/SDKs/iPhone${sdkType}${sdkVer}.sdk";
 
 in (import ../../../build-support/cc-wrapper {
-    inherit stdenv coreutils gnugrep runCommand;
+    inherit stdenv coreutils gnugrep runCommand buildPackages;
     nativeTools = false;
     nativeLibc = false;
     inherit binutils;
diff --git a/pkgs/servers/caddy/default.nix b/pkgs/servers/caddy/default.nix
index 5e5ac3bcafdc..77c836305147 100644
--- a/pkgs/servers/caddy/default.nix
+++ b/pkgs/servers/caddy/default.nix
@@ -2,7 +2,7 @@
 
 buildGoPackage rec {
   name = "caddy-${version}";
-  version = "0.10.3";
+  version = "0.10.4";
 
   goPackagePath = "github.com/mholt/caddy";
 
@@ -12,7 +12,7 @@ buildGoPackage rec {
     owner = "mholt";
     repo = "caddy";
     rev = "v${version}";
-    sha256 = "0srz1cji1z6ag591vfwjd0aypi32hr7hh9ypps8p5szf075rkr8p";
+    sha256 = "0zch19a38487dflx84dlkwz67by9g4v2v8d7wrslqhs14a0sifhk";
   };
 
   buildFlagsArray = ''
@@ -20,12 +20,10 @@ buildGoPackage rec {
       -X github.com/mholt/caddy/caddy/caddymain.gitTag=v${version}
   '';
 
-  goDeps = ./deps.nix;
-
   meta = with stdenv.lib; {
     homepage = https://caddyserver.com;
     description = "Fast, cross-platform HTTP/2 web server with automatic HTTPS";
     license = licenses.asl20;
-    maintainers = with maintainers; [ rushmorem fpletz ];
+    maintainers = with maintainers; [ rushmorem fpletz zimbatm ];
   };
 }
diff --git a/pkgs/servers/caddy/deps.nix b/pkgs/servers/caddy/deps.nix
deleted file mode 100644
index e2b318ca60e8..000000000000
--- a/pkgs/servers/caddy/deps.nix
+++ /dev/null
@@ -1,201 +0,0 @@
-# This file was generated by https://github.com/kamilchm/go2nix v1.2.0
-[
-  {
-    goPackagePath = "github.com/codahale/aesnicheck";
-    fetch = {
-      type = "git";
-      url = "https://github.com/codahale/aesnicheck";
-      rev = "349fcc471aaccc29cd074e1275f1a494323826cd";
-      sha256 = "1zab6jjs5hiqpq484pbpx490zlj42v7hf4wwkqmicyaq7wclfnka";
-    };
-  }
-  {
-    goPackagePath = "github.com/dustin/go-humanize";
-    fetch = {
-      type = "git";
-      url = "https://github.com/dustin/go-humanize";
-      rev = "259d2a102b871d17f30e3cd9881a642961a1e486";
-      sha256 = "1jiada1pfhw2wwkx7cjsa6ixa8c37w51b3x09vlr4m0l945pval9";
-    };
-  }
-  {
-    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 = "a91eba7f97777409bc2c443f5534d41dd20c5720";
-      sha256 = "13cg6wwkk2ddqbm0nh9fpx4mq7f6qym12ch4lvs53n028ycdgw87";
-    };
-  }
-  {
-    goPackagePath = "github.com/hashicorp/go-syslog";
-    fetch = {
-      type = "git";
-      url = "https://github.com/hashicorp/go-syslog";
-      rev = "b609c7d9de4658cded34a7336b90886c56f9dbdb";
-      sha256 = "1k0dqkizj4vwgdsb7x7fzmcgz9079sczhpn9whd0r3xcnqs7pkkb";
-    };
-  }
-  {
-    goPackagePath = "github.com/hashicorp/golang-lru";
-    fetch = {
-      type = "git";
-      url = "https://github.com/hashicorp/golang-lru";
-      rev = "0a025b7e63adc15a622f29b0b2c4c3848243bbf6";
-      sha256 = "1iq7lbpsz7ks052mpznmkf8s4k43p51z4dik2n9ivrxk666q2wxi";
-    };
-  }
-  {
-    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 = "25700e67be5c860bcc999137275b9ef8b65932bd";
-      sha256 = "08zbfy5n6ki6fjaihk7y686dwksdglds9c8f1klkldvjbg8mw4vp";
-    };
-  }
-  {
-    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 = "bb280f29be75d6d78c64a32692b668e2a99c57bb";
-      sha256 = "1a6xqh7z8amb1372kb63kmn764w6c0ypcl7c4c7kyy2sqx8lyjyc";
-    };
-  }
-  {
-    goPackagePath = "github.com/lucas-clemente/quic-go-certificates";
-    fetch = {
-      type = "git";
-      url = "https://github.com/lucas-clemente/quic-go-certificates";
-      rev = "d2f86524cced5186554df90d92529757d22c1cb6";
-      sha256 = "033099nv0y9pbv0v292x6g0mvwr2w02jf4vvpwx6sjpwbla4xjxd";
-    };
-  }
-  {
-    goPackagePath = "github.com/miekg/dns";
-    fetch = {
-      type = "git";
-      url = "https://github.com/miekg/dns";
-      rev = "e78414ef75607394ad7d917824f07f381df2eafa";
-      sha256 = "1g5rgbjy7nr0l6074plh2aqiwiy9nck9bhhks9c5ki3r00fjj3ay";
-    };
-  }
-  {
-    goPackagePath = "github.com/naoina/go-stringutil";
-    fetch = {
-      type = "git";
-      url = "https://github.com/naoina/go-stringutil";
-      rev = "6b638e95a32d0c1131db0e7fe83775cbea4a0d0b";
-      sha256 = "00831p1wn3rimybk1z8l30787kn1akv5jax5wx743nn76qcmkmc6";
-    };
-  }
-  {
-    goPackagePath = "github.com/naoina/toml";
-    fetch = {
-      type = "git";
-      url = "https://github.com/naoina/toml";
-      rev = "e6f5723bf2a66af014955e0888881314cf294129";
-      sha256 = "0kh7xnckw689kksh23ginyl3g8h2yqyvjh54nmnfvjaj886lvbsf";
-    };
-  }
-  {
-    goPackagePath = "github.com/russross/blackfriday";
-    fetch = {
-      type = "git";
-      url = "https://github.com/russross/blackfriday";
-      rev = "067529f716f4c3f5e37c8c95ddd59df1007290ae";
-      sha256 = "1l61ib6r6mg587p58li5zhafjkkmrzacachcjg1cvw0k4zza9137";
-    };
-  }
-  {
-    goPackagePath = "github.com/xenolf/lego";
-    fetch = {
-      type = "git";
-      url = "https://github.com/xenolf/lego";
-      rev = "aaa8e70aec58a858b6bef0706b367dd5e8d58128";
-      sha256 = "0899mdgb01bpz83zyxzln8ygyll78gmcslw5i36q9m60pqj59z60";
-    };
-  }
-  {
-    goPackagePath = "golang.org/x/crypto";
-    fetch = {
-      type = "git";
-      url = "https://go.googlesource.com/crypto";
-      rev = "e7ba82683099cae71475961448ab8f903ea77c26";
-      sha256 = "0w6zvzchgzk197siq3qbsh6pdpnx7g9xc08k5axv5yc6w8qhgx11";
-    };
-  }
-  {
-    goPackagePath = "golang.org/x/net";
-    fetch = {
-      type = "git";
-      url = "https://go.googlesource.com/net";
-      rev = "1a68b1313cf4ad7778376e82641197b60c02f65c";
-      sha256 = "1nfva16dasc9h5y1njcfnr2g09damk754g3yliij3ar06k06p1xf";
-    };
-  }
-  {
-    goPackagePath = "golang.org/x/text";
-    fetch = {
-      type = "git";
-      url = "https://go.googlesource.com/text";
-      rev = "210eee5cf7323015d097341bcf7166130d001cd8";
-      sha256 = "0sm9548ky5vi2sr5zjzwwna5f4pfs0nmlaw0pjnamxwfjzy4jnfb";
-    };
-  }
-  {
-    goPackagePath = "gopkg.in/natefinch/lumberjack.v2";
-    fetch = {
-      type = "git";
-      url = "https://gopkg.in/natefinch/lumberjack.v2";
-      rev = "a96e63847dc3c67d17befa69c303767e2f84e54f";
-      sha256 = "1l3vlv72b7rfkpy1164kwd3qzrqmmjnb67akzxqp2mlvc66k6p3d";
-    };
-  }
-  {
-    goPackagePath = "gopkg.in/square/go-jose.v1";
-    fetch = {
-      type = "git";
-      url = "https://gopkg.in/square/go-jose.v1";
-      rev = "aa2e30fdd1fe9dd3394119af66451ae790d50e0d";
-      sha256 = "0drajyadd6c4m5qv0jxcv748qczg8sgxz28nva1jn39f234m02is";
-    };
-  }
-  {
-    goPackagePath = "gopkg.in/yaml.v2";
-    fetch = {
-      type = "git";
-      url = "https://gopkg.in/yaml.v2";
-      rev = "cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b";
-      sha256 = "1hj2ag9knxflpjibck0n90jrhsrqz7qvad4qnif7jddyapi9bqzl";
-    };
-  }
-]
diff --git a/pkgs/servers/mail/postfix/pfixtools.nix b/pkgs/servers/mail/postfix/pfixtools.nix
index 1bbe6f3466b8..6a0d7fb588fd 100644
--- a/pkgs/servers/mail/postfix/pfixtools.nix
+++ b/pkgs/servers/mail/postfix/pfixtools.nix
@@ -10,7 +10,7 @@ let
     sha256 = "1vmbrw686f41n6xfjphfshn96vl07ynvnsyjdw9yfn9bfnldcjcq";
   };
 
-  srcRoot = "pfixtools-${pfixtoolsSrc.rev}-src";
+  srcRoot = pfixtoolsSrc.name;
 
   libCommonSrc = fetchFromGitHub {
     owner = "Fruneau";
diff --git a/pkgs/shells/ion/default.nix b/pkgs/shells/ion/default.nix
new file mode 100644
index 000000000000..4ab03b31fb93
--- /dev/null
+++ b/pkgs/shells/ion/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchFromGitHub, rustPlatform }:
+
+with rustPlatform;
+
+buildRustPackage rec {
+  name = "ion-${version}";
+  version = "1.0.3";
+
+  src = fetchFromGitHub {
+    owner = "redox-os";
+    repo = "ion";
+    rev = version;
+    sha256 = "0c2haw9qiwysyp1xj6qla8d6zpsdlygagzh86sk04c2b4ssyaca3";
+  };
+
+  depsSha256 = "0w2jgbrcx57js8ihzs5acp6b1niw1c7khdxrv14y3z9mmm9j55hs";
+
+  meta = with stdenv.lib; {
+    description = "Modern system shell with simple (and powerful) syntax";
+    homepage = https://github.com/redox-os/ion;
+    license = licenses.mit;
+    maintainers = with maintainers; [ dywedir ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix
index 0e68b5c8e128..f6d9bcac5104 100644
--- a/pkgs/stdenv/darwin/default.nix
+++ b/pkgs/stdenv/darwin/default.nix
@@ -54,14 +54,17 @@ in rec {
     __sandboxProfile = binShClosure + libSystemProfile;
   };
 
-  stageFun = step: last: {shell             ? "${bootstrapTools}/bin/sh",
+  stageFun = step: last: {shell             ? "${bootstrapTools}/bin/bash",
                           overrides         ? (self: super: {}),
                           extraPreHook      ? "",
                           extraBuildInputs,
                           allowedRequisites ? null}:
     let
       thisStdenv = import ../generic {
-        inherit config shell extraBuildInputs allowedRequisites;
+        inherit config shell extraBuildInputs;
+        allowedRequisites = if allowedRequisites == null then null else allowedRequisites ++ [
+          thisStdenv.cc.expand-response-params
+        ];
 
         name = "stdenv-darwin-boot-${toString step}";
 
@@ -77,12 +80,17 @@ in rec {
           nativeTools  = true;
           nativePrefix = bootstrapTools;
           nativeLibc   = false;
+          buildPackages = lib.optionalAttrs (last ? stdenv) {
+            inherit (last) stdenv;
+          };
+          hostPlatform = localSystem;
+          targetPlatform = localSystem;
           libc         = last.pkgs.darwin.Libsystem;
           isClang      = true;
           cc           = { name = "clang-9.9.9"; outPath = bootstrapTools; };
         };
 
-        preHook = stage0.stdenv.lib.optionalString (shell == "${bootstrapTools}/bin/sh") ''
+        preHook = stage0.stdenv.lib.optionalString (shell == "${bootstrapTools}/bin/bash") ''
           # Don't patch #!/interpreter because it leads to retained
           # dependencies on the bootstrapTools in the final stdenv.
           dontPatchShebangs=1
@@ -294,6 +302,11 @@ in rec {
       inherit shell;
       nativeTools = false;
       nativeLibc  = false;
+      buildPackages = {
+        inherit (prevStage) stdenv;
+      };
+      hostPlatform = localSystem;
+      targetPlatform = localSystem;
       inherit (pkgs) coreutils binutils gnugrep;
       inherit (pkgs.darwin) dyld;
       cc   = pkgs.llvmPackages.clang-unwrapped;
@@ -314,6 +327,7 @@ in rec {
       gzip ncurses.out ncurses.dev ncurses.man gnused bash gawk
       gnugrep llvmPackages.clang-unwrapped patch pcre.out binutils-raw.out
       binutils-raw.dev binutils gettext
+      cc.expand-response-params
     ]) ++ (with pkgs.darwin; [
       dyld Libsystem CF cctools ICU libiconv locale
     ]);
diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh
index eb63b18e5f3d..e5d2ba8682de 100644
--- a/pkgs/stdenv/generic/setup.sh
+++ b/pkgs/stdenv/generic/setup.sh
@@ -17,8 +17,9 @@ runHook() {
     shift
     local var="$hookName"
     if [[ "$hookName" =~ Hook$ ]]; then var+=s; else var+=Hooks; fi
-    eval "local -a dummy=(\"\${$var[@]}\")"
-    for hook in "_callImplicitHook 0 $hookName" "${dummy[@]}"; do
+    local -n var
+    local hook
+    for hook in "_callImplicitHook 0 $hookName" "${var[@]}"; do
         _eval "$hook" "$@"
     done
     return 0
@@ -32,8 +33,9 @@ runOneHook() {
     shift
     local var="$hookName"
     if [[ "$hookName" =~ Hook$ ]]; then var+=s; else var+=Hooks; fi
-    eval "local -a dummy=(\"\${$var[@]}\")"
-    for hook in "_callImplicitHook 1 $hookName" "${dummy[@]}"; do
+    local -n var
+    local hook
+    for hook in "_callImplicitHook 1 $hookName" "${var[@]}"; do
         if _eval "$hook" "$@"; then
             return 0
         fi
@@ -192,6 +194,7 @@ _addRpathPrefix() {
 # Return success if the specified file is an ELF object.
 isELF() {
     local fn="$1"
+    local fd
     local magic
     exec {fd}< "$fn"
     read -n 4 -u $fd magic
@@ -203,6 +206,7 @@ isELF() {
 # "#!").
 isScript() {
     local fn="$1"
+    local fd
     local magic
     if ! [ -x /bin/sh ]; then return 0; fi
     exec {fd}< "$fn"
diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix
index a27aca771abd..c475d2d1e927 100644
--- a/pkgs/stdenv/linux/default.nix
+++ b/pkgs/stdenv/linux/default.nix
@@ -76,6 +76,11 @@ let
              else lib.makeOverridable (import ../../build-support/cc-wrapper) {
           nativeTools = false;
           nativeLibc = false;
+          buildPackages = lib.optionalAttrs (prevStage ? stdenv) {
+            inherit (prevStage) stdenv;
+          };
+          hostPlatform = localSystem;
+          targetPlatform = localSystem;
           cc = prevStage.gcc-unwrapped;
           isGNU = true;
           libc = prevStage.glibc;
@@ -236,6 +241,11 @@ in
         nativeTools = false;
         nativeLibc = false;
         isGNU = true;
+        buildPackages = {
+          inherit (prevStage) stdenv;
+        };
+        hostPlatform = localSystem;
+        targetPlatform = localSystem;
         cc = prevStage.gcc-unwrapped;
         libc = self.glibc;
         inherit (self) stdenv binutils coreutils gnugrep;
diff --git a/pkgs/tools/archivers/unzip/default.nix b/pkgs/tools/archivers/unzip/default.nix
index 896cdd50973c..a35e473ec366 100644
--- a/pkgs/tools/archivers/unzip/default.nix
+++ b/pkgs/tools/archivers/unzip/default.nix
@@ -13,6 +13,8 @@ stdenv.mkDerivation {
 
   hardeningDisable = [ "format" ];
 
+  patchFlags = "-p1 -F3";
+
   patches = [
     ./CVE-2014-8139.diff
     ./CVE-2014-8140.diff
diff --git a/pkgs/tools/audio/ezstream/default.nix b/pkgs/tools/audio/ezstream/default.nix
new file mode 100644
index 000000000000..6524bedf9392
--- /dev/null
+++ b/pkgs/tools/audio/ezstream/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, libiconv, libshout, taglib, libxml2, pkgconfig }:
+
+stdenv.mkDerivation rec {
+  name = "ezstream-${version}";
+  version = "0.6.0";
+
+  src = fetchurl {
+    url = "https://ftp.osuosl.org/pub/xiph/releases/ezstream/${name}.tar.gz";
+    sha256 = "f86eb8163b470c3acbc182b42406f08313f85187bd9017afb8b79b02f03635c9";
+  };
+
+  buildInputs = [ libiconv libshout taglib libxml2 ];
+  nativeBuildInputs = [ pkgconfig ];
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "A command line source client for Icecast media streaming servers";
+    longDescription = ''
+      Ezstream is a command line source client for Icecast media
+      streaming servers. It began as the successor of the old "shout"
+      utility, and has since gained a lot of useful features.
+
+      In its basic mode of operation, it streams media files or data
+      from standard input without reencoding and thus requires only
+      very little CPU resources.
+    '';
+    homepage = http://icecast.org/ezstream/;
+    license = licenses.gpl2;
+    maintainers = [ maintainers.barrucadu ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/tools/filesystems/btrfs-progs/default.nix b/pkgs/tools/filesystems/btrfs-progs/default.nix
index 525aa2fec28a..d9b01eb5239f 100644
--- a/pkgs/tools/filesystems/btrfs-progs/default.nix
+++ b/pkgs/tools/filesystems/btrfs-progs/default.nix
@@ -21,6 +21,10 @@ stdenv.mkDerivation rec {
   # This should be fine on all platforms so apply universally
   patchPhase = "sed -i s/-O1/-O2/ configure";
 
+  postInstall = ''
+    install -v -m 444 -D btrfs-completion $out/etc/bash_completion.d/btrfs
+  '';
+
   meta = with stdenv.lib; {
     description = "Utilities for the btrfs filesystem";
     homepage = https://btrfs.wiki.kernel.org/;
diff --git a/pkgs/tools/misc/kronometer/default.nix b/pkgs/tools/misc/kronometer/default.nix
index 6db3278fade0..d74e2b4e12a7 100644
--- a/pkgs/tools/misc/kronometer/default.nix
+++ b/pkgs/tools/misc/kronometer/default.nix
@@ -1,7 +1,7 @@
 {
   mkDerivation, fetchurl, lib,
   extra-cmake-modules, kdoctools, wrapGAppsHook,
-  kconfig, kinit
+  kconfig, kcrash, kinit
 }:
 
 let
@@ -21,5 +21,5 @@ mkDerivation rec {
     maintainers = with maintainers; [ peterhoeg ];
   };
   nativeBuildInputs = [ extra-cmake-modules kdoctools wrapGAppsHook ];
-  propagatedBuildInputs = [ kconfig kinit ];
+  propagatedBuildInputs = [ kconfig kcrash kinit ];
 }
diff --git a/pkgs/tools/misc/partition-manager/default.nix b/pkgs/tools/misc/partition-manager/default.nix
index af5a45902bb4..a1c1eccdd88a 100644
--- a/pkgs/tools/misc/partition-manager/default.nix
+++ b/pkgs/tools/misc/partition-manager/default.nix
@@ -1,7 +1,7 @@
 { mkDerivation, fetchurl, lib
 , extra-cmake-modules, kdoctools, wrapGAppsHook
-, kconfig, kinit, kpmcore
-, kcrash, eject, libatasmart }:
+, kconfig, kcrash, kinit, kpmcore
+, eject, libatasmart }:
 
 let
   pname = "partitionmanager";
diff --git a/pkgs/tools/misc/peruse/default.nix b/pkgs/tools/misc/peruse/default.nix
index cd872fd966e5..a3fdca001d94 100644
--- a/pkgs/tools/misc/peruse/default.nix
+++ b/pkgs/tools/misc/peruse/default.nix
@@ -1,7 +1,7 @@
 {
   mkDerivation, fetchFromGitHub, fetchurl, lib,
   extra-cmake-modules, kdoctools, wrapGAppsHook,
-  baloo, kconfig, kfilemetadata, kinit, kirigami, knewstuff, plasma-framework
+  baloo, karchive, kconfig, kcrash, kfilemetadata, kinit, kirigami, knewstuff, plasma-framework
 }:
 
 let
@@ -23,7 +23,7 @@ in mkDerivation rec {
 
   nativeBuildInputs = [ extra-cmake-modules kdoctools wrapGAppsHook ];
 
-  propagatedBuildInputs = [ baloo kconfig kfilemetadata kinit kirigami knewstuff plasma-framework ];
+  propagatedBuildInputs = [ baloo karchive kconfig kcrash kfilemetadata kinit kirigami knewstuff plasma-framework ];
 
   pathsToLink = [ "/etc/xdg/peruse.knsrc"];
 
diff --git a/pkgs/tools/networking/curl/default.nix b/pkgs/tools/networking/curl/default.nix
index d1f7c4112c61..daf5a19b01c2 100644
--- a/pkgs/tools/networking/curl/default.nix
+++ b/pkgs/tools/networking/curl/default.nix
@@ -29,6 +29,7 @@ stdenv.mkDerivation rec {
   };
 
   outputs = [ "bin" "dev" "out" "man" "devdoc" ];
+  separateDebugInfo = stdenv.isLinux;
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/tools/networking/email/default.nix b/pkgs/tools/networking/email/default.nix
index 017da63a1e92..c7a6fbcfd7c7 100644
--- a/pkgs/tools/networking/email/default.nix
+++ b/pkgs/tools/networking/email/default.nix
@@ -8,7 +8,7 @@ let
     sha256 = "1cxxzhm36civ6vjdgrk7mfmlzkih44kdii6l2xgy4r434s8rzcpn";
   };
 
-  srcRoot = "eMail-${eMailSrc.rev}-src";
+  srcRoot = eMailSrc.name;
 
   dlibSrc = fetchFromGitHub {
     owner = "deanproxy";
diff --git a/pkgs/tools/networking/network-manager/default.nix b/pkgs/tools/networking/network-manager/default.nix
index 3ef4188052b6..d2a51b3acc86 100644
--- a/pkgs/tools/networking/network-manager/default.nix
+++ b/pkgs/tools/networking/network-manager/default.nix
@@ -32,7 +32,6 @@ stdenv.mkDerivation rec {
        --replace /usr/bin/ping6 ${inetutils}/bin/ping
     substituteInPlace src/devices/nm-arping-manager.c \
        --replace '("arping", NULL, NULL);' '("arping", "${iputils}/bin/arping", NULL);'
-    substituteInPlace src/NetworkManagerUtils.c --replace /sbin/modprobe ${kmod}/bin/modprobe
     substituteInPlace data/84-nm-drivers.rules \
       --replace /bin/sh ${stdenv.shell}
     substituteInPlace data/85-nm-unmanaged.rules \
@@ -43,6 +42,8 @@ stdenv.mkDerivation rec {
       --replace /bin/kill ${coreutils}/bin/kill
     substituteInPlace clients/common/nm-vpn-helpers.c \
       --subst-var-by openconnect ${openconnect}
+    substituteInPlace src/nm-core-utils.c \
+      --subst-var-by modprobeBinPath ${kmod}/bin/modprobe
     # to enable link-local connections
     configureFlags="$configureFlags --with-udev-dir=$out/lib/udev"
   '';
@@ -79,6 +80,7 @@ stdenv.mkDerivation rec {
       url = "https://github.com/NetworkManager/NetworkManager/commit/4e8eddd100bbc8429806a70620c90b72cfd29cb1.patch";
     })
     ./openconnect_helper_path.patch
+    ./modprobe.patch
   ];
 
   buildInputs = [ systemd libgudev libnl libuuid polkit ppp libndp
diff --git a/pkgs/tools/networking/network-manager/modprobe.patch b/pkgs/tools/networking/network-manager/modprobe.patch
new file mode 100644
index 000000000000..487c70b0165c
--- /dev/null
+++ b/pkgs/tools/networking/network-manager/modprobe.patch
@@ -0,0 +1,11 @@
+--- a/src/nm-core-utils.c	2017-02-15 13:10:27.000000000 +0100
++++ b/src/nm-core-utils.c	2017-07-06 14:28:41.575815695 +0200
+@@ -419,7 +419,7 @@
+ 
+ 	/* construct the argument list */
+ 	argv = g_ptr_array_sized_new (4);
+-	g_ptr_array_add (argv, "/sbin/modprobe");
++	g_ptr_array_add (argv, "@modprobeBinPath@");
+ 	g_ptr_array_add (argv, (char *) arg1);
+ 
+ 	va_start (ap, arg1);
diff --git a/pkgs/tools/package-management/gx/default.nix b/pkgs/tools/package-management/gx/default.nix
index b879ef002b12..524dc01cbe72 100644
--- a/pkgs/tools/package-management/gx/default.nix
+++ b/pkgs/tools/package-management/gx/default.nix
@@ -1,24 +1,19 @@
 # This file was generated by go2nix.
-{ stdenv, buildGoPackage, fetchgit, fetchhg, fetchbzr, fetchsvn }:
+{ stdenv, buildGoPackage, fetchgit }:
 
 buildGoPackage rec {
   name = "gx-${version}";
-  version = "20160601-${stdenv.lib.strings.substring 0 7 rev}";
-  rev = "f84ddf792ceb329e20c857731154798e1ce87314";
+  version = "0.12.0";
+  rev = "refs/tags/v${version}";
 
   goPackagePath = "github.com/whyrusleeping/gx";
 
   src = fetchgit {
     inherit rev;
     url = "https://github.com/whyrusleeping/gx";
-    sha256 = "10a6p9ba526jr6m66x3vsa3xsjlnzv7yma8vyp8d0bf0hs44bpih";
+    sha256 = "0pvf0j14xnzy01fxilja8xbki0i0g7h7y20jzw74ds5a7ywsdx8r";
   };
 
-  prePatch = ''
-    substituteInPlace tests/lib/random-dep.go \
-      --replace "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-random" "github.com/jbenet/go-random"
-  '';
-
   goDeps = ./deps.nix;
 
   meta = with stdenv.lib; {
diff --git a/pkgs/tools/package-management/gx/deps.nix b/pkgs/tools/package-management/gx/deps.nix
index 19372f807c21..c34d142c3850 100644
--- a/pkgs/tools/package-management/gx/deps.nix
+++ b/pkgs/tools/package-management/gx/deps.nix
@@ -1,56 +1,56 @@
 [
   {
-    goPackagePath = "github.com/anacrolix/missinggo";
+    goPackagePath = "github.com/agl/ed25519";
     fetch = {
       type = "git";
-      url = "https://github.com/anacrolix/missinggo";
-      rev = "e40875155efce3d98562ca9e265e152c364ada3e";
-      sha256 = "1p1qgnb430dz84d2395i6417jqnlvrx9zwg9rq1ri8d5v7dif4fg";
+      url = "https://github.com/agl/ed25519";
+      rev = "5312a61534124124185d41f09206b9fef1d88403";
+      sha256 = "1v8mhkf1m3ga5262s75vabskxvsw5rpqvi5nwhxwiv7gfk6h823i";
     };
   }
   {
-    goPackagePath = "github.com/anacrolix/sync";
+    goPackagePath = "github.com/blang/semver";
     fetch = {
       type = "git";
-      url = "https://github.com/anacrolix/sync";
-      rev = "812602587b72df6a2a4f6e30536adc75394a374b";
-      sha256 = "0pc38wanzws3vzqj0l5pakg3gn2hacqrb4n7pd0sqz083rss5k0l";
+      url = "https://github.com/blang/semver";
+      rev = "4a1e882c79dcf4ec00d2e29fac74b9c8938d5052";
+      sha256 = "07rk2jzmppw1v06qvsn11l1mwkyg6y9y06jfik316zq8glfh8b3m";
     };
   }
   {
-    goPackagePath = "github.com/anacrolix/utp";
+    goPackagePath = "github.com/btcsuite/btcd";
     fetch = {
       type = "git";
-      url = "https://github.com/anacrolix/utp";
-      rev = "d7ad5aff2b8a5fa415d1c1ed00b71cfd8b4c69e0";
-      sha256 = "07piwfny3b4prxf2shc512ai0qmrmrj839lbza9clhgcmj1a75d7";
+      url = "https://github.com/btcsuite/btcd";
+      rev = "9822ffad6802d3b902442b727a238230194d961f";
+      sha256 = "0mk3qxpn29gsbkvk6rj6jzsw3fn2z51afq890wpk4qz029kvip2h";
     };
   }
   {
-    goPackagePath = "github.com/blang/semver";
+    goPackagePath = "github.com/codegangsta/cli";
     fetch = {
       type = "git";
-      url = "https://github.com/blang/semver";
-      rev = "aea32c919a18e5ef4537bbd283ff29594b1b0165";
-      sha256 = "1s80qlij6j6wrh0fhm0l11hbf3qjra67nca5bl7izyfjj4621fcd";
+      url = "https://github.com/codegangsta/cli";
+      rev = "4b90d79a682b4bf685762c7452db20f2a676ecb2";
+      sha256 = "0ls3lfmbfwirm9j95b6yrw41wgh72lfkp1cvs873zw04si4yvaqr";
     };
   }
   {
-    goPackagePath = "github.com/bradfitz/iter";
+    goPackagePath = "github.com/coreos/go-semver";
     fetch = {
       type = "git";
-      url = "https://github.com/bradfitz/iter";
-      rev = "454541ec3da2a73fc34fd049b19ee5777bf19345";
-      sha256 = "0v07zlq2h2rjz5mdvh0rgizyzcj68qa235gci6hvlrai7igyi57i";
+      url = "https://github.com/coreos/go-semver";
+      rev = "1817cd4bea52af76542157eeabd74b057d1a199e";
+      sha256 = "0hfxcg87ag0zdfarbymfx2qmhcdzm8br39sxvhfc7n37rqdcsh9n";
     };
   }
   {
-    goPackagePath = "github.com/codegangsta/cli";
+    goPackagePath = "github.com/gogo/protobuf";
     fetch = {
       type = "git";
-      url = "https://github.com/codegangsta/cli";
-      rev = "e5bef42c62aa7d25aba4880dc02b7624f01e9e19";
-      sha256 = "1g0z2klbaivd0w1fwf1k1dkyk8jbq28qd7fvczjv0yj6hg4vz1wq";
+      url = "https://github.com/gogo/protobuf";
+      rev = "dda3e8acadcc9affc16faf33fbb229db78399245";
+      sha256 = "1f1lm6bgwnrd985n1aagqw0bxfx37z71fwfcijiz9k258vj4wlga";
     };
   }
   {
@@ -58,8 +58,26 @@
     fetch = {
       type = "git";
       url = "https://github.com/ipfs/go-ipfs-api";
-      rev = "7c354892da3abdaafb6ac576c100b259b1a73dac";
-      sha256 = "0n8k9ydn2l362vq0bpbjkciw08div3hpc22qygp6zsrlammizcvc";
+      rev = "2da86eb64d56571c123c02ae82140c7b4b95f72a";
+      sha256 = "1ljlzjig0qv2mjzyk2piid12b4043584qskx6ikbz5i16cnbvqsq";
+    };
+  }
+  {
+    goPackagePath = "github.com/ipfs/go-ipfs-util";
+    fetch = {
+      type = "git";
+      url = "https://github.com/ipfs/go-ipfs-util";
+      rev = "f25fcc891281327394bb48000ef0970d11baff2b";
+      sha256 = "1a79ggx0ma9ny39kjm0gzicrn541gyis4fn7kmkkfjjfaj8v5l3y";
+    };
+  }
+  {
+    goPackagePath = "github.com/ipfs/go-log";
+    fetch = {
+      type = "git";
+      url = "https://github.com/ipfs/go-log";
+      rev = "48d644b006ba26f1793bffc46396e981801078e3";
+      sha256 = "0q2bk2s2v626ikm2pjalq4qg4n53yyf1bb81jbljb23iijxrqsbr";
     };
   }
   {
@@ -72,66 +90,120 @@
     };
   }
   {
-    goPackagePath = "github.com/jbenet/go-multiaddr";
+    goPackagePath = "github.com/jbenet/go-os-rename";
     fetch = {
       type = "git";
-      url = "https://github.com/jbenet/go-multiaddr";
-      rev = "f3dff105e44513821be8fbe91c89ef15eff1b4d4";
-      sha256 = "0rz17cvhslspp2z8jbxah22kndqiq9zl8nlf14ng8hfxdfm1x4n7";
+      url = "https://github.com/jbenet/go-os-rename";
+      rev = "3ac97f61ef67a6b87b95c1282f6c317ed0e693c2";
+      sha256 = "0fmsmmh9h3l7swf5d56spy9jyrnrvw0vnxgh11mpvxmw5hv3lclr";
     };
   }
   {
-    goPackagePath = "github.com/jbenet/go-multiaddr-net";
+    goPackagePath = "github.com/jbenet/goprocess";
     fetch = {
       type = "git";
-      url = "https://github.com/jbenet/go-multiaddr-net";
-      rev = "d4cfd691db9f50e430528f682ca603237b0eaae0";
-      sha256 = "031xb8j5nysw052cm36rjn19c5wkjf8dh8x21vrbyb7220h5zp90";
+      url = "https://github.com/jbenet/goprocess";
+      rev = "b497e2f366b8624394fb2e89c10ab607bebdde0b";
+      sha256 = "1lnvkzki7vnqn5c4m6bigk0k85haicmg27w903kwg30rdvblm82s";
     };
   }
   {
-    goPackagePath = "github.com/jbenet/go-multihash";
+    goPackagePath = "github.com/kr/fs";
     fetch = {
       type = "git";
-      url = "https://github.com/jbenet/go-multihash";
-      rev = "e8d2374934f16a971d1e94a864514a21ac74bf7f";
-      sha256 = "1hlzgmjszn8mfvn848jbnpsvccm9g3m42saavgbh48qdryraqscp";
+      url = "https://github.com/kr/fs";
+      rev = "2788f0dbd16903de03cb8186e5c7d97b69ad387b";
+      sha256 = "1c0fipl4rsh0v5liq1ska1dl83v3llab4k6lm8mvrx9c4dyp71ly";
     };
   }
   {
-    goPackagePath = "github.com/jbenet/go-os-rename";
+    goPackagePath = "github.com/libp2p/go-floodsub";
     fetch = {
       type = "git";
-      url = "https://github.com/jbenet/go-os-rename";
-      rev = "3ac97f61ef67a6b87b95c1282f6c317ed0e693c2";
-      sha256 = "0fmsmmh9h3l7swf5d56spy9jyrnrvw0vnxgh11mpvxmw5hv3lclr";
+      url = "https://github.com/libp2p/go-floodsub";
+      rev = "a922092abea58f07c32eabe303ec817569578740";
+      sha256 = "0wbi67jyfvrzfsb9lkrhjgg9k66yk5sww7nvihhc9rdnblygigs3";
     };
   }
   {
-    goPackagePath = "github.com/jbenet/go-random";
+    goPackagePath = "github.com/libp2p/go-libp2p-crypto";
     fetch = {
       type = "git";
-      url = "https://github.com/jbenet/go-random";
-      rev = "384f606e91f542a98e779e652eed88051618f0f7";
-      sha256 = "0gcshzl9n3apzc0jaxqrjsc038yfrzfyhpdqgbpcnajin83l2msa";
+      url = "https://github.com/libp2p/go-libp2p-crypto";
+      rev = "e89e1de117dd65c6129d99d1d853f48bc847cf17";
+      sha256 = "1lb0qzspx99sqbdxbf9dczwcmmirl4h26q9x3v6ris253zmqcbyw";
     };
   }
   {
-    goPackagePath = "github.com/jbenet/go-random-files";
+    goPackagePath = "github.com/libp2p/go-libp2p-host";
     fetch = {
       type = "git";
-      url = "https://github.com/jbenet/go-random-files";
-      rev = "737479700b40b4b50e914e963ce8d9d44603e3c8";
-      sha256 = "1klpdc4qkrfy31r7qh00fcz42blswzabmcnry9byd5adhszxj9bw";
+      url = "https://github.com/libp2p/go-libp2p-host";
+      rev = "c1fc482de113ce7e4cdc9453a1c1c0fe4164d985";
+      sha256 = "1hiz5j64s248vml7i4gwjvz59g7l08zjfklhrbmk0cjxwhx9ypy0";
     };
   }
   {
-    goPackagePath = "github.com/kr/fs";
+    goPackagePath = "github.com/libp2p/go-libp2p-interface-conn";
     fetch = {
       type = "git";
-      url = "https://github.com/kr/fs";
-      rev = "2788f0dbd16903de03cb8186e5c7d97b69ad387b";
-      sha256 = "1c0fipl4rsh0v5liq1ska1dl83v3llab4k6lm8mvrx9c4dyp71ly";
+      url = "https://github.com/libp2p/go-libp2p-interface-conn";
+      rev = "95afdbf0c900237f3b9104f1f7cfd3d56175a241";
+      sha256 = "0dv0jc08hfzb8gsi14c2ivancq7pxs8d482l4rw89mg04m2pgnaa";
+    };
+  }
+  {
+    goPackagePath = "github.com/libp2p/go-libp2p-net";
+    fetch = {
+      type = "git";
+      url = "https://github.com/libp2p/go-libp2p-net";
+      rev = "2680a9894c7aabada540f728a53d7c1a16a1a44a";
+      sha256 = "1k44dz2dk7ahlfls6vk747jy8kbxmjhqyni8zw2wiz6sfm5hyw10";
+    };
+  }
+  {
+    goPackagePath = "github.com/libp2p/go-libp2p-peer";
+    fetch = {
+      type = "git";
+      url = "https://github.com/libp2p/go-libp2p-peer";
+      rev = "166a39e33e7a2a47a4bf999264f254ecaa4fe232";
+      sha256 = "0kgv1n2c8rfz92vk014sqm1bla7a99w18ydyphjjhc96fmlbrzgl";
+    };
+  }
+  {
+    goPackagePath = "github.com/libp2p/go-libp2p-peerstore";
+    fetch = {
+      type = "git";
+      url = "https://github.com/libp2p/go-libp2p-peerstore";
+      rev = "744a149e48eb42e032540507c8545d12cc3b7f6f";
+      sha256 = "1bcmqkdlvvxdz9dbqrcfmvhx0wnnk94fb2yl9ys1nx7mnqgl64y8";
+    };
+  }
+  {
+    goPackagePath = "github.com/libp2p/go-libp2p-protocol";
+    fetch = {
+      type = "git";
+      url = "https://github.com/libp2p/go-libp2p-protocol";
+      rev = "40488c03777c16bfcd65da2f675b192863cbc2dc";
+      sha256 = "1mvhi8pdfyn3lb1j1y4iz2mggnf0dz7ccbmrbij739v6cpjfwwbb";
+    };
+  }
+  {
+    goPackagePath = "github.com/libp2p/go-libp2p-transport";
+    fetch = {
+      type = "git";
+      url = "https://github.com/libp2p/go-libp2p-transport";
+      rev = "5d3cb5861b59c26052a5fe184e45c381ec17e22d";
+      sha256 = "1v63gavw98f6hs151mqk0bbdl46a9ci9m2pcx807wxdsmfphynar";
+    };
+  }
+  {
+    goPackagePath = "github.com/libp2p/go-maddr-filter";
+    fetch = {
+      type = "git";
+      url = "https://github.com/libp2p/go-maddr-filter";
+      rev = "90aacb5ee155f0d6f3fa8b34d775de842606c0b1";
+      sha256 = "0ijs599hppj78dg2v7rcglqs82pysygq84yabpis5b99fjp9bay0";
     };
   }
   {
@@ -139,8 +211,44 @@
     fetch = {
       type = "git";
       url = "https://github.com/mitchellh/go-homedir";
-      rev = "1111e456ffea841564ac0fa5f69c26ef44dafec9";
-      sha256 = "1ycb1cffgs46jnj4cbpjd46mcl584kxdmldlvfysg0wza9pp4x23";
+      rev = "b8bc1bf767474819792c23f32d8286a45736f1c6";
+      sha256 = "13ry4lylalkh4g2vny9cxwvryslzyzwp9r92z0b10idhdq3wad1q";
+    };
+  }
+  {
+    goPackagePath = "github.com/multiformats/go-multiaddr";
+    fetch = {
+      type = "git";
+      url = "https://github.com/multiformats/go-multiaddr";
+      rev = "33741da7b3f5773a599d4a03c333704fc560ef34";
+      sha256 = "0idhv960k68jvh0frhh28dw46p527m2g67rjwjh6r5va5sd8qjcd";
+    };
+  }
+  {
+    goPackagePath = "github.com/multiformats/go-multiaddr-net";
+    fetch = {
+      type = "git";
+      url = "https://github.com/multiformats/go-multiaddr-net";
+      rev = "a7b93d11855f04f56908e1385991eb6a400fcc43";
+      sha256 = "1q0d8asxxhxhm774xn29n1x6zni6pmm78lvm3652ipyj026y243k";
+    };
+  }
+  {
+    goPackagePath = "github.com/multiformats/go-multihash";
+    fetch = {
+      type = "git";
+      url = "https://github.com/multiformats/go-multihash";
+      rev = "a52a6a4768da72eba89ea7f59f70e9d42ddd3072";
+      sha256 = "0r6fmzvg4vjwc5wzfqn7jjxndcw8n0galdx6f524yd9bcfdlph5b";
+    };
+  }
+  {
+    goPackagePath = "github.com/multiformats/go-multistream";
+    fetch = {
+      type = "git";
+      url = "https://github.com/multiformats/go-multistream";
+      rev = "b8f1996688ab586031517919b49b1967fca8d5d9";
+      sha256 = "0y2hl78lmnd0rbryfmscgxa6kmjdfz00pz60ymhg8k4cifqai0x2";
     };
   }
   {
@@ -148,8 +256,26 @@
     fetch = {
       type = "git";
       url = "https://github.com/sabhiram/go-git-ignore";
-      rev = "228fcfa2a06e870a3ef238d54c45ea847f492a37";
-      sha256 = "0xyj2zsxjjbyd3ppxvs294c8y2ip181dxhvycaxxx6qysbm2nlzj";
+      rev = "87c28ffedb6cb7ff29ae89e0440e9ddee0d95a9e";
+      sha256 = "1qysvwjvbzq1wms09dm0sban58xq22bbkwpd7qnk28r99g6267rl";
+    };
+  }
+  {
+    goPackagePath = "github.com/spaolacci/murmur3";
+    fetch = {
+      type = "git";
+      url = "https://github.com/spaolacci/murmur3";
+      rev = "0d12bf811670bf6a1a63828dfbd003eded177fce";
+      sha256 = "0fv74n0cvgnxpfd04xyiry6ii1ag7mhwwk0kwplpvnbwi8y9yq1x";
+    };
+  }
+  {
+    goPackagePath = "github.com/whyrusleeping/go-logging";
+    fetch = {
+      type = "git";
+      url = "https://github.com/whyrusleeping/go-logging";
+      rev = "0457bb6b88fc1973573aaf6b5145d8d3ae972390";
+      sha256 = "1bl180mhg03hdqhyr5sfjcg16ns2ppal625g9ag5m10l2pvlwnqn";
     };
   }
   {
@@ -166,8 +292,26 @@
     fetch = {
       type = "git";
       url = "https://github.com/whyrusleeping/json-filter";
-      rev = "e9937f5649231265a56d0a419f062530425401a1";
-      sha256 = "1b7czlx57acbi30b9m1w2lvlxnh65c4pmxaa0546pjjip83byb3s";
+      rev = "ff25329a9528f01c5175414f16cc0a6a162a5b8b";
+      sha256 = "0cai0drvx4c8j686l908vpcsz3mw3vxi3ziz94b0f3c5ylpj07j7";
+    };
+  }
+  {
+    goPackagePath = "github.com/whyrusleeping/mafmt";
+    fetch = {
+      type = "git";
+      url = "https://github.com/whyrusleeping/mafmt";
+      rev = "15300f9d3a2d71db61951a8705d5ea8878764837";
+      sha256 = "0fiwrj8pla9y8q0m4ifyrh8gacmrz278h2zihdbqbk2b17b002yr";
+    };
+  }
+  {
+    goPackagePath = "github.com/whyrusleeping/progmeter";
+    fetch = {
+      type = "git";
+      url = "https://github.com/whyrusleeping/progmeter";
+      rev = "974d8fe8cd87585865b1370184050e89d606e817";
+      sha256 = "05njc5minpaxzwb6yg5zjr52ar4ar7qkiml45zsrp2ny92dyx07j";
     };
   }
   {
@@ -189,12 +333,30 @@
     };
   }
   {
+    goPackagePath = "github.com/whyrusleeping/timecache";
+    fetch = {
+      type = "git";
+      url = "https://github.com/whyrusleeping/timecache";
+      rev = "cfcb2f1abfee846c430233aef0b630a946e0a5a6";
+      sha256 = "0nnra7ivq7cj34rj2ib8hgfdpik3smr1hy7x18svhfin8z1xsj2s";
+    };
+  }
+  {
     goPackagePath = "golang.org/x/crypto";
     fetch = {
       type = "git";
       url = "https://go.googlesource.com/crypto";
-      rev = "f3241ce8505855877cc8a9717bd61a0f7c4ea83c";
-      sha256 = "0wxfnbhaq1m3i5jylww9llm2xl9hk33q6nxyz5i475rfrg0p3wsq";
+      rev = "a48ac81e47fd6f9ed1258f3b60ae9e75f93cb7ed";
+      sha256 = "0zpgwc362rghm3fv0s964dqmw6krixzxww2qxhnik9hvf7srapjd";
+    };
+  }
+  {
+    goPackagePath = "leb.io/hashland";
+    fetch = {
+      type = "git";
+      url = "https://github.com/tildeleb/hashland";
+      rev = "e13accbe55f7fa03c73c74ace4cca4c425e47260";
+      sha256 = "1ygfp7kjnm964w2bv61bsyxpw5y6vy6k4pra1lhd5r3nhlxgs31g";
     };
   }
 ]
diff --git a/pkgs/tools/package-management/gx/go/default.nix b/pkgs/tools/package-management/gx/go/default.nix
index aa5acfa22d58..6a9589f9ac2a 100644
--- a/pkgs/tools/package-management/gx/go/default.nix
+++ b/pkgs/tools/package-management/gx/go/default.nix
@@ -5,15 +5,15 @@
 
 buildGoPackage rec {
   name = "gx-go-${version}";
-  version = "20160611-${stdenv.lib.strings.substring 0 7 rev}";
-  rev = "639fc0be1a153c59d8946904cceecf0b66ab2944";
+  version = "1.5.0";
+  rev = "refs/tags/v${version}";
 
   goPackagePath = "github.com/whyrusleeping/gx-go";
 
   src = fetchgit {
     inherit rev;
     url = "https://github.com/whyrusleeping/gx-go";
-    sha256 = "0qxp7gqrx1rhcbqvp4jdb3gj1dlj200bdc4gq8pfklc8fcz1lc6l";
+    sha256 = "0bg4h5lzs293qmlsr9n257vjpr5w6bxb4ampb25gsn3fgy3rvsis";
   };
 
   goDeps = ../deps.nix;
diff --git a/pkgs/tools/security/sshuttle/default.nix b/pkgs/tools/security/sshuttle/default.nix
index daa02497d0f6..2d663175ec9d 100644
--- a/pkgs/tools/security/sshuttle/default.nix
+++ b/pkgs/tools/security/sshuttle/default.nix
@@ -1,23 +1,28 @@
-{ stdenv, pythonPackages, fetchurl, makeWrapper, pandoc
+{ stdenv, python3Packages, fetchurl, makeWrapper, pandoc
 , coreutils, iptables, nettools, openssh, procps }:
   
-pythonPackages.buildPythonApplication rec {
+python3Packages.buildPythonApplication rec {
   name = "sshuttle-${version}";
-  version = "0.78.0";
+  version = "0.78.3";
 
   src = fetchurl {
-    sha256 = "18hrwi2gyri1n2rq0nghvv7hfhbhh5h67am89524vc1yyx40vn3b";
+    sha256 = "12xyq5h77b57cnkljdk8qyjxzys512b73019s20x6ck5brj1m8wa";
     url = "mirror://pypi/s/sshuttle/${name}.tar.gz";
   };
 
   patches = [ ./sudo.patch ];
 
-  propagatedBuildInputs = with pythonPackages; [ PyXAPI mock pytest ];
-  nativeBuildInputs = [ makeWrapper pandoc pythonPackages.setuptools_scm ];
+  nativeBuildInputs = [ makeWrapper pandoc python3Packages.setuptools_scm ];
   buildInputs =
     [ coreutils openssh ] ++
     stdenv.lib.optionals stdenv.isLinux [ iptables nettools procps ];
 
+  checkInputs = with python3Packages; [ mock pytest pytestrunner ];
+
+  # Tests only run with Python 3. Server-side Python 2 still works if client
+  # uses Python 3, so it should be fine.
+  doCheck = true;
+
   postInstall = let
     mapPath = f: x: stdenv.lib.concatStringsSep ":" (map f x);
   in ''
diff --git a/pkgs/tools/text/groff/default.nix b/pkgs/tools/text/groff/default.nix
index aa9ece8955b4..fc6b1abf24dd 100644
--- a/pkgs/tools/text/groff/default.nix
+++ b/pkgs/tools/text/groff/default.nix
@@ -57,8 +57,11 @@ stdenv.mkDerivation rec {
   # Remove example output with (random?) colors and creation date
   # to avoid non-determinism in the output.
   postInstall = ''
-    rm $doc/share/doc/groff/examples/hdtbl/*color*ps
-    find $doc/share/doc/groff/ -type f -print0 | xargs -0 sed -i -e 's/%%CreationDate: .*//'
+    rm "$doc"/share/doc/groff/examples/hdtbl/*color*ps
+    find "$doc"/share/doc/groff/ -type f -print0 | xargs -0 sed -i -e 's/%%CreationDate: .*//'
+    for f in 'man.local' 'mdoc.local'; do
+        cat '${./site.tmac}' >>"$out/share/groff/site-tmac/$f"
+    done
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/tools/text/groff/site.tmac b/pkgs/tools/text/groff/site.tmac
new file mode 100644
index 000000000000..8ef1040ca4a0
--- /dev/null
+++ b/pkgs/tools/text/groff/site.tmac
@@ -0,0 +1,16 @@
+.
+.if n \{\
+.  \" Character translations for non-keyboard
+.  \" characters - to make them searchable
+.  if '\*[.T]'utf8' \{\
+.    char \- \N'45'
+.    char - \N'45'
+.    char ' \N'39'
+.    char \' \N'39'
+.  \}
+.
+.  \" Shut off SGR by default (groff colors)
+.  \" Require GROFF_SGR envvar defined to turn it on
+.  if '\V[GROFF_SGR]'' \
+.    output x X tty: sgr 0
+.\}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index f49741b320b3..b62908e2798b 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -185,8 +185,10 @@ with pkgs;
 
   fetchzip = callPackage ../build-support/fetchzip { };
 
+  gitRepoToName = callPackage ../build-support/fetchgit/gitrepotoname.nix { };
+
   fetchFromGitHub = {
-    owner, repo, rev, name ? "${repo}-${rev}-src",
+    owner, repo, rev, name ? gitRepoToName repo rev,
     fetchSubmodules ? false, private ? false,
     githubBase ? "github.com", varPrefix ? null,
     ... # For hash agility
@@ -223,7 +225,7 @@ with pkgs;
     } // passthruAttrs) // { inherit rev; };
 
   fetchFromBitbucket = {
-    owner, repo, rev, name ? "${repo}-${rev}-src",
+    owner, repo, rev, name ? gitRepoToName repo rev,
     ... # For hash agility
   }@args: fetchzip ({
     inherit name;
@@ -234,7 +236,7 @@ with pkgs;
 
   # cgit example, snapshot support is optional in cgit
   fetchFromSavannah = {
-    repo, rev, name ? "${repo}-${rev}-src",
+    repo, rev, name ? gitRepoToName repo rev,
     ... # For hash agility
   }@args: fetchzip ({
     inherit name;
@@ -244,7 +246,7 @@ with pkgs;
 
   # gitlab example
   fetchFromGitLab = {
-    owner, repo, rev, name ? "${repo}-${rev}-src",
+    owner, repo, rev, name ? gitRepoToName repo rev,
     ... # For hash agility
   }@args: fetchzip ({
     inherit name;
@@ -254,7 +256,7 @@ with pkgs;
 
   # gitweb example, snapshot support is optional in gitweb
   fetchFromRepoOrCz = {
-    repo, rev, name ? "${repo}-${rev}-src",
+    repo, rev, name ? gitRepoToName repo rev,
     ... # For hash agility
   }@args: fetchzip ({
     inherit name;
@@ -543,6 +545,8 @@ with pkgs;
 
   enpass = callPackage ../tools/security/enpass { };
 
+  ezstream = callPackage ../tools/audio/ezstream { };
+
   genymotion = callPackage ../development/mobile/genymotion { };
 
   grc = callPackage ../tools/misc/grc { };
@@ -5030,6 +5034,8 @@ with pkgs;
 
   fish-foreign-env = callPackage ../shells/fish-foreign-env { };
 
+  ion = callPackage ../shells/ion { };
+
   mksh = callPackage ../shells/mksh { };
 
   oh = callPackage ../shells/oh { };
@@ -6038,8 +6044,14 @@ with pkgs;
 
   inherit (beam.interpreters)
     erlang erlang_odbc erlang_javac erlang_odbc_javac
-    erlangR17 erlangR18 erlangR19 erlangR20
-    erlang_basho_R16B02 elixir lfe;
+    elixir elixir_1_5_rc elixir_1_4 elixir_1_3
+    lfe
+    erlangR16 erlangR16_odbc
+    erlang_basho_R16B02 erlang_basho_R16B02_odbc
+    erlangR17 erlangR17_odbc erlangR17_javac erlangR17_odbc_javac
+    erlangR18 erlangR18_odbc erlangR18_javac erlangR18_odbc_javac
+    erlangR19 erlangR19_odbc erlangR19_javac erlangR19_odbc_javac
+    erlangR20 erlangR20_odbc erlangR20_javac erlangR20_odbc_javac;
 
   inherit (beam.packages.erlang)
     rebar rebar3-open rebar3
@@ -15724,7 +15736,7 @@ with pkgs;
   };
 
   qutebrowser = libsForQt5.callPackage ../applications/networking/browsers/qutebrowser {
-    inherit (python3Packages) buildPythonApplication pyqt5 jinja2 pygments pyyaml pypeg2 cssutils;
+    inherit (python3Packages) buildPythonApplication pyqt5 jinja2 pygments pyyaml pypeg2 cssutils pyopengl;
     inherit (gst_all_1) gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav;
   };
 
@@ -18099,6 +18111,8 @@ with pkgs;
 
   picosat = callPackage ../applications/science/logic/picosat {};
 
+  libpoly = callPackage ../applications/science/logic/poly/default.nix {};
+
   prooftree = (with ocamlPackages_4_01_0;
     callPackage  ../applications/science/logic/prooftree {
       camlp5 = camlp5_transitional;
diff --git a/pkgs/top-level/beam-packages.nix b/pkgs/top-level/beam-packages.nix
index acdbea673328..8d01ad36139d 100644
--- a/pkgs/top-level/beam-packages.nix
+++ b/pkgs/top-level/beam-packages.nix
@@ -56,7 +56,8 @@ rec {
     # Other Beam languages. These are built with `beam.interpreters.erlang`. To
     # access for example elixir built with different version of Erlang, use
     # `beam.packages.erlangR19.elixir`.
-    elixir = packages.erlang.elixir;
+    inherit (packages.erlang) elixir elixir_1_5_rc elixir_1_4 elixir_1_3;
+
     lfe = packages.erlang.lfe;
   };
 
diff --git a/pkgs/top-level/lua-packages.nix b/pkgs/top-level/lua-packages.nix
index 71aef7544dd1..f33b397958ca 100644
--- a/pkgs/top-level/lua-packages.nix
+++ b/pkgs/top-level/lua-packages.nix
@@ -311,24 +311,23 @@ let
 
   lrexlib = buildLuaPackage rec {
     name = "lrexlib-${version}";
-    version = "2.7.2";
+    version = "2.8.0";
     src = fetchzip {
-      url = "https://github.com/rrthomas/lrexlib/archive/150c251be57c4e569da0f48bf6b01fbca97179fe.zip";
-      sha256 = "0acb3258681bjq61piz331r99bdff6cnkjaigq5phg3699iz5h75";
+      url = "https://github.com/rrthomas/lrexlib/archive/rel-2-8-0.zip";
+      sha256 = "1c62ny41b1ih6iddw5qn81gr6dqwfffzdp7q6m8x09zzcdz78zhr";
     };
     buildInputs = [ unzip luastdlib pcre luarocks oniguruma gnulib tre glibc ];
 
     buildPhase = let
-      luaVariable = "LUA_PATH=${luastdlib}/share/lua/${lua.luaversion}/?.lua";
+      luaVariable = ''LUA_PATH="${luastdlib}/share/lua/${lua.luaversion}/?/init.lua;${luastdlib}/share/lua/${lua.luaversion}/?.lua"'';
 
-      pcreVariable = "PCRE_DIR=${pcre.dev}";
+      pcreVariable = "PCRE_DIR=${pcre.out} PCRE_INCDIR=${pcre.dev}/include";
       onigVariable = "ONIG_DIR=${oniguruma}";
       gnuVariable = "GNU_INCDIR=${gnulib}/lib";
       treVariable = "TRE_DIR=${tre}";
       posixVariable = "POSIX_DIR=${glibc.dev}";
     in ''
-      sed -e 's@$(LUAROCKS) $(LUAROCKS_COMMAND) $$i;@$(LUAROCKS) $(LUAROCKS_COMMAND) $$i ${pcreVariable} ${onigVariable} ${gnuVariable} ${treVariable} ${posixVariable};@' \
-          -i Makefile
+      sed -e 's@$(LUAROCKS) $(LUAROCKS_COMMAND) $$i;@$(LUAROCKS) $(LUAROCKS_COMMAND) $$i ${pcreVariable} ${onigVariable} ${gnuVariable} ${treVariable} ${posixVariable};@' -i Makefile
       ${luaVariable} make
     '';
 
@@ -341,7 +340,6 @@ let
       homepage = "https://github.com/lua-stdlib/lua-stdlib/";
       platforms = stdenv.lib.platforms.linux;
       license = stdenv.lib.licenses.mit;
-      broken = true;
     };
   };