summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/compilers/gcc/7/default.nix19
-rw-r--r--pkgs/development/compilers/gcc/7/riscv-no-relax.patch109
-rw-r--r--pkgs/development/compilers/ghc/8.2.2.nix2
-rw-r--r--pkgs/development/compilers/ghc/8.4.1.nix5
-rw-r--r--pkgs/development/compilers/ghc/abi-depends-determinism.nix10
-rw-r--r--pkgs/development/compilers/go/1.10.nix3
-rw-r--r--pkgs/development/compilers/go/1.9.nix3
-rw-r--r--pkgs/development/compilers/rust/default.nix10
-rw-r--r--pkgs/development/compilers/rust/rustc.nix6
-rw-r--r--pkgs/development/compilers/vala/default.nix4
-rw-r--r--pkgs/development/compilers/zig/default.nix11
-rw-r--r--pkgs/development/interpreters/guile/2.0.nix16
-rw-r--r--pkgs/development/interpreters/guile/default.nix16
-rw-r--r--pkgs/development/interpreters/lua-5/5.2.nix31
-rw-r--r--pkgs/development/interpreters/lua-5/5.3.nix31
-rw-r--r--pkgs/development/libraries/SDL_gfx/default.nix4
-rw-r--r--pkgs/development/libraries/acl/default.nix2
-rw-r--r--pkgs/development/libraries/at-spi2-core/default.nix3
-rw-r--r--pkgs/development/libraries/atk/default.nix5
-rw-r--r--pkgs/development/libraries/attr/default.nix6
-rw-r--r--pkgs/development/libraries/cairo/default.nix5
-rw-r--r--pkgs/development/libraries/celt/0.5.1.nix7
-rw-r--r--pkgs/development/libraries/celt/generic.nix3
-rw-r--r--pkgs/development/libraries/cogl/default.nix12
-rw-r--r--pkgs/development/libraries/cracklib/default.nix4
-rw-r--r--pkgs/development/libraries/fontconfig/default.nix20
-rw-r--r--pkgs/development/libraries/freetype/cve-2017-8105.patch27
-rw-r--r--pkgs/development/libraries/freetype/cve-2017-8287.patch22
-rw-r--r--pkgs/development/libraries/freetype/default.nix26
-rw-r--r--pkgs/development/libraries/freetype/pcf-config-long-family-names.patch553
-rw-r--r--pkgs/development/libraries/freetype/pcf-introduce-driver.patch68
-rw-r--r--pkgs/development/libraries/gdk-pixbuf/default.nix5
-rw-r--r--pkgs/development/libraries/gegl/3.0.nix6
-rw-r--r--pkgs/development/libraries/gegl/default.nix8
-rw-r--r--pkgs/development/libraries/geoclue/2.0.nix7
-rw-r--r--pkgs/development/libraries/gettext/default.nix1
-rw-r--r--pkgs/development/libraries/gettext/gettext-setup-hook.sh21
-rw-r--r--pkgs/development/libraries/glib-networking/default.nix1
-rw-r--r--pkgs/development/libraries/glib/default.nix15
-rw-r--r--pkgs/development/libraries/glibc/2.27.nix101
-rw-r--r--pkgs/development/libraries/glibc/common-2.27.nix216
-rw-r--r--pkgs/development/libraries/glibc/common.nix41
-rw-r--r--pkgs/development/libraries/glibc/dont-use-system-ld-so-cache-2.27.patch46
-rw-r--r--pkgs/development/libraries/glibc/dont-use-system-ld-so-cache.patch38
-rw-r--r--pkgs/development/libraries/glibc/nix-locale-archive-2.27.patch118
-rw-r--r--pkgs/development/libraries/glibc/nix-locale-archive.patch122
-rw-r--r--pkgs/development/libraries/gnu-efi/default.nix4
-rw-r--r--pkgs/development/libraries/gnutls/generic.nix4
-rw-r--r--pkgs/development/libraries/gobject-introspection/default.nix5
-rw-r--r--pkgs/development/libraries/gstreamer/bad/default.nix6
-rw-r--r--pkgs/development/libraries/gstreamer/base/default.nix7
-rw-r--r--pkgs/development/libraries/gstreamer/default.nix3
-rw-r--r--pkgs/development/libraries/gstreamer/good/default.nix7
-rw-r--r--pkgs/development/libraries/gstreamer/legacy/gst-plugins-base/default.nix7
-rw-r--r--pkgs/development/libraries/gstreamer/legacy/gst-plugins-good/default.nix7
-rw-r--r--pkgs/development/libraries/gstreamer/legacy/gst-plugins-ugly/default.nix6
-rw-r--r--pkgs/development/libraries/gstreamer/legacy/gstreamer/default.nix6
-rw-r--r--pkgs/development/libraries/gstreamer/ugly/default.nix7
-rw-r--r--pkgs/development/libraries/gtk+/2.x.nix5
-rw-r--r--pkgs/development/libraries/gtk+/3.x.nix6
-rw-r--r--pkgs/development/libraries/gts/default.nix2
-rw-r--r--pkgs/development/libraries/harfbuzz/default.nix7
-rw-r--r--pkgs/development/libraries/json-glib/default.nix7
-rw-r--r--pkgs/development/libraries/libassuan/default.nix3
-rw-r--r--pkgs/development/libraries/libbsd/cdefs.patch222
-rw-r--r--pkgs/development/libraries/libbsd/default.nix11
-rw-r--r--pkgs/development/libraries/libbsd/features.patch26
-rw-r--r--pkgs/development/libraries/libbsd/non-glibc.patch74
-rw-r--r--pkgs/development/libraries/libglvnd/default.nix20
-rw-r--r--pkgs/development/libraries/libgpg-error/default.nix22
-rw-r--r--pkgs/development/libraries/libgpg-error/riscv.patch54
-rw-r--r--pkgs/development/libraries/libgsf/default.nix9
-rw-r--r--pkgs/development/libraries/libgtop/default.nix5
-rw-r--r--pkgs/development/libraries/libiconv/default.nix2
-rw-r--r--pkgs/development/libraries/libiconv/setup-hook.sh18
-rw-r--r--pkgs/development/libraries/libinfinity/default.nix8
-rw-r--r--pkgs/development/libraries/libksba/default.nix2
-rw-r--r--pkgs/development/libraries/libmicrohttpd/default.nix6
-rw-r--r--pkgs/development/libraries/libnatspec/default.nix1
-rw-r--r--pkgs/development/libraries/libpipeline/default.nix8
-rw-r--r--pkgs/development/libraries/librsvg/default.nix6
-rw-r--r--pkgs/development/libraries/libsecret/default.nix6
-rw-r--r--pkgs/development/libraries/libsoup/default.nix6
-rw-r--r--pkgs/development/libraries/libspatialindex/default.nix2
-rw-r--r--pkgs/development/libraries/libui/default.nix4
-rw-r--r--pkgs/development/libraries/libusb1/default.nix4
-rw-r--r--pkgs/development/libraries/libva/1.0.0.nix9
-rw-r--r--pkgs/development/libraries/libva/default.nix11
-rw-r--r--pkgs/development/libraries/libvdpau/default.nix7
-rw-r--r--pkgs/development/libraries/mesa-glu/default.nix7
-rw-r--r--pkgs/development/libraries/mesa/default.nix80
-rw-r--r--pkgs/development/libraries/ocl-icd/default.nix4
-rw-r--r--pkgs/development/libraries/pango/default.nix4
-rw-r--r--pkgs/development/libraries/pcre/default.nix4
-rw-r--r--pkgs/development/libraries/poppler/default.nix9
-rw-r--r--pkgs/development/libraries/qca2/default.nix6
-rw-r--r--pkgs/development/libraries/qscintilla/default.nix8
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/default.nix1
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/dlopen-absolute-paths.diff26
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtwebengine.nix4
-rw-r--r--pkgs/development/libraries/qwt/6.nix2
-rw-r--r--pkgs/development/libraries/qwt/default.nix2
-rw-r--r--pkgs/development/libraries/science/math/atlas/default.nix6
-rw-r--r--pkgs/development/libraries/science/math/openblas/default.nix2
-rw-r--r--pkgs/development/libraries/spice-gtk/default.nix4
-rw-r--r--pkgs/development/libraries/srtp/default.nix4
-rw-r--r--pkgs/development/libraries/stfl/default.nix3
-rw-r--r--pkgs/development/libraries/ti-rpc/default.nix10
-rw-r--r--pkgs/development/libraries/usbredir/default.nix4
-rw-r--r--pkgs/development/libraries/virglrenderer/default.nix9
-rw-r--r--pkgs/development/libraries/vulkan-loader/default.nix4
-rw-r--r--pkgs/development/libraries/webkitgtk/2.20.nix10
-rw-r--r--pkgs/development/libraries/wlc/default.nix8
-rw-r--r--pkgs/development/libraries/wlroots/default.nix4
-rw-r--r--pkgs/development/mobile/genymotion/default.nix4
-rw-r--r--pkgs/development/perl-modules/generic/builder.sh2
-rw-r--r--pkgs/development/python-modules/numpy/default.nix18
-rw-r--r--pkgs/development/r-modules/generic-builder.nix4
-rw-r--r--pkgs/development/tools/build-managers/cmake/2.8.nix5
-rwxr-xr-xpkgs/development/tools/build-managers/cmake/setup-hook.sh14
-rw-r--r--pkgs/development/tools/build-managers/gnumake/4.2/default.nix2
-rw-r--r--pkgs/development/tools/build-managers/gnumake/4.2/glibc-2.27-glob.patch32
-rw-r--r--pkgs/development/tools/build-managers/gnumake/4.2/glibc-2.27.patch24
-rw-r--r--pkgs/development/tools/build-managers/gnumake/4.2/head.nix69
-rw-r--r--pkgs/development/tools/build-managers/gnumake/4.2/impure-dirs-head.patch31
-rw-r--r--pkgs/development/tools/build-managers/meson/default.nix4
-rw-r--r--pkgs/development/tools/build-managers/meson/overly-strict-size-check.patch12
-rw-r--r--pkgs/development/tools/misc/automake/automake-1.16.x.nix4
-rw-r--r--pkgs/development/tools/misc/binutils/2.30.nix131
-rw-r--r--pkgs/development/tools/misc/binutils/default.nix10
-rw-r--r--pkgs/development/tools/misc/binutils/gold-symbol-visibility.patch79
-rw-r--r--pkgs/development/tools/misc/creduce/default.nix2
-rw-r--r--pkgs/development/tools/misc/csmith/default.nix2
-rw-r--r--pkgs/development/tools/misc/help2man/default.nix28
-rw-r--r--pkgs/development/tools/misc/intel-gpu-tools/default.nix2
-rw-r--r--pkgs/development/tools/misc/lsof/default.nix13
-rw-r--r--pkgs/development/tools/misc/lsof/dfile.patch18
137 files changed, 1142 insertions, 2024 deletions
diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix
index 8e7cd3d3fab..0b19aa95eff 100644
--- a/pkgs/development/compilers/gcc/7/default.nix
+++ b/pkgs/development/compilers/gcc/7/default.nix
@@ -57,16 +57,18 @@ let version = "7.3.0";
     enableParallelBuilding = true;
 
     patches =
-      [ ]
+      [ # https://gcc.gnu.org/ml/gcc-patches/2018-02/msg00633.html
+        ./riscv-pthread-reentrant.patch
+        # https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00297.html
+        ./riscv-no-relax.patch
+      ]
       ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch
       ++ optional noSysDirs ../no-sys-dirs.patch
       ++ optional (hostPlatform != buildPlatform) (fetchpatch { # XXX: Refine when this should be applied
         url = "https://git.busybox.net/buildroot/plain/package/gcc/7.1.0/0900-remove-selftests.patch?id=11271540bfe6adafbc133caf6b5b902a816f5f02";
         sha256 = "0mrvxsdwip2p3l17dscpc1x8vhdsciqw1z5q9i6p5g9yg1cqnmgs";
       })
