about summary refs log tree commit diff
path: root/pkgs/development/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/libraries')
-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/check/default.nix4
-rw-r--r--pkgs/development/libraries/cogl/default.nix12
-rw-r--r--pkgs/development/libraries/cracklib/default.nix4
-rw-r--r--pkgs/development/libraries/dbus/default.nix4
-rw-r--r--pkgs/development/libraries/epoxy/default.nix7
-rw-r--r--pkgs/development/libraries/epoxy/libgl-path.patch35
-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/gdbm/default.nix4
-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.nix10
-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.nix11
-rw-r--r--pkgs/development/libraries/http-parser/default.nix4
-rw-r--r--pkgs/development/libraries/iso-codes/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/libatomic_ops/default.nix7
-rw-r--r--pkgs/development/libraries/libatomic_ops/riscv.patch40
-rw-r--r--pkgs/development/libraries/libbfd/default.nix8
-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/libdrm/default.nix4
-rw-r--r--pkgs/development/libraries/libedit/default.nix4
-rw-r--r--pkgs/development/libraries/libglvnd/default.nix27
-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/libidn2/default.nix3
-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/libopcodes/default.nix6
-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.nix87
-rw-r--r--pkgs/development/libraries/mesa/missing-include.patch11
-rw-r--r--pkgs/development/libraries/mesa/musl-fixes.patch22
-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/libraries/zziplib/default.nix4
116 files changed, 852 insertions, 1723 deletions
diff --git a/pkgs/development/libraries/SDL_gfx/default.nix b/pkgs/development/libraries/SDL_gfx/default.nix
index 1d7d96f7536d..83a2ffc077c3 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 3c6f42e5cbf8..f9bb982a7842 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 b717101b3e13..6715a59579b5 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 efbc94457bf5..63fd7a4986f9 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 0bfeaf81a81d..96fe5b89a18c 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 6aa184e4204e..6a7beb1cc1a8 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 561be1ba2819..e45d74345d44 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 4ab554561f73..9d861f2c4328 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/check/default.nix b/pkgs/development/libraries/check/default.nix
index 1db991f63fee..ddaf022edfd4 100644
--- a/pkgs/development/libraries/check/default.nix
+++ b/pkgs/development/libraries/check/default.nix
@@ -4,11 +4,11 @@
 
 stdenv.mkDerivation rec {
   name = "check-${version}";
-  version = "0.11.0";
+  version = "0.12.0";
 
   src = fetchurl {
     url = "https://github.com/libcheck/check/releases/download/${version}/check-${version}.tar.gz";
-    sha256 = "05jn1pgb7hqb937xky2147nnq3r4qy5wwr79rddpax3bms5a9xr4";
+    sha256 = "0d22h8xshmbpl9hba9ch3xj8vb9ybm5akpsbbh7yj07fic4h2hj6";
   };
 
   # Test can randomly fail: http://hydra.nixos.org/build/7243912
diff --git a/pkgs/development/libraries/cogl/default.nix b/pkgs/development/libraries/cogl/default.nix
index 48b38c22af59..e06c71c15db4 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 d316b5bf2d1e..aa8b4231a869 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/dbus/default.nix b/pkgs/development/libraries/dbus/default.nix
index aa2af9a2ebc3..55484b85a8e6 100644
--- a/pkgs/development/libraries/dbus/default.nix
+++ b/pkgs/development/libraries/dbus/default.nix
@@ -6,8 +6,8 @@ assert x11Support -> libX11 != null
                   && libSM != null;
 
 let
-  version = "1.10.24";
-  sha256 = "06ydmrg76l1kwl3190d72zpiy3qxy248x6gskxbj9qiqfsr4w63i";
+  version = "1.12.6";
+  sha256 = "05picaq8j60wlwyi84qvw5liw3nd0cws9va3krnc3pms0wm906v2";
 
 self = stdenv.mkDerivation {
     name = "dbus-${version}";
diff --git a/pkgs/development/libraries/epoxy/default.nix b/pkgs/development/libraries/epoxy/default.nix
index 81966f14a568..e0f8e9ff8c76 100644
--- a/pkgs/development/libraries/epoxy/default.nix
+++ b/pkgs/development/libraries/epoxy/default.nix
@@ -25,10 +25,9 @@ stdenv.mkDerivation rec {
     substituteInPlace src/dispatch_common.h --replace "PLATFORM_HAS_GLX 0" "PLATFORM_HAS_GLX 1"
   '';
 
-  # add libGL to rpath because libepoxy dlopen()s libEGL
-  postFixup = optionalString stdenv.isLinux ''
-    patchelf --set-rpath "${stdenv.lib.makeLibraryPath [ libGL ]}:$(patchelf --print-rpath $out/lib/libepoxy.so.0.0.0)" $out/lib/libepoxy.so.0.0.0
-  '';
+  patches = [ ./libgl-path.patch ];
+
+  NIX_CFLAGS_COMPILE = ''-DLIBGL_PATH="${getLib libGL}/lib"'';
 
   meta = {
     description = "A library for handling OpenGL function pointer management";
diff --git a/pkgs/development/libraries/epoxy/libgl-path.patch b/pkgs/development/libraries/epoxy/libgl-path.patch
new file mode 100644
index 000000000000..6f50b9d262b5
--- /dev/null
+++ b/pkgs/development/libraries/epoxy/libgl-path.patch
@@ -0,0 +1,35 @@
+From 4046e0ac8ed93354c01de5f3b5cae790cce70404 Mon Sep 17 00:00:00 2001
+From: Will Dietz <w@wdtz.org>
+Date: Thu, 29 Mar 2018 07:21:02 -0500
+Subject: [PATCH] Explicitly search LIBGL_PATH as fallback, if defined.
+
+---
+ src/dispatch_common.c | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/src/dispatch_common.c b/src/dispatch_common.c
+index bc2fb94..776237b 100644
+--- a/src/dispatch_common.c
++++ b/src/dispatch_common.c
+@@ -306,6 +306,18 @@ get_dlopen_handle(void **handle, const char *lib_name, bool exit_on_fail)
+     pthread_mutex_lock(&api.mutex);
+     if (!*handle) {
+         *handle = dlopen(lib_name, RTLD_LAZY | RTLD_LOCAL);
++#ifdef LIBGL_PATH
++        if (!*handle) {
++          char pathbuf[sizeof(LIBGL_PATH) + 1 + 1024 + 1];
++          int l = snprintf(pathbuf, sizeof(pathbuf), "%s/%s", LIBGL_PATH, lib_name);
++          if (l < 0 || l >= sizeof(pathbuf)) {
++            // This really shouldn't happen
++            fprintf(stderr, "Error prefixing library pathname\n");
++            exit(1);
++          }
++          *handle = dlopen(pathbuf, RTLD_LAZY | RTLD_LOCAL);
++        }
++#endif
+         if (!*handle) {
+             if (exit_on_fail) {
+                 fprintf(stderr, "Couldn't open %s: %s\n", lib_name, dlerror());
+-- 
+2.16.3
+
diff --git a/pkgs/development/libraries/fontconfig/default.nix b/pkgs/development/libraries/fontconfig/default.nix
index 1109582ad64f..29838fe1ffa1 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 dc4327a52a88..000000000000
--- 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 7ccf4f3278b7..000000000000
--- 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 8f16f85cabf7..3fccce02def4 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 95ed83c60f8f..000000000000
--- 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 c1685c5116cc..000000000000
--- 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/gdbm/default.nix b/pkgs/development/libraries/gdbm/default.nix
index 310aaa430daf..3fd0bb082440 100644
--- a/pkgs/development/libraries/gdbm/default.nix
+++ b/pkgs/development/libraries/gdbm/default.nix
@@ -1,11 +1,11 @@
 { stdenv, lib, buildPlatform, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "gdbm-1.14";
+  name = "gdbm-1.14.1";
 
   src = fetchurl {
     url = "mirror://gnu/gdbm/${name}.tar.gz";
-    sha256 = "02dakgrq93xwgln8qfv3vs5jyz5yvds5nyzkx6rhg9v585x478dd";
+    sha256 = "0pxwz3jlwvglq2mrbxvrjgr8pa0aj73p3v9sxmdlj570zw0gzknd";
   };
 
   doCheck = true; # not cross;
diff --git a/pkgs/development/libraries/gdk-pixbuf/default.nix b/pkgs/development/libraries/gdk-pixbuf/default.nix
index a1a9b10fca63..6bfa6bdc2fb9 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 e743b60573ca..fee630c32a81 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 304d8110ad46..8c93428a0780 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 b70163789dec..495a113391e3 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 9c3024ce25fb..6dec7747c7e8 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 5932ef6a44f9..074d313e48aa 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 51ee5487f5f0..c3bcb3aa1c45 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 2c070ff3fa8c..d2dc9a8c637b 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 bb057ae899e7..000000000000
--- 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 4a5b31245c1c..000000000000
--- 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 c8e5b4562856..517c98e9f644 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 f84b1049adf8..000000000000
--- 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 fc14553c3ee0..f84b1049adf8 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 39312951fcf9..000000000000
--- 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 eeaf21901a39..39312951fcf9 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 a46abe3b4f7c..940b4e2aee4e 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 8769584a9f21..984603827c8d 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 3c884bb1224a..f79511897fbe 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 8caca820a57c..73cbaa0f8070 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
 }:
 
@@ -66,8 +66,8 @@ stdenv.mkDerivation rec {
     fluidsynth libvdpau
     libwebp xvidcore gnutls libGLU_combined
     libgme openssl x265 libxml2
+    libintl
   ]
-    ++ libintlOrEmpty
     ++ optional faacSupport faac
     ++ optional stdenv.isLinux wayland
     # wildmidi requires apple's OpenAL
@@ -76,5 +76,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 e2a8c36bf026..b3a4f445289e 100644
--- a/pkgs/development/libraries/gstreamer/base/default.nix
+++ b/pkgs/development/libraries/gstreamer/base/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, fetchpatch, pkgconfig, meson
 , ninja, gettext, gobjectIntrospection, python
 , gstreamer, orc, alsaLib, libXv, pango, libtheora
-, wayland, cdparanoia, libvisual, libintlOrEmpty
+, wayland, cdparanoia, libvisual, libintl
 }:
 
 stdenv.mkDerivation rec {
@@ -26,9 +26,8 @@ stdenv.mkDerivation rec {
   ];
 
   buildInputs = [
-    orc libXv pango libtheora cdparanoia wayland
+    orc libXv pango libtheora cdparanoia libintl wayland
   ]
-  ++ libintlOrEmpty
   ++ stdenv.lib.optional stdenv.isLinux alsaLib
   ++ stdenv.lib.optional (!stdenv.isDarwin) libvisual;
 
@@ -38,7 +37,7 @@ stdenv.mkDerivation rec {
     patchShebangs .
   '';
 
-  NIX_LDFLAGS = if stdenv.isDarwin then "-lintl" else null;
+  enableParallelBuilding = true;
 
   patches = [
     (fetchpatch {
diff --git a/pkgs/development/libraries/gstreamer/default.nix b/pkgs/development/libraries/gstreamer/default.nix
index ce74b2f27ff1..9aec87634040 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 { };
@@ -21,7 +21,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 960c03b52e29..5c10221b27d7 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, lame, mpg123, twolame
 , gtkSupport ? false, gtk3 ? null
 }:
@@ -43,13 +43,9 @@ stdenv.mkDerivation rec {
     gst-plugins-base orc bzip2
     libdv libvpx speex flac taglib
     cairo gdk_pixbuf aalib libcaca
-    libsoup libshout lame mpg123 twolame
+    libsoup libshout lame mpg123 twolame libintl
   ]
-  ++ libintlOrEmpty
   ++ optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ]
-  ++ optionals stdenv.isLinux [ libv4l libpulseaudio libavc1394 libiec61883 ]
-  # for gtksink
-  ++ optionals gtkSupport [ gtk3 ];
+  ++ optionals stdenv.isLinux [ libv4l libpulseaudio libavc1394 libiec61883 ];
 
-  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 2c2e1b0da122..8371b2780409 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 d533f798d999..75583624f545 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 5c289fb39114..ac680f8432ab 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 55d34a3fada3..e46ecfb76127 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 90e7eab860a3..a5449abb9f7d 100644
--- a/pkgs/development/libraries/gstreamer/ugly/default.nix
+++ b/pkgs/development/libraries/gstreamer/ugly/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, meson, ninja, pkgconfig, python
 , gst-plugins-base, orc, gettext
 , a52dec, libcdio, libdvdread
-, libmad, libmpeg2, x264, libintlOrEmpty
+, libmad, libmpeg2, x264, libintl
 }:
 
 stdenv.mkDerivation rec {
@@ -33,7 +33,6 @@ stdenv.mkDerivation rec {
     gst-plugins-base orc
     a52dec libcdio libdvdread
     libmad libmpeg2 x264
-  ] ++ 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 8a3ce884dfd7..d35e47f312f9 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 c96139ddb576..dc6a519dfade 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 59b3a34f7bdd..770f743fd260 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 bb68ae94a7f0..d098dd8fd146 100644
--- a/pkgs/development/libraries/harfbuzz/default.nix
+++ b/pkgs/development/libraries/harfbuzz/default.nix
@@ -1,11 +1,11 @@
-{ 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
 }:
 
 let
-  version = "1.7.5";
+  version = "1.7.6";
   inherit (stdenv.lib) optional optionals optionalString;
 in
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
 
   src = fetchurl {
     url = "http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-${version}.tar.bz2";
-    sha256 = "84574e1b1f65ca694cb8fb6905309665c0368af18a312357f8ff886ee2f29563";
+    sha256 = "16rf7qwgy1gza74v2ws79zdwwb1lpvgz2abwwm8ws9j82cwysyys";
   };
 
   outputs = [ "out" "dev" ];
@@ -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/http-parser/default.nix b/pkgs/development/libraries/http-parser/default.nix
index b17fc48c7e9a..5d4eae4e0639 100644
--- a/pkgs/development/libraries/http-parser/default.nix
+++ b/pkgs/development/libraries/http-parser/default.nix
@@ -1,13 +1,13 @@
 { stdenv, fetchurl, python2Packages, utillinux, fixDarwinDylibNames }:
 
 let
-  version = "2.8.0";
+  version = "2.8.1";
 in stdenv.mkDerivation {
   name = "http-parser-${version}";
 
   src = fetchurl {
     url = "https://github.com/joyent/http-parser/archive/v${version}.tar.gz";
-    sha256 = "17a7k3nxv2p1sp2x5d89wr51vk770753vz6qnlp2gz7nkgwwcxvj";
+    sha256 = "15ids8k2f0xhnnxh4m85w2f78pg5ndiwrpl24kyssznnp1l5yqai";
   };
 
   patches = [ ./build-shared.patch ];
diff --git a/pkgs/development/libraries/iso-codes/default.nix b/pkgs/development/libraries/iso-codes/default.nix
index 7d07408236e6..4dfe190124b1 100644
--- a/pkgs/development/libraries/iso-codes/default.nix
+++ b/pkgs/development/libraries/iso-codes/default.nix
@@ -1,11 +1,12 @@
 {stdenv, fetchurl, gettext, python3, xz}:
 
 stdenv.mkDerivation rec {
-  name = "iso-codes-3.74";
+  name = "iso-codes-${version}";
+  version = "3.79";
 
   src = fetchurl {
-    url = "http://pkg-isocodes.alioth.debian.org/downloads/${name}.tar.xz";
-    sha256 = "1vkaxkcx8h8lbg3z3jjfjs1x1rz1l01j6ll46ysza2gym37g7x11";
+    url = "https://salsa.debian.org/iso-codes-team/iso-codes/uploads/ef8de8bc12e0512d26ed73436a477871/${name}.tar.xz";
+    sha256 = "08i8hjy0qjlw9kd9i87jx967ihwh45l2xi55q1aa5265sind7byb";
   };
   patchPhase = ''
     for i in `find . -name \*.py`
diff --git a/pkgs/development/libraries/json-glib/default.nix b/pkgs/development/libraries/json-glib/default.nix
index bf32f4f8e8bc..21bddf8f6bb5 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 827d3de79ea8..91ceb959779e 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/libatomic_ops/default.nix b/pkgs/development/libraries/libatomic_ops/default.nix
index 04cf1c1e696e..fde8a06eb416 100644
--- a/pkgs/development/libraries/libatomic_ops/default.nix
+++ b/pkgs/development/libraries/libatomic_ops/default.nix
@@ -2,21 +2,18 @@
 
 stdenv.mkDerivation rec {
   name = "libatomic_ops-${version}";
-  version = "7.6.2";
+  version = "7.6.4";
 
   src = fetchurl {
     urls = [
       "http://www.ivmaisoft.com/_bin/atomic_ops/libatomic_ops-${version}.tar.gz"
       "https://github.com/ivmai/libatomic_ops/releases/download/v${version}/libatomic_ops-${version}.tar.gz"
     ];
-    sha256 ="1rif2hjscq5mh639nsnjhb90c01gnmy1sbmj6x6hsn1xmpnj95r1";
+    sha256 = "0knxncsjhbknlyy6lx7ycxhpzfk3sykhvicgxyp0rmsxd1d3v0jv";
   };
 
   outputs = [ "out" "dev" "doc" ];
 
-  # https://github.com/ivmai/libatomic_ops/pull/32
-  patches = if hostPlatform.isRiscV then [ ./riscv.patch ] else null;
-
   nativeBuildInputs = stdenv.lib.optionals stdenv.isCygwin [ autoconf automake libtool ];
 
   preConfigure = stdenv.lib.optionalString stdenv.isCygwin ''
diff --git a/pkgs/development/libraries/libatomic_ops/riscv.patch b/pkgs/development/libraries/libatomic_ops/riscv.patch
deleted file mode 100644
index 27f2408c34c6..000000000000
--- a/pkgs/development/libraries/libatomic_ops/riscv.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-diff -Naur libatomic_ops-7.6.2-orig/src/atomic_ops/sysdeps/gcc/riscv.h libatomic_ops-7.6.2/src/atomic_ops/sysdeps/gcc/riscv.h
---- libatomic_ops-7.6.2-orig/src/atomic_ops/sysdeps/gcc/riscv.h	1969-12-31 19:00:00.000000000 -0500
-+++ libatomic_ops-7.6.2/src/atomic_ops/sysdeps/gcc/riscv.h	2018-02-18 00:48:53.581721375 -0500
-@@ -0,0 +1 @@
-+#include "generic.h"
-diff -Naur libatomic_ops-7.6.2-orig/src/atomic_ops.h libatomic_ops-7.6.2/src/atomic_ops.h
---- libatomic_ops-7.6.2-orig/src/atomic_ops.h	2017-12-24 03:31:12.000000000 -0500
-+++ libatomic_ops-7.6.2/src/atomic_ops.h	2018-02-18 00:48:53.580721359 -0500
-@@ -352,6 +352,9 @@
- # if defined(__tile__)
- #   include "atomic_ops/sysdeps/gcc/tile.h"
- # endif
-+# if defined(__riscv)
-+#   include "atomic_ops/sysdeps/gcc/riscv.h"
-+# endif
- #endif /* __GNUC__ && !AO_USE_PTHREAD_DEFS */
- 
- #if (defined(__IBMC__) || defined(__IBMCPP__)) && !defined(__GNUC__) \
-diff -Naur libatomic_ops-7.6.2-orig/src/Makefile.am libatomic_ops-7.6.2/src/Makefile.am
---- libatomic_ops-7.6.2-orig/src/Makefile.am	2017-12-24 03:31:12.000000000 -0500
-+++ libatomic_ops-7.6.2/src/Makefile.am	2018-02-18 00:48:53.579721342 -0500
-@@ -92,6 +92,7 @@
-           atomic_ops/sysdeps/gcc/mips.h \
-           atomic_ops/sysdeps/gcc/nios2.h \
-           atomic_ops/sysdeps/gcc/powerpc.h \
-+          atomic_ops/sysdeps/gcc/riscv.h \
-           atomic_ops/sysdeps/gcc/s390.h \
-           atomic_ops/sysdeps/gcc/sh.h \
-           atomic_ops/sysdeps/gcc/sparc.h \
-diff -Naur libatomic_ops-7.6.2-orig/src/Makefile.in libatomic_ops-7.6.2/src/Makefile.in
---- libatomic_ops-7.6.2-orig/src/Makefile.in	2017-12-24 03:32:23.000000000 -0500
-+++ libatomic_ops-7.6.2/src/Makefile.in	2018-02-18 00:49:14.005062121 -0500
-@@ -446,6 +446,7 @@
-           atomic_ops/sysdeps/gcc/mips.h \
-           atomic_ops/sysdeps/gcc/nios2.h \
-           atomic_ops/sysdeps/gcc/powerpc.h \
-+          atomic_ops/sysdeps/gcc/riscv.h \
-           atomic_ops/sysdeps/gcc/s390.h \
-           atomic_ops/sysdeps/gcc/sh.h \
-           atomic_ops/sysdeps/gcc/sparc.h \
diff --git a/pkgs/development/libraries/libbfd/default.nix b/pkgs/development/libraries/libbfd/default.nix
index ac508908e8f2..3f244d399f7e 100644
--- a/pkgs/development/libraries/libbfd/default.nix
+++ b/pkgs/development/libraries/libbfd/default.nix
@@ -1,17 +1,15 @@
 { stdenv, buildPackages
-, fetchurl, fetchpatch, gnu-config, autoreconfHook264, bison
+, fetchurl, fetchpatch, gnu-config, autoreconfHook264, bison, binutils-unwrapped
 , libiberty, zlib
 }:
 
-let inherit (buildPackages.buildPackages) binutils-raw; in
-
 stdenv.mkDerivation rec {
   name = "libbfd-${version}";
-  inherit (binutils-raw.bintools) version src;
+  inherit (binutils-unwrapped) version src;
 
   outputs = [ "out" "dev" ];
 
-  patches = binutils-raw.bintools.patches ++ [
+  patches = binutils-unwrapped.patches ++ [
     ../../tools/misc/binutils/build-components-separately.patch
     (fetchpatch {
       url = "https://raw.githubusercontent.com/mxe/mxe/e1d4c144ee1994f70f86cf7fd8168fe69bd629c6/src/bfd-1-disable-subdir-doc.patch";
diff --git a/pkgs/development/libraries/libbsd/cdefs.patch b/pkgs/development/libraries/libbsd/cdefs.patch
new file mode 100644
index 000000000000..81822654aeb4
--- /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 0e232a50e943..ff9412ceb580 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 000000000000..66bd1e9232ba
--- /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 000000000000..f61e0d242943
--- /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/libdrm/default.nix b/pkgs/development/libraries/libdrm/default.nix
index 3eb7325132a8..82307e9ab163 100644
--- a/pkgs/development/libraries/libdrm/default.nix
+++ b/pkgs/development/libraries/libdrm/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, pkgconfig, libpthreadstubs, libpciaccess, valgrind-light }:
 
 stdenv.mkDerivation rec {
-  name = "libdrm-2.4.90";
+  name = "libdrm-2.4.91";
 
   src = fetchurl {
     url = "http://dri.freedesktop.org/libdrm/${name}.tar.bz2";
-    sha256 = "db37ec8f1dbaa2c192ad9903c8d0988b858ae88031e96f169bf76aaf705db68b";
+    sha256 = "0068dn47c478vm1lyyhy02gilrpsma0xmcblhvs0dzqyrk80wjk3";
   };
 
   outputs = [ "out" "dev" "bin" ];
diff --git a/pkgs/development/libraries/libedit/default.nix b/pkgs/development/libraries/libedit/default.nix
index bd230c61028f..154128144201 100644
--- a/pkgs/development/libraries/libedit/default.nix
+++ b/pkgs/development/libraries/libedit/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, ncurses, groff }:
 
 stdenv.mkDerivation rec {
-  name = "libedit-20160903-3.1";
+  name = "libedit-20170329-3.1";
 
   src = fetchurl {
     url = "http://thrysoee.dk/editline/${name}.tar.gz";
-    sha256 = "0rvmm8z6hal5bbp5pljp7yvkpqi4pkas1amizhvg35v0skkx5jqc";
+    sha256 = "1gnlgl0x8g9ky59s70nriy5gv47676d1s4ypvbv8y11apl7xkwli";
   };
 
   outputs = [ "out" "dev" ];
diff --git a/pkgs/development/libraries/libglvnd/default.nix b/pkgs/development/libraries/libglvnd/default.nix
index 7ea1ecdd0522..4bc1d1addcfb 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, fetchpatch, 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,21 @@ 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\""
   ];
 
+  # Upstream patch fixing use of libdl, should be in next release.
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/NVIDIA/libglvnd/commit/0177ade40262e31a80608a8e8e52d3da7163dccf.patch";
+      sha256 = "1rnz5jw2gvx4i1lcp0k85jz9xgr3dgzsd583m2dlxkaf2a09j89d";
+    })
+  ];
   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 5c5824a9930c..2fcf6701ab8f 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 afc3b9993a43..000000000000
--- 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 54a17d94a598..b0013d0f9491 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 0a44eee90aa0..656395b8867d 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 b55fc18cb69b..a4e6fed88e1c 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 000000000000..78222dddbf1d
--- /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/libidn2/default.nix b/pkgs/development/libraries/libidn2/default.nix
index d375785e497e..46cb579c56c4 100644
--- a/pkgs/development/libraries/libidn2/default.nix
+++ b/pkgs/development/libraries/libidn2/default.nix
@@ -15,8 +15,7 @@ stdenv.mkDerivation rec {
 
   patches = optional stdenv.isDarwin ./fix-error-darwin.patch;
 
-  nativeBuildInputs = [ ronn ]
-    ++ optional stdenv.isDarwin help2man;
+  nativeBuildInputs = optional stdenv.isDarwin help2man;
   buildInputs = [ libunistring ] ++ optional stdenv.isDarwin libiconv;
   depsBuildBuild = [ buildPackages.stdenv.cc ];
 
diff --git a/pkgs/development/libraries/libinfinity/default.nix b/pkgs/development/libraries/libinfinity/default.nix
index 9bbb8f0e129d..944cf7a6f5e2 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 3f7a4bed9cc9..0611e0e57e7b 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 2e7c913e6a8d..041e0d98d654 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 fe38755f10c5..9b692e9e3b2e 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/libopcodes/default.nix b/pkgs/development/libraries/libopcodes/default.nix
index d6d6989761bc..c918c61abf0d 100644
--- a/pkgs/development/libraries/libopcodes/default.nix
+++ b/pkgs/development/libraries/libopcodes/default.nix
@@ -1,15 +1,15 @@
 { stdenv, buildPackages
-, fetchurl, autoreconfHook264, bison, binutils-raw
+, fetchurl, autoreconfHook264, bison, binutils-unwrapped
 , libiberty, libbfd
 }:
 
 stdenv.mkDerivation rec {
   name = "libopcodes-${version}";
-  inherit (binutils-raw.bintools) version src;
+  inherit (binutils-unwrapped) version src;
 
   outputs = [ "out" "dev" ];
 
-  patches = binutils-raw.bintools.patches ++ [
+  patches = binutils-unwrapped.patches ++ [
     ../../tools/misc/binutils/build-components-separately.patch
   ];
 
diff --git a/pkgs/development/libraries/libpipeline/default.nix b/pkgs/development/libraries/libpipeline/default.nix
index 4da6a0b3cbc7..e11527ca10c9 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 4bb4db104382..c2e1739117b5 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 4ff00d777691..b77ba49822fd 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 dad245d0791e..92e9c3662c9f 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 fe0acbfc538d..aa3aaa1c59bc 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 2f8963db0cd8..b1e6938a1494 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 44638b4dfd59..69afd9d4c691 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 031ac781651c..04d621e29c84 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 6b8c3631fb37..0ba49da06cfe 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 eebdc2941974..35c339b45d09 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 9a6441956db3..4e35d6ed24d1 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 fbbfe44e27e8..e77a4e1414e9 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
@@ -66,12 +67,11 @@ let
 in
 
 let
-  version = "17.3.6";
+  version = "17.3.8";
   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 {
@@ -81,7 +81,7 @@ stdenv.mkDerivation {
       "ftp://ftp.freedesktop.org/pub/mesa/older-versions/${branch}.x/${version}/mesa-${version}.tar.xz"
       "https://mesa.freedesktop.org/archive/mesa-${version}.tar.xz"
     ];
-    sha256 = "e5915680d44ac9d05defdec529db7459ac9edd441c9845266eff2e2d3e57fbf8";
+    sha256 = "1cd6a4ll5arla3kncxnw9196ak1v4rvnb098aa7lm3n4h7r9p7cg";
   };
 
   prePatch = "patchShebangs .";
@@ -92,16 +92,17 @@ stdenv.mkDerivation {
   patches = [
     ./glx_ro_text_segm.patch # fix for grsecurity/PaX
     ./symlink-drivers.patch
-  ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./musl-fixes.patch;
+    ./missing-include.patch # dev_t needs sys/stat.h, fixes build w/musl
+  ];
 
   outputs = [ "out" "dev" "drivers" "osmesa" ];
 
   # 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 +119,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 +148,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 +176,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 +189,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 +225,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/mesa/missing-include.patch b/pkgs/development/libraries/mesa/missing-include.patch
new file mode 100644
index 000000000000..dd3e6bb64af8
--- /dev/null
+++ b/pkgs/development/libraries/mesa/missing-include.patch
@@ -0,0 +1,11 @@
+--- ./src/gallium/winsys/svga/drm/vmw_screen.h.orig
++++ ./src/gallium/winsys/svga/drm/vmw_screen.h
+@@ -34,7 +34,7 @@
+ #ifndef VMW_SCREEN_H_
+ #define VMW_SCREEN_H_
+ 
+-
++#include <sys/stat.h>
+ #include "pipe/p_compiler.h"
+ #include "pipe/p_state.h"
+ 
diff --git a/pkgs/development/libraries/mesa/musl-fixes.patch b/pkgs/development/libraries/mesa/musl-fixes.patch
deleted file mode 100644
index 60140d445ae8..000000000000
--- a/pkgs/development/libraries/mesa/musl-fixes.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- ./src/gallium/winsys/svga/drm/vmw_screen.h.orig
-+++ ./src/gallium/winsys/svga/drm/vmw_screen.h
-@@ -34,7 +34,7 @@
- #ifndef VMW_SCREEN_H_
- #define VMW_SCREEN_H_
- 
--
-+#include <sys/stat.h>
- #include "pipe/p_compiler.h"
- #include "pipe/p_state.h"
- 
---- a/src/util/u_endian.h.orig	2016-11-04 12:16:00.480356454 +0100
-+++ b/src/util/u_endian.h	2016-11-04 12:16:11.984347944 +0100
-@@ -27,7 +27,7 @@
- #ifndef U_ENDIAN_H
- #define U_ENDIAN_H
- 
--#if defined(__GLIBC__) || defined(ANDROID) || defined(__CYGWIN__)
-+#if defined(__linux__) || defined(ANDROID) || defined(__CYGWIN__)
- #include <endian.h>
- 
- #if __BYTE_ORDER == __LITTLE_ENDIAN
diff --git a/pkgs/development/libraries/ocl-icd/default.nix b/pkgs/development/libraries/ocl-icd/default.nix
index afd2a7b12dfa..ec6dc5f90528 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 3806926fa244..d880d41c7084 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 2ea5e923bad0..973798b849bc 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 1f360f075886..11dd8ec32910 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 4976399a66a6..568e7ce07b3b 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 d6bd90fa47d8..f442e1bf908e 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 bafe36647359..10f892bc4d00 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 0f5cf2b79c96..4c64e9e26e30 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 7e91cff065dd..08345510d787 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 314ab0f9e611..6e0fa53aa828 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 da5769e92cd1..f900de5e578b 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 d971f1a2e0b2..8cca5565bf6f 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 07d2a04c5e20..5ac0bcd1d7d7 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 bedd4771253b..0564459b24c0 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 d4ea531f886e..29ad55eb9d92 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 fd9ab5a2036d..89261b665f50 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 aa134d351044..99f0bb65441c 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 507c494ea27d..515c3b2ca3b9 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 0d9abc0247e2..2cd3b5a20c0c 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 2b0d765efc8b..cc6e7211b1d2 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.1.70.0";
@@ -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 588f4bc4e3bd..27524504872e 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
@@ -66,20 +66,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 846e710b0a48..a672bbf52a90 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 24cff1996c35..a4c2b3297145 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/libraries/zziplib/default.nix b/pkgs/development/libraries/zziplib/default.nix
index d43c481c8597..b59cb47eae57 100644
--- a/pkgs/development/libraries/zziplib/default.nix
+++ b/pkgs/development/libraries/zziplib/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "zziplib-${version}";
-  version = "0.13.68";
+  version = "0.13.69";
 
   src = fetchurl {
     url = "https://github.com/gdraheim/zziplib/archive/v${version}.tar.gz";
-    sha256 = "0chhl6m02562z6c4hjy568mh11pbq2qngw6g2x924ajr8sdr2q4l";
+    sha256 = "0i052a7shww0fzsxrdp3rd7g4mbzx7324a8ysbc0br7frpblcql4";
   };
 
   postPatch = ''