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/AntTweakBar/default.nix33
-rw-r--r--pkgs/development/libraries/CGAL/default.nix4
-rw-r--r--pkgs/development/libraries/LASzip/default.nix2
-rw-r--r--pkgs/development/libraries/SDL/default.nix101
-rw-r--r--pkgs/development/libraries/SDL/setup-hook.sh6
-rw-r--r--pkgs/development/libraries/SDL2/default.nix82
-rw-r--r--pkgs/development/libraries/SDL2/setup-hook.sh6
-rw-r--r--pkgs/development/libraries/SDL2_gfx/default.nix21
-rw-r--r--pkgs/development/libraries/SDL2_image/default.nix14
-rw-r--r--pkgs/development/libraries/SDL2_mixer/default.nix5
-rw-r--r--pkgs/development/libraries/SDL2_net/default.nix6
-rw-r--r--pkgs/development/libraries/SDL2_ttf/default.nix7
-rw-r--r--pkgs/development/libraries/SDL_gfx/default.nix7
-rw-r--r--pkgs/development/libraries/SDL_image/default.nix2
-rw-r--r--pkgs/development/libraries/SDL_mixer/default.nix4
-rw-r--r--pkgs/development/libraries/SDL_net/default.nix2
-rw-r--r--pkgs/development/libraries/SDL_ttf/default.nix2
-rw-r--r--pkgs/development/libraries/Xaw3d/default.nix8
-rw-r--r--pkgs/development/libraries/accounts-qt/default.nix7
-rw-r--r--pkgs/development/libraries/accountsservice/default.nix4
-rw-r--r--pkgs/development/libraries/ace/default.nix4
-rw-r--r--pkgs/development/libraries/acl/default.nix13
-rw-r--r--pkgs/development/libraries/agda/agda-stdlib/default.nix4
-rw-r--r--pkgs/development/libraries/agda/pretty/default.nix1
-rw-r--r--pkgs/development/libraries/agg/default.nix6
-rw-r--r--pkgs/development/libraries/alembic/default.nix9
-rw-r--r--pkgs/development/libraries/allegro/5.nix8
-rw-r--r--pkgs/development/libraries/allegro/default.nix4
-rw-r--r--pkgs/development/libraries/apache-activemq/default.nix4
-rw-r--r--pkgs/development/libraries/appstream-glib/default.nix51
-rw-r--r--pkgs/development/libraries/appstream-glib/paths.patch11
-rw-r--r--pkgs/development/libraries/appstream/default.nix50
-rw-r--r--pkgs/development/libraries/appstream/qt.nix25
-rw-r--r--pkgs/development/libraries/apr-util/default.nix4
-rw-r--r--pkgs/development/libraries/apr/default.nix4
-rw-r--r--pkgs/development/libraries/arguments/default.nix32
-rwxr-xr-xpkgs/development/libraries/arm-frc-linux-gnueabi-eglibc/default.nix65
-rwxr-xr-xpkgs/development/libraries/arm-frc-linux-gnueabi-linux-api-headers/default.nix43
-rw-r--r--pkgs/development/libraries/armadillo/default.nix4
-rw-r--r--pkgs/development/libraries/armadillo/use-unix-config-on-OS-X.patch9
-rw-r--r--pkgs/development/libraries/arrow-cpp/default.nix44
-rw-r--r--pkgs/development/libraries/asio/default.nix4
-rw-r--r--pkgs/development/libraries/aspell/default.nix19
-rw-r--r--pkgs/development/libraries/aspell/dictionaries.nix161
-rw-r--r--pkgs/development/libraries/assimp/default.nix4
-rw-r--r--pkgs/development/libraries/at-spi2-atk/default.nix10
-rw-r--r--pkgs/development/libraries/at-spi2-core/default.nix14
-rw-r--r--pkgs/development/libraries/atk/default.nix42
-rw-r--r--pkgs/development/libraries/atkmm/default.nix2
-rw-r--r--pkgs/development/libraries/attr/default.nix21
-rw-r--r--pkgs/development/libraries/attr/fix-headers-musl.patch54
-rw-r--r--pkgs/development/libraries/aubio/default.nix16
-rw-r--r--pkgs/development/libraries/audio/jamomacore/default.nix1
-rw-r--r--pkgs/development/libraries/audio/libgme/default.nix4
-rw-r--r--pkgs/development/libraries/audio/lv2/unstable.nix6
-rw-r--r--pkgs/development/libraries/audio/raul/default.nix6
-rw-r--r--pkgs/development/libraries/audio/suil/default.nix4
-rw-r--r--pkgs/development/libraries/audio/vamp/default.nix2
-rw-r--r--pkgs/development/libraries/audiofile/default.nix53
-rw-r--r--pkgs/development/libraries/avro-c/default.nix30
-rw-r--r--pkgs/development/libraries/aws-sdk-cpp/default.nix17
-rw-r--r--pkgs/development/libraries/babl/default.nix9
-rw-r--r--pkgs/development/libraries/bctoolbox/default.nix4
-rw-r--r--pkgs/development/libraries/beignet/default.nix4
-rw-r--r--pkgs/development/libraries/belcard/default.nix24
-rw-r--r--pkgs/development/libraries/belle-sip/default.nix4
-rw-r--r--pkgs/development/libraries/belr/default.nix24
-rw-r--r--pkgs/development/libraries/bobcat/default.nix1
-rw-r--r--pkgs/development/libraries/boehm-gc/default.nix34
-rw-r--r--pkgs/development/libraries/boehm-gc/riscv.patch53
-rw-r--r--pkgs/development/libraries/boolstuff/default.nix4
-rw-r--r--pkgs/development/libraries/boost/1.59.nix58
-rw-r--r--pkgs/development/libraries/boost/1.66.nix13
-rw-r--r--pkgs/development/libraries/boost/generic.nix152
-rw-r--r--pkgs/development/libraries/bootil/default.nix2
-rw-r--r--pkgs/development/libraries/botan/2.0.upstream4
-rw-r--r--pkgs/development/libraries/box2d/default.nix4
-rw-r--r--pkgs/development/libraries/breakpad/default.nix28
-rw-r--r--pkgs/development/libraries/buddy/default.nix2
-rw-r--r--pkgs/development/libraries/bullet/bullet283.nix29
-rw-r--r--pkgs/development/libraries/bullet/default.nix30
-rw-r--r--pkgs/development/libraries/bullet/gwen-narrowing.patch22
-rw-r--r--pkgs/development/libraries/bwidget/default.nix4
-rw-r--r--pkgs/development/libraries/bzrtp/default.nix24
-rw-r--r--pkgs/development/libraries/c-ares/default.nix29
-rw-r--r--pkgs/development/libraries/c-ares/release.patch19
-rw-r--r--pkgs/development/libraries/caf/default.nix12
-rw-r--r--pkgs/development/libraries/cairo/default.nix11
-rw-r--r--pkgs/development/libraries/cairomm/default.nix8
-rw-r--r--pkgs/development/libraries/catch/default.nix6
-rw-r--r--pkgs/development/libraries/cdk/default.nix9
-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/ceres-solver/default.nix4
-rw-r--r--pkgs/development/libraries/cfitsio/default.nix6
-rw-r--r--pkgs/development/libraries/check/default.nix4
-rw-r--r--pkgs/development/libraries/chipmunk/default.nix4
-rw-r--r--pkgs/development/libraries/cl/default.nix2
-rw-r--r--pkgs/development/libraries/clipper/default.nix27
-rw-r--r--pkgs/development/libraries/cln/default.nix2
-rw-r--r--pkgs/development/libraries/cloog-ppl/default.nix2
-rw-r--r--pkgs/development/libraries/cloog/0.18.0.nix2
-rw-r--r--pkgs/development/libraries/cloog/default.nix2
-rw-r--r--pkgs/development/libraries/clutter-gst/default.nix21
-rw-r--r--pkgs/development/libraries/clutter-gtk/default.nix19
-rw-r--r--pkgs/development/libraries/clutter/default.nix24
-rw-r--r--pkgs/development/libraries/cmark/default.nix6
-rw-r--r--pkgs/development/libraries/cminpack/default.nix4
-rw-r--r--pkgs/development/libraries/cmocka/default.nix21
-rw-r--r--pkgs/development/libraries/cogl/default.nix31
-rw-r--r--pkgs/development/libraries/coin3d/default.nix4
-rw-r--r--pkgs/development/libraries/confuse/default.nix7
-rw-r--r--pkgs/development/libraries/cpp-gsl/default.nix30
-rw-r--r--pkgs/development/libraries/cpp-netlib/default.nix1
-rw-r--r--pkgs/development/libraries/cppdb/default.nix6
-rw-r--r--pkgs/development/libraries/cppzmq/default.nix4
-rw-r--r--pkgs/development/libraries/cracklib/default.nix4
-rw-r--r--pkgs/development/libraries/csfml/default.nix31
-rw-r--r--pkgs/development/libraries/curlcpp/default.nix2
-rw-r--r--pkgs/development/libraries/cutee/default.nix2
-rw-r--r--pkgs/development/libraries/cyrus-sasl/default.nix3
-rw-r--r--pkgs/development/libraries/czmq/3.x.nix2
-rw-r--r--pkgs/development/libraries/czmq/4.x.nix9
-rw-r--r--pkgs/development/libraries/czmq/czmq3-gcc7.patch26
-rw-r--r--pkgs/development/libraries/dbus-cplusplus/default.nix25
-rw-r--r--pkgs/development/libraries/dbus/default.nix4
-rw-r--r--pkgs/development/libraries/dbus/make-dbus-conf.nix6
-rw-r--r--pkgs/development/libraries/dbus/make-system-conf.xsl1
-rw-r--r--pkgs/development/libraries/dirac/default.nix4
-rw-r--r--pkgs/development/libraries/dleyna-connector-dbus/default.nix24
-rw-r--r--pkgs/development/libraries/dleyna-core/0001-Search-connectors-in-DLEYNA_CONNECTOR_PATH.patch95
-rw-r--r--pkgs/development/libraries/dleyna-core/default.nix28
-rw-r--r--pkgs/development/libraries/dleyna-core/setup-hook.sh8
-rw-r--r--pkgs/development/libraries/dleyna-renderer/default.nix29
-rw-r--r--pkgs/development/libraries/dleyna-server/default.nix29
-rw-r--r--pkgs/development/libraries/dlib/default.nix6
-rw-r--r--pkgs/development/libraries/dotconf/default.nix2
-rw-r--r--pkgs/development/libraries/double-conversion/default.nix11
-rw-r--r--pkgs/development/libraries/drumstick/default.nix4
-rw-r--r--pkgs/development/libraries/easyloggingpp/default.nix14
-rw-r--r--pkgs/development/libraries/eccodes/default.nix6
-rw-r--r--pkgs/development/libraries/eigen/3.3.nix4
-rw-r--r--pkgs/development/libraries/elementary-cmake-modules/default.nix28
-rw-r--r--pkgs/development/libraries/elementary-cmake-modules/setup-hook.sh4
-rw-r--r--pkgs/development/libraries/enchant/2.x.nix27
-rw-r--r--pkgs/development/libraries/epoxy/default.nix20
-rw-r--r--pkgs/development/libraries/epoxy/libgl-path.patch35
-rw-r--r--pkgs/development/libraries/esdl/default.nix4
-rw-r--r--pkgs/development/libraries/exempi/default.nix4
-rw-r--r--pkgs/development/libraries/exiv2/default.nix18
-rw-r--r--pkgs/development/libraries/expat/default.nix6
-rw-r--r--pkgs/development/libraries/faac/default.nix6
-rw-r--r--pkgs/development/libraries/faad2/default.nix4
-rw-r--r--pkgs/development/libraries/facile/default.nix29
-rw-r--r--pkgs/development/libraries/facile/ocaml_4.xx.patch12
-rw-r--r--pkgs/development/libraries/farbfeld/default.nix6
-rw-r--r--pkgs/development/libraries/farstream/default.nix18
-rw-r--r--pkgs/development/libraries/fastpbkdf2/default.nix31
-rw-r--r--pkgs/development/libraries/fdk-aac/default.nix4
-rw-r--r--pkgs/development/libraries/fflas-ffpack/default.nix4
-rw-r--r--pkgs/development/libraries/ffmpeg-full/default.nix24
-rw-r--r--pkgs/development/libraries/ffmpeg/3.4.nix6
-rw-r--r--pkgs/development/libraries/ffmpeg/generic.nix10
-rw-r--r--pkgs/development/libraries/fftw/default.nix6
-rw-r--r--pkgs/development/libraries/flatbuffers/default.nix4
-rw-r--r--pkgs/development/libraries/flint/default.nix47
-rw-r--r--pkgs/development/libraries/flite/default.nix23
-rw-r--r--pkgs/development/libraries/fltk/default.nix4
-rw-r--r--pkgs/development/libraries/folly/default.nix16
-rw-r--r--pkgs/development/libraries/fontconfig/default.nix19
-rw-r--r--pkgs/development/libraries/fontconfig/make-fonts-cache.nix4
-rw-r--r--pkgs/development/libraries/fox/fox-1.6.nix8
-rw-r--r--pkgs/development/libraries/fplll/default.nix4
-rw-r--r--pkgs/development/libraries/freeglut/default.nix10
-rw-r--r--pkgs/development/libraries/freenect/default.nix18
-rw-r--r--pkgs/development/libraries/freetds/default.nix4
-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/fribidi/default.nix18
-rw-r--r--pkgs/development/libraries/ftgl/2.1.2.nix44
-rw-r--r--pkgs/development/libraries/ftgl/default.nix8
-rw-r--r--pkgs/development/libraries/ftgl/gcc.patch13
-rw-r--r--pkgs/development/libraries/gamin/debian-patches.nix2
-rw-r--r--pkgs/development/libraries/gamin/debian-patches.txt2
-rw-r--r--pkgs/development/libraries/gamin/default.nix11
-rw-r--r--pkgs/development/libraries/gbenchmark/default.nix4
-rw-r--r--pkgs/development/libraries/gcab/default.nix18
-rw-r--r--pkgs/development/libraries/gdal/default.nix6
-rw-r--r--pkgs/development/libraries/gdal/gdal-1_11.nix4
-rw-r--r--pkgs/development/libraries/gdbm/default.nix6
-rw-r--r--pkgs/development/libraries/gdcm/default.nix4
-rw-r--r--pkgs/development/libraries/gdk-pixbuf/default.nix24
-rw-r--r--pkgs/development/libraries/gdk-pixbuf/setup-hook.sh2
-rw-r--r--pkgs/development/libraries/gecode/3.nix6
-rw-r--r--pkgs/development/libraries/gecode/default.nix4
-rw-r--r--pkgs/development/libraries/gegl/3.0.nix26
-rw-r--r--pkgs/development/libraries/gegl/default.nix8
-rw-r--r--pkgs/development/libraries/geis/default.nix27
-rw-r--r--pkgs/development/libraries/geoclue/2.0.nix18
-rw-r--r--pkgs/development/libraries/geoclue/default.nix8
-rw-r--r--pkgs/development/libraries/geoip/default.nix17
-rw-r--r--pkgs/development/libraries/geos/default.nix4
-rw-r--r--pkgs/development/libraries/getdns/default.nix41
-rw-r--r--pkgs/development/libraries/gettext/default.nix3
-rw-r--r--pkgs/development/libraries/gettext/gettext-setup-hook.sh28
-rw-r--r--pkgs/development/libraries/giflib/5.0.nix18
-rw-r--r--pkgs/development/libraries/git2/0.25.nix34
-rw-r--r--pkgs/development/libraries/git2/default.nix45
-rw-r--r--pkgs/development/libraries/git2/disable-security.framework.patch58
-rw-r--r--pkgs/development/libraries/givaro/default.nix24
-rw-r--r--pkgs/development/libraries/glbinding/default.nix22
-rw-r--r--pkgs/development/libraries/gle/default.nix4
-rw-r--r--pkgs/development/libraries/glew/1.10.nix4
-rw-r--r--pkgs/development/libraries/glew/default.nix13
-rw-r--r--pkgs/development/libraries/glfw/2.x.nix4
-rw-r--r--pkgs/development/libraries/glfw/3.x.nix4
-rw-r--r--pkgs/development/libraries/glib-networking/default.nix40
-rw-r--r--pkgs/development/libraries/glib/default.nix43
-rw-r--r--pkgs/development/libraries/glib/schema-override-variable.patch12
-rw-r--r--pkgs/development/libraries/glib/setup-hook.sh7
-rw-r--r--pkgs/development/libraries/glibc/2.25-49.patch.gzbin89721 -> 0 bytes
-rw-r--r--pkgs/development/libraries/glibc/2.26-115to131.diff.gzbin0 -> 20022 bytes
-rw-r--r--pkgs/development/libraries/glibc/2.26-75.patch.gzbin0 -> 289084 bytes
-rw-r--r--pkgs/development/libraries/glibc/2.26-75to115.diff.gzbin0 -> 32865 bytes
-rw-r--r--pkgs/development/libraries/glibc/allow-kernel-2.6.32.patch39
-rw-r--r--pkgs/development/libraries/glibc/common.nix91
-rw-r--r--pkgs/development/libraries/glibc/dont-use-system-ld-so-cache.patch38
-rw-r--r--pkgs/development/libraries/glibc/locales.nix4
-rw-r--r--pkgs/development/libraries/glibc/nix-locale-archive.patch122
-rw-r--r--pkgs/development/libraries/glm/0954.nix36
-rw-r--r--pkgs/development/libraries/glm/default.nix39
-rw-r--r--pkgs/development/libraries/globalplatform/default.nix2
-rw-r--r--pkgs/development/libraries/glog/default.nix6
-rw-r--r--pkgs/development/libraries/glpk/default.nix4
-rw-r--r--pkgs/development/libraries/glui/default.nix4
-rw-r--r--pkgs/development/libraries/gmime/3.nix4
-rw-r--r--pkgs/development/libraries/gmp/6.x.nix7
-rw-r--r--pkgs/development/libraries/gmtk/default.nix32
-rw-r--r--pkgs/development/libraries/gmtk/fix-paths.patch20
-rw-r--r--pkgs/development/libraries/gnu-efi/default.nix19
-rw-r--r--pkgs/development/libraries/gnutls-kdh/generic.nix6
-rw-r--r--pkgs/development/libraries/gnutls/3.5.10.nix2
-rw-r--r--pkgs/development/libraries/gnutls/3.6.nix (renamed from pkgs/development/libraries/gnutls/3.5.nix)8
-rw-r--r--pkgs/development/libraries/gnutls/generic.nix6
-rw-r--r--pkgs/development/libraries/gobject-introspection/absolute_gir_path.patch11
-rw-r--r--pkgs/development/libraries/gobject-introspection/absolute_shlib_path.patch73
-rw-r--r--pkgs/development/libraries/gobject-introspection/default.nix37
-rw-r--r--pkgs/development/libraries/gobject-introspection/setup-hook.sh12
-rw-r--r--pkgs/development/libraries/godot_headers/default.nix23
-rw-r--r--pkgs/development/libraries/goffice/default.nix4
-rw-r--r--pkgs/development/libraries/goocanvas/2.x.nix29
-rw-r--r--pkgs/development/libraries/google-gflags/default.nix4
-rw-r--r--pkgs/development/libraries/gpgme/default.nix31
-rw-r--r--pkgs/development/libraries/granite/default.nix50
-rw-r--r--pkgs/development/libraries/grantlee/5/setup-hook.sh14
-rw-r--r--pkgs/development/libraries/grib-api/default.nix4
-rw-r--r--pkgs/development/libraries/grpc/default.nix26
-rw-r--r--pkgs/development/libraries/gsettings-qt/default.nix58
-rw-r--r--pkgs/development/libraries/gsl/default.nix3
-rw-r--r--pkgs/development/libraries/gsm/default.nix4
-rw-r--r--pkgs/development/libraries/gssdp/default.nix4
-rw-r--r--pkgs/development/libraries/gstreamer/bad/default.nix53
-rw-r--r--pkgs/development/libraries/gstreamer/bad/fix_pkgconfig_includedir.patch15
-rw-r--r--pkgs/development/libraries/gstreamer/base/default.nix35
-rw-r--r--pkgs/development/libraries/gstreamer/base/fix_pkgconfig_includedir.patch15
-rw-r--r--pkgs/development/libraries/gstreamer/core/default.nix31
-rw-r--r--pkgs/development/libraries/gstreamer/core/fix_pkgconfig_includedir.patch15
-rw-r--r--pkgs/development/libraries/gstreamer/core/setup-hook.sh2
-rw-r--r--pkgs/development/libraries/gstreamer/default.nix11
-rw-r--r--pkgs/development/libraries/gstreamer/ges/default.nix21
-rw-r--r--pkgs/development/libraries/gstreamer/ges/fix_pkgconfig_includedir.patch15
-rw-r--r--pkgs/development/libraries/gstreamer/gnonlin/default.nix30
-rw-r--r--pkgs/development/libraries/gstreamer/good/default.nix28
-rw-r--r--pkgs/development/libraries/gstreamer/good/fix_pkgconfig_includedir.patch15
-rw-r--r--pkgs/development/libraries/gstreamer/gstreamermm/default.nix13
-rw-r--r--pkgs/development/libraries/gstreamer/legacy/gst-plugins-bad/default.nix6
-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/legacy/gstreamer/setup-hook.sh2
-rw-r--r--pkgs/development/libraries/gstreamer/libav/default.nix15
-rw-r--r--pkgs/development/libraries/gstreamer/rtsp-server/default.nix29
-rw-r--r--pkgs/development/libraries/gstreamer/ugly/default.nix19
-rw-r--r--pkgs/development/libraries/gstreamer/vaapi/default.nix17
-rw-r--r--pkgs/development/libraries/gstreamer/validate/default.nix8
-rw-r--r--pkgs/development/libraries/gtdialog/default.nix8
-rw-r--r--pkgs/development/libraries/gtk+/2.x.nix11
-rw-r--r--pkgs/development/libraries/gtk+/3.x.nix49
-rw-r--r--pkgs/development/libraries/gtk-mac-integration/default.nix4
-rw-r--r--pkgs/development/libraries/gtkd/default.nix2
-rw-r--r--pkgs/development/libraries/gtkdatabox/default.nix4
-rw-r--r--pkgs/development/libraries/gtkmm/2.x.nix4
-rw-r--r--pkgs/development/libraries/gtksourceview/3.x-nix_share_path.patch11
-rw-r--r--pkgs/development/libraries/gtksourceview/3.x.nix60
-rw-r--r--pkgs/development/libraries/gtksourceview/4.x-nix_share_path.patch11
-rw-r--r--pkgs/development/libraries/gtksourceview/4.x.nix54
-rw-r--r--pkgs/development/libraries/gtkspell/3.nix10
-rw-r--r--pkgs/development/libraries/gts/default.nix2
-rw-r--r--pkgs/development/libraries/gumbo/default.nix (renamed from pkgs/development/libraries/libgumbo/default.nix)2
-rw-r--r--pkgs/development/libraries/gupnp-av/default.nix4
-rw-r--r--pkgs/development/libraries/gupnp-dlna/default.nix22
-rw-r--r--pkgs/development/libraries/gupnp/default.nix6
-rw-r--r--pkgs/development/libraries/gvfs/default.nix81
-rw-r--r--pkgs/development/libraries/harfbuzz/default.nix11
-rw-r--r--pkgs/development/libraries/herqq/default.nix4
-rw-r--r--pkgs/development/libraries/hivex/default.nix4
-rw-r--r--pkgs/development/libraries/hpx/default.nix4
-rw-r--r--pkgs/development/libraries/http-parser/default.nix4
-rw-r--r--pkgs/development/libraries/hunspell/default.nix4
-rw-r--r--pkgs/development/libraries/hunspell/dictionaries.nix118
-rw-r--r--pkgs/development/libraries/hwloc/default.nix25
-rw-r--r--pkgs/development/libraries/icu/58.nix4
-rw-r--r--pkgs/development/libraries/icu/60.nix4
-rw-r--r--pkgs/development/libraries/icu/base.nix118
-rw-r--r--pkgs/development/libraries/idnkit/default.nix7
-rw-r--r--pkgs/development/libraries/ignition-math/default.nix2
-rw-r--r--pkgs/development/libraries/ignition-transport/generic.nix3
-rw-r--r--pkgs/development/libraries/ilmbase/default.nix4
-rw-r--r--pkgs/development/libraries/imlib2/default.nix4
-rw-r--r--pkgs/development/libraries/indicator-application/gtk2.nix4
-rw-r--r--pkgs/development/libraries/indicator-application/gtk3.nix4
-rw-r--r--pkgs/development/libraries/iniparser/default.nix32
-rw-r--r--pkgs/development/libraries/ip2location-c/default.nix1
-rw-r--r--pkgs/development/libraries/irrlicht/default.nix4
-rw-r--r--pkgs/development/libraries/isl/0.11.1.nix4
-rw-r--r--pkgs/development/libraries/isl/0.12.2.nix2
-rw-r--r--pkgs/development/libraries/isl/0.14.1.nix2
-rw-r--r--pkgs/development/libraries/isl/0.15.0.nix2
-rw-r--r--pkgs/development/libraries/isl/0.17.1.nix2
-rw-r--r--pkgs/development/libraries/iso-codes/default.nix7
-rw-r--r--pkgs/development/libraries/itk/default.nix15
-rw-r--r--pkgs/development/libraries/jama/default.nix4
-rw-r--r--pkgs/development/libraries/jansson/default.nix4
-rw-r--r--pkgs/development/libraries/jasper/default.nix13
-rw-r--r--pkgs/development/libraries/java/classpath/default.nix61
-rw-r--r--pkgs/development/libraries/java/classpath/missing-casts.patch80
-rw-r--r--pkgs/development/libraries/java/commons/compress/default.nix4
-rw-r--r--pkgs/development/libraries/java/commons/io/default.nix4
-rw-r--r--pkgs/development/libraries/java/dbus-java/default.nix2
-rw-r--r--pkgs/development/libraries/java/hsqldb/default.nix4
-rw-r--r--pkgs/development/libraries/java/libmatthew-java/default.nix4
-rw-r--r--pkgs/development/libraries/java/lombok/default.nix15
-rw-r--r--pkgs/development/libraries/java/saxon/default.nix93
-rw-r--r--pkgs/development/libraries/java/saxon/default8.nix26
-rwxr-xr-xpkgs/development/libraries/java/saxon/unzip-builder.sh6
-rw-r--r--pkgs/development/libraries/java/swt/default.nix4
-rw-r--r--pkgs/development/libraries/javascript/jquery-ui/default.nix24
-rw-r--r--pkgs/development/libraries/javascript/jquery/default.nix36
-rw-r--r--pkgs/development/libraries/jbig2dec/default.nix12
-rw-r--r--pkgs/development/libraries/jemalloc/common.nix35
-rw-r--r--pkgs/development/libraries/jemalloc/default.nix39
-rw-r--r--pkgs/development/libraries/jemalloc/jemalloc450.nix6
-rw-r--r--pkgs/development/libraries/json-c/0.11.nix22
-rw-r--r--pkgs/development/libraries/json-c/default.nix13
-rw-r--r--pkgs/development/libraries/json-glib/default.nix11
-rw-r--r--pkgs/development/libraries/jsoncpp/default.nix4
-rw-r--r--pkgs/development/libraries/kdb/default.nix8
-rw-r--r--pkgs/development/libraries/kde-frameworks/default.nix6
-rw-r--r--pkgs/development/libraries/kde-frameworks/extra-cmake-modules/setup-hook.sh2
-rw-r--r--pkgs/development/libraries/kde-frameworks/fetch.sh2
-rw-r--r--pkgs/development/libraries/kde-frameworks/kcmutils/kcmutils-follow-symlinks.patch14
-rw-r--r--pkgs/development/libraries/kde-frameworks/kconfigwidgets/0001-qdiriterator-follow-symlinks.patch21
-rw-r--r--pkgs/development/libraries/kde-frameworks/kcoreaddons.nix4
-rw-r--r--pkgs/development/libraries/kde-frameworks/kdelibs4support/default.nix4
-rw-r--r--pkgs/development/libraries/kde-frameworks/kdoctools/default.nix14
-rw-r--r--pkgs/development/libraries/kde-frameworks/kdoctools/setup-hook.sh2
-rw-r--r--pkgs/development/libraries/kde-frameworks/kglobalaccel.nix4
-rw-r--r--pkgs/development/libraries/kde-frameworks/ki18n.nix8
-rw-r--r--pkgs/development/libraries/kde-frameworks/kimageformats.nix2
-rw-r--r--pkgs/development/libraries/kde-frameworks/kinit/default.nix8
-rw-r--r--pkgs/development/libraries/kde-frameworks/kservice/default.nix4
-rw-r--r--pkgs/development/libraries/kde-frameworks/ktexteditor.nix5
-rw-r--r--pkgs/development/libraries/kde-frameworks/plasma-framework.nix5
-rw-r--r--pkgs/development/libraries/kde-frameworks/srcs.nix624
-rw-r--r--pkgs/development/libraries/kdiagram/default.nix2
-rw-r--r--pkgs/development/libraries/kerberos/heimdal-make-missing-headers.patch10
-rw-r--r--pkgs/development/libraries/kerberos/heimdal.nix10
-rw-r--r--pkgs/development/libraries/kerberos/krb5.nix40
-rw-r--r--pkgs/development/libraries/keybinder/default.nix4
-rw-r--r--pkgs/development/libraries/keybinder3/default.nix4
-rw-r--r--pkgs/development/libraries/kirigami/default.nix47
-rw-r--r--pkgs/development/libraries/kmsxx/default.nix4
-rw-r--r--pkgs/development/libraries/kpmcore/default.nix4
-rw-r--r--pkgs/development/libraries/kyotocabinet/default.nix2
-rw-r--r--pkgs/development/libraries/languagemachines/frog.nix4
-rw-r--r--pkgs/development/libraries/languagemachines/libfolia.nix4
-rw-r--r--pkgs/development/libraries/languagemachines/mbt.nix4
-rw-r--r--pkgs/development/libraries/languagemachines/timbl.nix4
-rw-r--r--pkgs/development/libraries/languagemachines/timblserver.nix4
-rw-r--r--pkgs/development/libraries/languagemachines/ucto.nix6
-rw-r--r--pkgs/development/libraries/lasso/default.nix4
-rw-r--r--pkgs/development/libraries/lcms2/default.nix4
-rw-r--r--pkgs/development/libraries/ldns/default.nix21
-rw-r--r--pkgs/development/libraries/leatherman/default.nix4
-rw-r--r--pkgs/development/libraries/leveldb/default.nix20
-rw-r--r--pkgs/development/libraries/libHX/default.nix6
-rw-r--r--pkgs/development/libraries/libLAS/default.nix16
-rw-r--r--pkgs/development/libraries/libaal/default.nix4
-rw-r--r--pkgs/development/libraries/libaal/libaal-1.0.6-glibc-2.26.patch89
-rw-r--r--pkgs/development/libraries/libabw/default.nix4
-rw-r--r--pkgs/development/libraries/libaccounts-glib/default.nix10
-rw-r--r--pkgs/development/libraries/libagar/default.nix9
-rw-r--r--pkgs/development/libraries/libamqpcpp/default.nix29
-rw-r--r--pkgs/development/libraries/libamqpcpp/libamqpcpp-darwin.patch13
-rw-r--r--pkgs/development/libraries/libao/default.nix37
-rw-r--r--pkgs/development/libraries/libaom/default.nix25
-rw-r--r--pkgs/development/libraries/libappindicator/default.nix8
-rw-r--r--pkgs/development/libraries/libargon2/default.nix6
-rw-r--r--pkgs/development/libraries/libass/default.nix4
-rw-r--r--pkgs/development/libraries/libassuan/default.nix16
-rw-r--r--pkgs/development/libraries/libast/default.nix4
-rw-r--r--pkgs/development/libraries/libatomic_ops/default.nix10
-rw-r--r--pkgs/development/libraries/libatomic_ops/default.upstream1
-rw-r--r--pkgs/development/libraries/libaudclient/default.nix6
-rw-r--r--pkgs/development/libraries/libav/default.nix22
-rw-r--r--pkgs/development/libraries/libbap/default.nix6
-rw-r--r--pkgs/development/libraries/libbfd/default.nix59
-rw-r--r--pkgs/development/libraries/libbladeRF/default.nix6
-rw-r--r--pkgs/development/libraries/libbluray/default.nix6
-rw-r--r--pkgs/development/libraries/libbrotli/default.nix37
-rw-r--r--pkgs/development/libraries/libbsd/cdefs.patch222
-rw-r--r--pkgs/development/libraries/libbsd/darwin.patch138
-rw-r--r--pkgs/development/libraries/libbsd/default.nix16
-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/libbson/default.nix4
-rw-r--r--pkgs/development/libraries/libburn/default.nix4
-rw-r--r--pkgs/development/libraries/libcdio-paranoia/default.nix35
-rw-r--r--pkgs/development/libraries/libcdio/0.82.nix30
-rw-r--r--pkgs/development/libraries/libcdio/default.nix12
-rw-r--r--pkgs/development/libraries/libcdr/default.nix10
-rw-r--r--pkgs/development/libraries/libcec/platform.nix4
-rw-r--r--pkgs/development/libraries/libcerf/default.nix18
-rw-r--r--pkgs/development/libraries/libchamplain/default.nix44
-rw-r--r--pkgs/development/libraries/libchewing/default.nix4
-rw-r--r--pkgs/development/libraries/libclc/default.nix18
-rw-r--r--pkgs/development/libraries/libcli/default.nix1
-rw-r--r--pkgs/development/libraries/libcloudproviders/default.nix37
-rw-r--r--pkgs/development/libraries/libcloudproviders/fix-include.patch11
-rw-r--r--pkgs/development/libraries/libcollectdclient/default.nix11
-rw-r--r--pkgs/development/libraries/libconfuse/default.nix9
-rw-r--r--pkgs/development/libraries/libcouchbase/default.nix4
-rw-r--r--pkgs/development/libraries/libcue/default.nix4
-rw-r--r--pkgs/development/libraries/libcutl/default.nix10
-rw-r--r--pkgs/development/libraries/libdaemon/default.nix14
-rw-r--r--pkgs/development/libraries/libdaemon/fix-includes.patch13
-rw-r--r--pkgs/development/libraries/libdap/default.nix4
-rw-r--r--pkgs/development/libraries/libdazzle/default.nix55
-rw-r--r--pkgs/development/libraries/libdbi-drivers/default.nix18
-rw-r--r--pkgs/development/libraries/libdbusmenu/default.nix17
-rw-r--r--pkgs/development/libraries/libdevil/default.nix4
-rw-r--r--pkgs/development/libraries/libdigidocpp/default.nix6
-rw-r--r--pkgs/development/libraries/libdivecomputer/default.nix4
-rw-r--r--pkgs/development/libraries/libdrm/default.nix7
-rw-r--r--pkgs/development/libraries/libdvbpsi/default.nix4
-rw-r--r--pkgs/development/libraries/libdvdcss/default.nix4
-rw-r--r--pkgs/development/libraries/libdvdnav/default.nix4
-rw-r--r--pkgs/development/libraries/libdvdread/default.nix4
-rw-r--r--pkgs/development/libraries/libdwarf/default.nix8
-rw-r--r--pkgs/development/libraries/libdynd/default.nix7
-rw-r--r--pkgs/development/libraries/libebur128/default.nix4
-rw-r--r--pkgs/development/libraries/libedit/default.nix6
-rw-r--r--pkgs/development/libraries/libelf/default.nix24
-rw-r--r--pkgs/development/libraries/libesmtp/default.nix18
-rw-r--r--pkgs/development/libraries/libetpan/default.nix4
-rw-r--r--pkgs/development/libraries/libevdev/default.nix4
-rw-r--r--pkgs/development/libraries/libevent/default.nix3
-rw-r--r--pkgs/development/libraries/libewf/04-fix-FTBFS-GCC5.patch20
-rw-r--r--pkgs/development/libraries/libewf/default.nix10
-rw-r--r--pkgs/development/libraries/libewf/default.upstream7
-rw-r--r--pkgs/development/libraries/libexecinfo/default.nix46
-rw-r--r--pkgs/development/libraries/libexif/default.nix11
-rw-r--r--pkgs/development/libraries/libextractor/default.nix4
-rw-r--r--pkgs/development/libraries/libexttextcat/default.nix4
-rw-r--r--pkgs/development/libraries/libf2c/default.nix4
-rw-r--r--pkgs/development/libraries/libfaketime/default.nix12
-rw-r--r--pkgs/development/libraries/libffcall/default.nix4
-rw-r--r--pkgs/development/libraries/libffi/default.nix34
-rw-r--r--pkgs/development/libraries/libfilezilla/default.nix4
-rw-r--r--pkgs/development/libraries/libfixposix/default.nix4
-rw-r--r--pkgs/development/libraries/libftdi/1.x.nix6
-rw-r--r--pkgs/development/libraries/libftdi/default.nix12
-rw-r--r--pkgs/development/libraries/libgap/default.nix4
-rw-r--r--pkgs/development/libraries/libgcrypt/default.nix18
-rw-r--r--pkgs/development/libraries/libgee/0.6.nix27
-rw-r--r--pkgs/development/libraries/libgee/0.8.nix27
-rw-r--r--pkgs/development/libraries/libgig/default.nix22
-rw-r--r--pkgs/development/libraries/libgksu/default.nix10
-rw-r--r--pkgs/development/libraries/libglvnd/default.nix27
-rw-r--r--pkgs/development/libraries/libgpg-error/default.nix47
-rw-r--r--pkgs/development/libraries/libgphoto2/default.nix6
-rw-r--r--pkgs/development/libraries/libgphoto2/default.upstream9
-rw-r--r--pkgs/development/libraries/libgringotts/default.nix6
-rw-r--r--pkgs/development/libraries/libgroove/default.nix4
-rw-r--r--pkgs/development/libraries/libgroove/no-warnings-as-errors.patch15
-rw-r--r--pkgs/development/libraries/libgsf/default.nix13
-rw-r--r--pkgs/development/libraries/libgssglue/default.nix29
-rw-r--r--pkgs/development/libraries/libgsystem/default.nix4
-rw-r--r--pkgs/development/libraries/libgtop/default.nix28
-rw-r--r--pkgs/development/libraries/libgudev/default.nix17
-rw-r--r--pkgs/development/libraries/libguestfs/appliance.nix7
-rw-r--r--pkgs/development/libraries/libguestfs/default.nix51
-rw-r--r--pkgs/development/libraries/libhttpseverywhere/default.nix48
-rw-r--r--pkgs/development/libraries/libiberty/default.nix13
-rw-r--r--pkgs/development/libraries/libiconv/default.nix15
-rw-r--r--pkgs/development/libraries/libiconv/setup-hook.sh18
-rw-r--r--pkgs/development/libraries/libidn/default.nix3
-rw-r--r--pkgs/development/libraries/libidn2/default.nix7
-rw-r--r--pkgs/development/libraries/libimobiledevice/default.nix3
-rw-r--r--pkgs/development/libraries/libindicate/default.nix10
-rw-r--r--pkgs/development/libraries/libinfinity/default.nix12
-rw-r--r--pkgs/development/libraries/libinput/default.nix6
-rw-r--r--pkgs/development/libraries/libiodbc/default.nix4
-rw-r--r--pkgs/development/libraries/libisoburn/default.nix4
-rw-r--r--pkgs/development/libraries/libisofs/default.nix4
-rw-r--r--pkgs/development/libraries/libite/default.nix4
-rw-r--r--pkgs/development/libraries/libivykis/default.nix4
-rw-r--r--pkgs/development/libraries/libjpeg-turbo/default.nix6
-rw-r--r--pkgs/development/libraries/libjson-rpc-cpp/default.nix4
-rw-r--r--pkgs/development/libraries/libkate/default.nix4
-rw-r--r--pkgs/development/libraries/libkeyfinder/default.nix1
-rw-r--r--pkgs/development/libraries/libksba/default.nix3
-rw-r--r--pkgs/development/libraries/liblcf/default.nix23
-rw-r--r--pkgs/development/libraries/liblo/default.nix8
-rw-r--r--pkgs/development/libraries/liblogging/default.nix4
-rw-r--r--pkgs/development/libraries/liblouis/default.nix57
-rw-r--r--pkgs/development/libraries/liblscp/default.nix20
-rw-r--r--pkgs/development/libraries/libltc/default.nix6
-rw-r--r--pkgs/development/libraries/libmaxminddb/default.nix4
-rw-r--r--pkgs/development/libraries/libmbim/default.nix4
-rw-r--r--pkgs/development/libraries/libmd/default.nix4
-rw-r--r--pkgs/development/libraries/libmediainfo/default.nix6
-rw-r--r--pkgs/development/libraries/libmemcached/default.nix5
-rw-r--r--pkgs/development/libraries/libmemcached/musl-fixes.patch58
-rw-r--r--pkgs/development/libraries/libmicrohttpd/default.nix11
-rw-r--r--pkgs/development/libraries/libmikmod/default.nix4
-rw-r--r--pkgs/development/libraries/libminc/default.nix37
-rw-r--r--pkgs/development/libraries/libmng/default.nix4
-rw-r--r--pkgs/development/libraries/libmnl/default.nix2
-rw-r--r--pkgs/development/libraries/libmodbus/default.nix4
-rw-r--r--pkgs/development/libraries/libmodplug/default.nix4
-rw-r--r--pkgs/development/libraries/libmowgli/default.nix7
-rw-r--r--pkgs/development/libraries/libmpack/default.nix19
-rw-r--r--pkgs/development/libraries/libmpc/default.nix11
-rw-r--r--pkgs/development/libraries/libmsgpack/1.4.nix12
-rw-r--r--pkgs/development/libraries/libmsgpack/default.nix10
-rw-r--r--pkgs/development/libraries/libmsgpack/generic.nix13
-rw-r--r--pkgs/development/libraries/libmtp/default.nix4
-rw-r--r--pkgs/development/libraries/libmwaw/default.nix8
-rw-r--r--pkgs/development/libraries/libmx/default.nix6
-rw-r--r--pkgs/development/libraries/libmypaint/default.nix40
-rw-r--r--pkgs/development/libraries/libmysqlconnectorcpp/default.nix6
-rw-r--r--pkgs/development/libraries/libnatspec/default.nix1
-rw-r--r--pkgs/development/libraries/libnet/default.nix2
-rw-r--r--pkgs/development/libraries/libnet/fix-includes.patch29
-rw-r--r--pkgs/development/libraries/libnetfilter_conntrack/default.nix5
-rw-r--r--pkgs/development/libraries/libnetfilter_cttimeout/default.nix4
-rw-r--r--pkgs/development/libraries/libnetfilter_log/default.nix6
-rw-r--r--pkgs/development/libraries/libnetfilter_queue/default.nix7
-rw-r--r--pkgs/development/libraries/libnfnetlink/Use-stdlib-uint-instead-of-u_int.patch499
-rw-r--r--pkgs/development/libraries/libnfnetlink/default.nix4
-rw-r--r--pkgs/development/libraries/libnfs/default.nix2
-rw-r--r--pkgs/development/libraries/libnftnl/default.nix7
-rw-r--r--pkgs/development/libraries/libngspice/default.nix25
-rw-r--r--pkgs/development/libraries/libnice/default.nix4
-rw-r--r--pkgs/development/libraries/libnsl/cdefs.patch30
-rw-r--r--pkgs/development/libraries/libnsl/default.nix26
-rw-r--r--pkgs/development/libraries/libnsl/nis_h.patch45
-rw-r--r--pkgs/development/libraries/libofx/default.nix4
-rw-r--r--pkgs/development/libraries/libogg/default.nix4
-rw-r--r--pkgs/development/libraries/libomxil-bellagio/default.nix5
-rw-r--r--pkgs/development/libraries/libopcodes/default.nix44
-rw-r--r--pkgs/development/libraries/libosinfo/default.nix40
-rw-r--r--pkgs/development/libraries/libosinfo/osinfo-db-data-dir.patch11
-rw-r--r--pkgs/development/libraries/libowfat/default.nix10
-rw-r--r--pkgs/development/libraries/libp11/default.nix4
-rw-r--r--pkgs/development/libraries/libpar2/default.nix2
-rw-r--r--pkgs/development/libraries/libpcap/default.nix9
-rw-r--r--pkgs/development/libraries/libpfm/default.nix4
-rw-r--r--pkgs/development/libraries/libpinyin/default.nix9
-rw-r--r--pkgs/development/libraries/libpipeline/default.nix8
-rw-r--r--pkgs/development/libraries/libpng/default.nix2
-rw-r--r--pkgs/development/libraries/libpqxx/default.nix16
-rw-r--r--pkgs/development/libraries/libproxy/default.nix12
-rw-r--r--pkgs/development/libraries/libpsl/default.nix5
-rw-r--r--pkgs/development/libraries/libpst/default.nix4
-rw-r--r--pkgs/development/libraries/libqalculate/default.nix7
-rw-r--r--pkgs/development/libraries/libqglviewer/default.nix5
-rw-r--r--pkgs/development/libraries/libqmatrixclient/default.nix40
-rw-r--r--pkgs/development/libraries/libqmi/default.nix4
-rw-r--r--pkgs/development/libraries/libqrencode/default.nix4
-rw-r--r--pkgs/development/libraries/libqtav/default.nix10
-rw-r--r--pkgs/development/libraries/libraw/default.nix4
-rw-r--r--pkgs/development/libraries/libraw1394/default.nix4
-rw-r--r--pkgs/development/libraries/librdf/rasqal.nix4
-rw-r--r--pkgs/development/libraries/librdf/redland.nix2
-rw-r--r--pkgs/development/libraries/librdmacm/default.nix4
-rw-r--r--pkgs/development/libraries/libre/default.nix13
-rw-r--r--pkgs/development/libraries/librelp/default.nix4
-rw-r--r--pkgs/development/libraries/librem/default.nix4
-rw-r--r--pkgs/development/libraries/librep/default.nix4
-rw-r--r--pkgs/development/libraries/librep/setup-hook.sh2
-rw-r--r--pkgs/development/libraries/libressl/default.nix4
-rw-r--r--pkgs/development/libraries/librevenge/default.nix5
-rw-r--r--pkgs/development/libraries/librime/default.nix8
-rw-r--r--pkgs/development/libraries/libroxml/default.nix16
-rw-r--r--pkgs/development/libraries/librsvg/default.nix39
-rw-r--r--pkgs/development/libraries/librsync/default.nix4
-rw-r--r--pkgs/development/libraries/libs3/default.nix9
-rw-r--r--pkgs/development/libraries/libsass/default.nix4
-rw-r--r--pkgs/development/libraries/libsearpc/default.nix2
-rw-r--r--pkgs/development/libraries/libseccomp/default.nix7
-rw-r--r--pkgs/development/libraries/libsecret/default.nix21
-rw-r--r--pkgs/development/libraries/libserialport/default.nix4
-rw-r--r--pkgs/development/libraries/libsexy/default.nix2
-rw-r--r--pkgs/development/libraries/libsigcxx/default.nix5
-rw-r--r--pkgs/development/libraries/libsigsegv/2.5.nix23
-rw-r--r--pkgs/development/libraries/libsigsegv/default.nix6
-rw-r--r--pkgs/development/libraries/libskk/default.nix49
-rw-r--r--pkgs/development/libraries/libsnark/darwin-fix-clock-gettime.patch41
-rw-r--r--pkgs/development/libraries/libsnark/default.nix32
-rw-r--r--pkgs/development/libraries/libsndfile/default.nix29
-rw-r--r--pkgs/development/libraries/libsodium/default.nix4
-rw-r--r--pkgs/development/libraries/libsolv/default.nix4
-rw-r--r--pkgs/development/libraries/libsoundio/default.nix10
-rw-r--r--pkgs/development/libraries/libsoup/default.nix52
-rw-r--r--pkgs/development/libraries/libspatialindex/default.nix6
-rw-r--r--pkgs/development/libraries/libspatialite/default.nix4
-rw-r--r--pkgs/development/libraries/libsrs2/default.nix4
-rw-r--r--pkgs/development/libraries/libstatgrab/default.nix2
-rw-r--r--pkgs/development/libraries/libstdc++5/default.nix8
-rw-r--r--pkgs/development/libraries/libstdc++5/struct-ucontext.patch61
-rw-r--r--pkgs/development/libraries/libstemmer/default.nix22
-rw-r--r--pkgs/development/libraries/libstroke/default.nix6
-rw-r--r--pkgs/development/libraries/libstrophe/default.nix4
-rw-r--r--pkgs/development/libraries/libsvm/default.nix8
-rw-r--r--pkgs/development/libraries/libtar/default.nix2
-rw-r--r--pkgs/development/libraries/libtasn1/default.nix15
-rw-r--r--pkgs/development/libraries/libtcod/default.nix4
-rw-r--r--pkgs/development/libraries/libtermkey/default.nix4
-rw-r--r--pkgs/development/libraries/libtheora/default.nix2
-rw-r--r--pkgs/development/libraries/libtiff/default.nix12
-rw-r--r--pkgs/development/libraries/libtiger/default.nix8
-rw-r--r--pkgs/development/libraries/libtins/default.nix43
-rw-r--r--pkgs/development/libraries/libtomcrypt/default.nix29
-rw-r--r--pkgs/development/libraries/libtommath/default.nix32
-rw-r--r--pkgs/development/libraries/libtorrent-rasterbar/1.0.nix13
-rw-r--r--pkgs/development/libraries/libtorrent-rasterbar/default.nix4
-rw-r--r--pkgs/development/libraries/libtorrent-rasterbar/generic.nix2
-rw-r--r--pkgs/development/libraries/libtoxcore/default.nix13
-rw-r--r--pkgs/development/libraries/libtoxcore/old-api.nix59
-rw-r--r--pkgs/development/libraries/libtxc_dxtn/default.nix4
-rw-r--r--pkgs/development/libraries/libtxc_dxtn_s2tc/default.nix4
-rw-r--r--pkgs/development/libraries/libu2f-host/default.nix6
-rw-r--r--pkgs/development/libraries/libui/default.nix4
-rw-r--r--pkgs/development/libraries/libunique/3.x.nix4
-rw-r--r--pkgs/development/libraries/libunique/default.nix9
-rw-r--r--pkgs/development/libraries/libunique/gcc7-bug.patch18
-rw-r--r--pkgs/development/libraries/libunistring/clang.patch14
-rw-r--r--pkgs/development/libraries/libunistring/default.nix15
-rw-r--r--pkgs/development/libraries/libunity/default.nix27
-rw-r--r--pkgs/development/libraries/libunwind/backtrace-only-with-glibc.patch45
-rw-r--r--pkgs/development/libraries/libunwind/default.nix3
-rw-r--r--pkgs/development/libraries/liburcu/default.nix8
-rw-r--r--pkgs/development/libraries/libusb/default.nix2
-rw-r--r--pkgs/development/libraries/libusb/fix-headers.patch10
-rw-r--r--pkgs/development/libraries/libusb1/default.nix4
-rw-r--r--pkgs/development/libraries/libusbmuxd/default.nix3
-rw-r--r--pkgs/development/libraries/libuv/default.nix4
-rw-r--r--pkgs/development/libraries/libva-utils/default.nix29
-rw-r--r--pkgs/development/libraries/libva/1.0.0.nix37
-rw-r--r--pkgs/development/libraries/libva/default.nix45
-rw-r--r--pkgs/development/libraries/libvdpau-va-gl/default.nix4
-rw-r--r--pkgs/development/libraries/libvdpau/default.nix11
-rw-r--r--pkgs/development/libraries/libvirt-glib/default.nix10
-rw-r--r--pkgs/development/libraries/libvirt/build-on-bsd.patch58
-rw-r--r--pkgs/development/libraries/libvirt/default.nix69
-rw-r--r--pkgs/development/libraries/libvisio/default.nix29
-rw-r--r--pkgs/development/libraries/libvisual/default.nix2
-rw-r--r--pkgs/development/libraries/libvncserver/default.nix22
-rw-r--r--pkgs/development/libraries/libvorbis/default.nix15
-rw-r--r--pkgs/development/libraries/libvpx/default.nix2
-rw-r--r--pkgs/development/libraries/libvpx/git.nix2
-rw-r--r--pkgs/development/libraries/libwacom/default.nix6
-rw-r--r--pkgs/development/libraries/libwebp/default.nix10
-rw-r--r--pkgs/development/libraries/libwebsockets/default.nix4
-rw-r--r--pkgs/development/libraries/libwhereami/default.nix7
-rw-r--r--pkgs/development/libraries/libwnck/3.x.nix35
-rw-r--r--pkgs/development/libraries/libwnck/install_introspection_to_prefix.patch12
-rw-r--r--pkgs/development/libraries/libwpg/default.nix4
-rw-r--r--pkgs/development/libraries/libwps/default.nix6
-rw-r--r--pkgs/development/libraries/libx86emu/default.nix24
-rw-r--r--pkgs/development/libraries/libxc/default.nix32
-rw-r--r--pkgs/development/libraries/libxcomp/default.nix10
-rw-r--r--pkgs/development/libraries/libxkbcommon/default.nix33
-rw-r--r--pkgs/development/libraries/libxl/default.nix26
-rw-r--r--pkgs/development/libraries/libxls/default.nix2
-rw-r--r--pkgs/development/libraries/libxml2/default.nix7
-rw-r--r--pkgs/development/libraries/libxmlxx/default.nix2
-rw-r--r--pkgs/development/libraries/libxmlxx/v3.nix2
-rw-r--r--pkgs/development/libraries/libxmp/default.nix4
-rw-r--r--pkgs/development/libraries/libxslt/default.nix24
-rw-r--r--pkgs/development/libraries/libyaml-cpp/default.nix12
-rw-r--r--pkgs/development/libraries/libyubikey/default.nix2
-rw-r--r--pkgs/development/libraries/libzdb/default.nix8
-rw-r--r--pkgs/development/libraries/libzen/default.nix6
-rw-r--r--pkgs/development/libraries/libzip/default.nix8
-rw-r--r--pkgs/development/libraries/libzmf/default.nix4
-rw-r--r--pkgs/development/libraries/lightning/default.nix5
-rw-r--r--pkgs/development/libraries/lightstep-tracer-cpp/default.nix3
-rw-r--r--pkgs/development/libraries/liquidfun/default.nix4
-rw-r--r--pkgs/development/libraries/lirc/default.nix36
-rw-r--r--pkgs/development/libraries/live555/default.nix11
-rw-r--r--pkgs/development/libraries/lmdb/default.nix7
-rw-r--r--pkgs/development/libraries/lmdb/hardcoded-compiler.patch26
-rw-r--r--pkgs/development/libraries/log4cpp/default.nix4
-rw-r--r--pkgs/development/libraries/log4cxx/default.nix2
-rw-r--r--pkgs/development/libraries/luaffi/darwin.patch17
-rw-r--r--pkgs/development/libraries/luaffi/default.nix6
-rw-r--r--pkgs/development/libraries/lzo/default.nix3
-rw-r--r--pkgs/development/libraries/mailcore2/default.nix4
-rw-r--r--pkgs/development/libraries/matio/default.nix4
-rw-r--r--pkgs/development/libraries/mbedtls/darwin_dylib.patch28
-rw-r--r--pkgs/development/libraries/mbedtls/default.nix36
-rw-r--r--pkgs/development/libraries/mdds/default.nix4
-rw-r--r--pkgs/development/libraries/mediastreamer/default.nix19
-rw-r--r--pkgs/development/libraries/menu-cache/default.nix4
-rw-r--r--pkgs/development/libraries/mesa-glu/default.nix7
-rw-r--r--pkgs/development/libraries/mesa/default.nix94
-rw-r--r--pkgs/development/libraries/mesa/missing-include.patch11
-rw-r--r--pkgs/development/libraries/microsoft_gsl/default.nix22
-rw-r--r--pkgs/development/libraries/mimetic/default.nix2
-rw-r--r--pkgs/development/libraries/mlt/default.nix6
-rw-r--r--pkgs/development/libraries/mlt/qt-5.nix20
-rw-r--r--pkgs/development/libraries/mongoc/default.nix6
-rw-r--r--pkgs/development/libraries/movit/default.nix2
-rw-r--r--pkgs/development/libraries/mp4v2/default.nix20
-rw-r--r--pkgs/development/libraries/mpfr/default.nix12
-rw-r--r--pkgs/development/libraries/mpfr/upstream.patch1699
-rw-r--r--pkgs/development/libraries/mpich2/default.nix40
-rw-r--r--pkgs/development/libraries/mps/default.nix10
-rw-r--r--pkgs/development/libraries/msilbc/default.nix4
-rw-r--r--pkgs/development/libraries/mygui/default.nix4
-rw-r--r--pkgs/development/libraries/mysocketw/default.nix11
-rw-r--r--pkgs/development/libraries/nanoflann/default.nix4
-rw-r--r--pkgs/development/libraries/nanomsg/default.nix4
-rw-r--r--pkgs/development/libraries/ncurses/default.nix29
-rw-r--r--pkgs/development/libraries/ncurses/gcc-5.patch46
-rw-r--r--pkgs/development/libraries/ndn-cxx/default.nix1
-rw-r--r--pkgs/development/libraries/ndpi/default.nix2
-rw-r--r--pkgs/development/libraries/netcdf-cxx4/default.nix6
-rw-r--r--pkgs/development/libraries/netcdf-fortran/default.nix6
-rw-r--r--pkgs/development/libraries/netcdf/default.nix41
-rw-r--r--pkgs/development/libraries/nettle/default.nix4
-rw-r--r--pkgs/development/libraries/nettle/generic.nix5
-rw-r--r--pkgs/development/libraries/newt/default.nix6
-rw-r--r--pkgs/development/libraries/nix-plugins/default.nix10
-rw-r--r--pkgs/development/libraries/nlohmann_json/default.nix4
-rw-r--r--pkgs/development/libraries/npth/default.nix6
-rw-r--r--pkgs/development/libraries/nspr/default.nix7
-rw-r--r--pkgs/development/libraries/nss/85_security_load.patch8
-rw-r--r--pkgs/development/libraries/nss/ckpem.patch11
-rw-r--r--pkgs/development/libraries/nss/default.nix42
-rw-r--r--pkgs/development/libraries/nss_wrapper/default.nix4
-rw-r--r--pkgs/development/libraries/ntbtls/default.nix11
-rw-r--r--pkgs/development/libraries/ocl-icd/default.nix10
-rw-r--r--pkgs/development/libraries/ogre/1.9.x.nix46
-rw-r--r--pkgs/development/libraries/ogre/default.nix12
-rw-r--r--pkgs/development/libraries/ogrepaged/default.nix19
-rw-r--r--pkgs/development/libraries/oniguruma/default.nix4
-rw-r--r--pkgs/development/libraries/openal-soft/default.nix4
-rw-r--r--pkgs/development/libraries/openbsm/default.nix20
-rw-r--r--pkgs/development/libraries/opencascade/default.nix10
-rw-r--r--pkgs/development/libraries/opencl-headers/default.nix14
-rw-r--r--pkgs/development/libraries/opencollada/default.nix17
-rw-r--r--pkgs/development/libraries/opencolorio/default.nix8
-rw-r--r--pkgs/development/libraries/opencsg/default.nix8
-rw-r--r--pkgs/development/libraries/opencv/3.x.nix105
-rw-r--r--pkgs/development/libraries/opencv/default.nix2
-rw-r--r--pkgs/development/libraries/opendbx/default.nix6
-rw-r--r--pkgs/development/libraries/opendht/default.nix4
-rw-r--r--pkgs/development/libraries/openexr/default.nix10
-rw-r--r--pkgs/development/libraries/openexrid-unstable/default.nix11
-rw-r--r--pkgs/development/libraries/openfst/default.nix4
-rw-r--r--pkgs/development/libraries/openjpeg/2.1.nix37
-rw-r--r--pkgs/development/libraries/openjpeg/CVE-2016-9580-and-CVE-2016-9581.patch242
-rw-r--r--pkgs/development/libraries/openldap/default.nix2
-rw-r--r--pkgs/development/libraries/openmpi/default.nix44
-rw-r--r--pkgs/development/libraries/openpam/default.nix18
-rw-r--r--pkgs/development/libraries/opensaml-cpp/default.nix6
-rw-r--r--pkgs/development/libraries/openslp/CVE-2016-4912.patch11
-rw-r--r--pkgs/development/libraries/openslp/default.nix1
-rw-r--r--pkgs/development/libraries/openssl/default.nix66
-rw-r--r--pkgs/development/libraries/opensubdiv/default.nix22
-rw-r--r--pkgs/development/libraries/openvdb/default.nix8
-rw-r--r--pkgs/development/libraries/openwsman/default.nix37
-rw-r--r--pkgs/development/libraries/openzwave/default.nix56
-rw-r--r--pkgs/development/libraries/oracle-instantclient/default.nix36
-rw-r--r--pkgs/development/libraries/ortp/default.nix4
-rw-r--r--pkgs/development/libraries/osm-gps-map/default.nix2
-rw-r--r--pkgs/development/libraries/p11-kit/default.nix4
-rw-r--r--pkgs/development/libraries/pango/default.nix8
-rw-r--r--pkgs/development/libraries/pangolin/default.nix4
-rw-r--r--pkgs/development/libraries/parquet-cpp/default.nix37
-rw-r--r--pkgs/development/libraries/partio/default.nix25
-rw-r--r--pkgs/development/libraries/pcre/default.nix10
-rw-r--r--pkgs/development/libraries/pcre/stacksize-detection.patch16
-rw-r--r--pkgs/development/libraries/pcre2/default.nix11
-rw-r--r--pkgs/development/libraries/phonon/default.nix4
-rw-r--r--pkgs/development/libraries/physfs/default.nix50
-rw-r--r--pkgs/development/libraries/physics/fastjet/default.nix19
-rw-r--r--pkgs/development/libraries/physics/geant4/default.nix8
-rw-r--r--pkgs/development/libraries/physics/herwig/default.nix4
-rw-r--r--pkgs/development/libraries/physics/lhapdf/default.nix4
-rw-r--r--pkgs/development/libraries/physics/pythia/default.nix4
-rw-r--r--pkgs/development/libraries/physics/rivet/default.nix19
-rw-r--r--pkgs/development/libraries/physics/thepeg/default.nix4
-rw-r--r--pkgs/development/libraries/physics/yoda/default.nix7
-rw-r--r--pkgs/development/libraries/pipewire/default.nix50
-rw-r--r--pkgs/development/libraries/pixman/default.nix17
-rw-r--r--pkgs/development/libraries/pkcs11helper/default.nix8
-rw-r--r--pkgs/development/libraries/plib/default.nix4
-rw-r--r--pkgs/development/libraries/png++/default.nix14
-rw-r--r--pkgs/development/libraries/poco/default.nix9
-rw-r--r--pkgs/development/libraries/polkit/default.nix20
-rw-r--r--pkgs/development/libraries/poppler/0.61.nix56
-rw-r--r--pkgs/development/libraries/poppler/default.nix48
-rw-r--r--pkgs/development/libraries/poppler/qt4.nix44
-rw-r--r--pkgs/development/libraries/postgis/default.nix192
-rw-r--r--pkgs/development/libraries/postgis/pg_db_postgis_enable.sh38
-rw-r--r--pkgs/development/libraries/postgis/pg_db_postgis_fix_or_load_sql_dump.sh52
-rw-r--r--pkgs/development/libraries/ppl/default.nix8
-rw-r--r--pkgs/development/libraries/protobuf/2.5.nix10
-rw-r--r--pkgs/development/libraries/protobuf/3.4.nix4
-rw-r--r--pkgs/development/libraries/protobuf/3.5.nix6
-rw-r--r--pkgs/development/libraries/protobufc/generic.nix2
-rw-r--r--pkgs/development/libraries/psol/default.nix4
-rw-r--r--pkgs/development/libraries/psol/generic.nix2
-rw-r--r--pkgs/development/libraries/ptex/default.nix4
-rw-r--r--pkgs/development/libraries/ptlib/default.nix12
-rw-r--r--pkgs/development/libraries/ptlib/ptlib-2.10.11-glibc-2.26.patch13
-rw-r--r--pkgs/development/libraries/pugixml/default.nix4
-rw-r--r--pkgs/development/libraries/qca-qt5/default.nix18
-rw-r--r--pkgs/development/libraries/qca-qt5/move-project.patch19
-rw-r--r--pkgs/development/libraries/qca2/default.nix12
-rw-r--r--pkgs/development/libraries/qmlbox2d/default.nix31
-rw-r--r--pkgs/development/libraries/qmltermwidget/default.nix9
-rw-r--r--pkgs/development/libraries/qoauth/default.nix6
-rw-r--r--pkgs/development/libraries/qpdf/default.nix10
-rw-r--r--pkgs/development/libraries/qscintilla/default.nix38
-rw-r--r--pkgs/development/libraries/qt-3/default.nix8
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/clang-5-darwin.patch13
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/default.nix106
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/dlopen-absolute-paths.diff26
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/parallel-configure.patch22
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/patch-qthread-stacksize.diff54
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/qmake-hook.sh5
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/qsettings-recursive-global-mutex.patch17
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/qt-4.8.7-unixmake-darwin.patch11
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/qt-musl-iconv-no-bom.patch11
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/qt-musl.patch14
-rw-r--r--pkgs/development/libraries/qt-5/5.10/default.nix128
-rw-r--r--pkgs/development/libraries/qt-5/5.10/fetch.sh2
-rw-r--r--pkgs/development/libraries/qt-5/5.10/qtbase-darwin.patch70
-rw-r--r--pkgs/development/libraries/qt-5/5.10/qtbase.patch1152
-rw-r--r--pkgs/development/libraries/qt-5/5.10/qtdeclarative.patch33
-rw-r--r--pkgs/development/libraries/qt-5/5.10/qtscript.patch (renamed from pkgs/development/libraries/qt-5/5.6/qtscript/0001-glib-2.32.patch)12
-rw-r--r--pkgs/development/libraries/qt-5/5.10/qtserialport.patch (renamed from pkgs/development/libraries/qt-5/5.9/qtserialport/qtserialport-dlopen-udev.patch)10
-rw-r--r--pkgs/development/libraries/qt-5/5.10/qttools.patch71
-rw-r--r--pkgs/development/libraries/qt-5/5.10/qtwebengine-paxmark-mksnapshot.patch48
-rw-r--r--pkgs/development/libraries/qt-5/5.10/qtwebkit.patch77
-rw-r--r--pkgs/development/libraries/qt-5/5.10/restore-pc-files.patch27
-rw-r--r--pkgs/development/libraries/qt-5/5.10/srcs.nix341
-rw-r--r--pkgs/development/libraries/qt-5/5.6/default.nix135
-rw-r--r--pkgs/development/libraries/qt-5/5.6/fetch.sh4
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase.patch795
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/cmake-paths-darwin.patch384
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/cmake-paths.patch385
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/compose-search-path.patch16
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/decrypt-ssl-traffic.patch13
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/default.nix325
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-dbus.patch13
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-gl.patch17
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-libXcursor.patch17
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-openssl.patch26
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-resolv.patch26
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/library-paths.patch20
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/libressl.patch33
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/mkspecs-libgl.patch15
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/qpa-platform-plugin-path.patch43
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/series9
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/tzdir.patch40
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/xdg-config-dirs.patch42
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtconnectivity.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtdeclarative.patch (renamed from pkgs/development/libraries/qt-5/5.9/qtdeclarative/import-paths.patch)10
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtdeclarative/default.nix12
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtdeclarative/import-paths.patch20
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtdeclarative/series1
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtdoc.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtenginio.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtlocation.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtmultimedia.nix13
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtquickcontrols.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtquickcontrols2.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtscript.patch (renamed from pkgs/development/libraries/qt-5/5.9/qtscript/0001-glib-2.32.patch)12
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtscript/default.nix7
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtsensors.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtserialport.patch (renamed from pkgs/development/libraries/qt-5/5.6/qtserialport/qtserialport-dlopen-udev.patch)10
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtserialport/series1
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtsvg.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qttools.patch64
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qttools/cmake-paths.patch72
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qttools/default.nix12
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qttools/series1
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebchannel.nix7
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebengine-paxmark-mksnapshot.patch (renamed from pkgs/development/libraries/qt-5/5.6/qtwebengine/qtwebengine-paxmark-mksnapshot.patch)0
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebengine-seccomp.patch24
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebengine/chromium-clang-update-py.patch874
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebengine/default.nix90
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebkit.patch (renamed from pkgs/development/libraries/qt-5/5.6/qtwebkit/qtwebkit-icu-59.patch)99
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebkit/0001-dlopen-webkit-nsplugin.patch53
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebkit/0002-dlopen-webkit-gtk.patch25
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebkit/0003-dlopen-webkit-udev.patch31
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebkit/default.nix40
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebkit/qtwebkit-dlopen-gtk.patch64
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebkit/qtwebkit-dlopen-udev.patch0
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebkit/qtwebkit-icucore-darwin.patch13
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebkit/series4
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebsockets.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtx11extras.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtxmlpatterns.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.6/srcs.nix304
-rw-r--r--pkgs/development/libraries/qt-5/5.9/default.nix148
-rw-r--r--pkgs/development/libraries/qt-5/5.9/fetch.sh2
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase-darwin.patch (renamed from pkgs/development/libraries/qt-5/5.9/qtbase/darwin-cf.patch)16
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase.patch1141
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase/cmake-paths.patch359
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase/compose-search-path.patch18
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase/darwin-series3
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase/default.nix366
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase/dlopen-gl.patch19
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase/dlopen-gtkstyle.patch50
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase/dlopen-libXcursor.patch17
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase/dlopen-resolv.patch26
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase/library-paths.patch20
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase/libressl.patch33
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase/mkspecs-common-mac.patch11
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase/mkspecs-features-mac.patch292
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase/qgtk-env.patch36
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase/qnativesocketengine-type-pun.patch14
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase/series9
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase/tzdir.patch39
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtcharts.nix10
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtconnectivity.nix10
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtdeclarative.patch33
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtdeclarative/default.nix20
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtdeclarative/series1
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtgraphicaleffects.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtimageformats.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtlocation.nix13
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtquickcontrols2.nix10
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtscript.patch13
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtscript/default.nix7
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtsensors.nix13
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtserialport.patch (renamed from pkgs/development/libraries/qt-5/5.6/qtserialport/0001-dlopen-serialport-udev.patch)26
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtserialport/default.nix12
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtserialport/series1
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtsvg.nix10
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qttools.patch71
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qttools/cmake-paths.patch88
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qttools/default.nix16
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qttools/series1
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qttranslations.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtwayland.nix13
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtwebchannel.nix11
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtwebengine-paxmark-mksnapshot.patch (renamed from pkgs/development/libraries/qt-5/5.9/qtwebengine/qtwebengine-paxmark-mksnapshot.patch)0
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtwebkit.patch77
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtwebkit/qtwebkit-dlopen-gtk.patch64
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtwebkit/qtwebkit-dlopen-udev.patch0
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtwebkit/qtwebkit-icucore-darwin.patch13
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtwebkit/series3
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtwebsockets.nix10
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtxmlpatterns.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.9/srcs.nix320
-rw-r--r--pkgs/development/libraries/qt-5/README.md81
-rw-r--r--pkgs/development/libraries/qt-5/hooks/fix-qt-builtin-paths.sh64
-rw-r--r--pkgs/development/libraries/qt-5/hooks/fix-qt-module-paths.sh36
-rw-r--r--pkgs/development/libraries/qt-5/hooks/move-qt-dev-tools.sh34
-rw-r--r--pkgs/development/libraries/qt-5/hooks/qmake-hook.sh23
-rw-r--r--pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh64
-rw-r--r--pkgs/development/libraries/qt-5/hooks/qttools-setup-hook.sh1
-rw-r--r--pkgs/development/libraries/qt-5/mkDerivation.nix32
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtbase.nix405
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtcharts.nix7
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtconnectivity.nix8
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtdeclarative.nix25
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtdoc.nix (renamed from pkgs/development/libraries/qt-5/5.9/qtdoc.nix)4
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtgraphicaleffects.nix (renamed from pkgs/development/libraries/qt-5/5.6/qtgraphicaleffects.nix)5
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtimageformats.nix (renamed from pkgs/development/libraries/qt-5/5.6/qtimageformats.nix)4
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtlocation.nix16
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtmacextras.nix (renamed from pkgs/development/libraries/qt-5/5.9/qtmacextras.nix)4
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtmultimedia.nix (renamed from pkgs/development/libraries/qt-5/5.9/qtmultimedia.nix)8
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtquickcontrols.nix (renamed from pkgs/development/libraries/qt-5/5.9/qtquickcontrols.nix)4
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtquickcontrols2.nix7
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtscript.nix6
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtsensors.nix7
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtserialport.nix (renamed from pkgs/development/libraries/qt-5/5.6/qtserialport/default.nix)5
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtspeech.nix7
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtsvg.nix7
-rw-r--r--pkgs/development/libraries/qt-5/modules/qttools.nix36
-rw-r--r--pkgs/development/libraries/qt-5/modules/qttranslations.nix (renamed from pkgs/development/libraries/qt-5/5.6/qttranslations.nix)4
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtvirtualkeyboard.nix6
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtwayland.nix (renamed from pkgs/development/libraries/qt-5/5.6/qtwayland.nix)5
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtwebchannel.nix8
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtwebengine.nix (renamed from pkgs/development/libraries/qt-5/5.9/qtwebengine/default.nix)31
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtwebkit.nix (renamed from pkgs/development/libraries/qt-5/5.9/qtwebkit/default.nix)18
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtwebsockets.nix7
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtx11extras.nix (renamed from pkgs/development/libraries/qt-5/5.9/qtx11extras.nix)4
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtxmlpatterns.nix7
-rw-r--r--pkgs/development/libraries/qt-5/qmake-hook.sh47
-rw-r--r--pkgs/development/libraries/qt-5/qt-env.nix6
-rw-r--r--pkgs/development/libraries/qt-5/qtModule.nix59
-rw-r--r--pkgs/development/libraries/qt-5/qtbase-setup-hook-darwin.sh192
-rw-r--r--pkgs/development/libraries/qt-5/qtbase-setup-hook.sh155
-rw-r--r--pkgs/development/libraries/qt-5/qtsubmodule-setup-hook.sh2
-rw-r--r--pkgs/development/libraries/qtkeychain/default.nix22
-rw-r--r--pkgs/development/libraries/qtscriptgenerator/qt-4.8.patch2
-rw-r--r--pkgs/development/libraries/qtstyleplugin-kvantum-qt4/default.nix38
-rw-r--r--pkgs/development/libraries/qtstyleplugin-kvantum/default.nix32
-rw-r--r--pkgs/development/libraries/qtstyleplugins/default.nix5
-rw-r--r--pkgs/development/libraries/quazip/default.nix4
-rw-r--r--pkgs/development/libraries/quesoglc/default.nix4
-rw-r--r--pkgs/development/libraries/quickder/default.nix53
-rw-r--r--pkgs/development/libraries/qwt/6.nix2
-rw-r--r--pkgs/development/libraries/qwt/6_qt4.nix20
-rw-r--r--pkgs/development/libraries/qwt/default.nix2
-rw-r--r--pkgs/development/libraries/rabbitmq-c/default.nix6
-rw-r--r--pkgs/development/libraries/range-v3/default.nix19
-rw-r--r--pkgs/development/libraries/rapidjson/default.nix7
-rw-r--r--pkgs/development/libraries/rdkafka/default.nix10
-rw-r--r--pkgs/development/libraries/readline/6.3.nix6
-rw-r--r--pkgs/development/libraries/readosm/default.nix4
-rw-r--r--pkgs/development/libraries/rep-gtk/setup-hook.sh2
-rw-r--r--pkgs/development/libraries/resolv_wrapper/default.nix4
-rw-r--r--pkgs/development/libraries/rocksdb/default.nix36
-rw-r--r--pkgs/development/libraries/rote/default.nix1
-rw-r--r--pkgs/development/libraries/safefile/default.nix4
-rw-r--r--pkgs/development/libraries/sblim-sfcc/default.nix34
-rw-r--r--pkgs/development/libraries/schroedinger/default.nix2
-rw-r--r--pkgs/development/libraries/science/biology/EBTKS/default.nix28
-rw-r--r--pkgs/development/libraries/science/biology/bicpl/default.nix33
-rw-r--r--pkgs/development/libraries/science/biology/elastix/default.nix18
-rw-r--r--pkgs/development/libraries/science/biology/htslib/default.nix4
-rw-r--r--pkgs/development/libraries/science/biology/oobicpl/default.nix31
-rw-r--r--pkgs/development/libraries/science/math/arpack/default.nix8
-rw-r--r--pkgs/development/libraries/science/math/atlas/default.nix6
-rw-r--r--pkgs/development/libraries/science/math/blas/default.nix4
-rw-r--r--pkgs/development/libraries/science/math/caffe2/default.nix144
-rw-r--r--pkgs/development/libraries/science/math/caffe2/fix_compilation_on_gcc7.patch46
-rw-r--r--pkgs/development/libraries/science/math/caffe2/update_clang_cvtsh_bugfix.patch55
-rw-r--r--pkgs/development/libraries/science/math/clblas/default.nix17
-rw-r--r--pkgs/development/libraries/science/math/cliquer/default.nix38
-rw-r--r--pkgs/development/libraries/science/math/cudnn/default.nix8
-rw-r--r--pkgs/development/libraries/science/math/cudnn/generic.nix2
-rw-r--r--pkgs/development/libraries/science/math/fenics/default.nix2
-rw-r--r--pkgs/development/libraries/science/math/flintqs/default.nix40
-rw-r--r--pkgs/development/libraries/science/math/ipopt/default.nix4
-rw-r--r--pkgs/development/libraries/science/math/lcalc/default.nix78
-rw-r--r--pkgs/development/libraries/science/math/lcalc/makefile.patch113
-rw-r--r--pkgs/development/libraries/science/math/m4ri/default.nix30
-rw-r--r--pkgs/development/libraries/science/math/m4rie/default.nix39
-rw-r--r--pkgs/development/libraries/science/math/nccl/default.nix24
-rw-r--r--pkgs/development/libraries/science/math/nccl/generic.nix57
-rw-r--r--pkgs/development/libraries/science/math/openblas/default.nix29
-rw-r--r--pkgs/development/libraries/science/math/openlibm/default.nix4
-rw-r--r--pkgs/development/libraries/science/math/openspecfun/default.nix6
-rw-r--r--pkgs/development/libraries/science/math/petsc/default.nix9
-rw-r--r--pkgs/development/libraries/science/math/planarity/default.nix40
-rw-r--r--pkgs/development/libraries/science/math/rubiks/default.nix82
-rw-r--r--pkgs/development/libraries/science/math/sympow/default.nix89
-rw-r--r--pkgs/development/libraries/science/networking/ns3/default.nix98
-rw-r--r--pkgs/development/libraries/serd/default.nix15
-rw-r--r--pkgs/development/libraries/serf/default.nix2
-rw-r--r--pkgs/development/libraries/shapelib/default.nix4
-rw-r--r--pkgs/development/libraries/shibboleth-sp/default.nix6
-rw-r--r--pkgs/development/libraries/simgear/default.nix4
-rw-r--r--pkgs/development/libraries/skalibs/default.nix4
-rw-r--r--pkgs/development/libraries/slib/setup-hook.sh2
-rw-r--r--pkgs/development/libraries/smpeg/default.nix4
-rw-r--r--pkgs/development/libraries/smpeg2/default.nix7
-rw-r--r--pkgs/development/libraries/snappy/default.nix27
-rw-r--r--pkgs/development/libraries/snappy/disable-benchmark.patch5
-rw-r--r--pkgs/development/libraries/socket_wrapper/default.nix4
-rw-r--r--pkgs/development/libraries/sord/default.nix4
-rw-r--r--pkgs/development/libraries/soundtouch/default.nix4
-rw-r--r--pkgs/development/libraries/speech-tools/default.nix21
-rw-r--r--pkgs/development/libraries/speechd/default.nix72
-rw-r--r--pkgs/development/libraries/speex/default.nix2
-rw-r--r--pkgs/development/libraries/spice-gtk/default.nix54
-rw-r--r--pkgs/development/libraries/spice/default.nix8
-rw-r--r--pkgs/development/libraries/sqlcipher/default.nix4
-rw-r--r--pkgs/development/libraries/sqlite/default.nix8
-rw-r--r--pkgs/development/libraries/sqlite/sqlite3_analyzer.nix6
-rw-r--r--pkgs/development/libraries/srtp/default.nix4
-rw-r--r--pkgs/development/libraries/stfl/default.nix8
-rw-r--r--pkgs/development/libraries/stlport/default.nix2
-rw-r--r--pkgs/development/libraries/sundials/default.nix28
-rw-r--r--pkgs/development/libraries/swc/default.nix34
-rw-r--r--pkgs/development/libraries/swiften/default.nix4
-rw-r--r--pkgs/development/libraries/tachyon/default.nix57
-rw-r--r--pkgs/development/libraries/tachyon/make-archs.patch37
-rw-r--r--pkgs/development/libraries/tachyon/no-absolute-paths.patch57
-rw-r--r--pkgs/development/libraries/taglib/1.9.nix3
-rw-r--r--pkgs/development/libraries/taglib/default.nix38
-rw-r--r--pkgs/development/libraries/talloc/default.nix4
-rw-r--r--pkgs/development/libraries/tbb/default.nix2
-rw-r--r--pkgs/development/libraries/tbb/glibc-struct-mallinfo.patch43
-rw-r--r--pkgs/development/libraries/tclap/default.nix4
-rw-r--r--pkgs/development/libraries/tcllib/default.nix4
-rw-r--r--pkgs/development/libraries/tdb/default.nix4
-rw-r--r--pkgs/development/libraries/telepathy/farstream/default.nix4
-rw-r--r--pkgs/development/libraries/telepathy/glib/default.nix4
-rw-r--r--pkgs/development/libraries/telepathy/qt/default.nix62
-rw-r--r--pkgs/development/libraries/tevent/default.nix4
-rw-r--r--pkgs/development/libraries/theft/default.nix2
-rw-r--r--pkgs/development/libraries/thrift/default.nix4
-rw-r--r--pkgs/development/libraries/ti-rpc/default.nix16
-rw-r--r--pkgs/development/libraries/tinyxml-2/default.nix4
-rw-r--r--pkgs/development/libraries/tnt/default.nix4
-rw-r--r--pkgs/development/libraries/tntdb/default.nix2
-rw-r--r--pkgs/development/libraries/tremor/default.nix14
-rw-r--r--pkgs/development/libraries/udunits/default.nix6
-rw-r--r--pkgs/development/libraries/uhttpmock/default.nix4
-rw-r--r--pkgs/development/libraries/uid_wrapper/default.nix4
-rw-r--r--pkgs/development/libraries/umockdev/default.nix21
-rw-r--r--pkgs/development/libraries/unibilium/default.nix8
-rw-r--r--pkgs/development/libraries/unicorn-emu/default.nix26
-rw-r--r--pkgs/development/libraries/unittest-cpp/default.nix4
-rw-r--r--pkgs/development/libraries/unixODBC/default.nix4
-rw-r--r--pkgs/development/libraries/unixODBCDrivers/default.nix16
-rw-r--r--pkgs/development/libraries/uriparser/default.nix4
-rw-r--r--pkgs/development/libraries/usbredir/default.nix3
-rw-r--r--pkgs/development/libraries/v8/default.nix22
-rw-r--r--pkgs/development/libraries/vaapi-intel/default.nix22
-rw-r--r--pkgs/development/libraries/vaapi-vdpau/default.nix6
-rw-r--r--pkgs/development/libraries/vapoursynth/default.nix10
-rw-r--r--pkgs/development/libraries/vc/default.nix4
-rw-r--r--pkgs/development/libraries/vcdimager/default.nix15
-rw-r--r--pkgs/development/libraries/vigra/default.nix4
-rw-r--r--pkgs/development/libraries/virglrenderer/default.nix31
-rw-r--r--pkgs/development/libraries/vmime/default.nix2
-rw-r--r--pkgs/development/libraries/vmmlib/default.nix2
-rw-r--r--pkgs/development/libraries/vo-amrwbenc/default.nix22
-rw-r--r--pkgs/development/libraries/vrpn/default.nix4
-rw-r--r--pkgs/development/libraries/vtk/default.nix4
-rw-r--r--pkgs/development/libraries/vulkan-loader/default.nix26
-rw-r--r--pkgs/development/libraries/vulkan-loader/rev-file.patch21
-rw-r--r--pkgs/development/libraries/wayland/default.nix8
-rw-r--r--pkgs/development/libraries/wayland/protocols.nix4
-rw-r--r--pkgs/development/libraries/wcslib/default.nix4
-rw-r--r--pkgs/development/libraries/webkitgtk/2.18.nix103
-rw-r--r--pkgs/development/libraries/webkitgtk/2.20.nix89
-rw-r--r--pkgs/development/libraries/webkitgtk/2.4.nix2
-rw-r--r--pkgs/development/libraries/webkitgtk/PR-152650-2.patch62
-rw-r--r--pkgs/development/libraries/webkitgtk/PR-153138.patch26
-rw-r--r--pkgs/development/libraries/webkitgtk/PR-157554.patch33
-rw-r--r--pkgs/development/libraries/webkitgtk/PR-157574.patch62
-rw-r--r--pkgs/development/libraries/webkitgtk/finding-harfbuzz-icu.patch52
-rw-r--r--pkgs/development/libraries/webkitgtk/fix-execinfo.patch20
-rw-r--r--pkgs/development/libraries/webkitgtk/gstreamergl-2.17.patch13
-rw-r--r--pkgs/development/libraries/webrtc-audio-processing/default.nix2
-rw-r--r--pkgs/development/libraries/websocket++/default.nix2
-rw-r--r--pkgs/development/libraries/wildmidi/default.nix4
-rw-r--r--pkgs/development/libraries/wiredtiger/default.nix3
-rw-r--r--pkgs/development/libraries/wlc/default.nix28
-rw-r--r--pkgs/development/libraries/wld/default.nix30
-rw-r--r--pkgs/development/libraries/wlroots/default.nix32
-rw-r--r--pkgs/development/libraries/wlroots/libdrm.patch9
-rw-r--r--pkgs/development/libraries/wlroots/no-werror.patch10
-rw-r--r--pkgs/development/libraries/wolfssl/default.nix4
-rw-r--r--pkgs/development/libraries/wt/default.nix74
-rw-r--r--pkgs/development/libraries/wxSVG/default.nix4
-rw-r--r--pkgs/development/libraries/wxsqlite3/default.nix2
-rw-r--r--pkgs/development/libraries/wxwidgets/2.8/default.nix8
-rw-r--r--pkgs/development/libraries/wxwidgets/2.9/default.nix8
-rw-r--r--pkgs/development/libraries/wxwidgets/3.0/default.nix14
-rw-r--r--pkgs/development/libraries/wxwidgets/3.1/default.nix16
-rw-r--r--pkgs/development/libraries/x265/default.nix4
-rw-r--r--pkgs/development/libraries/xalanc/default.nix5
-rw-r--r--pkgs/development/libraries/xapian/default.nix4
-rw-r--r--pkgs/development/libraries/xapian/tools/omega/default.nix2
-rw-r--r--pkgs/development/libraries/xcb-util-cursor/HEAD.nix4
-rw-r--r--pkgs/development/libraries/xercesc/default.nix4
-rw-r--r--pkgs/development/libraries/xgboost/default.nix33
-rw-r--r--pkgs/development/libraries/xine-lib/default.nix8
-rw-r--r--pkgs/development/libraries/xlslib/default.nix2
-rw-r--r--pkgs/development/libraries/xml-tooling-c/default.nix6
-rw-r--r--pkgs/development/libraries/xmlrpc-c/default.nix6
-rw-r--r--pkgs/development/libraries/xvidcore/default.nix8
-rw-r--r--pkgs/development/libraries/xxHash/default.nix6
-rw-r--r--pkgs/development/libraries/yajl/default.nix4
-rw-r--r--pkgs/development/libraries/zeitgeist/dbus_glib.patch10
-rw-r--r--pkgs/development/libraries/zeitgeist/default.nix29
-rw-r--r--pkgs/development/libraries/zeromq/4.x.nix4
-rw-r--r--pkgs/development/libraries/zimg/default.nix4
-rw-r--r--pkgs/development/libraries/zlib/default.nix2
-rw-r--r--pkgs/development/libraries/zlog/default.nix2
-rw-r--r--pkgs/development/libraries/zxcvbn-c/default.nix24
-rw-r--r--pkgs/development/libraries/zziplib/default.nix17
1213 files changed, 18062 insertions, 14137 deletions
diff --git a/pkgs/development/libraries/AntTweakBar/default.nix b/pkgs/development/libraries/AntTweakBar/default.nix
new file mode 100644
index 000000000000..fcb708c829be
--- /dev/null
+++ b/pkgs/development/libraries/AntTweakBar/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, unzip, xorg, libGLU_combined }:
+
+stdenv.mkDerivation rec {
+  name = "AntTweakBar-1.16";
+
+  buildInputs = [ unzip xorg.libX11 libGLU_combined ];
+
+  src = fetchurl {
+    url = "mirror://sourceforge/project/anttweakbar/AntTweakBar_116.zip";
+    sha256 = "0z3frxpzf54cjs07m6kg09p7nljhr7140f4pznwi7srwq4cvgkpv";
+  };
+
+  postPatch = "cd src";
+  installPhase = ''
+    mkdir -p $out/lib/
+    cp ../lib/{libAntTweakBar.so,libAntTweakBar.so.1,libAntTweakBar.a} $out/lib/
+    cp -r ../include $out/
+  '';
+
+  meta = {
+    description = "Add a light/intuitive GUI to OpenGL applications";
+    longDescription = ''
+      A small and easy-to-use C/C++ library that allows to quickly add a light
+      and intuitive graphical user interface into graphic applications based on OpenGL
+      (compatibility and core profiles), DirectX 9, DirectX 10 or DirectX 11
+      to interactively tweak parameters on-screen
+    '';
+    homepage = http://anttweakbar.sourceforge.net/;
+    license = stdenv.lib.licenses.zlib;
+    maintainers = [ stdenv.lib.maintainers.razvan ];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/CGAL/default.nix b/pkgs/development/libraries/CGAL/default.nix
index e4eb8d3ab2ec..cdb37a84c801 100644
--- a/pkgs/development/libraries/CGAL/default.nix
+++ b/pkgs/development/libraries/CGAL/default.nix
@@ -1,14 +1,14 @@
 { stdenv, fetchFromGitHub, cmake, boost, gmp, mpfr }:
 
 stdenv.mkDerivation rec {
-  version = "4.9";
+  version = "4.11.1";
   name = "cgal-" + version;
 
   src = fetchFromGitHub {
     owner = "CGAL";
     repo = "releases";
     rev = "CGAL-${version}";
-    sha256 = "044amgml1x5h17rpkck2azmxrmjvlzzykv71cjh5hlajsi88cid5";
+    sha256 = "04nn1lzsjdglzjygc72cq09xrvpqwwnbf6l0xz8bfwfp4x9g10jf";
   };
 
   # note: optional component libCGAL_ImageIO would need zlib and opengl;
diff --git a/pkgs/development/libraries/LASzip/default.nix b/pkgs/development/libraries/LASzip/default.nix
index df9d126ad719..384178d2c8df 100644
--- a/pkgs/development/libraries/LASzip/default.nix
+++ b/pkgs/development/libraries/LASzip/default.nix
@@ -16,6 +16,6 @@ stdenv.mkDerivation rec {
     homepage = http://www.laszip.org;
     license = stdenv.lib.licenses.lgpl2;
     maintainers = [ stdenv.lib.maintainers.michelk ];
-    platforms = stdenv.lib.platforms.linux;
+    platforms = stdenv.lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/SDL/default.nix b/pkgs/development/libraries/SDL/default.nix
index e71ad14b11fd..5e1c527eb8b5 100644
--- a/pkgs/development/libraries/SDL/default.nix
+++ b/pkgs/development/libraries/SDL/default.nix
@@ -1,5 +1,5 @@
-{ stdenv, fetchurl, fetchpatch, pkgconfig, audiofile, libcap
-, openglSupport ? false, mesa_noglu, mesa_glu
+{ stdenv, lib, fetchurl, fetchpatch, pkgconfig, audiofile, libcap, libiconv
+, openglSupport ? false, libGL, libGLU
 , alsaSupport ? true, alsaLib
 , x11Support ? hostPlatform == buildPlatform, libXext, libICE, libXrandr
 , pulseaudioSupport ? true, libpulseaudio
@@ -7,13 +7,32 @@
 , hostPlatform, buildPlatform
 }:
 
-# OSS is no longer supported, for it's much crappier than ALSA and
-# PulseAudio.
-assert hostPlatform.isLinux -> alsaSupport || pulseaudioSupport;
+# NOTE: When editing this expression see if the same change applies to
+# SDL2 expression too
+
+with lib;
+
+assert !stdenv.isDarwin -> alsaSupport || pulseaudioSupport;
+assert openglSupport -> (stdenv.isDarwin || x11Support && libGL != null && libGLU != null);
 
 let
-  inherit (stdenv.lib) optional optionals;
+
+  configureFlagsFun = attrs: [
+    "--disable-oss"
+    "--disable-video-x11-xme"
+    "--enable-rpath"
+  # Building without this fails on Darwin with
+  #
+  #   ./src/video/x11/SDL_x11sym.h:168:17: error: conflicting types for '_XData32'
+  #   SDL_X11_SYM(int,_XData32,(Display *dpy,register long *data,unsigned len),(dpy,data,len),return)
+  #
+  # Please try revert the change that introduced this comment when updating SDL.
+  ] ++ optional stdenv.isDarwin "--disable-x11-shared"
+    ++ optional (!x11Support) "--without-x"
+    ++ optional alsaSupport "--with-alsa-prefix=${attrs.alsaLib.out}/lib";
+
 in
+
 stdenv.mkDerivation rec {
   name    = "SDL-${version}";
   version = "1.2.15";
@@ -23,40 +42,35 @@ stdenv.mkDerivation rec {
     sha256 = "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn";
   };
 
+  # make: *** No rule to make target 'build/*.lo', needed by 'build/libSDL.la'.  Stop.
+  postPatch = "patchShebangs ./configure";
+
   outputs = [ "out" "dev" ];
   outputBin = "dev"; # sdl-config
 
   nativeBuildInputs = [ pkgconfig ];
 
-  # Since `libpulse*.la' contain `-lgdbm', PulseAudio must be propagated.
-  propagatedBuildInputs =
-    optionals x11Support [ libXext libICE libXrandr ] ++
-    optional alsaSupport alsaLib ++
-    optional stdenv.isLinux libcap ++
-    optionals openglSupport [ mesa_noglu mesa_glu ] ++
-    optional pulseaudioSupport libpulseaudio ++
-    optional stdenv.isDarwin Cocoa;
-
-  buildInputs = let
-    notMingw = !hostPlatform.isMinGW;
-  in optional notMingw audiofile
-  ++ optionals stdenv.isDarwin [ OpenGL CoreAudio CoreServices AudioUnit Kernel ];
-
-  # XXX: By default, SDL wants to dlopen() PulseAudio, in which case
-  # we must arrange to add it to its RPATH; however, `patchelf' seems
-  # to fail at doing this, hence `--disable-pulseaudio-shared'.
-  configureFlags = [
-    "--disable-oss"
-    "--disable-video-x11-xme"
-    "--disable-x11-shared"
-    "--disable-alsa-shared"
-    "--enable-rpath"
-    "--disable-pulseaudio-shared"
-    "--disable-osmesa-shared"
-  ] ++ optional (!x11Support) "--without-x"
-    ++ optional (alsaSupport && hostPlatform != buildPlatform) "--with-alsa-prefix=${alsaLib.out}/lib";
+  propagatedBuildInputs = [ ]
+    ++ optionals x11Support [ libXext libICE libXrandr ]
+    ++ optional stdenv.isLinux libcap
+    ++ optionals openglSupport [ libGL libGLU ]
+    ++ optional alsaSupport alsaLib
+    ++ optional pulseaudioSupport libpulseaudio
+    ++ optional stdenv.isDarwin Cocoa;
+
+  buildInputs = [ libiconv ]
+    ++ optional (!hostPlatform.isMinGW) audiofile
+    ++ optionals stdenv.isDarwin [ AudioUnit CoreAudio CoreServices Kernel OpenGL ];
+
+  configureFlags = configureFlagsFun { inherit alsaLib; };
+
+  crossAttrs = {
+    configureFlags = configureFlagsFun { alsaLib = alsaLib.crossDrv; };
+  };
 
   patches = [
+    ./find-headers.patch
+
     # Fix window resizing issues, e.g. for xmonad
     # Ticket: http://bugzilla.libsdl.org/show_bug.cgi?id=1430
     (fetchpatch {
@@ -74,11 +88,16 @@ stdenv.mkDerivation rec {
       url = "http://hg.libsdl.org/SDL/raw-rev/95abff7adcc2";
       sha256 = "0i8x0kx0pw12ld5bfxhyzs466y3c0n9dscw1ijhq1b96r72xyhqq";
     })
+    # https://bugzilla.libsdl.org/show_bug.cgi?id=1769
+    (fetchpatch {
+      url = "http://hg.libsdl.org/SDL/raw-rev/91ad7b43317a";
+      sha256 = "15g537vbl2my4mfrjxfkcx9ri6bk2gjvaqj650rjdxwk2nkdkn4b";
+    })
     # Workaround X11 bug to allow changing gamma
     # Ticket: https://bugs.freedesktop.org/show_bug.cgi?id=27222
     (fetchpatch {
       name = "SDL_SetGamma.patch";
-      url = "http://pkgs.fedoraproject.org/cgit/rpms/SDL.git/plain/SDL-1.2.15-x11-Bypass-SetGammaRamp-when-changing-gamma.patch?id=04a3a7b1bd88c2d5502292fad27e0e02d084698d";
+      url = "http://src.fedoraproject.org/cgit/rpms/SDL.git/plain/SDL-1.2.15-x11-Bypass-SetGammaRamp-when-changing-gamma.patch?id=04a3a7b1bd88c2d5502292fad27e0e02d084698d";
       sha256 = "0x52s4328kilyq43i7psqkqg7chsfwh0aawr50j566nzd7j51dlv";
     })
     # Fix a build failure on OS X Mavericks
@@ -91,10 +110,20 @@ stdenv.mkDerivation rec {
       url = "http://hg.libsdl.org/SDL/raw-rev/bbfb41c13a87";
       sha256 = "1336g7waaf1c8yhkz11xbs500h8bmvabh4h437ax8l1xdwcppfxv";
     })
-    ./find-headers.patch
   ];
 
-  postFixup = ''moveToOutput share/aclocal "$dev" '';
+  postInstall = ''
+    moveToOutput share/aclocal "$dev"
+  '';
+
+  # See the same place in the expression for SDL2
+  postFixup = ''
+    for lib in $out/lib/*.so* ; do
+      if [[ -L "$lib" ]]; then
+        patchelf --set-rpath "$(patchelf --print-rpath $lib):${lib.makeLibraryPath propagatedBuildInputs}" "$lib"
+      fi
+    done
+  '';
 
   setupHook = ./setup-hook.sh;
 
diff --git a/pkgs/development/libraries/SDL/setup-hook.sh b/pkgs/development/libraries/SDL/setup-hook.sh
index 3696e743a07a..20382f18f529 100644
--- a/pkgs/development/libraries/SDL/setup-hook.sh
+++ b/pkgs/development/libraries/SDL/setup-hook.sh
@@ -4,8 +4,4 @@ addSDLPath () {
   fi
 }
 
-if test -n "$crossConfig"; then
-  crossEnvHooks+=(addSDLPath)
-else
-  envHooks+=(addSDLPath)
-fi
+addEnvHooks "$hostOffset" addSDLPath
diff --git a/pkgs/development/libraries/SDL2/default.nix b/pkgs/development/libraries/SDL2/default.nix
index 3216a130f671..fe19ecadd0ef 100644
--- a/pkgs/development/libraries/SDL2/default.nix
+++ b/pkgs/development/libraries/SDL2/default.nix
@@ -1,62 +1,66 @@
 { stdenv, lib, fetchurl, pkgconfig, audiofile
-, openglSupport ? false, mesa_noglu
+, openglSupport ? false, libGL
 , alsaSupport ? true, alsaLib
 , x11Support ? true, libICE, libXi, libXScrnSaver, libXcursor, libXinerama, libXext, libXxf86vm, libXrandr
+, waylandSupport ? true, wayland, wayland-protocols, libxkbcommon
 , dbusSupport ? false, dbus
 , udevSupport ? false, udev
 , ibusSupport ? false, ibus
 , pulseaudioSupport ? true, libpulseaudio
 , AudioUnit, Cocoa, CoreAudio, CoreServices, ForceFeedback, OpenGL
+, libiconv
 }:
 
-# OSS is no longer supported, for it's much crappier than ALSA and
-# PulseAudio.
-assert !stdenv.isDarwin -> alsaSupport || pulseaudioSupport;
+# NOTE: When editing this expression see if the same change applies to
+# SDL expression too
+
+with lib;
 
-assert openglSupport -> (stdenv.isDarwin || mesa_noglu != null && x11Support);
+assert !stdenv.isDarwin -> alsaSupport || pulseaudioSupport;
+assert openglSupport -> (stdenv.isDarwin || x11Support && libGL != null);
 
 let
+
   configureFlagsFun = attrs: [
-      "--disable-oss" "--disable-x11-shared"
-      "--disable-pulseaudio-shared" "--disable-alsa-shared"
-    ] ++ lib.optional alsaSupport "--with-alsa-prefix=${attrs.alsaLib.out}/lib"
-      ++ lib.optional (!x11Support) "--without-x";
+    "--disable-oss"
+  ] ++ optional (!x11Support) "--without-x"
+    ++ optional alsaSupport "--with-alsa-prefix=${attrs.alsaLib.out}/lib";
+
 in
+
 stdenv.mkDerivation rec {
   name = "SDL2-${version}";
-  version = "2.0.7";
+  version = "2.0.8";
 
   src = fetchurl {
     url = "http://www.libsdl.org/release/${name}.tar.gz";
-    sha256 = "0pjdpxla5kh1w1b0shxrx97a116vyy31njxi0jhyvqhk8d6cfdgf";
+    sha256 = "1v4js1gkr75hzbxzhwzzif0sf9g07234sd23x1vdaqc661bprizd";
   };
 
   outputs = [ "out" "dev" ];
+  outputBin = "dev"; # sdl-config
 
   patches = [ ./find-headers.patch ];
 
   nativeBuildInputs = [ pkgconfig ];
 
-  # Since `libpulse*.la' contain `-lgdbm', PulseAudio must be propagated.
-  propagatedBuildInputs = lib.optionals x11Support [ libICE libXi libXScrnSaver libXcursor libXinerama libXext libXrandr libXxf86vm ] ++
-    lib.optional pulseaudioSupport libpulseaudio;
-
-  buildInputs = [ audiofile ] ++
-    lib.optional openglSupport mesa_noglu ++
-    lib.optional alsaSupport alsaLib ++
-    lib.optional dbusSupport dbus ++
-    lib.optional udevSupport udev ++
-    lib.optional ibusSupport ibus ++
-    lib.optionals stdenv.isDarwin [ AudioUnit Cocoa CoreAudio CoreServices ForceFeedback OpenGL ];
+  propagatedBuildInputs = [ libiconv ]
+    ++ optional  dbusSupport dbus
+    ++ optional  udevSupport udev
+    ++ optionals x11Support [ libICE libXi libXScrnSaver libXcursor libXinerama libXext libXrandr libXxf86vm ]
+    ++ optionals waylandSupport [ wayland wayland-protocols libxkbcommon ]
+    ++ optional  alsaSupport alsaLib
+    ++ optional  pulseaudioSupport libpulseaudio;
 
-  # https://bugzilla.libsdl.org/show_bug.cgi?id=1431
-  dontDisableStatic = true;
+  buildInputs = [ audiofile ]
+    ++ optional  openglSupport libGL
+    ++ optional  ibusSupport ibus
+    ++ optionals stdenv.isDarwin [ AudioUnit Cocoa CoreAudio CoreServices ForceFeedback OpenGL ];
 
-  enableParallelBuilding = true;
+  # /build/SDL2-2.0.7/src/video/wayland/SDL_waylandevents.c:41:10: fatal error:
+  #   pointer-constraints-unstable-v1-client-protocol.h: No such file or directory
+  enableParallelBuilding = false;
 
-  # XXX: By default, SDL wants to dlopen() PulseAudio, in which case
-  # we must arrange to add it to its RPATH; however, `patchelf' seems
-  # to fail at doing this, hence `--disable-pulseaudio-shared'.
   configureFlags = configureFlagsFun { inherit alsaLib; };
 
   crossAttrs = {
@@ -69,6 +73,28 @@ stdenv.mkDerivation rec {
     moveToOutput bin/sdl2-config "$dev"
   '';
 
+  # SDL is weird in that instead of just dynamically linking with
+  # libraries when you `--enable-*` (or when `configure` finds) them
+  # it `dlopen`s them at runtime. In principle, this means it can
+  # ignore any missing optional dependencies like alsa, pulseaudio,
+  # some x11 libs, wayland, etc if they are missing on the system
+  # and/or work with wide array of versions of said libraries. In
+  # nixpkgs, however, we don't need any of that. Moreover, since we
+  # don't have a global ld-cache we have to stuff all the propagated
+  # libraries into rpath by hand or else some applications that use
+  # SDL API that requires said libraries will fail to start.
+  #
+  # You can grep SDL sources with `grep -rE 'SDL_(NAME|.*_SYM)'` to
+  # confirm that they actually use most of the `propagatedBuildInputs`
+  # from above in this way. This is pretty weird.
+  postFixup = ''
+    for lib in $out/lib/*.so* ; do
+      if [[ -L "$lib" ]]; then
+        patchelf --set-rpath "$(patchelf --print-rpath $lib):${lib.makeLibraryPath propagatedBuildInputs}" "$lib"
+      fi
+    done
+  '';
+
   setupHook = ./setup-hook.sh;
 
   passthru = { inherit openglSupport; };
diff --git a/pkgs/development/libraries/SDL2/setup-hook.sh b/pkgs/development/libraries/SDL2/setup-hook.sh
index 5a26440f37b3..3acce9d473c5 100644
--- a/pkgs/development/libraries/SDL2/setup-hook.sh
+++ b/pkgs/development/libraries/SDL2/setup-hook.sh
@@ -4,8 +4,4 @@ addSDL2Path () {
   fi
 }
 
-if test -n "$crossConfig"; then
-  crossEnvHooks+=(addSDL2Path)
-else
-  envHooks+=(addSDL2Path)
-fi
+addEnvHooks "$hostOffset" addSDL2Path
diff --git a/pkgs/development/libraries/SDL2_gfx/default.nix b/pkgs/development/libraries/SDL2_gfx/default.nix
index a7ef0290734b..04ec3f9652c2 100644
--- a/pkgs/development/libraries/SDL2_gfx/default.nix
+++ b/pkgs/development/libraries/SDL2_gfx/default.nix
@@ -1,15 +1,17 @@
-{ stdenv, fetchurl, SDL2 }:
+{ stdenv, darwin, fetchurl, SDL2 }:
 
 stdenv.mkDerivation rec {
-  name = "SDL2_gfx-${version}";
-  version = "1.0.1";
+  name = "${pname}-${version}";
+  pname = "SDL2_gfx";
+  version = "1.0.4";
 
   src = fetchurl {
-    url = "mirror://sourceforge/sdl2gfx/${name}.tar.gz";
-    sha256 = "16jrijzdp095qf416zvj9gs2fqqn6zkyvlxs5xqybd0ip37cp6yn";
+    url = "http://www.ferzkopp.net/Software/${pname}/${name}.tar.gz";
+    sha256 = "0qk2ax7f7grlxb13ba0ll3zlm8780s7j8fmrhlpxzjgdvldf1q33";
   };
 
-  buildInputs = [ SDL2 ];
+  buildInputs = [ SDL2 ]
+    ++ stdenv.lib.optional stdenv.isDarwin darwin.libobjc;
 
   configureFlags = if stdenv.isi686 || stdenv.isx86_64 then "--enable-mmx" else "--disable-mmx";
 
@@ -34,10 +36,9 @@ stdenv.mkDerivation rec {
       code. Its is written in plain C and can be used in C++ code.
     '';
 
-    homepage = https://sourceforge.net/projects/sdlgfx/;
+    homepage = http://www.ferzkopp.net/wordpress/2016/01/02/sdl_gfx-sdl2_gfx/;
     license = licenses.zlib;
-
-    maintainers = with maintainers; [ bjg ];
-    platforms = platforms.linux;
+    maintainers = with maintainers; [ cpages ];
+    platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/SDL2_image/default.nix b/pkgs/development/libraries/SDL2_image/default.nix
index 548f8e686ba8..b0f2d0e8b8d1 100644
--- a/pkgs/development/libraries/SDL2_image/default.nix
+++ b/pkgs/development/libraries/SDL2_image/default.nix
@@ -1,20 +1,24 @@
-{ stdenv, fetchurl, SDL2, libpng, libjpeg, libtiff, libungif, libXpm, zlib }:
+{ stdenv, fetchurl, SDL2, libpng, libjpeg, libtiff, libungif, libXpm, zlib, Foundation }:
 
 stdenv.mkDerivation rec {
   name = "SDL2_image-${version}";
-  version = "2.0.2";
+  version = "2.0.3";
 
   src = fetchurl {
     url = "http://www.libsdl.org/projects/SDL_image/release/${name}.tar.gz";
-    sha256 = "1s3ciydixrgv34vlf45ak5syq5nlfaqf19wf162lbz4ixxd0gpvj";
+    sha256 = "0s13dmakn21q6yw8avl67d4zkxzl1wap6l5nwf6cvzrmlxfw441m";
   };
 
-  buildInputs = [ SDL2 libpng libjpeg libtiff libungif libXpm zlib ];
+  buildInputs = [ SDL2 libpng libjpeg libtiff libungif libXpm zlib ]
+    ++ stdenv.lib.optional stdenv.isDarwin Foundation;
+
+  enableParallelBuilding = true;
 
   meta = with stdenv.lib; {
     description = "SDL image library";
     homepage = http://www.libsdl.org/projects/SDL_image/;
-    platforms = platforms.linux;
+    platforms = platforms.unix;
     license = licenses.zlib;
+    maintainers = with maintainers; [ cpages ];
   };
 }
diff --git a/pkgs/development/libraries/SDL2_mixer/default.nix b/pkgs/development/libraries/SDL2_mixer/default.nix
index 6eada0c83e52..00251adb9153 100644
--- a/pkgs/development/libraries/SDL2_mixer/default.nix
+++ b/pkgs/development/libraries/SDL2_mixer/default.nix
@@ -1,5 +1,6 @@
 { stdenv, lib, fetchurl, autoreconfHook, pkgconfig, which
 , SDL2, libogg, libvorbis, smpeg2, flac, libmodplug
+, CoreServices, AudioUnit, AudioToolbox
 , enableNativeMidi ? false, fluidsynth ? null }:
 
 stdenv.mkDerivation rec {
@@ -17,6 +18,8 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ autoreconfHook pkgconfig which ];
 
+  buildInputs = stdenv.lib.optionals stdenv.isDarwin [ CoreServices AudioUnit AudioToolbox ];
+
   propagatedBuildInputs = [ SDL2 libogg libvorbis fluidsynth smpeg2 flac libmodplug ];
 
   configureFlags = [ "--disable-music-ogg-shared" ]
@@ -24,7 +27,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "SDL multi-channel audio mixer library";
-    platforms = platforms.linux;
+    platforms = platforms.unix;
     homepage = https://www.libsdl.org/projects/SDL_mixer/;
     maintainers = with maintainers; [ MP2E ];
     license = licenses.zlib;
diff --git a/pkgs/development/libraries/SDL2_net/default.nix b/pkgs/development/libraries/SDL2_net/default.nix
index cf81fc0cac83..780444d51f4f 100644
--- a/pkgs/development/libraries/SDL2_net/default.nix
+++ b/pkgs/development/libraries/SDL2_net/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, SDL2 }:
+{ stdenv, darwin, fetchurl, SDL2 }:
 
 stdenv.mkDerivation rec {
   name = "SDL2_net-${version}";
@@ -9,6 +9,8 @@ stdenv.mkDerivation rec {
     sha256 = "08cxc1bicmyk89kiks7izw1rlx5ng5n6xpy8fy0zxni3b9z8mkhm";
   };
 
+  buildInputs = stdenv.lib.optional stdenv.isDarwin darwin.libobjc;
+
   propagatedBuildInputs = [ SDL2 ];
 
   meta = with stdenv.lib; {
@@ -16,6 +18,6 @@ stdenv.mkDerivation rec {
     homepage = https://www.libsdl.org/projects/SDL_net;
     license = licenses.zlib;
     maintainers = with maintainers; [ MP2E ];
-    platforms = platforms.linux;
+    platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/SDL2_ttf/default.nix b/pkgs/development/libraries/SDL2_ttf/default.nix
index 010ca46695a3..4558317ce3e3 100644
--- a/pkgs/development/libraries/SDL2_ttf/default.nix
+++ b/pkgs/development/libraries/SDL2_ttf/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, SDL2, freetype, mesa_noglu }:
+{ stdenv, darwin, fetchurl, SDL2, freetype, libGL }:
 
 stdenv.mkDerivation rec {
   name = "SDL2_ttf-${version}";
@@ -9,11 +9,12 @@ stdenv.mkDerivation rec {
     sha256 = "0xljwcpvd2knrjdfag5b257xqayplz55mqlszrqp0kpnphh5xnrl";
   };
 
-  buildInputs = [ SDL2 freetype mesa_noglu ];
+  buildInputs = [ SDL2 freetype libGL ]
+    ++ stdenv.lib.optional stdenv.isDarwin darwin.libobjc;
 
   meta = with stdenv.lib; {
     description = "SDL TrueType library";
-    platforms = platforms.linux;
+    platforms = platforms.unix;
     license = licenses.zlib;
     homepage = https://www.libsdl.org/projects/SDL_ttf/;
   };
diff --git a/pkgs/development/libraries/SDL_gfx/default.nix b/pkgs/development/libraries/SDL_gfx/default.nix
index 0f66f0afb178..83a2ffc077c3 100644
--- a/pkgs/development/libraries/SDL_gfx/default.nix
+++ b/pkgs/development/libraries/SDL_gfx/default.nix
@@ -2,16 +2,17 @@
 
 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 ] ;
 
-  configureFlags = [ "--disable-mmx" ];
+  configureFlags = [ "--disable-mmx" ]
+    ++ stdenv.lib.optional stdenv.isDarwin "--disable-sdltest";
 
   meta = with stdenv.lib; {
     description = "SDL graphics drawing primitives and support functions";
diff --git a/pkgs/development/libraries/SDL_image/default.nix b/pkgs/development/libraries/SDL_image/default.nix
index 55a4058fe56d..c8cab33ed57f 100644
--- a/pkgs/development/libraries/SDL_image/default.nix
+++ b/pkgs/development/libraries/SDL_image/default.nix
@@ -17,6 +17,8 @@ stdenv.mkDerivation rec {
     })
   ];
 
+  configureFlags = stdenv.lib.optional stdenv.isDarwin "--disable-sdltest";
+
   buildInputs = [ SDL libpng libjpeg libtiff libungif libXpm ];
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/SDL_mixer/default.nix b/pkgs/development/libraries/SDL_mixer/default.nix
index fe64569abbe2..d328d80d3898 100644
--- a/pkgs/development/libraries/SDL_mixer/default.nix
+++ b/pkgs/development/libraries/SDL_mixer/default.nix
@@ -12,7 +12,9 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ SDL libogg libvorbis fluidsynth smpeg ];
 
-  configureFlags = [ "--disable-music-ogg-shared" ] ++ lib.optional enableNativeMidi " --enable-music-native-midi-gpl";
+  configureFlags = [ "--disable-music-ogg-shared" ]
+    ++ lib.optional enableNativeMidi " --enable-music-native-midi-gpl"
+    ++ lib.optionals stdenv.isDarwin [ "--disable-sdltest" "--disable-smpegtest" ];
 
   meta = with stdenv.lib; {
     description = "SDL multi-channel audio mixer library";
diff --git a/pkgs/development/libraries/SDL_net/default.nix b/pkgs/development/libraries/SDL_net/default.nix
index a159a0691f49..f1c5a5462d11 100644
--- a/pkgs/development/libraries/SDL_net/default.nix
+++ b/pkgs/development/libraries/SDL_net/default.nix
@@ -11,6 +11,8 @@ stdenv.mkDerivation rec {
     sha256 = "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz";
   };
 
+  configureFlags = stdenv.lib.optional stdenv.isDarwin "--disable-sdltest";
+
   propagatedBuildInputs = [ SDL ];
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/SDL_ttf/default.nix b/pkgs/development/libraries/SDL_ttf/default.nix
index 1f290bf7044f..f98e4a3b0ad3 100644
--- a/pkgs/development/libraries/SDL_ttf/default.nix
+++ b/pkgs/development/libraries/SDL_ttf/default.nix
@@ -21,6 +21,8 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ SDL freetype ];
 
+  configureFlags = stdenv.lib.optional stdenv.isDarwin "--disable-sdltest";
+
   meta = with stdenv.lib; {
     description = "SDL TrueType library";
     license = licenses.zlib;
diff --git a/pkgs/development/libraries/Xaw3d/default.nix b/pkgs/development/libraries/Xaw3d/default.nix
index 8cadc7290aa9..f28ab55010b6 100644
--- a/pkgs/development/libraries/Xaw3d/default.nix
+++ b/pkgs/development/libraries/Xaw3d/default.nix
@@ -3,10 +3,8 @@
 stdenv.mkDerivation {
   name = "Xaw3d-1.6.2";
   src = fetchurl {
-    urls = [ 
-      ftp://ftp.x.org/pub/xorg/individual/lib/libXaw3d-1.6.tar.bz2
-      ];
-    sha256 = "099kx6ni5vkgr3kf40glif8m6r1m1hq6hxqlqrblaj1w5cphh8hi";
+    url = https://www.x.org/releases/individual/lib/libXaw3d-1.6.2.tar.bz2;
+    sha256 = "0awplv1nf53ywv01yxphga3v6dcniwqnxgnb0cn4khb121l12kxp";
   };
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [imake gccmakedep libXpm libXp bison flex];
@@ -14,6 +12,6 @@ stdenv.mkDerivation {
 
   meta = {
     description = "3D widget set based on the Athena Widget set";
-    platforms = stdenv.lib.platforms.linux;
+    platforms = stdenv.lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/accounts-qt/default.nix b/pkgs/development/libraries/accounts-qt/default.nix
index e45a9f2f3871..a50c92924e9a 100644
--- a/pkgs/development/libraries/accounts-qt/default.nix
+++ b/pkgs/development/libraries/accounts-qt/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "accounts-qt-${version}";
-  version = "1.13";
+  version = "1.15";
 
   src = fetchFromGitLab {
-    sha256 = "1gpkgw05dwsf2wk5cy3skgss3kw6mqh7iv3fadrxqxfc1za1xmyl";
-    rev = version;
+    sha256 = "0cnra7g2mcgzh8ykrj1dpb4khkx676pzdr4ia1bvsp0cli48691w";
+    rev = "VERSION_${version}";
     repo = "libaccounts-qt";
     owner = "accounts-sso";
   };
@@ -25,7 +25,6 @@ stdenv.mkDerivation rec {
     description = "Qt library for accessing the online accounts database";
     homepage = https://gitlab.com/accounts-sso;
     license = licenses.lgpl21;
-    maintainers = with maintainers; [ nckx ];
     platforms = with platforms; linux;
   };
 }
diff --git a/pkgs/development/libraries/accountsservice/default.nix b/pkgs/development/libraries/accountsservice/default.nix
index d1b3b9b98271..f12dfb4635b2 100644
--- a/pkgs/development/libraries/accountsservice/default.nix
+++ b/pkgs/development/libraries/accountsservice/default.nix
@@ -3,11 +3,11 @@
 
 stdenv.mkDerivation rec {
   name = "accountsservice-${version}";
-  version = "0.6.45";
+  version = "0.6.46";
 
   src = fetchurl {
     url = "http://www.freedesktop.org/software/accountsservice/accountsservice-${version}.tar.xz";
-    sha256 = "09pg25ir7kjigvp2cxd9fkfw8c8ql8vrswfvymg9zmbmma9w43zv";
+    sha256 = "09ddndbha2wh22a0k5150d2wy0v8k8zj3vmbdijyirqwhf5vjr8q";
   };
 
   nativeBuildInputs = [ pkgconfig makeWrapper ];
diff --git a/pkgs/development/libraries/ace/default.nix b/pkgs/development/libraries/ace/default.nix
index 42988e334b07..d61315f7db85 100644
--- a/pkgs/development/libraries/ace/default.nix
+++ b/pkgs/development/libraries/ace/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "ace-${version}";
-  version = "6.4.3";
+  version = "6.4.7";
 
   src = fetchurl {
     url = "http://download.dre.vanderbilt.edu/previous_versions/ACE-${version}.tar.bz2";
-    sha256 = "07dvpi3abmjvg7m0aak4x82aj8cvw5zl2cqj525wd3fl6y0pn3mq";
+    sha256 = "1zbncdxkkwnx4aphy0apnp7xn4aspxvq2h9bbjh33dpsy0j81afd";
   };
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/acl/default.nix b/pkgs/development/libraries/acl/default.nix
index dc9e4e6ff18b..f9bb982a7842 100644
--- a/pkgs/development/libraries/acl/default.nix
+++ b/pkgs/development/libraries/acl/default.nix
@@ -18,15 +18,18 @@ 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";
+  configureFlags = [ "MAKE=make" "MSGFMT=msgfmt" "MSGMERGE=msgmerge" "XGETTEXT=xgettext" "ZIP=gzip" "ECHO=echo" "SED=sed" "AWK=gawk" ];
 
-  installTargets = "install install-lib install-dev";
+  installTargets = [ "install" "install-lib" "install-dev" ];
 
-  meta = {
-    homepage = http://savannah.nongnu.org/projects/acl;
+  meta = with stdenv.lib; {
+    homepage = "http://savannah.nongnu.org/projects/acl";
     description = "Library and tools for manipulating access control lists";
-    platforms = stdenv.lib.platforms.linux;
+    platforms = platforms.linux;
+    license = licenses.gpl2Plus;
   };
 }
diff --git a/pkgs/development/libraries/agda/agda-stdlib/default.nix b/pkgs/development/libraries/agda/agda-stdlib/default.nix
index 815e0f20b54e..c72572139c68 100644
--- a/pkgs/development/libraries/agda/agda-stdlib/default.nix
+++ b/pkgs/development/libraries/agda/agda-stdlib/default.nix
@@ -1,14 +1,14 @@
 { stdenv, agda, fetchFromGitHub, ghcWithPackages }:
 
 agda.mkDerivation (self: rec {
-  version = "0.14";
+  version = "0.15";
   name = "agda-stdlib-${version}";
 
   src = fetchFromGitHub {
     repo = "agda-stdlib";
     owner = "agda";
     rev = "v${version}";
-    sha256 = "0qx72w6lwskp18q608f95j5dcxb9xr4q4mzdkxp01sgib8v2v56l";
+    sha256 = "0c2vfib4fmljy98c3s3s7jmpjlqxvsbv7wf6qxr38kamwzbryrjj";
   };
 
   nativeBuildInputs = [ (ghcWithPackages (self : [ self.filemanip ])) ];
diff --git a/pkgs/development/libraries/agda/pretty/default.nix b/pkgs/development/libraries/agda/pretty/default.nix
index 25e6ff6667fe..0e4f1da6e140 100644
--- a/pkgs/development/libraries/agda/pretty/default.nix
+++ b/pkgs/development/libraries/agda/pretty/default.nix
@@ -21,5 +21,6 @@ agda.mkDerivation (self: rec {
     license = stdenv.lib.licenses.mit;
     platforms = stdenv.lib.platforms.unix;
     maintainers = with maintainers; [ fuuzetsu ];
+    broken = true; # 2018-04-11
   };
 })
diff --git a/pkgs/development/libraries/agg/default.nix b/pkgs/development/libraries/agg/default.nix
index 2edf4e232260..ab3098580950 100644
--- a/pkgs/development/libraries/agg/default.nix
+++ b/pkgs/development/libraries/agg/default.nix
@@ -16,7 +16,11 @@ stdenv.mkDerivation rec {
     sh autogen.sh
   '';
 
-  configureFlags = "--x-includes=${libX11.dev}/include --x-libraries=${libX11.out}/lib";
+  configureFlags = "--x-includes=${libX11.dev}/include --x-libraries=${libX11.out}/lib --enable-examples=no";
+
+  # libtool --tag=CXX --mode=link g++ -g -O2 libexamples.la ../src/platform/X11/libaggplatformX11.la ../src/libagg.la -o alpha_mask2 alpha_mask2.o
+  # libtool: error: cannot find the library 'libexamples.la'
+  enableParallelBuilding = false;
 
   meta = {
     description = "High quality rendering engine for C++";
diff --git a/pkgs/development/libraries/alembic/default.nix b/pkgs/development/libraries/alembic/default.nix
index bd540cdd5005..2276264e03f1 100644
--- a/pkgs/development/libraries/alembic/default.nix
+++ b/pkgs/development/libraries/alembic/default.nix
@@ -1,20 +1,21 @@
-{ stdenv, fetchFromGitHub, unzip, cmake, openexr, hdf5 }:
+{ stdenv, fetchFromGitHub, unzip, cmake, openexr, hdf5-threadsafe }:
 
 stdenv.mkDerivation rec
 {
   name = "alembic-${version}";
-  version = "1.7.4";
+  version = "1.7.7";
 
   src = fetchFromGitHub {
     owner = "alembic";
     repo = "alembic";
     rev = "${version}";
-    sha256 = "00r6d8xk2sq5hdl5lp14nhyh1b2d68fxpzbm69fk6iq2f2gv0iqv";
+    sha256 = "16cgzn8cz3qbfpfh53bhn4ibwp5ddam3vxgz8zaglbj7z1a3pxfv";
   };
 
   outputs = [ "bin" "dev" "out" "lib" ];
 
-  buildInputs = [ unzip cmake openexr hdf5 ];
+  nativeBuildInputs = [ unzip cmake ];
+  buildInputs = [ openexr hdf5-threadsafe ];
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/allegro/5.nix b/pkgs/development/libraries/allegro/5.nix
index f1402e4ad9ed..e20b2700f0e2 100644
--- a/pkgs/development/libraries/allegro/5.nix
+++ b/pkgs/development/libraries/allegro/5.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchFromGitHub, texinfo, libXext, xextproto, libX11, xproto
 , libXpm, libXt, libXcursor, alsaLib, cmake, zlib, libpng, libvorbis
 , libXxf86dga, libXxf86misc, xf86dgaproto, xf86miscproto
-, xf86vidmodeproto, libXxf86vm, openal, mesa, kbproto, libjpeg, flac
+, xf86vidmodeproto, libXxf86vm, openal, libGLU_combined, kbproto, libjpeg, flac
 , inputproto, libXi, fixesproto, libXfixes, freetype, libopus, libtheora
 , physfs, enet, pkgconfig, gtk2, pcre, libpulseaudio, libpthreadstubs
 , libXdmcp
@@ -9,19 +9,19 @@
 
 stdenv.mkDerivation rec {
   name = "allegro-${version}";
-  version = "5.2.2.0";
+  version = "5.2.4.0";
 
   src = fetchFromGitHub {
     owner = "liballeg";
     repo = "allegro5";
     rev = version;
-    sha256 = "1sf0dr0ahrzsy6gzzpvys9d7d9w0grayhak4cyymjv7w857hf51m";
+    sha256 = "01y3hirn5b08f188nnhb2cbqj4vzysr7l2qpz2208srv8arzmj2d";
   };
 
   buildInputs = [
     texinfo libXext xextproto libX11 xproto libXpm libXt libXcursor
     alsaLib cmake zlib libpng libvorbis libXxf86dga libXxf86misc
-    xf86dgaproto xf86miscproto xf86vidmodeproto libXxf86vm openal mesa
+    xf86dgaproto xf86miscproto xf86vidmodeproto libXxf86vm openal libGLU_combined
     kbproto libjpeg flac
     inputproto libXi fixesproto libXfixes
     enet libtheora freetype physfs libopus pkgconfig gtk2 pcre libXdmcp
diff --git a/pkgs/development/libraries/allegro/default.nix b/pkgs/development/libraries/allegro/default.nix
index c0451486c144..12b2cbf07071 100644
--- a/pkgs/development/libraries/allegro/default.nix
+++ b/pkgs/development/libraries/allegro/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, texinfo, libXext, xextproto, libX11, xproto
 , libXpm, libXt, libXcursor, alsaLib, cmake, zlib, libpng, libvorbis
 , libXxf86dga, libXxf86misc, xf86dgaproto, xf86miscproto
-, xf86vidmodeproto, libXxf86vm, openal, mesa }:
+, xf86vidmodeproto, libXxf86vm, openal, libGLU_combined }:
 
 stdenv.mkDerivation rec {
   name = "allegro-${version}";
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
   buildInputs = [
     texinfo libXext xextproto libX11 xproto libXpm libXt libXcursor
     alsaLib cmake zlib libpng libvorbis libXxf86dga libXxf86misc
-    xf86dgaproto xf86miscproto xf86vidmodeproto libXxf86vm openal mesa
+    xf86dgaproto xf86miscproto xf86vidmodeproto libXxf86vm openal libGLU_combined
   ];
 
   hardeningDisable = [ "format" ];
diff --git a/pkgs/development/libraries/apache-activemq/default.nix b/pkgs/development/libraries/apache-activemq/default.nix
index c71dced918ac..fc79cae36f83 100644
--- a/pkgs/development/libraries/apache-activemq/default.nix
+++ b/pkgs/development/libraries/apache-activemq/default.nix
@@ -2,10 +2,10 @@
 
 stdenv.mkDerivation rec {
   name = "apache-activemq-${version}";
-  version = "5.13.4";
+  version = "5.14.5";
 
   src = fetchurl {
-    sha256 = "0sp806bmv9vs19zbzlv71ag09p1jbl2wn2wpxfwa20mndri8lsmz";
+    sha256 = "0vm8z7rxb9n10xg5xjahy357704fw3q477hmpb83kd1zrc633g54";
     url = "mirror://apache/activemq/${version}/${name}-bin.tar.gz";
   };
 
diff --git a/pkgs/development/libraries/appstream-glib/default.nix b/pkgs/development/libraries/appstream-glib/default.nix
index d177c3acfa71..2499a424c85c 100644
--- a/pkgs/development/libraries/appstream-glib/default.nix
+++ b/pkgs/development/libraries/appstream-glib/default.nix
@@ -1,30 +1,53 @@
-{ stdenv, fetchFromGitHub, pkgconfig, gettext, gtk3, glib
-, gtk_doc, libarchive, gobjectIntrospection
-, sqlite, libsoup, gcab, attr, acl, docbook_xsl
-, libuuid, json_glib, meson, gperf, ninja
+{ stdenv, fetchFromGitHub, substituteAll, pkgconfig, gettext, gtk3, glib
+, gtk-doc, libarchive, gobjectIntrospection, libxslt, pngquant
+, sqlite, libsoup, gcab, attr, acl, docbook_xsl, docbook_xml_dtd_42
+, libuuid, json-glib, meson, gperf, ninja
 }:
 stdenv.mkDerivation rec {
-  name = "appstream-glib-0.7.2";
+  name = "appstream-glib-0.7.7";
+
+  outputs = [ "out" "dev" "man" "installedTests" ];
+  outputBin = "dev";
 
   src = fetchFromGitHub {
     owner = "hughsie";
     repo = "appstream-glib";
     rev = stdenv.lib.replaceStrings ["." "-"] ["_" "_"] name;
-    sha256 = "1jvwfida12d2snc8p9lpbpqzrixw2naaiwfmsrldwkrxsj3i19pl";
+    sha256 = "127m5ds355i1vfvmn9nd4zqqnqm16jpqcn4p2p2pvn7i4wqxra40";
   };
 
-  nativeBuildInputs = [ meson pkgconfig ninja ];
-  buildInputs = [ glib gtk_doc gettext sqlite libsoup
-                  gcab attr acl docbook_xsl libuuid json_glib
-                  libarchive gobjectIntrospection gperf ];
+  nativeBuildInputs = [
+    meson pkgconfig ninja gtk-doc libxslt docbook_xsl docbook_xml_dtd_42
+  ];
+  buildInputs = [
+    glib gettext sqlite libsoup
+    gcab attr acl libuuid json-glib
+    libarchive gobjectIntrospection gperf
+  ];
   propagatedBuildInputs = [ gtk3 ];
-  mesonFlags = [ "-Denable-rpm=false" "-Denable-stemmer=false" "-Denable-dep11=false" ];
+
+  patches = [
+    (substituteAll {
+      src = ./paths.patch;
+      pngquant= "${pngquant}/bin/pngquant";
+    })
+  ];
+
+  mesonFlags = [
+    "-Drpm=false"
+    "-Dstemmer=false"
+    "-Ddep11=false"
+  ];
+
+  postInstall = ''
+    moveToOutput "share/installed-tests" "$installedTests"
+  '';
 
   meta = with stdenv.lib; {
     description = "Objects and helper methods to read and write AppStream metadata";
-    homepage    = https://github.com/hughsie/appstream-glib;
-    license     = licenses.lgpl21Plus;
-    platforms   = platforms.linux;
+    homepage = https://people.freedesktop.org/~hughsient/appstream-glib/;
+    license = licenses.lgpl2Plus;
+    platforms = platforms.linux;
     maintainers = with maintainers; [ lethalman matthewbauer ];
   };
 }
diff --git a/pkgs/development/libraries/appstream-glib/paths.patch b/pkgs/development/libraries/appstream-glib/paths.patch
new file mode 100644
index 000000000000..5c6396988a17
--- /dev/null
+++ b/pkgs/development/libraries/appstream-glib/paths.patch
@@ -0,0 +1,11 @@
+--- a/libappstream-builder/asb-utils.c
++++ b/libappstream-builder/asb-utils.c
+@@ -294,7 +294,7 @@
+ {
+ 	g_autofree gchar *standard_error = NULL;
+ 	gint exit_status = 0;
+-	const gchar *argv[] = { "/usr/bin/pngquant", "--skip-if-larger",
++	const gchar *argv[] = { "@pngquant@", "--skip-if-larger",
+ 				"--strip", "--ext", ".png",
+ 				"--force", "--speed", "1", filename, NULL };
+ 	if (!g_file_test (argv[0], G_FILE_TEST_IS_EXECUTABLE))
diff --git a/pkgs/development/libraries/appstream/default.nix b/pkgs/development/libraries/appstream/default.nix
index b79f274b9c3a..61ee182ce627 100644
--- a/pkgs/development/libraries/appstream/default.nix
+++ b/pkgs/development/libraries/appstream/default.nix
@@ -1,37 +1,55 @@
-{ stdenv, fetchFromGitHub, cmake, pkgconfig, gettext, intltool
-, xmlto, docbook_xsl, docbook_xml_dtd_45
-, glib, xapian, libxml2, libyaml, gobjectIntrospection
+{ stdenv, fetchpatch, fetchFromGitHub, meson, ninja, pkgconfig, gettext
+, xmlto, docbook_xsl, docbook_xml_dtd_45, libxslt
+, libstemmer, glib, xapian, libxml2, libyaml, gobjectIntrospection
 , pcre, itstool
 }:
 
 stdenv.mkDerivation rec {
   name = "appstream-${version}";
-  version = "0.10.6";
+  version = "0.11.8";
 
   src = fetchFromGitHub {
-    owner = "ximion";
-    repo = "appstream";
-    rev = "APPSTREAM_0_10_6";
-    sha256 = "1fg7zxx2qhkyj7fmcpwbf80b72d16kyi8dadi111kf00sgzfbiyy";
+    owner  = "ximion";
+    repo   = "appstream";
+    rev    = "APPSTREAM_${stdenv.lib.replaceStrings ["."] ["_"] version}";
+    sha256 = "07vzz57g1p5byj2jfg17y5n3il0g07d9wkiynzwra71mcxar1p08";
   };
 
+  patches = [
+    # drop this in version 0.11.9 and above
+    (fetchpatch {
+      name   = "define-location-and-soname.patch";
+      url    = "https://github.com/ximion/appstream/commit/3e58f9c9.patch";
+      sha256 = "1ffgbdfg80yq5vahjrvdd4f8xsp32ksm9vyasfmc7hzhx294s78w";
+    })
+  ];
+
   nativeBuildInputs = [
-    cmake pkgconfig gettext intltool
-    xmlto docbook_xsl docbook_xml_dtd_45
+    meson ninja pkgconfig gettext
+    libxslt xmlto docbook_xsl docbook_xml_dtd_45
     gobjectIntrospection itstool
   ];
 
-  buildInputs = [ pcre glib xapian libxml2 libyaml ];
+  buildInputs = [ libstemmer pcre glib xapian libxml2 libyaml ];
 
-  cmakeFlags = ''
-    -DSTEMMING=off
-    '';
+  prePatch = ''
+    substituteInPlace meson.build \
+      --replace /usr/include ${libstemmer}/include
+
+    substituteInPlace data/meson.build \
+      --replace /etc $out/etc
+  '';
+
+  mesonFlags = [
+    "-Dapidocs=false"
+    "-Ddocs=false"
+    "-Dgir=false"
+  ];
 
   meta = with stdenv.lib; {
     description = "Software metadata handling library";
     homepage    = https://www.freedesktop.org/wiki/Distributions/AppStream/;
-    longDescription =
-    ''
+    longDescription = ''
       AppStream is a cross-distro effort for building Software-Center applications
       and enhancing metadata provided by software components.  It provides
       specifications for meta-information which is shipped by upstream projects and
diff --git a/pkgs/development/libraries/appstream/qt.nix b/pkgs/development/libraries/appstream/qt.nix
new file mode 100644
index 000000000000..beff83f2365b
--- /dev/null
+++ b/pkgs/development/libraries/appstream/qt.nix
@@ -0,0 +1,25 @@
+{ stdenv, appstream, qtbase, qttools }:
+
+stdenv.mkDerivation rec {
+  name = "appstream-qt-${version}";
+  inherit (appstream) version src patches prePatch;
+
+  buildInputs = appstream.buildInputs ++ [ appstream qtbase ];
+
+  nativeBuildInputs = appstream.nativeBuildInputs ++ [ qttools ];
+
+  mesonFlags = appstream.mesonFlags ++ [ "-Dqt=true" ];
+
+  postInstall = ''
+    rm -rf $out/{bin,etc,include/appstream,lib/pkgconfig,lib/libappstream.so*,share}
+  '';
+
+  preFixup = ''
+    patchelf --add-needed ${appstream}/lib/libappstream.so.4 \
+      $out/lib/libAppStreamQt.so
+  '';
+
+  meta = appstream.meta // {
+    description = "Software metadata handling library - Qt";
+ };
+}
diff --git a/pkgs/development/libraries/apr-util/default.nix b/pkgs/development/libraries/apr-util/default.nix
index 3251693f5742..7e7864cef52c 100644
--- a/pkgs/development/libraries/apr-util/default.nix
+++ b/pkgs/development/libraries/apr-util/default.nix
@@ -13,11 +13,11 @@ assert ldapSupport -> openldap != null;
 with stdenv.lib;
 
 stdenv.mkDerivation rec {
-  name = "apr-util-1.6.0";
+  name = "apr-util-1.6.1";
 
   src = fetchurl {
     url = "mirror://apache/apr/${name}.tar.bz2";
-    sha256 = "0k6a90d67xl36brz69s7adgkswjmw7isnjblm1naqmjblwzwjx44";
+    sha256 = "0nq3s1yn13vplgl6qfm09f7n0wm08malff9s59bqf9nid9xjzqfk";
   };
 
   patches = optional stdenv.isFreeBSD ./include-static-dependencies.patch;
diff --git a/pkgs/development/libraries/apr/default.nix b/pkgs/development/libraries/apr/default.nix
index 9abf48289ae0..ecdeb35f6eda 100644
--- a/pkgs/development/libraries/apr/default.nix
+++ b/pkgs/development/libraries/apr/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "apr-1.6.2";
+  name = "apr-1.6.3";
 
   src = fetchurl {
     url = "mirror://apache/apr/${name}.tar.bz2";
-    sha256 = "1gffipa87pflvgvw01dbkvgh75p8n2sr56m1pcl01avv6zm9q409";
+    sha256 = "0wiik6amxn6lkc55fv9yz5i3kbxnqbp36alrzabx1avsdp8hc7qk";
   };
 
   patches = stdenv.lib.optionals stdenv.isDarwin [ ./is-this-a-compiler-bug.patch ];
diff --git a/pkgs/development/libraries/arguments/default.nix b/pkgs/development/libraries/arguments/default.nix
new file mode 100644
index 000000000000..912ea53c3d3a
--- /dev/null
+++ b/pkgs/development/libraries/arguments/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchFromGitHub, cmake, libminc, bicpl }:
+
+stdenv.mkDerivation rec {
+  pname = "arguments";
+  name  = "${pname}-2015-11-30";
+
+  owner = "BIC-MNI";
+
+  src = fetchFromGitHub {
+    inherit owner;
+    repo   = pname;
+    rev    = "b3aad97f6b6892cb8733455d0d448649a48fa108";
+    sha256 = "1ar8lm1w1jflz3vdmjr5c4x6y7rscvrj78b8gmrv79y95qrgzv6s";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ ];
+
+  #cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib" "-DBICPL_DIR=${bicpl}/lib" "-DBUILD_TESTING=FALSE" ];
+
+  checkPhase = "ctest --output-on-failure";
+  doCheck = false;
+  # internal_volume_io.h: No such file or directory
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/${owner}/${pname}";
+    description = "Library for argument handling for MINC programs";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license   = licenses.free;
+  };
+}
diff --git a/pkgs/development/libraries/arm-frc-linux-gnueabi-eglibc/default.nix b/pkgs/development/libraries/arm-frc-linux-gnueabi-eglibc/default.nix
deleted file mode 100755
index 8adbef8f5764..000000000000
--- a/pkgs/development/libraries/arm-frc-linux-gnueabi-eglibc/default.nix
+++ /dev/null
@@ -1,65 +0,0 @@
-{stdenv, fetchurl, arm-frc-linux-gnueabi-linux-api-headers}:
-
-let
-  _target = "arm-frc-linux-gnueabi";
-  _basever = "2.21-r0.83";
-  srcs = [
-    (fetchurl {
-      url = "http://download.ni.com/ni-linux-rt/feeds/2016/arm/ipk/cortexa9-vfpv3/libc6_${_basever}_cortexa9-vfpv3.ipk";
-      sha256 = "117058215440e258027bb9ff18db63c078d55288787dbedfcd5730c06c7a1ae9";
-    })
-    (fetchurl {
-      url = "http://download.ni.com/ni-linux-rt/feeds/2016/arm/ipk/cortexa9-vfpv3/libc6-dev_${_basever}_cortexa9-vfpv3.ipk";
-      sha256 = "e28b05d498c1160949f51539270035e12c5bb9d75d68df1f5f111a8fc087f3a6";
-    })
-    (fetchurl {
-      url = "http://download.ni.com/ni-linux-rt/feeds/2016/arm/ipk/cortexa9-vfpv3/libcidn1_${_basever}_cortexa9-vfpv3.ipk";
-      sha256 = "0f7372590abf69da54a9b7db8f944cf6c48d9ac8a091218ee60f84fdd9de2398";
-    })
-    (fetchurl {
-      url = "http://download.ni.com/ni-linux-rt/feeds/2016/arm/ipk/cortexa9-vfpv3/libc6-thread-db_${_basever}_cortexa9-vfpv3.ipk";
-      sha256 = "5a839498507a0b63165cb7a78234d7eb2ee2bb6a046bff586090f2e70e0e2bfb";
-    })
-    (fetchurl {
-      url = "http://download.ni.com/ni-linux-rt/feeds/2016/arm/ipk/cortexa9-vfpv3/libc6-extra-nss_${_basever}_cortexa9-vfpv3.ipk";
-      sha256 = "d765d43c8ec95a4c64fa38eddf8cee848fd090d9cc5b9fcda6d2c9b03d2635c5";
-    })
-  ];
-in
-stdenv.mkDerivation rec {
-  version = "2.21";
-  name = "${_target}-eglibc-${version}";
-
-  sourceRoot = ".";
-  inherit srcs;
-
-  phases = [ "unpackPhase" "installPhase" ];
-
-  unpackCmd = ''
-      ar x $curSrc
-      tar xf data.tar.gz
-  '';
-
-  installPhase = ''
-    mkdir -p $out/${_target}
-    rm -rf lib/eglibc
-    find . \( -name .install -o -name ..install.cmd \) -delete
-    cp -r lib $out/${_target}
-    cp -r usr $out/${_target}
-
-    cp -r ${arm-frc-linux-gnueabi-linux-api-headers}/* $out
-  '';
-
-  meta = {
-    description = "FRC standard C lib";
-    longDescription = ''
-      eglibc library for the NI RoboRio to be used in compiling frc user
-      programs.
-    '';
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = [ stdenv.lib.maintainers.colescott ];
-    platforms = stdenv.lib.platforms.linux;
-
-    priority = 2;
-  };
-}
diff --git a/pkgs/development/libraries/arm-frc-linux-gnueabi-linux-api-headers/default.nix b/pkgs/development/libraries/arm-frc-linux-gnueabi-linux-api-headers/default.nix
deleted file mode 100755
index 29e349e0a820..000000000000
--- a/pkgs/development/libraries/arm-frc-linux-gnueabi-linux-api-headers/default.nix
+++ /dev/null
@@ -1,43 +0,0 @@
-{stdenv, fetchurl}:
-
-let
-  _target = "arm-frc-linux-gnueabi";
-  _basever = "3.19-r0.36";
-  src = fetchurl {
-    url = "http://download.ni.com/ni-linux-rt/feeds/2016/arm/ipk/cortexa9-vfpv3/linux-libc-headers-dev_${_basever}_cortexa9-vfpv3.ipk";
-    sha256 = "10066ddb9a19bf764a9a67919a7976478041e98c44c19308f076c78ecb07408c";
-  };
-in
-stdenv.mkDerivation rec {
-  version = "3.19";
-  name = "${_target}-linux-api-headers-${version}";
-
-  sourceRoot = ".";
-  inherit src;
-
-  phases = [ "unpackPhase" "installPhase" ];
-
-  unpackCmd = ''
-    ar x $curSrc
-    tar xf data.tar.gz
-  '';
-
-  installPhase = ''
-    mkdir -p $out/${_target}
-    find . \( -name .install -o -name ..install.cmd \) -delete
-    cp -r usr/ $out/${_target}
-  '';
-
-  meta = {
-    description = "FRC linux api headers";
-    longDescription = ''
-      All linux api headers required to compile the arm-frc-linux-gnuaebi-gcc
-      cross compiler and all user programs.
-    '';
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = [ stdenv.lib.maintainers.colescott ];
-    platforms = stdenv.lib.platforms.linux;
-
-    priority = 1;
-  };
-}
diff --git a/pkgs/development/libraries/armadillo/default.nix b/pkgs/development/libraries/armadillo/default.nix
index 7a3e0b2083cc..a5ca79c0d82e 100644
--- a/pkgs/development/libraries/armadillo/default.nix
+++ b/pkgs/development/libraries/armadillo/default.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, cmake, openblasCompat, superlu, hdf5 }:
 
 stdenv.mkDerivation rec {
-  version = "7.800.1";
+  version = "8.400.0";
   name = "armadillo-${version}";
 
   src = fetchurl {
     url = "mirror://sourceforge/arma/armadillo-${version}.tar.xz";
-    sha256 = "1nxq2jp4jlvinynv0l04rpdzpnkzdsng0d5vi3hilc0hlsjnbnjs";
+    sha256 = "16yxhn904ll48879vmycv84rja28im0mrcfgb03nm7bs8lpvrdjw";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/armadillo/use-unix-config-on-OS-X.patch b/pkgs/development/libraries/armadillo/use-unix-config-on-OS-X.patch
index b6fdddcaf2da..a1442d141193 100644
--- a/pkgs/development/libraries/armadillo/use-unix-config-on-OS-X.patch
+++ b/pkgs/development/libraries/armadillo/use-unix-config-on-OS-X.patch
@@ -1,10 +1,9 @@
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
-@@ -84,7 +84,7 @@ message(STATUS "DETECT_HDF5                = ${DETECT_HDF5}"               )
- ##
- ## Find LAPACK and BLAS libraries, or their optimised versions
- ##
--
+@@ -152,6 +152,7 @@ message(STATUS "DETECT_HDF5                = ${DETECT_HDF5}"               )
+
+ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_aux/Modules/")
+
 +set(APPLE false)
  if(APPLE)
    
diff --git a/pkgs/development/libraries/arrow-cpp/default.nix b/pkgs/development/libraries/arrow-cpp/default.nix
new file mode 100644
index 000000000000..952f7435c069
--- /dev/null
+++ b/pkgs/development/libraries/arrow-cpp/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, symlinkJoin, fetchurl, boost, brotli, cmake, flatbuffers, gtest, gflags, lz4, python, rapidjson, snappy, zlib, zstd }:
+
+stdenv.mkDerivation rec {
+  name = "arrow-cpp-${version}";
+  version = "0.9.0";
+
+  src = fetchurl {
+    url = "mirror://apache/arrow/arrow-${version}/apache-arrow-${version}.tar.gz";
+    sha256 = "16l91fixb5dgx3v6xc73ipn1w1hjgbmijyvs81j7ywzpna2cdcdy";
+  };
+
+  sourceRoot = "apache-arrow-${version}/cpp";
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ boost python.pkgs.python python.pkgs.numpy ];
+
+  preConfigure = ''
+    substituteInPlace cmake_modules/FindBrotli.cmake --replace CMAKE_STATIC_LIBRARY CMAKE_SHARED_LIBRARY
+    substituteInPlace cmake_modules/FindLz4.cmake --replace CMAKE_STATIC_LIBRARY CMAKE_SHARED_LIBRARY
+    substituteInPlace cmake_modules/FindSnappy.cmake --replace CMAKE_STATIC_LIBRARY CMAKE_SHARED_LIBRARY
+  '';
+
+  BROTLI_HOME = symlinkJoin { name="brotli-wrap"; paths = [ brotli.lib brotli.dev ]; };
+  FLATBUFFERS_HOME = flatbuffers;
+  GTEST_HOME = gtest;
+  GFLAGS_HOME = gflags;
+  LZ4_HOME = symlinkJoin { name="lz4-wrap"; paths = [ lz4 lz4.dev ]; };
+  RAPIDJSON_HOME = rapidjson;
+  SNAPPY_HOME = symlinkJoin { name="snappy-wrap"; paths = [ snappy snappy.dev ]; };
+  ZLIB_HOME = symlinkJoin { name="zlib-wrap"; paths = [ zlib.dev zlib.static ]; };
+  ZSTD_HOME = zstd;
+
+  cmakeFlags = [
+    "-DARROW_PYTHON=ON"
+  ];
+
+  meta = {
+    description = "A  cross-language development platform for in-memory data";
+    homepage = https://arrow.apache.org/;
+    license = stdenv.lib.licenses.asl20;
+    platforms = stdenv.lib.platforms.unix;
+    maintainers = with stdenv.lib.maintainers; [ veprbl ];
+  };
+}
diff --git a/pkgs/development/libraries/asio/default.nix b/pkgs/development/libraries/asio/default.nix
index dae8657388f7..1126b4a7f2c9 100644
--- a/pkgs/development/libraries/asio/default.nix
+++ b/pkgs/development/libraries/asio/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl, boost, openssl}:
 
 stdenv.mkDerivation rec {
-  name = "asio-1.10.8";
+  name = "asio-1.12.1";
 
   src = fetchurl {
     url = "mirror://sourceforge/asio/${name}.tar.bz2";
-    sha256 = "0jgdl4fxw0hwy768rl3lhdc0czz7ak7czf3dg10j21pdpfpfvpi6";
+    sha256 = "0nln45662kg799ykvqx5m9z9qcsmadmgg6r5najryls7x16in2d9";
   };
 
   propagatedBuildInputs = [ boost ];
diff --git a/pkgs/development/libraries/aspell/default.nix b/pkgs/development/libraries/aspell/default.nix
index 0f6f5e8dd147..d0e93337a390 100644
--- a/pkgs/development/libraries/aspell/default.nix
+++ b/pkgs/development/libraries/aspell/default.nix
@@ -1,5 +1,6 @@
-{stdenv, fetchurl, perl
-, searchNixProfiles ? true}:
+{ stdenv, fetchurl, fetchpatch, perl
+, searchNixProfiles ? true
+}:
 
 stdenv.mkDerivation rec {
   name = "aspell-0.60.6.1";
@@ -9,13 +10,19 @@ stdenv.mkDerivation rec {
     sha256 = "1qgn5psfyhbrnap275xjfrzppf5a83fb67gpql0kfqv37al869gm";
   };
 
-  patchPhase = ''
+  patches = [
+    (fetchpatch { # remove in >= 0.60.7
+      name = "gcc-7.patch";
+      url = "https://github.com/GNUAspell/aspell/commit/8089fa02122fed0a.diff";
+      sha256 = "1b3p1zy2lqr2fknddckm58hyk95hw4scf6hzjny1v9iaic2p37ix";
+    })
+  ] ++ stdenv.lib.optional searchNixProfiles ./data-dirs-from-nix-profiles.patch;
+
+  postPatch = ''
     patch interfaces/cc/aspell.h < ${./clang.patch}
-  '' + stdenv.lib.optionalString searchNixProfiles ''
-    patch -p1 < ${./data-dirs-from-nix-profiles.patch}
   '';
 
-  buildInputs = [ perl ];
+  nativeBuildInputs = [ perl ];
 
   doCheck = true;
 
diff --git a/pkgs/development/libraries/aspell/dictionaries.nix b/pkgs/development/libraries/aspell/dictionaries.nix
index fc6b47e8a63c..096ac80e5a70 100644
--- a/pkgs/development/libraries/aspell/dictionaries.nix
+++ b/pkgs/development/libraries/aspell/dictionaries.nix
@@ -1,32 +1,113 @@
-{stdenv, fetchurl, aspell, which}:
+{lib, stdenv, fetchurl, aspell, which}:
+
+with lib;
+
+/* HOWTO:
+
+   * Add some of these to your profile or systemPackages.
+
+     ~~~~
+     environment.systemPackages = [
+       aspell
+       aspellDicts.en
+       aspellDicts.en-computers
+       aspellDicts.en-science
+     ];
+     ~~~~
+
+   * Rebuild and switch to the new profile.
+   * Add something like
+
+     ~~~~
+     master en_US
+     extra-dicts en-computers.rws
+     add-extra-dicts en_US-science.rws
+     ~~~~
+
+     to `/etc/aspell.conf` or `~/.aspell.conf`.
+   * Check that `aspell -a` starts without errors.
+   * (optional) Check your config with `aspell dump config | grep -vE '^(#|$)'`.
+   * Enjoy.
+
+*/
 
 let
 
   /* Function to compile an Aspell dictionary.  Fortunately, they all
      build in the exact same way. */
   buildDict =
-    {shortName, fullName, src, postInstall ? ""}:
+    {shortName, fullName, ...}@args:
 
-    stdenv.mkDerivation {
+    stdenv.mkDerivation ({
       name = "aspell-dict-${shortName}";
 
-      inherit src;
-
       buildInputs = [aspell which];
 
       dontAddPrefix = true;
 
       preBuild = "makeFlagsArray=(dictdir=$out/lib/aspell datadir=$out/lib/aspell)";
 
-      inherit postInstall;
-
       meta = {
         description = "Aspell dictionary for ${fullName}";
         platforms = stdenv.lib.platforms.all;
-      };
-    };
-
-in {
+      } // (args.meta or {});
+    } // removeAttrs args [ "meta" ]);
+
+  /* Function to compile txt dict files into Aspell dictionaries. */
+  buildTxtDict =
+    {langInputs ? [], ...}@args:
+    buildDict ({
+      propagatedUserEnvPackages = langInputs;
+
+      preBuild = ''
+        # Aspell can't handle multiple data-dirs
+        # Copy everything we might possibly need
+        ${concatMapStringsSep "\n" (p: ''
+          cp -a ${p}/lib/aspell/* .
+        '') ([ aspell ] ++ langInputs)}
+        export ASPELL_CONF="data-dir $(pwd)"
+
+        aspell-create() {
+          target=$1
+          shift
+          echo building $target
+          aspell create "$@" master ./$target.rws
+        }
+
+        words-only() {
+          awk -F'\t' '{print $1}' | sort | uniq
+        }
+
+        # drop comments
+        aspell-affix() {
+          words-only \
+            | grep -v '#' \
+            | aspell-create "$@"
+        }
+
+        # Hack: drop comments and words with affixes
+        aspell-plain() {
+          words-only \
+            | grep -v '#' \
+            | grep -v '/' \
+            | aspell-create "$@"
+        }
+
+        aspell-install() {
+          install -d $out/lib/aspell
+          for a in "$@"; do
+            echo installing $a
+            install -t $out/lib/aspell $a.rws
+          done
+        }
+      '';
+
+      phases = [ "preBuild" "buildPhase" "installPhase" ];
+    } // args);
+
+in rec {
+
+  ### Languages
 
   ca = buildDict {
     shortName = "ca-2.1.5-1";
@@ -212,6 +293,15 @@ in {
     };
   };
 
+  tr = buildDict {
+    shortName = "tr-0.50-0";
+    fullName = "Turkish";
+    src = fetchurl {
+      url = mirror://gnu/aspell/dict/tr/aspell-tr-0.50-0.tar.bz2;
+      sha256 = "0jpvpm96ga7s7rmsm6rbyrrr22b2dicxv2hy7ysv5y7bbq757ihb";
+    };
+  };
+
   uk = buildDict {
     shortName = "uk-1.4.0-0";
     fullName = "Ukrainian";
@@ -221,4 +311,53 @@ in {
     };
   };
 
+  ### Jargons
+
+  en-computers = buildTxtDict rec {
+    shortName = "en-computers";
+    fullName = "English Computer Jargon";
+
+    src = fetchurl {
+      url = https://mrsatterly.com/computer.dic;
+      sha256 = "1vzk7cdvcm9r1c6mgxpabrdcpvghdv9mjmnf6iq5wllcif5nsw2b";
+    };
+
+    langInputs = [ en ];
+
+    buildPhase = "cat $src | aspell-affix en-computers --dont-validate-words --lang=en";
+    installPhase = "aspell-install en-computers";
+
+    meta = {
+      homepage = https://mrsatterly.com/spelling.html;
+    };
+  };
+
+  en-science = buildTxtDict rec {
+    shortName = "en-science";
+    fullName = "English Scientific Jargon";
+
+    src1 = fetchurl {
+      url = http://jpetrie.net/wp-content/uploads/custom_scientific_US.txt;
+      sha256 = "1psqm094zl4prk2f8h18jv0d471hxykzd1zdnrlx7gzrzy6pz5r3";
+    };
+
+    src2 = fetchurl {
+      url = http://jpetrie.net/wp-content/uploads/custom_scientific_UK.txt;
+      sha256 = "17ss1sdr3k70zbyx2z9xf74345slrp41gbkpih8axrmg4x92fgm1";
+    };
+
+    langInputs = [ en ];
+
+    buildPhase = ''
+      cat $src1 | aspell-plain en_US-science --dont-validate-words --lang=en
+      cat $src2 | aspell-plain en_GB-science --dont-validate-words --lang=en
+    '';
+    installPhase = "aspell-install en_US-science en_GB-science";
+
+    meta = {
+      homepage = http://www.jpetrie.net/scientific-word-list-for-spell-checkersspelling-dictionaries/;
+    };
+
+  };
+
 }
diff --git a/pkgs/development/libraries/assimp/default.nix b/pkgs/development/libraries/assimp/default.nix
index e342d8ab6c09..219c8df803b7 100644
--- a/pkgs/development/libraries/assimp/default.nix
+++ b/pkgs/development/libraries/assimp/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "assimp-${version}";
-  version = "3.3.1";
+  version = "4.1.0";
 
   src = fetchFromGitHub{
     owner = "assimp";
     repo = "assimp";
     rev = "v${version}";
-    sha256 = "13y44fymj13h6alig0nqab91j2qch0yh9gq8yql2zz744ch2s5vc";
+    sha256 = "00g61g3ixmfszzjncpvm8x7gp2livaj4lmhbycjmrw4x3gfqlc4r";
   };
 
   buildInputs = [ cmake boost zlib ];
diff --git a/pkgs/development/libraries/at-spi2-atk/default.nix b/pkgs/development/libraries/at-spi2-atk/default.nix
index e2350cf2cd13..86f35d7f578e 100644
--- a/pkgs/development/libraries/at-spi2-atk/default.nix
+++ b/pkgs/development/libraries/at-spi2-atk/default.nix
@@ -1,20 +1,20 @@
 { stdenv, fetchurl, python, pkgconfig, popt, atk, libX11, libICE, xorg, libXi
-, intltool, dbus_glib, at_spi2_core, libSM }:
+, intltool, dbus-glib, at-spi2-core, libSM }:
 
 stdenv.mkDerivation rec {
   versionMajor = "2.26";
-  versionMinor = "0";
+  versionMinor = "1";
   moduleName   = "at-spi2-atk";
   name = "${moduleName}-${versionMajor}.${versionMinor}";
 
   src = fetchurl {
     url = "mirror://gnome/sources/${moduleName}/${versionMajor}/${name}.tar.xz";
-    sha256 = "d25e528e1406a10c7d9b675aa15e638bcbf0a122ca3681f655a30cce83272fb9";
+    sha256 = "0x9vc99ni46fg5dzlx67vbw0zqffr24gz8jvbdxbmzyvc5xw5w5l";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig intltool ];
   buildInputs = [ python popt atk libX11 libICE xorg.libXtst libXi
-                  intltool dbus_glib at_spi2_core libSM ];
+                  dbus-glib at-spi2-core libSM ];
 
   meta = with stdenv.lib; {
     platforms = platforms.unix;
diff --git a/pkgs/development/libraries/at-spi2-core/default.nix b/pkgs/development/libraries/at-spi2-core/default.nix
index 95de186a29a3..6715a59579b5 100644
--- a/pkgs/development/libraries/at-spi2-core/default.nix
+++ b/pkgs/development/libraries/at-spi2-core/default.nix
@@ -1,33 +1,29 @@
-{ stdenv, fetchurl, python, pkgconfig, popt, intltool, dbus_glib
+{ stdenv, fetchurl, python, pkgconfig, popt, gettext, dbus-glib
 , libX11, xextproto, libSM, libICE, libXtst, libXi, gobjectIntrospection }:
 
 stdenv.mkDerivation rec {
   versionMajor = "2.26";
-  versionMinor = "0";
+  versionMinor = "2";
   moduleName   = "at-spi2-core";
   name = "${moduleName}-${versionMajor}.${versionMinor}";
 
   src = fetchurl {
     url = "mirror://gnome/sources/${moduleName}/${versionMajor}/${name}.tar.xz";
-    sha256 = "511568a65fda11fdd5ba5d4adfd48d5d76810d0e6ba4f7460f1b2ec0dbbbc337";
+    sha256 = "0596ghkamkxgv08r4a1pdhm06qd5zzgcfqsv64038w9xbvghq3n8";
   };
 
   outputs = [ "out" "dev" ];
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig gettext gobjectIntrospection ];
   buildInputs = [
-    python popt  intltool dbus_glib
+    python popt dbus-glib
     libX11 xextproto libSM libICE libXtst libXi
-    gobjectIntrospection
   ];
 
   # 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 1574d8d037c7..63fd7a4986f9 100644
--- a/pkgs/development/libraries/atk/default.nix
+++ b/pkgs/development/libraries/atk/default.nix
@@ -1,28 +1,48 @@
-{ stdenv, fetchurl, pkgconfig, perl, glib, libintlOrEmpty, gobjectIntrospection }:
+{ stdenv, fetchurl, meson, ninja, gettext, pkgconfig, glib
+, fixDarwinDylibNames, gobjectIntrospection, gnome3
+}:
 
 let
-  ver_maj = "2.26";
-  ver_min = "0";
+  pname = "atk";
+  version = "2.28.1";
 in
+
 stdenv.mkDerivation rec {
-  name = "atk-${ver_maj}.${ver_min}";
+  name = "${pname}-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/atk/${ver_maj}/${name}.tar.xz";
-    sha256 = "eafe49d5c4546cb723ec98053290d7e0b8d85b3fdb123938213acb7bb4178827";
+    url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
+    sha256 = "1z7laf6qwv5zsqcnj222dm5f43c6f3liil0cgx4s4s62xjk1wfnd";
   };
 
-  enableParallelBuilding = true;
+  patches = [
+    # darwin linker arguments https://bugzilla.gnome.org/show_bug.cgi?id=794326
+    (fetchurl {
+      url = https://bugzilla.gnome.org/attachment.cgi?id=369680;
+      sha256 = "11v8fhpsbapa04ifb2268cga398vfk1nq8i628441632zjz1diwg";
+    })
+  ];
 
   outputs = [ "out" "dev" ];
 
-  buildInputs = libintlOrEmpty;
+  buildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
+
+  nativeBuildInputs = [ meson ninja pkgconfig gettext gobjectIntrospection ];
 
-  nativeBuildInputs = [ pkgconfig perl ];
+  propagatedBuildInputs = [
+    # Required by atk.pc
+    glib
+  ];
 
-  propagatedBuildInputs = [ glib gobjectIntrospection /*ToDo: why propagate*/ ];
+  NIX_LDFLAGS = if stdenv.isDarwin then "-lintl" else null;
 
-  #doCheck = true; # no checks in there (2.22.0)
+  doCheck = true;
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+    };
+  };
 
   meta = {
     description = "Accessibility toolkit";
diff --git a/pkgs/development/libraries/atkmm/default.nix b/pkgs/development/libraries/atkmm/default.nix
index e1cfb488be88..9ec9e6284f83 100644
--- a/pkgs/development/libraries/atkmm/default.nix
+++ b/pkgs/development/libraries/atkmm/default.nix
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "C++ wrappers for ATK accessibility toolkit";
     license = stdenv.lib.licenses.lgpl21Plus;
-    homepage = http://gtkmm.org;
+    homepage = https://gtkmm.org;
     platforms = stdenv.lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/attr/default.nix b/pkgs/development/libraries/attr/default.nix
index 6a94cb0c0e23..96fe5b89a18c 100644
--- a/pkgs/development/libraries/attr/default.nix
+++ b/pkgs/development/libraries/attr/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, gettext }:
+{ stdenv, fetchurl, gettext, hostPlatform }:
 
 stdenv.mkDerivation rec {
   name = "attr-2.4.47";
@@ -12,13 +12,22 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ gettext ];
 
-  configureFlags = "MAKE=make MSGFMT=msgfmt MSGMERGE=msgmerge XGETTEXT=xgettext ECHO=echo SED=sed AWK=gawk";
+  configureFlags = [ "MAKE=make" "MSGFMT=msgfmt" "MSGMERGE=msgmerge" "XGETTEXT=xgettext" "ECHO=echo" "SED=sed" "AWK=gawk" ];
 
-  installTargets = "install install-lib install-dev";
+  installTargets = [ "install" "install-lib" "install-dev" ];
 
-  meta = {
-    homepage = http://savannah.nongnu.org/projects/attr/;
+  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";
-    platforms = stdenv.lib.platforms.linux;
+    platforms = platforms.linux;
+    license = licenses.gpl2Plus;
   };
 }
diff --git a/pkgs/development/libraries/attr/fix-headers-musl.patch b/pkgs/development/libraries/attr/fix-headers-musl.patch
new file mode 100644
index 000000000000..e969f640eeef
--- /dev/null
+++ b/pkgs/development/libraries/attr/fix-headers-musl.patch
@@ -0,0 +1,54 @@
+--- attr-2.4.47/include/xattr.h
++++ attr-2.4.47/include/xattr.h
+@@ -31,33 +31,37 @@
+ #define XATTR_REPLACE 0x2       /* set value, fail if attr does not exist */
+ 
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ 
+ extern int setxattr (const char *__path, const char *__name,
+-		      const void *__value, size_t __size, int __flags) __THROW;
++		      const void *__value, size_t __size, int __flags);
+ extern int lsetxattr (const char *__path, const char *__name,
+-		      const void *__value, size_t __size, int __flags) __THROW;
++		      const void *__value, size_t __size, int __flags);
+ extern int fsetxattr (int __filedes, const char *__name,
+-		      const void *__value, size_t __size, int __flags) __THROW;
++		      const void *__value, size_t __size, int __flags);
+ 
+ extern ssize_t getxattr (const char *__path, const char *__name,
+-				void *__value, size_t __size) __THROW;
++				void *__value, size_t __size);
+ extern ssize_t lgetxattr (const char *__path, const char *__name,
+-				void *__value, size_t __size) __THROW;
++				void *__value, size_t __size);
+ extern ssize_t fgetxattr (int __filedes, const char *__name,
+-				void *__value, size_t __size) __THROW;
++				void *__value, size_t __size);
+ 
+ extern ssize_t listxattr (const char *__path, char *__list,
+-				size_t __size) __THROW;
++				size_t __size);
+ extern ssize_t llistxattr (const char *__path, char *__list,
+-				size_t __size) __THROW;
++				size_t __size);
+ extern ssize_t flistxattr (int __filedes, char *__list,
+-				size_t __size) __THROW;
++				size_t __size);
+ 
+-extern int removexattr (const char *__path, const char *__name) __THROW;
+-extern int lremovexattr (const char *__path, const char *__name) __THROW;
+-extern int fremovexattr (int __filedes,   const char *__name) __THROW;
++extern int removexattr (const char *__path, const char *__name);
++extern int lremovexattr (const char *__path, const char *__name);
++extern int fremovexattr (int __filedes,   const char *__name);
+ 
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* __XATTR_H__ */
diff --git a/pkgs/development/libraries/aubio/default.nix b/pkgs/development/libraries/aubio/default.nix
index e13b102c7887..51ae14be4046 100644
--- a/pkgs/development/libraries/aubio/default.nix
+++ b/pkgs/development/libraries/aubio/default.nix
@@ -1,23 +1,23 @@
 { stdenv, fetchurl, alsaLib, fftw, libjack2, libsamplerate
-, libsndfile, pkgconfig, python3
+, libsndfile, pkgconfig, python
 }:
 
 stdenv.mkDerivation rec {
-  name = "aubio-0.4.5";
+  name = "aubio-0.4.6";
 
   src = fetchurl {
     url = "http://aubio.org/pub/${name}.tar.bz2";
-    sha256 = "1xkshac4wdm7r5sc04c38d6lmvv5sk4qrb5r1yy0xgsgdx781hkh";
+    sha256 = "1yvwskahx1bf3x2fvi6cwah1ay11iarh79fjlqz8s887y3hkpixx";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ alsaLib fftw libjack2 libsamplerate libsndfile python3 ];
+  nativeBuildInputs = [ pkgconfig python ];
+  buildInputs = [ alsaLib fftw libjack2 libsamplerate libsndfile ];
 
-  configurePhase = "${python3.interpreter} waf configure --prefix=$out";
+  configurePhase = "python waf configure --prefix=$out";
 
-  buildPhase = "${python3.interpreter} waf";
+  buildPhase = "python waf";
 
-  installPhase = "${python3.interpreter} waf install";
+  installPhase = "python waf install";
 
   meta = with stdenv.lib; {
     description = "Library for audio labelling";
diff --git a/pkgs/development/libraries/audio/jamomacore/default.nix b/pkgs/development/libraries/audio/jamomacore/default.nix
index 7057b020d429..4e316ff1c991 100644
--- a/pkgs/development/libraries/audio/jamomacore/default.nix
+++ b/pkgs/development/libraries/audio/jamomacore/default.nix
@@ -20,5 +20,6 @@ stdenv.mkDerivation rec {
     license = stdenv.lib.licenses.bsd3;
     maintainers = [ stdenv.lib.maintainers.magnetophon ];
     platforms = stdenv.lib.platforms.linux;
+    broken = true; # 2018-04-10
   };
 }
diff --git a/pkgs/development/libraries/audio/libgme/default.nix b/pkgs/development/libraries/audio/libgme/default.nix
index 9a87e31cbd29..ac6f0470a0a8 100644
--- a/pkgs/development/libraries/audio/libgme/default.nix
+++ b/pkgs/development/libraries/audio/libgme/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchFromBitbucket, cmake }:
 let
-  version = "0.6.1";
+  version = "0.6.2";
 in stdenv.mkDerivation {
   name = "libgme-${version}";
 
@@ -16,7 +16,7 @@ in stdenv.mkDerivation {
     owner = "mpyne";
     repo = "game-music-emu";
     rev = version;
-    sha256 = "04vwpv3pmjcil1jw5vcnlg45nch5awqs06y3xqdlp3ibx5i4k199";
+    sha256 = "00vlbfk5h99dq5rbwxk20dv72dig6wdwpgf83q451avsscky0jvk";
   };
 
   buildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/audio/lv2/unstable.nix b/pkgs/development/libraries/audio/lv2/unstable.nix
index 595dd9e0a536..4a632d07006b 100644
--- a/pkgs/development/libraries/audio/lv2/unstable.nix
+++ b/pkgs/development/libraries/audio/lv2/unstable.nix
@@ -2,12 +2,12 @@
 
 stdenv.mkDerivation rec {
   name = "lv2-unstable-${version}";
-  version = "2016-10-23";
+  version = "2017-07-08";
 
   src = fetchgit {
     url = "http://lv2plug.in/git/cgit.cgi/lv2.git";
-    rev = "b36868f3b96a436961c0c51b5b2dd71d05da9b12";
-    sha256 = "1sx39j0gary2nayzv7xgqcra7z1rcw9hrafkji05aksdwf7q0pdm";
+    rev = "39c7c726cd52b2863fcea356cafe1bcab2ba7f37";
+    sha256 = "1gp2rd99dfmpibvpixrqn115mrhybzf3if3h8bssf6siyi13f29r";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/audio/raul/default.nix b/pkgs/development/libraries/audio/raul/default.nix
index b0b0c6bc59af..63e3ae36028b 100644
--- a/pkgs/development/libraries/audio/raul/default.nix
+++ b/pkgs/development/libraries/audio/raul/default.nix
@@ -2,12 +2,12 @@
 
 stdenv.mkDerivation rec {
   name = "raul-unstable-${rev}";
-  rev = "2016-09-20";
+  rev = "2017-07-23";
 
   src = fetchgit {
     url = "http://git.drobilla.net/cgit.cgi/raul.git";
-    rev = "f8bf77d3c3b77830aedafb9ebb5cdadfea7ed07a";
-    sha256 = "1lby508fb0n8ks6iz959sh18fc37br39d6pbapwvbcw5nckdrxwj";
+    rev = "4db870b2b20b0a608ec0283139056b836c5b1624";
+    sha256 = "04fajrass3ymr72flx5js5vxc601ccrmx8ny8scp0rw7j0igyjdr";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/audio/suil/default.nix b/pkgs/development/libraries/audio/suil/default.nix
index b2cfb0be8bec..63f43ac7a2c0 100644
--- a/pkgs/development/libraries/audio/suil/default.nix
+++ b/pkgs/development/libraries/audio/suil/default.nix
@@ -8,12 +8,12 @@ assert !(withQt4 && withQt5);
 
 stdenv.mkDerivation rec {
   pname = "suil";
-  version = "0.8.4";
+  version = "0.10.0";
   name = "${pname}-qt${if withQt4 then "4" else "5"}-${version}";
 
   src = fetchurl {
     url = "http://download.drobilla.net/${pname}-${version}.tar.bz2";
-    sha256 = "1kji3lhha26qr6xm9j8ic5c40zbrrb5qnwm2qxzmsfxgmrz29wkf";
+    sha256 = "0j489gm3fhnmwmbgw30bvd4byw1vsy4yazdlnji8jzhcz0qwb5cq";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/audio/vamp/default.nix b/pkgs/development/libraries/audio/vamp/default.nix
index 8cae07e29490..8098ac9f3efb 100644
--- a/pkgs/development/libraries/audio/vamp/default.nix
+++ b/pkgs/development/libraries/audio/vamp/default.nix
@@ -18,7 +18,7 @@ rec {
 
     meta = with stdenv.lib; {
       description = "Audio processing plugin system for plugins that extract descriptive information from audio data";
-      homepage = http://sourceforge.net/projects/vamp;
+      homepage = https://sourceforge.net/projects/vamp;
       license = licenses.bsd3;
       maintainers = [ maintainers.goibhniu maintainers.marcweber ];
       platforms = platforms.linux;
diff --git a/pkgs/development/libraries/audiofile/default.nix b/pkgs/development/libraries/audiofile/default.nix
index a7576e07f2dd..182471acf4ae 100644
--- a/pkgs/development/libraries/audiofile/default.nix
+++ b/pkgs/development/libraries/audiofile/default.nix
@@ -1,4 +1,14 @@
-{ stdenv, fetchurl, alsaLib, AudioUnit, CoreServices }:
+{ stdenv, fetchurl, fetchpatch, alsaLib, AudioUnit, CoreServices }:
+
+let
+
+  fetchDebianPatch = { name, debname, sha256 }:
+    fetchpatch {
+      inherit sha256 name;
+      url = "https://salsa.debian.org/multimedia-team/audiofile/raw/debian/0.3.6-4/debian/patches/${debname}";
+    };
+
+in
 
 stdenv.mkDerivation rec {
   name = "audiofile-0.3.6";
@@ -15,7 +25,46 @@ stdenv.mkDerivation rec {
     sha256 = "0rb927zknk9kmhprd8rdr4azql4gn2dp75a36iazx2xhkbqhvind";
   };
 
-  patches = [ ./CVE-2015-7747.patch ./gcc-6.patch ];
+  patches = [
+    ./gcc-6.patch
+    ./CVE-2015-7747.patch
+
+    (fetchDebianPatch {
+      name = "CVE-2017-6829.patch";
+      debname = "04_clamp-index-values-to-fix-index-overflow-in-IMA.cpp.patch";
+      sha256 = "04qxl51i64c53v69q2kx61qdq474f4vapk8rq97cipj7yrar392m";
+    })
+    (fetchDebianPatch {
+      name = "CVE-2017-6827+CVE-2017-6828+CVE-2017-6832+CVE-2017-6835+CVE-2017-6837.patch";
+      debname = "05_Always-check-the-number-of-coefficients.patch";
+      sha256 = "1ih03kfkabffi6ymp6832q470i28rsds78941vzqlshnqjb2nnxw";
+    })
+    (fetchDebianPatch {
+      name = "CVE-2017-6839.patch";
+      debname = "06_Check-for-multiplication-overflow-in-MSADPCM-decodeSam.patch";
+      sha256 = "0a8s2z8rljlj03p7l1is9s4fml8vyzvyvfrh1m6xj5a8vbi635d0";
+    })
+    (fetchDebianPatch {
+      name = "CVE-2017-6830+CVE-2017-6834+CVE-2017-6836+CVE-2017-6838.patch";
+      debname = "07_Check-for-multiplication-overflow-in-sfconvert.patch";
+      sha256 = "0rfba8rkasl5ycvc0kqlzinkl3rvyrrjvjhpc45h423wmjk2za2l";
+    })
+    (fetchDebianPatch {
+      name = "audiofile-fix-multiplyCheckOverflow-signature.patch";
+      debname = "08_Fix-signature-of-multiplyCheckOverflow.-It-returns-a-b.patch";
+      sha256 = "032p5jqp7q7jgc5axdnazz00zm7hd26z6m5j55ifs0sykr5lwldb";
+    })
+    (fetchDebianPatch {
+      name = "CVE-2017-6831.patch";
+      debname = "09_Actually-fail-when-error-occurs-in-parseFormat.patch";
+      sha256 = "0csikmj8cbiy6cigg0rmh67jrr0sgm56dfrnrxnac3m9635nxlac";
+    })
+    (fetchDebianPatch {
+      name = "CVE-2017-6833.patch";
+      debname = "10_Check-for-division-by-zero-in-BlockCodec-runPull.patch";
+      sha256 = "1rlislkjawq98bbcf1dgl741zd508wwsg85r37ca7pfdf6wgl6z7";
+    })
+  ];
 
   meta = with stdenv.lib; {
     description = "Library for reading and writing audio files in various formats";
diff --git a/pkgs/development/libraries/avro-c/default.nix b/pkgs/development/libraries/avro-c/default.nix
new file mode 100644
index 000000000000..8b787855c4de
--- /dev/null
+++ b/pkgs/development/libraries/avro-c/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, bash, cmake, fetchurl, pkgconfig, jansson, zlib }:
+
+let
+  version = "1.8.2";
+in stdenv.mkDerivation rec {
+  name = "avro-c-${version}";
+
+  src = fetchurl {
+    url = "mirror://apache/avro/avro-${version}/c/avro-c-${version}.tar.gz";
+    sha256 = "03pixl345kkpn1jds03rpdcwjabi41rgdzi8f7y93gcg5cmrhfa6";
+  };
+
+  postPatch = ''
+    patchShebangs .
+  '';
+
+  nativeBuildInputs = [ pkgconfig cmake ];
+
+  buildInputs = [ jansson zlib ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "A C library which implements parts of the Avro Specification";
+    homepage = https://avro.apache.org/;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ lblasc ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/aws-sdk-cpp/default.nix b/pkgs/development/libraries/aws-sdk-cpp/default.nix
index fe06bcfab6d3..0ab102a5ec43 100644
--- a/pkgs/development/libraries/aws-sdk-cpp/default.nix
+++ b/pkgs/development/libraries/aws-sdk-cpp/default.nix
@@ -3,6 +3,7 @@
   apis ? ["*"]
 , # Whether to enable AWS' custom memory management.
   customMemoryManagement ? true
+, darwin
 }:
 
 let
@@ -14,13 +15,13 @@ let
         else throw "Unsupported system!";
 in stdenv.mkDerivation rec {
   name = "aws-sdk-cpp-${version}";
-  version = "1.1.18";
+  version = "1.4.33";
 
   src = fetchFromGitHub {
     owner = "awslabs";
     repo = "aws-sdk-cpp";
     rev = version;
-    sha256 = "1i85zpns3gj5by45ppg4rfk9csix8mjazpyj6dqic40b2wshnw8c";
+    sha256 = "0fl4m3vsycd35gkrrlqsjlv0myh12bgb0jg3pm548l19qwrc0pm7";
   };
 
   # FIXME: might be nice to put different APIs in different outputs
@@ -28,10 +29,16 @@ in stdenv.mkDerivation rec {
   outputs = [ "out" "dev" ];
   separateDebugInfo = stdenv.isLinux;
 
-  buildInputs = [ cmake curl ];
+  nativeBuildInputs = [ cmake curl ];
+  buildInputs = [ zlib curl openssl ]
+    ++ lib.optionals (stdenv.isDarwin &&
+                        ((builtins.elem "text-to-speech" apis) ||
+                         (builtins.elem "*" apis)))
+         (with darwin.apple_sdk.frameworks; [ CoreAudio AudioToolbox ]);
 
   cmakeFlags =
     lib.optional (!customMemoryManagement) "-DCUSTOM_MEMORY_MANAGEMENT=0"
+    ++ lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) "-DENABLE_TESTING=OFF"
     ++ lib.optional (apis != ["*"])
       "-DBUILD_ONLY=${lib.concatStringsSep ";" apis}";
 
@@ -51,9 +58,7 @@ in stdenv.mkDerivation rec {
       rm aws-cpp-sdk-core-tests/aws/auth/AWSCredentialsProviderTest.cpp
     '';
 
-  NIX_LDFLAGS = lib.concatStringsSep " " (
-    (map (pkg: "-rpath ${lib.getOutput "lib" pkg}/lib"))
-      [ curl openssl zlib stdenv.cc.cc ]);
+  NIX_CFLAGS_COMPILE = [ "-Wno-error=noexcept-type" ];
 
   meta = {
     description = "A C++ interface for Amazon Web Services";
diff --git a/pkgs/development/libraries/babl/default.nix b/pkgs/development/libraries/babl/default.nix
index 133b39d07974..285f4dea802a 100644
--- a/pkgs/development/libraries/babl/default.nix
+++ b/pkgs/development/libraries/babl/default.nix
@@ -1,17 +1,20 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "babl-0.1.34";
+  name = "babl-0.1.46";
 
   src = fetchurl {
     url = "http://ftp.gtk.org/pub/babl/0.1/${name}.tar.bz2";
-    sha256 = "0nwakj313l2dh5npx18avkg4z17i2prkxbl6vj547a08n6ry1gsy";
+    sha256 = "0nwyhvfca6m35wjcccvwca7fcihzgdfyc012qi703y5d3cxl1hmv";
   };
 
-  meta = with stdenv.lib; { 
+  doCheck = true;
+
+  meta = with stdenv.lib; {
     description = "Image pixel format conversion library";
     homepage = http://gegl.org/babl/;
     license = licenses.gpl3;
+    maintainers = with stdenv.lib.maintainers; [ jtojnar ];
     platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/bctoolbox/default.nix b/pkgs/development/libraries/bctoolbox/default.nix
index 69faf913abfe..5439c7657e08 100644
--- a/pkgs/development/libraries/bctoolbox/default.nix
+++ b/pkgs/development/libraries/bctoolbox/default.nix
@@ -2,13 +2,13 @@
 stdenv.mkDerivation rec {
   name = "${baseName}-${version}";
   baseName = "bctoolbox";
-  version = "0.2.0";
+  version = "0.6.0";
   buildInputs = [cmake mbedtls bcunit srtp];
   src = fetchFromGitHub {
     owner = "BelledonneCommunications";
     repo = "${baseName}";
     rev = "${version}";
-    sha256 = "09mjqdfjxy4jy1z68b2i99hgkbnhhk7vnbfhj9sdpd1p3jk2ha33";
+    sha256 = "1cxx243wyzkd4xnvpyqf97n0rjhfckpvw1vhwnbwshq3q6fra909";
   };
 
   meta = {
diff --git a/pkgs/development/libraries/beignet/default.nix b/pkgs/development/libraries/beignet/default.nix
index 2484e287016b..02c67d7dbf8b 100644
--- a/pkgs/development/libraries/beignet/default.nix
+++ b/pkgs/development/libraries/beignet/default.nix
@@ -12,7 +12,7 @@
 , libXext
 , python3
 , ocl-icd
-, mesa_noglu
+, libGL
 , makeWrapper
 , beignet
 }:
@@ -46,7 +46,7 @@ stdenv.mkDerivation rec {
     libXdmcp
     libXdamage
     ocl-icd
-    mesa_noglu
+    libGL
   ];
 
   nativeBuildInputs = [
diff --git a/pkgs/development/libraries/belcard/default.nix b/pkgs/development/libraries/belcard/default.nix
new file mode 100644
index 000000000000..8805dc74a26c
--- /dev/null
+++ b/pkgs/development/libraries/belcard/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl, cmake, fetchFromGitHub, bctoolbox, belr }:
+
+stdenv.mkDerivation rec {
+  baseName = "belcard";
+  version = "1.0.2";
+  name = "${baseName}-${version}";
+
+  src = fetchFromGitHub {
+    owner = "BelledonneCommunications";
+    repo = "${baseName}";
+    rev = "${version}";
+    sha256 = "1pwji83vpsdrfma24rnj3rz1x0a0g6zk3v4xjnip7zf2ys3zcnlk";
+  };
+
+  buildInputs = [ bctoolbox belr ];
+  nativeBuildInputs = [ cmake ];
+
+  meta = with stdenv.lib;{
+    description = "Belcard is a C++ library to manipulate VCard standard format";
+    homepage = https://github.com/BelledonneCommunications/belcard;
+    license = licenses.lgpl21;
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/belle-sip/default.nix b/pkgs/development/libraries/belle-sip/default.nix
index b055b2358a54..003fce0ea8c3 100644
--- a/pkgs/development/libraries/belle-sip/default.nix
+++ b/pkgs/development/libraries/belle-sip/default.nix
@@ -4,14 +4,14 @@
 
 stdenv.mkDerivation rec {
   baseName = "belle-sip";
-  version = "1.5.0";
+  version = "1.6.3";
   name = "${baseName}-${version}";
 
   src = fetchFromGitHub {
     owner = "BelledonneCommunications";
     repo = "${baseName}";
     rev = "${version}";
-    sha256 = "0hnm64hwgq003wicz6c485fryjfhi820fgin8ndknq60kvwxsrzn";
+    sha256 = "0q70db1klvhca1af29bm9paka3gyii5hfbzrj4178gclsg7cj8fk";
   };
 
   nativeBuildInputs = [ jre cmake ];
diff --git a/pkgs/development/libraries/belr/default.nix b/pkgs/development/libraries/belr/default.nix
new file mode 100644
index 000000000000..214abb21f2cd
--- /dev/null
+++ b/pkgs/development/libraries/belr/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl, cmake, fetchFromGitHub, bctoolbox }:
+
+stdenv.mkDerivation rec {
+  baseName = "belr";
+  version = "0.1.3";
+  name = "${baseName}-${version}";
+
+  src = fetchFromGitHub {
+    owner = "BelledonneCommunications";
+    repo = "${baseName}";
+    rev = "${version}";
+    sha256 = "0mf8lsyq1z3b5p47c00lnwc8n7v9nzs1fd2g9c9hnz6fjd2ka44w";
+  };
+
+  buildInputs = [ bctoolbox ];
+  nativeBuildInputs = [ cmake ];
+
+  meta = with stdenv.lib;{
+    description = "Belr is Belledonne Communications' language recognition library";
+    homepage = https://github.com/BelledonneCommunications/belr;
+    license = licenses.lgpl21;
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/bobcat/default.nix b/pkgs/development/libraries/bobcat/default.nix
index 9805930c7bfa..dd7d6a348671 100644
--- a/pkgs/development/libraries/bobcat/default.nix
+++ b/pkgs/development/libraries/bobcat/default.nix
@@ -39,6 +39,5 @@ stdenv.mkDerivation rec {
     homepage = https://fbb-git.github.io/bobcat/;
     license = licenses.gpl3;
     platforms = platforms.linux;
-    maintainers = with maintainers; [ nckx ];
   };
 }
diff --git a/pkgs/development/libraries/boehm-gc/default.nix b/pkgs/development/libraries/boehm-gc/default.nix
index 1ac96e2b4f04..d4e91deb7449 100644
--- a/pkgs/development/libraries/boehm-gc/default.nix
+++ b/pkgs/development/libraries/boehm-gc/default.nix
@@ -1,13 +1,17 @@
-{ lib, stdenv, fetchurl, pkgconfig, libatomic_ops, enableLargeConfig ? false
+{ lib, stdenv, fetchurl, fetchpatch, pkgconfig, libatomic_ops, enableLargeConfig ? false
 , buildPlatform, hostPlatform
 }:
 
 stdenv.mkDerivation rec {
-  name = "boehm-gc-7.6.0";
+  name = "boehm-gc-${version}";
+  version = "7.6.4";
 
   src = fetchurl {
-    url = http://www.hboehm.info/gc/gc_source/gc-7.6.0.tar.gz;
-    sha256 = "143x7g0d0k6250ai6m2x3l4y352mzizi4wbgrmahxscv2aqjhjm1";
+    urls = [
+      "http://www.hboehm.info/gc/gc_source/gc-${version}.tar.gz"
+      "https://github.com/ivmai/bdwgc/releases/download/v${version}/gc-${version}.tar.gz"
+    ];
+    sha256 = "076dzsqqyxd3nlzs0z277vvhqjp8nv5dqi763s0m90zr6ljiyk5r";
   };
 
   buildInputs = [ libatomic_ops ];
@@ -16,20 +20,28 @@ stdenv.mkDerivation rec {
   outputs = [ "out" "dev" "doc" ];
   separateDebugInfo = stdenv.isLinux;
 
+  preConfigure = stdenv.lib.optionalString (stdenv.hostPlatform.libc == "musl") ''
+    export NIX_CFLAGS_COMPILE+="-D_GNU_SOURCE -DUSE_MMAP -DHAVE_DL_ITERATE_PHDR"
+  '';
+
+  patches = [ (fetchpatch {
+    url = "https://raw.githubusercontent.com/gentoo/musl/85b6a600996bdd71162b357e9ba93d8559342432/dev-libs/boehm-gc/files/boehm-gc-7.6.0-sys_select.patch";
+    sha256 = "1gydwlklvci30f5dpp5ccw2p2qpph5y41r55wx9idamjlq66fbb3";
+  }) ] ++
+    # https://github.com/ivmai/bdwgc/pull/208
+    lib.optional hostPlatform.isRiscV ./riscv.patch;
+
   configureFlags =
     [ "--enable-cplusplus" ]
-    ++ lib.optional enableLargeConfig "--enable-large-config";
+    ++ lib.optional enableLargeConfig "--enable-large-config"
+    ++ lib.optional (stdenv.hostPlatform.libc == "musl") "--disable-static";
 
-  doCheck = stdenv.buildPlatform == stdenv.hostPlatform;
+  doCheck = true; # not cross;
 
   # Don't run the native `strip' when cross-compiling.
   dontStrip = hostPlatform != buildPlatform;
 
-  postInstall =
-    ''
-      mkdir -p $out/share/doc
-      mv $out/share/gc $out/share/doc/gc
-    '';
+  enableParallelBuilding = true;
 
   meta = {
     description = "The Boehm-Demers-Weiser conservative garbage collector for C and C++";
diff --git a/pkgs/development/libraries/boehm-gc/riscv.patch b/pkgs/development/libraries/boehm-gc/riscv.patch
new file mode 100644
index 000000000000..249137d0a0dc
--- /dev/null
+++ b/pkgs/development/libraries/boehm-gc/riscv.patch
@@ -0,0 +1,53 @@
+diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h
+index a8e55dd2..439cc88d 100644
+--- a/include/private/gcconfig.h
++++ b/include/private/gcconfig.h
+@@ -650,6 +650,15 @@
+ #   endif
+ #   define mach_type_known
+ # endif
++# if defined(__riscv) && defined(LINUX)
++#   if __riscv_xlen == 32
++#     define RISCV32
++#     define mach_type_known
++#   elif __riscv_xlen == 64
++#     define RISCV64
++#     define mach_type_known
++#   endif
++# endif
+ 
+ # if defined(SN_TARGET_PSP2)
+ #   define mach_type_known
+@@ -2970,6 +2979,32 @@
+ #   endif
+ # endif
+ 
++# ifdef RISCV32
++#   define CPP_WORDSZ 32
++#   define MACH_TYPE "RISC-V 32"
++#   define ALIGNMENT 4
++#   ifdef LINUX
++#     define OS_TYPE "LINUX"
++      extern int __data_start[];
++#     define DATASTART ((ptr_t)__data_start)
++#     define LINUX_STACKBOTTOM
++#     define DYNAMIC_LOADING
++#   endif
++# endif
++
++# ifdef RISCV64
++#   define CPP_WORDSZ 64
++#   define MACH_TYPE "RISC-V 64"
++#   define ALIGNMENT 8
++#   ifdef LINUX
++#     define OS_TYPE "LINUX"
++      extern int __data_start[];
++#     define DATASTART ((ptr_t)__data_start)
++#     define LINUX_STACKBOTTOM
++#     define DYNAMIC_LOADING
++#   endif
++# endif
++
+ #if defined(__GLIBC__) && !defined(DONT_USE_LIBC_PRIVATES)
+   /* Use glibc's stack-end marker. */
+ # define USE_LIBC_PRIVATES
diff --git a/pkgs/development/libraries/boolstuff/default.nix b/pkgs/development/libraries/boolstuff/default.nix
index 0f899e4324c1..9ec27d3e9ebc 100644
--- a/pkgs/development/libraries/boolstuff/default.nix
+++ b/pkgs/development/libraries/boolstuff/default.nix
@@ -3,11 +3,11 @@
 let baseurl = "https://perso.b2b2c.ca/~sarrazip/dev"; in
 
 stdenv.mkDerivation rec {
-  name = "boolstuff-0.1.15";
+  name = "boolstuff-0.1.16";
 
   src = fetchurl {
     url = "${baseurl}/${name}.tar.gz";
-    sha256 = "1mzw4368hqw0b6xr01yqcbs9jk9ma3qq9hk3iqxmkiwqqxgirgln";
+    sha256 = "10qynbyw723gz2vrvn4xk2var172kvhlz3l3l80qbdsfb3d12wn0";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/boost/1.59.nix b/pkgs/development/libraries/boost/1.59.nix
index 2666b1d6c5d2..603d7883c647 100644
--- a/pkgs/development/libraries/boost/1.59.nix
+++ b/pkgs/development/libraries/boost/1.59.nix
@@ -8,33 +8,33 @@ callPackage ./generic.nix (args // rec {
     sha256 = "1jj1aai5rdmd72g90a3pd8sw9vi32zad46xv5av8fhnr48ir6ykj";
   };
 
-  patches = if stdenv.isCygwin then [
-      ./cygwin-fedora-boost-1.50.0-fix-non-utf8-files.patch
-      ./cygwin-fedora-boost-1.50.0-pool.patch
-      ./cygwin-fedora-boost-1.57.0-mpl-print.patch
-      ./cygwin-fedora-boost-1.57.0-spirit-unused_typedef.patch
-      ./cygwin-fedora-boost-1.54.0-locale-unused_typedef.patch
-      ./cygwin-fedora-boost-1.54.0-python-unused_typedef.patch
-      ./cygwin-fedora-boost-1.57.0-pool-test_linking.patch
-      ./cygwin-fedora-boost-1.54.0-pool-max_chunks_shadow.patch
-      ./cygwin-fedora-boost-1.57.0-signals2-weak_ptr.patch
-      ./cygwin-fedora-boost-1.57.0-uuid-comparison.patch
-      ./cygwin-fedora-boost-1.57.0-move-is_class.patch
-      ./cygwin-1.40.0-cstdint-cygwin.patch
-      ./cygwin-1.57.0-asio-cygwin.patch
-      ./cygwin-1.55.0-asio-MSG_EOR.patch
-      ./cygwin-1.57.0-config-cygwin.patch
-      ./cygwin-1.57.0-context-cygwin.patch
-      ./cygwin-1.57.0-filesystem-cygwin.patch
-      ./cygwin-1.55.0-interlocked-cygwin.patch
-      ./cygwin-1.40.0-iostreams-cygwin.patch
-      ./cygwin-1.57.0-locale-cygwin.patch
-      ./cygwin-1.57.0-log-cygwin.patch
-      ./cygwin-1.40.0-python-cygwin.patch
-      ./cygwin-1.40.0-regex-cygwin.patch
-      ./cygwin-1.57.0-smart_ptr-cygwin.patch
-      ./cygwin-1.57.0-system-cygwin.patch
-      ./cygwin-1.45.0-jam-cygwin.patch
-      ./cygwin-1.50.0-jam-pep3149.patch
-    ] else null;
+  patches = stdenv.lib.optionals stdenv.isCygwin [
+    ./cygwin-fedora-boost-1.50.0-fix-non-utf8-files.patch
+    ./cygwin-fedora-boost-1.50.0-pool.patch
+    ./cygwin-fedora-boost-1.57.0-mpl-print.patch
+    ./cygwin-fedora-boost-1.57.0-spirit-unused_typedef.patch
+    ./cygwin-fedora-boost-1.54.0-locale-unused_typedef.patch
+    ./cygwin-fedora-boost-1.54.0-python-unused_typedef.patch
+    ./cygwin-fedora-boost-1.57.0-pool-test_linking.patch
+    ./cygwin-fedora-boost-1.54.0-pool-max_chunks_shadow.patch
+    ./cygwin-fedora-boost-1.57.0-signals2-weak_ptr.patch
+    ./cygwin-fedora-boost-1.57.0-uuid-comparison.patch
+    ./cygwin-fedora-boost-1.57.0-move-is_class.patch
+    ./cygwin-1.40.0-cstdint-cygwin.patch
+    ./cygwin-1.57.0-asio-cygwin.patch
+    ./cygwin-1.55.0-asio-MSG_EOR.patch
+    ./cygwin-1.57.0-config-cygwin.patch
+    ./cygwin-1.57.0-context-cygwin.patch
+    ./cygwin-1.57.0-filesystem-cygwin.patch
+    ./cygwin-1.55.0-interlocked-cygwin.patch
+    ./cygwin-1.40.0-iostreams-cygwin.patch
+    ./cygwin-1.57.0-locale-cygwin.patch
+    ./cygwin-1.57.0-log-cygwin.patch
+    ./cygwin-1.40.0-python-cygwin.patch
+    ./cygwin-1.40.0-regex-cygwin.patch
+    ./cygwin-1.57.0-smart_ptr-cygwin.patch
+    ./cygwin-1.57.0-system-cygwin.patch
+    ./cygwin-1.45.0-jam-cygwin.patch
+    ./cygwin-1.50.0-jam-pep3149.patch
+  ];
 })
diff --git a/pkgs/development/libraries/boost/1.66.nix b/pkgs/development/libraries/boost/1.66.nix
new file mode 100644
index 000000000000..02cf511a6fdf
--- /dev/null
+++ b/pkgs/development/libraries/boost/1.66.nix
@@ -0,0 +1,13 @@
+{ stdenv, callPackage, fetchurl, hostPlatform, buildPlatform, ... } @ args:
+
+callPackage ./generic.nix (args // rec {
+  version = "1.66_0";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/boost/boost_1_66_0.tar.bz2";
+    # SHA256 from http://www.boost.org/users/history/version_1_66_0.html
+    sha256 = "5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9";
+  };
+
+  toolset = if stdenv.cc.isClang then "clang" else null;
+})
diff --git a/pkgs/development/libraries/boost/generic.nix b/pkgs/development/libraries/boost/generic.nix
index 3f9ae113f849..14ea512afbd2 100644
--- a/pkgs/development/libraries/boost/generic.nix
+++ b/pkgs/development/libraries/boost/generic.nix
@@ -1,18 +1,19 @@
 { stdenv, fetchurl, icu, expat, zlib, bzip2, python, fixDarwinDylibNames, libiconv
-, buildPlatform, hostPlatform
-, toolset ? if stdenv.cc.isClang then "clang" else null
+, which
+, buildPackages, buildPlatform, hostPlatform
+, toolset ? /**/ if stdenv.cc.isClang                                then "clang"
+            else if stdenv.cc.isGNU && hostPlatform != buildPlatform then "gcc-cross"
+            else null
 , enableRelease ? true
 , enableDebug ? false
 , enableSingleThreaded ? false
 , enableMultiThreaded ? true
 , enableShared ? !(hostPlatform.libc == "msvcrt") # problems for now
 , enableStatic ? !enableShared
-, enablePIC ? false
-, enableExceptions ? false
 , enablePython ? hostPlatform == buildPlatform
-, enableNumpy ? false, numpy ? null
+, enableNumpy ? enablePython && stdenv.lib.versionAtLeast version "1.65"
 , taggedLayout ? ((enableRelease && enableDebug) || (enableSingleThreaded && enableMultiThreaded) || (enableShared && enableStatic))
-, patches ? null
+, patches ? []
 , mpi ? null
 
 # Attributes inherit from specific versions
@@ -21,8 +22,9 @@
 }:
 
 # We must build at least one type of libraries
-assert !enableShared -> enableStatic;
+assert enableShared || enableStatic;
 
+# Python isn't supported when cross-compiling
 assert enablePython -> hostPlatform == buildPlatform;
 assert enableNumpy -> enablePython;
 
@@ -46,86 +48,41 @@ let
   # To avoid library name collisions
   layout = if taggedLayout then "tagged" else "system";
 
-  cflags = if enablePIC && enableExceptions then
-             "cflags=\"-fPIC -fexceptions\" cxxflags=-fPIC linkflags=-fPIC"
-           else if enablePIC then
-             "cflags=-fPIC cxxflags=-fPIC linkflags=-fPIC"
-           else if enableExceptions then
-             "cflags=-fexceptions"
-           else
-             "";
-
-  withToolset = stdenv.lib.optionalString (toolset != null) "--with-toolset=${toolset}";
-
-  genericB2Flags = [
+  b2Args = concatStringsSep " " ([
     "--includedir=$dev/include"
     "--libdir=$out/lib"
     "-j$NIX_BUILD_CORES"
     "--layout=${layout}"
     "variant=${variant}"
     "threading=${threading}"
-  ] ++ optional (link != "static") "runtime-link=${runtime-link}" ++ [
+    "runtime-link=${runtime-link}"
     "link=${link}"
-    "${cflags}"
-  ] ++ optional (variant == "release") "debug-symbols=off"
-    ++ optional (!enablePython) "--without-python";
-
-  nativeB2Flags = [
     "-sEXPAT_INCLUDE=${expat.dev}/include"
     "-sEXPAT_LIBPATH=${expat.out}/lib"
-  ] ++ optional (toolset != null) "toolset=${toolset}"
-    ++ optional (mpi != null) "--user-config=user-config.jam";
-  nativeB2Args = concatStringsSep " " (genericB2Flags ++ nativeB2Flags);
-
-  crossB2Flags = [
-    "-sEXPAT_INCLUDE=${expat.crossDrv}/include"
-    "-sEXPAT_LIBPATH=${expat.crossDrv}/lib"
-    "--user-config=user-config.jam"
-    "toolset=gcc-cross"
-  ] ++ optionals (hostPlatform.libc == "msvcrt") [
+  ] ++ optional (variant == "release") "debug-symbols=off"
+    ++ optional (toolset != null) "toolset=${toolset}"
+    ++ optional (mpi != null || hostPlatform != buildPlatform) "--user-config=user-config.jam"
+    ++ optionals (hostPlatform.libc == "msvcrt") [
     "target-os=windows"
     "threadapi=win32"
     "binary-format=pe"
     "address-model=${toString hostPlatform.parsed.cpu.bits}"
     "architecture=x86"
-  ];
-  crossB2Args = concatStringsSep " " (genericB2Flags ++ crossB2Flags);
-
-  builder = b2Args: ''
-    ./b2 ${b2Args}
-  '';
-
-  installer = b2Args: ''
-    # boostbook is needed by some applications
-    mkdir -p $dev/share/boostbook
-    cp -a tools/boostbook/{xsl,dtd} $dev/share/boostbook/
-
-    # Let boost install everything else
-    ./b2 ${b2Args} install
-  '';
-
-  commonConfigureFlags = [
-    "--includedir=$(dev)/include"
-    "--libdir=$(out)/lib"
-  ];
-
-  fixup = ''
-    # Make boost header paths relative so that they are not runtime dependencies
-    (
-      cd "$dev"
-      find include \( -name '*.hpp' -or -name '*.h' -or -name '*.ipp' \) \
-        -exec sed '1i#line 1 "{}"' -i '{}' \;
-    )
-  '' + optionalString (hostPlatform.libc == "msvcrt") ''
-    ${stdenv.cc.prefix}ranlib "$out/lib/"*.a
-  '';
+  ]);
 
 in
 
 stdenv.mkDerivation {
   name = "boost-${version}";
 
-  inherit src patches;
+  inherit src;
+
+  patchFlags = optionalString (hostPlatform.libc == "msvcrt") "-p0";
+  patches = patches ++ optional (hostPlatform.libc == "msvcrt") (fetchurl {
+    url = "https://svn.boost.org/trac/boost/raw-attachment/tickaet/7262/"
+        + "boost-mingw.patch";
+    sha256 = "0s32kwll66k50w6r5np1y5g907b7lcpsjhfgr7rsw7q5syhzddyj";
+  });
 
   meta = {
     homepage = http://boost.org/;
@@ -142,9 +99,13 @@ stdenv.mkDerivation {
           --replace '@rpath/$(<[1]:D=)' "$out/lib/\$(<[1]:D=)";
     fi;
   '' + optionalString (mpi != null) ''
-    cat << EOF > user-config.jam
+    cat << EOF >> user-config.jam
     using mpi : ${mpi}/bin/mpiCC ;
     EOF
+  '' + optionalString (hostPlatform != buildPlatform) ''
+    cat << EOF >> user-config.jam
+    using gcc : cross : ${stdenv.cc.targetPrefix}c++ ;
+    EOF
   '';
 
   NIX_CFLAGS_LINK = stdenv.lib.optionalString stdenv.isDarwin
@@ -152,46 +113,43 @@ stdenv.mkDerivation {
 
   enableParallelBuilding = true;
 
+  nativeBuildInputs = [ which buildPackages.stdenv.cc ];
   buildInputs = [ expat zlib bzip2 libiconv ]
     ++ optional (hostPlatform == buildPlatform) icu
     ++ optional stdenv.isDarwin fixDarwinDylibNames
     ++ optional enablePython python
-    ++ optional enableNumpy numpy;
+    ++ optional enableNumpy python.pkgs.numpy;
 
   configureScript = "./bootstrap.sh";
-  configureFlags = commonConfigureFlags
-    ++ [ "--with-python=${python.interpreter}" ]
-    ++ optional (hostPlatform == buildPlatform) "--with-icu=${icu.dev}"
+  configurePlatforms = [];
+  configureFlags = [
+    "--includedir=$(dev)/include"
+    "--libdir=$(out)/lib"
+  ] ++ optional enablePython "--with-python=${python.interpreter}"
+    ++ [ (if hostPlatform == buildPlatform then "--with-icu=${icu.dev}" else "--without-icu") ]
     ++ optional (toolset != null) "--with-toolset=${toolset}";
 
-  buildPhase = builder nativeB2Args;
+  buildPhase = ''
+    ./b2 ${b2Args}
+  '';
+
+  installPhase = ''
+    # boostbook is needed by some applications
+    mkdir -p $dev/share/boostbook
+    cp -a tools/boostbook/{xsl,dtd} $dev/share/boostbook/
 
-  installPhase = installer nativeB2Args;
+    # Let boost install everything else
+    ./b2 ${b2Args} install
+  '';
 
-  postFixup = fixup;
+  postFixup = ''
+    # Make boost header paths relative so that they are not runtime dependencies
+    cd "$dev" && find include \( -name '*.hpp' -or -name '*.h' -or -name '*.ipp' \) \
+      -exec sed '1i#line 1 "{}"' -i '{}' \;
+  '' + optionalString (hostPlatform.libc == "msvcrt") ''
+    $RANLIB "$out/lib/"*.a
+  '';
 
   outputs = [ "out" "dev" ];
   setOutputFlags = false;
-
-  crossAttrs = rec {
-    # We want to substitute the contents of configureFlags, removing thus the
-    # usual --build and --host added on cross building.
-    preConfigure = ''
-      export configureFlags="--without-icu ${concatStringsSep " " commonConfigureFlags}"
-      cat << EOF > user-config.jam
-      using gcc : cross : $crossConfig-g++ ;
-      EOF
-    '';
-    buildPhase = builder crossB2Args;
-    installPhase = installer crossB2Args;
-    postFixup = fixup;
-  } // optionalAttrs (hostPlatform.libc == "msvcrt") {
-    patches = fetchurl {
-      url = "https://svn.boost.org/trac/boost/raw-attachment/ticket/7262/"
-          + "boost-mingw.patch";
-      sha256 = "0s32kwll66k50w6r5np1y5g907b7lcpsjhfgr7rsw7q5syhzddyj";
-    };
-
-    patchFlags = "-p0";
-  };
 }
diff --git a/pkgs/development/libraries/bootil/default.nix b/pkgs/development/libraries/bootil/default.nix
index 727c6bfc4f3f..160f62305945 100644
--- a/pkgs/development/libraries/bootil/default.nix
+++ b/pkgs/development/libraries/bootil/default.nix
@@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
   platform =
     if stdenv.isLinux then "linux"
     else if stdenv.isDarwin then "macosx"
-    else abort "unrecognized platform";
+    else throw "unrecognized system ${stdenv.system}";
 
   buildInputs = [ premake4 ];
 
diff --git a/pkgs/development/libraries/botan/2.0.upstream b/pkgs/development/libraries/botan/2.0.upstream
index d10850d46adc..74eb1a2ca83f 100644
--- a/pkgs/development/libraries/botan/2.0.upstream
+++ b/pkgs/development/libraries/botan/2.0.upstream
@@ -1,5 +1,5 @@
-url http://botan.randombit.net/download.html
-version_link 'Botan-[0-9]+[.][0-9]*[02468]([.][0-9]+)?[.](tgz|tbz|tbz2|tar[.]bz2)$'
+url https://botan.randombit.net/
+version_link 'Botan-[0-9]+([.][0-9]+)*[.](tgz|tbz|tbz2|tar[.]bz2)$'
 ensure_version
 attribute_name botan2
 do_overwrite(){
diff --git a/pkgs/development/libraries/box2d/default.nix b/pkgs/development/libraries/box2d/default.nix
index 61f0fac7ffd0..e65980be320e 100644
--- a/pkgs/development/libraries/box2d/default.nix
+++ b/pkgs/development/libraries/box2d/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, unzip, cmake, mesa, freeglut, libX11, xproto, inputproto
+{ stdenv, fetchurl, unzip, cmake, libGLU_combined, freeglut, libX11, xproto, inputproto
 , libXi, pkgconfig }:
 
 stdenv.mkDerivation rec {
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [
-    unzip cmake mesa freeglut libX11 xproto inputproto libXi
+    unzip cmake libGLU_combined freeglut libX11 xproto inputproto libXi
   ];
 
   cmakeFlags = [ "-DBOX2D_INSTALL=ON" "-DBOX2D_BUILD_SHARED=ON" ];
diff --git a/pkgs/development/libraries/breakpad/default.nix b/pkgs/development/libraries/breakpad/default.nix
deleted file mode 100644
index 7f3117fac424..000000000000
--- a/pkgs/development/libraries/breakpad/default.nix
+++ /dev/null
@@ -1,28 +0,0 @@
-{ stdenv, fetchgit }:
-
-stdenv.mkDerivation {
-  name = "breakpad-2016-03-28";
-  
-  src = fetchgit {
-    url = "https://chromium.googlesource.com/breakpad/breakpad";
-    rev = "512cac3a1b69721ab727f3079f4d29e4580467b1";
-    sha256 = "1ksilbdpi1krycxkidqd1dlly95qf7air3zy8h5zfnagrlkz7zzx";
-  };
-
-  breakpad_lss = fetchgit {
-    url = "https://chromium.googlesource.com/linux-syscall-support";
-    rev = "08056836f2b4a5747daff75435d10d649bed22f6";
-    sha256 = "1ryshs2nyxwa0kn3rlbnd5b3fhna9vqm560yviddcfgdm2jyg0hz";
-  };
-
-  enableParallelBuilding = true;
-
-  prePatch = ''
-    cp -r $breakpad_lss src/third_party/lss
-    chmod +w -R src/third_party/lss
-  '';
-
-  meta = {
-    platforms = stdenv.lib.platforms.unix;
-  };
-}
diff --git a/pkgs/development/libraries/buddy/default.nix b/pkgs/development/libraries/buddy/default.nix
index 313ac086726f..00e236eba8c3 100644
--- a/pkgs/development/libraries/buddy/default.nix
+++ b/pkgs/development/libraries/buddy/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
     description = "Binary decision diagram package";
     license = "as-is";
 
-    platforms = with stdenv.lib.platforms; allBut cygwin;
+    platforms = stdenv.lib.platforms.unix; # Once had cygwin problems
     maintainers = [ stdenv.lib.maintainers.peti ];
   };
 }
diff --git a/pkgs/development/libraries/bullet/bullet283.nix b/pkgs/development/libraries/bullet/bullet283.nix
deleted file mode 100644
index 36790dbe3a2b..000000000000
--- a/pkgs/development/libraries/bullet/bullet283.nix
+++ /dev/null
@@ -1,29 +0,0 @@
-{ stdenv, fetchurl, cmake, mesa, freeglut }:
-
-stdenv.mkDerivation rec {
-  name = "bullet-2.83.7"; # vdrift 2012-07-22 doesn't build with 2.81
-  src = fetchurl {
-    url = "https://github.com/bulletphysics/bullet3/archive/2.83.7.tar.gz";
-    sha256 = "0hqjnmlb2p29yiasrm7kvgv0nklz5zkwhfk4f78zz1gf0vrdil80";
-  };
-
-  buildInputs = [ cmake mesa freeglut ];
-  configurePhase = ''
-    cmake -DBUILD_SHARED_LIBS=ON -DINSTALL_EXTRA_LIBS=TRUE \
-      -DCMAKE_INSTALL_PREFIX=$out .
-  '';
-
-  enableParallelBuilding = true;
-
-  meta = {
-    description = "A professional free 3D Game Multiphysics Library";
-    longDescription = ''
-      Bullet 3D Game Multiphysics Library provides state of the art collision
-      detection, soft body and rigid body dynamics. 
-    '';
-    homepage = https://github.com/bulletphysics/bullet3;
-    license = stdenv.lib.licenses.zlib;
-    maintainers = with stdenv.lib.maintainers; [ aforemny ];
-    platforms = with stdenv.lib.platforms; linux;
-  };
-}
diff --git a/pkgs/development/libraries/bullet/default.nix b/pkgs/development/libraries/bullet/default.nix
index e7b500905370..4d94faa9566a 100644
--- a/pkgs/development/libraries/bullet/default.nix
+++ b/pkgs/development/libraries/bullet/default.nix
@@ -1,34 +1,40 @@
-{ stdenv, fetchFromGitHub, cmake, mesa, freeglut, darwin }:
+{ stdenv, fetchFromGitHub, cmake, libGLU_combined, freeglut, darwin }:
 
 stdenv.mkDerivation rec {
   name = "bullet-${version}";
-  version = "2.86.1";
+  version = "2.87";
 
   src = fetchFromGitHub {
     owner = "bulletphysics";
     repo = "bullet3";
     rev = version;
-    sha256 = "1k81hr5y9rs2nsal6711fal21rxp6h573cpmjjk8x8ji2crqbqlz";
+    sha256 = "1msp7w3563vb43w70myjmqsdb97kna54dcfa7yvi9l3bvamb92w3";
   };
 
   buildInputs = [ cmake ] ++
     (if stdenv.isDarwin
      then with darwin.apple_sdk.frameworks; [ Cocoa OpenGL ]
-     else [mesa freeglut]);
+     else [libGLU_combined freeglut]);
+
+  patches = [ ./gwen-narrowing.patch ];
 
   postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
     sed -i 's/FIND_PACKAGE(OpenGL)//' CMakeLists.txt
     sed -i 's/FIND_LIBRARY(COCOA_LIBRARY Cocoa)//' CMakeLists.txt
   '';
 
-  cmakeFlags = [ "-DBUILD_SHARED_LIBS=ON" "-DBUILD_CPU_DEMOS=OFF" ] ++
-    stdenv.lib.optionals stdenv.isDarwin [
-      "-DMACOSX_DEPLOYMENT_TARGET=\"10.9\""
-      "-DOPENGL_FOUND=true"
-      "-DOPENGL_LIBRARIES=${darwin.apple_sdk.frameworks.OpenGL}/Library/Frameworks/OpenGL.framework"
-      "-DOPENGL_INCLUDE_DIR=${darwin.apple_sdk.frameworks.OpenGL}/Library/Frameworks/OpenGL.framework"
-      "-DOPENGL_gl_LIBRARY=${darwin.apple_sdk.frameworks.OpenGL}/Library/Frameworks/OpenGL.framework"
-      "-DCOCOA_LIBRARY=${darwin.apple_sdk.frameworks.Cocoa}/Library/Frameworks/Cocoa.framework"];
+  cmakeFlags = [
+    "-DBUILD_SHARED_LIBS=ON"
+    "-DBUILD_CPU_DEMOS=OFF"
+    "-DINSTALL_EXTRA_LIBS=ON"
+  ] ++ stdenv.lib.optionals stdenv.isDarwin [
+    "-DMACOSX_DEPLOYMENT_TARGET=\"10.9\""
+    "-DOPENGL_FOUND=true"
+    "-DOPENGL_LIBRARIES=${darwin.apple_sdk.frameworks.OpenGL}/Library/Frameworks/OpenGL.framework"
+    "-DOPENGL_INCLUDE_DIR=${darwin.apple_sdk.frameworks.OpenGL}/Library/Frameworks/OpenGL.framework"
+    "-DOPENGL_gl_LIBRARY=${darwin.apple_sdk.frameworks.OpenGL}/Library/Frameworks/OpenGL.framework"
+    "-DCOCOA_LIBRARY=${darwin.apple_sdk.frameworks.Cocoa}/Library/Frameworks/Cocoa.framework"
+  ];
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/bullet/gwen-narrowing.patch b/pkgs/development/libraries/bullet/gwen-narrowing.patch
new file mode 100644
index 000000000000..c6c06325dae0
--- /dev/null
+++ b/pkgs/development/libraries/bullet/gwen-narrowing.patch
@@ -0,0 +1,22 @@
+commit a5d3497577c78b03c05c69d17df972fa9fb54f53
+Author: Linus Heckemann <git@sphalerite.org>
+Date:   Fri Jan 5 23:57:09 2018 +0100
+
+    Add -Wno-narrowing to GWEN's CMakeLists
+    
+    This avoids the compilation issue that occurs on aarch64 with gcc6.
+    (nixpkgs-specific patch)
+
+diff --git a/examples/ThirdPartyLibs/Gwen/CMakeLists.txt b/examples/ThirdPartyLibs/Gwen/CMakeLists.txt
+index 82fa0ffba..26c4bbd37 100644
+--- a/examples/ThirdPartyLibs/Gwen/CMakeLists.txt
++++ b/examples/ThirdPartyLibs/Gwen/CMakeLists.txt
+@@ -15,7 +15,7 @@ IF(NOT WIN32 AND NOT APPLE)
+         ADD_DEFINITIONS("-DDYNAMIC_LOAD_X11_FUNCTIONS=1")
+ ENDIF()
+ 
+-ADD_DEFINITIONS( -DGLEW_STATIC -DGWEN_COMPILE_STATIC -D_HAS_EXCEPTIONS=0 -D_STATIC_CPPLIB )
++ADD_DEFINITIONS( -DGLEW_STATIC -DGWEN_COMPILE_STATIC -D_HAS_EXCEPTIONS=0 -D_STATIC_CPPLIB -Wno-narrowing )
+ 
+ FILE(GLOB gwen_SRCS "*.cpp" "Controls/*.cpp" "Controls/Dialog/*.cpp" "Controls/Dialogs/*.cpp" "Controls/Layout/*.cpp" "Controls/Property/*.cpp" "Input/*.cpp" "Platforms/*.cpp" "Renderers/*.cpp" "Skins/*.cpp")
+ FILE(GLOB gwen_HDRS "*.h" "Controls/*.h" "Controls/Dialog/*.h" "Controls/Dialogs/*.h" "Controls/Layout/*.h" "Controls/Property/*.h" "Input/*.h" "Platforms/*.h" "Renderers/*.h" "Skins/*.h")
diff --git a/pkgs/development/libraries/bwidget/default.nix b/pkgs/development/libraries/bwidget/default.nix
index 6dc658c03e3e..76c041e2ad56 100644
--- a/pkgs/development/libraries/bwidget/default.nix
+++ b/pkgs/development/libraries/bwidget/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "bwidget-${version}";
-  version = "1.9.10";
+  version = "1.9.12";
 
   src = fetchurl {
     url = "mirror://sourceforge/tcllib/bwidget-${version}.tar.gz";
-    sha256 = "025lmriaq4qqy99lh826wx2cnqqgxn7srz4m3q06bl6r9ch15hr6";
+    sha256 = "0qrj8k4zzrnhwgdn5dpa6j0q5j739myhwn60ssnqrzq77sljss1g";
   };
 
   dontBuild = true;
diff --git a/pkgs/development/libraries/bzrtp/default.nix b/pkgs/development/libraries/bzrtp/default.nix
new file mode 100644
index 000000000000..cdc660ca3f32
--- /dev/null
+++ b/pkgs/development/libraries/bzrtp/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl, cmake, fetchFromGitHub, bctoolbox, sqlite }:
+
+stdenv.mkDerivation rec {
+  baseName = "bzrtp";
+  version = "1.0.6";
+  name = "${baseName}-${version}";
+
+  src = fetchFromGitHub {
+    owner = "BelledonneCommunications";
+    repo = "${baseName}";
+    rev = "${version}";
+    sha256 = "0438zzxp82bj5fmvqnwlljkgrz9ab5qm5lgpwwgmg1cp78bp2l45";
+  };
+
+  buildInputs = [ bctoolbox sqlite ];
+  nativeBuildInputs = [ cmake ];
+
+  meta = with stdenv.lib; {
+    description = "BZRTP is an opensource implementation of ZRTP keys exchange protocol";
+    homepage = https://github.com/BelledonneCommunications/bzrtp;
+    license = licenses.lgpl21;
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/c-ares/default.nix b/pkgs/development/libraries/c-ares/default.nix
index 14ff7a5f16c3..6b3b69f99971 100644
--- a/pkgs/development/libraries/c-ares/default.nix
+++ b/pkgs/development/libraries/c-ares/default.nix
@@ -1,5 +1,6 @@
-{ stdenv, fetchurl }:
+{ stdenv, fetchurl, writeTextDir }:
 
+let self =
 stdenv.mkDerivation rec {
   name = "c-ares-1.13.0";
 
@@ -14,4 +15,28 @@ stdenv.mkDerivation rec {
     license = licenses.mit;
     platforms = platforms.all;
   };
-}
+
+  # Adapted from running a cmake build
+  passthru.cmake-config = writeTextDir "c-ares-config.cmake"
+    ''
+      set(c-ares_INCLUDE_DIR "${self}/include")
+
+      set(c-ares_LIBRARY c-ares::cares)
+
+      add_library(c-ares::cares SHARED IMPORTED)
+
+      set_target_properties(c-ares::cares PROPERTIES
+        INTERFACE_INCLUDE_DIRECTORIES "${self}/include"
+        INTERFACE_LINK_LIBRARIES "nsl;rt"
+      )
+      set_property(TARGET c-ares::cares APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+      set_target_properties(c-ares::cares PROPERTIES
+        IMPORTED_LOCATION_RELEASE "${self}/lib/libcares.so.2.2.0"
+        IMPORTED_SONAME_RELEASE "libcares.so.2"
+        )
+      add_library(c-ares::cares_shared INTERFACE IMPORTED)
+      set_target_properties(c-ares::cares_shared PROPERTIES INTERFACE_LINK_LIBRARIES "c-ares::cares")
+      set(c-ares_SHARED_LIBRARY c-ares::cares_shared)
+    '';
+
+}; in self
diff --git a/pkgs/development/libraries/c-ares/release.patch b/pkgs/development/libraries/c-ares/release.patch
new file mode 100644
index 000000000000..e745648062a5
--- /dev/null
+++ b/pkgs/development/libraries/c-ares/release.patch
@@ -0,0 +1,19 @@
+diff -aur c-ares-cares-1_13_0/ares_version.h c-ares-1.13.0/ares_version.h
+--- c-ares-cares-1_13_0/ares_version.h	2017-06-20 02:00:21.000000000 -0400
++++ c-ares-1.13.0/ares_version.h	2017-06-20 02:03:54.000000000 -0400
+@@ -6,12 +6,12 @@
+ #define ARES_COPYRIGHT "2004 - 2016 Daniel Stenberg, <daniel@haxx.se>."
+ 
+ #define ARES_VERSION_MAJOR 1
+-#define ARES_VERSION_MINOR 12
+-#define ARES_VERSION_PATCH 1
++#define ARES_VERSION_MINOR 13
++#define ARES_VERSION_PATCH 0
+ #define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\
+                        (ARES_VERSION_MINOR<<8)|\
+                        (ARES_VERSION_PATCH))
+-#define ARES_VERSION_STR "1.12.1-DEV"
++#define ARES_VERSION_STR "1.13.0"
+ 
+ #if (ARES_VERSION >= 0x010700)
+ #  define CARES_HAVE_ARES_LIBRARY_INIT 1
diff --git a/pkgs/development/libraries/caf/default.nix b/pkgs/development/libraries/caf/default.nix
index d3b6722b36cd..1e764aff4cc1 100644
--- a/pkgs/development/libraries/caf/default.nix
+++ b/pkgs/development/libraries/caf/default.nix
@@ -2,25 +2,17 @@
 
 stdenv.mkDerivation rec {
   name = "actor-framework-${version}";
-  version = "0.15.3";
+  version = "0.15.7";
 
   src = fetchFromGitHub {
     owner = "actor-framework";
     repo = "actor-framework";
     rev = "${version}";
-    sha256 = "0202nsdriigdh6sxi1k3hddvmf1x54qpykbvf2ghfhzyh0m1q7j2";
+    sha256 = "0qmb18k162xdvf8z03mybjazkwb2vqda5xd1qh5bwkvxracwq3sb";
   };
 
-  # See https://github.com/actor-framework/actor-framework/issues/545 and remove on next release that incorporates this
-  patches = [ (fetchpatch {
-    url    = "https://github.com/actor-framework/actor-framework/commit/c5a3ee26a6e76b28dd4226f35230b280f291386d.patch";
-    sha256 = "1l0323cqyqlp3lvggm709fmfm6lk6av1smdbd420adhi3ksj2vhj";
-  }) ];
-
   nativeBuildInputs = [ cmake ];
 
-  enableParallelBuilding = true;
-
   meta = with stdenv.lib; {
     description = "An open source implementation of the actor model in C++";
     homepage = http://actor-framework.org/;
diff --git a/pkgs/development/libraries/cairo/default.nix b/pkgs/development/libraries/cairo/default.nix
index 7c0e36d40689..6a7beb1cc1a8 100644
--- a/pkgs/development/libraries/cairo/default.nix
+++ b/pkgs/development/libraries/cairo/default.nix
@@ -1,13 +1,13 @@
 { 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, mesa_noglu ? null # mesa is no longer a big dependency
+, glSupport ? true, libGL ? null # libGLU_combined is no longer a big dependency
 , pdfSupport ? true
 , darwin
 }:
 
-assert glSupport -> mesa_noglu != null;
+assert glSupport -> libGL != null;
 
 let inherit (stdenv.lib) optional optionals; in
 
@@ -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
@@ -45,7 +46,7 @@ stdenv.mkDerivation rec {
     with xorg; [ libXext fontconfig expat freetype pixman zlib libpng libXrender ]
     ++ optionals xcbSupport [ libxcb xcbutil ]
     ++ optional gobjectSupport glib
-    ++ optional glSupport mesa_noglu
+    ++ optional glSupport libGL
     ; # TODO: maybe liblzo but what would it be for here?
 
   configureFlags = if stdenv.isDarwin then [
diff --git a/pkgs/development/libraries/cairomm/default.nix b/pkgs/development/libraries/cairomm/default.nix
index b1ee0b8d2736..09d162db8532 100644
--- a/pkgs/development/libraries/cairomm/default.nix
+++ b/pkgs/development/libraries/cairomm/default.nix
@@ -1,16 +1,16 @@
 { fetchurl, stdenv, pkgconfig, darwin, cairo, xlibsWrapper, fontconfig, freetype, libsigcxx }:
 let
   ver_maj = "1.12";
-  ver_min = "0";
+  ver_min = "2";
 in
 stdenv.mkDerivation rec {
   name = "cairomm-${ver_maj}.${ver_min}";
 
   src = fetchurl {
-    #url = "http://www.cairographics.org/releases/${name}.tar.gz";
+    url = "http://www.cairographics.org/releases/${name}.tar.gz";
     # gnome doesn't have the latest version ATM; beware: same name but different hash
-    url = "mirror://gnome/sources/cairomm/${ver_maj}/${name}.tar.xz";
-    sha256 = "a54ada8394a86182525c0762e6f50db6b9212a2109280d13ec6a0b29bfd1afe6";
+    # url = "mirror://gnome/sources/cairomm/${ver_maj}/${name}.tar.xz";
+    sha256 = "16fmigxsaz85c3lgcls7biwyz8zy8c8h3jndfm54cxxas3a7zi25";
   };
 
   outputs = [ "out" "dev" ];
diff --git a/pkgs/development/libraries/catch/default.nix b/pkgs/development/libraries/catch/default.nix
index 66ced59c26d7..116216d500e2 100644
--- a/pkgs/development/libraries/catch/default.nix
+++ b/pkgs/development/libraries/catch/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "catch-${version}";
-  version = "1.9.6";
+  version = "1.12.0";
 
   src = fetchFromGitHub {
-    owner = "philsquared";
+    owner = "catchorg";
     repo = "Catch";
     rev = "v${version}";
-    sha256 = "0nqnyw6haa2771748ycag4hhjb8ni32cv4f7w3h0pji212542xan";
+    sha256 = "0hkcmycvyyazzi9dywnyiipnmbx399iirh5xk5g957c8zl0505kd";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/cdk/default.nix b/pkgs/development/libraries/cdk/default.nix
index a97ca5cc6980..19f39217fd02 100644
--- a/pkgs/development/libraries/cdk/default.nix
+++ b/pkgs/development/libraries/cdk/default.nix
@@ -2,15 +2,18 @@
 
 stdenv.mkDerivation rec {
   name = "cdk-${version}";
-  version ="5.0-20161210";
+  version ="5.0-20171209";
 
   buildInputs = [
     ncurses
   ];
 
   src = fetchurl {
-    url = "ftp://invisible-island.net/cdk/cdk-${version}.tgz";
-    sha256 = "1bazwcwz4qhxyc8jaahdd2nlm30f5dhy0f6cnix5rjjhi35mhxcy";
+    urls = [
+      "ftp://ftp.invisible-island.net/cdk/cdk-${version}.tgz"
+      "https://invisible-mirror.net/archives/cdk/cdk-${version}.tgz"
+    ];
+    sha256 = "0jq0dx7gm7gl6lv5mhlfkxhw5362g9dxqdlpjlrag069nns8xdc8";
   };
 
   meta = with stdenv.lib; {
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/ceres-solver/default.nix b/pkgs/development/libraries/ceres-solver/default.nix
index 77e0cb7735d9..1e2017ef0e7f 100644
--- a/pkgs/development/libraries/ceres-solver/default.nix
+++ b/pkgs/development/libraries/ceres-solver/default.nix
@@ -12,11 +12,11 @@ assert runTests -> google-gflags != null;
 
 stdenv.mkDerivation rec {
   name = "ceres-solver-${version}";
-  version = "1.12.0";
+  version = "1.14.0";
 
   src = fetchurl {
     url = "http://ceres-solver.org/ceres-solver-${version}.tar.gz";
-    sha256 = "15f8mwhcy9f5qggcc9dqwl5y687ykvmlidr686aqdq0ia7azwnvl";
+    sha256 = "13lfxy8x58w8vprr0nkbzziaijlh0vvqshgahvcgw0mrqdgh0i27";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/cfitsio/default.nix b/pkgs/development/libraries/cfitsio/default.nix
index 93c187ec35ef..ecf5fb1f02fd 100644
--- a/pkgs/development/libraries/cfitsio/default.nix
+++ b/pkgs/development/libraries/cfitsio/default.nix
@@ -1,11 +1,11 @@
 { fetchurl, stdenv }:
 
  stdenv.mkDerivation {
-  name = "cfitsio-3.41";
+  name = "cfitsio-3.430";
 
   src = fetchurl {
-    url = "ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3410.tar.gz";
-    sha256 = "0k3knn5hz1vhzzvm46xa1y6fnpliwkwgw76lnkf4amcnl5zaqmm5";
+    url = "ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3430.tar.gz";
+    sha256 = "07fghxh5fl8nqk3q0dh8rvc83npnm0hisxzcj16a6r7gj5pmp40l";
   };
 
   # Shared-only build
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/chipmunk/default.nix b/pkgs/development/libraries/chipmunk/default.nix
index 2c50d8138057..ad233402f198 100644
--- a/pkgs/development/libraries/chipmunk/default.nix
+++ b/pkgs/development/libraries/chipmunk/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cmake, freeglut, mesa, glfw2, glew, libX11, xproto
+{ stdenv, fetchurl, cmake, freeglut, libGLU_combined, glfw2, glew, libX11, xproto
 , inputproto, libXi, libXmu
 }:
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake ];
   buildInputs =
-    [ freeglut mesa glfw2 glew libX11 xproto inputproto libXi libXmu ];
+    [ freeglut libGLU_combined glfw2 glew libX11 xproto inputproto libXi libXmu ];
 
   postInstall = ''
     mkdir -p $out/bin
diff --git a/pkgs/development/libraries/cl/default.nix b/pkgs/development/libraries/cl/default.nix
index b26327dd7754..7c44c2e0ab0c 100644
--- a/pkgs/development/libraries/cl/default.nix
+++ b/pkgs/development/libraries/cl/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchFromGitHub, SDL, mesa, rebar, erlang, opencl-headers, ocl-icd }:
+{stdenv, fetchFromGitHub, SDL, libGLU_combined, rebar, erlang, opencl-headers, ocl-icd }:
 
 stdenv.mkDerivation rec {
   version = "1.2.3";
diff --git a/pkgs/development/libraries/clipper/default.nix b/pkgs/development/libraries/clipper/default.nix
new file mode 100644
index 000000000000..31af37587821
--- /dev/null
+++ b/pkgs/development/libraries/clipper/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchurl, cmake, ninja, unzip }:
+
+stdenv.mkDerivation rec {
+  version = "6.4.2";
+  name = "Clipper-${version}";
+  src = fetchurl {
+    url = "mirror://sourceforge/polyclipping/clipper_ver${version}.zip";
+    sha256 = "09q6jc5k7p9y5d75qr2na5d1gm0wly5cjnffh127r04l47c20hx1";
+  };
+
+  sourceRoot = "cpp";
+
+  buildInputs = [ ];
+
+  nativeBuildInputs = [ cmake ninja unzip ];
+
+  meta = with stdenv.lib; {
+    longDescription = ''
+      The Clipper library performs line & polygon clipping - intersection, union, difference & exclusive-or,
+      and line & polygon offsetting. The library is based on Vatti's clipping algorithm.
+    '';
+    homepage = https://www.angusj.com/delphi/clipper.php;
+    license = licenses.boost;
+    maintainers = with maintainers; [ mpickering ];
+    platforms = with platforms; unix;
+  };
+}
diff --git a/pkgs/development/libraries/cln/default.nix b/pkgs/development/libraries/cln/default.nix
index 9d7c9c4f30f8..e39386dca3f4 100644
--- a/pkgs/development/libraries/cln/default.nix
+++ b/pkgs/development/libraries/cln/default.nix
@@ -15,6 +15,6 @@ stdenv.mkDerivation rec {
     description = "C/C++ library for numbers, a part of GiNaC";
     homepage = http://www.ginac.de/CLN/;
     maintainers = [ ];
-    platforms = with stdenv.lib.platforms; allBut cygwin;
+    platforms = stdenv.lib.platforms.unix; # Once had cygwin problems
   };
 }
diff --git a/pkgs/development/libraries/cloog-ppl/default.nix b/pkgs/development/libraries/cloog-ppl/default.nix
index 2c49e0363589..442b115a4082 100644
--- a/pkgs/development/libraries/cloog-ppl/default.nix
+++ b/pkgs/development/libraries/cloog-ppl/default.nix
@@ -69,6 +69,6 @@ stdenv.mkDerivation rec {
        make[3]: *** [Box.lo] Error 1
 
     */
-    platforms = with stdenv.lib.platforms; allBut cygwin;
+    platforms = stdenv.lib.platforms.unix; # Once had cygwin problems
   };
 }
diff --git a/pkgs/development/libraries/cloog/0.18.0.nix b/pkgs/development/libraries/cloog/0.18.0.nix
index ccd938283199..fa4e19f716ae 100644
--- a/pkgs/development/libraries/cloog/0.18.0.nix
+++ b/pkgs/development/libraries/cloog/0.18.0.nix
@@ -58,6 +58,6 @@ stdenv.mkDerivation rec {
        make[3]: *** [Box.lo] Error 1
 
     */
-    platforms = with stdenv.lib.platforms; allBut cygwin;
+    platforms = stdenv.lib.platforms.unix; # Once had cygwin problems
   };
 }
diff --git a/pkgs/development/libraries/cloog/default.nix b/pkgs/development/libraries/cloog/default.nix
index 5da29273a8be..902e0b26687b 100644
--- a/pkgs/development/libraries/cloog/default.nix
+++ b/pkgs/development/libraries/cloog/default.nix
@@ -59,6 +59,6 @@ stdenv.mkDerivation rec {
        make[3]: *** [Box.lo] Error 1
 
     */
-    platforms = with stdenv.lib.platforms; allBut cygwin;
+    platforms = stdenv.lib.platforms.unix; # Once had cygwin problems
   };
 }
diff --git a/pkgs/development/libraries/clutter-gst/default.nix b/pkgs/development/libraries/clutter-gst/default.nix
index 2b5f7069681c..962ca9ff9b53 100644
--- a/pkgs/development/libraries/clutter-gst/default.nix
+++ b/pkgs/development/libraries/clutter-gst/default.nix
@@ -1,13 +1,14 @@
-{ fetchurl, stdenv, pkgconfig, clutter, gtk3, glib, cogl }:
+{ fetchurl, stdenv, pkgconfig, clutter, gtk3, glib, cogl, gnome3 }:
 
-stdenv.mkDerivation rec {
-  major = "3.0";
-  minor = "24";
-  name = "clutter-gst-${major}.${minor}";
+let
+  pname = "clutter-gst";
+  version = "3.0.26";
+in stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/clutter-gst/${major}/${name}.tar.xz";
-    sha256 = "0v6cg0syh4vx7y7ni47jsvr2r57q0j3h1f1gjlp0ciscixywiwg9";
+    url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
+    sha256 = "0fnblqm4igdx4rn3681bp1gm1y2i00if3iblhlm0zv6ck9nqlqfq";
   };
 
   propagatedBuildInputs = [ clutter gtk3 glib cogl ];
@@ -15,6 +16,12 @@ stdenv.mkDerivation rec {
 
   postBuild = "rm -rf $out/share/gtk-doc";
 
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+    };
+  };
+
   meta = {
     description = "GStreamer bindings for clutter";
 
diff --git a/pkgs/development/libraries/clutter-gtk/default.nix b/pkgs/development/libraries/clutter-gtk/default.nix
index bada2c2c709c..71789b45a283 100644
--- a/pkgs/development/libraries/clutter-gtk/default.nix
+++ b/pkgs/development/libraries/clutter-gtk/default.nix
@@ -1,12 +1,13 @@
-{ fetchurl, stdenv, pkgconfig, gobjectIntrospection, clutter, gtk3 }:
-
+{ fetchurl, stdenv, pkgconfig, gobjectIntrospection, clutter, gtk3, gnome3 }:
+let
+  pname = "clutter-gtk";
+  version = "1.8.4";
+in
 stdenv.mkDerivation rec {
-  major = "1.8";
-  minor = "4";
-  name = "clutter-gtk-${major}.${minor}";
+  name = "${pname}-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/clutter-gtk/${major}/${name}.tar.xz";
+    url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
     sha256 = "01ibniy4ich0fgpam53q252idm7f4fn5xg5qvizcfww90gn9652j";
   };
 
@@ -15,6 +16,12 @@ stdenv.mkDerivation rec {
 
   postBuild = "rm -rf $out/share/gtk-doc";
 
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+    };
+  };
+
   meta = {
     description = "Clutter-GTK";
     homepage = http://www.clutter-project.org/;
diff --git a/pkgs/development/libraries/clutter/default.nix b/pkgs/development/libraries/clutter/default.nix
index 3292c8e353fe..eba94288e8fe 100644
--- a/pkgs/development/libraries/clutter/default.nix
+++ b/pkgs/development/libraries/clutter/default.nix
@@ -1,31 +1,37 @@
-{ stdenv, fetchurl, glib, pkgconfig, mesa, libX11, libXext, libXfixes
-, libXdamage, libXcomposite, libXi, libxcb, cogl, pango, atk, json_glib, 
-gobjectIntrospection, gtk3
+{ stdenv, fetchurl, glib, pkgconfig, libGLU_combined, libX11, libXext, libXfixes
+, libXdamage, libXcomposite, libXi, libxcb, cogl, pango, atk, json-glib,
+gobjectIntrospection, gtk3, gnome3
 }:
 
 let
-  ver_maj = "1.26";
-  ver_min = "2";
+  pname = "clutter";
+  version = "1.26.2";
 in
 stdenv.mkDerivation rec {
-  name = "clutter-${ver_maj}.${ver_min}";
+  name = "${pname}-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/clutter/${ver_maj}/${name}.tar.xz";
+    url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
     sha256 = "0mif1qnrpkgxi43h7pimim6w6zwywa16ixcliw0yjm9hk0a368z7";
   };
 
   buildInputs = [ gtk3 ];
   nativeBuildInputs = [ pkgconfig ];
   propagatedBuildInputs =
-    [ libX11 mesa libXext libXfixes libXdamage libXcomposite libXi cogl pango
-      atk json_glib gobjectIntrospection libxcb
+    [ libX11 libGLU_combined libXext libXfixes libXdamage libXcomposite libXi cogl pango
+      atk json-glib gobjectIntrospection libxcb
     ];
 
   configureFlags = [ "--enable-introspection" ]; # needed by muffin AFAIK
 
   #doCheck = true; # no tests possible without a display
 
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+    };
+  };
+
   meta = {
     description = "Library for creating fast, dynamic graphical user interfaces";
 
diff --git a/pkgs/development/libraries/cmark/default.nix b/pkgs/development/libraries/cmark/default.nix
index 5fdd1edfd972..81df7e863193 100644
--- a/pkgs/development/libraries/cmark/default.nix
+++ b/pkgs/development/libraries/cmark/default.nix
@@ -1,18 +1,18 @@
 { stdenv, fetchFromGitHub, cmake }:
 
 stdenv.mkDerivation rec {
-  version = "0.27.1";
+  version = "0.28.3";
   name = "cmark-${version}";
 
   src = fetchFromGitHub {
     owner = "jgm";
     repo = "cmark";
     rev = version;
-    sha256 = "06miwq3rl2bighkn6iq7bdwzmvcqa53qwpa0pqjqa8yn44j8ijj8";
+    sha256 = "1lal6n6q7l84njgdcq1xbfxan56qlvr8xaw9m2jbd0jk4y2wkczg";
   };
 
   nativeBuildInputs = [ cmake ];
-  doCheck = true;
+  doCheck = !stdenv.isDarwin;
   checkPhase = ''
     export LD_LIBRARY_PATH=$(readlink -f ./src)
     CTEST_OUTPUT_ON_FAILURE=1 make test
diff --git a/pkgs/development/libraries/cminpack/default.nix b/pkgs/development/libraries/cminpack/default.nix
index a13b42a08a8f..cb4f3e39aefa 100644
--- a/pkgs/development/libraries/cminpack/default.nix
+++ b/pkgs/development/libraries/cminpack/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation rec {
-  name = "cminpack-1.3.4";
+  name = "cminpack-1.3.6";
   
   src = fetchurl {
     url = "http://devernay.free.fr/hacks/cminpack/${name}.tar.gz";
-    sha256 = "1jh3ymxfcy3ykh6gnvds5bbkf38aminvjgc8halck356vkvpnl9v";
+    sha256 = "17yh695aim508x1kn9zf6g13jxwk3pi3404h5ix4g5lc60hzs1rw";
   };
 
   patchPhase = ''
diff --git a/pkgs/development/libraries/cmocka/default.nix b/pkgs/development/libraries/cmocka/default.nix
index f352357ac21b..995844524dcf 100644
--- a/pkgs/development/libraries/cmocka/default.nix
+++ b/pkgs/development/libraries/cmocka/default.nix
@@ -1,26 +1,15 @@
-{ fetchurl, stdenv, cmake, fetchpatch }:
+{ fetchurl, stdenv, cmake }:
 
 stdenv.mkDerivation rec {
   name = "cmocka-${version}";
-  version = "1.0.1";
+  majorVersion = "1.1";
+  version = "${majorVersion}.1";
 
   src = fetchurl {
-    url = "https://cmocka.org/files/1.0/cmocka-${version}.tar.xz";
-    sha256 = "0fvm6rdalqcxckbddch8ycdw6n2ckldblv117n09chi2l7bm0q5k";
+    url = "https://cmocka.org/files/${majorVersion}/cmocka-${version}.tar.xz";
+    sha256 = "f02ef48a7039aa77191d525c5b1aee3f13286b77a13615d11bc1148753fc0389";
   };
 
-  patches = [
-    # This fixes the build for clang-3.7.0 and thus Darwin.
-    # See https://open.cryptomilk.org/issues/43 for more info.
-    #
-    # The patch is already merged to upstream, so it should be removed
-    # here on next release.
-    (fetchpatch {
-      url = "https://git.cryptomilk.org/projects/cmocka.git/patch/?id=1b595a80934fa95234fb290913cfe533f740d965";
-      sha256 = "1fg8xwb1mrrmw4dqa65ghnvgfdkpi0lv4j2gq0lm9ayvsi3v00vp";
-    })
-  ];
-
   nativeBuildInputs = [ cmake ];
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/cogl/default.nix b/pkgs/development/libraries/cogl/default.nix
index 1ac34f7608bc..e06c71c15db4 100644
--- a/pkgs/development/libraries/cogl/default.nix
+++ b/pkgs/development/libraries/cogl/default.nix
@@ -1,20 +1,20 @@
-{ stdenv, fetchurl, pkgconfig, mesa_noglu, glib, gdk_pixbuf, xorg, libintlOrEmpty
-, pangoSupport ? true, pango, cairo, gobjectIntrospection, wayland
+{ stdenv, fetchurl, pkgconfig, libGL, glib, gdk_pixbuf, xorg, libintl
+, pangoSupport ? true, pango, cairo, gobjectIntrospection, wayland, gnome3
+, mesa_noglu
 , gstreamerSupport ? true, gst_all_1 }:
 
 let
-  ver_maj = "1.22";
-  ver_min = "2";
-in
-stdenv.mkDerivation rec {
-  name = "cogl-${ver_maj}.${ver_min}";
+  pname = "cogl";
+in stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  version = "1.22.2";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/cogl/${ver_maj}/${name}.tar.xz";
+    url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
     sha256 = "03f0ha3qk7ca0nnkkcr1garrm1n1vvfqhkz9lwjm592fnv6ii9rr";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig libintl ];
 
   configureFlags = [
     "--enable-introspection"
@@ -25,10 +25,9 @@ stdenv.mkDerivation rec {
     ++ stdenv.lib.optionals (!stdenv.isDarwin) [ "--enable-gles1" "--enable-gles2" ];
 
   propagatedBuildInputs = with xorg; [
-      glib gdk_pixbuf gobjectIntrospection wayland
-      mesa_noglu libXrandr libXfixes libXcomposite libXdamage
+      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 ];
 
@@ -38,10 +37,14 @@ 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 = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+    };
+  };
+
   meta = with stdenv.lib; {
     description = "A small open source library for using 3D graphics hardware for rendering";
     maintainers = with maintainers; [ lovek323 ];
diff --git a/pkgs/development/libraries/coin3d/default.nix b/pkgs/development/libraries/coin3d/default.nix
index ce78a6fc1347..442ed2a4b9a5 100644
--- a/pkgs/development/libraries/coin3d/default.nix
+++ b/pkgs/development/libraries/coin3d/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, mesa }:
+{ fetchurl, stdenv, libGLU_combined }:
 
 stdenv.mkDerivation rec {
   name = "coin3d-${version}";
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
     ./sbhashentry.patch
   ];
 
-  buildInputs = [ mesa ];
+  buildInputs = [ libGLU_combined ];
 
   meta = {
     homepage = http://www.coin3d.org/;
diff --git a/pkgs/development/libraries/confuse/default.nix b/pkgs/development/libraries/confuse/default.nix
index 95af4d94cf5f..3257dfe5d37c 100644
--- a/pkgs/development/libraries/confuse/default.nix
+++ b/pkgs/development/libraries/confuse/default.nix
@@ -1,10 +1,11 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation rec {
-  name = "confuse-2.7";
+  name = "confuse-${version}";
+  version = "3.2.1";
   src = fetchurl {
-    url = "mirror://savannah/confuse/${name}.tar.gz";
-    sha256 = "0y47r2ashz44wvnxdb18ivpmj8nxhw3y9bf7v9w0g5byhgyp89g3";
+    url = "https://github.com/martinh/libconfuse/releases/download/v${version}/${name}.tar.xz";
+    sha256 = "0pnjmlj9i0alp407qd7c0vq83sz7gpsjrbdgpcn4xvzjp9r35ii3";
   };
 
   meta = {
diff --git a/pkgs/development/libraries/cpp-gsl/default.nix b/pkgs/development/libraries/cpp-gsl/default.nix
new file mode 100644
index 000000000000..833275c72bd0
--- /dev/null
+++ b/pkgs/development/libraries/cpp-gsl/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchFromGitHub, cmake, catch }:
+
+stdenv.mkDerivation rec {
+  pname = "GSL-unstable";
+  version = "2017-02-15";
+  name = "${pname}-${version}";
+
+  src = fetchFromGitHub {
+    owner = "Microsoft";
+    repo = "GSL";
+    rev = "c87c123d1b3e64ae2cf725584f0c004da4d90f1c";
+    sha256 = "0h8py468bvxnydkjs352d7a9s8hk0ihc7msjkcnzj2d7nzp5nsc1";
+  };
+
+  NIX_CFLAGS_COMPILE = "-Wno-error=sign-conversion";
+  nativeBuildInputs = [ cmake catch ];
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/Microsoft/GSL;
+    description = "C++ Core Guideline support library";
+    longDescription = ''
+     The Guideline Support Library (GSL) contains functions and types that are suggested for
+     use by the C++ Core Guidelines maintained by the Standard C++ Foundation.
+     This package contains Microsoft's implementation of GSL.
+    '';
+    platforms = stdenv.lib.platforms.unix;
+    license = licenses.mit;
+    maintainers = with maintainers; [ yuriaisaka ];
+  };
+}
diff --git a/pkgs/development/libraries/cpp-netlib/default.nix b/pkgs/development/libraries/cpp-netlib/default.nix
index ecc730597c31..e5391e7100d5 100644
--- a/pkgs/development/libraries/cpp-netlib/default.nix
+++ b/pkgs/development/libraries/cpp-netlib/default.nix
@@ -26,6 +26,5 @@ stdenv.mkDerivation rec {
     homepage    = http://cpp-netlib.org;
     license     = licenses.boost;
     platforms   = platforms.all;
-    maintainers = with maintainers; [ nckx ];
   };
 }
diff --git a/pkgs/development/libraries/cppdb/default.nix b/pkgs/development/libraries/cppdb/default.nix
index 72fa309b721f..07c6e1490e7e 100644
--- a/pkgs/development/libraries/cppdb/default.nix
+++ b/pkgs/development/libraries/cppdb/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cmake, sqlite, libmysql, postgresql, unixODBC }:
+{ stdenv, fetchurl, cmake, sqlite, mysql, postgresql, unixODBC }:
 
 stdenv.mkDerivation rec {
   name = "cppdb";
@@ -11,9 +11,10 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  buildInputs = [ cmake sqlite libmysql postgresql unixODBC ];
+  buildInputs = [ cmake sqlite mysql.connector-c postgresql unixODBC ];
 
   cmakeFlags = [ "--no-warn-unused-cli" ];
+  NIX_CFLAGS_COMPILE = [ "-I${mysql.connector-c}/include/mysql" "-L${mysql.connector-c}/lib/mysql" ];
 
   meta = with stdenv.lib; {
     homepage = http://cppcms.com/sql/cppdb/;
@@ -23,4 +24,3 @@ stdenv.mkDerivation rec {
     maintainers = [ maintainers.juliendehos ];
   };
 }
-
diff --git a/pkgs/development/libraries/cppzmq/default.nix b/pkgs/development/libraries/cppzmq/default.nix
index 301b245a9f54..9933d1034af8 100644
--- a/pkgs/development/libraries/cppzmq/default.nix
+++ b/pkgs/development/libraries/cppzmq/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "cppzmq-${version}";
-  version = "4.2.1";
+  version = "4.2.3";
 
   src = fetchFromGitHub {
     owner = "zeromq";
     repo = "cppzmq";
     rev = "v${version}";
-    sha256 = "0hy8yxb22siimq0pf6jq6kdp9lvi5f6al1xd12c9i1jyajhp1lhk";
+    sha256 = "1yjs25ra5s8zs0rhk50w3f1rrrl80hhq784lwdhh1m3risk740sa";
   };
 
   nativeBuildInputs = [ cmake ];
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/csfml/default.nix b/pkgs/development/libraries/csfml/default.nix
new file mode 100644
index 000000000000..8f66b65e49ac
--- /dev/null
+++ b/pkgs/development/libraries/csfml/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchFromGitHub, cmake, sfml }:
+
+let
+  version = "2.4";
+in
+
+stdenv.mkDerivation {
+  name = "csfml-${version}";
+  src = fetchFromGitHub {
+    owner = "SFML";
+    repo  = "CSFML";
+    rev   = "b5facb85d13bff451a5fd2d088a97472a685576c";
+    sha256 = "1q716gd7c7jlxzwpq5z4rjj5lsrn71ql2djphccdf9jannllqizn";
+  };
+  buildInputs = [ cmake sfml ];
+  cmakeFlags = [ "-DCMAKE_MODULE_PATH=${sfml}/share/SFML/cmake/Modules/" ];
+
+  meta = with stdenv.lib; {
+    homepage = http://www.sfml-dev.org/;
+    description = "Simple and fast multimedia library";
+    longDescription = ''
+      SFML is a simple, fast, cross-platform and object-oriented multimedia API.
+      It provides access to windowing, graphics, audio and network.
+      It is written in C++, and has bindings for various languages such as C, .Net, Ruby, Python.
+    '';
+    license = licenses.zlib;
+    maintainers = [ maintainers.jpdoyle ];
+
+    platforms = platforms.linux ++ platforms.darwin;
+  };
+}
diff --git a/pkgs/development/libraries/curlcpp/default.nix b/pkgs/development/libraries/curlcpp/default.nix
index c1579b717484..c1c867abcdf5 100644
--- a/pkgs/development/libraries/curlcpp/default.nix
+++ b/pkgs/development/libraries/curlcpp/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ cmake curl ];
 
   meta = with stdenv.lib; {
-    homepage = http://josephp91.github.io/curlcpp/;
+    homepage = https://josephp91.github.io/curlcpp/;
     description = "Object oriented C++ wrapper for CURL";
     platforms = platforms.unix;
     license = licenses.mit;
diff --git a/pkgs/development/libraries/cutee/default.nix b/pkgs/development/libraries/cutee/default.nix
index eb19283caeaf..ba1d02380e29 100644
--- a/pkgs/development/libraries/cutee/default.nix
+++ b/pkgs/development/libraries/cutee/default.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "C++ Unit Testing Easy Environment";
-    homepage    = http://codesink.org/cutee_unit_testing.html;
+    homepage    = http://www.codesink.org/cutee_unit_testing.html;
     license     = licenses.gpl2Plus;
     maintainers = with maintainers; [ leenaars];
     platforms = platforms.linux;
diff --git a/pkgs/development/libraries/cyrus-sasl/default.nix b/pkgs/development/libraries/cyrus-sasl/default.nix
index 68398e93764c..7a9e3991aadb 100644
--- a/pkgs/development/libraries/cyrus-sasl/default.nix
+++ b/pkgs/development/libraries/cyrus-sasl/default.nix
@@ -22,7 +22,8 @@ stdenv.mkDerivation rec {
 
   patches = [
     ./missing-size_t.patch # https://bugzilla.redhat.com/show_bug.cgi?id=906519
-    (fetchpatch { # CVE-2013-4122
+    (fetchpatch {
+      name = "CVE-2013-4122.patch";
       url = "http://sourceforge.net/projects/miscellaneouspa/files/glibc217/cyrus-sasl-2.1.26-glibc217-crypt.diff";
       sha256 = "05l7dh1w9d5fvzg0pjwzqh0fy4ah8y5cv6v67s4ssbq8xwd4pkf2";
     })
diff --git a/pkgs/development/libraries/czmq/3.x.nix b/pkgs/development/libraries/czmq/3.x.nix
index 0b4aeeb0801d..9c9d85134224 100644
--- a/pkgs/development/libraries/czmq/3.x.nix
+++ b/pkgs/development/libraries/czmq/3.x.nix
@@ -9,6 +9,8 @@ stdenv.mkDerivation rec {
     sha256 = "16k9awrhdsymx7dnmvqcnkaq8lz8x8zppy6sh7ls8prpd6mkkjlb";
   };
 
+  patches = [ ./czmq3-gcc7.patch ];
+
   # Fix build on Glibc 2.24.
   NIX_CFLAGS_COMPILE = "-Wno-error=deprecated-declarations";
 
diff --git a/pkgs/development/libraries/czmq/4.x.nix b/pkgs/development/libraries/czmq/4.x.nix
index 971d15686cab..840fa34d6ae1 100644
--- a/pkgs/development/libraries/czmq/4.x.nix
+++ b/pkgs/development/libraries/czmq/4.x.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, zeromq }:
+{ stdenv, fetchurl, fetchpatch, zeromq }:
 
 stdenv.mkDerivation rec {
   version = "4.0.2";
@@ -9,6 +9,13 @@ stdenv.mkDerivation rec {
     sha256 = "12gbh57xnz2v82x1g80gv4bwapmyzl00lbin5ix3swyac8i7m340";
   };
 
+  patches = [
+    (fetchpatch {
+      url = https://patch-diff.githubusercontent.com/raw/zeromq/czmq/pull/1618.patch;
+      sha256 = "1dssy7k0fni6djail8rz0lk8p777158jvrqhgn500i636gkxaxhp";
+    })
+  ];
+
   # Needs to be propagated for the .pc file to work
   propagatedBuildInputs = [ zeromq ];
 
diff --git a/pkgs/development/libraries/czmq/czmq3-gcc7.patch b/pkgs/development/libraries/czmq/czmq3-gcc7.patch
new file mode 100644
index 000000000000..4ab14685a6c1
--- /dev/null
+++ b/pkgs/development/libraries/czmq/czmq3-gcc7.patch
@@ -0,0 +1,26 @@
+diff --git a/src/zgossip_engine.inc b/src/zgossip_engine.inc
+index 37dbb4eb..727aaa9b 100644
+--- a/src/zgossip_engine.inc
++++ b/src/zgossip_engine.inc
+@@ -258,7 +258,7 @@ engine_set_log_prefix (client_t *client, const char *string)
+ {
+     if (client) {
+         s_client_t *self = (s_client_t *) client;
+-        snprintf (self->log_prefix, sizeof (self->log_prefix) - 1,
++        snprintf (self->log_prefix, sizeof (self->log_prefix),
+             "%6d:%-33s", self->unique_id, string);
+     }
+ }
+diff --git a/src/zsys.c b/src/zsys.c
+index 4d0bb8a1..f07db9c8 100644
+--- a/src/zsys.c
++++ b/src/zsys.c
+@@ -1071,7 +1071,7 @@ zsys_run_as (const char *lockfile, const char *group, const char *user)
+             }
+         }
+         //   We record the current process id in the lock file
+-        char pid_buffer [10];
++        char pid_buffer [32];
+         snprintf (pid_buffer, sizeof (pid_buffer), "%6d\n", getpid ());
+         if (write (handle, pid_buffer, strlen (pid_buffer)) != strlen (pid_buffer)) {
+             zsys_error ("cannot write to lockfile: %s", strerror (errno));
diff --git a/pkgs/development/libraries/dbus-cplusplus/default.nix b/pkgs/development/libraries/dbus-cplusplus/default.nix
index ee7afbbf2522..051405811438 100644
--- a/pkgs/development/libraries/dbus-cplusplus/default.nix
+++ b/pkgs/development/libraries/dbus-cplusplus/default.nix
@@ -10,11 +10,26 @@ stdenv.mkDerivation rec {
     sha256 = "0qafmy2i6dzx4n1dqp6pygyy6gjljnb7hwjcj2z11c1wgclsq4dw";
   };
 
-  patches = [( fetchurl {
-    url = http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-libs/dbus-c%2B%2B/files/dbus-c%2B%2B-0.9.0-gcc-4.7.patch;
-    name = "gcc-4.7.patch";
-    sha256 = "0rwcz9pvc13b3yfr0lkifnfz0vb5q6dg240bzgf37ni4s8rpc72g";
-  })];
+  patches = [
+    (fetchurl {
+      name = "gcc-4.7.patch";
+      url = "http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-libs/"
+          + "dbus-c%2B%2B/files/dbus-c%2B%2B-0.9.0-gcc-4.7.patch";
+      sha256 = "0rwcz9pvc13b3yfr0lkifnfz0vb5q6dg240bzgf37ni4s8rpc72g";
+    })
+    (fetchurl {
+      name = "writechar.patch"; # since gcc7
+      url = "https://src.fedoraproject.org/cgit/rpms/dbus-c++.git/plain/"
+          + "dbus-c++-writechar.patch?id=7f371172f5c";
+      sha256 = "1kkg4gbpm4hp87l25zw2a3r9c58g7vvgzcqgiman734i66zsbb9l";
+    })
+    (fetchurl {
+      name = "threading.patch"; # since gcc7
+      url = "https://src.fedoraproject.org/cgit/rpms/dbus-c++.git/plain/"
+          + "dbus-c++-threading.patch?id=7f371172f5c";
+      sha256 = "1h362anx3wyxm5lq0v8girmip1jmkdbijrmbrq7k5pp47zkhwwrq";
+    })
+  ];
 
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ dbus glib expat ];
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/dbus/make-dbus-conf.nix b/pkgs/development/libraries/dbus/make-dbus-conf.nix
index d836d87efef8..b5bf2b230007 100644
--- a/pkgs/development/libraries/dbus/make-dbus-conf.nix
+++ b/pkgs/development/libraries/dbus/make-dbus-conf.nix
@@ -11,6 +11,7 @@
 runCommand "dbus-1"
   {
     inherit serviceDirectories suidHelper;
+    preferLocalBuild = true;
     XML_CATALOG_FILES = writeText "dbus-catalog.xml" ''
       <?xml version="1.0"?>
       <!DOCTYPE catalog PUBLIC
@@ -23,16 +24,17 @@ runCommand "dbus-1"
           rewritePrefix="file://${dbus}/share/xml/dbus/"/>
       </catalog>
     '';
+    nativeBuildInputs = [ libxslt.bin ];
   }
   ''
     mkdir -p $out
 
-    ${libxslt.bin}/bin/xsltproc --nonet \
+    xsltproc --nonet \
       --stringparam serviceDirectories "$serviceDirectories" \
       --stringparam suidHelper "$suidHelper" \
       ${./make-system-conf.xsl} ${dbus}/share/dbus-1/system.conf \
       > $out/system.conf
-    ${libxslt.bin}/bin/xsltproc --nonet \
+    xsltproc --nonet \
       --stringparam serviceDirectories "$serviceDirectories" \
       ${./make-session-conf.xsl} ${dbus}/share/dbus-1/session.conf \
       > $out/session.conf
diff --git a/pkgs/development/libraries/dbus/make-system-conf.xsl b/pkgs/development/libraries/dbus/make-system-conf.xsl
index 3d8b823437d6..dd644b4bce7c 100644
--- a/pkgs/development/libraries/dbus/make-system-conf.xsl
+++ b/pkgs/development/libraries/dbus/make-system-conf.xsl
@@ -27,6 +27,7 @@
       <xsl:for-each select="str:tokenize($serviceDirectories)">
         <servicedir><xsl:value-of select="." />/share/dbus-1/system-services</servicedir>
         <includedir><xsl:value-of select="." />/etc/dbus-1/system.d</includedir>
+        <includedir><xsl:value-of select="." />/share/dbus-1/system.d</includedir>
       </xsl:for-each>
     </busconfig>
   </xsl:template>
diff --git a/pkgs/development/libraries/dirac/default.nix b/pkgs/development/libraries/dirac/default.nix
index b64c6c84980a..5b05d64f0727 100644
--- a/pkgs/development/libraries/dirac/default.nix
+++ b/pkgs/development/libraries/dirac/default.nix
@@ -22,10 +22,10 @@ stdenv.mkDerivation rec {
   '';
 
   meta = with stdenv.lib; {
-    homepage = http://sourceforge.net/projects/dirac;
+    homepage = https://sourceforge.net/projects/dirac;
     description = "A general-purpose video codec based on wavelets";
     platforms = platforms.linux;
     license = with licenses; [ mpl11 gpl2 lgpl21 ];
-    maintainer = maintainers.igsha;
+    maintainers = [ maintainers.igsha ];
   };
 }
diff --git a/pkgs/development/libraries/dleyna-connector-dbus/default.nix b/pkgs/development/libraries/dleyna-connector-dbus/default.nix
new file mode 100644
index 000000000000..94efa8e31d3a
--- /dev/null
+++ b/pkgs/development/libraries/dleyna-connector-dbus/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, autoreconfHook, pkgconfig, fetchFromGitHub, dbus, dleyna-core, glib }:
+
+stdenv.mkDerivation rec {
+  name = "dleyna-connector-dbus";
+  version = "0.3.0";
+
+  src = fetchFromGitHub {
+    owner = "01org";
+    repo = name;
+    rev = "${version}";
+    sha256 = "0vziq5gwjm79yl2swch2mz6ias20nvfddf5cqgk9zbg25cb9m117";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ dbus dleyna-core glib ];
+
+  meta = with stdenv.lib; {
+    description = "A D-Bus API for the dLeyna services";
+    homepage = http://01.org/dleyna;
+    maintainers = [ maintainers.jtojnar ];
+    platforms = platforms.linux;
+    license = licenses.lgpl21;
+  };
+}
diff --git a/pkgs/development/libraries/dleyna-core/0001-Search-connectors-in-DLEYNA_CONNECTOR_PATH.patch b/pkgs/development/libraries/dleyna-core/0001-Search-connectors-in-DLEYNA_CONNECTOR_PATH.patch
new file mode 100644
index 000000000000..cc50c1598005
--- /dev/null
+++ b/pkgs/development/libraries/dleyna-core/0001-Search-connectors-in-DLEYNA_CONNECTOR_PATH.patch
@@ -0,0 +1,95 @@
+From bf549a028a5da122b7a4206529711b969c2ecd48 Mon Sep 17 00:00:00 2001
+From: Jan Tojnar <jtojnar@gmail.com>
+Date: Fri, 1 Sep 2017 13:49:06 +0200
+Subject: [PATCH] Search connectors in DLEYNA_CONNECTOR_PATH
+
+Previously, the connectors would only be looked for in a single
+directory, specified during compilation. This patch allows to
+traverse a list of directories provided by an environment variable.
+---
+ libdleyna/core/connector-mgr.c | 63 ++++++++++++++++++++++++++++--------------
+ 1 file changed, 42 insertions(+), 21 deletions(-)
+
+diff --git a/libdleyna/core/connector-mgr.c b/libdleyna/core/connector-mgr.c
+index eafb16c..8041c67 100644
+--- a/libdleyna/core/connector-mgr.c
++++ b/libdleyna/core/connector-mgr.c
+@@ -34,33 +34,54 @@ const dleyna_connector_t *dleyna_connector_mgr_load(const gchar *name)
+ 	const dleyna_connector_t *connector;
+ 	dleyna_connector_get_interface_t get_interface;
+ 	gchar *path;
++	const gchar *connector_path;
++	gchar **connector_path_list;
++	gsize i;
+ 
+ 	DLEYNA_LOG_DEBUG("Enter");
+ 
+-	path = g_strdup_printf("%s/%s%s.so", CONNECTOR_DIR,
+-			       DLEYNA_CONNECTOR_LIB_PATTERN, name);
+-	module = g_module_open(path, G_MODULE_BIND_LAZY);
+-	g_free(path);
++	connector_path = g_getenv ("DLEYNA_CONNECTOR_PATH");
++	if (!connector_path) {
++		DLEYNA_LOG_DEBUG ("DLEYNA_CONNECTOR_PATH not set");
++		connector_path = CONNECTOR_DIR;
++	} else {
++		DLEYNA_LOG_DEBUG ("DLEYNA_CONNECTOR_PATH set to %s", connector_path);
++	}
++
++	connector_path_list = g_strsplit (connector_path, G_SEARCHPATH_SEPARATOR_S, 0);
++
++	for (i = 0; connector_path_list[i]; i++) {
++		path = g_strdup_printf("%s/%s%s.so", connector_path_list[i],
++				       DLEYNA_CONNECTOR_LIB_PATTERN, name);
++		module = g_module_open(path, G_MODULE_BIND_LAZY);
++		g_free(path);
++
++		if (module) {
++			if (!g_connectors)
++				g_connectors = g_hash_table_new(g_direct_hash,
++								g_direct_equal);
++
++			if (g_module_symbol(module, "dleyna_connector_get_interface",
++					    (gpointer *)&get_interface)) {
++				connector = get_interface();
++				g_hash_table_insert(g_connectors, (gpointer)connector,
++						    module);
++
++				break;
++			} else {
++				connector = NULL;
++				g_module_close(module);
++				DLEYNA_LOG_CRITICAL(
++						"Connector '%s' entry point not found",
++						name);
++			}
+ 
+-	if (module) {
+-		if (!g_connectors)
+-			g_connectors = g_hash_table_new(g_direct_hash,
+-							g_direct_equal);
+-
+-		if (g_module_symbol(module, "dleyna_connector_get_interface",
+-				    (gpointer *)&get_interface)) {
+-			connector = get_interface();
+-			g_hash_table_insert(g_connectors, (gpointer)connector,
+-					    module);
+-		} else {
+-			connector = NULL;
+-			g_module_close(module);
+-			DLEYNA_LOG_CRITICAL(
+-					"Connector '%s' entry point not found",
+-					name);
+ 		}
++	}
+ 
+-	} else {
++	g_strfreev (connector_path_list);
++
++	if (!module) {
+ 		connector = NULL;
+ 		DLEYNA_LOG_CRITICAL("Connector '%s' not found", name);
+ 	}
+-- 
+2.14.1
+
diff --git a/pkgs/development/libraries/dleyna-core/default.nix b/pkgs/development/libraries/dleyna-core/default.nix
new file mode 100644
index 000000000000..1fc65b9ac7f0
--- /dev/null
+++ b/pkgs/development/libraries/dleyna-core/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, autoreconfHook, pkgconfig, fetchFromGitHub, gupnp }:
+
+stdenv.mkDerivation rec {
+  name = "dleyna-core";
+  version = "0.6.0";
+
+  src = fetchFromGitHub {
+    owner = "01org";
+    repo = name;
+    rev = "v${version}";
+    sha256 = "1x5vj5zfk95avyg6g3nf6gar250cfrgla2ixj2ifn8pcick2d9vq";
+  };
+
+  setupHook = ./setup-hook.sh;
+
+  patches = [ ./0001-Search-connectors-in-DLEYNA_CONNECTOR_PATH.patch ];
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  propagatedBuildInputs = [ gupnp ];
+
+  meta = with stdenv.lib; {
+    description = "Library of utility functions that are used by the higher level dLeyna";
+    homepage = http://01.org/dleyna;
+    maintainers = [ maintainers.jtojnar ];
+    platforms = platforms.linux;
+    license = licenses.lgpl21;
+  };
+}
diff --git a/pkgs/development/libraries/dleyna-core/setup-hook.sh b/pkgs/development/libraries/dleyna-core/setup-hook.sh
new file mode 100644
index 000000000000..87b5c67dff58
--- /dev/null
+++ b/pkgs/development/libraries/dleyna-core/setup-hook.sh
@@ -0,0 +1,8 @@
+addDleynaConnectorPath () {
+    if test -d "$1/lib/dleyna-1.0/connectors"
+    then
+        export DLEYNA_CONNECTOR_PATH="${DLEYNA_CONNECTOR_PATH}${DLEYNA_CONNECTOR_PATH:+:}$1/lib/dleyna-1.0/connectors"
+    fi
+}
+
+addEnvHooks "$targetOffset" addDleynaConnectorPath
diff --git a/pkgs/development/libraries/dleyna-renderer/default.nix b/pkgs/development/libraries/dleyna-renderer/default.nix
new file mode 100644
index 000000000000..176b05126b2b
--- /dev/null
+++ b/pkgs/development/libraries/dleyna-renderer/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, autoreconfHook, pkgconfig, fetchFromGitHub, dleyna-connector-dbus, dleyna-core, gssdp, gupnp, gupnp-av, gupnp-dlna, libsoup, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "dleyna-renderer";
+  version = "0.6.0";
+
+  src = fetchFromGitHub {
+    owner = "01org";
+    repo = name;
+    rev = "${version}";
+    sha256 = "0jy54aq8hgrvzchrvfzqaj4pcn0cfhafl9bv8a9p6j82yjk4pvpp";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig makeWrapper ];
+  buildInputs = [ dleyna-core dleyna-connector-dbus gssdp gupnp gupnp-av gupnp-dlna libsoup ];
+
+  preFixup = ''
+    wrapProgram "$out/libexec/dleyna-renderer-service" \
+      --set DLEYNA_CONNECTOR_PATH "$DLEYNA_CONNECTOR_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Library to discover and manipulate Digital Media Renderers";
+    homepage = http://01.org/dleyna;
+    maintainers = [ maintainers.jtojnar ];
+    platforms = platforms.linux;
+    license = licenses.lgpl21;
+  };
+}
diff --git a/pkgs/development/libraries/dleyna-server/default.nix b/pkgs/development/libraries/dleyna-server/default.nix
new file mode 100644
index 000000000000..d36e665bd85d
--- /dev/null
+++ b/pkgs/development/libraries/dleyna-server/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, autoreconfHook, makeWrapper, pkgconfig, fetchFromGitHub, dleyna-core, dleyna-connector-dbus, gssdp, gupnp, gupnp-av, gupnp-dlna, libsoup }:
+
+stdenv.mkDerivation rec {
+  name = "dleyna-server";
+  version = "0.6.0";
+
+  src = fetchFromGitHub {
+    owner = "01org";
+    repo = name;
+    rev = "${version}";
+    sha256 = "13a2i6ms27s46yxdvlh2zm7pim7jmr5cylnygzbliz53g3gxxl3j";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig makeWrapper ];
+  buildInputs = [ dleyna-core dleyna-connector-dbus gssdp gupnp gupnp-av gupnp-dlna libsoup ];
+
+  preFixup = ''
+    wrapProgram "$out/libexec/dleyna-server-service" \
+      --set DLEYNA_CONNECTOR_PATH "$DLEYNA_CONNECTOR_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Library to discover, browse and manipulate Digital Media Servers";
+    homepage = http://01.org/dleyna;
+    maintainers = [ maintainers.jtojnar ];
+    platforms = platforms.linux;
+    license = licenses.lgpl21;
+  };
+}
diff --git a/pkgs/development/libraries/dlib/default.nix b/pkgs/development/libraries/dlib/default.nix
index 61932b29e62c..eaae1f7ecdad 100644
--- a/pkgs/development/libraries/dlib/default.nix
+++ b/pkgs/development/libraries/dlib/default.nix
@@ -3,14 +3,14 @@
 }:
 
 stdenv.mkDerivation rec {
-  version = "19.6";
+  version = "19.9";
   name = "dlib-${version}";
 
   src = fetchFromGitHub {
     owner = "davisking";
     repo = "dlib";
     rev ="v${version}";
-    sha256 = "1nlx4z53jnk7wysaxrzbyyqb65m45rw4g1fagazl2jvwh1qn49ds";
+    sha256 = "0lc54r928j9dg7f2wn25m887z24d31wrc14v2hn6aknp1z084lrc";
   };
 
   postPatch = ''
@@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
     homepage = http://www.dlib.net;
     license = licenses.boost;
     maintainers = with maintainers; [ christopherpoole ];
-    platforms = platforms.all;
+    platforms = platforms.linux;
   };
 }
 
diff --git a/pkgs/development/libraries/dotconf/default.nix b/pkgs/development/libraries/dotconf/default.nix
index efadff6a1138..a2b2e08fd622 100644
--- a/pkgs/development/libraries/dotconf/default.nix
+++ b/pkgs/development/libraries/dotconf/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
   meta = with stdenv.lib; {
     description = "A configuration parser library";
     maintainers = with maintainers; [ pSub ];
-    homepage = http://www.azzit.de/dotconf/;
+    homepage = https://github.com/williamh/dotconf;
     license = licenses.lgpl21Plus;
     platforms = with platforms; unix;
   };
diff --git a/pkgs/development/libraries/double-conversion/default.nix b/pkgs/development/libraries/double-conversion/default.nix
index 47c165c1bad1..7a33559cbc79 100644
--- a/pkgs/development/libraries/double-conversion/default.nix
+++ b/pkgs/development/libraries/double-conversion/default.nix
@@ -1,20 +1,25 @@
-{ stdenv, fetchFromGitHub, cmake }:
+{ stdenv, lib, fetchFromGitHub, cmake }:
 
 stdenv.mkDerivation rec {
   name = "double-conversion-${version}";
-  version = "2.0.1";
+  version = "3.0.0";
 
   src = fetchFromGitHub {
     owner = "google";
     repo = "double-conversion";
     rev = "v${version}";
-    sha256 = "05x5rdwndgp1vdq2z1bpvng0dd8pn93kw4vhl6nsvv9vsara2q4b";
+    sha256 = "05m78wlwrg310mxh1cl3d8d0ishzfvzh84x64xmvng252m0vc8yz";
   };
 
   nativeBuildInputs = [ cmake ];
 
   cmakeFlags = [ "-DBUILD_SHARED_LIBS=ON" ];
 
+  # Case sensitivity issue
+  preConfigure = lib.optionalString stdenv.isDarwin ''
+    rm BUILD
+  '';
+
   enableParallelBuilding = true;
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/drumstick/default.nix b/pkgs/development/libraries/drumstick/default.nix
index a46c6bab6479..ab25a651844a 100644
--- a/pkgs/development/libraries/drumstick/default.nix
+++ b/pkgs/development/libraries/drumstick/default.nix
@@ -4,11 +4,11 @@
 
 stdenv.mkDerivation rec {
   name = "drumstick-${version}";
-  version = "1.1.0";
+  version = "1.1.1";
 
   src = fetchurl {
     url = "mirror://sourceforge/drumstick/${version}/${name}.tar.bz2";
-    sha256 = "13pkfqrav30bbcddgf1imd7jk6lpqbxkz1qv31718pdl446jq7df";
+    sha256 = "0avwxr6n9ra7narxc5lmkhdqi8ix10gmif8rpd06wp4g9iv46xrn";
   };
 
   outputs = [ "out" "dev" "man" ];
diff --git a/pkgs/development/libraries/easyloggingpp/default.nix b/pkgs/development/libraries/easyloggingpp/default.nix
index fe14a1b2b77c..8c6337cfaf60 100644
--- a/pkgs/development/libraries/easyloggingpp/default.nix
+++ b/pkgs/development/libraries/easyloggingpp/default.nix
@@ -1,18 +1,26 @@
+# To use this package with a CMake and pkg-config build:
+# pkg_check_modules(EASYLOGGINGPP REQUIRED easyloggingpp)
+# add_executable(main src/main.cpp ${EASYLOGGINGPP_PREFIX}/include/easylogging++.cc)
 { stdenv, fetchFromGitHub, cmake, gtest }:
 stdenv.mkDerivation rec {
   name = "easyloggingpp-${version}";
-  version = "9.95.0";
+  version = "9.96.4";
   src = fetchFromGitHub {
     owner = "muflihun";
     repo = "easyloggingpp";
     rev = "v${version}";
-    sha256 = "0gzmznw6ffag9x55lixxffy6x7mvb7691x0md4q9rbh88zkws7kq";
+    sha256 = "0l0b8cssxkj0wlfqjj8hfnfvrjcxa81h947d54w86iadrilrsprb";
   };
+
   nativeBuildInputs = [cmake];
   buildInputs = [gtest];
-  cmakeFlags = [ "-Dtest=ON" "-Dbuild_static_lib=ON"];
+  cmakeFlags = [ "-Dtest=ON" ];
   NIX_CFLAGS_COMPILE = "-std=c++11" +
     stdenv.lib.optionalString stdenv.isLinux " -pthread";
+  postInstall = ''
+    mkdir -p $out/include
+    cp ../src/easylogging++.cc $out/include
+  '';
   meta = {
     description = "C++ logging library";
     homepage = https://muflihun.github.io/easyloggingpp/;
diff --git a/pkgs/development/libraries/eccodes/default.nix b/pkgs/development/libraries/eccodes/default.nix
index 672fed2f015a..49dcb31c0478 100644
--- a/pkgs/development/libraries/eccodes/default.nix
+++ b/pkgs/development/libraries/eccodes/default.nix
@@ -6,11 +6,11 @@
 with stdenv.lib; 
 stdenv.mkDerivation rec {
   name = "eccodes-${version}";
-  version = "2.2.0";
+  version = "2.7.0";
 
   src = fetchurl {
-    url = https://software.ecmwf.int/wiki/download/attachments/45757960/eccodes-2.2.0-Source.tar.gz;
-    sha256 = "1hzl0akjfxphqivnaj2kg131w8ki80ba3872h0a45f4pchci4h8s";
+    url = "https://software.ecmwf.int/wiki/download/attachments/45757960/eccodes-${version}-Source.tar.gz";
+    sha256 = "0slfim64wdyd97nwv7ry0xwhiarphl93ij2v19c8a1c0dz7ld3qi";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/eigen/3.3.nix b/pkgs/development/libraries/eigen/3.3.nix
index 94652b129345..5d13fb09dcca 100644
--- a/pkgs/development/libraries/eigen/3.3.nix
+++ b/pkgs/development/libraries/eigen/3.3.nix
@@ -1,7 +1,7 @@
 {stdenv, fetchurl, cmake}:
 
 let
-  version = "3.3.3";
+  version = "3.3.4";
 in
 stdenv.mkDerivation {
   name = "eigen-${version}";
@@ -9,7 +9,7 @@ stdenv.mkDerivation {
   src = fetchurl {
     url = "http://bitbucket.org/eigen/eigen/get/${version}.tar.gz";
     name = "eigen-${version}.tar.gz";
-    sha256 = "0pz7k8kd9nydmsj2prjs67apixipl6pll3f0cjy0y3bvlazqr1wl";
+    sha256 = "1q85bgd6hnsgn0kq73wa4jwh4qdwklfg73pgqrz4zmxvzbqyi1j2";
   };
   
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/elementary-cmake-modules/default.nix b/pkgs/development/libraries/elementary-cmake-modules/default.nix
new file mode 100644
index 000000000000..5287db756094
--- /dev/null
+++ b/pkgs/development/libraries/elementary-cmake-modules/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, lib, fetchFromGitHub, cmake, pkgconfig }:
+
+stdenv.mkDerivation {
+  name = "elementary-cmake-modules";
+
+  src = fetchFromGitHub {
+    owner = "elementary";
+    repo = "cmake-modules";
+    rev = "319ec5336e9f05f3f22b886cc2053ef3d4b6599e";
+    sha256 = "191hhvdxyqvh9axzndaqld7vrmv7xkn0czks908zhb2zpjhv9rby";
+  };
+
+  prePatch = ''
+    substituteInPlace CMakeLists.txt  \
+      --replace ' ''${CMAKE_ROOT}/Modules' " $out/lib/cmake"
+  '';
+
+  propagatedBuildInputs = [ cmake pkgconfig ];
+
+  setupHook = ./setup-hook.sh;
+
+  meta = with lib; {
+    platforms = platforms.linux ++ platforms.darwin;
+    homepage = https://github.com/elementary/cmake-modules;
+    license = licenses.gpl3Plus;
+    maintainers = [ maintainers.samdroid-apps ];
+  };
+}
diff --git a/pkgs/development/libraries/elementary-cmake-modules/setup-hook.sh b/pkgs/development/libraries/elementary-cmake-modules/setup-hook.sh
new file mode 100644
index 000000000000..6408ac471577
--- /dev/null
+++ b/pkgs/development/libraries/elementary-cmake-modules/setup-hook.sh
@@ -0,0 +1,4 @@
+_elementaryCMakeEnvHook() {
+  cmakeFlagsArray+=(-DCMAKE_MODULE_PATH=@out@/lib/cmake)
+}
+addEnvHooks "$targetOffset" _elementaryCMakeEnvHook
diff --git a/pkgs/development/libraries/enchant/2.x.nix b/pkgs/development/libraries/enchant/2.x.nix
new file mode 100644
index 000000000000..458b23c33e94
--- /dev/null
+++ b/pkgs/development/libraries/enchant/2.x.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchurl, aspell, pkgconfig, glib, hunspell, hspell }:
+
+let
+  version = "2.2.3";
+  pname = "enchant";
+in stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+
+  outputs = [ "out" "dev" ];
+
+  src = fetchurl {
+    url = "https://github.com/AbiWord/${pname}/releases/download/v${version}/${name}.tar.gz";
+    sha256 = "0v87p1ls0gym95qirijpclk650sjbkcjjl6ssk059zswcwaykn5b";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ glib hunspell ];
+  propagatedBuildInputs = [ hspell aspell ]; # libtool puts it to la file
+
+  meta = with stdenv.lib; {
+    description = "Generic spell checking library";
+    homepage = https://abiword.github.io/enchant/;
+    license = licenses.lgpl21Plus; # with extra provision for non-free checkers
+    maintainers = with maintainers; [ jtojnar ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/epoxy/default.nix b/pkgs/development/libraries/epoxy/default.nix
index 18ce05af07a8..e0f8e9ff8c76 100644
--- a/pkgs/development/libraries/epoxy/default.nix
+++ b/pkgs/development/libraries/epoxy/default.nix
@@ -1,29 +1,35 @@
 { stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, utilmacros, python
-, mesa, libX11
+, libGL, libX11
 }:
 
+with stdenv.lib;
+
 stdenv.mkDerivation rec {
   name = "epoxy-${version}";
-  version = "1.3.1";
+  version = "1.5.0";
 
   src = fetchFromGitHub {
     owner = "anholt";
     repo = "libepoxy";
-    rev = "v${version}";
-    sha256 = "0dfkd4xbp7v5gwsf6qwaraz54yzizf3lj5ymyc0msjn0adq3j5yl";
+    rev = "${version}";
+    sha256 = "1ixpqb10pmdy3n9nxd5inflig9dal5502ggadcns5b58j6jr0yv0";
   };
 
   outputs = [ "out" "dev" ];
 
   nativeBuildInputs = [ autoreconfHook pkgconfig utilmacros python ];
-  buildInputs = [ mesa libX11 ];
+  buildInputs = [ libGL libX11 ];
 
-  preConfigure = stdenv.lib.optional stdenv.isDarwin ''
+  preConfigure = optionalString stdenv.isDarwin ''
     substituteInPlace configure --replace build_glx=no build_glx=yes
     substituteInPlace src/dispatch_common.h --replace "PLATFORM_HAS_GLX 0" "PLATFORM_HAS_GLX 1"
   '';
 
-  meta = with stdenv.lib; {
+  patches = [ ./libgl-path.patch ];
+
+  NIX_CFLAGS_COMPILE = ''-DLIBGL_PATH="${getLib libGL}/lib"'';
+
+  meta = {
     description = "A library for handling OpenGL function pointer management";
     homepage = https://github.com/anholt/libepoxy;
     license = licenses.mit;
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/esdl/default.nix b/pkgs/development/libraries/esdl/default.nix
index af8258a01966..7b40359837a3 100644
--- a/pkgs/development/libraries/esdl/default.nix
+++ b/pkgs/development/libraries/esdl/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, SDL, mesa, rebar, erlang}:
+{stdenv, fetchurl, SDL, libGLU_combined, rebar, erlang}:
 
 stdenv.mkDerivation rec {
   name = "esdl-1.3.1";
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs = [ erlang rebar ];
-  propagatedBuildInputs = [ SDL mesa ];
+  propagatedBuildInputs = [ SDL libGLU_combined ];
 
   buildPhase = ''
     rebar compile
diff --git a/pkgs/development/libraries/exempi/default.nix b/pkgs/development/libraries/exempi/default.nix
index b486a327466d..1f58fd698da3 100644
--- a/pkgs/development/libraries/exempi/default.nix
+++ b/pkgs/development/libraries/exempi/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, expat, zlib, boost, libiconv, darwin }:
 
 stdenv.mkDerivation rec {
-  name = "exempi-2.4.2";
+  name = "exempi-2.4.5";
 
   src = fetchurl {
     url = "http://libopenraw.freedesktop.org/download/${name}.tar.bz2";
-    sha256 = "1v665fc7x0yi7x6lzskvd8bd2anf7951svn2vd5384dblmgv43av";
+    sha256 = "07i29xmg8bqriviaf4vi1mwha4lrw85kfla29cfym14fp3z8aqa0";
   };
 
   configureFlags = [
diff --git a/pkgs/development/libraries/exiv2/default.nix b/pkgs/development/libraries/exiv2/default.nix
index a1a07b43197f..7f5f19035179 100644
--- a/pkgs/development/libraries/exiv2/default.nix
+++ b/pkgs/development/libraries/exiv2/default.nix
@@ -7,6 +7,24 @@ stdenv.mkDerivation rec {
     url = "http://www.exiv2.org/builds/${name}-trunk.tar.gz";
     sha256 = "1yza317qxd8yshvqnay164imm0ks7cvij8y8j86p1gqi1153qpn7";
   };
+
+  patches = [
+    (fetchurl rec {
+      name = "CVE-2017-9239.patch";
+      url = let patchname = "0006-1296-Fix-submitted.patch";
+          in "https://src.fedoraproject.org/lookaside/pkgs/exiv2/${patchname}"
+          + "/sha512/${sha512}/${patchname}";
+      sha512 = "3f9242dbd4bfa9dcdf8c9820243b13dc14990373a800c4ebb6cf7eac5653cfef"
+             + "e6f2c47a94fbee4ed24f0d8c2842729d721f6100a2b215e0f663c89bfefe9e32";
+     })
+     (fetchpatch {
+       # many CVEs - see https://github.com/Exiv2/exiv2/pull/120
+       url = "https://patch-diff.githubusercontent.com/raw/Exiv2/exiv2/pull/120.patch";
+       sha256 = "1szl22xmh12hibzaqf2zi8zl377x841m52x4jm5lziw6j8g81sj8";
+       excludes = [ "test/bugfixes-test.sh" ];
+     })
+  ];
+
   postPatch = "patchShebangs ./src/svn_version.sh";
 
   outputs = [ "out" "dev" ];
diff --git a/pkgs/development/libraries/expat/default.nix b/pkgs/development/libraries/expat/default.nix
index 77b826acc032..e341ce842eb6 100644
--- a/pkgs/development/libraries/expat/default.nix
+++ b/pkgs/development/libraries/expat/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchpatch, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "expat-2.2.4";
+  name = "expat-2.2.5";
 
   src = fetchurl {
     url = "mirror://sourceforge/expat/${name}.tar.bz2";
-    sha256 = "17h1fb9zvqvf0sr78j211bngc6jpql5wzar8fg9b52jzjvdqbb83";
+    sha256 = "1xpd78sp7m34jqrw5x13bz7kgz0n6aj15wn4zj4gfx3ypbpk5p6r";
   };
 
   outputs = [ "out" "dev" ]; # TODO: fix referrers
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
 
   outputMan = "dev"; # tiny page for a dev tool
 
-  doCheck = stdenv.hostPlatform == stdenv.buildPlatform;
+  doCheck = true; # not cross;
 
   preCheck = ''
     patchShebangs ./run.sh
diff --git a/pkgs/development/libraries/faac/default.nix b/pkgs/development/libraries/faac/default.nix
index 554337860028..516968861482 100644
--- a/pkgs/development/libraries/faac/default.nix
+++ b/pkgs/development/libraries/faac/default.nix
@@ -8,11 +8,11 @@ assert mp4v2Support -> (mp4v2 != null);
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "faac-${version}";
-  version = "1.29.3";
+  version = "1.29.9.2";
 
   src = fetchurl {
     url = "mirror://sourceforge/faac/${name}.tar.gz";
-    sha256 = "0gssrz2vq52mj8x2hvdqc9bwkp64s4f4g7yj7ac6dwxs8dw8kwnf";
+    sha256 = "0wf781vp7rzmxkx5h0w8j2i4xc63iixxikgbvvkdljbwhffj0pyl";
   };
 
   configureFlags = [ ]
@@ -26,6 +26,8 @@ stdenv.mkDerivation rec {
   buildInputs = [ ]
     ++ optional mp4v2Support mp4v2;
 
+  enableParallelBuilding = true;
+
   meta = {
     description = "Open source MPEG-4 and MPEG-2 AAC encoder";
     homepage    = http://www.audiocoding.com/faac.html;
diff --git a/pkgs/development/libraries/faad2/default.nix b/pkgs/development/libraries/faad2/default.nix
index 865bedf09ba2..04a6b9c53545 100644
--- a/pkgs/development/libraries/faad2/default.nix
+++ b/pkgs/development/libraries/faad2/default.nix
@@ -5,10 +5,10 @@
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "faad2-${version}";
-  version = "2.7";
+  version = "2.8.8";
 
   src = fetchurl {
-    url = "mirror://sourceforge/faac/${name}.tar.bz2";
+    url = "mirror://sourceforge/faac/${name}.tar.gz";
     sha256 = "1db37ydb6mxhshbayvirm5vz6j361bjim4nkpwjyhmy4ddfinmhl";
   };
 
diff --git a/pkgs/development/libraries/facile/default.nix b/pkgs/development/libraries/facile/default.nix
deleted file mode 100644
index 4050bdfd9eb0..000000000000
--- a/pkgs/development/libraries/facile/default.nix
+++ /dev/null
@@ -1,29 +0,0 @@
-{ stdenv, fetchurl, ocaml }:
-
-stdenv.mkDerivation rec {
-  name = "facile-1.1";
-  
-  src = fetchurl {
-    url = "${meta.homepage}/distrib/${name}.tar.gz";
-    sha256 = "1jp59ankjds8mh4vm0b5h4fd1lcbfn0rd6n151cgh14ihsknnym8";
-  };
-  
-  dontAddPrefix = 1;
-
-  patches = [ ./ocaml_4.xx.patch ];
-
-  postPatch = "sed -e 's@mkdir@mkdir -p@' -i Makefile";
-
-  postConfigure = "make -C src .depend";
-  
-  makeFlags = "FACILEDIR=\${out}/lib/ocaml/facile";
-  
-  buildInputs = [ ocaml ];
-
-  meta = {
-    homepage = http://www.recherche.enac.fr/log/facile;
-    license = "LGPL";
-    description = "A Functional Constraint Library";
-    platforms = stdenv.lib.platforms.unix;
-  };
-}
diff --git a/pkgs/development/libraries/facile/ocaml_4.xx.patch b/pkgs/development/libraries/facile/ocaml_4.xx.patch
deleted file mode 100644
index 429405fabdaa..000000000000
--- a/pkgs/development/libraries/facile/ocaml_4.xx.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -rupN facile-1.1/src/fcl_data.ml facile-1.1-patched//src/fcl_data.ml
---- facile-1.1/src/fcl_data.ml	2004-09-08 11:51:02.000000000 +0200
-+++ facile-1.1-patched//src/fcl_data.ml	2012-12-16 13:49:36.286722670 +0100
-@@ -16,7 +16,7 @@ end
- 
- module Hashtbl = struct
-   type ('a, 'b) t = ('a, 'b) Hashtbl.t
--  let create = Hashtbl.create
-+  let create x = Hashtbl.create x
-   let get h = h
- 
-   let add h k d =
diff --git a/pkgs/development/libraries/farbfeld/default.nix b/pkgs/development/libraries/farbfeld/default.nix
index 3f309f06630b..7c0addea5e8b 100644
--- a/pkgs/development/libraries/farbfeld/default.nix
+++ b/pkgs/development/libraries/farbfeld/default.nix
@@ -2,12 +2,12 @@
 
 stdenv.mkDerivation rec {
   name = "farbfeld-${version}";
-  version = "3";
+  version = "4";
 
   src = fetchgit {
-    url = "http://git.suckless.org/farbfeld";
+    url = "https://git.suckless.org/farbfeld";
     rev = "refs/tags/${version}";
-    sha256 = "1k9cnw2zk9ywcn4hibf7wgi4czwyxhgjdmia6ghpw3wcz8vi71xl";
+    sha256 = "0pkmkvv5ggpzqwqdchd19442x8gh152xy5z1z13ipfznhspsf870";
   };
 
   buildInputs = [ libpng libjpeg ];
diff --git a/pkgs/development/libraries/farstream/default.nix b/pkgs/development/libraries/farstream/default.nix
index 034738813395..020d04542864 100644
--- a/pkgs/development/libraries/farstream/default.nix
+++ b/pkgs/development/libraries/farstream/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, libnice, pkgconfig, pythonPackages, gstreamer, gst-plugins-base
-, gst-python, gupnp_igd
+, gst-python, gupnp-igd, gobjectIntrospection
 , gst-plugins-good, gst-plugins-bad, gst-libav
 }:
 
@@ -7,21 +7,25 @@ let
   inherit (pythonPackages) python pygobject2;
 in stdenv.mkDerivation rec {
   name = "farstream-0.2.8";
+
+  outputs = [ "out" "dev" ];
+
   src = fetchurl {
-    url = "http://www.freedesktop.org/software/farstream/releases/farstream/${name}.tar.gz";
+    url = "https://www.freedesktop.org/software/farstream/releases/farstream/${name}.tar.gz";
     sha256 = "0249ncd20x5mf884fd8bw75c3118b9fdml837v4fib349xmrqfrb";
   };
 
-  buildInputs = [ libnice python pygobject2 gupnp_igd libnice ];
+  buildInputs = [ libnice python pygobject2 gupnp-igd libnice ];
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig gobjectIntrospection ];
 
-  propagatedBuildInputs = [ gstreamer gst-plugins-base gst-python
+  propagatedBuildInputs = [
+    gstreamer gst-plugins-base gst-python
     gst-plugins-good gst-plugins-bad gst-libav
-    ];
+  ];
 
   meta = {
-    homepage = http://www.freedesktop.org/wiki/Software/Farstream;
+    homepage = https://www.freedesktop.org/wiki/Software/Farstream;
     description = "Audio/Video Communications Framework formely known as farsight";
     maintainers = [ ];
     platforms = stdenv.lib.platforms.linux;
diff --git a/pkgs/development/libraries/fastpbkdf2/default.nix b/pkgs/development/libraries/fastpbkdf2/default.nix
new file mode 100644
index 000000000000..e781e2aab838
--- /dev/null
+++ b/pkgs/development/libraries/fastpbkdf2/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchFromGitHub, openssl }:
+
+stdenv.mkDerivation {
+  name = "fastpbkdf2-1.0.0";
+  
+  src = fetchFromGitHub {
+    owner = "ctz";
+    repo = "fastpbkdf2";
+    rev = "v1.0.0";
+    sha256 = "09ax0h4ik3vhvp3s98lic93l3g9f4v1jkr5k6z4g1lvm7s3lrha2";
+  };
+  
+  buildInputs = [ openssl ];
+
+  preBuild = ''
+    makeFlagsArray=(CFLAGS="-std=c99 -O3 -g")
+  '';
+
+  installPhase = ''
+    mkdir -p $out/{lib,include/fastpbkdf2}
+    cp *.a $out/lib
+    cp fastpbkdf2.h $out/include/fastpbkdf2
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A fast PBKDF2-HMAC-{SHA1,SHA256,SHA512} implementation in C";
+    homepage = https://github.com/ctz/fastpbkdf2;
+    license = licenses.cc0;
+    maintainers = with maintainers; [ ledif ];
+  };
+}
diff --git a/pkgs/development/libraries/fdk-aac/default.nix b/pkgs/development/libraries/fdk-aac/default.nix
index 59dc4721812c..903f43b1e685 100644
--- a/pkgs/development/libraries/fdk-aac/default.nix
+++ b/pkgs/development/libraries/fdk-aac/default.nix
@@ -5,11 +5,11 @@
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "fdk-aac-${version}";
-  version = "0.1.5";
+  version = "0.1.6";
 
   src = fetchurl {
     url = "mirror://sourceforge/opencore-amr/fdk-aac/${name}.tar.gz";
-    sha256 = "1msdkcf559agmpycd4bk0scm2s2h9jyzbnnw1yrfarxlcwm5jr11";
+    sha256 = "1bfkpqba0v2jgxqwaf9xsrr63a089wckrir497lm6nbbmi11pdma";
   };
 
   configureFlags = [ ]
diff --git a/pkgs/development/libraries/fflas-ffpack/default.nix b/pkgs/development/libraries/fflas-ffpack/default.nix
index 0e4e897e27a4..edea352ae2dd 100644
--- a/pkgs/development/libraries/fflas-ffpack/default.nix
+++ b/pkgs/development/libraries/fflas-ffpack/default.nix
@@ -2,12 +2,12 @@
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
   pname = "fflas-ffpack";
-  version = "2.2.2";
+  version = "2.3.2";
   src = fetchFromGitHub {
     owner = "linbox-team";
     repo = "${pname}";
     rev = "v${version}";
-    sha256 = "0k1f4pb7azrm6ajncvg7vni7ixfmn6fssd5ld4xddbi6jqbsf9rd";
+    sha256 = "1cqhassj2dny3gx0iywvmnpq8ca0d6m82xl5rz4mb8gaxr2kwddl";
   };
   nativeBuildInputs = [ autoreconfHook pkgconfig ];
   buildInputs = [ givaro (liblapack.override {shared = true;}) openblas];
diff --git a/pkgs/development/libraries/ffmpeg-full/default.nix b/pkgs/development/libraries/ffmpeg-full/default.nix
index b50025aa108a..db39be465485 100644
--- a/pkgs/development/libraries/ffmpeg-full/default.nix
+++ b/pkgs/development/libraries/ffmpeg-full/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, perl, texinfo, yasm
+{ stdenv, fetchurl, fetchpatch, pkgconfig, perl, texinfo, yasm
 , hostPlatform
 /*
  *  Licensing options (yes some are listed twice, filters and such are not listed)
@@ -102,7 +102,7 @@
 #, opencl ? null # OpenCL code
 , opencore-amr ? null # AMR-NB de/encoder & AMR-WB decoder
 #, opencv ? null # Video filtering
-, openglExtlib ? false, mesa ? null # OpenGL rendering
+, openglExtlib ? false, libGLU_combined ? null # OpenGL rendering
 #, openh264 ? null # H.264/AVC encoder
 , openjpeg_1 ? null # JPEG 2000 de/encoder
 , opensslExtlib ? false, openssl ? null
@@ -119,7 +119,7 @@
 #, utvideo ? null # Ut Video de/encoder
 , vid-stab ? null # Video stabilization
 #, vo-aacenc ? null # AAC encoder
-#, vo-amrwbenc ? null # AMR-WB encoder
+, vo-amrwbenc ? null # AMR-WB encoder
 , wavpack ? null # Wavpack encoder
 , x264 ? null # H.264/AVC encoder
 , x265 ? null # H.265/HEVC encoder
@@ -225,20 +225,21 @@ assert gnutls != null -> !opensslExtlib;
 assert libxcbshmExtlib -> libxcb != null;
 assert libxcbxfixesExtlib -> libxcb != null;
 assert libxcbshapeExtlib -> libxcb != null;
-assert openglExtlib -> mesa != null;
+assert openglExtlib -> libGLU_combined != null;
 assert opensslExtlib -> gnutls == null && openssl != null && nonfreeLicensing;
 assert nvenc -> nvidia-video-sdk != null && nonfreeLicensing;
 
 stdenv.mkDerivation rec {
   name = "ffmpeg-full-${version}";
-  version = "3.4";
+  version = "3.4.2";
 
   src = fetchurl {
     url = "https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz";
-    sha256 = "1vzvpx8ixy8m44f8qwp833hv253hpghybgzbc4n8b3div3j0dvmf";
+    sha256 = "0h6prjn1ijkzzhkyj8mazp0wpx7m0n9ycadjxagf9czqirbyk4ib";
   };
 
-  patchPhase = ''patchShebangs .
+  prePatch = ''
+    patchShebangs .
   '' + stdenv.lib.optionalString stdenv.isDarwin ''
     sed -i 's/#ifndef __MAC_10_11/#if 1/' ./libavcodec/audiotoolboxdec.c
   '' + stdenv.lib.optionalString (frei0r != null) ''
@@ -379,7 +380,7 @@ stdenv.mkDerivation rec {
     #(enableFeature (utvideo != null && gplLicensing) "libutvideo")
     (enableFeature (vid-stab != null && gplLicensing) "libvidstab") # Actual min. version 2.0
     #(enableFeature (vo-aacenc != null && version3Licensing) "libvo-aacenc")
-    #(enableFeature (vo-amrwbenc != null && version3Licensing) "libvo-amrwbenc")
+    (enableFeature (vo-amrwbenc != null && version3Licensing) "libvo-amrwbenc")
     (enableFeature (wavpack != null) "libwavpack")
     (enableFeature (x264 != null && gplLicensing) "libx264")
     (enableFeature (x265 != null && gplLicensing) "libx265")
@@ -404,8 +405,9 @@ stdenv.mkDerivation rec {
     libjack2 ladspaH lame libass libbluray libbs2b libcaca libdc1394 libmodplug
     libogg libopus libssh libtheora libvdpau libvorbis libvpx libwebp libX11
     libxcb libXv lzma openal openjpeg_1 libpulseaudio rtmpdump opencore-amr
-    samba SDL2 soxr speex vid-stab wavpack x264 x265 xavs xvidcore zeromq4 zlib
-  ] ++ optional openglExtlib mesa
+    samba SDL2 soxr speex vid-stab vo-amrwbenc wavpack x264 x265 xavs xvidcore
+    zeromq4 zlib
+  ] ++ optional openglExtlib libGLU_combined
     ++ optionals nonfreeLicensing [ fdk_aac openssl ]
     ++ optional ((isLinux || isFreeBSD) && libva != null) libva
     ++ optionals isLinux [ alsaLib libraw1394 libv4l ]
@@ -438,7 +440,7 @@ stdenv.mkDerivation rec {
   crossAttrs = {
     configurePlatforms = [];
     configureFlags = configureFlags ++ [
-      "--cross-prefix=${stdenv.cc.prefix}"
+      "--cross-prefix=${stdenv.cc.targetPrefix}"
       "--enable-cross-compile"
       "--target_os=${hostPlatform.parsed.kernel.name}"
       "--arch=${hostPlatform.arch}"
diff --git a/pkgs/development/libraries/ffmpeg/3.4.nix b/pkgs/development/libraries/ffmpeg/3.4.nix
index 513654e98f74..98cbfdf43f6c 100644
--- a/pkgs/development/libraries/ffmpeg/3.4.nix
+++ b/pkgs/development/libraries/ffmpeg/3.4.nix
@@ -1,4 +1,4 @@
-{ stdenv, callPackage
+{ stdenv, callPackage, fetchpatch
 # Darwin frameworks
 , Cocoa, CoreMedia
 , ...
@@ -6,7 +6,7 @@
 
 callPackage ./generic.nix (args // rec {
   version = "${branch}";
-  branch = "3.4";
-  sha256 = "0pn8g3ab937ahslqd41crk0g4j4fh7kwimsrlfc0rl0pc3z132ax";
+  branch = "3.4.2";
+  sha256 = "0nkq4451masmzlx3p4vprqwc0sl2iwqxbzjrngmvj29q4azp00zb";
   darwinFrameworks = [ Cocoa CoreMedia ];
 })
diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix
index 1bd8b7392601..985f328a22dd 100644
--- a/pkgs/development/libraries/ffmpeg/generic.nix
+++ b/pkgs/development/libraries/ffmpeg/generic.nix
@@ -3,7 +3,7 @@
 , libtheora, libva, libvorbis, libvpx, lzma, libpulseaudio, soxr
 , x264, x265, xvidcore, zlib, libopus
 , hostPlatform
-, openglSupport ? false, mesa ? null
+, openglSupport ? false, libGLU_combined ? null
 # Build options
 , runtimeCpuDetectBuild ? true # Detect CPU capabilities at runtime
 , multithreadBuild ? true # Multithreading via pthreads/win32 threads
@@ -60,7 +60,7 @@ let
   vaapiSupport = reqMin "0.6" && ((isLinux || isFreeBSD) && !isArm);
 in
 
-assert openglSupport -> mesa != null;
+assert openglSupport -> libGLU_combined != null;
 
 stdenv.mkDerivation rec {
 
@@ -152,7 +152,7 @@ stdenv.mkDerivation rec {
   buildInputs = [
     bzip2 fontconfig freetype gnutls libiconv lame libass libogg libtheora
     libvdpau libvorbis lzma soxr x264 x265 xvidcore zlib libopus
-  ] ++ optional openglSupport mesa
+  ] ++ optional openglSupport libGLU_combined
     ++ optionals (!isDarwin && !isArm) [ libvpx libpulseaudio ] # Need to be fixed on Darwin and ARM
     ++ optional ((isLinux || isFreeBSD) && !isArm) libva
     ++ optional isLinux alsaLib
@@ -173,9 +173,9 @@ stdenv.mkDerivation rec {
   crossAttrs = {
     configurePlatforms = [];
     configureFlags = configureFlags ++ [
-      "--cross-prefix=${stdenv.cc.prefix}"
+      "--cross-prefix=${stdenv.cc.targetPrefix}"
       "--enable-cross-compile"
-      "--target_os=${hostPlatform.parsed.kernel}"
+      "--target_os=${hostPlatform.parsed.kernel.name}"
       "--arch=${hostPlatform.arch}"
     ];
   };
diff --git a/pkgs/development/libraries/fftw/default.nix b/pkgs/development/libraries/fftw/default.nix
index 5cf83752aa70..701209971074 100644
--- a/pkgs/development/libraries/fftw/default.nix
+++ b/pkgs/development/libraries/fftw/default.nix
@@ -5,7 +5,7 @@ with lib;
 assert elem precision [ "single" "double" "long-double" "quad-precision" ];
 
 let
-  version = "3.3.6-pl1";
+  version = "3.3.7";
   withDoc = stdenv.cc.isGNU;
 in
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "ftp://ftp.fftw.org/pub/fftw/fftw-${version}.tar.gz";
-    sha256 = "0g8qk98lgq770ixdf7n36yd5xjsgm2v3wzvnphwmhy6r4y2amx0y";
+    sha256 = "0wsms8narnbhfsa8chdflv2j9hzspvflblnqdn7hw8x5xdzrnq1v";
   };
 
   outputs = [ "out" "dev" "man" ]
@@ -29,7 +29,7 @@ stdenv.mkDerivation rec {
     # all x86_64 have sse2
     # however, not all float sizes fit
     ++ optional (stdenv.isx86_64 && (precision == "single" || precision == "double") )  "--enable-sse2"
-    ++ optional stdenv.cc.isGNU "--enable-openmp"
+    ++ optional (stdenv.cc.isGNU && !stdenv.hostPlatform.isMusl) "--enable-openmp"
     # doc generation causes Fortran wrapper generation which hard-codes gcc
     ++ optional (!withDoc) "--disable-doc";
 
diff --git a/pkgs/development/libraries/flatbuffers/default.nix b/pkgs/development/libraries/flatbuffers/default.nix
index add520558ba9..fb74c4ff4d24 100644
--- a/pkgs/development/libraries/flatbuffers/default.nix
+++ b/pkgs/development/libraries/flatbuffers/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "flatbuffers-${version}";
-  version = "1.4.0";
+  version = "1.8.0";
 
   src = fetchFromGitHub {
     owner = "google";
     repo = "flatbuffers";
     rev = "v${version}";
-    sha256 = "0jsqk49h521d5h4c9gk39a8968g6rcd6520a8knbfc7ssc4028y0";
+    sha256 = "1qq8qbv8wkiiizj8s984f17bsbjsrhbs9q1nw1yjgrw0grcxlsi9";
   };
 
   buildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/flint/default.nix b/pkgs/development/libraries/flint/default.nix
index 94cc7688cc8b..67bf7503db98 100644
--- a/pkgs/development/libraries/flint/default.nix
+++ b/pkgs/development/libraries/flint/default.nix
@@ -1,14 +1,51 @@
-{stdenv, fetchurl, gmp, mpir, mpfr, openblas, ntl}:
+{ stdenv
+, fetchurl
+, fetchpatch
+, gmp
+, mpir
+, mpfr
+, ntl
+, openblas ? null
+, withBlas ? true
+}:
+
+assert withBlas -> openblas != null;
+
 stdenv.mkDerivation rec {
   name = "flint-${version}";
-  version = "2.5.2";
-  # or fetchFromGitHub(owner,repo,rev) or fetchgit(rev)
+  version = "2.5.2"; # remove libflint.so.MAJOR patch when updating
   src = fetchurl {
     url = "http://www.flintlib.org/flint-${version}.tar.gz";
     sha256 = "11syazv1a8rrnac3wj3hnyhhflpqcmq02q8pqk2m6g2k6h0gxwfb";
   };
-  buildInputs = [gmp mpir mpfr openblas ntl];
-  configureFlags = "--with-gmp=${gmp} --with-mpir=${mpir} --with-mpfr=${mpfr} --with-blas=${openblas} --with-ntl=${ntl}";
+  buildInputs = [
+    gmp
+    mpir
+    mpfr
+    ntl
+  ] ++ stdenv.lib.optionals withBlas [
+    openblas
+  ];
+  propagatedBuildInputs = [
+    mpfr # flint.h includes mpfr.h
+  ];
+  configureFlags = [
+    "--with-gmp=${gmp}"
+    "--with-mpir=${mpir}"
+    "--with-mpfr=${mpfr}"
+    "--with-ntl=${ntl}"
+  ] ++ stdenv.lib.optionals withBlas [
+    "--with-blas=${openblas}"
+  ];
+  patches = [
+    (fetchpatch {
+      # Always produce libflint.so.MAJOR; will be included in the next flint version
+      # See https://github.com/wbhart/flint2/pull/347
+      url = "https://github.com/wbhart/flint2/commit/49fbcd8f736f847d3f9667f9f7d5567ef4550ecb.patch";
+      sha256 = "09w09bpq85kjf752bd3y3i5lvy59b8xjiy7qmrcxzibx2a21pj73";
+    })
+  ];
+  doCheck = true;
   meta = {
     inherit version;
     description = ''Fast Library for Number Theory'';
diff --git a/pkgs/development/libraries/flite/default.nix b/pkgs/development/libraries/flite/default.nix
index 483f02f823fd..0b4172cdc764 100644
--- a/pkgs/development/libraries/flite/default.nix
+++ b/pkgs/development/libraries/flite/default.nix
@@ -1,18 +1,23 @@
-{ stdenv, fetchurl, pkgconfig }:
+{ stdenv, fetchFromGitHub, alsaLib }:
 
 stdenv.mkDerivation rec {
-  name = "flite-1.9.0";
+  name = "flite-2.1.0";
 
-  src = fetchurl {
-    url = "http://www.festvox.org/bard/${name}-current.tar.bz2";
-    sha256 = "197cc2a1f045b1666a29a9b5f035b3d676db6db94a4439d99a03b65e551ae2e0";
+  src = fetchFromGitHub {
+    owner  = "festvox";
+    repo   = "flite";
+    rev    = "d673f65b2c4a8cd3da7447079309a6dc4bcf1a5e";
+    sha256 = "1kx43jvdln370590gfjhxxz3chxfi6kq18504wmdpljib2l0grjq";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ alsaLib ];
 
-  configureFlags = ''
-    --enable-shared
-  '';
+  configureFlags = [
+    "--enable-shared"
+    "--with-audio=alsa"
+  ];
+
+  enableParallelBuilding = true;
 
   meta = {
     description = "A small, fast run-time speech synthesis engine";
diff --git a/pkgs/development/libraries/fltk/default.nix b/pkgs/development/libraries/fltk/default.nix
index a1e4bb8274e0..ddc962d0aab6 100644
--- a/pkgs/development/libraries/fltk/default.nix
+++ b/pkgs/development/libraries/fltk/default.nix
@@ -1,5 +1,5 @@
 { stdenv, composableDerivation, fetchurl, pkgconfig, xlibsWrapper, inputproto, libXi
-, freeglut, mesa, libjpeg, zlib, libXinerama, libXft, libpng
+, freeglut, libGLU_combined, libjpeg, zlib, libXinerama, libXft, libpng
 , cfg ? {}
 , darwin, libtiff, freetype
 }:
@@ -29,7 +29,7 @@ composableDerivation.composableDerivation {} {
     # this could be tidied up (?).. eg why does it require freeglut without glSupport?
     edf { name = "cygwin"; }  #         use the CygWin libraries default=no
     // edf { name = "debug"; }  #          turn on debugging default=no
-    // edf { name = "gl"; enable = { buildInputs = [ mesa ]; }; }  #             turn on OpenGL support default=yes
+    // edf { name = "gl"; enable = { buildInputs = [ libGLU_combined ]; }; }  #             turn on OpenGL support default=yes
     // edf { name = "shared"; }  #         turn on shared libraries default=no
     // edf { name = "threads"; }  #        enable multi-threading support
     // edf { name = "quartz"; enable = { buildInputs = "quartz"; }; }  # don't konw yet what quartz is #         use Quartz instead of Quickdraw (default=no)
diff --git a/pkgs/development/libraries/folly/default.nix b/pkgs/development/libraries/folly/default.nix
index 286e4ac56b58..d3ba4b889094 100644
--- a/pkgs/development/libraries/folly/default.nix
+++ b/pkgs/development/libraries/folly/default.nix
@@ -1,27 +1,19 @@
 { stdenv, fetchFromGitHub, fetchpatch, autoreconfHook, pkgconfig, boost, libevent
-, double_conversion, glog, google-gflags, python, libiberty, openssl }:
+, double-conversion, glog, google-gflags, python, libiberty, openssl }:
 
 stdenv.mkDerivation rec {
   name = "folly-${version}";
-  version = "2017.07.24.00";
+  version = "2018.04.16.00";
 
   src = fetchFromGitHub {
     owner = "facebook";
     repo = "folly";
     rev = "v${version}";
-    sha256 = "1cmqrm9yjxrw4xr1kcgzl0s7vcvp125wcgb0cz7whssgj11mf169";
+    sha256 = "10wivnszpqcbg2hbvfal94lcjw20pjz0d8p0m4qa7i4v4z90q37p";
   };
 
-  patches = [
-    # Fix compilation
-    (fetchpatch {
-      url = "https://github.com/facebook/folly/commit/9fc87c83d93f092859823ec32289ed1b6abeb683.patch";
-      sha256 = "0ix0grqlzm16hwa4rjbajjck8kr9lksh6c3gn7p3ihbbchsmlhvl";
-    })
-  ];
-
   nativeBuildInputs = [ autoreconfHook python pkgconfig ];
-  buildInputs = [ libiberty boost libevent double_conversion glog google-gflags openssl ];
+  buildInputs = [ libiberty boost libevent double-conversion glog google-gflags openssl ];
 
   postPatch = "cd folly";
   preBuild = ''
diff --git a/pkgs/development/libraries/fontconfig/default.nix b/pkgs/development/libraries/fontconfig/default.nix
index 9c4116c8f0ba..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,22 +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}
-    touch src/*
-  '';
 
   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/fontconfig/make-fonts-cache.nix b/pkgs/development/libraries/fontconfig/make-fonts-cache.nix
index 9aa1a905ec98..8b534edd2498 100644
--- a/pkgs/development/libraries/fontconfig/make-fonts-cache.nix
+++ b/pkgs/development/libraries/fontconfig/make-fonts-cache.nix
@@ -24,4 +24,8 @@ runCommand "fc-cache"
 
     mkdir -p $out
     fc-cache -sv
+
+    # This is not a cache dir in the normal sense -- it won't be automatically
+    # recreated.
+    rm "$out/CACHEDIR.TAG"
   ''
diff --git a/pkgs/development/libraries/fox/fox-1.6.nix b/pkgs/development/libraries/fox/fox-1.6.nix
index 63ec62336163..a0ba95480129 100644
--- a/pkgs/development/libraries/fox/fox-1.6.nix
+++ b/pkgs/development/libraries/fox/fox-1.6.nix
@@ -1,9 +1,9 @@
 { stdenv, fetchurl, xlibsWrapper, libpng, libjpeg, libtiff, zlib, bzip2, libXcursor
-, libXrandr, mesa, libXft, libXfixes, xinput
+, libXrandr, libGLU_combined, libXft, libXfixes, xinput
 , CoreServices }:
 
 let
-  version = "1.6.49";
+  version = "1.6.56";
 in
 
 stdenv.mkDerivation rec {
@@ -11,12 +11,12 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "ftp://ftp.fox-toolkit.org/pub/${name}.tar.gz";
-    sha256 = "03m9wm8hpzh1i0fxx5mpvjr67384pfm9hn7gzdcq55b4639fqy9n";
+    sha256 = "1ckcb12gblz1ad1371ah1qirxn3r9zdngh9w0357hsqfmkyfa5y5";
   };
 
   buildInputs = [
     xlibsWrapper libpng libjpeg libtiff zlib bzip2 libXcursor libXrandr
-    libXft mesa libXfixes xinput
+    libXft libGLU_combined libXfixes xinput
   ] ++ stdenv.lib.optional stdenv.isDarwin CoreServices;
 
   doCheck = true;
diff --git a/pkgs/development/libraries/fplll/default.nix b/pkgs/development/libraries/fplll/default.nix
index b377061fe97e..2dd757bf8216 100644
--- a/pkgs/development/libraries/fplll/default.nix
+++ b/pkgs/development/libraries/fplll/default.nix
@@ -4,12 +4,12 @@
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
   pname = "fplll";
-  version = "5.0.2";
+  version = "5.2.0";
   src = fetchFromGitHub {
     owner = "${pname}";
     repo = "${pname}";
     rev = "${version}";
-    sha256 = "0rl98rx284giyhj3pf6iydn1a06jis8c8mnsc7kqs4rcmiw4bjpx";
+    sha256 = "0931i4q49lzlifsg9zd8a2yzj626i1s2bqhkfxvcxv94c38s0nh1";
   };
   nativeBuildInputs = [autoconf automake libtool gettext autoreconfHook];
   buildInputs = [gmp mpfr];
diff --git a/pkgs/development/libraries/freeglut/default.nix b/pkgs/development/libraries/freeglut/default.nix
index 6737e059b212..c34d9591d386 100644
--- a/pkgs/development/libraries/freeglut/default.nix
+++ b/pkgs/development/libraries/freeglut/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, libXi, libXrandr, libXxf86vm, mesa_noglu, mesa_glu, xlibsWrapper, cmake }:
+{ stdenv, fetchurl, libXi, libXrandr, libXxf86vm, libGL, libGLU, xlibsWrapper, cmake }:
 
 let version = "3.0.0";
 in stdenv.mkDerivation {
@@ -11,12 +11,12 @@ in stdenv.mkDerivation {
 
   outputs = [ "out" "dev" ];
 
-  buildInputs = [ libXi libXrandr libXxf86vm mesa_noglu mesa_glu xlibsWrapper cmake ];
+  buildInputs = [ libXi libXrandr libXxf86vm libGL libGLU xlibsWrapper cmake ];
 
   cmakeFlags = stdenv.lib.optionals stdenv.isDarwin [
-                 "-DOPENGL_INCLUDE_DIR=${mesa_noglu}/include"
-                 "-DOPENGL_gl_LIBRARY:FILEPATH=${mesa_noglu}/lib/libGL.dylib"
-                 "-DOPENGL_glu_LIBRARY:FILEPATH=${mesa_glu}/lib/libGLU.dylib"
+                 "-DOPENGL_INCLUDE_DIR=${libGL}/include"
+                 "-DOPENGL_gl_LIBRARY:FILEPATH=${libGL}/lib/libGL.dylib"
+                 "-DOPENGL_glu_LIBRARY:FILEPATH=${libGLU}/lib/libGLU.dylib"
                  "-DFREEGLUT_BUILD_DEMOS:BOOL=OFF"
                  "-DFREEGLUT_BUILD_STATIC:BOOL=OFF"
                ];
diff --git a/pkgs/development/libraries/freenect/default.nix b/pkgs/development/libraries/freenect/default.nix
index c77c3b3640b7..3771880d3608 100644
--- a/pkgs/development/libraries/freenect/default.nix
+++ b/pkgs/development/libraries/freenect/default.nix
@@ -1,25 +1,29 @@
-{ stdenv, fetchFromGitHub, cmake, libusb, pkgconfig, freeglut, mesa, libXi, libXmu }:
+{ stdenv, lib, fetchFromGitHub, cmake, libusb, pkgconfig, freeglut, libGLU_combined, libXi, libXmu
+, GLUT, Cocoa
+ }:
 
 stdenv.mkDerivation rec {
   name = "freenect-${version}";
-  version = "0.5.5";
+  version = "0.5.7";
 
   src = fetchFromGitHub {
     owner = "OpenKinect";
     repo = "libfreenect";
     rev = "v${version}";
-    sha256 = "0qmbagfkxjgbwd2ajn7i5lkic9gx5y02bsnmqm7cjay99zfw9ifx";
+    sha256 = "0vnc7z2avckh4mccqq6alsd2z7xvsh3kaslc5b0gnfxw0j269gl6";
   };
 
-  buildInputs = [ libusb freeglut mesa libXi libXmu ];
+  buildInputs = [ libusb freeglut libGLU_combined libXi libXmu ]
+    ++ lib.optionals stdenv.isDarwin [ GLUT Cocoa ];
+
   nativeBuildInputs = [ cmake pkgconfig ];
 
   meta = {
     description = "Drivers and libraries for the Xbox Kinect device on Windows, Linux, and macOS";
     inherit version;
     homepage = http://openkinect.org;
-    license = with stdenv.lib.licenses; [ gpl2 asl20 ];
-    maintainers = with stdenv.lib.maintainers; [ bennofs ];
-    platforms = stdenv.lib.platforms.linux;
+    license = with lib.licenses; [ gpl2 asl20 ];
+    maintainers = with lib.maintainers; [ bennofs ];
+    platforms = with lib.platforms; linux ++ darwin ;
   };
 }
diff --git a/pkgs/development/libraries/freetds/default.nix b/pkgs/development/libraries/freetds/default.nix
index d764121e8d6b..b097e5cbb64c 100644
--- a/pkgs/development/libraries/freetds/default.nix
+++ b/pkgs/development/libraries/freetds/default.nix
@@ -6,11 +6,11 @@ assert odbcSupport -> unixODBC != null;
 
 stdenv.mkDerivation rec {
   name = "freetds-${version}";
-  version = "1.00.70";
+  version = "1.00.80";
 
   src = fetchurl {
     url    = "http://www.freetds.org/files/stable/${name}.tar.bz2";
-    sha256 = "1ydh0c89nb6wh6wakbkqad7mdwpymygvgbcrk8c2mp7abgv1jqzp";
+    sha256 = "17s15avxcyhfk0zsj8rggizhpd2j2sa41w5xlnshzd2r3piqyl6k";
   };
 
   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/fribidi/default.nix b/pkgs/development/libraries/fribidi/default.nix
index bdfbb97f0218..a107c9a478f2 100644
--- a/pkgs/development/libraries/fribidi/default.nix
+++ b/pkgs/development/libraries/fribidi/default.nix
@@ -1,22 +1,26 @@
-{stdenv, fetchurl}:
+{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig }:
 
 stdenv.mkDerivation rec {
   name = "fribidi-${version}";
   version = "0.19.7";
 
-  src = fetchurl {
-    url = "http://fribidi.org/download/${name}.tar.bz2";
-    sha256 = "13jsb5qadlhsaxkbrb49nqslmbh904vvzhsm5mm2ghmv29i2l8h8";
+  src = fetchFromGitHub {
+    owner = "fribidi";
+    repo = "fribidi";
+    rev = version;
+    sha256 = "10q5jfch5qzrj2w4fbkr086ank66plx8hp7ra9a01irj80pbk96d";
   };
 
-  hardeningDisable = [ "format" ];
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+
+  # Configure script checks for glib, but it is only used for tests.
 
   outputs = [ "out" "devdoc" ];
 
   meta = with stdenv.lib; {
-    homepage = http://fribidi.org/;
+    homepage = https://github.com/fribidi/fribidi;
     description = "GNU implementation of the Unicode Bidirectional Algorithm (bidi)";
-    license = licenses.gpl2;
+    license = licenses.lgpl21;
     platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/ftgl/2.1.2.nix b/pkgs/development/libraries/ftgl/2.1.2.nix
deleted file mode 100644
index d4afc7ad481a..000000000000
--- a/pkgs/development/libraries/ftgl/2.1.2.nix
+++ /dev/null
@@ -1,44 +0,0 @@
-{stdenv, fetchurl, freetype, mesa}:
-
-let
-  name = "ftgl-2.1.2";
-in
-stdenv.mkDerivation {
-  inherit name;
-
-  src = fetchurl {
-    url = "mirror://sourceforge/ftgl/${name}.tar.gz";
-    sha256 = "0xa00fnn6wd3rnkrkcs1wpv21lxdsb83r4hjn3l33dn0zbawnn97";
-  };
-
-  buildInputs = [freetype mesa];
-
-  NIX_LDFLAGS = "-lGLU -lGL";
-
-  patches = [ ./gcc.patch ];
-
-  configureFlags = "--enable-shared";
-
-  preConfigure = ''
-    cd unix
-    cd docs
-    tar vxf ../../docs/html.tar.gz
-    cd ..
-  '';
-
-  meta = {
-    homepage = https://sourceforge.net/apps/mediawiki/ftgl/;
-    description = "Font rendering library for OpenGL applications";
-    license = stdenv.lib.licenses.gpl3Plus;
-
-    longDescription = ''
-      FTGL is a free cross-platform Open Source C++ library that uses
-      Freetype2 to simplify rendering fonts in OpenGL applications. FTGL
-      supports bitmaps, pixmaps, texture maps, outlines, polygon mesh,
-      and extruded polygon rendering modes.
-    '';
-
-    platforms = stdenv.lib.platforms.gnu;
-    maintainers = [];
-  };
-}
diff --git a/pkgs/development/libraries/ftgl/default.nix b/pkgs/development/libraries/ftgl/default.nix
index 5e94618376ba..8808af49f9e4 100644
--- a/pkgs/development/libraries/ftgl/default.nix
+++ b/pkgs/development/libraries/ftgl/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, freetype, mesa}:
+{stdenv, fetchurl, freetype, libGLU_combined}:
 
 let
   name = "ftgl-2.1.3-rc5";
@@ -11,7 +11,9 @@ stdenv.mkDerivation {
     sha256 = "0nsn4s6vnv5xcgxcw6q031amvh2zfj2smy1r5mbnjj2548hxcn2l";
   };
 
-  buildInputs = [freetype mesa];
+  buildInputs = [ freetype libGLU_combined ];
+
+  enableParallelBuilding = true;
 
   meta = {
     homepage = https://sourceforge.net/apps/mediawiki/ftgl/;
@@ -25,7 +27,7 @@ stdenv.mkDerivation {
       and extruded polygon rendering modes.
     '';
 
-    platforms = stdenv.lib.platforms.gnu;
+    platforms = stdenv.lib.platforms.unix;
     maintainers = [];
   };
 }
diff --git a/pkgs/development/libraries/ftgl/gcc.patch b/pkgs/development/libraries/ftgl/gcc.patch
deleted file mode 100644
index 6e9871476c81..000000000000
--- a/pkgs/development/libraries/ftgl/gcc.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/include/FTTextureGlyph.h b/include/FTTextureGlyph.h
-index c263f72..8959cb3 100755
---- a/include/FTTextureGlyph.h
-+++ b/include/FTTextureGlyph.h
-@@ -52,7 +52,7 @@ class FTGL_EXPORT FTTextureGlyph : public FTGlyph
-          * Reset the currently active texture to zero to get into a known state before
-          * drawing a string. This is to get round possible threading issues.
-          */
--        static void FTTextureGlyph::ResetActiveTexture(){ activeTextureID = 0;}
-+        static void ResetActiveTexture(){ activeTextureID = 0;}
-         
-     private:
-         /**
diff --git a/pkgs/development/libraries/gamin/debian-patches.nix b/pkgs/development/libraries/gamin/debian-patches.nix
index f784b8ccfee0..a8f334fb3c39 100644
--- a/pkgs/development/libraries/gamin/debian-patches.nix
+++ b/pkgs/development/libraries/gamin/debian-patches.nix
@@ -1,6 +1,6 @@
 # Generated by debian-patches.sh from debian-patches.txt
 let
-  prefix = "http://patch-tracker.debian.org/patch/series/dl/gamin/0.1.10-4.1";
+  prefix = "https://sources.debian.org/data/main/g/gamin/0.1.10-4.1/debian/patches";
 in
 [
   {
diff --git a/pkgs/development/libraries/gamin/debian-patches.txt b/pkgs/development/libraries/gamin/debian-patches.txt
index 4faad71d44d0..46d2420b21ed 100644
--- a/pkgs/development/libraries/gamin/debian-patches.txt
+++ b/pkgs/development/libraries/gamin/debian-patches.txt
@@ -1,2 +1,2 @@
-gamin/0.1.10-4
+gamin/0.1.10-4.1
 17_deprecated_const_return.patch
diff --git a/pkgs/development/libraries/gamin/default.nix b/pkgs/development/libraries/gamin/default.nix
index e6b1875a9e0c..2af7bbce18bc 100644
--- a/pkgs/development/libraries/gamin/default.nix
+++ b/pkgs/development/libraries/gamin/default.nix
@@ -1,10 +1,10 @@
-{ stdenv, fetchurl, python, pkgconfig, glib }:
+{ stdenv, fetchurl, fetchpatch, python, pkgconfig, glib }:
 
 stdenv.mkDerivation (rec {
   name = "gamin-0.1.10";
 
   src = fetchurl {
-    url = "http://www.gnome.org/~veillard/gamin/sources/${name}.tar.gz";
+    url = "https://www.gnome.org/~veillard/gamin/sources/${name}.tar.gz";
     sha256 = "18cr51y5qacvs2fc2p1bqv32rs8bzgs6l67zhasyl45yx055y218";
   };
 
@@ -18,7 +18,12 @@ stdenv.mkDerivation (rec {
 
   patches = [ ./deadlock.patch ]
     ++ map fetchurl (import ./debian-patches.nix)
-    ++ stdenv.lib.optional stdenv.cc.isClang ./returnval.patch;
+    ++ stdenv.lib.optional stdenv.cc.isClang ./returnval.patch
+    ++ stdenv.lib.optional stdenv.hostPlatform.isMusl (fetchpatch {
+      name = "fix-pthread-mutex.patch";
+      url = "https://git.alpinelinux.org/cgit/aports/plain/main/gamin/fix-pthread-mutex.patch?h=3.4-stable&id=a1a836b089573752c1b0da7d144c0948b04e8ea8";
+      sha256 = "13igdbqsxb3sz0h417k6ifmq2n4siwqspj6slhc7fdl5wd1fxmdz";
+    });
 
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/gbenchmark/default.nix b/pkgs/development/libraries/gbenchmark/default.nix
index dd16ebd5c886..6745bc1ecf5f 100644
--- a/pkgs/development/libraries/gbenchmark/default.nix
+++ b/pkgs/development/libraries/gbenchmark/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "gbenchmark-${version}";
-  version = "1.2.0";
+  version = "1.3.0";
 
   src = fetchFromGitHub {
     owner = "google";
     repo = "benchmark";
     rev = "v${version}";
-    sha256 = "1gld3zdxgc0c0466qvnsi70h2ksx8qprjrx008rypdhzp6660m48";
+    sha256 = "1qx2dp7y0haj6wfbbfw8hx8sxb8ww0igdfrmmaaxfl0vhckylrxh";
   };
 
   buildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/gcab/default.nix b/pkgs/development/libraries/gcab/default.nix
index 38a36fc4e546..0758d1252274 100644
--- a/pkgs/development/libraries/gcab/default.nix
+++ b/pkgs/development/libraries/gcab/default.nix
@@ -1,16 +1,24 @@
-{ stdenv, fetchurl, intltool, gobjectIntrospection, pkgconfig }:
+{ stdenv, fetchurl, gettext, gobjectIntrospection, pkgconfig, meson, ninja, glibcLocales, git, vala, glib, zlib }:
 
 stdenv.mkDerivation rec {
   name = "gcab-${version}";
-  version = "0.7";
+  version = "1.1";
+
+  LC_ALL = "en_US.UTF-8";
 
   src = fetchurl {
     url = "mirror://gnome/sources/gcab/${version}/${name}.tar.xz";
-    sha256 = "1vxdsiky3492zlyrym02sdwf09y19rl2z5h5iin7qm0wizw5wvm1";
+    sha256 = "0l19sr6pg0cfcddmi5n79d08mjjbhn427ip5jlsy9zddq9r24aqr";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ intltool gobjectIntrospection ];
+  nativeBuildInputs = [ meson ninja glibcLocales git pkgconfig vala gettext gobjectIntrospection ];
+
+  buildInputs = [ glib zlib ];
+
+  mesonFlags = [
+    "-Ddocs=false"
+    "-Dtests=false"
+  ];
 
   meta = with stdenv.lib; {
     platforms = platforms.linux;
diff --git a/pkgs/development/libraries/gdal/default.nix b/pkgs/development/libraries/gdal/default.nix
index 984d3da81198..562d79b00921 100644
--- a/pkgs/development/libraries/gdal/default.nix
+++ b/pkgs/development/libraries/gdal/default.nix
@@ -8,12 +8,12 @@
 with stdenv.lib;
 
 stdenv.mkDerivation rec {
-  version = "2.2.1";
+  version = "2.2.4";
   name = "gdal-${version}";
 
   src = fetchurl {
     url = "http://download.osgeo.org/gdal/${version}/${name}.tar.xz";
-    sha256 = "0rk0p0k787whzzdl8m1f9wcrm7h9bf1pny3z96d93b4383arhw4j";
+    sha256 = "0y1237m2wilxgrsd0cdjpbf1zj9z954sd8518g53hlmkmk8v27j4";
   };
 
   buildInputs = [ unzip libjpeg libtiff libpng proj openssl sqlite
@@ -29,7 +29,7 @@ stdenv.mkDerivation rec {
     "--with-poppler=${poppler.dev}" # optional
     "--with-libz=${zlib.dev}"       # optional
     "--with-pg=${postgresql}/bin/pg_config"
-    "--with-mysql=${mysql.lib.dev}/bin/mysql_config"
+    "--with-mysql=${mysql.connector-c or mysql}/bin/mysql_config"
     "--with-geotiff=${libgeotiff}"
     "--with-sqlite3=${sqlite.dev}"
     "--with-spatialite=${libspatialite}"
diff --git a/pkgs/development/libraries/gdal/gdal-1_11.nix b/pkgs/development/libraries/gdal/gdal-1_11.nix
index c9f0c0761019..7a80ce7fdb66 100644
--- a/pkgs/development/libraries/gdal/gdal-1_11.nix
+++ b/pkgs/development/libraries/gdal/gdal-1_11.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, unzip, libjpeg, libtiff, zlib
-, postgresql, mysql, libgeotiff, python, pythonPackages, proj, geos, openssl
+, postgresql, mysql57, libgeotiff, python, pythonPackages, proj, geos, openssl
 , libpng }:
 
 stdenv.mkDerivation rec {
@@ -32,7 +32,7 @@ stdenv.mkDerivation rec {
     "--with-libz=${zlib.dev}"       # optional
 
     "--with-pg=${postgresql}/bin/pg_config"
-    "--with-mysql=${mysql.lib.dev}/bin/mysql_config"
+    "--with-mysql=${mysql57.connector-c}/bin/mysql_config"
     "--with-geotiff=${libgeotiff}"
     "--with-python"               # optional
     "--with-static-proj4=${proj}" # optional
diff --git a/pkgs/development/libraries/gdbm/default.nix b/pkgs/development/libraries/gdbm/default.nix
index 3b78225a447f..3fd0bb082440 100644
--- a/pkgs/development/libraries/gdbm/default.nix
+++ b/pkgs/development/libraries/gdbm/default.nix
@@ -1,14 +1,14 @@
 { stdenv, lib, buildPlatform, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "gdbm-1.13";
+  name = "gdbm-1.14.1";
 
   src = fetchurl {
     url = "mirror://gnu/gdbm/${name}.tar.gz";
-    sha256 = "0lx201q20dvc70f8a3c9s7s18z15inlxvbffph97ngvrgnyjq9cx";
+    sha256 = "0pxwz3jlwvglq2mrbxvrjgr8pa0aj73p3v9sxmdlj570zw0gzknd";
   };
 
-  doCheck = stdenv.buildPlatform == stdenv.hostPlatform;
+  doCheck = true; # not cross;
 
   # Linking static stubs on cygwin requires correct ordering.
   # Consider upstreaming this.
diff --git a/pkgs/development/libraries/gdcm/default.nix b/pkgs/development/libraries/gdcm/default.nix
index 2d7e26b9e1a8..dcdb6a2297b2 100644
--- a/pkgs/development/libraries/gdcm/default.nix
+++ b/pkgs/development/libraries/gdcm/default.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, cmake, vtk }:
 
 stdenv.mkDerivation rec {
-  version = "2.6.4";
+  version = "2.8.6";
   name = "gdcm-${version}";
 
   src = fetchurl {
     url = "mirror://sourceforge/gdcm/${name}.tar.bz2";
-    sha256 = "14bysjdldq7xb9k1ayskxijm08dy2n45v9bg379dqrcz1q5xq5mi";
+    sha256 = "07q7w2qvpknvncp3g6m5f6b3m1ld4pzns52bqah8da7pabgwspjy";
   };
 
   dontUseCmakeBuildDir = true;
diff --git a/pkgs/development/libraries/gdk-pixbuf/default.nix b/pkgs/development/libraries/gdk-pixbuf/default.nix
index 38c1b6197a5f..6bfa6bdc2fb9 100644
--- a/pkgs/development/libraries/gdk-pixbuf/default.nix
+++ b/pkgs/development/libraries/gdk-pixbuf/default.nix
@@ -1,17 +1,17 @@
-{ stdenv, fetchurl, pkgconfig, glib, libtiff, libjpeg, libpng, libX11
-, jasper, libintlOrEmpty, gobjectIntrospection, doCheck ? false }:
+{ stdenv, fetchurl, pkgconfig, glib, libtiff, libjpeg, libpng, libX11, gnome3
+, jasper, gobjectIntrospection, doCheck ? false }:
 
 let
-  ver_maj = "2.36";
-  ver_min = "7";
+  pname = "gdk-pixbuf";
+  version = "2.36.7";
   # TODO: since 2.36.8 gdk-pixbuf gets configured to use mime-type sniffing,
-  # which apparently requires access to shared_mime_info files during runtime.
+  # which apparently requires access to shared-mime-info files during runtime.
 in
 stdenv.mkDerivation rec {
-  name = "gdk-pixbuf-${ver_maj}.${ver_min}";
+  name = "${pname}-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/gdk-pixbuf/${ver_maj}/${name}.tar.xz";
+    url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
     sha256 = "1b6e5eef09d98f05f383014ecd3503e25dfb03d7e5b5f5904e5a65b049a6a4d8";
   };
 
@@ -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 ];
 
@@ -47,6 +47,13 @@ stdenv.mkDerivation rec {
   # The tests take an excessive amount of time (> 1.5 hours) and memory (> 6 GB).
   inherit (doCheck);
 
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+      attrPath = "gdk_pixbuf";
+    };
+  };
+
   meta = with stdenv.lib; {
     description = "A library for image loading and manipulation";
     homepage = http://library.gnome.org/devel/gdk-pixbuf/;
@@ -54,4 +61,3 @@ stdenv.mkDerivation rec {
     platforms = platforms.unix;
   };
 }
-
diff --git a/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh b/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh
index ba7ab82f50b4..5a7dcd792996 100644
--- a/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh
+++ b/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh
@@ -14,4 +14,4 @@ findGdkPixbufLoaders() {
 
 }
 
-envHooks+=(findGdkPixbufLoaders)
+addEnvHooks "$hostOffset" findGdkPixbufLoaders
diff --git a/pkgs/development/libraries/gecode/3.nix b/pkgs/development/libraries/gecode/3.nix
index a0f3dc636f92..db2b14d71fdb 100644
--- a/pkgs/development/libraries/gecode/3.nix
+++ b/pkgs/development/libraries/gecode/3.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, perl }:
+{ stdenv, fetchurl, bash, perl }:
 
 stdenv.mkDerivation rec {
   name = "gecode-${version}";
@@ -9,7 +9,9 @@ stdenv.mkDerivation rec {
     sha256 = "0k45jas6p3cyldgyir1314ja3174sayn2h2ly3z9b4dl3368pk77";
   };
 
-  buildInputs = [ perl ];
+  nativeBuildInputs = [ bash perl ];
+
+  preConfigure = "patchShebangs configure";
 
   meta = with stdenv.lib; {
     license = licenses.mit;
diff --git a/pkgs/development/libraries/gecode/default.nix b/pkgs/development/libraries/gecode/default.nix
index 5d683de404d9..83ec0edfb49f 100644
--- a/pkgs/development/libraries/gecode/default.nix
+++ b/pkgs/development/libraries/gecode/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "gecode-${version}";
-  version = "5.0.0";
+  version = "6.0.0";
 
   src = fetchurl {
     url = "http://www.gecode.org/download/${name}.tar.gz";
-    sha256 = "0yz7m4msp7g2jzsn216q74d9n7rv6qh8abcv0jdc1n7y2nhjzzzl";
+    sha256 = "0dp7bm6k790jx669y4jr0ffi5cdfpwsqm1ykj2c0zh56jsgs6hfs";
   };
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/gegl/3.0.nix b/pkgs/development/libraries/gegl/3.0.nix
index 48b1e47e0edc..161153b7e3dc 100644
--- a/pkgs/development/libraries/gegl/3.0.nix
+++ b/pkgs/development/libraries/gegl/3.0.nix
@@ -1,12 +1,13 @@
 { stdenv, fetchurl, pkgconfig, glib, babl, libpng, cairo, libjpeg, which
-, librsvg, pango, gtk, bzip2, json_glib, intltool, autoreconfHook, libraw }:
+, librsvg, pango, gtk, bzip2, json-glib, intltool, autoreconfHook, libraw
+, libwebp, gnome3, libintl }:
 
 stdenv.mkDerivation rec {
-  name = "gegl-0.3.18";
+  name = "gegl-0.3.34";
 
   src = fetchurl {
     url = "http://download.gimp.org/pub/gegl/0.3/${name}.tar.bz2";
-    sha256 = "1ywihjav9yhmsvbrdyx9c5q71rqdkjg8l66ywca6s4yydvr8x1fp";
+    sha256 = "010k86wn8cmr07rqwa4lccrmiiqrwbnkxvic4lpapwgbamv258jw";
   };
 
   hardeningDisable = [ "format" ];
@@ -14,17 +15,24 @@ stdenv.mkDerivation rec {
   # needs fonts otherwise  don't know how to pass them
   configureFlags = "--disable-docs";
 
+  enableParallelBuilding = true;
+
+  doCheck = true;
+
   buildInputs = [
-    babl libpng cairo libjpeg librsvg pango gtk bzip2 which json_glib intltool
-    libraw
+    libpng cairo libjpeg librsvg pango gtk bzip2
+    libraw libwebp gnome3.gexiv2
   ];
 
-  nativeBuildInputs = [ pkgconfig autoreconfHook ];
+  propagatedBuildInputs = [ glib json-glib babl ]; # for gegl-3.0.pc
+
+  nativeBuildInputs = [ pkgconfig intltool which autoreconfHook libintl ];
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "Graph-based image processing framework";
     homepage = http://www.gegl.org;
-    license = stdenv.lib.licenses.gpl3;
-    platforms = stdenv.lib.platforms.linux;
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ jtojnar ];
+    platforms = platforms.unix;
   };
 }
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/geis/default.nix b/pkgs/development/libraries/geis/default.nix
index 6e043f5994df..5796425e4385 100644
--- a/pkgs/development/libraries/geis/default.nix
+++ b/pkgs/development/libraries/geis/default.nix
@@ -1,14 +1,20 @@
 { stdenv, fetchurl
 , pkgconfig
-, python3
+, python3Packages
+, wrapGAppsHook
+, atk
 , dbus_libs
 , evemu
 , frame
+, gdk_pixbuf
+, gobjectIntrospection
 , grail
+, gtk3
 , libX11
 , libXext
 , libXi
 , libXtst
+, pango
 , xorgserver
 }:
 
@@ -25,8 +31,23 @@ stdenv.mkDerivation rec {
 
   NIX_CFLAGS_COMPILE = "-Wno-format -Wno-misleading-indentation -Wno-error";
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ python3 dbus_libs evemu frame grail libX11 libXext libXi libXtst xorgserver ];
+  pythonPath = with python3Packages;
+    [ pygobject3  ];
+
+  nativeBuildInputs = [ pkgconfig wrapGAppsHook python3Packages.wrapPython];
+  buildInputs = [ atk dbus_libs evemu frame gdk_pixbuf gobjectIntrospection grail
+    gtk3 libX11 libXext libXi libXtst pango python3Packages.python xorgserver
+  ];
+
+  patchPhase = ''
+    substituteInPlace python/geis/geis_v2.py --replace \
+      "ctypes.util.find_library(\"geis\")" "'$out/lib/libgeis.so'"
+  '';
+
+  preFixup = ''
+    buildPythonPath "$out $pythonPath"
+    gappsWrapperArgs+=(--set PYTHONPATH "$program_PYTHONPATH")
+  '';
 
   meta = {
     description = "A library for input gesture recognition";
diff --git a/pkgs/development/libraries/geoclue/2.0.nix b/pkgs/development/libraries/geoclue/2.0.nix
index 483ee39c2da1..495a113391e3 100644
--- a/pkgs/development/libraries/geoclue/2.0.nix
+++ b/pkgs/development/libraries/geoclue/2.0.nix
@@ -1,5 +1,5 @@
-{ fetchurl, stdenv, intltool, libintlOrEmpty, pkgconfig, glib, json_glib, libsoup, geoip
-, dbus, dbus_glib, modemmanager, avahi, glib_networking, wrapGAppsHook
+{ fetchurl, stdenv, intltool, pkgconfig, glib, json-glib, libsoup, geoip
+, dbus, dbus-glib, modemmanager, avahi, glib-networking, wrapGAppsHook, gobjectIntrospection
 }:
 
 with stdenv.lib;
@@ -15,21 +15,20 @@ stdenv.mkDerivation rec {
   outputs = [ "out" "dev" ];
 
   nativeBuildInputs = [
-    pkgconfig intltool wrapGAppsHook
+    pkgconfig intltool wrapGAppsHook gobjectIntrospection
   ];
 
-  buildInputs = libintlOrEmpty ++
-   [ glib json_glib libsoup geoip
-     dbus dbus_glib avahi
+  buildInputs = [ glib json-glib libsoup geoip
+     dbus dbus-glib avahi
    ] ++ optionals (!stdenv.isDarwin) [ modemmanager ];
 
-  propagatedBuildInputs = [ dbus dbus_glib glib glib_networking ];
+  propagatedBuildInputs = [ dbus dbus-glib glib glib-networking ];
 
   preConfigure = ''
      substituteInPlace configure --replace "-Werror" ""
   '';
 
-  configureFlags = [ "--with-systemdsystemunitdir=$(out)/etc/systemd/system" ] ++
+  configureFlags = [ "--with-systemdsystemunitdir=$(out)/etc/systemd/system" "--enable-introspection" ] ++
                    optionals stdenv.isDarwin [
                        "--disable-silent-rules"
                        "--disable-3g-source"
@@ -37,14 +36,13 @@ 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|"
   '';
 
   meta = with stdenv.lib; {
     description = "Geolocation framework and some data providers";
+    homepage = https://freedesktop.org/wiki/Software/GeoClue/;
     maintainers = with maintainers; [ raskin garbas ];
     platforms = with platforms; linux ++ darwin;
     license = licenses.lgpl2;
diff --git a/pkgs/development/libraries/geoclue/default.nix b/pkgs/development/libraries/geoclue/default.nix
index ff65ca97eb74..bf0af502d017 100644
--- a/pkgs/development/libraries/geoclue/default.nix
+++ b/pkgs/development/libraries/geoclue/default.nix
@@ -1,5 +1,5 @@
-{ stdenv, fetchurl, dbus, dbus_glib, glib, pkgconfig, libxml2, gnome2,
-  libxslt, glib_networking }:
+{ stdenv, fetchurl, dbus, dbus-glib, glib, pkgconfig, libxml2, gnome2,
+  libxslt, glib-networking }:
 
 stdenv.mkDerivation rec {
   name = "geoclue-0.12.0";
@@ -11,9 +11,9 @@ stdenv.mkDerivation rec {
   outputs = [ "out" "dev" ];
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ libxml2 gnome2.GConf libxslt glib_networking ];
+  buildInputs = [ libxml2 gnome2.GConf libxslt glib-networking ];
 
-  propagatedBuildInputs = [dbus glib dbus_glib];
+  propagatedBuildInputs = [dbus glib dbus-glib];
 
   hardeningDisable = [ "format" ];
 
diff --git a/pkgs/development/libraries/geoip/default.nix b/pkgs/development/libraries/geoip/default.nix
index 60d40b10aa42..cb8138dc115e 100644
--- a/pkgs/development/libraries/geoip/default.nix
+++ b/pkgs/development/libraries/geoip/default.nix
@@ -1,18 +1,23 @@
 # in geoipDatabase, you can insert a package defining ${geoipDatabase}/share/GeoIP
 # e.g. geolite-legacy
-{ stdenv, fetchurl, pkgs, drvName ? "geoip", geoipDatabase ? "/var/lib/geoip-databases" }:
+{ stdenv, fetchFromGitHub, autoreconfHook
+, drvName ? "geoip", geoipDatabase ? "/var/lib/geoip-databases" }:
 
-let version = "1.6.2";
+let version = "1.6.12";
     dataDir = if (stdenv.lib.isDerivation geoipDatabase) then "${toString geoipDatabase}/share/GeoIP" else geoipDatabase;
 in stdenv.mkDerivation {
   name = "${drvName}-${version}";
 
-  src = fetchurl {
-    url = "http://geolite.maxmind.com/download/geoip/api/c/GeoIP-${version}.tar.gz";
-    sha256 = "0dd6si4cvip73kxdn43apg6yygvaf7dnk5awqfg9w2fd2ll0qnh7";
+  src = fetchFromGitHub {
+    owner = "maxmind";
+    repo = "geoip-api-c";
+    rev = "v${version}";
+    sha256 = "0ixyp3h51alnncr17hqp1p0rlqz9w69nlhm60rbzjjz3vjx52ajv";
   };
 
-  postPatch = ''
+  nativeBuildInputs = [ autoreconfHook ];
+
+  postConfigure = ''
     find . -name Makefile.in -exec sed -i -r 's#^pkgdatadir\s*=.+$#pkgdatadir = ${dataDir}#' {} \;
   '';
 
diff --git a/pkgs/development/libraries/geos/default.nix b/pkgs/development/libraries/geos/default.nix
index de7111f6be36..24e3b4842faf 100644
--- a/pkgs/development/libraries/geos/default.nix
+++ b/pkgs/development/libraries/geos/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, fetchpatch, python }:
 
 stdenv.mkDerivation rec {
-  name = "geos-3.6.1";
+  name = "geos-3.6.2";
 
   src = fetchurl {
     url = "http://download.osgeo.org/geos/${name}.tar.bz2";
-    sha256 = "1icz31kd5sml2kdxhjznvmv33zfr6nig9l0i6bdcz9q9g8x4wbja";
+    sha256 = "0ak5szby29l9l0vy43dm5z2g92xzdky20q1gc1kah1fnhkgi6nh4";
   };
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/getdns/default.nix b/pkgs/development/libraries/getdns/default.nix
new file mode 100644
index 000000000000..779534460df2
--- /dev/null
+++ b/pkgs/development/libraries/getdns/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchurl, libtool, unbound, libidn, m4, file
+, openssl, doxygen, autoreconfHook, automake }:
+
+stdenv.mkDerivation rec {
+  pname = "getdns";
+  name = "${pname}-${version}";
+  version = "1.4.1";
+
+  src = fetchurl {
+    url = "https://getdnsapi.net/releases/${pname}-1-4-1/${pname}-${version}.tar.gz";
+    sha256 = "07n5n5m4dnnh2xkh7wrnlx8s8myrvjf2nbs7n5m5nq8gg3f36li4";
+  };
+
+  nativeBuildInputs = [ libtool m4 autoreconfHook automake file ];
+
+  buildInputs = [ unbound libidn openssl doxygen ];
+
+  patchPhase = ''
+    substituteInPlace m4/acx_openssl.m4 \
+      --replace /usr/local/ssl ${openssl.dev}
+    '';
+
+  meta = with stdenv.lib; {
+    description = "A modern asynchronous DNS API";
+    longDescription = ''
+      getdns is an implementation of a modern asynchronous DNS API; the
+      specification was originally edited by Paul Hoffman. It is intended to make all
+      types of DNS information easily available to application developers and non-DNS
+      experts. DNSSEC offers a unique global infrastructure for establishing and
+      enhancing cryptographic trust relations. With the development of this API the
+      developers intend to offer application developers a modern and flexible
+      interface that enables end-to-end trust in the DNS architecture, and which will
+      inspire application developers to implement innovative security solutions in
+      their applications.
+'';
+    homepage = https://getdnsapi.net;
+    maintainers = with maintainers; [ leenaars ];
+    license = licenses.bsd3;
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/gettext/default.nix b/pkgs/development/libraries/gettext/default.nix
index a35d2380eded..6dec7747c7e8 100644
--- a/pkgs/development/libraries/gettext/default.nix
+++ b/pkgs/development/libraries/gettext/default.nix
@@ -48,6 +48,9 @@ stdenv.mkDerivation rec {
   # HACK, see #10874 (and 14664)
   buildInputs = stdenv.lib.optional (!stdenv.isLinux && !hostPlatform.isCygwin) libiconv;
 
+  setupHook = ./gettext-setup-hook.sh;
+  gettextNeedsLdflags = hostPlatform.libc != "glibc" && !hostPlatform.isMusl;
+
   enableParallelBuilding = true;
 
   meta = {
diff --git a/pkgs/development/libraries/gettext/gettext-setup-hook.sh b/pkgs/development/libraries/gettext/gettext-setup-hook.sh
new file mode 100644
index 000000000000..074d313e48aa
--- /dev/null
+++ b/pkgs/development/libraries/gettext/gettext-setup-hook.sh
@@ -0,0 +1,28 @@
+gettextDataDirsHook() {
+    if [ -d "$1/share/gettext" ]; then
+        addToSearchPath GETTEXTDATADIRS "$1/share/gettext"
+    fi
+}
+
+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/giflib/5.0.nix b/pkgs/development/libraries/giflib/5.0.nix
deleted file mode 100644
index 95038284cd60..000000000000
--- a/pkgs/development/libraries/giflib/5.0.nix
+++ /dev/null
@@ -1,18 +0,0 @@
-{stdenv, fetchurl, xmlto, docbook_xml_dtd_412, docbook_xsl, libxml2 }:
-
-stdenv.mkDerivation {
-  name = "giflib-5.0.6";
-  src = fetchurl {
-    url = mirror://sourceforge/giflib/giflib-5.0.6.tar.bz2;
-    sha256 = "1sk9ysh27nabwb6z7a38n8gy2y2rnl3vjkbapv7pbjnzrff862c9";
-  };
-
-  buildInputs = [ xmlto docbook_xml_dtd_412 docbook_xsl libxml2 ];
-  meta = {
-    description = "A library for reading and writing gif images";
-    platforms = stdenv.lib.platforms.unix;
-    license = stdenv.lib.licenses.mit;
-    maintainers = with stdenv.lib.maintainers; [ fuuzetsu ];
-    branch = "5.0";
-  };
-}
diff --git a/pkgs/development/libraries/git2/0.25.nix b/pkgs/development/libraries/git2/0.25.nix
new file mode 100644
index 000000000000..9743b82a14ab
--- /dev/null
+++ b/pkgs/development/libraries/git2/0.25.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchFromGitHub, cmake, pkgconfig, python
+, zlib, libssh2, openssl, http-parser, curl
+, libiconv, Security
+}:
+
+stdenv.mkDerivation rec {
+  version = "0.25.1";
+  name = "libgit2-${version}";
+
+  src = fetchFromGitHub {
+    owner = "libgit2";
+    repo = "libgit2";
+    rev = "v${version}";
+    sha256 = "1jhikg0gqpdzfzhgv44ybdpm24lvgkc7ki4306lc5lvmj1s2nylj";
+  };
+
+  cmakeFlags = [ "-DTHREADSAFE=ON" ];
+
+  nativeBuildInputs = [ cmake python pkgconfig ];
+
+  buildInputs = [ zlib libssh2 openssl http-parser curl ]
+    ++ stdenv.lib.optional stdenv.isDarwin Security;
+
+  propagatedBuildInputs = stdenv.lib.optional (!stdenv.isLinux) libiconv;
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "The Git linkable library";
+    homepage = https://libgit2.github.com/;
+    license = stdenv.lib.licenses.gpl2;
+    platforms = with stdenv.lib.platforms; all;
+  };
+}
diff --git a/pkgs/development/libraries/git2/default.nix b/pkgs/development/libraries/git2/default.nix
index 0d53d00737ba..c0659a79fd34 100644
--- a/pkgs/development/libraries/git2/default.nix
+++ b/pkgs/development/libraries/git2/default.nix
@@ -1,37 +1,36 @@
-{ stdenv, fetchurl, pkgconfig, cmake, zlib, python, libssh2, openssl, curl, http-parser, libiconv }:
+{ stdenv, fetchFromGitHub, pkgconfig, cmake
+, zlib, python, libssh2, openssl, curl, http-parser
+, libiconv, Security
+}:
 
 stdenv.mkDerivation (rec {
-  version = "0.25.1";
   name = "libgit2-${version}";
+  version = "0.26.0";
+  # keep the version in sync with pythonPackages.pygit2 and gnome3.libgit2-glib
 
-  src = fetchurl {
-    name = "${name}.tar.gz";
-    url = "https://github.com/libgit2/libgit2/tarball/v${version}";
-    sha256 = "100bah8picqjzyhpw4wd7z5vyidcb8aggin50bhbpn607h8n8bml";
+  src = fetchFromGitHub {
+    owner = "libgit2";
+    repo = "libgit2";
+    rev = "v${version}";
+    sha256 = "0zrrmfkfhd2xb4879z5khjb6xsdklrm01f1lscrs2ks68v25fk78";
   };
 
-  # TODO: `cargo` (rust's package manager) surfaced a serious bug in
-  # libgit2 when the `Security.framework` transport is used on Darwin.
-  # The upstream issue is tracked at
-  # https://github.com/libgit2/libgit2/issues/3885 - feel free to
-  # remove this patch as soon as it's resolved (i.E. when cargo is
-  # working fine without this patch)
-  patches = stdenv.lib.optionals stdenv.isDarwin [
-    ./disable-security.framework.patch
-  ];
-
-  cmakeFlags = "-DTHREADSAFE=ON";
+  cmakeFlags = [ "-DTHREADSAFE=ON" ];
 
   nativeBuildInputs = [ cmake python pkgconfig ];
-  buildInputs = [ zlib libssh2 openssl http-parser curl ];
 
-  meta = {
+  buildInputs = [ zlib libssh2 openssl http-parser curl ]
+    ++ stdenv.lib.optional stdenv.isDarwin Security;
+
+  propagatedBuildInputs = stdenv.lib.optional (!stdenv.isLinux) [ libiconv ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
     description = "The Git linkable library";
     homepage = https://libgit2.github.com/;
-    license = stdenv.lib.licenses.gpl2;
-    platforms = with stdenv.lib.platforms; all;
+    license = licenses.gpl2;
+    platforms = with platforms; all;
   };
 } // stdenv.lib.optionalAttrs (!stdenv.isLinux) {
-  NIX_LDFLAGS = "-liconv";
-  propagatedBuildInputs = [ libiconv ];
 })
diff --git a/pkgs/development/libraries/git2/disable-security.framework.patch b/pkgs/development/libraries/git2/disable-security.framework.patch
deleted file mode 100644
index ce6a008b1c4c..000000000000
--- a/pkgs/development/libraries/git2/disable-security.framework.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-From fbc2ea65406236a740b8734dd41dc5ddbc24f8c9 Mon Sep 17 00:00:00 2001
-From: mulrich <mulrich@entwicklerheld.local>
-Date: Mon, 8 Aug 2016 15:36:07 +0200
-Subject: [PATCH] disable security.framework
-
----
- CMakeLists.txt    | 7 +++----
- src/curl_stream.c | 9 ++++++++-
- 2 files changed, 11 insertions(+), 5 deletions(-)
-
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 93a9e47..331e148 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -49,7 +49,8 @@ ENDIF()
- 
- IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
- 	SET( USE_ICONV ON )
--	FIND_PACKAGE(Security)
-+	# FIND_PACKAGE(Security)
-+  SET(SECURITY_FOUND "NO")
- 	FIND_PACKAGE(CoreFoundation REQUIRED)
- ENDIF()
- 
-@@ -87,9 +88,7 @@ IF(MSVC)
- 	OPTION(MSVC_CRTDBG "Enable CRTDBG memory leak reporting" OFF)
- ENDIF()
- 
--IF (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
--	OPTION( USE_OPENSSL                     "Link with and use openssl library"             ON )
--ENDIF()
-+OPTION( USE_OPENSSL                     "Link with and use openssl library"             ON )
- 
- CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtim "sys/types.h;sys/stat.h"
- 	HAVE_STRUCT_STAT_ST_MTIM LANGUAGE C)
-diff --git a/src/curl_stream.c b/src/curl_stream.c
-index 98de187..a8a9f4c 100644
---- a/src/curl_stream.c
-+++ b/src/curl_stream.c
-@@ -309,7 +309,14 @@ int git_curl_stream_new(git_stream **out, const char *host, const char *port)
- 	curl_easy_setopt(handle, CURLOPT_HTTPPROXYTUNNEL, 1);
- 	curl_easy_setopt(handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
- 
--	/* curl_easy_setopt(handle, CURLOPT_VERBOSE, 1); */
-+  const char* cainfo = getenv("SSL_CERT_FILE");
-+  if(cainfo != NULL) {
-+    curl_easy_setopt(handle, CURLOPT_CAINFO, cainfo);
-+  }
-+
-+  /*
-+	curl_easy_setopt(handle, CURLOPT_VERBOSE, 1);
-+  */
- 
- 	st->parent.version = GIT_STREAM_VERSION;
- 	st->parent.encrypted = 0; /* we don't encrypt ourselves */
--- 
-2.3.8 (Apple Git-58)
-
diff --git a/pkgs/development/libraries/givaro/default.nix b/pkgs/development/libraries/givaro/default.nix
index 335afa566dbe..3556acb0590d 100644
--- a/pkgs/development/libraries/givaro/default.nix
+++ b/pkgs/development/libraries/givaro/default.nix
@@ -1,16 +1,34 @@
-{stdenv, fetchFromGitHub, automake, autoconf, libtool, autoreconfHook, gmpxx}:
+{ stdenv, fetchFromGitHub, automake, autoconf, libtool, autoreconfHook, gmpxx
+, optimize ? false # impure
+}:
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
   pname = "givaro";
-  version = "4.0.2";
+  version = "4.0.4";
   src = fetchFromGitHub {
     owner = "linbox-team";
     repo = "${pname}";
     rev = "v${version}";
-    sha256 = "04n1lyc823z3l1d7mnmqpc9z1pkn646szjchasbfkn74m7cb0qz7";
+    sha256 = "199p8wyj5i63jbnk7j8qbdbfp5rm2lpmcxyk3mdjy9bz7ygx3hhy";
   };
   nativeBuildInputs = [ autoreconfHook ];
   buildInputs = [autoconf automake libtool gmpxx];
+  configureFlags = [
+    "--disable-optimization"
+  ] ++ stdenv.lib.optionals (!optimize) [
+    # disable SIMD instructions (which are enabled *when available* by default)
+    "--disable-sse"
+    "--disable-sse2"
+    "--disable-sse3"
+    "--disable-ssse3"
+    "--disable-sse41"
+    "--disable-sse42"
+    "--disable-avx"
+    "--disable-avx2"
+    "--disable-fma"
+    "--disable-fma4"
+  ];
+  doCheck = true;
   meta = {
     inherit version;
     description = ''A C++ library for arithmetic and algebraic computations'';
diff --git a/pkgs/development/libraries/glbinding/default.nix b/pkgs/development/libraries/glbinding/default.nix
new file mode 100644
index 000000000000..339e0d8d60b9
--- /dev/null
+++ b/pkgs/development/libraries/glbinding/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchFromGitHub, cmake, libGLU, xlibsWrapper }:
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "glbinding";
+  version = "2.1.4";
+
+  src = fetchFromGitHub {
+    owner = "cginternals";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "1yic3p2iqzxc7wrjnqclx7vcaaqx5fiysq9rqbi6v390jqkg3zlz";
+  };
+
+  buildInputs = [ cmake libGLU xlibsWrapper ];
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/cginternals/glbinding/;
+    description = "A C++ binding for the OpenGL API, generated using the gl.xml specification";
+    license = licenses.mit;
+    maintainers = [ maintainers.mt-caret ];
+  };
+}
diff --git a/pkgs/development/libraries/gle/default.nix b/pkgs/development/libraries/gle/default.nix
index 64f51a56fd37..1980c633474f 100644
--- a/pkgs/development/libraries/gle/default.nix
+++ b/pkgs/development/libraries/gle/default.nix
@@ -1,7 +1,7 @@
-{stdenv, fetchurl, mesa, freeglut, libX11, libXt, libXmu, libXi, libXext}:
+{stdenv, fetchurl, libGLU_combined, freeglut, libX11, libXt, libXmu, libXi, libXext}:
 stdenv.mkDerivation {
   name = "gle-3.1.0";
-  buildInputs = [mesa freeglut libX11 libXt libXmu libXi libXext];
+  buildInputs = [libGLU_combined freeglut libX11 libXt libXmu libXi libXext];
   src = fetchurl {
     urls = [
       "mirror://sourceforge/project/gle/gle/gle-3.1.0/gle-3.1.0.tar.gz"
diff --git a/pkgs/development/libraries/glew/1.10.nix b/pkgs/development/libraries/glew/1.10.nix
index 3f8119d36d65..fafcf82258ab 100644
--- a/pkgs/development/libraries/glew/1.10.nix
+++ b/pkgs/development/libraries/glew/1.10.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, mesa_glu, x11, libXmu, libXi
+{ stdenv, fetchurl, libGLU, x11, libXmu, libXi
 , buildPlatform, hostPlatform
 , AGL ? null
 }:
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs = [ x11 libXmu libXi ] ++ optionals stdenv.isDarwin [ AGL ];
-  propagatedBuildInputs = [ mesa_glu ]; # GL/glew.h includes GL/glu.h
+  propagatedBuildInputs = [ libGLU ]; # GL/glew.h includes GL/glu.h
 
   patchPhase = ''
     sed -i 's|lib64|lib|' config/Makefile.linux
diff --git a/pkgs/development/libraries/glew/default.nix b/pkgs/development/libraries/glew/default.nix
index 57bb4cb631d4..a8add880090f 100644
--- a/pkgs/development/libraries/glew/default.nix
+++ b/pkgs/development/libraries/glew/default.nix
@@ -1,26 +1,27 @@
-{ stdenv, fetchurl, mesa_glu, xlibsWrapper, libXmu, libXi
+{ stdenv, fetchurl, libGLU, xlibsWrapper, libXmu, libXi
 , buildPlatform, hostPlatform
 }:
 
 with stdenv.lib;
 
 stdenv.mkDerivation rec {
-  name = "glew-2.0.0";
+  name = "glew-2.1.0";
 
   src = fetchurl {
     url = "mirror://sourceforge/glew/${name}.tgz";
-    sha256 = "0r37fg2s1f0jrvwh6c8cz5x6v4wqmhq42qm15cs9qs349q5c6wn5";
+    sha256 = "159wk5dc0ykjbxvag5i1m2mhp23zkk6ra04l26y3jc3nwvkr3ph4";
   };
 
   outputs = [ "bin" "out" "dev" "doc" ];
 
   buildInputs = [ xlibsWrapper libXmu libXi ];
-  propagatedBuildInputs = [ mesa_glu ]; # GL/glew.h includes GL/glu.h
+  propagatedBuildInputs = [ libGLU ]; # GL/glew.h includes GL/glu.h
 
   patchPhase = ''
     sed -i 's|lib64|lib|' config/Makefile.linux
+    substituteInPlace config/Makefile.darwin --replace /usr/local "$out"
     ${optionalString (hostPlatform != buildPlatform) ''
-    sed -i -e 's/\(INSTALL.*\)-s/\1/' Makefile
+      sed -i -e 's/\(INSTALL.*\)-s/\1/' Makefile
     ''}
   '';
 
@@ -43,6 +44,8 @@ stdenv.mkDerivation rec {
     "SYSTEM=${if hostPlatform.isMinGW then "mingw" else hostPlatform.parsed.kernel.name}"
   ];
 
+  enableParallelBuilding = true;
+
   meta = with stdenv.lib; {
     description = "An OpenGL extension loading library for C(++)";
     homepage = http://glew.sourceforge.net/;
diff --git a/pkgs/development/libraries/glfw/2.x.nix b/pkgs/development/libraries/glfw/2.x.nix
index a017ff3d988c..b1118b473b6f 100644
--- a/pkgs/development/libraries/glfw/2.x.nix
+++ b/pkgs/development/libraries/glfw/2.x.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, mesa_glu, mesa_noglu, libX11, libXext }:
+{ stdenv, fetchurl, libGLU, libGL, libX11, libXext }:
 
 stdenv.mkDerivation rec {
   name = "glfw-2.7.9";
@@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
     sha256 = "17c2msdcb7pn3p8f83805h1c216bmdqnbn9hgzr1j8wnwjcpxx6i";
   };
 
-  buildInputs = [ mesa_glu mesa_noglu libX11 libXext ];
+  buildInputs = [ libGLU libGL libX11 libXext ];
 
   buildPhase = ''
     make x11
diff --git a/pkgs/development/libraries/glfw/3.x.nix b/pkgs/development/libraries/glfw/3.x.nix
index c10b3c05986a..8d4d4d10038a 100644
--- a/pkgs/development/libraries/glfw/3.x.nix
+++ b/pkgs/development/libraries/glfw/3.x.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchFromGitHub, cmake, mesa_noglu, libXrandr, libXinerama, libXcursor, libX11
+{ stdenv, lib, fetchFromGitHub, cmake, libGL, libXrandr, libXinerama, libXcursor, libX11
 , darwin, fixDarwinDylibNames
 }:
 
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  propagatedBuildInputs = [ mesa_noglu ];
+  propagatedBuildInputs = [ libGL ];
 
   nativeBuildInputs = [ cmake ];
 
diff --git a/pkgs/development/libraries/glib-networking/default.nix b/pkgs/development/libraries/glib-networking/default.nix
index fd8055fd0b39..c3bcb3aa1c45 100644
--- a/pkgs/development/libraries/glib-networking/default.nix
+++ b/pkgs/development/libraries/glib-networking/default.nix
@@ -1,35 +1,49 @@
-{ stdenv, fetchurl, pkgconfig, glib, intltool, gnutls, libproxy
-, gsettings_desktop_schemas }:
+{ stdenv, fetchurl, fetchpatch, meson, ninja, pkgconfig, glib, gettext, gnutls, p11-kit, libproxy, gnome3
+, gsettings-desktop-schemas }:
 
 let
-  ver_maj = "2.54";
-  ver_min = "0";
+  pname = "glib-networking";
+  version = "2.56.0";
 in
 stdenv.mkDerivation rec {
-  name = "glib-networking-${ver_maj}.${ver_min}";
+  name = "${pname}-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/glib-networking/${ver_maj}/${name}.tar.xz";
-    sha256 = "5961b3779080b72314b373ff5d4790eb7e41b75ca91816ad7a81ef32922f7096";
+    url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
+    sha256 = "14vw8xwajd7m31bpavg2psk693plhjikwpk8bzf3jl1fmsy11za7";
   };
 
   outputs = [ "out" "dev" ]; # to deal with propagatedBuildInputs
 
-  configureFlags = "--with-ca-certificates=/etc/ssl/certs/ca-certificates.crt";
+  patches = [
+    # Use GNUTLS system trust for certificates
+    (fetchpatch {
+      url = https://git.gnome.org/browse/glib-networking/patch/?id=f1c8feee014007cc913b71357acb609f8d1200df;
+      sha256 = "1rbxqsrcb5if3xs2d18pqzd9xnjysdj715ijc41n5w326fsawg7i";
+    })
+  ];
 
-  preBuild = ''
-    sed -e "s@${glib.out}/lib/gio/modules@$out/lib/gio/modules@g" -i $(find . -name Makefile)
+  PKG_CONFIG_GIO_2_0_GIOMODULEDIR = "lib/gio/modules";
+
+  postPatch = ''
+    chmod +x meson_post_install.py # patchShebangs requires executable file
+    patchShebangs meson_post_install.py
   '';
 
-  nativeBuildInputs = [ pkgconfig intltool ];
-  propagatedBuildInputs = [ glib gnutls libproxy gsettings_desktop_schemas ];
+  nativeBuildInputs = [ meson ninja pkgconfig gettext ];
+  propagatedBuildInputs = [ glib gnutls p11-kit libproxy gsettings-desktop-schemas ];
 
   doCheck = false; # tests need to access the certificates (among other things)
 
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+    };
+  };
+
   meta = with stdenv.lib; {
     description = "Network-related giomodules for glib";
     license = licenses.lgpl2Plus;
     platforms = platforms.unix;
   };
 }
-
diff --git a/pkgs/development/libraries/glib/default.nix b/pkgs/development/libraries/glib/default.nix
index b82fd5f1e299..d2dc9a8c637b 100644
--- a/pkgs/development/libraries/glib/default.nix
+++ b/pkgs/development/libraries/glib/default.nix
@@ -1,10 +1,10 @@
-{ stdenv, hostPlatform, fetchurl, pkgconfig, gettext, perl, python
-, libiconv, libintlOrEmpty, zlib, libffi, pcre, libelf
+{ stdenv, hostPlatform, fetchurl, gettext, pkgconfig, perl, python
+, libiconv, zlib, libffi, pcre, libelf, gnome3
 # use utillinuxMinimal to avoid circular dependency (utillinux, systemd, glib)
 , utillinuxMinimal ? null
 
 # this is just for tests (not in closure of any regular package)
-, coreutils, dbus_daemon, libxml2, tzdata, desktop_file_utils, shared_mime_info, doCheck ? false
+, coreutils, dbus_daemon, libxml2, tzdata, desktop-file-utils, shared-mime-info, doCheck ? false
 }:
 
 with stdenv.lib;
@@ -42,20 +42,20 @@ let
     ln -sr -t "''${!outputInclude}/include/" "''${!outputInclude}"/lib/*/include/* 2>/dev/null || true
   '';
 
-  ver_maj = "2.54";
-  ver_min = "1";
+  version = "2.56.0";
 in
 
 stdenv.mkDerivation rec {
-  name = "glib-${ver_maj}.${ver_min}";
+  name = "glib-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/glib/${ver_maj}/${name}.tar.xz";
-    sha256 = "50c01b1419324f10fbf9b9709ec2164b18586968bdce7540583bf32302cf47a3";
+    url = "mirror://gnome/sources/glib/${gnome3.versionBranch version}/${name}.tar.xz";
+    sha256 = "1iqgi90fmpl3l23jm2iv44qp7hqsxvnv7978s18933bvx4bnxvzc";
   };
 
   patches = optional stdenv.isDarwin ./darwin-compilation.patch
-    ++ optional doCheck ./skip-timer-test.patch;
+    ++ optional doCheck ./skip-timer-test.patch
+    ++ [ ./schema-override-variable.patch ];
 
   outputs = [ "out" "dev" "devdoc" ];
   outputBin = "dev";
@@ -64,21 +64,23 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ libelf setupHook pcre ]
     ++ optionals stdenv.isLinux [ utillinuxMinimal ] # for libmount
-    ++ optionals doCheck [ tzdata libxml2 desktop_file_utils shared_mime_info ];
+    ++ 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"
-    ++ optional (stdenv.isFreeBSD || stdenv.isSunOS) "--with-libiconv=gnu"
-    ++ optional stdenv.isSunOS "--disable-dtrace";
+    ++ optional stdenv.isSunOS "--disable-dtrace"
+    # Can't run this test when cross-compiling
+    ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform)
+       [ "glib_cv_stack_grows=no" "glib_cv_uscore=no" ]
+    # 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
@@ -116,7 +118,7 @@ stdenv.mkDerivation rec {
     export XDG_CACHE_HOME="$TMP"
     export XDG_RUNTIME_HOME="$TMP"
     export HOME="$TMP"
-    export XDG_DATA_DIRS="${desktop_file_utils}/share:${shared_mime_info}/share"
+    export XDG_DATA_DIRS="${desktop-file-utils}/share:${shared-mime-info}/share"
     export G_TEST_DBUS_DAEMON="${dbus_daemon.out}/bin/dbus-daemon"
     export PATH="$PATH:$(pwd)/gobject"
     echo "PATH=$PATH"
@@ -135,8 +137,9 @@ stdenv.mkDerivation rec {
   '';
 
   passthru = {
-     gioModuleDir = "lib/gio/modules";
-     inherit flattenInclude;
+    gioModuleDir = "lib/gio/modules";
+    inherit flattenInclude;
+    updateScript = gnome3.updateScript { packageName = "glib"; };
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/glib/schema-override-variable.patch b/pkgs/development/libraries/glib/schema-override-variable.patch
new file mode 100644
index 000000000000..1cb5a730351b
--- /dev/null
+++ b/pkgs/development/libraries/glib/schema-override-variable.patch
@@ -0,0 +1,12 @@
+--- a/gio/gsettingsschema.c
++++ b/gio/gsettingsschema.c
+@@ -352,6 +352,9 @@
+ 
+       try_prepend_data_dir (g_get_user_data_dir ());
+ 
++      if ((path = g_getenv ("NIX_GSETTINGS_OVERRIDES_DIR")) != NULL)
++        try_prepend_dir (path);
++
+       if ((path = g_getenv ("GSETTINGS_SCHEMA_DIR")) != NULL)
+         try_prepend_dir (path);
+ 
diff --git a/pkgs/development/libraries/glib/setup-hook.sh b/pkgs/development/libraries/glib/setup-hook.sh
index c5cf293902cd..233845c6541f 100644
--- a/pkgs/development/libraries/glib/setup-hook.sh
+++ b/pkgs/development/libraries/glib/setup-hook.sh
@@ -5,13 +5,13 @@ make_glib_find_gsettings_schemas() {
         addToSearchPath GSETTINGS_SCHEMAS_PATH "$1/share/gsettings-schemas/"*
     fi
 }
-envHooks+=(make_glib_find_gsettings_schemas)
+addEnvHooks "$hostOffset" make_glib_find_gsettings_schemas
 
 # Install gschemas, if any, in a package-specific directory
 glibPreInstallPhase() {
   installFlagsArray+=("gsettingsschemadir=${!outputLib}/share/gsettings-schemas/$name/glib-2.0/schemas/")
 }
-preInstallPhases+=(glibPreInstallPhase)
+preInstallPhases+=" glibPreInstallPhase"
 
 glibPreFixupPhase() {
     # Move gschemas in case the install flag didn't help
@@ -22,5 +22,4 @@ glibPreFixupPhase() {
 
     addToSearchPath GSETTINGS_SCHEMAS_PATH "${!outputLib}/share/gsettings-schemas/$name"
 }
-preFixupPhases+=(glibPreFixupPhase)
-
+preFixupPhases+=" glibPreFixupPhase"
diff --git a/pkgs/development/libraries/glibc/2.25-49.patch.gz b/pkgs/development/libraries/glibc/2.25-49.patch.gz
deleted file mode 100644
index 6796347e3795..000000000000
--- a/pkgs/development/libraries/glibc/2.25-49.patch.gz
+++ /dev/null
Binary files differdiff --git a/pkgs/development/libraries/glibc/2.26-115to131.diff.gz b/pkgs/development/libraries/glibc/2.26-115to131.diff.gz
new file mode 100644
index 000000000000..3d866c567a79
--- /dev/null
+++ b/pkgs/development/libraries/glibc/2.26-115to131.diff.gz
Binary files differdiff --git a/pkgs/development/libraries/glibc/2.26-75.patch.gz b/pkgs/development/libraries/glibc/2.26-75.patch.gz
new file mode 100644
index 000000000000..e2a8867e4fff
--- /dev/null
+++ b/pkgs/development/libraries/glibc/2.26-75.patch.gz
Binary files differdiff --git a/pkgs/development/libraries/glibc/2.26-75to115.diff.gz b/pkgs/development/libraries/glibc/2.26-75to115.diff.gz
new file mode 100644
index 000000000000..9bf1a4f7d39b
--- /dev/null
+++ b/pkgs/development/libraries/glibc/2.26-75to115.diff.gz
Binary files differdiff --git a/pkgs/development/libraries/glibc/allow-kernel-2.6.32.patch b/pkgs/development/libraries/glibc/allow-kernel-2.6.32.patch
new file mode 100644
index 000000000000..ce18b874c427
--- /dev/null
+++ b/pkgs/development/libraries/glibc/allow-kernel-2.6.32.patch
@@ -0,0 +1,39 @@
+diff --git a/sysdeps/unix/sysv/linux/configure b/sysdeps/unix/sysv/linux/configure
+index cace758c01..38fe7fe0b0 100644
+--- a/sysdeps/unix/sysv/linux/configure
++++ b/sysdeps/unix/sysv/linux/configure
+@@ -69,7 +69,7 @@ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kernel header at least $minimum_kernel" >&5
+ $as_echo_n "checking for kernel header at least $minimum_kernel... " >&6; }
+ decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
+-abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
++abinum=`echo "2.6.32.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ #include <linux/version.h>
+diff --git a/sysdeps/unix/sysv/linux/configure.ac b/sysdeps/unix/sysv/linux/configure.ac
+index 13abda0a51..6abc12eaed 100644
+--- a/sysdeps/unix/sysv/linux/configure.ac
++++ b/sysdeps/unix/sysv/linux/configure.ac
+@@ -50,7 +50,7 @@ fi
+ AC_MSG_CHECKING(for kernel header at least $minimum_kernel)
+ changequote(,)dnl
+ decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
+-abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
++abinum=`echo "2.6.32.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
+ changequote([,])dnl
+ AC_TRY_COMPILE([#include <linux/version.h>
+ #if LINUX_VERSION_CODE < $decnum
+diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h
+index 823cd8224d..482caaeeec 100644
+--- a/sysdeps/unix/sysv/linux/dl-osinfo.h
++++ b/sysdeps/unix/sysv/linux/dl-osinfo.h
+@@ -39,7 +39,7 @@
+ 	  GLRO(dl_osversion) = version;					      \
+ 									      \
+ 	/* Now we can test with the required version.  */		      \
+-	if (__LINUX_KERNEL_VERSION > 0 && version < __LINUX_KERNEL_VERSION)   \
++	if (__LINUX_KERNEL_VERSION > 0 && version < __LINUX_KERNEL_VERSION && version != 0x020620)   \
+ 	  /* Not sufficent.  */						      \
+ 	  FATAL ("FATAL: kernel too old\n");				      \
+       }									      \
diff --git a/pkgs/development/libraries/glibc/common.nix b/pkgs/development/libraries/glibc/common.nix
index f0a7e5703e95..c8716bfdc796 100644
--- a/pkgs/development/libraries/glibc/common.nix
+++ b/pkgs/development/libraries/glibc/common.nix
@@ -20,9 +20,10 @@
 { stdenv, lib
 , buildPlatform, hostPlatform
 , buildPackages
-, fetchurl
+, fetchurl, fetchpatch ? null
 , linuxHeaders ? null
 , gd ? null, libpng ? null
+, bison
 }:
 
 { name
@@ -35,9 +36,9 @@
 } @ args:
 
 let
-  version = "2.25";
-  patchSuffix = "-49";
-  sha256 = "067bd9bb3390e79aa45911537d13c3721f1d9d3769931a30c2681bfee66f23a0";
+  version = "2.27";
+  patchSuffix = "";
+  sha256 = "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji";
   cross = if buildPlatform != hostPlatform then hostPlatform else null;
 in
 
@@ -45,7 +46,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.
@@ -57,13 +58,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.25-49.patch.gz
-
       /* Have rpcgen(1) look for cpp(1) in $PATH.  */
       ./rpcgen-path.patch
 
@@ -80,33 +74,49 @@ stdenv.mkDerivation ({
          "/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.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
     ''
+      # 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 =
     [ "-C"
       "--enable-add-ons"
+      "--enable-obsolete-nsl"
       "--enable-obsolete-rpc"
       "--sysconfdir=/etc"
       "--enable-stackguard-randomization"
@@ -116,15 +126,11 @@ stdenv.mkDerivation ({
       (if profilingLibraries
        then "--enable-profile"
        else "--disable-profile")
-    ] ++ lib.optionals (cross == null && withLinuxHeaders) [
-      "--enable-kernel=2.6.32"
+    ] ++ lib.optionals withLinuxHeaders [
+      "--enable-kernel=3.2.0" # can't get below with glibc >= 2.26
     ] ++ lib.optionals (cross != null) [
-      (if cross.withTLS then "--with-tls" else "--without-tls")
       (if cross ? float && cross.float == "soft" then "--without-fp" else "--with-fp")
-    ] ++ lib.optionals (cross != null
-          && cross.platform ? kernelMajor
-          && cross.platform.kernelMajor == "2.6") [
-      "--enable-kernel=2.6.0"
+    ] ++ lib.optionals (cross != null) [
       "--with-__thread"
     ] ++ lib.optionals (cross == null && stdenv.isArm) [
       "--host=arm-linux-gnueabi"
@@ -139,7 +145,8 @@ stdenv.mkDerivation ({
 
   outputs = [ "out" "bin" "dev" "static" ];
 
-  nativeBuildInputs = lib.optional (cross != null) buildPackages.stdenv.cc;
+  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
@@ -151,8 +158,7 @@ stdenv.mkDerivation ({
 // (removeAttrs args [ "withLinuxHeaders" "withGd" ]) //
 
 {
-  name = name + "-${version}${patchSuffix}" +
-    lib.optionalString (cross != null) "-${cross.config}";
+  name = name + "-${version}${patchSuffix}";
 
   src = fetchurl {
     url = "mirror://gnu/glibc/glibc-${version}.tar.xz";
@@ -185,14 +191,7 @@ stdenv.mkDerivation ({
     libc_cv_forced_unwind=yes
     libc_cv_c_cleanup=yes
     libc_cv_gnu89_inline=yes
-    # Only due to a problem in gcc configure scripts:
-    libc_cv_sparc64_tls=${if cross.withTLS then "yes" else "no"}
     EOF
-
-    export BUILD_CC=gcc
-    export CC="$crossConfig-gcc"
-    export AR="$crossConfig-ar"
-    export RANLIB="$crossConfig-ranlib"
   '';
 
   preBuild = lib.optionalString withGd "unset NIX_DONT_SET_RPATH";
@@ -226,6 +225,6 @@ stdenv.mkDerivation ({
 
   # To avoid a dependency on the build system 'bash'.
   preFixup = ''
-    rm $bin/bin/{ldd,tzselect,catchsegv,xtrace}
+    rm -f $bin/bin/{ldd,tzselect,catchsegv,xtrace}
   '';
 })
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/locales.nix b/pkgs/development/libraries/glibc/locales.nix
index debd7b39c86a..7090c5ceceec 100644
--- a/pkgs/development/libraries/glibc/locales.nix
+++ b/pkgs/development/libraries/glibc/locales.nix
@@ -6,7 +6,7 @@
    https://sourceware.org/git/?p=glibc.git;a=blob;f=localedata/SUPPORTED
 */
 
-{ stdenv, callPackage, writeText
+{ stdenv, buildPackages, callPackage, writeText
 , allLocales ? true, locales ? [ "en_US.UTF-8/UTF-8" ]
 }:
 
@@ -26,7 +26,7 @@ callPackage ./common.nix { inherit stdenv; } {
   # $TMPDIR/nix/store/...-glibc-.../lib/locale/locale-archive.
   buildPhase =
     ''
-      mkdir -p $TMPDIR/"${stdenv.cc.libc.out}/lib/locale"
+      mkdir -p $TMPDIR/"${buildPackages.stdenv.cc.libc.out}/lib/locale"
 
       # Hack to allow building of the locales (needed since glibc-2.12)
       sed -i -e 's,^$(rtld-prefix) $(common-objpfx)locale/localedef,localedef --prefix='$TMPDIR',' ../glibc-2*/localedata/Makefile
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/glm/0954.nix b/pkgs/development/libraries/glm/0954.nix
deleted file mode 100644
index 4eb3497b0392..000000000000
--- a/pkgs/development/libraries/glm/0954.nix
+++ /dev/null
@@ -1,36 +0,0 @@
-{ stdenv, fetchurl, unzip }:
-
-stdenv.mkDerivation rec {
-  name = "glm-0.9.5.4";
-
-  src = fetchurl {
-    url = "mirror://sourceforge/project/ogl-math/${name}/${name}.zip";
-    sha256 = "0v14xssysy3q1h2mga6rqlz722mwbis4rrx76zmvhjqh17qh4l62";
-  };
-
-  buildInputs = [ unzip ];
-
-  outputs = [ "out" "doc" ];
-
-  installPhase = ''
-    mkdir -p "$out/include"
-    cp -r glm "$out/include"
-
-    mkdir -p "$doc/share/doc/glm"
-    cp -r doc/* "$doc/share/doc/glm"
-  '';
-
-  meta = with stdenv.lib; {
-    description = "OpenGL Mathematics library for C++";
-    longDescription = ''
-      OpenGL Mathematics (GLM) is a header only C++ mathematics library for
-      graphics software based on the OpenGL Shading Language (GLSL)
-      specification and released under the MIT license.
-    '';
-    homepage = http://glm.g-truc.net/;
-    license = licenses.mit;
-    branch = "0.9.5.4";
-    platforms = platforms.unix;
-    maintainers = with stdenv.lib.maintainers; [ fuuzetsu ];
-  };
-}
diff --git a/pkgs/development/libraries/glm/default.nix b/pkgs/development/libraries/glm/default.nix
index 0841990fa95d..319a0359c581 100644
--- a/pkgs/development/libraries/glm/default.nix
+++ b/pkgs/development/libraries/glm/default.nix
@@ -1,23 +1,39 @@
-{ stdenv, fetchurl, unzip }:
+{ stdenv, fetchurl, fetchzip, cmake }:
 
 stdenv.mkDerivation rec {
-  name = "glm-0.9.6.1";
+  version = "0.9.8.5";
+  name = "glm-${version}";
 
-  src = fetchurl {
-    url = "mirror://sourceforge/project/ogl-math/${name}/${name}.zip";
-    sha256 = "1s1kpf9hpyq6bdf87nhlkxyr2ay0ip9wqicdma9h8yz4vs20r2hs";
+  src = fetchzip {
+    url = "https://github.com/g-truc/glm/releases/download/${version}/${name}.zip";
+    sha256 = "0dkfj4hin3am9fxgcvwr5gj0h9y52x7wa03lfwb3q0bvaj1rsly2";
   };
 
-  buildInputs = [ unzip ];
+  nativeBuildInputs = [ cmake ];
 
   outputs = [ "out" "doc" ];
 
-  installPhase = ''
-    mkdir -p "$out/include"
-    cp -r glm "$out/include"
+  cmakeConfigureFlags = [ "-DGLM_INSTALL_ENABLE=off" ];
 
-    mkdir -p "$doc/share/doc/glm"
-    cp -r doc/* "$doc/share/doc/glm"
+  # fetch newer version of platform.h which correctly supports gcc 7.3
+  gcc7PlatformPatch = fetchurl {
+    url = "https://raw.githubusercontent.com/g-truc/glm/384dab02e45a8ad3c1a3fa0906e0d5682c5b27b9/glm/simd/platform.h";
+    sha256 = "0ym0sgwznxhfyi014xs55x3ql7r65fjs34sqb5jiaffkdhkqgzia";
+  };
+
+  postPatch = ''
+    substituteInPlace CMakeLists.txt \
+      --replace '"''${CMAKE_CURRENT_BINARY_DIR}/''${GLM_INSTALL_CONFIGDIR}' '"''${GLM_INSTALL_CONFIGDIR}'
+    cp ${gcc7PlatformPatch} glm/simd/platform.h
+  '';
+
+  NIX_CFLAGS_COMPILE = stdenv.lib.optionals stdenv.isDarwin [
+    "-DGLM_COMPILER=0"
+  ];
+
+  postInstall = ''
+    mkdir -p $doc/share/doc/glm
+    cp -rv $NIX_BUILD_TOP/$sourceRoot/doc/* $doc/share/doc/glm
   '';
 
   meta = with stdenv.lib; {
@@ -33,3 +49,4 @@ stdenv.mkDerivation rec {
     maintainers = with stdenv.lib.maintainers; [ fuuzetsu ];
   };
 }
+
diff --git a/pkgs/development/libraries/globalplatform/default.nix b/pkgs/development/libraries/globalplatform/default.nix
index 5b55a09db625..3ef279616f75 100644
--- a/pkgs/development/libraries/globalplatform/default.nix
+++ b/pkgs/development/libraries/globalplatform/default.nix
@@ -16,6 +16,6 @@ stdenv.mkDerivation rec {
     homepage = https://sourceforge.net/p/globalplatform/wiki/Home/;
     description = "Library for interacting with smart card devices";
     license = licenses.gpl3;
-    platforms = platforms.all;
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/glog/default.nix b/pkgs/development/libraries/glog/default.nix
index 10ef1bbd920f..93e94fc8c42b 100644
--- a/pkgs/development/libraries/glog/default.nix
+++ b/pkgs/development/libraries/glog/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "glog-${version}";
-  version = "0.3.4";
+  version = "0.3.5";
 
   src = fetchFromGitHub {
-    owner = "Google";
+    owner = "google";
     repo = "glog";
     rev = "v${version}";
-    sha256 = "0ym5g15m7c8kjfr2c3zq6bz08ghin2d1r1nb6v2vnkfh1vn945x1";
+    sha256 = "12v7j6xy0ghya6a0f6ciy4fnbdc486vml2g07j9zm8y5xc6vx3pq";
   };
 
   nativeBuildInputs = [ autoreconfHook ];
diff --git a/pkgs/development/libraries/glpk/default.nix b/pkgs/development/libraries/glpk/default.nix
index 4ab61a2d2826..b9634e01900e 100644
--- a/pkgs/development/libraries/glpk/default.nix
+++ b/pkgs/development/libraries/glpk/default.nix
@@ -1,11 +1,11 @@
 { fetchurl, stdenv }:
 
 stdenv.mkDerivation rec {
-  name = "glpk-4.63";
+  name = "glpk-4.65";
 
   src = fetchurl {
     url = "mirror://gnu/glpk/${name}.tar.gz";
-    sha256 = "1xp7nclmp8inp20968bvvfcwmz3mz03sbm0v3yjz8aqwlpqjfkci";
+    sha256 = "040sfaa9jclg2nqdh83w71sv9rc1sznpnfiripjdyr48cady50a2";
   };
 
   doCheck = true;
diff --git a/pkgs/development/libraries/glui/default.nix b/pkgs/development/libraries/glui/default.nix
index 35d97712fa40..59357bf6fb1b 100644
--- a/pkgs/development/libraries/glui/default.nix
+++ b/pkgs/development/libraries/glui/default.nix
@@ -1,7 +1,7 @@
-{stdenv, fetchurl, freeglut, mesa, libXmu, libXext, libX11, libXi}:
+{stdenv, fetchurl, freeglut, libGLU_combined, libXmu, libXext, libX11, libXi}:
 stdenv.mkDerivation {
   name = "glui-2.35";
-  buildInputs = [freeglut mesa libXmu libXext libX11 libXi];
+  buildInputs = [freeglut libGLU_combined libXmu libXext libX11 libXi];
   preConfigure = ''cd src'';
   installPhase = ''
     mkdir -p "$out"/{bin,lib,share/glui/doc,include}
diff --git a/pkgs/development/libraries/gmime/3.nix b/pkgs/development/libraries/gmime/3.nix
index d6877e72a1f9..66d0cf88bd02 100644
--- a/pkgs/development/libraries/gmime/3.nix
+++ b/pkgs/development/libraries/gmime/3.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, pkgconfig, glib, zlib, gpgme, libidn, gobjectIntrospection }:
 
 stdenv.mkDerivation rec {
-  version = "3.0.1";
+  version = "3.0.5";
   name = "gmime-${version}";
 
   src = fetchurl {
     url = "mirror://gnome/sources/gmime/3.0/${name}.tar.xz";
-    sha256 = "001y93b8mq9alzkvli6vfh3pzdcn5c5iy206ml23lzhhhvm5k162";
+    sha256 = "1q45gd1ahnz9q1milc2lqqwl7j3q0wd6kiswhp25iak222n56lrg";
   };
 
   outputs = [ "out" "dev" ];
diff --git a/pkgs/development/libraries/gmp/6.x.nix b/pkgs/development/libraries/gmp/6.x.nix
index e3bacc86d58e..5973c89cef79 100644
--- a/pkgs/development/libraries/gmp/6.x.nix
+++ b/pkgs/development/libraries/gmp/6.x.nix
@@ -1,6 +1,5 @@
 { stdenv, fetchurl, m4, cxx ? true
 , buildPackages
-, buildPlatform, hostPlatform
 , withStatic ? false }:
 
 let inherit (stdenv.lib) optional optionalString; in
@@ -19,8 +18,8 @@ let self = stdenv.mkDerivation rec {
   outputs = [ "out" "dev" "info" ];
   passthru.static = self.out;
 
-  nativeBuildInputs = [ m4 ]
-    ++ stdenv.lib.optional (buildPlatform != hostPlatform) buildPackages.stdenv.cc;
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
+  nativeBuildInputs = [ m4 ];
 
   configureFlags =
     # Build a "fat binary", with routines for several sub-architectures
@@ -43,7 +42,7 @@ let self = stdenv.mkDerivation rec {
       configureFlagsArray+=("--build=$(./configfsf.guess)")
     '';
 
-  doCheck = buildPlatform == hostPlatform;
+  doCheck = true; # not cross;
 
   dontDisableStatic = withStatic;
 
diff --git a/pkgs/development/libraries/gmtk/default.nix b/pkgs/development/libraries/gmtk/default.nix
new file mode 100644
index 000000000000..0fac97aaa439
--- /dev/null
+++ b/pkgs/development/libraries/gmtk/default.nix
@@ -0,0 +1,32 @@
+{stdenv, substituteAll, fetchFromGitHub, libtool, pkgconfig, intltool, glib, gtk3
+, libpulseaudio, mplayer, gnome_mplayer }:
+
+stdenv.mkDerivation rec {
+  name = "gmtk-${version}";
+  version = "1.0.9";
+
+  src = fetchFromGitHub {
+    owner = "kdekorte";
+    repo = "gmtk";
+    rev = "v${version}";
+    sha256 = "1zb5m1y1gckal3140gvx31572a6xpccwfmdwa1w5lx2wdq1pwk1i";
+  };
+
+  nativeBuildInputs = [ libtool pkgconfig intltool ];
+  buildInputs = [ glib gtk3 libpulseaudio ];
+
+  patches = [
+    (substituteAll {
+      src = ./fix-paths.patch;
+      mplayer = "${mplayer}/bin/mplayer";
+    })
+  ];
+
+  meta = with stdenv.lib; {
+    description = "Common functions for gnome-mplayer and gecko-mediaplayer";
+    homepage = https://sites.google.com/site/kdekorte2/gnomemplayer;
+    license = licenses.gpl2;
+    maintainers = gnome_mplayer.meta.maintainers;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/gmtk/fix-paths.patch b/pkgs/development/libraries/gmtk/fix-paths.patch
new file mode 100644
index 000000000000..64738300aba4
--- /dev/null
+++ b/pkgs/development/libraries/gmtk/fix-paths.patch
@@ -0,0 +1,20 @@
+--- a/src/gmtk_media_player.c
++++ b/src/gmtk_media_player.c
+@@ -2449,7 +2449,7 @@
+         player->minimum_mplayer = detect_mplayer_features(player);
+ 
+         if (player->mplayer_binary == NULL || !g_file_test(player->mplayer_binary, G_FILE_TEST_EXISTS)) {
+-            argv[argn++] = g_strdup_printf("mplayer");
++            argv[argn++] = g_strdup_printf("@mplayer@");
+         } else {
+             argv[argn++] = g_strdup_printf("%s", player->mplayer_binary);
+         }
+@@ -4135,7 +4135,7 @@
+         return ret;
+ 
+     if (player->mplayer_binary == NULL || !g_file_test(player->mplayer_binary, G_FILE_TEST_EXISTS)) {
+-        av[ac++] = g_strdup_printf("mplayer");
++        av[ac++] = g_strdup_printf("@mplayer@");
+     } else {
+         av[ac++] = g_strdup_printf("%s", player->mplayer_binary);
+     }
diff --git a/pkgs/development/libraries/gnu-efi/default.nix b/pkgs/development/libraries/gnu-efi/default.nix
index 6691928c021e..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 ];
@@ -15,13 +15,14 @@ stdenv.mkDerivation rec {
 
   makeFlags = [
     "PREFIX=\${out}"
-    "CC=gcc"
-    "AS=as"
-    "LD=ld"
-    "AR=ar"
-    "RANLIB=ranlib"
-    "OBJCOPY=objcopy"
-  ] ++ stdenv.lib.optional stdenv.isArm "ARCH=arm";
+    "CC=${stdenv.cc.targetPrefix}gcc"
+    "AS=${stdenv.cc.targetPrefix}as"
+    "LD=${stdenv.cc.targetPrefix}ld"
+    "AR=${stdenv.cc.targetPrefix}ar"
+    "RANLIB=${stdenv.cc.targetPrefix}ranlib"
+    "OBJCOPY=${stdenv.cc.targetPrefix}objcopy"
+  ] ++ stdenv.lib.optional stdenv.isArm "ARCH=arm"
+    ++ stdenv.lib.optional stdenv.isAarch64 "ARCH=aarch64";
 
   meta = with stdenv.lib; {
     description = "GNU EFI development toolchain";
diff --git a/pkgs/development/libraries/gnutls-kdh/generic.nix b/pkgs/development/libraries/gnutls-kdh/generic.nix
index 0e8457a8c54b..472ec83fb02c 100644
--- a/pkgs/development/libraries/gnutls-kdh/generic.nix
+++ b/pkgs/development/libraries/gnutls-kdh/generic.nix
@@ -1,5 +1,5 @@
 { lib, fetchurl, stdenv, zlib, lzo, libtasn1, nettle, pkgconfig, lzip
-, guileBindings, guile, perl, gmp, autogen, libidn, p11_kit, unbound, libiconv
+, guileBindings, guile, perl, gmp, autogen, libidn, p11-kit, unbound, libiconv
 , tpmSupport ? true, trousers, nettools, bash, gperftools, gperf, gettext, automake
 , yacc, texinfo
 
@@ -52,7 +52,7 @@ stdenv.mkDerivation {
   # systemkey-args.h.
   enableParallelBuilding = false;
 
-  buildInputs = [ lzo lzip nettle libtasn1 libidn p11_kit zlib gmp
+  buildInputs = [ lzo lzip nettle libtasn1 libidn p11-kit zlib gmp
   autogen gperftools gperf gettext automake yacc texinfo ]
     ++ lib.optional doCheck nettools
     ++ lib.optional (stdenv.isFreeBSD || stdenv.isDarwin) libiconv
@@ -84,7 +84,7 @@ stdenv.mkDerivation {
        layer. It adds TLS-KDH ciphers: Kerberos + Diffie-Hellman.
     '';
 
-    homepage = http://www.gnu.org/software/gnutls://github.com/arpa2/gnutls-kdh;
+    homepage = https://github.com/arpa2/gnutls-kdh;
     license = licenses.lgpl21Plus;
     maintainers = with maintainers; [ leenaars ];
     platforms = platforms.all;
diff --git a/pkgs/development/libraries/gnutls/3.5.10.nix b/pkgs/development/libraries/gnutls/3.5.10.nix
index a1eab1a84c11..a44e2b04ed71 100644
--- a/pkgs/development/libraries/gnutls/3.5.10.nix
+++ b/pkgs/development/libraries/gnutls/3.5.10.nix
@@ -4,7 +4,7 @@ callPackage ./generic.nix (args // rec {
   version = "3.5.10";
 
   src = fetchurl {
-    url = "ftp://ftp.gnutls.org/gcrypt/gnutls/v3.5/gnutls-${version}.tar.xz";
+    url = "mirror://gnupg/gnutls/v3.5/gnutls-${version}.tar.xz";
     sha256 = "17apwvdkkazh5w8z8mbanpj2yj8s2002qwy46wz4v3akpa33wi5g";
   };
 })
diff --git a/pkgs/development/libraries/gnutls/3.5.nix b/pkgs/development/libraries/gnutls/3.6.nix
index 55c917f212e9..7fb1af70a289 100644
--- a/pkgs/development/libraries/gnutls/3.5.nix
+++ b/pkgs/development/libraries/gnutls/3.6.nix
@@ -1,18 +1,20 @@
 { callPackage, fetchurl, ... } @ args:
 
 callPackage ./generic.nix (args // rec {
-  version = "3.5.15";
+  version = "3.6.2";
 
   src = fetchurl {
-    url = "ftp://ftp.gnutls.org/gcrypt/gnutls/v3.5/gnutls-${version}.tar.xz";
-    sha256 = "1mgsxkbs44csw07ngwbqns2y2s03m975lk1sl5ay87wbic882q04";
+    url = "mirror://gnupg/gnutls/v3.6/gnutls-${version}.tar.xz";
+    sha256 = "07wdffklwmxpa9i50sh5nwrc5ajb47skrldm6rzjc0jf4dxxpmdw";
   };
 
   # Skip two tests introduced in 3.5.11.  Probable reasons of failure:
   #  - pkgconfig: building against the result won't work before installing
   #  - trust-store: default trust store path (/etc/ssl/...) is missing in sandbox
+  # Change p11-kit test to use pkg-config to find p11-kit
   postPatch = ''
     sed '2iexit 77' -i tests/pkgconfig.sh
     sed '/^void doit(void)/,$s/{/{ exit(77);/; t' -i tests/trust-store.c
+    sed 's:/usr/lib64/pkcs11/ /usr/lib/pkcs11/ /usr/lib/x86_64-linux-gnu/pkcs11/:`pkg-config --variable=p11_module_path p11-kit-1`:' -i tests/p11-kit-trust.sh
   '';
 })
diff --git a/pkgs/development/libraries/gnutls/generic.nix b/pkgs/development/libraries/gnutls/generic.nix
index d2947cd7c6b5..984603827c8d 100644
--- a/pkgs/development/libraries/gnutls/generic.nix
+++ b/pkgs/development/libraries/gnutls/generic.nix
@@ -1,5 +1,5 @@
 { lib, fetchurl, stdenv, zlib, lzo, libtasn1, nettle, pkgconfig, lzip
-, guileBindings, guile, perl, gmp, autogen, libidn, p11_kit, libiconv
+, guileBindings, guile, perl, gmp, autogen, libidn, p11-kit, libiconv
 , tpmSupport ? false, trousers, which, nettools, libunistring
 , unbound, dns-root-data, gettext
 
@@ -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/absolute_gir_path.patch b/pkgs/development/libraries/gobject-introspection/absolute_gir_path.patch
new file mode 100644
index 000000000000..f7e1bedd3e18
--- /dev/null
+++ b/pkgs/development/libraries/gobject-introspection/absolute_gir_path.patch
@@ -0,0 +1,11 @@
+--- a/gir/cairo-1.0.gir.in
++++ b/gir/cairo-1.0.gir.in
+@@ -5,7 +5,7 @@
+             xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
+   <package name="%CAIRO_GIR_PACKAGE%"/>
+   <namespace name="cairo" version="1.0"
+-	     shared-library="%CAIRO_SHARED_LIBRARY%"
++	     shared-library="@cairoLib@/%CAIRO_SHARED_LIBRARY%"
+ 	     c:identifier-prefixes="cairo"
+ 	     c:symbol-prefixes="cairo">
+     <record name="Context" c:type="cairo_t" foreign="1"
diff --git a/pkgs/development/libraries/gobject-introspection/absolute_shlib_path.patch b/pkgs/development/libraries/gobject-introspection/absolute_shlib_path.patch
index 75d9281dfb0e..6a112aedcc05 100644
--- a/pkgs/development/libraries/gobject-introspection/absolute_shlib_path.patch
+++ b/pkgs/development/libraries/gobject-introspection/absolute_shlib_path.patch
@@ -1,8 +1,6 @@
-diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
-index 89ec193..54f1d2e 100755
 --- a/giscanner/scannermain.py
 +++ b/giscanner/scannermain.py
-@@ -94,6 +94,39 @@ def get_windows_option_group(parser):
+@@ -100,6 +100,39 @@
      return group
  
  
@@ -42,7 +40,7 @@ index 89ec193..54f1d2e 100755
  def _get_option_parser():
      parser = optparse.OptionParser('%prog [options] sources')
      parser.add_option('', "--quiet",
-@@ -200,6 +233,10 @@ match the namespace prefix.""")
+@@ -209,6 +242,10 @@
      parser.add_option("", "--filelist",
                        action="store", dest="filelist", default=[],
                        help="file containing headers and sources to be scanned")
@@ -53,57 +51,50 @@ index 89ec193..54f1d2e 100755
  
      group = get_preprocessor_option_group(parser)
      parser.add_option_group(group)
-diff --git a/giscanner/shlibs.py b/giscanner/shlibs.py
-index 838d343..ca7fc0d 100644
 --- a/giscanner/shlibs.py
 +++ b/giscanner/shlibs.py
-@@ -53,10 +53,27 @@ def _resolve_libtool(options, binary, libraries):
- # Match absolute paths on OS X to conform to how libraries are usually
- # referenced on OS X systems.
- def _ldd_library_pattern(library_name):
-+    nix_store_dir = re.escape('@nixStoreDir@'.rstrip('/'))
-     pattern = "(?<![A-Za-z0-9_-])(lib*%s[^A-Za-z0-9_-][^\s\(\)]*)"
-     if platform.system() == 'Darwin':
+@@ -63,6 +63,11 @@
          pattern = "([^\s]*lib*%s[^A-Za-z0-9_-][^\s\(\)]*)"
--    return re.compile(pattern % re.escape(library_name))
-+        return re.compile(pattern % re.escape(library_name))
-+    pattern = r'''
-+        (
-+          (?:
-+            # First match Nix store paths because they need to be absolute.
-+            (?:%s(?:/[^/]*)+)
-+            # Everything else not a store path remains relative, because we
-+            # would end up with temporary paths that are only valid during
-+            # build time in the resulting GIR file.
-+            | (?<=/)
-+          )
-+          # And finally the library itself:
-+          (?:lib%s[^A-Za-z0-9_-][^\s\(\)]*)
-+        )
-+    '''
-+    return re.compile(pattern % (nix_store_dir, re.escape(library_name)),
-+                      re.VERBOSE)
+     return re.compile(pattern % re.escape(library_name))
  
++def _ldd_library_nix_pattern(library_name):
++    nix_store_dir = re.escape('@nixStoreDir@'.rstrip('/'))
++    pattern = r'(%s(?:/[^/]*)+lib%s[^A-Za-z0-9_-][^\s\(\)]*)'
++    return re.compile(pattern % (nix_store_dir, re.escape(library_name)))
++
  
  # This is a what we do for non-la files. We assume that we are on an
-@@ -115,7 +132,11 @@ def _resolve_non_libtool(options, binary, libraries):
-                 m = pattern.search(line)
+ # ELF-like system where ldd exists and the soname extracted with ldd is
+@@ -112,7 +117,7 @@
+         proc = subprocess.Popen(args, stdout=subprocess.PIPE)
+         patterns = {}
+         for library in libraries:
+-            patterns[library] = _ldd_library_pattern(library)
++            patterns[library] = (_ldd_library_pattern(library), _ldd_library_nix_pattern(library))
+ 
+         shlibs = []
+         for line in proc.stdout:
+@@ -122,11 +127,14 @@
+             # possible for the name of the binary to match _ldd_library_pattern.
+             if line == binary.args[0] + ':\n':
+                 continue
+-            for library, pattern in patterns.items():
+-                m = pattern.search(line)
++            for library, (pattern, nix_pattern) in patterns.items():
++                if line.find('@nixStoreDir@') != -1:
++                    m = nix_pattern.search(line)
++                else:
++                    m = pattern.search(line)
                  if m:
                      del patterns[library]
 -                    shlibs.append(m.group(1))
-+                    match = m.group(1)
-+                    if not match.startswith('/') \
-+                       and len(options.fallback_libpath) > 0:
-+                        match = os.path.join(options.fallback_libpath, match)
-+                    shlibs.append(match)
++                    shlibs.append(os.path.join(options.fallback_libpath, m.group(1)))
                      break
  
          if len(patterns) > 0:
-diff --git a/giscanner/utils.py b/giscanner/utils.py
-index 660081e..c9c767a 100644
 --- a/giscanner/utils.py
 +++ b/giscanner/utils.py
-@@ -109,17 +109,11 @@ def extract_libtool_shlib(la_file):
+@@ -113,17 +113,11 @@
      if dlname is None:
          return None
  
diff --git a/pkgs/development/libraries/gobject-introspection/default.nix b/pkgs/development/libraries/gobject-introspection/default.nix
index f629b9a8a3c3..f79511897fbe 100644
--- a/pkgs/development/libraries/gobject-introspection/default.nix
+++ b/pkgs/development/libraries/gobject-introspection/default.nix
@@ -1,31 +1,31 @@
 { stdenv, fetchurl, glib, flex, bison, pkgconfig, libffi, python
-, libintlOrEmpty, cctools
+, libintl, cctools, cairo, gnome3
 , substituteAll, nixStoreDir ? builtins.storeDir
+, x11Support ? true
 }:
 # now that gobjectIntrospection creates large .gir files (eg gtk3 case)
 # it may be worth thinking about using multiple derivation outputs
 # In that case its about 6MB which could be separated
 
 let
-  ver_maj = "1.54";
-  ver_min = "1";
+  pname = "gobject-introspection";
+  version = "1.56.0";
 in
 with stdenv.lib;
 stdenv.mkDerivation rec {
-  name = "gobject-introspection-${ver_maj}.${ver_min}";
+  name = "${pname}-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/gobject-introspection/${ver_maj}/${name}.tar.xz";
-    sha256 = "0zl7pfkzkm07733391b4f3cwjbnvb1nwvpmajf5bajh6bxgfv3dq";
+    url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
+    sha256 = "1y50pbn5qqbcv2h9rkz96wvv5jls2gma9bkqjq6wapmaszx5jw0d";
   };
 
   outputs = [ "out" "dev" ];
   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 ];
 
@@ -38,10 +38,23 @@ stdenv.mkDerivation rec {
 
   setupHook = ./setup-hook.sh;
 
-  patches = stdenv.lib.singleton (substituteAll {
-    src = ./absolute_shlib_path.patch;
-    inherit nixStoreDir;
-  });
+  patches = [
+    (substituteAll {
+      src = ./absolute_shlib_path.patch;
+      inherit nixStoreDir;
+    })
+  ] ++ stdenv.lib.optional x11Support # https://github.com/NixOS/nixpkgs/issues/34080
+    (substituteAll {
+      src = ./absolute_gir_path.patch;
+      cairoLib = "${getLib cairo}/lib";
+    });
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+      attrPath = "gobjectIntrospection";
+    };
+  };
 
   meta = with stdenv.lib; {
     description = "A middleware layer between C libraries and language bindings";
diff --git a/pkgs/development/libraries/gobject-introspection/setup-hook.sh b/pkgs/development/libraries/gobject-introspection/setup-hook.sh
index 583d8475ec3b..a79ce05a38df 100644
--- a/pkgs/development/libraries/gobject-introspection/setup-hook.sh
+++ b/pkgs/development/libraries/gobject-introspection/setup-hook.sh
@@ -1,5 +1,4 @@
 make_gobject_introspection_find_gir_files() {
-
     # required for .typelib files, eg mypaint git version
     if [ -d "$1/lib/girepository-1.0" ]; then
       addToSearchPath GI_TYPELIB_PATH $1/lib/girepository-1.0
@@ -11,11 +10,18 @@ make_gobject_introspection_find_gir_files() {
     fi
 }
 
-envHooks+=(make_gobject_introspection_find_gir_files)
+addEnvHooks "$hostOffset" make_gobject_introspection_find_gir_files
+
+giDiscoverSelf() {
+    if [ -d "$prefix/lib/girepository-1.0" ]; then
+      addToSearchPath GI_TYPELIB_PATH $prefix/lib/girepository-1.0
+    fi
+}
+
+preFixupHooks+=(giDiscoverSelf)
 
 _multioutMoveGlibGir() {
   moveToOutput share/gir-1.0 "${!outputDev}"
 }
 
 preFixupHooks+=(_multioutMoveGlibGir)
-
diff --git a/pkgs/development/libraries/godot_headers/default.nix b/pkgs/development/libraries/godot_headers/default.nix
new file mode 100644
index 000000000000..940882b1742d
--- /dev/null
+++ b/pkgs/development/libraries/godot_headers/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchFromGitHub }:
+stdenv.mkDerivation rec {
+  name = "godot_headers";
+  version = "2018-02-09";
+  src = fetchFromGitHub {
+    owner = "GodotNativeTools";
+    repo = "godot_headers";
+    rev = "51bca3bf5d917341f3e15076c5a9191f8a5118ae";
+    sha256 = "0z562pqm8y8wldmfiya72cvwwpvcfznpl0wypagw50v0f41ilywh";
+  };
+  buildPhase = "true";
+  installPhase = ''
+    mkdir $out
+    cp -r . $out/include
+  '';
+  meta = {
+    homepage = "https://github.com/GodotNativeTools/godot_headers/";
+    description = "Headers for the Godot API supplied by the GDNative module";
+    license = stdenv.lib.licenses.mit;
+    platforms = stdenv.lib.platforms.all;
+    maintainers = [ stdenv.lib.maintainers.twey ];
+  };
+}
diff --git a/pkgs/development/libraries/goffice/default.nix b/pkgs/development/libraries/goffice/default.nix
index 7971448133ea..6cdd19f307df 100644
--- a/pkgs/development/libraries/goffice/default.nix
+++ b/pkgs/development/libraries/goffice/default.nix
@@ -2,11 +2,11 @@
 , libgsf, libxml2, libxslt, cairo, pango, librsvg, libspectre }:
 
 stdenv.mkDerivation rec {
-  name = "goffice-0.10.35";
+  name = "goffice-0.10.39";
 
   src = fetchurl {
     url = "mirror://gnome/sources/goffice/0.10/${name}.tar.xz";
-    sha256 = "c19001afca09dc5446e06605a113d81a57124018a09c5889aeebba16cf1d5738";
+    sha256 = "73f23fbf05f3fa98343208b751db04b31a7ff743c2d828e1a0a130c566f1bc4f";
   };
 
   nativeBuildInputs = [ pkgconfig intltool ];
diff --git a/pkgs/development/libraries/goocanvas/2.x.nix b/pkgs/development/libraries/goocanvas/2.x.nix
new file mode 100644
index 000000000000..026f58079f6d
--- /dev/null
+++ b/pkgs/development/libraries/goocanvas/2.x.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl, pkgconfig, gettext, gtk-doc, gobjectIntrospection, python2, gtk3, cairo, glib }:
+
+let
+  version = "2.0.4";
+in stdenv.mkDerivation rec {
+  name = "goocanvas-${version}";
+
+  outputs = [ "out" "dev" "devdoc" ];
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/goocanvas/2.0/${name}.tar.xz";
+    sha256 = "141fm7mbqib0011zmkv3g8vxcjwa7hypmq71ahdyhnj2sjvy4a67";
+  };
+
+  nativeBuildInputs = [ pkgconfig gettext gtk-doc python2 ];
+  buildInputs = [ gtk3 cairo glib ];
+
+  configureFlags = [
+    "--disable-python"
+  ];
+
+  meta = with stdenv.lib; {
+    description = "Canvas widget for GTK+ based on the the Cairo 2D library";
+    homepage = https://wiki.gnome.org/Projects/GooCanvas;
+    license = licenses.lgpl2;
+    maintainers = with maintainers; [ ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/google-gflags/default.nix b/pkgs/development/libraries/google-gflags/default.nix
index 1a3a16587274..dbcb0342156b 100644
--- a/pkgs/development/libraries/google-gflags/default.nix
+++ b/pkgs/development/libraries/google-gflags/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "google-gflags-${version}";
-  version = "2.2.0";
+  version = "2.2.1";
 
   src = fetchFromGitHub {
     owner = "gflags";
     repo = "gflags";
     rev = "v${version}";
-    sha256 = "1y5808ky8qhjwv1nf134czz0h2p2faqvjhxa9zxf8mg8hn4ns9wp";
+    sha256 = "12wkihc4f07qmhyqk3cjylj8v5xz2bjrq75p7aq1vvvj60fbp58k";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/gpgme/default.nix b/pkgs/development/libraries/gpgme/default.nix
index 9773ef8b896e..94c09b716832 100644
--- a/pkgs/development/libraries/gpgme/default.nix
+++ b/pkgs/development/libraries/gpgme/default.nix
@@ -1,24 +1,23 @@
 { stdenv, fetchurl, fetchpatch, libgpgerror, gnupg, pkgconfig, glib, pth, libassuan
-, qtbase ? null }:
+, file, which
+, autoreconfHook
+, git
+, texinfo5
+, qtbase ? null
+, withPython ? false, swig2 ? null, python ? null
+}:
 
 let inherit (stdenv) lib system; in
 
 stdenv.mkDerivation rec {
-  name = "gpgme-1.9.0";
+  name = "gpgme-${version}";
+  version = "1.11.1";
 
   src = fetchurl {
     url = "mirror://gnupg/gpgme/${name}.tar.bz2";
-    sha256 = "1ssc0gs02r4fasabk7c6v6r865k2j02mpb5g1vkpbmzsigdzwa8v";
+    sha256 = "0vxx5xaag3rhp4g2arp5qm77gvz4kj0m3hnpvhkdvqyjfhbi26rd";
   };
 
-  patches = [
-    (fetchpatch {
-      url = "https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gpgme.git;a=commitdiff_plain;h=5d4f977dac542340c877fdd4b1304fa8f6e058e6";
-      sha256 = "0swpxzd3x3b6h2ry2py9j8l0xp3vdw8rixxhgfavzia5p869qyyx";
-      name = "qgpgme-format-security.patch";
-    })
-  ];
-
   outputs = [ "out" "dev" "info" ];
   outputBin = "dev"; # gpgme-config; not so sure about gpgme-tool
 
@@ -26,11 +25,17 @@ stdenv.mkDerivation rec {
     [ libgpgerror glib libassuan pth ]
     ++ lib.optional (qtbase != null) qtbase;
 
-  nativeBuildInputs = [ pkgconfig gnupg ];
+  nativeBuildInputs = [ file pkgconfig gnupg autoreconfHook git texinfo5 ]
+  ++ lib.optionals withPython [ python swig2 which ];
+
+  postPatch =''
+    substituteInPlace ./configure --replace /usr/bin/file ${file}/bin/file
+  '';
 
   configureFlags = [
     "--enable-fixed-path=${gnupg}/bin"
-  ];
+    "--with-libgpg-error-prefix=${libgpgerror.dev}"
+  ] ++ lib.optional withPython "--enable-languages=python";
 
   NIX_CFLAGS_COMPILE =
     # qgpgme uses Q_ASSERT which retains build inputs at runtime unless
diff --git a/pkgs/development/libraries/granite/default.nix b/pkgs/development/libraries/granite/default.nix
index be869063111c..8243775c6bc1 100644
--- a/pkgs/development/libraries/granite/default.nix
+++ b/pkgs/development/libraries/granite/default.nix
@@ -1,22 +1,42 @@
-{ stdenv, fetchurl, perl, cmake, vala, pkgconfig, gobjectIntrospection, glib, gtk3, gnome3, gettext }:
+{ stdenv, fetchFromGitHub, perl, cmake, ninja, vala, pkgconfig, gobjectIntrospection, glib, gtk3, gnome3, gettext }:
 
 stdenv.mkDerivation rec {
-  majorVersion = "0.4";
-  minorVersion = "0.1";
-  name = "granite-${majorVersion}.${minorVersion}";
-  src = fetchurl {
-    url = "https://launchpad.net/granite/${majorVersion}/${majorVersion}.${minorVersion}/+download/${name}.tar.xz";
-    sha256 = "1pf4jkz3xyn1sqv70063im80ayb5kdsqwqwx11dc7vgypsl458cm";
+  name = "granite-${version}";
+  version = "0.5";
+
+  src = fetchFromGitHub {
+    owner = "elementary";
+    repo = "granite";
+    rev = version;
+    sha256 = "15l8z1jkqhvappnr8jww27lfy3dwqybgsxk5iccyvnvzpjdh2s0h";
   };
-  cmakeFlags = "-DINTROSPECTION_GIRDIR=share/gir-1.0/ -DINTROSPECTION_TYPELIBDIR=lib/girepository-1.0";
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [perl cmake vala gobjectIntrospection glib gtk3 gnome3.libgee gettext];
-  meta = {
+
+  cmakeFlags = [
+    "-DINTROSPECTION_GIRDIR=share/gir-1.0/"
+    "-DINTROSPECTION_TYPELIBDIR=lib/girepository-1.0"
+  ];
+
+  nativeBuildInputs = [
+    vala
+    pkgconfig
+    cmake
+    ninja
+    perl
+    gettext
+    gobjectIntrospection
+  ];
+  buildInputs = [
+    glib
+    gtk3
+    gnome3.libgee
+  ];
+
+  meta = with stdenv.lib; {
     description = "An extension to GTK+ used by elementary OS";
     longDescription = "An extension to GTK+ that provides several useful widgets and classes to ease application development. Designed for elementary OS.";
-    homepage = https://launchpad.net/granite;
-    license = stdenv.lib.licenses.lgpl3;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.vozz ];
+    homepage = https://github.com/elementary/granite;
+    license = licenses.lgpl3;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.vozz ];
   };
 }
diff --git a/pkgs/development/libraries/grantlee/5/setup-hook.sh b/pkgs/development/libraries/grantlee/5/setup-hook.sh
index d11ef5883a1f..b51cb4a31909 100644
--- a/pkgs/development/libraries/grantlee/5/setup-hook.sh
+++ b/pkgs/development/libraries/grantlee/5/setup-hook.sh
@@ -4,20 +4,10 @@ providesGrantleeRuntime() {
     [ -d "$1/$grantleePluginPrefix" ]
 }
 
-_grantleeCrossEnvHook() {
-    if providesQtRuntime "$1"; then
-        propagatedBuildInputs+=" $1"
-        propagatedUserEnvPkgs+=" $1"
-    fi
-}
-crossEnvHooks+=(_grantleeCrossEnvHook)
-
 _grantleeEnvHook() {
     if providesGrantleeRuntime "$1"; then
-        propagatedNativeBuildInputs+=" $1"
-        if [ -z "$crossConfig" ]; then
+        propagatedBuildInputs+=" $1"
         propagatedUserEnvPkgs+=" $1"
-        fi
     fi
 }
-envHooks+=(_grantleeEnvHook)
+addEnvHooks "$hostOffset" _grantleeEnvHook
diff --git a/pkgs/development/libraries/grib-api/default.nix b/pkgs/development/libraries/grib-api/default.nix
index f091fedeb2de..61409279ded7 100644
--- a/pkgs/development/libraries/grib-api/default.nix
+++ b/pkgs/development/libraries/grib-api/default.nix
@@ -4,11 +4,11 @@
 
 stdenv.mkDerivation rec{
   name = "grib-api-${version}";
-  version = "1.19.0";
+  version = "1.26.0";
 
   src = fetchurl {
     url = "https://software.ecmwf.int/wiki/download/attachments/3473437/grib_api-${version}-Source.tar.gz";
-    sha256 = "07cj9mw5bb249lxx1m9nmfdqb8b2a8cm7s6x62cdwca3sp16dv6a";
+    sha256 = "00cmmj44bhdlzhqbvwb3bb4xks3bpva669m6g3g6ffjaqm25b90c";
   };
 
   preConfigure = ''
diff --git a/pkgs/development/libraries/grpc/default.nix b/pkgs/development/libraries/grpc/default.nix
new file mode 100644
index 000000000000..9f9166e43c9f
--- /dev/null
+++ b/pkgs/development/libraries/grpc/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchurl, cmake, zlib, c-ares, pkgconfig, openssl, protobuf, gflags }:
+
+stdenv.mkDerivation rec {
+  version = "1.10.0";
+  name = "grpc-${version}";
+  src = fetchurl {
+    url = "https://github.com/grpc/grpc/archive/v${version}.tar.gz";
+    sha256 = "0wngrb44bpryrvrnx5y1ncrhi2097qla929wqjwvs0razbk3v9rr";
+  };
+  nativeBuildInputs = [ cmake pkgconfig ];
+  buildInputs = [ zlib c-ares c-ares.cmake-config openssl protobuf gflags ];
+  cmakeFlags =
+    [ "-DgRPC_ZLIB_PROVIDER=package"
+      "-DgRPC_CARES_PROVIDER=package"
+      "-DgRPC_SSL_PROVIDER=package"
+      "-DgRPC_PROTOBUF_PROVIDER=package"
+      "-DgRPC_GFLAGS_PROVIDER=package"
+    ];
+  enableParallelBuilds = true;
+
+  meta = with stdenv.lib; {
+    description = "The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#)";
+    license = licenses.asl20;
+    homepage = https://grpc.io/;
+  };
+}
diff --git a/pkgs/development/libraries/gsettings-qt/default.nix b/pkgs/development/libraries/gsettings-qt/default.nix
new file mode 100644
index 000000000000..9e893932a64c
--- /dev/null
+++ b/pkgs/development/libraries/gsettings-qt/default.nix
@@ -0,0 +1,58 @@
+{ stdenv, fetchbzr, pkgconfig, qmake, qtbase, qtdeclarative, glib, gobjectIntrospection }:
+
+stdenv.mkDerivation rec {
+  name = "gsettings-qt-${version}";
+  version = "0.1.20170824";
+
+  src = fetchbzr {
+    url = http://bazaar.launchpad.net/~system-settings-touch/gsettings-qt/trunk;
+    rev = "85";
+    sha256 = "1kcw0fgdyndx9c0dyha11wkj0gi05spdc1adf1609mrinbb4rnyi";
+  };
+
+  nativeBuildInputs = [
+    pkgconfig
+    qmake
+    gobjectIntrospection
+  ];
+
+  buildInputs = [
+    glib
+    qtdeclarative
+  ];
+
+  patchPhase = ''
+    # force ordered build of subdirs
+    sed -i -e "\$aCONFIG += ordered" gsettings-qt.pro
+
+    # It seems that there is a bug in qtdeclarative: qmlplugindump fails
+    # because it can not find or load the Qt platform plugin "minimal".
+    # A workaround is to set QT_PLUGIN_PATH and QML2_IMPORT_PATH explicitly.
+    export QT_PLUGIN_PATH=${qtbase.bin}/${qtbase.qtPluginPrefix}
+    export QML2_IMPORT_PATH=${qtdeclarative.bin}/${qtbase.qtQmlPrefix}
+
+    substituteInPlace GSettings/gsettings-qt.pro \
+      --replace '$$[QT_INSTALL_QML]' "$out/$qtQmlPrefix" \
+      --replace '$$[QT_INSTALL_BINS]/qmlplugindump' "qmlplugindump"
+
+    substituteInPlace src/gsettings-qt.pro \
+      --replace '$$[QT_INSTALL_LIBS]' "$out/lib" \
+      --replace '$$[QT_INSTALL_HEADERS]' "$out/include"
+  '';
+
+  preInstall = ''
+    # do not install tests
+    for f in tests/Makefile{,.cpptest}; do
+      substituteInPlace $f \
+        --replace "install: install_target" "install: "
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Qt/QML bindings for GSettings";
+    homepage = https://launchpad.net/gsettings-qt;
+    license = licenses.lgpl3;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.romildo ];
+  };
+}
diff --git a/pkgs/development/libraries/gsl/default.nix b/pkgs/development/libraries/gsl/default.nix
index afd6391d719b..f1eed726eb2b 100644
--- a/pkgs/development/libraries/gsl/default.nix
+++ b/pkgs/development/libraries/gsl/default.nix
@@ -13,7 +13,8 @@ stdenv.mkDerivation rec {
     ./disable-fma.patch # http://lists.gnu.org/archive/html/bug-gsl/2011-11/msg00019.html
   ];
 
-  doCheck = stdenv.system != "i686-linux"; # https://lists.gnu.org/archive/html/bug-gsl/2015-11/msg00012.html
+  # https://lists.gnu.org/archive/html/bug-gsl/2015-11/msg00012.html
+  doCheck = stdenv.system != "i686-linux" && stdenv.system != "aarch64-linux";
 
   meta = {
     description = "The GNU Scientific Library, a large numerical library";
diff --git a/pkgs/development/libraries/gsm/default.nix b/pkgs/development/libraries/gsm/default.nix
index 42d36b8406e2..57112e2825ee 100644
--- a/pkgs/development/libraries/gsm/default.nix
+++ b/pkgs/development/libraries/gsm/default.nix
@@ -9,11 +9,11 @@ in
 
 stdenv.mkDerivation rec {
   name = "gsm-${version}";
-  version = "1.0.14";
+  version = "1.0.17";
 
   src = fetchurl {
     url = "http://www.quut.com/gsm/${name}.tar.gz";
-    sha256 = "0b1mx69jq88wva3wk0hi6fcl5a52qhnq2f9p3f3jdh5k61ma252q";
+    sha256 = "00bns0d4wwrvc60lj2w7wz4yk49q1f6rpdrwqzrxsha9d78mfnl5";
   };
 
   patchPhase = ''
diff --git a/pkgs/development/libraries/gssdp/default.nix b/pkgs/development/libraries/gssdp/default.nix
index 55e20065732c..d48ba9082af2 100644
--- a/pkgs/development/libraries/gssdp/default.nix
+++ b/pkgs/development/libraries/gssdp/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "gssdp-${version}";
-  version = "1.0.1";
+  version = "1.0.2";
 
   src = fetchurl {
     url = "mirror://gnome/sources/gssdp/1.0/${name}.tar.xz";
-    sha256 = "1qfj4gir1qf6v86z70ryzmjb75ns30q6zi5p89vhd3621gs6f7b0";
+    sha256 = "1p1m2m3ndzr2whipqw4vfb6s6ia0g7rnzzc4pnq8b8g1qw4prqd1";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/gstreamer/bad/default.nix b/pkgs/development/libraries/gstreamer/bad/default.nix
index 2e0e711ce71d..73cbaa0f8070 100644
--- a/pkgs/development/libraries/gstreamer/bad/default.nix
+++ b/pkgs/development/libraries/gstreamer/bad/default.nix
@@ -1,23 +1,28 @@
-{ stdenv, fetchurl, pkgconfig, python, gst-plugins-base, orc
+{ stdenv, fetchurl, fetchpatch, meson, ninja, gettext
+, pkgconfig, python, gst-plugins-base, orc
 , faacSupport ? false, faac ? null
-, gtkSupport ? false, gtk3 ? null
 , faad2, libass, libkate, libmms
-, libmodplug, mpeg2dec, mpg123
+, libmodplug, mpeg2dec
 , openjpeg, libopus, librsvg
 , wildmidi, fluidsynth, libvdpau, wayland
 , libwebp, xvidcore, gnutls, mjpegtools
-, mesa, libintlOrEmpty, libgme
+, libGLU_combined, libintl, libgme
 , openssl, x265, libxml2
 }:
 
 assert faacSupport -> faac != null;
-assert gtkSupport -> gtk3 != null;
 
 let
   inherit (stdenv.lib) optional optionalString;
+
+  # OpenJPEG version is hardcoded in package source
+  openJpegVersion = with stdenv;
+    lib.concatStringsSep "." (lib.lists.take 2
+      (lib.splitString "." (lib.getVersion openjpeg)));
+
 in
 stdenv.mkDerivation rec {
-  name = "gst-plugins-bad-1.12.2";
+  name = "gst-plugins-bad-1.14.0";
 
   meta = with stdenv.lib; {
     description = "Gstreamer Bad Plugins";
@@ -29,35 +34,47 @@ stdenv.mkDerivation rec {
       a real live maintainer, or some actual wide use.
     '';
     license     = licenses.lgpl2Plus;
-    platforms   = platforms.linux;
+    platforms   = platforms.linux ++ platforms.darwin;
   };
 
+  preConfigure = ''
+    patchShebangs .
+  '';
+
+  patches = [
+    (fetchpatch {
+        url = "https://bug794856.bugzilla-attachments.gnome.org/attachment.cgi?id=370409";
+        sha256 = "0hy0rcn35alq65yqwri4fqjz2hf3nyyg5c7rnndk51msmqjxpprk";
+    })
+    ./fix_pkgconfig_includedir.patch
+  ];
+
   src = fetchurl {
     url = "${meta.homepage}/src/gst-plugins-bad/${name}.tar.xz";
-    sha256 = "0dwyq03g2m0p16dwx8q5qvjn5x9ia72h21sf87mp97gmwkfpwb4w";
+    sha256 = "17sgzgx1c54k5rzz7ljyz3is0n7yj56k74vv05h8z1gjnsnjnppd";
   };
 
   outputs = [ "out" "dev" ];
 
-  nativeBuildInputs = [ pkgconfig python ];
+  nativeBuildInputs = [ meson ninja pkgconfig python gettext ];
 
   buildInputs = [
     gst-plugins-base orc
-    faad2 gtk3 libass libkate libmms
-    libmodplug mpeg2dec mpg123
+    faad2 libass libkate libmms
+    libmodplug mpeg2dec
     openjpeg libopus librsvg
     fluidsynth libvdpau
-    libwebp xvidcore gnutls mesa
-    mjpegtools libgme openssl x265 libxml2
+    libwebp xvidcore gnutls libGLU_combined
+    libgme openssl x265 libxml2
+    libintl
   ]
-    ++ libintlOrEmpty
     ++ optional faacSupport faac
-    # for gtksink
-    ++ optional gtkSupport gtk3
     ++ optional stdenv.isLinux wayland
     # wildmidi requires apple's OpenAL
     # TODO: package apple's OpenAL, fix wildmidi, include on Darwin
-    ++ optional (!stdenv.isDarwin) wildmidi;
+    ++ optional (!stdenv.isDarwin) wildmidi
+    # 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/bad/fix_pkgconfig_includedir.patch b/pkgs/development/libraries/gstreamer/bad/fix_pkgconfig_includedir.patch
new file mode 100644
index 000000000000..c687fffc9c08
--- /dev/null
+++ b/pkgs/development/libraries/gstreamer/bad/fix_pkgconfig_includedir.patch
@@ -0,0 +1,15 @@
+diff --git a/pkgconfig/meson.build b/pkgconfig/meson.build
+index 271f327f3..7e2afa754 100644
+--- a/pkgconfig/meson.build
++++ b/pkgconfig/meson.build
+@@ -2,8 +2,8 @@ pkgconf = configuration_data()
+ 
+ pkgconf.set('prefix', join_paths(get_option('prefix')))
+ pkgconf.set('exec_prefix', '${prefix}')
+-pkgconf.set('libdir', '${prefix}/@0@'.format(get_option('libdir')))
+-pkgconf.set('includedir', '${prefix}/@0@'.format(get_option('includedir')))
++pkgconf.set('libdir', join_paths(get_option('prefix'), get_option('libdir')))
++pkgconf.set('includedir', join_paths(get_option('prefix'), get_option('includedir')))
+ pkgconf.set('GST_API_VERSION', api_version)
+ pkgconf.set('VERSION', gst_version)
+ 
diff --git a/pkgs/development/libraries/gstreamer/base/default.nix b/pkgs/development/libraries/gstreamer/base/default.nix
index 2ff429179642..b3a4f445289e 100644
--- a/pkgs/development/libraries/gstreamer/base/default.nix
+++ b/pkgs/development/libraries/gstreamer/base/default.nix
@@ -1,10 +1,11 @@
-{ stdenv, fetchurl, pkgconfig, python, gstreamer, gobjectIntrospection
-, orc, alsaLib, libXv, pango, libtheora
-, cdparanoia, libvisual, libintlOrEmpty
+{ stdenv, fetchurl, fetchpatch, pkgconfig, meson
+, ninja, gettext, gobjectIntrospection, python
+, gstreamer, orc, alsaLib, libXv, pango, libtheora
+, wayland, cdparanoia, libvisual, libintl
 }:
 
 stdenv.mkDerivation rec {
-  name = "gst-plugins-base-1.12.2";
+  name = "gst-plugins-base-1.14.0";
 
   meta = {
     description = "Base plugins and helper libraries";
@@ -15,32 +16,34 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gst-plugins-base/${name}.tar.xz";
-    sha256 = "0x86a7aph0y6gyq178plvwvbbyhkfb3hf0gadx9sk5z1mzixqrsh";
+    sha256 = "0h39bcp7fcd9kgb189lxr8l0hm0almvzpzgpdh1jpq2nzxh4d43y";
   };
 
   outputs = [ "out" "dev" ];
 
   nativeBuildInputs = [
-    pkgconfig python gobjectIntrospection
+    pkgconfig python meson ninja gettext gobjectIntrospection
   ];
 
   buildInputs = [
-    orc libXv pango libtheora cdparanoia
+    orc libXv pango libtheora cdparanoia libintl wayland
   ]
-  ++ libintlOrEmpty
   ++ stdenv.lib.optional stdenv.isLinux alsaLib
   ++ stdenv.lib.optional (!stdenv.isDarwin) libvisual;
 
   propagatedBuildInputs = [ gstreamer ];
 
-  configureFlags = if stdenv.isDarwin then [
-    # Does not currently build on Darwin
-    "--disable-libvisual"
-    # Undefined symbols _cdda_identify and _cdda_identify_scsi in cdparanoia
-    "--disable-cdparanoia"
-  ] else null;
-
-  NIX_LDFLAGS = if stdenv.isDarwin then "-lintl" else null;
+  preConfigure = ''
+    patchShebangs .
+  '';
 
   enableParallelBuilding = true;
+
+  patches = [
+    (fetchpatch {
+        url = "https://bug794856.bugzilla-attachments.gnome.org/attachment.cgi?id=370414";
+        sha256 = "07x43xis0sr0hfchf36ap0cibx0lkfpqyszb3r3w9dzz301fk04z";
+    })
+    ./fix_pkgconfig_includedir.patch
+  ];
 }
diff --git a/pkgs/development/libraries/gstreamer/base/fix_pkgconfig_includedir.patch b/pkgs/development/libraries/gstreamer/base/fix_pkgconfig_includedir.patch
new file mode 100644
index 000000000000..04486a4647f9
--- /dev/null
+++ b/pkgs/development/libraries/gstreamer/base/fix_pkgconfig_includedir.patch
@@ -0,0 +1,15 @@
+diff --git a/pkgconfig/meson.build b/pkgconfig/meson.build
+index 04abfbee5..88c86b431 100644
+--- a/pkgconfig/meson.build
++++ b/pkgconfig/meson.build
+@@ -2,8 +2,8 @@ pkgconf = configuration_data()
+ 
+ pkgconf.set('prefix', get_option('prefix'))
+ pkgconf.set('exec_prefix', '${prefix}')
+-pkgconf.set('libdir', '${prefix}/@0@'.format(get_option('libdir')))
+-pkgconf.set('includedir', '${prefix}/@0@'.format(get_option('includedir')))
++pkgconf.set('libdir', join_paths(get_option('prefix'), get_option('libdir')))
++pkgconf.set('includedir', join_paths(get_option('prefix'), get_option('includedir')))
+ pkgconf.set('GST_API_VERSION', api_version)
+ pkgconf.set('VERSION', gst_version)
+ pkgconf.set('LIBM', libm.found() ? '-lm' : '')
diff --git a/pkgs/development/libraries/gstreamer/core/default.nix b/pkgs/development/libraries/gstreamer/core/default.nix
index 67521e40daf6..ab3f78767a1c 100644
--- a/pkgs/development/libraries/gstreamer/core/default.nix
+++ b/pkgs/development/libraries/gstreamer/core/default.nix
@@ -1,9 +1,11 @@
-{ stdenv, fetchurl, pkgconfig, perl, bison, flex, python, gobjectIntrospection
-, glib, makeWrapper
+{ stdenv, fetchurl, fetchpatch, meson, ninja
+, pkgconfig, gettext, gobjectIntrospection
+, bison, flex, python3, glib, makeWrapper
+, libcap,libunwind, darwin
 }:
 
 stdenv.mkDerivation rec {
-  name = "gstreamer-1.12.2";
+  name = "gstreamer-1.14.0";
 
   meta = {
     description = "Open source multimedia framework";
@@ -15,30 +17,37 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gstreamer/${name}.tar.xz";
-    sha256 = "1fllz7n58lavyy4nh64xc7izd4ffhl12a2ff0yg4z67al8wkzplz";
+    sha256 = "0vj6k01lp2yva6rfd95fkyng9jdr62gkz0x8d2l81dyly1ki6dpw";
   };
 
+  patches = [ 
+    (fetchpatch {
+        url = "https://bug794856.bugzilla-attachments.gnome.org/attachment.cgi?id=370411";
+        sha256 = "16plzzmkk906k4892zq68j3c9z8vdma5nxzlviq20jfv04ykhmk2";
+    })
+    ./fix_pkgconfig_includedir.patch
+  ];
+
   outputs = [ "out" "dev" ];
   outputBin = "dev";
 
   nativeBuildInputs = [
-    pkgconfig perl bison flex python gobjectIntrospection makeWrapper
+    meson ninja pkgconfig gettext bison flex python3 makeWrapper gobjectIntrospection
   ];
+  buildInputs = [ libcap libunwind ] ++ stdenv.lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.CoreServices;
 
   propagatedBuildInputs = [ glib ];
 
-  enableParallelBuilding = true;
-
-  preConfigure = ''
-    configureFlagsArray+=("--exec-prefix=$dev")
-  '';
-
   postInstall = ''
     for prog in "$dev/bin/"*; do
         wrapProgram "$prog" --suffix GST_PLUGIN_SYSTEM_PATH : "\$(unset _tmp; for profile in \$NIX_PROFILES; do _tmp="\$profile/lib/gstreamer-1.0''$\{_tmp:+:\}\$_tmp"; done; printf "\$_tmp")"
     done
   '';
 
+  preConfigure= ''
+    patchShebangs .
+  '';
+
   preFixup = ''
     moveToOutput "share/bash-completion" "$dev"
   '';
diff --git a/pkgs/development/libraries/gstreamer/core/fix_pkgconfig_includedir.patch b/pkgs/development/libraries/gstreamer/core/fix_pkgconfig_includedir.patch
new file mode 100644
index 000000000000..c388a82fa2a8
--- /dev/null
+++ b/pkgs/development/libraries/gstreamer/core/fix_pkgconfig_includedir.patch
@@ -0,0 +1,15 @@
+diff --git a/pkgconfig/meson.build b/pkgconfig/meson.build
+index edb0586c2..7ed46dfce 100644
+--- a/pkgconfig/meson.build
++++ b/pkgconfig/meson.build
+@@ -2,8 +2,8 @@ pkgconf = configuration_data()
+ 
+ pkgconf.set('prefix', join_paths(get_option('prefix')))
+ pkgconf.set('exec_prefix', '${prefix}')
+-pkgconf.set('libdir', '${prefix}/@0@'.format(get_option('libdir')))
+-pkgconf.set('includedir', '${prefix}/@0@'.format(get_option('includedir')))
++pkgconf.set('libdir', join_paths(get_option('prefix'), get_option('libdir')))
++pkgconf.set('includedir', join_paths(get_option('prefix'), get_option('includedir')))
+ pkgconf.set('GST_API_VERSION', apiversion)
+ pkgconf.set('VERSION', gst_version)
+ pkgconf.set('LIBM', mathlib.found() ? '-lm' : '')
diff --git a/pkgs/development/libraries/gstreamer/core/setup-hook.sh b/pkgs/development/libraries/gstreamer/core/setup-hook.sh
index 3dd7812ece6d..b8c741af578f 100644
--- a/pkgs/development/libraries/gstreamer/core/setup-hook.sh
+++ b/pkgs/development/libraries/gstreamer/core/setup-hook.sh
@@ -5,5 +5,5 @@ addGstreamer1LibPath () {
     fi
 }
 
-envHooks+=(addGstreamer1LibPath)
+addEnvHooks "$hostOffset" addGstreamer1LibPath
 
diff --git a/pkgs/development/libraries/gstreamer/default.nix b/pkgs/development/libraries/gstreamer/default.nix
index 76cffa89dbc5..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 { };
@@ -13,17 +13,14 @@ rec {
 
   gst-plugins-ugly = callPackage ./ugly { inherit gst-plugins-base; };
 
-  gst-libav = callPackage ./libav { inherit gst-plugins-base; };
+  gst-rtsp-server = callPackage ./rtsp-server { inherit gst-plugins-base; };
 
-  gnonlin = callPackage ./gnonlin { inherit gst-plugins-base; };
+  gst-libav = callPackage ./libav { inherit gst-plugins-base; };
 
-  # TODO: gnonlin is deprecated in gst-editing-services, better switch to nle
-  # (Non Linear Engine).
-  gst-editing-services = callPackage ./ges { inherit gnonlin; };
+  gst-editing-services = callPackage ./ges { inherit gst-plugins-base; };
 
   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/ges/default.nix b/pkgs/development/libraries/gstreamer/ges/default.nix
index e206f317d4ba..895f298c8269 100644
--- a/pkgs/development/libraries/gstreamer/ges/default.nix
+++ b/pkgs/development/libraries/gstreamer/ges/default.nix
@@ -1,9 +1,10 @@
-{ stdenv, fetchurl, pkgconfig, python, gobjectIntrospection
-, gnonlin, libxml2, flex, perl
+{ stdenv, fetchurl, fetchpatch, meson, ninja
+, pkgconfig, python, gst-plugins-base, libxml2
+, flex, perl, gettext, gobjectIntrospection
 }:
 
 stdenv.mkDerivation rec {
-  name = "gstreamer-editing-services-1.12.2";
+  name = "gstreamer-editing-services-1.14.0";
 
   meta = with stdenv.lib; {
     description = "Library for creation of audio/video non-linear editors";
@@ -14,12 +15,20 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gstreamer-editing-services/${name}.tar.xz";
-    sha256 = "0bi0f487949k9xnl1r6ngysgaibmmswwgdqcrchg0dixnnbm9isr";
+    sha256 = "14cdd6y9p4k603hsnyhdjw2igg855gwpx0362jmg8k1gagmr0pwd";
   };
 
   outputs = [ "out" "dev" ];
 
-  nativeBuildInputs = [ pkgconfig python gobjectIntrospection flex perl ];
+  nativeBuildInputs = [ meson ninja pkgconfig gettext gobjectIntrospection python flex perl ];
 
-  propagatedBuildInputs = [ gnonlin libxml2 ];
+  propagatedBuildInputs = [ gst-plugins-base libxml2 ];
+
+  patches = [
+    (fetchpatch {
+        url = "https://bug794856.bugzilla-attachments.gnome.org/attachment.cgi?id=370413";
+        sha256 = "1xcgbs18g6n5p7z7kqj7ffakwmkxq7ijajyvhyl7p3zvqll9dc7x";
+    })
+    ./fix_pkgconfig_includedir.patch
+  ];
 }
diff --git a/pkgs/development/libraries/gstreamer/ges/fix_pkgconfig_includedir.patch b/pkgs/development/libraries/gstreamer/ges/fix_pkgconfig_includedir.patch
new file mode 100644
index 000000000000..1e12f3bbfbea
--- /dev/null
+++ b/pkgs/development/libraries/gstreamer/ges/fix_pkgconfig_includedir.patch
@@ -0,0 +1,15 @@
+diff --git a/pkgconfig/meson.build b/pkgconfig/meson.build
+index a612b21b..c017eaff 100644
+--- a/pkgconfig/meson.build
++++ b/pkgconfig/meson.build
+@@ -2,8 +2,8 @@ pkgconf = configuration_data()
+ 
+ pkgconf.set('prefix', get_option('prefix'))
+ pkgconf.set('exec_prefix', '${prefix}')
+-pkgconf.set('libdir', '${prefix}/@0@'.format(get_option('libdir')))
+-pkgconf.set('includedir', '${prefix}/@0@'.format(get_option('includedir')))
++pkgconf.set('libdir', join_paths(get_option('prefix'), get_option('libdir')))
++pkgconf.set('includedir', join_paths(get_option('prefix'), get_option('includedir')))
+ pkgconf.set('GST_API_VERSION', apiversion)
+ pkgconf.set('VERSION', gst_version)
+ 
diff --git a/pkgs/development/libraries/gstreamer/gnonlin/default.nix b/pkgs/development/libraries/gstreamer/gnonlin/default.nix
deleted file mode 100644
index c04b64ae3c6a..000000000000
--- a/pkgs/development/libraries/gstreamer/gnonlin/default.nix
+++ /dev/null
@@ -1,30 +0,0 @@
-{ stdenv, fetchurl, pkgconfig
-, gst-plugins-base
-}:
-
-stdenv.mkDerivation rec {
-  name = "gnonlin-1.4.0";
-
-  meta = with stdenv.lib; {
-    description = "Gstreamer Non-Linear Multimedia Editing Plugins";
-    homepage    = "https://gstreamer.freedesktop.org";
-    longDescription = ''
-      Gnonlin is a library built on top of GStreamer which provides 
-      support for writing non-linear audio and video editing
-      applications. It introduces the concept of a timeline.
-    '';
-    license     = licenses.lgpl2Plus;
-    platforms   = platforms.unix;
-  };
-
-  src = fetchurl {
-    url = "${meta.homepage}/src/gnonlin/${name}.tar.xz";
-    sha256 = "0zv60rq2h736a6fivd3a3wp59dj1jar7b2vwzykahvl168b7wrid";
-  };
-
-  outputs = [ "out" "dev" ];
-
-  nativeBuildInputs = [ pkgconfig ];
-
-  propagatedBuildInputs = [ gst-plugins-base ];
-}
diff --git a/pkgs/development/libraries/gstreamer/good/default.nix b/pkgs/development/libraries/gstreamer/good/default.nix
index 1c7f7951e916..5c10221b27d7 100644
--- a/pkgs/development/libraries/gstreamer/good/default.nix
+++ b/pkgs/development/libraries/gstreamer/good/default.nix
@@ -1,17 +1,20 @@
-{ stdenv, fetchurl, pkgconfig, python
-, gst-plugins-base, orc, bzip2
+{ stdenv, fetchurl, meson, ninja, pkgconfig, python
+, gst-plugins-base, orc, bzip2, gettext
 , libv4l, libdv, libavc1394, libiec61883
 , libvpx, speex, flac, taglib, libshout
 , cairo, gdk_pixbuf, aalib, libcaca
-, libsoup, libpulseaudio, libintlOrEmpty
-, darwin
+, libsoup, libpulseaudio, libintl
+, darwin, lame, mpg123, twolame
+, gtkSupport ? false, gtk3 ? null
 }:
 
+assert gtkSupport -> gtk3 != null;
+
 let
   inherit (stdenv.lib) optionals optionalString;
 in
 stdenv.mkDerivation rec {
-  name = "gst-plugins-good-1.12.2";
+  name = "gst-plugins-good-1.14.0";
 
   meta = with stdenv.lib; {
     description = "Gstreamer Good Plugins";
@@ -27,27 +30,22 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gst-plugins-good/${name}.tar.xz";
-    sha256 = "15pfw54fsh9s9xwrnbap4z4njwgqdfvq52k562d2hc5b11rfx4am";
+    sha256 = "1226s30cf7pqg3fj8shd20l7sp93yw9sqplgxns3m3ajgms3byka";
   };
 
   outputs = [ "out" "dev" ];
 
-  nativeBuildInputs = [ pkgconfig python ];
+  patches = [ ./fix_pkgconfig_includedir.patch ];
+
+  nativeBuildInputs = [ pkgconfig python meson ninja gettext ];
 
   buildInputs = [
     gst-plugins-base orc bzip2
     libdv libvpx speex flac taglib
     cairo gdk_pixbuf aalib libcaca
-    libsoup libshout
+    libsoup libshout lame mpg123 twolame libintl
   ]
-  ++ libintlOrEmpty
   ++ optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ]
   ++ optionals stdenv.isLinux [ libv4l libpulseaudio libavc1394 libiec61883 ];
 
-  preFixup = ''
-    mkdir -p "$dev/lib/gstreamer-1.0"
-    mv "$out/lib/gstreamer-1.0/"*.la "$dev/lib/gstreamer-1.0"
-  '';
-
-  LDFLAGS = optionalString stdenv.isDarwin "-lintl";
 }
diff --git a/pkgs/development/libraries/gstreamer/good/fix_pkgconfig_includedir.patch b/pkgs/development/libraries/gstreamer/good/fix_pkgconfig_includedir.patch
new file mode 100644
index 000000000000..f68ad603a37c
--- /dev/null
+++ b/pkgs/development/libraries/gstreamer/good/fix_pkgconfig_includedir.patch
@@ -0,0 +1,15 @@
+diff --git a/pkgconfig/meson.build b/pkgconfig/meson.build
+index b3bf0d4d4..3e6e576c0 100644
+--- a/pkgconfig/meson.build
++++ b/pkgconfig/meson.build
+@@ -2,8 +2,8 @@ pkgconf = configuration_data()
+ 
+ pkgconf.set('prefix', get_option('prefix'))
+ pkgconf.set('exec_prefix', '${prefix}')
+-pkgconf.set('libdir', '${prefix}/@0@'.format(get_option('libdir')))
+-pkgconf.set('includedir', '${prefix}/@0@'.format(get_option('includedir')))
++pkgconf.set('libdir', join_paths(get_option('prefix'), get_option('libdir')))
++pkgconf.set('includedir', join_paths(get_option('prefix'), get_option('includedir')))
+ pkgconf.set('GST_API_VERSION', api_version)
+ pkgconf.set('VERSION', gst_version)
+ 
diff --git a/pkgs/development/libraries/gstreamer/gstreamermm/default.nix b/pkgs/development/libraries/gstreamer/gstreamermm/default.nix
index f6138fafaefc..14e27ab6068c 100644
--- a/pkgs/development/libraries/gstreamer/gstreamermm/default.nix
+++ b/pkgs/development/libraries/gstreamer/gstreamermm/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, pkgconfig, file, glibmm, gst_all_1 }:
 
 let
-  ver_maj = "1.8";
+  ver_maj = "1.10";
   ver_min = "0";
 in
 stdenv.mkDerivation rec {
@@ -9,16 +9,9 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url    = "mirror://gnome/sources/gstreamermm/${ver_maj}/${name}.tar.xz";
-    sha256 = "0i4sk6ns4dyi4szk45bkm4kvl57l52lgm15p2wg2rhx2gr2w3qry";
+    sha256 = "0q4dx9sncqbwgpzma0zvj6zssc279yl80pn8irb95qypyyggwn5y";
   };
 
-  patches = [
-    (fetchurl {
-      url = https://bug783628.bugzilla-attachments.gnome.org/attachment.cgi?id=354765;
-      sha256 = "082510a934bl05mz4cyakp8mfmd97cdj7vdrbvyqc4g58dcskvz0";
-    })
-  ];
-
   outputs = [ "out" "dev" ];
 
   nativeBuildInputs = [ pkgconfig file ];
@@ -31,8 +24,8 @@ stdenv.mkDerivation rec {
     description = "C++ interface for GStreamer";
     homepage = https://gstreamer.freedesktop.org/bindings/cplusplus.html;
     license = licenses.lgpl21Plus;
+    platforms = platforms.linux;
     maintainers = with maintainers; [ romildo ];
-    platforms = platforms.unix;
   };
 
 }
diff --git a/pkgs/development/libraries/gstreamer/legacy/gst-plugins-bad/default.nix b/pkgs/development/libraries/gstreamer/legacy/gst-plugins-bad/default.nix
index bdb1b6c7bb7a..77465645d237 100644
--- a/pkgs/development/libraries/gstreamer/legacy/gst-plugins-bad/default.nix
+++ b/pkgs/development/libraries/gstreamer/legacy/gst-plugins-bad/default.nix
@@ -12,6 +12,12 @@ stdenv.mkDerivation rec {
     sha256 = "148lw51dm6pgw8vc6v0fpvm7p233wr11nspdzmvq7bjp2cd7vbhf";
   };
 
+  postInstall = ''
+    # Fixes CVE-2016-9447
+    # Does not actually impact NSF playback
+    rm -v $out/lib/gstreamer-0.10/libgstnsf.so
+  '';
+
   buildInputs =
     [ pkgconfig glib gstreamer gst-plugins-base libdvdnav libdvdread orc ];
 
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/legacy/gstreamer/setup-hook.sh b/pkgs/development/libraries/gstreamer/legacy/gstreamer/setup-hook.sh
index e89aeda5bc1c..65ce26112519 100644
--- a/pkgs/development/libraries/gstreamer/legacy/gstreamer/setup-hook.sh
+++ b/pkgs/development/libraries/gstreamer/legacy/gstreamer/setup-hook.sh
@@ -5,4 +5,4 @@ addGstreamerLibPath () {
     fi
 }
 
-envHooks+=(addGstreamerLibPath)
+addEnvHooks "$hostOffset" addGstreamerLibPath
diff --git a/pkgs/development/libraries/gstreamer/libav/default.nix b/pkgs/development/libraries/gstreamer/libav/default.nix
index 7c0a05f8202b..564b37fab794 100644
--- a/pkgs/development/libraries/gstreamer/libav/default.nix
+++ b/pkgs/development/libraries/gstreamer/libav/default.nix
@@ -1,6 +1,6 @@
-{ stdenv, fetchurl, pkgconfig, python, yasm
-, gst-plugins-base, orc, bzip2
-, withSystemLibav ? true, libav ? null
+{ stdenv, fetchurl, meson, ninja, pkgconfig
+, python, yasm, gst-plugins-base, orc, bzip2
+, gettext, withSystemLibav ? true, libav ? null
 }:
 
 # Note that since gst-libav-1.6, libav is actually ffmpeg. See
@@ -9,7 +9,7 @@
 assert withSystemLibav -> libav != null;
 
 stdenv.mkDerivation rec {
-  name = "gst-libav-1.12.2";
+  name = "gst-libav-1.14.0";
 
   meta = {
     homepage = https://gstreamer.freedesktop.org;
@@ -19,16 +19,13 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gst-libav/${name}.tar.xz";
-    sha256 = "1crdahkjm23byg1awcrjkmgfbalfpvvac7h7whm6b2r1pfwkbdsv";
+    sha256 = "12gglx6rarnxbaj0h1wivlgkv467n1bz2bwjigplciq57r6ln4zv";
   };
 
   outputs = [ "out" "dev" ];
 
-  configureFlags = stdenv.lib.optionalString withSystemLibav
-    "--with-system-libav";
-
   nativeBuildInputs = with stdenv.lib;
-    [ pkgconfig python ]
+    [ meson ninja gettext pkgconfig python ]
     ++ optional (!withSystemLibav) yasm
     ;
 
diff --git a/pkgs/development/libraries/gstreamer/rtsp-server/default.nix b/pkgs/development/libraries/gstreamer/rtsp-server/default.nix
new file mode 100644
index 000000000000..9ff799b0a27b
--- /dev/null
+++ b/pkgs/development/libraries/gstreamer/rtsp-server/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl, meson, ninja, pkgconfig
+, gst-plugins-base, gettext, gobjectIntrospection
+}:
+
+stdenv.mkDerivation rec {
+  name = "gst-rtsp-server-1.14.0";
+
+  meta = with stdenv.lib; {
+    description = "Gstreamer RTSP server";
+    homepage    = "https://gstreamer.freedesktop.org";
+    longDescription = ''
+      a library on top of GStreamer for building an RTSP server.
+    '';
+    license     = licenses.lgpl2Plus;
+    platforms   = platforms.linux ++ platforms.darwin;
+    maintainers = with maintainers; [ bkchr ];
+  };
+
+  src = fetchurl {
+    url = "${meta.homepage}/src/gst-rtsp-server/${name}.tar.xz";
+    sha256 = "0mlp9ms5hfbyzyvmc9xgi7934g4zrh1sbgky2p9zc5fqprvs0rbb";
+  };
+
+  outputs = [ "out" "dev" ];
+
+  nativeBuildInputs = [ meson ninja gettext gobjectIntrospection pkgconfig ];
+
+  buildInputs = [ gst-plugins-base ];
+}
diff --git a/pkgs/development/libraries/gstreamer/ugly/default.nix b/pkgs/development/libraries/gstreamer/ugly/default.nix
index 610f10075a8d..a5449abb9f7d 100644
--- a/pkgs/development/libraries/gstreamer/ugly/default.nix
+++ b/pkgs/development/libraries/gstreamer/ugly/default.nix
@@ -1,11 +1,11 @@
-{ stdenv, fetchurl, pkgconfig, python
-, gst-plugins-base, orc
+{ stdenv, fetchurl, meson, ninja, pkgconfig, python
+, gst-plugins-base, orc, gettext
 , a52dec, libcdio, libdvdread
-, lame, libmad, libmpeg2, x264, libintlOrEmpty
+, libmad, libmpeg2, x264, libintl
 }:
 
 stdenv.mkDerivation rec {
-  name = "gst-plugins-ugly-1.12.2";
+  name = "gst-plugins-ugly-1.14.0";
 
   meta = with stdenv.lib; {
     description = "Gstreamer Ugly Plugins";
@@ -22,18 +22,17 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gst-plugins-ugly/${name}.tar.xz";
-    sha256 = "0rplyp1qk359c97ig9i2vc1v34g92khd8dslwfipva1ypwmr9hqw";
+    sha256 = "1la2nny9hfw3rf3wvqggkg8ivn52qrqqs4n4mqz4ppm2r1gymf9z";
   };
 
   outputs = [ "out" "dev" ];
 
-  nativeBuildInputs = [ pkgconfig python ];
+  nativeBuildInputs = [ meson ninja gettext pkgconfig python ];
 
   buildInputs = [
     gst-plugins-base orc
     a52dec libcdio libdvdread
-    lame libmad libmpeg2 x264
-  ] ++ libintlOrEmpty;
-
-  NIX_LDFLAGS = if stdenv.isDarwin then "-lintl" else null;
+    libmad libmpeg2 x264
+    libintl
+  ];
 }
diff --git a/pkgs/development/libraries/gstreamer/vaapi/default.nix b/pkgs/development/libraries/gstreamer/vaapi/default.nix
index becd4cf0d921..11b451e76fdf 100644
--- a/pkgs/development/libraries/gstreamer/vaapi/default.nix
+++ b/pkgs/development/libraries/gstreamer/vaapi/default.nix
@@ -1,32 +1,31 @@
-{ stdenv, fetchurl, pkgconfig, gst-plugins-base, bzip2, libva, wayland
-, libdrm, udev, xorg, mesa, yasm, gstreamer, gst-plugins-bad, nasm
+{ stdenv, fetchurl, meson, ninja, pkgconfig, gst-plugins-base, bzip2, libva, wayland
+, libdrm, udev, xorg, libGLU_combined, yasm, gstreamer, gst-plugins-bad, nasm
 , libvpx, python
 }:
 
 stdenv.mkDerivation rec {
   name = "gst-vaapi-${version}";
-  version = "1.12.2";
+  version = "1.14.0";
 
   src = fetchurl {
     url = "${meta.homepage}/src/gstreamer-vaapi/gstreamer-vaapi-${version}.tar.xz";
-    sha256 = "0fhncs27hcdcnb9a4prkxlyvr883hnzsx148zzk7lg2b8zh19ir3";
+    sha256 = "1whxk428badv8ibji00sn6hj17cp8l9n93rr948bz2gjbq41zqz4";
   };
 
   outputs = [ "out" "dev" ];
 
-  nativeBuildInputs = [ pkgconfig bzip2 ];
+  nativeBuildInputs = [ meson ninja pkgconfig bzip2 ];
 
   buildInputs = [
     gstreamer gst-plugins-base gst-plugins-bad libva wayland libdrm udev
     xorg.libX11 xorg.libXext xorg.libXv xorg.libXrandr xorg.libSM
-    xorg.libICE mesa nasm libvpx python
+    xorg.libICE libGLU_combined nasm libvpx python
   ];
 
-  preConfigure = "
+  preConfigure = ''
     export GST_PLUGIN_PATH_1_0=$out/lib/gstreamer-1.0
     mkdir -p $GST_PLUGIN_PATH_1_0
-    ";
-  configureFlags = "--disable-builtin-libvpx --with-gstreamer-api=1.0";
+  '';
 
   meta = {
     homepage = https://gstreamer.freedesktop.org;
diff --git a/pkgs/development/libraries/gstreamer/validate/default.nix b/pkgs/development/libraries/gstreamer/validate/default.nix
index 9704ca1d743c..bd33d9c52807 100644
--- a/pkgs/development/libraries/gstreamer/validate/default.nix
+++ b/pkgs/development/libraries/gstreamer/validate/default.nix
@@ -1,9 +1,9 @@
 { stdenv, fetchurl, pkgconfig, gstreamer, gst-plugins-base
-, python, gobjectIntrospection, json_glib
+, python, gobjectIntrospection, json-glib
 }:
 
 stdenv.mkDerivation rec {
-  name = "gst-validate-1.12.2";
+  name = "gst-validate-1.14.0";
 
   meta = {
     description = "Integration testing infrastructure for the GStreamer framework";
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gst-validate/${name}.tar.xz";
-    sha256 = "1pgycs35bwmp4aicyxwyzlfy1i5l2rzmh2a8ivhgy21azp8jaykb";
+    sha256 = "1pzzxqkv1spjrzpzpazdm2h4s2wk7gg5gag8nxj5v2gjfyzhiprk";
   };
 
   outputs = [ "out" "dev" ];
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
   ];
 
   buildInputs = [
-    python json_glib
+    python json-glib
   ];
 
   propagatedBuildInputs = [ gstreamer gst-plugins-base ];
diff --git a/pkgs/development/libraries/gtdialog/default.nix b/pkgs/development/libraries/gtdialog/default.nix
index d6f745d399d1..36da2fb72aa4 100644
--- a/pkgs/development/libraries/gtdialog/default.nix
+++ b/pkgs/development/libraries/gtdialog/default.nix
@@ -3,11 +3,11 @@ let
   s = # Generated upstream information
   rec {
     baseName="gtdialog";
-    version="1.3";
+    version="1.4";
     name="${baseName}-${version}";
-    hash="0y7sln877940bpj0s38cs5s97xg8csnaihh18lmnchf7c2kkbxpq";
-    url="http://foicica.com/gtdialog/download/gtdialog_1.3.zip";
-    sha256="0y7sln877940bpj0s38cs5s97xg8csnaihh18lmnchf7c2kkbxpq";
+    hash="1lhsaz56s8m838fi6vnfcd2r6djymvy3n2pbqhii88hraapq3rfk";
+    url="http://foicica.com/gtdialog/download/gtdialog_1.4.zip";
+    sha256="1lhsaz56s8m838fi6vnfcd2r6djymvy3n2pbqhii88hraapq3rfk";
   };
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [
diff --git a/pkgs/development/libraries/gtk+/2.x.nix b/pkgs/development/libraries/gtk+/2.x.nix
index 45222b7d7fcc..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
+, gdk_pixbuf, xlibsWrapper, gobjectIntrospection
 , xineramaSupport ? stdenv.isLinux
 , cupsSupport ? true, cups ? null
 , gdktarget ? "x11"
@@ -12,11 +12,11 @@ assert cupsSupport -> cups != null;
 with stdenv.lib;
 
 stdenv.mkDerivation rec {
-  name = "gtk+-2.24.31";
+  name = "gtk+-2.24.32";
 
   src = fetchurl {
     url = "mirror://gnome/sources/gtk+/2.24/${name}.tar.xz";
-    sha256 = "68c1922732c7efc08df4656a5366dcc3afdc8791513400dac276009b40954658";
+    sha256 = "b6c8a93ddda5eabe3bfee1eb39636c9a03d2a56c7b62828b359bf197943c582e";
   };
 
   outputs = [ "out" "dev" "devdoc" ];
@@ -24,11 +24,9 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  NIX_CFLAGS_COMPILE = optionalString (libintlOrEmpty != []) "-lintl";
-
   setupHook = ./setup-hook.sh;
 
-  nativeBuildInputs = [ setupHook perl pkgconfig gettext ];
+  nativeBuildInputs = [ setupHook perl pkgconfig gettext gobjectIntrospection ];
 
   patches = [ ./2.0-immodules.cache.patch ./gtk2-theme-paths.patch ];
 
@@ -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 1d0930d8d03c..dc6a519dfade 100644
--- a/pkgs/development/libraries/gtk+/3.x.nix
+++ b/pkgs/development/libraries/gtk+/3.x.nix
@@ -1,10 +1,10 @@
-{ stdenv, fetchurl, pkgconfig, gettext, perl
-, expat, glib, cairo, pango, gdk_pixbuf, atk, at_spi2_atk, gobjectIntrospection
-, xorg, epoxy, json_glib, libxkbcommon, gmp
-, waylandSupport ? stdenv.isLinux, wayland, wayland-protocols
+{ 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, mesa_noglu, wayland, wayland-protocols
 , xineramaSupport ? stdenv.isLinux
 , cupsSupport ? stdenv.isLinux, cups ? null
-, darwin
+, darwin, gnome3
 }:
 
 assert cupsSupport -> cups != null;
@@ -12,37 +12,40 @@ assert cupsSupport -> cups != null;
 with stdenv.lib;
 
 let
-  ver_maj = "3.22";
-  ver_min = "24";
-  version = "${ver_maj}.${ver_min}";
+  version = "3.22.29";
 in
 stdenv.mkDerivation rec {
   name = "gtk+3-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/gtk+/${ver_maj}/gtk+-${version}.tar.xz";
-    sha256 = "cbb16e4cfc928ab8f5f22f7290616f95f6ebc8c97cc724a2007b07ced833592b";
+    url = "mirror://gnome/sources/gtk+/${gnome3.versionBranch version}/gtk+-${version}.tar.xz";
+    sha256 = "1y5vzdbgww9l7xcrg13azff2rs94kggkywmpcsh39h7w76wn8zd0";
   };
 
   outputs = [ "out" "dev" ];
   outputBin = "dev";
 
-  nativeBuildInputs = [ pkgconfig gettext gobjectIntrospection perl ];
+  nativeBuildInputs = [ pkgconfig gettext gobjectIntrospection perl makeWrapper ];
 
-  patches = [ ./3.0-immodules.cache.patch ];
+  patches = [
+    ./3.0-immodules.cache.patch
+    (fetchpatch {
+      name = "Xft-setting-fallback-compute-DPI-properly.patch";
+      url = "https://bug757142.bugzilla-attachments.gnome.org/attachment.cgi?id=344123";
+      sha256 = "0g6fhqcv8spfy3mfmxpyji93k8d4p4q4fz1v9a1c1cgcwkz41d7p";
+    })
+  ];
 
-  buildInputs = [ libxkbcommon epoxy json_glib ];
+  buildInputs = [ libxkbcommon epoxy json-glib ];
   propagatedBuildInputs = with xorg; with stdenv.lib;
-    [ expat glib cairo pango gdk_pixbuf atk at_spi2_atk
+    [ 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";
 
@@ -67,8 +70,20 @@ stdenv.mkDerivation rec {
     moveToOutput bin/gtk-update-icon-cache "$out"
     # Launcher
     moveToOutput bin/gtk-launch "$out"
+
+    # TODO: patch glib directly
+    for f in $dev/bin/gtk-encode-symbolic-svg; do
+      wrapProgram $f --prefix XDG_DATA_DIRS : "${shared-mime-info}/share"
+    done
   '';
 
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = "gtk+";
+      attrPath = "gtk3";
+    };
+  };
+
   meta = with stdenv.lib; {
     description = "A multi-platform toolkit for creating graphical user interfaces";
 
diff --git a/pkgs/development/libraries/gtk-mac-integration/default.nix b/pkgs/development/libraries/gtk-mac-integration/default.nix
index f9ce0aa4b81e..0171a4b6833b 100644
--- a/pkgs/development/libraries/gtk-mac-integration/default.nix
+++ b/pkgs/development/libraries/gtk-mac-integration/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchFromGitHub, autoreconfHook, pkgconfig, glib, gtk_doc, gtk, gobjectIntrospection }:
+{ stdenv, lib, fetchFromGitHub, autoreconfHook, pkgconfig, glib, gtk-doc, gtk, gobjectIntrospection }:
 
 stdenv.mkDerivation rec {
   name = "gtk-mac-integration-2.0.8";
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
     sha256 = "1fbhnvj0rqc3089ypvgnpkp6ad2rr37v5qk38008dgamb9h7f3qs";
   };
 
-  nativeBuildInputs = [ autoreconfHook pkgconfig gtk_doc gobjectIntrospection ];
+  nativeBuildInputs = [ autoreconfHook pkgconfig gtk-doc gobjectIntrospection ];
   buildInputs = [ glib ];
   propagatedBuildInputs = [ gtk ];
 
diff --git a/pkgs/development/libraries/gtkd/default.nix b/pkgs/development/libraries/gtkd/default.nix
index ffbab3fce421..5a4cf75048f7 100644
--- a/pkgs/development/libraries/gtkd/default.nix
+++ b/pkgs/development/libraries/gtkd/default.nix
@@ -92,7 +92,7 @@ stdenv.mkDerivation rec {
   meta = with stdenv.lib; {
     description = "D binding and OO wrapper for GTK+";
     homepage = https://gtkd.org;
-    licence = licenses.lgpl3Plus;
+    license = licenses.lgpl3Plus;
     platforms = platforms.linux ++ platforms.darwin;
   };
 }
diff --git a/pkgs/development/libraries/gtkdatabox/default.nix b/pkgs/development/libraries/gtkdatabox/default.nix
index de5fd8343e3e..d074f51d3ca0 100644
--- a/pkgs/development/libraries/gtkdatabox/default.nix
+++ b/pkgs/development/libraries/gtkdatabox/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, pkgconfig, gtk2 }:
 
 stdenv.mkDerivation rec {
-  name = "gtkdatabox-0.9.2.0";
+  name = "gtkdatabox-0.9.3.0";
 
   src = fetchurl {
     url = "mirror://sourceforge/gtkdatabox/${name}.tar.gz";
-    sha256 = "0h20685bzw5j5h6mw8c6apbrbrd9w518c6xdhr55147px11nhnkl";
+    sha256 = "1wigd4bdlrz4pma2l2wd3z8sx7pqmsvq845nya5vma9ibi96nhhz";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/gtkmm/2.x.nix b/pkgs/development/libraries/gtkmm/2.x.nix
index 469c6adc6f76..69fd3f30e92d 100644
--- a/pkgs/development/libraries/gtkmm/2.x.nix
+++ b/pkgs/development/libraries/gtkmm/2.x.nix
@@ -11,12 +11,14 @@ stdenv.mkDerivation rec {
 
   outputs = [ "out" "dev" ];
 
-  nativeBuildInputs = [pkgconfig];
+  nativeBuildInputs = [ pkgconfig ];
 
   propagatedBuildInputs = [ glibmm gtk2 atkmm cairomm pangomm ];
 
   doCheck = true;
 
+  enableParallelBuilding = true;
+
   meta = {
     description = "C++ interface to the GTK+ graphical user interface library";
 
diff --git a/pkgs/development/libraries/gtksourceview/3.x-nix_share_path.patch b/pkgs/development/libraries/gtksourceview/3.x-nix_share_path.patch
new file mode 100644
index 000000000000..c87350167c25
--- /dev/null
+++ b/pkgs/development/libraries/gtksourceview/3.x-nix_share_path.patch
@@ -0,0 +1,11 @@
+--- a/gtksourceview/gtksourceview-utils.c	2014-07-13 16:13:57.418687726 +0200
++++ b/gtksourceview/gtksourceview-utils.c	2014-07-13 16:14:20.550847767 +0200
+@@ -68,6 +68,8 @@
+ 							 basename,
+ 							 NULL));
+ 
++        g_ptr_array_add (dirs, g_build_filename ("@NIX_SHARE_PATH@", SOURCEVIEW_DIR, basename, NULL));
++
+ 	g_ptr_array_add (dirs, NULL);
+ 
+ 	return (gchar**) g_ptr_array_free (dirs, FALSE);
diff --git a/pkgs/development/libraries/gtksourceview/3.x.nix b/pkgs/development/libraries/gtksourceview/3.x.nix
new file mode 100644
index 000000000000..673eb1e52c44
--- /dev/null
+++ b/pkgs/development/libraries/gtksourceview/3.x.nix
@@ -0,0 +1,60 @@
+{ stdenv, fetchurl, pkgconfig, atk, cairo, glib, gtk3, pango, vala_0_40
+, libxml2, perl, intltool, gettext, gnome3, gobjectIntrospection, dbus, xvfb_run, shared-mime-info }:
+
+let
+  checkInputs = [ xvfb_run dbus ];
+in stdenv.mkDerivation rec {
+  name = "gtksourceview-${version}";
+  version = "3.24.6";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/gtksourceview/${gnome3.versionBranch version}/${name}.tar.xz";
+    sha256 = "7aa6bdfebcdc73a763dddeaa42f190c40835e6f8495bb9eb8f78587e2577c188";
+  };
+
+  propagatedBuildInputs = [
+    # Required by gtksourceview-3.0.pc
+    gtk3
+    # Used by gtk_source_language_manager_guess_language
+    shared-mime-info
+  ];
+
+  outputs = [ "out" "dev" ];
+
+  nativeBuildInputs = [ pkgconfig intltool gettext perl gobjectIntrospection vala_0_40 ]
+    ++ stdenv.lib.optionals doCheck checkInputs;
+
+  buildInputs = [ atk cairo glib pango libxml2 ];
+
+  preBuild = ''
+    substituteInPlace gtksourceview/gtksourceview-utils.c --replace "@NIX_SHARE_PATH@" "$out/share"
+  '';
+
+  patches = [ ./3.x-nix_share_path.patch ];
+
+  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-lintl";
+
+  enableParallelBuilding = true;
+
+  doCheck = stdenv.isLinux;
+  checkPhase = ''
+    export NO_AT_BRIDGE=1
+    xvfb-run -s '-screen 0 800x600x24' dbus-run-session \
+      --config-file=${dbus.daemon}/share/dbus-1/session.conf \
+      make check
+  '';
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = "gtksourceview";
+      attrPath = "gnome3.gtksourceview";
+    };
+  };
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Projects/GtkSourceView;
+    platforms = with platforms; linux ++ darwin;
+    license = licenses.lgpl21;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/development/libraries/gtksourceview/4.x-nix_share_path.patch b/pkgs/development/libraries/gtksourceview/4.x-nix_share_path.patch
new file mode 100644
index 000000000000..a35d9a88d0df
--- /dev/null
+++ b/pkgs/development/libraries/gtksourceview/4.x-nix_share_path.patch
@@ -0,0 +1,11 @@
+--- a/gtksourceview/gtksourceutils.c
++++ b/gtksourceview/gtksourceutils.c
+@@ -232,6 +232,8 @@
+ 							 NULL));
+ 	}
+ 
++	g_ptr_array_add (dirs, g_build_filename (DATADIR, GSV_DATA_SUBDIR, basename, NULL));
++
+ 	g_ptr_array_add (dirs, NULL);
+ 
+ 	return (gchar **) g_ptr_array_free (dirs, FALSE);
diff --git a/pkgs/development/libraries/gtksourceview/4.x.nix b/pkgs/development/libraries/gtksourceview/4.x.nix
new file mode 100644
index 000000000000..2501e0253b39
--- /dev/null
+++ b/pkgs/development/libraries/gtksourceview/4.x.nix
@@ -0,0 +1,54 @@
+{ stdenv, fetchurl, pkgconfig, atk, cairo, glib, gtk3, pango, vala_0_40
+, libxml2, perl, gettext, gnome3, gobjectIntrospection, dbus, xvfb_run, shared-mime-info }:
+
+let
+  checkInputs = [ xvfb_run dbus ];
+in stdenv.mkDerivation rec {
+  name = "gtksourceview-${version}";
+  version = "4.0.0";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/gtksourceview/${gnome3.versionBranch version}/${name}.tar.xz";
+    sha256 = "0amkspjsvxr3rjznmnwjwsgw030hayf6bw49ya4nligslwl7lp3f";
+  };
+
+  propagatedBuildInputs = [
+    # Required by gtksourceview-4.0.pc
+    gtk3
+    # Used by gtk_source_language_manager_guess_language
+    shared-mime-info
+  ];
+
+  outputs = [ "out" "dev" ];
+
+  nativeBuildInputs = [ pkgconfig gettext perl gobjectIntrospection vala_0_40 ]
+    ++ stdenv.lib.optionals doCheck checkInputs;
+
+  buildInputs = [ atk cairo glib pango libxml2 ];
+
+  patches = [ ./4.x-nix_share_path.patch ];
+
+  enableParallelBuilding = true;
+
+  doCheck = stdenv.isLinux;
+  checkPhase = ''
+    export NO_AT_BRIDGE=1
+    xvfb-run -s '-screen 0 800x600x24' dbus-run-session \
+      --config-file=${dbus.daemon}/share/dbus-1/session.conf \
+      make check
+  '';
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = "gtksourceview";
+      attrPath = "gnome3.gtksourceview";
+    };
+  };
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Projects/GtkSourceView;
+    platforms = with platforms; linux ++ darwin;
+    license = licenses.lgpl21;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/development/libraries/gtkspell/3.nix b/pkgs/development/libraries/gtkspell/3.nix
index 5376482e58a5..90bc4fc7f820 100644
--- a/pkgs/development/libraries/gtkspell/3.nix
+++ b/pkgs/development/libraries/gtkspell/3.nix
@@ -1,18 +1,22 @@
-{stdenv, fetchurl, gtk3, aspell, pkgconfig, enchant, intltool}:
+{stdenv, fetchurl, gtk3, aspell, pkgconfig, enchant, isocodes, intltool, gobjectIntrospection}:
 
 stdenv.mkDerivation rec {
   name = "gtkspell-${version}";
   version = "3.0.9";
 
+  outputs = [ "out" "dev" ];
+
   src = fetchurl {
     url = "mirror://sourceforge/gtkspell/gtkspell3-${version}.tar.xz";
     sha256 = "09jdicmpipmj4v84gnkqwbmj4lh8v0i6pn967rb9jx4zg2ia9x54";
   };
 
-  nativeBuildInputs = [ pkgconfig intltool ];
-  buildInputs = [ aspell gtk3 enchant ];
+  nativeBuildInputs = [ pkgconfig intltool gobjectIntrospection ];
+  buildInputs = [ aspell gtk3 enchant isocodes ];
   propagatedBuildInputs = [ enchant ];
 
+  configureFlags = [ "--enable-introspection" ];
+
   meta = with stdenv.lib; {
     homepage = http://gtkspell.sourceforge.net/;
     description = "Word-processor-style highlighting GtkTextView widget";
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/libgumbo/default.nix b/pkgs/development/libraries/gumbo/default.nix
index 210a66e654a7..17ca323a5fef 100644
--- a/pkgs/development/libraries/libgumbo/default.nix
+++ b/pkgs/development/libraries/gumbo/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchFromGitHub, autoconf, automake, libtool }:
 
 stdenv.mkDerivation rec {
-  name = "libgumbo-${version}";
+  name = "gumbo-${version}";
   version = "0.10.1";
 
   src = fetchFromGitHub {
diff --git a/pkgs/development/libraries/gupnp-av/default.nix b/pkgs/development/libraries/gupnp-av/default.nix
index 789fdcd9c2a7..9b61f4b648e1 100644
--- a/pkgs/development/libraries/gupnp-av/default.nix
+++ b/pkgs/development/libraries/gupnp-av/default.nix
@@ -3,11 +3,11 @@
 stdenv.mkDerivation rec {
   name = "gupnp-av-${version}";
   majorVersion = "0.12";
-  version = "${majorVersion}.7";
+  version = "${majorVersion}.10";
 
   src = fetchurl {
     url = "mirror://gnome/sources/gupnp-av/${majorVersion}/${name}.tar.xz";
-    sha256 = "35e775bc4f7801d65dcb710905a6b8420ce751a239b5651e6d830615dc906ea8";
+    sha256 = "0nmq6wlbfsssanv3jgv2z0nhfkv8vzfr3gq5qa8svryvvn2fyf40";
   };
   
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/gupnp-dlna/default.nix b/pkgs/development/libraries/gupnp-dlna/default.nix
new file mode 100644
index 000000000000..642e10ea541d
--- /dev/null
+++ b/pkgs/development/libraries/gupnp-dlna/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, pkgconfig,  gobjectIntrospection, gupnp, gst_plugins_base }:
+
+stdenv.mkDerivation rec {
+  name = "gupnp-dlna-${version}";
+  majorVersion = "0.10";
+  version = "${majorVersion}.5";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/gupnp-dlna/${majorVersion}/${name}.tar.xz";
+    sha256 = "0spzd2saax7w776p5laixdam6d7smyynr9qszhbmq7f14y13cghj";
+  };
+
+  nativeBuildInputs = [ pkgconfig gobjectIntrospection ];
+  buildInputs = [ gupnp gst_plugins_base ];
+
+  meta = {
+    homepage = https://wiki.gnome.org/Projects/GUPnP/;
+    description = "Library to ease DLNA-related bits for applications using GUPnP";
+    license = stdenv.lib.licenses.gpl2;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/gupnp/default.nix b/pkgs/development/libraries/gupnp/default.nix
index afd5ee591c60..963b93ef6917 100644
--- a/pkgs/development/libraries/gupnp/default.nix
+++ b/pkgs/development/libraries/gupnp/default.nix
@@ -2,12 +2,12 @@
  
 stdenv.mkDerivation rec {
   name = "gupnp-${version}";
-  majorVersion = "0.20";
-  version = "${majorVersion}.14";
+  majorVersion = "1.0";
+  version = "${majorVersion}.2";
 
   src = fetchurl {
     url = "mirror://gnome/sources/gupnp/${majorVersion}/gupnp-${version}.tar.xz";
-    sha256 = "77ffb940ba77c4a6426d09d41004c75d92652dcbde86c84ac1c847dbd9ad59bd";
+    sha256 = "043nqxlj030a3wvd6x4c9z8fjarjjjsl2pjarl0nn70ig6kzswsi";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/gvfs/default.nix b/pkgs/development/libraries/gvfs/default.nix
index 78f507ca1465..238edddaf3ad 100644
--- a/pkgs/development/libraries/gvfs/default.nix
+++ b/pkgs/development/libraries/gvfs/default.nix
@@ -1,38 +1,76 @@
-{ stdenv, fetchurl, pkgconfig, intltool, libtool
-, glib, dbus, udev, libgudev, udisks2, libgcrypt, libcap, polkit
-, libgphoto2, avahi, libarchive, fuse, libcdio, file, bzip2, lzma
-, libxml2, libxslt, docbook_xsl, samba, libmtp
-, gnomeSupport ? false, gnome, makeWrapper }:
+{ stdenv, meson, ninja, fetchurl, pkgconfig, gettext, gnome3
+, glib, libgudev, udisks2, libgcrypt, libcap, polkit
+, libgphoto2, avahi, libarchive, fuse, libcdio
+, libxml2, libxslt, docbook_xsl, docbook_xml_dtd_42, samba, libmtp
+, gnomeSupport ? false, gnome, makeWrapper
+, libimobiledevice, libbluray, libcdio-paranoia, libnfs, openssh
+, libsecret, libgdata
+# Remove when switching back to meson
+, autoreconfHook, lzma, bzip2
+}:
+
+# TODO: switch to meson when upstream fixes a non-deterministic build failure
+# See https://bugzilla.gnome.org/show_bug.cgi?id=794549
+
+# Meson specific things are commented out and annotated, so switching back
+# should simply require deleting autotools specific things and adding back meson
+# flags etc.
 
 let
-  ver_maj = "1.34";
-  version = "${ver_maj}.1";
+  pname = "gvfs";
+  version = "1.36.1";
 in
 stdenv.mkDerivation rec {
-  name = "gvfs-${version}";
+  name = "${pname}-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/gvfs/${ver_maj}/${name}.tar.xz";
-    sha256 = "1d3j6f252mk316hrspwy63inrhxk6l78l4bmlmql401lqapb5yby";
+    url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
+    sha256 = "09phj9kqk8lzcmkjfq7qmzpkj4xp1vg4mskv6d2s9j62hvrxyh1q";
   };
 
+  # Uncomment when switching back to meson
+  # postPatch = ''
+  #   chmod +x meson_post_install.py # patchShebangs requires executable file
+  #   patchShebangs meson_post_install.py
+  # '';
+
   nativeBuildInputs = [
-    pkgconfig intltool libtool file makeWrapper
-    libxml2 libxslt docbook_xsl
+    autoreconfHook # Remove when switching to meson
+    # meson ninja
+    pkgconfig gettext makeWrapper
+    libxml2 libxslt docbook_xsl docbook_xml_dtd_42
   ];
 
   buildInputs =
-    [ glib dbus udev libgudev udisks2 libgcrypt
-      libgphoto2 avahi libarchive fuse libcdio lzma bzip2
-      samba libmtp libcap polkit
+    [ glib libgudev udisks2 libgcrypt
+      libgphoto2 avahi libarchive fuse libcdio
+      samba libmtp libcap polkit libimobiledevice libbluray
+      libcdio-paranoia libnfs openssh
+      # Remove when switching back to meson
+      lzma bzip2
       # ToDo: a ligther version of libsoup to have FTP/HTTP support?
     ] ++ stdenv.lib.optionals gnomeSupport (with gnome; [
-      libsoup libgnome_keyring gconf gcr
-      # ToDo: not working and probably useless until gnome3 from x-updates
+      libsoup gcr
+      gnome-online-accounts libsecret libgdata
     ]);
 
+  # Remove when switching back to meson
   configureFlags = stdenv.lib.optional (!gnomeSupport) "--disable-gcr";
 
+  # Uncomment when switching back to meson
+  # mesonFlags = [
+  #   "-Dgio_module_dir=lib/gio/modules"
+  #   "-Dsystemduserunitdir=lib/systemd/user"
+  #   "-Ddbus_service_dir=share/dbus-1/services"
+  #   "-Dtmpfilesdir=no"
+  # ] ++ stdenv.lib.optionals (!gnomeSupport) [
+  #   "-Dgcr=false" "-Dgoa=false" "-Dkeyring=false" "-Dhttp=false"
+  #   "-Dgoogle=false"
+  # ] ++ stdenv.lib.optionals (samba == null) [
+  #   # Xfce don't want samba
+  #   "-Dsmb=false"
+  # ];
+
   enableParallelBuilding = true;
 
   preFixup = ''
@@ -43,9 +81,16 @@ stdenv.mkDerivation rec {
     done
   '';
 
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+    };
+  };
+
   meta = with stdenv.lib; {
     description = "Virtual Filesystem support library" + optionalString gnomeSupport " (full GNOME support)";
+    license = licenses.lgpl2Plus;
     platforms = platforms.linux;
-    maintainers = [ maintainers.lethalman ];
+    maintainers = [ maintainers.lethalman ] ++ gnome3.maintainers;
   };
 }
diff --git a/pkgs/development/libraries/harfbuzz/default.nix b/pkgs/development/libraries/harfbuzz/default.nix
index f5756d1f5702..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.5.1";
+  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 = "56838dfdad2729b8866763c82d623354d138a4d99d9ffb710c7d377b5cfc7c51";
+    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/herqq/default.nix b/pkgs/development/libraries/herqq/default.nix
index 8f1aadc3a26e..75dd8693d2cf 100644
--- a/pkgs/development/libraries/herqq/default.nix
+++ b/pkgs/development/libraries/herqq/default.nix
@@ -15,10 +15,10 @@ stdenv.mkDerivation rec {
     sha256 = "1w674rbwbhpirq70gp9rk6p068j36rwn112fx3nz613wgw63x84m";
   };
 
-  meta = {
+  meta = with stdenv.lib; {
     homepage = http://herqq.org;
     description = "A software library for building UPnP devices and control points";
-    inherit (qt5.qtbase.meta) platforms;
+    platforms = platforms.linux;
     maintainers = [ ];
   };
 }
diff --git a/pkgs/development/libraries/hivex/default.nix b/pkgs/development/libraries/hivex/default.nix
index 7b4b9866d041..b2e2dbd35a40 100644
--- a/pkgs/development/libraries/hivex/default.nix
+++ b/pkgs/development/libraries/hivex/default.nix
@@ -3,11 +3,11 @@
 
 stdenv.mkDerivation rec {
   name = "hivex-${version}";
-  version = "1.3.14";
+  version = "1.3.15";
 
   src = fetchurl {
     url = "http://libguestfs.org/download/hivex/${name}.tar.gz";
-    sha256 = "0aqv28prjcmc66znw0wgaxjijg5mjm44bgn1iil8a4dlbsgv4p7b";
+    sha256 = "02vzipzrp1gr87rn7mkhyzr4zdjkp2dzcvvb223x7i0ch8ci7r4c";
   };
 
   patches = [ ./hivex-syms.patch ];
diff --git a/pkgs/development/libraries/hpx/default.nix b/pkgs/development/libraries/hpx/default.nix
index 6b08a0fd86f7..edb1dc01aa80 100644
--- a/pkgs/development/libraries/hpx/default.nix
+++ b/pkgs/development/libraries/hpx/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "hpx-${version}";
-  version = "1.0.0";
+  version = "1.1.0";
 
   src = fetchFromGitHub {
     owner = "STEllAR-GROUP";
     repo = "hpx";
     rev = "${version}";
-    sha256 = "0k79gw4c0v4i7ps1hw6x4m7svxbfml5xm6ly7p00dvg7z9521zsk";
+    sha256 = "0xlhnycmpy2jgiqyzpwmkdrl6drf46ywdsl0qm4vksvjxqfgk9z3";
   };
 
   buildInputs = [ boost hwloc gperftools ];
diff --git a/pkgs/development/libraries/http-parser/default.nix b/pkgs/development/libraries/http-parser/default.nix
index 60a1435462b7..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.7.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 = "0rqij6v6wv1giwx4prfa082kw1nka5d9vlb06zkc8mwszq1vzidh";
+    sha256 = "15ids8k2f0xhnnxh4m85w2f78pg5ndiwrpl24kyssznnp1l5yqai";
   };
 
   patches = [ ./build-shared.patch ];
diff --git a/pkgs/development/libraries/hunspell/default.nix b/pkgs/development/libraries/hunspell/default.nix
index dfb45aa598d7..ecbfbb7da0b8 100644
--- a/pkgs/development/libraries/hunspell/default.nix
+++ b/pkgs/development/libraries/hunspell/default.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, ncurses, readline, autoreconfHook }:
 
 stdenv.mkDerivation rec {
-  version = "1.6.1";
+  version = "1.6.2";
   name = "hunspell-${version}";
 
   src = fetchurl {
     url = "https://github.com/hunspell/hunspell/archive/v${version}.tar.gz";
-    sha256 = "0j9c20sj7bgd6f77193g1ihy8w905byk2gdhdc0r9dsh7irr7x9h";
+    sha256 = "1i7lsv2cm0713ia3j5wjkcrhpfp3lqpjpwp4d3v18n7ycaqcxn9w";
   };
 
   outputs = [ "bin" "dev" "out" "man" ];
diff --git a/pkgs/development/libraries/hunspell/dictionaries.nix b/pkgs/development/libraries/hunspell/dictionaries.nix
index 37c00f3e2aa8..ee8a5107b341 100644
--- a/pkgs/development/libraries/hunspell/dictionaries.nix
+++ b/pkgs/development/libraries/hunspell/dictionaries.nix
@@ -1,6 +1,6 @@
 /* hunspell dictionaries */
 
-{ stdenv, fetchurl, fetchFromGitHub, unzip, coreutils, bash, which, zip }:
+{ stdenv, fetchurl, fetchFromGitHub, unzip, coreutils, bash, which, zip, ispell, perl, hunspell }:
 
 
 let
@@ -61,6 +61,51 @@ let
       '';
     };
 
+  mkDictFromDSSO =
+    { shortName, shortDescription, dictFileName }:
+    mkDict rec {
+      inherit dictFileName;
+      version = "2.40";
+      # Should really use a string function or something
+      _version = "2-40";
+      name = "hunspell-dict-${shortName}-dsso-${version}";
+      _name = "ooo_swedish_dict_${_version}";
+      readmeFile = "LICENSE_en_US.txt";
+      src = fetchurl {
+        url = "https://extensions.libreoffice.org/extensions/swedish-spelling-dictionary-den-stora-svenska-ordlistan/${version}/@@download/file/${_name}.oxt";
+        sha256 = "b982881cc75f5c4af1199535bd4735ee476bdc48edf63e3f05fb4f715654a7bc";
+      };
+      meta = with stdenv.lib; {
+        longDescription = ''
+        Svensk ordlista baserad på DSSO (den stora svenska ordlistan) och Göran
+        Anderssons (goran@init.se) arbete med denna. Ordlistan hämtas från
+        LibreOffice då dsso.se inte längre verkar vara med oss.
+        '';
+        description = "Hunspell dictionary for ${shortDescription} from LibreOffice";
+        license = licenses.lgpl3;
+        platforms = platforms.all;
+      };
+      buildInputs = [ unzip ];
+      phases = "unpackPhase installPhase";
+      sourceRoot = ".";
+      unpackCmd = ''
+      unzip $src dictionaries/${dictFileName}.dic dictionaries/${dictFileName}.aff $readmeFile
+      '';
+      installPhase = ''
+        # hunspell dicts
+        install -dm755 "$out/share/hunspell"
+        install -m644 dictionaries/${dictFileName}.dic "$out/share/hunspell/"
+        install -m644 dictionaries/${dictFileName}.aff "$out/share/hunspell/"
+        # myspell dicts symlinks
+        install -dm755 "$out/share/myspell/dicts"
+        ln -sv "$out/share/hunspell/${dictFileName}.dic" "$out/share/myspell/dicts/"
+        ln -sv "$out/share/hunspell/${dictFileName}.aff" "$out/share/myspell/dicts/"
+        # docs
+        install -dm755 "$out/share/doc"
+        install -m644 ${readmeFile} $out/share/doc/${name}.txt
+      '';
+    };
+
   mkDictFromDicollecte =
     { shortName, shortDescription, longDescription, dictFileName }:
     mkDict rec {
@@ -168,6 +213,42 @@ let
       };
     };
 
+  mkDictFromJ3e =
+    { shortName, shortDescription, dictFileName }:
+    stdenv.mkDerivation rec {
+      name = "hunspell-dict-${shortName}-j3e-${version}";
+      version = "20161207";
+
+      src = fetchurl {
+        url = "https://j3e.de/ispell/igerman98/dict/igerman98-${version}.tar.bz2";
+        sha256 = "1a3055hp2bc4q4nlg3gmg0147p3a1zlfnc65xiv2v9pyql1nya8p";
+      };
+
+      buildInputs = [ ispell perl hunspell ];
+
+      phases = ["unpackPhase" "installPhase"];
+      installPhase = ''
+        patchShebangs bin
+        make hunspell/${dictFileName}.aff hunspell/${dictFileName}.dic
+        # hunspell dicts
+        install -dm755 "$out/share/hunspell"
+        install -m644 hunspell/${dictFileName}.dic "$out/share/hunspell/"
+        install -m644 hunspell/${dictFileName}.aff "$out/share/hunspell/"
+        # myspell dicts symlinks
+        install -dm755 "$out/share/myspell/dicts"
+        ln -sv "$out/share/hunspell/${dictFileName}.dic" "$out/share/myspell/dicts/"
+        ln -sv "$out/share/hunspell/${dictFileName}.aff" "$out/share/myspell/dicts/"
+      '';
+
+      meta = with stdenv.lib; {
+        homepage = https://www.j3e.de/ispell/igerman98/index_en.html;
+        description = shortDescription;
+        license = with licenses; [ gpl2 gpl3 ];
+        maintainers = with maintainers; [ timor ];
+        platforms = platforms.all;
+      };
+    };
+
 in {
 
   /* ENGLISH */
@@ -427,4 +508,39 @@ in {
       })
     ];
   };
+
+  /* SWEDISH */
+  
+  sv-se = mkDictFromDSSO rec {
+    shortName = "sv-se";
+    dictFileName = "sv_SE";
+    shortDescription = "Swedish (Sweden)";
+  };
+
+  # Finlandian Swedish (hello Linus Torvalds)
+  sv-fi = mkDictFromDSSO rec {
+    shortName = "sv-fi";
+    dictFileName = "sv_FI";
+    shortDescription = "Swedish (Finland)";
+  };
+  
+  /* GERMAN */
+
+  de-de = mkDictFromJ3e {
+    shortName = "de-de";
+    shortDescription = "German (Germany)";
+    dictFileName = "de_DE";
+  };
+
+  de-at = mkDictFromJ3e {
+    shortName = "de-at";
+    shortDescription = "German (Austria)";
+    dictFileName = "de_AT";
+  };
+
+  de-ch = mkDictFromJ3e {
+    shortName = "de-ch";
+    shortDescription = "German (Switzerland)";
+    dictFileName = "de_CH";
+  };
 }
diff --git a/pkgs/development/libraries/hwloc/default.nix b/pkgs/development/libraries/hwloc/default.nix
index e1acacc328cc..ad39a4fde319 100644
--- a/pkgs/development/libraries/hwloc/default.nix
+++ b/pkgs/development/libraries/hwloc/default.nix
@@ -1,16 +1,23 @@
-{ stdenv, fetchurl, pkgconfig, cairo, expat, ncurses, libX11
-, pciutils, numactl }:
+{ stdenv, fetchurl, pkgconfig, expat, ncurses, pciutils, numactl
+, x11Support ? false, libX11 ? null, cairo ? null
+}:
+
+assert x11Support -> libX11 != null && cairo != null;
 
 with stdenv.lib;
 
 stdenv.mkDerivation rec {
-  name = "hwloc-1.11.6";
+  name = "hwloc-1.11.9";
 
   src = fetchurl {
     url = "http://www.open-mpi.org/software/hwloc/v1.11/downloads/${name}.tar.bz2";
-    sha256 = "1yl7dm2qplwmnidd712zy12qfvxk28k8ccs694n42ybwdjwzg1bn";
+    sha256 = "0r2im1s5lp7zjwqalcqcnlxx0dsky1bnx5waf2r3rmj888c36hrr";
   };
 
+  configureFlags = [
+    "--localstatedir=/var"
+  ];
+
   # XXX: libX11 is not directly needed, but needed as a propagated dep of Cairo.
   nativeBuildInputs = [ pkgconfig ];
 
@@ -18,7 +25,7 @@ stdenv.mkDerivation rec {
   # derivation and set optional dependencies to `null'.
   buildInputs = stdenv.lib.filter (x: x != null)
    ([ expat ncurses ]
-     ++  (optionals (!stdenv.isCygwin) [ cairo libX11 ])
+     ++  (optionals x11Support [ cairo libX11 ])
      ++  (optionals stdenv.isLinux [ numactl ]));
 
   propagatedBuildInputs =
@@ -37,7 +44,7 @@ stdenv.mkDerivation rec {
              test -d "$numalibdir"
          fi
 
-         sed -i "$out/lib/libhwloc.la" \
+         sed -i "$lib/lib/libhwloc.la" \
              -e "s|-lnuma|-L$numalibdir -lnuma|g"
       '';
 
@@ -45,6 +52,8 @@ stdenv.mkDerivation rec {
   # fail on some build machines.
   doCheck = false;
 
+  outputs = [ "out" "lib" "dev" "doc" "man" ];
+
   meta = {
     description = "Portable abstraction of hierarchical architectures for high-performance computing";
     longDescription = ''
@@ -65,8 +74,8 @@ stdenv.mkDerivation rec {
 
     # http://www.open-mpi.org/projects/hwloc/license.php
     license = licenses.bsd3;
-    homepage = http://www.open-mpi.org/projects/hwloc/;
-    maintainers = [ ];
+    homepage = https://www.open-mpi.org/projects/hwloc/;
+    maintainers = with maintainers; [ fpletz ];
     platforms = platforms.all;
   };
 }
diff --git a/pkgs/development/libraries/icu/58.nix b/pkgs/development/libraries/icu/58.nix
index e5b80f4b2700..f7763ba49da1 100644
--- a/pkgs/development/libraries/icu/58.nix
+++ b/pkgs/development/libraries/icu/58.nix
@@ -1,4 +1,4 @@
-args @ { stdenv, fetchurl, fetchpatch, fixDarwinDylibNames }:
+fetchurl:
 let
   keywordFix = fetchurl {
     url = "http://bugs.icu-project.org/trac/changeset/39484?format=diff";
@@ -11,4 +11,4 @@ import ./base.nix {
   sha256 = "036shcb3f8bm1lynhlsb4kpjm9s9c2vdiir01vg216rs2l8482ib";
   patches = [ keywordFix ];
   patchFlags = "-p4";
-} args
+}
diff --git a/pkgs/development/libraries/icu/60.nix b/pkgs/development/libraries/icu/60.nix
new file mode 100644
index 000000000000..e56135b15c62
--- /dev/null
+++ b/pkgs/development/libraries/icu/60.nix
@@ -0,0 +1,4 @@
+import ./base.nix {
+  version = "60.2";
+  sha256 = "065l3n0q9wqaw8dz20x82srshhm6i987fr9ync5xf9mr6n7ylwzh";
+}
diff --git a/pkgs/development/libraries/icu/base.nix b/pkgs/development/libraries/icu/base.nix
index 78e0c5740446..87551ee6ee03 100644
--- a/pkgs/development/libraries/icu/base.nix
+++ b/pkgs/development/libraries/icu/base.nix
@@ -1,55 +1,95 @@
 { version, sha256, patches ? [], patchFlags ? "" }:
-{ stdenv, fetchurl, fetchpatch, fixDarwinDylibNames }:
+{ stdenv, fetchurl, fetchpatch, fixDarwinDylibNames
+  # Cross-compiled icu4c requires a build-root of a native compile
+, buildRootOnly ? false, nativeBuildRoot, buildPlatform, hostPlatform
+}:
 
 let
   pname = "icu4c";
-in
-stdenv.mkDerivation {
-  name = pname + "-" + version;
 
-  src = fetchurl {
-    url = "http://download.icu-project.org/files/${pname}/${version}/${pname}-"
-      + (stdenv.lib.replaceChars ["."] ["_"] version) + "-src.tgz";
-    inherit sha256;
-  };
+  baseAttrs = {
+    src = fetchurl {
+      url = "http://download.icu-project.org/files/${pname}/${version}/${pname}-"
+        + (stdenv.lib.replaceChars ["."] ["_"] version) + "-src.tgz";
+      inherit sha256;
+    };
+
+    postUnpack = ''
+      sourceRoot=''${sourceRoot}/source
+      echo Source root reset to ''${sourceRoot}
+    '';
+
+    # https://sourceware.org/glibc/wiki/Release/2.26#Removal_of_.27xlocale.h.27
+    postPatch = if (stdenv.hostPlatform.libc == "glibc" || stdenv.hostPlatform.libc == "musl")
+      then "substituteInPlace i18n/digitlst.cpp --replace '<xlocale.h>' '<locale.h>'"
+      else null; # won't find locale_t on darwin
+
+    inherit patchFlags patches;
+
+    preConfigure = ''
+      sed -i -e "s|/bin/sh|${stdenv.shell}|" configure
 
-  outputs = [ "out" "dev" ];
-  outputBin = "dev";
+      # $(includedir) is different from $(prefix)/include due to multiple outputs
+      sed -i -e 's|^\(CPPFLAGS = .*\) -I\$(prefix)/include|\1 -I$(includedir)|' config/Makefile.inc.in
+    '' + stdenv.lib.optionalString stdenv.isArm ''
+      # From https://archlinuxarm.org/packages/armv7h/icu/files/icudata-stdlibs.patch
+      sed -e 's/LDFLAGSICUDT=-nodefaultlibs -nostdlib/LDFLAGSICUDT=/' -i config/mh-linux
+    '';
 
-  # FIXME: This fixes dylib references in the dylibs themselves, but
-  # not in the programs in $out/bin.
-  buildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
+    configureFlags = "--disable-debug" +
+      stdenv.lib.optionalString (stdenv.isFreeBSD || stdenv.isDarwin) " --enable-rpath" +
+      stdenv.lib.optionalString (buildPlatform != hostPlatform) " --with-cross-build=${nativeBuildRoot}";
 
-  postUnpack = ''
-    sourceRoot=''${sourceRoot}/source
-    echo Source root reset to ''${sourceRoot}
-  '';
+    enableParallelBuilding = true;
 
-  inherit patchFlags patches;
+    meta = with stdenv.lib; {
+      description = "Unicode and globalization support library";
+      homepage = http://site.icu-project.org/;
+      maintainers = with maintainers; [ raskin ];
+      platforms = platforms.all;
+    };
+  };
+
+  realAttrs = baseAttrs // {
+    name = pname + "-" + version;
+
+    outputs = [ "out" "dev" ];
+    outputBin = "dev";
 
-  preConfigure = ''
-    sed -i -e "s|/bin/sh|${stdenv.shell}|" configure
-  '' + stdenv.lib.optionalString stdenv.isArm ''
-    # From https://archlinuxarm.org/packages/armv7h/icu/files/icudata-stdlibs.patch
-    sed -e 's/LDFLAGSICUDT=-nodefaultlibs -nostdlib/LDFLAGSICUDT=/' -i config/mh-linux
-  '';
+    # FIXME: This fixes dylib references in the dylibs themselves, but
+    # not in the programs in $out/bin.
+    buildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
-  configureFlags = "--disable-debug" +
-    stdenv.lib.optionalString (stdenv.isFreeBSD || stdenv.isDarwin) " --enable-rpath";
+    # remove dependency on bootstrap-tools in early stdenv build
+    postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
+      sed -i 's/INSTALL_CMD=.*install/INSTALL_CMD=install/' $out/lib/icu/${version}/pkgdata.inc
+    '' + ''
+      substituteInPlace "$dev/bin/icu-config" \
+        --replace \''${pkglibdir}/Makefile.inc "$dev/lib/icu/Makefile.inc"
+    '';
 
-  # remove dependency on bootstrap-tools in early stdenv build
-  postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
-    sed -i 's/INSTALL_CMD=.*install/INSTALL_CMD=install/' $out/lib/icu/${version}/pkgdata.inc
-  '';
+    postFixup = ''moveToOutput lib/icu "$dev" '';
+  };
 
-  postFixup = ''moveToOutput lib/icu "$dev" '';
+  buildRootOnlyAttrs = baseAttrs // {
+    name = pname + "-build-root-" + version;
 
-  enableParallelBuilding = true;
+    preConfigure = baseAttrs.preConfigure + ''
+      mkdir build
+      cd build
+      configureScript=../configure
+    '';
 
-  meta = with stdenv.lib; {
-    description = "Unicode and globalization support library";
-    homepage = http://site.icu-project.org/;
-    maintainers = with maintainers; [ raskin ];
-    platforms = platforms.all;
+    postBuild = ''
+      cd ..
+      mv build $out
+      echo "Doing build-root only, exiting now" >&2
+      exit 0
+    '';
   };
-}
+
+  attrs = if buildRootOnly
+            then buildRootOnlyAttrs
+          else realAttrs;
+in
+stdenv.mkDerivation attrs
diff --git a/pkgs/development/libraries/idnkit/default.nix b/pkgs/development/libraries/idnkit/default.nix
index 4cee28630935..442da700f345 100644
--- a/pkgs/development/libraries/idnkit/default.nix
+++ b/pkgs/development/libraries/idnkit/default.nix
@@ -1,11 +1,12 @@
 { stdenv, fetchurl, libiconv }:
 
 stdenv.mkDerivation rec {
-  name = "idnkit-1.0";
+  name = "idnkit-${version}";
+  version = "2.3";
 
   src = fetchurl {
-    url = "http://www.nic.ad.jp/ja/idn/idnkit/download/sources/${name}-src.tar.gz";
-    sha256 = "1z4i6fmyv67sflmjg763ymcxrcv84rbj1kv15im0s655h775zk8n";
+    url = "https://jprs.co.jp/idn/${name}.tar.bz2";
+    sha256 = "0zp9yc84ff5s0g2i6v9yfyza2n2x4xh0kq7hjd3anhh0clbp3l16";
   };
 
   buildInputs = [ libiconv ];
diff --git a/pkgs/development/libraries/ignition-math/default.nix b/pkgs/development/libraries/ignition-math/default.nix
index 66b21b6fae6c..867ce024d2fe 100644
--- a/pkgs/development/libraries/ignition-math/default.nix
+++ b/pkgs/development/libraries/ignition-math/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
   '';
 
   meta = with stdenv.lib; {
-    homepage = http://ignitionrobotics.org/libraries/math;
+    homepage = https://ignitionrobotics.org/libraries/math;
     description = "Math library by Ingition Robotics, created for the Gazebo project";
     license = licenses.asl20;
     maintainers = with maintainers; [ pxc ];
diff --git a/pkgs/development/libraries/ignition-transport/generic.nix b/pkgs/development/libraries/ignition-transport/generic.nix
index 8206338fb080..3568edb7890c 100644
--- a/pkgs/development/libraries/ignition-transport/generic.nix
+++ b/pkgs/development/libraries/ignition-transport/generic.nix
@@ -21,10 +21,11 @@ stdenv.mkDerivation rec {
   '';
 
   meta = with stdenv.lib; {
-    homepage = http://ignitionrobotics.org/libraries/math;
+    homepage = https://ignitionrobotics.org/libraries/math;
     description = "Math library by Ingition Robotics, created for the Gazebo project";
     license = licenses.asl20;
     maintainers = with maintainers; [ pxc ];
     platforms = platforms.all;
+    broken = true; # 2018-04-10
   };
 }
diff --git a/pkgs/development/libraries/ilmbase/default.nix b/pkgs/development/libraries/ilmbase/default.nix
index 21c2c46105e5..956a8667be5f 100644
--- a/pkgs/development/libraries/ilmbase/default.nix
+++ b/pkgs/development/libraries/ilmbase/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, automake, autoconf, libtool, which }:
 
 stdenv.mkDerivation rec {
-  name = "ilmbase-2.2.0";
+  name = "ilmbase-2.2.1";
 
   src = fetchurl {
     url = "http://download.savannah.nongnu.org/releases/openexr/${name}.tar.gz";
-    sha256 = "1izddjwbh1grs8080vmaix72z469qy29wrvkphgmqmcm0sv1by7c";
+    sha256 = "17k0hq19wplx9s029kjrq6c51x2ryrfmaavcappkd0g67gk0dhna";
   };
 
   outputs = [ "out" "dev" ];
diff --git a/pkgs/development/libraries/imlib2/default.nix b/pkgs/development/libraries/imlib2/default.nix
index 54c70197af4d..18b42ea4b4fa 100644
--- a/pkgs/development/libraries/imlib2/default.nix
+++ b/pkgs/development/libraries/imlib2/default.nix
@@ -5,11 +5,11 @@
 with stdenv.lib;
 
 stdenv.mkDerivation rec {
-  name = "imlib2-1.4.10";
+  name = "imlib2-1.5.0";
 
   src = fetchurl {
     url = "mirror://sourceforge/enlightenment/${name}.tar.bz2";
-    sha256 = "0wm2q2xlkbm71k7mw2jyzbxgzylrkcj5yh6nq58w5gybhp98qs9z";
+    sha256 = "0kg28b5wp886hiy12v7abdybrvlymb7g3nvg0ysn2y8h883s5w8m";
   };
 
   buildInputs = [ libjpeg libtiff giflib libpng bzip2 freetype libid3tag ]
diff --git a/pkgs/development/libraries/indicator-application/gtk2.nix b/pkgs/development/libraries/indicator-application/gtk2.nix
index b4fea7c1fa4a..36b637c62bb2 100644
--- a/pkgs/development/libraries/indicator-application/gtk2.nix
+++ b/pkgs/development/libraries/indicator-application/gtk2.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, lib, file
 , pkgconfig, autoconf
-, glib, dbus_glib, json_glib
+, glib, dbus-glib, json-glib
 , gtk2, libindicator-gtk2, libdbusmenu-gtk2, libappindicator-gtk2 }:
 
 with lib;
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ pkgconfig autoconf ];
 
   buildInputs = [
-    glib dbus_glib json_glib
+    glib dbus-glib json-glib
     gtk2 libindicator-gtk2 libdbusmenu-gtk2 libappindicator-gtk2
   ];
 
diff --git a/pkgs/development/libraries/indicator-application/gtk3.nix b/pkgs/development/libraries/indicator-application/gtk3.nix
index 03afd6f1e878..3d7c20691ab5 100644
--- a/pkgs/development/libraries/indicator-application/gtk3.nix
+++ b/pkgs/development/libraries/indicator-application/gtk3.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, lib, file
 , pkgconfig, autoconf
-, glib, dbus_glib, json_glib
+, glib, dbus-glib, json-glib
 , gtk3, libindicator-gtk3, libdbusmenu-gtk3, libappindicator-gtk3 }:
 
 with lib;
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ pkgconfig autoconf ];
 
   buildInputs = [
-    glib dbus_glib json_glib
+    glib dbus-glib json-glib
     gtk3 libindicator-gtk3 libdbusmenu-gtk3 libappindicator-gtk3
   ];
 
diff --git a/pkgs/development/libraries/iniparser/default.nix b/pkgs/development/libraries/iniparser/default.nix
index a09bcd6f039c..8beda8663c5c 100644
--- a/pkgs/development/libraries/iniparser/default.nix
+++ b/pkgs/development/libraries/iniparser/default.nix
@@ -1,27 +1,26 @@
 { stdenv, fetchFromGitHub }:
 
-let
-  inherit (stdenv.lib) optional;
-
-in stdenv.mkDerivation rec {
+stdenv.mkDerivation rec {
   name = "iniparser-${version}";
-  version = "4.0";
+  version = "4.1";
 
   src = fetchFromGitHub {
     owner = "ndevilla";
     repo = "iniparser";
     rev = "v${version}";
-    sha256 = "0339qa0qxa5z02xjcs5my8v91v0r9jm4piswrl1sa29kwyxgv5nb";
+    sha256 = "0dhab6pad6wh816lr7r3jb6z273njlgw2vpw8kcfnmi7ijaqhnr5";
   };
 
   patches = ./no-usr.patch;
 
+  postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
+    substituteInPlace Makefile \
+        --replace -Wl,-soname= -Wl,-install_name,
+  '';
+
   doCheck = true;
   preCheck = "patchShebangs test/make-tests.sh";
 
-  # TODO: Build dylib on Darwin
-  buildFlags = (if stdenv.isDarwin then [ "libiniparser.a" ] else [ "libiniparser.so" ]) ++ [ "CC=cc" ];
-
   installPhase = ''
     mkdir -p $out/lib
 
@@ -34,17 +33,16 @@ in stdenv.mkDerivation rec {
     done;
     cp -r html $out/share/doc/${name}
 
-  '' + (if stdenv.isDarwin then ''
     cp libiniparser.a $out/lib
-  '' else ''
-    cp libiniparser.so.0 $out/lib
-    ln -s libiniparser.so.0 $out/lib/libiniparser.so
-  '');
+    cp libiniparser.so.1 $out/lib
+    ln -s libiniparser.so.1 $out/lib/libiniparser.so
+  '';
 
-  meta = {
+  meta = with stdenv.lib; {
     inherit (src.meta) homepage;
     description = "Free standalone ini file parsing library";
-    license = stdenv.lib.licenses.mit;
-    platforms = stdenv.lib.platforms.unix;
+    license = licenses.mit;
+    platforms = platforms.unix;
+    maintainers = [ maintainers.primeos ];
   };
 }
diff --git a/pkgs/development/libraries/ip2location-c/default.nix b/pkgs/development/libraries/ip2location-c/default.nix
index 109510df79b1..82a4ec337555 100644
--- a/pkgs/development/libraries/ip2location-c/default.nix
+++ b/pkgs/development/libraries/ip2location-c/default.nix
@@ -28,6 +28,5 @@ stdenv.mkDerivation rec {
     homepage = http://www.ip2location.com/developers/c-7;
     license = with licenses; [ gpl3Plus lgpl3Plus ];
     platforms = platforms.linux;
-    maintainers = with maintainers; [ nckx ];
   };
 }
diff --git a/pkgs/development/libraries/irrlicht/default.nix b/pkgs/development/libraries/irrlicht/default.nix
index 336f446cdf10..d28ae012e574 100644
--- a/pkgs/development/libraries/irrlicht/default.nix
+++ b/pkgs/development/libraries/irrlicht/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchzip, mesa, unzip, libXrandr, libX11, libXxf86vm }:
+{ stdenv, fetchzip, libGLU_combined, unzip, libXrandr, libX11, libXxf86vm }:
 
 
 stdenv.mkDerivation rec {
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
     mkdir -p $out/lib
   '';
 
-  buildInputs = [ unzip mesa libXrandr libX11 libXxf86vm ];
+  buildInputs = [ unzip libGLU_combined libXrandr libX11 libXxf86vm ];
 
   meta = {
     homepage = http://irrlicht.sourceforge.net/;
diff --git a/pkgs/development/libraries/isl/0.11.1.nix b/pkgs/development/libraries/isl/0.11.1.nix
index 63140dba37f7..cdb018d297b6 100644
--- a/pkgs/development/libraries/isl/0.11.1.nix
+++ b/pkgs/development/libraries/isl/0.11.1.nix
@@ -4,7 +4,7 @@ stdenv.mkDerivation rec {
   name = "isl-0.11.1"; # CLooG 0.16.3 fails to build with ISL 0.08.
 
   src = fetchurl {
-    url = "http://pkgs.fedoraproject.org/repo/pkgs/gcc/isl-0.11.1.tar.bz2/bce1586384d8635a76d2f017fb067cd2/isl-0.11.1.tar.bz2";
+    url = "http://src.fedoraproject.org/repo/pkgs/gcc/isl-0.11.1.tar.bz2/bce1586384d8635a76d2f017fb067cd2/isl-0.11.1.tar.bz2";
     sha256 = "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9";
   };
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   enableParallelBuilding = true;
 
   meta = {
-    homepage = http://www.kotnet.org/~skimo/isl/;
+    homepage = https://www.kotnet.org/~skimo/isl/;
     license = stdenv.lib.licenses.lgpl21;
     description = "A library for manipulating sets and relations of integer points bounded by linear constraints";
     platforms = stdenv.lib.platforms.all;
diff --git a/pkgs/development/libraries/isl/0.12.2.nix b/pkgs/development/libraries/isl/0.12.2.nix
index d7143b8747ee..880f91fccedc 100644
--- a/pkgs/development/libraries/isl/0.12.2.nix
+++ b/pkgs/development/libraries/isl/0.12.2.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   enableParallelBuilding = true;
 
   meta = {
-    homepage = http://www.kotnet.org/~skimo/isl/;
+    homepage = https://www.kotnet.org/~skimo/isl/;
     license = stdenv.lib.licenses.lgpl21;
     description = "A library for manipulating sets and relations of integer points bounded by linear constraints";
     platforms = stdenv.lib.platforms.all;
diff --git a/pkgs/development/libraries/isl/0.14.1.nix b/pkgs/development/libraries/isl/0.14.1.nix
index 8196dec283ac..1ff4b7ec18a0 100644
--- a/pkgs/development/libraries/isl/0.14.1.nix
+++ b/pkgs/development/libraries/isl/0.14.1.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   enableParallelBuilding = true;
 
   meta = {
-    homepage = http://www.kotnet.org/~skimo/isl/;
+    homepage = https://www.kotnet.org/~skimo/isl/;
     license = stdenv.lib.licenses.lgpl21;
     description = "A library for manipulating sets and relations of integer points bounded by linear constraints";
     platforms = stdenv.lib.platforms.all;
diff --git a/pkgs/development/libraries/isl/0.15.0.nix b/pkgs/development/libraries/isl/0.15.0.nix
index eca3372ad4d0..8b6080c2880a 100644
--- a/pkgs/development/libraries/isl/0.15.0.nix
+++ b/pkgs/development/libraries/isl/0.15.0.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   enableParallelBuilding = true;
 
   meta = {
-    homepage = http://www.kotnet.org/~skimo/isl/;
+    homepage = https://www.kotnet.org/~skimo/isl/;
     license = stdenv.lib.licenses.lgpl21;
     description = "A library for manipulating sets and relations of integer points bounded by linear constraints";
     platforms = stdenv.lib.platforms.all;
diff --git a/pkgs/development/libraries/isl/0.17.1.nix b/pkgs/development/libraries/isl/0.17.1.nix
index 2136969c0752..59d4d38ce574 100644
--- a/pkgs/development/libraries/isl/0.17.1.nix
+++ b/pkgs/development/libraries/isl/0.17.1.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   enableParallelBuilding = true;
 
   meta = {
-    homepage = http://www.kotnet.org/~skimo/isl/;
+    homepage = https://www.kotnet.org/~skimo/isl/;
     license = stdenv.lib.licenses.lgpl21;
     description = "A library for manipulating sets and relations of integer points bounded by linear constraints";
     platforms = stdenv.lib.platforms.all;
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/itk/default.nix b/pkgs/development/libraries/itk/default.nix
index 3865aa226f9a..5280a95afb40 100644
--- a/pkgs/development/libraries/itk/default.nix
+++ b/pkgs/development/libraries/itk/default.nix
@@ -1,25 +1,20 @@
 { stdenv, fetchurl, fetchpatch, cmake, libX11, libuuid, xz, vtk }:
 
 stdenv.mkDerivation rec {
-  name = "itk-4.11.0";
+  name = "itk-4.13.0";
 
   src = fetchurl {
-    url = mirror://sourceforge/itk/InsightToolkit-4.11.0.tar.xz;
-    sha256 = "0axvyds0gads5914g0m70z5q16gzghr0rk0hy3qjpf1k9bkxvcq6";
+    url = mirror://sourceforge/itk/InsightToolkit-4.13.0.tar.xz;
+    sha256 = "09d1gmqx3wbdfgwf7r91r12m2vknviv0i8wxwh2q9w1vrpizrczy";
   };
 
-  # Clang 4 dislikes signed comparisons of pointers against integers. Should no longer be
-  # necessary once we get past ITK 4.11.
-  patches = [ (fetchpatch {
-    url    = "https://github.com/InsightSoftwareConsortium/ITK/commit/d1407a55910ad9c232f3d241833cfd2e59024946.patch";
-    sha256 = "0h851afkv23fwgkibjss30fkbz4nkfg6rmmm4pfvkwpml23gzz7s";
-  }) ];
-
   cmakeFlags = [
     "-DBUILD_TESTING=OFF"
     "-DBUILD_EXAMPLES=OFF"
     "-DBUILD_SHARED_LIBS=ON"
+    "-DModule_ITKMINC=ON"
     "-DModule_ITKIOMINC=ON"
+    "-DModule_ITKIOTransformMINC=ON"
     "-DModule_ITKVtkGlue=ON"
     "-DModule_ITKReview=ON"
   ];
diff --git a/pkgs/development/libraries/jama/default.nix b/pkgs/development/libraries/jama/default.nix
index 55f44df2b4f3..36eedadc4c2e 100644
--- a/pkgs/development/libraries/jama/default.nix
+++ b/pkgs/development/libraries/jama/default.nix
@@ -5,7 +5,7 @@ stdenv.mkDerivation rec {
   version = "1.2.5";
   
   src = fetchurl {
-    url = http://math.nist.gov/tnt/jama125.zip;
+    url = https://math.nist.gov/tnt/jama125.zip;
     sha256 = "031ns526fvi2nv7jzzv02i7i5sjcyr0gj884i3an67qhsx8vyckl";
   };
 
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
   '';
 
   meta = {
-    homepage = http://math.nist.gov/tnt/;
+    homepage = https://math.nist.gov/tnt/;
     description = "JAMA/C++ Linear Algebra Package: Java-like matrix C++ templates";
     platforms = stdenv.lib.platforms.unix;
   };
diff --git a/pkgs/development/libraries/jansson/default.nix b/pkgs/development/libraries/jansson/default.nix
index 2fbb2e3948ce..b1167efdfee6 100644
--- a/pkgs/development/libraries/jansson/default.nix
+++ b/pkgs/development/libraries/jansson/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation rec {
-  name = "jansson-2.10";
+  name = "jansson-2.11";
 
   src = fetchurl {
     url = "http://www.digip.org/jansson/releases/${name}.tar.gz";
-    sha256 = "0iv4rxsnamqm3ldpg7dyhjq0x9cp023nc7ac820jdd3pwb8ml8bq";
+    sha256 = "1x5jllzzqamq6kahx9d9a5mrarm9m3f30vfxvcqpi6p4mcnz91bf";
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/jasper/default.nix b/pkgs/development/libraries/jasper/default.nix
index 63dd931a139f..d374c935a2a4 100644
--- a/pkgs/development/libraries/jasper/default.nix
+++ b/pkgs/development/libraries/jasper/default.nix
@@ -2,15 +2,24 @@
 
 stdenv.mkDerivation rec {
   name = "jasper-${version}";
-  version = "2.0.13";
+  version = "2.0.14";
 
   src = fetchFromGitHub {
     repo = "jasper";
     owner = "mdadams";
     rev = "version-${version}";
-    sha256 = "1kd2xiszg9bxfavs3fadi4gi27m876d9zjjy0ns6mmbcjk109c0a";
+    sha256 = "0aarg8nbik9wrm7fx0451sbm5ypfdfr6i169pxzi354mpdp8gg7f";
   };
 
+  patches = [
+    (fetchpatch {
+      name = "CVE-2018-9055.patch";
+      url = "http://paste.opensuse.org/view/raw/330751ce";
+      sha256 = "0m798m6c4v9yyhql7x684j5kppcm6884n1rrb9ljz8p9aqq2jqnm";
+    })
+  ];
+
+
   # newer reconf to recognize a multiout flag
   nativeBuildInputs = [ cmake ];
   propagatedBuildInputs = [ libjpeg ];
diff --git a/pkgs/development/libraries/java/classpath/default.nix b/pkgs/development/libraries/java/classpath/default.nix
deleted file mode 100644
index 82e02d06906b..000000000000
--- a/pkgs/development/libraries/java/classpath/default.nix
+++ /dev/null
@@ -1,61 +0,0 @@
-{ fetchurl, stdenv, javac, jvm, antlr, pkgconfig, gtk2, gconf, ecj }:
-
-stdenv.mkDerivation rec {
-  name = "classpath-0.99";
-
-  src = fetchurl {
-    url = "mirror://gnu/classpath/${name}.tar.gz";
-    sha256 = "1j7cby4k66f1nvckm48xcmh352b1d1b33qk7l6hi7dp9i9zjjagr";
-  };
-
-  patches = [ ./missing-casts.patch ];
-
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ javac jvm antlr gtk2 gconf ecj ];
-
-  configurePhase = ''
-    # GCJ tries to compile all of Classpath during the `configure' run when
-    # trying to build in the source tree (see
-    # http://www.mail-archive.com/classpath@gnu.org/msg15079.html), thus we
-    # build out-of-tree.
-    mkdir ../build
-    cd ../build
-    echo "building in \`$PWD'"
-
-    ../${name}/configure --prefix="$out"                        \
-         --enable-fast-install --disable-dependency-tracking    \
-         ${configureFlags}
-  '';
-
-  /* Plug-in support requires Xulrunner and all that.  Maybe someday,
-     optionally.
-
-    Compilation with `-Werror' is disabled because of this:
-
-      native/jni/native-lib/cpnet.c: In function 'cpnet_addMembership':
-      native/jni/native-lib/cpnet.c:583: error: dereferencing type-punned pointer will break strict-aliasing rules
-      native/jni/native-lib/cpnet.c: In function 'cpnet_dropMembership':
-      native/jni/native-lib/cpnet.c:598: error: dereferencing type-punned pointer will break strict-aliasing rules
-
-   */
-
-  configureFlags = "--disable-Werror --disable-plugin --with-antlr-jar=${antlr}/lib/antlr.jar";
-
-  meta = {
-    description = "Essential libraries for Java";
-
-    longDescription = ''
-      GNU Classpath, Essential Libraries for Java, is a GNU project to create
-      free core class libraries for use with virtual machines and compilers
-      for the Java programming language.
-    '';
-
-    homepage = http://www.gnu.org/software/classpath/;
-
-    # The exception makes it similar to LGPLv2+ AFAICS.
-    license = stdenv.lib.licenses.gpl2ClasspathPlus;
-
-    maintainers = [ ];
-    platforms = stdenv.lib.platforms.linux;
-  };
-}
diff --git a/pkgs/development/libraries/java/classpath/missing-casts.patch b/pkgs/development/libraries/java/classpath/missing-casts.patch
deleted file mode 100644
index 863ca2cac8ce..000000000000
--- a/pkgs/development/libraries/java/classpath/missing-casts.patch
+++ /dev/null
@@ -1,80 +0,0 @@
-Add missing casts.  The GCC folks applied a similar patch in
-GCC's own copy of Classpath:
-http://gcc.gnu.org/ml/java/2007-05/msg00039.html .
-
---- classpath-0.98/javax/management/NotificationBroadcasterSupport.java	2009-07-30 16:52:08.000000000 +0200
-+++ classpath-0.98/javax/management/NotificationBroadcasterSupport.java	2009-07-30 16:51:58.000000000 +0200
-@@ -218,7 +218,7 @@
-   {
-     if (info == null || info.length == 0)
-       return new MBeanNotificationInfo[0];
--    return info.clone();
-+    return (MBeanNotificationInfo[]) info.clone();
-   }
- 
-   /**
-
---- classpath-0.98/java/util/concurrent/CopyOnWriteArrayList.java	2008-03-27 18:39:25.000000000 +0100
-+++ classpath-0.98/java/util/concurrent/CopyOnWriteArrayList.java	2009-07-30 17:08:30.000000000 +0200
-@@ -147,7 +148,7 @@ public class CopyOnWriteArrayList<E> 
-    */
-   public CopyOnWriteArrayList(E[] array)
-   {
--    data = array.clone();
-+    data = (E[]) array.clone();
-   }
- 
-   /**
-@@ -364,7 +365,7 @@ public class CopyOnWriteArrayList<E> 
-   public synchronized E set(int index, E e)
-   {
-     E result = data[index];
--    E[] newData = data.clone();
-+    E[] newData = (E[]) data.clone();
-     newData[index] = e;
-     data = newData;
-     return result;
-
---- classpath-0.98/java/util/EnumMap.java	2007-07-24 17:26:36.000000000 +0200
-+++ classpath-0.98/java/util/EnumMap.java	2009-07-30 17:12:19.000000000 +0200
-@@ -398,7 +398,7 @@ public class EnumMap<K extends Enum<K>, 
- 	// Can't happen.
- 	result = null;
-       }
--    result.store = store.clone();
-+    result.store = (V[]) store.clone();
-     return result;
-   }
- 
---- classpath-0.98/gnu/java/lang/reflect/GenericSignatureParser.java	2008-03-01 11:13:31.000000000 +0100
-+++ classpath-0.98/gnu/java/lang/reflect/GenericSignatureParser.java	2009-07-30 17:14:24.000000000 +0200
-@@ -75,7 +75,7 @@ final class TypeVariableImpl extends Typ
-     public Type[] getBounds()
-     {
-         resolve(bounds);
--        return bounds.clone();
-+        return (Type[]) bounds.clone();
-     }
- 
-     public GenericDeclaration getGenericDeclaration()
-@@ -154,7 +154,7 @@ final class ParameterizedTypeImpl extend
- 
-     public Type[] getActualTypeArguments()
-     {
--        return typeArgs.clone();
-+        return (Type[]) typeArgs.clone();
-     }
- 
-     public Type getRawType()
-
---- classpath-0.98/external/jsr166/java/util/ArrayDeque.java	2006-12-10 21:25:40.000000000 +0100
-+++ classpath-0.98/external/jsr166/java/util/ArrayDeque.java	2009-07-30 17:15:35.000000000 +0200
-@@ -787,7 +790,7 @@ public class ArrayDeque<E> extends Abstr
-             ArrayDeque<E> result = (ArrayDeque<E>) super.clone();
-             // Classpath local: we don't have Arrays.copyOf yet.
-             // result.elements = Arrays.copyOf(elements, elements.length);
--            result.elements = elements.clone();
-+            result.elements = (E[]) elements.clone();
-             return result;
- 
-         } catch (CloneNotSupportedException e) {
diff --git a/pkgs/development/libraries/java/commons/compress/default.nix b/pkgs/development/libraries/java/commons/compress/default.nix
index a35eaa0b260a..eff57d6f2fd9 100644
--- a/pkgs/development/libraries/java/commons/compress/default.nix
+++ b/pkgs/development/libraries/java/commons/compress/default.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  version = "1.8.1";
+  version = "1.16.1";
   name    = "commons-compress-${version}";
 
   src = fetchurl {
     url    = "mirror://apache/commons/compress/binaries/${name}-bin.tar.gz";
-    sha256 = "11viabgf34r3zx1avj51n00hzmx89kym3i90l6a5v5dbfh61h0lp";
+    sha256 = "0yz2m3qac1idg9346i64mjfrkq4kniajzx2manyybhj43v9dpx37";
   };
 
   installPhase = ''
diff --git a/pkgs/development/libraries/java/commons/io/default.nix b/pkgs/development/libraries/java/commons/io/default.nix
index d49165ac521a..03b083328da4 100644
--- a/pkgs/development/libraries/java/commons/io/default.nix
+++ b/pkgs/development/libraries/java/commons/io/default.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  version = "2.4";
+  version = "2.6";
   name    = "commons-io-${version}";
 
   src = fetchurl {
     url    = "mirror://apache/commons/io/binaries/${name}-bin.tar.gz";
-    sha256 = "0m5xmjfr9k2zmbrz425q530jd0lm6368c4wm3jsjlsrqmqjpsvz1";
+    sha256 = "1nzkv8gi56l1m4h7s8bcvqm0naq3bhh7fazcmgdhcr2zkjs5zfmn";
   };
 
   installPhase = ''
diff --git a/pkgs/development/libraries/java/dbus-java/default.nix b/pkgs/development/libraries/java/dbus-java/default.nix
index 8ca3bf1cd34a..23adfd80caac 100644
--- a/pkgs/development/libraries/java/dbus-java/default.nix
+++ b/pkgs/development/libraries/java/dbus-java/default.nix
@@ -17,9 +17,9 @@ stdenv.mkDerivation {
     sed -i -e "s|all: bin doc man|all: bin|" \
            -e "s|install: install-bin install-man install-doc|install: install-bin|" Makefile
   '';
-  maintainers = [ stdenv.lib.maintainers.sander ];
 
   meta = {
     platforms = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.lib.maintainers.sander ];
   };
 }
diff --git a/pkgs/development/libraries/java/hsqldb/default.nix b/pkgs/development/libraries/java/hsqldb/default.nix
index ad849a4d6d53..97ffcb647d62 100644
--- a/pkgs/development/libraries/java/hsqldb/default.nix
+++ b/pkgs/development/libraries/java/hsqldb/default.nix
@@ -2,12 +2,12 @@
 }:
 
 stdenv.mkDerivation {
-  name = "hsqldb-1.8.0.9";
+  name = "hsqldb-2.4.0";
   builder = ./builder.sh;
 
   src = fetchurl {
     url = mirror://sourceforge/hsqldb/hsqldb_1_8_0_9.zip;
-    sha256 = "e98d1d8bca15059f4ef4f0d3dde2d75778a5e1bbe8bc12abd4ec2cac39d5adec";
+    sha256 = "1v5dslwsqb7csjmi5g78pghsay2pszidvlzhyi79y18mra5iv3g9";
   };
 
   buildInputs = [ unzip
diff --git a/pkgs/development/libraries/java/libmatthew-java/default.nix b/pkgs/development/libraries/java/libmatthew-java/default.nix
index df4a19efd2c4..877535331698 100644
--- a/pkgs/development/libraries/java/libmatthew-java/default.nix
+++ b/pkgs/development/libraries/java/libmatthew-java/default.nix
@@ -3,15 +3,15 @@
 stdenv.mkDerivation {
   name = "libmatthew-java-0.8";
   src = fetchurl {
-    url = http://pkgs.fedoraproject.org/repo/pkgs/libmatthew-java/libmatthew-java-0.8.tar.gz/8455b8751083ce25c99c2840609271f5/libmatthew-java-0.8.tar.gz;
+    url = http://src.fedoraproject.org/repo/pkgs/libmatthew-java/libmatthew-java-0.8.tar.gz/8455b8751083ce25c99c2840609271f5/libmatthew-java-0.8.tar.gz;
     sha256 = "1yldkhsdzm0a41a0i881bin2jklhp85y3ah245jd6fz3npcx7l85";
   };
   JAVA_HOME=jdk;
   PREFIX=''''${out}'';
   buildInputs = [ jdk ];
-  maintainers = [ stdenv.lib.maintainers.sander ];
 
   meta = {
     platforms = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.lib.maintainers.sander ];
   };
 }
diff --git a/pkgs/development/libraries/java/lombok/default.nix b/pkgs/development/libraries/java/lombok/default.nix
index 05ad908b3c36..df9b3f96c871 100644
--- a/pkgs/development/libraries/java/lombok/default.nix
+++ b/pkgs/development/libraries/java/lombok/default.nix
@@ -1,13 +1,18 @@
-{stdenv, fetchurl}:
+{ stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "lombok-1.16.8";
+  name = "lombok-1.16.20";
+
   src = fetchurl {
     url = "https://projectlombok.org/downloads/${name}.jar";
-    sha256 = "0s7ak6gx1h04da2rdhvc0fk896cwqm2m7g3chqcjpsrkgfdv4cpy";
+    sha256 = "0v8fq4qlpjh4b87xx35m32y2xpnj4d05xflrgghia6mar8c8n5y5";
   };
-  phases = [ "installPhase" ];
-  installPhase = "mkdir -p $out/share/java; cp $src $out/share/java/lombok.jar";
+
+  buildCommand = ''
+    mkdir -p $out/share/java
+    cp $src $out/share/java/lombok.jar
+  '';
+
   meta = {
     description = "A library that can write a lot of boilerplate for your Java project";
     platforms = stdenv.lib.platforms.all;
diff --git a/pkgs/development/libraries/java/saxon/default.nix b/pkgs/development/libraries/java/saxon/default.nix
index fcd884f0a419..ca9aa8fc36e8 100644
--- a/pkgs/development/libraries/java/saxon/default.nix
+++ b/pkgs/development/libraries/java/saxon/default.nix
@@ -1,22 +1,83 @@
-{ stdenv, fetchurl, unzip }:
-
-stdenv.mkDerivation {
-  name = "saxon-6.5.3";
-  builder = ./unzip-builder.sh;
-  src = fetchurl {
-    url = mirror://sourceforge/saxon/saxon6_5_3.zip;
-    sha256 = "0l5y3y2z4wqgh80f26dwwxwncs8v3nkz3nidv14z024lmk730vs3";
+{ stdenv, fetchurl, unzip, jre }:
+
+let
+  common = { pname, version, src, description
+           , prog ? null, jar ? null, license ? stdenv.lib.licenses.mpl20 }:
+    stdenv.mkDerivation {
+      name = "${pname}-${version}";
+      inherit pname version src;
+
+      nativeBuildInputs = [ unzip ];
+
+      buildCommand = let
+        prog' = if prog == null then pname else prog;
+        jar' = if jar == null then pname else jar;
+      in ''
+        unzip $src -d $out
+        mkdir -p $out/bin $out/share $out/share/java
+        cp -s "$out"/*.jar "$out/share/java/"  # */
+        rm -rf $out/notices
+        mv $out/doc $out/share
+        cat > $out/bin/${prog'} <<EOF
+        #! $shell
+        export JAVA_HOME=${jre}
+        exec ${jre}/bin/java -jar $out/${jar'}.jar "\$@"
+        EOF
+        chmod a+x $out/bin/${prog'}
+      '';
+
+      meta = with stdenv.lib; {
+        inherit description license;
+        homepage = http://saxon.sourceforge.net/;
+        maintainers = with maintainers; [ rvl ];
+        platforms = platforms.all;
+      };
+    };
+
+in {
+  saxon = common {
+    pname = "saxon";
+    version = "6.5.3";
+    src = fetchurl {
+      url = mirror://sourceforge/saxon/saxon6_5_3.zip;
+      sha256 = "0l5y3y2z4wqgh80f26dwwxwncs8v3nkz3nidv14z024lmk730vs3";
+    };
+    description = "XSLT 1.0 processor";
+    # http://saxon.sourceforge.net/saxon6.5.3/conditions.html
+    license = stdenv.lib.licenses.mpl10;
   };
 
-  nativeBuildInputs = [ unzip ];
+  saxonb_8_8 = common {
+    pname = "saxonb";
+    version = "8.8";
+    jar = "saxon8";
+    src = fetchurl {
+      url = mirror://sourceforge/saxon/saxonb8-8j.zip;
+      sha256 = "15bzrfyd2f1045rsp9dp4znyhmizh1pm97q8ji2bc0b43q23xsb8";
+    };
+    description = "Complete and conformant processor of XSLT 2.0, XQuery 1.0, and XPath 2.0";
+  };
 
-  # still leaving in root as well, in case someone is relying on that
-  preFixup = ''
-    mkdir -p "$out/share/java"
-    cp -s "$out"/*.jar "$out/share/java/"
-  '';
+  saxonb_9_1 = common {
+    pname = "saxonb";
+    version = "9.1.0.8";
+    jar = "saxon9";
+    src = fetchurl {
+      url = mirror://sourceforge/saxon/Saxon-B/9.1.0.8/saxonb9-1-0-8j.zip;
+      sha256 = "1d39jdnwr3v3pzswm81zry6yikqlqy9dp2l2wmpqdiw00r5drg4j";
+    };
+    description = "Complete and conformant processor of XSLT 2.0, XQuery 1.0, and XPath 2.0";
+  };
 
-  meta = {
-    platforms = stdenv.lib.platforms.unix;
+  saxon-he = common {
+    pname = "saxon-he";
+    version = "9.8.0.6";
+    prog = "saxon-he";
+    jar = "saxon9he";
+    src = fetchurl {
+      url = mirror://sourceforge/saxon/Saxon-HE/9.8/SaxonHE9-8-0-6J.zip;
+      sha256 = "03r4djm298rxz8q7jph63h9niglrl3rifxskq1b3bclx5rgxi2lk";
+    };
+    description = "Processor for XSLT 3.0, XPath 2.0 and 3.1, and XQuery 3.1";
   };
 }
diff --git a/pkgs/development/libraries/java/saxon/default8.nix b/pkgs/development/libraries/java/saxon/default8.nix
deleted file mode 100644
index 7728737977c2..000000000000
--- a/pkgs/development/libraries/java/saxon/default8.nix
+++ /dev/null
@@ -1,26 +0,0 @@
-{stdenv, fetchurl, unzip, jre}:
-
-stdenv.mkDerivation {
-  name = "saxonb-8.8";
-  src = fetchurl {
-    url = mirror://sourceforge/saxon/saxonb8-8j.zip;
-    sha256 = "15bzrfyd2f1045rsp9dp4znyhmizh1pm97q8ji2bc0b43q23xsb8";
-  };
-
-  buildInputs = [unzip];
-
-  buildCommand = "
-    unzip $src -d $out
-    mkdir -p $out/bin
-    cat > $out/bin/saxon8 <<EOF
-#! $shell
-export JAVA_HOME=${jre}
-exec ${jre}/bin/java -jar $out/saxon8.jar \"\\$@\"
-EOF
-    chmod a+x $out/bin/saxon8
-  ";
-
-  meta = {
-    platforms = stdenv.lib.platforms.unix;
-  };
-}
diff --git a/pkgs/development/libraries/java/saxon/unzip-builder.sh b/pkgs/development/libraries/java/saxon/unzip-builder.sh
deleted file mode 100755
index 8ac35568f0b9..000000000000
--- a/pkgs/development/libraries/java/saxon/unzip-builder.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-source $stdenv/setup
-
-unzip $src -d $out
-
-fixupPhase
-
diff --git a/pkgs/development/libraries/java/swt/default.nix b/pkgs/development/libraries/java/swt/default.nix
index 2cf08e345758..1a7153f99e67 100644
--- a/pkgs/development/libraries/java/swt/default.nix
+++ b/pkgs/development/libraries/java/swt/default.nix
@@ -1,5 +1,5 @@
 { stdenv, lib, fetchurl, unzip, jdk, pkgconfig, gtk2
-, libXt, libXtst, libXi, mesa, webkit, libsoup, xorg
+, libXt, libXtst, libXi, libGLU_combined, webkit, libsoup, xorg
 , pango, gdk_pixbuf, glib
 }:
 
@@ -36,7 +36,7 @@ in stdenv.mkDerivation rec {
   sourceRoot = ".";
 
   nativeBuildInputs = [ unzip pkgconfig ];
-  buildInputs = [ jdk gtk2 libXt libXtst libXi mesa webkit libsoup ];
+  buildInputs = [ jdk gtk2 libXt libXtst libXi libGLU_combined webkit libsoup ];
 
   NIX_LFLAGS = (map (x: "-L${lib.getLib x}/lib") [ xorg.libX11 pango gdk_pixbuf glib ]) ++
     [ "-lX11" "-lpango-1.0" "-lgdk_pixbuf-2.0" "-lglib-2.0" ];
diff --git a/pkgs/development/libraries/javascript/jquery-ui/default.nix b/pkgs/development/libraries/javascript/jquery-ui/default.nix
deleted file mode 100644
index e65107a3c2fb..000000000000
--- a/pkgs/development/libraries/javascript/jquery-ui/default.nix
+++ /dev/null
@@ -1,24 +0,0 @@
-{ stdenv, fetchurl, unzip }:
-
-stdenv.mkDerivation rec {
-  name = "jquery-ui-1.11.4";
-
-  src = fetchurl {
-    url = "http://jqueryui.com/resources/download/${name}.zip";
-    sha256 = "0ciyaj1acg08g8hpzqx6whayq206fvf4whksz2pjgxlv207lqgjh";
-  };
-
-  buildInputs = [ unzip ];
-
-  installPhase =
-    ''
-      mkdir -p "$out/js"
-      cp -rv . "$out/js"
-    '';
-
-  meta = {
-    homepage = http://jqueryui.com/;
-    description = "A library of JavaScript widgets and effects";
-    platforms = stdenv.lib.platforms.all;
-  };
-}
diff --git a/pkgs/development/libraries/javascript/jquery/default.nix b/pkgs/development/libraries/javascript/jquery/default.nix
deleted file mode 100644
index 103721cadc38..000000000000
--- a/pkgs/development/libraries/javascript/jquery/default.nix
+++ /dev/null
@@ -1,36 +0,0 @@
-{ stdenv, fetchurl, compressed ? true }:
-
-with stdenv.lib;
-
-stdenv.mkDerivation rec {
-  name = "jquery-1.11.3";
-
-  src = if compressed then
-    fetchurl {
-      url = "http://code.jquery.com/${name}.min.js";
-      sha256 = "1f4glgxxn3jnvry3dpzmazj3207baacnap5w20gr2xlk789idfgc";
-    }
-    else
-    fetchurl {
-      url = "http://code.jquery.com/${name}.js";
-      sha256 = "1v956yf5spw0156rni5z77hzqwmby7ajwdcd6mkhb6zvl36awr90";
-    };
-
-  unpackPhase = "true";
-
-  installPhase =
-    ''
-      mkdir -p "$out/js"
-      cp -v "$src" "$out/js/jquery.js"
-      ${optionalString compressed ''
-        (cd "$out/js" && ln -s jquery.js jquery.min.js)
-      ''}
-    '';
-
-  meta = with stdenv.lib; {
-    description = "JavaScript library designed to simplify the client-side scripting of HTML";
-    homepage = http://jquery.com/;
-    license = licenses.mit;
-    platforms = platforms.all;
-  };
-}
diff --git a/pkgs/development/libraries/jbig2dec/default.nix b/pkgs/development/libraries/jbig2dec/default.nix
index 45df4876be1f..8731bd8e7366 100644
--- a/pkgs/development/libraries/jbig2dec/default.nix
+++ b/pkgs/development/libraries/jbig2dec/default.nix
@@ -1,21 +1,13 @@
 { stdenv, fetchurl, fetchpatch }:
 
 stdenv.mkDerivation rec {
-  name = "jbig2dec-0.13";
+  name = "jbig2dec-0.14";
 
   src = fetchurl {
     url = "http://downloads.ghostscript.com/public/jbig2dec/${name}.tar.gz";
-    sha256 = "04akiwab8iy5iy34razcvh9mcja9wy737civ3sbjxk4j143s1b2s";
+    sha256 = "0k01hp0q4275fj4rbr1gy64svfraw5w7wvwl08yjhvsnpb1rid11";
   };
 
-  patches =
-    [ (fetchpatch {
-        url = "http://git.ghostscript.com/?p=jbig2dec.git;a=patch;h=e698d5c11d27212aa1098bc5b1673a3378563092";
-        sha256 = "1fc8xm1z98xj2zkcl0zj7dpjjsbz3vn61b59jnkhcyzy3iiczv7f";
-        name = "CVE-2016-9601.patch";
-      })
-    ];
-
   meta = {
     homepage = https://www.ghostscript.com/jbig2dec.html;
     description = "Decoder implementation of the JBIG2 image compression format";
diff --git a/pkgs/development/libraries/jemalloc/common.nix b/pkgs/development/libraries/jemalloc/common.nix
new file mode 100644
index 000000000000..1a26bd13d41c
--- /dev/null
+++ b/pkgs/development/libraries/jemalloc/common.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchurl, version, sha256, ... }@args:
+
+stdenv.mkDerivation (rec {
+  name = "jemalloc-${version}";
+  inherit version;
+
+  src = fetchurl {
+    url = "https://github.com/jemalloc/jemalloc/releases/download/${version}/${name}.tar.bz2";
+    inherit sha256;
+  };
+
+  # By default, jemalloc puts a je_ prefix onto all its symbols on OSX, which
+  # then stops downstream builds (mariadb in particular) from detecting it. This
+  # option should remove the prefix and give us a working jemalloc.
+  configureFlags = stdenv.lib.optional stdenv.isDarwin "--with-jemalloc-prefix="
+                   # jemalloc is unable to correctly detect transparent hugepage support on
+                   # ARM (https://github.com/jemalloc/jemalloc/issues/526), and the default
+                   # kernel ARMv6/7 kernel does not enable it, so we explicitly disable support
+                   ++ stdenv.lib.optional stdenv.isArm "--disable-thp";
+  doCheck = true;
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = http://jemalloc.net;
+    description = "General purpose malloc(3) implementation";
+    longDescription = ''
+      malloc(3)-compatible memory allocator that emphasizes fragmentation
+      avoidance and scalable concurrency support.
+    '';
+    license = licenses.bsd2;
+    platforms = platforms.all;
+    maintainers = with maintainers; [ wkennington ];
+  };
+} // (builtins.removeAttrs args [ "stdenv" "fetchurl" "version" "sha256" ]))
diff --git a/pkgs/development/libraries/jemalloc/default.nix b/pkgs/development/libraries/jemalloc/default.nix
index 8c8c181409d4..40c06cbffdf0 100644
--- a/pkgs/development/libraries/jemalloc/default.nix
+++ b/pkgs/development/libraries/jemalloc/default.nix
@@ -1,31 +1,10 @@
-{ stdenv, fetchurl }:
-
-stdenv.mkDerivation rec {
-  name = "jemalloc-${version}";
-  version = "4.5.0";
-
-  src = fetchurl {
-    url = "https://github.com/jemalloc/jemalloc/releases/download/${version}/${name}.tar.bz2";
-    sha256 = "9409d85664b4f135b77518b0b118c549009dc10f6cba14557d170476611f6780";
-  };
-
-  # By default, jemalloc puts a je_ prefix onto all its symbols on OSX, which
-  # then stops downstream builds (mariadb in particular) from detecting it. This
-  # option should remove the prefix and give us a working jemalloc.
-  configureFlags = stdenv.lib.optional stdenv.isDarwin "--with-jemalloc-prefix=";
-
-  doCheck = true;
-
-
-  meta = with stdenv.lib; {
-    homepage = http://jemalloc.net;
-    description = "General purpose malloc(3) implementation";
-    longDescription = ''
-      malloc(3)-compatible memory allocator that emphasizes fragmentation
-      avoidance and scalable concurrency support.
-    '';
-    license = licenses.bsd2;
-    platforms = platforms.all;
-    maintainers = with maintainers; [ wkennington ];
-  };
+{ stdenv, fetchurl, fetchpatch }:
+import ./common.nix {
+  inherit stdenv fetchurl;
+  version = "5.0.1";
+  sha256 = "4814781d395b0ef093b21a08e8e6e0bd3dab8762f9935bbfb71679b0dea7c3e9";
+  patches = stdenv.lib.optional stdenv.isAarch64 (fetchpatch {
+    url = "https://patch-diff.githubusercontent.com/raw/jemalloc/jemalloc/pull/1035.patch";
+    sha256 = "02y0q3dp253bipxv4r954nqipbjbj92p6ww9bx5bk3d8pa81wkqq";
+  });
 }
diff --git a/pkgs/development/libraries/jemalloc/jemalloc450.nix b/pkgs/development/libraries/jemalloc/jemalloc450.nix
new file mode 100644
index 000000000000..00b38a855532
--- /dev/null
+++ b/pkgs/development/libraries/jemalloc/jemalloc450.nix
@@ -0,0 +1,6 @@
+{ stdenv, fetchurl }:
+import ./common.nix {
+  inherit stdenv fetchurl;
+  version = "4.5.0";
+  sha256 = "10373xhpc10pgmai9fkc1z0rs029qlcb3c0qfnvkbwdlcibdh2cl";
+}
diff --git a/pkgs/development/libraries/json-c/0.11.nix b/pkgs/development/libraries/json-c/0.11.nix
deleted file mode 100644
index 029921ee08c0..000000000000
--- a/pkgs/development/libraries/json-c/0.11.nix
+++ /dev/null
@@ -1,22 +0,0 @@
-{ stdenv, fetchurl }:
-
-stdenv.mkDerivation rec {
-  name = "json-c-0.11";
-  src = fetchurl {
-    url    = "https://github.com/json-c/json-c/archive/json-c-0.11-20130402.tar.gz";
-    sha256 = "1m8fy7lbahv1r7yqbhw4pl057sxmmgjihm1fsvc3h66710s2i24r";
-  };
-  meta = with stdenv.lib; {
-    description = "A JSON implementation in C";
-    homepage    = https://github.com/json-c/json-c/wiki;
-    maintainers = with maintainers; [ lovek323 ];
-    platforms   = platforms.unix;
-
-    longDescription = ''
-      JSON-C implements a reference counting object model that allows you to
-      easily construct JSON objects in C, output them as JSON formatted strings
-      and parse JSON formatted strings back into the C representation of JSON
-      objects.
-    '';
-  };
-}
diff --git a/pkgs/development/libraries/json-c/default.nix b/pkgs/development/libraries/json-c/default.nix
index b8c72d9669e0..27d1b701f054 100644
--- a/pkgs/development/libraries/json-c/default.nix
+++ b/pkgs/development/libraries/json-c/default.nix
@@ -1,20 +1,15 @@
-{ stdenv, fetchurl, autoreconfHook }:
+{ stdenv, fetchurl, autoconf }:
 
 stdenv.mkDerivation rec {
-  name = "json-c-0.12.1";
+  name = "json-c-0.13.1";
   src = fetchurl {
     url    = "https://s3.amazonaws.com/json-c_releases/releases/${name}-nodoc.tar.gz";
-    sha256 = "148jkvpnxmg1fwwigp0nq9qbd5vzpnmgiw3y34w7k6fymalpsqas";
+    sha256 = "0ch1v18wk703bpbyzj7h1mkwvsw4rw4qdwvgykscypvqq10678ll";
   };
 
   outputs = [ "out" "dev" ];
 
-  nativeBuildInputs = [ autoreconfHook ]; # won't configure without it, no idea why
-
-  # compatibility hack (for mypaint at least)
-  postInstall = ''
-    ln -s json-c.pc "$dev/lib/pkgconfig/json.pc"
-  '';
+  nativeBuildInputs = [ autoconf ];  # for autoheader
 
   meta = with stdenv.lib; {
     description = "A JSON implementation in C";
diff --git a/pkgs/development/libraries/json-glib/default.nix b/pkgs/development/libraries/json-glib/default.nix
index 2414931e76aa..21bddf8f6bb5 100644
--- a/pkgs/development/libraries/json-glib/default.nix
+++ b/pkgs/development/libraries/json-glib/default.nix
@@ -1,4 +1,7 @@
-{ stdenv, fetchurl, fetchpatch, glib, meson, ninja, pkgconfig, gettext, gobjectIntrospection, dbus, libintlOrEmpty }:
+{ stdenv, fetchurl, fetchpatch, glib, meson, ninja, pkgconfig, gettext
+, gobjectIntrospection, dbus
+, fixDarwinDylibNames
+}:
 
 stdenv.mkDerivation rec {
   name = "json-glib-${minVer}.2";
@@ -11,9 +14,7 @@ stdenv.mkDerivation rec {
 
   propagatedBuildInputs = [ glib ];
   nativeBuildInputs = [ meson ninja pkgconfig gettext gobjectIntrospection ];
-  buildInputs = libintlOrEmpty;
-
-  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
@@ -27,8 +28,6 @@ stdenv.mkDerivation rec {
 
   doCheck = true;
 
-  checkPhase = "meson test";
-
   meta = with stdenv.lib; {
     homepage = http://live.gnome.org/JsonGlib;
     description = "A library providing (de)serialization support for the JavaScript Object Notation (JSON) format";
diff --git a/pkgs/development/libraries/jsoncpp/default.nix b/pkgs/development/libraries/jsoncpp/default.nix
index 18ea6370634d..1c62d79ed328 100644
--- a/pkgs/development/libraries/jsoncpp/default.nix
+++ b/pkgs/development/libraries/jsoncpp/default.nix
@@ -5,13 +5,13 @@
 }:
 stdenv.mkDerivation rec {
   name = "jsoncpp-${version}";
-  version = "1.8.0";
+  version = "1.8.4";
 
   src = fetchFromGitHub {
     owner = "open-source-parsers";
     repo = "jsoncpp";
     rev = version;
-    sha256 = "1lg22zrjnl10x1bw0wfz72xd2kfbzynyggk8vdwd89mp1g8xjl9d";
+    sha256 = "1z0gj7a6jypkijmpknis04qybs1hkd04d1arr3gy89lnxmp6qzlm";
   };
 
   /* During darwin bootstrap, we have a cp that doesn't understand the
diff --git a/pkgs/development/libraries/kdb/default.nix b/pkgs/development/libraries/kdb/default.nix
index 399d5914c2de..1dedd3836c29 100644
--- a/pkgs/development/libraries/kdb/default.nix
+++ b/pkgs/development/libraries/kdb/default.nix
@@ -1,22 +1,22 @@
 {
   mkDerivation, lib, fetchurl,
   extra-cmake-modules,
-  qtbase, qttranslations, kcoreaddons, python2, sqlite, postgresql, libmysql
+  qtbase, qttranslations, kcoreaddons, python2, sqlite, postgresql, mysql
 }:
 
 mkDerivation rec {
   pname = "kdb";
-  version = "3.0.2";
+  version = "3.1.0";
   name = "${pname}-${version}";
 
   src = fetchurl {
     url = "mirror://kde/stable/${pname}/src/${name}.tar.xz";
-    sha256 = "1n11xhqk3sf4a5nzvnrnj7bj21yqqqkm2d1xzfx3q82fkyah8s49";
+    sha256 = "1wi9z7j0nr9wi6aqqkdcpnr38ixyxbv00sblya7pakdf96hlamhp";
   };
 
   nativeBuildInputs = [ extra-cmake-modules ];
 
-  buildInputs = [ qttranslations kcoreaddons python2 sqlite postgresql libmysql ];
+  buildInputs = [ qttranslations kcoreaddons python2 sqlite postgresql mysql.connector-c ];
 
   propagatedBuildInputs = [ qtbase ];
 
diff --git a/pkgs/development/libraries/kde-frameworks/default.nix b/pkgs/development/libraries/kde-frameworks/default.nix
index 2bf10737ab0b..08eebfd83aee 100644
--- a/pkgs/development/libraries/kde-frameworks/default.nix
+++ b/pkgs/development/libraries/kde-frameworks/default.nix
@@ -56,11 +56,7 @@ let
                     # Propagate $dev so that this setup hook is propagated
                     # But only if there is a separate $dev output
                     if [ "$outputDev" != out ]; then
-                        if [ -n "$crossConfig" ]; then
-                          propagatedBuildInputs="$propagatedBuildInputs @dev@"
-                        else
-                          propagatedNativeBuildInputs="$propagatedNativeBuildInputs @dev@"
-                        fi
+                        propagatedBuildInputs="$propagatedBuildInputs @dev@"
                     fi
                 fi
               '';
diff --git a/pkgs/development/libraries/kde-frameworks/extra-cmake-modules/setup-hook.sh b/pkgs/development/libraries/kde-frameworks/extra-cmake-modules/setup-hook.sh
index c1b1e21852cf..88091e78a0cd 100644
--- a/pkgs/development/libraries/kde-frameworks/extra-cmake-modules/setup-hook.sh
+++ b/pkgs/development/libraries/kde-frameworks/extra-cmake-modules/setup-hook.sh
@@ -2,7 +2,7 @@ _ecmEnvHook() {
     addToSearchPath XDG_DATA_DIRS "$1/share"
     addToSearchPath XDG_CONFIG_DIRS "$1/etc/xdg"
 }
-envHooks+=(_ecmEnvHook)
+addEnvHooks "$targetOffset" _ecmEnvHook
 
 _ecmPreConfigureHook() {
     # Because we need to use absolute paths here, we must set *all* the paths.
diff --git a/pkgs/development/libraries/kde-frameworks/fetch.sh b/pkgs/development/libraries/kde-frameworks/fetch.sh
index 0e0372ad7ac1..ede76323347e 100644
--- a/pkgs/development/libraries/kde-frameworks/fetch.sh
+++ b/pkgs/development/libraries/kde-frameworks/fetch.sh
@@ -1 +1 @@
-WGET_ARGS=( https://download.kde.org/stable/frameworks/5.39/ -A '*.tar.xz' )
+WGET_ARGS=( https://download.kde.org/stable/frameworks/5.45/ -A '*.tar.xz' )
diff --git a/pkgs/development/libraries/kde-frameworks/kcmutils/kcmutils-follow-symlinks.patch b/pkgs/development/libraries/kde-frameworks/kcmutils/kcmutils-follow-symlinks.patch
index 5e1007b7fc0b..cc041b9aa3b8 100644
--- a/pkgs/development/libraries/kde-frameworks/kcmutils/kcmutils-follow-symlinks.patch
+++ b/pkgs/development/libraries/kde-frameworks/kcmutils/kcmutils-follow-symlinks.patch
@@ -1,13 +1,13 @@
-Index: kcmutils-5.33.0/src/kpluginselector.cpp
-===================================================================
---- kcmutils-5.33.0.orig/src/kpluginselector.cpp
-+++ kcmutils-5.33.0/src/kpluginselector.cpp
-@@ -305,7 +305,7 @@ void KPluginSelector::addPlugins(const Q
+diff --git a/src/kpluginselector.cpp b/src/kpluginselector.cpp
+index 137c865..097ab75 100644
+--- a/src/kpluginselector.cpp
++++ b/src/kpluginselector.cpp
+@@ -303,7 +303,7 @@ void KPluginSelector::addPlugins(const QString &componentName,
      QStringList desktopFileNames;
      const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, componentName + QStringLiteral("/kpartplugins"), QStandardPaths::LocateDirectory);
-     Q_FOREACH (const QString &dir, dirs) {
+     for (const QString &dir : dirs) {
 -        QDirIterator it(dir, QStringList() << QStringLiteral("*.desktop"), QDir::NoFilter, QDirIterator::Subdirectories);
-+      QDirIterator it(dir, QStringList() << QStringLiteral("*.desktop"), QDir::NoFilter, QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
++        QDirIterator it(dir, QStringList() << QStringLiteral("*.desktop"), QDir::NoFilter, QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
          while (it.hasNext()) {
              desktopFileNames.append(it.next());
          }
diff --git a/pkgs/development/libraries/kde-frameworks/kconfigwidgets/0001-qdiriterator-follow-symlinks.patch b/pkgs/development/libraries/kde-frameworks/kconfigwidgets/0001-qdiriterator-follow-symlinks.patch
index 7a6c0ee90534..3b6ea27d41e5 100644
--- a/pkgs/development/libraries/kde-frameworks/kconfigwidgets/0001-qdiriterator-follow-symlinks.patch
+++ b/pkgs/development/libraries/kde-frameworks/kconfigwidgets/0001-qdiriterator-follow-symlinks.patch
@@ -1,25 +1,18 @@
-From 4f84780893d505b2d62a14633dd983baa8ec6e28 Mon Sep 17 00:00:00 2001
-From: Thomas Tuegel <ttuegel@gmail.com>
-Date: Wed, 14 Oct 2015 06:47:01 -0500
-Subject: [PATCH] qdiriterator follow symlinks
-
----
- src/khelpclient.cpp | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
 diff --git a/src/khelpclient.cpp b/src/khelpclient.cpp
-index 53a331e..80fbb01 100644
+index fbbc0fa..cb78741 100644
 --- a/src/khelpclient.cpp
 +++ b/src/khelpclient.cpp
 @@ -48,7 +48,7 @@ void KHelpClient::invokeHelp(const QString &anchor, const QString &_appname)
      QString docPath;
      const QStringList desktopDirs = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation);
-     Q_FOREACH (const QString &dir, desktopDirs) {
+     for (const QString &dir : desktopDirs) {
 -        QDirIterator it(dir, QStringList() << appname + QLatin1String(".desktop"), QDir::NoFilter, QDirIterator::Subdirectories);
 +        QDirIterator it(dir, QStringList() << appname + QLatin1String(".desktop"), QDir::NoFilter, QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
          while (it.hasNext()) {
              const QString desktopPath(it.next());
              KDesktopFile desktopFile(desktopPath);
--- 
-2.5.2
-
+@@ -75,4 +75,3 @@ void KHelpClient::invokeHelp(const QString &anchor, const QString &_appname)
+     // launch khelpcenter, or a browser for URIs not handled by khelpcenter
+     QDesktopServices::openUrl(url);
+ }
+-
diff --git a/pkgs/development/libraries/kde-frameworks/kcoreaddons.nix b/pkgs/development/libraries/kde-frameworks/kcoreaddons.nix
index 6658e4dca100..cd5f2163dd95 100644
--- a/pkgs/development/libraries/kde-frameworks/kcoreaddons.nix
+++ b/pkgs/development/libraries/kde-frameworks/kcoreaddons.nix
@@ -1,7 +1,7 @@
 {
   mkDerivation, lib, fetchurl, writeScript,
   extra-cmake-modules,
-  qtbase, qttools, shared_mime_info
+  qtbase, qttools, shared-mime-info
 }:
 
 mkDerivation {
@@ -11,6 +11,6 @@ mkDerivation {
     broken = builtins.compareVersions qtbase.version "5.7.0" < 0;
   };
   nativeBuildInputs = [ extra-cmake-modules ];
-  buildInputs = [ qttools shared_mime_info ];
+  buildInputs = [ qttools shared-mime-info ];
   propagatedBuildInputs = [ qtbase ];
 }
diff --git a/pkgs/development/libraries/kde-frameworks/kdelibs4support/default.nix b/pkgs/development/libraries/kde-frameworks/kdelibs4support/default.nix
index 6937a4056b28..7e3de9d4d141 100644
--- a/pkgs/development/libraries/kde-frameworks/kdelibs4support/default.nix
+++ b/pkgs/development/libraries/kde-frameworks/kdelibs4support/default.nix
@@ -5,7 +5,7 @@
   kdbusaddons, kded, kdesignerplugin, kemoticons, kglobalaccel, kguiaddons,
   ki18n, kiconthemes, kio, kitemmodels, kinit, knotifications, kparts, kservice,
   ktextwidgets, kunitconversion, kwidgetsaddons, kwindowsystem, kxmlgui,
-  networkmanager, qtbase, qtsvg, qttools, qtx11extras, xlibs
+  networkmanager, qtbase, qtsvg, qttools, qtx11extras, xorg
 }:
 
 mkDerivation {
@@ -17,7 +17,7 @@ mkDerivation {
   propagatedNativeBuildInputs = [ kdoctools ];
   buildInputs = [
     kcompletion kconfig kded kglobalaccel ki18n kio kservice kwidgetsaddons
-    kxmlgui networkmanager qtsvg qtx11extras xlibs.libSM
+    kxmlgui networkmanager qtsvg qtx11extras xorg.libSM
   ];
   propagatedBuildInputs = [
     kauth karchive kconfigwidgets kcoreaddons kcrash kdbusaddons kdesignerplugin
diff --git a/pkgs/development/libraries/kde-frameworks/kdoctools/default.nix b/pkgs/development/libraries/kde-frameworks/kdoctools/default.nix
index 661e89e30782..0a600fe8d057 100644
--- a/pkgs/development/libraries/kde-frameworks/kdoctools/default.nix
+++ b/pkgs/development/libraries/kde-frameworks/kdoctools/default.nix
@@ -8,10 +8,18 @@
 mkDerivation {
   name = "kdoctools";
   meta = { maintainers = [ lib.maintainers.ttuegel ]; };
-  nativeBuildInputs = [ extra-cmake-modules ];
-  propagatedNativeBuildInputs = [ perl perlPackages.URI ];
+  nativeBuildInputs = [
+    extra-cmake-modules
+    # The build system insists on having native Perl.
+    perl perlPackages.URI
+  ];
+  propagatedBuildInputs = [
+    # kdoctools at runtime actually needs Perl for the platform kdoctools is
+    # running on, not necessarily native perl.
+    perl perlPackages.URI
+    qtbase
+  ];
   buildInputs = [ karchive ki18n ];
-  propagatedBuildInputs = [ qtbase ];
   outputs = [ "out" "dev" ];
   patches = [ ./kdoctools-no-find-docbook-xml.patch ];
   cmakeFlags = [
diff --git a/pkgs/development/libraries/kde-frameworks/kdoctools/setup-hook.sh b/pkgs/development/libraries/kde-frameworks/kdoctools/setup-hook.sh
index 5cfffbd622d1..2928d9b34dbe 100644
--- a/pkgs/development/libraries/kde-frameworks/kdoctools/setup-hook.sh
+++ b/pkgs/development/libraries/kde-frameworks/kdoctools/setup-hook.sh
@@ -2,4 +2,4 @@ addXdgData() {
     addToSearchPath XDG_DATA_DIRS "$1/share"
 }
 
-envHooks+=(addXdgData)
+addEnvHooks "$targetOffset" addXdgData
diff --git a/pkgs/development/libraries/kde-frameworks/kglobalaccel.nix b/pkgs/development/libraries/kde-frameworks/kglobalaccel.nix
index 05fde45f17d2..ae945ab73384 100644
--- a/pkgs/development/libraries/kde-frameworks/kglobalaccel.nix
+++ b/pkgs/development/libraries/kde-frameworks/kglobalaccel.nix
@@ -13,8 +13,4 @@ mkDerivation {
     qtx11extras
   ];
   propagatedBuildInputs = [ qtbase ];
-  postPatch = ''
-    sed -i src/runtime/org.kde.kglobalaccel.service.in \
-        -e "s|@CMAKE_INSTALL_PREFIX@|''${!outputBin}|"
-  '';
 }
diff --git a/pkgs/development/libraries/kde-frameworks/ki18n.nix b/pkgs/development/libraries/kde-frameworks/ki18n.nix
index 3b9ca74bbd07..ee7d13af5b1e 100644
--- a/pkgs/development/libraries/kde-frameworks/ki18n.nix
+++ b/pkgs/development/libraries/kde-frameworks/ki18n.nix
@@ -1,5 +1,5 @@
 {
-  mkDerivation, lib,
+  mkDerivation, lib, fetchpatch,
   extra-cmake-modules, gettext, python,
   qtbase, qtdeclarative, qtscript,
 }:
@@ -13,4 +13,10 @@ mkDerivation {
   nativeBuildInputs = [ extra-cmake-modules ];
   propagatedNativeBuildInputs = [ gettext python ];
   buildInputs = [ qtdeclarative qtscript ];
+  patches = [
+    (fetchpatch {
+      url = "https://phabricator.kde.org/D12216?download=true";
+      sha256 = "04gpyb11vlgivqjx3lqdwgqb4ss5bphy5zmh65k57bbv4rnlsm15";
+    })
+  ];
 }
diff --git a/pkgs/development/libraries/kde-frameworks/kimageformats.nix b/pkgs/development/libraries/kde-frameworks/kimageformats.nix
index 26a8637bafc2..29748a5f7f42 100644
--- a/pkgs/development/libraries/kde-frameworks/kimageformats.nix
+++ b/pkgs/development/libraries/kde-frameworks/kimageformats.nix
@@ -12,5 +12,5 @@ mkDerivation {
   nativeBuildInputs = [ extra-cmake-modules ];
   buildInputs = [ karchive openexr qtbase ];
   outputs = [ "out" ]; # plugins only
-  NIX_CFLAGS_COMPILE = "-I${getDev ilmbase}/include/OpenEXR";
+  CXXFLAGS = "-I${getDev ilmbase}/include/OpenEXR";
 }
diff --git a/pkgs/development/libraries/kde-frameworks/kinit/default.nix b/pkgs/development/libraries/kde-frameworks/kinit/default.nix
index 1036ea277452..538078fd7457 100644
--- a/pkgs/development/libraries/kde-frameworks/kinit/default.nix
+++ b/pkgs/development/libraries/kde-frameworks/kinit/default.nix
@@ -14,10 +14,10 @@ mkDerivation {
     kconfig kcrash ki18n kio kservice kwindowsystem
   ];
   patches = copyPathsToStore (lib.readPathsFromFile ./. ./series);
-  NIX_CFLAGS_COMPILE = [
-    ''-DNIXPKGS_KF5_KIOCORE="${getLib kio}/lib/libKF5KIOCore.so.5"''
-    ''-DNIXPKGS_KF5_PARTS="${getLib kparts}/lib/libKF5Parts.so.5"''
-    ''-DNIXPKGS_KF5_PLASMA="${getLib plasma-framework}/lib/libKF5Plasma.so.5"''
+  CXXFLAGS = [
+    ''-DNIXPKGS_KF5_KIOCORE=\"${getLib kio}/lib/libKF5KIOCore.so.5\"''
+    ''-DNIXPKGS_KF5_PARTS=\"${getLib kparts}/lib/libKF5Parts.so.5\"''
+    ''-DNIXPKGS_KF5_PLASMA=\"${getLib plasma-framework}/lib/libKF5Plasma.so.5\"''
   ];
   postFixup = ''
     moveToOutput "lib/libexec/kf5/start_kdeinit" "$bin"
diff --git a/pkgs/development/libraries/kde-frameworks/kservice/default.nix b/pkgs/development/libraries/kde-frameworks/kservice/default.nix
index 3ac4f4dc2688..356e6537a4fd 100644
--- a/pkgs/development/libraries/kde-frameworks/kservice/default.nix
+++ b/pkgs/development/libraries/kde-frameworks/kservice/default.nix
@@ -2,7 +2,7 @@
   mkDerivation, lib, copyPathsToStore,
   bison, extra-cmake-modules, flex,
   kconfig, kcoreaddons, kcrash, kdbusaddons, kdoctools, ki18n, kwindowsystem,
-  qtbase, shared_mime_info,
+  qtbase, shared-mime-info,
 }:
 
 mkDerivation {
@@ -14,6 +14,6 @@ mkDerivation {
     kcrash kdbusaddons ki18n kwindowsystem qtbase
   ];
   propagatedBuildInputs = [ kconfig kcoreaddons ];
-  propagatedUserEnvPkgs = [ shared_mime_info ]; # for kbuildsycoca5
+  propagatedUserEnvPkgs = [ shared-mime-info ]; # for kbuildsycoca5
   patches = copyPathsToStore (lib.readPathsFromFile ./. ./series);
 }
diff --git a/pkgs/development/libraries/kde-frameworks/ktexteditor.nix b/pkgs/development/libraries/kde-frameworks/ktexteditor.nix
index 7fc11b1505c9..3efd4cf4e2a8 100644
--- a/pkgs/development/libraries/kde-frameworks/ktexteditor.nix
+++ b/pkgs/development/libraries/kde-frameworks/ktexteditor.nix
@@ -14,9 +14,4 @@ mkDerivation {
     qtxmlpatterns sonnet syntax-highlighting qtquickcontrols
   ];
   propagatedBuildInputs = [ kparts ];
-  patches = [ (fetchpatch {
-    url = "https://cgit.kde.org/ktexteditor.git/patch/?id=aeebeadb5f5955995c17de56cf83ba7166a132dd";
-    sha256 = "10a61w1qyw3czffl06xgccgd3yycz7s0hpg2vj0a24v05jhqiigf";
-    name = "ktextedtor_fix_indenters.patch";
-  })];
 }
diff --git a/pkgs/development/libraries/kde-frameworks/plasma-framework.nix b/pkgs/development/libraries/kde-frameworks/plasma-framework.nix
index d3a81b50bf17..44005ec7d282 100644
--- a/pkgs/development/libraries/kde-frameworks/plasma-framework.nix
+++ b/pkgs/development/libraries/kde-frameworks/plasma-framework.nix
@@ -4,7 +4,7 @@
   kactivities, karchive, kconfig, kconfigwidgets, kcoreaddons, kdbusaddons,
   kdeclarative, kglobalaccel, kguiaddons, ki18n, kiconthemes, kio,
   knotifications, kpackage, kservice, kwayland, kwindowsystem, kxmlgui,
-  qtbase, qtdeclarative, qtscript, qtx11extras,
+  qtbase, qtdeclarative, qtscript, qtx11extras, kirigami2, qtquickcontrols2
 }:
 
 mkDerivation {
@@ -14,7 +14,8 @@ mkDerivation {
   buildInputs = [
     kactivities karchive kconfig kconfigwidgets kcoreaddons kdbusaddons
     kdeclarative kglobalaccel kguiaddons ki18n kiconthemes kio knotifications
-    kwayland kwindowsystem kxmlgui qtdeclarative qtscript qtx11extras
+    kwayland kwindowsystem kxmlgui qtdeclarative qtscript qtx11extras kirigami2
+    qtquickcontrols2
   ];
   propagatedBuildInputs = [ kpackage kservice qtbase ];
 }
diff --git a/pkgs/development/libraries/kde-frameworks/srcs.nix b/pkgs/development/libraries/kde-frameworks/srcs.nix
index 3a8ed594655e..8e2187f29574 100644
--- a/pkgs/development/libraries/kde-frameworks/srcs.nix
+++ b/pkgs/development/libraries/kde-frameworks/srcs.nix
@@ -3,611 +3,627 @@
 
 {
   attica = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/attica-5.39.0.tar.xz";
-      sha256 = "15972518n4g65k391imkcsjikfsfhx8livdm6n0whag0aiz55haf";
-      name = "attica-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/attica-5.45.0.tar.xz";
+      sha256 = "1vzbajj2ldhg26ssxh0vkahj7fw5v9nhrv000vbxlhsrcczq81n5";
+      name = "attica-5.45.0.tar.xz";
     };
   };
   baloo = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/baloo-5.39.0.tar.xz";
-      sha256 = "06y8mv7v9y7syz04x0zicdm628k6za3p366xrzwafc43m159wyms";
-      name = "baloo-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/baloo-5.45.0.tar.xz";
+      sha256 = "0zr2pg946q3wc6bhsbngpmca0ylhw8ckfdrs6ym36v7xz3h5fhds";
+      name = "baloo-5.45.0.tar.xz";
     };
   };
   bluez-qt = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/bluez-qt-5.39.0.tar.xz";
-      sha256 = "0j0072q0zc9hdpjbkqciqv18pwpdij74qrjph7whh66csjkr5ad1";
-      name = "bluez-qt-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/bluez-qt-5.45.0.tar.xz";
+      sha256 = "056xl29yf7bkqrn655c9b2wdx69021q7cz176rx4daid70i8nx49";
+      name = "bluez-qt-5.45.0.tar.xz";
     };
   };
   breeze-icons = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/breeze-icons-5.39.0.tar.xz";
-      sha256 = "132bpgma1lqhrly48zz1f8jyg5z5pvnn1wnqxz6psvqhipw7fh5x";
-      name = "breeze-icons-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/breeze-icons-5.45.0.tar.xz";
+      sha256 = "0nzi4wy0p7lkb76nynmwbgnrsrfbhfxn3269mkbqwakq6i4mxsj8";
+      name = "breeze-icons-5.45.0.tar.xz";
     };
   };
   extra-cmake-modules = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/extra-cmake-modules-5.39.0.tar.xz";
-      sha256 = "1ldwzx2bzlzw7r31w8zy08j4cn9q7d1kszc5jb22zhfqpvbkc1dq";
-      name = "extra-cmake-modules-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/extra-cmake-modules-5.45.0.tar.xz";
+      sha256 = "0g7njdz6bqjcswq100mb2jr4l1mdicqq24wdw3a8f63syg5rvm76";
+      name = "extra-cmake-modules-5.45.0.tar.xz";
     };
   };
   frameworkintegration = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/frameworkintegration-5.39.0.tar.xz";
-      sha256 = "136s8chyiac30czicqgkrc4abgm7c8b2ppnqwv9ngxpx7nsjgd2h";
-      name = "frameworkintegration-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/frameworkintegration-5.45.0.tar.xz";
+      sha256 = "0s300vp674rq2dinhjjsp7v4gmv6ybxsk1r3asv3x789zwz1lr3i";
+      name = "frameworkintegration-5.45.0.tar.xz";
     };
   };
   kactivities = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kactivities-5.39.0.tar.xz";
-      sha256 = "0nkc1p7n6yvybcib6aqmnz08hwn3ryj1f9wbkiimgs0svr00sslq";
-      name = "kactivities-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kactivities-5.45.0.tar.xz";
+      sha256 = "0h3hym4am055f9kyhg98gabw00nb1h10b9dvbs3hs3178dyi5gjg";
+      name = "kactivities-5.45.0.tar.xz";
     };
   };
   kactivities-stats = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kactivities-stats-5.39.0.tar.xz";
-      sha256 = "18ghfqggwf38rmb1lkbv8ggxx71cp6ba3882kp5ccb7wwih51qcy";
-      name = "kactivities-stats-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kactivities-stats-5.45.0.tar.xz";
+      sha256 = "0jcvikr7yvjik8zdz46mkrxf2c3ydns194a07njw7hd15x1czqjl";
+      name = "kactivities-stats-5.45.0.tar.xz";
     };
   };
   kapidox = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kapidox-5.39.0.tar.xz";
-      sha256 = "12nmsa1cg5amyawfxywlg8qsl01idi0jacrd8jzmvdj5m8sisw6n";
-      name = "kapidox-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kapidox-5.45.0.tar.xz";
+      sha256 = "1996akdnhrky1bk63xraj0qawx6ar1vk6ia4rmdgq0bqjk804g1p";
+      name = "kapidox-5.45.0.tar.xz";
     };
   };
   karchive = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/karchive-5.39.0.tar.xz";
-      sha256 = "0rb8vr6lg8vx4f07swvlsyrxy4gj21aqfffk0cvhlsdz94j1phrw";
-      name = "karchive-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/karchive-5.45.0.tar.xz";
+      sha256 = "0gl86ybjkmjz6sl4s00j8mi43admj7xnjnmv92q5lngk75k1zbhq";
+      name = "karchive-5.45.0.tar.xz";
     };
   };
   kauth = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kauth-5.39.0.tar.xz";
-      sha256 = "08bjxvv22y199skx4l9m8az165wz7inqqx7s8b7p5cjms4bvi15i";
-      name = "kauth-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kauth-5.45.0.tar.xz";
+      sha256 = "1j6pgbkqjw70lnpk84wqi9m81hc55f1z4cfxkd8hhdk578pry56i";
+      name = "kauth-5.45.0.tar.xz";
     };
   };
   kbookmarks = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kbookmarks-5.39.0.tar.xz";
-      sha256 = "1xfabyc7hxmi1p0wqld0va5pl6bfwh50px4mvpxbnjdna6anw6z5";
-      name = "kbookmarks-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kbookmarks-5.45.0.tar.xz";
+      sha256 = "0ii0gi4vlngp0qypyn2780dnqpkg24k0wb5jpngllrvrf37132md";
+      name = "kbookmarks-5.45.0.tar.xz";
     };
   };
   kcmutils = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kcmutils-5.39.0.tar.xz";
-      sha256 = "1cz4haj83j59szl16r0mfh4zx93szrwkmb9mq2r21v46c8k5ldw0";
-      name = "kcmutils-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kcmutils-5.45.0.tar.xz";
+      sha256 = "0w082wr9h2rpk9jyads9bwdimhqjl6f68l710miwjglzcmfy4dgq";
+      name = "kcmutils-5.45.0.tar.xz";
     };
   };
   kcodecs = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kcodecs-5.39.0.tar.xz";
-      sha256 = "1q0l88nfbxgdy5lpm5xbcs749n9jyxhq7xsgqpf9c8irc7c1gw7f";
-      name = "kcodecs-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kcodecs-5.45.0.tar.xz";
+      sha256 = "0si694a64dbb65m7gzcvz474gd61nyvj71wh77chsbsh6hvl1xzx";
+      name = "kcodecs-5.45.0.tar.xz";
     };
   };
   kcompletion = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kcompletion-5.39.0.tar.xz";
-      sha256 = "09jdc4pn7yjb7nagic38xiqdpv9fy4f2f4c1a5ynbli7x1r6l7ms";
-      name = "kcompletion-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kcompletion-5.45.0.tar.xz";
+      sha256 = "0lqp0m715hqh8ci1cq7r1y00828ajjzz5y04xpxw78gk9gprakf8";
+      name = "kcompletion-5.45.0.tar.xz";
     };
   };
   kconfig = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kconfig-5.39.0.tar.xz";
-      sha256 = "011i48f07470igqqcz4hychbw0q85p0bh5dykpla4zwdldllsl1w";
-      name = "kconfig-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kconfig-5.45.0.tar.xz";
+      sha256 = "00r7vh2myh518wfngfr1gmz6svmnvjfx9bxv8px5z1ap0yda181p";
+      name = "kconfig-5.45.0.tar.xz";
     };
   };
   kconfigwidgets = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kconfigwidgets-5.39.0.tar.xz";
-      sha256 = "1i6cniqsmn9sds8nj7bcsnbmlkq9m1yjwvr45mhal9rkhaas4xzw";
-      name = "kconfigwidgets-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kconfigwidgets-5.45.0.tar.xz";
+      sha256 = "0kj0a2x6f27hkzyl7pfz20b0mv4625nxr7iqdq130wdy5x0wv71l";
+      name = "kconfigwidgets-5.45.0.tar.xz";
     };
   };
   kcoreaddons = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kcoreaddons-5.39.0.tar.xz";
-      sha256 = "0qskv44siykyn8iiq99llibw3bk499ry7r3i8abx4ljjl717cvlz";
-      name = "kcoreaddons-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kcoreaddons-5.45.0.tar.xz";
+      sha256 = "15zgz8yhw7z31rljgj63hd949sp48syd1ggbay5nmnsb91ly0z92";
+      name = "kcoreaddons-5.45.0.tar.xz";
     };
   };
   kcrash = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kcrash-5.39.0.tar.xz";
-      sha256 = "1fv32l50h9rlc5s9iplyljcsrscivgdy2baghq7hbcs58xrjf1ws";
-      name = "kcrash-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kcrash-5.45.0.tar.xz";
+      sha256 = "1ny3m1jqazf7b2qrh4dlprwyf60cddk2c88dxhmzr02a8040gckv";
+      name = "kcrash-5.45.0.tar.xz";
     };
   };
   kdbusaddons = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kdbusaddons-5.39.0.tar.xz";
-      sha256 = "0hp85995n3193dvvdv48hv59b66dzd9p4iwnx2dmj797lghpnir3";
-      name = "kdbusaddons-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kdbusaddons-5.45.0.tar.xz";
+      sha256 = "071zr5d95j1cd1djqd5nkfz5n224dmzsbx2a446dsp9liklhqaz6";
+      name = "kdbusaddons-5.45.0.tar.xz";
     };
   };
   kdeclarative = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kdeclarative-5.39.0.tar.xz";
-      sha256 = "1l8wnyfz6qjqmcpdzavsb6m1r3ay1b2r186myymsyknr80yr2d7p";
-      name = "kdeclarative-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kdeclarative-5.45.0.tar.xz";
+      sha256 = "0h84nla5symfdyrv5dvgs8b1mz0czclipiki16xglzdsja9z9xpl";
+      name = "kdeclarative-5.45.0.tar.xz";
     };
   };
   kded = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kded-5.39.0.tar.xz";
-      sha256 = "0jv4ghl2gzfdkhk1in3vx39kigvpprvcb9xlzc5506mpfjc38ga5";
-      name = "kded-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kded-5.45.0.tar.xz";
+      sha256 = "0qr4ycqqz2g5k9pzllahc7aj1b6fyh0zidvaxvbw600wjr5v3acw";
+      name = "kded-5.45.0.tar.xz";
     };
   };
   kdelibs4support = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/portingAids/kdelibs4support-5.39.0.tar.xz";
-      sha256 = "03xjzhdvs497sk9bpz79crxlzwff198ivj4n5f0mwmnqc0100dfp";
-      name = "kdelibs4support-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/portingAids/kdelibs4support-5.45.0.tar.xz";
+      sha256 = "0kil35fj9p8g99jmmkvch326j32wfjqrhypzwg0sa0d74vc2pv5s";
+      name = "kdelibs4support-5.45.0.tar.xz";
     };
   };
   kdesignerplugin = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kdesignerplugin-5.39.0.tar.xz";
-      sha256 = "1b7rn66wsyn9aipgvfmn2pq18g0zdjxb469126dj18fahg2k777f";
-      name = "kdesignerplugin-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kdesignerplugin-5.45.0.tar.xz";
+      sha256 = "0gqvga5akilmqldhzmgjyngbz2dmxmkcjq2g5diq6pijiafsx8kj";
+      name = "kdesignerplugin-5.45.0.tar.xz";
     };
   };
   kdesu = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kdesu-5.39.0.tar.xz";
-      sha256 = "03avzhs6a0p3cjv4kk9vavf6f64ffgs3pzhbdkfr76fh58h1v6wx";
-      name = "kdesu-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kdesu-5.45.0.tar.xz";
+      sha256 = "0znncn74vmczcqffc0n6q39q3mk4vsfwj3zn5kglzzsg0x730aly";
+      name = "kdesu-5.45.0.tar.xz";
     };
   };
   kdewebkit = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kdewebkit-5.39.0.tar.xz";
-      sha256 = "05f0l3zw8cnvyavwwijwy5jx8dairhdbvg6ynpn7r5l10vawcf6x";
-      name = "kdewebkit-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kdewebkit-5.45.0.tar.xz";
+      sha256 = "0jdxaaysgdgp15yn2fnxf6m22djyvnl4jcyyrjxz7mz0s0lc4pg9";
+      name = "kdewebkit-5.45.0.tar.xz";
     };
   };
   kdnssd = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kdnssd-5.39.0.tar.xz";
-      sha256 = "1c8d1wwr0hkdkgnq4k7lgkqwm1pj676i09l1kas256rzz6dcyl75";
-      name = "kdnssd-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kdnssd-5.45.0.tar.xz";
+      sha256 = "181slqgyp7xsg6xz92zris6yjmzysglvkbiyiii4245z1ms9pf0x";
+      name = "kdnssd-5.45.0.tar.xz";
     };
   };
   kdoctools = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kdoctools-5.39.0.tar.xz";
-      sha256 = "17g4kf7mbjjxhii4nbhfpmhjs1q23mlh0d3fqyxxhm3pp02jg8ap";
-      name = "kdoctools-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kdoctools-5.45.0.tar.xz";
+      sha256 = "0b2bkn9a7nxyynn5cy53kb62khfklayj8fwgfdh3sr5a15yjycm5";
+      name = "kdoctools-5.45.0.tar.xz";
     };
   };
   kemoticons = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kemoticons-5.39.0.tar.xz";
-      sha256 = "132gs69v43ms117ibdqmnhbyzzs5by76pfz7bd2zqwl4mq94hpgh";
-      name = "kemoticons-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kemoticons-5.45.0.tar.xz";
+      sha256 = "1981430xbypxswayrjf5c9bvk65dd2gsima8k0rvysbcqlnyqq7s";
+      name = "kemoticons-5.45.0.tar.xz";
     };
   };
   kfilemetadata = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kfilemetadata-5.39.0.tar.xz";
-      sha256 = "1mcxphjpayyq7v16b6c3zhb6c9vn67495xywfb9y8ysma1cdpshg";
-      name = "kfilemetadata-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kfilemetadata-5.45.0.tar.xz";
+      sha256 = "0wcgsbpkvi8pls9zh24z4c328dl7lq8km4r7dag9vw4200bncwa6";
+      name = "kfilemetadata-5.45.0.tar.xz";
     };
   };
   kglobalaccel = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kglobalaccel-5.39.0.tar.xz";
-      sha256 = "0wcbnwfi98cx8f99a2mcz2kg7mggz3hipfxv9s8ks6c80865kar1";
-      name = "kglobalaccel-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kglobalaccel-5.45.0.tar.xz";
+      sha256 = "1iwmwpdxrymsyryvp007n3kz2w9syhl4h9jk6x77hprnmwj62cym";
+      name = "kglobalaccel-5.45.0.tar.xz";
     };
   };
   kguiaddons = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kguiaddons-5.39.0.tar.xz";
-      sha256 = "1az9i5bg7xd7kv7ajq8j8jab7zly683gyi90rmk54vfnn6igbq3f";
-      name = "kguiaddons-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kguiaddons-5.45.0.tar.xz";
+      sha256 = "16cgi9a9laiwzg2fbp5hl3qlxjmhq0l7dw5kjpkzm7xvlj0rm5cn";
+      name = "kguiaddons-5.45.0.tar.xz";
+    };
+  };
+  kholidays = {
+    version = "5.45.0";
+    src = fetchurl {
+      url = "${mirror}/stable/frameworks/5.45/kholidays-5.45.0.tar.xz";
+      sha256 = "02bcybzkzp26sz6rjnsh60jmwidmjg8wnixzxs5fk7h8qfygm4ra";
+      name = "kholidays-5.45.0.tar.xz";
     };
   };
   khtml = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/portingAids/khtml-5.39.0.tar.xz";
-      sha256 = "097nbwv8ba48xmrga62j1irlkkc0l0f3971fp7225pzh1g3cg152";
-      name = "khtml-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/portingAids/khtml-5.45.0.tar.xz";
+      sha256 = "1ligyb5hpp53q13r9a2w1xi7b5dc1xqqi9bf3jri01n9pf5d4ynq";
+      name = "khtml-5.45.0.tar.xz";
     };
   };
   ki18n = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/ki18n-5.39.0.tar.xz";
-      sha256 = "1985qgihrch37b5gf7qw33bazahm3xb5v2nj43k6vdjxfg1clcay";
-      name = "ki18n-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/ki18n-5.45.0.tar.xz";
+      sha256 = "1xjwwlr46x0wr26xn4z086rlzm2bgzyi1ck91cbcc0jv6p6n43mp";
+      name = "ki18n-5.45.0.tar.xz";
     };
   };
   kiconthemes = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kiconthemes-5.39.0.tar.xz";
-      sha256 = "1k4r263zz54497dgqaw9a74wqdklq4w353mc0g905k2g8arh7p9f";
-      name = "kiconthemes-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kiconthemes-5.45.0.tar.xz";
+      sha256 = "0wir8drhv5lx00f4n984yh5xavpi75vg1vpyrf68dd490klwzg45";
+      name = "kiconthemes-5.45.0.tar.xz";
     };
   };
   kidletime = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kidletime-5.39.0.tar.xz";
-      sha256 = "01h5pcr5kn11jby0zsz6igiwzf31hzip7h63dcsa8h67li4sibd8";
-      name = "kidletime-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kidletime-5.45.0.tar.xz";
+      sha256 = "0057az4a9jvn120j94jsmf78lxw03c6s534mjn4r8ns9j46c060i";
+      name = "kidletime-5.45.0.tar.xz";
     };
   };
   kimageformats = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kimageformats-5.39.0.tar.xz";
-      sha256 = "1mnfdsxqnqdzhw3as77n1f1ddxpmab4slqlpwi4ih55xmgl85455";
-      name = "kimageformats-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kimageformats-5.45.0.tar.xz";
+      sha256 = "0kdcrlpj56sw9gy9wf6dxlrsa11k3hv6ayvv6irry3iv1akfx7yp";
+      name = "kimageformats-5.45.0.tar.xz";
     };
   };
   kinit = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kinit-5.39.0.tar.xz";
-      sha256 = "0a2wl1vhsbb2x1cjd3wz7j3bp9kz1pxfc6mml7gpnq70qgk8hsn2";
-      name = "kinit-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kinit-5.45.0.tar.xz";
+      sha256 = "0phqwp60368vynnkh0hl3kdz6p0kisa5ab6fvgvks5p9h1nb6l2h";
+      name = "kinit-5.45.0.tar.xz";
     };
   };
   kio = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kio-5.39.0.tar.xz";
-      sha256 = "091g4dbnals6c5wrj3xh3ws29wszysmb9ksyvyqf3d1lp9dfmjwn";
-      name = "kio-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kio-5.45.0.tar.xz";
+      sha256 = "05bb27jfinpfdh3vz76prkdvpp574sx1sr41b6qk267y37l14x9y";
+      name = "kio-5.45.0.tar.xz";
     };
   };
   kirigami2 = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kirigami2-5.39.0.tar.xz";
-      sha256 = "0spgylk4yjy74rs5d5b28qv72qz5ra9j3wfmk6vx2b6cvf1fw517";
-      name = "kirigami2-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kirigami2-5.45.0.tar.xz";
+      sha256 = "00miz1zwhq5ikwyqvvl6ha8w1dra7rxgw59wfg1ac74kjpb964ng";
+      name = "kirigami2-5.45.0.tar.xz";
     };
   };
   kitemmodels = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kitemmodels-5.39.0.tar.xz";
-      sha256 = "1bn0k0ya2phix6fyv8ax800ahncrkdzikz0sa3xrw5bq3iz1x6k9";
-      name = "kitemmodels-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kitemmodels-5.45.0.tar.xz";
+      sha256 = "08mbvs6lcfwbprk51fjswig0sprn5pcgrhy34qbbnim5ijf8gkw1";
+      name = "kitemmodels-5.45.0.tar.xz";
     };
   };
   kitemviews = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kitemviews-5.39.0.tar.xz";
-      sha256 = "0pl899d1lz1dymdbq70485a8332z9i3s38dxnxv3cdwbla3xlsfh";
-      name = "kitemviews-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kitemviews-5.45.0.tar.xz";
+      sha256 = "19cm7vxkp7qiqhjj7ma2nx4lvp2hiffnakiic26jqzb9sb0vkq2n";
+      name = "kitemviews-5.45.0.tar.xz";
     };
   };
   kjobwidgets = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kjobwidgets-5.39.0.tar.xz";
-      sha256 = "1z26555pkirdkfw8c9j1a863pqybklryfa30v3a59a0m9v2jdzfc";
-      name = "kjobwidgets-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kjobwidgets-5.45.0.tar.xz";
+      sha256 = "1946wqa6dpi82771nw70nz123w1xa9znhn9kgb0q5ypzc89498gj";
+      name = "kjobwidgets-5.45.0.tar.xz";
     };
   };
   kjs = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/portingAids/kjs-5.39.0.tar.xz";
-      sha256 = "0fkn308l6drj7pa94niqhcn2pqv7da7da5lq1nk8q6zlyg4nbcrn";
-      name = "kjs-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/portingAids/kjs-5.45.0.tar.xz";
+      sha256 = "1xmc57fv3692vk0pzmrs1wyzgd69dhp6by0i1kw4a76w8h0lh5sr";
+      name = "kjs-5.45.0.tar.xz";
     };
   };
   kjsembed = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/portingAids/kjsembed-5.39.0.tar.xz";
-      sha256 = "1i3qyxr409x82nqyck4qva63maxa2vvi07i0yxm6zqx5lvm9gkgb";
-      name = "kjsembed-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/portingAids/kjsembed-5.45.0.tar.xz";
+      sha256 = "15jlbr5nw3c3p4cylr01c6w8isf78wnljsym8fsl9513k8cfabif";
+      name = "kjsembed-5.45.0.tar.xz";
     };
   };
   kmediaplayer = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/portingAids/kmediaplayer-5.39.0.tar.xz";
-      sha256 = "09ysw11br4k26bq6rvzcws2g565336p3gjkz4fxc8w2g3ma527p1";
-      name = "kmediaplayer-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/portingAids/kmediaplayer-5.45.0.tar.xz";
+      sha256 = "0p3fm448xdcw7qmpbadx9rb6q1zx8bbap0a3xm11ni27s7dpvwgf";
+      name = "kmediaplayer-5.45.0.tar.xz";
     };
   };
   knewstuff = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/knewstuff-5.39.0.tar.xz";
-      sha256 = "1amflv96ybd6dqkc1chmz6d5crrl4dcq07fwsalxzx9mgr0z499r";
-      name = "knewstuff-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/knewstuff-5.45.0.tar.xz";
+      sha256 = "0jk2zsxkj558rf2ar120mljjv13f261js9p27272wr6ily55navn";
+      name = "knewstuff-5.45.0.tar.xz";
     };
   };
   knotifications = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/knotifications-5.39.0.tar.xz";
-      sha256 = "0f38ca090p291d114fg3jz25lhwz7vad7s60ql4x3xwmdgaaw7dj";
-      name = "knotifications-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/knotifications-5.45.0.tar.xz";
+      sha256 = "0rnqlfg7n86g7fdmx32l337xjr03g1ri88dg94wci3v9rpffy839";
+      name = "knotifications-5.45.0.tar.xz";
     };
   };
   knotifyconfig = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/knotifyconfig-5.39.0.tar.xz";
-      sha256 = "09nk6sr6sp9a85lj4x9ac0ir4s5ac08835927b95d7m4ap2dbxrb";
-      name = "knotifyconfig-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/knotifyconfig-5.45.0.tar.xz";
+      sha256 = "0qxfzrw8pmnm6jrl98d50d12x9azgj3f9bin2irim2w6zcsfqs37";
+      name = "knotifyconfig-5.45.0.tar.xz";
     };
   };
   kpackage = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kpackage-5.39.0.tar.xz";
-      sha256 = "1ibppkg9m77p0dcpfshcd891vlxcfgx6rk205gq6d5qxyqizygki";
-      name = "kpackage-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kpackage-5.45.0.tar.xz";
+      sha256 = "0ddmpn688dil3sdlr91iqczi52rz58nwifij00c0gvj5pgp6agvg";
+      name = "kpackage-5.45.0.tar.xz";
     };
   };
   kparts = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kparts-5.39.0.tar.xz";
-      sha256 = "1r32jf2qbhqdjih9ff4n0ajd6s1cdncpq367mp5am31fz1jv3sr6";
-      name = "kparts-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kparts-5.45.0.tar.xz";
+      sha256 = "0mhmy6sq21c4rgl4lfz9sr3r4zhzn2wfapm3g7qzf8554rinzs5z";
+      name = "kparts-5.45.0.tar.xz";
     };
   };
   kpeople = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kpeople-5.39.0.tar.xz";
-      sha256 = "1s78dld3zlldhpk66s08v34zwi1k5ghivzbi7ab290sgrjc9afar";
-      name = "kpeople-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kpeople-5.45.0.tar.xz";
+      sha256 = "1dm8nb9ckivww867541w6bfjvhg6hi64drzx61ak1ix3ha6n24g1";
+      name = "kpeople-5.45.0.tar.xz";
     };
   };
   kplotting = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kplotting-5.39.0.tar.xz";
-      sha256 = "1diy1f23n6pih0s91kv1bp4mnnypnjl3pmi1xqni1v2cfwy0mnba";
-      name = "kplotting-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kplotting-5.45.0.tar.xz";
+      sha256 = "1fdvbd57f8aikgi6xa5qb16a32398zkn83xb6vq5rjd3jrzyk4bi";
+      name = "kplotting-5.45.0.tar.xz";
     };
   };
   kpty = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kpty-5.39.0.tar.xz";
-      sha256 = "02h6dg3w3k58d1ydzyz6mhd1y5gds3k64wdsb84fnpxvlw46dlhn";
-      name = "kpty-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kpty-5.45.0.tar.xz";
+      sha256 = "0g8daxvybiraax0395sb05468qfzdg0cjgq810kz78512carsg7f";
+      name = "kpty-5.45.0.tar.xz";
     };
   };
   kross = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/portingAids/kross-5.39.0.tar.xz";
-      sha256 = "1gh9gicr7ba8y3c0r7qpw2fj651fbbrhsy8gps8yll71axhxqvfh";
-      name = "kross-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/portingAids/kross-5.45.0.tar.xz";
+      sha256 = "1s8y36cn9nj5lqf8f667yyqdk0m4ankqb0fr3s9c7llb87ca8iqn";
+      name = "kross-5.45.0.tar.xz";
     };
   };
   krunner = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/krunner-5.39.0.tar.xz";
-      sha256 = "0gxs9z8mlb3s615ccrgkwyxww4jly48d8fkay33zwjaanqhkhgfl";
-      name = "krunner-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/krunner-5.45.0.tar.xz";
+      sha256 = "18rq5nzdxr8x55s3hqp5b3mibfa51sbybirhdp49igz9x2la2j9x";
+      name = "krunner-5.45.0.tar.xz";
     };
   };
   kservice = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kservice-5.39.0.tar.xz";
-      sha256 = "0abz878yc8yir7iv5scn55d0g2nljnzhr9c81wa6ggjsw0h077hl";
-      name = "kservice-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kservice-5.45.0.tar.xz";
+      sha256 = "0qrawj6hvy6q68k278nqkmdnjqk1cwr6iym9wmiq3lphsab08nl7";
+      name = "kservice-5.45.0.tar.xz";
     };
   };
   ktexteditor = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/ktexteditor-5.39.0.tar.xz";
-      sha256 = "1bk5wlvzjmfv7g9ab77asn055jp647zj69mfx2z3lvxb69swdnf5";
-      name = "ktexteditor-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/ktexteditor-5.45.0.tar.xz";
+      sha256 = "1gp5f9v01f0824j96wmv7a48561wkcndnk75q1qdbkknxk4cmnnp";
+      name = "ktexteditor-5.45.0.tar.xz";
     };
   };
   ktextwidgets = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/ktextwidgets-5.39.0.tar.xz";
-      sha256 = "0p6h165y03ir7qdf50kc77iq9plgvx39c8pz9dalvscvx42d2jaq";
-      name = "ktextwidgets-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/ktextwidgets-5.45.0.tar.xz";
+      sha256 = "1r76qvn02m6b1rvzmp966xfxr6ifflzd7g7ln0sxccsd9c46lh2b";
+      name = "ktextwidgets-5.45.0.tar.xz";
     };
   };
   kunitconversion = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kunitconversion-5.39.0.tar.xz";
-      sha256 = "04r1b2nc6vi56nfh6glhhd3d9v0ywxn2waibryjbszwrr39yhlzv";
-      name = "kunitconversion-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kunitconversion-5.45.0.tar.xz";
+      sha256 = "0alm5s3c6g3w66gzii7jjsb0cn4naiimsnm5dag6idhix79wa1kr";
+      name = "kunitconversion-5.45.0.tar.xz";
     };
   };
   kwallet = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kwallet-5.39.0.tar.xz";
-      sha256 = "1vlz9y3r1n6w7q9is60jsl9f7bm1djckdi9ibgzanwsp4k5ab0sz";
-      name = "kwallet-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kwallet-5.45.0.tar.xz";
+      sha256 = "1yis49k3wyk8vhmdhgjrn42jq5kah5z7dg8wgy09dhq61w50sdi9";
+      name = "kwallet-5.45.0.tar.xz";
     };
   };
   kwayland = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kwayland-5.39.0.tar.xz";
-      sha256 = "0a9hi47nrsspkak88c9f6ind2i7q69zjmrgr5n7xsa4zxznwhx6x";
-      name = "kwayland-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kwayland-5.45.0.tar.xz";
+      sha256 = "0pk242h8ggd3szyw6jlk0zz8q4rw4ppbbidkilzv3lx340jr1qkq";
+      name = "kwayland-5.45.0.tar.xz";
     };
   };
   kwidgetsaddons = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kwidgetsaddons-5.39.0.tar.xz";
-      sha256 = "1d0d3ags15vr7ck031m6n5n3hw347siskzhb8rsgzghn6xnmbfdb";
-      name = "kwidgetsaddons-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kwidgetsaddons-5.45.0.tar.xz";
+      sha256 = "0ywya6fa0q7vdwj7almkvdi16m839c48ma7j9sd87rc0dhigv0p0";
+      name = "kwidgetsaddons-5.45.0.tar.xz";
     };
   };
   kwindowsystem = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kwindowsystem-5.39.0.tar.xz";
-      sha256 = "1dys70va4h00ixxgxv52wbg8wi3jgsqckaikjqr34fzrmjh1lxqp";
-      name = "kwindowsystem-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kwindowsystem-5.45.0.tar.xz";
+      sha256 = "0139413wk8ifyfwadln87ik55jrp5bccy3lbz6ya191fygglx16k";
+      name = "kwindowsystem-5.45.0.tar.xz";
     };
   };
   kxmlgui = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kxmlgui-5.39.0.tar.xz";
-      sha256 = "0zwy11rh3yphl2346hmcahajxkgmrnfz1m8pd3vlnjs175dwz115";
-      name = "kxmlgui-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kxmlgui-5.45.0.tar.xz";
+      sha256 = "1vb5izjp27qb9685haidagjg2p14a335fwzagzal20z3j2a7j3hv";
+      name = "kxmlgui-5.45.0.tar.xz";
     };
   };
   kxmlrpcclient = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/kxmlrpcclient-5.39.0.tar.xz";
-      sha256 = "1j4a1n3ydln62m98h5p5lxlg1i7k5vzxb4f9kxkvzhw5gfpy78zs";
-      name = "kxmlrpcclient-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/kxmlrpcclient-5.45.0.tar.xz";
+      sha256 = "0kfkai1cc4xb7vcspbmf6zd951dfz2yxiyjdar4d21s5krvcfh5l";
+      name = "kxmlrpcclient-5.45.0.tar.xz";
     };
   };
   modemmanager-qt = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/modemmanager-qt-5.39.0.tar.xz";
-      sha256 = "0gdsp1017yjcfbq2jny7jz5rv7y4cavps5pfvg7zmylx0v057zk7";
-      name = "modemmanager-qt-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/modemmanager-qt-5.45.0.tar.xz";
+      sha256 = "16qdvy19q5pjk82amn3mncwgvk3g2qrbdzl9wpfxhqcny18xbwdd";
+      name = "modemmanager-qt-5.45.0.tar.xz";
     };
   };
   networkmanager-qt = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/networkmanager-qt-5.39.0.tar.xz";
-      sha256 = "1jksv0zsdmkrid2f1m92fxw3gl6crcjaw43v5zra8h2m394iyr81";
-      name = "networkmanager-qt-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/networkmanager-qt-5.45.0.tar.xz";
+      sha256 = "00ipzc92v229bz9vv6kga37qhpcnqrxn2h47v9n5myfr1p6acgw0";
+      name = "networkmanager-qt-5.45.0.tar.xz";
     };
   };
   oxygen-icons5 = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/oxygen-icons5-5.39.0.tar.xz";
-      sha256 = "1k1rns0fz5gvfnfwg60lrcw885cqmn814nzql9jvk07340w29s98";
-      name = "oxygen-icons5-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/oxygen-icons5-5.45.0.tar.xz";
+      sha256 = "1va0296118x7apb7idjf0qjx5f0flamspmzicc03znbh4hx1fxyc";
+      name = "oxygen-icons5-5.45.0.tar.xz";
     };
   };
   plasma-framework = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/plasma-framework-5.39.0.tar.xz";
-      sha256 = "1gaxk9mzwlyld09gqk29y3shvi6a1g1q3l849a9kl1hd07gr53x3";
-      name = "plasma-framework-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/plasma-framework-5.45.0.tar.xz";
+      sha256 = "1db8pyq1bdkswi59aihaqgas3xzzlfsfd9yn34g4q00gzc17ird5";
+      name = "plasma-framework-5.45.0.tar.xz";
     };
   };
   prison = {
-    version = "5.39.0";
+    version = "5.45.0";
+    src = fetchurl {
+      url = "${mirror}/stable/frameworks/5.45/prison-5.45.0.tar.xz";
+      sha256 = "1g6rnyx84sz28cf427y9yp0lcbdhrlgx4ns80jz34gyzcgi4bxi0";
+      name = "prison-5.45.0.tar.xz";
+    };
+  };
+  purpose = {
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/prison-5.39.0.tar.xz";
-      sha256 = "1b0ji341xcamrd19z54r2nkm8cglbr4qfxyxmqzn8yc6icfl61nv";
-      name = "prison-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/purpose-5.45.0.tar.xz";
+      sha256 = "0mfx2gl78w2wwkykl0zch88i7d10zq5cm2xqwxjfpkpdjwb7pflb";
+      name = "purpose-5.45.0.tar.xz";
     };
   };
   qqc2-desktop-style = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/qqc2-desktop-style-5.39.0.tar.xz";
-      sha256 = "1q8ihhrnk2dh6bbmwkz822l5vv15y11qaj7gig1lf7xw5nr1i27v";
-      name = "qqc2-desktop-style-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/qqc2-desktop-style-5.45.0.tar.xz";
+      sha256 = "1dc20wkh2cfyhd7wkg1v1b5f6asz70m8ksml6r5hzs807sdqvrsa";
+      name = "qqc2-desktop-style-5.45.0.tar.xz";
     };
   };
   solid = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/solid-5.39.0.tar.xz";
-      sha256 = "19bl7hzg1fya613vqhdxllh09csm6amrndnhfqnx90w4gb31p36r";
-      name = "solid-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/solid-5.45.0.tar.xz";
+      sha256 = "175hsj2hdsdnz4wkg1l56275390nn1kjpwcyb7ryzzqabn7hdqmd";
+      name = "solid-5.45.0.tar.xz";
     };
   };
   sonnet = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/sonnet-5.39.0.tar.xz";
-      sha256 = "1b5bfjbpb6l3c9j9k42shhnz9lqqxk2g607qx9ni0n2pr7w2p7w1";
-      name = "sonnet-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/sonnet-5.45.0.tar.xz";
+      sha256 = "0msrwxfvc4vr4xqpwavnj0w4cwkflfjql8nhgm5bvk6cpcxs92ss";
+      name = "sonnet-5.45.0.tar.xz";
     };
   };
   syntax-highlighting = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/syntax-highlighting-5.39.0.tar.xz";
-      sha256 = "0b8sdkh9dqmqk3x48d25v4qhrqph0mv76v47skhvls9jspw7kzdc";
-      name = "syntax-highlighting-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/syntax-highlighting-5.45.0.tar.xz";
+      sha256 = "1v73jzansk6z0kwq65gxvkcm7vcmgw2jvl7916aqzj8xjx8kp433";
+      name = "syntax-highlighting-5.45.0.tar.xz";
     };
   };
   threadweaver = {
-    version = "5.39.0";
+    version = "5.45.0";
     src = fetchurl {
-      url = "${mirror}/stable/frameworks/5.39/threadweaver-5.39.0.tar.xz";
-      sha256 = "101bk8rzdysb3vi3vbbkh2s7sb1dhnsa8ncdvdsxqyyaya9ns4aw";
-      name = "threadweaver-5.39.0.tar.xz";
+      url = "${mirror}/stable/frameworks/5.45/threadweaver-5.45.0.tar.xz";
+      sha256 = "16s1pgyxhs6v1w7pwg3rr97xkd24xmf23x24pcm15ybd9g38a5yp";
+      name = "threadweaver-5.45.0.tar.xz";
     };
   };
 }
diff --git a/pkgs/development/libraries/kdiagram/default.nix b/pkgs/development/libraries/kdiagram/default.nix
index 853f02f566a0..50f3e6a6c025 100644
--- a/pkgs/development/libraries/kdiagram/default.nix
+++ b/pkgs/development/libraries/kdiagram/default.nix
@@ -13,7 +13,7 @@ mkDerivation {
   nativeBuildInputs = [ extra-cmake-modules qttools ];
   propagatedBuildInputs = [ qtbase qtsvg ];
   meta = {
-    shortDescription = "Libraries for creating business diagrams";
+    description = "Libraries for creating business diagrams";
     license = lib.licenses.gpl2;
     platforms = qtbase.meta.platforms;
     maintainers = [ lib.maintainers.ttuegel ];
diff --git a/pkgs/development/libraries/kerberos/heimdal-make-missing-headers.patch b/pkgs/development/libraries/kerberos/heimdal-make-missing-headers.patch
new file mode 100644
index 000000000000..a0fa625538b7
--- /dev/null
+++ b/pkgs/development/libraries/kerberos/heimdal-make-missing-headers.patch
@@ -0,0 +1,10 @@
+--- a/lib/hx509/Makefile.am 2018-03-21 15:41:38.622968809 +0100
++++ b/lib/hx509/Makefile.am 2018-03-21 15:41:32.655162197 +0100
+@@ -9,6 +9,8 @@
+	sel-gram.h			\
+	$(gen_files_ocsp:.x=.c)		\
+	$(gen_files_pkcs10:.x=.c)	\
++	ocsp_asn1.h			\
++	pkcs10_asn1.h			\
+	hx509_err.c			\
+	hx509_err.h
diff --git a/pkgs/development/libraries/kerberos/heimdal.nix b/pkgs/development/libraries/kerberos/heimdal.nix
index 81f878daaaaa..b72a00d242e9 100644
--- a/pkgs/development/libraries/kerberos/heimdal.nix
+++ b/pkgs/development/libraries/kerberos/heimdal.nix
@@ -12,15 +12,17 @@ in
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "${type}heimdal-${version}";
-  version = "7.4.0";
+  version = "7.5.0";
 
   src = fetchFromGitHub {
     owner = "heimdal";
     repo = "heimdal";
     rev = "heimdal-${version}";
-    sha256 = "01ch6kqjrxi9fki54yjj2fhxhdkxijz161w2inh5k8mcixlf67vp";
+    sha256 = "1j38wjj4k0q8vx168k3d3k0fwa8j1q5q8f2688nnx1b9qgjd6w1d";
   };
 
+  patches = [ ./heimdal-make-missing-headers.patch ];
+
   nativeBuildInputs = [ autoreconfHook pkgconfig python2 perl yacc flex ]
     ++ (with perlPackages; [ JSON ])
     ++ optional (!libOnly) texinfo;
@@ -44,6 +46,10 @@ stdenv.mkDerivation rec {
     "--with-capng"
   ];
 
+  postUnpack = ''
+    sed -i '/^DEFAULT_INCLUDES/ s,$, -I..,' source/cf/Makefile.am.common
+  '';
+
   buildPhase = optionalString libOnly ''
     (cd include; make -j $NIX_BUILD_CORES)
     (cd lib; make -j $NIX_BUILD_CORES)
diff --git a/pkgs/development/libraries/kerberos/krb5.nix b/pkgs/development/libraries/kerberos/krb5.nix
index 1e64a4d66005..98073b7bbdc4 100644
--- a/pkgs/development/libraries/kerberos/krb5.nix
+++ b/pkgs/development/libraries/kerberos/krb5.nix
@@ -19,10 +19,18 @@ stdenv.mkDerivation rec {
     sha256 = "0zn8s7anb10hw3nzwjz7vg10fgmmgvwnibn2zrn3nppjxn9f6f8n";
   };
 
+  outputs = [ "out" "dev" ];
+
   configureFlags = [ "--with-tcl=no" "--localstatedir=/var/lib"]
-    ++ optional stdenv.isFreeBSD ''WARN_CFLAGS=""'';
+    ++ optional stdenv.isFreeBSD ''WARN_CFLAGS=""''
+    ++ optionals (stdenv.buildPlatform != stdenv.hostPlatform)
+       [ "krb5_cv_attr_constructor_destructor=yes,yes"
+         "ac_cv_func_regcomp=yes"
+         "ac_cv_printf_positional=yes"
+       ];
 
-  nativeBuildInputs = [ pkgconfig perl yacc ]
+  nativeBuildInputs = [ pkgconfig perl ]
+    ++ optional (!libOnly) yacc
     # Provides the mig command used by the build scripts
     ++ optional stdenv.isDarwin bootstrap_cmds;
   buildInputs = [ openssl ]
@@ -31,20 +39,26 @@ stdenv.mkDerivation rec {
   preConfigure = "cd ./src";
 
   buildPhase = optionalString libOnly ''
-    (cd util; make -j $NIX_BUILD_CORES)
-    (cd include; make -j $NIX_BUILD_CORES)
-    (cd lib; make -j $NIX_BUILD_CORES)
-    (cd build-tools; make -j $NIX_BUILD_CORES)
+    MAKE="make -j $NIX_BUILD_CORES -l $NIX_BUILD_CORES"
+    (cd util; $MAKE)
+    (cd include; $MAKE)
+    (cd lib; $MAKE)
+    (cd build-tools; $MAKE)
   '';
 
   installPhase = optionalString libOnly ''
-    mkdir -p $out/{bin,include/{gssapi,gssrpc,kadm5,krb5},lib/pkgconfig,sbin,share/{et,man/man1}}
-    (cd util; make -j $NIX_BUILD_CORES install)
-    (cd include; make -j $NIX_BUILD_CORES install)
-    (cd lib; make -j $NIX_BUILD_CORES install)
-    (cd build-tools; make -j $NIX_BUILD_CORES install)
-    rm -rf $out/{sbin,share}
-    find $out/bin -type f | grep -v 'krb5-config' | xargs rm
+    mkdir -p "$out"/{bin,sbin,lib/pkgconfig,share/{et,man/man1}} \
+      "$dev"/include/{gssapi,gssrpc,kadm5,krb5}
+    (cd util; $MAKE install)
+    (cd include; $MAKE install)
+    (cd lib; $MAKE install)
+    (cd build-tools; $MAKE install)
+    ${postInstall}
+  '';
+
+  # not via outputBin, due to reference from libkrb5.so
+  postInstall = ''
+    moveToOutput bin "$dev"
   '';
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/keybinder/default.nix b/pkgs/development/libraries/keybinder/default.nix
index 5ce1b8ec13cc..5110908e0f27 100644
--- a/pkgs/development/libraries/keybinder/default.nix
+++ b/pkgs/development/libraries/keybinder/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, autoconf, automake, libtool, pkgconfig, gnome3
-, gtk_doc, gtk2, python2Packages, lua, libX11, libXext, libXrender, gobjectIntrospection
+, gtk-doc, gtk2, python2Packages, lua, libX11, libXext, libXrender, gobjectIntrospection
 }:
 
 let
@@ -16,7 +16,7 @@ in stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [
-    autoconf automake libtool gnome3.gnome_common gtk_doc gnome3.gtk3
+    autoconf automake libtool gnome3.gnome-common gtk-doc gnome3.gtk3
     python pygobject3 pygtk lua libX11 libXext libXrender gobjectIntrospection gtk2
   ];
 
diff --git a/pkgs/development/libraries/keybinder3/default.nix b/pkgs/development/libraries/keybinder3/default.nix
index f4158f7edbb4..cf4b85043bb2 100644
--- a/pkgs/development/libraries/keybinder3/default.nix
+++ b/pkgs/development/libraries/keybinder3/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchFromGitHub, autoconf, automake, libtool, pkgconfig, gnome3
-, gtk_doc, gtk3, python, lua, libX11, libXext, libXrender, gobjectIntrospection
+, gtk-doc, gtk3, python, lua, libX11, libXext, libXrender, gobjectIntrospection
 }:
 
 stdenv.mkDerivation rec {
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [
-    autoconf automake libtool gnome3.gnome_common gtk_doc
+    autoconf automake libtool gnome3.gnome-common gtk-doc
     libX11 libXext libXrender gobjectIntrospection gtk3
   ];
 
diff --git a/pkgs/development/libraries/kirigami/default.nix b/pkgs/development/libraries/kirigami/default.nix
deleted file mode 100644
index 1127f3e197df..000000000000
--- a/pkgs/development/libraries/kirigami/default.nix
+++ /dev/null
@@ -1,47 +0,0 @@
-{ stdenv, fetchurl, cmake, extra-cmake-modules, pkgconfig
-, plasma-framework, qtbase, qttranslations
-, qtquickcontrols ? null
-, qtquickcontrols2 ? null }:
-
-let
-  pname = "kirigami";
-
-  generic = { name, version, sha256, qtqc, broken }:
-  stdenv.mkDerivation rec {
-    inherit name version;
-
-    src = fetchurl {
-      url = "mirror://kde/stable/${pname}/${name}.tar.xz";
-      inherit sha256;
-    };
-
-    buildInputs = [ plasma-framework qtbase qtqc qttranslations ];
-
-    nativeBuildInputs = [ cmake pkgconfig extra-cmake-modules ];
-
-    meta = with stdenv.lib; {
-      license     = licenses.lgpl2;
-      homepage    = http://www.kde.org;
-      maintainers = with maintainers; [ ttuegel peterhoeg ];
-      platforms   = platforms.unix;
-      inherit broken;
-    };
-  };
-
-in {
-  kirigami_1 = generic rec {
-    name    = "${pname}-${version}";
-    version = "1.1.0";
-    sha256  = "1p9ydggwbyfdgwmvyc8004sk9mfshlg9b83lzvz9qk3a906ayxv6";
-    qtqc    = qtquickcontrols;
-    broken  = false;
-  };
-
-  kirigami_2 = generic rec {
-    name    = "${pname}2-${version}";
-    version = "2.1.0";
-    sha256  = "0d79h10jzv9z7xzap4k9vbw6p9as8vdkz3x6xlzx407i9sbzyi77";
-    qtqc    = qtquickcontrols2;
-    broken  = builtins.compareVersions qtbase.version "5.7.0" < 0;
-  };
-}
diff --git a/pkgs/development/libraries/kmsxx/default.nix b/pkgs/development/libraries/kmsxx/default.nix
index 490732c38025..8be8eb713572 100644
--- a/pkgs/development/libraries/kmsxx/default.nix
+++ b/pkgs/development/libraries/kmsxx/default.nix
@@ -1,7 +1,9 @@
 { stdenv, fetchFromGitHub, cmake, pkgconfig, libdrm, python }:
 
 stdenv.mkDerivation rec {
-  name = "kmsxx-2017-10-10";
+  pname = "kmsxx";
+  version = "2017-10-10";
+  name = pname + "-" + version;
 
   src = fetchFromGitHub {
     owner = "tomba";
diff --git a/pkgs/development/libraries/kpmcore/default.nix b/pkgs/development/libraries/kpmcore/default.nix
index 8532a8880ce8..2a2f0c79490e 100644
--- a/pkgs/development/libraries/kpmcore/default.nix
+++ b/pkgs/development/libraries/kpmcore/default.nix
@@ -7,11 +7,11 @@ let
 
 in stdenv.mkDerivation rec {
   name = "${pname}-${version}";
-  version = "3.0.3";
+  version = "3.3.0";
 
   src = fetchurl {
     url = "mirror://kde/stable/${pname}/${version}/src/${name}.tar.xz";
-    sha256 = "17lqrp39w31fm7haigwq23cp92zwk3czjzqa2fhn3wafx3vafwd2";
+    sha256 = "0s6v0jfrhjg31ri5p6h9n4w29jvasf5dj954j3vfpzl91lygmmmq";
   };
 
   buildInputs = [
diff --git a/pkgs/development/libraries/kyotocabinet/default.nix b/pkgs/development/libraries/kyotocabinet/default.nix
index 57eaf74d2908..935f52eeb71c 100644
--- a/pkgs/development/libraries/kyotocabinet/default.nix
+++ b/pkgs/development/libraries/kyotocabinet/default.nix
@@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
 
   patches = [(fetchurl {
     name = "gcc6.patch";
-    url = "http://pkgs.fedoraproject.org/rpms/kyotocabinet/raw/master/f/kyotocabinet-1.2.76-gcc6.patch";
+    url = "http://src.fedoraproject.org/rpms/kyotocabinet/raw/master/f/kyotocabinet-1.2.76-gcc6.patch";
     sha256 = "1h5k38mkiq7lz8nd2gbn7yvimcz49g3z7phn1cr560bzjih8rz23";
   })];
 
diff --git a/pkgs/development/libraries/languagemachines/frog.nix b/pkgs/development/libraries/languagemachines/frog.nix
index 725bc714db28..1a73a46d2872 100644
--- a/pkgs/development/libraries/languagemachines/frog.nix
+++ b/pkgs/development/libraries/languagemachines/frog.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl
-, automake, autoconf, libtool, pkgconfig, autoconf-archive
+, automake, autoconf, bzip2, libtar, libtool, pkgconfig, autoconf-archive
 , libxml2, icu
 , languageMachines
 }:
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
   src = fetchurl { inherit (release) url sha256;
                    name = "frog-${release.version}.tar.gz"; };
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ automake autoconf libtool autoconf-archive
+  buildInputs = [ automake autoconf bzip2 libtar libtool autoconf-archive
                   libxml2 icu
                   languageMachines.ticcutils
                   languageMachines.timbl
diff --git a/pkgs/development/libraries/languagemachines/libfolia.nix b/pkgs/development/libraries/languagemachines/libfolia.nix
index d5c232ae7767..a6f5adb95595 100644
--- a/pkgs/development/libraries/languagemachines/libfolia.nix
+++ b/pkgs/development/libraries/languagemachines/libfolia.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl
 , automake, autoconf, libtool, pkgconfig, autoconf-archive
-, libxml2, icu
+, libxml2, icu, bzip2, libtar
 , languageMachines }:
 
 let
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
   src = fetchurl { inherit (release) url sha256;
                    name = "libfolia-${release.version}.tar.gz"; };
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ automake autoconf libtool autoconf-archive libxml2 icu languageMachines.ticcutils ];
+  buildInputs = [ automake autoconf bzip2 libtool autoconf-archive libtar libxml2 icu languageMachines.ticcutils ];
   preConfigure = "sh bootstrap.sh";
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/languagemachines/mbt.nix b/pkgs/development/libraries/languagemachines/mbt.nix
index 2ffabac1ede9..3bc78a96a063 100644
--- a/pkgs/development/libraries/languagemachines/mbt.nix
+++ b/pkgs/development/libraries/languagemachines/mbt.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl
-, automake, autoconf, libtool, pkgconfig, autoconf-archive
+, automake, autoconf, bzip2, libtar, libtool, pkgconfig, autoconf-archive
 , libxml2
 , languageMachines
 }:
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
   src = fetchurl { inherit (release) url sha256;
                    name = "mbt-${release.version}.tar.gz"; };
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ automake autoconf libtool autoconf-archive
+  buildInputs = [ automake autoconf bzip2 libtar libtool autoconf-archive
                   libxml2
                   languageMachines.ticcutils
                   languageMachines.timbl
diff --git a/pkgs/development/libraries/languagemachines/timbl.nix b/pkgs/development/libraries/languagemachines/timbl.nix
index d12c970d4dc4..3ab38a9e84ac 100644
--- a/pkgs/development/libraries/languagemachines/timbl.nix
+++ b/pkgs/development/libraries/languagemachines/timbl.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl
 , automake, autoconf, libtool, pkgconfig, autoconf-archive
-, libxml2
+, libxml2, bzip2, libtar
 , languageMachines
 }:
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
   src = fetchurl { inherit (release) url sha256;
                    name = "timbl-${release.version}.tar.gz"; };
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ automake autoconf libtool autoconf-archive
+  buildInputs = [ automake autoconf bzip2 libtar libtool autoconf-archive
                   libxml2
                   languageMachines.ticcutils
                 ];
diff --git a/pkgs/development/libraries/languagemachines/timblserver.nix b/pkgs/development/libraries/languagemachines/timblserver.nix
index 7a07e9f33a8a..ee1579540c33 100644
--- a/pkgs/development/libraries/languagemachines/timblserver.nix
+++ b/pkgs/development/libraries/languagemachines/timblserver.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl
-, automake, autoconf, libtool, pkgconfig, autoconf-archive
+, automake, autoconf, bzip2, libtar, libtool, pkgconfig, autoconf-archive
 , libxml2
 , languageMachines
 }:
@@ -14,7 +14,7 @@ stdenv.mkDerivation {
   src = fetchurl { inherit (release) url sha256;
                    name = "timblserver-${release.version}.tar.gz"; };
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ automake autoconf libtool autoconf-archive
+  buildInputs = [ automake autoconf bzip2 libtar libtool autoconf-archive
                   libxml2
                   languageMachines.ticcutils
                   languageMachines.timbl
diff --git a/pkgs/development/libraries/languagemachines/ucto.nix b/pkgs/development/libraries/languagemachines/ucto.nix
index 5c12a2142cc1..8f917c2265d2 100644
--- a/pkgs/development/libraries/languagemachines/ucto.nix
+++ b/pkgs/development/libraries/languagemachines/ucto.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl
 , automake, autoconf, libtool, pkgconfig, autoconf-archive
-, libxml2, icu
+, libxml2, icu, bzip2, libtar
 , languageMachines
 }:
 
@@ -14,8 +14,8 @@ stdenv.mkDerivation {
   src = fetchurl { inherit (release) url sha256;
                    name = "ucto-${release.version}.tar.gz"; };
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ automake autoconf libtool autoconf-archive
-                  icu libxml2
+  buildInputs = [ automake autoconf bzip2 libtool autoconf-archive
+                  icu libtar libxml2
                   languageMachines.ticcutils
                   languageMachines.libfolia
                   languageMachines.uctodata
diff --git a/pkgs/development/libraries/lasso/default.nix b/pkgs/development/libraries/lasso/default.nix
index 09001b6a6f08..acd0d35a5f08 100644
--- a/pkgs/development/libraries/lasso/default.nix
+++ b/pkgs/development/libraries/lasso/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, autoconf, automake, autoreconfHook, fetchurl, glib, gobjectIntrospection, gtk_doc, libtool, libxml2, libxslt, openssl, pkgconfig, python27Packages, xmlsec, zlib }:
+{ stdenv, autoconf, automake, autoreconfHook, fetchurl, glib, gobjectIntrospection, gtk-doc, libtool, libxml2, libxslt, openssl, pkgconfig, python27Packages, xmlsec, zlib }:
 
 stdenv.mkDerivation rec {
 
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ autoreconfHook pkgconfig ];
-  buildInputs = [ autoconf automake glib gobjectIntrospection gtk_doc libtool libxml2 libxslt openssl python27Packages.six xmlsec zlib ];
+  buildInputs = [ autoconf automake glib gobjectIntrospection gtk-doc libtool libxml2 libxslt openssl python27Packages.six xmlsec zlib ];
 
   configurePhase = ''
     ./configure --with-pkg-config=$PKG_CONFIG_PATH \
diff --git a/pkgs/development/libraries/lcms2/default.nix b/pkgs/development/libraries/lcms2/default.nix
index 6fde8305da50..5d307dcfa7ad 100644
--- a/pkgs/development/libraries/lcms2/default.nix
+++ b/pkgs/development/libraries/lcms2/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, libtiff, libjpeg, zlib }:
 
 stdenv.mkDerivation rec {
-  name = "lcms2-2.8";
+  name = "lcms2-2.9";
 
   src = fetchurl {
     url = "mirror://sourceforge/lcms/${name}.tar.gz";
-    sha256 = "08pvl289g0mbznzx5l6ibhaldsgx41kwvdn2c974ga9fkli2pl36";
+    sha256 = "083xisy6z01zhm7p7rgk4bx9d6zlr8l20qkfv1g29ylnhgwzvij8";
   };
 
   outputs = [ "bin" "dev" "out" ];
diff --git a/pkgs/development/libraries/ldns/default.nix b/pkgs/development/libraries/ldns/default.nix
index f465cf1cc441..6c2a8f84d232 100644
--- a/pkgs/development/libraries/ldns/default.nix
+++ b/pkgs/development/libraries/ldns/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, openssl, perl, dns-root-data}:
+{ stdenv, fetchurl, fetchpatch, openssl, perl, dns-root-data }:
 
 stdenv.mkDerivation rec {
   pname = "ldns";
@@ -8,10 +8,25 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "https://www.nlnetlabs.nl/downloads/ldns/${name}.tar.gz";
-    sha1 = "ceeeccf8a27e61a854762737f6ee02f44662c1b8";
+    sha256 = "1k56jw4hz8njspfxcfw0czf1smg0n48ylia89ziwyx5k9wdmp7y1";
   };
 
-  patchPhase = ''
+  patches = [
+    (fetchpatch {
+      name = "CVE-2017-1000231.patch";
+      url = "https://git.nlnetlabs.nl/ldns/patch/?id=c8391790";
+      sha256 = "1rprfh0y1c28dqiy3vgwvwdhn7b5rsylfzzblx5xdhwfqgdw8vn0";
+      excludes = [ "Changelog" ];
+    })
+    (fetchpatch {
+      name = "CVE-2017-1000232.patch";
+      url = "https://git.nlnetlabs.nl/ldns/patch/?id=3bdeed02";
+      sha256 = "0bv0s5jjp0sswfg8da47d346iwp9yjhj9w7fa3bxh174br0zj07r";
+      excludes = [ "Changelog" ];
+    })
+  ];
+
+  postPatch = ''
     patchShebangs doc/doxyparse.pl
   '';
 
diff --git a/pkgs/development/libraries/leatherman/default.nix b/pkgs/development/libraries/leatherman/default.nix
index be033c3860cf..44d527e1304b 100644
--- a/pkgs/development/libraries/leatherman/default.nix
+++ b/pkgs/development/libraries/leatherman/default.nix
@@ -2,10 +2,10 @@
 
 stdenv.mkDerivation rec {
   name = "leatherman-${version}";
-  version = "1.3.0";
+  version = "1.4.0";
 
   src = fetchFromGitHub {
-    sha256 = "1pcbfgq9khlcvxjsqpdshjskwljzawryzps0ickazwm7l3m7hrln";
+    sha256 = "0whlyzz0imv4lm69xkwhcd6jzh3s0rzlqjmwimbqz96p4771ivpd";
     rev = version;
     repo = "leatherman";
     owner = "puppetlabs";
diff --git a/pkgs/development/libraries/leveldb/default.nix b/pkgs/development/libraries/leveldb/default.nix
index 2a109e0366fd..2b50c09af5cc 100644
--- a/pkgs/development/libraries/leveldb/default.nix
+++ b/pkgs/development/libraries/leveldb/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, sqlite, kyotocabinet }:
+{ stdenv, fetchFromGitHub }:
 
 stdenv.mkDerivation rec {
   name = "leveldb-${version}";
@@ -11,19 +11,25 @@ stdenv.mkDerivation rec {
     sha256 = "1bnsii47vbyqnbah42qgq6pbmmcg4k3fynjnw7whqfv6lpdgmb8d";
   };
 
-  buildInputs = [ sqlite kyotocabinet ];
-
   buildPhase = ''
-    make all db_bench{,_sqlite3,_tree_db} leveldbutil libmemenv.a
+    make all leveldbutil libmemenv.a
   '';
 
-  installPhase = "
+  installPhase = (stdenv.lib.optionalString stdenv.isDarwin ''
+    for file in *.dylib*; do
+      install_name_tool -id $out/lib/$file $file
+    done
+  '') + # XXX consider removing above after transition to cmake in the next release
+  "
     mkdir -p $out/{bin,lib,include}
+
     cp -r include $out
-    cp lib* $out/lib
-    cp db_bench{,_sqlite3,_tree_db} leveldbutil $out/bin
     mkdir -p $out/include/leveldb/helpers
     cp helpers/memenv/memenv.h $out/include/leveldb/helpers
+
+    cp lib* $out/lib
+
+    cp leveldbutil $out/bin
   ";
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libHX/default.nix b/pkgs/development/libraries/libHX/default.nix
index 31dfe6085ee1..7de72ed73a65 100644
--- a/pkgs/development/libraries/libHX/default.nix
+++ b/pkgs/development/libraries/libHX/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, autoconf, automake, libtool }:
 
 stdenv.mkDerivation rec {
-  name = "libHX-3.21";
+  name = "libHX-3.22";
 
   src = fetchurl {
-    url = "mirror://sourceforge/libhx/libHX/3.21/${name}.tar.xz";
-    sha256 = "0wcr6kbhsw6v4js7q4p7fhli37c39dv1rryjf768rkwshl2z8f6v";
+    url = "mirror://sourceforge/libhx/libHX/3.22/${name}.tar.xz";
+    sha256 = "18w39j528lyg2026dr11f2xxxphy91cg870nx182wbd8cjlqf86c";
   };
 
   patches = [];
diff --git a/pkgs/development/libraries/libLAS/default.nix b/pkgs/development/libraries/libLAS/default.nix
index 20531adcd1c7..272a9774a7f4 100644
--- a/pkgs/development/libraries/libLAS/default.nix
+++ b/pkgs/development/libraries/libLAS/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, boost, cmake, gdal, libgeotiff, libtiff, LASzip }:
+{ stdenv, fetchurl, boost, cmake, gdal, libgeotiff, libtiff, LASzip, fixDarwinDylibNames }:
 
 stdenv.mkDerivation rec {
   name = "libLAS-1.8.1";
@@ -9,14 +9,24 @@ stdenv.mkDerivation rec {
     sha256 = "0xjfxb3ydvr2258ji3spzyf81g9caap19ql2pk91wiivqsc4mnws";
   };
 
-  buildInputs = [ boost cmake gdal libgeotiff libtiff LASzip ];
+  buildInputs = [ boost cmake gdal libgeotiff libtiff LASzip ]
+                ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
+  cmakeFlags = [
+    "-DGDAL_CONFIG=${gdal}/bin/gdal-config"
+    "-DWITH_LASZIP=ON"
+    "-DLASZIP_INCLUDE_DIR=${LASzip}/include"
+  ];
+
+  postFixup = stdenv.lib.optionalString stdenv.isDarwin ''
+    install_name_tool -change "@rpath/liblas.3.dylib" "$out/lib/liblas.3.dylib" $out/lib/liblas_c.dylib
+  '';
 
   meta = {
     description = "LAS 1.0/1.1/1.2 ASPRS LiDAR data translation toolset";
     homepage = http://www.liblas.org;
     license = stdenv.lib.licenses.bsd3;
-    platforms = stdenv.lib.platforms.linux;
+    platforms = stdenv.lib.platforms.unix;
     maintainers = [ stdenv.lib.maintainers.michelk ];
   };
 }
diff --git a/pkgs/development/libraries/libaal/default.nix b/pkgs/development/libraries/libaal/default.nix
index 88396786ed78..6df7bc22772f 100644
--- a/pkgs/development/libraries/libaal/default.nix
+++ b/pkgs/development/libraries/libaal/default.nix
@@ -9,10 +9,14 @@ stdenv.mkDerivation rec {
     sha256 = "176f2sns6iyxv3h9zyirdinjwi05gdak48zqarhib2s38rvm98di";
   };
 
+  patches = [ ./libaal-1.0.6-glibc-2.26.patch ];
+
   preInstall = ''
     substituteInPlace Makefile --replace ./run-ldconfig true
   '';
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = http://www.namesys.com/;
     description = "Support library for Reiser4";
diff --git a/pkgs/development/libraries/libaal/libaal-1.0.6-glibc-2.26.patch b/pkgs/development/libraries/libaal/libaal-1.0.6-glibc-2.26.patch
new file mode 100644
index 000000000000..6d49682f03ae
--- /dev/null
+++ b/pkgs/development/libraries/libaal/libaal-1.0.6-glibc-2.26.patch
@@ -0,0 +1,89 @@
+Date: 2017-09-02 13:03:15.353403096 +0200
+From: Jan Engelhardt <jengelh@inai.de>
+
+Stop redefining libc definitions that cause build failures under glibc-2.26.
+
+[   46s] In file included from /usr/include/sys/types.h:156:0,
+[   46s]                  from /usr/include/stdlib.h:279,
+[   46s]                  from malloc.c:15:
+[   46s] /usr/include/bits/stdint-intn.h:27:19: error: conflicting types for 'int64_t'
+[   46s]  typedef __int64_t int64_t;
+[   46s]                    ^~~~~~~
+[   46s] In file included from ../include/aal/libaal.h:17:0,
+[   46s]                  from malloc.c:6:
+[   46s] ../include/aal/types.h:35:33: note: previous declaration of 'int64_t' was here
+[   46s]  typedef long long int           int64_t;
+
+
+---
+ include/aal/types.h |   48 ++----------------------------------------------
+ 1 file changed, 2 insertions(+), 46 deletions(-)
+
+Index: libaal-1.0.6/include/aal/types.h
+===================================================================
+--- libaal-1.0.6.orig/include/aal/types.h
++++ libaal-1.0.6/include/aal/types.h
+@@ -26,24 +26,7 @@
+ #undef ESTRUCT
+ #define ESTRUCT                 50
+ 
+-#ifndef __int8_t_defined
+-#define __int8_t_defined
+-typedef signed char             int8_t;
+-typedef short int               int16_t;
+-typedef int                     int32_t;
+-__extension__
+-typedef long long int           int64_t;
+-#endif
+- 
+-typedef unsigned char           uint8_t;
+-typedef unsigned short int      uint16_t;
+-#ifndef __uint32_t_defined
+-#define __uint32_t_defined
+-typedef unsigned int            uint32_t;
+-__extension__
+-typedef unsigned long long int  uint64_t;
+-#endif
+-
++#include <stdint.h>
+ #define MAX_UINT8  ((uint8_t)~0)
+ #define MAX_UINT16 ((uint16_t)~0)
+ #define MAX_UINT32 ((uint32_t)~0)
+@@ -53,36 +36,9 @@ typedef unsigned long long int  uint64_t
+    because we don't want use gcc builtins in minimal mode for achive as small
+    binary size as possible. */
+ 
+-#ifndef ENABLE_MINIMAL
+ #  include <stdarg.h>
+-#else
+-#ifndef _VA_LIST_
+-#define _VA_LIST_
+-typedef char *va_list;
+-#endif
+-#undef va_arg
+-#undef va_end
+-#undef va_start
+-
+-#define va_end(ap)       \
+-        do {} while(0);
+-
+-#define va_start(ap, p)  \
+-        (ap = (char *)(&(p)+1))
+-
+-#define va_arg(ap, type) \
+-        ((type *)(ap += sizeof(type)))[-1]
+-#endif
+-
+-/* As libaal may be used without any standard headers, we need to declare NULL
+-   macro here in order to avoid compilation errors. */
+-#undef NULL
+ 
+-#if defined(__cplusplus)
+-#  define NULL 0
+-#else
+-#  define NULL ((void *)0)
+-#endif
++#include <stdio.h>
+ 
+ /* Simple type for direction denoting */
+ enum aal_dir {
diff --git a/pkgs/development/libraries/libabw/default.nix b/pkgs/development/libraries/libabw/default.nix
index 71a28085541d..187e06239c10 100644
--- a/pkgs/development/libraries/libabw/default.nix
+++ b/pkgs/development/libraries/libabw/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libabw-${version}";
-  version = "0.1.1";
+  version = "0.1.2";
 
   src = fetchurl {
     url = "http://dev-www.libreoffice.org/src/libabw/${name}.tar.xz";
-    sha256 = "0zi1zj4fpxgpglbbb5n1kg3dmhqq5rpf46lli89r5daavp19iing";
+    sha256 = "11949iscdb99f2jplxjd39282jxcrf2fw0sqbh5dl7gqb96r8whb";
   };
 
   # Boost 1.59 compatability fix
diff --git a/pkgs/development/libraries/libaccounts-glib/default.nix b/pkgs/development/libraries/libaccounts-glib/default.nix
index e410b6d4aa52..4bb806b91d8a 100644
--- a/pkgs/development/libraries/libaccounts-glib/default.nix
+++ b/pkgs/development/libraries/libaccounts-glib/default.nix
@@ -1,19 +1,19 @@
 { stdenv, fetchFromGitLab, autoconf, automake, glib
-, gtk_doc, libtool, libxml2, libxslt, pkgconfig, sqlite }:
+, gtk-doc, libtool, libxml2, libxslt, pkgconfig, sqlite }:
 
-let version = "1.18"; in
+let version = "1.23"; in
 stdenv.mkDerivation rec {
   name = "libaccounts-glib-${version}";
 
   src = fetchFromGitLab {
-    sha256 = "02p23vrqhw2l2w6nrwlk4bqxf7z9kplkc2d43716x9xakxr291km";
-    rev = version;
+    sha256 = "11cvl3ch0y93756k90mw1swqv0ylr8qgalmvcn5yari8z4sg6cgg";
+    rev = "VERSION_${version}";
     repo = "libaccounts-glib";
     owner = "accounts-sso";
   };
 
   buildInputs = [ glib libxml2 libxslt sqlite ];
-  nativeBuildInputs = [ autoconf automake gtk_doc libtool pkgconfig ];
+  nativeBuildInputs = [ autoconf automake gtk-doc libtool pkgconfig ];
 
   postPatch = ''
     NOCONFIGURE=1 ./autogen.sh
diff --git a/pkgs/development/libraries/libagar/default.nix b/pkgs/development/libraries/libagar/default.nix
index 1c9e8eca0d57..49e5bcdd9058 100644
--- a/pkgs/development/libraries/libagar/default.nix
+++ b/pkgs/development/libraries/libagar/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, pkgconfig, libtool, perl, bsdbuild, gettext, mandoc
-, libpng, libjpeg, xlibsWrapper, libXinerama, freetype, SDL, mesa
+, libpng, libjpeg, xlibsWrapper, libXinerama, freetype, SDL, libGLU_combined
 , libsndfile, portaudio, mysql, fontconfig
 }:
 
@@ -19,16 +19,17 @@ stdenv.mkDerivation rec {
     "--enable-nls=yes"
     "--with-gettext=${gettext}"
     "--with-jpeg=${libjpeg.dev}"
-    "--with-gl=${mesa}"
-    "--with-mysql=yes"
+    "--with-gl=${libGLU_combined}"
+    "--with-mysql=${mysql.connector-c}"
     "--with-manpages=yes"
   ];
 
   outputs = [ "out" "devdoc" ];
 
   nativeBuildInputs = [ pkgconfig libtool gettext ];
+
   buildInputs = [
-    bsdbuild perl xlibsWrapper libXinerama SDL mesa  mysql.client mandoc
+    bsdbuild perl xlibsWrapper libXinerama SDL libGLU_combined mysql.connector-c mandoc
     freetype.dev libpng libjpeg.dev fontconfig portaudio libsndfile
   ];
 
diff --git a/pkgs/development/libraries/libamqpcpp/default.nix b/pkgs/development/libraries/libamqpcpp/default.nix
new file mode 100644
index 000000000000..85972e67e103
--- /dev/null
+++ b/pkgs/development/libraries/libamqpcpp/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchFromGitHub, openssl }:
+
+stdenv.mkDerivation rec {
+  name = "libamqpcpp-${version}";
+  version = "3.0.0";
+
+  src = fetchFromGitHub {
+    owner = "CopernicaMarketingSoftware";
+    repo = "AMQP-CPP";
+    rev = "v${version}";
+    sha256 = "0n93wy2v2hx9zalpyn8zxsxihh0xpgcd472qwvwsc253y97v8ngv";
+  };
+
+  buildInputs = [ openssl ];
+
+  patches = [ ./libamqpcpp-darwin.patch ];
+
+  makeFlags = [ "PREFIX=$(out)" ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "Library for communicating with a RabbitMQ server";
+    homepage = https://github.com/CopernicaMarketingSoftware/AMQP-CPP;
+    license = licenses.asl20;
+    maintainers = [ maintainers.mjp ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/libamqpcpp/libamqpcpp-darwin.patch b/pkgs/development/libraries/libamqpcpp/libamqpcpp-darwin.patch
new file mode 100644
index 000000000000..9f8d700929b4
--- /dev/null
+++ b/pkgs/development/libraries/libamqpcpp/libamqpcpp-darwin.patch
@@ -0,0 +1,13 @@
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -0,0 +1 @@
++CXX ?= g++
+@@ -43 +44 @@ ${SHARED_LIB}: ${SHARED_OBJECTS}
+-	${LD} ${LD_FLAGS} -Wl,${SONAMEPARAMETER},lib$(LIBRARY_NAME).so.$(SONAME) -o $@ ${SHARED_OBJECTS}
++	${CXX} ${LD_FLAGS} -Wl,${SONAMEPARAMETER},lib$(LIBRARY_NAME).so.$(SONAME) -o $@ ${SHARED_OBJECTS}
+@@ -52 +53 @@ ${SHARED_OBJECTS}:
+-	${CPP} ${CPPFLAGS} -fpic -o $@ ${@:%.o=%.cpp}
++	${CXX} ${CPPFLAGS} -fpic -o $@ ${@:%.o=%.cpp}
+@@ -55 +56 @@ ${STATIC_OBJECTS}:
+-	${CPP} ${CPPFLAGS} -o $@ ${@:%.s.o=%.cpp}
++	${CXX} ${CPPFLAGS} -o $@ ${@:%.s.o=%.cpp}
diff --git a/pkgs/development/libraries/libao/default.nix b/pkgs/development/libraries/libao/default.nix
index 3a1c89384050..826f72b1f5fb 100644
--- a/pkgs/development/libraries/libao/default.nix
+++ b/pkgs/development/libraries/libao/default.nix
@@ -1,33 +1,42 @@
-{ lib, stdenv, fetchurl, pkgconfig, libpulseaudio, alsaLib, libcap
+{ stdenv, lib, fetchFromGitHub, autoreconfHook, pkgconfig, libpulseaudio, alsaLib, libcap
 , CoreAudio, CoreServices, AudioUnit
 , usePulseAudio }:
 
 stdenv.mkDerivation rec {
-  version = "1.2.0";
+  version = "1.2.2";
   name = "libao-${version}";
-  src = fetchurl {
-    url = "http://downloads.xiph.org/releases/ao/${name}.tar.gz";
-    sha256 = "1bwwv1g9lchaq6qmhvj1pp3hnyqr64ydd4j38x94pmprs4d27b83";
+
+  # the github mirror is more up to date than downloads.xiph.org
+  src = fetchFromGitHub {
+    owner  = "xiph";
+    repo   = "libao";
+    rev    = "${version}";
+    sha256 = "0svgk4sc9kdhcsfyvbvgm5vpbg3sfr6z5rliflrw49v3x2i4vxq5";
   };
 
+  configureFlags = [
+    "--disable-broken-oss"
+    "--enable-alsa-mmap"
+  ];
+
   outputs = [ "out" "dev" "man" "doc" ];
 
-  buildInputs =
-    [ pkgconfig ] ++
-    lib.optional usePulseAudio libpulseaudio ++
-    lib.optional stdenv.isLinux alsaLib ++
-    lib.optional stdenv.isLinux libcap ++
+  buildInputs = [ ] ++
+    lib.optional  usePulseAudio   libpulseaudio ++
+    lib.optionals stdenv.isLinux  [ alsaLib libcap ] ++
     lib.optionals stdenv.isDarwin [ CoreAudio CoreServices AudioUnit ];
 
-  meta = {
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+
+  meta = with stdenv.lib; {
     longDescription = ''
       Libao is Xiph.org's cross-platform audio library that allows
       programs to output audio using a simple API on a wide variety of
       platforms.
     '';
     homepage = https://xiph.org/ao/;
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = with stdenv.lib.maintainers; [ fuuzetsu ];
-    platforms = with stdenv.lib.platforms; unix;
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ fuuzetsu ];
+    platforms = with platforms; unix;
   };
 }
diff --git a/pkgs/development/libraries/libaom/default.nix b/pkgs/development/libraries/libaom/default.nix
new file mode 100644
index 000000000000..d11bec2cb4ff
--- /dev/null
+++ b/pkgs/development/libraries/libaom/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchgit, yasm, perl, cmake,  pkgconfig }:
+
+stdenv.mkDerivation rec {
+  name = "libaom-0.1.0";
+
+  src = fetchgit {
+    url = "https://aomedia.googlesource.com/aom";
+    rev	= "105e9b195bb90c9b06edcbcb13b6232dab6db0b7";
+    sha256 = "1fl2sca4df01gyn00s0xcwwirxccfnjppvjdrxdnb8f2naj721by";
+  };
+
+  buildInputs = [ perl yasm  ];
+  nativeBuildInputs = [ cmake pkgconfig ];
+
+  cmakeFlags = [
+    "-DCONFIG_UNIT_TESTS=0"
+  ];
+
+  meta = with stdenv.lib; {
+    description = "AV1 Bitstream and Decoding Library";
+    homepage    = https://aomedia.org/av1-features/get-started/;
+    maintainers = with maintainers; [ kiloreux ];
+    platforms   = platforms.all;
+  };
+}
\ No newline at end of file
diff --git a/pkgs/development/libraries/libappindicator/default.nix b/pkgs/development/libraries/libappindicator/default.nix
index 3a26dd407e4e..6c87588fd3d7 100644
--- a/pkgs/development/libraries/libappindicator/default.nix
+++ b/pkgs/development/libraries/libappindicator/default.nix
@@ -2,10 +2,10 @@
 
 { stdenv, fetchurl, lib, file
 , pkgconfig, autoconf
-, glib, dbus_glib, gtkVersion
+, glib, dbus-glib, gtkVersion
 , gtk2 ? null, libindicator-gtk2 ? null, libdbusmenu-gtk2 ? null
 , gtk3 ? null, libindicator-gtk3 ? null, libdbusmenu-gtk3 ? null
-, python2Packages, gobjectIntrospection, vala_0_23
+, python2Packages, gobjectIntrospection, vala
 , monoSupport ? false, mono ? null, gtk-sharp-2_0 ? null
  }:
 
@@ -33,8 +33,8 @@ in stdenv.mkDerivation rec {
     else [ gtk3 libdbusmenu-gtk3 ];
 
   buildInputs = [
-    glib dbus_glib
-    python pygobject2 pygtk gobjectIntrospection vala_0_23
+    glib dbus-glib
+    python pygobject2 pygtk gobjectIntrospection vala
   ] ++ (if gtkVersion == "2"
     then [ libindicator-gtk2 ] ++ optionals monoSupport [ mono gtk-sharp-2_0 ]
     else [ libindicator-gtk3 ]);
diff --git a/pkgs/development/libraries/libargon2/default.nix b/pkgs/development/libraries/libargon2/default.nix
index 79cbf09317cf..a1a04a1dd7b2 100644
--- a/pkgs/development/libraries/libargon2/default.nix
+++ b/pkgs/development/libraries/libargon2/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "libargon2-${version}";
-  version = "20161029";
+  version = "20171227";
 
   src = fetchFromGitHub {
     owner = "P-H-C";
     repo = "phc-winner-argon2";
     rev = "${version}";
-    sha256 = "021g8wi4g67ywm8zf3yncqwrmfz7ypgm1ih9wcmnxip5n75rymh5";
+    sha256 = "0sc9zca1anqk41017vjpas4kxi4cbn0zvicv8vj8p2sb2gy94bh8";
   };
 
   installPhase = ''
@@ -36,6 +36,6 @@ stdenv.mkDerivation rec {
     homepage = https://www.argon2.com/;
     license = with licenses; [ asl20 cc0 ];
     maintainers = with maintainers; [ taeer olynch ];
-    platforms = platforms.linux;
+    platforms = platforms.linux ++ platforms.darwin;
   };
 }
diff --git a/pkgs/development/libraries/libass/default.nix b/pkgs/development/libraries/libass/default.nix
index 058839f70f8a..d7ebf781a049 100644
--- a/pkgs/development/libraries/libass/default.nix
+++ b/pkgs/development/libraries/libass/default.nix
@@ -19,11 +19,11 @@ in
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "libass-${version}";
-  version = "0.13.7";
+  version = "0.14.0";
 
   src = fetchurl {
     url = "https://github.com/libass/libass/releases/download/${version}/${name}.tar.xz";
-    sha256 = "17byv926w1mxn56n896sxvdq4m0yv1l7qbm688h6zr3nzgsyarbh";
+    sha256 = "18iqznl4mabhj9ywfsz4kwvbsplcv1jjxq50nxssvbj8my1267w8";
   };
 
   configureFlags = [
diff --git a/pkgs/development/libraries/libassuan/default.nix b/pkgs/development/libraries/libassuan/default.nix
index bad2a060cdca..91ceb959779e 100644
--- a/pkgs/development/libraries/libassuan/default.nix
+++ b/pkgs/development/libraries/libassuan/default.nix
@@ -1,17 +1,17 @@
-{ fetchurl, stdenv, pth, libgpgerror }:
+{ fetchurl, stdenv, gettext, pth, libgpgerror }:
 
 stdenv.mkDerivation rec {
-  name = "libassuan-2.4.3";
+  name = "libassuan-2.5.1";
 
   src = fetchurl {
     url = "mirror://gnupg/libassuan/${name}.tar.bz2";
-    sha256 = "0w9bmasln4z8mn16s1is55a06w3nv8jbyal496z5jvr5vcxkm112";
+    sha256 = "0jb4nb4nrjr949gd3lw8lh4v5d6qigxaq6xwy24w5apjnhvnrya7";
   };
 
   outputs = [ "out" "dev" "info" ];
   outputBin = "dev"; # libassuan-config
 
-  buildInputs = [ libgpgerror pth ];
+  buildInputs = [ libgpgerror pth gettext];
 
   doCheck = true;
 
@@ -20,18 +20,16 @@ stdenv.mkDerivation rec {
     sed -i 's,#include <gpg-error.h>,#include "${libgpgerror.dev}/include/gpg-error.h",g' $dev/include/assuan.h
   '';
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "IPC library used by GnuPG and related software";
-
     longDescription = ''
       Libassuan is a small library implementing the so-called Assuan
       protocol.  This protocol is used for IPC between most newer
       GnuPG components.  Both, server and client side functions are
       provided.
     '';
-
     homepage = http://gnupg.org;
-    license = stdenv.lib.licenses.lgpl2Plus;
-    platforms = stdenv.lib.platforms.all;
+    license = licenses.lgpl2Plus;
+    platforms = platforms.all;
   };
 }
diff --git a/pkgs/development/libraries/libast/default.nix b/pkgs/development/libraries/libast/default.nix
index 900bcac41569..bcfee0444756 100644
--- a/pkgs/development/libraries/libast/default.nix
+++ b/pkgs/development/libraries/libast/default.nix
@@ -3,8 +3,8 @@
 
 stdenv.mkDerivation rec {
   name = "libast-${version}";
-  version = "0.7";
-  
+  version = "0.7.1";
+
   src = fetchurl {
     url = "http://www.eterm.org/download/${name}.tar.gz";
     sha256 = "1w7bs46r4lykfd83kc3bg9i1rxzzlb4ydk23ikf8mx8avz05q1aj";
diff --git a/pkgs/development/libraries/libatomic_ops/default.nix b/pkgs/development/libraries/libatomic_ops/default.nix
index eedc0993d736..fde8a06eb416 100644
--- a/pkgs/development/libraries/libatomic_ops/default.nix
+++ b/pkgs/development/libraries/libatomic_ops/default.nix
@@ -1,17 +1,19 @@
-{ stdenv, fetchurl, autoconf, automake, libtool }:
+{ stdenv, fetchurl, autoconf, automake, libtool, hostPlatform }:
 
 stdenv.mkDerivation rec {
   name = "libatomic_ops-${version}";
-  version = "7.6.0";
+  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 ="03ylfr29g9zc0r6b6axz3i68alj5qmxgzknxwam3jlx0sz8hcb4f";
+    sha256 = "0knxncsjhbknlyy6lx7ycxhpzfk3sykhvicgxyp0rmsxd1d3v0jv";
   };
 
+  outputs = [ "out" "dev" "doc" ];
+
   nativeBuildInputs = stdenv.lib.optionals stdenv.isCygwin [ autoconf automake libtool ];
 
   preConfigure = stdenv.lib.optionalString stdenv.isCygwin ''
@@ -23,6 +25,6 @@ stdenv.mkDerivation rec {
     description = ''A library for semi-portable access to hardware-provided atomic memory update operations'';
     license = stdenv.lib.licenses.gpl2Plus ;
     maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.unix;
+    platforms = with stdenv.lib.platforms; unix ++ windows;
   };
 }
diff --git a/pkgs/development/libraries/libatomic_ops/default.upstream b/pkgs/development/libraries/libatomic_ops/default.upstream
deleted file mode 100644
index c9fd4554e4a1..000000000000
--- a/pkgs/development/libraries/libatomic_ops/default.upstream
+++ /dev/null
@@ -1 +0,0 @@
-url https://github.com/ivmai/libatomic_ops/wiki/Download
diff --git a/pkgs/development/libraries/libaudclient/default.nix b/pkgs/development/libraries/libaudclient/default.nix
index 81e32ab2c931..aab8fcd4beb8 100644
--- a/pkgs/development/libraries/libaudclient/default.nix
+++ b/pkgs/development/libraries/libaudclient/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, glib, dbus_glib }:
+{ stdenv, fetchurl, pkgconfig, glib, dbus-glib }:
 
 stdenv.mkDerivation rec {
   name = "libaudclient-3.5-rc2";
@@ -10,11 +10,11 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ glib dbus_glib ];
+  buildInputs = [ glib dbus-glib ];
 
   meta = with stdenv.lib; {
     description = "Legacy D-Bus client library for Audacious";
-    homepage = http://audacious-media-player.org/;
+    homepage = https://audacious-media-player.org/;
     license = licenses.bsd2;
     maintainers = with maintainers; [ pSub ];
     platforms = with platforms; unix;
diff --git a/pkgs/development/libraries/libav/default.nix b/pkgs/development/libraries/libav/default.nix
index e348fe0fae28..317768518c39 100644
--- a/pkgs/development/libraries/libav/default.nix
+++ b/pkgs/development/libraries/libav/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, yasm, bzip2, zlib, perl
+{ stdenv, fetchurl, pkgconfig, yasm, bzip2, zlib, perl, bash
 , mp3Support    ? true,   lame      ? null
 , speexSupport  ? true,   speex     ? null
 , theoraSupport ? true,   libtheora ? null
@@ -28,9 +28,9 @@ let inherit (stdenv.lib) optional optionals hasPrefix; in
 let
   result = {
     # e.g. https://libav.org/releases/libav-11.11.tar.xz.sha1
-    libav_0_8 = libavFun "0.8.20" "0c7a2417c3a01eb74072691bb93ce802ae1be08f";
-    libav_11  = libavFun "11.11"  "d7444fa4f135bdd7347cc962ab4b5228796b0f23";
-    libav_12  = libavFun "12.2"   "3784b15f88076ca0ab8fb6b0377e975b83a5c9f5";
+    libav_0_8 = libavFun "0.8.21" "d858f65128dad0bac1a8c3a51e5cbb27a7c79b3f";
+    libav_11  = libavFun "11.12"  "61d5dcab5fde349834af193a572b12a5fd6a4d42";
+    libav_12  = libavFun "12.3"   "386c18c8b857f23dfcf456ce40370716130211d9";
   };
 
   libavFun = version : sha1 : stdenv.mkDerivation rec {
@@ -45,7 +45,11 @@ let
       ++ optional (vpxSupport && hasPrefix "0.8." version) ./vpxenc-0.8.17-libvpx-1.5.patch
       ;
 
-    preConfigure = "patchShebangs doc/texi2pod.pl";
+    postPatch = ''
+      patchShebangs .
+      # another shebang was hidden in a here document text
+      substituteInPlace ./configure --replace "#! /bin/sh" "#!${bash}/bin/sh"
+    '';
 
     configureFlags =
       assert stdenv.lib.all (x: x!=null) buildInputs;
@@ -71,8 +75,8 @@ let
       ++ optional freetypeSupport "--enable-libfreetype"
       ;
 
-  nativeBuildInputs = [ pkgconfig ];
-    buildInputs = [ lame yasm zlib bzip2 SDL ]
+  nativeBuildInputs = [ pkgconfig perl ];
+    buildInputs = [ lame yasm zlib bzip2 SDL bash ]
       ++ [ perl ] # for install-man target
       ++ optional mp3Support lame
       ++ optional speexSupport speex
@@ -95,6 +99,7 @@ let
     # alltools to build smaller tools, incl. aviocat, ismindex, qt-faststart, etc.
     buildFlags = "all alltools install-man";
 
+
     postInstall = ''
       moveToOutput bin "$bin"
       # alltools target compiles an executable in tools/ for every C
@@ -110,7 +115,7 @@ let
     crossAttrs = {
       configurePlatforms = [];
       configureFlags = configureFlags ++ [
-        "--cross-prefix=${stdenv.cc.prefix}"
+        "--cross-prefix=${stdenv.cc.targetPrefix}"
         "--enable-cross-compile"
         "--target_os=linux"
         "--arch=${hostPlatform.arch}"
@@ -125,7 +130,6 @@ let
       license = with licenses; if enableUnfree then unfree #ToDo: redistributable or not?
         else if enableGPL then gpl2Plus else lgpl21Plus;
       platforms = with platforms; linux ++ darwin;
-      maintainers = [ maintainers.vcunat ];
     };
   }; # libavFun
 
diff --git a/pkgs/development/libraries/libbap/default.nix b/pkgs/development/libraries/libbap/default.nix
index a427bd99dd58..54fb89df0451 100644
--- a/pkgs/development/libraries/libbap/default.nix
+++ b/pkgs/development/libraries/libbap/default.nix
@@ -3,13 +3,13 @@
 
 stdenv.mkDerivation rec {
   name = "libbap-${version}";
-  version = "master-2017-02-08";
+  version = "master-2018-03-01";
 
   src = fetchFromGitHub {
     owner = "BinaryAnalysisPlatform";
     repo = "bap-bindings";
-    rev = "b3da5bd5cdb3d646015ccdeb886b5ea8fd85a108";
-    sha256 = "0cwfyfpxbi9bm4kkpamyd7mgsm5b6j1rh217fqb5gi05wg45rkbb";
+    rev = "bd125c379a784d4265c2ddcf1f6e34bde2e568d4";
+    sha256 = "0dp90djyjc262v1b1cw5irp424a8394y86fyprdk8z741wg56m3v";
   };
 
   nativeBuildInputs = [ autoreconfHook which ];
diff --git a/pkgs/development/libraries/libbfd/default.nix b/pkgs/development/libraries/libbfd/default.nix
new file mode 100644
index 000000000000..3f244d399f7e
--- /dev/null
+++ b/pkgs/development/libraries/libbfd/default.nix
@@ -0,0 +1,59 @@
+{ stdenv, buildPackages
+, fetchurl, fetchpatch, gnu-config, autoreconfHook264, bison, binutils-unwrapped
+, libiberty, zlib
+}:
+
+stdenv.mkDerivation rec {
+  name = "libbfd-${version}";
+  inherit (binutils-unwrapped) version src;
+
+  outputs = [ "out" "dev" ];
+
+  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";
+      sha256 = "0pzb3i74d1r7lhjan376h59a7kirw15j7swwm8pz3zy9lkdqkj6q";
+    })
+  ];
+
+  # We just want to build libbfd
+  postPatch = ''
+    cd bfd
+  '';
+
+  postAutoreconf = ''
+    echo "Updating config.guess and config.sub from ${gnu-config}"
+    cp -f ${gnu-config}/config.{guess,sub} ../
+  '';
+
+  # We update these ourselves
+  dontUpdateAutotoolsGnuConfigScripts = true;
+
+  nativeBuildInputs = [ autoreconfHook264 bison ];
+  buildInputs = [ libiberty zlib ];
+
+  configurePlatforms = [ "build" "host" ];
+  configureFlags = [
+    "--enable-targets=all" "--enable-64-bit-bfd"
+    "--enable-install-libbfd"
+    "--enable-shared"
+    "--with-system-zlib"
+  ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "A library for manipulating containers of machine code";
+    longDescription = ''
+      BFD is a library which provides a single interface to read and write
+      object files, executables, archive files, and core files in any format.
+      It is associated with GNU Binutils, and elsewhere often distributed with
+      it.
+    '';
+    homepage = http://www.gnu.org/software/binutils/;
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ ericson2314 ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/libbladeRF/default.nix b/pkgs/development/libraries/libbladeRF/default.nix
index 8948a74ad630..3f4f48775c1b 100644
--- a/pkgs/development/libraries/libbladeRF/default.nix
+++ b/pkgs/development/libraries/libbladeRF/default.nix
@@ -2,14 +2,14 @@
 , libusb1, udev }:
 
 stdenv.mkDerivation rec {
-  version = "1.4.0";
+  version = "1.9.0";
   name = "libbladeRF-v${version}";
 
   src = fetchFromGitHub {
     owner = "Nuand";
     repo = "bladeRF";
     rev = "libbladeRF_v${version}";
-    sha256 = "1y00hqsmqaix4dql8mb75zx87zvn8b483yxv53x9qyjspksbs60c";
+    sha256 = "0frvphp4xxdxwzmi94b0asl7b891sd3fk8iw9kfk8h6f3cdhj8xa";
   };
 
   nativeBuildInputs = [ pkgconfig ];
@@ -35,6 +35,6 @@ stdenv.mkDerivation rec {
     description = "Supporting library of the BladeRF SDR opensource hardware";
     license = licenses.lgpl21;
     maintainers = with maintainers; [ funfunctor ];
-    platforms = platforms.linux;
+    platforms = with platforms; linux;
   };
 }
diff --git a/pkgs/development/libraries/libbluray/default.nix b/pkgs/development/libraries/libbluray/default.nix
index 8b67d52b875e..fea4744a075a 100644
--- a/pkgs/development/libraries/libbluray/default.nix
+++ b/pkgs/development/libraries/libbluray/default.nix
@@ -19,11 +19,11 @@ assert withFonts -> freetype != null;
 
 stdenv.mkDerivation rec {
   name = "libbluray-${version}";
-  version  = "1.0.0";
+  version  = "1.0.2";
 
   src = fetchurl {
     url = "http://get.videolan.org/libbluray/${version}/${name}.tar.bz2";
-    sha256 = "1k3lag4lxi2jjd3zh4wcb5l3hadzm54j5kagh92yzfy76p9svqzp";
+    sha256 = "1zxfnw1xbghcj7b3zz5djndv6gwssxda19cz1lrlqrkg8577r7kd";
   };
 
   patches = optional withJava ./BDJ-JARFILE-path.patch;
@@ -50,7 +50,7 @@ stdenv.mkDerivation rec {
   '';
 
   configureFlags =  with stdenv.lib;
-                    optional (! withJava) "--disable-bdjava"
+                    optional (! withJava) "--disable-bdjava-jar"
                  ++ optional (! withMetadata) "--without-libxml2"
                  ++ optional (! withFonts) "--without-freetype"
                  ;
diff --git a/pkgs/development/libraries/libbrotli/default.nix b/pkgs/development/libraries/libbrotli/default.nix
deleted file mode 100644
index 03604e3a93e2..000000000000
--- a/pkgs/development/libraries/libbrotli/default.nix
+++ /dev/null
@@ -1,37 +0,0 @@
-{ stdenv, fetchFromGitHub, autoconf, automake, libtool, brotliUnstable }:
-
-stdenv.mkDerivation rec {
-  name = "libbrotli-${version}";
-  version = "1.0";
-
-  src = fetchFromGitHub {
-    owner = "bagder";
-    repo = "libbrotli";
-    rev = name;
-    sha256 = "0apd3hpy3vaa7brkv8v0xwz05zbd5xv86rcbkwns4x39klba3m3y";
-  };
-
-  nativeBuildInputs = [ autoconf automake libtool ];
-
-  preConfigure = ''
-    cp -r ${brotliUnstable.src}/* brotli/
-    chmod -R +700 brotli
-    mkdir m4
-    autoreconf --install --force --symlink
-  '';
-
-  meta = with stdenv.lib; {
-    description = "Meta project to build libraries from the brotli source code";
-    longDescription = ''
-      Wrapper scripts and code around the brotli code base.
-      Builds libraries out of the brotli decode and encode sources. Uses autotools.
-      'brotlidec' is the library for decoding, decompression
-      'brotlienc' is the library for encoding, compression
-    '';
-
-    homepage = https://github.com/bagder/libbrotli;
-    license = licenses.mit;
-    platforms = platforms.all;
-    maintainers = [];
-  };
-}
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/darwin.patch b/pkgs/development/libraries/libbsd/darwin.patch
index 77062cf4ec80..4bddec6b0ffd 100644
--- a/pkgs/development/libraries/libbsd/darwin.patch
+++ b/pkgs/development/libraries/libbsd/darwin.patch
@@ -1,8 +1,8 @@
 diff --git a/configure.ac b/configure.ac
-index 5a432d4..a69ae0b 100644
+index 88ccd91..0857782 100644
 --- a/configure.ac
 +++ b/configure.ac
-@@ -55,7 +55,7 @@ AS_CASE([$host_os],
+@@ -59,7 +59,7 @@ AS_CASE([$host_os],
  )
  
  # Checks for header files.
@@ -10,10 +10,10 @@ index 5a432d4..a69ae0b 100644
 +AC_CHECK_HEADERS([sys/ndir.h sys/dir.h ndir.h dirent.h stdio_ext.h])
  
  # Checks for typedefs, structures, and compiler characteristics.
- AC_TYPE_UID_T
-@@ -143,6 +143,31 @@ AC_CHECK_FUNCS([clearenv dirfd fopencookie __fpurge \
+ AC_C_INLINE
+@@ -146,6 +146,31 @@ AC_CHECK_FUNCS([clearenv dirfd fopencookie __fpurge \
                  pstat_getproc sysconf])
- AM_CONDITIONAL(HAVE_GETENTROPY, [test "x$ac_cv_func_getentropy" = "xtrue"])
+ AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xtrue"])
  
 +HostOS=`echo "$host" | sed 's/.*-//'`
 +os_is_macosx=false
@@ -44,12 +44,12 @@ index 5a432d4..a69ae0b 100644
  	Makefile
  	include/Makefile
 diff --git a/include/bsd/libutil.h b/include/bsd/libutil.h
-index ebb6160..ce882bf 100644
+index 45b3b15..d0d4043 100644
 --- a/include/bsd/libutil.h
 +++ b/include/bsd/libutil.h
 @@ -39,7 +39,9 @@
- #ifndef _LIBUTIL_H_
- #define _LIBUTIL_H_
+ #ifndef LIBBSD_LIBUTIL_H
+ #define LIBBSD_LIBUTIL_H
  
 +#ifdef HAVE_FEATURES_H
  #include <features.h>
@@ -58,10 +58,10 @@ index ebb6160..ce882bf 100644
  #include <sys/types.h>
  #include <stdint.h>
 diff --git a/include/bsd/stdio.h b/include/bsd/stdio.h
-index 7697425..ef34c4f 100644
+index 4b69983..c75151b 100644
 --- a/include/bsd/stdio.h
 +++ b/include/bsd/stdio.h
-@@ -44,12 +44,16 @@
+@@ -48,12 +48,16 @@
  __BEGIN_DECLS
  const char *fmtcheck(const char *, const char *);
  
@@ -69,37 +69,60 @@ index 7697425..ef34c4f 100644
  /* XXX: The function requires cooperation from the system libc to store the
   * line buffer in the FILE struct itself. */
  char *fgetln(FILE *fp, size_t *lenp)
- 	__attribute__((deprecated("This functions cannot be safely ported, "
- 	                          "use getline(3) instead, as it is supported "
- 	                          "by GNU and POSIX.1-2008.")));
+-	LIBBSD_DEPRECATED("This functions cannot be safely ported, "
+-	                  "use getline(3) instead, as it is supported "
+-	                  "by GNU and POSIX.1-2008.");
++	__attribute__((deprecated("This functions cannot be safely ported, "
++	                          "use getline(3) instead, as it is supported "
++	                          "by GNU and POSIX.1-2008.")));
 +#else
 +char *fgetln(FILE *fp, size_t *lenp);
 +#endif
  
  /*
   * Note: We diverge from the FreeBSD, OpenBSD and DragonFlyBSD declarations,
+diff --git a/include/bsd/stdlib.h b/include/bsd/stdlib.h
+index ebc9638..6cd7943 100644
+--- a/include/bsd/stdlib.h
++++ b/include/bsd/stdlib.h
+@@ -67,9 +67,11 @@ 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(_GNU_SOURCE) && defined(__GLIBC__) && defined(__GLIBC_PREREQ)
++#if !__GLIBC_PREREQ(2, 26)
+ void *reallocarray(void *ptr, size_t nmemb, size_t size);
+ #endif
++#endif
+ 
+ long long strtonum(const char *nptr, long long minval, long long maxval,
+                    const char **errstr);
 diff --git a/include/bsd/string.h b/include/bsd/string.h
-index ee2f953..a3ab077 100644
+index 6798bf6..6baaa14 100644
 --- a/include/bsd/string.h
 +++ b/include/bsd/string.h
-@@ -37,11 +37,14 @@
+@@ -37,6 +37,12 @@
  #include <sys/types.h>
  
  __BEGIN_DECLS
--size_t strlcpy(char *dst, const char *src, size_t siz);
--size_t strlcat(char *dst, const char *src, size_t siz);
- char *strnstr(const char *str, const char *find, size_t str_len);
 +#if defined(darwin) || defined(__APPLE__) || defined(MACOSX)
 +size_t bsd_strlcpy(char *dst, const char *src, size_t siz);
 +size_t bsd_strlcat(char *dst, const char *src, size_t siz);
++char *bsd_strnstr(const char *str, const char *find, size_t str_len);
 +void bsd_strmode(mode_t mode, char *str);
 +#else
- void strmode(mode_t mode, char *str);
--
-+#endif
+ size_t strlcpy(char *dst, const char *src, size_t siz);
+ size_t strlcat(char *dst, const char *src, size_t siz);
+ char *strnstr(const char *str, const char *find, size_t str_len);
+@@ -45,6 +51,7 @@ void strmode(mode_t mode, char *str);
+ #if defined(_GNU_SOURCE) && defined(__GLIBC__) && !__GLIBC_PREREQ(2, 25)
  void explicit_bzero(void *buf, size_t len);
+ #endif
++#endif
  __END_DECLS
  
+ #endif
 diff --git a/src/Makefile.am b/src/Makefile.am
 index ad83dbf..0f2a7ee 100644
 --- a/src/Makefile.am
@@ -519,16 +542,16 @@ index 462535a..e7eb46f 100644
 +}
  #endif
 diff --git a/src/funopen.c b/src/funopen.c
-index 7d6ae31..9963162 100644
+index 1e05c7e..75e61ea 100644
 --- a/src/funopen.c
 +++ b/src/funopen.c
-@@ -137,6 +137,7 @@ funopen(const void *cookie,
- 
- 	return fopencookie(cookiewrap, mode, funcswrap);
- }
+@@ -143,6 +143,7 @@ funopen(const void *cookie,
+  * they will not add the needed support to implement it. Just ignore this
+  * interface there, as it has never been provided anyway.
+  */
 +#elif defined(darwin) || defined(__APPLE__) || defined(MACOSX)
  #else
- #error "Function funopen() needs to be ported."
+ #error "Function funopen() needs to be ported or disabled."
  #endif
 diff --git a/src/getentropy.c b/src/getentropy.c
 index 3f11a1e..8a23a07 100644
@@ -562,13 +585,15 @@ index 4f368a1..ab22fc1 100644
  #define SHA512_DIGEST_LENGTH		64
  
 diff --git a/src/hash/sha512c.c b/src/hash/sha512c.c
-index c2a93be..f69013d 100644
+index b3c8d5e..f69013d 100644
 --- a/src/hash/sha512c.c
 +++ b/src/hash/sha512c.c
-@@ -27,7 +27,11 @@
- #include <sys/cdefs.h>
- __FBSDID("$FreeBSD$");
+@@ -25,7 +25,13 @@
+  */
  
+ #include <sys/cdefs.h>
++__FBSDID("$FreeBSD$");
++
 +#if defined(darwin) || defined(__APPLE__) || defined(MACOSX)
 +#include <machine/endian.h>
 +#else
@@ -578,24 +603,27 @@ index c2a93be..f69013d 100644
  
  #include <string.h>
 diff --git a/src/nlist.c b/src/nlist.c
-index 0cffe55..f785b61 100644
+index 0932f59..598a329 100644
 --- a/src/nlist.c
 +++ b/src/nlist.c
-@@ -27,6 +27,7 @@
+@@ -27,6 +27,10 @@
   * SUCH DAMAGE.
   */
  
 +#if !defined(darwin) && !defined(__APPLE__) && !defined(MACOSX)
- #if defined(LIBC_SCCS) && !defined(lint)
- static char sccsid[] = "@(#)nlist.c	8.1 (Berkeley) 6/4/93";
- #endif /* LIBC_SCCS and not lint */
-@@ -409,3 +410,4 @@ elf_sym_to_nlist(struct nlist *nl, Elf_Sym *s, Elf_Shdr *shdr, int shnum)
- 		nl->n_type |= N_EXT;
++#if defined(LIBC_SCCS) && !defined(lint)
++static char sccsid[] = "@(#)nlist.c	8.1 (Berkeley) 6/4/93";
++#endif /* LIBC_SCCS and not lint */
+ #include <sys/cdefs.h>
+ 
+ #include <sys/param.h>
+@@ -265,3 +269,4 @@ nlist(const char *name, struct nlist *list)
+ 	(void)close(fd);
+ 	return (n);
  }
- #endif /* _NLIST_DO_ELF */
-+#endif
++#endif /* _NLIST_DO_ELF */
 diff --git a/src/setproctitle.c b/src/setproctitle.c
-index c18c61c..b1b1591 100644
+index 038ac7d..d0ef01b 100644
 --- a/src/setproctitle.c
 +++ b/src/setproctitle.c
 @@ -32,6 +32,11 @@
@@ -626,42 +654,42 @@ index c18c61c..b1b1591 100644
  void setproctitle_stub(const char *fmt, ...)
  	__attribute__((alias("setproctitle_impl")));
 diff --git a/src/strlcat.c b/src/strlcat.c
-index 21c8afb..e036132 100644
+index 14c53a1..e01cb60 100644
 --- a/src/strlcat.c
 +++ b/src/strlcat.c
 @@ -27,7 +27,11 @@
-  * If retval >= siz, truncation occurred.
+  * If retval >= dsize, truncation occurred.
   */
  size_t
 +#if defined(darwin) || defined(__APPLE__) || defined(MACOSX)
-+bsd_strlcat(char *dst, const char *src, size_t siz)
++bsd_strlcat(char *dst, const char *src, size_t dsize)
 +#else
- strlcat(char *dst, const char *src, size_t siz)
+ strlcat(char *dst, const char *src, size_t dsize)
 +#endif
  {
- 	char *d = dst;
- 	const char *s = src;
+ 	const char *odst = dst;
+ 	const char *osrc = src;
 diff --git a/src/strlcpy.c b/src/strlcpy.c
-index 1719d35..c63591d 100644
+index e9a7fe4..10a855f 100644
 --- a/src/strlcpy.c
 +++ b/src/strlcpy.c
 @@ -25,7 +25,11 @@
-  * Returns strlen(src); if retval >= siz, truncation occurred.
+  * Returns strlen(src); if retval >= dsize, truncation occurred.
   */
  size_t
 +#if defined(darwin) || defined(__APPLE__) || defined(MACOSX)
-+bsd_strlcpy(char *dst, const char *src, size_t siz)
++bsd_strlcpy(char *dst, const char *src, size_t dsize)
 +#else
- strlcpy(char *dst, const char *src, size_t siz)
+ strlcpy(char *dst, const char *src, size_t dsize)
 +#endif
  {
- 	char *d = dst;
- 	const char *s = src;
+ 	const char *osrc = src;
+ 	size_t nleft = dsize;
 diff --git a/src/strmode.c b/src/strmode.c
-index 8d825ae..c1b5f8d 100644
+index e6afde5..c463243 100644
 --- a/src/strmode.c
 +++ b/src/strmode.c
-@@ -37,7 +37,11 @@ static char sccsid[] = "@(#)strmode.c	8.3 (Berkeley) 8/15/94";
+@@ -33,7 +33,11 @@
  #include <string.h>
  
  void
diff --git a/pkgs/development/libraries/libbsd/default.nix b/pkgs/development/libraries/libbsd/default.nix
index c73096d1eeb5..ff9412ceb580 100644
--- a/pkgs/development/libraries/libbsd/default.nix
+++ b/pkgs/development/libraries/libbsd/default.nix
@@ -2,23 +2,33 @@
 
 stdenv.mkDerivation rec {
   name = "libbsd-${version}";
-  version = "0.8.6";
+  version = "0.8.7";
 
   src = fetchurl {
     url = "http://libbsd.freedesktop.org/releases/${name}.tar.xz";
-    sha256 = "11wnkzims5grprvhb1ssmq9pc2lcgh2r2rk8gwgz36ply6fvyzs6";
+    sha256 = "0c9bl49zs0xdddcwj5dh0lay9sxi2m1yi74848g8p87mb87g2j7m";
   };
 
   # darwin changes configure.ac which means we need to regenerate
   # 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";
     homepage = https://libbsd.freedesktop.org/;
     license = licenses.bsd3;
     platforms = platforms.linux ++ platforms.darwin;
+    maintainers = with maintainers; [ matthewbauer ];
   };
 }
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/libbson/default.nix b/pkgs/development/libraries/libbson/default.nix
index 28a6aee67c1e..6b370f46e70d 100644
--- a/pkgs/development/libraries/libbson/default.nix
+++ b/pkgs/development/libraries/libbson/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "libbson-${version}";
-  version = "1.8.0";
+  version = "1.9.4";
 
   src = fetchFromGitHub {
     owner = "mongodb";
     repo = "libbson";
     rev = version;
-    sha256 = "1bd9z07q3faq5k4521d9inv0j836w6hrsd0vj2sapjlq8jmqgslg";
+    sha256 = "01lyikbpqky1ib8g4vhwpb5rjwyzm6g1z24z8m73lk4vcdl65190";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/libburn/default.nix b/pkgs/development/libraries/libburn/default.nix
index f49c449f9ea3..76977b745197 100644
--- a/pkgs/development/libraries/libburn/default.nix
+++ b/pkgs/development/libraries/libburn/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libburn-${version}";
-  version = "1.4.6";
+  version = "1.4.8";
 
   src = fetchurl {
     url = "http://files.libburnia-project.org/releases/${name}.tar.gz";
-    sha256 = "0wbh49s3az3sfpai09z1zdgynq7wnwrk31v5589033274nmzldlx";
+    sha256 = "19lxnzn8bz70glrrrn2hs43gf5g7gfbcka9rcbckhv1pb7is509y";
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libcdio-paranoia/default.nix b/pkgs/development/libraries/libcdio-paranoia/default.nix
new file mode 100644
index 000000000000..48e632ba52d8
--- /dev/null
+++ b/pkgs/development/libraries/libcdio-paranoia/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, libcdio, pkgconfig,
+  libiconv, IOKit, DiskArbitration}:
+
+stdenv.mkDerivation {
+  name = "libcdio-paranoia-0.94+2";
+
+  src = fetchFromGitHub {
+    owner = "rocky";
+    repo = "libcdio-paranoia";
+    rev = "release-10.2+0.94+2";
+    sha256 = "1wjgmmaca4baw7k5c3vdap9hnjc49ciagi5kvpvync3aqfmdvkha";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ libcdio ] ++
+    stdenv.lib.optionals stdenv.isDarwin [ libiconv IOKit DiskArbitration ];
+
+  propagatedBuildInputs = stdenv.lib.optional stdenv.isDarwin DiskArbitration;
+
+  configureFlags = stdenv.lib.optionals stdenv.isDarwin [
+    "--disable-ld-version-script"
+  ];
+
+  meta = with stdenv.lib; {
+    description = "CD paranoia on top of libcdio";
+    longDescription = ''
+      This is a port of xiph.org's cdda paranoia to use libcdio for CDROM
+      access. By doing this, cdparanoia runs on platforms other than GNU/Linux.
+    '';
+    license = licenses.gpl3;
+    homepage = https://github.com/rocky/libcdio-paranoia;
+    platforms = platforms.linux ++ platforms.darwin;
+    maintainers = [ maintainers.pbogdan ];
+  };
+}
diff --git a/pkgs/development/libraries/libcdio/0.82.nix b/pkgs/development/libraries/libcdio/0.82.nix
deleted file mode 100644
index a4b2e6078d2b..000000000000
--- a/pkgs/development/libraries/libcdio/0.82.nix
+++ /dev/null
@@ -1,30 +0,0 @@
-{ stdenv, fetchurl, libcddb, pkgconfig, ncurses, help2man, libiconv }:
-
-stdenv.mkDerivation rec {
-  name = "libcdio-0.82";
-
-  src = fetchurl {
-    url = "mirror://gnu/libcdio/${name}.tar.gz";
-    sha256 = "0fax1dzy84dzs20bmpq2gfw6hc1x2x9mhk53wynhcycjw3l3vjqs";
-  };
-
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ libcddb ncurses help2man ]
-    ++ stdenv.lib.optional stdenv.isDarwin libiconv;
-
-  # Disabled because one test (check_paranoia.sh) fails.
-  #doCheck = true;
-
-  meta = with stdenv.lib; {
-    description = "A library for OS-independent CD-ROM and CD image access";
-    longDescription = ''
-      GNU libcdio is a library for OS-independent CD-ROM and
-      CD image access.  It includes a library for working with
-      ISO-9660 filesystems (libiso9660), as well as utility
-      programs such as an audio CD player and an extractor.
-    '';
-    license = licenses.gpl2Plus;
-    homepage = http://www.gnu.org/software/libcdio/;
-    platforms = platforms.linux ++ platforms.darwin;
-  };
-}
diff --git a/pkgs/development/libraries/libcdio/default.nix b/pkgs/development/libraries/libcdio/default.nix
index f7596b9c702b..bb81721feeae 100644
--- a/pkgs/development/libraries/libcdio/default.nix
+++ b/pkgs/development/libraries/libcdio/default.nix
@@ -1,19 +1,19 @@
-{ stdenv, fetchurl, libcddb, pkgconfig, ncurses, help2man, libiconv }:
+{ stdenv, fetchurl, libcddb, pkgconfig, ncurses, help2man, libiconv, Carbon, IOKit }:
 
 stdenv.mkDerivation rec {
-  name = "libcdio-0.93";
+  name = "libcdio-2.0.0";
 
   src = fetchurl {
     url = "mirror://gnu/libcdio/${name}.tar.bz2";
-    sha256 = "1a6x2c5bvpnkn7lhmxkjgz4axmh93m1clrlv41s1wzkc48lnc9zq";
+    sha256 = "0jr8ppdm80c533nzmrpz3iffnpc6nhvsria1di9f4jg1l19a03fd";
   };
 
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ libcddb ncurses help2man ]
-    ++ stdenv.lib.optional stdenv.isDarwin libiconv;
+    ++ stdenv.lib.optionals stdenv.isDarwin [ libiconv Carbon IOKit ];
 
-  # Disabled because one test (check_paranoia.sh) fails.
-  #doCheck = true;
+  # Disabled due to several spurious test failures.
+  # doCheck = true;
 
   meta = with stdenv.lib; {
     description = "A library for OS-independent CD-ROM and CD image access";
diff --git a/pkgs/development/libraries/libcdr/default.nix b/pkgs/development/libraries/libcdr/default.nix
index 670484f0ae61..6d8cafcfaa60 100644
--- a/pkgs/development/libraries/libcdr/default.nix
+++ b/pkgs/development/libraries/libcdr/default.nix
@@ -1,14 +1,14 @@
-{ stdenv, fetchurl, libwpg, libwpd, lcms, pkgconfig, librevenge, icu, boost }:
+{ stdenv, fetchurl, libwpg, libwpd, lcms, pkgconfig, librevenge, icu, boost, cppunit }:
 
 stdenv.mkDerivation rec {
-  name = "libcdr-0.1.1";
+  name = "libcdr-0.1.4";
 
   src = fetchurl {
-    url = "http://dev-www.libreoffice.org/src/${name}.tar.bz2";
-    sha256 = "0javd72wmaqd6vprsh3clm393b3idjdjzbb7vyn44li7yaxppzkj";
+    url = "http://dev-www.libreoffice.org/src/${name}.tar.xz";
+    sha256 = "0vd6likgk51j46llybkx4wq3674xzrhp0k82220pkx9x1aqfi9z7";
   };
 
-  buildInputs = [ libwpg libwpd lcms librevenge icu boost ];
+  buildInputs = [ libwpg libwpd lcms librevenge icu boost cppunit ];
 
   nativeBuildInputs = [ pkgconfig ];
 
diff --git a/pkgs/development/libraries/libcec/platform.nix b/pkgs/development/libraries/libcec/platform.nix
index 228dccea3e39..0005525a7cd2 100644
--- a/pkgs/development/libraries/libcec/platform.nix
+++ b/pkgs/development/libraries/libcec/platform.nix
@@ -1,13 +1,13 @@
 { stdenv, fetchurl, cmake }:
 
-let version = "2.0.1"; in
+let version = "2.1.0.1"; in
 
 stdenv.mkDerivation {
   name = "p8-platform-${version}";
 
   src = fetchurl {
     url = "https://github.com/Pulse-Eight/platform/archive/p8-platform-${version}.tar.gz";
-    sha256 = "1kslq24p2zams92kc247qcczbxb2n89ykk9jfyiilmwh7qklazp9";
+    sha256 = "18381y54f7d18ckpzf9cfxbz1ws6imprbbm9pvhcg5c86ln8skq6";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/libcerf/default.nix b/pkgs/development/libraries/libcerf/default.nix
new file mode 100644
index 000000000000..fd5ee8dcaaf9
--- /dev/null
+++ b/pkgs/development/libraries/libcerf/default.nix
@@ -0,0 +1,18 @@
+{ stdenv, lib, fetchurl }:
+
+stdenv.mkDerivation {
+  name = "libcerf-1.5";
+
+  src = fetchurl {
+    url = "http://apps.jcns.fz-juelich.de/src/libcerf/libcerf-1.5.tgz";
+    sha256 = "11jwr8ql4a9kmv04ycgwk4dsqnlv4l65a8aa0x1i3y7zwx3w2vg3";
+  };
+
+  meta = with lib; {
+    description = "Complex error (erf), Dawson, Faddeeva, and Voigt function library";
+    homepage = http://apps.jcns.fz-juelich.de/doku/sc/libcerf;
+    license = licenses.mit;
+    maintainers = with maintainers; [ orivej ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/libchamplain/default.nix b/pkgs/development/libraries/libchamplain/default.nix
index 514a1fa85343..74e5bbc952ae 100644
--- a/pkgs/development/libraries/libchamplain/default.nix
+++ b/pkgs/development/libraries/libchamplain/default.nix
@@ -1,37 +1,43 @@
-{ fetchurl, stdenv, pkgconfig, glib, gtk3, cairo, clutter, sqlite
-, clutter_gtk, libsoup, gobjectIntrospection /*, libmemphis */ }:
+{ fetchurl, stdenv, pkgconfig, glib, gtk3, cairo, clutter, sqlite, gnome3
+, clutter-gtk, libsoup, gobjectIntrospection /*, libmemphis */ }:
 
+let
+  pname = "libchamplain";
+  version = "0.12.16";
+in
 stdenv.mkDerivation rec {
-  major = "0.12";
-  version = "${major}.16";
-  name = "libchamplain-${version}";
+  name = "${pname}-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/libchamplain/${major}/${name}.tar.xz";
+    url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
     sha256 = "13chvc2n074i0jw5jlb8i7cysda4yqx58ca6y3mrlrl9g37k2zja";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ gobjectIntrospection ];
+  nativeBuildInputs = [ pkgconfig gobjectIntrospection ];
 
-  propagatedBuildInputs = [ glib gtk3 cairo clutter_gtk sqlite libsoup ];
+  propagatedBuildInputs = [ glib gtk3 cairo clutter-gtk sqlite libsoup ];
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+    };
+  };
 
   meta = with stdenv.lib; {
-    inherit version;
-    homepage = http://projects.gnome.org/libchamplain/;
+    homepage = https://wiki.gnome.org/Projects/libchamplain;
     license = licenses.lgpl2Plus;
 
     description = "C library providing a ClutterActor to display maps";
 
-    longDescription =
-      '' libchamplain is a C library providing a ClutterActor to display
-         maps.  It also provides a Gtk+ widget to display maps in Gtk+
-         applications.  Python and Perl bindings are also available.  It
-         supports numerous free map sources such as OpenStreetMap,
-         OpenCycleMap, OpenAerialMap, and Maps for free.
-      '';
+    longDescription = ''
+      libchamplain is a C library providing a ClutterActor to display
+       maps.  It also provides a Gtk+ widget to display maps in Gtk+
+       applications.  Python and Perl bindings are also available.  It
+       supports numerous free map sources such as OpenStreetMap,
+       OpenCycleMap, OpenAerialMap, and Maps for free.
+    '';
 
-     maintainers = [ ];
+     maintainers = gnome3.maintainers;
      platforms = platforms.gnu;  # arbitrary choice
   };
 }
diff --git a/pkgs/development/libraries/libchewing/default.nix b/pkgs/development/libraries/libchewing/default.nix
index 0521ae8a0400..d3ef799ef605 100644
--- a/pkgs/development/libraries/libchewing/default.nix
+++ b/pkgs/development/libraries/libchewing/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec{
   name = "libchewing-${version}";
-  version = "0.4.0";
+  version = "0.5.1";
 
   src = fetchurl {
     url = "https://github.com/chewing/libchewing/releases/download/v${version}/libchewing-${version}.tar.bz2";
-    sha256 = "1j5g5j4w6yp73k03pmsq9n2r0p458hqriq0sd5kisj9xrssbynp5";
+    sha256 = "0aqp2vqgxczydpn7pxi7r6xf3l1hgl710f0gbi1k8q7s2lscc24p";
   };
 
   buildInputs = [ sqlite ];
diff --git a/pkgs/development/libraries/libclc/default.nix b/pkgs/development/libraries/libclc/default.nix
index c5ba65e7b6d7..a83a3c672c0f 100644
--- a/pkgs/development/libraries/libclc/default.nix
+++ b/pkgs/development/libraries/libclc/default.nix
@@ -1,16 +1,22 @@
-{ stdenv, fetchFromGitHub, python2, llvm_4, clang }:
+{ stdenv, fetchFromGitHub, python, llvmPackages }:
+
+let
+  llvm = llvmPackages.llvm;
+  clang = llvmPackages.clang;
+in
 
 stdenv.mkDerivation {
-  name = "libclc-2017-02-25";
+  name = "libclc-2017-11-29";
 
   src = fetchFromGitHub {
     owner = "llvm-mirror";
     repo = "libclc";
-    rev = "17648cd846390e294feafef21c32c7106eac1e24";
-    sha256 = "1c20jyh3sdwd9r37zs4vvppmsx8vhf2xbx0cxsrc27bhx5245p0s";
+    rev = "d6384415ab854c68777dd77451aa2bc0d959da99";
+    sha256 = "10fqrlnqlknh58x7pfsbg9r07fblfg2mgq2m4fr1jbb836ncn3wh";
   };
 
-  buildInputs = [ python2 llvm_4 clang ];
+  nativeBuildInputs = [ python ];
+  buildInputs = [ llvm clang ];
 
   postPatch = ''
     sed -i 's,llvm_clang =.*,llvm_clang = "${clang}/bin/clang",' configure.py
@@ -18,7 +24,7 @@ stdenv.mkDerivation {
   '';
 
   configurePhase = ''
-    ${python2.interpreter} ./configure.py --prefix=$out
+    ${python.interpreter} ./configure.py --prefix=$out
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libcli/default.nix b/pkgs/development/libraries/libcli/default.nix
index 587e72409c45..f101eb223106 100644
--- a/pkgs/development/libraries/libcli/default.nix
+++ b/pkgs/development/libraries/libcli/default.nix
@@ -27,6 +27,5 @@ stdenv.mkDerivation rec {
     homepage = http://sites.dparrish.com/libcli;
     license = licenses.lgpl21Plus;
     platforms = platforms.linux;
-    maintainers = with maintainers; [ nckx ];
   };
 }
diff --git a/pkgs/development/libraries/libcloudproviders/default.nix b/pkgs/development/libraries/libcloudproviders/default.nix
new file mode 100644
index 000000000000..fc857bf1ad46
--- /dev/null
+++ b/pkgs/development/libraries/libcloudproviders/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchurl, pkgconfig, meson, ninja, gtk-doc, docbook_xsl, glib }:
+
+# TODO: Add installed tests once https://gitlab.gnome.org/Incubator/libcloudproviders/issues/4 is fixed
+
+let
+  pname = "libcloudproviders";
+  version = "0.2.5";
+in stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+
+  src = fetchurl {
+    url = "https://gitlab.gnome.org/Incubator/${pname}/repository/archive.tar.gz?ref=${version}";
+    sha256 = "1c3vfg8wlsv0fmi1lm9qhsqdvp4k33yvwn6j680rh49laayf7k3g";
+  };
+
+  patches = [
+    ./fix-include.patch
+  ];
+
+  outputs = [ "out" "dev" "devdoc" ];
+
+  mesonFlags = [
+    "-Denable-gtk-doc=true"
+  ];
+
+  nativeBuildInputs = [ meson ninja pkgconfig gtk-doc docbook_xsl ];
+
+  buildInputs = [ glib ];
+
+  meta = with stdenv.lib; {
+    description = "DBus API that allows cloud storage sync clients to expose their services";
+    homepage = https://gitlab.gnome.org/Incubator/libcloudproviders;
+    license = licenses.lgpl3Plus;
+    maintainers = with maintainers; [ jtojnar ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/libcloudproviders/fix-include.patch b/pkgs/development/libraries/libcloudproviders/fix-include.patch
new file mode 100644
index 000000000000..d6f626436a62
--- /dev/null
+++ b/pkgs/development/libraries/libcloudproviders/fix-include.patch
@@ -0,0 +1,11 @@
+--- a/meson.build
++++ b/meson.build
+@@ -46,7 +46,7 @@
+ bindir = get_option ('bindir')
+ datadir = get_option ('datadir')
+ servicedir = join_paths (datadir, 'dbus-1', 'services')
+-incdir = join_paths (prefix, 'include', 'cloudproviders')
++incdir = join_paths (prefix, get_option('includedir'), 'cloudproviders')
+ 
+ gnome = import('gnome')
+ 
diff --git a/pkgs/development/libraries/libcollectdclient/default.nix b/pkgs/development/libraries/libcollectdclient/default.nix
index f6d9d7ca69b8..e4e61c942836 100644
--- a/pkgs/development/libraries/libcollectdclient/default.nix
+++ b/pkgs/development/libraries/libcollectdclient/default.nix
@@ -5,14 +5,17 @@ overrideDerivation collectd (oldAttrs: {
   name = "libcollectdclient-${collectd.version}";
   buildInputs = [ ];
 
-  configureFlags = [
-    "--without-daemon"
+  NIX_CFLAGS_COMPILE = oldAttrs.NIX_CFLAGS_COMPILE ++ [
+    "-Wno-error=unused-function"
   ];
 
-  makeFlags = [
-    "-C src/libcollectdclient/"
+  configureFlags = oldAttrs.configureFlags ++ [
+    "--disable-daemon"
+    "--disable-all-plugins"
   ];
 
+  postInstall = "rm -rf $out/{bin,etc,sbin,share}";
+
 }) // {
   meta = with stdenv.lib; {
     description = "C Library for collectd, a daemon which collects system performance statistics periodically";
diff --git a/pkgs/development/libraries/libconfuse/default.nix b/pkgs/development/libraries/libconfuse/default.nix
index a89bdec2c8af..29398ac8aac5 100644
--- a/pkgs/development/libraries/libconfuse/default.nix
+++ b/pkgs/development/libraries/libconfuse/default.nix
@@ -2,10 +2,10 @@
 
 stdenv.mkDerivation rec {
   name = "libconfuse-${version}";
-  version = "3.0";
+  version = "3.2.1";
 
   src = fetchFromGitHub {
-    sha256 = "0021768bxqdxn84yaipncgi64889zrhc0r4ifmlfxirwq101dgr5";
+    sha256 = "1pb74wpg1cxz9hpp0p8i1qq6anaq06mh4xljd8dllm653fxvbjdz";
     rev = "v${version}";
     repo = "libconfuse";
     owner = "martinh";
@@ -15,7 +15,9 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  doCheck = true;
+  # On darwin the tests depend on the installed libraries because of install_name.
+  doInstallCheck = true;
+  installCheckTarget = "check";
 
   meta = with stdenv.lib; {
     inherit (src.meta) homepage;
@@ -32,6 +34,5 @@ stdenv.mkDerivation rec {
     '';
     license = licenses.isc;
     platforms = platforms.linux ++ platforms.darwin;
-    maintainers = with maintainers; [ nckx ];
   };
 }
diff --git a/pkgs/development/libraries/libcouchbase/default.nix b/pkgs/development/libraries/libcouchbase/default.nix
index 2fccee0160b3..c3050bf8c676 100644
--- a/pkgs/development/libraries/libcouchbase/default.nix
+++ b/pkgs/development/libraries/libcouchbase/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "libcouchbase-${version}";
-  version = "2.7.6";
+  version = "2.8.6";
 
   src = fetchFromGitHub {
     owner = "couchbase";
     repo = "libcouchbase";
     rev = version;
-    sha256 = "13g7r0mcmrj37mihj6g1x1ckpaps659c4qwnw3ixrg7p5mb3p41f";
+    sha256 = "1in0fdl5mgzhwmd8kvniqkizi7isf2g2gvbknfbbdmxkki7a8p95";
   };
 
   cmakeFlags = "-DLCB_NO_MOCK=ON";
diff --git a/pkgs/development/libraries/libcue/default.nix b/pkgs/development/libraries/libcue/default.nix
index e217f5d96db1..fb0f0d3d3f9c 100644
--- a/pkgs/development/libraries/libcue/default.nix
+++ b/pkgs/development/libraries/libcue/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "libcue-${version}";
-  version = "2.1.0";
+  version = "2.2.0";
 
   src = fetchFromGitHub {
     owner = "lipnitsk";
     repo = "libcue";
     rev = "v${version}";
-    sha256 = "14a84d6sq3yp8s8i05lxvifjpkgpjwfpchrqf3bbpbwa8gvrc0rj";
+    sha256 = "0znn9scamy1nsz1dzvsamqg46zr7ldfvpxiyzi1ss9d6gbcm0frs";
   };
 
   nativeBuildInputs = [ cmake bison flex ];
diff --git a/pkgs/development/libraries/libcutl/default.nix b/pkgs/development/libraries/libcutl/default.nix
index 526890ed5637..7b4d39f955aa 100644
--- a/pkgs/development/libraries/libcutl/default.nix
+++ b/pkgs/development/libraries/libcutl/default.nix
@@ -1,11 +1,13 @@
-{stdenv, fetchurl, xercesc }:
+{ stdenv, fetchurl, xercesc }:
+let
+    major = "1.9";
+    minor = "0";
+in
 with stdenv; with lib;
 mkDerivation rec {
-  name = "libcutl-${meta.major}.${meta.minor}";
+  name = "libcutl-${major}.${minor}";
 
   meta = {
-    major = "1.9";
-    minor = "0";
     description = "A collection of generic and independent components such as meta-programming tests, smart pointers, containers, compiler building blocks" ;
     platforms = platforms.all;
     maintainers = with maintainers; [ ];
diff --git a/pkgs/development/libraries/libdaemon/default.nix b/pkgs/development/libraries/libdaemon/default.nix
index 07d5b77efc4f..59e576fd3923 100644
--- a/pkgs/development/libraries/libdaemon/default.nix
+++ b/pkgs/development/libraries/libdaemon/default.nix
@@ -1,6 +1,6 @@
 {stdenv, fetchurl}:
 
-stdenv.mkDerivation rec {
+stdenv.mkDerivation (rec {
   name = "libdaemon-0.14";
 
   src = fetchurl {
@@ -8,7 +8,11 @@ stdenv.mkDerivation rec {
     sha256 = "0d5qlq5ab95wh1xc87rqrh1vx6i8lddka1w3f1zcqvcqdxgyn8zx";
   };
 
-  configureFlags = [ "--disable-lynx" ];
+  configureFlags = [ "--disable-lynx" ]
+    ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform)
+    [ # Can't run this test while cross-compiling
+      "ac_cv_func_setpgrp_void=yes"
+    ];
 
   meta = {
     description = "Lightweight C library that eases the writing of UNIX daemons";
@@ -20,4 +24,8 @@ stdenv.mkDerivation rec {
     platforms = stdenv.lib.platforms.unix;
     maintainers = [ ];
   };
-}
+} // stdenv.lib.optionalAttrs stdenv.hostPlatform.isMusl {
+  # This patch should be applied unconditionally, but doing so will cause mass rebuild.
+  patches = ./fix-includes.patch;
+})
+
diff --git a/pkgs/development/libraries/libdaemon/fix-includes.patch b/pkgs/development/libraries/libdaemon/fix-includes.patch
new file mode 100644
index 000000000000..51c5133afede
--- /dev/null
+++ b/pkgs/development/libraries/libdaemon/fix-includes.patch
@@ -0,0 +1,13 @@
+--- libdaemon-0.14.orig/examples/testd.c
++++ libdaemon-0.14/examples/testd.c
+@@ -21,9 +21,9 @@
+ #include <signal.h>
+ #include <errno.h>
+ #include <string.h>
++#include <unistd.h>
+ #include <sys/types.h>
+ #include <sys/time.h>
+-#include <sys/unistd.h>
+ #include <sys/select.h>
+ 
+ #include <libdaemon/dfork.h>
diff --git a/pkgs/development/libraries/libdap/default.nix b/pkgs/development/libraries/libdap/default.nix
index 57b56c372339..fc0221b93889 100644
--- a/pkgs/development/libraries/libdap/default.nix
+++ b/pkgs/development/libraries/libdap/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, bison, libuuid, curl, libxml2, flex }:
 
 stdenv.mkDerivation rec {
-  version = "3.18.3";
+  version = "3.19.1";
   name = "libdap-${version}";
 
   nativeBuildInputs = [ bison flex ];
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "http://www.opendap.org/pub/source/${name}.tar.gz";
-    sha256 = "0azjf4gjqvp1fdf1wb3s98x52zfy4viq1m3j9lggaidldfinmv8c";
+    sha256 = "0gnki93z3kkzp65x7n1kancy7bd503j4qja5fhzvm1gkmi5l65aj";
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libdazzle/default.nix b/pkgs/development/libraries/libdazzle/default.nix
new file mode 100644
index 000000000000..faa8b483a780
--- /dev/null
+++ b/pkgs/development/libraries/libdazzle/default.nix
@@ -0,0 +1,55 @@
+{ stdenv, pkgs, fetchurl, ninja, meson, pkgconfig, vala, gobjectIntrospection, libxml2
+, gtk-doc, docbook_xsl, dbus, xvfb_run, glib, gtk3, gnome3 }:
+
+let
+  version = "3.28.1";
+  pname = "libdazzle";
+in
+stdenv.mkDerivation {
+  name = "${pname}-${version}";
+
+  outputs = [ "out" "dev" "devdoc" ];
+  outputBin = "dev";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/libdazzle/${stdenv.lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
+    sha256 = "04j9pjigpgxddq6y90y73k8qyjixlalip87q121ss5d8zp8xnz32";
+  };
+
+  nativeBuildInputs = [ ninja meson pkgconfig vala gobjectIntrospection libxml2 gtk-doc docbook_xsl dbus xvfb_run ];
+  buildInputs = [ glib gtk3 ];
+
+  mesonFlags = [
+    "-Denable_gtk_doc=true"
+  ];
+
+  doCheck = true;
+
+  checkPhase = ''
+    export NO_AT_BRIDGE=1
+    xvfb-run -s '-screen 0 800x600x24' dbus-run-session \
+      --config-file=${dbus.daemon}/share/dbus-1/session.conf \
+      meson test --print-errorlogs
+  '';
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+    };
+  };
+
+  meta = with stdenv.lib; {
+    description = "A library to delight your users with fancy features";
+    longDescription = ''
+      The libdazzle library is a companion library to GObject and Gtk+. It
+      provides various features that we wish were in the underlying library but
+      cannot for various reasons. In most cases, they are wildly out of scope
+      for those libraries. In other cases, our design isn't quite generic
+      enough to work for everyone.
+    '';
+    homepage = https://wiki.gnome.org/Apps/Builder;
+    license = licenses.gpl3Plus;
+    maintainers = gnome3.maintainers;
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/libdbi-drivers/default.nix b/pkgs/development/libraries/libdbi-drivers/default.nix
index 77c09f3ed158..2a03efd632ff 100644
--- a/pkgs/development/libraries/libdbi-drivers/default.nix
+++ b/pkgs/development/libraries/libdbi-drivers/default.nix
@@ -1,5 +1,7 @@
 { stdenv, fetchurl, libdbi
-, libmysql ? null, sqlite ? null, postgresql ? null
+, mysql ? null
+, sqlite ? null
+, postgresql ? null
 }:
 
 with stdenv.lib;
@@ -11,7 +13,7 @@ stdenv.mkDerivation rec {
     sha256 = "0m680h8cc4428xin4p733azysamzgzcmv4psjvraykrsaz6ymlj3";
   };
 
-  buildInputs = [ libdbi libmysql sqlite postgresql ];
+  buildInputs = [ libdbi sqlite postgresql ] ++ optional (mysql != null) mysql.connector-c;
 
   postPatch = ''
     sed -i '/SQLITE3_LIBS/ s/-lsqlite/-lsqlite3/' configure;
@@ -24,16 +26,18 @@ stdenv.mkDerivation rec {
     "--enable-libdbi"
     "--with-dbi-incdir=${libdbi}/include"
     "--with-dbi-libdir=${libdbi}/lib"
-  ] ++ optionals (libmysql != null) [
+  ] ++ optionals (mysql != null) [
     "--with-mysql"
-  ] ++ optionals (postgresql != null) [
-    "--with-pgsql"
-    "--with-pgsql_incdir=${postgresql}/include"
-    "--with-pgsql_libdir=${postgresql.lib}/lib"
+    "--with-mysql-incdir=${mysql.connector-c}/include/mysql"
+    "--with-mysql-libdir=${mysql.connector-c}/lib/mysql"
   ] ++ optionals (sqlite != null) [
     "--with-sqlite3"
     "--with-sqlite3-incdir=${sqlite.dev}/include/sqlite"
     "--with-sqlite3-libdir=${sqlite.out}/lib/sqlite"
+  ] ++ optionals (postgresql != null) [
+    "--with-pgsql"
+    "--with-pgsql_incdir=${postgresql}/include"
+    "--with-pgsql_libdir=${postgresql.lib}/lib"
   ];
 
   installFlags = [ "DESTDIR=\${out}" ];
diff --git a/pkgs/development/libraries/libdbusmenu/default.nix b/pkgs/development/libraries/libdbusmenu/default.nix
index 96e9c0624f21..220cc5a2eeb4 100644
--- a/pkgs/development/libraries/libdbusmenu/default.nix
+++ b/pkgs/development/libraries/libdbusmenu/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, lib, file
 , pkgconfig, intltool
-, glib, dbus_glib, json_glib
-, gobjectIntrospection, vala_0_23, gnome_doc_utils
+, glib, dbus-glib, json-glib
+, gobjectIntrospection, vala_0_38, gnome-doc-utils
 , gtkVersion ? null, gtk2 ? null, gtk3 ? null }:
 
 with lib;
@@ -10,19 +10,19 @@ stdenv.mkDerivation rec {
   name = let postfix = if gtkVersion == null then "glib" else "gtk${gtkVersion}";
           in "libdbusmenu-${postfix}-${version}";
   version = "${versionMajor}.${versionMinor}";
-  versionMajor = "12.10";
-  versionMinor = "2";
+  versionMajor = "16.04";
+  versionMinor = "0";
 
   src = fetchurl {
     url = "${meta.homepage}/${versionMajor}/${version}/+download/libdbusmenu-${version}.tar.gz";
-    sha256 = "9d6ad4a0b918b342ad2ee9230cce8a095eb601cb0cee6ddc1122d0481f9d04c9";
+    sha256 = "12l7z8dhl917iy9h02sxmpclnhkdjryn08r8i4sr8l3lrlm4mk5r";
   };
 
   nativeBuildInputs = [ pkgconfig intltool ];
 
   buildInputs = [
-    glib dbus_glib json_glib
-    gobjectIntrospection vala_0_23 gnome_doc_utils
+    glib dbus-glib json-glib
+    gobjectIntrospection vala_0_38 gnome-doc-utils
   ] ++ optional (gtkVersion != null) (if gtkVersion == "2" then gtk2 else gtk3);
 
   postPatch = ''
@@ -49,10 +49,11 @@ stdenv.mkDerivation rec {
   installFlags = [
     "sysconfdir=\${out}/etc"
     "localstatedir=\${TMPDIR}"
+    "typelibdir=\${out}/lib/girepository-1.0"
   ];
 
   meta = {
-    description = "A library for passing menu structures across DBus";
+    description = "Library for passing menu structures across DBus";
     homepage = https://launchpad.net/dbusmenu;
     license = with licenses; [ gpl3 lgpl21 lgpl3 ];
     platforms = platforms.linux;
diff --git a/pkgs/development/libraries/libdevil/default.nix b/pkgs/development/libraries/libdevil/default.nix
index 20e74cdc1517..f88d20bee703 100644
--- a/pkgs/development/libraries/libdevil/default.nix
+++ b/pkgs/development/libraries/libdevil/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, libjpeg, libpng, libmng, lcms1, libtiff, openexr, mesa_noglu
+{ stdenv, fetchurl, libjpeg, libpng, libmng, lcms1, libtiff, openexr, libGL
 , libX11, pkgconfig, OpenGL
 }:
 
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
 
   outputs = [ "out" "dev" ];
 
-  buildInputs = [ libjpeg libpng libmng lcms1 libtiff openexr mesa_noglu libX11 ]
+  buildInputs = [ libjpeg libpng libmng lcms1 libtiff openexr libGL libX11 ]
     ++ stdenv.lib.optionals stdenv.isDarwin [ OpenGL ];
   nativeBuildInputs = [ pkgconfig ];
 
diff --git a/pkgs/development/libraries/libdigidocpp/default.nix b/pkgs/development/libraries/libdigidocpp/default.nix
index a8b2e4b34209..6ff8a03175e8 100644
--- a/pkgs/development/libraries/libdigidocpp/default.nix
+++ b/pkgs/development/libraries/libdigidocpp/default.nix
@@ -3,12 +3,12 @@
 
 stdenv.mkDerivation rec {
 
-  version = "3.12.0.1317";
+  version = "3.13.3.1365";
   name = "libdigidocpp-${version}";
 
   src = fetchurl {
-    url = "https://installer.id.ee/media/ubuntu/pool/main/libd/libdigidocpp/libdigidocpp_3.12.0.1317.orig.tar.xz";
-    sha256 = "8059e1dbab99f062d070b9da0b1334b7226f1ab9badcd7fddea3100519d1f9a9";
+    url = "https://installer.id.ee/media/ubuntu/pool/main/libd/libdigidocpp/libdigidocpp_3.13.3.1365.orig.tar.xz";
+    sha256 = "1xmvjh5xzspm6ja8hz6bzblwly7yn2jni2m6kx8ny9g65zjrj2iw";
   };
 
   unpackPhase = ''
diff --git a/pkgs/development/libraries/libdivecomputer/default.nix b/pkgs/development/libraries/libdivecomputer/default.nix
index 23ab36fe09f0..a09e48dcc1d9 100644
--- a/pkgs/development/libraries/libdivecomputer/default.nix
+++ b/pkgs/development/libraries/libdivecomputer/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libdivecomputer-${version}";
-  version = "0.5.0";
+  version = "0.6.0";
 
   src = fetchurl {
     url = "http://www.libdivecomputer.org/releases/${name}.tar.gz";
-    sha256 = "11n2qpqg4b2h7mqifp9qm5gm1aqwy7wj1j4j5ha0wdjf55zzy30y";
+    sha256 = "0nm1mcscpxb9dv4p0lidd6rf5xg4vmcbigj6zqxvgn7pwnvpbzm0";
   };
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/libdrm/default.nix b/pkgs/development/libraries/libdrm/default.nix
index 992b1ea70dca..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.84";
+  name = "libdrm-2.4.91";
 
   src = fetchurl {
     url = "http://dri.freedesktop.org/libdrm/${name}.tar.bz2";
-    sha256 = "7ae9c24d91139ac9a2cdee06fe46dbe1c401a1eda1c0bd2a6d1ecf72f479e0aa";
+    sha256 = "0068dn47c478vm1lyyhy02gilrpsma0xmcblhvs0dzqyrk80wjk3";
   };
 
   outputs = [ "out" "dev" "bin" ];
@@ -20,7 +20,8 @@ stdenv.mkDerivation rec {
     "echo : \\\${ac_cv_func_clock_gettime=\'yes\'} > config.cache";
 
   configureFlags = [ "--enable-install-test-programs" ]
-    ++ stdenv.lib.optionals (stdenv.isArm || stdenv.isAarch64) [ "--enable-tegra-experimental-api" "--enable-etnaviv-experimental-api" ]
+    ++ stdenv.lib.optionals (stdenv.isArm || stdenv.isAarch64)
+      [ "--enable-tegra-experimental-api" "--enable-etnaviv-experimental-api" ]
     ++ stdenv.lib.optional stdenv.isDarwin "-C";
 
   crossAttrs.configureFlags = configureFlags ++ [ "--disable-intel" ];
diff --git a/pkgs/development/libraries/libdvbpsi/default.nix b/pkgs/development/libraries/libdvbpsi/default.nix
index ecfa14a43c9a..0984eb6e00bf 100644
--- a/pkgs/development/libraries/libdvbpsi/default.nix
+++ b/pkgs/development/libraries/libdvbpsi/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libdvbpsi-${version}";
-  version = "0.2.2";
+  version = "1.3.2";
 
   src = fetchurl {
     url = "http://get.videolan.org/libdvbpsi/${version}/${name}.tar.bz2";
-    sha256 = "1lry2swxqm8mhq0a4rjnc819ngsf2pxnfjajb57lml7yr12j79ls";
+    sha256 = "1zn5hfv4qbahmydbwh59a3b480s3m5ss27r6ml35gqdip7r3jkmc";
   };
 
   meta = {
diff --git a/pkgs/development/libraries/libdvdcss/default.nix b/pkgs/development/libraries/libdvdcss/default.nix
index 63978cfd740f..66cb5215a8a9 100644
--- a/pkgs/development/libraries/libdvdcss/default.nix
+++ b/pkgs/development/libraries/libdvdcss/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "libdvdcss-${version}";
-  version = "1.4.0";
+  version = "1.4.1";
 
   buildInputs = stdenv.lib.optional stdenv.isDarwin IOKit;
 
   src = fetchurl {
     url = "http://get.videolan.org/libdvdcss/${version}/${name}.tar.bz2";
-    sha256 = "0nl45ifc4xcb196snv9d6hinfw614cqpzcqp92dg43c0hickg290";
+    sha256 = "1b7awvyahivglp7qmgx2g5005kc5npv257gw7wxdprjsnx93f1zb";
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libdvdnav/default.nix b/pkgs/development/libraries/libdvdnav/default.nix
index a26b927a883a..42321b2f866a 100644
--- a/pkgs/development/libraries/libdvdnav/default.nix
+++ b/pkgs/development/libraries/libdvdnav/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libdvdnav-${version}";
-  version = "5.0.3";
+  version = "6.0.0";
 
   src = fetchurl {
     url = "http://get.videolan.org/libdvdnav/${version}/${name}.tar.bz2";
-    sha256 = "5097023e3d2b36944c763f1df707ee06b19dc639b2b68fb30113a5f2cbf60b6d";
+    sha256 = "062njcksmpgw9yv3737qkf93r2pzhaxi9szqjabpa8d010dp38ph";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/libdvdread/default.nix b/pkgs/development/libraries/libdvdread/default.nix
index be7e20f00eb5..95815f4abcda 100644
--- a/pkgs/development/libraries/libdvdread/default.nix
+++ b/pkgs/development/libraries/libdvdread/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libdvdread-${version}";
-  version = "5.0.3";
+  version = "6.0.0";
 
   src = fetchurl {
     url = "http://get.videolan.org/libdvdread/${version}/${name}.tar.bz2";
-    sha256 = "0ayqiq0psq18rcp6f5pz82sxsq66v0kwv0y55dbrcg68plnxy71j";
+    sha256 = "0dgr23fzcjhb7ck54xkr9zmf4jcq3ph0dz3fbyvla1c6ni9ijfxk";
   };
 
   buildInputs = [libdvdcss];
diff --git a/pkgs/development/libraries/libdwarf/default.nix b/pkgs/development/libraries/libdwarf/default.nix
index 4bb91878bd35..6057dae4be2e 100644
--- a/pkgs/development/libraries/libdwarf/default.nix
+++ b/pkgs/development/libraries/libdwarf/default.nix
@@ -1,11 +1,13 @@
 { stdenv, fetchurl, libelf }:
 
 let
-  version = "20170709";
+  version = "20180129";
   src = fetchurl {
     url = "http://www.prevanders.net/libdwarf-${version}.tar.gz";
-    sha512 = "afff6716ef1af5d8aae2b887f36b9a6547fb576770bc6f630b82725ed1e59cbd"
-           + "387779aa729bbd1a5ae026a25ac76aacf64b038cd898b2419a8676f9aa8c59f1";
+    # Upstream displays this hash broken into three parts:
+    sha512 = "02f8024bb9959c91a1fe322459f7587a589d096595"
+           + "6d643921a173e6f9e0a184db7aef66f0fd2548d669"
+           + "5be7f9ee368f1cc8940cea4ddda01ff99d28bbf1fe58";
   };
   meta = {
     homepage = https://www.prevanders.net/dwarf.html;
diff --git a/pkgs/development/libraries/libdynd/default.nix b/pkgs/development/libraries/libdynd/default.nix
index 8deec094866c..93ece69cf056 100644
--- a/pkgs/development/libraries/libdynd/default.nix
+++ b/pkgs/development/libraries/libdynd/default.nix
@@ -15,6 +15,12 @@ stdenv.mkDerivation {
     "-DDYND_BUILD_BENCHMARKS=OFF"
   ];
 
+  # added to fix build with gcc7
+  NIX_CFLAGS_COMPILE = [
+    "-Wno-error=implicit-fallthrough"
+    "-Wno-error=nonnull"
+  ];
+
   buildInputs = [ cmake ];
 
   outputs = [ "out" "dev" ];
@@ -24,5 +30,6 @@ stdenv.mkDerivation {
     description = "C++ dynamic ndarray library, with Python exposure.";
     homepage = http://libdynd.org;
     license = licenses.bsd2;
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/libebur128/default.nix b/pkgs/development/libraries/libebur128/default.nix
index 8281036e7491..6a4078f92cf3 100644
--- a/pkgs/development/libraries/libebur128/default.nix
+++ b/pkgs/development/libraries/libebur128/default.nix
@@ -1,14 +1,14 @@
 { stdenv, fetchFromGitHub, cmake, speexdsp, pkgconfig }:
 
 stdenv.mkDerivation rec {
-  version = "1.0.2";
+  version = "1.2.4";
   name = "libebur128-${version}";
 
   src = fetchFromGitHub {
     owner = "jiixyj";
     repo = "libebur128";
     rev = "v${version}";
-    sha256 = "19vy3ldbf931hjvn9jf9dvw1di3yx9ljxyk2yp5cnac1wqiza3jm";
+    sha256 = "0n81rnm8dm1zmibkr2v3q79rsd609y0dbbsrbay18njcjva88p0g";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/libedit/default.nix b/pkgs/development/libraries/libedit/default.nix
index c61876713c10..154128144201 100644
--- a/pkgs/development/libraries/libedit/default.nix
+++ b/pkgs/development/libraries/libedit/default.nix
@@ -1,17 +1,17 @@
 { 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" ];
 
   # Have `configure' avoid `/usr/bin/nroff' in non-chroot builds.
-  NROFF = "${groff}/bin/nroff";
+  # NROFF = "${groff}/bin/nroff";
 
   patches = [ ./01-cygwin.patch ];
 
diff --git a/pkgs/development/libraries/libelf/default.nix b/pkgs/development/libraries/libelf/default.nix
index bd0d23bd0cdb..bb1dbe51765e 100644
--- a/pkgs/development/libraries/libelf/default.nix
+++ b/pkgs/development/libraries/libelf/default.nix
@@ -1,5 +1,5 @@
-{ stdenv, fetchurl
-, gettext, glibc
+{ stdenv
+, fetchurl, autoreconfHook, gettext
 , buildPlatform, hostPlatform
 }:
 
@@ -17,12 +17,20 @@ stdenv.mkDerivation rec {
 
   doCheck = true;
 
-  # Libelf's custom NLS macros fail to determine the catalog file extension on
-  # Darwin, so disable NLS for now.
-  # FIXME: Eventually make Gettext a build input on all platforms.
-  configureFlags = stdenv.lib.optional hostPlatform.isDarwin "--disable-nls";
-
-  nativeBuildInputs = [ gettext ];
+  configureFlags = []
+       # Configure check for dynamic lib support is broken, see
+       # http://lists.uclibc.org/pipermail/uclibc-cvs/2005-August/019383.html
+    ++ stdenv.lib.optional (hostPlatform != buildPlatform) "mr_cv_target_elf=yes"
+       # Libelf's custom NLS macros fail to determine the catalog file extension
+       # on Darwin, so disable NLS for now.
+    ++ stdenv.lib.optional hostPlatform.isDarwin "--disable-nls";
+
+  nativeBuildInputs = [ gettext ]
+       # Need to regenerate configure script with newer version in order to pass
+       # "mr_cv_target_elf=yes", but `autoreconfHook` brings in `makeWrapper`
+       # which doesn't work with the bootstrapTools bash, so can only do this
+       # for cross builds when `stdenv.shell` is a newer bash.
+    ++ stdenv.lib.optional (hostPlatform != buildPlatform) autoreconfHook;
 
   meta = {
     description = "ELF object file access library";
diff --git a/pkgs/development/libraries/libesmtp/default.nix b/pkgs/development/libraries/libesmtp/default.nix
new file mode 100644
index 000000000000..980cee2e6879
--- /dev/null
+++ b/pkgs/development/libraries/libesmtp/default.nix
@@ -0,0 +1,18 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "libESMTP-${version}";
+  version = "1.0.6";
+
+  src = fetchurl {
+    url = "http://brianstafford.info/libesmtp/libesmtp-1.0.6.tar.bz2";
+    sha256 = "02zbniyz7qys1jmx3ghx21kxmns1wc3hmv80gp7ag7yra9f1m9nh";
+  };
+
+  meta = with stdenv.lib; {
+    homepage = http://brianstafford.info/libesmtp/index.html;
+    description = "A Library for Posting Electronic Mail";
+    license = licenses.lgpl21;
+  };
+}
+
diff --git a/pkgs/development/libraries/libetpan/default.nix b/pkgs/development/libraries/libetpan/default.nix
index 063633619431..b09c2dd0f47e 100644
--- a/pkgs/development/libraries/libetpan/default.nix
+++ b/pkgs/development/libraries/libetpan/default.nix
@@ -1,6 +1,6 @@
 { autoconf, automake, fetchgit, libtool, stdenv, openssl }:
 
-let version = "1.6"; in
+let version = "1.8"; in
 
 stdenv.mkDerivation {
   name = "libetpan-${version}";
@@ -8,7 +8,7 @@ stdenv.mkDerivation {
   src = fetchgit {
     url = "git://github.com/dinhviethoa/libetpan";
     rev = "refs/tags/" + version;
-    sha256 = "13hv49271rr9yj7ifxqqmc0jfy1f26llivhp22s5wigick7qjxky";
+    sha256 = "09xqy1n18qn63x7idfrpwm59lfkvb1p5vxkyksywvy4f6mn4pyxk";
   };
 
   buildInputs = [ autoconf automake libtool openssl ];
diff --git a/pkgs/development/libraries/libevdev/default.nix b/pkgs/development/libraries/libevdev/default.nix
index 090a12f63de1..5bcb9a1ede22 100644
--- a/pkgs/development/libraries/libevdev/default.nix
+++ b/pkgs/development/libraries/libevdev/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, python }:
 
 stdenv.mkDerivation rec {
-  name = "libevdev-1.5.7";
+  name = "libevdev-1.5.8";
 
   src = fetchurl {
     url = "https://www.freedesktop.org/software/libevdev/${name}.tar.xz";
-    sha256 = "08nl3p6226k51zph52fhilxvi3b31spp6fz8szzrglzhl8vrxrd1";
+    sha256 = "0vac7n1miqdprikq4g63vsk681q8v416r0nbh2xai7b08qgdi0v0";
   };
 
   buildInputs = [ python ];
diff --git a/pkgs/development/libraries/libevent/default.nix b/pkgs/development/libraries/libevent/default.nix
index e14f4cbf5d63..871437f19082 100644
--- a/pkgs/development/libraries/libevent/default.nix
+++ b/pkgs/development/libraries/libevent/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, findutils
+{ stdenv, fetchurl, findutils, fixDarwinDylibNames
 , sslSupport? true, openssl
 }:
 
@@ -26,6 +26,7 @@ stdenv.mkDerivation rec {
   buildInputs = []
     ++ stdenv.lib.optional sslSupport openssl
     ++ stdenv.lib.optional stdenv.isCygwin findutils
+    ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames
     ;
 
   postInstall = stdenv.lib.optionalString sslSupport ''
diff --git a/pkgs/development/libraries/libewf/04-fix-FTBFS-GCC5.patch b/pkgs/development/libraries/libewf/04-fix-FTBFS-GCC5.patch
deleted file mode 100644
index 54878303589d..000000000000
--- a/pkgs/development/libraries/libewf/04-fix-FTBFS-GCC5.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-Patch from Debian:
-https://sources.debian.net/data/main/libe/libewf/20140608-6/debian/patches/04-fix-FTBFS-GCC5.patch
-
-Description: fix a FTBFS with GCC-5. Thanks to Linn Crosetto <linn@hp.com> for
-             the first fix (see #777938). This patch closes #777945.
-Author: Joao Eriberto Mota Filho <eriberto@debian.org>
-Last-Update: 2015-07-02
-Index: libewf-20140608/libuna/Makefile.am
-===================================================================
---- libewf-20140608.orig/libuna/Makefile.am
-+++ libewf-20140608/libuna/Makefile.am
-@@ -3,7 +3,7 @@ AM_CPPFLAGS = \
- 	-I$(top_srcdir)/include \
- 	-I$(top_srcdir)/common \
- 	@LIBCSTRING_CPPFLAGS@ \
--	@LIBCERROR_CPPFLAGS@
-+	@LIBCERROR_CPPFLAGS@ -std=gnu89
- 
- noinst_LTLIBRARIES = libuna.la
- 
diff --git a/pkgs/development/libraries/libewf/default.nix b/pkgs/development/libraries/libewf/default.nix
index ec53b50b5af2..b1a6238a3780 100644
--- a/pkgs/development/libraries/libewf/default.nix
+++ b/pkgs/development/libraries/libewf/default.nix
@@ -1,16 +1,16 @@
 { fetchurl, stdenv, zlib, openssl, libuuid, file, fuse, autoreconfHook, pkgconfig }:
 
 stdenv.mkDerivation rec {
-  version = "20140608";
+  version = "20171104";
   name = "libewf-${version}";
+
   src = fetchurl {
-    url = "https://googledrive.com/host/0B3fBvzttpiiSMTdoaVExWWNsRjg/libewf-20140608.tar.gz";
-    sha256 = "0wfsffzxk934hl8cpwr14w8ixnh8d23x0xnnzcspjwi2c7730h6i";
+    url = "https://github.com/libyal/libewf/releases/download/${version}/libewf-experimental-${version}.tar.gz";
+    sha256 = "0h7036gpj5cryvh17aq6i2cpnbpwg5yswmfydxbbwvd9yfxd6dng";
   };
 
-  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ zlib openssl libuuid ];
-  patches = [ ./04-fix-FTBFS-GCC5.patch ];
 
   meta = {
     description = "Library for support of the Expert Witness Compression Format";
diff --git a/pkgs/development/libraries/libewf/default.upstream b/pkgs/development/libraries/libewf/default.upstream
deleted file mode 100644
index a071132463f8..000000000000
--- a/pkgs/development/libraries/libewf/default.upstream
+++ /dev/null
@@ -1,7 +0,0 @@
-url https://code.google.com/p/libewf/
-version_link 'googledrive[.]com'
-version_link '[.]tar[.]'
-do_overwrite () {
-  do_overwrite_just_version
-  set_var_value url "$CURRENT_URL"
-}
diff --git a/pkgs/development/libraries/libexecinfo/default.nix b/pkgs/development/libraries/libexecinfo/default.nix
new file mode 100644
index 000000000000..a61d51aa6b72
--- /dev/null
+++ b/pkgs/development/libraries/libexecinfo/default.nix
@@ -0,0 +1,46 @@
+{ stdenv, fetchurl, fetchpatch }:
+
+stdenv.mkDerivation rec {
+  name = "libexecinfo-${version}";
+  version = "1.1";
+
+  src = fetchurl {
+    url = "http://distcache.freebsd.org/local-distfiles/itetcu/${name}.tar.bz2";
+    sha256 = "07wvlpc1jk1sj4k5w53ml6wagh0zm9kv2l1jngv8xb7xww9ik8n9";
+  };
+
+  patches = [
+    (fetchpatch {
+      name = "10-execinfo.patch";
+      url = https://git.alpinelinux.org/cgit/aports/plain/main/libexecinfo/10-execinfo.patch?id=730cdcef6901750f4029d4c3b8639ce02ee3ead1;
+      sha256 = "0lnphrad4vspyljnvmm62dyxj98vgp3wabj4w3vfzfph7j8piw7g";
+    })
+    (fetchpatch {
+      name = "20-define-gnu-source.patch";
+      url = https://git.alpinelinux.org/cgit/aports/plain/main/libexecinfo/20-define-gnu-source.patch?id=730cdcef6901750f4029d4c3b8639ce02ee3ead1;
+      sha256 = "1mp8mc639b0h2s69m5z6s2h3q3n1zl298j9j0plzj7f979j76302";
+    })
+    (fetchpatch {
+      name = "30-linux-makefile.patch";
+      url = https://git.alpinelinux.org/cgit/aports/plain/main/libexecinfo/30-linux-makefile.patch?id=730cdcef6901750f4029d4c3b8639ce02ee3ead1;
+      sha256 = "1jwjz22z5cjy5h2bfghn62yl9ar8jiqhdvbwrcfavv17ihbhwcaf";
+    })
+  ];
+
+  makeFlags = [ "CC:=$(CC)" "AR:=$(AR)" ];
+
+  patchFlags = "-p0";
+
+  installPhase = ''
+    install -Dm644 execinfo.h stacktraverse.h -t $out/include
+    install -Dm755 libexecinfo.{a,so.1} -t $out/lib
+    ln -s $out/lib/libexecinfo.so{.1,}
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Quick-n-dirty BSD licensed clone of the GNU libc backtrace facility";
+    license = licenses.bsd2;
+    homepage = https://www.freshports.org/devel/libexecinfo;
+    maintainers = with maintainers; [ dtzWill ];
+  };
+}
diff --git a/pkgs/development/libraries/libexif/default.nix b/pkgs/development/libraries/libexif/default.nix
index ebcba0fa1553..5a8f5126680e 100644
--- a/pkgs/development/libraries/libexif/default.nix
+++ b/pkgs/development/libraries/libexif/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, gettext }:
+{ stdenv, fetchurl, fetchpatch, gettext }:
 
 stdenv.mkDerivation rec {
   name = "libexif-0.6.21";
@@ -8,6 +8,15 @@ stdenv.mkDerivation rec {
     sha256 = "06nlsibr3ylfwp28w8f5466l6drgrnydgxrm4jmxzrmk5svaxk8n";
   };
 
+  patches = [
+   (fetchpatch {
+     name = "CVE-2017-7544.patch";
+     url = https://sourceforge.net/p/libexif/bugs/_discuss/thread/fc394c4b/489a/attachment/xx.pat;
+     sha256 = "1qgk8hgnxr8d63jsc4vljxz9yg33mbml280dq4a6050rmk9wq4la";
+   })
+  ];
+  patchFlags = "-p0";
+
   buildInputs = [ gettext ];
 
   meta = {
diff --git a/pkgs/development/libraries/libextractor/default.nix b/pkgs/development/libraries/libextractor/default.nix
index a6fb4ec515a8..81caa3e91acc 100644
--- a/pkgs/development/libraries/libextractor/default.nix
+++ b/pkgs/development/libraries/libextractor/default.nix
@@ -7,11 +7,11 @@ assert gtkSupport -> glib != null && gtk3 != null;
 assert videoSupport -> ffmpeg != null && libmpeg2 != null;
 
 stdenv.mkDerivation rec {
-  name = "libextractor-1.4";
+  name = "libextractor-1.6";
 
   src = fetchurl {
     url = "mirror://gnu/libextractor/${name}.tar.gz";
-    sha256 = "0v7ns5jhsyp1wzvbaydfgxnva5zd63gkzm9djhckmam9liq824l4";
+    sha256 = "17gnpgspdhfgcr27j8sn9105vb4lw22yqdrhic62l79q5v5avm16";
   };
 
   preConfigure =
diff --git a/pkgs/development/libraries/libexttextcat/default.nix b/pkgs/development/libraries/libexttextcat/default.nix
index a9b6394ed5ba..0ba703585bbb 100644
--- a/pkgs/development/libraries/libexttextcat/default.nix
+++ b/pkgs/development/libraries/libexttextcat/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "libexttextcat-3.4.1";
+  name = "libexttextcat-3.4.5";
 
   src = fetchurl {
     url = "http://dev-www.libreoffice.org/src/libexttextcat/${name}.tar.xz";
-    sha256 = "0g1spzpsfbv3y8k9m1v53imz18437q93iq101hind7m4x00j6wpl";
+    sha256 = "1j6sjwkyhqvsgyw938bxxfwkzzi1mahk66g5342lv6j89jfvrz8k";
   };
 
   meta = {
diff --git a/pkgs/development/libraries/libf2c/default.nix b/pkgs/development/libraries/libf2c/default.nix
index 78901e2f013e..2de407e8f639 100644
--- a/pkgs/development/libraries/libf2c/default.nix
+++ b/pkgs/development/libraries/libf2c/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl, unzip}:
 
 stdenv.mkDerivation rec {
-  name = "libf2c-20100903";
+  name = "libf2c-20160102";
 
   src = fetchurl {
     url = http://www.netlib.org/f2c/libf2c.zip;
-    sha256 = "1mcp1lh7gay7hm186dr0wvwd2bc05xydhnc1qy3dqs4n3r102g7i";
+    sha256 = "1q78y8j8xpl8zdzdxmn5ablss56hi5a7vz3idam9l2nfx5q40h6a";
   };
 
   unpackPhase = ''
diff --git a/pkgs/development/libraries/libfaketime/default.nix b/pkgs/development/libraries/libfaketime/default.nix
index c620254aacd6..cedd5f98027a 100644
--- a/pkgs/development/libraries/libfaketime/default.nix
+++ b/pkgs/development/libraries/libfaketime/default.nix
@@ -1,11 +1,12 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "libfaketime-0.9.6";
+  name = "libfaketime-${version}";
+  version = "0.9.7";
 
   src = fetchurl {
-    url = "http://www.code-wizards.com/projects/libfaketime/${name}.tar.gz";
-    sha256 = "1dw2lqsv2iqwxg51mdn25b4fjj3v357s0mc6ahxawqp210krg29s";
+    url = "https://github.com/wolfcw/libfaketime/archive/v${version}.tar.gz";
+    sha256 = "07l189881q0hybzmlpjyp7r5fwz23iafkm957bwy4gnmn9lg6rad";
   };
 
   patches = [
@@ -16,12 +17,9 @@ stdenv.mkDerivation rec {
     makeFlagsArray+=(PREFIX="$out" LIBDIRNAME=/lib)
   '';
 
-  # Work around "libfaketime.c:513:7: error: nonnull argument 'buf' compared to NULL [-Werror=nonnull-compare]".
-  NIX_CFLAGS_COMPILE = "-Wno-nonnull-compare";
-
   meta = with stdenv.lib; {
     description = "Report faked system time to programs without having to change the system-wide time";
-    homepage = http://www.code-wizards.com/projects/libfaketime/;
+    homepage = "https://github.com/wolfcw/libfaketime/";
     license = licenses.gpl2;
     platforms = platforms.all;
     maintainers = [ maintainers.bjornfor ];
diff --git a/pkgs/development/libraries/libffcall/default.nix b/pkgs/development/libraries/libffcall/default.nix
index c6482842cacd..513a4dc3d384 100644
--- a/pkgs/development/libraries/libffcall/default.nix
+++ b/pkgs/development/libraries/libffcall/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libffcall-${version}";
-  version = "2.0";
+  version = "2.1";
 
   src = fetchurl {
     url = "mirror://gnu/libffcall/libffcall-${version}.tar.gz";
-    sha256 = "0v0rh3vawb8z5q40fs3kr2f9zp06n2fq4rr2ww4562nr96sd5aj1";
+    sha256 = "0iwcad6w78jp84vd6xaz5fwqm84n3cb42bdf5m5cj5xzpa5zp4d0";
   };
 
   enableParallelBuilding = false;
diff --git a/pkgs/development/libraries/libffi/default.nix b/pkgs/development/libraries/libffi/default.nix
index e48db6c9928b..50cf8526c362 100644
--- a/pkgs/development/libraries/libffi/default.nix
+++ b/pkgs/development/libraries/libffi/default.nix
@@ -1,5 +1,5 @@
-{ fetchurl, stdenv, dejagnu, doCheck ? false
-, buildPlatform, hostPlatform
+{ stdenv, fetchurl, fetchpatch,  dejagnu, doCheck ? false
+, buildPlatform, hostPlatform, autoreconfHook
 }:
 
 stdenv.mkDerivation rec {
@@ -10,16 +10,40 @@ stdenv.mkDerivation rec {
     sha256 = "0dya49bnhianl0r65m65xndz6ls2jn1xngyn72gd28ls3n7bnvnh";
   };
 
-  patches = stdenv.lib.optional stdenv.isCygwin ./3.2.1-cygwin.patch ++
-    stdenv.lib.optional stdenv.isAarch64 (fetchurl {
+  patches = stdenv.lib.optional stdenv.isCygwin ./3.2.1-cygwin.patch
+    ++ stdenv.lib.optional stdenv.isAarch64 (fetchpatch {
       url = https://src.fedoraproject.org/rpms/libffi/raw/ccffc1700abfadb0969495a6e51b964117fc03f6/f/libffi-aarch64-rhbz1174037.patch;
       sha256 = "1vpirrgny43hp0885rswgv3xski8hg7791vskpbg3wdjdpb20wbc";
-    });
+    })
+    ++ stdenv.lib.optional hostPlatform.isMusl (fetchpatch {
+      name = "gnu-linux-define.patch";
+      url = "https://git.alpinelinux.org/cgit/aports/plain/main/libffi/gnu-linux-define.patch?id=bb024fd8ec6f27a76d88396c9f7c5c4b5800d580";
+      sha256 = "11pvy3xkhyvnjfyy293v51f1xjy3x0azrahv1nw9y9mw8bifa2j2";
+    })
+    ++ stdenv.lib.optional hostPlatform.isRiscV (fetchpatch {
+      name = "riscv-support.patch";
+      url = https://github.com/sorear/libffi-riscv/commit/e46492e8bb1695a19bc1053ed869e6c2bab02ff2.patch;
+      sha256 = "1vl1vbvdkigs617kckxvj8j4m2cwg62kxm1clav1w5rnw9afxg0y";
+    })
+    ++ stdenv.lib.optionals stdenv.isMips [
+      (fetchpatch {
+        name = "0001-mips-Use-compiler-internal-define-for-linux.patch";
+        url = "http://cgit.openembedded.org/openembedded-core/plain/meta/recipes-support/libffi/libffi/0001-mips-Use-compiler-internal-define-for-linux.patch?id=318e33a708378652edcf61ce7d9d7f3a07743000";
+        sha256 = "1gc53lw90p6hc0cmhj3csrwincfz7va5ss995ksw5gm0yrr9mrvb";
+      })
+      (fetchpatch {
+        name = "0001-mips-fix-MIPS-softfloat-build-issue.patch";
+        url = "http://cgit.openembedded.org/openembedded-core/plain/meta/recipes-support/libffi/libffi/0001-mips-fix-MIPS-softfloat-build-issue.patch?id=318e33a708378652edcf61ce7d9d7f3a07743000";
+        sha256 = "0l8xgdciqalg4z9rcwyk87h8fdxpfv4hfqxwsy2agpnpszl5jjdq";
+      })
+    ];
 
   outputs = [ "out" "dev" "man" "info" ];
 
   buildInputs = stdenv.lib.optional doCheck dejagnu;
 
+  nativeBuildInputs = stdenv.lib.optional hostPlatform.isRiscV autoreconfHook;
+
   configureFlags = [
     "--with-gcc-arch=generic" # no detection of -march= or -mtune=
     "--enable-pax_emutramp"
diff --git a/pkgs/development/libraries/libfilezilla/default.nix b/pkgs/development/libraries/libfilezilla/default.nix
index 5447e7d8b543..3b27ffc6d386 100644
--- a/pkgs/development/libraries/libfilezilla/default.nix
+++ b/pkgs/development/libraries/libfilezilla/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libfilezilla-${version}";
-  version = "0.11.0";
+  version = "0.12.1";
 
   src = fetchurl {
     url = "http://download.filezilla-project.org/libfilezilla/${name}.tar.bz2";
-    sha256 = "1l4yhw269dyarqb2spqhycxzzyfn8pj4qh9vfycdw1c93hj6fx6c";
+    sha256 = "1gbqm42dd0m3fvqz3bk53889479dvn8679zp6ba8a9q2br2wkvv0";
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libfixposix/default.nix b/pkgs/development/libraries/libfixposix/default.nix
index f56dc60771d6..2d2d56dda4f2 100644
--- a/pkgs/development/libraries/libfixposix/default.nix
+++ b/pkgs/development/libraries/libfixposix/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name="libfixposix-${version}";
-  version="0.4.1";
+  version="0.4.3";
 
   src = fetchFromGitHub {
     owner = "sionescu";
     repo = "libfixposix";
     rev = "v${version}";
-    sha256 = "19wjb43mn16f4lin5a2dfi3ym2hy7kqibs0z631d205b16vxas15";
+    sha256 = "1x4q6yspi5g2s98vq4qszw4z3zjgk9l5zs8471w4d4cs6l97w08j";
   };
 
   nativeBuildInputs = [ autoreconfHook pkgconfig ];
diff --git a/pkgs/development/libraries/libftdi/1.x.nix b/pkgs/development/libraries/libftdi/1.x.nix
index 353c82aa1935..d54b05b1c828 100644
--- a/pkgs/development/libraries/libftdi/1.x.nix
+++ b/pkgs/development/libraries/libftdi/1.x.nix
@@ -9,11 +9,11 @@ assert pythonSupport -> python != null && swig != null;
 assert docSupport -> doxygen != null;
 
 stdenv.mkDerivation rec {
-  name = "libftdi1-1.3";
+  name = "libftdi1-1.4";
 
   src = fetchurl {
     url = "http://www.intra2net.com/en/developer/libftdi/download/${name}.tar.bz2";
-    sha256 = "1x41mbzh4qy7mrv2n86r2cr176rx03iacn0a99c3dkzv9g4rb34s";
+    sha256 = "0x0vncf6i92slgrn0h7ghkskqbglbs534220qa84d0qg114zndpc";
   };
 
   nativeBuildInputs = [ pkgconfig ];
@@ -37,7 +37,7 @@ stdenv.mkDerivation rec {
     description = "A library to talk to FTDI chips using libusb";
     homepage = https://www.intra2net.com/en/developer/libftdi/;
     license = with licenses; [ lgpl2 gpl2 ];
-    platforms = platforms.linux;
+    platforms = with platforms; linux ++ darwin;
     maintainers = [ maintainers.bjornfor ];
   };
 }
diff --git a/pkgs/development/libraries/libftdi/default.nix b/pkgs/development/libraries/libftdi/default.nix
index 2f499d3af87f..f90e741a57e9 100644
--- a/pkgs/development/libraries/libftdi/default.nix
+++ b/pkgs/development/libraries/libftdi/default.nix
@@ -2,7 +2,7 @@
 
 stdenv.mkDerivation rec {
   name = "libftdi-0.20";
-  
+
   src = fetchurl {
     url = "http://www.intra2net.com/en/developer/libftdi/download/${name}.tar.gz";
     sha256 = "13l39f6k6gff30hsgh0wa2z422g9pyl91rh8a8zz6f34k2sxaxii";
@@ -14,11 +14,19 @@ stdenv.mkDerivation rec {
 
   # Hack to avoid TMPDIR in RPATHs.
   preFixup = ''rm -rf "$(pwd)" '';
+  configureFlags = [ "--with-async-mode" ];
+
+  # allow async mode. from ubuntu. see:
+  #   https://bazaar.launchpad.net/~ubuntu-branches/ubuntu/trusty/libftdi/trusty/view/head:/debian/patches/04_async_mode.diff
+  patchPhase = ''
+    substituteInPlace ./src/ftdi.c \
+      --replace "ifdef USB_CLASS_PTP" "if 0"
+  '';
 
   meta = {
     description = "A library to talk to FTDI chips using libusb";
     homepage = https://www.intra2net.com/en/developer/libftdi/;
     license = stdenv.lib.licenses.lgpl21;
-    platforms = stdenv.lib.platforms.unix;
+    platforms = stdenv.lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/libgap/default.nix b/pkgs/development/libraries/libgap/default.nix
index 9e0510debd02..dec9676d5729 100644
--- a/pkgs/development/libraries/libgap/default.nix
+++ b/pkgs/development/libraries/libgap/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl, gmp}:
 stdenv.mkDerivation rec {
   name = "libgap-${version}";
-  version = "4.8.3";
+  version = "4.8.6";
   # or fetchFromGitHub(owner,repo,rev) or fetchgit(rev)
   src = fetchurl {
     url = "http://mirrors.mit.edu/sage/spkg/upstream/libgap/libgap-${version}.tar.gz";
-    sha256 = "0ng4wlw7bj63spf4vkdp43v3ja1fp782lxzdsyf51x26z21idrsq";
+    sha256 = "1h5fx5a55857w583ql7ly2jl49qyx9mvs7j5abys00ra9gzrpn5v";
   };
   buildInputs = [gmp];
   meta = {
diff --git a/pkgs/development/libraries/libgcrypt/default.nix b/pkgs/development/libraries/libgcrypt/default.nix
index e32ba050c38f..6f36199bd1a5 100644
--- a/pkgs/development/libraries/libgcrypt/default.nix
+++ b/pkgs/development/libraries/libgcrypt/default.nix
@@ -1,14 +1,16 @@
-{ stdenv, fetchurl, libgpgerror, enableCapabilities ? false, libcap }:
+{ stdenv, fetchurl, gettext, libgpgerror, enableCapabilities ? false, libcap
+, buildPackages
+}:
 
 assert enableCapabilities -> stdenv.isLinux;
 
 stdenv.mkDerivation rec {
   name = "libgcrypt-${version}";
-  version = "1.8.1";
+  version = "1.8.2";
 
   src = fetchurl {
     url = "mirror://gnupg/libgcrypt/${name}.tar.bz2";
-    sha256 = "1cvqd9jk5qshbh48yh3ixw4zyr4n5k50r3475rrh20xfn7w7aa3s";
+    sha256 = "01sca9m8hm6b5v8hmqsfdjhyz013869p1f0fxw9ln52qfnp4q1n8";
   };
 
   outputs = [ "out" "dev" "info" ];
@@ -19,9 +21,19 @@ stdenv.mkDerivation rec {
   # The build enables -O2 by default for everything else.
   hardeningDisable = stdenv.lib.optional stdenv.cc.isClang "fortify";
 
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
+
   buildInputs = [ libgpgerror ]
+    ++ stdenv.lib.optional stdenv.isDarwin gettext
     ++ stdenv.lib.optional enableCapabilities libcap;
 
+  preConfigure = stdenv.lib.optionalString stdenv.isCross ''
+    # This is intentional: gpg-error-config is a shell script that will work during the build
+    mkdir -p "$NIX_BUILD_TOP"/bin
+    ln -s ${libgpgerror.dev}/bin/gpg-error-config "$NIX_BUILD_TOP/bin"
+    export PATH="$NIX_BUILD_TOP/bin:$PATH"
+  '';
+
   # Make sure libraries are correct for .pc and .la files
   # Also make sure includes are fixed for callers who don't use libgpgcrypt-config
   postFixup = ''
diff --git a/pkgs/development/libraries/libgee/0.6.nix b/pkgs/development/libraries/libgee/0.6.nix
deleted file mode 100644
index 51487b41573f..000000000000
--- a/pkgs/development/libraries/libgee/0.6.nix
+++ /dev/null
@@ -1,27 +0,0 @@
-{ stdenv, fetchurl, pkgconfig, glib }:
-
-let
-  ver_maj = "0.6";
-  ver_min = "8";
-in
-stdenv.mkDerivation rec {
-  name = "libgee-${ver_maj}.${ver_min}";
-
-  src = fetchurl {
-    url = "https://download.gnome.org/sources/libgee/${ver_maj}/${name}.tar.xz";
-    sha256 = "1lzmxgz1bcs14ghfp8qqzarhn7s64ayx8c508ihizm3kc5wqs7x6";
-  };
-
-  buildInputs = [ glib ];
-  nativeBuildInputs = [ pkgconfig ];
-
-  doCheck = true;
-
-  meta = with stdenv.lib; {
-    description = "Utility library providing GObject-based interfaces and classes for commonly used data structures";
-    license = licenses.lgpl21Plus;
-    platforms = platforms.linux;
-    homepage = http://live.gnome.org/Libgee;
-    maintainers = with maintainers; [ abbradar ];
-  };
-}
diff --git a/pkgs/development/libraries/libgee/0.8.nix b/pkgs/development/libraries/libgee/0.8.nix
deleted file mode 100644
index 747cb9d4b237..000000000000
--- a/pkgs/development/libraries/libgee/0.8.nix
+++ /dev/null
@@ -1,27 +0,0 @@
-{ stdenv, fetchurl, pkgconfig, glib }:
-
-let
-  ver_maj = "0.8";
-  ver_min = "6";
-in
-stdenv.mkDerivation rec {
-  name = "libgee-${ver_maj}.${ver_min}";
-
-  src = fetchurl {
-    url = "https://download.gnome.org/sources/libgee/${ver_maj}/${name}.tar.xz";
-    sha256 = "1mp3bfghc8qh2v8h2pfhksda22mgy2d5ygm1jr3bir544nr8i4fg";
-  };
-
-  buildInputs = [ glib ];
-  nativeBuildInputs = [ pkgconfig ];
-
-  doCheck = true;
-
-  meta = with stdenv.lib; {
-    description = "Utility library providing GObject-based interfaces and classes for commonly used data structures";
-    license = licenses.lgpl21Plus;
-    platforms = platforms.linux;
-    homepage = http://live.gnome.org/Libgee;
-    maintainers = with maintainers; [ sternenseemann ];
-  };
-}
diff --git a/pkgs/development/libraries/libgig/default.nix b/pkgs/development/libraries/libgig/default.nix
index 4adb7e535789..90d41e30502f 100644
--- a/pkgs/development/libraries/libgig/default.nix
+++ b/pkgs/development/libraries/libgig/default.nix
@@ -1,19 +1,21 @@
-{ stdenv, fetchsvn, autoconf, automake, libsndfile, libtool, pkgconfig, libuuid }:
+{ stdenv, fetchurl, autoconf, automake, libsndfile, libtool, pkgconfig, libuuid }:
 
 stdenv.mkDerivation rec {
-  name = "libgig-svn-${version}";
-  version = "2334";
+  name = "libgig-${version}";
+  version = "4.1.0";
 
-  src = fetchsvn {
-    url = "https://svn.linuxsampler.org/svn/libgig/trunk";
-    rev = "${version}";
-    sha256 = "0i7sj3zm6banl5avjdxblx0mlbxxzbsbr4x5hsl2fhrdsv5dnxhc";
+  src = fetchurl {
+    url = "http://download.linuxsampler.org/packages/${name}.tar.bz2";
+    sha256 = "02xx6bqxzgkvrawwnzrnxx1ypk244q4kpwfd58266f9ji8kq18h6";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ autoconf automake libsndfile libtool libuuid ];
+  nativeBuildInputs = [ autoconf automake libtool pkgconfig ];
 
-  preConfigure = "make -f Makefile.cvs";
+  buildInputs = [ libsndfile libuuid ];
+
+  preConfigure = "make -f Makefile.svn";
+
+  enableParallelBuilding = true;
 
   meta = with stdenv.lib; {
     homepage = http://www.linuxsampler.org;
diff --git a/pkgs/development/libraries/libgksu/default.nix b/pkgs/development/libraries/libgksu/default.nix
index 7bd551e70d56..652848d8a955 100644
--- a/pkgs/development/libraries/libgksu/default.nix
+++ b/pkgs/development/libraries/libgksu/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, pkgconfig, wrapGAppsHook, gtk2, gnome2, gnome3,
   libstartup_notification, libgtop, perl, perlXMLParser,
-  autoreconfHook, intltool, gtk_doc, docbook_xsl, xauth, sudo
+  autoreconfHook, intltool, docbook_xsl, xauth, sudo
 }:
 
 stdenv.mkDerivation rec {
@@ -14,12 +14,12 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [
-    pkgconfig autoreconfHook intltool gtk_doc docbook_xsl wrapGAppsHook
+    pkgconfig autoreconfHook intltool docbook_xsl wrapGAppsHook
   ];
 
   buildInputs = [
     gtk2 gnome2.GConf libstartup_notification
-    gnome3.libgnome_keyring libgtop gnome2.libglade perl perlXMLParser
+    gnome3.libgnome-keyring libgtop gnome2.libglade perl perlXMLParser
   ];
 
   enableParallelBuilding = true;
@@ -67,6 +67,10 @@ stdenv.mkDerivation rec {
     intltoolize --force --copy --automake
   '';
 
+  configureFlags = [
+    "--disable-gtk-doc"
+  ];
+
   meta = {
     description = "A library for integration of su into applications";
     longDescription = ''
diff --git a/pkgs/development/libraries/libglvnd/default.nix b/pkgs/development/libraries/libglvnd/default.nix
index cc285979c6c1..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, mesa_noglu, 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=\"${mesa_noglu.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 56bf9b177b56..2fcf6701ab8f 100644
--- a/pkgs/development/libraries/libgpg-error/default.nix
+++ b/pkgs/development/libraries/libgpg-error/default.nix
@@ -1,25 +1,53 @@
-{ stdenv, fetchurl, gettext }:
+{ stdenv, lib, fetchpatch, buildPackages, fetchurl, gettext
+, genPosixLockObjOnly ? false
+}: let
+  genPosixLockObjOnlyAttrs = lib.optionalAttrs genPosixLockObjOnly {
+    buildPhase = ''
+      cd src
+      make gen-posix-lock-obj
+    '';
+
+    installPhase = ''
+      mkdir -p $out/bin
+      install -m755 gen-posix-lock-obj $out/bin
+    '';
 
-stdenv.mkDerivation rec {
+    outputs = [ "out" ];
+    outputBin = "out";
+  };
+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";
   };
 
-  postPatch = "sed '/BUILD_TIMESTAMP=/s/=.*/=1970-01-01T00:01+0000/' -i ./configure";
+  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
+  '' + lib.optionalString stdenv.hostPlatform.isMusl ''
+    ln -s lock-obj-pub.x86_64-pc-linux-musl.h src/syscfg/lock-obj-pub.linux-musl.h
+  '';
 
   outputs = [ "out" "dev" "info" ];
   outputBin = "dev"; # deps want just the lib, most likely
 
   # If architecture-dependent MO files aren't available, they're generated
   # during build, so we need gettext for cross-builds.
-  crossAttrs.buildInputs = [ gettext ];
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
+  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
@@ -27,7 +55,7 @@ stdenv.mkDerivation rec {
     # Thus, re-run it with Bash.
       "${stdenv.shell} config.status";
 
-  doCheck = true;
+  doCheck = true; # not cross
 
   meta = with stdenv.lib; {
     homepage = https://www.gnupg.org/related_software/libgpg-error/index.html;
@@ -44,5 +72,4 @@ stdenv.mkDerivation rec {
     platforms = platforms.all;
     maintainers = [ maintainers.fuuzetsu maintainers.vrthra ];
   };
-}
-
+} // genPosixLockObjOnlyAttrs)
diff --git a/pkgs/development/libraries/libgphoto2/default.nix b/pkgs/development/libraries/libgphoto2/default.nix
index c498871956a8..9c0ea4a3a73e 100644
--- a/pkgs/development/libraries/libgphoto2/default.nix
+++ b/pkgs/development/libraries/libgphoto2/default.nix
@@ -7,7 +7,7 @@ stdenv.mkDerivation rec {
     owner = "gphoto";
     repo = "libgphoto2";
     rev = "${meta.tag}";
-    sha256 = "0chwnw3d2d1k8g4xidzkpy9f3ci30yz7yvxq1mipp2rbndl1y2am";
+    sha256 = "1svbpmxqm56pqkv0rxhlyk4vw7mjgjz8zz4p669qvmw630082yj9";
   };
 
   patches = [];
@@ -33,8 +33,8 @@ stdenv.mkDerivation rec {
       MTP, and other vendor specific protocols for controlling and transferring data
       from digital cameras.
     '';
-    version = "2.5.12";
-    tag = "libgphoto2-2_5_12-release";
+    version = "2.5.16";
+    tag = "libgphoto2-2_5_16-release";
     # XXX: the homepage claims LGPL, but several src files are lgpl21Plus
     license = stdenv.lib.licenses.lgpl21Plus;
     platforms = with stdenv.lib.platforms; unix;
diff --git a/pkgs/development/libraries/libgphoto2/default.upstream b/pkgs/development/libraries/libgphoto2/default.upstream
deleted file mode 100644
index 0029e6959306..000000000000
--- a/pkgs/development/libraries/libgphoto2/default.upstream
+++ /dev/null
@@ -1,9 +0,0 @@
-url http://sourceforge.net/projects/gphoto/files/libgphoto/
-SF_version_dir
-version_link '[.]tar[.]bz2/download$'
-SF_redirect
-do_overwrite () {
-  ensure_hash
-  set_var_value version "$CURRENT_VERSION"
-  set_var_value sha256 "$CURRENT_HASH"
-}
diff --git a/pkgs/development/libraries/libgringotts/default.nix b/pkgs/development/libraries/libgringotts/default.nix
index 1da6cffe3f2c..89fcfdfde8da 100644
--- a/pkgs/development/libraries/libgringotts/default.nix
+++ b/pkgs/development/libraries/libgringotts/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libgringotts-${version}";
-  version = "1.1.2";
+  version = "1.2.1";
 
   src = fetchurl {
-    url = "http://libgringotts.sourceforge.net/current/${name}.tar.bz2";
-    sha256 = "1bzfnpf2gwc2bisbrw06s63g9z9v4mh1n9ksqr6pbgj2prz7bvlk";
+    url = "https://sourceforge.net/projects/gringotts.berlios/files/${name}.tar.bz2";
+    sha256 = "1ldz1lyl1aml5ci1mpnys8dg6n7khpcs4zpycak3spcpgdsnypm7";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/libgroove/default.nix b/pkgs/development/libraries/libgroove/default.nix
index ac6c9d297cc3..bd5a5f068515 100644
--- a/pkgs/development/libraries/libgroove/default.nix
+++ b/pkgs/development/libraries/libgroove/default.nix
@@ -11,6 +11,8 @@ stdenv.mkDerivation rec {
     sha256 = "1la9d9kig50mc74bxvhx6hzqv0nrci9aqdm4k2j4q0s1nlfgxipd";
   };
 
+  patches = [ ./no-warnings-as-errors.patch ];
+
   buildInputs = [ cmake libav SDL2 chromaprint libebur128 ];
 
   meta = with stdenv.lib; {
@@ -18,6 +20,6 @@ stdenv.mkDerivation rec {
     homepage = https://github.com/andrewrk/libgroove;
     license = licenses.mit;
     platforms = platforms.unix;
-    maintainers = [ maintainers.andrewrk ];
+    maintainers = with maintainers; [ andrewrk ma27 ];
   };
 }
diff --git a/pkgs/development/libraries/libgroove/no-warnings-as-errors.patch b/pkgs/development/libraries/libgroove/no-warnings-as-errors.patch
new file mode 100644
index 000000000000..86a8a935769c
--- /dev/null
+++ b/pkgs/development/libraries/libgroove/no-warnings-as-errors.patch
@@ -0,0 +1,15 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index a1e8541..6bc9c30 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -135,8 +135,8 @@ configure_file (
+   "${PROJECT_BINARY_DIR}/config.h"
+   )
+ 
+-set(LIB_CFLAGS "${C99_C_FLAGS} -pedantic -Werror -Wall -Werror=strict-prototypes -Werror=old-style-definition -Werror=missing-prototypes -D_REENTRANT -D_POSIX_C_SOURCE=200809L")
+-set(EXAMPLE_CFLAGS "${C99_C_FLAGS} -pedantic -Werror -Wall -g")
++set(LIB_CFLAGS "${C99_C_FLAGS} -pedantic -Wall -Werror=strict-prototypes -Werror=old-style-definition -Werror=missing-prototypes -D_REENTRANT -D_POSIX_C_SOURCE=200809L")
++set(EXAMPLE_CFLAGS "${C99_C_FLAGS} -pedantic -Wall -g")
+ set(EXAMPLE_INCLUDES "${PROJECT_SOURCE_DIR}")
+ 
+ add_library(groove SHARED ${LIBGROOVE_SOURCES} ${LIBGROOVE_HEADERS})
diff --git a/pkgs/development/libraries/libgsf/default.nix b/pkgs/development/libraries/libgsf/default.nix
index 6e036522b1cb..b0013d0f9491 100644
--- a/pkgs/development/libraries/libgsf/default.nix
+++ b/pkgs/development/libraries/libgsf/default.nix
@@ -1,31 +1,28 @@
 { 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
 
 stdenv.mkDerivation rec {
-  name = "libgsf-1.14.41";
+  name = "libgsf-1.14.42";
 
   src = fetchurl {
     url    = "mirror://gnome/sources/libgsf/1.14/${name}.tar.xz";
-    sha256 = "1lq87wnrsjbjafpk3c8xwd56gqx319fhck9xkg2da88hd9c9h2qm";
+    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/libgssglue/default.nix b/pkgs/development/libraries/libgssglue/default.nix
new file mode 100644
index 000000000000..612946f73ed5
--- /dev/null
+++ b/pkgs/development/libraries/libgssglue/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl, kerberos }:
+
+stdenv.mkDerivation rec {
+  name = "libgssglue-0.4";
+
+  src = fetchurl {
+    url = "http://www.citi.umich.edu/projects/nfsv4/linux/libgssglue/${name}.tar.gz";
+    sha256 = "0fh475kxzlabwz30wz3bf7i8kfqiqzhfahayx3jj79rba1sily9z";
+  };
+
+  postPatch = ''
+    sed s:/etc/gssapi_mech.conf:$out/etc/gssapi_mech.conf: -i src/g_initialize.c
+  '';
+
+  postInstall = ''
+    mkdir -p $out/etc
+    cat <<EOF > $out/etc/gssapi_mech.conf
+    ${kerberos}/lib/libgssapi_krb5.so mechglue_internal_krb5_init
+    EOF
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://www.citi.umich.edu/projects/nfsv4/linux/;
+    description = "Exports a gssapi interface which calls other random gssapi libraries";
+    license = licenses.bsd3;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ corngood ];
+  };
+}
diff --git a/pkgs/development/libraries/libgsystem/default.nix b/pkgs/development/libraries/libgsystem/default.nix
index eaf2eb170956..e29b3ed89dea 100644
--- a/pkgs/development/libraries/libgsystem/default.nix
+++ b/pkgs/development/libraries/libgsystem/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, gtk_doc, gobjectIntrospection
+{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, gtk-doc, gobjectIntrospection
 , glib, attr, systemd
 }:
 
@@ -20,7 +20,7 @@ stdenv.mkDerivation {
   };
 
   nativeBuildInputs = [
-    autoreconfHook pkgconfig gtk_doc gobjectIntrospection
+    autoreconfHook pkgconfig gtk-doc gobjectIntrospection
   ];
 
   propagatedBuildInputs = [ glib attr systemd ];
diff --git a/pkgs/development/libraries/libgtop/default.nix b/pkgs/development/libraries/libgtop/default.nix
index 49cd1d163a60..656395b8867d 100644
--- a/pkgs/development/libraries/libgtop/default.nix
+++ b/pkgs/development/libraries/libgtop/default.nix
@@ -1,21 +1,29 @@
-{ stdenv, fetchurl, glib, pkgconfig, perl, intltool, gobjectIntrospection, libintlOrEmpty }:
+{ stdenv, fetchurl, glib, pkgconfig, perl, gettext, gobjectIntrospection, libintl, gnome3 }:
+let
+  pname = "libgtop";
+  version = "2.38.0";
+in
 stdenv.mkDerivation rec {
-  name = "libgtop-${version}";
-  major = "2.38";
-  version = "${major}.0";
+  name = "${pname}-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/libgtop/${major}/${name}.tar.xz";
+    url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
     sha256 = "04mnxgzyb26wqk6qij4iw8cxwl82r8pcsna5dg8vz2j3pdi0wv2g";
   };
 
   propagatedBuildInputs = [ glib ];
-  buildInputs = libintlOrEmpty;
-  nativeBuildInputs = [ pkgconfig perl intltool gobjectIntrospection ];
+  nativeBuildInputs = [ pkgconfig perl gettext gobjectIntrospection ];
 
-  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-lintl";
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+    };
+  };
 
-  meta = {
-    platforms = with stdenv.lib.platforms; linux ++ darwin;
+  meta = with stdenv.lib; {
+    description = "A library that reads information about processes and the running system";
+    license = licenses.gpl2Plus;
+    maintainers = gnome3.maintainers;
+    platforms = with platforms; linux ++ darwin;
   };
 }
diff --git a/pkgs/development/libraries/libgudev/default.nix b/pkgs/development/libraries/libgudev/default.nix
index a5f8f5036d04..1e1f3eeb4c73 100644
--- a/pkgs/development/libraries/libgudev/default.nix
+++ b/pkgs/development/libraries/libgudev/default.nix
@@ -1,11 +1,13 @@
-{ stdenv, fetchurl, pkgconfig, udev, glib }:
+{ stdenv, fetchurl, pkgconfig, udev, glib, gnome3 }:
 
-stdenv.mkDerivation rec {
+let
+  pname = "libgudev";
+in stdenv.mkDerivation rec {
   name = "libgudev-${version}";
   version = "232";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/libgudev/${version}/${name}.tar.xz";
+    url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
     sha256 = "ee4cb2b9c573cdf354f6ed744f01b111d4b5bed3503ffa956cefff50489c7860";
   };
 
@@ -15,9 +17,16 @@ stdenv.mkDerivation rec {
   # There's a dependency cycle with umockdev and the tests fail to LD_PRELOAD anyway.
   configureFlags = [ "--disable-umockdev" ];
 
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+      versionPolicy = "none";
+    };
+  };
+
   meta = with stdenv.lib; {
     homepage = https://wiki.gnome.org/Projects/libgudev;
-    maintainers = [ maintainers.eelco ];
+    maintainers = [ maintainers.eelco ] ++ gnome3.maintainers;
     platforms = platforms.linux;
     license = licenses.lgpl2Plus;
   };
diff --git a/pkgs/development/libraries/libguestfs/appliance.nix b/pkgs/development/libraries/libguestfs/appliance.nix
new file mode 100644
index 000000000000..d47b0902818d
--- /dev/null
+++ b/pkgs/development/libraries/libguestfs/appliance.nix
@@ -0,0 +1,7 @@
+{ fetchzip }:
+
+fetchzip {
+  name = "libguestfs-appliance-1.38.0";
+  url = "http://libguestfs.org/download/binaries/appliance/appliance-1.38.0.tar.xz";
+  sha256 = "15rxwj5qjflizxk7slpbrj9lcwkd2lgm52f5yv101qba4yyn3g76";
+}
diff --git a/pkgs/development/libraries/libguestfs/default.nix b/pkgs/development/libraries/libguestfs/default.nix
index bfdd0cf8fd74..106de68d367a 100644
--- a/pkgs/development/libraries/libguestfs/default.nix
+++ b/pkgs/development/libraries/libguestfs/default.nix
@@ -2,20 +2,20 @@
 , ncurses, cpio, gperf, perl, cdrkit, flex, bison, qemu, pcre, augeas, libxml2
 , acl, libcap, libcap_ng, libconfig, systemd, fuse, yajl, libvirt, hivex
 , gmp, readline, file, libintlperl, GetoptLong, SysVirt, numactl, xen, libapparmor
-, getopt, perlPackages, ocamlPackages }:
+, getopt, perlPackages, ocamlPackages
+, appliance ? null
+, javaSupport ? false, jdk ? null }:
+
+assert appliance == null || stdenv.lib.isDerivation appliance;
+assert javaSupport -> jdk != null;
 
 stdenv.mkDerivation rec {
   name = "libguestfs-${version}";
-  version = "1.36.3";
-
-  appliance = fetchurl {
-    url = "http://libguestfs.org/download/binaries/appliance/appliance-1.36.1.tar.xz";
-    sha256 = "1klvr13gpg615hgjvviwpxlj839lbwwsrq7x100qg5zmmjfhl125";
-  };
+  version = "1.38.0";
 
   src = fetchurl {
-    url = "http://libguestfs.org/download/1.36-stable/libguestfs-${version}.tar.gz";
-    sha256 = "0dhb69b7svjgnrmbyvizdz5vsgsrr95ypz0qvp3kz83jyj6sa76m";
+    url = "http://libguestfs.org/download/1.38-stable/libguestfs-${version}.tar.gz";
+    sha256 = "0cgapiad3x5ggwm097mq62hng3bv91p5gmrikrb6adfaasr1l6m3";
   };
 
   nativeBuildInputs = [ pkgconfig ];
@@ -24,7 +24,8 @@ stdenv.mkDerivation rec {
     cdrkit flex bison qemu pcre augeas libxml2 acl libcap libcap_ng libconfig
     systemd fuse yajl libvirt gmp readline file hivex libintlperl GetoptLong
     SysVirt numactl xen libapparmor getopt perlPackages.ModuleBuild
-  ] ++ (with ocamlPackages; [ ocaml findlib ocamlbuild ocaml_libvirt ocaml_gettext ounit ]);
+  ] ++ (with ocamlPackages; [ ocaml findlib ocamlbuild ocaml_libvirt ocaml_gettext ounit ])
+    ++ stdenv.lib.optional javaSupport jdk;
 
   prePatch = ''
     # build-time scripts
@@ -40,7 +41,8 @@ stdenv.mkDerivation rec {
     # some scripts hardcore /usr/bin/env which is not available in the build env
     patchShebangs .
   '';
-  configureFlags = "--disable-appliance --disable-daemon";
+  configureFlags = [ "--disable-appliance" "--disable-daemon" "--with-distro=NixOS" ]
+    ++ stdenv.lib.optionals (!javaSupport) [ "--disable-java" "--without-java" ];
   patches = [ ./libguestfs-syms.patch ];
   NIX_CFLAGS_COMPILE="-I${libxml2.dev}/include/libxml2/";
   installFlags = "REALLY_INSTALL=yes";
@@ -49,14 +51,31 @@ stdenv.mkDerivation rec {
   postInstall = ''
     for bin in $out/bin/*; do
       wrapProgram "$bin" \
-        --prefix "PATH" : "$out/bin:${hivex}/bin:${qemu}/bin" \
-        --prefix "PERL5LIB" : "$PERL5LIB:$out/lib/perl5/site_perl"
+        --prefix PATH     : "$out/bin:${hivex}/bin:${qemu}/bin" \
+        --prefix PERL5LIB : "$out/lib/perl5/site_perl"
     done
   '';
 
-  postFixup = ''
-    mkdir -p "$out/lib/guestfs"
-    tar -Jxvf "$appliance" --strip 1 -C "$out/lib/guestfs"
+  postFixup = stdenv.lib.optionalString (appliance != null) ''
+    mkdir -p $out/{lib,lib64}
+    ln -s ${appliance} $out/lib64/guestfs
+    ln -s ${appliance} $out/lib/guestfs
+  '';
+
+  doInstallCheck = appliance != null;
+  installCheckPhase = ''
+    export HOME=$(mktemp -d) # avoid access to /homeless-shelter/.guestfish
+
+    ${qemu}/bin/qemu-img create -f qcow2 disk1.img 10G
+
+    $out/bin/guestfish <<'EOF'
+    add-drive disk1.img
+    run
+    list-filesystems
+    part-disk /dev/sda mbr
+    mkfs ext2 /dev/sda1
+    list-filesystems
+    EOF
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libhttpseverywhere/default.nix b/pkgs/development/libraries/libhttpseverywhere/default.nix
index 88a3ebbc4fbe..6af3f5225d4d 100644
--- a/pkgs/development/libraries/libhttpseverywhere/default.nix
+++ b/pkgs/development/libraries/libhttpseverywhere/default.nix
@@ -1,29 +1,41 @@
-{stdenv, fetchurl, gnome3, glib, json_glib, libxml2, libarchive, libsoup, gobjectIntrospection, meson, ninja, pkgconfig,  valadoc}:
+{ stdenv, fetchurl, pkgconfig, meson, ninja, makeFontsConf
+, gnome3, glib, json-glib, libarchive, libsoup, gobjectIntrospection }:
 
-stdenv.mkDerivation rec {
-  major = "0.4";
-  minor = "5";
-  version = "${major}.${minor}";
-
-  name = "libhttpseverywhere-${version}";
+let
+  pname = "libhttpseverywhere";
+  version = "0.8.2";
+in stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/libhttpseverywhere/${major}/libhttpseverywhere-${version}.tar.xz";
-    sha256 = "07sgcw285rl9wqr5k7srs3fj7fhgrrw6w780jx8wy8jw2bfwlvj2";
+    url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
+    sha256 = "0vcnimlfcscyvjbh845xbnjb9qc8x0mliaqz2gczxxpakxrbl3gh";
   };
 
-  nativeBuildInputs = [ gnome3.vala valadoc  gobjectIntrospection meson ninja pkgconfig ];
-  buildInputs = [ glib gnome3.libgee libxml2 json_glib libsoup libarchive ];
+  nativeBuildInputs = [ gnome3.vala gobjectIntrospection meson ninja pkgconfig ];
+  buildInputs = [ glib gnome3.libgee json-glib libsoup libarchive ];
+
+  mesonFlags = [ "-Denable_valadoc=true" ];
 
   doCheck = true;
 
-  checkPhase = "./httpseverywhere_test";
+  checkPhase = "(cd test && ./httpseverywhere_test)";
+
+  FONTCONFIG_FILE = makeFontsConf { fontDirectories = [ ]; };
+
+  outputs = [ "out" "devdoc" ];
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+    };
+  };
 
-  meta = {
-    description = "library to use HTTPSEverywhere in desktop applications";
-    homepage    = https://git.gnome.org/browse/libhttpseverywhere;
-    license     = stdenv.lib.licenses.lgpl3;
-    platforms   = stdenv.lib.platforms.linux;
-    maintainers = with stdenv.lib.maintainers; [ sternenseemann ];
+  meta = with stdenv.lib; {
+    description = "Library to use HTTPSEverywhere in desktop applications";
+    homepage = https://git.gnome.org/browse/libhttpseverywhere;
+    license = licenses.lgpl3;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ sternenseemann ] ++ gnome3.maintainers;
   };
 }
diff --git a/pkgs/development/libraries/libiberty/default.nix b/pkgs/development/libraries/libiberty/default.nix
index 1f5ab2cf0969..516e6bbbe88c 100644
--- a/pkgs/development/libraries/libiberty/default.nix
+++ b/pkgs/development/libraries/libiberty/default.nix
@@ -1,15 +1,20 @@
-{ stdenv, lib, fetchurl, gcc, staticBuild ? false }:
+{ stdenv, buildPackages, fetchurl, staticBuild ? false }:
+
+let inherit (buildPackages.buildPackages) gcc; in
 
 stdenv.mkDerivation rec {
   name = "libiberty-${gcc.cc.version}";
 
   inherit (gcc.cc) src;
 
+  outputs = [ "out" "dev" ];
+
   postUnpack = "sourceRoot=\${sourceRoot}/libiberty";
 
-  configureFlags = [ "--enable-install-libiberty" ] ++ lib.optional (!staticBuild) "--enable-shared";
+  configureFlags = [ "--enable-install-libiberty" ]
+    ++ stdenv.lib.optional (!staticBuild) "--enable-shared";
 
-  postInstall = lib.optionalString (!staticBuild) ''
+  postInstall = stdenv.lib.optionalString (!staticBuild) ''
     cp pic/libiberty.a $out/lib*/libiberty.a
   '';
 
@@ -17,7 +22,7 @@ stdenv.mkDerivation rec {
     homepage = http://gcc.gnu.org/;
     license = licenses.lgpl2;
     description = "Collection of subroutines used by various GNU programs";
-    maintainers = with maintainers; [ abbradar ];
+    maintainers = with maintainers; [ abbradar ericson2314 ];
     platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/libiconv/default.nix b/pkgs/development/libraries/libiconv/default.nix
index 899465124100..a4e6fed88e1c 100644
--- a/pkgs/development/libraries/libiconv/default.nix
+++ b/pkgs/development/libraries/libiconv/default.nix
@@ -1,8 +1,9 @@
 { fetchurl, stdenv, lib
 , buildPlatform, hostPlatform
+, enableStatic ? stdenv.hostPlatform.useAndroidPrebuilt
 }:
 
-assert !stdenv.isLinux || hostPlatform != buildPlatform; # TODO: improve on cross
+# assert !stdenv.isLinux || hostPlatform != buildPlatform; # TODO: improve on cross
 
 stdenv.mkDerivation rec {
   name = "libiconv-${version}";
@@ -13,20 +14,16 @@ stdenv.mkDerivation rec {
     sha256 = "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc";
   };
 
+  setupHook = ./setup-hook.sh;
+
   postPatch =
     lib.optionalString ((hostPlatform != buildPlatform && hostPlatform.libc == "msvcrt") || stdenv.cc.nativeLibc)
       ''
         sed '/^_GL_WARN_ON_USE (gets/d' -i srclib/stdio.in.h
       '';
 
-  configureFlags =
-    lib.optional stdenv.isFreeBSD "--with-pic";
-
-  crossAttrs = {
-    # Disable stripping to avoid "libiconv.a: Archive has no index" (MinGW).
-    dontStrip = true;
-    dontCrossStrip = true;
-  };
+  configureFlags = lib.optional stdenv.isFreeBSD "--with-pic"
+    ++ lib.optional enableStatic "--enable-static";
 
   meta = {
     description = "An iconv(3) implementation";
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/libidn/default.nix b/pkgs/development/libraries/libidn/default.nix
index df92693de5a6..54d669f1913b 100644
--- a/pkgs/development/libraries/libidn/default.nix
+++ b/pkgs/development/libraries/libidn/default.nix
@@ -10,7 +10,8 @@ stdenv.mkDerivation rec {
 
   outputs = [ "bin" "dev" "out" "info" "devdoc" ];
 
-  doCheck = (stdenv.buildPlatform == stdenv.hostPlatform) && !stdenv.isDarwin;
+  # broken with gcc-7
+  #doCheck = !stdenv.isDarwin && !stdenv.hostPlatform.isMusl;
 
   hardeningDisable = [ "format" ];
 
diff --git a/pkgs/development/libraries/libidn2/default.nix b/pkgs/development/libraries/libidn2/default.nix
index 521fe00b56d7..46cb579c56c4 100644
--- a/pkgs/development/libraries/libidn2/default.nix
+++ b/pkgs/development/libraries/libidn2/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, libiconv, libunistring, help2man, ronn }:
+{ fetchurl, stdenv, libiconv, libunistring, help2man, ronn, buildPackages }:
 
 with stdenv.lib;
 
@@ -15,8 +15,9 @@ stdenv.mkDerivation rec {
 
   patches = optional stdenv.isDarwin ./fix-error-darwin.patch;
 
-  buildInputs = [ libunistring ronn ]
-    ++ optionals stdenv.isDarwin [ libiconv help2man ];
+  nativeBuildInputs = optional stdenv.isDarwin help2man;
+  buildInputs = [ libunistring ] ++ optional stdenv.isDarwin libiconv;
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
 
   meta = {
     homepage = "https://www.gnu.org/software/libidn/#libidn2";
diff --git a/pkgs/development/libraries/libimobiledevice/default.nix b/pkgs/development/libraries/libimobiledevice/default.nix
index cef9cc0af6b2..d1b779627c69 100644
--- a/pkgs/development/libraries/libimobiledevice/default.nix
+++ b/pkgs/development/libraries/libimobiledevice/default.nix
@@ -10,7 +10,8 @@ stdenv.mkDerivation rec {
 
   patches = [
     ./disable_sslv3.patch
-    (fetchpatch { # CVE-2016-5104
+    (fetchpatch {
+      name = "CVE-2016-5104.patch";
       url = "https://github.com/libimobiledevice/libimobiledevice/commit/df1f5c4d70d0c19ad40072f5246ca457e7f9849e.patch";
       sha256 = "06ygb9aqcvm4v08wrldsddjgyqv5bkpq6lxzq2a1nwqp9mq4a4k1";
     })
diff --git a/pkgs/development/libraries/libindicate/default.nix b/pkgs/development/libraries/libindicate/default.nix
index 9f75f17caeed..445a505b68c8 100644
--- a/pkgs/development/libraries/libindicate/default.nix
+++ b/pkgs/development/libraries/libindicate/default.nix
@@ -2,9 +2,9 @@
 
 { stdenv, fetchurl, lib, file
 , pkgconfig, autoconf
-, glib, dbus_glib, libdbusmenu-glib
+, glib, dbus-glib, libdbusmenu-glib
 , gtkVersion, gtk2 ? null, gtk3 ? null
-, pythonPackages, gobjectIntrospection, vala_0_23, gnome_doc_utils
+, pythonPackages, gobjectIntrospection, vala, gnome-doc-utils
 , monoSupport ? false, mono ? null, gtk-sharp-2_0 ? null
  }:
 
@@ -24,11 +24,11 @@ in stdenv.mkDerivation rec {
     sha256 = "10am0ymajx633b33anf6b79j37k61z30v9vaf5f9fwk1x5cw1q21";
   };
 
-  nativeBuildInputs = [ pkgconfig autoconf ];
+  nativeBuildInputs = [ pkgconfig autoconf gobjectIntrospection vala gnome-doc-utils ];
 
   buildInputs = [
-    glib dbus_glib libdbusmenu-glib
-    python pygobject2 pygtk gobjectIntrospection vala_0_23 gnome_doc_utils
+    glib dbus-glib libdbusmenu-glib
+    python pygobject2 pygtk
   ] ++ (if gtkVersion == "2"
     then [ gtk2 ] ++ optionals monoSupport [ mono gtk-sharp-2_0 ]
     else [ gtk3 ]);
diff --git a/pkgs/development/libraries/libinfinity/default.nix b/pkgs/development/libraries/libinfinity/default.nix
index 835c7d6f2262..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;
@@ -12,21 +12,21 @@ let
 
 in stdenv.mkDerivation rec {
 
-  name = "libinfinity-0.6.5";
+  name = "libinfinity-0.7.1";
   src = fetchurl {
     url = "http://releases.0x539.de/libinfinity/${name}.tar.gz";
-    sha256 = "1idsxb6rz4i55g3vi2sv7hmm57psbccpb57yc4jgphaq6ydgqsr6";
+    sha256 = "1jw2fhrcbpyz99bij07iyhy9ffyqdn87vl8cb1qz897y3f2f0vk2";
   };
 
   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/libinput/default.nix b/pkgs/development/libraries/libinput/default.nix
index d39a71e16da9..0e2458a38959 100644
--- a/pkgs/development/libraries/libinput/default.nix
+++ b/pkgs/development/libraries/libinput/default.nix
@@ -16,11 +16,11 @@ in
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "libinput-${version}";
-  version = "1.9.1";
+  version = "1.10.0";
 
   src = fetchurl {
     url = "http://www.freedesktop.org/software/libinput/${name}.tar.xz";
-    sha256 = "1y3559146zlfizncky1jlly226i66vwikxhpdkw0jg8v47j0sy7h";
+    sha256 = "0mrzsf0349d1g68lizkzxw7vaw459fl8xhl7v0s8njb31hp2riy2";
   };
 
   outputs = [ "out" "dev" ];
@@ -50,8 +50,6 @@ stdenv.mkDerivation rec {
 
   doCheck = testsSupport;
 
-  checkPhase = "meson test";
-
   meta = {
     description = "Handles input devices in Wayland compositors and provides a generic X.Org input driver";
     homepage    = http://www.freedesktop.org/wiki/Software/libinput;
diff --git a/pkgs/development/libraries/libiodbc/default.nix b/pkgs/development/libraries/libiodbc/default.nix
index 267d3097c997..738c11161955 100644
--- a/pkgs/development/libraries/libiodbc/default.nix
+++ b/pkgs/development/libraries/libiodbc/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, pkgconfig, gtk2, useGTK ? false }:
 
 stdenv.mkDerivation rec {
-  name = "libiodbc-3.52.8";
+  name = "libiodbc-3.52.12";
 
   src = fetchurl {
     url = "mirror://sourceforge/iodbc/${name}.tar.gz";
-    sha256 = "16hjb6fcval85gnkgkxfhw4c5h3pgf86awyh8p2bhnnvzc0ma5hq";
+    sha256 = "0qpvklgr1lcn5g8xbz7fbc9rldqf9r8s6xybhqj20m4sglxgziai";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/libisoburn/default.nix b/pkgs/development/libraries/libisoburn/default.nix
index e113d62c5f7d..6e7764176091 100644
--- a/pkgs/development/libraries/libisoburn/default.nix
+++ b/pkgs/development/libraries/libisoburn/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libisoburn-${version}";
-  version = "1.4.4";
+  version = "1.4.8";
 
   src = fetchurl {
     url = "http://files.libburnia-project.org/releases/${name}.tar.gz";
-    sha256 = "1mn2dwkwdrdcjnd59czxali7r5nlxdx92clyxnsfpmw20f9s20kv";
+    sha256 = "19d53j17pn18vfxxqqlqwam5lm21ljyp8nai5434068g7x3m1kwi";
   };
 
   buildInputs = [ attr zlib libburn libisofs ];
diff --git a/pkgs/development/libraries/libisofs/default.nix b/pkgs/development/libraries/libisofs/default.nix
index a0205fb234ca..d0217a908b9f 100644
--- a/pkgs/development/libraries/libisofs/default.nix
+++ b/pkgs/development/libraries/libisofs/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libisofs-${version}";
-  version = "1.4.6";
+  version = "1.4.8";
 
   src = fetchurl {
     url = "http://files.libburnia-project.org/releases/${name}.tar.gz";
-    sha256 = "02m5g6lbmmkh2xc5xzq5zaf3ma6v31gls66aj886b3cq9qw0paql";
+    sha256 = "0scvqb72qq24wcg814p1iw1dknldl21hr1hxsc1wy9vc6vgyk7fw";
   };
 
   buildInputs = [ attr zlib ];
diff --git a/pkgs/development/libraries/libite/default.nix b/pkgs/development/libraries/libite/default.nix
index 479deb7593d6..51a7ab4851c3 100644
--- a/pkgs/development/libraries/libite/default.nix
+++ b/pkgs/development/libraries/libite/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "libite-${version}";
-  version = "1.9.2";
+  version = "2.0.1";
 
   src = fetchFromGitHub {
     owner = "troglobit";
     repo = "libite";
     rev = "v${version}";
-    sha256 = "1y2iylsgs8am5br7an0xkrgshq6k2zkk8jfsaa7vdw2dh3qvc9pr";
+    sha256 = "07zypi3f02ygl7h5yc9sy136iiwgdi3r3nkjai9bq4gzjmzsvyl9";
   };
 
   nativeBuildInputs = [ autoreconfHook pkgconfig ];
diff --git a/pkgs/development/libraries/libivykis/default.nix b/pkgs/development/libraries/libivykis/default.nix
index eac919612f0b..ed595505fae1 100644
--- a/pkgs/development/libraries/libivykis/default.nix
+++ b/pkgs/development/libraries/libivykis/default.nix
@@ -3,11 +3,11 @@
 stdenv.mkDerivation rec {
   name = "libivykis-${version}";
 
-  version = "0.41";
+  version = "0.42.1";
 
   src = fetchurl {
     url = "mirror://sourceforge/libivykis/${version}/ivykis-${version}.tar.gz";
-    sha256 = "1igk3svf36i5xgb6ipc507xpj6zjm4xi9j1j2cdqaachllwlb4rc";
+    sha256 = "0c90cfpxipw2m8i3ajr7vy7lb8gvcz2kh5n8sd542zphr4na8whq";
   };
 
   nativeBuildInputs = [ autoreconfHook pkgconfig ];
diff --git a/pkgs/development/libraries/libjpeg-turbo/default.nix b/pkgs/development/libraries/libjpeg-turbo/default.nix
index 77f9d999de44..4ec0e5ebd9f4 100644
--- a/pkgs/development/libraries/libjpeg-turbo/default.nix
+++ b/pkgs/development/libraries/libjpeg-turbo/default.nix
@@ -4,11 +4,11 @@
 
 stdenv.mkDerivation rec {
   name = "libjpeg-turbo-${version}";
-  version = "1.5.2";
+  version = "1.5.3";
 
   src = fetchurl {
     url = "mirror://sourceforge/libjpeg-turbo/${name}.tar.gz";
-    sha256 = "0a5m0psfp5952y5vrcs0nbdz1y9wqzg2ms0xwrx752034wxr964h";
+    sha256 = "08r5b5mywwrxv4axvq80dm31cklz81grczlzlxr2xqa6pgi90j5j";
   }; # github releases still need autotools, surprisingly
 
   patches =
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  doCheck = stdenv.buildPlatform == stdenv.hostPlatform;
+  doCheck = true; # not cross;
   checkTarget = "test";
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libjson-rpc-cpp/default.nix b/pkgs/development/libraries/libjson-rpc-cpp/default.nix
index 7c0bc358ea9c..87cae2246852 100644
--- a/pkgs/development/libraries/libjson-rpc-cpp/default.nix
+++ b/pkgs/development/libraries/libjson-rpc-cpp/default.nix
@@ -34,7 +34,7 @@ stdenv.mkDerivation rec {
              -DCMAKE_BUILD_TYPE=Release
   '';
 
-  installPhase = '' 
+  installPhase = ''
     mkdir -p $out
 
     function fixRunPath {
@@ -56,6 +56,8 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ cmake jsoncpp argtable curl libmicrohttpd doxygen catch ];
 
+  enableParallelBuilding = true;
+
   meta = with stdenv.lib; {
     description = "C++ framework for json-rpc (json remote procedure call)";
     homepage = https://github.com/cinemast/libjson-rpc-cpp;
diff --git a/pkgs/development/libraries/libkate/default.nix b/pkgs/development/libraries/libkate/default.nix
index 77f047b4c586..6c7e5881a784 100644
--- a/pkgs/development/libraries/libkate/default.nix
+++ b/pkgs/development/libraries/libkate/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, libogg, libpng }:
 
 stdenv.mkDerivation rec {
-  name = "libkate-0.3.8";
+  name = "libkate-0.4.1";
 
   src = fetchurl {
     url = "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/libkate/${name}.tar.gz";
-    sha256 = "00d6561g31la9bb8q99b7l4rvi67yiwm50ky8dhlsjd88h7rks2n";
+    sha256 = "0s3vr2nxfxlf1k75iqpp4l78yf4gil3f0v778kvlngbchvaq23n4";
   };
 
   buildInputs = [ libogg libpng ];
diff --git a/pkgs/development/libraries/libkeyfinder/default.nix b/pkgs/development/libraries/libkeyfinder/default.nix
index 326d9c4f9d78..93f3b2a4f84d 100644
--- a/pkgs/development/libraries/libkeyfinder/default.nix
+++ b/pkgs/development/libraries/libkeyfinder/default.nix
@@ -34,6 +34,5 @@ stdenv.mkDerivation rec {
     homepage = http://www.ibrahimshaath.co.uk/keyfinder/;
     license = licenses.gpl3Plus;
     platforms = platforms.linux;
-    maintainers = with maintainers; [ nckx ];
   };
 }
diff --git a/pkgs/development/libraries/libksba/default.nix b/pkgs/development/libraries/libksba/default.nix
index 8bff5a21cd09..0611e0e57e7b 100644
--- a/pkgs/development/libraries/libksba/default.nix
+++ b/pkgs/development/libraries/libksba/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, libgpgerror }:
+{ stdenv, fetchurl, gettext, libgpgerror }:
 
 stdenv.mkDerivation rec {
   name = "libksba-1.3.5";
@@ -10,6 +10,7 @@ stdenv.mkDerivation rec {
 
   outputs = [ "out" "dev" "info" ];
 
+  buildInputs = [ gettext ];
   propagatedBuildInputs = [ libgpgerror ];
 
   postInstall = ''
diff --git a/pkgs/development/libraries/liblcf/default.nix b/pkgs/development/libraries/liblcf/default.nix
new file mode 100644
index 000000000000..95b6b657fa2b
--- /dev/null
+++ b/pkgs/development/libraries/liblcf/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, expat, icu }:
+
+stdenv.mkDerivation rec {
+  name = "liblcf-${version}";
+  version = "0.5.3";
+
+  src = fetchFromGitHub {
+    owner = "EasyRPG";
+    repo = "liblcf";
+    rev = version;
+    sha256 = "1y3pbl3jxan9f0cb1rxkibqjc0h23jm3jlwlv0xxn2pgw8l0fk34";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ expat icu ];
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/EasyRPG/liblcf;
+    license = licenses.mit;
+    maintainers = with maintainers; [ yegortimoshenko ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/liblo/default.nix b/pkgs/development/libraries/liblo/default.nix
index 7b7e96012ea7..ae1d458b0d52 100644
--- a/pkgs/development/libraries/liblo/default.nix
+++ b/pkgs/development/libraries/liblo/default.nix
@@ -1,16 +1,16 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "liblo-0.26";
+  name = "liblo-0.29";
 
   src = fetchurl {
-    url = "mirror://sourceforge/liblo/liblo/0.26/${name}.tar.gz";
-    sha256 = "0n124fv9m8yjxs2yxnp3l1i30b8qgg1zx51y63ax12hpz04zndm6";
+    url = "mirror://sourceforge/liblo/liblo/0.29/${name}.tar.gz";
+    sha256 = "0sn0ckc1d0845mhsaa62wf7f9v0c0ykiq796a30ja5096kib9qdc";
   };
 
   meta = { 
     description = "Lightweight library to handle the sending and receiving of messages according to the Open Sound Control (OSC) protocol";
-    homepage = http://sourceforge.net/projects/liblo;
+    homepage = https://sourceforge.net/projects/liblo;
     license = stdenv.lib.licenses.gpl2;
     maintainers = [stdenv.lib.maintainers.marcweber];
     platforms = with stdenv.lib.platforms; linux ++ darwin;
diff --git a/pkgs/development/libraries/liblogging/default.nix b/pkgs/development/libraries/liblogging/default.nix
index 4667a6e76014..dd852e1de85a 100644
--- a/pkgs/development/libraries/liblogging/default.nix
+++ b/pkgs/development/libraries/liblogging/default.nix
@@ -3,11 +3,11 @@
 }:
 
 stdenv.mkDerivation rec {
-  name = "liblogging-1.0.5";
+  name = "liblogging-1.0.6";
 
   src = fetchurl {
     url = "http://download.rsyslog.com/liblogging/${name}.tar.gz";
-    sha256 = "02w94j344q0ywlj4mdf9fnzwggdsn3j1yn43sdlsddvr29lw239i";
+    sha256 = "14xz00mq07qmcgprlj5b2r21ljgpa4sbwmpr6jm2wrf8wms6331k";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/liblouis/default.nix b/pkgs/development/libraries/liblouis/default.nix
new file mode 100644
index 000000000000..bde1ff4e4936
--- /dev/null
+++ b/pkgs/development/libraries/liblouis/default.nix
@@ -0,0 +1,57 @@
+{ fetchFromGitHub, stdenv, autoreconfHook, pkgconfig, gettext, python3
+, texinfo, help2man, libyaml, perl
+}:
+
+let
+  version = "3.5.0";
+in stdenv.mkDerivation rec {
+  name = "liblouis-${version}";
+
+  src = fetchFromGitHub {
+    owner = "liblouis";
+    repo = "liblouis";
+    rev = "v${version}";
+    sha256 = "0klmyh6cg9khv59j4xdsrwwjzdgylw689gvrjiy5jsvqll58fcsd";
+  };
+
+  outputs = [ "out" "dev" "man" "info" "doc" ];
+
+  nativeBuildInputs = [
+    autoreconfHook pkgconfig gettext python3
+    # Docs, man, info
+    texinfo help2man
+  ];
+
+  buildInputs = [
+    # lou_checkYaml
+    libyaml
+    # maketable.d
+    perl
+  ];
+
+  configureFlags = [
+    # Required by Python bindings
+    "--enable-ucs4"
+  ];
+
+  postPatch = ''
+    patchShebangs tests
+    substituteInPlace python/louis/__init__.py.in --replace "###LIBLOUIS_SONAME###" "$out/lib/liblouis.so"
+  '';
+
+  postInstall = ''
+    pushd python
+    python setup.py install --prefix="$out" --optimize=1
+    popd
+  '';
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "Open-source braille translator and back-translator";
+    homepage = http://liblouis.org/;
+    license = licenses.lgpl21;
+    maintainers = with maintainers; [ jtojnar ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/liblscp/default.nix b/pkgs/development/libraries/liblscp/default.nix
index c89b21de0d64..1a5a4baf8086 100644
--- a/pkgs/development/libraries/liblscp/default.nix
+++ b/pkgs/development/libraries/liblscp/default.nix
@@ -1,19 +1,19 @@
-{ stdenv, fetchsvn, autoconf, automake, libtool, pkgconfig }:
+{ stdenv, fetchurl, autoconf, automake, libtool, pkgconfig }:
 
 stdenv.mkDerivation rec {
-  name = "liblscp-svn-${version}";
-  version = "2319";
+  name = "liblscp-${version}";
+  version = "0.6.0";
 
-  src = fetchsvn {
-    url = "https://svn.linuxsampler.org/svn/liblscp/trunk";
-    rev = "${version}";
-    sha256 = "0jgdy9gi9n8x2pqrbll9158vhx8293lnxv8vzl0szcincslgk7hi";
+  src = fetchurl {
+    url = "https://download.linuxsampler.org/packages/${name}.tar.gz";
+    sha256 = "1rl7ssdzj0z3658yvdijmb27n2lcwmplx4qxg5mwrm07pvs7i75k";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ autoconf automake libtool ];
+  nativeBuildInputs = [ autoconf automake libtool pkgconfig ];
 
-  preConfigure = "make -f Makefile.svn";
+  preConfigure = "make -f Makefile.git";
+
+  enableParallelBuilding = true;
 
   meta = with stdenv.lib; {
     homepage = http://www.linuxsampler.org;
diff --git a/pkgs/development/libraries/libltc/default.nix b/pkgs/development/libraries/libltc/default.nix
index ec306e0f7c34..dfc2402a7ec6 100644
--- a/pkgs/development/libraries/libltc/default.nix
+++ b/pkgs/development/libraries/libltc/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation {
-  name = "libltc-1.1.4";
+  name = "libltc-1.3.0";
 
   src = fetchurl {
-    url = https://github.com/x42/libltc/releases/download/v1.1.4/libltc-1.1.4.tar.gz;
-    sha256 = "0xas0zbi11nhq15al6cxn0iwa563s6fcz01hw0np1clh25h4773x";
+    url = https://github.com/x42/libltc/releases/download/v1.3.0/libltc-1.3.0.tar.gz;
+    sha256 = "0p7fgp44i9d1lrgbk5zj3sm5yzavx428zn36xb3bl7y65c2xxcda";
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libmaxminddb/default.nix b/pkgs/development/libraries/libmaxminddb/default.nix
index 9355c43642a4..f1b15a91ccac 100644
--- a/pkgs/development/libraries/libmaxminddb/default.nix
+++ b/pkgs/development/libraries/libmaxminddb/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libmaxminddb-${version}";
-  version = "1.2.0";
+  version = "1.3.2";
 
   src = fetchurl {
     url = meta.homepage + "/releases/download/${version}/${name}.tar.gz";
-    sha256 = "0dxdyw6sxxmpzk2a96qp323r5kdmw7vm6m0l5a8gr52gf7nmks0z";
+    sha256 = "1w60yq26x3yr3abxk7fwqqaggw8dc98595jdliaa3kyqdfm83y76";
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libmbim/default.nix b/pkgs/development/libraries/libmbim/default.nix
index 1c8e65dafd4b..431770ef12d1 100644
--- a/pkgs/development/libraries/libmbim/default.nix
+++ b/pkgs/development/libraries/libmbim/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, pkgconfig, glib, python, udev, libgudev }:
 
 stdenv.mkDerivation rec {
-  name = "libmbim-1.14.2";
+  name = "libmbim-1.16.0";
 
   src = fetchurl {
     url = "https://www.freedesktop.org/software/libmbim/${name}.tar.xz";
-    sha256 = "1krirl9881dnx7l29zhvagk2qlhi26vpvkzdifjklhrjhimzxji2";
+    sha256 = "1hpsjc7bzmakzvj8z9fffvqknc38fa8ridpmklq46jyxxnz51jn8";
   };
 
   outputs = [ "out" "dev" "man" ];
diff --git a/pkgs/development/libraries/libmd/default.nix b/pkgs/development/libraries/libmd/default.nix
index 8951017a4b5c..2da8e5ebf738 100644
--- a/pkgs/development/libraries/libmd/default.nix
+++ b/pkgs/development/libraries/libmd/default.nix
@@ -3,11 +3,11 @@
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
   pname = "libmd";
-  version = "0.0.0";
+  version = "1.0.0";
 
   src = fetchurl {
     url = "https://archive.hadrons.org/software/${pname}/${pname}-${version}.tar.xz";
-    sha256 = "121s73pgbqsnmy6xblbrkj9y44c5zzzpf2hcmh6zvcvg4dk26gzx";
+    sha256 = "1iv45npzv0gncjgcpx5m081861zdqxw667ysghqb8721yrlyl6pj";
   };
 
   nativeBuildInputs = [ autoreconfHook ];
diff --git a/pkgs/development/libraries/libmediainfo/default.nix b/pkgs/development/libraries/libmediainfo/default.nix
index 9e4b23a0919c..8c204ba4006f 100644
--- a/pkgs/development/libraries/libmediainfo/default.nix
+++ b/pkgs/development/libraries/libmediainfo/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, autoreconfHook, pkgconfig, libzen, zlib }:
 
 stdenv.mkDerivation rec {
-  version = "0.7.99";
+  version = "18.03.1";
   name = "libmediainfo-${version}";
   src = fetchurl {
     url = "https://mediaarea.net/download/source/libmediainfo/${version}/libmediainfo_${version}.tar.xz";
-    sha256 = "126nkxrzs6dxzm3hzx6smvw6xgrqr3zs6hdqvl2xmvqy10p8z6pc";
+    sha256 = "183gcb6h81blgvssfl5lxsv8h5izkgg6b86z0jy9g699adgkchq2";
   };
 
   nativeBuildInputs = [ autoreconfHook pkgconfig ];
@@ -15,6 +15,8 @@ stdenv.mkDerivation rec {
 
   configureFlags = [ "--enable-shared" ];
 
+  enableParallelBuilding = true;
+
   postInstall = ''
     install -vD -m 644 libmediainfo.pc "$out/lib/pkgconfig/libmediainfo.pc"
   '';
diff --git a/pkgs/development/libraries/libmemcached/default.nix b/pkgs/development/libraries/libmemcached/default.nix
index 086ba8f32d21..15e642832df6 100644
--- a/pkgs/development/libraries/libmemcached/default.nix
+++ b/pkgs/development/libraries/libmemcached/default.nix
@@ -17,11 +17,14 @@ stdenv.mkDerivation rec {
     ++ stdenv.lib.optional stdenv.isDarwin (fetchpatch {
       url = "https://raw.githubusercontent.com/Homebrew/homebrew/bfd4a0a4626b61c2511fdf573bcbbc6bbe86340e/Library/Formula/libmemcached.rb";
       sha256 = "1gjf3vd7hiyzxjvlg2zfc3y2j0lyr6nhbws4xb5dmin3csyp8qb8";
-    });
+    })
+    ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./musl-fixes.patch;
 
   buildInputs = [ libevent ];
   propagatedBuildInputs = [ cyrus_sasl ];
 
+  NIX_CFLAGS_COMPILE = [ "-fpermissive"/*gcc7*/ ];
+
   meta = with stdenv.lib; {
     homepage = http://libmemcached.org;
     description = "Open source C/C++ client library and tools for the memcached server";
diff --git a/pkgs/development/libraries/libmemcached/musl-fixes.patch b/pkgs/development/libraries/libmemcached/musl-fixes.patch
new file mode 100644
index 000000000000..eb2a6bc980eb
--- /dev/null
+++ b/pkgs/development/libraries/libmemcached/musl-fixes.patch
@@ -0,0 +1,58 @@
+diff --git a/libhashkit/fnv_64.cc b/libhashkit/fnv_64.cc
+index 68e4dd0..64656b7 100644
+--- a/libhashkit/fnv_64.cc
++++ b/libhashkit/fnv_64.cc
+@@ -37,8 +37,9 @@
+ 
+ 
+ #include <libhashkit/common.h>
++#include <limits.h>
+ 
+-#if __WORDSIZE == 64 && defined(HAVE_FNV64_HASH)
++#if (LONG_BITS == 64) && defined(HAVE_FNV64_HASH)
+ 
+ /* FNV hash'es lifted from Dustin Sallings work */
+ static uint64_t FNV_64_INIT= 0xcbf29ce484222325;
+diff --git a/libhashkit/has.cc b/libhashkit/has.cc
+index 843e32e..4153e5e 100644
+--- a/libhashkit/has.cc
++++ b/libhashkit/has.cc
+@@ -37,6 +37,7 @@
+ 
+ 
+ #include <libhashkit/common.h>
++#include <limits.h>
+ 
+ bool libhashkit_has_algorithm(const hashkit_hash_algorithm_t algo)
+ {
+@@ -44,7 +45,7 @@ bool libhashkit_has_algorithm(const hashkit_hash_algorithm_t algo)
+   {
+   case HASHKIT_HASH_FNV1_64:
+   case HASHKIT_HASH_FNV1A_64:
+-#if __WORDSIZE == 64 && defined(HAVE_FNV64_HASH)
++#if (LONG_BITS == 64) && defined(HAVE_FNV64_HASH)
+     return true;
+ #else
+     return false;
+diff --git a/libtest/cmdline.cc b/libtest/cmdline.cc
+index 29a22de..161c646 100644
+--- a/libtest/cmdline.cc
++++ b/libtest/cmdline.cc
+@@ -61,7 +61,7 @@ using namespace libtest;
+ #include <algorithm>
+ #include <stdexcept>
+ 
+-#ifndef __USE_GNU
++#ifndef _GNU_SOURCE
+ static char **environ= NULL;
+ #endif
+ 
+@@ -201,7 +201,7 @@ Application::error_t Application::run(const char *args[])
+ 
+   fatal_assert(posix_spawnattr_setsigmask(&spawnattr, &mask) == 0);
+ 
+-#if defined(POSIX_SPAWN_USEVFORK) || defined(__linux__)
++#if defined(POSIX_SPAWN_USEVFORK) || defined(__GLIBC__)
+   // Use USEVFORK on linux
+   flags |= POSIX_SPAWN_USEVFORK;
+ #endif
diff --git a/pkgs/development/libraries/libmicrohttpd/default.nix b/pkgs/development/libraries/libmicrohttpd/default.nix
index 68156c0c2171..041e0d98d654 100644
--- a/pkgs/development/libraries/libmicrohttpd/default.nix
+++ b/pkgs/development/libraries/libmicrohttpd/default.nix
@@ -1,17 +1,17 @@
-{ stdenv, fetchurl, libgcrypt, curl, gnutls, pkgconfig, libiconv, libintlOrEmpty }:
+{ stdenv, fetchurl, libgcrypt, curl, gnutls, pkgconfig, libiconv, libintl }:
 
 stdenv.mkDerivation rec {
-  name = "libmicrohttpd-0.9.55";
+  name = "libmicrohttpd-${version}";
+  version = "0.9.59";
 
   src = fetchurl {
     url = "mirror://gnu/libmicrohttpd/${name}.tar.gz";
-    sha256 = "1y6h1slav5l6k8zyb01dpw65dscdgxxgfa3a0z9qnn7jr66sn70c";
+    sha256 = "0g4jgnv43yddr9yxrqg11632rip0lg5c53gmy5wy3c0i1dywv74v";
   };
 
   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.
@@ -37,4 +37,3 @@ stdenv.mkDerivation rec {
     platforms = platforms.unix;
   };
 }
-
diff --git a/pkgs/development/libraries/libmikmod/default.nix b/pkgs/development/libraries/libmikmod/default.nix
index 8071d386db0f..c509fcd2b4f8 100644
--- a/pkgs/development/libraries/libmikmod/default.nix
+++ b/pkgs/development/libraries/libmikmod/default.nix
@@ -4,10 +4,10 @@ let
   inherit (stdenv.lib) optional optionals optionalString;
 
 in stdenv.mkDerivation rec {
-  name = "libmikmod-3.3.11";
+  name = "libmikmod-3.3.11.1";
   src = fetchurl {
     url = "mirror://sourceforge/mikmod/${name}.tar.gz";
-    sha256 = "1smb291jr4qm2cdk3gfpmh0pr23rx3jw3fw0j1zr3b4ih7727fni";
+    sha256 = "06bdnhb0l81srdzg6gn2v2ydhhaazza7rshrcj3q8dpqr3gn97dd";
   };
 
   buildInputs = [ texinfo ]
diff --git a/pkgs/development/libraries/libminc/default.nix b/pkgs/development/libraries/libminc/default.nix
index 217ce20c6cfb..704c73284ae1 100644
--- a/pkgs/development/libraries/libminc/default.nix
+++ b/pkgs/development/libraries/libminc/default.nix
@@ -1,27 +1,42 @@
-{ stdenv, fetchurl, cmake, zlib, netcdf, hdf5 }:
+{ stdenv, fetchFromGitHub, cmake, zlib, netcdf, nifticlib, hdf5 }:
 
 stdenv.mkDerivation rec {
-  _name = "libminc";
-  name  = "${_name}-2.3.00";
+  pname = "libminc";
+  name  = "${pname}-2017-09-14";
 
-  src = fetchurl {
-    url = "https://github.com/BIC-MNI/${_name}/archive/${_name}-2-3-00.tar.gz";
-    sha256 = "04ngqx4wkssxs9qqcgq2bvfs1cldcycmpcx587wy3b3m6lwf004c";
+  owner = "BIC-MNI";
+
+  # current master is significantly ahead of most recent release, so use Git version:
+  src = fetchFromGitHub {
+    inherit owner;
+    repo   = pname;
+    rev    = "e11c6df9321b4061bf87a7d43171ec55e9e3908f";
+    sha256 = "0lmd0js3jgni2mw1zfvd4qg6byxiv3ndgv2z3nm7975i83zw48xk";
   };
 
   nativeBuildInputs = [ cmake ];
-  buildInputs = [ zlib netcdf hdf5 ];
+  buildInputs = [ zlib netcdf nifticlib hdf5 ];
+
+  cmakeFlags = [ "-DBUILD_TESTING=${if doCheck then "TRUE" else "FALSE"}"
+                 "-DLIBMINC_MINC1_SUPPORT=TRUE"
+                 "-DLIBMINC_BUILD_SHARED_LIBS=TRUE"
+                 "-DLIBMINC_USE_SYSTEM_NIFTI=TRUE" ];
 
-  cmakeFlags = [ "-DBUILD_TESTING=${if doCheck then "ON" else "OFF"}"
-                 "-DLIBMINC_MINC1_SUPPORT=ON" ];
 
-  checkPhase = "ctest";
+  checkPhase = ''
+    export LD_LIBRARY_PATH="$(pwd)"  # see #22060
+    ctest -E 'ezminc_rw_test|minc_conversion' --output-on-failure
+    # ezminc_rw_test can't find libminc_io.so.5.2.0; minc_conversion hits netcdf compilation issue
+  '';
   doCheck = true;
 
+  enableParallelBuilding = true;
+
   meta = with stdenv.lib; {
-    homepage = https://github.com/BIC-MNI/libminc;
+    homepage = "https://github.com/${owner}/${pname}";
     description = "Medical imaging library based on HDF5";
     maintainers = with maintainers; [ bcdarwin ];
     platforms = platforms.unix;
+    license   = licenses.free;
   };
 }
diff --git a/pkgs/development/libraries/libmng/default.nix b/pkgs/development/libraries/libmng/default.nix
index ff627499855c..749a5d60e467 100644
--- a/pkgs/development/libraries/libmng/default.nix
+++ b/pkgs/development/libraries/libmng/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, zlib, libpng, libjpeg, lcms2 }:
 
 stdenv.mkDerivation rec {
-  name = "libmng-2.0.2";
+  name = "libmng-2.0.3";
 
   src = fetchurl {
     url = "mirror://sourceforge/libmng/${name}.tar.xz";
-    sha256 = "0l5wa3b9rr4zl49zbbjpapqyccqjwzkzw1ph3p4pk9p5h73h9317";
+    sha256 = "1lvxnpds0vcf0lil6ia2036ghqlbl740c4d2sz0q5g6l93fjyija";
   };
 
   outputs = [ "out" "dev" "devdoc" ];
diff --git a/pkgs/development/libraries/libmnl/default.nix b/pkgs/development/libraries/libmnl/default.nix
index 33ccccea2e95..2dbdb60b4b66 100644
--- a/pkgs/development/libraries/libmnl/default.nix
+++ b/pkgs/development/libraries/libmnl/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
       This library aims to provide simple helpers that allows you to re-use code and to avoid
       re-inventing the wheel.
     '';
-    homepage = http://netfilter.org/projects/libmnl/index.html;
+    homepage = https://netfilter.org/projects/libmnl/index.html;
     license = stdenv.lib.licenses.lgpl21Plus;
 
     platforms = stdenv.lib.platforms.linux;
diff --git a/pkgs/development/libraries/libmodbus/default.nix b/pkgs/development/libraries/libmodbus/default.nix
index f6a816ef96f6..10bd7af7fadd 100644
--- a/pkgs/development/libraries/libmodbus/default.nix
+++ b/pkgs/development/libraries/libmodbus/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "libmodbus-3.0.6";
+  name = "libmodbus-3.1.4";
 
   src = fetchurl {
     url = "http://libmodbus.org/releases/${name}.tar.gz";
-    sha256 = "1dkijjv3dq0c5vc5z5f1awm8dlssbwg6ivsnvih22pkm1zqn6v84";
+    sha256 = "0drnil8bzd4n4qb0wv3ilm9zvypxvwmzd65w96d6kfm7x6q65j68";
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libmodplug/default.nix b/pkgs/development/libraries/libmodplug/default.nix
index 600d7faace20..858004910160 100644
--- a/pkgs/development/libraries/libmodplug/default.nix
+++ b/pkgs/development/libraries/libmodplug/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl }:
 
 let
-  version = "0.8.8.5";
+  version = "0.8.9.0";
 in stdenv.mkDerivation rec {
   name = "libmodplug-${version}";
 
@@ -15,6 +15,6 @@ in stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "mirror://sourceforge/project/modplug-xmms/libmodplug/${version}/${name}.tar.gz";
-    sha256 = "1bfsladg7h6vnii47dd66f5vh1ir7qv12mfb8n36qiwrxq92sikp";
+    sha256 = "1pnri98a603xk47smnxr551svbmgbzcw018mq1k6srbrq6kaaz25";
   };
 }
diff --git a/pkgs/development/libraries/libmowgli/default.nix b/pkgs/development/libraries/libmowgli/default.nix
index 06a98bcdcebf..b23701837fa0 100644
--- a/pkgs/development/libraries/libmowgli/default.nix
+++ b/pkgs/development/libraries/libmowgli/default.nix
@@ -1,11 +1,12 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "libmowgli-0.9.50";
+  name = "libmowgli-${version}";
+  version = "2.1.3";
   
   src = fetchurl {
-    url = "http://distfiles.atheme.org/${name}.tar.bz2";
-    sha256 = "0wbnpd2rzk5jg6pghgxyx7brjrdmsyg4p0mm9blwmrdrj5ybxx9z";
+    url = "https://github.com/atheme/libmowgli-2/archive/v${version}.tar.gz";
+    sha256 = "0xx4vndmwz40pxa5gikl8z8cskpdl9a30i2i5fjncqzlp4pspymp";
   };
   
   meta = {
diff --git a/pkgs/development/libraries/libmpack/default.nix b/pkgs/development/libraries/libmpack/default.nix
index 9375a3810529..2754c726da2b 100644
--- a/pkgs/development/libraries/libmpack/default.nix
+++ b/pkgs/development/libraries/libmpack/default.nix
@@ -2,21 +2,18 @@
 
 stdenv.mkDerivation rec {
   name = "libmpack-${version}";
-  version = "1.0.3-rev${rev}";
-  rev = "80bd55ea677e70b041f65a4b99438c1f059cce4b";
+  version = "1.0.5";
   src = fetchFromGitHub {
     owner = "tarruda";
     repo = "libmpack";
-    inherit rev;
-    sha256 = "1whnbgxd5580h59kvc2xgx6ymw7nk9kz6r4ajgsfv6c6h2xbwbl3";
+    rev = version;
+    sha256 = "0rai5djdkjz7bsn025k5489in7r1amagw1pib0z4qns6b52kiar2";
   };
-  LIBTOOL = "libtool";
-  buildInputs = [ libtool ];
-  installPhase = ''
-    mkdir -p $out/lib/libmpack
-    cp -R build/* $out/lib/libmpack
-    rm -rf $out/lib/libmpack/debug
-  '';
+
+  nativeBuildInputs = [ libtool ];
+
+  makeFlags = [ "LIBTOOL=libtool" "PREFIX=$(out)" ];
+
   meta = with stdenv.lib; {
     description = "Simple implementation of msgpack in C";
     homepage = https://github.com/tarruda/libmpack/;
diff --git a/pkgs/development/libraries/libmpc/default.nix b/pkgs/development/libraries/libmpc/default.nix
index 4be59af6f0c2..106f6fe6c37c 100644
--- a/pkgs/development/libraries/libmpc/default.nix
+++ b/pkgs/development/libraries/libmpc/default.nix
@@ -1,24 +1,21 @@
 { stdenv, fetchurl
 , gmp, mpfr
-, buildPlatform, hostPlatform
 }:
 
 let
-  version = "1.0.3";
+  version = "1.1.0";
 in
 stdenv.mkDerivation rec {
   name = "libmpc-${version}"; # to avoid clash with the MPD client
 
   src = fetchurl {
-    url = "http://www.multiprecision.org/mpc/download/mpc-${version}.tar.gz";
-    sha256 = "1hzci2zrrd7v3g1jk35qindq05hbl0bhjcyyisq9z209xb3fqzb1";
+    url = "mirror://gnu/mpc/mpc-${version}.tar.gz";
+    sha256 = "0biwnhjm3rx3hc0rfpvyniky4lpzsvdcwhmcn7f0h4iw2hwcb1b9";
   };
 
   buildInputs = [ gmp mpfr ];
 
-  CFLAGS = "-I${gmp.dev}/include";
-
-  doCheck = hostPlatform == buildPlatform;
+  doCheck = true; # not cross;
 
   meta = {
     description = "Library for multiprecision complex arithmetic with exact rounding";
diff --git a/pkgs/development/libraries/libmsgpack/1.4.nix b/pkgs/development/libraries/libmsgpack/1.4.nix
deleted file mode 100644
index 2779162feb8a..000000000000
--- a/pkgs/development/libraries/libmsgpack/1.4.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-{ callPackage, fetchFromGitHub, ... } @ args:
-
-callPackage ./generic.nix (args // rec {
-  version = "1.4.2";
-
-  src = fetchFromGitHub {
-    owner = "msgpack";
-    repo = "msgpack-c";
-    rev = "cpp-${version}";
-    sha256 = "0zlanifi5hmm303pzykpidq5jbapl891zwkwhkllfn8ab1jvzbaa";
-  };
-})
diff --git a/pkgs/development/libraries/libmsgpack/default.nix b/pkgs/development/libraries/libmsgpack/default.nix
index 2af7e31c889a..8feacd4e3653 100644
--- a/pkgs/development/libraries/libmsgpack/default.nix
+++ b/pkgs/development/libraries/libmsgpack/default.nix
@@ -1,12 +1,12 @@
 { callPackage, fetchFromGitHub, ... } @ args:
 
 callPackage ./generic.nix (args // rec {
-  version = "2.0.0";
+  version = "2.1.5";
 
   src = fetchFromGitHub {
-    owner = "msgpack";
-    repo = "msgpack-c";
-    rev = "cpp-${version}";
-    sha256 = "189m44pwpcpf7g4yhzfla4djqyp2kl54wxmwfaj94gwgj5s370i7";
+    owner  = "msgpack";
+    repo   = "msgpack-c";
+    rev    = "cpp-${version}";
+    sha256 = "0n4kvma3dldfsvv7b0zw23qln6av5im2aqqd6m890i75zwwkw0zv";
   };
 })
diff --git a/pkgs/development/libraries/libmsgpack/generic.nix b/pkgs/development/libraries/libmsgpack/generic.nix
index c6870f77f1f3..7bca8f21c6b9 100644
--- a/pkgs/development/libraries/libmsgpack/generic.nix
+++ b/pkgs/development/libraries/libmsgpack/generic.nix
@@ -11,16 +11,21 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake ];
 
+  enableParallelBuilding = true;
+
   crossAttrs = {
   } // stdenv.lib.optionalAttrs (hostPlatform.libc == "msvcrt") {
-    cmakeFlags = "-DMSGPACK_BUILD_EXAMPLES=OFF -DCMAKE_SYSTEM_NAME=Windows";
+    cmakeFlags = [
+      "-DMSGPACK_BUILD_EXAMPLES=OFF"
+      "-DCMAKE_SYSTEM_NAME=Windows"
+    ];
   };
 
   meta = with stdenv.lib; {
     description = "MessagePack implementation for C and C++";
-    homepage = http://msgpack.org;
+    homepage    = http://msgpack.org;
+    license     = licenses.asl20;
     maintainers = with maintainers; [ redbaron wkennington ];
-    license = licenses.asl20;
-    platforms = platforms.all;
+    platforms   = platforms.all;
   };
 }
diff --git a/pkgs/development/libraries/libmtp/default.nix b/pkgs/development/libraries/libmtp/default.nix
index 9cac26bf2be1..88ef55715a7c 100644
--- a/pkgs/development/libraries/libmtp/default.nix
+++ b/pkgs/development/libraries/libmtp/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, pkgconfig, libusb1 }:
 
 stdenv.mkDerivation rec {
-  name = "libmtp-1.1.13";
+  name = "libmtp-1.1.15";
 
   src = fetchurl {
     url = "mirror://sourceforge/libmtp/${name}.tar.gz";
-    sha256 = "0h3dv9py5mmvxhfxmkr8ky4s80hgq3d66cmrfnnnlcdwpwpy0kj9";
+    sha256 = "089h79nkz7wcr3lbqi7025l8p75hbp0aigxk3wdk2zkm8q5r0h6h";
   };
 
   outputs = [ "bin" "dev" "out" ];
diff --git a/pkgs/development/libraries/libmwaw/default.nix b/pkgs/development/libraries/libmwaw/default.nix
index e1ac659683c9..35137a09cd9c 100644
--- a/pkgs/development/libraries/libmwaw/default.nix
+++ b/pkgs/development/libraries/libmwaw/default.nix
@@ -3,11 +3,11 @@ let
   s = # Generated upstream information
   rec {
     baseName="libmwaw";
-    version="0.3.10";
+    version="0.3.13";
     name="${baseName}-${version}";
-    hash="087j6kx03ggvqwpl944nnf75qkvi9bag8b0z59phg66gbz0s0imj";
-    url="https://netcologne.dl.sourceforge.net/project/libmwaw/libmwaw/libmwaw-0.3.10/libmwaw-0.3.10.tar.xz";
-    sha256="087j6kx03ggvqwpl944nnf75qkvi9bag8b0z59phg66gbz0s0imj";
+    hash="1sjs3nc39im232h5bf81w3il8ivd7w2bc2qssxf7k74g8hlcfmfv";
+    url="mirror://sourceforge/libmwaw/libmwaw/libmwaw-0.3.13/libmwaw-0.3.13.tar.xz";
+    sha256="1sjs3nc39im232h5bf81w3il8ivd7w2bc2qssxf7k74g8hlcfmfv";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/libmx/default.nix b/pkgs/development/libraries/libmx/default.nix
index 897a769b014d..42bcf5b64740 100644
--- a/pkgs/development/libraries/libmx/default.nix
+++ b/pkgs/development/libraries/libmx/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl
 , libtool, pkgconfig, automake, autoconf, intltool
-, glib, gobjectIntrospection, gtk2, gtk_doc
-, clutter, clutter_gtk
+, glib, gobjectIntrospection, gtk2, gtk-doc
+, clutter, clutter-gtk
 }:
 
 stdenv.mkDerivation rec {
@@ -36,7 +36,7 @@ stdenv.mkDerivation rec {
     automake autoconf libtool
     intltool
     gobjectIntrospection glib
-    gtk2 gtk_doc clutter clutter_gtk
+    gtk2 gtk-doc clutter clutter-gtk
   ];
 
   # patch to resolve GL errors
diff --git a/pkgs/development/libraries/libmypaint/default.nix b/pkgs/development/libraries/libmypaint/default.nix
new file mode 100644
index 000000000000..8719f19acc1d
--- /dev/null
+++ b/pkgs/development/libraries/libmypaint/default.nix
@@ -0,0 +1,40 @@
+{stdenv, autoconf, automake, fetchFromGitHub, fetchpatch, glib, intltool, json_c, libtool, pkgconfig}:
+
+let
+  version = "1.3.0";
+in stdenv.mkDerivation rec {
+  name = "libmypaint-${version}";
+
+  src = fetchFromGitHub {
+    owner = "mypaint";
+    repo = "libmypaint";
+    rev = "v${version}";
+    sha256 = "0b7aynr6ggigwhjkfzi8x3dwz15blj4grkg9hysbgjh6lvzpy9jc";
+  };
+
+  patches = [
+    # build with automake 1.16
+    (fetchpatch {
+      url = https://github.com/mypaint/libmypaint/commit/40d9077a80be13942476f164bddfabe842ab2a45.patch;
+      sha256 = "1dclh7apgvr2bvzy9z3rgas3hk9pf2hpf5h52q94kmx8s4a47qpi";
+    })
+  ];
+
+  nativeBuildInputs = [ autoconf automake intltool libtool pkgconfig ];
+
+  buildInputs = [ glib ];
+
+  propagatedBuildInputs = [ json_c ]; # for libmypaint.pc
+
+  doCheck = true;
+
+  preConfigure = "./autogen.sh";
+
+  meta = with stdenv.lib; {
+    homepage = http://mypaint.org/;
+    description = "Library for making brushstrokes which is used by MyPaint and other projects";
+    license = licenses.isc;
+    maintainers = with maintainers; [ goibhniu jtojnar ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/libmysqlconnectorcpp/default.nix b/pkgs/development/libraries/libmysqlconnectorcpp/default.nix
index 3905ba1b2716..9eefbcfdb49e 100644
--- a/pkgs/development/libraries/libmysqlconnectorcpp/default.nix
+++ b/pkgs/development/libraries/libmysqlconnectorcpp/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libmysqlconnectorcpp-${version}";
-  version = "1.1.7";
+  version = "1.1.9";
 
   src = fetchurl {
     url = "http://cdn.mysql.com/Downloads/Connector-C++/mysql-connector-c++-${version}.tar.gz";
-    sha256 = "0qy7kxz8h1zswr50ysyl2cc9gy0ip2j7ikl714m7lq3gsay3ydav";
+    sha256 = "1r6j17sy5816a2ld759iis2k6igc2w9p70y4nw9w3rd4d5x88c9y";
   };
 
   buildInputs = [ cmake boost mysql ];
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   cmakeFlags = [ "-DMYSQL_LIB_DIR=${mysql}/lib" ];
 
   meta = {
-    homepage = http://dev.mysql.com/downloads/connector/cpp/;
+    homepage = https://dev.mysql.com/downloads/connector/cpp/;
     description = "C++ library for connecting to mysql servers.";
     license = stdenv.lib.licenses.gpl2;
     platforms = stdenv.lib.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/libnet/default.nix b/pkgs/development/libraries/libnet/default.nix
index a93c16d784de..f642ad5ccfab 100644
--- a/pkgs/development/libraries/libnet/default.nix
+++ b/pkgs/development/libraries/libnet/default.nix
@@ -9,6 +9,8 @@ stdenv.mkDerivation rec {
     sha256 = "0qsapqa7dzq9f6lb19kzilif0pj82b64fjv5bq086hflb9w81hvj";
   };
 
+  patches = [ ./fix-includes.patch ];
+
   meta = with stdenv.lib; {
     homepage = https://github.com/sam-github/libnet;
     description = "Portable framework for low-level network packet construction";
diff --git a/pkgs/development/libraries/libnet/fix-includes.patch b/pkgs/development/libraries/libnet/fix-includes.patch
new file mode 100644
index 000000000000..5eb86bc37b79
--- /dev/null
+++ b/pkgs/development/libraries/libnet/fix-includes.patch
@@ -0,0 +1,29 @@
+--- libnet-1.1.6.orig/src/libnet_link_linux.c
++++ libnet-1.1.6/src/libnet_link_linux.c
+@@ -30,26 +30,15 @@
+ #include <sys/time.h>
+ 
+ #include <net/if.h>
+-#if (__GLIBC__)
+ #include <netinet/if_ether.h>
+ #include <net/if_arp.h>
+-#else
+-#include <linux/if_arp.h>
+-#include <linux/if_ether.h>
+-#endif
+ 
+ #if (HAVE_PACKET_SOCKET)
+ #ifndef SOL_PACKET
+ #define SOL_PACKET 263
+ #endif  /* SOL_PACKET */
+-#if __GLIBC__ >= 2 && __GLIBC_MINOR >= 1
+ #include <netpacket/packet.h>
+ #include <net/ethernet.h>     /* the L2 protocols */
+-#else
+-#include <asm/types.h>
+-#include <linux/if_packet.h>
+-#include <linux/if_ether.h>   /* The L2 protocols */
+-#endif
+ #endif  /* HAVE_PACKET_SOCKET */
+ 
+ #include "../include/libnet.h"
diff --git a/pkgs/development/libraries/libnetfilter_conntrack/default.nix b/pkgs/development/libraries/libnetfilter_conntrack/default.nix
index a94bf28cd972..1b4c471a2567 100644
--- a/pkgs/development/libraries/libnetfilter_conntrack/default.nix
+++ b/pkgs/development/libraries/libnetfilter_conntrack/default.nix
@@ -5,7 +5,7 @@ stdenv.mkDerivation rec {
   version = "1.0.6";
 
   src = fetchurl {
-    url = "http://netfilter.org/projects/libnetfilter_conntrack/files/${name}.tar.bz2";
+    url = "https://netfilter.org/projects/libnetfilter_conntrack/files/${name}.tar.bz2";
     sha256 = "1svzyf3rq9nbrcw1jsricgyhh7x1am8iqn6kjr6mzrw42810ik7g";
   };
 
@@ -21,9 +21,8 @@ stdenv.mkDerivation rec {
       previously known as libnfnetlink_conntrack and libctnetlink. This library is currently used
       by conntrack-tools among many other applications
     '';
-    homepage = http://netfilter.org/projects/libnetfilter_conntrack/;
+    homepage = https://netfilter.org/projects/libnetfilter_conntrack/;
     license = licenses.gpl2Plus;
     platforms = platforms.linux;
-    maintainers = with maintainers; [ nckx ];
   };
 }
diff --git a/pkgs/development/libraries/libnetfilter_cttimeout/default.nix b/pkgs/development/libraries/libnetfilter_cttimeout/default.nix
index f30e12a41631..d16155374ca8 100644
--- a/pkgs/development/libraries/libnetfilter_cttimeout/default.nix
+++ b/pkgs/development/libraries/libnetfilter_cttimeout/default.nix
@@ -5,7 +5,7 @@ stdenv.mkDerivation rec {
   version = "1.0.0";
 
   src = fetchurl {
-    url = "http://netfilter.org/projects/libnetfilter_cttimeout/files/${name}.tar.bz2";
+    url = "https://netfilter.org/projects/libnetfilter_cttimeout/files/${name}.tar.bz2";
     sha256 = "aeab12754f557cba3ce2950a2029963d817490df7edb49880008b34d7ff8feba";
   };
 
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
       With this library, you can create, update and delete timeout policies that can
       be attached to traffic flows. This library is used by conntrack-tools.
     '';
-    homepage = http://netfilter.org/projects/libnetfilter_cttimeout/;
+    homepage = https://netfilter.org/projects/libnetfilter_cttimeout/;
     license = stdenv.lib.licenses.gpl2Plus;
     platforms = stdenv.lib.platforms.linux;
   };
diff --git a/pkgs/development/libraries/libnetfilter_log/default.nix b/pkgs/development/libraries/libnetfilter_log/default.nix
index e3c8447549d1..0d8de14513ed 100644
--- a/pkgs/development/libraries/libnetfilter_log/default.nix
+++ b/pkgs/development/libraries/libnetfilter_log/default.nix
@@ -5,7 +5,7 @@ stdenv.mkDerivation rec {
   version = "1.0.1";
 
   src = fetchurl {
-    url = "http://netfilter.org/projects/libnetfilter_log/files/${name}.tar.bz2";
+    url = "https://netfilter.org/projects/libnetfilter_log/files/${name}.tar.bz2";
     sha256 = "089vjcfxl5qjqpswrbgklf4wflh44irmw6sk2k0kmfixfmszxq3l";
   };
 
@@ -21,9 +21,9 @@ stdenv.mkDerivation rec {
       system that deprecates the old syslog/dmesg based packet logging. This
       library has been previously known as libnfnetlink_log.
     '';
-    homepage = http://netfilter.org/projects/libnetfilter_log/;
+    homepage = https://netfilter.org/projects/libnetfilter_log/;
     license = licenses.gpl2Plus;
     platforms = platforms.linux;
-    maintainers = with maintainers; [ orivej nckx ];
+    maintainers = with maintainers; [ orivej ];
   };
 }
diff --git a/pkgs/development/libraries/libnetfilter_queue/default.nix b/pkgs/development/libraries/libnetfilter_queue/default.nix
index 5de9409b729f..12a45d088ef6 100644
--- a/pkgs/development/libraries/libnetfilter_queue/default.nix
+++ b/pkgs/development/libraries/libnetfilter_queue/default.nix
@@ -1,11 +1,12 @@
 { stdenv, fetchurl, pkgconfig, libmnl, libnfnetlink }:
 
 stdenv.mkDerivation rec {
-  name = "libnetfilter_queue-1.0.2";
+  version = "1.0.3";
+  name = "libnetfilter_queue-${version}";
 
   src = fetchurl {
-    url = "ftp://ftp.netfilter.org/pub/libnetfilter_queue/${name}.tar.bz2";
-    sha256 = "0chsmj9ky80068vn458ijz9sh4sk5yc08dw2d6b8yddybpmr1143";
+    url = "https://www.netfilter.org/projects/libnetfilter_queue/files/${name}.tar.bz2";
+    sha256 = "0x77m1fvbqzz5z64jz59fb6j8dvv8b9pg4fmznqwax4x6imjcncq";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/libnfnetlink/Use-stdlib-uint-instead-of-u_int.patch b/pkgs/development/libraries/libnfnetlink/Use-stdlib-uint-instead-of-u_int.patch
new file mode 100644
index 000000000000..074bef42b97a
--- /dev/null
+++ b/pkgs/development/libraries/libnfnetlink/Use-stdlib-uint-instead-of-u_int.patch
@@ -0,0 +1,499 @@
+From patchwork Fri Apr  3 22:04:46 2015
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: Use stdlib uint* instead of u_int*
+From: Nathan McSween <nwmcsween@gmail.com>
+X-Patchwork-Id: 458131
+X-Patchwork-Delegate: pablo@netfilter.org
+Message-Id: <1428098686-17843-1-git-send-email-nwmcsween@gmail.com>
+To: netfilter-devel@vger.kernel.org
+Cc: Nathan McSween <nwmcsween@gmail.com>
+Date: Fri,  3 Apr 2015 22:04:46 +0000
+
+Signed-off-by: Nathan McSween <nwmcsween@gmail.com>
+---
+ include/libnfnetlink/libnfnetlink.h           | 25 +++++-----
+ include/libnfnetlink/linux_nfnetlink.h        | 11 +++--
+ include/libnfnetlink/linux_nfnetlink_compat.h |  6 ++-
+ src/iftable.c                                 |  9 ++--
+ src/iftable.h                                 |  6 ++-
+ src/libnfnetlink.c                            | 71 ++++++++++++++-------------
+ src/rtnl.c                                    |  5 +-
+ src/rtnl.h                                    |  3 +-
+ 8 files changed, 73 insertions(+), 63 deletions(-)
+
+diff --git a/include/libnfnetlink/libnfnetlink.h b/include/libnfnetlink/libnfnetlink.h
+index 1d8c49d..cd0be3d 100644
+--- a/include/libnfnetlink/libnfnetlink.h
++++ b/include/libnfnetlink/libnfnetlink.h
+@@ -15,6 +15,7 @@
+ #define aligned_u64 unsigned long long __attribute__((aligned(8)))
+ #endif
+ 
++#include <stdint.h>
+ #include <sys/socket.h>	/* for sa_family_t */
+ #include <linux/netlink.h>
+ #include <libnfnetlink/linux_nfnetlink.h>
+@@ -55,7 +56,7 @@ struct nfnlhdr {
+ struct nfnl_callback {
+ 	int (*call)(struct nlmsghdr *nlh, struct nfattr *nfa[], void *data);
+ 	void *data;
+-	u_int16_t attr_count;
++	uint16_t attr_count;
+ };
+ 
+ struct nfnl_handle;
+@@ -69,7 +70,7 @@ extern struct nfnl_handle *nfnl_open(void);
+ extern int nfnl_close(struct nfnl_handle *);
+ 
+ extern struct nfnl_subsys_handle *nfnl_subsys_open(struct nfnl_handle *, 
+-						   u_int8_t, u_int8_t, 
++						   uint8_t, uint8_t,
+ 						   unsigned int);
+ extern void nfnl_subsys_close(struct nfnl_subsys_handle *);
+ 
+@@ -88,8 +89,8 @@ extern int nfnl_sendiov(const struct nfnl_handle *nfnlh,
+ 			const struct iovec *iov, unsigned int num,
+ 			unsigned int flags);
+ extern void nfnl_fill_hdr(struct nfnl_subsys_handle *, struct nlmsghdr *,
+-			  unsigned int, u_int8_t, u_int16_t, u_int16_t,
+-			  u_int16_t);
++			  unsigned int, uint8_t, uint16_t, uint16_t,
++			  uint16_t);
+ extern __attribute__((deprecated)) int
+ nfnl_talk(struct nfnl_handle *, struct nlmsghdr *, pid_t,
+           unsigned, struct nlmsghdr *,
+@@ -103,8 +104,8 @@ nfnl_listen(struct nfnl_handle *,
+ /* receiving */
+ extern ssize_t nfnl_recv(const struct nfnl_handle *h, unsigned char *buf, size_t len);
+ extern int nfnl_callback_register(struct nfnl_subsys_handle *,
+-				  u_int8_t type, struct nfnl_callback *cb);
+-extern int nfnl_callback_unregister(struct nfnl_subsys_handle *, u_int8_t type);
++				  uint8_t type, struct nfnl_callback *cb);
++extern int nfnl_callback_unregister(struct nfnl_subsys_handle *, uint8_t type);
+ extern int nfnl_handle_packet(struct nfnl_handle *, char *buf, int len);
+ 
+ /* parsing */
+@@ -180,12 +181,12 @@ extern int nfnl_query(struct nfnl_handle *h, struct nlmsghdr *nlh);
+ 
+ /* nfnl attribute handling functions */
+ extern int nfnl_addattr_l(struct nlmsghdr *, int, int, const void *, int);
+-extern int nfnl_addattr8(struct nlmsghdr *, int, int, u_int8_t);
+-extern int nfnl_addattr16(struct nlmsghdr *, int, int, u_int16_t);
+-extern int nfnl_addattr32(struct nlmsghdr *, int, int, u_int32_t);
++extern int nfnl_addattr8(struct nlmsghdr *, int, int, uint8_t);
++extern int nfnl_addattr16(struct nlmsghdr *, int, int, uint16_t);
++extern int nfnl_addattr32(struct nlmsghdr *, int, int, uint32_t);
+ extern int nfnl_nfa_addattr_l(struct nfattr *, int, int, const void *, int);
+-extern int nfnl_nfa_addattr16(struct nfattr *, int, int, u_int16_t);
+-extern int nfnl_nfa_addattr32(struct nfattr *, int, int, u_int32_t);
++extern int nfnl_nfa_addattr16(struct nfattr *, int, int, uint16_t);
++extern int nfnl_nfa_addattr32(struct nfattr *, int, int, uint32_t);
+ extern int nfnl_parse_attr(struct nfattr **, int, struct nfattr *, int);
+ #define nfnl_parse_nested(tb, max, nfa) \
+ 	nfnl_parse_attr((tb), (max), NFA_DATA((nfa)), NFA_PAYLOAD((nfa)))
+@@ -197,7 +198,7 @@ extern int nfnl_parse_attr(struct nfattr **, int, struct nfattr *, int);
+ ({	(tail)->nfa_len = (void *) NLMSG_TAIL(nlh) - (void *) tail; })
+ 
+ extern void nfnl_build_nfa_iovec(struct iovec *iov, struct nfattr *nfa, 
+-				 u_int16_t type, u_int32_t len,
++				 uint16_t type, uint32_t len,
+ 				 unsigned char *val);
+ extern unsigned int nfnl_rcvbufsiz(const struct nfnl_handle *h, 
+ 				   unsigned int size);
+diff --git a/include/libnfnetlink/linux_nfnetlink.h b/include/libnfnetlink/linux_nfnetlink.h
+index 76a8550..7b843c6 100644
+--- a/include/libnfnetlink/linux_nfnetlink.h
++++ b/include/libnfnetlink/linux_nfnetlink.h
+@@ -1,5 +1,6 @@
+ #ifndef _NFNETLINK_H
+ #define _NFNETLINK_H
++#include <stdint.h>
+ #include <linux/types.h>
+ #include <libnfnetlink/linux_nfnetlink_compat.h>
+ 
+@@ -25,9 +26,9 @@ enum nfnetlink_groups {
+ /* General form of address family dependent message.
+  */
+ struct nfgenmsg {
+-	u_int8_t  nfgen_family;		/* AF_xxx */
+-	u_int8_t  version;		/* nfnetlink version */
+-	u_int16_t    res_id;		/* resource id */
++	uint8_t  nfgen_family;		/* AF_xxx */
++	uint8_t  version;		/* nfnetlink version */
++	uint16_t    res_id;		/* resource id */
+ };
+ 
+ #define NFNETLINK_V0	0
+@@ -59,7 +60,7 @@ struct nfnl_callback
+ 	int (*call)(struct sock *nl, struct sk_buff *skb, 
+ 		struct nlmsghdr *nlh, struct nlattr *cda[]);
+ 	const struct nla_policy *policy;	/* netlink attribute policy */
+-	const u_int16_t attr_count;		/* number of nlattr's */
++	const uint16_t attr_count;		/* number of nlattr's */
+ };
+ 
+ struct nfnetlink_subsystem
+@@ -76,7 +77,7 @@ extern int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n);
+ extern int nfnetlink_has_listeners(unsigned int group);
+ extern int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, 
+ 			  int echo);
+-extern int nfnetlink_unicast(struct sk_buff *skb, u_int32_t pid, int flags);
++extern int nfnetlink_unicast(struct sk_buff *skb, uint32_t pid, int flags);
+ 
+ #define MODULE_ALIAS_NFNL_SUBSYS(subsys) \
+ 	MODULE_ALIAS("nfnetlink-subsys-" __stringify(subsys))
+diff --git a/include/libnfnetlink/linux_nfnetlink_compat.h b/include/libnfnetlink/linux_nfnetlink_compat.h
+index e145176..cd094fc 100644
+--- a/include/libnfnetlink/linux_nfnetlink_compat.h
++++ b/include/libnfnetlink/linux_nfnetlink_compat.h
+@@ -3,6 +3,8 @@
+ #ifndef __KERNEL__
+ /* Old nfnetlink macros for userspace */
+ 
++#include <stdint.h>
++
+ /* nfnetlink groups: Up to 32 maximum */
+ #define NF_NETLINK_CONNTRACK_NEW 		0x00000001
+ #define NF_NETLINK_CONNTRACK_UPDATE		0x00000002
+@@ -20,8 +22,8 @@
+ 
+ struct nfattr
+ {
+-	u_int16_t nfa_len;
+-	u_int16_t nfa_type;	/* we use 15 bits for the type, and the highest
++	uint16_t nfa_len;
++	uint16_t nfa_type;	/* we use 15 bits for the type, and the highest
+ 				 * bit to indicate whether the payload is nested */
+ };
+ 
+diff --git a/src/iftable.c b/src/iftable.c
+index 5976ed8..3411c4c 100644
+--- a/src/iftable.c
++++ b/src/iftable.c
+@@ -9,6 +9,7 @@
+ /* IFINDEX handling */
+ 
+ #include <unistd.h>
++#include <stdint.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+@@ -27,10 +28,10 @@
+ struct ifindex_node {
+ 	struct list_head head;
+ 
+-	u_int32_t	index;
+-	u_int32_t	type;
+-	u_int32_t	alen;
+-	u_int32_t	flags;
++	uint32_t	index;
++	uint32_t	type;
++	uint32_t	alen;
++	uint32_t	flags;
+ 	char		addr[8];
+ 	char		name[16];
+ };
+diff --git a/src/iftable.h b/src/iftable.h
+index 8df7f24..0cc5335 100644
+--- a/src/iftable.h
++++ b/src/iftable.h
+@@ -1,8 +1,10 @@
+ #ifndef _IFTABLE_H
+ #define _IFTABLE_H
+ 
+-int iftable_delete(u_int32_t dst, u_int32_t mask, u_int32_t gw, u_int32_t oif);
+-int iftable_insert(u_int32_t dst, u_int32_t mask, u_int32_t gw, u_int32_t oif);
++#include <stdint.h>
++
++int iftable_delete(uint32_t dst, uint32_t mask, uint32_t gw, uint32_t oif);
++int iftable_insert(uint32_t dst, uint32_t mask, uint32_t gw, uint32_t oif);
+ 
+ int iftable_init(void);
+ void iftable_fini(void);
+diff --git a/src/libnfnetlink.c b/src/libnfnetlink.c
+index 398b7d7..b8958dc 100644
+--- a/src/libnfnetlink.c
++++ b/src/libnfnetlink.c
+@@ -36,6 +36,7 @@
+  * 	minor cleanups
+  */
+ 
++#include <stdint.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <unistd.h>
+@@ -72,9 +73,9 @@
+ 
+ struct nfnl_subsys_handle {
+ 	struct nfnl_handle 	*nfnlh;
+-	u_int32_t		subscriptions;
+-	u_int8_t		subsys_id;
+-	u_int8_t		cb_count;
++	uint32_t		subscriptions;
++	uint8_t		subsys_id;
++	uint8_t		cb_count;
+ 	struct nfnl_callback 	*cb;	/* array of callbacks */
+ };
+ 
+@@ -86,11 +87,11 @@ struct nfnl_handle {
+ 	int			fd;
+ 	struct sockaddr_nl	local;
+ 	struct sockaddr_nl	peer;
+-	u_int32_t		subscriptions;
+-	u_int32_t		seq;
+-	u_int32_t		dump;
+-	u_int32_t		rcv_buffer_size;	/* for nfnl_catch */
+-	u_int32_t		flags;
++	uint32_t		subscriptions;
++	uint32_t		seq;
++	uint32_t		dump;
++	uint32_t		rcv_buffer_size;	/* for nfnl_catch */
++	uint32_t		flags;
+ 	struct nlmsghdr 	*last_nlhdr;
+ 	struct nfnl_subsys_handle subsys[NFNL_MAX_SUBSYS+1];
+ };
+@@ -145,7 +146,7 @@ unsigned int nfnl_portid(const struct nfnl_handle *h)
+ static int recalc_rebind_subscriptions(struct nfnl_handle *nfnlh)
+ {
+ 	int i, err;
+-	u_int32_t new_subscriptions = nfnlh->subscriptions;
++	uint32_t new_subscriptions = nfnlh->subscriptions;
+ 
+ 	for (i = 0; i < NFNL_MAX_SUBSYS; i++)
+ 		new_subscriptions |= nfnlh->subsys[i].subscriptions;
+@@ -273,8 +274,8 @@ void nfnl_set_rcv_buffer_size(struct nfnl_handle *h, unsigned int size)
+  * a valid address that points to a nfnl_subsys_handle structure is returned.
+  */
+ struct nfnl_subsys_handle *
+-nfnl_subsys_open(struct nfnl_handle *nfnlh, u_int8_t subsys_id,
+-		 u_int8_t cb_count, u_int32_t subscriptions)
++nfnl_subsys_open(struct nfnl_handle *nfnlh, uint8_t subsys_id,
++		 uint8_t cb_count, uint32_t subscriptions)
+ {
+ 	struct nfnl_subsys_handle *ssh;
+ 
+@@ -435,10 +436,10 @@ int nfnl_sendiov(const struct nfnl_handle *nfnlh, const struct iovec *iov,
+  */
+ void nfnl_fill_hdr(struct nfnl_subsys_handle *ssh,
+ 		    struct nlmsghdr *nlh, unsigned int len, 
+-		    u_int8_t family,
+-		    u_int16_t res_id,
+-		    u_int16_t msg_type,
+-		    u_int16_t msg_flags)
++		    uint8_t family,
++		    uint16_t res_id,
++		    uint16_t msg_type,
++		    uint16_t msg_flags)
+ {
+ 	assert(ssh);
+ 	assert(nlh);
+@@ -849,14 +850,14 @@ int nfnl_nfa_addattr_l(struct nfattr *nfa, int maxlen, int type,
+ }
+ 
+ /**
+- * nfnl_addattr8 - Add u_int8_t attribute to nlmsghdr
++ * nfnl_addattr8 - Add uint8_t attribute to nlmsghdr
+  *
+  * @n: netlink message header to which attribute is to be added
+  * @maxlen: maximum length of netlink message header
+  * @type: type of new attribute
+  * @data: content of new attribute
+  */
+-int nfnl_addattr8(struct nlmsghdr *n, int maxlen, int type, u_int8_t data)
++int nfnl_addattr8(struct nlmsghdr *n, int maxlen, int type, uint8_t data)
+ {
+ 	assert(n);
+ 	assert(maxlen > 0);
+@@ -866,7 +867,7 @@ int nfnl_addattr8(struct nlmsghdr *n, int maxlen, int type, u_int8_t data)
+ }
+ 
+ /**
+- * nfnl_nfa_addattr16 - Add u_int16_t attribute to struct nfattr 
++ * nfnl_nfa_addattr16 - Add uint16_t attribute to struct nfattr
+  *
+  * @nfa: struct nfattr
+  * @maxlen: maximal length of nfattr buffer
+@@ -875,7 +876,7 @@ int nfnl_addattr8(struct nlmsghdr *n, int maxlen, int type, u_int8_t data)
+  *
+  */
+ int nfnl_nfa_addattr16(struct nfattr *nfa, int maxlen, int type, 
+-		       u_int16_t data)
++		       uint16_t data)
+ {
+ 	assert(nfa);
+ 	assert(maxlen > 0);
+@@ -885,7 +886,7 @@ int nfnl_nfa_addattr16(struct nfattr *nfa, int maxlen, int type,
+ }
+ 
+ /**
+- * nfnl_addattr16 - Add u_int16_t attribute to nlmsghdr
++ * nfnl_addattr16 - Add uint16_t attribute to nlmsghdr
+  *
+  * @n: netlink message header to which attribute is to be added
+  * @maxlen: maximum length of netlink message header
+@@ -894,7 +895,7 @@ int nfnl_nfa_addattr16(struct nfattr *nfa, int maxlen, int type,
+  *
+  */
+ int nfnl_addattr16(struct nlmsghdr *n, int maxlen, int type,
+-		   u_int16_t data)
++		   uint16_t data)
+ {
+ 	assert(n);
+ 	assert(maxlen > 0);
+@@ -904,7 +905,7 @@ int nfnl_addattr16(struct nlmsghdr *n, int maxlen, int type,
+ }
+ 
+ /**
+- * nfnl_nfa_addattr32 - Add u_int32_t attribute to struct nfattr 
++ * nfnl_nfa_addattr32 - Add uint32_t attribute to struct nfattr
+  *
+  * @nfa: struct nfattr
+  * @maxlen: maximal length of nfattr buffer
+@@ -913,7 +914,7 @@ int nfnl_addattr16(struct nlmsghdr *n, int maxlen, int type,
+  *
+  */
+ int nfnl_nfa_addattr32(struct nfattr *nfa, int maxlen, int type, 
+-		       u_int32_t data)
++		       uint32_t data)
+ {
+ 	assert(nfa);
+ 	assert(maxlen > 0);
+@@ -923,7 +924,7 @@ int nfnl_nfa_addattr32(struct nfattr *nfa, int maxlen, int type,
+ }
+ 
+ /**
+- * nfnl_addattr32 - Add u_int32_t attribute to nlmsghdr
++ * nfnl_addattr32 - Add uint32_t attribute to nlmsghdr
+  *
+  * @n: netlink message header to which attribute is to be added
+  * @maxlen: maximum length of netlink message header
+@@ -932,7 +933,7 @@ int nfnl_nfa_addattr32(struct nfattr *nfa, int maxlen, int type,
+  *
+  */
+ int nfnl_addattr32(struct nlmsghdr *n, int maxlen, int type,
+-		   u_int32_t data)
++		   uint32_t data)
+ {
+ 	assert(n);
+ 	assert(maxlen > 0);
+@@ -980,7 +981,7 @@ int nfnl_parse_attr(struct nfattr *tb[], int max, struct nfattr *nfa, int len)
+  *
+  */ 
+ void nfnl_build_nfa_iovec(struct iovec *iov, struct nfattr *nfa, 
+-			  u_int16_t type, u_int32_t len, unsigned char *val)
++			  uint16_t type, uint32_t len, unsigned char *val)
+ {
+ 	assert(iov);
+ 	assert(nfa);
+@@ -1115,7 +1116,7 @@ struct nlmsghdr *nfnl_get_msg_next(struct nfnl_handle *h,
+  * appropiately.
+  */
+ int nfnl_callback_register(struct nfnl_subsys_handle *ssh,
+-			   u_int8_t type, struct nfnl_callback *cb)
++			   uint8_t type, struct nfnl_callback *cb)
+ {
+ 	assert(ssh);
+ 	assert(cb);
+@@ -1138,7 +1139,7 @@ int nfnl_callback_register(struct nfnl_subsys_handle *ssh,
+  * On sucess, 0 is returned. On error, -1 is returned and errno is
+  * set appropiately.
+  */
+-int nfnl_callback_unregister(struct nfnl_subsys_handle *ssh, u_int8_t type)
++int nfnl_callback_unregister(struct nfnl_subsys_handle *ssh, uint8_t type)
+ {
+ 	assert(ssh);
+ 
+@@ -1161,8 +1162,8 @@ int nfnl_check_attributes(const struct nfnl_handle *h,
+ 	assert(nfa);
+ 
+ 	int min_len;
+-	u_int8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type);
+-	u_int8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type);
++	uint8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type);
++	uint8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type);
+ 	const struct nfnl_subsys_handle *ssh;
+ 	struct nfnl_callback *cb;
+ 
+@@ -1212,8 +1213,8 @@ static int __nfnl_handle_msg(struct nfnl_handle *h, struct nlmsghdr *nlh,
+ 			     int len)
+ {
+ 	struct nfnl_subsys_handle *ssh;
+-	u_int8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type);
+-	u_int8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type);
++	uint8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type);
++	uint8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type);
+ 	int err = 0;
+ 
+ 	if (subsys_id > NFNL_MAX_SUBSYS)
+@@ -1243,7 +1244,7 @@ int nfnl_handle_packet(struct nfnl_handle *h, char *buf, int len)
+ {
+ 
+ 	while (len >= NLMSG_SPACE(0)) {
+-		u_int32_t rlen;
++		uint32_t rlen;
+ 		struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
+ 
+ 		if (nlh->nlmsg_len < sizeof(struct nlmsghdr)
+@@ -1285,8 +1286,8 @@ static int nfnl_is_error(struct nfnl_handle *h, struct nlmsghdr *nlh)
+ static int nfnl_step(struct nfnl_handle *h, struct nlmsghdr *nlh)
+ {
+ 	struct nfnl_subsys_handle *ssh;
+-	u_int8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type);
+-	u_int8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type);
++	uint8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type);
++	uint8_t subsys_id = NFNL_SUBSYS_ID(nlh->nlmsg_type);
+ 
+ 	/* Is this an error message? */
+ 	if (nfnl_is_error(h, nlh)) {
+diff --git a/src/rtnl.c b/src/rtnl.c
+index 7b4ac7d..34802fe 100644
+--- a/src/rtnl.c
++++ b/src/rtnl.c
+@@ -11,6 +11,7 @@
+ /* rtnetlink - routing table netlink interface */
+ 
+ #include <unistd.h>
++#include <stdint.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <errno.h>
+@@ -30,7 +31,7 @@
+ #define rtnl_log(x, ...)
+ 
+ static inline struct rtnl_handler *
+-find_handler(struct rtnl_handle *rtnl_handle, u_int16_t type)
++find_handler(struct rtnl_handle *rtnl_handle, uint16_t type)
+ {
+ 	struct rtnl_handler *h;
+ 	for (h = rtnl_handle->handlers; h; h = h->next) {
+@@ -41,7 +42,7 @@ find_handler(struct rtnl_handle *rtnl_handle, u_int16_t type)
+ }
+ 
+ static int call_handler(struct rtnl_handle *rtnl_handle,
+-			u_int16_t type,
++			uint16_t type,
+ 			struct nlmsghdr *hdr)
+ {
+ 	struct rtnl_handler *h = find_handler(rtnl_handle, type);
+diff --git a/src/rtnl.h b/src/rtnl.h
+index 0c403dc..9858ae5 100644
+--- a/src/rtnl.h
++++ b/src/rtnl.h
+@@ -1,13 +1,14 @@
+ #ifndef _RTNL_H
+ #define _RTNL_H
+ 
++#include <stdint.h>
+ #include <linux/types.h>
+ #include <linux/rtnetlink.h>
+ 
+ struct rtnl_handler {
+ 	struct rtnl_handler *next;
+ 
+-	u_int16_t	nlmsg_type;
++	uint16_t	nlmsg_type;
+ 	int		(*handlefn)(struct nlmsghdr *h, void *arg);
+ 	void		*arg;
+ };
diff --git a/pkgs/development/libraries/libnfnetlink/default.nix b/pkgs/development/libraries/libnfnetlink/default.nix
index be60612a4ff2..5395b5b2e99c 100644
--- a/pkgs/development/libraries/libnfnetlink/default.nix
+++ b/pkgs/development/libraries/libnfnetlink/default.nix
@@ -8,6 +8,10 @@ stdenv.mkDerivation rec {
     sha256 = "06mm2x4b01k3m7wnrxblk9j0mybyr4pfz28ml7944xhjx6fy2w7j";
   };
 
+  patches = [
+    ./Use-stdlib-uint-instead-of-u_int.patch
+  ];
+
   meta = {
     description = "Low-level library for netfilter related kernel/userspace communication";
     longDescription = ''
diff --git a/pkgs/development/libraries/libnfs/default.nix b/pkgs/development/libraries/libnfs/default.nix
index d9149a1fbac5..2955aaebc010 100644
--- a/pkgs/development/libraries/libnfs/default.nix
+++ b/pkgs/development/libraries/libnfs/default.nix
@@ -13,6 +13,8 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ autoreconfHook ];
 
+  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.cc.isClang "-Wno-error=tautological-compare";
+
   enableParallelBuilding = true;
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libnftnl/default.nix b/pkgs/development/libraries/libnftnl/default.nix
index 074c1a9dfd28..ad8c7626661e 100644
--- a/pkgs/development/libraries/libnftnl/default.nix
+++ b/pkgs/development/libraries/libnftnl/default.nix
@@ -1,11 +1,12 @@
 { stdenv, fetchurl, pkgconfig, libmnl }:
 
 stdenv.mkDerivation rec {
-  name = "libnftnl-1.0.7";
+  version = "1.0.9";
+  name = "libnftnl-${version}";
 
   src = fetchurl {
-    url = "http://netfilter.org/projects/libnftnl/files/${name}.tar.bz2";
-    sha256 = "10irjrylcfkbp11617yr19vpfhgl54w0kw02jhj0i1abqv5nxdlv";
+    url = "https://netfilter.org/projects/libnftnl/files/${name}.tar.bz2";
+    sha256 = "0d9nkdbdck8sg6msysqyv3m9kjr9sjif5amf26dfa0g3mqjdihgy";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/libngspice/default.nix b/pkgs/development/libraries/libngspice/default.nix
new file mode 100644
index 000000000000..b6d5912581ba
--- /dev/null
+++ b/pkgs/development/libraries/libngspice/default.nix
@@ -0,0 +1,25 @@
+{stdenv, fetchurl, bison, flex, fftw}:
+
+# Note that this does not provide the ngspice command-line utility. For that see
+# the ngspice derivation.
+stdenv.mkDerivation {
+  name = "libngspice-26";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/ngspice/ngspice-26.tar.gz";
+    sha256 = "51e230c8b720802d93747bc580c0a29d1fb530f3dd06f213b6a700ca9a4d0108";
+  };
+
+  nativeBuildInputs = [ flex bison ];
+  buildInputs = [ fftw ];
+
+  configureFlags = [ "--with-ngshared" "--enable-xspice" "--enable-cider" ];
+
+  meta = with stdenv.lib; {
+    description = "The Next Generation Spice (Electronic Circuit Simulator)";
+    homepage = http://ngspice.sourceforge.net;
+    license = with licenses; [ "BSD" gpl2 ];
+    maintainers = with maintainers; [ bgamari ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/libnice/default.nix b/pkgs/development/libraries/libnice/default.nix
index 7e9ae1608d2b..c7967c3fb6fc 100644
--- a/pkgs/development/libraries/libnice/default.nix
+++ b/pkgs/development/libraries/libnice/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, glib, gupnp_igd, gst_all_1, gnutls }:
+{ stdenv, fetchurl, pkgconfig, glib, gupnp-igd, gst_all_1, gnutls }:
 
 stdenv.mkDerivation rec {
   name = "libnice-0.1.14";
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ gst_all_1.gstreamer gst_all_1.gst-plugins-base gnutls ];
-  propagatedBuildInputs = [ glib gupnp_igd ];
+  propagatedBuildInputs = [ glib gupnp-igd ];
 
   meta = {
     homepage = https://nice.freedesktop.org/wiki/;
diff --git a/pkgs/development/libraries/libnsl/cdefs.patch b/pkgs/development/libraries/libnsl/cdefs.patch
new file mode 100644
index 000000000000..dbbe800a3479
--- /dev/null
+++ b/pkgs/development/libraries/libnsl/cdefs.patch
@@ -0,0 +1,30 @@
+--- a/src/rpcsvc/nislib.h
++++ b/src/rpcsvc/nislib.h
+@@ -19,6 +19,7 @@
+ #ifndef	__RPCSVC_NISLIB_H__
+ #define	__RPCSVC_NISLIB_H__
+ 
++#include <sys/cdefs.h>
+ #include <features.h>
+ 
+ __BEGIN_DECLS
+--- a/src/rpcsvc/ypclnt.h
++++ b/src/rpcsvc/ypclnt.h
+@@ -20,6 +20,7 @@
+ #ifndef	__RPCSVC_YPCLNT_H__
+ #define	__RPCSVC_YPCLNT_H__
+ 
++#include <sys/cdefs.h>
+ #include <features.h>
+ 
+ /* Some defines */
+--- a/src/rpcsvc/ypupd.h
++++ b/src/rpcsvc/ypupd.h
+@@ -33,6 +33,7 @@
+ #ifndef __RPCSVC_YPUPD_H__
+ #define __RPCSVC_YPUPD_H__
+ 
++#include <sys/cdefs.h>
+ #include <features.h>
+ 
+ #include <rpc/rpc.h>
diff --git a/pkgs/development/libraries/libnsl/default.nix b/pkgs/development/libraries/libnsl/default.nix
new file mode 100644
index 000000000000..9e8a46b2e6b3
--- /dev/null
+++ b/pkgs/development/libraries/libnsl/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, libtirpc, pkgconfig }:
+
+stdenv.mkDerivation rec {
+  name = "libnsl-${version}";
+  version = "1.1.0";
+
+  src = fetchFromGitHub {
+    owner = "thkukuk";
+    repo = "libnsl";
+    rev = "libnsl-${version}";
+    sha256 = "0h8br0gmgw3fp5fmy6bfbj1qlk9hry1ssg25ssjgxbd8spczpscs";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ libtirpc ];
+
+  patches = stdenv.lib.optionals stdenv.hostPlatform.isMusl [ ./cdefs.patch ./nis_h.patch ];
+
+  meta = with stdenv.lib; {
+    description = "Client interface library for NIS(YP) and NIS+";
+    homepage = https://github.com/thkukuk/libnsl;
+    license = licenses.lgpl21;
+    maintainers = [ maintainers.dezgeg ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/libnsl/nis_h.patch b/pkgs/development/libraries/libnsl/nis_h.patch
new file mode 100644
index 000000000000..199259df2e8d
--- /dev/null
+++ b/pkgs/development/libraries/libnsl/nis_h.patch
@@ -0,0 +1,45 @@
+--- a/src/rpcsvc/nis.h
++++ b/src/rpcsvc/nis.h
+@@ -32,6 +32,7 @@
+ #ifndef _RPCSVC_NIS_H
+ #define _RPCSVC_NIS_H 1
+ 
++#include <sys/cdefs.h>
+ #include <features.h>
+ #include <rpc/rpc.h>
+ #include <rpcsvc/nis_tags.h>
+@@ -56,6 +57,34 @@
+  *                                              <kukuk@suse.de>
+  */
+ 
++#ifndef rawmemchr
++#define rawmemchr(s,c) memchr((s),(size_t)-1,(c))
++#endif
++
++#ifndef __asprintf
++#define __asprintf asprintf
++#endif
++
++#ifndef __mempcpy
++#define __mempcpy mempcpy
++#endif
++
++#ifndef __strtok_r
++#define __strtok_r strtok_r
++#endif
++
++#ifndef __always_inline
++#define __always_inline __attribute__((__always_inline__))
++#endif
++
++#ifndef TEMP_FAILURE_RETRY
++#define TEMP_FAILURE_RETRY(exp) ({ \
++typeof (exp) _rc; \
++ do { \
++  _rc = (exp); \
++ } while (_rc == -1 && errno == EINTR); \
++ _rc; })
++#endif
+ 
+ #ifndef __nis_object_h
+ #define __nis_object_h
diff --git a/pkgs/development/libraries/libofx/default.nix b/pkgs/development/libraries/libofx/default.nix
index 77c049949564..1c8f33d82f72 100644
--- a/pkgs/development/libraries/libofx/default.nix
+++ b/pkgs/development/libraries/libofx/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, opensp, pkgconfig, libxml2, curl }:
         
 stdenv.mkDerivation rec {
-  name = "libofx-0.9.10";
+  name = "libofx-0.9.12";
 
   src = fetchurl {
     url = "mirror://sourceforge/libofx/${name}.tar.gz";
-    sha256 = "15gnbh4mszfxk70srdcjkdykk7dbhzqxi3pxgh48a9zg8i4nmqjl";
+    sha256 = "0wvkgffq9qjhjrggg8r1nbhmw65j3lcl4y4cdpmmkrqiz9ia0py1";
   };
 
   configureFlags = [ "--with-opensp-includes=${opensp}/include/OpenSP" ];
diff --git a/pkgs/development/libraries/libogg/default.nix b/pkgs/development/libraries/libogg/default.nix
index c5cb85d91ba2..8bf62890fac4 100644
--- a/pkgs/development/libraries/libogg/default.nix
+++ b/pkgs/development/libraries/libogg/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "libogg-1.3.2";
+  name = "libogg-1.3.3";
 
   src = fetchurl {
     url = "http://downloads.xiph.org/releases/ogg/${name}.tar.xz";
-    sha256 = "16z74q422jmprhyvy7c9x909li8cqzmvzyr8cgbm52xcsp6pqs1z";
+    sha256 = "022wjlzn8fx7mfby4pcgyjwx8zir7jr7cizichh3jgaki8bwcgsg";
   };
 
   outputs = [ "out" "dev" "doc" ];
diff --git a/pkgs/development/libraries/libomxil-bellagio/default.nix b/pkgs/development/libraries/libomxil-bellagio/default.nix
index 5140402eacb9..28c8a915c635 100644
--- a/pkgs/development/libraries/libomxil-bellagio/default.nix
+++ b/pkgs/development/libraries/libomxil-bellagio/default.nix
@@ -8,7 +8,10 @@ stdenv.mkDerivation rec {
     url = "mirror://sourceforge/omxil/omxil/Bellagio%20${version}/${name}.tar.gz";
     sha256 = "0k6p6h4npn8p1qlgq6z3jbfld6n1bqswzvxzndki937gr0lhfg2r";
   };
-  
+
+  configureFlags =
+    stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ "ac_cv_func_malloc_0_nonnull=yes" ];
+
   patches = [ ./fedora-fixes.patch ];
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libopcodes/default.nix b/pkgs/development/libraries/libopcodes/default.nix
new file mode 100644
index 000000000000..c918c61abf0d
--- /dev/null
+++ b/pkgs/development/libraries/libopcodes/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, buildPackages
+, fetchurl, autoreconfHook264, bison, binutils-unwrapped
+, libiberty, libbfd
+}:
+
+stdenv.mkDerivation rec {
+  name = "libopcodes-${version}";
+  inherit (binutils-unwrapped) version src;
+
+  outputs = [ "out" "dev" ];
+
+  patches = binutils-unwrapped.patches ++ [
+    ../../tools/misc/binutils/build-components-separately.patch
+  ];
+
+  # We just want to build libopcodes
+  postPatch = ''
+    cd opcodes
+    find . ../include/opcode -type f -exec sed {} -i -e 's/"bfd.h"/<bfd.h>/' \;
+  '';
+
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
+  nativeBuildInputs = [ autoreconfHook264 bison ];
+  buildInputs = [ libiberty ];
+  # dis-asm.h includes bfd.h
+  propagatedBuildInputs = [ libbfd ];
+
+  configurePlatforms = [ "build" "host" ];
+  configureFlags = [
+    "--enable-targets=all" "--enable-64-bit-bfd"
+    "--enable-install-libbfd"
+    "--enable-shared"
+  ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "A library from binutils for manipulating machine code";
+    homepage = http://www.gnu.org/software/binutils/;
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ ericson2314 ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/libosinfo/default.nix b/pkgs/development/libraries/libosinfo/default.nix
index db534d20c89c..0175e21bbc72 100644
--- a/pkgs/development/libraries/libosinfo/default.nix
+++ b/pkgs/development/libraries/libosinfo/default.nix
@@ -1,23 +1,43 @@
-{ stdenv, fetchurl, pkgconfig, intltool, gobjectIntrospection, libsoup
-, libxslt, check, vala_0_23 ? null
+{ stdenv, fetchurl, pkgconfig, intltool, gobjectIntrospection, gtk-doc, docbook_xsl
+, glib, libsoup, libxml2, libxslt, check, curl, perl, hwdata, osinfo-db, vala ? null
 }:
 
 stdenv.mkDerivation rec {
-  name = "libosinfo-0.2.12";
+  name = "libosinfo-1.1.0";
 
   src = fetchurl {
-    url = "https://fedorahosted.org/releases/l/i/libosinfo/${name}.tar.gz";
-    sha256 = "1vcg8ylh7q69s9y6hj94dqfffwfbann3i28yqgfc01navf6yl07s";
+    url = "https://releases.pagure.org/libosinfo/${name}.tar.gz";
+    sha256 = "0diigllgni6m0sc2h8aid6hmyaq9qb54pm5305m0irfsm2j463v0";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [
-    intltool gobjectIntrospection libsoup libxslt check vala_0_23
+  outputs = [ "out" "dev" "devdoc" ];
+
+  nativeBuildInputs = [
+    pkgconfig vala intltool gobjectIntrospection gtk-doc docbook_xsl
+  ] ++ stdenv.lib.optionals doCheck checkInputs;
+  checkInputs = [ check curl perl ];
+  buildInputs = [ glib libsoup libxml2 libxslt ];
+
+  patches = [
+    ./osinfo-db-data-dir.patch
+  ];
+
+  postPatch = ''
+    patchShebangs .
+    substituteInPlace osinfo/osinfo_loader.c --subst-var-by OSINFO_DB_DATA_DIR "${osinfo-db}/share"
+  '';
+
+  configureFlags = [
+    "--with-usb-ids-path=${hwdata}/data/hwdata/usb.ids"
+    "--with-pci-ids-path=${hwdata}/data/hwdata/pci.ids"
+    "--enable-gtk-doc"
   ];
 
+  doCheck = true;
+
   meta = with stdenv.lib; {
-    description = "Info about OSs, hypervisors and (virtual) hardware devices";
-    homepage = http://libosinfo.org/;
+    description = "GObject based library API for managing information about operating systems, hypervisors and the (virtual) hardware devices they can support";
+    homepage = https://libosinfo.org/;
     license = licenses.lgpl2Plus;
     platforms = platforms.linux;
     maintainers = [ maintainers.bjornfor ];
diff --git a/pkgs/development/libraries/libosinfo/osinfo-db-data-dir.patch b/pkgs/development/libraries/libosinfo/osinfo-db-data-dir.patch
new file mode 100644
index 000000000000..8d202a92d095
--- /dev/null
+++ b/pkgs/development/libraries/libosinfo/osinfo-db-data-dir.patch
@@ -0,0 +1,11 @@
+--- a/osinfo/osinfo_loader.c
++++ b/osinfo/osinfo_loader.c
+@@ -2304,7 +2304,7 @@
+     } else {
+         path = g_getenv("OSINFO_SYSTEM_DIR");
+         if (!path)
+-            path = DATA_DIR "/osinfo";
++            path = "@OSINFO_DB_DATA_DIR@/osinfo";
+ 
+         file = g_file_new_for_path(path);
+     }
diff --git a/pkgs/development/libraries/libowfat/default.nix b/pkgs/development/libraries/libowfat/default.nix
index aaa1abacab80..1304aff9e3b3 100644
--- a/pkgs/development/libraries/libowfat/default.nix
+++ b/pkgs/development/libraries/libowfat/default.nix
@@ -1,18 +1,18 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "libowfat-0.29";
+  name = "libowfat-0.31";
 
   src = fetchurl {
-    url = "http://dl.fefe.de/${name}.tar.bz2";
-    sha256 = "09v4phf1d4y617fdqwn214jmkialf7xqcsyx3rzk7x5ysvpbvbab";
+    url = "https://www.fefe.de/libowfat/${name}.tar.xz";
+    sha256 = "04lagr62bd2cr0k8h59qfnx2klh2cf73k5kxsx8xrdybzhfarr6i";
   };
 
   makeFlags = "prefix=$(out)";
-  
+
   meta = with stdenv.lib; {
     homepage = http://www.fefe.de/libowfat/;
     license = licenses.gpl2;
     platforms = platforms.linux;
   };
-}
\ No newline at end of file
+}
diff --git a/pkgs/development/libraries/libp11/default.nix b/pkgs/development/libraries/libp11/default.nix
index 26e754317df0..54e2616e782f 100644
--- a/pkgs/development/libraries/libp11/default.nix
+++ b/pkgs/development/libraries/libp11/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "libp11-${version}";
-  version = "0.4.4";
+  version = "0.4.7";
 
   src = fetchFromGitHub {
     owner = "OpenSC";
     repo = "libp11";
     rev = name;
-    sha256 = "1jnpnwipmw3skw112qff36w046nyz5amiil228rn5divpkvx4axa";
+    sha256 = "0n1i0pxj6l0vdq8gpdwfp5p9qd7wkymg0lpy6a17ix8hpqsljlhr";
   };
 
   makeFlags = [ "DESTDIR=$(out)" "PREFIX=" ];
diff --git a/pkgs/development/libraries/libpar2/default.nix b/pkgs/development/libraries/libpar2/default.nix
index 6d7606428f69..cf97744069b3 100644
--- a/pkgs/development/libraries/libpar2/default.nix
+++ b/pkgs/development/libraries/libpar2/default.nix
@@ -15,6 +15,8 @@ stdenv.mkDerivation rec {
 
   patches = [ ./libpar2-0.4-external-verification.patch ];
 
+  CXXFLAGS = stdenv.lib.optionalString stdenv.cc.isClang "-std=c++11";
+
   meta = {
     homepage = http://parchive.sourceforge.net/;
     license = stdenv.lib.licenses.gpl2Plus;
diff --git a/pkgs/development/libraries/libpcap/default.nix b/pkgs/development/libraries/libpcap/default.nix
index 0cd9d758725c..bef5f9a9da34 100644
--- a/pkgs/development/libraries/libpcap/default.nix
+++ b/pkgs/development/libraries/libpcap/default.nix
@@ -26,6 +26,15 @@ stdenv.mkDerivation rec {
       url    = "https://sources.debian.net/data/main/libp/libpcap/1.8.1-3/debian/patches/disable-remote.diff";
       sha256 = "0dvjax9c0spvq8cdjnkbnm65wlzaml259yragf95kzg611vszfmj";
     })
+    # See https://github.com/wjt/bustle/commit/f62cf6bfa662af4ae39effbbd4891bc619e3b4e9
+    (fetchpatch {
+      url    = "https://github.com/the-tcpdump-group/libpcap/commit/2be9c29d45fb1fab8e9549342a30c160b7dea3e1.patch";
+      sha256 = "1g8mh942vr0abn48g0bdvi4gmhq1bz0l80276603y7064qhy3wq5";
+    })
+    (fetchpatch {
+      url    = "https://github.com/the-tcpdump-group/libpcap/commit/1a6b088a88886eac782008f37a7219a32b86da45.patch";
+      sha256 = "1n5ylm7ch3i1lh4y2q16b0vabgym8g8mqiqxpqcdkjdn05c1wflr";
+    })
   ];
 
   preInstall = ''mkdir -p $out/bin'';
diff --git a/pkgs/development/libraries/libpfm/default.nix b/pkgs/development/libraries/libpfm/default.nix
index 34b09d45044d..a74d838e2eb6 100644
--- a/pkgs/development/libraries/libpfm/default.nix
+++ b/pkgs/development/libraries/libpfm/default.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  version = "4.8.0";
+  version = "4.9.0";
   name = "libpfm-${version}";
 
   src = fetchurl {
     url = "mirror://sourceforge/perfmon2/libpfm4/${name}.tar.gz";
-    sha256 = "0s6gcvrhj2h928cqc8399189annif7yl74k6wda446r0fdx7i4wi";
+    sha256 = "1qp4g4n6dw42p2w5rkwzdb7ynk8h7g5vg01ybpmvxncgwa7bw3yv";
   };
 
   installFlags = "DESTDIR=\${out} PREFIX= LDCONFIG=true";
diff --git a/pkgs/development/libraries/libpinyin/default.nix b/pkgs/development/libraries/libpinyin/default.nix
index 15d141990417..26694eb37770 100644
--- a/pkgs/development/libraries/libpinyin/default.nix
+++ b/pkgs/development/libraries/libpinyin/default.nix
@@ -2,14 +2,13 @@
 
 let
   modelData = fetchurl {
-    url    = "mirror://sourceforge/libpinyin/models/model12.text.tar.gz";
-    sha256 = "1fijhhnjgj8bj1xr5pp7c4qxf11cqybgfqg7v36l3x780d84hfnd";
+    url    = "mirror://sourceforge/libpinyin/models/model14.text.tar.gz";
+    sha256 = "0qqk30nflj07zjhs231c95ln4yj4ipzwxxiwrxazrg4hb8bhypqq";
   };
 in
-
 stdenv.mkDerivation rec {
   name = "libpinyin-${version}";
-  version = "1.6.0";
+  version = "2.1.91";
 
   nativeBuildInputs = [ autoreconfHook glib db pkgconfig ];
 
@@ -21,7 +20,7 @@ stdenv.mkDerivation rec {
     owner  = "libpinyin";
     repo   = "libpinyin";
     rev    = version;
-    sha256 = "0k40a7wfp8zj9d426afv0am5sr3m2i2p309fq0vf8qrb050hj17f";
+    sha256 = "0jbvn65p3zh0573hh27aasd3qly5anyfi8jnps2dxi0my09wbrq3";
   };
 
   meta = with stdenv.lib; {
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/libpng/default.nix b/pkgs/development/libraries/libpng/default.nix
index c4a6a246b909..5ad9cf1e7b77 100644
--- a/pkgs/development/libraries/libpng/default.nix
+++ b/pkgs/development/libraries/libpng/default.nix
@@ -30,7 +30,7 @@ in stdenv.mkDerivation rec {
 
   # it's hard to cross-run tests and some check programs didn't compile anyway
   makeFlags = stdenv.lib.optional (!doCheck) "check_PROGRAMS=";
-  doCheck = hostPlatform == buildPlatform;
+  doCheck = true; # not cross;
 
   passthru = { inherit zlib; };
 
diff --git a/pkgs/development/libraries/libpqxx/default.nix b/pkgs/development/libraries/libpqxx/default.nix
index 51cb1c48e54c..a6dd719a3812 100644
--- a/pkgs/development/libraries/libpqxx/default.nix
+++ b/pkgs/development/libraries/libpqxx/default.nix
@@ -1,14 +1,18 @@
-{ lib, stdenv, fetchurl, postgresql, python2, gnused }:
+{ lib, stdenv, fetchFromGitHub, postgresql, doxygen, xmlto, python2, gnused }:
 
 stdenv.mkDerivation rec {
-  name = "libpqxx-4.0.1";
+  name = "libpqxx-${version}";
+  version = "6.2.2";
 
-  src = fetchurl {
-    url = "http://pqxx.org/download/software/libpqxx/${name}.tar.gz";
-    sha256 = "0f6wxspp6rx12fkasanb0z2g2gc8dhcfwnxagx8wwqbpg6ifsz09";
+  src = fetchFromGitHub {
+    owner = "jtv";
+    repo = "libpqxx";
+    rev = version;
+    sha256 = "0f7mkl29v6d47kkdpl2gkb9xc5lnih2pq9pk3cq6nc2j6w758yp5";
   };
 
-  buildInputs = [ postgresql python2 gnused ];
+  nativeBuildInputs = [ gnused python2 ];
+  buildInputs = [ postgresql doxygen xmlto ];
 
   preConfigure = ''
     patchShebangs .
diff --git a/pkgs/development/libraries/libproxy/default.nix b/pkgs/development/libraries/libproxy/default.nix
index 614890e929f7..bf9e2d079cd6 100644
--- a/pkgs/development/libraries/libproxy/default.nix
+++ b/pkgs/development/libraries/libproxy/default.nix
@@ -1,5 +1,6 @@
-{ stdenv, lib, fetchFromGitHub, pkgconfig, cmake
-, dbus, networkmanager, spidermonkey_38, pcre, python2, python3 }:
+{ stdenv, lib, fetchFromGitHub, pkgconfig, cmake, zlib
+, dbus, networkmanager, spidermonkey_38, pcre, python2, python3
+, SystemConfiguration, CoreFoundation, JavaScriptCore }:
 
 stdenv.mkDerivation rec {
   name = "libproxy-${version}";
@@ -16,7 +17,10 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ pkgconfig cmake ];
 
-  buildInputs = [ dbus networkmanager spidermonkey_38 pcre python2 python3 ];
+  buildInputs = [ pcre python2 python3 zlib ]
+        ++ (if stdenv.hostPlatform.isDarwin
+            then [ SystemConfiguration CoreFoundation JavaScriptCore ]
+            else [ spidermonkey_38 dbus networkmanager ]);
 
   preConfigure = ''
     cmakeFlagsArray+=(
@@ -27,7 +31,7 @@ stdenv.mkDerivation rec {
   '';
 
   meta = with stdenv.lib; {
-    platforms = platforms.linux;
+    platforms = platforms.linux ++ platforms.darwin;
     license = licenses.lgpl21;
     homepage = http://libproxy.github.io/libproxy/;
     description = "A library that provides automatic proxy configuration management";
diff --git a/pkgs/development/libraries/libpsl/default.nix b/pkgs/development/libraries/libpsl/default.nix
index c35c7e1bc0f5..f5c92e11c357 100644
--- a/pkgs/development/libraries/libpsl/default.nix
+++ b/pkgs/development/libraries/libpsl/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, autoreconfHook, docbook_xsl, gtk_doc, icu
+{ stdenv, fetchFromGitHub, autoreconfHook, docbook_xsl, gtk-doc, icu
 , libxslt, pkgconfig, python2 }:
 
 let
@@ -25,7 +25,7 @@ in stdenv.mkDerivation rec {
   };
 
   buildInputs = [ icu libxslt ];
-  nativeBuildInputs = [ autoreconfHook docbook_xsl gtk_doc pkgconfig python2 ];
+  nativeBuildInputs = [ autoreconfHook docbook_xsl gtk-doc pkgconfig python2 ];
 
   postPatch = ''
     substituteInPlace src/psl.c --replace bits/stat.h sys/stat.h
@@ -64,6 +64,5 @@ in stdenv.mkDerivation rec {
     homepage = http://rockdaboot.github.io/libpsl/;
     license = licenses.mit;
     platforms = with platforms; linux ++ darwin;
-    maintainers = with maintainers; [ nckx ];
   };
 }
diff --git a/pkgs/development/libraries/libpst/default.nix b/pkgs/development/libraries/libpst/default.nix
index b19008449abe..cb30a890f401 100644
--- a/pkgs/development/libraries/libpst/default.nix
+++ b/pkgs/development/libraries/libpst/default.nix
@@ -2,11 +2,11 @@
   pkgconfig, bzip2, xmlto, gettext, imagemagick, doxygen }:
 
 stdenv.mkDerivation rec {
-  name = "libpst-0.6.70";
+  name = "libpst-0.6.71";
 
   src = fetchurl {
       url = "http://www.five-ten-sg.com/libpst/packages/${name}.tar.gz";
-      sha256 = "1m378vxh1sf9ry8k11x773xpy5f6cab5gkzqglz0jp9hc431r60r";
+      sha256 = "130nksrwgi3ih32si5alvxwzd5kmlg8yi7p03w0h7w9r3b90i4pv";
     };
 
   nativeBuildInputs = [ autoreconfHook pkgconfig ];
diff --git a/pkgs/development/libraries/libqalculate/default.nix b/pkgs/development/libraries/libqalculate/default.nix
index 0e67f970b763..1b15769465e1 100644
--- a/pkgs/development/libraries/libqalculate/default.nix
+++ b/pkgs/development/libraries/libqalculate/default.nix
@@ -3,11 +3,11 @@
 
 stdenv.mkDerivation rec {
   name = "libqalculate-${version}";
-  version = "2.1.0";
+  version = "2.3.0";
 
   src = fetchurl {
     url = "https://github.com/Qalculate/libqalculate/archive/v${version}.tar.gz";
-    sha256 = "036f284bssvavyz6pgpcdafvxa59h2wdrh8xl7nmxxnw9v7n2n7l";
+    sha256 = "1wrd9ajf00h1ja56r25vljjsgklg0qlzmziax7x26wjqkigc28iq";
   };
 
   outputs = [ "out" "dev" "doc" ];
@@ -25,6 +25,9 @@ stdenv.mkDerivation rec {
     substituteInPlace libqalculate/Calculator.cc \
       --replace 'commandline = "gnuplot"' 'commandline = "${gnuplot}/bin/gnuplot"' \
       --replace '"gnuplot -"' '"${gnuplot}/bin/gnuplot -"'
+  '' + stdenv.lib.optionalString stdenv.cc.isClang ''
+    substituteInPlace src/qalc.cc \
+      --replace 'printf(_("aborted"))' 'printf("%s", _("aborted"))'
   '';
 
   preBuild = ''
diff --git a/pkgs/development/libraries/libqglviewer/default.nix b/pkgs/development/libraries/libqglviewer/default.nix
index eef9e05ca036..e68c5052beb8 100644
--- a/pkgs/development/libraries/libqglviewer/default.nix
+++ b/pkgs/development/libraries/libqglviewer/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, qt4, qmake4Hook }:
+{ stdenv, fetchurl, qt4, qmake4Hook, AGL }:
 
 stdenv.mkDerivation rec {
   name = "libqglviewer-2.6.3";
@@ -9,7 +9,8 @@ stdenv.mkDerivation rec {
     sha256 = "00jdkyk4wg1356c3ar6nk3hyp494ya3yvshq9m57kfmqpn3inqdy";
   };
 
-  buildInputs = [ qt4 qmake4Hook ];
+  buildInputs = [ qt4 qmake4Hook ]
+    ++ stdenv.lib.optional stdenv.isDarwin AGL;
 
   postPatch =
     ''
diff --git a/pkgs/development/libraries/libqmatrixclient/default.nix b/pkgs/development/libraries/libqmatrixclient/default.nix
new file mode 100644
index 000000000000..f537013d2fec
--- /dev/null
+++ b/pkgs/development/libraries/libqmatrixclient/default.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchFromGitHub, cmake
+, qtbase }:
+
+# This doesn't actually do anything really yet as it doesn't support dynamic building
+# When it does, quaternion and tensor should use it
+
+stdenv.mkDerivation rec {
+  name = "libqmatrixclient-${version}";
+  version = "0.2";
+
+  src = fetchFromGitHub {
+    owner  = "QMatrixClient";
+    repo   = "libqmatrixclient";
+    rev    = "v${version}-q0.0.5";
+    sha256 = "1m53yxsqjxv2jq0h1xipwsgaj5rca4fk4cl3azgvmf19l9yn00ck";
+  };
+
+  buildInputs = [ qtbase ];
+
+  nativeBuildInputs = [ cmake ];
+
+  enableParallelBuilding = true;
+
+  installPhase = ''
+    runHook preInstall
+
+    install -Dm644 -t $out/lib *.a
+
+    runHook postInstall
+  '';
+
+  meta = with stdenv.lib; {
+    description= "A Qt5 library to write cross-platfrom clients for Matrix";
+    homepage = https://matrix.org/docs/projects/sdk/libqmatrixclient.html;
+    license = licenses.lgpl21;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ peterhoeg ];
+    hydraPlatforms = [ ];
+  };
+}
diff --git a/pkgs/development/libraries/libqmi/default.nix b/pkgs/development/libraries/libqmi/default.nix
index afa8a0451ac0..a0f5ac737679 100644
--- a/pkgs/development/libraries/libqmi/default.nix
+++ b/pkgs/development/libraries/libqmi/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, pkgconfig, glib, python, libgudev, libmbim }:
 
 stdenv.mkDerivation rec {
-  name = "libqmi-1.18.0";
+  name = "libqmi-1.20.0";
 
   src = fetchurl {
     url = "https://www.freedesktop.org/software/libqmi/${name}.tar.xz";
-    sha256 = "1v4cz3nsmh7nn3smhlhwzrb7yh6l1f270bwf40qacxayjdajr950";
+    sha256 = "1d3fca477sdwbv4bsq1cl98qc8sixrzp0gqjcmjj8mlwfk9qqhi1";
   };
 
   outputs = [ "out" "dev" "devdoc" ];
diff --git a/pkgs/development/libraries/libqrencode/default.nix b/pkgs/development/libraries/libqrencode/default.nix
index 337d9423aa3d..7c1844bf281e 100644
--- a/pkgs/development/libraries/libqrencode/default.nix
+++ b/pkgs/development/libraries/libqrencode/default.nix
@@ -3,12 +3,12 @@
 
 stdenv.mkDerivation rec {
   name = "libqrencode-${version}";
-  version = "3.4.4";
+  version = "4.0.0";
 
   src = fetchurl {
     url = "https://fukuchi.org/works/qrencode/qrencode-${version}.tar.gz";
     sha1 = "644054a76c8b593acb66a8c8b7dcf1b987c3d0b2";
-    sha256 = "0wiagx7i8p9zal53smf5abrnh9lr31mv0p36wg017401jrmf5577";
+    sha256 = "10da4q5pym7pzxcv21w2kc2rxmq7sp1rg58zdklwfr0jjci1nqjv";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/libqtav/default.nix b/pkgs/development/libraries/libqtav/default.nix
index 93d8ced49cea..b291ec2fdf0b 100644
--- a/pkgs/development/libraries/libqtav/default.nix
+++ b/pkgs/development/libraries/libqtav/default.nix
@@ -1,6 +1,6 @@
 { mkDerivation, lib, fetchFromGitHub, extra-cmake-modules
 , qtbase, qtmultimedia, qtquick1, qttools
-, mesa, libX11
+, libGLU_combined, libX11
 , libass, openal, ffmpeg, libuchardet
 , alsaLib, libpulseaudio, libva
 }:
@@ -14,7 +14,7 @@ mkDerivation rec {
   nativeBuildInputs = [ extra-cmake-modules qttools ];
   buildInputs = [
     qtbase qtmultimedia qtquick1
-    mesa libX11
+    libGLU_combined libX11
     libass openal ffmpeg libuchardet
     alsaLib libpulseaudio libva
   ];
@@ -28,9 +28,9 @@ mkDerivation rec {
   };
 
   # Make sure libqtav finds its libGL dependancy at both link and run time
-  # by adding mesa to rpath. Not sure why it wasn't done automatically like
-  # the other libraries as `mesa` is part of our `buildInputs`.
-  NIX_CFLAGS_LINK = [ "-Wl,-rpath,${mesa}/lib"];
+  # by adding libGLU_combined to rpath. Not sure why it wasn't done automatically like
+  # the other libraries as `libGLU_combined` is part of our `buildInputs`.
+  NIX_CFLAGS_LINK = [ "-Wl,-rpath,${libGLU_combined}/lib"];
 
   preFixup = ''
     mkdir -p "$out/bin"
diff --git a/pkgs/development/libraries/libraw/default.nix b/pkgs/development/libraries/libraw/default.nix
index 0b88cd02df70..d4ad1c038601 100644
--- a/pkgs/development/libraries/libraw/default.nix
+++ b/pkgs/development/libraries/libraw/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libraw-${version}";
-  version = "0.18.5";
+  version = "0.18.8";
 
   src = fetchurl {
     url = "http://www.libraw.org/data/LibRaw-${version}.tar.gz";
-    sha256 = "0y519nlvl4bfnnxbwry35f6gbcv6jbbpd2lmiwv6pbyzv4a7saps";
+    sha256 = "1qi0fkw2zmd0yplrf79z7lgpz0hxl45dj5rdgpaj7283jzys9b2n";
   };
 
   outputs = [ "out" "lib" "dev" "doc" ];
diff --git a/pkgs/development/libraries/libraw1394/default.nix b/pkgs/development/libraries/libraw1394/default.nix
index c767ef9a9ea7..39d5c64f64fc 100644
--- a/pkgs/development/libraries/libraw1394/default.nix
+++ b/pkgs/development/libraries/libraw1394/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "libraw1394-2.1.1";
+  name = "libraw1394-2.1.2";
 
   src = fetchurl {
     url = "mirror://kernel/linux/libs/ieee1394/${name}.tar.gz";
-    sha256 = "0x6az154wr7wv3945485grjvpk604khv34dbaph6vmc1zdasqq59";
+    sha256 = "0z5md84941ky5l7afayx2z6j0sk0mildxbjajq6niznd44ky7i6x";
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/librdf/rasqal.nix b/pkgs/development/libraries/librdf/rasqal.nix
index 56272b319917..ceff244670f3 100644
--- a/pkgs/development/libraries/librdf/rasqal.nix
+++ b/pkgs/development/libraries/librdf/rasqal.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, librdf_raptor2, gmp, pkgconfig, pcre, libxml2 }:
 
 stdenv.mkDerivation rec {
-  name = "rasqal-0.9.32";
+  name = "rasqal-0.9.33";
 
   src = fetchurl {
     url = "http://download.librdf.org/source/${name}.tar.gz";
-    sha256 = "eeba03218e3b7dfa033934d523a1a64671a9a0f64eadc38a01e4b43367be2e8f";
+    sha256 = "0z6rrwn4jsagvarg8d5zf0j352kjgi33py39jqd29gbhcnncj939";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/librdf/redland.nix b/pkgs/development/libraries/librdf/redland.nix
index 8e6fa005635f..402af5d6f583 100644
--- a/pkgs/development/libraries/librdf/redland.nix
+++ b/pkgs/development/libraries/librdf/redland.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ perl pkgconfig ];
 
   buildInputs = [ openssl libxslt curl pcre libxml2 ]
-    ++ stdenv.lib.optional withMysql mysql
+    ++ stdenv.lib.optional withMysql mysql.connector-c
     ++ stdenv.lib.optional withSqlite sqlite
     ++ stdenv.lib.optional withPostgresql postgresql
     ++ stdenv.lib.optional withBdb db;
diff --git a/pkgs/development/libraries/librdmacm/default.nix b/pkgs/development/libraries/librdmacm/default.nix
index 791e59cbc906..3b84ead7cec1 100644
--- a/pkgs/development/libraries/librdmacm/default.nix
+++ b/pkgs/development/libraries/librdmacm/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "librdmacm-${version}";
-  version = "1.0.21";
+  version = "1.1.0";
 
   src = fetchurl {
     url = "https://www.openfabrics.org/downloads/rdmacm/${name}.tar.gz";
-    sha256 = "0yx2wr5dvmf5apvc4f4r2f2mlvn05piwvxsqfb60p3rk4jfx56dx";
+    sha256 = "1ic0qd5ayvkybh4pxc5qx7sqvny1fv4anhxlf1nmsn0h926q844g";
   };
 
   buildInputs = [ libibverbs ];
diff --git a/pkgs/development/libraries/libre/default.nix b/pkgs/development/libraries/libre/default.nix
index 8bef305a0ecc..ebe765a0d0d4 100644
--- a/pkgs/development/libraries/libre/default.nix
+++ b/pkgs/development/libraries/libre/default.nix
@@ -1,16 +1,13 @@
 {stdenv, fetchurl, zlib, openssl}:
 stdenv.mkDerivation rec {
-  version = "0.5.1";
+  version = "0.5.7";
   name = "libre-${version}";
-  src=fetchurl {
+  src = fetchurl {
     url = "http://www.creytiv.com/pub/re-${version}.tar.gz";
-    sha256 = "1qs6gpflgwic2pp1nplhhyl585h9q0kf74h5z29ajr5ij0j65rsa";
+    sha256 = "0f8h224xfzvnb2ngvhxz8gzxqjlkkfr6d0nj8zqivzr81ihibk2x";
   };
-  buildInputs = [zlib openssl];
-  makeFlags = [
-    "USE_ZLIB=1" "USE_OPENSSL=1" 
-    ''PREFIX=$(out)''
-  ]
+  buildInputs = [ zlib openssl ];
+  makeFlags = [ "USE_ZLIB=1" "USE_OPENSSL=1" "PREFIX=$(out)" ]
   ++ stdenv.lib.optional (stdenv.cc.cc != null) "SYSROOT_ALT=${stdenv.cc.cc}"
   ++ stdenv.lib.optional (stdenv.cc.libc != null) "SYSROOT=${stdenv.lib.getDev stdenv.cc.libc}"
   ;
diff --git a/pkgs/development/libraries/librelp/default.nix b/pkgs/development/libraries/librelp/default.nix
index adc00b56a287..55bb22e660b0 100644
--- a/pkgs/development/libraries/librelp/default.nix
+++ b/pkgs/development/libraries/librelp/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, pkgconfig, gnutls, zlib }:
 
 stdenv.mkDerivation rec {
-  name = "librelp-1.2.12";
+  name = "librelp-1.2.15";
 
   src = fetchurl {
     url = "http://download.rsyslog.com/librelp/${name}.tar.gz";
-    sha256 = "1mvvxqfsfg96rb6xv3fw7mcsqmyfnsb74sc53gnhpcpp4h2p6m83";
+    sha256 = "16d9km99isa4mwk6psf8brny1sfl45dijlkdwzp0yrjnj0nq6cd9";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/librem/default.nix b/pkgs/development/libraries/librem/default.nix
index a3e98d260cea..f6e041e57322 100644
--- a/pkgs/development/libraries/librem/default.nix
+++ b/pkgs/development/libraries/librem/default.nix
@@ -1,10 +1,10 @@
 {stdenv, fetchurl, zlib, openssl, libre}:
 stdenv.mkDerivation rec {
-  version = "0.5.0";
+  version = "0.5.2";
   name = "librem-${version}";
   src=fetchurl {
     url = "http://www.creytiv.com/pub/rem-${version}.tar.gz";
-    sha256 = "1n1ajy1ccw0xw6bndad4js2pnj977s2angzs7lawadh7x5wnalbb";
+    sha256 = "1sv4986yyq42irk9alwp20gc3r5y0r6kix15sl8qmljgxn0lxigv";
   };
   buildInputs = [zlib openssl libre];
   makeFlags = [
diff --git a/pkgs/development/libraries/librep/default.nix b/pkgs/development/libraries/librep/default.nix
index c74a7981458d..5b3beda1eb8b 100644
--- a/pkgs/development/libraries/librep/default.nix
+++ b/pkgs/development/libraries/librep/default.nix
@@ -7,12 +7,12 @@ with stdenv.lib;
 
 stdenv.mkDerivation rec {
   name = "librep-${version}";
-  version = "0.92.6";
+  version = "0.92.7";
   sourceName = "librep_${version}";
 
   src = fetchurl {
     url = "http://download.tuxfamily.org/librep/${sourceName}.tar.xz";
-    sha256 = "1k6c0hmyzxh8459r790slh9vv9vwy9d7w3nlmrqypbx9mk855hgy";
+    sha256 = "1bmcjl1x1rdh514q9z3hzyjmjmwwwkziipjpjsl301bwmiwrd8a8";
   };
 
   nativeBuildInputs = [ autoreconfHook pkgconfig ];
diff --git a/pkgs/development/libraries/librep/setup-hook.sh b/pkgs/development/libraries/librep/setup-hook.sh
index 420d63d6c513..4d875b693304 100644
--- a/pkgs/development/libraries/librep/setup-hook.sh
+++ b/pkgs/development/libraries/librep/setup-hook.sh
@@ -2,4 +2,4 @@ addRepDLLoadPath () {
     addToSearchPath REP_DL_LOAD_PATH $1/lib/rep
 }
 
-envHooks+=(addRepDLLoadPath)
+addEnvHooks "$hostOffset" addRepDLLoadPath
diff --git a/pkgs/development/libraries/libressl/default.nix b/pkgs/development/libraries/libressl/default.nix
index 4818a720a30c..ae03ef7ecb97 100644
--- a/pkgs/development/libraries/libressl/default.nix
+++ b/pkgs/development/libraries/libressl/default.nix
@@ -33,7 +33,7 @@ in {
   };
 
   libressl_2_6 = generic {
-    version = "2.6.2";
-    sha256 = "0y64grb2zx98rjp2lbwihyhbml4z5ih3v7ydbxdvmabj5d4x4adh";
+    version = "2.6.4";
+    sha256 = "07yi37a2ghsgj2b4w30q1s4d2inqnix7ika1m21y57p9z71212k3";
   };
 }
diff --git a/pkgs/development/libraries/librevenge/default.nix b/pkgs/development/libraries/librevenge/default.nix
index 3523eb5c37bc..2c6e792ae8ce 100644
--- a/pkgs/development/libraries/librevenge/default.nix
+++ b/pkgs/development/libraries/librevenge/default.nix
@@ -21,11 +21,10 @@ stdenv.mkDerivation {
     inherit (s) url sha256;
   };
 
-  # Clang generates warnings in Boost's header files
+  # Clang and gcc-7 generate warnings, and
   # -Werror causes these warnings to be interpreted as errors
   # Simplest solution: disable -Werror
-  configureFlags = if stdenv.cc.isClang
-    then [ "--disable-werror" ] else null;
+  configureFlags = [ "--disable-werror" ];
 
   # Fix an issue with boost 1.59
   # This is fixed upstream so please remove this when updating
diff --git a/pkgs/development/libraries/librime/default.nix b/pkgs/development/libraries/librime/default.nix
index a8877bdb2da9..e6d2612fe626 100644
--- a/pkgs/development/libraries/librime/default.nix
+++ b/pkgs/development/libraries/librime/default.nix
@@ -3,13 +3,13 @@
 
 stdenv.mkDerivation rec {
   name = "librime-${version}";
-  version = "1.2.9";
+  version = "1.3.1";
 
   src = fetchFromGitHub {
     owner = "rime";
     repo = "librime";
-    rev = "rime-${version}";
-    sha256 = "14jgnfm61ynm086x9v7wfmv2p14h0qp8lq4d2jqm21n821jsraj6";
+    rev = "${version}";
+    sha256 = "1y0h3nnz97smx9z8h5fzk4c27mvrwv8kajxffqc43bhyvxvb2jd6";
   };
 
   nativeBuildInputs = [ cmake ];
@@ -23,6 +23,6 @@ stdenv.mkDerivation rec {
     description = "Rime Input Method Engine, the core library";
     license     = licenses.bsd3;
     maintainers = with maintainers; [ sifmelcara ];
-    platforms   = platforms.all;
+    platforms   = platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/libroxml/default.nix b/pkgs/development/libraries/libroxml/default.nix
new file mode 100644
index 000000000000..3993451e19f0
--- /dev/null
+++ b/pkgs/development/libraries/libroxml/default.nix
@@ -0,0 +1,16 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation {
+  name = "libroxml-2.3.0";
+  src = fetchurl {
+    url = "http://download.libroxml.net/pool/v2.x/libroxml-2.3.0.tar.gz";
+    sha256  = "0y0vc9n4rfbimjp28nx4kdfzz08j5xymh5xjy84l9fhfac5z5a0x";
+  };
+  meta = with stdenv.lib; {
+    homepage = "http://www.libroxml.net/";
+    description = "This library is minimum, easy-to-use, C implementation for xml file parsing.";
+    license = licenses.lgpl3;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ mpickering ];
+  };
+}
diff --git a/pkgs/development/libraries/librsvg/default.nix b/pkgs/development/libraries/librsvg/default.nix
index 09a0f4444b54..c2e1739117b5 100644
--- a/pkgs/development/libraries/librsvg/default.nix
+++ b/pkgs/development/libraries/librsvg/default.nix
@@ -1,33 +1,32 @@
 { lib, stdenv, fetchurl, pkgconfig, glib, gdk_pixbuf, pango, cairo, libxml2, libgsf
-, bzip2, libcroco, libintlOrEmpty, darwin
+, bzip2, libcroco, libintl, darwin, rust, gnome3
 , withGTK ? false, gtk3 ? null
-, gobjectIntrospection ? null, enableIntrospection ? false }:
-
-# no introspection by default, it's too big
+, vala, gobjectIntrospection }:
 
+let
+  pname = "librsvg";
+  version = "2.42.2";
+in
 stdenv.mkDerivation rec {
-  name = "librsvg-2.40.19";
+  name = "${pname}-${version}";
 
   src = fetchurl {
-    url    = "mirror://gnome/sources/librsvg/2.40/librsvg-2.40.18.tar.xz";
-    sha256 = "0k2nbd4g31qinkdfd8r5c5ih2ixl85fbkgkqqh9747lwr24c9j5z";
+    url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
+    sha256 = "0c550a0bffef768a436286116c03d9f6cd3f97f5021c13e7f093b550fac12562";
   };
 
-  NIX_LDFLAGS = if stdenv.isDarwin then "-lintl" else null;
-
   outputs = [ "out" "dev" ];
 
-  buildInputs = [ libxml2 libgsf bzip2 libcroco pango libintlOrEmpty ]
-    ++ stdenv.lib.optional enableIntrospection gobjectIntrospection;
+  buildInputs = [ libxml2 libgsf bzip2 libcroco pango libintl ];
 
   propagatedBuildInputs = [ glib gdk_pixbuf cairo ] ++ lib.optional withGTK gtk3;
 
-  nativeBuildInputs = [ pkgconfig ]
+  nativeBuildInputs = [ pkgconfig rust.rustc rust.cargo vala gobjectIntrospection ]
     ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
       ApplicationServices
     ]);
 
-  configureFlags = [ "--enable-introspection=auto" ]
+  configureFlags = [ "--enable-introspection" "--enable-vala" ]
     ++ stdenv.lib.optional stdenv.isDarwin "--disable-Bsymbolic";
 
   NIX_CFLAGS_COMPILE
@@ -60,7 +59,17 @@ stdenv.mkDerivation rec {
     rm $GDK_PIXBUF/loaders.cache.tmp
   '';
 
-  meta = {
-    platforms = stdenv.lib.platforms.unix;
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+    };
+  };
+
+  meta = with stdenv.lib; {
+    description = "A small library to render SVG images to Cairo surfaces";
+    homepage = https://wiki.gnome.org/Projects/LibRsvg;
+    license = licenses.lgpl2Plus;
+    maintainers = gnome3.maintainers;
+    platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/librsync/default.nix b/pkgs/development/libraries/librsync/default.nix
index 3409948f59eb..80acaf57d625 100644
--- a/pkgs/development/libraries/librsync/default.nix
+++ b/pkgs/development/libraries/librsync/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "librsync-${version}";
-  version = "2.0.0";
+  version = "2.0.2";
 
   src = fetchFromGitHub {
     owner = "librsync";
     repo = "librsync";
     rev = "v${version}";
-    sha256 = "0yad7nkw6d8j824qkxrj008ak2wq6yw5p894sbhr35yc1wr5mki6";
+    sha256 = "1qnr4rk93mhggqjh2025clmlhhgnjhq983p1vbh8i1g8aiqdnapi";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/libs3/default.nix b/pkgs/development/libraries/libs3/default.nix
index 2d8b2a3b5f15..540d84dc2440 100644
--- a/pkgs/development/libraries/libs3/default.nix
+++ b/pkgs/development/libraries/libs3/default.nix
@@ -1,17 +1,20 @@
 { stdenv, fetchFromGitHub, curl, libxml2 }:
 
 stdenv.mkDerivation {
-  name = "libs3-2015-04-23";
+  name = "libs3-2017-06-01";
 
   src = fetchFromGitHub {
     owner = "bji";
     repo = "libs3";
-    rev = "11a4e976c28ba525e7d61fbc3867c345a2af1519";
-    sha256 = "0xjjwyw14sk9am6s2m25hxi55vmsrc2yiawd6ln2lvg59xjcr48i";
+    rev = "fd8b149044e429ad30dc4c918f0713cdd40aadd2";
+    sha256 = "0a4c9rsd3wildssvnvph6cd11adn0p3rd4l02z03lvxkjhm20gw3";
   };
 
   buildInputs = [ curl libxml2 ];
 
+  # added to fix build with gcc7, review on update
+  NIX_CFLAGS_COMPILE = [ "-Wno-error=format-truncation" ];
+
   DESTDIR = "\${out}";
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libsass/default.nix b/pkgs/development/libraries/libsass/default.nix
index 75bc9668fca1..ec4fa6b7427a 100644
--- a/pkgs/development/libraries/libsass/default.nix
+++ b/pkgs/development/libraries/libsass/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libsass-${version}";
-  version = "3.4.5";
+  version = "3.5.2";
 
   src = fetchurl {
     url = "https://github.com/sass/libsass/archive/${version}.tar.gz";
-    sha256 = "1j22138l5ymqjfj5zan9d2hipa3ahjmifgpjahqy1smlg5sb837x";
+    sha256 = "1qjpicbjsj9gf8s00ma0d6kw6qfnc29fhrqdkvq8427wfffj654r";
   };
 
   patchPhase = ''
diff --git a/pkgs/development/libraries/libsearpc/default.nix b/pkgs/development/libraries/libsearpc/default.nix
index 3898071c8582..fae6dc82fcf6 100644
--- a/pkgs/development/libraries/libsearpc/default.nix
+++ b/pkgs/development/libraries/libsearpc/default.nix
@@ -28,6 +28,6 @@ stdenv.mkDerivation rec
     description = "A simple and easy-to-use C language RPC framework (including both server side & client side) based on GObject System";
     license = stdenv.lib.licenses.lgpl3;
     platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.calrama ];
+    maintainers = [ ];
   };
 }
diff --git a/pkgs/development/libraries/libseccomp/default.nix b/pkgs/development/libraries/libseccomp/default.nix
index 3b365c0e9712..e0c77a0cf357 100644
--- a/pkgs/development/libraries/libseccomp/default.nix
+++ b/pkgs/development/libraries/libseccomp/default.nix
@@ -2,13 +2,15 @@
 
 stdenv.mkDerivation rec {
   name = "libseccomp-${version}";
-  version = "2.3.2";
+  version = "2.3.3";
 
   src = fetchurl {
     url = "https://github.com/seccomp/libseccomp/releases/download/v${version}/libseccomp-${version}.tar.gz";
-    sha256 = "3ddc8c037956c0a5ac19664ece4194743f59e1ccd4adde848f4f0dae7f77bca1";
+    sha256 = "0mdiyfljrkfl50q1m3ws8yfcyfjwf1zgkvcva8ffcwncji18zhkz";
   };
 
+  outputs = [ "out" "lib" "dev" "man" ];
+
   buildInputs = [ getopt makeWrapper ];
 
   patchPhase = ''
@@ -23,6 +25,7 @@ stdenv.mkDerivation rec {
     homepage    = "https://github.com/seccomp/libseccomp";
     license     = licenses.lgpl21;
     platforms   = platforms.linux;
+    badPlatforms = platforms.riscv;
     maintainers = with maintainers; [ thoughtpolice wkennington ];
   };
 }
diff --git a/pkgs/development/libraries/libsecret/default.nix b/pkgs/development/libraries/libsecret/default.nix
index 0f8207e83c82..b77ba49822fd 100644
--- a/pkgs/development/libraries/libsecret/default.nix
+++ b/pkgs/development/libraries/libsecret/default.nix
@@ -1,25 +1,30 @@
-{ stdenv, fetchurl, glib, pkgconfig, intltool, libxslt, docbook_xsl, gtk_doc
-, libgcrypt, gobjectIntrospection, vala_0_32 }:
+{ stdenv, fetchurl, glib, pkgconfig, intltool, libxslt, docbook_xsl, gtk-doc
+, libgcrypt, gobjectIntrospection, vala_0_38, gnome3, libintl }:
 let
+  pname = "libsecret";
   version = "0.18.5";
 in
 stdenv.mkDerivation rec {
-  name = "libsecret-${version}";
+  name = "${pname}-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/libsecret/0.18/${name}.tar.xz";
+    url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
     sha256 = "1cychxc3ff8fp857iikw0n2s13s2mhw2dn1mr632f7w3sn6vvrww";
   };
 
   outputs = [ "out" "dev" ];
 
-  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-lintl";
-
   propagatedBuildInputs = [ glib ];
-  nativeBuildInputs = [ pkgconfig intltool libxslt docbook_xsl ];
-  buildInputs = [ libgcrypt gobjectIntrospection vala_0_32 ];
+  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)
 
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+    };
+  };
+
   meta = {
     description = "A library for storing and retrieving passwords and other secrets";
     homepage = https://wiki.gnome.org/Projects/Libsecret;
diff --git a/pkgs/development/libraries/libserialport/default.nix b/pkgs/development/libraries/libserialport/default.nix
index 812847ea123b..90f0afa5796c 100644
--- a/pkgs/development/libraries/libserialport/default.nix
+++ b/pkgs/development/libraries/libserialport/default.nix
@@ -4,7 +4,7 @@ stdenv.mkDerivation rec {
   name = "libserialport-0.1.1";
 
   src = fetchurl {
-    url = "http://sigrok.org/download/source/libserialport/${name}.tar.gz";
+    url = "https://sigrok.org/download/source/libserialport/${name}.tar.gz";
     sha256 = "17ajlwgvyyrap8z7f16zcs59pksvncwbmd3mzf98wj7zqgczjaja";
   };
 
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "Cross-platform shared library for serial port access";
-    homepage = http://sigrok.org/;
+    homepage = https://sigrok.org/;
     license = licenses.gpl3Plus;
     # macOS, Windows and Android is also supported (according to upstream).
     platforms = platforms.linux;
diff --git a/pkgs/development/libraries/libsexy/default.nix b/pkgs/development/libraries/libsexy/default.nix
index c8751c3e5dd4..49cdb2c95ba0 100644
--- a/pkgs/development/libraries/libsexy/default.nix
+++ b/pkgs/development/libraries/libsexy/default.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation {
 
   meta = with stdenv.lib; {
     description = "A collection of GTK+ widgets";
-    homepage = http://blog.chipx86.com/tag/libsexy/;
+    homepage = https://blog.chipx86.com/tag/libsexy/;
     license = licenses.lgpl21;
     maintainers = with maintainers; [ ];
     platforms = platforms.unix;
diff --git a/pkgs/development/libraries/libsigcxx/default.nix b/pkgs/development/libraries/libsigcxx/default.nix
index 4a309a87f2ec..f6bfff78fa26 100644
--- a/pkgs/development/libraries/libsigcxx/default.nix
+++ b/pkgs/development/libraries/libsigcxx/default.nix
@@ -10,11 +10,6 @@ stdenv.mkDerivation rec {
     url = "mirror://gnome/sources/libsigc++/${ver_maj}/${name}.tar.xz";
     sha256 = "f843d6346260bfcb4426259e314512b99e296e8ca241d771d21ac64f28298d81";
   };
-  patches = [(fetchpatch {
-    url = "https://anonscm.debian.org/cgit/collab-maint/libsigc++-2.0.git/plain"
-      + "/debian/patches/0002-Enforce-c-11-via-pkg-config.patch?id=d451a4d195b1";
-    sha256 = "19g19473syp2z3kg8vdrli89lm9kcvaqajkqfmdig1vfpkbq0nci";
-  })];
 
   nativeBuildInputs = [ pkgconfig gnum4 ];
 
diff --git a/pkgs/development/libraries/libsigsegv/2.5.nix b/pkgs/development/libraries/libsigsegv/2.5.nix
deleted file mode 100644
index fd453defe713..000000000000
--- a/pkgs/development/libraries/libsigsegv/2.5.nix
+++ /dev/null
@@ -1,23 +0,0 @@
-{ stdenv, fetchurl
-, enableSigbusFix ? false # required by kernels < 3.18.6
-}:
-
-stdenv.mkDerivation rec {
-  name = "libsigsegv-2.5";
-
-  src = fetchurl {
-    url = "mirror://gnu/libsigsegv/${name}.tar.gz";
-    sha256 = "0fvcsq9msi63vrbpvks6mqkrnls5cfy6bzww063sqhk2h49vsyyg";
-  };
-
-  patches = stdenv.lib.optional enableSigbusFix ./sigbus_fix.patch;
-
-  meta = {
-    homepage = http://libsigsegv.sf.net;
-    description = "A library for handling page faults in user mode";
-    branch = "2.5";
-    platforms = stdenv.lib.platforms.linux;
-  };
-
-  doCheck = true;
-}
diff --git a/pkgs/development/libraries/libsigsegv/default.nix b/pkgs/development/libraries/libsigsegv/default.nix
index 8e1079bfbc8a..8152c1ea8524 100644
--- a/pkgs/development/libraries/libsigsegv/default.nix
+++ b/pkgs/development/libraries/libsigsegv/default.nix
@@ -4,16 +4,16 @@
 }:
 
 stdenv.mkDerivation rec {
-  name = "libsigsegv-2.11";
+  name = "libsigsegv-2.12";
 
   src = fetchurl {
     url = "mirror://gnu/libsigsegv/${name}.tar.gz";
-    sha256 = "063swdvq7mbmc1clv0rnh20grwln1zfc2qnm0sa1hivcxyr2wz6x";
+    sha256 = "1dlhqf4igzpqayms25lkhycjq1ccavisx8cnb3y4zapbkqsszq9s";
   };
 
   patches = if enableSigbusFix then [ ./sigbus_fix.patch ] else null;
 
-  doCheck = hostPlatform == buildPlatform;
+  doCheck = true; # not cross;
 
   meta = {
     homepage = http://www.gnu.org/software/libsigsegv/;
diff --git a/pkgs/development/libraries/libskk/default.nix b/pkgs/development/libraries/libskk/default.nix
new file mode 100644
index 000000000000..521391b1bef8
--- /dev/null
+++ b/pkgs/development/libraries/libskk/default.nix
@@ -0,0 +1,49 @@
+{ stdenv, fetchurl, fetchFromGitHub,
+  libtool, gettext, pkgconfig,
+  vala, gnome-common, gobjectIntrospection,
+  libgee, json-glib, skk-dicts }:
+
+stdenv.mkDerivation rec {
+  name = "libskk-${version}";
+  version = "1.0.3";
+
+  src = fetchFromGitHub {
+    owner = "ueno";
+    repo = "libskk";
+    rev = version;
+    sha256 = "092bjir866f350s4prq9q0yg34s91vmr8wbgf2vh3kcax1yj1axm";
+  };
+
+  buildInputs = [ skk-dicts ];
+  nativeBuildInputs = [ vala gnome-common gobjectIntrospection libtool gettext pkgconfig ];
+  propagatedBuildInputs = [ libgee json-glib ];
+
+  preConfigure = ''
+    ./autogen.sh
+  '';
+
+  # link SKK-JISYO.L from skkdicts for the bundled tool `skk`
+  preInstall = ''
+    dictDir=$out/share/skk
+    mkdir -p $dictDir
+    ln -s ${skk-dicts}/share/SKK-JISYO.L $dictDir/
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "A library to deal with Japanese kana-to-kanji conversion method";
+    longDescription = ''
+      Libskk is a library that implements basic features of SKK including:
+      new word registration, completion, numeric conversion, abbrev mode, kuten input,
+      hankaku-katakana input, Lisp expression evaluation (concat only), and re-conversion.
+      It also supports various typing rules including: romaji-to-kana, AZIK, TUT-Code, and NICOLA,
+      as well as various dictionary types including: file dictionary (such as SKK-JISYO.[SML]),
+      user dictionary, skkserv, and CDB format dictionary.
+    '';
+    homepage = https://github.com/ueno/libskk;
+    license = stdenv.lib.licenses.gpl3Plus;
+    maintainers = with stdenv.lib.maintainers; [ yuriaisaka ];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/libsnark/darwin-fix-clock-gettime.patch b/pkgs/development/libraries/libsnark/darwin-fix-clock-gettime.patch
new file mode 100644
index 000000000000..2eee84d1c4b8
--- /dev/null
+++ b/pkgs/development/libraries/libsnark/darwin-fix-clock-gettime.patch
@@ -0,0 +1,41 @@
+Adapted from https://github.com/zcash/libsnark/pull/10
+
+diff --git a/depends/libff/libff/common/profiling.cpp b/depends/libff/libff/common/profiling.cpp
+index f2a1985..319149c 100755
+--- a/depends/libff/libff/common/profiling.cpp
++++ b/depends/libff/libff/common/profiling.cpp
+@@ -27,6 +27,13 @@
+ #include <proc/readproc.h>
+ #endif
+ 
++#ifdef __MACH__
++#include <time.h>
++#include <sys/time.h>
++#include <mach/clock.h>
++#include <mach/mach.h>
++#endif
++
+ namespace libff {
+ 
+ long long get_nsec_time()
+@@ -42,10 +49,20 @@ long long get_nsec_cpu_time()
+ 	return 0;
+ #else
+     ::timespec ts;
++#ifdef __MACH__
++    clock_serv_t cclock;
++    mach_timespec_t mts;
++    host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
++    clock_get_time(cclock, &mts);
++    mach_port_deallocate(mach_task_self(), cclock);
++    ts.tv_sec = mts.tv_sec;
++    ts.tv_nsec = mts.tv_nsec;
++#else
+     if ( ::clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) )
+         throw ::std::runtime_error("clock_gettime(CLOCK_PROCESS_CPUTIME_ID) failed");
+         // If we expected this to work, don't silently ignore failures, because that would hide the problem and incur an unnecessarily system-call overhead. So if we ever observe this exception, we should probably add a suitable #ifdef .
+         //TODO: clock_gettime(CLOCK_PROCESS_CPUTIME_ID) is not supported by native Windows. What about Cygwin? Should we #ifdef on CLOCK_PROCESS_CPUTIME_ID or on __linux__?
++#endif
+     return ts.tv_sec * 1000000000ll + ts.tv_nsec;
+ #endif
+ }
diff --git a/pkgs/development/libraries/libsnark/default.nix b/pkgs/development/libraries/libsnark/default.nix
new file mode 100644
index 000000000000..578053bbb427
--- /dev/null
+++ b/pkgs/development/libraries/libsnark/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchFromGitHub, cmake, pkgconfig, openssl, boost, gmp, procps, fetchpatch, patchutils }:
+
+let
+  rev = "9e6b19ff15bc19fba5da1707ba18e7f160e5ed07";
+  inherit (stdenv) lib;
+in stdenv.mkDerivation rec {
+  name = "libsnark-pre${version}";
+  version = stdenv.lib.substring 0 8 rev;
+
+  buildInputs = [ cmake pkgconfig openssl boost gmp ] ++ lib.optional stdenv.hostPlatform.isLinux procps;
+
+  cmakeFlags = lib.optionals stdenv.hostPlatform.isDarwin [ "-DWITH_PROCPS=OFF" "-DWITH_SUPERCOP=OFF" ];
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner           = "scipr-lab";
+    repo            = "libsnark";
+    sha256          = "13f02qp2fmfhvxlp4xi69m0l8r5nq913l2f0zwdk7hl46lprfdca";
+    fetchSubmodules = true;
+  };
+
+  patches = [ ./darwin-fix-clock-gettime.patch ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "C++ library for zkSNARKs";
+    homepage = https://github.com/scipr-lab/libsnark;
+    license = licenses.mit;
+    platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
+  };
+}
diff --git a/pkgs/development/libraries/libsndfile/default.nix b/pkgs/development/libraries/libsndfile/default.nix
index 53d927219e21..a68b5b2b6d5e 100644
--- a/pkgs/development/libraries/libsndfile/default.nix
+++ b/pkgs/development/libraries/libsndfile/default.nix
@@ -11,25 +11,30 @@ stdenv.mkDerivation rec {
   };
 
   patches = [
-    # CVE-2017-12562
     (fetchurl {
-       url = "https://github.com/erikd/libsndfile/commit/cf7a8182c2642c50f1cf90dddea9ce96a8bad2e8.patch";
-       sha256 = "1jg3wq30wdn9nv52mcyv6jyi4d80h4r1h9p96czcria7l91yh4sy";
+      name = "CVE-2017-12562.patch";
+      url = "https://github.com/erikd/libsndfile/commit/cf7a8182c2642c50f1cf90dddea9ce96a8bad2e8.patch";
+      sha256 = "1jg3wq30wdn9nv52mcyv6jyi4d80h4r1h9p96czcria7l91yh4sy";
     })
-    # CVE-2017-6892
     (fetchurl {
-       url = "https://github.com/erikd/libsndfile/commit/f833c53cb596e9e1792949f762e0b33661822748.patch";
-       sha256 = "05xkmz2ihc1zcj73sbmj1ikrv9qlcym2bkp1v6ak7w53ky619mwq";
+      name = "CVE-2017-6892.patch";
+      url = "https://github.com/erikd/libsndfile/commit/f833c53cb596e9e1792949f762e0b33661822748.patch";
+      sha256 = "05xkmz2ihc1zcj73sbmj1ikrv9qlcym2bkp1v6ak7w53ky619mwq";
     })
-    # CVE-2017-8361, CVE-2017-8363, CVE-2017-8363
     (fetchurl {
-       url = "https://github.com/erikd/libsndfile/commit/fd0484aba8e51d16af1e3a880f9b8b857b385eb3.patch";
-       sha256 = "0ccndnvjzx5fw18zvy03vnb29rr81h5vsh1m16msqbxk8ibndln2";
+      name = "CVE-2017-8361+CVE-2017-8363+CVE-2017-8365.patch";
+      url = "https://github.com/erikd/libsndfile/commit/fd0484aba8e51d16af1e3a880f9b8b857b385eb3.patch";
+      sha256 = "0ccndnvjzx5fw18zvy03vnb29rr81h5vsh1m16msqbxk8ibndln2";
     })
-    # CVE-2017-8362
     (fetchurl {
-       url = "https://github.com/erikd/libsndfile/commit/ef1dbb2df1c0e741486646de40bd638a9c4cd808.patch";
-       sha256 = "1xyv30ga71cpy4wx5f76sc4dma91la2lcc6s9f3pk9rndyi7gj9x";
+      name = "CVE-2017-8362.patch";
+      url = "https://github.com/erikd/libsndfile/commit/ef1dbb2df1c0e741486646de40bd638a9c4cd808.patch";
+      sha256 = "1xyv30ga71cpy4wx5f76sc4dma91la2lcc6s9f3pk9rndyi7gj9x";
+    })
+    (fetchurl {
+      name = "CVE-2017-14634.patch";
+      url = "https://github.com/erikd/libsndfile/commit/85c877d5072866aadbe8ed0c3e0590fbb5e16788.patch";
+      sha256 = "0kc7vp22qsxidhvmlc6nfamw7k92n0hcfpmwhb3gaksjamwhb2df";
     })
   ];
 
diff --git a/pkgs/development/libraries/libsodium/default.nix b/pkgs/development/libraries/libsodium/default.nix
index 5d4535676e7b..0b341b38917d 100644
--- a/pkgs/development/libraries/libsodium/default.nix
+++ b/pkgs/development/libraries/libsodium/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "libsodium-1.0.15";
+  name = "libsodium-1.0.16";
 
   src = fetchurl {
     url = "https://download.libsodium.org/libsodium/releases/${name}.tar.gz";
-    sha256 = "1x3qw7lsz44vcxpcn1dvwig410phg6gmv31jwj94arrgka3rwspv";
+    sha256 = "0cq5pn7qcib7q70mm1lgjwj75xdxix27v0xl1xl0kvxww7hwgbgf";
   };
 
   outputs = [ "out" "dev" ];
diff --git a/pkgs/development/libraries/libsolv/default.nix b/pkgs/development/libraries/libsolv/default.nix
index 480891e98af9..2d5fa20c7cf8 100644
--- a/pkgs/development/libraries/libsolv/default.nix
+++ b/pkgs/development/libraries/libsolv/default.nix
@@ -1,14 +1,14 @@
 { stdenv, fetchFromGitHub, cmake, zlib, expat, rpm, db }:
 
 stdenv.mkDerivation rec {
-  rev  = "0.6.23";
+  rev  = "0.6.34";
   name = "libsolv-${rev}";
 
   src = fetchFromGitHub {
     inherit rev;
     owner  = "openSUSE";
     repo   = "libsolv";
-    sha256 = "08ba7yx0br421lk6zf5mp0yl6nznkmc2vbka20qwm2lx5f0a25xg";
+    sha256 = "1knr48dilg8kscbmpjvd7m2krvgcdq0f9vpbqcgmxxa969mzrcy7";
   };
 
   cmakeFlags = "-DENABLE_RPMMD=true -DENABLE_RPMDB=true -DENABLE_PUBKEY=true -DENABLE_RPMDB_BYRPMHEADER=true";
diff --git a/pkgs/development/libraries/libsoundio/default.nix b/pkgs/development/libraries/libsoundio/default.nix
index 18d18941b887..7803b2a5ff11 100644
--- a/pkgs/development/libraries/libsoundio/default.nix
+++ b/pkgs/development/libraries/libsoundio/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, cmake, alsaLib, libjack2, libpulseaudio }:
+{ stdenv, fetchFromGitHub, cmake, alsaLib, libjack2, libpulseaudio, AudioUnit }:
 
 stdenv.mkDerivation rec {
   version = "1.1.0";
@@ -11,7 +11,13 @@ stdenv.mkDerivation rec {
     sha256 = "0mw197l4bci1cjc2z877gxwsvk8r43dr7qiwci2hwl2cjlcnqr2p";
   };
 
-  buildInputs = [ cmake alsaLib libjack2 libpulseaudio ];
+  nativeBuildInputs = [ cmake ];
+
+  buildInputs = [ libjack2 libpulseaudio ]
+    ++ stdenv.lib.optional stdenv.isLinux alsaLib
+    ++ stdenv.lib.optional stdenv.isDarwin AudioUnit;
+
+  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-Wno-strict-prototypes";
 
   meta = with stdenv.lib; {
     description = "Cross platform audio input and output";
diff --git a/pkgs/development/libraries/libsoup/default.nix b/pkgs/development/libraries/libsoup/default.nix
index 229a92d84bf5..92e9c3662c9f 100644
--- a/pkgs/development/libraries/libsoup/default.nix
+++ b/pkgs/development/libraries/libsoup/default.nix
@@ -1,18 +1,18 @@
-{ stdenv, fetchurl, glib, libxml2, pkgconfig
-, gnomeSupport ? true, libgnome_keyring3, sqlite, glib_networking, gobjectIntrospection
-, valaSupport ? true, vala_0_32
-, libintlOrEmpty
-, intltool, python }:
+{ stdenv, fetchurl, glib, libxml2, pkgconfig, gnome3
+, gnomeSupport ? true, sqlite, glib-networking, gobjectIntrospection
+, valaSupport ? true, vala_0_40
+, intltool, python3 }:
+
 let
-  majorVersion = "2.60";
-  version = "${majorVersion}.0";
+  pname = "libsoup";
+  version = "2.62.0";
 in
-stdenv.mkDerivation {
-  name = "libsoup-${version}";
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/libsoup/${majorVersion}/libsoup-${version}.tar.xz";
-    sha256 = "b324edbecda0884143c0853b4a2bd5bd37fb3761f12f293c621ff34b9acdc84c";
+    url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
+    sha256 = "1b5aff1igbsx1h4v3wmkffvzgiy8rscibqka7fmjf2lxs7l7lz5b";
   };
 
   prePatch = ''
@@ -24,21 +24,29 @@ stdenv.mkDerivation {
 
   outputs = [ "out" "dev" ];
 
-  buildInputs = libintlOrEmpty ++ [ intltool python sqlite ]
-    ++ stdenv.lib.optionals valaSupport [ vala_0_32 ];
-  nativeBuildInputs = [ pkgconfig ];
-  propagatedBuildInputs = [ glib libxml2 gobjectIntrospection ]
-    ++ stdenv.lib.optionals gnomeSupport [ libgnome_keyring3 ];
-  passthru.propagatedUserEnvPackages = [ glib_networking.out ];
+  buildInputs = [ python3 sqlite ];
+  nativeBuildInputs = [ pkgconfig intltool gobjectIntrospection ]
+    ++ stdenv.lib.optionals valaSupport [ vala_0_40 ];
+  propagatedBuildInputs = [ glib libxml2 ];
 
-  # glib_networking is a runtime dependency, not a compile-time dependency
-  configureFlags = "--disable-tls-check"
-    + " --enable-vala=${if valaSupport then "yes" else "no"}"
-    + stdenv.lib.optionalString (!gnomeSupport) " --without-gnome";
+  # glib-networking is a runtime dependency, not a compile-time dependency
+  configureFlags = [
+    "--disable-tls-check"
+    "--enable-vala=${if valaSupport then "yes" else "no"}"
+    "--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 {
+      packageName = pname;
+    };
+  };
 
   meta = {
+    description = "HTTP client/server library for GNOME";
+    homepage = https://wiki.gnome.org/Projects/libsoup;
+    license = stdenv.lib.licenses.gpl2;
     inherit (glib.meta) maintainers platforms;
   };
 }
diff --git a/pkgs/development/libraries/libspatialindex/default.nix b/pkgs/development/libraries/libspatialindex/default.nix
index 660d7e16310f..aa3aaa1c59bc 100644
--- a/pkgs/development/libraries/libspatialindex/default.nix
+++ b/pkgs/development/libraries/libspatialindex/default.nix
@@ -1,13 +1,13 @@
 { stdenv, fetchurl }:
 
-let version = "1.8.1"; in
+let version = "1.8.5"; in
 
 stdenv.mkDerivation rec {
   name = "libspatialindex-${version}";
 
   src = fetchurl {
     url = "http://download.osgeo.org/libspatialindex/spatialindex-src-${version}.tar.gz";
-    sha256 = "1ay1kxn4baccd0cqx466v7fn8c8gcfbhlnd5mbdnd7s4aw0ix88j";
+    sha256 = "1vxzm7kczwnb6qdmc0hb00z8ykx11zk3sb68gc7rch4vrfi4dakw";
   };
 
   enableParallelBuilding = true;
@@ -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/libspatialite/default.nix b/pkgs/development/libraries/libspatialite/default.nix
index 19ccc9159a3e..253c5365c8a3 100644
--- a/pkgs/development/libraries/libspatialite/default.nix
+++ b/pkgs/development/libraries/libspatialite/default.nix
@@ -3,11 +3,11 @@
 with lib;
 
 stdenv.mkDerivation rec {
-  name = "libspatialite-4.2.0";
+  name = "libspatialite-4.3.0a";
 
   src = fetchurl {
     url = "http://www.gaia-gis.it/gaia-sins/libspatialite-sources/${name}.tar.gz";
-    sha256 = "0b9ipmp09y2ij7yajyjsh0zcwps8n5g88lzfzlkph33lail8l4wz";
+    sha256 = "16d4lpl7xrm9zy4gphy6nwanpjp8wn9g4wq2i2kh8abnlhq01448";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/libsrs2/default.nix b/pkgs/development/libraries/libsrs2/default.nix
index a2e94c33ce32..7d9ea25e9d26 100644
--- a/pkgs/development/libraries/libsrs2/default.nix
+++ b/pkgs/development/libraries/libsrs2/default.nix
@@ -5,14 +5,14 @@ stdenv.mkDerivation rec {
   version = "1.0.18";
 
   src = fetchurl {
-    url = "http://www.libsrs2.org/srs/libsrs2-${version}.tar.gz";
+    url = "https://www.libsrs2.org/srs/libsrs2-${version}.tar.gz";
     sha256 = "9d1191b705d7587a5886736899001d04168392bbb6ed6345a057ade50943a492";
   };
 
   meta = {
     description = "The next generation SRS library from the original designer of SRS";
     license = with lib.licenses; [ gpl2 bsd3 ];
-    homepage = http://www.libsrs2.org/;
+    homepage = https://www.libsrs2.org/;
     platforms = stdenv.lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/libstatgrab/default.nix b/pkgs/development/libraries/libstatgrab/default.nix
index 036bb806f687..72d73e358485 100644
--- a/pkgs/development/libraries/libstatgrab/default.nix
+++ b/pkgs/development/libraries/libstatgrab/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
   buildInputs = [] ++ stdenv.lib.optional stdenv.isDarwin IOKit;
 
   meta = with stdenv.lib; {
-    homepage = http://www.i-scream.org/libstatgrab/;
+    homepage = https://www.i-scream.org/libstatgrab/;
     description = "A library that provides cross platforms access to statistics about the running system";
     license = licenses.gpl2;
     platforms = platforms.unix;
diff --git a/pkgs/development/libraries/libstdc++5/default.nix b/pkgs/development/libraries/libstdc++5/default.nix
index abe0538b8a9c..f8397052b770 100644
--- a/pkgs/development/libraries/libstdc++5/default.nix
+++ b/pkgs/development/libraries/libstdc++5/default.nix
@@ -21,14 +21,16 @@ stdenv.mkDerivation rec {
       name = "siginfo.patch";
       url = "https://git.archlinux.org/svntogit/packages.git/plain/trunk/siginfo.patch?h=packages/libstdc%2B%2B5&id=e36ee8ed9bb5942db14cf6249a2ead14974a2bfa";
       sha256 = "15zldbm33yba293dgrgsbv3j332hkc3iqpyc8fa7zl42mh9qk22j";
-      addPrefixes = true;
+      extraPrefix = "";
     })
     (fetchpatch {
       name = "gcc-3.4.3-no_multilib_amd64.patch";
       url = "https://git.archlinux.org/svntogit/packages.git/plain/trunk/gcc-3.4.3-no_multilib_amd64.patch?h=packages/libstdc%2B%2B5&id=e36ee8ed9bb5942db14cf6249a2ead14974a2bfa";
       sha256 = "11m5lc51b0addhc4yq4rz0dwpv6k73rrj73wya3lqdk8rly6cjpm";
-      addPrefixes = true;
+      extraPrefix = "";
     })
+    # Required because of glibc 2.26
+    ./struct-ucontext.patch
   ];
 
   postPatch = ''
@@ -62,7 +64,7 @@ stdenv.mkDerivation rec {
     # being generated to make sure that they use our glibc.
     EXTRA_FLAGS="-I$NIX_FIXINC_DUMMY $(cat $NIX_CC/nix-support/libc-cflags) -O2"
 
-    extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $(cat $NIX_CC/nix-support/libc-ldflags) $(cat $NIX_CC/nix-support/libc-ldflags-before)"
+    extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $(cat $NIX_BINTOOLS/nix-support/libc-ldflags) $(cat $NIX_BINTOOLS/nix-support/libc-ldflags-before)"
     for i in $extraLDFlags; do
       EXTRA_FLAGS="$EXTRA_FLAGS -Wl,$i"
     done
diff --git a/pkgs/development/libraries/libstdc++5/struct-ucontext.patch b/pkgs/development/libraries/libstdc++5/struct-ucontext.patch
new file mode 100644
index 000000000000..5462e0e33ecd
--- /dev/null
+++ b/pkgs/development/libraries/libstdc++5/struct-ucontext.patch
@@ -0,0 +1,61 @@
+diff --git a/gcc/config/alpha/linux.h b/gcc/config/alpha/linux.h
+index 3a2940c..67f9899 100644
+--- a/gcc/config/alpha/linux.h
++++ b/gcc/config/alpha/linux.h
+@@ -89,7 +89,7 @@ Boston, MA 02111-1307, USA.  */
+       {									\
+ 	struct rt_sigframe {						\
+ 	  struct siginfo info;						\
+-	  struct ucontext uc;						\
++	  ucontext_t uc;						\
+ 	} *rt_ = (CONTEXT)->cfa;					\
+ 	sc_ = &rt_->uc.uc_mcontext;					\
+       }									\
+diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
+index e86ab3d..30797a7 100644
+--- a/gcc/config/i386/linux.h
++++ b/gcc/config/i386/linux.h
+@@ -260,7 +260,7 @@ Boston, MA 02111-1307, USA.  */
+ 	  siginfo_t *pinfo;					\
+ 	  void *puc;							\
+ 	  siginfo_t info;						\
+-	  struct ucontext uc;						\
++	  ucontext_t uc;						\
+ 	} *rt_ = (CONTEXT)->cfa;					\
+ 	sc_ = (struct sigcontext *) &rt_->uc.uc_mcontext;		\
+       }									\
+diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
+index fbfaa58..200c8dc 100644
+--- a/gcc/config/i386/linux64.h
++++ b/gcc/config/i386/linux64.h
+@@ -112,7 +112,7 @@ Boston, MA 02111-1307, USA.  */
+     if (*(unsigned char *)(pc_+0) == 0x48				\
+ 	&& *(unsigned long *)(pc_+1) == 0x050f0000000fc0c7)		\
+       {									\
+-	struct ucontext *uc_ = (CONTEXT)->cfa;				\
++	ucontext_t *uc_ = (CONTEXT)->cfa;				\
+ 	sc_ = (struct sigcontext *) &uc_->uc_mcontext;			\
+       }									\
+     else								\
+@@ -182,7 +182,7 @@ Boston, MA 02111-1307, USA.  */
+ 	  struct siginfo *pinfo;					\
+ 	  void *puc;							\
+ 	  struct siginfo info;						\
+-	  struct ucontext uc;						\
++	  ucontext_t uc;						\
+ 	} *rt_ = (CONTEXT)->cfa;					\
+ 	sc_ = (struct sigcontext *) &rt_->uc.uc_mcontext;		\
+       }									\
+diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h
+index ba70ec1..0fff8b1 100644
+--- a/gcc/config/rs6000/linux.h
++++ b/gcc/config/rs6000/linux.h
+@@ -101,7 +101,7 @@ Boston, MA 02111-1307, USA.  */
+ 
+ struct kernel_old_ucontext {
+   unsigned long     uc_flags;
+-  struct ucontext  *uc_link;
++  ucontext_t       *uc_link;
+   stack_t           uc_stack;
+   struct sigcontext_struct uc_mcontext;
+   sigset_t          uc_sigmask;
diff --git a/pkgs/development/libraries/libstemmer/default.nix b/pkgs/development/libraries/libstemmer/default.nix
new file mode 100644
index 000000000000..67d6d8d42ead
--- /dev/null
+++ b/pkgs/development/libraries/libstemmer/default.nix
@@ -0,0 +1,22 @@
+{ lib, stdenv, fetchFromGitHub, cmake }:
+
+stdenv.mkDerivation rec {
+  name = "libstemmer-2017-03-02";
+
+  src = fetchFromGitHub {
+    owner = "zvelo";
+    repo = "libstemmer";
+    rev = "78c149a3a6f262a35c7f7351d3f77b725fc646cf";
+    sha256 = "06md6n6h1f2zvnjrpfrq7ng46l1x12c14cacbrzmh5n0j98crpq7";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  meta = with lib; {
+    description = "Snowball Stemming Algorithms";
+    homepage = "http://snowball.tartarus.org/";
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ fpletz ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/libstroke/default.nix b/pkgs/development/libraries/libstroke/default.nix
index 29fa8fc339f9..bd54b3aa343a 100644
--- a/pkgs/development/libraries/libstroke/default.nix
+++ b/pkgs/development/libraries/libstroke/default.nix
@@ -4,8 +4,8 @@ stdenv.mkDerivation {
   name = "libstroke-0.5.1";
 
   src = fetchurl {
-    url = http://etla.net/libstroke/libstroke-0.5.1.tar.gz;
-    sha256 = "0da9f5fde66feaf6697ba069baced8fb3772c3ddc609f39861f92788f5c7772d";
+    url = https://web.archive.org/web/20161204100704/http://etla.net/libstroke/libstroke-0.5.1.tar.gz;
+    sha256 = "0bbpqzsqh9zrc6cg62f6vp1p4dzvv37blsd0gdlzdskgwvyzba8d";
   };
 
   buildInputs = [ automake autoconf x11 ];
@@ -20,7 +20,7 @@ stdenv.mkDerivation {
 
   meta = {
     description = "Libstroke, a library for simple gesture recognition";
-    homepage = http://etla.net/libstroke/;
+    homepage = https://web.archive.org/web/20161204100704/http://etla.net/libstroke/;
     license = stdenv.lib.licenses.gpl2;
 
     longDescription =
diff --git a/pkgs/development/libraries/libstrophe/default.nix b/pkgs/development/libraries/libstrophe/default.nix
index 0d014cb22a82..c1e6a1f7fb89 100644
--- a/pkgs/development/libraries/libstrophe/default.nix
+++ b/pkgs/development/libraries/libstrophe/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "libstrophe-${version}";
-  version = "0.9.1";
+  version = "0.9.2";
 
   src = fetchFromGitHub {
     owner = "strophe";
     repo = "libstrophe";
     rev = version;
-    sha256 = "099iv13c03y1dsn2ngdhfx2cnax0aj2gfh00w55hlzpvmjm8dsml";
+    sha256 = "1milna92h8wzxax8ll362zvb70091nmfks5lmd105vk0478zraca";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/libsvm/default.nix b/pkgs/development/libraries/libsvm/default.nix
index a366baf27e33..aab0da90d394 100644
--- a/pkgs/development/libraries/libsvm/default.nix
+++ b/pkgs/development/libraries/libsvm/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libsvm-${version}";
-  version = "3.20";
+  version = "3.22";
 
   src = fetchurl {
-    url = "http://www.csie.ntu.edu.tw/~cjlin/libsvm/libsvm-${version}.tar.gz";
-    sha256 = "1gj5v5zp1qnsnv0iwxq0ikhf8262d3s5dq6syr6yqkglps0284hg";
+    url = "https://www.csie.ntu.edu.tw/~cjlin/libsvm/libsvm-${version}.tar.gz";
+    sha256 = "0zd7s19y5vb7agczl6456bn45cj1y64739sslaskw1qk7dywd0bd";
   };
 
   buildPhase = ''
@@ -30,7 +30,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "A library for support vector machines";
-    homepage = http://www.csie.ntu.edu.tw/~cjlin/libsvm/;
+    homepage = https://www.csie.ntu.edu.tw/~cjlin/libsvm/;
     license = licenses.bsd3;
     maintainers = [ maintainers.spwhitt ];
     platforms = platforms.unix;
diff --git a/pkgs/development/libraries/libtar/default.nix b/pkgs/development/libraries/libtar/default.nix
index 992bad020ea6..8123bf7ba84e 100644
--- a/pkgs/development/libraries/libtar/default.nix
+++ b/pkgs/development/libraries/libtar/default.nix
@@ -31,7 +31,7 @@ stdenv.mkDerivation rec {
     description = "C library for manipulating POSIX tar files";
     homepage = http://www.feep.net/libtar/;
     license = licenses.bsd3;
-    platforms = platforms.linux;
+    platforms = with platforms; linux ++ darwin;
     maintainers = [ maintainers.bjornfor ];
   };
 }
diff --git a/pkgs/development/libraries/libtasn1/default.nix b/pkgs/development/libraries/libtasn1/default.nix
index 7fa53fe162b2..cc5b19f7a595 100644
--- a/pkgs/development/libraries/libtasn1/default.nix
+++ b/pkgs/development/libraries/libtasn1/default.nix
@@ -1,25 +1,18 @@
 { stdenv, fetchurl, perl, texinfo }:
 
 stdenv.mkDerivation rec {
-  name = "libtasn1-4.12";
+  name = "libtasn1-4.13";
 
   src = fetchurl {
     url = "mirror://gnu/libtasn1/${name}.tar.gz";
-    sha256 = "0ls7jdq3y5fnrwg0pzhq11m21r8pshac2705bczz6mqjc8pdllv7";
+    sha256 = "1jlc1iahj8k3haz28j55nzg7sgni5h41vqy461i1bpbx6668wlky";
   };
 
-  patches = [
-    (fetchurl {
-      name = "CVE-2017-10790.patch";
-      url = "https://git.savannah.gnu.org/gitweb/?p=libtasn1.git;a=patch;h=d8d805e1f2e6799bb2dff4871a8598dc83088a39";
-      sha256 = "1v5w0dazp9qc2v7pc8b6g7s4dz5ak10hzrn35hx66q76yzrrzp7i";
-    })
-  ];
-
   outputs = [ "out" "dev" "devdoc" ];
   outputBin = "dev";
 
-  buildInputs = [ perl texinfo ];
+  nativeBuildInputs = [ texinfo ];
+  buildInputs = [ perl ];
 
   doCheck = true;
 
diff --git a/pkgs/development/libraries/libtcod/default.nix b/pkgs/development/libraries/libtcod/default.nix
index 0374c7f89b7a..4e859c282276 100644
--- a/pkgs/development/libraries/libtcod/default.nix
+++ b/pkgs/development/libraries/libtcod/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromBitbucket, cmake, SDL, mesa, upx, zlib }:
+{ stdenv, fetchFromBitbucket, cmake, SDL, libGLU_combined, upx, zlib }:
 
 stdenv.mkDerivation rec {
 
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
 
   cmakeFlags="-DLIBTCOD_SAMPLES=OFF";
 
-  buildInputs = [ cmake SDL mesa upx zlib ];
+  buildInputs = [ cmake SDL libGLU_combined upx zlib ];
 
   meta = {
     description = "API for roguelike games";
diff --git a/pkgs/development/libraries/libtermkey/default.nix b/pkgs/development/libraries/libtermkey/default.nix
index 429cc5d9f180..7261fb7b6b74 100644
--- a/pkgs/development/libraries/libtermkey/default.nix
+++ b/pkgs/development/libraries/libtermkey/default.nix
@@ -3,11 +3,11 @@
 stdenv.mkDerivation rec {
   name = "libtermkey-${version}";
 
-  version = "0.19";
+  version = "0.20";
 
   src = fetchzip {
     url = "http://www.leonerd.org.uk/code/libtermkey/libtermkey-${version}.tar.gz";
-    sha256 = "0v85h0zacd5lqwkykl2ms4009x8mfidzb6jr4dsq4gh7kwm54w56";
+    sha256 = "1i5a2zangq61ba1vdkag34ig5g4gzccldccdbcmqmk93saa6lkbx";
   };
 
   makeFlags = [ "PREFIX=$(out)" ]
diff --git a/pkgs/development/libraries/libtheora/default.nix b/pkgs/development/libraries/libtheora/default.nix
index 375c59f77631..fd58f4f44e78 100644
--- a/pkgs/development/libraries/libtheora/default.nix
+++ b/pkgs/development/libraries/libtheora/default.nix
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
   '';
 
   meta = with stdenv.lib; {
-    homepage = http://www.theora.org/;
+    homepage = https://www.theora.org/;
     description = "Library for Theora, a free and open video compression format";
     license = licenses.bsd3;
     maintainers = with maintainers; [ spwhitt wkennington ];
diff --git a/pkgs/development/libraries/libtiff/default.nix b/pkgs/development/libraries/libtiff/default.nix
index ee21f3df7ac9..ab1bda9ed299 100644
--- a/pkgs/development/libraries/libtiff/default.nix
+++ b/pkgs/development/libraries/libtiff/default.nix
@@ -1,20 +1,20 @@
 { stdenv, fetchurl, fetchpatch, pkgconfig, zlib, libjpeg, xz }:
 
 let
-  version = "4.0.8";
+  version = "4.0.9";
 in
 stdenv.mkDerivation rec {
   name = "libtiff-${version}";
 
   src = fetchurl {
     url = "http://download.osgeo.org/libtiff/tiff-${version}.tar.gz";
-    sha256 = "0419mh6kkhz5fkyl77gv0in8x4d2jpdpfs147y8mj86rrjlabmsr";
+    sha256 = "1kfg4q01r4mqn7dj63ifhi6pmqzbf4xax6ni6kkk81ri5kndwyvf";
   };
 
-  prePatch =let
+  prePatch = let
       debian = fetchurl {
-        url = http://snapshot.debian.org/archive/debian-debug/20170928T093547Z/pool/main/t/tiff/tiff_4.0.8-5.debian.tar.xz;
-        sha256 = "11qkiliw04dmdvdd5z2lv5hh2fiwa29qbhkxvlvmb4yslnmyywha";
+        url = http://snapshot.debian.org/archive/debian-debug/20180128T155203Z//pool/main/t/tiff/tiff_4.0.9-3.debian.tar.xz;
+        sha256 = "0wya42y7kcq093g3h7ca10cm5sns1mgnkjmdd2qdi59v8arga4y4";
       };
     in ''
       tar xf '${debian}'
@@ -29,7 +29,7 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  doCheck = stdenv.buildPlatform == stdenv.hostPlatform;
+  doCheck = true; # not cross;
 
   meta = with stdenv.lib; {
     description = "Library and utilities for working with the TIFF image file format";
diff --git a/pkgs/development/libraries/libtiger/default.nix b/pkgs/development/libraries/libtiger/default.nix
index aa5de3f2a5f3..bd0084dbaaf7 100644
--- a/pkgs/development/libraries/libtiger/default.nix
+++ b/pkgs/development/libraries/libtiger/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, libkate, pango, cairo, pkgconfig }:
+{ stdenv, lib, fetchurl, libkate, pango, cairo, pkgconfig, darwin }:
 
 stdenv.mkDerivation rec {
   name = "libtiger-0.3.4";
@@ -9,11 +9,13 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ libkate pango cairo ];
+  buildInputs = [ libkate pango cairo ]
+    ++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.ApplicationServices;
 
   meta = {
     homepage = https://code.google.com/archive/p/libtiger/;
     description = "A rendering library for Kate streams using Pango and Cairo";
-    platforms = stdenv.lib.platforms.unix;
+    platforms = lib.platforms.unix;
+    maintainers = with lib.maintainers; [ matthewbauer ];
   };
 }
diff --git a/pkgs/development/libraries/libtins/default.nix b/pkgs/development/libraries/libtins/default.nix
new file mode 100644
index 000000000000..efd63148fb10
--- /dev/null
+++ b/pkgs/development/libraries/libtins/default.nix
@@ -0,0 +1,43 @@
+{ boost, cmake, fetchFromGitHub, gtest, libpcap, openssl, stdenv }:
+
+stdenv.mkDerivation rec {
+  name = "libtins-${version}";
+  version = "3.5";
+  
+  src = fetchFromGitHub {
+    owner = "mfontanini";
+    repo = "libtins";
+    rev = "v${version}";
+    sha256 = "00d1fxyg8q6djljm79ms69gcrsqxxksny3b16v99bzf3aivfss5x";
+  };
+
+  postPatch = ''
+    rm -rf googletest
+    cp -r ${gtest.src}/googletest googletest
+    chmod -R a+w googletest
+  '';
+
+  nativeBuildInputs = [ cmake gtest ];
+  buildInputs = [
+    openssl
+    libpcap
+    boost
+  ];
+
+  configureFlags = [
+    "--with-boost-libdir=${boost.out}/lib"
+    "--with-boost=${boost.dev}"
+  ];
+
+  enableParallelBuilding = true;
+  doCheck = true;
+  checkPhase = "make tests && LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib make test";
+
+  meta = with stdenv.lib; {
+    description = "High-level, multiplatform C++ network packet sniffing and crafting library";
+    homepage = https://libtins.github.io/;
+    license = stdenv.lib.licenses.bsd2;
+    maintainers = with maintainers; [ fdns ];
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/libtomcrypt/default.nix b/pkgs/development/libraries/libtomcrypt/default.nix
index 13fa71e60dce..e30f699f103d 100644
--- a/pkgs/development/libraries/libtomcrypt/default.nix
+++ b/pkgs/development/libraries/libtomcrypt/default.nix
@@ -1,27 +1,34 @@
-{stdenv, fetchurl, libtool}:
+{ stdenv, fetchurl, libtool }:
 
-stdenv.mkDerivation {
-  name = "libtomcrypt-1.17";
+stdenv.mkDerivation rec {
+  name = "libtomcrypt-${version}";
+  version = "1.18.1";
 
   src = fetchurl {
-    url = "https://github.com/libtom/libtomcrypt/releases/download/1.17/crypt-1.17.tar.bz2";
-    sha256 = "e33b47d77a495091c8703175a25c8228aff043140b2554c08a3c3cd71f79d116";
+    url = "https://github.com/libtom/libtomcrypt/releases/download/v${version}/crypt-${version}.tar.xz";
+    sha256 = "053z0jzyvf6c9929phlh2p0ybx289s34g7nii5hnjigxzcs3mhap";
   };
 
-  buildInputs = [libtool];
+  nativeBuildInputs = [ libtool ];
+
+  postPatch = ''
+    substituteInPlace makefile.shared --replace "LT:=glibtool" "LT:=libtool"
+  '';
 
   preBuild = ''
-    makeFlagsArray=(LIBPATH=$out/lib INCPATH=$out/include \
-      DATAPATH=$out/share/doc/libtomcrypt/pdf \
+    makeFlagsArray=(PREFIX=$out \
       INSTALL_GROUP=$(id -g) \
       INSTALL_USER=$(id -u))
   '';
 
   makefile = "makefile.shared";
 
-  meta = {
-    homepage = http://libtom.org/?page=features&newsitems=5&whatfile=crypt;
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = http://www.libtom.net/LibTomCrypt/;
     description = "A fairly comprehensive, modular and portable cryptographic toolkit";
-    platforms = stdenv.lib.platforms.linux;
+    license = with licenses; [ publicDomain wtfpl ];
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/libtommath/default.nix b/pkgs/development/libraries/libtommath/default.nix
index 8b7c06b98dca..cd13eef156d0 100644
--- a/pkgs/development/libraries/libtommath/default.nix
+++ b/pkgs/development/libraries/libtommath/default.nix
@@ -1,27 +1,35 @@
-{stdenv, fetchurl, libtool}:
+{ stdenv, fetchurl, libtool }:
+
+stdenv.mkDerivation rec {
+  name = "libtommath-${version}";
+  version = "1.0.1";
 
-stdenv.mkDerivation {
-  name = "libtommath-1.0";
-  
   src = fetchurl {
-    url = https://github.com/libtom/libtommath/releases/download/v1.0/ltm-1.0.tar.xz;
-    sha256 = "0v5mpd8zqjfs2hr900w1mxifz23xylyjdqyx1i1wl7q9xvwpsflr";
+    url = "https://github.com/libtom/libtommath/releases/download/v${version}/ltm-${version}.tar.xz";
+    sha256 = "0sbccdwbkfc680id2fi0x067j23biqcjqilwkk7y9339knrjy0s7";
   };
 
-  buildInputs = [libtool];
+  nativeBuildInputs = [ libtool ];
+
+  postPatch = ''
+    substituteInPlace makefile.shared --replace "LT:=glibtool" "LT:=libtool"
+    substituteInPlace makefile_include.mk --replace "shell arch" "shell uname -m"
+  '';
 
   preBuild = ''
-    makeFlagsArray=(LIBPATH=$out/lib INCPATH=$out/include \
-      DATAPATH=$out/share/doc/libtommath/pdf \
+    makeFlagsArray=(PREFIX=$out \
       INSTALL_GROUP=$(id -g) \
       INSTALL_USER=$(id -u))
   '';
 
   makefile = "makefile.shared";
 
-  meta = {
-    homepage = http://math.libtomcrypt.com/;
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = http://www.libtom.net/LibTomMath/;
     description = "A library for integer-based number-theoretic applications";
-    platforms = stdenv.lib.platforms.unix;
+    license = with licenses; [ publicDomain wtfpl ];
+    platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/libtorrent-rasterbar/1.0.nix b/pkgs/development/libraries/libtorrent-rasterbar/1.0.nix
deleted file mode 100644
index fbd30ac04f76..000000000000
--- a/pkgs/development/libraries/libtorrent-rasterbar/1.0.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-args@{ callPackage, fetchpatch, ... }:
-
-callPackage (import ./generic.nix {
-  version = "1.0.11";
-  sha256 = "17p34d3n29q04pvz975gfl1fyj3sg9cl5l6j673xqfq3fpyis58i";
-  patches = [
-    # Compatibility with new Boost
-    (fetchpatch {
-      url = "https://github.com/arvidn/libtorrent/commit/7eb3cf6bc6dbada3fa7bb7ff4d5981182813a0e2.patch";
-      sha256 = "07agbrii6i8q4wmgpqbln7ldhhadaf5npcinvi6hnyipsr48jbj5";
-    })
-  ];
-}) args
diff --git a/pkgs/development/libraries/libtorrent-rasterbar/default.nix b/pkgs/development/libraries/libtorrent-rasterbar/default.nix
index ff5027fd472e..00ec22986179 100644
--- a/pkgs/development/libraries/libtorrent-rasterbar/default.nix
+++ b/pkgs/development/libraries/libtorrent-rasterbar/default.nix
@@ -1,6 +1,6 @@
 args@{ callPackage, ... }:
 
 callPackage (import ./generic.nix {
-  version = "1.1.5";
-  sha256 = "1ifpcqw5mj2dwk23lhc2vpb47mg3j573v5z4zp8dkczpz7wg5jxq";
+  version = "1.1.6";
+  sha256 = "1xlh0sqypjbx0imw3bkbjwgwb4bm6zl7c0y01p0xsw8ncfmwjll7";
 }) args
diff --git a/pkgs/development/libraries/libtorrent-rasterbar/generic.nix b/pkgs/development/libraries/libtorrent-rasterbar/generic.nix
index 315385cba6c8..8c85864f87a5 100644
--- a/pkgs/development/libraries/libtorrent-rasterbar/generic.nix
+++ b/pkgs/development/libraries/libtorrent-rasterbar/generic.nix
@@ -38,6 +38,6 @@ stdenv.mkDerivation rec {
     description = "A C++ BitTorrent implementation focusing on efficiency and scalability";
     license = licenses.bsd3;
     maintainers = [ maintainers.phreedom ];
-    platforms = platforms.linux;
+    platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/libtoxcore/default.nix b/pkgs/development/libraries/libtoxcore/default.nix
index 0d0563eb5ddf..16fca9ce3d39 100644
--- a/pkgs/development/libraries/libtoxcore/default.nix
+++ b/pkgs/development/libraries/libtoxcore/default.nix
@@ -3,13 +3,13 @@
 
 stdenv.mkDerivation rec {
   name = "libtoxcore-${version}";
-  version = "0.1.8";
+  version = "0.1.11";
 
   src = fetchFromGitHub {
     owner  = "TokTok";
     repo   = "c-toxcore";
     rev    = "v${version}";
-    sha256 = "08vdq3j60wn62lj2z9f3f47hibns93rvaqx5xc5bm3nglk70q7kk";
+    sha256 = "1fya5gfiwlpk6fxhalv95n945ymvp2iidiyksrjw1xw95fzsp1ij";
   };
 
   cmakeFlags = [
@@ -19,12 +19,16 @@ stdenv.mkDerivation rec {
   ];
 
   buildInputs = [
-    libsodium libmsgpack ncurses
+    libsodium libmsgpack ncurses libconfig
   ] ++ stdenv.lib.optionals (!stdenv.isArm) [
     libopus
     libvpx
   ];
+
   nativeBuildInputs = [ cmake pkgconfig ];
+
+  enableParallelBuilding = true;
+
   checkInputs = [ check ];
 
   checkPhase = "ctest";
@@ -33,7 +37,8 @@ stdenv.mkDerivation rec {
   doCheck = true;
 
   meta = with stdenv.lib; {
-    description = "P2P FOSS instant messaging application aimed to replace Skype with crypto";
+    description = "P2P FOSS instant messaging application aimed to replace Skype";
+    homepage = https://tox.chat;
     license = licenses.gpl3Plus;
     maintainers = with maintainers; [ peterhoeg ];
     platforms = platforms.all;
diff --git a/pkgs/development/libraries/libtoxcore/old-api.nix b/pkgs/development/libraries/libtoxcore/old-api.nix
deleted file mode 100644
index 5757e94559a8..000000000000
--- a/pkgs/development/libraries/libtoxcore/old-api.nix
+++ /dev/null
@@ -1,59 +0,0 @@
-{ stdenv, fetchFromGitHub, autoreconfHook, libsodium, ncurses, libopus
-, libvpx, check, libconfig, pkgconfig }:
-
-let
-  version = "4c220e336330213b151a0c20307d0a1fce04ac9e";
-  date = "20150126";
-
-in stdenv.mkDerivation rec {
-  name = "tox-core-old-${date}-${builtins.substring 0 7 version}";
-
-  src = fetchFromGitHub {
-    owner  = "irungentoo";
-    repo   = "toxcore";
-    rev    = version;
-    sha256 = "152yamak9ykl8dgkx1qzyrpa3f4xr1s8lgcb5k58r9lb1iwnhvqc";
-  };
-
-  NIX_LDFLAGS = "-lgcc_s";
-
-  postPatch = ''
-    # within Nix chroot builds, localhost is unresolvable
-    sed -i -e '/DEFTESTCASE(addr_resolv_localhost)/d' \
-      auto_tests/network_test.c
-    # takes WAAAY too long (~10 minutes) and would timeout
-    sed -i -e '/DEFTESTCASE[^(]*(many_clients\>/d' \
-      auto_tests/tox_test.c
-  '';
-
-  configureFlags = [
-    "--with-libsodium-headers=${libsodium.dev}/include"
-    "--with-libsodium-libs=${libsodium.out}/lib"
-    "--enable-ntox"
-    "--enable-daemon"
-  ];
-
-  buildInputs = [
-    autoreconfHook libsodium ncurses
-    check libconfig pkgconfig
-  ] ++ stdenv.lib.optionals (!stdenv.isArm) [
-    libopus
-  ];
-
-  propagatedBuildInputs = stdenv.lib.optionals (!stdenv.isArm) [ libvpx ];
-
-  # Some tests fail randomly due to timeout. This kind of problem is well known
-  # by upstream: https://github.com/irungentoo/toxcore/issues/{950,1054}
-  # They don't recommend running tests on 50core machines with other cpu-bound
-  # tests running in parallel.
-  #
-  # NOTE: run the tests locally on your machine before upgrading this package!
-  doCheck = false;
-
-  meta = with stdenv.lib; {
-    description = "P2P FOSS instant messaging application aimed to replace Skype with crypto";
-    license = licenses.gpl3Plus;
-    maintainers = with maintainers; [ viric jgeerds ];
-    platforms = platforms.all;
-  };
-}
diff --git a/pkgs/development/libraries/libtxc_dxtn/default.nix b/pkgs/development/libraries/libtxc_dxtn/default.nix
index 82aba6b89f5a..977570050158 100644
--- a/pkgs/development/libraries/libtxc_dxtn/default.nix
+++ b/pkgs/development/libraries/libtxc_dxtn/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, autoreconfHook, mesa }:
+{ stdenv, fetchurl, autoreconfHook, libGLU_combined }:
 
 let version = "1.0.1"; in
 
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ autoreconfHook ];
-  buildInputs = [ mesa ];
+  buildInputs = [ libGLU_combined ];
 
   meta = {
     homepage = http://dri.freedesktop.org/wiki/S3TC;
diff --git a/pkgs/development/libraries/libtxc_dxtn_s2tc/default.nix b/pkgs/development/libraries/libtxc_dxtn_s2tc/default.nix
index 387dbb22a816..aad8ae00c114 100644
--- a/pkgs/development/libraries/libtxc_dxtn_s2tc/default.nix
+++ b/pkgs/development/libraries/libtxc_dxtn_s2tc/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, autoreconfHook, mesa }:
+{ stdenv, fetchurl, autoreconfHook, libGLU_combined }:
 
 let version = "1.0"; in
 
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ autoreconfHook ];
-  buildInputs = [ mesa ];
+  buildInputs = [ libGLU_combined ];
 
   meta = {
     description = "A patent-free S3TC compatible implementation";
diff --git a/pkgs/development/libraries/libu2f-host/default.nix b/pkgs/development/libraries/libu2f-host/default.nix
index 48d55f17c579..2def14b1c10e 100644
--- a/pkgs/development/libraries/libu2f-host/default.nix
+++ b/pkgs/development/libraries/libu2f-host/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, pkgconfig, json_c, hidapi }:
 
 stdenv.mkDerivation rec {
-  name = "libu2f-host-1.1.1";
+  name = "libu2f-host-1.1.5";
 
   src = fetchurl {
     url = "https://developers.yubico.com/libu2f-host/Releases/${name}.tar.xz";
-    sha256 = "0g0f012w0c00cvj5g319x2b8prbh0d3fcac9960cy7xsd8chckg1";
+    sha256 = "159slvjfq4bqslx5amjkk90xnkiv3x0yzvbi54pl2vnzbr1p2azk";
   };
 
   nativeBuildInputs = [ pkgconfig ];
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     homepage = https://developers.yubico.com/libu2f-host;
-    description = "A C library and command-line tool thati mplements the host-side of the U2F protocol";
+    description = "A C library and command-line tool that implements the host-side of the U2F protocol";
     license = licenses.bsd2;
     platforms = platforms.unix;
     maintainers = with maintainers; [ wkennington ];
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/libunique/3.x.nix b/pkgs/development/libraries/libunique/3.x.nix
index b0066fa75f22..1a4f16046fc1 100644
--- a/pkgs/development/libraries/libunique/3.x.nix
+++ b/pkgs/development/libraries/libunique/3.x.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, pkgconfig
-, dbus, dbus_glib, gtk3, gobjectIntrospection
+, dbus, dbus-glib, gtk3, gobjectIntrospection
 , gtkdoc, docbook_xml_dtd_45, docbook_xsl
 , libxslt, libxml2 }:
 
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ dbus dbus_glib gtk3 gobjectIntrospection gtkdoc docbook_xml_dtd_45 docbook_xsl libxslt libxml2 ];
+  buildInputs = [ dbus dbus-glib gtk3 gobjectIntrospection gtkdoc docbook_xml_dtd_45 docbook_xsl libxslt libxml2 ];
 
   meta = {
     homepage = https://wiki.gnome.org/Attic/LibUnique;
diff --git a/pkgs/development/libraries/libunique/default.nix b/pkgs/development/libraries/libunique/default.nix
index a5adaa9ac179..2bb53dd2b97f 100644
--- a/pkgs/development/libraries/libunique/default.nix
+++ b/pkgs/development/libraries/libunique/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, glib, gtk2, dbus_glib }:
+{ stdenv, fetchurl, pkgconfig, glib, gtk2, dbus-glib }:
 
 stdenv.mkDerivation rec {
   name = "libunique-1.1.6";
@@ -13,10 +13,11 @@ stdenv.mkDerivation rec {
     ./1.1.6-fix-test.patch
     ./1.1.6-G_CONST_RETURN.patch
     ./1.1.6-include-terminator.patch
-  ];
+  ]
+    ++ [ ./gcc7-bug.patch ];
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ glib gtk2 dbus_glib ];
+  buildInputs = [ glib gtk2 dbus-glib ];
 
   # don't make deprecated usages hard errors
   preBuild = ''substituteInPlace unique/dbus/Makefile --replace -Werror ""'';
@@ -24,7 +25,7 @@ stdenv.mkDerivation rec {
   doCheck = true;
 
   meta = {
-    homepage = http://live.gnome.org/LibUnique;
+    homepage = https://wiki.gnome.org/Attic/LibUnique;
     description = "A library for writing single instance applications";
     license = stdenv.lib.licenses.lgpl21;
     platforms = stdenv.lib.platforms.linux;
diff --git a/pkgs/development/libraries/libunique/gcc7-bug.patch b/pkgs/development/libraries/libunique/gcc7-bug.patch
new file mode 100644
index 000000000000..2b0587510bc0
--- /dev/null
+++ b/pkgs/development/libraries/libunique/gcc7-bug.patch
@@ -0,0 +1,18 @@
+gcc-7 newly detects this class of bugs.
+In this particular case it's clear that the inention was
+to detect if the string is non-NULL *and* non-empty.
+
+
+diff --git a/unique/uniqueapp.c b/unique/uniqueapp.c
+index b40a86c..66a7226 100644
+--- a/unique/uniqueapp.c
++++ b/unique/uniqueapp.c
+@@ -176,7 +176,7 @@ set_startup_id (UniqueBackend *backend,
+ {
+   gchar *id;
+ 
+-  if (startup_id && startup_id != '\0')
++  if (startup_id && *startup_id != '\0')
+     id = g_strdup (startup_id);
+   else
+     {
diff --git a/pkgs/development/libraries/libunistring/clang.patch b/pkgs/development/libraries/libunistring/clang.patch
deleted file mode 100644
index fdcbc0d528d0..000000000000
--- a/pkgs/development/libraries/libunistring/clang.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-diff --git a/lib/stdint.in.h b/lib/stdint.in.h
-index 997e406..e0827f5 100644
---- a/lib/stdint.in.h
-+++ b/lib/stdint.in.h
-@@ -53,7 +53,8 @@
-      in <inttypes.h> would reinclude us, skipping our contents because
-      _GL_STDINT_H is defined.
-      The include_next requires a split double-inclusion guard.  */
--# @INCLUDE_NEXT@ @NEXT_STDINT_H@
-+# include <inttypes.h>
-+// # @INCLUDE_NEXT@ @NEXT_STDINT_H@
- #endif
- 
- #if ! defined _GL_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H
diff --git a/pkgs/development/libraries/libunistring/default.nix b/pkgs/development/libraries/libunistring/default.nix
index 42376b61f423..e3be66e8b1ca 100644
--- a/pkgs/development/libraries/libunistring/default.nix
+++ b/pkgs/development/libraries/libunistring/default.nix
@@ -1,28 +1,25 @@
 { fetchurl, stdenv, libiconv }:
 
 stdenv.mkDerivation rec {
-  name = "libunistring-0.9.7";
+  name = "libunistring-${version}";
+  version = "0.9.9";
 
   src = fetchurl {
     url = "mirror://gnu/libunistring/${name}.tar.gz";
-    sha256 = "1ra1baz2187kbw9im47g6kqb5mx9plq703mkjxaval8rxv5q3q4w";
+    sha256 = "0jm8pr469y7ybb90ll8k1585rciqm8ckzif0laipqhp5z440rsgm";
   };
 
-  patches = stdenv.lib.optionals stdenv.isDarwin [ ./clang.patch stdenv.secure-format-patch ];
-
   outputs = [ "out" "dev" "info" "doc" ];
 
   propagatedBuildInputs = stdenv.lib.optional (!stdenv.isLinux) libiconv;
 
-  enableParallelBuilding = false;
-
   configureFlags = [
     "--with-libiconv-prefix=${libiconv}"
   ];
 
-  # XXX: There are test failures on non-GNU systems, see
-  # http://lists.gnu.org/archive/html/bug-libunistring/2010-02/msg00004.html .
-  doCheck = (stdenv ? glibc) && (stdenv.hostPlatform == stdenv.buildPlatform);
+  doCheck = !stdenv.hostPlatform.isMusl;
+
+  enableParallelBuilding = true;
 
   meta = {
     homepage = http://www.gnu.org/software/libunistring/;
diff --git a/pkgs/development/libraries/libunity/default.nix b/pkgs/development/libraries/libunity/default.nix
deleted file mode 100644
index 66890f08ff3e..000000000000
--- a/pkgs/development/libraries/libunity/default.nix
+++ /dev/null
@@ -1,27 +0,0 @@
-{ stdenv, fetchurl, vala_0_23, python, intltool, pkgconfig
-, glib, libgee_0_6, gtk3, dee, libdbusmenu-glib
-}:
-
-stdenv.mkDerivation rec {
-  name = "libunity-${version}";
-  version = "6.12.0";
-
-  src = fetchurl {
-    url = "https://launchpad.net/libunity/6.0/${version}/+download/${name}.tar.gz";
-    sha256 = "1nadapl3390x98q1wv2yarh60hzi7ck0d1s8zz9xsiq3zz6msbjd";
-  };
-
-  buildInputs = [ glib libgee_0_6 gtk3 ];
-  propagatedBuildInputs = [ dee libdbusmenu-glib ];
-  nativeBuildInputs = [ vala_0_23 python intltool pkgconfig ];
-
-  enableParallelBuilding = true;
-
-  meta = with stdenv.lib; {
-    description = "A library for instrumenting- and integrating with all aspects of the Unity shell";
-    homepage = https://launchpad.net/libunity;
-    license = licenses.lgpl3;
-    platforms = platforms.linux;
-    maintainers = with maintainers; [ abbradar ];
-  };
-}
diff --git a/pkgs/development/libraries/libunwind/backtrace-only-with-glibc.patch b/pkgs/development/libraries/libunwind/backtrace-only-with-glibc.patch
new file mode 100644
index 000000000000..5fcaa72c0c01
--- /dev/null
+++ b/pkgs/development/libraries/libunwind/backtrace-only-with-glibc.patch
@@ -0,0 +1,45 @@
+From 04437142399662b576bd55a85485c6dcc14d0812 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem at gmail.com>
+Date: Thu, 31 Dec 2015 06:44:07 +0000
+Subject: [PATCH] backtrace: Use only with glibc and uclibc
+
+backtrace API is glibc specific not linux specific
+so make it behave so.
+
+Signed-off-by: Khem Raj <raj.khem at gmail.com>
+---
+Upstream-Status: Pending
+
+ tests/test-coredump-unwind.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/tests/test-coredump-unwind.c b/tests/test-coredump-unwind.c
+index 5254708..8767b42 100644
+--- a/tests/test-coredump-unwind.c
++++ b/tests/test-coredump-unwind.c
+@@ -57,7 +57,9 @@
+ #include <grp.h>
+ 
+ /* For SIGSEGV handler code */
++#ifdef __GLIBC__
+ #include <execinfo.h>
++#endif
+ #include <sys/ucontext.h>
+ 
+ #include <libunwind-coredump.h>
+@@ -238,11 +240,11 @@ void handle_sigsegv(int sig, siginfo_t *info, void *ucontext)
+ 			ip);
+ 
+   {
++#ifdef __GLIBC__
+     /* glibc extension */
+     void *array[50];
+     int size;
+     size = backtrace(array, 50);
+-#ifdef __linux__
+     backtrace_symbols_fd(array, size, 2);
+ #endif
+   }
+-- 
+2.6.4
+
diff --git a/pkgs/development/libraries/libunwind/default.nix b/pkgs/development/libraries/libunwind/default.nix
index 8565bc75ff9f..b901d352808e 100644
--- a/pkgs/development/libraries/libunwind/default.nix
+++ b/pkgs/development/libraries/libunwind/default.nix
@@ -11,6 +11,7 @@ stdenv.mkDerivation rec {
 
   patches = [
     ./version-1.2.1.patch
+    ./backtrace-only-with-glibc.patch
   ];
 
   nativeBuildInputs = [ autoreconfHook ];
@@ -32,4 +33,6 @@ stdenv.mkDerivation rec {
     platforms = platforms.linux;
     license = licenses.mit;
   };
+
+  passthru.supportsHost = !stdenv.hostPlatform.isRiscV;
 }
diff --git a/pkgs/development/libraries/liburcu/default.nix b/pkgs/development/libraries/liburcu/default.nix
index 3b92aff72a56..85f8b6df2959 100644
--- a/pkgs/development/libraries/liburcu/default.nix
+++ b/pkgs/development/libraries/liburcu/default.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, perl }:
 
 stdenv.mkDerivation rec {
-  version = "0.9.3";
+  version = "0.10.1";
   name = "liburcu-${version}";
 
   src = fetchurl {
-    url = "http://lttng.org/files/urcu/userspace-rcu-${version}.tar.bz2";
-    sha256 = "01j0xp3f0w147yfyzybkjvb7i67i7prsvnkssgvgwry9lvk35khv";
+    url = "https://lttng.org/files/urcu/userspace-rcu-${version}.tar.bz2";
+    sha256 = "01pbg67qy5hcssy2yi0ckqapzfclgdq93li2rmzw4pa3wh5j42cw";
   };
 
   nativeBuildInputs = stdenv.lib.optional doCheck perl;
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "Userspace RCU (read-copy-update) library";
-    homepage = http://lttng.org/urcu;
+    homepage = https://lttng.org/urcu;
     license = licenses.lgpl21Plus;
     platforms = platforms.unix;
     maintainers = [ maintainers.bjornfor ];
diff --git a/pkgs/development/libraries/libusb/default.nix b/pkgs/development/libraries/libusb/default.nix
index 1fd3cb39bbff..4704a1e5c331 100644
--- a/pkgs/development/libraries/libusb/default.nix
+++ b/pkgs/development/libraries/libusb/default.nix
@@ -14,6 +14,8 @@ stdenv.mkDerivation {
     sha256 = "0nn5icrfm9lkhzw1xjvaks9bq3w6mjg86ggv3fn7kgi4nfvg8kj0";
   };
 
+  patches = stdenv.lib.optional stdenv.hostPlatform.isMusl ./fix-headers.patch;
+
   meta = {
     platforms = stdenv.lib.platforms.unix;
   };
diff --git a/pkgs/development/libraries/libusb/fix-headers.patch b/pkgs/development/libraries/libusb/fix-headers.patch
new file mode 100644
index 000000000000..ea9cbc34978e
--- /dev/null
+++ b/pkgs/development/libraries/libusb/fix-headers.patch
@@ -0,0 +1,10 @@
+--- libusb-compat-0.1.5.orig/libusb/usb.h
++++ libusb-compat-0.1.5/libusb/usb.h
+@@ -25,6 +25,7 @@
+ #ifndef __USB_H__
+ #define __USB_H__
+ 
++#include <sys/types.h>
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <limits.h>
diff --git a/pkgs/development/libraries/libusb1/default.nix b/pkgs/development/libraries/libusb1/default.nix
index dd2f1edc5f2a..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.20";
+  name = "libusb-1.0.22";
 
   src = fetchurl {
     url = "mirror://sourceforge/libusb/${name}.tar.bz2";
-    sha256 = "1zzp6hc7r7m3gl6zjbmzn92zkih4664cckaf49l1g5hapa8721fb";
+    sha256 = "0mw1a5ss4alg37m6bd4k44v35xwrcwp5qm4s686q1nsgkbavkbkm";
   };
 
   outputs = [ "out" "dev" ]; # get rid of propagating systemd closure
diff --git a/pkgs/development/libraries/libusbmuxd/default.nix b/pkgs/development/libraries/libusbmuxd/default.nix
index 3e8beef3c9d0..3d15b698b481 100644
--- a/pkgs/development/libraries/libusbmuxd/default.nix
+++ b/pkgs/development/libraries/libusbmuxd/default.nix
@@ -8,7 +8,8 @@ stdenv.mkDerivation rec {
   };
 
   patches = [
-    (fetchpatch { # CVE-2016-5104
+    (fetchpatch {
+      name = "CVE-2016-5104.patch";
       url = "https://github.com/libimobiledevice/libusbmuxd/commit/4397b3376dc4e4cb1c991d0aed61ce6482614196.patch";
       sha256 = "0cl3vys7bkwbdzf64d0rz3zlqpfc30w4l7j49ljv01agh42ywhgk";
     })
diff --git a/pkgs/development/libraries/libuv/default.nix b/pkgs/development/libraries/libuv/default.nix
index 8dea502a4ff4..e8877c7f54b6 100644
--- a/pkgs/development/libraries/libuv/default.nix
+++ b/pkgs/development/libraries/libuv/default.nix
@@ -2,14 +2,14 @@
 , ApplicationServices, CoreServices }:
 
 stdenv.mkDerivation rec {
-  version = "1.15.0";
+  version = "1.19.2";
   name = "libuv-${version}";
 
   src = fetchFromGitHub {
     owner = "libuv";
     repo = "libuv";
     rev = "v${version}";
-    sha256 = "092hxqjvbb6d03h3msc38359w2kixba1ansyrsbyqq8iqiqwnkw0";
+    sha256 = "118r8wigm65107fm7kzfz7gc4awy8xxg0knvwnshx1j40ks08x9z";
   };
 
   postPatch = let
diff --git a/pkgs/development/libraries/libva-utils/default.nix b/pkgs/development/libraries/libva-utils/default.nix
new file mode 100644
index 000000000000..95d4be08548a
--- /dev/null
+++ b/pkgs/development/libraries/libva-utils/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, lib, fetchFromGitHub, autoreconfHook, pkgconfig
+, libdrm, libva
+}:
+
+stdenv.mkDerivation rec {
+  name = "libva-utils-${version}";
+  inherit (libva) version;
+
+  src = fetchFromGitHub {
+    owner  = "01org";
+    repo   = "libva-utils";
+    rev    = version;
+    sha256 = "113wdmi4r0qligizj9zmd4a8ml1996x9g2zp2i4pmhb8frv9m8j2";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+
+  buildInputs = [ libdrm libva ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "VAAPI tools: Video Acceleration API";
+    homepage = http://www.freedesktop.org/wiki/Software/vaapi;
+    license = licenses.mit;
+    maintainers = with maintainers; [ garbas ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/libva/1.0.0.nix b/pkgs/development/libraries/libva/1.0.0.nix
new file mode 100644
index 000000000000..04d621e29c84
--- /dev/null
+++ b/pkgs/development/libraries/libva/1.0.0.nix
@@ -0,0 +1,37 @@
+{ stdenv, lib, fetchurl, libX11, pkgconfig, libXext, libdrm, libXfixes, wayland, libffi
+, libGL, libGL_driver
+, minimal ? false, libva1-minimal
+}:
+
+stdenv.mkDerivation rec {
+  name = "libva-${version}";
+  version = "1.7.3";
+
+  src = fetchurl {
+    url = "http://www.freedesktop.org/software/vaapi/releases/libva/${name}.tar.bz2";
+    sha256 = "1ndrf136rlw03xag7j1xpmf9015d1h0dpnv6v587jnh6k2a17g12";
+  };
+
+  outputs = [ "bin" "dev" "out" ];
+
+  nativeBuildInputs = [ pkgconfig ];
+
+  buildInputs = [ libdrm ]
+    ++ lib.optionals (!minimal) [ libva1-minimal libX11 libXext libXfixes wayland libffi libGL ];
+  # TODO: share libs between minimal and !minimal - perhaps just symlink them
+
+  configureFlags =
+    # 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" ];
+
+  meta = with stdenv.lib; {
+    homepage = http://www.freedesktop.org/wiki/Software/vaapi;
+    license = licenses.mit;
+    description = "VAAPI library: Video Acceleration API";
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ garbas ];
+  };
+}
diff --git a/pkgs/development/libraries/libva/default.nix b/pkgs/development/libraries/libva/default.nix
index 031ac781651c..0ba49da06cfe 100644
--- a/pkgs/development/libraries/libva/default.nix
+++ b/pkgs/development/libraries/libva/default.nix
@@ -1,36 +1,45 @@
-{ stdenv, lib, fetchurl, libX11, pkgconfig, libXext, libdrm, libXfixes, wayland, libffi
-, mesa_noglu
-, minimal ? true, libva
+{ stdenv, lib, fetchFromGitHub, autoreconfHook, pkgconfig
+, libXext, libdrm, libXfixes, wayland, libffi, libX11
+, libGL, libGL_driver
+, minimal ? false, libva-minimal
 }:
 
 stdenv.mkDerivation rec {
-  name = "libva-${version}";
-  version = "1.7.3";
-
-  src = fetchurl {
-    url = "http://www.freedesktop.org/software/vaapi/releases/libva/${name}.tar.bz2";
-    sha256 = "1ndrf136rlw03xag7j1xpmf9015d1h0dpnv6v587jnh6k2a17g12";
+  name = "libva-${lib.optionalString minimal "minimal-"}${version}";
+  version = "2.1.0";
+
+  # update libva-utils and vaapiIntel as well
+  src = fetchFromGitHub {
+    owner  = "01org";
+    repo   = "libva";
+    rev    = version;
+    sha256 = "1a60lrgr65hx9b2qp0gjky1298c4d4zp3ap6vnmmz850sxx5rm8w";
   };
 
-  outputs = [ "bin" "dev" "out" ];
+  outputs = [ "dev" "out" ];
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
 
   buildInputs = [ libdrm ]
-    ++ lib.optionals (!minimal) [ libva libX11 libXext libXfixes wayland libffi mesa_noglu ];
+    ++ lib.optionals (!minimal) [ libva-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" ] ++
-    lib.optionals (!minimal) [ "--enable-glx" ];
+  enableParallelBuilding = true;
+
+  configureFlags = [
+    # 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" ];
+  installFlags = [
+    "dummy_drv_video_ladir=$(out)/lib/dri"
+  ];
 
   meta = with stdenv.lib; {
+    description = "VAAPI library: Video Acceleration API";
     homepage = http://www.freedesktop.org/wiki/Software/vaapi;
     license = licenses.mit;
-    description = "VAAPI library: Video Acceleration API";
-    platforms = platforms.unix;
     maintainers = with maintainers; [ garbas ];
+    platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/libvdpau-va-gl/default.nix b/pkgs/development/libraries/libvdpau-va-gl/default.nix
index 4285b05a6250..3ea0155b4f42 100644
--- a/pkgs/development/libraries/libvdpau-va-gl/default.nix
+++ b/pkgs/development/libraries/libvdpau-va-gl/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchFromGitHub, cmake, pkgconfig, libX11, libpthreadstubs, libXau, libXdmcp
-, libXext, libvdpau, glib, libva, ffmpeg, mesa_glu }:
+, libXext, libvdpau, glib, libva, ffmpeg, libGLU }:
 
 stdenv.mkDerivation rec {
   name = "libvdpau-va-gl-${version}";
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ cmake pkgconfig ];
-  buildInputs = [ libX11 libpthreadstubs libXau libXdmcp libXext libvdpau glib libva ffmpeg mesa_glu ];
+  buildInputs = [ libX11 libpthreadstubs libXau libXdmcp libXext libvdpau glib libva ffmpeg libGLU ];
 
   meta = with stdenv.lib; {
     homepage = https://github.com/i-rinat/libvdpau-va-gl;
diff --git a/pkgs/development/libraries/libvdpau/default.nix b/pkgs/development/libraries/libvdpau/default.nix
index ceb42fe2bfc3..35c339b45d09 100644
--- a/pkgs/development/libraries/libvdpau/default.nix
+++ b/pkgs/development/libraries/libvdpau/default.nix
@@ -1,10 +1,11 @@
-{ stdenv, fetchurl, pkgconfig, xorg, mesa_noglu }:
+{ stdenv, fetchurl, pkgconfig, xorg, libGL_driver }:
 
 stdenv.mkDerivation rec {
-  name = "libvdpau-1.1.1";
+  name = "libvdpau-${version}";
+  version = "1.1.1";
 
   src = fetchurl {
-    url = "http://people.freedesktop.org/~aplattner/vdpau/${name}.tar.bz2";
+    url = "https://people.freedesktop.org/~aplattner/vdpau/${name}.tar.bz2";
     sha256 = "857a01932609225b9a3a5bf222b85e39b55c08787d0ad427dbd9ec033d58d736";
   };
 
@@ -16,12 +17,12 @@ stdenv.mkDerivation rec {
   propagatedBuildInputs = [ xorg.libX11 ];
 
   configureFlags = stdenv.lib.optional stdenv.isLinux
-    "--with-module-dir=${mesa_noglu.driverLink}/lib/vdpau";
+    "--with-module-dir=${libGL_driver.driverLink}/lib/vdpau";
 
   installFlags = [ "moduledir=$(out)/lib/vdpau" ];
 
   meta = with stdenv.lib; {
-    homepage = http://people.freedesktop.org/~aplattner/vdpau/;
+    homepage = https://people.freedesktop.org/~aplattner/vdpau/;
     description = "Library to use the Video Decode and Presentation API for Unix (VDPAU)";
     license = licenses.mit; # expat version
     platforms = platforms.unix;
diff --git a/pkgs/development/libraries/libvirt-glib/default.nix b/pkgs/development/libraries/libvirt-glib/default.nix
index e41ab5fe5a33..0dbe30251bdd 100644
--- a/pkgs/development/libraries/libvirt-glib/default.nix
+++ b/pkgs/development/libraries/libvirt-glib/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, pkgconfig, libvirt, glib, libxml2, intltool, libtool, yajl
 , nettle, libgcrypt, pythonPackages, gobjectIntrospection, libcap_ng, numactl
-, xen, libapparmor
+, xen, libapparmor, vala
 }:
 
 let
@@ -8,15 +8,19 @@ let
 in stdenv.mkDerivation rec {
   name = "libvirt-glib-1.0.0";
 
+  outputs = [ "out" "dev" ];
+
   src = fetchurl {
     url = "http://libvirt.org/sources/glib/${name}.tar.gz";
     sha256 = "0iwa5sdbii52pjpdm5j37f67sdmf0kpcky4liwhy1nf43k85i4fa";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig vala ];
   buildInputs = [
     libvirt glib libxml2 intltool libtool yajl nettle libgcrypt
-    python pygobject2 gobjectIntrospection libcap_ng numactl xen libapparmor
+    python pygobject2 gobjectIntrospection libcap_ng numactl libapparmor
+  ] ++ stdenv.lib.optionals stdenv.isx86_64 [
+    xen
   ];
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/libvirt/build-on-bsd.patch b/pkgs/development/libraries/libvirt/build-on-bsd.patch
deleted file mode 100644
index 830f0f30ff9b..000000000000
--- a/pkgs/development/libraries/libvirt/build-on-bsd.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-diff -Naur libvirt-1.3.0.orig/src/admin/admin_protocol.c libvirt-1.3.0/src/admin/admin_protocol.c
---- libvirt-1.3.0.orig/src/admin/admin_protocol.c	2015-12-02 16:17:07.000000000 +0100
-+++ libvirt-1.3.0/src/admin/admin_protocol.c	2016-01-04 17:57:10.043412857 +0100
-@@ -6,6 +6,25 @@
- 
- #include "admin_protocol.h"
- 
-+/* cygwin's xdr implementation defines xdr_u_int64_t instead of xdr_uint64_t
-+ * and lacks IXDR_PUT_INT32 and IXDR_GET_INT32
-+ */
-+#ifdef HAVE_XDR_U_INT64_T
-+# define xdr_uint64_t xdr_u_int64_t
-+#endif
-+#ifndef IXDR_PUT_INT32
-+# define IXDR_PUT_INT32 IXDR_PUT_LONG
-+#endif
-+#ifndef IXDR_GET_INT32
-+# define IXDR_GET_INT32 IXDR_GET_LONG
-+#endif
-+#ifndef IXDR_PUT_U_INT32
-+# define IXDR_PUT_U_INT32 IXDR_PUT_U_LONG
-+#endif
-+#ifndef IXDR_GET_U_INT32
-+# define IXDR_GET_U_INT32 IXDR_GET_U_LONG
-+#endif
-+
- bool_t
- xdr_admin_nonnull_string (XDR *xdrs, admin_nonnull_string *objp)
- {
-diff -Naur libvirt-1.3.0.orig/src/logging/log_protocol.c libvirt-1.3.0/src/logging/log_protocol.c
---- libvirt-1.3.0.orig/src/logging/log_protocol.c	2015-12-08 13:07:35.000000000 +0100
-+++ libvirt-1.3.0/src/logging/log_protocol.c	2016-01-04 17:56:50.673463563 +0100
-@@ -7,6 +7,25 @@
- #include "log_protocol.h"
- #include "internal.h"
- 
-+/* cygwin's xdr implementation defines xdr_u_int64_t instead of xdr_uint64_t
-+ * and lacks IXDR_PUT_INT32 and IXDR_GET_INT32
-+ */
-+#ifdef HAVE_XDR_U_INT64_T
-+# define xdr_uint64_t xdr_u_int64_t
-+#endif
-+#ifndef IXDR_PUT_INT32
-+# define IXDR_PUT_INT32 IXDR_PUT_LONG
-+#endif
-+#ifndef IXDR_GET_INT32
-+# define IXDR_GET_INT32 IXDR_GET_LONG
-+#endif
-+#ifndef IXDR_PUT_U_INT32
-+# define IXDR_PUT_U_INT32 IXDR_PUT_U_LONG
-+#endif
-+#ifndef IXDR_GET_U_INT32
-+# define IXDR_GET_U_INT32 IXDR_GET_U_LONG
-+#endif
-+
- bool_t
- xdr_virLogManagerProtocolUUID (XDR *xdrs, virLogManagerProtocolUUID objp)
- {
diff --git a/pkgs/development/libraries/libvirt/default.nix b/pkgs/development/libraries/libvirt/default.nix
index ff72cc84d265..7262ca541f01 100644
--- a/pkgs/development/libraries/libvirt/default.nix
+++ b/pkgs/development/libraries/libvirt/default.nix
@@ -1,50 +1,60 @@
-{ stdenv, fetchurl, fetchpatch
-, pkgconfig, makeWrapper
+{ stdenv, fetchurl, fetchgit
+, pkgconfig, makeWrapper, libtool, autoconf, automake
 , coreutils, libxml2, gnutls, devicemapper, perl, python2, attr
 , iproute, iptables, readline, lvm2, utillinux, systemd, libpciaccess, gettext
 , libtasn1, ebtables, libgcrypt, yajl, pmutils, libcap_ng, libapparmor
 , dnsmasq, libnl, libpcap, libxslt, xhtml1, numad, numactl, perlPackages
-, curl, libiconv, gmp, xen, zfs, parted, qemu
+, curl, libiconv, gmp, xen, zfs, parted, bridge-utils, dmidecode
 }:
 
 with stdenv.lib;
 
-# if you update, also bump pythonPackages.libvirt or it will break
-stdenv.mkDerivation rec {
+# if you update, also bump <nixpkgs/pkgs/development/python-modules/libvirt/default.nix> and SysVirt in <nixpkgs/pkgs/top-level/perl-packages.nix>
+let
+  buildFromTarball = stdenv.isDarwin;
+in stdenv.mkDerivation rec {
   name = "libvirt-${version}";
-  version = "3.8.0";
+  version = "4.1.0";
 
-  src = fetchurl {
-    url = "http://libvirt.org/sources/${name}.tar.xz";
-    sha256 = "1y83z4jb2by6ara0nw4sivh7svqcrw97yfhqwdscxl4y10saisvk";
-  };
-
-  patches = [ ./build-on-bsd.patch ];
+  src =
+    if buildFromTarball then
+      fetchurl {
+        url = "http://libvirt.org/sources/${name}.tar.xz";
+        sha256 = "0fb466mcma21hsxx3cckllbr9hhncpbwim5px1mr66iidy1a8bwa";
+      }
+    else
+      fetchgit {
+        url = git://libvirt.org/libvirt.git;
+        rev = "v${version}";
+        sha256 = "01021r7i71dw9w7ffp6ia8h70ns6bc0ps5np0hq9nipxs68finm6";
+        fetchSubmodules = true;
+      };
 
   nativeBuildInputs = [ makeWrapper pkgconfig ];
   buildInputs = [
     libxml2 gnutls perl python2 readline gettext libtasn1 libgcrypt yajl
     libxslt xhtml1 perlPackages.XMLXPath curl libpcap
+  ] ++ optionals (!buildFromTarball) [
+    libtool autoconf automake
   ] ++ optionals stdenv.isLinux [
     libpciaccess devicemapper lvm2 utillinux systemd libnl numad zfs
-    libapparmor libcap_ng numactl xen attr parted
+    libapparmor libcap_ng numactl attr parted
+  ] ++ optionals (stdenv.isLinux && stdenv.isx86_64) [
+    xen
   ] ++ optionals stdenv.isDarwin [
-     libiconv gmp
+    libiconv gmp
   ];
 
-  preConfigure = optionalString stdenv.isLinux ''
-    PATH=${stdenv.lib.makeBinPath [ iproute iptables ebtables lvm2 systemd ]}:$PATH
-    substituteInPlace configure \
-      --replace 'as_dummy="/bin:/usr/bin:/usr/sbin"' 'as_dummy="${numad}/bin"'
+  preConfigure = ''
+    ${ optionalString (!buildFromTarball) "./bootstrap --no-git --gnulib-srcdir=$(pwd)/.gnulib" }
+
+    PATH=${stdenv.lib.makeBinPath ([ dnsmasq ] ++ optionals stdenv.isLinux [ iproute iptables ebtables lvm2 systemd numad ])}:$PATH
 
     # the path to qemu-kvm will be stored in VM's .xml and .save files
     # do not use "''${qemu_kvm}/bin/qemu-kvm" to avoid bound VMs to particular qemu derivations
-    substituteInPlace src/qemu/qemu_capabilities.c \
-      --replace '"/usr/libexec/qemu-kvm"' '"/run/libvirt/nix-emulators/${if stdenv.isAarch64 then "qemu-system-aarch64" else "qemu-kvm"}"'
     substituteInPlace src/lxc/lxc_conf.c \
       --replace 'lxc_path,' '"/run/libvirt/nix-emulators/libvirt_lxc",'
-  '' + ''
-    PATH=${dnsmasq}/bin:$PATH
+
     patchShebangs . # fixes /usr/bin/python references
   '';
 
@@ -78,18 +88,19 @@ stdenv.mkDerivation rec {
   ];
 
   postInstall = ''
-    sed -i 's/ON_SHUTDOWN=suspend/ON_SHUTDOWN=''${ON_SHUTDOWN:-suspend}/' $out/libexec/libvirt-guests.sh
     substituteInPlace $out/libexec/libvirt-guests.sh \
-      --replace "$out/bin" "${gettext}/bin" \
-      --replace "lock/subsys" "lock"
-    sed -e "/gettext\.sh/a \\\n# Added in nixpkgs:\ngettext() { \"${gettext}/bin/gettext\" \"\$@\"; }" \
-        -i "$out/libexec/libvirt-guests.sh"
-
+      --replace 'ON_SHUTDOWN=suspend' 'ON_SHUTDOWN=''${ON_SHUTDOWN:-suspend}' \
+      --replace "$out/bin"            '${gettext}/bin' \
+      --replace 'lock/subsys'         'lock' \
+      --replace 'gettext.sh'          'gettext.sh
+  # Added in nixpkgs:
+  gettext() { "${gettext}/bin/gettext" "$@"; }
+  '
   '' + optionalString stdenv.isLinux ''
     substituteInPlace $out/lib/systemd/system/libvirtd.service --replace /bin/kill ${coreutils}/bin/kill
     rm $out/lib/systemd/system/{virtlockd,virtlogd}.*
     wrapProgram $out/sbin/libvirtd \
-      --prefix PATH : ${makeBinPath [ iptables iproute pmutils numad numactl qemu ]}
+      --prefix PATH : /run/libvirt/nix-emulators:${makeBinPath [ iptables iproute pmutils numad numactl bridge-utils dmidecode dnsmasq ebtables ]}
   '';
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/libvisio/default.nix b/pkgs/development/libraries/libvisio/default.nix
index bda14d729476..a09e2cf2f72a 100644
--- a/pkgs/development/libraries/libvisio/default.nix
+++ b/pkgs/development/libraries/libvisio/default.nix
@@ -1,32 +1,31 @@
 { stdenv, fetchurl, boost, libwpd, libwpg, pkgconfig, zlib, gperf
-, librevenge, libxml2, icu, perl
+, librevenge, libxml2, icu, perl, cppunit, doxygen
 }:
 
 stdenv.mkDerivation rec {
-  name = "libvisio-0.1.3";
+  name = "libvisio-${version}";
+  version = "0.1.6";
+
+  outputs = [ "out" "bin" "dev" "doc" ];
 
   src = fetchurl {
-    url = "http://dev-www.libreoffice.org/src/${name}.tar.bz2";
-    sha256 = "1blgdwxprqkasm2175imcvy647sqv6xyf3k09p0b1i7hlq889wvy";
+    url = "https://dev-www.libreoffice.org/src/libvisio/${name}.tar.xz";
+    sha256 = "1yahpfl13qk6178irv8jn5ppxdn7isafqisyqsdw0lqxcz9h447y";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig cppunit doxygen ];
   buildInputs = [ boost libwpd libwpg zlib gperf librevenge libxml2 icu perl ];
 
-  # Boost 1.59 compatability fix
-  # Attempt removing when updating
-  postPatch = ''
-    sed -i 's,^CPPFLAGS.*,\0 -DBOOST_ERROR_CODE_HEADER_ONLY -DBOOST_SYSTEM_NO_DEPRECATED,' src/lib/Makefile.in
-  '';
-
   configureFlags = [
     "--disable-werror"
-    "--disable-tests"
   ];
 
-  meta = {
+  doCheck = true;
+
+  meta = with stdenv.lib; {
     description = "A library providing ability to interpret and import visio diagrams into various applications";
-    homepage = http://www.freedesktop.org/wiki/Software/libvisio;
-    platforms = stdenv.lib.platforms.unix;
+    homepage = https://wiki.documentfoundation.org/DLP/Libraries/libvisio;
+    license = licenses.mpl20;
+    platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/libvisual/default.nix b/pkgs/development/libraries/libvisual/default.nix
index 8bac0f41ddeb..2a53a1d0e7c4 100644
--- a/pkgs/development/libraries/libvisual/default.nix
+++ b/pkgs/development/libraries/libvisual/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
 
   meta = {
     description = "An abstraction library for audio visualisations";
-    homepage = http://sourceforge.net/projects/libvisual/;
+    homepage = https://sourceforge.net/projects/libvisual/;
     license = stdenv.lib.licenses.lgpl21Plus;
     platforms = stdenv.lib.platforms.unix;
   };
diff --git a/pkgs/development/libraries/libvncserver/default.nix b/pkgs/development/libraries/libvncserver/default.nix
index f7e477ff34a1..b325c9b246c2 100644
--- a/pkgs/development/libraries/libvncserver/default.nix
+++ b/pkgs/development/libraries/libvncserver/default.nix
@@ -1,12 +1,8 @@
 {stdenv, fetchurl,
-  libtool, libjpeg, openssl, libX11, libXdamage, xproto, damageproto, 
-  xextproto, libXext, fixesproto, libXfixes, xineramaproto, libXinerama, 
-  libXrandr, randrproto, libXtst, zlib, libgcrypt, autoreconfHook
-  , systemd, pkgconfig, libpng
+ libtool, libjpeg, openssl, zlib, libgcrypt, autoreconfHook, pkgconfig, libpng,
+ systemd
 }:
 
-assert stdenv.isLinux;
-
 let
   s = # Generated upstream information
   rec {
@@ -16,27 +12,25 @@ let
     url="https://github.com/LibVNC/libvncserver/archive/LibVNCServer-${version}.tar.gz";
     sha256="15189n09r1pg2nqrpgxqrcvad89cdcrca9gx6qhm6akjf81n6g8r";
   };
-  buildInputs = [
-    libtool libjpeg openssl libX11 libXdamage xproto damageproto
-    xextproto libXext fixesproto libXfixes xineramaproto libXinerama
-    libXrandr randrproto libXtst zlib libgcrypt autoreconfHook systemd
-    pkgconfig libpng
-  ];
 in
 stdenv.mkDerivation {
   inherit (s) name version;
-  inherit buildInputs;
   src = fetchurl {
     inherit (s) url sha256;
   };
   preConfigure = ''
     sed -e 's@/usr/include/linux@${stdenv.cc.libc}/include/linux@g' -i configure
   '';
+  nativeBuildInputs = [ pkgconfig autoreconfHook ];
+  buildInputs = [
+    libtool libjpeg openssl libgcrypt libpng
+  ] ++ stdenv.lib.optional stdenv.isLinux systemd;
+  propagatedBuildInputs = [ zlib ];
   meta = {
     inherit (s) version;
     description =  "VNC server library";
     license = stdenv.lib.licenses.gpl2Plus ;
     maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.linux;
+    platforms = stdenv.lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/libvorbis/default.nix b/pkgs/development/libraries/libvorbis/default.nix
index 682fcca98a36..2f9bca5ed95f 100644
--- a/pkgs/development/libraries/libvorbis/default.nix
+++ b/pkgs/development/libraries/libvorbis/default.nix
@@ -1,15 +1,22 @@
-{ stdenv, fetchurl, libogg, pkgconfig }:
+{ stdenv, fetchurl, libogg, pkgconfig, fetchpatch }:
 
 stdenv.mkDerivation rec {
-  name = "libvorbis-1.3.5";
+  name = "libvorbis-1.3.6";
 
   src = fetchurl {
     url = "http://downloads.xiph.org/releases/vorbis/${name}.tar.xz";
-    sha256 = "1lg1n3a6r41492r7in0fpvzc7909mc5ir9z0gd3qh2pz4yalmyal";
+    sha256 = "05dlzjkdpv46zb837wysxqyn8l636x3dw8v8ymlrwz2fg1dbn05g";
   };
 
   outputs = [ "out" "dev" "doc" ];
 
+  patches = [
+    (fetchpatch {
+      url = "https://gitlab.xiph.org/xiph/vorbis/uploads/a68cf70fa10c8081a633f77b5c6576b7/0001-CVE-2017-14160-make-sure-we-don-t-overflow.patch";
+      sha256 = "0v21p59cb3z77ch1v6q5dcrd733h91f3m8ifnd7kkkr8gzn17d5x";
+      name = "CVE-2017-14160";
+    })
+  ];
 
   nativeBuildInputs = [ pkgconfig ];
   propagatedBuildInputs = [ libogg ];
@@ -17,7 +24,7 @@ stdenv.mkDerivation rec {
   doCheck = true;
 
   meta = with stdenv.lib; {
-    homepage = http://xiph.org/vorbis/;
+    homepage = https://xiph.org/vorbis/;
     license = licenses.bsd3;
     maintainers = [ maintainers.ehmry ];
     platforms = platforms.all;
diff --git a/pkgs/development/libraries/libvpx/default.nix b/pkgs/development/libraries/libvpx/default.nix
index 4b50fe090e38..1e96ff9bb1ad 100644
--- a/pkgs/development/libraries/libvpx/default.nix
+++ b/pkgs/development/libraries/libvpx/default.nix
@@ -173,7 +173,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "WebM VP8/VP9 codec SDK";
-    homepage    = http://www.webmproject.org/;
+    homepage    = https://www.webmproject.org/;
     license     = licenses.bsd3;
     maintainers = with maintainers; [ codyopel ];
     platforms   = platforms.all;
diff --git a/pkgs/development/libraries/libvpx/git.nix b/pkgs/development/libraries/libvpx/git.nix
index 824449a347af..ef499f238d63 100644
--- a/pkgs/development/libraries/libvpx/git.nix
+++ b/pkgs/development/libraries/libvpx/git.nix
@@ -180,7 +180,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "WebM VP8/VP9 codec SDK";
-    homepage    = http://www.webmproject.org/;
+    homepage    = https://www.webmproject.org/;
     license     = licenses.bsd3;
     maintainers = with maintainers; [ codyopel ];
     platforms   = platforms.all;
diff --git a/pkgs/development/libraries/libwacom/default.nix b/pkgs/development/libraries/libwacom/default.nix
index 1fb0605530d7..8e36edff7edd 100644
--- a/pkgs/development/libraries/libwacom/default.nix
+++ b/pkgs/development/libraries/libwacom/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libwacom-${version}";
-  version = "0.26";
+  version = "0.28";
 
   src = fetchurl {
     url = "mirror://sourceforge/linuxwacom/libwacom/${name}.tar.bz2";
-    sha256 = "0xpvkjvzaj9blcmw8ha46616bzfivj99kwzvr91clxd6iaf11r63";
+    sha256 = "1vv768870597rvwxdb59v6pjn1pxaxg4r6znbb5j3cl828q35mp7";
   };
 
   nativeBuildInputs = [ pkgconfig ];
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     platforms = platforms.linux;
-    homepage = http://sourceforge.net/projects/linuxwacom/;
+    homepage = https://sourceforge.net/projects/linuxwacom/;
     description = "Libraries, configuration, and diagnostic tools for Wacom tablets running under Linux";
   };
 }
diff --git a/pkgs/development/libraries/libwebp/default.nix b/pkgs/development/libraries/libwebp/default.nix
index 673cd7abe7dd..f7d4fc3b3675 100644
--- a/pkgs/development/libraries/libwebp/default.nix
+++ b/pkgs/development/libraries/libwebp/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl
 , threadingSupport ? true # multi-threading
-, openglSupport ? false, freeglut ? null, mesa ? null # OpenGL (required for vwebp)
+, openglSupport ? false, freeglut ? null, libGLU_combined ? null # OpenGL (required for vwebp)
 , pngSupport ? true, libpng ? null # PNG image format
 , jpegSupport ? true, libjpeg ? null # JPEG image format
 , tiffSupport ? true, libtiff ? null # TIFF image format
@@ -14,7 +14,7 @@
 , libwebpdecoderSupport ? true # Build libwebpdecoder
 }:
 
-assert openglSupport -> ((freeglut != null) && (mesa != null));
+assert openglSupport -> ((freeglut != null) && (libGLU_combined != null));
 assert pngSupport -> (libpng != null);
 assert jpegSupport -> (libjpeg != null);
 assert tiffSupport -> (libtiff != null);
@@ -27,11 +27,11 @@ in
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "libwebp-${version}";
-  version = "0.6.0";
+  version = "0.6.1";
 
   src = fetchurl {
     url = "http://downloads.webmproject.org/releases/webp/${name}.tar.gz";
-    sha256 = "0h1brwkyxc7lb8lc53aacdks5vc1y9hzngqi41gg7y6l56912a69";
+    sha256 = "1ayq2zq0zbgf5yizbm32zh7p1vb8kibw74am6am1n5cz5mw3ql06";
   };
 
   configureFlags = [
@@ -51,7 +51,7 @@ stdenv.mkDerivation rec {
   ];
 
   buildInputs = [ ]
-    ++ optionals openglSupport [ freeglut mesa ]
+    ++ optionals openglSupport [ freeglut libGLU_combined ]
     ++ optional pngSupport libpng
     ++ optional jpegSupport libjpeg
     ++ optional tiffSupport libtiff
diff --git a/pkgs/development/libraries/libwebsockets/default.nix b/pkgs/development/libraries/libwebsockets/default.nix
index 98f3ea1679cb..3bc04f9ae3db 100644
--- a/pkgs/development/libraries/libwebsockets/default.nix
+++ b/pkgs/development/libraries/libwebsockets/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "libwebsockets-${version}";
-  version = "2.3.0";
+  version = "2.4.2";
 
   src = fetchFromGitHub {
     owner = "warmcat";
     repo = "libwebsockets";
     rev = "v${version}";
-    sha256 = "1hv2b5r6sg42xnqhm4ysjvyiz3cqpfmwaqm33vpbx0k7arj4ixvy";
+    sha256 = "0gbprzsi054f9gr31ihcf0cq7zfkybrmdp6894pmzb5hcv4wnh9i";
   };
 
   buildInputs = [ cmake openssl zlib libuv ];
diff --git a/pkgs/development/libraries/libwhereami/default.nix b/pkgs/development/libraries/libwhereami/default.nix
index 35e904989c41..880ebcc1e468 100644
--- a/pkgs/development/libraries/libwhereami/default.nix
+++ b/pkgs/development/libraries/libwhereami/default.nix
@@ -2,15 +2,18 @@
 
 stdenv.mkDerivation rec {
   name = "libwhereami-${version}";
-  version = "0.1.1";
+  version = "0.2.0";
 
   src = fetchFromGitHub {
-    sha256 = "0nhbmxm626cgawprszw6c03a3hasxjn1i9ldhhj5xyvxp8r5l9q4";
+    sha256 = "10phq4a11m8ly6b4dc2yg3dnjzg8ad5wnjv0ilvwylnw32800pxr";
     rev = version;
     repo = "libwhereami";
     owner = "puppetlabs";
   };
 
+  # post gcc7, upstream bug: https://tickets.puppetlabs.com/browse/FACT-1828
+  NIX_CFLAGS_COMPILE = "-Wno-error=deprecated";
+
   nativeBuildInputs = [ cmake ];
 
   buildInputs = [ boost curl leatherman ];
diff --git a/pkgs/development/libraries/libwnck/3.x.nix b/pkgs/development/libraries/libwnck/3.x.nix
index ed775fb45932..8efd908584e1 100644
--- a/pkgs/development/libraries/libwnck/3.x.nix
+++ b/pkgs/development/libraries/libwnck/3.x.nix
@@ -1,23 +1,38 @@
-{stdenv, fetchurl, pkgconfig, libX11, gtk3, intltool}:
+{stdenv, fetchurl, pkgconfig, libX11, gtk3, intltool, gobjectIntrospection, gnome3}:
 
-stdenv.mkDerivation {
-  name = "libwnck-3.4.7";
+let
+  pname = "libwnck";
+  version = "3.24.1";
+in stdenv.mkDerivation rec{
+  name = "${pname}-${version}";
 
   src = fetchurl {
-    url = mirror://gnome/sources/libwnck/3.4/libwnck-3.4.7.tar.xz;
-    sha256 = "d48ac9c7f50c0d563097f63d07bcc83744c7d92a1b4ef65e5faeab32b5ccb723";
+    url = "mirror://gnome/sources/${pname}/${gnome3.versionBranch version}/${name}.tar.xz";
+    sha256 = "010zk9zvydggxqnxfml3scml5yxmpjy90irpqcayrzw26lldr9mg";
   };
 
   outputs = [ "out" "dev" "devdoc" ];
   outputBin = "dev";
 
-  patches = [ ./install_introspection_to_prefix.patch ];
+  configureFlags = [ "--enable-introspection" ];
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ intltool ];
+  nativeBuildInputs = [ pkgconfig intltool gobjectIntrospection ];
   propagatedBuildInputs = [ libX11 gtk3 ];
 
-  meta = {
-    platforms = stdenv.lib.platforms.linux;
+  PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_GIRDIR = "$(dev)/share/gir-1.0";
+  PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_TYPELIBDIR = "$(out)/lib/girepository-1.0";
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+      attrPath = "gnome3.${pname}";
+    };
+  };
+
+  meta = with stdenv.lib; {
+    description = "Library to manage X windows and workspaces (via pagers, tasklists, etc.)";
+    license = licenses.lgpl21Plus;
+    platforms = platforms.linux;
+    maintainers = [];
   };
 }
diff --git a/pkgs/development/libraries/libwnck/install_introspection_to_prefix.patch b/pkgs/development/libraries/libwnck/install_introspection_to_prefix.patch
deleted file mode 100644
index 1bcf4a12ea31..000000000000
--- a/pkgs/development/libraries/libwnck/install_introspection_to_prefix.patch
+++ /dev/null
@@ -1,12 +0,0 @@
---- libwnck-3.4.7/configure	2013-08-20 14:46:14.000000000 +0000
-+++ libwnck-3.4.7-fix/configure	2014-01-05 17:18:56.665427787 +0000
-@@ -16150,7 +16150,7 @@ $as_echo "$found_introspection" >&6; }
-        INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
-        INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
--       INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
-+       INTROSPECTION_GIRDIR="${datadir}/gir-1.0"
--       INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
-+       INTROSPECTION_TYPELIBDIR="${libdir}/girepository-1.0"
-        INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
-        INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
-        INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
diff --git a/pkgs/development/libraries/libwpg/default.nix b/pkgs/development/libraries/libwpg/default.nix
index 57dfe34132f5..9d262910e14f 100644
--- a/pkgs/development/libraries/libwpg/default.nix
+++ b/pkgs/development/libraries/libwpg/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, pkgconfig, libwpd, zlib, librevenge }:
 
 stdenv.mkDerivation rec {
-  name = "libwpg-0.3.0";
+  name = "libwpg-0.3.2";
 
   src = fetchurl {
     url = "mirror://sourceforge/libwpg/${name}.tar.xz";
-    sha256 = "097jx8a638fwwfrzf6v29r1yhc34rq9526py7wf0ck2z4fcr2w3g";
+    sha256 = "0cwc5zkp210c661l0bvk6q21jg9ak5g8gmy578w5fgfnjymz3yjp";
   };
 
   buildInputs = [ libwpd zlib librevenge ];
diff --git a/pkgs/development/libraries/libwps/default.nix b/pkgs/development/libraries/libwps/default.nix
index 73fe5b55ab45..84748d601a64 100644
--- a/pkgs/development/libraries/libwps/default.nix
+++ b/pkgs/development/libraries/libwps/default.nix
@@ -2,16 +2,18 @@
 
 stdenv.mkDerivation rec {
   name = "libwps-${version}";
-  version = "0.4.3";
+  version = "0.4.8";
 
   src = fetchurl {
     url = "mirror://sourceforge/libwps/${name}.tar.bz2";
-    sha256 = "0v1a0hj96i4jhb5833336s4zcslzb6md5cnmnrvgywx8cmw40c0c";
+    sha256 = "163gdqaanqfs767aj6zdzagqldngn8i7f0hbmhhxlxr0wmvx6c9q";
   };
 
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ boost librevenge zlib ];
 
+  NIX_CFLAGS_COMPILE = [ "-Wno-error=implicit-fallthrough" ]; # newly detected by gcc-7
+
   meta = with stdenv.lib; {
     homepage = http://libwps.sourceforge.net/;
     description = "Microsoft Works document format import filter library";
diff --git a/pkgs/development/libraries/libx86emu/default.nix b/pkgs/development/libraries/libx86emu/default.nix
index ee32d9418dd9..b745098bd64b 100644
--- a/pkgs/development/libraries/libx86emu/default.nix
+++ b/pkgs/development/libraries/libx86emu/default.nix
@@ -1,27 +1,29 @@
-{ stdenv, fetchurl, perl }:
+{ stdenv, fetchFromGitHub, perl }:
 
 stdenv.mkDerivation rec {
   name = "libx86emu-${version}";
-  version = "1.5";
+  version = "1.12";
 
-  src = fetchurl {
-    url = "https://github.com/wfeldt/libx86emu/archive/${version}.tar.gz";
-    sha256 = "1im6w6m0bl6ajynx4hc028lad8v10whv4y7w9zxndzh3j4mi3aa8";
+  src = fetchFromGitHub {
+    owner = "wfeldt";
+    repo = "libx86emu";
+    rev = version;
+    sha256 = "0dlzvwdkk0vc6qf0a0zzbxki3pig1mda8p3fa54rxqaxkwp4mqr6";
   };
 
-  buildInputs = [ perl ];
+  nativeBuildInputs = [ perl ];
 
+  postUnpack = "rm $sourceRoot/git2log";
   patchPhase = ''
     # VERSION is usually generated using Git
     echo "${version}" > VERSION
-    sed -i 's|/usr/|/|g' Makefile
+    substituteInPlace Makefile --replace "/usr" "/"
   '';
 
-  makeFlags = [ "shared" ];
+  buildFlags = [ "shared" ];
+  enableParallelBuilding = true;
 
-  installPhase = ''
-    make install DESTDIR=$out/ LIBDIR=lib
-  '';
+  installFlags = [ "DESTDIR=$(out)" "LIBDIR=/lib" ];
 
   meta = with stdenv.lib; {
     description = "x86 emulation library";
diff --git a/pkgs/development/libraries/libxc/default.nix b/pkgs/development/libraries/libxc/default.nix
new file mode 100644
index 000000000000..67ec3b57fa77
--- /dev/null
+++ b/pkgs/development/libraries/libxc/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchurl, gfortran, perl }:
+
+let
+  version = "3.0.1";
+
+in stdenv.mkDerivation {
+  name = "libxc-${version}";
+  src = fetchurl {
+    url = "http://www.tddft.org/programs/octopus/down.php?file=libxc/${version}/libxc-${version}.tar.gz";
+    sha256 = "1xyac89yx03vm86rvk07ps1d39xss3amw46a1k53mv30mgr94rl3";
+  };
+
+  buildInputs = [ gfortran ];
+  nativeBuildInputs = [ perl ];
+
+  preConfigure = ''
+    patchShebangs ./
+  '';
+
+  configureFlags = [ "--enable-shared" ];
+
+  doCheck = true;
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "Library of exchange-correlation functionals for density-functional theory";
+    homepage = http://octopus-code.org/wiki/Libxc;
+    license = licenses.lgpl3;
+    platforms = [ "x86_64-linux" ];
+    maintainers = with maintainers; [ markuskowa ];
+  };
+}
diff --git a/pkgs/development/libraries/libxcomp/default.nix b/pkgs/development/libraries/libxcomp/default.nix
index f38c7a900329..d225831f7024 100644
--- a/pkgs/development/libraries/libxcomp/default.nix
+++ b/pkgs/development/libraries/libxcomp/default.nix
@@ -1,19 +1,20 @@
-{ stdenv, fetchurl, autoreconfHook, libjpeg, libpng, libX11, zlib }:
+{ stdenv, fetchurl, autoreconfHook, pkgconfig, libjpeg, libpng, libX11, zlib }:
 
 stdenv.mkDerivation rec {
   name = "libxcomp-${version}";
-  version = "3.5.0.32";
+  version = "3.5.99.16";
 
   src = fetchurl {
-    sha256 = "02n5bdc1jsq999agb4w6dmdj5l2wlln2lka84qz6rpswwc59zaxm";
+    sha256 = "1m3z9w3h6qpgk265xf030w7lcs181jgw2cdyzshb7l97mn1f7hh2";
     url = "http://code.x2go.org/releases/source/nx-libs/nx-libs-${version}-lite.tar.gz";
   };
 
   buildInputs = [ libjpeg libpng libX11 zlib ];
-  nativeBuildInputs = [ autoreconfHook ];
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
 
   preAutoreconf = ''
     cd nxcomp/
+    sed -i 's|/src/.libs/libXcomp.a|/src/.libs/libXcomp.la|' test/Makefile.am
   '';
 
   enableParallelBuilding = true;
@@ -23,6 +24,5 @@ stdenv.mkDerivation rec {
     homepage = http://wiki.x2go.org/doku.php/wiki:libs:nx-libs;
     license = licenses.gpl2;
     platforms = platforms.linux;
-    maintainers = with maintainers; [ nckx ];
   };
 }
diff --git a/pkgs/development/libraries/libxkbcommon/default.nix b/pkgs/development/libraries/libxkbcommon/default.nix
index e730cc6eaabf..faeed680f3d6 100644
--- a/pkgs/development/libraries/libxkbcommon/default.nix
+++ b/pkgs/development/libraries/libxkbcommon/default.nix
@@ -1,30 +1,35 @@
-{ stdenv, fetchurl, pkgconfig, yacc, flex, xkeyboard_config, libxcb, libX11 }:
+{ stdenv, fetchurl, fetchpatch, meson, ninja, pkgconfig, yacc, xkeyboard_config, libxcb, libX11, doxygen }:
 
 stdenv.mkDerivation rec {
-  name = "libxkbcommon-0.7.2";
+  name = "libxkbcommon-0.8.0";
 
   src = fetchurl {
-    url = "http://xkbcommon.org/download/${name}.tar.xz";
-    sha256 = "1n5rv5n210kjnkyrvbh04gfwaa7zrmzy1393p8nyqfw66lkxr918";
+    url = "https://xkbcommon.org/download/${name}.tar.xz";
+    sha256 = "0vgy84vfbig5bqznr137h5arjidnfwrxrdli0pxyn2jfn1fjcag8";
   };
 
-  outputs = [ "out" "dev" ];
+  outputs = [ "out" "dev" "doc" ];
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ yacc flex xkeyboard_config libxcb ];
+  nativeBuildInputs = [ meson ninja pkgconfig yacc doxygen ];
+  buildInputs = [ xkeyboard_config libxcb ];
 
-  configureFlags = [
-    "--with-xkb-config-root=${xkeyboard_config}/etc/X11/xkb"
-    "--with-x-locale-root=${libX11.out}/share/X11/locale"
+  patches = [
+    # darwin compatibility
+    (fetchpatch {
+      url = https://github.com/xkbcommon/libxkbcommon/commit/edb1c662394578a54b7bbed231d918925e5d8150.patch;
+      sha256 = "0ydjlir32r3xfsbqhnsx1bz6ags2m908yhf9i09i1s7sgcimbcx5";
+    })
   ];
 
-  preBuild = stdenv.lib.optionalString stdenv.isDarwin ''
-    sed -i 's/,--version-script=.*$//' Makefile
-  '';
+  mesonFlags = [
+    "-Denable-wayland=false"
+    "-Dxkb-config-root=${xkeyboard_config}/etc/X11/xkb"
+    "-Dx-locale-root=${libX11.out}/share/X11/locale"
+  ];
 
   meta = with stdenv.lib; {
     description = "A library to handle keyboard descriptions";
-    homepage = http://xkbcommon.org;
+    homepage = https://xkbcommon.org;
     license = licenses.mit;
     maintainers = with maintainers; [ garbas ttuegel ];
     platforms = with platforms; unix;
diff --git a/pkgs/development/libraries/libxl/default.nix b/pkgs/development/libraries/libxl/default.nix
new file mode 100644
index 000000000000..035bfa8d6dc3
--- /dev/null
+++ b/pkgs/development/libraries/libxl/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "libxl";
+  version = "3.8.1";
+
+  src = fetchurl {
+    url = "http://www.libxl.com/download/${name}-lin-${version}.tar.gz";
+    sha256 = "1zdbahhyhr70s8hygwp43j9z4zmglyrr782hkcm1078yvkr2f2fm";
+  };
+
+  phases = [ "unpackPhase" "installPhase" "fixupPhase" ];
+
+  installPhase = ''
+    mkdir $out
+    cp -rva include_c include_cpp license.txt $out/
+    cp -rva lib64 $out/lib
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A lbrary for parsing excel files";
+    license     = licenses.unfree;
+    platforms   = platforms.linux;
+    maintainers = with maintainers; [  ];
+  };
+}
diff --git a/pkgs/development/libraries/libxls/default.nix b/pkgs/development/libraries/libxls/default.nix
index 0d7115144449..3a3d99b655da 100644
--- a/pkgs/development/libraries/libxls/default.nix
+++ b/pkgs/development/libraries/libxls/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "Extract Cell Data From Excel xls files";
-    homepage = http://sourceforge.net/projects/libxls/;
+    homepage = https://sourceforge.net/projects/libxls/;
     license = licenses.bsd2;
     platforms = platforms.unix;
     maintainers = with maintainers; [ abbradar ];
diff --git a/pkgs/development/libraries/libxml2/default.nix b/pkgs/development/libraries/libxml2/default.nix
index bf38a954d60d..c4f3ff1efdd5 100644
--- a/pkgs/development/libraries/libxml2/default.nix
+++ b/pkgs/development/libraries/libxml2/default.nix
@@ -10,11 +10,11 @@ let
 
 in stdenv.mkDerivation rec {
   name = "libxml2-${version}";
-  version = "2.9.5";
+  version = "2.9.7";
 
   src = fetchurl {
     url = "http://xmlsoft.org/sources/${name}.tar.gz";
-    sha256 = "0f6d5nkvcfx8yqis2dwrnv6qaj0nhiifz49y657vmrwwxvnc2ca0";
+    sha256 = "034hylzspvkm0p4bczqbf8q05a7r2disr8dz725x4bin61ymwg7n";
   };
 
   outputs = [ "bin" "dev" "out" "man" "doc" ]
@@ -36,7 +36,8 @@ in stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  doCheck = (stdenv.hostPlatform == stdenv.buildPlatform) && !stdenv.isDarwin;
+  doCheck = (stdenv.hostPlatform == stdenv.buildPlatform) && !stdenv.isDarwin &&
+    hostPlatform.libc != "musl";
 
   crossAttrs = lib.optionalAttrs (hostPlatform.libc == "msvcrt") {
     # creating the DLL is broken ATM
diff --git a/pkgs/development/libraries/libxmlxx/default.nix b/pkgs/development/libraries/libxmlxx/default.nix
index 23b36db8fe10..226fe5be536a 100644
--- a/pkgs/development/libraries/libxmlxx/default.nix
+++ b/pkgs/development/libraries/libxmlxx/default.nix
@@ -10,6 +10,8 @@ stdenv.mkDerivation rec {
     sha256 = "1sb3akryklvh2v6m6dihdnbpf1lkx441v972q9hlz1sq6bfspm2a";
   };
 
+  outputs = [ "out" "devdoc" ];
+
   nativeBuildInputs = [ pkgconfig perl ];
 
   propagatedBuildInputs = [ libxml2 glibmm ];
diff --git a/pkgs/development/libraries/libxmlxx/v3.nix b/pkgs/development/libraries/libxmlxx/v3.nix
index 646fdfbac4f3..5e1e947b8f7c 100644
--- a/pkgs/development/libraries/libxmlxx/v3.nix
+++ b/pkgs/development/libraries/libxmlxx/v3.nix
@@ -10,6 +10,8 @@ stdenv.mkDerivation rec {
     sha256 = "19kik79fmg61nv0by0a5f9wchrcfjwzvih4v2waw01hqflhqvp0r";
   };
 
+  outputs = [ "out" "devdoc" ];
+
   nativeBuildInputs = [ pkgconfig perl ];
 
   buildInputs = [ glibmm ];
diff --git a/pkgs/development/libraries/libxmp/default.nix b/pkgs/development/libraries/libxmp/default.nix
index 28584d14a877..ca4d7edbf32d 100644
--- a/pkgs/development/libraries/libxmp/default.nix
+++ b/pkgs/development/libraries/libxmp/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "libxmp-4.3.12";
+  name = "libxmp-4.4.1";
 
   meta = with stdenv.lib; {
     description = "Extended module player library";
@@ -17,6 +17,6 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "mirror://sourceforge/xmp/libxmp/${name}.tar.gz";
-    sha256 = "1536dfxgxl6dyvkdby8lxzi9f7y2qlwl8ylrkybips3ampcqgkhm";
+    sha256 = "1kycz4jsyvmf7ny9227b497wc7y5ligydi6fvvldmkf8hk63ad9m";
   };
 }
diff --git a/pkgs/development/libraries/libxslt/default.nix b/pkgs/development/libraries/libxslt/default.nix
index 1c27b6e3233b..1bb90ee195da 100644
--- a/pkgs/development/libraries/libxslt/default.nix
+++ b/pkgs/development/libraries/libxslt/default.nix
@@ -10,21 +10,16 @@ assert pythonSupport -> libxml2.pythonSupport;
 with stdenv.lib;
 
 stdenv.mkDerivation rec {
-  name = "libxslt-1.1.29";
+  pname = "libxslt";
+  version = "1.1.32";
+  name = pname + "-" + version;
 
   src = fetchurl {
     url = "http://xmlsoft.org/sources/${name}.tar.gz";
-    sha256 = "1klh81xbm9ppzgqk339097i39b7fnpmlj8lzn8bpczl3aww6x5xm";
+    sha256 = "0q2l6m56iv3ysxgm2walhg4c9wp7q183jb328687i9zlp85csvjj";
   };
 
-  patches = [
-    (fetchpatch {
-      name = "CVE-2017-5029";
-      url = "https://git.gnome.org/browse/libxslt/"
-        + "patch/?id=08ab2774b870de1c7b5a48693df75e8154addae5";
-      sha256 = "10azfmyffjf9d7b5js4ipxw9f20qi0kw3zq34bpqmbcpq3l338ky";
-    })
-  ] ++ stdenv.lib.optional stdenv.isSunOS ./patch-ah.patch;
+  patches = stdenv.lib.optional stdenv.isSunOS ./patch-ah.patch;
 
   # fixes: can't build x86_64-unknown-cygwin shared library unless -no-undefined is specified
   postPatch = optionalString hostPlatform.isCygwin ''
@@ -38,12 +33,13 @@ stdenv.mkDerivation rec {
 
   propagatedBuildInputs = [ findXMLCatalogs ];
 
-  # TODO move cryptoSupport as last flag, when upgrading libxslt
-  configureFlags = optional (!cryptoSupport) "--without-crypto" ++ [
+  configureFlags = [
+    "--with-libxml-prefix=${libxml2.dev}"
     "--without-debug"
     "--without-mem-debug"
     "--without-debugger"
-  ] ++ optional pythonSupport "--with-python=${python2}";
+  ] ++ optional pythonSupport "--with-python=${python2}"
+    ++ optional (!cryptoSupport) "--without-crypto";
 
   postFixup = ''
     moveToOutput bin/xslt-config "$dev"
@@ -51,7 +47,7 @@ stdenv.mkDerivation rec {
     moveToOutput share/man/man1 "$bin"
   '' + optionalString pythonSupport ''
     mkdir -p $py/nix-support
-    echo ${libxml2.py} >> $py/nix-support/propagated-native-build-inputs
+    echo ${libxml2.py} >> $py/nix-support/propagated-build-inputs
     moveToOutput lib/python2.7 "$py"
   '';
 
diff --git a/pkgs/development/libraries/libyaml-cpp/default.nix b/pkgs/development/libraries/libyaml-cpp/default.nix
index f02843707265..ff09aeab2c6f 100644
--- a/pkgs/development/libraries/libyaml-cpp/default.nix
+++ b/pkgs/development/libraries/libyaml-cpp/default.nix
@@ -2,28 +2,26 @@
 
 stdenv.mkDerivation rec {
   name = "libyaml-cpp-${version}";
-  version = "0.5.3";
+  version = "0.6.2";
 
   src = fetchFromGitHub {
     owner = "jbeder";
     repo = "yaml-cpp";
-    rev = "release-${version}";
-    sha256 = "0qr286q8mwbr4cxz0y0rf045zc071qh3cb804by6w1ydlqciih8a";
+    rev = "yaml-cpp-${version}";
+    sha256 = "16lclpa487yghf9019wymj419wkyx4795wv9q7539hhimajw9kpb";
   };
 
   outputs = [ "out" "dev" ];
 
-  buildInputs = [ cmake boost ];
+  nativeBuildInputs = [ cmake ];
 
   cmakeFlags = "-DBUILD_SHARED_LIBS=ON";
 
-  enableParallelBuilding = true;
-
   meta = with stdenv.lib; {
     inherit (src.meta) homepage;
     description = "A YAML parser and emitter for C++";
     license = licenses.mit;
     platforms = platforms.unix;
-    maintainers = with maintainers; [ wkennington ];
+    maintainers = with maintainers; [ andir ];
   };
 }
diff --git a/pkgs/development/libraries/libyubikey/default.nix b/pkgs/development/libraries/libyubikey/default.nix
index aa2c81313922..5b10e62deee7 100644
--- a/pkgs/development/libraries/libyubikey/default.nix
+++ b/pkgs/development/libraries/libyubikey/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
     homepage = http://opensource.yubico.com/yubico-c/;
     description = "C library for manipulating Yubico YubiKey One-Time Passwords (OTPs)";
     license = licenses.bsd2;
-    maintainers = with maintainers; [ calrama wkennington ];
+    maintainers = with maintainers; [ wkennington ];
     platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/libzdb/default.nix b/pkgs/development/libraries/libzdb/default.nix
index a5799f79b56b..4a5aa057a5cf 100644
--- a/pkgs/development/libraries/libzdb/default.nix
+++ b/pkgs/development/libraries/libzdb/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec
 {
-  version = "3.0";
+  version = "3.1";
   name = "libzdb-${version}";
 
   src = fetchurl
   {
     url = "http://www.tildeslash.com/libzdb/dist/libzdb-${version}.tar.gz";
-    sha256 = "e334bcb9ca1410e863634a164e3b1b5784018eb6e90b6c2b527780fc29a123c8";
+    sha256 = "1596njvy518x7vsvsykmnk1ky82x8jxd6nmmp551y6hxn2qsn08g";
   };
 
   buildInputs = [ sqlite ];
@@ -19,6 +19,6 @@ stdenv.mkDerivation rec
     description = "A small, easy to use Open Source Database Connection Pool Library";
     license = stdenv.lib.licenses.gpl3;
     platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.calrama ];
+    maintainers = [ ];
   };
-}
\ No newline at end of file
+}
diff --git a/pkgs/development/libraries/libzen/default.nix b/pkgs/development/libraries/libzen/default.nix
index ab473bbe85c1..afa7696aca99 100644
--- a/pkgs/development/libraries/libzen/default.nix
+++ b/pkgs/development/libraries/libzen/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, autoreconfHook }:
 
 stdenv.mkDerivation rec {
-  version = "0.4.35";
+  version = "0.4.37";
   name = "libzen-${version}";
   src = fetchurl {
     url = "https://mediaarea.net/download/source/libzen/${version}/libzen_${version}.tar.bz2";
-    sha256 = "12a1icgcffgv503ii2k1453kxg5hfly09mf4zjcc80aq8a6rf8by";
+    sha256 = "1hcsrmn85b0xp0mp33aazk7g071q1v3f163nnhv8b0mv9c4bgsfn";
   };
 
   nativeBuildInputs = [ autoreconfHook ];
@@ -15,6 +15,8 @@ stdenv.mkDerivation rec {
 
   preConfigure = "sh autogen.sh";
 
+  enableParallelBuilding = true;
+
   meta = with stdenv.lib; {
     description = "Shared library for libmediainfo and mediainfo";
     homepage = https://mediaarea.net/;
diff --git a/pkgs/development/libraries/libzip/default.nix b/pkgs/development/libraries/libzip/default.nix
index 9958a65d408b..131b64c1c7f2 100644
--- a/pkgs/development/libraries/libzip/default.nix
+++ b/pkgs/development/libraries/libzip/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libzip-${version}";
-  version = "1.2.0";
+  version = "1.3.0";
 
   src = fetchurl {
-    url = "http://www.nih.at/libzip/${name}.tar.gz";
-    sha256 = "17vxj2ffsxwh8lkc6801ppmwj15jp8q58rin76znxfbx88789ybc";
+    url = "https://www.nih.at/libzip/${name}.tar.gz";
+    sha256 = "1633dvjc08zwwhzqhnv62rjf1abx8y5njmm8y16ik9iwd07ka6d9";
   };
 
   outputs = [ "out" "dev" ];
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
   '';
 
   meta = {
-    homepage = http://www.nih.at/libzip;
+    homepage = https://www.nih.at/libzip;
     description = "A C library for reading, creating and modifying zip archives";
     platforms = stdenv.lib.platforms.unix;
   };
diff --git a/pkgs/development/libraries/libzmf/default.nix b/pkgs/development/libraries/libzmf/default.nix
index e20aa514aa2a..6050a7080df9 100644
--- a/pkgs/development/libraries/libzmf/default.nix
+++ b/pkgs/development/libraries/libzmf/default.nix
@@ -3,11 +3,11 @@
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
   pname = "libzmf";
-  version = "0.0.1";
+  version = "0.0.2";
   
   src = fetchurl {
     url = "http://dev-www.libreoffice.org/src/libzmf/${name}.tar.xz";
-    sha256 = "0yp5l1b90xim506zmr3ljkn3qkvbc7qk3dnwq1snxdpr57m37xga";
+    sha256 = "08mg5kmkjrmqrd8j5rkzw9vdqlvibhb1ynp6bmfxnzq5rcq1l197";
   };
 
   buildInputs = [boost icu libpng librevenge zlib cppunit];
diff --git a/pkgs/development/libraries/lightning/default.nix b/pkgs/development/libraries/lightning/default.nix
index 5868fdf8b63a..b4a33bbe7df2 100644
--- a/pkgs/development/libraries/lightning/default.nix
+++ b/pkgs/development/libraries/lightning/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, binutils }:
+{ stdenv, fetchurl, libopcodes }:
 
 with stdenv.lib;
 stdenv.mkDerivation rec {
@@ -11,8 +11,7 @@ stdenv.mkDerivation rec {
     sha256 = "19j9nwl88k660045s40cbz5zrl1wpd2mcxnnc8qqnnaj311a58qz";
   };
 
-  # Needs libopcodes.so from binutils for 'make check'
-  buildInputs = [ binutils ];
+  buildInputs = stdenv.lib.optional doCheck libopcodes;
 
   doCheck = true;
 
diff --git a/pkgs/development/libraries/lightstep-tracer-cpp/default.nix b/pkgs/development/libraries/lightstep-tracer-cpp/default.nix
index 9aea42082c51..f2a8d75a9cbb 100644
--- a/pkgs/development/libraries/lightstep-tracer-cpp/default.nix
+++ b/pkgs/development/libraries/lightstep-tracer-cpp/default.nix
@@ -44,9 +44,10 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "Distributed tracing system built on top of the OpenTracing standard";
-    homepage = "http://lightstep.com/";
+    homepage = "https://lightstep.com/";
     license = licenses.mit;
     platforms = platforms.linux;
     maintainers = with maintainers; [ cstrahan ];
+    broken = true; # 2018-02-16
   };
 }
diff --git a/pkgs/development/libraries/liquidfun/default.nix b/pkgs/development/libraries/liquidfun/default.nix
index a4dc7b5e93d1..9c1815f840b4 100644
--- a/pkgs/development/libraries/liquidfun/default.nix
+++ b/pkgs/development/libraries/liquidfun/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, requireFile, cmake, mesa, libX11, libXi }:
+{ stdenv, requireFile, cmake, libGLU_combined, libX11, libXi }:
 
 let 
   sourceInfo = rec {
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
   };
 
   inherit (sourceInfo) name version;
-  buildInputs = [ cmake mesa libX11 libXi ];
+  buildInputs = [ cmake libGLU_combined libX11 libXi ];
 
   sourceRoot = "liquidfun/Box2D/";
 
diff --git a/pkgs/development/libraries/lirc/default.nix b/pkgs/development/libraries/lirc/default.nix
index 960c8cc24949..7f4d8cc19c8e 100644
--- a/pkgs/development/libraries/lirc/default.nix
+++ b/pkgs/development/libraries/lirc/default.nix
@@ -1,31 +1,45 @@
-{ stdenv, fetchurl, alsaLib, bash, help2man, pkgconfig, xlibsWrapper, python3, libxslt }:
+{ stdenv, fetchurl, alsaLib, bash, help2man, pkgconfig, xlibsWrapper, python3
+, libxslt, systemd, libusb, libftdi1 }:
 
 stdenv.mkDerivation rec {
-  name = "lirc-0.9.4";
+  name = "lirc-0.10.1";
 
   src = fetchurl {
     url = "mirror://sourceforge/lirc/${name}.tar.bz2";
-    sha256 = "19c6ldjsdnk1md66q3nb035ja1xj217k8iabhxpsb8rs10a6kwi6";
+    sha256 = "1whlyifvvc7w04ahq07nnk1h18wc8j7c6wnvlb6mszravxh3qxcb";
   };
 
-  preBuild = "patchShebangs .";
+  postPatch = ''
+    patchShebangs .
+
+    # fix overriding PYTHONPATH
+    sed -i 's,^PYTHONPATH *= *,PYTHONPATH := $(PYTHONPATH):,' \
+      Makefile.in
+    sed -i 's,PYTHONPATH=,PYTHONPATH=$(PYTHONPATH):,' \
+      doc/Makefile.in
+  '';
+
+  preConfigure = ''
+    # use empty inc file instead of a from linux kernel generated one
+    touch lib/lirc/input_map.inc
+  '';
 
   nativeBuildInputs = [ pkgconfig help2man ];
 
-  buildInputs = [ alsaLib xlibsWrapper python3 libxslt ];
+  buildInputs = [ alsaLib xlibsWrapper libxslt systemd libusb libftdi1 ]
+  ++ (with python3.pkgs; [ python pyyaml setuptools ]);
 
   configureFlags = [
-    "--with-driver=devinput"
     "--sysconfdir=/etc"
     "--localstatedir=/var"
-    "--enable-sandboxed"
+    "--with-systemdsystemunitdir=$(out)/lib/systemd/system"
+    "--enable-uinput" # explicite activation because build env has no uinput
+    "--enable-devinput" # explicite activation because build env has not /dev/input
   ];
 
-  makeFlags = [ "m4dir=$(out)/m4" ];
-
   installFlags = [
-    "sysconfdir=\${out}/etc"
-    "localstatedir=\${TMPDIR}"
+    "sysconfdir=$out/etc"
+    "localstatedir=$TMPDIR"
   ];
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/live555/default.nix b/pkgs/development/libraries/live555/default.nix
index de4d295ebe3b..1479f7b6153b 100644
--- a/pkgs/development/libraries/live555/default.nix
+++ b/pkgs/development/libraries/live555/default.nix
@@ -2,17 +2,22 @@
 
 # Based on https://projects.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD
 let
-  version = "2016.02.09";
+  version = "2018.02.28";
 in
 stdenv.mkDerivation {
   name = "live555-${version}";
 
   src = fetchurl { # the upstream doesn't provide a stable URL
     url = "mirror://sourceforge/slackbuildsdirectlinks/live.${version}.tar.gz";
-    sha256 = "02z2f8z5cy0ajnh9pgar40lsxdknfw5cbyw52138hxnpr6adrvak";
+    sha256 = "0zi47asv1qmb09g321m02q684i3c90vci0mgkdh1mlmx2rbg1d1d";
   };
 
-  postPatch = "sed 's,/bin/rm,rm,g' -i genMakefiles";
+  postPatch = "sed 's,/bin/rm,rm,g' -i genMakefiles"
+  + stdenv.lib.optionalString (stdenv ? glibc) ''
+
+    substituteInPlace liveMedia/include/Locale.hh \
+      --replace '<xlocale.h>' '<locale.h>'
+  '';
 
   configurePhase = ''
     sed \
diff --git a/pkgs/development/libraries/lmdb/default.nix b/pkgs/development/libraries/lmdb/default.nix
index d96b5ed6d520..0bb3a67d9502 100644
--- a/pkgs/development/libraries/lmdb/default.nix
+++ b/pkgs/development/libraries/lmdb/default.nix
@@ -2,17 +2,20 @@
 
 stdenv.mkDerivation rec {
   name = "lmdb-${version}";
-  version = "0.9.21";
+  version = "0.9.22";
 
   src = fetchFromGitHub {
     owner = "LMDB";
     repo = "lmdb";
     rev = "LMDB_${version}";
-    sha256 = "026a6himvg3y4ssnccdbgr3c2pq3w2d47nayn05v512875z4f2w3";
+    sha256 = "0lng4ra2qrbqcf8klvqp68qarha0z4bkqhhv8lhh45agsxyrhfkj";
   };
 
   postUnpack = "sourceRoot=\${sourceRoot}/libraries/liblmdb";
 
+  patches = [ ./hardcoded-compiler.patch ];
+  patchFlags = "-p3";
+
   outputs = [ "bin" "out" "dev" ];
 
   makeFlags = [ "prefix=$(out)" "CC=cc" ]
diff --git a/pkgs/development/libraries/lmdb/hardcoded-compiler.patch b/pkgs/development/libraries/lmdb/hardcoded-compiler.patch
new file mode 100644
index 000000000000..ddb247b7f113
--- /dev/null
+++ b/pkgs/development/libraries/lmdb/hardcoded-compiler.patch
@@ -0,0 +1,26 @@
+commit 029031a68873bc3784a8561bd8e049efbd34f9d0 (HEAD)
+Author: Vladimír Čunát <vcunat@gmail.com>
+Date:   Sun Apr 1 11:05:31 2018 +0200
+
+    make: gcc -> $(CC)
+
+diff --git a/libraries/liblmdb/Makefile b/libraries/liblmdb/Makefile
+index f254511..612484e 100644
+--- a/libraries/liblmdb/Makefile
++++ b/libraries/liblmdb/Makefile
+@@ -102,13 +102,13 @@ COV_OBJS=xmdb.o xmidl.o
+ 
+ coverage: xmtest
+ 	for i in mtest*.c [0-9]*.c; do j=`basename \$$i .c`; $(MAKE) $$j.o; \
+-		gcc -o x$$j $$j.o $(COV_OBJS) -pthread $(COV_FLAGS); \
++		$(CC) -o x$$j $$j.o $(COV_OBJS) -pthread $(COV_FLAGS); \
+ 		rm -rf testdb; mkdir testdb; ./x$$j; done
+ 	gcov xmdb.c
+ 	gcov xmidl.c
+ 
+ xmtest:	mtest.o xmdb.o xmidl.o
+-	gcc -o xmtest mtest.o xmdb.o xmidl.o -pthread $(COV_FLAGS)
++	$(CC) -o xmtest mtest.o xmdb.o xmidl.o -pthread $(COV_FLAGS)
+ 
+ xmdb.o: mdb.c lmdb.h midl.h
+ 	$(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -O0 $(COV_FLAGS) -c mdb.c -o $@
diff --git a/pkgs/development/libraries/log4cpp/default.nix b/pkgs/development/libraries/log4cpp/default.nix
index 96cbbb770b4c..d2918c87f335 100644
--- a/pkgs/development/libraries/log4cpp/default.nix
+++ b/pkgs/development/libraries/log4cpp/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "log4cpp-1.1.1";
+  name = "log4cpp-1.1.3";
 
   src = fetchurl {
     url = "mirror://sourceforge/log4cpp/${name}.tar.gz";
-    sha256 = "1l5yz5rfzzv6g3ynrj14mxfsk08cp5h1ssr7d74hjs0accrg7arm";
+    sha256 = "07gmr3jyaf2239n9sp6h7hwdz1pv7b7aka8n06gmr2fnlmaymfrc";
   };
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/log4cxx/default.nix b/pkgs/development/libraries/log4cxx/default.nix
index ac0b7bf68341..8e8541564245 100644
--- a/pkgs/development/libraries/log4cxx/default.nix
+++ b/pkgs/development/libraries/log4cxx/default.nix
@@ -34,7 +34,7 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ libtool ];
 
   meta = {
-    homepage = http://logging.apache.org/log4cxx/index.html;
+    homepage = https://logging.apache.org/log4cxx/index.html;
     description = "A logging framework for C++ patterned after Apache log4j";
     license = stdenv.lib.licenses.asl20;
     platforms = stdenv.lib.platforms.unix;
diff --git a/pkgs/development/libraries/luaffi/darwin.patch b/pkgs/development/libraries/luaffi/darwin.patch
new file mode 100644
index 000000000000..50db81b776d7
--- /dev/null
+++ b/pkgs/development/libraries/luaffi/darwin.patch
@@ -0,0 +1,17 @@
+diff --git a/Makefile b/Makefile
+index b2b5f2c..b690a5d 100644
+--- a/Makefile
++++ b/Makefile
+@@ -18,10 +18,10 @@ test:
+ 	if [ `uname` = "Darwin" ]; then $(MAKE) test_macosx; else $(MAKE) test_posix; fi
+ 
+ macosx:
+-	$(MAKE) posix "SOCC=MACOSX_DEPLOYMENT_TARGET=10.3 $(CC) -dynamiclib -single_module -undefined dynamic_lookup $(SOCFLAGS)"
++	$(MAKE) posix "SOCC= $(CC) -dynamiclib -single_module -undefined dynamic_lookup -Wl,-install_name,$(PREFIX)/lib/$(MODSO) $(SOCFLAGS)"
+ 
+ test_macosx:
+-	$(MAKE) test_posix "SOCC=MACOSX_DEPLOYMENT_TARGET=10.3 $(CC) -dynamiclib -single_module -undefined dynamic_lookup $(SOCFLAGS)"
++	$(MAKE) test_posix "SOCC= $(CC) -dynamiclib -single_module -undefined dynamic_lookup -Wl,-install_name,$(PREFIX)/lib/$(MODSO) $(SOCFLAGS)"
+ 
+ posix: $(MODSO) test_cdecl.so
+ 
diff --git a/pkgs/development/libraries/luaffi/default.nix b/pkgs/development/libraries/luaffi/default.nix
index 1e4cf11d1fa0..065562ac82ec 100644
--- a/pkgs/development/libraries/luaffi/default.nix
+++ b/pkgs/development/libraries/luaffi/default.nix
@@ -12,9 +12,9 @@ stdenv.mkDerivation {
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ lua ];
 
-  patches = [
-    ./makefile-errors.patch
-  ];
+  patches = [ ./darwin.patch ./makefile-errors.patch ];
+
+  makeFlags = [ "PREFIX=$(out)" ];
 
   installPhase = ''
     mkdir -p $out/lib
diff --git a/pkgs/development/libraries/lzo/default.nix b/pkgs/development/libraries/lzo/default.nix
index e8f8a6ab9bba..c7667b554f4e 100644
--- a/pkgs/development/libraries/lzo/default.nix
+++ b/pkgs/development/libraries/lzo/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  doCheck = stdenv.hostPlatform == stdenv.buildPlatform;
+  doCheck = true; # not cross;
 
   meta = with stdenv.lib; {
     description = "Real-time data (de)compression library";
@@ -30,6 +30,5 @@ stdenv.mkDerivation rec {
     license = licenses.gpl2Plus;
 
     platforms = platforms.all;
-    maintainers = with maintainers; [ nckx ];
   };
 }
diff --git a/pkgs/development/libraries/mailcore2/default.nix b/pkgs/development/libraries/mailcore2/default.nix
index 0a64c7c0429a..3828ebcb7a70 100644
--- a/pkgs/development/libraries/mailcore2/default.nix
+++ b/pkgs/development/libraries/mailcore2/default.nix
@@ -5,13 +5,13 @@
 stdenv.mkDerivation rec {
   name = "mailcore2-${version}";
 
-  version = "0.5.1";
+  version = "0.6.2";
 
   src = fetchFromGitHub {
     owner  = "MailCore";
     repo   = "mailcore2";
     rev    = version;
-    sha256 = "1k0l59cdk8np4pff1my07dp7ivf3nchlhcpvm9xizp0my9rqgbxb";
+    sha256 = "1d0wmnkk9vnjqc28i79z3fwaaycdbprfspagik4mzdkgval5r5pm";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/matio/default.nix b/pkgs/development/libraries/matio/default.nix
index 83ddcbf52e14..573215227369 100644
--- a/pkgs/development/libraries/matio/default.nix
+++ b/pkgs/development/libraries/matio/default.nix
@@ -1,9 +1,9 @@
 { stdenv, fetchurl }:
 stdenv.mkDerivation rec {
-  name = "matio-1.5.10";
+  name = "matio-1.5.12";
   src = fetchurl {
     url = "mirror://sourceforge/matio/${name}.tar.gz";
-    sha256 = "00dmg2f5k2xgakp7l0lganz122b1agazw5d899xci35xrqc9j821";
+    sha256 = "1afqjhc1wbm7g1vry3w30c7dbrxg6n4i482ybgx6l1b5wj0f75c6";
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/mbedtls/darwin_dylib.patch b/pkgs/development/libraries/mbedtls/darwin_dylib.patch
new file mode 100644
index 000000000000..bc6992d6e779
--- /dev/null
+++ b/pkgs/development/libraries/mbedtls/darwin_dylib.patch
@@ -0,0 +1,28 @@
+diff --git a/library/Makefile b/library/Makefile
+index 28f9231..ad9cc32 100644
+--- a/library/Makefile
++++ b/library/Makefile
+@@ -103,9 +103,9 @@ libmbedtls.so: libmbedtls.$(SOEXT_TLS)
+ 	echo "  LN    $@ -> $<"
+ 	ln -sf $< $@
+ 
+-libmbedtls.dylib: $(OBJS_TLS)
++libmbedtls.dylib: $(OBJS_TLS) libmbedx509.dylib
+ 	echo "  LD    $@"
+-	$(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_TLS)
++	$(CC) -dynamiclib -L. -lmbedcrypto -lmbedx509 $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_TLS)
+ 
+ libmbedtls.dll: $(OBJS_TLS) libmbedx509.dll
+ 	echo "  LD    $@"
+@@ -126,9 +126,9 @@ libmbedx509.so: libmbedx509.$(SOEXT_X509)
+ 	echo "  LN    $@ -> $<"
+ 	ln -sf $< $@
+ 
+-libmbedx509.dylib: $(OBJS_X509)
++libmbedx509.dylib: $(OBJS_X509) libmbedcrypto.dylib
+ 	echo "  LD    $@"
+-	$(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509)
++	$(CC) -dynamiclib -L. -lmbedcrypto  $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509)
+ 
+ libmbedx509.dll: $(OBJS_X509) libmbedcrypto.dll
+ 	echo "  LD    $@"
diff --git a/pkgs/development/libraries/mbedtls/default.nix b/pkgs/development/libraries/mbedtls/default.nix
index 8195ba2d4d66..8c2a2a694b03 100644
--- a/pkgs/development/libraries/mbedtls/default.nix
+++ b/pkgs/development/libraries/mbedtls/default.nix
@@ -1,28 +1,32 @@
-{ stdenv, fetchurl, perl }:
+{ stdenv, fetchFromGitHub, perl }:
 
 stdenv.mkDerivation rec {
-  name = "mbedtls-2.6.0";
+  name = "mbedtls-2.8.0";
 
-  src = fetchurl {
-    url = "https://tls.mbed.org/download/${name}-gpl.tgz";
-    sha256 = "042q1l4708zjn5v72sa9qdvgx173kmy4hbcd23wj5vqd6vbmk6d9";
+  src = fetchFromGitHub {
+    owner = "ARMmbed";
+    repo = "mbedtls";
+    rev = name;
+    sha256 = "1pnwmy0qg8g9lz26fpr5fzpvrdjm59winxpwdjfp6d62qxdjbgmn";
   };
 
   nativeBuildInputs = [ perl ];
 
-  patchPhase = stdenv.lib.optionalString stdenv.isDarwin ''
+  patches = stdenv.lib.optionals stdenv.isDarwin [ ./darwin_dylib.patch ];
+
+  postPatch = ''
+    patchShebangs .
+  '' + stdenv.lib.optionalString stdenv.isDarwin ''
     substituteInPlace library/Makefile --replace "-soname" "-install_name"
     substituteInPlace tests/scripts/run-test-suites.pl --replace "LD_LIBRARY_PATH" "DYLD_LIBRARY_PATH"
     # Necessary for install_name_tool below
     echo "LOCAL_LDFLAGS += -headerpad_max_install_names" >> programs/Makefile
   '';
 
-  postPatch = ''
-    patchShebangs .
-  '';
-
   makeFlags = [
     "SHARED=1"
+  ] ++ stdenv.lib.optionals stdenv.isDarwin [
+    "DLEXT=dylib"
   ];
 
   installFlags = [
@@ -30,14 +34,14 @@ stdenv.mkDerivation rec {
   ];
 
   postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
-      install_name_tool -change libmbedcrypto.so.0 $out/lib/libmbedcrypto.so.0 $out/lib/libmbedtls.so.10
-      install_name_tool -change libmbedcrypto.so.0 $out/lib/libmbedcrypto.so.0 $out/lib/libmbedx509.so.0
-      install_name_tool -change libmbedx509.so.0 $out/lib/libmbedx509.so.0 $out/lib/libmbedtls.so.10
+      install_name_tool -change libmbedcrypto.dylib $out/lib/libmbedcrypto.dylib $out/lib/libmbedtls.dylib
+      install_name_tool -change libmbedcrypto.dylib $out/lib/libmbedcrypto.dylib $out/lib/libmbedx509.dylib
+      install_name_tool -change libmbedx509.dylib $out/lib/libmbedx509.dylib $out/lib/libmbedtls.dylib
 
       for exe in $out/bin/*; do
-          install_name_tool -change libmbedtls.so.10 $out/lib/libmbedtls.so.10 $exe
-          install_name_tool -change libmbedx509.so.0 $out/lib/libmbedx509.so.0 $exe
-          install_name_tool -change libmbedcrypto.so.0 $out/lib/libmbedcrypto.so.0 $exe
+          install_name_tool -change libmbedtls.dylib $out/lib/libmbedtls.dylib $exe
+          install_name_tool -change libmbedx509.dylib $out/lib/libmbedx509.dylib $exe
+          install_name_tool -change libmbedcrypto.dylib $out/lib/libmbedcrypto.dylib $exe
       done
   '';
 
diff --git a/pkgs/development/libraries/mdds/default.nix b/pkgs/development/libraries/mdds/default.nix
index 7b7c77659bdc..592b6d7a6779 100644
--- a/pkgs/development/libraries/mdds/default.nix
+++ b/pkgs/development/libraries/mdds/default.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  version = "1.2.2";
+  version = "1.3.1";
   name = "mdds-${version}";
 
   src = fetchurl {
     url = "http://kohei.us/files/mdds/src/mdds-${version}.tar.bz2";
-    sha256 = "17fcjhsq3bzqm7ba9sgp6my3y4226jnwai6q5jq3810i745p67hl";
+    sha256 = "18g511z1lgfxrga2ld9yr95phmyfbd3ymbv4q5g5lyjn4ljcvf6w";
   };
 
   postInstall = ''
diff --git a/pkgs/development/libraries/mediastreamer/default.nix b/pkgs/development/libraries/mediastreamer/default.nix
index 06cc53abb564..8b756e338e48 100644
--- a/pkgs/development/libraries/mediastreamer/default.nix
+++ b/pkgs/development/libraries/mediastreamer/default.nix
@@ -1,28 +1,35 @@
 { stdenv, fetchurl, pkgconfig, intltool, alsaLib, libpulseaudio, speex, gsm
-, libopus, ffmpeg, libX11, libXv, mesa, glew, libtheora, libvpx, SDL, libupnp
+, libopus, ffmpeg, libX11, libXv, libGLU_combined, glew, libtheora, libvpx, SDL, libupnp
 , ortp, libv4l, libpcap, srtp, fetchFromGitHub, cmake, bctoolbox, doxygen
-, python, libXext, libmatroska, openssl
+, python, libXext, libmatroska, openssl, fetchpatch
 }:
 
 stdenv.mkDerivation rec {
   baseName = "mediastreamer2";
-  version = "2.14.0";
+  version = "2.16.1";
   name = "${baseName}-${version}";
 
   src = fetchFromGitHub {
     owner = "BelledonneCommunications";
     repo = "${baseName}";
     rev = "${version}";
-    sha256 = "1b59rzsaw54mhy4pz9hndmim4rgidkn7s6c4iyl34mz58lwxpmqp";
+    sha256 = "02745bzl2r1jqvdqzyv94fjd4w92zr976la4c4nfvsy52waqah7j";
   };
 
-  patches = [ ./plugins_dir.patch ];
+  patches = [
+    (fetchpatch {
+      name = "allow-build-without-git.patch";
+      url = "https://github.com/BelledonneCommunications/mediastreamer2/commit/de3a24b795d7a78e78eab6b974e7ec5abf2259ac.patch";
+      sha256 = "1zqkrab42n4dha0knfsyj4q0wc229ma125gk9grj67ps7r7ipscy";
+    })
+    ./plugins_dir.patch
+  ];
 
   nativeBuildInputs = [ pkgconfig intltool cmake doxygen python ];
 
   propagatedBuildInputs = [
     alsaLib libpulseaudio speex gsm libopus
-    ffmpeg libX11 libXv mesa glew libtheora libvpx SDL libupnp
+    ffmpeg libX11 libXv libGLU_combined glew libtheora libvpx SDL libupnp
     ortp libv4l libpcap srtp bctoolbox libXext libmatroska
     openssl
   ];
diff --git a/pkgs/development/libraries/menu-cache/default.nix b/pkgs/development/libraries/menu-cache/default.nix
index a490aa1e4451..c92b6a4e7287 100644
--- a/pkgs/development/libraries/menu-cache/default.nix
+++ b/pkgs/development/libraries/menu-cache/default.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, glib, pkgconfig, libfm-extra }:
 
-let name = "menu-cache-1.0.2";
+let name = "menu-cache-1.1.0";
 in
 stdenv.mkDerivation {
   inherit name;
   src = fetchurl {
     url = "mirror://sourceforge/lxde/${name}.tar.xz";
-    sha256 = "1m8j40npykfcfqs43kc0fmksal2jfmfi8lnb3mq3xy1lvvrfv0vg";
+    sha256 = "1iry4zlpppww8qai2cw4zid4081hh7fz8nzsp5lqyffbkm2yn0pd";
   };
 
   nativeBuildInputs = [ pkgconfig ];
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 fe34a8bb88fa..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.
@@ -14,7 +15,7 @@
 }:
 
 /** Packaging design:
-  - The basic mesa ($out) contains headers and libraries (GLU is in mesa_glu now).
+  - The basic mesa ($out) contains headers and libraries (GLU is in libGLU now).
     This or the mesa attribute (which also contains GLU) are small (~ 2 MB, mostly headers)
     and are designed to be the buildInput of other packages.
   - DRI drivers are compiled into $drivers output, which is much bigger and
@@ -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.2.4";
+  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 {
@@ -79,9 +79,9 @@ stdenv.mkDerivation {
       "ftp://ftp.freedesktop.org/pub/mesa/mesa-${version}.tar.xz"
       "ftp://ftp.freedesktop.org/pub/mesa/${version}/mesa-${version}.tar.xz"
       "ftp://ftp.freedesktop.org/pub/mesa/older-versions/${branch}.x/${version}/mesa-${version}.tar.xz"
-      "https://launchpad.net/mesa/trunk/${version}/+download/mesa-${version}.tar.xz"
+      "https://mesa.freedesktop.org/archive/mesa-${version}.tar.xz"
     ];
-    sha256 = "0l75q9l4g15y66rqk2swqvj18qj60hpimv0f97jk44bfrpz0i92v";
+    sha256 = "1cd6a4ll5arla3kncxnw9196ak1v4rvnb098aa7lm3n4h7r9p7cg";
   };
 
   prePatch = "patchShebangs .";
@@ -92,16 +92,17 @@ stdenv.mkDerivation {
   patches = [
     ./glx_ro_text_segm.patch # fix for grsecurity/PaX
     ./symlink-drivers.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=/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"
@@ -134,7 +136,7 @@ stdenv.mkDerivation {
     "--enable-shared-glapi"
     "--enable-sysfs"
     "--enable-llvm-shared-libs"
-    "--enable-omx"
+    "--enable-omx-bellagio"
     "--enable-va"
     "--disable-opencl"
   ];
@@ -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
@@ -197,7 +213,6 @@ stdenv.mkDerivation {
   '';
 
   # TODO:
-  #  @vcunat isn't sure if drirc will be found when in $out/etc/;
   #  check $out doesn't depend on llvm: builder failures are ignored
   #  for some reason grep -qv '${llvmPackages.llvm}' -R "$out";
   postFixup = ''
@@ -210,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 = http://www.mesa3d.org/;
+    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/microsoft_gsl/default.nix b/pkgs/development/libraries/microsoft_gsl/default.nix
index b419eccfe794..1c10bd6f8fcd 100644
--- a/pkgs/development/libraries/microsoft_gsl/default.nix
+++ b/pkgs/development/libraries/microsoft_gsl/default.nix
@@ -1,5 +1,10 @@
-{ stdenv, fetchgit, cmake }:
+{ stdenv, fetchgit, cmake
+, hostPlatform, buildPlatform
+}:
 
+let
+  nativeBuild = hostPlatform == buildPlatform;
+in
 stdenv.mkDerivation rec {
   name = "microsoft_gsl-${version}";
   version = "2017-02-13";
@@ -10,8 +15,11 @@ stdenv.mkDerivation rec {
     sha256 = "03d17mnx6n175aakin313308q14wzvaa9pd0m1yfk6ckhha4qf35";
   };
 
-  # build phase just runs the unit tests
-  buildInputs = [ cmake ];
+
+  # build phase just runs the unit tests, so skip it if
+  # we're doing a cross build
+  nativeBuildInputs = [ cmake ];
+  buildPhase = if nativeBuild then "make" else "true";
 
   installPhase = ''
     mkdir -p $out/include
@@ -20,9 +28,9 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "Functions and types that are suggested for use by the C++ Core Guidelines";
-    homepage = https://github.com/Microsoft/GSL;
-    license = licenses.mit;
-    platforms = platforms.all;
-    maintainers = with maintainers; [ xwvvvvwx ];
+    homepage    = https://github.com/Microsoft/GSL;
+    license     = licenses.mit;
+    platforms   = platforms.all;
+    maintainers = with maintainers; [ thoughtpolice xwvvvvwx ];
   };
 }
diff --git a/pkgs/development/libraries/mimetic/default.nix b/pkgs/development/libraries/mimetic/default.nix
index fc48c85f23c7..7a06f9277c95 100644
--- a/pkgs/development/libraries/mimetic/default.nix
+++ b/pkgs/development/libraries/mimetic/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "MIME handling library";
-    homepage    = http://codesink.org/mimetic_mime_library.html;
+    homepage    = http://www.codesink.org/mimetic_mime_library.html;
     license     = licenses.mit;
     maintainers = with maintainers; [ leenaars];
     platforms = platforms.linux;
diff --git a/pkgs/development/libraries/mlt/default.nix b/pkgs/development/libraries/mlt/default.nix
index 168b94495a97..59700669ba7c 100644
--- a/pkgs/development/libraries/mlt/default.nix
+++ b/pkgs/development/libraries/mlt/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, makeWrapper
+{ stdenv, fetchFromGitHub, fetchurl, makeWrapper
 , SDL, ffmpeg, frei0r, libjack2, libdv, libsamplerate
 , libvorbis, libxml2, movit, pkgconfig, sox
 , gtk2
@@ -6,13 +6,13 @@
 
 stdenv.mkDerivation rec {
   name = "mlt-${version}";
-  version = "6.4.1";
+  version = "6.6.0";
 
   src = fetchFromGitHub {
     owner = "mltframework";
     repo = "mlt";
     rev = "v${version}";
-    sha256 = "0k9vj21n6qxdjd0vvj22cwi35igajjzh5fbjza766izdbijv2i2w";
+    sha256 = "0b2fq0819r7n141l6hhr66hpayqqcmjr2yxw9azxkapg1h0div6q";
   };
 
   buildInputs = [
diff --git a/pkgs/development/libraries/mlt/qt-5.nix b/pkgs/development/libraries/mlt/qt-5.nix
index 1d56d58c68d3..27f7cf31cbf2 100644
--- a/pkgs/development/libraries/mlt/qt-5.nix
+++ b/pkgs/development/libraries/mlt/qt-5.nix
@@ -1,15 +1,19 @@
-{ stdenv, fetchurl, SDL, ffmpeg, frei0r, libjack2, libdv, libsamplerate
+{ stdenv, fetchFromGitHub, SDL, ffmpeg, frei0r, libjack2, libdv, libsamplerate
 , libvorbis, libxml2, makeWrapper, movit, pkgconfig, sox, qtbase, qtsvg
 , fftw, vid-stab, opencv3, ladspa-sdk
 }:
 
+let inherit (stdenv.lib) getDev; in
+
 stdenv.mkDerivation rec {
   name = "mlt-${version}";
-  version = "6.4.1";
+  version = "6.6.0";
 
-  src = fetchurl {
-    url = "https://github.com/mltframework/mlt/archive/v${version}.tar.gz";
-    sha256 = "10m3ry0b2pvqx3bk34qh5dq337nn8pkc2gzfyhsj4nv9abskln47";
+  src = fetchFromGitHub {
+    owner = "mltframework";
+    repo = "mlt";
+    rev = "v${version}";
+    sha256 = "0b2fq0819r7n141l6hhr66hpayqqcmjr2yxw9azxkapg1h0div6q";
   };
 
   buildInputs = [
@@ -27,6 +31,10 @@ stdenv.mkDerivation rec {
     "--enable-opengl"
   ];
 
+  # mlt is unable to cope with our multi-prefix Qt build
+  # because it does not use CMake or qmake.
+  NIX_CFLAGS_COMPILE = [ "-I${getDev qtsvg}/include/QtSvg" ];
+
   CXXFLAGS = "-std=c++11";
 
   enableParallelBuilding = true;
@@ -51,7 +59,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "Open source multimedia framework, designed for television broadcasting";
-    homepage = http://www.mltframework.org/;
+    homepage = https://www.mltframework.org/;
     license = licenses.gpl3;
     maintainers = [ maintainers.goibhniu ];
     platforms = platforms.linux;
diff --git a/pkgs/development/libraries/mongoc/default.nix b/pkgs/development/libraries/mongoc/default.nix
index 4cba89d9206f..2a933ef78401 100644
--- a/pkgs/development/libraries/mongoc/default.nix
+++ b/pkgs/development/libraries/mongoc/default.nix
@@ -12,8 +12,10 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ pkgconfig which perl ];
-  buildInputs = [ openssl zlib snappy ];
-  propagatedBuildInputs = [ libbson ];
+  buildInputs = [ openssl zlib ];
+  propagatedBuildInputs = [ libbson snappy ];
+
+  enableParallelBuilding = true;
 
   meta = with stdenv.lib; {
     description = "The official C client library for MongoDB";
diff --git a/pkgs/development/libraries/movit/default.nix b/pkgs/development/libraries/movit/default.nix
index d85d4f444077..3766140eea1e 100644
--- a/pkgs/development/libraries/movit/default.nix
+++ b/pkgs/development/libraries/movit/default.nix
@@ -5,7 +5,7 @@ stdenv.mkDerivation rec {
   version = "1.5.1";
 
   src = fetchurl {
-    url = "http://movit.sesse.net/${name}.tar.gz";
+    url = "https://movit.sesse.net/${name}.tar.gz";
     sha256 = "1259iq2ixiprk4mn7ypapinbg2w1sjq1aivzzbbch9i23kcfsd44";
   };
 
diff --git a/pkgs/development/libraries/mp4v2/default.nix b/pkgs/development/libraries/mp4v2/default.nix
index de8e5f786466..a5542ebb659a 100644
--- a/pkgs/development/libraries/mp4v2/default.nix
+++ b/pkgs/development/libraries/mp4v2/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl }:
+{ stdenv, lib, fetchurl }:
 
 stdenv.mkDerivation rec {
   name = "mp4v2-2.0.0";
@@ -8,20 +8,30 @@ stdenv.mkDerivation rec {
     sha256 = "0f438bimimsvxjbdp4vsr8hjw2nwggmhaxgcw07g2z361fkbj683";
   };
 
-  # From Handbrake
-  # mp4v2 doesn't seem to be actively maintained any more :-/
   patches = [
+    # From Handbrake
+    # mp4v2 doesn't seem to be actively maintained any more :-/
     ./A02-meaningful-4gb-warning.patch
+
+    (fetchurl {
+      name = "gcc-7.patch";
+      url = "https://src.fedoraproject.org/cgit/rpms/libmp4v2.git/plain/"
+          + "0004-Fix-GCC7-build.patch?id=d7aeedabb";
+      sha256 = "0sbn0il7lmk77yrjyb4f0a3z3h8gsmdkscvz5n9hmrrrhrwf672w";
+    })
   ];
+
   # `faac' expects `mp4.h'.
   postInstall = "ln -s mp4v2/mp4v2.h $out/include/mp4.h";
 
   hardeningDisable = [ "format" ];
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = https://code.google.com/archive/p/mp4v2/;
     maintainers = [ ];
-    platforms = stdenv.lib.platforms.linux;
-    license = stdenv.lib.licenses.mpl11;
+    platforms = lib.platforms.unix;
+    license = lib.licenses.mpl11;
   };
 }
diff --git a/pkgs/development/libraries/mpfr/default.nix b/pkgs/development/libraries/mpfr/default.nix
index 6be199af1930..4aac5a927092 100644
--- a/pkgs/development/libraries/mpfr/default.nix
+++ b/pkgs/development/libraries/mpfr/default.nix
@@ -1,17 +1,15 @@
 { stdenv, fetchurl, gmp
-, buildPlatform, hostPlatform
+, hostPlatform
 }:
 
 stdenv.mkDerivation rec {
-  name = "mpfr-3.1.3";
+  name = "mpfr-3.1.6";
 
   src = fetchurl {
-    url = "mirror://gnu/mpfr/${name}.tar.bz2";
-    sha256 = "1z8akfw9wbmq91vrx04bw86mmnxw2sw5qm5cr8ix5b3w2mcv8fzn";
+    url = "mirror://gnu/mpfr/${name}.tar.xz";
+    sha256 = "0l598h9klpgkz2bp0rxiqb90mkqh9f2f81n5rpy191j00hdaqqks";
   };
 
-  patches = [ ./upstream.patch ];
-
   outputs = [ "out" "dev" "doc" "info" ];
 
   # mpfr.h requires gmp.h
@@ -21,7 +19,7 @@ stdenv.mkDerivation rec {
     stdenv.lib.optional hostPlatform.isSunOS "--disable-thread-safe" ++
     stdenv.lib.optional hostPlatform.is64bit "--with-pic";
 
-  doCheck = hostPlatform == buildPlatform;
+  doCheck = true; # not cross;
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/mpfr/upstream.patch b/pkgs/development/libraries/mpfr/upstream.patch
deleted file mode 100644
index 779331605245..000000000000
--- a/pkgs/development/libraries/mpfr/upstream.patch
+++ /dev/null
@@ -1,1699 +0,0 @@
-diff -Naurd mpfr-3.1.3-a/PATCHES mpfr-3.1.3-b/PATCHES
---- mpfr-3.1.3-a/PATCHES	2015-07-02 10:49:23.950112879 +0000
-+++ mpfr-3.1.3-b/PATCHES	2015-07-02 10:49:24.042113845 +0000
-@@ -0,0 +1 @@
-+lngamma-and-doc
-diff -Naurd mpfr-3.1.3-a/VERSION mpfr-3.1.3-b/VERSION
---- mpfr-3.1.3-a/VERSION	2015-06-19 19:55:09.000000000 +0000
-+++ mpfr-3.1.3-b/VERSION	2015-07-02 10:49:24.042113845 +0000
-@@ -1 +1 @@
--3.1.3
-+3.1.3-p1
-diff -Naurd mpfr-3.1.3-a/doc/mpfr.texi mpfr-3.1.3-b/doc/mpfr.texi
---- mpfr-3.1.3-a/doc/mpfr.texi	2015-06-19 19:55:11.000000000 +0000
-+++ mpfr-3.1.3-b/doc/mpfr.texi	2015-07-02 10:49:24.018113593 +0000
-@@ -810,13 +810,17 @@
- When the input point is in the closure of the domain of the mathematical
- function and an input argument is +0 (resp.@: @minus{}0), one considers
- the limit when the corresponding argument approaches 0 from above
--(resp.@: below). If the limit is not defined (e.g., @code{mpfr_log} on
--@minus{}0), the behavior is specified in the description of the MPFR function.
-+(resp.@: below), if possible. If the limit is not defined (e.g.,
-+@code{mpfr_sqrt} and @code{mpfr_log} on @minus{}0), the behavior is
-+specified in the description of the MPFR function, but must be consistent
-+with the rule from the above paragraph (e.g., @code{mpfr_log} on @pom{}0
-+gives @minus{}Inf).
- 
- When the result is equal to 0, its sign is determined by considering the
- limit as if the input point were not in the domain: If one approaches 0
- from above (resp.@: below), the result is +0 (resp.@: @minus{}0);
--for example, @code{mpfr_sin} on +0 gives +0.
-+for example, @code{mpfr_sin} on @minus{}0 gives @minus{}0 and
-+@code{mpfr_acos} on 1 gives +0 (in all rounding modes).
- In the other cases, the sign is specified in the description of the MPFR
- function; for example @code{mpfr_max} on @minus{}0 and +0 gives +0.
- 
-@@ -832,8 +836,8 @@
- @c that advantages in practice), like for any bug fix.
- Example: @code{mpfr_hypot} on (NaN,0) gives NaN, but @code{mpfr_hypot}
- on (NaN,+Inf) gives +Inf (as specified in @ref{Special Functions}),
--since for any finite input @var{x}, @code{mpfr_hypot} on (@var{x},+Inf)
--gives +Inf.
-+since for any finite or infinite input @var{x}, @code{mpfr_hypot} on
-+(@var{x},+Inf) gives +Inf.
- 
- @node Exceptions, Memory Handling, Floating-Point Values on Special Numbers, MPFR Basics
- @comment  node-name,  next,  previous,  up
-@@ -1581,7 +1585,8 @@
- @deftypefunx int mpfr_add_z (mpfr_t @var{rop}, mpfr_t @var{op1}, mpz_t @var{op2}, mpfr_rnd_t @var{rnd})
- @deftypefunx int mpfr_add_q (mpfr_t @var{rop}, mpfr_t @var{op1}, mpq_t @var{op2}, mpfr_rnd_t @var{rnd})
- Set @var{rop} to @math{@var{op1} + @var{op2}} rounded in the direction
--@var{rnd}. For types having no signed zero, it is considered unsigned
-+@var{rnd}.  The IEEE-754 rules are used, in particular for signed zeros.
-+But for types having no signed zeros, 0 is considered unsigned
- (i.e., (+0) + 0 = (+0) and (@minus{}0) + 0 = (@minus{}0)).
- The @code{mpfr_add_d} function assumes that the radix of the @code{double} type
- is a power of 2, with a precision at most that declared by the C implementation
-@@ -1599,7 +1604,8 @@
- @deftypefunx int mpfr_sub_z (mpfr_t @var{rop}, mpfr_t @var{op1}, mpz_t @var{op2}, mpfr_rnd_t @var{rnd})
- @deftypefunx int mpfr_sub_q (mpfr_t @var{rop}, mpfr_t @var{op1}, mpq_t @var{op2}, mpfr_rnd_t @var{rnd})
- Set @var{rop} to @math{@var{op1} - @var{op2}} rounded in the direction
--@var{rnd}. For types having no signed zero, it is considered unsigned
-+@var{rnd}.  The IEEE-754 rules are used, in particular for signed zeros.
-+But for types having no signed zeros, 0 is considered unsigned
- (i.e., (+0) @minus{} 0 = (+0), (@minus{}0) @minus{} 0 = (@minus{}0),
- 0 @minus{} (+0) = (@minus{}0) and 0 @minus{} (@minus{}0) = (+0)).
- The same restrictions than for @code{mpfr_add_d} apply to @code{mpfr_d_sub}
-@@ -1615,7 +1621,7 @@
- Set @var{rop} to @math{@var{op1} @GMPtimes{} @var{op2}} rounded in the
- direction @var{rnd}.
- When a result is zero, its sign is the product of the signs of the operands
--(for types having no signed zero, it is considered positive).
-+(for types having no signed zeros, 0 is considered positive).
- The same restrictions than for @code{mpfr_add_d} apply to @code{mpfr_mul_d}.
- @end deftypefun
- 
-@@ -1635,7 +1641,7 @@
- @deftypefunx int mpfr_div_q (mpfr_t @var{rop}, mpfr_t @var{op1}, mpq_t @var{op2}, mpfr_rnd_t @var{rnd})
- Set @var{rop} to @math{@var{op1}/@var{op2}} rounded in the direction @var{rnd}.
- When a result is zero, its sign is the product of the signs of the operands
--(for types having no signed zero, it is considered positive).
-+(for types having no signed zeros, 0 is considered positive).
- The same restrictions than for @code{mpfr_add_d} apply to @code{mpfr_d_div}
- and @code{mpfr_div_d}.
- @end deftypefun
-@@ -1643,15 +1649,18 @@
- @deftypefun int mpfr_sqrt (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd})
- @deftypefunx int mpfr_sqrt_ui (mpfr_t @var{rop}, unsigned long int @var{op}, mpfr_rnd_t @var{rnd})
- Set @var{rop} to @m{\sqrt{@var{op}}, the square root of @var{op}}
--rounded in the direction @var{rnd} (set @var{rop} to @minus{}0 if @var{op} is
--@minus{}0, to be consistent with the IEEE 754 standard).
-+rounded in the direction @var{rnd}.  Set @var{rop} to @minus{}0 if
-+@var{op} is @minus{}0, to be consistent with the IEEE 754 standard.
- Set @var{rop} to NaN if @var{op} is negative.
- @end deftypefun
- 
- @deftypefun int mpfr_rec_sqrt (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd})
- Set @var{rop} to @m{1/\sqrt{@var{op}}, the reciprocal square root of @var{op}}
--rounded in the direction @var{rnd}. Set @var{rop} to +Inf if @var{op} is
--@pom{}0, +0 if @var{op} is +Inf, and NaN if @var{op} is negative.
-+rounded in the direction @var{rnd}.  Set @var{rop} to +Inf if @var{op} is
-+@pom{}0, +0 if @var{op} is +Inf, and NaN if @var{op} is negative.  Warning!
-+Therefore the result on @minus{}0 is different from the one of the rSqrt
-+function recommended by the IEEE 754-2008 standard (Section 9.2.1), which
-+is @minus{}Inf instead of +Inf.
- @end deftypefun
- 
- @deftypefun int mpfr_cbrt (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd})
-@@ -1832,7 +1841,9 @@
- @m{\log_2 @var{op}, log2(@var{op})} or
- @m{\log_{10} @var{op}, log10(@var{op})}, respectively,
- rounded in the direction @var{rnd}.
--Set @var{rop} to @minus{}Inf if @var{op} is @minus{}0
-+Set @var{rop} to +0 if @var{op} is 1 (in all rounding modes),
-+for consistency with the ISO C99 and IEEE 754-2008 standards.
-+Set @var{rop} to @minus{}Inf if @var{op} is @pom{}0
- (i.e., the sign of the zero has no influence on the result).
- @end deftypefun
- 
-@@ -2003,8 +2014,11 @@
- @deftypefun int mpfr_lngamma (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd})
- Set @var{rop} to the value of the logarithm of the Gamma function on @var{op},
- rounded in the direction @var{rnd}.
--When @math{@minus{}2@var{k}@minus{}1 @le{} @var{op} @le{} @minus{}2@var{k}},
--@var{k} being a non-negative integer, @var{rop} is set to NaN.
-+When @var{op} is 1 or 2, set @var{rop} to +0 (in all rounding modes).
-+When @var{op} is an infinity or a nonpositive integer, set @var{rop} to +Inf,
-+following the general rules on special values.
-+When @math{@minus{}2@var{k}@minus{}1 < @var{op} < @minus{}2@var{k}},
-+@var{k} being a nonnegative integer, set @var{rop} to NaN@.
- See also @code{mpfr_lgamma}.
- @end deftypefun
- 
-@@ -2012,10 +2026,11 @@
- Set @var{rop} to the value of the logarithm of the absolute value of the
- Gamma function on @var{op}, rounded in the direction @var{rnd}. The sign
- (1 or @minus{}1) of Gamma(@var{op}) is returned in the object pointed to
--by @var{signp}. When @var{op} is an infinity or a non-positive integer, set
--@var{rop} to +Inf. When @var{op} is NaN, @minus{}Inf or a negative integer,
--*@var{signp} is undefined, and when @var{op} is @pom{}0, *@var{signp} is
--the sign of the zero.
-+by @var{signp}.
-+When @var{op} is 1 or 2, set @var{rop} to +0 (in all rounding modes).
-+When @var{op} is an infinity or a nonpositive integer, set @var{rop} to +Inf.
-+When @var{op} is NaN, @minus{}Inf or a negative integer, *@var{signp} is
-+undefined, and when @var{op} is @pom{}0, *@var{signp} is the sign of the zero.
- @end deftypefun
- 
- @deftypefun int mpfr_digamma (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd})
-@@ -2064,7 +2079,10 @@
- @deftypefunx int mpfr_fms (mpfr_t @var{rop}, mpfr_t @var{op1}, mpfr_t @var{op2}, mpfr_t @var{op3}, mpfr_rnd_t @var{rnd})
- Set @var{rop} to @math{(@var{op1} @GMPtimes{} @var{op2}) + @var{op3}}
- (resp.@: @math{(@var{op1} @GMPtimes{} @var{op2}) - @var{op3}})
--rounded in the direction @var{rnd}.
-+rounded in the direction @var{rnd}.  Concerning special values (signed zeros,
-+infinities, NaN), these functions behave like a multiplication followed by a
-+separate addition or subtraction.  That is, the fused operation matters only
-+for rounding.
- @end deftypefun
- 
- @deftypefun int mpfr_agm (mpfr_t @var{rop}, mpfr_t @var{op1}, mpfr_t @var{op2}, mpfr_rnd_t @var{rnd})
-@@ -2089,8 +2107,8 @@
- i.e., $\sqrt{x^2+y^2}$,
- @end tex
- rounded in the direction @var{rnd}.
--Special values are handled as described in Section F.9.4.3 of
--the ISO C99 and IEEE 754-2008 standards:
-+Special values are handled as described in the ISO C99 (Section F.9.4.3)
-+and IEEE 754-2008 (Section 9.2.1) standards:
- If @var{x} or @var{y} is an infinity, then +Inf is returned in @var{rop},
- even if the other number is NaN.
- @end deftypefun
-diff -Naurd mpfr-3.1.3-a/doc/mpfr.info mpfr-3.1.3-b/doc/mpfr.info
---- mpfr-3.1.3-a/doc/mpfr.info	2015-06-19 19:55:53.000000000 +0000
-+++ mpfr-3.1.3-b/doc/mpfr.info	2015-07-02 10:49:38.718267817 +0000
-@@ -1,4 +1,4 @@
--This is mpfr.info, produced by makeinfo version 5.2 from mpfr.texi.
-+This is mpfr.info, produced by makeinfo version 6.0 from mpfr.texi.
- 
- This manual documents how to install and use the Multiple Precision
- Floating-Point Reliable Library, version 3.1.3.
-@@ -55,7 +55,7 @@
- MPFR Copying Conditions
- ***********************
- 
--The GNU MPFR library (or MPFR for short) is "free"; this means that
-+The GNU MPFR library (or MPFR for short) is “free”; this means that
- everyone is free to use it and free to redistribute it on a free basis.
- The library is not in the public domain; it is copyrighted and there are
- restrictions on its distribution, but these restrictions are designed to
-@@ -418,7 +418,7 @@
- 4.2 Nomenclature and Types
- ==========================
- 
--A "floating-point number", or "float" for short, is an arbitrary
-+A “floating-point number”, or “float” for short, is an arbitrary
- precision significand (also called mantissa) with a limited precision
- exponent.  The C data type for such objects is ‘mpfr_t’ (internally
- defined as a one-element array of a structure, and ‘mpfr_ptr’ is the C
-@@ -432,7 +432,7 @@
- to the other functions supported by MPFR. Unless documented otherwise,
- the sign bit of a NaN is unspecified.
- 
--The "precision" is the number of bits used to represent the significand
-+The “precision” is the number of bits used to represent the significand
- of a floating-point number; the corresponding C data type is
- ‘mpfr_prec_t’.  The precision can be any integer between ‘MPFR_PREC_MIN’
- and ‘MPFR_PREC_MAX’.  In the current implementation, ‘MPFR_PREC_MIN’ is
-@@ -446,7 +446,7 @@
- may abort, crash or have undefined behavior (depending on your C
- implementation).
- 
--The "rounding mode" specifies the way to round the result of a
-+The “rounding mode” specifies the way to round the result of a
- floating-point operation, in case the exact result can not be
- represented exactly in the destination significand; the corresponding C
- data type is ‘mpfr_rnd_t’.
-@@ -499,14 +499,14 @@
- representable numbers, it is rounded to the one with the least
- significant bit set to zero.  For example, the number 2.5, which is
- represented by (10.1) in binary, is rounded to (10.0)=2 with a precision
--of two bits, and not to (11.0)=3.  This rule avoids the "drift"
-+of two bits, and not to (11.0)=3.  This rule avoids the “drift”
- phenomenon mentioned by Knuth in volume 2 of The Art of Computer
- Programming (Section 4.2.2).
- 
-    Most MPFR functions take as first argument the destination variable,
- as second and following arguments the input variables, as last argument
- a rounding mode, and have a return value of type ‘int’, called the
--"ternary value".  The value stored in the destination variable is
-+“ternary value”.  The value stored in the destination variable is
- correctly rounded, i.e., MPFR behaves as if it computed the result with
- an infinite precision, then rounded it to the precision of this
- variable.  The input variables are regarded as exact (in particular,
-@@ -572,15 +572,18 @@
-    When the input point is in the closure of the domain of the
- mathematical function and an input argument is +0 (resp. −0), one
- considers the limit when the corresponding argument approaches 0 from
--above (resp. below).  If the limit is not defined (e.g., ‘mpfr_log’ on
--−0), the behavior is specified in the description of the MPFR function.
-+above (resp. below), if possible.  If the limit is not defined (e.g.,
-+‘mpfr_sqrt’ and ‘mpfr_log’ on −0), the behavior is specified in the
-+description of the MPFR function, but must be consistent with the rule
-+from the above paragraph (e.g., ‘mpfr_log’ on ±0 gives −Inf).
- 
-    When the result is equal to 0, its sign is determined by considering
- the limit as if the input point were not in the domain: If one
- approaches 0 from above (resp. below), the result is +0 (resp. −0); for
--example, ‘mpfr_sin’ on +0 gives +0.  In the other cases, the sign is
--specified in the description of the MPFR function; for example
--‘mpfr_max’ on −0 and +0 gives +0.
-+example, ‘mpfr_sin’ on −0 gives −0 and ‘mpfr_acos’ on 1 gives +0 (in all
-+rounding modes).  In the other cases, the sign is specified in the
-+description of the MPFR function; for example ‘mpfr_max’ on −0 and +0
-+gives +0.
- 
-    When the input point is not in the closure of the domain of the
- function, the result is NaN. Example: ‘mpfr_sqrt’ on −17 gives NaN.
-@@ -590,8 +593,8 @@
- numbers; such a case is always explicitly specified in *note MPFR
- Interface::.  Example: ‘mpfr_hypot’ on (NaN,0) gives NaN, but
- ‘mpfr_hypot’ on (NaN,+Inf) gives +Inf (as specified in *note Special
--Functions::), since for any finite input X, ‘mpfr_hypot’ on (X,+Inf)
--gives +Inf.
-+Functions::), since for any finite or infinite input X, ‘mpfr_hypot’ on
-+(X,+Inf) gives +Inf.
- 
- 
- File: mpfr.info,  Node: Exceptions,  Next: Memory Handling,  Prev: Floating-Point Values on Special Numbers,  Up: MPFR Basics
-@@ -1253,8 +1256,9 @@
-           mpfr_rnd_t RND)
-  -- Function: int mpfr_add_q (mpfr_t ROP, mpfr_t OP1, mpq_t OP2,
-           mpfr_rnd_t RND)
--     Set ROP to OP1 + OP2 rounded in the direction RND.  For types
--     having no signed zero, it is considered unsigned (i.e., (+0) + 0 =
-+     Set ROP to OP1 + OP2 rounded in the direction RND.  The IEEE-754
-+     rules are used, in particular for signed zeros.  But for types
-+     having no signed zeros, 0 is considered unsigned (i.e., (+0) + 0 =
-      (+0) and (−0) + 0 = (−0)).  The ‘mpfr_add_d’ function assumes that
-      the radix of the ‘double’ type is a power of 2, with a precision at
-      most that declared by the C implementation (macro
-@@ -1280,8 +1284,9 @@
-           mpfr_rnd_t RND)
-  -- Function: int mpfr_sub_q (mpfr_t ROP, mpfr_t OP1, mpq_t OP2,
-           mpfr_rnd_t RND)
--     Set ROP to OP1 - OP2 rounded in the direction RND.  For types
--     having no signed zero, it is considered unsigned (i.e., (+0) − 0 =
-+     Set ROP to OP1 - OP2 rounded in the direction RND.  The IEEE-754
-+     rules are used, in particular for signed zeros.  But for types
-+     having no signed zeros, 0 is considered unsigned (i.e., (+0) − 0 =
-      (+0), (−0) − 0 = (−0), 0 − (+0) = (−0) and 0 − (−0) = (+0)).  The
-      same restrictions than for ‘mpfr_add_d’ apply to ‘mpfr_d_sub’ and
-      ‘mpfr_sub_d’.
-@@ -1300,7 +1305,7 @@
-           mpfr_rnd_t RND)
-      Set ROP to OP1 times OP2 rounded in the direction RND.  When a
-      result is zero, its sign is the product of the signs of the
--     operands (for types having no signed zero, it is considered
-+     operands (for types having no signed zeros, 0 is considered
-      positive).  The same restrictions than for ‘mpfr_add_d’ apply to
-      ‘mpfr_mul_d’.
- 
-@@ -1327,21 +1332,24 @@
-           mpfr_rnd_t RND)
-      Set ROP to OP1/OP2 rounded in the direction RND.  When a result is
-      zero, its sign is the product of the signs of the operands (for
--     types having no signed zero, it is considered positive).  The same
-+     types having no signed zeros, 0 is considered positive).  The same
-      restrictions than for ‘mpfr_add_d’ apply to ‘mpfr_d_div’ and
-      ‘mpfr_div_d’.
- 
-  -- Function: int mpfr_sqrt (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
-  -- Function: int mpfr_sqrt_ui (mpfr_t ROP, unsigned long int OP,
-           mpfr_rnd_t RND)
--     Set ROP to the square root of OP rounded in the direction RND (set
--     ROP to −0 if OP is −0, to be consistent with the IEEE 754
--     standard).  Set ROP to NaN if OP is negative.
-+     Set ROP to the square root of OP rounded in the direction RND.  Set
-+     ROP to −0 if OP is −0, to be consistent with the IEEE 754 standard.
-+     Set ROP to NaN if OP is negative.
- 
-  -- Function: int mpfr_rec_sqrt (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
-      Set ROP to the reciprocal square root of OP rounded in the
-      direction RND.  Set ROP to +Inf if OP is ±0, +0 if OP is +Inf, and
--     NaN if OP is negative.
-+     NaN if OP is negative.  Warning!  Therefore the result on −0 is
-+     different from the one of the rSqrt function recommended by the
-+     IEEE 754-2008 standard (Section 9.2.1), which is −Inf instead of
-+     +Inf.
- 
-  -- Function: int mpfr_cbrt (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
-  -- Function: int mpfr_root (mpfr_t ROP, mpfr_t OP, unsigned long int K,
-@@ -1515,8 +1523,10 @@
-  -- Function: int mpfr_log2 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
-  -- Function: int mpfr_log10 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
-      Set ROP to the natural logarithm of OP, log2(OP) or log10(OP),
--     respectively, rounded in the direction RND.  Set ROP to −Inf if OP
--     is −0 (i.e., the sign of the zero has no influence on the result).
-+     respectively, rounded in the direction RND.  Set ROP to +0 if OP is
-+     1 (in all rounding modes), for consistency with the ISO C99 and
-+     IEEE 754-2008 standards.  Set ROP to −Inf if OP is ±0 (i.e., the
-+     sign of the zero has no influence on the result).
- 
-  -- Function: int mpfr_exp (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
-  -- Function: int mpfr_exp2 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
-@@ -1649,17 +1659,21 @@
- 
-  -- Function: int mpfr_lngamma (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
-      Set ROP to the value of the logarithm of the Gamma function on OP,
--     rounded in the direction RND.  When −2K−1 <= OP <= −2K, K being a
--     non-negative integer, ROP is set to NaN. See also ‘mpfr_lgamma’.
-+     rounded in the direction RND.  When OP is 1 or 2, set ROP to +0 (in
-+     all rounding modes).  When OP is an infinity or a nonpositive
-+     integer, set ROP to +Inf, following the general rules on special
-+     values.  When −2K−1 < OP < −2K, K being a nonnegative integer, set
-+     ROP to NaN.  See also ‘mpfr_lgamma’.
- 
-  -- Function: int mpfr_lgamma (mpfr_t ROP, int *SIGNP, mpfr_t OP,
-           mpfr_rnd_t RND)
-      Set ROP to the value of the logarithm of the absolute value of the
-      Gamma function on OP, rounded in the direction RND.  The sign (1 or
-      −1) of Gamma(OP) is returned in the object pointed to by SIGNP.
--     When OP is an infinity or a non-positive integer, set ROP to +Inf.
--     When OP is NaN, −Inf or a negative integer, *SIGNP is undefined,
--     and when OP is ±0, *SIGNP is the sign of the zero.
-+     When OP is 1 or 2, set ROP to +0 (in all rounding modes).  When OP
-+     is an infinity or a nonpositive integer, set ROP to +Inf.  When OP
-+     is NaN, −Inf or a negative integer, *SIGNP is undefined, and when
-+     OP is ±0, *SIGNP is the sign of the zero.
- 
-  -- Function: int mpfr_digamma (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND)
-      Set ROP to the value of the Digamma (sometimes also called Psi)
-@@ -1703,7 +1717,10 @@
-  -- Function: int mpfr_fms (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, mpfr_t
-           OP3, mpfr_rnd_t RND)
-      Set ROP to (OP1 times OP2) + OP3 (resp. (OP1 times OP2) - OP3)
--     rounded in the direction RND.
-+     rounded in the direction RND.  Concerning special values (signed
-+     zeros, infinities, NaN), these functions behave like a
-+     multiplication followed by a separate addition or subtraction.
-+     That is, the fused operation matters only for rounding.
- 
-  -- Function: int mpfr_agm (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2,
-           mpfr_rnd_t RND)
-@@ -1717,9 +1734,10 @@
-           RND)
-      Set ROP to the Euclidean norm of X and Y, i.e., the square root of
-      the sum of the squares of X and Y, rounded in the direction RND.
--     Special values are handled as described in Section F.9.4.3 of the
--     ISO C99 and IEEE 754-2008 standards: If X or Y is an infinity, then
--     +Inf is returned in ROP, even if the other number is NaN.
-+     Special values are handled as described in the ISO C99 (Section
-+     F.9.4.3) and IEEE 754-2008 (Section 9.2.1) standards: If X or Y is
-+     an infinity, then +Inf is returned in ROP, even if the other number
-+     is NaN.
- 
-  -- Function: int mpfr_ai (mpfr_t ROP, mpfr_t X, mpfr_rnd_t RND)
-      Set ROP to the value of the Airy function Ai on X, rounded in the
-@@ -2670,7 +2688,7 @@
- 5.16 Internals
- ==============
- 
--A "limb" means the part of a multi-precision number that fits in a
-+A “limb” means the part of a multi-precision number that fits in a
- single word.  Usually a limb contains 32 or 64 bits.  The C data type
- for a limb is ‘mp_limb_t’.
- 
-@@ -3140,7 +3158,7 @@
-   0. PREAMBLE
- 
-      The purpose of this License is to make a manual, textbook, or other
--     functional and useful document "free" in the sense of freedom: to
-+     functional and useful document “free” in the sense of freedom: to
-      assure everyone the effective freedom to copy and redistribute it,
-      with or without modifying it, either commercially or
-      noncommercially.  Secondarily, this License preserves for the
-@@ -3655,9 +3673,9 @@
- * Menu:
- 
- * mpfr_abs:                              Basic Arithmetic Functions.
--                                                              (line 160)
--* mpfr_acos:                             Special Functions.   (line  51)
--* mpfr_acosh:                            Special Functions.   (line 115)
-+                                                              (line 165)
-+* mpfr_acos:                             Special Functions.   (line  53)
-+* mpfr_acosh:                            Special Functions.   (line 117)
- * mpfr_add:                              Basic Arithmetic Functions.
-                                                               (line   6)
- * mpfr_add_d:                            Basic Arithmetic Functions.
-@@ -3670,15 +3688,15 @@
-                                                               (line   8)
- * mpfr_add_z:                            Basic Arithmetic Functions.
-                                                               (line  14)
--* mpfr_agm:                              Special Functions.   (line 210)
--* mpfr_ai:                               Special Functions.   (line 226)
--* mpfr_asin:                             Special Functions.   (line  52)
--* mpfr_asinh:                            Special Functions.   (line 116)
-+* mpfr_agm:                              Special Functions.   (line 219)
-+* mpfr_ai:                               Special Functions.   (line 236)
-+* mpfr_asin:                             Special Functions.   (line  54)
-+* mpfr_asinh:                            Special Functions.   (line 118)
- * mpfr_asprintf:                         Formatted Output Functions.
-                                                               (line 193)
--* mpfr_atan:                             Special Functions.   (line  53)
--* mpfr_atan2:                            Special Functions.   (line  63)
--* mpfr_atanh:                            Special Functions.   (line 117)
-+* mpfr_atan:                             Special Functions.   (line  55)
-+* mpfr_atan2:                            Special Functions.   (line  65)
-+* mpfr_atanh:                            Special Functions.   (line 119)
- * mpfr_buildopt_decimal_p:               Miscellaneous Functions.
-                                                               (line 162)
- * mpfr_buildopt_gmpinternals_p:          Miscellaneous Functions.
-@@ -3690,7 +3708,7 @@
- * mpfr_can_round:                        Rounding Related Functions.
-                                                               (line  39)
- * mpfr_cbrt:                             Basic Arithmetic Functions.
--                                                              (line 108)
-+                                                              (line 113)
- * mpfr_ceil:                             Integer Related Functions.
-                                                               (line   7)
- * mpfr_check_range:                      Exception Related Functions.
-@@ -3735,18 +3753,18 @@
-                                                               (line  27)
- * mpfr_cmp_z:                            Comparison Functions.
-                                                               (line  11)
--* mpfr_const_catalan:                    Special Functions.   (line 237)
--* mpfr_const_euler:                      Special Functions.   (line 236)
--* mpfr_const_log2:                       Special Functions.   (line 234)
--* mpfr_const_pi:                         Special Functions.   (line 235)
-+* mpfr_const_catalan:                    Special Functions.   (line 247)
-+* mpfr_const_euler:                      Special Functions.   (line 246)
-+* mpfr_const_log2:                       Special Functions.   (line 244)
-+* mpfr_const_pi:                         Special Functions.   (line 245)
- * mpfr_copysign:                         Miscellaneous Functions.
-                                                               (line 109)
--* mpfr_cos:                              Special Functions.   (line  29)
--* mpfr_cosh:                             Special Functions.   (line  95)
--* mpfr_cot:                              Special Functions.   (line  47)
--* mpfr_coth:                             Special Functions.   (line 111)
--* mpfr_csc:                              Special Functions.   (line  46)
--* mpfr_csch:                             Special Functions.   (line 110)
-+* mpfr_cos:                              Special Functions.   (line  31)
-+* mpfr_cosh:                             Special Functions.   (line  97)
-+* mpfr_cot:                              Special Functions.   (line  49)
-+* mpfr_coth:                             Special Functions.   (line 113)
-+* mpfr_csc:                              Special Functions.   (line  48)
-+* mpfr_csch:                             Special Functions.   (line 112)
- * mpfr_custom_get_exp:                   Custom Interface.    (line  75)
- * mpfr_custom_get_kind:                  Custom Interface.    (line  65)
- * mpfr_custom_get_significand:           Custom Interface.    (line  70)
-@@ -3756,47 +3774,47 @@
- * mpfr_custom_move:                      Custom Interface.    (line  82)
- * MPFR_DECL_INIT:                        Initialization Functions.
-                                                               (line  74)
--* mpfr_digamma:                          Special Functions.   (line 166)
-+* mpfr_digamma:                          Special Functions.   (line 172)
- * mpfr_dim:                              Basic Arithmetic Functions.
--                                                              (line 166)
-+                                                              (line 171)
- * mpfr_div:                              Basic Arithmetic Functions.
--                                                              (line  72)
-+                                                              (line  74)
- * mpfr_divby0_p:                         Exception Related Functions.
-                                                               (line 134)
- * mpfr_div_2exp:                         Compatibility with MPF.
-                                                               (line  49)
- * mpfr_div_2si:                          Basic Arithmetic Functions.
--                                                              (line 181)
-+                                                              (line 186)
- * mpfr_div_2ui:                          Basic Arithmetic Functions.
--                                                              (line 179)
-+                                                              (line 184)
- * mpfr_div_d:                            Basic Arithmetic Functions.
--                                                              (line  84)
-+                                                              (line  86)
- * mpfr_div_q:                            Basic Arithmetic Functions.
--                                                              (line  88)
-+                                                              (line  90)
- * mpfr_div_si:                           Basic Arithmetic Functions.
--                                                              (line  80)
-+                                                              (line  82)
- * mpfr_div_ui:                           Basic Arithmetic Functions.
--                                                              (line  76)
-+                                                              (line  78)
- * mpfr_div_z:                            Basic Arithmetic Functions.
--                                                              (line  86)
-+                                                              (line  88)
- * mpfr_d_div:                            Basic Arithmetic Functions.
--                                                              (line  82)
-+                                                              (line  84)
- * mpfr_d_sub:                            Basic Arithmetic Functions.
--                                                              (line  35)
--* mpfr_eint:                             Special Functions.   (line 133)
-+                                                              (line  36)
-+* mpfr_eint:                             Special Functions.   (line 135)
- * mpfr_eq:                               Compatibility with MPF.
-                                                               (line  28)
- * mpfr_equal_p:                          Comparison Functions.
-                                                               (line  59)
- * mpfr_erangeflag_p:                     Exception Related Functions.
-                                                               (line 137)
--* mpfr_erf:                              Special Functions.   (line 177)
--* mpfr_erfc:                             Special Functions.   (line 178)
--* mpfr_exp:                              Special Functions.   (line  23)
--* mpfr_exp10:                            Special Functions.   (line  25)
--* mpfr_exp2:                             Special Functions.   (line  24)
--* mpfr_expm1:                            Special Functions.   (line 129)
--* mpfr_fac_ui:                           Special Functions.   (line 121)
-+* mpfr_erf:                              Special Functions.   (line 183)
-+* mpfr_erfc:                             Special Functions.   (line 184)
-+* mpfr_exp:                              Special Functions.   (line  25)
-+* mpfr_exp10:                            Special Functions.   (line  27)
-+* mpfr_exp2:                             Special Functions.   (line  26)
-+* mpfr_expm1:                            Special Functions.   (line 131)
-+* mpfr_fac_ui:                           Special Functions.   (line 123)
- * mpfr_fits_intmax_p:                    Conversion Functions.
-                                                               (line 150)
- * mpfr_fits_sint_p:                      Conversion Functions.
-@@ -3815,20 +3833,20 @@
-                                                               (line 147)
- * mpfr_floor:                            Integer Related Functions.
-                                                               (line   8)
--* mpfr_fma:                              Special Functions.   (line 203)
-+* mpfr_fma:                              Special Functions.   (line 209)
- * mpfr_fmod:                             Integer Related Functions.
-                                                               (line  92)
--* mpfr_fms:                              Special Functions.   (line 205)
-+* mpfr_fms:                              Special Functions.   (line 211)
- * mpfr_fprintf:                          Formatted Output Functions.
-                                                               (line 157)
- * mpfr_frac:                             Integer Related Functions.
-                                                               (line  76)
--* mpfr_free_cache:                       Special Functions.   (line 244)
-+* mpfr_free_cache:                       Special Functions.   (line 254)
- * mpfr_free_str:                         Conversion Functions.
-                                                               (line 137)
- * mpfr_frexp:                            Conversion Functions.
-                                                               (line  45)
--* mpfr_gamma:                            Special Functions.   (line 148)
-+* mpfr_gamma:                            Special Functions.   (line 150)
- * mpfr_get_d:                            Conversion Functions.
-                                                               (line   7)
- * mpfr_get_decimal64:                    Conversion Functions.
-@@ -3887,7 +3905,7 @@
-                                                               (line  56)
- * mpfr_greater_p:                        Comparison Functions.
-                                                               (line  55)
--* mpfr_hypot:                            Special Functions.   (line 218)
-+* mpfr_hypot:                            Special Functions.   (line 227)
- * mpfr_inexflag_p:                       Exception Related Functions.
-                                                               (line 136)
- * mpfr_inf_p:                            Comparison Functions.
-@@ -3922,21 +3940,21 @@
-                                                               (line  31)
- * mpfr_integer_p:                        Integer Related Functions.
-                                                               (line 119)
--* mpfr_j0:                               Special Functions.   (line 182)
--* mpfr_j1:                               Special Functions.   (line 183)
--* mpfr_jn:                               Special Functions.   (line 184)
-+* mpfr_j0:                               Special Functions.   (line 188)
-+* mpfr_j1:                               Special Functions.   (line 189)
-+* mpfr_jn:                               Special Functions.   (line 190)
- * mpfr_lessequal_p:                      Comparison Functions.
-                                                               (line  58)
- * mpfr_lessgreater_p:                    Comparison Functions.
-                                                               (line  64)
- * mpfr_less_p:                           Comparison Functions.
-                                                               (line  57)
--* mpfr_lgamma:                           Special Functions.   (line 157)
--* mpfr_li2:                              Special Functions.   (line 143)
--* mpfr_lngamma:                          Special Functions.   (line 152)
-+* mpfr_lgamma:                           Special Functions.   (line 162)
-+* mpfr_li2:                              Special Functions.   (line 145)
-+* mpfr_lngamma:                          Special Functions.   (line 154)
- * mpfr_log:                              Special Functions.   (line  16)
- * mpfr_log10:                            Special Functions.   (line  18)
--* mpfr_log1p:                            Special Functions.   (line 125)
-+* mpfr_log1p:                            Special Functions.   (line 127)
- * mpfr_log2:                             Special Functions.   (line  17)
- * mpfr_max:                              Miscellaneous Functions.
-                                                               (line  22)
-@@ -3947,29 +3965,29 @@
- * mpfr_modf:                             Integer Related Functions.
-                                                               (line  82)
- * mpfr_mul:                              Basic Arithmetic Functions.
--                                                              (line  51)
-+                                                              (line  53)
- * mpfr_mul_2exp:                         Compatibility with MPF.
-                                                               (line  47)
- * mpfr_mul_2si:                          Basic Arithmetic Functions.
--                                                              (line 174)
-+                                                              (line 179)
- * mpfr_mul_2ui:                          Basic Arithmetic Functions.
--                                                              (line 172)
-+                                                              (line 177)
- * mpfr_mul_d:                            Basic Arithmetic Functions.
--                                                              (line  57)
-+                                                              (line  59)
- * mpfr_mul_q:                            Basic Arithmetic Functions.
--                                                              (line  61)
-+                                                              (line  63)
- * mpfr_mul_si:                           Basic Arithmetic Functions.
--                                                              (line  55)
-+                                                              (line  57)
- * mpfr_mul_ui:                           Basic Arithmetic Functions.
--                                                              (line  53)
-+                                                              (line  55)
- * mpfr_mul_z:                            Basic Arithmetic Functions.
--                                                              (line  59)
-+                                                              (line  61)
- * mpfr_nanflag_p:                        Exception Related Functions.
-                                                               (line 135)
- * mpfr_nan_p:                            Comparison Functions.
-                                                               (line  39)
- * mpfr_neg:                              Basic Arithmetic Functions.
--                                                              (line 159)
-+                                                              (line 164)
- * mpfr_nextabove:                        Miscellaneous Functions.
-                                                               (line  15)
- * mpfr_nextbelow:                        Miscellaneous Functions.
-@@ -3983,13 +4001,13 @@
- * mpfr_overflow_p:                       Exception Related Functions.
-                                                               (line 133)
- * mpfr_pow:                              Basic Arithmetic Functions.
--                                                              (line 116)
-+                                                              (line 121)
- * mpfr_pow_si:                           Basic Arithmetic Functions.
--                                                              (line 120)
-+                                                              (line 125)
- * mpfr_pow_ui:                           Basic Arithmetic Functions.
--                                                              (line 118)
-+                                                              (line 123)
- * mpfr_pow_z:                            Basic Arithmetic Functions.
--                                                              (line 122)
-+                                                              (line 127)
- * mpfr_prec_round:                       Rounding Related Functions.
-                                                               (line  13)
- * ‘mpfr_prec_t’:                         Nomenclature and Types.
-@@ -3999,7 +4017,7 @@
- * mpfr_print_rnd_mode:                   Rounding Related Functions.
-                                                               (line  71)
- * mpfr_rec_sqrt:                         Basic Arithmetic Functions.
--                                                              (line 103)
-+                                                              (line 105)
- * mpfr_regular_p:                        Comparison Functions.
-                                                               (line  43)
- * mpfr_reldiff:                          Compatibility with MPF.
-@@ -4021,11 +4039,11 @@
- * ‘mpfr_rnd_t’:                          Nomenclature and Types.
-                                                               (line  34)
- * mpfr_root:                             Basic Arithmetic Functions.
--                                                              (line 109)
-+                                                              (line 114)
- * mpfr_round:                            Integer Related Functions.
-                                                               (line   9)
--* mpfr_sec:                              Special Functions.   (line  45)
--* mpfr_sech:                             Special Functions.   (line 109)
-+* mpfr_sec:                              Special Functions.   (line  47)
-+* mpfr_sech:                             Special Functions.   (line 111)
- * mpfr_set:                              Assignment Functions.
-                                                               (line   9)
- * mpfr_setsign:                          Miscellaneous Functions.
-@@ -4100,57 +4118,57 @@
-                                                               (line  49)
- * mpfr_signbit:                          Miscellaneous Functions.
-                                                               (line  99)
--* mpfr_sin:                              Special Functions.   (line  30)
--* mpfr_sinh:                             Special Functions.   (line  96)
--* mpfr_sinh_cosh:                        Special Functions.   (line 101)
--* mpfr_sin_cos:                          Special Functions.   (line  35)
-+* mpfr_sin:                              Special Functions.   (line  32)
-+* mpfr_sinh:                             Special Functions.   (line  98)
-+* mpfr_sinh_cosh:                        Special Functions.   (line 103)
-+* mpfr_sin_cos:                          Special Functions.   (line  37)
- * mpfr_si_div:                           Basic Arithmetic Functions.
--                                                              (line  78)
-+                                                              (line  80)
- * mpfr_si_sub:                           Basic Arithmetic Functions.
--                                                              (line  31)
-+                                                              (line  32)
- * mpfr_snprintf:                         Formatted Output Functions.
-                                                               (line 180)
- * mpfr_sprintf:                          Formatted Output Functions.
-                                                               (line 170)
- * mpfr_sqr:                              Basic Arithmetic Functions.
--                                                              (line  69)
-+                                                              (line  71)
- * mpfr_sqrt:                             Basic Arithmetic Functions.
--                                                              (line  96)
-+                                                              (line  98)
- * mpfr_sqrt_ui:                          Basic Arithmetic Functions.
--                                                              (line  97)
-+                                                              (line  99)
- * mpfr_strtofr:                          Assignment Functions.
-                                                               (line  80)
- * mpfr_sub:                              Basic Arithmetic Functions.
--                                                              (line  25)
-+                                                              (line  26)
- * mpfr_subnormalize:                     Exception Related Functions.
-                                                               (line  60)
- * mpfr_sub_d:                            Basic Arithmetic Functions.
--                                                              (line  37)
-+                                                              (line  38)
- * mpfr_sub_q:                            Basic Arithmetic Functions.
--                                                              (line  43)
-+                                                              (line  44)
- * mpfr_sub_si:                           Basic Arithmetic Functions.
--                                                              (line  33)
-+                                                              (line  34)
- * mpfr_sub_ui:                           Basic Arithmetic Functions.
--                                                              (line  29)
-+                                                              (line  30)
- * mpfr_sub_z:                            Basic Arithmetic Functions.
--                                                              (line  41)
--* mpfr_sum:                              Special Functions.   (line 252)
-+                                                              (line  42)
-+* mpfr_sum:                              Special Functions.   (line 262)
- * mpfr_swap:                             Assignment Functions.
-                                                               (line 150)
- * ‘mpfr_t’:                              Nomenclature and Types.
-                                                               (line   6)
--* mpfr_tan:                              Special Functions.   (line  31)
--* mpfr_tanh:                             Special Functions.   (line  97)
-+* mpfr_tan:                              Special Functions.   (line  33)
-+* mpfr_tanh:                             Special Functions.   (line  99)
- * mpfr_trunc:                            Integer Related Functions.
-                                                               (line  10)
- * mpfr_ui_div:                           Basic Arithmetic Functions.
--                                                              (line  74)
-+                                                              (line  76)
- * mpfr_ui_pow:                           Basic Arithmetic Functions.
--                                                              (line 126)
-+                                                              (line 131)
- * mpfr_ui_pow_ui:                        Basic Arithmetic Functions.
--                                                              (line 124)
-+                                                              (line 129)
- * mpfr_ui_sub:                           Basic Arithmetic Functions.
--                                                              (line  27)
-+                                                              (line  28)
- * mpfr_underflow_p:                      Exception Related Functions.
-                                                               (line 132)
- * mpfr_unordered_p:                      Comparison Functions.
-@@ -4181,61 +4199,61 @@
-                                                               (line 182)
- * mpfr_vsprintf:                         Formatted Output Functions.
-                                                               (line 171)
--* mpfr_y0:                               Special Functions.   (line 193)
--* mpfr_y1:                               Special Functions.   (line 194)
--* mpfr_yn:                               Special Functions.   (line 195)
-+* mpfr_y0:                               Special Functions.   (line 199)
-+* mpfr_y1:                               Special Functions.   (line 200)
-+* mpfr_yn:                               Special Functions.   (line 201)
- * mpfr_zero_p:                           Comparison Functions.
-                                                               (line  42)
--* mpfr_zeta:                             Special Functions.   (line 171)
--* mpfr_zeta_ui:                          Special Functions.   (line 172)
-+* mpfr_zeta:                             Special Functions.   (line 177)
-+* mpfr_zeta_ui:                          Special Functions.   (line 178)
- * mpfr_z_sub:                            Basic Arithmetic Functions.
--                                                              (line  39)
-+                                                              (line  40)
- 
- 
- 
- Tag Table:
- Node: Top775
- Node: Copying2007
--Node: Introduction to MPFR3766
--Node: Installing MPFR5880
--Node: Reporting Bugs11323
--Node: MPFR Basics13353
--Node: Headers and Libraries13669
--Node: Nomenclature and Types16828
--Node: MPFR Variable Conventions18874
--Node: Rounding Modes20418
--Ref: ternary value21544
--Node: Floating-Point Values on Special Numbers23526
--Node: Exceptions26572
--Node: Memory Handling29749
--Node: MPFR Interface30894
--Node: Initialization Functions33008
--Node: Assignment Functions40318
--Node: Combined Initialization and Assignment Functions49673
--Node: Conversion Functions50974
--Node: Basic Arithmetic Functions60035
--Node: Comparison Functions69200
--Node: Special Functions72687
--Node: Input and Output Functions86672
--Node: Formatted Output Functions88644
--Node: Integer Related Functions98431
--Node: Rounding Related Functions105051
--Node: Miscellaneous Functions108888
--Node: Exception Related Functions117568
--Node: Compatibility with MPF124386
--Node: Custom Interface127127
--Node: Internals131526
--Node: API Compatibility133066
--Node: Type and Macro Changes134995
--Node: Added Functions137844
--Node: Changed Functions141132
--Node: Removed Functions145545
--Node: Other Changes145973
--Node: Contributors147576
--Node: References150219
--Node: GNU Free Documentation License151973
--Node: Concept Index174562
--Node: Function and Type Index180659
-+Node: Introduction to MPFR3770
-+Node: Installing MPFR5884
-+Node: Reporting Bugs11327
-+Node: MPFR Basics13357
-+Node: Headers and Libraries13673
-+Node: Nomenclature and Types16832
-+Node: MPFR Variable Conventions18894
-+Node: Rounding Modes20438
-+Ref: ternary value21568
-+Node: Floating-Point Values on Special Numbers23554
-+Node: Exceptions26813
-+Node: Memory Handling29990
-+Node: MPFR Interface31135
-+Node: Initialization Functions33249
-+Node: Assignment Functions40559
-+Node: Combined Initialization and Assignment Functions49914
-+Node: Conversion Functions51215
-+Node: Basic Arithmetic Functions60276
-+Node: Comparison Functions69777
-+Node: Special Functions73264
-+Node: Input and Output Functions87862
-+Node: Formatted Output Functions89834
-+Node: Integer Related Functions99621
-+Node: Rounding Related Functions106241
-+Node: Miscellaneous Functions110078
-+Node: Exception Related Functions118758
-+Node: Compatibility with MPF125576
-+Node: Custom Interface128317
-+Node: Internals132716
-+Node: API Compatibility134260
-+Node: Type and Macro Changes136189
-+Node: Added Functions139038
-+Node: Changed Functions142326
-+Node: Removed Functions146739
-+Node: Other Changes147167
-+Node: Contributors148770
-+Node: References151413
-+Node: GNU Free Documentation License153167
-+Node: Concept Index175760
-+Node: Function and Type Index181857
- 
- End Tag Table
- 
-diff -Naurd mpfr-3.1.3-a/src/lngamma.c mpfr-3.1.3-b/src/lngamma.c
---- mpfr-3.1.3-a/src/lngamma.c	2015-06-19 19:55:10.000000000 +0000
-+++ mpfr-3.1.3-b/src/lngamma.c	2015-07-02 10:49:24.018113593 +0000
-@@ -603,16 +603,17 @@
-       mpfr_get_prec (y), mpfr_log_prec, y, inex));
- 
-   /* special cases */
--  if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x)))
-+  if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x) ||
-+                     (MPFR_IS_NEG (x) && mpfr_integer_p (x))))
-     {
--      if (MPFR_IS_NAN (x) || MPFR_IS_NEG (x))
-+      if (MPFR_IS_NAN (x))
-         {
-           MPFR_SET_NAN (y);
-           MPFR_RET_NAN;
-         }
--      else /* lngamma(+Inf) = lngamma(+0) = +Inf */
-+      else /* lngamma(+/-Inf) = lngamma(nonpositive integer) = +Inf */
-         {
--          if (MPFR_IS_ZERO (x))
-+          if (!MPFR_IS_INF (x))
-             mpfr_set_divby0 ();
-           MPFR_SET_INF (y);
-           MPFR_SET_POS (y);
-@@ -620,8 +621,8 @@
-         }
-     }
- 
--  /* if x < 0 and -2k-1 <= x <= -2k, then lngamma(x) = NaN */
--  if (MPFR_IS_NEG (x) && (unit_bit (x) == 0 || mpfr_integer_p (x)))
-+  /* if -2k-1 < x < -2k <= 0, then lngamma(x) = NaN */
-+  if (MPFR_IS_NEG (x) && unit_bit (x) == 0)
-     {
-       MPFR_SET_NAN (y);
-       MPFR_RET_NAN;
-diff -Naurd mpfr-3.1.3-a/src/mpfr.h mpfr-3.1.3-b/src/mpfr.h
---- mpfr-3.1.3-a/src/mpfr.h	2015-06-19 19:55:10.000000000 +0000
-+++ mpfr-3.1.3-b/src/mpfr.h	2015-07-02 10:49:24.038113803 +0000
-@@ -27,7 +27,7 @@
- #define MPFR_VERSION_MAJOR 3
- #define MPFR_VERSION_MINOR 1
- #define MPFR_VERSION_PATCHLEVEL 3
--#define MPFR_VERSION_STRING "3.1.3"
-+#define MPFR_VERSION_STRING "3.1.3-p1"
- 
- /* Macros dealing with MPFR VERSION */
- #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
-diff -Naurd mpfr-3.1.3-a/src/version.c mpfr-3.1.3-b/src/version.c
---- mpfr-3.1.3-a/src/version.c	2015-06-19 19:55:10.000000000 +0000
-+++ mpfr-3.1.3-b/src/version.c	2015-07-02 10:49:24.042113845 +0000
-@@ -25,5 +25,5 @@
- const char *
- mpfr_get_version (void)
- {
--  return "3.1.3";
-+  return "3.1.3-p1";
- }
-diff -Naurd mpfr-3.1.3-a/tests/tlngamma.c mpfr-3.1.3-b/tests/tlngamma.c
---- mpfr-3.1.3-a/tests/tlngamma.c	2015-06-19 19:55:10.000000000 +0000
-+++ mpfr-3.1.3-b/tests/tlngamma.c	2015-07-02 10:49:24.018113593 +0000
-@@ -33,7 +33,7 @@
- special (void)
- {
-   mpfr_t x, y;
--  int inex;
-+  int i, inex;
- 
-   mpfr_init (x);
-   mpfr_init (y);
-@@ -46,25 +46,29 @@
-       exit (1);
-     }
- 
--  mpfr_set_inf (x, -1);
-+  mpfr_set_inf (x, 1);
-+  mpfr_clear_flags ();
-   mpfr_lngamma (y, x, MPFR_RNDN);
--  if (!mpfr_nan_p (y))
-+  if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 || __gmpfr_flags != 0)
-     {
--      printf ("Error for lngamma(-Inf)\n");
-+      printf ("Error for lngamma(+Inf)\n");
-       exit (1);
-     }
- 
--  mpfr_set_inf (x, 1);
-+  mpfr_set_inf (x, -1);
-+  mpfr_clear_flags ();
-   mpfr_lngamma (y, x, MPFR_RNDN);
--  if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0)
-+  if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 || __gmpfr_flags != 0)
-     {
--      printf ("Error for lngamma(+Inf)\n");
-+      printf ("Error for lngamma(-Inf)\n");
-       exit (1);
-     }
- 
-   mpfr_set_ui (x, 0, MPFR_RNDN);
-+  mpfr_clear_flags ();
-   mpfr_lngamma (y, x, MPFR_RNDN);
--  if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0)
-+  if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 ||
-+      __gmpfr_flags != MPFR_FLAGS_DIVBY0)
-     {
-       printf ("Error for lngamma(+0)\n");
-       exit (1);
-@@ -72,32 +76,58 @@
- 
-   mpfr_set_ui (x, 0, MPFR_RNDN);
-   mpfr_neg (x, x, MPFR_RNDN);
-+  mpfr_clear_flags ();
-   mpfr_lngamma (y, x, MPFR_RNDN);
--  if (!mpfr_nan_p (y))
-+  if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 ||
-+      __gmpfr_flags != MPFR_FLAGS_DIVBY0)
-     {
-       printf ("Error for lngamma(-0)\n");
-       exit (1);
-     }
- 
-   mpfr_set_ui (x, 1, MPFR_RNDN);
-+  mpfr_clear_flags ();
-   mpfr_lngamma (y, x, MPFR_RNDN);
--  if (MPFR_IS_NAN (y) || mpfr_cmp_ui (y, 0) || MPFR_IS_NEG (y))
-+  if (mpfr_cmp_ui0 (y, 0) || MPFR_IS_NEG (y))
-     {
-       printf ("Error for lngamma(1)\n");
-       exit (1);
-     }
- 
--  mpfr_set_si (x, -1, MPFR_RNDN);
--  mpfr_lngamma (y, x, MPFR_RNDN);
--  if (!mpfr_nan_p (y))
-+  for (i = 1; i <= 5; i++)
-     {
--      printf ("Error for lngamma(-1)\n");
--      exit (1);
-+      int c;
-+
-+      mpfr_set_si (x, -i, MPFR_RNDN);
-+      mpfr_clear_flags ();
-+      mpfr_lngamma (y, x, MPFR_RNDN);
-+      if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 ||
-+          __gmpfr_flags != MPFR_FLAGS_DIVBY0)
-+        {
-+          printf ("Error for lngamma(-%d)\n", i);
-+          exit (1);
-+        }
-+      if (i & 1)
-+        {
-+          mpfr_nextabove (x);
-+          c = '+';
-+        }
-+      else
-+        {
-+          mpfr_nextbelow (x);
-+          c = '-';
-+        }
-+      mpfr_lngamma (y, x, MPFR_RNDN);
-+      if (!mpfr_nan_p (y))
-+        {
-+          printf ("Error for lngamma(-%d%cepsilon)\n", i, c);
-+          exit (1);
-+        }
-     }
- 
-   mpfr_set_ui (x, 2, MPFR_RNDN);
-   mpfr_lngamma (y, x, MPFR_RNDN);
--  if (MPFR_IS_NAN (y) || mpfr_cmp_ui (y, 0) || MPFR_IS_NEG (y))
-+  if (mpfr_cmp_ui0 (y, 0) || MPFR_IS_NEG (y))
-     {
-       printf ("Error for lngamma(2)\n");
-       exit (1);
-@@ -127,7 +157,7 @@
-   mpfr_set_str (x, CHECK_X2, 10, MPFR_RNDN);
-   mpfr_lngamma (y, x, MPFR_RNDN);
-   mpfr_set_str (x, CHECK_Y2, 10, MPFR_RNDN);
--  if (MPFR_IS_NAN (y) || mpfr_cmp (y, x))
-+  if (mpfr_cmp0 (y, x))
-     {
-       printf ("mpfr_lngamma("CHECK_X2") is wrong:\n"
-               "expected ");
-@@ -143,7 +173,7 @@
-   mpfr_lngamma (y, x, MPFR_RNDU);
-   mpfr_set_prec (x, 175);
-   mpfr_set_str_binary (x, "0.1010001100011101101011001101110010100001000001000001110011000001101100001111001001000101011011100100010101011110100111110101010100010011010010000101010111001100011000101111E7");
--  if (MPFR_IS_NAN (y) || mpfr_cmp (x, y))
-+  if (mpfr_cmp0 (x, y))
-     {
-       printf ("Error in mpfr_lngamma (1)\n");
-       exit (1);
-@@ -155,7 +185,7 @@
-   mpfr_lngamma (x, y, MPFR_RNDZ);
-   mpfr_set_prec (y, 21);
-   mpfr_set_str_binary (y, "0.111000101000001100101E9");
--  if (MPFR_IS_NAN (x) || mpfr_cmp (x, y))
-+  if (mpfr_cmp0 (x, y))
-     {
-       printf ("Error in mpfr_lngamma (120)\n");
-       printf ("Expected "); mpfr_print_binary (y); puts ("");
-@@ -169,7 +199,7 @@
-   inex = mpfr_lngamma (y, x, MPFR_RNDN);
-   mpfr_set_prec (x, 206);
-   mpfr_set_str_binary (x, "0.10000111011000000011100010101001100110001110000111100011000100100110110010001011011110101001111011110110000001010100111011010000000011100110110101100111000111010011110010000100010111101010001101000110101001E13");
--  if (MPFR_IS_NAN (y) || mpfr_cmp (x, y))
-+  if (mpfr_cmp0 (x, y))
-     {
-       printf ("Error in mpfr_lngamma (768)\n");
-       exit (1);
-@@ -185,7 +215,7 @@
-   mpfr_set_str_binary (x, "0.1100E-66");
-   mpfr_lngamma (y, x, MPFR_RNDN);
-   mpfr_set_str_binary (x, "0.1100E6");
--  if (MPFR_IS_NAN (y) || mpfr_cmp (x, y))
-+  if (mpfr_cmp0 (x, y))
-     {
-       printf ("Error for lngamma(0.1100E-66)\n");
-       exit (1);
-@@ -199,7 +229,7 @@
-   mpfr_lngamma (y, x, MPFR_RNDN);
-   mpfr_set_prec (x, 32);
-   mpfr_set_str_binary (x, "-0.10001000111011111011000010100010E207");
--  if (MPFR_IS_NAN (y) || mpfr_cmp (x, y))
-+  if (mpfr_cmp0 (x, y))
-     {
-       printf ("Error for lngamma(-2^199+0.5)\n");
-       printf ("Got        ");
-diff -Naurd mpfr-3.1.3-a/PATCHES mpfr-3.1.3-b/PATCHES
---- mpfr-3.1.3-a/PATCHES	2015-07-02 10:50:08.046573308 +0000
-+++ mpfr-3.1.3-b/PATCHES	2015-07-02 10:50:08.126574142 +0000
-@@ -0,0 +1 @@
-+muldiv-2exp-overflow
-diff -Naurd mpfr-3.1.3-a/VERSION mpfr-3.1.3-b/VERSION
---- mpfr-3.1.3-a/VERSION	2015-07-02 10:49:24.042113845 +0000
-+++ mpfr-3.1.3-b/VERSION	2015-07-02 10:50:08.126574142 +0000
-@@ -1 +1 @@
--3.1.3-p1
-+3.1.3-p2
-diff -Naurd mpfr-3.1.3-a/src/div_2si.c mpfr-3.1.3-b/src/div_2si.c
---- mpfr-3.1.3-a/src/div_2si.c	2015-06-19 19:55:10.000000000 +0000
-+++ mpfr-3.1.3-b/src/div_2si.c	2015-07-02 10:50:08.106573933 +0000
-@@ -49,7 +49,7 @@
-             rnd_mode = MPFR_RNDZ;
-           return mpfr_underflow (y, rnd_mode, MPFR_SIGN(y));
-         }
--      else if (MPFR_UNLIKELY(n < 0 && (__gmpfr_emax < MPFR_EMIN_MIN - n ||
-+      else if (MPFR_UNLIKELY(n <= 0 && (__gmpfr_emax < MPFR_EMIN_MIN - n ||
-                                        exp > __gmpfr_emax + n)) )
-         return mpfr_overflow (y, rnd_mode, MPFR_SIGN(y));
- 
-diff -Naurd mpfr-3.1.3-a/src/div_2ui.c mpfr-3.1.3-b/src/div_2ui.c
---- mpfr-3.1.3-a/src/div_2ui.c	2015-06-19 19:55:10.000000000 +0000
-+++ mpfr-3.1.3-b/src/div_2ui.c	2015-07-02 10:50:08.106573933 +0000
-@@ -32,7 +32,7 @@
-      rnd_mode),
-     ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inexact));
- 
--  if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x)))
-+  if (MPFR_UNLIKELY (n == 0 || MPFR_IS_SINGULAR (x)))
-     return mpfr_set (y, x, rnd_mode);
-   else
-     {
-diff -Naurd mpfr-3.1.3-a/src/mpfr.h mpfr-3.1.3-b/src/mpfr.h
---- mpfr-3.1.3-a/src/mpfr.h	2015-07-02 10:49:24.038113803 +0000
-+++ mpfr-3.1.3-b/src/mpfr.h	2015-07-02 10:50:08.126574142 +0000
-@@ -27,7 +27,7 @@
- #define MPFR_VERSION_MAJOR 3
- #define MPFR_VERSION_MINOR 1
- #define MPFR_VERSION_PATCHLEVEL 3
--#define MPFR_VERSION_STRING "3.1.3-p1"
-+#define MPFR_VERSION_STRING "3.1.3-p2"
- 
- /* Macros dealing with MPFR VERSION */
- #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
-diff -Naurd mpfr-3.1.3-a/src/mul_2si.c mpfr-3.1.3-b/src/mul_2si.c
---- mpfr-3.1.3-a/src/mul_2si.c	2015-06-19 19:55:10.000000000 +0000
-+++ mpfr-3.1.3-b/src/mul_2si.c	2015-07-02 10:50:08.106573933 +0000
-@@ -39,7 +39,7 @@
-     {
-       mpfr_exp_t exp = MPFR_GET_EXP (x);
-       MPFR_SETRAW (inexact, y, x, exp, rnd_mode);
--      if (MPFR_UNLIKELY( n > 0 && (__gmpfr_emax < MPFR_EMIN_MIN + n ||
-+      if (MPFR_UNLIKELY(n >= 0 && (__gmpfr_emax < MPFR_EMIN_MIN + n ||
-                                    exp > __gmpfr_emax - n)))
-         return mpfr_overflow (y, rnd_mode, MPFR_SIGN(y));
-       else if (MPFR_UNLIKELY(n < 0 && (__gmpfr_emin > MPFR_EMAX_MAX + n ||
-diff -Naurd mpfr-3.1.3-a/src/version.c mpfr-3.1.3-b/src/version.c
---- mpfr-3.1.3-a/src/version.c	2015-07-02 10:49:24.042113845 +0000
-+++ mpfr-3.1.3-b/src/version.c	2015-07-02 10:50:08.126574142 +0000
-@@ -25,5 +25,5 @@
- const char *
- mpfr_get_version (void)
- {
--  return "3.1.3-p1";
-+  return "3.1.3-p2";
- }
-diff -Naurd mpfr-3.1.3-a/tests/tmul_2exp.c mpfr-3.1.3-b/tests/tmul_2exp.c
---- mpfr-3.1.3-a/tests/tmul_2exp.c	2015-06-19 19:55:10.000000000 +0000
-+++ mpfr-3.1.3-b/tests/tmul_2exp.c	2015-07-02 10:50:08.106573933 +0000
-@@ -242,6 +242,76 @@
-   large (MPFR_EMAX_MAX);
- }
- 
-+/* Cases where the function overflows on n = 0 when rounding is like
-+   away from zero. */
-+static void
-+overflow0 (mpfr_exp_t emax)
-+{
-+  mpfr_exp_t old_emax;
-+  mpfr_t x, y1, y2;
-+  int neg, r, op;
-+  static char *sop[4] = { "mul_2ui", "mul_2si", "div_2ui", "div_2si" };
-+
-+  old_emax = mpfr_get_emax ();
-+  set_emax (emax);
-+
-+  mpfr_init2 (x, 8);
-+  mpfr_inits2 (6, y1, y2, (mpfr_ptr) 0);
-+
-+  mpfr_set_inf (x, 1);
-+  mpfr_nextbelow (x);
-+
-+  for (neg = 0; neg <= 1; neg++)
-+    {
-+      RND_LOOP (r)
-+        {
-+          int inex1, inex2;
-+          unsigned int flags1, flags2;
-+
-+          /* Even if there isn't an overflow (rounding ~ toward zero),
-+             the result is the same as the one of an overflow. */
-+          inex1 = mpfr_overflow (y1, (mpfr_rnd_t) r, neg ? -1 : 1);
-+          flags1 = MPFR_FLAGS_INEXACT;
-+          if (mpfr_inf_p (y1))
-+            flags1 |= MPFR_FLAGS_OVERFLOW;
-+          for (op = 0; op < 4; op++)
-+            {
-+              mpfr_clear_flags ();
-+              inex2 =
-+                op == 0 ? mpfr_mul_2ui (y2, x, 0, (mpfr_rnd_t) r) :
-+                op == 1 ? mpfr_mul_2si (y2, x, 0, (mpfr_rnd_t) r) :
-+                op == 2 ? mpfr_div_2ui (y2, x, 0, (mpfr_rnd_t) r) :
-+                op == 3 ? mpfr_div_2si (y2, x, 0, (mpfr_rnd_t) r) :
-+                (MPFR_ASSERTN (0), 0);
-+              flags2 = __gmpfr_flags;
-+              if (!(mpfr_equal_p (y1, y2) &&
-+                    SAME_SIGN (inex1, inex2) &&
-+                    flags1 == flags2))
-+                {
-+                  printf ("Error in overflow0 for %s, mpfr_%s, emax = %"
-+                          MPFR_EXP_FSPEC "d,\nx = ",
-+                          mpfr_print_rnd_mode ((mpfr_rnd_t) r), sop[op],
-+                          (mpfr_eexp_t) emax);
-+                  mpfr_dump (x);
-+                  printf ("Expected ");
-+                  mpfr_dump (y1);
-+                  printf ("  with inex = %d, flags =", inex1);
-+                  flags_out (flags1);
-+                  printf ("Got      ");
-+                  mpfr_dump (y2);
-+                  printf ("  with inex = %d, flags =", inex2);
-+                  flags_out (flags2);
-+                  exit (1);
-+                }
-+            }
-+        }
-+      mpfr_neg (x, x, MPFR_RNDN);
-+    }
-+
-+  mpfr_clears (x, y1, y2, (mpfr_ptr) 0);
-+  set_emax (old_emax);
-+}
-+
- int
- main (int argc, char *argv[])
- {
-@@ -334,6 +404,11 @@
-   underflow0 ();
-   large0 ();
- 
-+  if (mpfr_get_emax () != MPFR_EMAX_MAX)
-+    overflow0 (mpfr_get_emax ());
-+  overflow0 (MPFR_EMAX_MAX);
-+  overflow0 (-1);
-+
-   tests_end_mpfr ();
-   return 0;
- }
-diff -Naurd mpfr-3.1.3-a/PATCHES mpfr-3.1.3-b/PATCHES
---- mpfr-3.1.3-a/PATCHES	2015-07-17 08:54:48.592799981 +0000
-+++ mpfr-3.1.3-b/PATCHES	2015-07-17 08:54:48.616811495 +0000
-@@ -0,0 +1 @@
-+muldiv-2exp-underflow
-diff -Naurd mpfr-3.1.3-a/VERSION mpfr-3.1.3-b/VERSION
---- mpfr-3.1.3-a/VERSION	2015-07-02 10:50:08.126574142 +0000
-+++ mpfr-3.1.3-b/VERSION	2015-07-17 08:54:48.616811495 +0000
-@@ -1 +1 @@
--3.1.3-p2
-+3.1.3-p3
-diff -Naurd mpfr-3.1.3-a/src/div_2si.c mpfr-3.1.3-b/src/div_2si.c
---- mpfr-3.1.3-a/src/div_2si.c	2015-07-02 10:50:08.106573933 +0000
-+++ mpfr-3.1.3-b/src/div_2si.c	2015-07-17 08:54:48.608807656 +0000
-@@ -45,7 +45,8 @@
-           if (rnd_mode == MPFR_RNDN &&
-               (__gmpfr_emin > MPFR_EMAX_MAX - (n - 1) ||
-                exp < __gmpfr_emin + (n - 1) ||
--               (inexact >= 0 && mpfr_powerof2_raw (y))))
-+               ((MPFR_IS_NEG (y) ? inexact <= 0 : inexact >= 0) &&
-+                mpfr_powerof2_raw (y))))
-             rnd_mode = MPFR_RNDZ;
-           return mpfr_underflow (y, rnd_mode, MPFR_SIGN(y));
-         }
-diff -Naurd mpfr-3.1.3-a/src/div_2ui.c mpfr-3.1.3-b/src/div_2ui.c
---- mpfr-3.1.3-a/src/div_2ui.c	2015-07-02 10:50:08.106573933 +0000
-+++ mpfr-3.1.3-b/src/div_2ui.c	2015-07-17 08:54:48.608807656 +0000
-@@ -44,7 +44,9 @@
-       if (MPFR_UNLIKELY (n >= diffexp))  /* exp - n <= emin - 1 */
-         {
-           if (rnd_mode == MPFR_RNDN &&
--              (n > diffexp || (inexact >= 0 && mpfr_powerof2_raw (y))))
-+              (n > diffexp ||
-+               ((MPFR_IS_NEG (y) ? inexact <= 0 : inexact >= 0) &&
-+                mpfr_powerof2_raw (y))))
-             rnd_mode = MPFR_RNDZ;
-           return mpfr_underflow (y, rnd_mode, MPFR_SIGN (y));
-         }
-diff -Naurd mpfr-3.1.3-a/src/mpfr.h mpfr-3.1.3-b/src/mpfr.h
---- mpfr-3.1.3-a/src/mpfr.h	2015-07-02 10:50:08.126574142 +0000
-+++ mpfr-3.1.3-b/src/mpfr.h	2015-07-17 08:54:48.616811495 +0000
-@@ -27,7 +27,7 @@
- #define MPFR_VERSION_MAJOR 3
- #define MPFR_VERSION_MINOR 1
- #define MPFR_VERSION_PATCHLEVEL 3
--#define MPFR_VERSION_STRING "3.1.3-p2"
-+#define MPFR_VERSION_STRING "3.1.3-p3"
- 
- /* Macros dealing with MPFR VERSION */
- #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
-diff -Naurd mpfr-3.1.3-a/src/mul_2si.c mpfr-3.1.3-b/src/mul_2si.c
---- mpfr-3.1.3-a/src/mul_2si.c	2015-07-02 10:50:08.106573933 +0000
-+++ mpfr-3.1.3-b/src/mul_2si.c	2015-07-17 08:54:48.608807656 +0000
-@@ -48,7 +48,8 @@
-           if (rnd_mode == MPFR_RNDN &&
-               (__gmpfr_emin > MPFR_EMAX_MAX + (n + 1) ||
-                exp < __gmpfr_emin - (n + 1) ||
--               (inexact >= 0 && mpfr_powerof2_raw (y))))
-+               ((MPFR_IS_NEG (y) ? inexact <= 0 : inexact >= 0) &&
-+                mpfr_powerof2_raw (y))))
-             rnd_mode = MPFR_RNDZ;
-           return mpfr_underflow (y, rnd_mode, MPFR_SIGN(y));
-         }
-diff -Naurd mpfr-3.1.3-a/src/version.c mpfr-3.1.3-b/src/version.c
---- mpfr-3.1.3-a/src/version.c	2015-07-02 10:50:08.126574142 +0000
-+++ mpfr-3.1.3-b/src/version.c	2015-07-17 08:54:48.616811495 +0000
-@@ -25,5 +25,5 @@
- const char *
- mpfr_get_version (void)
- {
--  return "3.1.3-p2";
-+  return "3.1.3-p3";
- }
-diff -Naurd mpfr-3.1.3-a/tests/tmul_2exp.c mpfr-3.1.3-b/tests/tmul_2exp.c
---- mpfr-3.1.3-a/tests/tmul_2exp.c	2015-07-02 10:50:08.106573933 +0000
-+++ mpfr-3.1.3-b/tests/tmul_2exp.c	2015-07-17 08:54:48.608807656 +0000
-@@ -50,77 +50,82 @@
- {
-   mpfr_t x, y, z1, z2;
-   mpfr_exp_t emin;
--  int i, k;
-+  int i, k, s;
-   int prec;
-   int rnd;
-   int div;
-   int inex1, inex2;
-   unsigned int flags1, flags2;
- 
--  /* Test mul_2si(x, e - k), div_2si(x, k - e) and div_2ui(x, k - e)
--   * with emin = e, x = 1 + i/16, i in { -1, 0, 1 }, and k = 1 to 4,
--   * by comparing the result with the one of a simple division.
-+  /* Test mul_2si(x, e - k), div_2si(x, k - e) and div_2ui(x, k - e) with
-+   * emin = e, x = s * (1 + i/16), i in { -1, 0, 1 }, s in { -1, 1 }, and
-+   * k = 1 to 4, by comparing the result with the one of a simple division.
-    */
-   emin = mpfr_get_emin ();
-   set_emin (e);
-   mpfr_inits2 (8, x, y, (mpfr_ptr) 0);
-   for (i = 15; i <= 17; i++)
--    {
--      inex1 = mpfr_set_ui_2exp (x, i, -4, MPFR_RNDN);
--      MPFR_ASSERTN (inex1 == 0);
--      for (prec = 6; prec >= 3; prec -= 3)
--        {
--          mpfr_inits2 (prec, z1, z2, (mpfr_ptr) 0);
--          RND_LOOP (rnd)
--            for (k = 1; k <= 4; k++)
--              {
--                /* The following one is assumed to be correct. */
--                inex1 = mpfr_mul_2si (y, x, e, MPFR_RNDN);
--                MPFR_ASSERTN (inex1 == 0);
--                inex1 = mpfr_set_ui (z1, 1 << k, MPFR_RNDN);
--                MPFR_ASSERTN (inex1 == 0);
--                mpfr_clear_flags ();
--                /* Do not use mpfr_div_ui to avoid the optimization
--                   by mpfr_div_2si. */
--                inex1 = mpfr_div (z1, y, z1, (mpfr_rnd_t) rnd);
--                flags1 = __gmpfr_flags;
--
--              for (div = 0; div <= 2; div++)
-+    for (s = 1; s >= -1; s -= 2)
-+      {
-+        inex1 = mpfr_set_si_2exp (x, s * i, -4, MPFR_RNDN);
-+        MPFR_ASSERTN (inex1 == 0);
-+        for (prec = 6; prec >= 3; prec -= 3)
-+          {
-+            mpfr_inits2 (prec, z1, z2, (mpfr_ptr) 0);
-+            RND_LOOP (rnd)
-+              for (k = 1; k <= 4; k++)
-                 {
-+                  /* The following one is assumed to be correct. */
-+                  inex1 = mpfr_mul_2si (y, x, e, MPFR_RNDN);
-+                  MPFR_ASSERTN (inex1 == 0);
-+                  inex1 = mpfr_set_ui (z1, 1 << k, MPFR_RNDN);
-+                  MPFR_ASSERTN (inex1 == 0);
-                   mpfr_clear_flags ();
--                  inex2 = div == 0 ?
--                    mpfr_mul_2si (z2, x, e - k, (mpfr_rnd_t) rnd) : div == 1 ?
--                    mpfr_div_2si (z2, x, k - e, (mpfr_rnd_t) rnd) :
--                    mpfr_div_2ui (z2, x, k - e, (mpfr_rnd_t) rnd);
--                  flags2 = __gmpfr_flags;
--                  if (flags1 == flags2 && SAME_SIGN (inex1, inex2) &&
--                      mpfr_equal_p (z1, z2))
--                    continue;
--                  printf ("Error in underflow(");
--                  if (e == MPFR_EMIN_MIN)
--                    printf ("MPFR_EMIN_MIN");
--                  else if (e == emin)
--                    printf ("default emin");
--                  else if (e >= LONG_MIN)
--                    printf ("%ld", (long) e);
--                  else
--                    printf ("<LONG_MIN");
--                  printf (") with mpfr_%s,\nx = %d/16, prec = %d, k = %d, "
--                          "%s\n", div == 0 ? "mul_2si" : div == 1 ?
--                          "div_2si" : "div_2ui", i, prec, k,
--                          mpfr_print_rnd_mode ((mpfr_rnd_t) rnd));
--                  printf ("Expected ");
--                  mpfr_out_str (stdout, 16, 0, z1, MPFR_RNDN);
--                  printf (", inex = %d, flags = %u\n", SIGN (inex1), flags1);
--                  printf ("Got      ");
--                  mpfr_out_str (stdout, 16, 0, z2, MPFR_RNDN);
--                  printf (", inex = %d, flags = %u\n", SIGN (inex2), flags2);
--                  exit (1);
--                }  /* div */
--              }  /* k */
--          mpfr_clears (z1, z2, (mpfr_ptr) 0);
--        }  /* prec */
--    }  /* i */
-+                  /* Do not use mpfr_div_ui to avoid the optimization
-+                     by mpfr_div_2si. */
-+                  inex1 = mpfr_div (z1, y, z1, (mpfr_rnd_t) rnd);
-+                  flags1 = __gmpfr_flags;
-+
-+                  for (div = 0; div <= 2; div++)
-+                    {
-+                      mpfr_clear_flags ();
-+                      inex2 =
-+                        div == 0 ?
-+                        mpfr_mul_2si (z2, x, e - k, (mpfr_rnd_t) rnd) :
-+                        div == 1 ?
-+                        mpfr_div_2si (z2, x, k - e, (mpfr_rnd_t) rnd) :
-+                        mpfr_div_2ui (z2, x, k - e, (mpfr_rnd_t) rnd);
-+                      flags2 = __gmpfr_flags;
-+                      if (flags1 == flags2 && SAME_SIGN (inex1, inex2) &&
-+                          mpfr_equal_p (z1, z2))
-+                        continue;
-+                      printf ("Error in underflow(");
-+                      if (e == MPFR_EMIN_MIN)
-+                        printf ("MPFR_EMIN_MIN");
-+                      else if (e == emin)
-+                        printf ("default emin");
-+                      else if (e >= LONG_MIN)
-+                        printf ("%ld", (long) e);
-+                      else
-+                        printf ("<LONG_MIN");
-+                      printf (") with mpfr_%s,\nx = %d/16, prec = %d, k = %d,"
-+                              " %s\n", div == 0 ? "mul_2si" : div == 1 ?
-+                              "div_2si" : "div_2ui", s * i, prec, k,
-+                              mpfr_print_rnd_mode ((mpfr_rnd_t) rnd));
-+                      printf ("Expected ");
-+                      mpfr_out_str (stdout, 16, 0, z1, MPFR_RNDN);
-+                      printf (", inex = %d, flags = %u\n",
-+                              SIGN (inex1), flags1);
-+                      printf ("Got      ");
-+                      mpfr_out_str (stdout, 16, 0, z2, MPFR_RNDN);
-+                      printf (", inex = %d, flags = %u\n",
-+                              SIGN (inex2), flags2);
-+                      exit (1);
-+                    }  /* div */
-+                }  /* k */
-+            mpfr_clears (z1, z2, (mpfr_ptr) 0);
-+          }  /* prec */
-+      }  /* i */
-   mpfr_clears (x, y, (mpfr_ptr) 0);
-   set_emin (emin);
- }
-diff -Naurd mpfr-3.1.3-a/PATCHES mpfr-3.1.3-b/PATCHES
---- mpfr-3.1.3-a/PATCHES	2015-07-17 08:58:21.094987384 +0000
-+++ mpfr-3.1.3-b/PATCHES	2015-07-17 08:58:21.118986898 +0000
-@@ -0,0 +1 @@
-+frexp
-diff -Naurd mpfr-3.1.3-a/VERSION mpfr-3.1.3-b/VERSION
---- mpfr-3.1.3-a/VERSION	2015-07-17 08:54:48.616811495 +0000
-+++ mpfr-3.1.3-b/VERSION	2015-07-17 08:58:21.118986898 +0000
-@@ -1 +1 @@
--3.1.3-p3
-+3.1.3-p4
-diff -Naurd mpfr-3.1.3-a/src/frexp.c mpfr-3.1.3-b/src/frexp.c
---- mpfr-3.1.3-a/src/frexp.c	2015-06-19 19:55:09.000000000 +0000
-+++ mpfr-3.1.3-b/src/frexp.c	2015-07-17 08:58:21.106987142 +0000
-@@ -26,6 +26,13 @@
- mpfr_frexp (mpfr_exp_t *exp, mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd)
- {
-   int inex;
-+  unsigned int saved_flags = __gmpfr_flags;
-+  MPFR_BLOCK_DECL (flags);
-+
-+  MPFR_LOG_FUNC
-+    (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd),
-+     ("y[%Pu]=%.*Rg exp=%" MPFR_EXP_FSPEC "d inex=%d", mpfr_get_prec (y),
-+      mpfr_log_prec, y, (mpfr_eexp_t) *exp, inex));
- 
-   if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(x)))
-     {
-@@ -49,8 +56,32 @@
-         }
-     }
- 
--  inex = mpfr_set (y, x, rnd);
-+  MPFR_BLOCK (flags, inex = mpfr_set (y, x, rnd));
-+  __gmpfr_flags = saved_flags;
-+
-+  /* Possible overflow due to the rounding, no possible underflow. */
-+
-+  if (MPFR_UNLIKELY (MPFR_OVERFLOW (flags)))
-+    {
-+      int inex2;
-+
-+      /* An overflow here means that the exponent of y would be larger than
-+         the one of x, thus x would be rounded to the next power of 2, and
-+         the returned y should be 1/2 in absolute value, rounded (i.e. with
-+         possible underflow or overflow). This also implies that x and y are
-+         different objects, so that the exponent of x has not been lost. */
-+      MPFR_LOG_MSG (("Internal overflow\n", 0));
-+      MPFR_ASSERTD (x != y);
-+      *exp = MPFR_GET_EXP (x) + 1;
-+      inex2 = mpfr_set_si_2exp (y, MPFR_INT_SIGN (x), -1, rnd);
-+      MPFR_LOG_MSG (("inex=%d inex2=%d\n", inex, inex2));
-+      if (inex2 != 0)
-+        inex = inex2;
-+      MPFR_RET (inex);
-+    }
-+
-   *exp = MPFR_GET_EXP (y);
--  MPFR_SET_EXP (y, 0);
-+  /* Do not use MPFR_SET_EXP because the range has not been checked yet. */
-+  MPFR_EXP (y) = 0;
-   return mpfr_check_range (y, inex, rnd);
- }
-diff -Naurd mpfr-3.1.3-a/src/mpfr.h mpfr-3.1.3-b/src/mpfr.h
---- mpfr-3.1.3-a/src/mpfr.h	2015-07-17 08:54:48.616811495 +0000
-+++ mpfr-3.1.3-b/src/mpfr.h	2015-07-17 08:58:21.114986979 +0000
-@@ -27,7 +27,7 @@
- #define MPFR_VERSION_MAJOR 3
- #define MPFR_VERSION_MINOR 1
- #define MPFR_VERSION_PATCHLEVEL 3
--#define MPFR_VERSION_STRING "3.1.3-p3"
-+#define MPFR_VERSION_STRING "3.1.3-p4"
- 
- /* Macros dealing with MPFR VERSION */
- #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
-diff -Naurd mpfr-3.1.3-a/src/version.c mpfr-3.1.3-b/src/version.c
---- mpfr-3.1.3-a/src/version.c	2015-07-17 08:54:48.616811495 +0000
-+++ mpfr-3.1.3-b/src/version.c	2015-07-17 08:58:21.118986898 +0000
-@@ -25,5 +25,5 @@
- const char *
- mpfr_get_version (void)
- {
--  return "3.1.3-p3";
-+  return "3.1.3-p4";
- }
-diff -Naurd mpfr-3.1.3-a/tests/tfrexp.c mpfr-3.1.3-b/tests/tfrexp.c
---- mpfr-3.1.3-a/tests/tfrexp.c	2015-06-19 19:55:10.000000000 +0000
-+++ mpfr-3.1.3-b/tests/tfrexp.c	2015-07-17 08:58:21.106987142 +0000
-@@ -129,12 +129,115 @@
-   mpfr_clear (x);
- }
- 
-+static void check1 (void)
-+{
-+  mpfr_exp_t emin, emax, e;
-+  mpfr_t x, y1, y2;
-+  int r, neg, red;
-+
-+  emin = mpfr_get_emin ();
-+  emax = mpfr_get_emax ();
-+  set_emin (MPFR_EMIN_MIN);
-+  set_emax (MPFR_EMAX_MAX);
-+
-+  mpfr_init2 (x, 7);
-+  mpfr_inits2 (4, y1, y2, (mpfr_ptr) 0);
-+
-+  mpfr_set_ui_2exp (x, 1, -2, MPFR_RNDN);
-+  while (mpfr_regular_p (x))
-+    {
-+      /* Test the exponents up to 3 and with the maximum exponent
-+         (to check potential intermediate overflow). */
-+      if (MPFR_GET_EXP (x) == 4)
-+        mpfr_set_exp (x, MPFR_EMAX_MAX);
-+      e = MPFR_GET_EXP (x);
-+      for (neg = 0; neg < 2; neg++)
-+        {
-+          RND_LOOP (r)
-+            {
-+              int inex1, inex2;
-+              mpfr_exp_t e1, e2;
-+              unsigned int flags1, flags2;
-+
-+              for (red = 0; red < 2; red++)
-+                {
-+                  if (red)
-+                    {
-+                      /* e1: exponent of the rounded value of x. */
-+                      MPFR_ASSERTN (e1 == e || e1 == e + 1);
-+                      set_emin (e);
-+                      set_emax (e);
-+                      mpfr_clear_flags ();
-+                      inex1 = e1 < 0 ?
-+                        mpfr_mul_2ui (y1, x, -e1, (mpfr_rnd_t) r) :
-+                        mpfr_div_2ui (y1, x, e1, (mpfr_rnd_t) r);
-+                      flags1 = __gmpfr_flags;
-+                    }
-+                  else
-+                    {
-+                      inex1 = mpfr_set (y1, x, (mpfr_rnd_t) r);
-+                      e1 = MPFR_IS_INF (y1) ? e + 1 : MPFR_GET_EXP (y1);
-+                      flags1 = inex1 != 0 ? MPFR_FLAGS_INEXACT : 0;
-+                    }
-+                  mpfr_clear_flags ();
-+                  inex2 = mpfr_frexp (&e2, y2, x, (mpfr_rnd_t) r);
-+                  flags2 = __gmpfr_flags;
-+                  set_emin (MPFR_EMIN_MIN);
-+                  set_emax (MPFR_EMAX_MAX);
-+                  if ((!red || e == 0) &&
-+                      (! mpfr_regular_p (y2) || MPFR_GET_EXP (y2) != 0))
-+                    {
-+                      printf ("Error in check1 for %s, red = %d, x = ",
-+                              mpfr_print_rnd_mode ((mpfr_rnd_t) r), red);
-+                      mpfr_dump (x);
-+                      printf ("Expected 1/2 <= |y| < 1, got y = ");
-+                      mpfr_dump (y2);
-+                      exit (1);
-+                    }
-+                  if (!red)
-+                    {
-+                      if (e2 > 0)
-+                        mpfr_mul_2ui (y2, y2, e2, MPFR_RNDN);
-+                      else if (e2 < 0)
-+                        mpfr_div_2ui (y2, y2, -e2, MPFR_RNDN);
-+                    }
-+                  if (! (SAME_SIGN (inex1, inex2) &&
-+                         mpfr_equal_p (y1, y2) &&
-+                         flags1 == flags2))
-+                    {
-+                      printf ("Error in check1 for %s, red = %d, x = ",
-+                              mpfr_print_rnd_mode ((mpfr_rnd_t) r), red);
-+                      mpfr_dump (x);
-+                      printf ("Expected y1 = ");
-+                      mpfr_dump (y1);
-+                      printf ("Got      y2 = ");
-+                      mpfr_dump (y2);
-+                      printf ("Expected inex ~= %d, got %d\n", inex1, inex2);
-+                      printf ("Expected flags:");
-+                      flags_out (flags1);
-+                      printf ("Got flags:     ");
-+                      flags_out (flags2);
-+                      exit (1);
-+                    }
-+                }
-+            }
-+          mpfr_neg (x, x, MPFR_RNDN);
-+        }
-+      mpfr_nextabove (x);
-+    }
-+
-+  mpfr_clears (x, y1, y2, (mpfr_ptr) 0);
-+  set_emin (emin);
-+  set_emax (emax);
-+}
-+
- int
- main (int argc, char *argv[])
- {
-   tests_start_mpfr ();
- 
-   check_special ();
-+  check1 ();
- 
-   tests_end_mpfr ();
-   return 0;
diff --git a/pkgs/development/libraries/mpich2/default.nix b/pkgs/development/libraries/mpich2/default.nix
index d400712a6f9b..4b8e2b651e45 100644
--- a/pkgs/development/libraries/mpich2/default.nix
+++ b/pkgs/development/libraries/mpich2/default.nix
@@ -1,19 +1,35 @@
-{ stdenv, fetchurl, python, perl, gfortran }:
+{ stdenv, fetchurl, python, perl, gfortran
+, slurm, openssh, hwloc
+} :
 
 stdenv.mkDerivation  rec {
   name = "mpich-${version}";
-  version = "3.2";
+  version = "3.2.1";
 
   src = fetchurl {
-    url = "http://www.mpich.org/static/downloads/3.2/mpich-3.2.tar.gz";
-    sha256 = "0bvvk4n9g4rmrncrgs9jnkcfh142i65wli5qp1akn9kwab1q80z6";
+    url = "http://www.mpich.org/static/downloads/${version}/mpich-${version}.tar.gz";
+    sha256 = "1w9h4g7d46d9l5jbcyfxpaqzpjrc5hyvr9d0ns7278psxpr3pdax";
   };
 
-  configureFlags = "--enable-shared --enable-sharedlib";
+  configureFlags = [
+    "--enable-shared"
+    "--enable-sharedlib"
+  ];
 
-  buildInputs = [ perl gfortran ];
+  buildInputs = [ perl gfortran slurm openssh hwloc ];
 
-  meta = {
+  doCheck = true;
+
+  preFixup = ''
+    # /tmp/nix-build... ends up in the RPATH, fix it manually
+    for entry in $out/bin/mpichversion $out/bin/mpivars; do
+      echo "fix rpath: $entry"
+      patchelf --set-rpath "$out/lib" $entry
+    done
+  '';
+
+
+  meta = with stdenv.lib; {
     description = "Implementation of the Message Passing Interface (MPI) standard";
 
     longDescription = ''
@@ -22,9 +38,11 @@ stdenv.mkDerivation  rec {
       version 2.
     '';
     homepage = http://www.mcs.anl.gov/mpi/mpich2/;
-    license = "free, see http://www.mcs.anl.gov/research/projects/mpich2/downloads/index.php?s=license";
-
-    maintainers = [ ];
-    platforms = stdenv.lib.platforms.unix;
+    license = {
+      url = http://git.mpich.org/mpich.git/blob/a385d6d0d55e83c3709ae851967ce613e892cd21:/COPYRIGHT;
+      fullName = "MPICH license (permissive)";
+    };
+    maintainers = [ maintainers.markuskowa ];
+    platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/mps/default.nix b/pkgs/development/libraries/mps/default.nix
index 4e4ddfb63899..aac9dc7f727a 100644
--- a/pkgs/development/libraries/mps/default.nix
+++ b/pkgs/development/libraries/mps/default.nix
@@ -5,16 +5,22 @@ stdenv.mkDerivation rec {
   version = "1.116.0";
 
   src = fetchurl {
-    url    = "http://www.ravenbrook.com/project/mps/release/${version}/mps-kit-${version}.tar.gz";
+    url    = "https://www.ravenbrook.com/project/mps/release/${version}/mps-kit-${version}.tar.gz";
     sha256 = "1k7vnanpgawnj84x2xs6md57pfib9p7c3acngqzkl3c2aqw8qay0";
   };
 
   nativeBuildInputs = [ autoreconfHook ];
   buildInputs = [ sqlite ];
 
+  # needed for 1.116.0 to build with gcc7
+  NIX_CFLAGS_COMPILE = [
+    "-Wno-implicit-fallthrough"
+  ];
+
+
   meta = {
     description = "A flexible memory management and garbage collection library";
-    homepage    = "http://www.ravenbrook.com/project/mps";
+    homepage    = "https://www.ravenbrook.com/project/mps";
     license     = stdenv.lib.licenses.sleepycat;
     platforms   = stdenv.lib.platforms.linux;
     maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
diff --git a/pkgs/development/libraries/msilbc/default.nix b/pkgs/development/libraries/msilbc/default.nix
index c7d65f156b8b..cfb02ddbf9dd 100644
--- a/pkgs/development/libraries/msilbc/default.nix
+++ b/pkgs/development/libraries/msilbc/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, ilbc, mediastreamer, pkgconfig }:
 
 stdenv.mkDerivation rec {
-  name = "msilbc-2.0.3";
+  name = "msilbc-2.1.2";
 
   src = fetchurl {
     url = "mirror://savannah/linphone/plugins/sources/${name}.tar.gz";
-    sha256 = "125yadpc0w1q84839dadin3ahs0gxxfas0zmc4c18mjmf58dmm7d";
+    sha256 = "07j02y994ybh274fp7ydjvi76h34y2c34ndwjpjfcwwr03b48cfp";
   };
 
   propagatedBuildInputs = [ ilbc mediastreamer ];
diff --git a/pkgs/development/libraries/mygui/default.nix b/pkgs/development/libraries/mygui/default.nix
index 715d2cb90f47..f4a869255f8c 100644
--- a/pkgs/development/libraries/mygui/default.nix
+++ b/pkgs/development/libraries/mygui/default.nix
@@ -1,5 +1,5 @@
 {  stdenv, fetchFromGitHub, libX11, unzip, cmake, ois, freetype, libuuid,
-   boost, pkgconfig, withOgre ? false, ogre ? null, mesa ? null } :
+   boost, pkgconfig, withOgre ? false, ogre ? null, libGLU_combined ? null } :
 
 let
   renderSystem = if withOgre then "3" else "4";
@@ -17,7 +17,7 @@ in stdenv.mkDerivation rec {
   enableParallelBuilding = true;
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ libX11 unzip cmake ois freetype libuuid boost (if withOgre then ogre else mesa) ];
+  buildInputs = [ libX11 unzip cmake ois freetype libuuid boost (if withOgre then ogre else libGLU_combined) ];
 
   # Tools are disabled due to compilation failures.
   cmakeFlags = [ "-DMYGUI_BUILD_TOOLS=OFF" "-DMYGUI_BUILD_DEMOS=OFF" "-DMYGUI_RENDERSYSTEM=${renderSystem}" ];
diff --git a/pkgs/development/libraries/mysocketw/default.nix b/pkgs/development/libraries/mysocketw/default.nix
index 379848b0cb08..6ec288f985b0 100644
--- a/pkgs/development/libraries/mysocketw/default.nix
+++ b/pkgs/development/libraries/mysocketw/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, openssl}:
+{ stdenv, fetchurl, openssl }:
 
 stdenv.mkDerivation rec {
   name = "mysocketw-031026";
@@ -9,11 +9,14 @@ stdenv.mkDerivation rec {
 
   patches = [ ./gcc.patch ];
 
-  configurePhase = ''
-    sed -i s,/usr/local,$out, Makefile.conf
+  buildInputs = [ openssl ];
+
+  postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
+    substituteInPlace src/Makefile \
+        --replace -Wl,-soname, -Wl,-install_name,$out/lib/
   '';
 
-  buildInputs = [ openssl ];
+  makeFlags = [ "PREFIX=$(out)" "CXX=c++" ];
 
   meta = {
     description = "Cross platform (Linux/FreeBSD/Unix/Win32) streaming socket C++";
diff --git a/pkgs/development/libraries/nanoflann/default.nix b/pkgs/development/libraries/nanoflann/default.nix
index 387632a890f0..b5d4ea0f4ebf 100644
--- a/pkgs/development/libraries/nanoflann/default.nix
+++ b/pkgs/development/libraries/nanoflann/default.nix
@@ -1,14 +1,14 @@
 {stdenv, fetchFromGitHub, cmake}:
 
 stdenv.mkDerivation rec {
-  version = "1.1.9";
+  version = "1.2.3";
   name = "nanoflann-${version}";
   
   src = fetchFromGitHub {
     owner = "jlblancoc";
     repo = "nanoflann";
     rev = "v${version}";
-    sha256 = "1q588cf2aark45bp4ciqjiz3dkdv8dcijkhm1ybzs8qjdzz9fimn";
+    sha256 = "1jrh73kjvdv7s7zc1sc3z254i17lpvn77b19wx32nvzsfxs4g44i";
   };
 
   buildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/nanomsg/default.nix b/pkgs/development/libraries/nanomsg/default.nix
index 6c0e633459bf..99c9c5f16001 100644
--- a/pkgs/development/libraries/nanomsg/default.nix
+++ b/pkgs/development/libraries/nanomsg/default.nix
@@ -1,14 +1,14 @@
 { stdenv, cmake, fetchFromGitHub }:
 
 stdenv.mkDerivation rec {
-  version = "1.0.0";
+  version = "1.1.2";
   name = "nanomsg-${version}";
 
   src = fetchFromGitHub {
     owner = "nanomsg";
     repo = "nanomsg";
     rev = version;
-    sha256 = "1iqlmvz5k8m4srb120g3kfkmm1w2p16hyxmx2asvihd21j285fmw";
+    sha256 = "1zvs91afsg61azfv5fldv84gnhf76w3yndkdvpvaprlacxbxdvf5";
   };
 
   buildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/ncurses/default.nix b/pkgs/development/libraries/ncurses/default.nix
index b8c7ff2f07d2..abb3020e5fba 100644
--- a/pkgs/development/libraries/ncurses/default.nix
+++ b/pkgs/development/libraries/ncurses/default.nix
@@ -3,6 +3,8 @@
 , abiVersion
 , mouseSupport ? false
 , unicode ? true
+, enableStatic ? stdenv.hostPlatform.useAndroidPrebuilt
+, withCxx ? !stdenv.hostPlatform.useAndroidPrebuilt
 
 , gpm
 
@@ -11,18 +13,15 @@
 }:
 
 stdenv.mkDerivation rec {
-  version = if abiVersion == "5" then "5.9" else "6.0-20170902";
-  name = "ncurses-${version}";
+  version = "6.1";
+  name = "ncurses-${version}" + lib.optionalString (abiVersion == "5") "-abi5-compat";
 
-  src = fetchurl (if abiVersion == "5" then {
-    url = "mirror://gnu/ncurses/${name}.tar.gz";
-    sha256 = "0fsn7xis81za62afan0vvm38bvgzg5wfmv1m86flqcj0nj7jjilh";
-  } else {
-    url = "ftp://ftp.invisible-island.net/ncurses/current/${name}.tgz";
-    sha256 = "1cks4gsz4148jw6wpqia4w5jx7cfxr29g2kmpvp0ssmvwczh8dr4";
-  });
+  src = fetchurl {
+    url = "mirror://gnu/ncurses/ncurses-${version}.tar.gz";
+    sha256 = "05qdmbmrrn88ii9f66rkcmcyzp1kb1ymkx7g040lfkd1nkp7w1da";
+  };
 
-  patches = [ ./clang.patch ] ++ lib.optional (abiVersion == "5" && stdenv.cc.isGNU) ./gcc-5.patch;
+  patches = lib.optional (!stdenv.cc.isClang) ./clang.patch;
 
   outputs = [ "out" "dev" "man" ];
   setOutputFlags = false; # some aren't supported
@@ -32,15 +31,19 @@ stdenv.mkDerivation rec {
     "--without-debug"
     "--enable-pc-files"
     "--enable-symlinks"
-  ] ++ lib.optional unicode "--enable-widec";
+  ] ++ lib.optional unicode "--enable-widec"
+    ++ lib.optional enableStatic "--enable-static"
+    ++ lib.optional (!withCxx) "--without-cxx"
+    ++ lib.optional (abiVersion == "5") "--with-abi-version=5";
 
   # Only the C compiler, and explicitly not C++ compiler needs this flag on solaris:
   CFLAGS = lib.optionalString stdenv.isSunOS "-D_XOPEN_SOURCE_EXTENDED";
 
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
   nativeBuildInputs = [
     pkgconfig
   ] ++ lib.optionals (buildPlatform != hostPlatform) [
-    buildPackages.ncurses buildPackages.stdenv.cc
+    buildPackages.ncurses
   ];
   buildInputs = lib.optional (mouseSupport && stdenv.isLinux) gpm;
 
@@ -118,6 +121,8 @@ stdenv.mkDerivation rec {
     moveToOutput "bin/tic" "$out"
     moveToOutput "bin/tput" "$out"
     moveToOutput "bin/tset" "$out"
+    moveToOutput "bin/captoinfo" "$out"
+    moveToOutput "bin/infotocap" "$out"
   '';
 
   preFixup = lib.optionalString (!hostPlatform.isCygwin) ''
diff --git a/pkgs/development/libraries/ncurses/gcc-5.patch b/pkgs/development/libraries/ncurses/gcc-5.patch
deleted file mode 100644
index 2448229b88e1..000000000000
--- a/pkgs/development/libraries/ncurses/gcc-5.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-https://bugs.gentoo.org/545114
-
-extracted from the upstream change (which had many unrelated commits in one)
-
-From 97bb4678dc03e753290b39bbff30ba2825df9517 Mon Sep 17 00:00:00 2001
-From: "Thomas E. Dickey" <dickey@invisible-island.net>
-Date: Sun, 7 Dec 2014 03:10:09 +0000
-Subject: [PATCH] ncurses 5.9 - patch 20141206
-
-+ modify MKlib_gen.sh to work around change in development version of
-  gcc introduced here:
-	  https://gcc.gnu.org/ml/gcc-patches/2014-06/msg02185.html
-	  https://gcc.gnu.org/ml/gcc-patches/2014-07/msg00236.html
-  (reports by Marcus Shawcroft, Maohui Lei).
-
-diff --git a/ncurses/base/MKlib_gen.sh b/ncurses/base/MKlib_gen.sh
-index d8cc3c9..b91398c 100755
---- a/ncurses/base/MKlib_gen.sh
-+++ b/ncurses/base/MKlib_gen.sh
-@@ -474,11 +474,22 @@ sed -n -f $ED1 \
- 	-e 's/gen_$//' \
- 	-e 's/  / /g' >>$TMP
- 
-+cat >$ED1 <<EOF
-+s/  / /g
-+s/^ //
-+s/ $//
-+s/P_NCURSES_BOOL/NCURSES_BOOL/g
-+EOF
-+
-+# A patch discussed here:
-+#	https://gcc.gnu.org/ml/gcc-patches/2014-06/msg02185.html
-+# introduces spurious #line markers.  Work around that by ignoring the system's
-+# attempt to define "bool" and using our own symbol here.
-+sed -e 's/bool/P_NCURSES_BOOL/g' $TMP > $ED2
-+cat $ED2 >$TMP
-+
- $preprocessor $TMP 2>/dev/null \
--| sed \
--	-e 's/  / /g' \
--	-e 's/^ //' \
--	-e 's/_Bool/NCURSES_BOOL/g' \
-+| sed -f $ED1 \
- | $AWK -f $AW2 \
- | sed -f $ED3 \
- | sed \
diff --git a/pkgs/development/libraries/ndn-cxx/default.nix b/pkgs/development/libraries/ndn-cxx/default.nix
index ee7d4765fb22..1040cb9a9343 100644
--- a/pkgs/development/libraries/ndn-cxx/default.nix
+++ b/pkgs/development/libraries/ndn-cxx/default.nix
@@ -45,5 +45,6 @@ stdenv.mkDerivation {
     license = licenses.lgpl3;
     platforms = stdenv.lib.platforms.unix;
     maintainers = [ maintainers.sjmackenzie ];
+    broken = true; # 2018-04-11
   };
 }
diff --git a/pkgs/development/libraries/ndpi/default.nix b/pkgs/development/libraries/ndpi/default.nix
index f1232d7d253a..c84cddc897c1 100644
--- a/pkgs/development/libraries/ndpi/default.nix
+++ b/pkgs/development/libraries/ndpi/default.nix
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
     longDescription = ''
       nDPI is a library for deep-packet inspection based on OpenDPI.
     '';
-    homepage = http://www.ntop.org/products/deep-packet-inspection/ndpi/;
+    homepage = https://www.ntop.org/products/deep-packet-inspection/ndpi/;
     license = with licenses; lgpl3;
     maintainers = with maintainers; [ takikawa ];
     platforms = with platforms; unix;
diff --git a/pkgs/development/libraries/netcdf-cxx4/default.nix b/pkgs/development/libraries/netcdf-cxx4/default.nix
index de9023a57106..a57884912bae 100644
--- a/pkgs/development/libraries/netcdf-cxx4/default.nix
+++ b/pkgs/development/libraries/netcdf-cxx4/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, netcdf, hdf5, curl }:
 stdenv.mkDerivation rec {
   name = "netcdf-cxx4-${version}";
-  version = "4.2.1";
+  version = "4.3.0";
 
   src = fetchurl {
     url = "https://github.com/Unidata/netcdf-cxx4/archive/v${version}.tar.gz";
-    sha256 = "1g0fsmz59dnjib4a7r899lm99j3z6yxsw10c0wlihclzr6znmmds";
+    sha256 = "13zi8cbk18gggx1c12a580wdsbl714lw68a1wg7c86x0sybirni5";
   };
 
   buildInputs = [ netcdf hdf5 curl ];
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
 
   meta = {
     description = "C++ API to manipulate netcdf files";
-    homepage = http://www.unidata.ucar.edu/software/netcdf/;
+    homepage = https://www.unidata.ucar.edu/software/netcdf/;
     license = stdenv.lib.licenses.free;
     platforms = stdenv.lib.platforms.unix;
   };
diff --git a/pkgs/development/libraries/netcdf-fortran/default.nix b/pkgs/development/libraries/netcdf-fortran/default.nix
index 35f675a305af..8af2a7aa3682 100644
--- a/pkgs/development/libraries/netcdf-fortran/default.nix
+++ b/pkgs/development/libraries/netcdf-fortran/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, netcdf, hdf5, curl, gfortran }:
 stdenv.mkDerivation rec {
   name = "netcdf-fortran-${version}";
-  version = "4.4.3";
+  version = "4.4.4";
 
   src = fetchurl {
     url = "https://github.com/Unidata/netcdf-fortran/archive/v${version}.tar.gz";
-    sha256 = "4170fc018c9ee8222e317215c6a273542623185f5f6ee00d37bbb4e024e4e998";
+    sha256 = "0rwybszj1jjb25cx8vfyrd77x5qsdjzwspcjz56n12br89n9ica4";
   };
 
   buildInputs = [ netcdf hdf5 curl gfortran ];
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "Fortran API to manipulate netcdf files";
-    homepage = http://www.unidata.ucar.edu/software/netcdf/;
+    homepage = https://www.unidata.ucar.edu/software/netcdf/;
     license = licenses.free;
     maintainers = [ maintainers.bzizou ];
     platforms = platforms.unix;
diff --git a/pkgs/development/libraries/netcdf/default.nix b/pkgs/development/libraries/netcdf/default.nix
index e7c64b9a76d0..8446a91cceca 100644
--- a/pkgs/development/libraries/netcdf/default.nix
+++ b/pkgs/development/libraries/netcdf/default.nix
@@ -9,27 +9,30 @@ let
   mpiSupport = hdf5.mpiSupport;
   mpi = hdf5.mpi;
 in stdenv.mkDerivation rec {
-    name = "netcdf-4.4.1.1";
-    src = fetchurl {
-        url = "http://www.unidata.ucar.edu/downloads/netcdf/ftp/${name}.tar.gz";
-        sha256 = "1blc7ik5yin7i0ls2kag0a9xjk12m0dzx6v1x88az3ras3scci2d";
-    };
+  name = "netcdf-4.6.1";
 
-    buildInputs = [ hdf5 m4 curl mpi];
+  src = fetchurl {
+    url = "https://www.unidata.ucar.edu/downloads/netcdf/ftp/${name}.tar.gz";
+    sha256 = "0hi61cdihwwvz5jz1l7yq712j7ca1cj4bhr8x0x7c2vlb1s9biw9";
+  };
 
-    passthru = {
-      mpiSupport = mpiSupport;
-      inherit mpi;
-    };
+  nativeBuildInputs = [ m4 ];
+  buildInputs = [ hdf5 curl mpi ];
 
-    configureFlags = [
-        "--enable-netcdf-4"
-        "--enable-dap"
-        "--enable-shared"
-    ]
-    ++ (stdenv.lib.optionals mpiSupport [ "--enable-parallel-tests" "CC=${mpi}/bin/mpicc" ]);
+  passthru = {
+    mpiSupport = mpiSupport;
+    inherit mpi;
+  };
 
-    meta = {
-        platforms = stdenv.lib.platforms.unix;
-    };
+  configureFlags = [
+      "--enable-netcdf-4"
+      "--enable-dap"
+      "--enable-shared"
+  ]
+  ++ (stdenv.lib.optionals mpiSupport [ "--enable-parallel-tests" "CC=${mpi}/bin/mpicc" ]);
+
+  meta = {
+      platforms = stdenv.lib.platforms.unix;
+      homepage = https://www.unidata.ucar.edu/software/netcdf/;
+  };
 }
diff --git a/pkgs/development/libraries/nettle/default.nix b/pkgs/development/libraries/nettle/default.nix
index 3923daad6f4b..5b998926f0a5 100644
--- a/pkgs/development/libraries/nettle/default.nix
+++ b/pkgs/development/libraries/nettle/default.nix
@@ -1,10 +1,10 @@
 { callPackage, fetchurl, ... } @ args:
 
 callPackage ./generic.nix (args // rec {
-  version = "3.3";
+  version = "3.4";
 
   src = fetchurl {
     url = "mirror://gnu/nettle/nettle-${version}.tar.gz";
-    sha256 = "07mif3af077763vc35s1x8vzhzlgqcgxh67c1xr13jnhslkjd526";
+    sha256 = "150y8655h629wn946dvzasq16qxsc1m9nf58mifvhl350bgl4ymf";
   };
 })
diff --git a/pkgs/development/libraries/nettle/generic.nix b/pkgs/development/libraries/nettle/generic.nix
index 9633dacd68f2..3af93469cf16 100644
--- a/pkgs/development/libraries/nettle/generic.nix
+++ b/pkgs/development/libraries/nettle/generic.nix
@@ -1,4 +1,4 @@
-{ stdenv, gmp, gnum4
+{ stdenv, buildPackages, gmp, gnum4
 
 # Version specific args
 , version, src
@@ -12,7 +12,8 @@ stdenv.mkDerivation (rec {
   outputs = [ "out" "dev" ];
   outputBin = "dev";
 
-  buildInputs = [ gnum4 ];
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
+  nativeBuildInputs = [ gnum4 ];
   propagatedBuildInputs = [ gmp ];
 
   doCheck = (stdenv.system != "i686-cygwin" && !stdenv.isDarwin);
diff --git a/pkgs/development/libraries/newt/default.nix b/pkgs/development/libraries/newt/default.nix
index e00decca2ffd..cd1e51bd19c1 100644
--- a/pkgs/development/libraries/newt/default.nix
+++ b/pkgs/development/libraries/newt/default.nix
@@ -1,11 +1,11 @@
 { fetchurl, stdenv, slang, popt }:
 
 stdenv.mkDerivation rec {
-  name = "newt-0.52.15";
+  name = "newt-0.52.20";
 
   src = fetchurl {
     url = "https://fedorahosted.org/releases/n/e/newt/${name}.tar.gz";
-    sha256 = "0hg2l0siriq6qrz6mmzr6l7rpl40ay56c8cak87rb2ks7s952qbs";
+    sha256 = "1g3dpfnvaw7vljbr7nzq1rl88d6r8cmrvvng9inphgzwxxmvlrld";
   };
 
   patchPhase = ''
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
   '';
 
   crossAttrs = {
-    makeFlags = "CROSS_COMPILE=${stdenv.cc.prefix}";
+    makeFlags = "CROSS_COMPILE=${stdenv.cc.targetPrefix}";
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/nix-plugins/default.nix b/pkgs/development/libraries/nix-plugins/default.nix
index 2dcc7e9a53dd..c4a30f52b050 100644
--- a/pkgs/development/libraries/nix-plugins/default.nix
+++ b/pkgs/development/libraries/nix-plugins/default.nix
@@ -1,5 +1,5 @@
-{ stdenv, fetchFromGitHub, nix, boehmgc }:
-let version = "2.0.7"; in
+{ stdenv, fetchFromGitHub, nix, cmake, pkgconfig, boost }:
+let version = "4.0.4"; in
 stdenv.mkDerivation {
   name = "nix-plugins-${version}";
 
@@ -7,12 +7,12 @@ stdenv.mkDerivation {
     owner = "shlevy";
     repo = "nix-plugins";
     rev = version;
-    sha256 = "1q4ydp2w114wbfm41m4qgrabha7ifa17xyz5dr137vvnj6njp4vs";
+    sha256 = "02lz62n55pvqin4x44qlxb5knrapyckmj9k8ggk4qxgb36368ifn";
   };
 
-  buildFlags = [ "NIX_INCLUDE=${nix.dev}/include" "GC_INCLUDE=${boehmgc.dev}/include" ];
+  nativeBuildInputs = [ cmake pkgconfig ];
 
-  installFlags = [ "PREFIX=$(out)" ];
+  buildInputs = [ nix boost ];
 
   meta = {
     description = "Collection of miscellaneous plugins for the nix expression language";
diff --git a/pkgs/development/libraries/nlohmann_json/default.nix b/pkgs/development/libraries/nlohmann_json/default.nix
index 9fb614cd071a..59cc9438a9f1 100644
--- a/pkgs/development/libraries/nlohmann_json/default.nix
+++ b/pkgs/development/libraries/nlohmann_json/default.nix
@@ -4,13 +4,13 @@
 
 stdenv.mkDerivation rec {
   name = "nlohmann_json-${version}";
-  version = "2.1.0";
+  version = "3.1.2";
 
   src = fetchFromGitHub {
     owner = "nlohmann";
     repo = "json";
     rev = "v${version}";
-    sha256 = "116309lx77m31x4krln0g7mra900g0knk9lbkxbpxnmamkagjyl9";
+    sha256 = "1mpr781fb2dfbyscrr7nil75lkxsazg4wkm749168lcf2ksrrbfi";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/npth/default.nix b/pkgs/development/libraries/npth/default.nix
index 8ebf62cfdf0e..a600938cdbb2 100644
--- a/pkgs/development/libraries/npth/default.nix
+++ b/pkgs/development/libraries/npth/default.nix
@@ -1,13 +1,15 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "npth-1.3";
+  name = "npth-1.5";
 
   src = fetchurl {
     url = "ftp://ftp.gnupg.org/gcrypt/npth/${name}.tar.bz2";
-    sha256 = "0am86vblapwz84254qpmhz0chk70g6qzh3wdxcs0gvba8d01ka5w";
+    sha256 = "1hmkkp6vzyrh8v01c2ynzf9vwikyagp7p1lxhbnr4ysk3w66jji9";
   };
 
+  doCheck = true;
+
   meta = with stdenv.lib; {
     description = "The New GNU Portable Threads Library";
     longDescription = ''
diff --git a/pkgs/development/libraries/nspr/default.nix b/pkgs/development/libraries/nspr/default.nix
index 8f7bebf649c9..17805f32afb1 100644
--- a/pkgs/development/libraries/nspr/default.nix
+++ b/pkgs/development/libraries/nspr/default.nix
@@ -1,14 +1,14 @@
 { stdenv, fetchurl
 , CoreServices ? null }:
 
-let version = "4.16"; in
+let version = "4.18"; in
 
 stdenv.mkDerivation {
   name = "nspr-${version}";
 
   src = fetchurl {
     url = "mirror://mozilla/nspr/releases/v${version}/src/nspr-${version}.tar.gz";
-    sha256 = "1l9wlnb9y0bzicv448jjl9kssqn044dc2qrkwzp4ll35fvch4ccv";
+    sha256 = "0d7vr3wrgp73qbywrvdkikk8vq1s1n9vhf62db80g1zqkg05g5mq";
   };
 
   outputs = [ "out" "dev" ];
@@ -16,6 +16,9 @@ stdenv.mkDerivation {
 
   preConfigure = ''
     cd nspr
+  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+    substituteInPlace configure --replace '@executable_path/' "$out/lib/"
+    substituteInPlace configure.in --replace '@executable_path/' "$out/lib/"
   '';
 
   configureFlags = [
diff --git a/pkgs/development/libraries/nss/85_security_load.patch b/pkgs/development/libraries/nss/85_security_load.patch
index 7687ea9bedb0..132d5a96b29f 100644
--- a/pkgs/development/libraries/nss/85_security_load.patch
+++ b/pkgs/development/libraries/nss/85_security_load.patch
@@ -13,10 +13,10 @@ diff -ru -x '*~' -x '*.orig' -x '*.rej' nss/cmd/shlibsign/shlibsign.c nss/cmd/sh
 diff -ru -x '*~' -x '*.orig' -x '*.rej' nss/coreconf/config.mk nss/coreconf/config.mk
 --- nss/coreconf/config.mk	2017-01-04 15:24:24.000000000 +0100
 +++ nss/coreconf/config.mk	2017-01-24 14:43:47.989432372 +0100
-@@ -208,3 +208,6 @@
- # exported symbols, which causes problem when NSS is built as part of Mozilla.
- # So we add a NSS_SSL_ENABLE_ZLIB variable to allow Mozilla to turn this off.
- NSS_SSL_ENABLE_ZLIB = 1
+@@ -202,3 +202,6 @@
+ 
+ # Hide old, deprecated, TLS cipher suite names when building NSS
+ DEFINES += -DSSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES
 +
 +# Nix specific stuff.
 +DEFINES += -DNIX_NSS_LIBDIR=\"$(out)/lib/\"
diff --git a/pkgs/development/libraries/nss/ckpem.patch b/pkgs/development/libraries/nss/ckpem.patch
new file mode 100644
index 000000000000..c1a65a6c0b28
--- /dev/null
+++ b/pkgs/development/libraries/nss/ckpem.patch
@@ -0,0 +1,11 @@
+--- nss/lib/ckfw/pem/ckpem.h	2018-01-03 13:36:12.000000000 -0800
++++ nss/lib/ckfw/pem/ckpem.h	2018-01-03 13:36:20.000000000 -0800
+@@ -156,8 +156,6 @@
+ NSS_EXTERN_DATA pemInternalObject nss_pem_data[];
+ NSS_EXTERN_DATA const PRUint32               nss_pem_nObjects;
+ 
+-  PRBool          logged_in;
+-
+ /* our raw object data array */
+ NSS_EXTERN_DATA pemInternalObject nss_pem_data[];
+ NSS_EXTERN_DATA const PRUint32               nss_pem_nObjects;
diff --git a/pkgs/development/libraries/nss/default.nix b/pkgs/development/libraries/nss/default.nix
index 5f0918d6451e..8662b956ce22 100644
--- a/pkgs/development/libraries/nss/default.nix
+++ b/pkgs/development/libraries/nss/default.nix
@@ -1,7 +1,13 @@
-{ stdenv, fetchurl, nspr, perl, zlib, sqlite }:
+{ stdenv, fetchurl, nspr, perl, zlib, sqlite, fixDarwinDylibNames }:
 
 let
 
+  # Fix aarch64 build, shouldn't be needed after 3.35
+  aarch64Patch = fetchurl {
+    url = https://hg.mozilla.org/projects/nss/raw-rev/74e679158d1b;
+    sha256 = "1lhs4h32mb2al3z461yylk227nid769di1pdjr7p0kqm2z1qm3jq";
+  };
+
   nssPEM = fetchurl {
     url = http://dev.gentoo.org/~polynomial-c/mozilla/nss-3.15.4-pem-support-20140109.patch.xz;
     sha256 = "10ibz6y0hknac15zr6dw4gv9nb5r5z9ym6gq18j3xqx7v7n3vpdw";
@@ -9,29 +15,37 @@ let
 
 in stdenv.mkDerivation rec {
   name = "nss-${version}";
-  version = "3.32.1";
+  version = "3.35";
 
   src = fetchurl {
-    url = "mirror://mozilla/security/nss/releases/NSS_3_32_1_RTM/src/${name}.tar.gz";
-    sha256 = "0lj6c94102aa81bnjisnix09zfjly9aa1d6vrzxmcjmzynkrrrad";
+    url = "mirror://mozilla/security/nss/releases/NSS_3_35_RTM/src/${name}.tar.gz";
+    sha256 = "1ypn68z9ncbbshi3184ywrhx5i846lyd72gps1grzqzdkgh7s4pl";
   };
 
-  buildInputs = [ perl zlib sqlite ];
+  buildInputs = [ perl zlib sqlite ]
+    ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
   propagatedBuildInputs = [ nspr ];
 
   prePatch = ''
     xz -d < ${nssPEM} | patch -p1
+  '' + stdenv.lib.optionalString stdenv.isAarch64 ''
+      (cd nss && patch -p1 < ${aarch64Patch})
   '';
 
   patches =
     [
       # Based on http://patch-tracker.debian.org/patch/series/dl/nss/2:3.15.4-1/85_security_load.patch
       ./85_security_load.patch
+      ./ckpem.patch
     ];
 
   patchFlags = "-p0";
 
+  postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
+    substituteInPlace nss/coreconf/Darwin.mk --replace '@executable_path/$(notdir $@)' "$out/lib/\$(notdir \$@)"
+  '';
+
   outputs = [ "out" "dev" "tools" ];
 
   preConfigure = "cd nss";
@@ -45,7 +59,8 @@ in stdenv.mkDerivation rec {
     "NSS_ENABLE_ECC=1"
     "USE_SYSTEM_ZLIB=1"
     "NSS_USE_SYSTEM_SQLITE=1"
-  ] ++ stdenv.lib.optional stdenv.is64bit "USE_64=1";
+  ] ++ stdenv.lib.optional stdenv.is64bit "USE_64=1"
+    ++ stdenv.lib.optional stdenv.isDarwin "CCC=clang++";
 
   NIX_CFLAGS_COMPILE = "-Wno-error";
 
@@ -84,15 +99,22 @@ in stdenv.mkDerivation rec {
 
   postFixup = ''
     for libname in freebl3 nssdbm3 softokn3
-    do
-      libfile="$out/lib/lib$libname.so"
-      LD_LIBRARY_PATH=$out/lib $out/bin/shlibsign -v -i "$libfile"
+    do '' +
+    (if stdenv.isDarwin
+     then ''
+       libfile="$out/lib/lib$libname.dylib"
+       DYLD_LIBRARY_PATH=$out/lib:${nspr.out}/lib \
+     '' else ''
+       libfile="$out/lib/lib$libname.so"
+       LD_LIBRARY_PATH=$out/lib:${nspr.out}/lib \
+     '') + ''
+        $out/bin/shlibsign -v -i "$libfile"
     done
 
     moveToOutput bin "$tools"
     moveToOutput bin/nss-config "$dev"
     moveToOutput lib/libcrmf.a "$dev" # needed by firefox, for example
-    rm "$out"/lib/*.a
+    rm -f "$out"/lib/*.a
   '';
 
   meta = {
diff --git a/pkgs/development/libraries/nss_wrapper/default.nix b/pkgs/development/libraries/nss_wrapper/default.nix
index 9051d96eff79..969e7534eac4 100644
--- a/pkgs/development/libraries/nss_wrapper/default.nix
+++ b/pkgs/development/libraries/nss_wrapper/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, cmake, pkgconfig }:
 
 stdenv.mkDerivation rec {
-  name = "nss_wrapper-1.0.3";
+  name = "nss_wrapper-1.1.3";
 
   src = fetchurl {
     url = "mirror://samba/cwrap/${name}.tar.gz";
-    sha256 = "0bysdijvi9n0jk74iklbfhbp0kvv81a727lcfd5q03q2hkzjfm18";
+    sha256 = "18rsaw8r8xwn5003arc7xw8iliwbmzxfxgacmp6lhsdwqla4rf69";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/ntbtls/default.nix b/pkgs/development/libraries/ntbtls/default.nix
index b095c0366adc..dac65e1c2f9a 100644
--- a/pkgs/development/libraries/ntbtls/default.nix
+++ b/pkgs/development/libraries/ntbtls/default.nix
@@ -1,19 +1,20 @@
-{ stdenv, fetchurl, libgpgerror, libgcrypt, libksba, zlib }:
+{ stdenv, fetchurl, gettext, libgpgerror, libgcrypt, libksba, zlib }:
 
 with stdenv.lib;
 
 stdenv.mkDerivation rec {
   name = "ntbtls-${version}";
-  version = "0.1.1";
+  version = "0.1.2";
 
   src = fetchurl {
     url = "mirror://gnupg/ntbtls/ntbtls-${version}.tar.bz2";
-    sha256 = "0d322kgih43vr0gvy7kdj4baql1d6fa71vgpv0z63ira9pk4q9rd";
+    sha256 = "1rywgdyj7prmwdi5r1rpglakqpnjskgln1mqksqm28qcwn2dnh42";
   };
 
   outputs = [ "dev" "out" ];
 
-  buildInputs = [ libgcrypt libgpgerror libksba zlib ];
+  buildInputs = [ libgcrypt libgpgerror libksba zlib ]
+    ++ stdenv.lib.optional stdenv.isDarwin gettext;
 
   postInstall = ''
     moveToOutput "bin/ntbtls-config" $dev
@@ -21,7 +22,7 @@ stdenv.mkDerivation rec {
 
   meta = {
     description = "A tiny TLS 1.2 only implementation";
-    homepage = https://www.gnupg.org/software/ntbtls/index.html;
+    homepage = "https://www.gnupg.org/software/ntbtls/";
     license = licenses.gpl3Plus;
     platforms = platforms.unix;
     maintainers = with maintainers; [ joachifm ];
diff --git a/pkgs/development/libraries/ocl-icd/default.nix b/pkgs/development/libraries/ocl-icd/default.nix
index 6c3a77cfaf5e..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, mesa_noglu }:
+{stdenv, fetchurl, ruby, opencl-headers, libGL_driver }:
 
 stdenv.mkDerivation rec {
   name = "ocl-icd-${version}";
@@ -9,14 +9,16 @@ stdenv.mkDerivation rec {
     sha256 = "0f14gpa13sdm0kzqv5yycp4pschbmi6n5fj7wl4ilspzsrqcgqr2";
   };
 
-  buildInputs = [ ruby opencl-headers ];
+  nativeBuildInputs = [ ruby ];
+
+  buildInputs = [ opencl-headers ];
 
   postPatch = ''
-    sed -i 's,"/etc/OpenCL/vendors","${mesa_noglu.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; {
-    description = "OpenCL ICD Loader";
+    description = "OpenCL ICD Loader for ${opencl-headers.name}";
     homepage    = https://forge.imag.fr/projects/ocl-icd/;
     license     = licenses.bsd2;
     platforms = platforms.linux;
diff --git a/pkgs/development/libraries/ogre/1.9.x.nix b/pkgs/development/libraries/ogre/1.9.x.nix
new file mode 100644
index 000000000000..0f6495f0c9c1
--- /dev/null
+++ b/pkgs/development/libraries/ogre/1.9.x.nix
@@ -0,0 +1,46 @@
+{ fetchFromGitHub, stdenv, lib
+, cmake, libGLU_combined
+, freetype, freeimage, zziplib, randrproto, libXrandr
+, libXaw, freeglut, libXt, libpng, boost, ois
+, xproto, libX11, libXmu, libSM, pkgconfig
+, libXxf86vm, xf86vidmodeproto, libICE
+, renderproto, libXrender
+, withNvidiaCg ? false, nvidia_cg_toolkit
+, withSamples ? false }:
+
+stdenv.mkDerivation rec {
+  pname = "ogre";
+  version = "1.9.1";
+  name = "${pname}-${version}";
+
+  src = fetchFromGitHub {
+    owner = "OGRECave";
+    repo = "ogre";
+    rev = "v${version}";
+    sha256 = "11lfgzqaps3728dswrq3cbwk7aicigyz08q4hfyy6ikc6m35r4wg";
+  };
+
+  cmakeFlags = [ "-DOGRE_BUILD_SAMPLES=${toString withSamples}" ]
+    ++ map (x: "-DOGRE_BUILD_PLUGIN_${x}=on")
+           ([ "BSP" "OCTREE" "PCZ" "PFX" ] ++ lib.optional withNvidiaCg "CG")
+    ++ map (x: "-DOGRE_BUILD_RENDERSYSTEM_${x}=on") [ "GL" ];
+
+  enableParallelBuilding = true;
+
+  buildInputs =
+   [ cmake libGLU_combined
+     freetype freeimage zziplib randrproto libXrandr
+     libXaw freeglut libXt libpng boost ois
+     xproto libX11 libXmu libSM pkgconfig
+     libXxf86vm xf86vidmodeproto libICE
+     renderproto libXrender
+   ] ++ lib.optional withNvidiaCg nvidia_cg_toolkit;
+
+  meta = {
+    description = "A 3D engine";
+    homepage = https://www.ogre3d.org/;
+    maintainers = [ stdenv.lib.maintainers.raskin ];
+    platforms = stdenv.lib.platforms.linux;
+    license = stdenv.lib.licenses.mit;
+  };
+}
diff --git a/pkgs/development/libraries/ogre/default.nix b/pkgs/development/libraries/ogre/default.nix
index aba02827665b..0b7202459f9e 100644
--- a/pkgs/development/libraries/ogre/default.nix
+++ b/pkgs/development/libraries/ogre/default.nix
@@ -1,5 +1,5 @@
 { fetchurl, stdenv, lib
-, cmake, mesa
+, cmake, libGLU_combined
 , freetype, freeimage, zziplib, randrproto, libXrandr
 , libXaw, freeglut, libXt, libpng, boost, ois
 , xproto, libX11, libXmu, libSM, pkgconfig
@@ -9,11 +9,11 @@
 , withSamples ? false }:
 
 stdenv.mkDerivation {
-  name = "ogre-1.9-hg-20160322";
+  name = "ogre-1.10.11";
 
   src = fetchurl {
-     url = "https://bitbucket.org/sinbad/ogre/get/v1-9.tar.gz";
-     sha256 = "0w3argjy1biaxwa3c80zxxgll67wjp8czd83p87awlcvwzdk5mz9";
+     url = "https://bitbucket.org/sinbad/ogre/get/v1-10-11.tar.gz";
+     sha256 = "1zwvlx5dz9nwjazhnrhzb0w8ilpa84r0hrxrmmy69pgr1p1yif5a";
   };
 
   cmakeFlags = [ "-DOGRE_BUILD_SAMPLES=${toString withSamples}" ]
@@ -24,7 +24,7 @@ stdenv.mkDerivation {
   enableParallelBuilding = true;
 
   buildInputs =
-   [ cmake mesa
+   [ cmake libGLU_combined
      freetype freeimage zziplib randrproto libXrandr
      libXaw freeglut libXt libpng boost ois
      xproto libX11 libXmu libSM pkgconfig
@@ -34,7 +34,7 @@ stdenv.mkDerivation {
 
   meta = {
     description = "A 3D engine";
-    homepage = http://www.ogre3d.org/;
+    homepage = https://www.ogre3d.org/;
     maintainers = [ stdenv.lib.maintainers.raskin ];
     platforms = stdenv.lib.platforms.linux;
     license = stdenv.lib.licenses.mit;
diff --git a/pkgs/development/libraries/ogrepaged/default.nix b/pkgs/development/libraries/ogrepaged/default.nix
index 2408c3e49041..e4045bcd5dc4 100644
--- a/pkgs/development/libraries/ogrepaged/default.nix
+++ b/pkgs/development/libraries/ogrepaged/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cmake, pkgconfig, ois, ogre, libX11, boost }:
+{ stdenv, fetchurl, fetchpatch, cmake, pkgconfig, ois, ogre, libX11, boost }:
 
 stdenv.mkDerivation rec {
   name = "ogre-paged-${version}";
@@ -9,6 +9,23 @@ stdenv.mkDerivation rec {
     sha256 = "17j7rw9wbkynxbhm2lay3qgjnnagb2vd5jn9iijnn2lf8qzbgy82";
   };
 
+  patches = [
+    # These patches come from https://github.com/RigsOfRods/ogre-pagedgeometry/pull/6
+    # and make ogre-paged build with ogre-1.10.
+    (fetchpatch {
+      url = "https://github.com/RigsOfRods/ogre-pagedgeometry/commit/2d4df577decba37ec3cdafc965deae0f6d31fe45.patch";
+      sha256 = "0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73";
+    })
+    (fetchpatch {
+      url = "https://github.com/RigsOfRods/ogre-pagedgeometry/commit/4d81789ec6f55e294a5ad040ea7abe2b415cbc92.patch";
+      sha256 = "17q8djdz2y3g46azxc3idhyvi6vf0sqkxld4bbyp3l9zn7dq76rp";
+    })
+    (fetchpatch {
+      url = "https://github.com/RigsOfRods/ogre-pagedgeometry/commit/10f7c5ce5b422e9cbac59d466f3567a24c8831a4.patch";
+      sha256 = "1kk0dbadzg73ai99l3w04q51sil36vzbkaqc79mdwy0vjrn4ardb";
+    })
+  ];
+
   buildInputs = [ ois ogre libX11 boost ];
   nativeBuildInputs = [ cmake pkgconfig ];
 
diff --git a/pkgs/development/libraries/oniguruma/default.nix b/pkgs/development/libraries/oniguruma/default.nix
index b82f137ec6d7..3989ab42468d 100644
--- a/pkgs/development/libraries/oniguruma/default.nix
+++ b/pkgs/development/libraries/oniguruma/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "onig-${version}";
-  version = "6.6.1";
+  version = "6.8.2";
 
   src = fetchFromGitHub {
     owner = "kkos";
     repo = "oniguruma";
     rev = "v${version}";
-    sha256 = "062g5443dyxsraq346panfqvbd6wal6nmb336n4dw1rszx576sxz";
+    sha256 = "00ly5i26n7wajhyhq3xadsc7dxrf7qllhwilk8dza2qj5dhld4nd";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/openal-soft/default.nix b/pkgs/development/libraries/openal-soft/default.nix
index 87e5e44b7dae..8d1a2876a375 100644
--- a/pkgs/development/libraries/openal-soft/default.nix
+++ b/pkgs/development/libraries/openal-soft/default.nix
@@ -10,12 +10,12 @@ assert alsaSupport -> alsaLib != null;
 assert pulseSupport -> libpulseaudio != null;
 
 stdenv.mkDerivation rec {
-  version = "1.17.2";
+  version = "1.18.2";
   name = "openal-soft-${version}";
 
   src = fetchurl {
     url = "http://kcat.strangesoft.net/openal-releases/${name}.tar.bz2";
-    sha256 = "051k5fy8pk4fd9ha3qaqcv08xwbks09xl5qs4ijqq2qz5xaghhd3";
+    sha256 = "10kydm8701a2kppiss9sdidn1820cmzhqgx1b2bsa5dsgzic32lz";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/openbsm/default.nix b/pkgs/development/libraries/openbsm/default.nix
new file mode 100644
index 000000000000..a6e62cea9d7e
--- /dev/null
+++ b/pkgs/development/libraries/openbsm/default.nix
@@ -0,0 +1,20 @@
+{ stdenv, fetchFromGitHub, lib }:
+
+stdenv.mkDerivation rec {
+  pname = "openbsm";
+  name = "${pname}-${version}";
+  version = "1.1";
+
+  src = fetchFromGitHub {
+    owner = pname;
+    repo = pname;
+    rev = "${lib.toUpper (builtins.replaceStrings ["." "-"] ["_" "_"] name)}";
+    sha256 = "0b98359hd8mm585sh145ss828pg2y8vgz38lqrb7nypapiyqdnd1";
+  };
+
+  meta = {
+    homepage = http://www.openbsm.org/;
+    platforms = lib.platforms.unix;
+    maintainers = with lib.maintainers; [ matthewbauer ];
+  };
+}
diff --git a/pkgs/development/libraries/opencascade/default.nix b/pkgs/development/libraries/opencascade/default.nix
index 58f9019d6e03..6af15d90cefd 100644
--- a/pkgs/development/libraries/opencascade/default.nix
+++ b/pkgs/development/libraries/opencascade/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, mesa, tcl, tk, file, libXmu, cmake, libtool, qt4,
+{stdenv, fetchurl, libGLU_combined, tcl, tk, file, libXmu, cmake, libtool, qt4,
 ftgl, freetype}:
 
 stdenv.mkDerivation rec {
@@ -8,7 +8,13 @@ stdenv.mkDerivation rec {
     sha256 = "0vpmnb0k5y2f7lpmwx9pg9yfq24zjvnsak5alzacncfm1hv9b6cd";
   };
 
-  buildInputs = [ mesa tcl tk file libXmu libtool qt4 ftgl freetype cmake ];
+  buildInputs = [ libGLU_combined tcl tk file libXmu libtool qt4 ftgl freetype cmake ];
+
+  # Fix for glibc 2.26
+  postPatch = ''
+    sed -i -e 's/^\( *#include <\)x\(locale.h>\)//' \
+      src/Standard/Standard_CLocaleSentry.hxx
+  '';
 
   preConfigure = ''
     cmakeFlags="$cmakeFlags -DOCE_INSTALL_PREFIX=$out"
diff --git a/pkgs/development/libraries/opencl-headers/default.nix b/pkgs/development/libraries/opencl-headers/default.nix
index 717bb5ad0eed..9ce8bb618bf9 100644
--- a/pkgs/development/libraries/opencl-headers/default.nix
+++ b/pkgs/development/libraries/opencl-headers/default.nix
@@ -1,22 +1,24 @@
-{ stdenv, fetchFromGitHub }:
+{ stdenv, fetchFromGitHub
+, version # "12" for "1.2", "22" for "2.2" and so on
+}:
 
 stdenv.mkDerivation rec {
-  name = "opencl-headers-2.1-2016-11-29";
+  name = "opencl-headers-${version}-2017-07-18";
 
   src = fetchFromGitHub {
     owner = "KhronosGroup";
     repo = "OpenCL-Headers";
-    rev = "abb29588550c77f8340a6c3683531407013bf26b";
-    sha256 = "0zjznq65i4b2h4k36qfbbzq1acf2jdd9vygjv5az1yk7qgsp4jj7";
+    rev = "f039db6764d52388658ef15c30b2237bbda49803";
+    sha256 = "0z04i330zr8czak2624q71aajdcq7ly8mb5bgala5m235qjpsrh7";
   };
 
   installPhase = ''
     mkdir -p $out/include/CL
-    cp * $out/include/CL
+    cp opencl${version}/CL/* $out/include/CL
   '';
 
   meta = with stdenv.lib; {
-    description = "Khronos OpenCL headers";
+    description = "Khronos OpenCL headers version ${version}";
     homepage = https://www.khronos.org/registry/cl/;
     license = licenses.mit;
     platforms = platforms.unix;
diff --git a/pkgs/development/libraries/opencollada/default.nix b/pkgs/development/libraries/opencollada/default.nix
index 5ce30b039696..fb1199367037 100644
--- a/pkgs/development/libraries/opencollada/default.nix
+++ b/pkgs/development/libraries/opencollada/default.nix
@@ -1,28 +1,35 @@
-{ lib, stdenv, fetchFromGitHub, cmake, pkgconfig, libxml2, pcre }:
+{ lib, stdenv, fetchFromGitHub, cmake, pkgconfig, libxml2, pcre
+, darwin}:
 
 stdenv.mkDerivation rec {
   name = "opencollada-${version}";
 
-  version = "1.6.59";
+  version = "1.6.62";
 
   src = fetchFromGitHub {
     owner = "KhronosGroup";
     repo = "OpenCOLLADA";
     rev = "v${version}";
-    sha256 = "0gpjvzcfyilb96x5ywajxgkw42ipwp4my36z9cq686bd9vpp3q0g";
+    sha256 = "0bqki6sdvxsp9drzj87ma6n7m98az9pr0vyxhgw8b8b9knk8c48r";
   };
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ cmake ];
+  buildInputs = [ cmake ]
+    ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ AGL ]);
 
   propagatedBuildInputs = [ libxml2 pcre ];
 
   enableParallelBuilding = true;
 
+  patchPhase = lib.optionalString stdenv.isDarwin ''
+    substituteInPlace GeneratedSaxParser/src/GeneratedSaxParserUtils.cpp \
+      --replace math.h cmath
+  '';
+
   meta = {
     description = "A library for handling the COLLADA file format";
     homepage = https://github.com/KhronosGroup/OpenCOLLADA/;
     maintainers = [ stdenv.lib.maintainers.eelco ];
-    platforms = stdenv.lib.platforms.linux;
+    platforms = stdenv.lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/opencolorio/default.nix b/pkgs/development/libraries/opencolorio/default.nix
index db9a5aeed21e..3b0e60fca395 100644
--- a/pkgs/development/libraries/opencolorio/default.nix
+++ b/pkgs/development/libraries/opencolorio/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cmake, unzip }:
+{ stdenv, lib, fetchurl, cmake, unzip, boost }:
 
 stdenv.mkDerivation rec {
   name = "opencolorio-${version}";
@@ -11,7 +11,9 @@ stdenv.mkDerivation rec {
 
   outputs = [ "bin" "out" "dev" ];
 
-  buildInputs = [ cmake unzip ];
+  buildInputs = [ cmake unzip ] ++ lib.optional stdenv.isDarwin boost;
+
+  cmakeFlags = lib.optional stdenv.isDarwin "-DOCIO_USE_BOOST_PTR=ON";
 
   postInstall = ''
     rm $out/lib/*.a
@@ -23,6 +25,6 @@ stdenv.mkDerivation rec {
     description = "A color management framework for visual effects and animation";
     license = licenses.bsd3;
     maintainers = [ maintainers.goibhniu ];
-    platforms = platforms.linux;
+    platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/opencsg/default.nix b/pkgs/development/libraries/opencsg/default.nix
index c5f79b8613ec..2724976c5ae8 100644
--- a/pkgs/development/libraries/opencsg/default.nix
+++ b/pkgs/development/libraries/opencsg/default.nix
@@ -1,15 +1,15 @@
-{stdenv, fetchurl, mesa, freeglut, glew, libXmu, libXext, libX11
+{stdenv, fetchurl, libGLU_combined, freeglut, glew, libXmu, libXext, libX11
   }:
 
 stdenv.mkDerivation rec {
-  version = "1.4.0";
+  version = "1.4.2";
   name = "opencsg-${version}";
   src = fetchurl {
     url = "http://www.opencsg.org/OpenCSG-${version}.tar.gz";
-    sha256 = "13c73jxadm27h7spdh3qj1v6rnn81v4xwqlv5a6k72pv9kjnpd7c";
+    sha256 = "1ysazynm759gnw1rdhn9xw9nixnzrlzrc462340a6iif79fyqlnr";
   };
 
-  buildInputs = [mesa freeglut glew libXmu libXext libX11];
+  buildInputs = [libGLU_combined freeglut glew libXmu libXext libX11];
 
   doCheck = false;
 
diff --git a/pkgs/development/libraries/opencv/3.x.nix b/pkgs/development/libraries/opencv/3.x.nix
index e6cb75d3b3d9..efb9a7cdbe43 100644
--- a/pkgs/development/libraries/opencv/3.x.nix
+++ b/pkgs/development/libraries/opencv/3.x.nix
@@ -1,6 +1,7 @@
 { lib, stdenv
-, fetchurl, fetchFromGitHub
-, cmake, pkgconfig, unzip, zlib, pcre, hdf5, protobuf
+, fetchurl, fetchFromGitHub, fetchpatch
+, cmake, pkgconfig, unzip, zlib, pcre, hdf5
+, glog, boost, google-gflags, protobuf
 , config
 
 , enableJPEG      ? true, libjpeg
@@ -11,37 +12,43 @@
 , enableJPEG2K    ? true, jasper
 , enableEigen     ? true, eigen
 , enableOpenblas  ? true, openblas
+, enableContrib   ? true
 
 , enableCuda      ? (config.cudaSupport or false), cudatoolkit
 
+, enableUnfree    ? false
 , enableIpp       ? false
-, enableContrib   ? false  #, caffe, glog, boost, google-gflags
 , enablePython    ? false, pythonPackages
 , enableGtk2      ? false, gtk2
 , enableGtk3      ? false, gtk3
+, enableVtk       ? false, vtk
 , enableFfmpeg    ? false, ffmpeg
 , enableGStreamer ? false, gst_all_1
 , enableTesseract ? false, tesseract, leptonica
+, enableTbb       ? false, tbb
+, enableOvis      ? false, ogre
+, enableGPhoto2   ? false, libgphoto2
+, enableDC1394    ? false, libdc1394
 , enableDocs      ? false, doxygen, graphviz-nox
 
-, AVFoundation, Cocoa, QTKit
+, AVFoundation, Cocoa, QTKit, VideoDecodeAcceleration, bzip2
 }:
 
 let
-  version = "3.3.0";
+  version = "3.4.1";
 
   src = fetchFromGitHub {
     owner  = "opencv";
     repo   = "opencv";
     rev    = version;
-    sha256 = "0266kg337wij9rz602z5088jn2fq56aqpxxflf0fbh28kygchvk4";
+    sha256 = "08yahgf427d2qbs2mw02xww6bv5yjkfc1hihihh7fhqgfz0jnj1h";
   };
 
   contribSrc = fetchFromGitHub {
     owner  = "opencv";
     repo   = "opencv_contrib";
     rev    = version;
-    sha256 = "0qxdvzdszzlpsya1pn4d2r9z4j98isxrgk15a2wwa3dqjmgv880d";
+    sha256 = "00x1x53qv2pnc7i56244b5nf44wm2mp77hj486i5697r6hikk8n3";
   };
 
   # Contrib must be built in order to enable Tesseract support:
@@ -52,16 +59,16 @@ let
     src = fetchFromGitHub {
       owner  = "opencv";
       repo   = "opencv_3rdparty";
-      rev    = "a62e20676a60ee0ad6581e217fe7e4bada3b95db";
-      sha256 = "04idycc479l7fidj6r107sv65iszndswm287ms3nh896jbpbaxbv";
+      rev    = "dfe3162c237af211e98b8960018b564bc209261d";
+      sha256 = "1k5xiwdi5r2y3fs5g70lpknxqi4pj32w6l311gfwng3q1cb2crif";
     } + "/ippicv";
-    files = let name = platform : "ippicv_2017u2_${platform}_20170418.tgz"; in
+    files = let name = platform : "ippicv_2017u3_${platform}_general_20170822.tgz"; in
       if stdenv.system == "x86_64-linux" then
-      { ${name "lnx_intel64"} = "87cbdeb627415d8e4bc811156289fa3a"; }
+      { ${name "lnx_intel64"} = "4e0352ce96473837b1d671ce87f17359"; }
       else if stdenv.system == "i686-linux" then
-      { ${name "lnx_ia32"}    = "f2cece00d802d4dea86df52ed095257e"; }
+      { ${name "lnx_ia32"}    = "dcdb0ba4b123f240596db1840cd59a76"; }
       else if stdenv.system == "x86_64-darwin" then
-      { ${name "mac_intel64"} = "0c25953c99dbb499ff502485a9356d8d"; }
+      { ${name "mac_intel64"} = "c1ebb5dfa5b7f54b0c44e1917805a463"; }
       else
       throw "ICV is not available for this platform (or not yet supported by this package)";
     dst = ".cache/ippicv";
@@ -104,6 +111,21 @@ let
     dst = ".cache/xfeatures2d/boostdesc";
   };
 
+  # See opencv_contrib/modules/face/CMakeLists.txt
+  face = {
+    src = fetchFromGitHub {
+      owner  = "opencv";
+      repo   = "opencv_3rdparty";
+      rev    = "8afa57abc8229d611c4937165d20e2a2d9fc5a12";
+      sha256 = "061lsvqdidq9xa2hwrcvwi9ixflr2c2lfpc8drr159g68zi8bp4v";
+    };
+    files = {
+      "face_landmark_model.dat" = "7505c44ca4eb54b4ab1e4777cb96ac05";
+    };
+    dst = ".cache/data";
+  };
+
+  # See opencv/cmake/OpenCVDownload.cmake
   installExtraFiles = extra : with lib; ''
     mkdir -p "${extra.dst}"
   '' + concatStrings (mapAttrsToList (name : md5 : ''
@@ -121,8 +143,9 @@ let
     dst  = ".cache/tiny_dnn";
   };
 
-  opencvFlag = name: enabled: "-DWITH_${name}=${if enabled then "ON" else "OFF"}";
+  opencvFlag = name: enabled: "-DWITH_${name}=${printEnabled enabled}";
 
+  printEnabled = enabled : if enabled then "ON" else "OFF";
 in
 
 stdenv.mkDerivation rec {
@@ -144,22 +167,24 @@ stdenv.mkDerivation rec {
   '';
 
   preConfigure =
-    installExtraFiles ippicv + (
+    lib.optionalString enableIpp (installExtraFiles ippicv) + (
     lib.optionalString buildContrib ''
       cmakeFlagsArray+=("-DOPENCV_EXTRA_MODULES_PATH=$NIX_BUILD_TOP/opencv_contrib")
 
       ${installExtraFiles vgg}
       ${installExtraFiles boostdesc}
+      ${installExtraFiles face}
 
       mkdir -p "${tinyDnn.dst}"
       ln -s "${tinyDnn.src}" "${tinyDnn.dst}/${tinyDnn.md5}-${tinyDnn.name}"
     '');
 
   buildInputs =
-       [ zlib pcre hdf5 protobuf ]
+       [ zlib pcre hdf5 glog boost google-gflags protobuf ]
     ++ lib.optional enablePython pythonPackages.python
     ++ lib.optional enableGtk2 gtk2
     ++ lib.optional enableGtk3 gtk3
+    ++ lib.optional enableVtk vtk
     ++ lib.optional enableJPEG libjpeg
     ++ lib.optional enablePNG libpng
     ++ lib.optional enableTIFF libtiff
@@ -167,20 +192,21 @@ stdenv.mkDerivation rec {
     ++ lib.optionals enableEXR [ openexr ilmbase ]
     ++ lib.optional enableJPEG2K jasper
     ++ lib.optional enableFfmpeg ffmpeg
+    ++ lib.optionals (enableFfmpeg && stdenv.isDarwin)
+                     [ VideoDecodeAcceleration bzip2 ]
     ++ lib.optionals enableGStreamer (with gst_all_1; [ gstreamer gst-plugins-base ])
+    ++ lib.optional enableOvis ogre
+    ++ lib.optional enableGPhoto2 libgphoto2
+    ++ lib.optional enableDC1394 libdc1394
     ++ lib.optional enableEigen eigen
     ++ lib.optional enableOpenblas openblas
     # There is seemingly no compile-time flag for Tesseract.  It's
     # simply enabled automatically if contrib is built, and it detects
     # tesseract & leptonica.
     ++ lib.optionals enableTesseract [ tesseract leptonica ]
+    ++ lib.optional enableTbb tbb
     ++ lib.optional enableCuda cudatoolkit
-
-    # These are only needed for the currently disabled
-    # cnn_3dobj and dnn_modern modules
-    # ++ lib.optionals buildContrib [ caffe glog boost google-gflags ]
-
-    ++ lib.optionals stdenv.isDarwin [ AVFoundation Cocoa QTKit ]
+    ++ lib.optionals stdenv.isDarwin [ AVFoundation Cocoa QTKit VideoDecodeAcceleration bzip2 ]
     ++ lib.optionals enableDocs [ doxygen graphviz-nox ];
 
   propagatedBuildInputs = lib.optional enablePython pythonPackages.numpy;
@@ -189,10 +215,17 @@ stdenv.mkDerivation rec {
 
   NIX_CFLAGS_COMPILE = lib.optional enableEXR "-I${ilmbase.dev}/include/OpenEXR";
 
+  # Configure can't find the library without this.
+  OpenBLAS_HOME = lib.optionalString enableOpenblas openblas;
+
   cmakeFlags = [
+    "-DWITH_OPENMP=ON"
     "-DBUILD_PROTOBUF=OFF"
     "-DPROTOBUF_UPDATE_FILES=ON"
-    "-DWITH_OPENMP=ON"
+    "-DOPENCV_ENABLE_NONFREE=${printEnabled enableUnfree}"
+    "-DBUILD_TESTS=OFF"
+    "-DBUILD_PERF_TESTS=OFF"
+    "-DBUILD_DOCS=${printEnabled enableDocs}"
     (opencvFlag "IPP" enableIpp)
     (opencvFlag "TIFF" enableTIFF)
     (opencvFlag "JASPER" enableJPEG2K)
@@ -202,20 +235,18 @@ stdenv.mkDerivation rec {
     (opencvFlag "OPENEXR" enableEXR)
     (opencvFlag "CUDA" enableCuda)
     (opencvFlag "CUBLAS" enableCuda)
+    (opencvFlag "TBB" enableTbb)
   ] ++ lib.optionals enableCuda [
     "-DCUDA_FAST_MATH=ON"
-    "-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/gcc"
-  ] ++ lib.optionals buildContrib [
-         # the cnn_3dobj module fails to build
-         "-DBUILD_opencv_cnn_3dobj=OFF"
-
-         # the dnn_modern module causes:
-         # https://github.com/opencv/opencv_contrib/issues/823
-         #
-         # On OS X its dependency tiny-dnn-1.0.0a3 also fails to build.
-         "-DBUILD_opencv_dnn_modern=OFF"
-       ]
-    ++ lib.optionals stdenv.isDarwin ["-DWITH_OPENCL=OFF" "-DWITH_LAPACK=OFF"];
+    "-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/cc"
+    "-DCUDA_NVCC_FLAGS=--expt-relaxed-constexpr"
+  ] ++ lib.optionals stdenv.isDarwin [
+    "-DWITH_OPENCL=OFF"
+    "-DWITH_LAPACK=OFF"
+
+    # On OS X the tiny-dnn-1.0.0a3 dependency of dnn_modern fails to build.
+    "-DBUILD_opencv_dnn_modern=OFF"
+  ];
 
   enableParallelBuilding = true;
 
@@ -229,8 +260,8 @@ stdenv.mkDerivation rec {
 
   meta = {
     description = "Open Computer Vision Library with more than 500 algorithms";
-    homepage = http://opencv.org/;
-    license = stdenv.lib.licenses.bsd3;
+    homepage = https://opencv.org/;
+    license = with stdenv.lib.licenses; if enableUnfree then unfree else bsd3;
     maintainers = with stdenv.lib.maintainers; [viric mdaiter basvandijk];
     platforms = with stdenv.lib.platforms; linux ++ darwin;
   };
diff --git a/pkgs/development/libraries/opencv/default.nix b/pkgs/development/libraries/opencv/default.nix
index aadd108620aa..cbac7210a10e 100644
--- a/pkgs/development/libraries/opencv/default.nix
+++ b/pkgs/development/libraries/opencv/default.nix
@@ -85,7 +85,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "Open Computer Vision Library with more than 500 algorithms";
-    homepage = http://opencv.org/;
+    homepage = https://opencv.org/;
     license = licenses.bsd3;
     maintainers = with maintainers; [ viric ];
     platforms = platforms.linux ++ platforms.darwin;
diff --git a/pkgs/development/libraries/opendbx/default.nix b/pkgs/development/libraries/opendbx/default.nix
index 37afa3fd5070..48ec5141e34f 100644
--- a/pkgs/development/libraries/opendbx/default.nix
+++ b/pkgs/development/libraries/opendbx/default.nix
@@ -12,10 +12,10 @@ stdenv.mkDerivation rec {
   };
 
   preConfigure = ''
-    export CPPFLAGS="-I${getDev mysql.client}/include/mysql"
-    export LDFLAGS="-L${getLib mysql.client}/lib/mysql -L${getLib postgresql}/lib"
+    export CPPFLAGS="-I${mysql.connector-c}/include/mysql"
+    export LDFLAGS="-L${mysql.connector-c}/lib/mysql -L${postgresql}/lib"
     configureFlagsArray=(--with-backends="mysql pgsql sqlite3")
   '';
 
-  buildInputs = [ readline mysql.client postgresql sqlite ];
+  buildInputs = [ readline mysql.connector-c postgresql sqlite ];
 }
diff --git a/pkgs/development/libraries/opendht/default.nix b/pkgs/development/libraries/opendht/default.nix
index 75d2b090e711..fc2068ca02ca 100644
--- a/pkgs/development/libraries/opendht/default.nix
+++ b/pkgs/development/libraries/opendht/default.nix
@@ -13,13 +13,13 @@
 
 stdenv.mkDerivation rec {
   name = "opendht-${version}";
-  version = "1.3.4";
+  version = "1.7.0";
 
   src = fetchFromGitHub {
     owner = "savoirfairelinux";
     repo = "opendht";
     rev = "${version}";
-    sha256 = "0karj37f0zq39w0ip8ahrjr6lcrrn9jd6bpzylp1m92jzs8pfki8";
+    sha256 = "14pdih09h3bmgimmj9sa917x7kld49m91gvh0lcncink8rmbxvf1";
   };
 
   buildInputs = [
diff --git a/pkgs/development/libraries/openexr/default.nix b/pkgs/development/libraries/openexr/default.nix
index 27a9860c8683..8d5a6bb65a91 100644
--- a/pkgs/development/libraries/openexr/default.nix
+++ b/pkgs/development/libraries/openexr/default.nix
@@ -1,13 +1,17 @@
-{ lib, stdenv, fetchurl, autoconf, automake, libtool, pkgconfig, zlib, ilmbase }:
+{ lib, stdenv, fetchurl, fetchpatch, autoconf, automake, libtool, pkgconfig, zlib, ilmbase }:
 
 stdenv.mkDerivation rec {
   name = "openexr-${lib.getVersion ilmbase}";
 
   src = fetchurl {
     url = "http://download.savannah.nongnu.org/releases/openexr/${name}.tar.gz";
-    sha256 = "0ca2j526n4wlamrxb85y2jrgcv0gf21b3a19rr0gh4rjqkv1581n";
+    sha256 = "1kdf2gqznsdinbd5vcmqnif442nyhdf9l7ckc51410qm2gv5m6lg";
   };
 
+  patches = [
+    ./bootstrap.patch
+  ];
+
   outputs = [ "bin" "dev" "out" "doc" ];
 
   preConfigure = ''
@@ -20,8 +24,6 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  patches = [ ./bootstrap.patch ];
-
   meta = with stdenv.lib; {
     homepage = http://www.openexr.com/;
     license = licenses.bsd3;
diff --git a/pkgs/development/libraries/openexrid-unstable/default.nix b/pkgs/development/libraries/openexrid-unstable/default.nix
index fcf4c2c2468f..099bd8d1e973 100644
--- a/pkgs/development/libraries/openexrid-unstable/default.nix
+++ b/pkgs/development/libraries/openexrid-unstable/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, unzip, re2, openfx, zlib, ilmbase, mesa, openexr }:
+{ stdenv, fetchFromGitHub, unzip, re2, openfx, zlib, ilmbase, libGLU_combined, openexr }:
 
 stdenv.mkDerivation rec
 {
@@ -16,12 +16,17 @@ stdenv.mkDerivation rec
 
   patches = [ ./openexrid.patch ];
 
+  postPatch = ''
+    substituteInPlace openexrid/makefile \
+        --replace g++ c++
+  '';
+
   NIX_CFLAGS_COMPILE=''-I${ilmbase.dev}/include/OpenEXR
                        -I${openexr.dev}/include/OpenEXR
                        -I${openfx.dev}/include/OpenFX
                       '';
 
-  buildInputs = [ unzip re2 openfx zlib ilmbase mesa openexr ];
+  buildInputs = [ unzip re2 openfx zlib ilmbase libGLU_combined openexr ];
 
   enableParallelBuilding = true;
 
@@ -38,7 +43,7 @@ stdenv.mkDerivation rec
       find $out
       mv $out/include $dev/
       mv $out/lib $lib/
-      '';
+  '';
 
   meta = with stdenv.lib; {
     description = "OpenEXR files able to isolate any object of a CG image with a perfect antialiazing";
diff --git a/pkgs/development/libraries/openfst/default.nix b/pkgs/development/libraries/openfst/default.nix
index 690261438ab9..1ab6661db5bb 100644
--- a/pkgs/development/libraries/openfst/default.nix
+++ b/pkgs/development/libraries/openfst/default.nix
@@ -3,11 +3,11 @@
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
   pname = "openfst";
-  version = "1.6.3";
+  version = "1.6.7";
 
   src = fetchurl {
     url = "http://www.openfst.org/twiki/pub/FST/FstDownload/${name}.tar.gz";
-    sha256 = "5c28b6ccd017fc6ff94ebd0c73ed8ab37d48f563dab1c603856fb05bc9333d99";
+    sha256 = "1xqpc1qlvghprwih99immsjh3ba08lg754cf5icnmpkwh9nlh6p2";
   };
   meta = {
     description = "Library for working with finite-state transducers";
diff --git a/pkgs/development/libraries/openjpeg/2.1.nix b/pkgs/development/libraries/openjpeg/2.1.nix
index ae8710e58a28..d18c971dc112 100644
--- a/pkgs/development/libraries/openjpeg/2.1.nix
+++ b/pkgs/development/libraries/openjpeg/2.1.nix
@@ -1,37 +1,8 @@
 { callPackage, fetchpatch, ... } @ args:
 
 callPackage ./generic.nix (args // rec {
-  version = "2.1.2";
-  branch = "2.1";
-  revision = "v2.1.2";
-  sha256 = "0kdcl9sqjz0vagli4ad6bxq1r8ma086m0prpkm5x3dxp37hpjp8h";
-
-  patches = [
-    # Fetched from https://github.com/szukw000/openjpeg/commit/cadff5fb6e73398de26a92e96d3d7cac893af255
-    # Referenced from https://bugzilla.redhat.com/show_bug.cgi?id=1405135
-    # Put in our source code to make sure we don't lose it, since that
-    # referenced commit is someone else's fork, and not actually up-stream.
-    ./CVE-2016-9580-and-CVE-2016-9581.patch
-
-    (fetchpatch {
-      url = "https://bugzilla.suse.com/attachment.cgi?id=707359&action=diff&context=patch&collapsed=&headers=1&format=raw";
-      name = "CVE-2016-9112.patch";
-      sha256 = "18hqx73wdzfybr5n5k6pzhbhdlmawiqbjci8n82zykxiyfgp18pd";
-    })
-    (fetchpatch {
-      url = "https://bugzilla.suse.com/attachment.cgi?id=707354&action=diff&context=patch&collapsed=&headers=1&format=raw";
-      name = "CVE-2016-9114.patch";
-      sha256 = "0qam3arw9kdbh4501xim2pyldl708dnpyjwvjmwc9gc7hcq4gfi3";
-    })
-    (fetchpatch {
-      url = "https://bugzilla.suse.com/attachment.cgi?id=707356&action=diff&context=patch&collapsed=&headers=1&format=raw";
-      name = "CVE-2016-9116.patch";
-      sha256 = "0yyb3pxqi5sr44a48bacngzp206j4z49lzkg6hbkz1nra9na61a3";
-    })
-    (fetchpatch {
-      url = "https://bugzilla.suse.com/attachment.cgi?id=707358&action=diff&context=patch&collapsed=&headers=1&format=raw";
-      name = "CVE-2016-9118.patch";
-      sha256 = "125n8bmh07y7697s0y82ypb39rxgj0bdn8rcywbvamscagwg2wy9";
-    })
-  ];
+  version = "2.3.0";
+  branch = "2.3";
+  revision = "v${version}";
+  sha256 = "08plxrnfl33sn2vh5nwbsngyv6b1sfpplvx881crm1v1ai10m2lz";
 })
diff --git a/pkgs/development/libraries/openjpeg/CVE-2016-9580-and-CVE-2016-9581.patch b/pkgs/development/libraries/openjpeg/CVE-2016-9580-and-CVE-2016-9581.patch
deleted file mode 100644
index 064e7419c341..000000000000
--- a/pkgs/development/libraries/openjpeg/CVE-2016-9580-and-CVE-2016-9581.patch
+++ /dev/null
@@ -1,242 +0,0 @@
-From cadff5fb6e73398de26a92e96d3d7cac893af255 Mon Sep 17 00:00:00 2001
-From: szukw000 <szukw000@arcor.de>
-Date: Fri, 9 Dec 2016 08:29:55 +0100
-Subject: [PATCH] These changes repair bugs of #871 and #872
-
----
- src/bin/jp2/converttif.c | 107 +++++++++++++++++++++++++++++++----------------
- 1 file changed, 70 insertions(+), 37 deletions(-)
-
-diff --git a/src/bin/jp2/converttif.c b/src/bin/jp2/converttif.c
-index 143d3be..c690f8b 100644
---- a/src/bin/jp2/converttif.c
-+++ b/src/bin/jp2/converttif.c
-@@ -553,20 +553,18 @@ static void tif_32sto16u(const OPJ_INT32* pSrc, OPJ_UINT16* pDst, OPJ_SIZE_T len
- 
- int imagetotif(opj_image_t * image, const char *outfile)
- {
--	int width, height;
--	int bps,adjust, sgnd;
--	int tiPhoto;
-+	uint32 width, height, bps, tiPhoto;
-+	int adjust, sgnd;
- 	TIFF *tif;
- 	tdata_t buf;
--	tsize_t strip_size;
-+	tmsize_t strip_size, rowStride;
- 	OPJ_UINT32 i, numcomps;
--	OPJ_SIZE_T rowStride;
- 	OPJ_INT32* buffer32s = NULL;
- 	OPJ_INT32 const* planes[4];
- 	convert_32s_PXCX cvtPxToCx = NULL;
- 	convert_32sXXx_C1R cvt32sToTif = NULL;
- 
--	bps = (int)image->comps[0].prec;
-+	bps = (uint32)image->comps[0].prec;
- 	planes[0] = image->comps[0].data;
- 	
- 	numcomps = image->numcomps;
-@@ -674,13 +672,13 @@ int imagetotif(opj_image_t * image, const char *outfile)
- 			break;
- 	}
- 	sgnd = (int)image->comps[0].sgnd;
--	adjust = sgnd ? 1 << (image->comps[0].prec - 1) : 0;
--	width   = (int)image->comps[0].w;
--	height  = (int)image->comps[0].h;
-+	adjust = sgnd ? (int)(1 << (image->comps[0].prec - 1)) : 0;
-+	width   = (uint32)image->comps[0].w;
-+	height  = (uint32)image->comps[0].h;
- 	
- 	TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
- 	TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
--	TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, numcomps);
-+	TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, (uint32)numcomps);
- 	TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
- 	TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
- 	TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
-@@ -688,8 +686,8 @@ int imagetotif(opj_image_t * image, const char *outfile)
- 	TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
- 	
- 	strip_size = TIFFStripSize(tif);
--	rowStride = ((OPJ_SIZE_T)width * numcomps * (OPJ_SIZE_T)bps + 7U) / 8U;
--	if (rowStride != (OPJ_SIZE_T)strip_size) {
-+	rowStride = (width * numcomps * bps + 7U) / 8U;
-+	if (rowStride != strip_size) {
- 		fprintf(stderr, "Invalid TIFF strip size\n");
- 		TIFFClose(tif);
- 		return 1;
-@@ -699,7 +697,7 @@ int imagetotif(opj_image_t * image, const char *outfile)
- 		TIFFClose(tif);
- 		return 1;
- 	}
--	buffer32s = (OPJ_INT32 *)malloc((OPJ_SIZE_T)width * numcomps * sizeof(OPJ_INT32));
-+	buffer32s = (OPJ_INT32 *)malloc((OPJ_SIZE_T)(width * numcomps * sizeof(OPJ_INT32)));
- 	if (buffer32s == NULL) {
- 		_TIFFfree(buf);
- 		TIFFClose(tif);
-@@ -1211,20 +1209,19 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
- 	TIFF *tif;
- 	tdata_t buf;
- 	tstrip_t strip;
--	tsize_t strip_size;
-+	tmsize_t strip_size;
- 	int j, currentPlane, numcomps = 0, w, h;
- 	OPJ_COLOR_SPACE color_space = OPJ_CLRSPC_UNKNOWN;
- 	opj_image_cmptparm_t cmptparm[4]; /* RGBA */
- 	opj_image_t *image = NULL;
- 	int has_alpha = 0;
--	unsigned short tiBps, tiPhoto, tiSf, tiSpp, tiPC;
--	unsigned int tiWidth, tiHeight;
-+	uint32 tiBps, tiPhoto, tiSf, tiSpp, tiPC, tiWidth, tiHeight;
- 	OPJ_BOOL is_cinema = OPJ_IS_CINEMA(parameters->rsiz);
- 	convert_XXx32s_C1R cvtTifTo32s = NULL;
- 	convert_32s_CXPX cvtCxToPx = NULL;
- 	OPJ_INT32* buffer32s = NULL;
- 	OPJ_INT32* planes[4];
--	OPJ_SIZE_T rowStride;
-+	tmsize_t rowStride;
- 	
- 	tif = TIFFOpen(filename, "r");
- 	
-@@ -1243,22 +1240,35 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
- 	TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &tiSpp);
- 	TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &tiPhoto);
- 	TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &tiPC);
--	w= (int)tiWidth;
--	h= (int)tiHeight;
--	
--	if(tiBps > 16U) {
--		fprintf(stderr,"tiftoimage: Bits=%d, Only 1 to 16 bits implemented\n",tiBps);
--		fprintf(stderr,"\tAborting\n");
-+
-+	if(tiSpp == 0 || tiSpp > 4) { /* should be 1 ... 4 */
-+		fprintf(stderr,"tiftoimage: Bad value for samples per pixel == %hu.\n"
-+		 "\tAborting.\n", tiSpp);
-+		TIFFClose(tif);
-+		return NULL;
-+	}
-+	if(tiBps > 16U || tiBps == 0) {
-+		fprintf(stderr,"tiftoimage: Bad values for Bits == %d.\n"
-+		 "\tMax. 16 Bits are allowed here.\n\tAborting.\n",tiBps);
- 		TIFFClose(tif);
- 		return NULL;
- 	}
- 	if(tiPhoto != PHOTOMETRIC_MINISBLACK && tiPhoto != PHOTOMETRIC_RGB) {
--		fprintf(stderr,"tiftoimage: Bad color format %d.\n\tOnly RGB(A) and GRAY(A) has been implemented\n",(int) tiPhoto);
-+		fprintf(stderr,"tiftoimage: Bad color format %d.\n"
-+		 "\tOnly RGB(A) and GRAY(A) has been implemented\n",(int) tiPhoto);
- 		fprintf(stderr,"\tAborting\n");
- 		TIFFClose(tif);
- 		return NULL;
- 	}
--	
-+	if(tiWidth == 0 || tiHeight == 0) {
-+		fprintf(stderr,"tiftoimage: Bad values for width(%u) "
-+		 "and/or height(%u)\n\tAborting.\n",tiWidth,tiHeight);
-+		TIFFClose(tif);
-+		return NULL;
-+	}
-+	w= (int)tiWidth;
-+	h= (int)tiHeight;
-+
- 	switch (tiBps) {
- 		case 1:
- 		case 2:
-@@ -1312,7 +1322,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
- 		
- 		TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES,
- 													&extrasamples, &sampleinfo);
--		
-+
- 		if(extrasamples >= 1)
- 		{
- 			switch(sampleinfo[0])
-@@ -1333,7 +1343,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
- 		else /* extrasamples == 0 */
- 			if(tiSpp == 4 || tiSpp == 2) has_alpha = 1;
- 	}
--	
-+
- 	/* initialize image components */
- 	memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t));
- 	
-@@ -1346,7 +1356,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
- 	} else {
- 		is_cinema = 0U;
- 	}
--	
-+
- 	if(tiPhoto == PHOTOMETRIC_RGB) /* RGB(A) */
- 	{
- 		numcomps = 3 + has_alpha;
-@@ -1384,10 +1394,24 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
- 	image->x0 = (OPJ_UINT32)parameters->image_offset_x0;
- 	image->y0 = (OPJ_UINT32)parameters->image_offset_y0;
- 	image->x1 =	!image->x0 ? (OPJ_UINT32)(w - 1) * (OPJ_UINT32)subsampling_dx + 1 :
--	image->x0 + (OPJ_UINT32)(w - 1) * (OPJ_UINT32)subsampling_dx + 1;
-+	 image->x0 + (OPJ_UINT32)(w - 1) * (OPJ_UINT32)subsampling_dx + 1;
-+	if(image->x1 <= image->x0) {
-+		fprintf(stderr,"tiftoimage: Bad value for image->x1(%d) vs. "
-+		 "image->x0(%d)\n\tAborting.\n",image->x1,image->x0);
-+		TIFFClose(tif);
-+		opj_image_destroy(image);
-+		return NULL;
-+	}
- 	image->y1 =	!image->y0 ? (OPJ_UINT32)(h - 1) * (OPJ_UINT32)subsampling_dy + 1 :
--	image->y0 + (OPJ_UINT32)(h - 1) * (OPJ_UINT32)subsampling_dy + 1;
--
-+	 image->y0 + (OPJ_UINT32)(h - 1) * (OPJ_UINT32)subsampling_dy + 1;
-+	if(image->y1 <= image->y0) {
-+		fprintf(stderr,"tiftoimage: Bad value for image->y1(%d) vs. "
-+		 "image->y0(%d)\n\tAborting.\n",image->y1,image->y0);
-+		TIFFClose(tif);
-+		opj_image_destroy(image);
-+		return NULL;
-+	}
-+	
- 	for(j = 0; j < numcomps; j++)
- 	{
- 		planes[j] = image->comps[j].data;
-@@ -1395,15 +1419,15 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
- 	image->comps[numcomps - 1].alpha = (OPJ_UINT16)(1 - (numcomps & 1));
- 		
- 	strip_size = TIFFStripSize(tif);
--	
-+
- 	buf = _TIFFmalloc(strip_size);
- 	if (buf == NULL) {
- 		TIFFClose(tif);
- 		opj_image_destroy(image);
- 		return NULL;
- 	}
--	rowStride = ((OPJ_SIZE_T)w * tiSpp * tiBps + 7U) / 8U;
--	buffer32s = (OPJ_INT32 *)malloc((OPJ_SIZE_T)w * tiSpp * sizeof(OPJ_INT32));
-+	rowStride = (w * tiSpp * tiBps + 7U) / 8U;
-+	buffer32s = (OPJ_INT32 *)malloc((OPJ_SIZE_T)(w * tiSpp * sizeof(OPJ_INT32)));
- 	if (buffer32s == NULL) {
- 		_TIFFfree(buf);
- 		TIFFClose(tif);
-@@ -1421,11 +1445,20 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
- 		for(; (h > 0) && (strip < TIFFNumberOfStrips(tif)); strip++)
- 		{
- 				const OPJ_UINT8 *dat8;
--				OPJ_SIZE_T ssize;
-+				tmsize_t ssize;
- 				
--				ssize = (OPJ_SIZE_T)TIFFReadEncodedStrip(tif, strip, buf, strip_size);
-+				ssize = TIFFReadEncodedStrip(tif, strip, buf, strip_size);
-+				if(ssize < 1 || ssize > strip_size) {
-+					fprintf(stderr,"tiftoimage: Bad value for ssize(%ld) "
-+                     "vs. strip_size(%ld).\n\tAborting.\n",ssize,strip_size);
-+					_TIFFfree(buf);
-+					_TIFFfree(buffer32s);
-+					TIFFClose(tif);
-+					opj_image_destroy(image);
-+					return NULL;
-+				}
- 				dat8 = (const OPJ_UINT8*)buf;
--				
-+
- 				while (ssize >= rowStride) {
- 					cvtTifTo32s(dat8, buffer32s, (OPJ_SIZE_T)w * tiSpp);
- 					cvtCxToPx(buffer32s, planes, (OPJ_SIZE_T)w);
diff --git a/pkgs/development/libraries/openldap/default.nix b/pkgs/development/libraries/openldap/default.nix
index 475ac496e7e8..56118c9bbb2c 100644
--- a/pkgs/development/libraries/openldap/default.nix
+++ b/pkgs/development/libraries/openldap/default.nix
@@ -57,7 +57,7 @@ stdenv.mkDerivation rec {
   meta = with stdenv.lib; {
     homepage    = http://www.openldap.org/;
     description = "An open source implementation of the Lightweight Directory Access Protocol";
-    maintainers = with maintainers; [ lovek323 mornfall ];
+    maintainers = with maintainers; [ lovek323 ];
     platforms   = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/openmpi/default.nix b/pkgs/development/libraries/openmpi/default.nix
index 2d08f37c8c23..9aca076c5dcb 100644
--- a/pkgs/development/libraries/openmpi/default.nix
+++ b/pkgs/development/libraries/openmpi/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, gfortran, perl, libibverbs
+{ stdenv, fetchurl, gfortran, perl, libnl, rdma-core, zlib
 
 # Enable the Sun Grid Engine bindings
 , enableSGE ? false
@@ -7,44 +7,48 @@
 , enablePrefix ? false
 }:
 
-with stdenv.lib;
-
 let
-  majorVersion = "1.10";
+  majorVersion = "3.0";
+  minorVersion = "0";
 
 in stdenv.mkDerivation rec {
-  name = "openmpi-${majorVersion}.7";
+  name = "openmpi-${majorVersion}.${minorVersion}";
 
   src = fetchurl {
     url = "http://www.open-mpi.org/software/ompi/v${majorVersion}/downloads/${name}.tar.bz2";
-    sha256 = "142s1vny9gllkq336yafxayjgcirj2jv0ddabj879jgya7hyr2d0";
+    sha256 = "1mw2d94k6mp4scg1wnkj50vdh734fy5m2ygyrj65s4mh3prbz6gn";
   };
 
-  buildInputs = [ gfortran ]
-    ++ optional (stdenv.isLinux || stdenv.isFreeBSD) libibverbs;
+  postPatch = ''
+    patchShebangs ./
+  '';
+
+  buildInputs = with stdenv; [ gfortran zlib ]
+    ++ lib.optional isLinux libnl
+    ++ lib.optional (isLinux || isFreeBSD) rdma-core;
 
   nativeBuildInputs = [ perl ];
 
-  configureFlags = []
-    ++ optional enableSGE "--with-sge"
-    ++ optional enablePrefix "--enable-mpirun-prefix-by-default"
+  configureFlags = with stdenv; [ "--disable-mca-dso" ]
+    ++ lib.optional isLinux  "--with-libnl=${libnl.dev}"
+    ++ lib.optional enableSGE "--with-sge"
+    ++ lib.optional enablePrefix "--enable-mpirun-prefix-by-default"
     ;
 
   enableParallelBuilding = true;
 
-  preBuild = ''
-    patchShebangs ompi/mpi/fortran/base/gen-mpi-sizeof.pl
-  '';
-
   postInstall = ''
-		rm -f $out/lib/*.la
+    rm -f $out/lib/*.la
    '';
 
-  meta = {
+  doCheck = true;
+
+  meta = with stdenv.lib; {
     homepage = http://www.open-mpi.org/;
-    description = "Open source MPI-2 implementation";
-    longDescription = "The Open MPI Project is an open source MPI-2 implementation that is developed and maintained by a consortium of academic, research, and industry partners. Open MPI is therefore able to combine the expertise, technologies, and resources from all across the High Performance Computing community in order to build the best MPI library available. Open MPI offers advantages for system and software vendors, application developers and computer science researchers.";
-    maintainers = [ stdenv.lib.maintainers.mornfall ];
+    description = "Open source MPI-3 implementation";
+    longDescription = "The Open MPI Project is an open source MPI-3 implementation that is developed and maintained by a consortium of academic, research, and industry partners. Open MPI is therefore able to combine the expertise, technologies, and resources from all across the High Performance Computing community in order to build the best MPI library available. Open MPI offers advantages for system and software vendors, application developers and computer science researchers.";
+    maintainers = with maintainers; [ markuskowa ];
+    license = licenses.bsd3;
     platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/openpam/default.nix b/pkgs/development/libraries/openpam/default.nix
new file mode 100644
index 000000000000..187f86133756
--- /dev/null
+++ b/pkgs/development/libraries/openpam/default.nix
@@ -0,0 +1,18 @@
+{ stdenv, buildPackages, hostPlatform, fetchurl, lib }:
+
+stdenv.mkDerivation rec {
+  name = "openpam-${version}";
+  version = "20170430";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/openpam/openpam/Resedacea/${name}.tar.gz";
+    sha256 = "0pz8kf9mxj0k8yp8jgmhahddz58zv2b7gnyjwng75xgsx4i55xi2";
+  };
+
+  meta = {
+    homepage = https://www.openpam.org;
+    description = "An open source PAM library that focuses on simplicity, correctness, and cleanliness";
+    platforms = lib.platforms.unix;
+    maintainers = with lib.maintainers; [ matthewbauer ];
+  };
+}
diff --git a/pkgs/development/libraries/opensaml-cpp/default.nix b/pkgs/development/libraries/opensaml-cpp/default.nix
index c2c102ccf9bd..659c4fb7cff6 100644
--- a/pkgs/development/libraries/opensaml-cpp/default.nix
+++ b/pkgs/development/libraries/opensaml-cpp/default.nix
@@ -2,12 +2,12 @@
 
 stdenv.mkDerivation rec {
   name = "opensaml-cpp-${version}";
-  version = "2.6.0";
+  version = "2.6.1";
 
   src = fetchgit {
     url = "https://git.shibboleth.net/git/cpp-opensaml.git";
-    rev = "61193de29e4c9f1ccff7ed7e1f42c2748c62be77";
-    sha256 = "1jlxa1f2qn0kd15fzjqp80apxn42v47wg3mx1vk424m31rhi00xr";
+    rev = version;
+    sha256 = "0wjb6jyvh4hwpy1pvhh63i821746nqijysrd4vasbirkf4h6z7nx";
   };
 
   buildInputs = [ boost openssl log4shib xercesc xml-security-c xml-tooling-c zlib ];
diff --git a/pkgs/development/libraries/openslp/CVE-2016-4912.patch b/pkgs/development/libraries/openslp/CVE-2016-4912.patch
new file mode 100644
index 000000000000..06223deda89b
--- /dev/null
+++ b/pkgs/development/libraries/openslp/CVE-2016-4912.patch
@@ -0,0 +1,11 @@
+--- a/common/slp_xmalloc.c
++++ b/common/slp_xmalloc.c
+@@ -206,7 +206,7 @@ void * _xrealloc(const char * file, int line, void * ptr, size_t size)
+          if (newptr == 0)
+             return 0;
+          memcpy(newptr, ptr, x->size);
+-         _xfree(file, line, x);
++         _xfree(file, line, ptr);
+       }
+       return newptr;
+    }
diff --git a/pkgs/development/libraries/openslp/default.nix b/pkgs/development/libraries/openslp/default.nix
index 3ab3f68cde5e..3e178d92013e 100644
--- a/pkgs/development/libraries/openslp/default.nix
+++ b/pkgs/development/libraries/openslp/default.nix
@@ -19,6 +19,7 @@ stdenv.mkDerivation {
       url = "https://src.fedoraproject.org/cgit/rpms/openslp.git/plain/openslp-2.0.0-cve-2016-7567.patch";
       sha256 = "0zp61axx93b7nrbsyhn2x4dnw7n9y6g4rys21hyqxk4khrnc2yr9";
     })
+    ./CVE-2016-4912.patch
   ];
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix
index 68e88cc57d06..5a9052222cb8 100644
--- a/pkgs/development/libraries/openssl/default.nix
+++ b/pkgs/development/libraries/openssl/default.nix
@@ -1,5 +1,6 @@
 { stdenv, fetchurl, buildPackages, perl
-, hostPlatform
+, buildPlatform, hostPlatform
+, fetchpatch
 , withCryptodev ? false, cryptodevHeaders
 , enableSSL2 ? false
 }:
@@ -7,10 +8,6 @@
 with stdenv.lib;
 
 let
-
-  opensslCrossSystem = hostPlatform.openssl.system or
-    (throw "openssl needs its platform name cross building");
-
   common = args@{ version, sha256, patches ? [] }: stdenv.mkDerivation rec {
     name = "openssl-${version}";
 
@@ -23,23 +20,44 @@ let
       (args.patches or [])
       ++ [ ./nix-ssl-cert-file.patch ]
       ++ optional (versionOlder version "1.1.0")
-          (if stdenv.isDarwin then ./use-etc-ssl-certs-darwin.patch else ./use-etc-ssl-certs.patch)
+          (if hostPlatform.isDarwin then ./use-etc-ssl-certs-darwin.patch else ./use-etc-ssl-certs.patch)
       ++ optional (versionOlder version "1.0.2" && hostPlatform.isDarwin)
            ./darwin-arch.patch;
 
+  postPatch = if (versionAtLeast version "1.1.0" && stdenv.hostPlatform.isMusl) then ''
+    substituteInPlace crypto/async/arch/async_posix.h \
+      --replace '!defined(__ANDROID__) && !defined(__OpenBSD__)' \
+                '!defined(__ANDROID__) && !defined(__OpenBSD__) && 0'
+  '' else null;
+
     outputs = [ "bin" "dev" "out" "man" ];
     setOutputFlags = false;
-    separateDebugInfo = stdenv.isLinux;
+    separateDebugInfo = hostPlatform.isLinux;
 
     nativeBuildInputs = [ perl ];
     buildInputs = stdenv.lib.optional withCryptodev cryptodevHeaders;
 
-    # On x86_64-darwin, "./config" misdetects the system as
-    # "darwin-i386-cc".  So specify the system type explicitly.
-    configureScript =
-      if stdenv.system == "x86_64-darwin" then "./Configure darwin64-x86_64-cc"
-      else if stdenv.system == "x86_64-solaris" then "./Configure solaris64-x86_64-gcc"
-      else "./config";
+    # TODO(@Ericson2314): Improve with mass rebuild
+    configureScript = {
+        "x86_64-darwin"  = "./Configure darwin64-x86_64-cc";
+        "x86_64-solaris" = "./Configure solaris64-x86_64-gcc";
+      }.${hostPlatform.system} or (
+        if hostPlatform == buildPlatform
+          then "./config"
+        else if hostPlatform.isMinGW
+          then "./Configure mingw${toString hostPlatform.parsed.cpu.bits}"
+        else if hostPlatform.isLinux
+          then "./Configure linux-generic${toString hostPlatform.parsed.cpu.bits}"
+        else
+          throw "Not sure what configuration to use for ${hostPlatform.config}"
+      );
+
+    # TODO(@Ericson2314): Make unconditional on mass rebuild
+    ${if buildPlatform != hostPlatform then "configurePlatforms" else null} = [];
+
+    preConfigure = ''
+      patchShebangs Configure
+    '';
 
     configureFlags = [
       "shared"
@@ -49,7 +67,7 @@ let
       "-DHAVE_CRYPTODEV"
       "-DUSE_CRYPTODEV_DIGESTS"
     ] ++ stdenv.lib.optional enableSSL2 "enable-ssl2"
-      ++ stdenv.lib.optional (versionAtLeast version "1.1.0" && stdenv.isAarch64) "no-afalgeng";
+      ++ stdenv.lib.optional (versionAtLeast version "1.1.0" && hostPlatform.isAarch64) "no-afalgeng";
 
     makeFlags = [ "MANDIR=$(man)/share/man" ];
 
@@ -83,18 +101,6 @@ let
       fi
     '';
 
-    crossAttrs = {
-      # upstream patch: https://rt.openssl.org/Ticket/Display.html?id=2558
-      postPatch = ''
-         sed -i -e 's/[$][(]CROSS_COMPILE[)]windres/$(WINDRES)/' Makefile.shared
-      '';
-      preConfigure=''
-        # It's configure does not like --build or --host
-        export configureFlags="${concatStringsSep " " (configureFlags ++ [ opensslCrossSystem ])}"
-      '';
-      configureScript = "./Configure";
-    };
-
     meta = {
       homepage = https://www.openssl.org/;
       description = "A cryptographic library that implements the SSL and TLS protocols";
@@ -107,13 +113,13 @@ let
 in {
 
   openssl_1_0_2 = common {
-    version = "1.0.2m";
-    sha256 = "03vvlfnxx4lhxc83ikfdl6jqph4h52y7lb7li03va6dkqrgg2vwc";
+    version = "1.0.2o";
+    sha256 = "0kcy13l701054nhpbd901mz32v1kn4g311z0nifd83xs2jbmqgzc";
   };
 
   openssl_1_1_0 = common {
-    version = "1.1.0g";
-    sha256 = "1bvka2wf33w2vxv7yw578nnjqyhz2b3chvfb0l4k2ffscw950kfy";
+    version = "1.1.0h";
+    sha256 = "05x509lccqjscgyi935z809pwfm708islypwhmjnb6cyvrn64daq";
   };
 
 }
diff --git a/pkgs/development/libraries/opensubdiv/default.nix b/pkgs/development/libraries/opensubdiv/default.nix
index 91899ad8da43..62c093f310fb 100644
--- a/pkgs/development/libraries/opensubdiv/default.nix
+++ b/pkgs/development/libraries/opensubdiv/default.nix
@@ -1,36 +1,44 @@
-{ lib, stdenv, fetchurl, fetchFromGitHub, cmake, pkgconfig, xorg, mesa_glu
-, mesa_noglu, glew, ocl-icd, python3
+{ lib, stdenv, fetchurl, fetchFromGitHub, cmake, pkgconfig, xorg, libGLU
+, libGL, glew, ocl-icd, python3
 , cudaSupport ? false, cudatoolkit
+, darwin
 }:
 
 stdenv.mkDerivation rec {
   name = "opensubdiv-${version}";
-  version = "3.3.0";
+  version = "3.3.1";
 
   src = fetchFromGitHub {
     owner = "PixarAnimationStudios";
     repo = "OpenSubdiv";
     rev = "v${lib.replaceChars ["."] ["_"] version}";
-    sha256 = "0wpjwfik4q9s4r30hndhzmfyzv968mmg5lgng0123l07mn47d2yl";
+    sha256 = "1s96038yvf8wch5gv537iigqflxx7rh9wwn3wlrk8f9yfdwv1mk1";
   };
 
   outputs = [ "out" "dev" ];
 
   buildInputs =
-    [ cmake pkgconfig mesa_glu mesa_noglu ocl-icd python3
+    [ cmake pkgconfig libGLU libGL python3
       # FIXME: these are not actually needed, but the configure script wants them.
       glew xorg.libX11 xorg.libXrandr xorg.libXxf86vm xorg.libXcursor
       xorg.libXinerama xorg.libXi
     ]
+    ++ lib.optional (!stdenv.isDarwin) ocl-icd
+    ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [OpenCL Cocoa CoreVideo IOKit AppKit AGL ])
     ++ lib.optional cudaSupport cudatoolkit;
 
   cmakeFlags =
     [ "-DNO_TUTORIALS=1"
       "-DNO_REGRESSION=1"
       "-DNO_EXAMPLES=1"
+      "-DNO_METAL=1" # don’t have metal in apple sdk
+    ] ++ lib.optionals (!stdenv.isDarwin) [
       "-DGLEW_INCLUDE_DIR=${glew.dev}/include"
       "-DGLEW_LIBRARY=${glew.dev}/lib"
-    ] ++ lib.optional cudaSupport "-DOSD_CUDA_NVCC_FLAGS=--gpu-architecture=compute_30";
+    ] ++ lib.optionals cudaSupport [
+      "-DOSD_CUDA_NVCC_FLAGS=--gpu-architecture=compute_30"
+      "-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/cc"
+    ];
 
   enableParallelBuilding = true;
 
@@ -39,7 +47,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "An Open-Source subdivision surface library";
     homepage = http://graphics.pixar.com/opensubdiv;
-    platforms = lib.platforms.linux;
+    platforms = lib.platforms.unix;
     maintainers = [ lib.maintainers.eelco ];
     license = lib.licenses.asl20;
   };
diff --git a/pkgs/development/libraries/openvdb/default.nix b/pkgs/development/libraries/openvdb/default.nix
index 2940ab45eaaf..be28c84e3e42 100644
--- a/pkgs/development/libraries/openvdb/default.nix
+++ b/pkgs/development/libraries/openvdb/default.nix
@@ -3,13 +3,13 @@
 stdenv.mkDerivation rec
 {
   name = "openvdb-${version}";
-  version = "4.0.2";
+  version = "5.1.0";
 
   src = fetchFromGitHub {
     owner = "dreamworksanimation";
     repo = "openvdb";
     rev = "v${version}";
-    sha256 = "0kqlsfa9rdpxpw7v61vfknvs11axh196ilqk6bnyyfkslmmcak45";
+    sha256 = "1als53dnbnwa66k16vy95h1rhpdzz6i80c0gc2g3i17qbasl6ni5";
   };
 
   outputs = [ "out" ];
@@ -32,7 +32,7 @@ stdenv.mkDerivation rec
     LOG4CPLUS_LIB=
     BLOSC_INCLUDE_DIR=${c-blosc}/include/
     BLOSC_LIB_DIR=${c-blosc}/lib/
-    '';
+  '';
 
   installFlags = ''DESTDIR=$(out)'';
 
@@ -43,7 +43,7 @@ stdenv.mkDerivation rec
     description = "An open framework for voxel";
     homepage = "http://www.openvdb.org";
     maintainers = [ maintainers.guibou ];
-    platforms = platforms.all;
+    platforms = platforms.linux;
     license = licenses.mpl20;
   };
 }
diff --git a/pkgs/development/libraries/openwsman/default.nix b/pkgs/development/libraries/openwsman/default.nix
index b179ca8803c1..1aa0f2684571 100644
--- a/pkgs/development/libraries/openwsman/default.nix
+++ b/pkgs/development/libraries/openwsman/default.nix
@@ -1,16 +1,20 @@
-{ fetchurl, stdenv, autoconf, automake, libtool, pkgconfig, libxml2, curl, cmake, pam, sblim-sfcc }:
+{ stdenv, fetchFromGitHub, cmake, pkgconfig
+, curl, libxml2, pam, sblim-sfcc }:
 
 stdenv.mkDerivation rec {
-  version = "2.6.0";
   name = "openwsman-${version}";
+  version = "2.6.5";
 
-  src = fetchurl {
-    url = "https://github.com/Openwsman/openwsman/archive/v${version}.tar.gz";
-    sha256 = "0gw2dsjxzpchg3s85kplwgp9xhd9l7q4fh37iy7r203pvir4k6s4";
+  src = fetchFromGitHub {
+    owner  = "Openwsman";
+    repo   = "openwsman";
+    rev    = "v${version}";
+    sha256 = "1r0zslgpcr4m20car4s3hsccy10xcb39qhpw3dhpjv42xsvvs5xv";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ autoconf automake libtool libxml2 curl cmake pam sblim-sfcc ];
+  nativeBuildInputs = [ cmake pkgconfig ];
+
+  buildInputs = [ curl libxml2 pam sblim-sfcc ];
 
   cmakeFlags = [
     "-DCMAKE_BUILD_RUBY_GEM=no"
@@ -22,18 +26,13 @@ stdenv.mkDerivation rec {
 
   configureFlags = "--disable-more-warnings";
 
-  meta = {
-    description = "Openwsman server implementation and client api with bindings";
-
-    homepage = https://github.com/Openwsman/openwsman;
-    downloadPage = "https://github.com/Openwsman/openwsman/releases";
-
-    maintainers = [ stdenv.lib.maintainers.deepfire ];
-
-    license = stdenv.lib.licenses.bsd3;
-
-    platforms = stdenv.lib.platforms.gnu;  # arbitrary choice
-
+  meta = with stdenv.lib; {
+    description  = "Openwsman server implementation and client API with bindings";
+    downloadPage = https://github.com/Openwsman/openwsman/releases;
+    homepage     = https://openwsman.github.io;
+    license      = licenses.bsd3;
+    maintainers  = with maintainers; [ deepfire ];
+    platforms    = platforms.linux; # PAM is not available on Darwin
     inherit version;
   };
 }
diff --git a/pkgs/development/libraries/openzwave/default.nix b/pkgs/development/libraries/openzwave/default.nix
new file mode 100644
index 000000000000..63c51996b227
--- /dev/null
+++ b/pkgs/development/libraries/openzwave/default.nix
@@ -0,0 +1,56 @@
+{ stdenv, fetchFromGitHub
+, doxygen, fontconfig, graphviz-nox, libxml2, pkgconfig, which
+, systemd }:
+
+let
+  version = "2018-04-04";
+
+in stdenv.mkDerivation rec {
+  name = "openzwave-${version}";
+
+  src = fetchFromGitHub {
+    owner = "OpenZWave";
+    repo = "open-zwave";
+    rev = "ab5fe966fee882bb9e8d78a91db892a60a1863d9";
+    sha256 = "0yby8ygzjn5zp5vhysxaadbzysqanwd2zakz379299qs454pr2h9";
+  };
+
+  nativeBuildInputs = [ doxygen fontconfig graphviz-nox libxml2 pkgconfig which ];
+
+  buildInputs = [ systemd ];
+
+  enableParallelBuilding = true;
+
+  installPhase = ''
+    runHook preInstall
+
+    DESTDIR=$out PREFIX= pkgconfigdir=lib/pkgconfig make install $installFlags
+
+    runHook postInstall
+  '';
+
+  FONTCONFIG_FILE="${fontconfig.out}/etc/fonts/fonts.conf";
+  FONTCONFIG_PATH="${fontconfig.out}/etc/fonts/";
+
+  postPatch = ''
+    substituteInPlace cpp/src/Options.cpp \
+      --replace /etc/openzwave $out/etc/openzwave
+  '';
+
+  fixupPhase = ''
+    substituteInPlace $out/lib/pkgconfig/libopenzwave.pc \
+      --replace prefix= prefix=$out \
+      --replace dir=    dir=$out
+
+    substituteInPlace $out/bin/ozw_config \
+      --replace pcfile=${pkgconfig} pcfile=$out
+  '';
+
+  meta = with stdenv.lib; {
+    description = "C++ library to control Z-Wave Networks via a USB Z-Wave Controller";
+    homepage = http://www.openzwave.net/;
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ etu ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/oracle-instantclient/default.nix b/pkgs/development/libraries/oracle-instantclient/default.nix
index d0085752623d..1c629c137796 100644
--- a/pkgs/development/libraries/oracle-instantclient/default.nix
+++ b/pkgs/development/libraries/oracle-instantclient/default.nix
@@ -4,10 +4,12 @@
 
 assert odbcSupport -> unixODBC != null;
 
-let optional = stdenv.lib.optional;
-    optionalString  = stdenv.lib.optionalString;
-    requireSource = version: part: hash: (requireFile rec {
-      name = "oracle-instantclient12.1-${part}-${version}.x86_64.rpm";
+with stdenv.lib;
+
+let
+    baseVersion = "12.2";
+    requireSource = version: rel: part: hash: (requireFile rec {
+      name = "oracle-instantclient${baseVersion}-${part}-${version}-${rel}.x86_64.rpm";
       message = ''
         This Nix expression requires that ${name} already
         be part of the store. Download the file
@@ -24,13 +26,13 @@ let optional = stdenv.lib.optional;
       sha256 = hash;
     });
 in stdenv.mkDerivation rec {
-  version = "12.1.0.2.0-1";
+  version = "${baseVersion}.0.1.0";
   name = "oracle-instantclient-${version}";
 
-  srcBase = (requireSource version "basic" "f0e51e247cc3f210b950fd939ab1f696de9ca678d1eb179ba49ac73acb9a20ed");
-  srcDevel = (requireSource version "devel" "13b638882f07d6cfc06c85dc6b9eb5cac37064d3d594194b6b09d33483a08296");
-  srcSqlplus = (requireSource version "sqlplus" "16d87w1lii0ag47c8srnr7v4wfm9q4hy6gka8m3v6gp9cc065vam");
-  srcOdbc = optionalString odbcSupport (requireSource version "odbc" "d3aa1a4957a2f15ced05921dab551ba823aa7925d8fcb58d5b3a7f624e4df063");
+  srcBase = (requireSource version "1" "basic" "43c4bfa938af741ae0f9964a656f36a0700849f5780a2887c8e9f1be14fe8b66");
+  srcDevel = (requireSource version "1" "devel" "4c7ad8d977f9f908e47c5e71ce56c2a40c7dc83cec8a5c106b9ff06d45bb3442");
+  srcSqlplus = (requireSource version "1" "sqlplus" "303e82820a10f78e401e2b07d4eebf98b25029454d79f06c46e5f9a302ce5552");
+  srcOdbc = optionalString odbcSupport (requireSource version "2" "odbc" "e870c84d2d4be6f77c0760083b82b7ffbb15a4bf5c93c4e6c84f36d6ed4dfdf1");
 
   buildInputs = [ glibc patchelf rpmextract ] ++
     optional odbcSupport unixODBC;
@@ -41,15 +43,13 @@ in stdenv.mkDerivation rec {
     ${rpmextract}/bin/rpmextract "${srcBase}"
     ${rpmextract}/bin/rpmextract "${srcDevel}"
     ${rpmextract}/bin/rpmextract "${srcSqlplus}"
-    ${optionalString odbcSupport ''
-        ${rpmextract}/bin/rpmextract "${srcOdbc}"
-    ''}
-
+    '' + optionalString odbcSupport ''${rpmextract}/bin/rpmextract ${srcOdbc}
+    '' + ''
     mkdir -p "$out/"{bin,include,lib,"share/${name}/demo/"}
-    mv "usr/share/oracle/12.1/client64/demo/"* "$out/share/${name}/demo/"
-    mv "usr/include/oracle/12.1/client64/"* "$out/include/"
-    mv "usr/lib/oracle/12.1/client64/lib/"* "$out/lib/"
-    mv "usr/lib/oracle/12.1/client64/bin/"* "$out/bin/"
+    mv "usr/share/oracle/${baseVersion}/client64/demo/"* "$out/share/${name}/demo/"
+    mv "usr/include/oracle/${baseVersion}/client64/"* "$out/include/"
+    mv "usr/lib/oracle/${baseVersion}/client64/lib/"* "$out/lib/"
+    mv "usr/lib/oracle/${baseVersion}/client64/bin/"* "$out/bin/"
     ln -s "$out/bin/sqlplus" "$out/bin/sqlplus64"
 
     for lib in $out/lib/lib*.so; do
@@ -84,7 +84,7 @@ in stdenv.mkDerivation rec {
       command line SQL client.
     '';
     license = licenses.unfree;
-    platforms = platforms.linux;
+    platforms = [ "x86_64-linux" ];
     maintainers = with maintainers; [ pesterhazy ];
   };
 }
diff --git a/pkgs/development/libraries/ortp/default.nix b/pkgs/development/libraries/ortp/default.nix
index f05811f34813..5dc5df8e95b9 100644
--- a/pkgs/development/libraries/ortp/default.nix
+++ b/pkgs/development/libraries/ortp/default.nix
@@ -2,14 +2,14 @@
 
 stdenv.mkDerivation rec {
   baseName = "ortp";
-  version = "0.27.0";
+  version = "1.0.2";
   name = "${baseName}-${version}";
 
   src = fetchFromGitHub {
     owner = "BelledonneCommunications";
     repo = "${baseName}";
     rev = "${version}";
-    sha256 = "0gjaaph4pamay9gn1yn7ky5wyzhj93r53rwak7h8s48vf08fqyv7";
+    sha256 = "12cwv593bsdnxs0zfcp07vwyk7ghlz2wv7vdbs1ksv293w3vj2rv";
   };
 
   buildInputs = [ bctoolbox ];
diff --git a/pkgs/development/libraries/osm-gps-map/default.nix b/pkgs/development/libraries/osm-gps-map/default.nix
index 63c882076b9d..febba5d5703f 100644
--- a/pkgs/development/libraries/osm-gps-map/default.nix
+++ b/pkgs/development/libraries/osm-gps-map/default.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
   buildInputs = [
     cairo glib gobjectIntrospection
   ] ++ (with gnome3; [
-    gnome_common gtk libsoup
+    gnome-common gtk libsoup
   ]);
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/p11-kit/default.nix b/pkgs/development/libraries/p11-kit/default.nix
index 34182cd5a847..a3d4857d57a9 100644
--- a/pkgs/development/libraries/p11-kit/default.nix
+++ b/pkgs/development/libraries/p11-kit/default.nix
@@ -3,13 +3,13 @@
 
 stdenv.mkDerivation rec {
   name = "p11-kit-${version}";
-  version = "0.23.7";
+  version = "0.23.10";
 
   src = fetchFromGitHub {
     owner = "p11-glue";
     repo = "p11-kit";
     rev = version;
-    sha256 = "1l8sg0g74k2mk0y6vz19hc103dzizxa0h579gdhvxifckglb01hy";
+    sha256 = "0n0wqv028flzvnxllqv8i6x9nv705csl7ddzi0fzvppc9fp2yinp";
   };
 
   outputs = [ "out" "dev"];
diff --git a/pkgs/development/libraries/pango/default.nix b/pkgs/development/libraries/pango/default.nix
index 85032677aae3..d880d41c7084 100644
--- a/pkgs/development/libraries/pango/default.nix
+++ b/pkgs/development/libraries/pango/default.nix
@@ -1,19 +1,19 @@
 { stdenv, fetchurl, fetchpatch, pkgconfig, libXft, cairo, harfbuzz
-, libintlOrEmpty, gobjectIntrospection, darwin
+, libintl, gobjectIntrospection, darwin
 }:
 
 with stdenv.lib;
 
 let
   ver_maj = "1.40";
-  ver_min = "12";
+  ver_min = "14";
 in
 stdenv.mkDerivation rec {
   name = "pango-${ver_maj}.${ver_min}";
 
   src = fetchurl {
     url = "mirror://gnome/sources/pango/${ver_maj}/${name}.tar.xz";
-    sha256 = "75f1a9a8e4e2b28cbc078b50c1fa927ee4ded994d1ade97c5603e2d1f3161cfc";
+    sha256 = "90af1beaa7bf9e4c52db29ec251ec4fd0a8f2cc185d521ad1f88d01b3a6a17e3";
   };
 
   outputs = [ "bin" "dev" "out" "devdoc" ];
@@ -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/pangolin/default.nix b/pkgs/development/libraries/pangolin/default.nix
index 09cbd86eb92b..6fb123f50949 100644
--- a/pkgs/development/libraries/pangolin/default.nix
+++ b/pkgs/development/libraries/pangolin/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchFromGitHub, cmake, pkgconfig, doxygen, mesa_noglu, glew
+{ stdenv, lib, fetchFromGitHub, cmake, pkgconfig, doxygen, libGL, glew
 , xorg , ffmpeg, python3 , libjpeg, libpng, libtiff, eigen
 , Carbon ? null, Cocoa ? null
 }:
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ cmake pkgconfig doxygen ]; 
 
   buildInputs = [ 
-    mesa_noglu 
+    libGL 
     glew 
     xorg.libX11 
     ffmpeg 
diff --git a/pkgs/development/libraries/parquet-cpp/default.nix b/pkgs/development/libraries/parquet-cpp/default.nix
new file mode 100644
index 000000000000..e281e604380b
--- /dev/null
+++ b/pkgs/development/libraries/parquet-cpp/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, symlinkJoin, fetchurl, arrow-cpp, boost, cmake, gtest, snappy, thrift, zlib }:
+
+stdenv.mkDerivation rec {
+  name = "parquet-cpp-${version}";
+  version = "1.4.0";
+
+  src = fetchurl {
+    url = "https://github.com/apache/parquet-cpp/archive/apache-${name}.tar.gz";
+    sha256 = "1kn7pjzi5san5f05qbl8l8znqsa3f9cq9bflfr4s2jfwr7k9p2aj";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ boost ];
+
+  preConfigure = ''
+    substituteInPlace cmake_modules/FindThrift.cmake --replace CMAKE_STATIC_LIBRARY CMAKE_SHARED_LIBRARY
+    substituteInPlace cmake_modules/FindSnappy.cmake --replace CMAKE_STATIC_LIBRARY CMAKE_SHARED_LIBRARY
+  '';
+
+  ARROW_HOME = arrow-cpp;
+  THRIFT_HOME = thrift;
+  GTEST_HOME = gtest;
+  SNAPPY_HOME = symlinkJoin { name="snappy-wrap"; paths = [ snappy snappy.dev ]; };
+  ZLIB_HOME = symlinkJoin { name="zlib-wrap"; paths = [ zlib.dev zlib.static ]; };
+
+  cmakeFlags = [
+    "-DPARQUET_BUILD_BENCHMARKS=OFF"
+  ];
+
+  meta = {
+    description = "A C++ library to read and write the Apache Parquet columnar data format";
+    homepage = http://parquet.apache.org;
+    license = stdenv.lib.licenses.asl20;
+    platforms = stdenv.lib.platforms.unix;
+    maintainers = with stdenv.lib.maintainers; [ veprbl ];
+  };
+}
diff --git a/pkgs/development/libraries/partio/default.nix b/pkgs/development/libraries/partio/default.nix
index 4f93ed562115..b45ed2966916 100644
--- a/pkgs/development/libraries/partio/default.nix
+++ b/pkgs/development/libraries/partio/default.nix
@@ -1,30 +1,28 @@
-{ stdenv, fetchFromGitHub, unzip, cmake, freeglut, mesa, zlib, swig, python, doxygen, xorg }:
+{ stdenv, fetchFromGitHub, unzip, cmake, freeglut, libGLU_combined, zlib, swig, python, doxygen, xorg }:
 
 stdenv.mkDerivation rec
 {
   name = "partio-${version}";
-  version = "1.1.0";
+  version = "2018-03-01";
 
   src = fetchFromGitHub {
     owner = "wdas";
     repo = "partio";
-    rev = "v${version}";
-    sha256 = "0z7n5ay21ca7g7xb80v6jmr96x9k7vm7zawawvmx71yj32rg1n34";
+    rev = "8b6ea0d20f1ab77cd7f18390999251e60932de4a";
+    sha256 = "16sdj103v02l2dgq9y9cna9jakafabz9jxzdxsd737ir6wn10ksb";
   };
 
   outputs = [ "dev" "out" "lib" ];
 
-  buildInputs = [ unzip cmake freeglut mesa zlib swig python doxygen xorg.libXi xorg.libXmu ];
+  nativeBuildInputs = [ unzip cmake doxygen ];
+  buildInputs = [ freeglut libGLU_combined zlib swig python xorg.libXi xorg.libXmu ];
 
   enableParallelBuilding = true;
 
   buildPhase = ''
-    sed 's/ADD_LIBRARY (partio /ADD_LIBRARY (partio SHARED /' -i ../src/lib/CMakeLists.txt
-    CXXFLAGS="-std=c++11" cmake .
     make partio
 
     mkdir $dev
-    mkdir -p $lib/lib
     mkdir $out
       '';
 
@@ -32,19 +30,16 @@ stdenv.mkDerivation rec
   # Sexpr support
 
   installPhase = ''
-    mkdir $dev/lib
-    mkdir -p $dev/include/partio
-
-    mv lib/libpartio.so $lib/lib
-
-    mv ../src/lib/* $dev/include/partio
+    make install prefix=$out
+    mkdir $dev/include/partio
+    mv $dev/include/*.h $dev/include/partio
   '';
 
   meta = with stdenv.lib; {
     description = "C++ (with python bindings) library for easily reading/writing/manipulating common animation particle formats such as PDB, BGEO, PTC";
     homepage = "https://www.disneyanimation.com/technology/partio.html";
     license = licenses.bsd3;
-    platforms = platforms.all;
+    platforms = platforms.linux;
     maintainers = [ maintainers.guibou ];
   };
 }
diff --git a/pkgs/development/libraries/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix
index e6055151301c..973798b849bc 100644
--- a/pkgs/development/libraries/pcre/default.nix
+++ b/pkgs/development/libraries/pcre/default.nix
@@ -24,8 +24,7 @@ in stdenv.mkDerivation rec {
 
   outputs = [ "bin" "dev" "out" "doc" "man" ];
 
-  configureFlags = [
-    "--enable-jit"
+  configureFlags = optional (!hostPlatform.isRiscV) "--enable-jit" ++ [
     "--enable-unicode-properties"
     "--disable-cpp"
   ]
@@ -33,6 +32,13 @@ in stdenv.mkDerivation rec {
 
   buildInputs = optional (hostPlatform.libc == "msvcrt") windows.mingw_w64_pthreads;
 
+  # 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/pcre/stacksize-detection.patch b/pkgs/development/libraries/pcre/stacksize-detection.patch
new file mode 100644
index 000000000000..4bc97069b1e2
--- /dev/null
+++ b/pkgs/development/libraries/pcre/stacksize-detection.patch
@@ -0,0 +1,16 @@
+diff --git a/pcre_exec.c b/pcre_exec.c
+--- a/pcre_exec.c
++++ b/pcre_exec.c
+@@ -509,6 +509,12 @@
+                  (e.g. stopped by repeated call or recursion limit)
+ */
+ 
++#ifdef __GNUC__
++static int
++match(REGISTER PCRE_PUCHAR eptr, REGISTER const pcre_uchar *ecode,
++  PCRE_PUCHAR mstart, int offset_top, match_data *md, eptrblock *eptrb,
++  unsigned int rdepth) __attribute__((noinline,noclone));
++#endif
+ static int
+ match(REGISTER PCRE_PUCHAR eptr, REGISTER const pcre_uchar *ecode,
+   PCRE_PUCHAR mstart, int offset_top, match_data *md, eptrblock *eptrb,
diff --git a/pkgs/development/libraries/pcre2/default.nix b/pkgs/development/libraries/pcre2/default.nix
index 3b698ff74cfa..9603e45a8b44 100644
--- a/pkgs/development/libraries/pcre2/default.nix
+++ b/pkgs/development/libraries/pcre2/default.nix
@@ -20,14 +20,21 @@ stdenv.mkDerivation rec {
       url = "https://vcs.pcre.org/pcre2/code/trunk/src/pcre2_ucd.c?view=patch&r1=316&r2=670&sortby=date";
       sha256 = "10yzglvbn7h06hg7zffr5zh378i5jihvx7d5gggkynws79vgwvfr";
       stripLen = 2;
-      addPrefixes = true;
+      extraPrefix = "";
     })
     (fetchpatch {
       name = "CVE-2017-7186-part2.patch";
       url = "https://vcs.pcre.org/pcre2/code/trunk/src/pcre2_internal.h?view=patch&r1=600&r2=670&sortby=date";
       sha256 = "1bggk7vd5hg0bjg96lj4h1lacmr6grq68dm6iz1n7vg3zf7virjn";
       stripLen = 2;
-      addPrefixes = true;
+      extraPrefix = "";
+    })
+    (fetchpatch {
+      name = "CVE-2017-8786.patch";
+      url = "https://vcs.pcre.org/pcre2/code/trunk/src/pcre2test.c?r1=692&r2=697&view=patch";
+      sha256 = "1c629nzrk4il2rfclwyc1a373q58m4q9ys9wr91zhl4skfk7x19b";
+      stripLen = 2;
+      extraPrefix = "";
     })
   ];
 
diff --git a/pkgs/development/libraries/phonon/default.nix b/pkgs/development/libraries/phonon/default.nix
index 2cb2dde33f7e..8e1ee8196c30 100644
--- a/pkgs/development/libraries/phonon/default.nix
+++ b/pkgs/development/libraries/phonon/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchurl, cmake, mesa, pkgconfig, libpulseaudio
+{ stdenv, lib, fetchurl, cmake, libGLU_combined, pkgconfig, libpulseaudio
 , qt4 ? null, extra-cmake-modules ? null, qtbase ? null, qttools ? null
 , withQt5 ? false
 , debug ? false }:
@@ -32,7 +32,7 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs =
-    [ mesa libpulseaudio ]
+    [ libGLU_combined libpulseaudio ]
     ++ (if withQt5 then [ qtbase qttools ] else [ qt4 ]);
 
   nativeBuildInputs =
diff --git a/pkgs/development/libraries/physfs/default.nix b/pkgs/development/libraries/physfs/default.nix
index 43bcef0f2d3c..e29af17f35df 100644
--- a/pkgs/development/libraries/physfs/default.nix
+++ b/pkgs/development/libraries/physfs/default.nix
@@ -1,23 +1,41 @@
-{stdenv, fetchurl, cmake}:
+{ stdenv, fetchurl, cmake, doxygen
+, zlib }:
 
-stdenv.mkDerivation rec {
-  name = "physfs-2.0.3";
+let
+  generic = version: sha256:
+  stdenv.mkDerivation rec {
+    name = "physfs-${version}";
 
-  src = fetchurl {
-    url = "${meta.homepage}/downloads/${name}.tar.bz2";
-    sha256 = "0sbbyqzqhyf0g68fcvvv20n3928j0x6ik1njmhn1yigvq2bj11na";
-  };
+    src = fetchurl {
+      url = "${meta.homepage}/downloads/${name}.tar.bz2";
+      inherit sha256;
+    };
+
+    nativeBuildInputs = [ cmake doxygen ];
+
+    buildInputs = [ zlib ];
 
-  nativeBuildInputs = [ cmake ];
+    enableParallelBuilding = true;
 
-  patchPhase = ''
-    sed s,-Werror,, -i CMakeLists.txt
-  '';
+    patchPhase = ''
+      sed s,-Werror,, -i CMakeLists.txt
+    '';
 
-  meta = {
-    homepage = http://icculus.org/physfs/;
-    description = "Library to provide abstract access to various archives";
-    license = stdenv.lib.licenses.free;
-    platforms = stdenv.lib.platforms.linux;
+    doInstallCheck = true;
+
+    installCheckPhase = ''
+      ./test_physfs --version
+    '';
+
+    meta = with stdenv.lib; {
+      homepage = http://icculus.org/physfs/;
+      description = "Library to provide abstract access to various archives";
+      license = licenses.free;
+      platforms = platforms.linux;
+    };
   };
+
+in {
+  physfs_2 = generic "2.0.3" "0sbbyqzqhyf0g68fcvvv20n3928j0x6ik1njmhn1yigvq2bj11na";
+  physfs   = generic "3.0.1" "1wgj2zqpnfbnyyi1i7bq5pshcc9n5cvwlpzp8im67nb8662ryyxp";
 }
diff --git a/pkgs/development/libraries/physics/fastjet/default.nix b/pkgs/development/libraries/physics/fastjet/default.nix
index 93c4320e78a1..0ee68415b89c 100644
--- a/pkgs/development/libraries/physics/fastjet/default.nix
+++ b/pkgs/development/libraries/physics/fastjet/default.nix
@@ -1,15 +1,26 @@
-{ stdenv, fetchurl }:
+{ stdenv, fetchurl, python2 }:
 
 stdenv.mkDerivation rec {
   name = "fastjet-${version}";
-  version = "3.2.0";
+  version = "3.3.0";
 
   src = fetchurl {
     url = "http://fastjet.fr/repo/fastjet-${version}.tar.gz";
-    sha256 = "1qvmab7l4ps5xd1wvmblgpzyhkbs2gff41qgyg7r7b9nlgqjgacn";
+    sha256 = "03x75mmnlw2m0a7669k82rf9a7dgjwygf8wjbk8cdgnb82c5pnp9";
   };
 
-  configureFlags = "--enable-allcxxplugins";
+  buildInputs = [ python2 ];
+
+  postPatch = ''
+    substituteInPlace plugins/SISCone/SISConeBasePlugin.cc \
+      --replace 'structure_of<UserScaleBase::StructureType>()' \
+                'structure_of<UserScaleBase>()'
+  '';
+
+  configureFlags = [
+    "--enable-allcxxplugins"
+    "--enable-pyext"
+    ];
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/physics/geant4/default.nix b/pkgs/development/libraries/physics/geant4/default.nix
index 2c07c1e08580..794d0b24c778 100644
--- a/pkgs/development/libraries/physics/geant4/default.nix
+++ b/pkgs/development/libraries/physics/geant4/default.nix
@@ -25,7 +25,7 @@
 , motif ? null # motif or lesstif
 
 # For enableQT, enableXM, enableOpenGLX11, enableRaytracerX11.
-, mesa   ? null
+, libGLU_combined   ? null
 , xlibsWrapper    ? null
 , libXmu ? null
 }:
@@ -40,7 +40,7 @@ assert enableQT -> qt != null;
 assert enableXM -> motif != null;
 
 # OpenGL/X11 User Interface and Visualisation drivers.
-assert enableQT || enableXM || enableOpenGLX11 || enableRaytracerX11 -> mesa   != null;
+assert enableQT || enableXM || enableOpenGLX11 || enableRaytracerX11 -> libGLU_combined   != null;
 assert enableQT || enableXM || enableOpenGLX11 || enableRaytracerX11 -> xlibsWrapper    != null;
 assert enableQT || enableXM || enableOpenGLX11 || enableRaytracerX11 -> libXmu != null;
 
@@ -81,8 +81,8 @@ let
       };
 
       enableParallelBuilding = true;
-      buildInputs = [ cmake clhep expat zlib xercesc qt motif mesa xlibsWrapper libXmu ];
-      propagatedBuildInputs = [ g4data clhep expat zlib xercesc qt motif mesa xlibsWrapper libXmu ];
+      buildInputs = [ cmake clhep expat zlib xercesc qt motif libGLU_combined xlibsWrapper libXmu ];
+      propagatedBuildInputs = [ g4data clhep expat zlib xercesc qt motif libGLU_combined xlibsWrapper libXmu ];
 
       setupHook = ./setup-hook.sh;
 
diff --git a/pkgs/development/libraries/physics/herwig/default.nix b/pkgs/development/libraries/physics/herwig/default.nix
index 407be5c5e4a4..f3ba8a4a6ff6 100644
--- a/pkgs/development/libraries/physics/herwig/default.nix
+++ b/pkgs/development/libraries/physics/herwig/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "herwig-${version}";
-  version = "7.1.1";
+  version = "7.1.2";
 
   src = fetchurl {
     url = "http://www.hepforge.org/archive/herwig/Herwig-${version}.tar.bz2";
-    sha256 = "13xaykwr7x6mp2bi22wz6dyzx3dxhcv6aw9cg8p29bh9l890g63j";
+    sha256 = "0wr2mmmf5rlvcc6xgdagafm6vb5g6ifvrjc7kd86gs9jip32p29i";
   };
 
   nativeBuildInputs = [ autoconf automake libtool ];
diff --git a/pkgs/development/libraries/physics/lhapdf/default.nix b/pkgs/development/libraries/physics/lhapdf/default.nix
index 1a203172d2c8..93e0fa99c347 100644
--- a/pkgs/development/libraries/physics/lhapdf/default.nix
+++ b/pkgs/development/libraries/physics/lhapdf/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "lhapdf-${version}";
-  version = "6.2.0";
+  version = "6.2.1";
 
   src = fetchurl {
     url = "http://www.hepforge.org/archive/lhapdf/LHAPDF-${version}.tar.gz";
-    sha256 = "0gfjps7v93n0rrdndkhp22d93y892bf76pnzdhqbish0cigkkxph";
+    sha256 = "0bi02xcmq5as0wf0jn6i3hx0qy0hj61m02sbrbzd1gwjhpccwmvd";
   };
 
   buildInputs = [ python2 ];
diff --git a/pkgs/development/libraries/physics/pythia/default.nix b/pkgs/development/libraries/physics/pythia/default.nix
index 94074f6dcb45..eca2807ce153 100644
--- a/pkgs/development/libraries/physics/pythia/default.nix
+++ b/pkgs/development/libraries/physics/pythia/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "pythia-${version}";
-  version = "8.219";
+  version = "8.226";
 
   src = fetchurl {
     url = "http://home.thep.lu.se/~torbjorn/pythia8/pythia${builtins.replaceStrings ["."] [""] version}.tgz";
-    sha256 = "13fhphddl0jir8jyjvj6a9qz14wiv02q9lby8mcdyv8gsw0ir8hy";
+    sha256 = "1jfjkq78d1llrrm2k5pgsl92a5z8af9rx3n83rzv28lxrqdjix4g";
   };
 
   buildInputs = [ boost fastjet hepmc zlib rsync lhapdf ];
diff --git a/pkgs/development/libraries/physics/rivet/default.nix b/pkgs/development/libraries/physics/rivet/default.nix
index 454c868dfcd2..c13b659f792e 100644
--- a/pkgs/development/libraries/physics/rivet/default.nix
+++ b/pkgs/development/libraries/physics/rivet/default.nix
@@ -2,17 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "rivet-${version}";
-  version = "2.5.4";
+  version = "2.6.0";
 
   src = fetchurl {
     url = "http://www.hepforge.org/archive/rivet/Rivet-${version}.tar.bz2";
-    sha256 = "1qi7am60f2l4krd3sbj95mbzfk82lir0wy8z27yr9ncq6qcm48kp";
+    sha256 = "007rwal8wx2k9gs0r6kym6ix0siz0x9l55q9myq41siirpf2jcpv";
   };
 
-  postPatch = "patchShebangs ./src/Analyses/cat_with_lines";
-
-  pythonPath = []; # python wrapper support
-
   patches = [
     ./darwin.patch # configure relies on impure sw_vers to -Dunix
   ];
@@ -31,6 +27,13 @@ stdenv.mkDerivation rec {
   buildInputs = [ hepmc imagemagick python2 latex makeWrapper ];
   propagatedBuildInputs = [ fastjet ghostscript gsl yoda ];
 
+  preConfigure = ''
+    substituteInPlace bin/rivet-buildplugin.in \
+      --replace '"which"' '"${which}/bin/which"' \
+      --replace 'mycxx=' 'mycxx=${stdenv.cc}/bin/${if stdenv.cc.isClang or false then "clang++" else "g++"}  #' \
+      --replace 'mycxxflags="' "mycxxflags=\"-std=c++11 $NIX_CFLAGS_COMPILE $NIX_CXXSTDLIB_COMPILE $NIX_CFLAGS_LINK "
+  '';
+
   preInstall = ''
     substituteInPlace bin/make-plots \
       --replace '"which"' '"${which}/bin/which"' \
@@ -42,10 +45,6 @@ stdenv.mkDerivation rec {
       --replace '"convert"' '"${imagemagick.out}/bin/convert"'
     substituteInPlace bin/rivet \
       --replace '"less"' '"${less}/bin/less"'
-    substituteInPlace bin/rivet-buildplugin \
-      --replace '"which"' '"${which}/bin/which"' \
-      --replace 'mycxx=' 'mycxx=${stdenv.cc}/bin/${if stdenv.cc.isClang or false then "clang++" else "g++"}  #' \
-      --replace 'mycxxflags="' "mycxxflags=\"-std=c++11 $NIX_CFLAGS_COMPILE $NIX_CXXSTDLIB_COMPILE $NIX_CFLAGS_LINK "
     substituteInPlace bin/rivet-mkhtml \
       --replace '"make-plots"' \"$out/bin/make-plots\" \
       --replace '"rivet-cmphistos"' \"$out/bin/rivet-cmphistos\"
diff --git a/pkgs/development/libraries/physics/thepeg/default.nix b/pkgs/development/libraries/physics/thepeg/default.nix
index 7989eb518c78..63db874d8480 100644
--- a/pkgs/development/libraries/physics/thepeg/default.nix
+++ b/pkgs/development/libraries/physics/thepeg/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "thepeg-${version}";
-  version = "2.1.1";
+  version = "2.1.2";
 
   src = fetchurl {
     url = "http://www.hepforge.org/archive/thepeg/ThePEG-${version}.tar.bz2";
-    sha256 = "1082n4q036sah5r4asyl3hpcyc05cymg40dnk3jsdjgv2v0vvc71";
+    sha256 = "0jbz70ax05w3lpjvz71fnfz35rcjp0jry1nyjpa662714xd6f3va";
   };
 
   buildInputs = [ boost fastjet gsl hepmc lhapdf rivet zlib ];
diff --git a/pkgs/development/libraries/physics/yoda/default.nix b/pkgs/development/libraries/physics/yoda/default.nix
index dd1b33056468..7519d0da03fc 100644
--- a/pkgs/development/libraries/physics/yoda/default.nix
+++ b/pkgs/development/libraries/physics/yoda/default.nix
@@ -1,18 +1,19 @@
-{ stdenv, fetchurl, fetchpatch, python2Packages, root, makeWrapper, withRootSupport ? false }:
+{ stdenv, fetchurl, fetchpatch, python2Packages, root, makeWrapper, zlib, withRootSupport ? false }:
 
 stdenv.mkDerivation rec {
   name = "yoda-${version}";
-  version = "1.6.7";
+  version = "1.7.0";
 
   src = fetchurl {
     url = "http://www.hepforge.org/archive/yoda/YODA-${version}.tar.bz2";
-    sha256 = "05jyv5dypa6d4q1m8wm2qycgq1i0bgzwzzm9qqdj0b43ff2kggra";
+    sha256 = "0fyf6ld1klzlfmr5sl1jxzck4a0h14zfkrff8397rn1fqnqbzmmk";
   };
 
   pythonPath = []; # python wrapper support
 
   buildInputs = with python2Packages; [ python numpy matplotlib makeWrapper ]
     ++ stdenv.lib.optional withRootSupport root;
+  propagatedBuildInputs = [ zlib ];
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/pipewire/default.nix b/pkgs/development/libraries/pipewire/default.nix
new file mode 100644
index 000000000000..7e7314c936dd
--- /dev/null
+++ b/pkgs/development/libraries/pipewire/default.nix
@@ -0,0 +1,50 @@
+{ stdenv, fetchFromGitHub, meson, ninja, pkgconfig, doxygen, graphviz, valgrind
+, glib, dbus, gst_all_1, v4l_utils, alsaLib, ffmpeg, libjack2, libudev, libva, xorg
+, sbc, SDL2, makeFontsConf, freefont_ttf
+}:
+
+let
+  version = "0.1.9";
+
+  fontsConf = makeFontsConf {
+    fontDirectories = [ freefont_ttf ];
+  };
+in stdenv.mkDerivation rec {
+  name = "pipewire-${version}";
+
+  src = fetchFromGitHub {
+    owner = "PipeWire";
+    repo = "pipewire";
+    rev = version;
+    sha256 = "0r9mgwbggnnijhdz49fnv0qdka364xn1h8yml2jakyqpfrm3i2nm";
+  };
+
+  outputs = [ "out" "dev" "doc" ];
+
+  nativeBuildInputs = [
+    meson ninja pkgconfig doxygen graphviz valgrind
+  ];
+  buildInputs = [
+    glib dbus gst_all_1.gst-plugins-base gst_all_1.gstreamer v4l_utils
+    alsaLib ffmpeg libjack2 libudev libva xorg.libX11 sbc SDL2
+  ];
+
+  mesonFlags = [
+    "-Denable_docs=true"
+    "-Denable_gstreamer=true"
+  ];
+
+  PKG_CONFIG_SYSTEMD_SYSTEMDUSERUNITDIR = "lib/systemd/user";
+
+  FONTCONFIG_FILE = fontsConf; # Fontconfig error: Cannot load default config file
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "Server and user space API to deal with multimedia pipelines";
+    homepage = https://pipewire.org/;
+    license = licenses.lgpl21;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ jtojnar ];
+  };
+}
diff --git a/pkgs/development/libraries/pixman/default.nix b/pkgs/development/libraries/pixman/default.nix
index dc378711d36b..e70ffc3eb2f1 100644
--- a/pkgs/development/libraries/pixman/default.nix
+++ b/pkgs/development/libraries/pixman/default.nix
@@ -1,16 +1,25 @@
-{ fetchurl, stdenv, pkgconfig, libpng, glib /*just passthru*/ }:
+{ stdenv, fetchurl, fetchpatch, autoconf, automake, libtool, autoreconfHook, pkgconfig, libpng, glib /*just passthru*/ }:
 
 stdenv.mkDerivation rec {
-  name = "pixman-0.34.0";
+  name = "pixman-${version}";
+  version = "0.34.0";
 
   src = fetchurl {
     url = "mirror://xorg/individual/lib/${name}.tar.bz2";
     sha256 = "184lazwdpv67zrlxxswpxrdap85wminh1gmq1i5lcz6iycw39fir";
   };
 
-  patches = [];
+  patches = stdenv.lib.optionals stdenv.cc.isClang [
+    (fetchpatch {
+      name = "builtin-shuffle.patch";
+      url = https://patchwork.freedesktop.org/patch/177506/raw;
+      sha256 = "0rvraq93769dy2im2m022rz99fcdxprgc2fbmasnddcwrqy1x3xr";
+    })
+  ];
+
+  nativeBuildInputs = [ pkgconfig ]
+    ++ stdenv.lib.optionals stdenv.cc.isClang [ autoconf automake libtool autoreconfHook ];
 
-  nativeBuildInputs = [ pkgconfig ];
   buildInputs = stdenv.lib.optional doCheck libpng;
 
   configureFlags = stdenv.lib.optional stdenv.isArm "--disable-arm-iwmmxt";
diff --git a/pkgs/development/libraries/pkcs11helper/default.nix b/pkgs/development/libraries/pkcs11helper/default.nix
index 9d7d7552cfc7..1a1bb1800cf2 100644
--- a/pkgs/development/libraries/pkcs11helper/default.nix
+++ b/pkgs/development/libraries/pkcs11helper/default.nix
@@ -2,20 +2,22 @@
 
 stdenv.mkDerivation rec {
   name = "pkcs11-helper-${version}";
-  version = "1.21";
+  version = "1.22";
 
   src = fetchFromGitHub {
     owner = "OpenSC";
     repo = "pkcs11-helper";
     rev = "${name}";
-    sha256 = "17a2cssycl7fh44xikmhszigx57vvn0h2sjsnmsy3772kfj796b1";
+    sha256 = "01v3zv6sr5phqhr2f21fl2rmcnmkp9518dkq82g1v2y9ysjksg7q";
   };
 
   nativeBuildInputs = [ autoreconfHook pkgconfig ];
   buildInputs = [ openssl ];
 
+  enableParallelBuilding = true;
+
   meta = with stdenv.lib; {
-    homepage = https://www.opensc-project.org/opensc/wiki/pkcs11-helper;
+    homepage = https://github.com/OpenSC/pkcs11-helper;
     license = with licenses; [ bsd3 gpl2 ];
     description = "Library that simplifies the interaction with PKCS#11 providers";
     platforms = platforms.unix;
diff --git a/pkgs/development/libraries/plib/default.nix b/pkgs/development/libraries/plib/default.nix
index 4030be2996cc..c9e8c632c7f1 100644
--- a/pkgs/development/libraries/plib/default.nix
+++ b/pkgs/development/libraries/plib/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, fetchpatch, stdenv, mesa, freeglut, SDL
+{ fetchurl, fetchpatch, stdenv, libGLU_combined, freeglut, SDL
 , libXi, libSM, libXmu, libXext, libX11 }:
 
 stdenv.mkDerivation rec {
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
   ];
 
   propagatedBuildInputs = [
-    mesa freeglut SDL
+    libGLU_combined freeglut SDL
 
     # The following libs ought to be propagated build inputs of Mesa.
     libXi libSM libXmu libXext libX11
diff --git a/pkgs/development/libraries/png++/default.nix b/pkgs/development/libraries/png++/default.nix
index 6ca4734a4f7d..ef4b3ea7e010 100644
--- a/pkgs/development/libraries/png++/default.nix
+++ b/pkgs/development/libraries/png++/default.nix
@@ -21,13 +21,17 @@ stdenv.mkDerivation rec {
 
   postCheck = "cat test/test.log";
 
-  buildInputs = [ ]
-    ++ stdenv.lib.optional docSupport doxygen;
+  buildInputs = stdenv.lib.optional docSupport doxygen;
 
   propagatedBuildInputs = [ libpng ];
 
-  makeFlags = [ "PREFIX=\${out}" ]
-    ++ stdenv.lib.optional docSupport "docs";
+  preConfigure = stdenv.lib.optionalString stdenv.isDarwin ''
+    substituteInPlace error.hpp --replace "#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE" "#if (__clang__ || _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE"
+  '' + ''
+    sed "s|\(PNGPP := .\)|PREFIX := ''${out}\n\\1|" -i Makefile
+  '';
+
+  makeFlags = stdenv.lib.optional docSupport "docs";
 
   enableParallelBuilding = true;
 
@@ -35,7 +39,7 @@ stdenv.mkDerivation rec {
     homepage = http://www.nongnu.org/pngpp/;
     description = "C++ wrapper for libpng library";
     license = licenses.bsd3;
-    platforms = platforms.linux;
+    platforms = platforms.unix;
     maintainers = [ maintainers.ramkromberg ];
   };
 }
diff --git a/pkgs/development/libraries/poco/default.nix b/pkgs/development/libraries/poco/default.nix
index 0f971cff64d4..d44bc78a533d 100644
--- a/pkgs/development/libraries/poco/default.nix
+++ b/pkgs/development/libraries/poco/default.nix
@@ -1,21 +1,20 @@
-{ stdenv, fetchurl, cmake, pkgconfig, zlib, pcre, expat, sqlite, openssl, unixODBC, libmysql }:
+{ stdenv, fetchurl, cmake, pkgconfig, zlib, pcre, expat, sqlite, openssl, unixODBC, mysql }:
 
 stdenv.mkDerivation rec {
   name = "poco-${version}";
 
-  version = "1.7.8";
+  version = "1.9.0";
 
   src = fetchurl {
     url = "https://pocoproject.org/releases/${name}/${name}-all.tar.gz";
-    sha256 = "17y6kvj4qdpb3p1im8n9qfylfh4bd2xsvbpn24jv97x7f146nhjf";
+    sha256 = "11z1i0drbacs7c7d5virc3kz7wh79svd06iffh8j6giikl7vz1q3";
   };
 
   nativeBuildInputs = [ cmake pkgconfig ];
 
-  buildInputs = [ zlib pcre expat sqlite openssl unixODBC libmysql ];
+  buildInputs = [ zlib pcre expat sqlite openssl unixODBC mysql.connector-c ];
 
   cmakeFlags = [
-    "-DMYSQL_INCLUDE_DIR=${libmysql.dev}/include/mysql"
     "-DPOCO_UNBUNDLED=ON"
   ];
 
diff --git a/pkgs/development/libraries/polkit/default.nix b/pkgs/development/libraries/polkit/default.nix
index aef627f8f1fe..ef865529805f 100644
--- a/pkgs/development/libraries/polkit/default.nix
+++ b/pkgs/development/libraries/polkit/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, fetchpatch, autoreconfHook, pkgconfig, glib, expat, pam
 , intltool, spidermonkey_17 , gobjectIntrospection, libxslt, docbook_xsl
-, docbook_xml_dtd_412, gtk_doc
+, docbook_xml_dtd_412, gtk-doc
 , useSystemd ? stdenv.isLinux, systemd
 }:
 
@@ -26,23 +26,31 @@ stdenv.mkDerivation rec {
 
   patches = [
     (fetchpatch {
-      url = "http://pkgs.fedoraproject.org/cgit/rpms/polkit.git/plain/polkit-0.113-agent-leaks.patch?id=fa6fd575804de92886c95d3bc2b7eb2abcd13760";
+      url = "http://src.fedoraproject.org/cgit/rpms/polkit.git/plain/polkit-0.113-agent-leaks.patch?id=fa6fd575804de92886c95d3bc2b7eb2abcd13760";
       sha256 = "1cxnhj0y30g7ldqq1y6zwsbdwcx7h97d3mpd3h5jy7dhg3h9ym91";
     })
     (fetchpatch {
-      url = "http://pkgs.fedoraproject.org/cgit/rpms/polkit.git/plain/polkit-0.113-polkitpermission-leak.patch?id=fa6fd575804de92886c95d3bc2b7eb2abcd13760";
+      url = "http://src.fedoraproject.org/cgit/rpms/polkit.git/plain/polkit-0.113-polkitpermission-leak.patch?id=fa6fd575804de92886c95d3bc2b7eb2abcd13760";
       sha256 = "1h1rkd4avqyyr8q6836zzr3w10jf521gcqnvhrhzwdpgp1ay4si7";
     })
     (fetchpatch {
-      url = "http://pkgs.fedoraproject.org/cgit/rpms/polkit.git/plain/polkit-0.113-itstool.patch?id=fa6fd575804de92886c95d3bc2b7eb2abcd13760";
+      url = "http://src.fedoraproject.org/cgit/rpms/polkit.git/plain/polkit-0.113-itstool.patch?id=fa6fd575804de92886c95d3bc2b7eb2abcd13760";
       sha256 = "0bxmjwp8ahy1y5g1l0kxmld0l3mlvb2l0i5n1qabia3d5iyjkyfh";
     })
-  ];
+  ]
+  # Could be applied uncondtionally but don't want to trigger rebuild
+  # https://bugs.freedesktop.org/show_bug.cgi?id=50145
+  ++ stdenv.lib.optional stdenv.hostPlatform.isMusl (fetchpatch {
+    name = "netgroup-optional.patch";
+    url = "https://bugs.freedesktop.org/attachment.cgi?id=118753";
+    sha256 = "1zq51dhmqi9zi86bj9dq4i4pxlxm41k3k4a091j07bd78cjba038";
+  });
+
 
   outputs = [ "bin" "dev" "out" ]; # small man pages in $bin
 
   nativeBuildInputs =
-    [ gtk_doc pkgconfig autoreconfHook intltool gobjectIntrospection ]
+    [ gtk-doc pkgconfig autoreconfHook intltool gobjectIntrospection ]
     ++ [ libxslt docbook_xsl docbook_xml_dtd_412 ]; # man pages
   buildInputs =
     [ glib expat pam spidermonkey_17 gobjectIntrospection ]
diff --git a/pkgs/development/libraries/poppler/0.61.nix b/pkgs/development/libraries/poppler/0.61.nix
new file mode 100644
index 000000000000..072de0f9fa06
--- /dev/null
+++ b/pkgs/development/libraries/poppler/0.61.nix
@@ -0,0 +1,56 @@
+{ stdenv, lib, fetchurl, cmake, ninja, pkgconfig, libiconv, libintlOrEmpty
+, zlib, curl, cairo, freetype, fontconfig, lcms, libjpeg, openjpeg
+, withData ? true, poppler_data
+, qt5Support ? false, qtbase ? null
+, introspectionSupport ? false, gobjectIntrospection ? null
+, utils ? false
+, minimal ? false, suffix ? "glib"
+}:
+
+let
+  version = "0.61.0";
+  mkFlag = optset: flag: "-DENABLE_${flag}=${if optset then "on" else "off"}";
+in
+stdenv.mkDerivation rec {
+  name = "poppler-${suffix}-${version}";
+
+  src = fetchurl {
+    url = "${meta.homepage}/poppler-${version}.tar.xz";
+    sha256 = "0zrbb1b77k6bm2qdnra08jnbyllv6vj29790igmp6fzs59xf3kak";
+  };
+
+  outputs = [ "out" "dev" ];
+
+  buildInputs = [ libiconv ] ++ libintlOrEmpty ++ lib.optional withData poppler_data;
+
+  # TODO: reduce propagation to necessary libs
+  propagatedBuildInputs = with lib;
+    [ zlib freetype fontconfig libjpeg openjpeg ]
+    ++ optionals (!minimal) [ cairo lcms curl ]
+    ++ optional qt5Support qtbase
+    ++ optional introspectionSupport gobjectIntrospection;
+
+  nativeBuildInputs = [ cmake ninja pkgconfig ];
+
+  cmakeFlags = [
+    (mkFlag true "XPDF_HEADERS")
+    (mkFlag (!minimal) "GLIB")
+    (mkFlag (!minimal) "CPP")
+    (mkFlag (!minimal) "LIBCURL")
+    (mkFlag utils "UTILS")
+    (mkFlag qt5Support "QT5")
+  ];
+
+  meta = with lib; {
+    homepage = https://poppler.freedesktop.org/;
+    description = "A PDF rendering library";
+
+    longDescription = ''
+      Poppler is a PDF rendering library based on the xpdf-3.0 code base.
+    '';
+
+    license = licenses.gpl2;
+    platforms = platforms.all;
+    maintainers = with maintainers; [ ttuegel ];
+  };
+}
diff --git a/pkgs/development/libraries/poppler/default.nix b/pkgs/development/libraries/poppler/default.nix
index 5fcb7d386faf..11dd8ec32910 100644
--- a/pkgs/development/libraries/poppler/default.nix
+++ b/pkgs/development/libraries/poppler/default.nix
@@ -1,64 +1,48 @@
-{ stdenv, lib, fetchurl, fetchpatch, pkgconfig, libiconv, libintlOrEmpty
+{ stdenv, lib, fetchurl, cmake, ninja, pkgconfig, libiconv, libintl
 , zlib, curl, cairo, freetype, fontconfig, lcms, libjpeg, openjpeg
 , withData ? true, poppler_data
-, qt4Support ? false, qt4 ? null
 , qt5Support ? false, qtbase ? null
 , introspectionSupport ? false, gobjectIntrospection ? null
 , utils ? false
 , minimal ? false, suffix ? "glib"
-, hostPlatform
 }:
 
 let # beware: updates often break cups-filters build
-  version = "0.56.0";
-  sha256 = "0wviayidfv2ix2ql0d4nl9r1ia6qi5kc1nybd9vjx27dk7gvm7c6";
+  version = "0.63.0";
+  mkFlag = optset: flag: "-DENABLE_${flag}=${if optset then "on" else "off"}";
 in
 stdenv.mkDerivation rec {
   name = "poppler-${suffix}-${version}";
 
   src = fetchurl {
     url = "${meta.homepage}/poppler-${version}.tar.xz";
-    inherit sha256;
+    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;
     [ zlib freetype fontconfig libjpeg openjpeg ]
     ++ optionals (!minimal) [ cairo lcms curl ]
-    ++ optional qt4Support qt4
     ++ optional qt5Support qtbase
     ++ optional introspectionSupport gobjectIntrospection;
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ cmake ninja pkgconfig ];
 
-  NIX_CFLAGS_COMPILE = [ "-DQT_NO_DEBUG" ];
+  # Not sure when and how to pass it.  It seems an upstream bug anyway.
+  CXXFLAGS = stdenv.lib.optionalString stdenv.cc.isClang "-std=c++11";
 
-  CXXFLAGS = lib.optional qt5Support "-std=c++11";
-
-  configureFlags = with lib;
-    [
-      "--enable-xpdf-headers"
-      "--enable-libcurl"
-      "--enable-zlib"
-      "--enable-build-type=release"
-    ]
-    ++ optionals minimal [
-      "--disable-poppler-glib" "--disable-poppler-cpp"
-      "--disable-libcurl"
-    ]
-    ++ optional (!utils) "--disable-utils"
-    ++ optional introspectionSupport "--enable-introspection";
-
-  enableParallelBuilding = true;
-
-  crossAttrs.postPatch =
-    # there are tests using `strXXX_s` functions that are missing apparently
-    stdenv.lib.optionalString (hostPlatform.libc or null == "msvcrt")
-      "sed '/^SUBDIRS =/s/ test / /' -i Makefile.in";
+  cmakeFlags = [
+    (mkFlag true "XPDF_HEADERS")
+    (mkFlag (!minimal) "GLIB")
+    (mkFlag (!minimal) "CPP")
+    (mkFlag (!minimal) "LIBCURL")
+    (mkFlag utils "UTILS")
+    (mkFlag qt5Support "QT5")
+  ];
 
   meta = with lib; {
     homepage = https://poppler.freedesktop.org/;
diff --git a/pkgs/development/libraries/poppler/qt4.nix b/pkgs/development/libraries/poppler/qt4.nix
new file mode 100644
index 000000000000..c82a543413e2
--- /dev/null
+++ b/pkgs/development/libraries/poppler/qt4.nix
@@ -0,0 +1,44 @@
+# TODO: get rid of this (https://github.com/NixOS/nixpkgs/issues/32883)
+{ stdenv, lib, fetchurl, cmake, ninja, pkgconfig, libiconv, libintlOrEmpty
+, zlib, curl, cairo, freetype, fontconfig, lcms2, libjpeg, openjpeg
+, poppler_data, qt4
+}:
+
+let
+  # Last version supporting QT4
+  version = "0.61.1";
+in
+stdenv.mkDerivation rec {
+  name = "poppler-qt4-${version}";
+
+  src = fetchurl {
+    url = "${meta.homepage}/poppler-${version}.tar.xz";
+    sha256 = "1afdrxxkaivvviazxkg5blsf2x24sjkfj92ib0d3q5pm8dihjrhj";
+  };
+
+  outputs = [ "out" "dev" ];
+
+  buildInputs = [ libiconv poppler_data ] ++ libintlOrEmpty;
+
+  propagatedBuildInputs = [ zlib freetype fontconfig libjpeg openjpeg cairo lcms2 curl qt4 ];
+
+  nativeBuildInputs = [ cmake ninja pkgconfig ];
+
+  cmakeFlags = [
+    "-DENABLE_XPDF_HEADERS=on"
+    "-DENABLE_UTILS=off"
+  ];
+
+  meta = with lib; {
+    homepage = https://poppler.freedesktop.org/;
+    description = "A PDF rendering library";
+
+    longDescription = ''
+      Poppler is a PDF rendering library based on the xpdf-3.0 code base.
+    '';
+
+    license = licenses.gpl2;
+    platforms = platforms.all;
+    maintainers = with maintainers; [ ttuegel ];
+  };
+}
diff --git a/pkgs/development/libraries/postgis/default.nix b/pkgs/development/libraries/postgis/default.nix
index bdf537f4375e..d201654fbb4c 100644
--- a/pkgs/development/libraries/postgis/default.nix
+++ b/pkgs/development/libraries/postgis/default.nix
@@ -1,11 +1,24 @@
-args@{fetchurl, composableDerivation, stdenv, perl, libxml2, postgresql, geos, proj, flex, gdal, json_c, pkgconfig, file, ...}:
+{ fetchurl
+, fetchpatch
+, stdenv
+, perl
+, libxml2
+, postgresql
+, geos
+, proj
+, flex
+, gdal
+, json_c
+, pkgconfig
+, file
+}:
 
   /*
 
   ### NixOS - usage:
   ==================
 
-    services.postgresql.extraPlugins = [ (pkgs.postgis.override { postgresql = pkgs.postgresql95; }).v_2_3_1 ];
+    services.postgresql.extraPlugins = [ (pkgs.postgis.override { postgresql = pkgs.postgresql95; }) ];
 
 
   ### important Postgis implementation details:
@@ -31,108 +44,75 @@ args@{fetchurl, composableDerivation, stdenv, perl, libxml2, postgresql, geos, p
 
 
 let
-  pgDerivationBase = composableDerivation.composableDerivation {} ( fix :
-
-  let version = fix.fixed.version; in {
-
-    name = "postgis-${version}";
-
-    src = fetchurl {
-      url = "http://postgis.refractions.net/download/postgis-${fix.fixed.version}.tar.gz";
-      inherit (fix.fixed) sha256;
-    };
-
-    # don't pass these vars to the builder
-    removeAttrs = ["hash" "sql_comments" "sql_srcs"];
-
-    preConfigure = ''
-      configureFlags="--datadir=$out/share --datarootdir=$out/share --bindir=$out/bin"
-      makeFlags="PERL=${perl}/bin/perl datadir=$out/share pkglibdir=$out/lib bindir=$out/bin"
-    '';
-
-    # create aliases for all commands adding version information
-    postInstall = ''
-
-      sql_srcs=$(for sql in ${builtins.toString fix.fixed.sql_srcs}; do echo -n "$(find $out -iname "$sql") "; done )
-
-      for prog in $out/bin/*; do # */
-        ln -s $prog $prog-${version}
-      done
-
-      cp -r doc $out
-    '';
-
-    buildInputs = [libxml2 postgresql geos proj perl];
-
-    sql_comments = "postgis_comments.sql";
-
-    meta = {
-      description = "Geographic Objects for PostgreSQL";
-      homepage = http://postgis.refractions.net;
-      license = stdenv.lib.licenses.gpl2;
-      maintainers = [stdenv.lib.maintainers.marcweber];
-      platforms = stdenv.lib.platforms.linux;
-    };
-  });
-
-  pgDerivationBaseNewer = pgDerivationBase.merge (fix: {
-    src = fetchurl {
-      url = "http://download.osgeo.org/postgis/source/postgis-${builtins.toString fix.fixed.version}.tar.gz";
-      inherit (fix.fixed) sha256;
-    };
-  });
-
-in rec {
-
-  v_2_3_1 = pgDerivationBaseNewer.merge ( fix : {
-    version = "2.3.1";
-    sha256 = "0xd21h2k6x3i1b3z6pgm3pmkfpxm6irxd5wbx68acjndjgd6p3ac";
-    sql_srcs = ["postgis.sql" "spatial_ref_sys.sql"];
-    builtInputs = [gdal json_c pkgconfig];
-
-    # postgis config directory assumes /include /lib from the same root for json-c library
-    NIX_LDFLAGS = "-L${stdenv.lib.getLib json_c}/lib";
-
-    dontDisableStatic = true;
-    preConfigure = ''
-      sed -i 's@/usr/bin/file@${file}/bin/file@' configure
-      configureFlags="$configureFlags --with-gdalconfig=${gdal}/bin/gdal-config --with-jsondir=${json_c.dev}"
-    '';
-    postConfigure = ''
-      sed -i "s|@mkdir -p \$(DESTDIR)\$(PGSQL_BINDIR)||g ;
-              s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g
-              " \
-          "raster/loader/Makefile";
-      sed -i "s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g
-              " \
-          "raster/scripts/python/Makefile";
-    '';
-  });
-
-  v_2_4_0 = pgDerivationBaseNewer.merge ( fix : {
-    version = "2.4.0";
-    sha256 = "02baa90f04da41e04b6c18eedfda53110c45ae943d4e65050f6d202f7de07d29";
-    sql_srcs = ["postgis.sql" "spatial_ref_sys.sql"];
-    builtInputs = [gdal json_c pkgconfig];
-
-    # postgis config directory assumes /include /lib from the same root for json-c library
-    NIX_LDFLAGS = "-L${stdenv.lib.getLib json_c}/lib";
-
-    dontDisableStatic = true;
-    preConfigure = ''
-      sed -i 's@/usr/bin/file@${file}/bin/file@' configure
-      configureFlags="$configureFlags --with-gdalconfig=${gdal}/bin/gdal-config --with-jsondir=${json_c.dev}"
-    '';
-    postConfigure = ''
-      sed -i "s|@mkdir -p \$(DESTDIR)\$(PGSQL_BINDIR)||g ;
-              s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g
-              " \
-          "raster/loader/Makefile";
-      sed -i "s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g
-              " \
-          "raster/scripts/python/Makefile";
-    '';
-  });
-
-
+  version = "2.4.3";
+  sha256 = "1fg4pmla5m903m76ndjd8q5dkcykf67v1p4dcajmnr3bvg2p8lza";
+in stdenv.mkDerivation rec {
+  name = "postgis-${version}";
+
+  src = fetchurl {
+    url = "http://download.osgeo.org/postgis/source/postgis-${builtins.toString version}.tar.gz";
+    inherit sha256;
+  };
+
+  patches = [
+    (fetchpatch {
+      url = "https://trac.osgeo.org/postgis/changeset/16417?format=diff&new=16417";
+      name = "json-c-0.13.patch";
+      sha256 = "1hk2fh4nsvq76ksi7z4shlgj7fik6ac3sjsb0khsypsjfhz7ic8z";
+      stripLen = 3;
+      extraPrefix = "";
+      excludes = [ "NEWS" ];
+    })
+  ];
+
+  # don't pass these vars to the builder
+  removeAttrs = ["sql_comments" "sql_srcs"];
+
+  preInstall = ''
+    mkdir -p $out/bin
+  '';
+
+  # create aliases for all commands adding version information
+  postInstall = ''
+    sql_srcs=$(for sql in ${builtins.toString sql_srcs}; do echo -n "$(find $out -iname "$sql") "; done )
+
+    for prog in $out/bin/*; do # */
+      ln -s $prog $prog-${version}
+    done
+
+    cp -r doc $out
+  '';
+
+  buildInputs = [ libxml2 postgresql geos proj perl gdal json_c pkgconfig ];
+
+  sql_comments = "postgis_comments.sql";
+
+  sql_srcs = ["postgis.sql" "spatial_ref_sys.sql"];
+
+  # postgis config directory assumes /include /lib from the same root for json-c library
+  NIX_LDFLAGS = "-L${stdenv.lib.getLib json_c}/lib";
+
+  dontDisableStatic = true;
+  preConfigure = ''
+    sed -i 's@/usr/bin/file@${file}/bin/file@' configure
+    configureFlags="--datadir=$out/share --datarootdir=$out/share --bindir=$out/bin --with-gdalconfig=${gdal}/bin/gdal-config --with-jsondir=${json_c.dev}"
+    makeFlags="PERL=${perl}/bin/perl datadir=$out/share pkglibdir=$out/lib bindir=$out/bin"
+  '';
+  postConfigure = ''
+    sed -i "s|@mkdir -p \$(DESTDIR)\$(PGSQL_BINDIR)||g ;
+            s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g
+            " \
+        "raster/loader/Makefile";
+    sed -i "s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g
+            " \
+        "raster/scripts/python/Makefile";
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Geographic Objects for PostgreSQL";
+    homepage = http://postgis.refractions.net;
+    license = licenses.gpl2;
+    maintainers = [ maintainers.marcweber ];
+    platforms = platforms.linux;
+  };
 }
diff --git a/pkgs/development/libraries/postgis/pg_db_postgis_enable.sh b/pkgs/development/libraries/postgis/pg_db_postgis_enable.sh
deleted file mode 100644
index c7652e20d9f3..000000000000
--- a/pkgs/development/libraries/postgis/pg_db_postgis_enable.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-sql_files=(@sql_srcs@)
-sql_comments=@sql_comments@
-
-do_help(){ echo "$0 [--comments] db_name1 [db_name2 ..]"; }
-
-for arg in "$@"; do
-  case "$arg" in
-    -h|--help)
-      do_help; exit 0
-      ;;
-    --comments)
-      LOAD_COMMENTS=1
-    ;;
-    *)
-      dbs=(${dbs[@]} "$arg")
-    ;;
-  esac
-done
-
-PSQL(){
-  echo ">> loading $1"
-  psql -d "$db" -f $1
-}
-
-for db in ${dbs[@]}; do
-  createlang plpgsql "$db"
-
-  # mandatory
-  for sql in $sql_files; do
-    PSQL $sql
-  done
-
-  # optionally load some comments
-  if [ -n "$LOAD_COMMENTS" ]; then
-    PSQL $sql_comments
-  fi
-done
diff --git a/pkgs/development/libraries/postgis/pg_db_postgis_fix_or_load_sql_dump.sh b/pkgs/development/libraries/postgis/pg_db_postgis_fix_or_load_sql_dump.sh
deleted file mode 100644
index 6a98c5d24ca8..000000000000
--- a/pkgs/development/libraries/postgis/pg_db_postgis_fix_or_load_sql_dump.sh
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/sh
-libName=@libName@
-
-# this is a quick and dirty implementation
-
-do_help(){
-  echo "$0 --str str in-file|- [out|-|psql:db]";
-  echo "in: - = STDIN or filename";
-  echo "out: - = STDIN or filename or psql:database_name" 
-  echo "         psql:database_name will load the dump into the database" 
-  echo "         if out is omitted in is used for out (same file)"
-  echo "--str: different replacement string. Eg for Ubuntu use: '/usr/lib/postgresql/8.3/lib/liblwgeom'";
-  echo "WARNING: A postgis dump is not meant to be distributed - it still may be useful :)"
-}
-
-if [ -z "$1" -o "$1" = --help -o "$1" = -h ]; then
-  do_help; exit 1
-fi
-
-tostr='$libdir/'"$libName"
-if [ "$1" == "--str" ]; then
-  to="$2"; shift 2
-fi
-
-i=$1
-o="${2:-$1}"
-
-cmd_in(){
-  case "$i" in
-    -) cat;;
-    *) cat "$i";;
-  esac
-}
-
-cmd_out(){
-  case "$o" in
-    -) cat;;  # stdout
-    psql:*) psql "${o:5}";; # pipe into psql
-    *)
-      t=`mktemp`; cat > "$t"; mv "$t" "$o"
-      ;;
-  esac
-}
-
-cmd_replace(){
-  contents=`cat`
-  # get wrong library path:
-  fromstr=$(echo "$contents" | head -n 50 | sed -n "s/.*AS '\([^']*\)'.*/\1/p" | head -n 1)
-  echo "$contents" | sed "s@AS '$fromstr@AS '$tostr@g"
-}
-
-cmd_in | cmd_replace | cmd_out
diff --git a/pkgs/development/libraries/ppl/default.nix b/pkgs/development/libraries/ppl/default.nix
index 73eda630e449..566d88dcdb56 100644
--- a/pkgs/development/libraries/ppl/default.nix
+++ b/pkgs/development/libraries/ppl/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, gmpxx, perl, gnum4 }:
+{ fetchurl, fetchpatch, stdenv, gmpxx, perl, gnum4 }:
 
 let version = "1.2"; in
 
@@ -10,6 +10,12 @@ stdenv.mkDerivation rec {
     sha256 = "1wgxcbgmijgk11df43aiqfzv31r3bkxmgb4yl68g21194q60nird";
   };
 
+  patches = [(fetchpatch {
+    name = "ppl.patch";
+    url = "http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=patch;h=c39f6a07b51f89e365b05ba4147aa2aa448febd7";
+    sha256 = "1zj90hm25pkgvk4jlkfzh18ak9b98217gbidl3731fdccbw6hr87";
+  })];
+
   nativeBuildInputs = [ perl gnum4 ];
   propagatedBuildInputs = [ gmpxx ];
 
diff --git a/pkgs/development/libraries/protobuf/2.5.nix b/pkgs/development/libraries/protobuf/2.5.nix
new file mode 100644
index 000000000000..550d0b1bace2
--- /dev/null
+++ b/pkgs/development/libraries/protobuf/2.5.nix
@@ -0,0 +1,10 @@
+{ callPackage, fetchurl, ... } @ args:
+
+callPackage ./generic.nix (args // rec {
+  version = "2.5.0";
+  # make sure you test also -A pythonPackages.protobuf
+  src = fetchurl {
+    url = "http://protobuf.googlecode.com/files/${version}.tar.bz2";
+    sha256 = "0xxn9gxhvsgzz2sgmihzf6pf75clr05mqj6218camwrwajpcbgqk";
+  };
+})
\ No newline at end of file
diff --git a/pkgs/development/libraries/protobuf/3.4.nix b/pkgs/development/libraries/protobuf/3.4.nix
index 75f1bb22c248..5a9034a56a80 100644
--- a/pkgs/development/libraries/protobuf/3.4.nix
+++ b/pkgs/development/libraries/protobuf/3.4.nix
@@ -1,6 +1,6 @@
 { callPackage, lib, ... }:
 
 lib.overrideDerivation (callPackage ./generic-v3.nix {
-  version = "3.4.0";
-  sha256 = "0385j54kgr71h0cxh5vqr81qs57ack2g2k9mcdbq188v4ckjacyx";
+  version = "3.4.1";
+  sha256 = "1lzxmbqlnmi34kymnf399azv86gmdbrf71xiad6wc24bzpkzqybb";
 }) (attrs: { NIX_CFLAGS_COMPILE = "-Wno-error"; })
diff --git a/pkgs/development/libraries/protobuf/3.5.nix b/pkgs/development/libraries/protobuf/3.5.nix
new file mode 100644
index 000000000000..db9cb6f0371b
--- /dev/null
+++ b/pkgs/development/libraries/protobuf/3.5.nix
@@ -0,0 +1,6 @@
+{ callPackage, lib, ... }:
+
+lib.overrideDerivation (callPackage ./generic-v3.nix {
+  version = "3.5.1.1";
+  sha256 = "1h4xydr5j2zg1888ncn8a1jvqq8fgpgckrmjg6lqzy9jpkvqvfdk";
+}) (attrs: { NIX_CFLAGS_COMPILE = "-Wno-error"; })
diff --git a/pkgs/development/libraries/protobufc/generic.nix b/pkgs/development/libraries/protobufc/generic.nix
index b9ad506e20a8..ce0b2506c572 100644
--- a/pkgs/development/libraries/protobufc/generic.nix
+++ b/pkgs/development/libraries/protobufc/generic.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ protobuf zlib ];
 
   meta = with stdenv.lib; {
-    homepage = http://github.com/protobuf-c/protobuf-c/;
+    homepage = https://github.com/protobuf-c/protobuf-c/;
     description = "C bindings for Google's Protocol Buffers";
     license = licenses.bsd2;
     platforms = platforms.all;
diff --git a/pkgs/development/libraries/psol/default.nix b/pkgs/development/libraries/psol/default.nix
index 5c78c1a288f6..270c24dc01f4 100644
--- a/pkgs/development/libraries/psol/default.nix
+++ b/pkgs/development/libraries/psol/default.nix
@@ -1,5 +1,5 @@
 { callPackage }:
 callPackage ./generic.nix {} {
-  version = "1.11.33.4";
-  sha256  = "1jq2llp0i4666rwqnx1hs4pjlpblxivvs1jkkjzlmdbsv28jzjq8";
+  version = "1.13.35.2"; # Latest stable, 2018-02-05
+  sha256  = "0xi2srf9gx0x2sz9r45zb35k2n0iv457if1lqzvbanls3f935cmr";
 }
diff --git a/pkgs/development/libraries/psol/generic.nix b/pkgs/development/libraries/psol/generic.nix
index 3e82bb4975dc..c61926fe13fa 100644
--- a/pkgs/development/libraries/psol/generic.nix
+++ b/pkgs/development/libraries/psol/generic.nix
@@ -3,7 +3,7 @@
 { inherit version; } // fetchzip {
   inherit sha256;
   name   = "psol-${version}";
-  url    = "https://dl.google.com/dl/page-speed/psol/${version}.tar.gz";
+  url    = "https://dl.google.com/dl/page-speed/psol/${version}-x64.tar.gz";
 
   meta = {
     description = "PageSpeed Optimization Libraries";
diff --git a/pkgs/development/libraries/ptex/default.nix b/pkgs/development/libraries/ptex/default.nix
index d40ae8564951..f300a571b0cc 100644
--- a/pkgs/development/libraries/ptex/default.nix
+++ b/pkgs/development/libraries/ptex/default.nix
@@ -3,13 +3,13 @@
 stdenv.mkDerivation rec
 {
   name = "ptex-${version}";
-  version = "2.1.28";
+  version = "2.1.33";
 
   src = fetchFromGitHub {
     owner = "wdas";
     repo = "ptex";
     rev = "v${version}";
-    sha256 = "1h6gb3mpis4m6ph7h9q764w50f9jrar3jz2ja76rn5czy6wn318x";
+    sha256 = "15ijjq3w7hwgm4mqah0x4jzjy3v2nnmmv28lbqzmxzcxjgh4sjkn";
   };
 
   outputs = [ "bin" "dev" "out" "lib" ];
diff --git a/pkgs/development/libraries/ptlib/default.nix b/pkgs/development/libraries/ptlib/default.nix
index c5d3d7411309..ae60a6f69d63 100644
--- a/pkgs/development/libraries/ptlib/default.nix
+++ b/pkgs/development/libraries/ptlib/default.nix
@@ -24,11 +24,16 @@ stdenv.mkDerivation rec {
     (fetchpatch { url = http://sources.debian.net/data/main/p/ptlib/2.10.11~dfsg-2.1/debian/patches/no-sslv3;
       sha256 = "172s1dnnrl54p9sf1nl7s475sm78rpw3p8jxi0pdx6izzl8hcdr0";
     })
-    (fetchpatch { url = http://sources.debian.net/data/main/p/ptlib/2.10.11~dfsg-2.1/debian/patches/gcc-5_support;
-      sha256 = "0pf2yj0150r4cnc6nv65mclrm3dillqh1xjk7m6gsjnk9b96i5d4";
-    })
+    ./ptlib-2.10.11-glibc-2.26.patch
   ];
 
+  # fix typedef clashes with unixODBC>=2.3.5
+  postPatch = ''
+    substituteInPlace include/ptlib/unix/ptlib/contain.h \
+      --replace "typedef uintptr_t    UINT" "typedef unsigned int    UINT" \
+      --replace "typedef wchar_t                 WCHAR" "typedef unsigned short          WCHAR"
+  '';
+
   meta = with stdenv.lib; {
     description = "Portable Tools from OPAL VoIP";
     maintainers = [ maintainers.raskin ];
@@ -41,4 +46,3 @@ stdenv.mkDerivation rec {
     };
   };
 }
-
diff --git a/pkgs/development/libraries/ptlib/ptlib-2.10.11-glibc-2.26.patch b/pkgs/development/libraries/ptlib/ptlib-2.10.11-glibc-2.26.patch
new file mode 100644
index 000000000000..300c3736abf7
--- /dev/null
+++ b/pkgs/development/libraries/ptlib/ptlib-2.10.11-glibc-2.26.patch
@@ -0,0 +1,13 @@
+diff --git a/src/ptlib/unix/channel.cxx b/src/ptlib/unix/channel.cxx
+index 3b17dda..2dcaa18 100644
+--- a/src/ptlib/unix/channel.cxx
++++ b/src/ptlib/unix/channel.cxx
+@@ -36,7 +36,7 @@
+ 
+ #include <ptlib.h>
+ #include <sys/ioctl.h>
+-
++#include <sys/uio.h>
+ 
+ #include "../common/pchannel.cxx"
+ 
diff --git a/pkgs/development/libraries/pugixml/default.nix b/pkgs/development/libraries/pugixml/default.nix
index dd33f63c913c..1730f9b733ca 100644
--- a/pkgs/development/libraries/pugixml/default.nix
+++ b/pkgs/development/libraries/pugixml/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "pugixml-${version}";
-  version = "1.8.1";
+  version = "1.9";
 
   src = fetchurl {
     url = "https://github.com/zeux/pugixml/releases/download/v${version}/${name}.tar.gz";
-    sha256 = "0fcgggry5x5bn0zhb09ij9hb0p45nb0sv0d9fw3cm1cf62hp9n80";
+    sha256 = "19nv3zhik3djp4blc4vrjwrl8dfhzmal8b21sq7y907nhddx6mni";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/qca-qt5/default.nix b/pkgs/development/libraries/qca-qt5/default.nix
index 9433eb87109f..6e190a656f63 100644
--- a/pkgs/development/libraries/qca-qt5/default.nix
+++ b/pkgs/development/libraries/qca-qt5/default.nix
@@ -1,21 +1,31 @@
 { stdenv, fetchurl, cmake, openssl, pkgconfig, qtbase }:
 
 stdenv.mkDerivation rec {
-  name = "qca-qt5-2.1.1";
+  name = "qca-qt5-2.1.3";
 
   src = fetchurl {
-    url = "http://download.kde.org/stable/qca/2.1.1/src/qca-2.1.1.tar.xz";
-    sha256 = "10z9icq28fww4qbzwra8d9z55ywbv74qk68nhiqfrydm21wkxplm";
+    url = "http://download.kde.org/stable/qca/2.1.3/src/qca-2.1.3.tar.xz";
+    sha256 = "0lz3n652z208daxypdcxiybl0a9fnn6ida0q7fh5f42269mdhgq0";
   };
 
   buildInputs = [ openssl qtbase ];
   nativeBuildInputs = [ cmake pkgconfig ];
 
+  # Without this patch cmake fails with a "No known features for CXX compiler"
+  # error on darwin
+  patches = stdenv.lib.optional stdenv.isDarwin ./move-project.patch ;
+
+  # tells CMake to use this CA bundle file if it is accessible
+  preConfigure = ''export QC_CERTSTORE_PATH=/etc/ssl/certs/ca-certificates.crt'';
+
+  # tricks CMake into using this CA bundle file if it is not accessible (in a sandbox)
+  cmakeFlags = [ "-Dqca_CERTSTORE=/etc/ssl/certs/ca-certificates.crt" ];
+
   meta = with stdenv.lib; {
     description = "Qt 5 Cryptographic Architecture";
     homepage = http://delta.affinix.com/qca;
     maintainers = with maintainers; [ ttuegel ];
     license = licenses.lgpl21Plus;
-    platforms = with platforms; linux;
+    platforms = with platforms; unix;
   };
 }
diff --git a/pkgs/development/libraries/qca-qt5/move-project.patch b/pkgs/development/libraries/qca-qt5/move-project.patch
new file mode 100644
index 000000000000..2a109a3aa3c7
--- /dev/null
+++ b/pkgs/development/libraries/qca-qt5/move-project.patch
@@ -0,0 +1,19 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 453fd8a..5f6ee11 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -6,13 +6,13 @@ if(NOT CMAKE_INSTALL_PREFIX)
+   unset(CMAKE_INSTALL_PREFIX CACHE)
+ endif(NOT CMAKE_INSTALL_PREFIX)
+
+-project(qca)
+
+ if(NOT APPLE)
+   cmake_minimum_required(VERSION 2.8.12)
+ else()
+   cmake_minimum_required(VERSION 3.0)
+ endif()
++project(qca)
+
+ set(QCA_LIB_MAJOR_VERSION "2")
+ set(QCA_LIB_MINOR_VERSION "1")
diff --git a/pkgs/development/libraries/qca2/default.nix b/pkgs/development/libraries/qca2/default.nix
index 2265d0df3949..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,15 +10,21 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ cmake pkgconfig ];
-  buildInputs = [ qt ];
+  buildInputs = [ (stdenv.lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security) qt ];
 
   enableParallelBuilding = true;
 
+  # tells CMake to use this CA bundle file if it is accessible
+  preConfigure = ''export QC_CERTSTORE_PATH=/etc/ssl/certs/ca-certificates.crt'';
+
+  # tricks CMake into using this CA bundle file if it is not accessible (in a sandbox)
+  cmakeFlags = [ "-Dqca_CERTSTORE=/etc/ssl/certs/ca-certificates.crt" ];
+
   meta = with stdenv.lib; {
     description = "Qt Cryptographic Architecture";
     license = "LGPL";
     homepage = http://delta.affinix.com/qca;
     maintainers = [ maintainers.sander ];
-    platforms = platforms.linux;
+    platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/qmlbox2d/default.nix b/pkgs/development/libraries/qmlbox2d/default.nix
new file mode 100644
index 000000000000..630f606c2e54
--- /dev/null
+++ b/pkgs/development/libraries/qmlbox2d/default.nix
@@ -0,0 +1,31 @@
+{stdenv, qtdeclarative, fetchFromGitHub, qmake }:
+stdenv.mkDerivation rec {
+  name = "qml-box2d-2018-03-16";
+  src = fetchFromGitHub {
+    owner = "qml-box2d";
+    repo = "qml-box2d";
+    sha256 = "1fbsvv28b4r0szcv8bk5gxpf8v534jp2axyfp438384sy757wsq2";
+    rev = "21e57f1";
+  };
+
+  enableParallelBuilding = true;
+  nativeBuildInputs = [ qmake ];
+
+  buildInputs = [ qtdeclarative ];
+
+  patchPhase = ''
+    substituteInPlace box2d.pro \
+      --replace '$$[QT_INSTALL_QML]' "/$qtQmlPrefix/"
+    qmakeFlags="$qmakeFlags PREFIXSHORTCUT=$out"
+    '';
+
+  installFlags = [ "INSTALL_ROOT=$(out)" ];
+
+  meta = with stdenv.lib; {
+    description = "A QML plugin for Box2D engine";
+    homepage = "https://github.com/qml-box2d/qml-box2d";
+    maintainers = [ maintainers.guibou ];
+    platforms = platforms.linux;
+    license = licenses.zlib;
+  };
+}
diff --git a/pkgs/development/libraries/qmltermwidget/default.nix b/pkgs/development/libraries/qmltermwidget/default.nix
index 2057aee3e995..79ed37dd2a9a 100644
--- a/pkgs/development/libraries/qmltermwidget/default.nix
+++ b/pkgs/development/libraries/qmltermwidget/default.nix
@@ -1,12 +1,13 @@
-{ stdenv, fetchgit, qtbase, qtquick1, qmake, qtmultimedia }:
+{ stdenv, fetchFromGitHub, qtbase, qtquick1, qmake, qtmultimedia }:
 
 stdenv.mkDerivation rec {
   version = "0.1.0";
   name = "qmltermwidget-${version}";
 
-  src = fetchgit {
-    url = "https://github.com/Swordfish90/qmltermwidget.git";
-    rev = "refs/tags/v${version}";
+  src = fetchFromGitHub {
+    repo = "qmltermwidget";
+    owner = "Swordfish90";
+    rev = "v${version}";
     sha256 = "0ca500mzcqglkj0i6km0z512y3a025dbm24605xyv18l6y0l2ny3";
   };
 
diff --git a/pkgs/development/libraries/qoauth/default.nix b/pkgs/development/libraries/qoauth/default.nix
index fa998b9e1984..d09c0d9a6ce0 100644
--- a/pkgs/development/libraries/qoauth/default.nix
+++ b/pkgs/development/libraries/qoauth/default.nix
@@ -9,7 +9,11 @@ stdenv.mkDerivation {
     sha256 = "a28005986410d333e03d077679cdf6c504ec5a33342867dc0f9fb0b74285e333";
   };
 
-  patchPhase = "sed -e 's/lib64/lib/g' -i src/src.pro";
+  postPatch = ''
+    sed -i src/src.pro \
+        -e 's/lib64/lib/g' \
+        -e '/features.path =/ s|$$\[QMAKE_MKSPECS\]|$$NIX_OUTPUT_DEV/mkspecs|'
+  '';
 
   buildInputs = [ qt5.qtbase qca2-qt5 ];
   nativeBuildInputs = [ qt5.qmake ];
diff --git a/pkgs/development/libraries/qpdf/default.nix b/pkgs/development/libraries/qpdf/default.nix
index 4cd5fb0f6414..00ce51330487 100644
--- a/pkgs/development/libraries/qpdf/default.nix
+++ b/pkgs/development/libraries/qpdf/default.nix
@@ -1,18 +1,18 @@
-{ stdenv, fetchurl, pcre, zlib, perl }:
+{ stdenv, fetchurl, libjpeg, zlib, perl }:
 
-let version = "6.0.0";
+let version = "8.0.2";
 in
 stdenv.mkDerivation rec {
   name = "qpdf-${version}";
 
   src = fetchurl {
     url = "mirror://sourceforge/qpdf/qpdf/${version}/${name}.tar.gz";
-    sha256 = "0csj2p2gkxrc0rk8ykymlsdgfas96vzf1dip3y1x7z1q9plwgzd9";
+    sha256 = "1hf8jfjar8p7v288d7ccmr8w171mv9kb86b6hq1nk58mnlq1g7mh";
   };
 
   nativeBuildInputs = [ perl ];
 
-  buildInputs = [ pcre zlib ];
+  buildInputs = [ zlib libjpeg ];
 
   postPatch = ''
     patchShebangs qpdf/fix-qdf
@@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
   meta = with stdenv.lib; {
     homepage = http://qpdf.sourceforge.net/;
     description = "A C++ library and set of programs that inspect and manipulate the structure of PDF files";
-    license = licenses.artistic2;
+    license = licenses.asl20; # as of 7.0.0, people may stay at artistic2
     maintainers = with maintainers; [ abbradar ];
     platforms = platforms.all;
   };
diff --git a/pkgs/development/libraries/qscintilla/default.nix b/pkgs/development/libraries/qscintilla/default.nix
index c2e6c3cb3b52..281dbe0a5eda 100644
--- a/pkgs/development/libraries/qscintilla/default.nix
+++ b/pkgs/development/libraries/qscintilla/default.nix
@@ -1,31 +1,47 @@
-{ stdenv, fetchurl, unzip
+{ stdenv, lib, fetchurl, unzip
 , qt4 ? null, qmake4Hook ? null
-, withQt5 ? false, qtbase ? null, qmake ? null
+, 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";
+  version = "2.10.3";
 
   name = "${pname}-${if withQt5 then "qt5" else "qt4"}-${version}";
 
   src = fetchurl {
     url = "mirror://sourceforge/pyqt/QScintilla2/QScintilla-${version}/QScintilla_gpl-${version}.zip";
-    sha256 = "04678skipydx68zf52vznsfmll2v9aahr66g50lcqbr6xsmgr1yi";
+    sha256 = "0rsx0b0iz5yf3x594kzhi0c2wpbmknv9b0a3rmx5w37bvmpd6qav";
   };
 
-  buildInputs = if withQt5 then [ qtbase ] else [ qt4 ];
-  nativeBuildInputs = [ unzip ] ++ (if withQt5 then [ qmake ] else [ qmake4Hook ]);
+  buildInputs = [ (if withQt5 then qtbase else qt4) ]
+    ++ lib.optional (withQt5 && stdenv.isDarwin) qtmacextras;
+  nativeBuildInputs = [ unzip ]
+    ++ (if withQt5 then [ qmake ] else [ qmake4Hook ]);
+
+
+  patches = [] ++ lib.optional withQt5 [ xcodePatch ];
 
   enableParallelBuilding = true;
 
   preConfigure = ''
     cd Qt4Qt5
-    sed -i -e "s,\$\$\\[QT_INSTALL_LIBS\\],$out/lib," \
-           -e "s,\$\$\\[QT_INSTALL_HEADERS\\],$out/include/," \
-           -e "s,\$\$\\[QT_INSTALL_TRANSLATIONS\\],$out/share/qt/translations," \
-           -e "s,\$\$\\[QT_INSTALL_DATA\\],$out/share/qt," \
-           qscintilla.pro
+    sed -i qscintilla.pro \
+      -e "s,\$\$\\[QT_INSTALL_LIBS\\],$out/lib," \
+      -e "s,\$\$\\[QT_INSTALL_HEADERS\\],$out/include/," \
+      -e "s,\$\$\\[QT_INSTALL_TRANSLATIONS\\],$out/translations," \
+    ${if withQt5 then ''
+      -e "s,\$\$\\[QT_HOST_DATA\\]/mkspecs,$out/mkspecs," \
+      -e "s,\$\$\\[QT_INSTALL_DATA\\]/mkspecs,$out/mkspecs," \
+      -e "s,\$\$\\[QT_INSTALL_DATA\\],$out/share,"
+    '' else ''
+      -e "s,\$\$\\[QT_INSTALL_DATA\\],$out/share/qt,"
+    ''}
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/qt-3/default.nix b/pkgs/development/libraries/qt-3/default.nix
index 6d92de001cb7..32841c9b9331 100644
--- a/pkgs/development/libraries/qt-3/default.nix
+++ b/pkgs/development/libraries/qt-3/default.nix
@@ -6,7 +6,7 @@
 , cursorSupport ? true, libXcursor ? null
 , threadSupport ? true
 , mysqlSupport ? false, mysql ? null
-, openglSupport ? false, mesa ? null, libXmu ? null
+, openglSupport ? false, libGLU_combined ? null, libXmu ? null
 , xlibsWrapper, xextproto, zlib, libjpeg, libpng, which
 }:
 
@@ -15,7 +15,7 @@ assert xrenderSupport -> xftSupport && libXrender != null;
 assert xrandrSupport -> libXrandr != null && randrproto != null;
 assert cursorSupport -> libXcursor != null;
 assert mysqlSupport -> mysql != null;
-assert openglSupport -> mesa != null && libXmu != null;
+assert openglSupport -> libGLU_combined != null && libXmu != null;
 
 stdenv.mkDerivation {
   name = "qt-3.3.8";
@@ -40,7 +40,7 @@ stdenv.mkDerivation {
     -qt-gif
     -I${xextproto}/include
     ${if openglSupport then "-dlopen-opengl
-      -L${mesa}/lib -I${mesa}/include
+      -L${libGLU_combined}/lib -I${libGLU_combined}/include
       -L${libXmu.out}/lib -I${libXmu.dev}/include" else ""}
     ${if threadSupport then "-thread" else "-no-thread"}
     ${if xrenderSupport then "-xrender -L${libXrender.out}/lib -I${libXrender.dev}/include" else "-no-xrender"}
@@ -49,7 +49,7 @@ stdenv.mkDerivation {
       -I${randrproto}/include" else "-no-xrandr"}
     ${if xineramaSupport then "-xinerama -L${libXinerama.out}/lib -I${libXinerama.dev}/include" else "-no-xinerama"}
     ${if cursorSupport then "-L${libXcursor.out}/lib -I${libXcursor.dev}/include" else ""}
-    ${if mysqlSupport then "-qt-sql-mysql -L${stdenv.lib.getLib mysql.client}/lib/mysql -I${mysql.client}/include/mysql" else ""}
+    ${if mysqlSupport then "-qt-sql-mysql -L${mysql.connector-c}/lib/mysql -I${mysql.connector-c}/include/mysql" else ""}
     ${if xftSupport then "-xft
       -L${libXft.out}/lib -I${libXft.dev}/include
       -L${libXft.freetype.out}/lib -I${libXft.freetype.dev}/include
diff --git a/pkgs/development/libraries/qt-4.x/4.8/clang-5-darwin.patch b/pkgs/development/libraries/qt-4.x/4.8/clang-5-darwin.patch
new file mode 100644
index 000000000000..7b181f3ad896
--- /dev/null
+++ b/pkgs/development/libraries/qt-4.x/4.8/clang-5-darwin.patch
@@ -0,0 +1,13 @@
+diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm
+index 204d685..e05179e 100644
+--- a/src/gui/text/qfontengine_coretext.mm
++++ b/src/gui/text/qfontengine_coretext.mm
+@@ -886,7 +886,7 @@ void QCoreTextFontEngine::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, gl
+ 
+ QFixed QCoreTextFontEngine::emSquareSize() const
+ {
+-    return QFixed::QFixed(int(CTFontGetUnitsPerEm(ctfont)));
++    return QFixed(int(CTFontGetUnitsPerEm(ctfont)));
+ }
+ 
+ QFontEngine *QCoreTextFontEngine::cloneWithSize(qreal pixelSize) const
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 c9679d227d88..10f892bc4d00 100644
--- a/pkgs/development/libraries/qt-4.x/4.8/default.nix
+++ b/pkgs/development/libraries/qt-4.x/4.8/default.nix
@@ -2,7 +2,7 @@
 , hostPlatform
 , libXrender, libXinerama, libXcursor, libXmu, libXv, libXext
 , libXfixes, libXrandr, libSM, freetype, fontconfig, zlib, libjpeg, libpng
-, libmng, which, mesaSupported, mesa, mesa_glu, openssl, dbus, cups, pkgconfig
+, libmng, which, libGLSupported, libGL, libGLU, openssl, dbus, cups, pkgconfig
 , libtiff, glib, icu, mysql, postgresql, sqlite, perl, coreutils, libXi
 , buildMultimedia ? stdenv.isLinux, alsaLib, gstreamer, gst-plugins-base
 , buildWebkit ? (stdenv.isLinux || stdenv.isDarwin)
@@ -67,15 +67,29 @@ stdenv.mkDerivation rec {
   patches =
     [ ./glib-2.32.patch
       ./libressl.patch
+      ./parallel-configure.patch
+      ./clang-5-darwin.patch
+      ./qt-4.8.7-unixmake-darwin.patch
       (substituteAll {
         src = ./dlopen-absolute-paths.diff;
         cups = if cups != null then stdenv.lib.getLib cups else null;
         icu = icu.out;
         libXfixes = libXfixes.out;
         glibc = stdenv.cc.libc.out;
-        openglDriver = if mesaSupported then mesa.driverLink else "/no-such-path";
       })
-    ] ++ stdenv.lib.optional gtkStyle (substituteAll ({
+      (fetchpatch {
+        name = "fix-medium-font.patch";
+        url = "http://anonscm.debian.org/cgit/pkg-kde/qt/qt4-x11.git/plain/debian/patches/"
+          + "kubuntu_39_fix_medium_font.diff?id=21b342d71c19e6d68b649947f913410fe6129ea4";
+        sha256 = "0bli44chn03c2y70w1n8l7ss4ya0b40jqqav8yxrykayi01yf95j";
+      })
+      (fetchpatch {
+        name = "qt4-gcc6.patch";
+        url = "https://git.archlinux.org/svntogit/packages.git/plain/trunk/qt4-gcc6.patch?h=packages/qt4&id=ca773a144f5abb244ac4f2749eeee9333cac001f";
+        sha256 = "07lrva7bjh6i40p7b3ml26a2jlznri8bh7y7iyx5zmvb1gfxmj34";
+      })
+    ]
+    ++ stdenv.lib.optional gtkStyle (substituteAll ({
         src = ./dlopen-gtkstyle.diff;
         # substituteAll ignores env vars starting with capital letter
         gtk = gtk2.out;
@@ -93,19 +107,12 @@ stdenv.mkDerivation rec {
         url = "https://src.fedoraproject.org/rpms/qt/raw/ecf530486e0fb7fe31bad26805cde61115562b2b/f/qt-aarch64.patch";
         sha256 = "1fbjh78nmafqmj7yk67qwjbhl3f6ylkp6x33b1dqxfw9gld8b3gl";
       })
-    ++ [
-      (fetchpatch {
-        name = "fix-medium-font.patch";
-        url = "http://anonscm.debian.org/cgit/pkg-kde/qt/qt4-x11.git/plain/debian/patches/"
-          + "kubuntu_39_fix_medium_font.diff?id=21b342d71c19e6d68b649947f913410fe6129ea4";
-        sha256 = "0bli44chn03c2y70w1n8l7ss4ya0b40jqqav8yxrykayi01yf95j";
-      })
-      (fetchpatch {
-        name = "qt4-gcc6.patch";
-        url = "https://git.archlinux.org/svntogit/packages.git/plain/trunk/qt4-gcc6.patch?h=packages/qt4&id=ca773a144f5abb244ac4f2749eeee9333cac001f";
-        sha256 = "07lrva7bjh6i40p7b3ml26a2jlznri8bh7y7iyx5zmvb1gfxmj34";
-      })
-    ];
+    ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
+        ./qt-musl.patch
+        ./qt-musl-iconv-no-bom.patch
+        ./patch-qthread-stacksize.diff
+        ./qsettings-recursive-global-mutex.patch
+      ];
 
   preConfigure = ''
     export LD_LIBRARY_PATH="`pwd`/lib:$LD_LIBRARY_PATH"
@@ -117,6 +124,7 @@ stdenv.mkDerivation rec {
       -demosdir $TMPDIR/share/doc/${name}/demos
       -datadir $out/share/${name}
       -translationdir $out/share/${name}/translations
+      --jobs=$NIX_BUILD_CORES
     "
     unset LD # Makefile uses gcc for linking; setting LD interferes
   '' + optionalString stdenv.cc.isClang ''
@@ -128,7 +136,7 @@ stdenv.mkDerivation rec {
 
   configureFlags =
     ''
-      -v -no-separate-debug-info -release -no-fast -confirm-license -opensource
+      -v -no-separate-debug-info -release -fast -confirm-license -opensource
 
       -${if stdenv.isFreeBSD then "no-" else ""}opengl -xrender -xrandr -xinerama -xcursor -xinput -xfixes -fontconfig
       -qdbus -${if cups == null then "no-" else ""}cups -glib -dbus-linked -openssl-linked
@@ -150,7 +158,7 @@ stdenv.mkDerivation rec {
     [ libXrender libXrandr libXinerama libXcursor libXext libXfixes libXv libXi
       libSM zlib libpng openssl dbus freetype fontconfig glib ]
         # Qt doesn't directly need GLU (just GL), but many apps use, it's small and doesn't remain a runtime-dep if not used
-    ++ optional mesaSupported mesa_glu
+    ++ optional libGLSupported libGLU
     ++ optional ((buildWebkit || buildMultimedia) && stdenv.isLinux ) alsaLib
     ++ optionals (buildWebkit || buildMultimedia) [ gstreamer gst-plugins-base ];
 
@@ -158,22 +166,23 @@ stdenv.mkDerivation rec {
   buildInputs =
     [ cups # Qt dlopen's libcups instead of linking to it
       postgresql sqlite libjpeg libmng libtiff icu ]
-    ++ optionals (mysql != null) [ mysql.lib ]
+    ++ optionals (mysql != null) [ mysql.connector-c ]
     ++ optionals gtkStyle [ gtk2 gdk_pixbuf ]
     ++ optionals stdenv.isDarwin [ cf-private ApplicationServices OpenGL Cocoa AGL libcxx libobjc ];
 
   nativeBuildInputs = [ perl pkgconfig which ];
 
-  enableParallelBuilding = false;
+  enableParallelBuilding = true;
 
   NIX_CFLAGS_COMPILE =
-    optionalString stdenv.isLinux "-std=gnu++98" # gnu++ in (Obj)C flags is no good on Darwin
-    + optionalString (stdenv.isFreeBSD || stdenv.isDarwin)
-      " -I${glib.dev}/include/glib-2.0 -I${glib.out}/lib/glib-2.0/include"
-    + optionalString stdenv.isDarwin " -I${libcxx}/include/c++/v1";
+    # with gcc7 the warnings blow the log over Hydra's limit
+    [ "-Wno-expansion-to-defined" "-Wno-unused-local-typedefs" ]
+    ++ optional stdenv.isLinux "-std=gnu++98" # gnu++ in (Obj)C flags is no good on Darwin
+    ++ optionals (stdenv.isFreeBSD || stdenv.isDarwin)
+      [ "-I${glib.dev}/include/glib-2.0" "-I${glib.out}/lib/glib-2.0/include" ]
+    ++ optional stdenv.isDarwin "-I${libcxx}/include/c++/v1";
 
-  NIX_LDFLAGS = optionalString (stdenv.isFreeBSD || stdenv.isDarwin)
-    "-lglib-2.0";
+  NIX_LDFLAGS = optionalString (stdenv.isFreeBSD || stdenv.isDarwin) "-lglib-2.0";
 
   preBuild = optionalString stdenv.isDarwin ''
     # resolve "extra qualification on member" error
@@ -183,37 +192,8 @@ stdenv.mkDerivation rec {
     sed -i 's/^\(LIBS[[:space:]]*=.*$\)/\1 -lobjc/' ./src/corelib/Makefile.Release
   '';
 
-  installPhase = optionalString stdenv.isDarwin ''
-    runHook preInstall
-    cp -r lib $out
-
-    mkdir -p $out/Applications
-    mv bin/*.app $out/Applications
-    rm -rf bin/*.app
-
-    cp -r bin $out
-
-    mkdir -p $out/share/doc/${name}
-    mkdir -p $out/lib
-    mkdir -p $out/lib/qt4/plugins
-    mkdir -p $out/lib/qt4/imports
-    mkdir -p $out/bin
-    mkdir -p $out/include
-    mkdir -p $out/share/${name}
-
-    cp -r mkspecs $out/share/${name}
-    cp -r translations $out/share/${name}
-    cp -r tools/linguist/phrasebooks $out/share/${name}
-    cp tools/porting/src/q3porting.xml $out/share/${name}
-
-    cp -r plugins $out/lib/qt4
-    cp -r imports $out/lib/qt4
-    cp -r doc/* $out/share/doc/${name}
-    runHook postInstall
-  '';
-
-  postInstall = optionalString (!stdenv.isDarwin) ''
-      rm -rf $out/tests
+  postInstall = ''
+    rm -rf $out/tests
   '';
 
   crossAttrs = {
@@ -229,11 +209,11 @@ stdenv.mkDerivation rec {
     '' + optionalString hostPlatform.isMinGW " -xplatform win32-g++-4.6";
     patches = [];
     preConfigure = ''
-      sed -i -e 's/ g++/ ${stdenv.cc.prefix}g++/' \
-        -e 's/ gcc/ ${stdenv.cc.prefix}gcc/' \
-        -e 's/ ar/ ${stdenv.cc.prefix}ar/' \
-        -e 's/ strip/ ${stdenv.cc.prefix}strip/' \
-        -e 's/ windres/ ${stdenv.cc.prefix}windres/' \
+      sed -i -e 's/ g++/ ${stdenv.cc.targetPrefix}g++/' \
+        -e 's/ gcc/ ${stdenv.cc.targetPrefix}gcc/' \
+        -e 's/ ar/ ${stdenv.cc.targetPrefix}ar/' \
+        -e 's/ strip/ ${stdenv.cc.targetPrefix}strip/' \
+        -e 's/ windres/ ${stdenv.cc.targetPrefix}windres/' \
         mkspecs/win32-g++/qmake.conf
     '';
 
@@ -251,7 +231,7 @@ stdenv.mkDerivation rec {
     homepage    = http://qt-project.org/;
     description = "A cross-platform application framework for C++";
     license     = licenses.lgpl21Plus; # or gpl3
-    maintainers = with maintainers; [ lovek323 phreedom sander ];
+    maintainers = with maintainers; [ orivej lovek323 phreedom sander ];
     platforms   = platforms.unix;
   };
 }
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-4.x/4.8/parallel-configure.patch b/pkgs/development/libraries/qt-4.x/4.8/parallel-configure.patch
new file mode 100644
index 000000000000..b9b9d6d0a683
--- /dev/null
+++ b/pkgs/development/libraries/qt-4.x/4.8/parallel-configure.patch
@@ -0,0 +1,22 @@
+--- a/configure
++++ b/configure
+@@ -1087,2 +1087,3 @@ fi
+ #-------------------------------------------------------------------------------
++JOBS=
+ 
+@@ -2528,2 +2529,5 @@ while [ "$#" -gt 0 ]; do
+         ;;
++    jobs)
++        JOBS=-j$VAL
++        ;;
+     *)
+@@ -5072,3 +5076,3 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
+         if "$WHICH" makedepend >/dev/null 2>&1 && grep 'depend:' "$mkfile" >/dev/null 2>&1; then
+-            (cd "$outpath/qmake" && "$MAKE" -f "$mkfile" depend) >/dev/null 2>&1
++            (cd "$outpath/qmake" && "$MAKE" $JOBS -f "$mkfile" depend) >/dev/null 2>&1
+            sed "s,^.*/\([^/]*.o\):,\1:,g" "$mkfile" >"$mkfile.tmp"
+@@ -5080,3 +5084,3 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
+     QMAKE_BUILD_ERROR=no
+-    (cd "$outpath/qmake"; "$MAKE") || QMAKE_BUILD_ERROR=yes
++    (cd "$outpath/qmake"; "$MAKE" $JOBS) || QMAKE_BUILD_ERROR=yes
+     [ '!' -z "$QCONFIG_H" ] && mv -f "$QCONFIG_H" "$QMAKE_QCONFIG_H" #move qmake's qconfig.h to qconfig.h.qmake
diff --git a/pkgs/development/libraries/qt-4.x/4.8/patch-qthread-stacksize.diff b/pkgs/development/libraries/qt-4.x/4.8/patch-qthread-stacksize.diff
new file mode 100644
index 000000000000..53a4c70ac3ae
--- /dev/null
+++ b/pkgs/development/libraries/qt-4.x/4.8/patch-qthread-stacksize.diff
@@ -0,0 +1,54 @@
+--- a/src/corelib/thread/qthread_unix.cpp.orig	2015-11-23 19:05:40.000000000 +0100
++++ b/src/corelib/thread/qthread_unix.cpp	2015-11-24 11:22:31.000000000 +0100
+@@ -79,6 +79,7 @@
+ #endif
+ 
++#include <sys/resource.h> // getrlimit/setrlimit
+ #if defined(Q_OS_MAC)
+ # ifdef qDebug
+ #   define old_qDebug qDebug
+ #   undef qDebug
+@@ -649,6 +650,43 @@
+ #endif // QT_HAS_THREAD_PRIORITY_SCHEDULING
+ 
+ 
++    if (d->stackSize == 0) {
++        // Fix the default (too small) stack size for threads on OS X,
++        // which also affects the thread pool.
++        // See also:
++        // https://bugreports.qt.io/browse/QTBUG-2568
++        // This fix can also be found in Chromium:
++        // https://chromium.googlesource.com/chromium/src.git/+/master/base/threading/platform_thread_mac.mm#186
++
++        // The Mac OS X default for a pthread stack size is 512kB.
++        // Libc-594.1.4/pthreads/pthread.c's pthread_attr_init uses
++        // DEFAULT_STACK_SIZE for this purpose.
++        //
++        // 512kB isn't quite generous enough for some deeply recursive threads that
++        // otherwise request the default stack size by specifying 0. Here, adopt
++        // glibc's behavior as on Linux, which is to use the current stack size
++        // limit (ulimit -s) as the default stack size. See
++        // glibc-2.11.1/nptl/nptl-init.c's __pthread_initialize_minimal_internal. To
++        // avoid setting the limit below the Mac OS X default or the minimum usable
++        // stack size, these values are also considered. If any of these values
++        // can't be determined, or if stack size is unlimited (ulimit -s unlimited),
++        // stack_size is left at 0 to get the system default.
++        //
++        // Mac OS X normally only applies ulimit -s to the main thread stack. On
++        // contemporary OS X and Linux systems alike, this value is generally 8MB
++        // or in that neighborhood.
++        size_t default_stack_size = 0;
++        struct rlimit stack_rlimit;
++        if (pthread_attr_getstacksize(&attr, &default_stack_size) == 0 &&
++            getrlimit(RLIMIT_STACK, &stack_rlimit) == 0 &&
++            stack_rlimit.rlim_cur != RLIM_INFINITY) {
++            default_stack_size =
++                    std::max(std::max(default_stack_size,
++                                      static_cast<size_t>(PTHREAD_STACK_MIN)),
++                             static_cast<size_t>(stack_rlimit.rlim_cur));
++        }
++        d->stackSize = default_stack_size;
++    }
+     if (d->stackSize > 0) {
+ #if defined(_POSIX_THREAD_ATTR_STACKSIZE) && (_POSIX_THREAD_ATTR_STACKSIZE-0 > 0)
+         int code = pthread_attr_setstacksize(&attr, d->stackSize);
diff --git a/pkgs/development/libraries/qt-4.x/4.8/qmake-hook.sh b/pkgs/development/libraries/qt-4.x/4.8/qmake-hook.sh
index bf716a72d0fc..f288e99dd12a 100644
--- a/pkgs/development/libraries/qt-4.x/4.8/qmake-hook.sh
+++ b/pkgs/development/libraries/qt-4.x/4.8/qmake-hook.sh
@@ -3,6 +3,11 @@ qmakeConfigurePhase() {
 
     $QMAKE PREFIX=$out $qmakeFlags
 
+    if ! [[ -v enableParallelBuilding ]]; then
+        enableParallelBuilding=1
+        echo "qmake4Hook: enabled parallel building"
+    fi
+
     runHook postConfigure
 }
 
diff --git a/pkgs/development/libraries/qt-4.x/4.8/qsettings-recursive-global-mutex.patch b/pkgs/development/libraries/qt-4.x/4.8/qsettings-recursive-global-mutex.patch
new file mode 100644
index 000000000000..229123c54f76
--- /dev/null
+++ b/pkgs/development/libraries/qt-4.x/4.8/qsettings-recursive-global-mutex.patch
@@ -0,0 +1,17 @@
+Calling qsettings before constructing qapplications causes a dead-lock.
+
+http://sourceforge.net/tracker/?func=detail&aid=3168620&group_id=4932&atid=104932
+http://developer.qt.nokia.com/forums/viewthread/10365
+
+
+--- ./src/corelib/io/qsettings.cpp.orig
++++ ./src/corelib/io/qsettings.cpp
+@@ -122,7 +122,7 @@
+ Q_GLOBAL_STATIC(ConfFileCache, unusedCacheFunc)
+ Q_GLOBAL_STATIC(PathHash, pathHashFunc)
+ Q_GLOBAL_STATIC(CustomFormatVector, customFormatVectorFunc)
+-Q_GLOBAL_STATIC(QMutex, globalMutex)
++Q_GLOBAL_STATIC_WITH_ARGS(QMutex, globalMutex, (QMutex::Recursive))
+ static QSettings::Format globalDefaultFormat = QSettings::NativeFormat;
+ 
+ #ifndef Q_OS_WIN
diff --git a/pkgs/development/libraries/qt-4.x/4.8/qt-4.8.7-unixmake-darwin.patch b/pkgs/development/libraries/qt-4.x/4.8/qt-4.8.7-unixmake-darwin.patch
new file mode 100644
index 000000000000..99a36a24fe43
--- /dev/null
+++ b/pkgs/development/libraries/qt-4.x/4.8/qt-4.8.7-unixmake-darwin.patch
@@ -0,0 +1,11 @@
+--- a/qmake/generators/unix/unixmake.cpp
++++ b/qmake/generators/unix/unixmake.cpp
+@@ -831,7 +831,7 @@ UnixMakefileGenerator::defaultInstall(const QString &t)
+             else if(project->first("TEMPLATE") == "app" && !project->isEmpty("QMAKE_STRIPFLAGS_APP"))
+                 ret += " " + var("QMAKE_STRIPFLAGS_APP");
+             if(bundle)
+-                ret = " \"" + dst_targ + "/Contents/MacOS/$(QMAKE_TARGET)\"";
++                ret += " \"" + dst_targ + "/Contents/MacOS/$(QMAKE_TARGET)\"";
+             else
+                 ret += " \"" + dst_targ + "\"";
+         }
diff --git a/pkgs/development/libraries/qt-4.x/4.8/qt-musl-iconv-no-bom.patch b/pkgs/development/libraries/qt-4.x/4.8/qt-musl-iconv-no-bom.patch
new file mode 100644
index 000000000000..35380ad6714d
--- /dev/null
+++ b/pkgs/development/libraries/qt-4.x/4.8/qt-musl-iconv-no-bom.patch
@@ -0,0 +1,11 @@
+--- qt-everywhere-opensource-src-4.8.5/src/corelib/codecs/qiconvcodec.cpp.orig
++++ qt-everywhere-opensource-src-4.8.5/src/corelib/codecs/qiconvcodec.cpp
+@@ -62,7 +62,7 @@
+ #elif defined(Q_OS_AIX)
+ #  define NO_BOM
+ #  define UTF16 "UCS-2"
+-#elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC)
++#elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC) || (defined(Q_OS_LINUX) && !defined(__GLIBC__))
+ #  define NO_BOM
+ #  if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ #    define UTF16 "UTF-16BE"
diff --git a/pkgs/development/libraries/qt-4.x/4.8/qt-musl.patch b/pkgs/development/libraries/qt-4.x/4.8/qt-musl.patch
new file mode 100644
index 000000000000..90b9ccda08c9
--- /dev/null
+++ b/pkgs/development/libraries/qt-4.x/4.8/qt-musl.patch
@@ -0,0 +1,14 @@
+--- qt-everywhere-opensource-src-4.8.5/mkspecs/linux-g++/qplatformdefs.h.orig
++++ qt-everywhere-opensource-src-4.8.5/mkspecs/linux-g++/qplatformdefs.h
+@@ -86,11 +86,7 @@
+ 
+ #undef QT_SOCKLEN_T
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF		::snprintf
diff --git a/pkgs/development/libraries/qt-5/5.10/default.nix b/pkgs/development/libraries/qt-5/5.10/default.nix
new file mode 100644
index 000000000000..a45e055e60b2
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.10/default.nix
@@ -0,0 +1,128 @@
+/*
+
+# Updates
+
+Before a major version update, make a copy of this directory. (We like to
+keep the old version around for a short time after major updates.) Add a
+top-level attribute to `top-level/all-packages.nix`.
+
+1. Update the URL in `pkgs/development/libraries/qt-5/$VERSION/fetch.sh`.
+2. From the top of the Nixpkgs tree, run
+   `./maintainers/scripts/fetch-kde-qt.sh > pkgs/development/libraries/qt-5/$VERSION/srcs.nix`.
+3. Update `qtCompatVersion` below if the minor version number changes.
+4. Check that the new packages build correctly.
+5. Commit the changes and open a pull request.
+
+*/
+
+{
+  newScope,
+  stdenv, fetchurl, makeSetupHook, makeWrapper,
+  bison, cups ? null, harfbuzz, libGL, perl,
+  gstreamer, gst-plugins-base, gtk3, dconf,
+
+  # options
+  developerBuild ? false,
+  decryptSslTraffic ? false,
+  debug ? false,
+}:
+
+with stdenv.lib;
+
+let
+
+  qtCompatVersion = "5.10";
+
+  mirror = "http://download.qt.io";
+  srcs = import ./srcs.nix { inherit fetchurl; inherit mirror; };
+
+  patches = {
+    qtbase = [ ./qtbase.patch ] ++
+      optionals stdenv.isDarwin [ ./qtbase-darwin.patch
+                                  ./restore-pc-files.patch ];
+    qtdeclarative = [ ./qtdeclarative.patch ];
+    qtscript = [ ./qtscript.patch ];
+    qtserialport = [ ./qtserialport.patch ];
+    qttools = [ ./qttools.patch ];
+    qtwebengine = optional stdenv.needsPax ./qtwebengine-paxmark-mksnapshot.patch;
+    qtwebkit = [ ./qtwebkit.patch ];
+  };
+
+  mkDerivation =
+    import ../mkDerivation.nix
+    { inherit stdenv; inherit (stdenv) lib; }
+    { inherit debug; };
+
+  qtModule =
+    import ../qtModule.nix
+    { inherit mkDerivation perl; inherit (stdenv) lib; }
+    { inherit self srcs patches; };
+
+  addPackages = self: with self;
+    let
+      callPackage = self.newScope { inherit qtCompatVersion qtModule srcs; };
+    in {
+
+      inherit mkDerivation;
+
+      qtbase = callPackage ../modules/qtbase.nix {
+        inherit (srcs.qtbase) src version;
+        patches = patches.qtbase;
+        inherit bison cups harfbuzz libGL;
+        withGtk3 = true; inherit dconf gtk3;
+        inherit developerBuild decryptSslTraffic;
+      };
+
+      qtcharts = callPackage ../modules/qtcharts.nix {};
+      qtconnectivity = callPackage ../modules/qtconnectivity.nix {};
+      qtdeclarative = callPackage ../modules/qtdeclarative.nix {};
+      qtdoc = callPackage ../modules/qtdoc.nix {};
+      qtgraphicaleffects = callPackage ../modules/qtgraphicaleffects.nix {};
+      qtimageformats = callPackage ../modules/qtimageformats.nix {};
+      qtlocation = callPackage ../modules/qtlocation.nix {};
+      qtmacextras = callPackage ../modules/qtmacextras.nix {};
+      qtmultimedia = callPackage ../modules/qtmultimedia.nix {
+        inherit gstreamer gst-plugins-base;
+      };
+      qtquick1 = null;
+      qtquickcontrols = callPackage ../modules/qtquickcontrols.nix {};
+      qtquickcontrols2 = callPackage ../modules/qtquickcontrols2.nix {};
+      qtscript = callPackage ../modules/qtscript.nix {};
+      qtsensors = callPackage ../modules/qtsensors.nix {};
+      qtserialport = callPackage ../modules/qtserialport.nix {};
+      qtspeech = callPackage ../modules/qtspeech.nix {};
+      qtsvg = callPackage ../modules/qtsvg.nix {};
+      qttools = callPackage ../modules/qttools.nix {};
+      qttranslations = callPackage ../modules/qttranslations.nix {};
+      qtvirtualkeyboard = callPackage ../modules/qtvirtualkeyboard.nix {};
+      qtwayland = callPackage ../modules/qtwayland.nix {};
+      qtwebchannel = callPackage ../modules/qtwebchannel.nix {};
+      qtwebengine = callPackage ../modules/qtwebengine.nix {};
+      qtwebkit = callPackage ../modules/qtwebkit.nix {};
+      qtwebsockets = callPackage ../modules/qtwebsockets.nix {};
+      qtx11extras = callPackage ../modules/qtx11extras.nix {};
+      qtxmlpatterns = callPackage ../modules/qtxmlpatterns.nix {};
+
+      env = callPackage ../qt-env.nix {};
+      full = env "qt-full-${qtbase.version}" ([
+        qtcharts qtconnectivity qtdeclarative qtdoc qtgraphicaleffects
+        qtimageformats qtlocation qtmultimedia qtquickcontrols qtquickcontrols2
+        qtscript qtsensors qtserialport qtsvg qttools qttranslations
+        qtvirtualkeyboard qtwebchannel qtwebengine qtwebkit qtwebsockets
+        qtx11extras qtxmlpatterns
+      ] ++ optional (!stdenv.isDarwin) qtwayland
+        ++ optional (stdenv.isDarwin) qtmacextras);
+
+      qmake = makeSetupHook {
+        deps = [ self.qtbase.dev ];
+        substitutions = {
+          inherit (stdenv) isDarwin;
+          qtbase_dev = self.qtbase.dev;
+          fix_qt_builtin_paths = ../hooks/fix-qt-builtin-paths.sh;
+        };
+      } ../hooks/qmake-hook.sh;
+    };
+
+   self = makeScope newScope addPackages;
+
+in self
diff --git a/pkgs/development/libraries/qt-5/5.10/fetch.sh b/pkgs/development/libraries/qt-5/5.10/fetch.sh
new file mode 100644
index 000000000000..4770644ae4e9
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.10/fetch.sh
@@ -0,0 +1,2 @@
+WGET_ARGS=( http://download.qt.io/official_releases/qt/5.10/5.10.1/submodules/ \
+            -A '*.tar.xz' )
diff --git a/pkgs/development/libraries/qt-5/5.10/qtbase-darwin.patch b/pkgs/development/libraries/qt-5/5.10/qtbase-darwin.patch
new file mode 100644
index 000000000000..fa389fe55c2f
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.10/qtbase-darwin.patch
@@ -0,0 +1,70 @@
+diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
+index 66baf16..89794ef 100644
+--- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
++++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
+@@ -830,7 +830,7 @@ void QCoreTextFontEngine::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, gl
+ 
+ QFixed QCoreTextFontEngine::emSquareSize() const
+ {
+-    return QFixed::QFixed(int(CTFontGetUnitsPerEm(ctfont)));
++    return QFixed(int(CTFontGetUnitsPerEm(ctfont)));
+ }
+ 
+ QFontEngine *QCoreTextFontEngine::cloneWithSize(qreal pixelSize) const
+diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm
+index 341d3bccf2..3368234c26 100644
+--- a/src/plugins/bearer/corewlan/qcorewlanengine.mm
++++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm
+@@ -287,7 +287,7 @@ void QScanThread::getUserConfigurations()
+     QMacAutoReleasePool pool;
+     userProfiles.clear();
+ 
+-    NSArray<NSString *> *wifiInterfaces = [CWWiFiClient interfaceNames];
++    NSArray *wifiInterfaces = [CWWiFiClient interfaceNames];
+     for (NSString *ifName in wifiInterfaces) {
+ 
+         CWInterface *wifiInterface = [[CWWiFiClient sharedWiFiClient] interfaceWithName:ifName];
+@@ -602,7 +602,7 @@ void QCoreWlanEngine::doRequestUpdate()
+ 
+     QMacAutoReleasePool pool;
+ 
+-    NSArray<NSString *> *wifiInterfaces = [CWWiFiClient interfaceNames];
++    NSArray *wifiInterfaces = [CWWiFiClient interfaceNames];
+     for (NSString *ifName in wifiInterfaces) {
+             scanThread->interfaceName = QString::fromNSString(ifName);
+             scanThread->start();
+diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
+index d1f19f2..1ac2cf1 100644
+--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
++++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
+@@ -1699,7 +1699,7 @@ void QCocoaWindow::applyContentBorderThickness(NSWindow *window)
+
+     if (!m_drawContentBorderGradient) {
+         window.styleMask = window.styleMask & ~NSTexturedBackgroundWindowMask;
+-        [window.contentView.superview setNeedsDisplay:YES];
++        [[window.contentView superview] setNeedsDisplay:YES];
+         window.titlebarAppearsTransparent = NO;
+         return;
+     }
+diff --git a/src/plugins/platforms/cocoa/qnswindow.mm b/src/plugins/platforms/cocoa/qnswindow.mm
+index e846fa0..4171cd4 100644
+--- a/src/plugins/platforms/cocoa/qnswindow.mm
++++ b/src/plugins/platforms/cocoa/qnswindow.mm
+@@ -224,7 +224,7 @@ static bool isMouseEvent(NSEvent *ev)
+     if (pw->frameStrutEventsEnabled() && isMouseEvent(theEvent)) {
+         NSPoint loc = [theEvent locationInWindow];
+         NSRect windowFrame = [self convertRectFromScreen:self.frame];
+-        NSRect contentFrame = self.contentView.frame;
++        NSRect contentFrame = [self.contentView frame];
+         if (NSMouseInRect(loc, windowFrame, NO) && !NSMouseInRect(loc, contentFrame, NO))
+             [qnsview_cast(pw->view()) handleFrameStrutMouseEvent:theEvent];
+     }
+@@ -253,7 +253,7 @@ static bool isMouseEvent(NSEvent *ev)
+ + (void)applicationActivationChanged:(NSNotification*)notification
+ {
+     const id sender = self;
+-    NSEnumerator<NSWindow*> *windowEnumerator = nullptr;
++    NSEnumerator *windowEnumerator = nullptr;
+     NSApplication *application = [NSApplication sharedApplication];
+
+ #if QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12)
diff --git a/pkgs/development/libraries/qt-5/5.10/qtbase.patch b/pkgs/development/libraries/qt-5/5.10/qtbase.patch
new file mode 100644
index 000000000000..286dea2178b1
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.10/qtbase.patch
@@ -0,0 +1,1152 @@
+diff --git a/mkspecs/common/mac.conf b/mkspecs/common/mac.conf
+index 5208379f9a..92fe29a0ac 100644
+--- a/mkspecs/common/mac.conf
++++ b/mkspecs/common/mac.conf
+@@ -23,7 +23,7 @@ QMAKE_INCDIR_OPENGL     = \
+ 
+ QMAKE_FIX_RPATH         = install_name_tool -id
+ 
+-QMAKE_LFLAGS_RPATH      = -Wl,-rpath,
++QMAKE_LFLAGS_RPATH      =
+ QMAKE_LFLAGS_GCSECTIONS = -Wl,-dead_strip
+ 
+ QMAKE_LFLAGS_REL_RPATH  =
+diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
+index bb5083c925..77034f9bb6 100644
+--- a/mkspecs/features/create_cmake.prf
++++ b/mkspecs/features/create_cmake.prf
+@@ -21,7 +21,7 @@ load(cmake_functions)
+ # at cmake time whether package has been found via a symlink, and correct
+ # that to an absolute path. This is only done for installations to
+ # the /usr or / prefix.
+-CMAKE_INSTALL_LIBS_DIR = $$cmakeTargetPath($$[QT_INSTALL_LIBS])
++CMAKE_INSTALL_LIBS_DIR = $$cmakeTargetPath($$NIX_OUTPUT_OUT/lib/)
+ contains(CMAKE_INSTALL_LIBS_DIR, ^(/usr)?/lib(64)?.*): CMAKE_USR_MOVE_WORKAROUND = $$CMAKE_INSTALL_LIBS_DIR
+ 
+ CMAKE_OUT_DIR = $$MODULE_BASE_OUTDIR/lib/cmake
+@@ -47,47 +47,22 @@ split_incpath {
+         $$cmake_extra_source_includes.output
+ }
+ 
+-CMAKE_INCLUDE_DIR = $$cmakeRelativePath($$[QT_INSTALL_HEADERS], $$[QT_INSTALL_PREFIX])
+-contains(CMAKE_INCLUDE_DIR, "^\\.\\./.*") {
+-    CMAKE_INCLUDE_DIR = $$[QT_INSTALL_HEADERS]/
+-    CMAKE_INCLUDE_DIR_IS_ABSOLUTE = True
+-}
++CMAKE_INCLUDE_DIR = $$NIX_OUTPUT_DEV/include/
++CMAKE_INCLUDE_DIR_IS_ABSOLUTE = True
+ 
+ !exists($$first(QT.$${MODULE}_private.includes)): CMAKE_NO_PRIVATE_INCLUDES = true
+ 
+-CMAKE_LIB_DIR = $$cmakeRelativePath($$[QT_INSTALL_LIBS], $$[QT_INSTALL_PREFIX])
+-contains(CMAKE_LIB_DIR,"^\\.\\./.*") {
+-    CMAKE_LIB_DIR = $$[QT_INSTALL_LIBS]/
+-    CMAKE_LIB_DIR_IS_ABSOLUTE = True
+-} else {
+-    CMAKE_RELATIVE_INSTALL_LIBS_DIR = $$cmakeRelativePath($$[QT_INSTALL_PREFIX], $$[QT_INSTALL_LIBS])
+-    # We need to go up another two levels because the CMake files are
+-    # installed in $${CMAKE_LIB_DIR}/cmake/Qt5$${CMAKE_MODULE_NAME}
+-    CMAKE_RELATIVE_INSTALL_DIR = "$${CMAKE_RELATIVE_INSTALL_LIBS_DIR}../../"
+-}
++CMAKE_LIB_DIR = $$NIX_OUTPUT_OUT/lib/
++CMAKE_LIB_DIR_IS_ABSOLUTE = True
+ 
+-CMAKE_BIN_DIR = $$cmakeRelativePath($$[QT_HOST_BINS], $$[QT_INSTALL_PREFIX])
+-contains(CMAKE_BIN_DIR, "^\\.\\./.*") {
+-    CMAKE_BIN_DIR = $$[QT_HOST_BINS]/
+-    CMAKE_BIN_DIR_IS_ABSOLUTE = True
+-}
++CMAKE_BIN_DIR = $$NIX_OUTPUT_BIN/bin/
++CMAKE_BIN_DIR_IS_ABSOLUTE = True
+ 
+-CMAKE_PLUGIN_DIR = $$cmakeRelativePath($$[QT_INSTALL_PLUGINS], $$[QT_INSTALL_PREFIX])
+-contains(CMAKE_PLUGIN_DIR, "^\\.\\./.*") {
+-    CMAKE_PLUGIN_DIR = $$[QT_INSTALL_PLUGINS]/
+-    CMAKE_PLUGIN_DIR_IS_ABSOLUTE = True
+-}
++CMAKE_PLUGIN_DIR = $$NIX_OUTPUT_PLUGIN/
++CMAKE_PLUGIN_DIR_IS_ABSOLUTE = True
+ 
+-win32:!static:!staticlib {
+-    CMAKE_DLL_DIR = $$cmakeRelativePath($$[QT_INSTALL_BINS], $$[QT_INSTALL_PREFIX])
+-    contains(CMAKE_DLL_DIR, "^\\.\\./.*") {
+-        CMAKE_DLL_DIR = $$[QT_INSTALL_BINS]/
+-        CMAKE_DLL_DIR_IS_ABSOLUTE = True
+-    }
+-} else {
+-    CMAKE_DLL_DIR = $$CMAKE_LIB_DIR
+-    CMAKE_DLL_DIR_IS_ABSOLUTE = $$CMAKE_LIB_DIR_IS_ABSOLUTE
+-}
++CMAKE_DLL_DIR = $$NIX_OUTPUT_OUT/lib/
++CMAKE_DLL_DIR_IS_ABSOLUTE = True
+ 
+ static|staticlib:CMAKE_STATIC_TYPE = true
+ 
+@@ -167,7 +142,7 @@ contains(CONFIG, plugin) {
+       cmake_target_file
+ 
+     cmake_qt5_plugin_file.files = $$cmake_target_file.output
+-    cmake_qt5_plugin_file.path = $$[QT_INSTALL_LIBS]/cmake/Qt5$${CMAKE_MODULE_NAME}
++    cmake_qt5_plugin_file.path = $$NIX_OUTPUT_OUT/lib/cmake/Qt5$${CMAKE_MODULE_NAME}
+     INSTALLS += cmake_qt5_plugin_file
+ 
+     return()
+@@ -314,7 +289,7 @@ exists($$cmake_macros_file.input) {
+     cmake_qt5_module_files.files += $$cmake_macros_file.output
+ }
+ 
+-cmake_qt5_module_files.path = $$[QT_INSTALL_LIBS]/cmake/Qt5$${CMAKE_MODULE_NAME}
++cmake_qt5_module_files.path = $$NIX_OUTPUT_OUT/lib/cmake/Qt5$${CMAKE_MODULE_NAME}
+ 
+ # We are generating cmake files. Most developers of Qt are not aware of cmake,
+ # so we require automatic tests to be available. The only module which should
+diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+index 55c74aad66..0bbc8718eb 100644
+--- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
++++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+@@ -9,30 +9,6 @@ if (CMAKE_VERSION VERSION_LESS 3.0.0)
+ endif()
+ !!ENDIF
+ 
+-!!IF !isEmpty(CMAKE_USR_MOVE_WORKAROUND)
+-!!IF !isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-set(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$[QT_INSTALL_PREFIX]\")
+-!!ELSE
+-get_filename_component(_IMPORT_PREFIX \"${CMAKE_CURRENT_LIST_FILE}\" PATH)
+-# Use original install prefix when loaded through a
+-# cross-prefix symbolic link such as /lib -> /usr/lib.
+-get_filename_component(_realCurr \"${_IMPORT_PREFIX}\" REALPATH)
+-get_filename_component(_realOrig \"$$CMAKE_INSTALL_LIBS_DIR/cmake/Qt5$${CMAKE_MODULE_NAME}\" REALPATH)
+-if(_realCurr STREQUAL _realOrig)
+-    get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$CMAKE_INSTALL_LIBS_DIR/$${CMAKE_RELATIVE_INSTALL_LIBS_DIR}\" ABSOLUTE)
+-else()
+-    get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
+-endif()
+-unset(_realOrig)
+-unset(_realCurr)
+-unset(_IMPORT_PREFIX)
+-!!ENDIF
+-!!ELIF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
+-!!ELSE
+-set(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$[QT_INSTALL_PREFIX]\")
+-!!ENDIF
+-
+ !!IF !equals(TEMPLATE, aux)
+ # For backwards compatibility only. Use Qt5$${CMAKE_MODULE_NAME}_VERSION instead.
+ set(Qt5$${CMAKE_MODULE_NAME}_VERSION_STRING "$$eval(QT.$${MODULE}.VERSION)")
+@@ -58,11 +34,7 @@ endmacro()
+ macro(_populate_$${CMAKE_MODULE_NAME}_target_properties Configuration LIB_LOCATION IMPLIB_LOCATION)
+     set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
+ 
+-!!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
+-!!ENDIF
+     _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
+     set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
+         \"INTERFACE_LINK_LIBRARIES\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\"
+@@ -75,11 +47,7 @@ macro(_populate_$${CMAKE_MODULE_NAME}_target_properties Configuration LIB_LOCATI
+     )
+ 
+ !!IF !isEmpty(CMAKE_WINDOWS_BUILD)
+-!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    set(imported_implib \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
+-!!ELSE
+     set(imported_implib \"IMPORTED_IMPLIB_${Configuration}\" \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
+-!!ENDIF
+     _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_implib})
+     if(NOT \"${IMPLIB_LOCATION}\" STREQUAL \"\")
+         set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
+@@ -95,24 +63,13 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ !!IF !no_module_headers
+ !!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
+     set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS
+-      \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework\"
+-      \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Headers\"
++      \"$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework\"
++      \"$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Headers\"
+     )
+ !!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
+     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/\"
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/$${MODULE_INCNAME}\"
+-    )
+-!!ELSE
+-    set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
+-!!ENDIF
+-!!ELSE
+-!!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
+-    set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR\" \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}\")
+-!!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
+-    set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION\"
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION/$${MODULE_INCNAME}\"
++        \"$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/\"
++        \"$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/$${MODULE_INCNAME}\"
+     )
+ !!ELSE
+     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
+@@ -128,7 +85,6 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
+ !!ENDIF
+ !!ENDIF
+-!!ENDIF
+ !!IF !isEmpty(CMAKE_ADD_SOURCE_INCLUDE_DIRS)
+     include(\"${CMAKE_CURRENT_LIST_DIR}/ExtraSourceIncludes.cmake\" OPTIONAL)
+ !!ENDIF
+@@ -280,25 +236,13 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
+ !!IF isEmpty(CMAKE_DEBUG_TYPE)
+ !!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
+-!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+-!!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
+     if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+-!!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
+         _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" \"\" )
+ !!ELSE // CMAKE_STATIC_WINDOWS_BUILD
+     if (EXISTS
+-!!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
+-!!ELSE
+         \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
+-!!ENDIF
+       AND EXISTS
+-!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+-!!ELSE
+         \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+-!!ENDIF
+         _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+ !!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
+     endif()
+@@ -317,25 +261,13 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
+ !!IF isEmpty(CMAKE_RELEASE_TYPE)
+ !!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
+-!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+-!!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
+     if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+-!!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
+         _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" \"\" )
+ !!ELSE // CMAKE_STATIC_WINDOWS_BUILD
+     if (EXISTS
+-!!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
+-!!ELSE
+         \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
+-!!ENDIF
+       AND EXISTS
+-!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+-!!ELSE
+         \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+-!!ENDIF
+         _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+ !!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
+     endif()
+@@ -354,11 +286,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+     macro(_populate_$${CMAKE_MODULE_NAME}_plugin_properties Plugin Configuration PLUGIN_LOCATION)
+         set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
+ 
+-!!IF isEmpty(CMAKE_PLUGIN_DIR_IS_ABSOLUTE)
+-        set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
+-!!ELSE
+         set(imported_location \"$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
+-!!ENDIF
+         _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
+         set_target_properties(Qt5::${Plugin} PROPERTIES
+             \"IMPORTED_LOCATION_${Configuration}\" ${imported_location}
+diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf
+index 50a1ec6764..d6368b769e 100644
+--- a/mkspecs/features/mac/default_post.prf
++++ b/mkspecs/features/mac/default_post.prf
+@@ -25,188 +25,3 @@ qt {
+     }
+ }
+ 
+-# Add the same default rpaths as Xcode does for new projects.
+-# This is especially important for iOS/tvOS/watchOS where no other option is possible.
+-!no_default_rpath {
+-    QMAKE_RPATHDIR += @executable_path/Frameworks
+-    equals(TEMPLATE, lib):!plugin:lib_bundle: QMAKE_RPATHDIR += @loader_path/Frameworks
+-}
+-
+-# Don't pass -headerpad_max_install_names when using Bitcode.
+-# In that case the linker emits a warning stating that the flag is ignored when
+-# used with bitcode, for reasons that cannot be determined (rdar://problem/20748962).
+-# Using this flag is also unnecessary in practice on UIKit platforms since they
+-# are sandboxed, and only UIKit platforms support bitcode to begin with.
+-!bitcode: QMAKE_LFLAGS += $$QMAKE_LFLAGS_HEADERPAD
+-
+-app_extension_api_only {
+-    QMAKE_CFLAGS              += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
+-    QMAKE_CXXFLAGS            += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
+-    QMAKE_CXXFLAGS_PRECOMPILE += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
+-    QMAKE_LFLAGS              += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
+-}
+-
+-macx-xcode {
+-    qmake_pkginfo_typeinfo.name = QMAKE_PKGINFO_TYPEINFO
+-    !isEmpty(QMAKE_PKGINFO_TYPEINFO): \
+-        qmake_pkginfo_typeinfo.value = $$QMAKE_PKGINFO_TYPEINFO
+-    else: \
+-        qmake_pkginfo_typeinfo.value = "????"
+-    QMAKE_MAC_XCODE_SETTINGS += qmake_pkginfo_typeinfo
+-
+-    !isEmpty(VERSION) {
+-        l = $$split(VERSION, '.') 0 0  # make sure there are at least three
+-        VER_MAJ = $$member(l, 0, 0)
+-        VER_MIN = $$member(l, 1, 1)
+-        VER_PAT = $$member(l, 2, 2)
+-        unset(l)
+-
+-        qmake_full_version.name = QMAKE_FULL_VERSION
+-        qmake_full_version.value = $${VER_MAJ}.$${VER_MIN}.$${VER_PAT}
+-        QMAKE_MAC_XCODE_SETTINGS += qmake_full_version
+-
+-        qmake_short_version.name = QMAKE_SHORT_VERSION
+-        qmake_short_version.value = $${VER_MAJ}.$${VER_MIN}
+-        QMAKE_MAC_XCODE_SETTINGS += qmake_short_version
+-    }
+-
+-    !isEmpty(QMAKE_XCODE_DEBUG_INFORMATION_FORMAT) {
+-        debug_information_format.name = DEBUG_INFORMATION_FORMAT
+-        debug_information_format.value = $$QMAKE_XCODE_DEBUG_INFORMATION_FORMAT
+-        debug_information_format.build = debug
+-        QMAKE_MAC_XCODE_SETTINGS += debug_information_format
+-    }
+-
+-    QMAKE_XCODE_ARCHS =
+-
+-    arch_device.name = "ARCHS[sdk=$${device.sdk}*]"
+-    arch_device.value = $$QMAKE_APPLE_DEVICE_ARCHS
+-    QMAKE_XCODE_ARCHS += $$QMAKE_APPLE_DEVICE_ARCHS
+-    QMAKE_MAC_XCODE_SETTINGS += arch_device
+-
+-    simulator {
+-        arch_simulator.name = "ARCHS[sdk=$${simulator.sdk}*]"
+-        arch_simulator.value = $$QMAKE_APPLE_SIMULATOR_ARCHS
+-        QMAKE_XCODE_ARCHS += $$QMAKE_APPLE_SIMULATOR_ARCHS
+-        QMAKE_MAC_XCODE_SETTINGS += arch_simulator
+-    }
+-
+-    only_active_arch.name = ONLY_ACTIVE_ARCH
+-    only_active_arch.value = YES
+-    only_active_arch.build = debug
+-    QMAKE_MAC_XCODE_SETTINGS += only_active_arch
+-} else {
+-    device|!simulator: VALID_DEVICE_ARCHS = $$QMAKE_APPLE_DEVICE_ARCHS
+-    simulator: VALID_SIMULATOR_ARCHS = $$QMAKE_APPLE_SIMULATOR_ARCHS
+-    VALID_ARCHS = $$VALID_DEVICE_ARCHS $$VALID_SIMULATOR_ARCHS
+-
+-    isEmpty(VALID_ARCHS): \
+-        error("QMAKE_APPLE_DEVICE_ARCHS or QMAKE_APPLE_SIMULATOR_ARCHS must contain at least one architecture")
+-
+-    single_arch: VALID_ARCHS = $$first(VALID_ARCHS)
+-
+-    ACTIVE_ARCHS = $(filter $(EXPORT_VALID_ARCHS), $(ARCHS))
+-    ARCH_ARGS = $(foreach arch, $(if $(EXPORT_ACTIVE_ARCHS), $(EXPORT_ACTIVE_ARCHS), $(EXPORT_VALID_ARCHS)), -arch $(arch))
+-
+-    QMAKE_EXTRA_VARIABLES += VALID_ARCHS ACTIVE_ARCHS ARCH_ARGS
+-
+-    arch_flags = $(EXPORT_ARCH_ARGS)
+-
+-    QMAKE_CFLAGS += $$arch_flags
+-    QMAKE_CXXFLAGS += $$arch_flags
+-    QMAKE_LFLAGS += $$arch_flags
+-
+-    QMAKE_PCH_ARCHS = $$VALID_ARCHS
+-
+-    macos: deployment_target = $$QMAKE_MACOSX_DEPLOYMENT_TARGET
+-    ios: deployment_target = $$QMAKE_IOS_DEPLOYMENT_TARGET
+-    tvos: deployment_target = $$QMAKE_TVOS_DEPLOYMENT_TARGET
+-    watchos: deployment_target = $$QMAKE_WATCHOS_DEPLOYMENT_TARGET
+-
+-    # If we're doing a simulator and device build, device and simulator
+-    # architectures use different paths and flags for the sysroot and
+-    # deployment target switch, so we must multiplex them across multiple
+-    # architectures using -Xarch. Otherwise we fall back to the simple path.
+-    # This is not strictly necessary, but results in cleaner command lines
+-    # and makes it easier for people to override EXPORT_VALID_ARCHS to limit
+-    # individual rules to a different set of architecture(s) from the overall
+-    # build (such as machtest in QtCore).
+-    simulator:device {
+-        QMAKE_XARCH_CFLAGS =
+-        QMAKE_XARCH_LFLAGS =
+-        QMAKE_EXTRA_VARIABLES += QMAKE_XARCH_CFLAGS QMAKE_XARCH_LFLAGS
+-
+-        for (arch, VALID_ARCHS) {
+-            contains(VALID_SIMULATOR_ARCHS, $$arch) {
+-                sdk = $$simulator.sdk
+-                version_identifier = $$simulator.deployment_identifier
+-            } else {
+-                sdk = $$device.sdk
+-                version_identifier = $$device.deployment_identifier
+-            }
+-
+-            version_min_flags = \
+-                -Xarch_$${arch} \
+-                -m$${version_identifier}-version-min=$$deployment_target
+-            QMAKE_XARCH_CFLAGS_$${arch} = $$version_min_flags \
+-                -Xarch_$${arch} \
+-                -isysroot$$xcodeSDKInfo(Path, $$sdk)
+-            QMAKE_XARCH_LFLAGS_$${arch} = $$version_min_flags \
+-                -Xarch_$${arch} \
+-                -Wl,-syslibroot,$$xcodeSDKInfo(Path, $$sdk)
+-
+-            QMAKE_XARCH_CFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS_$${arch})
+-            QMAKE_XARCH_LFLAGS += $(EXPORT_QMAKE_XARCH_LFLAGS_$${arch})
+-
+-            QMAKE_EXTRA_VARIABLES += \
+-                QMAKE_XARCH_CFLAGS_$${arch} \
+-                QMAKE_XARCH_LFLAGS_$${arch}
+-        }
+-
+-        QMAKE_CFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS)
+-        QMAKE_CXXFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS)
+-        QMAKE_LFLAGS += $(EXPORT_QMAKE_XARCH_LFLAGS)
+-    } else {
+-        simulator: \
+-            version_identifier = $$simulator.deployment_identifier
+-        else: \
+-            version_identifier = $$device.deployment_identifier
+-        version_min_flag = -m$${version_identifier}-version-min=$$deployment_target
+-        QMAKE_CFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag
+-        QMAKE_CXXFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag
+-        QMAKE_LFLAGS += -Wl,-syslibroot,$$QMAKE_MAC_SDK_PATH $$version_min_flag
+-    }
+-
+-    # Enable precompiled headers for multiple architectures
+-    QMAKE_CFLAGS_USE_PRECOMPILE =
+-    for (arch, VALID_ARCHS) {
+-        icc_pch_style: \
+-            use_flag = "-pch-use "
+-        else: \
+-            use_flag = -include
+-
+-        # Only use Xarch with multi-arch, as the option confuses ccache
+-        count(VALID_ARCHS, 1, greaterThan): \
+-            QMAKE_CFLAGS_USE_PRECOMPILE += \
+-                -Xarch_$${arch}
+-
+-        QMAKE_CFLAGS_USE_PRECOMPILE += \
+-            $${use_flag}${QMAKE_PCH_OUTPUT_$${arch}}
+-    }
+-    icc_pch_style {
+-        QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE -include ${QMAKE_PCH_INPUT}
+-        QMAKE_CFLAGS_USE_PRECOMPILE =
+-    } else {
+-        QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
+-        QMAKE_OBJCFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
+-        QMAKE_OBJCXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
+-    }
+-
+-    QMAKE_PCH_OUTPUT_EXT = _${QMAKE_PCH_ARCH}$${QMAKE_PCH_OUTPUT_EXT}
+-}
+-
+-cache(QMAKE_XCODE_DEVELOPER_PATH, stash)
+-!isEmpty(QMAKE_XCODE_VERSION): \
+-    cache(QMAKE_XCODE_VERSION, stash)
+-
+-QMAKE_XCODE_LIBRARY_SUFFIX = $$qtPlatformTargetSuffix()
+diff --git a/mkspecs/features/mac/default_pre.prf b/mkspecs/features/mac/default_pre.prf
+index f1a4ca77b2..3b01424e67 100644
+--- a/mkspecs/features/mac/default_pre.prf
++++ b/mkspecs/features/mac/default_pre.prf
+@@ -1,67 +1,2 @@
+ CONFIG = asset_catalogs rez $$CONFIG
+ load(default_pre)
+-
+-isEmpty(QMAKE_XCODE_DEVELOPER_PATH) {
+-    # Get path of Xcode's Developer directory
+-    QMAKE_XCODE_DEVELOPER_PATH = $$system("/usr/bin/xcode-select --print-path 2>/dev/null")
+-    isEmpty(QMAKE_XCODE_DEVELOPER_PATH): \
+-        error("Xcode path is not set. Please use xcode-select to choose Xcode installation path.")
+-
+-    # Make sure Xcode path is valid
+-    !exists($$QMAKE_XCODE_DEVELOPER_PATH): \
+-        error("Xcode is not installed in $${QMAKE_XCODE_DEVELOPER_PATH}. Please use xcode-select to choose Xcode installation path.")
+-}
+-
+-isEmpty(QMAKE_XCODEBUILD_PATH): \
+-    QMAKE_XCODEBUILD_PATH = $$system("/usr/bin/xcrun -find xcodebuild 2>/dev/null")
+-
+-!isEmpty(QMAKE_XCODEBUILD_PATH) {
+-    # Make sure Xcode is set up properly
+-    !system("/usr/bin/xcrun xcodebuild -license check 2>/dev/null"): \
+-        error("Xcode not set up properly. You need to confirm the license agreement by running 'sudo xcrun xcodebuild -license accept'.")
+-
+-    isEmpty(QMAKE_XCODE_VERSION) {
+-        # Extract Xcode version using xcodebuild
+-        xcode_version = $$system("/usr/bin/xcrun xcodebuild -version")
+-        QMAKE_XCODE_VERSION = $$member(xcode_version, 1)
+-        isEmpty(QMAKE_XCODE_VERSION): error("Could not resolve Xcode version.")
+-        unset(xcode_version)
+-    }
+-}
+-
+-isEmpty(QMAKE_TARGET_BUNDLE_PREFIX) {
+-    QMAKE_XCODE_PREFERENCES_FILE = $$(HOME)/Library/Preferences/com.apple.dt.Xcode.plist
+-    exists($$QMAKE_XCODE_PREFERENCES_FILE): \
+-        QMAKE_TARGET_BUNDLE_PREFIX = $$system("/usr/libexec/PlistBuddy -c 'print IDETemplateOptions:bundleIdentifierPrefix' $$QMAKE_XCODE_PREFERENCES_FILE 2>/dev/null")
+-
+-    !isEmpty(_QMAKE_CACHE_):!isEmpty(QMAKE_TARGET_BUNDLE_PREFIX): \
+-        cache(QMAKE_TARGET_BUNDLE_PREFIX)
+-}
+-
+-QMAKE_ASSET_CATALOGS_APP_ICON = AppIcon
+-
+-# Make the default debug info format for static debug builds
+-# DWARF instead of DWARF with dSYM. This cuts down build times
+-# for application debug builds significantly, as Xcode doesn't
+-# have to pull out all the DWARF info from the Qt static libs
+-# and put it into a dSYM file. We don't need that dSYM file in
+-# the first place, since the information is available in the
+-# object files inside the archives (static libraries).
+-macx-xcode:qtConfig(static): \
+-    QMAKE_XCODE_DEBUG_INFORMATION_FORMAT = dwarf
+-
+-# This variable is used by the xcode_dynamic_library_suffix
+-# feature, which allows Xcode to choose the Qt libraries to link to
+-# at build time, depending on the current Xcode SDK and configuration.
+-QMAKE_XCODE_LIBRARY_SUFFIX_SETTING = QT_LIBRARY_SUFFIX
+-
+-xcode_copy_phase_strip_setting.name = COPY_PHASE_STRIP
+-xcode_copy_phase_strip_setting.value = NO
+-QMAKE_MAC_XCODE_SETTINGS += xcode_copy_phase_strip_setting
+-
+-xcode_product_bundle_identifier_setting.name = PRODUCT_BUNDLE_IDENTIFIER
+-xcode_product_bundle_identifier_setting.value = $$QMAKE_TARGET_BUNDLE_PREFIX
+-isEmpty(xcode_product_bundle_identifier_setting.value): \
+-    xcode_product_bundle_identifier_setting.value = "com.yourcompany"
+-xcode_product_bundle_identifier_setting.value = "$${xcode_product_bundle_identifier_setting.value}.${PRODUCT_NAME:rfc1034identifier}"
+-QMAKE_MAC_XCODE_SETTINGS += xcode_product_bundle_identifier_setting
+diff --git a/mkspecs/features/mac/sdk.prf b/mkspecs/features/mac/sdk.prf
+index 3f6dc076ca..e69de29bb2 100644
+--- a/mkspecs/features/mac/sdk.prf
++++ b/mkspecs/features/mac/sdk.prf
+@@ -1,58 +0,0 @@
+-
+-isEmpty(QMAKE_MAC_SDK): \
+-    error("QMAKE_MAC_SDK must be set when using CONFIG += sdk.")
+-
+-contains(QMAKE_MAC_SDK, .*/.*): \
+-    error("QMAKE_MAC_SDK can only contain short-form SDK names (eg. macosx, iphoneos)")
+-
+-defineReplace(xcodeSDKInfo) {
+-    info = $$1
+-    equals(info, "Path"): \
+-        info = --show-sdk-path
+-    equals(info, "PlatformPath"): \
+-        info = --show-sdk-platform-path
+-    equals(info, "SDKVersion"): \
+-        info = --show-sdk-version
+-    sdk = $$2
+-    isEmpty(sdk): \
+-        sdk = $$QMAKE_MAC_SDK
+-
+-    isEmpty(QMAKE_MAC_SDK.$${sdk}.$${info}) {
+-        QMAKE_MAC_SDK.$${sdk}.$${info} = $$system("/usr/bin/xcrun --sdk $$sdk $$info 2>/dev/null")
+-        # --show-sdk-platform-path won't work for Command Line Tools; this is fine
+-        # only used by the XCTest backend to testlib
+-        isEmpty(QMAKE_MAC_SDK.$${sdk}.$${info}):if(!isEmpty(QMAKE_XCODEBUILD_PATH)|!equals(info, "--show-sdk-platform-path")): \
+-            error("Could not resolve SDK $$info for \'$$sdk\'")
+-        cache(QMAKE_MAC_SDK.$${sdk}.$${info}, set stash, QMAKE_MAC_SDK.$${sdk}.$${info})
+-    }
+-
+-    return($$eval(QMAKE_MAC_SDK.$${sdk}.$${info}))
+-}
+-
+-QMAKE_MAC_SDK_PATH = $$xcodeSDKInfo(Path)
+-QMAKE_MAC_SDK_PLATFORM_PATH = $$xcodeSDKInfo(PlatformPath)
+-QMAKE_MAC_SDK_VERSION = $$xcodeSDKInfo(SDKVersion)
+-
+-sysrootified =
+-for(val, QMAKE_INCDIR_OPENGL): sysrootified += $${QMAKE_MAC_SDK_PATH}$$val
+-QMAKE_INCDIR_OPENGL = $$sysrootified
+-
+-QMAKESPEC_NAME = $$basename(QMAKESPEC)
+-
+-# Resolve SDK version of various tools
+-for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_FIX_RPATH QMAKE_AR QMAKE_RANLIB QMAKE_LINK QMAKE_LINK_SHLIB QMAKE_ACTOOL)) {
+-    tool_variable = QMAKE_MAC_SDK.$${QMAKESPEC_NAME}.$${QMAKE_MAC_SDK}.$${tool}
+-    !isEmpty($$tool_variable) {
+-        $$tool = $$eval($$tool_variable)
+-        next()
+-    }
+-
+-    value = $$eval($$tool)
+-    isEmpty(value): next()
+-
+-    sysrooted = $$system("/usr/bin/xcrun -sdk $$QMAKE_MAC_SDK -find $$first(value) 2>/dev/null")
+-    isEmpty(sysrooted): next()
+-
+-    $$tool = $$sysrooted $$member(value, 1, -1)
+-    cache($$tool_variable, set stash, $$tool)
+-}
+diff --git a/mkspecs/features/qml_module.prf b/mkspecs/features/qml_module.prf
+index 4db0040dc5..65d6da1f4d 100644
+--- a/mkspecs/features/qml_module.prf
++++ b/mkspecs/features/qml_module.prf
+@@ -23,13 +23,8 @@ for(qmlf, AUX_QML_FILES): fq_aux_qml_files += $$absolute_path($$qmlf, $$_PRO_FIL
+ 
+ load(qt_build_paths)
+ 
+-qml1_target {
+-    DESTDIR = $$MODULE_BASE_OUTDIR/imports/$$TARGETPATH
+-    instbase = $$[QT_INSTALL_IMPORTS]
+-} else {
+-    DESTDIR = $$MODULE_BASE_OUTDIR/qml/$$TARGETPATH
+-    instbase = $$[QT_INSTALL_QML]
+-}
++DESTDIR = $$MODULE_BASE_OUTDIR/qml/$$TARGETPATH
++instbase = $$NIX_OUTPUT_QML
+ 
+ !qml1_target:static: CONFIG += builtin_resources
+ 
+diff --git a/mkspecs/features/qml_plugin.prf b/mkspecs/features/qml_plugin.prf
+index d49f4c49c1..097dcd7d39 100644
+--- a/mkspecs/features/qml_plugin.prf
++++ b/mkspecs/features/qml_plugin.prf
+@@ -48,13 +48,8 @@ exists($$QMLTYPEFILE): AUX_QML_FILES += $$QMLTYPEFILE
+ 
+ load(qt_build_paths)
+ 
+-qml1_target {
+-    DESTDIR = $$MODULE_BASE_OUTDIR/imports/$$TARGETPATH
+-    instbase = $$[QT_INSTALL_IMPORTS]
+-} else {
+-    DESTDIR = $$MODULE_BASE_OUTDIR/qml/$$TARGETPATH
+-    instbase = $$[QT_INSTALL_QML]
+-}
++DESTDIR = $$MODULE_BASE_OUTDIR/qml/$$TARGETPATH
++instbase = $$NIX_OUTPUT_QML
+ 
+ target.path = $$instbase/$$TARGETPATH
+ INSTALLS += target
+diff --git a/mkspecs/features/qt_app.prf b/mkspecs/features/qt_app.prf
+index 883f8ca215..81db8eb2d4 100644
+--- a/mkspecs/features/qt_app.prf
++++ b/mkspecs/features/qt_app.prf
+@@ -33,7 +33,7 @@ host_build:force_bootstrap {
+     target.path = $$[QT_HOST_BINS]
+ } else {
+     !build_pass:qtConfig(debug_and_release): CONFIG += release
+-    target.path = $$[QT_INSTALL_BINS]
++    target.path = $$NIX_OUTPUT_BIN/bin
+     CONFIG += relative_qt_rpath  # Qt's tools and apps should be relocatable
+ }
+ INSTALLS += target
+diff --git a/mkspecs/features/qt_build_paths.prf b/mkspecs/features/qt_build_paths.prf
+index 1848f00e90..2af93675c5 100644
+--- a/mkspecs/features/qt_build_paths.prf
++++ b/mkspecs/features/qt_build_paths.prf
+@@ -23,6 +23,6 @@ exists($$MODULE_BASE_INDIR/.git): \
+ !force_independent {
+     # If the module is not built independently, everything ends up in qtbase.
+     # This is the case in non-prefix builds, except for selected modules.
+-    MODULE_BASE_OUTDIR = $$[QT_HOST_PREFIX]
+-    MODULE_QMAKE_OUTDIR = $$[QT_HOST_PREFIX]
++    MODULE_BASE_OUTDIR = $$NIX_OUTPUT_OUT
++    MODULE_QMAKE_OUTDIR = $$NIX_OUTPUT_OUT
+ }
+diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf
+index f4ae5bde80..6d4c6d223f 100644
+--- a/mkspecs/features/qt_common.prf
++++ b/mkspecs/features/qt_common.prf
+@@ -32,8 +32,8 @@ contains(TEMPLATE, .*lib) {
+         qqt_libdir = \$\$\$\$[QT_HOST_LIBS]
+         qt_libdir = $$[QT_HOST_LIBS]
+     } else {
+-        qqt_libdir = \$\$\$\$[QT_INSTALL_LIBS]
+-        qt_libdir = $$[QT_INSTALL_LIBS]
++        qqt_libdir = \$\$\$\$NIX_OUTPUT_OUT/lib
++        qt_libdir = $$NIX_OUTPUT_OUT/lib
+     }
+     contains(QMAKE_DEFAULT_LIBDIRS, $$qt_libdir) {
+         lib_replace.match = "[^ ']*$$rplbase/lib"
+diff --git a/mkspecs/features/qt_docs.prf b/mkspecs/features/qt_docs.prf
+index 72dde61a40..f891a2baed 100644
+--- a/mkspecs/features/qt_docs.prf
++++ b/mkspecs/features/qt_docs.prf
+@@ -45,7 +45,7 @@ QMAKE_DOCS_OUTPUTDIR = $$QMAKE_DOCS_BASE_OUTDIR/$$QMAKE_DOCS_TARGETDIR
+ 
+ QDOC += -outputdir $$shell_quote($$QMAKE_DOCS_OUTPUTDIR)
+ !build_online_docs: \
+-    QDOC += -installdir $$shell_quote($$[QT_INSTALL_DOCS])
++    QDOC += -installdir $$shell_quote($$NIX_OUTPUT_DOC)
+ PREP_DOC_INDEXES =
+ DOC_INDEXES =
+ !isEmpty(QTREPOS) {
+@@ -64,8 +64,8 @@ DOC_INDEXES =
+         DOC_INDEXES += -indexdir $$shell_quote($$qrep/doc)
+ } else {
+     prepare_docs: \
+-        PREP_DOC_INDEXES += -indexdir $$shell_quote($$[QT_INSTALL_DOCS/get])
+-    DOC_INDEXES += -indexdir $$shell_quote($$[QT_INSTALL_DOCS/get])
++        PREP_DOC_INDEXES += -indexdir $$shell_quote($$NIX_OUTPUT_DOC)
++    DOC_INDEXES += -indexdir $$shell_quote($$NIX_OUTPUT_DOC)
+ }
+ 
+ qtattributionsscanner.target = qtattributionsscanner
+@@ -88,12 +88,12 @@ prepare_docs {
+     qch_docs.commands = $$QHELPGENERATOR $$shell_quote($$QMAKE_DOCS_OUTPUTDIR/$${QMAKE_DOCS_TARGET}.qhp) -o $$shell_quote($$QMAKE_DOCS_BASE_OUTDIR/$${QMAKE_DOCS_TARGET}.qch)
+ 
+     inst_html_docs.files = $$QMAKE_DOCS_OUTPUTDIR
+-    inst_html_docs.path = $$[QT_INSTALL_DOCS]
++    inst_html_docs.path = $$NIX_OUTPUT_DOC
+     inst_html_docs.CONFIG += no_check_exist directory no_default_install no_build
+     INSTALLS += inst_html_docs
+ 
+     inst_qch_docs.files = $$QMAKE_DOCS_BASE_OUTDIR/$${QMAKE_DOCS_TARGET}.qch
+-    inst_qch_docs.path = $$[QT_INSTALL_DOCS]
++    inst_qch_docs.path = $$NIX_OUTPUT_DOC
+     inst_qch_docs.CONFIG += no_check_exist no_default_install no_build
+     INSTALLS += inst_qch_docs
+ 
+diff --git a/mkspecs/features/qt_example_installs.prf b/mkspecs/features/qt_example_installs.prf
+index c9ce926b1a..f00868a031 100644
+--- a/mkspecs/features/qt_example_installs.prf
++++ b/mkspecs/features/qt_example_installs.prf
+@@ -88,7 +88,7 @@ sourcefiles += \
+     $$SOURCES $$HEADERS $$FORMS $$RESOURCES $$TRANSLATIONS \
+     $$DBUS_ADAPTORS $$DBUS_INTERFACES
+ addInstallFiles(sources.files, $$sourcefiles)
+-sources.path = $$[QT_INSTALL_EXAMPLES]/$$probase
++sources.path = $$NIX_OUTPUT_DEV/share/examples/$$probase
+ INSTALLS += sources
+ 
+ check_examples {
+diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf
+index 1903e509c8..ae7b585989 100644
+--- a/mkspecs/features/qt_functions.prf
++++ b/mkspecs/features/qt_functions.prf
+@@ -69,7 +69,7 @@ defineTest(qtHaveModule) {
+ defineTest(qtPrepareTool) {
+     cmd = $$eval(QT_TOOL.$${2}.binary)
+     isEmpty(cmd) {
+-        cmd = $$[QT_HOST_BINS]/$$2
++        cmd = $$system("command -v $$2")
+         exists($${cmd}.pl) {
+             $${1}_EXE = $${cmd}.pl
+             cmd = perl -w $$system_path($${cmd}.pl)
+diff --git a/mkspecs/features/qt_installs.prf b/mkspecs/features/qt_installs.prf
+index 90d84cc535..387481bfc6 100644
+--- a/mkspecs/features/qt_installs.prf
++++ b/mkspecs/features/qt_installs.prf
+@@ -12,16 +12,10 @@
+ #library
+ !qt_no_install_library {
+     win32 {
+-       host_build: \
+-           dlltarget.path = $$[QT_HOST_BINS]
+-       else: \
+-           dlltarget.path = $$[QT_INSTALL_BINS]
++        dlltarget.path = $$NIX_OUTPUT_BIN/bin
+        INSTALLS += dlltarget
+     }
+-    host_build: \
+-        target.path = $$[QT_HOST_LIBS]
+-    else: \
+-        target.path = $$[QT_INSTALL_LIBS]
++    target.path = $$NIX_OUTPUT_OUT/lib
+     !static: target.CONFIG = no_dll
+     INSTALLS += target
+ }
+@@ -29,33 +23,33 @@
+ #headers
+ qt_install_headers {
+     class_headers.files = $$SYNCQT.HEADER_CLASSES
+-    class_headers.path = $$[QT_INSTALL_HEADERS]/$$MODULE_INCNAME
++    class_headers.path = $$NIX_OUTPUT_DEV/include/$$MODULE_INCNAME
+     INSTALLS += class_headers
+ 
+     targ_headers.files = $$SYNCQT.HEADER_FILES $$SYNCQT.INJECTED_HEADER_FILES
+-    targ_headers.path = $$[QT_INSTALL_HEADERS]/$$MODULE_INCNAME
++    targ_headers.path = $$NIX_OUTPUT_DEV/include/$$MODULE_INCNAME
+     INSTALLS += targ_headers
+ 
+     private_headers.files = $$SYNCQT.PRIVATE_HEADER_FILES $$SYNCQT.INJECTED_PRIVATE_HEADER_FILES
+-    private_headers.path = $$[QT_INSTALL_HEADERS]/$$MODULE_INCNAME/$$VERSION/$$MODULE_INCNAME/private
++    private_headers.path = $$NIX_OUTPUT_DEV/include/$$MODULE_INCNAME/$$VERSION/$$MODULE_INCNAME/private
+     INSTALLS += private_headers
+ 
+     qpa_headers.files = $$SYNCQT.QPA_HEADER_FILES
+-    qpa_headers.path = $$[QT_INSTALL_HEADERS]/$$MODULE_INCNAME/$$VERSION/$$MODULE_INCNAME/qpa
++    qpa_headers.path = $$NIX_OUTPUT_DEV/include/$$MODULE_INCNAME/$$VERSION/$$MODULE_INCNAME/qpa
+     INSTALLS += qpa_headers
+ }
+ 
+ #module
+ qt_install_module {
+     !isEmpty(MODULE_PRI) {
+-        pritarget.path = $$[QT_HOST_DATA]/mkspecs/modules
++        pritarget.path = $$NIX_OUTPUT_DEV/mkspecs/modules
+         pritarget.files = $$MODULE_PRI
+         INSTALLS += pritarget
+     } else: isEmpty(MODULE_PRIVATE_PRI) {
+         warning("Project $$basename(_PRO_FILE_) is a module, but has not defined MODULE_PRI, which is required for Qt to expose the module to other projects.")
+     }
+     !isEmpty(MODULE_PRIVATE_PRI) {
+-        privpritarget.path = $$[QT_HOST_DATA]/mkspecs/modules
++        privpritarget.path = $$NIX_OUTPUT_DEV/mkspecs/modules
+         privpritarget.files = $$MODULE_PRIVATE_PRI
+         INSTALLS += privpritarget
+     }
+diff --git a/mkspecs/features/qt_plugin.prf b/mkspecs/features/qt_plugin.prf
+index 14fc5f9a94..2a0f2cd27f 100644
+--- a/mkspecs/features/qt_plugin.prf
++++ b/mkspecs/features/qt_plugin.prf
+@@ -88,7 +88,7 @@ CONFIG(static, static|shared)|prefix_build {
+     }
+ }
+ 
+-target.path = $$[QT_INSTALL_PLUGINS]/$$PLUGIN_TYPE
++target.path = $$NIX_OUTPUT_PLUGIN/$$PLUGIN_TYPE
+ INSTALLS += target
+ 
+ TARGET = $$qt5LibraryTarget($$TARGET)
+diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
+index 545b9a3d1e..6ac0cdefe4 100644
+--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
++++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
+@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::qmake)
+     add_executable(Qt5::qmake IMPORTED)
+ 
+ !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
+ !!ENDIF
+@@ -18,7 +18,7 @@ if (NOT TARGET Qt5::moc)
+     add_executable(Qt5::moc IMPORTED)
+ 
+ !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
+ !!ENDIF
+@@ -35,7 +35,7 @@ if (NOT TARGET Qt5::rcc)
+     add_executable(Qt5::rcc IMPORTED)
+ 
+ !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
+ !!ENDIF
+@@ -133,7 +133,7 @@ if (NOT TARGET Qt5::WinMain)
+ !!IF !isEmpty(CMAKE_RELEASE_TYPE)
+     set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+ !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
+ !!ENDIF
+@@ -147,7 +147,7 @@ if (NOT TARGET Qt5::WinMain)
+     set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
+ 
+ !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
+ !!ENDIF
+diff --git a/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in b/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
+index c357237d0e..6f0c75de3c 100644
+--- a/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
++++ b/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
+@@ -1,6 +1,6 @@
+ 
+ !!IF isEmpty(CMAKE_HOST_DATA_DIR_IS_ABSOLUTE)
+-set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_HOST_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
++set(_qt5_corelib_extra_includes \"$$NIX_OUTPUT_DEV/$${CMAKE_HOST_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
+ !!ELSE
+ set(_qt5_corelib_extra_includes \"$${CMAKE_HOST_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
+ !!ENDIF
+diff --git a/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in b/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
+index 706304cf34..546420f6ad 100644
+--- a/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
++++ b/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
+@@ -1,6 +1,6 @@
+ 
+ !!IF isEmpty(CMAKE_INSTALL_DATA_DIR_IS_ABSOLUTE)
+-set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_INSTALL_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
++set(_qt5_corelib_extra_includes \"$$NIX_OUTPUT_DEV/$${CMAKE_INSTALL_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
+ !!ELSE
+ set(_qt5_corelib_extra_includes \"$${CMAKE_INSTALL_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
+ !!ENDIF
+diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
+index 3814894630..3c6468277c 100644
+--- a/src/corelib/kernel/qcoreapplication.cpp
++++ b/src/corelib/kernel/qcoreapplication.cpp
+@@ -2601,6 +2601,15 @@ QStringList QCoreApplication::libraryPaths()
+         QStringList *app_libpaths = new QStringList;
+         coreappdata()->app_libpaths.reset(app_libpaths);
+ 
++        // Add library paths derived from PATH
++        const QStringList paths = QFile::decodeName(qgetenv("PATH")).split(':');
++        const QString plugindir = QStringLiteral("../" NIXPKGS_QT_PLUGIN_PREFIX);
++        for (const QString &path: paths) {
++            if (!path.isEmpty()) {
++                app_libpaths->append(QDir::cleanPath(path + QDir::separator() + plugindir));
++            }
++        }
++
+         const QByteArray libPathEnv = qgetenv("QT_PLUGIN_PATH");
+         if (!libPathEnv.isEmpty()) {
+             QStringList paths = QFile::decodeName(libPathEnv).split(QDir::listSeparator(), QString::SkipEmptyParts);
+diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp
+index 6a5df6272a..a6136ca4cd 100644
+--- a/src/corelib/tools/qtimezoneprivate_tz.cpp
++++ b/src/corelib/tools/qtimezoneprivate_tz.cpp
+@@ -70,7 +70,11 @@ typedef QHash<QByteArray, QTzTimeZone> QTzTimeZoneHash;
+ // Parse zone.tab table, assume lists all installed zones, if not will need to read directories
+ static QTzTimeZoneHash loadTzTimeZones()
+ {
+-    QString path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
++    // Try TZDIR first, in case we're running on NixOS.
++    QString path = QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/zone.tab");
++    // Fallback to traditional paths in case we are not on NixOS.
++    if (!QFile::exists(path))
++        path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
+     if (!QFile::exists(path))
+         path = QStringLiteral("/usr/lib/zoneinfo/zone.tab");
+ 
+@@ -644,12 +648,16 @@ void QTzTimeZonePrivate::init(const QByteArray &ianaId)
+         if (!tzif.open(QIODevice::ReadOnly))
+             return;
+     } else {
+-        // Open named tz, try modern path first, if fails try legacy path
+-        tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
++        // Try TZDIR first, in case we're running on NixOS
++        tzif.setFileName(QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/") + QString::fromLocal8Bit(ianaId));
+         if (!tzif.open(QIODevice::ReadOnly)) {
+-            tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
+-            if (!tzif.open(QIODevice::ReadOnly))
+-                return;
++            // Open named tz, try modern path first, if fails try legacy path
++            tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
++            if (!tzif.open(QIODevice::ReadOnly)) {
++                tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
++                if (!tzif.open(QIODevice::ReadOnly))
++                    return;
++            }
+         }
+     }
+ 
+diff --git a/src/dbus/Qt5DBusConfigExtras.cmake.in b/src/dbus/Qt5DBusConfigExtras.cmake.in
+index 1d947159e2..b36865fc48 100644
+--- a/src/dbus/Qt5DBusConfigExtras.cmake.in
++++ b/src/dbus/Qt5DBusConfigExtras.cmake.in
+@@ -2,11 +2,7 @@
+ if (NOT TARGET Qt5::qdbuscpp2xml)
+     add_executable(Qt5::qdbuscpp2xml IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5DBus_install_prefix}/$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+-    set(imported_location \"$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
++    set(imported_location \"$$NIX_OUTPUT_DEV/bin/qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
+     _qt5_DBus_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::qdbuscpp2xml PROPERTIES
+@@ -17,11 +13,7 @@ endif()
+ if (NOT TARGET Qt5::qdbusxml2cpp)
+     add_executable(Qt5::qdbusxml2cpp IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5DBus_install_prefix}/$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+-    set(imported_location \"$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
++    set(imported_location \"$$NIX_OUTPUT_DEV/bin/qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
+     _qt5_DBus_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::qdbusxml2cpp PROPERTIES
+diff --git a/src/gui/Qt5GuiConfigExtras.cmake.in b/src/gui/Qt5GuiConfigExtras.cmake.in
+index 07869efd7d..fb4183bada 100644
+--- a/src/gui/Qt5GuiConfigExtras.cmake.in
++++ b/src/gui/Qt5GuiConfigExtras.cmake.in
+@@ -2,7 +2,7 @@
+ !!IF !isEmpty(CMAKE_ANGLE_EGL_DLL_RELEASE)
+ 
+ !!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
+-set(Qt5Gui_EGL_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR/QtANGLE\")
++set(Qt5Gui_EGL_INCLUDE_DIRS \"$$NIX_OUTPUT_DEV/$$CMAKE_INCLUDE_DIR/QtANGLE\")
+ !!ELSE
+ set(Qt5Gui_EGL_INCLUDE_DIRS \"$$CMAKE_INCLUDE_DIR/QtANGLE\")
+ !!ENDIF
+@@ -17,13 +17,13 @@ macro(_populate_qt5gui_gl_target_properties TargetName Configuration LIB_LOCATIO
+     set_property(TARGET Qt5::${TargetName} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
+ 
+ !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Gui_install_prefix}/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
++    set(imported_location \"$$NIX_OUTPUT_OUT/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
+ !!ENDIF
+ 
+ !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    set(imported_implib \"${_qt5Gui_install_prefix}/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
++    set(imported_implib \"$$NIX_OUTPUT_OUT/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
+ !!ELSE
+     set(imported_implib \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
+ !!ENDIF
+diff --git a/src/network/kernel/qdnslookup_unix.cpp b/src/network/kernel/qdnslookup_unix.cpp
+index ce1ec6442a..4f75655abe 100644
+--- a/src/network/kernel/qdnslookup_unix.cpp
++++ b/src/network/kernel/qdnslookup_unix.cpp
+@@ -95,7 +95,7 @@ static bool resolveLibraryInternal()
+     if (!lib.load())
+ #endif
+     {
+-        lib.setFileName(QLatin1String("resolv"));
++        lib.setFileName(QLatin1String(NIXPKGS_LIBRESOLV));
+         if (!lib.load())
+             return false;
+     }
+diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
+index 8d2cffc304..9730fb33f2 100644
+--- a/src/network/kernel/qhostinfo_unix.cpp
++++ b/src/network/kernel/qhostinfo_unix.cpp
+@@ -98,7 +98,7 @@ static bool resolveLibraryInternal()
+     if (!lib.load())
+ #endif
+     {
+-        lib.setFileName(QLatin1String("resolv"));
++        lib.setFileName(QLatin1String(NIXPKGS_LIBRESOLV));
+         if (!lib.load())
+             return false;
+     }
+diff --git a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
+index b5a0a5bbeb..6c20305f4d 100644
+--- a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
++++ b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
+@@ -265,12 +265,9 @@ void TableGenerator::initPossibleLocations()
+     m_possibleLocations.reserve(7);
+     if (qEnvironmentVariableIsSet("QTCOMPOSE"))
+         m_possibleLocations.append(QString::fromLocal8Bit(qgetenv("QTCOMPOSE")));
+-    m_possibleLocations.append(QStringLiteral("/usr/share/X11/locale"));
+-    m_possibleLocations.append(QStringLiteral("/usr/local/share/X11/locale"));
+-    m_possibleLocations.append(QStringLiteral("/usr/lib/X11/locale"));
+-    m_possibleLocations.append(QStringLiteral("/usr/local/lib/X11/locale"));
+     m_possibleLocations.append(QStringLiteral(X11_PREFIX "/share/X11/locale"));
+     m_possibleLocations.append(QStringLiteral(X11_PREFIX "/lib/X11/locale"));
++    m_possibleLocations.append(QLatin1String(NIXPKGS_QTCOMPOSE));
+ }
+ 
+ QString TableGenerator::findComposeFile()
+diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+index a59dc15b0e..a13ee89b5a 100644
+--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
++++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+@@ -584,7 +584,14 @@ QFunctionPointer QGLXContext::getProcAddress(const char *procName)
+ #if QT_CONFIG(library)
+                 extern const QString qt_gl_library_name();
+ //                QLibrary lib(qt_gl_library_name());
++                // Check system library paths first
+                 QLibrary lib(QLatin1String("GL"));
++#ifdef NIXPKGS_MESA_GL
++                if (!lib.load()) {
++                    // Fallback to Mesa driver
++                    lib.setFileName(QLatin1String(NIXPKGS_MESA_GL));
++                }
++#endif // NIXPKGS_MESA_GL
+                 glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB");
+ #endif
+             }
+diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp
+index da63360333..95e34e2e50 100644
+--- a/src/plugins/platforms/xcb/qxcbcursor.cpp
++++ b/src/plugins/platforms/xcb/qxcbcursor.cpp
+@@ -311,10 +311,10 @@ QXcbCursor::QXcbCursor(QXcbConnection *conn, QXcbScreen *screen)
+ #if QT_CONFIG(xcb_xlib) && QT_CONFIG(library)
+     static bool function_ptrs_not_initialized = true;
+     if (function_ptrs_not_initialized) {
+-        QLibrary xcursorLib(QLatin1String("Xcursor"), 1);
++        QLibrary xcursorLib(QLatin1String(NIXPKGS_LIBXCURSOR), 1);
+         bool xcursorFound = xcursorLib.load();
+         if (!xcursorFound) { // try without the version number
+-            xcursorLib.setFileName(QLatin1String("Xcursor"));
++            xcursorLib.setFileName(QLatin1String(NIXPKGS_LIBXCURSOR));
+             xcursorFound = xcursorLib.load();
+         }
+         if (xcursorFound) {
+diff --git a/src/plugins/platformthemes/gtk3/main.cpp b/src/plugins/platformthemes/gtk3/main.cpp
+index c4cd66c33b..b6f2691587 100644
+--- a/src/plugins/platformthemes/gtk3/main.cpp
++++ b/src/plugins/platformthemes/gtk3/main.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include <qpa/qplatformthemeplugin.h>
+ #include "qgtk3theme.h"
++#include <QFile>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -54,8 +55,22 @@ public:
+ QPlatformTheme *QGtk3ThemePlugin::create(const QString &key, const QStringList &params)
+ {
+     Q_UNUSED(params);
+-    if (!key.compare(QLatin1String(QGtk3Theme::name), Qt::CaseInsensitive))
++    if (!key.compare(QLatin1String(QGtk3Theme::name), Qt::CaseInsensitive)) {
++
++#ifdef NIXPKGS_QGTK3_XDG_DATA_DIRS
++        QStringList XDG_DATA_DIRS = QFile::decodeName(qgetenv("XDG_DATA_DIRS")).split(':');
++        XDG_DATA_DIRS << QLatin1String(NIXPKGS_QGTK3_XDG_DATA_DIRS);
++        qputenv("XDG_DATA_DIRS", QFile::encodeName(XDG_DATA_DIRS.join(':')));
++#endif
++
++#ifdef NIXPKGS_QGTK3_GIO_EXTRA_MODULES
++        QStringList GIO_EXTRA_MODULES = QFile::decodeName(qgetenv("GIO_EXTRA_MODULES")).split(':');
++        GIO_EXTRA_MODULES << QLatin1String(NIXPKGS_QGTK3_GIO_EXTRA_MODULES);
++        qputenv("GIO_EXTRA_MODULES", QFile::encodeName(GIO_EXTRA_MODULES.join(':')));
++#endif
++
+         return new QGtk3Theme;
++    }
+ 
+     return 0;
+ }
+diff --git a/src/testlib/qtestassert.h b/src/testlib/qtestassert.h
+index 6498ea84ef..d821ced7fc 100644
+--- a/src/testlib/qtestassert.h
++++ b/src/testlib/qtestassert.h
+@@ -44,10 +44,13 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-
++#if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
++#define QTEST_ASSERT(cond) do { } while ((false) && (cond))
++#define QTEST_ASSERT_X(cond, where, what) do { } while ((false) && (cond))
++#else
+ #define QTEST_ASSERT(cond) do { if (!(cond)) qt_assert(#cond,__FILE__,__LINE__); } while (false)
+-
+ #define QTEST_ASSERT_X(cond, where, what) do { if (!(cond)) qt_assert_x(where, what,__FILE__,__LINE__); } while (false)
++#endif
+ 
+ QT_END_NAMESPACE
+ 
+diff --git a/src/widgets/Qt5WidgetsConfigExtras.cmake.in b/src/widgets/Qt5WidgetsConfigExtras.cmake.in
+index 99d87e2e46..a4eab2aa72 100644
+--- a/src/widgets/Qt5WidgetsConfigExtras.cmake.in
++++ b/src/widgets/Qt5WidgetsConfigExtras.cmake.in
+@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::uic)
+     add_executable(Qt5::uic IMPORTED)
+ 
+ !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Widgets_install_prefix}/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
+ !!ENDIF
diff --git a/pkgs/development/libraries/qt-5/5.10/qtdeclarative.patch b/pkgs/development/libraries/qt-5/5.10/qtdeclarative.patch
new file mode 100644
index 000000000000..01a975c14ec7
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.10/qtdeclarative.patch
@@ -0,0 +1,33 @@
+diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
+index a7cafa1a9..e17ffd35b 100644
+--- a/src/qml/qml/qqmlimport.cpp
++++ b/src/qml/qml/qqmlimport.cpp
+@@ -1737,6 +1737,15 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e)
+     QString installImportsPath =  QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
+     addImportPath(installImportsPath);
+ 
++    // Add import paths derived from PATH
++    const QStringList paths = QFile::decodeName(qgetenv("PATH")).split(':');
++    const QString qmldir = QStringLiteral("../" NIXPKGS_QML2_IMPORT_PREFIX);
++    for (const QString &path: paths) {
++        if (!path.isEmpty()) {
++            addImportPath(QDir::cleanPath(path + QDir::separator() + qmldir));
++        }
++    }
++
+     // env import paths
+     if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QML2_IMPORT_PATH"))) {
+         const QString envImportPath = qEnvironmentVariable("QML2_IMPORT_PATH");
+diff --git a/tools/qmlcachegen/qmlcache.prf b/tools/qmlcachegen/qmlcache.prf
+index 330da358b..cdf570205 100644
+--- a/tools/qmlcachegen/qmlcache.prf
++++ b/tools/qmlcachegen/qmlcache.prf
+@@ -44,7 +44,7 @@ defineReplace(qmlCacheOutputFileName) {
+ }
+ 
+ qmlcacheinst.base = $$QMLCACHE_DESTDIR
+-qmlcacheinst.path = $$[QT_INSTALL_QML]/$$TARGETPATH
++qmlcacheinst.path = $$NIX_OUTPUT_QML/$$TARGETPATH
+ qmlcacheinst.CONFIG = no_check_exist
+ 
+ qmlcachegen.input = CACHEGEN_FILES
diff --git a/pkgs/development/libraries/qt-5/5.6/qtscript/0001-glib-2.32.patch b/pkgs/development/libraries/qt-5/5.10/qtscript.patch
index 887e107b6c1b..5508dec1280e 100644
--- a/pkgs/development/libraries/qt-5/5.6/qtscript/0001-glib-2.32.patch
+++ b/pkgs/development/libraries/qt-5/5.10/qtscript.patch
@@ -1,12 +1,3 @@
-From abd80356449bb36c8adcc5c9ca1df6b47715d265 Mon Sep 17 00:00:00 2001
-From: Thomas Tuegel <ttuegel@gmail.com>
-Date: Sun, 23 Aug 2015 09:13:34 -0500
-Subject: [PATCH] glib-2.32
-
----
- src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
 diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h
 index 1f6d25e..087c3fb 100644
 --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h
@@ -20,6 +11,3 @@ index 1f6d25e..087c3fb 100644
  typedef struct _GCond GCond;
  #endif
  
--- 
-2.5.0
-
diff --git a/pkgs/development/libraries/qt-5/5.9/qtserialport/qtserialport-dlopen-udev.patch b/pkgs/development/libraries/qt-5/5.10/qtserialport.patch
index 65bb64710ebd..f25524e80bcf 100644
--- a/pkgs/development/libraries/qt-5/5.9/qtserialport/qtserialport-dlopen-udev.patch
+++ b/pkgs/development/libraries/qt-5/5.10/qtserialport.patch
@@ -1,8 +1,8 @@
-Index: qtserialport-opensource-src-5.8.0/src/serialport/qtudev_p.h
-===================================================================
---- qtserialport-opensource-src-5.8.0.orig/src/serialport/qtudev_p.h
-+++ qtserialport-opensource-src-5.8.0/src/serialport/qtudev_p.h
-@@ -111,9 +111,17 @@ inline QFunctionPointer resolveSymbol(QL
+diff --git a/src/serialport/qtudev_p.h b/src/serialport/qtudev_p.h
+index af2dab2..8e17f64 100644
+--- a/src/serialport/qtudev_p.h
++++ b/src/serialport/qtudev_p.h
+@@ -111,9 +111,17 @@ inline QFunctionPointer resolveSymbol(QLibrary *udevLibrary, const char *symbolN
  inline bool resolveSymbols(QLibrary *udevLibrary)
  {
      if (!udevLibrary->isLoaded()) {
diff --git a/pkgs/development/libraries/qt-5/5.10/qttools.patch b/pkgs/development/libraries/qt-5/5.10/qttools.patch
new file mode 100644
index 000000000000..fbba439ef7a5
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.10/qttools.patch
@@ -0,0 +1,71 @@
+diff --git a/src/assistant/help/Qt5HelpConfigExtras.cmake.in b/src/assistant/help/Qt5HelpConfigExtras.cmake.in
+index 3b97923a..63336bd5 100644
+--- a/src/assistant/help/Qt5HelpConfigExtras.cmake.in
++++ b/src/assistant/help/Qt5HelpConfigExtras.cmake.in
+@@ -2,11 +2,10 @@
+ if (NOT TARGET Qt5::qcollectiongenerator)
+     add_executable(Qt5::qcollectiongenerator IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Help_install_prefix}/$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
++    if(NOT EXISTS \"${imported_location}\")
++        set(imported_location \"$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
++    endif()
+     _qt5_Help_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::qcollectiongenerator PROPERTIES
+@@ -17,11 +16,7 @@ endif()
+ if (NOT TARGET Qt5::qhelpgenerator)
+     add_executable(Qt5::qhelpgenerator IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Help_install_prefix}/$${CMAKE_BIN_DIR}qhelpgenerator$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}qhelpgenerator$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
+     _qt5_Help_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::qhelpgenerator PROPERTIES
+diff --git a/src/linguist/Qt5LinguistToolsConfig.cmake.in b/src/linguist/Qt5LinguistToolsConfig.cmake.in
+index 4318b16f..d60db4ff 100644
+--- a/src/linguist/Qt5LinguistToolsConfig.cmake.in
++++ b/src/linguist/Qt5LinguistToolsConfig.cmake.in
+@@ -44,11 +44,7 @@ endmacro()
+ if (NOT TARGET Qt5::lrelease)
+     add_executable(Qt5::lrelease IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
+     _qt5_LinguistTools_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::lrelease PROPERTIES
+@@ -59,11 +55,7 @@ endif()
+ if (NOT TARGET Qt5::lupdate)
+     add_executable(Qt5::lupdate IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
+     _qt5_LinguistTools_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::lupdate PROPERTIES
+@@ -74,11 +66,7 @@ endif()
+ if (NOT TARGET Qt5::lconvert)
+     add_executable(Qt5::lconvert IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lconvert$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}lconvert$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
+     _qt5_LinguistTools_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::lconvert PROPERTIES
diff --git a/pkgs/development/libraries/qt-5/5.10/qtwebengine-paxmark-mksnapshot.patch b/pkgs/development/libraries/qt-5/5.10/qtwebengine-paxmark-mksnapshot.patch
new file mode 100644
index 000000000000..e1621b005c61
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.10/qtwebengine-paxmark-mksnapshot.patch
@@ -0,0 +1,48 @@
+diff --git a/src/3rdparty/chromium/v8/src/v8.gyp b/chromium/v8/src/v8.gyp
+index e7e19f5059..934448c7d8 100644
+--- a/src/3rdparty/chromium/v8/src/v8.gyp
++++ b/src/3rdparty/chromium/v8/src/v8.gyp
+@@ -35,6 +35,7 @@
+     'v8_extra_library_files%': [],
+     'v8_experimental_extra_library_files%': [],
+     'mksnapshot_exec': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)mksnapshot<(EXECUTABLE_SUFFIX)',
++    'mksnapshot_u_exec': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)mksnapshot_u<(EXECUTABLE_SUFFIX)',
+     'v8_os_page_size%': 0,
+   },
+   'includes': ['../gypfiles/toolchain.gypi', '../gypfiles/features.gypi', 'inspector/inspector.gypi'],
+@@ -2576,7 +2577,7 @@
+         ]
+     },
+     {
+-      'target_name': 'mksnapshot',
++      'target_name': 'mksnapshot_u',
+       'type': 'executable',
+       'dependencies': [
+         'v8_base',
+@@ -2606,5 +2607,26 @@
+         }],
+       ],
+     },
++    {
++      'target_name': 'mksnapshot',
++      'type': 'executable',
++      'dependencies': ['mksnapshot_u'],
++      'actions': [
++        {
++          'action_name': 'paxmark_m_mksnapshot',
++          'inputs': [
++            '<(mksnapshot_u_exec)',
++          ],
++          'outputs': [
++            '<(mksnapshot_exec)',
++          ],
++          'action': [
++            'sh',
++            '-c',
++            'cp <(mksnapshot_u_exec) <(mksnapshot_exec) && paxctl -czexm <(mksnapshot_exec)',
++          ],
++        },
++      ],
++    },
+   ],
+ }
diff --git a/pkgs/development/libraries/qt-5/5.10/qtwebkit.patch b/pkgs/development/libraries/qt-5/5.10/qtwebkit.patch
new file mode 100644
index 000000000000..c78cb58f564b
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.10/qtwebkit.patch
@@ -0,0 +1,77 @@
+diff --git a/Source/WTF/WTF.pri b/Source/WTF/WTF.pri
+index 69e4cd1f3..3f729a75e 100644
+--- a/Source/WTF/WTF.pri
++++ b/Source/WTF/WTF.pri
+@@ -12,7 +12,7 @@ mac {
+     # Mac OS does ship libicu but not the associated header files.
+     # Therefore WebKit provides adequate header files.
+     INCLUDEPATH = $${ROOT_WEBKIT_DIR}/Source/WTF/icu $$INCLUDEPATH
+-    LIBS += -licucore
++    LIBS += /usr/lib/libicucore.dylib
+ } else:!use?(wchar_unicode): {
+     win32 {
+         CONFIG(static, static|shared) {
+diff --git a/Source/WebCore/plugins/qt/PluginPackageQt.cpp b/Source/WebCore/plugins/qt/PluginPackageQt.cpp
+index a923d49aa..46772a4bb 100644
+--- a/Source/WebCore/plugins/qt/PluginPackageQt.cpp
++++ b/Source/WebCore/plugins/qt/PluginPackageQt.cpp
+@@ -136,7 +136,11 @@ static void initializeGtk(QLibrary* module = 0)
+         }
+     }
+ 
++#ifdef NIXPKGS_LIBGTK2
++    QLibrary library(QLatin1String(NIXPKGS_LIBGTK2), 0);
++#else
+     QLibrary library(QLatin1String("libgtk-x11-2.0"), 0);
++#endif
+     if (library.load()) {
+         typedef void *(*gtk_init_check_ptr)(int*, char***);
+         gtk_init_check_ptr gtkInitCheck = (gtk_init_check_ptr)library.resolve("gtk_init_check");
+diff --git a/Source/WebCore/plugins/qt/PluginViewQt.cpp b/Source/WebCore/plugins/qt/PluginViewQt.cpp
+index de06a2fea..86fe39ef1 100644
+--- a/Source/WebCore/plugins/qt/PluginViewQt.cpp
++++ b/Source/WebCore/plugins/qt/PluginViewQt.cpp
+@@ -697,7 +697,11 @@ static Display *getPluginDisplay()
+     // support gdk based plugins (like flash) that use a different X connection.
+     // The code below has the same effect as this one:
+     // Display *gdkDisplay = gdk_x11_display_get_xdisplay(gdk_display_get_default());
++#ifdef NIXPKGS_LIBGDK2
++    QLibrary library(QLatin1String(NIXPKGS_LIBGDK2), 0);
++#else
+     QLibrary library(QLatin1String("libgdk-x11-2.0"), 0);
++#endif
+     if (!library.load())
+         return 0;
+ 
+diff --git a/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp b/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
+index 8de65216b..38f5c05e5 100644
+--- a/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
++++ b/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
+@@ -53,7 +53,11 @@ static void messageHandler(QtMsgType type, const QMessageLogContext&, const QStr
+ 
+ static bool initializeGtk()
+ {
++#ifdef NIXPKGS_LIBGTK2
++    QLibrary gtkLibrary(QLatin1String(NIXPKGS_LIBGTK2), 0);
++#else
+     QLibrary gtkLibrary(QLatin1String("libgtk-x11-2.0"), 0);
++#endif
+     if (!gtkLibrary.load())
+         return false;
+     typedef void* (*gtk_init_ptr)(void*, void*);
+diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
+index d734ff684..0f6ff63d1 100644
+--- a/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
++++ b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
+@@ -64,7 +64,11 @@ static Display* getPluginDisplay()
+     // The code below has the same effect as this one:
+     // Display *gdkDisplay = gdk_x11_display_get_xdisplay(gdk_display_get_default());
+ 
++#ifdef NIXPKGS_LIBGDK2
++    QLibrary library(QLatin1String(NIXPKGS_LIBGDK2), 0);
++#else
+     QLibrary library(QLatin1String("libgdk-x11-2.0"), 0);
++#endif
+     if (!library.load())
+         return 0;
+ 
diff --git a/pkgs/development/libraries/qt-5/5.10/restore-pc-files.patch b/pkgs/development/libraries/qt-5/5.10/restore-pc-files.patch
new file mode 100644
index 000000000000..a012c3f583e3
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.10/restore-pc-files.patch
@@ -0,0 +1,27 @@
+diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf
+index e6a0d97f1a..b50ce77d51 100644
+--- a/mkspecs/features/qt_module.prf
++++ b/mkspecs/features/qt_module.prf
+@@ -266,7 +266,7 @@ load(qt_installs)
+ load(qt_targets)
+ 
+ # this builds on top of qt_common
+-!internal_module:!lib_bundle:if(unix|mingw) {
++!internal_module:if(unix|mingw) {
+     CONFIG += create_pc
+     QMAKE_PKGCONFIG_DESTDIR = pkgconfig
+     host_build: \
+diff --git a/mkspecs/features/qt_module_headers.prf b/mkspecs/features/qt_module_headers.prf
+index 62b88c6fe2..f302f1e202 100644
+--- a/mkspecs/features/qt_module_headers.prf
++++ b/mkspecs/features/qt_module_headers.prf
+@@ -102,8 +102,7 @@ git_build: \
+ else: \
+     INC_PATH = $$MODULE_BASE_INDIR
+ include($$INC_PATH/include/$$MODULE_INCNAME/headers.pri, "", true)
+-!lib_bundle: \  # Headers are embedded into the bundle, so don't install them separately.
+-    CONFIG += qt_install_headers
++CONFIG += qt_install_headers
+ 
+ alien_syncqt: return()
+ 
diff --git a/pkgs/development/libraries/qt-5/5.10/srcs.nix b/pkgs/development/libraries/qt-5/5.10/srcs.nix
new file mode 100644
index 000000000000..025c7aa44e13
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.10/srcs.nix
@@ -0,0 +1,341 @@
+# DO NOT EDIT! This file is generated automatically by fetch-kde-qt.sh
+{ fetchurl, mirror }:
+
+{
+  qt3d = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qt3d-everywhere-src-5.10.1.tar.xz";
+      sha256 = "0fvb346xhiyc0csxcvs5ifwkzs9wnza54vvsw6dvyax76qjv87q4";
+      name = "qt3d-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtactiveqt = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtactiveqt-everywhere-src-5.10.1.tar.xz";
+      sha256 = "1r4i72i1pl9xnmcx8rr8g48fmym8mxs28pkg1nl302xi6izan8ch";
+      name = "qtactiveqt-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtandroidextras = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtandroidextras-everywhere-src-5.10.1.tar.xz";
+      sha256 = "03jmf7gw4abn5gj92b1ns0k75bbi4wycbc4bbb7c9mngzkv3nzkn";
+      name = "qtandroidextras-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtbase = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtbase-everywhere-src-5.10.1.tar.xz";
+      sha256 = "0sd9cn3ywkjfswddcxhbfplkwk8snqld752q5laaapdakhc0wrnq";
+      name = "qtbase-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtcanvas3d = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtcanvas3d-everywhere-src-5.10.1.tar.xz";
+      sha256 = "1h5hpjwdyp824r2ajmaqjcshra06yfzz7dp991h4kf54da79m0ny";
+      name = "qtcanvas3d-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtcharts = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtcharts-everywhere-src-5.10.1.tar.xz";
+      sha256 = "1j8y683ainri9ma44ky6q87pjs1d794znb2wfsrbplixyxxmf3ag";
+      name = "qtcharts-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtconnectivity = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtconnectivity-everywhere-src-5.10.1.tar.xz";
+      sha256 = "1j9ydlkwz3039yslaizz923h0qbszm4z2sqspk28wr8rd3f22a35";
+      name = "qtconnectivity-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtdatavis3d = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtdatavis3d-everywhere-src-5.10.1.tar.xz";
+      sha256 = "0ny8j689jm2fghklzw894yc5hjqa23yf395yv17yvwi72kpiz0b3";
+      name = "qtdatavis3d-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtdeclarative = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtdeclarative-everywhere-src-5.10.1.tar.xz";
+      sha256 = "0lwmg1qan886czzkzi4px36mqxlqiw0acrsa9kqcddg5pi8yvy9s";
+      name = "qtdeclarative-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtdoc = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtdoc-everywhere-src-5.10.1.tar.xz";
+      sha256 = "1gl62acr346jrcfxla8vxlczf706a3md52zc0zaqbjw9rf2bgnqq";
+      name = "qtdoc-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtgamepad = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtgamepad-everywhere-src-5.10.1.tar.xz";
+      sha256 = "1xs6adpnv5ymdmb7kcbvcc0vx2lp6wqz53pzr9amyzbgyl0jiiw5";
+      name = "qtgamepad-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtgraphicaleffects = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtgraphicaleffects-everywhere-src-5.10.1.tar.xz";
+      sha256 = "0zw4n6s42w70r45gjg66ad0s9dpxil6wmwwrivshnqvrnlqhcfrz";
+      name = "qtgraphicaleffects-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtimageformats = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtimageformats-everywhere-src-5.10.1.tar.xz";
+      sha256 = "10x248s4a6ij18awkdskk3g7zfw6gwyj63l2jr803blyfyibl118";
+      name = "qtimageformats-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtlocation = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtlocation-everywhere-src-5.10.1.tar.xz";
+      sha256 = "1jbjzl6gwxy4n43x6m55b86vkdpjvwyvw7xsxg4a40f72xaw0p2y";
+      name = "qtlocation-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtmacextras = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtmacextras-everywhere-src-5.10.1.tar.xz";
+      sha256 = "1jkzizsa8nr1dp5n9p81s6ylnqfh0vqwz8l72632fg68x229jfn7";
+      name = "qtmacextras-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtmultimedia = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtmultimedia-everywhere-src-5.10.1.tar.xz";
+      sha256 = "0j9nq8s2kzfc7zqs253pixqwd5xjv2cbqyik5lgvi9p5bq0riym1";
+      name = "qtmultimedia-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtnetworkauth = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtnetworkauth-everywhere-src-5.10.1.tar.xz";
+      sha256 = "1p6wnma2nygqbjhrbiijjgkc8jq6lkdmq6xaxcgdh8ynkcqiq8wp";
+      name = "qtnetworkauth-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtpurchasing = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtpurchasing-everywhere-src-5.10.1.tar.xz";
+      sha256 = "090gmxy5bp44rirl5yrb1ryn97z37ri4fmmclh9z7c4dvnmr2d3j";
+      name = "qtpurchasing-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtquickcontrols = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtquickcontrols-everywhere-src-5.10.1.tar.xz";
+      sha256 = "1dw22sk2x5bk2mix06w8dv1b05dyq0gx088aqvdz18y67ncs2cfj";
+      name = "qtquickcontrols-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtquickcontrols2 = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtquickcontrols2-everywhere-src-5.10.1.tar.xz";
+      sha256 = "0jk01vgzc78w45q8kys1hwri3jx0hzx5vxivzmv8nh8yj0dlmijx";
+      name = "qtquickcontrols2-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtremoteobjects = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtremoteobjects-everywhere-src-5.10.1.tar.xz";
+      sha256 = "052fa27rv4b9h6qbldrq013zxb69ysgmqnxbyv9c48s2ra50pnp9";
+      name = "qtremoteobjects-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtscript = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtscript-everywhere-src-5.10.1.tar.xz";
+      sha256 = "0bakr5xcxc6j6l78fyazh7sgcz2hwf2g8k60jb9307qzrgvqlqg0";
+      name = "qtscript-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtscxml = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtscxml-everywhere-src-5.10.1.tar.xz";
+      sha256 = "00v1n86pyw9cm320qa2fpazvkfi6czd027x60k2g2sprwh0x4hhb";
+      name = "qtscxml-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtsensors = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtsensors-everywhere-src-5.10.1.tar.xz";
+      sha256 = "15jw2r6snhwi26b4ajp7m89l89kaf1j0kgqds4wjpksk1rngf3dv";
+      name = "qtsensors-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtserialbus = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtserialbus-everywhere-src-5.10.1.tar.xz";
+      sha256 = "0mr2j86mk1fm9z5iba3kav651231j9jv0805q8716h7ia1ws2l06";
+      name = "qtserialbus-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtserialport = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtserialport-everywhere-src-5.10.1.tar.xz";
+      sha256 = "17ja368ggl9aak64r8sqzx34j2i8zv7z60bkhncynrgipc9wpr08";
+      name = "qtserialport-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtspeech = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtspeech-everywhere-src-5.10.1.tar.xz";
+      sha256 = "07clcy3bslq4fk7xb6cqlfsz5frhmy41hzpajdqjwj9h6dvmqxw5";
+      name = "qtspeech-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtsvg = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtsvg-everywhere-src-5.10.1.tar.xz";
+      sha256 = "0nkz3kxclk7s95fnh8xgljahk131mwb8pjllgp7n70ycmc20rq00";
+      name = "qtsvg-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qttools = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qttools-everywhere-src-5.10.1.tar.xz";
+      sha256 = "0lwa0i6zspcrii0ak1dyxacif1fkv2vhmdp3dmp7af71bwg49spi";
+      name = "qttools-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qttranslations = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qttranslations-everywhere-src-5.10.1.tar.xz";
+      sha256 = "1za34rvn3bhzi4mxqm9lghdhaqcxpsi6xa61dfbhpc047l788v8z";
+      name = "qttranslations-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtvirtualkeyboard = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtvirtualkeyboard-everywhere-src-5.10.1.tar.xz";
+      sha256 = "0bnmhy0kibvyra0i15qzwc9195s8wpfhg5gk0d6rfwd5d07gj6a3";
+      name = "qtvirtualkeyboard-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtwayland = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtwayland-everywhere-src-5.10.1.tar.xz";
+      sha256 = "0mk3p8pkfia3z7v7phk0qdyzd1zkfpk92c995g851p5wbqx699zm";
+      name = "qtwayland-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtwebchannel = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtwebchannel-everywhere-src-5.10.1.tar.xz";
+      sha256 = "0r1p1ar4xh7g7lzi564hgw1ng5xkim4mkpgq29ymjlmhxjgl8b62";
+      name = "qtwebchannel-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtwebengine = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtwebengine-everywhere-src-5.10.1.tar.xz";
+      sha256 = "1ph1pinxn0dp44zall9gihbgziira4zpynixacm4ldd85f6lyr0j";
+      name = "qtwebengine-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtwebglplugin = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtwebglplugin-everywhere-src-5.10.1.tar.xz";
+      sha256 = "1hdzymwai5f6agkn4hz32aq5fjv2lqdac285fwrlk5gsff0j0yal";
+      name = "qtwebglplugin-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtwebsockets = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtwebsockets-everywhere-src-5.10.1.tar.xz";
+      sha256 = "1sjkml5kqigvyxrkv5b7x1cy69d69dzma40yfg72vr7zal4pkkvf";
+      name = "qtwebsockets-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtwebview = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtwebview-everywhere-src-5.10.1.tar.xz";
+      sha256 = "110mwc423cq1bwdz0vv78cjprzy03xawxnxhfcs4138gssfj0n0b";
+      name = "qtwebview-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtwinextras = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtwinextras-everywhere-src-5.10.1.tar.xz";
+      sha256 = "05w9n8kry1mg3i14i4m98gm5hf20mlwxbagbk9xk11xykbm1wh0j";
+      name = "qtwinextras-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtx11extras = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtx11extras-everywhere-src-5.10.1.tar.xz";
+      sha256 = "1d4pvisxbcyb7ljl1lh2zg72kw44h9kk14l0xmvajb8bslgkg2n3";
+      name = "qtx11extras-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtxmlpatterns = {
+    version = "5.10.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.10/5.10.1/submodules/qtxmlpatterns-everywhere-src-5.10.1.tar.xz";
+      sha256 = "1zp9smsfdqyfiarxs7r8kfr7yq68cdn7biddwl36cybax6fgbpiw";
+      name = "qtxmlpatterns-everywhere-src-5.10.1.tar.xz";
+    };
+  };
+  qtwebkit = {
+    version = "5.9.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.9/5.9.1/submodules/qtwebkit-opensource-src-5.9.1.tar.xz";
+      sha256 = "1ksjn1vjbfhdm4y4rg08ag4krk87ahp7qcdcpwll42l0rnz61998";
+      name = "qtwebkit-opensource-src-5.9.1.tar.xz";
+    };
+  };
+  qtwebkit-examples = {
+    version = "5.9.1";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.9/5.9.1/submodules/qtwebkit-examples-opensource-src-5.9.1.tar.xz";
+      sha256 = "1l2l7ycgqql6rf4gx6sjhsqjapdhvy6vxaxssax3l938nkk4vkp4";
+      name = "qtwebkit-examples-opensource-src-5.9.1.tar.xz";
+    };
+  };
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/default.nix b/pkgs/development/libraries/qt-5/5.6/default.nix
index b250ae8b9527..b9ed5eddd5cf 100644
--- a/pkgs/development/libraries/qt-5/5.6/default.nix
+++ b/pkgs/development/libraries/qt-5/5.6/default.nix
@@ -27,13 +27,13 @@ existing packages here and modify it as necessary.
 {
   newScope,
   stdenv, fetchurl, makeSetupHook, makeWrapper,
-  bison, cups ? null, harfbuzz, mesa, perl,
+  bison, cups ? null, harfbuzz, libGL, perl,
   gstreamer, gst-plugins-base,
 
   # options
   developerBuild ? false,
   decryptSslTraffic ? false,
-  debug ? null,
+  debug ? false,
 }:
 
 with stdenv.lib;
@@ -45,64 +45,38 @@ let
   mirror = "http://download.qt.io";
   srcs = import ./srcs.nix { inherit fetchurl; inherit mirror; };
 
-  mkDerivation = args:
-    stdenv.mkDerivation (args // {
-
-      qmakeFlags =
-        (args.qmakeFlags or [])
-        ++ optional (debug != null)
-           (if debug then "CONFIG+=debug" else "CONFIG+=release");
-
-      cmakeFlags =
-        (args.cmakeFlags or [])
-        ++ [ "-DBUILD_TESTING=OFF" ]
-        ++ optional (debug != null)
-           (if debug then "-DCMAKE_BUILD_TYPE=Debug"
-                     else "-DCMAKE_BUILD_TYPE=Release");
-
-      enableParallelBuilding = args.enableParallelBuilding or true;
-
-    });
-
-  qtSubmodule = args:
-    let
-      inherit (args) name;
-      version = args.version or srcs."${name}".version;
-      src = args.src or srcs."${name}".src;
-    in mkDerivation (args // {
-      name = "${name}-${version}";
-      inherit src;
-
-      propagatedBuildInputs = args.qtInputs ++ (args.propagatedBuildInputs or []);
-      nativeBuildInputs =
-        (args.nativeBuildInputs or [])
-        ++ [ perl self.qmake ];
-
-      NIX_QT_SUBMODULE = args.NIX_QT_SUBMODULE or true;
-
-      outputs = args.outputs or [ "out" "dev" ];
-      setOutputFlags = args.setOutputFlags or false;
-
-      setupHook = ../qtsubmodule-setup-hook.sh;
-
-      meta = {
-        homepage = http://www.qt.io;
-        description = "A cross-platform application framework for C++";
-        license = with licenses; [ fdl13 gpl2 lgpl21 lgpl3 ];
-        maintainers = with maintainers; [ qknight ttuegel periklis ];
-        platforms = platforms.unix;
-      } // (args.meta or {});
-    });
+  patches = {
+    qtbase = [ ./qtbase.patch ];
+    qtdeclarative = [ ./qtdeclarative.patch ];
+    qtscript = [ ./qtscript.patch ];
+    qtserialport = [ ./qtserialport.patch ];
+    qttools = [ ./qttools.patch ];
+    qtwebengine = [ ./qtwebengine-seccomp.patch ]
+      ++ optional stdenv.needsPax ./qtwebengine-paxmark-mksnapshot.patch;
+    qtwebkit = [ ./qtwebkit.patch ];
+  };
+
+  mkDerivation =
+    import ../mkDerivation.nix
+    { inherit stdenv; inherit (stdenv) lib; }
+    { inherit debug; };
+
+  qtModule =
+    import ../qtModule.nix
+    { inherit mkDerivation perl; inherit (stdenv) lib; }
+    { inherit self srcs patches; };
 
   addPackages = self: with self;
     let
-      callPackage = self.newScope { inherit qtCompatVersion qtSubmodule srcs; };
+      callPackage = self.newScope { inherit qtCompatVersion qtModule srcs; };
     in {
 
       inherit mkDerivation;
 
-      qtbase = callPackage ./qtbase {
-        inherit bison cups harfbuzz mesa;
+      qtbase = callPackage ../modules/qtbase.nix {
+        inherit bison cups harfbuzz libGL;
+        inherit (srcs.qtbase) src version;
+        patches = patches.qtbase;
         inherit developerBuild decryptSslTraffic;
       };
 
@@ -110,47 +84,46 @@ let
       /* qtactiveqt = not packaged */
       /* qtandroidextras = not packaged */
       /* qtcanvas3d = not packaged */
-      qtconnectivity = callPackage ./qtconnectivity.nix {};
-      qtdeclarative = callPackage ./qtdeclarative {};
-      qtdoc = callPackage ./qtdoc.nix {};
-      qtenginio = callPackage ./qtenginio.nix {};
-      qtgraphicaleffects = callPackage ./qtgraphicaleffects.nix {};
-      qtimageformats = callPackage ./qtimageformats.nix {};
-      qtlocation = callPackage ./qtlocation.nix {};
+      qtconnectivity = callPackage ../modules/qtconnectivity.nix {};
+      qtdeclarative = callPackage ../modules/qtdeclarative.nix {};
+      qtdoc = callPackage ../modules/qtdoc.nix {};
+      qtgraphicaleffects = callPackage ../modules/qtgraphicaleffects.nix {};
+      qtimageformats = callPackage ../modules/qtimageformats.nix {};
+      qtlocation = callPackage ../modules/qtlocation.nix {};
       /* qtmacextras = not packaged */
-      qtmultimedia = callPackage ./qtmultimedia.nix {
+      qtmultimedia = callPackage ../modules/qtmultimedia.nix {
         inherit gstreamer gst-plugins-base;
       };
       qtquick1 = null;
-      qtquickcontrols = callPackage ./qtquickcontrols.nix {};
-      qtquickcontrols2 = callPackage ./qtquickcontrols2.nix {};
-      qtscript = callPackage ./qtscript {};
-      qtsensors = callPackage ./qtsensors.nix {};
-      qtserialport = callPackage ./qtserialport {};
-      qtsvg = callPackage ./qtsvg.nix {};
-      qttools = callPackage ./qttools {};
-      qttranslations = callPackage ./qttranslations.nix {};
-      qtwayland = callPackage ./qtwayland.nix {};
-      qtwebchannel = callPackage ./qtwebchannel.nix {};
-      qtwebengine = callPackage ./qtwebengine {};
-      qtwebkit = callPackage ./qtwebkit {};
-      qtwebsockets = callPackage ./qtwebsockets.nix {};
+      qtquickcontrols = callPackage ../modules/qtquickcontrols.nix {};
+      qtquickcontrols2 = callPackage ../modules/qtquickcontrols2.nix {};
+      qtscript = callPackage ../modules/qtscript.nix {};
+      qtsensors = callPackage ../modules/qtsensors.nix {};
+      qtserialport = callPackage ../modules/qtserialport.nix {};
+      qtsvg = callPackage ../modules/qtsvg.nix {};
+      qttools = callPackage ../modules/qttools.nix {};
+      qttranslations = callPackage ../modules/qttranslations.nix {};
+      qtwayland = callPackage ../modules/qtwayland.nix {};
+      qtwebchannel = callPackage ../modules/qtwebchannel.nix {};
+      qtwebengine = callPackage ../modules/qtwebengine.nix {};
+      qtwebkit = callPackage ../modules/qtwebkit.nix {};
+      qtwebsockets = callPackage ../modules/qtwebsockets.nix {};
       /* qtwinextras = not packaged */
-      qtx11extras = callPackage ./qtx11extras.nix {};
-      qtxmlpatterns = callPackage ./qtxmlpatterns.nix {};
+      qtx11extras = callPackage ../modules/qtx11extras.nix {};
+      qtxmlpatterns = callPackage ../modules/qtxmlpatterns.nix {};
 
       env = callPackage ../qt-env.nix {};
-      full = env "qt-${qtbase.version}" [
-        qtconnectivity qtdeclarative qtdoc qtenginio qtgraphicaleffects
-        qtimageformats qtlocation qtmultimedia qtquickcontrols qtquickcontrols2
-        qtscript qtsensors qtserialport qtsvg qttools qttranslations qtwayland
+      full = env "qt-full-${qtbase.version}" [
+        qtconnectivity qtdeclarative qtdoc qtgraphicaleffects qtimageformats
+        qtlocation qtmultimedia qtquickcontrols qtquickcontrols2 qtscript
+        qtsensors qtserialport qtsvg qttools qttranslations qtwayland
         qtwebchannel qtwebengine qtwebkit qtwebsockets qtx11extras qtxmlpatterns
       ];
 
       qmake = makeSetupHook {
         deps = [ self.qtbase.dev ];
         substitutions = { inherit (stdenv) isDarwin; };
-      } ../qmake-hook.sh;
+      } ../hooks/qmake-hook.sh;
     };
 
    self = makeScope newScope addPackages;
diff --git a/pkgs/development/libraries/qt-5/5.6/fetch.sh b/pkgs/development/libraries/qt-5/5.6/fetch.sh
index 3aa539cda033..ee3a5ddf8deb 100644
--- a/pkgs/development/libraries/qt-5/5.6/fetch.sh
+++ b/pkgs/development/libraries/qt-5/5.6/fetch.sh
@@ -1,3 +1,3 @@
-WGET_ARGS=( http://download.qt.io/official_releases/qt/5.6/5.6.2/submodules/ \
-            http://download.qt.io/community_releases/5.6/5.6.2/ \
+WGET_ARGS=( http://download.qt.io/official_releases/qt/5.6/5.6.3/submodules/ \
+            http://download.qt.io/community_releases/5.6/5.6.3/ \
             -A '*.tar.xz' )
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase.patch b/pkgs/development/libraries/qt-5/5.6/qtbase.patch
new file mode 100644
index 000000000000..d8322cbc1997
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase.patch
@@ -0,0 +1,795 @@
+diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
+index 11fb52a0b1..614fdbb046 100644
+--- a/mkspecs/features/create_cmake.prf
++++ b/mkspecs/features/create_cmake.prf
+@@ -21,7 +21,7 @@ load(cmake_functions)
+ # at cmake time whether package has been found via a symlink, and correct
+ # that to an absolute path. This is only done for installations to
+ # the /usr or / prefix.
+-CMAKE_INSTALL_LIBS_DIR = $$cmakeTargetPath($$[QT_INSTALL_LIBS])
++CMAKE_INSTALL_LIBS_DIR = $$cmakeTargetPath($$NIX_OUTPUT_OUT/lib/)
+ contains(CMAKE_INSTALL_LIBS_DIR, ^(/usr)?/lib(64)?.*): CMAKE_USR_MOVE_WORKAROUND = $$CMAKE_INSTALL_LIBS_DIR
+ 
+ CMAKE_OUT_DIR = $$MODULE_BASE_OUTDIR/lib/cmake
+@@ -47,47 +47,22 @@ split_incpath {
+         $$cmake_extra_source_includes.output
+ }
+ 
+-CMAKE_INCLUDE_DIR = $$cmakeRelativePath($$[QT_INSTALL_HEADERS], $$[QT_INSTALL_PREFIX])
+-contains(CMAKE_INCLUDE_DIR, "^\\.\\./.*") {
+-    CMAKE_INCLUDE_DIR = $$[QT_INSTALL_HEADERS]/
+-    CMAKE_INCLUDE_DIR_IS_ABSOLUTE = True
+-}
++CMAKE_INCLUDE_DIR = $$NIX_OUTPUT_DEV/include/
++CMAKE_INCLUDE_DIR_IS_ABSOLUTE = True
+ 
+ !exists($$first(QT.$${MODULE}_private.includes)): CMAKE_NO_PRIVATE_INCLUDES = true
+ 
+-CMAKE_LIB_DIR = $$cmakeRelativePath($$[QT_INSTALL_LIBS], $$[QT_INSTALL_PREFIX])
+-contains(CMAKE_LIB_DIR,"^\\.\\./.*") {
+-    CMAKE_LIB_DIR = $$[QT_INSTALL_LIBS]/
+-    CMAKE_LIB_DIR_IS_ABSOLUTE = True
+-} else {
+-    CMAKE_RELATIVE_INSTALL_LIBS_DIR = $$cmakeRelativePath($$[QT_INSTALL_PREFIX], $$[QT_INSTALL_LIBS])
+-    # We need to go up another two levels because the CMake files are
+-    # installed in $${CMAKE_LIB_DIR}/cmake/Qt5$${CMAKE_MODULE_NAME}
+-    CMAKE_RELATIVE_INSTALL_DIR = "$${CMAKE_RELATIVE_INSTALL_LIBS_DIR}../../"
+-}
++CMAKE_LIB_DIR = $$NIX_OUTPUT_OUT/lib/
++CMAKE_LIB_DIR_IS_ABSOLUTE = True
+ 
+-CMAKE_BIN_DIR = $$cmakeRelativePath($$[QT_HOST_BINS], $$[QT_INSTALL_PREFIX])
+-contains(CMAKE_BIN_DIR, "^\\.\\./.*") {
+-    CMAKE_BIN_DIR = $$[QT_HOST_BINS]/
+-    CMAKE_BIN_DIR_IS_ABSOLUTE = True
+-}
++CMAKE_BIN_DIR = $$NIX_OUTPUT_BIN/bin/
++CMAKE_BIN_DIR_IS_ABSOLUTE = True
+ 
+-CMAKE_PLUGIN_DIR = $$cmakeRelativePath($$[QT_INSTALL_PLUGINS], $$[QT_INSTALL_PREFIX])
+-contains(CMAKE_PLUGIN_DIR, "^\\.\\./.*") {
+-    CMAKE_PLUGIN_DIR = $$[QT_INSTALL_PLUGINS]/
+-    CMAKE_PLUGIN_DIR_IS_ABSOLUTE = True
+-}
++CMAKE_PLUGIN_DIR = $$NIX_OUTPUT_PLUGIN/
++CMAKE_PLUGIN_DIR_IS_ABSOLUTE = True
+ 
+-win32:!wince:!static:!staticlib {
+-    CMAKE_DLL_DIR = $$cmakeRelativePath($$[QT_INSTALL_BINS], $$[QT_INSTALL_PREFIX])
+-    contains(CMAKE_DLL_DIR, "^\\.\\./.*") {
+-        CMAKE_DLL_DIR = $$[QT_INSTALL_BINS]/
+-        CMAKE_DLL_DIR_IS_ABSOLUTE = True
+-    }
+-} else {
+-    CMAKE_DLL_DIR = $$CMAKE_LIB_DIR
+-    CMAKE_DLL_DIR_IS_ABSOLUTE = $$CMAKE_LIB_DIR_IS_ABSOLUTE
+-}
++CMAKE_DLL_DIR = $$NIX_OUTPUT_OUT/lib/
++CMAKE_DLL_DIR_IS_ABSOLUTE = True
+ 
+ static|staticlib:CMAKE_STATIC_TYPE = true
+ 
+@@ -167,7 +142,7 @@ contains(CONFIG, plugin) {
+       cmake_target_file
+ 
+     cmake_qt5_plugin_file.files = $$cmake_target_file.output
+-    cmake_qt5_plugin_file.path = $$[QT_INSTALL_LIBS]/cmake/Qt5$${CMAKE_MODULE_NAME}
++    cmake_qt5_plugin_file.path = $$NIX_OUTPUT_OUT/lib/cmake/Qt5$${CMAKE_MODULE_NAME}
+     INSTALLS += cmake_qt5_plugin_file
+ 
+     return()
+@@ -314,7 +289,7 @@ exists($$cmake_macros_file.input) {
+     cmake_qt5_module_files.files += $$cmake_macros_file.output
+ }
+ 
+-cmake_qt5_module_files.path = $$[QT_INSTALL_LIBS]/cmake/Qt5$${CMAKE_MODULE_NAME}
++cmake_qt5_module_files.path = $$NIX_OUTPUT_OUT/lib/cmake/Qt5$${CMAKE_MODULE_NAME}
+ 
+ # We are generating cmake files. Most developers of Qt are not aware of cmake,
+ # so we require automatic tests to be available. The only module which should
+diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+index d2358cae4b..61d8cc0471 100644
+--- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
++++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+@@ -9,30 +9,6 @@ if (CMAKE_VERSION VERSION_LESS 3.0.0)
+ endif()
+ !!ENDIF
+ 
+-!!IF !isEmpty(CMAKE_USR_MOVE_WORKAROUND)
+-!!IF !isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-set(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$[QT_INSTALL_PREFIX]\")
+-!!ELSE
+-get_filename_component(_IMPORT_PREFIX \"${CMAKE_CURRENT_LIST_FILE}\" PATH)
+-# Use original install prefix when loaded through a
+-# cross-prefix symbolic link such as /lib -> /usr/lib.
+-get_filename_component(_realCurr \"${_IMPORT_PREFIX}\" REALPATH)
+-get_filename_component(_realOrig \"$$CMAKE_INSTALL_LIBS_DIR/cmake/Qt5$${CMAKE_MODULE_NAME}\" REALPATH)
+-if(_realCurr STREQUAL _realOrig)
+-    get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$CMAKE_INSTALL_LIBS_DIR/$${CMAKE_RELATIVE_INSTALL_LIBS_DIR}\" ABSOLUTE)
+-else()
+-    get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
+-endif()
+-unset(_realOrig)
+-unset(_realCurr)
+-unset(_IMPORT_PREFIX)
+-!!ENDIF
+-!!ELIF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
+-!!ELSE
+-set(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$[QT_INSTALL_PREFIX]\")
+-!!ENDIF
+-
+ !!IF !equals(TEMPLATE, aux)
+ # For backwards compatibility only. Use Qt5$${CMAKE_MODULE_NAME}_VERSION instead.
+ set(Qt5$${CMAKE_MODULE_NAME}_VERSION_STRING "$$eval(QT.$${MODULE}.MAJOR_VERSION).$$eval(QT.$${MODULE}.MINOR_VERSION).$$eval(QT.$${MODULE}.PATCH_VERSION)")
+@@ -58,11 +34,7 @@ endmacro()
+ macro(_populate_$${CMAKE_MODULE_NAME}_target_properties Configuration LIB_LOCATION IMPLIB_LOCATION)
+     set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
+ 
+-!!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
+-!!ENDIF
+     _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
+     set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
+         \"INTERFACE_LINK_LIBRARIES\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\"
+@@ -75,11 +47,7 @@ macro(_populate_$${CMAKE_MODULE_NAME}_target_properties Configuration LIB_LOCATI
+     )
+ 
+ !!IF !isEmpty(CMAKE_WINDOWS_BUILD)
+-!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    set(imported_implib \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
+-!!ELSE
+     set(imported_implib \"IMPORTED_IMPLIB_${Configuration}\" \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
+-!!ENDIF
+     _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_implib})
+     if(NOT \"${IMPLIB_LOCATION}\" STREQUAL \"\")
+         set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
+@@ -95,24 +63,13 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ !!IF !no_module_headers
+ !!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
+     set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS
+-      \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework\"
+-      \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Headers\"
++      \"$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework\"
++      \"$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Headers\"
+     )
+ !!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
+     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/\"
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/$${MODULE_INCNAME}\"
+-    )
+-!!ELSE
+-    set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
+-!!ENDIF
+-!!ELSE
+-!!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
+-    set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR\" \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}\")
+-!!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
+-    set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION\"
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION/$${MODULE_INCNAME}\"
++        \"$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/\"
++        \"$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/$${MODULE_INCNAME}\"
+     )
+ !!ELSE
+     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
+@@ -128,7 +85,6 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
+ !!ENDIF
+ !!ENDIF
+-!!ENDIF
+ !!IF !isEmpty(CMAKE_ADD_SOURCE_INCLUDE_DIRS)
+     include(\"${CMAKE_CURRENT_LIST_DIR}/ExtraSourceIncludes.cmake\" OPTIONAL)
+ !!ENDIF
+@@ -254,25 +210,13 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
+ !!IF isEmpty(CMAKE_DEBUG_TYPE)
+ !!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
+-!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+-!!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
+     if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+-!!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
+         _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" \"\" )
+ !!ELSE // CMAKE_STATIC_WINDOWS_BUILD
+     if (EXISTS
+-!!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
+-!!ELSE
+         \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
+-!!ENDIF
+       AND EXISTS
+-!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+-!!ELSE
+         \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+-!!ENDIF
+         _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+ !!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
+     endif()
+@@ -291,25 +235,13 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
+ !!IF isEmpty(CMAKE_RELEASE_TYPE)
+ !!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
+-!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+-!!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
+     if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+-!!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
+         _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" \"\" )
+ !!ELSE // CMAKE_STATIC_WINDOWS_BUILD
+     if (EXISTS
+-!!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
+-!!ELSE
+         \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
+-!!ENDIF
+       AND EXISTS
+-!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+-!!ELSE
+         \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+-!!ENDIF
+         _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+ !!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
+     endif()
+@@ -328,11 +260,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+     macro(_populate_$${CMAKE_MODULE_NAME}_plugin_properties Plugin Configuration PLUGIN_LOCATION)
+         set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
+ 
+-!!IF isEmpty(CMAKE_PLUGIN_DIR_IS_ABSOLUTE)
+-        set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
+-!!ELSE
+         set(imported_location \"$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
+-!!ENDIF
+         _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
+         set_target_properties(Qt5::${Plugin} PROPERTIES
+             \"IMPORTED_LOCATION_${Configuration}\" ${imported_location}
+diff --git a/mkspecs/features/qml_module.prf b/mkspecs/features/qml_module.prf
+index 47ebe78400..25aa2b93e7 100644
+--- a/mkspecs/features/qml_module.prf
++++ b/mkspecs/features/qml_module.prf
+@@ -17,10 +17,7 @@ fq_qml_files = $$_PRO_FILE_PWD_/qmldir
+ 
+ for(qmlf, QML_FILES): fq_qml_files += $$absolute_path($$qmlf, $$_PRO_FILE_PWD_)
+ 
+-qml1_target: \
+-    instbase = $$[QT_INSTALL_IMPORTS]
+-else: \
+-    instbase = $$[QT_INSTALL_QML]
++instbase = $$NIX_OUTPUT_QML
+ 
+ # Install rules
+ qmldir.base = $$_PRO_FILE_PWD_
+diff --git a/mkspecs/features/qml_plugin.prf b/mkspecs/features/qml_plugin.prf
+index ebec1db8da..62ace84a6c 100644
+--- a/mkspecs/features/qml_plugin.prf
++++ b/mkspecs/features/qml_plugin.prf
+@@ -46,13 +46,8 @@ exists($$QMLTYPEFILE): QML_FILES += $$QMLTYPEFILE
+ 
+ load(qt_build_paths)
+ 
+-qml1_target {
+-    DESTDIR = $$MODULE_BASE_OUTDIR/imports/$$TARGETPATH
+-    instbase = $$[QT_INSTALL_IMPORTS]
+-} else {
+-    DESTDIR = $$MODULE_BASE_OUTDIR/qml/$$TARGETPATH
+-    instbase = $$[QT_INSTALL_QML]
+-}
++DESTDIR = $$MODULE_BASE_OUTDIR/qml/$$TARGETPATH
++instbase = $$NIX_OUTPUT_QML
+ 
+ target.path = $$instbase/$$TARGETPATH
+ INSTALLS += target
+diff --git a/mkspecs/features/qt_app.prf b/mkspecs/features/qt_app.prf
+index 46aca50cc2..4f4e634724 100644
+--- a/mkspecs/features/qt_app.prf
++++ b/mkspecs/features/qt_app.prf
+@@ -29,7 +29,7 @@ host_build:force_bootstrap {
+     target.path = $$[QT_HOST_BINS]
+ } else {
+     !build_pass:contains(QT_CONFIG, debug_and_release): CONFIG += release
+-    target.path = $$[QT_INSTALL_BINS]
++    target.path = $$NIX_OUTPUT_BIN/bin
+     CONFIG += relative_qt_rpath  # Qt's tools and apps should be relocatable
+ }
+ INSTALLS += target
+diff --git a/mkspecs/features/qt_build_paths.prf b/mkspecs/features/qt_build_paths.prf
+index 1848f00e90..2af93675c5 100644
+--- a/mkspecs/features/qt_build_paths.prf
++++ b/mkspecs/features/qt_build_paths.prf
+@@ -23,6 +23,6 @@ exists($$MODULE_BASE_INDIR/.git): \
+ !force_independent {
+     # If the module is not built independently, everything ends up in qtbase.
+     # This is the case in non-prefix builds, except for selected modules.
+-    MODULE_BASE_OUTDIR = $$[QT_HOST_PREFIX]
+-    MODULE_QMAKE_OUTDIR = $$[QT_HOST_PREFIX]
++    MODULE_BASE_OUTDIR = $$NIX_OUTPUT_OUT
++    MODULE_QMAKE_OUTDIR = $$NIX_OUTPUT_OUT
+ }
+diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf
+index 08b3f3e5af..5ffeafd9d8 100644
+--- a/mkspecs/features/qt_common.prf
++++ b/mkspecs/features/qt_common.prf
+@@ -30,8 +30,8 @@ contains(TEMPLATE, .*lib) {
+         qqt_libdir = \$\$\$\$[QT_HOST_LIBS]
+         qt_libdir = $$[QT_HOST_LIBS]
+     } else {
+-        qqt_libdir = \$\$\$\$[QT_INSTALL_LIBS]
+-        qt_libdir = $$[QT_INSTALL_LIBS]
++        qqt_libdir = \$\$\$\$NIX_OUTPUT_OUT/lib
++        qt_libdir = $$NIX_OUTPUT_OUT/lib
+     }
+     contains(QMAKE_DEFAULT_LIBDIRS, $$qt_libdir) {
+         lib_replace.match = "[^ ']*$$rplbase/lib"
+diff --git a/mkspecs/features/qt_docs.prf b/mkspecs/features/qt_docs.prf
+index 183d0c9502..17982b04ec 100644
+--- a/mkspecs/features/qt_docs.prf
++++ b/mkspecs/features/qt_docs.prf
+@@ -41,7 +41,7 @@ QMAKE_DOCS_OUTPUTDIR = $$QMAKE_DOCS_BASE_OUTDIR/$$QMAKE_DOCS_TARGETDIR
+ 
+ QDOC += -outputdir $$shell_quote($$QMAKE_DOCS_OUTPUTDIR)
+ !build_online_docs: \
+-    QDOC += -installdir $$shell_quote($$[QT_INSTALL_DOCS])
++    QDOC += -installdir $$shell_quote($$NIX_OUTPUT_DOC)
+ PREP_DOC_INDEXES =
+ DOC_INDEXES =
+ !isEmpty(QTREPOS) {
+@@ -60,8 +60,8 @@ DOC_INDEXES =
+         DOC_INDEXES += -indexdir $$shell_quote($$qrep/doc)
+ } else {
+     prepare_docs: \
+-        PREP_DOC_INDEXES += -indexdir $$shell_quote($$[QT_INSTALL_DOCS/get])
+-    DOC_INDEXES += -indexdir $$shell_quote($$[QT_INSTALL_DOCS/get])
++        PREP_DOC_INDEXES += -indexdir $$shell_quote($$NIX_OUTPUT_DOC)
++    DOC_INDEXES += -indexdir $$shell_quote($$NIX_OUTPUT_DOC)
+ }
+ doc_command = $$QDOC $$QMAKE_DOCS
+ prepare_docs {
+@@ -75,12 +75,12 @@ prepare_docs {
+     qch_docs.commands = $$QHELPGENERATOR $$shell_quote($$QMAKE_DOCS_OUTPUTDIR/$${QMAKE_DOCS_TARGET}.qhp) -o $$shell_quote($$QMAKE_DOCS_BASE_OUTDIR/$${QMAKE_DOCS_TARGET}.qch)
+ 
+     inst_html_docs.files = $$QMAKE_DOCS_OUTPUTDIR
+-    inst_html_docs.path = $$[QT_INSTALL_DOCS]
++    inst_html_docs.path = $$NIX_OUTPUT_DOC
+     inst_html_docs.CONFIG += no_check_exist directory no_default_install no_build
+     INSTALLS += inst_html_docs
+ 
+     inst_qch_docs.files = $$QMAKE_DOCS_BASE_OUTDIR/$${QMAKE_DOCS_TARGET}.qch
+-    inst_qch_docs.path = $$[QT_INSTALL_DOCS]
++    inst_qch_docs.path = $$NIX_OUTPUT_DOC
+     inst_qch_docs.CONFIG += no_check_exist no_default_install no_build
+     INSTALLS += inst_qch_docs
+ 
+diff --git a/mkspecs/features/qt_example_installs.prf b/mkspecs/features/qt_example_installs.prf
+index 4c68cfd72f..f422f18266 100644
+--- a/mkspecs/features/qt_example_installs.prf
++++ b/mkspecs/features/qt_example_installs.prf
+@@ -70,7 +70,7 @@ probase = $$relative_path($$_PRO_FILE_PWD_, $$dirname(_QMAKE_CONF_)/examples)
+         $$SOURCES $$HEADERS $$FORMS $$RESOURCES $$TRANSLATIONS \
+         $$DBUS_ADAPTORS $$DBUS_INTERFACES
+     addInstallFiles(sources.files, $$sourcefiles)
+-    sources.path = $$[QT_INSTALL_EXAMPLES]/$$probase
++    sources.path = $$NIX_OUTPUT_DEV/share/examples/$$probase
+     INSTALLS += sources
+ 
+     check_examples {
+diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf
+index 4a1d265a8b..d346424b5b 100644
+--- a/mkspecs/features/qt_functions.prf
++++ b/mkspecs/features/qt_functions.prf
+@@ -70,7 +70,7 @@ defineTest(qtHaveModule) {
+ defineTest(qtPrepareTool) {
+     cmd = $$eval(QT_TOOL.$${2}.binary)
+     isEmpty(cmd) {
+-        cmd = $$[QT_HOST_BINS]/$$2
++        cmd = $$system("command -v $$2")
+         exists($${cmd}.pl) {
+             cmd = perl -w $$system_path($${cmd}.pl)
+         } else: contains(QMAKE_HOST.os, Windows) {
+diff --git a/mkspecs/features/qt_installs.prf b/mkspecs/features/qt_installs.prf
+index 3a5dbb6274..24f321bd82 100644
+--- a/mkspecs/features/qt_installs.prf
++++ b/mkspecs/features/qt_installs.prf
+@@ -12,16 +12,10 @@
+ #library
+ !qt_no_install_library {
+     win32 {
+-       host_build: \
+-           dlltarget.path = $$[QT_HOST_BINS]
+-       else: \
+-           dlltarget.path = $$[QT_INSTALL_BINS]
++        dlltarget.path = $$NIX_OUTPUT_BIN/bin
+        INSTALLS += dlltarget
+     }
+-    host_build: \
+-        target.path = $$[QT_HOST_LIBS]
+-    else: \
+-        target.path = $$[QT_INSTALL_LIBS]
++    target.path = $$NIX_OUTPUT_OUT/lib
+     !static: target.CONFIG = no_dll
+     INSTALLS += target
+ }
+@@ -29,33 +23,33 @@
+ #headers
+ qt_install_headers {
+     class_headers.files = $$SYNCQT.HEADER_CLASSES
+-    class_headers.path = $$[QT_INSTALL_HEADERS]/$$MODULE_INCNAME
++    class_headers.path = $$NIX_OUTPUT_DEV/include/$$MODULE_INCNAME
+     INSTALLS += class_headers
+ 
+     targ_headers.files = $$SYNCQT.HEADER_FILES
+-    targ_headers.path = $$[QT_INSTALL_HEADERS]/$$MODULE_INCNAME
++    targ_headers.path = $$NIX_OUTPUT_DEV/include/$$MODULE_INCNAME
+     INSTALLS += targ_headers
+ 
+     private_headers.files = $$SYNCQT.PRIVATE_HEADER_FILES
+-    private_headers.path = $$[QT_INSTALL_HEADERS]/$$MODULE_INCNAME/$$VERSION/$$MODULE_INCNAME/private
++    private_headers.path = $$NIX_OUTPUT_DEV/include/$$MODULE_INCNAME/$$VERSION/$$MODULE_INCNAME/private
+     INSTALLS += private_headers
+ 
+     qpa_headers.files = $$SYNCQT.QPA_HEADER_FILES
+-    qpa_headers.path = $$[QT_INSTALL_HEADERS]/$$MODULE_INCNAME/$$VERSION/$$MODULE_INCNAME/qpa
++    qpa_headers.path = $$NIX_OUTPUT_DEV/include/$$MODULE_INCNAME/$$VERSION/$$MODULE_INCNAME/qpa
+     INSTALLS += qpa_headers
+ }
+ 
+ #module
+ qt_install_module {
+     !isEmpty(MODULE_PRI) {
+-        pritarget.path = $$[QT_HOST_DATA]/mkspecs/modules
++        pritarget.path = $$NIX_OUTPUT_DEV/mkspecs/modules
+         pritarget.files = $$MODULE_PRI
+         INSTALLS += pritarget
+     } else: isEmpty(MODULE_PRIVATE_PRI) {
+         warning("Project $$basename(_PRO_FILE_) is a module, but has not defined MODULE_PRI, which is required for Qt to expose the module to other projects.")
+     }
+     !isEmpty(MODULE_PRIVATE_PRI) {
+-        privpritarget.path = $$[QT_HOST_DATA]/mkspecs/modules
++        privpritarget.path = $$NIX_OUTPUT_DEV/mkspecs/modules
+         privpritarget.files = $$MODULE_PRIVATE_PRI
+         INSTALLS += privpritarget
+     }
+diff --git a/mkspecs/features/qt_plugin.prf b/mkspecs/features/qt_plugin.prf
+index 3cf6c7349c..83e68025a5 100644
+--- a/mkspecs/features/qt_plugin.prf
++++ b/mkspecs/features/qt_plugin.prf
+@@ -82,7 +82,7 @@ CONFIG(static, static|shared)|prefix_build {
+     }
+ }
+ 
+-target.path = $$[QT_INSTALL_PLUGINS]/$$PLUGIN_TYPE
++target.path = $$NIX_OUTPUT_PLUGIN/$$PLUGIN_TYPE
+ INSTALLS += target
+ 
+ TARGET = $$qt5LibraryTarget($$TARGET)
+diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
+index 91a4eb619a..08b533e69c 100644
+--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
++++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
+@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::qmake)
+     add_executable(Qt5::qmake IMPORTED)
+ 
+ !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
+ !!ENDIF
+@@ -18,7 +18,7 @@ if (NOT TARGET Qt5::moc)
+     add_executable(Qt5::moc IMPORTED)
+ 
+ !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
+ !!ENDIF
+@@ -35,7 +35,7 @@ if (NOT TARGET Qt5::rcc)
+     add_executable(Qt5::rcc IMPORTED)
+ 
+ !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
+ !!ENDIF
+@@ -131,7 +131,7 @@ if (NOT TARGET Qt5::WinMain)
+ !!IF !isEmpty(CMAKE_RELEASE_TYPE)
+     set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+ !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
+ !!ENDIF
+@@ -145,7 +145,7 @@ if (NOT TARGET Qt5::WinMain)
+     set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
+ 
+ !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
+ !!ENDIF
+diff --git a/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in b/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
+index c357237d0e..6f0c75de3c 100644
+--- a/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
++++ b/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
+@@ -1,6 +1,6 @@
+ 
+ !!IF isEmpty(CMAKE_HOST_DATA_DIR_IS_ABSOLUTE)
+-set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_HOST_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
++set(_qt5_corelib_extra_includes \"$$NIX_OUTPUT_DEV/$${CMAKE_HOST_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
+ !!ELSE
+ set(_qt5_corelib_extra_includes \"$${CMAKE_HOST_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
+ !!ENDIF
+diff --git a/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in b/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
+index 706304cf34..546420f6ad 100644
+--- a/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
++++ b/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
+@@ -1,6 +1,6 @@
+ 
+ !!IF isEmpty(CMAKE_INSTALL_DATA_DIR_IS_ABSOLUTE)
+-set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_INSTALL_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
++set(_qt5_corelib_extra_includes \"$$NIX_OUTPUT_DEV/$${CMAKE_INSTALL_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
+ !!ELSE
+ set(_qt5_corelib_extra_includes \"$${CMAKE_INSTALL_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
+ !!ENDIF
+diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
+index bd3c12ce97..a796775970 100644
+--- a/src/corelib/kernel/qcoreapplication.cpp
++++ b/src/corelib/kernel/qcoreapplication.cpp
+@@ -2533,6 +2533,15 @@ QStringList QCoreApplication::libraryPaths()
+         QStringList *app_libpaths = new QStringList;
+         coreappdata()->app_libpaths.reset(app_libpaths);
+ 
++        // Add library paths derived from PATH
++        const QStringList paths = QFile::decodeName(qgetenv("PATH")).split(':');
++        const QString plugindir = QStringLiteral("../" NIXPKGS_QT_PLUGIN_PREFIX);
++        for (const QString &path: paths) {
++            if (!path.isEmpty()) {
++                app_libpaths->append(QDir::cleanPath(path + QDir::separator() + plugindir));
++            }
++        }
++
+         const QByteArray libPathEnv = qgetenv("QT_PLUGIN_PATH");
+         if (!libPathEnv.isEmpty()) {
+             QStringList paths = QFile::decodeName(libPathEnv).split(QDir::listSeparator(), QString::SkipEmptyParts);
+diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp
+index c13c9a5223..6936851511 100644
+--- a/src/corelib/tools/qtimezoneprivate_tz.cpp
++++ b/src/corelib/tools/qtimezoneprivate_tz.cpp
+@@ -64,7 +64,11 @@ typedef QHash<QByteArray, QTzTimeZone> QTzTimeZoneHash;
+ // Parse zone.tab table, assume lists all installed zones, if not will need to read directories
+ static QTzTimeZoneHash loadTzTimeZones()
+ {
+-    QString path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
++    // Try TZDIR first, in case we're running on NixOS.
++    QString path = QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/zone.tab");
++    // Fallback to traditional paths in case we are not on NixOS.
++    if (!QFile::exists(path))
++        path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
+     if (!QFile::exists(path))
+         path = QStringLiteral("/usr/lib/zoneinfo/zone.tab");
+ 
+@@ -636,12 +640,16 @@ void QTzTimeZonePrivate::init(const QByteArray &ianaId)
+         if (!tzif.open(QIODevice::ReadOnly))
+             return;
+     } else {
+-        // Open named tz, try modern path first, if fails try legacy path
+-        tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
++        // Try TZDIR first, in case we're running on NixOS
++        tzif.setFileName(QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/") + QString::fromLocal8Bit(ianaId));
+         if (!tzif.open(QIODevice::ReadOnly)) {
+-            tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
+-            if (!tzif.open(QIODevice::ReadOnly))
+-                return;
++            // Open named tz, try modern path first, if fails try legacy path
++            tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
++            if (!tzif.open(QIODevice::ReadOnly)) {
++                tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
++                if (!tzif.open(QIODevice::ReadOnly))
++                    return;
++            }
+         }
+     }
+ 
+diff --git a/src/dbus/Qt5DBusConfigExtras.cmake.in b/src/dbus/Qt5DBusConfigExtras.cmake.in
+index 1d947159e2..b36865fc48 100644
+--- a/src/dbus/Qt5DBusConfigExtras.cmake.in
++++ b/src/dbus/Qt5DBusConfigExtras.cmake.in
+@@ -2,11 +2,7 @@
+ if (NOT TARGET Qt5::qdbuscpp2xml)
+     add_executable(Qt5::qdbuscpp2xml IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5DBus_install_prefix}/$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+-    set(imported_location \"$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
++    set(imported_location \"$$NIX_OUTPUT_DEV/bin/qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
+     _qt5_DBus_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::qdbuscpp2xml PROPERTIES
+@@ -17,11 +13,7 @@ endif()
+ if (NOT TARGET Qt5::qdbusxml2cpp)
+     add_executable(Qt5::qdbusxml2cpp IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5DBus_install_prefix}/$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+-    set(imported_location \"$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
++    set(imported_location \"$$NIX_OUTPUT_DEV/bin/qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
+     _qt5_DBus_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::qdbusxml2cpp PROPERTIES
+diff --git a/src/gui/Qt5GuiConfigExtras.cmake.in b/src/gui/Qt5GuiConfigExtras.cmake.in
+index 07869efd7d..fb4183bada 100644
+--- a/src/gui/Qt5GuiConfigExtras.cmake.in
++++ b/src/gui/Qt5GuiConfigExtras.cmake.in
+@@ -2,7 +2,7 @@
+ !!IF !isEmpty(CMAKE_ANGLE_EGL_DLL_RELEASE)
+ 
+ !!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
+-set(Qt5Gui_EGL_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR/QtANGLE\")
++set(Qt5Gui_EGL_INCLUDE_DIRS \"$$NIX_OUTPUT_DEV/$$CMAKE_INCLUDE_DIR/QtANGLE\")
+ !!ELSE
+ set(Qt5Gui_EGL_INCLUDE_DIRS \"$$CMAKE_INCLUDE_DIR/QtANGLE\")
+ !!ENDIF
+@@ -17,13 +17,13 @@ macro(_populate_qt5gui_gl_target_properties TargetName Configuration LIB_LOCATIO
+     set_property(TARGET Qt5::${TargetName} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
+ 
+ !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Gui_install_prefix}/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
++    set(imported_location \"$$NIX_OUTPUT_OUT/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
+ !!ENDIF
+ 
+ !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    set(imported_implib \"${_qt5Gui_install_prefix}/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
++    set(imported_implib \"$$NIX_OUTPUT_OUT/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
+ !!ELSE
+     set(imported_implib \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
+ !!ENDIF
+diff --git a/src/network/kernel/qdnslookup_unix.cpp b/src/network/kernel/qdnslookup_unix.cpp
+index 584f0b0f0e..24d80063f2 100644
+--- a/src/network/kernel/qdnslookup_unix.cpp
++++ b/src/network/kernel/qdnslookup_unix.cpp
+@@ -83,7 +83,7 @@ static bool resolveLibraryInternal()
+     if (!lib.load())
+ #endif
+     {
+-        lib.setFileName(QLatin1String("resolv"));
++        lib.setFileName(QLatin1String(NIXPKGS_LIBRESOLV));
+         if (!lib.load())
+             return false;
+     }
+diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
+index dabf1913cc..53bb867e07 100644
+--- a/src/network/kernel/qhostinfo_unix.cpp
++++ b/src/network/kernel/qhostinfo_unix.cpp
+@@ -94,7 +94,7 @@ static bool resolveLibraryInternal()
+     if (!lib.load())
+ #endif
+     {
+-        lib.setFileName(QLatin1String("resolv"));
++        lib.setFileName(QLatin1String(NIXPKGS_LIBRESOLV));
+         if (!lib.load())
+             return false;
+     }
+diff --git a/src/network/ssl/qsslcontext_openssl.cpp b/src/network/ssl/qsslcontext_openssl.cpp
+index 68caaeb6dc..fef4a81474 100644
+--- a/src/network/ssl/qsslcontext_openssl.cpp
++++ b/src/network/ssl/qsslcontext_openssl.cpp
+@@ -340,7 +340,7 @@ init_context:
+ 
+     const QVector<QSslEllipticCurve> qcurves = sslContext->sslConfiguration.ellipticCurves();
+     if (!qcurves.isEmpty()) {
+-#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_EC)
++#if OPENSSL_VERSION_NUMBER >= 0x10002000L && defined(SSL_CTRL_SET_CURVES) && !defined(OPENSSL_NO_EC)
+         // Set the curves to be used
+         if (q_SSLeay() >= 0x10002000L) {
+             // SSL_CTX_ctrl wants a non-const pointer as last argument,
+@@ -354,7 +354,7 @@ init_context:
+                 return sslContext;
+             }
+         } else
+-#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_EC)
++#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L && defined(SSL_CTRL_SET_CURVES) && !defined(OPENSSL_NO_EC)
+         {
+             // specific curves requested, but not possible to set -> error
+             sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocket::tr("OpenSSL version too old, need at least v1.0.2"));
+diff --git a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
+index 338c7ca3be..dd52114bac 100644
+--- a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
++++ b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
+@@ -251,12 +251,9 @@ void TableGenerator::initPossibleLocations()
+     // the QTCOMPOSE environment variable
+     if (qEnvironmentVariableIsSet("QTCOMPOSE"))
+         m_possibleLocations.append(QString::fromLocal8Bit(qgetenv("QTCOMPOSE")));
+-    m_possibleLocations.append(QStringLiteral("/usr/share/X11/locale"));
+-    m_possibleLocations.append(QStringLiteral("/usr/local/share/X11/locale"));
+-    m_possibleLocations.append(QStringLiteral("/usr/lib/X11/locale"));
+-    m_possibleLocations.append(QStringLiteral("/usr/local/lib/X11/locale"));
+     m_possibleLocations.append(QStringLiteral(X11_PREFIX "/share/X11/locale"));
+     m_possibleLocations.append(QStringLiteral(X11_PREFIX "/lib/X11/locale"));
++    m_possibleLocations.append(QLatin1String(NIXPKGS_QTCOMPOSE));
+ }
+ 
+ QString TableGenerator::findComposeFile()
+diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+index c2b7a562a9..4fa5f6d6a5 100644
+--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
++++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+@@ -570,7 +570,14 @@ void (*QGLXContext::getProcAddress(const QByteArray &procName)) ()
+ #ifndef QT_NO_LIBRARY
+                 extern const QString qt_gl_library_name();
+ //                QLibrary lib(qt_gl_library_name());
++                // Check system library paths first
+                 QLibrary lib(QLatin1String("GL"));
++#ifdef NIXPKGS_MESA_GL
++                if (!lib.load()) {
++                    // Fallback to Mesa driver
++                    lib.setFileName(QLatin1String(NIXPKGS_MESA_GL));
++                }
++#endif // NIXPKGS_MESA_GL
+                 glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB");
+ #endif
+             }
+diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp
+index 4646ced954..ff3111f393 100644
+--- a/src/plugins/platforms/xcb/qxcbcursor.cpp
++++ b/src/plugins/platforms/xcb/qxcbcursor.cpp
+@@ -303,10 +303,10 @@ QXcbCursor::QXcbCursor(QXcbConnection *conn, QXcbScreen *screen)
+ #if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY)
+     static bool function_ptrs_not_initialized = true;
+     if (function_ptrs_not_initialized) {
+-        QLibrary xcursorLib(QLatin1String("Xcursor"), 1);
++        QLibrary xcursorLib(QLatin1String(NIXPKGS_LIBXCURSOR), 1);
+         bool xcursorFound = xcursorLib.load();
+         if (!xcursorFound) { // try without the version number
+-            xcursorLib.setFileName(QLatin1String("Xcursor"));
++            xcursorLib.setFileName(QLatin1String(NIXPKGS_LIBXCURSOR));
+             xcursorFound = xcursorLib.load();
+         }
+         if (xcursorFound) {
+diff --git a/src/testlib/qtestassert.h b/src/testlib/qtestassert.h
+index ca3e02ca06..28dd73d772 100644
+--- a/src/testlib/qtestassert.h
++++ b/src/testlib/qtestassert.h
+@@ -38,10 +38,13 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-
+-#define QTEST_ASSERT(cond) do { if (!(cond)) qt_assert(#cond,__FILE__,__LINE__); } while (0)
+-
+-#define QTEST_ASSERT_X(cond, where, what) do { if (!(cond)) qt_assert_x(where, what,__FILE__,__LINE__); } while (0)
++#if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
++#define QTEST_ASSERT(cond) do { } while ((false) && (cond))
++#define QTEST_ASSERT_X(cond, where, what) do { } while ((false) && (cond))
++#else
++#define QTEST_ASSERT(cond) do { if (!(cond)) qt_assert(#cond,__FILE__,__LINE__); } while (false)
++#define QTEST_ASSERT_X(cond, where, what) do { if (!(cond)) qt_assert_x(where, what,__FILE__,__LINE__); } while (false)
++#endif
+ 
+ QT_END_NAMESPACE
+ 
+diff --git a/src/widgets/Qt5WidgetsConfigExtras.cmake.in b/src/widgets/Qt5WidgetsConfigExtras.cmake.in
+index 99d87e2e46..a4eab2aa72 100644
+--- a/src/widgets/Qt5WidgetsConfigExtras.cmake.in
++++ b/src/widgets/Qt5WidgetsConfigExtras.cmake.in
+@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::uic)
+     add_executable(Qt5::uic IMPORTED)
+ 
+ !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Widgets_install_prefix}/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
+ !!ENDIF
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/cmake-paths-darwin.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/cmake-paths-darwin.patch
deleted file mode 100644
index 9d42314e4cc9..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/cmake-paths-darwin.patch
+++ /dev/null
@@ -1,384 +0,0 @@
-Index: qtbase-opensource-src-5.6.1/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
-+++ qtbase-opensource-src-5.6.1/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
-@@ -9,30 +9,6 @@ if (CMAKE_VERSION VERSION_LESS 3.0.0)
- endif()
- !!ENDIF
- 
--!!IF !isEmpty(CMAKE_USR_MOVE_WORKAROUND)
--!!IF !isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--set(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$[QT_INSTALL_PREFIX]\")
--!!ELSE
--get_filename_component(_IMPORT_PREFIX \"${CMAKE_CURRENT_LIST_FILE}\" PATH)
--# Use original install prefix when loaded through a
--# cross-prefix symbolic link such as /lib -> /usr/lib.
--get_filename_component(_realCurr \"${_IMPORT_PREFIX}\" REALPATH)
--get_filename_component(_realOrig \"$$CMAKE_INSTALL_LIBS_DIR/cmake/Qt5$${CMAKE_MODULE_NAME}\" REALPATH)
--if(_realCurr STREQUAL _realOrig)
--    get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$CMAKE_INSTALL_LIBS_DIR/$${CMAKE_RELATIVE_INSTALL_LIBS_DIR}\" ABSOLUTE)
--else()
--    get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
--endif()
--unset(_realOrig)
--unset(_realCurr)
--unset(_IMPORT_PREFIX)
--!!ENDIF
--!!ELIF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
--!!ELSE
--set(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$[QT_INSTALL_PREFIX]\")
--!!ENDIF
--
- !!IF !equals(TEMPLATE, aux)
- # For backwards compatibility only. Use Qt5$${CMAKE_MODULE_NAME}_VERSION instead.
- set(Qt5$${CMAKE_MODULE_NAME}_VERSION_STRING "$$eval(QT.$${MODULE}.MAJOR_VERSION).$$eval(QT.$${MODULE}.MINOR_VERSION).$$eval(QT.$${MODULE}.PATCH_VERSION)")
-@@ -59,7 +35,10 @@ macro(_populate_$${CMAKE_MODULE_NAME}_ta
-     set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
- 
- !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
-+    set(imported_location \"@NIX_OUT@/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
-+    if(NOT EXISTS \"${imported_location}\")
-+        set(imported_location \"@NIX_DEV@/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
-+    endif()
- !!ELSE
-     set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
- !!ENDIF
-@@ -74,45 +53,17 @@ macro(_populate_$${CMAKE_MODULE_NAME}_ta
-         \"IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\"
-     )
- 
--!!IF !isEmpty(CMAKE_WINDOWS_BUILD)
--!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    set(imported_implib \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
--!!ELSE
--    set(imported_implib \"IMPORTED_IMPLIB_${Configuration}\" \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
--!!ENDIF
--    _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_implib})
--    if(NOT \"${IMPLIB_LOCATION}\" STREQUAL \"\")
--        set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
--        \"IMPORTED_IMPLIB_${Configuration}\" ${imported_implib}
--        )
--    endif()
--!!ENDIF
- endmacro()
- !!ENDIF
- 
- if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
- 
- !!IF !no_module_headers
--!!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
--    set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS
--      \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework\"
--      \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Headers\"
--    )
--!!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
--    set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/\"
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/$${MODULE_INCNAME}\"
--    )
--!!ELSE
--    set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
--!!ENDIF
--!!ELSE
- !!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
--    set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR\" \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}\")
-+    set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS \"@NIX_OUT@/lib\" \"@NIX_OUT@/lib/$${MODULE_INCNAME}.framework/Headers\")
- !!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
-     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION\"
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION/$${MODULE_INCNAME}\"
-+        \"\"
-     )
- !!ELSE
-     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
-@@ -128,7 +80,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
-     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
- !!ENDIF
- !!ENDIF
--!!ENDIF
-+
- !!IF !isEmpty(CMAKE_ADD_SOURCE_INCLUDE_DIRS)
-     include(\"${CMAKE_CURRENT_LIST_DIR}/ExtraSourceIncludes.cmake\" OPTIONAL)
- !!ENDIF
-@@ -253,28 +205,19 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
- 
- !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
- !!IF isEmpty(CMAKE_DEBUG_TYPE)
--!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
--!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
--!!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
--    if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
--!!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
--        _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" \"\" )
--!!ELSE // CMAKE_STATIC_WINDOWS_BUILD
-     if (EXISTS
- !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
-+        \"@NIX_OUT@/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
- !!ELSE
-         \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
- !!ENDIF
-       AND EXISTS
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
-+        \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
- !!ELSE
-         \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
- !!ENDIF
-         _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
--!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
-     endif()
- !!ENDIF // CMAKE_DEBUG_TYPE
- !!ENDIF // CMAKE_FIND_OTHER_LIBRARY_BUILD
-@@ -282,36 +225,23 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
- !!ENDIF // CMAKE_RELEASE_TYPE
- 
- !!IF !isEmpty(CMAKE_DEBUG_TYPE)
--!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
--    _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" \"\" )
--!!ELSE
-     _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
--!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
- 
- !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
- !!IF isEmpty(CMAKE_RELEASE_TYPE)
--!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
--!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
--!!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
--    if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
--!!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
--        _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" \"\" )
--!!ELSE // CMAKE_STATIC_WINDOWS_BUILD
-     if (EXISTS
- !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
-+        \"@NIX_OUT@/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
- !!ELSE
-         \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
- !!ENDIF
-       AND EXISTS
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
-+        \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
- !!ELSE
-         \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
- !!ENDIF
-         _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
--!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
-     endif()
- !!ENDIF // CMAKE_RELEASE_TYPE
- !!ENDIF // CMAKE_FIND_OTHER_LIBRARY_BUILD
-@@ -328,11 +258,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
-     macro(_populate_$${CMAKE_MODULE_NAME}_plugin_properties Plugin Configuration PLUGIN_LOCATION)
-         set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
- 
--!!IF isEmpty(CMAKE_PLUGIN_DIR_IS_ABSOLUTE)
--        set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
--!!ELSE
--        set(imported_location \"$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
--!!ENDIF
-+        set(imported_location \"${PLUGIN_LOCATION}\")
-         _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
-         set_target_properties(Qt5::${Plugin} PROPERTIES
-             \"IMPORTED_LOCATION_${Configuration}\" ${imported_location}
-Index: qtbase-opensource-src-5.6.1/src/gui/Qt5GuiConfigExtras.cmake.in
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/src/gui/Qt5GuiConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.6.1/src/gui/Qt5GuiConfigExtras.cmake.in
-@@ -2,7 +2,7 @@
- !!IF !isEmpty(CMAKE_ANGLE_EGL_DLL_RELEASE)
- 
- !!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
--set(Qt5Gui_EGL_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR/QtANGLE\")
-+set(Qt5Gui_EGL_INCLUDE_DIRS \"@NIX_DEV@/$$CMAKE_INCLUDE_DIR/QtANGLE\")
- !!ELSE
- set(Qt5Gui_EGL_INCLUDE_DIRS \"$$CMAKE_INCLUDE_DIR/QtANGLE\")
- !!ENDIF
-@@ -17,13 +17,13 @@ macro(_populate_qt5gui_gl_target_propert
-     set_property(TARGET Qt5::${TargetName} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
- 
- !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Gui_install_prefix}/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
-+    set(imported_location \"@NIX_OUT@/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
- !!ELSE
-     set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
- !!ENDIF
- 
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    set(imported_implib \"${_qt5Gui_install_prefix}/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
-+    set(imported_implib \"@NIX_DEV@/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
- !!ELSE
-     set(imported_implib \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
- !!ENDIF
-Index: qtbase-opensource-src-5.6.1/src/widgets/Qt5WidgetsConfigExtras.cmake.in
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/src/widgets/Qt5WidgetsConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.6.1/src/widgets/Qt5WidgetsConfigExtras.cmake.in
-@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::uic)
-     add_executable(Qt5::uic IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Widgets_install_prefix}/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-Index: qtbase-opensource-src-5.6.1/src/corelib/Qt5CoreConfigExtras.cmake.in
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/src/corelib/Qt5CoreConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.6.1/src/corelib/Qt5CoreConfigExtras.cmake.in
-@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::qmake)
-     add_executable(Qt5::qmake IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-@@ -18,7 +18,7 @@ if (NOT TARGET Qt5::moc)
-     add_executable(Qt5::moc IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-@@ -35,7 +35,7 @@ if (NOT TARGET Qt5::rcc)
-     add_executable(Qt5::rcc IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-@@ -131,7 +131,7 @@ if (NOT TARGET Qt5::WinMain)
- !!IF !isEmpty(CMAKE_RELEASE_TYPE)
-     set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
- !!ELSE
-     set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
- !!ENDIF
-@@ -145,7 +145,7 @@ if (NOT TARGET Qt5::WinMain)
-     set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
- 
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
- !!ELSE
-     set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
- !!ENDIF
-Index: qtbase-opensource-src-5.6.1/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
-+++ qtbase-opensource-src-5.6.1/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
-@@ -1,6 +1,6 @@
- 
- !!IF isEmpty(CMAKE_INSTALL_DATA_DIR_IS_ABSOLUTE)
--set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_INSTALL_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
-+set(_qt5_corelib_extra_includes \"@NIX_DEV@/$${CMAKE_INSTALL_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
- !!ELSE
- set(_qt5_corelib_extra_includes \"$${CMAKE_INSTALL_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
- !!ENDIF
-Index: qtbase-opensource-src-5.6.1/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
-+++ qtbase-opensource-src-5.6.1/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
-@@ -1,6 +1,6 @@
- 
- !!IF isEmpty(CMAKE_HOST_DATA_DIR_IS_ABSOLUTE)
--set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_HOST_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
-+set(_qt5_corelib_extra_includes \"@NIX_DEV@/$${CMAKE_HOST_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
- !!ELSE
- set(_qt5_corelib_extra_includes \"$${CMAKE_HOST_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
- !!ENDIF
-Index: qtbase-opensource-src-5.6.1/src/dbus/Qt5DBusConfigExtras.cmake.in
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/src/dbus/Qt5DBusConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.6.1/src/dbus/Qt5DBusConfigExtras.cmake.in
-@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::qdbuscpp2xml)
-     add_executable(Qt5::qdbuscpp2xml IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5DBus_install_prefix}/$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-@@ -18,7 +18,7 @@ if (NOT TARGET Qt5::qdbusxml2cpp)
-     add_executable(Qt5::qdbusxml2cpp IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5DBus_install_prefix}/$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-Index: qtbase-opensource-src-5.6.1/mkspecs/features/create_cmake.prf
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/mkspecs/features/create_cmake.prf
-+++ qtbase-opensource-src-5.6.1/mkspecs/features/create_cmake.prf
-@@ -136,28 +136,28 @@ contains(CONFIG, plugin) {
- 
-     win32 {
-         isEmpty(CMAKE_STATIC_TYPE) {
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.dll
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.dll
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/$${TARGET}.dll
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/$${TARGET}d.dll
-         } else:mingw {
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}.a
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}d.a
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}/$$PLUGIN_TYPE/lib$${TARGET}.a
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}d.a
-         } else {                         # MSVC static
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.lib
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.lib
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/$${TARGET}.lib
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/$${TARGET}d.lib
-         }
-     } else {
-         mac {
-             isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .dylib
-             else: CMAKE_PlUGIN_EXT = .a
- 
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-         } else {
-             isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .so
-             else: CMAKE_PlUGIN_EXT = .a
- 
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-         }
-     }
-     cmake_target_file.input = $$PWD/data/cmake/Qt5PluginTarget.cmake.in
-Index: qtbase-opensource-src-5.6.1/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
-+++ qtbase-opensource-src-5.6.1/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
-@@ -2,10 +2,10 @@
- add_library(Qt5::$$CMAKE_PLUGIN_NAME MODULE IMPORTED)
- 
- !!IF !isEmpty(CMAKE_RELEASE_TYPE)
--_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
-+_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"@NIX_OUT@/$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
- !!ENDIF
- !!IF !isEmpty(CMAKE_DEBUG_TYPE)
--_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
-+_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"@NIX_OUT@/$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
- !!ENDIF
- 
- list(APPEND Qt5$${CMAKE_MODULE_NAME}_PLUGINS Qt5::$$CMAKE_PLUGIN_NAME)
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/cmake-paths.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/cmake-paths.patch
deleted file mode 100644
index ca8a42663754..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/cmake-paths.patch
+++ /dev/null
@@ -1,385 +0,0 @@
-Index: qtbase-opensource-src-5.6.1/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
-+++ qtbase-opensource-src-5.6.1/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
-@@ -9,30 +9,6 @@ if (CMAKE_VERSION VERSION_LESS 3.0.0)
- endif()
- !!ENDIF
- 
--!!IF !isEmpty(CMAKE_USR_MOVE_WORKAROUND)
--!!IF !isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--set(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$[QT_INSTALL_PREFIX]\")
--!!ELSE
--get_filename_component(_IMPORT_PREFIX \"${CMAKE_CURRENT_LIST_FILE}\" PATH)
--# Use original install prefix when loaded through a
--# cross-prefix symbolic link such as /lib -> /usr/lib.
--get_filename_component(_realCurr \"${_IMPORT_PREFIX}\" REALPATH)
--get_filename_component(_realOrig \"$$CMAKE_INSTALL_LIBS_DIR/cmake/Qt5$${CMAKE_MODULE_NAME}\" REALPATH)
--if(_realCurr STREQUAL _realOrig)
--    get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$CMAKE_INSTALL_LIBS_DIR/$${CMAKE_RELATIVE_INSTALL_LIBS_DIR}\" ABSOLUTE)
--else()
--    get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
--endif()
--unset(_realOrig)
--unset(_realCurr)
--unset(_IMPORT_PREFIX)
--!!ENDIF
--!!ELIF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
--!!ELSE
--set(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$[QT_INSTALL_PREFIX]\")
--!!ENDIF
--
- !!IF !equals(TEMPLATE, aux)
- # For backwards compatibility only. Use Qt5$${CMAKE_MODULE_NAME}_VERSION instead.
- set(Qt5$${CMAKE_MODULE_NAME}_VERSION_STRING "$$eval(QT.$${MODULE}.MAJOR_VERSION).$$eval(QT.$${MODULE}.MINOR_VERSION).$$eval(QT.$${MODULE}.PATCH_VERSION)")
-@@ -59,7 +35,10 @@ macro(_populate_$${CMAKE_MODULE_NAME}_ta
-     set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
- 
- !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
-+    set(imported_location \"@NIX_OUT@/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
-+    if(NOT EXISTS \"${imported_location}\")
-+        set(imported_location \"@NIX_DEV@/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
-+    endif()
- !!ELSE
-     set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
- !!ENDIF
-@@ -74,45 +53,18 @@ macro(_populate_$${CMAKE_MODULE_NAME}_ta
-         \"IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\"
-     )
- 
--!!IF !isEmpty(CMAKE_WINDOWS_BUILD)
--!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    set(imported_implib \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
--!!ELSE
--    set(imported_implib \"IMPORTED_IMPLIB_${Configuration}\" \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
--!!ENDIF
--    _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_implib})
--    if(NOT \"${IMPLIB_LOCATION}\" STREQUAL \"\")
--        set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
--        \"IMPORTED_IMPLIB_${Configuration}\" ${imported_implib}
--        )
--    endif()
--!!ENDIF
- endmacro()
- !!ENDIF
- 
- if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
- 
- !!IF !no_module_headers
--!!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
--    set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS
--      \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework\"
--      \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Headers\"
--    )
--!!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
--    set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/\"
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/$${MODULE_INCNAME}\"
--    )
--!!ELSE
--    set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
--!!ENDIF
--!!ELSE
- !!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
--    set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR\" \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}\")
-+    set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS \"@NIX_DEV@/$$CMAKE_INCLUDE_DIR\" \"@NIX_DEV@/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}\")
- !!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
-     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION\"
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION/$${MODULE_INCNAME}\"
-+        \"@NIX_DEV@/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION\"
-+        \"@NIX_DEV@/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION/$${MODULE_INCNAME}\"
-     )
- !!ELSE
-     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
-@@ -128,7 +80,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
-     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
- !!ENDIF
- !!ENDIF
--!!ENDIF
-+
- !!IF !isEmpty(CMAKE_ADD_SOURCE_INCLUDE_DIRS)
-     include(\"${CMAKE_CURRENT_LIST_DIR}/ExtraSourceIncludes.cmake\" OPTIONAL)
- !!ENDIF
-@@ -253,28 +205,19 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
- 
- !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
- !!IF isEmpty(CMAKE_DEBUG_TYPE)
--!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
--!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
--!!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
--    if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
--!!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
--        _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" \"\" )
--!!ELSE // CMAKE_STATIC_WINDOWS_BUILD
-     if (EXISTS
- !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
-+        \"@NIX_OUT@/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
- !!ELSE
-         \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
- !!ENDIF
-       AND EXISTS
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
-+        \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
- !!ELSE
-         \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
- !!ENDIF
-         _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
--!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
-     endif()
- !!ENDIF // CMAKE_DEBUG_TYPE
- !!ENDIF // CMAKE_FIND_OTHER_LIBRARY_BUILD
-@@ -282,36 +225,23 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
- !!ENDIF // CMAKE_RELEASE_TYPE
- 
- !!IF !isEmpty(CMAKE_DEBUG_TYPE)
--!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
--    _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" \"\" )
--!!ELSE
-     _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
--!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
- 
- !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
- !!IF isEmpty(CMAKE_RELEASE_TYPE)
--!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
--!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
--!!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
--    if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
--!!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
--        _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" \"\" )
--!!ELSE // CMAKE_STATIC_WINDOWS_BUILD
-     if (EXISTS
- !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
-+        \"@NIX_OUT@/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
- !!ELSE
-         \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
- !!ENDIF
-       AND EXISTS
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
-+        \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
- !!ELSE
-         \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
- !!ENDIF
-         _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
--!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
-     endif()
- !!ENDIF // CMAKE_RELEASE_TYPE
- !!ENDIF // CMAKE_FIND_OTHER_LIBRARY_BUILD
-@@ -328,11 +258,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
-     macro(_populate_$${CMAKE_MODULE_NAME}_plugin_properties Plugin Configuration PLUGIN_LOCATION)
-         set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
- 
--!!IF isEmpty(CMAKE_PLUGIN_DIR_IS_ABSOLUTE)
--        set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
--!!ELSE
--        set(imported_location \"$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
--!!ENDIF
-+        set(imported_location \"${PLUGIN_LOCATION}\")
-         _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
-         set_target_properties(Qt5::${Plugin} PROPERTIES
-             \"IMPORTED_LOCATION_${Configuration}\" ${imported_location}
-Index: qtbase-opensource-src-5.6.1/src/gui/Qt5GuiConfigExtras.cmake.in
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/src/gui/Qt5GuiConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.6.1/src/gui/Qt5GuiConfigExtras.cmake.in
-@@ -2,7 +2,7 @@
- !!IF !isEmpty(CMAKE_ANGLE_EGL_DLL_RELEASE)
- 
- !!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
--set(Qt5Gui_EGL_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR/QtANGLE\")
-+set(Qt5Gui_EGL_INCLUDE_DIRS \"@NIX_DEV@/$$CMAKE_INCLUDE_DIR/QtANGLE\")
- !!ELSE
- set(Qt5Gui_EGL_INCLUDE_DIRS \"$$CMAKE_INCLUDE_DIR/QtANGLE\")
- !!ENDIF
-@@ -17,13 +17,13 @@ macro(_populate_qt5gui_gl_target_propert
-     set_property(TARGET Qt5::${TargetName} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
- 
- !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Gui_install_prefix}/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
-+    set(imported_location \"@NIX_OUT@/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
- !!ELSE
-     set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
- !!ENDIF
- 
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    set(imported_implib \"${_qt5Gui_install_prefix}/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
-+    set(imported_implib \"@NIX_DEV@/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
- !!ELSE
-     set(imported_implib \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
- !!ENDIF
-Index: qtbase-opensource-src-5.6.1/src/widgets/Qt5WidgetsConfigExtras.cmake.in
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/src/widgets/Qt5WidgetsConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.6.1/src/widgets/Qt5WidgetsConfigExtras.cmake.in
-@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::uic)
-     add_executable(Qt5::uic IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Widgets_install_prefix}/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-Index: qtbase-opensource-src-5.6.1/src/corelib/Qt5CoreConfigExtras.cmake.in
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/src/corelib/Qt5CoreConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.6.1/src/corelib/Qt5CoreConfigExtras.cmake.in
-@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::qmake)
-     add_executable(Qt5::qmake IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-@@ -18,7 +18,7 @@ if (NOT TARGET Qt5::moc)
-     add_executable(Qt5::moc IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-@@ -35,7 +35,7 @@ if (NOT TARGET Qt5::rcc)
-     add_executable(Qt5::rcc IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-@@ -131,7 +131,7 @@ if (NOT TARGET Qt5::WinMain)
- !!IF !isEmpty(CMAKE_RELEASE_TYPE)
-     set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
- !!ELSE
-     set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
- !!ENDIF
-@@ -145,7 +145,7 @@ if (NOT TARGET Qt5::WinMain)
-     set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
- 
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
- !!ELSE
-     set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
- !!ENDIF
-Index: qtbase-opensource-src-5.6.1/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
-+++ qtbase-opensource-src-5.6.1/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
-@@ -1,6 +1,6 @@
- 
- !!IF isEmpty(CMAKE_INSTALL_DATA_DIR_IS_ABSOLUTE)
--set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_INSTALL_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
-+set(_qt5_corelib_extra_includes \"@NIX_DEV@/$${CMAKE_INSTALL_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
- !!ELSE
- set(_qt5_corelib_extra_includes \"$${CMAKE_INSTALL_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
- !!ENDIF
-Index: qtbase-opensource-src-5.6.1/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
-+++ qtbase-opensource-src-5.6.1/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
-@@ -1,6 +1,6 @@
- 
- !!IF isEmpty(CMAKE_HOST_DATA_DIR_IS_ABSOLUTE)
--set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_HOST_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
-+set(_qt5_corelib_extra_includes \"@NIX_DEV@/$${CMAKE_HOST_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
- !!ELSE
- set(_qt5_corelib_extra_includes \"$${CMAKE_HOST_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
- !!ENDIF
-Index: qtbase-opensource-src-5.6.1/src/dbus/Qt5DBusConfigExtras.cmake.in
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/src/dbus/Qt5DBusConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.6.1/src/dbus/Qt5DBusConfigExtras.cmake.in
-@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::qdbuscpp2xml)
-     add_executable(Qt5::qdbuscpp2xml IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5DBus_install_prefix}/$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-@@ -18,7 +18,7 @@ if (NOT TARGET Qt5::qdbusxml2cpp)
-     add_executable(Qt5::qdbusxml2cpp IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5DBus_install_prefix}/$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-Index: qtbase-opensource-src-5.6.1/mkspecs/features/create_cmake.prf
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/mkspecs/features/create_cmake.prf
-+++ qtbase-opensource-src-5.6.1/mkspecs/features/create_cmake.prf
-@@ -136,28 +136,28 @@ contains(CONFIG, plugin) {
- 
-     win32 {
-         isEmpty(CMAKE_STATIC_TYPE) {
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.dll
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.dll
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/$${TARGET}.dll
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/$${TARGET}d.dll
-         } else:mingw {
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}.a
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}d.a
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}/$$PLUGIN_TYPE/lib$${TARGET}.a
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}d.a
-         } else {                         # MSVC static
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.lib
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.lib
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/$${TARGET}.lib
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/$${TARGET}d.lib
-         }
-     } else {
-         mac {
-             isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .dylib
-             else: CMAKE_PlUGIN_EXT = .a
- 
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-         } else {
-             isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .so
-             else: CMAKE_PlUGIN_EXT = .a
- 
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-         }
-     }
-     cmake_target_file.input = $$PWD/data/cmake/Qt5PluginTarget.cmake.in
-Index: qtbase-opensource-src-5.6.1/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
-+++ qtbase-opensource-src-5.6.1/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
-@@ -2,10 +2,10 @@
- add_library(Qt5::$$CMAKE_PLUGIN_NAME MODULE IMPORTED)
- 
- !!IF !isEmpty(CMAKE_RELEASE_TYPE)
--_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
-+_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"@NIX_OUT@/$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
- !!ENDIF
- !!IF !isEmpty(CMAKE_DEBUG_TYPE)
--_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
-+_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"@NIX_OUT@/$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
- !!ENDIF
- 
- list(APPEND Qt5$${CMAKE_MODULE_NAME}_PLUGINS Qt5::$$CMAKE_PLUGIN_NAME)
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/compose-search-path.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/compose-search-path.patch
deleted file mode 100644
index 230ca4167dbc..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/compose-search-path.patch
+++ /dev/null
@@ -1,16 +0,0 @@
-Index: qtbase-opensource-src-5.6.0/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
-===================================================================
---- qtbase-opensource-src-5.6.0.orig/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
-+++ qtbase-opensource-src-5.6.0/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
-@@ -251,10 +251,7 @@ void TableGenerator::initPossibleLocatio
-     // the QTCOMPOSE environment variable
-     if (qEnvironmentVariableIsSet("QTCOMPOSE"))
-         m_possibleLocations.append(QString::fromLocal8Bit(qgetenv("QTCOMPOSE")));
--    m_possibleLocations.append(QStringLiteral("/usr/share/X11/locale"));
--    m_possibleLocations.append(QStringLiteral("/usr/local/share/X11/locale"));
--    m_possibleLocations.append(QStringLiteral("/usr/lib/X11/locale"));
--    m_possibleLocations.append(QStringLiteral("/usr/local/lib/X11/locale"));
-+    m_possibleLocations.append(QStringLiteral("${libX11}/share/X11/locale"));
-     m_possibleLocations.append(QStringLiteral(X11_PREFIX "/share/X11/locale"));
-     m_possibleLocations.append(QStringLiteral(X11_PREFIX "/lib/X11/locale"));
- }
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/decrypt-ssl-traffic.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/decrypt-ssl-traffic.patch
deleted file mode 100644
index 495db07cfbb5..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/decrypt-ssl-traffic.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Index: qtbase-opensource-src-5.5.1/src/network/ssl/qsslsocket_openssl.cpp
-===================================================================
---- qtbase-opensource-src-5.5.1.orig/src/network/ssl/qsslsocket_openssl.cpp
-+++ qtbase-opensource-src-5.5.1/src/network/ssl/qsslsocket_openssl.cpp
-@@ -48,7 +48,7 @@
- ****************************************************************************/
- 
- //#define QSSLSOCKET_DEBUG
--//#define QT_DECRYPT_SSL_TRAFFIC
-+#define QT_DECRYPT_SSL_TRAFFIC
- 
- #include "qssl_p.h"
- #include "qsslsocket_openssl_p.h"
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/default.nix b/pkgs/development/libraries/qt-5/5.6/qtbase/default.nix
deleted file mode 100644
index f2e18233d913..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/default.nix
+++ /dev/null
@@ -1,325 +0,0 @@
-{ stdenv, lib, fetchgit, copyPathsToStore
-, srcs, qtCompatVersion
-
-, xlibs, libX11, libxcb, libXcursor, libXext, libXrender, libXi
-, xcbutil, xcbutilimage, xcbutilkeysyms, xcbutilwm, libxkbcommon
-, fontconfig, freetype, harfbuzz
-, openssl, dbus, glib, udev, libxml2, libxslt, pcre16
-, zlib, libjpeg, libpng, libtiff, sqlite, icu
-
-, coreutils, bison, flex, gdb, gperf, lndir
-, patchelf, perl, pkgconfig, python2
-, darwin, libiconv
-
-# optional dependencies
-, cups ? null
-, mysql ? null, postgresql ? null
-
-# options
-, mesaSupported ? (!stdenv.isDarwin)
-, mesa
-, buildExamples ? false
-, buildTests ? false
-, developerBuild ? false
-, decryptSslTraffic ? false
-}:
-
-let
-  system-x86_64 = lib.elem stdenv.system lib.platforms.x86_64;
-in
-
-stdenv.mkDerivation {
-
-  name = "qtbase-${srcs.qtbase.version}";
-  inherit (srcs.qtbase) src version;
-  inherit qtCompatVersion;
-
-  outputs = [ "out" "dev" ];
-
-  patches =
-    copyPathsToStore (lib.readPathsFromFile ./. ./series)
-    ++ [(if stdenv.isDarwin then ./cmake-paths-darwin.patch else ./cmake-paths.patch)]
-    ++ lib.optional decryptSslTraffic ./decrypt-ssl-traffic.patch
-    ++ lib.optionals mesaSupported [ ./dlopen-gl.patch ./mkspecs-libgl.patch ];
-
-  postPatch =
-    ''
-      substituteInPlace configure --replace /bin/pwd pwd
-      substituteInPlace src/corelib/global/global.pri --replace /bin/ls ${coreutils}/bin/ls
-      sed -e 's@/\(usr\|opt\)/@/var/empty/@g' -i config.tests/*/*.test -i mkspecs/*/*.conf
-
-      sed -i 's/PATHS.*NO_DEFAULT_PATH//' "src/corelib/Qt5Config.cmake.in"
-      sed -i 's/PATHS.*NO_DEFAULT_PATH//' "src/corelib/Qt5CoreMacros.cmake"
-      sed -i 's/NO_DEFAULT_PATH//' "src/gui/Qt5GuiConfigExtras.cmake.in"
-      sed -i 's/PATHS.*NO_DEFAULT_PATH//' "mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in"
-
-      substituteInPlace src/network/kernel/qdnslookup_unix.cpp \
-        --replace "@glibc@" "${stdenv.cc.libc.out}"
-      substituteInPlace src/network/kernel/qhostinfo_unix.cpp \
-        --replace "@glibc@" "${stdenv.cc.libc.out}"
-
-      substituteInPlace src/network/ssl/qsslsocket_openssl_symbols.cpp \
-        --replace "@openssl@" "${openssl.out}"
-    '' + lib.optionalString stdenv.isLinux ''
-      substituteInPlace src/plugins/platforms/xcb/qxcbcursor.cpp \
-        --replace "@libXcursor@" "${libXcursor.out}"
-
-      substituteInPlace src/dbus/qdbus_symbols.cpp \
-        --replace "@dbus_libs@" "${dbus.lib}"
-
-      substituteInPlace \
-        src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp \
-        --replace "@libX11@" "${libX11.out}"
-    '' + lib.optionalString mesaSupported ''
-      substituteInPlace \
-        src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp \
-        --replace "@mesa_lib@" "${mesa.out}"
-      substituteInPlace mkspecs/common/linux.conf \
-        --replace "@mesa_lib@" "${mesa.out}" \
-        --replace "@mesa_inc@" "${mesa.dev or mesa}"
-    '' + lib.optionalString stdenv.isDarwin ''
-      sed -i \
-          -e 's|! /usr/bin/xcode-select --print-path >/dev/null 2>&1;|false;|' \
-          -e 's|! /usr/bin/xcrun -find xcodebuild >/dev/null 2>&1;|false;|' \
-          -e 's|sysroot=$(/usr/bin/xcodebuild -sdk $sdk -version Path 2>/dev/null)|sysroot=/nonsense|' \
-          -e 's|QMAKE_CONF_COMPILER=`getXQMakeConf QMAKE_CXX`|QMAKE_CXX="clang++"\nQMAKE_CONF_COMPILER="clang++"|' \
-          -e 's|XCRUN=`/usr/bin/xcrun -sdk macosx clang -v 2>&1`|XCRUN="clang -v 2>&1"|' \
-          -e 's#sdk_val=$(/usr/bin/xcrun -sdk $sdk -find $(echo $val | cut -d \x27 \x27 -f 1))##' \
-          -e 's#val=$(echo $sdk_val $(echo $val | cut -s -d \x27 \x27 -f 2-))##' \
-          ./configure
-      sed -i '3,$d' ./mkspecs/features/mac/default_pre.prf
-      sed -i '26,$d' ./mkspecs/features/mac/default_post.prf
-      sed -i '1,$d' ./mkspecs/features/mac/sdk.prf
-      sed 's/QMAKE_LFLAGS_RPATH      = -Wl,-rpath,/QMAKE_LFLAGS_RPATH      =/' -i ./mkspecs/common/mac.conf
-    '';
-    # Note on the above: \x27 is a way if including a single-quote
-    # character in the sed string arguments.
-
-  qtPluginPrefix = "lib/qt-${qtCompatVersion}/plugins";
-  qtQmlPrefix = "lib/qt-${qtCompatVersion}/qml";
-  qtDocPrefix = "share/doc/qt-${qtCompatVersion}";
-
-  setOutputFlags = false;
-  preConfigure = ''
-    export LD_LIBRARY_PATH="$PWD/lib:$PWD/plugins/platforms:$LD_LIBRARY_PATH"
-    export MAKEFLAGS=-j$NIX_BUILD_CORES
-    # We need to set LD to CXX or otherwise we get nasty compile errors
-    export LD=$CXX
-
-    configureFlags+="\
-        -plugindir $out/$qtPluginPrefix \
-        -qmldir $out/$qtQmlPrefix \
-        -docdir $out/$qtDocPrefix"
-
-    NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QT_PLUGIN_PREFIX=\"$qtPluginPrefix\""
-    NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QPA_PLATFORM_PLUGIN_PATH=\"''${!outputLib}/$qtPluginPrefix/platforms\""
-
-    unset LD
-  '';
-
-  prefixKey = "-prefix ";
-
-  # -no-eglfs, -no-directfb, -no-linuxfb and -no-kms because of the current minimalist mesa
-  # TODO Remove obsolete and useless flags once the build will be totally mastered
-  configureFlags = ''
-    -verbose
-    -confirm-license
-    -opensource
-
-    -release
-    -shared
-    -c++11
-    ${lib.optionalString developerBuild "-developer-build"}
-    -largefile
-    -accessibility
-    -optimized-qmake
-    -strip
-    -no-reduce-relocations
-    -system-proxies
-    -pkg-config
-
-    -gui
-    -widgets
-    -opengl desktop
-    -qml-debug
-    -iconv
-    -icu
-    -pch
-
-    ${lib.optionalString (!system-x86_64) "-no-sse2"}
-    -no-sse3
-    -no-ssse3
-    -no-sse4.1
-    -no-sse4.2
-    -no-avx
-    -no-avx2
-    -no-mips_dsp
-    -no-mips_dspr2
-
-    -system-zlib
-    -system-libpng
-    -system-libjpeg
-    -system-harfbuzz
-    -system-pcre
-    -openssl-linked
-
-    -system-sqlite
-    -${if mysql != null then "plugin" else "no"}-sql-mysql
-    -${if postgresql != null then "plugin" else "no"}-sql-psql
-
-    -make libs
-    -make tools
-    -${lib.optionalString (buildExamples == false) "no"}make examples
-    -${lib.optionalString (buildTests == false) "no"}make tests
-  '' + lib.optionalString (!stdenv.isDarwin) ''
-    -no-rpath
-    -glib
-    -xcb
-    -qpa xcb
-
-    -${lib.optionalString (cups == null) "no-"}cups
-
-    -no-eglfs
-    -no-directfb
-    -no-linuxfb
-    -no-kms
-
-    -system-xcb
-    -system-xkbcommon
-    -dbus-linked
-  '' + lib.optionalString stdenv.isDarwin ''
-    -platform macx-clang
-    -no-use-gold-linker
-    -no-fontconfig
-    -qt-freetype
-  '';
-
-  # PostgreSQL autodetection fails sporadically because Qt omits the "-lpq" flag
-  # if dependency paths contain the string "pq", which can occur in the hash.
-  # To prevent these failures, we need to override PostgreSQL detection.
-  PSQL_LIBS = lib.optionalString (postgresql != null) "-L${postgresql.lib}/lib -lpq";
-
-  propagatedBuildInputs = [
-    libxml2 libxslt openssl pcre16 sqlite zlib
-
-    # Text rendering
-    harfbuzz icu
-
-    # Image formats
-    libjpeg libpng libtiff
-  ]
-  ++ lib.optional mesaSupported mesa
-  ++ lib.optionals (!stdenv.isDarwin) [
-    dbus glib udev
-
-    # Text rendering
-    fontconfig freetype
-    # X11 libs
-    xlibs.libXcomposite libX11 libxcb libXext libXrender libXi
-    xcbutil xcbutilimage xcbutilkeysyms xcbutilwm libxkbcommon
-  ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
-    ApplicationServices CoreServices AppKit Carbon OpenGL AGL Cocoa
-    DiskArbitration darwin.cf-private libiconv
-  ]);
-
-  buildInputs =
-    [ bison flex gperf ]
-    ++ lib.optional developerBuild gdb
-    ++ lib.optional (cups != null) cups
-    ++ lib.optional (mysql != null) mysql.lib
-    ++ lib.optional (postgresql != null) postgresql;
-
-  nativeBuildInputs = [ lndir perl pkgconfig python2 ] ++ lib.optional (!stdenv.isDarwin) patchelf;
-
-  # freetype-2.5.4 changed signedness of some struct fields
-  NIX_CFLAGS_COMPILE = "-Wno-error=sign-compare"
-    + lib.optionalString stdenv.isDarwin " -D__MAC_OS_X_VERSION_MAX_ALLOWED=1090 -D__AVAILABILITY_INTERNAL__MAC_10_10=__attribute__((availability(macosx,introduced=10.10)))";
-  # Note that nixpkgs's objc4 is from macOS 10.11 while the SDK is
-  # 10.9 which necessitates the above macro definition that mentions
-  # 10.10
-
-  postInstall = ''
-    find "$out" -name "*.cmake" | while read file; do
-        substituteInPlace "$file" \
-            --subst-var-by NIX_OUT "''${!outputLib}" \
-            --subst-var-by NIX_DEV "''${!outputDev}" \
-            --subst-var-by NIX_BIN "''${!outputBin}"
-    done
-  '';
-
-  preFixup = ''
-    # We cannot simply set these paths in configureFlags because libQtCore retains
-    # references to the paths it was built with.
-    moveToOutput "bin" "$dev"
-    moveToOutput "include" "$dev"
-    moveToOutput "mkspecs" "$dev"
-
-    # The destination directory must exist or moveToOutput will do nothing
-    mkdir -p "$dev/share"
-    moveToOutput "share/doc" "$dev"
-  '';
-
-  # Don't move .prl files on darwin because they end up in
-  # "dev/lib/Foo.framework/Foo.prl" which interferes with subsequent
-  # use of lndir in the qtbase setup-hook. On Linux, the .prl files
-  # are in lib, and so do not cause a subsequent recreation of deep
-  # framework directory trees.
-  postFixup =
-    ''
-      # Don't retain build-time dependencies like gdb.
-      sed '/QMAKE_DEFAULT_.*DIRS/ d' -i $dev/mkspecs/qconfig.pri
-
-      # Move libtool archives and qmake projects
-      if [ "z''${!outputLib}" != "z''${!outputDev}" ]; then
-          pushd "''${!outputLib}"
-          find lib -name '*.a' -o -name '*.la'${if stdenv.isDarwin then "" else "-o -name '*.prl'"} | \
-              while read -r file; do
-                  mkdir -p "''${!outputDev}/$(dirname "$file")"
-                  mv "''${!outputLib}/$file" "''${!outputDev}/$file"
-              done
-          popd
-      fi
-    ''
-
-    # fixup .pc file (where to find 'moc' etc.)
-    + lib.optionalString (!stdenv.isDarwin) ''
-      sed -i "$dev/lib/pkgconfig/Qt5Core.pc" \
-          -e "/^host_bins=/ c host_bins=$dev/bin"
-    ''
-
-    # Don't move .prl files on darwin because they end up in
-    # "dev/lib/Foo.framework/Foo.prl" which interferes with subsequent
-    # use of lndir in the qtbase setup-hook. On Linux, the .prl files
-    # are in lib, and so do not cause a subsequent recreation of deep
-    # framework directory trees.
-    + lib.optionalString stdenv.isDarwin ''
-      fixDarwinDylibNames_rpath() {
-        local flags=()
-
-        for fn in "$@"; do
-          flags+=(-change "@rpath/$fn.framework/Versions/5/$fn" "$out/lib/$fn.framework/Versions/5/$fn")
-        done
-
-        for fn in "$@"; do
-          echo "$fn: fixing dylib"
-          install_name_tool -id "$out/lib/$fn.framework/Versions/5/$fn" "''${flags[@]}" "$out/lib/$fn.framework/Versions/5/$fn"
-        done
-      }
-      fixDarwinDylibNames_rpath "QtConcurrent" "QtPrintSupport" "QtCore" "QtSql" "QtDBus" "QtTest" "QtGui" "QtWidgets" "QtNetwork" "QtXml" "QtOpenGL"
-    '';
-
-  inherit lndir;
-  setupHook = if stdenv.isDarwin
-              then ../../qtbase-setup-hook-darwin.sh
-              else ../../qtbase-setup-hook.sh;
-
-  enableParallelBuilding = true;
-
-  meta = with lib; {
-    homepage = http://www.qt.io;
-    description = "A cross-platform application framework for C++";
-    license = with licenses; [ fdl13 gpl2 lgpl21 lgpl3 ];
-    maintainers = with maintainers; [ qknight ttuegel ];
-    platforms = platforms.unix;
-  };
-}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-dbus.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-dbus.patch
deleted file mode 100644
index 2bc526a72bd7..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-dbus.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Index: qtbase-opensource-src-5.6.1/src/dbus/qdbus_symbols.cpp
-===================================================================
---- qtbase-opensource-src-5.6.1.orig/src/dbus/qdbus_symbols.cpp
-+++ qtbase-opensource-src-5.6.1/src/dbus/qdbus_symbols.cpp
-@@ -90,7 +90,7 @@ bool qdbus_loadLibDBus()
- #ifdef Q_OS_WIN
-         QLatin1String("dbus-1"),
- #endif
--        QLatin1String("libdbus-1")
-+        QLatin1String("@dbus_libs@/lib/libdbus-1")
-     };
- 
-     lib->unload();
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-gl.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-gl.patch
deleted file mode 100644
index ea3073ced50a..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-gl.patch
+++ /dev/null
@@ -1,17 +0,0 @@
-Index: qtbase-opensource-src-5.5.1/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
-===================================================================
---- qtbase-opensource-src-5.5.1.orig/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
-+++ qtbase-opensource-src-5.5.1/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
-@@ -563,7 +563,12 @@ void (*QGLXContext::getProcAddress(const
-             {
-                 extern const QString qt_gl_library_name();
- //                QLibrary lib(qt_gl_library_name());
-+                // Check system library paths first
-                 QLibrary lib(QLatin1String("GL"));
-+                if (!lib.load()) {
-+                    // Fallback to Mesa driver
-+                    lib.setFileName(QLatin1String("@mesa_lib@/lib/libGL"));
-+                }
-                 glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB");
-             }
-         }
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-libXcursor.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-libXcursor.patch
deleted file mode 100644
index 3e2e8ab349d3..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-libXcursor.patch
+++ /dev/null
@@ -1,17 +0,0 @@
-Index: qtbase-opensource-src-5.6.0/src/plugins/platforms/xcb/qxcbcursor.cpp
-===================================================================
---- qtbase-opensource-src-5.6.0.orig/src/plugins/platforms/xcb/qxcbcursor.cpp
-+++ qtbase-opensource-src-5.6.0/src/plugins/platforms/xcb/qxcbcursor.cpp
-@@ -303,10 +303,10 @@ QXcbCursor::QXcbCursor(QXcbConnection *c
- #if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY)
-     static bool function_ptrs_not_initialized = true;
-     if (function_ptrs_not_initialized) {
--        QLibrary xcursorLib(QLatin1String("Xcursor"), 1);
-+        QLibrary xcursorLib(QLatin1String("@libXcursor@/lib/libXcursor"), 1);
-         bool xcursorFound = xcursorLib.load();
-         if (!xcursorFound) { // try without the version number
--            xcursorLib.setFileName(QLatin1String("Xcursor"));
-+            xcursorLib.setFileName(QLatin1String("@libXcursor@/lib/Xcursor"));
-             xcursorFound = xcursorLib.load();
-         }
-         if (xcursorFound) {
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-openssl.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-openssl.patch
deleted file mode 100644
index 1d97aad94065..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-openssl.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-Index: qtbase-opensource-src-5.6.0/src/network/ssl/qsslsocket_openssl_symbols.cpp
-===================================================================
---- qtbase-opensource-src-5.6.0.orig/src/network/ssl/qsslsocket_openssl_symbols.cpp
-+++ qtbase-opensource-src-5.6.0/src/network/ssl/qsslsocket_openssl_symbols.cpp
-@@ -652,8 +652,8 @@ static QPair<QLibrary*, QLibrary*> loadO
- #endif
- #if defined(SHLIB_VERSION_NUMBER) && !defined(Q_OS_QNX) // on QNX, the libs are always libssl.so and libcrypto.so
-     // first attempt: the canonical name is libssl.so.<SHLIB_VERSION_NUMBER>
--    libssl->setFileNameAndVersion(QLatin1String("ssl"), QLatin1String(SHLIB_VERSION_NUMBER));
--    libcrypto->setFileNameAndVersion(QLatin1String("crypto"), QLatin1String(SHLIB_VERSION_NUMBER));
-+    libssl->setFileNameAndVersion(QLatin1String("@openssl@/lib/libssl"), QLatin1String(SHLIB_VERSION_NUMBER));
-+    libcrypto->setFileNameAndVersion(QLatin1String("@openssl@/lib/libcrypto"), QLatin1String(SHLIB_VERSION_NUMBER));
-     if (libcrypto->load() && libssl->load()) {
-         // libssl.so.<SHLIB_VERSION_NUMBER> and libcrypto.so.<SHLIB_VERSION_NUMBER> found
-         return pair;
-@@ -670,8 +670,8 @@ static QPair<QLibrary*, QLibrary*> loadO
-     //  OS X's /usr/lib/libssl.dylib, /usr/lib/libcrypto.dylib will be picked up in the third
-     //    attempt, _after_ <bundle>/Contents/Frameworks has been searched.
-     //  iOS does not ship a system libssl.dylib, libcrypto.dylib in the first place.
--    libssl->setFileNameAndVersion(QLatin1String("ssl"), -1);
--    libcrypto->setFileNameAndVersion(QLatin1String("crypto"), -1);
-+    libssl->setFileNameAndVersion(QLatin1String("@openssl@/lib/libssl"), -1);
-+    libcrypto->setFileNameAndVersion(QLatin1String("@openssl@/lib/libcrypto"), -1);
-     if (libcrypto->load() && libssl->load()) {
-         // libssl.so.0 and libcrypto.so.0 found
-         return pair;
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-resolv.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-resolv.patch
deleted file mode 100644
index e9d3c2734d1e..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-resolv.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-Index: qtbase-opensource-src-5.6.2/src/network/kernel/qdnslookup_unix.cpp
-===================================================================
---- qtbase-opensource-src-5.6.2.orig/src/network/kernel/qdnslookup_unix.cpp
-+++ qtbase-opensource-src-5.6.2/src/network/kernel/qdnslookup_unix.cpp
-@@ -83,7 +83,7 @@ static bool resolveLibraryInternal()
-     if (!lib.load())
- #endif
-     {
--        lib.setFileName(QLatin1String("resolv"));
-+        lib.setFileName(QLatin1String("@glibc@/lib/resolv"));
-         if (!lib.load())
-             return false;
-     }
-Index: qtbase-opensource-src-5.6.2/src/network/kernel/qhostinfo_unix.cpp
-===================================================================
---- qtbase-opensource-src-5.6.2.orig/src/network/kernel/qhostinfo_unix.cpp
-+++ qtbase-opensource-src-5.6.2/src/network/kernel/qhostinfo_unix.cpp
-@@ -94,7 +94,7 @@ static bool resolveLibraryInternal()
-     if (!lib.load())
- #endif
-     {
--        lib.setFileName(QLatin1String("resolv"));
-+        lib.setFileName(QLatin1String("@glibc@/lib/libresolv"));
-         if (!lib.load())
-             return false;
-     }
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/library-paths.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/library-paths.patch
deleted file mode 100644
index fecbce59050d..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/library-paths.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-Index: qtbase-opensource-src-5.6.2/src/corelib/kernel/qcoreapplication.cpp
-===================================================================
---- qtbase-opensource-src-5.6.2.orig/src/corelib/kernel/qcoreapplication.cpp
-+++ qtbase-opensource-src-5.6.2/src/corelib/kernel/qcoreapplication.cpp
-@@ -2533,6 +2533,15 @@ QStringList QCoreApplication::libraryPat
-         QStringList *app_libpaths = new QStringList;
-         coreappdata()->app_libpaths.reset(app_libpaths);
- 
-+        // Add library paths derived from PATH
-+        const QStringList paths = QFile::decodeName(qgetenv("PATH")).split(':');
-+        const QString plugindir = QStringLiteral("../" NIXPKGS_QT_PLUGIN_PREFIX);
-+        for (const QString &path: paths) {
-+            if (!path.isEmpty()) {
-+                app_libpaths->append(QDir::cleanPath(path + QDir::separator() + plugindir));
-+            }
-+        }
-+
-         const QByteArray libPathEnv = qgetenv("QT_PLUGIN_PATH");
-         if (!libPathEnv.isEmpty()) {
-             QStringList paths = QFile::decodeName(libPathEnv).split(QDir::listSeparator(), QString::SkipEmptyParts);
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/libressl.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/libressl.patch
deleted file mode 100644
index c721a6be7470..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/libressl.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From 81494e67eccba04fc3fe554d76a9ca6fe7f2250e Mon Sep 17 00:00:00 2001
-From: hasufell <hasufell@gentoo.org>
-Date: Sat, 10 Oct 2015 01:15:01 +0200
-Subject: [PATCH] Fix compilation with libressl
-
-By additionally checking for defined(SSL_CTRL_SET_CURVES), which
-is defined in openssl, but not in libressl.
----
- src/network/ssl/qsslcontext_openssl.cpp | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-Index: qtbase-opensource-src-5.6.0/src/network/ssl/qsslcontext_openssl.cpp
-===================================================================
---- qtbase-opensource-src-5.6.0.orig/src/network/ssl/qsslcontext_openssl.cpp
-+++ qtbase-opensource-src-5.6.0/src/network/ssl/qsslcontext_openssl.cpp
-@@ -340,7 +340,7 @@ init_context:
- 
-     const QVector<QSslEllipticCurve> qcurves = sslContext->sslConfiguration.ellipticCurves();
-     if (!qcurves.isEmpty()) {
--#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_EC)
-+#if OPENSSL_VERSION_NUMBER >= 0x10002000L && defined(SSL_CTRL_SET_CURVES) && !defined(OPENSSL_NO_EC)
-         // Set the curves to be used
-         if (q_SSLeay() >= 0x10002000L) {
-             // SSL_CTX_ctrl wants a non-const pointer as last argument,
-@@ -354,7 +354,7 @@ init_context:
-                 return sslContext;
-             }
-         } else
--#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_EC)
-+#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L && defined(SSL_CTRL_SET_CURVES) && !defined(OPENSSL_NO_EC)
-         {
-             // specific curves requested, but not possible to set -> error
-             sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocket::tr("OpenSSL version too old, need at least v1.0.2"));
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/mkspecs-libgl.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/mkspecs-libgl.patch
deleted file mode 100644
index fda3d3e36533..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/mkspecs-libgl.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-Index: qtbase-opensource-src-5.5.1/mkspecs/common/linux.conf
-===================================================================
---- qtbase-opensource-src-5.5.1.orig/mkspecs/common/linux.conf
-+++ qtbase-opensource-src-5.5.1/mkspecs/common/linux.conf
-@@ -12,8 +12,8 @@ QMAKE_INCDIR            =
- QMAKE_LIBDIR            =
- QMAKE_INCDIR_X11        =
- QMAKE_LIBDIR_X11        =
--QMAKE_INCDIR_OPENGL     =
--QMAKE_LIBDIR_OPENGL     =
-+QMAKE_INCDIR_OPENGL     = @mesa_inc@/include
-+QMAKE_LIBDIR_OPENGL     = @mesa_lib@/lib
- QMAKE_INCDIR_OPENGL_ES2 = $$QMAKE_INCDIR_OPENGL
- QMAKE_LIBDIR_OPENGL_ES2 = $$QMAKE_LIBDIR_OPENGL
- QMAKE_INCDIR_EGL        =
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/qpa-platform-plugin-path.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/qpa-platform-plugin-path.patch
deleted file mode 100644
index 32d9dcad622d..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/qpa-platform-plugin-path.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-Index: qtbase-opensource-src-5.6.2/src/gui/kernel/qplatformintegrationfactory.cpp
-===================================================================
---- qtbase-opensource-src-5.6.2.orig/src/gui/kernel/qplatformintegrationfactory.cpp
-+++ qtbase-opensource-src-5.6.2/src/gui/kernel/qplatformintegrationfactory.cpp
-@@ -67,9 +67,10 @@ QPlatformIntegration *QPlatformIntegrati
-     // Try loading the plugin from platformPluginPath first:
-     if (!platformPluginPath.isEmpty()) {
-         QCoreApplication::addLibraryPath(platformPluginPath);
--        if (QPlatformIntegration *ret = loadIntegration(directLoader(), platform, paramList, argc, argv))
--            return ret;
-     }
-+    QCoreApplication::addLibraryPath(QStringLiteral(NIXPKGS_QPA_PLATFORM_PLUGIN_PATH));
-+    if (QPlatformIntegration *ret = loadIntegration(directLoader(), platform, paramList, argc, argv))
-+        return ret;
-     if (QPlatformIntegration *ret = loadIntegration(loader(), platform, paramList, argc, argv))
-         return ret;
- #else
-@@ -95,15 +96,16 @@ QStringList QPlatformIntegrationFactory:
-     QStringList list;
-     if (!platformPluginPath.isEmpty()) {
-         QCoreApplication::addLibraryPath(platformPluginPath);
--        list = directLoader()->keyMap().values();
--        if (!list.isEmpty()) {
--            const QString postFix = QStringLiteral(" (from ")
--                                    + QDir::toNativeSeparators(platformPluginPath)
--                                    + QLatin1Char(')');
--            const QStringList::iterator end = list.end();
--            for (QStringList::iterator it = list.begin(); it != end; ++it)
--                (*it).append(postFix);
--        }
-+    }
-+    QCoreApplication::addLibraryPath(QStringLiteral(NIXPKGS_QPA_PLATFORM_PLUGIN_PATH));
-+    list = directLoader()->keyMap().values();
-+    if (!list.isEmpty()) {
-+        const QString postFix = QStringLiteral(" (from ")
-+            + QDir::toNativeSeparators(platformPluginPath)
-+            + QLatin1Char(')');
-+        const QStringList::iterator end = list.end();
-+        for (QStringList::iterator it = list.begin(); it != end; ++it)
-+            (*it).append(postFix);
-     }
-     list.append(loader()->keyMap().values());
-     return list;
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/series b/pkgs/development/libraries/qt-5/5.6/qtbase/series
deleted file mode 100644
index bacb3a4ed899..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/series
+++ /dev/null
@@ -1,9 +0,0 @@
-dlopen-resolv.patch
-tzdir.patch
-dlopen-libXcursor.patch
-dlopen-openssl.patch
-dlopen-dbus.patch
-xdg-config-dirs.patch
-library-paths.patch
-compose-search-path.patch
-libressl.patch
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/tzdir.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/tzdir.patch
deleted file mode 100644
index f197211ded7b..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/tzdir.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-Index: qtbase-opensource-src-5.6.2/src/corelib/tools/qtimezoneprivate_tz.cpp
-===================================================================
---- qtbase-opensource-src-5.6.2.orig/src/corelib/tools/qtimezoneprivate_tz.cpp
-+++ qtbase-opensource-src-5.6.2/src/corelib/tools/qtimezoneprivate_tz.cpp
-@@ -64,7 +64,10 @@ typedef QHash<QByteArray, QTzTimeZone> Q
- // Parse zone.tab table, assume lists all installed zones, if not will need to read directories
- static QTzTimeZoneHash loadTzTimeZones()
- {
--    QString path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
-+    QString path = qgetenv("TZDIR");
-+    path += "/zone.tab";
-+    if (!QFile::exists(path))
-+        path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
-     if (!QFile::exists(path))
-         path = QStringLiteral("/usr/lib/zoneinfo/zone.tab");
- 
-@@ -636,12 +639,18 @@ void QTzTimeZonePrivate::init(const QByt
-         if (!tzif.open(QIODevice::ReadOnly))
-             return;
-     } else {
--        // Open named tz, try modern path first, if fails try legacy path
--        tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
-+        // Try TZDIR first
-+        QString zoneinfoDir = qgetenv("TZDIR");
-+        zoneinfoDir += "/" + QString::fromLocal8Bit(ianaId);
-+        tzif.setFileName(zoneinfoDir);
-         if (!tzif.open(QIODevice::ReadOnly)) {
--            tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
--            if (!tzif.open(QIODevice::ReadOnly))
--                return;
-+            // Open named tz, try modern path first, if fails try legacy path
-+            tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
-+            if (!tzif.open(QIODevice::ReadOnly)) {
-+                tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
-+                if (!tzif.open(QIODevice::ReadOnly))
-+                    return;
-+            }
-         }
-     }
- 
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/xdg-config-dirs.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/xdg-config-dirs.patch
deleted file mode 100644
index 8756cbe9f5f0..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/xdg-config-dirs.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-Index: qtbase-opensource-src-5.6.0/src/corelib/io/qsettings.cpp
-===================================================================
---- qtbase-opensource-src-5.6.0.orig/src/corelib/io/qsettings.cpp
-+++ qtbase-opensource-src-5.6.0/src/corelib/io/qsettings.cpp
-@@ -1155,6 +1155,24 @@ QConfFileSettingsPrivate::QConfFileSetti
-     if (!application.isEmpty())
-         confFiles[F_System | F_Application].reset(QConfFile::fromName(systemPath + appFile, false));
-     confFiles[F_System | F_Organization].reset(QConfFile::fromName(systemPath + orgFile, false));
-+
-+#if !defined(Q_OS_WIN)
-+    // Add directories specified in $XDG_CONFIG_DIRS
-+    const QString pathEnv = QString::fromLocal8Bit(getenv("XDG_CONFIG_DIRS"));
-+    if (!pathEnv.isEmpty()) {
-+        const QStringList pathEntries = pathEnv.split(QLatin1Char(':'), QString::SkipEmptyParts);
-+        if (!pathEntries.isEmpty()) {
-+            int j = 4; // This is the number of confFiles set above -- we need to start adding $XDG_CONFIG_DIRS after those.
-+            for (int k = 0; k < pathEntries.size() && j < NumConfFiles - 1; ++k) {
-+                const QString& path = pathEntries.at(k);
-+                if (!application.isEmpty())
-+                    confFiles[j++].reset(QConfFile::fromName(path + QDir::separator() + appFile, false));
-+                confFiles[j++].reset(QConfFile::fromName(path + QDir::separator() + orgFile, false));
-+            }
-+        }
-+    }
-+#endif
-+
- #else
-     QString confName = getPath(format, QSettings::UserScope) + org;
-     if (!application.isEmpty())
-Index: qtbase-opensource-src-5.6.0/src/corelib/io/qsettings_p.h
-===================================================================
---- qtbase-opensource-src-5.6.0.orig/src/corelib/io/qsettings_p.h
-+++ qtbase-opensource-src-5.6.0/src/corelib/io/qsettings_p.h
-@@ -241,7 +241,7 @@ public:
-         F_Organization = 0x1,
-         F_User = 0x0,
-         F_System = 0x2,
--        NumConfFiles = 4
-+        NumConfFiles = 40 // HACK: increase NumConfFiles from 4 to 40 in order to accommodate more paths in $XDG_CONFIG_DIRS -- ellis
- #else
-         SandboxConfFile = 0,
-         NumConfFiles = 1
diff --git a/pkgs/development/libraries/qt-5/5.6/qtconnectivity.nix b/pkgs/development/libraries/qt-5/5.6/qtconnectivity.nix
deleted file mode 100644
index 95cd6fea79b4..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtconnectivity.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ qtSubmodule, qtbase, qtdeclarative }:
-
-qtSubmodule {
-  name = "qtconnectivity";
-  qtInputs = [ qtbase qtdeclarative ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtdeclarative/import-paths.patch b/pkgs/development/libraries/qt-5/5.6/qtdeclarative.patch
index d50ee823a78b..dbddaa2a1d60 100644
--- a/pkgs/development/libraries/qt-5/5.9/qtdeclarative/import-paths.patch
+++ b/pkgs/development/libraries/qt-5/5.6/qtdeclarative.patch
@@ -1,8 +1,8 @@
-Index: qtdeclarative-opensource-src-5.8.0/src/qml/qml/qqmlimport.cpp
-===================================================================
---- qtdeclarative-opensource-src-5.8.0.orig/src/qml/qml/qqmlimport.cpp
-+++ qtdeclarative-opensource-src-5.8.0/src/qml/qml/qqmlimport.cpp
-@@ -1630,6 +1630,15 @@ QQmlImportDatabase::QQmlImportDatabase(Q
+diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
+index dfdf2edbe..7ee96049d 100644
+--- a/src/qml/qml/qqmlimport.cpp
++++ b/src/qml/qml/qqmlimport.cpp
+@@ -1568,6 +1568,15 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e)
      QString installImportsPath =  QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
      addImportPath(installImportsPath);
  
diff --git a/pkgs/development/libraries/qt-5/5.6/qtdeclarative/default.nix b/pkgs/development/libraries/qt-5/5.6/qtdeclarative/default.nix
deleted file mode 100644
index 57b8e53b215c..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtdeclarative/default.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-{ qtSubmodule, lib, copyPathsToStore, python2, qtbase, qtsvg, qtxmlpatterns }:
-
-qtSubmodule {
-  name = "qtdeclarative";
-  patches = copyPathsToStore (lib.readPathsFromFile ./. ./series);
-  qtInputs = [ qtbase qtsvg qtxmlpatterns ];
-  nativeBuildInputs = [ python2 ];
-
-  preConfigure = ''
-    NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QML2_IMPORT_PREFIX=\"$qtQmlPrefix\""
-  '';
-}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtdeclarative/import-paths.patch b/pkgs/development/libraries/qt-5/5.6/qtdeclarative/import-paths.patch
deleted file mode 100644
index a942d837c305..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtdeclarative/import-paths.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-Index: qtdeclarative-opensource-src-5.6.2/src/qml/qml/qqmlimport.cpp
-===================================================================
---- qtdeclarative-opensource-src-5.6.2.orig/src/qml/qml/qqmlimport.cpp
-+++ qtdeclarative-opensource-src-5.6.2/src/qml/qml/qqmlimport.cpp
-@@ -1568,6 +1568,15 @@ QQmlImportDatabase::QQmlImportDatabase(Q
-     QString installImportsPath =  QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
-     addImportPath(installImportsPath);
- 
-+    // Add import paths derived from PATH
-+    const QStringList paths = QFile::decodeName(qgetenv("PATH")).split(':');
-+    const QString qmldir = QStringLiteral("../" NIXPKGS_QML2_IMPORT_PREFIX);
-+    for (const QString &path: paths) {
-+        if (!path.isEmpty()) {
-+            addImportPath(QDir::cleanPath(path + QDir::separator() + qmldir));
-+        }
-+    }
-+
-     // env import paths
-     if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QML2_IMPORT_PATH"))) {
-         const QByteArray envImportPath = qgetenv("QML2_IMPORT_PATH");
diff --git a/pkgs/development/libraries/qt-5/5.6/qtdeclarative/series b/pkgs/development/libraries/qt-5/5.6/qtdeclarative/series
deleted file mode 100644
index 38abb916a508..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtdeclarative/series
+++ /dev/null
@@ -1 +0,0 @@
-import-paths.patch
diff --git a/pkgs/development/libraries/qt-5/5.6/qtdoc.nix b/pkgs/development/libraries/qt-5/5.6/qtdoc.nix
deleted file mode 100644
index 578ea6ba0b22..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtdoc.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ qtSubmodule, qtdeclarative }:
-
-qtSubmodule {
-  name = "qtdoc";
-  qtInputs = [ qtdeclarative ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtenginio.nix b/pkgs/development/libraries/qt-5/5.6/qtenginio.nix
deleted file mode 100644
index b860a73ef890..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtenginio.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ qtSubmodule, qtdeclarative }:
-
-qtSubmodule {
-  name = "qtenginio";
-  qtInputs = [ qtdeclarative ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtlocation.nix b/pkgs/development/libraries/qt-5/5.6/qtlocation.nix
deleted file mode 100644
index 1e134057c4b4..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtlocation.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ qtSubmodule, qtbase, qtmultimedia }:
-
-qtSubmodule {
-  name = "qtlocation";
-  qtInputs = [ qtbase qtmultimedia ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtmultimedia.nix b/pkgs/development/libraries/qt-5/5.6/qtmultimedia.nix
deleted file mode 100644
index 20e6e364799f..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtmultimedia.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-{ qtSubmodule, qtbase, qtdeclarative, pkgconfig
-, alsaLib, gstreamer, gst-plugins-base, libpulseaudio
-}:
-
-qtSubmodule {
-  name = "qtmultimedia";
-  qtInputs = [ qtbase qtdeclarative ];
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [
-    alsaLib gstreamer gst-plugins-base libpulseaudio
-  ];
-  qmakeFlags = [ "GST_VERSION=1.0" ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtquickcontrols.nix b/pkgs/development/libraries/qt-5/5.6/qtquickcontrols.nix
deleted file mode 100644
index 93a864621b82..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtquickcontrols.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ qtSubmodule, qtdeclarative }:
-
-qtSubmodule {
-  name = "qtquickcontrols";
-  qtInputs = [ qtdeclarative ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtquickcontrols2.nix b/pkgs/development/libraries/qt-5/5.6/qtquickcontrols2.nix
deleted file mode 100644
index 19750f2fd99d..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtquickcontrols2.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ qtSubmodule, qtdeclarative }:
-
-qtSubmodule {
-  name = "qtquickcontrols2";
-  qtInputs = [ qtdeclarative ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtscript/0001-glib-2.32.patch b/pkgs/development/libraries/qt-5/5.6/qtscript.patch
index 887e107b6c1b..5508dec1280e 100644
--- a/pkgs/development/libraries/qt-5/5.9/qtscript/0001-glib-2.32.patch
+++ b/pkgs/development/libraries/qt-5/5.6/qtscript.patch
@@ -1,12 +1,3 @@
-From abd80356449bb36c8adcc5c9ca1df6b47715d265 Mon Sep 17 00:00:00 2001
-From: Thomas Tuegel <ttuegel@gmail.com>
-Date: Sun, 23 Aug 2015 09:13:34 -0500
-Subject: [PATCH] glib-2.32
-
----
- src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
 diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h
 index 1f6d25e..087c3fb 100644
 --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h
@@ -20,6 +11,3 @@ index 1f6d25e..087c3fb 100644
  typedef struct _GCond GCond;
  #endif
  
--- 
-2.5.0
-
diff --git a/pkgs/development/libraries/qt-5/5.6/qtscript/default.nix b/pkgs/development/libraries/qt-5/5.6/qtscript/default.nix
deleted file mode 100644
index 127766e2ebd6..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtscript/default.nix
+++ /dev/null
@@ -1,7 +0,0 @@
-{ qtSubmodule, qtbase, qttools }:
-
-qtSubmodule {
-  name = "qtscript";
-  qtInputs = [ qtbase qttools ];
-  patches = [ ./0001-glib-2.32.patch ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtsensors.nix b/pkgs/development/libraries/qt-5/5.6/qtsensors.nix
deleted file mode 100644
index 61e64dc47e4d..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtsensors.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ qtSubmodule, qtbase, qtdeclarative }:
-
-qtSubmodule {
-  name = "qtsensors";
-  qtInputs = [ qtbase qtdeclarative ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtserialport/qtserialport-dlopen-udev.patch b/pkgs/development/libraries/qt-5/5.6/qtserialport.patch
index 65bb64710ebd..b2cffbe4f39b 100644
--- a/pkgs/development/libraries/qt-5/5.6/qtserialport/qtserialport-dlopen-udev.patch
+++ b/pkgs/development/libraries/qt-5/5.6/qtserialport.patch
@@ -1,8 +1,8 @@
-Index: qtserialport-opensource-src-5.8.0/src/serialport/qtudev_p.h
-===================================================================
---- qtserialport-opensource-src-5.8.0.orig/src/serialport/qtudev_p.h
-+++ qtserialport-opensource-src-5.8.0/src/serialport/qtudev_p.h
-@@ -111,9 +111,17 @@ inline QFunctionPointer resolveSymbol(QL
+diff --git a/src/serialport/qtudev_p.h b/src/serialport/qtudev_p.h
+index 6f2cabd..cd3c0ed 100644
+--- a/src/serialport/qtudev_p.h
++++ b/src/serialport/qtudev_p.h
+@@ -105,9 +105,17 @@ inline QFunctionPointer resolveSymbol(QLibrary *udevLibrary, const char *symbolN
  inline bool resolveSymbols(QLibrary *udevLibrary)
  {
      if (!udevLibrary->isLoaded()) {
diff --git a/pkgs/development/libraries/qt-5/5.6/qtserialport/series b/pkgs/development/libraries/qt-5/5.6/qtserialport/series
deleted file mode 100644
index 83f4abf094e9..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtserialport/series
+++ /dev/null
@@ -1 +0,0 @@
-qtserialport-dlopen-udev.patch
diff --git a/pkgs/development/libraries/qt-5/5.6/qtsvg.nix b/pkgs/development/libraries/qt-5/5.6/qtsvg.nix
deleted file mode 100644
index b9ccac7cf933..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtsvg.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ qtSubmodule, qtbase }:
-
-qtSubmodule {
-  name = "qtsvg";
-  qtInputs = [ qtbase ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.6/qttools.patch b/pkgs/development/libraries/qt-5/5.6/qttools.patch
new file mode 100644
index 000000000000..dcb15e0e55a6
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qttools.patch
@@ -0,0 +1,64 @@
+diff --git a/src/assistant/help/Qt5HelpConfigExtras.cmake.in b/src/assistant/help/Qt5HelpConfigExtras.cmake.in
+index 5a5bd5ce..1c6727d4 100644
+--- a/src/assistant/help/Qt5HelpConfigExtras.cmake.in
++++ b/src/assistant/help/Qt5HelpConfigExtras.cmake.in
+@@ -2,14 +2,13 @@
+ if (NOT TARGET Qt5::qcollectiongenerator)
+     add_executable(Qt5::qcollectiongenerator IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Help_install_prefix}/$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
++    if(NOT EXISTS \"${imported_location}\")
++        set(imported_location \"$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
++    endif()
+     _qt5_Help_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::qcollectiongenerator PROPERTIES
+         IMPORTED_LOCATION ${imported_location}
+     )
+-endif()
++endif()
+\ No newline at end of file
+diff --git a/src/linguist/Qt5LinguistToolsConfig.cmake.in b/src/linguist/Qt5LinguistToolsConfig.cmake.in
+index 4318b16f..d60db4ff 100644
+--- a/src/linguist/Qt5LinguistToolsConfig.cmake.in
++++ b/src/linguist/Qt5LinguistToolsConfig.cmake.in
+@@ -44,11 +44,7 @@ endmacro()
+ if (NOT TARGET Qt5::lrelease)
+     add_executable(Qt5::lrelease IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
+     _qt5_LinguistTools_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::lrelease PROPERTIES
+@@ -59,11 +55,7 @@ endif()
+ if (NOT TARGET Qt5::lupdate)
+     add_executable(Qt5::lupdate IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
+     _qt5_LinguistTools_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::lupdate PROPERTIES
+@@ -74,11 +66,7 @@ endif()
+ if (NOT TARGET Qt5::lconvert)
+     add_executable(Qt5::lconvert IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lconvert$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}lconvert$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
+     _qt5_LinguistTools_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::lconvert PROPERTIES
diff --git a/pkgs/development/libraries/qt-5/5.6/qttools/cmake-paths.patch b/pkgs/development/libraries/qt-5/5.6/qttools/cmake-paths.patch
deleted file mode 100644
index fe5bcadbe9a8..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qttools/cmake-paths.patch
+++ /dev/null
@@ -1,72 +0,0 @@
-Index: qttools-opensource-src-5.5.1/src/assistant/help/Qt5HelpConfigExtras.cmake.in
-===================================================================
---- qttools-opensource-src-5.5.1.orig/src/assistant/help/Qt5HelpConfigExtras.cmake.in
-+++ qttools-opensource-src-5.5.1/src/assistant/help/Qt5HelpConfigExtras.cmake.in
-@@ -2,11 +2,10 @@
- if (NOT TARGET Qt5::qcollectiongenerator)
-     add_executable(Qt5::qcollectiongenerator IMPORTED)
- 
--!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Help_install_prefix}/$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
--!!ELSE
--    set(imported_location \"$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
--!!ENDIF
-+    set(imported_location \"@NIX_OUT@/$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
-+    if(NOT EXISTS \"${imported_location}\")
-+        set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
-+    endif()
-     _qt5_Help_check_file_exists(${imported_location})
- 
-     set_target_properties(Qt5::qcollectiongenerator PROPERTIES
-Index: qttools-opensource-src-5.5.1/src/linguist/Qt5LinguistToolsConfig.cmake.in
-===================================================================
---- qttools-opensource-src-5.5.1.orig/src/linguist/Qt5LinguistToolsConfig.cmake.in
-+++ qttools-opensource-src-5.5.1/src/linguist/Qt5LinguistToolsConfig.cmake.in
-@@ -44,11 +44,10 @@ endmacro()
- if (NOT TARGET Qt5::lrelease)
-     add_executable(Qt5::lrelease IMPORTED)
- 
--!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\")
--!!ELSE
--    set(imported_location \"$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\")
--!!ENDIF
-+    set(imported_location \"@NIX_OUT@/$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\")
-+    if(NOT EXISTS \"${imported_location}\")
-+        set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\")
-+    endif()
-     _qt5_LinguistTools_check_file_exists(${imported_location})
- 
-     set_target_properties(Qt5::lrelease PROPERTIES
-@@ -59,11 +58,10 @@ endif()
- if (NOT TARGET Qt5::lupdate)
-     add_executable(Qt5::lupdate IMPORTED)
- 
--!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\")
--!!ELSE
--    set(imported_location \"$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\")
--!!ENDIF
-+    set(imported_location \"@NIX_OUT@/$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\")
-+    if(NOT EXISTS \"${imported_location}\")
-+        set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\")
-+    endif()
-     _qt5_LinguistTools_check_file_exists(${imported_location})
- 
-     set_target_properties(Qt5::lupdate PROPERTIES
-@@ -74,11 +72,10 @@ endif()
- if (NOT TARGET Qt5::lconvert)
-     add_executable(Qt5::lconvert IMPORTED)
- 
--!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lconvert$$CMAKE_BIN_SUFFIX\")
--!!ELSE
--    set(imported_location \"$${CMAKE_BIN_DIR}lconvert$$CMAKE_BIN_SUFFIX\")
--!!ENDIF
-+    set(imported_location \"@NIX_OUT@/$${CMAKE_BIN_DIR}lconvert$$CMAKE_BIN_SUFFIX\")
-+    if(NOT EXISTS \"${imported_location}\")
-+        set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}lconvert$$CMAKE_BIN_SUFFIX\")
-+    endif()
-     _qt5_LinguistTools_check_file_exists(${imported_location})
- 
-     set_target_properties(Qt5::lconvert PROPERTIES
diff --git a/pkgs/development/libraries/qt-5/5.6/qttools/default.nix b/pkgs/development/libraries/qt-5/5.6/qttools/default.nix
deleted file mode 100644
index 57b1b46a9c5d..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qttools/default.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-{ qtSubmodule, lib, copyPathsToStore, qtbase }:
-
-qtSubmodule {
-  name = "qttools";
-  qtInputs = [ qtbase ];
-  patches = copyPathsToStore (lib.readPathsFromFile ./. ./series);
-  postFixup = ''
-    moveToOutput "bin/qdbus" "$out"
-    moveToOutput "bin/qdbusviewer" "$out"
-    moveToOutput "bin/qtpaths" "$out"
-  '';
-}
diff --git a/pkgs/development/libraries/qt-5/5.6/qttools/series b/pkgs/development/libraries/qt-5/5.6/qttools/series
deleted file mode 100644
index 6cc1d3b87bca..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qttools/series
+++ /dev/null
@@ -1 +0,0 @@
-cmake-paths.patch
diff --git a/pkgs/development/libraries/qt-5/5.6/qtwebchannel.nix b/pkgs/development/libraries/qt-5/5.6/qtwebchannel.nix
deleted file mode 100644
index fd7a3c52026e..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtwebchannel.nix
+++ /dev/null
@@ -1,7 +0,0 @@
-{ qtSubmodule, qtbase, qtdeclarative }:
-
-qtSubmodule {
-  name = "qtwebchannel";
-  qtInputs = [ qtbase qtdeclarative ];
-}
-
diff --git a/pkgs/development/libraries/qt-5/5.6/qtwebengine/qtwebengine-paxmark-mksnapshot.patch b/pkgs/development/libraries/qt-5/5.6/qtwebengine-paxmark-mksnapshot.patch
index b3316188f7d9..b3316188f7d9 100644
--- a/pkgs/development/libraries/qt-5/5.6/qtwebengine/qtwebengine-paxmark-mksnapshot.patch
+++ b/pkgs/development/libraries/qt-5/5.6/qtwebengine-paxmark-mksnapshot.patch
diff --git a/pkgs/development/libraries/qt-5/5.6/qtwebengine-seccomp.patch b/pkgs/development/libraries/qt-5/5.6/qtwebengine-seccomp.patch
new file mode 100644
index 000000000000..bf6af8059823
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtwebengine-seccomp.patch
@@ -0,0 +1,24 @@
+Backported to Qt 5.6 for epoll_pwait fix on newer glibc
+Part of upstream Chromium's 4e8083b4ab953ba298aedfc4e79d464be15e4012
+Review URL: https://codereview.chromium.org/1613883002
+---
+diff --git a/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc b/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
+index 10278dc5fc9b..b30b3e6acef6 100644
+--- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
++++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
+@@ -414,6 +414,7 @@ bool SyscallSets::IsAllowedEpoll(int sysno) {
+     case __NR_epoll_create:
+     case __NR_epoll_wait:
+ #endif
++    case __NR_epoll_pwait:
+     case __NR_epoll_create1:
+     case __NR_epoll_ctl:
+       return true;
+@@ -421,7 +422,6 @@ bool SyscallSets::IsAllowedEpoll(int sysno) {
+ #if defined(__x86_64__)
+     case __NR_epoll_ctl_old:
+ #endif
+-    case __NR_epoll_pwait:
+ #if defined(__x86_64__)
+     case __NR_epoll_wait_old:
+ #endif
diff --git a/pkgs/development/libraries/qt-5/5.6/qtwebengine/chromium-clang-update-py.patch b/pkgs/development/libraries/qt-5/5.6/qtwebengine/chromium-clang-update-py.patch
deleted file mode 100644
index 65a604d25347..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtwebengine/chromium-clang-update-py.patch
+++ /dev/null
@@ -1,874 +0,0 @@
---- a/src/3rdparty/chromium/tools/clang/scripts/update.py	2016-05-26 04:58:54.000000000 -0800
-+++ b/src/3rdparty/chromium/tools/clang/scripts/update.py	2016-11-04 08:35:34.956154012 -0800
-@@ -3,12 +3,12 @@
- # Use of this source code is governed by a BSD-style license that can be
- # found in the LICENSE file.
- 
--"""Windows can't run .sh files, so this is a Python implementation of
--update.sh. This script should replace update.sh on all platforms eventually."""
-+"""This script is used to download prebuilt clang binaries.
-+
-+It is also used by package.py to build the prebuilt clang binaries."""
- 
- import argparse
--import contextlib
--import cStringIO
-+import distutils.spawn
- import glob
- import os
- import pipes
-@@ -18,6 +18,7 @@
- import stat
- import sys
- import tarfile
-+import tempfile
- import time
- import urllib2
- import zipfile
-@@ -25,19 +26,16 @@
- # Do NOT CHANGE this if you don't know what you're doing -- see
- # https://code.google.com/p/chromium/wiki/UpdatingClang
- # Reverting problematic clang rolls is safe, though.
--# Note: this revision is only used for Windows. Other platforms use update.sh.
--# TODO(thakis): Use the same revision on Windows and non-Windows.
--# TODO(thakis): Remove update.sh, use update.py everywhere.
--LLVM_WIN_REVISION = '239674'
-+CLANG_REVISION = '239674'
- 
- use_head_revision = 'LLVM_FORCE_HEAD_REVISION' in os.environ
- if use_head_revision:
--  LLVM_WIN_REVISION = 'HEAD'
-+  CLANG_REVISION = 'HEAD'
- 
- # This is incremented when pushing a new build of Clang at the same revision.
- CLANG_SUB_REVISION=1
- 
--PACKAGE_VERSION = "%s-%s" % (LLVM_WIN_REVISION, CLANG_SUB_REVISION)
-+PACKAGE_VERSION = "%s-%s" % (CLANG_REVISION, CLANG_SUB_REVISION)
- 
- # Path constants. (All of these should be absolute paths.)
- THIS_DIR = os.path.abspath(os.path.dirname(__file__))
-@@ -50,17 +48,26 @@
- CHROME_TOOLS_SHIM_DIR = os.path.join(LLVM_DIR, 'tools', 'chrometools')
- LLVM_BUILD_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'llvm-build',
-                               'Release+Asserts')
--COMPILER_RT_BUILD_DIR = os.path.join(LLVM_BUILD_DIR, '32bit-compiler-rt')
-+COMPILER_RT_BUILD_DIR = os.path.join(LLVM_BUILD_DIR, 'compiler-rt')
- CLANG_DIR = os.path.join(LLVM_DIR, 'tools', 'clang')
- LLD_DIR = os.path.join(LLVM_DIR, 'tools', 'lld')
--COMPILER_RT_DIR = os.path.join(LLVM_DIR, 'projects', 'compiler-rt')
-+# compiler-rt is built as part of the regular LLVM build on Windows to get
-+# the 64-bit runtime, and out-of-tree elsewhere.
-+# TODO(thakis): Try to unify this.
-+if sys.platform == 'win32':
-+  COMPILER_RT_DIR = os.path.join(LLVM_DIR, 'projects', 'compiler-rt')
-+else:
-+  COMPILER_RT_DIR = os.path.join(LLVM_DIR, 'compiler-rt')
- LIBCXX_DIR = os.path.join(LLVM_DIR, 'projects', 'libcxx')
- LIBCXXABI_DIR = os.path.join(LLVM_DIR, 'projects', 'libcxxabi')
- LLVM_BUILD_TOOLS_DIR = os.path.abspath(
-     os.path.join(LLVM_DIR, '..', 'llvm-build-tools'))
--STAMP_FILE = os.path.join(LLVM_DIR, '..', 'llvm-build', 'cr_build_revision')
-+STAMP_FILE = os.path.normpath(
-+    os.path.join(LLVM_DIR, '..', 'llvm-build', 'cr_build_revision'))
- BINUTILS_DIR = os.path.join(THIRD_PARTY_DIR, 'binutils')
--VERSION = '3.7.0'
-+VERSION = '3.8.0'
-+ANDROID_NDK_DIR = os.path.join(
-+    CHROMIUM_DIR, 'third_party', 'android_tools', 'ndk')
- 
- # URL for pre-built binaries.
- CDS_URL = 'https://commondatastorage.googleapis.com/chromium-browser-clang'
-@@ -74,40 +81,75 @@
-   """Download url into output_file."""
-   CHUNK_SIZE = 4096
-   TOTAL_DOTS = 10
--  sys.stdout.write('Downloading %s ' % url)
--  sys.stdout.flush()
--  response = urllib2.urlopen(url)
--  total_size = int(response.info().getheader('Content-Length').strip())
--  bytes_done = 0
--  dots_printed = 0
-+  num_retries = 3
-+  retry_wait_s = 5  # Doubled at each retry.
-+
-   while True:
--    chunk = response.read(CHUNK_SIZE)
--    if not chunk:
--      break
--    output_file.write(chunk)
--    bytes_done += len(chunk)
--    num_dots = TOTAL_DOTS * bytes_done / total_size
--    sys.stdout.write('.' * (num_dots - dots_printed))
--    sys.stdout.flush()
--    dots_printed = num_dots
--  print ' Done.'
-+    try:
-+      sys.stdout.write('Downloading %s ' % url)
-+      sys.stdout.flush()
-+      response = urllib2.urlopen(url)
-+      total_size = int(response.info().getheader('Content-Length').strip())
-+      bytes_done = 0
-+      dots_printed = 0
-+      while True:
-+        chunk = response.read(CHUNK_SIZE)
-+        if not chunk:
-+          break
-+        output_file.write(chunk)
-+        bytes_done += len(chunk)
-+        num_dots = TOTAL_DOTS * bytes_done / total_size
-+        sys.stdout.write('.' * (num_dots - dots_printed))
-+        sys.stdout.flush()
-+        dots_printed = num_dots
-+      if bytes_done != total_size:
-+        raise urllib2.URLError("only got %d of %d bytes" %
-+                               (bytes_done, total_size))
-+      print ' Done.'
-+      return
-+    except urllib2.URLError as e:
-+      sys.stdout.write('\n')
-+      print e
-+      if num_retries == 0 or isinstance(e, urllib2.HTTPError) and e.code == 404:
-+        raise e
-+      num_retries -= 1
-+      print 'Retrying in %d s ...' % retry_wait_s
-+      time.sleep(retry_wait_s)
-+      retry_wait_s *= 2
-+
-+
-+def EnsureDirExists(path):
-+  if not os.path.exists(path):
-+    print "Creating directory %s" % path
-+    os.makedirs(path)
-+
-+
-+def DownloadAndUnpack(url, output_dir):
-+  with tempfile.TemporaryFile() as f:
-+    DownloadUrl(url, f)
-+    f.seek(0)
-+    EnsureDirExists(output_dir)
-+    if url.endswith('.zip'):
-+      zipfile.ZipFile(f).extractall(path=output_dir)
-+    else:
-+      tarfile.open(mode='r:gz', fileobj=f).extractall(path=output_dir)
- 
- 
- def ReadStampFile():
-   """Return the contents of the stamp file, or '' if it doesn't exist."""
-   try:
-     with open(STAMP_FILE, 'r') as f:
--      return f.read()
-+      return f.read().rstrip()
-   except IOError:
-     return ''
- 
- 
- def WriteStampFile(s):
-   """Write s to the stamp file."""
--  if not os.path.exists(os.path.dirname(STAMP_FILE)):
--    os.makedirs(os.path.dirname(STAMP_FILE))
-+  EnsureDirExists(os.path.dirname(STAMP_FILE))
-   with open(STAMP_FILE, 'w') as f:
-     f.write(s)
-+    f.write('\n')
- 
- 
- def GetSvnRevision(svn_repo):
-@@ -129,6 +171,13 @@
-   shutil.rmtree(dir, onerror=ChmodAndRetry)
- 
- 
-+def RmCmakeCache(dir):
-+  """Delete CMakeCache.txt files under dir recursively."""
-+  for dirpath, _, files in os.walk(dir):
-+    if 'CMakeCache.txt' in files:
-+      os.remove(os.path.join(dirpath, 'CMakeCache.txt'))
-+
-+
- def RunCommand(command, msvc_arch=None, env=None, fail_hard=True):
-   """Run command and return success (True) or failure; or if fail_hard is
-      True, exit on failure.  If msvc_arch is set, runs the command in a
-@@ -170,8 +219,8 @@
- def CopyDirectoryContents(src, dst, filename_filter=None):
-   """Copy the files from directory src to dst
-   with an optional filename filter."""
--  if not os.path.exists(dst):
--    os.makedirs(dst)
-+  dst = os.path.realpath(dst)  # realpath() in case dst ends in /..
-+  EnsureDirExists(dst)
-   for root, _, files in os.walk(src):
-     for f in files:
-       if filename_filter and not re.match(filename_filter, f):
-@@ -181,9 +230,9 @@
- 
- def Checkout(name, url, dir):
-   """Checkout the SVN module at url into dir. Use name for the log message."""
--  print "Checking out %s r%s into '%s'" % (name, LLVM_WIN_REVISION, dir)
-+  print "Checking out %s r%s into '%s'" % (name, CLANG_REVISION, dir)
- 
--  command = ['svn', 'checkout', '--force', url + '@' + LLVM_WIN_REVISION, dir]
-+  command = ['svn', 'checkout', '--force', url + '@' + CLANG_REVISION, dir]
-   if RunCommand(command, fail_hard=False):
-     return
- 
-@@ -195,120 +244,9 @@
-   RunCommand(command)
- 
- 
--def RevertPreviouslyPatchedFiles():
--  print 'Reverting previously patched files'
--  files = [
--    '%(clang)s/test/Index/crash-recovery-modules.m',
--    '%(clang)s/unittests/libclang/LibclangTest.cpp',
--    '%(compiler_rt)s/lib/asan/asan_rtl.cc',
--    '%(compiler_rt)s/test/asan/TestCases/Linux/new_array_cookie_test.cc',
--    '%(llvm)s/test/DebugInfo/gmlt.ll',
--    '%(llvm)s/lib/CodeGen/SpillPlacement.cpp',
--    '%(llvm)s/lib/CodeGen/SpillPlacement.h',
--    '%(llvm)s/lib/Transforms/Instrumentation/MemorySanitizer.cpp',
--    '%(clang)s/test/Driver/env.c',
--    '%(clang)s/lib/Frontend/InitPreprocessor.cpp',
--    '%(clang)s/test/Frontend/exceptions.c',
--    '%(clang)s/test/Preprocessor/predefined-exceptions.m',
--    '%(llvm)s/test/Bindings/Go/go.test',
--    '%(clang)s/lib/Parse/ParseExpr.cpp',
--    '%(clang)s/lib/Parse/ParseTemplate.cpp',
--    '%(clang)s/lib/Sema/SemaDeclCXX.cpp',
--    '%(clang)s/lib/Sema/SemaExprCXX.cpp',
--    '%(clang)s/test/SemaCXX/default2.cpp',
--    '%(clang)s/test/SemaCXX/typo-correction-delayed.cpp',
--    '%(compiler_rt)s/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc',
--    '%(compiler_rt)s/test/tsan/signal_segv_handler.cc',
--    '%(compiler_rt)s/lib/sanitizer_common/sanitizer_coverage_libcdep.cc',
--    '%(compiler_rt)s/cmake/config-ix.cmake',
--    '%(compiler_rt)s/CMakeLists.txt',
--    '%(compiler_rt)s/lib/ubsan/ubsan_platform.h',
--    ]
--  for f in files:
--    f = f % {
--        'clang': CLANG_DIR,
--        'compiler_rt': COMPILER_RT_DIR,
--        'llvm': LLVM_DIR,
--        }
--    if os.path.exists(f):
--      os.remove(f)  # For unversioned files.
--      RunCommand(['svn', 'revert', f])
--
--
--def ApplyLocalPatches():
--  # There's no patch program on Windows by default.  We don't need patches on
--  # Windows yet, and maybe this not working on Windows will motivate us to
--  # remove patches over time.
--  assert sys.platform != 'win32'
--
--  # Apply patch for tests failing with --disable-pthreads (llvm.org/PR11974)
--  clang_patches = [ r"""\
----- test/Index/crash-recovery-modules.m	(revision 202554)
--+++ test/Index/crash-recovery-modules.m	(working copy)
--@@ -12,6 +12,8 @@
-- 
-- // REQUIRES: crash-recovery
-- // REQUIRES: shell
--+// XFAIL: *
--+//    (PR11974)
-- 
-- @import Crash;
--""", r"""\
----- unittests/libclang/LibclangTest.cpp (revision 215949)
--+++ unittests/libclang/LibclangTest.cpp (working copy)
--@@ -431,7 +431,7 @@
--   EXPECT_EQ(0U, clang_getNumDiagnostics(ClangTU));
-- }
--
---TEST_F(LibclangReparseTest, ReparseWithModule) {
--+TEST_F(LibclangReparseTest, DISABLED_ReparseWithModule) {
--   const char *HeaderTop = "#ifndef H\n#define H\nstruct Foo { int bar;";
--   const char *HeaderBottom = "\n};\n#endif\n";
--   const char *MFile = "#include \"HeaderFile.h\"\nint main() {"
--"""
--      ]
--
--  # This Go bindings test doesn't work after bootstrap on Linux, PR21552.
--  llvm_patches = [ r"""\
----- test/Bindings/Go/go.test    (revision 223109)
--+++ test/Bindings/Go/go.test    (working copy)
--@@ -1,3 +1,3 @@
---; RUN: llvm-go test llvm.org/llvm/bindings/go/llvm
--+; RUN: true
-- 
-- ; REQUIRES: shell
--"""
--      ]
--
--  # The UBSan run-time, which is now bundled with the ASan run-time, doesn't
--  # work on Mac OS X 10.8 (PR23539).
--  compiler_rt_patches = [ r"""\
----- CMakeLists.txt	(revision 241602)
--+++ CMakeLists.txt	(working copy)
--@@ -305,6 +305,7 @@
--       list(APPEND SANITIZER_COMMON_SUPPORTED_OS iossim)
--     endif()
--   endif()
--+  set(SANITIZER_MIN_OSX_VERSION "10.7")
--   if(SANITIZER_MIN_OSX_VERSION VERSION_LESS "10.7")
--     message(FATAL_ERROR "Too old OS X version: ${SANITIZER_MIN_OSX_VERSION}")
--   endif()
--"""
--      ]
--
--  for path, patches in [(LLVM_DIR, llvm_patches),
--                        (CLANG_DIR, clang_patches),
--                        (COMPILER_RT_DIR, compiler_rt_patches)]:
--    print 'Applying patches in', path
--    for patch in patches:
--      print patch
--      p = subprocess.Popen( ['patch', '-p0', '-d', path], stdin=subprocess.PIPE)
--      (stdout, stderr) = p.communicate(input=patch)
--      if p.returncode != 0:
--        raise RuntimeError('stdout %s, stderr %s' % (stdout, stderr))
--
--
- def DeleteChromeToolsShim():
-+  OLD_SHIM_DIR = os.path.join(LLVM_DIR, 'tools', 'zzz-chrometools')
-+  shutil.rmtree(OLD_SHIM_DIR, ignore_errors=True)
-   shutil.rmtree(CHROME_TOOLS_SHIM_DIR, ignore_errors=True)
- 
- 
-@@ -337,6 +275,25 @@
-     f.write('endif (CHROMIUM_TOOLS_SRC)\n')
- 
- 
-+def MaybeDownloadHostGcc(args):
-+  """Downloads gcc 4.8.2 if needed and makes sure args.gcc_toolchain is set."""
-+  if not sys.platform.startswith('linux') or args.gcc_toolchain:
-+    return
-+
-+  if subprocess.check_output(['gcc', '-dumpversion']).rstrip() < '4.7.0':
-+    # We need a newer gcc version.
-+    gcc_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, 'gcc482precise')
-+    if not os.path.exists(gcc_dir):
-+      print 'Downloading pre-built GCC 4.8.2...'
-+      DownloadAndUnpack(
-+          CDS_URL + '/tools/gcc482precise.tgz', LLVM_BUILD_TOOLS_DIR)
-+    args.gcc_toolchain = gcc_dir
-+  else:
-+    # Always set gcc_toolchain; llvm-symbolizer needs the bundled libstdc++.
-+    args.gcc_toolchain = \
-+        os.path.dirname(os.path.dirname(distutils.spawn.find_executable('gcc')))
-+
-+
- def AddCMakeToPath():
-   """Download CMake and add it to PATH."""
-   if sys.platform == 'win32':
-@@ -345,20 +302,10 @@
-                              'cmake-3.2.2-win32-x86', 'bin')
-   else:
-     suffix = 'Darwin' if sys.platform == 'darwin' else 'Linux'
--    zip_name = 'cmake310_%s.tgz' % suffix
--    cmake_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, 'cmake310', 'bin')
-+    zip_name = 'cmake322_%s.tgz' % suffix
-+    cmake_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, 'cmake322', 'bin')
-   if not os.path.exists(cmake_dir):
--    if not os.path.exists(LLVM_BUILD_TOOLS_DIR):
--      os.makedirs(LLVM_BUILD_TOOLS_DIR)
--    # The cmake archive is smaller than 20 MB, small enough to keep in memory:
--    with contextlib.closing(cStringIO.StringIO()) as f:
--      DownloadUrl(CDS_URL + '/tools/' + zip_name, f)
--      f.seek(0)
--      if zip_name.endswith('.zip'):
--        zipfile.ZipFile(f).extractall(path=LLVM_BUILD_TOOLS_DIR)
--      else:
--        tarfile.open(mode='r:gz', fileobj=f).extractall(path=
--            LLVM_BUILD_TOOLS_DIR)
-+    DownloadAndUnpack(CDS_URL + '/tools/' + zip_name, LLVM_BUILD_TOOLS_DIR)
-   os.environ['PATH'] = cmake_dir + os.pathsep + os.environ.get('PATH', '')
- 
- vs_version = None
-@@ -383,37 +330,61 @@
- 
- def UpdateClang(args):
-   print 'Updating Clang to %s...' % PACKAGE_VERSION
--  if ReadStampFile() == PACKAGE_VERSION:
--    print 'Already up to date.'
--    return 0
-+
-+  need_gold_plugin = 'LLVM_DOWNLOAD_GOLD_PLUGIN' in os.environ or (
-+      sys.platform.startswith('linux') and
-+      'buildtype=Official' in os.environ.get('GYP_DEFINES', '') and
-+      'branding=Chrome' in os.environ.get('GYP_DEFINES', ''))
-+
-+  if ReadStampFile() == PACKAGE_VERSION and not args.force_local_build:
-+    print 'Clang is already up to date.'
-+    if not need_gold_plugin or os.path.exists(
-+        os.path.join(LLVM_BUILD_DIR, "lib/LLVMgold.so")):
-+      return 0
- 
-   # Reset the stamp file in case the build is unsuccessful.
-   WriteStampFile('')
- 
-   if not args.force_local_build:
-     cds_file = "clang-%s.tgz" %  PACKAGE_VERSION
--    cds_full_url = CDS_URL + '/Win/' + cds_file
-+    if sys.platform == 'win32':
-+      cds_full_url = CDS_URL + '/Win/' + cds_file
-+    elif sys.platform == 'darwin':
-+      cds_full_url = CDS_URL + '/Mac/' + cds_file
-+    else:
-+      assert sys.platform.startswith('linux')
-+      cds_full_url = CDS_URL + '/Linux_x64/' + cds_file
- 
--    # Check if there's a prebuilt binary and if so just fetch that. That's
--    # faster, and goma relies on having matching binary hashes on client and
--    # server too.
--    print 'Trying to download prebuilt clang'
--
--    # clang packages are smaller than 50 MB, small enough to keep in memory.
--    with contextlib.closing(cStringIO.StringIO()) as f:
--      try:
--        DownloadUrl(cds_full_url, f)
--        f.seek(0)
--        tarfile.open(mode='r:gz', fileobj=f).extractall(path=LLVM_BUILD_DIR)
--        print 'clang %s unpacked' % PACKAGE_VERSION
--        WriteStampFile(PACKAGE_VERSION)
--        return 0
--      except urllib2.HTTPError:
--        print 'Did not find prebuilt clang %s, building locally' % cds_file
-+    print 'Downloading prebuilt clang'
-+    if os.path.exists(LLVM_BUILD_DIR):
-+      RmTree(LLVM_BUILD_DIR)
-+    try:
-+      DownloadAndUnpack(cds_full_url, LLVM_BUILD_DIR)
-+      print 'clang %s unpacked' % PACKAGE_VERSION
-+      # Download the gold plugin if requested to by an environment variable.
-+      # This is used by the CFI ClusterFuzz bot, and it's required for official
-+      # builds on linux.
-+      if need_gold_plugin:
-+        RunCommand(['python', CHROMIUM_DIR+'/build/download_gold_plugin.py'])
-+      WriteStampFile(PACKAGE_VERSION)
-+      return 0
-+    except urllib2.URLError:
-+      print 'Failed to download prebuilt clang %s' % cds_file
-+      print 'Use --force-local-build if you want to build locally.'
-+      print 'Exiting.'
-+      return 1
-+
-+  if args.with_android and not os.path.exists(ANDROID_NDK_DIR):
-+    print 'Android NDK not found at ' + ANDROID_NDK_DIR
-+    print 'The Android NDK is needed to build a Clang whose -fsanitize=address'
-+    print 'works on Android. See '
-+    print 'http://code.google.com/p/chromium/wiki/AndroidBuildInstructions'
-+    print 'for how to install the NDK, or pass --without-android.'
-+    return 1
- 
-+  MaybeDownloadHostGcc(args)
-   AddCMakeToPath()
- 
--  RevertPreviouslyPatchedFiles()
-   DeleteChromeToolsShim()
- 
-   Checkout('LLVM', LLVM_REPO_URL + '/llvm/trunk', LLVM_DIR)
-@@ -429,10 +400,24 @@
-     # into it too (since OS X 10.6 doesn't have libc++abi.dylib either).
-     Checkout('libcxxabi', LLVM_REPO_URL + '/libcxxabi/trunk', LIBCXXABI_DIR)
- 
--  if args.with_patches and sys.platform != 'win32':
--    ApplyLocalPatches()
--
-   cc, cxx = None, None
-+  libstdcpp = None
-+  if args.gcc_toolchain:  # This option is only used on Linux.
-+    # Use the specified gcc installation for building.
-+    cc = os.path.join(args.gcc_toolchain, 'bin', 'gcc')
-+    cxx = os.path.join(args.gcc_toolchain, 'bin', 'g++')
-+
-+    if not os.access(cc, os.X_OK):
-+      print 'Invalid --gcc-toolchain: "%s"' % args.gcc_toolchain
-+      print '"%s" does not appear to be valid.' % cc
-+      return 1
-+
-+    # Set LD_LIBRARY_PATH to make auxiliary targets (tablegen, bootstrap
-+    # compiler, etc.) find the .so.
-+    libstdcpp = subprocess.check_output(
-+        [cxx, '-print-file-name=libstdc++.so.6']).rstrip()
-+    os.environ['LD_LIBRARY_PATH'] = os.path.dirname(libstdcpp)
-+
-   cflags = cxxflags = ldflags = []
- 
-   # LLVM uses C++11 starting in llvm 3.5. On Linux, this means libstdc++4.7+ is
-@@ -462,8 +447,7 @@
- 
-   if args.bootstrap:
-     print 'Building bootstrap compiler'
--    if not os.path.exists(LLVM_BOOTSTRAP_DIR):
--      os.makedirs(LLVM_BOOTSTRAP_DIR)
-+    EnsureDirExists(LLVM_BOOTSTRAP_DIR)
-     os.chdir(LLVM_BOOTSTRAP_DIR)
-     bootstrap_args = base_cmake_args + [
-         '-DLLVM_TARGETS_TO_BUILD=host',
-@@ -473,11 +457,16 @@
-         ]
-     if cc is not None:  bootstrap_args.append('-DCMAKE_C_COMPILER=' + cc)
-     if cxx is not None: bootstrap_args.append('-DCMAKE_CXX_COMPILER=' + cxx)
-+    RmCmakeCache('.')
-     RunCommand(['cmake'] + bootstrap_args + [LLVM_DIR], msvc_arch='x64')
-     RunCommand(['ninja'], msvc_arch='x64')
-     if args.run_tests:
-       RunCommand(['ninja', 'check-all'], msvc_arch='x64')
-     RunCommand(['ninja', 'install'], msvc_arch='x64')
-+    if args.gcc_toolchain:
-+      # Copy that gcc's stdlibc++.so.6 to the build dir, so the bootstrap
-+      # compiler can start.
-+      CopyFile(libstdcpp, os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'lib'))
- 
-     if sys.platform == 'win32':
-       cc = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang-cl.exe')
-@@ -489,6 +478,12 @@
-     else:
-       cc = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang')
-       cxx = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang++')
-+
-+    if args.gcc_toolchain:
-+      # Tell the bootstrap compiler to use a specific gcc prefix to search
-+      # for standard library headers and shared object files.
-+      cflags = ['--gcc-toolchain=' + args.gcc_toolchain]
-+      cxxflags = ['--gcc-toolchain=' + args.gcc_toolchain]
-     print 'Building final compiler'
- 
-   if sys.platform == 'darwin':
-@@ -543,7 +538,7 @@
-     binutils_incdir = os.path.join(BINUTILS_DIR, 'Linux_x64/Release/include')
- 
-   # If building at head, define a macro that plugins can use for #ifdefing
--  # out code that builds at head, but not at LLVM_WIN_REVISION or vice versa.
-+  # out code that builds at head, but not at CLANG_REVISION or vice versa.
-   if use_head_revision:
-     cflags += ['-DLLVM_FORCE_HEAD_REVISION']
-     cxxflags += ['-DLLVM_FORCE_HEAD_REVISION']
-@@ -555,8 +550,15 @@
-     deployment_env = os.environ.copy()
-     deployment_env['MACOSX_DEPLOYMENT_TARGET'] = deployment_target
- 
--  cmake_args = base_cmake_args + [
-+  cmake_args = []
-+  # TODO(thakis): Unconditionally append this to base_cmake_args instead once
-+  # compiler-rt can build with clang-cl on Windows (http://llvm.org/PR23698)
-+  cc_args = base_cmake_args if sys.platform != 'win32' else cmake_args
-+  if cc is not None:  cc_args.append('-DCMAKE_C_COMPILER=' + cc)
-+  if cxx is not None: cc_args.append('-DCMAKE_CXX_COMPILER=' + cxx)
-+  cmake_args += base_cmake_args + [
-       '-DLLVM_BINUTILS_INCDIR=' + binutils_incdir,
-+      '-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly',
-       '-DCMAKE_C_FLAGS=' + ' '.join(cflags),
-       '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags),
-       '-DCMAKE_EXE_LINKER_FLAGS=' + ' '.join(ldflags),
-@@ -565,35 +567,44 @@
-       '-DCMAKE_INSTALL_PREFIX=' + LLVM_BUILD_DIR,
-       '-DCHROMIUM_TOOLS_SRC=%s' % os.path.join(CHROMIUM_DIR, 'tools', 'clang'),
-       '-DCHROMIUM_TOOLS=%s' % ';'.join(args.tools)]
--  # TODO(thakis): Unconditionally append this to base_cmake_args instead once
--  # compiler-rt can build with clang-cl on Windows (http://llvm.org/PR23698)
--  cc_args = base_cmake_args if sys.platform != 'win32' else cmake_args
--  if cc is not None:  cc_args.append('-DCMAKE_C_COMPILER=' + cc)
--  if cxx is not None: cc_args.append('-DCMAKE_CXX_COMPILER=' + cxx)
- 
--  if not os.path.exists(LLVM_BUILD_DIR):
--    os.makedirs(LLVM_BUILD_DIR)
-+  EnsureDirExists(LLVM_BUILD_DIR)
-   os.chdir(LLVM_BUILD_DIR)
-+  RmCmakeCache('.')
-   RunCommand(['cmake'] + cmake_args + [LLVM_DIR],
-              msvc_arch='x64', env=deployment_env)
--  RunCommand(['ninja'], msvc_arch='x64')
-+
-+  if args.gcc_toolchain:
-+    # Copy in the right stdlibc++.so.6 so clang can start.
-+    if not os.path.exists(os.path.join(LLVM_BUILD_DIR, 'lib')):
-+      os.mkdir(os.path.join(LLVM_BUILD_DIR, 'lib'))
-+    libstdcpp = subprocess.check_output(
-+        [cxx] + cxxflags + ['-print-file-name=libstdc++.so.6']).rstrip()
-+    CopyFile(libstdcpp, os.path.join(LLVM_BUILD_DIR, 'lib'))
-+
-+  # TODO(thakis): Remove "-d explain" once http://crbug.com/569337 is fixed.
-+  RunCommand(['ninja', '-d', 'explain'], msvc_arch='x64')
- 
-   if args.tools:
-     # If any Chromium tools were built, install those now.
-     RunCommand(['ninja', 'cr-install'], msvc_arch='x64')
- 
-   if sys.platform == 'darwin':
--    CopyFile(os.path.join(LLVM_BUILD_DIR, 'libc++.1.dylib'),
-+    CopyFile(os.path.join(libcxxbuild, 'libc++.1.dylib'),
-              os.path.join(LLVM_BUILD_DIR, 'bin'))
-     # See http://crbug.com/256342
-     RunCommand(['strip', '-x', os.path.join(LLVM_BUILD_DIR, 'bin', 'clang')])
-   elif sys.platform.startswith('linux'):
-     RunCommand(['strip', os.path.join(LLVM_BUILD_DIR, 'bin', 'clang')])
- 
--  # Do an x86 build of compiler-rt to get the 32-bit ASan run-time.
-+  # Do an out-of-tree build of compiler-rt.
-+  # On Windows, this is used to get the 32-bit ASan run-time.
-   # TODO(hans): Remove once the regular build above produces this.
--  if not os.path.exists(COMPILER_RT_BUILD_DIR):
--    os.makedirs(COMPILER_RT_BUILD_DIR)
-+  # On Mac and Linux, this is used to get the regular 64-bit run-time.
-+  # Do a clobbered build due to cmake changes.
-+  if os.path.isdir(COMPILER_RT_BUILD_DIR):
-+    RmTree(COMPILER_RT_BUILD_DIR)
-+  os.makedirs(COMPILER_RT_BUILD_DIR)
-   os.chdir(COMPILER_RT_BUILD_DIR)
-   # TODO(thakis): Add this once compiler-rt can build with clang-cl (see
-   # above).
-@@ -606,11 +617,17 @@
-       '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags)]
-   if sys.platform != 'win32':
-     compiler_rt_args += ['-DLLVM_CONFIG_PATH=' +
--                         os.path.join(LLVM_BUILD_DIR, 'bin', 'llvm-config')]
--  RunCommand(['cmake'] + compiler_rt_args + [LLVM_DIR],
--              msvc_arch='x86', env=deployment_env)
-+                         os.path.join(LLVM_BUILD_DIR, 'bin', 'llvm-config'),
-+                        '-DSANITIZER_MIN_OSX_VERSION="10.7"']
-+  # compiler-rt is part of the llvm checkout on Windows but a stand-alone
-+  # directory elsewhere, see the TODO above COMPILER_RT_DIR.
-+  RmCmakeCache('.')
-+  RunCommand(['cmake'] + compiler_rt_args +
-+             [LLVM_DIR if sys.platform == 'win32' else COMPILER_RT_DIR],
-+             msvc_arch='x86', env=deployment_env)
-   RunCommand(['ninja', 'compiler-rt'], msvc_arch='x86')
- 
-+  # Copy select output to the main tree.
-   # TODO(hans): Make this (and the .gypi and .isolate files) version number
-   # independent.
-   if sys.platform == 'win32':
-@@ -620,17 +637,35 @@
-   else:
-     assert sys.platform.startswith('linux')
-     platform = 'linux'
--  asan_rt_lib_src_dir = os.path.join(COMPILER_RT_BUILD_DIR, 'lib', 'clang',
--                                     VERSION, 'lib', platform)
-+  asan_rt_lib_src_dir = os.path.join(COMPILER_RT_BUILD_DIR, 'lib', platform)
-+  if sys.platform == 'win32':
-+    # TODO(thakis): This too is due to compiler-rt being part of the checkout
-+    # on Windows, see TODO above COMPILER_RT_DIR.
-+    asan_rt_lib_src_dir = os.path.join(COMPILER_RT_BUILD_DIR, 'lib', 'clang',
-+                                       VERSION, 'lib', platform)
-   asan_rt_lib_dst_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang',
-                                      VERSION, 'lib', platform)
--  CopyDirectoryContents(asan_rt_lib_src_dir, asan_rt_lib_dst_dir,
--                        r'^.*-i386\.lib$')
--  CopyDirectoryContents(asan_rt_lib_src_dir, asan_rt_lib_dst_dir,
--                        r'^.*-i386\.dll$')
-+  # Blacklists:
-+  CopyDirectoryContents(os.path.join(asan_rt_lib_src_dir, '..', '..'),
-+                        os.path.join(asan_rt_lib_dst_dir, '..', '..'),
-+                        r'^.*blacklist\.txt$')
-+  # Headers:
-+  if sys.platform != 'win32':
-+    CopyDirectoryContents(
-+        os.path.join(COMPILER_RT_BUILD_DIR, 'include/sanitizer'),
-+        os.path.join(LLVM_BUILD_DIR, 'lib/clang', VERSION, 'include/sanitizer'))
-+  # Static and dynamic libraries:
-+  CopyDirectoryContents(asan_rt_lib_src_dir, asan_rt_lib_dst_dir)
-+  if sys.platform == 'darwin':
-+    for dylib in glob.glob(os.path.join(asan_rt_lib_dst_dir, '*.dylib')):
-+      # Fix LC_ID_DYLIB for the ASan dynamic libraries to be relative to
-+      # @executable_path.
-+      # TODO(glider): this is transitional. We'll need to fix the dylib
-+      # name either in our build system, or in Clang. See also
-+      # http://crbug.com/344836.
-+      subprocess.call(['install_name_tool', '-id',
-+                       '@executable_path/' + os.path.basename(dylib), dylib])
- 
--  CopyFile(os.path.join(asan_rt_lib_src_dir, '..', '..', 'asan_blacklist.txt'),
--           os.path.join(asan_rt_lib_dst_dir, '..', '..'))
- 
-   if sys.platform == 'win32':
-     # Make an extra copy of the sanitizer headers, to be put on the include path
-@@ -640,22 +675,67 @@
-     aux_sanitizer_include_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang',
-                                              VERSION, 'include_sanitizer',
-                                              'sanitizer')
--    if not os.path.exists(aux_sanitizer_include_dir):
--      os.makedirs(aux_sanitizer_include_dir)
-+    EnsureDirExists(aux_sanitizer_include_dir)
-     for _, _, files in os.walk(sanitizer_include_dir):
-       for f in files:
-         CopyFile(os.path.join(sanitizer_include_dir, f),
-                  aux_sanitizer_include_dir)
- 
-+  if args.with_android:
-+    make_toolchain = os.path.join(
-+        ANDROID_NDK_DIR, 'build', 'tools', 'make-standalone-toolchain.sh')
-+    for target_arch in ['aarch64', 'arm', 'i686']:
-+      # Make standalone Android toolchain for target_arch.
-+      toolchain_dir = os.path.join(
-+          LLVM_BUILD_DIR, 'android-toolchain-' + target_arch)
-+      RunCommand([
-+          make_toolchain,
-+          '--platform=android-' + ('21' if target_arch == 'aarch64' else '19'),
-+          '--install-dir="%s"' % toolchain_dir,
-+          '--system=linux-x86_64',
-+          '--stl=stlport',
-+          '--toolchain=' + {
-+              'aarch64': 'aarch64-linux-android-4.9',
-+              'arm': 'arm-linux-androideabi-4.9',
-+              'i686': 'x86-4.9',
-+          }[target_arch]])
-+      # Android NDK r9d copies a broken unwind.h into the toolchain, see
-+      # http://crbug.com/357890
-+      for f in glob.glob(os.path.join(toolchain_dir, 'include/c++/*/unwind.h')):
-+        os.remove(f)
-+
-+      # Build ASan runtime for Android in a separate build tree.
-+      build_dir = os.path.join(LLVM_BUILD_DIR, 'android-' + target_arch)
-+      if not os.path.exists(build_dir):
-+        os.mkdir(os.path.join(build_dir))
-+      os.chdir(build_dir)
-+      cflags = ['--target=%s-linux-androideabi' % target_arch,
-+                '--sysroot=%s/sysroot' % toolchain_dir,
-+                '-B%s' % toolchain_dir]
-+      android_args = base_cmake_args + [
-+        '-DCMAKE_C_COMPILER=' + os.path.join(LLVM_BUILD_DIR, 'bin/clang'),
-+        '-DCMAKE_CXX_COMPILER=' + os.path.join(LLVM_BUILD_DIR, 'bin/clang++'),
-+        '-DLLVM_CONFIG_PATH=' + os.path.join(LLVM_BUILD_DIR, 'bin/llvm-config'),
-+        '-DCMAKE_C_FLAGS=' + ' '.join(cflags),
-+        '-DCMAKE_CXX_FLAGS=' + ' '.join(cflags),
-+        '-DANDROID=1']
-+      RmCmakeCache('.')
-+      RunCommand(['cmake'] + android_args + [COMPILER_RT_DIR])
-+      RunCommand(['ninja', 'libclang_rt.asan-%s-android.so' % target_arch])
-+
-+      # And copy it into the main build tree.
-+      runtime = 'libclang_rt.asan-%s-android.so' % target_arch
-+      for root, _, files in os.walk(build_dir):
-+        if runtime in files:
-+          shutil.copy(os.path.join(root, runtime), asan_rt_lib_dst_dir)
-+
-   # Run tests.
-   if args.run_tests or use_head_revision:
-     os.chdir(LLVM_BUILD_DIR)
--    RunCommand(GetVSVersion().SetupScript('x64') +
--               ['&&', 'ninja', 'cr-check-all'])
-+    RunCommand(['ninja', 'cr-check-all'], msvc_arch='x64')
-   if args.run_tests:
-     os.chdir(LLVM_BUILD_DIR)
--    RunCommand(GetVSVersion().SetupScript('x64') +
--               ['&&', 'ninja', 'check-all'])
-+    RunCommand(['ninja', 'check-all'], msvc_arch='x64')
- 
-   WriteStampFile(PACKAGE_VERSION)
-   print 'Clang update was successful.'
-@@ -663,31 +743,6 @@
- 
- 
- def main():
--  if not sys.platform in ['win32', 'cygwin']:
--    # For non-Windows, fall back to update.sh.
--    # TODO(hans): Make update.py replace update.sh completely.
--
--    # This script is called by gclient. gclient opens its hooks subprocesses
--    # with (stdout=subprocess.PIPE, stderr=subprocess.STDOUT) and then does
--    # custom output processing that breaks printing '\r' characters for
--    # single-line updating status messages as printed by curl and wget.
--    # Work around this by setting stderr of the update.sh process to stdin (!):
--    # gclient doesn't redirect stdin, and while stdin itself is read-only, a
--    # dup()ed sys.stdin is writable, try
--    #   fd2 = os.dup(sys.stdin.fileno()); os.write(fd2, 'hi')
--    # TODO: Fix gclient instead, http://crbug.com/95350
--    if '--no-stdin-hack' in sys.argv:
--      sys.argv.remove('--no-stdin-hack')
--      stderr = None
--    else:
--      try:
--        stderr = os.fdopen(os.dup(sys.stdin.fileno()))
--      except:
--        stderr = sys.stderr
--    return subprocess.call(
--        [os.path.join(os.path.dirname(__file__), 'update.sh')] + sys.argv[1:],
--        stderr=stderr)
--
-   parser = argparse.ArgumentParser(description='Build Clang.')
-   parser.add_argument('--bootstrap', action='store_true',
-                       help='first build clang with CC, then with itself.')
-@@ -695,26 +750,24 @@
-                       help="run only if the script thinks clang is needed")
-   parser.add_argument('--force-local-build', action='store_true',
-                       help="don't try to download prebuild binaries")
-+  parser.add_argument('--gcc-toolchain', help='set the version for which gcc '
-+                      'version be used for building; --gcc-toolchain=/opt/foo '
-+                      'picks /opt/foo/bin/gcc')
-   parser.add_argument('--print-revision', action='store_true',
-                       help='print current clang revision and exit.')
-+  parser.add_argument('--print-clang-version', action='store_true',
-+                      help='print current clang version (e.g. x.y.z) and exit.')
-   parser.add_argument('--run-tests', action='store_true',
-                       help='run tests after building; only for local builds')
-   parser.add_argument('--tools', nargs='*',
-                       help='select which chrome tools to build',
-                       default=['plugins', 'blink_gc_plugin'])
--  parser.add_argument('--without-patches', action='store_false',
--                      help="don't apply patches (default)", dest='with_patches',
--                      default=True)
--
--  # For now, these flags are only used for the non-Windows flow, but argparser
--  # gets mad if it sees a flag it doesn't recognize.
--  parser.add_argument('--no-stdin-hack', action='store_true')
--
-+  parser.add_argument('--without-android', action='store_false',
-+                      help='don\'t build Android ASan runtime (linux only)',
-+                      dest='with_android',
-+                      default=sys.platform.startswith('linux'))
-   args = parser.parse_args()
- 
--  if re.search(r'\b(make_clang_dir)=', os.environ.get('GYP_DEFINES', '')):
--    print 'Skipping Clang update (make_clang_dir= was set in GYP_DEFINES).'
--    return 0
-   if args.if_needed:
-     is_clang_required = False
-     # clang is always used on Mac and Linux.
-@@ -730,8 +783,16 @@
-       is_clang_required = True
-     if not is_clang_required:
-       return 0
-+    if re.search(r'\b(make_clang_dir)=', os.environ.get('GYP_DEFINES', '')):
-+      print 'Skipping Clang update (make_clang_dir= was set in GYP_DEFINES).'
-+      return 0
-+
-+  if use_head_revision:
-+    # TODO(hans): Remove after the next roll.
-+    global VERSION
-+    VERSION = '3.9.0'
- 
--  global LLVM_WIN_REVISION, PACKAGE_VERSION
-+  global CLANG_REVISION, PACKAGE_VERSION
-   if args.print_revision:
-     if use_head_revision:
-       print GetSvnRevision(LLVM_DIR)
-@@ -739,6 +800,10 @@
-       print PACKAGE_VERSION
-     return 0
- 
-+  if args.print_clang_version:
-+    sys.stdout.write(VERSION)
-+    return 0
-+
-   # Don't buffer stdout, so that print statements are immediately flushed.
-   # Do this only after --print-revision has been handled, else we'll get
-   # an error message when this script is run from gn for some reason.
-@@ -747,12 +812,13 @@
-   if use_head_revision:
-     # Use a real revision number rather than HEAD to make sure that the stamp
-     # file logic works.
--    LLVM_WIN_REVISION = GetSvnRevision(LLVM_REPO_URL)
--    PACKAGE_VERSION = LLVM_WIN_REVISION + '-0'
-+    CLANG_REVISION = GetSvnRevision(LLVM_REPO_URL)
-+    PACKAGE_VERSION = CLANG_REVISION + '-0'
- 
-     args.force_local_build = True
--    # Skip local patches when using HEAD: they probably don't apply anymore.
--    args.with_patches = False
-+    if 'OS=android' not in os.environ.get('GYP_DEFINES', ''):
-+      # Only build the Android ASan rt on ToT bots when targetting Android.
-+      args.with_android = False
- 
-   return UpdateClang(args)
- 
diff --git a/pkgs/development/libraries/qt-5/5.6/qtwebengine/default.nix b/pkgs/development/libraries/qt-5/5.6/qtwebengine/default.nix
deleted file mode 100644
index 7ffc42fe7f68..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtwebengine/default.nix
+++ /dev/null
@@ -1,90 +0,0 @@
-{ qtSubmodule, qtquickcontrols, qtlocation, qtwebchannel
-
-, xlibs, libXcursor, libXScrnSaver, libXrandr, libXtst
-, fontconfig, freetype, harfbuzz, icu, dbus
-, zlib, minizip, libjpeg, libpng, libtiff, libwebp, libopus
-, jsoncpp, protobuf, libvpx, srtp, snappy, nss, libevent
-, alsaLib
-, libcap
-, pciutils
-
-, bison, flex, git, which, gperf
-, coreutils
-, pkgconfig, python2
-
-, lib, stdenv # lib.optional, needsPax
-}:
-
-qtSubmodule {
-  name = "qtwebengine";
-  qtInputs = [ qtquickcontrols qtlocation qtwebchannel ];
-  buildInputs = [ bison flex git which gperf ];
-  nativeBuildInputs = [ pkgconfig python2 coreutils ];
-  doCheck = true;
-
-  enableParallelBuilding = true;
-
-  preConfigure = ''
-    export MAKEFLAGS=-j$NIX_BUILD_CORES
-    substituteInPlace ./src/3rdparty/chromium/build/common.gypi \
-      --replace /bin/echo ${coreutils}/bin/echo
-    substituteInPlace ./src/3rdparty/chromium/v8/build/toolchain.gypi \
-      --replace /bin/echo ${coreutils}/bin/echo
-    substituteInPlace ./src/3rdparty/chromium/v8/build/standalone.gypi \
-      --replace /bin/echo ${coreutils}/bin/echo
-
-    # hardcode paths for which default path resolution does not work in nix
-    sed -i -e 's,\(static QString potentialResourcesPath =\).*,\1 QLatin1String("'$out'/resources");,' src/core/web_engine_library_info.cpp
-    sed -i -e 's,\(static QString processPath\),\1 = QLatin1String("'$out'/libexec/QtWebEngineProcess"),' src/core/web_engine_library_info.cpp
-    sed -i -e 's,\(static QString potentialLocalesPath =\).*,\1 QLatin1String("'$out'/translations/qtwebengine_locales");,' src/core/web_engine_library_info.cpp
-
-    # fix default SSL bundle location
-    sed -i -e 's,/cert.pem,/certs/ca-bundle.crt,' src/3rdparty/chromium/third_party/boringssl/src/crypto/x509/x509_def.c
-
-    configureFlags+="\
-        -plugindir $out/$qtPluginPrefix \
-        -qmldir $out/$qtQmlPrefix \
-        -docdir $out/$qtDocPrefix"
-  '';
-  propagatedBuildInputs = [
-    # Image formats
-    libjpeg libpng libtiff libwebp
-
-    # Video formats
-    srtp libvpx
-
-    # Audio formats
-    libopus
-
-    # Text rendering
-    harfbuzz icu
-  ]
-  ++ lib.optionals (!stdenv.isDarwin) [
-    dbus zlib minizip snappy nss protobuf jsoncpp libevent
-
-    # Audio formats
-    alsaLib
-
-    # Text rendering
-    fontconfig freetype
-
-    libcap
-    pciutils
-
-    # X11 libs
-    xlibs.xrandr libXScrnSaver libXcursor libXrandr xlibs.libpciaccess libXtst
-    xlibs.libXcomposite
-  ];
-  patches = [
-    ./chromium-clang-update-py.patch
-  ] ++ stdenv.lib.optional stdenv.needsPax ./qtwebengine-paxmark-mksnapshot.patch;
-
-  postInstall = ''
-    cat > $out/libexec/qt.conf <<EOF
-    [Paths]
-    Prefix = ..
-    EOF
-
-    paxmark m $out/libexec/QtWebEngineProcess
-  '';
-}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtwebkit/qtwebkit-icu-59.patch b/pkgs/development/libraries/qt-5/5.6/qtwebkit.patch
index add365b5dd64..da1658554e44 100644
--- a/pkgs/development/libraries/qt-5/5.6/qtwebkit/qtwebkit-icu-59.patch
+++ b/pkgs/development/libraries/qt-5/5.6/qtwebkit.patch
@@ -1,19 +1,5 @@
-From: Konstantin Tokarev <annulen@yandex.ru>
-Date: Thu, 4 May 2017 12:12:37 +0000 (+0300)
-Subject: Fix compilation with ICU 59
-X-Git-Url: https://codereview.qt-project.org/gitweb?p=qt%2Fqtwebkit.git;a=commitdiff_plain;h=bf172ae289a1348842005a9421797970f9b72060;hp=821eaaadc9d63d03aca65cf757230b520daaaa7c
-
-Fix compilation with ICU 59
-
-Upstream fix: https://bugs.webkit.org/show_bug.cgi?id=171612
-
-Task-number: QTBUG-60532
-Change-Id: I6014feea213aa70ebe40b09d9d1a03fd1ed3c843
-Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
----
-
 diff --git a/Source/JavaScriptCore/API/JSStringRef.cpp b/Source/JavaScriptCore/API/JSStringRef.cpp
-index 812f3d4..77a3fd0 100644
+index 812f3d413..77a3fd0f4 100644
 --- a/Source/JavaScriptCore/API/JSStringRef.cpp
 +++ b/Source/JavaScriptCore/API/JSStringRef.cpp
 @@ -37,7 +37,7 @@ using namespace WTF::Unicode;
@@ -44,7 +30,7 @@ index 812f3d4..77a3fd0 100644
  
  size_t JSStringGetMaximumUTF8CStringSize(JSStringRef string)
 diff --git a/Source/JavaScriptCore/runtime/DateConversion.cpp b/Source/JavaScriptCore/runtime/DateConversion.cpp
-index 0b57f01..05e2733 100644
+index 0b57f012d..05e27338b 100644
 --- a/Source/JavaScriptCore/runtime/DateConversion.cpp
 +++ b/Source/JavaScriptCore/runtime/DateConversion.cpp
 @@ -107,7 +107,8 @@ String formatDateTime(const GregorianDateTime& t, DateTimeFormat format, bool as
@@ -57,8 +43,21 @@ index 0b57f01..05e2733 100644
  #else
              struct tm gtm = t;
              char timeZoneName[70];
+diff --git a/Source/WTF/WTF.pri b/Source/WTF/WTF.pri
+index 1f4866d66..bb61e4ba3 100644
+--- a/Source/WTF/WTF.pri
++++ b/Source/WTF/WTF.pri
+@@ -12,7 +12,7 @@ mac {
+     # Mac OS does ship libicu but not the associated header files.
+     # Therefore WebKit provides adequate header files.
+     INCLUDEPATH = $${ROOT_WEBKIT_DIR}/Source/WTF/icu $$INCLUDEPATH
+-    LIBS += -licucore
++    LIBS += /usr/lib/libicucore.dylib
+ } else:!use?(wchar_unicode): {
+     win32 {
+         CONFIG(static, static|shared) {
 diff --git a/Source/WTF/wtf/TypeTraits.h b/Source/WTF/wtf/TypeTraits.h
-index 9df2c95..f5d6121 100644
+index 9df2c95cf..f5d6121fd 100644
 --- a/Source/WTF/wtf/TypeTraits.h
 +++ b/Source/WTF/wtf/TypeTraits.h
 @@ -72,6 +72,9 @@ namespace WTF {
@@ -71,8 +70,56 @@ index 9df2c95..f5d6121 100644
  #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED)
      template<> struct IsInteger<wchar_t>            { static const bool value = true; };
  #endif
+diff --git a/Source/WebCore/plugins/qt/PluginPackageQt.cpp b/Source/WebCore/plugins/qt/PluginPackageQt.cpp
+index a923d49aa..46772a4bb 100644
+--- a/Source/WebCore/plugins/qt/PluginPackageQt.cpp
++++ b/Source/WebCore/plugins/qt/PluginPackageQt.cpp
+@@ -136,7 +136,11 @@ static void initializeGtk(QLibrary* module = 0)
+         }
+     }
+ 
++#ifdef NIXPKGS_LIBGTK2
++    QLibrary library(QLatin1String(NIXPKGS_LIBGTK2), 0);
++#else
+     QLibrary library(QLatin1String("libgtk-x11-2.0"), 0);
++#endif
+     if (library.load()) {
+         typedef void *(*gtk_init_check_ptr)(int*, char***);
+         gtk_init_check_ptr gtkInitCheck = (gtk_init_check_ptr)library.resolve("gtk_init_check");
+diff --git a/Source/WebCore/plugins/qt/PluginViewQt.cpp b/Source/WebCore/plugins/qt/PluginViewQt.cpp
+index de06a2fea..86fe39ef1 100644
+--- a/Source/WebCore/plugins/qt/PluginViewQt.cpp
++++ b/Source/WebCore/plugins/qt/PluginViewQt.cpp
+@@ -697,7 +697,11 @@ static Display *getPluginDisplay()
+     // support gdk based plugins (like flash) that use a different X connection.
+     // The code below has the same effect as this one:
+     // Display *gdkDisplay = gdk_x11_display_get_xdisplay(gdk_display_get_default());
++#ifdef NIXPKGS_LIBGDK2
++    QLibrary library(QLatin1String(NIXPKGS_LIBGDK2), 0);
++#else
+     QLibrary library(QLatin1String("libgdk-x11-2.0"), 0);
++#endif
+     if (!library.load())
+         return 0;
+ 
+diff --git a/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp b/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
+index 8de65216b..38f5c05e5 100644
+--- a/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
++++ b/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
+@@ -53,7 +53,11 @@ static void messageHandler(QtMsgType type, const QMessageLogContext&, const QStr
+ 
+ static bool initializeGtk()
+ {
++#ifdef NIXPKGS_LIBGTK2
++    QLibrary gtkLibrary(QLatin1String(NIXPKGS_LIBGTK2), 0);
++#else
+     QLibrary gtkLibrary(QLatin1String("libgtk-x11-2.0"), 0);
++#endif
+     if (!gtkLibrary.load())
+         return false;
+     typedef void* (*gtk_init_ptr)(void*, void*);
 diff --git a/Source/WebKit2/Shared/API/c/WKString.cpp b/Source/WebKit2/Shared/API/c/WKString.cpp
-index cbac67d..23400a6 100644
+index cbac67dd8..23400a64e 100644
 --- a/Source/WebKit2/Shared/API/c/WKString.cpp
 +++ b/Source/WebKit2/Shared/API/c/WKString.cpp
 @@ -55,7 +55,7 @@ size_t WKStringGetLength(WKStringRef stringRef)
@@ -84,3 +131,19 @@ index cbac67d..23400a6 100644
  }
  
  size_t WKStringGetMaximumUTF8CStringSize(WKStringRef stringRef)
+diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
+index d734ff684..0f6ff63d1 100644
+--- a/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
++++ b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
+@@ -64,7 +64,11 @@ static Display* getPluginDisplay()
+     // The code below has the same effect as this one:
+     // Display *gdkDisplay = gdk_x11_display_get_xdisplay(gdk_display_get_default());
+ 
++#ifdef NIXPKGS_LIBGDK2
++    QLibrary library(QLatin1String(NIXPKGS_LIBGDK2), 0);
++#else
+     QLibrary library(QLatin1String("libgdk-x11-2.0"), 0);
++#endif
+     if (!library.load())
+         return 0;
+ 
diff --git a/pkgs/development/libraries/qt-5/5.6/qtwebkit/0001-dlopen-webkit-nsplugin.patch b/pkgs/development/libraries/qt-5/5.6/qtwebkit/0001-dlopen-webkit-nsplugin.patch
deleted file mode 100644
index 0eeacce1bc05..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtwebkit/0001-dlopen-webkit-nsplugin.patch
+++ /dev/null
@@ -1,53 +0,0 @@
-From 862ce7d357a3ec32683ac6ec7c0ebdc9346b44ba Mon Sep 17 00:00:00 2001
-From: Thomas Tuegel <ttuegel@gmail.com>
-Date: Sun, 23 Aug 2015 09:18:54 -0500
-Subject: [PATCH 1/3] dlopen webkit nsplugin
-
----
- Source/WebCore/plugins/qt/PluginPackageQt.cpp                        | 2 +-
- Source/WebCore/plugins/qt/PluginViewQt.cpp                           | 2 +-
- Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp | 2 +-
- 3 files changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/Source/WebCore/plugins/qt/PluginPackageQt.cpp b/Source/WebCore/plugins/qt/PluginPackageQt.cpp
-index a923d49..2731d05 100644
---- a/Source/WebCore/plugins/qt/PluginPackageQt.cpp
-+++ b/Source/WebCore/plugins/qt/PluginPackageQt.cpp
-@@ -136,7 +136,7 @@ static void initializeGtk(QLibrary* module = 0)
-         }
-     }
- 
--    QLibrary library(QLatin1String("libgtk-x11-2.0"), 0);
-+    QLibrary library(QLatin1String("@gtk@/lib/libgtk-x11-2.0"), 0);
-     if (library.load()) {
-         typedef void *(*gtk_init_check_ptr)(int*, char***);
-         gtk_init_check_ptr gtkInitCheck = (gtk_init_check_ptr)library.resolve("gtk_init_check");
-diff --git a/Source/WebCore/plugins/qt/PluginViewQt.cpp b/Source/WebCore/plugins/qt/PluginViewQt.cpp
-index de06a2f..363bde5 100644
---- a/Source/WebCore/plugins/qt/PluginViewQt.cpp
-+++ b/Source/WebCore/plugins/qt/PluginViewQt.cpp
-@@ -697,7 +697,7 @@ static Display *getPluginDisplay()
-     // support gdk based plugins (like flash) that use a different X connection.
-     // The code below has the same effect as this one:
-     // Display *gdkDisplay = gdk_x11_display_get_xdisplay(gdk_display_get_default());
--    QLibrary library(QLatin1String("libgdk-x11-2.0"), 0);
-+    QLibrary library(QLatin1String("@gdk_pixbuf@/lib/libgdk-x11-2.0"), 0);
-     if (!library.load())
-         return 0;
- 
-diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
-index d734ff6..62a2197 100644
---- a/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
-+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
-@@ -64,7 +64,7 @@ static Display* getPluginDisplay()
-     // The code below has the same effect as this one:
-     // Display *gdkDisplay = gdk_x11_display_get_xdisplay(gdk_display_get_default());
- 
--    QLibrary library(QLatin1String("libgdk-x11-2.0"), 0);
-+    QLibrary library(QLatin1String("@gdk_pixbuf@/libgdk-x11-2.0"), 0);
-     if (!library.load())
-         return 0;
- 
--- 
-2.5.0
-
diff --git a/pkgs/development/libraries/qt-5/5.6/qtwebkit/0002-dlopen-webkit-gtk.patch b/pkgs/development/libraries/qt-5/5.6/qtwebkit/0002-dlopen-webkit-gtk.patch
deleted file mode 100644
index bb5d1f74364c..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtwebkit/0002-dlopen-webkit-gtk.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From 6a407d30357c2551abceac75c82f4a1688e47437 Mon Sep 17 00:00:00 2001
-From: Thomas Tuegel <ttuegel@gmail.com>
-Date: Sun, 23 Aug 2015 09:19:16 -0500
-Subject: [PATCH 2/3] dlopen webkit gtk
-
----
- Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp b/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
-index 8de6521..0b25748 100644
---- a/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
-+++ b/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
-@@ -53,7 +53,7 @@ static void messageHandler(QtMsgType type, const QMessageLogContext&, const QStr
- 
- static bool initializeGtk()
- {
--    QLibrary gtkLibrary(QLatin1String("libgtk-x11-2.0"), 0);
-+    QLibrary gtkLibrary(QLatin1String("@gtk@/lib/libgtk-x11-2.0"), 0);
-     if (!gtkLibrary.load())
-         return false;
-     typedef void* (*gtk_init_ptr)(void*, void*);
--- 
-2.5.0
-
diff --git a/pkgs/development/libraries/qt-5/5.6/qtwebkit/0003-dlopen-webkit-udev.patch b/pkgs/development/libraries/qt-5/5.6/qtwebkit/0003-dlopen-webkit-udev.patch
deleted file mode 100644
index 19de7d99c85e..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtwebkit/0003-dlopen-webkit-udev.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From 864020dd47c3b6d532d9f26b82185904cf9324f2 Mon Sep 17 00:00:00 2001
-From: Thomas Tuegel <ttuegel@gmail.com>
-Date: Sun, 23 Aug 2015 09:19:29 -0500
-Subject: [PATCH 3/3] dlopen webkit udev
-
----
- Source/WebCore/platform/qt/GamepadsQt.cpp | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/Source/WebCore/platform/qt/GamepadsQt.cpp b/Source/WebCore/platform/qt/GamepadsQt.cpp
-index 60ff317..da8ac69 100644
---- a/Source/WebCore/platform/qt/GamepadsQt.cpp
-+++ b/Source/WebCore/platform/qt/GamepadsQt.cpp
-@@ -111,13 +111,12 @@ private:
-     bool load()
-     {
-         m_libUdev.setLoadHints(QLibrary::ResolveAllSymbolsHint);
--        m_libUdev.setFileNameAndVersion(QStringLiteral("udev"), 1);
-+        m_libUdev.setFileNameAndVersion(QLatin1String(NIXPKGS_LIBUDEV), 1);
-         m_loaded = m_libUdev.load();
-         if (resolveMethods())
-             return true;
- 
--        m_libUdev.setFileNameAndVersion(QStringLiteral("udev"), 0);
-+        m_libUdev.setFileNameAndVersion(QLatin1String(NIXPKGS_LIBUDEV), 0);
-         m_loaded = m_libUdev.load();
-         return resolveMethods();
-     }
--- 
-2.5.0
-
diff --git a/pkgs/development/libraries/qt-5/5.6/qtwebkit/default.nix b/pkgs/development/libraries/qt-5/5.6/qtwebkit/default.nix
deleted file mode 100644
index 664281aac311..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtwebkit/default.nix
+++ /dev/null
@@ -1,40 +0,0 @@
-{ qtSubmodule, stdenv, copyPathsToStore, lib
-, qtdeclarative, qtlocation, qtsensors
-, fontconfig, gdk_pixbuf, gtk2, libwebp, libxml2, libxslt
-, sqlite, systemd, glib, gst_all_1
-, bison2, flex, gdb, gperf, perl, pkgconfig, python2, ruby
-, darwin
-, substituteAll
-, flashplayerFix ? false
-}:
-
-let inherit (lib) optional optionals getLib; in
-
-qtSubmodule {
-  name = "qtwebkit";
-  qtInputs = [ qtdeclarative qtlocation qtsensors ];
-  buildInputs = [ fontconfig libwebp libxml2 libxslt sqlite glib gst_all_1.gstreamer gst_all_1.gst-plugins-base ]
-    ++ optionals (stdenv.isDarwin) (with darwin.apple_sdk.frameworks; [ OpenGL ]);
-  nativeBuildInputs = [
-    bison2 flex gdb gperf perl pkgconfig python2 ruby
-  ];
-
-  __impureHostDeps = optionals (stdenv.isDarwin) [
-    "/usr/lib/libicucore.dylib"
-  ];
-
-  patches =  copyPathsToStore (lib.readPathsFromFile ./. ./series);
-
-  NIX_CFLAGS_COMPILE =
-    optionals flashplayerFix
-      [
-        ''-DNIXPKGS_LIBGTK2="${getLib gtk2}/lib/libgtk-x11-2.0"''
-        ''-DNIXPKGS_LIBGDK2="${getLib gdk_pixbuf}/lib/libgdk-x11-2.0"''
-      ]
-    ++ optional (!stdenv.isDarwin) ''-DNIXPKGS_LIBUDEV="${getLib systemd}/lib/libudev"'';
-
-  # Hack to avoid TMPDIR in RPATHs.
-  preFixup = ''rm -rf "$(pwd)" && mkdir "$(pwd)" '';
-
-  meta.maintainers = with stdenv.lib.maintainers; [ abbradar periklis ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtwebkit/qtwebkit-dlopen-gtk.patch b/pkgs/development/libraries/qt-5/5.6/qtwebkit/qtwebkit-dlopen-gtk.patch
deleted file mode 100644
index e34eda592af7..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtwebkit/qtwebkit-dlopen-gtk.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-Index: qtwebkit-opensource-src-5.8.0/Source/WebCore/plugins/qt/PluginPackageQt.cpp
-===================================================================
---- qtwebkit-opensource-src-5.8.0.orig/Source/WebCore/plugins/qt/PluginPackageQt.cpp
-+++ qtwebkit-opensource-src-5.8.0/Source/WebCore/plugins/qt/PluginPackageQt.cpp
-@@ -136,7 +136,11 @@ static void initializeGtk(QLibrary* modu
-         }
-     }
- 
-+#ifdef NIXPKGS_LIBGTK2
-+    QLibrary library(QLatin1String(NIXPKGS_LIBGTK2), 0);
-+#else
-     QLibrary library(QLatin1String("libgtk-x11-2.0"), 0);
-+#endif
-     if (library.load()) {
-         typedef void *(*gtk_init_check_ptr)(int*, char***);
-         gtk_init_check_ptr gtkInitCheck = (gtk_init_check_ptr)library.resolve("gtk_init_check");
-Index: qtwebkit-opensource-src-5.8.0/Source/WebCore/plugins/qt/PluginViewQt.cpp
-===================================================================
---- qtwebkit-opensource-src-5.8.0.orig/Source/WebCore/plugins/qt/PluginViewQt.cpp
-+++ qtwebkit-opensource-src-5.8.0/Source/WebCore/plugins/qt/PluginViewQt.cpp
-@@ -697,7 +697,11 @@ static Display *getPluginDisplay()
-     // support gdk based plugins (like flash) that use a different X connection.
-     // The code below has the same effect as this one:
-     // Display *gdkDisplay = gdk_x11_display_get_xdisplay(gdk_display_get_default());
-+#ifdef NIXPKGS_LIBGDK2
-+    QLibrary library(QLatin1String(NIXPKGS_LIBGDK2), 0);
-+#else
-     QLibrary library(QLatin1String("libgdk-x11-2.0"), 0);
-+#endif
-     if (!library.load())
-         return 0;
- 
-Index: qtwebkit-opensource-src-5.8.0/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
-===================================================================
---- qtwebkit-opensource-src-5.8.0.orig/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
-+++ qtwebkit-opensource-src-5.8.0/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
-@@ -64,7 +64,11 @@ static Display* getPluginDisplay()
-     // The code below has the same effect as this one:
-     // Display *gdkDisplay = gdk_x11_display_get_xdisplay(gdk_display_get_default());
- 
-+#ifdef NIXPKGS_LIBGDK2
-+    QLibrary library(QLatin1String(NIXPKGS_LIBGDK2), 0);
-+#else
-     QLibrary library(QLatin1String("libgdk-x11-2.0"), 0);
-+#endif
-     if (!library.load())
-         return 0;
- 
-Index: qtwebkit-opensource-src-5.8.0/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
-===================================================================
---- qtwebkit-opensource-src-5.8.0.orig/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
-+++ qtwebkit-opensource-src-5.8.0/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
-@@ -53,7 +53,11 @@ static void messageHandler(QtMsgType typ
- 
- static bool initializeGtk()
- {
-+#ifdef NIXPKGS_LIBGTK2
-+    QLibrary gtkLibrary(QLatin1String(NIXPKGS_LIBGTK2), 0);
-+#else
-     QLibrary gtkLibrary(QLatin1String("libgtk-x11-2.0"), 0);
-+#endif
-     if (!gtkLibrary.load())
-         return false;
-     typedef void* (*gtk_init_ptr)(void*, void*);
diff --git a/pkgs/development/libraries/qt-5/5.6/qtwebkit/qtwebkit-dlopen-udev.patch b/pkgs/development/libraries/qt-5/5.6/qtwebkit/qtwebkit-dlopen-udev.patch
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtwebkit/qtwebkit-dlopen-udev.patch
+++ /dev/null
diff --git a/pkgs/development/libraries/qt-5/5.6/qtwebkit/qtwebkit-icucore-darwin.patch b/pkgs/development/libraries/qt-5/5.6/qtwebkit/qtwebkit-icucore-darwin.patch
deleted file mode 100644
index 63c653da94ef..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtwebkit/qtwebkit-icucore-darwin.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Index: qtwebkit-opensource-src-5.8.0/Source/WTF/WTF.pri
-===================================================================
---- qtwebkit-opensource-src-5.8.0.orig/Source/WTF/WTF.pri
-+++ qtwebkit-opensource-src-5.8.0/Source/WTF/WTF.pri
-@@ -12,7 +12,7 @@ mac {
-     # Mac OS does ship libicu but not the associated header files.
-     # Therefore WebKit provides adequate header files.
-     INCLUDEPATH = $${ROOT_WEBKIT_DIR}/Source/WTF/icu $$INCLUDEPATH
--    LIBS += -licucore
-+    LIBS += /usr/lib/libicucore.dylib
- } else:!use?(wchar_unicode): {
-     win32 {
-         CONFIG(static, static|shared) {
diff --git a/pkgs/development/libraries/qt-5/5.6/qtwebkit/series b/pkgs/development/libraries/qt-5/5.6/qtwebkit/series
deleted file mode 100644
index 7828e491c08b..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtwebkit/series
+++ /dev/null
@@ -1,4 +0,0 @@
-qtwebkit-dlopen-gtk.patch
-qtwebkit-dlopen-udev.patch
-qtwebkit-icucore-darwin.patch
-qtwebkit-icu-59.patch
diff --git a/pkgs/development/libraries/qt-5/5.6/qtwebsockets.nix b/pkgs/development/libraries/qt-5/5.6/qtwebsockets.nix
deleted file mode 100644
index fbdfbbcf0dbe..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtwebsockets.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ qtSubmodule, qtbase, qtdeclarative }:
-
-qtSubmodule {
-  name = "qtwebsockets";
-  qtInputs = [ qtbase qtdeclarative ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtx11extras.nix b/pkgs/development/libraries/qt-5/5.6/qtx11extras.nix
deleted file mode 100644
index a765161e2d7e..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtx11extras.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ qtSubmodule, qtbase }:
-
-qtSubmodule {
-  name = "qtx11extras";
-  qtInputs = [ qtbase ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtxmlpatterns.nix b/pkgs/development/libraries/qt-5/5.6/qtxmlpatterns.nix
deleted file mode 100644
index 9a8ddbba2bd2..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtxmlpatterns.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ qtSubmodule, qtbase }:
-
-qtSubmodule {
-  name = "qtxmlpatterns";
-  qtInputs = [ qtbase ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.6/srcs.nix b/pkgs/development/libraries/qt-5/5.6/srcs.nix
index 3f6c3ae66997..87d35a43d86b 100644
--- a/pkgs/development/libraries/qt-5/5.6/srcs.nix
+++ b/pkgs/development/libraries/qt-5/5.6/srcs.nix
@@ -3,259 +3,307 @@
 
 {
   qt3d = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qt3d-opensource-src-5.6.2.tar.xz";
-      sha256 = "0hg91j3brsbh75why6j0527z5myk1r9s7q9z45q6qp0gdvdqc5x2";
-      name = "qt3d-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qt3d-opensource-src-5.6.3.tar.xz";
+      sha256 = "1zkzc3wh2i89nacb55mbgl09zhrjbrxg9ir626bsvz15x4q5ml0h";
+      name = "qt3d-opensource-src-5.6.3.tar.xz";
     };
   };
   qtactiveqt = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtactiveqt-opensource-src-5.6.2.tar.xz";
-      sha256 = "1a3mai3d0l2a8gyjkjng1r7y9y27yppxc5rdzxsgc4kq58rflghw";
-      name = "qtactiveqt-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtactiveqt-opensource-src-5.6.3.tar.xz";
+      sha256 = "00qscqjpkv5ssrjdwwcjp9q1rqgp8lsdjjksjpyyg4v6knd74s0i";
+      name = "qtactiveqt-opensource-src-5.6.3.tar.xz";
     };
   };
   qtandroidextras = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtandroidextras-opensource-src-5.6.2.tar.xz";
-      sha256 = "164mkmzswqwjzhs9cwdq361yb60bx6is37740jglrjxgss1phmhr";
-      name = "qtandroidextras-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtandroidextras-opensource-src-5.6.3.tar.xz";
+      sha256 = "1v19p1pqcdicylj3hd2lbm5swqddydlv9aqmws3qwsc2vwh15d4n";
+      name = "qtandroidextras-opensource-src-5.6.3.tar.xz";
     };
   };
   qtbase = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtbase-opensource-src-5.6.2.tar.xz";
-      sha256 = "11z73qgzbyj1cwjdkng94cz46wam8frsw0bs705gx0nrqn9swvig";
-      name = "qtbase-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtbase-opensource-src-5.6.3.tar.xz";
+      sha256 = "18ad7cxln61276cm8h8hzm0y6svw6b5m5nbm1niif9pwlqlqbx7y";
+      name = "qtbase-opensource-src-5.6.3.tar.xz";
     };
   };
   qtcanvas3d = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtcanvas3d-opensource-src-5.6.2.tar.xz";
-      sha256 = "1bd01ag2p1445ffckyyi3sxi4vssflp95kmbrj99dy83dc04sn6p";
-      name = "qtcanvas3d-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtcanvas3d-opensource-src-5.6.3.tar.xz";
+      sha256 = "1zsn3xbsqapivfg80cldjlh7z07nf88958a7g6dm7figkwahx7p9";
+      name = "qtcanvas3d-opensource-src-5.6.3.tar.xz";
+    };
+  };
+  qtcharts = {
+    version = "2.1.3";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtcharts-opensource-src-2.1.3.tar.xz";
+      sha256 = "0bvxmqx7094mq1svrv1i1jp6vl87r2mp7k9n3gqpixjmqaqsjdpn";
+      name = "qtcharts-opensource-src-2.1.3.tar.xz";
     };
   };
   qtconnectivity = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtconnectivity-opensource-src-5.6.2.tar.xz";
-      sha256 = "1ygdmd7fh2fhhyv58zxl1lglr85iajs9gv6c0pv64gbhw0ijjrqv";
-      name = "qtconnectivity-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtconnectivity-opensource-src-5.6.3.tar.xz";
+      sha256 = "1pnc0zmps5iw5yhn2w0wl8cnyxhcy88d3rnaiv62ljpsccynwh7s";
+      name = "qtconnectivity-opensource-src-5.6.3.tar.xz";
+    };
+  };
+  qtdatavis3d = {
+    version = "1.2.3";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtdatavis3d-opensource-src-1.2.3.tar.xz";
+      sha256 = "0rqhr6s3fic91r6r1g2ws57j6ixvkh4zhcwh7savs1risx374vya";
+      name = "qtdatavis3d-opensource-src-1.2.3.tar.xz";
     };
   };
   qtdeclarative = {
-    version = "5.6.2";
+    version = "5.6.3";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtdeclarative-opensource-src-5.6.3.tar.xz";
+      sha256 = "1z4ih5jbydnk5dz0arhvwc54fjw7fynqx3rhm6f8lsyis19w0gzn";
+      name = "qtdeclarative-opensource-src-5.6.3.tar.xz";
+    };
+  };
+  qtdeclarative-render2d = {
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtdeclarative-opensource-src-5.6.2.tar.xz";
-      sha256 = "1nh989jp2gdp5bxa62n3g1whs2pzrl44sh4ca6x9icrnpj3ak1h0";
-      name = "qtdeclarative-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtdeclarative-render2d-opensource-src-5.6.3.tar.xz";
+      sha256 = "0r2qn8l3wh73cj75rq34zmc6rgl7v11c31pjdcsybad76nw5wb2p";
+      name = "qtdeclarative-render2d-opensource-src-5.6.3.tar.xz";
     };
   };
   qtdoc = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtdoc-opensource-src-5.6.2.tar.xz";
-      sha256 = "0s78c5bpj4lcx63x2y5a6scxv6sszvs4dlj4qy86jkwmm7m1wsgn";
-      name = "qtdoc-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtdoc-opensource-src-5.6.3.tar.xz";
+      sha256 = "11zhlry8hlql1q3pm4mf7qyky9i2irxqdrr9nr5m93wjyfsjbh7f";
+      name = "qtdoc-opensource-src-5.6.3.tar.xz";
     };
   };
   qtenginio = {
-    version = "1.6.2";
+    version = "1.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtenginio-opensource-src-1.6.2.tar.xz";
-      sha256 = "1hywpl1x9lbpqqjdw5wwwhx0gg0j7y260iqaz47anxaa466w7zwh";
-      name = "qtenginio-opensource-src-1.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtenginio-opensource-src-1.6.3.tar.xz";
+      sha256 = "04ir5pa8wpkc7cq08s0b69a0vhkr7479ixn3m2vww4jm6l5hc1yr";
+      name = "qtenginio-opensource-src-1.6.3.tar.xz";
     };
   };
   qtgraphicaleffects = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtgraphicaleffects-opensource-src-5.6.2.tar.xz";
-      sha256 = "0pp71gqfgbl5ra15jp8kr4p3sl9gs7cv4x6vjv9i5a3j5jn0z7qy";
-      name = "qtgraphicaleffects-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtgraphicaleffects-opensource-src-5.6.3.tar.xz";
+      sha256 = "1vcrm4jfmxjlw23dnwf45mzq2z5s4fz6j2znknr25ca5bqnmjhn7";
+      name = "qtgraphicaleffects-opensource-src-5.6.3.tar.xz";
     };
   };
   qtimageformats = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtimageformats-opensource-src-5.6.2.tar.xz";
-      sha256 = "1r27s5dy9c016ia5xgpbs7nfvmmrnd051dmsrv5r7hyscaz57cag";
-      name = "qtimageformats-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtimageformats-opensource-src-5.6.3.tar.xz";
+      sha256 = "1hs8b258xsbc4xb4844mas9ka54f5cfhhszblawwjxn9j0ydmr7g";
+      name = "qtimageformats-opensource-src-5.6.3.tar.xz";
     };
   };
   qtlocation = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtlocation-opensource-src-5.6.2.tar.xz";
-      sha256 = "0fnj51f6fll1z1xsfp3g73al70hsg993gh1k7aa0y8nhdqh9b2bs";
-      name = "qtlocation-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtlocation-opensource-src-5.6.3.tar.xz";
+      sha256 = "0rhlmyi5kkhl1bimaj1fmp36v7x5r79j3flgx9dv27rkric1ra5p";
+      name = "qtlocation-opensource-src-5.6.3.tar.xz";
     };
   };
   qtmacextras = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtmacextras-opensource-src-5.6.2.tar.xz";
-      sha256 = "05chq7dqgvlfzpqf1y9inxp0kx6hfzwbc5kswpp6gsnsyfln6ll5";
-      name = "qtmacextras-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtmacextras-opensource-src-5.6.3.tar.xz";
+      sha256 = "10v2a058yv6k76gg9dgpy4fc0xd652dknzsw5432gm8d9391382i";
+      name = "qtmacextras-opensource-src-5.6.3.tar.xz";
     };
   };
   qtmultimedia = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtmultimedia-opensource-src-5.6.2.tar.xz";
-      sha256 = "1bwcpc1s6yjvgpqbn22k4mdfjy9lhs89bbzwlgj5psy0qskp16nb";
-      name = "qtmultimedia-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtmultimedia-opensource-src-5.6.3.tar.xz";
+      sha256 = "0ihvbv0ldravbrx6406ps0z8y6521iz6h58n5ws44xq3m2g06dmf";
+      name = "qtmultimedia-opensource-src-5.6.3.tar.xz";
+    };
+  };
+  qtpurchasing = {
+    version = "5.6.3";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtpurchasing-opensource-src-5.6.3.tar.xz";
+      sha256 = "0lf269jzd6y4x5bxjwgz9dpw7hxmc6sp39qpxwlswd505cf0wgd7";
+      name = "qtpurchasing-opensource-src-5.6.3.tar.xz";
     };
   };
   qtquickcontrols = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtquickcontrols-opensource-src-5.6.2.tar.xz";
-      sha256 = "0b0h8svlzvq23kcmam7ng697bzcq4x3haymmn7gj40p15clz5l2y";
-      name = "qtquickcontrols-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtquickcontrols-opensource-src-5.6.3.tar.xz";
+      sha256 = "13nvn0d2i4lf4igc1xqf7m98n4j66az1bi02zzv5m18vyb40zfri";
+      name = "qtquickcontrols-opensource-src-5.6.3.tar.xz";
     };
   };
   qtquickcontrols2 = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtquickcontrols2-opensource-src-5.6.2.tar.xz";
-      sha256 = "1hgydll95by0rvfpv3sprxq0hkdrpacynaaq2jzaw0a7m881gp09";
-      name = "qtquickcontrols2-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtquickcontrols2-opensource-src-5.6.3.tar.xz";
+      sha256 = "1jw1zykrx8aa9p781hc74h9za7lnnm4ifpdyqa4ahbdy193phl7c";
+      name = "qtquickcontrols2-opensource-src-5.6.3.tar.xz";
     };
   };
   qtscript = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtscript-opensource-src-5.6.2.tar.xz";
-      sha256 = "03hi2j64l0mgs8p0w1jaz53zsa4lfpbgskydaxxiiqnaf6rgcvp0";
-      name = "qtscript-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtscript-opensource-src-5.6.3.tar.xz";
+      sha256 = "12dkf2s1l9y9cwdyayg2mpnwvx14kq93pymp3iy3fw1s1vfj11zh";
+      name = "qtscript-opensource-src-5.6.3.tar.xz";
     };
   };
   qtsensors = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtsensors-opensource-src-5.6.2.tar.xz";
-      sha256 = "09rl0njijl3cgh6l3pfij2rhnsg10axkl37llkbz1wmlma0r1057";
-      name = "qtsensors-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtsensors-opensource-src-5.6.3.tar.xz";
+      sha256 = "0ws96fmk5zz9szrw9x1dwa6gnv9rpv1q0h9ax9z5m1kiapfd80km";
+      name = "qtsensors-opensource-src-5.6.3.tar.xz";
     };
   };
   qtserialbus = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtserialbus-opensource-src-5.6.2.tar.xz";
-      sha256 = "09pqr9f6kl3wq4858vksbzxnrrnqxblivmayjf126lwi2q4n14mk";
-      name = "qtserialbus-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtserialbus-opensource-src-5.6.3.tar.xz";
+      sha256 = "17lskz4r549hc02riv0a3jdjbyaq4y4a94xd3jhy454lhzirpj3i";
+      name = "qtserialbus-opensource-src-5.6.3.tar.xz";
     };
   };
   qtserialport = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtserialport-opensource-src-5.6.2.tar.xz";
-      sha256 = "0xpkjkn6w0g3p7hmm12b2c96f7q98rmk2dcn321x4arcmldjhxmg";
-      name = "qtserialport-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtserialport-opensource-src-5.6.3.tar.xz";
+      sha256 = "06mfkd88rcn4p8pfzsyqbfg956vwwcql0khchjgx3bh34zp1yb88";
+      name = "qtserialport-opensource-src-5.6.3.tar.xz";
     };
   };
   qtsvg = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtsvg-opensource-src-5.6.2.tar.xz";
-      sha256 = "0kmwr3fphs7ddgxmqzy53f8p2hbp1gfmjdaig5vswc8vcszn38zp";
-      name = "qtsvg-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtsvg-opensource-src-5.6.3.tar.xz";
+      sha256 = "1v6wz8fcgsh4lfv68bhavms0l1z3mcn8vggakc3m8rdl2wsih3qh";
+      name = "qtsvg-opensource-src-5.6.3.tar.xz";
     };
   };
   qttools = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qttools-opensource-src-5.6.2.tar.xz";
-      sha256 = "1dz1i5wwhgb9li095mnmc33mwpbd8nf7sdrc2x3pl9c6hwqv8ayv";
-      name = "qttools-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qttools-opensource-src-5.6.3.tar.xz";
+      sha256 = "09krlrgcglylsv7xx4r681v7zmyy6nr8j18482skrmsqh21vlqqs";
+      name = "qttools-opensource-src-5.6.3.tar.xz";
     };
   };
   qttranslations = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qttranslations-opensource-src-5.6.2.tar.xz";
-      sha256 = "08d4xyk7njkdbd3m48dzmvdm8ma3s4x8h4jm1ip20wqngi23nybx";
-      name = "qttranslations-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qttranslations-opensource-src-5.6.3.tar.xz";
+      sha256 = "1avcfymi9bxk02i1rqh89c6hnvf4bg9qry94z29g1r62c80lxvbd";
+      name = "qttranslations-opensource-src-5.6.3.tar.xz";
+    };
+  };
+  qtvirtualkeyboard = {
+    version = "2.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtvirtualkeyboard-opensource-src-2.0.tar.xz";
+      sha256 = "1v0saqz76h9gnb13b8mri4jq93i7f1gr7hj81zj3vz433s2klm0x";
+      name = "qtvirtualkeyboard-opensource-src-2.0.tar.xz";
     };
   };
   qtwayland = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtwayland-opensource-src-5.6.2.tar.xz";
-      sha256 = "11kciqnqfyzjfnx1m666g35v98jdazsg083h9fv2g5kiyjck2p03";
-      name = "qtwayland-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtwayland-opensource-src-5.6.3.tar.xz";
+      sha256 = "18ys14fzjybx02aj85vyqzsp89ypv2c6vfpklxzslwyvn9w54iss";
+      name = "qtwayland-opensource-src-5.6.3.tar.xz";
     };
   };
   qtwebchannel = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtwebchannel-opensource-src-5.6.2.tar.xz";
-      sha256 = "0lhskzqcijz9x6h8p80ff5dd6ni7zqm23nzljdqbggaibzpzs3kh";
-      name = "qtwebchannel-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtwebchannel-opensource-src-5.6.3.tar.xz";
+      sha256 = "04q7wmdnv4pskah2s5nnrzbsb207fvkj333m69wkqrc64anb1ccf";
+      name = "qtwebchannel-opensource-src-5.6.3.tar.xz";
     };
   };
   qtwebengine = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtwebengine-opensource-src-5.6.2.tar.xz";
-      sha256 = "0h4pyc7r2fx8qsiw3663jd1hg1fid5yv7wil06njpcm8w541c2ig";
-      name = "qtwebengine-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtwebengine-opensource-src-5.6.3.tar.xz";
+      sha256 = "19xpvnjwrjpj6wx7sy1cs1r1ibnh5hqfk9w9rnqf5h7n77xnk780";
+      name = "qtwebengine-opensource-src-5.6.3.tar.xz";
     };
   };
   qtwebkit = {
-    version = "5.6.2";
+    version = "5.6.3";
+    src = fetchurl {
+      url = "${mirror}/community_releases/5.6/5.6.3/qtwebkit-opensource-src-5.6.3.tar.xz";
+      sha256 = "15iqgaw3jznfq1mdg1mmr7pn8w3qhw964h5m36vg3ywqayr6p309";
+      name = "qtwebkit-opensource-src-5.6.3.tar.xz";
+    };
+  };
+  qtwebkit-examples = {
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/community_releases/5.6/5.6.2/qtwebkit-opensource-src-5.6.2.tar.xz";
-      sha256 = "0rirszy092pmdvy4vzqkk4p9wwxv8qx4zkp84rxkd5ah3j5np2jj";
-      name = "qtwebkit-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/community_releases/5.6/5.6.3/qtwebkit-examples-opensource-src-5.6.3.tar.xz";
+      sha256 = "17hnls8j4wz0kyzzq7m3105lqz71zsxr0hya7i23pl4qc8affv1d";
+      name = "qtwebkit-examples-opensource-src-5.6.3.tar.xz";
     };
   };
   qtwebsockets = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtwebsockets-opensource-src-5.6.2.tar.xz";
-      sha256 = "0ddsnnp3sn423ryqqa1060cqlbdcp7ncj3zhabifaswfzyxx9n9w";
-      name = "qtwebsockets-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtwebsockets-opensource-src-5.6.3.tar.xz";
+      sha256 = "1sr8q0wqw4xwcdl6nvnv04pcjxb0fbs4ywrkcghdz2bcc52r0hx2";
+      name = "qtwebsockets-opensource-src-5.6.3.tar.xz";
     };
   };
   qtwebview = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtwebview-opensource-src-5.6.2.tar.xz";
-      sha256 = "1mjix4w71x1w86ykcdhsl7gg7xv9dn2pw6yiaxrp6pxvvk73cyjs";
-      name = "qtwebview-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtwebview-opensource-src-5.6.3.tar.xz";
+      sha256 = "076q9g2ca41v8lyhn7354rs8w2ca0wp2hsxc76zprzghi5p4b2kn";
+      name = "qtwebview-opensource-src-5.6.3.tar.xz";
     };
   };
   qtwinextras = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtwinextras-opensource-src-5.6.2.tar.xz";
-      sha256 = "1s375b1bf8cqs73mg8chwvj0npr01hpyrwv75srqnxkp61avi1gr";
-      name = "qtwinextras-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtwinextras-opensource-src-5.6.3.tar.xz";
+      sha256 = "0nmhvd1g18w12q6i8s87aq7rwikcn1m8m9m0a02l3p22xvimkxzf";
+      name = "qtwinextras-opensource-src-5.6.3.tar.xz";
     };
   };
   qtx11extras = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtx11extras-opensource-src-5.6.2.tar.xz";
-      sha256 = "1v8cnhas3rynqz7b8wryry2qhblrnmnd3v39gdki1hzfz8fdxzvi";
-      name = "qtx11extras-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtx11extras-opensource-src-5.6.3.tar.xz";
+      sha256 = "0zv70z5z48wlg0q2zd7nbp7i0wimdcalns6yg0mjp7v2w2b8wyhy";
+      name = "qtx11extras-opensource-src-5.6.3.tar.xz";
     };
   };
   qtxmlpatterns = {
-    version = "5.6.2";
+    version = "5.6.3";
     src = fetchurl {
-      url = "${mirror}/official_releases/qt/5.6/5.6.2/submodules/qtxmlpatterns-opensource-src-5.6.2.tar.xz";
-      sha256 = "1k428wj8iffm6rrbvwbw0hksr99xqsxww8iahbk8r38qpzpg6vbw";
-      name = "qtxmlpatterns-opensource-src-5.6.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.6/5.6.3/submodules/qtxmlpatterns-opensource-src-5.6.3.tar.xz";
+      sha256 = "1xjimf88j2s5jrqgr9ki82zmis8r979rrzq4k6dxw43k1ngzyqd4";
+      name = "qtxmlpatterns-opensource-src-5.6.3.tar.xz";
     };
   };
 }
diff --git a/pkgs/development/libraries/qt-5/5.9/default.nix b/pkgs/development/libraries/qt-5/5.9/default.nix
index 8f9be38fc882..e109fe447aa2 100644
--- a/pkgs/development/libraries/qt-5/5.9/default.nix
+++ b/pkgs/development/libraries/qt-5/5.9/default.nix
@@ -6,9 +6,9 @@ Before a major version update, make a copy of this directory. (We like to
 keep the old version around for a short time after major updates.) Add a
 top-level attribute to `top-level/all-packages.nix`.
 
-1. Update the URL in `maintainers/scripts/generate-qt.sh`.
+1. Update the URL in `pkgs/development/libraries/qt-5/$VERSION/fetch.sh`.
 2. From the top of the Nixpkgs tree, run
-   `./maintainers/scripts/generate-qt.sh > pkgs/development/libraries/qt-5/$VERSION/srcs.nix`.
+   `./maintainers/scripts/fetch-kde-qt.sh > pkgs/development/libraries/qt-5/$VERSION/srcs.nix`.
 3. Update `qtCompatVersion` below if the minor version number changes.
 4. Check that the new packages build correctly.
 5. Commit the changes and open a pull request.
@@ -18,13 +18,13 @@ top-level attribute to `top-level/all-packages.nix`.
 {
   newScope,
   stdenv, fetchurl, makeSetupHook, makeWrapper,
-  bison, cups ? null, harfbuzz, mesa, perl,
+  bison, cups ? null, harfbuzz, libGL, perl,
   gstreamer, gst-plugins-base, gtk3, dconf,
 
   # options
   developerBuild ? false,
   decryptSslTraffic ? false,
-  debug ? null,
+  debug ? false,
 }:
 
 with stdenv.lib;
@@ -36,110 +36,88 @@ let
   mirror = "http://download.qt.io";
   srcs = import ./srcs.nix { inherit fetchurl; inherit mirror; };
 
-  mkDerivation = args:
-    stdenv.mkDerivation (args // {
-
-      qmakeFlags =
-        (args.qmakeFlags or [])
-        ++ optional (debug != null)
-           (if debug then "CONFIG+=debug" else "CONFIG+=release");
-
-      cmakeFlags =
-        (args.cmakeFlags or [])
-        ++ [ "-DBUILD_TESTING=OFF" ]
-        ++ optional (debug != null)
-           (if debug then "-DCMAKE_BUILD_TYPE=Debug"
-                     else "-DCMAKE_BUILD_TYPE=Release");
-
-      enableParallelBuilding = args.enableParallelBuilding or true;
-
-    });
-
-  qtSubmodule = args:
-    let
-      inherit (args) name;
-      version = args.version or srcs."${name}".version;
-      src = args.src or srcs."${name}".src;
-    in mkDerivation (args // {
-      name = "${name}-${version}";
-      inherit src;
-
-      propagatedBuildInputs = args.qtInputs ++ (args.propagatedBuildInputs or []);
-      nativeBuildInputs =
-        (args.nativeBuildInputs or [])
-        ++ [ perl self.qmake ];
-
-      NIX_QT_SUBMODULE = args.NIX_QT_SUBMODULE or true;
-
-      outputs = args.outputs or [ "out" "dev" ];
-      setOutputFlags = args.setOutputFlags or false;
-
-      setupHook = ../qtsubmodule-setup-hook.sh;
-
-      meta = {
-        homepage = http://www.qt.io;
-        description = "A cross-platform application framework for C++";
-        license = with licenses; [ fdl13 gpl2 lgpl21 lgpl3 ];
-        maintainers = with maintainers; [ qknight ttuegel periklis ];
-        platforms = platforms.unix;
-      } // (args.meta or {});
-    });
+  patches = {
+    qtbase = [ ./qtbase.patch ] ++ optional stdenv.isDarwin ./qtbase-darwin.patch;
+    qtdeclarative = [ ./qtdeclarative.patch ];
+    qtscript = [ ./qtscript.patch ];
+    qtserialport = [ ./qtserialport.patch ];
+    qttools = [ ./qttools.patch ];
+    qtwebengine = optional stdenv.needsPax ./qtwebengine-paxmark-mksnapshot.patch;
+    qtwebkit = [ ./qtwebkit.patch ];
+  };
+
+  mkDerivation =
+    import ../mkDerivation.nix
+    { inherit stdenv; inherit (stdenv) lib; }
+    { inherit debug; };
+
+  qtModule =
+    import ../qtModule.nix
+    { inherit mkDerivation perl; inherit (stdenv) lib; }
+    { inherit self srcs patches; };
 
   addPackages = self: with self;
     let
-      callPackage = self.newScope { inherit qtCompatVersion qtSubmodule srcs; };
+      callPackage = self.newScope { inherit qtCompatVersion qtModule srcs; };
     in {
 
       inherit mkDerivation;
 
-      qtbase = callPackage ./qtbase {
+      qtbase = callPackage ../modules/qtbase.nix {
         inherit (srcs.qtbase) src version;
-        inherit bison cups harfbuzz mesa;
-        inherit dconf gtk3;
+        patches = patches.qtbase;
+        inherit bison cups harfbuzz libGL;
+        withGtk3 = true; inherit dconf gtk3;
         inherit developerBuild decryptSslTraffic;
       };
 
-      qtcharts = callPackage ./qtcharts.nix {};
-      qtconnectivity = callPackage ./qtconnectivity.nix {};
-      qtdeclarative = callPackage ./qtdeclarative {};
-      qtdoc = callPackage ./qtdoc.nix {};
-      qtgraphicaleffects = callPackage ./qtgraphicaleffects.nix {};
-      qtimageformats = callPackage ./qtimageformats.nix {};
-      qtlocation = callPackage ./qtlocation.nix {};
-      qtmacextras = callPackage ./qtmacextras.nix {};
-      qtmultimedia = callPackage ./qtmultimedia.nix {
+      qtcharts = callPackage ../modules/qtcharts.nix {};
+      qtconnectivity = callPackage ../modules/qtconnectivity.nix {};
+      qtdeclarative = callPackage ../modules/qtdeclarative.nix {};
+      qtdoc = callPackage ../modules/qtdoc.nix {};
+      qtgraphicaleffects = callPackage ../modules/qtgraphicaleffects.nix {};
+      qtimageformats = callPackage ../modules/qtimageformats.nix {};
+      qtlocation = callPackage ../modules/qtlocation.nix {};
+      qtmacextras = callPackage ../modules/qtmacextras.nix {};
+      qtmultimedia = callPackage ../modules/qtmultimedia.nix {
         inherit gstreamer gst-plugins-base;
       };
       qtquick1 = null;
-      qtquickcontrols = callPackage ./qtquickcontrols.nix {};
-      qtquickcontrols2 = callPackage ./qtquickcontrols2.nix {};
-      qtscript = callPackage ./qtscript {};
-      qtsensors = callPackage ./qtsensors.nix {};
-      qtserialport = callPackage ./qtserialport {};
-      qtsvg = callPackage ./qtsvg.nix {};
-      qttools = callPackage ./qttools {};
-      qttranslations = callPackage ./qttranslations.nix {};
-      qtwayland = callPackage ./qtwayland.nix {};
-      qtwebchannel = callPackage ./qtwebchannel.nix {};
-      qtwebengine = callPackage ./qtwebengine {};
-      qtwebkit = callPackage ./qtwebkit {};
-      qtwebsockets = callPackage ./qtwebsockets.nix {};
-      qtx11extras = callPackage ./qtx11extras.nix {};
-      qtxmlpatterns = callPackage ./qtxmlpatterns.nix {};
+      qtquickcontrols = callPackage ../modules/qtquickcontrols.nix {};
+      qtquickcontrols2 = callPackage ../modules/qtquickcontrols2.nix {};
+      qtscript = callPackage ../modules/qtscript.nix {};
+      qtsensors = callPackage ../modules/qtsensors.nix {};
+      qtserialport = callPackage ../modules/qtserialport.nix {};
+      qtsvg = callPackage ../modules/qtsvg.nix {};
+      qttools = callPackage ../modules/qttools.nix {};
+      qttranslations = callPackage ../modules/qttranslations.nix {};
+      qtvirtualkeyboard = callPackage ../modules/qtvirtualkeyboard.nix {};
+      qtwayland = callPackage ../modules/qtwayland.nix {};
+      qtwebchannel = callPackage ../modules/qtwebchannel.nix {};
+      qtwebengine = callPackage ../modules/qtwebengine.nix {};
+      qtwebkit = callPackage ../modules/qtwebkit.nix {};
+      qtwebsockets = callPackage ../modules/qtwebsockets.nix {};
+      qtx11extras = callPackage ../modules/qtx11extras.nix {};
+      qtxmlpatterns = callPackage ../modules/qtxmlpatterns.nix {};
 
       env = callPackage ../qt-env.nix {};
-      full = env "qt-${qtbase.version}" ([
+      full = env "qt-full-${qtbase.version}" ([
         qtcharts qtconnectivity qtdeclarative qtdoc qtgraphicaleffects
-        qtimageformats qtlocation qtmultimedia qtquickcontrols qtscript
-        qtsensors qtserialport qtsvg qttools qttranslations qtwebsockets
+        qtimageformats qtlocation qtmultimedia qtquickcontrols qtquickcontrols2
+        qtscript qtsensors qtserialport qtsvg qttools qttranslations
+        qtvirtualkeyboard qtwebchannel qtwebengine qtwebkit qtwebsockets
         qtx11extras qtxmlpatterns
       ] ++ optional (!stdenv.isDarwin) qtwayland
         ++ optional (stdenv.isDarwin) qtmacextras);
 
       qmake = makeSetupHook {
         deps = [ self.qtbase.dev ];
-        substitutions = { inherit (stdenv) isDarwin; };
-      } ../qmake-hook.sh;
+        substitutions = {
+          inherit (stdenv) isDarwin;
+          qtbase_dev = self.qtbase.dev;
+          fix_qt_builtin_paths = ../hooks/fix-qt-builtin-paths.sh;
+        };
+      } ../hooks/qmake-hook.sh;
     };
 
    self = makeScope newScope addPackages;
diff --git a/pkgs/development/libraries/qt-5/5.9/fetch.sh b/pkgs/development/libraries/qt-5/5.9/fetch.sh
index d026d2a922a0..103fa4e09abc 100644
--- a/pkgs/development/libraries/qt-5/5.9/fetch.sh
+++ b/pkgs/development/libraries/qt-5/5.9/fetch.sh
@@ -1,2 +1,2 @@
-WGET_ARGS=( https://download.qt.io/archive/qt/5.9/5.9.2/submodules/ \
+WGET_ARGS=( http://download.qt.io/official_releases/qt/5.9/5.9.3/submodules/ \
             -A '*.tar.xz' )
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase/darwin-cf.patch b/pkgs/development/libraries/qt-5/5.9/qtbase-darwin.patch
index 3e6e0e5101a1..1c3a9b05cb24 100644
--- a/pkgs/development/libraries/qt-5/5.9/qtbase/darwin-cf.patch
+++ b/pkgs/development/libraries/qt-5/5.9/qtbase-darwin.patch
@@ -1,3 +1,16 @@
+diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
+index 66baf16..89794ef 100644
+--- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
++++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
+@@ -830,7 +830,7 @@ void QCoreTextFontEngine::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, gl
+ 
+ QFixed QCoreTextFontEngine::emSquareSize() const
+ {
+-    return QFixed::QFixed(int(CTFontGetUnitsPerEm(ctfont)));
++    return QFixed(int(CTFontGetUnitsPerEm(ctfont)));
+ }
+ 
+ QFontEngine *QCoreTextFontEngine::cloneWithSize(qreal pixelSize) const
 diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm
 index 341d3bc..3368234 100644
 --- a/src/plugins/bearer/corewlan/qcorewlanengine.mm
@@ -20,9 +33,8 @@ index 341d3bc..3368234 100644
      for (NSString *ifName in wifiInterfaces) {
              scanThread->interfaceName = QString::fromNSString(ifName);
              scanThread->start();
- QString TableGenerator::findComposeFile()
 diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
-index 59b7637..b91139d 100644
+index 5cd4beb..84919e6 100644
 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm
 +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
 @@ -320,7 +320,7 @@ static void qt_closePopups()
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase.patch b/pkgs/development/libraries/qt-5/5.9/qtbase.patch
new file mode 100644
index 000000000000..086ddf4fe3e7
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.9/qtbase.patch
@@ -0,0 +1,1141 @@
+diff --git a/mkspecs/common/mac.conf b/mkspecs/common/mac.conf
+index 5208379f9a..92fe29a0ac 100644
+--- a/mkspecs/common/mac.conf
++++ b/mkspecs/common/mac.conf
+@@ -23,7 +23,7 @@ QMAKE_INCDIR_OPENGL     = \
+ 
+ QMAKE_FIX_RPATH         = install_name_tool -id
+ 
+-QMAKE_LFLAGS_RPATH      = -Wl,-rpath,
++QMAKE_LFLAGS_RPATH      =
+ QMAKE_LFLAGS_GCSECTIONS = -Wl,-dead_strip
+ 
+ QMAKE_LFLAGS_REL_RPATH  =
+diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
+index bb5083c925..77034f9bb6 100644
+--- a/mkspecs/features/create_cmake.prf
++++ b/mkspecs/features/create_cmake.prf
+@@ -21,7 +21,7 @@ load(cmake_functions)
+ # at cmake time whether package has been found via a symlink, and correct
+ # that to an absolute path. This is only done for installations to
+ # the /usr or / prefix.
+-CMAKE_INSTALL_LIBS_DIR = $$cmakeTargetPath($$[QT_INSTALL_LIBS])
++CMAKE_INSTALL_LIBS_DIR = $$cmakeTargetPath($$NIX_OUTPUT_OUT/lib/)
+ contains(CMAKE_INSTALL_LIBS_DIR, ^(/usr)?/lib(64)?.*): CMAKE_USR_MOVE_WORKAROUND = $$CMAKE_INSTALL_LIBS_DIR
+ 
+ CMAKE_OUT_DIR = $$MODULE_BASE_OUTDIR/lib/cmake
+@@ -47,47 +47,22 @@ split_incpath {
+         $$cmake_extra_source_includes.output
+ }
+ 
+-CMAKE_INCLUDE_DIR = $$cmakeRelativePath($$[QT_INSTALL_HEADERS], $$[QT_INSTALL_PREFIX])
+-contains(CMAKE_INCLUDE_DIR, "^\\.\\./.*") {
+-    CMAKE_INCLUDE_DIR = $$[QT_INSTALL_HEADERS]/
+-    CMAKE_INCLUDE_DIR_IS_ABSOLUTE = True
+-}
++CMAKE_INCLUDE_DIR = $$NIX_OUTPUT_DEV/include/
++CMAKE_INCLUDE_DIR_IS_ABSOLUTE = True
+ 
+ !exists($$first(QT.$${MODULE}_private.includes)): CMAKE_NO_PRIVATE_INCLUDES = true
+ 
+-CMAKE_LIB_DIR = $$cmakeRelativePath($$[QT_INSTALL_LIBS], $$[QT_INSTALL_PREFIX])
+-contains(CMAKE_LIB_DIR,"^\\.\\./.*") {
+-    CMAKE_LIB_DIR = $$[QT_INSTALL_LIBS]/
+-    CMAKE_LIB_DIR_IS_ABSOLUTE = True
+-} else {
+-    CMAKE_RELATIVE_INSTALL_LIBS_DIR = $$cmakeRelativePath($$[QT_INSTALL_PREFIX], $$[QT_INSTALL_LIBS])
+-    # We need to go up another two levels because the CMake files are
+-    # installed in $${CMAKE_LIB_DIR}/cmake/Qt5$${CMAKE_MODULE_NAME}
+-    CMAKE_RELATIVE_INSTALL_DIR = "$${CMAKE_RELATIVE_INSTALL_LIBS_DIR}../../"
+-}
++CMAKE_LIB_DIR = $$NIX_OUTPUT_OUT/lib/
++CMAKE_LIB_DIR_IS_ABSOLUTE = True
+ 
+-CMAKE_BIN_DIR = $$cmakeRelativePath($$[QT_HOST_BINS], $$[QT_INSTALL_PREFIX])
+-contains(CMAKE_BIN_DIR, "^\\.\\./.*") {
+-    CMAKE_BIN_DIR = $$[QT_HOST_BINS]/
+-    CMAKE_BIN_DIR_IS_ABSOLUTE = True
+-}
++CMAKE_BIN_DIR = $$NIX_OUTPUT_BIN/bin/
++CMAKE_BIN_DIR_IS_ABSOLUTE = True
+ 
+-CMAKE_PLUGIN_DIR = $$cmakeRelativePath($$[QT_INSTALL_PLUGINS], $$[QT_INSTALL_PREFIX])
+-contains(CMAKE_PLUGIN_DIR, "^\\.\\./.*") {
+-    CMAKE_PLUGIN_DIR = $$[QT_INSTALL_PLUGINS]/
+-    CMAKE_PLUGIN_DIR_IS_ABSOLUTE = True
+-}
++CMAKE_PLUGIN_DIR = $$NIX_OUTPUT_PLUGIN/
++CMAKE_PLUGIN_DIR_IS_ABSOLUTE = True
+ 
+-win32:!static:!staticlib {
+-    CMAKE_DLL_DIR = $$cmakeRelativePath($$[QT_INSTALL_BINS], $$[QT_INSTALL_PREFIX])
+-    contains(CMAKE_DLL_DIR, "^\\.\\./.*") {
+-        CMAKE_DLL_DIR = $$[QT_INSTALL_BINS]/
+-        CMAKE_DLL_DIR_IS_ABSOLUTE = True
+-    }
+-} else {
+-    CMAKE_DLL_DIR = $$CMAKE_LIB_DIR
+-    CMAKE_DLL_DIR_IS_ABSOLUTE = $$CMAKE_LIB_DIR_IS_ABSOLUTE
+-}
++CMAKE_DLL_DIR = $$NIX_OUTPUT_OUT/lib/
++CMAKE_DLL_DIR_IS_ABSOLUTE = True
+ 
+ static|staticlib:CMAKE_STATIC_TYPE = true
+ 
+@@ -167,7 +142,7 @@ contains(CONFIG, plugin) {
+       cmake_target_file
+ 
+     cmake_qt5_plugin_file.files = $$cmake_target_file.output
+-    cmake_qt5_plugin_file.path = $$[QT_INSTALL_LIBS]/cmake/Qt5$${CMAKE_MODULE_NAME}
++    cmake_qt5_plugin_file.path = $$NIX_OUTPUT_OUT/lib/cmake/Qt5$${CMAKE_MODULE_NAME}
+     INSTALLS += cmake_qt5_plugin_file
+ 
+     return()
+@@ -314,7 +289,7 @@ exists($$cmake_macros_file.input) {
+     cmake_qt5_module_files.files += $$cmake_macros_file.output
+ }
+ 
+-cmake_qt5_module_files.path = $$[QT_INSTALL_LIBS]/cmake/Qt5$${CMAKE_MODULE_NAME}
++cmake_qt5_module_files.path = $$NIX_OUTPUT_OUT/lib/cmake/Qt5$${CMAKE_MODULE_NAME}
+ 
+ # We are generating cmake files. Most developers of Qt are not aware of cmake,
+ # so we require automatic tests to be available. The only module which should
+diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+index 55c74aad66..0bbc8718eb 100644
+--- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
++++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+@@ -9,30 +9,6 @@ if (CMAKE_VERSION VERSION_LESS 3.0.0)
+ endif()
+ !!ENDIF
+ 
+-!!IF !isEmpty(CMAKE_USR_MOVE_WORKAROUND)
+-!!IF !isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-set(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$[QT_INSTALL_PREFIX]\")
+-!!ELSE
+-get_filename_component(_IMPORT_PREFIX \"${CMAKE_CURRENT_LIST_FILE}\" PATH)
+-# Use original install prefix when loaded through a
+-# cross-prefix symbolic link such as /lib -> /usr/lib.
+-get_filename_component(_realCurr \"${_IMPORT_PREFIX}\" REALPATH)
+-get_filename_component(_realOrig \"$$CMAKE_INSTALL_LIBS_DIR/cmake/Qt5$${CMAKE_MODULE_NAME}\" REALPATH)
+-if(_realCurr STREQUAL _realOrig)
+-    get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$CMAKE_INSTALL_LIBS_DIR/$${CMAKE_RELATIVE_INSTALL_LIBS_DIR}\" ABSOLUTE)
+-else()
+-    get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
+-endif()
+-unset(_realOrig)
+-unset(_realCurr)
+-unset(_IMPORT_PREFIX)
+-!!ENDIF
+-!!ELIF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
+-!!ELSE
+-set(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$[QT_INSTALL_PREFIX]\")
+-!!ENDIF
+-
+ !!IF !equals(TEMPLATE, aux)
+ # For backwards compatibility only. Use Qt5$${CMAKE_MODULE_NAME}_VERSION instead.
+ set(Qt5$${CMAKE_MODULE_NAME}_VERSION_STRING "$$eval(QT.$${MODULE}.VERSION)")
+@@ -58,11 +34,7 @@ endmacro()
+ macro(_populate_$${CMAKE_MODULE_NAME}_target_properties Configuration LIB_LOCATION IMPLIB_LOCATION)
+     set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
+ 
+-!!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
+-!!ENDIF
+     _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
+     set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
+         \"INTERFACE_LINK_LIBRARIES\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\"
+@@ -75,11 +47,7 @@ macro(_populate_$${CMAKE_MODULE_NAME}_target_properties Configuration LIB_LOCATI
+     )
+ 
+ !!IF !isEmpty(CMAKE_WINDOWS_BUILD)
+-!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    set(imported_implib \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
+-!!ELSE
+     set(imported_implib \"IMPORTED_IMPLIB_${Configuration}\" \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
+-!!ENDIF
+     _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_implib})
+     if(NOT \"${IMPLIB_LOCATION}\" STREQUAL \"\")
+         set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
+@@ -95,24 +63,13 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ !!IF !no_module_headers
+ !!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
+     set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS
+-      \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework\"
+-      \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Headers\"
++      \"$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework\"
++      \"$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Headers\"
+     )
+ !!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
+     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/\"
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/$${MODULE_INCNAME}\"
+-    )
+-!!ELSE
+-    set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
+-!!ENDIF
+-!!ELSE
+-!!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
+-    set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR\" \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}\")
+-!!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
+-    set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION\"
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION/$${MODULE_INCNAME}\"
++        \"$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/\"
++        \"$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/$${MODULE_INCNAME}\"
+     )
+ !!ELSE
+     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
+@@ -128,7 +85,6 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
+ !!ENDIF
+ !!ENDIF
+-!!ENDIF
+ !!IF !isEmpty(CMAKE_ADD_SOURCE_INCLUDE_DIRS)
+     include(\"${CMAKE_CURRENT_LIST_DIR}/ExtraSourceIncludes.cmake\" OPTIONAL)
+ !!ENDIF
+@@ -280,25 +236,13 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
+ !!IF isEmpty(CMAKE_DEBUG_TYPE)
+ !!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
+-!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+-!!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
+     if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+-!!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
+         _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" \"\" )
+ !!ELSE // CMAKE_STATIC_WINDOWS_BUILD
+     if (EXISTS
+-!!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
+-!!ELSE
+         \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
+-!!ENDIF
+       AND EXISTS
+-!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+-!!ELSE
+         \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+-!!ENDIF
+         _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+ !!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
+     endif()
+@@ -317,25 +261,13 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
+ !!IF isEmpty(CMAKE_RELEASE_TYPE)
+ !!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
+-!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+-!!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
+     if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+-!!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
+         _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" \"\" )
+ !!ELSE // CMAKE_STATIC_WINDOWS_BUILD
+     if (EXISTS
+-!!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
+-!!ELSE
+         \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
+-!!ENDIF
+       AND EXISTS
+-!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+-!!ELSE
+         \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+-!!ENDIF
+         _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+ !!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
+     endif()
+@@ -354,11 +286,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+     macro(_populate_$${CMAKE_MODULE_NAME}_plugin_properties Plugin Configuration PLUGIN_LOCATION)
+         set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
+ 
+-!!IF isEmpty(CMAKE_PLUGIN_DIR_IS_ABSOLUTE)
+-        set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
+-!!ELSE
+         set(imported_location \"$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
+-!!ENDIF
+         _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
+         set_target_properties(Qt5::${Plugin} PROPERTIES
+             \"IMPORTED_LOCATION_${Configuration}\" ${imported_location}
+diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf
+index e645ba5803..a0e5c68b7e 100644
+--- a/mkspecs/features/mac/default_post.prf
++++ b/mkspecs/features/mac/default_post.prf
+@@ -24,166 +24,3 @@ qt {
+         }
+     }
+ }
+-
+-# Add the same default rpaths as Xcode does for new projects.
+-# This is especially important for iOS/tvOS/watchOS where no other option is possible.
+-!no_default_rpath {
+-    QMAKE_RPATHDIR += @executable_path/Frameworks
+-    equals(TEMPLATE, lib):!plugin:lib_bundle: QMAKE_RPATHDIR += @loader_path/Frameworks
+-}
+-
+-# Don't pass -headerpad_max_install_names when using Bitcode.
+-# In that case the linker emits a warning stating that the flag is ignored when
+-# used with bitcode, for reasons that cannot be determined (rdar://problem/20748962).
+-# Using this flag is also unnecessary in practice on UIKit platforms since they
+-# are sandboxed, and only UIKit platforms support bitcode to begin with.
+-!bitcode: QMAKE_LFLAGS += $$QMAKE_LFLAGS_HEADERPAD
+-
+-app_extension_api_only {
+-    QMAKE_CFLAGS              += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
+-    QMAKE_CXXFLAGS            += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
+-    QMAKE_CXXFLAGS_PRECOMPILE += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
+-    QMAKE_LFLAGS              += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
+-}
+-
+-macx-xcode {
+-    !isEmpty(QMAKE_XCODE_DEBUG_INFORMATION_FORMAT) {
+-        debug_information_format.name = DEBUG_INFORMATION_FORMAT
+-        debug_information_format.value = $$QMAKE_XCODE_DEBUG_INFORMATION_FORMAT
+-        debug_information_format.build = debug
+-        QMAKE_MAC_XCODE_SETTINGS += debug_information_format
+-    }
+-
+-    QMAKE_XCODE_ARCHS =
+-
+-    arch_device.name = "ARCHS[sdk=$${device.sdk}*]"
+-    arch_device.value = $$QMAKE_APPLE_DEVICE_ARCHS
+-    QMAKE_XCODE_ARCHS += $$QMAKE_APPLE_DEVICE_ARCHS
+-    QMAKE_MAC_XCODE_SETTINGS += arch_device
+-
+-    simulator {
+-        arch_simulator.name = "ARCHS[sdk=$${simulator.sdk}*]"
+-        arch_simulator.value = $$QMAKE_APPLE_SIMULATOR_ARCHS
+-        QMAKE_XCODE_ARCHS += $$QMAKE_APPLE_SIMULATOR_ARCHS
+-        QMAKE_MAC_XCODE_SETTINGS += arch_simulator
+-    }
+-
+-    only_active_arch.name = ONLY_ACTIVE_ARCH
+-    only_active_arch.value = YES
+-    only_active_arch.build = debug
+-    QMAKE_MAC_XCODE_SETTINGS += only_active_arch
+-} else {
+-    device|!simulator: VALID_DEVICE_ARCHS = $$QMAKE_APPLE_DEVICE_ARCHS
+-    simulator: VALID_SIMULATOR_ARCHS = $$QMAKE_APPLE_SIMULATOR_ARCHS
+-    VALID_ARCHS = $$VALID_DEVICE_ARCHS $$VALID_SIMULATOR_ARCHS
+-
+-    isEmpty(VALID_ARCHS): \
+-        error("QMAKE_APPLE_DEVICE_ARCHS or QMAKE_APPLE_SIMULATOR_ARCHS must contain at least one architecture")
+-
+-    single_arch: VALID_ARCHS = $$first(VALID_ARCHS)
+-
+-    ACTIVE_ARCHS = $(filter $(EXPORT_VALID_ARCHS), $(ARCHS))
+-    ARCH_ARGS = $(foreach arch, $(if $(EXPORT_ACTIVE_ARCHS), $(EXPORT_ACTIVE_ARCHS), $(EXPORT_VALID_ARCHS)), -arch $(arch))
+-
+-    QMAKE_EXTRA_VARIABLES += VALID_ARCHS ACTIVE_ARCHS ARCH_ARGS
+-
+-    arch_flags = $(EXPORT_ARCH_ARGS)
+-
+-    QMAKE_CFLAGS += $$arch_flags
+-    QMAKE_CXXFLAGS += $$arch_flags
+-    QMAKE_LFLAGS += $$arch_flags
+-
+-    QMAKE_PCH_ARCHS = $$VALID_ARCHS
+-
+-    macos: deployment_target = $$QMAKE_MACOSX_DEPLOYMENT_TARGET
+-    ios: deployment_target = $$QMAKE_IOS_DEPLOYMENT_TARGET
+-    tvos: deployment_target = $$QMAKE_TVOS_DEPLOYMENT_TARGET
+-    watchos: deployment_target = $$QMAKE_WATCHOS_DEPLOYMENT_TARGET
+-
+-    # If we're doing a simulator and device build, device and simulator
+-    # architectures use different paths and flags for the sysroot and
+-    # deployment target switch, so we must multiplex them across multiple
+-    # architectures using -Xarch. Otherwise we fall back to the simple path.
+-    # This is not strictly necessary, but results in cleaner command lines
+-    # and makes it easier for people to override EXPORT_VALID_ARCHS to limit
+-    # individual rules to a different set of architecture(s) from the overall
+-    # build (such as machtest in QtCore).
+-    simulator:device {
+-        QMAKE_XARCH_CFLAGS =
+-        QMAKE_XARCH_LFLAGS =
+-        QMAKE_EXTRA_VARIABLES += QMAKE_XARCH_CFLAGS QMAKE_XARCH_LFLAGS
+-
+-        for (arch, VALID_ARCHS) {
+-            contains(VALID_SIMULATOR_ARCHS, $$arch) {
+-                sdk = $$simulator.sdk
+-                version_identifier = $$simulator.deployment_identifier
+-            } else {
+-                sdk = $$device.sdk
+-                version_identifier = $$device.deployment_identifier
+-            }
+-
+-            version_min_flags = \
+-                -Xarch_$${arch} \
+-                -m$${version_identifier}-version-min=$$deployment_target
+-            QMAKE_XARCH_CFLAGS_$${arch} = $$version_min_flags \
+-                -Xarch_$${arch} \
+-                -isysroot$$xcodeSDKInfo(Path, $$sdk)
+-            QMAKE_XARCH_LFLAGS_$${arch} = $$version_min_flags \
+-                -Xarch_$${arch} \
+-                -Wl,-syslibroot,$$xcodeSDKInfo(Path, $$sdk)
+-
+-            QMAKE_XARCH_CFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS_$${arch})
+-            QMAKE_XARCH_LFLAGS += $(EXPORT_QMAKE_XARCH_LFLAGS_$${arch})
+-
+-            QMAKE_EXTRA_VARIABLES += \
+-                QMAKE_XARCH_CFLAGS_$${arch} \
+-                QMAKE_XARCH_LFLAGS_$${arch}
+-        }
+-
+-        QMAKE_CFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS)
+-        QMAKE_CXXFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS)
+-        QMAKE_LFLAGS += $(EXPORT_QMAKE_XARCH_LFLAGS)
+-    } else {
+-        simulator: \
+-            version_identifier = $$simulator.deployment_identifier
+-        else: \
+-            version_identifier = $$device.deployment_identifier
+-        version_min_flag = -m$${version_identifier}-version-min=$$deployment_target
+-        QMAKE_CFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag
+-        QMAKE_CXXFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag
+-        QMAKE_LFLAGS += -Wl,-syslibroot,$$QMAKE_MAC_SDK_PATH $$version_min_flag
+-    }
+-
+-    # Enable precompiled headers for multiple architectures
+-    QMAKE_CFLAGS_USE_PRECOMPILE =
+-    for (arch, VALID_ARCHS) {
+-        icc_pch_style: \
+-            use_flag = "-pch-use "
+-        else: \
+-            use_flag = -include
+-
+-        # Only use Xarch with multi-arch, as the option confuses ccache
+-        count(VALID_ARCHS, 1, greaterThan): \
+-            QMAKE_CFLAGS_USE_PRECOMPILE += \
+-                -Xarch_$${arch}
+-
+-        QMAKE_CFLAGS_USE_PRECOMPILE += \
+-            $${use_flag}${QMAKE_PCH_OUTPUT_$${arch}}
+-    }
+-    icc_pch_style {
+-        QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE -include ${QMAKE_PCH_INPUT}
+-        QMAKE_CFLAGS_USE_PRECOMPILE =
+-    } else {
+-        QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
+-        QMAKE_OBJCFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
+-        QMAKE_OBJCXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
+-    }
+-
+-    QMAKE_PCH_OUTPUT_EXT = _${QMAKE_PCH_ARCH}$${QMAKE_PCH_OUTPUT_EXT}
+-}
+-
+-cache(QMAKE_XCODE_DEVELOPER_PATH, stash)
+-!isEmpty(QMAKE_XCODE_VERSION): \
+-    cache(QMAKE_XCODE_VERSION, stash)
+-
+-QMAKE_XCODE_LIBRARY_SUFFIX = $$qtPlatformTargetSuffix()
+diff --git a/mkspecs/features/mac/default_pre.prf b/mkspecs/features/mac/default_pre.prf
+index 44636f2288..3b01424e67 100644
+--- a/mkspecs/features/mac/default_pre.prf
++++ b/mkspecs/features/mac/default_pre.prf
+@@ -1,56 +1,2 @@
+ CONFIG = asset_catalogs rez $$CONFIG
+ load(default_pre)
+-
+-isEmpty(QMAKE_XCODE_DEVELOPER_PATH) {
+-    # Get path of Xcode's Developer directory
+-    QMAKE_XCODE_DEVELOPER_PATH = $$system("/usr/bin/xcode-select --print-path 2>/dev/null")
+-    isEmpty(QMAKE_XCODE_DEVELOPER_PATH): \
+-        error("Xcode path is not set. Please use xcode-select to choose Xcode installation path.")
+-
+-    # Make sure Xcode path is valid
+-    !exists($$QMAKE_XCODE_DEVELOPER_PATH): \
+-        error("Xcode is not installed in $${QMAKE_XCODE_DEVELOPER_PATH}. Please use xcode-select to choose Xcode installation path.")
+-}
+-
+-isEmpty(QMAKE_XCODEBUILD_PATH): \
+-    QMAKE_XCODEBUILD_PATH = $$system("/usr/bin/xcrun -find xcodebuild 2>/dev/null")
+-
+-!isEmpty(QMAKE_XCODEBUILD_PATH) {
+-    # Make sure Xcode is set up properly
+-    !system("/usr/bin/xcrun xcodebuild -license check 2>/dev/null"): \
+-        error("Xcode not set up properly. You need to confirm the license agreement by running 'sudo xcrun xcodebuild -license accept'.")
+-
+-    isEmpty(QMAKE_XCODE_VERSION) {
+-        # Extract Xcode version using xcodebuild
+-        xcode_version = $$system("/usr/bin/xcrun xcodebuild -version")
+-        QMAKE_XCODE_VERSION = $$member(xcode_version, 1)
+-        isEmpty(QMAKE_XCODE_VERSION): error("Could not resolve Xcode version.")
+-        unset(xcode_version)
+-    }
+-}
+-
+-isEmpty(QMAKE_TARGET_BUNDLE_PREFIX) {
+-    QMAKE_XCODE_PREFERENCES_FILE = $$(HOME)/Library/Preferences/com.apple.dt.Xcode.plist
+-    exists($$QMAKE_XCODE_PREFERENCES_FILE): \
+-        QMAKE_TARGET_BUNDLE_PREFIX = $$system("/usr/libexec/PlistBuddy -c 'print IDETemplateOptions:bundleIdentifierPrefix' $$QMAKE_XCODE_PREFERENCES_FILE 2>/dev/null")
+-
+-    !isEmpty(_QMAKE_CACHE_):!isEmpty(QMAKE_TARGET_BUNDLE_PREFIX): \
+-        cache(QMAKE_TARGET_BUNDLE_PREFIX)
+-}
+-
+-QMAKE_ASSET_CATALOGS_APP_ICON = AppIcon
+-
+-# Make the default debug info format for static debug builds
+-# DWARF instead of DWARF with dSYM. This cuts down build times
+-# for application debug builds significantly, as Xcode doesn't
+-# have to pull out all the DWARF info from the Qt static libs
+-# and put it into a dSYM file. We don't need that dSYM file in
+-# the first place, since the information is available in the
+-# object files inside the archives (static libraries).
+-macx-xcode:qtConfig(static): \
+-    QMAKE_XCODE_DEBUG_INFORMATION_FORMAT = dwarf
+-
+-# This variable is used by the xcode_dynamic_library_suffix
+-# feature, which allows Xcode to choose the Qt libraries to link to
+-# at build time, depending on the current Xcode SDK and configuration.
+-QMAKE_XCODE_LIBRARY_SUFFIX_SETTING = QT_LIBRARY_SUFFIX
+diff --git a/mkspecs/features/mac/sdk.prf b/mkspecs/features/mac/sdk.prf
+index 3f6dc076ca..e69de29bb2 100644
+--- a/mkspecs/features/mac/sdk.prf
++++ b/mkspecs/features/mac/sdk.prf
+@@ -1,58 +0,0 @@
+-
+-isEmpty(QMAKE_MAC_SDK): \
+-    error("QMAKE_MAC_SDK must be set when using CONFIG += sdk.")
+-
+-contains(QMAKE_MAC_SDK, .*/.*): \
+-    error("QMAKE_MAC_SDK can only contain short-form SDK names (eg. macosx, iphoneos)")
+-
+-defineReplace(xcodeSDKInfo) {
+-    info = $$1
+-    equals(info, "Path"): \
+-        info = --show-sdk-path
+-    equals(info, "PlatformPath"): \
+-        info = --show-sdk-platform-path
+-    equals(info, "SDKVersion"): \
+-        info = --show-sdk-version
+-    sdk = $$2
+-    isEmpty(sdk): \
+-        sdk = $$QMAKE_MAC_SDK
+-
+-    isEmpty(QMAKE_MAC_SDK.$${sdk}.$${info}) {
+-        QMAKE_MAC_SDK.$${sdk}.$${info} = $$system("/usr/bin/xcrun --sdk $$sdk $$info 2>/dev/null")
+-        # --show-sdk-platform-path won't work for Command Line Tools; this is fine
+-        # only used by the XCTest backend to testlib
+-        isEmpty(QMAKE_MAC_SDK.$${sdk}.$${info}):if(!isEmpty(QMAKE_XCODEBUILD_PATH)|!equals(info, "--show-sdk-platform-path")): \
+-            error("Could not resolve SDK $$info for \'$$sdk\'")
+-        cache(QMAKE_MAC_SDK.$${sdk}.$${info}, set stash, QMAKE_MAC_SDK.$${sdk}.$${info})
+-    }
+-
+-    return($$eval(QMAKE_MAC_SDK.$${sdk}.$${info}))
+-}
+-
+-QMAKE_MAC_SDK_PATH = $$xcodeSDKInfo(Path)
+-QMAKE_MAC_SDK_PLATFORM_PATH = $$xcodeSDKInfo(PlatformPath)
+-QMAKE_MAC_SDK_VERSION = $$xcodeSDKInfo(SDKVersion)
+-
+-sysrootified =
+-for(val, QMAKE_INCDIR_OPENGL): sysrootified += $${QMAKE_MAC_SDK_PATH}$$val
+-QMAKE_INCDIR_OPENGL = $$sysrootified
+-
+-QMAKESPEC_NAME = $$basename(QMAKESPEC)
+-
+-# Resolve SDK version of various tools
+-for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_FIX_RPATH QMAKE_AR QMAKE_RANLIB QMAKE_LINK QMAKE_LINK_SHLIB QMAKE_ACTOOL)) {
+-    tool_variable = QMAKE_MAC_SDK.$${QMAKESPEC_NAME}.$${QMAKE_MAC_SDK}.$${tool}
+-    !isEmpty($$tool_variable) {
+-        $$tool = $$eval($$tool_variable)
+-        next()
+-    }
+-
+-    value = $$eval($$tool)
+-    isEmpty(value): next()
+-
+-    sysrooted = $$system("/usr/bin/xcrun -sdk $$QMAKE_MAC_SDK -find $$first(value) 2>/dev/null")
+-    isEmpty(sysrooted): next()
+-
+-    $$tool = $$sysrooted $$member(value, 1, -1)
+-    cache($$tool_variable, set stash, $$tool)
+-}
+diff --git a/mkspecs/features/qml_module.prf b/mkspecs/features/qml_module.prf
+index 4db0040dc5..65d6da1f4d 100644
+--- a/mkspecs/features/qml_module.prf
++++ b/mkspecs/features/qml_module.prf
+@@ -23,13 +23,8 @@ for(qmlf, AUX_QML_FILES): fq_aux_qml_files += $$absolute_path($$qmlf, $$_PRO_FIL
+ 
+ load(qt_build_paths)
+ 
+-qml1_target {
+-    DESTDIR = $$MODULE_BASE_OUTDIR/imports/$$TARGETPATH
+-    instbase = $$[QT_INSTALL_IMPORTS]
+-} else {
+-    DESTDIR = $$MODULE_BASE_OUTDIR/qml/$$TARGETPATH
+-    instbase = $$[QT_INSTALL_QML]
+-}
++DESTDIR = $$MODULE_BASE_OUTDIR/qml/$$TARGETPATH
++instbase = $$NIX_OUTPUT_QML
+ 
+ !qml1_target:static: CONFIG += builtin_resources
+ 
+diff --git a/mkspecs/features/qml_plugin.prf b/mkspecs/features/qml_plugin.prf
+index d49f4c49c1..097dcd7d39 100644
+--- a/mkspecs/features/qml_plugin.prf
++++ b/mkspecs/features/qml_plugin.prf
+@@ -48,13 +48,8 @@ exists($$QMLTYPEFILE): AUX_QML_FILES += $$QMLTYPEFILE
+ 
+ load(qt_build_paths)
+ 
+-qml1_target {
+-    DESTDIR = $$MODULE_BASE_OUTDIR/imports/$$TARGETPATH
+-    instbase = $$[QT_INSTALL_IMPORTS]
+-} else {
+-    DESTDIR = $$MODULE_BASE_OUTDIR/qml/$$TARGETPATH
+-    instbase = $$[QT_INSTALL_QML]
+-}
++DESTDIR = $$MODULE_BASE_OUTDIR/qml/$$TARGETPATH
++instbase = $$NIX_OUTPUT_QML
+ 
+ target.path = $$instbase/$$TARGETPATH
+ INSTALLS += target
+diff --git a/mkspecs/features/qt_app.prf b/mkspecs/features/qt_app.prf
+index 883f8ca215..81db8eb2d4 100644
+--- a/mkspecs/features/qt_app.prf
++++ b/mkspecs/features/qt_app.prf
+@@ -33,7 +33,7 @@ host_build:force_bootstrap {
+     target.path = $$[QT_HOST_BINS]
+ } else {
+     !build_pass:qtConfig(debug_and_release): CONFIG += release
+-    target.path = $$[QT_INSTALL_BINS]
++    target.path = $$NIX_OUTPUT_BIN/bin
+     CONFIG += relative_qt_rpath  # Qt's tools and apps should be relocatable
+ }
+ INSTALLS += target
+diff --git a/mkspecs/features/qt_build_paths.prf b/mkspecs/features/qt_build_paths.prf
+index 1848f00e90..2af93675c5 100644
+--- a/mkspecs/features/qt_build_paths.prf
++++ b/mkspecs/features/qt_build_paths.prf
+@@ -23,6 +23,6 @@ exists($$MODULE_BASE_INDIR/.git): \
+ !force_independent {
+     # If the module is not built independently, everything ends up in qtbase.
+     # This is the case in non-prefix builds, except for selected modules.
+-    MODULE_BASE_OUTDIR = $$[QT_HOST_PREFIX]
+-    MODULE_QMAKE_OUTDIR = $$[QT_HOST_PREFIX]
++    MODULE_BASE_OUTDIR = $$NIX_OUTPUT_OUT
++    MODULE_QMAKE_OUTDIR = $$NIX_OUTPUT_OUT
+ }
+diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf
+index fb96d1b6a0..508ed17d30 100644
+--- a/mkspecs/features/qt_common.prf
++++ b/mkspecs/features/qt_common.prf
+@@ -32,8 +32,8 @@ contains(TEMPLATE, .*lib) {
+         qqt_libdir = \$\$\$\$[QT_HOST_LIBS]
+         qt_libdir = $$[QT_HOST_LIBS]
+     } else {
+-        qqt_libdir = \$\$\$\$[QT_INSTALL_LIBS]
+-        qt_libdir = $$[QT_INSTALL_LIBS]
++        qqt_libdir = \$\$\$\$NIX_OUTPUT_OUT/lib
++        qt_libdir = $$NIX_OUTPUT_OUT/lib
+     }
+     contains(QMAKE_DEFAULT_LIBDIRS, $$qt_libdir) {
+         lib_replace.match = "[^ ']*$$rplbase/lib"
+diff --git a/mkspecs/features/qt_docs.prf b/mkspecs/features/qt_docs.prf
+index 72dde61a40..f891a2baed 100644
+--- a/mkspecs/features/qt_docs.prf
++++ b/mkspecs/features/qt_docs.prf
+@@ -45,7 +45,7 @@ QMAKE_DOCS_OUTPUTDIR = $$QMAKE_DOCS_BASE_OUTDIR/$$QMAKE_DOCS_TARGETDIR
+ 
+ QDOC += -outputdir $$shell_quote($$QMAKE_DOCS_OUTPUTDIR)
+ !build_online_docs: \
+-    QDOC += -installdir $$shell_quote($$[QT_INSTALL_DOCS])
++    QDOC += -installdir $$shell_quote($$NIX_OUTPUT_DOC)
+ PREP_DOC_INDEXES =
+ DOC_INDEXES =
+ !isEmpty(QTREPOS) {
+@@ -64,8 +64,8 @@ DOC_INDEXES =
+         DOC_INDEXES += -indexdir $$shell_quote($$qrep/doc)
+ } else {
+     prepare_docs: \
+-        PREP_DOC_INDEXES += -indexdir $$shell_quote($$[QT_INSTALL_DOCS/get])
+-    DOC_INDEXES += -indexdir $$shell_quote($$[QT_INSTALL_DOCS/get])
++        PREP_DOC_INDEXES += -indexdir $$shell_quote($$NIX_OUTPUT_DOC)
++    DOC_INDEXES += -indexdir $$shell_quote($$NIX_OUTPUT_DOC)
+ }
+ 
+ qtattributionsscanner.target = qtattributionsscanner
+@@ -88,12 +88,12 @@ prepare_docs {
+     qch_docs.commands = $$QHELPGENERATOR $$shell_quote($$QMAKE_DOCS_OUTPUTDIR/$${QMAKE_DOCS_TARGET}.qhp) -o $$shell_quote($$QMAKE_DOCS_BASE_OUTDIR/$${QMAKE_DOCS_TARGET}.qch)
+ 
+     inst_html_docs.files = $$QMAKE_DOCS_OUTPUTDIR
+-    inst_html_docs.path = $$[QT_INSTALL_DOCS]
++    inst_html_docs.path = $$NIX_OUTPUT_DOC
+     inst_html_docs.CONFIG += no_check_exist directory no_default_install no_build
+     INSTALLS += inst_html_docs
+ 
+     inst_qch_docs.files = $$QMAKE_DOCS_BASE_OUTDIR/$${QMAKE_DOCS_TARGET}.qch
+-    inst_qch_docs.path = $$[QT_INSTALL_DOCS]
++    inst_qch_docs.path = $$NIX_OUTPUT_DOC
+     inst_qch_docs.CONFIG += no_check_exist no_default_install no_build
+     INSTALLS += inst_qch_docs
+ 
+diff --git a/mkspecs/features/qt_example_installs.prf b/mkspecs/features/qt_example_installs.prf
+index 668669e4cd..eb4840a0aa 100644
+--- a/mkspecs/features/qt_example_installs.prf
++++ b/mkspecs/features/qt_example_installs.prf
+@@ -82,7 +82,7 @@ sourcefiles += \
+     $$SOURCES $$HEADERS $$FORMS $$RESOURCES $$TRANSLATIONS \
+     $$DBUS_ADAPTORS $$DBUS_INTERFACES
+ addInstallFiles(sources.files, $$sourcefiles)
+-sources.path = $$[QT_INSTALL_EXAMPLES]/$$probase
++sources.path = $$NIX_OUTPUT_DEV/share/examples/$$probase
+ INSTALLS += sources
+ 
+ check_examples {
+diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf
+index 1903e509c8..ae7b585989 100644
+--- a/mkspecs/features/qt_functions.prf
++++ b/mkspecs/features/qt_functions.prf
+@@ -69,7 +69,7 @@ defineTest(qtHaveModule) {
+ defineTest(qtPrepareTool) {
+     cmd = $$eval(QT_TOOL.$${2}.binary)
+     isEmpty(cmd) {
+-        cmd = $$[QT_HOST_BINS]/$$2
++        cmd = $$system("command -v $$2")
+         exists($${cmd}.pl) {
+             $${1}_EXE = $${cmd}.pl
+             cmd = perl -w $$system_path($${cmd}.pl)
+diff --git a/mkspecs/features/qt_installs.prf b/mkspecs/features/qt_installs.prf
+index 0d3dfb6b93..5f935b4424 100644
+--- a/mkspecs/features/qt_installs.prf
++++ b/mkspecs/features/qt_installs.prf
+@@ -12,16 +12,10 @@
+ #library
+ !qt_no_install_library {
+     win32 {
+-       host_build: \
+-           dlltarget.path = $$[QT_HOST_BINS]
+-       else: \
+-           dlltarget.path = $$[QT_INSTALL_BINS]
++        dlltarget.path = $$NIX_OUTPUT_BIN/bin
+        INSTALLS += dlltarget
+     }
+-    host_build: \
+-        target.path = $$[QT_HOST_LIBS]
+-    else: \
+-        target.path = $$[QT_INSTALL_LIBS]
++    target.path = $$NIX_OUTPUT_OUT/lib
+     !static: target.CONFIG = no_dll
+     INSTALLS += target
+ }
+@@ -29,33 +23,33 @@
+ #headers
+ qt_install_headers {
+     class_headers.files = $$SYNCQT.HEADER_CLASSES
+-    class_headers.path = $$[QT_INSTALL_HEADERS]/$$MODULE_INCNAME
++    class_headers.path = $$NIX_OUTPUT_DEV/include/$$MODULE_INCNAME
+     INSTALLS += class_headers
+ 
+     targ_headers.files = $$SYNCQT.HEADER_FILES
+-    targ_headers.path = $$[QT_INSTALL_HEADERS]/$$MODULE_INCNAME
++    targ_headers.path = $$NIX_OUTPUT_DEV/include/$$MODULE_INCNAME
+     INSTALLS += targ_headers
+ 
+     private_headers.files = $$SYNCQT.PRIVATE_HEADER_FILES $$SYNCQT.INJECTED_PRIVATE_HEADER_FILES
+-    private_headers.path = $$[QT_INSTALL_HEADERS]/$$MODULE_INCNAME/$$VERSION/$$MODULE_INCNAME/private
++    private_headers.path = $$NIX_OUTPUT_DEV/include/$$MODULE_INCNAME/$$VERSION/$$MODULE_INCNAME/private
+     INSTALLS += private_headers
+ 
+     qpa_headers.files = $$SYNCQT.QPA_HEADER_FILES
+-    qpa_headers.path = $$[QT_INSTALL_HEADERS]/$$MODULE_INCNAME/$$VERSION/$$MODULE_INCNAME/qpa
++    qpa_headers.path = $$NIX_OUTPUT_DEV/include/$$MODULE_INCNAME/$$VERSION/$$MODULE_INCNAME/qpa
+     INSTALLS += qpa_headers
+ }
+ 
+ #module
+ qt_install_module {
+     !isEmpty(MODULE_PRI) {
+-        pritarget.path = $$[QT_HOST_DATA]/mkspecs/modules
++        pritarget.path = $$NIX_OUTPUT_DEV/mkspecs/modules
+         pritarget.files = $$MODULE_PRI
+         INSTALLS += pritarget
+     } else: isEmpty(MODULE_PRIVATE_PRI) {
+         warning("Project $$basename(_PRO_FILE_) is a module, but has not defined MODULE_PRI, which is required for Qt to expose the module to other projects.")
+     }
+     !isEmpty(MODULE_PRIVATE_PRI) {
+-        privpritarget.path = $$[QT_HOST_DATA]/mkspecs/modules
++        privpritarget.path = $$NIX_OUTPUT_DEV/mkspecs/modules
+         privpritarget.files = $$MODULE_PRIVATE_PRI
+         INSTALLS += privpritarget
+     }
+diff --git a/mkspecs/features/qt_plugin.prf b/mkspecs/features/qt_plugin.prf
+index 62e1b69fde..abd63123f9 100644
+--- a/mkspecs/features/qt_plugin.prf
++++ b/mkspecs/features/qt_plugin.prf
+@@ -88,7 +88,7 @@ CONFIG(static, static|shared)|prefix_build {
+     }
+ }
+ 
+-target.path = $$[QT_INSTALL_PLUGINS]/$$PLUGIN_TYPE
++target.path = $$NIX_OUTPUT_PLUGIN/$$PLUGIN_TYPE
+ INSTALLS += target
+ 
+ TARGET = $$qt5LibraryTarget($$TARGET)
+diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
+index 545b9a3d1e..6ac0cdefe4 100644
+--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
++++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
+@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::qmake)
+     add_executable(Qt5::qmake IMPORTED)
+ 
+ !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
+ !!ENDIF
+@@ -18,7 +18,7 @@ if (NOT TARGET Qt5::moc)
+     add_executable(Qt5::moc IMPORTED)
+ 
+ !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
+ !!ENDIF
+@@ -35,7 +35,7 @@ if (NOT TARGET Qt5::rcc)
+     add_executable(Qt5::rcc IMPORTED)
+ 
+ !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
+ !!ENDIF
+@@ -133,7 +133,7 @@ if (NOT TARGET Qt5::WinMain)
+ !!IF !isEmpty(CMAKE_RELEASE_TYPE)
+     set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+ !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
+ !!ENDIF
+@@ -147,7 +147,7 @@ if (NOT TARGET Qt5::WinMain)
+     set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
+ 
+ !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
+ !!ENDIF
+diff --git a/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in b/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
+index c357237d0e..6f0c75de3c 100644
+--- a/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
++++ b/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
+@@ -1,6 +1,6 @@
+ 
+ !!IF isEmpty(CMAKE_HOST_DATA_DIR_IS_ABSOLUTE)
+-set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_HOST_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
++set(_qt5_corelib_extra_includes \"$$NIX_OUTPUT_DEV/$${CMAKE_HOST_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
+ !!ELSE
+ set(_qt5_corelib_extra_includes \"$${CMAKE_HOST_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
+ !!ENDIF
+diff --git a/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in b/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
+index 706304cf34..546420f6ad 100644
+--- a/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
++++ b/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
+@@ -1,6 +1,6 @@
+ 
+ !!IF isEmpty(CMAKE_INSTALL_DATA_DIR_IS_ABSOLUTE)
+-set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_INSTALL_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
++set(_qt5_corelib_extra_includes \"$$NIX_OUTPUT_DEV/$${CMAKE_INSTALL_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
+ !!ELSE
+ set(_qt5_corelib_extra_includes \"$${CMAKE_INSTALL_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
+ !!ENDIF
+diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
+index cba279c184..5ae3fd62e5 100644
+--- a/src/corelib/kernel/qcoreapplication.cpp
++++ b/src/corelib/kernel/qcoreapplication.cpp
+@@ -2533,6 +2533,15 @@ QStringList QCoreApplication::libraryPaths()
+         QStringList *app_libpaths = new QStringList;
+         coreappdata()->app_libpaths.reset(app_libpaths);
+ 
++        // Add library paths derived from PATH
++        const QStringList paths = QFile::decodeName(qgetenv("PATH")).split(':');
++        const QString plugindir = QStringLiteral("../" NIXPKGS_QT_PLUGIN_PREFIX);
++        for (const QString &path: paths) {
++            if (!path.isEmpty()) {
++                app_libpaths->append(QDir::cleanPath(path + QDir::separator() + plugindir));
++            }
++        }
++
+         const QByteArray libPathEnv = qgetenv("QT_PLUGIN_PATH");
+         if (!libPathEnv.isEmpty()) {
+             QStringList paths = QFile::decodeName(libPathEnv).split(QDir::listSeparator(), QString::SkipEmptyParts);
+diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp
+index 4fdc2e36ac..d3ec222543 100644
+--- a/src/corelib/tools/qtimezoneprivate_tz.cpp
++++ b/src/corelib/tools/qtimezoneprivate_tz.cpp
+@@ -70,7 +70,11 @@ typedef QHash<QByteArray, QTzTimeZone> QTzTimeZoneHash;
+ // Parse zone.tab table, assume lists all installed zones, if not will need to read directories
+ static QTzTimeZoneHash loadTzTimeZones()
+ {
+-    QString path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
++    // Try TZDIR first, in case we're running on NixOS.
++    QString path = QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/zone.tab");
++    // Fallback to traditional paths in case we are not on NixOS.
++    if (!QFile::exists(path))
++        path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
+     if (!QFile::exists(path))
+         path = QStringLiteral("/usr/lib/zoneinfo/zone.tab");
+ 
+@@ -645,12 +649,16 @@ void QTzTimeZonePrivate::init(const QByteArray &ianaId)
+         if (!tzif.open(QIODevice::ReadOnly))
+             return;
+     } else {
+-        // Open named tz, try modern path first, if fails try legacy path
+-        tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
++        // Try TZDIR first, in case we're running on NixOS
++        tzif.setFileName(QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/") + QString::fromLocal8Bit(ianaId));
+         if (!tzif.open(QIODevice::ReadOnly)) {
+-            tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
+-            if (!tzif.open(QIODevice::ReadOnly))
+-                return;
++            // Open named tz, try modern path first, if fails try legacy path
++            tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
++            if (!tzif.open(QIODevice::ReadOnly)) {
++                tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
++                if (!tzif.open(QIODevice::ReadOnly))
++                    return;
++            }
+         }
+     }
+ 
+diff --git a/src/dbus/Qt5DBusConfigExtras.cmake.in b/src/dbus/Qt5DBusConfigExtras.cmake.in
+index 1d947159e2..b36865fc48 100644
+--- a/src/dbus/Qt5DBusConfigExtras.cmake.in
++++ b/src/dbus/Qt5DBusConfigExtras.cmake.in
+@@ -2,11 +2,7 @@
+ if (NOT TARGET Qt5::qdbuscpp2xml)
+     add_executable(Qt5::qdbuscpp2xml IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5DBus_install_prefix}/$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+-    set(imported_location \"$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
++    set(imported_location \"$$NIX_OUTPUT_DEV/bin/qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
+     _qt5_DBus_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::qdbuscpp2xml PROPERTIES
+@@ -17,11 +13,7 @@ endif()
+ if (NOT TARGET Qt5::qdbusxml2cpp)
+     add_executable(Qt5::qdbusxml2cpp IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5DBus_install_prefix}/$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+-    set(imported_location \"$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
++    set(imported_location \"$$NIX_OUTPUT_DEV/bin/qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
+     _qt5_DBus_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::qdbusxml2cpp PROPERTIES
+diff --git a/src/gui/Qt5GuiConfigExtras.cmake.in b/src/gui/Qt5GuiConfigExtras.cmake.in
+index 07869efd7d..fb4183bada 100644
+--- a/src/gui/Qt5GuiConfigExtras.cmake.in
++++ b/src/gui/Qt5GuiConfigExtras.cmake.in
+@@ -2,7 +2,7 @@
+ !!IF !isEmpty(CMAKE_ANGLE_EGL_DLL_RELEASE)
+ 
+ !!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
+-set(Qt5Gui_EGL_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR/QtANGLE\")
++set(Qt5Gui_EGL_INCLUDE_DIRS \"$$NIX_OUTPUT_DEV/$$CMAKE_INCLUDE_DIR/QtANGLE\")
+ !!ELSE
+ set(Qt5Gui_EGL_INCLUDE_DIRS \"$$CMAKE_INCLUDE_DIR/QtANGLE\")
+ !!ENDIF
+@@ -17,13 +17,13 @@ macro(_populate_qt5gui_gl_target_properties TargetName Configuration LIB_LOCATIO
+     set_property(TARGET Qt5::${TargetName} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
+ 
+ !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Gui_install_prefix}/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
++    set(imported_location \"$$NIX_OUTPUT_OUT/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
+ !!ENDIF
+ 
+ !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+-    set(imported_implib \"${_qt5Gui_install_prefix}/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
++    set(imported_implib \"$$NIX_OUTPUT_OUT/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
+ !!ELSE
+     set(imported_implib \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
+ !!ENDIF
+diff --git a/src/network/kernel/qdnslookup_unix.cpp b/src/network/kernel/qdnslookup_unix.cpp
+index 1da00813ce..0bf877afcb 100644
+--- a/src/network/kernel/qdnslookup_unix.cpp
++++ b/src/network/kernel/qdnslookup_unix.cpp
+@@ -92,7 +92,7 @@ static bool resolveLibraryInternal()
+     if (!lib.load())
+ #endif
+     {
+-        lib.setFileName(QLatin1String("resolv"));
++        lib.setFileName(QLatin1String(NIXPKGS_LIBRESOLV));
+         if (!lib.load())
+             return false;
+     }
+diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
+index 9a24938284..74962b4ae2 100644
+--- a/src/network/kernel/qhostinfo_unix.cpp
++++ b/src/network/kernel/qhostinfo_unix.cpp
+@@ -102,7 +102,7 @@ static bool resolveLibraryInternal()
+     if (!lib.load())
+ #endif
+     {
+-        lib.setFileName(QLatin1String("resolv"));
++        lib.setFileName(QLatin1String(NIXPKGS_LIBRESOLV));
+         if (!lib.load())
+             return false;
+     }
+diff --git a/src/network/ssl/qsslcontext_openssl.cpp b/src/network/ssl/qsslcontext_openssl.cpp
+index c92d8fc3f8..6008063bcf 100644
+--- a/src/network/ssl/qsslcontext_openssl.cpp
++++ b/src/network/ssl/qsslcontext_openssl.cpp
+@@ -351,7 +351,7 @@ init_context:
+ 
+     const QVector<QSslEllipticCurve> qcurves = sslContext->sslConfiguration.ellipticCurves();
+     if (!qcurves.isEmpty()) {
+-#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_EC)
++#if OPENSSL_VERSION_NUMBER >= 0x10002000L && defined(SSL_CTRL_SET_CURVES) && !defined(OPENSSL_NO_EC)
+         // Set the curves to be used
+         if (q_SSLeay() >= 0x10002000L) {
+             // SSL_CTX_ctrl wants a non-const pointer as last argument,
+@@ -364,7 +364,7 @@ init_context:
+                 sslContext->errorCode = QSslError::UnspecifiedError;
+             }
+         } else
+-#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_EC)
++#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L && defined(SSL_CTRL_SET_CURVES) && !defined(OPENSSL_NO_EC)
+         {
+             // specific curves requested, but not possible to set -> error
+             sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocket::tr("OpenSSL version too old, need at least v1.0.2"));
+diff --git a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
+index b5a0a5bbeb..6c20305f4d 100644
+--- a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
++++ b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
+@@ -265,12 +265,9 @@ void TableGenerator::initPossibleLocations()
+     m_possibleLocations.reserve(7);
+     if (qEnvironmentVariableIsSet("QTCOMPOSE"))
+         m_possibleLocations.append(QString::fromLocal8Bit(qgetenv("QTCOMPOSE")));
+-    m_possibleLocations.append(QStringLiteral("/usr/share/X11/locale"));
+-    m_possibleLocations.append(QStringLiteral("/usr/local/share/X11/locale"));
+-    m_possibleLocations.append(QStringLiteral("/usr/lib/X11/locale"));
+-    m_possibleLocations.append(QStringLiteral("/usr/local/lib/X11/locale"));
+     m_possibleLocations.append(QStringLiteral(X11_PREFIX "/share/X11/locale"));
+     m_possibleLocations.append(QStringLiteral(X11_PREFIX "/lib/X11/locale"));
++    m_possibleLocations.append(QLatin1String(NIXPKGS_QTCOMPOSE));
+ }
+ 
+ QString TableGenerator::findComposeFile()
+diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+index e2e573f0e1..1c8289f81e 100644
+--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
++++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+@@ -580,7 +580,14 @@ QFunctionPointer QGLXContext::getProcAddress(const char *procName)
+ #if QT_CONFIG(library)
+                 extern const QString qt_gl_library_name();
+ //                QLibrary lib(qt_gl_library_name());
++                // Check system library paths first
+                 QLibrary lib(QLatin1String("GL"));
++#ifdef NIXPKGS_MESA_GL
++                if (!lib.load()) {
++                    // Fallback to Mesa driver
++                    lib.setFileName(QLatin1String(NIXPKGS_MESA_GL));
++                }
++#endif // NIXPKGS_MESA_GL
+                 glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB");
+ #endif
+             }
+diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp
+index 7c62c2e2b3..fefa40e0f6 100644
+--- a/src/plugins/platforms/xcb/qxcbcursor.cpp
++++ b/src/plugins/platforms/xcb/qxcbcursor.cpp
+@@ -311,10 +311,10 @@ QXcbCursor::QXcbCursor(QXcbConnection *conn, QXcbScreen *screen)
+ #if QT_CONFIG(xcb_xlib) && QT_CONFIG(library)
+     static bool function_ptrs_not_initialized = true;
+     if (function_ptrs_not_initialized) {
+-        QLibrary xcursorLib(QLatin1String("Xcursor"), 1);
++        QLibrary xcursorLib(QLatin1String(NIXPKGS_LIBXCURSOR), 1);
+         bool xcursorFound = xcursorLib.load();
+         if (!xcursorFound) { // try without the version number
+-            xcursorLib.setFileName(QLatin1String("Xcursor"));
++            xcursorLib.setFileName(QLatin1String(NIXPKGS_LIBXCURSOR));
+             xcursorFound = xcursorLib.load();
+         }
+         if (xcursorFound) {
+diff --git a/src/plugins/platformthemes/gtk3/main.cpp b/src/plugins/platformthemes/gtk3/main.cpp
+index c4cd66c33b..b6f2691587 100644
+--- a/src/plugins/platformthemes/gtk3/main.cpp
++++ b/src/plugins/platformthemes/gtk3/main.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include <qpa/qplatformthemeplugin.h>
+ #include "qgtk3theme.h"
++#include <QFile>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -54,8 +55,22 @@ public:
+ QPlatformTheme *QGtk3ThemePlugin::create(const QString &key, const QStringList &params)
+ {
+     Q_UNUSED(params);
+-    if (!key.compare(QLatin1String(QGtk3Theme::name), Qt::CaseInsensitive))
++    if (!key.compare(QLatin1String(QGtk3Theme::name), Qt::CaseInsensitive)) {
++
++#ifdef NIXPKGS_QGTK3_XDG_DATA_DIRS
++        QStringList XDG_DATA_DIRS = QFile::decodeName(qgetenv("XDG_DATA_DIRS")).split(':');
++        XDG_DATA_DIRS << QLatin1String(NIXPKGS_QGTK3_XDG_DATA_DIRS);
++        qputenv("XDG_DATA_DIRS", QFile::encodeName(XDG_DATA_DIRS.join(':')));
++#endif
++
++#ifdef NIXPKGS_QGTK3_GIO_EXTRA_MODULES
++        QStringList GIO_EXTRA_MODULES = QFile::decodeName(qgetenv("GIO_EXTRA_MODULES")).split(':');
++        GIO_EXTRA_MODULES << QLatin1String(NIXPKGS_QGTK3_GIO_EXTRA_MODULES);
++        qputenv("GIO_EXTRA_MODULES", QFile::encodeName(GIO_EXTRA_MODULES.join(':')));
++#endif
++
+         return new QGtk3Theme;
++    }
+ 
+     return 0;
+ }
+diff --git a/src/testlib/qtestassert.h b/src/testlib/qtestassert.h
+index 6498ea84ef..d821ced7fc 100644
+--- a/src/testlib/qtestassert.h
++++ b/src/testlib/qtestassert.h
+@@ -44,10 +44,13 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-
++#if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
++#define QTEST_ASSERT(cond) do { } while ((false) && (cond))
++#define QTEST_ASSERT_X(cond, where, what) do { } while ((false) && (cond))
++#else
+ #define QTEST_ASSERT(cond) do { if (!(cond)) qt_assert(#cond,__FILE__,__LINE__); } while (false)
+-
+ #define QTEST_ASSERT_X(cond, where, what) do { if (!(cond)) qt_assert_x(where, what,__FILE__,__LINE__); } while (false)
++#endif
+ 
+ QT_END_NAMESPACE
+ 
+diff --git a/src/widgets/Qt5WidgetsConfigExtras.cmake.in b/src/widgets/Qt5WidgetsConfigExtras.cmake.in
+index 99d87e2e46..a4eab2aa72 100644
+--- a/src/widgets/Qt5WidgetsConfigExtras.cmake.in
++++ b/src/widgets/Qt5WidgetsConfigExtras.cmake.in
+@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::uic)
+     add_executable(Qt5::uic IMPORTED)
+ 
+ !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Widgets_install_prefix}/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
++    set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
+ !!ENDIF
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase/cmake-paths.patch b/pkgs/development/libraries/qt-5/5.9/qtbase/cmake-paths.patch
deleted file mode 100644
index 9616f5812cfd..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtbase/cmake-paths.patch
+++ /dev/null
@@ -1,359 +0,0 @@
-Index: qtbase-opensource-src-5.9.0/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
-===================================================================
---- qtbase-opensource-src-5.9.0.orig/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
-+++ qtbase-opensource-src-5.9.0/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
-@@ -9,30 +9,6 @@ if (CMAKE_VERSION VERSION_LESS 3.0.0)
- endif()
- !!ENDIF
- 
--!!IF !isEmpty(CMAKE_USR_MOVE_WORKAROUND)
--!!IF !isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--set(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$[QT_INSTALL_PREFIX]\")
--!!ELSE
--get_filename_component(_IMPORT_PREFIX \"${CMAKE_CURRENT_LIST_FILE}\" PATH)
--# Use original install prefix when loaded through a
--# cross-prefix symbolic link such as /lib -> /usr/lib.
--get_filename_component(_realCurr \"${_IMPORT_PREFIX}\" REALPATH)
--get_filename_component(_realOrig \"$$CMAKE_INSTALL_LIBS_DIR/cmake/Qt5$${CMAKE_MODULE_NAME}\" REALPATH)
--if(_realCurr STREQUAL _realOrig)
--    get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$CMAKE_INSTALL_LIBS_DIR/$${CMAKE_RELATIVE_INSTALL_LIBS_DIR}\" ABSOLUTE)
--else()
--    get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
--endif()
--unset(_realOrig)
--unset(_realCurr)
--unset(_IMPORT_PREFIX)
--!!ENDIF
--!!ELIF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
--!!ELSE
--set(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$[QT_INSTALL_PREFIX]\")
--!!ENDIF
--
- !!IF !equals(TEMPLATE, aux)
- # For backwards compatibility only. Use Qt5$${CMAKE_MODULE_NAME}_VERSION instead.
- set(Qt5$${CMAKE_MODULE_NAME}_VERSION_STRING "$$eval(QT.$${MODULE}.MAJOR_VERSION).$$eval(QT.$${MODULE}.MINOR_VERSION).$$eval(QT.$${MODULE}.PATCH_VERSION)")
-@@ -59,7 +35,10 @@ macro(_populate_$${CMAKE_MODULE_NAME}_ta
-     set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
- 
- !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
-+    set(imported_location \"@NIX_OUT@/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
-+    if(NOT EXISTS \"${imported_location}\")
-+        set(imported_location \"@NIX_DEV@/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
-+    endif()
- !!ELSE
-     set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
- !!ENDIF
-@@ -74,19 +53,6 @@ macro(_populate_$${CMAKE_MODULE_NAME}_ta
-         \"IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\"
-     )
- 
--!!IF !isEmpty(CMAKE_WINDOWS_BUILD)
--!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    set(imported_implib \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
--!!ELSE
--    set(imported_implib \"IMPORTED_IMPLIB_${Configuration}\" \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
--!!ENDIF
--    _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_implib})
--    if(NOT \"${IMPLIB_LOCATION}\" STREQUAL \"\")
--        set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
--        \"IMPORTED_IMPLIB_${Configuration}\" ${imported_implib}
--        )
--    endif()
--!!ENDIF
- endmacro()
- !!ENDIF
- 
-@@ -95,24 +61,24 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
- !!IF !no_module_headers
- !!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
-     set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS
--      \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework\"
--      \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Headers\"
-+      \"@NIX_OUT@/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework\"
-+      \"@NIX_OUT@/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Headers\"
-     )
- !!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
-     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/\"
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/$${MODULE_INCNAME}\"
-+        \"@NIX_OUT@/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/\"
-+        \"@NIX_OUT@/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/$${MODULE_INCNAME}\"
-     )
- !!ELSE
-     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
- !!ENDIF
- !!ELSE
- !!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
--    set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR\" \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}\")
-+    set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS \"@NIX_DEV@/$$CMAKE_INCLUDE_DIR\" \"@NIX_DEV@/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}\")
- !!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
-     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION\"
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION/$${MODULE_INCNAME}\"
-+        \"@NIX_DEV@/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION\"
-+        \"@NIX_DEV@/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION/$${MODULE_INCNAME}\"
-     )
- !!ELSE
-     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
-@@ -281,7 +247,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
- !!IF isEmpty(CMAKE_DEBUG_TYPE)
- !!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
-+    if (EXISTS \"@NIX_OUT@/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
- !!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
-     if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
- !!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
-@@ -289,13 +255,13 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
- !!ELSE // CMAKE_STATIC_WINDOWS_BUILD
-     if (EXISTS
- !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
-+        \"@NIX_OUT@/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
- !!ELSE
-         \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
- !!ENDIF
-       AND EXISTS
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
-+        \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
- !!ELSE
-         \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
- !!ENDIF
-@@ -318,7 +284,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
- !!IF isEmpty(CMAKE_RELEASE_TYPE)
- !!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
-+    if (EXISTS \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
- !!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
-     if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
- !!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
-@@ -326,13 +292,13 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
- !!ELSE // CMAKE_STATIC_WINDOWS_BUILD
-     if (EXISTS
- !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
-+        \"@NIX_OUT@/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
- !!ELSE
-         \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
- !!ENDIF
-       AND EXISTS
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
-+        \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
- !!ELSE
-         \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
- !!ENDIF
-@@ -354,11 +320,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
-     macro(_populate_$${CMAKE_MODULE_NAME}_plugin_properties Plugin Configuration PLUGIN_LOCATION)
-         set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
- 
--!!IF isEmpty(CMAKE_PLUGIN_DIR_IS_ABSOLUTE)
--        set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
--!!ELSE
--        set(imported_location \"$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
--!!ENDIF
-+        set(imported_location \"${PLUGIN_LOCATION}\")
-         _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
-         set_target_properties(Qt5::${Plugin} PROPERTIES
-             \"IMPORTED_LOCATION_${Configuration}\" ${imported_location}
-Index: qtbase-opensource-src-5.9.0/src/gui/Qt5GuiConfigExtras.cmake.in
-===================================================================
---- qtbase-opensource-src-5.9.0.orig/src/gui/Qt5GuiConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.9.0/src/gui/Qt5GuiConfigExtras.cmake.in
-@@ -2,7 +2,7 @@
- !!IF !isEmpty(CMAKE_ANGLE_EGL_DLL_RELEASE)
- 
- !!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
--set(Qt5Gui_EGL_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR/QtANGLE\")
-+set(Qt5Gui_EGL_INCLUDE_DIRS \"@NIX_DEV@/$$CMAKE_INCLUDE_DIR/QtANGLE\")
- !!ELSE
- set(Qt5Gui_EGL_INCLUDE_DIRS \"$$CMAKE_INCLUDE_DIR/QtANGLE\")
- !!ENDIF
-@@ -17,13 +17,13 @@ macro(_populate_qt5gui_gl_target_propert
-     set_property(TARGET Qt5::${TargetName} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
- 
- !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Gui_install_prefix}/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
-+    set(imported_location \"@NIX_OUT@/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
- !!ELSE
-     set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
- !!ENDIF
- 
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    set(imported_implib \"${_qt5Gui_install_prefix}/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
-+    set(imported_implib \"@NIX_DEV@/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
- !!ELSE
-     set(imported_implib \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
- !!ENDIF
-Index: qtbase-opensource-src-5.9.0/src/widgets/Qt5WidgetsConfigExtras.cmake.in
-===================================================================
---- qtbase-opensource-src-5.9.0.orig/src/widgets/Qt5WidgetsConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.9.0/src/widgets/Qt5WidgetsConfigExtras.cmake.in
-@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::uic)
-     add_executable(Qt5::uic IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Widgets_install_prefix}/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-Index: qtbase-opensource-src-5.9.0/src/corelib/Qt5CoreConfigExtras.cmake.in
-===================================================================
---- qtbase-opensource-src-5.9.0.orig/src/corelib/Qt5CoreConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.9.0/src/corelib/Qt5CoreConfigExtras.cmake.in
-@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::qmake)
-     add_executable(Qt5::qmake IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-@@ -18,7 +18,7 @@ if (NOT TARGET Qt5::moc)
-     add_executable(Qt5::moc IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-@@ -35,7 +35,7 @@ if (NOT TARGET Qt5::rcc)
-     add_executable(Qt5::rcc IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-@@ -133,7 +133,7 @@ if (NOT TARGET Qt5::WinMain)
- !!IF !isEmpty(CMAKE_RELEASE_TYPE)
-     set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
- !!ELSE
-     set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
- !!ENDIF
-@@ -147,7 +147,7 @@ if (NOT TARGET Qt5::WinMain)
-     set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
- 
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
- !!ELSE
-     set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
- !!ENDIF
-Index: qtbase-opensource-src-5.9.0/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
-===================================================================
---- qtbase-opensource-src-5.9.0.orig/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
-+++ qtbase-opensource-src-5.9.0/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
-@@ -1,6 +1,6 @@
- 
- !!IF isEmpty(CMAKE_INSTALL_DATA_DIR_IS_ABSOLUTE)
--set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_INSTALL_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
-+set(_qt5_corelib_extra_includes \"@NIX_DEV@/$${CMAKE_INSTALL_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
- !!ELSE
- set(_qt5_corelib_extra_includes \"$${CMAKE_INSTALL_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
- !!ENDIF
-Index: qtbase-opensource-src-5.9.0/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
-===================================================================
---- qtbase-opensource-src-5.9.0.orig/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
-+++ qtbase-opensource-src-5.9.0/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
-@@ -1,6 +1,6 @@
- 
- !!IF isEmpty(CMAKE_HOST_DATA_DIR_IS_ABSOLUTE)
--set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_HOST_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
-+set(_qt5_corelib_extra_includes \"@NIX_DEV@/$${CMAKE_HOST_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
- !!ELSE
- set(_qt5_corelib_extra_includes \"$${CMAKE_HOST_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
- !!ENDIF
-Index: qtbase-opensource-src-5.9.0/src/dbus/Qt5DBusConfigExtras.cmake.in
-===================================================================
---- qtbase-opensource-src-5.9.0.orig/src/dbus/Qt5DBusConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.9.0/src/dbus/Qt5DBusConfigExtras.cmake.in
-@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::qdbuscpp2xml)
-     add_executable(Qt5::qdbuscpp2xml IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5DBus_install_prefix}/$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-@@ -18,7 +18,7 @@ if (NOT TARGET Qt5::qdbusxml2cpp)
-     add_executable(Qt5::qdbusxml2cpp IMPORTED)
- 
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5DBus_install_prefix}/$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-Index: qtbase-opensource-src-5.9.0/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
-===================================================================
---- qtbase-opensource-src-5.9.0.orig/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
-+++ qtbase-opensource-src-5.9.0/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
-@@ -2,10 +2,10 @@
- add_library(Qt5::$$CMAKE_PLUGIN_NAME MODULE IMPORTED)
- 
- !!IF !isEmpty(CMAKE_RELEASE_TYPE)
--_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
-+_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"@NIX_BIN@/$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
- !!ENDIF
- !!IF !isEmpty(CMAKE_DEBUG_TYPE)
--_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
-+_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"@NIX_BIN@/$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
- !!ENDIF
- 
- list(APPEND Qt5$${CMAKE_MODULE_NAME}_PLUGINS Qt5::$$CMAKE_PLUGIN_NAME)
-Index: qtbase-opensource-src-5.9.0/mkspecs/features/create_cmake.prf
-===================================================================
---- qtbase-opensource-src-5.9.0.orig/mkspecs/features/create_cmake.prf
-+++ qtbase-opensource-src-5.9.0/mkspecs/features/create_cmake.prf
-@@ -136,28 +136,28 @@ contains(CONFIG, plugin) {
- 
-     win32 {
-         isEmpty(CMAKE_STATIC_TYPE) {
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.dll
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.dll
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/$${TARGET}.dll
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/$${TARGET}d.dll
-         } else:mingw {
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}.a
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}d.a
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}.a
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}d.a
-         } else {                         # MSVC static
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.lib
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.lib
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/$${TARGET}.lib
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/$${TARGET}d.lib
-         }
-     } else {
-         mac {
-             isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .dylib
-             else: CMAKE_PlUGIN_EXT = .a
- 
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-         } else {
-             isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .so
-             else: CMAKE_PlUGIN_EXT = .a
- 
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-         }
-     }
-     cmake_target_file.input = $$PWD/data/cmake/Qt5PluginTarget.cmake.in
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase/compose-search-path.patch b/pkgs/development/libraries/qt-5/5.9/qtbase/compose-search-path.patch
deleted file mode 100644
index 720e7d81fa22..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtbase/compose-search-path.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-Index: qtbase-opensource-src-5.9.0/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
-===================================================================
---- qtbase-opensource-src-5.9.0.orig/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
-+++ qtbase-opensource-src-5.9.0/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
-@@ -265,12 +265,9 @@ void TableGenerator::initPossibleLocatio
-     m_possibleLocations.reserve(7);
-     if (qEnvironmentVariableIsSet("QTCOMPOSE"))
-         m_possibleLocations.append(QString::fromLocal8Bit(qgetenv("QTCOMPOSE")));
--    m_possibleLocations.append(QStringLiteral("/usr/share/X11/locale"));
--    m_possibleLocations.append(QStringLiteral("/usr/local/share/X11/locale"));
--    m_possibleLocations.append(QStringLiteral("/usr/lib/X11/locale"));
--    m_possibleLocations.append(QStringLiteral("/usr/local/lib/X11/locale"));
-     m_possibleLocations.append(QStringLiteral(X11_PREFIX "/share/X11/locale"));
-     m_possibleLocations.append(QStringLiteral(X11_PREFIX "/lib/X11/locale"));
-+    m_possibleLocations.append(QLatin1String(NIXPKGS_QTCOMPOSE));
- }
- 
- QString TableGenerator::findComposeFile()
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase/darwin-series b/pkgs/development/libraries/qt-5/5.9/qtbase/darwin-series
deleted file mode 100644
index 1111ff65f440..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtbase/darwin-series
+++ /dev/null
@@ -1,3 +0,0 @@
-mkspecs-common-mac.patch
-mkspecs-features-mac.patch
-darwin-cf.patch
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase/default.nix b/pkgs/development/libraries/qt-5/5.9/qtbase/default.nix
deleted file mode 100644
index d63936c561c1..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtbase/default.nix
+++ /dev/null
@@ -1,366 +0,0 @@
-{
-  stdenv, lib, copyPathsToStore,
-  src, version, qtCompatVersion,
-
-  coreutils, bison, flex, gdb, gperf, lndir, patchelf, perl, pkgconfig, python2,
-  ruby, which,
-  # darwin support
-  darwin, libiconv, libcxx,
-
-  dbus, dconf, fontconfig, freetype, glib, gtk3, harfbuzz, icu, libX11, libXcomposite,
-  libXcursor, libXext, libXi, libXrender, libinput, libjpeg, libpng, libtiff,
-  libxcb, libxkbcommon, libxml2, libxslt, openssl, pcre2, sqlite, udev,
-  xcbutil, xcbutilimage, xcbutilkeysyms, xcbutilrenderutil, xcbutilwm, xlibs,
-  zlib,
-
-  # optional dependencies
-  cups ? null, mysql ? null, postgresql ? null,
-
-  # options
-  mesaSupported ? (!stdenv.isDarwin),
-  mesa,
-  buildExamples ? false,
-  buildTests ? false,
-  developerBuild ? false,
-  decryptSslTraffic ? false
-}:
-
-let
-  system-x86_64 = lib.elem stdenv.system lib.platforms.x86_64;
-in
-
-stdenv.mkDerivation {
-
-  name = "qtbase-${version}";
-  inherit qtCompatVersion src version;
-
-  propagatedBuildInputs =
-    [
-      libxml2 libxslt openssl pcre2 sqlite zlib
-
-      # Text rendering
-      harfbuzz icu
-
-      # Image formats
-      libjpeg libpng libtiff
-    ]
-
-    ++ lib.optional (mesaSupported && !stdenv.isDarwin) mesa
-
-    ++ lib.optionals (!stdenv.isDarwin) [
-      dbus glib udev
-
-      # Text rendering
-      fontconfig freetype
-
-      # X11 libs
-      libX11 libXcomposite libXext libXi libXrender libxcb libxkbcommon xcbutil
-      xcbutilimage xcbutilkeysyms xcbutilrenderutil xcbutilwm
-    ]
-
-    ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
-      AGL AppKit ApplicationServices Carbon Cocoa
-      CoreAudio CoreBluetooth CoreLocation CoreServices
-      DiskArbitration Foundation OpenGL
-      darwin.libobjc libiconv
-    ]);
-
-  buildInputs = [ ]
-    ++ lib.optionals (!stdenv.isDarwin) [ gtk3 libinput ]
-    ++ lib.optional developerBuild gdb
-    ++ lib.optional (cups != null) cups
-    ++ lib.optional (mysql != null) mysql.lib
-    ++ lib.optional (postgresql != null) postgresql;
-
-  nativeBuildInputs =
-    [ bison flex gperf lndir perl pkgconfig python2 which ]
-    ++ lib.optional (!stdenv.isDarwin) patchelf;
-
-  outputs = [ "bin" "dev" "out" ];
-
-  patches =
-    copyPathsToStore (lib.readPathsFromFile ./. ./series)
-    ++ stdenv.lib.optional stdenv.isDarwin (copyPathsToStore (lib.readPathsFromFile ./. ./darwin-series));
-
-  postPatch =
-    ''
-      substituteInPlace configure --replace /bin/pwd pwd
-      substituteInPlace src/corelib/global/global.pri --replace /bin/ls ${coreutils}/bin/ls
-      sed -e 's@/\(usr\|opt\)/@/var/empty/@g' -i mkspecs/*/*.conf
-
-      sed -i '/PATHS.*NO_DEFAULT_PATH/ d' src/corelib/Qt5Config.cmake.in
-      sed -i '/PATHS.*NO_DEFAULT_PATH/ d' src/corelib/Qt5CoreMacros.cmake
-      sed -i 's/NO_DEFAULT_PATH//' src/gui/Qt5GuiConfigExtras.cmake.in
-      sed -i '/PATHS.*NO_DEFAULT_PATH/ d' mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
-    ''
-
-    + lib.optionalString (mesaSupported && !stdenv.isDarwin) ''
-      sed -i mkspecs/common/linux.conf \
-          -e "/^QMAKE_INCDIR_OPENGL/ s|$|${mesa.dev or mesa}/include|" \
-          -e "/^QMAKE_LIBDIR_OPENGL/ s|$|${mesa.out}/lib|"
-    ''
-
-    + lib.optionalString stdenv.isDarwin ''
-      sed -i \
-          -e 's|! /usr/bin/xcode-select --print-path >/dev/null 2>&1;|false;|' \
-          -e 's|! /usr/bin/xcrun -find xcodebuild >/dev/null 2>&1;|false;|' \
-          -e 's|sysroot=$(/usr/bin/xcodebuild -sdk $sdk -version Path 2>/dev/null)|sysroot=/nonsense|' \
-          -e 's|sysroot=$(/usr/bin/xcrun --sdk $sdk --show-sdk-path 2>/dev/null)|sysroot=/nonsense|' \
-          -e 's|QMAKE_CONF_COMPILER=`getXQMakeConf QMAKE_CXX`|QMAKE_CXX="clang++"\nQMAKE_CONF_COMPILER="clang++"|' \
-          -e 's|XCRUN=`/usr/bin/xcrun -sdk macosx clang -v 2>&1`|XCRUN="clang -v 2>&1"|' \
-          -e 's#sdk_val=$(/usr/bin/xcrun -sdk $sdk -find $(echo $val | cut -d \x27 \x27 -f 1))##' \
-          -e 's#val=$(echo $sdk_val $(echo $val | cut -s -d \x27 \x27 -f 2-))##' \
-          ./configure
-          substituteInPlace ./mkspecs/common/mac.conf \
-              --replace "/System/Library/Frameworks/OpenGL.framework/" "${darwin.apple_sdk.frameworks.OpenGL}/Library/Frameworks/OpenGL.framework/"
-          substituteInPlace ./mkspecs/common/mac.conf \
-              --replace "/System/Library/Frameworks/AGL.framework/" "${darwin.apple_sdk.frameworks.AGL}/Library/Frameworks/AGL.framework/"
-     '';
-     # Note on the above: \x27 is a way if including a single-quote
-     # character in the sed string arguments.
-
-  qtPluginPrefix = "lib/qt-${qtCompatVersion}/plugins";
-  qtQmlPrefix = "lib/qt-${qtCompatVersion}/qml";
-  qtDocPrefix = "share/doc/qt-${qtCompatVersion}";
-
-  setOutputFlags = false;
-  preConfigure = ''
-    export LD_LIBRARY_PATH="$PWD/lib:$PWD/plugins/platforms:$LD_LIBRARY_PATH"
-    export MAKEFLAGS=-j$NIX_BUILD_CORES
-
-    configureFlags+="\
-        -plugindir $out/$qtPluginPrefix \
-        -qmldir $out/$qtQmlPrefix \
-        -docdir $out/$qtDocPrefix"
-
-    NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QT_PLUGIN_PREFIX=\"$qtPluginPrefix\""
-  '';
-
-
-  NIX_CFLAGS_COMPILE =
-    [
-      "-Wno-error=sign-compare" # freetype-2.5.4 changed signedness of some struct fields
-      ''-DNIXPKGS_QTCOMPOSE="${libX11.out}/share/X11/locale"''
-      ''-DNIXPKGS_LIBRESOLV="${stdenv.cc.libc.out}/lib/libresolv"''
-      ''-DNIXPKGS_LIBXCURSOR="${libXcursor.out}/lib/libXcursor"''
-    ]
-
-    ++ lib.optional (mesaSupported && !stdenv.isDarwin)
-       ''-DNIXPKGS_MESA_GL="${mesa.out}/lib/libGL"''
-
-    ++ lib.optionals (!stdenv.isDarwin)
-    [
-      ''-DNIXPKGS_QGTK3_XDG_DATA_DIRS="${gtk3}/share/gsettings-schemas/${gtk3.name}"''
-      ''-DNIXPKGS_QGTK3_GIO_EXTRA_MODULES="${dconf.lib}/lib/gio/modules"''
-    ]
-
-    ++ lib.optionals stdenv.isDarwin
-    [
-      "-Wno-missing-sysroot"
-      "-D__MAC_OS_X_VERSION_MAX_ALLOWED=1090"
-      "-D__AVAILABILITY_INTERNAL__MAC_10_10=__attribute__((availability(macosx,introduced=10.10)))"
-      # Note that nixpkgs's objc4 is from macOS 10.11 while the SDK is
-      # 10.9 which necessitates the above macro definition that mentions
-      # 10.10
-    ]
-
-    ++ lib.optional decryptSslTraffic "-DQT_DECRYPT_SSL_TRAFFIC";
-
-  prefixKey = "-prefix ";
-
-  # PostgreSQL autodetection fails sporadically because Qt omits the "-lpq" flag
-  # if dependency paths contain the string "pq", which can occur in the hash.
-  # To prevent these failures, we need to override PostgreSQL detection.
-  PSQL_LIBS = lib.optionalString (postgresql != null) "-L${postgresql.lib}/lib -lpq";
-
-  # -no-eglfs, -no-directfb, -no-linuxfb and -no-kms because of the current minimalist mesa
-  # TODO Remove obsolete and useless flags once the build will be totally mastered
-  configureFlags =
-    [
-      "-verbose"
-      "-confirm-license"
-      "-opensource"
-
-      "-release"
-      "-shared"
-      "-accessibility"
-      "-optimized-qmake"
-      "-strip"
-      "-system-proxies"
-      "-pkg-config"
-    ]
-    ++ lib.optionals developerBuild [
-      "-developer-build"
-      "-no-warnings-are-errors"
-    ]
-    ++ [
-      "-gui"
-      "-widgets"
-      "-opengl desktop"
-      "-qml-debug"
-      "-icu"
-      "-pch"
-    ]
-
-    ++ [
-      ''${lib.optionalString (!system-x86_64) "-no"}-sse2''
-      "-no-sse3"
-      "-no-ssse3"
-      "-no-sse4.1"
-      "-no-sse4.2"
-      "-no-avx"
-      "-no-avx2"
-      "-no-mips_dsp"
-      "-no-mips_dspr2"
-    ]
-
-    ++ [
-      "-system-zlib"
-      "-system-libjpeg"
-      "-system-harfbuzz"
-      "-system-pcre"
-      "-openssl-linked"
-      "-system-sqlite"
-      ''-${if mysql != null then "plugin" else "no"}-sql-mysql''
-      ''-${if postgresql != null then "plugin" else "no"}-sql-psql''
-
-      "-make libs"
-      "-make tools"
-      ''-${lib.optionalString (buildExamples == false) "no"}make examples''
-      ''-${lib.optionalString (buildTests == false) "no"}make tests''
-      "-v"
-    ]
-
-    ++ lib.optionals (!stdenv.isDarwin) [
-      "-rpath"
-
-      "-system-xcb"
-      "-xcb"
-      "-qpa xcb"
-
-      "-system-xkbcommon"
-      "-libinput"
-      "-xkbcommon-evdev"
-
-      "-no-eglfs"
-      "-no-gbm"
-      "-no-kms"
-      "-no-linuxfb"
-
-      ''-${lib.optionalString (cups == null) "no-"}cups''
-      "-dbus-linked"
-      "-glib"
-      "-gtk"
-      "-inotify"
-      "-system-libjpeg"
-      "-system-libpng"
-      # gold linker of binutils 2.28 generates duplicate symbols
-      # TODO: remove for newer version of binutils 
-      "-no-use-gold-linker"
-    ]
-
-    ++ lib.optionals stdenv.isDarwin [
-      "-platform macx-clang"
-      "-no-use-gold-linker"
-      "-no-fontconfig"
-      "-qt-freetype"
-      "-qt-libpng"
-    ];
-
-  enableParallelBuilding = true;
-
-  postInstall =
-    # Hardcode some CMake module paths.
-    ''
-      find "$out" -name "*.cmake" | while read file; do
-          substituteInPlace "$file" \
-              --subst-var-by NIX_OUT "''${!outputLib}" \
-              --subst-var-by NIX_DEV "''${!outputDev}" \
-              --subst-var-by NIX_BIN "''${!outputBin}"
-      done
-    '';
-
-  preFixup =
-    # Move selected outputs.
-    ''
-      moveToOutput "bin" "$dev"
-      moveToOutput "include" "$dev"
-      moveToOutput "mkspecs" "$dev"
-
-      mkdir -p "$dev/share"
-      moveToOutput "share/doc" "$dev"
-
-      moveToOutput "$qtPluginPrefix" "$bin"
-    '';
-
-  postFixup =
-    # Don't retain build-time dependencies like gdb.
-    ''
-      sed '/QMAKE_DEFAULT_.*DIRS/ d' -i $dev/mkspecs/qconfig.pri
-    ''
-
-    # Move libtool archives into $dev
-    + ''
-      if [ "z''${!outputLib}" != "z''${!outputDev}" ]; then
-          pushd "''${!outputLib}"
-          find lib -name '*.a' -o -name '*.la' | while read -r file; do
-              mkdir -p "''${!outputDev}/$(dirname "$file")"
-              mv "''${!outputLib}/$file" "''${!outputDev}/$file"
-          done
-          popd
-      fi
-    ''
-
-    # Move qmake project files into $dev.
-    # Don't move .prl files on darwin because they end up in
-    # "dev/lib/Foo.framework/Foo.prl" which interferes with subsequent
-    # use of lndir in the qtbase setup-hook. On Linux, the .prl files
-    # are in lib, and so do not cause a subsequent recreation of deep
-    # framework directory trees.
-    + lib.optionalString (!stdenv.isDarwin) ''
-      if [ "z''${!outputLib}" != "z''${!outputDev}" ]; then
-          pushd "''${!outputLib}"
-          find lib -name '*.prl' | while read -r file; do
-              mkdir -p "''${!outputDev}/$(dirname "$file")"
-              mv "''${!outputLib}/$file" "''${!outputDev}/$file"
-          done
-          popd
-      fi
-    ''
-
-    # fixup .pc file (where to find 'moc' etc.)
-    + lib.optionalString (!stdenv.isDarwin) ''
-      sed -i "$dev/lib/pkgconfig/Qt5Core.pc" \
-          -e "/^host_bins=/ c host_bins=$dev/bin"
-    ''
-
-    + lib.optionalString stdenv.isDarwin ''
-      fixDarwinDylibNames_rpath() {
-        local flags=()
-
-        for fn in "$@"; do
-          flags+=(-change "@rpath/$fn.framework/Versions/5/$fn" "$out/lib/$fn.framework/Versions/5/$fn")
-        done
-
-        for fn in "$@"; do
-          echo "$fn: fixing dylib"
-          install_name_tool -id "$out/lib/$fn.framework/Versions/5/$fn" "''${flags[@]}" "$out/lib/$fn.framework/Versions/5/$fn"
-        done
-      }
-      fixDarwinDylibNames_rpath "QtConcurrent" "QtPrintSupport" "QtCore" "QtSql" "QtDBus" "QtTest" "QtGui" "QtWidgets" "QtNetwork" "QtXml" "QtOpenGL"
-    '';
-
-  inherit lndir;
-  setupHook = if stdenv.isDarwin
-              then ../../qtbase-setup-hook-darwin.sh
-              else ../../qtbase-setup-hook.sh;
-
-  meta = with lib; {
-    homepage = http://www.qt.io;
-    description = "A cross-platform application framework for C++";
-    license = with licenses; [ fdl13 gpl2 lgpl21 lgpl3 ];
-    maintainers = with maintainers; [ qknight ttuegel periklis ];
-    platforms = platforms.unix;
-  };
-
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase/dlopen-gl.patch b/pkgs/development/libraries/qt-5/5.9/qtbase/dlopen-gl.patch
deleted file mode 100644
index 9385c7f6678c..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtbase/dlopen-gl.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-Index: qtbase-opensource-src-5.9.0/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
-===================================================================
---- qtbase-opensource-src-5.9.0.orig/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
-+++ qtbase-opensource-src-5.9.0/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
-@@ -580,7 +580,14 @@ QFunctionPointer QGLXContext::getProcAdd
- #if QT_CONFIG(library)
-                 extern const QString qt_gl_library_name();
- //                QLibrary lib(qt_gl_library_name());
-+                // Check system library paths first
-                 QLibrary lib(QLatin1String("GL"));
-+#ifdef NIXPKGS_MESA_GL
-+                if (!lib.load()) {
-+                    // Fallback to Mesa driver
-+                    lib.setFileName(QLatin1String(NIXPKGS_MESA_GL));
-+                }
-+#endif // NIXPKGS_MESA_GL
-                 glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB");
- #endif
-             }
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase/dlopen-gtkstyle.patch b/pkgs/development/libraries/qt-5/5.9/qtbase/dlopen-gtkstyle.patch
deleted file mode 100644
index 755b0965cf5f..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtbase/dlopen-gtkstyle.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-Index: qtbase-opensource-src-5.5.1/src/widgets/styles/qgtk2painter.cpp
-===================================================================
---- qtbase-opensource-src-5.5.1.orig/src/widgets/styles/qgtk2painter.cpp
-+++ qtbase-opensource-src-5.5.1/src/widgets/styles/qgtk2painter.cpp
-@@ -96,7 +96,7 @@ static void initGtk()
-     static bool initialized = false;
-     if (!initialized) {
-         // enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
--        QLibrary libgtk(QLS("gtk-x11-2.0"), 0, 0);
-+        QLibrary libgtk(QLS("@gtk@/lib/libgtk-x11-2.0"), 0, 0);
- 
-         QGtk2PainterPrivate::gdk_pixmap_new = (Ptr_gdk_pixmap_new)libgtk.resolve("gdk_pixmap_new");
-         QGtk2PainterPrivate::gdk_pixbuf_get_from_drawable = (Ptr_gdk_pixbuf_get_from_drawable)libgtk.resolve("gdk_pixbuf_get_from_drawable");
-Index: qtbase-opensource-src-5.5.1/src/widgets/styles/qgtkstyle_p.cpp
-===================================================================
---- qtbase-opensource-src-5.5.1.orig/src/widgets/styles/qgtkstyle_p.cpp
-+++ qtbase-opensource-src-5.5.1/src/widgets/styles/qgtkstyle_p.cpp
-@@ -327,7 +327,7 @@ void QGtkStylePrivate::gtkWidgetSetFocus
- void QGtkStylePrivate::resolveGtk() const
- {
-     // enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
--    QLibrary libgtk(QLS("gtk-x11-2.0"), 0, 0);
-+    QLibrary libgtk(QLS("@gtk@/lib/libgtk-x11-2.0"), 0, 0);
- 
-     gtk_init = (Ptr_gtk_init)libgtk.resolve("gtk_init");
-     gtk_window_new = (Ptr_gtk_window_new)libgtk.resolve("gtk_window_new");
-@@ -425,8 +425,8 @@ void QGtkStylePrivate::resolveGtk() cons
-     pango_font_description_get_family = (Ptr_pango_font_description_get_family)libgtk.resolve("pango_font_description_get_family");
-     pango_font_description_get_style = (Ptr_pango_font_description_get_style)libgtk.resolve("pango_font_description_get_style");
- 
--    gnome_icon_lookup_sync = (Ptr_gnome_icon_lookup_sync)QLibrary::resolve(QLS("gnomeui-2"), 0, "gnome_icon_lookup_sync");
--    gnome_vfs_init= (Ptr_gnome_vfs_init)QLibrary::resolve(QLS("gnomevfs-2"), 0, "gnome_vfs_init");
-+    gnome_icon_lookup_sync = (Ptr_gnome_icon_lookup_sync)QLibrary::resolve(QLS("@libgnomeui@/lib/libgnomeui-2"), 0, "gnome_icon_lookup_sync");
-+    gnome_vfs_init= (Ptr_gnome_vfs_init)QLibrary::resolve(QLS("@gnome_vfs@/lib/libgnomevfs-2"), 0, "gnome_vfs_init");
- }
- 
- /* \internal
-@@ -594,9 +594,9 @@ void QGtkStylePrivate::cleanupGtkWidgets
- static bool resolveGConf()
- {
-     if (!QGtkStylePrivate::gconf_client_get_default) {
--        QGtkStylePrivate::gconf_client_get_default = (Ptr_gconf_client_get_default)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_default");
--        QGtkStylePrivate::gconf_client_get_string =  (Ptr_gconf_client_get_string)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_string");
--        QGtkStylePrivate::gconf_client_get_bool =  (Ptr_gconf_client_get_bool)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_bool");
-+        QGtkStylePrivate::gconf_client_get_default = (Ptr_gconf_client_get_default)QLibrary::resolve(QLS("@gconf@/lib/libgconf-2"), 4, "gconf_client_get_default");
-+        QGtkStylePrivate::gconf_client_get_string =  (Ptr_gconf_client_get_string)QLibrary::resolve(QLS("@gconf@/lib/libgconf-2"), 4, "gconf_client_get_string");
-+        QGtkStylePrivate::gconf_client_get_bool =  (Ptr_gconf_client_get_bool)QLibrary::resolve(QLS("@gconf@/lib/libgconf-2"), 4, "gconf_client_get_bool");
-     }
-     return (QGtkStylePrivate::gconf_client_get_default !=0);
- }
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase/dlopen-libXcursor.patch b/pkgs/development/libraries/qt-5/5.9/qtbase/dlopen-libXcursor.patch
deleted file mode 100644
index 31339abc7856..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtbase/dlopen-libXcursor.patch
+++ /dev/null
@@ -1,17 +0,0 @@
-Index: qtbase-opensource-src-5.9.0/src/plugins/platforms/xcb/qxcbcursor.cpp
-===================================================================
---- qtbase-opensource-src-5.9.0.orig/src/plugins/platforms/xcb/qxcbcursor.cpp
-+++ qtbase-opensource-src-5.9.0/src/plugins/platforms/xcb/qxcbcursor.cpp
-@@ -311,10 +311,10 @@ QXcbCursor::QXcbCursor(QXcbConnection *c
- #if defined(XCB_USE_XLIB) && QT_CONFIG(library)
-     static bool function_ptrs_not_initialized = true;
-     if (function_ptrs_not_initialized) {
--        QLibrary xcursorLib(QLatin1String("Xcursor"), 1);
-+        QLibrary xcursorLib(QLatin1String(NIXPKGS_LIBXCURSOR), 1);
-         bool xcursorFound = xcursorLib.load();
-         if (!xcursorFound) { // try without the version number
--            xcursorLib.setFileName(QLatin1String("Xcursor"));
-+            xcursorLib.setFileName(QLatin1String(NIXPKGS_LIBXCURSOR));
-             xcursorFound = xcursorLib.load();
-         }
-         if (xcursorFound) {
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase/dlopen-resolv.patch b/pkgs/development/libraries/qt-5/5.9/qtbase/dlopen-resolv.patch
deleted file mode 100644
index 598456a49ffb..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtbase/dlopen-resolv.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-Index: qtbase-opensource-src-5.9.0/src/network/kernel/qdnslookup_unix.cpp
-===================================================================
---- qtbase-opensource-src-5.9.0.orig/src/network/kernel/qdnslookup_unix.cpp
-+++ qtbase-opensource-src-5.9.0/src/network/kernel/qdnslookup_unix.cpp
-@@ -92,7 +92,7 @@ static bool resolveLibraryInternal()
-     if (!lib.load())
- #endif
-     {
--        lib.setFileName(QLatin1String("resolv"));
-+        lib.setFileName(QLatin1String(NIXPKGS_LIBRESOLV));
-         if (!lib.load())
-             return false;
-     }
-Index: qtbase-opensource-src-5.9.0/src/network/kernel/qhostinfo_unix.cpp
-===================================================================
---- qtbase-opensource-src-5.9.0.orig/src/network/kernel/qhostinfo_unix.cpp
-+++ qtbase-opensource-src-5.9.0/src/network/kernel/qhostinfo_unix.cpp
-@@ -102,7 +102,7 @@ static bool resolveLibraryInternal()
-     if (!lib.load())
- #endif
-     {
--        lib.setFileName(QLatin1String("resolv"));
-+        lib.setFileName(QLatin1String(NIXPKGS_LIBRESOLV));
-         if (!lib.load())
-             return false;
-     }
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase/library-paths.patch b/pkgs/development/libraries/qt-5/5.9/qtbase/library-paths.patch
deleted file mode 100644
index 4c24d73ed364..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtbase/library-paths.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-Index: qtbase-opensource-src-5.9.0/src/corelib/kernel/qcoreapplication.cpp
-===================================================================
---- qtbase-opensource-src-5.9.0.orig/src/corelib/kernel/qcoreapplication.cpp
-+++ qtbase-opensource-src-5.9.0/src/corelib/kernel/qcoreapplication.cpp
-@@ -2533,6 +2533,15 @@ QStringList QCoreApplication::libraryPat
-         QStringList *app_libpaths = new QStringList;
-         coreappdata()->app_libpaths.reset(app_libpaths);
- 
-+        // Add library paths derived from PATH
-+        const QStringList paths = QFile::decodeName(qgetenv("PATH")).split(':');
-+        const QString plugindir = QStringLiteral("../" NIXPKGS_QT_PLUGIN_PREFIX);
-+        for (const QString &path: paths) {
-+            if (!path.isEmpty()) {
-+                app_libpaths->append(QDir::cleanPath(path + QDir::separator() + plugindir));
-+            }
-+        }
-+
-         const QByteArray libPathEnv = qgetenv("QT_PLUGIN_PATH");
-         if (!libPathEnv.isEmpty()) {
-             QStringList paths = QFile::decodeName(libPathEnv).split(QDir::listSeparator(), QString::SkipEmptyParts);
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase/libressl.patch b/pkgs/development/libraries/qt-5/5.9/qtbase/libressl.patch
deleted file mode 100644
index e9c60e7ab076..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtbase/libressl.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From 81494e67eccba04fc3fe554d76a9ca6fe7f2250e Mon Sep 17 00:00:00 2001
-From: hasufell <hasufell@gentoo.org>
-Date: Sat, 10 Oct 2015 01:15:01 +0200
-Subject: [PATCH] Fix compilation with libressl
-
-By additionally checking for defined(SSL_CTRL_SET_CURVES), which
-is defined in openssl, but not in libressl.
----
- src/network/ssl/qsslcontext_openssl.cpp | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-Index: qtbase-opensource-src-5.8.0/src/network/ssl/qsslcontext_openssl.cpp
-===================================================================
---- qtbase-opensource-src-5.8.0.orig/src/network/ssl/qsslcontext_openssl.cpp
-+++ qtbase-opensource-src-5.8.0/src/network/ssl/qsslcontext_openssl.cpp
-@@ -351,7 +351,7 @@ init_context:
- 
-     const QVector<QSslEllipticCurve> qcurves = sslContext->sslConfiguration.ellipticCurves();
-     if (!qcurves.isEmpty()) {
--#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_EC)
-+#if OPENSSL_VERSION_NUMBER >= 0x10002000L && defined(SSL_CTRL_SET_CURVES) && !defined(OPENSSL_NO_EC)
-         // Set the curves to be used
-         if (q_SSLeay() >= 0x10002000L) {
-             // SSL_CTX_ctrl wants a non-const pointer as last argument,
-@@ -364,7 +364,7 @@ init_context:
-                 sslContext->errorCode = QSslError::UnspecifiedError;
-             }
-         } else
--#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_EC)
-+#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L && defined(SSL_CTRL_SET_CURVES) && !defined(OPENSSL_NO_EC)
-         {
-             // specific curves requested, but not possible to set -> error
-             sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocket::tr("OpenSSL version too old, need at least v1.0.2"));
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase/mkspecs-common-mac.patch b/pkgs/development/libraries/qt-5/5.9/qtbase/mkspecs-common-mac.patch
deleted file mode 100644
index b77f87781226..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtbase/mkspecs-common-mac.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- qtbase-opensource-src-5.9.1.orig/mkspecs/common/mac.conf	2017-09-16 16:40:30.000000000 +0800
-+++ qtbase-opensource-src-5.9.1/mkspecs/common/mac.conf	2017-09-16 16:41:27.000000000 +0800
-@@ -23,7 +23,7 @@
- 
- QMAKE_FIX_RPATH         = install_name_tool -id
- 
--QMAKE_LFLAGS_RPATH      = -Wl,-rpath,
-+QMAKE_LFLAGS_RPATH      =
- QMAKE_LFLAGS_GCSECTIONS = -Wl,-dead_strip
- 
- QMAKE_LFLAGS_REL_RPATH  =
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase/mkspecs-features-mac.patch b/pkgs/development/libraries/qt-5/5.9/qtbase/mkspecs-features-mac.patch
deleted file mode 100644
index 46d950a767bb..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtbase/mkspecs-features-mac.patch
+++ /dev/null
@@ -1,292 +0,0 @@
-diff -u -r qtbase-opensource-src-5.9.2.orig/mkspecs/features/mac/default_post.prf qtbase-opensource-src-5.9.2/mkspecs/features/mac/default_post.prf
---- qtbase-opensource-src-5.9.2.orig/mkspecs/features/mac/default_post.prf	2017-10-14 12:31:04.000000000 +0800
-+++ qtbase-opensource-src-5.9.2/mkspecs/features/mac/default_post.prf	2017-10-14 12:42:02.000000000 +0800
-@@ -24,166 +24,3 @@
-         }
-     }
- }
--
--# Add the same default rpaths as Xcode does for new projects.
--# This is especially important for iOS/tvOS/watchOS where no other option is possible.
--!no_default_rpath {
--    QMAKE_RPATHDIR += @executable_path/Frameworks
--    equals(TEMPLATE, lib):!plugin:lib_bundle: QMAKE_RPATHDIR += @loader_path/Frameworks
--}
--
--# Don't pass -headerpad_max_install_names when using Bitcode.
--# In that case the linker emits a warning stating that the flag is ignored when
--# used with bitcode, for reasons that cannot be determined (rdar://problem/20748962).
--# Using this flag is also unnecessary in practice on UIKit platforms since they
--# are sandboxed, and only UIKit platforms support bitcode to begin with.
--!bitcode: QMAKE_LFLAGS += $$QMAKE_LFLAGS_HEADERPAD
--
--app_extension_api_only {
--    QMAKE_CFLAGS              += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
--    QMAKE_CXXFLAGS            += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
--    QMAKE_CXXFLAGS_PRECOMPILE += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
--    QMAKE_LFLAGS              += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
--}
--
--macx-xcode {
--    !isEmpty(QMAKE_XCODE_DEBUG_INFORMATION_FORMAT) {
--        debug_information_format.name = DEBUG_INFORMATION_FORMAT
--        debug_information_format.value = $$QMAKE_XCODE_DEBUG_INFORMATION_FORMAT
--        debug_information_format.build = debug
--        QMAKE_MAC_XCODE_SETTINGS += debug_information_format
--    }
--
--    QMAKE_XCODE_ARCHS =
--
--    arch_device.name = "ARCHS[sdk=$${device.sdk}*]"
--    arch_device.value = $$QMAKE_APPLE_DEVICE_ARCHS
--    QMAKE_XCODE_ARCHS += $$QMAKE_APPLE_DEVICE_ARCHS
--    QMAKE_MAC_XCODE_SETTINGS += arch_device
--
--    simulator {
--        arch_simulator.name = "ARCHS[sdk=$${simulator.sdk}*]"
--        arch_simulator.value = $$QMAKE_APPLE_SIMULATOR_ARCHS
--        QMAKE_XCODE_ARCHS += $$QMAKE_APPLE_SIMULATOR_ARCHS
--        QMAKE_MAC_XCODE_SETTINGS += arch_simulator
--    }
--
--    only_active_arch.name = ONLY_ACTIVE_ARCH
--    only_active_arch.value = YES
--    only_active_arch.build = debug
--    QMAKE_MAC_XCODE_SETTINGS += only_active_arch
--} else {
--    device|!simulator: VALID_DEVICE_ARCHS = $$QMAKE_APPLE_DEVICE_ARCHS
--    simulator: VALID_SIMULATOR_ARCHS = $$QMAKE_APPLE_SIMULATOR_ARCHS
--    VALID_ARCHS = $$VALID_DEVICE_ARCHS $$VALID_SIMULATOR_ARCHS
--
--    isEmpty(VALID_ARCHS): \
--        error("QMAKE_APPLE_DEVICE_ARCHS or QMAKE_APPLE_SIMULATOR_ARCHS must contain at least one architecture")
--
--    single_arch: VALID_ARCHS = $$first(VALID_ARCHS)
--
--    ACTIVE_ARCHS = $(filter $(EXPORT_VALID_ARCHS), $(ARCHS))
--    ARCH_ARGS = $(foreach arch, $(if $(EXPORT_ACTIVE_ARCHS), $(EXPORT_ACTIVE_ARCHS), $(EXPORT_VALID_ARCHS)), -arch $(arch))
--
--    QMAKE_EXTRA_VARIABLES += VALID_ARCHS ACTIVE_ARCHS ARCH_ARGS
--
--    arch_flags = $(EXPORT_ARCH_ARGS)
--
--    QMAKE_CFLAGS += $$arch_flags
--    QMAKE_CXXFLAGS += $$arch_flags
--    QMAKE_LFLAGS += $$arch_flags
--
--    QMAKE_PCH_ARCHS = $$VALID_ARCHS
--
--    macos: deployment_target = $$QMAKE_MACOSX_DEPLOYMENT_TARGET
--    ios: deployment_target = $$QMAKE_IOS_DEPLOYMENT_TARGET
--    tvos: deployment_target = $$QMAKE_TVOS_DEPLOYMENT_TARGET
--    watchos: deployment_target = $$QMAKE_WATCHOS_DEPLOYMENT_TARGET
--
--    # If we're doing a simulator and device build, device and simulator
--    # architectures use different paths and flags for the sysroot and
--    # deployment target switch, so we must multiplex them across multiple
--    # architectures using -Xarch. Otherwise we fall back to the simple path.
--    # This is not strictly necessary, but results in cleaner command lines
--    # and makes it easier for people to override EXPORT_VALID_ARCHS to limit
--    # individual rules to a different set of architecture(s) from the overall
--    # build (such as machtest in QtCore).
--    simulator:device {
--        QMAKE_XARCH_CFLAGS =
--        QMAKE_XARCH_LFLAGS =
--        QMAKE_EXTRA_VARIABLES += QMAKE_XARCH_CFLAGS QMAKE_XARCH_LFLAGS
--
--        for (arch, VALID_ARCHS) {
--            contains(VALID_SIMULATOR_ARCHS, $$arch) {
--                sdk = $$simulator.sdk
--                version_identifier = $$simulator.deployment_identifier
--            } else {
--                sdk = $$device.sdk
--                version_identifier = $$device.deployment_identifier
--            }
--
--            version_min_flags = \
--                -Xarch_$${arch} \
--                -m$${version_identifier}-version-min=$$deployment_target
--            QMAKE_XARCH_CFLAGS_$${arch} = $$version_min_flags \
--                -Xarch_$${arch} \
--                -isysroot$$xcodeSDKInfo(Path, $$sdk)
--            QMAKE_XARCH_LFLAGS_$${arch} = $$version_min_flags \
--                -Xarch_$${arch} \
--                -Wl,-syslibroot,$$xcodeSDKInfo(Path, $$sdk)
--
--            QMAKE_XARCH_CFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS_$${arch})
--            QMAKE_XARCH_LFLAGS += $(EXPORT_QMAKE_XARCH_LFLAGS_$${arch})
--
--            QMAKE_EXTRA_VARIABLES += \
--                QMAKE_XARCH_CFLAGS_$${arch} \
--                QMAKE_XARCH_LFLAGS_$${arch}
--        }
--
--        QMAKE_CFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS)
--        QMAKE_CXXFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS)
--        QMAKE_LFLAGS += $(EXPORT_QMAKE_XARCH_LFLAGS)
--    } else {
--        simulator: \
--            version_identifier = $$simulator.deployment_identifier
--        else: \
--            version_identifier = $$device.deployment_identifier
--        version_min_flag = -m$${version_identifier}-version-min=$$deployment_target
--        QMAKE_CFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag
--        QMAKE_CXXFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag
--        QMAKE_LFLAGS += -Wl,-syslibroot,$$QMAKE_MAC_SDK_PATH $$version_min_flag
--    }
--
--    # Enable precompiled headers for multiple architectures
--    QMAKE_CFLAGS_USE_PRECOMPILE =
--    for (arch, VALID_ARCHS) {
--        icc_pch_style: \
--            use_flag = "-pch-use "
--        else: \
--            use_flag = -include
--
--        # Only use Xarch with multi-arch, as the option confuses ccache
--        count(VALID_ARCHS, 1, greaterThan): \
--            QMAKE_CFLAGS_USE_PRECOMPILE += \
--                -Xarch_$${arch}
--
--        QMAKE_CFLAGS_USE_PRECOMPILE += \
--            $${use_flag}${QMAKE_PCH_OUTPUT_$${arch}}
--    }
--    icc_pch_style {
--        QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE -include ${QMAKE_PCH_INPUT}
--        QMAKE_CFLAGS_USE_PRECOMPILE =
--    } else {
--        QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
--        QMAKE_OBJCFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
--        QMAKE_OBJCXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
--    }
--
--    QMAKE_PCH_OUTPUT_EXT = _${QMAKE_PCH_ARCH}$${QMAKE_PCH_OUTPUT_EXT}
--}
--
--cache(QMAKE_XCODE_DEVELOPER_PATH, stash)
--!isEmpty(QMAKE_XCODE_VERSION): \
--    cache(QMAKE_XCODE_VERSION, stash)
--
--QMAKE_XCODE_LIBRARY_SUFFIX = $$qtPlatformTargetSuffix()
-diff -u -r qtbase-opensource-src-5.9.2.orig/mkspecs/features/mac/default_pre.prf qtbase-opensource-src-5.9.2/mkspecs/features/mac/default_pre.prf
---- qtbase-opensource-src-5.9.2.orig/mkspecs/features/mac/default_pre.prf	2017-10-14 12:31:04.000000000 +0800
-+++ qtbase-opensource-src-5.9.2/mkspecs/features/mac/default_pre.prf	2017-10-14 12:42:02.000000000 +0800
-@@ -1,56 +1,2 @@
- CONFIG = asset_catalogs rez $$CONFIG
- load(default_pre)
--
--isEmpty(QMAKE_XCODE_DEVELOPER_PATH) {
--    # Get path of Xcode's Developer directory
--    QMAKE_XCODE_DEVELOPER_PATH = $$system("/usr/bin/xcode-select --print-path 2>/dev/null")
--    isEmpty(QMAKE_XCODE_DEVELOPER_PATH): \
--        error("Xcode path is not set. Please use xcode-select to choose Xcode installation path.")
--
--    # Make sure Xcode path is valid
--    !exists($$QMAKE_XCODE_DEVELOPER_PATH): \
--        error("Xcode is not installed in $${QMAKE_XCODE_DEVELOPER_PATH}. Please use xcode-select to choose Xcode installation path.")
--}
--
--isEmpty(QMAKE_XCODEBUILD_PATH): \
--    QMAKE_XCODEBUILD_PATH = $$system("/usr/bin/xcrun -find xcodebuild 2>/dev/null")
--
--!isEmpty(QMAKE_XCODEBUILD_PATH) {
--    # Make sure Xcode is set up properly
--    !system("/usr/bin/xcrun xcodebuild -license check 2>/dev/null"): \
--        error("Xcode not set up properly. You need to confirm the license agreement by running 'sudo xcrun xcodebuild -license accept'.")
--
--    isEmpty(QMAKE_XCODE_VERSION) {
--        # Extract Xcode version using xcodebuild
--        xcode_version = $$system("/usr/bin/xcrun xcodebuild -version")
--        QMAKE_XCODE_VERSION = $$member(xcode_version, 1)
--        isEmpty(QMAKE_XCODE_VERSION): error("Could not resolve Xcode version.")
--        unset(xcode_version)
--    }
--}
--
--isEmpty(QMAKE_TARGET_BUNDLE_PREFIX) {
--    QMAKE_XCODE_PREFERENCES_FILE = $$(HOME)/Library/Preferences/com.apple.dt.Xcode.plist
--    exists($$QMAKE_XCODE_PREFERENCES_FILE): \
--        QMAKE_TARGET_BUNDLE_PREFIX = $$system("/usr/libexec/PlistBuddy -c 'print IDETemplateOptions:bundleIdentifierPrefix' $$QMAKE_XCODE_PREFERENCES_FILE 2>/dev/null")
--
--    !isEmpty(_QMAKE_CACHE_):!isEmpty(QMAKE_TARGET_BUNDLE_PREFIX): \
--        cache(QMAKE_TARGET_BUNDLE_PREFIX)
--}
--
--QMAKE_ASSET_CATALOGS_APP_ICON = AppIcon
--
--# Make the default debug info format for static debug builds
--# DWARF instead of DWARF with dSYM. This cuts down build times
--# for application debug builds significantly, as Xcode doesn't
--# have to pull out all the DWARF info from the Qt static libs
--# and put it into a dSYM file. We don't need that dSYM file in
--# the first place, since the information is available in the
--# object files inside the archives (static libraries).
--macx-xcode:qtConfig(static): \
--    QMAKE_XCODE_DEBUG_INFORMATION_FORMAT = dwarf
--
--# This variable is used by the xcode_dynamic_library_suffix
--# feature, which allows Xcode to choose the Qt libraries to link to
--# at build time, depending on the current Xcode SDK and configuration.
--QMAKE_XCODE_LIBRARY_SUFFIX_SETTING = QT_LIBRARY_SUFFIX
-diff -u -r qtbase-opensource-src-5.9.2.orig/mkspecs/features/mac/sdk.prf qtbase-opensource-src-5.9.2/mkspecs/features/mac/sdk.prf
---- qtbase-opensource-src-5.9.2.orig/mkspecs/features/mac/sdk.prf	2017-10-14 12:31:04.000000000 +0800
-+++ qtbase-opensource-src-5.9.2/mkspecs/features/mac/sdk.prf	2017-10-14 12:42:10.000000000 +0800
-@@ -1,58 +0,0 @@
--
--isEmpty(QMAKE_MAC_SDK): \
--    error("QMAKE_MAC_SDK must be set when using CONFIG += sdk.")
--
--contains(QMAKE_MAC_SDK, .*/.*): \
--    error("QMAKE_MAC_SDK can only contain short-form SDK names (eg. macosx, iphoneos)")
--
--defineReplace(xcodeSDKInfo) {
--    info = $$1
--    equals(info, "Path"): \
--        info = --show-sdk-path
--    equals(info, "PlatformPath"): \
--        info = --show-sdk-platform-path
--    equals(info, "SDKVersion"): \
--        info = --show-sdk-version
--    sdk = $$2
--    isEmpty(sdk): \
--        sdk = $$QMAKE_MAC_SDK
--
--    isEmpty(QMAKE_MAC_SDK.$${sdk}.$${info}) {
--        QMAKE_MAC_SDK.$${sdk}.$${info} = $$system("/usr/bin/xcrun --sdk $$sdk $$info 2>/dev/null")
--        # --show-sdk-platform-path won't work for Command Line Tools; this is fine
--        # only used by the XCTest backend to testlib
--        isEmpty(QMAKE_MAC_SDK.$${sdk}.$${info}):if(!isEmpty(QMAKE_XCODEBUILD_PATH)|!equals(info, "--show-sdk-platform-path")): \
--            error("Could not resolve SDK $$info for \'$$sdk\'")
--        cache(QMAKE_MAC_SDK.$${sdk}.$${info}, set stash, QMAKE_MAC_SDK.$${sdk}.$${info})
--    }
--
--    return($$eval(QMAKE_MAC_SDK.$${sdk}.$${info}))
--}
--
--QMAKE_MAC_SDK_PATH = $$xcodeSDKInfo(Path)
--QMAKE_MAC_SDK_PLATFORM_PATH = $$xcodeSDKInfo(PlatformPath)
--QMAKE_MAC_SDK_VERSION = $$xcodeSDKInfo(SDKVersion)
--
--sysrootified =
--for(val, QMAKE_INCDIR_OPENGL): sysrootified += $${QMAKE_MAC_SDK_PATH}$$val
--QMAKE_INCDIR_OPENGL = $$sysrootified
--
--QMAKESPEC_NAME = $$basename(QMAKESPEC)
--
--# Resolve SDK version of various tools
--for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_FIX_RPATH QMAKE_AR QMAKE_RANLIB QMAKE_LINK QMAKE_LINK_SHLIB QMAKE_ACTOOL)) {
--    tool_variable = QMAKE_MAC_SDK.$${QMAKESPEC_NAME}.$${QMAKE_MAC_SDK}.$${tool}
--    !isEmpty($$tool_variable) {
--        $$tool = $$eval($$tool_variable)
--        next()
--    }
--
--    value = $$eval($$tool)
--    isEmpty(value): next()
--
--    sysrooted = $$system("/usr/bin/xcrun -sdk $$QMAKE_MAC_SDK -find $$first(value) 2>/dev/null")
--    isEmpty(sysrooted): next()
--
--    $$tool = $$sysrooted $$member(value, 1, -1)
--    cache($$tool_variable, set stash, $$tool)
--}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase/qgtk-env.patch b/pkgs/development/libraries/qt-5/5.9/qtbase/qgtk-env.patch
deleted file mode 100644
index 8e5e2c71828a..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtbase/qgtk-env.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-Index: qtbase-opensource-src-5.8.0/src/plugins/platformthemes/gtk3/main.cpp
-===================================================================
---- qtbase-opensource-src-5.8.0.orig/src/plugins/platformthemes/gtk3/main.cpp
-+++ qtbase-opensource-src-5.8.0/src/plugins/platformthemes/gtk3/main.cpp
-@@ -39,6 +39,7 @@
- 
- #include <qpa/qplatformthemeplugin.h>
- #include "qgtk3theme.h"
-+#include <QFile>
- 
- QT_BEGIN_NAMESPACE
- 
-@@ -54,8 +55,22 @@ public:
- QPlatformTheme *QGtk3ThemePlugin::create(const QString &key, const QStringList &params)
- {
-     Q_UNUSED(params);
--    if (!key.compare(QLatin1String(QGtk3Theme::name), Qt::CaseInsensitive))
-+    if (!key.compare(QLatin1String(QGtk3Theme::name), Qt::CaseInsensitive)) {
-+
-+#ifdef NIXPKGS_QGTK3_XDG_DATA_DIRS
-+        QStringList XDG_DATA_DIRS = QFile::decodeName(qgetenv("XDG_DATA_DIRS")).split(':');
-+        XDG_DATA_DIRS << QLatin1String(NIXPKGS_QGTK3_XDG_DATA_DIRS);
-+        qputenv("XDG_DATA_DIRS", QFile::encodeName(XDG_DATA_DIRS.join(':')));
-+#endif
-+
-+#ifdef NIXPKGS_QGTK3_GIO_EXTRA_MODULES
-+        QStringList GIO_EXTRA_MODULES = QFile::decodeName(qgetenv("GIO_EXTRA_MODULES")).split(':');
-+        GIO_EXTRA_MODULES << QLatin1String(NIXPKGS_QGTK3_GIO_EXTRA_MODULES);
-+        qputenv("GIO_EXTRA_MODULES", QFile::encodeName(GIO_EXTRA_MODULES.join(':')));
-+#endif
-+
-         return new QGtk3Theme;
-+    }
- 
-     return 0;
- }
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase/qnativesocketengine-type-pun.patch b/pkgs/development/libraries/qt-5/5.9/qtbase/qnativesocketengine-type-pun.patch
deleted file mode 100644
index ad40dfab2f7b..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtbase/qnativesocketengine-type-pun.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-Index: qtbase-opensource-src-5.8.0/src/network/socket/qnativesocketengine_unix.cpp
-===================================================================
---- qtbase-opensource-src-5.8.0.orig/src/network/socket/qnativesocketengine_unix.cpp
-+++ qtbase-opensource-src-5.8.0/src/network/socket/qnativesocketengine_unix.cpp
-@@ -979,7 +979,8 @@ qint64 QNativeSocketEnginePrivate::nativ
-             if (cmsgptr->cmsg_len == CMSG_LEN(sizeof(int))
-                     && ((cmsgptr->cmsg_level == IPPROTO_IPV6 && cmsgptr->cmsg_type == IPV6_HOPLIMIT)
-                         || (cmsgptr->cmsg_level == IPPROTO_IP && cmsgptr->cmsg_type == IP_TTL))) {
--                header->hopLimit = *reinterpret_cast<int *>(CMSG_DATA(cmsgptr));
-+                int *ttl = reinterpret_cast<int *>(CMSG_DATA(cmsgptr));
-+                header->hopLimit = *ttl;
-             }
- 
- #ifndef QT_NO_SCTP
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase/series b/pkgs/development/libraries/qt-5/5.9/qtbase/series
deleted file mode 100644
index 4f354e87c847..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtbase/series
+++ /dev/null
@@ -1,9 +0,0 @@
-dlopen-resolv.patch
-tzdir.patch
-dlopen-libXcursor.patch
-library-paths.patch
-libressl.patch
-dlopen-gl.patch
-compose-search-path.patch
-cmake-paths.patch
-qgtk-env.patch
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase/tzdir.patch b/pkgs/development/libraries/qt-5/5.9/qtbase/tzdir.patch
deleted file mode 100644
index d57f24c3ed0a..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtbase/tzdir.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-Index: qtbase-opensource-src-5.9.0/src/corelib/tools/qtimezoneprivate_tz.cpp
-===================================================================
---- qtbase-opensource-src-5.9.0.orig/src/corelib/tools/qtimezoneprivate_tz.cpp
-+++ qtbase-opensource-src-5.9.0/src/corelib/tools/qtimezoneprivate_tz.cpp
-@@ -70,7 +70,11 @@ typedef QHash<QByteArray, QTzTimeZone> Q
- // Parse zone.tab table, assume lists all installed zones, if not will need to read directories
- static QTzTimeZoneHash loadTzTimeZones()
- {
--    QString path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
-+    // Try TZDIR first, in case we're running on NixOS.
-+    QString path = QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/zone.tab");
-+    // Fallback to traditional paths in case we are not on NixOS.
-+    if (!QFile::exists(path))
-+        path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
-     if (!QFile::exists(path))
-         path = QStringLiteral("/usr/lib/zoneinfo/zone.tab");
- 
-@@ -643,12 +647,16 @@ void QTzTimeZonePrivate::init(const QByt
-         if (!tzif.open(QIODevice::ReadOnly))
-             return;
-     } else {
--        // Open named tz, try modern path first, if fails try legacy path
--        tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
-+        // Try TZDIR first, in case we're running on NixOS
-+        tzif.setFileName(QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/") + QString::fromLocal8Bit(ianaId));
-         if (!tzif.open(QIODevice::ReadOnly)) {
--            tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
--            if (!tzif.open(QIODevice::ReadOnly))
--                return;
-+            // Open named tz, try modern path first, if fails try legacy path
-+            tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
-+            if (!tzif.open(QIODevice::ReadOnly)) {
-+                tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
-+                if (!tzif.open(QIODevice::ReadOnly))
-+                    return;
-+            }
-         }
-     }
- 
diff --git a/pkgs/development/libraries/qt-5/5.9/qtcharts.nix b/pkgs/development/libraries/qt-5/5.9/qtcharts.nix
deleted file mode 100644
index afc09e3eeb58..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtcharts.nix
+++ /dev/null
@@ -1,10 +0,0 @@
-{ qtSubmodule, qtbase, qtdeclarative }:
-
-qtSubmodule {
-  name = "qtcharts";
-  qtInputs = [ qtbase qtdeclarative ];
-  outputs = [ "bin" "dev" "out" ];
-  postInstall = ''
-    moveToOutput "$qtQmlPrefix" "$bin"
-  '';
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtconnectivity.nix b/pkgs/development/libraries/qt-5/5.9/qtconnectivity.nix
deleted file mode 100644
index 8153f0d40785..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtconnectivity.nix
+++ /dev/null
@@ -1,10 +0,0 @@
-{ qtSubmodule, qtbase, qtdeclarative }:
-
-qtSubmodule {
-  name = "qtconnectivity";
-  qtInputs = [ qtbase qtdeclarative ];
-  outputs = [ "bin" "dev" "out" ];
-  postInstall = ''
-    moveToOutput "$qtQmlPrefix" "$bin"
-  '';
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtdeclarative.patch b/pkgs/development/libraries/qt-5/5.9/qtdeclarative.patch
new file mode 100644
index 000000000000..bb1bbbeb05e0
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.9/qtdeclarative.patch
@@ -0,0 +1,33 @@
+diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
+index ee5b38717..bbccef8c4 100644
+--- a/src/qml/qml/qqmlimport.cpp
++++ b/src/qml/qml/qqmlimport.cpp
+@@ -1678,6 +1678,15 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e)
+     QString installImportsPath =  QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
+     addImportPath(installImportsPath);
+ 
++    // Add import paths derived from PATH
++    const QStringList paths = QFile::decodeName(qgetenv("PATH")).split(':');
++    const QString qmldir = QStringLiteral("../" NIXPKGS_QML2_IMPORT_PREFIX);
++    for (const QString &path: paths) {
++        if (!path.isEmpty()) {
++            addImportPath(QDir::cleanPath(path + QDir::separator() + qmldir));
++        }
++    }
++
+     // env import paths
+     if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QML2_IMPORT_PATH"))) {
+         const QByteArray envImportPath = qgetenv("QML2_IMPORT_PATH");
+diff --git a/tools/qmlcachegen/qmlcache.prf b/tools/qmlcachegen/qmlcache.prf
+index 330da358b..cdf570205 100644
+--- a/tools/qmlcachegen/qmlcache.prf
++++ b/tools/qmlcachegen/qmlcache.prf
+@@ -44,7 +44,7 @@ defineReplace(qmlCacheOutputFileName) {
+ }
+ 
+ qmlcacheinst.base = $$QMLCACHE_DESTDIR
+-qmlcacheinst.path = $$[QT_INSTALL_QML]/$$TARGETPATH
++qmlcacheinst.path = $$NIX_OUTPUT_QML/$$TARGETPATH
+ qmlcacheinst.CONFIG = no_check_exist
+ 
+ qmlcachegen.input = CACHEGEN_FILES
diff --git a/pkgs/development/libraries/qt-5/5.9/qtdeclarative/default.nix b/pkgs/development/libraries/qt-5/5.9/qtdeclarative/default.nix
deleted file mode 100644
index 39b4d35ef36c..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtdeclarative/default.nix
+++ /dev/null
@@ -1,20 +0,0 @@
-{ stdenv, qtSubmodule, copyPathsToStore, python2, qtbase, qtsvg, qtxmlpatterns }:
-
-with stdenv.lib;
-
-qtSubmodule {
-  name = "qtdeclarative";
-  patches = copyPathsToStore (readPathsFromFile ./. ./series);
-  qtInputs = [ qtbase qtsvg qtxmlpatterns ];
-  nativeBuildInputs = [ python2 ];
-  outputs = [ "bin" "dev" "out" ];
-
-  preConfigure = ''
-    NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QML2_IMPORT_PREFIX=\"$qtQmlPrefix\""
-  '';
-
-  postInstall = ''
-    moveToOutput "$qtPluginPrefix" "$bin"
-    moveToOutput "$qtQmlPrefix" "$bin"
-  '';
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtdeclarative/series b/pkgs/development/libraries/qt-5/5.9/qtdeclarative/series
deleted file mode 100644
index 38abb916a508..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtdeclarative/series
+++ /dev/null
@@ -1 +0,0 @@
-import-paths.patch
diff --git a/pkgs/development/libraries/qt-5/5.9/qtgraphicaleffects.nix b/pkgs/development/libraries/qt-5/5.9/qtgraphicaleffects.nix
deleted file mode 100644
index 3273f12eb830..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtgraphicaleffects.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ qtSubmodule, qtdeclarative }:
-
-qtSubmodule {
-  name = "qtgraphicaleffects";
-  qtInputs = [ qtdeclarative ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtimageformats.nix b/pkgs/development/libraries/qt-5/5.9/qtimageformats.nix
deleted file mode 100644
index 03d0fffbe80e..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtimageformats.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ qtSubmodule, qtbase }:
-
-qtSubmodule {
-  name = "qtimageformats";
-  qtInputs = [ qtbase ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtlocation.nix b/pkgs/development/libraries/qt-5/5.9/qtlocation.nix
deleted file mode 100644
index f883fd4ff40f..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtlocation.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-{ qtSubmodule, qtbase, qtmultimedia }:
-
-qtSubmodule {
-  name = "qtlocation";
-  qtInputs = [ qtbase qtmultimedia ];
-  outputs = [ "bin" "dev" "out" ];
-  postInstall = ''
-    moveToOutput "$qtPluginPrefix" "$bin"
-    moveToOutput "$qtQmlPrefix" "$bin"
-  '';
-  # Linking with -lclipper fails with parallel build enabled
-  enableParallelBuilding = false;
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtquickcontrols2.nix b/pkgs/development/libraries/qt-5/5.9/qtquickcontrols2.nix
deleted file mode 100644
index 37d7d59f8153..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtquickcontrols2.nix
+++ /dev/null
@@ -1,10 +0,0 @@
-{ qtSubmodule, qtdeclarative }:
-
-qtSubmodule {
-  name = "qtquickcontrols2";
-  qtInputs = [ qtdeclarative ];
-  outputs = [ "bin" "dev" "out" ];
-  postInstall = ''
-    moveToOutput "$qtQmlPrefix" "$bin"
-  '';
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtscript.patch b/pkgs/development/libraries/qt-5/5.9/qtscript.patch
new file mode 100644
index 000000000000..5508dec1280e
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.9/qtscript.patch
@@ -0,0 +1,13 @@
+diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h
+index 1f6d25e..087c3fb 100644
+--- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h
++++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h
+@@ -81,7 +81,7 @@
+ #include <pthread.h>
+ #elif PLATFORM(GTK)
+ #include <wtf/gtk/GOwnPtr.h>
+-typedef struct _GMutex GMutex;
++typedef union _GMutex GMutex;
+ typedef struct _GCond GCond;
+ #endif
+ 
diff --git a/pkgs/development/libraries/qt-5/5.9/qtscript/default.nix b/pkgs/development/libraries/qt-5/5.9/qtscript/default.nix
deleted file mode 100644
index 127766e2ebd6..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtscript/default.nix
+++ /dev/null
@@ -1,7 +0,0 @@
-{ qtSubmodule, qtbase, qttools }:
-
-qtSubmodule {
-  name = "qtscript";
-  qtInputs = [ qtbase qttools ];
-  patches = [ ./0001-glib-2.32.patch ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtsensors.nix b/pkgs/development/libraries/qt-5/5.9/qtsensors.nix
deleted file mode 100644
index 4127d00b7693..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtsensors.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-{ stdenv, qtSubmodule, qtbase, qtdeclarative }:
-
-with stdenv.lib;
-
-qtSubmodule {
-  name = "qtsensors";
-  qtInputs = [ qtbase qtdeclarative ];
-  outputs = [ "bin" "dev" "out" ];
-  postInstall = ''
-    moveToOutput "$qtPluginPrefix" "$bin"
-    moveToOutput "$qtQmlPrefix" "$bin"
-  '';
-}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtserialport/0001-dlopen-serialport-udev.patch b/pkgs/development/libraries/qt-5/5.9/qtserialport.patch
index 9893fdff9a5c..f25524e80bcf 100644
--- a/pkgs/development/libraries/qt-5/5.6/qtserialport/0001-dlopen-serialport-udev.patch
+++ b/pkgs/development/libraries/qt-5/5.9/qtserialport.patch
@@ -1,28 +1,22 @@
-From d81c2c870b9bea8fb8e6b85baefb06542f568338 Mon Sep 17 00:00:00 2001
-From: Thomas Tuegel <ttuegel@gmail.com>
-Date: Sun, 23 Aug 2015 09:16:02 -0500
-Subject: [PATCH] dlopen serialport udev
-
----
- src/serialport/qtudev_p.h | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
 diff --git a/src/serialport/qtudev_p.h b/src/serialport/qtudev_p.h
-index 6f2cabd..81b9849 100644
+index af2dab2..8e17f64 100644
 --- a/src/serialport/qtudev_p.h
 +++ b/src/serialport/qtudev_p.h
-@@ -105,10 +105,9 @@ inline QFunctionPointer resolveSymbol(QLibrary *udevLibrary, const char *symbolN
+@@ -111,9 +111,17 @@ inline QFunctionPointer resolveSymbol(QLibrary *udevLibrary, const char *symbolN
  inline bool resolveSymbols(QLibrary *udevLibrary)
  {
      if (!udevLibrary->isLoaded()) {
--        udevLibrary->setFileNameAndVersion(QStringLiteral("udev"), 1);
++#ifdef NIXPKGS_LIBUDEV
 +        udevLibrary->setFileNameAndVersion(QLatin1String(NIXPKGS_LIBUDEV), 1);
++#else
+         udevLibrary->setFileNameAndVersion(QStringLiteral("udev"), 1);
++#endif
          if (!udevLibrary->load()) {
--            udevLibrary->setFileNameAndVersion(QStringLiteral("udev"), 0);
++#ifdef NIXPKGS_LIBUDEV
 +            udevLibrary->setFileNameAndVersion(QLatin1String(NIXPKGS_LIBUDEV), 0);
++#else
+             udevLibrary->setFileNameAndVersion(QStringLiteral("udev"), 0);
++#endif
              if (!udevLibrary->load()) {
                  qWarning("Failed to load the library: %s, supported version(s): %i and %i", qPrintable(udevLibrary->fileName()), 1, 0);
                  return false;
--- 
-2.5.0
-
diff --git a/pkgs/development/libraries/qt-5/5.9/qtserialport/default.nix b/pkgs/development/libraries/qt-5/5.9/qtserialport/default.nix
deleted file mode 100644
index 925e8a808f25..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtserialport/default.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-{ stdenv, qtSubmodule, lib, copyPathsToStore, qtbase, substituteAll, systemd }:
-
-let inherit (lib) getLib optional; in
-
-qtSubmodule {
-  name = "qtserialport";
-  qtInputs = [ qtbase ];
-  patches =  copyPathsToStore (lib.readPathsFromFile ./. ./series);
-  NIX_CFLAGS_COMPILE =
-    optional stdenv.isLinux
-    ''-DNIXPKGS_LIBUDEV="${getLib systemd}/lib/libudev"'';
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtserialport/series b/pkgs/development/libraries/qt-5/5.9/qtserialport/series
deleted file mode 100644
index 83f4abf094e9..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtserialport/series
+++ /dev/null
@@ -1 +0,0 @@
-qtserialport-dlopen-udev.patch
diff --git a/pkgs/development/libraries/qt-5/5.9/qtsvg.nix b/pkgs/development/libraries/qt-5/5.9/qtsvg.nix
deleted file mode 100644
index ce419731dfaf..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtsvg.nix
+++ /dev/null
@@ -1,10 +0,0 @@
-{ qtSubmodule, qtbase }:
-
-qtSubmodule {
-  name = "qtsvg";
-  qtInputs = [ qtbase ];
-  outputs = [ "bin" "dev" "out" ];
-  postInstall = ''
-    moveToOutput "$qtPluginPrefix" "$bin"
-  '';
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/qttools.patch b/pkgs/development/libraries/qt-5/5.9/qttools.patch
new file mode 100644
index 000000000000..fbba439ef7a5
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.9/qttools.patch
@@ -0,0 +1,71 @@
+diff --git a/src/assistant/help/Qt5HelpConfigExtras.cmake.in b/src/assistant/help/Qt5HelpConfigExtras.cmake.in
+index 3b97923a..63336bd5 100644
+--- a/src/assistant/help/Qt5HelpConfigExtras.cmake.in
++++ b/src/assistant/help/Qt5HelpConfigExtras.cmake.in
+@@ -2,11 +2,10 @@
+ if (NOT TARGET Qt5::qcollectiongenerator)
+     add_executable(Qt5::qcollectiongenerator IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Help_install_prefix}/$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
++    if(NOT EXISTS \"${imported_location}\")
++        set(imported_location \"$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
++    endif()
+     _qt5_Help_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::qcollectiongenerator PROPERTIES
+@@ -17,11 +16,7 @@ endif()
+ if (NOT TARGET Qt5::qhelpgenerator)
+     add_executable(Qt5::qhelpgenerator IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5Help_install_prefix}/$${CMAKE_BIN_DIR}qhelpgenerator$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}qhelpgenerator$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
+     _qt5_Help_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::qhelpgenerator PROPERTIES
+diff --git a/src/linguist/Qt5LinguistToolsConfig.cmake.in b/src/linguist/Qt5LinguistToolsConfig.cmake.in
+index 4318b16f..d60db4ff 100644
+--- a/src/linguist/Qt5LinguistToolsConfig.cmake.in
++++ b/src/linguist/Qt5LinguistToolsConfig.cmake.in
+@@ -44,11 +44,7 @@ endmacro()
+ if (NOT TARGET Qt5::lrelease)
+     add_executable(Qt5::lrelease IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
+     _qt5_LinguistTools_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::lrelease PROPERTIES
+@@ -59,11 +55,7 @@ endif()
+ if (NOT TARGET Qt5::lupdate)
+     add_executable(Qt5::lupdate IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
+     _qt5_LinguistTools_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::lupdate PROPERTIES
+@@ -74,11 +66,7 @@ endif()
+ if (NOT TARGET Qt5::lconvert)
+     add_executable(Qt5::lconvert IMPORTED)
+ 
+-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+-    set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lconvert$$CMAKE_BIN_SUFFIX\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}lconvert$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
+     _qt5_LinguistTools_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::lconvert PROPERTIES
diff --git a/pkgs/development/libraries/qt-5/5.9/qttools/cmake-paths.patch b/pkgs/development/libraries/qt-5/5.9/qttools/cmake-paths.patch
deleted file mode 100644
index dfcba9045a75..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qttools/cmake-paths.patch
+++ /dev/null
@@ -1,88 +0,0 @@
-Index: qttools-opensource-src-5.8.0/src/assistant/help/Qt5HelpConfigExtras.cmake.in
-===================================================================
---- qttools-opensource-src-5.8.0.orig/src/assistant/help/Qt5HelpConfigExtras.cmake.in
-+++ qttools-opensource-src-5.8.0/src/assistant/help/Qt5HelpConfigExtras.cmake.in
-@@ -2,11 +2,10 @@
- if (NOT TARGET Qt5::qcollectiongenerator)
-     add_executable(Qt5::qcollectiongenerator IMPORTED)
- 
--!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Help_install_prefix}/$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
--!!ELSE
--    set(imported_location \"$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
--!!ENDIF
-+    set(imported_location \"@NIX_OUT@/$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
-+    if(NOT EXISTS \"${imported_location}\")
-+        set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
-+    endif()
-     _qt5_Help_check_file_exists(${imported_location})
- 
-     set_target_properties(Qt5::qcollectiongenerator PROPERTIES
-@@ -17,11 +16,10 @@ endif()
- if (NOT TARGET Qt5::qhelpgenerator)
-     add_executable(Qt5::qhelpgenerator IMPORTED)
- 
--!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Help_install_prefix}/$${CMAKE_BIN_DIR}qhelpgenerator$$CMAKE_BIN_SUFFIX\")
--!!ELSE
--    set(imported_location \"$${CMAKE_BIN_DIR}qhelpgenerator$$CMAKE_BIN_SUFFIX\")
--!!ENDIF
-+    set(imported_location \"@NIX_OUT@/$${CMAKE_BIN_DIR}qhelpgenerator$$CMAKE_BIN_SUFFIX\")
-+    if(NOT EXISTS \"${imported_location}\")
-+        set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}qhelpgenerator$$CMAKE_BIN_SUFFIX\")
-+    endif()
-     _qt5_Help_check_file_exists(${imported_location})
- 
-     set_target_properties(Qt5::qhelpgenerator PROPERTIES
-Index: qttools-opensource-src-5.8.0/src/linguist/Qt5LinguistToolsConfig.cmake.in
-===================================================================
---- qttools-opensource-src-5.8.0.orig/src/linguist/Qt5LinguistToolsConfig.cmake.in
-+++ qttools-opensource-src-5.8.0/src/linguist/Qt5LinguistToolsConfig.cmake.in
-@@ -44,11 +44,10 @@ endmacro()
- if (NOT TARGET Qt5::lrelease)
-     add_executable(Qt5::lrelease IMPORTED)
- 
--!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\")
--!!ELSE
--    set(imported_location \"$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\")
--!!ENDIF
-+    set(imported_location \"@NIX_OUT@/$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\")
-+    if(NOT EXISTS \"${imported_location}\")
-+        set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\")
-+    endif()
-     _qt5_LinguistTools_check_file_exists(${imported_location})
- 
-     set_target_properties(Qt5::lrelease PROPERTIES
-@@ -59,11 +58,10 @@ endif()
- if (NOT TARGET Qt5::lupdate)
-     add_executable(Qt5::lupdate IMPORTED)
- 
--!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\")
--!!ELSE
--    set(imported_location \"$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\")
--!!ENDIF
-+    set(imported_location \"@NIX_OUT@/$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\")
-+    if(NOT EXISTS \"${imported_location}\")
-+        set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\")
-+    endif()
-     _qt5_LinguistTools_check_file_exists(${imported_location})
- 
-     set_target_properties(Qt5::lupdate PROPERTIES
-@@ -74,11 +72,10 @@ endif()
- if (NOT TARGET Qt5::lconvert)
-     add_executable(Qt5::lconvert IMPORTED)
- 
--!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lconvert$$CMAKE_BIN_SUFFIX\")
--!!ELSE
--    set(imported_location \"$${CMAKE_BIN_DIR}lconvert$$CMAKE_BIN_SUFFIX\")
--!!ENDIF
-+    set(imported_location \"@NIX_OUT@/$${CMAKE_BIN_DIR}lconvert$$CMAKE_BIN_SUFFIX\")
-+    if(NOT EXISTS \"${imported_location}\")
-+        set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}lconvert$$CMAKE_BIN_SUFFIX\")
-+    endif()
-     _qt5_LinguistTools_check_file_exists(${imported_location})
- 
-     set_target_properties(Qt5::lconvert PROPERTIES
diff --git a/pkgs/development/libraries/qt-5/5.9/qttools/default.nix b/pkgs/development/libraries/qt-5/5.9/qttools/default.nix
deleted file mode 100644
index 38d8f1ebe647..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qttools/default.nix
+++ /dev/null
@@ -1,16 +0,0 @@
-{ stdenv, qtSubmodule, copyPathsToStore, qtbase }:
-
-with stdenv.lib;
-
-qtSubmodule {
-  name = "qttools";
-  qtInputs = [ qtbase ];
-  outputs = [ "bin" "dev" "out" ];
-  patches = copyPathsToStore (readPathsFromFile ./. ./series);
-  # qmake moves all binaries to $dev in preFixup
-  postFixup = ''
-    moveToOutput "bin/qdbus" "$bin"
-    moveToOutput "bin/qdbusviewer" "$bin"
-    moveToOutput "bin/qtpaths" "$bin"
-  '';
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/qttools/series b/pkgs/development/libraries/qt-5/5.9/qttools/series
deleted file mode 100644
index 6cc1d3b87bca..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qttools/series
+++ /dev/null
@@ -1 +0,0 @@
-cmake-paths.patch
diff --git a/pkgs/development/libraries/qt-5/5.9/qttranslations.nix b/pkgs/development/libraries/qt-5/5.9/qttranslations.nix
deleted file mode 100644
index 50fc8cf6826a..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qttranslations.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ qtSubmodule, qttools }:
-
-qtSubmodule {
-  name = "qttranslations";
-  qtInputs = [ qttools ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtwayland.nix b/pkgs/development/libraries/qt-5/5.9/qtwayland.nix
deleted file mode 100644
index 8b3072c5534d..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtwayland.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-{ qtSubmodule, qtbase, qtquickcontrols, wayland, pkgconfig }:
-
-qtSubmodule {
-  name = "qtwayland";
-  qtInputs = [ qtbase qtquickcontrols ];
-  buildInputs = [ wayland ];
-  nativeBuildInputs = [ pkgconfig ];
-  outputs = [ "bin" "dev" "out" ];
-  postInstall = ''
-    moveToOutput "$qtPluginPrefix" "$bin"
-    moveToOutput "$qtQmlPrefix" "$bin"
-  '';
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtwebchannel.nix b/pkgs/development/libraries/qt-5/5.9/qtwebchannel.nix
deleted file mode 100644
index e6a2d74e714c..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtwebchannel.nix
+++ /dev/null
@@ -1,11 +0,0 @@
-{ qtSubmodule, qtbase, qtdeclarative }:
-
-qtSubmodule {
-  name = "qtwebchannel";
-  qtInputs = [ qtbase qtdeclarative ];
-  outputs = [ "bin" "dev" "out" ];
-  postInstall = ''
-    moveToOutput "$qtQmlPrefix" "$bin"
-  '';
-}
-
diff --git a/pkgs/development/libraries/qt-5/5.9/qtwebengine/qtwebengine-paxmark-mksnapshot.patch b/pkgs/development/libraries/qt-5/5.9/qtwebengine-paxmark-mksnapshot.patch
index 5e170567ce5d..5e170567ce5d 100644
--- a/pkgs/development/libraries/qt-5/5.9/qtwebengine/qtwebengine-paxmark-mksnapshot.patch
+++ b/pkgs/development/libraries/qt-5/5.9/qtwebengine-paxmark-mksnapshot.patch
diff --git a/pkgs/development/libraries/qt-5/5.9/qtwebkit.patch b/pkgs/development/libraries/qt-5/5.9/qtwebkit.patch
new file mode 100644
index 000000000000..c78cb58f564b
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.9/qtwebkit.patch
@@ -0,0 +1,77 @@
+diff --git a/Source/WTF/WTF.pri b/Source/WTF/WTF.pri
+index 69e4cd1f3..3f729a75e 100644
+--- a/Source/WTF/WTF.pri
++++ b/Source/WTF/WTF.pri
+@@ -12,7 +12,7 @@ mac {
+     # Mac OS does ship libicu but not the associated header files.
+     # Therefore WebKit provides adequate header files.
+     INCLUDEPATH = $${ROOT_WEBKIT_DIR}/Source/WTF/icu $$INCLUDEPATH
+-    LIBS += -licucore
++    LIBS += /usr/lib/libicucore.dylib
+ } else:!use?(wchar_unicode): {
+     win32 {
+         CONFIG(static, static|shared) {
+diff --git a/Source/WebCore/plugins/qt/PluginPackageQt.cpp b/Source/WebCore/plugins/qt/PluginPackageQt.cpp
+index a923d49aa..46772a4bb 100644
+--- a/Source/WebCore/plugins/qt/PluginPackageQt.cpp
++++ b/Source/WebCore/plugins/qt/PluginPackageQt.cpp
+@@ -136,7 +136,11 @@ static void initializeGtk(QLibrary* module = 0)
+         }
+     }
+ 
++#ifdef NIXPKGS_LIBGTK2
++    QLibrary library(QLatin1String(NIXPKGS_LIBGTK2), 0);
++#else
+     QLibrary library(QLatin1String("libgtk-x11-2.0"), 0);
++#endif
+     if (library.load()) {
+         typedef void *(*gtk_init_check_ptr)(int*, char***);
+         gtk_init_check_ptr gtkInitCheck = (gtk_init_check_ptr)library.resolve("gtk_init_check");
+diff --git a/Source/WebCore/plugins/qt/PluginViewQt.cpp b/Source/WebCore/plugins/qt/PluginViewQt.cpp
+index de06a2fea..86fe39ef1 100644
+--- a/Source/WebCore/plugins/qt/PluginViewQt.cpp
++++ b/Source/WebCore/plugins/qt/PluginViewQt.cpp
+@@ -697,7 +697,11 @@ static Display *getPluginDisplay()
+     // support gdk based plugins (like flash) that use a different X connection.
+     // The code below has the same effect as this one:
+     // Display *gdkDisplay = gdk_x11_display_get_xdisplay(gdk_display_get_default());
++#ifdef NIXPKGS_LIBGDK2
++    QLibrary library(QLatin1String(NIXPKGS_LIBGDK2), 0);
++#else
+     QLibrary library(QLatin1String("libgdk-x11-2.0"), 0);
++#endif
+     if (!library.load())
+         return 0;
+ 
+diff --git a/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp b/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
+index 8de65216b..38f5c05e5 100644
+--- a/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
++++ b/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
+@@ -53,7 +53,11 @@ static void messageHandler(QtMsgType type, const QMessageLogContext&, const QStr
+ 
+ static bool initializeGtk()
+ {
++#ifdef NIXPKGS_LIBGTK2
++    QLibrary gtkLibrary(QLatin1String(NIXPKGS_LIBGTK2), 0);
++#else
+     QLibrary gtkLibrary(QLatin1String("libgtk-x11-2.0"), 0);
++#endif
+     if (!gtkLibrary.load())
+         return false;
+     typedef void* (*gtk_init_ptr)(void*, void*);
+diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
+index d734ff684..0f6ff63d1 100644
+--- a/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
++++ b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
+@@ -64,7 +64,11 @@ static Display* getPluginDisplay()
+     // The code below has the same effect as this one:
+     // Display *gdkDisplay = gdk_x11_display_get_xdisplay(gdk_display_get_default());
+ 
++#ifdef NIXPKGS_LIBGDK2
++    QLibrary library(QLatin1String(NIXPKGS_LIBGDK2), 0);
++#else
+     QLibrary library(QLatin1String("libgdk-x11-2.0"), 0);
++#endif
+     if (!library.load())
+         return 0;
+ 
diff --git a/pkgs/development/libraries/qt-5/5.9/qtwebkit/qtwebkit-dlopen-gtk.patch b/pkgs/development/libraries/qt-5/5.9/qtwebkit/qtwebkit-dlopen-gtk.patch
deleted file mode 100644
index e34eda592af7..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtwebkit/qtwebkit-dlopen-gtk.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-Index: qtwebkit-opensource-src-5.8.0/Source/WebCore/plugins/qt/PluginPackageQt.cpp
-===================================================================
---- qtwebkit-opensource-src-5.8.0.orig/Source/WebCore/plugins/qt/PluginPackageQt.cpp
-+++ qtwebkit-opensource-src-5.8.0/Source/WebCore/plugins/qt/PluginPackageQt.cpp
-@@ -136,7 +136,11 @@ static void initializeGtk(QLibrary* modu
-         }
-     }
- 
-+#ifdef NIXPKGS_LIBGTK2
-+    QLibrary library(QLatin1String(NIXPKGS_LIBGTK2), 0);
-+#else
-     QLibrary library(QLatin1String("libgtk-x11-2.0"), 0);
-+#endif
-     if (library.load()) {
-         typedef void *(*gtk_init_check_ptr)(int*, char***);
-         gtk_init_check_ptr gtkInitCheck = (gtk_init_check_ptr)library.resolve("gtk_init_check");
-Index: qtwebkit-opensource-src-5.8.0/Source/WebCore/plugins/qt/PluginViewQt.cpp
-===================================================================
---- qtwebkit-opensource-src-5.8.0.orig/Source/WebCore/plugins/qt/PluginViewQt.cpp
-+++ qtwebkit-opensource-src-5.8.0/Source/WebCore/plugins/qt/PluginViewQt.cpp
-@@ -697,7 +697,11 @@ static Display *getPluginDisplay()
-     // support gdk based plugins (like flash) that use a different X connection.
-     // The code below has the same effect as this one:
-     // Display *gdkDisplay = gdk_x11_display_get_xdisplay(gdk_display_get_default());
-+#ifdef NIXPKGS_LIBGDK2
-+    QLibrary library(QLatin1String(NIXPKGS_LIBGDK2), 0);
-+#else
-     QLibrary library(QLatin1String("libgdk-x11-2.0"), 0);
-+#endif
-     if (!library.load())
-         return 0;
- 
-Index: qtwebkit-opensource-src-5.8.0/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
-===================================================================
---- qtwebkit-opensource-src-5.8.0.orig/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
-+++ qtwebkit-opensource-src-5.8.0/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
-@@ -64,7 +64,11 @@ static Display* getPluginDisplay()
-     // The code below has the same effect as this one:
-     // Display *gdkDisplay = gdk_x11_display_get_xdisplay(gdk_display_get_default());
- 
-+#ifdef NIXPKGS_LIBGDK2
-+    QLibrary library(QLatin1String(NIXPKGS_LIBGDK2), 0);
-+#else
-     QLibrary library(QLatin1String("libgdk-x11-2.0"), 0);
-+#endif
-     if (!library.load())
-         return 0;
- 
-Index: qtwebkit-opensource-src-5.8.0/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
-===================================================================
---- qtwebkit-opensource-src-5.8.0.orig/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
-+++ qtwebkit-opensource-src-5.8.0/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp
-@@ -53,7 +53,11 @@ static void messageHandler(QtMsgType typ
- 
- static bool initializeGtk()
- {
-+#ifdef NIXPKGS_LIBGTK2
-+    QLibrary gtkLibrary(QLatin1String(NIXPKGS_LIBGTK2), 0);
-+#else
-     QLibrary gtkLibrary(QLatin1String("libgtk-x11-2.0"), 0);
-+#endif
-     if (!gtkLibrary.load())
-         return false;
-     typedef void* (*gtk_init_ptr)(void*, void*);
diff --git a/pkgs/development/libraries/qt-5/5.9/qtwebkit/qtwebkit-dlopen-udev.patch b/pkgs/development/libraries/qt-5/5.9/qtwebkit/qtwebkit-dlopen-udev.patch
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtwebkit/qtwebkit-dlopen-udev.patch
+++ /dev/null
diff --git a/pkgs/development/libraries/qt-5/5.9/qtwebkit/qtwebkit-icucore-darwin.patch b/pkgs/development/libraries/qt-5/5.9/qtwebkit/qtwebkit-icucore-darwin.patch
deleted file mode 100644
index 63c653da94ef..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtwebkit/qtwebkit-icucore-darwin.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Index: qtwebkit-opensource-src-5.8.0/Source/WTF/WTF.pri
-===================================================================
---- qtwebkit-opensource-src-5.8.0.orig/Source/WTF/WTF.pri
-+++ qtwebkit-opensource-src-5.8.0/Source/WTF/WTF.pri
-@@ -12,7 +12,7 @@ mac {
-     # Mac OS does ship libicu but not the associated header files.
-     # Therefore WebKit provides adequate header files.
-     INCLUDEPATH = $${ROOT_WEBKIT_DIR}/Source/WTF/icu $$INCLUDEPATH
--    LIBS += -licucore
-+    LIBS += /usr/lib/libicucore.dylib
- } else:!use?(wchar_unicode): {
-     win32 {
-         CONFIG(static, static|shared) {
diff --git a/pkgs/development/libraries/qt-5/5.9/qtwebkit/series b/pkgs/development/libraries/qt-5/5.9/qtwebkit/series
deleted file mode 100644
index 140e2a3dd4e2..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtwebkit/series
+++ /dev/null
@@ -1,3 +0,0 @@
-qtwebkit-dlopen-gtk.patch
-qtwebkit-dlopen-udev.patch
-qtwebkit-icucore-darwin.patch
diff --git a/pkgs/development/libraries/qt-5/5.9/qtwebsockets.nix b/pkgs/development/libraries/qt-5/5.9/qtwebsockets.nix
deleted file mode 100644
index 888c1fb65348..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtwebsockets.nix
+++ /dev/null
@@ -1,10 +0,0 @@
-{ qtSubmodule, qtbase, qtdeclarative }:
-
-qtSubmodule {
-  name = "qtwebsockets";
-  qtInputs = [ qtbase qtdeclarative ];
-  outputs = [ "bin" "dev" "out" ];
-  postInstall = ''
-    moveToOutput "$qtQmlPrefix" "$bin"
-  '';
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtxmlpatterns.nix b/pkgs/development/libraries/qt-5/5.9/qtxmlpatterns.nix
deleted file mode 100644
index 9a8ddbba2bd2..000000000000
--- a/pkgs/development/libraries/qt-5/5.9/qtxmlpatterns.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ qtSubmodule, qtbase }:
-
-qtSubmodule {
-  name = "qtxmlpatterns";
-  qtInputs = [ qtbase ];
-}
diff --git a/pkgs/development/libraries/qt-5/5.9/srcs.nix b/pkgs/development/libraries/qt-5/5.9/srcs.nix
index f30802472fb8..df7846ca3866 100644
--- a/pkgs/development/libraries/qt-5/5.9/srcs.nix
+++ b/pkgs/development/libraries/qt-5/5.9/srcs.nix
@@ -3,283 +3,275 @@
 
 {
   qt3d = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qt3d-opensource-src-5.9.2.tar.xz";
-      sha256 = "10q7npsl087sja0g2n3v0cg4n75y7sbrs3mfjcsg1wpkw8psjmf9";
-      name = "qt3d-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qt3d-opensource-src-5.9.3.tar.xz";
+      sha256 = "0gr7wvd3p8i2frj9nkfxffxapwqx6i4wh171ymvcsg2qy0r534lp";
+      name = "qt3d-opensource-src-5.9.3.tar.xz";
     };
   };
   qtactiveqt = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtactiveqt-opensource-src-5.9.2.tar.xz";
-      sha256 = "1kz59ns6afnd8s73ys7hqffg9ki9g7px009b2ab72nq7f8cqsib0";
-      name = "qtactiveqt-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtactiveqt-opensource-src-5.9.3.tar.xz";
+      sha256 = "16aka3y7a6mhs0yfm7vbq8v5gbh2ifmk4v2hl04iacindq9f5v2r";
+      name = "qtactiveqt-opensource-src-5.9.3.tar.xz";
     };
   };
   qtandroidextras = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtandroidextras-opensource-src-5.9.2.tar.xz";
-      sha256 = "1hsx16v17iqjhs20xn7an2ad7g8djwrmxachscjhji1dvk4682nl";
-      name = "qtandroidextras-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtandroidextras-opensource-src-5.9.3.tar.xz";
+      sha256 = "0f653qmzvr3rjjgipjbcxvp5wq9fbaz1b4bvj7g868s2d9gpqp9n";
+      name = "qtandroidextras-opensource-src-5.9.3.tar.xz";
     };
   };
   qtbase = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtbase-opensource-src-5.9.2.tar.xz";
-      sha256 = "16v0dny4rcyd5p8qsnsfg89w98k8kqk3rp9x3g3k7xjmi53bpqkz";
-      name = "qtbase-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtbase-opensource-src-5.9.3.tar.xz";
+      sha256 = "10lrkarvs7dpx9rlj7sjcc0pzi42098x8nqnhmydr4bnbq048z4y";
+      name = "qtbase-opensource-src-5.9.3.tar.xz";
     };
   };
   qtcanvas3d = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtcanvas3d-opensource-src-5.9.2.tar.xz";
-      sha256 = "1siyzgm1mjx90rwyzzq9vw2s2xzyf6n7q0vn8gw7mdim5indda44";
-      name = "qtcanvas3d-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtcanvas3d-opensource-src-5.9.3.tar.xz";
+      sha256 = "1g0a606fgal4x17ly0qrj05pb0k8riwh7nj4g3jip05g8iwb2f2y";
+      name = "qtcanvas3d-opensource-src-5.9.3.tar.xz";
     };
   };
   qtcharts = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtcharts-opensource-src-5.9.2.tar.xz";
-      sha256 = "193a3imkgryw42s0gbwaj9gpqd673h3jrg86jvmy33l2fc5gfyjf";
-      name = "qtcharts-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtcharts-opensource-src-5.9.3.tar.xz";
+      sha256 = "1sb99ncmh84bz0xzq55chgic7jk61awnfvi7ld4gq5ap3nl865zc";
+      name = "qtcharts-opensource-src-5.9.3.tar.xz";
     };
   };
   qtconnectivity = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtconnectivity-opensource-src-5.9.2.tar.xz";
-      sha256 = "1k7kjmlny0ykm40qx796wbsg3310v6b8hqizkbr597cmxjbrax9c";
-      name = "qtconnectivity-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtconnectivity-opensource-src-5.9.3.tar.xz";
+      sha256 = "0j86rspn4xgwq1ddc1mpq1kq0ib2c0ag6rsn9ly2xs4iimp1x2g2";
+      name = "qtconnectivity-opensource-src-5.9.3.tar.xz";
     };
   };
   qtdatavis3d = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtdatavis3d-opensource-src-5.9.2.tar.xz";
-      sha256 = "1cmjjbbmdqdix1f8b7qyc2vwhj9pvchc8r4lp65qw11dhycmdbh6";
-      name = "qtdatavis3d-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtdatavis3d-opensource-src-5.9.3.tar.xz";
+      sha256 = "0s636ix44akrjx47gv9qj2ac02q8clnwj3acfr28p6pagm46k7vh";
+      name = "qtdatavis3d-opensource-src-5.9.3.tar.xz";
     };
   };
   qtdeclarative = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtdeclarative-opensource-src-5.9.2.tar.xz";
-      sha256 = "020bha6q8byxc8cj5zw7gms5rgsjg71hv31hv1rr2fy7x56zsh0d";
-      name = "qtdeclarative-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtdeclarative-opensource-src-5.9.3.tar.xz";
+      sha256 = "01wlk17zf47yzx7cc3cp617gj70yadllj2rsfk78879c0v96cpsh";
+      name = "qtdeclarative-opensource-src-5.9.3.tar.xz";
     };
   };
   qtdoc = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtdoc-opensource-src-5.9.2.tar.xz";
-      sha256 = "0dfva8h8f9wpszih285qcxlfcijy52qcbfy1zy20gxh72nfi86c9";
-      name = "qtdoc-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtdoc-opensource-src-5.9.3.tar.xz";
+      sha256 = "0aki592arm3r08y9cq8863jp9zzkvgx7sc48426n30m6q9valsg5";
+      name = "qtdoc-opensource-src-5.9.3.tar.xz";
     };
   };
   qtgamepad = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtgamepad-opensource-src-5.9.2.tar.xz";
-      sha256 = "0lm5v43psf7r8zc79dcjdmmdnz4jm30ylgkvsyv8k88mj06yklbn";
-      name = "qtgamepad-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtgamepad-opensource-src-5.9.3.tar.xz";
+      sha256 = "14vari5cq10a0z02559l2m1v78g7ygnyqf1ilkmy2f0kr36wm7y6";
+      name = "qtgamepad-opensource-src-5.9.3.tar.xz";
     };
   };
   qtgraphicaleffects = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtgraphicaleffects-opensource-src-5.9.2.tar.xz";
-      sha256 = "0xpvigfiqfqvf05ywj8x69y57rp8dwq2hs1kpxlxs15pniz4wn8l";
-      name = "qtgraphicaleffects-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtgraphicaleffects-opensource-src-5.9.3.tar.xz";
+      sha256 = "1nghl39sqsjamjn6pfmxmgga6z9vwzv2zbgc92amrfxxr2dh42vr";
+      name = "qtgraphicaleffects-opensource-src-5.9.3.tar.xz";
     };
   };
   qtimageformats = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtimageformats-opensource-src-5.9.2.tar.xz";
-      sha256 = "1wwxxcl24mk1p4w6knyfai09axmwqsm6cgsbkjsmdz3zmjh6qqis";
-      name = "qtimageformats-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtimageformats-opensource-src-5.9.3.tar.xz";
+      sha256 = "1p95wzm46j49c5br45g0pmlz3n3fl93j1ipzmnpmq9y2pbfhkcyl";
+      name = "qtimageformats-opensource-src-5.9.3.tar.xz";
     };
   };
   qtlocation = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtlocation-opensource-src-5.9.2.tar.xz";
-      sha256 = "033b6l6jbvmc0k5qvbgh5vkzvfga7npqcphrywrrqkmx9vj446n8";
-      name = "qtlocation-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtlocation-opensource-src-5.9.3.tar.xz";
+      sha256 = "1qacqz6l7zljqszblhgzg5y1v4mgki59k45ag7yc2iw7vrf45zc0";
+      name = "qtlocation-opensource-src-5.9.3.tar.xz";
     };
   };
   qtmacextras = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtmacextras-opensource-src-5.9.2.tar.xz";
-      sha256 = "0f14xkardmidvwljccrv6adcs4nyn8rzry9k74mwqn0ikvycs3my";
-      name = "qtmacextras-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtmacextras-opensource-src-5.9.3.tar.xz";
+      sha256 = "0piv3q49vhpjxafdicizcw13am49h0ybfhb37vai0x1wbrlvhdiy";
+      name = "qtmacextras-opensource-src-5.9.3.tar.xz";
     };
   };
   qtmultimedia = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtmultimedia-opensource-src-5.9.2.tar.xz";
-      sha256 = "0815hi3cxy5zy6yc5fkdpx2xd6rk7968j1ziwl2g4wa80802g9n9";
-      name = "qtmultimedia-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtmultimedia-opensource-src-5.9.3.tar.xz";
+      sha256 = "19iqh8xpspzlmpzh05bx5rchlslbfy2pp00xv52496yf9b95i5g7";
+      name = "qtmultimedia-opensource-src-5.9.3.tar.xz";
     };
   };
   qtnetworkauth = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtnetworkauth-opensource-src-5.9.2.tar.xz";
-      sha256 = "16i33m8x5yii22ciq97bpfmnw0lwhvgv84i2az30a1ikm9dg00x0";
-      name = "qtnetworkauth-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtnetworkauth-opensource-src-5.9.3.tar.xz";
+      sha256 = "0fdz5q47xbiij3mi5lzhvxpq4jp9fm929v9kyvcyadz86mp3f8nz";
+      name = "qtnetworkauth-opensource-src-5.9.3.tar.xz";
     };
   };
   qtpurchasing = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtpurchasing-opensource-src-5.9.2.tar.xz";
-      sha256 = "04f28y7qcr4kd0pw26mm515qj7haxr0i8lijn1q47wkikxyhawca";
-      name = "qtpurchasing-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtpurchasing-opensource-src-5.9.3.tar.xz";
+      sha256 = "00yfdd00frgf7fs9s0vyn1c6c4abxgld5rfgkzms3y6n6lcphs0j";
+      name = "qtpurchasing-opensource-src-5.9.3.tar.xz";
     };
   };
   qtquickcontrols = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtquickcontrols-opensource-src-5.9.2.tar.xz";
-      sha256 = "07xxhkfsljwdwlp9jfp88pwkrig02y2pnwhdsaz8mkcackwfq2az";
-      name = "qtquickcontrols-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtquickcontrols-opensource-src-5.9.3.tar.xz";
+      sha256 = "09p2q3max4xrlw5svbhn11y9cgrvcjsj88xw4c0kq91cgnyyw3ih";
+      name = "qtquickcontrols-opensource-src-5.9.3.tar.xz";
     };
   };
   qtquickcontrols2 = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtquickcontrols2-opensource-src-5.9.2.tar.xz";
-      sha256 = "1ln83afxyp5dmvdnq6n7as82xrd5k3xvfx7b1jxnljivslyxsm9b";
-      name = "qtquickcontrols2-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtquickcontrols2-opensource-src-5.9.3.tar.xz";
+      sha256 = "0hq888qq8q7dglpyzif64pplqjxfrqjpkvbcx0ycq35darls5ai1";
+      name = "qtquickcontrols2-opensource-src-5.9.3.tar.xz";
     };
   };
   qtremoteobjects = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtremoteobjects-opensource-src-5.9.2.tar.xz";
-      sha256 = "1ylphdwis34y4pm9xiwh2xqfd0hh2gp8kkawlps2q5mh2bm11376";
-      name = "qtremoteobjects-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtremoteobjects-opensource-src-5.9.3.tar.xz";
+      sha256 = "0z6qd381r6a7gdrsknlkkbhq9mmdqi040kfrvgm6mfa69336f4dk";
+      name = "qtremoteobjects-opensource-src-5.9.3.tar.xz";
     };
   };
   qtscript = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtscript-opensource-src-5.9.2.tar.xz";
-      sha256 = "1wa0rnbphkhgydnwkf5bjwn0llskl6hgs0964nh0jik8qaspv027";
-      name = "qtscript-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtscript-opensource-src-5.9.3.tar.xz";
+      sha256 = "0rjm6nph1nssfpknp4i682bvk7363y4a2f74060vcm7ib2pzl2xq";
+      name = "qtscript-opensource-src-5.9.3.tar.xz";
     };
   };
   qtscxml = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtscxml-opensource-src-5.9.2.tar.xz";
-      sha256 = "0pdimqwdrj8hckm81lwy1z58ji4bdv0bzgv336m0a8v3pj914awx";
-      name = "qtscxml-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtscxml-opensource-src-5.9.3.tar.xz";
+      sha256 = "06x8hs3p7bfgnl6b2fjld4s41acw1rbnxbcgkprgw2fxxnl1zxfq";
+      name = "qtscxml-opensource-src-5.9.3.tar.xz";
     };
   };
   qtsensors = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtsensors-opensource-src-5.9.2.tar.xz";
-      sha256 = "1lxmhi19dbb8vjhpjph0l0ss6zh72hb4908lp4s1pgf8r641ai3r";
-      name = "qtsensors-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtsensors-opensource-src-5.9.3.tar.xz";
+      sha256 = "1hfsih5iy4fi6mnpw2shf1lzx9hxcdc1arspad1mark17l5s4pmr";
+      name = "qtsensors-opensource-src-5.9.3.tar.xz";
     };
   };
   qtserialbus = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtserialbus-opensource-src-5.9.2.tar.xz";
-      sha256 = "025yv7zajz5scrmkjkmgkyvxpgkliqvrzc88is0gr481zpd4phmv";
-      name = "qtserialbus-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtserialbus-opensource-src-5.9.3.tar.xz";
+      sha256 = "0f39qh05mp54frpn5sy9k5vfw5zb2gg72qaqz81mwlck2xg78qpg";
+      name = "qtserialbus-opensource-src-5.9.3.tar.xz";
     };
   };
   qtserialport = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtserialport-opensource-src-5.9.2.tar.xz";
-      sha256 = "0hndc9z7qzxazzjvc6k5yd58afw13444plk70b05nqdi5p19rvah";
-      name = "qtserialport-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtserialport-opensource-src-5.9.3.tar.xz";
+      sha256 = "1pxb679cx77vk39ik7j0k91a57wqa63d4g4riw3r2gpcay8kxpac";
+      name = "qtserialport-opensource-src-5.9.3.tar.xz";
     };
   };
   qtspeech = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtspeech-opensource-src-5.9.2.tar.xz";
-      sha256 = "0cq33dffi7q7dnvzhdivky5prakb8xnwap0b76fwgirhbbn88ypg";
-      name = "qtspeech-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtspeech-opensource-src-5.9.3.tar.xz";
+      sha256 = "1c4rpf3by620fx8lrvmc38r60cikqczqh2rfcm7ixz3x8cj60lh1";
+      name = "qtspeech-opensource-src-5.9.3.tar.xz";
     };
   };
   qtsvg = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtsvg-opensource-src-5.9.2.tar.xz";
-      sha256 = "020icrl9vi8jh8ygsssqrx2bl8bx28m15dwmf9a969qdnvxyp5ms";
-      name = "qtsvg-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtsvg-opensource-src-5.9.3.tar.xz";
+      sha256 = "1wjx9ymk2h19l9kk76jh87bnhhj955f9a93akvwwzfwg1jk2hrnz";
+      name = "qtsvg-opensource-src-5.9.3.tar.xz";
     };
   };
   qttools = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qttools-opensource-src-5.9.2.tar.xz";
-      sha256 = "06nqsa5mj0mc9w9xbm7mgdkb66x4wlvkhnas32f97sb8ic8rdf9b";
-      name = "qttools-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qttools-opensource-src-5.9.3.tar.xz";
+      sha256 = "1zw4j8ymwcpn7dx1dlbxpmx5lfp26rag7pysap1xry9m7vg3hb24";
+      name = "qttools-opensource-src-5.9.3.tar.xz";
     };
   };
   qttranslations = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qttranslations-opensource-src-5.9.2.tar.xz";
-      sha256 = "0byi4s07lfnzzlr2c4sc5qg3hrysswmakwmf80q2mx50kpgnvwax";
-      name = "qttranslations-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qttranslations-opensource-src-5.9.3.tar.xz";
+      sha256 = "1ncvj1qlcgrm0zqdlq2bkb0hc8dyisz8m7bszxyx4kyxg7n5gb20";
+      name = "qttranslations-opensource-src-5.9.3.tar.xz";
     };
   };
   qtvirtualkeyboard = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtvirtualkeyboard-opensource-src-5.9.2.tar.xz";
-      sha256 = "1z66chp5746cb0rwy2isnpbvwjj44qvp2hg56n3g47dj901wldp8";
-      name = "qtvirtualkeyboard-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtvirtualkeyboard-opensource-src-5.9.3.tar.xz";
+      sha256 = "1zrj4pjy98dskzycjswbkm4m2j6k1j4150h0w7vdrw1681s3ycdr";
+      name = "qtvirtualkeyboard-opensource-src-5.9.3.tar.xz";
     };
   };
   qtwayland = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtwayland-opensource-src-5.9.2.tar.xz";
-      sha256 = "1ipn4xh0dj1kjg5i4vfl4gpx3hg2377w5gls47xpv1ikz41lshzn";
-      name = "qtwayland-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtwayland-opensource-src-5.9.3.tar.xz";
+      sha256 = "0vazcmpqdka3llmyg7m99lw0ngrydmw74p9nd04544xdn128r3ih";
+      name = "qtwayland-opensource-src-5.9.3.tar.xz";
     };
   };
   qtwebchannel = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtwebchannel-opensource-src-5.9.2.tar.xz";
-      sha256 = "09iss70c1iqgf8qpik35qlgrdw5y9935v0fm2ppgkmxdxkpls6ww";
-      name = "qtwebchannel-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtwebchannel-opensource-src-5.9.3.tar.xz";
+      sha256 = "0n438mk01sh2bbqakc1m3s65qqmi75m4n4hymad8wcgijfr9a9v3";
+      name = "qtwebchannel-opensource-src-5.9.3.tar.xz";
     };
   };
   qtwebengine = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtwebengine-opensource-src-5.9.2.tar.xz";
-      sha256 = "0251qk04yif4lsn8qvkc2kmzzmaw1v3pfh5ypr06d04zb3j6kc6a";
-      name = "qtwebengine-opensource-src-5.9.2.tar.xz";
-    };
-  };
-  qtwebsockets = {
-    version = "5.9.2";
-    src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtwebsockets-opensource-src-5.9.2.tar.xz";
-      sha256 = "0x0nx1ampqsgj9qlc3l32z3ham1a5vq7m2lnxk5pr92yj6yw3pdg";
-      name = "qtwebsockets-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtwebengine-opensource-src-5.9.3.tar.xz";
+      sha256 = "0dqxawc9vfffz6ygdn5mdpl79rrqfx18jy2d1w81q9w7zm113bj5";
+      name = "qtwebengine-opensource-src-5.9.3.tar.xz";
     };
   };
   qtwebkit = {
@@ -298,36 +290,44 @@
       name = "qtwebkit-examples-opensource-src-5.9.1.tar.xz";
     };
   };
+  qtwebsockets = {
+    version = "5.9.3";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtwebsockets-opensource-src-5.9.3.tar.xz";
+      sha256 = "1phic630ah85ajxp6iqrw9bpg0y8s88y45ygkc1wcasmbgzrs1nf";
+      name = "qtwebsockets-opensource-src-5.9.3.tar.xz";
+    };
+  };
   qtwebview = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtwebview-opensource-src-5.9.2.tar.xz";
-      sha256 = "1cdqw6pjfqagnwxrha0s18zadjnm65dsildxj07h2qiwqxwyrjpw";
-      name = "qtwebview-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtwebview-opensource-src-5.9.3.tar.xz";
+      sha256 = "1i99fy86gydpfsfc4my5d9vxjywfrzbqxk66cb3yf2ac57j66mpf";
+      name = "qtwebview-opensource-src-5.9.3.tar.xz";
     };
   };
   qtwinextras = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtwinextras-opensource-src-5.9.2.tar.xz";
-      sha256 = "07qq9rxl6hhl300w7qxsjjbdd5fwpszfk3rbinxklg20f6c6ixml";
-      name = "qtwinextras-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtwinextras-opensource-src-5.9.3.tar.xz";
+      sha256 = "1lj4qa51ymhpvk0bdp6xf6b3n1k39kihns5lvp6xq1w2mljn6phl";
+      name = "qtwinextras-opensource-src-5.9.3.tar.xz";
     };
   };
   qtx11extras = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtx11extras-opensource-src-5.9.2.tar.xz";
-      sha256 = "1ias745j5lfnrfkgyk0pr8n8zlkqs08gq7yyzaj1c645sh54b1fv";
-      name = "qtx11extras-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtx11extras-opensource-src-5.9.3.tar.xz";
+      sha256 = "1gpjgca4xvyy0r743kh2ys128r14fh6j8bdphnmmi5v2pf6bzq74";
+      name = "qtx11extras-opensource-src-5.9.3.tar.xz";
     };
   };
   qtxmlpatterns = {
-    version = "5.9.2";
+    version = "5.9.3";
     src = fetchurl {
-      url = "${mirror}/archive/qt/5.9/5.9.2/submodules/qtxmlpatterns-opensource-src-5.9.2.tar.xz";
-      sha256 = "0knk4bplqhvsxar1wv16bzfw57q0aja12gdaxz7m8mvx121sm9ha";
-      name = "qtxmlpatterns-opensource-src-5.9.2.tar.xz";
+      url = "${mirror}/official_releases/qt/5.9/5.9.3/submodules/qtxmlpatterns-opensource-src-5.9.3.tar.xz";
+      sha256 = "1fphhqr3v3vzjp2vbv16bc1vs879wn7aqlabgcpkhqx92ak6d76g";
+      name = "qtxmlpatterns-opensource-src-5.9.3.tar.xz";
     };
   };
 }
diff --git a/pkgs/development/libraries/qt-5/README.md b/pkgs/development/libraries/qt-5/README.md
new file mode 100644
index 000000000000..c13b172e82ab
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/README.md
@@ -0,0 +1,81 @@
+# Qt 5 Maintainer's Notes
+
+## Minor Updates
+
+Let `$major` be the major version number, e.g. `5.9`.
+
+1. Change the version number in the `$major/fetch.sh`.
+2. Run `./maintainers/scripts/fetch-kde-qt.sh pkgs/development/qt-5/$major`
+   from the top of the Nixpkgs tree.
+
+See below if it is necessary to update any patches.
+
+## Major Updates
+
+Let `$major` be the new major version number, e.g. `5.10`.
+
+1. Copy the subdirectory from the previous major version to `$major`.
+2. Change the version number in `$major/fetch.sh`.
+3. Run `./maintainers/scripts/fetch-kde-qt.sh pkgs/development/qt-5/$major`
+   from the top of the Nixpkgs tree.
+4. Add a top-level attribute in `pkgs/top-level/all-packages.nix` for the new
+   major version.
+5. Change the `qt5` top-level attribute to point to the new major version.
+6. If the previous major version is _not_ a long-term support release,
+   remove it from Nixpkgs.
+
+See below if it is necessary to update any patches.
+
+## Patches
+
+Nixpkgs maintains several patches for Qt which cannot be submitted upstream. To
+facilitate maintenance, a fork of the upstream repository is created for each patched module:
+
+- [qtbase](https://github.com/ttuegel/qtbase)
+- [qtwebkit](https://github.com/ttuegel/qtwebkit)
+- [qttools](https://github.com/ttuegel/qttools)
+- [qtscript](https://github.com/ttuegel/qtscript)
+- [qtserialport](https://github.com/ttuegel/qtserialport)
+- [qtdeclarative](https://github.com/ttuegel/qtdeclarative)
+- [qtwebengine](https://github.com/ttuegel/qtwebengine)
+
+In each repository, the patches are contained in a branch named `nixpkgs/$major`
+for each major version. Please make a pull request to add or update any patch
+which will be maintained in Nixpkgs.
+
+The forked repository for each module is used to create a single patch in
+Nixpkgs. To recreate the patch for module `$module` (e.g. `qtbase`) at version
+`$version` (e.g. `5.9.1`) in the branch `$major` (e.g. `5.9`),
+
+1. Clone the fork for `$module` from the list above.
+2. Checkout the active branch, `git checkout nixpkgs/$major`.
+3. Compare the patched branch to the release tag,
+   `git diff v$version > $module.patch`.
+4. Copy `$module.patch` into the Nixpkgs tree.
+
+### Minor Version Updates
+
+To update module `$module` to version `$version` from an older version in the
+same branch `$major`,
+
+1. Clone the fork for `$module` from the list above.
+2. Checkout the active branch, `git checkout nixpkgs/$major`.
+3. Merge the new version into the active branch,
+   `git merge --no-ff v$version`.
+4. Fix any conflicts.
+5. Open a pull request for the changes.
+6. Follow the instructions above to recreate the module patch in Nixpkgs.
+
+### Major Version Updates
+
+To update module `$module` from `$oldversion` in branch `$oldmajor` to version
+`$version` in branch `$major`,
+
+1. Clone the fork for `$module` from the list above.
+2. Checkout a new branch for the new major version,
+   `git checkout -b nixpkgs/$major nixpkgs/$oldmajor`.
+3. Rebase the patches from `$oldversion` onto the new branch,
+   `git rebase v$oldversion --onto v$version`.
+4. Fix any conflicts.
+5. Open a pull request for the changes.
+6. Follow the instructions above to recreate the module patch in Nixpkgs.
diff --git a/pkgs/development/libraries/qt-5/hooks/fix-qt-builtin-paths.sh b/pkgs/development/libraries/qt-5/hooks/fix-qt-builtin-paths.sh
new file mode 100644
index 000000000000..4ca11a223de2
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/hooks/fix-qt-builtin-paths.sh
@@ -0,0 +1,64 @@
+# fixQtBuiltinPaths
+#
+# Usage: fixQtBuiltinPaths _dir_ _pattern_
+#
+# Fix Qt builtin paths in files matching _pattern_ under _dir_.
+#
+fixQtBuiltinPaths() {
+    local dir="$1"
+    local pattern="$2"
+    local bin="${!outputBin}"
+    local dev="${!outputDev}"
+    local doc="${!outputDoc}"
+    local lib="${!outputLib}"
+
+    if [ -d "$dir" ]; then
+        find "$dir" -name "$pattern" | while read pr_; do
+            if grep -q '\$\$\[QT_' "${pr_:?}"; then
+                echo "fixQtBuiltinPaths: Fixing Qt builtin paths in \`${pr_:?}'..."
+                sed -i "${pr_:?}" \
+                    -e "s|\\\$\\\$\\[QT_HOST_BINS[^]]*\\]|$dev/bin|g" \
+                    -e "s|\\\$\\\$\\[QT_HOST_DATA[^]]*\\]/mkspecs|$dev/mkspecs|g" \
+                    -e "s|\\\$\\\$\\[QT_HOST_PREFIX[^]]*\\]|$dev|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_ARCHDATA[^]]*\\]|$lib|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_BINS[^]]*\\]|$bin/bin|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_CONFIGURATION[^]]*\\]|$bin|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_DATA[^]]*\\]|$lib|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_DOCS[^]]*\\]|$doc/share/doc|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_EXAMPLES[^]]*\\]|$doc/examples|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_HEADERS[^]]*\\]|$dev/include|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_LIBS[^]]*\\]|$lib/lib|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_LIBEXECS[^]]*\\]|$lib/libexec|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_PLUGINS[^]]*\\]|$bin/$qtPluginPrefix|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_PREFIX[^]]*\\]|$lib|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_TESTS[^]]*\\]|$dev/tests|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_TRANSLATIONS[^]]*\\]|$lib/translations|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_QML[^]]*\\]|$bin/$qtQmlPrefix|g"
+            fi
+        done
+    elif [ -e "$dir" ]; then
+        if grep -q '\$\$\[QT_' "${dir:?}"; then
+            echo "fixQtBuiltinPaths: Fixing Qt builtin paths in \`${dir:?}'..."
+            sed -i "${dir:?}" \
+                -e "s|\\\$\\\$\\[QT_HOST_BINS[^]]*\\]|$dev/bin|g" \
+                -e "s|\\\$\\\$\\[QT_HOST_DATA[^]]*\\]/mkspecs|$dev/mkspecs|g" \
+                -e "s|\\\$\\\$\\[QT_HOST_PREFIX[^]]*\\]|$dev|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_ARCHDATA[^]]*\\]|$lib|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_BINS[^]]*\\]|$bin/bin|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_CONFIGURATION[^]]*\\]|$bin|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_DATA[^]]*\\]|$lib|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_DOCS[^]]*\\]|$doc/share/doc|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_EXAMPLES[^]]*\\]|$doc/examples|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_HEADERS[^]]*\\]|$dev/include|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_LIBS[^]]*\\]|$lib/lib|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_LIBEXECS[^]]*\\]|$lib/libexec|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_PLUGINS[^]]*\\]|$bin/$qtPluginPrefix|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_PREFIX[^]]*\\]|$lib|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_TESTS[^]]*\\]|$dev/tests|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_TRANSLATIONS[^]]*\\]|$lib/translations|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_QML[^]]*\\]|$bin/$qtQmlPrefix|g"
+        fi
+    else
+        echo "fixQtBuiltinPaths: Warning: \`$dir' does not exist"
+    fi
+}
diff --git a/pkgs/development/libraries/qt-5/hooks/fix-qt-module-paths.sh b/pkgs/development/libraries/qt-5/hooks/fix-qt-module-paths.sh
new file mode 100644
index 000000000000..33682f6f3c69
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/hooks/fix-qt-module-paths.sh
@@ -0,0 +1,36 @@
+# fixQtModulePaths
+#
+# Usage: fixQtModulePaths _dir_
+#
+# Find Qt module definitions in directory _dir_ and patch the module paths.
+#
+fixQtModulePaths () {
+    local dir="$1"
+    local bin="${!outputBin}"
+    local dev="${!outputDev}"
+    local lib="${!outputLib}"
+
+    if [ -d "$dir" ]; then
+        find "$dir" -name 'qt_*.pri' | while read pr; do
+            if grep -q '\$\$QT_MODULE_' "${pr:?}"; then
+                echo "fixQtModulePaths: Fixing module paths in \`${pr:?}'..."
+                sed -i "${pr:?}" \
+                    -e "s|\\\$\\\$QT_MODULE_LIB_BASE|$lib/lib|g" \
+                    -e "s|\\\$\\\$QT_MODULE_HOST_LIB_BASE|$lib/lib|g" \
+                    -e "s|\\\$\\\$QT_MODULE_INCLUDE_BASE|$dev/include|g" \
+                    -e "s|\\\$\\\$QT_MODULE_BIN_BASE|$dev/bin|g"
+            fi
+        done
+    elif [ -e "$dir" ]; then
+        echo "fixQtModulePaths: Warning: \`$dir' is not a directory"
+    else
+        echo "fixQtModulePaths: Warning: \`$dir' does not exist"
+    fi
+
+    if [ "z$bin" != "z$dev" ]; then
+        if [ -d "$bin/bin" ]; then
+            mkdir -p "$dev/bin"
+            lndir -silent "$bin/bin" "$dev/bin"
+        fi
+    fi
+}
diff --git a/pkgs/development/libraries/qt-5/hooks/move-qt-dev-tools.sh b/pkgs/development/libraries/qt-5/hooks/move-qt-dev-tools.sh
new file mode 100644
index 000000000000..85489c85105b
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/hooks/move-qt-dev-tools.sh
@@ -0,0 +1,34 @@
+updateToolPath() {
+    local tool="$1"
+    local target="$2"
+    local original="${!outputBin}/$tool"
+    local actual="${!outputDev}/$tool"
+    if grep -q "$original" "$target"; then
+        echo "updateToolPath: Updating \`$original' in \`$target\'..."
+        sed -i "$target" -e "s|$original|$actual|"
+    fi
+}
+
+moveQtDevTools() {
+    if [ -n "$devTools" ]; then
+        for tool in $devTools; do
+            moveToOutput "$tool" "${!outputDev}"
+        done
+
+        if [ -d "${!outputDev}/mkspecs" ]; then
+            find "${!outputDev}/mkspecs" -name '*.pr?' | while read pr_; do
+                for tool in $devTools; do
+                    updateToolPath "$tool" "$pr_"
+                done
+            done
+        fi
+
+        if [ -d "${!outputDev}/lib/cmake" ]; then
+            find "${!outputDev}/lib/cmake" -name '*.cmake' | while read cmake; do
+                for tool in $devTools; do
+                    updateToolPath "$tool" "$cmake"
+                done
+            done
+        fi
+    fi
+}
diff --git a/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh b/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh
new file mode 100644
index 000000000000..eef2c7d24dfc
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh
@@ -0,0 +1,23 @@
+qmakeConfigurePhase() {
+    runHook preConfigure
+
+    qmake PREFIX=$out \
+          NIX_OUTPUT_OUT=$out \
+          NIX_OUTPUT_DEV=${!outputDev} \
+          NIX_OUTPUT_BIN=${!outputBin} \
+          NIX_OUTPUT_DOC=${!outputDev}/${qtDocPrefix:?} \
+          NIX_OUTPUT_QML=${!outputBin}/${qtQmlPrefix:?} \
+          NIX_OUTPUT_PLUGIN=${!outputBin}/${qtPluginPrefix:?} \
+          $qmakeFlags
+
+    if ! [[ -v enableParallelBuilding ]]; then
+        enableParallelBuilding=1
+        echo "qmake: enabled parallel building"
+    fi
+
+    runHook postConfigure
+}
+
+if [ -z "$dontUseQmakeConfigure" -a -z "$configurePhase" ]; then
+    configurePhase=qmakeConfigurePhase
+fi
diff --git a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh
new file mode 100644
index 000000000000..3a558153988c
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh
@@ -0,0 +1,64 @@
+qtPluginPrefix=@qtPluginPrefix@
+qtQmlPrefix=@qtQmlPrefix@
+qtDocPrefix=@qtDocPrefix@
+
+. @fix_qt_builtin_paths@
+. @fix_qt_module_paths@
+
+providesQtRuntime() {
+    [ -d "$1/$qtPluginPrefix" ] || [ -d "$1/$qtQmlPrefix" ]
+}
+
+# Build tools are often confused if QMAKE is unset.
+QMAKE=@dev@/bin/qmake
+export QMAKE
+
+QMAKEPATH=
+export QMAKEPATH
+
+QMAKEMODULES=
+export QMAKEMODULES
+
+addToQMAKEPATH() {
+    if [ -d "$1/mkspecs" ]; then
+        QMAKEMODULES="${QMAKEMODULES}${QMAKEMODULES:+:}/mkspecs"
+        QMAKEPATH="${QMAKEPATH}${QMAKEPATH:+:}$1"
+    fi
+}
+
+# Propagate any runtime dependency of the building package.
+# Each dependency is propagated to the user environment and as a build
+# input so that it will be re-propagated to the user environment by any
+# package depending on the building package. (This is necessary in case
+# the building package does not provide runtime dependencies itself and so
+# would not be propagated to the user environment.)
+qtEnvHook() {
+    addToQMAKEPATH "$1"
+    if providesQtRuntime "$1"; then
+        if [ "z${!outputBin}" != "z${!outputDev}" ]; then
+            propagatedBuildInputs+=" $1"
+        fi
+        propagatedUserEnvPkgs+=" $1"
+    fi
+}
+envHostTargetHooks+=(qtEnvHook)
+
+postPatchMkspecs() {
+    local bin="${!outputBin}"
+    local dev="${!outputDev}"
+    local doc="${!outputDoc}"
+    local lib="${!outputLib}"
+
+    moveToOutput "mkspecs" "$dev"
+
+    if [ -d "$dev/mkspecs/modules" ]; then
+        fixQtModulePaths "$dev/mkspecs/modules"
+    fi
+
+    if [ -d "$dev/mkspecs" ]; then
+        fixQtBuiltinPaths "$dev/mkspecs" '*.pr?'
+    fi
+}
+if [ -z "$dontPatchMkspecs" ]; then
+    postPhases="${postPhases}${postPhases:+ }postPatchMkspecs"
+fi
diff --git a/pkgs/development/libraries/qt-5/hooks/qttools-setup-hook.sh b/pkgs/development/libraries/qt-5/hooks/qttools-setup-hook.sh
new file mode 100644
index 000000000000..b09cf5f46c9c
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/hooks/qttools-setup-hook.sh
@@ -0,0 +1 @@
+qmakeFlags="$qmakeFlags${qmakeFlags:+ }QMAKE_LRELEASE=@dev@/bin/lrelease"
diff --git a/pkgs/development/libraries/qt-5/mkDerivation.nix b/pkgs/development/libraries/qt-5/mkDerivation.nix
new file mode 100644
index 000000000000..739c9b4a1608
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/mkDerivation.nix
@@ -0,0 +1,32 @@
+{ stdenv, lib }:
+
+let inherit (lib) optional; in
+
+{ debug }:
+
+args:
+
+let
+  args_ = {
+
+    qmakeFlags =
+      (args.qmakeFlags or [])
+      ++ [ ("CONFIG+=" + (if debug then "debug" else "release")) ];
+
+    NIX_CFLAGS_COMPILE =
+      optional (!debug) "-DQT_NO_DEBUG"
+      ++ lib.toList (args.NIX_CFLAGS_COMPILE or []);
+
+    cmakeFlags =
+      (args.cmakeFlags or [])
+      ++ [
+        "-DBUILD_TESTING=OFF"
+        ("-DCMAKE_BUILD_TYPE=" + (if debug then "Debug" else "Release"))
+      ];
+
+    enableParallelBuilding = args.enableParallelBuilding or true;
+
+  };
+in
+
+stdenv.mkDerivation (args // args_)
diff --git a/pkgs/development/libraries/qt-5/modules/qtbase.nix b/pkgs/development/libraries/qt-5/modules/qtbase.nix
new file mode 100644
index 000000000000..8887e05704d2
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/modules/qtbase.nix
@@ -0,0 +1,405 @@
+{
+  stdenv, lib,
+  src, patches, version, qtCompatVersion,
+
+  coreutils, bison, flex, gdb, gperf, lndir, patchelf, perl, pkgconfig, python2,
+  ruby, which,
+  # darwin support
+  darwin, libiconv, libcxx,
+
+  dbus, fontconfig, freetype, glib, harfbuzz, icu, libX11, libXcomposite,
+  libXcursor, libXext, libXi, libXrender, libinput, libjpeg, libpng, libtiff,
+  libxcb, libxkbcommon, libxml2, libxslt, openssl, pcre16, pcre2, sqlite, udev,
+  xcbutil, xcbutilimage, xcbutilkeysyms, xcbutilrenderutil, xcbutilwm, xorg,
+  zlib,
+
+  # optional dependencies
+  cups ? null, mysql ? null, postgresql ? null,
+  withGtk3 ? false, dconf ? null, gtk3 ? null,
+
+  # options
+  libGLSupported ? (!stdenv.isDarwin),
+  libGL,
+  buildExamples ? false,
+  buildTests ? false,
+  developerBuild ? false,
+  decryptSslTraffic ? false
+}:
+
+assert withGtk3 -> dconf != null;
+assert withGtk3 -> gtk3 != null;
+
+let
+  compareVersion = v: builtins.compareVersions version v;
+in
+
+stdenv.mkDerivation {
+
+  name = "qtbase-${version}";
+  inherit qtCompatVersion src version;
+
+  propagatedBuildInputs =
+    [
+      libxml2 libxslt openssl sqlite zlib
+
+      # Text rendering
+      harfbuzz icu
+
+      # Image formats
+      libjpeg libpng libtiff
+      (if compareVersion "5.9.0" >= 0 then pcre2 else pcre16)
+    ]
+    ++ (
+      if stdenv.isDarwin
+      then with darwin.apple_sdk.frameworks;
+        [
+          AGL AppKit ApplicationServices Carbon Cocoa CoreAudio CoreBluetooth
+          CoreLocation CoreServices DiskArbitration Foundation OpenGL
+          darwin.libobjc libiconv
+        ]
+      else
+        [
+          dbus glib udev
+
+          # Text rendering
+          fontconfig freetype
+
+          # X11 libs
+          libX11 libXcomposite libXext libXi libXrender libxcb libxkbcommon xcbutil
+          xcbutilimage xcbutilkeysyms xcbutilrenderutil xcbutilwm
+        ]
+        ++ lib.optional libGLSupported libGL
+    );
+
+  buildInputs =
+    lib.optionals (!stdenv.isDarwin)
+    (
+      [ libinput ]
+      ++ lib.optional withGtk3 gtk3
+    )
+    ++ lib.optional developerBuild gdb
+    ++ lib.optional (cups != null) cups
+    ++ lib.optional (mysql != null) mysql.connector-c
+    ++ lib.optional (postgresql != null) postgresql;
+
+  nativeBuildInputs =
+    [ bison flex gperf lndir perl pkgconfig python2 which ]
+    ++ lib.optional (!stdenv.isDarwin) patchelf;
+
+  propagatedNativeBuildInputs = [ lndir ];
+
+  outputs = [ "bin" "dev" "out" ];
+
+  inherit patches;
+
+  fix_qt_builtin_paths = ../hooks/fix-qt-builtin-paths.sh;
+  fix_qt_module_paths = ../hooks/fix-qt-module-paths.sh;
+  preHook = ''
+    . "$fix_qt_builtin_paths"
+    . "$fix_qt_module_paths"
+    . ${../hooks/move-qt-dev-tools.sh}
+  '';
+
+  postPatch =
+    ''
+      for prf in qml_plugin.prf qt_plugin.prf qt_docs.prf qml_module.prf create_cmake.prf; do
+          substituteInPlace "mkspecs/features/$prf" \
+              --subst-var qtPluginPrefix \
+              --subst-var qtQmlPrefix \
+              --subst-var qtDocPrefix
+      done
+
+      substituteInPlace configure --replace /bin/pwd pwd
+      substituteInPlace src/corelib/global/global.pri --replace /bin/ls ${coreutils}/bin/ls
+      sed -e 's@/\(usr\|opt\)/@/var/empty/@g' -i mkspecs/*/*.conf
+
+      sed -i '/PATHS.*NO_DEFAULT_PATH/ d' src/corelib/Qt5Config.cmake.in
+      sed -i '/PATHS.*NO_DEFAULT_PATH/ d' src/corelib/Qt5CoreMacros.cmake
+      sed -i 's/NO_DEFAULT_PATH//' src/gui/Qt5GuiConfigExtras.cmake.in
+      sed -i '/PATHS.*NO_DEFAULT_PATH/ d' mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+    ''
+
+    + (
+      if stdenv.isDarwin
+      then
+        ''
+          sed -i \
+              -e 's|! /usr/bin/xcode-select --print-path >/dev/null 2>&1;|false;|' \
+              -e 's|! /usr/bin/xcrun -find xcodebuild >/dev/null 2>&1;|false;|' \
+              -e 's|sysroot=$(/usr/bin/xcodebuild -sdk $sdk -version Path 2>/dev/null)|sysroot=/nonsense|' \
+              -e 's|sysroot=$(/usr/bin/xcrun --sdk $sdk --show-sdk-path 2>/dev/null)|sysroot=/nonsense|' \
+              -e 's|QMAKE_CONF_COMPILER=`getXQMakeConf QMAKE_CXX`|QMAKE_CXX="clang++"\nQMAKE_CONF_COMPILER="clang++"|' \
+              -e 's|XCRUN=`/usr/bin/xcrun -sdk macosx clang -v 2>&1`|XCRUN="clang -v 2>&1"|' \
+              -e 's#sdk_val=$(/usr/bin/xcrun -sdk $sdk -find $(echo $val | cut -d \x27 \x27 -f 1))##' \
+              -e 's#val=$(echo $sdk_val $(echo $val | cut -s -d \x27 \x27 -f 2-))##' \
+              ./configure
+              substituteInPlace ./mkspecs/common/mac.conf \
+                  --replace "/System/Library/Frameworks/OpenGL.framework/" "${darwin.apple_sdk.frameworks.OpenGL}/Library/Frameworks/OpenGL.framework/"
+              substituteInPlace ./mkspecs/common/mac.conf \
+                  --replace "/System/Library/Frameworks/AGL.framework/" "${darwin.apple_sdk.frameworks.AGL}/Library/Frameworks/AGL.framework/"
+        ''
+        # Note on the above: \x27 is a way if including a single-quote
+        # character in the sed string arguments.
+      else
+        lib.optionalString libGLSupported
+          ''
+            sed -i mkspecs/common/linux.conf \
+                -e "/^QMAKE_INCDIR_OPENGL/ s|$|${libGL.dev or libGL}/include|" \
+                -e "/^QMAKE_LIBDIR_OPENGL/ s|$|${libGL.out}/lib|"
+          ''
+    );
+
+  qtPluginPrefix = "lib/qt-${qtCompatVersion}/plugins";
+  qtQmlPrefix = "lib/qt-${qtCompatVersion}/qml";
+  qtDocPrefix = "share/doc/qt-${qtCompatVersion}";
+
+  setOutputFlags = false;
+  preConfigure = ''
+    export LD_LIBRARY_PATH="$PWD/lib:$PWD/plugins/platforms:$LD_LIBRARY_PATH"
+    ${lib.optionalString (compareVersion "5.9.0" < 0) ''
+    # We need to set LD to CXX or otherwise we get nasty compile errors
+    export LD=$CXX
+    ''}
+
+    configureFlags+="\
+        -plugindir $out/$qtPluginPrefix \
+        -qmldir $out/$qtQmlPrefix \
+        -docdir $out/$qtDocPrefix"
+
+    createQmakeCache() {
+        cat >>"$1" <<EOF
+    NIX_OUTPUT_BIN = $bin
+    NIX_OUTPUT_DEV = $dev
+    NIX_OUTPUT_OUT = $out
+    NIX_OUTPUT_DOC = $dev/$qtDocPrefix
+    NIX_OUTPUT_QML = $bin/$qtQmlPrefix
+    NIX_OUTPUT_PLUGIN = $bin/$qtPluginPrefix
+    EOF
+    }
+
+    find . -name '.qmake.conf' | while read conf; do
+        cache=$(dirname $conf)/.qmake.cache
+        echo "Creating \`$cache'"
+        createQmakeCache "$cache"
+    done
+
+    NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QT_PLUGIN_PREFIX=\"$qtPluginPrefix\""
+  '';
+
+
+  NIX_CFLAGS_COMPILE =
+    [
+      "-Wno-error=sign-compare" # freetype-2.5.4 changed signedness of some struct fields
+      ''-DNIXPKGS_QTCOMPOSE="${libX11.out}/share/X11/locale"''
+      ''-DNIXPKGS_LIBRESOLV="${stdenv.cc.libc.out}/lib/libresolv"''
+      ''-DNIXPKGS_LIBXCURSOR="${libXcursor.out}/lib/libXcursor"''
+    ]
+
+    ++ (
+      if stdenv.isDarwin
+      then
+        [
+          "-Wno-missing-sysroot"
+          "-D__MAC_OS_X_VERSION_MAX_ALLOWED=1090"
+          "-D__AVAILABILITY_INTERNAL__MAC_10_10=__attribute__((availability(macosx,introduced=10.10)))"
+          # Note that nixpkgs's objc4 is from macOS 10.11 while the SDK is
+          # 10.9 which necessitates the above macro definition that mentions
+          # 10.10
+        ]
+      else
+        lib.optional libGLSupported ''-DNIXPKGS_MESA_GL="${libGL.out}/lib/libGL"''
+        ++ lib.optionals withGtk3
+          [
+            ''-DNIXPKGS_QGTK3_XDG_DATA_DIRS="${gtk3}/share/gsettings-schemas/${gtk3.name}"''
+            ''-DNIXPKGS_QGTK3_GIO_EXTRA_MODULES="${dconf.lib}/lib/gio/modules"''
+          ]
+    )
+
+    ++ lib.optional decryptSslTraffic "-DQT_DECRYPT_SSL_TRAFFIC";
+
+  prefixKey = "-prefix ";
+
+  # PostgreSQL autodetection fails sporadically because Qt omits the "-lpq" flag
+  # if dependency paths contain the string "pq", which can occur in the hash.
+  # To prevent these failures, we need to override PostgreSQL detection.
+  PSQL_LIBS = lib.optionalString (postgresql != null) "-L${postgresql.lib}/lib -lpq";
+
+  # -no-eglfs, -no-directfb, -no-linuxfb and -no-kms because of the current minimalist mesa
+  # TODO Remove obsolete and useless flags once the build will be totally mastered
+  configureFlags =
+    [
+      "-verbose"
+      "-confirm-license"
+      "-opensource"
+
+      "-release"
+      "-shared"
+      "-accessibility"
+      "-optimized-qmake"
+      "-strip"
+      "-system-proxies"
+      "-pkg-config"
+
+      "-gui"
+      "-widgets"
+      "-opengl desktop"
+      "-qml-debug"
+      "-icu"
+      "-pch"
+    ]
+    ++ lib.optionals (compareVersion "5.9.0" < 0)
+    [
+      "-c++11"
+      "-no-reduce-relocations"
+    ]
+    ++ lib.optionals developerBuild [
+      "-developer-build"
+      "-no-warnings-are-errors"
+    ]
+    ++ (
+      if (!stdenv.hostPlatform.isx86_64)
+      then [ "-no-sse2" ]
+      else lib.optional (compareVersion "5.9.0" >= 0) [ "-sse2" ]
+    )
+    ++ [
+      "-no-sse3"
+      "-no-ssse3"
+      "-no-sse4.1"
+      "-no-sse4.2"
+      "-no-avx"
+      "-no-avx2"
+      "-no-mips_dsp"
+      "-no-mips_dspr2"
+    ]
+
+    ++ [
+      "-system-zlib"
+      "-system-libjpeg"
+      "-system-harfbuzz"
+      "-system-pcre"
+      "-openssl-linked"
+      "-system-sqlite"
+      ''-${if mysql != null then "plugin" else "no"}-sql-mysql''
+      ''-${if postgresql != null then "plugin" else "no"}-sql-psql''
+
+      "-make libs"
+      "-make tools"
+      ''-${lib.optionalString (!buildExamples) "no"}make examples''
+      ''-${lib.optionalString (!buildTests) "no"}make tests''
+      "-v"
+    ]
+
+    ++ (
+      if stdenv.isDarwin
+      then
+        [
+          "-platform macx-clang"
+          "-no-use-gold-linker"
+          "-no-fontconfig"
+          "-qt-freetype"
+          "-qt-libpng"
+        ]
+      else
+        [
+          "-${lib.optionalString (compareVersion "5.9.0" < 0) "no-"}rpath"
+
+          "-system-xcb"
+          "-xcb"
+          "-qpa xcb"
+
+          "-system-xkbcommon"
+          "-libinput"
+          "-xkbcommon-evdev"
+
+          "-no-eglfs"
+          "-no-gbm"
+          "-no-kms"
+          "-no-linuxfb"
+
+          ''-${lib.optionalString (cups == null) "no-"}cups''
+          "-dbus-linked"
+          "-glib"
+          "-system-libjpeg"
+          "-system-libpng"
+          # gold linker of binutils 2.28 generates duplicate symbols
+          # TODO: remove for newer version of binutils
+          "-no-use-gold-linker"
+        ]
+        ++ lib.optional withGtk3 "-gtk"
+        ++ lib.optional (compareVersion "5.9.0" >= 0) "-inotify"
+    );
+
+  enableParallelBuilding = true;
+
+  postInstall =
+    # Move selected outputs.
+    ''
+      moveToOutput "mkspecs" "$dev"
+    '';
+
+  devTools = [
+    "bin/fixqt4headers.pl"
+    "bin/moc"
+    "bin/qdbuscpp2xml"
+    "bin/qdbusxml2cpp"
+    "bin/qlalr"
+    "bin/qmake"
+    "bin/rcc"
+    "bin/syncqt.pl"
+    "bin/uic"
+  ];
+
+  postFixup =
+    # Don't retain build-time dependencies like gdb.
+    ''
+      sed '/QMAKE_DEFAULT_.*DIRS/ d' -i $dev/mkspecs/qconfig.pri
+    ''
+
+    + ''
+      fixQtModulePaths "''${!outputDev}/mkspecs/modules"
+      fixQtBuiltinPaths "''${!outputDev}" '*.pr?'
+    ''
+
+    # Move development tools to $dev
+    + ''
+      moveQtDevTools
+      moveToOutput bin "$dev"
+    ''
+
+    + (
+      if stdenv.isDarwin
+      then
+        ''
+          fixDarwinDylibNames_rpath() {
+            local flags=()
+
+            for fn in "$@"; do
+              flags+=(-change "@rpath/$fn.framework/Versions/5/$fn" "$out/lib/$fn.framework/Versions/5/$fn")
+            done
+
+            for fn in "$@"; do
+              echo "$fn: fixing dylib"
+              install_name_tool -id "$out/lib/$fn.framework/Versions/5/$fn" "''${flags[@]}" "$out/lib/$fn.framework/Versions/5/$fn"
+            done
+          }
+          fixDarwinDylibNames_rpath "QtConcurrent" "QtPrintSupport" "QtCore" "QtSql" "QtDBus" "QtTest" "QtGui" "QtWidgets" "QtNetwork" "QtXml" "QtOpenGL"
+        ''
+      else
+        # fixup .pc file (where to find 'moc' etc.)
+        ''
+          sed -i "$dev/lib/pkgconfig/Qt5Core.pc" \
+              -e "/^host_bins=/ c host_bins=$dev/bin"
+        ''
+    );
+
+  setupHook = ../hooks/qtbase-setup-hook.sh;
+
+  meta = with lib; {
+    homepage = http://www.qt.io;
+    description = "A cross-platform application framework for C++";
+    license = with licenses; [ fdl13 gpl2 lgpl21 lgpl3 ];
+    maintainers = with maintainers; [ qknight ttuegel periklis ];
+    platforms = platforms.unix;
+  };
+
+}
diff --git a/pkgs/development/libraries/qt-5/modules/qtcharts.nix b/pkgs/development/libraries/qt-5/modules/qtcharts.nix
new file mode 100644
index 000000000000..84d3a17ea8ce
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/modules/qtcharts.nix
@@ -0,0 +1,7 @@
+{ qtModule, qtbase, qtdeclarative }:
+
+qtModule {
+  name = "qtcharts";
+  qtInputs = [ qtbase qtdeclarative ];
+  outputs = [ "out" "dev" "bin" ];
+}
diff --git a/pkgs/development/libraries/qt-5/modules/qtconnectivity.nix b/pkgs/development/libraries/qt-5/modules/qtconnectivity.nix
new file mode 100644
index 000000000000..d866edb052b8
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/modules/qtconnectivity.nix
@@ -0,0 +1,8 @@
+{ qtModule, qtbase, qtdeclarative, bluez }:
+
+qtModule {
+  name = "qtconnectivity";
+  qtInputs = [ qtbase qtdeclarative ];
+  buildInputs = [ bluez ];
+  outputs = [ "out" "dev" "bin" ];
+}
diff --git a/pkgs/development/libraries/qt-5/modules/qtdeclarative.nix b/pkgs/development/libraries/qt-5/modules/qtdeclarative.nix
new file mode 100644
index 000000000000..fc0a751f48a0
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/modules/qtdeclarative.nix
@@ -0,0 +1,25 @@
+{ qtModule, lib, python2, qtbase, qtsvg, qtxmlpatterns }:
+
+with lib;
+
+qtModule {
+  name = "qtdeclarative";
+  qtInputs = [ qtbase qtsvg qtxmlpatterns ];
+  nativeBuildInputs = [ python2 ];
+  outputs = [ "out" "dev" "bin" ];
+  preConfigure = ''
+    NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QML2_IMPORT_PREFIX=\"$qtQmlPrefix\""
+  '';
+  devTools = [
+    "bin/qml"
+    "bin/qmlcachegen"
+    "bin/qmleasing"
+    "bin/qmlimportscanner"
+    "bin/qmllint"
+    "bin/qmlmin"
+    "bin/qmlplugindump"
+    "bin/qmlprofiler"
+    "bin/qmlscene"
+    "bin/qmltestrunner"
+  ];
+}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtdoc.nix b/pkgs/development/libraries/qt-5/modules/qtdoc.nix
index 7f979ee94c0f..10623962c430 100644
--- a/pkgs/development/libraries/qt-5/5.9/qtdoc.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtdoc.nix
@@ -1,6 +1,6 @@
-{ qtSubmodule, qtdeclarative }:
+{ qtModule, qtdeclarative }:
 
-qtSubmodule {
+qtModule {
   name = "qtdoc";
   qtInputs = [ qtdeclarative ];
   outputs = [ "out" ];
diff --git a/pkgs/development/libraries/qt-5/5.6/qtgraphicaleffects.nix b/pkgs/development/libraries/qt-5/modules/qtgraphicaleffects.nix
index 3273f12eb830..888f627baab8 100644
--- a/pkgs/development/libraries/qt-5/5.6/qtgraphicaleffects.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtgraphicaleffects.nix
@@ -1,6 +1,7 @@
-{ qtSubmodule, qtdeclarative }:
+{ qtModule, qtdeclarative }:
 
-qtSubmodule {
+qtModule {
   name = "qtgraphicaleffects";
   qtInputs = [ qtdeclarative ];
+  outputs = [ "out" ];
 }
diff --git a/pkgs/development/libraries/qt-5/5.6/qtimageformats.nix b/pkgs/development/libraries/qt-5/modules/qtimageformats.nix
index 03d0fffbe80e..1a7726070be3 100644
--- a/pkgs/development/libraries/qt-5/5.6/qtimageformats.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtimageformats.nix
@@ -1,6 +1,6 @@
-{ qtSubmodule, qtbase }:
+{ qtModule, qtbase }:
 
-qtSubmodule {
+qtModule {
   name = "qtimageformats";
   qtInputs = [ qtbase ];
 }
diff --git a/pkgs/development/libraries/qt-5/modules/qtlocation.nix b/pkgs/development/libraries/qt-5/modules/qtlocation.nix
new file mode 100644
index 000000000000..e8952e29cbaf
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/modules/qtlocation.nix
@@ -0,0 +1,16 @@
+{ stdenv, qtModule, qtbase, qtmultimedia }:
+
+qtModule {
+  name = "qtlocation";
+  qtInputs = [ qtbase qtmultimedia ];
+  outputs = [ "bin" "out" "dev" ];
+  # Linking with -lclipper fails with parallel build enabled
+  enableParallelBuilding = false;
+  qmakeFlags = stdenv.lib.optional stdenv.isDarwin [
+     # boost uses std::auto_ptr which has been disabled in clang with libcxx
+     # This flag re-enables this feature
+     # https://libcxx.llvm.org/docs/UsingLibcxx.html#c-17-specific-configuration-macros
+     "QMAKE_CXXFLAGS+=-D_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR"
+  ];
+
+}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtmacextras.nix b/pkgs/development/libraries/qt-5/modules/qtmacextras.nix
index 582294cc7f76..5a3b1fe35cd8 100644
--- a/pkgs/development/libraries/qt-5/5.9/qtmacextras.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtmacextras.nix
@@ -1,6 +1,6 @@
-{ qtSubmodule, qtbase, lib }:
+{ qtModule, qtbase, lib }:
 
-qtSubmodule {
+qtModule {
   name = "qtmacextras";
   qtInputs = [ qtbase ];
   meta = with lib; {
diff --git a/pkgs/development/libraries/qt-5/5.9/qtmultimedia.nix b/pkgs/development/libraries/qt-5/modules/qtmultimedia.nix
index 1c728b036ad8..1b7a7c1fceaa 100644
--- a/pkgs/development/libraries/qt-5/5.9/qtmultimedia.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtmultimedia.nix
@@ -1,11 +1,11 @@
-{ stdenv, qtSubmodule, qtbase, qtdeclarative, pkgconfig
+{ qtModule, stdenv, qtbase, qtdeclarative, pkgconfig
 , alsaLib, gstreamer, gst-plugins-base, libpulseaudio
 , darwin
 }:
 
 with stdenv.lib;
 
-qtSubmodule {
+qtModule {
   name = "qtmultimedia";
   qtInputs = [ qtbase qtdeclarative ];
   nativeBuildInputs = [ pkgconfig ];
@@ -14,8 +14,4 @@ qtSubmodule {
   outputs = [ "bin" "dev" "out" ];
   qmakeFlags = [ "GST_VERSION=1.0" ];
   NIX_LDFLAGS = optionalString (stdenv.isDarwin) "-lobjc";
-  postInstall = ''
-    moveToOutput "$qtPluginPrefix" "$bin"
-    moveToOutput "$qtQmlPrefix" "$bin"
-  '';
 }
diff --git a/pkgs/development/libraries/qt-5/5.9/qtquickcontrols.nix b/pkgs/development/libraries/qt-5/modules/qtquickcontrols.nix
index 93a864621b82..ba0f20bc0d83 100644
--- a/pkgs/development/libraries/qt-5/5.9/qtquickcontrols.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtquickcontrols.nix
@@ -1,6 +1,6 @@
-{ qtSubmodule, qtdeclarative }:
+{ qtModule, qtdeclarative }:
 
-qtSubmodule {
+qtModule {
   name = "qtquickcontrols";
   qtInputs = [ qtdeclarative ];
 }
diff --git a/pkgs/development/libraries/qt-5/modules/qtquickcontrols2.nix b/pkgs/development/libraries/qt-5/modules/qtquickcontrols2.nix
new file mode 100644
index 000000000000..a9522f4b1f0c
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/modules/qtquickcontrols2.nix
@@ -0,0 +1,7 @@
+{ qtModule, qtdeclarative }:
+
+qtModule {
+  name = "qtquickcontrols2";
+  qtInputs = [ qtdeclarative ];
+  outputs = [ "out" "dev" "bin" ];
+}
diff --git a/pkgs/development/libraries/qt-5/modules/qtscript.nix b/pkgs/development/libraries/qt-5/modules/qtscript.nix
new file mode 100644
index 000000000000..5a1a462a9640
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/modules/qtscript.nix
@@ -0,0 +1,6 @@
+{ qtModule, qtbase, qttools }:
+
+qtModule {
+  name = "qtscript";
+  qtInputs = [ qtbase qttools ];
+}
diff --git a/pkgs/development/libraries/qt-5/modules/qtsensors.nix b/pkgs/development/libraries/qt-5/modules/qtsensors.nix
new file mode 100644
index 000000000000..3b8732b68851
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/modules/qtsensors.nix
@@ -0,0 +1,7 @@
+{ qtModule, qtbase, qtdeclarative }:
+
+qtModule {
+  name = "qtsensors";
+  qtInputs = [ qtbase qtdeclarative ];
+  outputs = [ "out" "dev" "bin" ];
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtserialport/default.nix b/pkgs/development/libraries/qt-5/modules/qtserialport.nix
index 925e8a808f25..2f8c142323d2 100644
--- a/pkgs/development/libraries/qt-5/5.6/qtserialport/default.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtserialport.nix
@@ -1,11 +1,10 @@
-{ stdenv, qtSubmodule, lib, copyPathsToStore, qtbase, substituteAll, systemd }:
+{ qtModule, stdenv, lib, qtbase, substituteAll, systemd }:
 
 let inherit (lib) getLib optional; in
 
-qtSubmodule {
+qtModule {
   name = "qtserialport";
   qtInputs = [ qtbase ];
-  patches =  copyPathsToStore (lib.readPathsFromFile ./. ./series);
   NIX_CFLAGS_COMPILE =
     optional stdenv.isLinux
     ''-DNIXPKGS_LIBUDEV="${getLib systemd}/lib/libudev"'';
diff --git a/pkgs/development/libraries/qt-5/modules/qtspeech.nix b/pkgs/development/libraries/qt-5/modules/qtspeech.nix
new file mode 100644
index 000000000000..7b4b19ccab5a
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/modules/qtspeech.nix
@@ -0,0 +1,7 @@
+{ qtModule }:
+
+qtModule {
+  name = "qtspeech";
+  qtInputs = [ ];
+  outputs = [ "out" "dev" "bin" ];
+}
diff --git a/pkgs/development/libraries/qt-5/modules/qtsvg.nix b/pkgs/development/libraries/qt-5/modules/qtsvg.nix
new file mode 100644
index 000000000000..3ce68e56e412
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/modules/qtsvg.nix
@@ -0,0 +1,7 @@
+{ qtModule, qtbase }:
+
+qtModule {
+  name = "qtsvg";
+  qtInputs = [ qtbase ];
+  outputs = [ "out" "dev" "bin" ];
+}
diff --git a/pkgs/development/libraries/qt-5/modules/qttools.nix b/pkgs/development/libraries/qt-5/modules/qttools.nix
new file mode 100644
index 000000000000..622d841b4051
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/modules/qttools.nix
@@ -0,0 +1,36 @@
+{ qtModule, stdenv, lib, qtbase }:
+
+with lib;
+
+qtModule {
+  name = "qttools";
+  qtInputs = [ qtbase ];
+  outputs = [ "out" "dev" "bin" ];
+
+  # fixQtBuiltinPaths overwrites a builtin path we should keep
+  postPatch = ''
+    sed -i "src/linguist/linguist.pro" \
+        -e '/^cmake_linguist_config_version_file.input =/ s|$$\[QT_HOST_DATA.*\]|${getDev qtbase}|'
+  '';
+
+  devTools = [
+    "bin/qcollectiongenerator"
+    "bin/linguist"
+    "bin/assistant"
+    "bin/qdoc"
+    "bin/lconvert"
+    "bin/designer"
+    "bin/qtattributesscanner"
+    "bin/lrelease"
+    "bin/pixeltool"
+    "bin/lupdate"
+    "bin/qtdiag"
+    "bin/qhelpgenerator"
+    "bin/qtplugininfo"
+    "bin/qthelpconverter"
+  ] ++ optionals stdenv.isDarwin [
+    "bin/macdeployqt"
+  ];
+
+  setupHook = ../hooks/qttools-setup-hook.sh;
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qttranslations.nix b/pkgs/development/libraries/qt-5/modules/qttranslations.nix
index 50fc8cf6826a..11a6e3fedcb1 100644
--- a/pkgs/development/libraries/qt-5/5.6/qttranslations.nix
+++ b/pkgs/development/libraries/qt-5/modules/qttranslations.nix
@@ -1,6 +1,6 @@
-{ qtSubmodule, qttools }:
+{ qtModule, qttools }:
 
-qtSubmodule {
+qtModule {
   name = "qttranslations";
   qtInputs = [ qttools ];
 }
diff --git a/pkgs/development/libraries/qt-5/modules/qtvirtualkeyboard.nix b/pkgs/development/libraries/qt-5/modules/qtvirtualkeyboard.nix
new file mode 100644
index 000000000000..2ba720c8eedc
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/modules/qtvirtualkeyboard.nix
@@ -0,0 +1,6 @@
+{ qtModule, qtbase, qtdeclarative, qtsvg, hunspell  }:
+
+qtModule {
+  name = "qtvirtualkeyboard";
+  qtInputs = [ qtbase qtdeclarative qtsvg hunspell ];
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtwayland.nix b/pkgs/development/libraries/qt-5/modules/qtwayland.nix
index 6d887f7c650b..c7a7704f2837 100644
--- a/pkgs/development/libraries/qt-5/5.6/qtwayland.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtwayland.nix
@@ -1,8 +1,9 @@
-{ qtSubmodule, qtbase, qtquickcontrols, wayland, pkgconfig }:
+{ qtModule, qtbase, qtquickcontrols, wayland, pkgconfig }:
 
-qtSubmodule {
+qtModule {
   name = "qtwayland";
   qtInputs = [ qtbase qtquickcontrols ];
   buildInputs = [ wayland ];
   nativeBuildInputs = [ pkgconfig ];
+  outputs = [ "out" "dev" "bin" ];
 }
diff --git a/pkgs/development/libraries/qt-5/modules/qtwebchannel.nix b/pkgs/development/libraries/qt-5/modules/qtwebchannel.nix
new file mode 100644
index 000000000000..84fb88385a3e
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/modules/qtwebchannel.nix
@@ -0,0 +1,8 @@
+{ qtModule, qtbase, qtdeclarative }:
+
+qtModule {
+  name = "qtwebchannel";
+  qtInputs = [ qtbase qtdeclarative ];
+  outputs = [ "out" "dev" "bin" ];
+}
+
diff --git a/pkgs/development/libraries/qt-5/5.9/qtwebengine/default.nix b/pkgs/development/libraries/qt-5/modules/qtwebengine.nix
index 58716f65738f..08345510d787 100644
--- a/pkgs/development/libraries/qt-5/5.9/qtwebengine/default.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtwebengine.nix
@@ -1,9 +1,10 @@
-{ qtSubmodule, qtquickcontrols, qtlocation, qtwebchannel
+{ qtModule, qtCompatVersion,
+  qtdeclarative, qtquickcontrols, qtlocation, qtwebchannel
 
 , bison, coreutils, flex, git, gperf, ninja, pkgconfig, python2, which
 
-, xlibs, libXcursor, libXScrnSaver, libXrandr, libXtst
-, fontconfig, freetype, harfbuzz, icu, dbus
+, xorg, libXcursor, libXScrnSaver, libXrandr, libXtst
+, fontconfig, freetype, harfbuzz, icu, dbus, libdrm
 , zlib, minizip, libjpeg, libpng, libtiff, libwebp, libopus
 , jsoncpp, protobuf, libvpx, srtp, snappy, nss, libevent
 , alsaLib
@@ -18,9 +19,11 @@
 
 with stdenv.lib;
 
-qtSubmodule {
+let qt56 = qtCompatVersion == "5.6"; in
+
+qtModule {
   name = "qtwebengine";
-  qtInputs = [ qtquickcontrols qtlocation qtwebchannel ];
+  qtInputs = [ qtdeclarative qtquickcontrols qtlocation qtwebchannel ];
   nativeBuildInputs = [
     bison coreutils flex git gperf ninja pkgconfig python2 which
   ];
@@ -38,9 +41,9 @@ qtSubmodule {
     + ''
       substituteInPlace ./src/3rdparty/chromium/build/common.gypi \
         --replace /bin/echo ${coreutils}/bin/echo
-      substituteInPlace ./src/3rdparty/chromium/v8/gypfiles/toolchain.gypi \
+      substituteInPlace ./src/3rdparty/chromium/v8/${if qt56 then "build" else "gypfiles"}/toolchain.gypi \
         --replace /bin/echo ${coreutils}/bin/echo
-      substituteInPlace ./src/3rdparty/chromium/v8/gypfiles/standalone.gypi \
+      substituteInPlace ./src/3rdparty/chromium/v8/${if qt56 then "build" else "gypfiles"}/standalone.gypi \
         --replace /bin/echo ${coreutils}/bin/echo
     ''
     # Patch library paths in Qt sources
@@ -60,8 +63,13 @@ qtSubmodule {
         src/3rdparty/chromium/gpu/config/gpu_info_collector_linux.cc
     '';
 
+
   preConfigure = ''
-    export MAKEFLAGS=-j$NIX_BUILD_CORES
+    export NINJAFLAGS=-j$NIX_BUILD_CORES
+
+    if [ -d "$PWD/tools/qmake" ]; then
+        QMAKEPATH="$PWD/tools/qmake''${QMAKEPATH:+:}$QMAKEPATH"
+    fi
  '';
 
   qmakeFlags =
@@ -96,10 +104,9 @@ qtSubmodule {
     pciutils
 
     # X11 libs
-    xlibs.xrandr libXScrnSaver libXcursor libXrandr xlibs.libpciaccess libXtst
-    xlibs.libXcomposite
+    xorg.xrandr libXScrnSaver libXcursor libXrandr xorg.libpciaccess libXtst
+    xorg.libXcomposite xorg.libXdamage libdrm
   ];
-  patches = optional stdenv.needsPax ./qtwebengine-paxmark-mksnapshot.patch;
 
   dontUseNinjaBuild = true;
   dontUseNinjaInstall = true;
@@ -111,7 +118,5 @@ qtSubmodule {
     EOF
 
     paxmark m $out/libexec/QtWebEngineProcess
-
-    moveToOutput "$qtQmlPrefix" "$bin"
   '';
 }
diff --git a/pkgs/development/libraries/qt-5/5.9/qtwebkit/default.nix b/pkgs/development/libraries/qt-5/modules/qtwebkit.nix
index 664281aac311..6834b7ce87b6 100644
--- a/pkgs/development/libraries/qt-5/5.9/qtwebkit/default.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtwebkit.nix
@@ -1,5 +1,5 @@
-{ qtSubmodule, stdenv, copyPathsToStore, lib
-, qtdeclarative, qtlocation, qtsensors
+{ qtModule, stdenv, lib
+, qtbase, qtdeclarative, qtlocation, qtsensors
 , fontconfig, gdk_pixbuf, gtk2, libwebp, libxml2, libxslt
 , sqlite, systemd, glib, gst_all_1
 , bison2, flex, gdb, gperf, perl, pkgconfig, python2, ruby
@@ -10,9 +10,9 @@
 
 let inherit (lib) optional optionals getLib; in
 
-qtSubmodule {
+qtModule {
   name = "qtwebkit";
-  qtInputs = [ qtdeclarative qtlocation qtsensors ];
+  qtInputs = [ qtbase qtdeclarative qtlocation qtsensors ];
   buildInputs = [ fontconfig libwebp libxml2 libxslt sqlite glib gst_all_1.gstreamer gst_all_1.gst-plugins-base ]
     ++ optionals (stdenv.isDarwin) (with darwin.apple_sdk.frameworks; [ OpenGL ]);
   nativeBuildInputs = [
@@ -23,10 +23,16 @@ qtSubmodule {
     "/usr/lib/libicucore.dylib"
   ];
 
-  patches =  copyPathsToStore (lib.readPathsFromFile ./. ./series);
+  # QtWebKit overrides qmake's default_pre and default_post features,
+  # so its custom qmake files must be found first at the front of QMAKEPATH.
+  preConfigure = ''
+    QMAKEPATH="$PWD/Tools/qmake''${QMAKEPATH:+:}$QMAKEPATH"
+    fixQtBuiltinPaths . '*.pr?'
+  '';
 
   NIX_CFLAGS_COMPILE =
-    optionals flashplayerFix
+    [ "-Wno-expansion-to-defined" ] # with gcc7 this warning blows the log over Hydra's limit
+    ++ optionals flashplayerFix
       [
         ''-DNIXPKGS_LIBGTK2="${getLib gtk2}/lib/libgtk-x11-2.0"''
         ''-DNIXPKGS_LIBGDK2="${getLib gdk_pixbuf}/lib/libgdk-x11-2.0"''
diff --git a/pkgs/development/libraries/qt-5/modules/qtwebsockets.nix b/pkgs/development/libraries/qt-5/modules/qtwebsockets.nix
new file mode 100644
index 000000000000..ad5e7625f289
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/modules/qtwebsockets.nix
@@ -0,0 +1,7 @@
+{ qtModule, qtbase, qtdeclarative }:
+
+qtModule {
+  name = "qtwebsockets";
+  qtInputs = [ qtbase qtdeclarative ];
+  outputs = [ "out" "dev" "bin" ];
+}
diff --git a/pkgs/development/libraries/qt-5/5.9/qtx11extras.nix b/pkgs/development/libraries/qt-5/modules/qtx11extras.nix
index a765161e2d7e..4d431fee278b 100644
--- a/pkgs/development/libraries/qt-5/5.9/qtx11extras.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtx11extras.nix
@@ -1,6 +1,6 @@
-{ qtSubmodule, qtbase }:
+{ qtModule, qtbase }:
 
-qtSubmodule {
+qtModule {
   name = "qtx11extras";
   qtInputs = [ qtbase ];
 }
diff --git a/pkgs/development/libraries/qt-5/modules/qtxmlpatterns.nix b/pkgs/development/libraries/qt-5/modules/qtxmlpatterns.nix
new file mode 100644
index 000000000000..ee8ef617fc8d
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/modules/qtxmlpatterns.nix
@@ -0,0 +1,7 @@
+{ qtModule, qtbase }:
+
+qtModule {
+  name = "qtxmlpatterns";
+  qtInputs = [ qtbase ];
+  devTools = [ "bin/xmlpatterns" "bin/xmlpatternsvalidator" ];
+}
diff --git a/pkgs/development/libraries/qt-5/qmake-hook.sh b/pkgs/development/libraries/qt-5/qmake-hook.sh
deleted file mode 100644
index c70410975ecd..000000000000
--- a/pkgs/development/libraries/qt-5/qmake-hook.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-qmakeConfigurePhase() {
-    runHook preConfigure
-
-    qmake PREFIX=$out $qmakeFlags
-
-    runHook postConfigure
-}
-
-if [ -z "$dontUseQmakeConfigure" -a -z "$configurePhase" ]; then
-    configurePhase=qmakeConfigurePhase
-fi
-
-_qtModuleMultioutDevsPre() {
-    # We cannot simply set these paths in configureFlags because libQtCore retains
-    # references to the paths it was built with.
-    moveToOutput "bin" "${!outputDev}"
-    moveToOutput "include" "${!outputDev}"
-
-    # The destination directory must exist or moveToOutput will do nothing
-    mkdir -p "${!outputDev}/share"
-    moveToOutput "share/doc" "${!outputDev}"
-}
-
-_qtModuleMultioutDevsPost() {
-    local -a findopts=(-name '*.a' -o -name '*.la')
-    if [ -z "@isDarwin@" ]; then
-        findopts+=(-o -name '*.prl')
-    fi
-
-    # Move libtool archives and qmake project files to $dev/lib
-    if [ "z${!outputLib}" != "z${!outputDev}" ]; then
-        pushd "${!outputLib}"
-        if [ -d "lib" ]; then
-            find lib \( "${findopts[@]}" \) -print0 | \
-                while read -r -d $'\0' file; do
-                    mkdir -p "${!outputDev}/$(dirname "$file")"
-                    mv "${!outputLib}/$file" "${!outputDev}/$file"
-                done
-        fi
-        popd
-    fi
-}
-
-if [ -n "$NIX_QT_SUBMODULE" ]; then
-    preFixupHooks+=(_qtModuleMultioutDevsPre)
-    postFixupHooks+=(_qtModuleMultioutDevsPost)
-fi
diff --git a/pkgs/development/libraries/qt-5/qt-env.nix b/pkgs/development/libraries/qt-5/qt-env.nix
index 728761689b42..49585f601d14 100644
--- a/pkgs/development/libraries/qt-5/qt-env.nix
+++ b/pkgs/development/libraries/qt-5/qt-env.nix
@@ -13,9 +13,9 @@ buildEnv {
     cat >"$out/bin/qt.conf" <<EOF
     [Paths]
     Prefix = $out
-    Plugins = $qtPluginPrefix
-    Qml2Imports = $qtQmlPrefix
-    Documentation = $qtDocPrefix
+    Plugins = ${qtbase.qtPluginPrefix}
+    Qml2Imports = ${qtbase.qtQmlPrefix}
+    Documentation = ${qtbase.qtDocPrefix}
     EOF
   '';
 }
diff --git a/pkgs/development/libraries/qt-5/qtModule.nix b/pkgs/development/libraries/qt-5/qtModule.nix
new file mode 100644
index 000000000000..11e4ae1c26c5
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/qtModule.nix
@@ -0,0 +1,59 @@
+{ lib, mkDerivation, perl }:
+
+let inherit (lib) licenses maintainers platforms; in
+
+{ self, srcs, patches }:
+
+args:
+
+let
+  inherit (args) name;
+  version = args.version or srcs."${name}".version;
+  src = args.src or srcs."${name}".src;
+in
+
+mkDerivation (args // {
+  name = "${name}-${version}";
+  inherit src;
+  patches = args.patches or patches."${name}" or [];
+
+  nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ perl self.qmake ];
+  propagatedBuildInputs = args.qtInputs ++ (args.propagatedBuildInputs or []);
+
+  outputs = args.outputs or [ "out" "dev" ];
+  setOutputFlags = args.setOutputFlags or false;
+
+  preHook = ''
+    . ${./hooks/move-qt-dev-tools.sh}
+    . ${./hooks/fix-qt-builtin-paths.sh}
+  '';
+
+  preConfigure = ''
+    ${args.preConfigure or ""}
+
+    fixQtBuiltinPaths . '*.pr?'
+  '';
+
+  postFixup = ''
+    if [ -d "''${!outputDev}/lib/pkgconfig" ]; then
+        find "''${!outputDev}/lib/pkgconfig" -name '*.pc' | while read pc; do
+            sed -i "$pc" \
+                -e "/^prefix=/ c prefix=''${!outputLib}" \
+                -e "/^exec_prefix=/ c exec_prefix=''${!outputBin}" \
+                -e "/^includedir=/ c includedir=''${!outputDev}/include"
+        done
+    fi
+
+    moveQtDevTools
+
+    ${args.postFixup or ""}
+  '';
+
+  meta = {
+    homepage = http://www.qt.io;
+    description = "A cross-platform application framework for C++";
+    license = with licenses; [ fdl13 gpl2 lgpl21 lgpl3 ];
+    maintainers = with maintainers; [ qknight ttuegel periklis ];
+    platforms = platforms.unix;
+  } // (args.meta or {});
+})
diff --git a/pkgs/development/libraries/qt-5/qtbase-setup-hook-darwin.sh b/pkgs/development/libraries/qt-5/qtbase-setup-hook-darwin.sh
deleted file mode 100644
index 3f6a00dc1a1e..000000000000
--- a/pkgs/development/libraries/qt-5/qtbase-setup-hook-darwin.sh
+++ /dev/null
@@ -1,192 +0,0 @@
-qtPluginPrefix=@qtPluginPrefix@
-qtQmlPrefix=@qtQmlPrefix@
-qtDocPrefix=@qtDocPrefix@
-
-_qtRmCMakeLink() {
-    find "${!outputLib}" -name "*.cmake" -type l -delete
-}
-
-postInstallHooks+=(_qtRmCMakeLink)
-
-addToSearchPathOnceWithCustomDelimiter() {
-    local delim="$1"
-    local search="$2"
-    local target="$3"
-    local dirs
-    local exported
-    IFS="$delim" read -a dirs <<< "${!search}"
-    local canonical
-    if canonical=$(readlink -e "$target"); then
-        for dir in ${dirs[@]}; do
-            if [ "z$dir" == "z$canonical" ]; then exported=1; fi
-        done
-        if [ -z $exported ]; then
-            eval "export ${search}=\"${!search}${!search:+$delim}$canonical\""
-        fi
-    fi
-}
-
-addToSearchPathOnce() {
-    addToSearchPathOnceWithCustomDelimiter ':' "$@"
-}
-
-propagateOnce() {
-    addToSearchPathOnceWithCustomDelimiter ' ' "$@"
-}
-
-_qtPropagate() {
-    for dir in $qtPluginPrefix $qtQmlPrefix; do
-        if [ -d "$1/$dir" ]; then
-            propagateOnce propagatedBuildInputs "$1"
-            break
-        fi
-    done
-    addToSearchPathOnce QT_PLUGIN_PATH "$1/$qtPluginPrefix"
-    addToSearchPathOnce QML2_IMPORT_PATH "$1/$qtQmlPrefix"
-}
-
-crossEnvHooks+=(_qtPropagate)
-
-_qtPropagateNative() {
-    for dir in $qtPluginPrefix $qtQmlPrefix; do
-        if [ -d "$1/$dir" ]; then
-            propagateOnce propagatedNativeBuildInputs "$1"
-            break
-        fi
-    done
-    if [ -z "$crossConfig" ]; then
-    addToSearchPathOnce QT_PLUGIN_PATH "$1/$qtPluginPrefix"
-    addToSearchPathOnce QML2_IMPORT_PATH "$1/$qtQmlPrefix"
-    fi
-}
-
-envHooks+=(_qtPropagateNative)
-
-_qtMultioutDevs() {
-    # This is necessary whether the package is a Qt module or not
-    moveToOutput "mkspecs" "${!outputDev}"
-}
-
-preFixupHooks+=(_qtMultioutDevs)
-
-_qtSetCMakePrefix() {
-    export CMAKE_PREFIX_PATH="$NIX_QT5_TMP${CMAKE_PREFIX_PATH:+:}${CMAKE_PREFIX_PATH}"
-}
-
-_qtRmTmp() {
-    if [ -z "$NIX_QT_SUBMODULE" ]; then
-        rm -fr "$NIX_QT5_TMP"
-    else
-        cat "$NIX_QT5_TMP/nix-support/qt-inputs" | while read file; do
-            if [ ! -d "$NIX_QT5_TMP/$file" ]; then
-                rm -f "$NIX_QT5_TMP/$file"
-            fi
-        done
-
-        cat "$NIX_QT5_TMP/nix-support/qt-inputs" | while read dir; do
-            if [ -d "$NIX_QT5_TMP/$dir" ]; then
-                rmdir --ignore-fail-on-non-empty -p "$NIX_QT5_TMP/$dir"
-            fi
-        done
-
-        rm "$NIX_QT5_TMP/nix-support/qt-inputs"
-    fi
-}
-
-_qtSetQmakePath() {
-    export PATH="$NIX_QT5_TMP/bin${PATH:+:}$PATH"
-}
-
-if [ -z "$NIX_QT5_TMP" ]; then
-    if [ -z "$NIX_QT_SUBMODULE" ]; then
-        NIX_QT5_TMP=$(pwd)/.nix_qt5
-    else
-        NIX_QT5_TMP=$out
-    fi
-    postInstallHooks+=(_qtRmTmp)
-
-    mkdir -p "$NIX_QT5_TMP/nix-support"
-    for subdir in bin include mkspecs share; do
-        mkdir -p "$NIX_QT5_TMP/$subdir"
-        echo "$subdir/" >> "$NIX_QT5_TMP/nix-support/qt-inputs"
-    done
-    mkdir -p "$NIX_QT5_TMP/lib"
-
-    postHooks+=(_qtSetCMakePrefix)
-
-    ln -sf "@dev@/bin/qmake" "$NIX_QT5_TMP/bin"
-    echo "bin/qmake" >> "$NIX_QT5_TMP/nix-support/qt-inputs"
-
-    cat >"$NIX_QT5_TMP/bin/qt.conf" <<EOF
-[Paths]
-Prefix = $NIX_QT5_TMP
-Plugins = $qtPluginPrefix
-Qml2Imports = $qtQmlPrefix
-Documentation = $qtDocPrefix
-EOF
-    echo "bin/qt.conf" >> "$NIX_QT5_TMP/nix-support/qt-inputs"
-
-    export QMAKE="$NIX_QT5_TMP/bin/qmake"
-
-    # Set PATH to find qmake first in a preConfigure hook
-    # It must run after all the envHooks!
-    preConfigureHooks+=(_qtSetQmakePath)
-fi
-
-qt5LinkModuleDir() {
-    if [ -d "$1/$2" ]; then
-        @lndir@/bin/lndir -silent "$1/$2" "$NIX_QT5_TMP/$2"
-        find "$1/$2" -printf "$2/%P\n" >> "$NIX_QT5_TMP/nix-support/qt-inputs"
-    fi
-}
-
-qt5LinkDarwinModuleLibDir() {
-  for fw in $(find "$1"/lib -maxdepth 1 -name '*.framework'); do
-    if [ ! -L "$fw" ]; then
-      ln -s "$fw" "$NIX_QT5_TMP"/lib
-    fi
-  done
-  for file in $(find "$1"/lib -maxdepth 1 -type f); do
-    if [ ! -L "$file" ]; then
-      ln -s "$file" "$NIX_QT5_TMP"/lib
-    fi
-  done
-  for dir in $(find "$1"/lib -maxdepth 1 -mindepth 1 -type d ! -name '*.framework'); do
-      mkdir -p "$NIX_QT5_TMP"/lib/$(basename "$dir")
-      @lndir@/bin/lndir -silent "$dir" "$NIX_QT5_TMP"/lib/$(basename "$dir")
-  done
-}
-
-NIX_QT5_MODULES="${NIX_QT5_MODULES}${NIX_QT5_MODULES:+:}@out@"
-NIX_QT5_MODULES_DEV="${NIX_QT5_MODULES_DEV}${NIX_QT5_MODULES_DEV:+:}@dev@"
-
-_qtLinkAllModules() {
-    IFS=: read -a modules <<< $NIX_QT5_MODULES
-    for module in ${modules[@]}; do
-        qt5LinkDarwinModuleLibDir "$module"
-    done
-
-    IFS=: read -a modules <<< $NIX_QT5_MODULES_DEV
-    for module in ${modules[@]}; do
-        qt5LinkModuleDir "$module" "bin"
-        qt5LinkModuleDir "$module" "include"
-        qt5LinkDarwinModuleLibDir "$module"
-        qt5LinkModuleDir "$module" "mkspecs"
-        qt5LinkModuleDir "$module" "share"
-    done
-}
-
-preConfigureHooks+=(_qtLinkAllModules)
-
-_qtFixCMakePaths() {
-    find "${!outputLib}" -name "*.cmake" | while read file; do
-        substituteInPlace "$file" \
-            --subst-var-by NIX_OUT "${!outputLib}" \
-            --subst-var-by NIX_DEV "${!outputDev}" \
-            --subst-var-by NIX_BIN "${!outputBin}"
-    done
-}
-
-if [ -n "$NIX_QT_SUBMODULE" ]; then
-    postInstallHooks+=(_qtFixCMakePaths)
-fi
diff --git a/pkgs/development/libraries/qt-5/qtbase-setup-hook.sh b/pkgs/development/libraries/qt-5/qtbase-setup-hook.sh
deleted file mode 100644
index e4ef456bf97b..000000000000
--- a/pkgs/development/libraries/qt-5/qtbase-setup-hook.sh
+++ /dev/null
@@ -1,155 +0,0 @@
-qtPluginPrefix=@qtPluginPrefix@
-qtQmlPrefix=@qtQmlPrefix@
-qtDocPrefix=@qtDocPrefix@
-
-NIX_QT5_MODULES="${NIX_QT5_MODULES}${NIX_QT5_MODULES:+:}@out@"
-NIX_QT5_MODULES_DEV="${NIX_QT5_MODULES_DEV}${NIX_QT5_MODULES_DEV:+:}@dev@"
-
-providesQtRuntime() {
-    [ -d "$1/$qtPluginPrefix" ] || [ -d "$1/$qtQmlPrefix" ]
-}
-
-# Propagate any runtime dependency of the building package.
-# Each dependency is propagated to the user environment and as a build
-# input so that it will be re-propagated to the user environment by any
-# package depending on the building package. (This is necessary in case
-# the building package does not provide runtime dependencies itself and so
-# would not be propagated to the user environment.)
-_qtCrossEnvHook() {
-    if providesQtRuntime "$1"; then
-        propagatedBuildInputs+=" $1"
-        propagatedUserEnvPkgs+=" $1"
-    fi
-}
-if [ -z "$NIX_QT5_TMP" ]; then
-    crossEnvHooks+=(_qtCrossEnvHook)
-fi
-
-_qtEnvHook() {
-    if providesQtRuntime "$1"; then
-        propagatedNativeBuildInputs+=" $1"
-        if [ -z "$crossConfig" ]; then
-        propagatedUserEnvPkgs+=" $1"
-        fi
-    fi
-}
-if [ -z "$NIX_QT5_TMP" ]; then
-    envHooks+=(_qtEnvHook)
-fi
-
-_qtPreFixupHook() {
-    moveToOutput "mkspecs" "${!outputDev}"
-}
-if [ -z "$NIX_QT5_TMP" ]; then
-    preFixupHooks+=(_qtPreFixupHook)
-fi
-
-_qtPostInstallHook() {
-    # Clean up temporary installation files created by this setup hook.
-    # For building Qt modules, this is necessary to prevent including
-    # dependencies in the output. For all other packages, this is necessary
-    # to induce patchelf to remove the temporary paths from the RPATH of
-    # dynamically-linked objects.
-    if [ -z "$NIX_QT_SUBMODULE" ]; then
-        rm -fr "$NIX_QT5_TMP"
-    else
-        cat "$NIX_QT5_TMP/nix-support/qt-inputs" | while read file; do
-            if [ ! -d "$NIX_QT5_TMP/$file" ]; then
-                rm -f "$NIX_QT5_TMP/$file"
-            fi
-        done
-
-        cat "$NIX_QT5_TMP/nix-support/qt-inputs" | while read dir; do
-            if [ -d "$NIX_QT5_TMP/$dir" ]; then
-                rmdir --ignore-fail-on-non-empty -p "$NIX_QT5_TMP/$dir"
-            fi
-        done
-
-        rm "$NIX_QT5_TMP/nix-support/qt-inputs"
-    fi
-
-    # Patch CMake modules
-    if [ -n "$NIX_QT_SUBMODULE" ]; then
-        find "${!outputLib}" -name "*.cmake" | while read file; do
-            substituteInPlace "$file" \
-                --subst-var-by NIX_OUT "${!outputLib}" \
-                --subst-var-by NIX_DEV "${!outputDev}" \
-                --subst-var-by NIX_BIN "${!outputBin}"
-        done
-    fi
-}
-if [ -z "$NIX_QT5_TMP" ]; then
-    preConfigureHooks+=(_qtPreConfigureHook)
-fi
-
-_qtLinkModuleDir() {
-    if [ -d "$1/$2" ]; then
-        @lndir@/bin/lndir -silent "$1/$2" "$NIX_QT5_TMP/$2"
-        find "$1/$2" -printf "$2/%P\n" >> "$NIX_QT5_TMP/nix-support/qt-inputs"
-    fi
-}
-
-_qtPreConfigureHook() {
-    # Find the temporary qmake executable first.
-    # This must run after all the environment hooks!
-    export PATH="$NIX_QT5_TMP/bin${PATH:+:}$PATH"
-
-    # Link all runtime module dependencies into the temporary directory.
-    IFS=: read -a modules <<< $NIX_QT5_MODULES
-    for module in ${modules[@]}; do
-        _qtLinkModuleDir "$module" "lib"
-    done
-
-    # Link all the build-time module dependencies into the temporary directory.
-    IFS=: read -a modules <<< $NIX_QT5_MODULES_DEV
-    for module in ${modules[@]}; do
-        _qtLinkModuleDir "$module" "bin"
-        _qtLinkModuleDir "$module" "include"
-        _qtLinkModuleDir "$module" "lib"
-        _qtLinkModuleDir "$module" "mkspecs"
-        _qtLinkModuleDir "$module" "share"
-    done
-}
-if [ -z "$NIX_QT5_TMP" ]; then
-    postInstallHooks+=(_qtPostInstallHook)
-fi
-
-if [ -z "$NIX_QT5_TMP" ]; then
-    if [ -z "$NIX_QT_SUBMODULE" ]; then
-        if [ -z "$IN_NIX_SHELL" ]; then
-            NIX_QT5_TMP=$(pwd)/__nix_qt5__
-        else
-            NIX_QT5_TMP=$(mktemp -d)
-        fi
-    else
-        NIX_QT5_TMP=$out
-    fi
-
-    mkdir -p "$NIX_QT5_TMP/nix-support"
-    for subdir in bin include lib mkspecs share; do
-        mkdir -p "$NIX_QT5_TMP/$subdir"
-        echo "$subdir/" >> "$NIX_QT5_TMP/nix-support/qt-inputs"
-    done
-
-    cp "@dev@/bin/qmake" "$NIX_QT5_TMP/bin"
-    echo "bin/qmake" >> "$NIX_QT5_TMP/nix-support/qt-inputs"
-
-    cat >"$NIX_QT5_TMP/bin/qt.conf" <<EOF
-[Paths]
-Prefix = $NIX_QT5_TMP
-Plugins = $qtPluginPrefix
-Qml2Imports = $qtQmlPrefix
-Documentation = $qtDocPrefix
-EOF
-    echo "bin/qt.conf" >> "$NIX_QT5_TMP/nix-support/qt-inputs"
-
-    export QMAKE="$NIX_QT5_TMP/bin/qmake"
-fi
-
-_qtShellCleanupHook () {
-    rm -fr $NIX_QT5_TMP
-}
-
-if [ -n "$IN_NIX_SHELL" ]; then
-    trap _qtShellCleanupHook EXIT
-fi
diff --git a/pkgs/development/libraries/qt-5/qtsubmodule-setup-hook.sh b/pkgs/development/libraries/qt-5/qtsubmodule-setup-hook.sh
deleted file mode 100644
index e41433c11386..000000000000
--- a/pkgs/development/libraries/qt-5/qtsubmodule-setup-hook.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-NIX_QT5_MODULES="${NIX_QT5_MODULES}${NIX_QT5_MODULES:+:}@out@"
-NIX_QT5_MODULES_DEV="${NIX_QT5_MODULES_DEV}${NIX_QT5_MODULES_DEV:+:}@dev@"
diff --git a/pkgs/development/libraries/qtkeychain/default.nix b/pkgs/development/libraries/qtkeychain/default.nix
index ef0f5d4014ea..5baeb76820ac 100644
--- a/pkgs/development/libraries/qtkeychain/default.nix
+++ b/pkgs/development/libraries/qtkeychain/default.nix
@@ -1,31 +1,43 @@
 { stdenv, fetchFromGitHub, cmake, qt4 ? null
 , withQt5 ? false, qtbase ? null, qttools ? null
+, darwin ? null
 }:
 
 assert withQt5 -> qtbase != null;
 assert withQt5 -> qttools != null;
+assert stdenv.isDarwin -> darwin != null;
 
 stdenv.mkDerivation rec {
   name = "qtkeychain-${if withQt5 then "qt5" else "qt4"}-${version}";
-  version = "0.7.0";
+  version = "0.8.0";            # verify after nix-build with `grep -R "set(PACKAGE_VERSION " result/`
 
   src = fetchFromGitHub {
     owner = "frankosterfeld";
     repo = "qtkeychain";
     rev = "v${version}";
-    sha256 = "04v6ymkw7qd1pf9lwijgqrl89w2hhsnqgz7dm4cdrh8i8dffpn52";
+    sha256 = "1r6qp9l2lp5jpc6ciklbg1swvvzcpc37rg9py46hk0wxy6klnm0b"; # v0.8.0
   };
 
-  cmakeFlags = [ "-DQT_TRANSLATIONS_DIR=share/qt/translations" ];
+  cmakeFlags = [ "-DQT_TRANSLATIONS_DIR=share/qt/translations" ]
+    ++ stdenv.lib.optional stdenv.isDarwin [
+       # correctly detect the compiler
+       # for details see cmake --help-policy CMP0025
+       "-DCMAKE_POLICY_DEFAULT_CMP0025=NEW"
+       ]
+   ;
 
   nativeBuildInputs = [ cmake ];
 
-  buildInputs = if withQt5 then [ qtbase qttools ] else [ qt4 ];
+  buildInputs = if withQt5 then [ qtbase qttools ] else [ qt4 ]
+    ++ stdenv.lib.optional stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
+         CoreFoundation Security
+    ])
+  ;
 
   meta = {
     description = "Platform-independent Qt API for storing passwords securely";
     homepage = https://github.com/frankosterfeld/qtkeychain;
     license = stdenv.lib.licenses.bsd3;
-    platforms = stdenv.lib.platforms.linux;
+    platforms = stdenv.lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/qtscriptgenerator/qt-4.8.patch b/pkgs/development/libraries/qtscriptgenerator/qt-4.8.patch
index 0b02b0097252..8fe643e2c98f 100644
--- a/pkgs/development/libraries/qtscriptgenerator/qt-4.8.patch
+++ b/pkgs/development/libraries/qtscriptgenerator/qt-4.8.patch
@@ -1,4 +1,4 @@
-Origin: http://pkgs.fedoraproject.org/gitweb/?p=qtscriptgenerator.git;a=blob_plain;f=qtscriptgenerator-src-0.1.0-no_QFileOpenEvent.patch;h=f397b5ab13bcfc268e6d7b7ba4c6bc66ae38b5c0;hb=HEAD
+Origin: http://src.fedoraproject.org/gitweb/?p=qtscriptgenerator.git;a=blob_plain;f=qtscriptgenerator-src-0.1.0-no_QFileOpenEvent.patch;h=f397b5ab13bcfc268e6d7b7ba4c6bc66ae38b5c0;hb=HEAD
 diff -up qtscriptgenerator-src-0.1.0/generator/typesystem_gui-common.xml.no_QFileOpenEvent qtscriptgenerator-src-0.1.0/generator/typesystem_gui-common.xml
 --- qtscriptgenerator-src-0.1.0/generator/typesystem_gui-common.xml.no_QFileOpenEvent	2011-12-22 11:34:52.615149619 -0600
 +++ qtscriptgenerator-src-0.1.0/generator/typesystem_gui-common.xml	2011-12-22 11:35:31.808659632 -0600
diff --git a/pkgs/development/libraries/qtstyleplugin-kvantum-qt4/default.nix b/pkgs/development/libraries/qtstyleplugin-kvantum-qt4/default.nix
new file mode 100644
index 000000000000..2f0e39eb5c90
--- /dev/null
+++ b/pkgs/development/libraries/qtstyleplugin-kvantum-qt4/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, fetchFromGitHub, qmake4Hook , qt4, libX11, libXext }:
+
+stdenv.mkDerivation rec {
+  name = "qtstyleplugin-kvantum-qt4-${version}";
+  version = "0.10.4";
+
+  src = fetchFromGitHub {
+    owner = "tsujan";
+    repo = "Kvantum";
+    rev = "0527bb03f2252269fd382e11181a34ca72c96b4b";
+    sha256 = "0ky44s1fgqxraywagx1mv07yz76ppgiz3prq447db78wkwqg2d8p";
+  };
+
+  nativeBuildInputs = [ qmake4Hook ];
+  buildInputs = [ qt4 libX11 libXext ];
+
+  postUnpack = "sourceRoot=\${sourceRoot}/Kvantum";
+
+  buildPhase = ''
+    qmake kvantum.pro
+    make
+  '';
+
+  installPhase = ''
+    mkdir $TMP/kvantum
+    make INSTALL_ROOT="$TMP/kvantum" install
+    mv $TMP/kvantum/usr/ $out
+    mv $TMP/kvantum/${qt4}/lib $out
+  '';
+
+  meta = with stdenv.lib; {
+    description = "SVG-based Qt4 theme engine";
+    homepage = "https://github.com/tsujan/Kvantum";
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.bugworm ];
+  };
+}
diff --git a/pkgs/development/libraries/qtstyleplugin-kvantum/default.nix b/pkgs/development/libraries/qtstyleplugin-kvantum/default.nix
new file mode 100644
index 000000000000..8667f272cf7d
--- /dev/null
+++ b/pkgs/development/libraries/qtstyleplugin-kvantum/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchFromGitHub, qmake, qtbase, qtsvg, qtx11extras, libX11, libXext, qttools }:
+
+stdenv.mkDerivation rec {
+  name = "qtstyleplugin-kvantum-${version}";
+  version = "0.10.6";
+
+  src = fetchFromGitHub {
+    owner = "tsujan";
+    repo = "Kvantum";
+    rev = "a6daa1a6df3c5d4abc7ea39ef7028ddea2addbf6";
+    sha256 = "1zns4x95h0ydiwx8yw0bmyg4lc2sy7annmdrg66sx753x3177zxp";
+  };
+
+  nativeBuildInputs = [ qmake qttools ];
+  buildInputs = [ qtbase qtsvg qtx11extras libX11 libXext  ];
+
+  postUnpack = "sourceRoot=\${sourceRoot}/Kvantum";
+
+  postPatch = ''
+    # Fix plugin dir
+    substituteInPlace style/style.pro \
+      --replace "\$\$[QT_INSTALL_PLUGINS]" "$out/$qtPluginPrefix"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "SVG-based Qt5 theme engine plus a config tool and extra themes";
+    homepage = "https://github.com/tsujan/Kvantum";
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.bugworm ];
+  };
+}
diff --git a/pkgs/development/libraries/qtstyleplugins/default.nix b/pkgs/development/libraries/qtstyleplugins/default.nix
index 1be83731f202..a8611b312405 100644
--- a/pkgs/development/libraries/qtstyleplugins/default.nix
+++ b/pkgs/development/libraries/qtstyleplugins/default.nix
@@ -13,11 +13,6 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ pkgconfig qmake ];
   buildInputs = [ gtk2 ];
 
-  installPhase = ''
-    make INSTALL_ROOT=$NIX_QT5_TMP install
-    mv $NIX_QT5_TMP/$NIX_QT5_TMP $out
-  '';
-
   meta = with stdenv.lib; {
     description = "Additional style plugins for Qt5, including BB10, GTK+, Cleanlooks, Motif, Plastique";
     homepage = http://blog.qt.io/blog/2012/10/30/cleaning-up-styles-in-qt5-and-adding-fusion/;
diff --git a/pkgs/development/libraries/quazip/default.nix b/pkgs/development/libraries/quazip/default.nix
index 4379f5cf667b..8d096e18f08f 100644
--- a/pkgs/development/libraries/quazip/default.nix
+++ b/pkgs/development/libraries/quazip/default.nix
@@ -1,11 +1,11 @@
 { fetchurl, stdenv, zip, zlib, qtbase, qmake }:
 
 stdenv.mkDerivation rec {
-  name = "quazip-0.7.1";
+  name = "quazip-0.7.3";
 
   src = fetchurl {
     url = "mirror://sourceforge/quazip/${name}.tar.gz";
-    sha256 = "1pijy6zn8kdx9m6wrckid24vkgp250hklbpmgrpixiam6l889jbq";
+    sha256 = "1db9w8ax1ki0p67a47h4cnbwfgi2di4y3k9nc3a610kffiag7m1a";
   };
 
   preConfigure = "cd quazip";
diff --git a/pkgs/development/libraries/quesoglc/default.nix b/pkgs/development/libraries/quesoglc/default.nix
index 33e8d49454c1..84be9876c1cb 100644
--- a/pkgs/development/libraries/quesoglc/default.nix
+++ b/pkgs/development/libraries/quesoglc/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, mesa, glew, freetype, fontconfig, fribidi, libX11 }:
+{ stdenv, fetchurl, libGLU_combined, glew, freetype, fontconfig, fribidi, libX11 }:
 stdenv.mkDerivation rec {
   pname = "quesoglc";
   version = "0.7.2";
@@ -7,7 +7,7 @@ stdenv.mkDerivation rec {
     url = "mirror://sourceforge/${pname}/${name}.tar.bz2";
     sha256 = "0cf9ljdzii5d4i2m23gdmf3kn521ljcldzq69lsdywjid3pg5zjl";
   };
-  buildInputs = [ mesa glew freetype fontconfig fribidi libX11 ];
+  buildInputs = [ libGLU_combined glew freetype fontconfig fribidi libX11 ];
   # FIXME: Configure fails to use system glew.
   meta = with stdenv.lib; {
     description = "A free implementation of the OpenGL Character Renderer";
diff --git a/pkgs/development/libraries/quickder/default.nix b/pkgs/development/libraries/quickder/default.nix
index 73bd9e863cde..77e76ad638ab 100644
--- a/pkgs/development/libraries/quickder/default.nix
+++ b/pkgs/development/libraries/quickder/default.nix
@@ -1,32 +1,53 @@
-{ stdenv, fetchFromGitHub, fetchurl, hexio, python, which, asn2quickder, bash }:
+{ stdenv, fetchFromGitHub, fetchurl, python2Packages, hexio
+, which, cmake, bash, arpa2cm, git, asn2quickder, pkgconfig }:
 
 stdenv.mkDerivation rec {
   pname = "quickder";
   name = "${pname}-${version}";
-  version = "1.0-RC2";
+  version = "1.2-6";
 
   src = fetchFromGitHub {
-    sha256 = "1nzk8x6qzpvli8bf74dc2qya63nlppqjrnkaxvjxr2dbqb8qcrqd";
+    sha256 = "00wifjydgmqw2i5vmr049visc3shjqccgzqynkmmhkjhs86ghzr6";
     rev = "version-${version}";
     owner = "vanrein";
     repo = "quick-der";
   };
 
-  buildInputs = [ which asn2quickder bash ];
+  buildInputs = with python2Packages; [
+    arpa2cm
+    asn1ate
+    bash
+    cmake
+    git
+    hexio
+    pyparsing
+    python
+    six
+    which
+    asn1ate
+    asn2quickder
+    pkgconfig
+  ];
 
-  patchPhase = ''
-    substituteInPlace Makefile \
-      --replace 'lib tool test rfc' 'lib test rfc'
-    substituteInPlace ./rfc/Makefile \
-      --replace 'ASN2QUICKDER_CMD = ' 'ASN2QUICKDER_CMD = ${asn2quickder}/bin/asn2quickder #'
-    '';
+  postPatch = ''
+    substituteInPlace ./CMakeLists.txt \
+      --replace "get_version_from_git" "set (Quick-DER_VERSION 1.2) #"
+    substituteInPlace ./CMakeLists.txt \
+      --replace \$\{ARPA2CM_TOOLCHAIN_DIR} "$out/share/ARPA2CM/toolchain/"
+    patchShebangs python/scripts/
+  '';
 
-  installFlags = "ASN2QUICKDER_DIR=${asn2quickder}/bin ASN2QUICKDER_CMD=${asn2quickder}/bin/asn2quickder";
-  installPhase = ''
-    mkdir -p $out/lib $out/man
-    make DESTDIR=$out PREFIX=/ all
-    make DESTDIR=$out PREFIX=/ install
-    '';
+  cmakeFlags = [
+    "-DNO_TESTING=ON"
+    "-DARPA2CM_TOOLCHAIN_DIR=$out/share/ARPA2CM/toolchain/"
+    "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON"
+    "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON"
+    "-DPACKAGE_NO_PACKAGE_REGISTRY=ON"
+  ];
+
+  preConfigure = ''
+    export PREFIX=$out
+  '';
 
   meta = with stdenv.lib; {
     description = "Quick (and Easy) DER, a Library for parsing ASN.1";
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/6_qt4.nix b/pkgs/development/libraries/qwt/6_qt4.nix
index 0315ae72709e..79b182b33b22 100644
--- a/pkgs/development/libraries/qwt/6_qt4.nix
+++ b/pkgs/development/libraries/qwt/6_qt4.nix
@@ -1,20 +1,32 @@
-{ stdenv, fetchurl, qt4, qmake4Hook }:
+{ stdenv, fetchurl, qt4, qmake4Hook, AGL }:
 
 stdenv.mkDerivation rec {
-  name = "qwt-6.1.2";
+  name = "qwt-6.1.3";
 
   src = fetchurl {
     url = "mirror://sourceforge/qwt/${name}.tar.bz2";
-    sha256 = "031x4hz1jpbirv9k35rqb52bb9mf2w7qav89qv1yfw1r3n6z221b";
+    sha256 = "0cwp63s03dw351xavb3pzbjlqvx7kj88wv7v4a2b18m9f97d7v7k";
   };
 
-  buildInputs = [ qt4 ];
+  buildInputs = [
+    qt4
+  ] ++ stdenv.lib.optionals stdenv.isDarwin [ AGL ];
+
   nativeBuildInputs = [ qmake4Hook ];
 
+  enableParallelBuilding = true;
+
   postPatch = ''
     sed -e "s|QWT_INSTALL_PREFIX.*=.*|QWT_INSTALL_PREFIX = $out|g" -i qwtconfig.pri
   '';
 
+  # qwt.framework output includes a relative reference to itself, which breaks dependents
+  preFixup =
+    stdenv.lib.optionalString stdenv.isDarwin ''
+      echo "Attempting to repair qwt"
+      install_name_tool -id "$out/lib/qwt.framework/Versions/6/qwt" "$out/lib/qwt.framework/Versions/6/qwt"
+    '';
+
   qmakeFlags = [ "-after doc.path=$out/share/doc/${name}" ];
 
   meta = with stdenv.lib; {
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/rabbitmq-c/default.nix b/pkgs/development/libraries/rabbitmq-c/default.nix
index 0ab9cd1df041..c841d82ccce0 100644
--- a/pkgs/development/libraries/rabbitmq-c/default.nix
+++ b/pkgs/development/libraries/rabbitmq-c/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "rabbitmq-c-${version}";
-  version = "0.7.1";
+  version = "0.8.0";
 
   src = fetchFromGitHub {
     owner = "alanxz";
     repo = "rabbitmq-c";
     rev = "v${version}";
-    sha256 = "084zlir59zc505nxd4m2g9d355m9a8y94gbjaqmjz9kym8lpayd1";
+    sha256 = "0vjh1q3hyzrq1iiddy28vvwpwwn4px00mjc2hqp4zgfpis2xlqbj";
   };
 
   buildInputs = [ cmake openssl popt xmlto ];
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
     description = "RabbitMQ C AMQP client library";
     homepage = https://github.com/alanxz/rabbitmq-c;
     license = licenses.mit;
-    platforms = platforms.linux;
+    platforms = platforms.unix;
     maintainers = with maintainers; [ wkennington ];
   };
 }
diff --git a/pkgs/development/libraries/range-v3/default.nix b/pkgs/development/libraries/range-v3/default.nix
index f1d9026b5f92..bddda1dff552 100644
--- a/pkgs/development/libraries/range-v3/default.nix
+++ b/pkgs/development/libraries/range-v3/default.nix
@@ -1,21 +1,22 @@
-{ stdenv, fetchFromGitHub }:
+{ stdenv, fetchFromGitHub, cmake }:
 
 stdenv.mkDerivation rec {
   name = "range-v3-${version}";
-  version = "2017-01-30";
+  version = "0.3.5";
 
   src = fetchFromGitHub {
     owner = "ericniebler";
     repo = "range-v3";
-    rev = "bab29767cce120e11872d79a2537bc6f0be76963";
-    sha256 = "0kncpxms3f0nmn6jppp484244xq15d9298g3h3nlm1wvq8ib1jhi";
+    rev = version;
+    sha256 = "00bwm7n3wyf49xpr7zjhm08dzwx3lwibgafi6isvfls3dhk1m4kp";
   };
 
-  dontBuild = true;
-  installPhase = ''
-    mkdir -p $out/include
-    mv include/ $out/
-  '';
+  nativeBuildInputs = [ cmake ];
+
+  doCheck = true;
+  checkTarget = "test";
+
+  enableParallelBuilding = true;
 
   meta = with stdenv.lib; {
     description = "Experimental range library for C++11/14/17";
diff --git a/pkgs/development/libraries/rapidjson/default.nix b/pkgs/development/libraries/rapidjson/default.nix
index 5e9a11d42512..a1671aa3e0f9 100644
--- a/pkgs/development/libraries/rapidjson/default.nix
+++ b/pkgs/development/libraries/rapidjson/default.nix
@@ -13,11 +13,16 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ pkgconfig cmake ];
 
+  preConfigure = ''
+    substituteInPlace CMakeLists.txt --replace "-Werror" ""
+    substituteInPlace example/CMakeLists.txt --replace "-Werror" ""
+  '';
+
   meta = with lib; {
     description = "Fast JSON parser/generator for C++ with both SAX/DOM style API";
     homepage = "http://rapidjson.org/";
     license = licenses.mit;
-    platforms = platforms.linux;
+    platforms = platforms.unix;
     maintainers = with maintainers; [ cstrahan ];
   };
 }
diff --git a/pkgs/development/libraries/rdkafka/default.nix b/pkgs/development/libraries/rdkafka/default.nix
index ff017279dc64..a1af43748430 100644
--- a/pkgs/development/libraries/rdkafka/default.nix
+++ b/pkgs/development/libraries/rdkafka/default.nix
@@ -1,23 +1,21 @@
-{ stdenv, fetchFromGitHub, zlib, perl, pkgconfig, python }:
+{ stdenv, fetchFromGitHub, zlib, perl, pkgconfig, python, openssl }:
 
 stdenv.mkDerivation rec {
   name = "rdkafka-${version}";
-  version = "0.9.5";
+  version = "0.11.4";
 
   src = fetchFromGitHub {
     owner = "edenhill";
     repo = "librdkafka";
     rev = "v${version}";
-    sha256 = "0yp8vmj3yc564hcmhx46ssyn8qayywnsrg4wg67qk6jw967qgwsn";
+    sha256 = "11ps8sy4v8yvj4sha7d1q3rmhfw7l1rd52rnl01xam9862yasahs";
   };
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ zlib perl python ];
+  buildInputs = [ zlib perl python openssl ];
 
   NIX_CFLAGS_COMPILE = "-Wno-error=strict-overflow";
 
-  configureFlags = stdenv.lib.optionals stdenv.isDarwin [ "--disable-ssl" ];
-
   postPatch = ''
     patchShebangs .
   '';
diff --git a/pkgs/development/libraries/readline/6.3.nix b/pkgs/development/libraries/readline/6.3.nix
index 1183f46b8db7..75c25e12d667 100644
--- a/pkgs/development/libraries/readline/6.3.nix
+++ b/pkgs/development/libraries/readline/6.3.nix
@@ -16,6 +16,12 @@ stdenv.mkDerivation rec {
 
   patchFlags = "-p0";
 
+  configureFlags =
+    stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform)
+    [ # This test requires running host code
+      "bash_cv_wcwidth_broken=no"
+    ];
+
   patches =
     [ ./link-against-ncurses.patch
       ./no-arch_only-6.3.patch
diff --git a/pkgs/development/libraries/readosm/default.nix b/pkgs/development/libraries/readosm/default.nix
index cabd89dc9350..7faee7e69a2e 100644
--- a/pkgs/development/libraries/readosm/default.nix
+++ b/pkgs/development/libraries/readosm/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, expat, zlib, geos, libspatialite }:
 
 stdenv.mkDerivation rec {
-  name = "readosm-1.0.0b";
+  name = "readosm-1.1.0";
 
   src = fetchurl {
     url = "http://www.gaia-gis.it/gaia-sins/readosm-sources/${name}.tar.gz";
-    sha256 = "042pv31smc7l6y111rvp0hza5sw86wa8ldg2jyq78xgwzcbhszpd";
+    sha256 = "1v20pnda67imjd70fn0zw30aar525xicy3d3v49md5cvqklws265";
   };
 
   buildInputs = [ expat zlib geos libspatialite ];
diff --git a/pkgs/development/libraries/rep-gtk/setup-hook.sh b/pkgs/development/libraries/rep-gtk/setup-hook.sh
index 420d63d6c513..4d875b693304 100644
--- a/pkgs/development/libraries/rep-gtk/setup-hook.sh
+++ b/pkgs/development/libraries/rep-gtk/setup-hook.sh
@@ -2,4 +2,4 @@ addRepDLLoadPath () {
     addToSearchPath REP_DL_LOAD_PATH $1/lib/rep
 }
 
-envHooks+=(addRepDLLoadPath)
+addEnvHooks "$hostOffset" addRepDLLoadPath
diff --git a/pkgs/development/libraries/resolv_wrapper/default.nix b/pkgs/development/libraries/resolv_wrapper/default.nix
index 4ec06d68a329..fff1d6498361 100644
--- a/pkgs/development/libraries/resolv_wrapper/default.nix
+++ b/pkgs/development/libraries/resolv_wrapper/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, cmake, pkgconfig }:
 
 stdenv.mkDerivation rec {
-  name = "resolv_wrapper-1.1.3";
+  name = "resolv_wrapper-1.1.5";
 
   src = fetchurl {
     url = "mirror://samba/cwrap/${name}.tar.gz";
-    sha256 = "1h76155pnmd3pqxfyi00q0fg6v45ad9dhnjsqcsbzg18s626wyad";
+    sha256 = "0v5hw5ipq2rrpraf4ck4r9w9xihmgwzkpf5wgppz7gc52fmgv2g9";
   };
 
   nativeBuildInputs = [ cmake pkgconfig ];
diff --git a/pkgs/development/libraries/rocksdb/default.nix b/pkgs/development/libraries/rocksdb/default.nix
index a791c8994856..bb0faf76be69 100644
--- a/pkgs/development/libraries/rocksdb/default.nix
+++ b/pkgs/development/libraries/rocksdb/default.nix
@@ -1,4 +1,7 @@
-{ stdenv, fetchFromGitHub, fixDarwinDylibNames
+{ stdenv
+, fetchFromGitHub
+, fixDarwinDylibNames
+, which, perl
 
 # Optional Arguments
 , snappy ? null, google-gflags ? null, zlib ? null, bzip2 ? null, lz4 ? null
@@ -12,18 +15,22 @@
 
 let
   malloc = if jemalloc != null then jemalloc else gperftools;
+  tools = [ "sst_dump" "ldb" "rocksdb_dump" "rocksdb_undump" "blob_dump" ];
 in
 stdenv.mkDerivation rec {
   name = "rocksdb-${version}";
-  version = "5.1.2";
+  version = "5.10.3";
+
+  outputs = [ "dev" "out" "static" "bin" ];
 
   src = fetchFromGitHub {
     owner = "facebook";
     repo = "rocksdb";
     rev = "v${version}";
-    sha256 = "1smahz67gcd86nkdqaml78lci89dza131mlj5472r4sxjdxsx277";
+    sha256 = "19d8i8map8qz639mhflmxc0w9gp78fvkq1l46y5s6b5imwh0w7xq";
   };
 
+  nativeBuildInputs = [ which perl ];
   buildInputs = [ snappy google-gflags zlib bzip2 lz4 malloc fixDarwinDylibNames ];
 
   postPatch = ''
@@ -37,18 +44,22 @@ stdenv.mkDerivation rec {
   CMAKE_CXX_FLAGS = "-std=gnu++11";
   JEMALLOC_LIB = stdenv.lib.optionalString (malloc == jemalloc) "-ljemalloc";
 
-  ${if enableLite then "LIBNAME" else null} = "librocksdb_lite";
+  LIBNAME = "librocksdb${stdenv.lib.optionalString enableLite "_lite"}";
   ${if enableLite then "CXXFLAGS" else null} = "-DROCKSDB_LITE=1";
 
-  buildFlags = [
+  buildAndInstallFlags = [
+    "USE_RTTI=1"
     "DEBUG_LEVEL=0"
+    "DISABLE_WARNING_AS_ERROR=1"
+  ];
+
+  buildFlags = buildAndInstallFlags ++ [
     "shared_lib"
     "static_lib"
-  ];
+  ] ++ tools ;
 
-  installFlags = [
+  installFlags = buildAndInstallFlags ++ [
     "INSTALL_PATH=\${out}"
-    "DEBUG_LEVEL=0"
     "install-shared"
     "install-static"
   ];
@@ -57,6 +68,11 @@ stdenv.mkDerivation rec {
     # Might eventually remove this when we are confident in the build process
     echo "BUILD CONFIGURATION FOR SANITY CHECKING"
     cat make_config.mk
+    mkdir -pv $static/lib/
+    mv -vi $out/lib/${LIBNAME}.a $static/lib/
+
+    install -d ''${!outputBin}/bin
+    install -D ${stdenv.lib.concatStringsSep " " tools} ''${!outputBin}/bin
   '';
 
   enableParallelBuilding = true;
@@ -65,7 +81,7 @@ stdenv.mkDerivation rec {
     homepage = http://rocksdb.org;
     description = "A library that provides an embeddable, persistent key-value store for fast storage";
     license = licenses.bsd3;
-    platforms = platforms.allBut [ "i686-linux" ];
-    maintainers = with maintainers; [ wkennington ];
+    platforms = platforms.x86_64;
+    maintainers = with maintainers; [ adev wkennington ];
   };
 }
diff --git a/pkgs/development/libraries/rote/default.nix b/pkgs/development/libraries/rote/default.nix
index 524afd7cf4d2..195db9a16858 100644
--- a/pkgs/development/libraries/rote/default.nix
+++ b/pkgs/development/libraries/rote/default.nix
@@ -26,6 +26,5 @@ stdenv.mkDerivation rec {
     homepage = http://rote.sourceforge.net/;
     license = licenses.lgpl21;
     platforms = platforms.linux;
-    maintainers = with maintainers; [ nckx ];
   };
 }
diff --git a/pkgs/development/libraries/safefile/default.nix b/pkgs/development/libraries/safefile/default.nix
index 5cef2576b711..159bad4c68ea 100644
--- a/pkgs/development/libraries/safefile/default.nix
+++ b/pkgs/development/libraries/safefile/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl}:
+{ stdenv, fetchurl, path }:
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
   pname = "safefile";
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   passthru = {
     updateScript = ''
       cd ${toString ./.}
-      ${toString <nixpkgs/pkgs/build-support/upstream-updater/update-walker.sh>} default.nix
+      ${toString path}/pkgs/build-support/upstream-updater/update-walker.sh default.nix
     '';
   };
 
diff --git a/pkgs/development/libraries/sblim-sfcc/default.nix b/pkgs/development/libraries/sblim-sfcc/default.nix
index 111b08b633a7..ba0b8f4e996f 100644
--- a/pkgs/development/libraries/sblim-sfcc/default.nix
+++ b/pkgs/development/libraries/sblim-sfcc/default.nix
@@ -1,30 +1,28 @@
-{ fetchgit, stdenv, autoconf, automake, libtool, curl }:
+{ stdenv, fetchFromGitHub, autoreconfHook, curl }:
 
 stdenv.mkDerivation rec {
-  version = "2.2.9";
   name = "sblim-sfcc-${version}";
+  version = "2.2.9"; # this is technically 2.2.9-preview
 
-  src = fetchgit {
-    url = "https://github.com/kkaempf/sblim-sfcc.git";
-    rev = "f70fecb410a53531e4fe99d39cf81b581819cac9";
-    sha256 = "1hsxim284qzldh599gf6khxj80g8q5263xl3lj3hdndxbhbs843v";
+  src = fetchFromGitHub {
+    owner  = "kkaempf";
+    repo   = "sblim-sfcc";
+    rev    = "514a76af2020fd6dc6fc380df76cbe27786a76a2";
+    sha256 = "06c1mskl9ixbf26v88w0lvn6v2xd6n5f0jd5mckqrn9j4vmh70hs";
   };
 
-  preConfigure = "./autoconfiscate.sh";
+  buildInputs = [ curl ];
 
-  buildInputs = [ autoconf automake libtool curl ];
+  nativeBuildInputs = [ autoreconfHook ];
 
-  meta = {
-    description = "Small Footprint CIM Client Library";
-
-    homepage = http://sourceforge.net/projects/sblim/;
-
-    maintainers = [ stdenv.lib.maintainers.deepfire ];
-
-    license = stdenv.lib.licenses.cpl10;
-
-    platforms = stdenv.lib.platforms.gnu;  # arbitrary choice
+  enableParallelBuilding = true;
 
+  meta = with stdenv.lib; {
+    description = "Small Footprint CIM Client Library";
+    homepage    = https://sourceforge.net/projects/sblim/;
+    license     = licenses.cpl10;
+    maintainers = with maintainers; [ deepfire ];
+    platforms   = platforms.unix;
     inherit version;
   };
 }
diff --git a/pkgs/development/libraries/schroedinger/default.nix b/pkgs/development/libraries/schroedinger/default.nix
index d8e67baa13df..2309719c2bdc 100644
--- a/pkgs/development/libraries/schroedinger/default.nix
+++ b/pkgs/development/libraries/schroedinger/default.nix
@@ -22,6 +22,6 @@ stdenv.mkDerivation {
     homepage = http://diracvideo.org/;
     maintainers = [ maintainers.spwhitt ];
     license = [ licenses.mpl11 licenses.lgpl2 licenses.mit ];
-    platforms = platforms.unix;
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/science/biology/EBTKS/default.nix b/pkgs/development/libraries/science/biology/EBTKS/default.nix
new file mode 100644
index 000000000000..67f868a91a7b
--- /dev/null
+++ b/pkgs/development/libraries/science/biology/EBTKS/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchFromGitHub, cmake, libminc }:
+
+stdenv.mkDerivation rec {
+  pname = "EBTKS";
+  name  = "${pname}-2017-09-23";
+
+  src = fetchFromGitHub {
+    owner  = "BIC-MNI";
+    repo   = pname;
+    rev    = "67e4e197d8a32d6462c9bdc7af44d64ebde4fb5c";
+    sha256 = "1a1qw6i47fs1izx60l1ysabpmyx9j5sjnbdv8b47wi2xcc9i3hpq";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ libminc ];
+
+  cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib/" ];
+
+  checkPhase = "ctest --output-on-failure";  # but cmake doesn't run the tests ...
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/BIC-MNI/${pname}";
+    description = "Library for working with MINC files";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license   = licenses.free;
+  };
+}
diff --git a/pkgs/development/libraries/science/biology/bicpl/default.nix b/pkgs/development/libraries/science/biology/bicpl/default.nix
new file mode 100644
index 000000000000..d00a74f61e20
--- /dev/null
+++ b/pkgs/development/libraries/science/biology/bicpl/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchFromGitHub, cmake, libminc, netpbm }:
+
+stdenv.mkDerivation rec {
+  pname = "bicpl";
+  name  = "${pname}-2017-09-10";
+
+  owner = "BIC-MNI";
+
+  # current master is significantly ahead of most recent release, so use Git version:
+  src = fetchFromGitHub {
+    inherit owner;
+    repo   = pname;
+    rev    = "612a63e740fadb162fcf27ee00da6a18dec4d5a9";
+    sha256 = "1vv9gi184bkvp3f99v9xmmw1ly63ip5b09y7zdjn39g7kmwzrga7";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ libminc netpbm ];
+
+  cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib" "-DBUILD_TESTING=FALSE" ];
+
+  checkPhase = "ctest --output-on-failure";
+  doCheck = false;
+  # internal_volume_io.h: No such file or directory
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/${owner}/${pname}";
+    description = "Brain Imaging Centre programming library";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license   = licenses.free;
+  };
+}
diff --git a/pkgs/development/libraries/science/biology/elastix/default.nix b/pkgs/development/libraries/science/biology/elastix/default.nix
index 06550372ba8a..7b9e6b24d418 100644
--- a/pkgs/development/libraries/science/biology/elastix/default.nix
+++ b/pkgs/development/libraries/science/biology/elastix/default.nix
@@ -1,22 +1,18 @@
-{ stdenv, fetchFromGitHub, cmake, itk, python }:
+{ stdenv, fetchurl, cmake, itk, python }:
 
 stdenv.mkDerivation rec {
-  _name    = "elastix";
-  _version = "4.8";
-  name  = "${_name}-${_version}";
+  pname    = "elastix";
+  pversion = "4.9.0";
+  name  = "${pname}-${pversion}";
 
-  src = fetchFromGitHub {
-    owner  = "SuperElastix";
-    repo   = "elastix";
-    rev    = "ef057ff89233822b26b04b31c3c043af57d5deff";
-    sha256 = "0gm3a8dgqww50h6zld9ighjk92wlpybpimjwfz4s5h82vdjsvxrm";
+  src = fetchurl {
+    url    = "https://github.com/SuperElastix/${pname}/archive/${pversion}.tar.gz";
+    sha256 = "02pbln36nq98xxfyqwlxg7b6gmigdq4fgfqr9mym1qn58aj04shg";
   };
 
   nativeBuildInputs = [ cmake python ];
   buildInputs = [ itk ];
 
-  cmakeFlags = [ "-DUSE_KNNGraphAlphaMutualInformationMetric=OFF" ];
-
   checkPhase = "ctest";
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/science/biology/htslib/default.nix b/pkgs/development/libraries/science/biology/htslib/default.nix
index b3c6d9f26d47..2144a7f78935 100644
--- a/pkgs/development/libraries/science/biology/htslib/default.nix
+++ b/pkgs/development/libraries/science/biology/htslib/default.nix
@@ -3,11 +3,11 @@
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
   pname = "htslib";
-  version = "1.6";
+  version = "1.7";
 
   src = fetchurl {
     url = "https://github.com/samtools/htslib/releases/download/${version}/${name}.tar.bz2";
-    sha256 = "1jsca3hg4rbr6iqq6imkj4lsvgl8g9768bcmny3hlff2w25vx24m";
+    sha256 = "be3d4e25c256acdd41bebb8a7ad55e89bb18e2fc7fc336124b1e2c82ae8886c6";
   };
 
   # perl is only used during the check phase.
diff --git a/pkgs/development/libraries/science/biology/oobicpl/default.nix b/pkgs/development/libraries/science/biology/oobicpl/default.nix
new file mode 100644
index 000000000000..8755b7fd2eba
--- /dev/null
+++ b/pkgs/development/libraries/science/biology/oobicpl/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchFromGitHub, cmake, libminc, bicpl, arguments, pcre-cpp }:
+
+stdenv.mkDerivation rec {
+  pname = "oobicpl";
+  name  = "${pname}-2016-03-02";
+
+  owner = "BIC-MNI";
+
+  src = fetchFromGitHub {
+    inherit owner;
+    repo   = pname;
+    rev    = "bc062a65dead2e58461f5afb37abedfa6173f10c";
+    sha256 = "05l4ml9djw17bgdnrldhcxydrzkr2f2scqlyak52ph5azj5n4zsx";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ libminc bicpl arguments pcre-cpp ];
+
+  cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib"
+                 "-DBICPL_DIR=${bicpl}/lib"
+                 "-DARGUMENTS_DIR=${arguments}/lib"
+                 "-DOOBICPL_BUILD_SHARED_LIBS=TRUE" ];
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/${owner}/${pname}";
+    description = "Brain Imaging Centre object-oriented programming library (and tools)";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license   = licenses.free;
+  };
+}
diff --git a/pkgs/development/libraries/science/math/arpack/default.nix b/pkgs/development/libraries/science/math/arpack/default.nix
index fe90d41ccb29..77cb7cf1f2b6 100644
--- a/pkgs/development/libraries/science/math/arpack/default.nix
+++ b/pkgs/development/libraries/science/math/arpack/default.nix
@@ -4,22 +4,24 @@
 with stdenv.lib;
 
 let
-  version = "3.3.0";
+  version = "3.5.0";
 in
 stdenv.mkDerivation {
   name = "arpack-${version}";
 
   src = fetchurl {
     url = "https://github.com/opencollab/arpack-ng/archive/${version}.tar.gz";
-    sha256 = "1cz53wqzcf6czmcpfb3vb61xi0rn5bwhinczl65hpmbrglg82ndd";
+    sha256 = "0f8jx3fifmj9qdp289zr7r651y1q48k1jya859rqxq62mvis7xsh";
   };
 
   nativeBuildInputs = [ autoconf automake gettext libtool ];
   buildInputs = [ gfortran openblas ];
 
+  doCheck = true;
+
   BLAS_LIBS = "-L${openblas}/lib -lopenblas";
 
-  FFLAGS = optional openblas.blas64 "-fdefault-integer-8";
+  INTERFACE64 = optional openblas.blas64 "1";
 
   preConfigure = ''
     ./bootstrap
diff --git a/pkgs/development/libraries/science/math/atlas/default.nix b/pkgs/development/libraries/science/math/atlas/default.nix
index c6797ef05ac3..8cca5565bf6f 100644
--- a/pkgs/development/libraries/science/math/atlas/default.nix
+++ b/pkgs/development/libraries/science/math/atlas/default.nix
@@ -45,6 +45,8 @@
 
 let
   inherit (stdenv.lib) optional optionalString;
+  # Don't upgrade until https://github.com/math-atlas/math-atlas/issues/44
+  # is resolved.
   version = "3.10.2";
 in
 
@@ -100,6 +102,10 @@ stdenv.mkDerivation {
     fi
   '';
 
+  # 1. /buildATLAS/build/bin/ATLrun.sh: multiple segfaults.
+  # 2. "atlas does its own parallel builds"
+  enableParallelBuilding = false;
+
   meta = {
     homepage = http://math-atlas.sourceforge.net/;
     description = "Automatically Tuned Linear Algebra Software (ATLAS)";
diff --git a/pkgs/development/libraries/science/math/blas/default.nix b/pkgs/development/libraries/science/math/blas/default.nix
index 4455a9488c00..9955af046597 100644
--- a/pkgs/development/libraries/science/math/blas/default.nix
+++ b/pkgs/development/libraries/science/math/blas/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "blas-${version}";
-  version = "3.7.1";
+  version = "3.8.0";
 
   src = fetchurl {
     url = "http://www.netlib.org/blas/${name}.tgz";
-    sha256 = "1hvmwp488hd6sdxdbmhjhmyrrd4s1ds1cjzh5d86l10b3wsm99n5";
+    sha256 = "1s24iry5197pskml4iygasw196bdhplj0jmbsb9jhabcjqj2mpsm";
   };
 
   buildInputs = [ gfortran ];
diff --git a/pkgs/development/libraries/science/math/caffe2/default.nix b/pkgs/development/libraries/science/math/caffe2/default.nix
new file mode 100644
index 000000000000..916bf122b3c2
--- /dev/null
+++ b/pkgs/development/libraries/science/math/caffe2/default.nix
@@ -0,0 +1,144 @@
+{ stdenv, lib, config, fetchFromGitHub, fetchpatch
+, cmake
+, glog, google-gflags, gtest
+, protobuf, snappy
+, python, future, six, python-protobuf, numpy, pydot
+, eigen3
+, doxygen
+, useCuda ? (config.cudaSupport or false), cudatoolkit ? null
+, useCudnn ? (config.cudnnSupport or false), cudnn ? null
+, useOpenmp ? false, openmp ? null
+, useOpencv3 ? true, opencv3 ? null
+, useLeveldb ? false, leveldb ? null
+, useLmdb ? true, lmdb ? null
+, useRocksdb ? false, rocksdb ? null
+, useZeromq ? false, zeromq ? null
+, useMpi ? false, mpi ? null
+# TODO: distributed computations
+#, useGloo ? false
+#, useNccl ? false
+#, useNnpack ? false
+}:
+
+assert useCuda -> cudatoolkit != null;
+assert useCudnn -> (useCuda && cudnn != null);
+assert useOpencv3 -> opencv3 != null;
+assert useLeveldb -> leveldb != null;
+assert useLmdb -> lmdb != null;
+assert useRocksdb -> rocksdb != null;
+assert useZeromq -> zeromq != null;
+assert useMpi -> mpi != null;
+
+let
+  # Third party modules that caffe2 holds as git submodules.
+  # Download them and create symlinks from caffe2/third_party.
+  installExtraSrc = extra: ''
+    rmdir "third_party/${extra.dst}"
+    ln -s "${extra.src}" "third_party/${extra.dst}"
+  '';
+
+  cub = {
+    src = fetchFromGitHub rec {
+      owner  = "NVlabs";
+      repo   = "cub";
+      rev    = "v1.7.4";
+      sha256 = "0ksd5n1lxqhm5l5cd2lps4cszhjkf6gmzahaycs7nxb06qci8c66";
+    };
+    dst = "cub";
+  };
+
+  pybind11 = {
+    src = fetchFromGitHub {
+      owner  = "pybind";
+      repo   = "pybind11";
+      rev    = "86e2ad4f77442c3350f9a2476650da6bee253c52";
+      sha256 = "05gi58dirvc8fgm0avpydvidzsbh2zrzgfaq671ym09f6dz0bcgz";
+    };
+    dst = "pybind11";
+  };
+
+  ccVersion = (builtins.parseDrvName stdenv.cc.name).version;
+in
+
+stdenv.mkDerivation rec {
+  name = "caffe2-${version}";
+  version = "0.8.1";
+  src = fetchFromGitHub {
+    owner = "caffe2";
+    repo = "caffe2";
+    rev = "v${version}";
+    sha256 = "18y7zjc69j6n5642l9caddl641b0djf3pjn4wacdsc1wk1jiyqk8";
+  };
+
+  nativeBuildInputs = [ cmake doxygen gtest ];
+  outputs = [ "bin" "out" ];
+  propagatedBuildOutputs = [ ]; # otherwise propagates out -> bin cycle
+
+  buildInputs = [ glog google-gflags protobuf snappy eigen3 ]
+    ++ lib.optional useCuda cudatoolkit
+    ++ lib.optional useCudnn cudnn
+    ++ lib.optional useOpenmp openmp
+    ++ lib.optional useOpencv3 opencv3
+    ++ lib.optional useLeveldb leveldb
+    ++ lib.optional useLmdb lmdb
+    ++ lib.optional useRocksdb rocksdb
+    ++ lib.optional useZeromq zeromq
+  ;
+  propagatedBuildInputs = [ numpy future six python-protobuf pydot ];
+
+  patches = lib.optional (stdenv.cc.isGNU && lib.versionAtLeast ccVersion "7.0.0") [
+    ./fix_compilation_on_gcc7.patch
+  ] ++ lib.optional stdenv.cc.isClang [ ./update_clang_cvtsh_bugfix.patch ];
+
+  cmakeFlags = [ ''-DBUILD_TEST=OFF''
+                 ''-DBUILD_PYTHON=ON''
+                 ''-DUSE_CUDA=${if useCuda then ''ON''else ''OFF''}''
+                 ''-DUSE_OPENMP=${if useOpenmp then ''ON''else ''OFF''}''
+                 ''-DUSE_OPENCV=${if useOpencv3 then ''ON''else ''OFF''}''
+                 ''-DUSE_MPI=${if useMpi then ''ON''else ''OFF''}''
+                 ''-DUSE_LEVELDB=${if useLeveldb then ''ON''else ''OFF''}''
+                 ''-DUSE_LMDB=${if useLmdb then ''ON''else ''OFF''}''
+                 ''-DUSE_ROCKSDB=${if useRocksdb then ''ON''else ''OFF''}''
+                 ''-DUSE_ZMQ=${if useZeromq  then ''ON''else ''OFF''}''
+                 ''-DUSE_GLOO=OFF''
+                 ''-DUSE_NNPACK=OFF''
+                 ''-DUSE_NCCL=OFF''
+                 ''-DUSE_REDIS=OFF''
+                 ''-DUSE_FFMPEG=OFF''
+               ]
+               ++ lib.optional useCuda [
+                 ''-DCUDA_TOOLKIT_ROOT_DIR=${cudatoolkit}''
+                 ''-DCUDA_FAST_MATH=ON''
+                 ''-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/gcc''
+               ];
+
+  preConfigure = ''
+    ${installExtraSrc cub}
+    ${installExtraSrc pybind11}
+    # XXX hack
+    export NIX_CFLAGS_COMPILE="-I ${eigen3}/include/eigen3/ $NIX_CFLAGS_COMPILE"
+  '';
+
+  postInstall = ''
+    moveToOutput "bin" "$bin"
+    mkdir -p $out/lib/${python.libPrefix}
+    ln -s $out/ $out/${python.sitePackages}
+  '';
+
+  doCheck = false;
+  enableParallelBuilding = true;
+
+  meta = {
+    homepage = https://caffe2.ai/;
+    description = "A new lightweight, modular, and scalable deep learning framework";
+    longDescription = ''
+      Caffe2 aims to provide an easy and straightforward way for you to experiment
+      with deep learning and leverage community contributions of new models and
+      algorithms. You can bring your creations to scale using the power of GPUs in the
+      cloud or to the masses on mobile with Caffe2's cross-platform libraries.
+    '';
+    platforms = with stdenv.lib.platforms; linux;
+    license = stdenv.lib.licenses.asl20;
+    maintainers = with stdenv.lib.maintainers; [ yuriaisaka ];
+  };
+}
diff --git a/pkgs/development/libraries/science/math/caffe2/fix_compilation_on_gcc7.patch b/pkgs/development/libraries/science/math/caffe2/fix_compilation_on_gcc7.patch
new file mode 100644
index 000000000000..f319f20233a2
--- /dev/null
+++ b/pkgs/development/libraries/science/math/caffe2/fix_compilation_on_gcc7.patch
@@ -0,0 +1,46 @@
+diff --git a/caffe2/operators/recurrent_network_op.cc b/caffe2/operators/recurrent_network_op.cc
+index dd4fded..5995e8a 100644
+--- a/caffe2/operators/recurrent_network_op.cc
++++ b/caffe2/operators/recurrent_network_op.cc
+@@ -1,4 +1,4 @@
+-#include "recurrent_network_op.h"
++#include "caffe2/operators/recurrent_network_op.h"
+ #include "caffe2/core/workspace.h"
+ 
+ namespace caffe2 {
+diff --git a/caffe2/operators/recurrent_network_op.h b/caffe2/operators/recurrent_network_op.h
+index 55328e5..ea898bc 100644
+--- a/caffe2/operators/recurrent_network_op.h
++++ b/caffe2/operators/recurrent_network_op.h
+@@ -762,8 +762,8 @@ class AccumulateInputGradientOp : public Operator<Context> {
+   USE_OPERATOR_CONTEXT_FUNCTIONS;
+ 
+   bool RunOnDevice() override {
+-    const auto t =
+-        OperatorBase::Input<Tensor<CPUContext>>(0).template data<int32_t>()[0];
++    const auto& t0 = OperatorBase::Input<Tensor<CPUContext>>(0);
++    const auto t = t0.template data<int32_t>()[0];
+     auto& og = Input(1);
+     auto* g = Output(0);
+ 
+diff --git a/caffe2/queue/queue_ops.h b/caffe2/queue/queue_ops.h
+index f2c0a33..642343f 100644
+--- a/caffe2/queue/queue_ops.h
++++ b/caffe2/queue/queue_ops.h
+@@ -17,13 +17,10 @@ class CreateBlobsQueueOp final : public Operator<Context> {
+         name(operator_def.output().Get(0)) {}
+ 
+   bool RunOnDevice() override {
+-    const auto capacity =
+-        OperatorBase::template GetSingleArgument<int>("capacity", 1);
+-    const auto numBlobs =
+-        OperatorBase::template GetSingleArgument<int>("num_blobs", 1);
++    const auto capacity = GetSingleArgument("capacity", 1);
++    const auto numBlobs = GetSingleArgument("num_blobs", 1);
+     const auto enforceUniqueName =
+-        OperatorBase::template GetSingleArgument<int>(
+-            "enforce_unique_name", false);
++        GetSingleArgument("enforce_unique_name", false);
+     const auto fieldNames =
+         OperatorBase::template GetRepeatedArgument<std::string>("field_names");
+     CAFFE_ENFORCE_EQ(this->OutputSize(), 1);
diff --git a/pkgs/development/libraries/science/math/caffe2/update_clang_cvtsh_bugfix.patch b/pkgs/development/libraries/science/math/caffe2/update_clang_cvtsh_bugfix.patch
new file mode 100644
index 000000000000..d908cb6ba80b
--- /dev/null
+++ b/pkgs/development/libraries/science/math/caffe2/update_clang_cvtsh_bugfix.patch
@@ -0,0 +1,55 @@
+diff --git a/caffe2/perfkernels/cvtsh_ss_bugfix.h b/caffe2/perfkernels/cvtsh_ss_bugfix.h
+index bd06681..00172b7 100644
+--- a/caffe2/perfkernels/cvtsh_ss_bugfix.h
++++ b/caffe2/perfkernels/cvtsh_ss_bugfix.h
+@@ -1,10 +1,36 @@
++/**
++ * Copyright (c) 2016-present, Facebook, Inc.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ *     http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
+ #pragma once
+ 
+-#if defined(__APPLE__) && (__clang_major__ < 8)
++// Apple clang was fixed in 8.1
++#if defined(__apple_build_version__) && ((__clang_major__ < 8) || ((__clang_major__ == 8) && (__clang_minor__ < 1)))
++#define __APPLE_NEED_FIX 1
++#endif
++
++// Regular clang was fixed in 3.9
++#if defined(__clang__) && (__clang_major__ < 4) && (__clang_minor__ < 9)
++#define __CLANG_NEED_FIX 1
++#endif
++
++#if __APPLE_NEED_FIX || __CLANG_NEED_FIX
+ 
+ #include <emmintrin.h>
+ 
+-// This version of apple clang has a bug that _cvtsh_ss is not defined, see
++// This version of clang has a bug that _cvtsh_ss is not defined, see
+ // https://reviews.llvm.org/D16177
+ static __inline float
+     __attribute__((__always_inline__, __nodebug__, __target__("f16c")))
+@@ -15,7 +41,10 @@ _cvtsh_ss(unsigned short a)
+   return r[0];
+ }
+ 
+-#endif // defined(__APPLE__) && (__clang_major__ < 8)
++#endif // __APPLE_NEED_FIX || __CLANG_NEED_FIX
++
++#undef __APPLE_NEED_FIX
++#undef __CLANG_NEED_FIX
+ 
+ #ifdef _MSC_VER
+ 
diff --git a/pkgs/development/libraries/science/math/clblas/default.nix b/pkgs/development/libraries/science/math/clblas/default.nix
index 40b02d303417..7a653a58eb2a 100644
--- a/pkgs/development/libraries/science/math/clblas/default.nix
+++ b/pkgs/development/libraries/science/math/clblas/default.nix
@@ -7,6 +7,7 @@
 , python
 , ocl-icd
 , opencl-headers
+, Accelerate, CoreGraphics, CoreVideo, OpenCL
 , gtest
 }:
 
@@ -40,11 +41,19 @@ stdenv.mkDerivation rec {
     gfortran
     blas
     python
-    ocl-icd
-    opencl-headers
     boost
     gtest
-  ]; 
+  ] ++ stdenv.lib.optionals (!stdenv.isDarwin) [
+    ocl-icd
+    opencl-headers
+  ] ++ stdenv.lib.optionals stdenv.isDarwin [
+    Accelerate
+    CoreGraphics
+    CoreVideo
+  ];
+  propagatedBuildInputs = stdenv.lib.optionals stdenv.isDarwin [
+    OpenCL
+  ];
 
   enableParallelBuilding = true;
 
@@ -56,7 +65,7 @@ stdenv.mkDerivation rec {
     '';
     license = licenses.asl20;
     maintainers = with maintainers; [ artuuge ];
-    platforms = platforms.linux;
+    platforms = platforms.unix;
   };
 
 }
diff --git a/pkgs/development/libraries/science/math/cliquer/default.nix b/pkgs/development/libraries/science/math/cliquer/default.nix
new file mode 100644
index 000000000000..2441aff9fa30
--- /dev/null
+++ b/pkgs/development/libraries/science/math/cliquer/default.nix
@@ -0,0 +1,38 @@
+{ stdenv
+, fetchFromGitHub
+, autoreconfHook
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.21";
+  name = "cliquer-${version}";
+
+  # autotoolized version of the original cliquer
+  src = fetchFromGitHub {
+    owner = "dimpase";
+    repo = "autocliquer";
+    rev = "v${version}";
+    sha256 = "180i4qj1a25qfp75ig2d3144xfpb1dgcgpha0iqqghd7di4awg7z";
+  };
+
+  doCheck = true;
+
+  buildInputs = [
+    autoreconfHook
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://users.aalto.fi/~pat/cliquer.html;
+    downloadPage = src.meta.homepage; # autocliquer
+    description = "Routines for clique searching";
+    longDescription = ''
+      Cliquer is a set of C routines for finding cliques in an arbitrary weighted graph.
+      It uses an exact branch-and-bound algorithm developed by Patric Östergård.
+      It is designed with the aim of being efficient while still being flexible and
+      easy to use.
+    '';
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/science/math/cudnn/default.nix b/pkgs/development/libraries/science/math/cudnn/default.nix
index 574899d3a89c..f5715157531e 100644
--- a/pkgs/development/libraries/science/math/cudnn/default.nix
+++ b/pkgs/development/libraries/science/math/cudnn/default.nix
@@ -30,16 +30,16 @@ in
   };
 
   cudnn_cudatoolkit8 = generic rec {
-    version = "7.0.3";
+    version = "7.0.5";
     cudatoolkit = cudatoolkit8;
     srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v7.tgz";
-    sha256 = "0gzwadxcyirr2zgiikdapnm860x3gcfwfxh5xn3s47zaa03x4kg4";
+    sha256 = "9e0b31735918fe33a79c4b3e612143d33f48f61c095a3b993023cdab46f6d66e";
   };
 
   cudnn_cudatoolkit9 = generic rec {
-    version = "7.0.3";
+    version = "7.0.5";
     cudatoolkit = cudatoolkit9;
     srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v7.tgz";
-    sha256 = "1ycy413cq9y9yxj20djqv05aarn3qzcy2md3dvvjpvhc269kwn09";
+    sha256 = "1rfmdd2v47p83fm3sfyvik31gci0q17qs6kjng6mvcsd6akmvb8y";
   };
 }
diff --git a/pkgs/development/libraries/science/math/cudnn/generic.nix b/pkgs/development/libraries/science/math/cudnn/generic.nix
index 663b741e4748..51bda19cf139 100644
--- a/pkgs/development/libraries/science/math/cudnn/generic.nix
+++ b/pkgs/development/libraries/science/math/cudnn/generic.nix
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
       This nix expression requires that ${name} is already part of the store.
       Register yourself to NVIDIA Accelerated Computing Developer Program, retrieve the cuDNN library
       at https://developer.nvidia.com/cudnn, and run the following command in the download directory:
-      nix-prefetch-url file://${name}
+      nix-prefetch-url file://\$PWD/${name}
     '';
   };
 
diff --git a/pkgs/development/libraries/science/math/fenics/default.nix b/pkgs/development/libraries/science/math/fenics/default.nix
index 9d40baafe65a..1825a6f1bb25 100644
--- a/pkgs/development/libraries/science/math/fenics/default.nix
+++ b/pkgs/development/libraries/science/math/fenics/default.nix
@@ -158,7 +158,7 @@ stdenv.mkDerivation {
   meta = {
     description = "The FEniCS Problem Solving Environment in Python and C++";
     homepage = http://fenicsproject.org/;
-    platforms = stdenv.lib.platforms.all;
+    platforms = stdenv.lib.platforms.darwin;
     license = stdenv.lib.licenses.lgpl3;
   };
 }
diff --git a/pkgs/development/libraries/science/math/flintqs/default.nix b/pkgs/development/libraries/science/math/flintqs/default.nix
new file mode 100644
index 000000000000..2891429c8578
--- /dev/null
+++ b/pkgs/development/libraries/science/math/flintqs/default.nix
@@ -0,0 +1,40 @@
+{ stdenv
+, fetchFromGitHub
+, autoreconfHook
+, gmp
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.0";
+  pname = "flintqs";
+  name = "${pname}-${version}";
+
+  src = fetchFromGitHub {
+    owner = "sagemath";
+    repo = "FlintQS";
+    rev = "v${version}";
+    sha256 = "1f0lnayz6j6qgasx8pbq61d2fqam0wwhsmh6h15l4vq58l1vvbwj";
+  };
+
+  preAutoreconf = ''
+    touch ChangeLog
+  '';
+
+  buildInputs = [
+    gmp
+  ];
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/sagemath/FlintQS;
+    description = "Highly optimized multi-polynomial quadratic sieve for integer factorization";
+    license = with licenses; [ gpl2 ];
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/science/math/ipopt/default.nix b/pkgs/development/libraries/science/math/ipopt/default.nix
index 567ee7853f88..f694f72f22b6 100644
--- a/pkgs/development/libraries/science/math/ipopt/default.nix
+++ b/pkgs/development/libraries/science/math/ipopt/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "ipopt-${version}";
-  version = "3.12.8";
+  version = "3.12.9";
 
   src = fetchurl {
     url = "http://www.coin-or.org/download/source/Ipopt/Ipopt-${version}.zip";
-    sha256 = "1lyhgashyk2wswv0z2qnkxng32pim80kzf9jfgxi07wl09x753w1";
+    sha256 = "1fqdjgxh6l1xjvw1ffma7lg92xqg0l8sj02y0zqvbfnx8i47qs9a";
   };
 
   CXXDEFS = [ "-DHAVE_RAND" "-DHAVE_CSTRING" "-DHAVE_CSTDIO" ];
diff --git a/pkgs/development/libraries/science/math/lcalc/default.nix b/pkgs/development/libraries/science/math/lcalc/default.nix
new file mode 100644
index 000000000000..90393cff001c
--- /dev/null
+++ b/pkgs/development/libraries/science/math/lcalc/default.nix
@@ -0,0 +1,78 @@
+{ stdenv
+, fetchurl
+, fetchpatch
+, pari
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.23";
+  pname = "lcalc";
+  name = "${pname}-${version}";
+
+  src = fetchurl {
+    # original at http://oto.math.uwaterloo.ca/~mrubinst/L_function_public/CODE/L-${version}.tar.gz, no longer available
+    # "newer" version at google code https://code.google.com/archive/p/l-calc/source/default/source
+    url = "http://mirrors.mit.edu/sage/spkg/upstream/lcalc/lcalc-${version}.tar.bz2";
+    sha256 = "1c6dsdshgxhqppjxvxhp8yhpxaqvnz3d1mlh26r571gkq8z2bm43";
+  };
+
+  preConfigure = "cd src";
+
+  buildInputs = [
+    pari
+  ];
+
+  patches = [
+    # Port to newer pari
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/lcalc/patches/pari-2.7.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "1x3aslldm8njjm7p9g9s9w2c91kphnci2vpkxkrcxfihw3ayss6c";
+    })
+
+    # Uncomment the definition of lcalc_to_double(const long double& x).
+    # (Necessary for GCC >= 4.6.0, cf. https://trac.sagemath.org/ticket/10892)
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/lcalc/patches/Lcommon.h.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "0g4ybvsrcv48rmlh1xjnkms19jp25k58azv6ds1f2cm34hxs8fdx";
+    })
+
+    # Include also <time.h> in Lcommandline_numbertheory.h (at least required
+    # on Cygwin, cf. https://trac.sagemath.org/ticket/9845)
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/lcalc/patches/time.h.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "1brf04n11kkc43ylagf8dm32j5r2g9zv51dp5wag1mpm4p04l7cl";
+    })
+
+    # Fix for gcc >4.6
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/lcalc/patches/lcalc-1.23_default_parameters_1.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "0i2yvxm5fx4z0v6m4srgh8rj98kijmlvyirlxf1ky0bp2si6bpka";
+    })
+
+    # gcc 5.1
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/lcalc/patches/lcalc-1.23_default_parameters_2.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "0dqwmxpm9wb53qbypsyfkgsvk2f8nf67sydphd4dkc2vw4yz6vlh";
+    })
+
+    # based on gentoos makefile patch -- fix paths, adhere to flags
+    ./makefile.patch
+  ];
+
+  installFlags = [
+    "DESTDIR=$(out)"
+  ];
+
+  makeFlags = [
+    "PARI_DEFINE=-DINCLUDE_PARI"
+    "PARI_PREFIX=${pari}"
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = http://oto.math.uwaterloo.ca/~mrubinst/L_function_public/L.html;
+    description = "A program for calculating with L-functions";
+    license = with licenses; [ gpl2 ];
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/science/math/lcalc/makefile.patch b/pkgs/development/libraries/science/math/lcalc/makefile.patch
new file mode 100644
index 000000000000..f55bbe3f24fa
--- /dev/null
+++ b/pkgs/development/libraries/science/math/lcalc/makefile.patch
@@ -0,0 +1,113 @@
+diff --git a/src/Makefile b/src/Makefile
+index 84e4e88..56ca676 100644
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -58,7 +58,7 @@ ifeq ($(G5),TRUE)
+    #MACHINE_SPECIFIC_FLAGS = -mpowerpc -mpowerpc64 -m64
+ endif
+ 
+-CCFLAGS =  -Wa,-W -O3 $(OPENMP_FLAG) -Wno-deprecated $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS) $(EXTRA)
++CCFLAGS = $(CXXFLAGS) $(OPENMP_FLAG) $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS)
+ #CCFLAGS =  -Wa,-W -O3 $(OPENMP_FLAG)  $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS) $(EXTRA)
+ #CCFLAGS =  -Wa,-W -O2 -fno-exceptions -Wno-deprecated $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS) $(EXTRA)
+ 
+@@ -68,12 +68,12 @@ CCFLAGS =  -Wa,-W -O3 $(OPENMP_FLAG) -Wno-deprecated $(PREPROCESSOR_DEFINE) $(MA
+ 
+ ifeq ($(PARI_DEFINE),-DINCLUDE_PARI)
+     #location of pari.h.
+-    LOCATION_PARI_H = /usr/local/include/pari #usual location
++    LOCATION_PARI_H = $(PARI_PREFIX)/include/pari #usual location
+ 
+     #location of libpari.a or of libpari.so
+     #depending on whether static or dynamic libraries are being used.
+     #On mac os x it's the former, on linux I think usually the latter.
+-    LOCATION_PARI_LIBRARY = /usr/local/lib #usual location
++    LOCATION_PARI_LIBRARY = $(PARI_PREFIX)/lib #usual location
+ else
+     #supplied as a dummy so as to avoid more ifeq's below
+     LOCATION_PARI_H = .
+@@ -89,24 +89,24 @@ INCLUDEFILES= -I../include
+ 
+ ifeq ($(OS_NAME),Darwin)
+     LDFLAGS2 =
+-    DYN_OPTION=dynamiclib
++    DYN_OPTION=-dynamiclib
+ else
+-    LDFLAGS1 = -Xlinker -export-dynamic #not sure why pari calls these when linking but on the web I found
++    LDFLAGS1 = #not sure why pari calls these when linking but on the web I found
+     #'Libtool provides the `-export-dynamic' link flag (see section Link mode), which does this declaration.
+     #You need to use this flag if you are linking a shared library that will be dlopened'
+     #see notes below
+     #ifeq ($(PARI_DEFINE),-DINCLUDE_PARI)
+-       LDFLAGS2 = $(LDFLAGS1) -Xlinker -rpath -Xlinker $(LOCATION_PARI_LIBRARY)
++       LDFLAGS2 = $(LDFLAGS)
+     #else
+     #    LDFLAGS2 = $(LDFLAGS1)
+     #endif
+-    DYN_OPTION=shared
++    DYN_OPTION=$(LDFLAGS) -shared -Wl,-soname,libLfunction.so
+ endif
+ 
+ ifeq ($(PARI_DEFINE),-DINCLUDE_PARI)
+-    LDFLAGS = $(LDFLAGS2) -L$(LOCATION_PARI_LIBRARY) -lpari
++    MYLDFLAGS = $(LDFLAGS2) -L$(LOCATION_PARI_LIBRARY) -lpari
+ else
+-    LDFLAGS = $(LDFLAGS2)
++    MYLDFLAGS = $(LDFLAGS2)
+ endif
+ 
+ 
+@@ -129,7 +129,8 @@ endif
+ #become clear which libraries the computer can find.
+ 
+ 
+-INSTALL_DIR= /usr/local
++INSTALL_DIR= $(DESTDIR)
++LIB_DIR ?=lib
+ 
+ #object files for the libLfunction library
+ OBJ_L = Lglobals.o Lgamma.o Lriemannsiegel.o Lriemannsiegel_blfi.o Ldokchitser.o
+@@ -141,9 +142,8 @@ OBJECTS = $(OBJ3)
+ 
+ all:
+ #	make print_vars
+-	make libLfunction.so
+-	make lcalc
+-	make examples
++	${MAKE} libLfunction.so
++	${MAKE} lcalc
+ #	make find_L
+ #	make test
+ 
+@@ -151,7 +151,7 @@ print_vars:
+ 	@echo OS_NAME = $(OS_NAME)
+ 
+ lcalc: $(OBJECTS)
+-	$(CC) $(CCFLAGS) $(INCLUDEFILES) $(OBJECTS) $(LDFLAGS) -o lcalc $(GMP_FLAGS)
++	$(CC) $(CCFLAGS) $(INCLUDEFILES) $(OBJECTS) $(MYLDFLAGS) -o lcalc $(GMP_FLAGS)
+ 
+ examples:
+ 	$(CC) $(CCFLAGS) $(INCLUDEFILES) example_programs/example.cc libLfunction.so -o example_programs/example $(GMP_FLAGS)
+@@ -262,15 +262,18 @@ Lcommandline.o: ../include/Lcommandline_values_zeros.h
+ 
+ 
+ libLfunction.so: $(OBJ_L)
+-	g++ -$(DYN_OPTION)  -o libLfunction.so $(OBJ_L)
++	g++ $(DYN_OPTION) -o libLfunction.so $(OBJ_L)
+ 
+ clean:
+ 	rm -f *.o lcalc libLfunction.so example_programs/example
+ 
+ install:
+-	cp -f lcalc $(INSTALL_DIR)/bin/.
+-	cp -f libLfunction.so $(INSTALL_DIR)/lib/.
+-	cp -rf ../include $(INSTALL_DIR)/include/Lfunction
++	install -d $(INSTALL_DIR)/bin
++	install -d $(INSTALL_DIR)/$(LIB_DIR)
++	install -d $(INSTALL_DIR)/include/libLfunction
++	install lcalc $(INSTALL_DIR)/bin
++	install libLfunction.so $(INSTALL_DIR)/$(LIB_DIR)
++	install -m 644 -t $(INSTALL_DIR)/include/libLfunction ../include/*.h
+ 
+ 
+ SRCS = Lcommandline.cc Lcommandline_elliptic.cc Lcommandline_globals.cc Lcommandline_misc.cc Lcommandline_numbertheory.cc Lcommandline_twist.cc Lcommandline_values_zeros.cc Lgamma.cc Lglobals.cc Lmisc.cc Lriemannsiegel.cc Lriemannsiegel_blfi.cc cmdline.c
diff --git a/pkgs/development/libraries/science/math/m4ri/default.nix b/pkgs/development/libraries/science/math/m4ri/default.nix
new file mode 100644
index 000000000000..b9ee1e2a10d7
--- /dev/null
+++ b/pkgs/development/libraries/science/math/m4ri/default.nix
@@ -0,0 +1,30 @@
+{ stdenv
+, fetchFromBitbucket
+, autoreconfHook
+}:
+
+stdenv.mkDerivation rec {
+  version = "20140914";
+  name = "m4ri-${version}";
+
+  src = fetchFromBitbucket {
+    owner = "malb";
+    repo = "m4ri";
+    rev = "release-${version}";
+    sha256 = "0xfg6pffbn8r1s0y7bn9b8i55l00d41dkmhrpf7pwk53qa3achd3";
+  };
+
+  doCheck = true;
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://malb.bitbucket.io/m4ri/;
+    description = "Library to do fast arithmetic with dense matrices over F_2";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/science/math/m4rie/default.nix b/pkgs/development/libraries/science/math/m4rie/default.nix
new file mode 100644
index 000000000000..23fc03655cf3
--- /dev/null
+++ b/pkgs/development/libraries/science/math/m4rie/default.nix
@@ -0,0 +1,39 @@
+{ stdenv
+, fetchFromBitbucket
+, autoreconfHook
+, m4ri
+}:
+
+stdenv.mkDerivation rec {
+  version = "20150908";
+  name = "m4rie-${version}";
+
+  src = fetchFromBitbucket {
+    owner = "malb";
+    repo = "m4rie";
+    rev = "release-${version}";
+    sha256 = "0r8lv46qx5mkz5kp3ay2jnsp0mbhlqr5z2z220wdk73wdshcznss";
+  };
+
+  doCheck = true;
+
+  buildInputs = [
+    m4ri
+  ];
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://malb.bitbucket.io/m4rie/;
+    description = "Library for matrix multiplication, reduction and inversion over GF(2^k) for 2 <= k <= 10";
+    longDescription = ''
+      M4RIE is a library for fast arithmetic with dense matrices over small finite fields of even characteristic.
+      It uses the M4RI library, implementing the same operations over the finite field F2.
+    '';
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/science/math/nccl/default.nix b/pkgs/development/libraries/science/math/nccl/default.nix
new file mode 100644
index 000000000000..1d692f6316ff
--- /dev/null
+++ b/pkgs/development/libraries/science/math/nccl/default.nix
@@ -0,0 +1,24 @@
+{ callPackage, cudatoolkit8, cudatoolkit9 }:
+
+let
+  generic = args: callPackage (import ./generic.nix (removeAttrs args ["cudatoolkit"])) {
+    inherit (args) cudatoolkit;
+  };
+
+in
+
+{
+  nccl_cudatoolkit8 = generic rec {
+    version = "2.1.4";
+    cudatoolkit = cudatoolkit8;
+    srcName = "nccl_${version}-1+cuda${cudatoolkit.majorVersion}_x86_64.txz";
+    sha256 = "1lwwm8kdhna5m318yg304kl2gsz1jwhv4zv4gn8av2m57zh848zi";
+  };
+
+  nccl_cudatoolkit9 = generic rec {
+    version = "2.1.4";
+    cudatoolkit = cudatoolkit9;
+    srcName = "nccl_${version}-1+cuda${cudatoolkit.majorVersion}_x86_64.txz";
+    sha256 = "0pajmqzkacpszs63jh2hw2qqc49kj75kcf7r0ky8hdh560q8xn0p";
+  };
+}
diff --git a/pkgs/development/libraries/science/math/nccl/generic.nix b/pkgs/development/libraries/science/math/nccl/generic.nix
new file mode 100644
index 000000000000..609a7df51e58
--- /dev/null
+++ b/pkgs/development/libraries/science/math/nccl/generic.nix
@@ -0,0 +1,57 @@
+{ version
+, srcName
+, sha256
+}:
+
+{ stdenv
+, lib
+, requireFile
+, cudatoolkit
+}:
+
+stdenv.mkDerivation rec {
+  name = "cudatoolkit-${cudatoolkit.majorVersion}-nccl-${version}";
+
+  inherit version;
+
+  src = requireFile rec {
+    name = srcName;
+    inherit sha256;
+    message = ''
+      This nix expression requires that ${name} is already part of the store.
+      Register yourself to NVIDIA Accelerated Computing Developer Program, retrieve the NCCL library
+      at https://developer.nvidia.com/nccl, and run the following command in the download directory:
+      nix-prefetch-url file://\$PWD/${name}
+    '';
+  };
+
+  unpackCmd = "tar xJf $src";
+
+  installPhase = ''
+    function fixRunPath {
+      p=$(patchelf --print-rpath $1)
+      patchelf --set-rpath "$p:${lib.makeLibraryPath [ stdenv.cc.cc ]}" $1
+    }
+    fixRunPath lib/libnccl.so
+
+    mkdir -p $out
+    cp -a include $out/include
+    cp -a lib $out/lib
+  '';
+
+  propagatedBuildInputs = [
+    cudatoolkit
+  ];
+
+  passthru = {
+    inherit cudatoolkit;
+  };
+
+  meta = with stdenv.lib; {
+    description = "Multi-GPU and multi-node collective communication primitives that are performance optimized for NVIDIA GPUs";
+    homepage = https://developer.nvidia.com/nccl;
+    license = licenses.unfree;
+    platforms = [ "x86_64-linux" ];
+    maintainers = with maintainers; [ mdaiter ];
+  };
+}
diff --git a/pkgs/development/libraries/science/math/openblas/default.nix b/pkgs/development/libraries/science/math/openblas/default.nix
index 7edc39c11f5c..5ac0bcd1d7d7 100644
--- a/pkgs/development/libraries/science/math/openblas/default.nix
+++ b/pkgs/development/libraries/science/math/openblas/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, gfortran, perl, which, config, coreutils
+{ stdenv, fetchurl, fetchpatch, gfortran, perl, which, config, coreutils
 # Most packages depending on openblas expect integer width to match
 # pointer width, but some expect to use 32-bit integers always
 # (for compatibility with reference BLAS).
@@ -12,6 +12,14 @@ let blas64_ = blas64; in
 let
   # To add support for a new platform, add an element to this set.
   configs = {
+    armv6l-linux = {
+      BINARY = "32";
+      TARGET = "ARMV6";
+      DYNAMIC_ARCH = "0";
+      CC = "gcc";
+      USE_OPENMP = "1";
+    };
+
     armv7l-linux = {
       BINARY = "32";
       TARGET = "ARMV7";
@@ -20,6 +28,14 @@ let
       USE_OPENMP = "1";
     };
 
+    aarch64-linux = {
+      BINARY = "64";
+      TARGET = "ARMV8";
+      DYNAMIC_ARCH = "1";
+      CC = "gcc";
+      USE_OPENMP = "1";
+    };
+
     i686-linux = {
       BINARY = "32";
       TARGET = "P2";
@@ -44,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
@@ -99,9 +115,16 @@ stdenv.mkDerivation {
       "NUM_THREADS=64"
       "INTERFACE64=${if blas64 then "1" else "0"}"
       "NO_STATIC=1"
-    ]
+    ] ++ stdenv.lib.optional (stdenv.hostPlatform.libc == "musl") "NO_AFFINITY=1"
     ++ mapAttrsToList (var: val: var + "=" + val) config;
 
+  patches = stdenv.lib.optional (stdenv.hostPlatform.libc != "glibc")
+    # https://github.com/xianyi/OpenBLAS/pull/1247
+    (fetchpatch {
+      url = "https://github.com/xianyi/OpenBLAS/commit/88a35ff457f55e527e0e8a503a0dc61976c1846d.patch";
+      sha256 = "1a3qrhvl5hp06c53fjqghq4zgf6ls7narm06l0shcvs57hznh09n";
+    });
+
   doCheck = true;
   checkTarget = "tests";
 
diff --git a/pkgs/development/libraries/science/math/openlibm/default.nix b/pkgs/development/libraries/science/math/openlibm/default.nix
index 6b229f31f161..195b90c86e1a 100644
--- a/pkgs/development/libraries/science/math/openlibm/default.nix
+++ b/pkgs/development/libraries/science/math/openlibm/default.nix
@@ -2,10 +2,10 @@
 
 stdenv.mkDerivation rec {
   name = "openlibm-${version}";
-  version = "0.5.4";
+  version = "0.5.5";
   src = fetchurl {
     url = "https://github.com/JuliaLang/openlibm/archive/v${version}.tar.gz";
-    sha256 = "0cwqqqlblj3kzp9aq1wnpfs1fl0qd1wp1xzm5shb09w06i4rh9nn";
+    sha256 = "1z8cj5q8ca8kmrakwkpjxf8svi81waw0c568cx8v8pv9kvswbp07";
   };
 
   makeFlags = [ "prefix=$(out)" ];
diff --git a/pkgs/development/libraries/science/math/openspecfun/default.nix b/pkgs/development/libraries/science/math/openspecfun/default.nix
index 989ad27055fa..3a4c5a784385 100644
--- a/pkgs/development/libraries/science/math/openspecfun/default.nix
+++ b/pkgs/development/libraries/science/math/openspecfun/default.nix
@@ -1,10 +1,10 @@
 { stdenv, fetchurl, gfortran }:
 
 stdenv.mkDerivation {
-  name = "openspecfun-0.4";
+  name = "openspecfun-0.5.3";
   src = fetchurl {
-    url = "https://github.com/JuliaLang/openspecfun/archive/v0.4.tar.gz";
-    sha256 = "0nsa3jjmlhcqkw5ba5ypbn3n0c8b6lc22zzlxnmxkxi9shhdx65z";
+    url = "https://github.com/JuliaLang/openspecfun/archive/v0.5.3.tar.gz";
+    sha256 = "1rs1bv8jq751fv9vq79890wqf9xlbjc7lvz3ighzyfczbyjcf18m";
   };
 
   makeFlags = [ "prefix=$(out)" ];
diff --git a/pkgs/development/libraries/science/math/petsc/default.nix b/pkgs/development/libraries/science/math/petsc/default.nix
index bc5527a8e970..ac8129c9032f 100644
--- a/pkgs/development/libraries/science/math/petsc/default.nix
+++ b/pkgs/development/libraries/science/math/petsc/default.nix
@@ -7,15 +7,20 @@
 
 stdenv.mkDerivation rec {
   name = "petsc-${version}";
-  version = "3.7.6";
+  version = "3.8.4";
 
   src = fetchurl {
     url = "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-${version}.tar.gz";
-    sha256 = "0jfl35lrhzvv982z6h1v5rcp39g0x16ca43rm9dx91wm6i8y13iw";
+    sha256 = "1iy49gagxncx09d88kxnwkj876p35683mpfk33x37165si6xqy4z";
   };
 
   nativeBuildInputs = [ blas gfortran.cc.lib liblapack python ];
 
+  prePatch = stdenv.lib.optionalString stdenv.isDarwin ''
+    substituteInPlace config/install.py \
+      --replace /usr/bin/install_name_tool install_name_tool
+  '';
+
   preConfigure = ''
     patchShebangs .
     configureFlagsArray=(
diff --git a/pkgs/development/libraries/science/math/planarity/default.nix b/pkgs/development/libraries/science/math/planarity/default.nix
new file mode 100644
index 000000000000..7394fb9e1b41
--- /dev/null
+++ b/pkgs/development/libraries/science/math/planarity/default.nix
@@ -0,0 +1,40 @@
+{ stdenv
+, fetchFromGitHub
+, fetchpatch
+, autoreconfHook
+}:
+
+stdenv.mkDerivation rec {
+  pname = "planarity";
+  version = "3.0.0.5";
+  name = "${pname}-${version}";
+
+  src = fetchFromGitHub {
+    owner = "graph-algorithms";
+    repo = "edge-addition-planarity-suite";
+    rev = "Version_${version}";
+    sha256 = "01cm7ay1njkfsdnmnvh5zwc7wg7x189hq1vbfhh9p3ihrbnmqzh8";
+  };
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  doCheck = true;
+
+  patches = [
+    # declare variables declared in headers as extern, not yet merged upstream
+    (fetchpatch {
+      url = "https://github.com/graph-algorithms/edge-addition-planarity-suite/pull/3.patch";
+      sha256 = "1nqjc4clr326imz4jxqxcxv2hgh1sjgzll27k5cwkdin8lnmmil8";
+    })
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/graph-algorithms/edge-addition-planarity-suite;
+    description = "A library for implementing graph algorithms";
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/science/math/rubiks/default.nix b/pkgs/development/libraries/science/math/rubiks/default.nix
new file mode 100644
index 000000000000..5b20948686b4
--- /dev/null
+++ b/pkgs/development/libraries/science/math/rubiks/default.nix
@@ -0,0 +1,82 @@
+{ stdenv
+, fetchurl
+, fetchpatch
+, coreutils
+}:
+
+stdenv.mkDerivation rec {
+  pname = "rubiks";
+  version = "20070912";
+  name = "${pname}-${version}";
+
+  src = fetchurl {
+    url = "http://mirrors.mit.edu/sage/spkg/upstream/rubiks/rubiks-${version}.tar.bz2";
+    sha256 = "0zdmkb0j1kyspdpsszzb2k3279xij79jkx0dxd9f3ix1yyyg3yfq";
+  };
+
+  preConfigure = ''
+    export INSTALL="${coreutils}/bin/install"
+  '';
+
+  # everything is done in `make install`
+  buildPhase = "true";
+
+  installFlags = [
+    "PREFIX=$out"
+  ];
+
+  patches = [
+    # Fix makefiles which use all the variables in all the wrong ways and
+    # hardcode values for some variables.
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/rubiks/patches/dietz-cu2-Makefile.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "1ry3w1mk9q4jqd91zlaa1bdiiplld4hpfjaldbhlmzlgrrc99qmq";
+    })
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/rubiks/patches/dietz-mcube-Makefile.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "0zsbh6k3kqdg82fv0kzghr1x7pafisv943gmssqscp107bhg77bz";
+    })
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/rubiks/patches/dietz-solver-Makefile.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "0vhw70ylnmydgjhwx8jjlb2slccj4pfqn6vzirkyz1wp8apsmfhp";
+    })
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/rubiks/patches/reid-Makefile.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "1r311sn012xs135s0d21qwsig2kld7rdcq19nm0zbnklviid57df";
+    })
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.sagemath.org/spkg/rubiks;
+    description = "Several programs for working with Rubik's cubes";
+    # The individual websites are no longer available
+    longDescription = ''
+      There are several programs for working with Rubik's cubes, by three
+      different people. Look inside the directories under /src to see
+      specific info and licensing. In summary the three contributers are:
+
+
+      Michael Reid (GPL) http://www.math.ucf.edu/~reid/Rubik/optimal_solver.html
+          optimal - uses many pre-computed tables to find an optimal
+                    solution to the 3x3x3 Rubik's cube
+
+
+      Dik T. Winter (MIT License)
+          cube    - uses Kociemba's algorithm to iteratively find a short
+                    solution to the 3x3x3 Rubik's cube
+          size222 - solves a 2x2x2 Rubik's cube
+
+
+      Eric Dietz (GPL) http://www.wrongway.org/?rubiksource
+          cu2   - A fast, non-optimal 2x2x2 solver
+          cubex - A fast, non-optimal 3x3x3 solver
+          mcube - A fast, non-optimal 4x4x4 solver
+    '';
+    license = with licenses; [
+      gpl2 # Michael Reid's and Eric Dietz software
+      mit # Dik T. Winter's software
+    ];
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/science/math/sympow/default.nix b/pkgs/development/libraries/science/math/sympow/default.nix
new file mode 100644
index 000000000000..fd677f5c0b7b
--- /dev/null
+++ b/pkgs/development/libraries/science/math/sympow/default.nix
@@ -0,0 +1,89 @@
+{ stdenv
+, fetchurl
+, fetchpatch
+, makeWrapper
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.018.1";
+  name = "sympow-${version}";
+
+  src = fetchurl {
+    # Original website no longer reachable
+    url = "http://mirrors.mit.edu/sage/spkg/upstream/sympow/sympow-${version}.tar.bz2";
+    sha256 = "0hphs7ia1wr5mydf288zvwj4svrymfpadcg3pi6w80km2yg5bm3c";
+  };
+
+  nativeBuildInputs = [
+    makeWrapper
+  ];
+
+  configurePhase = ''
+    runHook preConfigure
+    ./Configure # doesn't take any options
+    runHook postConfigure
+  '';
+
+  installPhase = ''
+    runHook preInstall
+    install -d datafiles "$out/share/sympow/datafiles"
+    install *.gp "$out/share/sympow/"
+    install -Dm755 sympow "$out/share/sympow/sympow"
+    install -D new_data "$out/bin/new_data"
+
+    makeWrapper "$out/share/sympow/sympow" "$out/bin/sympow" \
+      --run 'export SYMPOW_LOCAL="$HOME/.local/share/sympow"' \
+      --run 'if [ ! -d "$SYMPOW_LOCAL" ]; then
+        mkdir -p "$SYMPOW_LOCAL" 
+        cp -r ${placeholder "out"}/share/sympow/* "$SYMPOW_LOCAL"
+        chmod -R +xw "$SYMPOW_LOCAL"
+    fi' \
+      --run 'cd "$SYMPOW_LOCAL"'
+    runHook postInstall
+  '';
+
+  patches = [
+    # don't hardcode paths
+    (fetchpatch {
+      name = "do_not_hardcode_paths.patch";
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/sympow/patches/Configure.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "1611p8ra8zkxvmxn3gm2l64bd4ma4m6r4vd6vwswcic91k1fci04";
+    })
+
+    # bug on some platforms in combination with a newer gcc:
+    # https://trac.sagemath.org/ticket/11920
+    (fetchpatch {
+      name = "fix_newer_gcc1.patch";
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/sympow/patches/fpu.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "14gfa56w3ddfmd4d5ir9a40y2zi43cj1i4d2l2ij9l0qlqdy9jyx";
+    })
+    (fetchpatch {
+      name = "fix_newer_gcc2.patch";
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/sympow/patches/execlp.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "190gqhgz9wgw4lqwz0nwb1izc9zffx34bazsiw2a2sz94bmgb54v";
+    })
+
+    # fix pointer initialization bug (https://trac.sagemath.org/ticket/22862)
+    (fetchpatch {
+      name = "fix_pointer_initialization1.patch";
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/sympow/patches/initialize-tacks.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "02341vdbbidfs39s26vi4n5wigz619sw8fdbl0h9qsmwwhscgf85";
+    })
+    (fetchpatch {
+      name = "fix_pointer_initialization2.patch";
+      url = "https://git.archlinux.org/svntogit/community.git/plain/trunk/sympow-datafiles.patch?h=packages/sympow";
+      sha256 = "1m0vz048layb47r1jjf7fplw650ccc9x0w3l322iqmppzmv3022a";
+    })
+  ];
+
+  meta = with stdenv.lib; {
+    description = "A package to compute special values of symmetric power elliptic curve L-functions";
+    license = {
+      shortName = "sympow";
+      fullName = "Custom, BSD-like. See COPYING file.";
+      free = true;
+    };
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/science/networking/ns3/default.nix b/pkgs/development/libraries/science/networking/ns3/default.nix
new file mode 100644
index 000000000000..9fc72f18e5d7
--- /dev/null
+++ b/pkgs/development/libraries/science/networking/ns3/default.nix
@@ -0,0 +1,98 @@
+{ stdenv
+, fetchFromGitHub, fetchurl
+, python
+
+# for binding generation
+, castxml ? null
+
+# can take a long time, generates > 30000 images/graphs
+, enableDoxygen ? false
+
+# e.g. "optimized" or "debug". If not set, use default one
+, build_profile ? null
+
+# --enable-examples
+, withExamples ? false
+
+# very long
+, withManual ? false, doxygen ? null, graphviz ? null, imagemagick ? null
+# for manual, tetex is used to get the eps2pdf binary
+# texlive to get latexmk. building manual still fails though
+, dia, tetex ? null, ghostscript ? null, texlive ? null
+
+# generates python bindings
+, generateBindings ? false, ncurses ? null
+
+# All modules can be enabled by choosing 'all_modules'.
+# we include here the DCE mandatory ones
+, modules ? [ "core" "network" "internet" "point-to-point" "fd-net-device" "netanim"]
+, gcc6
+, lib
+}:
+
+let
+  pythonEnv = python.withPackages(ps:
+    stdenv.lib.optional withManual ps.sphinx
+    ++ stdenv.lib.optionals generateBindings (with ps;[ pybindgen pygccxml ])
+  );
+in
+stdenv.mkDerivation rec {
+
+  name = "ns-3.${version}";
+  version = "28";
+
+  # the all in one https://www.nsnam.org/release/ns-allinone-3.27.tar.bz2;
+  # fetches everything (netanim, etc), this package focuses on ns3-core
+  src = fetchFromGitHub {
+    owner  = "nsnam";
+    repo   = "ns-3-dev-git";
+    rev    = name;
+    sha256 = "17kzfjpgw2mvyx1c9bxccnvw67jpk09fxmcnlkqx9xisk10qnhng";
+  };
+
+  # ncurses is a hidden dependency of waf when checking python
+  buildInputs = lib.optionals generateBindings [ castxml ncurses ]
+    ++ stdenv.lib.optional enableDoxygen [ doxygen graphviz imagemagick ]
+    ++ stdenv.lib.optional withManual [ dia tetex ghostscript texlive.combined.scheme-medium ];
+
+  propagatedBuildInputs = [ gcc6 pythonEnv ];
+
+  postPatch = ''
+    patchShebangs ./waf
+    patchShebangs doc/ns3_html_theme/get_version.sh
+  '';
+
+  configureScript = "${python.interpreter} ./waf configure";
+
+  configureFlags = with stdenv.lib; [
+      "--enable-modules=${stdenv.lib.concatStringsSep "," modules}"
+      "--with-python=${pythonEnv.interpreter}"
+  ]
+  ++ optional (build_profile != null) "--build-profile=${build_profile}"
+  ++ optional generateBindings [  ]
+  ++ optional withExamples " --enable-examples "
+  ++ optional doCheck " --enable-tests "
+  ;
+
+  postBuild = with stdenv.lib; let flags = concatStringsSep ";" (
+      optional enableDoxygen "./waf doxygen"
+      ++ optional withManual "./waf sphinx"
+    );
+    in "${flags}"
+  ;
+
+  doCheck = true;
+
+  # we need to specify the proper interpreter else ns3 can check against a
+  # different version even though we
+  checkPhase =  ''
+    ${pythonEnv.interpreter} ./test.py
+  '';
+
+  meta = {
+    homepage = http://www.nsnam.org;
+    license = stdenv.lib.licenses.gpl3;
+    description = "A discrete time event network simulator";
+    platforms = with stdenv.lib.platforms; unix;
+  };
+}
diff --git a/pkgs/development/libraries/serd/default.nix b/pkgs/development/libraries/serd/default.nix
index 968550675235..96449a8ed962 100644
--- a/pkgs/development/libraries/serd/default.nix
+++ b/pkgs/development/libraries/serd/default.nix
@@ -1,22 +1,21 @@
-{ stdenv, fetchurl, pcre, pkgconfig, python }:
+{ stdenv, fetchurl, pkgconfig, python }:
 
 stdenv.mkDerivation rec {
   name = "serd-${version}";
-  version = "0.26.0";
+  version = "0.28.0";
 
   src = fetchurl {
     url = "http://download.drobilla.net/${name}.tar.bz2";
-    sha256 = "164j43am4hka2vbzw4n52zy7rafgp6kmkgbcbvap368az644mr73";
+    sha256 = "1v4ai4zyj1q3255nghicns9817jkwb3bh60ssprsjmnjfj41mwhx";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ pcre python ];
+  nativeBuildInputs = [ pkgconfig python ];
 
-  configurePhase = "${python.interpreter} waf configure --prefix=$out";
+  configurePhase = "python waf configure --prefix=$out";
 
-  buildPhase = "${python.interpreter} waf";
+  buildPhase = "python waf";
 
-  installPhase = "${python.interpreter} waf install";
+  installPhase = "python waf install";
 
   meta = with stdenv.lib; {
     homepage = http://drobilla.net/software/serd;
diff --git a/pkgs/development/libraries/serf/default.nix b/pkgs/development/libraries/serf/default.nix
index 001199cd8212..81dff49571da 100644
--- a/pkgs/development/libraries/serf/default.nix
+++ b/pkgs/development/libraries/serf/default.nix
@@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
         APU="$(echo "${aprutil.dev}"/bin/*-config)" CC="${
           if stdenv.cc.isClang then "clang" else "${stdenv.cc}/bin/gcc"
         }" ${
-          if (stdenv.isDarwin || stdenv.isCygwin) then "" else "GSSAPI=\"${kerberos}\""
+          if (stdenv.isDarwin || stdenv.isCygwin) then "" else "GSSAPI=\"${kerberos.dev}\""
         }
   '';
 
diff --git a/pkgs/development/libraries/shapelib/default.nix b/pkgs/development/libraries/shapelib/default.nix
index b481bd0cf651..3234d1bb89bf 100644
--- a/pkgs/development/libraries/shapelib/default.nix
+++ b/pkgs/development/libraries/shapelib/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, proj }:
 
 stdenv.mkDerivation rec {
-  name = "shapelib-1.4.0";
+  name = "shapelib-1.4.1";
 
   src = fetchurl {
     url = "http://download.osgeo.org/shapelib/${name}.tar.gz";
-    sha256 = "18d7j5pn5srika7q3f90j0l2l4526xsjd64pin6z2b0gd7rdbp9y";
+    sha256 = "1cr3b5jfglwisbyzj7fnxp9xysqad0fcmcqvqaja6qap6qblijd4";
   };
 
   buildInputs =  [ proj ];
diff --git a/pkgs/development/libraries/shibboleth-sp/default.nix b/pkgs/development/libraries/shibboleth-sp/default.nix
index 219cda38bc28..74f861297d1a 100644
--- a/pkgs/development/libraries/shibboleth-sp/default.nix
+++ b/pkgs/development/libraries/shibboleth-sp/default.nix
@@ -2,12 +2,12 @@
 
 stdenv.mkDerivation rec {
   name = "shibboleth-sp-${version}";
-  version = "2.6.0";
+  version = "2.6.1";
 
   src = fetchgit {
     url = "https://git.shibboleth.net/git/cpp-sp.git";
-    rev = "9ebba5c3a16d03769f436e383e4c4cdaa33f5509";
-    sha256 = "1b5r4nd098lnjwr2g13f04ycqv5fvbrhpwg6fsdk8xy9cigvfzxj";
+    rev = version;
+    sha256 = "01q13p7gc0janjfml6zs46na8qnval8hc833fk2wrnmi4w9xw4fd";
   };
 
   nativeBuildInputs = [ autoreconfHook pkgconfig ];
diff --git a/pkgs/development/libraries/simgear/default.nix b/pkgs/development/libraries/simgear/default.nix
index d724ebbf3738..28b96d17aa60 100644
--- a/pkgs/development/libraries/simgear/default.nix
+++ b/pkgs/development/libraries/simgear/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, plib, freeglut, xproto, libX11, libXext, xextproto, libXi
-, inputproto, libICE, libSM, libXt, libXmu, mesa, boost, zlib, libjpeg, freealut
+, inputproto, libICE, libSM, libXt, libXmu, libGLU_combined, boost, zlib, libjpeg, freealut
 , openscenegraph, openal, expat, cmake, apr
 , curl
 }:
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs = [ plib freeglut xproto libX11 libXext xextproto libXi inputproto
-                  libICE libSM libXt libXmu mesa boost zlib libjpeg freealut
+                  libICE libSM libXt libXmu libGLU_combined boost zlib libjpeg freealut
                   openscenegraph openal expat cmake apr curl ];
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/skalibs/default.nix b/pkgs/development/libraries/skalibs/default.nix
index b87662a6e342..29cc477a279d 100644
--- a/pkgs/development/libraries/skalibs/default.nix
+++ b/pkgs/development/libraries/skalibs/default.nix
@@ -2,7 +2,7 @@
 
 let
 
-  version = "2.4.0.1";
+  version = "2.6.0.1";
 
 in stdenv.mkDerivation rec {
 
@@ -11,7 +11,7 @@ in stdenv.mkDerivation rec {
   src = fetchgit {
     url = "git://git.skarnet.org/skalibs";
     rev = "refs/tags/v${version}";
-    sha256 = "1sdzm2vd9mxlwxbmjajb6n1n13dpsavdap2nbbnyx4wnzixxx9k7";
+    sha256 = "0skdv3wff1i78hb0y771apw0cak5rzxbwbh6l922snfm01z9k1ws";
   };
 
   dontDisableStatic = true;
diff --git a/pkgs/development/libraries/slib/setup-hook.sh b/pkgs/development/libraries/slib/setup-hook.sh
index 62b72d6dc0ab..3c7e91e81886 100644
--- a/pkgs/development/libraries/slib/setup-hook.sh
+++ b/pkgs/development/libraries/slib/setup-hook.sh
@@ -10,4 +10,4 @@ addSlibPath () {
     fi
 }
 
-envHooks+=(addSlibPath)
+addEnvHooks "$hostOffset" addSlibPath
diff --git a/pkgs/development/libraries/smpeg/default.nix b/pkgs/development/libraries/smpeg/default.nix
index f248d65e2ed6..7119f76c55fd 100644
--- a/pkgs/development/libraries/smpeg/default.nix
+++ b/pkgs/development/libraries/smpeg/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchsvn, SDL, autoconf, automake, libtool, gtk2, m4, pkgconfig, mesa, makeWrapper }:
+{ stdenv, fetchsvn, SDL, autoconf, automake, libtool, gtk2, m4, pkgconfig, libGLU_combined, makeWrapper }:
 
 stdenv.mkDerivation rec {
   name = "smpeg-svn${version}";
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  buildInputs = [ SDL gtk2 mesa ];
+  buildInputs = [ SDL gtk2 libGLU_combined ];
 
   nativeBuildInputs = [ autoconf automake libtool m4 pkgconfig makeWrapper ];
 
diff --git a/pkgs/development/libraries/smpeg2/default.nix b/pkgs/development/libraries/smpeg2/default.nix
index 10386a7b33e4..3207bdb3a7f2 100644
--- a/pkgs/development/libraries/smpeg2/default.nix
+++ b/pkgs/development/libraries/smpeg2/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchsvn, autoconf, automake, libtool, m4, pkgconfig, makeWrapper, SDL2 }:
+{ stdenv, darwin, fetchsvn, autoconf, automake, libtool, m4, pkgconfig, makeWrapper, SDL2 }:
 
 stdenv.mkDerivation rec {
   name = "smpeg2-svn${version}";
@@ -17,7 +17,8 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ autoconf automake pkgconfig makeWrapper ];
 
-  buildInputs = [ SDL2 ];
+  buildInputs = [ SDL2 ]
+    ++ stdenv.lib.optional stdenv.isDarwin darwin.libobjc;
 
   preConfigure = ''
     sh autogen.sh
@@ -37,7 +38,7 @@ stdenv.mkDerivation rec {
     homepage = http://icculus.org/smpeg/;
     description = "SDL2 MPEG Player Library";
     license = licenses.lgpl2;
-    platforms = platforms.linux;
+    platforms = platforms.unix;
     maintainers = with maintainers; [ orivej ];
   };
 }
diff --git a/pkgs/development/libraries/snappy/default.nix b/pkgs/development/libraries/snappy/default.nix
index c5e52124ceed..8f37302cec50 100644
--- a/pkgs/development/libraries/snappy/default.nix
+++ b/pkgs/development/libraries/snappy/default.nix
@@ -1,24 +1,27 @@
-{ stdenv, fetchurl, pkgconfig }:
+{ stdenv, fetchFromGitHub, cmake }:
 
 stdenv.mkDerivation rec {
   name = "snappy-${version}";
-  version = "1.1.4";
+  version = "1.1.7";
 
-  src = fetchurl {
-    url = "http://github.com/google/snappy/releases/download/${version}/"
-        + "snappy-${version}.tar.gz";
-    sha256 = "0mq0nz8gbi1sp3y6xcg0a6wbvnd6gc717f3vh2xrjmfj5w9gwjqk";
+  src = fetchFromGitHub {
+    owner = "google";
+    repo = "snappy";
+    rev = "${version}";
+    sha256 = "1x7r8sjmdqlqjz0xfiwdyrqpgaj5yrvrgb28ivgpvnxgar5qv6m2";
   };
 
-  outputs = [ "out" "dev" "doc" ];
+  patches = [ ./disable-benchmark.patch ];
 
-  nativeBuildInputs = [ pkgconfig ];
+  outputs = [ "out" "dev" ];
 
-  # -DNDEBUG for speed
-  configureFlags = [ "CXXFLAGS=-DNDEBUG" ];
+  nativeBuildInputs = [ cmake ];
 
-  # SIGILL on darwin
-  doCheck = !stdenv.isDarwin;
+  cmakeFlags = [ "-DBUILD_SHARED_LIBS=ON" "-DCMAKE_SKIP_BUILD_RPATH=OFF" ];
+
+  checkTarget = "test";
+
+  doCheck = true;
 
   meta = with stdenv.lib; {
     homepage = https://google.github.io/snappy/;
diff --git a/pkgs/development/libraries/snappy/disable-benchmark.patch b/pkgs/development/libraries/snappy/disable-benchmark.patch
new file mode 100644
index 000000000000..c891c13fe74c
--- /dev/null
+++ b/pkgs/development/libraries/snappy/disable-benchmark.patch
@@ -0,0 +1,5 @@
+--- a/snappy-test.cc
++++ b/snappy-test.cc
+@@ -46 +46 @@
+-DEFINE_bool(run_microbenchmarks, true,
++DEFINE_bool(run_microbenchmarks, false,
diff --git a/pkgs/development/libraries/socket_wrapper/default.nix b/pkgs/development/libraries/socket_wrapper/default.nix
index 4db4a07b4e56..6d0ca4c1d675 100644
--- a/pkgs/development/libraries/socket_wrapper/default.nix
+++ b/pkgs/development/libraries/socket_wrapper/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, cmake, pkgconfig }:
 
 stdenv.mkDerivation rec {
-  name = "socket_wrapper-1.1.5";
+  name = "socket_wrapper-1.1.9";
 
   src = fetchurl {
     url = "mirror://samba/cwrap/${name}.tar.gz";
-    sha256 = "01gn21kbicwfn3vlnnir8c11z2g54b532bj3qrpdrhgrcm3ifi45";
+    sha256 = "1d7bbr4j1ybq2dm6q3f6ncv36qqxyjygq4z1q0hvadlcaw7pj79c";
   };
 
   nativeBuildInputs = [ cmake pkgconfig ];
diff --git a/pkgs/development/libraries/sord/default.nix b/pkgs/development/libraries/sord/default.nix
index 57f81aa4613e..995ac631580d 100644
--- a/pkgs/development/libraries/sord/default.nix
+++ b/pkgs/development/libraries/sord/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, python, serd }:
+{ stdenv, fetchurl, pkgconfig, python, serd, pcre }:
 
 stdenv.mkDerivation rec {
   name = "sord-${version}";
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ python serd ];
+  buildInputs = [ python serd pcre ];
 
   configurePhase = "${python.interpreter} waf configure --prefix=$out";
 
diff --git a/pkgs/development/libraries/soundtouch/default.nix b/pkgs/development/libraries/soundtouch/default.nix
index 729967ea1b7f..c338d6762a4d 100644
--- a/pkgs/development/libraries/soundtouch/default.nix
+++ b/pkgs/development/libraries/soundtouch/default.nix
@@ -2,10 +2,10 @@
 
 stdenv.mkDerivation rec {
   pName = "soundtouch";
-  name = "${pName}-1.9.2";
+  name = "${pName}-2.0.0";
   src = fetchurl {
     url = "http://www.surina.net/soundtouch/${name}.tar.gz";
-    sha256 = "04y5l56yn4jvwpv9mn1p3m2vi5kdym9xpdac8pmhwhl13r8qdsya";
+    sha256 = "09cxr02mfyj2bg731bj0i9hh565x8l9p91aclxs8wpqv8b8zf96j";
   };
 
   buildInputs = [ autoconf automake libtool ];
diff --git a/pkgs/development/libraries/speech-tools/default.nix b/pkgs/development/libraries/speech-tools/default.nix
index fba354213556..22d66b7e71d1 100644
--- a/pkgs/development/libraries/speech-tools/default.nix
+++ b/pkgs/development/libraries/speech-tools/default.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, gawk, alsaLib, ncurses }:
 
 stdenv.mkDerivation rec {
-  name = "speech_tools-${version}";
-  version = "2.1";
+  name = "speech_tools-${version}.0";
+  version = "2.5";
 
   src = fetchurl {
     url = "http://www.festvox.org/packed/festival/${version}/${name}-release.tar.gz";
-    sha256 = "1s9bkfgdgyas8v2cr7x3dg0ck1xf9mn1q6a73gwy524sjb6nfqgz";
+    sha256 = "1k2xh13miyv48gh06rgsq2vj25xwj7z6vwq9ilsn8i7ig3nrgzg4";
   };
 
   buildInputs = [ alsaLib ncurses ];
@@ -14,6 +14,10 @@ stdenv.mkDerivation rec {
   preConfigure = ''
     sed -e s@/usr/bin/@@g -i $( grep -rl '/usr/bin/' . )
     sed -re 's@/bin/(rm|printf|uname)@\1@g' -i $( grep -rl '/bin/' . )
+
+    # c99 makes isnan valid for float and double
+    substituteInPlace include/EST_math.h \
+      --replace '__isnanf(X)' 'isnan(X)'
   '';
 
   installPhase = ''
@@ -26,16 +30,17 @@ stdenv.mkDerivation rec {
     done
   '';
 
+  doCheck = true;
+
+  checkTarget = "test";
+
   meta = with stdenv.lib; {
-    broken = true;
     description = "Text-to-speech engine";
-    maintainers = with maintainers;
-    [
-      raskin
-    ];
+    maintainers = with maintainers; [ raskin ];
     platforms = platforms.linux;
     license = licenses.free;
   };
+
   passthru = {
     updateInfo = {
       downloadPage = "http://www.festvox.org/packed/festival/";
diff --git a/pkgs/development/libraries/speechd/default.nix b/pkgs/development/libraries/speechd/default.nix
index ee45c0d1c65a..b27fd0843bc0 100644
--- a/pkgs/development/libraries/speechd/default.nix
+++ b/pkgs/development/libraries/speechd/default.nix
@@ -1,29 +1,70 @@
-{ fetchurl, lib, stdenv, intltool, libtool, pkgconfig, glib, dotconf, libsndfile
-, libao, python3Packages
-, withEspeak ? false, espeak
+{ stdenv, pkgconfig, fetchurl, python3Packages
+, intltool, itstool, libtool, texinfo, autoreconfHook
+, glib, dotconf, libsndfile
+, withLibao ? true, libao
+, withPulse ? false, libpulseaudio
+, withAlsa ? false, alsaLib
+, withOss ? false
+, withFlite ? true, flite
+# , withFestival ? false, festival-freebsoft-utils
+, withEspeak ? true, espeak, sonic, pcaudiolib
 , withPico ? true, svox
+# , withIvona ? false, libdumbtts
 }:
 
-stdenv.mkDerivation rec {
+let
+  inherit (stdenv.lib) optional optionals;
+  inherit (python3Packages) python pyxdg wrapPython;
+
+  # speechd hard-codes espeak, even when built without support for it.
+  selectedDefaultModule =
+    if withEspeak then
+      "espeak-ng"
+    else if withPico then
+      "pico"
+    else if withFlite then
+      "flite"
+    else
+      throw "You need to enable at least one output module.";
+in stdenv.mkDerivation rec {
   name = "speech-dispatcher-${version}";
-  version = "0.8.5";
+  version = "0.8.8";
 
   src = fetchurl {
     url = "http://www.freebsoft.org/pub/projects/speechd/${name}.tar.gz";
-    sha256 = "18jlxnhlahyi6njc6l6576hfvmzivjjgfjyd2n7vvrvx9inphjrb";
+    sha256 = "1wvck00w9ixildaq6hlhnf6wa576y02ac96lp6932h3k1n08jaiw";
   };
 
-  buildInputs = [ intltool libtool glib dotconf libsndfile libao python3Packages.python ]
-             ++ lib.optional withEspeak espeak
-             ++ lib.optional withPico svox;
-  nativeBuildInputs = [ pkgconfig python3Packages.wrapPython ];
+  nativeBuildInputs = [ pkgconfig autoreconfHook intltool libtool itstool texinfo wrapPython ];
+
+  buildInputs = [ glib dotconf libsndfile libao libpulseaudio alsaLib python ]
+    ++ optionals withEspeak [ espeak sonic pcaudiolib ]
+    ++ optional withFlite flite
+    ++ optional withPico svox
+    # TODO: add flint/festival support with festival-freebsoft-utils package
+    # ++ optional withFestival festival-freebsoft-utils
+    # TODO: add Ivona support with libdumbtts package
+    # ++ optional withIvona libdumbtts
+  ;
 
-  hardeningDisable = [ "format" ];
+  pythonPath = [ pyxdg ];
 
-  pythonPath = with python3Packages; [ pyxdg ];
+  configureFlags = [
+    # Audio method falls back from left to right.
+    "--with-default-audio-method=\"libao,pulse,alsa,oss\""
+  ] ++ optional withPulse "--with-pulse"
+    ++ optional withAlsa "--with-alsa"
+    ++ optional withLibao "--with-libao"
+    ++ optional withOss "--with-oss"
+    ++ optional withEspeak "--with-espeak-ng"
+    ++ optional withPico "--with-pico"
+    # ++ optional withFestival "--with-flint"
+    # ++ optional withIvona "--with-ivona"
+  ;
 
-  postPatch = lib.optionalString withPico ''
-    sed -i 's,/usr/share/pico/lang/,${svox}/share/pico/lang/,g' src/modules/pico.c
+  postPatch = ''
+    substituteInPlace config/speechd.conf --replace "DefaultModule espeak" "DefaultModule ${selectedDefaultModule}"
+    substituteInPlace src/modules/pico.c --replace "/usr/share/pico/lang" "${svox}/share/pico/lang"
   '';
 
   postInstall = ''
@@ -32,8 +73,9 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "Common interface to speech synthesis";
-    homepage = http://www.freebsoft.org/speechd;
+    homepage = https://devel.freebsoft.org/speechd;
     license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ berce ];
     platforms = platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/speex/default.nix b/pkgs/development/libraries/speex/default.nix
index 602359965f12..173b460a0ab2 100644
--- a/pkgs/development/libraries/speex/default.nix
+++ b/pkgs/development/libraries/speex/default.nix
@@ -25,7 +25,7 @@ stdenv.mkDerivation rec {
   ];
 
   meta = with stdenv.lib; {
-    homepage = http://www.speex.org/;
+    homepage = https://www.speex.org/;
     description = "An Open Source/Free Software patent-free audio compression format designed for speech";
     license = licenses.bsd3;
     platforms = platforms.unix;
diff --git a/pkgs/development/libraries/spice-gtk/default.nix b/pkgs/development/libraries/spice-gtk/default.nix
index 080dbc4510dd..0564459b24c0 100644
--- a/pkgs/development/libraries/spice-gtk/default.nix
+++ b/pkgs/development/libraries/spice-gtk/default.nix
@@ -1,7 +1,29 @@
-{ stdenv, fetchurl, pkgconfig, spice_protocol, gettext, celt_0_5_1
+{ stdenv, fetchurl, pkgconfig, spice-protocol, gettext, celt_0_5_1
 , openssl, libpulseaudio, pixman, gobjectIntrospection, libjpeg_turbo, zlib
 , cyrus_sasl, python2Packages, autoreconfHook, usbredir, libsoup
-, gtk3, epoxy }:
+, withPolkit ? true, polkit, acl, usbutils
+, 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.
+# The helper confirms via polkit that the user has an active session,
+# then adds a device acl entry for that user.
+# Example NixOS config to create a setuid wrapper for the helper:
+# security.wrappers.spice-client-glib-usb-acl-helper.source =
+#   "${pkgs.spice-gtk}/bin/spice-client-glib-usb-acl-helper";
+# On non-NixOS installations, make a setuid copy of the helper
+# outside the store and adjust PATH to find the setuid version.
+
+# If this package is built without polkit support (withPolkit=false),
+# usb redirection requires read-write access to usb devices.
+# This can be granted by adding users to a custom group like "usb"
+# and using a udev rule to put all usb devices in that group.
+# Example NixOS config:
+#  users.groups.usb = {};
+#  users.users.dummy.extraGroups = [ "usb" ];
+#  services.udev.extraRules = ''
+#    KERNEL=="*", SUBSYSTEMS=="usb", MODE="0664", GROUP="usb"
+#  '';
 
 with stdenv.lib;
 
@@ -10,28 +32,32 @@ let
 in stdenv.mkDerivation rec {
   name = "spice-gtk-0.34";
 
+  outputs = [ "out" "dev" ];
+
   src = fetchurl {
     url = "http://www.spice-space.org/download/gtk/${name}.tar.bz2";
     sha256 = "1vknp72pl6v6nf3dphhwp29hk6gv787db2pmyg4m312z2q0hwwp9";
   };
 
-  buildInputs = [
-    spice_protocol celt_0_5_1 openssl libpulseaudio pixman gobjectIntrospection
-    libjpeg_turbo zlib cyrus_sasl python pygtk usbredir gtk3 epoxy
-  ];
+  postPatch = ''
+    # get rid of absolute path to helper in store so we can use a setuid wrapper
+    substituteInPlace src/usb-acl-helper.c \
+      --replace 'ACL_HELPER_PATH"/' '"'
+  '';
 
-  nativeBuildInputs = [ pkgconfig gettext libsoup autoreconfHook ];
+  buildInputs = [
+    spice-protocol celt_0_5_1 openssl libpulseaudio pixman
+    libjpeg_turbo zlib cyrus_sasl python pygtk usbredir gtk3 epoxy libdrm
+  ] ++ optionals withPolkit [ polkit acl usbutils ] ;
 
-  NIX_CFLAGS_COMPILE = "-fno-stack-protector";
+  nativeBuildInputs = [ pkgconfig gettext libsoup autoreconfHook vala gobjectIntrospection ];
 
-  preAutoreconf = ''
-    substituteInPlace src/Makefile.am \
-          --replace '=codegendir pygtk-2.0' '=codegendir pygobject-2.0'
-  '';
+  PKG_CONFIG_POLKIT_GOBJECT_1_POLICYDIR = "share/polkit-1/actions";
 
   configureFlags = [
-    "--disable-maintainer-mode"
     "--with-gtk3"
+    "--enable-introspection"
+    "--enable-vala"
   ];
 
   dontDisableStatic = true; # Needed by the coroutine test
@@ -49,7 +75,7 @@ in stdenv.mkDerivation rec {
 
     homepage = http://www.spice-space.org/;
     license = licenses.lgpl21;
-
+    maintainers = [ maintainers.xeji ];
     platforms = platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/spice/default.nix b/pkgs/development/libraries/spice/default.nix
index 808bfd4f811d..1ab76340cc7c 100644
--- a/pkgs/development/libraries/spice/default.nix
+++ b/pkgs/development/libraries/spice/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, fetchpatch, pkgconfig, pixman, celt, alsaLib
 , openssl, libXrandr, libXfixes, libXext, libXrender, libXinerama
-, libjpeg, zlib, spice_protocol, python, pyparsing, glib, cyrus_sasl
+, libjpeg, zlib, spice-protocol, python, pyparsing, glib, cyrus_sasl
 , lz4 }:
 
 with stdenv.lib;
@@ -17,12 +17,12 @@ stdenv.mkDerivation rec {
     # the following three patches fix CVE-2016-9577 and CVE-2016-9578
     (fetchpatch {
       name = "0001-Prevent-possible-DoS-attempts-during-protocol-handsh.patch";
-      url = "http://pkgs.fedoraproject.org/cgit/rpms/spice.git/plain/0001-Prevent-possible-DoS-attempts-during-protocol-handsh.patch?id=d919d639ae5f83a9735a04d843eed675f9357c0d";
+      url = "http://src.fedoraproject.org/cgit/rpms/spice.git/plain/0001-Prevent-possible-DoS-attempts-during-protocol-handsh.patch?id=d919d639ae5f83a9735a04d843eed675f9357c0d";
       sha256 = "11x5566lx5zyl7f39glwsgpzkxb7hpcshx8va5ab3imrns07130q";
     })
     (fetchpatch {
       name = "0002-Prevent-integer-overflows-in-capability-checks.patch";
-      url = "http://pkgs.fedoraproject.org/cgit/rpms/spice.git/plain/0002-Prevent-integer-overflows-in-capability-checks.patch?id=d919d639ae5f83a9735a04d843eed675f9357c0d";
+      url = "http://src.fedoraproject.org/cgit/rpms/spice.git/plain/0002-Prevent-integer-overflows-in-capability-checks.patch?id=d919d639ae5f83a9735a04d843eed675f9357c0d";
       sha256 = "1r1bhq98w93cvvrlrz6jwdfsy261xl3xqs0ppchaa2igyxvxv5z5";
     })
     (fetchpatch {
@@ -36,7 +36,7 @@ stdenv.mkDerivation rec {
                   libXrandr libXfixes libXrender libXext libXinerama
                   python pyparsing glib cyrus_sasl lz4 ];
 
-  nativeBuildInputs = [ pkgconfig spice_protocol ];
+  nativeBuildInputs = [ pkgconfig spice-protocol ];
 
   NIX_CFLAGS_COMPILE = "-fno-stack-protector";
 
diff --git a/pkgs/development/libraries/sqlcipher/default.nix b/pkgs/development/libraries/sqlcipher/default.nix
index c1f624f8744d..ed19814be34a 100644
--- a/pkgs/development/libraries/sqlcipher/default.nix
+++ b/pkgs/development/libraries/sqlcipher/default.nix
@@ -4,13 +4,13 @@ assert readline != null -> ncurses != null;
 
 stdenv.mkDerivation rec {
   name = "sqlcipher-${version}";
-  version = "3.4.0";
+  version = "3.4.2";
 
   src = fetchFromGitHub {
     owner = "sqlcipher";
     repo = "sqlcipher";
     rev = "v${version}";
-    sha256 = "1lwc2m21sax3pnjfqddldbpbwr3b51s91fxz7dd7hf6ly8swnsvp";
+    sha256 = "168wb6fvyap7y8j86fb3xl5rd4wmhiq0dxvx9wxwi5kwm1j4vn1a";
   };
 
   buildInputs = [ readline ncurses openssl tcl ];
diff --git a/pkgs/development/libraries/sqlite/default.nix b/pkgs/development/libraries/sqlite/default.nix
index 0625183fb7de..b8b7d0c701dd 100644
--- a/pkgs/development/libraries/sqlite/default.nix
+++ b/pkgs/development/libraries/sqlite/default.nix
@@ -3,11 +3,11 @@
 assert interactive -> readline != null && ncurses != null;
 
 stdenv.mkDerivation {
-  name = "sqlite-3.21.0";
+  name = "sqlite-3.22.0";
 
   src = fetchurl {
-    url = "http://sqlite.org/2017/sqlite-autoconf-3210000.tar.gz";
-    sha256 = "1qxvzdjwzw6k0kqjfabj86rnq87xdbwbca7laxxdhnh0fmkm3pfp";
+    url = "http://sqlite.org/2018/sqlite-autoconf-3220000.tar.gz";
+    sha256 = "04n6hnw2g818d7r92cp2608kd5mhzyysy83k29kbq1mp709an918";
   };
 
   outputs = [ "bin" "dev" "out" ];
@@ -31,6 +31,8 @@ stdenv.mkDerivation {
     "-DSQLITE_ENABLE_UNLOCK_NOTIFY"
     "-DSQLITE_SOUNDEX"
     "-DSQLITE_SECURE_DELETE"
+    "-DSQLITE_MAX_VARIABLE_NUMBER=250000"
+    "-DSQLITE_MAX_EXPR_DEPTH=10000"
   ];
 
   # Test for features which may not be available at compile time
diff --git a/pkgs/development/libraries/sqlite/sqlite3_analyzer.nix b/pkgs/development/libraries/sqlite/sqlite3_analyzer.nix
index d971587ee6ee..1feedb94c158 100644
--- a/pkgs/development/libraries/sqlite/sqlite3_analyzer.nix
+++ b/pkgs/development/libraries/sqlite/sqlite3_analyzer.nix
@@ -1,11 +1,11 @@
 { lib, stdenv, fetchurl, unzip, tcl }:
 
 stdenv.mkDerivation {
-  name = "sqlite3_analyzer-3.20.1";
+  name = "sqlite3_analyzer-3.22.0";
 
   src = fetchurl {
-    url = "https://www.sqlite.org/2017/sqlite-src-3200100.zip";
-    sha256 = "0aicmapa99141hjncyxwg66ndhr16nwpbqy27x79fg1ikzhwlnv6";
+    url = "https://www.sqlite.org/2018/sqlite-src-3220000.zip";
+    sha256 = "04w97jj1659vl84rr73wg1mhj6by8r5075rzpn2xp42n537a7ibv";
   };
 
   nativeBuildInputs = [ unzip ];
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 1430c3aa9c29..89261b665f50 100644
--- a/pkgs/development/libraries/stfl/default.nix
+++ b/pkgs/development/libraries/stfl/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, ncurses, libiconv }:
 
 stdenv.mkDerivation rec {
-  name = "stfl-0.22";
+  name = "stfl-0.24";
 
   src = fetchurl {
     url = "http://www.clifford.at/stfl/${name}.tar.gz";
-    sha256 = "062lqlf3qhp8bcapbpc0k3wym7x6ngncql8jmx5x06p6679szp9d";
+    sha256 = "1460d5lc780p3q38l3wc9jfr2a7zlyrcra0li65aynj738cam9yl";
   };
 
   buildInputs = [ ncurses libiconv ];
@@ -14,7 +14,6 @@ stdenv.mkDerivation rec {
     sed -i s/gcc/cc/g Makefile
     sed -i s%ncursesw/ncurses.h%ncurses.h% stfl_internals.h
   '' + ( stdenv.lib.optionalString stdenv.isDarwin ''
-    sed -i 's/LDLIBS += -lncursesw/LDLIBS += -lncursesw -liconv/' Makefile
     sed -i s/-soname/-install_name/ Makefile
   '' ) + ''
     make
@@ -24,7 +23,7 @@ stdenv.mkDerivation rec {
     DESTDIR=$out prefix=\"\" make install
 
     # some programs rely on libstfl.so.0 to be present, so link it
-    ln -s $out/lib/libstfl.so.0.22 $out/lib/libstfl.so.0
+    ln -s $out/lib/libstfl.so.0.24 $out/lib/libstfl.so.0
   '';
 
   meta = {
@@ -35,4 +34,3 @@ stdenv.mkDerivation rec {
     platforms   = stdenv.lib.platforms.unix;
   };
 }
-
diff --git a/pkgs/development/libraries/stlport/default.nix b/pkgs/development/libraries/stlport/default.nix
index 30f87d36ddf9..ff1a7b57f4a5 100644
--- a/pkgs/development/libraries/stlport/default.nix
+++ b/pkgs/development/libraries/stlport/default.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
 
   meta = {
     description = "An implementation of the C++ Standard Library";
-    homepage = http://sourceforge.net/projects/stlport/;
+    homepage = https://sourceforge.net/projects/stlport/;
     license = stdenv.lib.licenses.free; # seems BSD-like
     broken = true; # probably glibc-2.20 -related issue
   };
diff --git a/pkgs/development/libraries/sundials/default.nix b/pkgs/development/libraries/sundials/default.nix
new file mode 100644
index 000000000000..41f7267fdca9
--- /dev/null
+++ b/pkgs/development/libraries/sundials/default.nix
@@ -0,0 +1,28 @@
+{ cmake, fetchurl, python, stdenv }:
+
+stdenv.mkDerivation rec {
+
+  pname = "sundials";
+  version = "3.1.0";
+  name = "${pname}-${version}";
+
+  src = fetchurl {
+  url = "https://computation.llnl.gov/projects/${pname}/download/${pname}-${version}.tar.gz";
+  sha256 = "0fnlrpj6qjamxahd70r4vsgv85kxbgh93gxqk5xzf9ln6a7jzm8q";
+  };
+
+  preConfigure = ''
+    export cmakeFlags="-DCMAKE_INSTALL_PREFIX=$out -DEXAMPLES_INSTALL_PATH=$out/share/examples $cmakeFlags"
+  '';
+  
+  buildInputs = [ cmake python ];
+
+  meta = with stdenv.lib; {
+    description = "Suite of nonlinear differential/algebraic equation solvers";
+    homepage    = https://computation.llnl.gov/casc/sundials/main.html;
+    platforms   = platforms.all;
+    maintainers = [ maintainers.idontgetoutmuch ];
+    license     = licenses.bsd3;
+  };
+
+}
diff --git a/pkgs/development/libraries/swc/default.nix b/pkgs/development/libraries/swc/default.nix
deleted file mode 100644
index bbc3aa20dd60..000000000000
--- a/pkgs/development/libraries/swc/default.nix
+++ /dev/null
@@ -1,34 +0,0 @@
-{ lib, stdenv, fetchurl, pkgconfig
-, wld, wayland, xwayland, fontconfig, pixman, libdrm, libinput, libevdev, libxkbcommon, libxcb, xcbutilwm
-}:
-
-stdenv.mkDerivation rec {
-  name = "swc-${version}";
-  version = "git-2016-02-09";
-  repo = "https://github.com/michaelforney/swc";
-  rev = "1da0ef13fddc572accea12439a4471b4d2f64ddd";
-
-  src = fetchurl {
-    url = "${repo}/archive/${rev}.tar.gz";
-    sha256 = "d1894612d8aa1ce828efb78f1570290f84bba6563e21eb777e08c3c3859b7bbe";
-  };
-
-  nativeBuildInputs = [ pkgconfig ];
-
-  buildInputs = [ wld wayland xwayland fontconfig pixman libdrm libinput libevdev libxkbcommon libxcb xcbutilwm ];
-
-  prePatch = ''
-    substituteInPlace launch/local.mk --replace 4755 755
-  '';
-
-  makeFlags = "PREFIX=$(out)";
-  installPhase = "PREFIX=$out make install";
-
-  meta = {
-    description = "A library for making a simple Wayland compositor";
-    homepage    = repo;
-    license     = lib.licenses.mit;
-    platforms   = lib.platforms.linux;
-    maintainers = with lib.maintainers; [ ];
-  };
-}
diff --git a/pkgs/development/libraries/swiften/default.nix b/pkgs/development/libraries/swiften/default.nix
index e6fb5a2b6853..272967fcb996 100644
--- a/pkgs/development/libraries/swiften/default.nix
+++ b/pkgs/development/libraries/swiften/default.nix
@@ -1,14 +1,14 @@
 { stdenv, python, fetchurl, openssl, boost }:
 stdenv.mkDerivation rec {
   name    = "swiften-${version}";
-  version = "3.0beta2";
+  version = "4.0";
 
   buildInputs           = [ python ];
   propagatedBuildInputs = [ openssl boost ];
 
   src = fetchurl {
     url    = "http://swift.im/downloads/releases/swift-${version}/swift-${version}.tar.gz";
-    sha256 = "0i6ks122rry9wvg6qahk3yiggi7nlkpgws1z0r41vi4i1siq0ls0";
+    sha256 = "06bk45hxqmny8z7x78ycrfrazq6xdzv5c28i8x0lgc85j03b5dsh";
   };
   
   buildPhase = ''
diff --git a/pkgs/development/libraries/tachyon/default.nix b/pkgs/development/libraries/tachyon/default.nix
index b1649da6459f..53e48eb89317 100644
--- a/pkgs/development/libraries/tachyon/default.nix
+++ b/pkgs/development/libraries/tachyon/default.nix
@@ -1,17 +1,57 @@
-{stdenv, fetchurl}:
+{ stdenv
+, fetchurl
+, fetchpatch
+, Carbon ? null
+, libjpeg ? null
+, libpng ? null
+, withJpegSupport ? true # support jpeg output
+, withPngSupport ? true # support png output
+}:
+
+assert withJpegSupport -> libjpeg != null;
+assert withPngSupport -> libpng != null;
+assert stdenv.isDarwin -> Carbon != null;
+
 stdenv.mkDerivation rec {
   name = "tachyon-${version}";
-  version = "0.98.9";
+  version = "0.99b2";
   src = fetchurl {
     url = "http://jedi.ks.uiuc.edu/~johns/tachyon/files/${version}/${name}.tar.gz";
-    sha256 = "1ms0xr4ibrzz291ibm265lyjrdjrmhfrx0a70hwykhsdxn6jk8y6";
+    sha256 = "04m0bniszyg7ryknj8laj3rl5sspacw5nr45x59j2swcsxmdvn1v";
   };
-  buildInputs = [];
-  preBuild = "cd unix";
-  arch = if stdenv.system == "x86_64-linux" then "linux-64-thr" else
-         if stdenv.system == "i686-linux"   then "linux-thr"    else
+  buildInputs = stdenv.lib.optionals stdenv.isDarwin [
+    Carbon
+  ] ++ stdenv.lib.optionals withJpegSupport [
+    libjpeg
+  ] ++ stdenv.lib.optionals withPngSupport [
+    libpng
+  ];
+  preBuild = ''
+    cd unix
+  '' + stdenv.lib.optionalString withJpegSupport ''
+    export USEJPEG=" -DUSEJPEG"
+    export JPEGLIB=" -ljpeg"
+  '' + stdenv.lib.optionalString withPngSupport ''
+    export USEPNG=" -DUSEPNG"
+    export PNGLIB=" -lpng -lz"
+  '';
+  arch = if stdenv.system == "x86_64-linux"   then "linux-64-thr"  else
+         if stdenv.system == "i686-linux"     then "linux-thr"     else
+         if stdenv.system == "aarch64-linux"  then "linux-arm-thr" else
+         if stdenv.system == "x86_64-darwin"  then "macosx-thr"    else
+         if stdenv.system == "i686-darwin"    then "macosx-64-thr" else
+         if stdenv.system == "i686-cygwin"    then "win32"         else
+         if stdenv.system == "x86_64-freebsd" then "bsd"           else
+         if stdenv.system == "x686-freebsd"   then "bsd"           else
          throw "Don't know what arch to select for tachyon build";
   makeFlags = "${arch}";
+  patches = [
+    # Remove absolute paths in Make-config (and unset variables so they can be set in preBuild)
+    ./no-absolute-paths.patch
+    # Include new targets (like arm)
+    ./make-archs.patch
+  ];
+
   installPhase = ''
     cd ../compile/${arch}
     mkdir -p "$out"/{bin,lib,include,share/doc/tachyon,share/tachyon}
@@ -26,7 +66,8 @@ stdenv.mkDerivation rec {
     description = ''A Parallel / Multiprocessor Ray Tracing System'';
     license = stdenv.lib.licenses.bsd3;
     maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.linux;
+    # darwin fails due to missing Carbon.h, even though Carbon is a build input
+    platforms = with stdenv.lib.platforms; linux ++ cygwin;
     homepage = http://jedi.ks.uiuc.edu/~johns/tachyon/;
   };
 }
diff --git a/pkgs/development/libraries/tachyon/make-archs.patch b/pkgs/development/libraries/tachyon/make-archs.patch
new file mode 100644
index 000000000000..cf83f8c8c31c
--- /dev/null
+++ b/pkgs/development/libraries/tachyon/make-archs.patch
@@ -0,0 +1,37 @@
+diff --git a/unix/Make-arch b/unix/Make-arch
+index 08afb85..dbeb691 100644
+--- a/unix/Make-arch
++++ b/unix/Make-arch
+@@ -920,6 +920,15 @@ macosx:
+ 	"RANLIB = ranlib" \
+ 	"LIBS = -L. -ltachyon $(MISCLIB)"
+ 
++macosx-64:
++	$(MAKE) all \
++	"ARCH = macosx" \
++	"CFLAGS = -Os -m64 -ffast-math -DBsd $(MISCFLAGS)" \
++	"ARFLAGS = r" \
++	"STRIP = strip" \
++	"RANLIB = ranlib" \
++	"LIBS = -L. -ltachyon $(MISCLIB)"
++
+ macosx-thr:
+ 	$(MAKE) all \
+ 	"ARCH = macosx-thr" \
+@@ -1209,6 +1218,16 @@ linux-thr:
+ 	"RANLIB = ranlib" \
+ 	"LIBS = -L. -ltachyon $(MISCLIB) -lm -lpthread"
+ 
++# Linux Arm using gcc, with threads
++linux-arm-thr:
++	$(MAKE) all \
++	"ARCH = linux-arm-thr" \
++	"CFLAGS = -Wall -O3 -fomit-frame-pointer -ffast-math -DLinux -DTHR -D_REENTRANT $(MISCFLAGS)" \
++	"ARFLAGS = r" \
++	"STRIP = strip" \
++	"RANLIB = ranlib" \
++	"LIBS = -L. -ltachyon $(MISCLIB) -lm -lpthread"
++
+ # Linux x86 using gcc, threads, and OpenGL
+ linux-thr-ogl:
+ 	$(MAKE) all \
diff --git a/pkgs/development/libraries/tachyon/no-absolute-paths.patch b/pkgs/development/libraries/tachyon/no-absolute-paths.patch
new file mode 100644
index 000000000000..faa3810fb5c6
--- /dev/null
+++ b/pkgs/development/libraries/tachyon/no-absolute-paths.patch
@@ -0,0 +1,57 @@
+diff --git a/unix/Make-config b/unix/Make-config
+index ee4f388..c1d51d4 100644
+--- a/unix/Make-config
++++ b/unix/Make-config
+@@ -18,7 +18,7 @@
+ # Bourne Shell Configuration:
+ #   set SHELL=/bin/sh or wherever your bourne shell is
+ ##########################################################################
+-SHELL=/bin/sh
++# SHELL=/bin/sh
+ 
+ 
+ 
+@@ -30,7 +30,7 @@ SHELL=/bin/sh
+ 
+ # The following line should be set to -Ixxx where xxx is your X11 include path
+ # Sun puts X11 in /usr/openwin/xxx
+-X11INC= -I/usr/openwin/include
++# X11INC= -I/usr/openwin/include
+ 
+ # Others typically use /usr/X11 or /usr/X11R6
+ #X11INC= -I/usr/X11
+@@ -57,7 +57,7 @@ X11LIB= -lX11
+ ##########################################################################
+ 
+ # Standard MPICH installation location
+-MPIDIR=/usr/local/mpi
++# MPIDIR=/usr/local/mpi
+ 
+ # UMR CS Dept
+ #MPIDIR=/software/all/mpi
+@@ -108,9 +108,9 @@ MBOX=
+ #   http://www.ijg.org/files/
+ ##########################################################################
+ # Uncomment the following lines to disable JPEG support
+-USEJPEG=
+-JPEGINC=
+-JPEGLIB=
++# USEJPEG=
++# JPEGINC=
++# JPEGLIB=
+ 
+ # Uncomment the following lines to enable JPEG support
+ #USEJPEG= -DUSEJPEG
+@@ -128,9 +128,9 @@ JPEGLIB=
+ #   http://www.libpng.org/
+ ##########################################################################
+ # Uncomment the following lines to disable PNG support
+-USEPNG=
+-PNGINC=
+-PNGLIB=
++# USEPNG=
++# PNGINC=
++# PNGLIB=
+ 
+ # Uncomment the following lines to enable PNG support
+ #USEPNG= -DUSEPNG
diff --git a/pkgs/development/libraries/taglib/1.9.nix b/pkgs/development/libraries/taglib/1.9.nix
index 71b8a764eed1..1caa8a376fb1 100644
--- a/pkgs/development/libraries/taglib/1.9.nix
+++ b/pkgs/development/libraries/taglib/1.9.nix
@@ -8,10 +8,9 @@ stdenv.mkDerivation rec {
     sha256 = "06n7gnbcqa3r6c9gv00y0y1r48dyyazm6yj403i7ma0r2k6p3lvj";
   };
 
-  cmakeFlags = "-DWITH_ASF=ON -DWITH_MP4=ON";
+  nativeBuildInputs = [ cmake ];
 
   buildInputs = [ zlib ];
-  nativeBuildInputs = [ cmake ];
 
   meta = {
     homepage = http://developer.kde.org/~wheeler/taglib.html;
diff --git a/pkgs/development/libraries/taglib/default.nix b/pkgs/development/libraries/taglib/default.nix
index 602aab852ccc..67db6e5097d0 100644
--- a/pkgs/development/libraries/taglib/default.nix
+++ b/pkgs/development/libraries/taglib/default.nix
@@ -1,24 +1,40 @@
-{stdenv, fetchurl, zlib, cmake}:
+{stdenv, fetchurl, zlib, cmake, fetchpatch}:
 
 stdenv.mkDerivation rec {
-  name = "taglib-1.10";
+  name = "taglib-1.11.1";
 
   src = fetchurl {
-    url = "http://taglib.github.io/releases/${name}.tar.gz";
-    sha256 = "1alv6vp72p0x9i9yscmz2a71anjwqy53y9pbcbqxvc1c0i82vhr4";
+    url = "http://taglib.org/releases/${name}.tar.gz";
+    sha256 = "0ssjcdjv4qf9liph5ry1kngam1y7zp8fzr9xv4wzzrma22kabldn";
   };
 
-  cmakeFlags = "-DWITH_ASF=ON -DWITH_MP4=ON";
+  patches = [
+    (fetchpatch {
+      # https://github.com/taglib/taglib/issues/829
+      name = "CVE-2017-12678.patch";
+      url = "https://github.com/taglib/taglib/commit/eb9ded1206f18.patch";
+      sha256 = "1bvpxsvmlpi3by7myzss9kkpdkv405612n8ff68mw1ambj8h1m90";
+    })
+  ];
 
-  buildInputs = [ zlib ];
   nativeBuildInputs = [ cmake ];
 
-  meta = {
-    homepage = http://developer.kde.org/~wheeler/taglib.html;
-    repositories.git = git://github.com/taglib/taglib.git;
+  buildInputs = [ zlib ];
 
-    description = "A library for reading and editing the meta-data of several popular audio formats";
+  cmakeFlags = [ "-DBUILD_SHARED_LIBS=ON" ];
+
+  meta = with stdenv.lib; {
+    homepage = http://taglib.org/;
+    repositories.git = git://github.com/taglib/taglib.git;
+    description = "A library for reading and editing audio file metadata.";
+    longDescription = ''
+      TagLib is a library for reading and editing the meta-data of several
+      popular audio formats. Currently it supports both ID3v1 and ID3v2 for MP3
+      files, Ogg Vorbis comments and ID3 tags and Vorbis comments in FLAC, MPC,
+      Speex, WavPack, TrueAudio, WAV, AIFF, MP4 and ASF files.
+    '';
+    license = with licenses; [ lgpl3 mpl11 ];
     inherit (cmake.meta) platforms;
-    maintainers = [ ];
+    maintainers = with maintainers; [ ttuegel ];
   };
 }
diff --git a/pkgs/development/libraries/talloc/default.nix b/pkgs/development/libraries/talloc/default.nix
index 1e7448b66050..1d6818276eb8 100644
--- a/pkgs/development/libraries/talloc/default.nix
+++ b/pkgs/development/libraries/talloc/default.nix
@@ -3,11 +3,11 @@
 }:
 
 stdenv.mkDerivation rec {
-  name = "talloc-2.1.8";
+  name = "talloc-2.1.12";
 
   src = fetchurl {
     url = "mirror://samba/talloc/${name}.tar.gz";
-    sha256 = "0c3ihyb0jd8mhvi7gg2mr5w1zl2habx6jlkbyxzyckad2q8lkl92";
+    sha256 = "0jv0ri9vj93fczzgl7rn7xvnfgl2kfx4x85cr8h8v52yh7v0qz4q";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/tbb/default.nix b/pkgs/development/libraries/tbb/default.nix
index 13b1970866e7..182fbb35d499 100644
--- a/pkgs/development/libraries/tbb/default.nix
+++ b/pkgs/development/libraries/tbb/default.nix
@@ -16,6 +16,8 @@ with stdenv.lib; stdenv.mkDerivation rec {
     optional (stdver != null) "stdver=${stdver}"
   );
 
+  patches = stdenv.lib.optional stdenv.hostPlatform.isMusl ./glibc-struct-mallinfo.patch;
+
   installPhase = ''
     mkdir -p $out/{lib,share/doc}
     cp "build/"*release*"/"*${stdenv.hostPlatform.extensions.sharedLibrary}* $out/lib/
diff --git a/pkgs/development/libraries/tbb/glibc-struct-mallinfo.patch b/pkgs/development/libraries/tbb/glibc-struct-mallinfo.patch
new file mode 100644
index 000000000000..64056ecb1462
--- /dev/null
+++ b/pkgs/development/libraries/tbb/glibc-struct-mallinfo.patch
@@ -0,0 +1,43 @@
+From b577153a10c98f4e13405dc93ea2ab1a7b990e07 Mon Sep 17 00:00:00 2001
+From: David Huffman <storedbox+alpine@outlook.com>
+Date: Wed, 6 Jan 2016 07:09:30 -0500
+Subject: [PATCH] hard-code glibc's definition of struct mallinfo
+
+---
+ src/tbbmalloc/proxy.h | 20 ++++++++++++++++++++
+ 1 file changed, 20 insertions(+)
+
+diff --git a/src/tbbmalloc/proxy.h b/src/tbbmalloc/proxy.h
+index 781cadc..e1ea1ae 100644
+--- a/src/tbbmalloc/proxy.h
++++ b/src/tbbmalloc/proxy.h
+@@ -32,6 +32,26 @@
+ 
+ #include <stddef.h>
+ 
++// The following definition was taken from /usr/include/malloc.h as provided by
++// the glibc-devel-2.19-17.4.x86_64 package on openSUSE Leap 42.1; it is
++// made available under the GNU Lesser General Public License v2.1 or later.
++// See <https://www.gnu.org/licenses>.
++//
++// Copyright (C) 1996-2014 Free Software Foundation, Inc.
++struct mallinfo
++{
++  int arena;    /* non-mmapped space allocated from system */
++  int ordblks;  /* number of free chunks */
++  int smblks;   /* number of fastbin blocks */
++  int hblks;    /* number of mmapped regions */
++  int hblkhd;   /* space in mmapped regions */
++  int usmblks;  /* maximum total allocated space */
++  int fsmblks;  /* space available in freed fastbin blocks */
++  int uordblks; /* total allocated space */
++  int fordblks; /* total free space */
++  int keepcost; /* top-most, releasable (via malloc_trim) space */
++};
++
+ extern "C" {
+     void * scalable_malloc(size_t size);
+     void * scalable_calloc(size_t nobj, size_t size);
+-- 
+2.6.2
+
diff --git a/pkgs/development/libraries/tclap/default.nix b/pkgs/development/libraries/tclap/default.nix
index 276b279fc09e..a92c7b74ebf7 100644
--- a/pkgs/development/libraries/tclap/default.nix
+++ b/pkgs/development/libraries/tclap/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "tclap-1.2.1";
+  name = "tclap-1.2.2";
 
   src = fetchurl {
     url = "mirror://sourceforge/tclap/${name}.tar.gz";
-    sha256 = "1fzf7l1wvlhxnpwi15jvvfizn836s7r0r8vckgbqk2lyf7ihz7wz";
+    sha256 = "0dsqvsgzam3mypj2ladn6v1yjq9zd47p3lg21jx6kz5azkkkn0gm";
   };
 
   meta = {
diff --git a/pkgs/development/libraries/tcllib/default.nix b/pkgs/development/libraries/tcllib/default.nix
index 75b811df30c3..6ffbe5dc60c5 100644
--- a/pkgs/development/libraries/tcllib/default.nix
+++ b/pkgs/development/libraries/tcllib/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "tcllib-${version}";
-  version = "1.18";
+  version = "1.19";
 
   src = fetchurl {
     url = "mirror://sourceforge/tcllib/tcllib-${version}.tar.gz";
-    sha256 = "05dmrk9qsryah2n17z6z85dj9l9lfyvnsd7faw0p9bs1pp5pwrkj";
+    sha256 = "173abxaazdmf210v651708ab6h7xhskvd52krxk6ifam337qgzh1";
   };
 
   passthru = {
diff --git a/pkgs/development/libraries/tdb/default.nix b/pkgs/development/libraries/tdb/default.nix
index 7ccd98856f62..d372c61dbe28 100644
--- a/pkgs/development/libraries/tdb/default.nix
+++ b/pkgs/development/libraries/tdb/default.nix
@@ -3,11 +3,11 @@
 }:
 
 stdenv.mkDerivation rec {
-  name = "tdb-1.3.11";
+  name = "tdb-1.3.15";
 
   src = fetchurl {
     url = "mirror://samba/tdb/${name}.tar.gz";
-    sha256 = "0i1l38h0vyck6zkcj4fn2l03spadlmyr1qa1xpdp9dy2ccbm3s1r";
+    sha256 = "0a37jhpij8wr4f4pjqdlwnffy2l6a2vkqdpz1bqxj6v06cwbz8dl";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/telepathy/farstream/default.nix b/pkgs/development/libraries/telepathy/farstream/default.nix
index aed08435a149..41308a7ef4ec 100644
--- a/pkgs/development/libraries/telepathy/farstream/default.nix
+++ b/pkgs/development/libraries/telepathy/farstream/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, telepathy_glib, farstream, dbus_glib }:
+{ stdenv, fetchurl, pkgconfig, telepathy-glib, farstream, dbus-glib }:
 
 stdenv.mkDerivation rec {
   name = "${pname}-0.6.2";
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
     sha256 = "02ky12bb92prr5f6xmvmfq4yz2lj33li6nj4829a98hk5pr9k83g";
   };
 
-  propagatedBuildInputs = [ dbus_glib telepathy_glib farstream ];
+  propagatedBuildInputs = [ dbus-glib telepathy-glib farstream ];
   nativeBuildInputs = [ pkgconfig ];
 
   meta = {
diff --git a/pkgs/development/libraries/telepathy/glib/default.nix b/pkgs/development/libraries/telepathy/glib/default.nix
index fffe677f6a71..df5c76abd7cd 100644
--- a/pkgs/development/libraries/telepathy/glib/default.nix
+++ b/pkgs/development/libraries/telepathy/glib/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, dbus_glib, glib, python2, pkgconfig, libxslt
+{ stdenv, fetchurl, dbus-glib, glib, python2, pkgconfig, libxslt
 , gobjectIntrospection, valaSupport ? true, vala_0_38, glibcLocales }:
 
 stdenv.mkDerivation rec {
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
 
   configureFlags = stdenv.lib.optional valaSupport "--enable-vala-bindings";
   LC_ALL = "en_US.UTF-8";
-  propagatedBuildInputs = [dbus_glib glib gobjectIntrospection];
+  propagatedBuildInputs = [dbus-glib glib gobjectIntrospection];
 
   nativeBuildInputs = [ pkgconfig libxslt ] ++ stdenv.lib.optional valaSupport vala_0_38;
   buildInputs = [ glibcLocales python2 ];
diff --git a/pkgs/development/libraries/telepathy/qt/default.nix b/pkgs/development/libraries/telepathy/qt/default.nix
index 93d69d5a8d99..90dd47c11e2f 100644
--- a/pkgs/development/libraries/telepathy/qt/default.nix
+++ b/pkgs/development/libraries/telepathy/qt/default.nix
@@ -1,54 +1,40 @@
-{ stdenv, fetchurl, cmake, qtbase, pkgconfig, python2Packages, dbus_glib, dbus_daemon
-, telepathy_farstream, telepathy_glib, fetchpatch }:
+{ stdenv, fetchurl, cmake, qtbase, pkgconfig, python2Packages, dbus-glib, dbus_daemon
+, telepathy-farstream, telepathy-glib, fetchpatch }:
 
 let
   inherit (python2Packages) python dbus-python;
 in stdenv.mkDerivation rec {
-  name = "telepathy-qt-0.9.6.1";
+  name = "telepathy-qt-0.9.7";
 
   src = fetchurl {
     url = "http://telepathy.freedesktop.org/releases/telepathy-qt/${name}.tar.gz";
-    sha256 = "1y51c6rxk5qvmab98c8rnmrlyk27hnl248casvbq3cd93sav8vj9";
+    sha256 = "0krxd4hhfx6r0ja19wh3848j7gn1rv8jrnakgmkbmi7bww5x7fi1";
   };
 
-  patches = let
-    mkUrl = hash: "http://cgit.freedesktop.org/telepathy/telepathy-qt/patch/?id=" + hash;
-    in [
-      (fetchpatch {
-        name = "gst-1.6.patch";
-        url = mkUrl "ec4a3d62b68a57254515f01fc5ea3325ffb1dbfb";
-        sha256 = "1rh7n3xyrwpvpa3haqi35qn4mfz4396ha43w4zsqpmcyda9y65v2";
-      })
-      (fetchpatch {
-        name = "parallel-make-1.patch";
-        url = mkUrl "1e1f53e9d91684918c34ec50392f86287e001a1e";
-        sha256 = "1f9nk0bi90armb9zay53c7cz70zcwqqwli7sb9wgw76rmwqhl8qw";
-      })
-      (fetchpatch {
-        name = "parallel-make-2.patch";
-        url = mkUrl "7389dc990c67d4269f3a79c924c054e87f2e4ac5";
-        sha256 = "0mvdvyy76kpaxacljidf06wd43fr2qripr4mwsakjs3hxb1pkk57";
-      })
-    ];
-
   nativeBuildInputs = [ cmake pkgconfig python ];
-  propagatedBuildInputs = [ qtbase dbus_glib telepathy_farstream telepathy_glib dbus-python ];
-
-  buildInputs = stdenv.lib.optional doCheck dbus_daemon;
-
-  cmakeFlags = "-DDESIRED_QT_VERSION=${builtins.substring 0 1 qtbase.version}";
-
-  # should be removable after the next update
-  NIX_CFLAGS_COMPILE = [ "-Wno-error" ];
-
-  preBuild = ''
-    NIX_CFLAGS_COMPILE+=" `pkg-config --cflags dbus-glib-1`"
-  '';
+  propagatedBuildInputs = [ qtbase telepathy-farstream telepathy-glib ];
+  buildInputs = [ dbus-glib ];
+  checkInputs = [ dbus_daemon dbus-python ];
+
+  patches = [
+    # https://github.com/TelepathyIM/telepathy-qt/issues/25
+    (fetchpatch {
+      url = https://github.com/TelepathyIM/telepathy-qt/commit/d654dc70dbec7097e96e6d96ca74ab1b5b00ef8c.patch;
+      sha256 = "1jzd9b9rqh3c8xlq8dr7c0r8aabzf5ywv2gpkk6phh3xwngzrfbh";
+    })
+  ];
+
+  # No point in building tests if they are not run
+  # On 0.9.7, they do not even build with QT4
+  cmakeFlags = stdenv.lib.optional (!doCheck) "-DENABLE_TESTS=OFF";
 
   enableParallelBuilding = true;
   doCheck = false; # giving up for now
 
-  meta = {
-    platforms = stdenv.lib.platforms.linux;
+  meta = with stdenv.lib; {
+    description = "Telepathy Qt bindings";
+    homepage = https://telepathy.freedesktop.org/components/telepathy-qt/;
+    license = licenses.lgpl21;
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/tevent/default.nix b/pkgs/development/libraries/tevent/default.nix
index 2982d33e9962..154db61894fa 100644
--- a/pkgs/development/libraries/tevent/default.nix
+++ b/pkgs/development/libraries/tevent/default.nix
@@ -3,11 +3,11 @@
 }:
 
 stdenv.mkDerivation rec {
-  name = "tevent-0.9.30";
+  name = "tevent-0.9.36";
 
   src = fetchurl {
     url = "mirror://samba/tevent/${name}.tar.gz";
-    sha256 = "1gccqiibf6ia129xhqrg18anax3sxwfbwm8h4pvsga3ndxg931ap";
+    sha256 = "0k1v4vnlzpf7h3p4khaw8a7damrc68g136bf2xzys08nzpinnaxx";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/theft/default.nix b/pkgs/development/libraries/theft/default.nix
index a0110c5f22b2..2a1180533cea 100644
--- a/pkgs/development/libraries/theft/default.nix
+++ b/pkgs/development/libraries/theft/default.nix
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "A C library for property-based testing";
     platforms = stdenv.lib.platforms.linux;
-    homepage = "http://github.com/silentbicycle/theft/";
+    homepage = "https://github.com/silentbicycle/theft/";
     license = stdenv.lib.licenses.isc;
     maintainers = [ stdenv.lib.maintainers.kquick ];
   };
diff --git a/pkgs/development/libraries/thrift/default.nix b/pkgs/development/libraries/thrift/default.nix
index 55855d05d16e..45e5174ed573 100644
--- a/pkgs/development/libraries/thrift/default.nix
+++ b/pkgs/development/libraries/thrift/default.nix
@@ -4,11 +4,11 @@
 
 stdenv.mkDerivation rec {
   name = "thrift-${version}";
-  version = "0.10.0";
+  version = "0.11.0";
 
   src = fetchurl {
     url = "http://archive.apache.org/dist/thrift/${version}/${name}.tar.gz";
-    sha256 = "02x1xw0l669idkn6xww39j60kqxzcbmim4mvpb5h9nz8wqnx1292";
+    sha256 = "1hk0zb9289gf920rdl0clmwqx6kvygz92nj01lqrhd2arfv3ibf4";
   };
 
   #enableParallelBuilding = true; problems on hydra
diff --git a/pkgs/development/libraries/ti-rpc/default.nix b/pkgs/development/libraries/ti-rpc/default.nix
index d66b5d82ff52..99f0bb65441c 100644
--- a/pkgs/development/libraries/ti-rpc/default.nix
+++ b/pkgs/development/libraries/ti-rpc/default.nix
@@ -1,13 +1,21 @@
-{ fetchurl, stdenv, autoreconfHook, libkrb5 }:
+{ fetchurl, fetchpatch, stdenv, autoreconfHook, libkrb5 }:
 
 stdenv.mkDerivation rec {
-  name = "libtirpc-1.0.2";
+  name = "libtirpc-1.0.3";
 
   src = fetchurl {
     url = "mirror://sourceforge/libtirpc/${name}.tar.bz2";
-    sha256 = "1xchbxy0xql7yl7z4n1icj8r7dmly46i22fvm00vdjq64zlmqg3j";
+    sha256 = "0ppxl3k3nsz0qdakq844i2kj4fvh9h937lhx26bgmpmxq67sghw6";
   };
 
+  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 ];
   propagatedBuildInputs = [ libkrb5 ];
 
@@ -20,7 +28,7 @@ stdenv.mkDerivation rec {
   doCheck = true;
 
   meta = with stdenv.lib; {
-    homepage = http://sourceforge.net/projects/libtirpc/;
+    homepage = https://sourceforge.net/projects/libtirpc/;
     description = "The transport-independent Sun RPC implementation (TI-RPC)";
     license = licenses.bsd3;
     platforms = platforms.linux;
diff --git a/pkgs/development/libraries/tinyxml-2/default.nix b/pkgs/development/libraries/tinyxml-2/default.nix
index 9011d33e9222..7f1b3ebcbf5b 100644
--- a/pkgs/development/libraries/tinyxml-2/default.nix
+++ b/pkgs/development/libraries/tinyxml-2/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "tinyxml-2-${version}";
-  version = "4.0.1";
+  version = "6.0.0";
 
   src = fetchFromGitHub {
     repo = "tinyxml2";
     owner = "leethomason";
     rev = version;
-    sha256 = "1a0skfi8rzk53qcxbv88qlvhlqzvsvg4hm20dnx4zw7vrn6anr9y";
+    sha256 = "031fmhpah449h3rkyamzzdpzccrrfrvjb4qn6vx2vjm47jwc54qv";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/tnt/default.nix b/pkgs/development/libraries/tnt/default.nix
index 5e3d16000004..23ef997e5ce1 100644
--- a/pkgs/development/libraries/tnt/default.nix
+++ b/pkgs/development/libraries/tnt/default.nix
@@ -5,7 +5,7 @@ stdenv.mkDerivation rec {
   version = "3.0.12";
   
   src = fetchurl {
-    url = http://math.nist.gov/tnt/tnt_3_0_12.zip;
+    url = https://math.nist.gov/tnt/tnt_3_0_12.zip;
     sha256 = "1bzkfdb598584qlc058n8wqq9vbz714gr5r57401rsa9qaxhk5j7";
   };
 
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
   '';
 
   meta = {
-    homepage = http://math.nist.gov/tnt/;
+    homepage = https://math.nist.gov/tnt/;
     description = "Template Numerical Toolkit: C++ headers for array and matrices";
     platforms = stdenv.lib.platforms.unix;
   };
diff --git a/pkgs/development/libraries/tntdb/default.nix b/pkgs/development/libraries/tntdb/default.nix
index d11a5c344c9d..75a494cfbded 100644
--- a/pkgs/development/libraries/tntdb/default.nix
+++ b/pkgs/development/libraries/tntdb/default.nix
@@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
     sha256 = "0js79dbvkic30bzw1pf26m64vs2ssw2sbj55w1dc0sy69dlv4fh9";
   };
 
-  buildInputs = [ cxxtools postgresql mysql sqlite zlib openssl ];
+  buildInputs = [ cxxtools postgresql mysql.connector-c sqlite zlib openssl ];
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/tremor/default.nix b/pkgs/development/libraries/tremor/default.nix
index fec256e703fe..5609f1d67d17 100644
--- a/pkgs/development/libraries/tremor/default.nix
+++ b/pkgs/development/libraries/tremor/default.nix
@@ -1,12 +1,12 @@
-{ stdenv, fetchsvn, autoreconfHook, pkgconfig, libogg }:
+{ stdenv, fetchgit, autoreconfHook, pkgconfig, libogg }:
 
 stdenv.mkDerivation rec {
-  name = "tremor-svn-${src.rev}";
+  name = "tremor-unstable-2018-03-16";
 
-  src = fetchsvn {
-    url = http://svn.xiph.org/trunk/Tremor;
-    rev = "17866";
-    sha256 = "161411cbefa1527da7a8fc087e78d8e21d19143d3a6eb42fb281e5026aad7568";
+  src = fetchgit {
+    url = https://git.xiph.org/tremor.git;
+    rev = "562307a4a7082e24553f3d2c55dab397a17c4b4f";
+    sha256 = "0m07gq4zfgigsiz8b518xyb19v7qqp76qmp7lb262825vkqzl3zq";
   };
 
   nativeBuildInputs = [ autoreconfHook pkgconfig ];
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
   '';
 
   meta = {
-    homepage = http://xiph.org/tremor/;
+    homepage = https://xiph.org/tremor/;
     description = "Fixed-point version of the Ogg Vorbis decoder";
     license = stdenv.lib.licenses.bsd3;
     platforms = stdenv.lib.platforms.unix;
diff --git a/pkgs/development/libraries/udunits/default.nix b/pkgs/development/libraries/udunits/default.nix
index 8fa974a95e24..b02ac8852371 100644
--- a/pkgs/development/libraries/udunits/default.nix
+++ b/pkgs/development/libraries/udunits/default.nix
@@ -3,17 +3,17 @@
 }:
 
 stdenv.mkDerivation rec {
-    name = "udunits-2.2.24";
+    name = "udunits-2.2.26";
     src = fetchurl {
         url = "ftp://ftp.unidata.ucar.edu/pub/udunits/${name}.tar.gz";
-        sha256 = "15bz2wv46wiwdzai8770gzy05prgj120x6j2hmihavv5y89cbfi0";
+        sha256 = "0v9mqw4drnkzkm57331ail6yvs9485jmi37s40lhvmf7r5lli3rn";
     };
 
     nativeBuildInputs = [ bison flex file ];
     buildInputs = [ expat ];
 
     meta = with stdenv.lib; {
-      homepage = http://www.unidata.ucar.edu/software/udunits/;
+      homepage = https://www.unidata.ucar.edu/software/udunits/;
       description = "A C-based package for the programatic handling of units of physical quantities";
       license = licenses.bsdOriginal;
       platforms = platforms.linux;
diff --git a/pkgs/development/libraries/uhttpmock/default.nix b/pkgs/development/libraries/uhttpmock/default.nix
index 26c040721bdf..377ceba59e70 100644
--- a/pkgs/development/libraries/uhttpmock/default.nix
+++ b/pkgs/development/libraries/uhttpmock/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchFromGitLab, autoconf, gtk_doc, automake, libtool, pkgconfig, glib, libsoup, gobjectIntrospection }:
+{ stdenv, lib, fetchFromGitLab, autoconf, gtk-doc, automake, libtool, pkgconfig, glib, libsoup, gobjectIntrospection }:
 
 stdenv.mkDerivation rec {
   version="0.5.0";
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ autoconf gtk_doc automake libtool glib libsoup gobjectIntrospection ];
+  buildInputs = [ autoconf gtk-doc automake libtool glib libsoup gobjectIntrospection ];
 
   preConfigure = "./autogen.sh";
 
diff --git a/pkgs/development/libraries/uid_wrapper/default.nix b/pkgs/development/libraries/uid_wrapper/default.nix
index 9a2f6eb203a1..ccd876dfefbd 100644
--- a/pkgs/development/libraries/uid_wrapper/default.nix
+++ b/pkgs/development/libraries/uid_wrapper/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, cmake, pkgconfig }:
 
 stdenv.mkDerivation rec {
-  name = "uid_wrapper-1.2.0";
+  name = "uid_wrapper-1.2.4";
 
   src = fetchurl {
     url = "mirror://samba/cwrap/${name}.tar.gz";
-    sha256 = "0sfznk53kmz9m3rxwbv4pwwqs4bw3kr917y4n53h5jaxjym0m4c0";
+    sha256 = "1yjhrm3rcyiykkrgpifmig117mzjxrms75kp8gpp8022f59zcq1w";
   };
 
   nativeBuildInputs = [ cmake pkgconfig ];
diff --git a/pkgs/development/libraries/umockdev/default.nix b/pkgs/development/libraries/umockdev/default.nix
index fdf882ce817e..fb43af362433 100644
--- a/pkgs/development/libraries/umockdev/default.nix
+++ b/pkgs/development/libraries/umockdev/default.nix
@@ -1,29 +1,26 @@
-{ stdenv, fetchFromGitHub, autoreconfHook
-, pkgconfig, glib, systemd, libgudev, vala  }:
+{ stdenv, fetchFromGitHub, automake, autoconf, libtool, gtk-doc
+, pkgconfig, glib, systemd, libgudev, vala }:
 
 stdenv.mkDerivation rec {
-  name = "umockdev";
-  version = "0.8.13";
+  name = "umockdev-${version}";
+  version = "0.11.2";
 
   src = fetchFromGitHub {
     owner = "martinpitt";
     repo = "umockdev";
     rev = version;
-    sha256 ="0bw2dpshlgbdwg5mhq4j22z474llpqix8pxii63r2bk5nhjc537k";
+    sha256 ="1dvhs9nkznlnagzjny61fh574g42c47b9s5hxsqdgqb51njawdg1";
   };
 
-  buildInputs = [ glib systemd libgudev vala ];
-  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ glib systemd libgudev ];
+  nativeBuildInputs = [ automake autoconf libtool gtk-doc pkgconfig vala ];
 
-  ### docs/gtk-doc.make not found
-  prePatch = ''
-    sed -i 's|include $(top_srcdir)/docs/gtk-doc.make||g' docs/reference/Makefile.am
-   sed -i 's|+=|=|g' docs/reference/Makefile.am
-   '';
+  preConfigure = "NOCONFIGURE=1 ./autogen.sh";
 
   meta = with stdenv.lib; {
     description = "Mock hardware devices for creating unit tests";
     license = licenses.lgpl2;
     maintainers = [ maintainers.ndowens ];
+    platforms = with platforms; linux;
   };
 }
diff --git a/pkgs/development/libraries/unibilium/default.nix b/pkgs/development/libraries/unibilium/default.nix
index 53207f855418..7c92e7224f9e 100644
--- a/pkgs/development/libraries/unibilium/default.nix
+++ b/pkgs/development/libraries/unibilium/default.nix
@@ -1,21 +1,21 @@
-{ stdenv, lib, fetchFromGitHub, libtool, pkgconfig }:
+{ stdenv, lib, fetchFromGitHub, libtool, pkgconfig, perl }:
 
 stdenv.mkDerivation rec {
   name = "unibilium-${version}";
 
-  version = "1.2.1";
+  version = "2.0.0";
 
   src = fetchFromGitHub {
     owner = "mauke";
     repo = "unibilium";
     rev = "v${version}";
-    sha256 = "11mbfijdrvbmdlmxs8j4vij78ki0vna89yg3r9n9g1i6j45hiq2r";
+    sha256 = "1wa9a32wzqnxqh1jh554afj13dzjr6mw2wzqzw8d08nza9pg2ra2";
   };
 
   makeFlags = [ "PREFIX=$(out)" ]
     ++ stdenv.lib.optional stdenv.isDarwin "LIBTOOL=${libtool}/bin/libtool";
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig perl ];
   buildInputs = [ libtool ];
 
   meta = with lib; {
diff --git a/pkgs/development/libraries/unicorn-emu/default.nix b/pkgs/development/libraries/unicorn-emu/default.nix
new file mode 100644
index 000000000000..9f9d8e62de50
--- /dev/null
+++ b/pkgs/development/libraries/unicorn-emu/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchurl, bash, pkgconfig, python }:
+
+stdenv.mkDerivation rec {
+  name    = "unicorn-emulator-${version}";
+  version = "1.0.1";
+
+  src = fetchurl {
+    url    = "https://github.com/unicorn-engine/unicorn/archive/${version}.tar.gz";
+    sha256 = "0z01apwmvhvdldm372ww9pjfn45awkw3m90c0h4v0nj0ihmlysis";
+  };
+
+  configurePhase = '' patchShebangs make.sh '';
+  buildPhase = '' ./make.sh '';
+  installPhase = '' env PREFIX=$out ./make.sh install '';
+
+  nativeBuildInputs = [ pkgconfig python ];
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "Lightweight multi-platform CPU emulator library";
+    homepage    = "http://www.unicorn-engine.org";
+    license     = stdenv.lib.licenses.bsd3;
+    platforms   = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
+  };
+}
diff --git a/pkgs/development/libraries/unittest-cpp/default.nix b/pkgs/development/libraries/unittest-cpp/default.nix
index 97cffbf0f75b..90a28df6a15a 100644
--- a/pkgs/development/libraries/unittest-cpp/default.nix
+++ b/pkgs/development/libraries/unittest-cpp/default.nix
@@ -4,13 +4,13 @@ with stdenv.lib;
 
 stdenv.mkDerivation rec {
   name = "unittest-cpp-${version}";
-  version = "1.6.1";
+  version = "2.0.0";
 
   src = fetchFromGitHub {
     owner = "unittest-cpp";
     repo = "unittest-cpp";
     rev = "v${version}";
-    sha256 = "1sva2bm90z4vmwwvp0af82f7p4sdq5j2jjqzhs2ppihdkggn62d1";
+    sha256 = "0sxb3835nly1jxn071f59fwbdzmqi74j040r81fanxyw3s1azw0i";
   };
 
   buildInputs = [cmake];
diff --git a/pkgs/development/libraries/unixODBC/default.nix b/pkgs/development/libraries/unixODBC/default.nix
index 99ab8a056162..ccd243e1f735 100644
--- a/pkgs/development/libraries/unixODBC/default.nix
+++ b/pkgs/development/libraries/unixODBC/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "unixODBC-${version}";
-  version = "2.3.4";
+  version = "2.3.6";
 
   src = fetchurl {
     url = "ftp://ftp.unixodbc.org/pub/unixODBC/${name}.tar.gz";
-    sha256 = "0f8y88rcc2akjvjv5y66yx7k0ms9h1s0vbcfy25j93didflhj59f";
+    sha256 = "0sads5b8cmmj526gyjba7ccknl1vbhkslfqshv1yqln08zv3gdl8";
   };
 
   configureFlags = [ "--disable-gui" "--sysconfdir=/etc" ];
diff --git a/pkgs/development/libraries/unixODBCDrivers/default.nix b/pkgs/development/libraries/unixODBCDrivers/default.nix
index 233fdd902541..e7a2dee541d0 100644
--- a/pkgs/development/libraries/unixODBCDrivers/default.nix
+++ b/pkgs/development/libraries/unixODBCDrivers/default.nix
@@ -5,11 +5,11 @@
 {
   psql = stdenv.mkDerivation rec {
     name = "psqlodbc-${version}";
-    version = "09.05.0210";
+    version = "10.01.0000";
 
     src = fetchurl {
       url = "http://ftp.postgresql.org/pub/odbc/versions/src/${name}.tar.gz";
-      sha256 = "0317zrxaiy209xzcc6b5sz6hsyiv4zm74iikp91rgz7z3ll4n4dc";
+      sha256 = "1cyams7157f3gry86x64xrplqi2vyqrq3rqka59gv4lb4rpl7jl7";
     };
 
     buildInputs = [ unixODBC postgresql ];
@@ -37,19 +37,12 @@
     };
 
     nativeBuildInputs = [ cmake ];
-    buildInputs = [ unixODBC mariadb.lib ];
+    buildInputs = [ unixODBC mariadb.connector-c ];
 
     cmakeFlags = [
-      "-DMARIADB_INCLUDE_DIR=${mariadb.lib}/include/mysql"
+      "-DMARIADB_INCLUDE_DIR=${mariadb.connector-c}/include/mariadb"
     ];
 
-    preConfigure = ''
-      sed -i \
-        -e 's,mariadb_config,mysql_config,g' \
-        -e 's,libmariadbclient,libmysqlclient,g' \
-        cmake/FindMariaDB.cmake
-    '';
-
     passthru = {
       fancyName = "MariaDB";
       driver = "lib/libmyodbc3-3.51.12.so";
@@ -60,7 +53,6 @@
       homepage =  https://downloads.mariadb.org/connector-odbc/;
       license = licenses.gpl2;
       platforms = platforms.linux;
-      broken = true;
     };
   };
 
diff --git a/pkgs/development/libraries/uriparser/default.nix b/pkgs/development/libraries/uriparser/default.nix
index 6b5c48a6105d..9b4e3a74afe1 100644
--- a/pkgs/development/libraries/uriparser/default.nix
+++ b/pkgs/development/libraries/uriparser/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "uriparser-${version}";
-  version = "0.8.4";
+  version = "0.8.5";
 
   src = fetchurl {
     url = "mirror://sourceforge/project/uriparser/Sources/${version}/${name}.tar.bz2";
-    sha256 = "08vvcmg4mcpi2gyrq043c9mfcy3mbrw6lhp86698hx392fjcsz6f";
+    sha256 = "1p9c6lr39rjl4bbzi7wl2nsg72gcz8qhicxh9v043qyr0dfcvsjq";
   };
 
 
diff --git a/pkgs/development/libraries/usbredir/default.nix b/pkgs/development/libraries/usbredir/default.nix
index e4e053805af7..515c3b2ca3b9 100644
--- a/pkgs/development/libraries/usbredir/default.nix
+++ b/pkgs/development/libraries/usbredir/default.nix
@@ -9,8 +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.optionalString stdenv.isi686 "-Wno-error=format";
+  NIX_CFLAGS_COMPILE = [ "-Wno-error" ];
 
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ libusb ];
diff --git a/pkgs/development/libraries/v8/default.nix b/pkgs/development/libraries/v8/default.nix
index c2cd5a015168..f14ec4fc6084 100644
--- a/pkgs/development/libraries/v8/default.nix
+++ b/pkgs/development/libraries/v8/default.nix
@@ -7,13 +7,11 @@
 assert readline != null;
 
 let
-  arch = if stdenv.isArm
-         then if stdenv.is64bit
-              then"arm64"
-              else "arm"
-         else if stdenv.is64bit
-              then"x64"
-              else "ia32";
+  arch = if stdenv.isx86_64 then "x64"
+            else if stdenv.isi686 then "ia32"
+            else if stdenv.isAarch64 then "arm64"
+            else if stdenv.isArm then "arm"
+            else throw "Unknown architecture for v8";
   git_url = "https://chromium.googlesource.com";
   clangFlag = if stdenv.isDarwin then "1" else "0";
   sharedFlag = if static then "static_library" else "shared_library";
@@ -158,10 +156,12 @@ stdenv.mkDerivation rec {
   '';
 
   nativeBuildInputs = [ which ];
-  buildInputs = [ readline python icu patchelf ]
-  ++ stdenv.lib.optionals stdenv.isDarwin [ cctools ];
+  buildInputs = [ readline python icu ]
+    ++ stdenv.lib.optional stdenv.isDarwin cctools
+    ++ stdenv.lib.optional stdenv.isLinux patchelf;
 
-  NIX_CFLAGS_COMPILE = "-Wno-error=strict-overflow -Wno-error=unused-function -Wno-error=attributes";
+  NIX_CFLAGS_COMPILE = "-Wno-error=strict-overflow -Wno-error=unused-function -Wno-error=attributes"
+    + stdenv.lib.optionalString stdenv.cc.isClang " -Wno-error=unused-lambda-capture";
 
   buildFlags = [
     "LINK=c++"
@@ -172,6 +172,8 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
+  dontUpdateAutotoolsGnuConfigScripts = if stdenv.isAarch64 then true else null;
+
   # the `libv8_libplatform` target is _only_ built as a static library,
   # and is expected to be statically linked in when needed.
   # see the following link for further commentary:
diff --git a/pkgs/development/libraries/vaapi-intel/default.nix b/pkgs/development/libraries/vaapi-intel/default.nix
index dcb44a408a82..4e729db4671e 100644
--- a/pkgs/development/libraries/vaapi-intel/default.nix
+++ b/pkgs/development/libraries/vaapi-intel/default.nix
@@ -1,14 +1,16 @@
-{ stdenv, fetchurl, gnum4, pkgconfig, python2
-, intel-gpu-tools, libdrm, libva, libX11, mesa_noglu, wayland
+{ stdenv, fetchFromGitHub, autoreconfHook, gnum4, pkgconfig, python2
+, intel-gpu-tools, libdrm, libva, libX11, libGL, wayland, libXext
 }:
 
 stdenv.mkDerivation rec {
   name = "intel-vaapi-driver-${version}";
-  version = "1.8.2";
+  inherit (libva) version;
 
-  src = fetchurl {
-    url = "http://www.freedesktop.org/software/vaapi/releases/libva-intel-driver/${name}.tar.bz2";
-    sha256 = "00mpcvininwr5c4wyhp16s4bddg7vclxxjm2sfq5h7lifjcxyv46";
+  src = fetchFromGitHub {
+    owner  = "01org";
+    repo   = "libva-intel-driver";
+    rev    = version;
+    sha256 = "15ag4al9h6b8f8sw1zpighyhsmr5qfqp1882q7r3gsh5g4cnj763";
   };
 
   patchPhase = ''
@@ -25,12 +27,14 @@ stdenv.mkDerivation rec {
     "--enable-wayland"
   ];
 
-  nativeBuildInputs = [ gnum4 pkgconfig python2 ];
+  nativeBuildInputs = [ autoreconfHook gnum4 pkgconfig python2 ];
 
-  buildInputs = [ intel-gpu-tools libdrm libva libX11 mesa_noglu wayland ];
+  buildInputs = [ intel-gpu-tools libdrm libva libX11 libXext libGL wayland ];
+
+  enableParallelBuilding = true;
 
   meta = with stdenv.lib; {
-    homepage = http://cgit.freedesktop.org/vaapi/intel-driver/;
+    homepage = https://cgit.freedesktop.org/vaapi/intel-driver/;
     license = licenses.mit;
     description = "Intel driver for the VAAPI library";
     platforms = platforms.unix;
diff --git a/pkgs/development/libraries/vaapi-vdpau/default.nix b/pkgs/development/libraries/vaapi-vdpau/default.nix
index 4522ecc1bb63..013af68cb6c4 100644
--- a/pkgs/development/libraries/vaapi-vdpau/default.nix
+++ b/pkgs/development/libraries/vaapi-vdpau/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, libvdpau, mesa, libva, pkgconfig }:
+{ stdenv, fetchurl, libvdpau, libGLU_combined, libva, pkgconfig }:
 let
   libvdpau08patch = (fetchurl { url = "http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/x11-libs/libva-vdpau-driver/files/libva-vdpau-driver-0.7.4-libvdpau-0.8.patch?revision=1.1";
                                 name = "libva-vdpau-driver-0.7.4-libvdpau-0.8.patch";
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
                         }) ];
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ libvdpau mesa libva ];
+  buildInputs = [ libvdpau libGLU_combined libva ];
 
   preConfigure = ''
     patch -p0 < ${libvdpau08patch}  # use -p0 instead of -p1
@@ -29,7 +29,7 @@ stdenv.mkDerivation rec {
 
 
   meta = {
-    homepage = http://cgit.freedesktop.org/vaapi/vdpau-driver/;
+    homepage = https://cgit.freedesktop.org/vaapi/vdpau-driver/;
     license = stdenv.lib.licenses.gpl2Plus;
     description = "VDPAU driver for the VAAPI library";
     platforms = stdenv.lib.platforms.linux;
diff --git a/pkgs/development/libraries/vapoursynth/default.nix b/pkgs/development/libraries/vapoursynth/default.nix
index 6864db12f18d..e45337c8cf5d 100644
--- a/pkgs/development/libraries/vapoursynth/default.nix
+++ b/pkgs/development/libraries/vapoursynth/default.nix
@@ -1,8 +1,8 @@
 { stdenv, fetchFromGitHub, pkgconfig, autoreconfHook
 , zimg, libass, python3, libiconv
 , ApplicationServices, nasm
-, ocrSupport ?  false, tesseract
-, imwriSupport? true,  imagemagick7
+, ocrSupport ?  false, tesseract ? null
+, imwriSupport? true,  imagemagick7 ? null
 }:
 
 assert ocrSupport   -> tesseract != null;
@@ -12,13 +12,13 @@ with stdenv.lib;
 
 stdenv.mkDerivation rec {
   name = "vapoursynth-${version}";
-  version = "R39";
+  version = "R43";
 
   src = fetchFromGitHub {
     owner  = "vapoursynth";
     repo   = "vapoursynth";
     rev    = version;
-    sha256 = "0cw7w8xiwhxhwykydy13m44wm9vn9hrsi30z6017ngga9d84fhqy";
+    sha256 = "01yzxggjxr6fz3wj81z6vgp9m4jqddyk73i22kz2x620cpdgb9j9";
   };
 
   nativeBuildInputs = [ pkgconfig autoreconfHook nasm ];
@@ -39,7 +39,7 @@ stdenv.mkDerivation rec {
     description = "A video processing framework with the future in mind";
     homepage    = http://www.vapoursynth.com/;
     license     = licenses.lgpl21;
-    platforms   = platforms.unix;
+    platforms   = platforms.x86_64;
     maintainers = with maintainers; [ rnhmjoj ];
   };
 
diff --git a/pkgs/development/libraries/vc/default.nix b/pkgs/development/libraries/vc/default.nix
index 1dbbcf798c9f..e2a2af615b88 100644
--- a/pkgs/development/libraries/vc/default.nix
+++ b/pkgs/development/libraries/vc/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "Vc-${version}";
-  version = "1.3.2";
+  version = "1.3.3";
 
   src = fetchFromGitHub {
     owner = "VcDevel";
     repo = "Vc";
     rev = version;
-    sha256 = "119sm0kldr5j163ff04fra35420cvpj040hs7n0mnfbcgyx4nxq9";
+    sha256 = "0y4riz2kiw6a9w2zydj6x0vhy2qc9v17wspq3n2q88nbas72yd2m";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/vcdimager/default.nix b/pkgs/development/libraries/vcdimager/default.nix
index e93f071aefac..48ad33424f60 100644
--- a/pkgs/development/libraries/vcdimager/default.nix
+++ b/pkgs/development/libraries/vcdimager/default.nix
@@ -1,11 +1,11 @@
-{ stdenv, fetchurl, pkgconfig, libcdio, libxml2, popt }:
+{ stdenv, lib, fetchurl, pkgconfig, libcdio, libxml2, popt }:
 
-stdenv.mkDerivation {
-  name = "vcdimager-0.7.24";
+stdenv.mkDerivation rec {
+  name = "vcdimager-2.0.1";
 
   src = fetchurl {
-    url = mirror://gnu/vcdimager/vcdimager-0.7.24.tar.gz;
-    sha256 = "1526jxynslg07i50v3c3afhc8swbd4si8y6s8m3h1wrz6mkplp87";
+    url = "mirror://gnu/vcdimager/${name}.tar.gz";
+    sha256 = "0ypnb1vp49nmzp5571ynlz6n1gh90f23w3z4x95hb7c2p7pmylb7";
   };
 
   nativeBuildInputs = [ pkgconfig ];
@@ -14,9 +14,10 @@ stdenv.mkDerivation {
 
   propagatedBuildInputs = [ libcdio ];
 
-  meta = {
+  meta = with lib; {
     homepage = http://www.gnu.org/software/vcdimager/;
     description = "Full-featured mastering suite for authoring, disassembling and analyzing Video CDs and Super Video CDs";
-    platforms = stdenv.lib.platforms.gnu; # random choice
+    platforms = platforms.gnu; # random choice
+    license = licenses.gpl2;
   };
 }
diff --git a/pkgs/development/libraries/vigra/default.nix b/pkgs/development/libraries/vigra/default.nix
index 2910e8b7dbbc..438b4eda454b 100644
--- a/pkgs/development/libraries/vigra/default.nix
+++ b/pkgs/development/libraries/vigra/default.nix
@@ -24,9 +24,11 @@ in stdenv.mkDerivation rec {
             ++ stdenv.lib.optionals (stdenv.system == "x86_64-linux")
                   [ "-DCMAKE_CXX_FLAGS=-fPIC" "-DCMAKE_C_FLAGS=-fPIC" ];
 
+  enableParallelBuilding = true;
+
   meta = with stdenv.lib; {
     description = "Novel computer vision C++ library with customizable algorithms and data structures";
-    homepage = http://hci.iwr.uni-heidelberg.de/vigra;
+    homepage = https://hci.iwr.uni-heidelberg.de/vigra;
     license = licenses.mit;
     maintainers = [ maintainers.viric ];
     platforms = platforms.linux;
diff --git a/pkgs/development/libraries/virglrenderer/default.nix b/pkgs/development/libraries/virglrenderer/default.nix
new file mode 100644
index 000000000000..2cd3b5a20c0c
--- /dev/null
+++ b/pkgs/development/libraries/virglrenderer/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchurl, pkgconfig, libGLU, epoxy, libX11, libdrm, mesa_noglu }:
+
+
+stdenv.mkDerivation rec {
+
+  name = "virglrenderer-${version}";
+  version = "0.6.0";
+
+  src = fetchurl {
+    url = "https://www.freedesktop.org/software/virgl/${name}.tar.bz2";
+    sha256 = "a549e351e0eb2ad1df471386ddcf85f522e7202808d1616ee9ff894209066e1a";
+  };
+
+  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/;
+    license = licenses.mit;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.xeji ];
+  };
+
+}
diff --git a/pkgs/development/libraries/vmime/default.nix b/pkgs/development/libraries/vmime/default.nix
index 9bef1b27e9cd..e0398487abc3 100644
--- a/pkgs/development/libraries/vmime/default.nix
+++ b/pkgs/development/libraries/vmime/default.nix
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
   ];
 
   meta = {
-    homepage = http://www.vmime.org/;
+    homepage = https://www.vmime.org/;
     description = "Free mail library for C++";
     license = stdenv.lib.licenses.gpl3;
     maintainers = with stdenv.lib.maintainers; [viric];
diff --git a/pkgs/development/libraries/vmmlib/default.nix b/pkgs/development/libraries/vmmlib/default.nix
index ccdf2b05e7e3..18b9278539fc 100644
--- a/pkgs/development/libraries/vmmlib/default.nix
+++ b/pkgs/development/libraries/vmmlib/default.nix
@@ -38,7 +38,7 @@ stdenv.mkDerivation rec {
             computations and frustum culling classes, and spatial data structures'';
 
     license     = licenses.bsd2;
-    homepage    = http://github.com/VMML/vmmlib/;
+    homepage    = https://github.com/VMML/vmmlib/;
     maintainers = [ maintainers.adev ];
     platforms   = platforms.all;
   };
diff --git a/pkgs/development/libraries/vo-amrwbenc/default.nix b/pkgs/development/libraries/vo-amrwbenc/default.nix
new file mode 100644
index 000000000000..ba6e437ca3c3
--- /dev/null
+++ b/pkgs/development/libraries/vo-amrwbenc/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, autoreconfHook }:
+
+let
+    version = "0.1.3";
+in
+stdenv.mkDerivation {
+  name = "vo-amrwbenc-${version}";
+  version = "0.1.3";
+  buildInputs = [ autoreconfHook ];
+  src = fetchurl {
+    url = "https://github.com/mstorsjo/vo-amrwbenc/archive/v${version}.tar.gz";
+    sha256 = "85c79997ba7ddb9c95b5ddbe9ea032e27595390f3cbd686ed46a69e485cc053c";
+  };
+
+  meta = {
+    homepage = "http://sourceforge.net/projects/opencore-amr/";
+    description = "VisualOn Adaptive Multi Rate Wideband (AMR-WB) encoder";
+    license = "stdenv.lib.licenses.apache";
+    maintainers = [ stdenv.lib.maintainers.Esteth ];
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/vrpn/default.nix b/pkgs/development/libraries/vrpn/default.nix
index 5250b7815906..ddeecce21c61 100644
--- a/pkgs/development/libraries/vrpn/default.nix
+++ b/pkgs/development/libraries/vrpn/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, unzip, cmake, mesa }:
+{ stdenv, fetchFromGitHub, unzip, cmake, libGLU_combined }:
 
 stdenv.mkDerivation rec {
   name    = "${pname}-${date}";
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
     sha256 = "032q295d68w34rk5q8nfqdd29s55n00bfik84y7xzkjrpspaprlh";
   };
 
-  buildInputs = [ unzip cmake mesa ];
+  buildInputs = [ unzip cmake libGLU_combined ];
 
   doCheck = false; # FIXME: test failure
   checkTarget = "test";
diff --git a/pkgs/development/libraries/vtk/default.nix b/pkgs/development/libraries/vtk/default.nix
index 5b0bdb4ee741..984a106236ce 100644
--- a/pkgs/development/libraries/vtk/default.nix
+++ b/pkgs/development/libraries/vtk/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, cmake, mesa, libX11, xproto, libXt
+{ stdenv, fetchurl, fetchpatch, cmake, libGLU_combined, libX11, xproto, libXt
 , qtLib ? null
 # Darwin support
 , Cocoa, CoreServices, DiskArbitration, IOKit, CFNetwork, Security, GLUT, OpenGL
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
 
   buildInputs =
     if !stdenv.isDarwin
-    then [ cmake mesa libX11 xproto libXt ] ++ optional (qtLib != null) qtLib
+    then [ cmake libGLU_combined libX11 xproto libXt ] ++ optional (qtLib != null) qtLib
     else [ cmake qtLib xpc CoreServices DiskArbitration IOKit cf-private
            CFNetwork Security ApplicationServices CoreText IOSurface ImageIO
            OpenGL GLUT ];
diff --git a/pkgs/development/libraries/vulkan-loader/default.nix b/pkgs/development/libraries/vulkan-loader/default.nix
index 8330f7f44f33..cc6e7211b1d2 100644
--- a/pkgs/development/libraries/vulkan-loader/default.nix
+++ b/pkgs/development/libraries/vulkan-loader/default.nix
@@ -1,14 +1,14 @@
 { stdenv, fetchgit, fetchFromGitHub, cmake, pkgconfig, git, python3,
   python3Packages, glslang, spirv-tools, x11, libxcb, libXrandr,
-  libXext, wayland, mesa_noglu, makeWrapper }:
+  libXext, wayland, libGL_driver, makeWrapper }:
 
 let
-  version = "1.0.42.2";
+  version = "1.1.70.0";
   src = fetchFromGitHub {
     owner = "KhronosGroup";
     repo = "Vulkan-LoaderAndValidationLayers";
     rev = "sdk-${version}";
-    sha256 = "0na1ax2cgv6w29213mby56mndfsj3iizj3n5pbpy4s4p7ij9kdgn";
+    sha256 = "1a7xwl65bi03l4zbjq54qkxjb8kb4m78qvw8bas5alhf9v6i6yqp";
   };
 in
 
@@ -18,23 +18,28 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ makeWrapper pkgconfig ];
   buildInputs = [ cmake git python3 python3Packages.lxml
-                  glslang spirv-tools x11 libxcb libXrandr libXext wayland
+                  glslang x11 libxcb libXrandr libXext wayland
                 ];
   enableParallelBuilding = true;
 
   cmakeFlags = [
     "-DBUILD_WSI_MIR_SUPPORT=OFF"
-    "-DFALLBACK_DATA_DIRS=${mesa_noglu.driverLink}/share:/usr/local/share:/usr/share"
+    "-DFALLBACK_DATA_DIRS=${libGL_driver.driverLink}/share:/usr/local/share:/usr/share"
   ];
 
   outputs = [ "out" "dev" "demos" ];
+  patches = [ ./rev-file.patch ];
+
+  postUnpack = ''
+    # Hack so a version header can be generated. Relies on ./rev-file.patch to work.
+    mkdir -p "$sourceRoot/external/glslang/External"
+    echo "${spirv-tools.src.rev}" > "$sourceRoot/external/glslang/External/spirv-tools"
+  '';
 
   preConfigure = ''
     checkRev() {
       [ "$2" = $(cat "external_revisions/$1_revision") ] || (echo "ERROR: dependency $1 is revision $2 but should be revision" $(cat "external_revisions/$1_revision") && exit 1)
     }
-    checkRev spirv-tools "${spirv-tools.src.rev}"
-    checkRev spirv-headers "${spirv-tools.headers.rev}"
     checkRev glslang "${glslang.src.rev}"
   '';
 
@@ -48,11 +53,12 @@ stdenv.mkDerivation rec {
     sed -i "s:\\./lib:$out/lib/lib:g" "$out/share/vulkan/"*/*.json
     mkdir -p $dev/include
     cp -rv ../include $dev/
+    mkdir -p $demos/share/vulkan-demos
+    cp demos/*.spv demos/*.ppm $demos/share/vulkan-demos
     mkdir -p $demos/bin
-    cp demos/*.spv demos/*.ppm $demos/bin
-    find demos -type f -executable -not -name vulkaninfo -exec cp {} $demos/bin \;
+    find demos -type f -executable -not -name vulkaninfo -exec cp -v {} $demos/bin \;
     for p in cube cubepp; do
-      wrapProgram $demos/bin/$p --run "cd $demos/bin"
+      wrapProgram $demos/bin/$p --run "cd $demos/share/vulkan-demos"
     done
   '';
 
diff --git a/pkgs/development/libraries/vulkan-loader/rev-file.patch b/pkgs/development/libraries/vulkan-loader/rev-file.patch
new file mode 100644
index 000000000000..e8f9f92c8ead
--- /dev/null
+++ b/pkgs/development/libraries/vulkan-loader/rev-file.patch
@@ -0,0 +1,21 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index c9f73ce96..d14ffeed9 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -339,13 +339,13 @@ macro(run_vk_xml_generate dependency output)
+ endmacro()
+ 
+ # Define macro used for generating header files containing commit IDs for external dependencies
+-macro(run_external_revision_generate source_dir symbol_name output)
++macro(run_external_revision_generate rev_file symbol_name output)
+     add_custom_command(OUTPUT ${output}
+     # NOTE: If you modify this call to use --rev_file instead of --git_dir (to read the commit ID from a file instead of
+     # parsing from a Git repository), you probably also want to add the revision file to the list of DEPENDS on the
+     # subsequent line (to ensure that the script is re-run when the revision file is modified).
+-    COMMAND ${PYTHON_CMD} ${SCRIPTS_DIR}/external_revision_generator.py --git_dir ${source_dir} -s ${symbol_name} -o ${output}
+-    DEPENDS ${SCRIPTS_DIR}/external_revision_generator.py ${source_dir}/.git/HEAD ${source_dir}/.git/index
++    COMMAND ${PYTHON_CMD} ${SCRIPTS_DIR}/external_revision_generator.py --rev_file ${rev_file} -s ${symbol_name} -o ${output}
++    DEPENDS ${SCRIPTS_DIR}/external_revision_generator.py ${rev_file}
+     )
+ endmacro()
+ 
diff --git a/pkgs/development/libraries/wayland/default.nix b/pkgs/development/libraries/wayland/default.nix
index 836a4527b508..a5b7a6a99ce4 100644
--- a/pkgs/development/libraries/wayland/default.nix
+++ b/pkgs/development/libraries/wayland/default.nix
@@ -8,11 +8,11 @@ assert expat != null;
 
 stdenv.mkDerivation rec {
   name = "wayland-${version}";
-  version = "1.12.0";
+  version = "1.14.0";
 
   src = fetchurl {
-    url = "http://wayland.freedesktop.org/releases/${name}.tar.xz";
-    sha256 = "d6b4135cba0188abcb7275513c72dede751d6194f6edc5b82183a3ba8b821ab1";
+    url = "https://wayland.freedesktop.org/releases/${name}.tar.xz";
+    sha256 = "1f3sla6h0bw15fz8pjc67jhwj7pwmfdc7qlj42j5k9v116ycm07d";
   };
 
   configureFlags = [ "--with-scanner" "--disable-documentation" ];
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
 
   meta = {
     description = "Reference implementation of the wayland protocol";
-    homepage    = http://wayland.freedesktop.org/;
+    homepage    = https://wayland.freedesktop.org/;
     license     = lib.licenses.mit;
     platforms   = lib.platforms.linux;
     maintainers = with lib.maintainers; [ codyopel wkennington ];
diff --git a/pkgs/development/libraries/wayland/protocols.nix b/pkgs/development/libraries/wayland/protocols.nix
index 436de5609e5a..ed9866048191 100644
--- a/pkgs/development/libraries/wayland/protocols.nix
+++ b/pkgs/development/libraries/wayland/protocols.nix
@@ -4,11 +4,11 @@
 
 stdenv.mkDerivation rec {
   name = "wayland-protocols-${version}";
-  version = "1.10";
+  version = "1.13";
 
   src = fetchurl {
     url = "http://wayland.freedesktop.org/releases/${name}.tar.xz";
-    sha256 = "5719c51d7354864983171c5083e93a72ac99229e2b460c4bb10513de08839c0a";
+    sha256 = "0f4gqvmz53q9d8h0ilhf4z773nb4vskzx11a3d1jycym120bqn07";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/wcslib/default.nix b/pkgs/development/libraries/wcslib/default.nix
index 64c5293fac7d..5dd79980680f 100644
--- a/pkgs/development/libraries/wcslib/default.nix
+++ b/pkgs/development/libraries/wcslib/default.nix
@@ -1,14 +1,14 @@
 { fetchurl,  stdenv, flex }:
 
 stdenv.mkDerivation rec {
-  version = "5.15";
+  version = "5.18";
   name = "wcslib-${version}";
 
   buildInputs = [ flex ];
 
   src = fetchurl {
     url = "ftp://ftp.atnf.csiro.au/pub/software/wcslib/${name}.tar.bz2";
-    sha256 ="1s2nig327g4bimd9xshlk11ww09a7mrjmsbpdcd8smsmn2kl1glb";
+    sha256 ="16jh568k99c9p0y3qzcgps2rii933x9wlay7q1xm0lr59zqzp4xn";
   };
 
   prePatch = ''
diff --git a/pkgs/development/libraries/webkitgtk/2.18.nix b/pkgs/development/libraries/webkitgtk/2.18.nix
deleted file mode 100644
index e1b520eb10b1..000000000000
--- a/pkgs/development/libraries/webkitgtk/2.18.nix
+++ /dev/null
@@ -1,103 +0,0 @@
-{ stdenv, fetchurl, perl, python2, ruby, bison, gperf, cmake
-, pkgconfig, gettext, gobjectIntrospection, libnotify, gnutls
-, gtk2, gtk3, wayland, libwebp, enchant, xlibs, libxkbcommon, epoxy, at_spi2_core
-, libxml2, libsoup, libsecret, libxslt, harfbuzz, libpthreadstubs, pcre, nettle, libtasn1, p11_kit
-, libidn, libedit, readline, mesa, libintlOrEmpty
-, enableGeoLocation ? true, geoclue2, sqlite
-, gst-plugins-base, gst-plugins-bad
-}:
-
-assert enableGeoLocation -> geoclue2 != null;
-
-with stdenv.lib;
-stdenv.mkDerivation rec {
-  name = "webkitgtk-${version}";
-  version = "2.18.1";
-
-  meta = {
-    description = "Web content rendering engine, GTK+ port";
-    homepage = http://webkitgtk.org/;
-    license = licenses.bsd2;
-    platforms = with platforms; linux ++ darwin;
-    hydraPlatforms = [];
-    maintainers = with maintainers; [ ];
-  };
-
-  postConfigure = optionalString stdenv.isDarwin ''
-    substituteInPlace Source/WebKit2/CMakeFiles/WebKit2.dir/link.txt \
-        --replace "../../lib/libWTFGTK.a" ""
-    substituteInPlace Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/link.txt \
-        --replace "../../lib/libbmalloc.a" ""
-    sed -i "s|[\./]*\.\./lib/lib[^\.]*\.a||g" \
-        Source/JavaScriptCore/CMakeFiles/LLIntOffsetsExtractor.dir/link.txt \
-        Source/JavaScriptCore/shell/CMakeFiles/jsc.dir/link.txt \
-        Source/JavaScriptCore/shell/CMakeFiles/testb3.dir/link.txt \
-        Source/WebKit2/CMakeFiles/DatabaseProcess.dir/link.txt \
-        Source/WebKit2/CMakeFiles/NetworkProcess.dir/link.txt \
-        Source/WebKit2/CMakeFiles/webkit2gtkinjectedbundle.dir/link.txt \
-        Source/WebKit2/CMakeFiles/WebProcess.dir/link.txt
-    substituteInPlace Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/link.txt \
-        --replace "../../lib/libWTFGTK.a" "-Wl,-all_load ../../lib/libWTFGTK.a"
-  '';
-
-  src = fetchurl {
-    url = "http://webkitgtk.org/releases/${name}.tar.xz";
-    sha256 = "15fp7szmkpannx7avsynf0nv3y343qwq0fvq3rz2m2mw5wq7pnww";
-  };
-
-  # see if we can clean this up....
-
-  patches = [ ./finding-harfbuzz-icu.patch ]
-     ++ optionals stdenv.isDarwin [
-    ./PR-152650-2.patch
-    ./PR-153138.patch
-    ./PR-157554.patch
-    ./PR-157574.patch
-  ];
-
-  cmakeFlags = [
-  "-DPORT=GTK"
-  "-DUSE_LIBHYPHEN=0"
-  ]
-  ++ optional stdenv.isLinux "-DENABLE_GLES2=ON"
-  ++ optionals stdenv.isDarwin [
-  "-DUSE_SYSTEM_MALLOC=ON"
-  "-DUSE_ACCELERATE=0"
-  "-DENABLE_INTROSPECTION=ON"
-  "-DENABLE_MINIBROWSER=OFF"
-  "-DENABLE_PLUGIN_PROCESS_GTK2=OFF"
-  "-DENABLE_MINIBROWSER=OFF"
-  "-DENABLE_VIDEO=ON"
-  "-DENABLE_QUARTZ_TARGET=ON"
-  "-DENABLE_X11_TARGET=OFF"
-  "-DENABLE_OPENGL=OFF"
-  "-DENABLE_WEB_AUDIO=OFF"
-  "-DENABLE_WEBGL=OFF"
-  "-DENABLE_GRAPHICS_CONTEXT_3D=OFF"
-  "-DENABLE_GTKDOC=OFF"
-  ];
-
-  NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin " -lintl";
-
-  nativeBuildInputs = [
-    cmake perl python2 ruby bison gperf
-    pkgconfig gettext gobjectIntrospection
-  ];
-
-  buildInputs = libintlOrEmpty ++ [
-    gtk2 libwebp enchant libnotify gnutls pcre nettle libidn
-    libxml2 libsecret libxslt harfbuzz libpthreadstubs libtasn1 p11_kit
-    sqlite gst-plugins-base gst-plugins-bad libxkbcommon epoxy at_spi2_core
-  ] ++ optional enableGeoLocation geoclue2
-    ++ (with xlibs; [ libXdmcp libXt libXtst ])
-    ++ optionals stdenv.isDarwin [ libedit readline mesa ]
-    ++ optional stdenv.isLinux wayland;
-
-  propagatedBuildInputs = [
-    libsoup gtk3
-  ];
-
-  enableParallelBuilding = true;
-
-  outputs = [ "out" "dev" ];
-}
diff --git a/pkgs/development/libraries/webkitgtk/2.20.nix b/pkgs/development/libraries/webkitgtk/2.20.nix
new file mode 100644
index 000000000000..3cc26b512c89
--- /dev/null
+++ b/pkgs/development/libraries/webkitgtk/2.20.nix
@@ -0,0 +1,89 @@
+{ stdenv, fetchurl, perl, python2, ruby, bison, gperf, cmake, ninja
+, 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, libintl
+, enableGeoLocation ? true, geoclue2, sqlite
+, enableGtk2Plugins ? false, gtk2 ? null
+, gst-plugins-base, gst-plugins-bad, woff2
+}:
+
+assert enableGeoLocation -> geoclue2 != null;
+assert enableGtk2Plugins -> gtk2 != null;
+assert stdenv.isDarwin -> !enableGtk2Plugins;
+
+with stdenv.lib;
+stdenv.mkDerivation rec {
+  name = "webkitgtk-${version}";
+  version = "2.20.1";
+
+  meta = {
+    description = "Web content rendering engine, GTK+ port";
+    homepage = https://webkitgtk.org/;
+    license = licenses.bsd2;
+    platforms = with platforms; linux ++ darwin;
+    hydraPlatforms = [];
+    maintainers = with maintainers; [ ];
+  };
+
+  src = fetchurl {
+    url = "http://webkitgtk.org/releases/${name}.tar.xz";
+    sha256 = "0nc9dj05dbk31ciip08b3rdsfja7ckc5mgagrj030fafza2k5r23";
+  };
+
+  patches = optionals stdenv.isDarwin [
+    ## TODO add necessary patches for Darwin
+  ];
+
+  postPatch = ''
+    patchShebangs .
+  '';
+
+  postConfigure = ''
+    # A stopgap for a non-deterministic build failure when using only one core
+    # Upstream bug: https://bugs.webkit.org/show_bug.cgi?id=183788#c4
+    ninja JavaScriptCoreForwardingHeaders WTFForwardingHeaders
+  '';
+
+  cmakeFlags = [
+  "-DPORT=GTK"
+  "-DUSE_LIBHYPHEN=0"
+  "-DENABLE_INTROSPECTION=ON"
+  ]
+  ++ optional (!enableGtk2Plugins) "-DENABLE_PLUGIN_PROCESS_GTK2=OFF"
+  ++ optional stdenv.isLinux "-DENABLE_GLES2=ON"
+  ++ optionals stdenv.isDarwin [
+  "-DUSE_SYSTEM_MALLOC=ON"
+  "-DUSE_ACCELERATE=0"
+  "-DENABLE_MINIBROWSER=OFF"
+  "-DENABLE_VIDEO=ON"
+  "-DENABLE_QUARTZ_TARGET=ON"
+  "-DENABLE_X11_TARGET=OFF"
+  "-DENABLE_OPENGL=OFF"
+  "-DENABLE_WEB_AUDIO=OFF"
+  "-DENABLE_WEBGL=OFF"
+  "-DENABLE_GRAPHICS_CONTEXT_3D=OFF"
+  "-DENABLE_GTKDOC=OFF"
+  ];
+
+  nativeBuildInputs = [
+    cmake ninja perl python2 ruby bison gperf
+    pkgconfig gettext gobjectIntrospection
+  ];
+
+  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 libXdamage ])
+    ++ optionals stdenv.isDarwin [ libedit readline libGLU_combined ]
+    ++ optional stdenv.isLinux wayland;
+
+  propagatedBuildInputs = [
+    libsoup gtk3
+  ];
+
+  outputs = [ "out" "dev" ];
+}
diff --git a/pkgs/development/libraries/webkitgtk/2.4.nix b/pkgs/development/libraries/webkitgtk/2.4.nix
index 6669b562400f..18d20bf9c780 100644
--- a/pkgs/development/libraries/webkitgtk/2.4.nix
+++ b/pkgs/development/libraries/webkitgtk/2.4.nix
@@ -53,6 +53,8 @@ stdenv.mkDerivation rec {
     ./quartz-webcore.patch
     ./libc++.patch
     ./plugin-none.patch
+  ] ++ optionals stdenv.hostPlatform.isMusl [
+    ./fix-execinfo.patch
   ];
 
   configureFlags = with stdenv.lib; [
diff --git a/pkgs/development/libraries/webkitgtk/PR-152650-2.patch b/pkgs/development/libraries/webkitgtk/PR-152650-2.patch
deleted file mode 100644
index f87b8ee73e23..000000000000
--- a/pkgs/development/libraries/webkitgtk/PR-152650-2.patch
+++ /dev/null
@@ -1,62 +0,0 @@
-From 4607ea0a569b3c527ae8dce341ab55eb0d69d8f7 Mon Sep 17 00:00:00 2001
-From: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-Date: Tue, 8 Mar 2016 17:26:23 -0800
-Subject: [PATCH 2/2] [GTK][Mac] Enable support for gtk-doc on Mac
-
-https://bugs.webkit.org/show_bug.cgi?id=152650
-
-Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
----
- ChangeLog                     | 10 ++++++++++
- Source/PlatformGTK.cmake      |  2 +-
- Source/cmake/OptionsGTK.cmake |  5 -----
- 3 files changed, 11 insertions(+), 6 deletions(-)
-
-diff --git a/Source/PlatformGTK.cmake b/Source/PlatformGTK.cmake
-index af4d2e3..0b11b56 100644
---- a/Source/PlatformGTK.cmake
-+++ b/Source/PlatformGTK.cmake
-@@ -34,7 +34,7 @@ endmacro()
- add_gtkdoc_generator("docs-build.stamp" "")
- if (ENABLE_GTKDOC)
-     add_custom_target(gtkdoc ALL DEPENDS "${CMAKE_BINARY_DIR}/docs-build.stamp")
--elseif (NOT ENABLED_COMPILER_SANITIZERS AND NOT CMAKE_CROSSCOMPILING AND NOT APPLE)
-+elseif (NOT ENABLED_COMPILER_SANITIZERS AND NOT CMAKE_CROSSCOMPILING)
-     add_custom_target(gtkdoc DEPENDS "${CMAKE_BINARY_DIR}/docs-build.stamp")
- 
-     # Add a default build step which check that documentation does not have any warnings
-diff --git a/Source/cmake/OptionsGTK.cmake b/Source/cmake/OptionsGTK.cmake
-index 6b01f1a..b443d10 100644
---- a/Source/cmake/OptionsGTK.cmake
-+++ b/Source/cmake/OptionsGTK.cmake
-@@ -424,11 +424,6 @@ if (CMAKE_CROSSCOMPILING)
-     set(ENABLE_INTROSPECTION OFF)
- endif ()
- 
--# Override the cached variable, gtk-doc does not really work when building on Mac.
--if (APPLE)
--    set(ENABLE_GTKDOC OFF)
--endif ()
--
- set(DERIVED_SOURCES_WEBKITGTK_DIR ${DERIVED_SOURCES_DIR}/webkitgtk)
- set(DERIVED_SOURCES_WEBKITGTK_API_DIR ${DERIVED_SOURCES_WEBKITGTK_DIR}/webkit)
- set(DERIVED_SOURCES_WEBKIT2GTK_DIR ${DERIVED_SOURCES_DIR}/webkit2gtk)
-diff --git a/Tools/gtk/gtkdoc.py b/Tools/gtk/gtkdoc.py
-index 4c8237b..a628ae0 100644
---- a/Tools/gtk/gtkdoc.py
-+++ b/Tools/gtk/gtkdoc.py
-@@ -322,6 +322,11 @@ class GTKDoc(object):
-                 env['RUN'] = 'LD_LIBRARY_PATH="%s:%s" ' % (self.library_path, current_ld_library_path)
-             else:
-                 env['RUN'] = 'LD_LIBRARY_PATH="%s" ' % self.library_path
-+            current_dyld_library_path = env.get('DYLD_LIBRARY_PATH')
-+            if current_ld_library_path:
-+                env['RUN'] = 'DYLD_LIBRARY_PATH="%s:%s" ' % (self.library_path, current_dyld_library_path)
-+            else:
-+                env['RUN'] = 'DYLD_LIBRARY_PATH="%s" ' % self.library_path
- 
-         if ldflags:
-             env['LDFLAGS'] = '%s %s' % (ldflags, env.get('LDFLAGS', ''))
--- 
-2.7.2
-
diff --git a/pkgs/development/libraries/webkitgtk/PR-153138.patch b/pkgs/development/libraries/webkitgtk/PR-153138.patch
deleted file mode 100644
index 833921f68061..000000000000
--- a/pkgs/development/libraries/webkitgtk/PR-153138.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From 07886d9eacb7587dd52a9bcae10c1fc8ab56a910 Mon Sep 17 00:00:00 2001
-From: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-Date: Fri, 15 Jan 2016 11:53:07 -0800
-Subject: [PATCH] https://bugs.webkit.org/show_bug.cgi?id=153138
-
-Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
----
- Source/JavaScriptCore/bytecode/StructureStubInfo.cpp | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/Source/JavaScriptCore/bytecode/StructureStubInfo.cpp b/Source/JavaScriptCore/bytecode/StructureStubInfo.cpp
-index 1e4b4f5..9b27aed 100644
---- a/Source/JavaScriptCore/bytecode/StructureStubInfo.cpp
-+++ b/Source/JavaScriptCore/bytecode/StructureStubInfo.cpp
-@@ -26,6 +26,8 @@
- #include "config.h"
- #include "StructureStubInfo.h"
- 
-+#include "JSCellInlines.h"
-+
- #include "JSObject.h"
- #include "PolymorphicAccess.h"
- #include "Repatch.h"
--- 
-2.7.0
-
diff --git a/pkgs/development/libraries/webkitgtk/PR-157554.patch b/pkgs/development/libraries/webkitgtk/PR-157554.patch
deleted file mode 100644
index 615e805c92ce..000000000000
--- a/pkgs/development/libraries/webkitgtk/PR-157554.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-https://bugs.webkit.org/show_bug.cgi?id=157554
-
---- a/Source/WTF/wtf/OSRandomSource.cpp
-+++ b/Source/WTF/wtf/OSRandomSource.cpp
-@@ -29,7 +29,7 @@
- #include <stdint.h>
- #include <stdlib.h>
- 
--#if !OS(DARWIN) && OS(UNIX)
-+#if OS(UNIX) && !(OS(DARWIN) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)
- #include <errno.h>
- #include <fcntl.h>
- #include <unistd.h>
-@@ -46,7 +46,7 @@
- 
- namespace WTF {
- 
--#if !OS(DARWIN) && OS(UNIX)
-+#if OS(UNIX) && !(OS(DARWIN) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)
- NEVER_INLINE NO_RETURN_DUE_TO_CRASH static void crashUnableToOpenURandom()
- {
-     CRASH();
-@@ -60,8 +56,8 @@ NEVER_INLINE NO_RETURN_DUE_TO_CRASH static void crashUnableToReadFromURandom()
-     
- void cryptographicallyRandomValuesFromOS(unsigned char* buffer, size_t length)
- {
--#if OS(DARWIN)
--    RELEASE_ASSERT(!CCRandomCopyBytes(kCCRandomDefault, buffer, length));
-+#if OS(DARWIN) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
-+    return arc4random_buf(buffer, length);
- #elif OS(UNIX)
-     int fd = open("/dev/urandom", O_RDONLY, 0);
-     if (fd < 0)
diff --git a/pkgs/development/libraries/webkitgtk/PR-157574.patch b/pkgs/development/libraries/webkitgtk/PR-157574.patch
deleted file mode 100644
index d9b0795afa5b..000000000000
--- a/pkgs/development/libraries/webkitgtk/PR-157574.patch
+++ /dev/null
@@ -1,62 +0,0 @@
-diff --git a/Source/JavaScriptCore/API/WebKitAvailability.h b/Source/JavaScriptCore/API/WebKitAvailability.h
-index ab53183..1310dec 100644
---- a/Source/JavaScriptCore/API/WebKitAvailability.h
-+++ b/Source/JavaScriptCore/API/WebKitAvailability.h
-@@ -27,57 +27,12 @@
- #define __WebKitAvailability__
- 
- #if defined(__APPLE__)
--
--#include <AvailabilityMacros.h>
- #include <CoreFoundation/CoreFoundation.h>
--
--#if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED < 101100
--/* To support availability macros that mention newer OS X versions when building on older OS X versions,
--   we provide our own definitions of the underlying macros that the availability macros expand to. We're
--   free to expand the macros as no-ops since frameworks built on older OS X versions only ship bundled with
--   an application rather than as part of the system.
--*/
--
--#ifndef __NSi_10_10 // Building from trunk rather than SDK.
--#define __NSi_10_10 introduced=10.0 // Use 10.0 to indicate that everything is available.
--#endif
--
--#ifndef __NSi_10_11 // Building from trunk rather than SDK.
--#define __NSi_10_11 introduced=10.0 // Use 10.0 to indicate that everything is available.
--#endif
--
--#ifndef __NSi_10_12 // Building from trunk rather than SDK.
--#define __NSi_10_12 introduced=10.0 // Use 10.0 to indicate that everything is available.
--#endif
--
--#ifndef __AVAILABILITY_INTERNAL__MAC_10_9
--#define __AVAILABILITY_INTERNAL__MAC_10_9
--#endif
--
--#ifndef __AVAILABILITY_INTERNAL__MAC_10_10
--#define __AVAILABILITY_INTERNAL__MAC_10_10
- #endif
- 
--#ifndef AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
--#define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
--#endif
--
--#ifndef AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
--#define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
--#endif
--
--#endif /* __MAC_OS_X_VERSION_MIN_REQUIRED <= 101100 */
--
--#if defined(BUILDING_GTK__)
- #undef CF_AVAILABLE
- #define CF_AVAILABLE(_mac, _ios)
- #undef CF_ENUM_AVAILABLE
- #define CF_ENUM_AVAILABLE(_mac, _ios)
--#endif
--
--#else
--#define CF_AVAILABLE(_mac, _ios)
--#define CF_ENUM_AVAILABLE(_mac, _ios)
--#endif
- 
- #endif /* __WebKitAvailability__ */
diff --git a/pkgs/development/libraries/webkitgtk/finding-harfbuzz-icu.patch b/pkgs/development/libraries/webkitgtk/finding-harfbuzz-icu.patch
deleted file mode 100644
index 14d58ef04f68..000000000000
--- a/pkgs/development/libraries/webkitgtk/finding-harfbuzz-icu.patch
+++ /dev/null
@@ -1,52 +0,0 @@
---- webkitgtk-2.6.1.orig/Source/cmake/FindHarfBuzz.cmake	2014-10-09 01:54:38.000000000 +0800
-+++ webkitgtk-2.6.1/Source/cmake/FindHarfBuzz.cmake	2014-10-15 13:41:29.832290412 +0800
-@@ -34,21 +34,39 @@
- 
- pkg_check_modules(PC_HARFBUZZ harfbuzz>=0.9.7)
- 
--find_path(HARFBUZZ_INCLUDE_DIRS NAMES hb.h
--    HINTS ${PC_HARFBUZZ_INCLUDE_DIRS} ${PC_HARFBUZZ_INCLUDEDIR}
--)
--
--find_library(HARFBUZZ_LIBRARIES NAMES harfbuzz
--    HINTS ${PC_HARFBUZZ_LIBRARY_DIRS} ${PC_HARFBUZZ_LIBDIR}
--)
--
- # HarfBuzz 0.9.18 split ICU support into a separate harfbuzz-icu library.
- if ("${PC_HARFBUZZ_VERSION}" VERSION_GREATER "0.9.17")
-     pkg_check_modules(PC_HARFBUZZ_ICU harfbuzz-icu>=0.9.18 REQUIRED)
--    find_library(HARFBUZZ_ICU_LIBRARIES NAMES harfbuzz-icu
-+
-+    find_path(HARFBUZZ_ICU_INCLUDEDIR NAMES hb-icu.h
-+        HINTS ${PC_HARFBUZZ_ICU_INCLUDE_DIRS} ${PC_HARFBUZZ_INCLUDEDIR}
-+    )
-+
-+    find_library(HARFBUZZ_ICU_LIBRARY NAMES harfbuzz-icu
-         HINTS ${PC_HARFBUZZ_ICU_LIBRARY_DIRS} ${PC_HARFBUZZ_ICU_LIBDIR}
-     )
--    list(APPEND HARFBUZZ_LIBRARIES "${HARFBUZZ_ICU_LIBRARIES}")
-+
-+    find_library(HARFBUZZ_LIBRARY NAMES harfbuzz
-+        HINTS ${PC_HARFBUZZ_LIBRARY_DIRS} ${PC_HARFBUZZ_LIBDIR}
-+    )
-+
-+    set(HARFBUZZ_INCLUDE_DIRS
-+        ${PC_HARFBUZZ_INCLUDE_DIRS} ${HARFBUZZ_ICU_INCLUDEDIR}
-+        CACHE INTERNAL ""
-+    )
-+
-+    set(HARFBUZZ_LIBRARIES
-+        ${HARFBUZZ_LIBRARY} ${HARFBUZZ_ICU_LIBRARY}
-+        CACHE INTERNAL ""
-+    )
-+else ()
-+    find_path(HARFBUZZ_INCLUDE_DIRS NAMES hb.h
-+        HINTS ${PC_HARFBUZZ_INCLUDE_DIRS} ${PC_HARFBUZZ_INCLUDEDIR}
-+    )
-+
-+    find_library(HARFBUZZ_LIBRARIES NAMES harfbuzz
-+        HINTS ${PC_HARFBUZZ_LIBRARY_DIRS} ${PC_HARFBUZZ_LIBDIR}
-+    )
- endif ()
- 
- include(FindPackageHandleStandardArgs)
diff --git a/pkgs/development/libraries/webkitgtk/fix-execinfo.patch b/pkgs/development/libraries/webkitgtk/fix-execinfo.patch
new file mode 100644
index 000000000000..eb825312f3be
--- /dev/null
+++ b/pkgs/development/libraries/webkitgtk/fix-execinfo.patch
@@ -0,0 +1,20 @@
+--- webkitgtk-2.2.0.orig/Source/WTF/wtf/Assertions.cpp
++++ webkitgtk-2.2.0/Source/WTF/wtf/Assertions.cpp
+@@ -64,7 +64,7 @@
+ #include <windows.h>
+ #endif
+ 
+-#if OS(DARWIN) || (OS(LINUX) && !defined(__UCLIBC__))
++#if OS(DARWIN) || (OS(LINUX) && defined(__GLIBC__) && !defined(__UCLIBC__))
+ #include <cxxabi.h>
+ #include <dlfcn.h>
+ #include <execinfo.h>
+@@ -242,7 +242,7 @@
+ 
+ void WTFGetBacktrace(void** stack, int* size)
+ {
+-#if OS(DARWIN) || (OS(LINUX) && !defined(__UCLIBC__))
++#if OS(DARWIN) || (OS(LINUX) && defined(__GLIBC__) && !defined(__UCLIBC__))
+     *size = backtrace(stack, *size);
+ #elif OS(WINDOWS) && !OS(WINCE)
+     // The CaptureStackBackTrace function is available in XP, but it is not defined
diff --git a/pkgs/development/libraries/webkitgtk/gstreamergl-2.17.patch b/pkgs/development/libraries/webkitgtk/gstreamergl-2.17.patch
deleted file mode 100644
index 7c47db52abaa..000000000000
--- a/pkgs/development/libraries/webkitgtk/gstreamergl-2.17.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git i/Source/cmake/OptionsGTK.cmake w/Source/cmake/OptionsGTK.cmake
-index d3577a8..9620dc0 100644
---- i/Source/cmake/OptionsGTK.cmake
-+++ w/Source/cmake/OptionsGTK.cmake
-@@ -94,7 +94,7 @@ WEBKIT_OPTION_DEFINE(USE_LIBSECRET "Whether to enable the persistent credential
- 
- # Private options specific to the GTK+ port. Changing these options is
- # completely unsupported. They are intended for use only by WebKit developers.
--WEBKIT_OPTION_DEFINE(USE_GSTREAMER_GL "Whether to enable support for GStreamer GL" PRIVATE ON)
-+WEBKIT_OPTION_DEFINE(USE_GSTREAMER_GL "Whether to enable support for GStreamer GL" PRIVATE OFF)
- WEBKIT_OPTION_DEFINE(USE_GSTREAMER_MPEGTS "Whether to enable support for MPEG-TS" PRIVATE OFF)
- WEBKIT_OPTION_DEFINE(USE_REDIRECTED_XCOMPOSITE_WINDOW "Whether to use a Redirected XComposite Window for accelerated compositing in X11." PRIVATE ON)
- 
diff --git a/pkgs/development/libraries/webrtc-audio-processing/default.nix b/pkgs/development/libraries/webrtc-audio-processing/default.nix
index f5d49290484f..b5a3aed91d90 100644
--- a/pkgs/development/libraries/webrtc-audio-processing/default.nix
+++ b/pkgs/development/libraries/webrtc-audio-processing/default.nix
@@ -12,6 +12,8 @@ stdenv.mkDerivation rec {
   # signal_processing/filter_ar_fast_q12_armv7.S:88: Error: selected processor does not support `sbfx r11,r6,#12,#16' in ARM mode
   patchPhase = stdenv.lib.optionalString stdenv.isArm ''
     substituteInPlace configure --replace 'armv7*|armv8*' 'disabled'
+  '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+    substituteInPlace webrtc/base/checks.cc --replace 'defined(__UCLIBC__)' 1
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/websocket++/default.nix b/pkgs/development/libraries/websocket++/default.nix
index fbfc460db96d..8a0ec2523b94 100644
--- a/pkgs/development/libraries/websocket++/default.nix
+++ b/pkgs/development/libraries/websocket++/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ cmake ];
 
   meta = with stdenv.lib; {
-    homepage = http://www.zaphoyd.com/websocketpp/;
+    homepage = https://www.zaphoyd.com/websocketpp/;
     description = "C++/Boost Asio based websocket client/server library";
     license = licenses.bsd3;
     platforms = platforms.unix;
diff --git a/pkgs/development/libraries/wildmidi/default.nix b/pkgs/development/libraries/wildmidi/default.nix
index 9d22833e1c04..06a4e48827ed 100644
--- a/pkgs/development/libraries/wildmidi/default.nix
+++ b/pkgs/development/libraries/wildmidi/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, cmake, alsaLib, freepats }:
 
 stdenv.mkDerivation rec {
-  name = "wildmidi-0.3.9";
+  name = "wildmidi-0.4.2";
 
   src = fetchurl {
     url = "https://github.com/Mindwerks/wildmidi/archive/${name}.tar.gz";
-    sha256 = "1fbcsvzn8akvvy7vg6vmnikcc8gh405b4gp1r016bq7yginljwwp";
+    sha256 = "178hm2wh5h7apkcb1a0dyla2ia8569php8ikz62rh0g6dp5l67am";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/wiredtiger/default.nix b/pkgs/development/libraries/wiredtiger/default.nix
index e4b95fc1cb9f..c905c40cf960 100644
--- a/pkgs/development/libraries/wiredtiger/default.nix
+++ b/pkgs/development/libraries/wiredtiger/default.nix
@@ -15,7 +15,7 @@ let
   mkWith = mkFlag "with-" "without-";
   mkOther = mkFlag "" "" true;
 
-  shouldUsePkg = pkg: if pkg != null && any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
+  shouldUsePkg = pkg: if pkg != null && pkg.meta.available then pkg else null;
 
   optLz4 = shouldUsePkg lz4;
   optSnappy = shouldUsePkg snappy;
@@ -71,5 +71,6 @@ stdenv.mkDerivation rec {
     license = licenses.gpl2;
     platforms = intersectLists platforms.unix platforms.x86_64;
     maintainers = with maintainers; [ wkennington ];
+    broken = true; # Broken by f689a6d1c6796c4a4f116ffec6c4624379e04bc9.
   };
 }
diff --git a/pkgs/development/libraries/wlc/default.nix b/pkgs/development/libraries/wlc/default.nix
index 7fcf4fbbe5f6..a672bbf52a90 100644
--- a/pkgs/development/libraries/wlc/default.nix
+++ b/pkgs/development/libraries/wlc/default.nix
@@ -1,38 +1,28 @@
 { stdenv, fetchFromGitHub, fetchpatch, cmake, pkgconfig
-, wayland, pixman, libxkbcommon, libinput, xcbutilwm, xcbutilimage, mesa_noglu
-, libX11, dbus_libs, wayland-protocols
-, libpthreadstubs, libXdmcp, libXext
+, wayland, pixman, libxkbcommon, libinput, xcbutilwm, xcbutilimage, libGL
+, libX11, dbus_libs, wayland-protocols, libdrm, mesa_noglu
+, libpthreadstubs, libXdmcp, libXext, libXfixes
 , withOptionalPackages ? true, zlib, valgrind, doxygen
 }:
 
-let
-  # for 0.0.10
-  xwaylandPatch = fetchpatch {
-    url = "https://github.com/Cloudef/wlc/commit/a130f6006560fb8ac02fb59a90ced1659563f9ca.diff";
-    sha256 = "0kzcbqklcyg8bganm65di8cif6dpc8bkrsvkjia09kr92lymxm2c";
-  };
-in stdenv.mkDerivation rec {
+stdenv.mkDerivation rec {
   name = "wlc-${version}";
-  version = "0.0.10";
+  version = "0.0.11";
 
   src = fetchFromGitHub {
     owner = "Cloudef";
     repo = "wlc";
     rev = "v${version}";
     fetchSubmodules = true;
-    sha256 = "09kvwhrpgkxlagn9lgqxc80jbg56djn29a6z0n6h0dsm90ysyb2k";
+    sha256 = "1qnak907gjd35hq4b0rrhgb7kz5iwnirh8yk372yzxpgk7dq0gz9";
   };
 
-  patches = [
-    xwaylandPatch
-  ];
-
   nativeBuildInputs = [ cmake pkgconfig ];
 
   buildInputs = [
-    wayland pixman libxkbcommon libinput xcbutilwm xcbutilimage mesa_noglu
-    libX11 dbus_libs wayland-protocols
-    libpthreadstubs libXdmcp libXext ]
+    wayland pixman libxkbcommon libinput xcbutilwm xcbutilimage libGL
+    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/wld/default.nix b/pkgs/development/libraries/wld/default.nix
deleted file mode 100644
index 1dd5858ec720..000000000000
--- a/pkgs/development/libraries/wld/default.nix
+++ /dev/null
@@ -1,30 +0,0 @@
-{ lib, stdenv, fetchurl, pkgconfig
-, wayland, fontconfig, pixman, freetype, libdrm
-}:
-
-stdenv.mkDerivation rec {
-  name = "wld-${version}";
-  version = "git-2015-09-01";
-  repo = "https://github.com/michaelforney/wld";
-  rev = "efe0a1ed1856a2e4a1893ed0f2d7dde43b5627f0";
-
-  src = fetchurl {
-    url = "${repo}/archive/${rev}.tar.gz";
-    sha256 = "09388f7828e18c75e7b8d41454903886a725d7a868f60e66c128bd7d2e953ee1";
-  };
-
-  nativeBuildInputs = [ pkgconfig ];
-
-  buildInputs = [ wayland fontconfig pixman freetype libdrm ];
-
-  makeFlags = "PREFIX=$(out)";
-  installPhase = "PREFIX=$out make install";
-
-  meta = {
-    description = "A primitive drawing library targeted at Wayland";
-    homepage    = repo;
-    license     = lib.licenses.mit;
-    platforms   = lib.platforms.linux;
-    maintainers = with lib.maintainers; [ ];
-  };
-}
diff --git a/pkgs/development/libraries/wlroots/default.nix b/pkgs/development/libraries/wlroots/default.nix
index 79bd8bb96659..a4c2b3297145 100644
--- a/pkgs/development/libraries/wlroots/default.nix
+++ b/pkgs/development/libraries/wlroots/default.nix
@@ -1,35 +1,49 @@
 { stdenv, fetchFromGitHub, meson, ninja, pkgconfig
-, wayland, mesa_noglu, wayland-protocols, libinput, libxkbcommon, pixman
-, xcbutilwm, libX11, libcap
+, wayland, libGL, wayland-protocols, libinput, libxkbcommon, pixman
+, xcbutilwm, libX11, libcap, xcbutilimage, xcbutilerrors, mesa_noglu
 }:
 
 let pname = "wlroots";
-    version = "unstable-2017-10-31";
+    version = "unstable-2018-03-16";
 in stdenv.mkDerivation rec {
   name = "${pname}-${version}";
 
   src = fetchFromGitHub {
     owner = "swaywm";
     repo = "wlroots";
-    rev = "7200d643363e988edf6777c38e7f8fcd451a2c50";
-    sha256 = "179raymkni1xzaph32zdhg7nfin0xfzrlnbnxkcr266k9y8k66ac";
+    rev = "9cc875429b40e2567b219f8e9ffd23316d136204";
+    sha256 = "1prhic3pyf9n65qfg5akzkc9qv2z3ab60dpcacr7wgr9nxrvnsdq";
   };
 
-  # TODO: Temporary workaround for compilation errors
-  patches = [ ./libdrm.patch ./no-werror.patch ];
+  # $out for the library and $bin for rootston
+  outputs = [ "out" "bin" ];
 
   nativeBuildInputs = [ meson ninja pkgconfig ];
 
   buildInputs = [
-    wayland mesa_noglu wayland-protocols libinput libxkbcommon pixman
-    xcbutilwm libX11 libcap
+    wayland libGL wayland-protocols libinput libxkbcommon pixman
+    xcbutilwm libX11 libcap xcbutilimage xcbutilerrors mesa_noglu
   ];
 
+  # Install rootston (the reference compositor) to $bin
+  postInstall = ''
+    mkdir -p $bin/bin
+    cp rootston/rootston $bin/bin/
+    mkdir $bin/lib
+    cp libwlroots* $bin/lib/
+    patchelf --set-rpath "$bin/lib:${stdenv.lib.makeLibraryPath buildInputs}" $bin/bin/rootston
+    mkdir $bin/etc
+    cp ../rootston/rootston.ini.example $bin/etc/rootston.ini
+  '';
+
   meta = with stdenv.lib; {
     description = "A modular Wayland compositor library";
     inherit (src.meta) homepage;
     license     = licenses.mit;
     platforms   = platforms.linux;
     maintainers = with maintainers; [ primeos ];
+    # Marked as broken until the first official/stable release (upstream
+    # request). See #38344 for the public discussion.
+    broken = true;
   };
 }
diff --git a/pkgs/development/libraries/wlroots/libdrm.patch b/pkgs/development/libraries/wlroots/libdrm.patch
deleted file mode 100644
index 2b9d85382764..000000000000
--- a/pkgs/development/libraries/wlroots/libdrm.patch
+++ /dev/null
@@ -1,9 +0,0 @@
---- a/backend/meson.build	2017-10-31 22:08:01.112927610 +0100
-+++ b/backend/meson.build	2017-10-31 22:09:28.155264343 +0100
-@@ -43,5 +43,5 @@
- 	'wlr_backend',
- 	backend_files,
- 	include_directories: wlr_inc,
--	dependencies: [wayland_server, egl, gbm, libinput, systemd, elogind, wlr_render, wlr_protos],
-+	dependencies: [wayland_server, egl, gbm, libinput, systemd, elogind, wlr_render, wlr_protos, drm],
- )
diff --git a/pkgs/development/libraries/wlroots/no-werror.patch b/pkgs/development/libraries/wlroots/no-werror.patch
deleted file mode 100644
index 78c374d9dbb8..000000000000
--- a/pkgs/development/libraries/wlroots/no-werror.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/meson.build	2017-10-31 22:08:01.132927689 +0100
-+++ b/meson.build	2017-10-31 22:20:58.215784350 +0100
-@@ -5,7 +5,6 @@
- 	default_options: [
- 		'c_std=c11',
- 		'warning_level=2',
--		'werror=true',
- 	],
- )
- 
diff --git a/pkgs/development/libraries/wolfssl/default.nix b/pkgs/development/libraries/wolfssl/default.nix
index fdbef27705e8..fa65a14121fc 100644
--- a/pkgs/development/libraries/wolfssl/default.nix
+++ b/pkgs/development/libraries/wolfssl/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "wolfssl-${version}";
-  version = "3.12.0";
+  version = "3.13.0";
 
   src = fetchFromGitHub {
     owner = "wolfSSL";
     repo = "wolfssl";
     rev = "v${version}-stable";
-    sha256 = "0bjfzpgj50cd27lfz6vry9bdz0f0kvgq8plqdbhlk7kjp32nm2bv";
+    sha256 = "0mvq7ifcpckfrg0zzcxqfbrv08pnz4a8g2z2j3s9h3cwns9ipn6h";
   };
 
   outputs = [ "out" "dev" "doc" "lib" ];
diff --git a/pkgs/development/libraries/wt/default.nix b/pkgs/development/libraries/wt/default.nix
index 3adf4f1497f8..99f73add795a 100644
--- a/pkgs/development/libraries/wt/default.nix
+++ b/pkgs/development/libraries/wt/default.nix
@@ -1,42 +1,54 @@
 { stdenv, fetchFromGitHub, cmake, boost, pkgconfig, doxygen, qt48Full, libharu
-, pango, fcgi, firebird, libmysql, postgresql, graphicsmagick, glew, openssl
+, pango, fcgi, firebird, mysql, postgresql, graphicsmagick, glew, openssl
 , pcre
 }:
 
-stdenv.mkDerivation rec {
-  name = "wt-${version}";
-  version = "4.0.0";
+let
+  generic =
+    { version, sha256 }:
+    stdenv.mkDerivation rec {
+      name = "wt-${version}";
 
-  src = fetchFromGitHub {
-    owner = "kdeforche";
-    repo = "wt";
-    rev = version;
-    sha256 = "1451xxvnx6mlvxg0jxlr1mfv5v18h2214kijk5kacilqashfc43i";
-  };
+      src = fetchFromGitHub {
+        owner = "emweb";
+        repo = "wt";
+        rev = version;
+        inherit sha256;
+      };
 
-  enableParallelBuilding = true;
+      enableParallelBuilding = true;
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [
-    cmake boost doxygen qt48Full libharu
-    pango fcgi firebird libmysql postgresql graphicsmagick glew
-    openssl pcre
-  ];
+      nativeBuildInputs = [ pkgconfig ];
+      buildInputs = [
+        cmake boost doxygen qt48Full libharu
+        pango fcgi firebird mysql.connector-c postgresql graphicsmagick glew
+        openssl pcre
+      ];
 
-  cmakeFlags = [
-    "-DWT_WRASTERIMAGE_IMPLEMENTATION=GraphicsMagick"
-    "-DWT_CPP_11_MODE=-std=c++11"
-    "-DGM_PREFIX=${graphicsmagick}"
-    "-DMYSQL_PREFIX=${libmysql.dev}"
-    "--no-warn-unused-cli"
-  ];
+      cmakeFlags = [
+        "-DWT_WRASTERIMAGE_IMPLEMENTATION=GraphicsMagick"
+        "-DWT_CPP_11_MODE=-std=c++11"
+        "-DGM_PREFIX=${graphicsmagick}"
+        "-DMYSQL_PREFIX=${mysql.connector-c}"
+        "--no-warn-unused-cli"
+      ];
 
-  meta = with stdenv.lib; {
-    homepage = https://www.webtoolkit.eu/wt;
-    description = "C++ library for developing web applications";
-    platforms = platforms.linux;
-    license = licenses.gpl2;
-    maintainers = [ maintainers.juliendehos ];
+      meta = with stdenv.lib; {
+        homepage = https://www.webtoolkit.eu/wt;
+        description = "C++ library for developing web applications";
+        platforms = platforms.linux;
+        license = licenses.gpl2;
+        maintainers = with maintainers; [ juliendehos willibutz ];
+      };
+    };
+in {
+  wt3 = generic {
+    version = "3.3.10";
+    sha256 = "1y25mhghgbgjgycpny0x4z95xn98q0wraab1c5gkwnay097bgwdy";
   };
-}
 
+  wt4 = generic {
+    version = "4.0.3";
+    sha256 = "01xch5dkpcanwhr515236wa9mdmnq2a2j13dn7smyhwzqgbpknsg";
+  };
+}
diff --git a/pkgs/development/libraries/wxSVG/default.nix b/pkgs/development/libraries/wxSVG/default.nix
index b991590924db..82b72a0fc7b3 100644
--- a/pkgs/development/libraries/wxSVG/default.nix
+++ b/pkgs/development/libraries/wxSVG/default.nix
@@ -7,11 +7,11 @@ stdenv.mkDerivation rec {
 
   name = "wxSVG-${version}";
   srcName = "wxsvg-${version}";
-  version = "1.5.11";
+  version = "1.5.13";
 
   src = fetchurl {
     url = "mirror://sourceforge/project/wxsvg/wxsvg/${version}/${srcName}.tar.bz2";
-    sha256 = "0m3ff8mjiq4hvy8rmxyc9fkpf24xwxhvr3a6jmvr2q5zc41xhz7x";
+    sha256 = "029a1rayp4c480x8ayng13rcjk1j98ar0z6ggijrznkn8kgx8j2j";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/wxsqlite3/default.nix b/pkgs/development/libraries/wxsqlite3/default.nix
index a06003997845..49f12842533b 100644
--- a/pkgs/development/libraries/wxsqlite3/default.nix
+++ b/pkgs/development/libraries/wxsqlite3/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
     ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Cocoa darwin.stubs.setfile darwin.stubs.rez darwin.stubs.derez ];
 
   meta = with stdenv.lib; {
-    homepage = http://utelle.github.io/wxsqlite3/ ;
+    homepage = https://utelle.github.io/wxsqlite3/ ;
     description = "A C++ wrapper around the public domain SQLite 3.x for wxWidgets";
     platforms = platforms.unix;
     maintainers = with maintainers; [ vrthra ];
diff --git a/pkgs/development/libraries/wxwidgets/2.8/default.nix b/pkgs/development/libraries/wxwidgets/2.8/default.nix
index 9ce8e95d9e94..bbb3b0faf347 100644
--- a/pkgs/development/libraries/wxwidgets/2.8/default.nix
+++ b/pkgs/development/libraries/wxwidgets/2.8/default.nix
@@ -1,10 +1,10 @@
 { stdenv, fetchurl, pkgconfig, gtk2, libXinerama, libSM, libXxf86vm, xf86vidmodeproto
 , gstreamer, gst-plugins-base, GConf, libX11, cairo
-, withMesa ? true, mesa_glu ? null, mesa_noglu ? null
+, withMesa ? true, libGLU ? null, libGL ? null
 , compat24 ? false, compat26 ? true, unicode ? true,
 }:
 
-assert withMesa -> mesa_glu != null && mesa_noglu != null;
+assert withMesa -> libGLU != null && libGL != null;
 
 with stdenv.lib;
 
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs = [ gtk2 libXinerama libSM libXxf86vm xf86vidmodeproto gstreamer gst-plugins-base GConf libX11 cairo ]
-    ++ optional withMesa mesa_glu;
+    ++ optional withMesa libGLU;
 
   nativeBuildInputs = [ pkgconfig ];
 
@@ -39,7 +39,7 @@ stdenv.mkDerivation rec {
     "${libXinerama.dev}/include ${libSM.dev}/include ${libXxf86vm.dev}/include";
   SEARCH_LIB =
     "${libXinerama.out}/lib ${libSM.out}/lib ${libXxf86vm.out}/lib "
-    + optionalString withMesa "${mesa_glu.out}/lib ${mesa_noglu.out}/lib ";
+    + optionalString withMesa "${libGLU.out}/lib ${libGL.out}/lib ";
 
   # Work around a bug in configure.
   NIX_CFLAGS_COMPILE = [ "-DHAVE_X11_XLIB_H=1" "-lX11" "-lcairo" "-Wno-narrowing" ];
diff --git a/pkgs/development/libraries/wxwidgets/2.9/default.nix b/pkgs/development/libraries/wxwidgets/2.9/default.nix
index 6230536b33ab..19c3ca307c5e 100644
--- a/pkgs/development/libraries/wxwidgets/2.9/default.nix
+++ b/pkgs/development/libraries/wxwidgets/2.9/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, pkgconfig, gtk2, libXinerama, libSM, libXxf86vm, xf86vidmodeproto
 , gstreamer, gst-plugins-base, GConf, setfile
-, withMesa ? true, mesa_glu ? null, mesa_noglu ? null
+, withMesa ? true, libGLU ? null, libGL ? null
 , compat24 ? false, compat26 ? true, unicode ? true
 , Carbon ? null, Cocoa ? null, Kernel ? null, QuickTime ? null, AGL ? null
 }:
 
-assert withMesa -> mesa_glu != null && mesa_noglu != null;
+assert withMesa -> libGLU != null && libGL != null;
 
 with stdenv.lib;
 
@@ -31,7 +31,7 @@ stdenv.mkDerivation {
   buildInputs =
     [ gtk2 libXinerama libSM libXxf86vm xf86vidmodeproto gstreamer
       gst-plugins-base GConf ]
-    ++ optional withMesa mesa_glu
+    ++ optional withMesa libGLU
     ++ optionals stdenv.isDarwin [ setfile Carbon Cocoa Kernel QuickTime ];
 
   nativeBuildInputs = [ pkgconfig ];
@@ -48,7 +48,7 @@ stdenv.mkDerivation {
       # allow building on 64-bit
       [ "--with-cocoa" "--enable-universal-binaries" "--with-macosx-version-min=10.7" ];
 
-  SEARCH_LIB = "${mesa_glu.out}/lib ${mesa_noglu.out}/lib ";
+  SEARCH_LIB = "${libGLU.out}/lib ${libGL.out}/lib ";
 
   preConfigure = "
     substituteInPlace configure --replace 'SEARCH_INCLUDE=' 'DUMMY_SEARCH_INCLUDE='
diff --git a/pkgs/development/libraries/wxwidgets/3.0/default.nix b/pkgs/development/libraries/wxwidgets/3.0/default.nix
index 951f27f7d547..309d9be274d1 100644
--- a/pkgs/development/libraries/wxwidgets/3.0/default.nix
+++ b/pkgs/development/libraries/wxwidgets/3.0/default.nix
@@ -1,16 +1,16 @@
 { stdenv, fetchFromGitHub, fetchurl, fetchpatch, pkgconfig
 , gtk2, gtk3, libXinerama, libSM, libXxf86vm
 , xf86vidmodeproto , gstreamer, gst-plugins-base, GConf, setfile
-, withMesa ? true, mesa_glu ? null, mesa_noglu ? null
+, withMesa ? true, libGLU ? null, libGL ? null
 , compat24 ? false, compat26 ? true, unicode ? true
 , withGtk2 ? true
-, withWebKit ? false, webkitgtk24x-gtk2 ? null, webkitgtk218x ? null
+, withWebKit ? false, webkitgtk24x-gtk2 ? null, webkitgtk ? null
 , AGL ? null, Carbon ? null, Cocoa ? null, Kernel ? null, QTKit ? null
 }:
 
 
-assert withMesa -> mesa_glu != null && mesa_noglu != null;
-assert withWebKit -> (if withGtk2 then webkitgtk24x-gtk2 else webkitgtk218x) != null;
+assert withMesa -> libGLU != null && libGL != null;
+assert withWebKit -> (if withGtk2 then webkitgtk24x-gtk2 else webkitgtk) != null;
 
 with stdenv.lib;
 
@@ -30,8 +30,8 @@ stdenv.mkDerivation {
   buildInputs =
     [ (if withGtk2 then gtk2 else gtk3) libXinerama libSM libXxf86vm xf86vidmodeproto gstreamer
       gst-plugins-base GConf ]
-    ++ optional withMesa mesa_glu
-    ++ optional withWebKit (if withGtk2 then webkitgtk24x-gtk2 else webkitgtk218x)
+    ++ optional withMesa libGLU
+    ++ optional withWebKit (if withGtk2 then webkitgtk24x-gtk2 else webkitgtk)
     ++ optionals stdenv.isDarwin [ setfile Carbon Cocoa Kernel QTKit ];
 
   nativeBuildInputs = [ pkgconfig ];
@@ -62,7 +62,7 @@ stdenv.mkDerivation {
     ++ optionals withWebKit
       ["--enable-webview" "--enable-webview-webkit"];
 
-  SEARCH_LIB = "${mesa_glu.out}/lib ${mesa_noglu.out}/lib ";
+  SEARCH_LIB = "${libGLU.out}/lib ${libGL.out}/lib ";
 
   preConfigure = "
     substituteInPlace configure --replace 'SEARCH_INCLUDE=' 'DUMMY_SEARCH_INCLUDE='
diff --git a/pkgs/development/libraries/wxwidgets/3.1/default.nix b/pkgs/development/libraries/wxwidgets/3.1/default.nix
new file mode 100644
index 000000000000..4b410a307bb4
--- /dev/null
+++ b/pkgs/development/libraries/wxwidgets/3.1/default.nix
@@ -0,0 +1,16 @@
+{ stdenv, fetchFromGitHub
+, wxGTK30
+}:
+
+with stdenv.lib;
+
+wxGTK30.overrideAttrs (oldAttrs : rec {
+    name = "wxwidgets-${version}";
+    version = "3.1.0";
+    src = fetchFromGitHub {
+        owner = "wxWidgets";
+        repo = "wxWidgets";
+        rev = "v${version}";
+        sha256 = "14kl1rsngm70v3mbyv1mal15iz2b18k97avjx8jn7s81znha1c7f";
+    };
+})
\ No newline at end of file
diff --git a/pkgs/development/libraries/x265/default.nix b/pkgs/development/libraries/x265/default.nix
index 29d7ddf1fdc9..418829e7af8a 100644
--- a/pkgs/development/libraries/x265/default.nix
+++ b/pkgs/development/libraries/x265/default.nix
@@ -16,14 +16,14 @@ in
 
 stdenv.mkDerivation rec {
   name = "x265-${version}";
-  version = "2.5";
+  version = "2.6";
 
   src = fetchurl {
     urls = [
       "http://get.videolan.org/x265/x265_${version}.tar.gz"
       "https://github.com/videolan/x265/archive/${version}.tar.gz"
     ];
-    sha256 = "05rxbnfcc8yl05q3xqkl1kk90k7zn5ih305r46dxnzjaa2djalrf";
+    sha256 = "1gyd94jkwdii9308m07nymsbxrmrcl81c0j8i10zhslr2mj07w0v";
   };
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/xalanc/default.nix b/pkgs/development/libraries/xalanc/default.nix
index 28575f4c5d5e..aeb741dbae7b 100644
--- a/pkgs/development/libraries/xalanc/default.nix
+++ b/pkgs/development/libraries/xalanc/default.nix
@@ -13,12 +13,11 @@ in stdenv.mkDerivation rec {
     sha256 = "0a3a2b15vpacnqgpp6fiy1pwyc8q6ywzvyb5445f6wixfdspypjg";
   };
 
-  # TODO: should we really be putting outputs in $out/usr? I'd expect -P$out below
   configurePhase = ''
     export XALANCROOT=`pwd`/c
     cd `pwd`/c
-    mkdir -p $out/usr
-    ./runConfigure -p ${platform} -c cc -x c++ -P$out/usr
+    mkdir -p $out
+    ./runConfigure -p ${platform} -c cc -x c++ -P$out
   '';
 
   buildInputs = [ xercesc getopt ];
diff --git a/pkgs/development/libraries/xapian/default.nix b/pkgs/development/libraries/xapian/default.nix
index 23fee81e0a52..482c765dcda9 100644
--- a/pkgs/development/libraries/xapian/default.nix
+++ b/pkgs/development/libraries/xapian/default.nix
@@ -27,7 +27,7 @@ let
 
     meta = with stdenv.lib; {
       description = "Search engine library";
-      homepage = http://xapian.org/;
+      homepage = https://xapian.org/;
       license = licenses.gpl2Plus;
       maintainers = with maintainers; [ chaoflow ];
       platforms = platforms.unix;
@@ -36,5 +36,5 @@ let
 in {
   # xapian-ruby needs 1.2.22 as of 2017-05-06
   xapian_1_2_22 = generic "1.2.22" "0zsji22n0s7cdnbgj0kpil05a6bgm5cfv0mvx12d8ydg7z58g6r6";
-  xapian_1_4_4 = generic "1.4.4" "1n9j2w2as0flih3hgim7gprfxsx6gimijs91rxsjsi8shjlqbad6";
+  xapian_1_4 = generic "1.4.5" "0axhqrj202hbll9mcx1qdm8gsqj19216w3z02gyjbycxvr9gkdc5";
 }
diff --git a/pkgs/development/libraries/xapian/tools/omega/default.nix b/pkgs/development/libraries/xapian/tools/omega/default.nix
index 2923bfc1fc68..09c2171945e4 100644
--- a/pkgs/development/libraries/xapian/tools/omega/default.nix
+++ b/pkgs/development/libraries/xapian/tools/omega/default.nix
@@ -6,7 +6,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "http://oligarchy.co.uk/xapian/${version}/xapian-omega-${version}.tar.xz";
-    sha256 = "0pl9gs0sbavxykfgrkm8syswqnfynmmqhf8429bv8a5qjh5pkp8l";
+    sha256 = "0zji8ckp4h5xdy2wbir3lvk680w1g1l4h5swmaxsx7ah12lkrjcr";
   };
 
   buildInputs = [ xapian perl pcre zlib libmagic ];
diff --git a/pkgs/development/libraries/xcb-util-cursor/HEAD.nix b/pkgs/development/libraries/xcb-util-cursor/HEAD.nix
index 81ac75489baf..17f8646b5177 100644
--- a/pkgs/development/libraries/xcb-util-cursor/HEAD.nix
+++ b/pkgs/development/libraries/xcb-util-cursor/HEAD.nix
@@ -13,9 +13,9 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "XCB cursor library (libxcursor port)";
-    homepage    = http://cgit.freedesktop.org/xcb/util-cursor;
+    homepage    = https://cgit.freedesktop.org/xcb/util-cursor;
     license     = licenses.mit;
-    maintainer  = with maintainers; [ lovek323 ];
+    maintainers = with maintainers; [ lovek323 ];
     platforms   = platforms.linux ++ platforms.darwin;
   };
 
diff --git a/pkgs/development/libraries/xercesc/default.nix b/pkgs/development/libraries/xercesc/default.nix
index b6bb4e63df34..9fa1768f4dce 100644
--- a/pkgs/development/libraries/xercesc/default.nix
+++ b/pkgs/development/libraries/xercesc/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "xerces-c-${version}";
-  version = "3.1.4";
+  version = "3.2.1";
 
   src = fetchurl {
     url = "mirror://apache/xerces/c/3/sources/${name}.tar.gz";
-    sha256 = "1xpccqzykpd3806kd788lgkl01pk7v5lklva6q4kp9zq9jnfv3n9";
+    sha256 = "18045nyjkr2hygkjc43pi2fmz6qcbn9p00kf42my3aa4i0mn1m3d";
   };
 
   meta = {
diff --git a/pkgs/development/libraries/xgboost/default.nix b/pkgs/development/libraries/xgboost/default.nix
index e37991367e6f..7865724efa40 100644
--- a/pkgs/development/libraries/xgboost/default.nix
+++ b/pkgs/development/libraries/xgboost/default.nix
@@ -1,30 +1,47 @@
-{ stdenv, fetchgit }:
+{ stdenv, lib, fetchgit, cmake
+, avxSupport ? false
+, cudaSupport ? false, cudatoolkit
+, ncclSupport ? false, nccl
+, llvmPackages
+}:
+
+assert ncclSupport -> cudaSupport;
 
 stdenv.mkDerivation rec {
   name = "xgboost-${version}";
-  version = "0.60";
+  version = "0.7";
 
   # needs submodules
   src = fetchgit {
     url = "https://github.com/dmlc/xgboost";
     rev = "refs/tags/v${version}";
-    sha256 = "0536vfl59n9vlagl1cpdl06c9y19dscwhwdzvi27zk5nc5qb6rdq";
+    sha256 = "1wxh020l4q037hc5z7vgxflb70l41a97anl8g6y4wxb74l5zv61l";
   };
 
   enableParallelBuilding = true;
 
-  installPhase = ''
+  nativeBuildInputs = [ cmake ] ++ lib.optional stdenv.isDarwin llvmPackages.openmp;
+
+  buildInputs = lib.optional cudaSupport cudatoolkit
+                ++ lib.optional ncclSupport nccl;
+
+  cmakeFlags = lib.optionals cudaSupport [ "-DUSE_CUDA=ON" "-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/cc" ]
+               ++ lib.optional ncclSupport "-DUSE_NCCL=ON";
+
+  installPhase = let
+    libname = if stdenv.isDarwin then "libxgboost.dylib" else "libxgboost.so";
+  in ''
     mkdir -p $out
-    cp -r include $out
-    install -Dm755 lib/libxgboost.so $out/lib/libxgboost.so
-    install -Dm755 xgboost $out/bin/xgboost
+    cp -r ../include $out
+    install -Dm755 ../lib/${libname} $out/lib/${libname}
+    install -Dm755 ../xgboost $out/bin/xgboost
   '';
 
   meta = with stdenv.lib; {
     description = "Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library";
     homepage = https://github.com/dmlc/xgboost;
     license = licenses.asl20;
-    platforms = platforms.linux;
+    platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" ];
     maintainers = with maintainers; [ abbradar ];
   };
 }
diff --git a/pkgs/development/libraries/xine-lib/default.nix b/pkgs/development/libraries/xine-lib/default.nix
index 83c75dcfa8a1..274a70057bdd 100644
--- a/pkgs/development/libraries/xine-lib/default.nix
+++ b/pkgs/development/libraries/xine-lib/default.nix
@@ -1,22 +1,22 @@
-{ stdenv, fetchurl, pkgconfig, xorg, alsaLib, mesa, aalib
+{ stdenv, fetchurl, pkgconfig, xorg, alsaLib, libGLU_combined, aalib
 , libvorbis, libtheora, speex, zlib, libdvdcss, perl, ffmpeg
 , flac, libcaca, libpulseaudio, libmng, libcdio, libv4l, vcdimager
 , libmpcdec
 }:
 
 stdenv.mkDerivation rec {
-  name = "xine-lib-1.2.6";
+  name = "xine-lib-1.2.9";
 
   src = fetchurl {
     url = "mirror://sourceforge/xine/${name}.tar.xz";
-    sha256 = "01d0nv4zhr4k8id5n4rmw13llrjsv9dhwg1a773c1iqpi1ris15x";
+    sha256 = "13clir4qxl2zvsvvjd9yv3yrdhsnvcn5s7ambbbn5dzy9604xcrj";
   };
 
   nativeBuildInputs = [ pkgconfig perl ];
 
   buildInputs = [
     xorg.libX11 xorg.libXv xorg.libXinerama xorg.libxcb xorg.libXext
-    alsaLib mesa aalib libvorbis libtheora speex perl ffmpeg flac
+    alsaLib libGLU_combined aalib libvorbis libtheora speex perl ffmpeg flac
     libcaca libpulseaudio libmng libcdio libv4l vcdimager libmpcdec
   ];
 
diff --git a/pkgs/development/libraries/xlslib/default.nix b/pkgs/development/libraries/xlslib/default.nix
index b274bba9c126..718554b20a48 100644
--- a/pkgs/development/libraries/xlslib/default.nix
+++ b/pkgs/development/libraries/xlslib/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "C++/C library to construct Excel .xls files in code";
-    homepage = http://sourceforge.net/projects/xlslib/;
+    homepage = https://sourceforge.net/projects/xlslib/;
     license = licenses.bsd2;
     platforms = platforms.linux;
     maintainers = with maintainers; [ abbradar ];
diff --git a/pkgs/development/libraries/xml-tooling-c/default.nix b/pkgs/development/libraries/xml-tooling-c/default.nix
index f2d7711c9f00..8e1d71fab3fa 100644
--- a/pkgs/development/libraries/xml-tooling-c/default.nix
+++ b/pkgs/development/libraries/xml-tooling-c/default.nix
@@ -2,12 +2,12 @@
 
 stdenv.mkDerivation rec {
   name = "xml-tooling-c-${version}";
-  version = "1.6.0";
+  version = "1.6.3";
 
   src = fetchgit {
     url = "https://git.shibboleth.net/git/cpp-xmltooling.git";
-    rev = "db08101c3854518a59096be95ed6564838381744";
-    sha256 = "0rhzvxm4z3pm28kpk34hayhm12bjjms2kygv1z68vnz8ijzgcinq";
+    rev = version;
+    sha256 = "09z2pp3yy3kqx22vwgxyi3s0vlpdv9camw8dpi3q8piff6zxak3q";
   };
 
   buildInputs = [ boost curl openssl log4shib xercesc xml-security-c ];
diff --git a/pkgs/development/libraries/xmlrpc-c/default.nix b/pkgs/development/libraries/xmlrpc-c/default.nix
index 0b5f08bdf9b3..8a0017109bbf 100644
--- a/pkgs/development/libraries/xmlrpc-c/default.nix
+++ b/pkgs/development/libraries/xmlrpc-c/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, curl, libxml2 }:
 
 stdenv.mkDerivation rec {
-  name = "xmlrpc-c-1.33.17";
+  name = "xmlrpc-c-1.39.12";
 
   src = fetchurl {
     url = "mirror://sourceforge/xmlrpc-c/${name}.tgz";
-    sha256 = "0makq1zpfqnrj6xx1xc7wi4mh115ri9p4yz2rbvjhj0il4y8l4ah";
+    sha256 = "026fh7w7y3q9pvxd09i5d4hq3l6gd81n9k19yq4zwbc398kg6c6q";
   };
 
   buildInputs = [ curl libxml2 ];
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
     # <xmlrpc-c>/doc/COPYING also lists "Expat license",
     # "ABYSS Web Server License" and "Python 1.5.2 License"
     license = licenses.bsd3;
-    platforms = platforms.linux;
+    platforms = platforms.unix;
     maintainers = [ maintainers.bjornfor ];
   };
 }
diff --git a/pkgs/development/libraries/xvidcore/default.nix b/pkgs/development/libraries/xvidcore/default.nix
index 057be97ce96b..17d7320cb648 100644
--- a/pkgs/development/libraries/xvidcore/default.nix
+++ b/pkgs/development/libraries/xvidcore/default.nix
@@ -3,11 +3,11 @@
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "xvidcore-${version}";
-  version = "1.3.4";
-  
+  version = "1.3.5";
+
   src = fetchurl {
     url = "http://downloads.xvid.org/downloads/${name}.tar.bz2";
-    sha256 = "1xwbmp9wqshc0ckm970zdpi0yvgqxlqg0s8bkz98mnr8p2067bsz";
+    sha256 = "1d0hy1w9sn6491a3vhyf3vmhq4xkn6yd4ralx1191s6qz5wz483w";
   };
 
   preConfigure = ''
@@ -35,7 +35,7 @@ stdenv.mkDerivation rec {
   postInstall = optionalString (!stdenv.isDarwin) ''
     rm $out/lib/*.a
   '';
-  
+
   meta = {
     description = "MPEG-4 video codec for PC";
     homepage    = https://www.xvid.com/;
diff --git a/pkgs/development/libraries/xxHash/default.nix b/pkgs/development/libraries/xxHash/default.nix
index d702500bf719..cbe32da64457 100644
--- a/pkgs/development/libraries/xxHash/default.nix
+++ b/pkgs/development/libraries/xxHash/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "xxHash-${version}";
-  version = "0.6.3.20171018";
+  version = "0.6.4.20171222";
 
   src = fetchFromGitHub {
-    sha256 = "0061ivxpx0p24m4vg7kfx9fs9f0jxvv4g76bmyss5gp90p05hc18";
-    rev = "333804ccf0c0339451accac023deeab9e5f7c002";
+    sha256 = "1az5vm14rdc3pa3l0wj180wpii14if16diril3gz8q9ip1215gwj";
+    rev = "7caf8bd76440c75dfe1070d3acfbd7891aea8fca";
     repo = "xxHash";
     owner = "Cyan4973";
   };
diff --git a/pkgs/development/libraries/yajl/default.nix b/pkgs/development/libraries/yajl/default.nix
index c6ab03df10a1..02e1e96cabd1 100644
--- a/pkgs/development/libraries/yajl/default.nix
+++ b/pkgs/development/libraries/yajl/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cmake, ruby }:
+{ stdenv, fetchurl, cmake }:
 
 stdenv.mkDerivation rec {
   name = "yajl-2.1.0";
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
     sha256 = "0f6yrjc05aa26wfi7lqn2gslm19m6rm81b30ksllpkappvh162ji";
   };
 
-  buildInputs = [ cmake ruby ];
+  nativeBuildInputs = [ cmake ];
 
   meta = {
     description = "Yet Another JSON Library";
diff --git a/pkgs/development/libraries/zeitgeist/dbus_glib.patch b/pkgs/development/libraries/zeitgeist/dbus_glib.patch
deleted file mode 100644
index 872ea0db31b8..000000000000
--- a/pkgs/development/libraries/zeitgeist/dbus_glib.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- configure.ac	2014-01-27 22:45:42.000000000 +0100
-+++ configure.ac.new	2014-05-02 17:25:45.813491239 +0200
-@@ -151,6 +151,7 @@
-                             gio-2.0 >= $GLIB_REQUIRED
-                             gio-unix-2.0 >= $GLIB_REQUIRED
-                             gtk+-3.0 >= $GTK_REQUIRED
-+                            dbus-glib-1
-                             json-glib-1.0 >= $JSON_GLIB_REQUIRED"
- 
- AC_ARG_ENABLE([datahub],
diff --git a/pkgs/development/libraries/zeitgeist/default.nix b/pkgs/development/libraries/zeitgeist/default.nix
index ed84dec365e1..33cf5dd4af84 100644
--- a/pkgs/development/libraries/zeitgeist/default.nix
+++ b/pkgs/development/libraries/zeitgeist/default.nix
@@ -1,39 +1,34 @@
-{ stdenv, fetchgit, pkgconfig, glib, sqlite, gnome3, vala_0_38
-, intltool, libtool, dbus_libs, telepathy_glib
-, gtk3, json_glib, librdf_raptor2, dbus_glib
+{ stdenv, fetchgit, pkgconfig, glib, sqlite, vala_0_38
+, autoconf, automake, libtool, gettext, dbus_libs, telepathy-glib
+, gtk3, json-glib, librdf_raptor2, dbus-glib
 , pythonSupport ? true, python2Packages
 }:
 
 stdenv.mkDerivation rec {
-  version = "1.0";
+  version = "1.0.1";
   name = "zeitgeist-${version}";
 
   src = fetchgit {
     url = "git://anongit.freedesktop.org/git/zeitgeist/zeitgeist";
     rev = "v${version}";
-    sha256 = "0vw6m0azycqabbz8f0fd8xsh5kf6j3ig4wpqlhw6sklvf44ii5b8";
+    sha256 = "1lgqcqr5h9ba751b7ajp7h2w1bb5qza2w3k1f95j3ab15p7q0q44";
   };
 
-  NIX_CFLAGS_COMPILE = "-I${glib.dev}/include/gio-unix-2.0";
-
-  configureScript = "./autogen.sh";
+  preConfigure = "NOCONFIGURE=1 ./autogen.sh";
 
   configureFlags = [ "--with-session-bus-services-dir=$(out)/share/dbus-1/services" ];
 
-  nativeBuildInputs = [ pkgconfig gnome3.gnome_common intltool libtool vala_0_38 ];
-  buildInputs = [ glib sqlite dbus_libs telepathy_glib dbus_glib
-                  gtk3 json_glib librdf_raptor2 python2Packages.rdflib ];
+  nativeBuildInputs = [ autoconf automake libtool pkgconfig gettext vala_0_38 python2Packages.python ];
+  buildInputs = [
+    glib sqlite dbus_libs telepathy-glib dbus-glib
+    gtk3 json-glib librdf_raptor2 python2Packages.rdflib
+  ];
 
   prePatch = "patchShebangs .";
 
-  patches = [ ./dbus_glib.patch ];
-
-  patchFlags = [ "-p0" ];
-
   enableParallelBuilding = true;
 
-  postFixup = ''
-  '' + stdenv.lib.optionalString pythonSupport ''
+  postFixup = stdenv.lib.optionalString pythonSupport ''
     moveToOutput lib/${python2Packages.python.libPrefix} "$py"
   '';
 
diff --git a/pkgs/development/libraries/zeromq/4.x.nix b/pkgs/development/libraries/zeromq/4.x.nix
index 030246db3185..eea0fb727b01 100644
--- a/pkgs/development/libraries/zeromq/4.x.nix
+++ b/pkgs/development/libraries/zeromq/4.x.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "zeromq-${version}";
-  version = "4.2.2";
+  version = "4.2.3";
 
   src = fetchFromGitHub {
     owner = "zeromq";
     repo = "libzmq";
     rev = "v${version}";
-    sha256 = "09317g4zkalp3k11x6vbidcm4qf02ciml1wxgp3742lrlgcblgxy";
+    sha256 = "1yadf4vz4m49lpwwwscxs6wf4v9dgqgxkwgwpby9lvb4pv8qbmaf";
   };
 
   nativeBuildInputs = [ cmake asciidoc ];
diff --git a/pkgs/development/libraries/zimg/default.nix b/pkgs/development/libraries/zimg/default.nix
index b5bb73e3e33b..f67964748dca 100644
--- a/pkgs/development/libraries/zimg/default.nix
+++ b/pkgs/development/libraries/zimg/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec{
   name = "zimg-${version}";
-  version = "2.6.1";
+  version = "2.7.4";
 
   src = fetchFromGitHub {
     owner  = "sekrit-twc";
     repo   = "zimg";
     rev    = "release-${version}";
-    sha256 = "08hynzcxz95a4i67k5cn6isafdb6xjgd0x0miyhlnp2xc220zfqj";
+    sha256 = "1gpmf6algpl1g1z891jfnsici84scg2cq1kj4v90glgik9z99mci";
   };
 
   nativeBuildInputs = [ autoreconfHook ];
diff --git a/pkgs/development/libraries/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix
index ceb4bb9f370b..de2e0b62f9e2 100644
--- a/pkgs/development/libraries/zlib/default.nix
+++ b/pkgs/development/libraries/zlib/default.nix
@@ -62,7 +62,7 @@ stdenv.mkDerivation rec {
   ];
 
   makeFlags = [
-    "PREFIX=${stdenv.cc.prefix}"
+    "PREFIX=${stdenv.cc.targetPrefix}"
   ] ++ stdenv.lib.optionals (hostPlatform.libc == "msvcrt") [
     "-f" "win32/Makefile.gcc"
   ] ++ stdenv.lib.optionals (!static) [
diff --git a/pkgs/development/libraries/zlog/default.nix b/pkgs/development/libraries/zlog/default.nix
index d3dc41371de3..21d8a7babb3c 100644
--- a/pkgs/development/libraries/zlog/default.nix
+++ b/pkgs/development/libraries/zlog/default.nix
@@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
     homepage = http://hardysimpson.github.com/zlog;
     license = licenses.lgpl21;
     platforms = platforms.linux; # cannot test on something else
-    maintainers = [ maintainers.matthiasbeyer ];
+    maintainers = [ ];
   };
 
 }
diff --git a/pkgs/development/libraries/zxcvbn-c/default.nix b/pkgs/development/libraries/zxcvbn-c/default.nix
new file mode 100644
index 000000000000..1ba073943483
--- /dev/null
+++ b/pkgs/development/libraries/zxcvbn-c/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchFromGitHub }:
+stdenv.mkDerivation rec {
+  name = "zxcvbn-c-${version}";
+  version = "2.3";
+
+  src = fetchFromGitHub {
+    owner = "tsyrogit";
+    repo = "zxcvbn-c";
+    rev = "v${version}";
+    sha256 = "1m097b4qq1r3kk4b236pc3mpaj22il9fh43ifagad5wy54x8zf7b";
+  };
+
+  installPhase = ''
+    install -D -t $out/lib libzxcvbn.so*
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/tsyrogit/zxcvbn-c;
+    description = "A C/C++ implementation of the zxcvbn password strength estimation";
+    license = licenses.mit;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ xurei ];
+  };
+}
diff --git a/pkgs/development/libraries/zziplib/default.nix b/pkgs/development/libraries/zziplib/default.nix
index 07a6f7ef0889..b59cb47eae57 100644
--- a/pkgs/development/libraries/zziplib/default.nix
+++ b/pkgs/development/libraries/zziplib/default.nix
@@ -1,21 +1,26 @@
-{ fetchurl, stdenv, perl, python2, zip, xmlto, zlib }:
+{ docbook_xml_dtd_412, fetchurl, stdenv, perl, python2, zip, xmlto, zlib }:
 
 stdenv.mkDerivation rec {
   name = "zziplib-${version}";
-  version = "0.13.67";
+  version = "0.13.69";
 
   src = fetchurl {
     url = "https://github.com/gdraheim/zziplib/archive/v${version}.tar.gz";
-    sha256 = "0802kdxwxx9zanpwb4w4wfi3blwhv0ri05mzdgd35j5sva5ify0j";
+    sha256 = "0i052a7shww0fzsxrdp3rd7g4mbzx7324a8ysbc0br7frpblcql4";
   };
 
-  patchPhase = ''
+  postPatch = ''
     sed -i -e s,--export-dynamic,, configure
   '';
 
-  buildInputs = [ perl python2 zip xmlto zlib ];
+  # TODO: still an issue: https://github.com/gdraheim/zziplib/issues/27
 
-  doCheck = true;
+  buildInputs = [ docbook_xml_dtd_412 perl python2 zip xmlto zlib ];
+
+  # tests are broken (https://github.com/gdraheim/zziplib/issues/20),
+  # and test/zziptests.py requires network access
+  # (https://github.com/gdraheim/zziplib/issues/24)
+  doCheck = false;
 
   meta = with stdenv.lib; {
     description = "Library to extract data from files archived in a zip file";