-      ++ optional langFortran ../gfortran-driving.patch
-         # https://gcc.gnu.org/ml/gcc-patches/2018-02/msg00633.html
-      ++ optional targetPlatform.isRiscV ./riscv-pthread-reentrant.patch;
+      ++ optional langFortran ../gfortran-driving.patch;
 
     javaEcj = fetchurl {
       # The `$(top_srcdir)/ecj.jar' file is automatically picked up at
@@ -212,7 +214,12 @@ stdenv.mkDerivation ({
       --replace "-install_name \\\$rpath/\\\$soname" "-install_name $lib/lib/\\\$soname"
   '';
 
-  postPatch =
+  postPatch = ''
+    configureScripts=$(find . -name configure)
+    for configureScript in $configureScripts; do
+      patchShebangs $configureScript
+    done
+  '' + (
     if (hostPlatform.isHurd
         || (libcCross != null                  # e.g., building `gcc.crossDrv'
             && libcCross ? crossConfig
@@ -271,7 +278,7 @@ stdenv.mkDerivation ({
             sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
         ''
         )
-    else null;
+    else "");
 
   # TODO(@Ericson2314): Make passthru instead. Weird to avoid mass rebuild,
   crossStageStatic = targetPlatform == hostPlatform || crossStageStatic;
diff --git a/pkgs/development/compilers/gcc/7/riscv-no-relax.patch b/pkgs/development/compilers/gcc/7/riscv-no-relax.patch
new file mode 100644
index 00000000000..93d9cd1d60f
--- /dev/null
+++ b/pkgs/development/compilers/gcc/7/riscv-no-relax.patch
@@ -0,0 +1,109 @@
+commit e7c570f37384d824cb9725f237920e9691e57269
+gpg: Signature made Tue 06 Mar 2018 04:52:46 PM PST
+gpg:                using RSA key 00CE76D1834960DFCE886DF8EF4CA1502CCBAB41
+gpg:                issuer "palmer@dabbelt.com"
+gpg: Good signature from "Palmer Dabbelt <palmer@dabbelt.com>" [ultimate]
+gpg:                 aka "Palmer Dabbelt <palmer@sifive.com>" [ultimate]
+Author: Palmer Dabbelt <palmer@sifive.com>
+Date:   Thu Mar 1 12:01:06 2018 -0800
+
+    RISC-V: Add and document the "-mno-relax" option
+
+    RISC-V relies on aggressive linker relaxation to get good code size.  As
+    a result no text symbol addresses can be known until link time, which
+    means that alignment must be handled during the link.  This alignment
+    pass is essentially just another linker relaxation, so this has the
+    unfortunate side effect that linker relaxation is required for
+    correctness on many RISC-V targets.
+
+    The RISC-V assembler has supported an ".option norelax" for a long time
+    because there are situations in which linker relaxation is a bad idea --
+    the canonical example is when trying to materialize the initial value of
+    the global pointer into a register, which would otherwise be relaxed to
+    a NOP.  We've been relying on users who want to disable relaxation for
+    an entire link to pass "-Wl,--no-relax", but that still relies on the
+    linker relaxing R_RISCV_ALIGN to handle alignment despite it not being
+    strictly necessary.
+
+    This patch adds a GCC option, "-mno-relax", that disable linker
+    relaxation by adding ".option norelax" to the top of every generated
+    assembly file.  The assembler is smart enough to handle alignment at
+    assemble time for files that have never emitted a relaxable relocation,
+    so this is sufficient to really disable all relaxations in the linker,
+    which results in significantly faster link times for large objects.
+
+    This also has the side effect of allowing toolchains that don't support
+    linker relaxation (LLVM and the Linux module loader) to function
+    correctly.  Toolchains that don't support linker relaxation should
+    default to "-mno-relax" and error when presented with any R_RISCV_ALIGN
+    relocation as those need to be handled for correctness.
+
+    gcc/ChangeLog
+
+    2018-03-01  Palmer Dabbelt  <palmer@sifive.com>
+
+            * config/riscv/riscv.opt (mrelax): New option.
+            * config/riscv/riscv.c (riscv_file_start): Emit ".option
+            "norelax" when riscv_mrelax is disabled.
+            * doc/invoke.texi (RISC-V): Document "-mrelax" and "-mno-relax".
+
+diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c
+index c38f6c394d54..3e81874de232 100644
+--- a/gcc/config/riscv/riscv.c
++++ b/gcc/config/riscv/riscv.c
+@@ -3979,6 +3979,11 @@ riscv_file_start (void)
+
+   /* Instruct GAS to generate position-[in]dependent code.  */
+   fprintf (asm_out_file, "\t.option %spic\n", (flag_pic ? "" : "no"));
++
++  /* If the user specifies "-mno-relax" on the command line then disable linker
++     relaxation in the assembler.  */
++  if (! riscv_mrelax)
++    fprintf (asm_out_file, "\t.option norelax\n");
+ }
+
+ /* Implement TARGET_ASM_OUTPUT_MI_THUNK.  Generate rtl rather than asm text
+diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt
+index 581a26bb5c1e..b37ac75d9bb4 100644
+--- a/gcc/config/riscv/riscv.opt
++++ b/gcc/config/riscv/riscv.opt
+@@ -106,6 +106,11 @@ mexplicit-relocs
+ Target Report Mask(EXPLICIT_RELOCS)
+ Use %reloc() operators, rather than assembly macros, to load addresses.
+
++mrelax
++Target Bool Var(riscv_mrelax) Init(1)
++Take advantage of linker relaxations to reduce the number of instructions
++required to materialize symbol addresses.
++
+ Mask(64BIT)
+
+ Mask(MUL)
+diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
+index 8d366c626bae..deb48af2ecad 100644
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -1042,7 +1042,8 @@ See RS/6000 and PowerPC Options.
+ -msave-restore  -mno-save-restore @gol
+ -mstrict-align -mno-strict-align @gol
+ -mcmodel=medlow -mcmodel=medany @gol
+--mexplicit-relocs  -mno-explicit-relocs @gol}
++-mexplicit-relocs  -mno-explicit-relocs @gol
++-mrelax -mno-relax @gol}
+
+ @emph{RL78 Options}
+ @gccoptlist{-msim  -mmul=none  -mmul=g13  -mmul=g14  -mallregs @gol
+@@ -23102,6 +23103,12 @@ Use or do not use assembler relocation operators when dealing with symbolic
+ addresses.  The alternative is to use assembler macros instead, which may
+ limit optimization.
+
++@item -mrelax
++@itemx -mno-relax
++Take advantage of linker relaxations to reduce the number of instructions
++required to materialize symbol addresses. The default is to take advantage of
++linker relaxations.
++
+ @end table
+
+ @node RL78 Options
+
diff --git a/pkgs/development/compilers/ghc/8.2.2.nix b/pkgs/development/compilers/ghc/8.2.2.nix
index 1c3f260da1c..6520daa4d42 100644
--- a/pkgs/development/compilers/ghc/8.2.2.nix
+++ b/pkgs/development/compilers/ghc/8.2.2.nix
@@ -4,6 +4,7 @@
 # build-tools
 , bootPkgs, alex, happy, hscolour
 , autoconf, autoreconfHook, automake, coreutils, fetchurl, fetchpatch, perl, python3, sphinx
+, runCommand
 
 , libffi, libiconv ? null, ncurses
 
@@ -89,6 +90,7 @@ stdenv.mkDerivation rec {
       url = "https://git.haskell.org/ghc.git/commitdiff_plain/2fc8ce5f0c8c81771c26266ac0b150ca9b75c5f3";
       sha256 = "03253ci40np1v6k0wmi4aypj3nmj3rdyvb1k6rwqipb30nfc719f";
     })
+    (import ./abi-depends-determinism.nix { inherit fetchpatch runCommand; })
   ] ++ stdenv.lib.optional deterministicProfiling
     (fetchpatch { # Backport of https://phabricator.haskell.org/D4388 for more determinism
       url = "https://github.com/shlevy/ghc/commit/fec1b8d3555c447c0d8da0e96b659be67c8bb4bc.patch";
diff --git a/pkgs/development/compilers/ghc/8.4.1.nix b/pkgs/development/compilers/ghc/8.4.1.nix
index dd0e5e4b057..df23f660147 100644
--- a/pkgs/development/compilers/ghc/8.4.1.nix
+++ b/pkgs/development/compilers/ghc/8.4.1.nix
@@ -4,6 +4,7 @@
 # build-tools
 , bootPkgs, alex, happy
 , autoconf, automake, coreutils, fetchgit, fetchpatch, perl, python3
+, runCommand
 
 , libffi, libiconv ? null, ncurses
 
@@ -85,7 +86,9 @@ stdenv.mkDerivation rec {
 
   outputs = [ "out" "doc" ];
 
-  patches = stdenv.lib.optional deterministicProfiling
+  patches = [
+    (import ./abi-depends-determinism.nix { inherit fetchpatch runCommand; })
+  ] ++ stdenv.lib.optional deterministicProfiling
     (fetchpatch { # https://phabricator.haskell.org/D4388 for more determinism
       url = "https://github.com/shlevy/ghc/commit/8b2dbd869d1a64de3e99fa8b1c9bb1140eee7099.patch";
       sha256 = "0hxpiwhbg64rsyjdr4psh6dwyp58b96mad3adccvfr0x8hc6ba2m";
diff --git a/pkgs/development/compilers/ghc/abi-depends-determinism.nix b/pkgs/development/compilers/ghc/abi-depends-determinism.nix
new file mode 100644
index 00000000000..afa272d03a8
--- /dev/null
+++ b/pkgs/development/compilers/ghc/abi-depends-determinism.nix
@@ -0,0 +1,10 @@
+# https://phabricator.haskell.org/D4159 to fix non-determinism in
+# cached abi-depends fields in package databases, modified to only
+# contain hunks that exist in distribution tarballs.
+{ fetchpatch, runCommand }: let
+  base = fetchpatch { # Non-determinism in cached abi-depends fields
+    url = https://phabricator-files.haskell.org/file/data/4pqrbo5b62sifktfbrls/PHID-FILE-4g4zjiqlfxmmlaos7lz7/D4159.diff;
+    sha256 = "0b8a08sisf1swmarm6nh9rgw7cpzi2rwdzvrd6ny49c7wk0f7x4b";
+  };
+in runCommand base.name {}
+  "sed -n '/utils\\/ghc-pkg/,$p' ${base} >$out"
diff --git a/pkgs/development/compilers/go/1.10.nix b/pkgs/development/compilers/go/1.10.nix
index 145f6a17978..1be94ba5c6c 100644
--- a/pkgs/development/compilers/go/1.10.nix
+++ b/pkgs/development/compilers/go/1.10.nix
@@ -35,8 +35,7 @@ stdenv.mkDerivation rec {
   };
 
   # perl is used for testing go vet
-  nativeBuildInputs = [ perl which pkgconfig patch makeWrapper ]
-    ++ optionals stdenv.isLinux [ procps ];
+  nativeBuildInputs = [ perl which pkgconfig patch makeWrapper procps ];
   buildInputs = [ cacert pcre ]
     ++ optionals stdenv.isLinux [ stdenv.cc.libc.out ]
     ++ optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ];
diff --git a/pkgs/development/compilers/go/1.9.nix b/pkgs/development/compilers/go/1.9.nix
index c866212170c..47c1d1fdc95 100644
--- a/pkgs/development/compilers/go/1.9.nix
+++ b/pkgs/development/compilers/go/1.9.nix
@@ -35,8 +35,7 @@ stdenv.mkDerivation rec {
   };
 
   # perl is used for testing go vet
-  nativeBuildInputs = [ perl which pkgconfig patch makeWrapper ]
-    ++ optionals stdenv.isLinux [ procps ];
+  nativeBuildInputs = [ perl which pkgconfig patch makeWrapper procps ];
   buildInputs = [ cacert pcre ]
     ++ optionals stdenv.isLinux [ stdenv.cc.libc.out ]
     ++ optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ];
diff --git a/pkgs/development/compilers/rust/default.nix b/pkgs/development/compilers/rust/default.nix
index dd15580c11b..fd19a38ead2 100644
--- a/pkgs/development/compilers/rust/default.nix
+++ b/pkgs/development/compilers/rust/default.nix
@@ -1,4 +1,5 @@
 { stdenv, callPackage, recurseIntoAttrs, makeRustPlatform, llvm, fetchurl
+, fetchpatch
 , targets ? []
 , targetToolchains ? []
 , targetPatches ? []
@@ -6,11 +7,11 @@
 
 let
   rustPlatform = recurseIntoAttrs (makeRustPlatform (callPackage ./bootstrap.nix {}));
-  version = "1.24.0";
+  version = "1.24.1";
   cargoVersion = "0.24.0";
   src = fetchurl {
     url = "https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz";
-    sha256 = "17v3jpyky8vkkgai5yd2zr8zl87qpgj6dx99gx27x1sf0kv7d0mv";
+    sha256 = "1vv10x2h9kq7fxh2v01damdq8pvlp5acyh1kzcda9sfjx12kv99y";
   };
 in rec {
   rustc = callPackage ./rustc.nix {
@@ -22,6 +23,11 @@ in rec {
 
     patches = [
       ./patches/0001-Disable-fragile-tests-libstd-net-tcp-on-Darwin-Linux.patch
+      # Adapted from https://github.com/rust-lang/rust/pull/47912
+      (fetchpatch {
+        url = "https://src.fedoraproject.org/rpms/rust/raw/1bb4d24c060915c304c9a9f86a438388e599f9c6/f/0002-Use-a-range-to-identify-SIGSEGV-in-stack-guards.patch";
+        sha256 = "16hc170qzzcb9lcabk0ln005zji2h1gq0knbr9avbbzlbg9jha2q";
+      })
     ] ++ stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch
       # https://github.com/rust-lang/rust/issues/45410
       ++ stdenv.lib.optional stdenv.isAarch64 ./patches/aarch64-disable-test_loading_cosine.patch;
diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix
index 92b149865fa..f678286eade 100644
--- a/pkgs/development/compilers/rust/rustc.nix
+++ b/pkgs/development/compilers/rust/rustc.nix
@@ -1,5 +1,5 @@
 { stdenv, targetPackages
-, fetchurl, fetchgit, fetchzip, file, python2, tzdata, procps
+, fetchurl, fetchgit, fetchzip, file, python2, tzdata, ps
 , llvm, jemalloc, ncurses, darwin, rustPlatform, git, cmake, curl
 , which, libffi, gdb
 , version
@@ -19,8 +19,6 @@ let
   inherit (stdenv.lib) optional optionalString;
   inherit (darwin.apple_sdk.frameworks) Security;
 
-  procps = if stdenv.isDarwin then darwin.ps else args.procps;
-
   llvmShared = llvm.override { enableSharedLibraries = true; };
 
   target = builtins.replaceStrings [" "] [","] (builtins.toString targets);
@@ -127,7 +125,7 @@ stdenv.mkDerivation {
 
   # ps is needed for one of the test cases
   nativeBuildInputs =
-    [ file python2 procps rustPlatform.rust.rustc git cmake
+    [ file python2 ps rustPlatform.rust.rustc git cmake
       which libffi
     ]
     # Only needed for the debuginfo tests
diff --git a/pkgs/development/compilers/vala/default.nix b/pkgs/development/compilers/vala/default.nix
index 6a020e11a4b..f36bea42e2a 100644
--- a/pkgs/development/compilers/vala/default.nix
+++ b/pkgs/development/compilers/vala/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, pkgconfig, flex, bison, libxslt, autoconf, graphviz
-, glib, libiconv, libintlOrEmpty, libtool, expat
+, glib, libiconv, libintl, libtool, expat
 }:
 
 let
@@ -16,7 +16,7 @@ let
 
     nativeBuildInputs = [ pkgconfig flex bison libxslt ] ++ extraNativeBuildInputs;
 
-    buildInputs = [ glib libiconv ] ++ libintlOrEmpty ++ extraBuildInputs;
+    buildInputs = [ glib libiconv libintl ] ++ extraBuildInputs;
 
     meta = with stdenv.lib; {
       description = "Compiler for GObject type system";
diff --git a/pkgs/development/compilers/zig/default.nix b/pkgs/development/compilers/zig/default.nix
index cffc683f9e7..44d1f7bfe4a 100644
--- a/pkgs/development/compilers/zig/default.nix
+++ b/pkgs/development/compilers/zig/default.nix
@@ -1,17 +1,18 @@
-{ stdenv, fetchFromGitHub, cmake, llvmPackages }:
+{ stdenv, fetchFromGitHub, cmake, llvmPackages, libxml2 }:
 
 stdenv.mkDerivation rec {
-  version = "0.1.1";
+  version = "0.2.0";
   name = "zig-${version}";
 
   src = fetchFromGitHub {
     owner = "zig-lang";
     repo = "zig";
     rev = "${version}";
-    sha256 = "01yqjyi25f99bfmxxwyh45k7j84z0zg7n9jl8gg0draf96mzdh06";
+    sha256 = "0lym28z9mj6hfiq78x1fsd8y89h8xyfc1jgqyazi1g9r72427n07";
   };
 
-  buildInputs = [ cmake llvmPackages.clang-unwrapped llvmPackages.llvm ];
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ llvmPackages.clang-unwrapped llvmPackages.llvm libxml2 ];
 
   cmakeFlags = [
     "-DZIG_LIBC_INCLUDE_DIR=${stdenv.cc.libc_dev}/include"
@@ -26,7 +27,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "Programming languaged designed for robustness, optimality, and clarity";
-    homepage = http://ziglang.org/;
+    homepage = https://ziglang.org/;
     license = licenses.mit;
     platforms = platforms.unix;
     maintainers = [ maintainers.andrewrk ];
diff --git a/pkgs/development/interpreters/guile/2.0.nix b/pkgs/development/interpreters/guile/2.0.nix
index afd90397e23..2c9aec5b695 100644
--- a/pkgs/development/interpreters/guile/2.0.nix
+++ b/pkgs/development/interpreters/guile/2.0.nix
@@ -27,12 +27,15 @@
   nativeBuildInputs = [ makeWrapper gawk pkgconfig ];
   buildInputs = [ readline libtool libunistring libffi ];
 
-  propagatedBuildInputs = [ gmp boehmgc ]
-    # XXX: These ones aren't normally needed here, but since
-    # `libguile-2.0.la' reads `-lltdl -lunistring', adding them here will add
+  propagatedBuildInputs = [
+    gmp boehmgc
+
+    # XXX: These ones aren't normally needed here, but `libguile*.la' has '-l'
+    # flags for them without corresponding '-L' flags. Adding them here will add
     # the needed `-L' flags.  As for why the `.la' file lacks the `-L' flags,
     # see below.
-    ++ [ libtool libunistring ];
+    libtool libunistring
+  ];
 
   enableParallelBuilding = true;
 
@@ -70,11 +73,12 @@
 
   postInstall = ''
     wrapProgram $out/bin/guile-snarf --prefix PATH : "${gawk}/bin"
-
+  ''
     # XXX: See http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/18903 for
     # why `--with-libunistring-prefix' and similar options coming from
     # `AC_LIB_LINKFLAGS_BODY' don't work on NixOS/x86_64.
-    sed -i "$out/lib/pkgconfig/guile-2.0.pc"    \
+  + ''
+    sed -i "$out/lib/pkgconfig/guile"-*.pc    \
         -e "s|-lunistring|-L${libunistring}/lib -lunistring|g ;
             s|^Cflags:\(.*\)$|Cflags: -I${libunistring}/include \1|g ;
             s|-lltdl|-L${libtool.lib}/lib -lltdl|g ;
diff --git a/pkgs/development/interpreters/guile/default.nix b/pkgs/development/interpreters/guile/default.nix
index dc6e18ae1af..3d5c51dc420 100644
--- a/pkgs/development/interpreters/guile/default.nix
+++ b/pkgs/development/interpreters/guile/default.nix
@@ -28,12 +28,15 @@
   nativeBuildInputs = [ makeWrapper gawk pkgconfig ];
   buildInputs = [ readline libtool libunistring libffi ];
 
-  propagatedBuildInputs = [ gmp boehmgc ]
-    # XXX: These ones aren't normally needed here, but since
-    # `libguile-2.0.la' reads `-lltdl -lunistring', adding them here will add
+  propagatedBuildInputs = [
+    gmp boehmgc
+
+    # XXX: These ones aren't normally needed here, but `libguile*.la' has '-l'
+    # flags for them without corresponding '-L' flags. Adding them here will add
     # the needed `-L' flags.  As for why the `.la' file lacks the `-L' flags,
     # see below.
-    ++ [ libtool libunistring ];
+    libtool libunistring
+  ];
 
   enableParallelBuilding = true;
 
@@ -66,11 +69,12 @@
 
   postInstall = ''
     wrapProgram $out/bin/guile-snarf --prefix PATH : "${gawk}/bin"
-
+  ''
     # XXX: See http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/18903 for
     # why `--with-libunistring-prefix' and similar options coming from
     # `AC_LIB_LINKFLAGS_BODY' don't work on NixOS/x86_64.
-    sed -i "$out/lib/pkgconfig/guile-2.2.pc"    \
+  + ''
+    sed -i "$out/lib/pkgconfig/guile"-*.pc    \
         -e "s|-lunistring|-L${libunistring}/lib -lunistring|g ;
             s|^Cflags:\(.*\)$|Cflags: -I${libunistring}/include \1|g ;
             s|-lltdl|-L${libtool.lib}/lib -lltdl|g ;
diff --git a/pkgs/development/interpreters/lua-5/5.2.nix b/pkgs/development/interpreters/lua-5/5.2.nix
index 0cdc4770a98..acddbcfd303 100644
--- a/pkgs/development/interpreters/lua-5/5.2.nix
+++ b/pkgs/development/interpreters/lua-5/5.2.nix
@@ -19,17 +19,17 @@ stdenv.mkDerivation rec {
     sha256 = "0b8034v1s82n4dg5rzcn12067ha3nxaylp2vdp8gg08kjsbzphhk";
   };
 
-  nativeBuildInputs = [ readline ];
+  buildInputs = [ readline ];
 
   patches = if stdenv.isDarwin then [ ./5.2.darwin.patch ] else [ dsoPatch ];
 
   configurePhase =
     if stdenv.isDarwin
     then ''
-    makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=macosx CFLAGS="-DLUA_USE_LINUX -fno-common -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" LDFLAGS="-fPIC" V=${luaversion} R=${version} )
+    makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=macosx CFLAGS="-DLUA_USE_LINUX -fno-common -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" LDFLAGS="-fPIC" V=${luaversion} R=${version}  CC="$CC" )
     installFlagsArray=( TO_BIN="lua luac" TO_LIB="liblua.${version}.dylib" INSTALL_DATA='cp -d' )
   '' else ''
-    makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=linux CFLAGS="-DLUA_USE_LINUX -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" LDFLAGS="-fPIC" V=${luaversion} R=${version} )
+    makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=linux CFLAGS="-DLUA_USE_LINUX -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" LDFLAGS="-fPIC" V=${luaversion} R=${version} CC="$CC" AR="$AR q" RANLIB="$RANLIB" )
     installFlagsArray=( TO_BIN="lua luac" TO_LIB="liblua.a liblua.so liblua.so.${luaversion} liblua.so.${version}" INSTALL_DATA='cp -d' )
   '';
 
@@ -56,31 +56,6 @@ stdenv.mkDerivation rec {
     EOF
   '';
 
-  crossAttrs = let
-    inherit (hostPlatform) isDarwin isMinGW;
-  in {
-    configurePhase = ''
-      makeFlagsArray=(
-        INSTALL_TOP=$out
-        INSTALL_MAN=$out/share/man/man1
-        V=${luaversion}
-        R=${version}
-        ${if isMinGW then "mingw" else stdenv.lib.optionalString isDarwin ''
-        ''}
-      )
-    '' + stdenv.lib.optionalString isMinGW ''
-      installFlagsArray=(
-        TO_BIN="lua.exe luac.exe"
-        TO_LIB="liblua.a lua52.dll"
-        INSTALL_DATA="cp -d"
-      )
-    '';
-  } // stdenv.lib.optionalAttrs isDarwin {
-    postPatch = ''
-      sed -i -e 's/-Wl,-soname[^ ]* *//' src/Makefile
-    '';
-  };
-
   meta = {
     homepage = http://www.lua.org;
     description = "Powerful, fast, lightweight, embeddable scripting language";
diff --git a/pkgs/development/interpreters/lua-5/5.3.nix b/pkgs/development/interpreters/lua-5/5.3.nix
index ad1dfa8823c..7f0703c6288 100644
--- a/pkgs/development/interpreters/lua-5/5.3.nix
+++ b/pkgs/development/interpreters/lua-5/5.3.nix
@@ -12,17 +12,17 @@ stdenv.mkDerivation rec {
     sha256 = "0320a8dg3aci4hxla380dx1ifkw8gj4gbw5c4dz41g1kh98sm0gn";
   };
 
-  nativeBuildInputs = [ readline ];
+  buildInputs = [ readline ];
 
   patches = if stdenv.isDarwin then [ ./5.2.darwin.patch ] else [];
 
   configurePhase =
     if stdenv.isDarwin
     then ''
-    makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=macosx CFLAGS="-DLUA_USE_LINUX -fno-common -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" LDFLAGS="-fPIC" V=${luaversion} R=${version} )
+    makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=macosx CFLAGS="-DLUA_USE_LINUX -fno-common -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" LDFLAGS="-fPIC" V=${luaversion} R=${version}  CC="$CC" )
     installFlagsArray=( TO_BIN="lua luac" TO_LIB="liblua.${version}.dylib" INSTALL_DATA='cp -d' )
   '' else ''
-    makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=linux CFLAGS="-DLUA_USE_LINUX -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" LDFLAGS="-fPIC" V=${luaversion} R=${version})
+    makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=linux CFLAGS="-DLUA_USE_LINUX -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" LDFLAGS="-fPIC" V=${luaversion} R=${version} CC="$CC" AR="$AR q" RANLIB="$RANLIB" )
     installFlagsArray=( TO_BIN="lua luac" TO_LIB="liblua.a liblua.so liblua.so.${luaversion} liblua.so.${version}" INSTALL_DATA='cp -d' )
     cat ${./lua-5.3-dso.make} >> src/Makefile
     sed -e 's/ALL_T *= */& $(LUA_SO)/' -i src/Makefile
@@ -55,31 +55,6 @@ stdenv.mkDerivation rec {
     EOF
   '';
 
-  crossAttrs = let
-    inherit (hostPlatform) isDarwin isMinGW;
-  in {
-    configurePhase = ''
-      makeFlagsArray=(
-        INSTALL_TOP=$out
-        INSTALL_MAN=$out/share/man/man1
-        V=${luaversion}
-        R=${version}
-        ${if isMinGW then "mingw" else stdenv.lib.optionalString isDarwin ''
-        ''}
-      )
-    '' + stdenv.lib.optionalString isMinGW ''
-      installFlagsArray=(
-        TO_BIN="lua.exe luac.exe"
-        TO_LIB="liblua.a lua52.dll"
-        INSTALL_DATA="cp -d"
-      )
-    '';
-  } // stdenv.lib.optionalAttrs isDarwin {
-    postPatch = ''
-      sed -i -e 's/-Wl,-soname[^ ]* *//' src/Makefile
-    '';
-  };
-
   meta = {
     homepage = http://www.lua.org;
     description = "Powerful, fast, lightweight, embeddable scripting language";
diff --git a/pkgs/development/libraries/SDL_gfx/default.nix b/pkgs/development/libraries/SDL_gfx/default.nix
index 1d7d96f7536..83a2ffc077c 100644
--- a/pkgs/development/libraries/SDL_gfx/default.nix
+++ b/pkgs/development/libraries/SDL_gfx/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "SDL_gfx-${version}";
-  version = "2.0.25";
+  version = "2.0.26";
 
   src = fetchurl {
     url = "http://www.ferzkopp.net/Software/SDL_gfx-2.0/${name}.tar.gz";
-    sha256 = "1h2rj34dxi5xlwpvm293v2d91gsirhnpzlmnjns9xwkcdg0fsvjm";
+    sha256 = "0ijljhs0v99dj6y27hc10z6qchyp8gdp4199y6jzngy6dzxlzsvw";
   };
 
   buildInputs = [ SDL ] ;
diff --git a/pkgs/development/libraries/acl/default.nix b/pkgs/development/libraries/acl/default.nix
index 3c6f42e5cbf..f9bb982a784 100644
--- a/pkgs/development/libraries/acl/default.nix
+++ b/pkgs/development/libraries/acl/default.nix
@@ -18,6 +18,8 @@ stdenv.mkDerivation rec {
   patchPhase = ''
     echo "Removing C++-style comments from include/acl.h"
     sed -e '/^\/\//d' -i include/acl.h
+
+    patchShebangs .
   '';
 
   configureFlags = [ "MAKE=make" "MSGFMT=msgfmt" "MSGMERGE=msgmerge" "XGETTEXT=xgettext" "ZIP=gzip" "ECHO=echo" "SED=sed" "AWK=gawk" ];
diff --git a/pkgs/development/libraries/at-spi2-core/default.nix b/pkgs/development/libraries/at-spi2-core/default.nix
index b717101b3e1..6715a59579b 100644
--- a/pkgs/development/libraries/at-spi2-core/default.nix
+++ b/pkgs/development/libraries/at-spi2-core/default.nix
@@ -23,10 +23,7 @@ stdenv.mkDerivation rec {
   # ToDo: on non-NixOS we create a symlink from there?
   configureFlags = "--with-dbus-daemondir=/run/current-system/sw/bin/";
 
-  NIX_LDFLAGS = with stdenv; lib.optionalString isDarwin "-lintl";
-
   meta = with stdenv.lib; {
     platforms = platforms.unix;
   };
 }
-
diff --git a/pkgs/development/libraries/atk/default.nix b/pkgs/development/libraries/atk/default.nix
index efbc94457bf..63fd7a4986f 100644
--- a/pkgs/development/libraries/atk/default.nix
+++ b/pkgs/development/libraries/atk/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, meson, ninja, gettext, pkgconfig, glib
-, fixDarwinDylibNames, libintlOrEmpty, gobjectIntrospection, gnome3
+, fixDarwinDylibNames, gobjectIntrospection, gnome3
 }:
 
 let
@@ -25,8 +25,7 @@ stdenv.mkDerivation rec {
 
   outputs = [ "out" "dev" ];
 
-  buildInputs = libintlOrEmpty
-    ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
+  buildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
   nativeBuildInputs = [ meson ninja pkgconfig gettext gobjectIntrospection ];
 
diff --git a/pkgs/development/libraries/attr/default.nix b/pkgs/development/libraries/attr/default.nix
index 0bfeaf81a81..96fe5b89a18 100644
--- a/pkgs/development/libraries/attr/default.nix
+++ b/pkgs/development/libraries/attr/default.nix
@@ -18,6 +18,12 @@ stdenv.mkDerivation rec {
 
   patches = if (hostPlatform.libc == "musl") then [ ./fix-headers-musl.patch ] else null;
 
+  postPatch = ''
+    for script in install-sh include/install-sh; do
+      patchShebangs $script
+    done
+  '';
+
   meta = with stdenv.lib; {
     homepage = "http://savannah.nongnu.org/projects/attr/";
     description = "Library and tools for manipulating extended attributes";
diff --git a/pkgs/development/libraries/cairo/default.nix b/pkgs/development/libraries/cairo/default.nix
index 6aa184e4204..6a7beb1cc1a 100644
--- a/pkgs/development/libraries/cairo/default.nix
+++ b/pkgs/development/libraries/cairo/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, fetchFromGitHub, fetchpatch, pkgconfig, libiconv
-, libintlOrEmpty, expat, zlib, libpng, pixman, fontconfig, freetype, xorg
+, libintl, expat, zlib, libpng, pixman, fontconfig, freetype, xorg
 , gobjectSupport ? true, glib
 , xcbSupport ? true # no longer experimental since 1.12
 , glSupport ? true, libGL ? null # libGLU_combined is no longer a big dependency
@@ -34,7 +34,8 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [
     pkgconfig
     libiconv
-  ] ++ libintlOrEmpty ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
+    libintl
+  ] ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
     CoreGraphics
     CoreText
     ApplicationServices
diff --git a/pkgs/development/libraries/celt/0.5.1.nix b/pkgs/development/libraries/celt/0.5.1.nix
index 561be1ba281..e45d74345d4 100644
--- a/pkgs/development/libraries/celt/0.5.1.nix
+++ b/pkgs/development/libraries/celt/0.5.1.nix
@@ -7,4 +7,11 @@ callPackage ./generic.nix (args // rec{
     url = "http://downloads.xiph.org/releases/celt/celt-${version}.tar.gz";
     sha256 = "0bkam9z5vnrxpbxkkh9kw6yzjka9di56h11iijikdd1f71l5nbpw";
   };
+
+  # Don't build tests due to badness with ec_ilog
+  prePatch = ''
+    substituteInPlace Makefile.in \
+      --replace 'SUBDIRS = libcelt tests' \
+                'SUBDIRS = libcelt'
+  '';
 })
diff --git a/pkgs/development/libraries/celt/generic.nix b/pkgs/development/libraries/celt/generic.nix
index 4ab554561f7..9d861f2c432 100644
--- a/pkgs/development/libraries/celt/generic.nix
+++ b/pkgs/development/libraries/celt/generic.nix
@@ -1,5 +1,6 @@
 { stdenv, version, src
 , liboggSupport ? true, libogg ? null # if disabled only the library will be built
+, prePatch ? ""
 , ...
 }:
 
@@ -10,6 +11,8 @@ stdenv.mkDerivation rec {
 
   inherit src;
 
+  inherit prePatch;
+
   buildInputs = []
     ++ stdenv.lib.optional liboggSupport libogg;
 
diff --git a/pkgs/development/libraries/cogl/default.nix b/pkgs/development/libraries/cogl/default.nix
index 48b38c22af5..e06c71c15db 100644
--- a/pkgs/development/libraries/cogl/default.nix
+++ b/pkgs/development/libraries/cogl/default.nix
@@ -1,19 +1,20 @@
-{ stdenv, fetchurl, pkgconfig, libGL, glib, gdk_pixbuf, xorg, libintlOrEmpty
+{ stdenv, fetchurl, pkgconfig, libGL, glib, gdk_pixbuf, xorg, libintl
 , pangoSupport ? true, pango, cairo, gobjectIntrospection, wayland, gnome3
+, mesa_noglu
 , gstreamerSupport ? true, gst_all_1 }:
 
 let
   pname = "cogl";
-  version = "1.22.2";
 in stdenv.mkDerivation rec {
   name = "${pname}-${version}";
+  version = "1.22.2";
 
   src = fetchurl {
     url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
     sha256 = "03f0ha3qk7ca0nnkkcr1garrm1n1vvfqhkz9lwjm592fnv6ii9rr";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig libintl ];
 
   configureFlags = [
     "--enable-introspection"
@@ -24,10 +25,9 @@ in stdenv.mkDerivation rec {
     ++ stdenv.lib.optionals (!stdenv.isDarwin) [ "--enable-gles1" "--enable-gles2" ];
 
   propagatedBuildInputs = with xorg; [
-      glib gdk_pixbuf gobjectIntrospection wayland
+      glib gdk_pixbuf gobjectIntrospection wayland mesa_noglu
       libGL libXrandr libXfixes libXcomposite libXdamage
     ]
-    ++ libintlOrEmpty
     ++ stdenv.lib.optionals gstreamerSupport [ gst_all_1.gstreamer
                                                gst_all_1.gst-plugins-base ];
 
@@ -37,8 +37,6 @@ in stdenv.mkDerivation rec {
     = stdenv.lib.optionalString (stdenv.isDarwin && pangoSupport)
       "-I${pango.dev}/include/pango-1.0 -I${cairo.dev}/include/cairo";
 
-  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-lintl";
-
   #doCheck = true; # all tests fail (no idea why)
 
   passthru = {
diff --git a/pkgs/development/libraries/cracklib/default.nix b/pkgs/development/libraries/cracklib/default.nix
index d316b5bf2d1..aa8b4231a86 100644
--- a/pkgs/development/libraries/cracklib/default.nix
+++ b/pkgs/development/libraries/cracklib/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, libintlOrEmpty, zlib, gettext }:
+{ stdenv, fetchurl, zlib, gettext }:
 
 stdenv.mkDerivation rec {
   name = "cracklib-2.9.6";
@@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
     sha256 = "0hrkb0prf7n92w6rxgq0ilzkk6rkhpys2cfqkrbzswp27na7dkqp";
   };
 
-  buildInputs = [ libintlOrEmpty zlib gettext ];
+  buildInputs = [ zlib gettext ];
 
   meta = with stdenv.lib; {
     homepage    = https://github.com/cracklib/cracklib;
diff --git a/pkgs/development/libraries/fontconfig/default.nix b/pkgs/development/libraries/fontconfig/default.nix
index 1109582ad64..29838fe1ffa 100644
--- a/pkgs/development/libraries/fontconfig/default.nix
+++ b/pkgs/development/libraries/fontconfig/default.nix
@@ -1,5 +1,5 @@
 { stdenv, substituteAll, fetchurl, fetchpatch
-, pkgconfig, freetype, expat, libxslt, dejavu_fonts
+, pkgconfig, freetype, expat, libxslt, gperf, dejavu_fonts
 , hostPlatform
 }:
 
@@ -18,11 +18,12 @@ let
   configVersion = "2.11"; # bump whenever fontconfig breaks compatibility with older configurations
 in
 stdenv.mkDerivation rec {
-  name = "fontconfig-2.12.1";
+  name = "fontconfig-${version}";
+  version = "2.12.6";
 
   src = fetchurl {
     url = "http://fontconfig.org/release/${name}.tar.bz2";
-    sha256 = "1wy7svvp7df6bjpg1m5vizb3ngd7rhb20vpclv3x3qa71khs6jdl";
+    sha256 = "05zh65zni11kgnhg726gjbrd55swspdvhqbcnj5a5xh8gn03036g";
   };
 
   patches = [
@@ -30,23 +31,12 @@ stdenv.mkDerivation rec {
       src = ./config-compat.patch;
       inherit configVersion;
     })
-    (fetchpatch {
-      name = "glibc-2.25.diff";
-      url = "https://cgit.freedesktop.org/fontconfig/patch/?id=1ab5258f7c";
-      sha256 = "0x2a4qx51j3gqcp1kp4lisdzmhrkw1zw0r851d82ksgjlc0vkbaz";
-    })
   ];
-  # additionally required for the glibc-2.25 patch; avoid requiring gperf
-  postPatch = ''
-    sed s/CHAR_WIDTH/CHARWIDTH/g -i src/fcobjshash.{h,gperf}
-    sleep 2
-    touch src/fcobjshash.h
-  '';
 
   outputs = [ "bin" "dev" "lib" "out" ]; # $out contains all the config
 
   propagatedBuildInputs = [ freetype ];
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig gperf ];
   buildInputs = [ expat ];
 
   configureFlags = [
diff --git a/pkgs/development/libraries/freetype/cve-2017-8105.patch b/pkgs/development/libraries/freetype/cve-2017-8105.patch
deleted file mode 100644
index dc4327a52a8..00000000000
--- a/pkgs/development/libraries/freetype/cve-2017-8105.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=f958c48ee43
-
-diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c
-index af7b465..7dd4513 100644
---- a/src/psaux/t1decode.c
-+++ b/src/psaux/t1decode.c
-@@ -780,10 +780,19 @@
-             /* point without adding any point to the outline    */
-             idx = decoder->num_flex_vectors++;
-             if ( idx > 0 && idx < 7 )
-+            {
-+              /* in malformed fonts it is possible to have other */
-+              /* opcodes in the middle of a flex (which don't    */
-+              /* increase `num_flex_vectors'); we thus have to   */
-+              /* check whether we can add a point                */
-+              if ( FT_SET_ERROR( t1_builder_check_points( builder, 1 ) ) )
-+                goto Syntax_Error;
-+
-               t1_builder_add_point( builder,
-                                     x,
-                                     y,
-                                     (FT_Byte)( idx == 3 || idx == 6 ) );
-+            }
-           }
-           break;
- 
-
diff --git a/pkgs/development/libraries/freetype/cve-2017-8287.patch b/pkgs/development/libraries/freetype/cve-2017-8287.patch
deleted file mode 100644
index 7ccf4f3278b..00000000000
--- a/pkgs/development/libraries/freetype/cve-2017-8287.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=3774fc08b
-
-diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
-index d18e821..0baf836 100644
---- a/src/psaux/psobjs.c
-+++ b/src/psaux/psobjs.c
-@@ -1718,6 +1718,14 @@
-     first = outline->n_contours <= 1
-             ? 0 : outline->contours[outline->n_contours - 2] + 1;
- 
-+    /* in malformed fonts it can happen that a contour was started */
-+    /* but no points were added                                    */
-+    if ( outline->n_contours && first == outline->n_points )
-+    {
-+      outline->n_contours--;
-+      return;
-+    }
-+
-     /* We must not include the last point in the path if it */
-     /* is located on the first point.                       */
-     if ( outline->n_points > 1 )
-
diff --git a/pkgs/development/libraries/freetype/default.nix b/pkgs/development/libraries/freetype/default.nix
index 8f16f85cabf..3fccce02def 100644
--- a/pkgs/development/libraries/freetype/default.nix
+++ b/pkgs/development/libraries/freetype/default.nix
@@ -1,6 +1,6 @@
 { stdenv, lib, fetchurl, copyPathsToStore
 , hostPlatform
-, pkgconfig, which
+, pkgconfig, which, makeWrapper
 , zlib, bzip2, libpng, gnumake, glib
 
 , # FreeType supports LCD filtering (colloquially referred to as sub-pixel rendering).
@@ -11,10 +11,10 @@
 
 let
   inherit (stdenv.lib) optional optionals optionalString;
-  version = "2.7.1"; name = "freetype-" + version;
 
-in stdenv.mkDerivation {
-  inherit name;
+in stdenv.mkDerivation rec {
+  name = "freetype-${version}";
+  version = "2.9";
 
   meta = with stdenv.lib; {
     description = "A font rendering engine";
@@ -33,24 +33,17 @@ in stdenv.mkDerivation {
 
   src = fetchurl {
     url = "mirror://savannah/freetype/${name}.tar.bz2";
-    sha256 = "121gm15ayfg3rglby8ifh8384mcjb9dhmx9j40zl7yszw72b4frs";
+    sha256 = "12jcdz1in20yaa55izxalg3hm1pf7nydfrzps5bzb4zgihybmzz6";
   };
 
   propagatedBuildInputs = [ zlib bzip2 libpng ]; # needed when linking against freetype
   # dependence on harfbuzz is looser than the reverse dependence
-  nativeBuildInputs = [ pkgconfig which ]
+  nativeBuildInputs = [ pkgconfig which makeWrapper ]
     # FreeType requires GNU Make, which is not part of stdenv on FreeBSD.
     ++ optional (!stdenv.isLinux) gnumake;
 
   patches =
-    [
-      ./pcf-introduce-driver.patch
-      ./pcf-config-long-family-names.patch
-      ./disable-pcf-long-family-names.patch
-      ./enable-table-validation.patch
-      # remove the two CVE patches after updating to >= 2.8
-      ./cve-2017-8105.patch
-      ./cve-2017-8287.patch
+    [ ./enable-table-validation.patch
     ] ++
     optional useEncumberedCode ./enable-subpixel-rendering.patch;
 
@@ -65,7 +58,10 @@ in stdenv.mkDerivation {
 
   doCheck = true;
 
-  postInstall = glib.flattenInclude;
+  postInstall = glib.flattenInclude + ''
+    wrapProgram "$dev/bin/freetype-config" \
+      --set PKG_CONFIG_PATH "$PKG_CONFIG_PATH:$dev/lib/pkgconfig"
+  '';
 
   crossAttrs = stdenv.lib.optionalAttrs (hostPlatform.libc or null != "msvcrt") {
     # Somehow it calls the unwrapped gcc, "i686-pc-linux-gnu-gcc", instead
diff --git a/pkgs/development/libraries/freetype/pcf-config-long-family-names.patch b/pkgs/development/libraries/freetype/pcf-config-long-family-names.patch
deleted file mode 100644
index 95ed83c60f8..00000000000
--- a/pkgs/development/libraries/freetype/pcf-config-long-family-names.patch
+++ /dev/null
@@ -1,553 +0,0 @@
-diff --git a/devel/ftoption.h b/devel/ftoption.h
-index 3b63931..b8b0a8d 100644
---- a/devel/ftoption.h
-+++ b/devel/ftoption.h
-@@ -82,8 +82,8 @@ FT_BEGIN_HEADER
-   /* to control the various font drivers and modules.  The controllable    */
-   /* properties are listed in the section `Controlling FreeType Modules'   */
-   /* in the reference's table of contents; currently there are properties  */
--  /* for the auto-hinter (file `ftautoh.h'), CFF (file `ftcffdrv.h'), and  */
--  /* TrueType (file `ftttdrv.h').                                          */
-+  /* for the auto-hinter (file `ftautoh.h'), CFF (file `ftcffdrv.h'),      */
-+  /* TrueType (file `ftttdrv.h'), and PCF (file `ftpcfdrv.h').             */
-   /*                                                                       */
-   /* `FREETYPE_PROPERTIES' has the following syntax form (broken here into */
-   /* multiple lines for better readability).                               */
-@@ -835,6 +835,33 @@ FT_BEGIN_HEADER
-   /*************************************************************************/
-   /*************************************************************************/
-   /****                                                                 ****/
-+  /****         P C F   D R I V E R    C O N F I G U R A T I O N        ****/
-+  /****                                                                 ****/
-+  /*************************************************************************/
-+  /*************************************************************************/
-+
-+
-+  /*************************************************************************/
-+  /*                                                                       */
-+  /* There are many PCF fonts just called `Fixed' which look completely    */
-+  /* different, and which have nothing to do with each other.  When        */
-+  /* selecting `Fixed' in KDE or Gnome one gets results that appear rather */
-+  /* random, the style changes often if one changes the size and one       */
-+  /* cannot select some fonts at all.  This option makes the PCF module    */
-+  /* prepend the foundry name (plus a space) to the family name.           */
-+  /*                                                                       */
-+  /* We also check whether we have `wide' characters; all put together, we */
-+  /* get family names like `Sony Fixed' or `Misc Fixed Wide'.              */
-+  /*                                                                       */
-+  /* If this option is activated, it can be controlled with the            */
-+  /* `no-long-family-names' property of the pcf driver module.             */
-+  /*                                                                       */
-+#define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
-+
-+
-+  /*************************************************************************/
-+  /*************************************************************************/
-+  /****                                                                 ****/
-   /****    A U T O F I T   M O D U L E    C O N F I G U R A T I O N     ****/
-   /****                                                                 ****/
-   /*************************************************************************/
-diff --git a/docs/CHANGES b/docs/CHANGES
-index cb3b327..3823395 100644
---- a/docs/CHANGES
-+++ b/docs/CHANGES
-@@ -1,4 +1,20 @@
- 
-+CHANGES BETWEEN 2.7.1 and 2.7.2
-+
-+  I. IMPORTANT CHANGES
-+
-+    - The PCF change to show more `colourful' family names (introduced
-+      in version 2.7.1) was too radical; it can now be configured with
-+      PCF_CONFIG_OPTION_LONG_FAMILY_NAMES   at   compile   time.    If
-+      activated, it can  be switched off at run time  with the new pcf
-+      property  `no-long-family-names'.  If  the `FREETYPE_PROPERTIES'
-+      environment variable is available, you can say
-+
-+        FREETYPE_PROPERTIES=pcf:no-long-family-names=1
-+
-+
-+======================================================================
-+
- CHANGES BETWEEN 2.7 and 2.7.1
- 
-   I. IMPORTANT CHANGES
-diff --git a/include/freetype/config/ftheader.h b/include/freetype/config/ftheader.h
-index 950d36c..d491af5 100644
---- a/include/freetype/config/ftheader.h
-+++ b/include/freetype/config/ftheader.h
-@@ -357,6 +357,19 @@
-   /*************************************************************************
-    *
-    * @macro:
-+   *   FT_PCF_DRIVER_H
-+   *
-+   * @description:
-+   *   A macro used in #include statements to name the file containing
-+   *   structures and macros related to the PCF driver module.
-+   *
-+   */
-+#define FT_PCF_DRIVER_H  <freetype/ftpcfdrv.h>
-+
-+
-+  /*************************************************************************
-+   *
-+   * @macro:
-    *   FT_TYPE1_TABLES_H
-    *
-    * @description:
-diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
-index f5bc540..5676074 100644
---- a/include/freetype/config/ftoption.h
-+++ b/include/freetype/config/ftoption.h
-@@ -82,8 +82,8 @@ FT_BEGIN_HEADER
-   /* to control the various font drivers and modules.  The controllable    */
-   /* properties are listed in the section `Controlling FreeType Modules'   */
-   /* in the reference's table of contents; currently there are properties  */
--  /* for the auto-hinter (file `ftautoh.h'), CFF (file `ftcffdrv.h'), and  */
--  /* TrueType (file `ftttdrv.h').                                          */
-+  /* for the auto-hinter (file `ftautoh.h'), CFF (file `ftcffdrv.h'),      */
-+  /* TrueType (file `ftttdrv.h'), and PCF (file `ftpcfdrv.h').             */
-   /*                                                                       */
-   /* `FREETYPE_PROPERTIES' has the following syntax form (broken here into */
-   /* multiple lines for better readability).                               */
-@@ -835,6 +835,33 @@ FT_BEGIN_HEADER
-   /*************************************************************************/
-   /*************************************************************************/
-   /****                                                                 ****/
-+  /****         P C F   D R I V E R    C O N F I G U R A T I O N        ****/
-+  /****                                                                 ****/
-+  /*************************************************************************/
-+  /*************************************************************************/
-+
-+
-+  /*************************************************************************/
-+  /*                                                                       */
-+  /* There are many PCF fonts just called `Fixed' which look completely    */
-+  /* different, and which have nothing to do with each other.  When        */
-+  /* selecting `Fixed' in KDE or Gnome one gets results that appear rather */
-+  /* random, the style changes often if one changes the size and one       */
-+  /* cannot select some fonts at all.  This option makes the PCF module    */
-+  /* prepend the foundry name (plus a space) to the family name.           */
-+  /*                                                                       */
-+  /* We also check whether we have `wide' characters; all put together, we */
-+  /* get family names like `Sony Fixed' or `Misc Fixed Wide'.              */
-+  /*                                                                       */
-+  /* If this option is activated, it can be controlled with the            */
-+  /* `no-long-family-names' property of the pcf driver module.             */
-+  /*                                                                       */
-+#define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
-+
-+
-+  /*************************************************************************/
-+  /*************************************************************************/
-+  /****                                                                 ****/
-   /****    A U T O F I T   M O D U L E    C O N F I G U R A T I O N     ****/
-   /****                                                                 ****/
-   /*************************************************************************/
-diff --git a/include/freetype/ftchapters.h b/include/freetype/ftchapters.h
-index ab43895..a0a121b 100644
---- a/include/freetype/ftchapters.h
-+++ b/include/freetype/ftchapters.h
-@@ -77,6 +77,7 @@
- /*    auto_hinter                                                          */
- /*    cff_driver                                                           */
- /*    tt_driver                                                            */
-+/*    pcf_driver                                                           */
- /*                                                                         */
- /***************************************************************************/
- 
-diff --git a/include/freetype/ftpcfdrv.h b/include/freetype/ftpcfdrv.h
-new file mode 100644
-index 0000000..6622c93
---- /dev/null
-+++ b/include/freetype/ftpcfdrv.h
-@@ -0,0 +1,105 @@
-+/***************************************************************************/
-+/*                                                                         */
-+/*  ftpcfdrv.h                                                             */
-+/*                                                                         */
-+/*    FreeType API for controlling the PCF driver (specification only).    */
-+/*                                                                         */
-+/*  Copyright 2017 by                                                      */
-+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
-+/*                                                                         */
-+/*  This file is part of the FreeType project, and may only be used,       */
-+/*  modified, and distributed under the terms of the FreeType project      */
-+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
-+/*  this file you indicate that you have read the license and              */
-+/*  understand and accept it fully.                                        */
-+/*                                                                         */
-+/***************************************************************************/
-+
-+
-+#ifndef FTPCFDRV_H_
-+#define FTPCFDRV_H_
-+
-+#include <ft2build.h>
-+#include FT_FREETYPE_H
-+
-+#ifdef FREETYPE_H
-+#error "freetype.h of FreeType 1 has been loaded!"
-+#error "Please fix the directory search order for header files"
-+#error "so that freetype.h of FreeType 2 is found first."
-+#endif
-+
-+
-+FT_BEGIN_HEADER
-+
-+
-+  /**************************************************************************
-+   *
-+   * @section:
-+   *   pcf_driver
-+   *
-+   * @title:
-+   *   The PCF driver
-+   *
-+   * @abstract:
-+   *   Controlling the PCF driver module.
-+   *
-+   * @description:
-+   *   While FreeType's PCF driver doesn't expose API functions by itself,
-+   *   it is possible to control its behaviour with @FT_Property_Set and
-+   *   @FT_Property_Get.  Right now, there is a single property
-+   *   `no-long-family-names' available if FreeType is compiled with
-+   *   PCF_CONFIG_OPTION_LONG_FAMILY_NAMES.
-+   *
-+   *   The PCF driver's module name is `pcf'.
-+   *
-+   */
-+
-+
-+  /**************************************************************************
-+   *
-+   * @property:
-+   *   no-long-family-names
-+   *
-+   * @description:
-+   *   If PCF_CONFIG_OPTION_LONG_FAMILY_NAMES is active while compiling
-+   *   FreeType, the PCF driver constructs long family names.
-+   *
-+   *   There are many PCF fonts just called `Fixed' which look completely
-+   *   different, and which have nothing to do with each other.  When
-+   *   selecting `Fixed' in KDE or Gnome one gets results that appear rather
-+   *   random, the style changes often if one changes the size and one
-+   *   cannot select some fonts at all.  The improve this situation, the PCF
-+   *   module prepends the foundry name (plus a space) to the family name. 
-+   *   It also checks whether there are `wide' characters; all put together,
-+   *   family names like `Sony Fixed' or `Misc Fixed Wide' are constructed.
-+   *
-+   *   If `no-long-family-names' is set, this feature gets switched off.
-+   *
-+   *   {
-+   *     FT_Library  library;
-+   *     FT_Bool     no_long_family_names = TRUE;
-+   *
-+   *
-+   *     FT_Init_FreeType( &library );
-+   *
-+   *     FT_Property_Set( library, "pcf",
-+   *                               "no-long-family-names",
-+   *                               &no_long_family_names );
-+   *   }
-+   *
-+   * @note:
-+   *   This property can be used with @FT_Property_Get also.
-+   *
-+   *   This property can be set via the `FREETYPE_PROPERTIES' environment
-+   *   variable (using values 1 and 0 for `on' and `off', respectively).
-+   *
-+   */
-+
-+
-+FT_END_HEADER
-+
-+
-+#endif /* FTPCFDRV_H_ */
-+
-+
-+/* END */
-diff --git a/src/pcf/pcf.h b/src/pcf/pcf.h
-index 830cabe..f0390cb 100644
---- a/src/pcf/pcf.h
-+++ b/src/pcf/pcf.h
-@@ -167,6 +167,8 @@ FT_BEGIN_HEADER
-   {
-     FT_DriverRec  root;
- 
-+    FT_Bool  no_long_family_names;
-+
-   } PCF_DriverRec, *PCF_Driver;
- 
- 
-diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
-index 8f4a90d..bc65423 100644
---- a/src/pcf/pcfdrivr.c
-+++ b/src/pcf/pcfdrivr.c
-@@ -49,6 +49,8 @@ THE SOFTWARE.
- 
- #include FT_SERVICE_BDF_H
- #include FT_SERVICE_FONT_FORMAT_H
-+#include FT_SERVICE_PROPERTIES_H
-+#include FT_PCF_DRIVER_H
- 
- 
-   /*************************************************************************/
-@@ -667,6 +669,110 @@ THE SOFTWARE.
-   };
- 
- 
-+  /*
-+   *  PROPERTY SERVICE
-+   *
-+   */
-+  static FT_Error
-+  pcf_property_set( FT_Module    module,         /* PCF_Driver */
-+                    const char*  property_name,
-+                    const void*  value,
-+                    FT_Bool      value_is_string )
-+  {
-+#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
-+
-+    FT_Error    error  = FT_Err_Ok;
-+    PCF_Driver  driver = (PCF_Driver)module;
-+
-+#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
-+    FT_UNUSED( value_is_string );
-+#endif
-+
-+
-+    if ( !ft_strcmp( property_name, "no-long-family-names" ) )
-+    {
-+#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
-+      if ( value_is_string )
-+      {
-+        const char*  s   = (const char*)value;
-+        long         lfn = ft_strtol( s, NULL, 10 );
-+
-+
-+        if ( lfn == 0 )
-+          driver->no_long_family_names = 0;
-+        else if ( lfn == 1 )
-+          driver->no_long_family_names = 1;
-+        else
-+          return FT_THROW( Invalid_Argument );
-+      }
-+      else
-+#endif
-+      {
-+        FT_Bool*  no_long_family_names = (FT_Bool*)value;
-+
-+
-+        driver->no_long_family_names = *no_long_family_names;
-+      }
-+
-+      return error;
-+    }
-+
-+#else /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
-+
-+    FT_UNUSED( module );
-+    FT_UNUSED( value );
-+    FT_UNUSED( value_is_string );
-+
-+#endif /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
-+
-+    FT_TRACE0(( "pcf_property_set: missing property `%s'\n",
-+                property_name ));
-+    return FT_THROW( Missing_Property );
-+  }
-+
-+
-+  static FT_Error
-+  pcf_property_get( FT_Module    module,         /* PCF_Driver */
-+                    const char*  property_name,
-+                    const void*  value )
-+  {
-+#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
-+
-+    FT_Error    error  = FT_Err_Ok;
-+    PCF_Driver  driver = (PCF_Driver)module;
-+
-+
-+    if ( !ft_strcmp( property_name, "no-long-family-names" ) )
-+    {
-+      FT_Bool   no_long_family_names = driver->no_long_family_names;
-+      FT_Bool*  val                  = (FT_Bool*)value;
-+
-+
-+      *val = no_long_family_names;
-+
-+      return error;
-+    }
-+
-+#else /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
-+
-+    FT_UNUSED( module );
-+    FT_UNUSED( value );
-+
-+#endif /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
-+
-+    FT_TRACE0(( "pcf_property_get: missing property `%s'\n",
-+                property_name ));
-+    return FT_THROW( Missing_Property );
-+  }
-+
-+
-+  FT_DEFINE_SERVICE_PROPERTIESREC(
-+    pcf_service_properties,
-+
-+    (FT_Properties_SetFunc)pcf_property_set,      /* set_property */
-+    (FT_Properties_GetFunc)pcf_property_get )     /* get_property */
-+
-+
-  /*
-   *
-   *  SERVICE LIST
-@@ -677,6 +783,7 @@ THE SOFTWARE.
-   {
-     { FT_SERVICE_ID_BDF,         &pcf_service_bdf },
-     { FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_PCF },
-+    { FT_SERVICE_ID_PROPERTIES,  &pcf_service_properties },
-     { NULL, NULL }
-   };
- 
-@@ -694,7 +801,14 @@ THE SOFTWARE.
-   FT_CALLBACK_DEF( FT_Error )
-   pcf_driver_init( FT_Module  module )      /* PCF_Driver */
-   {
-+#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
-+    PCF_Driver  driver = (PCF_Driver)module;
-+
-+
-+    driver->no_long_family_names = 0;
-+#else
-     FT_UNUSED( module );
-+#endif
- 
-     return FT_Err_Ok;
-   }
-diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
-index 38ba110..3eacf2b 100644
---- a/src/pcf/pcfread.c
-+++ b/src/pcf/pcfread.c
-@@ -1393,57 +1393,75 @@ THE SOFTWARE.
-       prop = pcf_find_property( face, "FAMILY_NAME" );
-       if ( prop && prop->isString )
-       {
--        /* Prepend the foundry name plus a space to the family name.      */
--        /* There are many fonts just called `Fixed' which look completely */
--        /* different, and which have nothing to do with each other.  When */
--        /* selecting `Fixed' in KDE or Gnome one gets results that appear */
--        /* rather random, the style changes often if one changes the size */
--        /* and one cannot select some fonts at all.                       */
--        /*                                                                */
--        /* We also check whether we have `wide' characters; all put       */
--        /* together, we get family names like `Sony Fixed' or `Misc Fixed */
--        /* Wide'.                                                         */
--        PCF_Property  foundry_prop, point_size_prop, average_width_prop;
--
--        int  l    = ft_strlen( prop->value.atom ) + 1;
--        int  wide = 0;
--
--
--        foundry_prop       = pcf_find_property( face, "FOUNDRY" );
--        point_size_prop    = pcf_find_property( face, "POINT_SIZE" );
--        average_width_prop = pcf_find_property( face, "AVERAGE_WIDTH" );
--
--        if ( point_size_prop && average_width_prop )
-+
-+#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
-+
-+        PCF_Driver  driver = (PCF_Driver)FT_FACE_DRIVER( face );
-+
-+
-+        if ( !driver->no_long_family_names )
-         {
--          if ( average_width_prop->value.l >= point_size_prop->value.l )
-+          /* Prepend the foundry name plus a space to the family name.     */
-+          /* There are many fonts just called `Fixed' which look           */
-+          /* completely different, and which have nothing to do with each  */
-+          /* other.  When selecting `Fixed' in KDE or Gnome one gets       */
-+          /* results that appear rather random, the style changes often if */
-+          /* one changes the size and one cannot select some fonts at all. */
-+          /*                                                               */
-+          /* We also check whether we have `wide' characters; all put      */
-+          /* together, we get family names like `Sony Fixed' or `Misc      */
-+          /* Fixed Wide'.                                                  */
-+
-+          PCF_Property  foundry_prop, point_size_prop, average_width_prop;
-+
-+          int  l    = ft_strlen( prop->value.atom ) + 1;
-+          int  wide = 0;
-+
-+
-+          foundry_prop       = pcf_find_property( face, "FOUNDRY" );
-+          point_size_prop    = pcf_find_property( face, "POINT_SIZE" );
-+          average_width_prop = pcf_find_property( face, "AVERAGE_WIDTH" );
-+
-+          if ( point_size_prop && average_width_prop )
-           {
--            /* This font is at least square shaped or even wider */
--            wide = 1;
--            l   += ft_strlen( " Wide" );
-+            if ( average_width_prop->value.l >= point_size_prop->value.l )
-+            {
-+              /* This font is at least square shaped or even wider */
-+              wide = 1;
-+              l   += ft_strlen( " Wide" );
-+            }
-           }
--        }
- 
--        if ( foundry_prop && foundry_prop->isString )
--        {
--          l += ft_strlen( foundry_prop->value.atom ) + 1;
-+          if ( foundry_prop && foundry_prop->isString )
-+          {
-+            l += ft_strlen( foundry_prop->value.atom ) + 1;
- 
--          if ( FT_NEW_ARRAY( root->family_name, l ) )
--            goto Exit;
-+            if ( FT_NEW_ARRAY( root->family_name, l ) )
-+              goto Exit;
-+
-+            ft_strcpy( root->family_name, foundry_prop->value.atom );
-+            ft_strcat( root->family_name, " " );
-+            ft_strcat( root->family_name, prop->value.atom );
-+          }
-+          else
-+          {
-+            if ( FT_NEW_ARRAY( root->family_name, l ) )
-+              goto Exit;
- 
--          ft_strcpy( root->family_name, foundry_prop->value.atom );
--          ft_strcat( root->family_name, " " );
--          ft_strcat( root->family_name, prop->value.atom );
-+            ft_strcpy( root->family_name, prop->value.atom );
-+          }
-+
-+          if ( wide )
-+            ft_strcat( root->family_name, " Wide" );
-         }
-         else
-+
-+#endif /* PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
-+
-         {
--          if ( FT_NEW_ARRAY( root->family_name, l ) )
-+          if ( FT_STRDUP( root->family_name, prop->value.atom ) )
-             goto Exit;
--
--          ft_strcpy( root->family_name, prop->value.atom );
-         }
--
--        if ( wide )
--          ft_strcat( root->family_name, " Wide" );
-       }
-       else
-         root->family_name = NULL;
--- 
-cgit v1.0-41-gc330
-
diff --git a/pkgs/development/libraries/freetype/pcf-introduce-driver.patch b/pkgs/development/libraries/freetype/pcf-introduce-driver.patch
deleted file mode 100644
index c1685c5116c..00000000000
--- a/pkgs/development/libraries/freetype/pcf-introduce-driver.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-diff --git a/src/pcf/pcf.h b/src/pcf/pcf.h
-index c726e5e..830cabe 100644
---- a/src/pcf/pcf.h
-+++ b/src/pcf/pcf.h
-@@ -163,6 +163,13 @@ FT_BEGIN_HEADER
-   } PCF_FaceRec, *PCF_Face;
- 
- 
-+  typedef struct  PCF_DriverRec_
-+  {
-+    FT_DriverRec  root;
-+
-+  } PCF_DriverRec, *PCF_Driver;
-+
-+
-   /* macros for pcf font format */
- 
- #define LSBFirst  0
-diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
-index 10d5c20..8f4a90d 100644
---- a/src/pcf/pcfdrivr.c
-+++ b/src/pcf/pcfdrivr.c
-@@ -691,22 +691,38 @@ THE SOFTWARE.
-   }
- 
- 
-+  FT_CALLBACK_DEF( FT_Error )
-+  pcf_driver_init( FT_Module  module )      /* PCF_Driver */
-+  {
-+    FT_UNUSED( module );
-+
-+    return FT_Err_Ok;
-+  }
-+
-+
-+  FT_CALLBACK_DEF( void )
-+  pcf_driver_done( FT_Module  module )      /* PCF_Driver */
-+  {
-+    FT_UNUSED( module );
-+  }
-+
-+
-   FT_CALLBACK_TABLE_DEF
-   const FT_Driver_ClassRec  pcf_driver_class =
-   {
-     {
-       FT_MODULE_FONT_DRIVER        |
-       FT_MODULE_DRIVER_NO_OUTLINES,
--      sizeof ( FT_DriverRec ),
- 
-+      sizeof ( PCF_DriverRec ),
-       "pcf",
-       0x10000L,
-       0x20000L,
- 
--      NULL,    /* module-specific interface */
-+      NULL,   /* module-specific interface */
- 
--      NULL,                     /* FT_Module_Constructor  module_init   */
--      NULL,                     /* FT_Module_Destructor   module_done   */
-+      pcf_driver_init,          /* FT_Module_Constructor  module_init   */
-+      pcf_driver_done,          /* FT_Module_Destructor   module_done   */
-       pcf_driver_requester      /* FT_Module_Requester    get_interface */
-     },
- 
--- 
-cgit v1.0-41-gc330
-
diff --git a/pkgs/development/libraries/gdk-pixbuf/default.nix b/pkgs/development/libraries/gdk-pixbuf/default.nix
index a1a9b10fca6..6bfa6bdc2fb 100644
--- a/pkgs/development/libraries/gdk-pixbuf/default.nix
+++ b/pkgs/development/libraries/gdk-pixbuf/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, pkgconfig, glib, libtiff, libjpeg, libpng, libX11, gnome3
-, jasper, libintlOrEmpty, gobjectIntrospection, doCheck ? false }:
+, jasper, gobjectIntrospection, doCheck ? false }:
 
 let
   pname = "gdk-pixbuf";
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
   enableParallelBuilding = true;
 
   # !!! We might want to factor out the gdk-pixbuf-xlib subpackage.
-  buildInputs = [ libX11 gobjectIntrospection ] ++ libintlOrEmpty;
+  buildInputs = [ libX11 gobjectIntrospection ];
 
   nativeBuildInputs = [ pkgconfig ];
 
@@ -61,4 +61,3 @@ stdenv.mkDerivation rec {
     platforms = platforms.unix;
   };
 }
-
diff --git a/pkgs/development/libraries/gegl/3.0.nix b/pkgs/development/libraries/gegl/3.0.nix
index e743b60573c..fee630c32a8 100644
--- a/pkgs/development/libraries/gegl/3.0.nix
+++ b/pkgs/development/libraries/gegl/3.0.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, pkgconfig, glib, babl, libpng, cairo, libjpeg, which
 , librsvg, pango, gtk, bzip2, json-glib, intltool, autoreconfHook, libraw
-, libwebp, gnome3 }:
+, libwebp, gnome3, libintl }:
 
 stdenv.mkDerivation rec {
   name = "gegl-0.3.30";
@@ -10,8 +10,6 @@ stdenv.mkDerivation rec {
     sha256 = "0lg5j5kn24qvyb6fn7khxf3jadkacbpnb9nrqzy7w665s8xakd7q";
   };
 
-  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-lintl";
-
   hardeningDisable = [ "format" ];
 
   # needs fonts otherwise  don't know how to pass them
@@ -28,7 +26,7 @@ stdenv.mkDerivation rec {
 
   propagatedBuildInputs = [ glib json-glib babl ]; # for gegl-3.0.pc
 
-  nativeBuildInputs = [ pkgconfig intltool which autoreconfHook ];
+  nativeBuildInputs = [ pkgconfig intltool which autoreconfHook libintl ];
 
   meta = with stdenv.lib; {
     description = "Graph-based image processing framework";
diff --git a/pkgs/development/libraries/gegl/default.nix b/pkgs/development/libraries/gegl/default.nix
index 304d8110ad4..8c93428a078 100644
--- a/pkgs/development/libraries/gegl/default.nix
+++ b/pkgs/development/libraries/gegl/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, pkgconfig, glib, babl, libpng, cairo, libjpeg
-, librsvg, pango, gtk2, bzip2, intltool
+, librsvg, pango, gtk2, bzip2, intltool, libintl
 , OpenGL ? null }:
 
 stdenv.mkDerivation rec {
@@ -20,14 +20,12 @@ stdenv.mkDerivation rec {
   # needs fonts otherwise  don't know how to pass them
   configureFlags = "--disable-docs";
 
-  NIX_LDFLAGS = if stdenv.isDarwin then "-lintl" else null;
-
-  buildInputs = [ babl libpng cairo libjpeg librsvg pango gtk2 bzip2 intltool ]
+  buildInputs = [ babl libpng cairo libjpeg librsvg pango gtk2 bzip2 intltool libintl ]
     ++ stdenv.lib.optional stdenv.isDarwin OpenGL;
 
   nativeBuildInputs = [ pkgconfig ];
 
-  meta = { 
+  meta = {
     description = "Graph-based image processing framework";
     homepage = http://www.gegl.org;
     license = stdenv.lib.licenses.gpl3;
diff --git a/pkgs/development/libraries/geoclue/2.0.nix b/pkgs/development/libraries/geoclue/2.0.nix
index b70163789de..495a113391e 100644
--- a/pkgs/development/libraries/geoclue/2.0.nix
+++ b/pkgs/development/libraries/geoclue/2.0.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, intltool, libintlOrEmpty, pkgconfig, glib, json-glib, libsoup, geoip
+{ fetchurl, stdenv, intltool, pkgconfig, glib, json-glib, libsoup, geoip
 , dbus, dbus-glib, modemmanager, avahi, glib-networking, wrapGAppsHook, gobjectIntrospection
 }:
 
@@ -18,8 +18,7 @@ stdenv.mkDerivation rec {
     pkgconfig intltool wrapGAppsHook gobjectIntrospection
   ];
 
-  buildInputs = libintlOrEmpty ++
-   [ glib json-glib libsoup geoip
+  buildInputs = [ glib json-glib libsoup geoip
      dbus dbus-glib avahi
    ] ++ optionals (!stdenv.isDarwin) [ modemmanager ];
 
@@ -37,8 +36,6 @@ stdenv.mkDerivation rec {
                        "--disable-modem-gps-source"
                        "--disable-nmea-source" ];
 
-  NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin " -lintl";
-
   postInstall = ''
     sed -i $dev/lib/pkgconfig/libgeoclue-2.0.pc -e "s|includedir=.*|includedir=$dev/include|"
   '';
diff --git a/pkgs/development/libraries/gettext/default.nix b/pkgs/development/libraries/gettext/default.nix
index 9c3024ce25f..6dec7747c7e 100644
--- a/pkgs/development/libraries/gettext/default.nix
+++ b/pkgs/development/libraries/gettext/default.nix
@@ -49,6 +49,7 @@ stdenv.mkDerivation rec {
   buildInputs = stdenv.lib.optional (!stdenv.isLinux && !hostPlatform.isCygwin) libiconv;
 
   setupHook = ./gettext-setup-hook.sh;
+  gettextNeedsLdflags = hostPlatform.libc != "glibc" && !hostPlatform.isMusl;
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/gettext/gettext-setup-hook.sh b/pkgs/development/libraries/gettext/gettext-setup-hook.sh
index 5932ef6a44f..074d313e48a 100644
--- a/pkgs/development/libraries/gettext/gettext-setup-hook.sh
+++ b/pkgs/development/libraries/gettext/gettext-setup-hook.sh
@@ -5,3 +5,24 @@ gettextDataDirsHook() {
 }
 
 addEnvHooks "$hostOffset" gettextDataDirsHook
+
+# libintl must be listed in load flags on non-Glibc
+# it doesn't hurt to have it in Glibc either though
+gettextLdflags() {
+    # The `depHostOffset` describes how the host platform of the dependencies
+    # are slid relative to the depending package. It is brought into scope of
+    # the environment hook defined as the role of the dependency being applied.
+    case $depHostOffset in
+        -1) local role='BUILD_' ;;
+        0)  local role='' ;;
+        1)  local role='TARGET_' ;;
+        *)  echo "cc-wrapper: Error: Cannot be used with $depHostOffset-offset deps" >2;
+            return 1 ;;
+    esac
+
+    export NIX_${role}LDFLAGS+=" -lintl"
+}
+
+if [ ! -z "@gettextNeedsLdflags@" ]; then
+    addEnvHooks "$hostOffset" gettextLdflags
+fi
diff --git a/pkgs/development/libraries/glib-networking/default.nix b/pkgs/development/libraries/glib-networking/default.nix
index 51ee5487f5f..c3bcb3aa1c4 100644
--- a/pkgs/development/libraries/glib-networking/default.nix
+++ b/pkgs/development/libraries/glib-networking/default.nix
@@ -47,4 +47,3 @@ stdenv.mkDerivation rec {
     platforms = platforms.unix;
   };
 }
-
diff --git a/pkgs/development/libraries/glib/default.nix b/pkgs/development/libraries/glib/default.nix
index 2c070ff3fa8..d2dc9a8c637 100644
--- a/pkgs/development/libraries/glib/default.nix
+++ b/pkgs/development/libraries/glib/default.nix
@@ -1,5 +1,5 @@
-{ stdenv, hostPlatform, fetchurl, pkgconfig, gettext, perl, python
-, libiconv, libintlOrEmpty, zlib, libffi, pcre, libelf, gnome3
+{ stdenv, hostPlatform, fetchurl, gettext, pkgconfig, perl, python
+, libiconv, zlib, libffi, pcre, libelf, gnome3
 # use utillinuxMinimal to avoid circular dependency (utillinux, systemd, glib)
 , utillinuxMinimal ? null
 
@@ -66,17 +66,13 @@ stdenv.mkDerivation rec {
     ++ optionals stdenv.isLinux [ utillinuxMinimal ] # for libmount
     ++ optionals doCheck [ tzdata libxml2 desktop-file-utils shared-mime-info ];
 
-  nativeBuildInputs = [ pkgconfig gettext perl python ];
+  nativeBuildInputs = [ pkgconfig perl python ];
 
-  propagatedBuildInputs = [ zlib libffi libiconv ]
-    ++ libintlOrEmpty;
+  propagatedBuildInputs = [ zlib libffi gettext libiconv ];
 
   # internal pcre would only add <200kB, but it's relatively common
   configureFlags = [ "--with-pcre=system" ]
     ++ optional stdenv.isDarwin "--disable-compile-warnings"
-    # glibc inclues GNU libiconv, but Darwin's iconv function is good enonugh.
-    ++ optional (stdenv.hostPlatform.libc != "glibc" && !stdenv.hostPlatform.isDarwin)
-      "--with-libiconv=gnu"
     ++ optional stdenv.isSunOS "--disable-dtrace"
     # Can't run this test when cross-compiling
     ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform)
@@ -84,8 +80,7 @@ stdenv.mkDerivation rec {
     # GElf only supports elf64 hosts
     ++ optional (!stdenv.hostPlatform.is64bit) "--disable-libelf";
 
-  NIX_CFLAGS_COMPILE = optional stdenv.isDarwin "-lintl"
-    ++ optional stdenv.isSunOS "-DBSD_COMP";
+  NIX_CFLAGS_COMPILE = optional stdenv.isSunOS "-DBSD_COMP";
 
   preConfigure = optionalString stdenv.isSunOS ''
     sed -i -e 's|inotify.h|foobar-inotify.h|g' configure
diff --git a/pkgs/development/libraries/glibc/2.27.nix b/pkgs/development/libraries/glibc/2.27.nix
deleted file mode 100644
index bb057ae899e..00000000000
--- a/pkgs/development/libraries/glibc/2.27.nix
+++ /dev/null
@@ -1,101 +0,0 @@
-{ stdenv, callPackage
-, withLinuxHeaders ? true
-, installLocales ? true
-, profilingLibraries ? false
-, withGd ? false
-}:
-
-assert stdenv.cc.isGNU;
-
-callPackage ./common-2.27.nix { inherit stdenv; } {
-    name = "glibc" + stdenv.lib.optionalString withGd "-gd";
-
-    inherit withLinuxHeaders profilingLibraries installLocales withGd;
-
-    NIX_NO_SELF_RPATH = true;
-
-    postConfigure = ''
-      # Hack: get rid of the `-static' flag set by the bootstrap stdenv.
-      # This has to be done *after* `configure' because it builds some
-      # test binaries.
-      export NIX_CFLAGS_LINK=
-      export NIX_LDFLAGS_BEFORE=
-
-      export NIX_DONT_SET_RPATH=1
-      unset CFLAGS
-
-      # Apparently --bindir is not respected.
-      makeFlagsArray+=("bindir=$bin/bin" "sbindir=$bin/sbin" "rootsbindir=$bin/sbin")
-    '';
-
-    # The stackprotector and fortify hardening flags are autodetected by glibc
-    # and enabled by default if supported. Setting it for every gcc invocation
-    # does not work.
-    hardeningDisable = [ "stackprotector" "fortify" ];
-
-    # When building glibc from bootstrap-tools, we need libgcc_s at RPATH for
-    # any program we run, because the gcc will have been placed at a new
-    # store path than that determined when built (as a source for the
-    # bootstrap-tools tarball)
-    # Building from a proper gcc staying in the path where it was installed,
-    # libgcc_s will not be at {gcc}/lib, and gcc's libgcc will be found without
-    # any special hack.
-    preInstall = ''
-      if [ -f ${stdenv.cc.cc}/lib/libgcc_s.so.1 ]; then
-          mkdir -p $out/lib
-          cp ${stdenv.cc.cc}/lib/libgcc_s.so.1 $out/lib/libgcc_s.so.1
-          # the .so It used to be a symlink, but now it is a script
-          cp -a ${stdenv.cc.cc}/lib/libgcc_s.so $out/lib/libgcc_s.so
-      fi
-    '';
-
-    postInstall = ''
-      if test -n "$installLocales"; then
-          make -j''${NIX_BUILD_CORES:-1} -l''${NIX_BUILD_CORES:-1} localedata/install-locales
-      fi
-
-      test -f $out/etc/ld.so.cache && rm $out/etc/ld.so.cache
-
-      if test -n "$linuxHeaders"; then
-          # Include the Linux kernel headers in Glibc, except the `scsi'
-          # subdirectory, which Glibc provides itself.
-          (cd $dev/include && \
-           ln -sv $(ls -d $linuxHeaders/include/* | grep -v scsi\$) .)
-      fi
-
-      # Fix for NIXOS-54 (ldd not working on x86_64).  Make a symlink
-      # "lib64" to "lib".
-      if test -n "$is64bit"; then
-          ln -s lib $out/lib64
-      fi
-
-      # Get rid of more unnecessary stuff.
-      rm -rf $out/var $bin/bin/sln
-
-      # For some reason these aren't stripped otherwise and retain reference
-      # to bootstrap-tools; on cross-arm this stripping would break objects.
-      if [ -z "$crossConfig" ]; then
-        for i in "$out"/lib/*.a; do
-            [ "$i" = "$out/lib/libm.a" ] || strip -S "$i"
-        done
-      fi
-
-      # Put libraries for static linking in a separate output.  Note
-      # that libc_nonshared.a and libpthread_nonshared.a are required
-      # for dynamically-linked applications.
-      mkdir -p $static/lib
-      mv $out/lib/*.a $static/lib
-      mv $static/lib/lib*_nonshared.a $out/lib
-      # Some of *.a files are linker scripts where moving broke the paths.
-      sed "/^GROUP/s|$out/lib/lib|$static/lib/lib|g" \
-        -i "$static"/lib/*.a
-
-      # Work around a Nix bug: hard links across outputs cause a build failure.
-      cp $bin/bin/getconf $bin/bin/getconf_
-      mv $bin/bin/getconf_ $bin/bin/getconf
-    '';
-
-    separateDebugInfo = true;
-
-    meta.description = "The GNU C Library";
-  }
diff --git a/pkgs/development/libraries/glibc/common-2.27.nix b/pkgs/development/libraries/glibc/common-2.27.nix
deleted file mode 100644
index 4a5b31245c1..00000000000
--- a/pkgs/development/libraries/glibc/common-2.27.nix
+++ /dev/null
@@ -1,216 +0,0 @@
-/* Build configuration used to build glibc, Info files, and locale
-   information.  */
-
-{ stdenv, lib
-, buildPlatform, hostPlatform
-, buildPackages
-, fetchurl, fetchpatch ? null
-, linuxHeaders ? null
-, gd ? null, libpng ? null
-, bison
-}:
-
-{ name
-, withLinuxHeaders ? false
-, profilingLibraries ? false
-, installLocales ? false
-, withGd ? false
-, meta
-, ...
-} @ args:
-
-let
-  version = "2.27";
-  patchSuffix = "";
-  sha256 = "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji";
-  cross = if buildPlatform != hostPlatform then hostPlatform else null;
-in
-
-assert withLinuxHeaders -> linuxHeaders != null;
-assert withGd -> gd != null && libpng != null;
-
-stdenv.mkDerivation ({
-  inherit  installLocales;
-  linuxHeaders = if withLinuxHeaders then linuxHeaders else null;
-
-  # The host/target system.
-  crossConfig = if cross != null then cross.config else null;
-
-  inherit (stdenv) is64bit;
-
-  enableParallelBuilding = true;
-
-  patches =
-    [
-      /* Have rpcgen(1) look for cpp(1) in $PATH.  */
-      ./rpcgen-path.patch
-
-      /* Allow NixOS and Nix to handle the locale-archive. */
-      ./nix-locale-archive-2.27.patch
-
-      /* Don't use /etc/ld.so.cache, for non-NixOS systems.  */
-      ./dont-use-system-ld-so-cache-2.27.patch
-
-      /* Don't use /etc/ld.so.preload, but /etc/ld-nix.so.preload.  */
-      ./dont-use-system-ld-so-preload.patch
-
-      /* The command "getconf CS_PATH" returns the default search path
-         "/bin:/usr/bin", which is inappropriate on NixOS machines. This
-         patch extends the search path by "/run/current-system/sw/bin". */
-      ./fix_path_attribute_in_getconf.patch
-
-      /* Allow running with RHEL 6 -like kernels.  The patch adds an exception
-        for glibc to accept 2.6.32 and to tag the ELFs as 2.6.32-compatible
-        (otherwise the loader would refuse libc).
-        Note that glibc will fully work only on their heavily patched kernels
-        and we lose early mismatch detection on 2.6.32.
-
-        On major glibc updates we should check that the patched kernel supports
-        all the required features.  ATM it's verified up to glibc-2.26-131.
-        # HOWTO: check glibc sources for changes in kernel requirements
-        git log -p glibc-2.25.. sysdeps/unix/sysv/linux/x86_64/kernel-features.h sysdeps/unix/sysv/linux/kernel-features.h
-        # get kernel sources (update the URL)
-        mkdir tmp && cd tmp
-        curl http://vault.centos.org/6.9/os/Source/SPackages/kernel-2.6.32-696.el6.src.rpm | rpm2cpio - | cpio -idmv
-        tar xf linux-*.bz2
-        # check syscall presence, for example
-        less linux-*?/arch/x86/kernel/syscall_table_32.S
-       */
-      ./allow-kernel-2.6.32.patch
-    ]
-    ++ lib.optional stdenv.isx86_64 ./fix-x64-abi.patch
-    ++ lib.optional stdenv.hostPlatform.isMusl
-      (fetchpatch {
-        name = "fix-with-musl.patch";
-        url = "https://sourceware.org/bugzilla/attachment.cgi?id=10151&action=diff&collapsed=&headers=1&format=raw";
-        sha256 = "18kk534k6da5bkbsy1ivbi77iin76lsna168mfcbwv4ik5vpziq2";
-      });
-
-  postPatch =
-    ''
-      # Needed for glibc to build with the gnumake 3.82
-      # http://comments.gmane.org/gmane.linux.lfs.support/31227
-      sed -i 's/ot \$/ot:\n\ttouch $@\n$/' manual/Makefile
-
-      # nscd needs libgcc, and we don't want it dynamically linked
-      # because we don't want it to depend on bootstrap-tools libs.
-      echo "LDFLAGS-nscd += -static-libgcc" >> nscd/Makefile
-    '';
-
-  configureFlags =
-    [ "-C"
-      "--enable-add-ons"
-      "--enable-obsolete-nsl"
-      "--enable-obsolete-rpc"
-      "--sysconfdir=/etc"
-      "--enable-stackguard-randomization"
-      (if withLinuxHeaders
-       then "--with-headers=${linuxHeaders}/include"
-       else "--without-headers")
-      (if profilingLibraries
-       then "--enable-profile"
-       else "--disable-profile")
-    ] ++ lib.optionals withLinuxHeaders [
-      "--enable-kernel=3.2.0" # can't get below with glibc >= 2.26
-    ] ++ lib.optionals (cross != null) [
-      (if cross ? float && cross.float == "soft" then "--without-fp" else "--with-fp")
-    ] ++ lib.optionals (cross != null) [
-      "--with-__thread"
-    ] ++ lib.optionals (cross == null && stdenv.isArm) [
-      "--host=arm-linux-gnueabi"
-      "--build=arm-linux-gnueabi"
-
-      # To avoid linking with -lgcc_s (dynamic link)
-      # so the glibc does not depend on its compiler store path
-      "libc_cv_as_needed=no"
-    ] ++ lib.optional withGd "--with-gd";
-
-  installFlags = [ "sysconfdir=$(out)/etc" ];
-
-  outputs = [ "out" "bin" "dev" "static" ];
-
-  depsBuildBuild = [ buildPackages.stdenv.cc ];
-  nativeBuildInputs = [ bison ];
-  buildInputs = lib.optionals withGd [ gd libpng ];
-
-  # Needed to install share/zoneinfo/zone.tab.  Set to impure /bin/sh to
-  # prevent a retained dependency on the bootstrap tools in the stdenv-linux
-  # bootstrap.
-  BASH_SHELL = "/bin/sh";
-}
-
-// (removeAttrs args [ "withLinuxHeaders" "withGd" ]) //
-
-{
-  name = name + "-${version}${patchSuffix}";
-
-  src = fetchurl {
-    url = "mirror://gnu/glibc/glibc-${version}.tar.xz";
-    inherit sha256;
-  };
-
-  # Remove absolute paths from `configure' & co.; build out-of-tree.
-  preConfigure = ''
-    export PWD_P=$(type -tP pwd)
-    for i in configure io/ftwtest-sh; do
-        # Can't use substituteInPlace here because replace hasn't been
-        # built yet in the bootstrap.
-        sed -i "$i" -e "s^/bin/pwd^$PWD_P^g"
-    done
-
-    mkdir ../build
-    cd ../build
-
-    configureScript="`pwd`/../$sourceRoot/configure"
-
-    ${lib.optionalString (stdenv.cc.libc != null)
-      ''makeFlags="$makeFlags BUILD_LDFLAGS=-Wl,-rpath,${stdenv.cc.libc}/lib"''
-    }
-
-
-  '' + lib.optionalString (cross != null) ''
-    sed -i s/-lgcc_eh//g "../$sourceRoot/Makeconfig"
-
-    cat > config.cache << "EOF"
-    libc_cv_forced_unwind=yes
-    libc_cv_c_cleanup=yes
-    libc_cv_gnu89_inline=yes
-    EOF
-  '';
-
-  preBuild = lib.optionalString withGd "unset NIX_DONT_SET_RPATH";
-
-  meta = {
-    homepage = http://www.gnu.org/software/libc/;
-    description = "The GNU C Library";
-
-    longDescription =
-      '' Any Unix-like operating system needs a C library: the library which
-         defines the "system calls" and other basic facilities such as
-         open, malloc, printf, exit...
-
-         The GNU C library is used as the C library in the GNU system and
-         most systems with the Linux kernel.
-      '';
-
-    license = lib.licenses.lgpl2Plus;
-
-    maintainers = [ lib.maintainers.eelco ];
-    platforms = lib.platforms.linux;
-  } // meta;
-
-  passthru = { inherit version; };
-}
-
-// lib.optionalAttrs (cross != null) {
-  preInstall = null; # clobber the native hook
-
-  dontStrip = true;
-
-  separateDebugInfo = false; # this is currently broken for crossDrv
-
-  # To avoid a dependency on the build system 'bash'.
-  preFixup = ''
-    rm -f $bin/bin/{ldd,tzselect,catchsegv,xtrace}
-  '';
-})
diff --git a/pkgs/development/libraries/glibc/common.nix b/pkgs/development/libraries/glibc/common.nix
index c8e5b456285..517c98e9f64 100644
--- a/pkgs/development/libraries/glibc/common.nix
+++ b/pkgs/development/libraries/glibc/common.nix
@@ -7,6 +7,7 @@
 , fetchurl, fetchpatch ? null
 , linuxHeaders ? null
 , gd ? null, libpng ? null
+, bison
 }:
 
 { name
@@ -19,9 +20,9 @@
 } @ args:
 
 let
-  version = "2.26";
-  patchSuffix = "-131";
-  sha256 = "1ggnj1hzjym7sn93rbwydcqd562q73lsb7g7kd199g6j9j9hlkp5";
+  version = "2.27";
+  patchSuffix = "";
+  sha256 = "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji";
   cross = if buildPlatform != hostPlatform then hostPlatform else null;
 in
 
@@ -29,7 +30,7 @@ assert withLinuxHeaders -> linuxHeaders != null;
 assert withGd -> gd != null && libpng != null;
 
 stdenv.mkDerivation ({
-  inherit  installLocales;
+  inherit version installLocales;
   linuxHeaders = if withLinuxHeaders then linuxHeaders else null;
 
   # The host/target system.
@@ -41,17 +42,6 @@ stdenv.mkDerivation ({
 
   patches =
     [
-      /*  No tarballs for stable upstream branch, only https://sourceware.org/git/?p=glibc.git
-          $ git co release/2.25/master; git describe
-          glibc-2.25-49-gbc5ace67fe
-          $ git show --reverse glibc-2.25..release/2.25/master | gzip -n -9 --rsyncable - > 2.25-49.patch.gz
-      */
-      ./2.26-75.patch.gz
-      ./2.26-75to115.diff.gz
-      # contains fix for CVE-2018-1000001 as the last commit:
-      # https://sourceware.org/git/?p=glibc.git;a=commit;h=fabef2edbc
-      ./2.26-115to131.diff.gz
-
       /* Have rpcgen(1) look for cpp(1) in $PATH.  */
       ./rpcgen-path.patch
 
@@ -97,24 +87,14 @@ stdenv.mkDerivation ({
       });
 
   postPatch =
-    # Needed for glibc to build with the gnumake 3.82
-    # http://comments.gmane.org/gmane.linux.lfs.support/31227
     ''
+      # Needed for glibc to build with the gnumake 3.82
+      # http://comments.gmane.org/gmane.linux.lfs.support/31227
       sed -i 's/ot \$/ot:\n\ttouch $@\n$/' manual/Makefile
-    ''
-    # nscd needs libgcc, and we don't want it dynamically linked
-    # because we don't want it to depend on bootstrap-tools libs.
-    + ''
+
+      # nscd needs libgcc, and we don't want it dynamically linked
+      # because we don't want it to depend on bootstrap-tools libs.
       echo "LDFLAGS-nscd += -static-libgcc" >> nscd/Makefile
-    ''
-    # Replace the date and time in nscd by a prefix of $out.
-    # It is used as a protocol compatibility check.
-    # Note: the size of the struct changes, but using only a part
-    # would break hash-rewriting. When receiving stats it does check
-    # that the struct sizes match and can't cause overflow or something.
-    + ''
-      cat ${./glibc-remove-datetime-from-nscd.patch} \
-        | sed "s,@out@,$out," | patch -p1
     '';
 
   configureFlags =
@@ -150,6 +130,7 @@ stdenv.mkDerivation ({
   outputs = [ "out" "bin" "dev" "static" ];
 
   depsBuildBuild = [ buildPackages.stdenv.cc ];
+  nativeBuildInputs = [ bison ];
   buildInputs = lib.optionals withGd [ gd libpng ];
 
   # Needed to install share/zoneinfo/zone.tab.  Set to impure /bin/sh to
diff --git a/pkgs/development/libraries/glibc/dont-use-system-ld-so-cache-2.27.patch b/pkgs/development/libraries/glibc/dont-use-system-ld-so-cache-2.27.patch
deleted file mode 100644
index f84b1049adf..00000000000
--- a/pkgs/development/libraries/glibc/dont-use-system-ld-so-cache-2.27.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-diff -Naur glibc-2.27-orig/elf/ldconfig.c glibc-2.27/elf/ldconfig.c
---- glibc-2.27-orig/elf/ldconfig.c	2018-02-01 11:17:18.000000000 -0500
-+++ glibc-2.27/elf/ldconfig.c	2018-02-17 22:43:17.232175182 -0500
-@@ -51,7 +51,7 @@
- #endif
- 
- #ifndef LD_SO_CONF
--# define LD_SO_CONF SYSCONFDIR "/ld.so.conf"
-+# define LD_SO_CONF PREFIX "/etc/ld.so.conf"
- #endif
- 
- /* Get libc version number.  */
-diff -Naur glibc-2.27-orig/elf/Makefile glibc-2.27/elf/Makefile
---- glibc-2.27-orig/elf/Makefile	2018-02-01 11:17:18.000000000 -0500
-+++ glibc-2.27/elf/Makefile	2018-02-17 22:44:50.334006750 -0500
-@@ -559,13 +559,13 @@
- 
- $(objpfx)ldconfig: $(ldconfig-modules:%=$(objpfx)%.o)
- 
--SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"'
--CFLAGS-ldconfig.c += $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
-+PREFIX-FLAGS := -D'PREFIX="$(prefix)"'
-+CFLAGS-ldconfig.c += $(PREFIX-FLAGS) -D'LIBDIR="$(libdir)"' \
- 		    -D'SLIBDIR="$(slibdir)"'
- libof-ldconfig = ldconfig
--CFLAGS-dl-cache.c += $(SYSCONF-FLAGS)
--CFLAGS-cache.c += $(SYSCONF-FLAGS)
--CFLAGS-rtld.c += $(SYSCONF-FLAGS)
-+CFLAGS-dl-cache.c += $(PREFIX-FLAGS)
-+CFLAGS-cache.c += $(PREFIX-FLAGS)
-+CFLAGS-rtld.c += $(PREFIX-FLAGS)
- 
- cpp-srcs-left := $(all-rtld-routines:=.os)
- lib := rtld
-diff -Naur glibc-2.27-orig/sysdeps/generic/dl-cache.h glibc-2.27/sysdeps/generic/dl-cache.h
---- glibc-2.27-orig/sysdeps/generic/dl-cache.h	2018-02-01 11:17:18.000000000 -0500
-+++ glibc-2.27/sysdeps/generic/dl-cache.h	2018-02-17 22:45:20.471598816 -0500
-@@ -28,7 +28,7 @@
- #endif
- 
- #ifndef LD_SO_CACHE
--# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache"
-+# define LD_SO_CACHE PREFIX "/etc/ld.so.cache"
- #endif
- 
- #ifndef add_system_dir
diff --git a/pkgs/development/libraries/glibc/dont-use-system-ld-so-cache.patch b/pkgs/development/libraries/glibc/dont-use-system-ld-so-cache.patch
index fc14553c3ee..f84b1049adf 100644
--- a/pkgs/development/libraries/glibc/dont-use-system-ld-so-cache.patch
+++ b/pkgs/development/libraries/glibc/dont-use-system-ld-so-cache.patch
@@ -1,7 +1,7 @@
-diff -ru glibc-2.16.0-orig/elf/ldconfig.c glibc-2.16.0/elf/ldconfig.c
---- glibc-2.16.0-orig/elf/ldconfig.c	2012-06-30 15:12:34.000000000 -0400
-+++ glibc-2.16.0/elf/ldconfig.c	2012-09-18 11:59:27.463284814 -0400
-@@ -50,7 +50,7 @@
+diff -Naur glibc-2.27-orig/elf/ldconfig.c glibc-2.27/elf/ldconfig.c
+--- glibc-2.27-orig/elf/ldconfig.c	2018-02-01 11:17:18.000000000 -0500
++++ glibc-2.27/elf/ldconfig.c	2018-02-17 22:43:17.232175182 -0500
+@@ -51,7 +51,7 @@
  #endif
  
  #ifndef LD_SO_CONF
@@ -10,31 +10,31 @@ diff -ru glibc-2.16.0-orig/elf/ldconfig.c glibc-2.16.0/elf/ldconfig.c
  #endif
  
  /* Get libc version number.  */
-diff -ru glibc-2.16.0-orig/elf/Makefile glibc-2.16.0/elf/Makefile
---- glibc-2.16.0-orig/elf/Makefile	2012-06-30 15:12:34.000000000 -0400
-+++ glibc-2.16.0/elf/Makefile	2012-09-18 12:03:30.031955196 -0400
-@@ -415,12 +415,12 @@
+diff -Naur glibc-2.27-orig/elf/Makefile glibc-2.27/elf/Makefile
+--- glibc-2.27-orig/elf/Makefile	2018-02-01 11:17:18.000000000 -0500
++++ glibc-2.27/elf/Makefile	2018-02-17 22:44:50.334006750 -0500
+@@ -559,13 +559,13 @@
  
  $(objpfx)ldconfig: $(ldconfig-modules:%=$(objpfx)%.o)
  
 -SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"'
--CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
+-CFLAGS-ldconfig.c += $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
 +PREFIX-FLAGS := -D'PREFIX="$(prefix)"'
-+CFLAGS-ldconfig.c = $(PREFIX-FLAGS) -D'LIBDIR="$(libdir)"' \
++CFLAGS-ldconfig.c += $(PREFIX-FLAGS) -D'LIBDIR="$(libdir)"' \
  		    -D'SLIBDIR="$(slibdir)"'
  libof-ldconfig = ldconfig
--CFLAGS-dl-cache.c = $(SYSCONF-FLAGS)
--CFLAGS-cache.c = $(SYSCONF-FLAGS)
--CFLAGS-rtld.c = $(SYSCONF-FLAGS)
-+CFLAGS-dl-cache.c = $(PREFIX-FLAGS)
-+CFLAGS-cache.c = $(PREFIX-FLAGS)
-+CFLAGS-rtld.c = $(PREFIX-FLAGS)
+-CFLAGS-dl-cache.c += $(SYSCONF-FLAGS)
+-CFLAGS-cache.c += $(SYSCONF-FLAGS)
+-CFLAGS-rtld.c += $(SYSCONF-FLAGS)
++CFLAGS-dl-cache.c += $(PREFIX-FLAGS)
++CFLAGS-cache.c += $(PREFIX-FLAGS)
++CFLAGS-rtld.c += $(PREFIX-FLAGS)
  
  cpp-srcs-left := $(all-rtld-routines:=.os)
  lib := rtld
-diff -ru glibc-2.16.0-orig/sysdeps/generic/dl-cache.h glibc-2.16.0/sysdeps/generic/dl-cache.h
---- glibc-2.16.0-orig/sysdeps/generic/dl-cache.h	2012-06-30 15:12:34.000000000 -0400
-+++ glibc-2.16.0/sysdeps/generic/dl-cache.h	2012-09-18 11:59:27.465284809 -0400
+diff -Naur glibc-2.27-orig/sysdeps/generic/dl-cache.h glibc-2.27/sysdeps/generic/dl-cache.h
+--- glibc-2.27-orig/sysdeps/generic/dl-cache.h	2018-02-01 11:17:18.000000000 -0500
++++ glibc-2.27/sysdeps/generic/dl-cache.h	2018-02-17 22:45:20.471598816 -0500
 @@ -28,7 +28,7 @@
  #endif
  
diff --git a/pkgs/development/libraries/glibc/nix-locale-archive-2.27.patch b/pkgs/development/libraries/glibc/nix-locale-archive-2.27.patch
deleted file mode 100644
index 39312951fcf..00000000000
--- a/pkgs/development/libraries/glibc/nix-locale-archive-2.27.patch
+++ /dev/null
@@ -1,118 +0,0 @@
-diff -Naur glibc-2.27-orig/locale/loadarchive.c glibc-2.27/locale/loadarchive.c
---- glibc-2.27-orig/locale/loadarchive.c	2018-02-01 11:17:18.000000000 -0500
-+++ glibc-2.27/locale/loadarchive.c	2018-02-17 22:32:25.680169462 -0500
-@@ -123,6 +123,23 @@
-   return MAX (namehash_end, MAX (string_end, locrectab_end));
- }
- 
-+static int
-+open_locale_archive (void)
-+{
-+  int fd = -1;
-+  char *versioned_path = getenv ("LOCALE_ARCHIVE_2_27");
-+  char *path = getenv ("LOCALE_ARCHIVE");
-+  if (versioned_path)
-+    fd = __open_nocancel (versioned_path, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
-+  if (path && fd < 0)
-+    fd = __open_nocancel (path, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
-+  if (fd < 0)
-+    fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
-+  if (fd < 0)
-+    fd = __open_nocancel ("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE|O_CLOEXEC);
-+  return fd;
-+}
-+
- 
- /* Find the locale *NAMEP in the locale archive, and return the
-    internalized data structure for its CATEGORY data.  If this locale has
-@@ -202,7 +219,7 @@
-       archmapped = &headmap;
- 
-       /* The archive has never been opened.  */
--      fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
-+      fd = open_locale_archive ();
-       if (fd < 0)
- 	/* Cannot open the archive, for whatever reason.  */
- 	return NULL;
-@@ -397,8 +414,7 @@
- 	  if (fd == -1)
- 	    {
- 	      struct stat64 st;
--	      fd = __open_nocancel (archfname,
--				    O_RDONLY|O_LARGEFILE|O_CLOEXEC);
-+	      fd = open_locale_archive ();
- 	      if (fd == -1)
- 		/* Cannot open the archive, for whatever reason.  */
- 		return NULL;
-diff -Naur glibc-2.27-orig/locale/programs/locale.c glibc-2.27/locale/programs/locale.c
---- glibc-2.27-orig/locale/programs/locale.c	2018-02-01 11:17:18.000000000 -0500
-+++ glibc-2.27/locale/programs/locale.c	2018-02-17 22:36:39.726293213 -0500
-@@ -633,6 +633,24 @@
- 
- 
- static int
-+open_locale_archive (void)
-+{
-+  int fd = -1;
-+  char *versioned_path = getenv ("LOCALE_ARCHIVE_2_27");
-+  char *path = getenv ("LOCALE_ARCHIVE");
-+  if (versioned_path)
-+    fd = open64 (versioned_path, O_RDONLY);
-+  if (path && fd < 0)
-+    fd = open64 (path, O_RDONLY);
-+  if (fd < 0)
-+    fd = open64 (ARCHIVE_NAME, O_RDONLY);
-+  if (fd < 0)
-+    fd = open64 ("/usr/lib/locale/locale-archive", O_RDONLY);
-+  return fd;
-+}
-+
-+
-+static int
- write_archive_locales (void **all_datap, char *linebuf)
- {
-   struct stat64 st;
-@@ -644,7 +662,7 @@
-   int fd, ret = 0;
-   uint32_t cnt;
- 
--  fd = open64 (ARCHIVE_NAME, O_RDONLY);
-+  fd = open_locale_archive ();
-   if (fd < 0)
-     return 0;
- 
-diff -Naur glibc-2.27-orig/locale/programs/locarchive.c glibc-2.27/locale/programs/locarchive.c
---- glibc-2.27-orig/locale/programs/locarchive.c	2018-02-01 11:17:18.000000000 -0500
-+++ glibc-2.27/locale/programs/locarchive.c	2018-02-17 22:40:51.245293975 -0500
-@@ -117,6 +117,22 @@
- }
- 
- 
-+static int
-+open_locale_archive (const char * archivefname, int flags)
-+{
-+  int fd = -1;
-+  char *versioned_path = getenv ("LOCALE_ARCHIVE_2_27");
-+  char *path = getenv ("LOCALE_ARCHIVE");
-+  if (versioned_path)
-+    fd = open64 (versioned_path, flags);
-+  if (path && fd < 0)
-+    fd = open64 (path, flags);
-+  if (fd < 0)
-+    fd = open64 (archivefname, flags);
-+  return fd;
-+}
-+
-+
- static void
- create_archive (const char *archivefname, struct locarhandle *ah)
- {
-@@ -578,7 +594,7 @@
-   while (1)
-     {
-       /* Open the archive.  We must have exclusive write access.  */
--      fd = open64 (archivefname, readonly ? O_RDONLY : O_RDWR);
-+      fd = open_locale_archive (archivefname, readonly ? O_RDONLY : O_RDWR);
-       if (fd == -1)
- 	{
- 	  /* Maybe the file does not yet exist? If we are opening
diff --git a/pkgs/development/libraries/glibc/nix-locale-archive.patch b/pkgs/development/libraries/glibc/nix-locale-archive.patch
index eeaf21901a3..39312951fcf 100644
--- a/pkgs/development/libraries/glibc/nix-locale-archive.patch
+++ b/pkgs/development/libraries/glibc/nix-locale-archive.patch
@@ -1,114 +1,118 @@
-diff -ru glibc-2.16.0-orig/locale/loadarchive.c glibc-2.16.0/locale/loadarchive.c
---- glibc-2.16.0-orig/locale/loadarchive.c	2012-06-30 15:12:34.000000000 -0400
-+++ glibc-2.16.0/locale/loadarchive.c	2012-09-18 11:57:57.277515212 -0400
-@@ -123,6 +123,25 @@
+diff -Naur glibc-2.27-orig/locale/loadarchive.c glibc-2.27/locale/loadarchive.c
+--- glibc-2.27-orig/locale/loadarchive.c	2018-02-01 11:17:18.000000000 -0500
++++ glibc-2.27/locale/loadarchive.c	2018-02-17 22:32:25.680169462 -0500
+@@ -123,6 +123,23 @@
+   return MAX (namehash_end, MAX (string_end, locrectab_end));
  }
  
- 
 +static int
 +open_locale_archive (void)
 +{
 +  int fd = -1;
-+  char *path = getenv ("LOCALE_ARCHIVE_2_11");
-+  char *path2 = getenv ("LOCALE_ARCHIVE");
-+  const char *usualpath = "/usr/lib/locale/locale-archive";
-+  if (path)
-+    fd = open_not_cancel_2 (path, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
-+  if (path2 && fd < 0)
-+    fd = open_not_cancel_2 (path2, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
++  char *versioned_path = getenv ("LOCALE_ARCHIVE_2_27");
++  char *path = getenv ("LOCALE_ARCHIVE");
++  if (versioned_path)
++    fd = __open_nocancel (versioned_path, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
++  if (path && fd < 0)
++    fd = __open_nocancel (path, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
 +  if (fd < 0)
-+    fd = open_not_cancel_2 (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
++    fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
 +  if (fd < 0)
-+    fd = open_not_cancel_2 (usualpath, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
++    fd = __open_nocancel ("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE|O_CLOEXEC);
 +  return fd;
 +}
 +
-+
+ 
  /* Find the locale *NAMEP in the locale archive, and return the
     internalized data structure for its CATEGORY data.  If this locale has
-    already been loaded from the archive, just returns the existing data
-@@ -202,7 +221,7 @@
+@@ -202,7 +219,7 @@
        archmapped = &headmap;
  
        /* The archive has never been opened.  */
--      fd = open_not_cancel_2 (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+-      fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
 +      fd = open_locale_archive ();
        if (fd < 0)
  	/* Cannot open the archive, for whatever reason.  */
  	return NULL;
-@@ -393,8 +412,7 @@
+@@ -397,8 +414,7 @@
  	  if (fd == -1)
  	    {
  	      struct stat64 st;
--	      fd = open_not_cancel_2 (archfname,
--				      O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+-	      fd = __open_nocancel (archfname,
+-				    O_RDONLY|O_LARGEFILE|O_CLOEXEC);
 +	      fd = open_locale_archive ();
  	      if (fd == -1)
  		/* Cannot open the archive, for whatever reason.  */
  		return NULL;
-diff -ru glibc-2.16.0-orig/locale/programs/locale.c glibc-2.16.0/locale/programs/locale.c
---- glibc-2.16.0-orig/locale/programs/locale.c	2012-06-30 15:12:34.000000000 -0400
-+++ glibc-2.16.0/locale/programs/locale.c	2012-09-18 11:53:03.719920947 -0400
-@@ -628,6 +628,20 @@
- 		  ((const struct nameent *) b)->name);
- }
+diff -Naur glibc-2.27-orig/locale/programs/locale.c glibc-2.27/locale/programs/locale.c
+--- glibc-2.27-orig/locale/programs/locale.c	2018-02-01 11:17:18.000000000 -0500
++++ glibc-2.27/locale/programs/locale.c	2018-02-17 22:36:39.726293213 -0500
+@@ -633,6 +633,24 @@
  
-+static int
-+open_nix_locale_archive (const char * fname, int access)
+ 
+ static int
++open_locale_archive (void)
 +{
 +  int fd = -1;
-+  char *path = getenv ("LOCALE_ARCHIVE_2_11");
-+  char *path2 = getenv ("LOCALE_ARCHIVE");
-+  if (path)
-+    fd = open64 (path, access);
-+  if (path2 && fd < 0)
-+    fd = open64 (path2, access);
++  char *versioned_path = getenv ("LOCALE_ARCHIVE_2_27");
++  char *path = getenv ("LOCALE_ARCHIVE");
++  if (versioned_path)
++    fd = open64 (versioned_path, O_RDONLY);
++  if (path && fd < 0)
++    fd = open64 (path, O_RDONLY);
++  if (fd < 0)
++    fd = open64 (ARCHIVE_NAME, O_RDONLY);
 +  if (fd < 0)
-+    fd = open64 (fname, access);
++    fd = open64 ("/usr/lib/locale/locale-archive", O_RDONLY);
 +  return fd;
 +}
- 
- static int
++
++
++static int
  write_archive_locales (void **all_datap, char *linebuf)
-@@ -641,7 +655,7 @@
+ {
+   struct stat64 st;
+@@ -644,7 +662,7 @@
    int fd, ret = 0;
    uint32_t cnt;
  
 -  fd = open64 (ARCHIVE_NAME, O_RDONLY);
-+  fd = open_nix_locale_archive (ARCHIVE_NAME, O_RDONLY);
++  fd = open_locale_archive ();
    if (fd < 0)
      return 0;
  
-diff -ru glibc-2.16.0-orig/locale/programs/locarchive.c glibc-2.16.0/locale/programs/locarchive.c
---- glibc-2.16.0-orig/locale/programs/locarchive.c	2012-06-30 15:12:34.000000000 -0400
-+++ glibc-2.16.0/locale/programs/locarchive.c	2012-09-18 11:53:03.720920942 -0400
-@@ -509,6 +509,20 @@
-   *ah = new_ah;
+diff -Naur glibc-2.27-orig/locale/programs/locarchive.c glibc-2.27/locale/programs/locarchive.c
+--- glibc-2.27-orig/locale/programs/locarchive.c	2018-02-01 11:17:18.000000000 -0500
++++ glibc-2.27/locale/programs/locarchive.c	2018-02-17 22:40:51.245293975 -0500
+@@ -117,6 +117,22 @@
  }
  
+ 
 +static int
-+open_nix_locale_archive (const char * fname, int access)
++open_locale_archive (const char * archivefname, int flags)
 +{
 +  int fd = -1;
-+  char *path = getenv ("LOCALE_ARCHIVE_2_11");
-+  char *path2 = getenv ("LOCALE_ARCHIVE");
-+  if (path)
-+    fd = open64 (path, access);
-+  if (path2 && fd < 0)
-+    fd = open64 (path2, access);
++  char *versioned_path = getenv ("LOCALE_ARCHIVE_2_27");
++  char *path = getenv ("LOCALE_ARCHIVE");
++  if (versioned_path)
++    fd = open64 (versioned_path, flags);
++  if (path && fd < 0)
++    fd = open64 (path, flags);
 +  if (fd < 0)
-+    fd = open64 (fname, access);
++    fd = open64 (archivefname, flags);
 +  return fd;
 +}
- 
- void
- open_archive (struct locarhandle *ah, bool readonly)
-@@ -528,7 +542,7 @@
++
++
+ static void
+ create_archive (const char *archivefname, struct locarhandle *ah)
+ {
+@@ -578,7 +594,7 @@
    while (1)
      {
        /* Open the archive.  We must have exclusive write access.  */
 -      fd = open64 (archivefname, readonly ? O_RDONLY : O_RDWR);
-+      fd = open_nix_locale_archive (archivefname, readonly ? O_RDONLY : O_RDWR);
++      fd = open_locale_archive (archivefname, readonly ? O_RDONLY : O_RDWR);
        if (fd == -1)
  	{
- 	  /* Maybe the file does not yet exist.  */
+ 	  /* Maybe the file does not yet exist? If we are opening
diff --git a/pkgs/development/libraries/gnu-efi/default.nix b/pkgs/development/libraries/gnu-efi/default.nix
index a46abe3b4f7..940b4e2aee4 100644
--- a/pkgs/development/libraries/gnu-efi/default.nix
+++ b/pkgs/development/libraries/gnu-efi/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "gnu-efi-${version}";
-  version = "3.0.6";
+  version = "3.0.8";
 
   src = fetchurl {
     url = "mirror://sourceforge/gnu-efi/${name}.tar.bz2";
-    sha256 = "149cyadpn2jm4zxfn1qmpm520iqssp9p07d650rs5ghgv015jl91";
+    sha256 = "08mpw8s79azip9jbzm6msq0999pnkqzd82axydrcyyynm276s03n";
   };
 
   buildInputs = [ pciutils ];
diff --git a/pkgs/development/libraries/gnutls/generic.nix b/pkgs/development/libraries/gnutls/generic.nix
index 8769584a9f2..984603827c8 100644
--- a/pkgs/development/libraries/gnutls/generic.nix
+++ b/pkgs/development/libraries/gnutls/generic.nix
@@ -40,9 +40,7 @@ stdenv.mkDerivation {
 
   enableParallelBuilding = true;
 
-  buildInputs = [ lzo lzip libtasn1 libidn p11-kit zlib gmp autogen libunistring unbound ]
-    ++ lib.optional (stdenv.isFreeBSD || stdenv.isDarwin) libiconv
-    ++ lib.optional stdenv.isDarwin gettext
+  buildInputs = [ lzo lzip libtasn1 libidn p11-kit zlib gmp autogen libunistring unbound gettext libiconv ]
     ++ lib.optional (tpmSupport && stdenv.isLinux) trousers
     ++ lib.optional guileBindings guile
     ++ buildInputs;
diff --git a/pkgs/development/libraries/gobject-introspection/default.nix b/pkgs/development/libraries/gobject-introspection/default.nix
index 3c884bb1224..f79511897fb 100644
--- a/pkgs/development/libraries/gobject-introspection/default.nix
+++ b/pkgs/development/libraries/gobject-introspection/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, glib, flex, bison, pkgconfig, libffi, python
-, libintlOrEmpty, cctools, cairo, gnome3
+, libintl, cctools, cairo, gnome3
 , substituteAll, nixStoreDir ? builtins.storeDir
 , x11Support ? true
 }:
@@ -24,9 +24,8 @@ stdenv.mkDerivation rec {
   outputBin = "dev";
   outputMan = "dev"; # tiny pages
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig libintl ];
   buildInputs = [ flex bison python setupHook/*move .gir*/ ]
-    ++ libintlOrEmpty
     ++ stdenv.lib.optional stdenv.isDarwin cctools;
   propagatedBuildInputs = [ libffi glib ];
 
diff --git a/pkgs/development/libraries/gstreamer/bad/default.nix b/pkgs/development/libraries/gstreamer/bad/default.nix
index d4cc2f43aaa..72fead258f5 100644
--- a/pkgs/development/libraries/gstreamer/bad/default.nix
+++ b/pkgs/development/libraries/gstreamer/bad/default.nix
@@ -6,7 +6,7 @@
 , openjpeg, libopus, librsvg
 , wildmidi, fluidsynth, libvdpau, wayland
 , libwebp, xvidcore, gnutls, mjpegtools
-, libGLU_combined, libintlOrEmpty, libgme
+, libGLU_combined, libintl, libgme
 , openssl, x265, libxml2
 }:
 
@@ -63,8 +63,8 @@ stdenv.mkDerivation rec {
     fluidsynth libvdpau
     libwebp xvidcore gnutls libGLU_combined
     libgme openssl x265 libxml2
+    libintl
   ]
-    ++ libintlOrEmpty
     ++ optional faacSupport faac
     # for gtksink
     ++ optional gtkSupport gtk3
@@ -75,7 +75,5 @@ stdenv.mkDerivation rec {
     # TODO: mjpegtools uint64_t is not compatible with guint64 on Darwin
     ++ optional (!stdenv.isDarwin) mjpegtools;
 
-  LDFLAGS = optionalString stdenv.isDarwin "-lintl";
-
   enableParallelBuilding = true;
 }
diff --git a/pkgs/development/libraries/gstreamer/base/default.nix b/pkgs/development/libraries/gstreamer/base/default.nix
index 2cd0c14c1f3..c0c03dc1566 100644
--- a/pkgs/development/libraries/gstreamer/base/default.nix
+++ b/pkgs/development/libraries/gstreamer/base/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, pkgconfig, python, gstreamer, gobjectIntrospection
 , orc, alsaLib, libXv, pango, libtheora
-, cdparanoia, libvisual, libintlOrEmpty
+, cdparanoia, libvisual, libintl
 }:
 
 stdenv.mkDerivation rec {
@@ -25,9 +25,8 @@ stdenv.mkDerivation rec {
   ];
 
   buildInputs = [
-    orc libXv pango libtheora cdparanoia
+    orc libXv pango libtheora cdparanoia libintl
   ]
-  ++ libintlOrEmpty
   ++ stdenv.lib.optional stdenv.isLinux alsaLib
   ++ stdenv.lib.optional (!stdenv.isDarwin) libvisual;
 
@@ -40,7 +39,5 @@ stdenv.mkDerivation rec {
     "--disable-cdparanoia"
   ] else null;
 
-  NIX_LDFLAGS = if stdenv.isDarwin then "-lintl" else null;
-
   enableParallelBuilding = true;
 }
diff --git a/pkgs/development/libraries/gstreamer/default.nix b/pkgs/development/libraries/gstreamer/default.nix
index 76cffa89dbc..97f775e8e58 100644
--- a/pkgs/development/libraries/gstreamer/default.nix
+++ b/pkgs/development/libraries/gstreamer/default.nix
@@ -1,4 +1,4 @@
-{ callPackage, libva-full }:
+{ callPackage }:
 
 rec {
   gstreamer = callPackage ./core { };
@@ -23,7 +23,6 @@ rec {
 
   gst-vaapi = callPackage ./vaapi {
     inherit gst-plugins-base gstreamer gst-plugins-bad;
-    libva = libva-full; # looks also for libva-{x11,wayland}
   };
 
   gst-validate = callPackage ./validate { inherit gst-plugins-base; };
diff --git a/pkgs/development/libraries/gstreamer/good/default.nix b/pkgs/development/libraries/gstreamer/good/default.nix
index e4e4f3b394d..daca02c408b 100644
--- a/pkgs/development/libraries/gstreamer/good/default.nix
+++ b/pkgs/development/libraries/gstreamer/good/default.nix
@@ -3,7 +3,7 @@
 , libv4l, libdv, libavc1394, libiec61883
 , libvpx, speex, flac, taglib, libshout
 , cairo, gdk_pixbuf, aalib, libcaca
-, libsoup, libpulseaudio, libintlOrEmpty
+, libsoup, libpulseaudio, libintl
 , darwin
 }:
 
@@ -38,9 +38,8 @@ stdenv.mkDerivation rec {
     gst-plugins-base orc bzip2
     libdv libvpx speex flac taglib
     cairo gdk_pixbuf aalib libcaca
-    libsoup libshout
+    libsoup libshout libintl
   ]
-  ++ libintlOrEmpty
   ++ optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ]
   ++ optionals stdenv.isLinux [ libv4l libpulseaudio libavc1394 libiec61883 ];
 
@@ -48,6 +47,4 @@ stdenv.mkDerivation rec {
     mkdir -p "$dev/lib/gstreamer-1.0"
     mv "$out/lib/gstreamer-1.0/"*.la "$dev/lib/gstreamer-1.0"
   '';
-
-  LDFLAGS = optionalString stdenv.isDarwin "-lintl";
 }
diff --git a/pkgs/development/libraries/gstreamer/legacy/gst-plugins-base/default.nix b/pkgs/development/libraries/gstreamer/legacy/gst-plugins-base/default.nix
index 2c2e1b0da12..8371b278040 100644
--- a/pkgs/development/libraries/gstreamer/legacy/gst-plugins-base/default.nix
+++ b/pkgs/development/libraries/gstreamer/legacy/gst-plugins-base/default.nix
@@ -1,6 +1,6 @@
 { fetchurl, stdenv, pkgconfig, python, gstreamer, xorg, alsaLib, cdparanoia
 , libogg, libtheora, libvorbis, freetype, pango, liboil, glib, cairo, orc
-, libintlOrEmpty
+, libintl
 , ApplicationServices
 , # Whether to build no plugins that have external dependencies
   # (except the ALSA plugin).
@@ -29,7 +29,7 @@ stdenv.mkDerivation rec {
 
   # TODO : v4l, libvisual
   buildInputs =
-    [ pkgconfig glib cairo orc ]
+    [ pkgconfig glib cairo orc libintl ]
     # can't build alsaLib on darwin
     ++ stdenv.lib.optional (!stdenv.isDarwin) alsaLib
     ++ stdenv.lib.optionals (!minimalDeps)
@@ -37,11 +37,8 @@ stdenv.mkDerivation rec {
         liboil ]
     # can't build cdparanoia on darwin
     ++ stdenv.lib.optional (!minimalDeps && !stdenv.isDarwin) cdparanoia
-    ++ libintlOrEmpty
     ++ stdenv.lib.optional stdenv.isDarwin ApplicationServices;
 
-  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-lintl";
-
   propagatedBuildInputs = [ gstreamer ];
 
   postInstall = "rm -rf $out/share/gtk-doc";
diff --git a/pkgs/development/libraries/gstreamer/legacy/gst-plugins-good/default.nix b/pkgs/development/libraries/gstreamer/legacy/gst-plugins-good/default.nix
index d533f798d99..75583624f54 100644
--- a/pkgs/development/libraries/gstreamer/legacy/gst-plugins-good/default.nix
+++ b/pkgs/development/libraries/gstreamer/legacy/gst-plugins-good/default.nix
@@ -1,7 +1,7 @@
 { fetchurl, stdenv, lib, pkgconfig, gst-plugins-base, aalib, cairo
 , flac, libjpeg, zlib, speex, libpng, libdv, libcaca, libvpx
 , libiec61883, libavc1394, taglib, libpulseaudio, gdk_pixbuf, orc
-, glib, gstreamer, bzip2, libsoup, libshout, ncurses, libintlOrEmpty
+, glib, gstreamer, bzip2, libsoup, libshout, ncurses, libintl
 , # Whether to build no plugins that have external dependencies
   # (except the PulseAudio plugin).
   minimalDeps ? false
@@ -23,15 +23,12 @@ stdenv.mkDerivation rec {
   configureFlags = [ "--enable-experimental" "--disable-oss" ];
 
   buildInputs =
-    [ pkgconfig glib gstreamer gst-plugins-base ]
+    [ pkgconfig glib gstreamer gst-plugins-base libintl ]
     ++ lib.optional stdenv.isLinux libpulseaudio
-    ++ libintlOrEmpty
     ++ lib.optionals (!minimalDeps)
       [ aalib libcaca cairo libdv flac libjpeg libpng speex
         taglib bzip2 libvpx gdk_pixbuf orc libsoup libshout ];
 
-  NIX_LDFLAGS = if stdenv.isDarwin then "-lintl" else null;
-
   enableParallelBuilding = true;
 
   postInstall = lib.optionalString (!minimalDeps) ''
diff --git a/pkgs/development/libraries/gstreamer/legacy/gst-plugins-ugly/default.nix b/pkgs/development/libraries/gstreamer/legacy/gst-plugins-ugly/default.nix
index 5c289fb3911..ac680f8432a 100644
--- a/pkgs/development/libraries/gstreamer/legacy/gst-plugins-ugly/default.nix
+++ b/pkgs/development/libraries/gstreamer/legacy/gst-plugins-ugly/default.nix
@@ -1,5 +1,5 @@
 { fetchurl, stdenv, pkgconfig, glib, gstreamer, gst-plugins-base
-, libmad, libdvdread, libmpeg2, libcdio, a52dec, x264, orc, lame, libintlOrEmpty }:
+, libmad, libdvdread, libmpeg2, libcdio, a52dec, x264, orc, lame, libintl }:
 
 stdenv.mkDerivation rec {
   name = "gst-plugins-ugly-0.10.19";
@@ -13,9 +13,7 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs =
-    [ pkgconfig glib gstreamer gst-plugins-base libmad libdvdread a52dec x264 orc lame ] ++ libintlOrEmpty;
-
-  NIX_LDFLAGS = if stdenv.isDarwin then "-lintl" else null;
+    [ pkgconfig glib gstreamer gst-plugins-base libmad libdvdread a52dec x264 orc lame libintl ];
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/gstreamer/legacy/gstreamer/default.nix b/pkgs/development/libraries/gstreamer/legacy/gstreamer/default.nix
index 55d34a3fada..e46ecfb7612 100644
--- a/pkgs/development/libraries/gstreamer/legacy/gstreamer/default.nix
+++ b/pkgs/development/libraries/gstreamer/legacy/gstreamer/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, perl, bison, flex, pkgconfig, glib, libxml2, libintlOrEmpty }:
+{ fetchurl, stdenv, perl, bison, flex, pkgconfig, glib, libxml2, libintl }:
 
 stdenv.mkDerivation rec {
   name = "gstreamer-0.10.36";
@@ -13,9 +13,9 @@ stdenv.mkDerivation rec {
 
   outputs = [ "out" "dev" ];
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig libintl ];
   buildInputs = [ perl bison flex ];
-  propagatedBuildInputs = [ glib libxml2 ] ++ libintlOrEmpty;
+  propagatedBuildInputs = [ glib libxml2 ];
 
   patchPhase = ''
     sed -i -e 's/^   /\t/' docs/gst/Makefile.in docs/libs/Makefile.in docs/plugins/Makefile.in
diff --git a/pkgs/development/libraries/gstreamer/ugly/default.nix b/pkgs/development/libraries/gstreamer/ugly/default.nix
index cdaa88ce350..a4083b3e84b 100644
--- a/pkgs/development/libraries/gstreamer/ugly/default.nix
+++ b/pkgs/development/libraries/gstreamer/ugly/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, pkgconfig, python
 , gst-plugins-base, orc
 , a52dec, libcdio, libdvdread
-, lame, libmad, libmpeg2, x264, libintlOrEmpty, mpg123
+, lame, libmad, libmpeg2, x264, libintl, mpg123
 }:
 
 stdenv.mkDerivation rec {
@@ -33,7 +33,6 @@ stdenv.mkDerivation rec {
     gst-plugins-base orc
     a52dec libcdio libdvdread
     lame libmad libmpeg2 x264 mpg123
-  ] ++ libintlOrEmpty;
-
-  NIX_LDFLAGS = if stdenv.isDarwin then "-lintl" else null;
+    libintl
+  ];
 }
diff --git a/pkgs/development/libraries/gtk+/2.x.nix b/pkgs/development/libraries/gtk+/2.x.nix
index 8a3ce884dfd..d35e47f312f 100644
--- a/pkgs/development/libraries/gtk+/2.x.nix
+++ b/pkgs/development/libraries/gtk+/2.x.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, pkgconfig, gettext, glib, atk, pango, cairo, perl, xorg
-, gdk_pixbuf, libintlOrEmpty, xlibsWrapper, gobjectIntrospection
+, gdk_pixbuf, xlibsWrapper, gobjectIntrospection
 , xineramaSupport ? stdenv.isLinux
 , cupsSupport ? true, cups ? null
 , gdktarget ? "x11"
@@ -24,8 +24,6 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  NIX_CFLAGS_COMPILE = optionalString (libintlOrEmpty != []) "-lintl";
-
   setupHook = ./setup-hook.sh;
 
   nativeBuildInputs = [ setupHook perl pkgconfig gettext gobjectIntrospection ];
@@ -38,7 +36,6 @@ stdenv.mkDerivation rec {
          libXrandr libXrender libXcomposite libXi libXcursor
        ]
     ++ optionals stdenv.isDarwin [ xlibsWrapper libXdamage ]
-    ++ libintlOrEmpty
     ++ optional xineramaSupport libXinerama
     ++ optionals cupsSupport [ cups ]
     ++ optionals stdenv.isDarwin [ AppKit Cocoa ];
diff --git a/pkgs/development/libraries/gtk+/3.x.nix b/pkgs/development/libraries/gtk+/3.x.nix
index c96139ddb57..dc6a519dfad 100644
--- a/pkgs/development/libraries/gtk+/3.x.nix
+++ b/pkgs/development/libraries/gtk+/3.x.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, fetchpatch, pkgconfig, gettext, perl, makeWrapper, shared-mime-info
 , expat, glib, cairo, pango, gdk_pixbuf, atk, at-spi2-atk, gobjectIntrospection
 , xorg, epoxy, json-glib, libxkbcommon, gmp
-, waylandSupport ? stdenv.isLinux, wayland, wayland-protocols
+, waylandSupport ? stdenv.isLinux, mesa_noglu, wayland, wayland-protocols
 , xineramaSupport ? stdenv.isLinux
 , cupsSupport ? stdenv.isLinux, cups ? null
 , darwin, gnome3
@@ -40,14 +40,12 @@ stdenv.mkDerivation rec {
   propagatedBuildInputs = with xorg; with stdenv.lib;
     [ expat glib cairo pango gdk_pixbuf atk at-spi2-atk gnome3.gsettings-desktop-schemas
       libXrandr libXrender libXcomposite libXi libXcursor libSM libICE ]
-    ++ optionals waylandSupport [ wayland wayland-protocols ]
+    ++ optionals waylandSupport [ mesa_noglu wayland wayland-protocols ]
     ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ AppKit Cocoa ])
     ++ optional xineramaSupport libXinerama
     ++ optional cupsSupport cups;
   #TODO: colord?
 
-  NIX_LDFLAGS = optionalString stdenv.isDarwin "-lintl";
-
   # demos fail to install, no idea where's the problem
   preConfigure = "sed '/^SRC_SUBDIRS /s/demos//' -i Makefile.in";
 
diff --git a/pkgs/development/libraries/gts/default.nix b/pkgs/development/libraries/gts/default.nix
index 59b3a34f7bd..770f743fd26 100644
--- a/pkgs/development/libraries/gts/default.nix
+++ b/pkgs/development/libraries/gts/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ glib ] ++ stdenv.lib.optional (stdenv.system == "x86_64-darwin") gettext;
+  buildInputs = [ glib gettext ];
 
   meta = {
     homepage = http://gts.sourceforge.net/;
diff --git a/pkgs/development/libraries/harfbuzz/default.nix b/pkgs/development/libraries/harfbuzz/default.nix
index bb68ae94a7f..9b2e2e27f42 100644
--- a/pkgs/development/libraries/harfbuzz/default.nix
+++ b/pkgs/development/libraries/harfbuzz/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, glib, freetype, cairo, libintlOrEmpty
+{ stdenv, fetchurl, pkgconfig, glib, freetype, cairo, libintl
 , icu, graphite2, harfbuzz # The icu variant uses and propagates the non-icu one.
 , withIcu ? false # recommended by upstream as default, but most don't needed and it's big
 , withGraphite2 ? true # it is small and major distros do include it
@@ -25,9 +25,8 @@ stdenv.mkDerivation {
     ( "--with-icu=" +       (if withIcu       then "yes" else "no") )
   ];
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ glib freetype cairo ] # recommended by upstream
-    ++ libintlOrEmpty;
+  nativeBuildInputs = [ pkgconfig libintl ];
+  buildInputs = [ glib freetype cairo ]; # recommended by upstream
   propagatedBuildInputs = []
     ++ optional withGraphite2 graphite2
     ++ optionals withIcu [ icu harfbuzz ]
diff --git a/pkgs/development/libraries/json-glib/default.nix b/pkgs/development/libraries/json-glib/default.nix
index bf32f4f8e8b..21bddf8f6bb 100644
--- a/pkgs/development/libraries/json-glib/default.nix
+++ b/pkgs/development/libraries/json-glib/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, fetchpatch, glib, meson, ninja, pkgconfig, gettext
-, gobjectIntrospection, dbus, libintlOrEmpty
+, gobjectIntrospection, dbus
 , fixDarwinDylibNames
 }:
 
@@ -14,10 +14,7 @@ stdenv.mkDerivation rec {
 
   propagatedBuildInputs = [ glib ];
   nativeBuildInputs = [ meson ninja pkgconfig gettext gobjectIntrospection ];
-  buildInputs = libintlOrEmpty
-    ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
-
-  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-lintl";
+  buildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
   patches = [
     # https://gitlab.gnome.org/GNOME/json-glib/issues/27
diff --git a/pkgs/development/libraries/libassuan/default.nix b/pkgs/development/libraries/libassuan/default.nix
index 827d3de79ea..91ceb959779 100644
--- a/pkgs/development/libraries/libassuan/default.nix
+++ b/pkgs/development/libraries/libassuan/default.nix
@@ -11,8 +11,7 @@ stdenv.mkDerivation rec {
   outputs = [ "out" "dev" "info" ];
   outputBin = "dev"; # libassuan-config
 
-  buildInputs = [ libgpgerror pth ]
-    ++ stdenv.lib.optional stdenv.isDarwin gettext;
+  buildInputs = [ libgpgerror pth gettext];
 
   doCheck = true;
 
diff --git a/pkgs/development/libraries/libbsd/cdefs.patch b/pkgs/development/libraries/libbsd/cdefs.patch
new file mode 100644
index 00000000000..81822654aeb
--- /dev/null
+++ b/pkgs/development/libraries/libbsd/cdefs.patch
@@ -0,0 +1,222 @@
+From 11ec8f1e5dfa1c10e0c9fb94879b6f5b96ba52dd Mon Sep 17 00:00:00 2001
+From: Guillem Jover <guillem@hadrons.org>
+Date: Tue, 6 Mar 2018 01:41:35 +0100
+Subject: Handle systems missing <sys/cdefs.h>
+
+This is a non-portable header, and we cannot expect it to be provided by
+the system libc (e.g. musl). We just need and rely on declaration that
+we have defined ourselves in our own <bsd/sys/cdefs.h>. So we switch to
+only ever assume that.
+
+Fixes: https://bugs.freedesktop.org/105281
+---
+ include/bsd/libutil.h        | 4 ++++
+ include/bsd/md5.h            | 4 ++++
+ include/bsd/nlist.h          | 4 ++++
+ include/bsd/readpassphrase.h | 4 ++++
+ include/bsd/stdlib.h         | 4 ++++
+ include/bsd/string.h         | 4 ++++
+ include/bsd/stringlist.h     | 5 +++++
+ include/bsd/sys/queue.h      | 4 ++++
+ include/bsd/sys/tree.h       | 4 ++++
+ include/bsd/timeconv.h       | 4 ++++
+ include/bsd/vis.h            | 4 ++++
+ include/bsd/wchar.h          | 4 ++++
+ 12 files changed, 49 insertions(+)
+
+diff --git a/include/bsd/libutil.h b/include/bsd/libutil.h
+index 45b3b15..ccca29a 100644
+--- a/include/bsd/libutil.h
++++ b/include/bsd/libutil.h
+@@ -40,7 +40,11 @@
+ #define LIBBSD_LIBUTIL_H
+ 
+ #include <features.h>
++#ifdef LIBBSD_OVERLAY
+ #include <sys/cdefs.h>
++#else
++#include <bsd/sys/cdefs.h>
++#endif
+ #include <sys/types.h>
+ #include <stdint.h>
+ #include <stdio.h>
+diff --git a/include/bsd/md5.h b/include/bsd/md5.h
+index 5f3ae46..bf36a30 100644
+--- a/include/bsd/md5.h
++++ b/include/bsd/md5.h
+@@ -27,7 +27,11 @@ typedef struct MD5Context {
+ 	uint8_t buffer[MD5_BLOCK_LENGTH];	/* input buffer */
+ } MD5_CTX;
+ 
++#ifdef LIBBSD_OVERLAY
+ #include <sys/cdefs.h>
++#else
++#include <bsd/sys/cdefs.h>
++#endif
+ #include <sys/types.h>
+ 
+ __BEGIN_DECLS
+diff --git a/include/bsd/nlist.h b/include/bsd/nlist.h
+index cb297e8..8767117 100644
+--- a/include/bsd/nlist.h
++++ b/include/bsd/nlist.h
+@@ -27,7 +27,11 @@
+ #ifndef LIBBSD_NLIST_H
+ #define LIBBSD_NLIST_H
+ 
++#ifdef LIBBSD_OVERLAY
+ #include <sys/cdefs.h>
++#else
++#include <bsd/sys/cdefs.h>
++#endif
+ 
+ struct nlist {
+ 	union {
+diff --git a/include/bsd/readpassphrase.h b/include/bsd/readpassphrase.h
+index 14744b8..5eb8021 100644
+--- a/include/bsd/readpassphrase.h
++++ b/include/bsd/readpassphrase.h
+@@ -31,7 +31,11 @@
+ #define RPP_SEVENBIT    0x10		/* Strip the high bit from input. */
+ #define RPP_STDIN       0x20		/* Read from stdin, not /dev/tty */
+ 
++#ifdef LIBBSD_OVERLAY
+ #include <sys/cdefs.h>
++#else
++#include <bsd/sys/cdefs.h>
++#endif
+ #include <sys/types.h>
+ 
+ __BEGIN_DECLS
+diff --git a/include/bsd/stdlib.h b/include/bsd/stdlib.h
+index ebc9638..8d33d1f 100644
+--- a/include/bsd/stdlib.h
++++ b/include/bsd/stdlib.h
+@@ -42,7 +42,11 @@
+ #ifndef LIBBSD_STDLIB_H
+ #define LIBBSD_STDLIB_H
+ 
++#ifdef LIBBSD_OVERLAY
+ #include <sys/cdefs.h>
++#else
++#include <bsd/sys/cdefs.h>
++#endif
+ #include <sys/stat.h>
+ #include <stdint.h>
+ 
+diff --git a/include/bsd/string.h b/include/bsd/string.h
+index 6798bf6..29097f6 100644
+--- a/include/bsd/string.h
++++ b/include/bsd/string.h
+@@ -33,7 +33,11 @@
+ #ifndef LIBBSD_STRING_H
+ #define LIBBSD_STRING_H
+ 
++#ifdef LIBBSD_OVERLAY
+ #include <sys/cdefs.h>
++#else
++#include <bsd/sys/cdefs.h>
++#endif
+ #include <sys/types.h>
+ 
+ __BEGIN_DECLS
+diff --git a/include/bsd/stringlist.h b/include/bsd/stringlist.h
+index ff30cac..dd71496 100644
+--- a/include/bsd/stringlist.h
++++ b/include/bsd/stringlist.h
+@@ -31,7 +31,12 @@
+ 
+ #ifndef LIBBSD_STRINGLIST_H
+ #define LIBBSD_STRINGLIST_H
++
++#ifdef LIBBSD_OVERLAY
+ #include <sys/cdefs.h>
++#else
++#include <bsd/sys/cdefs.h>
++#endif
+ #include <sys/types.h>
+ 
+ /*
+diff --git a/include/bsd/sys/queue.h b/include/bsd/sys/queue.h
+index 4a94ea7..ac00026 100644
+--- a/include/bsd/sys/queue.h
++++ b/include/bsd/sys/queue.h
+@@ -33,7 +33,11 @@
+ #ifndef LIBBSD_SYS_QUEUE_H
+ #define LIBBSD_SYS_QUEUE_H
+ 
++#ifdef LIBBSD_OVERLAY
+ #include <sys/cdefs.h>
++#else
++#include <bsd/sys/cdefs.h>
++#endif
+ 
+ /*
+  * This file defines four types of data structures: singly-linked lists,
+diff --git a/include/bsd/sys/tree.h b/include/bsd/sys/tree.h
+index 628bec0..325b382 100644
+--- a/include/bsd/sys/tree.h
++++ b/include/bsd/sys/tree.h
+@@ -30,7 +30,11 @@
+ #ifndef LIBBSD_SYS_TREE_H
+ #define LIBBSD_SYS_TREE_H
+ 
++#ifdef LIBBSD_OVERLAY
+ #include <sys/cdefs.h>
++#else
++#include <bsd/sys/cdefs.h>
++#endif
+ 
+ /*
+  * This file defines data structures for different types of trees:
+diff --git a/include/bsd/timeconv.h b/include/bsd/timeconv.h
+index e2a2c55..a426bd3 100644
+--- a/include/bsd/timeconv.h
++++ b/include/bsd/timeconv.h
+@@ -41,7 +41,11 @@
+ #ifndef LIBBSD_TIMECONV_H
+ #define LIBBSD_TIMECONV_H
+ 
++#ifdef LIBBSD_OVERLAY
+ #include <sys/cdefs.h>
++#else
++#include <bsd/sys/cdefs.h>
++#endif
+ #include <stdint.h>
+ #include <time.h>
+ 
+diff --git a/include/bsd/vis.h b/include/bsd/vis.h
+index 970dfdd..ab5430c 100644
+--- a/include/bsd/vis.h
++++ b/include/bsd/vis.h
+@@ -72,7 +72,11 @@
+  */
+ #define	UNVIS_END	1	/* no more characters */
+ 
++#ifdef LIBBSD_OVERLAY
+ #include <sys/cdefs.h>
++#else
++#include <bsd/sys/cdefs.h>
++#endif
+ 
+ __BEGIN_DECLS
+ char	*vis(char *, int, int, int);
+diff --git a/include/bsd/wchar.h b/include/bsd/wchar.h
+index 33a500e..7216503 100644
+--- a/include/bsd/wchar.h
++++ b/include/bsd/wchar.h
+@@ -40,7 +40,11 @@
+ #define LIBBSD_WCHAR_H
+ 
+ #include <stddef.h>
++#ifdef LIBBSD_OVERLAY
+ #include <sys/cdefs.h>
++#else
++#include <bsd/sys/cdefs.h>
++#endif
+ #include <sys/types.h>
+ 
+ __BEGIN_DECLS
+-- 
+cgit v1.1
+
diff --git a/pkgs/development/libraries/libbsd/default.nix b/pkgs/development/libraries/libbsd/default.nix
index 0e232a50e94..ff9412ceb58 100644
--- a/pkgs/development/libraries/libbsd/default.nix
+++ b/pkgs/development/libraries/libbsd/default.nix
@@ -13,7 +13,16 @@ stdenv.mkDerivation rec {
   # the configure scripts
   nativeBuildInputs = [ autoreconfHook ];
 
-  patches = stdenv.lib.optionals stdenv.isDarwin [ ./darwin.patch ];
+  patches = stdenv.lib.optional stdenv.isDarwin ./darwin.patch
+    # Suitable for all, but limited to musl to avoid rebuilds
+    ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
+      # https://cgit.freedesktop.org/libbsd/commit/?id=1f8a3f7bccfc84b195218ad0086ebd57049c3490
+      ./non-glibc.patch
+      # https://cgit.freedesktop.org/libbsd/commit/?id=11ec8f1e5dfa1c10e0c9fb94879b6f5b96ba52dd
+      ./cdefs.patch
+      # https://cgit.freedesktop.org/libbsd/commit/?id=b20272f5a966333b49fdf2bda797e2a9f0227404
+      ./features.patch
+  ];
 
   meta = with stdenv.lib; {
     description = "Common functions found on BSD systems";
diff --git a/pkgs/development/libraries/libbsd/features.patch b/pkgs/development/libraries/libbsd/features.patch
new file mode 100644
index 00000000000..66bd1e9232b
--- /dev/null
+++ b/pkgs/development/libraries/libbsd/features.patch
@@ -0,0 +1,26 @@
+From b20272f5a966333b49fdf2bda797e2a9f0227404 Mon Sep 17 00:00:00 2001
+From: Guillem Jover <guillem@hadrons.org>
+Date: Tue, 6 Mar 2018 01:42:52 +0100
+Subject: Remove <features.h> inclusion from <bsd/libutil.h>
+
+This is a non-portable header, and we should not assume it is present.
+Let the first system header pull it in if needed.
+---
+ include/bsd/libutil.h | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/include/bsd/libutil.h b/include/bsd/libutil.h
+index ccca29a..e5f148a 100644
+--- a/include/bsd/libutil.h
++++ b/include/bsd/libutil.h
+@@ -39,7 +39,6 @@
+ #ifndef LIBBSD_LIBUTIL_H
+ #define LIBBSD_LIBUTIL_H
+ 
+-#include <features.h>
+ #ifdef LIBBSD_OVERLAY
+ #include <sys/cdefs.h>
+ #else
+-- 
+cgit v1.1
+
diff --git a/pkgs/development/libraries/libbsd/non-glibc.patch b/pkgs/development/libraries/libbsd/non-glibc.patch
new file mode 100644
index 00000000000..f61e0d24294
--- /dev/null
+++ b/pkgs/development/libraries/libbsd/non-glibc.patch
@@ -0,0 +1,74 @@
+From 1f8a3f7bccfc84b195218ad0086ebd57049c3490 Mon Sep 17 00:00:00 2001
+From: Guillem Jover <guillem@hadrons.org>
+Date: Tue, 6 Mar 2018 01:39:45 +0100
+Subject: Fix function declaration protection for glibc already providing them
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+On non-glibc based systems we cannot unconditionally use the
+__GLIBC_PREREQ macro as it gets expanded before evaluation. Instead,
+if it is undefined, define it to 0.
+
+We should also always declare these functions on non-glibc based
+systems. And on systems with a new enough glibc, which provides these
+functions, we should still provide the declarations if _GNU_SOURCE
+is *not* defined.
+
+Reported-by: Jörg Krause <joerg.krause@embedded.rocks>
+---
+ include/bsd/stdlib.h    | 3 ++-
+ include/bsd/string.h    | 3 ++-
+ include/bsd/sys/cdefs.h | 8 ++++++++
+ 3 files changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/include/bsd/stdlib.h b/include/bsd/stdlib.h
+index 8d33d1f..a5b063c 100644
+--- a/include/bsd/stdlib.h
++++ b/include/bsd/stdlib.h
+@@ -71,7 +71,8 @@ int sradixsort(const unsigned char **base, int nmemb,
+                const unsigned char *table, unsigned endbyte);
+ 
+ void *reallocf(void *ptr, size_t size);
+-#if defined(_GNU_SOURCE) && defined(__GLIBC__) && !__GLIBC_PREREQ(2, 26)
++#if !defined(__GLIBC__) || \
++    (defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 26) || !defined(_GNU_SOURCE)))
+ void *reallocarray(void *ptr, size_t nmemb, size_t size);
+ #endif
+ 
+diff --git a/include/bsd/string.h b/include/bsd/string.h
+index 29097f6..f987fee 100644
+--- a/include/bsd/string.h
++++ b/include/bsd/string.h
+@@ -46,7 +46,8 @@ size_t strlcat(char *dst, const char *src, size_t siz);
+ char *strnstr(const char *str, const char *find, size_t str_len);
+ void strmode(mode_t mode, char *str);
+ 
+-#if defined(_GNU_SOURCE) && defined(__GLIBC__) && !__GLIBC_PREREQ(2, 25)
++#if !defined(__GLIBC__) || \
++    (defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 25) || !defined(_GNU_SOURCE)))
+ void explicit_bzero(void *buf, size_t len);
+ #endif
+ __END_DECLS
+diff --git a/include/bsd/sys/cdefs.h b/include/bsd/sys/cdefs.h
+index b4c8f30..d1cc419 100644
+--- a/include/bsd/sys/cdefs.h
++++ b/include/bsd/sys/cdefs.h
+@@ -59,6 +59,14 @@
+ #endif
+ 
+ /*
++ * On non-glibc based systems, we cannot unconditionally use the
++ * __GLIBC_PREREQ macro as it gets expanded before evaluation.
++ */
++#ifndef __GLIBC_PREREQ
++#define __GLIBC_PREREQ(maj, min) 0
++#endif
++
++/*
+  * Some kFreeBSD headers expect those macros to be set for sanity checks.
+  */
+ #ifndef _SYS_CDEFS_H_
+-- 
+cgit v1.1
+
diff --git a/pkgs/development/libraries/libglvnd/default.nix b/pkgs/development/libraries/libglvnd/default.nix
index 7ea1ecdd052..3740fd5569a 100644
--- a/pkgs/development/libraries/libglvnd/default.nix
+++ b/pkgs/development/libraries/libglvnd/default.nix
@@ -1,15 +1,16 @@
-{stdenv, fetchFromGitHub, autoreconfHook, python2, pkgconfig, libGL_driver, libX11, libXext, glproto }:
+{ stdenv, lib, fetchFromGitHub, autoreconfHook, python2, pkgconfig, libX11, libXext, glproto }:
 
-# Git version is needed for EGL and GLES handling.
-
-stdenv.mkDerivation rec {
-  name = "libglvnd-2016-12-22";
+let
+  driverLink = "/run/opengl-driver" + lib.optionalString stdenv.isi686 "-32";
+in stdenv.mkDerivation rec {
+  name = "libglvnd-${version}";
+  version = "1.0.0";
 
   src = fetchFromGitHub {
     owner = "NVIDIA";
     repo = "libglvnd";
-    rev = "dc16f8c337703ad141f83583a4004fcf42e07766";
-    sha256 = "1dbwf1216np77xf1kx3ci3y7hfa1p4vgrrzg71gw36hqxf36vg5f";
+    rev = "v${version}";
+    sha256 = "1a126lzhd2f04zr3rvdl6814lfl0j077spi5dsf2alghgykn5iif";
   };
 
   nativeBuildInputs = [ autoreconfHook pkgconfig python2 ];
@@ -17,11 +18,14 @@ stdenv.mkDerivation rec {
 
   NIX_CFLAGS_COMPILE = [
     "-UDEFAULT_EGL_VENDOR_CONFIG_DIRS"
-    "-DDEFAULT_EGL_VENDOR_CONFIG_DIRS=\"${libGL_driver.driverLink}/share/glvnd/egl_vendor.d\""
+    # FHS paths are added so that non-NixOS applications can find vendor files.
+    "-DDEFAULT_EGL_VENDOR_CONFIG_DIRS=\"${driverLink}/share/glvnd/egl_vendor.d:/etc/glvnd/egl_vendor.d:/usr/share/glvnd/egl_vendor.d\""
   ];
 
   outputs = [ "out" "dev" ];
 
+  passthru = { inherit driverLink; };
+
   meta = with stdenv.lib; {
     description = "The GL Vendor-Neutral Dispatch library";
     homepage = https://github.com/NVIDIA/libglvnd;
diff --git a/pkgs/development/libraries/libgpg-error/default.nix b/pkgs/development/libraries/libgpg-error/default.nix
index 5c5824a9930..2fcf6701ab8 100644
--- a/pkgs/development/libraries/libgpg-error/default.nix
+++ b/pkgs/development/libraries/libgpg-error/default.nix
@@ -1,7 +1,7 @@
-{ stdenv, buildPackages, fetchurl, gettext
-, hostPlatform, genPosixLockObjOnly ? false
+{ stdenv, lib, fetchpatch, buildPackages, fetchurl, gettext
+, genPosixLockObjOnly ? false
 }: let
-  genPosixLockObjOnlyAttrs = stdenv.lib.optionalAttrs genPosixLockObjOnly {
+  genPosixLockObjOnlyAttrs = lib.optionalAttrs genPosixLockObjOnly {
     buildPhase = ''
       cd src
       make gen-posix-lock-obj
@@ -17,18 +17,24 @@
   };
 in stdenv.mkDerivation (rec {
   name = "libgpg-error-${version}";
-  version = "1.27";
+  version = "1.28";
 
   src = fetchurl {
     url = "mirror://gnupg/libgpg-error/${name}.tar.bz2";
-    sha256 = "1li95ni122fzinzlmxbln63nmgij63irxfvi52ws4zfbzv3am4sg";
+    sha256 = "0jfsfnh9bxlxiwxws60yah4ybjw2hshmvqp31pri4m4h8ivrbnry";
   };
 
-  patches = if hostPlatform.isRiscV then ./riscv.patch else null;
+  patches = [
+    # Fix builds on ARM, AArch64
+    (fetchpatch {
+      url = "https://github.com/gpg/libgpg-error/commit/791177de023574223eddf7288eb7c5a0721ac623.patch";
+      sha256 = "0vqfw0ak1j37wf6sk9y9vmdyk3kxdxkldhs0bv2waa76s11cmdx0";
+    })
+  ];
 
   postPatch = ''
     sed '/BUILD_TIMESTAMP=/s/=.*/=1970-01-01T00:01+0000/' -i ./configure
-  '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+  '' + lib.optionalString stdenv.hostPlatform.isMusl ''
     ln -s lock-obj-pub.x86_64-pc-linux-musl.h src/syscfg/lock-obj-pub.linux-musl.h
   '';
 
@@ -41,7 +47,7 @@ in stdenv.mkDerivation (rec {
   nativeBuildInputs = [ gettext ];
 
   postConfigure =
-    stdenv.lib.optionalString stdenv.isSunOS
+    lib.optionalString stdenv.isSunOS
     # For some reason, /bin/sh on OpenIndiana leads to this at the end of the
     # `config.status' run:
     #   ./config.status[1401]: shift: (null): bad number
diff --git a/pkgs/development/libraries/libgpg-error/riscv.patch b/pkgs/development/libraries/libgpg-error/riscv.patch
deleted file mode 100644
index afc3b9993a4..00000000000
--- a/pkgs/development/libraries/libgpg-error/riscv.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-commit b3e9ec5626d474c58e683a41d09576297d4acd3d
-Author: Shea Levy <shea@shealevy.com>
-Date:   Sat Feb 24 21:12:44 2018 -0500
-
-    syscfg: Add lock-obj-pub file for riscv64-unknown-linux-gnu.
-    
-    * src/syscfg/lock-obj-pub.riscv64-unknown-linux-gnu.h: new.
-    * src/Makefile.am (lock_obj_pub): Add it.
-    
-    Signed-off-by: Shea Levy <shea@shealevy.com>
-
-diff --git a/src/Makefile.am b/src/Makefile.am
-index 4446612..5a8cc43 100644
---- a/src/Makefile.in
-+++ b/src/Makefile.in
-@@ -65,6 +65,7 @@ lock_obj_pub = \
-         syscfg/lock-obj-pub.powerpc64-unknown-linux-gnu.h   \
- 	syscfg/lock-obj-pub.powerpc64le-unknown-linux-gnu.h \
- 	syscfg/lock-obj-pub.powerpc-unknown-linux-gnuspe.h  \
-+        syscfg/lock-obj-pub.riscv64-unknown-linux-gnu.h     \
-         syscfg/lock-obj-pub.s390x-ibm-linux-gnu.h           \
-         syscfg/lock-obj-pub.sh3-unknown-linux-gnu.h         \
-         syscfg/lock-obj-pub.sh4-unknown-linux-gnu.h         \
-diff --git a/src/syscfg/lock-obj-pub.riscv64-unknown-linux-gnu.h b/src/syscfg/lock-obj-pub.riscv64-unknown-linux-gnu.h
-new file mode 100644
-index 0000000..8aab9d6
---- /dev/null
-+++ b/src/syscfg/lock-obj-pub.riscv64-unknown-linux-gnu.h
-@@ -0,0 +1,25 @@
-+## lock-obj-pub.riscv64-unknown-linux-gnu.h
-+## File created by gen-posix-lock-obj - DO NOT EDIT
-+## To be included by mkheader into gpg-error.h
-+
-+typedef struct
-+{
-+  long _vers;
-+  union {
-+    volatile char _priv[40];
-+    long _x_align;
-+    long *_xp_align;
-+  } u;
-+} gpgrt_lock_t;
-+
-+#define GPGRT_LOCK_INITIALIZER {1,{{0,0,0,0,0,0,0,0, \
-+                                    0,0,0,0,0,0,0,0, \
-+                                    0,0,0,0,0,0,0,0, \
-+                                    0,0,0,0,0,0,0,0, \
-+                                    0,0,0,0,0,0,0,0}}}
-+##
-+## Local Variables:
-+## mode: c
-+## buffer-read-only: t
-+## End:
-+##
diff --git a/pkgs/development/libraries/libgsf/default.nix b/pkgs/development/libraries/libgsf/default.nix
index 54a17d94a59..b0013d0f949 100644
--- a/pkgs/development/libraries/libgsf/default.nix
+++ b/pkgs/development/libraries/libgsf/default.nix
@@ -1,5 +1,5 @@
 { fetchurl, stdenv, pkgconfig, intltool, gettext, glib, libxml2, zlib, bzip2
-, python, perl, gdk_pixbuf, libiconv, libintlOrEmpty }:
+, python, perl, gdk_pixbuf, libiconv, libintl }:
 
 let inherit (stdenv.lib) optionals; in
 
@@ -11,21 +11,18 @@ stdenv.mkDerivation rec {
     sha256 = "1hhdz0ymda26q6bl5ygickkgrh998lxqq4z9i8dzpcvqna3zpzr9";
   };
 
-  nativeBuildInputs = [ pkgconfig intltool ];
+  nativeBuildInputs = [ pkgconfig intltool libintl ];
 
   buildInputs = [ gettext bzip2 zlib python ]
     ++ stdenv.lib.optional doCheck perl;
 
-  propagatedBuildInputs = [ libxml2 glib gdk_pixbuf libiconv ]
-    ++ libintlOrEmpty;
+  propagatedBuildInputs = [ libxml2 glib gdk_pixbuf libiconv ];
 
   outputs = [ "out" "dev" ];
 
   doCheck = true;
   preCheck = "patchShebangs ./tests/";
 
-  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-lintl";
-
   meta = with stdenv.lib; {
     description = "GNOME's Structured File Library";
     homepage    = https://www.gnome.org/projects/libgsf;
diff --git a/pkgs/development/libraries/libgtop/default.nix b/pkgs/development/libraries/libgtop/default.nix
index 0a44eee90aa..656395b8867 100644
--- a/pkgs/development/libraries/libgtop/default.nix
+++ b/pkgs/development/libraries/libgtop/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, glib, pkgconfig, perl, gettext, gobjectIntrospection, libintlOrEmpty, gnome3 }:
+{ stdenv, fetchurl, glib, pkgconfig, perl, gettext, gobjectIntrospection, libintl, gnome3 }:
 let
   pname = "libgtop";
   version = "2.38.0";
@@ -12,11 +12,8 @@ stdenv.mkDerivation rec {
   };
 
   propagatedBuildInputs = [ glib ];
-  buildInputs = libintlOrEmpty;
   nativeBuildInputs = [ pkgconfig perl gettext gobjectIntrospection ];
 
-  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-lintl";
-
   passthru = {
     updateScript = gnome3.updateScript {
       packageName = pname;
diff --git a/pkgs/development/libraries/libiconv/default.nix b/pkgs/development/libraries/libiconv/default.nix
index b55fc18cb69..a4e6fed88e1 100644
--- a/pkgs/development/libraries/libiconv/default.nix
+++ b/pkgs/development/libraries/libiconv/default.nix
@@ -14,6 +14,8 @@ stdenv.mkDerivation rec {
     sha256 = "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc";
   };
 
+  setupHook = ./setup-hook.sh;
+
   postPatch =
     lib.optionalString ((hostPlatform != buildPlatform && hostPlatform.libc == "msvcrt") || stdenv.cc.nativeLibc)
       ''
diff --git a/pkgs/development/libraries/libiconv/setup-hook.sh b/pkgs/development/libraries/libiconv/setup-hook.sh
new file mode 100644
index 00000000000..78222dddbf1
--- /dev/null
+++ b/pkgs/development/libraries/libiconv/setup-hook.sh
@@ -0,0 +1,18 @@
+# libiconv must be listed in load flags on non-Glibc
+# it doesn't hurt to have it in Glibc either though
+iconvLdflags() {
+    # The `depHostOffset` describes how the host platform of the dependencies
+    # are slid relative to the depending package. It is brought into scope of
+    # the environment hook defined as the role of the dependency being applied.
+    case $depHostOffset in
+        -1) local role='BUILD_' ;;
+        0)  local role='' ;;
+        1)  local role='TARGET_' ;;
+        *)  echo "cc-wrapper: Error: Cannot be used with $depHostOffset-offset deps" >2;
+            return 1 ;;
+    esac
+
+    export NIX_${role}LDFLAGS+=" -liconv"
+}
+
+addEnvHooks "$hostOffset" iconvLdflags
diff --git a/pkgs/development/libraries/libinfinity/default.nix b/pkgs/development/libraries/libinfinity/default.nix
index 9bbb8f0e129..944cf7a6f5e 100644
--- a/pkgs/development/libraries/libinfinity/default.nix
+++ b/pkgs/development/libraries/libinfinity/default.nix
@@ -4,7 +4,7 @@
 , avahiSupport ? false # build support for Avahi in libinfinity
 , stdenv, fetchurl, pkgconfig, glib, libxml2, gnutls, gsasl
 , gtk2 ? null, gtkdoc ? null, avahi ? null, libdaemon ? null, libidn, gss
-, libintlOrEmpty }:
+, libintl }:
 
 let
   edf = flag: feature: (if flag then "--with-" else "--without-") + feature;
@@ -19,14 +19,14 @@ in stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ glib libxml2 gsasl libidn gss libintlOrEmpty ]
+  buildInputs = [ glib libxml2 gsasl libidn gss libintl ]
     ++ optional gtkWidgets gtk2
     ++ optional documentation gtkdoc
     ++ optional avahiSupport avahi
     ++ optional daemon libdaemon;
 
   propagatedBuildInputs = [ gnutls ];
-  
+
   configureFlags = ''
     ${if documentation then "--enable-gtk-doc" else "--disable-gtk-doc"}
     ${edf gtkWidgets "inftextgtk"}
@@ -36,8 +36,6 @@ in stdenv.mkDerivation rec {
     ${edf avahiSupport "avahi"}
   '';
 
-  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-lintl";
-
   meta = {
     homepage = http://gobby.0x539.de/;
     description = "An implementation of the Infinote protocol written in GObject-based C";
diff --git a/pkgs/development/libraries/libksba/default.nix b/pkgs/development/libraries/libksba/default.nix
index 3f7a4bed9cc..0611e0e57e7 100644
--- a/pkgs/development/libraries/libksba/default.nix
+++ b/pkgs/development/libraries/libksba/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
 
   outputs = [ "out" "dev" "info" ];
 
-  buildInputs = stdenv.lib.optional stdenv.isDarwin gettext;
+  buildInputs = [ gettext ];
   propagatedBuildInputs = [ libgpgerror ];
 
   postInstall = ''
diff --git a/pkgs/development/libraries/libmicrohttpd/default.nix b/pkgs/development/libraries/libmicrohttpd/default.nix
index 2e7c913e6a8..041e0d98d65 100644
--- a/pkgs/development/libraries/libmicrohttpd/default.nix
+++ b/pkgs/development/libraries/libmicrohttpd/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, libgcrypt, curl, gnutls, pkgconfig, libiconv, libintlOrEmpty }:
+{ stdenv, fetchurl, libgcrypt, curl, gnutls, pkgconfig, libiconv, libintl }:
 
 stdenv.mkDerivation rec {
   name = "libmicrohttpd-${version}";
@@ -11,8 +11,7 @@ stdenv.mkDerivation rec {
 
   outputs = [ "out" "dev" "devdoc" "info" ];
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ libgcrypt curl gnutls ]
-    ++ stdenv.lib.optionals stdenv.isDarwin [ libiconv libintlOrEmpty ];
+  buildInputs = [ libgcrypt curl gnutls libiconv libintl ];
 
   preCheck = ''
     # Since `localhost' can't be resolved in a chroot, work around it.
@@ -38,4 +37,3 @@ stdenv.mkDerivation rec {
     platforms = platforms.unix;
   };
 }
-
diff --git a/pkgs/development/libraries/libnatspec/default.nix b/pkgs/development/libraries/libnatspec/default.nix
index fe38755f10c..9b692e9e3b2 100644
--- a/pkgs/development/libraries/libnatspec/default.nix
+++ b/pkgs/development/libraries/libnatspec/default.nix
@@ -19,6 +19,5 @@ stdenv.mkDerivation (rec {
     maintainers = [ ];
   };
 } // stdenv.lib.optionalAttrs (!stdenv.isLinux) {
-  NIX_LDFLAGS = "-liconv";
   propagatedBuildInputs = [ libiconv ];
 })
diff --git a/pkgs/development/libraries/libpipeline/default.nix b/pkgs/development/libraries/libpipeline/default.nix
index 4da6a0b3cbc..e11527ca10c 100644
--- a/pkgs/development/libraries/libpipeline/default.nix
+++ b/pkgs/development/libraries/libpipeline/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl }:
- 
+
 stdenv.mkDerivation rec {
-  name = "libpipeline-1.4.1";
-  
+  name = "libpipeline-1.5.0";
+
   src = fetchurl {
     url = "mirror://savannah/libpipeline/${name}.tar.gz";
-    sha256 = "1vmrs4nvdsmb550bk10cankrd42ffczlibpsnafxpak306rdfins";
+    sha256 = "0avg525wvifcvjrwa6i1r6kvahmsswj0mpxrsxzzdzra9wpf2whd";
   };
 
   patches = stdenv.lib.optionals stdenv.isDarwin [ ./fix-on-osx.patch ];
diff --git a/pkgs/development/libraries/librsvg/default.nix b/pkgs/development/libraries/librsvg/default.nix
index 4bb4db10438..c2e1739117b 100644
--- a/pkgs/development/libraries/librsvg/default.nix
+++ b/pkgs/development/libraries/librsvg/default.nix
@@ -1,5 +1,5 @@
 { lib, stdenv, fetchurl, pkgconfig, glib, gdk_pixbuf, pango, cairo, libxml2, libgsf
-, bzip2, libcroco, libintlOrEmpty, darwin, rust, gnome3
+, bzip2, libcroco, libintl, darwin, rust, gnome3
 , withGTK ? false, gtk3 ? null
 , vala, gobjectIntrospection }:
 
@@ -15,11 +15,9 @@ stdenv.mkDerivation rec {
     sha256 = "0c550a0bffef768a436286116c03d9f6cd3f97f5021c13e7f093b550fac12562";
   };
 
-  NIX_LDFLAGS = if stdenv.isDarwin then "-lintl" else null;
-
   outputs = [ "out" "dev" ];
 
-  buildInputs = [ libxml2 libgsf bzip2 libcroco pango libintlOrEmpty ];
+  buildInputs = [ libxml2 libgsf bzip2 libcroco pango libintl ];
 
   propagatedBuildInputs = [ glib gdk_pixbuf cairo ] ++ lib.optional withGTK gtk3;
 
diff --git a/pkgs/development/libraries/libsecret/default.nix b/pkgs/development/libraries/libsecret/default.nix
index 4ff00d77769..b77ba49822f 100644
--- a/pkgs/development/libraries/libsecret/default.nix
+++ b/pkgs/development/libraries/libsecret/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, glib, pkgconfig, intltool, libxslt, docbook_xsl, gtk-doc
-, libgcrypt, gobjectIntrospection, vala_0_38, gnome3 }:
+, libgcrypt, gobjectIntrospection, vala_0_38, gnome3, libintl }:
 let
   pname = "libsecret";
   version = "0.18.5";
@@ -14,10 +14,8 @@ stdenv.mkDerivation rec {
 
   outputs = [ "out" "dev" ];
 
-  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-lintl";
-
   propagatedBuildInputs = [ glib ];
-  nativeBuildInputs = [ pkgconfig intltool libxslt docbook_xsl ];
+  nativeBuildInputs = [ pkgconfig intltool libxslt docbook_xsl libintl ];
   buildInputs = [ libgcrypt gobjectIntrospection vala_0_38 ];
   # optional: build docs with gtk-doc? (probably needs a flag as well)
 
diff --git a/pkgs/development/libraries/libsoup/default.nix b/pkgs/development/libraries/libsoup/default.nix
index dad245d0791..92e9c3662c9 100644
--- a/pkgs/development/libraries/libsoup/default.nix
+++ b/pkgs/development/libraries/libsoup/default.nix
@@ -1,8 +1,8 @@
 { stdenv, fetchurl, glib, libxml2, pkgconfig, gnome3
 , gnomeSupport ? true, sqlite, glib-networking, gobjectIntrospection
 , valaSupport ? true, vala_0_40
-, libintlOrEmpty
 , intltool, python3 }:
+
 let
   pname = "libsoup";
   version = "2.62.0";
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
 
   outputs = [ "out" "dev" ];
 
-  buildInputs = libintlOrEmpty ++ [ python3 sqlite ];
+  buildInputs = [ python3 sqlite ];
   nativeBuildInputs = [ pkgconfig intltool gobjectIntrospection ]
     ++ stdenv.lib.optionals valaSupport [ vala_0_40 ];
   propagatedBuildInputs = [ glib libxml2 ];
@@ -36,8 +36,6 @@ stdenv.mkDerivation rec {
     "--with-gnome=${if gnomeSupport then "yes" else "no"}"
   ];
 
-  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-lintl";
-
   passthru = {
     propagatedUserEnvPackages = [ glib-networking.out ];
     updateScript = gnome3.updateScript {
diff --git a/pkgs/development/libraries/libspatialindex/default.nix b/pkgs/development/libraries/libspatialindex/default.nix
index fe0acbfc538..aa3aaa1c59b 100644
--- a/pkgs/development/libraries/libspatialindex/default.nix
+++ b/pkgs/development/libraries/libspatialindex/default.nix
@@ -16,6 +16,6 @@ stdenv.mkDerivation rec {
     description = "Extensible spatial index library in C++";
     homepage = http://libspatialindex.github.io/;
     license = stdenv.lib.licenses.mit;
-    platforms = stdenv.lib.platforms.linux;
+    platforms = stdenv.lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/libui/default.nix b/pkgs/development/libraries/libui/default.nix
index 2f8963db0cd..b1e6938a149 100644
--- a/pkgs/development/libraries/libui/default.nix
+++ b/pkgs/development/libraries/libui/default.nix
@@ -15,7 +15,9 @@ in
 
   nativeBuildInputs = [ pkgconfig ];
     buildInputs = [ cmake ] ++
-      (if stdenv.isDarwin then [darwin.apple_sdk.frameworks.Cocoa] else [gtk3]);
+      (if backend == "darwin" then [darwin.apple_sdk.frameworks.Cocoa]
+       else if backend == "unix" then [gtk3]
+       else null);
 
     preConfigure = stdenv.lib.optionalString stdenv.isDarwin ''
       sed -i 's/set(CMAKE_OSX_DEPLOYMENT_TARGET "10.8")//' ./CMakeLists.txt
diff --git a/pkgs/development/libraries/libusb1/default.nix b/pkgs/development/libraries/libusb1/default.nix
index 44638b4dfd5..69afd9d4c69 100644
--- a/pkgs/development/libraries/libusb1/default.nix
+++ b/pkgs/development/libraries/libusb1/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, pkgconfig, systemd ? null, libobjc, IOKit }:
 
 stdenv.mkDerivation rec {
-  name = "libusb-1.0.21";
+  name = "libusb-1.0.22";
 
   src = fetchurl {
     url = "mirror://sourceforge/libusb/${name}.tar.bz2";
-    sha256 = "0jw2n5kdnrqvp7zh792fd6mypzzfap6jp4gfcmq4n6c1kb79rkkx";
+    sha256 = "0mw1a5ss4alg37m6bd4k44v35xwrcwp5qm4s686q1nsgkbavkbkm";
   };
 
   outputs = [ "out" "dev" ]; # get rid of propagating systemd closure
diff --git a/pkgs/development/libraries/libva/1.0.0.nix b/pkgs/development/libraries/libva/1.0.0.nix
index 031ac781651..04d621e29c8 100644
--- a/pkgs/development/libraries/libva/1.0.0.nix
+++ b/pkgs/development/libraries/libva/1.0.0.nix
@@ -1,6 +1,6 @@
 { stdenv, lib, fetchurl, libX11, pkgconfig, libXext, libdrm, libXfixes, wayland, libffi
-, mesa_noglu
-, minimal ? true, libva
+, libGL, libGL_driver
+, minimal ? false, libva1-minimal
 }:
 
 stdenv.mkDerivation rec {
@@ -17,11 +17,12 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ pkgconfig ];
 
   buildInputs = [ libdrm ]
-    ++ lib.optionals (!minimal) [ libva libX11 libXext libXfixes wayland libffi mesa_noglu ];
+    ++ lib.optionals (!minimal) [ libva1-minimal libX11 libXext libXfixes wayland libffi libGL ];
   # TODO: share libs between minimal and !minimal - perhaps just symlink them
 
   configureFlags =
-    [ "--with-drivers-path=${mesa_noglu.driverLink}/lib/dri" ] ++
+    # Add FHS paths for non-NixOS applications.
+    [ "--with-drivers-path=${libGL_driver.driverLink}/lib/dri:/usr/lib/dri:/usr/lib32/dri" ] ++
     lib.optionals (!minimal) [ "--enable-glx" ];
 
   installFlags = [ "dummy_drv_video_ladir=$(out)/lib/dri" ];
diff --git a/pkgs/development/libraries/libva/default.nix b/pkgs/development/libraries/libva/default.nix
index 6b8c3631fb3..0ba49da06cf 100644
--- a/pkgs/development/libraries/libva/default.nix
+++ b/pkgs/development/libraries/libva/default.nix
@@ -1,11 +1,11 @@
 { stdenv, lib, fetchFromGitHub, autoreconfHook, pkgconfig
 , libXext, libdrm, libXfixes, wayland, libffi, libX11
-, libGL
-, minimal ? true, libva
+, libGL, libGL_driver
+, minimal ? false, libva-minimal
 }:
 
 stdenv.mkDerivation rec {
-  name = "libva-${lib.optionalString (!minimal) "full-"}${version}";
+  name = "libva-${lib.optionalString minimal "minimal-"}${version}";
   version = "2.1.0";
 
   # update libva-utils and vaapiIntel as well
@@ -21,13 +21,14 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ autoreconfHook pkgconfig ];
 
   buildInputs = [ libdrm ]
-    ++ lib.optionals (!minimal) [ libva libX11 libXext libXfixes wayland libffi libGL ];
+    ++ lib.optionals (!minimal) [ libva-minimal libX11 libXext libXfixes wayland libffi libGL ];
   # TODO: share libs between minimal and !minimal - perhaps just symlink them
 
   enableParallelBuilding = true;
 
   configureFlags = [
-    "--with-drivers-path=${libGL.driverLink}/lib/dri"
+    # Add FHS paths for non-NixOS applications.
+    "--with-drivers-path=${libGL_driver.driverLink}/lib/dri:/usr/lib/dri:/usr/lib32/dri"
   ] ++ lib.optionals (!minimal) [ "--enable-glx" ];
 
   installFlags = [
diff --git a/pkgs/development/libraries/libvdpau/default.nix b/pkgs/development/libraries/libvdpau/default.nix
index eebdc294197..35c339b45d0 100644
--- a/pkgs/development/libraries/libvdpau/default.nix
+++ b/pkgs/development/libraries/libvdpau/default.nix
@@ -1,7 +1,8 @@
-{ stdenv, fetchurl, pkgconfig, xorg, libGL }:
+{ stdenv, fetchurl, pkgconfig, xorg, libGL_driver }:
 
 stdenv.mkDerivation rec {
-  name = "libvdpau-1.1.1";
+  name = "libvdpau-${version}";
+  version = "1.1.1";
 
   src = fetchurl {
     url = "https://people.freedesktop.org/~aplattner/vdpau/${name}.tar.bz2";
@@ -16,7 +17,7 @@ stdenv.mkDerivation rec {
   propagatedBuildInputs = [ xorg.libX11 ];
 
   configureFlags = stdenv.lib.optional stdenv.isLinux
-    "--with-module-dir=${libGL.driverLink}/lib/vdpau";
+    "--with-module-dir=${libGL_driver.driverLink}/lib/vdpau";
 
   installFlags = [ "moduledir=$(out)/lib/vdpau" ];
 
diff --git a/pkgs/development/libraries/mesa-glu/default.nix b/pkgs/development/libraries/mesa-glu/default.nix
index 9a6441956db..4e35d6ed24d 100644
--- a/pkgs/development/libraries/mesa-glu/default.nix
+++ b/pkgs/development/libraries/mesa-glu/default.nix
@@ -1,7 +1,8 @@
-{ stdenv, fetchurl, pkgconfig, mesa_noglu }:
+{ stdenv, fetchurl, pkgconfig, libGL }:
 
 stdenv.mkDerivation rec {
-  name = "glu-9.0.0";
+  name = "glu-${version}";
+  version = "9.0.0";
 
   src = fetchurl {
     url = "ftp://ftp.freedesktop.org/pub/mesa/glu/${name}.tar.bz2";
@@ -12,7 +13,7 @@ stdenv.mkDerivation rec {
   '';
 
   nativeBuildInputs = [ pkgconfig ];
-  propagatedBuildInputs = [ mesa_noglu ];
+  propagatedBuildInputs = [ libGL ];
 
   outputs = [ "out" "dev" ];
 
diff --git a/pkgs/development/libraries/mesa/default.nix b/pkgs/development/libraries/mesa/default.nix
index fbbfe44e27e..984c11d55b9 100644
--- a/pkgs/development/libraries/mesa/default.nix
+++ b/pkgs/development/libraries/mesa/default.nix
@@ -1,8 +1,9 @@
 { stdenv, fetchurl, fetchpatch, lib
 , pkgconfig, intltool, autoreconfHook, substituteAll
 , file, expat, libdrm, xorg, wayland, wayland-protocols, openssl
-, llvmPackages, libffi, libomxil-bellagio, libva
+, llvmPackages, libffi, libomxil-bellagio, libva-minimal
 , libelf, libvdpau, valgrind-light, python2
+, libglvnd
 , grsecEnabled ? false
 , enableRadv ? true
 # Texture floats are patented, see docs/patents.txt, so we don't enable them for full Mesa.
@@ -54,7 +55,7 @@ let
     (if gallium_ == null
           then defaultGalliumDrivers
           else gallium_)
-    ++ ["swrast"];
+    ++ ["swrast" "virgl"];
   driDrivers =
     (if dri_ == null
       then defaultDriDrivers
@@ -68,10 +69,9 @@ in
 let
   version = "17.3.6";
   branch  = head (splitString "." version);
-  driverLink = "/run/opengl-driver" + optionalString stdenv.isi686 "-32";
 in
 
-stdenv.mkDerivation {
+let self = stdenv.mkDerivation {
   name = "mesa-noglu-${version}";
 
   src =  fetchurl {
@@ -98,10 +98,10 @@ stdenv.mkDerivation {
 
   # TODO: Figure out how to enable opencl without having a runtime dependency on clang
   configureFlags = [
-    "--sysconfdir=${driverLink}/etc"
+    "--sysconfdir=${libglvnd.driverLink}/etc"
     "--localstatedir=/var"
     "--with-dri-driverdir=$(drivers)/lib/dri"
-    "--with-dri-searchpath=${driverLink}/lib/dri"
+    "--with-dri-searchpath=${libglvnd.driverLink}/lib/dri"
     "--with-platforms=x11,wayland,drm"
   ]
   ++ (optional (galliumDrivers != [])
@@ -118,6 +118,7 @@ stdenv.mkDerivation {
     (enableFeature grsecEnabled "glx-rts")
     (enableFeature stdenv.isLinux "dri3")
     (enableFeature stdenv.isLinux "nine") # Direct3D in Wine
+    "--enable-libglvnd"
     "--enable-dri"
     "--enable-driglx-direct"
     "--enable-gles1"
@@ -146,21 +147,21 @@ stdenv.mkDerivation {
     ++ optional stdenv.isLinux libdrm;
 
   buildInputs = with xorg; [
-    expat llvmPackages.llvm
+    expat llvmPackages.llvm libglvnd
     glproto dri2proto dri3proto presentproto
     libX11 libXext libxcb libXt libXfixes libxshmfence
     libffi wayland wayland-protocols libvdpau libelf libXvMC
-    libomxil-bellagio libva libpthreadstubs openssl/*or another sha1 provider*/
+    libomxil-bellagio libva-minimal libpthreadstubs openssl/*or another sha1 provider*/
     valgrind-light python2
   ];
 
-
   enableParallelBuilding = true;
   doCheck = false;
 
   installFlags = [
     "sysconfdir=\${out}/etc"
     "localstatedir=\${TMPDIR}"
+    "vendorjsondir=\${out}/share/glvnd/egl_vendor.d"
   ];
 
   # TODO: probably not all .la files are completely fixed, but it shouldn't matter;
@@ -174,8 +175,10 @@ stdenv.mkDerivation {
       $out/lib/libxatracker* \
       $out/lib/libvulkan_*
 
+    # Move other drivers to a separate output
     mv $out/lib/dri/* $drivers/lib/dri # */
     rmdir "$out/lib/dri"
+    mv $out/lib/lib*_mesa* $drivers/lib
 
     # move libOSMesa to $osmesa, as it's relatively big
     mkdir -p {$osmesa,$drivers}/lib/
@@ -185,10 +188,22 @@ stdenv.mkDerivation {
     sed "/^libdir=/s,$out,$osmesa," -i $osmesa/lib/libOSMesa*.la
 
     # set the default search path for DRI drivers; used e.g. by X server
-    substituteInPlace "$dev/lib/pkgconfig/dri.pc" --replace '$(drivers)' "${driverLink}"
-  '' + optionalString (vulkanDrivers != []) ''
-    # move share/vulkan/icd.d/
+    substituteInPlace "$dev/lib/pkgconfig/dri.pc" --replace '$(drivers)' "${libglvnd.driverLink}"
+
+    # remove GLES libraries; they are provided by libglvnd
+    rm $out/lib/lib{GLESv1_CM,GLESv2}.*
+
+    # remove pkgconfig files for GL/GLES/EGL; they are provided by libGL.
+    rm $dev/lib/pkgconfig/{gl,egl,glesv1_cm,glesv2}.pc
+
+    # move vendor files
     mv $out/share/ $drivers/
+
+    # Update search path used by glvnd
+    for js in $drivers/share/glvnd/egl_vendor.d/*.json; do
+      substituteInPlace "$js" --replace '"libEGL_' '"'"$drivers/lib/libEGL_"
+    done
+  '' + optionalString (vulkanDrivers != []) ''
     # Update search path used by Vulkan (it's pointing to $out but
     # drivers are in $drivers)
     for js in $drivers/share/vulkan/icd.d/*.json; do
@@ -209,13 +224,48 @@ stdenv.mkDerivation {
     done
   '';
 
-  passthru = { inherit libdrm version driverLink; };
+  passthru = {
+    inherit libdrm version;
+    inherit (libglvnd) driverLink;
+
+    stubs = stdenv.mkDerivation {
+      name = "libGL-${libglvnd.version}";
+      outputs = [ "out" "dev" ];
+
+      # Use stub libraries from libglvnd and headers from Mesa.
+      buildCommand = ''
+        ln -s ${libglvnd.out} $out
+        mkdir -p $dev/{,lib/pkgconfig,nix-support}
+        echo "$out" > $dev/nix-support/propagated-build-inputs
+        ln -s ${self.dev}/include $dev/include
+
+        genPkgConfig() {
+          local name="$1"
+          local lib="$2"
+
+          cat <<EOF >$dev/lib/pkgconfig/$name.pc
+        Name: $name
+        Description: $lib library
+        Version: ${self.version}
+        Libs: -L${libglvnd.out}/lib -l$lib
+        Cflags: -I${self.dev}/include
+        EOF
+        }
+
+        genPkgConfig gl GL
+        genPkgConfig egl EGL
+        genPkgConfig glesv1_cm GLESv1_CM
+        genPkgConfig glesv2 GLESv2
+      '';
+    };
+  };
 
   meta = with stdenv.lib; {
     description = "An open source implementation of OpenGL";
     homepage = https://www.mesa3d.org/;
     license = licenses.mit; # X11 variant, in most files
-    platforms = platforms.mesaPlatforms;
+    platforms = platforms.linux;
     maintainers = with maintainers; [ eduarrrd vcunat ];
   };
-}
+};
+in self
diff --git a/pkgs/development/libraries/ocl-icd/default.nix b/pkgs/development/libraries/ocl-icd/default.nix
index afd2a7b12df..ec6dc5f9052 100644
--- a/pkgs/development/libraries/ocl-icd/default.nix
+++ b/pkgs/development/libraries/ocl-icd/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, ruby, opencl-headers, libGL }:
+{stdenv, fetchurl, ruby, opencl-headers, libGL_driver }:
 
 stdenv.mkDerivation rec {
   name = "ocl-icd-${version}";
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ opencl-headers ];
 
   postPatch = ''
-    sed -i 's,"/etc/OpenCL/vendors","${libGL.driverLink}/etc/OpenCL/vendors",g' ocl_icd_loader.c
+    sed -i 's,"/etc/OpenCL/vendors","${libGL_driver.driverLink}/etc/OpenCL/vendors",g' ocl_icd_loader.c
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/pango/default.nix b/pkgs/development/libraries/pango/default.nix
index 3806926fa24..d880d41c708 100644
--- a/pkgs/development/libraries/pango/default.nix
+++ b/pkgs/development/libraries/pango/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, fetchpatch, pkgconfig, libXft, cairo, harfbuzz
-, libintlOrEmpty, gobjectIntrospection, darwin
+, libintl, gobjectIntrospection, darwin
 }:
 
 with stdenv.lib;
@@ -25,7 +25,7 @@ stdenv.mkDerivation rec {
        CoreGraphics
        CoreText
     ]);
-  propagatedBuildInputs = [ cairo harfbuzz libXft ] ++ libintlOrEmpty;
+  propagatedBuildInputs = [ cairo harfbuzz libXft libintl ];
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix
index 2ea5e923bad..973798b849b 100644
--- a/pkgs/development/libraries/pcre/default.nix
+++ b/pkgs/development/libraries/pcre/default.nix
@@ -35,6 +35,10 @@ in stdenv.mkDerivation rec {
   # https://bugs.exim.org/show_bug.cgi?id=2173
   patches = [ ./stacksize-detection.patch ];
 
+  preCheck = ''
+    patchShebangs RunGrepTest
+  '';
+
   doCheck = !(with hostPlatform; isCygwin || isFreeBSD) && hostPlatform == buildPlatform;
     # XXX: test failure on Cygwin
     # we are running out of stack on both freeBSDs on Hydra
diff --git a/pkgs/development/libraries/poppler/default.nix b/pkgs/development/libraries/poppler/default.nix
index 1f360f07588..11dd8ec3291 100644
--- a/pkgs/development/libraries/poppler/default.nix
+++ b/pkgs/development/libraries/poppler/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchurl, cmake, ninja, pkgconfig, libiconv, libintlOrEmpty
+{ stdenv, lib, fetchurl, cmake, ninja, pkgconfig, libiconv, libintl
 , zlib, curl, cairo, freetype, fontconfig, lcms, libjpeg, openjpeg
 , withData ? true, poppler_data
 , qt5Support ? false, qtbase ? null
@@ -8,7 +8,7 @@
 }:
 
 let # beware: updates often break cups-filters build
-  version = "0.62.0";
+  version = "0.63.0";
   mkFlag = optset: flag: "-DENABLE_${flag}=${if optset then "on" else "off"}";
 in
 stdenv.mkDerivation rec {
@@ -16,12 +16,12 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/poppler-${version}.tar.xz";
-    sha256 = "1ii9ly1pngyvs0aiq2wxpya08hidpl54y7nsb8b1vxnnskgp76jv";
+    sha256 = "04d1z1ygyb3llzc6s6c99wxafvljj2sc5b76djif34f7mzfqmk17";
   };
 
   outputs = [ "out" "dev" ];
 
-  buildInputs = [ libiconv ] ++ libintlOrEmpty ++ lib.optional withData poppler_data;
+  buildInputs = [ libiconv libintl ] ++ lib.optional withData poppler_data;
 
   # TODO: reduce propagation to necessary libs
   propagatedBuildInputs = with lib;
@@ -32,6 +32,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake ninja pkgconfig ];
 
+  # Not sure when and how to pass it.  It seems an upstream bug anyway.
   CXXFLAGS = stdenv.lib.optionalString stdenv.cc.isClang "-std=c++11";
 
   cmakeFlags = [
diff --git a/pkgs/development/libraries/qca2/default.nix b/pkgs/development/libraries/qca2/default.nix
index 4976399a66a..568e7ce07b3 100644
--- a/pkgs/development/libraries/qca2/default.nix
+++ b/pkgs/development/libraries/qca2/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cmake, pkgconfig, qt }:
+{ stdenv, fetchurl, cmake, pkgconfig, qt, darwin }:
 
 stdenv.mkDerivation rec {
   name = "qca-${version}";
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ cmake pkgconfig ];
-  buildInputs = [ qt ];
+  buildInputs = [ (stdenv.lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security) qt ];
 
   enableParallelBuilding = true;
 
@@ -25,6 +25,6 @@ stdenv.mkDerivation rec {
     license = "LGPL";
     homepage = http://delta.affinix.com/qca;
     maintainers = [ maintainers.sander ];
-    platforms = platforms.linux;
+    platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/qscintilla/default.nix b/pkgs/development/libraries/qscintilla/default.nix
index d6bd90fa47d..f442e1bf908 100644
--- a/pkgs/development/libraries/qscintilla/default.nix
+++ b/pkgs/development/libraries/qscintilla/default.nix
@@ -3,6 +3,11 @@
 , withQt5 ? false, qtbase ? null, qtmacextras ? null, qmake ? null
 }:
 
+# Fix Xcode 8 compilation problem
+let xcodePatch =
+  fetchurl { url = "https://raw.githubusercontent.com/Homebrew/formula-patches/a651d71/qscintilla2/xcode-8.patch";
+             sha256 = "1a88309fdfd421f4458550b710a562c622d72d6e6fdd697107e4a43161d69bc9"; };
+in
 stdenv.mkDerivation rec {
   pname = "qscintilla";
   version = "2.9.4";
@@ -19,6 +24,9 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ unzip ]
     ++ (if withQt5 then [ qmake ] else [ qmake4Hook ]);
 
+
+  patches = [] ++ lib.optional withQt5 [ xcodePatch ];
+
   enableParallelBuilding = true;
 
   preConfigure = ''
diff --git a/pkgs/development/libraries/qt-4.x/4.8/default.nix b/pkgs/development/libraries/qt-4.x/4.8/default.nix
index bafe3664735..10f892bc4d0 100644
--- a/pkgs/development/libraries/qt-4.x/4.8/default.nix
+++ b/pkgs/development/libraries/qt-4.x/4.8/default.nix
@@ -76,7 +76,6 @@ stdenv.mkDerivation rec {
         icu = icu.out;
         libXfixes = libXfixes.out;
         glibc = stdenv.cc.libc.out;
-        openglDriver = if libGLSupported then libGL.driverLink else "/no-such-path";
       })
       (fetchpatch {
         name = "fix-medium-font.patch";
diff --git a/pkgs/development/libraries/qt-4.x/4.8/dlopen-absolute-paths.diff b/pkgs/development/libraries/qt-4.x/4.8/dlopen-absolute-paths.diff
index 0f5cf2b79c9..4c64e9e26e3 100644
--- a/pkgs/development/libraries/qt-4.x/4.8/dlopen-absolute-paths.diff
+++ b/pkgs/development/libraries/qt-4.x/4.8/dlopen-absolute-paths.diff
@@ -59,32 +59,6 @@ index 6b42d1e..f88b628 100644
      lib.setLoadHints(QLibrary::ImprovedSearchHeuristics);
      if (!lib.load())
          return;
-diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp
-index 229d6f9..c122bf3 100644
---- a/src/plugins/platforms/xcb/qglxintegration.cpp
-+++ b/src/plugins/platforms/xcb/qglxintegration.cpp
-@@ -136,7 +136,7 @@ void* QGLXContext::getProcAddress(const QString& procName)
-             {
-                 extern const QString qt_gl_library_name();
- //                QLibrary lib(qt_gl_library_name());
--                QLibrary lib(QLatin1String("GL"));
-+                QLibrary lib(QLatin1String("@openglDriver@/lib/libGL"));
-                 glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB");
-             }
-         }
-diff --git a/src/plugins/platforms/xlib/qglxintegration.cpp b/src/plugins/platforms/xlib/qglxintegration.cpp
-index 2467247..a2441d4 100644
---- a/src/plugins/platforms/xlib/qglxintegration.cpp
-+++ b/src/plugins/platforms/xlib/qglxintegration.cpp
-@@ -137,7 +137,7 @@ void* QGLXContext::getProcAddress(const QString& procName)
-             {
-                 extern const QString qt_gl_library_name();
- //                QLibrary lib(qt_gl_library_name());
--                QLibrary lib(QLatin1String("GL"));
-+                QLibrary lib(QLatin1String("@openglDriver@/lib/libGL"));
-                 glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB");
-             }
-         }
 diff --git a/src/plugins/platforms/xlib/qxlibstatic.cpp b/src/plugins/platforms/xlib/qxlibstatic.cpp
 index f8f3d69..d63c5bc 100644
 --- a/src/plugins/platforms/xlib/qxlibstatic.cpp
diff --git a/pkgs/development/libraries/qt-5/modules/qtwebengine.nix b/pkgs/development/libraries/qt-5/modules/qtwebengine.nix
index 7e91cff065d..08345510d78 100644
--- a/pkgs/development/libraries/qt-5/modules/qtwebengine.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtwebengine.nix
@@ -4,7 +4,7 @@
 , bison, coreutils, flex, git, gperf, ninja, pkgconfig, python2, which
 
 , xorg, libXcursor, libXScrnSaver, libXrandr, libXtst
-, fontconfig, freetype, harfbuzz, icu, dbus
+, fontconfig, freetype, harfbuzz, icu, dbus, libdrm
 , zlib, minizip, libjpeg, libpng, libtiff, libwebp, libopus
 , jsoncpp, protobuf, libvpx, srtp, snappy, nss, libevent
 , alsaLib
@@ -105,7 +105,7 @@ qtModule {
 
     # X11 libs
     xorg.xrandr libXScrnSaver libXcursor libXrandr xorg.libpciaccess libXtst
-    xorg.libXcomposite
+    xorg.libXcomposite xorg.libXdamage libdrm
   ];
 
   dontUseNinjaBuild = true;
diff --git a/pkgs/development/libraries/qwt/6.nix b/pkgs/development/libraries/qwt/6.nix
index 314ab0f9e61..6e0fa53aa82 100644
--- a/pkgs/development/libraries/qwt/6.nix
+++ b/pkgs/development/libraries/qwt/6.nix
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
     homepage = http://qwt.sourceforge.net/;
     # LGPL 2.1 plus a few exceptions (more liberal)
     license = stdenv.lib.licenses.qwt;
-    platforms = platforms.linux;
+    platforms = platforms.unix;
     maintainers = [ maintainers.bjornfor ];
     branch = "6";
   };
diff --git a/pkgs/development/libraries/qwt/default.nix b/pkgs/development/libraries/qwt/default.nix
index da5769e92cd..f900de5e578 100644
--- a/pkgs/development/libraries/qwt/default.nix
+++ b/pkgs/development/libraries/qwt/default.nix
@@ -25,7 +25,7 @@ stdenv.mkDerivation rec {
     homepage = http://qwt.sourceforge.net/;
     # LGPL 2.1 plus a few exceptions (more liberal)
     license = stdenv.lib.licenses.qwt;
-    platforms = platforms.linux;
+    platforms = platforms.unix;
     maintainers = [ maintainers.bjornfor ];
   };
 }
diff --git a/pkgs/development/libraries/science/math/atlas/default.nix b/pkgs/development/libraries/science/math/atlas/default.nix
index d971f1a2e0b..8cca5565bf6 100644
--- a/pkgs/development/libraries/science/math/atlas/default.nix
+++ b/pkgs/development/libraries/science/math/atlas/default.nix
@@ -45,7 +45,9 @@
 
 let
   inherit (stdenv.lib) optional optionalString;
-  version = "3.10.3";
+  # Don't upgrade until https://github.com/math-atlas/math-atlas/issues/44
+  # is resolved.
+  version = "3.10.2";
 in
 
 stdenv.mkDerivation {
@@ -53,7 +55,7 @@ stdenv.mkDerivation {
 
   src = fetchurl {
     url = "mirror://sourceforge/math-atlas/atlas${version}.tar.bz2";
-    sha256 = "1dyjlq3fiparvm8ypwk6rsmjzmnwk81l88gkishphpvc79ryp216";
+    sha256 = "0bqh4bdnjdyww4mcpg6kn0x7338mfqbdgysn97dzrwwb26di7ars";
   };
 
   buildInputs = [ gfortran ];
diff --git a/pkgs/development/libraries/science/math/openblas/default.nix b/pkgs/development/libraries/science/math/openblas/default.nix
index 07d2a04c5e2..5ac0bcd1d7d 100644
--- a/pkgs/development/libraries/science/math/openblas/default.nix
+++ b/pkgs/development/libraries/science/math/openblas/default.nix
@@ -60,7 +60,7 @@ let
       TARGET = "ATHLON";
       DYNAMIC_ARCH = "1";
       CC = "gcc";
-      USE_OPENMP = "1";
+      USE_OPENMP = if stdenv.hostPlatform.isMusl then "0" else "1";
     };
   };
 in
diff --git a/pkgs/development/libraries/spice-gtk/default.nix b/pkgs/development/libraries/spice-gtk/default.nix
index bedd4771253..0564459b24c 100644
--- a/pkgs/development/libraries/spice-gtk/default.nix
+++ b/pkgs/development/libraries/spice-gtk/default.nix
@@ -2,7 +2,7 @@
 , openssl, libpulseaudio, pixman, gobjectIntrospection, libjpeg_turbo, zlib
 , cyrus_sasl, python2Packages, autoreconfHook, usbredir, libsoup
 , withPolkit ? true, polkit, acl, usbutils
-, vala, gtk3, epoxy }:
+, vala, gtk3, epoxy, libdrm }:
 
 # If this package is built with polkit support (withPolkit=true),
 # usb redirection reqires spice-client-glib-usb-acl-helper to run setuid root.
@@ -47,7 +47,7 @@ in stdenv.mkDerivation rec {
 
   buildInputs = [
     spice-protocol celt_0_5_1 openssl libpulseaudio pixman
-    libjpeg_turbo zlib cyrus_sasl python pygtk usbredir gtk3 epoxy
+    libjpeg_turbo zlib cyrus_sasl python pygtk usbredir gtk3 epoxy libdrm
   ] ++ optionals withPolkit [ polkit acl usbutils ] ;
 
   nativeBuildInputs = [ pkgconfig gettext libsoup autoreconfHook vala gobjectIntrospection ];
diff --git a/pkgs/development/libraries/srtp/default.nix b/pkgs/development/libraries/srtp/default.nix
index d4ea531f886..29ad55eb9d9 100644
--- a/pkgs/development/libraries/srtp/default.nix
+++ b/pkgs/development/libraries/srtp/default.nix
@@ -5,13 +5,13 @@
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "libsrtp-${version}";
-  version = "1.5.4";
+  version = "2.1.0";
 
   src = fetchFromGitHub {
     owner = "cisco";
     repo = "libsrtp";
     rev = "v${version}";
-    sha256 = "0s029m4iw0nsvnsm2hlz8yajrasdvf315iv2dw8mfm7nhbshwsqa";
+    sha256 = "1q2rf1d2bsypdnw9k8ag6hrh9vbinfa504d1f42fdgdqw31d6lib";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/stfl/default.nix b/pkgs/development/libraries/stfl/default.nix
index fd9ab5a2036..89261b665f5 100644
--- a/pkgs/development/libraries/stfl/default.nix
+++ b/pkgs/development/libraries/stfl/default.nix
@@ -13,8 +13,6 @@ stdenv.mkDerivation rec {
   buildPhase = ''
     sed -i s/gcc/cc/g Makefile
     sed -i s%ncursesw/ncurses.h%ncurses.h% stfl_internals.h
-  '' + stdenv.lib.optionalString (stdenv.hostPlatform.libc != "glibc") ''
-    sed -i 's/LDLIBS += -lncursesw/LDLIBS += -lncursesw -liconv/' Makefile
   '' + ( stdenv.lib.optionalString stdenv.isDarwin ''
     sed -i s/-soname/-install_name/ Makefile
   '' ) + ''
@@ -36,4 +34,3 @@ stdenv.mkDerivation rec {
     platforms   = stdenv.lib.platforms.unix;
   };
 }
-
diff --git a/pkgs/development/libraries/ti-rpc/default.nix b/pkgs/development/libraries/ti-rpc/default.nix
index aa134d35104..99f0bb65441 100644
--- a/pkgs/development/libraries/ti-rpc/default.nix
+++ b/pkgs/development/libraries/ti-rpc/default.nix
@@ -8,14 +8,12 @@ stdenv.mkDerivation rec {
     sha256 = "0ppxl3k3nsz0qdakq844i2kj4fvh9h937lhx26bgmpmxq67sghw6";
   };
 
-  patches = stdenv.lib.optional stdenv.hostPlatform.isMusl
-    (fetchpatch {
-      url = "https://raw.githubusercontent.com/openembedded/openembedded-core/2be873301420ec6ca2c70d899b7c49a7e2b0954d/meta/recipes-extended/libtirpc/libtirpc/0001-replace-__bzero-with-memset-API.patch";
-      sha256 = "1jmbn0j2bnjp0j9z5vzz5xiwyv3kd28w5pixbqsy2lz6q8nii7cf";
-    });
-
   postPatch = ''
     sed '1i#include <stdint.h>' -i src/xdr_sizeof.c
+  '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+    substituteInPlace tirpc/rpc/types.h \
+      --replace '#if defined __APPLE_CC__ || defined __FreeBSD__' \
+                '#if defined __APPLE_CC__ || defined __FreeBSD__ || !defined __GLIBC__'
   '';
 
   nativeBuildInputs = [ autoreconfHook ];
diff --git a/pkgs/development/libraries/usbredir/default.nix b/pkgs/development/libraries/usbredir/default.nix
index 507c494ea27..515c3b2ca3b 100644
--- a/pkgs/development/libraries/usbredir/default.nix
+++ b/pkgs/development/libraries/usbredir/default.nix
@@ -9,9 +9,7 @@ stdenv.mkDerivation rec {
     sha256 = "1wsnmk4wjpdhbn1zaxg6bmyxspcki2zgy0am9lk037rnl4krwzj0";
   };
 
-  # Works around bunch of "format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'uint64_t {aka long long unsigned int}'" warnings
-  NIX_CFLAGS_COMPILE = stdenv.lib.optional (!stdenv.is64bit) "-Wno-error=format"
-    ++ [ "-Wno-error=format-truncation" ]; # newly detected with gcc-7
+  NIX_CFLAGS_COMPILE = [ "-Wno-error" ];
 
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ libusb ];
diff --git a/pkgs/development/libraries/virglrenderer/default.nix b/pkgs/development/libraries/virglrenderer/default.nix
index 0d9abc0247e..2cd3b5a20c0 100644
--- a/pkgs/development/libraries/virglrenderer/default.nix
+++ b/pkgs/development/libraries/virglrenderer/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, libGLU, epoxy, libX11 }:
+{ stdenv, fetchurl, pkgconfig, libGLU, epoxy, libX11, libdrm, mesa_noglu }:
 
 
 stdenv.mkDerivation rec {
@@ -11,10 +11,15 @@ stdenv.mkDerivation rec {
     sha256 = "a549e351e0eb2ad1df471386ddcf85f522e7202808d1616ee9ff894209066e1a";
   };
 
-  buildInputs = [ libGLU epoxy libX11 ];
+  buildInputs = [ libGLU epoxy libX11 libdrm mesa_noglu ];
 
   nativeBuildInputs = [ pkgconfig ];
 
+  # Fix use of fd_set without proper include
+  prePatch = ''
+    sed -e '1i#include <sys/select.h>' -i vtest/util.c
+  '';
+
   meta = with stdenv.lib; {
     description = "A virtual 3D GPU library that allows a qemu guest to use the host GPU for accelerated 3D rendering";
     homepage = https://virgil3d.github.io/;
diff --git a/pkgs/development/libraries/vulkan-loader/default.nix b/pkgs/development/libraries/vulkan-loader/default.nix
index 4bc64203051..9b73b9e1e41 100644
--- a/pkgs/development/libraries/vulkan-loader/default.nix
+++ b/pkgs/development/libraries/vulkan-loader/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchgit, fetchFromGitHub, cmake, pkgconfig, git, python3,
   python3Packages, glslang, spirv-tools, x11, libxcb, libXrandr,
-  libXext, wayland, libGL, makeWrapper }:
+  libXext, wayland, libGL_driver, makeWrapper }:
 
 let
   version = "1.0.61.1";
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
 
   cmakeFlags = [
     "-DBUILD_WSI_MIR_SUPPORT=OFF"
-    "-DFALLBACK_DATA_DIRS=${libGL.driverLink}/share:/usr/local/share:/usr/share"
+    "-DFALLBACK_DATA_DIRS=${libGL_driver.driverLink}/share:/usr/local/share:/usr/share"
   ];
 
   outputs = [ "out" "dev" "demos" ];
diff --git a/pkgs/development/libraries/webkitgtk/2.20.nix b/pkgs/development/libraries/webkitgtk/2.20.nix
index 8b44f11ee93..47144bee83a 100644
--- a/pkgs/development/libraries/webkitgtk/2.20.nix
+++ b/pkgs/development/libraries/webkitgtk/2.20.nix
@@ -2,7 +2,7 @@
 , pkgconfig, gettext, gobjectIntrospection, libnotify, gnutls, libgcrypt
 , gtk3, wayland, libwebp, enchant2, xorg, libxkbcommon, epoxy, at-spi2-core
 , libxml2, libsoup, libsecret, libxslt, harfbuzz, libpthreadstubs, pcre, nettle, libtasn1, p11-kit
-, libidn, libedit, readline, libGLU_combined, libintlOrEmpty
+, libidn, libedit, readline, libGLU_combined, libintl
 , enableGeoLocation ? true, geoclue2, sqlite
 , enableGtk2Plugins ? false, gtk2 ? null
 , gst-plugins-base, gst-plugins-bad, woff2
@@ -60,20 +60,18 @@ stdenv.mkDerivation rec {
   "-DENABLE_GTKDOC=OFF"
   ];
 
-  NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin " -lintl";
-
   nativeBuildInputs = [
     cmake ninja perl python2 ruby bison gperf
     pkgconfig gettext gobjectIntrospection
   ];
 
-  buildInputs = libintlOrEmpty ++ [
-    libwebp enchant2 libnotify gnutls pcre nettle libidn libgcrypt woff2
+  buildInputs = [
+    libintl libwebp enchant2 libnotify gnutls pcre nettle libidn libgcrypt woff2
     libxml2 libsecret libxslt harfbuzz libpthreadstubs libtasn1 p11-kit
     sqlite gst-plugins-base gst-plugins-bad libxkbcommon epoxy at-spi2-core
   ] ++ optional enableGeoLocation geoclue2
     ++ optional enableGtk2Plugins gtk2
-    ++ (with xorg; [ libXdmcp libXt libXtst ])
+    ++ (with xorg; [ libXdmcp libXt libXtst libXdamage ])
     ++ optionals stdenv.isDarwin [ libedit readline libGLU_combined ]
     ++ optional stdenv.isLinux wayland;
 
diff --git a/pkgs/development/libraries/wlc/default.nix b/pkgs/development/libraries/wlc/default.nix
index 846e710b0a4..a672bbf52a9 100644
--- a/pkgs/development/libraries/wlc/default.nix
+++ b/pkgs/development/libraries/wlc/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchFromGitHub, fetchpatch, cmake, pkgconfig
 , wayland, pixman, libxkbcommon, libinput, xcbutilwm, xcbutilimage, libGL
-, libX11, dbus_libs, wayland-protocols
-, libpthreadstubs, libXdmcp, libXext
+, libX11, dbus_libs, wayland-protocols, libdrm, mesa_noglu
+, libpthreadstubs, libXdmcp, libXext, libXfixes
 , withOptionalPackages ? true, zlib, valgrind, doxygen
 }:
 
@@ -21,8 +21,8 @@ stdenv.mkDerivation rec {
 
   buildInputs = [
     wayland pixman libxkbcommon libinput xcbutilwm xcbutilimage libGL
-    libX11 dbus_libs wayland-protocols
-    libpthreadstubs libXdmcp libXext ]
+    libX11 libXfixes dbus_libs wayland-protocols
+    libpthreadstubs libXdmcp libXext libdrm mesa_noglu ]
     ++ stdenv.lib.optionals withOptionalPackages [ zlib valgrind doxygen ];
 
   doCheck = true;
diff --git a/pkgs/development/libraries/wlroots/default.nix b/pkgs/development/libraries/wlroots/default.nix
index 3fdaeb82438..3349506c575 100644
--- a/pkgs/development/libraries/wlroots/default.nix
+++ b/pkgs/development/libraries/wlroots/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchFromGitHub, meson, ninja, pkgconfig
 , wayland, libGL, wayland-protocols, libinput, libxkbcommon, pixman
-, xcbutilwm, libX11, libcap, xcbutilimage, xcbutilerrors
+, xcbutilwm, libX11, libcap, xcbutilimage, xcbutilerrors, mesa_noglu
 }:
 
 let pname = "wlroots";
@@ -22,7 +22,7 @@ in stdenv.mkDerivation rec {
 
   buildInputs = [
     wayland libGL wayland-protocols libinput libxkbcommon pixman
-    xcbutilwm libX11 libcap xcbutilimage xcbutilerrors
+    xcbutilwm libX11 libcap xcbutilimage xcbutilerrors mesa_noglu
   ];
 
   # Install rootston (the reference compositor) to $bin
diff --git a/pkgs/development/mobile/genymotion/default.nix b/pkgs/development/mobile/genymotion/default.nix
index db3cb07765b..37834eff947 100644
--- a/pkgs/development/mobile/genymotion/default.nix
+++ b/pkgs/development/mobile/genymotion/default.nix
@@ -5,9 +5,9 @@
 
 let
   packages = [
-    stdenv.cc.cc zlib glib xorg.libX11 libxkbcommon libXmu libXi libXext
+    stdenv.cc.cc zlib glib xorg.libX11 libxkbcommon libXmu libXi libXext libGL
   ];
-  libPath = "${stdenv.lib.makeLibraryPath packages}:${libGL.driverLink}/lib";
+  libPath = "${stdenv.lib.makeLibraryPath packages}";
 in
 stdenv.mkDerivation rec {
   name = "genymotion-${version}";
diff --git a/pkgs/development/perl-modules/generic/builder.sh b/pkgs/development/perl-modules/generic/builder.sh
index 937dad971b8..b833ceb3cab 100644
--- a/pkgs/development/perl-modules/generic/builder.sh
+++ b/pkgs/development/perl-modules/generic/builder.sh
@@ -22,7 +22,7 @@ preConfigure() {
         fi
     done
 
-    perl Makefile.PL PREFIX=$out INSTALLDIRS=site $makeMakerFlags PERL=$(type -P perl) FULLPERL=$perl/bin/perl
+    perl Makefile.PL PREFIX=$out INSTALLDIRS=site $makeMakerFlags PERL=$(type -P perl) FULLPERL=\"$perl/bin/perl\"
 }
 
 
diff --git a/pkgs/development/python-modules/numpy/default.nix b/pkgs/development/python-modules/numpy/default.nix
index 3fce29cd8cd..b561149b2ab 100644
--- a/pkgs/development/python-modules/numpy/default.nix
+++ b/pkgs/development/python-modules/numpy/default.nix
@@ -1,14 +1,14 @@
-{lib, fetchPypi, python, buildPythonPackage, isPy27, isPyPy, gfortran, nose, blas}:
+{lib, fetchPypi, python, buildPythonPackage, isPy27, isPyPy, gfortran, nose, blas, hostPlatform }:
 
 buildPythonPackage rec {
   pname = "numpy";
-  version = "1.14.1";
+  version = "1.14.2";
   name = "${pname}-${version}";
 
   src = fetchPypi {
     inherit pname version;
     extension = "zip";
-    sha256 = "fa0944650d5d3fb95869eaacd8eedbd2d83610c85e271bd9d3495ffa9bc4dc9c";
+    sha256 = "facc6f925c3099ac01a1f03758100772560a0b020fb9d70f210404be08006bcb";
   };
 
   disabled = isPyPy;
@@ -20,6 +20,18 @@ buildPythonPackage rec {
     ./numpy-distutils-C++.patch
   ];
 
+  postPatch = lib.optionalString hostPlatform.isMusl ''
+    # Use fenv.h
+    sed -i \
+      numpy/core/src/npymath/ieee754.c.src \
+      numpy/core/include/numpy/ufuncobject.h \
+      -e 's/__GLIBC__/__linux__/'
+    # Don't use various complex trig functions
+    substituteInPlace numpy/core/src/private/npy_config.h \
+      --replace '#if defined(__GLIBC__)' "#if 1" \
+      --replace '#if !__GLIBC_PREREQ(2, 18)' "#if 1"
+  '';
+
   preConfigure = ''
     sed -i 's/-faltivec//' numpy/distutils/system_info.py
     export NPY_NUM_BUILD_JOBS=$NIX_BUILD_CORES
diff --git a/pkgs/development/r-modules/generic-builder.nix b/pkgs/development/r-modules/generic-builder.nix
index ff6c3ad1b90..0d731de33f8 100644
--- a/pkgs/development/r-modules/generic-builder.nix
+++ b/pkgs/development/r-modules/generic-builder.nix
@@ -3,9 +3,9 @@
 { name, buildInputs ? [], ... } @ attrs:
 
 stdenv.mkDerivation ({
-  buildInputs = buildInputs ++ [R] ++
+  buildInputs = buildInputs ++ [R gettext] ++
                 stdenv.lib.optionals attrs.requireX [utillinux xvfb_run] ++
-                stdenv.lib.optionals stdenv.isDarwin [Cocoa Foundation gettext gfortran];
+                stdenv.lib.optionals stdenv.isDarwin [Cocoa Foundation gfortran];
 
   NIX_CFLAGS_COMPILE =
     stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1";
diff --git a/pkgs/development/tools/build-managers/cmake/2.8.nix b/pkgs/development/tools/build-managers/cmake/2.8.nix
index fcf06782e4d..5fcd6b34165 100644
--- a/pkgs/development/tools/build-managers/cmake/2.8.nix
+++ b/pkgs/development/tools/build-managers/cmake/2.8.nix
@@ -1,11 +1,10 @@
 { stdenv, fetchurl, fetchpatch, replace, curl, expat, zlib, bzip2
-, useNcurses ? false, ncurses, useQt4 ? false, qt4, wantPS ? false, ps ? null
+, useNcurses ? false, ncurses, useQt4 ? false, qt4, ps
 , buildPlatform, hostPlatform
 }:
 
 with stdenv.lib;
 
-assert wantPS -> (ps != null);
 assert stdenv ? cc;
 assert stdenv.cc ? libc;
 
@@ -52,7 +51,7 @@ stdenv.mkDerivation rec {
     ++ optional useNcurses ncurses
     ++ optional useQt4 qt4;
 
-  propagatedBuildInputs = optional wantPS ps;
+  propagatedBuildInputs = [ ps ];
 
   CMAKE_PREFIX_PATH = concatStringsSep ":"
     (concatMap (p: [ (p.dev or p) (p.out or p) ]) buildInputs);
diff --git a/pkgs/development/tools/build-managers/cmake/setup-hook.sh b/pkgs/development/tools/build-managers/cmake/setup-hook.sh
index c796c31cb70..5053559bcca 100755
--- a/pkgs/development/tools/build-managers/cmake/setup-hook.sh
+++ b/pkgs/development/tools/build-managers/cmake/setup-hook.sh
@@ -44,6 +44,20 @@ cmakeConfigurePhase() {
         cmakeFlags="-DCMAKE_STRIP=$(command -v $crossConfig-strip) $cmakeFlags"
     fi
 
+    # on macOS we want to prefer Unix-style headers to Frameworks
+    # because we usually do not package the framework
+    cmakeFlags="-DCMAKE_FIND_FRAMEWORK=last $cmakeFlags"
+
+    # we never want to use the global macOS SDK
+    cmakeFlags="-DCMAKE_OSX_SYSROOT= $cmakeFlags"
+
+    # disable OSX deployment target
+    # we don't want our binaries to have a "minimum" OSX version
+    cmakeFlags="-DCMAKE_OSX_DEPLOYMENT_TARGET= $cmakeFlags"
+
+    # correctly detect our clang compiler
+    cmakeFlags="-DCMAKE_POLICY_DEFAULT_CMP0025=NEW $cmakeFlags"
+
     # This installs shared libraries with a fully-specified install
     # name. By default, cmake installs shared libraries with just the
     # basename as the install name, which means that, on Darwin, they
diff --git a/pkgs/development/tools/build-managers/gnumake/4.2/default.nix b/pkgs/development/tools/build-managers/gnumake/4.2/default.nix
index e175205143f..95466d843d6 100644
--- a/pkgs/development/tools/build-managers/gnumake/4.2/default.nix
+++ b/pkgs/development/tools/build-managers/gnumake/4.2/default.nix
@@ -20,6 +20,8 @@ stdenv.mkDerivation {
     # included Makefiles, don't look in /usr/include and friends.
     ./impure-dirs.patch
     ./pselect.patch
+    # Fix support for glibc 2.27's glob, inspired by http://www.linuxfromscratch.org/lfs/view/8.2/chapter05/make.html
+    ./glibc-2.27-glob.patch
   ];
 
   nativeBuildInputs = stdenv.lib.optionals guileSupport [ pkgconfig ];
diff --git a/pkgs/development/tools/build-managers/gnumake/4.2/glibc-2.27-glob.patch b/pkgs/development/tools/build-managers/gnumake/4.2/glibc-2.27-glob.patch
new file mode 100644
index 00000000000..186212d0d29
--- /dev/null
+++ b/pkgs/development/tools/build-managers/gnumake/4.2/glibc-2.27-glob.patch
@@ -0,0 +1,32 @@
+diff -Naur glob/glob.c glob/glob.c
+--- glob/glob.c	2013-10-20 13:14:38.000000000 -0400
++++ glob/glob.c	2018-03-16 14:32:38.483496170 -0400
+@@ -208,28 +208,9 @@
+ #endif /* __GNU_LIBRARY__ || __DJGPP__ */
+ 
+ 
+-#if !defined __alloca && !defined __GNU_LIBRARY__
+-
+-# ifdef	__GNUC__
+-#  undef alloca
+-#  define alloca(n)	__builtin_alloca (n)
+-# else	/* Not GCC.  */
+-#  ifdef HAVE_ALLOCA_H
+ #   include <alloca.h>
+-#  else	/* Not HAVE_ALLOCA_H.  */
+-#   ifndef _AIX
+-#    ifdef WINDOWS32
+-#     include <malloc.h>
+-#    else
+-extern char *alloca ();
+-#    endif /* WINDOWS32 */
+-#   endif /* Not _AIX.  */
+-#  endif /* sparc or HAVE_ALLOCA_H.  */
+-# endif	/* GCC.  */
+-
+ # define __alloca	alloca
+ 
+-#endif
+ 
+ #ifndef __GNU_LIBRARY__
+ # define __stat stat
diff --git a/pkgs/development/tools/build-managers/gnumake/4.2/glibc-2.27.patch b/pkgs/development/tools/build-managers/gnumake/4.2/glibc-2.27.patch
deleted file mode 100644
index c2639c6cc92..00000000000
--- a/pkgs/development/tools/build-managers/gnumake/4.2/glibc-2.27.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-From 48c8a116a914a325a0497721f5d8b58d5bba34d4 Mon Sep 17 00:00:00 2001
-From: Paul Smith <psmith@gnu.org>
-Date: Sun, 19 Nov 2017 15:09:16 -0500
-Subject: * configure.ac: Support GLIBC glob interface version 2
-
----
- configure.ac | 3 +--
- 1 file changed, 1 insertion(+), 2 deletions(-)
-
-diff -Naur a/configure b/configure
---- configure	2016-06-10 19:03:21.000000000 -0400
-+++ configure	2018-02-18 04:40:32.971371555 -0500
-@@ -11481,10 +11481,9 @@
- #include <glob.h>
- #include <fnmatch.h>
- 
--#define GLOB_INTERFACE_VERSION 1
- #if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
- # include <gnu-versions.h>
--# if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION
-+# if _GNU_GLOB_INTERFACE_VERSION == 1 || _GNU_GLOB_INTERFACE_VERSION == 2
-    gnu glob
- # endif
- #endif
diff --git a/pkgs/development/tools/build-managers/gnumake/4.2/head.nix b/pkgs/development/tools/build-managers/gnumake/4.2/head.nix
deleted file mode 100644
index 5f3ae10c3e5..00000000000
--- a/pkgs/development/tools/build-managers/gnumake/4.2/head.nix
+++ /dev/null
@@ -1,69 +0,0 @@
-{ stdenv, fetchurl, texinfo, guileSupport ? false, pkgconfig , guile ? null, autoreconfHook }:
-
-assert guileSupport -> ( guile != null );
-
-let
-  version = "4.2.90";
-  revision = "48c8a116a914a325a0497721f5d8b58d5bba34d4";
-  revCount = "2491";
-  shortRev = "48c8a11";
-
-  baseVersion = "4.2.1";
-  baseTarball = fetchurl {
-    url = "mirror://gnu/make/make-${baseVersion}.tar.bz2";
-    sha256 = "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn";
-  };
-in
-stdenv.mkDerivation {
-  name = "gnumake-${version}pre${revCount}_${shortRev}";
-
-  src = fetchurl {
-    url = "http://git.savannah.gnu.org/cgit/make.git/snapshot/make-${revision}.tar.gz";
-    sha256 = "0k6yvhr2a5lh1qhflv02dyvq5p20ikgaakm8w6gr4xmkspljwpwx";
-  };
-
-  postUnpack = ''
-    unpackFile ${baseTarball}
-    cp make-${baseVersion}/po/*.po $sourceRoot/po
-    cp make-${baseVersion}/doc/{fdl,make-stds}.texi $sourceRoot/doc
-  '';
-
-  patches = [
-    # Purity: don't look for library dependencies (of the form `-lfoo') in /lib
-    # and /usr/lib. It's a stupid feature anyway. Likewise, when searching for
-    # included Makefiles, don't look in /usr/include and friends.
-    ./impure-dirs-head.patch
-  ];
-
-  postPatch = ''
-    # These aren't in the 4.2.1 tarball yet.
-    sed -i -e 's/sr//' -e 's/zh_TW//' po/LINGUAS
-  '';
-
-  nativeBuildInputs = [ autoreconfHook pkgconfig texinfo ];
-  buildInputs = stdenv.lib.optional guileSupport guile;
-
-  configureFlags = stdenv.lib.optional guileSupport "--with-guile";
-
-  outputs = [ "out" "man" "info" ];
-
-  meta = with stdenv.lib; {
-    homepage = http://www.gnu.org/software/make/;
-    description = "A tool to control the generation of non-source files from sources";
-    license = licenses.gpl3Plus;
-
-    longDescription = ''
-      Make is a tool which controls the generation of executables and
-      other non-source files of a program from the program's source files.
-
-      Make gets its knowledge of how to build your program from a file
-      called the makefile, which lists each of the non-source files and
-      how to compute it from other files. When you write a program, you
-      should write a makefile for it, so that it is possible to use Make
-      to build and install the program.
-    '';
-
-    platforms = platforms.all;
-    maintainers = [ maintainers.vrthra ];
-  };
-}
diff --git a/pkgs/development/tools/build-managers/gnumake/4.2/impure-dirs-head.patch b/pkgs/development/tools/build-managers/gnumake/4.2/impure-dirs-head.patch
deleted file mode 100644
index 06d39e13ce3..00000000000
--- a/pkgs/development/tools/build-managers/gnumake/4.2/impure-dirs-head.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-diff -Naur a/src/read.c b/src/read.c
---- a/src/read.c	2017-11-19 15:17:47.000000000 -0500
-+++ b/src/read.c	2018-02-19 08:53:51.548755213 -0500
-@@ -109,10 +109,12 @@
- #endif
-     INCLUDEDIR,
- #ifndef _AMIGA
-+#if 0
-     "/usr/gnu/include",
-     "/usr/local/include",
-     "/usr/include",
- #endif
-+#endif
-     0
-   };
- 
-diff -Naur a/src/remake.c b/src/remake.c
---- a/src/remake.c	2017-11-19 15:17:47.000000000 -0500
-+++ b/src/remake.c	2018-02-19 08:54:08.304101943 -0500
-@@ -1601,9 +1601,11 @@
-   static const char *dirs[] =
-     {
- #ifndef _AMIGA
-+#if 0
-       "/lib",
-       "/usr/lib",
- #endif
-+#endif
- #if defined(WINDOWS32) && !defined(LIBDIR)
- /*
-  * This is completely up to the user at product install time. Just define
diff --git a/pkgs/development/tools/build-managers/meson/default.nix b/pkgs/development/tools/build-managers/meson/default.nix
index 47e57423632..aa642ffa727 100644
--- a/pkgs/development/tools/build-managers/meson/default.nix
+++ b/pkgs/development/tools/build-managers/meson/default.nix
@@ -43,6 +43,10 @@ in python3Packages.buildPythonApplication rec {
       src = ./fix-rpath.patch;
       inherit (builtins) storeDir;
     })
+
+    # No one will ever need more than 128 bytes of data structure
+    # https://github.com/mesonbuild/meson/issues/3113
+    ./overly-strict-size-check.patch
   ];
 
   setupHook = ./setup-hook.sh;
diff --git a/pkgs/development/tools/build-managers/meson/overly-strict-size-check.patch b/pkgs/development/tools/build-managers/meson/overly-strict-size-check.patch
new file mode 100644
index 00000000000..ea0e9bcd7ea
--- /dev/null
+++ b/pkgs/development/tools/build-managers/meson/overly-strict-size-check.patch
@@ -0,0 +1,12 @@
+diff -Naur a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
+--- a/mesonbuild/compilers/c.py	2017-12-10 08:37:19.000000000 -0500
++++ b/mesonbuild/compilers/c.py	2018-03-24 07:46:04.739929307 -0400
+@@ -406,7 +406,7 @@
+         }}'''
+         if not self.compiles(t.format(**fargs), env, extra_args, dependencies):
+             return -1
+-        return self.cross_compute_int('sizeof(%s)' % typename, 1, 128, None, prefix, env, extra_args, dependencies)
++        return self.cross_compute_int('sizeof(%s)' % typename, 1, 1024, None, prefix, env, extra_args, dependencies)
+ 
+     def sizeof(self, typename, prefix, env, extra_args=None, dependencies=None):
+         if extra_args is None:
diff --git a/pkgs/development/tools/misc/automake/automake-1.16.x.nix b/pkgs/development/tools/misc/automake/automake-1.16.x.nix
index 43efcf46280..affc400a9ed 100644
--- a/pkgs/development/tools/misc/automake/automake-1.16.x.nix
+++ b/pkgs/development/tools/misc/automake/automake-1.16.x.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, perl, autoconf, makeWrapper, doCheck ? false }:
 
 stdenv.mkDerivation rec {
-  name = "automake-1.16";
+  name = "automake-1.16.1";
 
   src = fetchurl {
     url = "mirror://gnu/automake/${name}.tar.xz";
-    sha256 = "12jvcmkcmd5p14b41w9f7ixd3sca97pymd6lqbkwnl8qn6bjv3zr";
+    sha256 = "08g979ficj18i1w6w5219bgmns7czr03iadf20mk3lrzl8wbn1ax";
   };
 
   nativeBuildInputs = [ autoconf perl ];
diff --git a/pkgs/development/tools/misc/binutils/2.30.nix b/pkgs/development/tools/misc/binutils/2.30.nix
deleted file mode 100644
index 830c0733052..00000000000
--- a/pkgs/development/tools/misc/binutils/2.30.nix
+++ /dev/null
@@ -1,131 +0,0 @@
-{ stdenv, buildPackages
-, fetchurl, zlib
-, buildPlatform, hostPlatform, targetPlatform
-, noSysDirs, gold ? true, bison ? null
-}:
-
-let
-  version = "2.30";
-  basename = "binutils-${version}";
-  inherit (stdenv.lib) optional optionals optionalString;
-  # The targetPrefix prepended to binary names to allow multiple binuntils on the
-  # PATH to both be usable.
-  targetPrefix = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-";
-in
-
-stdenv.mkDerivation rec {
-  name = targetPrefix + basename;
-
-  src = fetchurl {
-    url = "mirror://gnu/binutils/${basename}.tar.bz2";
-    sha256 = "028cklfqaab24glva1ks2aqa1zxa6w6xmc8q34zs1sb7h22dxspg";
-  };
-
-  patches = [
-    # Turn on --enable-new-dtags by default to make the linker set
-    # RUNPATH instead of RPATH on binaries.  This is important because
-    # RUNPATH can be overriden using LD_LIBRARY_PATH at runtime.
-    ./new-dtags.patch
-
-    # Since binutils 2.22, DT_NEEDED flags aren't copied for dynamic outputs.
-    # That requires upstream changes for things to work. So we can patch it to
-    # get the old behaviour by now.
-    ./dtneeded.patch
-
-    # Make binutils output deterministic by default.
-    ./deterministic.patch
-
-    # Always add PaX flags section to ELF files.
-    # This is needed, for instance, so that running "ldd" on a binary that is
-    # PaX-marked to disable mprotect doesn't fail with permission denied.
-    ./pt-pax-flags.patch
-
-    # Bfd looks in BINDIR/../lib for some plugins that don't
-    # exist. This is pointless (since users can't install plugins
-    # there) and causes a cycle between the lib and bin outputs, so
-    # get rid of it.
-    ./no-plugins.patch
-
-    # Help bfd choose between elf32-littlearm, elf32-littlearm-symbian, and
-    # elf32-littlearm-vxworks in favor of the first.
-    # https://github.com/NixOS/nixpkgs/pull/30484#issuecomment-345472766
-    ./disambiguate-arm-targets.patch
-
-    # For some reason bfd ld doesn't search DT_RPATH when cross-compiling. It's
-    # not clear why this behavior was decided upon but it has the unfortunate
-    # consequence that the linker will fail to find transitive dependencies of
-    # shared objects when cross-compiling. Consequently, we are forced to
-    # override this behavior, forcing ld to search DT_RPATH even when
-    # cross-compiling.
-    ./always-search-rpath.patch
-  ];
-
-  outputs = [ "out" "info" "man" ];
-
-  depsBuildBuild = [ buildPackages.stdenv.cc ];
-  nativeBuildInputs = [ bison ];
-  buildInputs = [ zlib ];
-
-  inherit noSysDirs;
-
-  preConfigure = ''
-    # Clear the default library search path.
-    if test "$noSysDirs" = "1"; then
-        echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt
-    fi
-
-    # Use symlinks instead of hard links to save space ("strip" in the
-    # fixup phase strips each hard link separately).
-    for i in binutils/Makefile.in gas/Makefile.in ld/Makefile.in gold/Makefile.in; do
-        sed -i "$i" -e 's|ln |ln -s |'
-    done
-  '';
-
-  # As binutils takes part in the stdenv building, we don't want references
-  # to the bootstrap-tools libgcc (as uses to happen on arm/mips)
-  NIX_CFLAGS_COMPILE = if hostPlatform.isDarwin
-    then "-Wno-string-plus-int -Wno-deprecated-declarations"
-    else "-static-libgcc";
-
-  # TODO(@Ericson2314): Always pass "--target" and always targetPrefix.
-  configurePlatforms =
-    # TODO(@Ericson2314): Figure out what's going wrong with Arm
-    if buildPlatform == hostPlatform && hostPlatform == targetPlatform && targetPlatform.isArm
-    then []
-    else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
-
-  configureFlags = [
-    "--enable-targets=all" "--enable-64-bit-bfd"
-    "--disable-install-libbfd"
-    "--disable-shared" "--enable-static"
-    "--with-system-zlib"
-
-    "--enable-deterministic-archives"
-    "--disable-werror"
-    "--enable-fix-loongson2f-nop"
-  ] ++ optionals gold [ "--enable-gold" "--enable-plugins" ];
-
-  enableParallelBuilding = true;
-
-  passthru = {
-    inherit targetPrefix version;
-  };
-
-  meta = with stdenv.lib; {
-    description = "Tools for manipulating binaries (linker, assembler, etc.)";
-    longDescription = ''
-      The GNU Binutils are a collection of binary tools.  The main
-      ones are `ld' (the GNU linker) and `as' (the GNU assembler).
-      They also include the BFD (Binary File Descriptor) library,
-      `gprof', `nm', `strip', etc.
-    '';
-    homepage = http://www.gnu.org/software/binutils/;
-    license = licenses.gpl3Plus;
-    maintainers = with maintainers; [ ericson2314 ];
-    platforms = platforms.unix;
-
-    /* Give binutils a lower priority than gcc-wrapper to prevent a
-       collision due to the ld/as wrappers/symlinks in the latter. */
-    priority = 10;
-  };
-}
diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix
index 05d0d21a179..ec0a5b4e9eb 100644
--- a/pkgs/development/tools/misc/binutils/default.nix
+++ b/pkgs/development/tools/misc/binutils/default.nix
@@ -5,10 +5,7 @@
 }:
 
 let
-  # Note to whoever is upgrading this: 2.29 is broken.
-  # ('nix-build pkgs/stdenv/linux/make-bootstrap-tools.nix -A test' segfaults on aarch64)
-  # Also glibc might need patching, see commit 733e20fee4a6700510f71fbe1a58ac23ea202f6a.
-  version = "2.28.1";
+  version = "2.30";
   basename = "binutils-${version}";
   inherit (stdenv.lib) optional optionals optionalString;
   # The targetPrefix prepended to binary names to allow multiple binuntils on the
@@ -21,7 +18,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "mirror://gnu/binutils/${basename}.tar.bz2";
-    sha256 = "1sj234nd05cdgga1r36zalvvdkvpfbr12g5mir2n8i1dwsdrj939";
+    sha256 = "028cklfqaab24glva1ks2aqa1zxa6w6xmc8q34zs1sb7h22dxspg";
   };
 
   patches = [
@@ -61,6 +58,9 @@ stdenv.mkDerivation rec {
     # override this behavior, forcing ld to search DT_RPATH even when
     # cross-compiling.
     ./always-search-rpath.patch
+
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=22868
+    ./gold-symbol-visibility.patch
   ];
 
   outputs = [ "out" "info" "man" ];
diff --git a/pkgs/development/tools/misc/binutils/gold-symbol-visibility.patch b/pkgs/development/tools/misc/binutils/gold-symbol-visibility.patch
new file mode 100644
index 00000000000..0fb05a482d1
--- /dev/null
+++ b/pkgs/development/tools/misc/binutils/gold-symbol-visibility.patch
@@ -0,0 +1,79 @@
+commit 8564af037f5c4c6d2744a89497691359205b2bbc
+Author: Shea Levy <shea@shealevy.com>
+Date:   Mon Mar 19 10:52:40 2018 -0400
+
+    Revert "Allow multiply-defined absolute symbols when they have the same value."
+    
+    This reverts commit 5dc824ed42cd173c1525f5abc76f4091f11a4dbc.
+
+diff --git a/gold/ChangeLog-2017 b/gold/ChangeLog-2017
+index b2a47710b5..d7ca1b48c0 100644
+--- a/gold/ChangeLog-2017
++++ b/gold/ChangeLog-2017
+@@ -114,11 +114,6 @@
+ 	(localedir): Define as @localedir@.
+ 	(gnulocaledir, gettextsrcdir): Use @datarootdir@.
+ 
+-2017-11-28  Cary Coutant  <ccoutant@gmail.com>
+-
+-	* resolve.cc (Symbol_table::resolve): Allow multiply-defined absolute
+-	symbols when they have the same value.
+-
+ 2017-11-28  Cary Coutant  <ccoutant@gmail.com>
+ 
+ 	* object.h (class Sized_relobj_file): Remove discarded_eh_frame_shndx_.
+diff --git a/gold/resolve.cc b/gold/resolve.cc
+index 4a5784cf8b..803576bfed 100644
+--- a/gold/resolve.cc
++++ b/gold/resolve.cc
+@@ -247,28 +247,18 @@ Symbol_table::resolve(Sized_symbol<size>* to,
+ 		      Object* object, const char* version,
+ 		      bool is_default_version)
+ {
+-  bool to_is_ordinary;
+-  const unsigned int to_shndx = to->shndx(&to_is_ordinary);
+-
+   // It's possible for a symbol to be defined in an object file
+   // using .symver to give it a version, and for there to also be
+   // a linker script giving that symbol the same version.  We
+   // don't want to give a multiple-definition error for this
+   // harmless redefinition.
++  bool to_is_ordinary;
+   if (to->source() == Symbol::FROM_OBJECT
+       && to->object() == object
+-      && to->is_defined()
+       && is_ordinary
++      && to->is_defined()
++      && to->shndx(&to_is_ordinary) == st_shndx
+       && to_is_ordinary
+-      && to_shndx == st_shndx
+-      && to->value() == sym.get_st_value())
+-    return;
+-
+-  // Likewise for an absolute symbol defined twice with the same value.
+-  if (!is_ordinary
+-      && st_shndx == elfcpp::SHN_ABS
+-      && !to_is_ordinary
+-      && to_shndx == elfcpp::SHN_ABS
+       && to->value() == sym.get_st_value())
+     return;
+ 
+@@ -360,8 +350,8 @@ Symbol_table::resolve(Sized_symbol<size>* to,
+       && (sym.get_st_bind() == elfcpp::STB_WEAK
+ 	  || to->binding() == elfcpp::STB_WEAK)
+       && orig_st_shndx != elfcpp::SHN_UNDEF
++      && to->shndx(&to_is_ordinary) != elfcpp::SHN_UNDEF
+       && to_is_ordinary
+-      && to_shndx != elfcpp::SHN_UNDEF
+       && sym.get_st_size() != 0    // Ignore weird 0-sized symbols.
+       && to->symsize() != 0
+       && (sym.get_st_type() != to->type()
+@@ -372,7 +362,7 @@ Symbol_table::resolve(Sized_symbol<size>* to,
+     {
+       Symbol_location fromloc
+           = { object, orig_st_shndx, static_cast<off_t>(sym.get_st_value()) };
+-      Symbol_location toloc = { to->object(), to_shndx,
++      Symbol_location toloc = { to->object(), to->shndx(&to_is_ordinary),
+ 				static_cast<off_t>(to->value()) };
+       this->candidate_odr_violations_[to->name()].insert(fromloc);
+       this->candidate_odr_violations_[to->name()].insert(toloc);
diff --git a/pkgs/development/tools/misc/creduce/default.nix b/pkgs/development/tools/misc/creduce/default.nix
index 37ec63627b1..cbf5883b297 100644
--- a/pkgs/development/tools/misc/creduce/default.nix
+++ b/pkgs/development/tools/misc/creduce/default.nix
@@ -6,8 +6,6 @@
 , utillinux
 }:
 
-assert stdenv.isLinux -> (utillinux != null);
-
 stdenv.mkDerivation rec {
   name = "creduce-${version}";
   version = "2.7.0";
diff --git a/pkgs/development/tools/misc/csmith/default.nix b/pkgs/development/tools/misc/csmith/default.nix
index 9a8c24fa168..c4994ad24d7 100644
--- a/pkgs/development/tools/misc/csmith/default.nix
+++ b/pkgs/development/tools/misc/csmith/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ m4 makeWrapper ];
-  buildInputs = [ libbsd perl SysCPU ];
+  buildInputs = [ perl SysCPU libbsd ];
 
   postInstall = ''
     substituteInPlace $out/bin/compiler_test.pl \
diff --git a/pkgs/development/tools/misc/help2man/default.nix b/pkgs/development/tools/misc/help2man/default.nix
index 6e341b577cf..b786aa2123f 100644
--- a/pkgs/development/tools/misc/help2man/default.nix
+++ b/pkgs/development/tools/misc/help2man/default.nix
@@ -1,26 +1,34 @@
-{ stdenv, hostPlatform, fetchurl, perl, gettext, LocaleGettext, makeWrapper }:
+{ stdenv, hostPlatform, fetchurl, perl, gettext, LocaleGettext }:
 
 stdenv.mkDerivation rec {
-  name = "help2man-1.47.5";
+  name = "help2man-1.47.6";
 
   src = fetchurl {
     url = "mirror://gnu/help2man/${name}.tar.xz";
-    sha256 = "1cb14kp380jzk1yi4i7x9d8qplc8c5mgcbgycgs9ggpx34jhp9kw";
+    sha256 = "0vz4dlrvy4vc6l7w0a7n668pfa0rdm73wr2gar58wqranyah46yr";
   };
 
-  nativeBuildInputs = [ makeWrapper gettext LocaleGettext ];
+  nativeBuildInputs = [ gettext LocaleGettext ];
   buildInputs = [ perl LocaleGettext ];
 
   doCheck = false;                                # target `check' is missing
 
   patches = if hostPlatform.isCygwin then [ ./1.40.4-cygwin-nls.patch ] else null;
 
-  postInstall =
-    '' wrapProgram "$out/bin/help2man" \
-         --prefix PERL5LIB : "$(echo ${LocaleGettext}/lib/perl*/site_perl)" \
-         ${stdenv.lib.optionalString hostPlatform.isCygwin "--prefix PATH : ${gettext}/bin"}
-    '';
-
+  # We don't use makeWrapper here because it uses substitutions our
+  # bootstrap shell can't handle.
+  postInstall = ''
+    gettext_perl="$(echo ${LocaleGettext}/lib/perl*/site_perl)"
+    mv $out/bin/help2man $out/bin/.help2man-wrapped
+    cat > $out/bin/help2man <<EOF
+    #! $SHELL -e
+    export PERL5LIB=\''${PERL5LIB:+:}$gettext_perl
+    ${stdenv.lib.optionalString hostPlatform.isCygwin
+        "export PATH=\''${PATH:+:}${gettext}/bin"}
+    exec -a \$0 $out/bin/.help2man-wrapped "\$@"
+    EOF
+    chmod +x $out/bin/help2man
+  '';
 
   meta = with stdenv.lib; {
     description = "Generate man pages from `--help' output";
diff --git a/pkgs/development/tools/misc/intel-gpu-tools/default.nix b/pkgs/development/tools/misc/intel-gpu-tools/default.nix
index 775a31df2b1..5176be12301 100644
--- a/pkgs/development/tools/misc/intel-gpu-tools/default.nix
+++ b/pkgs/development/tools/misc/intel-gpu-tools/default.nix
@@ -25,6 +25,8 @@ stdenv.mkDerivation rec {
     substituteInPlace tests/Makefile.am --replace '$(CAIRO_CFLAGS)' '$(CAIRO_CFLAGS) $(GLIB_CFLAGS)'
   '';
 
+  enableParallelBuilding = true;
+
   meta = with stdenv.lib; {
     homepage = https://01.org/linuxgraphics/;
     description = "Tools for development and testing of the Intel DRM driver";
diff --git a/pkgs/development/tools/misc/lsof/default.nix b/pkgs/development/tools/misc/lsof/default.nix
index 224e0aba6ef..53b960a7c03 100644
--- a/pkgs/development/tools/misc/lsof/default.nix
+++ b/pkgs/development/tools/misc/lsof/default.nix
@@ -4,13 +4,13 @@ let dialect = with stdenv.lib; last (splitString "-" stdenv.system); in
 
 stdenv.mkDerivation rec {
   name = "lsof-${version}";
-  version = "4.89";
+  version = "4.90";
 
   depsBuildBuild = [ buildPackages.stdenv.cc ];
   buildInputs = [ ncurses ];
 
   src = fetchurl {
-    urls =
+    urls = ["https://fossies.org/linux/misc/lsof_4.90.tar.bz2"] ++ # Mirrors seem to be down...
       ["ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_${version}.tar.bz2"]
       ++ map (
         # the tarball is moved after new version is released
@@ -23,22 +23,19 @@ stdenv.mkDerivation rec {
         + "${stdenv.lib.optionalString isOld "OLD/"}lsof_${version}.tar.bz2"
       ) [ false true ]
       ;
-    sha256 = "061p18v0mhzq517791xkjs8a5dfynq1418a1mwxpji69zp2jzb41";
+    sha256 = "1xhn3amvl5mmwji5g90nkw7lfmh2494v18qbv1f729hrg468853g";
   };
 
   unpackPhase = "tar xvjf $src; cd lsof_*; tar xvf lsof_*.tar; sourceRoot=$( echo lsof_*/); ";
 
-  patches = [ ./dfile.patch ];
-
   postPatch = stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
     substituteInPlace dialects/linux/dlsof.h --replace "defined(__UCLIBC__)" 1
   '';
 
   # Stop build scripts from searching global include paths
-  LSOF_INCLUDE = "${stdenv.cc.libc}/include";
+  LSOF_INCLUDE = "${stdenv.lib.getDev stdenv.cc.libc}/include";
   configurePhase = "LINUX_CONF_CC=$CC_FOR_BUILD LSOF_CC=$CC LSOF_AR=\"$AR cr\" LSOF_RANLIB=$RANLIB ./Configure -n ${dialect}";
   preBuild = ''
-    sed -i Makefile -e 's/^CFGF=/&	-DHASIPv6=1/;' -e 's/-lcurses/-lncurses/'
     for filepath in $(find dialects/${dialect} -type f); do
       sed -i "s,/usr/include,$LSOF_INCLUDE,g" $filepath
     done
@@ -58,7 +55,7 @@ stdenv.mkDerivation rec {
       socket (IPv6/IPv4/UNIX local), or partition (by opening a file
       from it).
     '';
-    maintainers = [ ];
+    maintainers = [ stdenv.lib.maintainers.dezgeg ];
     platforms = stdenv.lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/tools/misc/lsof/dfile.patch b/pkgs/development/tools/misc/lsof/dfile.patch
deleted file mode 100644
index 47202d5ebea..00000000000
--- a/pkgs/development/tools/misc/lsof/dfile.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- lsof_4.89_src/dialects/darwin/libproc/dfile.c	2014-10-30 12:39:46.000000000 +0100
-+++ lsof_4.89_src/dialects/darwin/libproc/dfile_new.c	2016-10-04 13:44:58.000000000 +0200
-@@ -286,13 +286,13 @@
- 
- #if	defined(PROC_FP_GUARDED)
- 	if (extra > 1)
--	    putchar(`,');
-+	    putchar(',');
- 	if (lf->guardflags) {
- 	    struct pff_tab *tp;
- 	    long gf;
- 
- 	    (void) printf("guard=");
--	    tp = Pgf_tab;
-+	    tp = Pff_tab;
- 	    gf = lf->guardflags;
- 	    while (gf && !FsvFlagX) {
- 		while (tp->nm) {