summary refs log tree commit diff
path: root/pkgs/development/libraries
diff options
context:
space:
mode:
authorRobin Gloster <mail@glob.in>2019-08-25 18:55:46 +0200
committerRobin Gloster <mail@glob.in>2019-08-25 18:55:46 +0200
commit616b8343c4c384f651f51d8c9b8e96239e1113d0 (patch)
treec6894ea5e950e373bcf8c8e8948fb2a7d4716565 /pkgs/development/libraries
parent45d6ccea3357c65135b985f2eebf88020ca6461e (diff)
parent48191315aa2e34643203dbfc5ae8bd84c1cafe54 (diff)
downloadnixpkgs-616b8343c4c384f651f51d8c9b8e96239e1113d0.tar
nixpkgs-616b8343c4c384f651f51d8c9b8e96239e1113d0.tar.gz
nixpkgs-616b8343c4c384f651f51d8c9b8e96239e1113d0.tar.bz2
nixpkgs-616b8343c4c384f651f51d8c9b8e96239e1113d0.tar.lz
nixpkgs-616b8343c4c384f651f51d8c9b8e96239e1113d0.tar.xz
nixpkgs-616b8343c4c384f651f51d8c9b8e96239e1113d0.tar.zst
nixpkgs-616b8343c4c384f651f51d8c9b8e96239e1113d0.zip
Merge remote-tracking branch 'upstream/master' into gcc-8
Diffstat (limited to 'pkgs/development/libraries')
-rw-r--r--pkgs/development/libraries/SDL/default.nix10
-rw-r--r--pkgs/development/libraries/SDL2/default.nix11
-rw-r--r--pkgs/development/libraries/SDL2_image/default.nix4
-rw-r--r--pkgs/development/libraries/SDL_gpu/default.nix36
-rw-r--r--pkgs/development/libraries/aacskeys/default.nix47
-rw-r--r--pkgs/development/libraries/accountsservice/default.nix78
-rw-r--r--pkgs/development/libraries/accountsservice/fix-paths.patch125
-rw-r--r--pkgs/development/libraries/ace/default.nix4
-rw-r--r--pkgs/development/libraries/agda/agda-iowa-stdlib/default.nix4
-rw-r--r--pkgs/development/libraries/agda/agda-prelude/default.nix4
-rw-r--r--pkgs/development/libraries/agda/agda-stdlib/default.nix4
-rw-r--r--pkgs/development/libraries/appstream-glib/default.nix6
-rw-r--r--pkgs/development/libraries/appstream/default.nix2
-rw-r--r--pkgs/development/libraries/aravis/default.nix4
-rw-r--r--pkgs/development/libraries/arb/default.nix2
-rw-r--r--pkgs/development/libraries/armadillo/default.nix4
-rw-r--r--pkgs/development/libraries/arrow-cpp/default.nix32
-rw-r--r--pkgs/development/libraries/at-spi2-atk/default.nix2
-rw-r--r--pkgs/development/libraries/at-spi2-core/default.nix2
-rw-r--r--pkgs/development/libraries/audio/libbass/default.nix18
-rw-r--r--pkgs/development/libraries/avahi/default.nix2
-rw-r--r--pkgs/development/libraries/aws-c-common/default.nix6
-rw-r--r--pkgs/development/libraries/aws-checksums/default.nix4
-rw-r--r--pkgs/development/libraries/boehm-gc/default.nix2
-rw-r--r--pkgs/development/libraries/boost/generic.nix2
-rw-r--r--pkgs/development/libraries/caf/default.nix4
-rw-r--r--pkgs/development/libraries/cairo/default.nix2
-rw-r--r--pkgs/development/libraries/catch2/default.nix2
-rw-r--r--pkgs/development/libraries/cdo/default.nix16
-rw-r--r--pkgs/development/libraries/ceres-solver/default.nix8
-rw-r--r--pkgs/development/libraries/cfitsio/darwin-curl-config.patch25
-rw-r--r--pkgs/development/libraries/cfitsio/default.nix13
-rw-r--r--pkgs/development/libraries/cimg/default.nix4
-rw-r--r--pkgs/development/libraries/clutter-gst/default.nix4
-rw-r--r--pkgs/development/libraries/cm256cc/default.nix23
-rw-r--r--pkgs/development/libraries/cogl/default.nix6
-rw-r--r--pkgs/development/libraries/coin3d/default.nix33
-rw-r--r--pkgs/development/libraries/coin3d/gcc-4.8.patch38
-rw-r--r--pkgs/development/libraries/coin3d/sbhashentry.patch25
-rw-r--r--pkgs/development/libraries/cpp-netlib/default.nix15
-rw-r--r--pkgs/development/libraries/cpp-utilities/default.nix27
-rw-r--r--pkgs/development/libraries/cppzmq/default.nix4
-rw-r--r--pkgs/development/libraries/crc32c/default.nix24
-rw-r--r--pkgs/development/libraries/cre2/default.nix8
-rw-r--r--pkgs/development/libraries/ctypes_sh/default.nix28
-rw-r--r--pkgs/development/libraries/cutelyst/default.nix14
-rw-r--r--pkgs/development/libraries/cyrus-sasl/default.nix2
-rw-r--r--pkgs/development/libraries/czmq/4.x.nix2
-rw-r--r--pkgs/development/libraries/dav1d/default.nix16
-rw-r--r--pkgs/development/libraries/dee/default.nix5
-rw-r--r--pkgs/development/libraries/directfb/default.nix41
-rw-r--r--pkgs/development/libraries/directfb/default.upstream3
-rw-r--r--pkgs/development/libraries/discord-rpc/default.nix40
-rw-r--r--pkgs/development/libraries/dleyna-renderer/default.nix1
-rw-r--r--pkgs/development/libraries/dlib/default.nix4
-rw-r--r--pkgs/development/libraries/eclib/default.nix1
-rw-r--r--pkgs/development/libraries/editline/default.nix2
-rw-r--r--pkgs/development/libraries/eigen/default.nix2
-rw-r--r--pkgs/development/libraries/elf-header/default.nix2
-rw-r--r--pkgs/development/libraries/exiv2/default.nix88
-rw-r--r--pkgs/development/libraries/exiv2/fix-cmake.patch16
-rw-r--r--pkgs/development/libraries/exosip/default.nix17
-rw-r--r--pkgs/development/libraries/expat/default.nix4
-rw-r--r--pkgs/development/libraries/fcppt/default.nix6
-rw-r--r--pkgs/development/libraries/ffmpeg-full/default.nix39
-rw-r--r--pkgs/development/libraries/ffmpeg-full/prefer-libdav1d-over-libaom.patch19
-rw-r--r--pkgs/development/libraries/ffmpeg/4.nix4
-rw-r--r--pkgs/development/libraries/ffms/default.nix7
-rw-r--r--pkgs/development/libraries/flatpak/bubblewrap-paths.patch4
-rw-r--r--pkgs/development/libraries/flatpak/default.nix8
-rw-r--r--pkgs/development/libraries/flatpak/fix-paths.patch6
-rw-r--r--pkgs/development/libraries/flatpak/fix-test-paths.patch29
-rw-r--r--pkgs/development/libraries/flatpak/respect-xml-catalog-files-var.patch4
-rw-r--r--pkgs/development/libraries/flatpak/unset-env-vars.patch4
-rw-r--r--pkgs/development/libraries/flatpak/use-flatpak-from-path.patch22
-rw-r--r--pkgs/development/libraries/flatpak/validate-icon-pixbuf.patch4
-rw-r--r--pkgs/development/libraries/fltk/1.4.nix32
-rw-r--r--pkgs/development/libraries/fltk/default.nix31
-rw-r--r--pkgs/development/libraries/fmt/default.nix2
-rw-r--r--pkgs/development/libraries/folly/default.nix8
-rw-r--r--pkgs/development/libraries/freetds/default.nix2
-rw-r--r--pkgs/development/libraries/freetype/default.nix7
-rw-r--r--pkgs/development/libraries/g2o/default.nix32
-rw-r--r--pkgs/development/libraries/g2o/remove-compiler-reference.patch25
-rw-r--r--pkgs/development/libraries/gcr/default.nix16
-rw-r--r--pkgs/development/libraries/gdal/001.3_0_1.darwin.patch29
-rw-r--r--pkgs/development/libraries/gdal/2.4.0.nix95
-rw-r--r--pkgs/development/libraries/gdal/default.nix46
-rw-r--r--pkgs/development/libraries/gdal/gdal-1_11.nix9
-rw-r--r--pkgs/development/libraries/gdcm/default.nix8
-rw-r--r--pkgs/development/libraries/gdk-pixbuf/default.nix3
-rw-r--r--pkgs/development/libraries/gegl/4.0.nix2
-rw-r--r--pkgs/development/libraries/geis/default.nix4
-rw-r--r--pkgs/development/libraries/geoclue/default.nix6
-rw-r--r--pkgs/development/libraries/gfbgraph/default.nix4
-rw-r--r--pkgs/development/libraries/gflags/default.nix (renamed from pkgs/development/libraries/google-gflags/default.nix)2
-rw-r--r--pkgs/development/libraries/git2/0.27.nix36
-rw-r--r--pkgs/development/libraries/git2/default.nix23
-rw-r--r--pkgs/development/libraries/givaro/default.nix4
-rw-r--r--pkgs/development/libraries/gl2ps/default.nix29
-rw-r--r--pkgs/development/libraries/glbinding/default.nix4
-rw-r--r--pkgs/development/libraries/glfw/3.x.nix13
-rw-r--r--pkgs/development/libraries/glib-networking/default.nix4
-rw-r--r--pkgs/development/libraries/glib/default.nix9
-rw-r--r--pkgs/development/libraries/globalplatform/default.nix4
-rw-r--r--pkgs/development/libraries/globalplatform/gppcscconnectionplugin.nix4
-rw-r--r--pkgs/development/libraries/gmp/5.1.x.nix2
-rw-r--r--pkgs/development/libraries/gmp/6.x.nix2
-rw-r--r--pkgs/development/libraries/gnome-online-accounts/default.nix52
-rw-r--r--pkgs/development/libraries/gnome-sharp/default.nix2
-rw-r--r--pkgs/development/libraries/gnome-sharp/fix-mono-path.patch13
-rw-r--r--pkgs/development/libraries/gnome-video-effects/default.nix46
-rw-r--r--pkgs/development/libraries/gnome-video-effects/fix-pc-file.patch11
-rw-r--r--pkgs/development/libraries/gnutls/default.nix4
-rw-r--r--pkgs/development/libraries/gobject-introspection/default.nix6
-rw-r--r--pkgs/development/libraries/gom/default.nix4
-rw-r--r--pkgs/development/libraries/google-cloud-cpp/default.nix65
-rw-r--r--pkgs/development/libraries/gperftools/default.nix4
-rw-r--r--pkgs/development/libraries/gpgme/default.nix4
-rw-r--r--pkgs/development/libraries/graphene-hardened-malloc/default.nix10
-rw-r--r--pkgs/development/libraries/graphene/0001-meson-add-options-for-tests-installation-dirs.patch79
-rw-r--r--pkgs/development/libraries/graphene/default.nix11
-rw-r--r--pkgs/development/libraries/grilo-plugins/default.nix82
-rw-r--r--pkgs/development/libraries/grilo/default.nix62
-rw-r--r--pkgs/development/libraries/grilo/setup-hook.sh7
-rw-r--r--pkgs/development/libraries/grpc/default.nix7
-rw-r--r--pkgs/development/libraries/gsettings-desktop-schemas/default.nix2
-rw-r--r--pkgs/development/libraries/gsettings-qt/default.nix6
-rw-r--r--pkgs/development/libraries/gsignond/default.nix2
-rw-r--r--pkgs/development/libraries/gsignond/plugins/oauth.nix2
-rw-r--r--pkgs/development/libraries/gsignond/plugins/sasl.nix2
-rw-r--r--pkgs/development/libraries/gsignond/wrapper.nix2
-rw-r--r--pkgs/development/libraries/gstreamer/bad/default.nix132
-rw-r--r--pkgs/development/libraries/gstreamer/base/default.nix51
-rw-r--r--pkgs/development/libraries/gstreamer/core/default.nix45
-rw-r--r--pkgs/development/libraries/gstreamer/default.nix6
-rw-r--r--pkgs/development/libraries/gstreamer/ges/default.nix12
-rw-r--r--pkgs/development/libraries/gstreamer/good/default.nix45
-rw-r--r--pkgs/development/libraries/gstreamer/legacy/gst-plugins-good/default.nix4
-rw-r--r--pkgs/development/libraries/gstreamer/legacy/gstreamer/default.nix3
-rw-r--r--pkgs/development/libraries/gstreamer/libav/default.nix10
-rw-r--r--pkgs/development/libraries/gstreamer/rtsp-server/default.nix16
-rw-r--r--pkgs/development/libraries/gstreamer/ugly/default.nix13
-rw-r--r--pkgs/development/libraries/gstreamer/vaapi/default.nix10
-rw-r--r--pkgs/development/libraries/gstreamer/validate/default.nix9
-rw-r--r--pkgs/development/libraries/gthree/default.nix72
-rw-r--r--pkgs/development/libraries/gtk+/01-build-Fix-path-handling-in-pkgconfig.patch30
-rw-r--r--pkgs/development/libraries/gtk+/2.x.nix4
-rw-r--r--pkgs/development/libraries/gtk+/3.x.nix170
-rw-r--r--pkgs/development/libraries/gtk+/gtk3-setup-hook.sh10
-rw-r--r--pkgs/development/libraries/gtkd/default.nix23
-rw-r--r--pkgs/development/libraries/gvfs/default.nix4
-rw-r--r--pkgs/development/libraries/harfbuzz/default.nix4
-rw-r--r--pkgs/development/libraries/hpx/default.nix4
-rw-r--r--pkgs/development/libraries/hunspell/0001-Make-hunspell-look-in-XDG_DATA_DIRS-for-dictionaries.patch37
-rw-r--r--pkgs/development/libraries/hunspell/default.nix2
-rw-r--r--pkgs/development/libraries/hunspell/dictionaries.nix51
-rw-r--r--pkgs/development/libraries/hwloc/default.nix4
-rw-r--r--pkgs/development/libraries/ilmbase/default.nix2
-rw-r--r--pkgs/development/libraries/imlib/default.nix10
-rw-r--r--pkgs/development/libraries/intel-gmmlib/default.nix4
-rw-r--r--pkgs/development/libraries/intel-media-driver/default.nix6
-rw-r--r--pkgs/development/libraries/itk/default.nix16
-rw-r--r--pkgs/development/libraries/java/commons/lang/default.nix4
-rw-r--r--pkgs/development/libraries/java/swt/default.nix4
-rw-r--r--pkgs/development/libraries/jsoncpp/default.nix4
-rw-r--r--pkgs/development/libraries/kde-frameworks/default.nix15
-rw-r--r--pkgs/development/libraries/kde-frameworks/extra-cmake-modules/setup-hook.sh64
-rw-r--r--pkgs/development/libraries/kde-frameworks/kconfigwidgets/default.nix7
-rw-r--r--pkgs/development/libraries/kde-frameworks/kinit/default.nix4
-rw-r--r--pkgs/development/libraries/kde-frameworks/ktexteditor.nix4
-rw-r--r--pkgs/development/libraries/kerberos/heimdal.nix4
-rw-r--r--pkgs/development/libraries/kinetic-cpp-client/default.nix4
-rw-r--r--pkgs/development/libraries/kpmcore/default.nix4
-rw-r--r--pkgs/development/libraries/languagemachines/packages.nix12
-rw-r--r--pkgs/development/libraries/lasem/default.nix8
-rw-r--r--pkgs/development/libraries/ldacbt/default.nix1
-rw-r--r--pkgs/development/libraries/leatherman/default.nix4
-rw-r--r--pkgs/development/libraries/leptonica/default.nix2
-rw-r--r--pkgs/development/libraries/lib3mf/default.nix4
-rw-r--r--pkgs/development/libraries/libao/default.nix2
-rw-r--r--pkgs/development/libraries/libaom/default.nix2
-rw-r--r--pkgs/development/libraries/libaosd/default.nix2
-rw-r--r--pkgs/development/libraries/libarchive/default.nix29
-rw-r--r--pkgs/development/libraries/libargon2/default.nix12
-rw-r--r--pkgs/development/libraries/libbladeRF/default.nix2
-rw-r--r--pkgs/development/libraries/libblockdev/default.nix33
-rw-r--r--pkgs/development/libraries/libbluray/default.nix4
-rw-r--r--pkgs/development/libraries/libbytesize/default.nix4
-rw-r--r--pkgs/development/libraries/libcacard/default.nix4
-rw-r--r--pkgs/development/libraries/libcdaudio/default.nix6
-rw-r--r--pkgs/development/libraries/libcef/default.nix4
-rw-r--r--pkgs/development/libraries/libcouchbase/default.nix4
-rw-r--r--pkgs/development/libraries/libcsptr/default.nix2
-rw-r--r--pkgs/development/libraries/libdap/default.nix4
-rw-r--r--pkgs/development/libraries/libdazzle/default.nix4
-rw-r--r--pkgs/development/libraries/libdeflate/default.nix4
-rw-r--r--pkgs/development/libraries/libdrm/default.nix22
-rw-r--r--pkgs/development/libraries/libelf/default.nix5
-rw-r--r--pkgs/development/libraries/libelf/preprocessor-warnings.patch264
-rw-r--r--pkgs/development/libraries/libetpan/default.nix27
-rw-r--r--pkgs/development/libraries/libev/default.nix4
-rw-r--r--pkgs/development/libraries/libevdev/default.nix4
-rw-r--r--pkgs/development/libraries/libevent/default.nix2
-rw-r--r--pkgs/development/libraries/libextractor/default.nix12
-rw-r--r--pkgs/development/libraries/libfaketime/default.nix2
-rw-r--r--pkgs/development/libraries/libfilezilla/default.nix17
-rw-r--r--pkgs/development/libraries/libfsm/default.nix53
-rw-r--r--pkgs/development/libraries/libftdi/default.nix8
-rw-r--r--pkgs/development/libraries/libgdamm/default.nix4
-rw-r--r--pkgs/development/libraries/libgdata/default.nix82
-rw-r--r--pkgs/development/libraries/libgdata/installed-tests-path.patch94
-rw-r--r--pkgs/development/libraries/libgeotiff/default.nix19
-rw-r--r--pkgs/development/libraries/libgig/default.nix4
-rw-r--r--pkgs/development/libraries/libgpg-error/default.nix2
-rw-r--r--pkgs/development/libraries/libgphoto2/default.nix6
-rw-r--r--pkgs/development/libraries/libgpiod/default.nix15
-rw-r--r--pkgs/development/libraries/libgpod/default.nix4
-rw-r--r--pkgs/development/libraries/libgsf/default.nix4
-rw-r--r--pkgs/development/libraries/libgweather/default.nix4
-rw-r--r--pkgs/development/libraries/libhandy/default.nix4
-rw-r--r--pkgs/development/libraries/libhttpseverywhere/default.nix2
-rw-r--r--pkgs/development/libraries/libical/default.nix2
-rw-r--r--pkgs/development/libraries/libiio/default.nix13
-rw-r--r--pkgs/development/libraries/libimagequant/default.nix4
-rw-r--r--pkgs/development/libraries/libimobiledevice/default.nix1
-rw-r--r--pkgs/development/libraries/libinput/default.nix4
-rw-r--r--pkgs/development/libraries/libirecovery/default.nix54
-rw-r--r--pkgs/development/libraries/libivykis/default.nix2
-rw-r--r--pkgs/development/libraries/libjpeg-turbo/default.nix6
-rw-r--r--pkgs/development/libraries/liblastfm/default.nix4
-rw-r--r--pkgs/development/libraries/liblcf/default.nix4
-rw-r--r--pkgs/development/libraries/liblockfile/default.nix4
-rw-r--r--pkgs/development/libraries/liblouis/default.nix4
-rw-r--r--pkgs/development/libraries/libmediaart/default.nix4
-rw-r--r--pkgs/development/libraries/libmediainfo/default.nix4
-rw-r--r--pkgs/development/libraries/libmicrohttpd/default.nix4
-rw-r--r--pkgs/development/libraries/libmikmod/default.nix2
-rw-r--r--pkgs/development/libraries/libmodbus/default.nix4
-rw-r--r--pkgs/development/libraries/libmodule/default.nix29
-rw-r--r--pkgs/development/libraries/libmodulemd/1.nix21
-rw-r--r--pkgs/development/libraries/libmodulemd/default.nix59
-rw-r--r--pkgs/development/libraries/libmodulemd/dont-check-docs.patch29
-rw-r--r--pkgs/development/libraries/libmodulemd/pygobject-dir.patch45
-rw-r--r--pkgs/development/libraries/libmpack/default.nix2
-rw-r--r--pkgs/development/libraries/libndctl/default.nix6
-rw-r--r--pkgs/development/libraries/libnice/default.nix18
-rw-r--r--pkgs/development/libraries/libnotify/default.nix4
-rw-r--r--pkgs/development/libraries/libnxml/default.nix2
-rw-r--r--pkgs/development/libraries/libosinfo/default.nix21
-rw-r--r--pkgs/development/libraries/libosinfo/osinfo-db-data-dir.patch2
-rw-r--r--pkgs/development/libraries/libosmium/default.nix4
-rw-r--r--pkgs/development/libraries/libow/default.nix2
-rw-r--r--pkgs/development/libraries/libpinyin/default.nix29
-rw-r--r--pkgs/development/libraries/libpqxx/default.nix4
-rw-r--r--pkgs/development/libraries/libqalculate/default.nix4
-rw-r--r--pkgs/development/libraries/libqglviewer/default.nix20
-rw-r--r--pkgs/development/libraries/libraw/default.nix4
-rw-r--r--pkgs/development/libraries/librealsense/default.nix4
-rw-r--r--pkgs/development/libraries/librelp/default.nix25
-rw-r--r--pkgs/development/libraries/libressl/default.nix19
-rw-r--r--pkgs/development/libraries/librime/default.nix6
-rw-r--r--pkgs/development/libraries/librsvg/default.nix8
-rw-r--r--pkgs/development/libraries/libsass/default.nix4
-rw-r--r--pkgs/development/libraries/libshout/default.nix4
-rw-r--r--pkgs/development/libraries/libsolv/default.nix4
-rw-r--r--pkgs/development/libraries/libspatialite/default.nix3
-rw-r--r--pkgs/development/libraries/libspf2/default.nix43
-rw-r--r--pkgs/development/libraries/libssh/default.nix2
-rw-r--r--pkgs/development/libraries/libssh2/default.nix4
-rw-r--r--pkgs/development/libraries/libstatgrab/default.nix4
-rw-r--r--pkgs/development/libraries/libsystemtap/default.nix30
-rw-r--r--pkgs/development/libraries/libtensorflow/default.nix80
-rw-r--r--pkgs/development/libraries/libtorrent-rasterbar/default.nix2
-rw-r--r--pkgs/development/libraries/libtoxcore/default.nix4
-rw-r--r--pkgs/development/libraries/libuchardet/default.nix3
-rw-r--r--pkgs/development/libraries/libui/default.nix4
-rw-r--r--pkgs/development/libraries/liburcu/default.nix4
-rw-r--r--pkgs/development/libraries/liburing/default.nix47
-rw-r--r--pkgs/development/libraries/libuv/default.nix6
-rw-r--r--pkgs/development/libraries/libva-utils/default.nix2
-rw-r--r--pkgs/development/libraries/libva/1.0.0.nix6
-rw-r--r--pkgs/development/libraries/libva/default.nix10
-rw-r--r--pkgs/development/libraries/libvdpau/default.nix4
-rw-r--r--pkgs/development/libraries/libversion/default.nix8
-rw-r--r--pkgs/development/libraries/libvirt-glib/default.nix5
-rw-r--r--pkgs/development/libraries/libvirt/default.nix38
-rw-r--r--pkgs/development/libraries/libvisio/default.nix4
-rw-r--r--pkgs/development/libraries/libvisual/default.nix2
-rw-r--r--pkgs/development/libraries/libvterm-neovim/default.nix2
-rw-r--r--pkgs/development/libraries/libwebp/default.nix4
-rw-r--r--pkgs/development/libraries/libwebsockets/default.nix4
-rw-r--r--pkgs/development/libraries/libwnck/3.x.nix77
-rw-r--r--pkgs/development/libraries/libwnck/fix-pc-file.patch24
-rw-r--r--pkgs/development/libraries/libxkbcommon/default.nix25
-rw-r--r--pkgs/development/libraries/libxkbcommon/libxkbcommon_7.nix2
-rw-r--r--pkgs/development/libraries/libxml2/default.nix2
-rw-r--r--pkgs/development/libraries/libxmlb/default.nix60
-rw-r--r--pkgs/development/libraries/libxmlb/installed-tests-path.patch24
-rw-r--r--pkgs/development/libraries/libxmlxx/v3.nix14
-rw-r--r--pkgs/development/libraries/libxslt/default.nix10
-rw-r--r--pkgs/development/libraries/libyaml/default.nix40
-rw-r--r--pkgs/development/libraries/libzapojit/default.nix4
-rw-r--r--pkgs/development/libraries/linbox/default.nix5
-rw-r--r--pkgs/development/libraries/liquid-dsp/default.nix2
-rw-r--r--pkgs/development/libraries/live555/default.nix4
-rw-r--r--pkgs/development/libraries/lmdb/default.nix4
-rw-r--r--pkgs/development/libraries/luaffi/darwin.patch17
-rw-r--r--pkgs/development/libraries/luaffi/default.nix31
-rw-r--r--pkgs/development/libraries/luaffi/makefile-errors.patch13
-rw-r--r--pkgs/development/libraries/mapnik/default.nix4
-rw-r--r--pkgs/development/libraries/matio/default.nix4
-rw-r--r--pkgs/development/libraries/mdds/default.nix4
-rw-r--r--pkgs/development/libraries/mesa/default.nix295
-rw-r--r--pkgs/development/libraries/mesa/disk_cache-include-dri-driver-path-in-cache-key.patch59
-rw-r--r--pkgs/development/libraries/mesa/opencl-install-dir.patch12
-rw-r--r--pkgs/development/libraries/mesa/stubs.nix75
-rw-r--r--pkgs/development/libraries/mesa/symlink-drivers.patch112
-rw-r--r--pkgs/development/libraries/mlt/default.nix4
-rw-r--r--pkgs/development/libraries/mlt/qt-5.nix4
-rw-r--r--pkgs/development/libraries/movit/default.nix4
-rw-r--r--pkgs/development/libraries/mp4v2/default.nix2
-rw-r--r--pkgs/development/libraries/mtxclient/default.nix30
-rw-r--r--pkgs/development/libraries/mumlib/default.nix28
-rw-r--r--pkgs/development/libraries/mutest/default.nix34
-rw-r--r--pkgs/development/libraries/nco/default.nix10
-rw-r--r--pkgs/development/libraries/nss/default.nix4
-rw-r--r--pkgs/development/libraries/nss_wrapper/default.nix4
-rw-r--r--pkgs/development/libraries/nsss/default.nix2
-rw-r--r--pkgs/development/libraries/nuspell/default.nix14
-rw-r--r--pkgs/development/libraries/odpic/default.nix26
-rw-r--r--pkgs/development/libraries/ogre/default.nix4
-rw-r--r--pkgs/development/libraries/olm/default.nix4
-rw-r--r--pkgs/development/libraries/oniguruma/default.nix4
-rw-r--r--pkgs/development/libraries/openbsm/default.nix2
-rw-r--r--pkgs/development/libraries/opencascade-occt/default.nix30
-rw-r--r--pkgs/development/libraries/opencollada/default.nix4
-rw-r--r--pkgs/development/libraries/opencv/3.x.nix37
-rw-r--r--pkgs/development/libraries/opencv/4.x.nix18
-rw-r--r--pkgs/development/libraries/opencv/default.nix4
-rw-r--r--pkgs/development/libraries/opendkim/default.nix6
-rw-r--r--pkgs/development/libraries/opendkim/openssl-1.1.patch81
-rw-r--r--pkgs/development/libraries/openexr/default.nix2
-rw-r--r--pkgs/development/libraries/openjpeg/1.x.nix1
-rw-r--r--pkgs/development/libraries/openjpeg/2.x.nix10
-rw-r--r--pkgs/development/libraries/openjpeg/generic.nix11
-rw-r--r--pkgs/development/libraries/openmpi/default.nix15
-rw-r--r--pkgs/development/libraries/opensaml-cpp/default.nix14
-rw-r--r--pkgs/development/libraries/openscenegraph/3.4.0.nix39
-rw-r--r--pkgs/development/libraries/openscenegraph/default.nix12
-rw-r--r--pkgs/development/libraries/openssl/default.nix2
-rw-r--r--pkgs/development/libraries/opensubdiv/default.nix4
-rw-r--r--pkgs/development/libraries/openvdb/default.nix4
-rw-r--r--pkgs/development/libraries/openxr-loader/default.nix40
-rw-r--r--pkgs/development/libraries/oracle-instantclient/default.nix131
-rw-r--r--pkgs/development/libraries/orcania/default.nix32
-rw-r--r--pkgs/development/libraries/packr/default.nix25
-rw-r--r--pkgs/development/libraries/pagmo2/default.nix4
-rw-r--r--pkgs/development/libraries/pcl/default.nix6
-rw-r--r--pkgs/development/libraries/physics/apfel/default.nix4
-rw-r--r--pkgs/development/libraries/physics/geant4/default.nix2
-rw-r--r--pkgs/development/libraries/physics/geant4/g4py/default.nix2
-rw-r--r--pkgs/development/libraries/physics/hepmc2/default.nix (renamed from pkgs/development/libraries/physics/hepmc/default.nix)8
-rw-r--r--pkgs/development/libraries/physics/hepmc2/in_source.patch (renamed from pkgs/development/libraries/physics/hepmc/in_source.patch)0
-rw-r--r--pkgs/development/libraries/physics/pythia/default.nix10
-rw-r--r--pkgs/development/libraries/physics/rivet/default.nix8
-rw-r--r--pkgs/development/libraries/physics/thepeg/default.nix6
-rw-r--r--pkgs/development/libraries/physics/yoda/default.nix4
-rw-r--r--pkgs/development/libraries/pixman/default.nix2
-rw-r--r--pkgs/development/libraries/png++/default.nix4
-rw-r--r--pkgs/development/libraries/poco/default.nix4
-rw-r--r--pkgs/development/libraries/podofo/default.nix1
-rw-r--r--pkgs/development/libraries/polkit/default.nix2
-rw-r--r--pkgs/development/libraries/proj-datumgrid/default.nix32
-rw-r--r--pkgs/development/libraries/proj/5.2.nix20
-rw-r--r--pkgs/development/libraries/proj/default.nix21
-rw-r--r--pkgs/development/libraries/prometheus-cpp/default.nix4
-rw-r--r--pkgs/development/libraries/properties-cpp/default.nix4
-rw-r--r--pkgs/development/libraries/protobuf/3.4.nix6
-rw-r--r--pkgs/development/libraries/protobuf/3.5.nix6
-rw-r--r--pkgs/development/libraries/protobuf/3.8.nix6
-rw-r--r--pkgs/development/libraries/protobuf/3.9.nix6
-rw-r--r--pkgs/development/libraries/protobuf/generic-v3.nix6
-rw-r--r--pkgs/development/libraries/protozero/default.nix4
-rw-r--r--pkgs/development/libraries/ptex/default.nix27
-rw-r--r--pkgs/development/libraries/pth/default.nix3
-rw-r--r--pkgs/development/libraries/ptlib/default.nix5
-rw-r--r--pkgs/development/libraries/pyotherside/default.nix4
-rw-r--r--pkgs/development/libraries/qca2/default.nix4
-rw-r--r--pkgs/development/libraries/qgnomeplatform/default.nix8
-rw-r--r--pkgs/development/libraries/qpdf/default.nix2
-rw-r--r--pkgs/development/libraries/qt-3/default.nix5
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/default.nix24
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/qt4-gcc6.patch33
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/qt4-openssl-1.1.patch398
-rw-r--r--pkgs/development/libraries/qt-5/5.11/default.nix51
-rw-r--r--pkgs/development/libraries/qt-5/5.11/qttools.patch15
-rw-r--r--pkgs/development/libraries/qt-5/5.12/default.nix52
-rw-r--r--pkgs/development/libraries/qt-5/5.12/qtbase.patch60
-rw-r--r--pkgs/development/libraries/qt-5/5.12/qttools.patch15
-rw-r--r--pkgs/development/libraries/qt-5/5.12/qtwebengine-darwin-no-platform-check.patch12
-rw-r--r--pkgs/development/libraries/qt-5/5.6/default.nix183
-rw-r--r--pkgs/development/libraries/qt-5/5.6/fetch.sh2
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase-fixguicmake.patch30
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase.patch795
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtdeclarative.patch20
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtscript.patch13
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtserialport.patch22
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qttools.patch64
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebengine-seccomp.patch24
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebkit.patch149
-rw-r--r--pkgs/development/libraries/qt-5/5.6/srcs.nix309
-rw-r--r--pkgs/development/libraries/qt-5/5.9/default.nix52
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase-openssl_1_1.patch3985
-rw-r--r--pkgs/development/libraries/qt-5/5.9/qtbase.patch22
-rw-r--r--pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh22
-rw-r--r--pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh102
-rw-r--r--pkgs/development/libraries/qt-5/mkDerivation.nix8
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtbase.nix9
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtconnectivity.nix4
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtmacextras.nix6
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtspeech.nix2
-rw-r--r--pkgs/development/libraries/qt-5/modules/qttools.nix5
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtwebengine.nix15
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtwebkit.nix4
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtwebview.nix10
-rw-r--r--pkgs/development/libraries/qtpbfimageplugin/default.nix39
-rw-r--r--pkgs/development/libraries/qtstyleplugins/default.nix4
-rw-r--r--pkgs/development/libraries/qtutilities/default.nix24
-rw-r--r--pkgs/development/libraries/rdkafka/default.nix4
-rw-r--r--pkgs/development/libraries/readline/readline-8.0-patches.nix1
-rw-r--r--pkgs/development/libraries/rocksdb/0001-findzlib.patch13
-rw-r--r--pkgs/development/libraries/rocksdb/default.nix100
-rw-r--r--pkgs/development/libraries/science/biology/mirtk/default.nix2
-rw-r--r--pkgs/development/libraries/science/math/brial/default.nix4
-rw-r--r--pkgs/development/libraries/science/math/caffe2/default.nix4
-rw-r--r--pkgs/development/libraries/science/math/fenics/default.nix8
-rw-r--r--pkgs/development/libraries/science/math/liblapack/default.nix3
-rw-r--r--pkgs/development/libraries/science/math/mkl/default.nix2
-rw-r--r--pkgs/development/libraries/science/math/nccl/default.nix4
-rw-r--r--pkgs/development/libraries/science/math/openblas/default.nix2
-rw-r--r--pkgs/development/libraries/science/math/or-tools/default.nix6
-rw-r--r--pkgs/development/libraries/science/math/osi/default.nix42
-rw-r--r--pkgs/development/libraries/science/math/spooles/default.nix48
-rw-r--r--pkgs/development/libraries/science/math/spooles/spooles.patch188
-rw-r--r--pkgs/development/libraries/science/math/sympow/default.nix101
-rw-r--r--pkgs/development/libraries/science/math/tensorflow/bin.nix72
-rw-r--r--pkgs/development/libraries/science/math/tensorflow/binary-hashes.nix15
-rwxr-xr-xpkgs/development/libraries/science/math/tensorflow/prefetcher.sh24
-rw-r--r--pkgs/development/libraries/serialdv/default.nix23
-rw-r--r--pkgs/development/libraries/sfml/default.nix7
-rw-r--r--pkgs/development/libraries/shibboleth-sp/default.nix4
-rw-r--r--pkgs/development/libraries/simgear/default.nix19
-rw-r--r--pkgs/development/libraries/simpleitk/default.nix17
-rw-r--r--pkgs/development/libraries/skalibs/default.nix6
-rw-r--r--pkgs/development/libraries/soil/default.nix6
-rw-r--r--pkgs/development/libraries/soqt/default.nix18
-rw-r--r--pkgs/development/libraries/soundtouch/default.nix28
-rw-r--r--pkgs/development/libraries/soxt/default.nix17
-rw-r--r--pkgs/development/libraries/speexdsp/default.nix4
-rw-r--r--pkgs/development/libraries/spice-gtk/default.nix8
-rw-r--r--pkgs/development/libraries/spice/default.nix2
-rw-r--r--pkgs/development/libraries/sqlcipher/default.nix4
-rw-r--r--pkgs/development/libraries/sqlite/default.nix3
-rw-r--r--pkgs/development/libraries/swiften/default.nix4
-rw-r--r--pkgs/development/libraries/swiften/scons.patch9
-rw-r--r--pkgs/development/libraries/symengine/default.nix4
-rw-r--r--pkgs/development/libraries/tbb/default.nix4
-rw-r--r--pkgs/development/libraries/tdlib/default.nix24
-rw-r--r--pkgs/development/libraries/theft/default.nix30
-rw-r--r--pkgs/development/libraries/thrift/0.10.nix39
-rw-r--r--pkgs/development/libraries/tk/generic.nix8
-rw-r--r--pkgs/development/libraries/tracker-miners/default.nix140
-rw-r--r--pkgs/development/libraries/tracker-miners/fix-paths.patch20
-rw-r--r--pkgs/development/libraries/tracker/default.nix71
-rw-r--r--pkgs/development/libraries/tracker/fix-paths.patch12
-rw-r--r--pkgs/development/libraries/trompeloeil/default.nix23
-rw-r--r--pkgs/development/libraries/uid_wrapper/default.nix4
-rw-r--r--pkgs/development/libraries/umockdev/default.nix36
-rw-r--r--pkgs/development/libraries/umockdev/disable-failed-test.patch13
-rw-r--r--pkgs/development/libraries/umockdev/fix-test-paths.patch12
-rw-r--r--pkgs/development/libraries/unicap/default.nix4
-rw-r--r--pkgs/development/libraries/unixODBCDrivers/default.nix4
-rw-r--r--pkgs/development/libraries/utmps/default.nix2
-rw-r--r--pkgs/development/libraries/vaapi-intel/default.nix2
-rw-r--r--pkgs/development/libraries/vaapi-vdpau/default.nix47
-rw-r--r--pkgs/development/libraries/vaapi-vdpau/glext85.patch20
-rw-r--r--pkgs/development/libraries/vapoursynth/default.nix17
-rw-r--r--pkgs/development/libraries/vapoursynth/editor.nix41
-rw-r--r--pkgs/development/libraries/virglrenderer/default.nix4
-rw-r--r--pkgs/development/libraries/volume-key/default.nix1
-rw-r--r--pkgs/development/libraries/vte/2.90.nix2
-rw-r--r--pkgs/development/libraries/vtk/default.nix16
-rw-r--r--pkgs/development/libraries/vulkan-loader/default.nix4
-rw-r--r--pkgs/development/libraries/vulkan-loader/system-search-path.patch45
-rw-r--r--pkgs/development/libraries/wasilibc/default.nix8
-rw-r--r--pkgs/development/libraries/wavpack/default.nix60
-rw-r--r--pkgs/development/libraries/wcslib/default.nix4
-rw-r--r--pkgs/development/libraries/webkitgtk/default.nix4
-rw-r--r--pkgs/development/libraries/wiredtiger/default.nix11
-rw-r--r--pkgs/development/libraries/wlc/default.nix39
-rw-r--r--pkgs/development/libraries/wlroots/default.nix10
-rw-r--r--pkgs/development/libraries/wolfssl/default.nix4
-rw-r--r--pkgs/development/libraries/wt/default.nix10
-rw-r--r--pkgs/development/libraries/wxSVG/default.nix4
-rw-r--r--pkgs/development/libraries/wxwidgets/2.8/default.nix5
-rw-r--r--pkgs/development/libraries/wxwidgets/2.9/default.nix5
-rw-r--r--pkgs/development/libraries/wxwidgets/3.0/default.nix7
-rw-r--r--pkgs/development/libraries/wxwidgets/3.0/mac.nix13
-rw-r--r--pkgs/development/libraries/wxwidgets/3.1/default.nix102
-rw-r--r--pkgs/development/libraries/x265/default.nix4
-rw-r--r--pkgs/development/libraries/xapian/default.nix2
-rw-r--r--pkgs/development/libraries/xdg-desktop-portal-gtk/default.nix31
-rw-r--r--pkgs/development/libraries/xdg-desktop-portal/default.nix8
-rw-r--r--pkgs/development/libraries/xdg-desktop-portal/respect-path-env-var.patch20
-rw-r--r--pkgs/development/libraries/xine-lib/default.nix10
-rw-r--r--pkgs/development/libraries/xml-security-c/cxx11.patch11
-rw-r--r--pkgs/development/libraries/xml-security-c/default.nix11
-rw-r--r--pkgs/development/libraries/xml-tooling-c/default.nix10
-rw-r--r--pkgs/development/libraries/xxHash/default.nix4
-rw-r--r--pkgs/development/libraries/yder/default.nix46
-rw-r--r--pkgs/development/libraries/yder/fix-pkgconfig.patch9
-rw-r--r--pkgs/development/libraries/zeromq/4.x.nix8
-rw-r--r--pkgs/development/libraries/zimg/default.nix10
-rw-r--r--pkgs/development/libraries/zlib/default.nix47
-rw-r--r--pkgs/development/libraries/zlog/default.nix4
-rw-r--r--pkgs/development/libraries/zziplib/default.nix9
527 files changed, 10887 insertions, 4253 deletions
diff --git a/pkgs/development/libraries/SDL/default.nix b/pkgs/development/libraries/SDL/default.nix
index 007cd02957b..a8d5d608f89 100644
--- a/pkgs/development/libraries/SDL/default.nix
+++ b/pkgs/development/libraries/SDL/default.nix
@@ -1,11 +1,11 @@
-{ stdenv, config, libGLSupported, fetchurl, fetchpatch, pkgconfig, audiofile, libcap, libiconv
+{ stdenv, config, fetchurl, fetchpatch, pkgconfig, audiofile, libcap, libiconv
+, libGLSupported ? stdenv.lib.elem stdenv.hostPlatform.system stdenv.lib.platforms.mesaPlatforms
 , openglSupport ? libGLSupported, libGL, libGLU
 , alsaSupport ? stdenv.isLinux && !stdenv.hostPlatform.isAndroid, alsaLib
 , x11Support ? !stdenv.isCygwin && !stdenv.hostPlatform.isAndroid
 , libXext, libICE, libXrandr
 , pulseaudioSupport ? config.pulseaudio or stdenv.isLinux && !stdenv.hostPlatform.isAndroid, libpulseaudio
 , OpenGL, CoreAudio, CoreServices, AudioUnit, Kernel, Cocoa
-, cf-private
 }:
 
 # NOTE: When editing this expression see if the same change applies to
@@ -40,11 +40,7 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ ]
     ++ optional (!stdenv.hostPlatform.isMinGW && alsaSupport) audiofile
-    ++ optionals stdenv.isDarwin [
-      AudioUnit CoreAudio CoreServices Kernel OpenGL
-      # Needed for NSDefaultRunLoopMode symbols.
-      cf-private
-    ];
+    ++ optionals stdenv.isDarwin [ AudioUnit CoreAudio CoreServices Kernel OpenGL ];
 
   configureFlags = [
     "--disable-oss"
diff --git a/pkgs/development/libraries/SDL2/default.nix b/pkgs/development/libraries/SDL2/default.nix
index 2909b16d65d..94aca192852 100644
--- a/pkgs/development/libraries/SDL2/default.nix
+++ b/pkgs/development/libraries/SDL2/default.nix
@@ -1,4 +1,5 @@
-{ stdenv, config, libGLSupported, fetchurl, pkgconfig
+{ stdenv, config, fetchurl, pkgconfig
+, libGLSupported ? stdenv.lib.elem stdenv.hostPlatform.system stdenv.lib.platforms.mesaPlatforms
 , openglSupport ? libGLSupported, libGL
 , alsaSupport ? stdenv.isLinux && !stdenv.hostPlatform.isAndroid, alsaLib
 , x11Support ? !stdenv.isCygwin && !stdenv.hostPlatform.isAndroid
@@ -13,7 +14,7 @@
 , pulseaudioSupport ? config.pulseaudio or stdenv.isLinux && !stdenv.hostPlatform.isAndroid
 , libpulseaudio
 , AudioUnit, Cocoa, CoreAudio, CoreServices, ForceFeedback, OpenGL
-, audiofile, cf-private, libiconv
+, audiofile, libiconv
 }:
 
 # NOTE: When editing this expression see if the same change applies to
@@ -57,11 +58,7 @@ stdenv.mkDerivation rec {
     ++ dlopenBuildInputs
     ++ optional  ibusSupport ibus
     ++ optional  fcitxSupport fcitx
-    ++ optionals stdenv.isDarwin [
-      AudioUnit Cocoa CoreAudio CoreServices ForceFeedback OpenGL
-      # Needed for NSDefaultRunLoopMode symbols.
-      cf-private
-    ];
+    ++ optionals stdenv.isDarwin [ AudioUnit Cocoa CoreAudio CoreServices ForceFeedback OpenGL ];
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/SDL2_image/default.nix b/pkgs/development/libraries/SDL2_image/default.nix
index a2ef54cc136..ba33b1fbc1d 100644
--- a/pkgs/development/libraries/SDL2_image/default.nix
+++ b/pkgs/development/libraries/SDL2_image/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "SDL2_image-${version}";
-  version = "2.0.4";
+  version = "2.0.5";
 
   src = fetchurl {
     url = "https://www.libsdl.org/projects/SDL_image/release/${name}.tar.gz";
-    sha256 = "1b6f7002bm007y3zpyxb5r6ag0lml51jyvx1pwpj9sq24jfc8kp7";
+    sha256 = "1l0864kas9cwpp2d32yxl81g98lx40dhbdp03dz7sbv84vhgdmdx";
   };
 
   buildInputs = [ SDL2 libpng libjpeg libtiff libungif libwebp libXpm zlib ]
diff --git a/pkgs/development/libraries/SDL_gpu/default.nix b/pkgs/development/libraries/SDL_gpu/default.nix
new file mode 100644
index 00000000000..dc88b7b12ef
--- /dev/null
+++ b/pkgs/development/libraries/SDL_gpu/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, fetchFromGitHub, cmake, SDL2, libGLU }:
+
+stdenv.mkDerivation rec {
+  pname = "SDL_gpu-unstable";
+  version = "2019-01-24";
+
+  src = fetchFromGitHub {
+    owner = "grimfang4";
+    repo = "sdl-gpu";
+    rev = "e3d350b325a0e0d0b3007f69ede62313df46c6ef";
+    sha256 = "0kibcaim01inb6xxn4mr6affn4hm50vz9kahb5k9iz8dmdsrhxy1";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ SDL2 libGLU ];
+
+  cmakeFlags = [
+    "-DSDL_gpu_BUILD_DEMOS=OFF"
+    "-DSDL_gpu_BUILD_TOOLS=OFF"
+    "-DSDL_gpu_BUILD_VIDEO_TEST=OFF"
+    "-DSDL_gpu_BUILD_TESTS=OFF"
+  ];
+
+  patchPhase = ''
+    sed -ie '210s#''${OUTPUT_DIR}/lib#''${CMAKE_INSTALL_LIBDIR}#' src/CMakeLists.txt
+    sed -ie '213s#''${OUTPUT_DIR}/lib#''${CMAKE_INSTALL_LIBDIR}#' src/CMakeLists.txt
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A library for high-performance, modern 2D graphics with SDL written in C";
+    homepage = "https://github.com/grimfang4/sdl-gpu";
+    license = licenses.mit;
+    maintainers = with maintainers; [ pmiddend ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/aacskeys/default.nix b/pkgs/development/libraries/aacskeys/default.nix
deleted file mode 100644
index 9e28bfd4fe2..00000000000
--- a/pkgs/development/libraries/aacskeys/default.nix
+++ /dev/null
@@ -1,47 +0,0 @@
-{stdenv, fetchurl, openssl, jdk, premake3}:
-
-# Info on how to use / obtain aacs keys:
-# http://vlc-bluray.whoknowsmy.name/
-# https://wiki.archlinux.org/index.php/BluRay
-
-
-let baseName = "aacskeys";
-    version  = "0.4.0e";
-in
-
-stdenv.mkDerivation {
-  name = "${baseName}-${version}";
-
-  patchPhase = ''
-    substituteInPlace "premake.lua" \
-      --replace "/usr/lib/jvm/java-6-sun/include" "${jdk}/include"
-  '';
-
-  src = fetchurl {
-    url = "http://deb-multimedia.org/pool/main/a/${baseName}/${baseName}_${version}.orig.tar.gz";
-    sha256 = "0d3zvwixpkixfkkc16wj37h2xbcq5hsqqhqngzqr6pslmqr67vnr";
-  };
-
-  buildInputs = [openssl jdk premake3];
-
-  installPhase = ''
-    mkdir -p $out/{bin,lib,share/${baseName}}
-
-    # Install lib
-    install -Dm444 lib/linux/libaacskeys.so $out/lib
-
-    # Install program
-    install -Dm555 bin/linux/aacskeys $out/bin
-
-    # Install resources
-    install -Dm444 HostKeyCertificate.txt $out/share/${baseName}
-    install -Dm444 ProcessingDeviceKeysSimple.txt $out/share/${baseName}
-  '';
-
-  meta = with stdenv.lib; {
-    homepage = http://forum.doom9.org/showthread.php?t=123311;
-    description = "A library and program to retrieve decryption keys for HD discs";
-    platforms = platforms.linux;
-    license = licenses.publicDomain;
-  };
-}
diff --git a/pkgs/development/libraries/accountsservice/default.nix b/pkgs/development/libraries/accountsservice/default.nix
index c20167138b7..8713663ecca 100644
--- a/pkgs/development/libraries/accountsservice/default.nix
+++ b/pkgs/development/libraries/accountsservice/default.nix
@@ -1,45 +1,77 @@
-{ stdenv, fetchurl, pkgconfig, glib, intltool, makeWrapper, shadow
-, gobject-introspection, polkit, systemd, coreutils, meson, dbus
-, ninja, python3 }:
+{ stdenv
+, fetchurl
+, fetchpatch
+, substituteAll
+, pkgconfig
+, glib
+, shadow
+, gobject-introspection
+, polkit
+, systemd
+, coreutils
+, meson
+, dbus
+, ninja
+, python3
+, gettext
+}:
 
 stdenv.mkDerivation rec {
-  name = "accountsservice-${version}";
+  pname = "accountsservice";
   version = "0.6.55";
 
+  outputs = [ "out" "dev" ];
+
   src = fetchurl {
-    url = "https://www.freedesktop.org/software/accountsservice/accountsservice-${version}.tar.xz";
+    url = "https://www.freedesktop.org/software/${pname}/${pname}-${version}.tar.xz";
     sha256 = "16wwd633jak9ajyr1f1h047rmd09fhf3kzjz6g5xjsz0lwcj8azz";
   };
 
-  nativeBuildInputs = [ pkgconfig makeWrapper meson ninja python3 ];
+  nativeBuildInputs = [
+    dbus
+    gettext
+    gobject-introspection
+    meson
+    ninja
+    pkgconfig
+    python3
+  ];
+
+  buildInputs = [
+    glib
+    polkit
+  ];
 
-  buildInputs = [ glib intltool gobject-introspection polkit systemd dbus ];
+  mesonFlags = [
+    "-Dadmin_group=wheel"
+    "-Dlocalstatedir=/var"
+    "-Dsystemdsystemunitdir=${placeholder ''out''}/etc/systemd/system"
+  ];
 
-  mesonFlags = [ "-Dsystemdsystemunitdir=etc/systemd/system"
-                 "-Dlocalstatedir=/var" ];
-  prePatch = ''
+  postPatch = ''
     chmod +x meson_post_install.py
     patchShebangs meson_post_install.py
-
-    substituteInPlace src/daemon.c --replace '"/usr/sbin/useradd"' '"${shadow}/bin/useradd"' \
-                                   --replace '"/usr/sbin/userdel"' '"${shadow}/bin/userdel"'
-    substituteInPlace src/user.c   --replace '"/usr/sbin/usermod"' '"${shadow}/bin/usermod"' \
-                                   --replace '"/usr/bin/chage"' '"${shadow}/bin/chage"' \
-                                   --replace '"/usr/bin/passwd"' '"${shadow}/bin/passwd"' \
-                                   --replace '"/bin/cat"' '"${coreutils}/bin/cat"'
   '';
 
   patches = [
+    (substituteAll {
+      src = ./fix-paths.patch;
+      inherit shadow coreutils;
+    })
     ./no-create-dirs.patch
     ./Disable-methods-that-change-files-in-etc.patch
+    # Systemd unit improvements. Notably using StateDirectory eliminating the
+    # need of an ad-hoc script.
+    (fetchpatch {
+      url = "https://gitlab.freedesktop.org/accountsservice/accountsservice/commit/152b845bbd3ca2a64516691493a160825f1a2046.patch";
+      sha256 = "114wrf5mwj5bgc5v1g05md4ridcnwdrwppr3bjz96sknwh5hk8s5";
+    })
+    (fetchpatch {
+      url = "https://gitlab.freedesktop.org/accountsservice/accountsservice/commit/0e712e935abd26499ff5995ab363e5bfd9ee7c4c.patch";
+      sha256 = "1y60a5fmgfqjzprwpizilrazqn3mggdlgc5sgcpsprsp62fv78rl";
+    })
   ];
 
-  preFixup = ''
-    wrapProgram "$out/libexec/accounts-daemon" \
-      --run "${coreutils}/bin/mkdir -p /var/lib/AccountsService/users" \
-      --run "${coreutils}/bin/mkdir -p /var/lib/AccountsService/icons"
-  '';
-
   meta = with stdenv.lib; {
     description = "D-Bus interface for user account query and manipulation";
     homepage = https://www.freedesktop.org/wiki/Software/AccountsService;
diff --git a/pkgs/development/libraries/accountsservice/fix-paths.patch b/pkgs/development/libraries/accountsservice/fix-paths.patch
new file mode 100644
index 00000000000..0bf6ee3d91a
--- /dev/null
+++ b/pkgs/development/libraries/accountsservice/fix-paths.patch
@@ -0,0 +1,125 @@
+diff --git a/src/daemon.c b/src/daemon.c
+index c52bda3..75d214e 100644
+--- a/src/daemon.c
++++ b/src/daemon.c
+@@ -1106,7 +1106,7 @@ daemon_create_user_authorized_cb (Daemon                *daemon,
+ 
+         sys_log (context, "create user '%s'", cd->user_name);
+ 
+-        argv[0] = "/usr/sbin/useradd";
++        argv[0] = "@shadow@/bin/useradd";
+         argv[1] = "-m";
+         argv[2] = "-c";
+         argv[3] = cd->real_name;
+@@ -1318,7 +1318,7 @@ daemon_delete_user_authorized_cb (Daemon                *daemon,
+ 
+         user_set_saved (user, FALSE);
+ 
+-        argv[0] = "/usr/sbin/userdel";
++        argv[0] = "@shadow@/bin/userdel";
+         if (ud->remove_files) {
+                 argv[1] = "-f";
+                 argv[2] = "-r";
+diff --git a/src/user.c b/src/user.c
+index 9f57af5..e65289d 100644
+--- a/src/user.c
++++ b/src/user.c
+@@ -844,7 +844,7 @@ user_change_real_name_authorized_cb (Daemon                *daemon,
+                          accounts_user_get_uid (ACCOUNTS_USER (user)),
+                          name);
+ 
+-                argv[0] = "/usr/sbin/usermod";
++                argv[0] = "@shadown@/bin/usermod";
+                 argv[1] = "-c";
+                 argv[2] = name;
+                 argv[3] = "--";
+@@ -913,7 +913,7 @@ user_change_user_name_authorized_cb (Daemon                *daemon,
+                          accounts_user_get_uid (ACCOUNTS_USER (user)),
+                          name);
+ 
+-                argv[0] = "/usr/sbin/usermod";
++                argv[0] = "@shadow@/bin/usermod";
+                 argv[1] = "-l";
+                 argv[2] = name;
+                 argv[3] = "--";
+@@ -1321,7 +1321,7 @@ user_change_home_dir_authorized_cb (Daemon                *daemon,
+                          accounts_user_get_uid (ACCOUNTS_USER (user)),
+                          home_dir);
+ 
+-                argv[0] = "/usr/sbin/usermod";
++                argv[0] = "@shadow@/bin/usermod";
+                 argv[1] = "-m";
+                 argv[2] = "-d";
+                 argv[3] = home_dir;
+@@ -1378,7 +1378,7 @@ user_change_shell_authorized_cb (Daemon                *daemon,
+                          accounts_user_get_uid (ACCOUNTS_USER (user)),
+                          shell);
+ 
+-                argv[0] = "/usr/sbin/usermod";
++                argv[0] = "@shadow@/bin/usermod";
+                 argv[1] = "-s";
+                 argv[2] = shell;
+                 argv[3] = "--";
+@@ -1520,7 +1520,7 @@ user_change_icon_file_authorized_cb (Daemon                *daemon,
+                         return;
+                 }
+ 
+-                argv[0] = "/bin/cat";
++                argv[0] = "@coreutils@/bin/cat";
+                 argv[1] = filename;
+                 argv[2] = NULL;
+ 
+@@ -1601,7 +1601,7 @@ user_change_locked_authorized_cb (Daemon                *daemon,
+                          locked ? "locking" : "unlocking",
+                          accounts_user_get_user_name (ACCOUNTS_USER (user)),
+                          accounts_user_get_uid (ACCOUNTS_USER (user)));
+-                argv[0] = "/usr/sbin/usermod";
++                argv[0] = "@shadow@/bin/usermod";
+                 argv[1] = locked ? "-L" : "-U";
+                 argv[2] = "--";
+                 argv[3] = accounts_user_get_user_name (ACCOUNTS_USER (user));
+@@ -1726,7 +1726,7 @@ user_change_account_type_authorized_cb (Daemon                *daemon,
+ 
+                 g_free (groups);
+ 
+-                argv[0] = "/usr/sbin/usermod";
++                argv[0] = "@shadow@/bin/usermod";
+                 argv[1] = "-G";
+                 argv[2] = str->str;
+                 argv[3] = "--";
+@@ -1794,7 +1794,7 @@ user_change_password_mode_authorized_cb (Daemon                *daemon,
+                 if (mode == PASSWORD_MODE_SET_AT_LOGIN ||
+                     mode == PASSWORD_MODE_NONE) {
+ 
+-                        argv[0] = "/usr/bin/passwd";
++                        argv[0] = "/run/wrappers/bin/passwd";
+                         argv[1] = "-d";
+                         argv[2] = "--";
+                         argv[3] = accounts_user_get_user_name (ACCOUNTS_USER (user));
+@@ -1806,7 +1806,7 @@ user_change_password_mode_authorized_cb (Daemon                *daemon,
+                         }
+ 
+                         if (mode == PASSWORD_MODE_SET_AT_LOGIN) {
+-                                argv[0] = "/usr/bin/chage";
++                                argv[0] = "@shadow@/bin/chage";
+                                 argv[1] = "-d";
+                                 argv[2] = "0";
+                                 argv[3] = "--";
+@@ -1827,7 +1827,7 @@ user_change_password_mode_authorized_cb (Daemon                *daemon,
+                         accounts_user_set_locked (ACCOUNTS_USER (user), FALSE);
+                 }
+                 else if (accounts_user_get_locked (ACCOUNTS_USER (user))) {
+-                        argv[0] = "/usr/sbin/usermod";
++                        argv[0] = "@shadow@/bin/usermod";
+                         argv[1] = "-U";
+                         argv[2] = "--";
+                         argv[3] = accounts_user_get_user_name (ACCOUNTS_USER (user));
+@@ -1905,7 +1905,7 @@ user_change_password_authorized_cb (Daemon                *daemon,
+ 
+         g_object_freeze_notify (G_OBJECT (user));
+ 
+-        argv[0] = "/usr/sbin/usermod";
++        argv[0] = "@shadow@/bin/usermod";
+         argv[1] = "-p";
+         argv[2] = strings[0];
+         argv[3] = "--";
diff --git a/pkgs/development/libraries/ace/default.nix b/pkgs/development/libraries/ace/default.nix
index e0c46acb630..75c942d4d48 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.5.5";
+  version = "6.5.6";
 
   src = fetchurl {
     url = "http://download.dre.vanderbilt.edu/previous_versions/ACE-${version}.tar.bz2";
-    sha256 = "1r1bvy65n50l6lbxm1k1bscqcv29mpkgp0pgr5cvvv7ldisrjl39";
+    sha256 = "15lfjc8r854hvjfvimhnqc3987b3cdngilhkii9rwpzginbyipi4";
   };
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/agda/agda-iowa-stdlib/default.nix b/pkgs/development/libraries/agda/agda-iowa-stdlib/default.nix
index 3ab4ed3e962..e2d64841985 100644
--- a/pkgs/development/libraries/agda/agda-iowa-stdlib/default.nix
+++ b/pkgs/development/libraries/agda/agda-iowa-stdlib/default.nix
@@ -1,14 +1,14 @@
 { stdenv, agda, fetchFromGitHub }:
 
 agda.mkDerivation (self: rec {
-  version = "1.4.0";
+  version = "1.5.0";
   name = "agda-iowa-stdlib-${version}";
 
   src = fetchFromGitHub {
     owner = "cedille";
     repo  = "ial";
     rev = "v${version}";
-    sha256 = "1gwxpybxwdj5ipbb3gapm7r5hfl3g6sj9kp13954pdmx8d5b0gma";
+    sha256 = "0dlis6v6nzbscf713cmwlx8h9n2gxghci8y21qak3hp18gkxdp0g";
   };
 
   sourceDirectories = [ "./." ];
diff --git a/pkgs/development/libraries/agda/agda-prelude/default.nix b/pkgs/development/libraries/agda/agda-prelude/default.nix
index e3dcf765dfd..a57ee6e08ba 100644
--- a/pkgs/development/libraries/agda/agda-prelude/default.nix
+++ b/pkgs/development/libraries/agda/agda-prelude/default.nix
@@ -1,13 +1,13 @@
 { stdenv, agda, fetchgit }:
 
 agda.mkDerivation (self: rec {
-  version = "0dca24a81d417db2ae8fc871eccb7776f7eae952";
+  version = "eacc961c2c312b7443109a7872f99d55557df317";
   name = "agda-prelude-${version}";
 
   src = fetchgit {
     url = "https://github.com/UlfNorell/agda-prelude.git";
     rev = version;
-    sha256 = "0gwfgvj96i1mx5v01bi46h567d1q1fbgvzv6z8zv91l2jhybwff5";
+    sha256 = "0iql67hb1q0fn8dwkcx07brkdkxqfqrsbwjy71ndir0k7qzw7qv2";
   };
 
   topSourceDirectories = [ "src" ];
diff --git a/pkgs/development/libraries/agda/agda-stdlib/default.nix b/pkgs/development/libraries/agda/agda-stdlib/default.nix
index d9350d135eb..4d071251ee8 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 = "1.0";
+  version = "1.1";
   name = "agda-stdlib-${version}";
 
   src = fetchFromGitHub {
     repo = "agda-stdlib";
     owner = "agda";
     rev = "v${version}";
-    sha256 = "19qrdfi0vig3msqg76k1zf5j3vav0jz44cvj6i4dyfbscdwf2l9c";
+    sha256 = "190bxsy92ffmvwpmyyg3lxs91vyss2z25rqz1w79gkj56484cy64";
   };
 
   nativeBuildInputs = [ (ghcWithPackages (self : [ self.filemanip ])) ];
diff --git a/pkgs/development/libraries/appstream-glib/default.nix b/pkgs/development/libraries/appstream-glib/default.nix
index 45ad58819c3..4068e36badf 100644
--- a/pkgs/development/libraries/appstream-glib/default.nix
+++ b/pkgs/development/libraries/appstream-glib/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchFromGitHub, substituteAll, pkgconfig, gettext, gtk3, glib
 , gtk-doc, libarchive, gobject-introspection, libxslt, pngquant
 , sqlite, libsoup, attr, acl, docbook_xsl, docbook_xml_dtd_42
-, libuuid, json-glib, meson, gperf, ninja, gdk_pixbuf
+, libuuid, json-glib, meson, gperf, ninja, gdk-pixbuf
 }:
 stdenv.mkDerivation rec {
   name = "appstream-glib-0.7.15";
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
   buildInputs = [
     glib gettext sqlite libsoup
     attr acl libuuid json-glib
-    libarchive gperf gdk_pixbuf
+    libarchive gperf gdk-pixbuf
   ];
   propagatedBuildInputs = [ gtk3 ];
 
@@ -49,7 +49,7 @@ stdenv.mkDerivation rec {
     description = "Objects and helper methods to read and write AppStream metadata";
     homepage = https://people.freedesktop.org/~hughsient/appstream-glib/;
     license = licenses.lgpl2Plus;
-    platforms = platforms.linux;
+    platforms = platforms.unix;
     maintainers = with maintainers; [ lethalman matthewbauer ];
   };
 }
diff --git a/pkgs/development/libraries/appstream/default.nix b/pkgs/development/libraries/appstream/default.nix
index f59a3fd713f..429da8de835 100644
--- a/pkgs/development/libraries/appstream/default.nix
+++ b/pkgs/development/libraries/appstream/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchpatch, fetchFromGitHub, meson, ninja, pkgconfig, gettext
+{ stdenv, fetchFromGitHub, meson, ninja, pkgconfig, gettext
 , xmlto, docbook_xsl, docbook_xml_dtd_45, libxslt
 , libstemmer, glib, xapian, libxml2, libyaml, gobject-introspection
 , pcre, itstool, gperf, vala
diff --git a/pkgs/development/libraries/aravis/default.nix b/pkgs/development/libraries/aravis/default.nix
index ba68f046b0a..9d506b10e35 100644
--- a/pkgs/development/libraries/aravis/default.nix
+++ b/pkgs/development/libraries/aravis/default.nix
@@ -33,13 +33,13 @@ in
   stdenv.mkDerivation rec {
 
     pname = "aravis";
-    version = "0.6.2";
+    version = "0.6.3";
 
     src = fetchFromGitHub {
       owner = "AravisProject";
       repo = pname;
       rev= "ARAVIS_${builtins.replaceStrings ["."] ["_"] version}";
-      sha256 = "0zlmw040iv0xx9qw7ygzbl96bli6ivll2fbziv19f4bdc0yhqjpw";
+      sha256 = "0lmgx854z522dwcxsg37bxdyiai9fnycpx1nvgayksj38h39kfn2";
     };
 
     outputs = [ "bin" "dev" "out" "lib" ];
diff --git a/pkgs/development/libraries/arb/default.nix b/pkgs/development/libraries/arb/default.nix
index 4c34e40586f..eb58003a5f6 100644
--- a/pkgs/development/libraries/arb/default.nix
+++ b/pkgs/development/libraries/arb/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchFromGitHub, fetchpatch, mpir, gmp, mpfr, flint}:
+{stdenv, fetchFromGitHub, mpir, gmp, mpfr, flint}:
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
   pname = "arb";
diff --git a/pkgs/development/libraries/armadillo/default.nix b/pkgs/development/libraries/armadillo/default.nix
index c6568913664..3b93a351f7f 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 = "9.400.4";
+  version = "9.600.6";
   name = "armadillo-${version}";
 
   src = fetchurl {
     url = "mirror://sourceforge/arma/armadillo-${version}.tar.xz";
-    sha256 = "1wv08i8mq16hswxkll3kmbfih4hz4d8v7apszm76lwxpya2bm65l";
+    sha256 = "0wlk1yv9531vpvgja4cpy0sxykrn0p5w376kx86vl45b50yamx7g";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/arrow-cpp/default.nix b/pkgs/development/libraries/arrow-cpp/default.nix
index 7f7ef3336a4..7660ea81eaf 100644
--- a/pkgs/development/libraries/arrow-cpp/default.nix
+++ b/pkgs/development/libraries/arrow-cpp/default.nix
@@ -1,38 +1,40 @@
-{ stdenv, fetchurl, fetchFromGitHub, autoconf, boost, brotli, cmake, double-conversion, flatbuffers, gflags, glog, gtest, lz4, perl, python, rapidjson, snappy, thrift, uriparser, which, zlib, zstd }:
+{ stdenv, fetchurl, fetchFromGitHub, fixDarwinDylibNames, autoconf, boost, brotli, cmake, double-conversion, flatbuffers, gflags, glog, gtest, lz4, perl, python, rapidjson, snappy, thrift, uriparser, which, zlib, zstd }:
 
 let
   parquet-testing = fetchFromGitHub {
     owner = "apache";
     repo = "parquet-testing";
-    rev = "8991d0b58d5a59925c87dd2a0bdb59a5a4a16bd4";
-    sha256 = "00js5d1s98y3ianrvh1ggrd157yfmia4g55jx9xmfcz4a8mcbawx";
-  };
-
-  # Enable non-bundled uriparser
-  # Introduced in https://github.com/apache/arrow/pull/4092
-  Finduriparser_cmake = fetchurl {
-    url = https://raw.githubusercontent.com/apache/arrow/af4f52961209a5f1b43a19483536285c957e3bed/cpp/cmake_modules/Finduriparser.cmake;
-    sha256 = "1cylrw00n2nkc2c49xk9j3rrza351rpravxgpw047vimcw0sk93s";
+    rev = "a277dc4e55ded3e3ea27dab1e4faf98c112442df";
+    sha256 = "1yh5a8l4ship36hwmgmp2kl72s5ac9r8ly1qcs650xv2g9q7yhnq";
   };
 in
 
 stdenv.mkDerivation rec {
   name = "arrow-cpp-${version}";
-  version = "0.13.0";
+  version = "0.14.1";
 
   src = fetchurl {
     url = "mirror://apache/arrow/arrow-${version}/apache-arrow-${version}.tar.gz";
-    sha256 = "06irh5zx6lc7jjf6hpz1vzk0pvbdx08lcirc8cp8ksb8j7fpfamc";
+    sha256 = "0a0xrsbr7dd1yp34yw82jw7psfkfvm935jhd5mam32vrsjvdsj4r";
   };
 
   sourceRoot = "apache-arrow-${version}/cpp";
 
+  ARROW_JEMALLOC_URL = fetchurl {
+    # From
+    # ./cpp/cmake_modules/ThirdpartyToolchain.cmake
+    # ./cpp/thirdparty/versions.txt
+    url = "https://github.com/jemalloc/jemalloc/releases/download/5.2.0/jemalloc-5.2.0.tar.bz2";
+    sha256 = "1d73a5c5qdrwck0fa5pxz0myizaf3s9alsvhiqwrjahdlr29zgkl";
+  };
+
   patches = [
     # patch to fix python-test
     ./darwin.patch
     ];
 
-  nativeBuildInputs = [ cmake autoconf /* for vendored jemalloc */ ];
+  nativeBuildInputs = [ cmake autoconf /* for vendored jemalloc */ ]
+    ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
   buildInputs = [
     boost brotli double-conversion flatbuffers gflags glog gtest lz4 rapidjson
     snappy thrift uriparser zlib zstd python.pkgs.python python.pkgs.numpy
@@ -41,8 +43,6 @@ stdenv.mkDerivation rec {
   preConfigure = ''
     substituteInPlace cmake_modules/FindLz4.cmake --replace CMAKE_STATIC_LIBRARY CMAKE_SHARED_LIBRARY
 
-    cp ${Finduriparser_cmake} cmake_modules/Finduriparser.cmake
-
     patchShebangs build-support/
 
     # Fix build for ARROW_USE_SIMD=OFF
@@ -63,7 +63,7 @@ stdenv.mkDerivation rec {
   PARQUET_TEST_DATA = if doInstallCheck then "${parquet-testing}/data" else null;
   installCheckInputs = [ perl which ];
   installCheckPhase = (stdenv.lib.optionalString stdenv.isDarwin ''
-    for f in release/*-test; do
+    for f in release/*test; do
       install_name_tool -add_rpath "$out"/lib  "$f"
     done
   '') + ''
diff --git a/pkgs/development/libraries/at-spi2-atk/default.nix b/pkgs/development/libraries/at-spi2-atk/default.nix
index 6c3f3aa9fa2..2268d438902 100644
--- a/pkgs/development/libraries/at-spi2-atk/default.nix
+++ b/pkgs/development/libraries/at-spi2-atk/default.nix
@@ -42,7 +42,7 @@ stdenv.mkDerivation rec {
     description = "D-Bus bridge for Assistive Technology Service Provider Interface (AT-SPI) and Accessibility Toolkit (ATK)";
     homepage = https://gitlab.gnome.org/GNOME/at-spi2-atk;
     license = licenses.lgpl2Plus; # NOTE: 2018-06-06: Please check the license when upstream sorts-out licensing: https://gitlab.gnome.org/GNOME/at-spi2-atk/issues/2
-    maintainers = with maintainers; [ jtojnar gnome3.maintainers ];
+    maintainers = gnome3.maintainers;
     platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/at-spi2-core/default.nix b/pkgs/development/libraries/at-spi2-core/default.nix
index e5d5313eeb1..47c8c090d08 100644
--- a/pkgs/development/libraries/at-spi2-core/default.nix
+++ b/pkgs/development/libraries/at-spi2-core/default.nix
@@ -45,7 +45,7 @@ stdenv.mkDerivation rec {
     description = "Assistive Technology Service Provider Interface protocol definitions and daemon for D-Bus";
     homepage = https://gitlab.gnome.org/GNOME/at-spi2-core;
     license = licenses.lgpl2Plus; # NOTE: 2018-06-06: Please check the license when upstream sorts-out licensing: https://gitlab.gnome.org/GNOME/at-spi2-core/issues/2
-    maintainers = with maintainers; [ jtojnar gnome3.maintainers ];
+    maintainers = gnome3.maintainers;
     platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/audio/libbass/default.nix b/pkgs/development/libraries/audio/libbass/default.nix
index 0e1445ca9ee..3552e335fed 100644
--- a/pkgs/development/libraries/audio/libbass/default.nix
+++ b/pkgs/development/libraries/audio/libbass/default.nix
@@ -1,32 +1,38 @@
 { stdenv, unzip, fetchurl }:
 
-let
-  version = "24";
+# Upstream changes files in-place, to update:
+# 1. Check latest version at http://www.un4seen.com/
+# 2. Update `version`s and `sha256` sums.
+# See also http://www.un4seen.com/forum/?topic=18614.0
 
+let
   allBass = {
     bass = {
       h = "bass.h";
+      version = "2.4.14";
       so = {
         i686_linux = "libbass.so";
         x86_64-linux = "x64/libbass.so";
       };
-      urlpath = "bass${version}-linux.zip";
-      sha256 = "1hjxp1akj8367qlglv5rqpwq2dimfz3bkllwq39abavz4sp8smjz";
+      urlpath = "bass24-linux.zip";
+      sha256 = "1nyzs08z0djyvz6jx1y9y99y0ksp4sxz9l2x43k1c9irls24xpfy";
     };
 
     bass_fx = {
       h = "C/bass_fx.h";
+      version = "2.4.12.1";
       so = {
         i686_linux = "libbass_fx.so";
         x86_64-linux = "x64/libbass_fx.so";
       };
-      urlpath = "z/0/bass_fx${version}-linux.zip";
+      urlpath = "z/0/bass_fx24-linux.zip";
       sha256 = "1q0g74z7iyhxqps5b3gnnbic8v2jji1r0mkvais57lsx8y21sbin";
     };
   };
 
   dropBass = name: bass: stdenv.mkDerivation {
-    name = "lib${name}-${version}";
+    pname = "lib${name}";
+    inherit (bass) version;
 
     src = fetchurl {
       url = "https://www.un4seen.com/files/${bass.urlpath}";
diff --git a/pkgs/development/libraries/avahi/default.nix b/pkgs/development/libraries/avahi/default.nix
index 76010dacc5e..ee451818831 100644
--- a/pkgs/development/libraries/avahi/default.nix
+++ b/pkgs/development/libraries/avahi/default.nix
@@ -73,7 +73,7 @@ stdenv.mkDerivation rec {
     homepage    = http://avahi.org;
     license     = licenses.lgpl2Plus;
     platforms   = platforms.unix;
-    maintainers = with maintainers; [ lovek323 ];
+    maintainers = with maintainers; [ lovek323 globin ];
 
     longDescription = ''
       Avahi is a system which facilitates service discovery on a local
diff --git a/pkgs/development/libraries/aws-c-common/default.nix b/pkgs/development/libraries/aws-c-common/default.nix
index c8f284acc13..4286eedc87b 100644
--- a/pkgs/development/libraries/aws-c-common/default.nix
+++ b/pkgs/development/libraries/aws-c-common/default.nix
@@ -1,14 +1,14 @@
-{ lib, stdenv, fetchFromGitHub, cmake, libexecinfo }:
+{ lib, stdenv, fetchFromGitHub, cmake }:
 
 stdenv.mkDerivation rec {
   pname = "aws-c-common";
-  version = "0.3.9";
+  version = "0.3.11";
 
   src = fetchFromGitHub {
     owner = "awslabs";
     repo = pname;
     rev = "v${version}";
-    sha256 = "04wrmrw83vypqzsq88b2q8kp5sfbv0qsci3bcxw0c2mfxqk8358n";
+    sha256 = "0a7hi4crnc3j1j39qcnd44zqdfwzw1xghcf80marx5vdf1qdzy6p";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/aws-checksums/default.nix b/pkgs/development/libraries/aws-checksums/default.nix
index 0e47398b346..124984f0d53 100644
--- a/pkgs/development/libraries/aws-checksums/default.nix
+++ b/pkgs/development/libraries/aws-checksums/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   pname = "aws-checksums";
-  version = "0.1.2";
+  version = "0.1.3";
 
   src = fetchFromGitHub {
     owner = "awslabs";
     repo = pname;
     rev = "v${version}";
-    sha256 = "1r21sfs1ik6cb8bz17w6gp6y2xa9rbjxjka0p6airb3qds094iv5";
+    sha256 = "1s6zwf97rkkvnf3p7vlaykwa4pxpvj78pmxvvjf5jk29f93b49xp";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/boehm-gc/default.nix b/pkgs/development/libraries/boehm-gc/default.nix
index 003d466f011..a241b42e187 100644
--- a/pkgs/development/libraries/boehm-gc/default.nix
+++ b/pkgs/development/libraries/boehm-gc/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchurl, fetchpatch
+{ lib, stdenv, fetchurl
 , enableLargeConfig ? false # doc: https://github.com/ivmai/bdwgc/blob/v7.6.6/doc/README.macros#L179
 }:
 
diff --git a/pkgs/development/libraries/boost/generic.nix b/pkgs/development/libraries/boost/generic.nix
index 90dd8ff1744..f7bd189022f 100644
--- a/pkgs/development/libraries/boost/generic.nix
+++ b/pkgs/development/libraries/boost/generic.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, icu, expat, zlib, bzip2, python, fixDarwinDylibNames, libiconv
+{ stdenv, icu, expat, zlib, bzip2, python, fixDarwinDylibNames, libiconv
 , which
 , buildPackages
 , toolset ? /**/ if stdenv.cc.isClang  then "clang"
diff --git a/pkgs/development/libraries/caf/default.nix b/pkgs/development/libraries/caf/default.nix
index 15744744067..4a1ea394207 100644
--- a/pkgs/development/libraries/caf/default.nix
+++ b/pkgs/development/libraries/caf/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "actor-framework-${version}";
-  version = "0.16.3";
+  version = "0.17.0";
 
   src = fetchFromGitHub {
     owner = "actor-framework";
     repo = "actor-framework";
     rev = "${version}";
-    sha256 = "0nqw1cv7wxbcn2qwm08qffb6k4n3kgvdiaphks5gjgm305jk4vnx";
+    sha256 = "10dcpmdsfq6r7hpvg413pqi1q3rjvgn7f87c17ghyz30x6rjhaic";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/cairo/default.nix b/pkgs/development/libraries/cairo/default.nix
index 0151bac402c..e388b3af5f6 100644
--- a/pkgs/development/libraries/cairo/default.nix
+++ b/pkgs/development/libraries/cairo/default.nix
@@ -3,7 +3,7 @@
 , x11Support? !stdenv.isDarwin, libXext, libXrender
 , gobjectSupport ? true, glib
 , xcbSupport ? x11Support, libxcb, xcbutil # no longer experimental since 1.12
-, libGLSupported
+, libGLSupported ? stdenv.lib.elem stdenv.hostPlatform.system stdenv.lib.platforms.mesaPlatforms
 , glSupport ? config.cairo.gl or (libGLSupported && stdenv.isLinux && !stdenv.isAarch32 && !stdenv.isMips)
 , libGL ? null # libGLU_combined is no longer a big dependency
 , pdfSupport ? true
diff --git a/pkgs/development/libraries/catch2/default.nix b/pkgs/development/libraries/catch2/default.nix
index 67f5350d8fe..2d0fd4cb1bc 100644
--- a/pkgs/development/libraries/catch2/default.nix
+++ b/pkgs/development/libraries/catch2/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, cmake, python }:
+{ stdenv, fetchFromGitHub, cmake }:
 
 stdenv.mkDerivation rec {
   name = "catch2-${version}";
diff --git a/pkgs/development/libraries/cdo/default.nix b/pkgs/development/libraries/cdo/default.nix
index af69e23ca1f..2a3dbc7a2d1 100644
--- a/pkgs/development/libraries/cdo/default.nix
+++ b/pkgs/development/libraries/cdo/default.nix
@@ -5,15 +5,15 @@
 }:
 
 stdenv.mkDerivation rec {
-  version = "1.9.0";
-  name = "cdo-${version}";
+  pname = "cdo";
+  version = "1.9.7.1";
 
   # Dependencies
   buildInputs = [ curl netcdf hdf5 ];
 
   src = fetchurl {
-    url = "https://code.mpimet.mpg.de/attachments/download/15187/${name}.tar.gz";
-    sha256 = "024hsr6qfg2dicwvm0vvkg3fr998bchf0qgwpj2v0jmz7a67ydnz";
+    url = "https://code.mpimet.mpg.de/attachments/download/20124/${pname}-${version}.tar.gz";
+    sha256 = "0b4n8dwxfsdbz4jflsx0b75hwapdf1rp14p48dfr7ksv0qp9aw9p";
   };
 
  # Configure phase
@@ -23,15 +23,15 @@ stdenv.mkDerivation rec {
    ++ stdenv.lib.optional (enable_all_static) "--enable-all-static"
    ++ stdenv.lib.optional (enable_cxx) "--enable-cxx";
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "Collection of command line Operators to manipulate and analyse Climate and NWP model Data";
     longDescription = ''
       Supported data formats are GRIB 1/2, netCDF 3/4, SERVICE, EXTRA and IEG.
       There are more than 600 operators available.
     '';
     homepage = https://code.mpimet.mpg.de/projects/cdo/;
-    license = stdenv.lib.licenses.gpl2;
-    maintainers = [ stdenv.lib.maintainers.ltavard ];
-    platforms = with stdenv.lib.platforms; linux ++ darwin;
+    license = licenses.gpl2;
+    maintainers = [ maintainers.ltavard ];
+    platforms = with platforms; linux ++ darwin;
   };
 }
diff --git a/pkgs/development/libraries/ceres-solver/default.nix b/pkgs/development/libraries/ceres-solver/default.nix
index 043b9e263d8..52e0f06eeec 100644
--- a/pkgs/development/libraries/ceres-solver/default.nix
+++ b/pkgs/development/libraries/ceres-solver/default.nix
@@ -2,13 +2,13 @@
 , eigen
 , fetchurl
 , cmake
-, google-gflags
+, gflags
 , glog
 , runTests ? false
 }:
 
-# google-gflags is required to run tests
-assert runTests -> google-gflags != null;
+# gflags is required to run tests
+assert runTests -> gflags != null;
 
 stdenv.mkDerivation rec {
   name = "ceres-solver-${version}";
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake ];
   buildInputs = [ eigen glog ]
-    ++ stdenv.lib.optional runTests google-gflags;
+    ++ stdenv.lib.optional runTests gflags;
 
   # The Basel BUILD file conflicts with the cmake build directory on
   # case-insensitive filesystems, eg. darwin.
diff --git a/pkgs/development/libraries/cfitsio/darwin-curl-config.patch b/pkgs/development/libraries/cfitsio/darwin-curl-config.patch
deleted file mode 100644
index 77d8f719d77..00000000000
--- a/pkgs/development/libraries/cfitsio/darwin-curl-config.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-diff -ruN cfitsio/configure cfitsio-curl-config/configure
---- cfitsio/configure	2018-05-09 21:16:00.000000000 +0200
-+++ cfitsio-curl-config/configure	2018-05-30 13:28:58.000000000 +0200
-@@ -4783,13 +4783,6 @@
- CURL_LIB=""
- CURL_INC=""
- # Use curl-config to get compiler & linker flags, if available.
--# On Macs, prefer XCode curl-config, and reject MacPorts version
--# until further notice to prevent build errors:
--if test "x$EXT" = xdarwin -a -x /usr/bin/curl-config; then
--  CURLCONFIG="/usr/bin/curl-config"
--  { $as_echo "$as_me:${as_lineno-$LINENO}: result: checking for curl-config... choosing /usr/bin/curl-config on Mac" >&5
--$as_echo "checking for curl-config... choosing /usr/bin/curl-config on Mac" >&6; }
--else
-   # Extract the first word of "curl-config", so it can be a program name with args.
- set dummy curl-config; ac_word=$2
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-@@ -4833,7 +4826,6 @@
-   fi
- fi
- fi
--fi
- CURLCONFIG=$ac_cv_prog_CURLCONFIG
- if test -n "$CURLCONFIG"; then
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CURLCONFIG" >&5
diff --git a/pkgs/development/libraries/cfitsio/default.nix b/pkgs/development/libraries/cfitsio/default.nix
index 32308c34ead..7576c24024a 100644
--- a/pkgs/development/libraries/cfitsio/default.nix
+++ b/pkgs/development/libraries/cfitsio/default.nix
@@ -2,22 +2,23 @@
 
 # Optional dependencies
 , bzip2 ? null }:
-
 stdenv.mkDerivation rec {
-  name = "cfitsio-${version}";
-  version = "3.450";
+  pname = "cfitsio";
+  version = "3.47";
 
   src = fetchurl {
-    url = "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio${builtins.replaceStrings ["."] [""] version}.tar.gz";
-    sha256 = "0bmrkw6w65zb0k3mszaaqy1f4zjm2hl7njww74nb5v38wvdi4q5z";
+    url = "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-${version}.tar.gz";
+    sha256 = "1vzlxnrjckz78p2wf148v2z3krkwnykfqvlj42sz3q711vqid1a1";
   };
 
   buildInputs = [ bzip2 ];
 
-  patches = [ ./darwin-curl-config.patch ./darwin-rpath-universal.patch ];
+  patches = [ ./darwin-rpath-universal.patch ];
 
   configureFlags = stdenv.lib.optional (bzip2 != null) "--with-bzip2=${bzip2.out}";
 
+  hardeningDisable = [ "format" ];
+
   # Shared-only build
   buildFlags = "shared";
   postPatch = '' sed -e '/^install:/s/libcfitsio.a //' -e 's@/bin/@@g' -i Makefile.in
diff --git a/pkgs/development/libraries/cimg/default.nix b/pkgs/development/libraries/cimg/default.nix
index 4025d386d77..3e6e62e5a96 100644
--- a/pkgs/development/libraries/cimg/default.nix
+++ b/pkgs/development/libraries/cimg/default.nix
@@ -3,11 +3,11 @@
 stdenv.mkDerivation rec {
 
   name = "cimg-${version}";
-  version = "2.6.4";
+  version = "2.7.0";
 
   src = fetchurl {
     url = "http://cimg.eu/files/CImg_${version}.zip";
-    sha256 = "0hvr030588jnm5s8zgxvhkg13al83dy6273rbdi801cmgfcwxq29";
+    sha256 = "1la6332cppyciyn3pflbchxa3av72a70p0n1c9sm1hgfbjlydqnv";
   };
 
   nativeBuildInputs = [ unzip ];
diff --git a/pkgs/development/libraries/clutter-gst/default.nix b/pkgs/development/libraries/clutter-gst/default.nix
index 9577bfe9e8a..3c88327c790 100644
--- a/pkgs/development/libraries/clutter-gst/default.nix
+++ b/pkgs/development/libraries/clutter-gst/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, pkgconfig, clutter, gtk3, glib, cogl, gnome3, gdk_pixbuf }:
+{ fetchurl, stdenv, pkgconfig, clutter, gtk3, glib, cogl, gnome3, gdk-pixbuf }:
 
 let
   pname = "clutter-gst";
@@ -11,7 +11,7 @@ in stdenv.mkDerivation rec {
     sha256 = "17czmpl92dzi4h3rn5rishk015yi3jwiw29zv8qan94xcmnbssgy";
   };
 
-  propagatedBuildInputs = [ clutter gtk3 glib cogl gdk_pixbuf ];
+  propagatedBuildInputs = [ clutter gtk3 glib cogl gdk-pixbuf ];
   nativeBuildInputs = [ pkgconfig ];
 
   postBuild = "rm -rf $out/share/gtk-doc";
diff --git a/pkgs/development/libraries/cm256cc/default.nix b/pkgs/development/libraries/cm256cc/default.nix
new file mode 100644
index 00000000000..aaf40998102
--- /dev/null
+++ b/pkgs/development/libraries/cm256cc/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchFromGitHub, cmake, boost } :
+
+stdenv.mkDerivation rec {
+  pname = "cm256cc";
+  version = "1.0.5";
+
+  src = fetchFromGitHub {
+    owner = "f4exb";
+    repo = "cm256cc";
+    rev = "v${version}";
+    sha256 = "0d16y3lhdwr644am4sxqpshpbc3qik6dgr1w2c39vy75w9ff61a0";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ boost ];
+
+  meta = with stdenv.lib; {
+    description = "Fast GF(256) Cauchy MDS Block Erasure Codec in C++";
+    homepage = "https://github.com/f4exb/cm256cc";
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ alkeryn ];
+  };
+}
diff --git a/pkgs/development/libraries/cogl/default.nix b/pkgs/development/libraries/cogl/default.nix
index cff32ca2d70..4700d9e2418 100644
--- a/pkgs/development/libraries/cogl/default.nix
+++ b/pkgs/development/libraries/cogl/default.nix
@@ -1,6 +1,6 @@
-{ stdenv, fetchurl, fetchpatch, pkgconfig, libGL, glib, gdk_pixbuf, xorg, libintl
+{ stdenv, fetchurl, fetchpatch, pkgconfig, libGL, glib, gdk-pixbuf, xorg, libintl
 , pangoSupport ? true, pango, cairo, gobject-introspection, wayland, gnome3
-, mesa_noglu
+, mesa
 , gstreamerSupport ? true, gst_all_1 }:
 
 let
@@ -44,7 +44,7 @@ in stdenv.mkDerivation rec {
     ++ stdenv.lib.optionals (!stdenv.isDarwin) [ "--enable-gles1" "--enable-gles2" ];
 
   propagatedBuildInputs = with xorg; [
-      glib gdk_pixbuf gobject-introspection wayland mesa_noglu
+      glib gdk-pixbuf gobject-introspection wayland mesa
       libGL libXrandr libXfixes libXcomposite libXdamage
     ]
     ++ stdenv.lib.optionals gstreamerSupport [ gst_all_1.gstreamer
diff --git a/pkgs/development/libraries/coin3d/default.nix b/pkgs/development/libraries/coin3d/default.nix
index 442ed2a4b9a..80b6480323b 100644
--- a/pkgs/development/libraries/coin3d/default.nix
+++ b/pkgs/development/libraries/coin3d/default.nix
@@ -1,30 +1,25 @@
-{ fetchurl, stdenv, libGLU_combined }:
+{ fetchFromBitbucket, stdenv, boost, cmake, libGLU_combined }:
 
 stdenv.mkDerivation rec {
-  name = "coin3d-${version}";
-  version = "3.1.3";
+  pname = "coin";
+  version = "unstable-2019-06-12";
 
-  src = fetchurl {
-    url = "https://bitbucket.org/Coin3D/coin/downloads/Coin-${version}.tar.gz";
-    sha256 = "05ylhrcglm81dajbk132l1w892634z2i97x10fm64y1ih72phd2q";
+  src = fetchFromBitbucket {
+    owner = "Coin3D";
+    repo = "coin";
+    rev = "8d860d7ba112b22c4e9b289268fd8b3625ab81d3";
+    sha256 = "1cpncljqvw28k5wvpgchv593nayhby5gwpvbnyllc9hb9ms816xn";
   };
 
-  patches = [
-    (fetchurl {
-      url = http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/media-libs/coin/files/coin-3.1.3-gcc-4.7.patch;
-      name = "gcc-4.7.patch";
-      sha256 = "076dyc52swk8qc7ylps53fg6iqmd52x8s7m18i80x49dd109yw20";
-    })
-    ./gcc-4.8.patch # taken from FC-17 source rpm
-    # see https://bitbucket.org/Coin3D/coin/issues/128/crash-in-cc_memalloc_deallocate
-    # patch adapted from https://bitbucket.org/Coin3D/coin/pull-requests/75/added-fix-for-issue-128-provided-by-fedora/diff
-    ./sbhashentry.patch
-  ];
+  postPatch = ''
+    sed -i /cpack.d/d CMakeLists.txt
+  '';
 
-  buildInputs = [ libGLU_combined ];
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ boost libGLU_combined ];
 
   meta = {
-    homepage = http://www.coin3d.org/;
+    homepage = "https://bitbucket.org/Coin3D/coin/wiki/Home";
     license = stdenv.lib.licenses.gpl2Plus;
     description = "High-level, retained-mode toolkit for effective 3D graphics development";
     maintainers = [ stdenv.lib.maintainers.viric ];
diff --git a/pkgs/development/libraries/coin3d/gcc-4.8.patch b/pkgs/development/libraries/coin3d/gcc-4.8.patch
deleted file mode 100644
index be5b8b03b63..00000000000
--- a/pkgs/development/libraries/coin3d/gcc-4.8.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-From 9f5d96a2b9a71ab539237d2dab4c54fc46fc5c5b Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Ralf=20Cors=C3=A9pius?= <corsepiu@corsepiu.home>
-Date: Thu, 18 Apr 2013 19:17:06 +0200
-Subject: [PATCH 10/10] GCC-4.8.0 fixes
-
----
- src/fonts/freetype.cpp | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/fonts/freetype.cpp b/src/fonts/freetype.cpp
-index 760b88b..e705d3a 100644
---- a/src/fonts/freetype.cpp
-+++ b/src/fonts/freetype.cpp
-@@ -32,18 +32,18 @@
- 
-    20050613 mortene. */
- 
--#include "fonts/freetype.h"
--
- #ifdef HAVE_CONFIG_H
- #include "config.h"
- #endif /* HAVE_CONFIG_H */
- 
--#include <stdlib.h>
-+#include <cstdlib>
- #include <assert.h>
- 
- #include "glue/freetype.h"
- #include "glue/GLUWrapper.h"
- 
-+#include "fonts/freetype.h"
-+
- /* ************************************************************************* */
- 
- #ifdef __cplusplus
--- 
-1.8.1.4
-
diff --git a/pkgs/development/libraries/coin3d/sbhashentry.patch b/pkgs/development/libraries/coin3d/sbhashentry.patch
deleted file mode 100644
index 88c9a5f02a2..00000000000
--- a/pkgs/development/libraries/coin3d/sbhashentry.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-diff -u --label /tmp/Coin-3.1.3/src/misc/SbHash.h --label \#\<buffer\ SbHash.h\> /tmp/Coin-3.1.3/src/misc/SbHash.h /tmp/buffer-content-21756V0
---- a/src/misc/SbHash.h
-+++ b/src/misc/SbHash.h
-@@ -88,8 +88,8 @@
-     SbHashEntry<Type, Key> * entry = static_cast<SbHashEntry<Type, Key> *>( ptr);
-     cc_memalloc_deallocate(entry->memhandler, ptr);
-   }
--  SbHashEntry(const Key & key, const Type & obj) : key(key), obj(obj) {}
--
-+  SbHashEntry(const Key & key, const Type & obj, cc_memalloc *memhandler)
-+		: key(key), obj(obj), memhandler(memhandler) {}
-   Key key;
-   Type obj;
-   SbHashEntry<Type, Key> * next;
-@@ -218,7 +218,7 @@
-     /* Key not already in the hash table; insert a new
-      * entry as the first element in the bucket
-      */
--    entry = new (this->memhandler) SbHashEntry<Type, Key>(key, obj);
-+    entry = new (this->memhandler) SbHashEntry<Type, Key>(key, obj, this->memhandler);
-     entry->next = this->buckets[i];
-     this->buckets[i] = entry;
-
-
-Diff finished.  Sat Sep  9 19:50:32 2017
diff --git a/pkgs/development/libraries/cpp-netlib/default.nix b/pkgs/development/libraries/cpp-netlib/default.nix
index badfc630a47..a4729cdeaed 100644
--- a/pkgs/development/libraries/cpp-netlib/default.nix
+++ b/pkgs/development/libraries/cpp-netlib/default.nix
@@ -1,12 +1,15 @@
-{ stdenv, fetchurl, cmake, boost, openssl, asio }:
+{ stdenv, fetchFromGitHub, cmake, boost, openssl, asio }:
 
 stdenv.mkDerivation rec {
-  name = "cpp-netlib-${version}";
-  version = "0.12.0";
+  pname = "cpp-netlib";
+  version = "0.13.0-final";
 
-  src = fetchurl {
-    url = "http://downloads.cpp-netlib.org/${version}/${name}-final.tar.bz2";
-    sha256 = "0h7gyrbr3madycnj8rl8k1jzk2hd8np2k5ad9mijlh0fizzzk3h8";
+  src = fetchFromGitHub {
+    owner = pname;
+    repo = pname;
+    rev = "${pname}-${version}";
+    sha256 = "18782sz7aggsl66b4mmi1i0ijwa76iww337fi9sygnplz2hs03a3";
+    fetchSubmodules = true;
   };
 
   buildInputs = [ cmake boost openssl ];
diff --git a/pkgs/development/libraries/cpp-utilities/default.nix b/pkgs/development/libraries/cpp-utilities/default.nix
new file mode 100644
index 00000000000..cd16dea56b1
--- /dev/null
+++ b/pkgs/development/libraries/cpp-utilities/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchFromGitHub, cmake, cppunit }:
+
+stdenv.mkDerivation rec {
+  pname = "cpp-utilities";
+  version = "4.17.1";
+
+  src = fetchFromGitHub {
+    owner = "Martchus";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "12088cwg3jbqipmbn4843w1cgxi1q6vwx47gy042rkfvbk6azhxl";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  checkInputs = [ cppunit ];
+  # Otherwise, tests fail since the resulting shared object libc++utilities.so is only available in PWD of the make files
+  checkFlagsArray = [ "LD_LIBRARY_PATH=$(PWD)" ];
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/Martchus/cpp-utilities";
+    description = "Common C++ classes and routines used by @Martchus' applications featuring argument parser, IO and conversion utilities";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ doronbehar ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/cppzmq/default.nix b/pkgs/development/libraries/cppzmq/default.nix
index 4c63e93e5c4..5bffda607ee 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.3.0";
+  version = "4.4.1";
 
   src = fetchFromGitHub {
     owner = "zeromq";
     repo = "cppzmq";
     rev = "v${version}";
-    sha256 = "1g45cdny1m08zw4l261bqcqfdb825mnwjwqcf35bkyc03fr4213l";
+    sha256 = "15dgkv51csfkafplf0n0vqbjdr4pxqxq44dln0dcizhsn1p0a57q";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/crc32c/default.nix b/pkgs/development/libraries/crc32c/default.nix
new file mode 100644
index 00000000000..916ec5b703b
--- /dev/null
+++ b/pkgs/development/libraries/crc32c/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchFromGitHub, cmake, gflags }:
+stdenv.mkDerivation rec {
+  pname = "crc32c";
+  version = "1.1.0";
+
+  src = fetchFromGitHub {
+    owner = "google";
+    repo = "crc32c";
+    rev = version;
+    sha256 = "1sazkis9rzbrklfrvk7jn1mqywnq4yghmzg94mxd153h8b1sb149";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ gflags ];
+  NIX_CFLAGS_COMPILE = stdenv.lib.optional stdenv.isAarch64 "-march=armv8-a+crc";
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/google/crc32c;
+    description = "CRC32C implementation with support for CPU-specific acceleration instructions";
+    license = with licenses; [ bsd3 ];
+    maintainers = with maintainers; [ andir ];
+  };
+}
diff --git a/pkgs/development/libraries/cre2/default.nix b/pkgs/development/libraries/cre2/default.nix
index 74619cbaaae..d8130d0b8f9 100644
--- a/pkgs/development/libraries/cre2/default.nix
+++ b/pkgs/development/libraries/cre2/default.nix
@@ -3,13 +3,13 @@
 
 stdenv.mkDerivation rec {
   name = "cre2-${version}";
-  version = "0.3.0";
-    
+  version = "0.3.6";
+
   src = fetchFromGitHub {
     owner = "marcomaggi";
     repo = "cre2";
-    rev = version;
-    sha256 = "12yrdad87jjqrhbqm02hzsayan2402vf61a9x1b2iabv6d1c1bnj";
+    rev = "v${version}";
+    sha256 = "1h9jwn6z8kjf4agla85b5xf7gfkdwncp0mfd8zwk98jkm8y2qx9q";
   };
 
   nativeBuildInputs = [
diff --git a/pkgs/development/libraries/ctypes_sh/default.nix b/pkgs/development/libraries/ctypes_sh/default.nix
new file mode 100644
index 00000000000..1e12afd95ca
--- /dev/null
+++ b/pkgs/development/libraries/ctypes_sh/default.nix
@@ -0,0 +1,28 @@
+{ stdenv
+, fetchFromGitHub
+, autoreconfHook, pkgconfig
+, zlib, libffi, elfutils, libdwarf
+}:
+
+stdenv.mkDerivation rec {
+  pname = "ctypes.sh";
+  version = "1.1";
+
+  src = fetchFromGitHub {
+    owner = "taviso";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "07rqbdxw33h92mllh0srymjjx52mddafs3jyzqpsflq3v0l0dk37";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ zlib libffi elfutils libdwarf ];
+
+  meta = with stdenv.lib; {
+    description = "A foreign function interface for bash";
+    homepage = "https://github.com/taviso/ctypes.sh";
+    license = licenses.mit;
+    maintainers = with maintainers; [ tadeokondrak ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/cutelyst/default.nix b/pkgs/development/libraries/cutelyst/default.nix
index 784a282f6b2..216b644b38e 100644
--- a/pkgs/development/libraries/cutelyst/default.nix
+++ b/pkgs/development/libraries/cutelyst/default.nix
@@ -1,19 +1,19 @@
-{ stdenv, lib, fetchFromGitHub, cmake, pkgconfig, makeWrapper
+{ stdenv, lib, fetchFromGitHub, cmake, pkgconfig, wrapQtAppsHook
 , qtbase, libuuid, libcap, uwsgi, grantlee, pcre
 }:
 
 stdenv.mkDerivation rec {
   name = "cutelyst-${version}";
-  version = "2.7.0";
+  version = "2.8.0";
 
   src = fetchFromGitHub {
     owner = "cutelyst";
     repo = "cutelyst";
     rev = "v${version}";
-    sha256 = "09cgfpr2k1jp98h1ahxqm5lmv3qbk0bcxpqpill6n5wmq2c8kl8b";
+    sha256 = "02jys32qkyksa2dmanyg4x0y5lh4ra0xbn2mfr2k84slrxbgjs1g";
   };
 
-  nativeBuildInputs = [ cmake pkgconfig makeWrapper ];
+  nativeBuildInputs = [ cmake pkgconfig wrapQtAppsHook ];
   buildInputs = [ qtbase libuuid libcap uwsgi grantlee pcre ];
 
   cmakeFlags = [
@@ -31,12 +31,6 @@ stdenv.mkDerivation rec {
     unset LD_LIBRARY_PATH
   '';
 
-  postInstall = ''
-    for prog in $out/bin/*; do
-      wrapProgram "$prog" --set QT_PLUGIN_PATH '${qtbase}/${qtbase.qtPluginPrefix}'
-    done
-  '';
-
   meta = with lib; {
     description = "C++ Web Framework built on top of Qt";
     homepage = https://cutelyst.org/;
diff --git a/pkgs/development/libraries/cyrus-sasl/default.nix b/pkgs/development/libraries/cyrus-sasl/default.nix
index 06eac4423e7..0bdaf1be955 100644
--- a/pkgs/development/libraries/cyrus-sasl/default.nix
+++ b/pkgs/development/libraries/cyrus-sasl/default.nix
@@ -1,5 +1,5 @@
 { lib, stdenv, fetchurl, openssl, openldap, kerberos, db, gettext
-, pam, fixDarwinDylibNames, autoreconfHook, fetchpatch, enableLdap ? false
+, pam, fixDarwinDylibNames, autoreconfHook, enableLdap ? false
 , buildPackages, pruneLibtoolFiles }:
 
 with stdenv.lib;
diff --git a/pkgs/development/libraries/czmq/4.x.nix b/pkgs/development/libraries/czmq/4.x.nix
index 06801dfb7d2..13cee8fe86b 100644
--- a/pkgs/development/libraries/czmq/4.x.nix
+++ b/pkgs/development/libraries/czmq/4.x.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, zeromq }:
+{ stdenv, fetchurl, zeromq }:
 
 stdenv.mkDerivation rec {
   version = "4.2.0";
diff --git a/pkgs/development/libraries/dav1d/default.nix b/pkgs/development/libraries/dav1d/default.nix
index 157a6a21f3d..5f7ca179d4a 100644
--- a/pkgs/development/libraries/dav1d/default.nix
+++ b/pkgs/development/libraries/dav1d/default.nix
@@ -1,19 +1,27 @@
-{ stdenv, fetchFromGitLab, meson, ninja, nasm }:
+{ stdenv, fetchFromGitLab
+, meson, ninja, nasm, pkgconfig
+, withTools ? false, SDL2
+}:
 
 stdenv.mkDerivation rec {
   pname = "dav1d";
-  version = "0.3.1";
+  version = "0.4.0";
 
   src = fetchFromGitLab {
     domain = "code.videolan.org";
     owner = "videolan";
     repo = pname;
     rev = version;
-    sha256 = "1m5vdg64iqxpi37l84mcfiq313g9z55zf66s85j2rqik6asmxbqg";
+    sha256 = "1fbalfzw8j00vwbrh9h8kjdx6h99dr10vmvbpg3rhsspmxq9h66h";
   };
 
-  nativeBuildInputs = [ meson ninja nasm ];
+  nativeBuildInputs = [ meson ninja nasm pkgconfig ];
   # TODO: doxygen (currently only HTML and not build by default).
+  buildInputs = stdenv.lib.optional withTools SDL2;
+
+  mesonFlags= [
+    "-Denable_tools=${stdenv.lib.boolToString withTools}"
+  ];
 
   meta = with stdenv.lib; {
     description = "A cross-platform AV1 decoder focused on speed and correctness";
diff --git a/pkgs/development/libraries/dee/default.nix b/pkgs/development/libraries/dee/default.nix
index f0f31ae1ffc..04ecadadefa 100644
--- a/pkgs/development/libraries/dee/default.nix
+++ b/pkgs/development/libraries/dee/default.nix
@@ -5,7 +5,7 @@
 , icu
 , gobject-introspection
 , dbus-glib
-, vala
+, vala_0_40
 , python3
 , autoreconfHook
 }:
@@ -30,7 +30,8 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [
     pkgconfig
-    vala
+    # https://gitlab.gnome.org/GNOME/vala/issues/803
+    vala_0_40
     autoreconfHook
     gobject-introspection
     python3
diff --git a/pkgs/development/libraries/directfb/default.nix b/pkgs/development/libraries/directfb/default.nix
index 3d831efbcb7..f7545bb03d5 100644
--- a/pkgs/development/libraries/directfb/default.nix
+++ b/pkgs/development/libraries/directfb/default.nix
@@ -1,31 +1,29 @@
-{ stdenv, fetchurl, pkgconfig, perl, zlib, libjpeg, freetype, libpng, giflib
+{ stdenv, lib, fetchFromGitHub, autoreconfHook, perl, pkgconfig, flux, zlib
+, libjpeg, freetype, libpng, giflib
 , enableX11 ? true, xorg
 , enableSDL ? true, SDL }:
 
-let s = 
-rec {
-   version = "1.7.7";
-   name="directfb-${version}";
-   sha256 = "18r7h0pwbyyk8z3pgdv77nmma8lvr1si9gl1ghxgxf1ivhwcd1dp";
-   url="http://directfb.org/downloads/Core/DirectFB-1.7/DirectFB-${version}.tar.gz";
-}
-; in
-stdenv.mkDerivation {
-  inherit (s) name;
-  src = fetchurl {
-    inherit (s) url sha256;
+stdenv.mkDerivation rec {
+  pname = "directfb";
+  version = "1.7.7";
+
+  src = fetchFromGitHub {
+    owner = "deniskropp";
+    repo = "DirectFB";
+    rev = "DIRECTFB_${lib.replaceStrings ["."] ["_"] version}";
+    sha256 = "0bs3yzb7hy3mgydrj8ycg7pllrd2b6j0gxj596inyr7ihssr3i0y";
   };
 
-  nativeBuildInputs = [ perl pkgconfig ];
+  nativeBuildInputs = [ autoreconfHook perl pkgconfig flux ];
 
   buildInputs = [ zlib libjpeg freetype giflib libpng ]
-    ++ stdenv.lib.optional enableSDL SDL
-    ++ stdenv.lib.optionals enableX11 (with xorg; [
+    ++ lib.optional enableSDL SDL
+    ++ lib.optionals enableX11 (with xorg; [
       xorgproto libX11 libXext
       libXrender
     ]);
 
-  NIX_LDFLAGS="-lgcc_s";
+  NIX_LDFLAGS = "-lgcc_s";
 
   configureFlags = [
     "--enable-sdl"
@@ -35,14 +33,11 @@ stdenv.mkDerivation {
     "--enable-fbdev"
     "--enable-mmx"
     "--enable-sse"
-    #"--enable-sysfs" # not recognized
     "--with-software"
     "--with-smooth-scaling"
-    ] ++ stdenv.lib.optionals enableX11 [
-      "--enable-x11"
-    ];
+  ] ++ lib.optional enableX11 "--enable-x11";
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Graphics and input library designed with embedded systems in mind";
     longDescription = ''
       DirectFB is a thin library that provides hardware graphics acceleration,
@@ -54,7 +49,7 @@ stdenv.mkDerivation {
       power to embedded systems and sets a new standard for graphics under
       Linux.
     '';
-    homepage = http://directfb.org/;
+    homepage = "https://github.com/deniskropp/DirectFB";
     license = licenses.lgpl21;
     platforms = platforms.linux;
     maintainers = [ maintainers.bjornfor ];
diff --git a/pkgs/development/libraries/directfb/default.upstream b/pkgs/development/libraries/directfb/default.upstream
deleted file mode 100644
index ef4ed8e490d..00000000000
--- a/pkgs/development/libraries/directfb/default.upstream
+++ /dev/null
@@ -1,3 +0,0 @@
-url 'http://directfb.org/index.php?path=Main%2FDownloads'
-version_link 'DirectFB-[0-9]'
-minimize_overwrite
diff --git a/pkgs/development/libraries/discord-rpc/default.nix b/pkgs/development/libraries/discord-rpc/default.nix
new file mode 100644
index 00000000000..3a8290a6597
--- /dev/null
+++ b/pkgs/development/libraries/discord-rpc/default.nix
@@ -0,0 +1,40 @@
+{ stdenv
+, fetchFromGitHub
+, cmake
+, rapidjson
+, AppKit
+, buildExamples ? false
+}:
+
+stdenv.mkDerivation rec {
+  pname = "discord-rpc";
+  version = "3.4.0";
+
+  src = fetchFromGitHub {
+    owner = "discordapp";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "04cxhqdv5r92lrpnhxf8702a8iackdf3sfk1050z7pijbijiql2a";
+  };
+
+  nativeBuildInputs = [
+    cmake
+  ];
+
+  buildInputs = [
+    rapidjson
+  ] ++ stdenv.lib.optional stdenv.isDarwin AppKit;
+
+  cmakeFlags = [
+    "-DBUILD_SHARED_LIBS=true"
+    "-DBUILD_EXAMPLES=${stdenv.lib.boolToString buildExamples}"
+  ];
+
+  meta = with stdenv.lib; {
+    description = "Official library to interface with the Discord client";
+    homepage = "https://github.com/discordapp/discord-rpc";
+    license = licenses.mit;
+    maintainers = with maintainers; [ tadeokondrak ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/dleyna-renderer/default.nix b/pkgs/development/libraries/dleyna-renderer/default.nix
index aae7861fef4..18244d83dee 100644
--- a/pkgs/development/libraries/dleyna-renderer/default.nix
+++ b/pkgs/development/libraries/dleyna-renderer/default.nix
@@ -1,5 +1,4 @@
 { stdenv
-, fetchurl
 , fetchFromGitHub
 , autoreconfHook
 , pkgconfig
diff --git a/pkgs/development/libraries/dlib/default.nix b/pkgs/development/libraries/dlib/default.nix
index 67a56855bb7..97d74e1ed3c 100644
--- a/pkgs/development/libraries/dlib/default.nix
+++ b/pkgs/development/libraries/dlib/default.nix
@@ -6,14 +6,14 @@
 }:
 
 stdenv.mkDerivation rec {
-  version = "19.16";
+  version = "19.17";
   name = "dlib-${version}";
 
   src = fetchFromGitHub {
     owner = "davisking";
     repo = "dlib";
     rev ="v${version}";
-    sha256 = "0ix52npsxfm6324jli7y0zkyijl5yirv2yzfncyd4sq0r9fcwb4p";
+    sha256 = "0g11ilma6cll3bd2ahm66j1sjb9v4rxz3xjbfkcg5pjsvb49n029";
   };
 
   postPatch = ''
diff --git a/pkgs/development/libraries/eclib/default.nix b/pkgs/development/libraries/eclib/default.nix
index 681062cd671..62f04e061cf 100644
--- a/pkgs/development/libraries/eclib/default.nix
+++ b/pkgs/development/libraries/eclib/default.nix
@@ -1,6 +1,5 @@
 { stdenv
 , fetchFromGitHub
-, fetchpatch
 , autoreconfHook
 , pari
 , ntl
diff --git a/pkgs/development/libraries/editline/default.nix b/pkgs/development/libraries/editline/default.nix
index e2a989f4ef2..6dfd4edd071 100644
--- a/pkgs/development/libraries/editline/default.nix
+++ b/pkgs/development/libraries/editline/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, fetchpatch, autoreconfHook }:
+{ stdenv, fetchFromGitHub, autoreconfHook }:
 
 stdenv.mkDerivation rec {
   name = "editline-${version}";
diff --git a/pkgs/development/libraries/eigen/default.nix b/pkgs/development/libraries/eigen/default.nix
index 25d0760a32d..6aec15f976b 100644
--- a/pkgs/development/libraries/eigen/default.nix
+++ b/pkgs/development/libraries/eigen/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, fetchpatch, cmake}:
+{stdenv, fetchurl, cmake}:
 
 let
   version = "3.3.7";
diff --git a/pkgs/development/libraries/elf-header/default.nix b/pkgs/development/libraries/elf-header/default.nix
index 47b39eeb7e9..c1764e83c30 100644
--- a/pkgs/development/libraries/elf-header/default.nix
+++ b/pkgs/development/libraries/elf-header/default.nix
@@ -17,7 +17,7 @@ stdenvNoCC.mkDerivation {
 
   src = null;
 
-  unpackPhase = "true";
+  dontUnpack = true;
 
   dontBuild = true;
 
diff --git a/pkgs/development/libraries/exiv2/default.nix b/pkgs/development/libraries/exiv2/default.nix
index 3f731bdf799..9b05165e1b2 100644
--- a/pkgs/development/libraries/exiv2/default.nix
+++ b/pkgs/development/libraries/exiv2/default.nix
@@ -1,28 +1,94 @@
-{ stdenv, fetchurl, fetchFromGitHub, fetchpatch, zlib, expat, gettext
-, autoconf }:
+{ stdenv
+, fetchFromGitHub
+, zlib
+, expat
+, cmake
+, which
+, libxml2
+, python3
+, gettext
+, doxygen
+, graphviz
+, libxslt
+}:
 
 stdenv.mkDerivation rec {
-  name = "exiv2-0.26.2018.12.30";
+  pname = "exiv2";
+  version = "0.27.1";
 
-    #url = "https://www.exiv2.org/builds/${name}-trunk.tar.gz";
   src = fetchFromGitHub rec {
     owner = "exiv2";
     repo  = "exiv2";
-    rev = "f5d0b25"; # https://github.com/Exiv2/exiv2/commits/0.26
-    sha256 = "1blaz3g8dlij881g14nv2nsgr984wy6ypbwgi2pixk978p0gm70i";
+    rev = version;
+    sha256 = "0b5m921070fkyif0zlyb49gly3p6xd0hv1jyym4j25hx12gzbx0c";
   };
 
-  postPatch = "patchShebangs ./src/svn_version.sh";
+  patches = [
+    # https://github.com/Exiv2/exiv2/commit/aae88060ca85a483cd7fe791ba116c04d96c0bf9#comments
+    ./fix-cmake.patch
+  ];
 
-  preConfigure = "make config"; # needed because not using tarball
+  cmakeFlags = [
+    "-DEXIV2_BUILD_PO=ON"
+    "-DEXIV2_BUILD_DOC=ON"
+  ];
 
-  outputs = [ "out" "dev" ];
+  outputs = [ "out" "dev" "doc" "man" ];
 
   nativeBuildInputs = [
+    cmake
+    doxygen
     gettext
-    autoconf # needed because not using tarball
+    graphviz
+    libxslt
+  ];
+
+  propagatedBuildInputs = [
+    expat
+    zlib
+  ];
+
+  checkInputs = [
+    libxml2.bin
+    python3
+    which
+  ];
+
+  buildFlags = [
+    "doc"
   ];
-  propagatedBuildInputs = [ zlib expat ];
+
+  doCheck = stdenv.isLinux;
+
+  # Test setup found by inspecting ${src}/.travis/run.sh; problems without cmake.
+  checkTarget = "tests";
+
+  preCheck = ''
+    patchShebangs ../test/
+    mkdir ../test/tmp
+    export LD_LIBRARY_PATH="$(realpath ../build/lib)"
+
+    # Fix tests on Aarch64
+    ${stdenv.lib.optionalString stdenv.isAarch64 ''
+      rm -f ../tests/bugfixes/github/test_CVE_2018_12265.py
+    ''}
+  '';
+
+  postCheck = ''
+    (cd ../tests/ && python3 runner.py)
+  '';
+
+  # With cmake we have to enable samples or there won't be
+  # a tests target. This removes them.
+  postInstall = ''
+    ( cd "$out/bin"
+      mv exiv2 .exiv2
+      rm *
+      mv .exiv2 exiv2
+    )
+  '';
+
+  enableParallelBuilding = true;
 
   meta = with stdenv.lib; {
     homepage = https://www.exiv2.org/;
diff --git a/pkgs/development/libraries/exiv2/fix-cmake.patch b/pkgs/development/libraries/exiv2/fix-cmake.patch
new file mode 100644
index 00000000000..1e19aed8b90
--- /dev/null
+++ b/pkgs/development/libraries/exiv2/fix-cmake.patch
@@ -0,0 +1,16 @@
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 34087004..41b3a068 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -239,9 +239,9 @@ install(FILES
+     ${CMAKE_BINARY_DIR}/exiv2lib_export.h
+     DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/exiv2)
+ 
+-install(EXPORT exiv2Config DESTINATION "${CMAKE_INSTALL_LIBDIR}/exiv2/cmake")
++install(EXPORT exiv2Config DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/exiv2")
+ 
+-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/exiv2ConfigVersion.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/exiv2/cmake")
++install(FILES ${CMAKE_CURRENT_BINARY_DIR}/exiv2ConfigVersion.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/exiv2")
+ 
+ # ******************************************************************************
+ # exiv2 application
diff --git a/pkgs/development/libraries/exosip/default.nix b/pkgs/development/libraries/exosip/default.nix
index 240f3c136ef..332504e46b5 100644
--- a/pkgs/development/libraries/exosip/default.nix
+++ b/pkgs/development/libraries/exosip/default.nix
@@ -1,20 +1,27 @@
-{stdenv, fetchurl, libosip, openssl, pkgconfig }:
+{ stdenv, fetchurl, libosip, openssl, pkgconfig, fetchpatch }:
 
 stdenv.mkDerivation rec {
  name = "libexosip2-${version}";
  version = "4.1.0";
- 
+
  src = fetchurl {
     url = "mirror://savannah/exosip/libeXosip2-${version}.tar.gz";
     sha256 = "17cna8kpc8nk1si419vgr6r42k2lda0rdk50vlxrw8rzg0xp2xrw";
   };
- 
+
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ libosip openssl ];
-      
+
+  patches = [
+    (fetchpatch {
+      url = "https://sources.debian.net/data/main/libe/libexosip2/4.1.0-2.1/debian/patches/openssl110.patch";
+      sha256 = "01q2dax7pwh197mn18r22y38mrsky85mvs9vbkn9fpcilrdayal6";
+    })
+  ];
+
   meta = with stdenv.lib; {
     license = licenses.gpl2Plus;
     description = "Library that hides the complexity of using the SIP protocol";
-    platforms =platforms.linux;
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/expat/default.nix b/pkgs/development/libraries/expat/default.nix
index 7e4d46c012d..ef257401945 100644
--- a/pkgs/development/libraries/expat/default.nix
+++ b/pkgs/development/libraries/expat/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "expat-2.2.6";
+  name = "expat-2.2.7";
 
   src = fetchurl {
     url = "mirror://sourceforge/expat/${name}.tar.bz2";
-    sha256 = "1wl1x93b5w457ddsdgj0lh7yjq4q6l7wfbgwhagkc8fm2qkkrd0p";
+    sha256 = "067cfhqwiswm4zynw7xaxl59mrrimaiyjhnn8byxma1i98pi1jfb";
   };
 
   outputs = [ "out" "dev" ]; # TODO: fix referrers
diff --git a/pkgs/development/libraries/fcppt/default.nix b/pkgs/development/libraries/fcppt/default.nix
index a37ebe7c5e0..77e26f6b5dc 100644
--- a/pkgs/development/libraries/fcppt/default.nix
+++ b/pkgs/development/libraries/fcppt/default.nix
@@ -1,14 +1,14 @@
 { stdenv, fetchFromGitHub, cmake, boost, brigand, catch2 }:
 
 stdenv.mkDerivation rec {
-  name = "fcppt-${version}";
-  version = "3.0.0";
+  pname = "fcppt";
+  version = "3.2.2";
 
   src = fetchFromGitHub {
     owner = "freundlich";
     repo = "fcppt";
     rev = version;
-    sha256 = "0l78fjhy9nl3afrf0da9da4wzp1sx3kcyc2j6b71i60kvk44v4in";
+    sha256 = "09mah52m3lih2n0swpsh8qb72yzl4nixaq99xp7wxyxxprhf4bpa";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/ffmpeg-full/default.nix b/pkgs/development/libraries/ffmpeg-full/default.nix
index db606cc02d6..28ab53feebd 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
 /*
  *  Licensing options (yes some are listed twice, filters and such are not listed)
  */
@@ -52,6 +52,7 @@
 , bzip2 ? null
 , celt ? null # CELT decoder
 #, crystalhd ? null # Broadcom CrystalHD hardware acceleration
+, dav1d ? null # AV1 decoder (focused on speed and correctness)
 #, decklinkExtlib ? false, blackmagic-design-desktop-video ? null # Blackmagic Design DeckLink I/O support
 , fdkaacExtlib ? false, fdk_aac ? null # Fraunhofer FDK AAC de/encoder
 #, flite ? null # Flite (voice synthesis) support
@@ -97,7 +98,7 @@
 , libXv ? null # Xlib support
 , libXext ? null # Xlib support
 , lzma ? null # xz-utils
-, nvenc ? true, nv-codec-headers ? null # NVIDIA NVENC support
+, nvenc ? !stdenv.isDarwin && !stdenv.isAarch64, nv-codec-headers ? null # NVIDIA NVENC support
 , openal ? null # OpenAL 1.1 capture support
 #, opencl ? null # OpenCL code
 , opencore-amr ? null # AMR-NB de/encoder & AMR-WB decoder
@@ -139,7 +140,7 @@
  *  Darwin frameworks
  */
 , Cocoa, CoreAudio, CoreServices, AVFoundation, MediaToolbox
-, VideoDecodeAcceleration, cf-private
+, VideoDecodeAcceleration
 }:
 
 /* Maintainer notes:
@@ -163,6 +164,9 @@
  *   libvpx(stable 1.3.0) openal openjpeg pulseaudio rtmpdump samba vid-stab
  *   wavpack x265 xavs
  *
+ * Need fixes to support AArch64:
+ *   libmfx(intel-media-sdk) nvenc
+ *
  * Not supported:
  *   stagefright-h264(android only)
  *
@@ -175,7 +179,7 @@
  */
 
 let
-  inherit (stdenv) isCygwin isFreeBSD isLinux;
+  inherit (stdenv) isCygwin isDarwin isFreeBSD isLinux isAarch64;
   inherit (stdenv.lib) optional optionals optionalString enableFeature;
 in
 
@@ -190,6 +194,10 @@ assert nonfreeLicensing -> gplLicensing && version3Licensing;
 assert networkBuild -> gnutls != null || opensslExtlib;
 assert pixelutilsBuild -> avutilLibrary;
 /*
+ *  Platform dependencies
+ */
+assert isDarwin -> !nvenc;
+/*
  *  Program dependencies
  */
 assert ffmpegProgram -> avcodecLibrary
@@ -230,13 +238,15 @@ assert opensslExtlib -> gnutls == null && openssl != null && nonfreeLicensing;
 
 stdenv.mkDerivation rec {
   name = "ffmpeg-full-${version}";
-  version = "4.1.3";
+  version = "4.2";
 
   src = fetchurl {
     url = "https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz";
-    sha256 = "0gdnprc7gk4b7ckq8wbxbrj7i00r76r9a5g9mj7iln40512j0c0c";
+    sha256 = "1mgcxm7sqkajx35px05szsmn9mawwm03cfpmk3br7bcp3a1i0gq2";
   };
 
+  patches = [ ./prefer-libdav1d-over-libaom.patch ];
+
   prePatch = ''
     patchShebangs .
   '' + stdenv.lib.optionalString stdenv.isDarwin ''
@@ -318,6 +328,7 @@ stdenv.mkDerivation rec {
     (enableFeature (bzip2 != null) "bzlib")
     (enableFeature (celt != null) "libcelt")
     #(enableFeature crystalhd "crystalhd")
+    (enableFeature (dav1d != null) "libdav1d")
     #(enableFeature decklinkExtlib "decklink")
     (enableFeature (fdkaacExtlib && gplLicensing) "libfdk-aac")
     #(enableFeature (flite != null) "libflite")
@@ -342,7 +353,7 @@ stdenv.mkDerivation rec {
     (enableFeature (if isLinux then libdc1394 != null && libraw1394 != null else false) "libdc1394")
     (enableFeature (libiconv != null) "iconv")
     #(enableFeature (if isLinux then libiec61883 != null && libavc1394 != null && libraw1394 != null else false) "libiec61883")
-    (enableFeature (if isLinux then libmfx != null else false) "libmfx")
+    (enableFeature (if isLinux && !isAarch64 then libmfx != null else false) "libmfx")
     (enableFeature (libmodplug != null) "libmodplug")
     (enableFeature (libmysofa != null) "libmysofa")
     #(enableFeature (libnut != null) "libnut")
@@ -405,7 +416,7 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ perl pkgconfig texinfo yasm ];
 
   buildInputs = [
-    bzip2 celt fontconfig freetype frei0r fribidi game-music-emu gnutls gsm
+    bzip2 celt dav1d fontconfig freetype frei0r fribidi game-music-emu gnutls gsm
     libjack2 ladspaH lame libaom libass libbluray libbs2b libcaca libdc1394 libmodplug libmysofa
     libogg libopus libssh libtheora libvdpau libvorbis libvpx libwebp libX11
     libxcb libXv libXext lzma openal openjpeg libpulseaudio rtmpdump opencore-amr
@@ -415,11 +426,11 @@ stdenv.mkDerivation rec {
     ++ optionals nonfreeLicensing [ fdk_aac openssl ]
     ++ optional ((isLinux || isFreeBSD) && libva != null) libva
     ++ optionals isLinux [ alsaLib libraw1394 libv4l ]
-    ++ optional (isLinux && libmfx != null) libmfx
+    ++ optional (isLinux && !isAarch64 && libmfx != null) libmfx
     ++ optional nvenc nv-codec-headers
     ++ optionals stdenv.isDarwin [ Cocoa CoreServices CoreAudio AVFoundation
                                    MediaToolbox VideoDecodeAcceleration
-                                   libiconv cf-private /* For _OBJC_EHTYPE_$_NSException */ ];
+                                   libiconv ];
 
   buildFlags = [ "all" ]
     ++ optional qtFaststartProgram "tools/qt-faststart"; # Build qt-faststart executable
@@ -427,14 +438,6 @@ stdenv.mkDerivation rec {
   # Hacky framework patching technique borrowed from the phantomjs2 package
   postInstall = optionalString qtFaststartProgram ''
     cp -a tools/qt-faststart $out/bin/
-  '' + optionalString stdenv.isDarwin ''
-    FILES=($(ls $out/bin/*))
-    FILES+=($(ls $out/lib/*.dylib))
-    for f in ''${FILES[@]}; do
-      if [ ! -h "$f" ]; then
-        install_name_tool -change ${cf-private}/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation "$f"
-      fi
-    done
   '';
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/ffmpeg-full/prefer-libdav1d-over-libaom.patch b/pkgs/development/libraries/ffmpeg-full/prefer-libdav1d-over-libaom.patch
new file mode 100644
index 00000000000..789bfc2674f
--- /dev/null
+++ b/pkgs/development/libraries/ffmpeg-full/prefer-libdav1d-over-libaom.patch
@@ -0,0 +1,19 @@
+diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
+index d2f9a39ce5..2342399a8e 100644
+--- a/libavcodec/allcodecs.c
++++ b/libavcodec/allcodecs.c
+@@ -679,13 +679,13 @@ extern AVCodec ff_pcm_mulaw_at_encoder;
+ extern AVCodec ff_pcm_mulaw_at_decoder;
+ extern AVCodec ff_qdmc_at_decoder;
+ extern AVCodec ff_qdm2_at_decoder;
++extern AVCodec ff_libdav1d_decoder;
+ extern AVCodec ff_libaom_av1_decoder;
+ extern AVCodec ff_libaom_av1_encoder;
+ extern AVCodec ff_libaribb24_decoder;
+ extern AVCodec ff_libcelt_decoder;
+ extern AVCodec ff_libcodec2_encoder;
+ extern AVCodec ff_libcodec2_decoder;
+-extern AVCodec ff_libdav1d_decoder;
+ extern AVCodec ff_libdavs2_decoder;
+ extern AVCodec ff_libfdk_aac_encoder;
+ extern AVCodec ff_libfdk_aac_decoder;
diff --git a/pkgs/development/libraries/ffmpeg/4.nix b/pkgs/development/libraries/ffmpeg/4.nix
index 3066e0b12e5..8fd2ce70498 100644
--- a/pkgs/development/libraries/ffmpeg/4.nix
+++ b/pkgs/development/libraries/ffmpeg/4.nix
@@ -6,7 +6,7 @@
 
 callPackage ./generic.nix (args // rec {
   version = "${branch}";
-  branch = "4.1.3";
-  sha256 = "0aka5pibjhpks1wrsvqpy98v8cbvyvnngwqhh4ajkg6pbdl7k9i9";
+  branch = "4.2";
+  sha256 = "1f3glany3p2j832a9wia5vj8ds9xpm0xxlyia91y17hy85gxwsrh";
   darwinFrameworks = [ Cocoa CoreMedia VideoToolbox ];
 })
diff --git a/pkgs/development/libraries/ffms/default.nix b/pkgs/development/libraries/ffms/default.nix
index 8a5a9705cb2..1ad861fc63d 100644
--- a/pkgs/development/libraries/ffms/default.nix
+++ b/pkgs/development/libraries/ffms/default.nix
@@ -16,6 +16,13 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ zlib ffmpeg ];
 
+  # ffms includes a built-in vapoursynth plugin, see:
+  # https://github.com/FFMS/ffms2#avisynth-and-vapoursynth-plugin
+  postInstall = ''
+    mkdir $out/lib/vapoursynth
+    ln -s $out/lib/libffms2.so $out/lib/vapoursynth/libffms2.so
+  '';
+
   meta = with stdenv.lib; {
     homepage = https://github.com/FFMS/ffms2/;
     description = "Libav/ffmpeg based source library for easy frame accurate access";
diff --git a/pkgs/development/libraries/flatpak/bubblewrap-paths.patch b/pkgs/development/libraries/flatpak/bubblewrap-paths.patch
index 79257fd6be5..407811736f8 100644
--- a/pkgs/development/libraries/flatpak/bubblewrap-paths.patch
+++ b/pkgs/development/libraries/flatpak/bubblewrap-paths.patch
@@ -1,8 +1,8 @@
 diff --git a/icon-validator/validate-icon.c b/icon-validator/validate-icon.c
-index 6e23d9f2..8c621ec4 100644
+index 9e885070..d02eeb8c 100644
 --- a/icon-validator/validate-icon.c
 +++ b/icon-validator/validate-icon.c
-@@ -149,8 +149,8 @@ rerun_in_sandbox (const char *arg_width,
+@@ -156,8 +156,8 @@ rerun_in_sandbox (const char *arg_width,
              "--unshare-ipc",
              "--unshare-net",
              "--unshare-pid",
diff --git a/pkgs/development/libraries/flatpak/default.nix b/pkgs/development/libraries/flatpak/default.nix
index 4ea17e588a9..d29be4cb930 100644
--- a/pkgs/development/libraries/flatpak/default.nix
+++ b/pkgs/development/libraries/flatpak/default.nix
@@ -1,18 +1,18 @@
 { stdenv, fetchurl, autoreconfHook, docbook_xml_dtd_412, docbook_xml_dtd_42, docbook_xml_dtd_43, docbook_xsl, which, libxml2
 , gobject-introspection, gtk-doc, intltool, libxslt, pkgconfig, xmlto, appstream-glib, substituteAll, glibcLocales, yacc, xdg-dbus-proxy, p11-kit
-, bubblewrap, bzip2, dbus, glib, gpgme, json-glib, libarchive, libcap, libseccomp, coreutils, gettext, python2, hicolor-icon-theme
+, bubblewrap, bzip2, dbus, glib, gpgme, json-glib, libarchive, libcap, libseccomp, coreutils, gettext, hicolor-icon-theme, fuse
 , libsoup, lzma, ostree, polkit, python3, systemd, xorg, valgrind, glib-networking, wrapGAppsHook, gnome3, gsettings-desktop-schemas, librsvg }:
 
 stdenv.mkDerivation rec {
   pname = "flatpak";
-  version = "1.2.4";
+  version = "1.4.2";
 
   # TODO: split out lib once we figure out what to do with triggerdir
   outputs = [ "out" "man" "doc" "installedTests" ];
 
   src = fetchurl {
     url = "https://github.com/flatpak/flatpak/releases/download/${version}/${pname}-${version}.tar.xz";
-    sha256 = "1qf3ys84fzv11z6f6li59rxjdjbyrv7cyi9539k73r9i9pckjr8v";
+    sha256 = "08nmpp26mgv0vp3mlwk97rnp0j7i108h4hr9nllja19sjxnrlygj";
   };
 
   patches = [
@@ -43,7 +43,7 @@ stdenv.mkDerivation rec {
 
   buildInputs = [
     bubblewrap bzip2 dbus gnome3.dconf glib gpgme json-glib libarchive libcap libseccomp
-    libsoup lzma ostree polkit python3 systemd xorg.libXau
+    libsoup lzma ostree polkit python3 systemd xorg.libXau fuse
     gsettings-desktop-schemas glib-networking
     librsvg # for flatpak-validate-icon
   ];
diff --git a/pkgs/development/libraries/flatpak/fix-paths.patch b/pkgs/development/libraries/flatpak/fix-paths.patch
index 49fcaa2b3f9..746b4382864 100644
--- a/pkgs/development/libraries/flatpak/fix-paths.patch
+++ b/pkgs/development/libraries/flatpak/fix-paths.patch
@@ -1,6 +1,8 @@
+diff --git a/session-helper/flatpak-session-helper.c b/session-helper/flatpak-session-helper.c
+index 5dd7629e..ddc71a4c 100644
 --- a/session-helper/flatpak-session-helper.c
 +++ b/session-helper/flatpak-session-helper.c
-@@ -624,7 +624,7 @@
+@@ -693,7 +693,7 @@ start_p11_kit_server (const char *flatpak_dir)
    g_auto(GStrv) stdout_lines = NULL;
    int i;
    char *p11_argv[] = {
@@ -9,7 +11,7 @@
      /* We explicitly request --sh here, because we then fail on earlier versions that doesn't support
       * this flag. This is good, because those earlier versions did not properly daemonize and caused
       * the spawn_sync to hang forever, waiting for the pipe to close.
-@@ -770,7 +770,7 @@
+@@ -836,7 +836,7 @@ main (int    argc,
        exit (1);
      }
  
diff --git a/pkgs/development/libraries/flatpak/fix-test-paths.patch b/pkgs/development/libraries/flatpak/fix-test-paths.patch
index f987899e3bc..85b222152d0 100644
--- a/pkgs/development/libraries/flatpak/fix-test-paths.patch
+++ b/pkgs/development/libraries/flatpak/fix-test-paths.patch
@@ -1,6 +1,8 @@
+diff --git a/tests/libtest.sh b/tests/libtest.sh
+index 46bcefb3..0134425e 100644
 --- a/tests/libtest.sh
 +++ b/tests/libtest.sh
-@@ -328,7 +328,7 @@
+@@ -352,7 +352,7 @@ if [ -z "${FLATPAK_BWRAP:-}" ]; then
      # running installed-tests: assume we know what we're doing
      _flatpak_bwrap_works=true
  elif ! "$FLATPAK_BWRAP" --unshare-ipc --unshare-net --unshare-pid \
@@ -9,7 +11,7 @@
      _flatpak_bwrap_works=false
  else
      _flatpak_bwrap_works=true
-@@ -309,12 +309,12 @@
+@@ -426,12 +426,12 @@ dbus-daemon --fork --config-file=session.conf --print-address=3 --print-pid=4 \
  export DBUS_SESSION_BUS_ADDRESS="$(cat dbus-session-bus-address)"
  DBUS_SESSION_BUS_PID="$(cat dbus-session-bus-pid)"
  
@@ -24,9 +26,11 @@
      gpg-connect-agent --homedir "${FL_GPG_HOMEDIR}" killagent /bye || true
      fusermount -u $XDG_RUNTIME_DIR/doc || :
      if test -n "${TEST_SKIP_CLEANUP:-}"; then
+diff --git a/tests/make-test-app.sh b/tests/make-test-app.sh
+index 0a0a28f1..16fd51fe 100755
 --- a/tests/make-test-app.sh
 +++ b/tests/make-test-app.sh
-@@ -114,13 +114,13 @@ msgid "Hello world"
+@@ -129,13 +129,13 @@ msgid "Hello world"
  msgstr "Hallo Welt"
  EOF
  mkdir -p ${DIR}/files/de/share/de/LC_MESSAGES
@@ -42,9 +46,11 @@
  
  flatpak build-finish ${DIR}
  mkdir -p repos
+diff --git a/tests/make-test-runtime.sh b/tests/make-test-runtime.sh
+index 57899b75..9236996f 100755
 --- a/tests/make-test-runtime.sh
 +++ b/tests/make-test-runtime.sh
-@@ -26,6 +26,7 @@
+@@ -28,6 +28,7 @@ EOF
  PATH="$PATH:/usr/sbin:/sbin"
  
  # Add bash and dependencies
@@ -52,7 +58,7 @@
  mkdir -p ${DIR}/usr/bin
  mkdir -p ${DIR}/usr/lib
  ln -s ../lib ${DIR}/usr/lib64
-@@ -35,48 +36,27 @@
+@@ -37,48 +38,23 @@ if test -f /sbin/ldconfig.real; then
  else
      cp `which ldconfig` ${DIR}/usr/bin
  fi
@@ -105,21 +111,20 @@
 -# We copy the C.UTF8 locale and call it en_US. Its a bit of a lie, but
 -# the real en_US locale is often not available, because its in the
 -# local archive.
+-mkdir -p ${DIR}/usr/lib/locale/
+-cp -r /usr/lib/locale/C.* ${DIR}/usr/lib/locale/en_US
 +mv ${DIR}/nix/store ${DIR}/usr/store # files outside /usr are not permitted, we will have to replace /nix/store with /usr/store
 +chmod -R u+w ${DIR} # nix store has read-only directories which would cause problems during clean-up, files need to be writable for sed
 +find ${DIR} -type f -print0 | xargs -0 sed -i 's~/nix/store/~/usr/store/~g' # replace hardcoded paths
 +find ${DIR} -type l | xargs -I '{}' sh -c 'tg="$(readlink "$1")"; newtg="${tg#/nix/store/}"; if [ "$tg" != "$newtg" ]; then ln -fs "/usr/store/$newtg" "$1"; fi' -- '{}' # replace symlink targets
-+
-+# We copy the whole locale archive because we do not have C.UTF8 locale
- mkdir -p ${DIR}/usr/lib/locale/
--cp -r /usr/lib/locale/C.* ${DIR}/usr/lib/locale/en_US
-+cp @glibcLocales@/lib/locale/locale-archive ${DIR}/usr/lib/locale/locale-archive
  
  if [ x$COLLECTION_ID != x ]; then
      collection_args=--collection-id=${COLLECTION_ID}
+diff --git a/tests/testlibrary.c b/tests/testlibrary.c
+index f2773dc8..3af9026f 100644
 --- a/tests/testlibrary.c
 +++ b/tests/testlibrary.c
-@@ -584,7 +584,7 @@
+@@ -1053,7 +1053,7 @@ check_bwrap_support (void)
      {
        gint exit_code = 0;
        char *argv[] = { (char *) bwrap, "--unshare-ipc", "--unshare-net",
@@ -128,6 +133,8 @@
        g_autofree char *argv_str = g_strjoinv (" ", argv);
        g_test_message ("Spawning %s", argv_str);
        g_spawn_sync (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL, &exit_code, &error);
+diff --git a/triggers/gtk-icon-cache.trigger b/triggers/gtk-icon-cache.trigger
+index 711cfab2..10c220ec 100755
 --- a/triggers/gtk-icon-cache.trigger
 +++ b/triggers/gtk-icon-cache.trigger
 @@ -1,7 +1,7 @@
diff --git a/pkgs/development/libraries/flatpak/respect-xml-catalog-files-var.patch b/pkgs/development/libraries/flatpak/respect-xml-catalog-files-var.patch
index 0e259aebd8a..4cee60be2d0 100644
--- a/pkgs/development/libraries/flatpak/respect-xml-catalog-files-var.patch
+++ b/pkgs/development/libraries/flatpak/respect-xml-catalog-files-var.patch
@@ -1,6 +1,8 @@
+diff --git a/acinclude.m4 b/acinclude.m4
+index 92ec3985..b3fccf1d 100644
 --- a/acinclude.m4
 +++ b/acinclude.m4
-@@ -40,8 +40,8 @@
+@@ -40,8 +40,8 @@ AC_DEFUN([JH_CHECK_XML_CATALOG],
  [
    AC_REQUIRE([JH_PATH_XML_CATALOG],[JH_PATH_XML_CATALOG(,[:])])dnl
    AC_MSG_CHECKING([for ifelse([$2],,[$1],[$2]) in XML catalog])
diff --git a/pkgs/development/libraries/flatpak/unset-env-vars.patch b/pkgs/development/libraries/flatpak/unset-env-vars.patch
index 798e388b23c..63ce0d12fe0 100644
--- a/pkgs/development/libraries/flatpak/unset-env-vars.patch
+++ b/pkgs/development/libraries/flatpak/unset-env-vars.patch
@@ -1,6 +1,8 @@
+diff --git a/common/flatpak-run.c b/common/flatpak-run.c
+index 8d52d3a5..81700183 100644
 --- a/common/flatpak-run.c
 +++ b/common/flatpak-run.c
-@@ -1192,6 +1192,7 @@ static const ExportData default_exports[] = {
+@@ -1232,6 +1232,7 @@ static const ExportData default_exports[] = {
    {"PERLLIB", NULL},
    {"PERL5LIB", NULL},
    {"XCURSOR_PATH", NULL},
diff --git a/pkgs/development/libraries/flatpak/use-flatpak-from-path.patch b/pkgs/development/libraries/flatpak/use-flatpak-from-path.patch
index 408198bda5c..01363ffb7b3 100644
--- a/pkgs/development/libraries/flatpak/use-flatpak-from-path.patch
+++ b/pkgs/development/libraries/flatpak/use-flatpak-from-path.patch
@@ -1,6 +1,8 @@
+diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c
+index 8f9dc66c..d3ab6e5f 100644
 --- a/common/flatpak-dir.c
 +++ b/common/flatpak-dir.c
-@@ -5758,7 +5758,7 @@ export_desktop_file (const char   *app,
+@@ -6701,7 +6701,7 @@ export_desktop_file (const char         *app,
  
        new_exec = g_string_new ("");
        g_string_append_printf (new_exec,
@@ -9,7 +11,7 @@
                                escaped_branch,
                                escaped_arch);
  
-@@ -6935,8 +6935,8 @@ flatpak_dir_deploy (FlatpakDir          *self,
+@@ -7891,8 +7891,8 @@ flatpak_dir_deploy (FlatpakDir          *self,
                                         error))
          return FALSE;
  
@@ -21,28 +23,28 @@
                                      G_FILE_CREATE_REPLACE_DESTINATION, NULL, cancellable, error))
          return FALSE;
 diff --git a/tests/test-bundle.sh b/tests/test-bundle.sh
-index 6937b041..01f8add7 100755
+index dff17f33..a9857adc 100755
 --- a/tests/test-bundle.sh
 +++ b/tests/test-bundle.sh
 @@ -59,7 +59,7 @@ assert_has_dir $FL_DIR/app/org.test.Hello/$ARCH/master/active/files
  assert_has_dir $FL_DIR/app/org.test.Hello/$ARCH/master/active/export
  assert_has_file $FL_DIR/exports/share/applications/org.test.Hello.desktop
  # Ensure Exec key is rewritten
--assert_file_has_content $FL_DIR/exports/share/applications/org.test.Hello.desktop "^Exec=.*/flatpak run --branch=master --arch=$ARCH --command=hello.sh org.test.Hello$"
-+assert_file_has_content $FL_DIR/exports/share/applications/org.test.Hello.desktop "^Exec=flatpak run --branch=master --arch=$ARCH --command=hello.sh org.test.Hello$"
+-assert_file_has_content $FL_DIR/exports/share/applications/org.test.Hello.desktop "^Exec=.*/flatpak run --branch=master --arch=$ARCH --command=hello\.sh org\.test\.Hello$"
++assert_file_has_content $FL_DIR/exports/share/applications/org.test.Hello.desktop "^Exec=flatpak run --branch=master --arch=$ARCH --command=hello\.sh org\.test\.Hello$"
  assert_has_file $FL_DIR/exports/share/icons/hicolor/64x64/apps/org.test.Hello.png
  assert_has_file $FL_DIR/exports/share/icons/HighContrast/64x64/apps/org.test.Hello.png
  
 diff --git a/tests/test-run.sh b/tests/test-run.sh
-index 9d83d82e..234e4ec6 100755
+index 233df9ad..76e0b23b 100644
 --- a/tests/test-run.sh
 +++ b/tests/test-run.sh
-@@ -42,7 +42,7 @@ assert_has_dir $FL_DIR/app/org.test.Hello/$ARCH/master/active/files
- assert_has_dir $FL_DIR/app/org.test.Hello/$ARCH/master/active/export
+@@ -45,7 +45,7 @@ assert_has_dir $FL_DIR/app/org.test.Hello/$ARCH/stable/active/files
+ assert_has_dir $FL_DIR/app/org.test.Hello/$ARCH/stable/active/export
  assert_has_file $FL_DIR/exports/share/applications/org.test.Hello.desktop
  # Ensure Exec key is rewritten
--assert_file_has_content $FL_DIR/exports/share/applications/org.test.Hello.desktop "^Exec=.*/flatpak run --branch=master --arch=$ARCH --command=hello.sh org.test.Hello$"
-+assert_file_has_content $FL_DIR/exports/share/applications/org.test.Hello.desktop "^Exec=flatpak run --branch=master --arch=$ARCH --command=hello.sh org.test.Hello$"
+-assert_file_has_content $FL_DIR/exports/share/applications/org.test.Hello.desktop "^Exec=.*/flatpak run --branch=stable --arch=$ARCH --command=hello\.sh org\.test\.Hello$"
++assert_file_has_content $FL_DIR/exports/share/applications/org.test.Hello.desktop "^Exec=flatpak run --branch=stable --arch=$ARCH --command=hello\.sh org\.test\.Hello$"
  assert_has_file $FL_DIR/exports/share/icons/hicolor/64x64/apps/org.test.Hello.png
  assert_not_has_file $FL_DIR/exports/share/icons/hicolor/64x64/apps/dont-export.png
  assert_has_file $FL_DIR/exports/share/icons/HighContrast/64x64/apps/org.test.Hello.png
diff --git a/pkgs/development/libraries/flatpak/validate-icon-pixbuf.patch b/pkgs/development/libraries/flatpak/validate-icon-pixbuf.patch
index 5b8cc2d0383..086114e11c3 100644
--- a/pkgs/development/libraries/flatpak/validate-icon-pixbuf.patch
+++ b/pkgs/development/libraries/flatpak/validate-icon-pixbuf.patch
@@ -1,8 +1,8 @@
 diff --git a/icon-validator/validate-icon.c b/icon-validator/validate-icon.c
-index 6e23d9f2..f0659a78 100644
+index 9e885070..44fea035 100644
 --- a/icon-validator/validate-icon.c
 +++ b/icon-validator/validate-icon.c
-@@ -193,6 +193,8 @@ rerun_in_sandbox (const char *arg_width,
+@@ -200,6 +200,8 @@ rerun_in_sandbox (const char *arg_width,
      add_args (args, "--setenv", "G_MESSAGES_DEBUG", g_getenv ("G_MESSAGES_DEBUG"), NULL);
    if (g_getenv ("G_MESSAGES_PREFIXED"))
      add_args (args, "--setenv", "G_MESSAGES_PREFIXED", g_getenv ("G_MESSAGES_PREFIXED"), NULL);
diff --git a/pkgs/development/libraries/fltk/1.4.nix b/pkgs/development/libraries/fltk/1.4.nix
index 3cdebe184d7..cad4419a26c 100644
--- a/pkgs/development/libraries/fltk/1.4.nix
+++ b/pkgs/development/libraries/fltk/1.4.nix
@@ -1,11 +1,13 @@
 { stdenv, fetchurl, pkgconfig, xlibsWrapper, xorgproto, libXi
 , freeglut, libGLU_combined, libjpeg, zlib, libXft, libpng
-, libtiff, freetype, cf-private, Cocoa, AGL, GLUT
+, libtiff, freetype, Cocoa, AGL, GLUT
 }:
 
 let
   version = "1.4.x-r13121";
-in stdenv.mkDerivation {
+in
+
+stdenv.mkDerivation {
   name = "fltk-${version}";
 
   src = fetchurl {
@@ -13,19 +15,16 @@ in stdenv.mkDerivation {
     sha256 = "1v8wxvxcbk99i82x2v5fpqg5vj8n7g8a38g30ry7nzcjn5sf3r63";
   };
 
-  preConfigure = "make clean";
-
   patches = stdenv.lib.optionals stdenv.isDarwin [ ./nsosv.patch ];
 
   nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ libGLU_combined libjpeg zlib libpng libXft ]
+    ++ stdenv.lib.optional stdenv.isDarwin [ AGL Cocoa GLUT ];
 
-  buildInputs = [
-    libGLU_combined
-    libjpeg
-    zlib
-    libpng
-    libXft
-  ];
+  propagatedBuildInputs = [ xorgproto ]
+    ++ (if stdenv.isDarwin
+        then [ freetype libtiff ]
+        else [ xlibsWrapper libXi freeglut ]);
 
   configureFlags = [
     "--enable-gl"
@@ -35,18 +34,15 @@ in stdenv.mkDerivation {
     "--enable-xft"
   ];
 
-  propagatedBuildInputs = [ xorgproto ]
-    ++ (if stdenv.isDarwin
-        then [ Cocoa AGL GLUT freetype libtiff cf-private  /* Needed for NSDefaultRunLoopMode */ ]
-        else [ xlibsWrapper libXi freeglut ]);
+  preConfigure = "make clean";
 
   enableParallelBuilding = true;
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "A C++ cross-platform lightweight GUI library";
     homepage = http://www.fltk.org;
-    platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
-    license = stdenv.lib.licenses.gpl2;
+    platforms = platforms.linux ++ platforms.darwin;
+    license = licenses.gpl2;
   };
 
 }
diff --git a/pkgs/development/libraries/fltk/default.nix b/pkgs/development/libraries/fltk/default.nix
index 60773d29d3d..bb9f8fe76c9 100644
--- a/pkgs/development/libraries/fltk/default.nix
+++ b/pkgs/development/libraries/fltk/default.nix
@@ -1,11 +1,13 @@
 { stdenv, fetchurl, pkgconfig, xlibsWrapper, xorgproto, libXi
 , freeglut, libGLU_combined, libjpeg, zlib, libXft, libpng
-, libtiff, freetype, cf-private, Cocoa, AGL, GLUT
+, libtiff, freetype, Cocoa, AGL, GLUT
 }:
 
 let
   version = "1.3.5";
-in stdenv.mkDerivation {
+in
+
+stdenv.mkDerivation {
   name = "fltk-${version}";
 
   src = fetchurl {
@@ -16,14 +18,13 @@ in stdenv.mkDerivation {
   patches = stdenv.lib.optionals stdenv.isDarwin [ ./nsosv.patch ];
 
   nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ libGLU_combined libjpeg zlib libpng libXft ]
+    ++ stdenv.lib.optional stdenv.isDarwin [ AGL Cocoa GLUT ];
 
-  buildInputs = [
-    libGLU_combined
-    libjpeg
-    zlib
-    libpng
-    libXft
-  ];
+  propagatedBuildInputs = [ xorgproto ]
+    ++ (if stdenv.isDarwin
+        then [ freetype libtiff ]
+        else [ xlibsWrapper libXi freeglut ]);
 
   configureFlags = [
     "--enable-gl"
@@ -33,18 +34,12 @@ in stdenv.mkDerivation {
     "--enable-xft"
   ];
 
-  propagatedBuildInputs = [ xorgproto ]
-    ++ (if stdenv.isDarwin
-        then [ Cocoa AGL GLUT freetype libtiff cf-private  /* Needed for NSDefaultRunLoopMode */ ]
-        else [ xlibsWrapper libXi freeglut ]);
-
   enableParallelBuilding = true;
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "A C++ cross-platform lightweight GUI library";
     homepage = http://www.fltk.org;
-    platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
-    license = stdenv.lib.licenses.gpl2;
+    platforms = platforms.linux ++ platforms.darwin;
+    license = licenses.gpl2;
   };
-
 }
diff --git a/pkgs/development/libraries/fmt/default.nix b/pkgs/development/libraries/fmt/default.nix
index 6974adf74ce..2cfc87d6a2e 100644
--- a/pkgs/development/libraries/fmt/default.nix
+++ b/pkgs/development/libraries/fmt/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, fetchpatch, cmake, enableShared ? true }:
+{ stdenv, fetchFromGitHub, cmake, enableShared ? true }:
 
 stdenv.mkDerivation rec {
   version = "5.3.0";
diff --git a/pkgs/development/libraries/folly/default.nix b/pkgs/development/libraries/folly/default.nix
index 00ac6abbc8e..a2c3d41d35d 100644
--- a/pkgs/development/libraries/folly/default.nix
+++ b/pkgs/development/libraries/folly/default.nix
@@ -1,15 +1,15 @@
 { stdenv, fetchFromGitHub, cmake, boost, libevent, double-conversion, glog
-, google-gflags, libiberty, openssl }:
+, gflags, libiberty, openssl }:
 
 stdenv.mkDerivation rec {
   name = "folly-${version}";
-  version = "2019.05.27.00";
+  version = "2019.08.05.00";
 
   src = fetchFromGitHub {
     owner = "facebook";
     repo = "folly";
     rev = "v${version}";
-    sha256 = "00xacaziqllps069xzg7iz68rj5hr8mj3rbi4shkrr9jq51y9ikj";
+    sha256 = "03arl9hg06rzbyaf3fzyk7q8d5mfbzfwmhqnfnvqcgzlqdj0gaa5";
   };
 
   nativeBuildInputs = [ cmake ];
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
     boost
     double-conversion
     glog
-    google-gflags
+    gflags
     libevent
     libiberty
     openssl
diff --git a/pkgs/development/libraries/freetds/default.nix b/pkgs/development/libraries/freetds/default.nix
index d8bb9e8e85b..ee63ce2f2f9 100644
--- a/pkgs/development/libraries/freetds/default.nix
+++ b/pkgs/development/libraries/freetds/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   version = "1.1.6";
 
   src = fetchurl {
-    url    = "http://www.freetds.org/files/stable/${name}.tar.bz2";
+    url    = "https://www.freetds.org/files/stable/${name}.tar.bz2";
     sha256 = "18rry59npbhxpzjb0l3ib7zlnlzj43srb5adcm65wyklklsh0gn2";
   };
 
diff --git a/pkgs/development/libraries/freetype/default.nix b/pkgs/development/libraries/freetype/default.nix
index 4658ac049df..eb26a241d1c 100644
--- a/pkgs/development/libraries/freetype/default.nix
+++ b/pkgs/development/libraries/freetype/default.nix
@@ -14,7 +14,7 @@ let
 
 in stdenv.mkDerivation rec {
   pname = "freetype";
-  version = "2.10.0";
+  version = "2.10.1";
 
   meta = with stdenv.lib; {
     description = "A font rendering engine";
@@ -32,11 +32,12 @@ in stdenv.mkDerivation rec {
   };
 
   src = fetchurl {
-    url = "mirror://savannah/${pname}/${pname}-${version}.tar.bz2";
-    sha256 = "01mybx78n3n9dhzylbrdy42wxdwfn8rp514qdkzjy6b5ij965k7w";
+    url = "mirror://savannah/${pname}/${pname}-${version}.tar.xz";
+    sha256 = "0vx2dg1jh5kq34dd6ifpjywkpapp8a7p1bvyq9yq5zi1i94gmnqn";
   };
 
   propagatedBuildInputs = [ zlib bzip2 libpng ]; # needed when linking against freetype
+
   # dependence on harfbuzz is looser than the reverse dependence
   nativeBuildInputs = [ pkgconfig which makeWrapper ]
     # FreeType requires GNU Make, which is not part of stdenv on FreeBSD.
diff --git a/pkgs/development/libraries/g2o/default.nix b/pkgs/development/libraries/g2o/default.nix
index 1486b5bfc55..909c504870f 100644
--- a/pkgs/development/libraries/g2o/default.nix
+++ b/pkgs/development/libraries/g2o/default.nix
@@ -1,4 +1,5 @@
-{ lib, stdenv, fetchFromGitHub, cmake, eigen, suitesparse }:
+{ lib, stdenv, fetchFromGitHub, cmake, eigen, suitesparse, libGLU, qt5
+, libsForQt5, makeWrapper }:
 
 stdenv.mkDerivation rec {
   pname = "g2o";
@@ -11,8 +12,33 @@ stdenv.mkDerivation rec {
     sha256 = "1rgrz6zxiinrik3lgwgvsmlww1m2fnpjmvcx1mf62xi1s2ma5w2i";
   };
 
-  nativeBuildInputs = [ cmake ];
-  buildInputs = [ eigen suitesparse ];
+  # Removes a reference to gcc that is only used in a debug message
+  patches = [ ./remove-compiler-reference.patch ];
+
+  separateDebugInfo = true;
+
+  nativeBuildInputs = [ cmake makeWrapper ];
+  buildInputs = [ eigen suitesparse libGLU qt5.qtbase libsForQt5.libqglviewer ];
+
+  cmakeFlags = [
+    # Detection script is broken
+    "-DQGLVIEWER_INCLUDE_DIR=${libsForQt5.libqglviewer}/include/QGLViewer"
+    "-DG2O_BUILD_EXAMPLES=OFF"
+  ] ++ lib.optionals stdenv.isx86_64 ([ "-DDO_SSE_AUTODETECT=OFF" ] ++ {
+    "default"        = [ "-DDISABLE_SSE3=ON" "-DDISABLE_SSE4_1=ON" "-DDISABLE_SSE4_2=ON" "-DDISABLE_SSE4_A=ON" ];
+    "westmere"       = [                                                                 "-DDISABLE_SSE4_A=ON" ];
+    "sandybridge"    = [                                                                 "-DDISABLE_SSE4_A=ON" ];
+    "ivybridge"      = [                                                                 "-DDISABLE_SSE4_A=ON" ];
+    "haswell"        = [                                                                 "-DDISABLE_SSE4_A=ON" ];
+    "broadwell"      = [                                                                 "-DDISABLE_SSE4_A=ON" ];
+    "skylake"        = [                                                                 "-DDISABLE_SSE4_A=ON" ];
+    "skylake-avx512" = [                                                                 "-DDISABLE_SSE4_A=ON" ];
+  }.${stdenv.hostPlatform.platform.gcc.arch or "default"});
+
+  postInstall = ''
+    wrapProgram $out/bin/g2o_viewer \
+      --prefix QT_PLUGIN_PATH : "${qt5.qtbase}/${qt5.qtbase.qtPluginPrefix}"
+  '';
 
   meta = {
     description = "A General Framework for Graph Optimization";
diff --git a/pkgs/development/libraries/g2o/remove-compiler-reference.patch b/pkgs/development/libraries/g2o/remove-compiler-reference.patch
new file mode 100644
index 00000000000..347c5780240
--- /dev/null
+++ b/pkgs/development/libraries/g2o/remove-compiler-reference.patch
@@ -0,0 +1,25 @@
+From b9bfed09e4e3c481b7eb36bee1ff4202ccf69dee Mon Sep 17 00:00:00 2001
+From: Ben Wolsieffer <benwolsieffer@gmail.com>
+Date: Fri, 17 May 2019 19:05:36 -0400
+Subject: [PATCH] Remove reference to compiler.
+
+---
+ CMakeLists.txt | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index a3f66dd..bb05bd0 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -371,7 +371,7 @@ set(G2O_HAVE_CHOLMOD ${CHOLMOD_FOUND})
+ set(G2O_HAVE_CSPARSE ${CSPARSE_FOUND})
+ set(G2O_SHARED_LIBS ${BUILD_SHARED_LIBS})
+ set(G2O_LGPL_SHARED_LIBS ${BUILD_LGPL_SHARED_LIBS})
+-set(G2O_CXX_COMPILER "${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER}")
++set(G2O_CXX_COMPILER "${CMAKE_CXX_COMPILER_ID} unknown")
+ 
+ configure_file(config.h.in "${PROJECT_BINARY_DIR}/g2o/config.h")
+ install(FILES ${PROJECT_BINARY_DIR}/g2o/config.h DESTINATION ${INCLUDES_DESTINATION}/g2o)
+-- 
+2.21.0
+
diff --git a/pkgs/development/libraries/gcr/default.nix b/pkgs/development/libraries/gcr/default.nix
index 693fda99759..dcb4df1419e 100644
--- a/pkgs/development/libraries/gcr/default.nix
+++ b/pkgs/development/libraries/gcr/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, pkgconfig, intltool, gnupg, p11-kit, glib
-, libgcrypt, libtasn1, dbus-glib, gtk3, pango, gdk_pixbuf, atk
+, libgcrypt, libtasn1, dbus-glib, gtk3, pango, gdk-pixbuf, atk
 , gobject-introspection, makeWrapper, libxslt, vala, gnome3
 , python2 }:
 
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
   buildInputs = let
     gpg = gnupg.override { guiSupport = false; }; # prevent build cycle with pinentry_gnome
   in [
-    gpg libgcrypt libtasn1 dbus-glib pango gdk_pixbuf atk
+    gpg libgcrypt libtasn1 dbus-glib pango gdk-pixbuf atk
   ];
 
   propagatedBuildInputs = [ glib gtk3 p11-kit ];
@@ -45,5 +45,17 @@ stdenv.mkDerivation rec {
   meta = with stdenv.lib; {
     platforms = platforms.linux;
     maintainers = gnome3.maintainers;
+    description = "GNOME crypto services (daemon and tools)";
+    homepage    = https://gitlab.gnome.org/GNOME/gcr;
+    license     = licenses.gpl2;
+
+    longDescription = ''
+      GCR is a library for displaying certificates, and crypto UI, accessing
+      key stores. It also provides the viewer for crypto files on the GNOME
+      desktop.
+
+      GCK is a library for accessing PKCS#11 modules like smart cards, in a
+      (G)object oriented way.
+    '';
   };
 }
diff --git a/pkgs/development/libraries/gdal/001.3_0_1.darwin.patch b/pkgs/development/libraries/gdal/001.3_0_1.darwin.patch
new file mode 100644
index 00000000000..3d34f689120
--- /dev/null
+++ b/pkgs/development/libraries/gdal/001.3_0_1.darwin.patch
@@ -0,0 +1,29 @@
+diff a/swig/python/setup.py b/swig/python/setup.py
+--- a/swig/python/setup.py
++++ b/swig/python/setup.py
+@@ -268,17 +268,17 @@ class gdal_ext(build_ext):
+                     if ext.name != 'osgeo._gdalconst':
+                         ext.extra_compile_args += [cxx11_flag]
+ 
+-        # Adding arch flags here if OS X and compiler is clang
+-        if sys.platform == 'darwin' and [int(x) for x in os.uname()[2].split('.')] >= [11, 0, 0]:
+-            # since MacOS X 10.9, clang no longer accepts -mno-fused-madd
+-            # extra_compile_args.append('-Qunused-arguments')
+-            clang_flag = '-Wno-error=unused-command-line-argument-hard-error-in-future'
+-            if has_flag(self.compiler, clang_flag): 
+-                ext.extra_compile_args += [clang_flag]
+-            else:
+-                clang_flag = '-Wno-error=unused-command-line-argument'
+-                if has_flag(self.compiler, clang_flag):
+-                    ext.extra_compile_args += [clang_flag]
++                    # Adding arch flags here if OS X and compiler is clang
++                    if sys.platform == 'darwin' and [int(x) for x in os.uname()[2].split('.')] >= [11, 0, 0]:
++                        # since MacOS X 10.9, clang no longer accepts -mno-fused-madd
++                        # extra_compile_args.append('-Qunused-arguments')
++                        clang_flag = '-Wno-error=unused-command-line-argument-hard-error-in-future'
++                        if has_flag(self.compiler, clang_flag): 
++                            ext.extra_compile_args += [clang_flag]
++                        else:
++                            clang_flag = '-Wno-error=unused-command-line-argument'
++                            if has_flag(self.compiler, clang_flag):
++                                ext.extra_compile_args += [clang_flag]
diff --git a/pkgs/development/libraries/gdal/2.4.0.nix b/pkgs/development/libraries/gdal/2.4.0.nix
new file mode 100644
index 00000000000..14113d8b87e
--- /dev/null
+++ b/pkgs/development/libraries/gdal/2.4.0.nix
@@ -0,0 +1,95 @@
+{ stdenv, fetchurl, fetchpatch, unzip, libjpeg, libtiff, zlib
+, postgresql, mysql, libgeotiff, pythonPackages, proj, geos, openssl
+, libpng, sqlite, libspatialite, poppler, hdf4, qhull, giflib, expat
+, libiconv, libxml2
+, netcdfSupport ? true, netcdf, hdf5, curl
+}:
+
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+  name = "gdal-${version}";
+  version = "2.4.0";
+
+  src = fetchurl {
+    url = "https://download.osgeo.org/gdal/${version}/${name}.tar.xz";
+    sha256 = "09qgy36z0jc9w05373m4n0vm4j54almdzql6z9p9zr9pdp61syf3";
+  };
+
+  buildInputs = [ unzip libjpeg libtiff libgeotiff libpng proj openssl sqlite
+    libspatialite poppler hdf4 qhull giflib expat libxml2 proj ]
+  ++ (with pythonPackages; [ python numpy wrapPython ])
+  ++ stdenv.lib.optional stdenv.isDarwin libiconv
+  ++ stdenv.lib.optionals netcdfSupport [ netcdf hdf5 curl ];
+
+  configureFlags = [
+    "--with-expat=${expat.dev}"
+    "--with-jpeg=${libjpeg.dev}"
+    "--with-libtiff=${libtiff.dev}" # optional (without largetiff support)
+    "--with-png=${libpng.dev}"      # optional
+    "--with-poppler=${poppler.dev}" # optional
+    "--with-libz=${zlib.dev}"       # optional
+    "--with-pg=${postgresql}/bin/pg_config"
+    "--with-mysql=${mysql.connector-c or mysql}/bin/mysql_config"
+    "--with-geotiff=${libgeotiff.dev}"
+    "--with-sqlite3=${sqlite.dev}"
+    "--with-spatialite=${libspatialite}"
+    "--with-python"               # optional
+    "--with-proj=${proj.dev}" # optional
+    "--with-geos=${geos}/bin/geos-config"# optional
+    "--with-hdf4=${hdf4.dev}" # optional
+    "--with-xml2=${libxml2.dev}/bin/xml2-config" # optional
+    (if netcdfSupport then "--with-netcdf=${netcdf}" else "")
+  ];
+
+  hardeningDisable = [ "format" ];
+
+  CXXFLAGS = "-fpermissive";
+
+  postPatch = ''
+    sed -i '/ifdef bool/i\
+      #ifdef swap\
+      #undef swap\
+      #endif' ogr/ogrsf_frmts/mysql/ogr_mysql.h
+    # poppler 0.73.0 support
+    patch -lp2 <${
+      fetchpatch {
+        url = "https://github.com/OSGeo/gdal/commit/29f4dfbcac2de718043f862166cd639ab578b552.diff";
+        sha256 = "1h2rsjjrgwqfgqzppmzv5jgjs1dbbg8pvfmay0j9y0618qp3r734";
+      }
+    } || true
+    patch -p2 <${
+      fetchpatch {
+        url = "https://github.com/OSGeo/gdal/commit/19967e682738977e11e1d0336e0178882c39cad2.diff";
+        sha256 = "12yqd77226i6xvzgqmxiac5ghdinixh8k2crg1r2gnhc0xlc3arj";
+      }
+    }
+  '';
+
+  # - Unset CC and CXX as they confuse libtool.
+  # - teach gdal that libdf is the legacy name for libhdf
+  preConfigure = ''
+      unset CC CXX
+      substituteInPlace configure \
+      --replace "-lmfhdf -ldf" "-lmfhdf -lhdf"
+    '';
+
+  preBuild = ''
+    substituteInPlace swig/python/GNUmakefile \
+      --replace "ifeq (\$(STD_UNIX_LAYOUT),\"TRUE\")" "ifeq (1,1)"
+  '';
+
+  postInstall = ''
+    wrapPythonPrograms
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "Translator library for raster geospatial data formats";
+    homepage = https://www.gdal.org/;
+    license = stdenv.lib.licenses.mit;
+    maintainers = [ stdenv.lib.maintainers.marcweber ];
+    platforms = with stdenv.lib.platforms; linux ++ darwin;
+  };
+}
diff --git a/pkgs/development/libraries/gdal/default.nix b/pkgs/development/libraries/gdal/default.nix
index e7ffdde6cb1..0db16e2efe3 100644
--- a/pkgs/development/libraries/gdal/default.nix
+++ b/pkgs/development/libraries/gdal/default.nix
@@ -1,7 +1,7 @@
-{ stdenv, fetchurl, fetchpatch, unzip, libjpeg, libtiff, zlib
+{ stdenv, fetchFromGitHub, fetchpatch, unzip, libjpeg, libtiff, zlib
 , postgresql, mysql, libgeotiff, pythonPackages, proj, geos, openssl
 , libpng, sqlite, libspatialite, poppler, hdf4, qhull, giflib, expat
-, libiconv, libxml2
+, libiconv, libxml2, autoreconfHook
 , netcdfSupport ? true, netcdf, hdf5, curl
 }:
 
@@ -9,15 +9,23 @@ with stdenv.lib;
 
 stdenv.mkDerivation rec {
   name = "gdal-${version}";
-  version = "2.4.0";
+  version = "3.0.1";
 
-  src = fetchurl {
-    url = "https://download.osgeo.org/gdal/${version}/${name}.tar.xz";
-    sha256 = "09qgy36z0jc9w05373m4n0vm4j54almdzql6z9p9zr9pdp61syf3";
+  src = fetchFromGitHub {
+    owner = "OSGeo";
+    repo = "gdal";
+    rev = "v${version}";
+    sha256 = "04rraqhygv8b8fy87qvdhkgx87whby9n98p3gxqr7kdrfymwnh8l";
   };
 
+  sourceRoot = "source/gdal";
+
+  patches = [ ./001.3_0_1.darwin.patch ];
+
+  nativeBuildInputs = [ autoreconfHook ];
+
   buildInputs = [ unzip libjpeg libtiff libpng proj openssl sqlite
-    libspatialite poppler hdf4 qhull giflib expat libxml2 ]
+    libspatialite libgeotiff poppler hdf4 qhull giflib expat libxml2 ]
   ++ (with pythonPackages; [ python numpy wrapPython ])
   ++ stdenv.lib.optional stdenv.isDarwin libiconv
   ++ stdenv.lib.optionals netcdfSupport [ netcdf hdf5 curl ];
@@ -35,7 +43,7 @@ stdenv.mkDerivation rec {
     "--with-sqlite3=${sqlite.dev}"
     "--with-spatialite=${libspatialite}"
     "--with-python"               # optional
-    "--with-proj=${proj}" # optional
+    "--with-proj=${proj.dev}" # optional
     "--with-geos=${geos}/bin/geos-config"# optional
     "--with-hdf4=${hdf4.dev}" # optional
     "--with-xml2=${libxml2.dev}/bin/xml2-config" # optional
@@ -46,31 +54,9 @@ stdenv.mkDerivation rec {
 
   CXXFLAGS = "-fpermissive";
 
-  postPatch = ''
-    sed -i '/ifdef bool/i\
-      #ifdef swap\
-      #undef swap\
-      #endif' ogr/ogrsf_frmts/mysql/ogr_mysql.h
-
-    # poppler 0.73.0 support
-    patch -lp2 <${
-      fetchpatch {
-        url = "https://github.com/OSGeo/gdal/commit/29f4dfbcac2de718043f862166cd639ab578b552.diff";
-        sha256 = "1h2rsjjrgwqfgqzppmzv5jgjs1dbbg8pvfmay0j9y0618qp3r734";
-      }
-    } || true
-    patch -p2 <${
-      fetchpatch {
-        url = "https://github.com/OSGeo/gdal/commit/19967e682738977e11e1d0336e0178882c39cad2.diff";
-        sha256 = "12yqd77226i6xvzgqmxiac5ghdinixh8k2crg1r2gnhc0xlc3arj";
-      }
-    }
-  '';
-
   # - Unset CC and CXX as they confuse libtool.
   # - teach gdal that libdf is the legacy name for libhdf
   preConfigure = ''
-      unset CC CXX
       substituteInPlace configure \
       --replace "-lmfhdf -ldf" "-lmfhdf -lhdf"
     '';
diff --git a/pkgs/development/libraries/gdal/gdal-1_11.nix b/pkgs/development/libraries/gdal/gdal-1_11.nix
index 32101221e64..40308a95791 100644
--- a/pkgs/development/libraries/gdal/gdal-1_11.nix
+++ b/pkgs/development/libraries/gdal/gdal-1_11.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
     sha256 = "0hphxzvy23v3vqxx1y22hhhg4cypihrb8555y12nb4mrhzlw7zfl";
   };
 
-  buildInputs = [ unzip libjpeg libtiff libpng python pythonPackages.numpy proj openssl ];
+  buildInputs = [ unzip libjpeg libtiff libgeotiff libpng python pythonPackages.numpy proj openssl ];
 
   patches = [
     # This ensures that the python package is installed into gdal's prefix,
@@ -33,12 +33,17 @@ stdenv.mkDerivation rec {
 
     "--with-pg=${postgresql}/bin/pg_config"
     "--with-mysql=${mysql57.connector-c}/bin/mysql_config"
-    "--with-geotiff=${libgeotiff}"
+    "--with-geotiff=${libgeotiff.dev}"
     "--with-python"               # optional
     "--with-static-proj4=${proj}" # optional
     "--with-geos=${geos}/bin/geos-config"# optional
   ];
 
+  # Allow use of old proj_api.h
+  NIX_CFLAGS_COMPILE = [
+    "-DACCEPT_USE_OF_DEPRECATED_PROJ_API_H=1"
+  ];
+
   # Prevent this:
   #
   #   Checking .pth file support in /nix/store/xkrmb8xnvqxzjwsdmasqmsdh1a5y2y99-gdal-1.11.2/lib/python2.7/site-packages/
diff --git a/pkgs/development/libraries/gdcm/default.nix b/pkgs/development/libraries/gdcm/default.nix
index fca567d683d..fa99dbe1d9f 100644
--- a/pkgs/development/libraries/gdcm/default.nix
+++ b/pkgs/development/libraries/gdcm/default.nix
@@ -1,12 +1,12 @@
-{ stdenv, fetchurl, cmake, vtk }:
+{ stdenv, fetchurl, cmake, vtk, darwin }:
 
 stdenv.mkDerivation rec {
-  version = "3.0.0";
+  version = "3.0.1";
   name = "gdcm-${version}";
 
   src = fetchurl {
     url = "mirror://sourceforge/gdcm/${name}.tar.bz2";
-    sha256 = "1rhblnl0q4bl3hmanz4ckv5kzdrzdiqp9xlcqh8df3rfrgk4d81x";
+    sha256 = "1n206rr28f9ysd5yns6hc6vxwhwj1ck59p2j1wqyclm60zr84isq";
   };
 
   dontUseCmakeBuildDir = true;
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
   '';
 
   enableParallelBuilding = true;
-  buildInputs = [ cmake vtk ];
+  buildInputs = [ cmake vtk ] ++ stdenv.lib.optional stdenv.isDarwin [ darwin.apple_sdk.frameworks.ApplicationServices darwin.apple_sdk.frameworks.Cocoa ];
   propagatedBuildInputs = [ ];
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/gdk-pixbuf/default.nix b/pkgs/development/libraries/gdk-pixbuf/default.nix
index d98d9e8107e..59e7808057f 100644
--- a/pkgs/development/libraries/gdk-pixbuf/default.nix
+++ b/pkgs/development/libraries/gdk-pixbuf/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, fixDarwinDylibNames, meson, ninja, pkgconfig, gettext, python3, libxml2, libxslt, docbook_xsl
+{ stdenv, fetchurl, fixDarwinDylibNames, meson, ninja, pkgconfig, gettext, python3, libxml2, libxslt, docbook_xsl
 , docbook_xml_dtd_43, gtk-doc, glib, libtiff, libjpeg, libpng, libX11, gnome3
 , jasper, gobject-introspection, doCheck ? false, makeWrapper }:
 
@@ -83,7 +83,6 @@ in stdenv.mkDerivation rec {
   passthru = {
     updateScript = gnome3.updateScript {
       packageName = pname;
-      attrPath = "gdk_pixbuf";
     };
 
     # gdk_pixbuf_moduledir variable from gdk-pixbuf-2.0.pc
diff --git a/pkgs/development/libraries/gegl/4.0.nix b/pkgs/development/libraries/gegl/4.0.nix
index 4215f0ebc30..0e3f79b1814 100644
--- a/pkgs/development/libraries/gegl/4.0.nix
+++ b/pkgs/development/libraries/gegl/4.0.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, pkgconfig, glib, babl, libpng, cairo, libjpeg, which
 , librsvg, pango, gtk, bzip2, json-glib, gettext, autoreconfHook, libraw
-, gexiv2, libwebp, gnome3, libintl }:
+, gexiv2, libwebp, libintl }:
 
 stdenv.mkDerivation rec {
   pname = "gegl";
diff --git a/pkgs/development/libraries/geis/default.nix b/pkgs/development/libraries/geis/default.nix
index e1f243f8fd3..4b9f67b7aaf 100644
--- a/pkgs/development/libraries/geis/default.nix
+++ b/pkgs/development/libraries/geis/default.nix
@@ -6,7 +6,7 @@
 , dbus
 , evemu
 , frame
-, gdk_pixbuf
+, gdk-pixbuf
 , gobject-introspection
 , grail
 , gtk3
@@ -37,7 +37,7 @@ stdenv.mkDerivation rec {
     [ pygobject3  ];
 
   nativeBuildInputs = [ pkgconfig wrapGAppsHook python3Packages.wrapPython];
-  buildInputs = [ atk dbus evemu frame gdk_pixbuf gobject-introspection grail
+  buildInputs = [ atk dbus evemu frame gdk-pixbuf gobject-introspection grail
     gtk3 libX11 libXext libXi libXtst pango python3Packages.python xorgserver
   ];
 
diff --git a/pkgs/development/libraries/geoclue/default.nix b/pkgs/development/libraries/geoclue/default.nix
index 6a44f01d011..cc2037791e0 100644
--- a/pkgs/development/libraries/geoclue/default.nix
+++ b/pkgs/development/libraries/geoclue/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitLab, intltool, meson, ninja, pkgconfig, gtk-doc, docbook_xsl, docbook_xml_dtd_412, glib, json-glib, libsoup, libnotify, gdk_pixbuf
+{ stdenv, fetchFromGitLab, intltool, meson, ninja, pkgconfig, gtk-doc, docbook_xsl, docbook_xml_dtd_412, glib, json-glib, libsoup, libnotify, gdk-pixbuf
 , modemmanager, avahi, glib-networking, python3, wrapGAppsHook, gobject-introspection, vala
 , withDemoAgent ? false
 }:
@@ -32,7 +32,7 @@ stdenv.mkDerivation rec {
   buildInputs = [
     glib json-glib libsoup avahi
   ] ++ optionals withDemoAgent [
-    libnotify gdk_pixbuf
+    libnotify gdk-pixbuf
   ] ++ optionals (!stdenv.isDarwin) [ modemmanager ];
 
   propagatedBuildInputs = [ glib glib-networking ];
@@ -58,7 +58,7 @@ stdenv.mkDerivation rec {
   meta = with stdenv.lib; {
     description = "Geolocation framework and some data providers";
     homepage = https://gitlab.freedesktop.org/geoclue/geoclue/wikis/home;
-    maintainers = with maintainers; [ raskin garbas ];
+    maintainers = with maintainers; [ raskin ];
     platforms = with platforms; linux ++ darwin;
     license = licenses.lgpl2;
   };
diff --git a/pkgs/development/libraries/gfbgraph/default.nix b/pkgs/development/libraries/gfbgraph/default.nix
index 1bdcb7d8b28..235cd195071 100644
--- a/pkgs/development/libraries/gfbgraph/default.nix
+++ b/pkgs/development/libraries/gfbgraph/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, glib, librest
+{ stdenv, fetchurl, pkgconfig, glib, librest, gnome-online-accounts
 , gnome3, libsoup, json-glib, gobject-introspection }:
 
 stdenv.mkDerivation rec {
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ pkgconfig gobject-introspection ];
-  buildInputs = [ glib gnome3.gnome-online-accounts ];
+  buildInputs = [ glib gnome-online-accounts ];
   propagatedBuildInputs = [ libsoup json-glib librest ];
 
   configureFlags = [ "--enable-introspection" ];
diff --git a/pkgs/development/libraries/google-gflags/default.nix b/pkgs/development/libraries/gflags/default.nix
index fefc3a8b4b8..2e818ea94ea 100644
--- a/pkgs/development/libraries/google-gflags/default.nix
+++ b/pkgs/development/libraries/gflags/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchFromGitHub, cmake }:
 
 stdenv.mkDerivation rec {
-  name = "google-gflags-${version}";
+  pname = "gflags";
   version = "2.2.2";
 
   src = fetchFromGitHub {
diff --git a/pkgs/development/libraries/git2/0.27.nix b/pkgs/development/libraries/git2/0.27.nix
deleted file mode 100644
index 510f53f24b1..00000000000
--- a/pkgs/development/libraries/git2/0.27.nix
+++ /dev/null
@@ -1,36 +0,0 @@
-{ stdenv, fetchFromGitHub, cmake, pkgconfig, python
-, zlib, libssh2, openssl, http-parser, curl
-, libiconv, Security
-}:
-
-stdenv.mkDerivation rec {
-  version = "0.27.8";
-  name = "libgit2-${version}";
-
-  src = fetchFromGitHub {
-    owner = "libgit2";
-    repo = "libgit2";
-    rev = "v${version}";
-    sha256 = "0wzx8nkyy9m7mx6cks58chjd4289vjsw97mxm9w6f1ggqsfnmbr9";
-  };
-
-  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;
-
-  doCheck = false; # hangs. or very expensive?
-
-  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 358fc31fc80..514d21def1e 100644
--- a/pkgs/development/libraries/git2/default.nix
+++ b/pkgs/development/libraries/git2/default.nix
@@ -1,18 +1,18 @@
-{ stdenv, fetchFromGitHub, pkgconfig, cmake
-, zlib, python, libssh2, openssl, curl, http-parser
+{ stdenv, fetchFromGitHub, cmake, pkgconfig, python
+, zlib, libssh2, openssl, http-parser, curl
 , libiconv, Security
 }:
 
-stdenv.mkDerivation (rec {
-  name = "libgit2-${version}";
-  version = "0.26.6";
+stdenv.mkDerivation rec {
+  pname = "libgit2";
+  version = "0.27.8";
   # keep the version in sync with pythonPackages.pygit2 and libgit2-glib
 
   src = fetchFromGitHub {
     owner = "libgit2";
     repo = "libgit2";
     rev = "v${version}";
-    sha256 = "17pjvprmdrx4h6bb1hhc98w9qi6ki7yl57f090n9kbhswxqfs7s3";
+    sha256 = "0wzx8nkyy9m7mx6cks58chjd4289vjsw97mxm9w6f1ggqsfnmbr9";
   };
 
   cmakeFlags = [ "-DTHREADSAFE=ON" ];
@@ -22,17 +22,16 @@ stdenv.mkDerivation (rec {
   buildInputs = [ zlib libssh2 openssl http-parser curl ]
     ++ stdenv.lib.optional stdenv.isDarwin Security;
 
-  propagatedBuildInputs = stdenv.lib.optional (!stdenv.isLinux) [ libiconv ];
+  propagatedBuildInputs = stdenv.lib.optional (!stdenv.isLinux) libiconv;
 
   enableParallelBuilding = true;
 
   doCheck = false; # hangs. or very expensive?
 
-  meta = with stdenv.lib; {
+  meta = {
     description = "The Git linkable library";
     homepage = https://libgit2.github.com/;
-    license = licenses.gpl2;
-    platforms = with platforms; all;
+    license = stdenv.lib.licenses.gpl2;
+    platforms = with stdenv.lib.platforms; all;
   };
-} // stdenv.lib.optionalAttrs (!stdenv.isLinux) {
-})
+}
diff --git a/pkgs/development/libraries/givaro/default.nix b/pkgs/development/libraries/givaro/default.nix
index 0221b9c7013..1a97150aa48 100644
--- a/pkgs/development/libraries/givaro/default.nix
+++ b/pkgs/development/libraries/givaro/default.nix
@@ -2,12 +2,12 @@
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
   pname = "givaro";
-  version = "4.1.0";
+  version = "4.1.1";
   src = fetchFromGitHub {
     owner = "linbox-team";
     repo = "${pname}";
     rev = "v${version}";
-    sha256 = "1l1172c964hni66mjdmhr7766l5k7y63zs3hgcpr10a8f1nx3iwp";
+    sha256 = "11wz57q6ijsvfs5r82masxgr319as92syi78lnl9lgdblpc6xigk";
   };
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/gl2ps/default.nix b/pkgs/development/libraries/gl2ps/default.nix
new file mode 100644
index 00000000000..aadc6986f5a
--- /dev/null
+++ b/pkgs/development/libraries/gl2ps/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl, cmake
+, zlib, libGL, libGLU, libpng, freeglut }:
+
+stdenv.mkDerivation rec {
+  version = "1.4.0";
+  name = "gl2ps-${version}";
+
+  src = fetchurl {
+    url = "http://geuz.org/gl2ps/src/${name}.tgz";
+    sha256 = "1qpidkz8x3bxqf69hlhyz1m0jmfi9kq24fxsp7rq6wfqzinmxjq3";
+  };
+
+  buildInputs = [
+    cmake
+    zlib
+    libGL
+    libGLU
+    libpng
+    freeglut
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = http://geuz.org/gl2ps;
+    description = "An OpenGL to PostScript printing library";
+    platforms = platforms.all;
+    license = licenses.lgpl2;
+    maintainers = with maintainers; [raskin twhitehead];
+  };
+}
diff --git a/pkgs/development/libraries/glbinding/default.nix b/pkgs/development/libraries/glbinding/default.nix
index 60778df663a..d12b8a7c11d 100644
--- a/pkgs/development/libraries/glbinding/default.nix
+++ b/pkgs/development/libraries/glbinding/default.nix
@@ -2,13 +2,13 @@
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
   pname = "glbinding";
-  version = "3.0.2";
+  version = "3.1.0";
 
   src = fetchFromGitHub {
     owner = "cginternals";
     repo = pname;
     rev = "v${version}";
-    sha256 = "1lvcps0n0p8gg0p2bkm5aq4b4kv8bvxlaaf4fcham2pgbgzil9d4";
+    sha256 = "1avd7ssms11xx7h0cm8h4pfpk55f07f1j1ybykxfgsym2chb2z08";
   };
 
   buildInputs = [ cmake libGLU xlibsWrapper ];
diff --git a/pkgs/development/libraries/glfw/3.x.nix b/pkgs/development/libraries/glfw/3.x.nix
index 668fe436e91..6944d5b9292 100644
--- a/pkgs/development/libraries/glfw/3.x.nix
+++ b/pkgs/development/libraries/glfw/3.x.nix
@@ -1,5 +1,5 @@
 { stdenv, lib, fetchFromGitHub, cmake, libGL, libXrandr, libXinerama, libXcursor, libX11
-, cf-private, Cocoa, Kernel, fixDarwinDylibNames
+, Cocoa, Kernel, fixDarwinDylibNames
 }:
 
 stdenv.mkDerivation rec {
@@ -19,13 +19,8 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake ];
 
-  buildInputs = [
-    libX11 libXrandr libXinerama libXcursor
-  ] ++ lib.optionals stdenv.isDarwin [
-    Cocoa Kernel fixDarwinDylibNames
-    # Needed for NSDefaultRunLoopMode symbols.
-    cf-private
-  ];
+  buildInputs = [ libX11 libXrandr libXinerama libXcursor ]
+    ++ lib.optionals stdenv.isDarwin [ Cocoa Kernel fixDarwinDylibNames ];
 
   cmakeFlags = [ "-DBUILD_SHARED_LIBS=ON" ];
 
@@ -35,7 +30,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "Multi-platform library for creating OpenGL contexts and managing input, including keyboard, mouse, joystick and time";
-    homepage = http://www.glfw.org/;
+    homepage = https://www.glfw.org/;
     license = licenses.zlib;
     maintainers = with maintainers; [ marcweber ];
     platforms = platforms.unix;
diff --git a/pkgs/development/libraries/glib-networking/default.nix b/pkgs/development/libraries/glib-networking/default.nix
index a51183e4e11..4f853e9821f 100644
--- a/pkgs/development/libraries/glib-networking/default.nix
+++ b/pkgs/development/libraries/glib-networking/default.nix
@@ -3,14 +3,14 @@
 
 let
   pname = "glib-networking";
-  version = "2.60.2";
+  version = "2.60.3";
 in
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
 
   src = fetchurl {
     url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${name}.tar.xz";
-    sha256 = "0cl74q7hvq4xqqc88vlzmfw1sh5n9hdh1yvn2v1vg9am1z8z68n0";
+    sha256 = "1mfw44qpmwvz6yzj8c6spx6z357wrmkk15byrkc5byagd82860fm";
   };
 
   outputs = [ "out" "dev" ]; # to deal with propagatedBuildInputs
diff --git a/pkgs/development/libraries/glib/default.nix b/pkgs/development/libraries/glib/default.nix
index a2c7bdc5bde..ecbcbea1394 100644
--- a/pkgs/development/libraries/glib/default.nix
+++ b/pkgs/development/libraries/glib/default.nix
@@ -1,4 +1,4 @@
-{ config, stdenv, fetchurl, fetchpatch, gettext, meson, ninja, pkgconfig, perl, python3, glibcLocales
+{ config, stdenv, fetchurl, gettext, meson, ninja, pkgconfig, perl, python3, glibcLocales
 , libiconv, zlib, libffi, pcre, libelf, gnome3, libselinux, bash, gnum4, gtk-doc, docbook_xsl, docbook_xml_dtd_45
 # use utillinuxMinimal to avoid circular dependency (utillinux, systemd, glib)
 , utillinuxMinimal ? null
@@ -46,7 +46,7 @@ let
   '';
 
   binPrograms = optional (!stdenv.isDarwin) "gapplication" ++ [ "gdbus" "gio" "gsettings" ];
-  version = "2.60.3";
+  version = "2.60.4";
 in
 
 stdenv.mkDerivation rec {
@@ -54,7 +54,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "mirror://gnome/sources/glib/${stdenv.lib.versions.majorMinor version}/${name}.tar.xz";
-    sha256 = "1fb0nx9fcmic8rsh0fbp79lqpasfjxljvnshbw2hsya51mb0vaq4";
+    sha256 = "1p9k8z83272mkm4d4fhm5jhwhyw2basrwbz47yl5wbmrvk2ix51b";
   };
 
   patches = optional stdenv.isDarwin ./darwin-compilation.patch
@@ -81,9 +81,6 @@ stdenv.mkDerivation rec {
     utillinuxMinimal # for libmount
   ] ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
     AppKit Carbon Cocoa CoreFoundation CoreServices Foundation
-    # Needed for CFURLCreateFromFSRef, etc. which have deen deprecated
-    # since 10.9 and are not part of swift-corelibs CoreFoundation.
-    darwin.cf-private
   ]);
 
   nativeBuildInputs = [
diff --git a/pkgs/development/libraries/globalplatform/default.nix b/pkgs/development/libraries/globalplatform/default.nix
index 3ef279616f7..f01fb13c3c3 100644
--- a/pkgs/development/libraries/globalplatform/default.nix
+++ b/pkgs/development/libraries/globalplatform/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, zlib, openssl, pcsclite }:
+{ stdenv, fetchurl, pkgconfig, zlib, openssl_1_0_2, pcsclite }:
 
 stdenv.mkDerivation rec {
   name = "globalplatform-${version}";
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ zlib openssl pcsclite ];
+  buildInputs = [ zlib openssl_1_0_2 pcsclite ];
 
   meta = with stdenv.lib; {
     homepage = https://sourceforge.net/p/globalplatform/wiki/Home/;
diff --git a/pkgs/development/libraries/globalplatform/gppcscconnectionplugin.nix b/pkgs/development/libraries/globalplatform/gppcscconnectionplugin.nix
index 10df82196c2..87addaa9991 100644
--- a/pkgs/development/libraries/globalplatform/gppcscconnectionplugin.nix
+++ b/pkgs/development/libraries/globalplatform/gppcscconnectionplugin.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, globalplatform, openssl, pcsclite }:
+{ stdenv, fetchurl, pkgconfig, globalplatform, openssl_1_0_2, pcsclite }:
 
 stdenv.mkDerivation rec {
   name = "gppcscconnectionplugin-${version}";
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ globalplatform openssl pcsclite ];
+  buildInputs = [ globalplatform openssl_1_0_2 pcsclite ];
 
   meta = with stdenv.lib; {
     homepage = https://sourceforge.net/p/globalplatform/wiki/Home/;
diff --git a/pkgs/development/libraries/gmp/5.1.x.nix b/pkgs/development/libraries/gmp/5.1.x.nix
index 43b8434b496..494d9acb6bb 100644
--- a/pkgs/development/libraries/gmp/5.1.x.nix
+++ b/pkgs/development/libraries/gmp/5.1.x.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, m4, cxx ? true, withStatic ? true }:
 
-let inherit (stdenv.lib) optional optionalString; in
+let inherit (stdenv.lib) optional; in
 
 let self = stdenv.mkDerivation rec {
   name = "gmp-5.1.3";
diff --git a/pkgs/development/libraries/gmp/6.x.nix b/pkgs/development/libraries/gmp/6.x.nix
index f320c303123..de31128e5a6 100644
--- a/pkgs/development/libraries/gmp/6.x.nix
+++ b/pkgs/development/libraries/gmp/6.x.nix
@@ -3,7 +3,7 @@
 , buildPackages
 , withStatic ? false }:
 
-let inherit (stdenv.lib) optional optionalString; in
+let inherit (stdenv.lib) optional; in
 
 let self = stdenv.mkDerivation rec {
   name = "gmp-6.1.2";
diff --git a/pkgs/development/libraries/gnome-online-accounts/default.nix b/pkgs/development/libraries/gnome-online-accounts/default.nix
new file mode 100644
index 00000000000..9ae4a572d93
--- /dev/null
+++ b/pkgs/development/libraries/gnome-online-accounts/default.nix
@@ -0,0 +1,52 @@
+{ stdenv, fetchurl, pkgconfig, vala, glib, libxslt, gtk3, wrapGAppsHook
+, webkitgtk, json-glib, librest, libsecret, gtk-doc, gobject-introspection
+, gettext, icu, glib-networking, hicolor-icon-theme
+, libsoup, docbook_xsl, docbook_xml_dtd_412, gnome3, gcr, kerberos
+}:
+
+let
+  pname = "gnome-online-accounts";
+  version = "3.32.0";
+in stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${name}.tar.xz";
+    sha256 = "1anlx0rb2hafg9929pgfms25mdz23sd0vdva06h6zlf8f5byc68w";
+  };
+
+  outputs = [ "out" "man" "dev" "devdoc" ];
+
+  configureFlags = [
+    "--enable-media-server"
+    "--enable-kerberos"
+    "--enable-lastfm"
+    "--enable-todoist"
+    "--enable-gtk-doc"
+    "--enable-documentation"
+  ];
+
+  enableParallelBuilding = true;
+
+  nativeBuildInputs = [
+    pkgconfig gobject-introspection vala gettext wrapGAppsHook
+    libxslt docbook_xsl docbook_xml_dtd_412 gtk-doc
+    hicolor-icon-theme # for setup-hook
+  ];
+  buildInputs = [
+    glib gtk3 webkitgtk json-glib librest libsecret glib-networking icu libsoup
+    gcr kerberos
+  ];
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+      attrPath = "gnome3.${pname}";
+    };
+  };
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+  };
+}
diff --git a/pkgs/development/libraries/gnome-sharp/default.nix b/pkgs/development/libraries/gnome-sharp/default.nix
index f2393a23dfe..5e525ad46af 100644
--- a/pkgs/development/libraries/gnome-sharp/default.nix
+++ b/pkgs/development/libraries/gnome-sharp/default.nix
@@ -27,6 +27,8 @@ stdenv.mkDerivation rec {
   buildInputs = [ gtk2 mono gtk-sharp-2_0 ]
   ++ (with gnome2; [ libart_lgpl gnome_vfs libgnome libgnomecanvas libgnomeui ]);
 
+  patches = [ ./fix-mono-path.patch ];
+
   preConfigure = ''
     ./bootstrap-${lib.versions.majorMinor version}
   '';
diff --git a/pkgs/development/libraries/gnome-sharp/fix-mono-path.patch b/pkgs/development/libraries/gnome-sharp/fix-mono-path.patch
new file mode 100644
index 00000000000..706f119c8ba
--- /dev/null
+++ b/pkgs/development/libraries/gnome-sharp/fix-mono-path.patch
@@ -0,0 +1,13 @@
+diff --git a/sample/gconf/Makefile.am b/sample/gconf/Makefile.am
+index a0ee802..8260694 100644
+--- a/sample/gconf/Makefile.am
++++ b/sample/gconf/Makefile.am
+@@ -22,7 +22,7 @@ sample.exe: $(SCHEMA) $(srcdir)/sample.glade $(FILES) $(ASSEMBLIES)
+	$(CSC) /out:sample.exe $(FILES) $(REFERENCES) $(RESOURCES)
+ 
+ Settings.cs: $(SCHEMA)
+-	MONO_PATH=$(top_builddir)/gconf/GConf/gconf-sharp.dll:${MONO_PATH} $(RUNTIME) $(GCONFDIR)/tools/gconfsharp-schemagen.exe Sample $(SCHEMA) > Settings.cs
++	MONO_PATH=$(top_builddir)/gconf/GConf/:${MONO_PATH} $(RUNTIME) $(GCONFDIR)/tools/gconfsharp-schemagen.exe Sample $(SCHEMA) > Settings.cs
+ 
+ CLEANFILES = sample.exe Settings.cs
+
diff --git a/pkgs/development/libraries/gnome-video-effects/default.nix b/pkgs/development/libraries/gnome-video-effects/default.nix
new file mode 100644
index 00000000000..03799c1ef7c
--- /dev/null
+++ b/pkgs/development/libraries/gnome-video-effects/default.nix
@@ -0,0 +1,46 @@
+{ stdenv
+, fetchurl
+, pkgconfig
+, meson
+, ninja
+, gettext
+, gnome3
+}:
+
+stdenv.mkDerivation rec {
+  pname = "gnome-video-effects";
+  version = "0.5.0";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
+    sha256 = "1j6h98whgkcxrh30bwvnxvyqxrxchgpdgqhl0j71xz7x72dqxijd";
+  };
+
+  patches = [
+    # Fix effectsdir in .pc file
+    # https://gitlab.gnome.org/GNOME/gnome-video-effects/commit/955404195ada606819974dd63c48956f25611e14
+    ./fix-pc-file.patch
+  ];
+
+  nativeBuildInputs = [
+    meson
+    ninja
+    pkgconfig
+    gettext
+  ];
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+      versionPolicy = "none";
+    };
+  };
+
+  meta = with stdenv.lib; {
+    description = "A collection of GStreamer effects to be used in different GNOME Modules";
+    homepage = https://wiki.gnome.org/Projects/GnomeVideoEffects;
+    platforms = platforms.linux;
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+  };
+}
diff --git a/pkgs/development/libraries/gnome-video-effects/fix-pc-file.patch b/pkgs/development/libraries/gnome-video-effects/fix-pc-file.patch
new file mode 100644
index 00000000000..62b29e7d025
--- /dev/null
+++ b/pkgs/development/libraries/gnome-video-effects/fix-pc-file.patch
@@ -0,0 +1,11 @@
+--- a/meson.build
++++ b/meson.build
+@@ -17,7 +17,7 @@
+ # Can't use pkgconfig helper https://github.com/mesonbuild/meson/issues/2253
+ conf = configuration_data()
+ conf.set('prefix', prefix)
+-conf.set('datarootdir', pkgdatadir)
++conf.set('datarootdir', datadir)
+ conf.set('VERSION', meson.project_version())
+ 
+ pkg = configure_file(configuration: conf,
diff --git a/pkgs/development/libraries/gnutls/default.nix b/pkgs/development/libraries/gnutls/default.nix
index e0a54052c23..1b17f4c800f 100644
--- a/pkgs/development/libraries/gnutls/default.nix
+++ b/pkgs/development/libraries/gnutls/default.nix
@@ -8,7 +8,7 @@
 
 assert guileBindings -> guile != null;
 let
-  version = "3.6.8";
+  version = "3.6.9";
 
   # XXX: Gnulib's `test-select' fails on FreeBSD:
   # http://hydra.nixos.org/build/2962084/nixlog/1/raw .
@@ -24,7 +24,7 @@ stdenv.mkDerivation {
 
   src = fetchurl {
     url = "mirror://gnupg/gnutls/v3.6/gnutls-${version}.tar.xz";
-    sha256 = "10ry71sy8zbksa905bjryphafcg25gkmfa3pf48ripimar7990da";
+    sha256 = "1jqz5s3lv8sa53348cfi9nr5pw5l55n8m40b8msdvv0pb2jzqca3";
   };
 
   outputs = [ "bin" "dev" "out" "man" "devdoc" ];
diff --git a/pkgs/development/libraries/gobject-introspection/default.nix b/pkgs/development/libraries/gobject-introspection/default.nix
index 26c472930ed..43695d8db58 100644
--- a/pkgs/development/libraries/gobject-introspection/default.nix
+++ b/pkgs/development/libraries/gobject-introspection/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, glib, flex, bison, meson, ninja, pkgconfig, libffi, python3
-, libintl, cctools, cairo, gnome3, glibcLocales, fetchpatch
+, libintl, cctools, cairo, gnome3, glibcLocales
 , substituteAll, nixStoreDir ? builtins.storeDir
 , x11Support ? true
 }:
@@ -9,7 +9,7 @@
 
 let
   pname = "gobject-introspection";
-  version = "1.60.1";
+  version = "1.60.2";
 in
 with stdenv.lib;
 stdenv.mkDerivation rec {
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${name}.tar.xz";
-    sha256 = "1cr4r3lh5alrks9q2ycs1kn2crnkhrhn2wrmibng6dndkr4x2i6q";
+    sha256 = "172ymc1vbg2rclq1rszx4y32vm900nn1mc4qg1a4mqxjiwvf5pzz";
   };
 
   outputs = [ "out" "dev" "man" ];
diff --git a/pkgs/development/libraries/gom/default.nix b/pkgs/development/libraries/gom/default.nix
index 5694c50e90a..9a947c3ff82 100644
--- a/pkgs/development/libraries/gom/default.nix
+++ b/pkgs/development/libraries/gom/default.nix
@@ -7,7 +7,7 @@
 , glib
 , python3
 , sqlite
-, gdk_pixbuf
+, gdk-pixbuf
 , gnome3
 , gobject-introspection
 }:
@@ -45,7 +45,7 @@ stdenv.mkDerivation rec {
   ];
 
   buildInputs = [
-    gdk_pixbuf
+    gdk-pixbuf
     glib
     sqlite
     python3.pkgs.pygobject3
diff --git a/pkgs/development/libraries/google-cloud-cpp/default.nix b/pkgs/development/libraries/google-cloud-cpp/default.nix
new file mode 100644
index 00000000000..7dd075e440e
--- /dev/null
+++ b/pkgs/development/libraries/google-cloud-cpp/default.nix
@@ -0,0 +1,65 @@
+{ stdenv, grpc, curl, cmake, pkgconfig, fetchFromGitHub, doxygen, protobuf, crc32c, c-ares, nlohmann_json, fetchurl }:
+let
+  googleapis_rev = "a8ee1416f4c588f2ab92da72e7c1f588c784d3e6";
+  googleapis = fetchurl {
+    name = "${googleapis_rev}.tar.gz";
+    url = "https://github.com/googleapis/googleapis/archive/${googleapis_rev}.tar.gz";
+    sha256 = "1kxi27r034p7jfldhvgpbn6rqqqddycnja47m6jyjxj4rcmrp2kb";
+  };
+in stdenv.mkDerivation rec {
+  pname = "google-cloud-cpp";
+  version = "0.11.0";
+
+  src = fetchFromGitHub {
+    owner = "googleapis";
+    repo = "google-cloud-cpp";
+    rev = "v${version}";
+    sha256 = "1w942gzyv01ym1cv2a417x92zxra9s2v3xz5crcv84j919f616f8";
+  };
+
+  buildInputs = [ curl grpc protobuf nlohmann_json crc32c c-ares c-ares.cmake-config ];
+  nativeBuildInputs = [ cmake pkgconfig doxygen ];
+
+  outputs = [ "out" "dev" ];
+
+  postPatch = ''
+    NLOHMANN_SHA256=$(sha256sum ${nlohmann_json}/include/nlohmann/json.hpp | cut -f1 -d' ')
+    sed -e 's,https://github.com/nlohmann/json/releases/download/.*,file://${nlohmann_json}/include/nlohmann/json.hpp"),' \
+        -e "s,JSON_SHA256 .*,JSON_SHA256 ''${NLOHMANN_SHA256}," \
+        -i cmake/DownloadNlohmannJson.cmake
+
+    sed -e 's,https://github.com/googleapis/googleapis/archive/${googleapis_rev}.tar.gz,file://${googleapis},' \
+        -i cmake/external/googleapis.cmake
+
+    # Fixup the library path. It would build a path like /build/external//nix/store/…-foo/lib/foo.so for each library instead of /build/external/lib64/foo.so
+    sed -e 's,''${CMAKE_INSTALL_LIBDIR},lib64,g' \
+        -e 's,;lib64,lib,g' \
+        -i cmake/ExternalProjectHelper.cmake
+  '';
+
+  preFixup = ''
+    mv --no-clobber $out/lib64/cmake/* $out/lib/cmake
+    mv --no-clobber $out/lib64/pkgconfig/* $out/lib/pkgconfig
+    rmdir $out/lib64/cmake $out/lib64/pkgconfig
+    find $out/lib64
+
+    for file in $out/lib/pkgconfig/*; do
+      sed -e 's,\''${prefix}//,/,g' -i $file
+    done
+  '';
+
+  cmakeFlags = [
+    "-DGOOGLE_CLOUD_CPP_BIGTABLE_ENABLE_INSTALL=no"
+    "-DGOOGLE_CLOUD_CPP_DEPENDENCY_PROVIDER=package"
+    "-DGOOGLE_CLOUD_CPP_GOOGLEAPIS_PROVIDER=external"
+    "-DBUILD_SHARED_LIBS:BOOL=ON"
+    "-DGOOGLE_CLOUD_CPP_INSTALL_RPATH=$(out)/lib"
+  ];
+
+  meta = with stdenv.lib; {
+    license = with licenses; [ asl20 ];
+    homepage = https://github.com/googleapis/google-cloud-cpp;
+    description = "C++ Idiomatic Clients for Google Cloud Platform services";
+    maintainers = with maintainers; [ andir ];
+  };
+}
diff --git a/pkgs/development/libraries/gperftools/default.nix b/pkgs/development/libraries/gperftools/default.nix
index 44339c3dfed..bc10c9f9bdd 100644
--- a/pkgs/development/libraries/gperftools/default.nix
+++ b/pkgs/development/libraries/gperftools/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, libunwind }:
 
 stdenv.mkDerivation rec {
-  name = "gperftools-2.6.3";
+  name = "gperftools-2.7";
 
   src = fetchurl {
     url = "https://github.com/gperftools/gperftools/releases/download/${name}/${name}.tar.gz";
-    sha256 = "17zfivp6n00rlqbrx6q6h71y2f815nvlzysff1ihgk4mxpv2yjri";
+    sha256 = "1jb30zxmw7h9qxa8yi76rfxj4ssk60rv8n9y41m6pzqfk9lwis0y";
   };
 
   buildInputs = stdenv.lib.optional stdenv.isLinux libunwind;
diff --git a/pkgs/development/libraries/gpgme/default.nix b/pkgs/development/libraries/gpgme/default.nix
index fc7634128dc..c462f2e685a 100644
--- a/pkgs/development/libraries/gpgme/default.nix
+++ b/pkgs/development/libraries/gpgme/default.nix
@@ -13,11 +13,11 @@ in
 
 stdenv.mkDerivation rec {
   name = "gpgme-${version}";
-  version = "1.13.0";
+  version = "1.13.1";
 
   src = fetchurl {
     url = "mirror://gnupg/gpgme/${name}.tar.bz2";
-    sha256 = "0c6676g0yhfsmy32i1dgwh5cx0ja8vhcqf4k08zad177m53kxcnl";
+    sha256 = "0imyjfryvvjdbai454p70zcr95m94j9xnzywrlilqdw2fqi0pqy4";
   };
 
   outputs = [ "out" "dev" "info" ];
diff --git a/pkgs/development/libraries/graphene-hardened-malloc/default.nix b/pkgs/development/libraries/graphene-hardened-malloc/default.nix
index 0aae8ca4945..3e21f3c229f 100644
--- a/pkgs/development/libraries/graphene-hardened-malloc/default.nix
+++ b/pkgs/development/libraries/graphene-hardened-malloc/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "graphene-hardened-malloc-${version}";
-  version = "190405.003.2019.04.01.19";
+  version = "2";
 
   src = fetchurl {
-    url = "https://github.com/GrapheneOS/hardened_malloc/archive/PQ2A.${version}.tar.gz";
-    sha256 = "1qczmajy3q07jd236dmal4iq5xxcsrkyw26gc9r4vs4wj4m42d11";
+    url = "https://github.com/GrapheneOS/hardened_malloc/archive/${version}.tar.gz";
+    sha256 = "0zsl4vl65ic6lw5rzcjzvcxg8makg683abnwvy60zfap8hvijvjb";
   };
 
   installPhase = ''
@@ -17,6 +17,8 @@ stdenv.mkDerivation rec {
     chmod 0555 $out/bin/preload-hardened-malloc
   '';
 
+  separateDebugInfo = true;
+
   doInstallCheck = true;
   installCheckPhase = ''
     pushd test
@@ -27,7 +29,7 @@ stdenv.mkDerivation rec {
     make
 
     # these tests don't actually appear to generate overflows currently
-    rm read_after_free_small string_overflow
+    rm read_after_free_small string_overflow eight_byte_overflow_large
 
     for t in `find . -regex ".*/[a-z_]+"` ; do
       echo "Running $t..."
diff --git a/pkgs/development/libraries/graphene/0001-meson-add-options-for-tests-installation-dirs.patch b/pkgs/development/libraries/graphene/0001-meson-add-options-for-tests-installation-dirs.patch
index d6a441e1577..51bc206659d 100644
--- a/pkgs/development/libraries/graphene/0001-meson-add-options-for-tests-installation-dirs.patch
+++ b/pkgs/development/libraries/graphene/0001-meson-add-options-for-tests-installation-dirs.patch
@@ -1,34 +1,31 @@
-From c550bf4a41e9f86351b0a65ea3d6c9ab616e27c0 Mon Sep 17 00:00:00 2001
+From 2bf6614a6d7516e194e39eb691c05b486860153c Mon Sep 17 00:00:00 2001
 From: worldofpeace <worldofpeace@protonmail.ch>
 Date: Thu, 16 May 2019 21:15:15 -0400
 Subject: [PATCH] meson: add options for tests installation dirs
 
 ---
- meson_options.txt     |  6 ++++++
- src/tests/meson.build | 19 ++++++++++++++-----
+ meson_options.txt |  6 ++++++
+ tests/meson.build | 19 ++++++++++++++-----
  2 files changed, 20 insertions(+), 5 deletions(-)
 
 diff --git a/meson_options.txt b/meson_options.txt
-index c938805..c1e9e95 100644
+index 578bdae..6f5fa23 100644
 --- a/meson_options.txt
 +++ b/meson_options.txt
-@@ -19,6 +19,12 @@ option('arm_neon', type: 'boolean',
- option('tests', type: 'boolean',
+@@ -22,3 +22,9 @@ option('tests', type: 'boolean',
+ option('installed_tests', type: 'boolean',
         value: true,
-        description: 'Build the test suite (requires GObject)')
+        description: 'Install tests')
 +option('installed_test_datadir', type: 'string',
 +       value: '',
 +       description: 'Installation directory for data files in tests')
 +option('installed_test_bindir', type: 'string',
 +       value: '',
 +       description: 'Installation directory for binary files in tests')
- option('benchmarks', type: 'boolean',
-        value: true,
-        description: 'Build the benchmarks suite (requires GObject)')
-diff --git a/src/tests/meson.build b/src/tests/meson.build
-index 62129c6..0186400 100644
---- a/src/tests/meson.build
-+++ b/src/tests/meson.build
+diff --git a/tests/meson.build b/tests/meson.build
+index 1f9bd0e..0253ac3 100644
+--- a/tests/meson.build
++++ b/tests/meson.build
 @@ -22,8 +22,17 @@ unit_tests = [
  python = python3.find_python()
  gen_installed_test = join_paths(meson.current_source_dir(), 'gen-installed-test.py')
@@ -47,33 +44,33 @@ index 62129c6..0186400 100644
 +    test_bindir = join_paths(get_option('prefix'), get_option('libexecdir'), test_suffix)
 +endif
  
- foreach unit: unit_tests
-   wrapper = '@0@.test'.format(unit)
-@@ -32,13 +41,13 @@ foreach unit: unit_tests
-                        command: [
-                          python,
-                          gen_installed_test,
--                         '--testdir=@0@'.format(installed_test_bindir),
-+                         '--testdir=@0@'.format(test_bindir),
-                          '--testname=@0@'.format(unit),
-                          '--outdir=@OUTDIR@',
-                          '--outfile=@0@'.format(wrapper),
-                        ],
-                        install: true,
--                       install_dir: installed_test_datadir)
-+                       install_dir: test_datadir)
- 
-   exe = executable(unit, unit + '.c',
-                    dependencies: graphene_dep,
-@@ -50,7 +59,7 @@ foreach unit: unit_tests
-                      '-DGLIB_DISABLE_DEPRECATION_WARNINGS',
-                    ],
-                    install: true,
--                   install_dir: installed_test_bindir)
-+                   install_dir: test_bindir)
+ # Make tests conditional on having mutest-1 installed system-wide, or
+ # available as a subproject
+@@ -42,13 +51,13 @@ if mutest_dep.found()
+       command: [
+         python,
+         gen_installed_test,
+-        '--testdir=@0@'.format(installed_test_bindir),
++        '--testdir=@0@'.format(test_bindir),
+         '--testname=@0@'.format(unit),
+         '--outdir=@OUTDIR@',
+         '--outfile=@0@'.format(wrapper),
+       ],
+       install: get_option('installed_tests'),
+-      install_dir: installed_test_datadir,
++      install_dir: test_datadir,
+     )
  
-   test(unit, exe, args: [ '--tap', '-k' ])
- endforeach
+     test(unit,
+@@ -57,7 +66,7 @@ if mutest_dep.found()
+         include_directories: graphene_inc,
+         c_args: common_cflags,
+         install: get_option('installed_tests'),
+-        install_dir: installed_test_bindir,
++        install_dir: test_bindir,
+       ),
+       env: ['MUTEST_OUTPUT=tap'],
+       protocol: 'tap',
 -- 
-2.21.0
+2.22.0
 
diff --git a/pkgs/development/libraries/graphene/default.nix b/pkgs/development/libraries/graphene/default.nix
index 253fce4ea0d..7c61b222486 100644
--- a/pkgs/development/libraries/graphene/default.nix
+++ b/pkgs/development/libraries/graphene/default.nix
@@ -4,6 +4,7 @@
 , meson
 , ninja
 , python3
+, mutest
 , glib
 , gtk-doc
 , docbook_xsl
@@ -13,7 +14,7 @@
 
 stdenv.mkDerivation rec {
   pname = "graphene";
-  version = "1.8.6";
+  version = "1.9.6";
 
   outputs = [ "out" "devdoc" "installedTests" ];
 
@@ -21,7 +22,7 @@ stdenv.mkDerivation rec {
     owner = "ebassi";
     repo = pname;
     rev = version;
-    sha256 = "1hdbdzcz86jrvsq5h954ph9q62m8jr2a5s5acklxhdkfqn5bkbv8";
+    sha256 = "0hb7s6g00l7zlf4hlfda55krn0pls9ajz0hcqrh8m656zr18ddwa";
   };
 
   patches = [
@@ -41,17 +42,21 @@ stdenv.mkDerivation rec {
     meson
     ninja
     pkgconfig
+    gobject-introspection
     python3
   ];
 
   buildInputs = [
+    glib
     gobject-introspection
   ];
 
   checkInputs = [
-    glib
+    mutest
   ];
 
+  doCheck = true;
+
   meta = with stdenv.lib; {
     description = "A thin layer of graphic data types";
     homepage = "https://ebassi.github.com/graphene";
diff --git a/pkgs/development/libraries/grilo-plugins/default.nix b/pkgs/development/libraries/grilo-plugins/default.nix
new file mode 100644
index 00000000000..118a910a168
--- /dev/null
+++ b/pkgs/development/libraries/grilo-plugins/default.nix
@@ -0,0 +1,82 @@
+{ stdenv
+, fetchurl
+, meson
+, ninja
+, pkgconfig
+, gettext
+, gperf
+, sqlite
+, librest
+, libarchive
+, libsoup
+, gnome3
+, libxml2
+, lua5_3
+, liboauth
+, libgdata
+, libmediaart
+, grilo
+, gnome-online-accounts
+, gmime
+, json-glib
+, avahi
+, tracker
+, dleyna-server
+, itstool
+, totem-pl-parser
+}:
+
+stdenv.mkDerivation rec {
+  pname = "grilo-plugins";
+  version = "0.3.9";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
+    sha256 = "1hv84b56qjic8vz8iz46ikhrxx31l29ilbr8dm5qcghbd8ikw8j1";
+  };
+
+  nativeBuildInputs = [
+    meson
+    ninja
+    pkgconfig
+    gettext
+    itstool
+    gperf # for lua-factory
+  ];
+
+  buildInputs = [
+    grilo
+    libxml2
+    libgdata
+    lua5_3
+    liboauth
+    sqlite
+    gnome-online-accounts
+    totem-pl-parser
+    librest
+    libarchive
+    libsoup
+    gmime
+    json-glib
+    avahi
+    libmediaart
+    tracker
+    dleyna-server
+  ];
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+      attrPath = "gnome3.${pname}";
+      versionPolicy = "none";
+    };
+  };
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Projects/Grilo;
+    description = "A collection of plugins for the Grilo framework";
+    maintainers = gnome3.maintainers;
+    license = licenses.lgpl21;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/grilo/default.nix b/pkgs/development/libraries/grilo/default.nix
new file mode 100644
index 00000000000..b2a7f0bd5ae
--- /dev/null
+++ b/pkgs/development/libraries/grilo/default.nix
@@ -0,0 +1,62 @@
+{ stdenv, fetchurl, meson, ninja, pkgconfig, gettext, vala, glib, liboauth, gtk3
+, gtk-doc, docbook_xsl, docbook_xml_dtd_43, fetchpatch
+, libxml2, gnome3, gobject-introspection, libsoup, totem-pl-parser }:
+
+let
+  pname = "grilo";
+  version = "0.3.9"; # if you change minor, also change ./setup-hook.sh
+in stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+
+  outputs = [ "out" "dev" "man" "devdoc" ];
+  outputBin = "dev";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${name}.tar.xz";
+    sha256 = "1wnabc69730jsv8dljj5ik8g7p581nw60mw1mkgamkzjcb6821bk";
+  };
+
+  setupHook = ./setup-hook.sh;
+
+  mesonFlags = [
+    "-Dgtk_doc=true"
+  ];
+
+  patches = [
+    # https://gitlab.gnome.org/GNOME/grilo/merge_requests/45
+    # commits are from a separate branch so they shouldn't 404
+    (fetchpatch {
+      url = "https://gitlab.gnome.org/worldofpeace/grilo/commit/f6993c2a8a6c1a6246372569f9f7a9179955c95e.patch";
+      sha256 = "1x4s0ahs60dqyphgv2dy3x2sjnxv5ydd55kdlcjsys5870ijwbi8";
+    })
+    (fetchpatch {
+      url = "https://gitlab.gnome.org/worldofpeace/grilo/commit/61bca28b141162a33eb2fb575ef1daf0f21c7741.patch";
+      sha256 = "1147xbmaq61myfwxz0pagdv056krfmh1s78qjbiy5k7k203qrjz0";
+    })
+    (fetchpatch {
+      url = "https://gitlab.gnome.org/worldofpeace/grilo/commit/363b198a062eeb8aaa5489ea9720e69d428e885c.patch";
+      sha256 = "01w1bfzdbnxy5l37b2z7a9h2mrxziqkzdw02dybjphy85nb0hz5w";
+    })
+  ];
+
+  nativeBuildInputs = [
+    meson ninja pkgconfig gettext gobject-introspection vala
+    gtk-doc docbook_xsl docbook_xml_dtd_43
+  ];
+  buildInputs = [ glib liboauth gtk3 libxml2 libsoup totem-pl-parser ];
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+      versionPolicy = "none";
+    };
+  };
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Projects/Grilo;
+    description = "Framework that provides access to various sources of multimedia content, using a pluggable system";
+    maintainers = gnome3.maintainers;
+    license = licenses.lgpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/grilo/setup-hook.sh b/pkgs/development/libraries/grilo/setup-hook.sh
new file mode 100644
index 00000000000..9337c520a20
--- /dev/null
+++ b/pkgs/development/libraries/grilo/setup-hook.sh
@@ -0,0 +1,7 @@
+make_grilo_find_plugins() {
+    if [ -d "$1"/lib/grilo-0.3 ]; then
+        addToSearchPath GRL_PLUGIN_PATH "$1/lib/grilo-0.3"
+    fi
+}
+
+addEnvHooks "$hostOffset" make_grilo_find_plugins
diff --git a/pkgs/development/libraries/grpc/default.nix b/pkgs/development/libraries/grpc/default.nix
index 77773e91e17..78335e073ed 100644
--- a/pkgs/development/libraries/grpc/default.nix
+++ b/pkgs/development/libraries/grpc/default.nix
@@ -1,13 +1,13 @@
 { stdenv, fetchFromGitHub, cmake, zlib, c-ares, pkgconfig, openssl, protobuf, gflags }:
 
 stdenv.mkDerivation rec {
-  version = "1.19.1";
+  version = "1.23.0"; # N.B: if you change this, change pythonPackages.grpcio and pythonPackages.grpcio-tools to a matching version too
   name = "grpc-${version}";
   src = fetchFromGitHub {
     owner = "grpc";
     repo = "grpc";
     rev = "v${version}";
-    sha256 = "0c0jra4qnd86gyr4rlblic3igb5dpgrldac35myk5i5ia547fdhj";
+    sha256 = "14svfy7lvz8lf6b7zg1fbypj2n46n9gq0ldgnv85jm0ikv72cgv6";
   };
   nativeBuildInputs = [ cmake pkgconfig ];
   buildInputs = [ zlib c-ares c-ares.cmake-config openssl protobuf gflags ];
@@ -19,6 +19,7 @@ stdenv.mkDerivation rec {
       "-DgRPC_PROTOBUF_PROVIDER=package"
       "-DgRPC_GFLAGS_PROVIDER=package"
       "-DBUILD_SHARED_LIBS=ON"
+      "-DCMAKE_SKIP_BUILD_RPATH=OFF"
     ];
 
   # CMake creates a build directory by default, this conflicts with the
@@ -38,7 +39,7 @@ stdenv.mkDerivation rec {
   meta = with stdenv.lib; {
     description = "The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#)";
     license = licenses.asl20;
-    maintainers = [ maintainers.lnl7 ];
+    maintainers = [ maintainers.lnl7 maintainers.marsam ];
     homepage = https://grpc.io/;
   };
 }
diff --git a/pkgs/development/libraries/gsettings-desktop-schemas/default.nix b/pkgs/development/libraries/gsettings-desktop-schemas/default.nix
index c1bdcd6956e..d454ca63fd7 100644
--- a/pkgs/development/libraries/gsettings-desktop-schemas/default.nix
+++ b/pkgs/development/libraries/gsettings-desktop-schemas/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, intltool, glib, gobject-introspection
+{ stdenv, fetchurl, pkgconfig, glib, gobject-introspection
 , meson
 , ninja
 , python3
diff --git a/pkgs/development/libraries/gsettings-qt/default.nix b/pkgs/development/libraries/gsettings-qt/default.nix
index 3f9cd8120d8..744d9eb6de9 100644
--- a/pkgs/development/libraries/gsettings-qt/default.nix
+++ b/pkgs/development/libraries/gsettings-qt/default.nix
@@ -1,4 +1,7 @@
-{ stdenv, fetchbzr, pkgconfig, qmake, qtbase, qtdeclarative, glib, gobject-introspection }:
+{ stdenv, fetchbzr, pkgconfig
+, qmake, qtbase, qtdeclarative, wrapQtAppsHook
+, glib, gobject-introspection
+}:
 
 stdenv.mkDerivation rec {
   name = "gsettings-qt-${version}";
@@ -14,6 +17,7 @@ stdenv.mkDerivation rec {
     pkgconfig
     qmake
     gobject-introspection
+    wrapQtAppsHook
   ];
 
   buildInputs = [
diff --git a/pkgs/development/libraries/gsignond/default.nix b/pkgs/development/libraries/gsignond/default.nix
index a81e72bf66f..88a4ecb3622 100644
--- a/pkgs/development/libraries/gsignond/default.nix
+++ b/pkgs/development/libraries/gsignond/default.nix
@@ -61,7 +61,7 @@ unwrapped = stdenv.mkDerivation rec {
 
 in if plugins == [] then unwrapped
     else import ./wrapper.nix {
-      inherit stdenv makeWrapper symlinkJoin gsignondPlugins plugins;
+      inherit makeWrapper symlinkJoin plugins;
       gsignond = unwrapped;
     }
 
diff --git a/pkgs/development/libraries/gsignond/plugins/oauth.nix b/pkgs/development/libraries/gsignond/plugins/oauth.nix
index 6182ea283cb..887376d3187 100644
--- a/pkgs/development/libraries/gsignond/plugins/oauth.nix
+++ b/pkgs/development/libraries/gsignond/plugins/oauth.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitLab, fetchpatch, pkgconfig, meson, ninja, glib, gsignond, check
+{ stdenv, fetchFromGitLab, pkgconfig, meson, ninja, glib, gsignond, check
 , json-glib, libsoup, gnutls, gtk-doc, docbook_xml_dtd_43, docbook_xml_dtd_45
 , docbook_xsl, glibcLocales, gobject-introspection }:
 
diff --git a/pkgs/development/libraries/gsignond/plugins/sasl.nix b/pkgs/development/libraries/gsignond/plugins/sasl.nix
index d1fa37939a7..655f73931f6 100644
--- a/pkgs/development/libraries/gsignond/plugins/sasl.nix
+++ b/pkgs/development/libraries/gsignond/plugins/sasl.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitLab, fetchpatch, pkgconfig, meson, ninja, glib, gsignond, gsasl, check
+{ stdenv, fetchFromGitLab, pkgconfig, meson, ninja, glib, gsignond, gsasl, check
 , gtk-doc, docbook_xml_dtd_43, docbook_xml_dtd_45, docbook_xsl, glibcLocales, gobject-introspection }:
 
 stdenv.mkDerivation rec {
diff --git a/pkgs/development/libraries/gsignond/wrapper.nix b/pkgs/development/libraries/gsignond/wrapper.nix
index 04463aac379..a4738e4b6a7 100644
--- a/pkgs/development/libraries/gsignond/wrapper.nix
+++ b/pkgs/development/libraries/gsignond/wrapper.nix
@@ -1,4 +1,4 @@
-{ stdenv, makeWrapper, symlinkJoin, gsignond, gsignondPlugins, plugins }:
+{ makeWrapper, symlinkJoin, gsignond, plugins }:
 
 symlinkJoin {
   name = "gsignond-with-plugins-${gsignond.version}";
diff --git a/pkgs/development/libraries/gstreamer/bad/default.nix b/pkgs/development/libraries/gstreamer/bad/default.nix
index 8179806859c..2ae0ad2b453 100644
--- a/pkgs/development/libraries/gstreamer/bad/default.nix
+++ b/pkgs/development/libraries/gstreamer/bad/default.nix
@@ -1,10 +1,43 @@
 { stdenv, fetchurl, fetchpatch, meson, ninja, gettext
+, config
 , pkgconfig, python3, gst-plugins-base, orc
+, gobject-introspection
+, enableZbar ? true
 , faacSupport ? false, faac ? null
 , faad2, libass, libkate, libmms, librdf, ladspaH
 , libnice, webrtc-audio-processing, lilv, lv2, serd, sord, sratom
 , libbs2b, libmodplug, mpeg2dec
 , openjpeg, libopus, librsvg
+, bluez
+, chromaprint
+, curl
+, directfb
+, fdk_aac
+, flite
+, gsm
+, libaom
+, libdc1394
+, libde265
+, libdrm
+, libdvdnav
+, libdvdread
+, libgudev
+, libofa
+, libsndfile
+, libusb1
+, neon
+, openal
+, opencv3
+, openexr
+, openh264
+, pango
+, rtmpdump
+, sbc
+, soundtouch
+, spandsp
+, srtp
+, zbar
+, wayland-protocols
 , wildmidi, fluidsynth, libvdpau, wayland
 , libwebp, xvidcore, gnutls, mjpegtools
 , libGLU_combined, libintl, libgme
@@ -15,11 +48,11 @@
 assert faacSupport -> faac != null;
 
 let
-  inherit (stdenv.lib) optional;
+  inherit (stdenv.lib) optional optionals;
 in
 stdenv.mkDerivation rec {
   name = "gst-plugins-bad-${version}";
-  version = "1.14.4";
+  version = "1.16.0";
 
   meta = with stdenv.lib; {
     description = "Gstreamer Bad Plugins";
@@ -40,27 +73,32 @@ stdenv.mkDerivation rec {
   '';
 
   patches = [
+    ./fix_pkgconfig_includedir.patch
+    # Remove when https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/312 is merged and available to us
     (fetchpatch {
-        url = "https://bug794856.bugzilla-attachments.gnome.org/attachment.cgi?id=370409";
-        sha256 = "0hy0rcn35alq65yqwri4fqjz2hf3nyyg5c7rnndk51msmqjxpprk";
+      url = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/commit/99790eaad9083cce5ab2b1646489e1a1c0faad1e.patch";
+      sha256 = "11bqy4sl05qq5mj4bx5s09rq106s3j0vnpjl4np058im32j69lr3";
     })
-    ./fix_pkgconfig_includedir.patch
-    # Enable bs2b compilation
-    # https://bugzilla.gnome.org/show_bug.cgi?id=794346
-    (fetchurl {
-      url = https://bugzilla.gnome.org/attachment.cgi?id=369724;
-      sha256 = "1716mp0h2866ab33w607isvfhv1zwyj71qb4jrkx5v0h276v1pwr";
+    # Remove when https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/312 is merged and available to us
+    (fetchpatch {
+      url = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/commit/1872da81c48d3a719bd39955fd97deac7d037d74.patch";
+      sha256 = "11zwrr5ggflmvr0qfssj7dmhgd3ybiadmy79b4zh24022zgw3xpz";
     })
   ];
 
   src = fetchurl {
     url = "${meta.homepage}/src/gst-plugins-bad/${name}.tar.xz";
-    sha256 = "1r8dma3x127rbx42yab7kwq7q1bhkmvz2ykn0rnqnzl95q74w2wi";
+    sha256 = "019b0yqjrcg6jmfd4cc336h1bz5p4wxl58yz1c4sdb96avirs4r2";
   };
 
   outputs = [ "out" "dev" ];
 
-  nativeBuildInputs = [ meson ninja pkgconfig python3 gettext ];
+  nativeBuildInputs = [
+    meson ninja pkgconfig python3 gettext gobject-introspection
+  ]
+  ++ optionals stdenv.isLinux [
+    wayland-protocols
+  ];
 
   buildInputs = [
     gst-plugins-base orc
@@ -71,12 +109,41 @@ stdenv.mkDerivation rec {
     lilv lv2 serd sord sratom # lv2 plug-in
     libmodplug mpeg2dec
     openjpeg libopus librsvg
+    bluez
+    chromaprint
+    curl.dev
+    directfb
+    fdk_aac
+    flite
+    gsm
+    libaom
+    libdc1394
+    libde265
+    libdrm
+    libdvdnav
+    libdvdread
+    libgudev
+    libofa
+    libsndfile
+    libusb1
+    neon
+    openal
+    opencv3
+    openexr
+    openh264
+    rtmpdump
+    pango
+    sbc
+    soundtouch
+    spandsp
+    srtp
     fluidsynth libvdpau
     libwebp xvidcore gnutls libGLU_combined
     libgme openssl x265 libxml2
     libintl
     srt
   ]
+    ++ optional enableZbar zbar
     ++ optional faacSupport faac
     ++ optional stdenv.isLinux wayland
     # wildmidi requires apple's OpenAL
@@ -85,6 +152,47 @@ stdenv.mkDerivation rec {
     # TODO: mjpegtools uint64_t is not compatible with guint64 on Darwin
     ++ optional (!stdenv.isDarwin) mjpegtools;
 
+  mesonFlags = [
+    # Enables all features, so that we know when new dependencies are necessary.
+    "-Dauto_features=enabled"
+
+    "-Dexamples=disabled" # requires many dependencies and probably not useful for our users
+
+    "-Ddts=disabled" # required `libdca` library not packaged in nixpkgs as of writing, and marked as "BIG FAT WARNING: libdca is still in early development"
+    "-Dzbar=${if enableZbar then "enabled" else "disabled"}"
+    "-Dfaac=${if faacSupport then "enabled" else "disabled"}"
+    "-Diqa=disabled" # required `dssim` library not packaging in nixpkgs as of writing
+    "-Dmsdk=disabled" # not packaged in nixpkgs as of writing / no Windows support
+    # As of writing, with `libmpcdec` in `buildInputs` we get
+    #   "Could not find libmpcdec header files, but Musepack was enabled via options"
+    # This is likely because nixpkgs has the header in libmpc/mpcdec.h
+    # instead of mpc/mpcdec.h, like Arch does. The situation is not trivial.
+    # There are apparently 2 things called `libmpcdec` from the same author:
+    #   * http://svn.musepack.net/libmpcdec/trunk/src/
+    #   * http://svn.musepack.net/libmpc/trunk/include/mpc/
+    # Fixing it likely requires to first figure out with upstream which one
+    # is needed, and then patching upstream to find it (though it probably
+    # already works on Arch?).
+    "-Dmusepack=disabled"
+    "-Dopenmpt=disabled" # `libopenmpt` not packaged in nixpkgs as of writing
+    "-Dopenni2=disabled" # not packaged in nixpkgs as of writing
+    "-Dopensles=disabled" # not packaged in nixpkgs as of writing
+    "-Dsctp=disabled" # required `usrsctp` library not packaged in nixpkgs as of writing
+    "-Dteletext=disabled" # required `zvbi` library not packaged in nixpkgs as of writing
+    "-Dtinyalsa=disabled" # not packaged in nixpkgs as of writing
+    "-Dvoaacenc=disabled" # required `vo-aacenc` library not packaged in nixpkgs as of writing
+    "-Dvoamrwbenc=disabled" # required `vo-amrwbenc` library not packaged in nixpkgs as of writing
+    "-Dvulkan=disabled" # Linux-only, and we haven't figured out yet which of the vulkan nixpkgs it needs
+    "-Dwasapi=disabled" # not packaged in nixpkgs as of writing / no Windows support
+    "-Dwpe=disabled" # required `wpe-webkit` library not packaged in nixpkgs as of writing
+
+    # Requires CUDA and we haven't figured out how to make Meson find CUDA yet;
+    # it probably searches via pkgconfig, for which we have no .pc files,
+    # see https://github.com/NixOS/nixpkgs/issues/54395
+    "-Dnvdec=disabled"
+    "-Dnvenc=disabled"
+  ];
+
   enableParallelBuilding = true;
 
   doCheck = false; # fails 20 out of 58 tests, expensive
diff --git a/pkgs/development/libraries/gstreamer/base/default.nix b/pkgs/development/libraries/gstreamer/base/default.nix
index 0acdf71fb72..87bbef227de 100644
--- a/pkgs/development/libraries/gstreamer/base/default.nix
+++ b/pkgs/development/libraries/gstreamer/base/default.nix
@@ -2,6 +2,11 @@
 , pkgconfig, meson, ninja, gettext, gobject-introspection
 , python3, gstreamer, orc, pango, libtheora
 , libintl, libopus
+, isocodes
+, libjpeg
+, libvisual
+, tremor # provides 'virbisidec'
+, gtk-doc, docbook_xsl, docbook_xml_dtd_412
 , enableX11 ? stdenv.isLinux, libXv
 , enableWayland ? stdenv.isLinux, wayland
 , enableAlsa ? stdenv.isLinux, alsaLib
@@ -10,7 +15,7 @@
 
 stdenv.mkDerivation rec {
   name = "gst-plugins-base-${version}";
-  version = "1.14.4";
+  version = "1.16.0";
 
   meta = with lib; {
     description = "Base plugins and helper libraries";
@@ -22,28 +27,56 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gst-plugins-base/${name}.tar.xz";
-    sha256 = "0qbllw4kphchwhy4p7ivdysigx69i97gyw6q0rvkx1j81r4kjqfa";
+    sha256 = "1bmmdwbyy89ayb85xc48y217f6wdmpz96f30zm6v53z2a5xsm4s0";
   };
 
   outputs = [ "out" "dev" ];
 
-  nativeBuildInputs = [ pkgconfig python3 gettext gobject-introspection ]
-
+  nativeBuildInputs = [
+    pkgconfig python3 gettext gobject-introspection
+    gtk-doc
+    # Without these, enabling the 'gtk_doc' gives us `FAILED: meson-install`
+    docbook_xsl docbook_xml_dtd_412
+  ]
   # Broken meson with Darwin. Should hopefully be fixed soon. Tracking
   # in https://bugzilla.gnome.org/show_bug.cgi?id=781148.
   ++ lib.optionals (!stdenv.isDarwin) [ meson ninja ];
 
+  # On Darwin, we currently use autoconf, on all other systems Meson
+  # TODO Switch to Meson on Darwin as well
+
   # TODO How to pass these to Meson?
-  configureFlags = [
+  configureFlags = lib.optionals stdenv.isDarwin [
     "--enable-x11=${if enableX11 then "yes" else "no"}"
     "--enable-wayland=${if enableWayland then "yes" else "no"}"
     "--enable-cocoa=${if enableCocoa then "yes" else "no"}"
   ]
-
   # Introspection fails on my MacBook currently
   ++ lib.optional stdenv.isDarwin "--disable-introspection";
 
-  buildInputs = [ orc libtheora libintl libopus ]
+  mesonFlags = lib.optionals (!stdenv.isDarwin) [
+    # Enables all features, so that we know when new dependencies are necessary.
+    "-Dauto_features=enabled"
+    "-Dexamples=disabled" # requires many dependencies and probably not useful for our users
+    "-Dgl-graphene=disabled" # not packaged in nixpkgs as of writing
+    # See https://github.com/GStreamer/gst-plugins-base/blob/d64a4b7a69c3462851ff4dcfa97cc6f94cd64aef/meson_options.txt#L15 for a list of choices
+    "-Dgl_winsys=[${lib.concatStringsSep "," (lib.optional enableX11 "x11" ++ lib.optional enableWayland "wayland" ++ lib.optional enableCocoa "cocoa")}]"
+    # We must currently disable gtk_doc API docs generation,
+    # because it is not compatible with some features being disabled.
+    # See for example
+    #     https://gitlab.gnome.org/GNOME/gnome-build-meta/issues/38
+    # for it failing because some Wayland symbols are missing.
+    # This problem appeared between 1.15.1 and 1.16.0.
+    "-Dgtk_doc=disabled"
+  ]
+  ++ lib.optional (!enableX11) "-Dx11=disabled"
+  # TODO How to disable Wayland?
+  ++ lib.optional (!enableAlsa) "-Dalsa=disabled"
+  ++ lib.optional (!enableCdparanoia) "-Dcdparanoia=disabled"
+  ;
+
+  buildInputs = [ orc libtheora libintl libopus isocodes libjpeg tremor ]
+    ++ lib.optional (!stdenv.isDarwin) libvisual
     ++ lib.optional enableAlsa alsaLib
     ++ lib.optionals enableX11 [ libXv pango ]
     ++ lib.optional enableWayland wayland
@@ -61,10 +94,6 @@ stdenv.mkDerivation rec {
   doCheck = false; # fails, wants DRI access for OpenGL
 
   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/core/default.nix b/pkgs/development/libraries/gstreamer/core/default.nix
index b69ab89df24..fa838d5ff77 100644
--- a/pkgs/development/libraries/gstreamer/core/default.nix
+++ b/pkgs/development/libraries/gstreamer/core/default.nix
@@ -2,12 +2,17 @@
 , pkgconfig, gettext, gobject-introspection
 , bison, flex, python3, glib, makeWrapper
 , libcap,libunwind, darwin
+, elfutils # for libdw
+, bash-completion
+, docbook_xsl, docbook_xml_dtd_412
+, gtk-doc
 , lib
+, CoreServices
 }:
 
 stdenv.mkDerivation rec {
   name = "gstreamer-${version}";
-  version = "1.14.4";
+  version = "1.16.0";
 
   meta = with lib ;{
     description = "Open source multimedia framework";
@@ -19,14 +24,10 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gstreamer/${name}.tar.xz";
-    sha256 = "1izzhnlsy83rgr4zl3jcl1sryxqbbigrrqw3j4x3nnphqnb6ckzr";
+    sha256 = "003wy1p1in85p9sr5jsyhbnwqaiwz069flwkhyx7qhxy31qjz3hf";
   };
 
   patches = [
-    (fetchpatch {
-        url = "https://bug794856.bugzilla-attachments.gnome.org/attachment.cgi?id=370411";
-        sha256 = "16plzzmkk906k4892zq68j3c9z8vdma5nxzlviq20jfv04ykhmk2";
-    })
     ./fix_pkgconfig_includedir.patch
   ];
 
@@ -35,13 +36,27 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [
     meson ninja pkgconfig gettext bison flex python3 makeWrapper gobject-introspection
+    bash-completion
+    gtk-doc
+    # Without these, enabling the 'gtk_doc' gives us `FAILED: meson-install`
+    docbook_xsl docbook_xml_dtd_412
   ];
+
   buildInputs =
-       lib.optionals stdenv.isLinux [ libcap libunwind ]
-    ++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.CoreServices;
+       lib.optionals stdenv.isLinux [ libcap libunwind elfutils ]
+    ++ lib.optional stdenv.isDarwin CoreServices;
 
   propagatedBuildInputs = [ glib ];
 
+  mesonFlags = [
+    # Enables all features, so that we know when new dependencies are necessary.
+    "-Dauto_features=enabled"
+    "-Ddbghelp=disabled" # not needed as we already provide libunwind and libdw, and dbghelp is a fallback to those
+    "-Dexamples=disabled" # requires many dependencies and probably not useful for our users
+  ]
+    # darwin.libunwind doesn't have pkgconfig definitions so meson doesn't detect it.
+    ++ stdenv.lib.optionals stdenv.isDarwin [ "-Dlibunwind=disabled" "-Dlibdw=disabled" ];
+
   postInstall = ''
     for prog in "$dev/bin/"*; do
         # We can't use --suffix here due to quoting so we craft the export command by hand
@@ -49,9 +64,17 @@ stdenv.mkDerivation rec {
     done
   '';
 
-  preConfigure= ''
-    patchShebangs .
-  '';
+  preConfigure=
+    # These files are not executable upstream, so we need to
+    # make them executable for `patchShebangs` to pick them up.
+    # Can be removed when this is merged and available:
+    #     https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/141
+    ''
+      chmod +x gst/parse/get_flex_version.py
+    '' +
+    ''
+      patchShebangs .
+    '';
 
   preFixup = ''
     moveToOutput "share/bash-completion" "$dev"
diff --git a/pkgs/development/libraries/gstreamer/default.nix b/pkgs/development/libraries/gstreamer/default.nix
index 9aec8763404..94d71760a7f 100644
--- a/pkgs/development/libraries/gstreamer/default.nix
+++ b/pkgs/development/libraries/gstreamer/default.nix
@@ -1,7 +1,7 @@
-{ callPackage }:
+{ callPackage, CoreServices }:
 
 rec {
-  gstreamer = callPackage ./core { };
+  gstreamer = callPackage ./core { inherit CoreServices; };
 
   gstreamermm = callPackage ./gstreamermm { };
 
@@ -13,7 +13,7 @@ rec {
 
   gst-plugins-ugly = callPackage ./ugly { inherit gst-plugins-base; };
 
-  gst-rtsp-server = callPackage ./rtsp-server { inherit gst-plugins-base; };
+  gst-rtsp-server = callPackage ./rtsp-server { inherit gst-plugins-base gst-plugins-bad; };
 
   gst-libav = callPackage ./libav { inherit gst-plugins-base; };
 
diff --git a/pkgs/development/libraries/gstreamer/ges/default.nix b/pkgs/development/libraries/gstreamer/ges/default.nix
index fb7a37a4f44..703fcb58898 100644
--- a/pkgs/development/libraries/gstreamer/ges/default.nix
+++ b/pkgs/development/libraries/gstreamer/ges/default.nix
@@ -5,7 +5,7 @@
 
 stdenv.mkDerivation rec {
   name = "gstreamer-editing-services-${version}";
-  version = "1.14.4";
+  version = "1.16.0";
 
   meta = with stdenv.lib; {
     description = "Library for creation of audio/video non-linear editors";
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gstreamer-editing-services/${name}.tar.xz";
-    sha256 = "0pxk65jib3mqszjkyvlzklwia4kbdj6j2b6jw1d502b06mdx5lak";
+    sha256 = "1las94jkx83sxmzi5w6b0xm89dqqwzpdsb6h9w9ixndhnbpzm8w2";
   };
 
   outputs = [ "out" "dev" ];
@@ -25,11 +25,11 @@ stdenv.mkDerivation rec {
 
   propagatedBuildInputs = [ gst-plugins-base libxml2 ];
 
+  mesonFlags = [
+    "-Dgtk_doc=disabled"
+  ];
+
   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/good/default.nix b/pkgs/development/libraries/gstreamer/good/default.nix
index 247a74e3a32..557e3caa722 100644
--- a/pkgs/development/libraries/gstreamer/good/default.nix
+++ b/pkgs/development/libraries/gstreamer/good/default.nix
@@ -2,14 +2,21 @@
 , gst-plugins-base, orc, bzip2, gettext
 , libv4l, libdv, libavc1394, libiec61883
 , libvpx, speex, flac, taglib, libshout
-, cairo, gdk_pixbuf, aalib, libcaca
+, cairo, gdk-pixbuf, aalib, libcaca
 , libsoup, libpulseaudio, libintl
 , darwin, lame, mpg123, twolame
 , gtkSupport ? false, gtk3 ? null
+# As of writing, jack2 incurs a Qt dependency (big!) via `ffado`.
+# In the fuure we should probably split `ffado`.
+, enableJack ? false
 , libXdamage
 , libXext
 , libXfixes
 , ncurses
+, xorg
+, libgudev
+, wavpack
+, jack2
 }:
 
 assert gtkSupport -> gtk3 != null;
@@ -19,7 +26,7 @@ let
 in
 stdenv.mkDerivation rec {
   name = "gst-plugins-good-${version}";
-  version = "1.14.4";
+  version = "1.16.0";
 
   meta = with stdenv.lib; {
     description = "Gstreamer Good Plugins";
@@ -36,7 +43,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gst-plugins-good/${name}.tar.xz";
-    sha256 = "0y89qynb4b6fry3h43z1r99qslmi3m8xhlq0i5baq2nbc0r5b2sz";
+    sha256 = "1zdhif1mhf0ihkjpjyrh65g2iz2cawkjjb3h5w8h9ml06grxwjk5";
   };
 
   outputs = [ "out" "dev" ];
@@ -50,18 +57,36 @@ stdenv.mkDerivation rec {
   buildInputs = [
     gst-plugins-base orc bzip2
     libdv libvpx speex flac taglib
-    cairo gdk_pixbuf aalib libcaca
+    cairo gdk-pixbuf aalib libcaca
     libsoup libshout lame mpg123 twolame libintl
-    # TODO: Remove the comments once https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/commit/e234932dc703e51a0e1aa3b9c408f12758b12335
-    # is merged and available in nixpkgs.
-    libXdamage # present feature but undeclared in meson_options.txt, see https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/553
-    libXext # present feature but undeclared in meson_options.txt, see https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/553
-    libXfixes # present feature but undeclared in meson_options.txt, see https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/553
+    libXdamage
+    libXext
+    libXfixes
     ncurses
+    xorg.libXfixes
+    xorg.libXdamage
+    wavpack
   ]
   ++ optional gtkSupport gtk3 # for gtksink
   ++ optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ]
-  ++ optionals stdenv.isLinux [ libv4l libpulseaudio libavc1394 libiec61883 ];
+  ++ optionals stdenv.isLinux [ libv4l libpulseaudio libavc1394 libiec61883 libgudev ]
+  ++ optionals (stdenv.isLinux && enableJack) [
+    jack2
+  ];
+
+  mesonFlags = [
+    # Enables all features, so that we know when new dependencies are necessary.
+    "-Dauto_features=enabled"
+    "-Dexamples=disabled" # requires many dependencies and probably not useful for our users
+    "-Dqt5=disabled" # not clear as of writing how to correctly pass in the required qt5 deps
+  ]
+  ++ optional (!gtkSupport) "-Dgtk3=disabled"
+  ++ optionals (!stdenv.isLinux || !enableJack) [
+    "-Djack=disabled" # unclear whether Jack works on Darwin
+  ]
+  ++ optionals (!stdenv.isLinux) [
+    "-Dv4l2-gudev=disabled"
+  ];
 
   # fails 1 tests with "Unexpected critical/warning: g_object_set_is_valid_property: object class 'GstRtpStorage' has no property named ''"
   doCheck = false;
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 7ecb6c34b43..2b78d4daaf3 100644
--- a/pkgs/development/libraries/gstreamer/legacy/gst-plugins-good/default.nix
+++ b/pkgs/development/libraries/gstreamer/legacy/gst-plugins-good/default.nix
@@ -1,6 +1,6 @@
 { fetchurl, stdenv, lib, pkgconfig, gst-plugins-base, aalib, cairo
 , flac, libjpeg, speex, libpng, libdv, libcaca, libvpx
-, taglib, libpulseaudio, gdk_pixbuf, orc
+, taglib, libpulseaudio, gdk-pixbuf, orc
 , glib, gstreamer, bzip2, libsoup, libshout, ncurses, libintl
 , # Whether to build no plugins that have external dependencies
   # (except the PulseAudio plugin).
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
     ++ lib.optional stdenv.isLinux libpulseaudio
     ++ lib.optionals (!minimalDeps)
       [ aalib libcaca cairo libdv flac libjpeg libpng speex
-        taglib bzip2 libvpx gdk_pixbuf orc libsoup libshout ];
+        taglib bzip2 libvpx gdk-pixbuf orc libsoup libshout ];
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/gstreamer/legacy/gstreamer/default.nix b/pkgs/development/libraries/gstreamer/legacy/gstreamer/default.nix
index d03151e4344..c70e898a47d 100644
--- a/pkgs/development/libraries/gstreamer/legacy/gstreamer/default.nix
+++ b/pkgs/development/libraries/gstreamer/legacy/gstreamer/default.nix
@@ -1,5 +1,5 @@
 { fetchurl, fetchpatch, stdenv, autoreconfHook
-, perl, bison2, flex, pkgconfig, glib, libxml2, libintl
+, perl, bison2, flex, pkgconfig, glib, libxml2, libintl, libunwind
 }:
 
 stdenv.mkDerivation rec {
@@ -16,6 +16,7 @@ stdenv.mkDerivation rec {
   outputs = [ "out" "dev" ];
 
   nativeBuildInputs = [ autoreconfHook flex perl pkgconfig libintl bison2 glib ];
+  buildInputs = stdenv.lib.optional stdenv.isDarwin libunwind;
   propagatedBuildInputs = [ glib libxml2 ];
 
   patches = [
diff --git a/pkgs/development/libraries/gstreamer/libav/default.nix b/pkgs/development/libraries/gstreamer/libav/default.nix
index 7f7393bba28..297c8ada884 100644
--- a/pkgs/development/libraries/gstreamer/libav/default.nix
+++ b/pkgs/development/libraries/gstreamer/libav/default.nix
@@ -10,7 +10,7 @@ assert withSystemLibav -> libav != null;
 
 stdenv.mkDerivation rec {
   name = "gst-libav-${version}";
-  version = "1.14.4";
+  version = "1.16.0";
 
   meta = {
     homepage = https://gstreamer.freedesktop.org;
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gst-libav/${name}.tar.xz";
-    sha256 = "1nk5g24z2xx5kaw5cg8dv8skdc516inahmkymcz8bxqxj28qbmyz";
+    sha256 = "16ixqpfrr7plaaz14n3vagr2q5xbfkv7gpmcsyndrkx98f813b6z";
   };
 
   outputs = [ "out" "dev" ];
@@ -34,4 +34,10 @@ stdenv.mkDerivation rec {
     [ gst-plugins-base orc bzip2 ]
     ++ optional withSystemLibav libav
     ;
+
+  mesonFlags = [
+    # Enables all features, so that we know when new dependencies are necessary.
+    "-Dauto_features=enabled"
+  ];
+
 }
diff --git a/pkgs/development/libraries/gstreamer/rtsp-server/default.nix b/pkgs/development/libraries/gstreamer/rtsp-server/default.nix
index 6236edec6a4..c4620a29e94 100644
--- a/pkgs/development/libraries/gstreamer/rtsp-server/default.nix
+++ b/pkgs/development/libraries/gstreamer/rtsp-server/default.nix
@@ -1,10 +1,12 @@
 { stdenv, fetchurl, meson, ninja, pkgconfig
-, gst-plugins-base, gettext, gobject-introspection
+, gettext, gobject-introspection
+, gst-plugins-base
+, gst-plugins-bad
 }:
 
 stdenv.mkDerivation rec {
   name = "gst-rtsp-server-${version}";
-  version = "1.14.4";
+  version = "1.16.0";
 
   meta = with stdenv.lib; {
     description = "Gstreamer RTSP server";
@@ -19,12 +21,18 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gst-rtsp-server/${name}.tar.xz";
-    sha256 = "1wc4d0y57hpfvv9sykjg8mxj86dw60mf696fbqbiqq6dzlmcw3ix";
+    sha256 = "069zy159izy50blci9fli1i2r8jh91qkmgrz1n0xqciy3bn9x3hr";
   };
 
   outputs = [ "out" "dev" ];
 
   nativeBuildInputs = [ meson ninja gettext gobject-introspection pkgconfig ];
 
-  buildInputs = [ gst-plugins-base ];
+  buildInputs = [ gst-plugins-base gst-plugins-bad ];
+
+  mesonFlags = [
+    # Enables all features, so that we know when new dependencies are necessary.
+    "-Dauto_features=enabled"
+    "-Dexamples=disabled" # requires many dependencies and probably not useful for our users
+  ];
 }
diff --git a/pkgs/development/libraries/gstreamer/ugly/default.nix b/pkgs/development/libraries/gstreamer/ugly/default.nix
index 0cdfd1f4a7b..5c3a56814ba 100644
--- a/pkgs/development/libraries/gstreamer/ugly/default.nix
+++ b/pkgs/development/libraries/gstreamer/ugly/default.nix
@@ -2,12 +2,13 @@
 , gst-plugins-base, orc, gettext
 , a52dec, libcdio, libdvdread
 , libmad, libmpeg2, x264, libintl, lib
+, opencore-amr
 , darwin
 }:
 
 stdenv.mkDerivation rec {
   name = "gst-plugins-ugly-${version}";
-  version = "1.14.4";
+  version = "1.16.0";
 
   meta = with lib; {
     description = "Gstreamer Ugly Plugins";
@@ -25,7 +26,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gst-plugins-ugly/${name}.tar.xz";
-    sha256 = "08vd1xgwmapnviah47zv5h2r02qdd20y4f07rvv5zhv6y4vxh0mc";
+    sha256 = "1hm46c1fy9vl1wfwipsj41zp79cm7in1fpmjw24j5hriy32n82g3";
   };
 
   outputs = [ "out" "dev" ];
@@ -37,8 +38,16 @@ stdenv.mkDerivation rec {
     a52dec libcdio libdvdread
     libmad libmpeg2 x264
     libintl
+    opencore-amr
   ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks;
     [ IOKit CoreFoundation DiskArbitration ]);
 
+  mesonFlags = [
+    # Enables all features, so that we know when new dependencies are necessary.
+    "-Dauto_features=enabled"
+    "-Dexamples=disabled" # requires many dependencies and probably not useful for our users
+    "-Dsidplay=disabled" # sidplay / sidplay/player.h isn't packaged in nixpkgs as of writing
+  ];
+
   NIX_LDFLAGS = [ "-lm" ];
 }
diff --git a/pkgs/development/libraries/gstreamer/vaapi/default.nix b/pkgs/development/libraries/gstreamer/vaapi/default.nix
index e84f8dce912..c0541857e8b 100644
--- a/pkgs/development/libraries/gstreamer/vaapi/default.nix
+++ b/pkgs/development/libraries/gstreamer/vaapi/default.nix
@@ -5,11 +5,11 @@
 
 stdenv.mkDerivation rec {
   name = "gst-vaapi-${version}";
-  version = "1.14.4";
+  version = "1.16.0";
 
   src = fetchurl {
     url = "${meta.homepage}/src/gstreamer-vaapi/gstreamer-vaapi-${version}.tar.xz";
-    sha256 = "18yha6119v7mwz47idv2vykzfssqfmh6hc824wqqsshwjvzdn66f";
+    sha256 = "07qpynamiz0lniqajcaijh3n7ixs4lfk9a5mfk50sng0dricwzsf";
   };
 
   outputs = [ "out" "dev" ];
@@ -27,6 +27,12 @@ stdenv.mkDerivation rec {
     mkdir -p $GST_PLUGIN_PATH_1_0
   '';
 
+  mesonFlags = [
+    # Enables all features, so that we know when new dependencies are necessary.
+    "-Dauto_features=enabled"
+    "-Dexamples=disabled" # requires many dependencies and probably not useful for our users
+  ];
+
   meta = {
     homepage = https://gstreamer.freedesktop.org;
     license = stdenv.lib.licenses.lgpl21Plus;
diff --git a/pkgs/development/libraries/gstreamer/validate/default.nix b/pkgs/development/libraries/gstreamer/validate/default.nix
index 916185bf7ec..06d275078f3 100644
--- a/pkgs/development/libraries/gstreamer/validate/default.nix
+++ b/pkgs/development/libraries/gstreamer/validate/default.nix
@@ -4,7 +4,7 @@
 
 stdenv.mkDerivation rec {
   name = "gst-validate-${version}";
-  version = "1.14.4";
+  version = "1.16.0";
 
   meta = {
     description = "Integration testing infrastructure for the GStreamer framework";
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/src/gst-validate/${name}.tar.xz";
-    sha256 = "1ismv4i7ldi04swq76pcpd5apxqd52yify5hvlyan2yw9flwrp0q";
+    sha256 = "1jfnd0g9hmdbqfxsx96yc9vpf1w6m33hqwrr6lj4i83kl54awcck";
   };
 
   outputs = [ "out" "dev" ];
@@ -31,4 +31,9 @@ stdenv.mkDerivation rec {
   propagatedBuildInputs = [ gstreamer gst-plugins-base ];
 
   enableParallelBuilding = true;
+
+  mesonFlags = [
+    # Enables all features, so that we know when new dependencies are necessary.
+    "-Dauto_features=enabled"
+  ];
 }
diff --git a/pkgs/development/libraries/gthree/default.nix b/pkgs/development/libraries/gthree/default.nix
new file mode 100644
index 00000000000..6588b8ab440
--- /dev/null
+++ b/pkgs/development/libraries/gthree/default.nix
@@ -0,0 +1,72 @@
+{ stdenv
+, fetchFromGitHub
+, fetchpatch
+, ninja
+, meson
+, pkgconfig
+, gobject-introspection
+, gtk-doc
+, docbook_xsl
+, docbook_xml_dtd_43
+, glib
+, gtk3
+, graphene
+, epoxy
+, json-glib
+}:
+
+stdenv.mkDerivation rec {
+  pname = "gthree";
+  version = "unstable-2019-08-21";
+
+  outputs = [ "out" "dev" "devdoc" ];
+
+  src = fetchFromGitHub {
+    owner = "alexlarsson";
+    repo = "gthree";
+    rev = "dac46b0f35e29319c004c7e17b5f345ef4c04cb8";
+    sha256 = "16ixis2g04000zffm44s7ir64vn3byz9a793g2s76aasqybl86i2";
+  };
+
+  patches = [
+    # correctly declare json-glib in .pc file
+    # https://github.com/alexlarsson/gthree/pull/61
+    (fetchpatch {
+      url = https://github.com/alexlarsson/gthree/commit/784b1f20e0b6eb15f113a51f74c2cba871249861.patch;
+      sha256 = "07vxafaxris5a98w751aw04nlw0l45np1lba08xd16wdzmkadz0x";
+    })
+  ];
+
+  nativeBuildInputs = [
+    ninja
+    meson
+    pkgconfig
+    gtk-doc
+    docbook_xsl
+    docbook_xml_dtd_43
+    gobject-introspection
+  ];
+
+  buildInputs = [
+    epoxy
+  ];
+
+  propagatedBuildInputs = [
+    glib
+    gtk3
+    graphene
+    json-glib
+  ];
+
+  mesonFlags = [
+    "-Dgtk_doc=${if stdenv.isDarwin then "false" else "true"}"
+  ];
+
+  meta = with stdenv.lib; {
+    description = "GObject/GTK port of three.js";
+    homepage = https://github.com/alexlarsson/gthree;
+    license = licenses.mit;
+    maintainers = with maintainers; [ jtojnar ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/gtk+/01-build-Fix-path-handling-in-pkgconfig.patch b/pkgs/development/libraries/gtk+/01-build-Fix-path-handling-in-pkgconfig.patch
new file mode 100644
index 00000000000..ec69a12514f
--- /dev/null
+++ b/pkgs/development/libraries/gtk+/01-build-Fix-path-handling-in-pkgconfig.patch
@@ -0,0 +1,30 @@
+From 7b692e618c4183a51af3d3b0037f106c4fec2355 Mon Sep 17 00:00:00 2001
+From: worldofpeace <worldofpeace@protonmail.ch>
+Date: Fri, 19 Jul 2019 13:32:57 -0400
+Subject: [PATCH] build: Fix path handling in pkgconfig
+
+---
+ meson.build | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/meson.build b/meson.build
+index 36913b3f04..161b378ba5 100644
+--- a/meson.build
++++ b/meson.build
+@@ -834,10 +834,10 @@ configure_file(input: 'config.h.meson',
+ # pkg-config files - bit of a mess all of this
+ pkgconf = configuration_data()
+ 
+-pkgconf.set('prefix', get_option('prefix'))
++pkgconf.set('prefix', gtk_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', gtk_libdir)
++pkgconf.set('includedir', join_paths('${prefix}', gtk_includedir))
+ pkgconf.set('GTK_API_VERSION', gtk_api_version)
+ pkgconf.set('VERSION', meson.project_version())
+ pkgconf.set('GTK_BINARY_VERSION', gtk_binary_version)
+-- 
+2.22.0
+
diff --git a/pkgs/development/libraries/gtk+/2.x.nix b/pkgs/development/libraries/gtk+/2.x.nix
index 8dad69eb998..886f0aefafb 100644
--- a/pkgs/development/libraries/gtk+/2.x.nix
+++ b/pkgs/development/libraries/gtk+/2.x.nix
@@ -1,5 +1,5 @@
 { config, stdenv, fetchurl, pkgconfig, gettext, glib, atk, pango, cairo, perl, xorg
-, gdk_pixbuf, xlibsWrapper, gobject-introspection
+, gdk-pixbuf, xlibsWrapper, gobject-introspection
 , xineramaSupport ? stdenv.isLinux
 , cupsSupport ? config.gtk2.cups or stdenv.isLinux, cups ? null
 , gdktarget ? if stdenv.isDarwin then "quartz" else "x11"
@@ -41,7 +41,7 @@ stdenv.mkDerivation rec {
   ];
 
   propagatedBuildInputs = with xorg;
-    [ glib cairo pango gdk_pixbuf atk ]
+    [ glib cairo pango gdk-pixbuf atk ]
     ++ optionals (stdenv.isLinux || stdenv.isDarwin) [
          libXrandr libXrender libXcomposite libXi libXcursor
        ]
diff --git a/pkgs/development/libraries/gtk+/3.x.nix b/pkgs/development/libraries/gtk+/3.x.nix
index 30b33c7aea9..94b745794f1 100644
--- a/pkgs/development/libraries/gtk+/3.x.nix
+++ b/pkgs/development/libraries/gtk+/3.x.nix
@@ -1,32 +1,61 @@
-{ stdenv, fetchurl, fetchpatch, pkgconfig, gettext, perl, makeWrapper, shared-mime-info, isocodes
-, expat, glib, cairo, pango, gdk_pixbuf, atk, at-spi2-atk, gobject-introspection, fribidi
-, xorg, epoxy, json-glib, libxkbcommon, gmp, gnome3, autoreconfHook, gsettings-desktop-schemas
+{ stdenv
+, fetchurl
+, fetchpatch
+, pkgconfig
+, gettext
+, meson
+, ninja
+, python3
+, makeWrapper
+, shared-mime-info
+, isocodes
+, expat
+, glib
+, cairo
+, pango
+, gdk-pixbuf
+, atk
+, at-spi2-atk
+, gobject-introspection
+, fribidi
+, xorg
+, epoxy
+, json-glib
+, libxkbcommon
+, gmp
+, gnome3
+, hicolor-icon-theme
+, gsettings-desktop-schemas
+, sassc
 , x11Support ? stdenv.isLinux
-, waylandSupport ? stdenv.isLinux, mesa_noglu, wayland, wayland-protocols
+, waylandSupport ? stdenv.isLinux
+, mesa
+, wayland
+, wayland-protocols
 , xineramaSupport ? stdenv.isLinux
-, cupsSupport ? stdenv.isLinux, cups ? null
-, AppKit, Cocoa
+, cupsSupport ? stdenv.isLinux
+, cups ? null
+, AppKit
+, Cocoa
 }:
 
 assert cupsSupport -> cups != null;
 
 with stdenv.lib;
 
-let
-  version = "3.24.8";
-in
 stdenv.mkDerivation rec {
-  name = "gtk+3-${version}";
-
-  src = fetchurl {
-    url = "mirror://gnome/sources/gtk+/${stdenv.lib.versions.majorMinor version}/gtk+-${version}.tar.xz";
-    sha256 = "16f71bbkhwhndcsrpyhjia3b77cb5ksf5c45lyfgws4pkgg64sb6";
-  };
+  pname = "gtk+3";
+  version = "3.24.10";
 
   outputs = [ "out" "dev" ];
   outputBin = "dev";
 
-  nativeBuildInputs = [ pkgconfig gettext gobject-introspection perl makeWrapper autoreconfHook ];
+  setupHook = ./gtk3-setup-hook.sh;
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/gtk+/${stdenv.lib.versions.majorMinor version}/gtk+-${version}.tar.xz";
+    sha256 = "00qvq1r96ikdalv7xzgng1kad9i0rcahqk01gwhxl3xrw83z3a1m";
+  };
 
   patches = [
     ./3.0-immodules.cache.patch
@@ -35,6 +64,8 @@ stdenv.mkDerivation rec {
       url = "https://bug757142.bugzilla-attachments.gnome.org/attachment.cgi?id=344123";
       sha256 = "0g6fhqcv8spfy3mfmxpyji93k8d4p4q4fz1v9a1c1cgcwkz41d7p";
     })
+    # https://gitlab.gnome.org/GNOME/gtk/merge_requests/1002
+    ./01-build-Fix-path-handling-in-pkgconfig.patch
   ] ++ optionals stdenv.isDarwin [
     # X11 module requires <gio/gdesktopappinfo.h> which is not installed on Darwin
     # let’s drop that dependency in similar way to how other parts of the library do it
@@ -42,39 +73,76 @@ stdenv.mkDerivation rec {
     ./3.0-darwin-x11.patch
   ];
 
-  buildInputs = [ libxkbcommon epoxy json-glib isocodes ]
-    ++ optional stdenv.isDarwin AppKit;
-  propagatedBuildInputs = with xorg; with stdenv.lib;
-    [ expat glib cairo pango gdk_pixbuf atk at-spi2-atk gsettings-desktop-schemas fribidi
-      libXrandr libXrender libXcomposite libXi libXcursor libSM libICE ]
-    ++ optional stdenv.isDarwin Cocoa  # explicitly propagated, always needed
-    ++ optionals waylandSupport [ mesa_noglu wayland wayland-protocols ]
-    ++ optional xineramaSupport libXinerama
-    ++ optional cupsSupport cups;
-  #TODO: colord?
+  mesonFlags = [
+    "-Dtests=false"
+  ];
+
+  postPatch = ''
+    files=(
+      build-aux/meson/post-install.py
+      demos/gtk-demo/geninclude.py
+      gdk/broadway/gen-c-array.py
+      gdk/gen-gdk-gresources-xml.py
+      gtk/cursor/dnd-copy.png
+      gtk/gen-gtk-gresources-xml.py
+      gtk/gen-rc.py
+      gtk/gentypefuncs.py
+    )
+
+    chmod +x ''${files[@]}
+    patchShebangs ''${files[@]}
+  '';
 
-  # demos fail to install, no idea where's the problem
-  preConfigure = "sed '/^SRC_SUBDIRS /s/demos//' -i Makefile.in";
-
-  enableParallelBuilding = true;
-
-  configureFlags = optional stdenv.isDarwin [
-    "--disable-debug"
-    "--disable-dependency-tracking"
-    "--disable-glibtest"
-  ] ++ optional (stdenv.isDarwin && !x11Support)
-    "--enable-quartz-backend"
-    ++ optional x11Support [
-    "--enable-x11-backend"
-  ] ++ optional waylandSupport [
-    "--enable-wayland-backend"
+  nativeBuildInputs = [
+    gettext
+    gobject-introspection
+    hicolor-icon-theme # setup-hook
+    makeWrapper
+    meson
+    ninja
+    pkgconfig
+    python3
+    sassc
+    setupHook
   ];
 
+  buildInputs = [
+    libxkbcommon
+    epoxy
+    json-glib
+    isocodes
+  ]
+  ++ optional stdenv.isDarwin AppKit
+  ;
+
+  propagatedBuildInputs = with xorg; [
+    at-spi2-atk
+    atk
+    cairo
+    expat
+    fribidi
+    gdk-pixbuf
+    glib
+    gsettings-desktop-schemas
+    libICE
+    libSM
+    libXcomposite
+    libXcursor
+    libXi
+    libXrandr
+    libXrender
+    pango
+  ]
+  ++ optional stdenv.isDarwin Cocoa  # explicitly propagated, always needed
+  ++ optionals waylandSupport [ mesa wayland wayland-protocols ]
+  ++ optional xineramaSupport libXinerama
+  ++ optional cupsSupport cups
+  ;
+  #TODO: colord?
+
   doCheck = false; # needs X11
 
   postInstall = optionalString (!stdenv.isDarwin) ''
-    substituteInPlace "$out/lib/gtk-3.0/3.0.0/printbackends/libprintbackend-cups.la" \
-      --replace '-L${gmp.dev}/lib' '-L${gmp.out}/lib'
     # The updater is needed for nixos env and it's tiny.
     moveToOutput bin/gtk-update-icon-cache "$out"
     # Launcher
@@ -86,6 +154,16 @@ stdenv.mkDerivation rec {
     done
   '';
 
+  # Wrap demos
+  postFixup =  optionalString (!stdenv.isDarwin) ''
+    demos=(gtk3-demo gtk3-demo-application gtk3-icon-browser gtk3-widget-factory)
+
+    for program in ''${demos[@]}; do
+      wrapProgram $dev/bin/$program \
+        --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH:$out/share/gsettings-schemas/${pname}-${version}"
+    done
+  '';
+
   passthru = {
     updateScript = gnome3.updateScript {
       packageName = "gtk+";
@@ -93,9 +171,8 @@ stdenv.mkDerivation rec {
     };
   };
 
-  meta = with stdenv.lib; {
+  meta = {
     description = "A multi-platform toolkit for creating graphical user interfaces";
-
     longDescription = ''
       GTK+ is a highly usable, feature rich toolkit for creating
       graphical user interfaces which boasts cross platform
@@ -106,11 +183,8 @@ stdenv.mkDerivation rec {
       proprietary software with GTK+ without any license fees or
       royalties.
     '';
-
     homepage = https://www.gtk.org/;
-
     license = licenses.lgpl2Plus;
-
     maintainers = with maintainers; [ raskin vcunat lethalman ];
     platforms = platforms.all;
   };
diff --git a/pkgs/development/libraries/gtk+/gtk3-setup-hook.sh b/pkgs/development/libraries/gtk+/gtk3-setup-hook.sh
new file mode 100644
index 00000000000..bddeb2d25d5
--- /dev/null
+++ b/pkgs/development/libraries/gtk+/gtk3-setup-hook.sh
@@ -0,0 +1,10 @@
+fixupOutputHooks+=(_gtk3CleanComments)
+
+# Clean comments that link to generator of the file
+_gtk3CleanComments() {
+    local f="$prefix/lib/gtk-3.0/3.0.0/immodules.cache"
+    if [ -f "$f" ]; then
+        sed 's|Created by .*bin/gtk-query-|Created by bin/gtk-query-|' -i "$f"
+    fi
+}
+
diff --git a/pkgs/development/libraries/gtkd/default.nix b/pkgs/development/libraries/gtkd/default.nix
index b69e99e0fb8..c2f05b51a65 100644
--- a/pkgs/development/libraries/gtkd/default.nix
+++ b/pkgs/development/libraries/gtkd/default.nix
@@ -1,7 +1,9 @@
-{ stdenv, fetchzip, atk, cairo, dmd, gdk_pixbuf, gnome3, gst_all_1, librsvg
-, pango, pkgconfig, which, vte }:
+{ stdenv, fetchzip, atk, cairo, dmd, gdk-pixbuf, gnome3, gst_all_1, librsvg
+, glib, gtk3, gtksourceview, libgda, libpeas, pango, pkgconfig, which, vte }:
 
-stdenv.mkDerivation rec {
+let
+  inherit (gst_all_1) gstreamer gst-plugins-base;
+in stdenv.mkDerivation rec {
   name = "gtkd-${version}";
   version = "3.8.5";
 
@@ -13,7 +15,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ dmd pkgconfig which ];
   propagatedBuildInputs = [
-    atk cairo gdk_pixbuf glib gstreamer gst_plugins_base gtk3 gtksourceview
+    atk cairo gdk-pixbuf glib gstreamer gst-plugins-base gtk3 gtksourceview
     libgda libpeas librsvg pango vte
   ];
 
@@ -26,8 +28,8 @@ stdenv.mkDerivation rec {
       --replace libcairo.so.2 ${cairo}/lib/libcairo.so.2 \
       --replace libcairo.dylib ${cairo}/lib/libcairo.dylib
     substituteInPlace generated/gtkd/gdkpixbuf/c/functions.d \
-      --replace libgdk_pixbuf-2.0.so.0 ${gdk_pixbuf}/lib/libgdk_pixbuf-2.0.so.0 \
-      --replace libgdk_pixbuf-2.0.0.dylib ${gdk_pixbuf}/lib/libgdk_pixbuf-2.0.0.dylib
+      --replace libgdk_pixbuf-2.0.so.0 ${gdk-pixbuf}/lib/libgdk_pixbuf-2.0.so.0 \
+      --replace libgdk_pixbuf-2.0.0.dylib ${gdk-pixbuf}/lib/libgdk_pixbuf-2.0.0.dylib
     substituteInPlace generated/gtkd/atk/c/functions.d \
       --replace libatk-1.0.so.0 ${atk}/lib/libatk-1.0.so.0 \
       --replace libatk-1.0.0.dylib ${atk}/lib/libatk-1.0.0.dylib
@@ -57,8 +59,8 @@ stdenv.mkDerivation rec {
       --replace libvte-2.91.so.0 ${vte}/lib/libvte-2.91.so.0 \
       --replace libvte-2.91.0.dylib ${vte}/lib/libvte-2.91.0.dylib
     substituteInPlace generated/gstreamer/gstinterfaces/c/functions.d \
-      --replace libgstvideo-1.0.so.0 ${gst_plugins_base}/lib/libgstvideo-1.0.so.0 \
-      --replace libgstvideo-1.0.0.dylib ${gst_plugins_base}/lib/libgstvideo-1.0.0.dylib
+      --replace libgstvideo-1.0.so.0 ${gst-plugins-base}/lib/libgstvideo-1.0.so.0 \
+      --replace libgstvideo-1.0.0.dylib ${gst-plugins-base}/lib/libgstvideo-1.0.0.dylib
     substituteInPlace generated/sourceview/gsv/c/functions.d \
       --replace libgtksourceview-3.0.so.1 ${gtksourceview}/lib/libgtksourceview-3.0.so.1 \
       --replace libgtksourceview-3.0.1.dylib ${gtksourceview}/lib/libgtksourceview-3.0.1.dylib
@@ -84,11 +86,6 @@ stdenv.mkDerivation rec {
 
   installFlags = "prefix=$(out)";
 
-  inherit atk cairo gdk_pixbuf librsvg pango;
-  inherit (gnome3) glib gtk3 gtksourceview libgda libpeas;
-  inherit (gst_all_1) gstreamer;
-  gst_plugins_base = gst_all_1.gst-plugins-base;
-
   meta = with stdenv.lib; {
     description = "D binding and OO wrapper for GTK+";
     homepage = https://gtkd.org;
diff --git a/pkgs/development/libraries/gvfs/default.nix b/pkgs/development/libraries/gvfs/default.nix
index d9163c97cb7..60188d77962 100644
--- a/pkgs/development/libraries/gvfs/default.nix
+++ b/pkgs/development/libraries/gvfs/default.nix
@@ -9,13 +9,13 @@
 
 let
   pname = "gvfs";
-  version = "1.40.1";
+  version = "1.40.2";
 in stdenv.mkDerivation rec {
   name = "${pname}-${version}";
 
   src = fetchurl {
     url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${name}.tar.xz";
-    sha256 = "1cfnzamr4mvgpf6yhm28lh9cafy9z6842s8jpbqnfizfxybg8ylj";
+    sha256 = "07lpcfric3h0302n9b1pwa38mjb76r9s98kg2867y2d1qvzfivxx";
   };
 
   postPatch = ''
diff --git a/pkgs/development/libraries/harfbuzz/default.nix b/pkgs/development/libraries/harfbuzz/default.nix
index a405633c1b8..26a3428f679 100644
--- a/pkgs/development/libraries/harfbuzz/default.nix
+++ b/pkgs/development/libraries/harfbuzz/default.nix
@@ -8,7 +8,7 @@
 }:
 
 let
-  version = "2.5.1";
+  version = "2.5.3";
   inherit (stdenv.lib) optional optionals optionalString;
 in
 
@@ -17,7 +17,7 @@ stdenv.mkDerivation {
 
   src = fetchurl {
     url = "https://www.freedesktop.org/software/harfbuzz/release/harfbuzz-${version}.tar.xz";
-    sha256 = "17kiyq23g7bnjvyn2yg4gyr7i7qjam65n20whsrplpxxk9bk8j3d";
+    sha256 = "0p45xk5bblsw8lfs7y7z80b4rvda9f2hlpr28flkrfmpjz3hvl7y";
   };
 
   postPatch = ''
diff --git a/pkgs/development/libraries/hpx/default.nix b/pkgs/development/libraries/hpx/default.nix
index c0028666482..99777bbd6f0 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.2.1";
+  version = "1.3.0";
 
   src = fetchFromGitHub {
     owner = "STEllAR-GROUP";
     repo = "hpx";
     rev = "${version}";
-    sha256 = "18dk9413qcgljdlw2jfkk21lwi4iwc57s41yqnc3jp8vdj96w32s";
+    sha256 = "0yzxb8520qh9rvzsa190yzx21jn3d8rl8ac5v01767ygd0413hfk";
   };
 
   buildInputs = [ boost hwloc gperftools ];
diff --git a/pkgs/development/libraries/hunspell/0001-Make-hunspell-look-in-XDG_DATA_DIRS-for-dictionaries.patch b/pkgs/development/libraries/hunspell/0001-Make-hunspell-look-in-XDG_DATA_DIRS-for-dictionaries.patch
new file mode 100644
index 00000000000..4607f8b8ee0
--- /dev/null
+++ b/pkgs/development/libraries/hunspell/0001-Make-hunspell-look-in-XDG_DATA_DIRS-for-dictionaries.patch
@@ -0,0 +1,37 @@
+From 8c67f314de2684d77315eecd99ef091d441f17dd Mon Sep 17 00:00:00 2001
+From: Matthew Bauer <mjbauer95@gmail.com>
+Date: Wed, 24 Jul 2019 15:35:18 -0400
+Subject: [PATCH] Make hunspell look in XDG_DATA_DIRS for dictionaries
+
+Some dictionaries may exist but only show up under XDG_DATA_DIRS. For
+instance, $HOME/.local/share/hunspell could contain some dictionaries.
+
+This patch adds each directory in the hunspell subdir of each
+XDG_DATA_DIRS to the lookup path.
+
+Upstream pr is available at: https://github.com/hunspell/hunspell/pull/637
+---
+ src/tools/hunspell.cxx | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/src/tools/hunspell.cxx b/src/tools/hunspell.cxx
+index 690e34a..6cd127e 100644
+--- a/src/tools/hunspell.cxx
++++ b/src/tools/hunspell.cxx
+@@ -2044,6 +2044,13 @@ int main(int argc, char** argv) {
+     if (getenv("DICPATH")) {
+       path_std_str.append(getenv("DICPATH")).append(PATHSEP);
+     }
++    if (getenv("XDG_DATA_DIRS")) {
++      char* dir = strtok(getenv("XDG_DATA_DIRS"), ":");
++      while (dir != NULL) {
++        path_std_str.append(dir).append("/hunspell:");
++        dir = strtok(NULL, ":");
++      }
++    }
+     path_std_str.append(LIBDIR).append(PATHSEP);
+     if (HOME) {
+       const char * userooodir[] = USEROOODIR;
+-- 
+2.22.0
+
diff --git a/pkgs/development/libraries/hunspell/default.nix b/pkgs/development/libraries/hunspell/default.nix
index 3728c05e516..18e32585ce2 100644
--- a/pkgs/development/libraries/hunspell/default.nix
+++ b/pkgs/development/libraries/hunspell/default.nix
@@ -14,6 +14,8 @@ stdenv.mkDerivation rec {
   buildInputs = [ ncurses readline ];
   nativeBuildInputs = [ autoreconfHook ];
 
+  patches = [ ./0001-Make-hunspell-look-in-XDG_DATA_DIRS-for-dictionaries.patch ];
+
   postPatch = ''
     patchShebangs tests
   '';
diff --git a/pkgs/development/libraries/hunspell/dictionaries.nix b/pkgs/development/libraries/hunspell/dictionaries.nix
index b8de133f502..b9a283d80d2 100644
--- a/pkgs/development/libraries/hunspell/dictionaries.nix
+++ b/pkgs/development/libraries/hunspell/dictionaries.nix
@@ -286,10 +286,11 @@ let
       };
     };
 
-in {
+in rec {
 
   /* ENGLISH */
 
+  en_US = en-us;
   en-us = mkDictFromWordlist {
     shortName = "en-us";
     shortDescription = "English (United States)";
@@ -300,6 +301,7 @@ in {
     };
   };
 
+  en_CA = en-ca;
   en-ca = mkDictFromWordlist {
     shortName = "en-ca";
     shortDescription = "English (Canada)";
@@ -310,6 +312,18 @@ in {
     };
   };
 
+  en-au = mkDictFromWordlist {
+    shortName = "en-au";
+    shortDescription = "English (Australia)";
+    dictFileName = "en_AU";
+    src = fetchurl {
+      url = mirror://sourceforge/wordlist/speller/2018.04.16/hunspell-en_AU-2018.04.16.zip;
+      sha256 = "1kp06npl1kd05mm9r52cg2iwc13x02zwqgpibdw15b6x43agg6f5";
+    };
+  };
+  en_AU = en-au;
+
+  en_GB-ise = en-gb-ise;
   en-gb-ise = mkDictFromWordlist {
     shortName = "en-gb-ise";
     shortDescription = "English (United Kingdom, 'ise' ending)";
@@ -320,6 +334,7 @@ in {
     };
   };
 
+  en_GB-ize = en-gb-ize;
   en-gb-ize = mkDictFromWordlist {
     shortName = "en-gb-ize";
     shortDescription = "English (United Kingdom, 'ize' ending)";
@@ -332,126 +347,147 @@ in {
 
   /* SPANISH */
 
+  es_ANY = es-any;
   es-any = mkDictFromRla {
     shortName = "es-any";
     shortDescription = "Spanish (any variant)";
     dictFileName = "es_ANY";
   };
 
+  es_AR = es-ar;
   es-ar = mkDictFromRla {
     shortName = "es-ar";
     shortDescription = "Spanish (Argentina)";
     dictFileName = "es_AR";
   };
 
+  es_BO = es-bo;
   es-bo = mkDictFromRla {
     shortName = "es-bo";
     shortDescription = "Spanish (Bolivia)";
     dictFileName = "es_BO";
   };
 
+  es_CL = es-cl;
   es-cl = mkDictFromRla {
     shortName = "es-cl";
     shortDescription = "Spanish (Chile)";
     dictFileName = "es_CL";
   };
 
+  es_CO = es-co;
   es-co = mkDictFromRla {
     shortName = "es-co";
     shortDescription = "Spanish (Colombia)";
     dictFileName = "es_CO";
   };
 
+  es_CR = es-cr;
   es-cr = mkDictFromRla {
     shortName = "es-cr";
     shortDescription = "Spanish (Costra Rica)";
     dictFileName = "es_CR";
   };
 
+  es_CU = es-cu;
   es-cu = mkDictFromRla {
     shortName = "es-cu";
     shortDescription = "Spanish (Cuba)";
     dictFileName = "es_CU";
   };
 
+  es_DO = es-do;
   es-do = mkDictFromRla {
     shortName = "es-do";
     shortDescription = "Spanish (Dominican Republic)";
     dictFileName = "es_DO";
   };
 
+  es_EC = es-ec;
   es-ec = mkDictFromRla {
     shortName = "es-ec";
     shortDescription = "Spanish (Ecuador)";
     dictFileName = "es_EC";
   };
 
+  es_ES = es-es;
   es-es = mkDictFromRla {
     shortName = "es-es";
     shortDescription = "Spanish (Spain)";
     dictFileName = "es_ES";
   };
 
+  es_GT = es-gt;
   es-gt = mkDictFromRla {
     shortName = "es-gt";
     shortDescription = "Spanish (Guatemala)";
     dictFileName = "es_GT";
   };
 
+  es_HN = es-hn;
   es-hn = mkDictFromRla {
     shortName = "es-hn";
     shortDescription = "Spanish (Honduras)";
     dictFileName = "es_HN";
   };
 
+  es_MX = es-mx;
   es-mx = mkDictFromRla {
     shortName = "es-mx";
     shortDescription = "Spanish (Mexico)";
     dictFileName = "es_MX";
   };
 
+  es_NI = es-ni;
   es-ni = mkDictFromRla {
     shortName = "es-ni";
     shortDescription = "Spanish (Nicaragua)";
     dictFileName = "es_NI";
   };
 
+  es_PA = es-pa;
   es-pa = mkDictFromRla {
     shortName = "es-pa";
     shortDescription = "Spanish (Panama)";
     dictFileName = "es_PA";
   };
 
+  es_PE = es-pe;
   es-pe = mkDictFromRla {
     shortName = "es-pe";
     shortDescription = "Spanish (Peru)";
     dictFileName = "es_PE";
   };
 
+  es_PR = es-pr;
   es-pr = mkDictFromRla {
     shortName = "es-pr";
     shortDescription = "Spanish (Puerto Rico)";
     dictFileName = "es_PR";
   };
 
+  es_PY = es-py;
   es-py = mkDictFromRla {
     shortName = "es-py";
     shortDescription = "Spanish (Paraguay)";
     dictFileName = "es_PY";
   };
 
+  es_SV = es-sv;
   es-sv = mkDictFromRla {
     shortName = "es-sv";
     shortDescription = "Spanish (El Salvador)";
     dictFileName = "es_SV";
   };
 
+  es_UY = es-uy;
   es-uy = mkDictFromRla {
     shortName = "es-uy";
     shortDescription = "Spanish (Uruguay)";
     dictFileName = "es_UY";
   };
 
+  es_VE = es-ve;
   es-ve = mkDictFromRla {
     shortName = "es-ve";
     shortDescription = "Spanish (Venezuela)";
@@ -505,6 +541,7 @@ in {
 
   /* ITALIAN */
 
+  it_IT = it-it;
   it-it =  mkDictFromLinguistico rec {
     shortName = "it-it";
     dictFileName = "it_IT";
@@ -517,6 +554,7 @@ in {
 
   /* BASQUE */
 
+  eu_ES = eu-es;
   eu-es = mkDictFromXuxen {
     shortName = "eu-es";
     dictFileName = "eu_ES";
@@ -549,6 +587,7 @@ in {
 
   /* HUNGARIAN */
 
+  hu_HU = hu-hu;
   hu-hu = mkDictFromLibreOffice {
     shortName = "hu-hu";
     dictFileName = "hu_HU";
@@ -557,7 +596,8 @@ in {
   };
 
   /* SWEDISH */
-  
+
+  sv_SE = sv-se;
   sv-se = mkDictFromDSSO rec {
     shortName = "sv-se";
     dictFileName = "sv_SE";
@@ -565,26 +605,30 @@ in {
   };
 
   # Finlandian Swedish (hello Linus Torvalds)
+  sv_FI = sv-fi;
   sv-fi = mkDictFromDSSO rec {
     shortName = "sv-fi";
     dictFileName = "sv_FI";
     shortDescription = "Swedish (Finland)";
   };
-  
+
   /* GERMAN */
 
+  de_DE = de-de;
   de-de = mkDictFromJ3e {
     shortName = "de-de";
     shortDescription = "German (Germany)";
     dictFileName = "de_DE";
   };
 
+  de_AT = de-at;
   de-at = mkDictFromJ3e {
     shortName = "de-at";
     shortDescription = "German (Austria)";
     dictFileName = "de_AT";
   };
 
+  de_CH = de-ch;
   de-ch = mkDictFromJ3e {
     shortName = "de-ch";
     shortDescription = "German (Switzerland)";
@@ -593,6 +637,7 @@ in {
 
   /* UKRAINIAN */
 
+  uk_UA = uk-ua;
   uk-ua = mkDict rec {
     name = "hunspell-dict-uk-ua-${version}";
     version = "4.2.5";
diff --git a/pkgs/development/libraries/hwloc/default.nix b/pkgs/development/libraries/hwloc/default.nix
index 5866d6b8fed..0f4ce4e6b97 100644
--- a/pkgs/development/libraries/hwloc/default.nix
+++ b/pkgs/development/libraries/hwloc/default.nix
@@ -15,7 +15,7 @@ in stdenv.mkDerivation {
   inherit name;
 
   src = fetchurl {
-    url = "http://www.open-mpi.org/software/hwloc/v${versmm}/downloads/${name}.tar.bz2";
+    url = "https://www.open-mpi.org/software/hwloc/v${versmm}/downloads/${name}.tar.bz2";
     sha256 = "1aa7s208gdijk19vvzzahyl8pglk1va3yd6kdbpfa5pz5ms0ag35";
   };
 
@@ -78,7 +78,7 @@ in stdenv.mkDerivation {
        more.
     '';
 
-    # http://www.open-mpi.org/projects/hwloc/license.php
+    # https://www.open-mpi.org/projects/hwloc/license.php
     license = licenses.bsd3;
     homepage = https://www.open-mpi.org/projects/hwloc/;
     maintainers = with maintainers; [ fpletz markuskowa ];
diff --git a/pkgs/development/libraries/ilmbase/default.nix b/pkgs/development/libraries/ilmbase/default.nix
index 42cf7780262..2d22788e1ec 100644
--- a/pkgs/development/libraries/ilmbase/default.nix
+++ b/pkgs/development/libraries/ilmbase/default.nix
@@ -29,7 +29,7 @@ stdenv.mkDerivation rec {
   doCheck = stdenv.isx86_64;
 
   meta = with stdenv.lib; {
-    homepage = http://www.openexr.com/;
+    homepage = https://www.openexr.com/;
     license = licenses.bsd3;
     platforms = platforms.all;
   };
diff --git a/pkgs/development/libraries/imlib/default.nix b/pkgs/development/libraries/imlib/default.nix
index a6281156afa..e476bc22eca 100644
--- a/pkgs/development/libraries/imlib/default.nix
+++ b/pkgs/development/libraries/imlib/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, libX11, libXext, xorgproto, libjpeg, libungif, libtiff, libpng}:
+{stdenv, fetchurl, fetchpatch, libX11, libXext, xorgproto, libjpeg, libungif, libtiff, libpng}:
 
 stdenv.mkDerivation {
   name = "imlib-1.9.15";
@@ -7,6 +7,14 @@ stdenv.mkDerivation {
     sha256 = "0ggjxyvgp4pxc0b88v40xj9daz90518ydnycw7qax011gxpr12d3";
   };
 
+  patches = [
+    (fetchpatch {
+      name = "CVE-2007-3568.patch";
+      url = https://gitweb.gentoo.org/repo/gentoo.git/plain/media-libs/imlib/files/imlib-1.9.15-bpp16-CVE-2007-3568.patch;
+      sha256 = "0lxfibi094gki39sq1w4p0hcx25xlk0875agbhjkjngzx862wvbg";
+    })
+  ];
+
   configureFlags = [
     "--disable-shm"
     "--x-includes=${libX11.dev}/include"
diff --git a/pkgs/development/libraries/intel-gmmlib/default.nix b/pkgs/development/libraries/intel-gmmlib/default.nix
index 50e97bfbfdb..1212d3817d4 100644
--- a/pkgs/development/libraries/intel-gmmlib/default.nix
+++ b/pkgs/development/libraries/intel-gmmlib/default.nix
@@ -4,13 +4,13 @@
 
 stdenv.mkDerivation rec {
   name = "intel-gmmlib-${version}";
-  version = "19.1.2";
+  version = "19.2.3";
 
   src = fetchFromGitHub {
     owner  = "intel";
     repo   = "gmmlib";
     rev    = name;
-    sha256 = "1nw5qg10dqkchx39vqk9nkqggk0in2kr794dqjp73njpirixgr2b";
+    sha256 = "0hki53czv1na7h5b06fcwkd8bhn690ywg6dwjfs3x9fa4g48kqjb";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/intel-media-driver/default.nix b/pkgs/development/libraries/intel-media-driver/default.nix
index a362b1ac634..e549067b11f 100644
--- a/pkgs/development/libraries/intel-media-driver/default.nix
+++ b/pkgs/development/libraries/intel-media-driver/default.nix
@@ -5,18 +5,20 @@
 
 stdenv.mkDerivation rec {
   name = "intel-media-driver-${version}";
-  version = "19.1.0";
+  version = "19.2";
 
   src = fetchFromGitHub {
     owner  = "intel";
     repo   = "media-driver";
     rev    = "intel-media-${version}";
-    sha256 = "072ry87h1lds14fqb2sfz3n2sssvacamaxv2gj4nd8agnzbwizn7";
+    sha256 = "118cg1grzm62lppaygvh7mgxn23bicjkwjwpxhbyqs9g6yhdj3p8";
   };
 
   cmakeFlags = [
     "-DINSTALL_DRIVER_SYSCONF=OFF"
     "-DLIBVA_DRIVERS_PATH=${placeholder "out"}/lib/dri"
+    # Works only on hosts with suitable CPUs.
+    "-DMEDIA_RUN_TEST_SUITE=OFF"
   ];
 
   nativeBuildInputs = [ cmake pkgconfig ];
diff --git a/pkgs/development/libraries/itk/default.nix b/pkgs/development/libraries/itk/default.nix
index 6e393ba02ce..3577e7a8196 100644
--- a/pkgs/development/libraries/itk/default.nix
+++ b/pkgs/development/libraries/itk/default.nix
@@ -1,11 +1,14 @@
-{ stdenv, fetchurl, cmake, libX11, libuuid, xz, vtk }:
+{ stdenv, fetchFromGitHub, cmake, libX11, libuuid, xz, vtk, darwin }:
 
 stdenv.mkDerivation rec {
-  name = "itk-4.13.2";
+  pname = "itk";
+  version = "5.0.1";
 
-  src = fetchurl {
-    url = mirror://sourceforge/itk/InsightToolkit-4.13.2.tar.xz;
-    sha256 = "19cgfpd63gqrvc3m27m394gy2d7w79g5y6lvznb5qqr49lihbgns";
+  src = fetchFromGitHub {
+    owner = "InsightSoftwareConsortium";
+    repo = "ITK";
+    rev = "v${version}";
+    sha256 = "0dcjsn5frjnrphfgw8alnd2ahrvicpx2a2ngb5ixaa9anaicz9z1";
   };
 
   cmakeFlags = [
@@ -21,13 +24,12 @@ stdenv.mkDerivation rec {
   enableParallelBuilding = true;
 
   nativeBuildInputs = [ cmake xz ];
-  buildInputs = [ libX11 libuuid vtk ];
+  buildInputs = [ libX11 libuuid vtk ] ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ];
 
   meta = {
     description = "Insight Segmentation and Registration Toolkit";
     homepage = http://www.itk.org/;
     license = stdenv.lib.licenses.asl20;
     maintainers = with stdenv.lib.maintainers; [viric];
-    platforms = with stdenv.lib.platforms; linux ++ darwin;
   };
 }
diff --git a/pkgs/development/libraries/java/commons/lang/default.nix b/pkgs/development/libraries/java/commons/lang/default.nix
index e46f22fadfb..322cb486e93 100644
--- a/pkgs/development/libraries/java/commons/lang/default.nix
+++ b/pkgs/development/libraries/java/commons/lang/default.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  version = "3.6";
+  version = "3.9";
   name    = "commons-lang-${version}";
 
   src = fetchurl {
     url    = "mirror://apache/commons/lang/binaries/commons-lang3-${version}-bin.tar.gz";
-    sha256 = "0r1wdjw48k2mk2wzyq5c3cx2zmark4q9psw52ma6v2i0sh6a9il0";
+    sha256 = "0l0q1hnicvpbjmxl81ig3rwc212x5sdfnlg3cniwbmnx8fxjgbki";
   };
 
   installPhase = ''
diff --git a/pkgs/development/libraries/java/swt/default.nix b/pkgs/development/libraries/java/swt/default.nix
index 0dc9e8bd892..c2acd234893 100644
--- a/pkgs/development/libraries/java/swt/default.nix
+++ b/pkgs/development/libraries/java/swt/default.nix
@@ -1,6 +1,6 @@
 { stdenv, lib, fetchurl, unzip, jdk, pkgconfig, gtk2
 , libXt, libXtst, libXi, libGLU_combined, webkitgtk, libsoup, xorg
-, pango, gdk_pixbuf, glib
+, pango, gdk-pixbuf, glib
 }:
 
 let
@@ -38,7 +38,7 @@ in stdenv.mkDerivation rec {
   nativeBuildInputs = [ unzip pkgconfig ];
   buildInputs = [ jdk gtk2 libXt libXtst libXi libGLU_combined webkitgtk libsoup ];
 
-  NIX_LFLAGS = (map (x: "-L${lib.getLib x}/lib") [ xorg.libX11 pango gdk_pixbuf glib ]) ++
+  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" ];
 
   buildPhase = ''
diff --git a/pkgs/development/libraries/jsoncpp/default.nix b/pkgs/development/libraries/jsoncpp/default.nix
index b543d47a050..fa2b45ae948 100644
--- a/pkgs/development/libraries/jsoncpp/default.nix
+++ b/pkgs/development/libraries/jsoncpp/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   pname = "jsoncpp";
-  version = "1.8.4";
+  version = "1.9.0";
 
   src = fetchFromGitHub {
     owner = "open-source-parsers";
     repo = "jsoncpp";
     rev = version;
-    sha256 = "1z0gj7a6jypkijmpknis04qybs1hkd04d1arr3gy89lnxmp6qzlm";
+    sha256 = "10wnwlq92gp32f5p55kjcc12jfsl0yq6f2y4abb0si6wym12krw9";
   };
 
   /* During darwin bootstrap, we have a cp that doesn't understand the
diff --git a/pkgs/development/libraries/kde-frameworks/default.nix b/pkgs/development/libraries/kde-frameworks/default.nix
index 62ae433ff71..7745d78f8fc 100644
--- a/pkgs/development/libraries/kde-frameworks/default.nix
+++ b/pkgs/development/libraries/kde-frameworks/default.nix
@@ -45,17 +45,9 @@ let
                 if [ "$hookName" != postHook ]; then
                     postHooks+=("source @dev@/nix-support/setup-hook")
                 else
-                    # Propagate $${out} output
-                    propagatedUserEnvPkgs="$propagatedUserEnvPkgs @${out}@"
-
-                    if [ -z "$outputDev" ]; then
-                        echo "error: \$outputDev is unset!" >&2
-                        exit 1
-                    fi
-
                     # Propagate $dev so that this setup hook is propagated
                     # But only if there is a separate $dev output
-                    if [ "$outputDev" != out ]; then
+                    if [ "''${outputDev:?}" != out ]; then
                         propagatedBuildInputs="$propagatedBuildInputs @dev@"
                     fi
                 fi
@@ -75,10 +67,9 @@ let
             inherit (srcs."${name}") src version;
 
             outputs = args.outputs or [ "bin" "dev" "out" ];
-            hasBin = lib.elem "bin" outputs;
-            hasDev = lib.elem "dev" outputs;
+            hasSeparateDev = lib.elem "dev" outputs;
 
-            defaultSetupHook = if hasBin && hasDev then propagateBin else null;
+            defaultSetupHook = if hasSeparateDev then propagateBin else null;
             setupHook = args.setupHook or defaultSetupHook;
 
             meta = {
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 88091e78a0c..4df086ddbf2 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
@@ -1,16 +1,16 @@
-_ecmEnvHook() {
+ecmEnvHook() {
     addToSearchPath XDG_DATA_DIRS "$1/share"
     addToSearchPath XDG_CONFIG_DIRS "$1/etc/xdg"
 }
-addEnvHooks "$targetOffset" _ecmEnvHook
+addEnvHooks "$targetOffset" ecmEnvHook
 
-_ecmPreConfigureHook() {
+ecmPostHook() {
     # Because we need to use absolute paths here, we must set *all* the paths.
     cmakeFlags+=" -DKDE_INSTALL_EXECROOTDIR=${!outputBin}"
     cmakeFlags+=" -DKDE_INSTALL_BINDIR=${!outputBin}/bin"
     cmakeFlags+=" -DKDE_INSTALL_SBINDIR=${!outputBin}/sbin"
     cmakeFlags+=" -DKDE_INSTALL_LIBDIR=${!outputLib}/lib"
-    cmakeFlags+=" -DKDE_INSTALL_LIBEXECDIR=${!outputLib}/lib/libexec"
+    cmakeFlags+=" -DKDE_INSTALL_LIBEXECDIR=${!outputLib}/libexec"
     cmakeFlags+=" -DKDE_INSTALL_CMAKEPACKAGEDIR=${!outputDev}/lib/cmake"
     cmakeFlags+=" -DKDE_INSTALL_INCLUDEDIR=${!outputInclude}/include"
     cmakeFlags+=" -DKDE_INSTALL_LOCALSTATEDIR=/var"
@@ -51,4 +51,58 @@ _ecmPreConfigureHook() {
         cmakeFlags+=" -DKDE_INSTALL_QMLDIR=${!outputBin}/$qtQmlPrefix"
     fi
 }
-preConfigureHooks+=(_ecmPreConfigureHook)
+postHooks+=(ecmPostHook)
+
+xdgDataSubdirs=(
+    "doc" "config.kcfg" "kconf_update" "kservices5" "kservicetypes5" \
+    "kxmlgui5" "knotifications5" "icons" "locale" "sounds" "templates" \
+    "wallpapers" "applications" "desktop-directories" "mime" "appdata" "dbus-1" \
+)
+
+
+ecmHostPathSeen=( )
+
+ecmUnseenHostPath() {
+    for pkg in "${ecmHostPathSeen[@]}"
+    do
+        if [ "${pkg:?}" == "$1" ]
+        then
+            return 1
+        fi
+    done
+
+    ecmHostPathSeen+=("$1")
+    return 0
+}
+
+ecmHostPathHook() {
+    ecmUnseenHostPath "$1" || return 0
+
+    local xdgConfigDir="$1/etc/xdg"
+    if [ -d "$xdgConfigDir" ]
+    then
+        qtWrapperArgs+=(--prefix XDG_CONFIG_DIRS : "$xdgConfigDir")
+    fi
+
+    for xdgDataSubdir in "${xdgDataSubdirs[@]}"
+    do
+        if [ -d "$1/share/$xdgDataSubdir" ]
+        then
+            qtWrapperArgs+=(--prefix XDG_DATA_DIRS : "$1/share")
+            break
+        fi
+    done
+
+    local manDir="$1/man"
+    if [ -d "$manDir" ]
+    then
+        qtWrapperArgs+=(--prefix MANPATH : "$manDir")
+    fi
+
+    local infoDir="$1/info"
+    if [ -d "$infoDir" ]
+    then
+        qtWrapperArgs+=(--prefix INFOPATH : "$infoDir")
+    fi
+}
+addEnvHooks "$hostOffset" ecmHostPathHook
diff --git a/pkgs/development/libraries/kde-frameworks/kconfigwidgets/default.nix b/pkgs/development/libraries/kde-frameworks/kconfigwidgets/default.nix
index 3943e5d6d49..e06d9547de0 100644
--- a/pkgs/development/libraries/kde-frameworks/kconfigwidgets/default.nix
+++ b/pkgs/development/libraries/kde-frameworks/kconfigwidgets/default.nix
@@ -11,10 +11,5 @@ mkDerivation {
   propagatedBuildInputs = [ kauth kcodecs kconfig kwidgetsaddons ];
   patches = [ ./0001-qdiriterator-follow-symlinks.patch ];
   outputs = [ "out" "dev" ];
-  preConfigure = ''
-    outputBin=dev
-  '';
-  postInstall = ''
-    moveToOutput share/man $dev
-  '';
+  outputBin = "dev";
 }
diff --git a/pkgs/development/libraries/kde-frameworks/kinit/default.nix b/pkgs/development/libraries/kde-frameworks/kinit/default.nix
index 538078fd745..42a1e157a91 100644
--- a/pkgs/development/libraries/kde-frameworks/kinit/default.nix
+++ b/pkgs/development/libraries/kde-frameworks/kinit/default.nix
@@ -9,6 +9,7 @@ let inherit (lib) getLib; in
 mkDerivation {
   name = "kinit";
   meta = { maintainers = [ lib.maintainers.ttuegel ]; };
+  outputs = [ "out" "dev" ];
   nativeBuildInputs = [ extra-cmake-modules kdoctools ];
   buildInputs = [
     kconfig kcrash ki18n kio kservice kwindowsystem
@@ -19,9 +20,6 @@ mkDerivation {
     ''-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"
-  '';
   setupHook = writeScript "setup-hook.sh" ''
     kinitFixupOutputHook() {
         if [ $prefix != ''${!outputBin} ] && [ -d $prefix/lib ]; then
diff --git a/pkgs/development/libraries/kde-frameworks/ktexteditor.nix b/pkgs/development/libraries/kde-frameworks/ktexteditor.nix
index c633aee30a1..98f9b3f82ca 100644
--- a/pkgs/development/libraries/kde-frameworks/ktexteditor.nix
+++ b/pkgs/development/libraries/kde-frameworks/ktexteditor.nix
@@ -2,7 +2,8 @@
   mkDerivation, lib,
   extra-cmake-modules, perl,
   karchive, kconfig, kguiaddons, ki18n, kiconthemes, kio, kparts, libgit2,
-  qtscript, qtxmlpatterns, sonnet, syntax-highlighting, qtquickcontrols
+  qtscript, qtxmlpatterns, sonnet, syntax-highlighting, qtquickcontrols,
+  editorconfig-core-c
 }:
 
 mkDerivation {
@@ -12,6 +13,7 @@ mkDerivation {
   buildInputs = [
     karchive kconfig kguiaddons ki18n kiconthemes kio libgit2 qtscript
     qtxmlpatterns sonnet syntax-highlighting qtquickcontrols
+    editorconfig-core-c
   ];
   propagatedBuildInputs = [ kparts ];
 }
diff --git a/pkgs/development/libraries/kerberos/heimdal.nix b/pkgs/development/libraries/kerberos/heimdal.nix
index 197911be0d4..d2283f5c1d5 100644
--- a/pkgs/development/libraries/kerberos/heimdal.nix
+++ b/pkgs/development/libraries/kerberos/heimdal.nix
@@ -7,13 +7,13 @@
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "heimdal-${version}";
-  version = "7.6.0";
+  version = "7.7.0";
 
   src = fetchFromGitHub {
     owner = "heimdal";
     repo = "heimdal";
     rev = "heimdal-${version}";
-    sha256 = "1i70xas6wddkw2840lk0ah9w6ddx0dzrslby1ggxlwfmcax8rcgp";
+    sha256 = "099qn9b8q20invvi5r8d8q9rnwpcm3nr89hx5rj7gj2ah2x5vgxs";
   };
 
   outputs = [ "out" "dev" "man" "info" ];
diff --git a/pkgs/development/libraries/kinetic-cpp-client/default.nix b/pkgs/development/libraries/kinetic-cpp-client/default.nix
index 0fa46dde23e..1ebf2c2e21e 100644
--- a/pkgs/development/libraries/kinetic-cpp-client/default.nix
+++ b/pkgs/development/libraries/kinetic-cpp-client/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchgit, fetchurl, cmake, protobuf, libunwind, openssl, glog
-, google-gflags, gmock, gtest
+, gflags, gmock, gtest
 }:
 
 let
@@ -25,7 +25,7 @@ stdenv.mkDerivation rec {
   '';
 
   nativeBuildInputs = [ cmake protobuf ];
-  buildInputs = [ libunwind glog google-gflags gmock gtest ];
+  buildInputs = [ libunwind glog gflags gmock gtest ];
 
   # The headers and library include from these and there is no provided pc file
   propagatedBuildInputs = [ protobuf openssl ];
diff --git a/pkgs/development/libraries/kpmcore/default.nix b/pkgs/development/libraries/kpmcore/default.nix
index 5c53f5e6ad5..52e6264843b 100644
--- a/pkgs/development/libraries/kpmcore/default.nix
+++ b/pkgs/development/libraries/kpmcore/default.nix
@@ -28,6 +28,8 @@ in stdenv.mkDerivation rec {
   enableParallelBuilding = true;
 
   meta = with stdenv.lib; {
-   maintainers = with lib.maintainers; [ peterhoeg ];
+    maintainers = with lib.maintainers; [ peterhoeg ];
+    # The build requires at least Qt 5.12:
+    broken = lib.versionOlder qtbase.version "5.12.0";
   };
 }
diff --git a/pkgs/development/libraries/languagemachines/packages.nix b/pkgs/development/libraries/languagemachines/packages.nix
index c2d449ed13c..8a490bbc986 100644
--- a/pkgs/development/libraries/languagemachines/packages.nix
+++ b/pkgs/development/libraries/languagemachines/packages.nix
@@ -1,13 +1,17 @@
-{ callPackage }:
+{ pkgs }:
+let
+  inherit (pkgs) callPackage;
+  icu = pkgs.icu60;
+in
 {
   ticcutils = callPackage ./ticcutils.nix { };
-  libfolia = callPackage ./libfolia.nix { };
-  ucto = callPackage ./ucto.nix { };
+  libfolia = callPackage ./libfolia.nix { inherit icu; };
+  ucto = callPackage ./ucto.nix { inherit icu; };
   uctodata = callPackage ./uctodata.nix { };
   timbl = callPackage ./timbl.nix { };
   timblserver = callPackage ./timblserver.nix { };
   mbt = callPackage ./mbt.nix { };
-  frog = callPackage ./frog.nix { };
+  frog = callPackage ./frog.nix { inherit icu; };
   frogdata = callPackage ./frogdata.nix { };
 
   test = callPackage ./test.nix { };
diff --git a/pkgs/development/libraries/lasem/default.nix b/pkgs/development/libraries/lasem/default.nix
index aa1172029d2..5e00ce1037f 100644
--- a/pkgs/development/libraries/lasem/default.nix
+++ b/pkgs/development/libraries/lasem/default.nix
@@ -1,21 +1,21 @@
-{ fetchurl, stdenv, pkgconfig, intltool, gobject-introspection, glib, gdk_pixbuf
+{ fetchurl, stdenv, pkgconfig, intltool, gobject-introspection, glib, gdk-pixbuf
 , libxml2, cairo, pango, gnome3 }:
 
 stdenv.mkDerivation rec {
   pname = "lasem";
-  version = "0.4.3";
+  version = "0.4.4";
 
   outputs = [ "bin" "out" "dev" "man" "doc" "devdoc" ];
 
   src = fetchurl {
     url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
-    sha256 = "13ym5pm2y3wk5hh9zb2535i3lnhnzyzs0na1knxwgvwxazwm1ng7";
+    sha256 = "0fds3fsx84ylsfvf55zp65y8xqjj5n8gbhcsk02vqglivk7izw4v";
   };
 
   nativeBuildInputs = [ pkgconfig intltool gobject-introspection ];
 
   propagatedBuildInputs = [
-    glib gdk_pixbuf libxml2 cairo pango
+    glib gdk-pixbuf libxml2 cairo pango
   ];
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/ldacbt/default.nix b/pkgs/development/libraries/ldacbt/default.nix
index 4ff58843d15..839f0a75156 100644
--- a/pkgs/development/libraries/ldacbt/default.nix
+++ b/pkgs/development/libraries/ldacbt/default.nix
@@ -1,6 +1,5 @@
 { stdenv
 , fetchFromGitHub
-, pkgconfig
 , cmake
 }:
 
diff --git a/pkgs/development/libraries/leatherman/default.nix b/pkgs/development/libraries/leatherman/default.nix
index 6a20afe4c6d..e27f758ff58 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.6.0";
+  version = "1.7.1";
 
   src = fetchFromGitHub {
-    sha256 = "1dy1iisc0h1l28ff72pq7vxa4mj5zpq2jflpdghhx8yqksxhii4k";
+    sha256 = "0m2dm1gzwj0kwyl031bif89h3n4znml3m5n97hywlbra58ni8km1";
     rev = version;
     repo = "leatherman";
     owner = "puppetlabs";
diff --git a/pkgs/development/libraries/leptonica/default.nix b/pkgs/development/libraries/leptonica/default.nix
index 52d835d7a20..dd3c42e8b7f 100644
--- a/pkgs/development/libraries/leptonica/default.nix
+++ b/pkgs/development/libraries/leptonica/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, autoreconfHook, pkgconfig, which, gnuplot
+{ stdenv, fetchurl, autoreconfHook, pkgconfig, which, gnuplot
 , giflib, libjpeg, libpng, libtiff, libwebp, openjpeg, zlib
 }:
 
diff --git a/pkgs/development/libraries/lib3mf/default.nix b/pkgs/development/libraries/lib3mf/default.nix
index 7e41743e1e0..5d1894da579 100644
--- a/pkgs/development/libraries/lib3mf/default.nix
+++ b/pkgs/development/libraries/lib3mf/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, cmake, ninja, libuuid, gtest }:
+{ stdenv, fetchFromGitHub, cmake, ninja, libuuid, libossp_uuid, gtest }:
 
 stdenv.mkDerivation rec {
   pname = "lib3mf";
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake ninja ];
 
-  buildInputs = [ libuuid ];
+  buildInputs = if stdenv.isDarwin then [ libossp_uuid ] else [ libuuid ];
 
   postPatch = ''
     rmdir UnitTests/googletest
diff --git a/pkgs/development/libraries/libao/default.nix b/pkgs/development/libraries/libao/default.nix
index c1cf3215c16..826f72b1f5f 100644
--- a/pkgs/development/libraries/libao/default.nix
+++ b/pkgs/development/libraries/libao/default.nix
@@ -1,5 +1,5 @@
 { stdenv, lib, fetchFromGitHub, autoreconfHook, pkgconfig, libpulseaudio, alsaLib, libcap
-, CoreAudio, CoreServices, AudioUnit, AudioToolbox
+, CoreAudio, CoreServices, AudioUnit
 , usePulseAudio }:
 
 stdenv.mkDerivation rec {
diff --git a/pkgs/development/libraries/libaom/default.nix b/pkgs/development/libraries/libaom/default.nix
index c7d7bfb1e82..62e0a850bad 100644
--- a/pkgs/development/libraries/libaom/default.nix
+++ b/pkgs/development/libraries/libaom/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchgit, yasm, perl, cmake, pkgconfig, python3, writeText }:
+{ stdenv, fetchgit, yasm, perl, cmake, pkgconfig, python3 }:
 
 stdenv.mkDerivation rec {
   name = "libaom-${version}";
diff --git a/pkgs/development/libraries/libaosd/default.nix b/pkgs/development/libraries/libaosd/default.nix
index e63bfd20c79..dd3320005a4 100644
--- a/pkgs/development/libraries/libaosd/default.nix
+++ b/pkgs/development/libraries/libaosd/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchFromGitHub, pkgconfig, cairo, pango,
+{ stdenv, fetchFromGitHub, pkgconfig, cairo, pango,
   libX11, libXcomposite, autoconf, automake }:
 
 stdenv.mkDerivation rec {
diff --git a/pkgs/development/libraries/libarchive/default.nix b/pkgs/development/libraries/libarchive/default.nix
index f2a1c500a8b..3cf8a6da736 100644
--- a/pkgs/development/libraries/libarchive/default.nix
+++ b/pkgs/development/libraries/libarchive/default.nix
@@ -1,5 +1,5 @@
 {
-  fetchurl, fetchpatch, stdenv, pkgconfig,
+  fetchFromGitHub, stdenv, pkgconfig, autoreconfHook,
   acl, attr, bzip2, e2fsprogs, libxml2, lzo, openssl, sharutils, xz, zlib,
 
   # Optional but increases closure only negligibly.
@@ -10,31 +10,18 @@ assert xarSupport -> libxml2 != null;
 
 stdenv.mkDerivation rec {
   name = "libarchive-${version}";
-  version = "3.3.3";
+  version = "3.4.0";
 
-  src = fetchurl {
-    url = "${meta.homepage}/downloads/${name}.tar.gz";
-    sha256 = "0bhfncid058p7n1n8v29l6wxm3mhdqfassscihbsxfwz3iwb2zms";
+  src = fetchFromGitHub {
+    owner = "libarchive";
+    repo = "libarchive";
+    rev = "v${version}";
+    sha256 = "063f5bw9qmksj3iy6094qxwawx174cx00q1fg6l698wqw7xn8ihq";
   };
 
-  patches = [
-    (fetchpatch {
-      # details: https://github.com/libarchive/libarchive/pull/1105
-      name = "cve-2018-1000877.diff"; # CVE-2018-1000877..80
-      url = "https://github.com/libarchive/libarchive/pull/1105.diff";
-      sha256 = "0mxcawfdy9m40mykzwhkl39a6vnh4ypgy0ipcz74qm4bi72x0gyf";
-    })
-    (fetchpatch {
-      # details: https://github.com/libarchive/libarchive/pull/1120
-      name = "cve-2019-1000019_cve-2019-1000020.diff";
-      url = "https://github.com/libarchive/libarchive/pull/1120.diff";
-      sha256 = "1mgx92v8hm7hw9j34nbfriqfkxshh3cy25rhavr7kl7lz4x5a6g4";
-    })
-  ];
-
   outputs = [ "out" "lib" "dev" ];
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig autoreconfHook ];
   buildInputs = [ sharutils zlib bzip2 openssl xz lzo ]
     ++ stdenv.lib.optionals stdenv.isLinux [ e2fsprogs attr acl ]
     ++ stdenv.lib.optional xarSupport libxml2;
diff --git a/pkgs/development/libraries/libargon2/default.nix b/pkgs/development/libraries/libargon2/default.nix
index a1a04a1dd7b..c0dd406dd31 100644
--- a/pkgs/development/libraries/libargon2/default.nix
+++ b/pkgs/development/libraries/libargon2/default.nix
@@ -1,14 +1,14 @@
 { stdenv, fetchFromGitHub }:
 
 stdenv.mkDerivation rec {
-  name = "libargon2-${version}";
-  version = "20171227";
+  pname = "libargon2";
+  version = "20190702";
 
   src = fetchFromGitHub {
     owner = "P-H-C";
     repo = "phc-winner-argon2";
-    rev = "${version}";
-    sha256 = "0sc9zca1anqk41017vjpas4kxi4cbn0zvicv8vj8p2sb2gy94bh8";
+    rev = version;
+    sha256 = "0p4ry9dn0mi9js0byijxdyiwx74p1nr8zj7wjpd1fjgqva4sk23i";
   };
 
   installPhase = ''
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
       --replace @HOST_MULTIARCH@ ""                         \
       --replace 'prefix=/usr' "prefix=$out"
 
-    make install PREFIX=$out
+    make install PREFIX=$out LIBRARY_REL=lib
     ln -s $out/lib/libargon2.so $out/lib/libargon2.so.0
     runHook postInstall
   '';
@@ -33,7 +33,7 @@ stdenv.mkDerivation rec {
       Catena, Lyra2, Makwa and yescrypt were given special recognition. The PHC
       recommends using Argon2 rather than legacy algorithms.
     '';
-    homepage = https://www.argon2.com/;
+    homepage = "https://www.argon2.com/";
     license = with licenses; [ asl20 cc0 ];
     maintainers = with maintainers; [ taeer olynch ];
     platforms = platforms.linux ++ platforms.darwin;
diff --git a/pkgs/development/libraries/libbladeRF/default.nix b/pkgs/development/libraries/libbladeRF/default.nix
index d908a8af85d..d22518e96d4 100644
--- a/pkgs/development/libraries/libbladeRF/default.nix
+++ b/pkgs/development/libraries/libbladeRF/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchFromGitHub, fetchpatch, pkgconfig, cmake, git, doxygen, help2man, ncurses, tecla
+{ stdenv, lib, fetchFromGitHub, pkgconfig, cmake, git, doxygen, help2man, ncurses, tecla
 , libusb1, udev }:
 
 let
diff --git a/pkgs/development/libraries/libblockdev/default.nix b/pkgs/development/libraries/libblockdev/default.nix
index a807e399827..6deb89a80ea 100644
--- a/pkgs/development/libraries/libblockdev/default.nix
+++ b/pkgs/development/libraries/libblockdev/default.nix
@@ -1,18 +1,18 @@
-{ stdenv, fetchFromGitHub, substituteAll, autoreconfHook, pkgconfig, gtk-doc, libxslt, docbook_xsl
-, docbook_xml_dtd_43, python3, gobject-introspection, glib, udev, kmod, parted, gptfdisk, libyaml
+{ stdenv, fetchFromGitHub, substituteAll, autoreconfHook, pkgconfig, gtk-doc
+, docbook_xml_dtd_43, python3, gobject-introspection, glib, udev, kmod, parted
 , cryptsetup, lvm2, dmraid, utillinux, libbytesize, libndctl, nss, volume_key
+, libxslt, docbook_xsl, gptfdisk, libyaml, autoconf-archive
+, thin-provisioning-tools, makeWrapper
 }:
-
-let
-  version = "2.20";
-in stdenv.mkDerivation rec {
-  name = "libblockdev-${version}";
+stdenv.mkDerivation rec {
+  pname = "libblockdev";
+  version = "2.22";
 
   src = fetchFromGitHub {
     owner = "storaged-project";
     repo = "libblockdev";
     rev = "${version}-1";
-    sha256 = "13xy8vx2dnnxczpnwapchc5ncigcxb2fhpmrmglbpkjqmhn2zbdj";
+    sha256 = "03y4ps37wbi9p1136q0xzgshfnrjg4lgy8pgm1a3ihfcjnbwrbnq";
   };
 
   outputs = [ "out" "dev" "devdoc" ];
@@ -29,18 +29,25 @@ in stdenv.mkDerivation rec {
   '';
 
   nativeBuildInputs = [
-    autoreconfHook pkgconfig gtk-doc libxslt docbook_xsl docbook_xml_dtd_43 python3 gobject-introspection
+    autoreconfHook pkgconfig gtk-doc libxslt docbook_xsl docbook_xml_dtd_43
+    python3 gobject-introspection autoconf-archive makeWrapper
   ];
 
   buildInputs = [
-    glib udev kmod parted gptfdisk cryptsetup lvm2 dmraid utillinux libbytesize libndctl nss volume_key libyaml
+    glib udev kmod parted gptfdisk cryptsetup lvm2 dmraid utillinux libbytesize
+    libndctl nss volume_key libyaml
   ];
 
+  postInstall = ''
+    wrapProgram $out/bin/lvm-cache-stats --prefix PATH : \
+      ${stdenv.lib.makeBinPath [ thin-provisioning-tools ]}
+  '';
+
   meta = with stdenv.lib; {
     description = "A library for manipulating block devices";
-    homepage = http://storaged.org/libblockdev/;
-    license = licenses.lgpl2Plus; # lgpl2Plus for the library, gpl2Plus for the utils
-    maintainers = with maintainers; [];
+    homepage = "http://storaged.org/libblockdev/";
+    license = with licenses; [ lgpl2Plus gpl2Plus ]; # lgpl2Plus for the library, gpl2Plus for the utils
+    maintainers = with maintainers; [ johnazoidberg ];
     platforms = platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/libbluray/default.nix b/pkgs/development/libraries/libbluray/default.nix
index a98748d3b52..b7ca9dda1ea 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.1.1";
+  version  = "1.1.2";
 
   src = fetchurl {
     url = "http://get.videolan.org/libbluray/${version}/${name}.tar.bz2";
-    sha256 = "0f138xlldzci8wic89i9vpka3mdsn8r78khpnk3wijlbgjhphr0h";
+    sha256 = "0hhbgkm11fw4pwbrklm76aiy54r6d7hk06yhl2fxq05i74i4bpd3";
   };
 
   patches = optional withJava ./BDJ-JARFILE-path.patch;
diff --git a/pkgs/development/libraries/libbytesize/default.nix b/pkgs/development/libraries/libbytesize/default.nix
index 97f8e17a5f6..18593f80799 100644
--- a/pkgs/development/libraries/libbytesize/default.nix
+++ b/pkgs/development/libraries/libbytesize/default.nix
@@ -4,7 +4,7 @@
 }:
 
 let
-  version = "2.0";
+  version = "2.1";
 in stdenv.mkDerivation rec {
   name = "libbytesize-${version}";
 
@@ -12,7 +12,7 @@ in stdenv.mkDerivation rec {
     owner = "storaged-project";
     repo = "libbytesize";
     rev = version;
-    sha256 = "0m950idlyv6mbkhr8ngnda5l5wwb5lzs4wn4kxl73cvdlcvklmwj";
+    sha256 = "0qb6zx2fdghm21lishlcrhnwf4wwy5p69dsgp0504kn93ii7mw3m";
   };
 
   outputs = [ "out" "dev" "devdoc" ];
diff --git a/pkgs/development/libraries/libcacard/default.nix b/pkgs/development/libraries/libcacard/default.nix
index f116360474e..62d70973375 100644
--- a/pkgs/development/libraries/libcacard/default.nix
+++ b/pkgs/development/libraries/libcacard/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libcacard-${version}";
-  version = "2.6.1";
+  version = "2.7.0";
 
   src = fetchurl {
     url = "https://www.spice-space.org/download/libcacard/${name}.tar.xz";
-    sha256 = "1w6y0kiakhg7dgyf8yqpm4jj6jiv17zhy9lp3d7z32q1pniccxk2";
+    sha256 = "0vyvkk4b6xjwq1ccggql13c1x7g4y90clpkqw28257azgn2a1c8n";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/libcdaudio/default.nix b/pkgs/development/libraries/libcdaudio/default.nix
index 218eaeea571..c48818972b5 100644
--- a/pkgs/development/libraries/libcdaudio/default.nix
+++ b/pkgs/development/libraries/libcdaudio/default.nix
@@ -1,10 +1,10 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation {
-  name = "libcdaudio-0.99.12";
+  name = "libcdaudio-0.99.12p2";
   src = fetchurl {
-    url = mirror://sourceforge/libcdaudio/libcdaudio-0.99.12.tar.gz ;
-    sha256 = "1g3ba1n12g8h7pps0vlxx8di6cmf108mbcvbl6hj8x71ndkglygb" ;
+    url = mirror://sourceforge/libcdaudio/libcdaudio-0.99.12p2.tar.gz ;
+    sha256 = "1fsy6dlzxrx177qc877qhajm9l4g28mvh06h2l15rxy4bapzknjz" ;
   };
 
   meta = {
diff --git a/pkgs/development/libraries/libcef/default.nix b/pkgs/development/libraries/libcef/default.nix
index 9e7d608b512..ecba18cd58c 100644
--- a/pkgs/development/libraries/libcef/default.nix
+++ b/pkgs/development/libraries/libcef/default.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, cmake, alsaLib, atk, cairo, cups, dbus, expat, fontconfig
-, GConf, gdk_pixbuf, glib, gtk2, libX11, libxcb, libXcomposite, libXcursor
+, GConf, gdk-pixbuf, glib, gtk2, libX11, libxcb, libXcomposite, libXcursor
 , libXdamage, libXext, libXfixes, libXi, libXrandr, libXrender, libXScrnSaver
 , libXtst, nspr, nss, pango, libpulseaudio, systemd }:
 
 let
   libPath =
     stdenv.lib.makeLibraryPath [
-      alsaLib atk cairo cups dbus expat fontconfig GConf gdk_pixbuf glib gtk2
+      alsaLib atk cairo cups dbus expat fontconfig GConf gdk-pixbuf glib gtk2
       libX11 libxcb libXcomposite libXcursor libXdamage libXext libXfixes libXi
       libXrandr libXrender libXScrnSaver libXtst nspr nss pango libpulseaudio
       systemd
diff --git a/pkgs/development/libraries/libcouchbase/default.nix b/pkgs/development/libraries/libcouchbase/default.nix
index 77f495e32b8..894faf0b910 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.10.3";
+  version = "2.10.4";
 
   src = fetchFromGitHub {
     owner = "couchbase";
     repo = "libcouchbase";
     rev = version;
-    sha256 = "0a3fin5rcwa3xwd980mrzrkr7dpjdwbri81mqwxw1fkppjqw23z4";
+    sha256 = "1yfmcx65aqd5l87scha6kmm2s38n85ci3gg0h6qfs16s3jfi6bw7";
   };
 
   cmakeFlags = "-DLCB_NO_MOCK=ON";
diff --git a/pkgs/development/libraries/libcsptr/default.nix b/pkgs/development/libraries/libcsptr/default.nix
index d7638dd2059..3d32f4d0b95 100644
--- a/pkgs/development/libraries/libcsptr/default.nix
+++ b/pkgs/development/libraries/libcsptr/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, cmake, git }:
+{ stdenv, fetchFromGitHub, cmake }:
 
 stdenv.mkDerivation rec {
   name = "libcsptr-${version}";
diff --git a/pkgs/development/libraries/libdap/default.nix b/pkgs/development/libraries/libdap/default.nix
index 067144ddfa0..86d14fe7974 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.20.3";
+  version = "3.20.4";
   name = "libdap-${version}";
 
   nativeBuildInputs = [ bison flex ];
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "https://www.opendap.org/pub/source/${name}.tar.gz";
-    sha256 = "0n6ciicaa7sn88gvg5sgcq0438i3vh6xbl9lxgafjqiznli1k5i9";
+    sha256 = "0x44igs389b49nb2psd656wpvmbx9bwmla2l5ahfa09vxb314s5i";
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libdazzle/default.nix b/pkgs/development/libraries/libdazzle/default.nix
index 28d9152dcee..f7e0a987b06 100644
--- a/pkgs/development/libraries/libdazzle/default.nix
+++ b/pkgs/development/libraries/libdazzle/default.nix
@@ -2,7 +2,7 @@
 , gtk-doc, docbook_xsl, docbook_xml_dtd_43, glibcLocales, dbus, xvfb_run, glib, gtk3, gnome3 }:
 
 let
-  version = "3.32.2";
+  version = "3.32.3";
   pname = "libdazzle";
 in
 stdenv.mkDerivation {
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
 
   src = fetchurl {
     url = "mirror://gnome/sources/libdazzle/${stdenv.lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
-    sha256 = "0hgi7gnkna9n42nh7p81crrw0jjj22yr8acych60wxh6hzxqsgs1";
+    sha256 = "1s37hv12ikfzhvh86qzgmfcjm3wvp12l2vsr0whl5xmm2harp3bc";
   };
 
   nativeBuildInputs = [ ninja meson pkgconfig vala gobject-introspection libxml2 gtk-doc docbook_xsl docbook_xml_dtd_43 glibcLocales dbus xvfb_run ];
diff --git a/pkgs/development/libraries/libdeflate/default.nix b/pkgs/development/libraries/libdeflate/default.nix
index db5448caa10..a5b178caf82 100644
--- a/pkgs/development/libraries/libdeflate/default.nix
+++ b/pkgs/development/libraries/libdeflate/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "libdeflate-${version}";
-  version = "1.2";
+  version = "1.3";
 
   src = fetchFromGitHub {
     owner = "ebiggers";
     repo = "libdeflate";
     rev = "v${version}";
-    sha256 = "0kmp38s7vahvbgzzhs5v0bfyjgas1in7jn69gpyh70kl08279ly0";
+    sha256 = "019xsz5dnbpxiz29j3zqsxyi4ksjkkygi6a2zyc8fxbm8lvaa9ar";
   };
 
   postPatch = ''
diff --git a/pkgs/development/libraries/libdrm/default.nix b/pkgs/development/libraries/libdrm/default.nix
index 7415aa754e7..bdc191fe8a3 100644
--- a/pkgs/development/libraries/libdrm/default.nix
+++ b/pkgs/development/libraries/libdrm/default.nix
@@ -1,18 +1,18 @@
-{ stdenv, fetchurl, pkgconfig, libpthreadstubs, libpciaccess, valgrind-light }:
+{ stdenv, fetchurl, pkgconfig, meson, ninja, libpthreadstubs, libpciaccess, valgrind-light }:
 
 stdenv.mkDerivation rec {
-  name = "libdrm-2.4.98";
+  pname = "libdrm";
+  version = "2.4.99";
 
   src = fetchurl {
-    url = "https://dri.freedesktop.org/libdrm/${name}.tar.bz2";
-    sha256 = "150qdzsm2nx6dfacc75rx53anzsc6m31nhxidf5xxax3mk6fvq4b";
+    url = "https://dri.freedesktop.org/${pname}/${pname}-${version}.tar.bz2";
+    sha256 = "0pnsw4bmajzdbz8pk4wswdmw93shhympf2q9alhbnpfjgsf57gsd";
   };
 
   outputs = [ "out" "dev" "bin" ];
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkgconfig meson ninja ];
   buildInputs = [ libpthreadstubs libpciaccess valgrind-light ];
-    # libdrm as of 2.4.70 does not actually do anything with udev.
 
   postPatch = ''
     for a in */*-symbol-check ; do
@@ -20,13 +20,15 @@ stdenv.mkDerivation rec {
     done
   '';
 
-  configureFlags = [ "--enable-install-test-programs" ]
+  mesonFlags =
+    [ "-Dinstall-test-programs=true" ]
     ++ stdenv.lib.optionals (stdenv.isAarch32 || stdenv.isAarch64)
-      [ "--enable-tegra-experimental-api" "--enable-etnaviv-experimental-api" ]
-    ++ stdenv.lib.optional stdenv.isDarwin "-C"
-    ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "--disable-intel"
+      [ "-Dtegra=true" "-Detnaviv=true" ]
+    ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "-Dintel=false"
     ;
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = https://dri.freedesktop.org/libdrm/;
     description = "Library for accessing the kernel's Direct Rendering Manager";
diff --git a/pkgs/development/libraries/libelf/default.nix b/pkgs/development/libraries/libelf/default.nix
index 55a01c75dcf..b168dd9bb56 100644
--- a/pkgs/development/libraries/libelf/default.nix
+++ b/pkgs/development/libraries/libelf/default.nix
@@ -6,12 +6,15 @@ stdenv.mkDerivation rec {
   name = "libelf-0.8.13";
 
   src = fetchurl {
-    url = "http://www.mr511.de/software/${name}.tar.gz";
+    url = "https://fossies.org/linux/misc/old/${name}.tar.gz";
     sha256 = "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr";
   };
 
   patches = [
     ./dont-hardcode-ar.patch
+    # Fix warnings from preprocessor instructions.
+    # https://github.com/NixOS/nixpkgs/issues/59929
+    ./preprocessor-warnings.patch
   ];
 
   doCheck = true;
diff --git a/pkgs/development/libraries/libelf/preprocessor-warnings.patch b/pkgs/development/libraries/libelf/preprocessor-warnings.patch
new file mode 100644
index 00000000000..e04c8ee202a
--- /dev/null
+++ b/pkgs/development/libraries/libelf/preprocessor-warnings.patch
@@ -0,0 +1,264 @@
+diff --git a/lib/elf_repl.h b/lib/elf_repl.h
+index c5cf90f..7e1e8df 100644
+--- a/lib/elf_repl.h
++++ b/lib/elf_repl.h
+@@ -45,7 +45,7 @@ typedef __libelf_u32_t		Elf32_Word;
+ #define ELF32_FSZ_SWORD		4
+ #define ELF32_FSZ_WORD		4
+ 
+-#if __LIBELF64
++#if defined(__LIBELF64)
+ 
+ typedef __libelf_u64_t		Elf64_Addr;
+ typedef __libelf_u16_t		Elf64_Half;
+@@ -93,7 +93,7 @@ typedef struct {
+     Elf32_Half		e_shstrndx;
+ } Elf32_Ehdr;
+ 
+-#if __LIBELF64
++#if defined(__LIBELF64)
+ typedef struct {
+     unsigned char	e_ident[EI_NIDENT];
+     Elf64_Half		e_type;
+@@ -307,7 +307,7 @@ typedef struct {
+     Elf32_Word		sh_entsize;
+ } Elf32_Shdr;
+ 
+-#if __LIBELF64
++#if defined(__LIBELF64)
+ typedef struct {
+     Elf64_Word		sh_name;
+     Elf64_Word		sh_type;
+@@ -434,7 +434,7 @@ typedef struct {
+     Elf32_Half		st_shndx;
+ } Elf32_Sym;
+ 
+-#if __LIBELF64
++#if defined(__LIBELF64)
+ typedef struct {
+     Elf64_Word		st_name;
+     unsigned char	st_info;
+@@ -457,7 +457,7 @@ typedef struct {
+ #define ELF32_ST_TYPE(i)	((i)&0xf)
+ #define ELF32_ST_INFO(b,t)	(((b)<<4)+((t)&0xf))
+ 
+-#if __LIBELF64
++#if defined(__LIBELF64)
+ #define ELF64_ST_BIND(i)	((i)>>4)
+ #define ELF64_ST_TYPE(i)	((i)&0xf)
+ #define ELF64_ST_INFO(b,t)	(((b)<<4)+((t)&0xf))
+@@ -495,7 +495,7 @@ typedef struct {
+  * Macros for manipulating st_other
+  */
+ #define ELF32_ST_VISIBILITY(o)	((o)&0x3)
+-#if __LIBELF64
++#if defined(__LIBELF64)
+ #define ELF64_ST_VISIBILITY(o)	((o)&0x3)
+ #endif /* __LIBELF64 */
+ 
+@@ -521,7 +521,7 @@ typedef struct {
+     Elf32_Sword		r_addend;
+ } Elf32_Rela;
+ 
+-#if __LIBELF64
++#if defined(__LIBELF64)
+ typedef struct {
+     Elf64_Addr		r_offset;
+     Elf64_Xword		r_info;
+@@ -541,7 +541,7 @@ typedef struct {
+ #define ELF32_R_TYPE(i)		((unsigned char)(i))
+ #define ELF32_R_INFO(s,t)	(((s)<<8)+(unsigned char)(t))
+ 
+-#if __LIBELF64
++#if defined(__LIBELF64)
+ #define ELF64_R_SYM(i)		((Elf64_Xword)(i)>>32)
+ #define ELF64_R_TYPE(i)		((i)&0xffffffffL)
+ #define ELF64_R_INFO(s,t)	(((Elf64_Xword)(s)<<32)+((t)&0xffffffffL))
+@@ -556,7 +556,7 @@ typedef struct {
+     Elf32_Word		n_type;		/* descriptor type */
+ } Elf32_Nhdr;
+ 
+-#if __LIBELF64
++#if defined(__LIBELF64)
+ /* Solaris and GNU use this layout.  Be compatible. */
+ /* XXX: Latest ELF specs say it's 64-bit!!! */
+ typedef struct {
+@@ -587,7 +587,7 @@ typedef struct {
+     Elf32_Word		p_align;
+ } Elf32_Phdr;
+ 
+-#if __LIBELF64
++#if defined(__LIBELF64)
+ typedef struct {
+     Elf64_Word		p_type;
+     Elf64_Word		p_flags;
+@@ -654,7 +654,7 @@ typedef struct {
+     } d_un;
+ } Elf32_Dyn;
+ 
+-#if __LIBELF64
++#if defined(__LIBELF64)
+ typedef struct {
+     Elf64_Sxword	d_tag;
+     union {
+@@ -798,7 +798,7 @@ typedef struct {
+     Elf32_Half		si_flags;
+ } Elf32_Syminfo;
+ 
+-#if __LIBELF64
++#if defined(__LIBELF64)
+ typedef struct {
+     Elf64_Half		si_boundto;
+     Elf64_Half		si_flags;
+@@ -863,7 +863,7 @@ typedef struct {
+ 
+ typedef Elf32_Half	Elf32_Versym;
+ 
+-#if __LIBELF64
++#if defined(__LIBELF64)
+ 
+ typedef struct {
+     Elf64_Half		vd_version;
+@@ -933,7 +933,7 @@ typedef Elf64_Half	Elf64_Versym;
+ /*
+  * Move section
+  */
+-#if __LIBELF64
++#if defined(__LIBELF64)
+ 
+ typedef struct {
+     Elf32_Lword		m_value;
+@@ -973,7 +973,7 @@ typedef struct {
+     } c_un;
+ } Elf32_Cap;
+ 
+-#if __LIBELF64
++#if defined(__LIBELF64)
+ 
+ typedef struct {
+     Elf64_Xword     	c_tag;
+diff --git a/lib/gelf.h b/lib/gelf.h
+index 5af0558..98a759c 100644
+--- a/lib/gelf.h
++++ b/lib/gelf.h
+@@ -22,15 +22,15 @@
+ #ifndef _GELF_H
+ #define _GELF_H
+ 
+-#if __LIBELF_INTERNAL__
++#if defined(__LIBELF_INTERNAL__)
+ #include <libelf.h>
+ #else /* __LIBELF_INTERNAL__ */
+ #include <libelf/libelf.h>
+ #endif /* __LIBELF_INTERNAL__ */
+ 
+-#if __LIBELF_NEED_LINK_H
++#if defined(__LIBELF_NEED_LINK_H)
+ #include <link.h>
+-#elif __LIBELF_NEED_SYS_LINK_H
++#elif defined(__LIBELF_NEED_SYS_LINK_H)
+ #include <sys/link.h>
+ #endif /* __LIBELF_NEED_LINK_H */
+ 
+@@ -46,7 +46,7 @@ extern "C" {
+ # endif /* __STDC__ || defined(__cplusplus) */
+ #endif /* __P */
+ 
+-#if !__LIBELF64
++#if !defined(__LIBELF64)
+ 
+ #error "GElf is not supported on this system."
+ 
+@@ -71,7 +71,7 @@ typedef Elf64_Sym	GElf_Sym;
+ /*
+  * Symbol versioning
+  */
+-#if __LIBELF_SYMBOL_VERSIONS
++#if defined(__LIBELF_SYMBOL_VERSIONS)
+ typedef Elf64_Verdef	GElf_Verdef;
+ typedef Elf64_Verneed	GElf_Verneed;
+ typedef Elf64_Verdaux	GElf_Verdaux;
+diff --git a/lib/libelf.h b/lib/libelf.h
+index 3ebd0f3..788482d 100644
+--- a/lib/libelf.h
++++ b/lib/libelf.h
+@@ -25,7 +25,7 @@
+ #include <stddef.h>	/* for size_t */
+ #include <sys/types.h>
+ 
+-#if __LIBELF_INTERNAL__
++#if defined(__LIBELF_INTERNAL__)
+ #include <sys_elf.h>
+ #else /* __LIBELF_INTERNAL__ */
+ #include <libelf/sys_elf.h>
+@@ -224,7 +224,7 @@ extern Elf_Data *elf32_xlatetom __P((Elf_Data *__dst, const Elf_Data *__src,
+  */
+ extern long elf32_checksum __P((Elf *__elf));
+ 
+-#if __LIBELF64
++#if defined(__LIBELF64)
+ /*
+  * 64-bit ELF functions
+  * Not available on all platforms
+diff --git a/lib/sys_elf.h.in b/lib/sys_elf.h.in
+index b71a20d..722051b 100644
+--- a/lib/sys_elf.h.in
++++ b/lib/sys_elf.h.in
+@@ -68,7 +68,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ #ifdef __LIBELF_HEADER_ELF_H
+ # include __LIBELF_HEADER_ELF_H
+ #else /* __LIBELF_HEADER_ELF_H */
+-# if __LIBELF_INTERNAL__
++# if defined(__LIBELF_INTERNAL__)
+ #  include <elf_repl.h>
+ # else /* __LIBELF_INTERNAL__ */
+ #  include <libelf/elf_repl.h>
+@@ -92,7 +92,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ #  define STN_UNDEF	0
+ # endif /* STN_UNDEF */
+ 
+-# if __LIBELF64
++# if defined(__LIBELF64)
+ 
+ #  ifndef ELF64_FSZ_ADDR
+ #   define ELF64_FSZ_ADDR	8
+@@ -116,7 +116,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ #   define ELF64_R_INFO(s,t)	(((Elf64_Xword)(s)<<32)+((t)&0xffffffffL))
+ #  endif /* ELF64_R_SYM */
+ 
+-#  if __LIBELF64_LINUX
++#  if defined(__LIBELF64_LINUX)
+ typedef __libelf_u64_t	Elf64_Addr;
+ typedef __libelf_u16_t	Elf64_Half;
+ typedef __libelf_u64_t	Elf64_Off;
+diff --git a/lib/sys_elf.h.w32 b/lib/sys_elf.h.w32
+index 0f93c55..7360104 100644
+--- a/lib/sys_elf.h.w32
++++ b/lib/sys_elf.h.w32
+@@ -68,7 +68,7 @@
+ #ifdef __LIBELF_HEADER_ELF_H

+ # include __LIBELF_HEADER_ELF_H

+ #else /* __LIBELF_HEADER_ELF_H */

+-# if __LIBELF_INTERNAL__

++# if defined(__LIBELF_INTERNAL__)

+ #  include <elf_repl.h>

+ # else /* __LIBELF_INTERNAL__ */

+ #  include <libelf/elf_repl.h>

+@@ -92,7 +92,7 @@
+ #  define STN_UNDEF	0

+ # endif /* STN_UNDEF */

+ 

+-# if __LIBELF64

++# if defined(__LIBELF64)

+ 

+ #  ifndef ELF64_FSZ_ADDR

+ #   define ELF64_FSZ_ADDR	8

+@@ -116,7 +116,7 @@
+ #   define ELF64_R_INFO(s,t)	(((Elf64_Xword)(s)<<32)+((t)&0xffffffffL))

+ #  endif /* ELF64_R_SYM */

+ 

+-#  if __LIBELF64_LINUX

++#  if defined(__LIBELF64_LINUX)

+ typedef __libelf_u64_t	Elf64_Addr;

+ typedef __libelf_u16_t	Elf64_Half;

+ typedef __libelf_u64_t	Elf64_Off;

diff --git a/pkgs/development/libraries/libetpan/default.nix b/pkgs/development/libraries/libetpan/default.nix
index b09c2dd0f47..6756a8dbc56 100644
--- a/pkgs/development/libraries/libetpan/default.nix
+++ b/pkgs/development/libraries/libetpan/default.nix
@@ -1,17 +1,24 @@
-{ autoconf, automake, fetchgit, libtool, stdenv, openssl }:
+{ stdenv, fetchFromGitHub
+, autoconf
+, automake
+, libtool
+, openssl
+}:
 
-let version = "1.8"; in
+stdenv.mkDerivation rec {
+  pname = "libetpan";
+  version = "1.9.3";
 
-stdenv.mkDerivation {
-  name = "libetpan-${version}";
-
-  src = fetchgit {
-    url = "git://github.com/dinhviethoa/libetpan";
-    rev = "refs/tags/" + version;
-    sha256 = "09xqy1n18qn63x7idfrpwm59lfkvb1p5vxkyksywvy4f6mn4pyxk";
+  src = fetchFromGitHub {
+    owner = "dinhviethoa";
+    repo = "libetpan";
+    rev = version;
+    sha256 = "19g4qskg71jv7sxfxsdkjmrxk9mk5kf9b6fhw06g6wvm3205n95f";
   };
 
-  buildInputs = [ autoconf automake libtool openssl ];
+  nativeBuildInputs = [ libtool autoconf automake ];
+
+  buildInputs = [ openssl ];
 
   configureScript = "./autogen.sh";
 
diff --git a/pkgs/development/libraries/libev/default.nix b/pkgs/development/libraries/libev/default.nix
index 922207f1cce..365c128239d 100644
--- a/pkgs/development/libraries/libev/default.nix
+++ b/pkgs/development/libraries/libev/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libev-${version}";
-  version="4.25";
+  version="4.27";
 
   src = fetchurl {
     url = "http://dist.schmorp.de/libev/Attic/${name}.tar.gz";
-    sha256 = "1295q0lkkbrlpd5dl5i48bh1rm8mjzh9y795jlvjz3bp4wf7wxbq";
+    sha256 = "0kil23cgsp0r5shvnwwbsy7fzxb62sxqzqbkbkfp5w54ipy2cm9d";
   };
 
   meta = {
diff --git a/pkgs/development/libraries/libevdev/default.nix b/pkgs/development/libraries/libevdev/default.nix
index 7998655e46b..b0383b7f742 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.6.0";
+  name = "libevdev-1.7.0";
 
   src = fetchurl {
     url = "https://www.freedesktop.org/software/libevdev/${name}.tar.xz";
-    sha256 = "057qdrwbhql2lvr4kxljk3yqjsmh65hyrfbr2b681nc7b635q07m";
+    sha256 = "0sg3lbjn68qaq3yz2k735h29kaf3fmx7b5m1x7rm2fnhn7rf3nqi";
   };
 
   buildInputs = [ python ];
diff --git a/pkgs/development/libraries/libevent/default.nix b/pkgs/development/libraries/libevent/default.nix
index 2bc2bcb5b85..611287b9aaa 100644
--- a/pkgs/development/libraries/libevent/default.nix
+++ b/pkgs/development/libraries/libevent/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, findutils, fixDarwinDylibNames
+{ stdenv, fetchurl, findutils, fixDarwinDylibNames
 , sslSupport? true, openssl
 }:
 
diff --git a/pkgs/development/libraries/libextractor/default.nix b/pkgs/development/libraries/libextractor/default.nix
index d5c720e0a1f..8fd01dbd506 100644
--- a/pkgs/development/libraries/libextractor/default.nix
+++ b/pkgs/development/libraries/libextractor/default.nix
@@ -1,5 +1,5 @@
 { fetchurl, stdenv, libtool, gettext, zlib, bzip2, flac, libvorbis
-, exiv2, libgsf, rpm, pkgconfig
+, exiv2, libgsf, rpm, pkgconfig, fetchpatch
 , gtkSupport ? true, glib ? null, gtk3 ? null
 , videoSupport ? true, ffmpeg ? null, libmpeg2 ? null}:
 
@@ -14,7 +14,15 @@ stdenv.mkDerivation rec {
     sha256 = "1zz2zvikvfibxnk1va3kgzs7djsmiqy7bmk8y01vbsf54ryjb3zh";
   };
 
-  patches = [ ./fix-gcc8-build.patch ];
+  patches = [
+    ./fix-gcc8-build.patch
+    # Fixes build with exiv2 0.27
+    (fetchpatch {
+      name = "libextractor-exiv2-0.27.patch";
+      url = "https://git.archlinux.org/svntogit/community.git/plain/trunk/libextractor-exiv2-0.27.patch?h=packages/libextractor&id=4dc53f7fc69210ae571285dface108ed65d8ee53";
+      sha256 = "0w4gc1q1m1yxsd4hv105nblmif465nw3g5nxzldy0x2rl9mdncg6";
+    })
+  ];
 
   preConfigure =
     '' echo "patching installation directory in \`extractor.c'..."
diff --git a/pkgs/development/libraries/libfaketime/default.nix b/pkgs/development/libraries/libfaketime/default.nix
index 3492a07905d..f70886f7358 100644
--- a/pkgs/development/libraries/libfaketime/default.nix
+++ b/pkgs/development/libraries/libfaketime/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, bash, perl }:
+{ stdenv, fetchurl, perl }:
 
 stdenv.mkDerivation rec {
   name = "libfaketime-${version}";
diff --git a/pkgs/development/libraries/libfilezilla/default.nix b/pkgs/development/libraries/libfilezilla/default.nix
index 4a051f34b0b..9b6c1d505c1 100644
--- a/pkgs/development/libraries/libfilezilla/default.nix
+++ b/pkgs/development/libraries/libfilezilla/default.nix
@@ -1,19 +1,26 @@
-{ stdenv, fetchurl, pkgconfig, nettle }:
+{ stdenv
+, fetchurl
+
+, gettext
+, gnutls
+, nettle
+, pkgconfig
+}:
 
 stdenv.mkDerivation rec {
   pname = "libfilezilla";
-  version = "0.16.0";
+  version = "0.18.1";
 
   src = fetchurl {
     url = "https://download.filezilla-project.org/${pname}/${pname}-${version}.tar.bz2";
-    sha256 = "1fd71vmllzvljff5l5ka5wnzbdsxx4i54dpxpklydmbsqpilnv1v";
+    sha256 = "15vzi95ibp6a9n4jjfs78z4b1iym8x1yv849gjipxzx64y5awyyb";
   };
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ nettle ];
+  buildInputs = [ gettext gnutls nettle ];
 
   meta = with stdenv.lib; {
-    homepage = https://lib.filezilla-project.org/;
+    homepage = "https://lib.filezilla-project.org/";
     description = "A modern C++ library, offering some basic functionality to build high-performing, platform-independent programs";
     license = licenses.gpl2Plus;
     maintainers = with maintainers; [ pSub ];
diff --git a/pkgs/development/libraries/libfsm/default.nix b/pkgs/development/libraries/libfsm/default.nix
new file mode 100644
index 00000000000..5491fab3edf
--- /dev/null
+++ b/pkgs/development/libraries/libfsm/default.nix
@@ -0,0 +1,53 @@
+{ stdenv, fetchFromGitHub
+, bmake
+}:
+
+stdenv.mkDerivation rec {
+  name    = "libfsm-${version}";
+  version = "0.1pre1869_${builtins.substring 0 7 src.rev}";
+
+  src = fetchFromGitHub {
+    owner  = "katef";
+    repo   = "libfsm";
+    rev    = "f70c3c5778a79eeecb52f9fd35c7cbc241db0ed6";
+    sha256 = "1hgv272jdv6dwnsdjajyky537z84q0cwzspw9br46qj51h8gkwvx";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [ bmake ];
+  enableParallelBuilding = true;
+
+  # note: build checks value of '$CC' to add some extra cflags, but we don't
+  # necessarily know which 'stdenv' someone chose, so we leave it alone (e.g.
+  # if we use stdenv vs clangStdenv, we don't know which, and CC=cc in all
+  # cases.) it's unclear exactly what should be done if we want those flags,
+  # but the defaults work fine.
+  buildPhase = "PREFIX=$out bmake -r install";
+
+  # fix up multi-output install. we also have to fix the pkgconfig libdir
+  # file; it uses prefix=$out; libdir=${prefix}/lib, which is wrong in
+  # our case; libdir should really be set to the $lib output.
+  installPhase = ''
+    mkdir -p $lib $dev/lib
+
+    mv $out/lib             $lib/lib
+    mv $out/include         $dev/include
+    mv $out/share/pkgconfig $dev/lib/pkgconfig
+    rmdir $out/share
+
+    for x in libfsm.pc libre.pc; do
+      substituteInPlace "$dev/lib/pkgconfig/$x" \
+        --replace 'libdir=''${prefix}/lib' "libdir=$lib/lib"
+    done
+  '';
+
+  outputs = [ "out" "lib" "dev" ];
+
+  meta = with stdenv.lib; {
+    description = "DFA regular expression library & friends";
+    homepage    = "https://github.com/katef/libfsm";
+    license     = licenses.bsd2;
+    platforms   = platforms.unix;
+    maintainers = with maintainers; [ thoughtpolice ];
+  };
+}
diff --git a/pkgs/development/libraries/libftdi/default.nix b/pkgs/development/libraries/libftdi/default.nix
index 74b87a46ef0..08ec1d84a3f 100644
--- a/pkgs/development/libraries/libftdi/default.nix
+++ b/pkgs/development/libraries/libftdi/default.nix
@@ -1,6 +1,6 @@
 {stdenv, fetchurl, libusb}:
 
-stdenv.mkDerivation rec {
+with stdenv; mkDerivation rec {
   name = "libftdi-0.20";
 
   src = fetchurl {
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
 
   # Hack to avoid TMPDIR in RPATHs.
   preFixup = ''rm -rf "$(pwd)" '';
-  configureFlags = [ "--with-async-mode" ];
+  configureFlags = lib.optional (!isDarwin) [ "--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
@@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
   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.linux;
+    license = lib.licenses.lgpl21;
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/libraries/libgdamm/default.nix b/pkgs/development/libraries/libgdamm/default.nix
index 4367cc5b276..f5cc5efa06a 100644
--- a/pkgs/development/libraries/libgdamm/default.nix
+++ b/pkgs/development/libraries/libgdamm/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, pkgconfig, glibmm, libgda, libxml2, gnome3
-, mysqlSupport ? false, mysql ? null
-, postgresSupport ? false, postgresql ? null }:
+, mysqlSupport ? false
+, postgresSupport ? false }:
 
 let
   gda = libgda.override {
diff --git a/pkgs/development/libraries/libgdata/default.nix b/pkgs/development/libraries/libgdata/default.nix
index 59e19750715..f61283aec4a 100644
--- a/pkgs/development/libraries/libgdata/default.nix
+++ b/pkgs/development/libraries/libgdata/default.nix
@@ -1,20 +1,86 @@
-{ stdenv, fetchurl, pkgconfig, intltool, libxml2, glib, json-glib, gcr
-, gobject-introspection, liboauth, gnome3, p11-kit, openssl, uhttpmock }:
+{ stdenv
+, fetchurl
+, fetchpatch
+, pkgconfig
+, meson
+, ninja
+, vala
+, gettext
+, libxml2
+, glib
+, json-glib
+, gcr
+, gnome-online-accounts
+, gobject-introspection
+, liboauth
+, gnome3
+, p11-kit
+, openssl
+, uhttpmock
+, libsoup
+}:
 
 stdenv.mkDerivation rec {
   pname = "libgdata";
-  version = "0.17.9";
+  version = "0.17.10";
+
+  outputs = [ "out" "dev" "installedTests" ];
 
   src = fetchurl {
     url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
-    sha256 = "0fj54yqxdapdppisqm1xcyrpgcichdmipq0a0spzz6009ikzgi45";
+    sha256 = "04mh2p5x2iidfx0d1cablxbi3hvna8cmlddc1mm4387n0grx3ly1";
   };
 
-  nativeBuildInputs = [ pkgconfig intltool gobject-introspection ];
+  patches = [
+    ./installed-tests-path.patch
+    (fetchpatch {
+      # Meson fixes
+      url = "https://gitlab.gnome.org/GNOME/libgdata/commit/f6d0e3f3b6fa8e8ee9569372c5709c1fb84af2c1.diff";
+      sha256 = "00yrppn0s21i41r9mwzvrrv7j5dida09kh7i44kv8hrbrlfag7bm";
+    })
+    (fetchpatch {
+      # Meson minor fixes
+      url = "https://gitlab.gnome.org/GNOME/libgdata/commit/b653f602b3c2b518101c5d909e1651534c22757a.diff";
+      sha256 = "1bn0rffsvkzjl59aw8dmq1wil58x1fshz0m6xabpn79ffvbjld8j";
+    })
+    (fetchpatch {
+      # Meson: Fix G_LOG_DOMAIN
+      url = "https://gitlab.gnome.org/GNOME/libgdata/commit/5d318e0bf905d0f1a8b3fe1e47ee7847739082e3.diff";
+      sha256 = "11i2blq811d53433kdq4hhsscgkrq5f50d9ih4ixgs3j47hg7b1w";
+    })
+  ];
+
+  nativeBuildInputs = [
+    gettext
+    gobject-introspection
+    meson
+    ninja
+    pkgconfig
+    vala
+  ];
+
+  buildInputs = [
+    gcr
+    glib
+    liboauth
+    libsoup
+    libxml2
+    openssl
+    p11-kit
+    uhttpmock
+  ];
 
-  buildInputs = [ gnome3.libsoup libxml2 glib liboauth gcr gnome3.gnome-online-accounts p11-kit openssl uhttpmock ];
+  propagatedBuildInputs = [
+    gnome-online-accounts
+    json-glib
+  ];
 
-  propagatedBuildInputs = [ json-glib ];
+  mesonFlags = [
+    "-Dgtk_doc=false"
+    "-Dinstalled_test_bindir=${placeholder ''installedTests''}/libexec"
+    "-Dinstalled_test_datadir=${placeholder ''installedTests''}/share"
+    "-Dinstalled_tests=true"
+  ];
 
   passthru = {
     updateScript = gnome3.updateScript {
@@ -26,7 +92,7 @@ stdenv.mkDerivation rec {
   meta = with stdenv.lib; {
     description = "GData API library";
     homepage = https://wiki.gnome.org/Projects/libgdata;
-    maintainers = with maintainers; [ raskin lethalman ];
+    maintainers = with maintainers; [ raskin lethalman ] ++ gnome3.maintainers;
     platforms = platforms.linux;
     license = licenses.lgpl21Plus;
   };
diff --git a/pkgs/development/libraries/libgdata/installed-tests-path.patch b/pkgs/development/libraries/libgdata/installed-tests-path.patch
new file mode 100644
index 00000000000..18669817cfe
--- /dev/null
+++ b/pkgs/development/libraries/libgdata/installed-tests-path.patch
@@ -0,0 +1,94 @@
+diff --git a/gdata/tests/meson.build b/gdata/tests/meson.build
+index 52154e7a..1a44d1d8 100644
+--- a/gdata/tests/meson.build
++++ b/gdata/tests/meson.build
+@@ -1,5 +1,12 @@
+-tests_execdir = gdata_libexecdir / 'installed-tests' / gdata_name
+-tests_metadir = gdata_datadir / 'installed-tests' / gdata_name
++tests_bindir = get_option('installed_test_bindir') / 'installed-tests' / gdata_name
++if tests_bindir == ''
++    test_bindir = gdata_libexecdir / 'installed-tests' / gdata_name
++endif
++
++tests_datadir = get_option('installed_test_datadir') / 'installed-tests' / gdata_name
++if tests_datadir == ''
++    tests_datadir = gdata_datadir / 'installed-tests' / gdata_name
++endif
+ 
+ tests_sources = files(
+   'common.c',
+@@ -48,7 +55,7 @@ foreach test_name, extra_args: tests
+     dependencies: common_deps + extra_args.get('dependencies', []),
+     sources: tests_sources,
+     install: install_tests,
+-    install_dir: tests_execdir,
++    install_dir: tests_bindir,
+   )
+ 
+   test(
+@@ -63,7 +70,7 @@ if install_tests
+   foreach test_name, extra_args: tests
+     tests_conf = {
+       'TEST_TYPE': 'session',
+-      'TEST_ABS_PATH': gdata_prefix / tests_execdir / test_name,
++      'TEST_ABS_PATH': tests_bindir / test_name,
+     }
+ 
+     configure_file (
+@@ -71,13 +78,13 @@ if install_tests
+       output: test_name + '.test',
+       configuration: tests_conf,
+       install: true,
+-      install_dir: tests_metadir,
++      install_dir: tests_datadir,
+     )
+   endforeach
+ 
+   install_subdir(
+     'traces',
+-    install_dir: tests_execdir,
++    install_dir: tests_bindir,
+   )
+ 
+   test_data = [
+@@ -96,6 +103,6 @@ if install_tests
+ 
+   install_data(
+     test_data,
+-    install_dir: tests_execdir,
++    install_dir: tests_bindir,
+   )
+ endif
+diff --git a/meson.build b/meson.build
+index 7d2f5254..bed3e189 100644
+--- a/meson.build
++++ b/meson.build
+@@ -20,9 +20,9 @@ gdata_api_version_minor = 0
+ 
+ # Define the install directories
+ gdata_prefix = get_option('prefix')
+-gdata_datadir = get_option('datadir')
+-gdata_libexecdir = get_option('libexecdir')
+-gdata_includedir = get_option('includedir')
++gdata_datadir = gdata_prefix / get_option('datadir')
++gdata_libexecdir = gdata_prefix / get_option('libexecdir')
++gdata_includedir = gdata_prefix / get_option('includedir')
+ 
+ gdata_include_subdir = gdata_name / 'gdata'
+ 
+diff --git a/meson_options.txt b/meson_options.txt
+index 25cc6b55..6fc2cfa3 100644
+--- a/meson_options.txt
++++ b/meson_options.txt
+@@ -43,3 +43,11 @@ option('vapi',
+   type: 'boolean',
+   value: true,
+   description: 'Enable creation of vapi files')
++
++option('installed_test_datadir', type: 'string',
++  value: '',
++  description: 'Installation directory for data files in tests')
++
++option('installed_test_bindir', type: 'string',
++  value: '',
++  description: 'Installation directory for binary files in tests')
diff --git a/pkgs/development/libraries/libgeotiff/default.nix b/pkgs/development/libraries/libgeotiff/default.nix
index 33b9e7830e7..51520eb0fe3 100644
--- a/pkgs/development/libraries/libgeotiff/default.nix
+++ b/pkgs/development/libraries/libgeotiff/default.nix
@@ -1,18 +1,27 @@
-{ stdenv, fetchurl, libtiff, libjpeg, proj, zlib}:
+{ stdenv, fetchFromGitHub, libtiff, libjpeg, proj, zlib, autoreconfHook }:
 
 stdenv.mkDerivation rec {
-  version = "1.4.3";
+  version = "1.5.1";
   name = "libgeotiff-${version}";
 
-  src = fetchurl {
-    url = "https://download.osgeo.org/geotiff/libgeotiff/${name}.tar.gz";
-    sha256 = "0rbjqixi4c8yz19larlzq6jda0px2gpmpp9c52cyhplbjsdhsldq";
+  src = fetchFromGitHub {
+    owner = "OSGeo";
+    repo = "libgeotiff";
+    rev = version;
+    sha256 = "081ag23pn2n5y4fkb2rnh4hmcnq92siqiqv0s20jmx0j3s2nvfxy";
   };
 
+  outputs = [ "out" "dev" ];
+
+  sourceRoot = "source/libgeotiff";
+
   configureFlags = [
     "--with-jpeg=${libjpeg.dev}"
     "--with-zlib=${zlib.dev}"
   ];
+
+  nativeBuildInputs = [ autoreconfHook ];
+
   buildInputs = [ libtiff proj ];
 
   hardeningDisable = [ "format" ];
diff --git a/pkgs/development/libraries/libgig/default.nix b/pkgs/development/libraries/libgig/default.nix
index 08fce9c521e..56f160838e6 100644
--- a/pkgs/development/libraries/libgig/default.nix
+++ b/pkgs/development/libraries/libgig/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libgig-${version}";
-  version = "4.1.0";
+  version = "4.2.0";
 
   src = fetchurl {
     url = "https://download.linuxsampler.org/packages/${name}.tar.bz2";
-    sha256 = "02xx6bqxzgkvrawwnzrnxx1ypk244q4kpwfd58266f9ji8kq18h6";
+    sha256 = "1zs5yy124bymfyapsnljr6rv2lnn5inwchm0xnwiw44b2d39l8hn";
   };
 
   nativeBuildInputs = [ autoconf automake libtool pkgconfig ];
diff --git a/pkgs/development/libraries/libgpg-error/default.nix b/pkgs/development/libraries/libgpg-error/default.nix
index dc221156f46..f3e1b8b0f99 100644
--- a/pkgs/development/libraries/libgpg-error/default.nix
+++ b/pkgs/development/libraries/libgpg-error/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchpatch, buildPackages, fetchurl, gettext
+{ stdenv, lib, buildPackages, fetchurl, gettext
 , genPosixLockObjOnly ? false
 }: let
   genPosixLockObjOnlyAttrs = lib.optionalAttrs genPosixLockObjOnly {
diff --git a/pkgs/development/libraries/libgphoto2/default.nix b/pkgs/development/libraries/libgphoto2/default.nix
index 8616a014675..cbedd97b2ee 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 = "0pbfg89817qkb35mmajsw2iz6j9nhkkj67m419f8x8yxpqkaa0wb";
+    sha256 = "1sc2ycx11khf0qzp1cqxxx1qymv6bjfbkx3vvbwz6wnbyvsigxz2";
   };
 
   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.17";
-    tag = "libgphoto2-2_5_17-release";
+    version = "2.5.23";
+    tag = "libgphoto2-2_5_23-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/libgpiod/default.nix b/pkgs/development/libraries/libgpiod/default.nix
index c498ef3460a..23f46ad2a0c 100644
--- a/pkgs/development/libraries/libgpiod/default.nix
+++ b/pkgs/development/libraries/libgpiod/default.nix
@@ -1,13 +1,12 @@
-{ stdenv, fetchgit, autoreconfHook, autoconf-archive, pkgconfig, kmod, enable-tools ? true }:
+{ stdenv, fetchurl, autoreconfHook, autoconf-archive, pkgconfig, kmod, enable-tools ? true }:
 
 stdenv.mkDerivation rec {
-  name = "libgpiod-unstable-${version}";
-  version = "2018-10-07";
+  pname = "libgpiod";
+  version = "1.4.1";
 
-  src = fetchgit {
-    url = "https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git";
-    rev = "4bf402d3a49336eacd33654441d575bd267780b8";
-    sha256 = "01f3jzb133z189sxdiz9qiy65p0bjqhynfllidbpxdr0cxkyyc1d";
+  src = fetchurl {
+    url = "https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/snapshot/libgpiod-${version}.tar.gz";
+    sha256 = "0x8ar31b0cp47dgmamxf6a54ixwrjgvs81zra8l9ws4szrzgrnbw";
   };
 
   buildInputs = [ kmod ];
@@ -20,7 +19,7 @@ stdenv.mkDerivation rec {
   configureFlags = [
     "--enable-tools=${if enable-tools then "yes" else "no"}"
     "--enable-bindings-cxx"
-    "--prefix=$(out)"
+    "--prefix=${placeholder ''out''}"
   ];
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libgpod/default.nix b/pkgs/development/libraries/libgpod/default.nix
index b77690bd159..d561ebcd7af 100644
--- a/pkgs/development/libraries/libgpod/default.nix
+++ b/pkgs/development/libraries/libgpod/default.nix
@@ -1,5 +1,5 @@
 {stdenv, lib, fetchurl, gettext, perlPackages, intltool, pkgconfig, glib,
-  libxml2, sqlite, zlib, sg3_utils, gdk_pixbuf, taglib,
+  libxml2, sqlite, zlib, sg3_utils, gdk-pixbuf, taglib,
   libimobiledevice, pythonPackages, mutagen,
   monoSupport ? false, mono, gtk-sharp-2_0
 }:
@@ -23,7 +23,7 @@ in stdenv.mkDerivation rec {
   dontStrip = true;
 
   propagatedBuildInputs = [ glib libxml2 sqlite zlib sg3_utils
-    gdk_pixbuf taglib libimobiledevice python pygobject2 mutagen ];
+    gdk-pixbuf taglib libimobiledevice python pygobject2 mutagen ];
 
   nativeBuildInputs = [ gettext intltool pkgconfig ]
     ++ (with perlPackages; [ perl XMLParser ])
diff --git a/pkgs/development/libraries/libgsf/default.nix b/pkgs/development/libraries/libgsf/default.nix
index f2d31cf1676..89a72bba872 100644
--- a/pkgs/development/libraries/libgsf/default.nix
+++ b/pkgs/development/libraries/libgsf/default.nix
@@ -1,5 +1,5 @@
 { fetchurl, stdenv, pkgconfig, intltool, gettext, glib, libxml2, zlib, bzip2
-, python, perl, gdk_pixbuf, libiconv, libintl, gnome3 }:
+, python, perl, gdk-pixbuf, libiconv, libintl, gnome3 }:
 
 stdenv.mkDerivation rec {
   pname = "libgsf";
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ gettext bzip2 zlib python ];
   checkInputs = [ perl ];
 
-  propagatedBuildInputs = [ libxml2 glib gdk_pixbuf libiconv ];
+  propagatedBuildInputs = [ libxml2 glib gdk-pixbuf libiconv ];
 
   outputs = [ "out" "dev" ];
 
diff --git a/pkgs/development/libraries/libgweather/default.nix b/pkgs/development/libraries/libgweather/default.nix
index 3300e9b1d68..5e35a43fb9d 100644
--- a/pkgs/development/libraries/libgweather/default.nix
+++ b/pkgs/development/libraries/libgweather/default.nix
@@ -3,13 +3,13 @@
 
 stdenv.mkDerivation rec {
   pname = "libgweather";
-  version = "3.32.1";
+  version = "3.32.2";
 
   outputs = [ "out" "dev" "devdoc" ];
 
   src = fetchurl {
     url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
-    sha256 = "1079d26y8d2zaw9w50l9scqjhbrynpdd6kyaa32x4393f7nih8hw";
+    sha256 = "00iwbllh8dmnqch0ysng9xhkzzs3ir9jl9f4hp41vbvg1pq5zv98";
   };
 
   nativeBuildInputs = [ meson ninja pkgconfig gettext vala gtk-doc docbook_xsl docbook_xml_dtd_43 gobject-introspection python3 ];
diff --git a/pkgs/development/libraries/libhandy/default.nix b/pkgs/development/libraries/libhandy/default.nix
index d32bb82abcb..9c3d9faf1f4 100644
--- a/pkgs/development/libraries/libhandy/default.nix
+++ b/pkgs/development/libraries/libhandy/default.nix
@@ -7,7 +7,7 @@
 
 let
   pname = "libhandy";
-  version = "0.0.9";
+  version = "0.0.10";
 in stdenv.mkDerivation rec {
   name = "${pname}-${version}";
 
@@ -19,7 +19,7 @@ in stdenv.mkDerivation rec {
     owner = "Librem5";
     repo = pname;
     rev = "v${version}";
-    sha256 = "0smfnvfba6cnxbrcm1vh3zbr1hww43qcxhawka3hzn2hjr06rfzn";
+    sha256 = "1702hbdqhfpgw0c4vj2ag08vgl83byiryrbngbq11b9azmj3jhzs";
   };
 
   nativeBuildInputs = [
diff --git a/pkgs/development/libraries/libhttpseverywhere/default.nix b/pkgs/development/libraries/libhttpseverywhere/default.nix
index cf5c80c9b21..c58812eca58 100644
--- a/pkgs/development/libraries/libhttpseverywhere/default.nix
+++ b/pkgs/development/libraries/libhttpseverywhere/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, pkgconfig, meson, ninja, makeFontsConf, vala, fetchpatch
-, gnome3, glib, json-glib, libarchive, libsoup, gobject-introspection, valadoc }:
+, gnome3, glib, json-glib, libarchive, libsoup, gobject-introspection }:
 
 let
   pname = "libhttpseverywhere";
diff --git a/pkgs/development/libraries/libical/default.nix b/pkgs/development/libraries/libical/default.nix
index 91653022052..b86a48ecd1b 100644
--- a/pkgs/development/libraries/libical/default.nix
+++ b/pkgs/development/libraries/libical/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchFromGitHub, perl, pkgconfig, cmake, ninja, vala, gobject-introspection
-, python3, tzdata, gtk-doc, docbook_xsl, docbook_xml_dtd_43, glib, libxml2, icu }:
+, python3, tzdata, glib, libxml2, icu }:
 
 stdenv.mkDerivation rec {
   name = "libical-${version}";
diff --git a/pkgs/development/libraries/libiio/default.nix b/pkgs/development/libraries/libiio/default.nix
index ee8029966dc..df5035461af 100644
--- a/pkgs/development/libraries/libiio/default.nix
+++ b/pkgs/development/libraries/libiio/default.nix
@@ -1,6 +1,7 @@
 { stdenv, fetchFromGitHub
 , cmake, flex, bison
 , libxml2, python
+, libusb1, runtimeShell
 }:
 
 stdenv.mkDerivation rec {
@@ -17,7 +18,17 @@ stdenv.mkDerivation rec {
   outputs = [ "out" "lib" "dev" "python" ];
 
   nativeBuildInputs = [ cmake flex bison ];
-  buildInputs = [ libxml2 ];
+  buildInputs = [ libxml2 libusb1 ];
+
+  postPatch = ''
+    substituteInPlace libiio.rules.cmakein \
+      --replace /bin/sh ${runtimeShell}
+  '';
+
+  # since we can't expand $out in cmakeFlags
+  preConfigure = ''
+    cmakeFlags="$cmakeFlags -DUDEV_RULES_INSTALL_DIR=$out/etc/udev/rules.d"
+  '';
 
   postInstall = ''
     mkdir -p $python/lib/${python.libPrefix}/site-packages/
diff --git a/pkgs/development/libraries/libimagequant/default.nix b/pkgs/development/libraries/libimagequant/default.nix
index 83afd26bf1d..9c2dd920c9f 100644
--- a/pkgs/development/libraries/libimagequant/default.nix
+++ b/pkgs/development/libraries/libimagequant/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   pname = "libimagequant";
-  version = "2.12.3";
+  version = "2.12.5";
 
   src = fetchFromGitHub {
     owner = "ImageOptim";
     repo = pname;
     rev = version;
-    sha256 = "0qsfq1kv1m5jzn9v9iz0bac66k4clcis1c9877qabnwzwmwma5v0";
+    sha256 = "0cp68w04ja5pv77ssfafsn958w9hh9zb8crrlb5j3gsrcmdc032k";
   };
 
   preConfigure = ''
diff --git a/pkgs/development/libraries/libimobiledevice/default.nix b/pkgs/development/libraries/libimobiledevice/default.nix
index 83a500c1380..6464e4e5820 100644
--- a/pkgs/development/libraries/libimobiledevice/default.nix
+++ b/pkgs/development/libraries/libimobiledevice/default.nix
@@ -34,7 +34,6 @@ stdenv.mkDerivation rec {
   preConfigure = "NOCONFIGURE=1 ./autogen.sh";
 
   configureFlags = [
-    "--disable-static"
     "--disable-openssl"
     "--without-cython"
   ];
diff --git a/pkgs/development/libraries/libinput/default.nix b/pkgs/development/libraries/libinput/default.nix
index 651c4329708..0c759835183 100644
--- a/pkgs/development/libraries/libinput/default.nix
+++ b/pkgs/development/libraries/libinput/default.nix
@@ -27,11 +27,11 @@ in
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "libinput-${version}";
-  version = "1.13.2";
+  version = "1.13.4";
 
   src = fetchurl {
     url = "https://www.freedesktop.org/software/libinput/${name}.tar.xz";
-    sha256 = "0vbapc90m49n0z8w8w4v0qf1iiwaixw9h79jfmps9pj8hdls17qx";
+    sha256 = "07a0w7rak7rvnh6g4j0akwjxwinxfszc1xi9mrx12fv82k3mgsyk";
   };
 
   outputs = [ "bin" "out" "dev" ];
diff --git a/pkgs/development/libraries/libirecovery/default.nix b/pkgs/development/libraries/libirecovery/default.nix
new file mode 100644
index 00000000000..32a2971b3e3
--- /dev/null
+++ b/pkgs/development/libraries/libirecovery/default.nix
@@ -0,0 +1,54 @@
+{ stdenv, fetchFromGitHub, automake, autoconf, libtool, pkgconfig
+, libusb
+, readline
+}:
+
+stdenv.mkDerivation rec {
+  pname = "libirecovery";
+  version = "2019-01-28";
+
+  src = fetchFromGitHub {
+    owner = "libimobiledevice";
+    repo = pname;
+    rev = "5da2a0d7d60f79d93c283964888c6fbbc17be1a3";
+    sha256 = "0fqmr1h4b3qn608dn606y7aqv3bsm949gx72b5d6433xlw9b23n8";
+  };
+
+  outputs = [ "out" "dev" ];
+
+  nativeBuildInputs = [
+    autoconf
+    automake
+    libtool
+    pkgconfig
+  ];
+
+  buildInputs = [
+    libusb
+    readline
+  ];
+
+  preConfigure = "NOCONFIGURE=1 ./autogen.sh";
+
+  # Packager note: Not clear whether this needs a NixOS configuration,
+  # as only the `idevicerestore` binary was tested so far (which worked
+  # without further configuration).
+  configureFlags = [
+    "--with-udevrulesdir=${placeholder ''out''}/lib/udev/rules.d"
+    ''--with-udevrule="OWNER=\"root\", GROUP=\"myusergroup\", MODE=\"0660\""''
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/libimobiledevice/libirecovery;
+    description = "Library and utility to talk to iBoot/iBSS via USB on Mac OS X, Windows, and Linux";
+    longDescription = ''
+      libirecovery is a cross-platform library which implements communication to
+      iBoot/iBSS found on Apple's iOS devices via USB. A command-line utility is also
+      provided.
+    '';
+    license = licenses.lgpl21;
+    # Upstream description says it works on more platforms, but packager hasn't tried that yet
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ nh2 ];
+  };
+}
diff --git a/pkgs/development/libraries/libivykis/default.nix b/pkgs/development/libraries/libivykis/default.nix
index 9419046db4e..51b2dd7c7bd 100644
--- a/pkgs/development/libraries/libivykis/default.nix
+++ b/pkgs/development/libraries/libivykis/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
       notification facilities
     '';
     license = licenses.zlib;
-    maintainers = [ maintainers.rickynils ];
+    maintainers = [];
     platforms = platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/libjpeg-turbo/default.nix b/pkgs/development/libraries/libjpeg-turbo/default.nix
index 57c35ab8677..191c375f3be 100644
--- a/pkgs/development/libraries/libjpeg-turbo/default.nix
+++ b/pkgs/development/libraries/libjpeg-turbo/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, cmake, nasm }:
+{ stdenv, fetchurl, cmake, nasm }:
 
 stdenv.mkDerivation rec {
 
@@ -18,7 +18,9 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake nasm ];
 
-  cmakeFlags = [ "-DCMAKE_INSTALL_BINDIR=${placeholder "bin"}/bin" "-DENABLE_STATIC=0" ];
+  cmakeFlags = [
+    "-DENABLE_STATIC=0"
+  ];
 
   doInstallCheck = true;
   installCheckTarget = "test";
diff --git a/pkgs/development/libraries/liblastfm/default.nix b/pkgs/development/libraries/liblastfm/default.nix
index b7d90100837..767485a7515 100644
--- a/pkgs/development/libraries/liblastfm/default.nix
+++ b/pkgs/development/libraries/liblastfm/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, qt4, pkgconfig, libsamplerate, fftwSinglePrec, which, cmake
 , darwin }:
 
-let version = "1.0.9"; in
+let version = "1.1.0"; in
 
 stdenv.mkDerivation rec {
   name = "liblastfm-${version}";
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
   src = fetchurl {
     url = "https://github.com/lastfm/liblastfm/tarball/${version}";
     name = "${name}.tar.gz";
-    sha256 = "09qiaxsxw6g2m7mvkffpfsi5wis8nl1x4lgnk0sa30859z54iw53";
+    sha256 = "1j34xc30vg7sfszm2jx9mlz9hy7p1l929fka9wnfcpbib8gfi43x";
   };
 
   prefixKey = "--prefix ";
diff --git a/pkgs/development/libraries/liblcf/default.nix b/pkgs/development/libraries/liblcf/default.nix
index 313780a9f0f..9870e024687 100644
--- a/pkgs/development/libraries/liblcf/default.nix
+++ b/pkgs/development/libraries/liblcf/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "liblcf-${version}";
-  version = "0.6.0";
+  version = "0.6.1";
 
   src = fetchFromGitHub {
     owner = "EasyRPG";
     repo = "liblcf";
     rev = version;
-    sha256 = "1nhwwb32c3x0y82s0w93k0xz8h6xsd0sb4r1a0my8fd8p5rsnwbi";
+    sha256 = "18kx9h004bncyi0hbj6vrc7f4k8l1rwp96cwncv3xm0lwspj0vyl";
   };
 
   nativeBuildInputs = [ autoreconfHook pkgconfig ];
diff --git a/pkgs/development/libraries/liblockfile/default.nix b/pkgs/development/libraries/liblockfile/default.nix
index 46ea9fe6ee5..aba751bae5c 100644
--- a/pkgs/development/libraries/liblockfile/default.nix
+++ b/pkgs/development/libraries/liblockfile/default.nix
@@ -2,12 +2,12 @@
 
 stdenv.mkDerivation rec {
   _name   = "liblockfile";
-  version = "1.14";
+  version = "1.15";
   name    = "${_name}-${version}";
 
   src = fetchurl {
     url = "mirror://debian/pool/main/libl/${_name}/${_name}_${version}.orig.tar.gz";
-    sha256 = "0q6hn78fnzr6lhisg85a948rmpsd9rx67skzx3vh9hnbx2ix8h5b";
+    sha256 = "04ml9isvdl72fbr1825x7jb680xp8aprdq4pag32ahyjqk909cmh";
   };
 
   preConfigure = ''
diff --git a/pkgs/development/libraries/liblouis/default.nix b/pkgs/development/libraries/liblouis/default.nix
index a3af7aab526..c2731e44efb 100644
--- a/pkgs/development/libraries/liblouis/default.nix
+++ b/pkgs/development/libraries/liblouis/default.nix
@@ -3,7 +3,7 @@
 }:
 
 let
-  version = "3.9.0";
+  version = "3.10.0";
 in stdenv.mkDerivation rec {
   name = "liblouis-${version}";
 
@@ -11,7 +11,7 @@ in stdenv.mkDerivation rec {
     owner = "liblouis";
     repo = "liblouis";
     rev = "v${version}";
-    sha256 = "11vq9rnmrfqka3fiyrxs0q1gpvpj4m9jmrkwd1yvrq94fndgvh1m";
+    sha256 = "1wimv2wfl566jp8hhrxr91dmx20hldqzj70dar8i9k3hzq1kmb4q";
   };
 
   outputs = [ "out" "dev" "man" "info" "doc" ];
diff --git a/pkgs/development/libraries/libmediaart/default.nix b/pkgs/development/libraries/libmediaart/default.nix
index 64d2cc7577c..569c567e928 100644
--- a/pkgs/development/libraries/libmediaart/default.nix
+++ b/pkgs/development/libraries/libmediaart/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, meson, ninja, pkgconfig, vala, gtk-doc, docbook_xsl, docbook_xml_dtd_412, glib, gdk_pixbuf, gobject-introspection, gnome3 }:
+{ stdenv, fetchurl, meson, ninja, pkgconfig, vala, gtk-doc, docbook_xsl, docbook_xml_dtd_412, glib, gdk-pixbuf, gobject-introspection, gnome3 }:
 
 stdenv.mkDerivation rec {
   pname = "libmediaart";
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ meson ninja pkgconfig vala gtk-doc docbook_xsl docbook_xml_dtd_412 gobject-introspection ];
-  buildInputs = [ glib gdk_pixbuf ];
+  buildInputs = [ glib gdk-pixbuf ];
 
   # FIXME: Turn on again when https://github.com/NixOS/nixpkgs/issues/53701
   # is fixed on master.
diff --git a/pkgs/development/libraries/libmediainfo/default.nix b/pkgs/development/libraries/libmediainfo/default.nix
index 172b9cd88da..bf6aa0d23fb 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 = "19.04";
+  version = "19.07";
   name = "libmediainfo-${version}";
   src = fetchurl {
     url = "https://mediaarea.net/download/source/libmediainfo/${version}/libmediainfo_${version}.tar.xz";
-    sha256 = "1yr2vl2z9z1kllr5ygi39r1ryw695cic8yj34yragkk33l1z6xc2";
+    sha256 = "0k3d7mha1lay2s09crc9z9zr970l617lb0c3b35wl44flkqf7jss";
   };
 
   nativeBuildInputs = [ autoreconfHook pkgconfig ];
diff --git a/pkgs/development/libraries/libmicrohttpd/default.nix b/pkgs/development/libraries/libmicrohttpd/default.nix
index 0ecd568c376..f75d32c4313 100644
--- a/pkgs/development/libraries/libmicrohttpd/default.nix
+++ b/pkgs/development/libraries/libmicrohttpd/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "libmicrohttpd-${version}";
-  version = "0.9.63";
+  version = "0.9.64";
 
   src = fetchurl {
     url = "mirror://gnu/libmicrohttpd/${name}.tar.gz";
-    sha256 = "173lj66crwvhzwp1r812sc5h1hda7g6lb9l1y5zf7w3pw4dnzhrp";
+    sha256 = "03imzkd1hl2mkkpi84vg5xq9x6b58gwsv86ym85km0lhb7nxi4p7";
   };
 
   outputs = [ "out" "dev" "devdoc" "info" ];
diff --git a/pkgs/development/libraries/libmikmod/default.nix b/pkgs/development/libraries/libmikmod/default.nix
index ef095fd4336..284d415454d 100644
--- a/pkgs/development/libraries/libmikmod/default.nix
+++ b/pkgs/development/libraries/libmikmod/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, texinfo, alsaLib, libpulseaudio, CoreAudio }:
 
 let
-  inherit (stdenv.lib) optional optionals optionalString;
+  inherit (stdenv.lib) optional optionalString;
 
 in stdenv.mkDerivation rec {
   name = "libmikmod-3.3.11.1";
diff --git a/pkgs/development/libraries/libmodbus/default.nix b/pkgs/development/libraries/libmodbus/default.nix
index 182d642bc08..e18de4127a4 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.1.4";
+  name = "libmodbus-3.1.6";
 
   src = fetchurl {
     url = "http://libmodbus.org/releases/${name}.tar.gz";
-    sha256 = "0drnil8bzd4n4qb0wv3ilm9zvypxvwmzd65w96d6kfm7x6q65j68";
+    sha256 = "05kwz0n5gn9m33cflzv87lz3zp502yp8fpfzbx70knvfl6agmnfp";
   };
 
   configureFlags = [
diff --git a/pkgs/development/libraries/libmodule/default.nix b/pkgs/development/libraries/libmodule/default.nix
new file mode 100644
index 00000000000..bcd20c3b407
--- /dev/null
+++ b/pkgs/development/libraries/libmodule/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchFromGitHub
+, cmake, pkgconfig }:
+
+stdenv.mkDerivation rec {
+  pname = "libmodule";
+  version = "4.2.0";
+
+  src = fetchFromGitHub {
+    owner = "FedeDP";
+    repo = "libmodule";
+    rev = version;
+    sha256 = "1qn54pysdm0q7v1gnisd43i5i4ylf8s8an77jk6jd8qimysv08mx";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    pkgconfig
+  ];
+
+  meta = with stdenv.lib; {
+    description = "C simple and elegant implementation of an actor library";
+    homepage = https://github.com/FedeDP/libmodule;
+    platforms = platforms.linux;
+    license = licenses.mit;
+    maintainers = with maintainers; [
+      eadwu
+    ];
+  };
+}
diff --git a/pkgs/development/libraries/libmodulemd/1.nix b/pkgs/development/libraries/libmodulemd/1.nix
new file mode 100644
index 00000000000..174296375e0
--- /dev/null
+++ b/pkgs/development/libraries/libmodulemd/1.nix
@@ -0,0 +1,21 @@
+{ libmodulemd, fetchurl }:
+
+libmodulemd.overrideAttrs(old: rec {
+  name = "libmodulemd-${version}";
+  version = "1.8.15";
+
+  # Removes py output since there's no overrides here
+  outputs = [ "out" "devdoc" ];
+
+  patches = [
+    # Checks for glib docs in glib's prefix
+    # but they're installed to another
+    ./dont-check-docs.patch
+  ];
+
+  src = fetchurl {
+    url = "https://github.com/fedora-modularity/libmodulemd/releases/download/${name}/modulemd-${version}.tar.xz";
+    sha256 = "0gz8p3qzji3cx0r57sy3gn4dhigg4k7pcxj3lmjcjn13vxh5rm7z";
+  };
+
+})
diff --git a/pkgs/development/libraries/libmodulemd/default.nix b/pkgs/development/libraries/libmodulemd/default.nix
new file mode 100644
index 00000000000..ba77c7806b5
--- /dev/null
+++ b/pkgs/development/libraries/libmodulemd/default.nix
@@ -0,0 +1,59 @@
+{ stdenv
+, fetchFromGitHub
+, pkgconfig
+, meson
+, ninja
+, gobject-introspection
+, python3
+, libyaml
+, gtk-doc
+, docbook_xsl
+, docbook_xml_dtd_412
+, glib
+}:
+
+stdenv.mkDerivation rec {
+  pname = "libmodulemd";
+  version = "2.6.0";
+
+  outputs = [ "out" "devdoc" "py" ];
+
+  src = fetchFromGitHub {
+    owner = "fedora-modularity";
+    repo = pname;
+    rev = "${pname}-${version}";
+    sha256 = "0gizfmzs6jrzb29lwcimm5dq3027935xbzwgkbvbp67zcmjd3y5i";
+  };
+
+  patches = [
+    ./pygobject-dir.patch
+  ];
+
+  nativeBuildInputs = [
+    pkgconfig
+    meson
+    ninja
+    gtk-doc
+    docbook_xsl
+    docbook_xml_dtd_412
+    gobject-introspection
+  ];
+
+  buildInputs = [
+    libyaml
+    glib
+  ];
+
+  mesonFlags = [
+    "-Ddeveloper_build=false"
+    "-Dpygobject_override_dir=${placeholder "py"}/${python3.sitePackages}/gi/overrides"
+  ];
+
+  meta = with stdenv.lib; {
+    description = "C Library for manipulating module metadata files";
+    homepage = "https://github.com/fedora-modularity/libmodulemd";
+    license = licenses.mit;
+    maintainers = with maintainers; [ ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/libmodulemd/dont-check-docs.patch b/pkgs/development/libraries/libmodulemd/dont-check-docs.patch
new file mode 100644
index 00000000000..38ad5683692
--- /dev/null
+++ b/pkgs/development/libraries/libmodulemd/dont-check-docs.patch
@@ -0,0 +1,29 @@
+diff --git a/meson.build b/meson.build
+index 155c9e7..9125372 100644
+--- a/meson.build
++++ b/meson.build
+@@ -60,15 +60,15 @@ sh = find_program('sh')
+ sed = find_program('sed')
+ test = find_program('test')
+ 
+-ret = run_command ([test, '-e', join_paths(glib_docpath, 'glib/index.html')])
+-if ret.returncode() != 0
+-  error('Missing documentation for GLib.')
+-endif
+-
+-ret = run_command ([test, '-e', join_paths(glib_docpath, 'gobject/index.html')])
+-if ret.returncode() != 0
+-  error('Missing documentation for GObject.')
+-endif
++# ret = run_command ([test, '-e', join_paths(glib_docpath, 'glib/index.html')])
++# if ret.returncode() != 0
++#   error('Missing documentation for GLib.')
++# endif
++
++# ret = run_command ([test, '-e', join_paths(glib_docpath, 'gobject/index.html')])
++# if ret.returncode() != 0
++#   error('Missing documentation for GObject.')
++# endif
+ 
+ python_name = get_option('python_name')
+ 
diff --git a/pkgs/development/libraries/libmodulemd/pygobject-dir.patch b/pkgs/development/libraries/libmodulemd/pygobject-dir.patch
new file mode 100644
index 00000000000..a367872eec6
--- /dev/null
+++ b/pkgs/development/libraries/libmodulemd/pygobject-dir.patch
@@ -0,0 +1,45 @@
+diff --git a/bindings/python/meson.build b/bindings/python/meson.build
+index 4358b79..61fd5a5 100644
+--- a/bindings/python/meson.build
++++ b/bindings/python/meson.build
+@@ -1,3 +1,5 @@
++pygobject_override_dir = get_option('pygobject_override_dir')
++
+ get_overridedir = '''
+ import os
+ import sysconfig
+@@ -21,7 +23,7 @@ print(overridedir)
+ '''
+ 
+ # Python 3
+-if (get_option('with_py3_overrides'))
++if (get_option('with_py3_overrides')) and pygobject_override_dir == ''
+   ret = run_command([python3, '-c', get_overridedir])
+ 
+   if ret.returncode() != 0
+@@ -34,7 +36,7 @@ if (get_option('with_py3_overrides'))
+ endif
+ 
+ # Python 2
+-if (get_option('with_py2_overrides'))
++if (get_option('with_py2_overrides')) and pygobject_override_dir == ''
+   ret2 = run_command([python2, '-c', get_overridedir])
+ 
+   if ret2.returncode() != 0
+@@ -45,3 +47,7 @@ if (get_option('with_py2_overrides'))
+ 
+   install_data('gi/overrides/Modulemd.py', install_dir: pygobject2_override_dir)
+ endif
++
++if pygobject_override_dir != ''
++    install_data('gi/overrides/Modulemd.py', install_dir: pygobject_override_dir)
++endif
+diff --git a/meson_options.txt b/meson_options.txt
+index 147419f..9071a04 100644
+--- a/meson_options.txt
++++ b/meson_options.txt
+@@ -18,3 +18,4 @@ option('skip_introspection', type : 'boolean', value : false)
+ option('python_name', type : 'string')
+ option('with_py2_overrides', type : 'boolean', value : false)
+ option('with_py3_overrides', type : 'boolean', value : true)
++option('pygobject_override_dir', type : 'string', value : '', description: 'Path to pygobject overrides directory')
diff --git a/pkgs/development/libraries/libmpack/default.nix b/pkgs/development/libraries/libmpack/default.nix
index 2754c726da2..4df38a9cc3c 100644
--- a/pkgs/development/libraries/libmpack/default.nix
+++ b/pkgs/development/libraries/libmpack/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
     description = "Simple implementation of msgpack in C";
     homepage = https://github.com/tarruda/libmpack/;
     license = licenses.mit;
-    maintainers = with maintainers; [ lovek323 garbas ];
+    maintainers = with maintainers; [ lovek323 ];
     platforms = platforms.linux ++ platforms.darwin;
   };
 }
diff --git a/pkgs/development/libraries/libndctl/default.nix b/pkgs/development/libraries/libndctl/default.nix
index d9db09f1e98..38c6bb00863 100644
--- a/pkgs/development/libraries/libndctl/default.nix
+++ b/pkgs/development/libraries/libndctl/default.nix
@@ -1,17 +1,17 @@
 { stdenv, fetchFromGitHub, autoreconfHook
 , asciidoctor, pkgconfig, xmlto, docbook_xsl, docbook_xml_dtd_45, libxslt
-, json_c, kmod, which, file, utillinux, systemd, keyutils
+, json_c, kmod, which, utillinux, systemd, keyutils
 }:
 
 stdenv.mkDerivation rec {
   name = "libndctl-${version}";
-  version = "65";
+  version = "66";
 
   src = fetchFromGitHub {
     owner  = "pmem";
     repo   = "ndctl";
     rev    = "v${version}";
-    sha256 = "0d8hzfvyxs2q8kgkwgdizlml41kin4mhx3vpdsjk34pfi7mqy69y";
+    sha256 = "1pq1ss6b1lnyfnvdfhpi0x70jjrnm567fcyvkgvhmp2ndzsn393f";
   };
 
   outputs = [ "out" "lib" "man" "dev" ];
diff --git a/pkgs/development/libraries/libnice/default.nix b/pkgs/development/libraries/libnice/default.nix
index d6bb8ec5046..f4ce1f6eea0 100644
--- a/pkgs/development/libraries/libnice/default.nix
+++ b/pkgs/development/libraries/libnice/default.nix
@@ -20,18 +20,20 @@ stdenv.mkDerivation rec {
     })
   ];
 
-  nativeBuildInputs = [ meson ninja pkgconfig python3 gobject-introspection gtk-doc docbook_xsl docbook_xml_dtd_412 ];
+  nativeBuildInputs = [
+    meson ninja pkgconfig python3 gobject-introspection
+    gtk-doc
+    # Without these, enabling the 'gtk_doc' gives us `FAILED: meson-install`
+    docbook_xsl docbook_xml_dtd_412
+  ];
   buildInputs = [ gst_all_1.gstreamer gst_all_1.gst-plugins-base gnutls ];
   propagatedBuildInputs = [ glib gupnp-igd ];
 
   mesonFlags = [
-    "-Dgupnp=enabled"
-    "-Dgstreamer=enabled"
-    "-Dignored-network-interface-prefix=enabled"
-    "-Dexamples=enabled"
-    "-Dtests=enabled"
-    "-Dgtk_doc=enabled"
-    "-Dintrospection=enabled"
+    # Enables all features, so that we know when new dependencies are necessary.
+    "-Dauto_features=enabled"
+    "-Dgtk_doc=enabled" # Disabled by default as of libnice-0.1.15
+    "-Dexamples=disabled" # requires many dependencies and probably not useful for our users
   ];
 
   # TODO; see #53293 etc.
diff --git a/pkgs/development/libraries/libnotify/default.nix b/pkgs/development/libraries/libnotify/default.nix
index ddadb3cd97b..be1daa0505a 100644
--- a/pkgs/development/libraries/libnotify/default.nix
+++ b/pkgs/development/libraries/libnotify/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, meson, ninja, pkgconfig, fetchpatch
-, glib, gdk_pixbuf, gobject-introspection, gnome3 }:
+, glib, gdk-pixbuf, gobject-introspection, gnome3 }:
 
 stdenv.mkDerivation rec {
   pname = "libnotify";
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
   ];
 
   nativeBuildInputs = [ meson ninja pkgconfig gobject-introspection ];
-  buildInputs = [ glib gdk_pixbuf ];
+  buildInputs = [ glib gdk-pixbuf ];
 
   passthru = {
     updateScript = gnome3.updateScript {
diff --git a/pkgs/development/libraries/libnxml/default.nix b/pkgs/development/libraries/libnxml/default.nix
index 8d97a13b0a0..0a6c58c8a01 100644
--- a/pkgs/development/libraries/libnxml/default.nix
+++ b/pkgs/development/libraries/libnxml/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
   buildInputs = [ curl ];
 
   meta = {
-    homepage = http://www.autistici.org/bakunin/libnxml/;
+    homepage = https://www.autistici.org/bakunin/libnxml/;
     description = "C library for parsing, writing and creating XML 1.0 and 1.1 files or streams";
     license = stdenv.lib.licenses.lgpl2;
 
diff --git a/pkgs/development/libraries/libosinfo/default.nix b/pkgs/development/libraries/libosinfo/default.nix
index 9efeb0f678e..a040956f553 100644
--- a/pkgs/development/libraries/libosinfo/default.nix
+++ b/pkgs/development/libraries/libosinfo/default.nix
@@ -1,33 +1,32 @@
-{ stdenv, fetchurl, fetchpatch, pkgconfig, intltool, gobject-introspection, gtk-doc, docbook_xsl
-, glib, libsoup, libxml2, libxslt, check, curl, perl, hwdata, osinfo-db, vala ? null
+{ stdenv, fetchurl, fetchpatch, pkgconfig, gettext, gobject-introspection, gtk-doc, docbook_xsl
+, glib, libsoup, libxml2, libxslt, check, curl, perl, hwdata, osinfo-db, substituteAll
+, vala ? null
 }:
 
 stdenv.mkDerivation rec {
   pname = "libosinfo";
-  version = "1.5.0";
+  version = "1.6.0";
 
   src = fetchurl {
     url = "https://releases.pagure.org/${pname}/${pname}-${version}.tar.gz";
-    sha256 = "12b0xj9fz9q91d1pz9xm6aqap5k1ip0m9m3qvqmwjy1lk1kjasdz";
+    sha256 = "1iwh35mahch1ls3sgq7wz8kamxrxisrff5ciqzyh2qxlrqf5qf1w";
   };
 
   outputs = [ "out" "dev" "devdoc" ];
 
   nativeBuildInputs = [
-    pkgconfig vala intltool gobject-introspection gtk-doc docbook_xsl
+    pkgconfig vala gettext gobject-introspection gtk-doc docbook_xsl
   ];
   buildInputs = [ glib libsoup libxml2 libxslt ];
   checkInputs = [ check curl perl ];
 
   patches = [
-    ./osinfo-db-data-dir.patch
+    (substituteAll {
+      src = ./osinfo-db-data-dir.patch;
+      osinfo_db_data_dir = "${osinfo-db}/share";
+    })
   ];
 
-  postPatch = ''
-    patchShebangs .
-    substituteInPlace osinfo/osinfo_loader.c --subst-var-by OSINFO_DB_DATA_DIR "${osinfo-db}/share"
-  '';
-
   configureFlags = [
     "--with-usb-ids-path=${hwdata}/share/hwdata/usb.ids"
     "--with-pci-ids-path=${hwdata}/share/hwdata/pci.ids"
diff --git a/pkgs/development/libraries/libosinfo/osinfo-db-data-dir.patch b/pkgs/development/libraries/libosinfo/osinfo-db-data-dir.patch
index 8d202a92d09..2197eca23d9 100644
--- a/pkgs/development/libraries/libosinfo/osinfo-db-data-dir.patch
+++ b/pkgs/development/libraries/libosinfo/osinfo-db-data-dir.patch
@@ -5,7 +5,7 @@
          path = g_getenv("OSINFO_SYSTEM_DIR");
          if (!path)
 -            path = DATA_DIR "/osinfo";
-+            path = "@OSINFO_DB_DATA_DIR@/osinfo";
++            path = "@osinfo_db_data_dir@/osinfo";
  
          file = g_file_new_for_path(path);
      }
diff --git a/pkgs/development/libraries/libosmium/default.nix b/pkgs/development/libraries/libosmium/default.nix
index 791e4d890f9..885880c54c3 100644
--- a/pkgs/development/libraries/libosmium/default.nix
+++ b/pkgs/development/libraries/libosmium/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "libosmium-${version}";
-  version = "2.15.1";
+  version = "2.15.2";
 
   src = fetchFromGitHub {
     owner = "osmcode";
     repo = "libosmium";
     rev = "v${version}";
-    sha256 = "1v1m068lcjngxnwirpi0vqjhqnxn9gqvafjp3sy14vzmgl2sw2kr";
+    sha256 = "1fh8wl4grs1c0g9whx90kd4jva3k9b6zbb1cl3isay489gwndgss";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/libow/default.nix b/pkgs/development/libraries/libow/default.nix
index 66cb0762c25..7797061a71a 100644
--- a/pkgs/development/libraries/libow/default.nix
+++ b/pkgs/development/libraries/libow/default.nix
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "1-Wire File System full library";
-    homepage = http://owfs.org/;
+    homepage = https://owfs.org/;
     license = licenses.gpl2;
     maintainers = with maintainers; [ disserman ];
     platforms = platforms.unix;
diff --git a/pkgs/development/libraries/libpinyin/default.nix b/pkgs/development/libraries/libpinyin/default.nix
index 26694eb3777..bf516b33d02 100644
--- a/pkgs/development/libraries/libpinyin/default.nix
+++ b/pkgs/development/libraries/libpinyin/default.nix
@@ -1,31 +1,36 @@
-{ stdenv, fetchurl, fetchFromGitHub, autoreconfHook, glib, db, pkgconfig }:
+{ stdenv, fetchurl, fetchFromGitHub
+, autoreconfHook
+, glib
+, db
+, pkgconfig
+}:
 
 let
   modelData = fetchurl {
-    url    = "mirror://sourceforge/libpinyin/models/model14.text.tar.gz";
-    sha256 = "0qqk30nflj07zjhs231c95ln4yj4ipzwxxiwrxazrg4hb8bhypqq";
+    url    = "mirror://sourceforge/libpinyin/models/model17.text.tar.gz";
+    sha256 = "1kb2nswpsqlk2qm5jr7vqcp97f2dx7nvpk24lxjs1g12n252f5z0";
   };
 in
 stdenv.mkDerivation rec {
   name = "libpinyin-${version}";
-  version = "2.1.91";
-
-  nativeBuildInputs = [ autoreconfHook glib db pkgconfig ];
-
-  postUnpack = ''
-    tar -xzf ${modelData} -C $sourceRoot/data
-  '';
+  version = "2.3.0";
 
   src = fetchFromGitHub {
     owner  = "libpinyin";
     repo   = "libpinyin";
     rev    = version;
-    sha256 = "0jbvn65p3zh0573hh27aasd3qly5anyfi8jnps2dxi0my09wbrq3";
+    sha256 = "14fkpp16s5k0pbw5wwd24pqr0qbdjgbl90n9aqwx72m03n7an40l";
   };
 
+  postUnpack = ''
+    tar -xzf ${modelData} -C $sourceRoot/data
+  '';
+
+  nativeBuildInputs = [ autoreconfHook glib db pkgconfig ];
+
   meta = with stdenv.lib; {
     description = "Library for intelligent sentence-based Chinese pinyin input method";
-    homepage    = https://sourceforge.net/projects/libpinyin;
+    homepage    = "https://sourceforge.net/projects/libpinyin";
     license     = licenses.gpl2;
     maintainers = with maintainers; [ ericsagnes ];
     platforms   = platforms.linux;
diff --git a/pkgs/development/libraries/libpqxx/default.nix b/pkgs/development/libraries/libpqxx/default.nix
index 737c0dc4a0a..f6f2412c818 100644
--- a/pkgs/development/libraries/libpqxx/default.nix
+++ b/pkgs/development/libraries/libpqxx/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   pname = "libpqxx";
-  version = "6.4.4";
+  version = "6.4.5";
 
   src = fetchFromGitHub {
     owner = "jtv";
     repo = pname;
     rev = version;
-    sha256 = "0l62qlln5q1qhapbnm8n1k0hbzf3287gld1jpcbwr0yj79l9j579";
+    sha256 = "0djmjr2b5x5nd2a4idv5j8s6w0kdmvil910iv1kyc7x94dirbrni";
   };
 
   nativeBuildInputs = [ gnused python2 ];
diff --git a/pkgs/development/libraries/libqalculate/default.nix b/pkgs/development/libraries/libqalculate/default.nix
index 49490e1f785..1b73af7037b 100644
--- a/pkgs/development/libraries/libqalculate/default.nix
+++ b/pkgs/development/libraries/libqalculate/default.nix
@@ -3,13 +3,13 @@
 
 stdenv.mkDerivation rec {
   pname = "libqalculate";
-  version = "3.2.0";
+  version = "3.3.0";
 
   src = fetchFromGitHub {
     owner = "qalculate";
     repo = "libqalculate";
     rev = "v${version}";
-    sha256 = "0f82jss3kjxsk8znvrg1vfh756nnc15sbzr34ww1dvvrxipi7sns";
+    sha256 = "1qgsngi9z1sr6pzgcq6kgng62arpc5xn2ai1ks69myzzmgwk8adp";
   };
 
   outputs = [ "out" "dev" "doc" ];
diff --git a/pkgs/development/libraries/libqglviewer/default.nix b/pkgs/development/libraries/libqglviewer/default.nix
index e68c5052beb..34b396a7102 100644
--- a/pkgs/development/libraries/libqglviewer/default.nix
+++ b/pkgs/development/libraries/libqglviewer/default.nix
@@ -1,25 +1,25 @@
-{ stdenv, fetchurl, qt4, qmake4Hook, AGL }:
+{ stdenv, fetchurl, qmake, qtbase, libGLU, AGL }:
 
 stdenv.mkDerivation rec {
-  name = "libqglviewer-2.6.3";
-  version = "2.6.3";
+  pname = "libqglviewer";
+  version = "2.7.1";
 
   src = fetchurl {
     url = "http://www.libqglviewer.com/src/libQGLViewer-${version}.tar.gz";
-    sha256 = "00jdkyk4wg1356c3ar6nk3hyp494ya3yvshq9m57kfmqpn3inqdy";
+    sha256 = "08f10yk22kjdsvrqhd063gqa8nxnl749c20mwhaxij4f7rzdkixz";
   };
 
-  buildInputs = [ qt4 qmake4Hook ]
+  nativeBuildInputs = [ qmake ];
+  buildInputs = [ qtbase libGLU ]
     ++ stdenv.lib.optional stdenv.isDarwin AGL;
 
-  postPatch =
-    ''
-      cd QGLViewer
-    '';
+  postPatch = ''
+    cd QGLViewer
+  '';
 
   meta = with stdenv.lib; {
     description = "C++ library based on Qt that eases the creation of OpenGL 3D viewers";
-    homepage = http://libqglviewer.com/;
+    homepage = "http://libqglviewer.com";
     license = licenses.gpl2;
     platforms = platforms.all;
   };
diff --git a/pkgs/development/libraries/libraw/default.nix b/pkgs/development/libraries/libraw/default.nix
index 1a998c04435..5eb8049437c 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.19.2";
+  version = "0.19.3";
 
   src = fetchurl {
     url = "https://www.libraw.org/data/LibRaw-${version}.tar.gz";
-    sha256 = "0i4nhjm5556xgn966x0i503ygk2wafq6z83kg0lisacjjab4f3a0";
+    sha256 = "0xs1qb6pcvc4c43fy5xi3nkqxcif77gakkw99irf0fc5iccdd5px";
   };
 
   outputs = [ "out" "lib" "dev" "doc" ];
diff --git a/pkgs/development/libraries/librealsense/default.nix b/pkgs/development/libraries/librealsense/default.nix
index db8dfcf2eec..3805965d11c 100644
--- a/pkgs/development/libraries/librealsense/default.nix
+++ b/pkgs/development/libraries/librealsense/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "librealsense-${version}";
-  version = "2.21.0";
+  version = "2.25.0";
 
   src = fetchFromGitHub {
     owner = "IntelRealSense";
     repo = "librealsense";
     rev = "v${version}";
-    sha256 = "0fg4js390gj9lhyh9hmr7k3lhg5q1r47skyvziv9dmbj9dqm1ll7";
+    sha256 = "029qps0bbck0m2xj0mb5g3pgkk7a1zq8wcilfkvpx72sn7039xvw";
   };
 
   buildInputs = [
diff --git a/pkgs/development/libraries/librelp/default.nix b/pkgs/development/libraries/librelp/default.nix
index 82a71be5210..bcc3e16dae8 100644
--- a/pkgs/development/libraries/librelp/default.nix
+++ b/pkgs/development/libraries/librelp/default.nix
@@ -1,19 +1,28 @@
-{ stdenv, fetchurl, pkgconfig, gnutls, zlib }:
+{ stdenv, fetchFromGitHub
+, autoreconfHook
+, gnutls
+, openssl
+, pkgconfig
+, zlib
+}:
 
 stdenv.mkDerivation rec {
-  name = "librelp-1.3.0";
+  pname = "librelp";
+  version = "1.4.0";
 
-  src = fetchurl {
-    url = "http://download.rsyslog.com/librelp/${name}.tar.gz";
-    sha256 = "1xg99ndn65984mrh30qvys5npc73ag4348whshghrcj9azya494z";
+  src = fetchFromGitHub {
+    owner = "rsyslog";
+    repo = "librelp";
+    rev = "v${version}";
+    sha256 = "1q0k8zm7p6wpkri419kkpz734lp1hnxfqx1aa3xys4pj7zgx9jck";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ gnutls zlib ];
+  nativeBuildInputs = [ pkgconfig autoreconfHook ];
+  buildInputs = [ gnutls zlib openssl ];
 
   meta = with stdenv.lib; {
-    homepage = https://www.librelp.com/;
     description = "A reliable logging library";
+    homepage = "https://www.librelp.com/";
     license = licenses.gpl2;
     platforms = platforms.linux;
   };
diff --git a/pkgs/development/libraries/libressl/default.nix b/pkgs/development/libraries/libressl/default.nix
index fb4b1ac54a9..7fbe25addc0 100644
--- a/pkgs/development/libraries/libressl/default.nix
+++ b/pkgs/development/libraries/libressl/default.nix
@@ -13,7 +13,15 @@ let
 
     nativeBuildInputs = [ cmake ];
 
-    cmakeFlags = [ "-DENABLE_NC=ON" "-DBUILD_SHARED_LIBS=ON" ];
+    cmakeFlags = [
+      "-DENABLE_NC=ON"
+      "-DBUILD_SHARED_LIBS=ON"
+      # Ensure that the output libraries do not require an executable stack.
+      # Without this define, assembly files in libcrypto do not include a
+      # .note.GNU-stack section, and if that section is missing from any object,
+      # the linker will make the stack executable.
+      "-DCMAKE_C_FLAGS=-DHAVE_GNU_STACK"
+    ];
 
     # The autoconf build is broken as of 2.9.1, resulting in the following error:
     # libressl-2.9.1/tls/.libs/libtls.a', needed by 'handshake_table'.
@@ -39,9 +47,9 @@ let
     meta = with lib; {
       description = "Free TLS/SSL implementation";
       homepage    = "https://www.libressl.org";
-      license = with licenses; [ publicDomain bsdOriginal bsd0 bsd3 gpl3 isc ];
+      license = with licenses; [ publicDomain bsdOriginal bsd0 bsd3 gpl3 isc openssl ];
       platforms   = platforms.all;
-      maintainers = with maintainers; [ thoughtpolice fpletz globin ];
+      maintainers = with maintainers; [ thoughtpolice fpletz ];
     };
   };
 
@@ -56,4 +64,9 @@ in {
     version = "2.9.2";
     sha256 = "1m6mz515dcbrbnyz8hrpdfjzdmj1c15vbgnqxdxb89g3z9kq3iy4";
   };
+
+  libressl_3_0 = generic {
+    version = "3.0.0";
+    sha256 = "0xiwri6xcnl3wb5nbc4aw8pv32s3hp13r9v465yr8wykaw211n81";
+  };
 }
diff --git a/pkgs/development/libraries/librime/default.nix b/pkgs/development/libraries/librime/default.nix
index 71362fd7ef7..e1d0a51a668 100644
--- a/pkgs/development/libraries/librime/default.nix
+++ b/pkgs/development/libraries/librime/default.nix
@@ -3,13 +3,13 @@
 
 stdenv.mkDerivation rec {
   pname = "librime";
-  version = "1.5.0";
+  version = "1.5.3";
 
   src = fetchFromGitHub {
     owner = "rime";
     repo = "librime";
     rev = "${version}";
-    sha256 = "10wvh1l4317yzcys4rzlkw42i6cj5p8g62r1xzyjw32ky2d0ndxl";
+    sha256 = "0xskhdhk7dgpc71r39pfzxi5vrlzy90aqj1gzv8nnapq91p2awhv";
   };
 
   nativeBuildInputs = [ cmake ];
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
   enableParallelBuilding = true;
 
   meta = with stdenv.lib; {
-    homepage    = https://rime.im/;
+    homepage    = "https://rime.im/";
     description = "Rime Input Method Engine, the core library";
     license     = licenses.bsd3;
     maintainers = with maintainers; [ sifmelcara ];
diff --git a/pkgs/development/libraries/librsvg/default.nix b/pkgs/development/libraries/librsvg/default.nix
index 0cbd60409b4..a911524a9ac 100644
--- a/pkgs/development/libraries/librsvg/default.nix
+++ b/pkgs/development/libraries/librsvg/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchurl, pkgconfig, glib, gdk_pixbuf, pango, cairo, libxml2, libgsf
+{ lib, stdenv, fetchurl, pkgconfig, glib, gdk-pixbuf, pango, cairo, libxml2, libgsf
 , bzip2, libcroco, libintl, darwin, rustc, cargo, gnome3
 , withGTK ? false, gtk3 ? null
 , vala, gobject-introspection }:
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ libxml2 libgsf bzip2 libcroco pango libintl ];
 
-  propagatedBuildInputs = [ glib gdk_pixbuf cairo ] ++ lib.optional withGTK gtk3;
+  propagatedBuildInputs = [ glib gdk-pixbuf cairo ] ++ lib.optional withGTK gtk3;
 
   nativeBuildInputs = [ pkgconfig rustc cargo vala gobject-introspection ]
     ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
@@ -57,7 +57,7 @@ stdenv.mkDerivation rec {
          -i gdk-pixbuf-loader/Makefile
 
     # Fix thumbnailer path
-    sed -e "s#@bindir@\(/gdk-pixbuf-thumbnailer\)#${gdk_pixbuf}/bin\1#g" \
+    sed -e "s#@bindir@\(/gdk-pixbuf-thumbnailer\)#${gdk-pixbuf}/bin\1#g" \
         -i gdk-pixbuf-loader/librsvg.thumbnailer.in
   '';
 
@@ -66,7 +66,7 @@ stdenv.mkDerivation rec {
   # Merge gdkpixbuf and librsvg loaders
   postInstall = ''
     mv $GDK_PIXBUF/loaders.cache $GDK_PIXBUF/loaders.cache.tmp
-    cat ${gdk_pixbuf.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache $GDK_PIXBUF/loaders.cache.tmp > $GDK_PIXBUF/loaders.cache
+    cat ${gdk-pixbuf.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache $GDK_PIXBUF/loaders.cache.tmp > $GDK_PIXBUF/loaders.cache
     rm $GDK_PIXBUF/loaders.cache.tmp
   '';
 
diff --git a/pkgs/development/libraries/libsass/default.nix b/pkgs/development/libraries/libsass/default.nix
index 957201b83ab..2092d72c9f8 100644
--- a/pkgs/development/libraries/libsass/default.nix
+++ b/pkgs/development/libraries/libsass/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   pname = "libsass";
-  version = "3.6.0";
+  version = "3.6.1";
 
   src = fetchFromGitHub {
     owner = "sass";
     repo = pname;
     rev = version;
-    sha256 = "0c2cfmxv1h4f258l9ph6jrnk1ip5bngapzbw1x3vsqxw7hy20n4a";
+    sha256 = "1599j2lbsygy3883x9si7rbad1pkjhl6y72aimaapcv90ga5kxkm";
     # Remove unicode file names which leads to different checksums on HFS+
     # vs. other filesystems because of unicode normalisation.
     extraPostFetch = ''
diff --git a/pkgs/development/libraries/libshout/default.nix b/pkgs/development/libraries/libshout/default.nix
index 3753a070c63..849c93962f8 100644
--- a/pkgs/development/libraries/libshout/default.nix
+++ b/pkgs/development/libraries/libshout/default.nix
@@ -4,11 +4,11 @@
 # need pkgconfig so that libshout installs ${out}/lib/pkgconfig/shout.pc
 
 stdenv.mkDerivation rec {
-  name = "libshout-2.4.2";
+  name = "libshout-2.4.3";
 
   src = fetchurl {
     url = "http://downloads.xiph.org/releases/libshout/${name}.tar.gz";
-    sha256 = "0qgwarqp2p6jy3zadds6dzj8z1jfb2mbwc3lsdlidf527h0a86ym";
+    sha256 = "1zhdshas539cs8fsz8022ljxnnncr5lafhfd1dqr1gs125fzb2hd";
   };
 
   outputs = [ "out" "dev" "doc" ];
diff --git a/pkgs/development/libraries/libsolv/default.nix b/pkgs/development/libraries/libsolv/default.nix
index 4c1e0d830d1..8ffae53be19 100644
--- a/pkgs/development/libraries/libsolv/default.nix
+++ b/pkgs/development/libraries/libsolv/default.nix
@@ -1,14 +1,14 @@
 { stdenv, fetchFromGitHub, cmake, ninja, zlib, expat, rpm, db }:
 
 stdenv.mkDerivation rec {
-  version  = "0.7.4";
+  version  = "0.7.5";
   name = "libsolv-${version}";
 
   src = fetchFromGitHub {
     owner  = "openSUSE";
     repo   = "libsolv";
     rev    = version;
-    sha256 = "0d7xwykb3mxg8bhmlswnj5f0iyl1qsjyidxswzhcbk21fcgm5d4y";
+    sha256 = "0khks19i01s9h297c7af4bpq448abs2pqw55scf56xfdvxpv23aw";
   };
 
   cmakeFlags = [
diff --git a/pkgs/development/libraries/libspatialite/default.nix b/pkgs/development/libraries/libspatialite/default.nix
index 8e7b539527e..7bd22248d87 100644
--- a/pkgs/development/libraries/libspatialite/default.nix
+++ b/pkgs/development/libraries/libspatialite/default.nix
@@ -11,12 +11,15 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ pkgconfig ];
+
   buildInputs = [ libxml2 sqlite zlib proj geos libiconv ];
 
   configureFlags = [ "--disable-freexl" ];
 
   enableParallelBuilding = true;
 
+  CFLAGS = "-DACCEPT_USE_OF_DEPRECATED_PROJ_API_H=1";
+
   postInstall = "" + optionalString stdenv.isDarwin ''
     ln -s $out/lib/mod_spatialite.{so,dylib}
   '';
diff --git a/pkgs/development/libraries/libspf2/default.nix b/pkgs/development/libraries/libspf2/default.nix
new file mode 100644
index 00000000000..d4b11270428
--- /dev/null
+++ b/pkgs/development/libraries/libspf2/default.nix
@@ -0,0 +1,43 @@
+{ stdenv, fetchurl, autoreconfHook }:
+
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+  pname = "libspf2";
+  version = "1.2.10";
+
+  src = fetchurl {
+    url = "https://www.libspf2.org/spf/libspf2-${version}.tar.gz";
+    sha256 = "1j91p0qiipzf89qxq4m1wqhdf01hpn1h5xj4djbs51z23bl3s7nr";
+  };
+
+  patches = [
+    (fetchurl {
+      name = "0001-gcc-variadic-macros.patch";
+      url = "https://github.com/shevek/libspf2/commit/5852828582f556e73751076ad092f72acf7fc8b6.patch";
+      sha256 = "1v6ashqzpr0xidxq0vpkjd8wd66cj8df01kyzj678ljzcrax35hk";
+    })
+  ];
+
+  postPatch = ''
+    # disable static bins compilation
+    sed -i \
+      -e '/bin_PROGRAMS/s/spfquery_static//' src/spfquery/Makefile.am \
+      -e '/bin_PROGRAMS/s/spftest_static//' src/spftest/Makefile.am \
+      -e '/bin_PROGRAMS/s/spfd_static//' src/spfd/Makefile.am \
+      -e '/bin_PROGRAMS/s/spf_example_static//' src/spf_example/Makefile.am
+  '';
+
+  # autoreconf necessary because we modified automake files
+  nativeBuildInputs = [ autoreconfHook ];
+
+  doCheck = true;
+
+  meta = {
+    description = "Implementation of the Sender Policy Framework for SMTP authorization";
+    homepage = https://www.libspf2.org;
+    license = with licenses; [ lgpl21Plus bsd2 ];
+    maintainers = with maintainers; [ pacien ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/libssh/default.nix b/pkgs/development/libraries/libssh/default.nix
index fe7bc094fdc..65de6db3b47 100644
--- a/pkgs/development/libraries/libssh/default.nix
+++ b/pkgs/development/libraries/libssh/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, pkgconfig, cmake, zlib, openssl, libsodium }:
+{ stdenv, fetchurl, pkgconfig, cmake, zlib, openssl, libsodium }:
 
 stdenv.mkDerivation rec {
   name = "libssh-0.8.7";
diff --git a/pkgs/development/libraries/libssh2/default.nix b/pkgs/development/libraries/libssh2/default.nix
index 483a56dcdce..d4205981499 100644
--- a/pkgs/development/libraries/libssh2/default.nix
+++ b/pkgs/development/libraries/libssh2/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   pname = "libssh2";
-  version = "1.8.2";
+  version = "1.9.0";
 
   src = fetchurl {
     url = "${meta.homepage}/download/${pname}-${version}.tar.gz";
-    sha256 = "0rqd37pc80nm2pz4sa2m9pfc48axys7jwq1l7z0vii5nyvchg0q8";
+    sha256 = "1zfsz9nldakfz61d2j70pk29zlmj7w2vv46s9l3x2prhcgaqpyym";
   };
 
   outputs = [ "out" "dev" "devdoc" ];
diff --git a/pkgs/development/libraries/libstatgrab/default.nix b/pkgs/development/libraries/libstatgrab/default.nix
index 8896447590b..e10dffa96c1 100644
--- a/pkgs/development/libraries/libstatgrab/default.nix
+++ b/pkgs/development/libraries/libstatgrab/default.nix
@@ -2,11 +2,11 @@
 , IOKit ? null }:
 
 stdenv.mkDerivation rec {
-  name = "libstatgrab-0.91";
+  name = "libstatgrab-0.92";
 
   src = fetchurl {
     url = "https://ftp.i-scream.org/pub/i-scream/libstatgrab/${name}.tar.gz";
-    sha256 = "1azinx2yzs442ycwq6p15skl3mscmqj7fd5hq7fckhjp92735s83";
+    sha256 = "15m1sl990l85ijf8pnc6hdfha6fqyiq74mijrzm3xz4zzxm91wav";
   };
 
   buildInputs = [] ++ stdenv.lib.optional stdenv.isDarwin IOKit;
diff --git a/pkgs/development/libraries/libsystemtap/default.nix b/pkgs/development/libraries/libsystemtap/default.nix
new file mode 100644
index 00000000000..ecfa3377c99
--- /dev/null
+++ b/pkgs/development/libraries/libsystemtap/default.nix
@@ -0,0 +1,30 @@
+{stdenv, fetchgit, gettext, python, elfutils}:
+
+stdenv.mkDerivation {
+  pname = "libsystemtap";
+  version = "3.2";
+
+  src = fetchgit {
+    url = git://sourceware.org/git/systemtap.git;
+    rev = "4051c70c9318c837981384cbb23f3e9eb1bd0892";
+    sha256 = "0sd8n3j3rishks3gyqj2jyqhps7hmlfjyz8i0w8v98cczhhh04rq";
+    fetchSubmodules = false;
+  };
+
+  dontBuild = true;
+
+  nativeBuildInputs = [ gettext python elfutils ];
+
+  installPhase = ''
+    mkdir -p $out/include
+    cp -r includes/* $out/include/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Statically defined probes development files";
+    homepage = "https://sourceware.org/systemtap/";
+    license = licenses.bsd3;
+    platforms = platforms.unix;
+    maintainers = [ stdenv.lib.maintainers.farlion ];
+  };
+}
diff --git a/pkgs/development/libraries/libtensorflow/default.nix b/pkgs/development/libraries/libtensorflow/default.nix
deleted file mode 100644
index 98096371e40..00000000000
--- a/pkgs/development/libraries/libtensorflow/default.nix
+++ /dev/null
@@ -1,80 +0,0 @@
-{ config, stdenv
-, fetchurl
-, patchelf
-, cudaSupport ? config.cudaSupport or false, symlinkJoin, cudatoolkit, cudnn, nvidia_x11
-}:
-with stdenv.lib;
-let
-  tfType = if cudaSupport then "gpu" else "cpu";
-  system =
-    if stdenv.isx86_64
-    then if      stdenv.isLinux  then "linux-x86_64"
-         else if stdenv.isDarwin then "darwin-x86_64" else unavailable
-    else unavailable;
-  unavailable = throw "libtensorflow is not available for this platform!";
-  cudatoolkit_joined = symlinkJoin {
-    name = "unsplit_cudatoolkit";
-    paths = [ cudatoolkit.out
-              cudatoolkit.lib ];};
-  rpath = makeLibraryPath ([stdenv.cc.libc stdenv.cc.cc.lib] ++
-            optionals cudaSupport [ cudatoolkit_joined cudnn nvidia_x11 ]);
-  patchLibs =
-    if stdenv.isDarwin
-    then ''
-      install_name_tool -id $out/lib/libtensorflow.so $out/lib/libtensorflow.so
-      install_name_tool -id $out/lib/libtensorflow_framework.so $out/lib/libtensorflow_framework.so
-    ''
-    else ''
-      ${patchelf}/bin/patchelf --set-rpath "${rpath}:$out/lib" $out/lib/libtensorflow.so
-      ${patchelf}/bin/patchelf --set-rpath "${rpath}" $out/lib/libtensorflow_framework.so
-    '';
-
-in stdenv.mkDerivation rec {
-  pname = "libtensorflow";
-  version = "1.9.0";
-  name = "${pname}-${version}";
-  src = fetchurl {
-    url = "https://storage.googleapis.com/tensorflow/${pname}/${pname}-${tfType}-${system}-${version}.tar.gz";
-    sha256 =
-      if system == "linux-x86_64" then
-        if cudaSupport
-        then "1q3mh06x344im25z7r3vgrfksfdsi8fh8ldn6y2mf86h4d11yxc3"
-        else "0l9ps115ng5ffzdwphlqmj3jhidps2v5afppdzrbpzmy41xz0z21"
-      else if system == "darwin-x86_64" then
-        if cudaSupport
-        then unavailable
-        else "1qj0v1706w6mczycdsh38h2glyv5d25v62kdn98wxd5rw8f9v657"
-      else unavailable;
-  };
-
-  # Patch library to use our libc, libstdc++ and others
-  buildCommand = ''
-    . $stdenv/setup
-    mkdir -pv $out
-    tar -C $out -xzf $src
-    chmod +w $out/lib/libtensorflow.so
-    chmod +w $out/lib/libtensorflow_framework.so
-    ${patchLibs}
-    chmod -w $out/lib/libtensorflow.so
-    chmod -w $out/lib/libtensorflow_framework.so
-
-    # Write pkgconfig file.
-    mkdir $out/lib/pkgconfig
-    cat > $out/lib/pkgconfig/tensorflow.pc << EOF
-    Name: TensorFlow
-    Version: ${version}
-    Description: Library for computation using data flow graphs for scalable machine learning
-    Requires:
-    Libs: -L$out/lib -ltensorflow
-    Cflags: -I$out/include/tensorflow
-    EOF
-  '';
-
-  meta = {
-    description = "C API for TensorFlow";
-    homepage = https://www.tensorflow.org/versions/master/install/install_c;
-    license = licenses.asl20;
-    platforms = with platforms; linux ++ darwin;
-    maintainers = [maintainers.basvandijk];
-  };
-}
diff --git a/pkgs/development/libraries/libtorrent-rasterbar/default.nix b/pkgs/development/libraries/libtorrent-rasterbar/default.nix
index cd8192e34fb..046229e8f1d 100644
--- a/pkgs/development/libraries/libtorrent-rasterbar/default.nix
+++ b/pkgs/development/libraries/libtorrent-rasterbar/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchFromGitHub, fetchpatch, pkgconfig, automake, autoconf
+{ stdenv, lib, fetchFromGitHub, pkgconfig, automake, autoconf
 , zlib, boost, openssl, libtool, python, libiconv, geoip, ncurses
 }:
 
diff --git a/pkgs/development/libraries/libtoxcore/default.nix b/pkgs/development/libraries/libtoxcore/default.nix
index 1605abf6efa..50fdbf2a81f 100644
--- a/pkgs/development/libraries/libtoxcore/default.nix
+++ b/pkgs/development/libraries/libtoxcore/default.nix
@@ -48,7 +48,7 @@ in rec {
   };
 
   libtoxcore_0_2 = generic {
-    version = "0.2.9";
-    sha256 = "0aljr9hqybla6p61af6fdkv0x8gph7c2wacqqa9hq2z9w0p4fs5j";
+    version = "0.2.10";
+    sha256 = "0r5j2s5n8ikayvr1zylvv3ai3smbhm2m0yhpa9lfcsxhvyn9phcn";
   };
 }
diff --git a/pkgs/development/libraries/libuchardet/default.nix b/pkgs/development/libraries/libuchardet/default.nix
index 5aa26a749e4..6bfb694a41b 100644
--- a/pkgs/development/libraries/libuchardet/default.nix
+++ b/pkgs/development/libraries/libuchardet/default.nix
@@ -15,9 +15,6 @@ stdenv.mkDerivation rec {
 
   cmakeFlags = [
     "-DCMAKE_SKIP_BUILD_RPATH=OFF" # for tests
-    # TODO: move the following to CMake setup hook
-    "-DCMAKE_INSTALL_BINDIR=${placeholder "bin"}/bin"
-    "-DCMAKE_INSTALL_MANDIR=${placeholder "man"}/share/man"
   ];
 
   doCheck = true;
diff --git a/pkgs/development/libraries/libui/default.nix b/pkgs/development/libraries/libui/default.nix
index dcc406accbd..446d30c609e 100644
--- a/pkgs/development/libraries/libui/default.nix
+++ b/pkgs/development/libraries/libui/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchgit, cmake, pkgconfig, gtk3, cf-private, Cocoa }:
+{ stdenv, fetchgit, cmake, pkgconfig, gtk3, Cocoa }:
 
 let
   shortName = "libui";
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake pkgconfig ];
   buildInputs = stdenv.lib.optional stdenv.isLinux gtk3
-    ++ stdenv.lib.optionals stdenv.isDarwin [ Cocoa cf-private /* For NSDefaultRunLoopMode */ ];
+    ++ stdenv.lib.optionals stdenv.isDarwin [ Cocoa ];
 
   preConfigure = stdenv.lib.optionalString stdenv.isDarwin ''
     sed -i 's/set(CMAKE_OSX_DEPLOYMENT_TARGET "10.8")//' ./CMakeLists.txt
diff --git a/pkgs/development/libraries/liburcu/default.nix b/pkgs/development/libraries/liburcu/default.nix
index 0cc1b0d08f9..90be7740114 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.11.0";
+  version = "0.11.1";
   name = "liburcu-${version}";
 
   src = fetchurl {
     url = "https://lttng.org/files/urcu/userspace-rcu-${version}.tar.bz2";
-    sha256 = "1rxk5vbkbmqlsnjnvkjz0pkx2076mqnq6jzblpmz8rk29x66kx8s";
+    sha256 = "0l1kxgzch4m8fxiz2hc8fwg56hrvzzspp7n0svnl7i7iycdrgfcj";
   };
 
   checkInputs = [ perl ];
diff --git a/pkgs/development/libraries/liburing/default.nix b/pkgs/development/libraries/liburing/default.nix
index cce10a761d3..7d595db85dd 100644
--- a/pkgs/development/libraries/liburing/default.nix
+++ b/pkgs/development/libraries/liburing/default.nix
@@ -1,16 +1,57 @@
 { stdenv, fetchgit
+, fetchpatch
 }:
 
 stdenv.mkDerivation rec {
   name = "liburing-${version}";
-  version = "1.0.0pre137_${builtins.substring 0 7 src.rev}";
+  version = "0.1";
 
   src = fetchgit {
     url    = "http://git.kernel.dk/liburing";
-    rev    = "91dde5c956b1af491bc6c16ee230daa4b4b66706";
-    sha256 = "0rk1ikrn3s6sp3gx7kc4y6msx7yncr3845m67vhk8lxvhd90sgza";
+    rev    = "refs/tags/liburing-${version}";
+    sha256 = "038iqsbm9bdmlwvmb899bc6g1rw5dalr990azynbvgn8qs5adysh";
   };
 
+  patches = [
+
+    # This patch re-introduces support for aarch64-linux, by adding the
+    # necessary memory barrier primitives for it to work.
+    #
+    # Already upstream: remove when moving to the next version
+    (fetchpatch {
+      url    = "http://git.kernel.dk/cgit/liburing/patch/?id=0520db454c29f1d96cda6cf6cedeb93df65301e8";
+      sha256 = "1i8133sb1imzxpplmhlhnaxkffgplhj40vanivc6clbibvhgwpq6";
+    })
+
+    # This patch shuffles the name of the io_uring memory barrier primitives.
+    # They were using extremely common names by accident, which caused
+    # namespace conflicts with many other projects using the same names. Note:
+    # this does not change the user-visible API of liburing (liburing is
+    # designed exactly to hide the necessary memory barriers when using the
+    # io_uring syscall directly). It only changes the names of some internals.
+    # The only reason this caused problems at all is because memory barrier
+    # primitives are written as preprocessor defines, in a common header file,
+    # which get included unilaterally.
+    #
+    # Already upstream: remove when moving to the next version
+    (fetchpatch {
+      url    = "http://git.kernel.dk/cgit/liburing/patch/?id=552c6a08d04c74d20eeaa86f535bfd553b352370";
+      sha256 = "123d6jdqfy7b8aq9f6ax767n48hhbx6pln3nlrp623595i8zz3wf";
+    })
+
+    # Finally, this patch fixes the aarch64-linux support introduced by the
+    # first patch, but which was _broken_ by the second patch, in a horrid
+    # twist of fate: it neglected to change the names of the aarch64 barriers
+    # appropriately.
+    #
+    # Already upstream: remove when moving to the next version
+    (fetchpatch {
+      url    = "http://git.kernel.dk/cgit/liburing/patch/?id=6e9dd0c8c50b5988a0c77532c9c2bd6afd4790d2";
+      sha256 = "11mqa1bp2pdfqh08gpcd98kg7lh3rrng41b4l1wvhxdbvg5rfw9c";
+    })
+
+  ];
+
   separateDebugInfo = true;
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/libuv/default.nix b/pkgs/development/libraries/libuv/default.nix
index e725439a3f1..07f99a058d8 100644
--- a/pkgs/development/libraries/libuv/default.nix
+++ b/pkgs/development/libraries/libuv/default.nix
@@ -1,14 +1,14 @@
-{ stdenv, lib, fetchpatch, fetchFromGitHub, autoconf, automake, libtool, pkgconfig, ApplicationServices, CoreServices }:
+{ stdenv, lib, fetchFromGitHub, autoconf, automake, libtool, pkgconfig, ApplicationServices, CoreServices }:
 
 stdenv.mkDerivation rec {
-  version = "1.29.1";
+  version = "1.30.1";
   pname = "libuv";
 
   src = fetchFromGitHub {
     owner = pname;
     repo = pname;
     rev = "v${version}";
-    sha256 = "0scnircr6khgh7l3bw9zyfzdgx2c11mpfhd9d8qlw47arrvqg7l8";
+    sha256 = "16l207g9qwckxn0vnbnwiybhw6083imdwyfd6ipfsl44b1m8jmf7";
   };
 
   postPatch = let
diff --git a/pkgs/development/libraries/libva-utils/default.nix b/pkgs/development/libraries/libva-utils/default.nix
index e41ca206c51..9883de59feb 100644
--- a/pkgs/development/libraries/libva-utils/default.nix
+++ b/pkgs/development/libraries/libva-utils/default.nix
@@ -29,7 +29,7 @@ stdenv.mkDerivation rec {
     description = "VAAPI tools: Video Acceleration API";
     homepage = http://www.freedesktop.org/wiki/Software/vaapi;
     license = licenses.mit;
-    maintainers = with maintainers; [ garbas ];
+    maintainers = with maintainers; [ ];
     platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/libva/1.0.0.nix b/pkgs/development/libraries/libva/1.0.0.nix
index 097ac0e3e98..6a067244543 100644
--- a/pkgs/development/libraries/libva/1.0.0.nix
+++ b/pkgs/development/libraries/libva/1.0.0.nix
@@ -1,5 +1,5 @@
 { stdenv, lib, fetchurl, libX11, pkgconfig, libXext, libdrm, libXfixes, wayland, libffi
-, libGL, libGL_driver
+, libGL, mesa
 , minimal ? false, libva1-minimal
 }:
 
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
 
   configureFlags =
     # Add FHS paths for non-NixOS applications.
-    [ "--with-drivers-path=${libGL_driver.driverLink}/lib/dri:/usr/lib/dri:/usr/lib32/dri" ] ++
+    [ "--with-drivers-path=${mesa.drivers.driverLink}/lib/dri:/usr/lib/dri:/usr/lib32/dri" ] ++
     lib.optionals (!minimal) [ "--enable-glx" ];
 
   installFlags = [ "dummy_drv_video_ladir=$(out)/lib/dri" ];
@@ -32,6 +32,6 @@ stdenv.mkDerivation rec {
     license = licenses.mit;
     description = "VAAPI library: Video Acceleration API";
     platforms = platforms.unix;
-    maintainers = with maintainers; [ garbas ];
+    maintainers = with maintainers; [ ];
   };
 }
diff --git a/pkgs/development/libraries/libva/default.nix b/pkgs/development/libraries/libva/default.nix
index 752d56a344e..7aba75a1d23 100644
--- a/pkgs/development/libraries/libva/default.nix
+++ b/pkgs/development/libraries/libva/default.nix
@@ -1,19 +1,19 @@
 { stdenv, lib, fetchFromGitHub, autoreconfHook, pkgconfig
 , libXext, libdrm, libXfixes, wayland, libffi, libX11
-, libGL, libGL_driver
+, libGL, mesa
 , minimal ? false, libva-minimal
 }:
 
 stdenv.mkDerivation rec {
   name = "libva-${lib.optionalString minimal "minimal-"}${version}";
-  version = "2.4.1";
+  version = "2.5.0";
 
   # update libva-utils and vaapiIntel as well
   src = fetchFromGitHub {
     owner  = "01org";
     repo   = "libva";
     rev    = version;
-    sha256 = "06kqff05jhd87yi53gyc2qivgg4sbf19qyznm9s4dyz92k04cl5c";
+    sha256 = "0pys6blkh8ayxmxgfh7qrjzzcrzzn14z5d8q4a34ffqk90b6r93z";
   };
 
   outputs = [ "dev" "out" ];
@@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
 
   configureFlags = [
     # Add FHS paths for non-NixOS applications.
-    "--with-drivers-path=${libGL_driver.driverLink}/lib/dri:/usr/lib/dri:/usr/lib32/dri"
+    "--with-drivers-path=${mesa.drivers.driverLink}/lib/dri:/usr/lib/dri:/usr/lib32/dri"
   ] ++ lib.optionals (!minimal) [ "--enable-glx" ];
 
   installFlags = [
@@ -39,7 +39,7 @@ stdenv.mkDerivation rec {
     description = "VAAPI library: Video Acceleration API";
     homepage = http://www.freedesktop.org/wiki/Software/vaapi;
     license = licenses.mit;
-    maintainers = with maintainers; [ garbas ];
+    maintainers = with maintainers; [ ];
     platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/libvdpau/default.nix b/pkgs/development/libraries/libvdpau/default.nix
index a61b3c3f2ac..d6842226014 100644
--- a/pkgs/development/libraries/libvdpau/default.nix
+++ b/pkgs/development/libraries/libvdpau/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, xorg, libGL_driver }:
+{ stdenv, fetchurl, pkgconfig, xorg, mesa }:
 
 stdenv.mkDerivation rec {
   name = "libvdpau-${version}";
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
   propagatedBuildInputs = [ xorg.libX11 ];
 
   configureFlags = stdenv.lib.optional stdenv.isLinux
-    "--with-module-dir=${libGL_driver.driverLink}/lib/vdpau";
+    "--with-module-dir=${mesa.drivers.driverLink}/lib/vdpau";
 
   NIX_LDFLAGS = if stdenv.isDarwin then "-lX11" else null;
 
diff --git a/pkgs/development/libraries/libversion/default.nix b/pkgs/development/libraries/libversion/default.nix
index 0ace54582eb..3c7ed207703 100644
--- a/pkgs/development/libraries/libversion/default.nix
+++ b/pkgs/development/libraries/libversion/default.nix
@@ -1,10 +1,8 @@
 { stdenv, fetchFromGitHub, cmake }:
 
-let
-  version = "2.8.1";
-in
-stdenv.mkDerivation {
-  name = "libversion-${version}";
+stdenv.mkDerivation rec {
+  pname = "libversion";
+  version = "2.9.0";
 
   src = fetchFromGitHub {
     owner = "repology";
diff --git a/pkgs/development/libraries/libvirt-glib/default.nix b/pkgs/development/libraries/libvirt-glib/default.nix
index 74c3d24560c..9dd89133f4b 100644
--- a/pkgs/development/libraries/libvirt-glib/default.nix
+++ b/pkgs/development/libraries/libvirt-glib/default.nix
@@ -1,6 +1,7 @@
 { stdenv, fetchurl, pkgconfig, libvirt, glib, libxml2, intltool, libtool, yajl
 , nettle, libgcrypt, pythonPackages, gobject-introspection, libcap_ng, numactl
-, xen, libapparmor, vala
+, libapparmor, vala
+, xenSupport ? false, xen ? null
 }:
 
 let
@@ -19,7 +20,7 @@ in stdenv.mkDerivation rec {
   buildInputs = [
     libvirt glib libxml2 intltool libtool yajl nettle libgcrypt
     python pygobject2 gobject-introspection libcap_ng numactl libapparmor
-  ] ++ stdenv.lib.optionals stdenv.isx86_64 [
+  ] ++ stdenv.lib.optionals xenSupport [
     xen
   ];
 
diff --git a/pkgs/development/libraries/libvirt/default.nix b/pkgs/development/libraries/libvirt/default.nix
index 85b8b128d20..125259a6bee 100644
--- a/pkgs/development/libraries/libvirt/default.nix
+++ b/pkgs/development/libraries/libvirt/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, fetchgit
-, pkgconfig, makeWrapper, libtool, autoconf, automake
+, pkgconfig, makeWrapper, libtool, autoconf, automake, fetchpatch
 , coreutils, libxml2, gnutls, perl, python2, attr
 , iproute, iptables, readline, lvm2, utillinux, systemd, libpciaccess, gettext
 , libtasn1, ebtables, libgcrypt, yajl, pmutils, libcap_ng, libapparmor
@@ -17,22 +17,46 @@ let
   buildFromTarball = stdenv.isDarwin;
 in stdenv.mkDerivation rec {
   name = "libvirt-${version}";
-  version = "4.10.0";
+  version = "5.4.0";
 
   src =
     if buildFromTarball then
       fetchurl {
         url = "http://libvirt.org/sources/${name}.tar.xz";
-        sha256 = "0v17zzyyb25nn9l18v5244myg7590dp6ppwgi8xysipifc0q77bz";
+        sha256 = "0ywf8m9yz2hxnic7fylzlmgy4m353r4vv5zsvp89zq5yh4h81yhw";
       }
     else
       fetchgit {
         url = git://libvirt.org/libvirt.git;
         rev = "v${version}";
-        sha256 = "0dlpv3v6jpbmgvhpn29ryp0w2a1xny8ciqid8hnlf3klahz9kwz9";
+        sha256 = "1dja1mf295w0sl83zag62c4j55cfbzzfbhdxpkyv2zm3zv0mwdyc";
         fetchSubmodules = true;
       };
 
+  patches = optionals (!stdenv.isDarwin) [
+    (fetchpatch {
+      name = "5.4.0-CVE-2019-10161.patch";
+      url = "https://libvirt.org/git/?p=libvirt.git;a=patch;h=aed6a032cead4386472afb24b16196579e239580";
+      sha256 = "19k9z9xx68nf03igbgy1imxnlp5ppj7cgdbq9kri3s834hkjcygs";
+    })
+  ] ++ [
+    (fetchpatch {
+      name = "5.4.0-CVE-2019-10166.patch";
+      url = "https://libvirt.org/git/?p=libvirt.git;a=patch;h=db0b78457f183e4c7ac45bc94de86044a1e2056a";
+      sha256 = "17pd1rab2mxj4q0vg30vi2gh78mf52ik1p5l12wrghb0wjf7swml";
+    })
+    (fetchpatch {
+      name = "5.4.0-CVE-2019-10167.patch";
+      url = "https://libvirt.org/git/?p=libvirt.git;a=patch;h=8afa68bac0cf99d1f8aaa6566685c43c22622f26";
+      sha256 = "0hgbwk0y2n6ihzjk8vqabhw914axjqgzcb7c5xx893r86c54c0ml";
+    })
+    (fetchpatch {
+      name = "5.4.0-CVE-2019-10168.patch";
+      url = "https://libvirt.org/git/?p=libvirt.git;a=patch;h=bf6c2830b6c338b1f5699b095df36f374777b291";
+      sha256 = "0s4hc3hsjncx1852ndjas1nng9v23pxf4mi1jxcajsqvhw89la0g";
+    })
+  ];
+
   nativeBuildInputs = [ makeWrapper pkgconfig ];
   buildInputs = [
     libxml2 gnutls perl python2 readline gettext libtasn1 libgcrypt yajl
@@ -76,13 +100,14 @@ in stdenv.mkDerivation rec {
     "--with-esx"
     "--with-remote"
   ] ++ optionals stdenv.isLinux [
+    "QEMU_BRIDGE_HELPER=/run/wrappers/bin/qemu-bridge-helper"
+    "QEMU_PR_HELPER=/run/libvirt/nix-helpers/qemu-pr-helper"
     "--with-attr"
     "--with-apparmor"
     "--with-secdriver-apparmor"
     "--with-numad"
     "--with-macvtap"
     "--with-virtualport"
-    "--with-init-script=systemd+redhat"
     "--with-storage-disk"
   ] ++ optionals (stdenv.isLinux && zfs != null) [
     "--with-storage-zfs"
@@ -104,6 +129,7 @@ in stdenv.mkDerivation rec {
     binPath = [ iptables iproute pmutils numad numactl bridge-utils dmidecode dnsmasq ebtables ] ++ optionals enableIscsi [ openiscsi ];
   in ''
     substituteInPlace $out/libexec/libvirt-guests.sh \
+      --replace 'ON_BOOT=start'       'ON_BOOT=''${ON_BOOT:-start}' \
       --replace 'ON_SHUTDOWN=suspend' 'ON_SHUTDOWN=''${ON_SHUTDOWN:-suspend}' \
       --replace "$out/bin"            '${gettext}/bin' \
       --replace 'lock/subsys'         'lock' \
@@ -131,6 +157,6 @@ in stdenv.mkDerivation rec {
     '';
     license = licenses.lgpl2Plus;
     platforms = platforms.unix;
-    maintainers = with maintainers; [ fpletz ];
+    maintainers = with maintainers; [ fpletz globin ];
   };
 }
diff --git a/pkgs/development/libraries/libvisio/default.nix b/pkgs/development/libraries/libvisio/default.nix
index a09e2cf2f72..5cb1c673be5 100644
--- a/pkgs/development/libraries/libvisio/default.nix
+++ b/pkgs/development/libraries/libvisio/default.nix
@@ -4,13 +4,13 @@
 
 stdenv.mkDerivation rec {
   name = "libvisio-${version}";
-  version = "0.1.6";
+  version = "0.1.7";
 
   outputs = [ "out" "bin" "dev" "doc" ];
 
   src = fetchurl {
     url = "https://dev-www.libreoffice.org/src/libvisio/${name}.tar.xz";
-    sha256 = "1yahpfl13qk6178irv8jn5ppxdn7isafqisyqsdw0lqxcz9h447y";
+    sha256 = "0k7adcbbf27l7n453cca1m6s9yj6qvb5j6bsg2db09ybf3w8vbwg";
   };
 
   nativeBuildInputs = [ pkgconfig cppunit doxygen ];
diff --git a/pkgs/development/libraries/libvisual/default.nix b/pkgs/development/libraries/libvisual/default.nix
index 2a53a1d0e7c..6e8e2d95b6b 100644
--- a/pkgs/development/libraries/libvisual/default.nix
+++ b/pkgs/development/libraries/libvisual/default.nix
@@ -17,6 +17,6 @@ stdenv.mkDerivation rec {
     description = "An abstraction library for audio visualisations";
     homepage = https://sourceforge.net/projects/libvisual/;
     license = stdenv.lib.licenses.lgpl21Plus;
-    platforms = stdenv.lib.platforms.unix;
+    platforms = stdenv.lib.platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/libvterm-neovim/default.nix b/pkgs/development/libraries/libvterm-neovim/default.nix
index e00b3e1c7b3..75e935d18d9 100644
--- a/pkgs/development/libraries/libvterm-neovim/default.nix
+++ b/pkgs/development/libraries/libvterm-neovim/default.nix
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
     description = "VT220/xterm/ECMA-48 terminal emulator library";
     homepage = http://www.leonerd.org.uk/code/libvterm/;
     license = licenses.mit;
-    maintainers = with maintainers; [ garbas ];
+    maintainers = with maintainers; [ ];
     platforms = platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/libwebp/default.nix b/pkgs/development/libraries/libwebp/default.nix
index b0457e76f2f..c11f70290a4 100644
--- a/pkgs/development/libraries/libwebp/default.nix
+++ b/pkgs/development/libraries/libwebp/default.nix
@@ -27,11 +27,11 @@ in
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "libwebp-${version}";
-  version = "1.0.2";
+  version = "1.0.3";
 
   src = fetchurl {
     url = "http://downloads.webmproject.org/releases/webp/${name}.tar.gz";
-    sha256 = "1cb4sm6h1czvk9kqqgld3g5f0d9qv60xnbbv0kl7cr7d826b8irx";
+    sha256 = "0kxk4sic34bln3k09mml7crvrmhj97swdk7b1ahbp5w6bj30f2p2";
   };
 
   configureFlags = [
diff --git a/pkgs/development/libraries/libwebsockets/default.nix b/pkgs/development/libraries/libwebsockets/default.nix
index 7c1d58d2980..144bde9a23a 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 = "3.1.0";
+  version = "3.2.0";
 
   src = fetchFromGitHub {
     owner = "warmcat";
     repo = "libwebsockets";
     rev = "v${version}";
-    sha256 = "1w1wz6snf3cmcpa3f4dci2nz9za2f5rrylxl109id7bcb36xhbdl";
+    sha256 = "0ac5755h3w1pl6cznqbvg63dwkqy544fqlhvqyp7s11hgs7jx6l8";
   };
 
   buildInputs = [ cmake openssl zlib libuv ];
diff --git a/pkgs/development/libraries/libwnck/3.x.nix b/pkgs/development/libraries/libwnck/3.x.nix
index 9c35d337350..29692c41c93 100644
--- a/pkgs/development/libraries/libwnck/3.x.nix
+++ b/pkgs/development/libraries/libwnck/3.x.nix
@@ -1,31 +1,78 @@
-{ stdenv, fetchurl, pkgconfig, libX11, gtk3, intltool, gobject-introspection, gnome3 }:
+{ stdenv
+, fetchurl
+, fetchpatch
+, meson
+, ninja
+, pkgconfig
+, gtk-doc
+, docbook_xsl
+, docbook_xml_dtd_412
+, libX11
+, glib
+, gtk3
+, pango
+, cairo
+, libXres
+, libstartup_notification
+, gettext
+, gobject-introspection
+, gnome3
+}:
 
-let
+stdenv.mkDerivation rec{
   pname = "libwnck";
-  version = "3.30.0";
-in stdenv.mkDerivation rec{
-  name = "${pname}-${version}";
+  version = "3.32.0";
+
+  outputs = [ "out" "dev" "devdoc" ];
+  outputBin = "dev";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${name}.tar.xz";
-    sha256 = "0f9lvhm3w25046dqq8xyg7nzggxpmdriwrb661nng05a8qk0svdc";
+    url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
+    sha256 = "1jp3p1lnwnwi6fxl2rz3166cmwzwy9vqz896anpwc3wdy9f875cm";
   };
 
-  outputs = [ "out" "dev" "devdoc" ];
-  outputBin = "dev";
+  patches = [
+    # https://gitlab.gnome.org/GNOME/libwnck/issues/139
+    (fetchpatch {
+      url = https://gitlab.gnome.org/GNOME/libwnck/commit/0d9ff7db63af568feef8e8c566e249058ccfcb4e.patch;
+      sha256 = "18f78aayq9jma54v2qz3rm2clmz1cfq5bngxw8p4zba7hplyqsl9";
+    })
+    # https://gitlab.gnome.org/GNOME/libwnck/merge_requests/12
+    ./fix-pc-file.patch
+  ];
+
+  nativeBuildInputs = [
+    meson
+    ninja
+    pkgconfig
+    gettext
+    gobject-introspection
+    gtk-doc
+    docbook_xsl
+    docbook_xml_dtd_412
+  ];
 
-  configureFlags = [ "--enable-introspection" ];
+  buildInputs = [
+    libX11
+    libstartup_notification
+    pango
+    cairo
+    libXres
+  ];
 
-  nativeBuildInputs = [ pkgconfig intltool gobject-introspection ];
-  propagatedBuildInputs = [ libX11 gtk3 ];
+  propagatedBuildInputs = [
+    glib
+    gtk3
+  ];
 
-  PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_GIRDIR = "${placeholder "dev"}/share/gir-1.0";
-  PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_TYPELIBDIR = "${placeholder "out"}/lib/girepository-1.0";
+  mesonFlags = [
+    "-Dgtk_doc=true"
+  ];
 
   passthru = {
     updateScript = gnome3.updateScript {
       packageName = pname;
-      attrPath = "gnome3.${pname}";
+      attrPath = "${pname}${stdenv.lib.versions.major version}";
     };
   };
 
diff --git a/pkgs/development/libraries/libwnck/fix-pc-file.patch b/pkgs/development/libraries/libwnck/fix-pc-file.patch
new file mode 100644
index 00000000000..42017a993b5
--- /dev/null
+++ b/pkgs/development/libraries/libwnck/fix-pc-file.patch
@@ -0,0 +1,24 @@
+diff --git a/meson.build b/meson.build
+index 28799d8..047e523 100644
+--- a/meson.build
++++ b/meson.build
+@@ -72,11 +72,15 @@
+ pc_conf = configuration_data()
+ pc_conf.set('prefix', get_option('prefix'))
+ pc_conf.set('exec_prefix', '${prefix}')
+-pc_conf.set('libdir', '${exec_prefix}/' + get_option('libdir'))
+-pc_conf.set('includedir', '${prefix}/' + get_option('includedir'))
+-pc_conf.set('STARTUP_NOTIFICATION_PACKAGE', STARTUP_NOTIFICATION_PACKAGE)
++pc_conf.set('libdir', '${exec_prefix}' / get_option('libdir'))
++pc_conf.set('includedir', '${prefix}' / get_option('includedir'))
++if conf.has('HAVE_' + STARTUP_NOTIFICATION_PACKAGE.to_upper().underscorify())
++  pc_conf.set('STARTUP_NOTIFICATION_PACKAGE', STARTUP_NOTIFICATION_PACKAGE)
++endif
+ pc_conf.set('X11_PACKAGE', X11_PACKAGE)
+-pc_conf.set('XRES_PACKAGE', XRES_PACKAGE)
++if conf.has('HAVE_' + XRES_PACKAGE.to_upper().underscorify())
++  pc_conf.set('XRES_PACKAGE', XRES_PACKAGE)
++endif
+ pc_conf.set('VERSION', meson.project_version())
+ 
+ foreach pc: [PACKAGE_NAME, PACKAGE_NAME + '-uninstalled']
diff --git a/pkgs/development/libraries/libxkbcommon/default.nix b/pkgs/development/libraries/libxkbcommon/default.nix
index 3e0a2872c00..44530b38150 100644
--- a/pkgs/development/libraries/libxkbcommon/default.nix
+++ b/pkgs/development/libraries/libxkbcommon/default.nix
@@ -1,11 +1,12 @@
 { stdenv, fetchurl, fetchpatch, meson, ninja, pkgconfig, yacc, xkeyboard_config, libxcb, libX11, doxygen }:
 
 stdenv.mkDerivation rec {
-  name = "libxkbcommon-0.8.0";
+  pname = "libxkbcommon";
+  version = "0.8.4";
 
   src = fetchurl {
-    url = "https://xkbcommon.org/download/${name}.tar.xz";
-    sha256 = "0vgy84vfbig5bqznr137h5arjidnfwrxrdli0pxyn2jfn1fjcag8";
+    url = "https://xkbcommon.org/download/${pname}-${version}.tar.xz";
+    sha256 = "12vc91ydhphd5sddz15560r41l7k0i7mq6nma8kkbzdp6bwwzpb0";
   };
 
   outputs = [ "out" "dev" "doc" ];
@@ -13,27 +14,27 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ meson ninja pkgconfig yacc doxygen ];
   buildInputs = [ xkeyboard_config libxcb ];
 
-  patches = [
-    # darwin compatibility
-    (fetchpatch {
-      url = https://github.com/xkbcommon/libxkbcommon/commit/edb1c662394578a54b7bbed231d918925e5d8150.patch;
-      sha256 = "0ydjlir32r3xfsbqhnsx1bz6ags2m908yhf9i09i1s7sgcimbcx5";
-    })
-  ];
-
   mesonFlags = [
     "-Denable-wayland=false"
     "-Dxkb-config-root=${xkeyboard_config}/etc/X11/xkb"
     "-Dx-locale-root=${libX11.out}/share/X11/locale"
   ];
 
+  patches = stdenv.lib.optionals stdenv.isDarwin [
+    # Fix build on darwin
+    (fetchpatch {
+      url = "https://github.com/xkbcommon/libxkbcommon/commit/32d178b50fe0da05e51e4fe8903c84371d133331.patch";
+      sha256 = "1wqdjla8hmgdqr8xc2manw363sxrqqsn3s8bd397h3cd7fj3hh1v";
+    })
+  ];
+
   doCheck = false; # fails, needs unicode locale
 
   meta = with stdenv.lib; {
     description = "A library to handle keyboard descriptions";
     homepage = https://xkbcommon.org;
     license = licenses.mit;
-    maintainers = with maintainers; [ garbas ttuegel ];
+    maintainers = with maintainers; [ ttuegel ];
     platforms = with platforms; unix;
   };
 }
diff --git a/pkgs/development/libraries/libxkbcommon/libxkbcommon_7.nix b/pkgs/development/libraries/libxkbcommon/libxkbcommon_7.nix
index 0d034f5385f..510955d0af2 100644
--- a/pkgs/development/libraries/libxkbcommon/libxkbcommon_7.nix
+++ b/pkgs/development/libraries/libxkbcommon/libxkbcommon_7.nix
@@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
     description = "A library to handle keyboard descriptions";
     homepage = https://xkbcommon.org;
     license = licenses.mit;
-    maintainers = with maintainers; [ garbas ttuegel ];
+    maintainers = with maintainers; [ ttuegel ];
     platforms = with platforms; unix;
   };
 }
diff --git a/pkgs/development/libraries/libxml2/default.nix b/pkgs/development/libraries/libxml2/default.nix
index de131052314..33f818f7d62 100644
--- a/pkgs/development/libraries/libxml2/default.nix
+++ b/pkgs/development/libraries/libxml2/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchurl, fetchpatch
+{ stdenv, lib, fetchurl
 , zlib, xz, python2, ncurses, findXMLCatalogs
 , pythonSupport ? stdenv.buildPlatform == stdenv.hostPlatform
 , icuSupport ? false, icu ? null
diff --git a/pkgs/development/libraries/libxmlb/default.nix b/pkgs/development/libraries/libxmlb/default.nix
index 9edb9b475e8..4800a6c405c 100644
--- a/pkgs/development/libraries/libxmlb/default.nix
+++ b/pkgs/development/libraries/libxmlb/default.nix
@@ -1,25 +1,65 @@
-{ stdenv, fetchFromGitHub, meson, ninja, pkgconfig, glib, libuuid, gobject-introspection, gtk-doc, shared-mime-info, python3, docbook_xsl, docbook_xml_dtd_43 }:
+{ stdenv
+, fetchFromGitHub
+, fetchpatch
+, docbook_xml_dtd_43
+, docbook_xsl
+, glib
+, gobject-introspection
+, gtk-doc
+, libuuid
+, meson
+, ninja
+, pkgconfig
+, python3
+, shared-mime-info
+, nixosTests
+}:
 
 stdenv.mkDerivation rec {
-  name = "libxmlb-${version}";
-  version = "0.1.10";
+  pname = "libxmlb";
+  version = "0.1.11";
 
-  outputs = [ "out" "lib" "dev" "devdoc" ];
+  outputs = [ "out" "lib" "dev" "devdoc" "installedTests" ];
 
   src = fetchFromGitHub {
     owner = "hughsie";
     repo = "libxmlb";
     rev = version;
-    sha256 = "1ismh3bdwd0l1fjlhwycam89faxjmpb0wxqlbv58m0z6cxykp6rd";
+    sha256 = "1503v76w7543snqyjxykiqa5va62zb0ccn3jlw0gpdx8973v80mr";
   };
 
-  nativeBuildInputs = [ meson ninja python3 pkgconfig gobject-introspection gtk-doc shared-mime-info docbook_xsl docbook_xml_dtd_43 ];
+  patches = [
+    # Fix installed tests
+    # https://github.com/hughsie/libxmlb/pull/2
+    (fetchpatch {
+      url = "https://github.com/hughsie/libxmlb/commit/78850c8b0f644f729fa21e2bf9ebed0d9d6010f3.diff";
+      sha256 = "0zw7c6vy8hscln7za7ijqd9svirach3zdskvbzyxxcsm3xcwxpjm";
+    })
 
-  buildInputs = [ glib libuuid ];
+    ./installed-tests-path.patch
+  ];
+
+  nativeBuildInputs = [
+    docbook_xml_dtd_43
+    docbook_xsl
+    gobject-introspection
+    gtk-doc
+    meson
+    ninja
+    pkgconfig
+    (python3.withPackages (pkgs: with pkgs; [ setuptools ]))
+    shared-mime-info
+  ];
+
+  buildInputs = [
+    glib
+    libuuid
+  ];
 
   mesonFlags = [
     "--libexecdir=${placeholder "out"}/libexec"
     "-Dgtkdoc=true"
+    "-Dinstalled_test_prefix=${placeholder "installedTests"}"
   ];
 
   preCheck = ''
@@ -28,6 +68,12 @@ stdenv.mkDerivation rec {
 
   doCheck = true;
 
+  passthru = {
+    tests = {
+      installed-tests = nixosTests.libxmlb;
+    };
+  };
+
   meta = with stdenv.lib; {
     description = "A library to help create and query binary XML blobs";
     homepage = https://github.com/hughsie/libxmlb;
diff --git a/pkgs/development/libraries/libxmlb/installed-tests-path.patch b/pkgs/development/libraries/libxmlb/installed-tests-path.patch
new file mode 100644
index 00000000000..ab36d9efad8
--- /dev/null
+++ b/pkgs/development/libraries/libxmlb/installed-tests-path.patch
@@ -0,0 +1,24 @@
+diff --git a/meson.build b/meson.build
+index b064cb8..1a470cf 100644
+--- a/meson.build
++++ b/meson.build
+@@ -103,8 +103,8 @@
+ 
+ libexecdir = join_paths(prefix, get_option('libexecdir'))
+ datadir = join_paths(prefix, get_option('datadir'))
+-installed_test_bindir = join_paths(libexecdir, 'installed-tests', meson.project_name())
+-installed_test_datadir = join_paths(datadir, 'installed-tests', meson.project_name())
++installed_test_bindir = join_paths(get_option('installed_test_prefix'), 'libexec', 'installed-tests', meson.project_name())
++installed_test_datadir = join_paths(get_option('installed_test_prefix'), 'share', 'installed-tests', meson.project_name())
+ 
+ gio = dependency('gio-2.0', version : '>= 2.45.8')
+ uuid = dependency('uuid')
+diff --git a/meson_options.txt b/meson_options.txt
+index 27e8cb6..74548ae 100644
+--- a/meson_options.txt
++++ b/meson_options.txt
+@@ -2,3 +2,4 @@
+ option('introspection', type : 'boolean', value : true, description : 'generate GObject Introspection data')
+ option('tests', type : 'boolean', value : true, description : 'enable tests')
+ option('stemmer', type : 'boolean', value : false, description : 'enable stemmer support')
++option('installed_test_prefix', type: 'string', value: '', description: 'Prefix for installed tests')
diff --git a/pkgs/development/libraries/libxmlxx/v3.nix b/pkgs/development/libraries/libxmlxx/v3.nix
index 5e1e947b8f7..94c2ca09582 100644
--- a/pkgs/development/libraries/libxmlxx/v3.nix
+++ b/pkgs/development/libraries/libxmlxx/v3.nix
@@ -1,16 +1,15 @@
 { stdenv, fetchurl, pkgconfig, libxml2, glibmm, perl }:
 
 stdenv.mkDerivation rec {
-  name = "libxml++-${maj_ver}.${min_ver}";
-  maj_ver = "3.0";
-  min_ver = "1";
+  pname = "libxml++";
+  version = "3.0.1";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/libxml++/${maj_ver}/${name}.tar.xz";
+    url = "mirror://gnome/sources/libxml++/${stdenv.lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
     sha256 = "19kik79fmg61nv0by0a5f9wchrcfjwzvih4v2waw01hqflhqvp0r";
   };
 
-  outputs = [ "out" "devdoc" ];
+  outputs = [ "out" "dev" "doc" "devdoc" ];
 
   nativeBuildInputs = [ pkgconfig perl ];
 
@@ -18,6 +17,11 @@ stdenv.mkDerivation rec {
 
   propagatedBuildInputs = [ libxml2 ];
 
+  postFixup = ''
+    substituteInPlace $dev/lib/pkgconfig/libxml++-3.0.pc \
+      --replace 'docdir=''${datarootdir}' "docdir=$doc/share"
+  '';
+
   meta = with stdenv.lib; {
     homepage = http://libxmlplusplus.sourceforge.net/;
     description = "C++ wrapper for the libxml2 XML parser library, version 3";
diff --git a/pkgs/development/libraries/libxslt/default.nix b/pkgs/development/libraries/libxslt/default.nix
index 41633d91f3b..2dde7fe32ef 100644
--- a/pkgs/development/libraries/libxslt/default.nix
+++ b/pkgs/development/libraries/libxslt/default.nix
@@ -24,6 +24,16 @@ stdenv.mkDerivation rec {
       url = "https://gitlab.gnome.org/GNOME/libxslt/commit/e03553605b45c88f0b4b2980adfbbb8f6fca2fd6.patch";
       sha256 = "0pkpb4837km15zgg6h57bncp66d5lwrlvkr73h0lanywq7zrwhj8";
     })
+    (fetchpatch {
+      url = "https://gitlab.gnome.org/GNOME/libxslt/commit/c5eb6cf3aba0af048596106ed839b4ae17ecbcb1.patch";
+      name = "CVE-2019-13117.patch";
+      sha256 = "0ynfq8y5h623cypj1426iiz7796n3mqbjqa24ndvh2am6rl5lw15";
+    })
+    (fetchpatch {
+      url = "https://gitlab.gnome.org/GNOME/libxslt/commit/6ce8de69330783977dd14f6569419489875fb71b.patch";
+      name = "CVE-2019-13118.patch";
+      sha256 = "0bglz9m9sh2vi50qxcm06iqrazw3h45ycgxnp15iankq95z283iq";
+    })
   ];
 
   outputs = [ "bin" "dev" "out" "man" "doc" ] ++ stdenv.lib.optional pythonSupport "py";
diff --git a/pkgs/development/libraries/libyaml/default.nix b/pkgs/development/libraries/libyaml/default.nix
index c1f34bd3398..143555137d7 100644
--- a/pkgs/development/libraries/libyaml/default.nix
+++ b/pkgs/development/libraries/libyaml/default.nix
@@ -1,30 +1,20 @@
-{ stdenv, fetchurl, fetchpatch }:
-
-let
-
-  version = "0.2.1";
-
-  # https://github.com/yaml/pyyaml/issues/214
-  p1 = fetchpatch {
-         url = https://github.com/yaml/libyaml/commit/8ee83c0da22fe9aa7dea667be8f899a7e32ffb83.patch;
-         sha256 = "00jh39zww6s4gyhxfmlxwb6lz90nl3p51k5h1qm6z3ymik5vljmz";
-       };
-  p2 = fetchpatch {
-         url = https://github.com/yaml/libyaml/commit/56f4b17221868593d6903ee58d6d679b690cf4df.patch;
-         sha256 = "0najcay1y4kgfpsidj7dnyafnwjbav5jyawhyv215zl9gg3386n0";
-       };
-
-in
-
-stdenv.mkDerivation {
-  name = "libyaml-${version}";
-
-  src = fetchurl {
-    url = "https://pyyaml.org/download/libyaml/yaml-${version}.tar.gz";
-    sha256 = "1karpcfgacgppa82wm2drcfn2kb6q2wqfykf5nrhy20sci2i2a3q";
+{ stdenv
+, fetchFromGitHub
+, autoreconfHook
+}:
+
+stdenv.mkDerivation rec {
+  pname = "libyaml";
+  version = "0.2.2";
+
+  src = fetchFromGitHub {
+    owner = "yaml";
+    repo = "libyaml";
+    rev = version;
+    sha256 = "0839nqcmxjzfgjn39j7740pnlsgmvngpkamiw1lfy1qlcqyc3r4v";
   };
 
-  patches = [ p1 p2 ];  # remove when the next release comes out
+  nativeBuildInputs = [ autoreconfHook ];
 
   meta = with stdenv.lib; {
     homepage = https://pyyaml.org/;
diff --git a/pkgs/development/libraries/libzapojit/default.nix b/pkgs/development/libraries/libzapojit/default.nix
index 2ad017dc90b..215535fb8f1 100644
--- a/pkgs/development/libraries/libzapojit/default.nix
+++ b/pkgs/development/libraries/libzapojit/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, glib, intltool, json-glib, librest, libsoup, gnome3, gobject-introspection }:
+{ stdenv, fetchurl, pkgconfig, glib, intltool, json-glib, librest, libsoup, gnome3, gnome-online-accounts, gobject-introspection }:
 
 stdenv.mkDerivation rec {
   pname = "libzapojit";
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ pkgconfig intltool gobject-introspection ];
-  propagatedBuildInputs = [ glib json-glib librest libsoup gnome3.gnome-online-accounts ]; # zapojit-0.0.pc
+  propagatedBuildInputs = [ glib json-glib librest libsoup gnome-online-accounts ]; # zapojit-0.0.pc
 
   passthru = {
     updateScript = gnome3.updateScript {
diff --git a/pkgs/development/libraries/linbox/default.nix b/pkgs/development/libraries/linbox/default.nix
index 11f975187b0..9af0c20d701 100644
--- a/pkgs/development/libraries/linbox/default.nix
+++ b/pkgs/development/libraries/linbox/default.nix
@@ -1,6 +1,5 @@
 { stdenv
 , fetchFromGitHub
-, fetchpatch
 , autoreconfHook
 , givaro
 , pkgconfig
@@ -12,14 +11,14 @@
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
   pname = "linbox";
-  version = "1.6.2";
+  version = "1.6.3";
 
 
   src = fetchFromGitHub {
     owner = "linbox-team";
     repo = "${pname}";
     rev = "v${version}";
-    sha256 = "038br15hhc8dc1hq0pkv6vb1qx9hjr7hjv3w9fq9qwkd870h2v1q";
+    sha256 = "10j6dspbsq7d2l4q3y0c1l1xwmaqqba2fxg59q5bhgk9h5d7q571";
   };
 
   nativeBuildInputs = [
diff --git a/pkgs/development/libraries/liquid-dsp/default.nix b/pkgs/development/libraries/liquid-dsp/default.nix
index 391606d59e6..99ea6343d70 100644
--- a/pkgs/development/libraries/liquid-dsp/default.nix
+++ b/pkgs/development/libraries/liquid-dsp/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ autoreconfHook ];
 
   meta = {
-    homepage = http://liquidsdr.org/;
+    homepage = https://liquidsdr.org/;
     description = "Digital signal processing library for software-defined radios";
     license = stdenv.lib.licenses.mit;
     platforms = stdenv.lib.platforms.unix;
diff --git a/pkgs/development/libraries/live555/default.nix b/pkgs/development/libraries/live555/default.nix
index bf5b7bb1d0d..ff77cd71265 100644
--- a/pkgs/development/libraries/live555/default.nix
+++ b/pkgs/development/libraries/live555/default.nix
@@ -3,14 +3,14 @@
 # Based on https://projects.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD
 stdenv.mkDerivation rec {
   name = "live555-${version}";
-  version = "2019.05.29";
+  version = "2019.08.16";
 
   src = fetchurl { # the upstream doesn't provide a stable URL
     urls = [
       "mirror://sourceforge/slackbuildsdirectlinks/live.${version}.tar.gz"
       "https://download.videolan.org/contrib/live555/live.${version}.tar.gz"
     ];
-    sha256 = "08i63jr8ihn1xiq5z5n3yls3yz6li5sg0s454l56p5bcvbrw81my";
+    sha256 = "1y77dc5qxd731w96x707iibavmkfayy5s557d7lasg742h36lcqv";
   };
 
   postPatch = ''
diff --git a/pkgs/development/libraries/lmdb/default.nix b/pkgs/development/libraries/lmdb/default.nix
index 9d57d472182..690a42cfb30 100644
--- a/pkgs/development/libraries/lmdb/default.nix
+++ b/pkgs/development/libraries/lmdb/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "lmdb-${version}";
-  version = "0.9.23";
+  version = "0.9.24";
 
   src = fetchFromGitHub {
     owner = "LMDB";
     repo = "lmdb";
     rev = "LMDB_${version}";
-    sha256 = "0ag7l5180ajvm73y59m7sn3p52xm8m972d08cshxhpwgwa4v35k6";
+    sha256 = "088q6m8fvr12w43s461h7cvpg5hj8csaqj6n9pci150dz7bk5lxm";
   };
 
   postUnpack = "sourceRoot=\${sourceRoot}/libraries/liblmdb";
diff --git a/pkgs/development/libraries/luaffi/darwin.patch b/pkgs/development/libraries/luaffi/darwin.patch
deleted file mode 100644
index 50db81b776d..00000000000
--- a/pkgs/development/libraries/luaffi/darwin.patch
+++ /dev/null
@@ -1,17 +0,0 @@
-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
deleted file mode 100644
index 065562ac82e..00000000000
--- a/pkgs/development/libraries/luaffi/default.nix
+++ /dev/null
@@ -1,31 +0,0 @@
-{ stdenv, fetchFromGitHub, lua, pkgconfig }:
-
-stdenv.mkDerivation {
-  name = "luaffi-2013-11-08";
-  src = fetchFromGitHub {
-    owner = "jmckaskill";
-    repo = "luaffi";
-    rev = "abc638c9341025580099dcf77795c4b320ba0e63";
-    sha256 = "1hv1y9i66p473hfy36nqj220sfrxdmbd75c1gpjvpk8073vx55ac";
-  };
-
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ lua ];
-
-  patches = [ ./darwin.patch ./makefile-errors.patch ];
-
-  makeFlags = [ "PREFIX=$(out)" ];
-
-  installPhase = ''
-    mkdir -p $out/lib
-    cp ffi.so $out/lib/ffi.so
-  '';
-
-  meta = with stdenv.lib; {
-    description = "Standalone FFI library for calling C functions from lua. Compatible with the luajit FFI interface.";
-    homepage = https://github.com/jmckaskill/luaffi;
-    maintainers = with maintainers; [ ma27 ];
-    license = licenses.mit;
-    platforms = platforms.unix;
-  };
-}
diff --git a/pkgs/development/libraries/luaffi/makefile-errors.patch b/pkgs/development/libraries/luaffi/makefile-errors.patch
deleted file mode 100644
index 0ee6e639006..00000000000
--- a/pkgs/development/libraries/luaffi/makefile-errors.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/Makefile b/Makefile
-index b2b5f2c..49d4c99 100644
---- a/Makefile
-+++ b/Makefile
-@@ -6,7 +6,7 @@ LUA=lua
- LUA_CFLAGS=`$(PKG_CONFIG) --cflags lua5.2 2>/dev/null || $(PKG_CONFIG) --cflags lua`
- SOCFLAGS=-fPIC
- SOCC=$(CC) -shared $(SOCFLAGS)
--CFLAGS=-fPIC -g -Wall -Werror $(LUA_CFLAGS) -fvisibility=hidden -Wno-unused-function --std=gnu99
-+CFLAGS=-fPIC -g -Wall $(LUA_CFLAGS) -fvisibility=hidden -Wno-unused-function --std=gnu99
- 
- MODNAME=ffi
- MODSO=$(MODNAME).so
diff --git a/pkgs/development/libraries/mapnik/default.nix b/pkgs/development/libraries/mapnik/default.nix
index 1424ef9e12b..3a90a4cdf33 100644
--- a/pkgs/development/libraries/mapnik/default.nix
+++ b/pkgs/development/libraries/mapnik/default.nix
@@ -1,6 +1,6 @@
-{ stdenv, fetchzip, fetchpatch
+{ stdenv, fetchzip
 , boost, cairo, freetype, gdal, harfbuzz, icu, libjpeg, libpng, libtiff
-, libwebp, libxml2, proj, python, scons, sqlite, zlib
+, libwebp, libxml2, proj, python, sqlite, zlib
 
 # supply a postgresql package to enable the PostGIS input plugin
 , postgresql ? null
diff --git a/pkgs/development/libraries/matio/default.nix b/pkgs/development/libraries/matio/default.nix
index 9abdf4bbd85..9f8f34e0a80 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.15";
+  name = "matio-1.5.17";
   src = fetchurl {
     url = "mirror://sourceforge/matio/${name}.tar.gz";
-    sha256 = "1kxi15ph68nnbi0s1m8icb0685wg8ql8gj7wnkdk20kzpf3lbgr1";
+    sha256 = "00644612zhn53j25vj50q73kmjcrsns2lnmy99y2kavhsckmaiay";
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/mdds/default.nix b/pkgs/development/libraries/mdds/default.nix
index 16502ca4e61..cdc3dfa5ca0 100644
--- a/pkgs/development/libraries/mdds/default.nix
+++ b/pkgs/development/libraries/mdds/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   pname = "mdds";
-  version = "1.4.3";
+  version = "1.5.0";
 
   src = fetchurl {
     url = "https://kohei.us/files/${pname}/src/${pname}-${version}.tar.bz2";
-    sha256 = "10cw6irdm6d15nxnys2v5akp8yz52qijpcjvw0frwq7nz5d3vki5";
+    sha256 = "03b8i43pw4m767mm0cnbi77x7qhpkzpi9b1f6dpp4cmyszmnsk8l";
   };
 
   postInstall = ''
diff --git a/pkgs/development/libraries/mesa/default.nix b/pkgs/development/libraries/mesa/default.nix
index 40a03707ea5..7b1b5a3cfa9 100644
--- a/pkgs/development/libraries/mesa/default.nix
+++ b/pkgs/development/libraries/mesa/default.nix
@@ -1,13 +1,13 @@
-{ stdenv, fetchurl, lib
-, pkgconfig, intltool, autoreconfHook
-, file, expat, libdrm, xorg, wayland, wayland-protocols, openssl
+{ stdenv, lib, fetchurl, fetchpatch
+, pkgconfig, intltool, ninja, meson
+, file, flex, bison, expat, libdrm, xorg, wayland, wayland-protocols, openssl
 , llvmPackages, libffi, libomxil-bellagio, libva-minimal
-, libelf, libvdpau, python2, python2Packages
+, libelf, libvdpau, python3Packages
 , libglvnd
 , enableRadv ? true
-, galliumDrivers ? null
-, driDrivers ? null
-, vulkanDrivers ? null
+, galliumDrivers ? ["auto"]
+, driDrivers ? ["auto"]
+, vulkanDrivers ? ["auto"]
 , eglPlatforms ? [ "x11" ] ++ lib.optionals stdenv.isLinux [ "wayland" "drm" ]
 , OpenGL, Xplugin
 , withValgrind ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAarch32, valgrind-light
@@ -27,49 +27,13 @@
 with stdenv.lib;
 
 let
-  # platforms that have PCIe slots and thus can use most non-integrated GPUs
-  pciePlatform = !stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64;
-  defaultGalliumDrivers = optionals (elem "drm" eglPlatforms) ([ "virgl" ]
-    ++ lib.optionals pciePlatform [ "r300" "r600" "radeonsi" ]
-    ++ lib.optionals (pciePlatform || stdenv.hostPlatform.isAarch32 || stdenv.hostPlatform.isAarch64) [ "nouveau" ]
-    ++ lib.optionals stdenv.hostPlatform.isx86 [ "i915" "svga" ]
-    ++ lib.optionals (stdenv.hostPlatform.isAarch32 || stdenv.hostPlatform.isAarch64) [ "vc4" ]
-    ++ lib.optionals stdenv.hostPlatform.isAarch64 [ "freedreno" "etnaviv" "imx" ]
-  );
-  defaultDriDrivers = optionals (elem "drm" eglPlatforms) ([ ]
-    ++ lib.optionals pciePlatform [ "radeon" "r200" ]
-    ++ lib.optionals (pciePlatform || stdenv.hostPlatform.isAarch32 || stdenv.hostPlatform.isAarch64) [ "nouveau" ]
-    ++ lib.optionals stdenv.hostPlatform.isx86 [ "i915" "i965" ]);
-  defaultVulkanDrivers = optionals stdenv.hostPlatform.isLinux ([ ]
-    ++ lib.optional stdenv.hostPlatform.isx86 "intel"
-    ++ lib.optional enableRadv "radeon");
-in
-
-let gallium_ = galliumDrivers; dri_ = driDrivers; vulkan_ = vulkanDrivers; in
-
-let
-  galliumDrivers =
-    (if gallium_ == null
-          then defaultGalliumDrivers
-          else gallium_)
-    ++ lib.optional stdenv.isLinux "swrast";
-  driDrivers =
-    (if dri_ == null
-      then optionals (elem "drm" eglPlatforms) defaultDriDrivers
-      else dri_) ++ lib.optional stdenv.isLinux "swrast";
-  vulkanDrivers =
-    if vulkan_ == null
-    then defaultVulkanDrivers
-    else vulkan_;
-in
-
-let
-  version = "18.3.4";
+  version = "19.1.3";
   branch  = head (splitString "." version);
 in
 
-let self = stdenv.mkDerivation {
-  name = "mesa-noglu-${version}";
+stdenv.mkDerivation rec {
+  pname = "mesa";
+  inherit version;
 
   src =  fetchurl {
     urls = [
@@ -78,7 +42,7 @@ let self = stdenv.mkDerivation {
       "ftp://ftp.freedesktop.org/pub/mesa/older-versions/${branch}.x/${version}/mesa-${version}.tar.xz"
       "https://mesa.freedesktop.org/archive/mesa-${version}.tar.xz"
     ];
-    sha256 = "01xv03ah4l5lcfx015n3fg1620dh4nbbv6gmhh6zhdsx6sj4sc9j";
+    sha256 = "1q5p4mw7zrklwx1is09knnb762zzk33xwhwp99fw25ax4ar60m44";
   };
 
   prePatch = "patchShebangs .";
@@ -87,60 +51,58 @@ let self = stdenv.mkDerivation {
   #  revive ./dricore-gallium.patch when it gets ported (from Ubuntu), as it saved
   #  ~35 MB in $drivers; watch https://launchpad.net/ubuntu/+source/mesa/+changelog
   patches = [
-    ./symlink-drivers.patch
     ./missing-includes.patch # dev_t needs sys/stat.h, time_t needs time.h, etc.-- fixes build w/musl
+    ./opencl-install-dir.patch
     ./disk_cache-include-dri-driver-path-in-cache-key.patch
-  ];
+  ] # do not prefix user provided dri-drivers-path
+    ++ lib.optional (lib.versionOlder version "19.0.0") (fetchpatch {
+      url = "https://gitlab.freedesktop.org/mesa/mesa/commit/f6556ec7d126b31da37c08d7cb657250505e01a0.patch";
+      sha256 = "0z6phi8hbrbb32kkp1js7ggzviq7faz1ria36wi4jbc4in2392d9";
+    })
+    ++ lib.optionals (lib.versionOlder version "19.1.0") [
+      # do not prefix user provided d3d-drivers-path
+      (fetchpatch {
+        url = "https://gitlab.freedesktop.org/mesa/mesa/commit/dcc48664197c7e44684ccfb970a4ae083974d145.patch";
+        sha256 = "1nhs0xpx3hiy8zfb5gx1zd7j7xha6h0hr7yingm93130a5902lkb";
+      })
+
+      # don't build libGLES*.so with GLVND
+      (fetchpatch {
+        url = "https://gitlab.freedesktop.org/mesa/mesa/commit/b01524fff05eef66e8cd24f1c5aacefed4209f03.patch";
+        sha256 = "1pszr6acx2xw469zq89n156p3bf3xf84qpbjw5fr1sj642lbyh7c";
+      })
+    ];
 
-  outputs = [ "out" "dev" "drivers" ]
-            ++ lib.optional (elem "swrast" galliumDrivers) "osmesa";
+  outputs = [ "out" "dev" "drivers" "osmesa" ];
 
   # TODO: Figure out how to enable opencl without having a runtime dependency on clang
-  configureFlags = [
-    "--sysconfdir=${libglvnd.driverLink}/etc"
-    "--localstatedir=/var"
-    "--with-dri-driverdir=$(drivers)/lib/dri"
-    "--with-dri-searchpath=${libglvnd.driverLink}/lib/dri"
-    "--with-platforms=${concatStringsSep "," eglPlatforms}"
-    "--with-gallium-drivers=${concatStringsSep "," galliumDrivers}"
-    "--with-dri-drivers=${concatStringsSep "," driDrivers}"
-    "--with-vulkan-drivers=${concatStringsSep "," vulkanDrivers}"
-    "--enable-texture-float"
-    (enableFeature stdenv.isLinux "dri3")
-    (enableFeature stdenv.isLinux "nine") # Direct3D in Wine
-    (enableFeature stdenv.isLinux "libglvnd")
-    "--enable-dri"
-    "--enable-driglx-direct"
-    "--enable-gles1"
-    "--enable-gles2"
-    "--enable-glx"
-    # https://bugs.freedesktop.org/show_bug.cgi?id=35268
-    (enableFeature (!stdenv.hostPlatform.isMusl) "glx-tls")
-    # used by wine
-    (enableFeature (elem "swrast" galliumDrivers) "gallium-osmesa")
-    "--enable-llvm"
-    (enableFeature stdenv.isLinux "egl")
-    (enableFeature stdenv.isLinux "xa") # used in vmware driver
-    (enableFeature stdenv.isLinux "gbm")
-    "--enable-xvmc"
-    "--enable-vdpau"
-    "--enable-shared-glapi"
-    "--enable-llvm-shared-libs"
-    (enableFeature stdenv.isLinux "omx-bellagio")
-    (enableFeature stdenv.isLinux "va")
-    "--disable-opencl"
-  ];
-
-  nativeBuildInputs = [
-    autoreconfHook intltool pkgconfig file
-    python2 python2Packages.Mako
+  mesonFlags = [
+    "--sysconfdir=/etc"
+
+    # Don't build in debug mode
+    # https://gitlab.freedesktop.org/mesa/mesa/blob/master/docs/meson.html#L327
+    "-Db_ndebug=true"
+
+    "-Ddisk-cache-key=${placeholder "drivers"}"
+    "-Ddri-search-path=${libglvnd.driverLink}/lib/dri"
+
+    "-Dplatforms=${concatStringsSep "," eglPlatforms}"
+    "-Ddri-drivers=${concatStringsSep "," driDrivers}"
+    "-Dgallium-drivers=${concatStringsSep "," galliumDrivers}"
+    "-Dvulkan-drivers=${concatStringsSep "," vulkanDrivers}"
+
+    "-Ddri-drivers-path=${placeholder "drivers"}/lib/dri"
+    "-Dvdpau-libs-path=${placeholder "drivers"}/lib/vdpau"
+    "-Dxvmc-libs-path=${placeholder "drivers"}/lib"
+    "-Domx-libs-path=${placeholder "drivers"}/lib/bellagio"
+    "-Dva-libs-path=${placeholder "drivers"}/lib/dri"
+    "-Dd3d-drivers-path=${placeholder "drivers"}/lib/d3d"
+  ] ++ optionals stdenv.isLinux [
+    "-Dglvnd=true"
+    "-Dosmesa=gallium" # used by wine
+    "-Dgallium-nine=true" # Direct3D in Wine
   ];
 
-  propagatedBuildInputs = with xorg; [
-    libXdamage libXxf86vm
-  ] ++ optional stdenv.isLinux libdrm
-    ++ optionals stdenv.isDarwin [ OpenGL Xplugin ];
-
   buildInputs = with xorg; [
     expat llvmPackages.llvm libglvnd xorgproto
     libX11 libXext libxcb libXt libXfixes libxshmfence libXrandr
@@ -150,50 +112,38 @@ let self = stdenv.mkDerivation {
     ++ lib.optionals stdenv.isLinux [ libomxil-bellagio libva-minimal ]
     ++ lib.optional withValgrind valgrind-light;
 
+  nativeBuildInputs = [
+    pkgconfig meson ninja
+    intltool bison flex file
+    python3Packages.python python3Packages.Mako
+  ];
+
+  propagatedBuildInputs = with xorg; [
+    libXdamage libXxf86vm
+  ] ++ optional stdenv.isLinux libdrm
+    ++ optionals stdenv.isDarwin [ OpenGL Xplugin ];
+
   enableParallelBuilding = true;
   doCheck = false;
 
-  installFlags = [
-    "sysconfdir=\${drivers}/etc"
-    "localstatedir=\${TMPDIR}"
-    "vendorjsondir=\${out}/share/glvnd/egl_vendor.d"
-  ];
-
-  # TODO: probably not all .la files are completely fixed, but it shouldn't matter;
   postInstall = ''
     # Some installs don't have any drivers so this directory is never created.
-    mkdir -p $drivers
-  '' + optionalString (galliumDrivers != []) ''
+    mkdir -p $drivers $osmesa
+  '' + optionalString stdenv.isLinux ''
+    mkdir -p $drivers/lib
+
     # move gallium-related stuff to $drivers, so $out doesn't depend on LLVM
-    mv -t "$drivers/lib/"    \
-      $out/lib/libXvMC*      \
-      $out/lib/d3d           \
-      $out/lib/vdpau         \
-      $out/lib/bellagio      \
+    mv -t $drivers/lib       \
       $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/
+    mkdir -p $osmesa/lib
     mv -t $osmesa/lib/ $out/lib/libOSMesa*
 
-    # now fix references in .la files
-    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)' "${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/
 
@@ -202,11 +152,6 @@ let self = stdenv.mkDerivation {
       substituteInPlace "$js" --replace '"libEGL_' '"'"$drivers/lib/libEGL_"
     done
 
-    # Update search path used by pkg-config
-    for pc in $dev/lib/pkgconfig/{d3d,dri,xatracker}.pc; do
-      substituteInPlace "$pc" --replace $out $drivers
-    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
@@ -217,7 +162,18 @@ let self = stdenv.mkDerivation {
   # TODO:
   #  check $out doesn't depend on llvm: builder failures are ignored
   #  for some reason grep -qv '${llvmPackages.llvm}' -R "$out";
-  postFixup = optionalString (galliumDrivers != []) ''
+  postFixup = optionalString stdenv.isLinux ''
+    # set the default search path for DRI drivers; used e.g. by X server
+    substituteInPlace "$dev/lib/pkgconfig/dri.pc" --replace "$drivers" "${libglvnd.driverLink}"
+
+    # remove pkgconfig files for GL/EGL; they are provided by libGL.
+    rm $dev/lib/pkgconfig/{gl,egl}.pc
+
+    # Update search path used by pkg-config
+    for pc in $dev/lib/pkgconfig/{d3d,dri,xatracker}.pc; do
+      substituteInPlace "$pc" --replace $out $drivers
+    done
+
     # add RPATH so the drivers can find the moved libgallium and libdricore9
     # moved here to avoid problems with stripping patchelfed files
     for lib in $drivers/lib/*.so* $drivers/lib/*/*.so*; do
@@ -227,81 +183,11 @@ let self = stdenv.mkDerivation {
     done
   '';
 
+  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-fno-common";
+
   passthru = {
-    inherit libdrm version;
+    inherit libdrm;
     inherit (libglvnd) driverLink;
-
-    # Use stub libraries from libglvnd and headers from Mesa.
-    stubs = stdenv.mkDerivation {
-      name = "libGL-${libglvnd.version}";
-      outputs = [ "out" "dev" ];
-
-      # On macOS, libglvnd is not supported, so we just use what mesa
-      # build. We need to also include OpenGL.framework, and some
-      # extra tricks to go along with. We add mesa’s libGLX to support
-      # the X extensions to OpenGL.
-      buildCommand = if stdenv.hostPlatform.isDarwin then ''
-        mkdir -p $out/nix-support $dev
-        echo ${OpenGL} >> $out/nix-support/propagated-build-inputs
-        ln -s ${self.out}/lib $out/lib
-
-        mkdir -p $dev/lib/pkgconfig $dev/nix-support
-        echo "$out" > $dev/nix-support/propagated-build-inputs
-        ln -s ${self.dev}/include $dev/include
-
-        cat <<EOF >$dev/lib/pkgconfig/gl.pc
-      Name: gl
-      Description: gl library
-      Version: ${self.version}
-      Libs: -L${self.out}/lib -lGL
-      Cflags: -I${self.dev}/include
-      EOF
-
-        cat <<EOF >$dev/lib/pkgconfig/glesv1_cm.pc
-      Name: glesv1_cm
-      Description: glesv1_cm library
-      Version: ${self.version}
-      Libs: -L${self.out}/lib -lGLESv1_CM
-      Cflags: -I${self.dev}/include
-      EOF
-
-        cat <<EOF >$dev/lib/pkgconfig/glesv2.pc
-      Name: glesv2
-      Description: glesv2 library
-      Version: ${self.version}
-      Libs: -L${self.out}/lib -lGLESv2
-      Cflags: -I${self.dev}/include
-      EOF
-      ''
-
-      # Otherwise, setup gl stubs to use libglvnd.
-      else ''
-        mkdir -p $out/nix-support
-        ln -s ${libglvnd.out}/lib $out/lib
-
-        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; {
@@ -311,5 +197,4 @@ let self = stdenv.mkDerivation {
     platforms = platforms.mesaPlatforms;
     maintainers = with maintainers; [ vcunat ];
   };
-};
-in self
+}
diff --git a/pkgs/development/libraries/mesa/disk_cache-include-dri-driver-path-in-cache-key.patch b/pkgs/development/libraries/mesa/disk_cache-include-dri-driver-path-in-cache-key.patch
index 37813db8934..1e280b64ee5 100644
--- a/pkgs/development/libraries/mesa/disk_cache-include-dri-driver-path-in-cache-key.patch
+++ b/pkgs/development/libraries/mesa/disk_cache-include-dri-driver-path-in-cache-key.patch
@@ -6,29 +6,30 @@ Subject: [PATCH] disk_cache: include dri driver path in cache key
 This fixes invalid cache hits on NixOS where all shared library
 timestamps in /nix/store are zero.
 ---
- src/util/Makefile.am  | 3 +++
+ meson_options.txt     | 6 ++++++
  src/util/disk_cache.c | 3 +++
- 2 files changed, 6 insertions(+)
+ src/util/meson.build  | 7 ++++++-
+ 3 files changed, 15 insertions(+), 1 deletion(-)
 
-diff --git a/src/util/Makefile.am b/src/util/Makefile.am
-index bafb57439a..a22e2e41eb 100644
---- a/src/util/Makefile.am
-+++ b/src/util/Makefile.am
-@@ -35,6 +35,9 @@ noinst_LTLIBRARIES = \
- 	libmesautil.la \
- 	libxmlconfig.la
- 
-+AM_CFLAGS = \
-+	-DDISK_CACHE_KEY=\"$(drivers)\"
-+
- AM_CPPFLAGS = \
- 	$(PTHREAD_CFLAGS) \
- 	-I$(top_srcdir)/include
+diff --git a/meson_options.txt b/meson_options.txt
+index a723b5406cf..65a8954291f 100644
+--- a/meson_options.txt
++++ b/meson_options.txt
+@@ -330,3 +330,9 @@ option(
+   value : true,
+   description : 'Enable direct rendering in GLX and EGL for DRI',
+ )
++option(
++  'disk-cache-key',
++  type : 'string',
++  value : '',
++  description : 'Mesa cache key.'
++)
 diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
-index 368ec41792..071220b2ba 100644
+index 0aa2646a9bb..bd784d38e21 100644
 --- a/src/util/disk_cache.c
 +++ b/src/util/disk_cache.c
-@@ -388,8 +388,10 @@ disk_cache_create(const char *gpu_name, const char *driver_id,
+@@ -389,8 +389,10 @@ disk_cache_create(const char *gpu_name, const char *driver_id,
  
     /* Create driver id keys */
     size_t id_size = strlen(driver_id) + 1;
@@ -39,7 +40,7 @@ index 368ec41792..071220b2ba 100644
     cache->driver_keys_blob_size += gpu_name_size;
  
     /* We sometimes store entire structs that contains a pointers in the cache,
-@@ -410,6 +412,7 @@ disk_cache_create(const char *gpu_name, const char *driver_id,
+@@ -411,6 +413,7 @@ disk_cache_create(const char *gpu_name, const char *driver_id,
     uint8_t *drv_key_blob = cache->driver_keys_blob;
     DRV_KEY_CPY(drv_key_blob, &cache_version, cv_size)
     DRV_KEY_CPY(drv_key_blob, driver_id, id_size)
@@ -47,6 +48,24 @@ index 368ec41792..071220b2ba 100644
     DRV_KEY_CPY(drv_key_blob, gpu_name, gpu_name_size)
     DRV_KEY_CPY(drv_key_blob, &ptr_size, ptr_size_size)
     DRV_KEY_CPY(drv_key_blob, &driver_flags, driver_flags_size)
+diff --git a/src/util/meson.build b/src/util/meson.build
+index 397c2228129..77013563e5d 100644
+--- a/src/util/meson.build
++++ b/src/util/meson.build
+@@ -120,7 +120,12 @@ libmesa_util = static_library(
+   [files_mesa_util, format_srgb],
+   include_directories : inc_common,
+   dependencies : [dep_zlib, dep_clock, dep_thread, dep_atomic, dep_m],
+-  c_args : [c_msvc_compat_args, c_vis_args],
++  c_args : [
++    c_msvc_compat_args, c_vis_args,
++    '-DDISK_CACHE_KEY="@0@"'.format(
++      get_option('disk-cache-key')
++    ),
++  ],
+   build_by_default : false
+ )
+ 
 -- 
-2.19.1
+2.19.2
 
diff --git a/pkgs/development/libraries/mesa/opencl-install-dir.patch b/pkgs/development/libraries/mesa/opencl-install-dir.patch
new file mode 100644
index 00000000000..fe85d2c90bb
--- /dev/null
+++ b/pkgs/development/libraries/mesa/opencl-install-dir.patch
@@ -0,0 +1,12 @@
+diff --git a/src/gallium/targets/opencl/meson.build b/src/gallium/targets/opencl/meson.build
+index 317ad8dab4a..5567308caf0 100644
+--- a/src/gallium/targets/opencl/meson.build
++++ b/src/gallium/targets/opencl/meson.build
+@@ -68,6 +68,6 @@ if with_opencl_icd
+     input : 'mesa.icd.in',
+     output : 'mesa.icd',
+     install : true,
+-    install_dir : join_paths(get_option('sysconfdir'), 'OpenCL', 'vendors'),
++    install_dir : join_paths(get_option('prefix'), 'etc', 'OpenCL', 'vendors'),
+   )
+ endif
diff --git a/pkgs/development/libraries/mesa/stubs.nix b/pkgs/development/libraries/mesa/stubs.nix
new file mode 100644
index 00000000000..5cb6ac3d4d1
--- /dev/null
+++ b/pkgs/development/libraries/mesa/stubs.nix
@@ -0,0 +1,75 @@
+{ stdenv
+, libglvnd, mesa
+, OpenGL }:
+
+stdenv.mkDerivation {
+  inherit (libglvnd) version;
+  pname = "libGL";
+  outputs = [ "out" "dev" ];
+
+  # On macOS, libglvnd is not supported, so we just use what mesa
+  # build. We need to also include OpenGL.framework, and some
+  # extra tricks to go along with. We add mesa’s libGLX to support
+  # the X extensions to OpenGL.
+  buildCommand = if stdenv.hostPlatform.isDarwin then ''
+    mkdir -p $out/nix-support $dev
+    echo ${OpenGL} >> $out/nix-support/propagated-build-inputs
+    ln -s ${mesa.out}/lib $out/lib
+
+    mkdir -p $dev/lib/pkgconfig $dev/nix-support
+    echo "$out" > $dev/nix-support/propagated-build-inputs
+    ln -s ${mesa.dev}/include $dev/include
+
+    cat <<EOF >$dev/lib/pkgconfig/gl.pc
+  Name: gl
+  Description: gl library
+  Version: ${mesa.version}
+  Libs: -L${mesa.out}/lib -lGL
+  Cflags: -I${mesa.dev}/include
+  EOF
+
+    cat <<EOF >$dev/lib/pkgconfig/glesv1_cm.pc
+  Name: glesv1_cm
+  Description: glesv1_cm library
+  Version: ${mesa.version}
+  Libs: -L${mesa.out}/lib -lGLESv1_CM
+  Cflags: -I${mesa.dev}/include
+  EOF
+
+    cat <<EOF >$dev/lib/pkgconfig/glesv2.pc
+  Name: glesv2
+  Description: glesv2 library
+  Version: ${mesa.version}
+  Libs: -L${mesa.out}/lib -lGLESv2
+  Cflags: -I${mesa.dev}/include
+  EOF
+  ''
+
+  # Otherwise, setup gl stubs to use libglvnd.
+  else ''
+    mkdir -p $out/nix-support
+    ln -s ${libglvnd.out}/lib $out/lib
+
+    mkdir -p $dev/{,lib/pkgconfig,nix-support}
+    echo "$out" > $dev/nix-support/propagated-build-inputs
+    ln -s ${mesa.dev}/include $dev/include
+
+    genPkgConfig() {
+      local name="$1"
+      local lib="$2"
+
+      cat <<EOF >$dev/lib/pkgconfig/$name.pc
+    Name: $name
+    Description: $lib library
+    Version: ${mesa.version}
+    Libs: -L${libglvnd.out}/lib -l$lib
+    Cflags: -I${mesa.dev}/include
+    EOF
+    }
+
+    genPkgConfig gl GL
+    genPkgConfig egl EGL
+    genPkgConfig glesv1_cm GLESv1_CM
+    genPkgConfig glesv2 GLESv2
+  '';
+}
diff --git a/pkgs/development/libraries/mesa/symlink-drivers.patch b/pkgs/development/libraries/mesa/symlink-drivers.patch
deleted file mode 100644
index af2ec9fdb09..00000000000
--- a/pkgs/development/libraries/mesa/symlink-drivers.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-diff -ru -x '*~' mesa-12.0.3-orig/src/gallium/targets/dri/Makefile.am mesa-12.0.3/src/gallium/targets/dri/Makefile.am
---- mesa-12.0.3-orig/src/gallium/targets/dri/Makefile.am	2016-09-08 18:57:48.000000000 +0200
-+++ mesa-12.0.3/src/gallium/targets/dri/Makefile.am	2016-09-22 14:42:19.173575498 +0200
-@@ -134,14 +134,13 @@
- 	done;
- endif
- 
--# hardlink each megadriver instance, but don't actually have
--# gallium_dri.so in the set of final installed files.
-+# symlink each megadriver instance.
- install-data-hook:
- 	for i in $(TARGET_DRIVERS); do                                  \
--		ln -f $(DESTDIR)$(dridir)/gallium_dri.so                \
-+		ln -srf $(DESTDIR)$(dridir)/gallium_dri.so              \
- 		      $(DESTDIR)$(dridir)/$${i}_dri.so;                 \
- 	done;                                                           \
--	$(RM) $(DESTDIR)$(dridir)/gallium_dri.*;                        \
-+	$(RM) $(DESTDIR)$(dridir)/gallium_dri.la                        \
- 	$(RM) -d $(DESTDIR)$(dridir) &>/dev/null || true
- 
- uninstall-hook:
- 	for i in $(TARGET_DRIVERS); do                                  \
-diff -ru -x '*~' mesa-12.0.3-orig/src/gallium/targets/va/Makefile.am mesa-12.0.3/src/gallium/targets/va/Makefile.am
---- mesa-12.0.3-orig/src/gallium/targets/va/Makefile.am	2016-09-08 18:57:48.000000000 +0200
-+++ mesa-12.0.3/src/gallium/targets/va/Makefile.am	2016-09-22 14:45:39.635963339 +0200
-@@ -71,10 +71,10 @@
- # gallium_drv_video.so in the set of final installed files.
- install-data-hook:
- 	for i in $(TARGET_DRIVERS); do                                  \
--		ln -f $(DESTDIR)$(vadir)/gallium_drv_video.so                \
-+		ln -srf $(DESTDIR)$(vadir)/gallium_drv_video.so                \
- 		      $(DESTDIR)$(vadir)/$${i}_drv_video.so;                 \
- 	done;                                                           \
--	$(RM) $(DESTDIR)$(vadir)/gallium_drv_video.*
-+	$(RM) $(DESTDIR)$(vadir)/gallium_drv_video.la
- 
- uninstall-hook:
- 	for i in $(TARGET_DRIVERS); do                                  \
-diff -ru -x '*~' mesa-12.0.3-orig/src/gallium/targets/vdpau/Makefile.am mesa-12.0.3/src/gallium/targets/vdpau/Makefile.am
---- mesa-12.0.3-orig/src/gallium/targets/vdpau/Makefile.am	2016-05-24 21:19:37.000000000 +0200
-+++ mesa-12.0.3/src/gallium/targets/vdpau/Makefile.am	2016-09-22 14:42:19.173575498 +0200
-@@ -103,15 +103,14 @@
- 	done;
- endif
- 
--# hardlink each megadriver instance, but don't actually have
--# libvdpau_gallium.so in the set of final installed files.
-+# symlink each megadriver instance.
- install-data-hook:
- 	$(AM_V_GEN)dest_dir=$(DESTDIR)/$(vdpaudir);			\
- 	for i in $(TARGET_DRIVERS); do					\
- 		j=libvdpau_gallium.$(LIB_EXT);				\
- 		k=libvdpau_$${i}.$(LIB_EXT);				\
- 		l=$${k}.$(VDPAU_MAJOR).$(VDPAU_MINOR).0;		\
--		ln -f $${dest_dir}/$${j}.$(VDPAU_MAJOR).$(VDPAU_MINOR).0 \
-+		ln -srf $${dest_dir}/$${j}.$(VDPAU_MAJOR).$(VDPAU_MINOR).0 \
- 		      $${dest_dir}/$${l};				\
- 		ln -sf $${l}						\
- 		       $${dest_dir}/$${k}.$(VDPAU_MAJOR).$(VDPAU_MINOR); \
-@@ -120,7 +119,7 @@
- 		ln -sf $${l}						\
- 		       $${dest_dir}/$${k};				\
- 	done;								\
--	$(RM) $${dest_dir}/libvdpau_gallium.*;				\
-+	$(RM) $${dest_dir}/libvdpau_gallium.la				\
- 	$(RM) -d $${dest_dir} &>/dev/null || true
- 
- uninstall-hook:
- 	for i in $(TARGET_DRIVERS); do					\
-diff -ru -x '*~' mesa-12.0.3-orig/src/gallium/targets/xvmc/Makefile.am mesa-12.0.3/src/gallium/targets/xvmc/Makefile.am
---- mesa-12.0.3-orig/src/gallium/targets/xvmc/Makefile.am	2016-05-24 21:19:37.000000000 +0200
-+++ mesa-12.0.3/src/gallium/targets/xvmc/Makefile.am	2016-09-22 14:54:22.291014543 +0200
-@@ -73,7 +73,7 @@
- 		j=libXvMCgallium.$(LIB_EXT);				\
- 		k=libXvMC$${i}.$(LIB_EXT);				\
- 		l=$${k}.$(XVMC_MAJOR).$(XVMC_MINOR).0;			\
--		ln -f $${dest_dir}/$${j}.$(XVMC_MAJOR).$(XVMC_MINOR).0	\
-+		ln -srf $${dest_dir}/$${j}.$(XVMC_MAJOR).$(XVMC_MINOR).0 \
- 		      $${dest_dir}/$${l};				\
- 		ln -sf $${l}						\
- 		       $${dest_dir}/$${k}.$(XVMC_MAJOR).$(XVMC_MINOR);	\
-@@ -82,7 +82,7 @@
- 		ln -sf $${l}						\
- 		       $${dest_dir}/$${k};				\
- 	done;								\
--	$(RM) $${dest_dir}/libXvMCgallium.*;				\
-+	$(RM) $${dest_dir}/libXvMCgallium.la				\
- 	$(RM) -d $${dest_dir} &>/dev/null || true
- 
- uninstall-hook:
- 	for i in $(TARGET_DRIVERS); do					\
-diff -ru -x '*~' mesa-12.0.3-orig/src/mesa/drivers/dri/Makefile.am mesa-12.0.3/src/mesa/drivers/dri/Makefile.am
---- mesa-12.0.3-orig/src/mesa/drivers/dri/Makefile.am	2016-09-08 18:57:48.000000000 +0200
-+++ mesa-12.0.3/src/mesa/drivers/dri/Makefile.am	2016-09-22 14:42:19.173575498 +0200
-@@ -94,14 +94,13 @@
- 	done;
- endif
- 
--# hardlink each megadriver instance, but don't actually have
--# mesa_dri_drivers.so in the set of final installed files.
-+# symink each megadriver instance.
- install-data-hook:
- 	for i in $(MEGADRIVERS); do \
--		ln -f $(DESTDIR)$(dridir)/mesa_dri_drivers.so \
-+		ln -srf $(DESTDIR)$(dridir)/mesa_dri_drivers.so \
- 		      $(DESTDIR)$(dridir)/$$i; \
- 	done;
--	$(RM) $(DESTDIR)$(dridir)/mesa_dri_drivers.*
-+	$(RM) $(DESTDIR)$(dridir)/mesa_dri_drivers.la
- 
- uninstall-hook:
- 	for i in $(MEGADRIVERS); do \
diff --git a/pkgs/development/libraries/mlt/default.nix b/pkgs/development/libraries/mlt/default.nix
index d8075c41a70..a56deff66e4 100644
--- a/pkgs/development/libraries/mlt/default.nix
+++ b/pkgs/development/libraries/mlt/default.nix
@@ -6,13 +6,13 @@
 
 stdenv.mkDerivation rec {
   name = "mlt-${version}";
-  version = "6.10.0";
+  version = "6.16.0";
 
   src = fetchFromGitHub {
     owner = "mltframework";
     repo = "mlt";
     rev = "v${version}";
-    sha256 = "0ki86yslr5ywa6sz8pjrgd9a4rn2rr4mss2zkmqi7pq8prgsm1fr";
+    sha256 = "1362fv63p34kza9v4b71b6wakgvsa2vdx9y0g28x3yh4cp4k97kx";
   };
 
   buildInputs = [
diff --git a/pkgs/development/libraries/mlt/qt-5.nix b/pkgs/development/libraries/mlt/qt-5.nix
index 85ea7a6292a..f46ec57197f 100644
--- a/pkgs/development/libraries/mlt/qt-5.nix
+++ b/pkgs/development/libraries/mlt/qt-5.nix
@@ -7,13 +7,13 @@ let inherit (stdenv.lib) getDev; in
 
 stdenv.mkDerivation rec {
   name = "mlt-${version}";
-  version = "6.14.0";
+  version = "6.16.0";
 
   src = fetchFromGitHub {
     owner = "mltframework";
     repo = "mlt";
     rev = "v${version}";
-    sha256 = "0lxjrd0rsadkfwg86qp0p176kqd9zdfhbmjygmrg5jklmxzd5i25";
+    sha256 = "1362fv63p34kza9v4b71b6wakgvsa2vdx9y0g28x3yh4cp4k97kx";
   };
 
   buildInputs = [
diff --git a/pkgs/development/libraries/movit/default.nix b/pkgs/development/libraries/movit/default.nix
index 849da2e6cad..96444ea4a23 100644
--- a/pkgs/development/libraries/movit/default.nix
+++ b/pkgs/development/libraries/movit/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "movit-${version}";
-  version = "1.6.2";
+  version = "1.6.3";
 
   src = fetchurl {
     url = "https://movit.sesse.net/${name}.tar.gz";
-    sha256 = "1q9h086v6h3da4b9qyflcjx73cgnqjhb92rv6g4j90m34dndaa3l";
+    sha256 = "164lm5sg95ca6k546zf775g3s79mgff0az96wl6hbmlrxh4z26gb";
   };
 
   outputs = [ "out" "dev" ];
diff --git a/pkgs/development/libraries/mp4v2/default.nix b/pkgs/development/libraries/mp4v2/default.nix
index 51081f25bf2..f920f637960 100644
--- a/pkgs/development/libraries/mp4v2/default.nix
+++ b/pkgs/development/libraries/mp4v2/default.nix
@@ -17,6 +17,8 @@ stdenv.mkDerivation rec {
     })
   ];
 
+  buildFlags = [ "CXXFLAGS=-std=c++03" ];
+
   # `faac' expects `mp4.h'.
   postInstall = "ln -s mp4v2/mp4v2.h $out/include/mp4.h";
 
diff --git a/pkgs/development/libraries/mtxclient/default.nix b/pkgs/development/libraries/mtxclient/default.nix
index 3ab1e0a7974..ef8525cf54d 100644
--- a/pkgs/development/libraries/mtxclient/default.nix
+++ b/pkgs/development/libraries/mtxclient/default.nix
@@ -1,39 +1,35 @@
 { stdenv, fetchFromGitHub, fetchpatch, cmake, pkgconfig
-, boost, openssl, zlib, libsodium, olm, gtest, spdlog, nlohmann_json }:
+, boost, openssl, zlib, libsodium, olm, nlohmann_json }:
 
 stdenv.mkDerivation rec {
   name = "mtxclient-${version}";
-  version = "0.2.0";
+  version = "0.2.1";
 
   src = fetchFromGitHub {
-    owner = "mujx";
+    owner = "Nheko-Reborn";
     repo = "mtxclient";
     rev = "v${version}";
-    sha256 = "19v1qa6mzvc65m7wy7x0g4i24bcg9xk31y1grwvd3zr0l4v6xcgs";
+    sha256 = "0pycznrvj57ff6gbwfn1xj943d2dr4vadl79hii1z16gn0nzxpmj";
   };
 
-  patches = [
-    # remove on the next mtxclient update
-    (fetchpatch {
-      url = "https://github.com/Nheko-Reborn/mtxclient/commit/41314809da7eb17ec00cff1795af6a528c5e904a.diff";
-      sha256 = "17pzrkdhd4jr8xwd7hhyzak880k8yb9nkg3vcbyjfp5si89dha5j";
-    })
+  cmakeFlags = [
+    "-DBUILD_LIB_TESTS=OFF"
+    "-DBUILD_LIB_EXAMPLES=OFF"
+    "-Dnlohmann_json_DIR=${nlohmann_json}/lib/cmake/nlohmann_json"
   ];
 
-  postPatch = ''
-    ln -s ${nlohmann_json}/include/nlohmann/json.hpp include/json.hpp
-  '';
-
-  cmakeFlags = [ "-DBUILD_LIB_TESTS=OFF" "-DBUILD_LIB_EXAMPLES=OFF" ];
-
   nativeBuildInputs = [ cmake pkgconfig ];
   buildInputs = [ boost openssl zlib libsodium olm ];
 
   meta = with stdenv.lib; {
     description = "Client API library for Matrix, built on top of Boost.Asio";
-    homepage = https://github.com/mujx/mtxclient;
+    homepage = https://github.com/Nheko-Reborn/mtxclient;
     license = licenses.mit;
     maintainers = with maintainers; [ fpletz ];
     platforms = platforms.unix;
+
+    # As of 2019-06-30, all of the dependencies are available on macOS but the
+    # package itself does not build.
+    broken = stdenv.isDarwin;
   };
 }
diff --git a/pkgs/development/libraries/mumlib/default.nix b/pkgs/development/libraries/mumlib/default.nix
new file mode 100644
index 00000000000..7117599d15e
--- /dev/null
+++ b/pkgs/development/libraries/mumlib/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, lib, fetchFromGitHub, cmake, pkgconfig
+, boost, openssl, log4cpp, libopus, protobuf }:
+with lib; stdenv.mkDerivation rec {
+  pname = "mumlib";
+  version = "unstable-2018-12-12";
+
+  src = fetchFromGitHub {
+    owner = "slomkowski";
+    repo = "mumlib";
+    rev = "f91720de264c0ab5e02bb30deafc5c4b2c245eac";
+    sha256 = "0p29z8379dp2ra0420x8xjp4d3r2mf680lj38xmlc8npdzqjqjdp";
+  };
+
+  buildInputs = [ boost openssl libopus protobuf log4cpp ];
+  nativeBuildInputs = [ cmake pkgconfig ];
+  installPhase = ''
+    install -Dm555 libmumlib.so $out/lib/libmumlib.so
+    cp -a ../include $out
+  '';
+
+  meta = {
+    description = "Fairy simple Mumble library written in C++, using boost::asio asynchronous networking framework";
+    homepage = "https://github.com/slomkowski/mumlib";
+    maintainers = with maintainers; [ das_j ];
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/mutest/default.nix b/pkgs/development/libraries/mutest/default.nix
new file mode 100644
index 00000000000..b247706067e
--- /dev/null
+++ b/pkgs/development/libraries/mutest/default.nix
@@ -0,0 +1,34 @@
+{ stdenv
+, fetchFromGitHub
+, meson
+, ninja
+}:
+
+stdenv.mkDerivation rec {
+  pname = "mutest";
+  version = "unstable-2019-10-12";
+
+  outputs = [ "out" "dev" ];
+
+  src = fetchFromGitHub {
+    owner = "ebassi";
+    repo = "mutest";
+    rev = "822b5ddf07f957135ba39889d81e513d525b9b8e";
+    sha256 = "0a5fjdq9p0q5bibqngbbpd9lga0gzrv8yj5wgdfb8ylxzg0jph2p";
+  };
+
+  nativeBuildInputs = [
+    meson
+    ninja
+  ];
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://ebassi.github.io/mutest/mutest.md.html;
+    description = "A BDD testing framework for C, inspired by Mocha";
+    license = licenses.mit;
+    maintainers = with maintainers; [ jtojnar worldofpeace ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/nco/default.nix b/pkgs/development/libraries/nco/default.nix
index f801e25d91f..55e9f44eae3 100644
--- a/pkgs/development/libraries/nco/default.nix
+++ b/pkgs/development/libraries/nco/default.nix
@@ -1,17 +1,17 @@
-{ stdenv, fetchurl, netcdf, netcdfcxx4, gsl, udunits, antlr, which, curl }:
+{ stdenv, fetchurl, netcdf, netcdfcxx4, gsl, udunits, antlr, which, curl, flex }:
 
 stdenv.mkDerivation rec {
-  version = "4.5.5";
+  version = "4.8.1";
   name = "nco-${version}";
 
-  buildInputs = [ netcdf netcdfcxx4 gsl udunits antlr which curl ];
+  buildInputs = [ netcdf netcdfcxx4 gsl udunits antlr which curl flex ];
 
   src = fetchurl {
     url = "https://github.com/nco/nco/archive/${version}.tar.gz";
-    sha256 = "bc6f5b976fdfbdec51f2ebefa158fa54672442c2fd5f042ba884f9f32c2ad666";
+    sha256 = "0s1ww78p4cb2d9qkr4zs439x4xk3ndq6lv8ps677jrn28vnkzbnx";
   };
 
-  meta = { 
+  meta = {
     description = "NetCDF Operator toolkit";
     longDescription = "The NCO (netCDF Operator) toolkit manipulates and analyzes data stored in netCDF-accessible formats, including DAP, HDF4, and HDF5";
     homepage = http://nco.sourceforge.net/;
diff --git a/pkgs/development/libraries/nss/default.nix b/pkgs/development/libraries/nss/default.nix
index f3fc4caf315..b410686865f 100644
--- a/pkgs/development/libraries/nss/default.nix
+++ b/pkgs/development/libraries/nss/default.nix
@@ -5,7 +5,7 @@ let
     url = http://dev.gentoo.org/~polynomial-c/mozilla/nss-3.15.4-pem-support-20140109.patch.xz;
     sha256 = "10ibz6y0hknac15zr6dw4gv9nb5r5z9ym6gq18j3xqx7v7n3vpdw";
   };
-  version = "3.44";
+  version = "3.44.1";
   underscoreVersion = builtins.replaceStrings ["."] ["_"] version;
 
 in stdenv.mkDerivation rec {
@@ -14,7 +14,7 @@ in stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "mirror://mozilla/security/nss/releases/NSS_${underscoreVersion}_RTM/src/${name}.tar.gz";
-    sha256 = "1zvabgxlyvz3fnv4w89y4a5qkscjmm88naf929dgvvgfnrchwqm5";
+    sha256 = "1y0jvva4s3j7cjz22kqw2lsml0an1295bgpc2raf7kc9r60cpr7w";
   };
 
   depsBuildBuild = [ buildPackages.stdenv.cc ];
diff --git a/pkgs/development/libraries/nss_wrapper/default.nix b/pkgs/development/libraries/nss_wrapper/default.nix
index e165f037be6..79eb4d1e10e 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.1.5";
+  name = "nss_wrapper-1.1.6";
 
   src = fetchurl {
     url = "mirror://samba/cwrap/${name}.tar.gz";
-    sha256 = "0srk7hffhkwl811q4pjy0n0gm8rh26akb2bh6avcpbns0zzn9ldn";
+    sha256 = "1hijnwabj4nh0m0a913pq07iqq0bw8qb2zxcv73zbnsaay7pa55h";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/nsss/default.nix b/pkgs/development/libraries/nsss/default.nix
index f503799e6b1..cd1205e2c7d 100644
--- a/pkgs/development/libraries/nsss/default.nix
+++ b/pkgs/development/libraries/nsss/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, skawarePackages }:
+{ skawarePackages }:
 
 with skawarePackages;
 
diff --git a/pkgs/development/libraries/nuspell/default.nix b/pkgs/development/libraries/nuspell/default.nix
index b667dea8d49..91318c802d8 100644
--- a/pkgs/development/libraries/nuspell/default.nix
+++ b/pkgs/development/libraries/nuspell/default.nix
@@ -1,19 +1,21 @@
-{ stdenv, fetchFromGitHub, cmake, pkgconfig, boost, icu, catch2 }:
+{ stdenv, fetchFromGitHub, cmake, pkgconfig, boost, icu, catch2, ronn }:
 
 stdenv.mkDerivation rec {
   name = "nuspell-${version}";
-  version = "2.2.0";
+  version = "2.3.0";
 
   src = fetchFromGitHub {
     owner = "nuspell";
     repo = "nuspell";
     rev = "v${version}";
-    sha256 = "17khkb1sxn1p6rfql72l7a4lxafbxj0dwi95hsmyi6wajvfrg9sy";
+    sha256 = "0n5cajrp1fhk8p54ch3akkd9nl8b9c6wwf25980dhagcdys3vab3";
   };
 
-  nativeBuildInputs = [ cmake pkgconfig ];
+  nativeBuildInputs = [ cmake pkgconfig ronn ];
   buildInputs = [ boost icu ];
 
+  outputs = [ "out" "lib" "dev" "man" ];
+
   enableParallelBuilding = true;
 
   postPatch = ''
@@ -21,6 +23,10 @@ stdenv.mkDerivation rec {
     ln -sf ${catch2.src} external/Catch2
   '';
 
+  postInstall = ''
+    rm -rf $out/share/doc
+  '';
+
   meta = with stdenv.lib; {
     description = "Free and open source C++ spell checking library";
     homepage = "https://nuspell.github.io/";
diff --git a/pkgs/development/libraries/odpic/default.nix b/pkgs/development/libraries/odpic/default.nix
index 931ecc186be..f3e8742bb20 100644
--- a/pkgs/development/libraries/odpic/default.nix
+++ b/pkgs/development/libraries/odpic/default.nix
@@ -1,12 +1,19 @@
-{ stdenv, fetchurl, fixDarwinDylibNames, oracle-instantclient, libaio }:
+{ stdenv, fetchFromGitHub, fixDarwinDylibNames, oracle-instantclient, libaio }:
 
-stdenv.mkDerivation rec {
-  name = "odpic-${version}";
-  version = "3.1.0";
+let
+  version = "3.2.1";
+  libPath = stdenv.lib.makeLibraryPath [ oracle-instantclient.lib ];
 
-  src = fetchurl {
-    url = "https://github.com/oracle/odpi/archive/v${version}.tar.gz";
-    sha256 = "0m6g7lbvfir4amf2cnap9wz9fmqrihqpihd84igrd7fp076894c0";
+in stdenv.mkDerivation {
+  inherit version;
+
+  pname = "odpic";
+
+  src = fetchFromGitHub {
+    owner = "oracle";
+    repo = "odpi";
+    rev = "v${version}";
+    sha256 = "1f9gznc7h73cgx32p55rkhzla6l7l9dg53ilwh6zdgdqlp7n018i";
   };
 
   nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin [ fixDarwinDylibNames ];
@@ -14,15 +21,12 @@ stdenv.mkDerivation rec {
   buildInputs = [ oracle-instantclient ]
     ++ stdenv.lib.optionals stdenv.isLinux [ libaio ];
 
-  libPath = stdenv.lib.makeLibraryPath
-    [ oracle-instantclient ];
-
   dontPatchELF = true;
   makeFlags = [ "PREFIX=$(out)" "CC=cc" "LD=cc"];
 
   postFixup = ''
     ${stdenv.lib.optionalString (stdenv.isLinux) ''
-      patchelf --set-rpath "${libPath}" $out/lib/libodpic${stdenv.hostPlatform.extensions.sharedLibrary}
+      patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $out/lib/libodpic${stdenv.hostPlatform.extensions.sharedLibrary})" $out/lib/libodpic${stdenv.hostPlatform.extensions.sharedLibrary}
     ''}
     ${stdenv.lib.optionalString (stdenv.isDarwin) ''
       install_name_tool -add_rpath "${libPath}" $out/lib/libodpic${stdenv.hostPlatform.extensions.sharedLibrary}
diff --git a/pkgs/development/libraries/ogre/default.nix b/pkgs/development/libraries/ogre/default.nix
index a6de278a7a7..f1b6060e166 100644
--- a/pkgs/development/libraries/ogre/default.nix
+++ b/pkgs/development/libraries/ogre/default.nix
@@ -11,11 +11,11 @@
 
 stdenv.mkDerivation rec {
   name = "ogre-${version}";
-  version = "1.12.0";
+  version = "1.12.1";
 
   src = fetchurl {
      url = "https://github.com/OGRECave/ogre/archive/v${version}.zip";
-     sha256 = "1hkkg5prixppiq1p5jz7wz1npm5s7kwm1s86079280waccvr2v6x";
+     sha256 = "1iv6k0dwdzg5nnzw2mcgcl663q4f7p2kj7nhs8afnsikrzxxgsi4";
   };
 
   cmakeFlags = [ "-DOGRE_BUILD_SAMPLES=${toString withSamples}" ]
diff --git a/pkgs/development/libraries/olm/default.nix b/pkgs/development/libraries/olm/default.nix
index 4749efb5f00..49daff30e7b 100644
--- a/pkgs/development/libraries/olm/default.nix
+++ b/pkgs/development/libraries/olm/default.nix
@@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
     description = "Implements double cryptographic ratchet and Megolm ratchet";
     license = stdenv.lib.licenses.asl20;
     homepage = https://matrix.org/git/olm/about;
-    platforms = stdenv.lib.platforms.linux;
+    platforms = with stdenv.lib.platforms; darwin ++ linux;
   };
 
   src = fetchurl {
@@ -22,5 +22,7 @@ stdenv.mkDerivation rec {
   # requires optimisation but memory operations are compiled with -O0
   hardeningDisable = ["fortify"];
 
+  makeFlags = if stdenv.cc.isClang then [ "CC=cc" ] else null;
+
   installFlags = "PREFIX=$(out)";
 }
diff --git a/pkgs/development/libraries/oniguruma/default.nix b/pkgs/development/libraries/oniguruma/default.nix
index b54f34fbb2c..e64d21c87ed 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.9.2";
+  version = "6.9.3";
 
   src = fetchFromGitHub {
     owner = "kkos";
     repo = "oniguruma";
     rev = "v${version}";
-    sha256 = "15asc9v6ylal8fwzlnrh673mp62wngxvv9jx7h86vhljjdap6yfc";
+    sha256 = "0wzmqpjmxpryk83acbyhl9gwgm43ixbwraga2g5li9kx88mv4k0n";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/openbsm/default.nix b/pkgs/development/libraries/openbsm/default.nix
index 13666542528..2b2fc3ff4d5 100644
--- a/pkgs/development/libraries/openbsm/default.nix
+++ b/pkgs/development/libraries/openbsm/default.nix
@@ -14,6 +14,8 @@ stdenv.mkDerivation rec {
 
   patches = lib.optional stdenv.isDarwin [ ./bsm-add-audit_token_to_pid.patch ];
 
+  configureFlags = [ "ac_cv_file__usr_include_mach_audit_triggers_defs=no" ];
+
   meta = {
     homepage = http://www.openbsm.org/;
     platforms = lib.platforms.unix;
diff --git a/pkgs/development/libraries/opencascade-occt/default.nix b/pkgs/development/libraries/opencascade-occt/default.nix
index 2d1e0ffb200..83b1cfc2add 100644
--- a/pkgs/development/libraries/opencascade-occt/default.nix
+++ b/pkgs/development/libraries/opencascade-occt/default.nix
@@ -1,22 +1,10 @@
-{ stdenv
-, fetchurl
-, cmake
-, tcl
-, tk
-, vtk
-, mesa_glu
-, libXext
-, libXmu
-, libXi
-, doxygen
-}:
+{ stdenv, fetchurl, fetchpatch, cmake, ninja, tcl, tk,
+  libGL, libGLU, libXext, libXmu, libXi }:
 
-let version = "7.3.0p3";
-    commit = "V${builtins.replaceStrings ["."] ["_"] version}";
-
-in stdenv.mkDerivation {
-
-  name = "opencascade-occt-${version}";
+stdenv.mkDerivation rec {
+  pname = "opencascade-occt";
+  version = "7.3.0p3";
+  commit = "V${builtins.replaceStrings ["."] ["_"] version}";
 
   src = fetchurl {
     name = "occt-${commit}.tar.gz";
@@ -24,10 +12,8 @@ in stdenv.mkDerivation {
     sha256 = "0k9c3ypcnjcilq1dhsf6xxbd52gyq4h5rchvp30k3c8ph4ris5pz";
   };
 
-  nativeBuildInputs = [ cmake ];
-  buildInputs = [ tcl tk vtk mesa_glu libXext libXmu libXi doxygen ];
-
-  enableParallelBuilding = true;
+  nativeBuildInputs = [ cmake ninja ];
+  buildInputs = [ tcl tk libGL libGLU libXext libXmu libXi ];
 
   meta = with stdenv.lib; {
     description = "Open CASCADE Technology, libraries for 3D modeling and numerical simulation";
diff --git a/pkgs/development/libraries/opencollada/default.nix b/pkgs/development/libraries/opencollada/default.nix
index d3e1482feb4..cd3da4a7960 100644
--- a/pkgs/development/libraries/opencollada/default.nix
+++ b/pkgs/development/libraries/opencollada/default.nix
@@ -4,13 +4,13 @@
 stdenv.mkDerivation rec {
   name = "opencollada-${version}";
 
-  version = "1.6.67";
+  version = "1.6.68";
 
   src = fetchFromGitHub {
     owner = "KhronosGroup";
     repo = "OpenCOLLADA";
     rev = "v${version}";
-    sha256 = "0x1h2ns0y05bdvn3i5s600jz6nb8qw8qqgg54njz7833bcy913mj";
+    sha256 = "1ym16fxx9qhf952vva71sdzgbm7ifis0h1n5fj1bfdj8zvvkbw5w";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/opencv/3.x.nix b/pkgs/development/libraries/opencv/3.x.nix
index b0652176c94..d5dc716c4a8 100644
--- a/pkgs/development/libraries/opencv/3.x.nix
+++ b/pkgs/development/libraries/opencv/3.x.nix
@@ -1,7 +1,7 @@
 { lib, stdenv
-, fetchurl, fetchFromGitHub, fetchpatch
+, fetchFromGitHub, fetchpatch
 , cmake, pkgconfig, unzip, zlib, pcre, hdf5
-, glog, boost, google-gflags, protobuf
+, glog, boost, gflags, protobuf
 , config
 
 , enableJPEG      ? true, libjpeg
@@ -31,24 +31,24 @@
 , enableDC1394    ? false, libdc1394
 , enableDocs      ? false, doxygen, graphviz-nox
 
-, cf-private, AVFoundation, Cocoa, VideoDecodeAcceleration, bzip2
+, AVFoundation, Cocoa, VideoDecodeAcceleration, bzip2
 }:
 
 let
-  version = "3.4.6";
+  version = "3.4.7";
 
   src = fetchFromGitHub {
     owner  = "opencv";
     repo   = "opencv";
     rev    = version;
-    sha256 = "1gf0rbgd5s13q46bdna0bqn4yz9rxfhvlhbp5ds9hs326q8zprg8";
+    sha256 = "0r5rrcnqx2lsnr1ja5ij2chb7yk9kkamr4p0ik52sqxydwkv3z50";
   };
 
   contribSrc = fetchFromGitHub {
     owner  = "opencv";
     repo   = "opencv_contrib";
     rev    = version;
-    sha256 = "115qcq0k2wmvhxw5lyv14yrd8m6xq3qy0pdby90ml2yl1caymbfy";
+    sha256 = "1ik6acsmgrx66awf19r2y3ijqvv9xg43gaphwszbiyi0jq3r43yw";
   };
 
   # Contrib must be built in order to enable Tesseract support:
@@ -61,16 +61,16 @@ let
     src = fetchFromGitHub {
       owner  = "opencv";
       repo   = "opencv_3rdparty";
-      rev    = "bdb7bb85f34a8cb0d35e40a81f58da431aa1557a";
-      sha256 = "1ys9mshfpm8iy8h4ml792gnqrq959dsrcv26axx14niivxyjbji8";
+      rev    = "32e315a5b106a7b89dbed51c28f8120a48b368b4";
+      sha256 = "19w9f0r16072s59diqxsr5q6nmwyz9gnxjs49nglzhd66p3ddbkp";
     } + "/ippicv";
-    files = let name = platform : "ippicv_2017u3_${platform}_general_20180518.tgz"; in
+    files = let name = platform : "ippicv_2019_${platform}_general_20180723.tgz"; in
       if stdenv.hostPlatform.system == "x86_64-linux" then
-      { ${name "lnx_intel64"} = "b7cc351267db2d34b9efa1cd22ff0572"; }
+      { ${name "lnx_intel64"} = "c0bd78adb4156bbf552c1dfe90599607"; }
       else if stdenv.hostPlatform.system == "i686-linux" then
-      { ${name "lnx_ia32"}    = "ea72de74dae3c604eb6348395366e78e"; }
+      { ${name "lnx_ia32"}    = "4f38432c30bfd6423164b7a24bbc98a0"; }
       else if stdenv.hostPlatform.system == "x86_64-darwin" then
-      { ${name "mac_intel64"} = "3ae52b9be0fe73dd45bc5e9429cd3732"; }
+      { ${name "mac_intel64"} = "fe6b2bb75ae0e3f19ad3ae1a31dfa4a2"; }
       else
       throw "ICV is not available for this platform (or not yet supported by this package)";
     dst = ".cache/ippicv";
@@ -147,12 +147,6 @@ stdenv.mkDerivation rec {
     cp --no-preserve=mode -r "${contribSrc}/modules" "$NIX_BUILD_TOP/opencv_contrib"
   '';
 
-  patches = lib.optional stdenv.isDarwin
-    (fetchpatch {
-      url = "https://github.com/opencv/opencv/commit/7621b91769098359e893e68ad474040ca7940fa1.patch";
-      sha256 = "12qb14yd5934ig61lzs4pg29gak9wjyhnj7nmfx5r213jj1a4m21";
-    });
-
   # This prevents cmake from using libraries in impure paths (which
   # causes build failure on non NixOS)
   # Also, work around https://github.com/NixOS/nixpkgs/issues/26304 with
@@ -179,7 +173,7 @@ stdenv.mkDerivation rec {
   '';
 
   buildInputs =
-       [ zlib pcre hdf5 glog boost google-gflags ]
+       [ zlib pcre hdf5 glog boost gflags ]
     ++ lib.optional useSystemProtobuf protobuf
     ++ lib.optional enablePython pythonPackages.python
     ++ lib.optional enableGtk2 gtk2
@@ -206,7 +200,7 @@ stdenv.mkDerivation rec {
     ++ lib.optionals enableTesseract [ tesseract leptonica ]
     ++ lib.optional enableTbb tbb
     ++ lib.optional enableCuda cudatoolkit
-    ++ lib.optionals stdenv.isDarwin [ cf-private AVFoundation Cocoa VideoDecodeAcceleration bzip2 ]
+    ++ lib.optionals stdenv.isDarwin [ bzip2 AVFoundation Cocoa VideoDecodeAcceleration ]
     ++ lib.optionals enableDocs [ doxygen graphviz-nox ];
 
   propagatedBuildInputs = lib.optional enablePython pythonPackages.numpy;
@@ -246,6 +240,9 @@ stdenv.mkDerivation rec {
     "-DBUILD_opencv_videoio=OFF"
   ] ++ lib.optionals enablePython [
     "-DOPENCV_SKIP_PYTHON_LOADER=ON"
+  ] ++ lib.optional enableEigen [
+    # Autodetection broken by https://github.com/opencv/opencv/pull/13337
+    "-DEIGEN_INCLUDE_PATH=${eigen}/include/eigen3"
   ];
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/opencv/4.x.nix b/pkgs/development/libraries/opencv/4.x.nix
index b4ad2bcb867..3fdc392e92b 100644
--- a/pkgs/development/libraries/opencv/4.x.nix
+++ b/pkgs/development/libraries/opencv/4.x.nix
@@ -1,7 +1,7 @@
 { lib, stdenv
-, fetchurl, fetchFromGitHub
+, fetchurl, fetchFromGitHub, fetchpatch
 , cmake, pkgconfig, unzip, zlib, pcre, hdf5
-, glog, boost, google-gflags, protobuf
+, glog, boost, gflags, protobuf
 , config
 
 , enableJPEG      ? true, libjpeg
@@ -31,7 +31,7 @@
 , enableDC1394    ? false, libdc1394
 , enableDocs      ? false, doxygen, graphviz-nox
 
-, cf-private, AVFoundation, Cocoa, VideoDecodeAcceleration, bzip2
+, AVFoundation, Cocoa, VideoDecodeAcceleration, bzip2
 }:
 
 let
@@ -160,6 +160,14 @@ stdenv.mkDerivation rec {
     cp --no-preserve=mode -r "${contribSrc}/modules" "$NIX_BUILD_TOP/source/opencv_contrib"
   '';
 
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/opencv/opencv/commit/5691d998ead1d9b0542bcfced36c2dceb3a59023.patch";
+      name = "CVE-2019-14493.patch";
+      sha256 = "14qva9f5z10apz5q0skdyiclr9sgkhab4fzksy1w3b6j6hg4wm7m";
+    })
+  ];
+
   # This prevents cmake from using libraries in impure paths (which
   # causes build failure on non NixOS)
   # Also, work around https://github.com/NixOS/nixpkgs/issues/26304 with
@@ -187,7 +195,7 @@ stdenv.mkDerivation rec {
   '';
 
   buildInputs =
-       [ zlib pcre hdf5 glog boost google-gflags protobuf ]
+       [ zlib pcre hdf5 glog boost gflags protobuf ]
     ++ lib.optional enablePython pythonPackages.python
     ++ lib.optional enableGtk2 gtk2
     ++ lib.optional enableGtk3 gtk3
@@ -213,7 +221,7 @@ stdenv.mkDerivation rec {
     ++ lib.optionals enableTesseract [ tesseract leptonica ]
     ++ lib.optional enableTbb tbb
     ++ lib.optional enableCuda cudatoolkit
-    ++ lib.optionals stdenv.isDarwin [ cf-private AVFoundation Cocoa VideoDecodeAcceleration bzip2 ]
+    ++ lib.optionals stdenv.isDarwin [ bzip2 AVFoundation Cocoa VideoDecodeAcceleration ]
     ++ lib.optionals enableDocs [ doxygen graphviz-nox ];
 
   propagatedBuildInputs = lib.optional enablePython pythonPackages.numpy;
diff --git a/pkgs/development/libraries/opencv/default.nix b/pkgs/development/libraries/opencv/default.nix
index 123b8807a74..784071c6e4d 100644
--- a/pkgs/development/libraries/opencv/default.nix
+++ b/pkgs/development/libraries/opencv/default.nix
@@ -10,7 +10,7 @@
 , enableFfmpeg ? false, ffmpeg
 , enableGStreamer ? false, gst_all_1
 , enableEigen ? true, eigen
-, cf-private, Cocoa, QTKit
+, Cocoa, QTKit
 }:
 
 let
@@ -54,7 +54,7 @@ stdenv.mkDerivation rec {
     ++ lib.optional enableFfmpeg ffmpeg
     ++ lib.optionals enableGStreamer (with gst_all_1; [ gstreamer gst-plugins-base ])
     ++ lib.optional enableEigen eigen
-    ++ lib.optionals stdenv.isDarwin [ Cocoa QTKit cf-private /* For NSDefaultRunLoopMode */ ]
+    ++ lib.optionals stdenv.isDarwin [ Cocoa QTKit ]
     ;
 
   propagatedBuildInputs = lib.optional enablePython pythonPackages.numpy;
diff --git a/pkgs/development/libraries/opendkim/default.nix b/pkgs/development/libraries/opendkim/default.nix
index 3d110910b15..71885ba46f1 100644
--- a/pkgs/development/libraries/opendkim/default.nix
+++ b/pkgs/development/libraries/opendkim/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, pkgconfig, libbsd, openssl, libmilter
-, perl, makeWrapper }:
+, autoreconfHook, perl, makeWrapper }:
 
 stdenv.mkDerivation rec {
   name = "opendkim-${version}";
@@ -16,10 +16,12 @@ stdenv.mkDerivation rec {
     "ac_cv_func_realloc_0_nonnull=yes"
   ];
 
-  nativeBuildInputs = [ pkgconfig makeWrapper ];
+  nativeBuildInputs = [ autoreconfHook pkgconfig makeWrapper ];
 
   buildInputs = [ libbsd openssl libmilter perl ];
 
+  patches = [ ./openssl-1.1.patch ];
+
   postInstall = ''
     wrapProgram $out/sbin/opendkim-genkey \
       --prefix PATH : ${openssl.bin}/bin
diff --git a/pkgs/development/libraries/opendkim/openssl-1.1.patch b/pkgs/development/libraries/opendkim/openssl-1.1.patch
new file mode 100644
index 00000000000..c36559cf16c
--- /dev/null
+++ b/pkgs/development/libraries/opendkim/openssl-1.1.patch
@@ -0,0 +1,81 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -864,26 +864,28 @@
+ 	AC_SEARCH_LIBS([ERR_peek_error], [crypto], ,
+ 	               AC_MSG_ERROR([libcrypto not found]))
+ 
+-	AC_SEARCH_LIBS([SSL_library_init], [ssl], ,
+-		[
+-			if test x"$enable_shared" = x"yes"
+-			then
+-				AC_MSG_ERROR([Cannot build shared opendkim
+-				              against static openssl libraries.
+-				              Configure with --disable-shared
+-				              to get this working or obtain a
+-				              shared libssl library for
+-				              opendkim to use.])
+-			fi
+-
+-			# avoid caching issue - last result of SSL_library_init
+-			# shouldn't be cached for this next check
+-			unset ac_cv_search_SSL_library_init
+-			LIBCRYPTO_LIBS="$LIBCRYPTO_LIBS -ldl"
+-			AC_SEARCH_LIBS([SSL_library_init], [ssl], ,
+-			               AC_MSG_ERROR([libssl not found]), [-ldl])
+-		]
+-	)
++
++	AC_LINK_IFELSE(
++		       [AC_LANG_PROGRAM([[#include <openssl/ssl.h>]],
++					[[SSL_library_init();]])],
++					[od_have_ossl="yes";],
++					[od_have_ossl="no";])
++	if test x"$od_have_ossl" = x"no"
++	then
++		if test x"$enable_shared" = x"yes"
++		then
++			AC_MSG_ERROR([Cannot build shared opendkim
++			              against static openssl libraries.
++			              Configure with --disable-shared
++			              to get this working or obtain a
++			              shared libssl library for
++			              opendkim to use.])
++		fi
++
++		LIBCRYPTO_LIBS="$LIBCRYPTO_LIBS -ldl"
++		AC_SEARCH_LIBS([SSL_library_init], [ssl], ,
++		               AC_MSG_ERROR([libssl not found]), [-ldl])
++	fi
+ 
+ 	AC_CHECK_DECL([SHA256_DIGEST_LENGTH],
+                       AC_DEFINE([HAVE_SHA256], 1,
+--- a/opendkim/opendkim-crypto.c
++++ b/opendkim/opendkim-crypto.c
+@@ -222,7 +222,11 @@
+ 	{
+ 		assert(pthread_setspecific(id_key, ptr) == 0);
+ 
++#if OPENSSL_VERSION_NUMBER >= 0x10100000
++		OPENSSL_thread_stop();
++#else
+ 		ERR_remove_state(0);
++#endif
+ 
+ 		free(ptr);
+ 
+@@ -392,11 +396,15 @@
+ {
+ 	if (crypto_init_done)
+ 	{
++#if OPENSSL_VERSION_NUMBER >= 0x10100000
++		OPENSSL_thread_stop();
++#else
+ 		CRYPTO_cleanup_all_ex_data();
+ 		CONF_modules_free();
+ 		EVP_cleanup();
+ 		ERR_free_strings();
+ 		ERR_remove_state(0);
++#endif
+ 
+ 		if (nmutexes > 0)
+ 		{
diff --git a/pkgs/development/libraries/openexr/default.nix b/pkgs/development/libraries/openexr/default.nix
index 54b617fdc01..072848d7bbc 100644
--- a/pkgs/development/libraries/openexr/default.nix
+++ b/pkgs/development/libraries/openexr/default.nix
@@ -48,7 +48,7 @@ stdenv.mkDerivation rec {
   doCheck = false; # fails 1 of 1 tests
 
   meta = with stdenv.lib; {
-    homepage = http://www.openexr.com/;
+    homepage = https://www.openexr.com/;
     license = licenses.bsd3;
     platforms = platforms.all;
   };
diff --git a/pkgs/development/libraries/openjpeg/1.x.nix b/pkgs/development/libraries/openjpeg/1.x.nix
index dfa5605dec8..2a625f32e7f 100644
--- a/pkgs/development/libraries/openjpeg/1.x.nix
+++ b/pkgs/development/libraries/openjpeg/1.x.nix
@@ -5,4 +5,5 @@ callPackage ./generic.nix (args // rec {
   branch = "1.5";
   revision = "version.1.5.2";
   sha256 = "1dvvpvb597i5z8srz2v4c5dsbxb966h125jx3m2z0r2gd2wvpfkp";
+  testsSupport = false;
 })
diff --git a/pkgs/development/libraries/openjpeg/2.x.nix b/pkgs/development/libraries/openjpeg/2.x.nix
index e865e2e8549..24f3752ef43 100644
--- a/pkgs/development/libraries/openjpeg/2.x.nix
+++ b/pkgs/development/libraries/openjpeg/2.x.nix
@@ -13,5 +13,15 @@ callPackage ./generic.nix (args // rec {
 
   patches = [
     ./fix-cmake-config-includedir.patch
+    (fetchpatch {
+      url = "https://github.com/uclouvain/openjpeg/commit/21399f6b7d318fcdf4406d5e88723c4922202aa3.patch";
+      name = "CVE-2019-12973-1.patch";
+      sha256 = "161yvnfbzy2016qqapm0ywfgglgs1v8ljnk6fj8d2bwdh1cxxz8f";
+    })
+    (fetchpatch {
+      url = "https://github.com/uclouvain/openjpeg/commit/3aef207f90e937d4931daf6d411e092f76d82e66.patch";
+      name = "CVE-2019-12973-2.patch";
+      sha256 = "1jkkfw13l7nx4hxdhc7z17f4vfgqcaf09zpl235kypbxx1ygc7vq";
+    })
   ];
 })
diff --git a/pkgs/development/libraries/openjpeg/generic.nix b/pkgs/development/libraries/openjpeg/generic.nix
index d3130a64b03..e26f4160921 100644
--- a/pkgs/development/libraries/openjpeg/generic.nix
+++ b/pkgs/development/libraries/openjpeg/generic.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchFromGitHub, cmake, pkgconfig
-, libpng, libtiff, lcms2
+, libpng, libtiff, lcms2, jpylyzer
 , mj2Support ? true # MJ2 executables
 , jpwlLibSupport ? true # JPWL library & executables
 , jpipLibSupport ? false # JPIP library & executables
@@ -8,7 +8,7 @@
 , openjpegJarSupport ? false # Openjpeg jar (Java)
 , jp3dSupport ? true # # JP3D comp
 , thirdPartySupport ? false # Third party libraries - OFF: only build when found, ON: always build
-, testsSupport ? false
+, testsSupport ? true
 , jdk ? null
 # Inherit generics
 , branch, version, revision, sha256, patches ? [], extraFlags ? [], ...
@@ -62,6 +62,13 @@ stdenv.mkDerivation rec {
 
   propagatedBuildInputs = [ libpng libtiff lcms2 ];
 
+  doCheck = (testsSupport && !stdenv.isAarch64); # tests fail on aarch64-linux
+  checkPhase = ''
+    substituteInPlace ../tools/ctest_scripts/travis-ci.cmake \
+      --replace "JPYLYZER_EXECUTABLE=" "JPYLYZER_EXECUTABLE=\"${jpylyzer}/bin/jpylyzer\" # "
+    OPJ_SOURCE_DIR=.. ctest -S ../tools/ctest_scripts/travis-ci.cmake
+  '';
+
   passthru = {
     incDir = "openjpeg-${branch}";
   };
diff --git a/pkgs/development/libraries/openmpi/default.nix b/pkgs/development/libraries/openmpi/default.nix
index 1a0e589373c..760fc3e3232 100644
--- a/pkgs/development/libraries/openmpi/default.nix
+++ b/pkgs/development/libraries/openmpi/default.nix
@@ -15,16 +15,25 @@ in stdenv.mkDerivation rec {
   name = "openmpi-${version}";
 
   src = with stdenv.lib.versions; fetchurl {
-    url = "http://www.open-mpi.org/software/ompi/v${major version}.${minor version}/downloads/${name}.tar.bz2";
+    url = "https://www.open-mpi.org/software/ompi/v${major version}.${minor version}/downloads/${name}.tar.bz2";
     sha256 = "02cpzcp113gj5hb0j2xc0cqma2fn04i2i0bzf80r71120p9bdryc";
   };
 
+  patches = [
+    (fetchpatch {
+      name = "openmpi-mca_btl_vader_component_close-segfault.patch";
+      url = "https://github.com/open-mpi/ompi/pull/6526.patch";
+      sha256 = "0s7ac9rkcj3fi6ampkvy76njlj478yyr4zvypjc7licy6dgr595x";
+    })
+  ];
+
   postPatch = ''
     patchShebangs ./
   '';
 
   buildInputs = with stdenv; [ gfortran zlib ]
-    ++ lib.optionals isLinux [ libnl numactl libevent hwloc ]
+    ++ lib.optionals isLinux [ libnl numactl ]
+    ++ [ libevent hwloc ]
     ++ lib.optional (isLinux || isFreeBSD) rdma-core;
 
   nativeBuildInputs = [ perl ];
@@ -44,7 +53,7 @@ in stdenv.mkDerivation rec {
   doCheck = true;
 
   meta = with stdenv.lib; {
-    homepage = http://www.open-mpi.org/;
+    homepage = https://www.open-mpi.org/;
     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 ];
diff --git a/pkgs/development/libraries/opensaml-cpp/default.nix b/pkgs/development/libraries/opensaml-cpp/default.nix
index 659c4fb7cff..9488ef484c6 100644
--- a/pkgs/development/libraries/opensaml-cpp/default.nix
+++ b/pkgs/development/libraries/opensaml-cpp/default.nix
@@ -1,17 +1,21 @@
-{ stdenv, fetchgit, autoreconfHook, boost, openssl, log4shib, xercesc, xml-security-c, xml-tooling-c, zlib }:
+{ stdenv, fetchgit, autoreconfHook, pkgconfig
+, boost, openssl, log4shib, xercesc, xml-security-c, xml-tooling-c, zlib
+}:
 
 stdenv.mkDerivation rec {
   name = "opensaml-cpp-${version}";
-  version = "2.6.1";
+  version = "3.0.1";
 
   src = fetchgit {
     url = "https://git.shibboleth.net/git/cpp-opensaml.git";
     rev = version;
-    sha256 = "0wjb6jyvh4hwpy1pvhh63i821746nqijysrd4vasbirkf4h6z7nx";
+    sha256 = "0ms3sqmwqkrqb92d7jy2hqwnz5yd7cbrz73n321jik0jilrwl5w8";
   };
 
-  buildInputs = [ boost openssl log4shib xercesc xml-security-c xml-tooling-c zlib ];
-  nativeBuildInputs = [ autoreconfHook ];
+  buildInputs = [
+    boost openssl log4shib xercesc xml-security-c xml-tooling-c zlib
+  ];
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
 
   configureFlags = [ "--with-xmltooling=${xml-tooling-c}" ];
 
diff --git a/pkgs/development/libraries/openscenegraph/3.4.0.nix b/pkgs/development/libraries/openscenegraph/3.4.0.nix
deleted file mode 100644
index 8d083904189..00000000000
--- a/pkgs/development/libraries/openscenegraph/3.4.0.nix
+++ /dev/null
@@ -1,39 +0,0 @@
-{ stdenv, lib, fetchurl, cmake, pkgconfig, doxygen, unzip
-, freetype, libjpeg, jasper, libxml2, zlib, gdal, curl, libX11
-, cairo, poppler, librsvg, libpng, libtiff, libXrandr
-, xineLib, boost
-, withApps ? false
-, withSDL ? false, SDL
-, withQt4 ? false, qt4
-}:
-
-stdenv.mkDerivation rec {
-  name = "openscenegraph-${version}";
-  version = "3.4.0";
-
-  src = fetchurl {
-    url = "http://trac.openscenegraph.org/downloads/developer_releases/OpenSceneGraph-${version}.zip";
-    sha256 = "03h4wfqqk7rf3mpz0sa99gy715cwpala7964z2npd8jxfn27swjw";
-  };
-
-  nativeBuildInputs = [ pkgconfig cmake doxygen unzip ];
-
-  buildInputs = [
-    freetype libjpeg jasper libxml2 zlib gdal curl libX11
-    cairo poppler librsvg libpng libtiff libXrandr boost
-    xineLib
-  ] ++ lib.optional withSDL SDL
-    ++ lib.optional withQt4 qt4;
-
-  enableParallelBuilding = true;
-
-  cmakeFlags = lib.optional (!withApps) "-DBUILD_OSG_APPLICATIONS=OFF";
-
-  meta = with stdenv.lib; {
-    description = "A 3D graphics toolkit";
-    homepage = http://www.openscenegraph.org/;
-    maintainers = [ maintainers.raskin ];
-    platforms = platforms.linux;
-    license = "OpenSceneGraph Public License - free LGPL-based license";
-  };
-}
diff --git a/pkgs/development/libraries/openscenegraph/default.nix b/pkgs/development/libraries/openscenegraph/default.nix
index 9f5ef3ff68c..1398e829dd5 100644
--- a/pkgs/development/libraries/openscenegraph/default.nix
+++ b/pkgs/development/libraries/openscenegraph/default.nix
@@ -26,14 +26,14 @@
 }:
 
 stdenv.mkDerivation rec {
-  name = "openscenegraph-${version}";
-  version = "3.6.3";
+  pname = "openscenegraph";
+  version = "3.6.4";
 
   src = fetchFromGitHub {
     owner = "openscenegraph";
     repo = "OpenSceneGraph";
-    rev = "d011ca4e8d83549a3688bf6bb8cd468dd9684822";
-    sha256 = "0h32z15sa8sbq276j0iib0n707m8bs4p5ji9z2ah411446paad9q";
+    rev = "OpenSceneGraph-${version}";
+    sha256 = "0x8hdbzw0b71j91fzp9cwmy9a7ava8v8wwyj8nxijq942vdx1785";
   };
 
   nativeBuildInputs = [ pkgconfig cmake doxygen ];
@@ -64,14 +64,12 @@ stdenv.mkDerivation rec {
     ++ lib.optionals withExamples [ fltk wxGTK ]
   ;
 
-  enableParallelBuilding = true;
-
   cmakeFlags = lib.optional (!withApps) "-DBUILD_OSG_APPLICATIONS=OFF" ++ lib.optional withExamples "-DBUILD_OSG_EXAMPLES=ON";
 
   meta = with stdenv.lib; {
     description = "A 3D graphics toolkit";
     homepage = http://www.openscenegraph.org/;
-    maintainers = [ maintainers.raskin ];
+    maintainers = with maintainers; [ aanderse raskin ];
     platforms = platforms.linux;
     license = "OpenSceneGraph Public License - free LGPL-based license";
   };
diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix
index ef617a92eaa..67b903970d3 100644
--- a/pkgs/development/libraries/openssl/default.nix
+++ b/pkgs/development/libraries/openssl/default.nix
@@ -7,7 +7,7 @@
 with stdenv.lib;
 
 let
-  common = args@{ version, sha256, patches ? [], withDocs ? false }: stdenv.mkDerivation rec {
+  common = { version, sha256, patches ? [], withDocs ? false }: stdenv.mkDerivation rec {
     name = "openssl-${version}";
 
     src = fetchurl {
diff --git a/pkgs/development/libraries/opensubdiv/default.nix b/pkgs/development/libraries/opensubdiv/default.nix
index 57f1c9830a6..72e532ae782 100644
--- a/pkgs/development/libraries/opensubdiv/default.nix
+++ b/pkgs/development/libraries/opensubdiv/default.nix
@@ -6,13 +6,13 @@
 
 stdenv.mkDerivation rec {
   name = "opensubdiv-${version}";
-  version = "3.3.3";
+  version = "3.4.0";
 
   src = fetchFromGitHub {
     owner = "PixarAnimationStudios";
     repo = "OpenSubdiv";
     rev = "v${lib.replaceChars ["."] ["_"] version}";
-    sha256 = "1rld4hgl9yrbnk5sd6bhvnm8jdnqq09hq93hrmx0nhccccximi9z";
+    sha256 = "0cippg6aqc5dlya1cmh3908pwssrg52fwgyylnvz5343yrxmgk12";
   };
 
   outputs = [ "out" "dev" ];
diff --git a/pkgs/development/libraries/openvdb/default.nix b/pkgs/development/libraries/openvdb/default.nix
index aa8032c5280..af88172c57a 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 = "6.0.0";
+  version = "6.1.0";
 
   src = fetchFromGitHub {
     owner = "dreamworksanimation";
     repo = "openvdb";
     rev = "v${version}";
-    sha256 = "07m012a966l821f09jmrrhs25cs2rcmhlxcicywibllaac10wk5k";
+    sha256 = "0rs50741c4m0jgc7k2fdyinvm7hhjrbg0wls6whqaghbbaf1lhpk";
   };
 
   outputs = [ "out" ];
diff --git a/pkgs/development/libraries/openxr-loader/default.nix b/pkgs/development/libraries/openxr-loader/default.nix
new file mode 100644
index 00000000000..d1a20552ff7
--- /dev/null
+++ b/pkgs/development/libraries/openxr-loader/default.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchFromGitHub, cmake, python3, libX11, libXxf86vm, libXrandr }:
+
+stdenv.mkDerivation rec {
+  pname = "openxr-loader";
+  version = "1.0.1";
+
+  src = fetchFromGitHub {
+    owner = "KhronosGroup";
+    repo = "OpenXR-SDK-Source";
+    rev = "release-${version}";
+    sha256 = "1sif2w2vm793j6493364i6pp6s6yqi7fwa6iky5abzmzda51cg5q";
+  };
+
+  nativeBuildInputs = [ cmake python3 ];
+  buildInputs = [ libX11 libXxf86vm libXrandr ];
+  enableParallelBuilding = true;
+
+  cmakeFlags = [ "-DBUILD_TESTS=OFF" ];
+
+  outputs = [ "out" "dev" "layers" ];
+
+  postInstall = ''
+    mkdir -p "$layers/share"
+    mv "$out/share/openxr" "$layers/share"
+    # Use absolute paths in manifests so no LD_LIBRARY_PATH shenanigans are necessary
+    for file in "$layers/share/openxr/1/api_layers/explicit.d/"*; do
+        substituteInPlace "$file" --replace '"library_path": "lib' "\"library_path\": \"$layers/lib/lib"
+    done
+    mkdir -p "$layers/lib"
+    mv "$out/lib/libXrApiLayer"* "$layers/lib"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Khronos OpenXR loader";
+    homepage    = https://www.khronos.org/openxr;
+    platforms   = platforms.linux;
+    license     = licenses.asl20;
+    maintainers = [ maintainers.ralith ];
+  };
+}
diff --git a/pkgs/development/libraries/oracle-instantclient/default.nix b/pkgs/development/libraries/oracle-instantclient/default.nix
index fe260e0c2ad..06b9e360d1a 100644
--- a/pkgs/development/libraries/oracle-instantclient/default.nix
+++ b/pkgs/development/libraries/oracle-instantclient/default.nix
@@ -1,71 +1,126 @@
-{ stdenv, requireFile, autoPatchelfHook, fixDarwinDylibNames, unzip, libaio, makeWrapper, odbcSupport ? false, unixODBC }:
+{ stdenv
+, fetchurl
+, requireFile
+, autoPatchelfHook
+, fixDarwinDylibNames
+, unzip
+, libaio
+, makeWrapper
+, odbcSupport ? true
+, unixODBC
+}:
 
 assert odbcSupport -> unixODBC != null;
 
 let
   inherit (stdenv.lib) optional optionals optionalString;
 
-  baseVersion = "12.2";
-  version = "${baseVersion}.0.1.0";
+  throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
 
-  requireSource = component: arch: version: rel: hash: (requireFile rec {
-    name = "instantclient-${component}-${arch}-${version}" + (optionalString (rel != "") "-${rel}") + ".zip";
-    url = "http://www.oracle.com/technetwork/database/database-technologies/instant-client/downloads/index.html";
-    sha256 = hash;
-  });
+  # assemble list of components
+  components = [ "basic" "sdk" "sqlplus" ] ++ optional odbcSupport "odbc";
 
-  throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
+  # determine the version number, there might be different ones per architecture
+  version = {
+    "x86_64-linux" = "19.3.0.0.0";
+    "x86_64-darwin" = "18.1.0.0.0";
+  }."${stdenv.hostPlatform.system}" or throwSystem;
+
+  # hashes per component and architecture
+  hashes = {
+    "x86_64-linux" = {
+      "basic"   = "1yk4ng3a9ka1mzgfph9br6rwclagbgfvmg6kja11nl5dapxdzaxy";
+      "sdk"     = "115v1gqr0czy7dcf2idwxhc6ja5b0nind0mf1rn8iawgrw560l99";
+      "sqlplus" = "0zj5h84ypv4n4678kfix6jih9yakb277l9hc0819iddc0a5slbi5";
+      "odbc"    = "1g1z6pdn76dp440fh49pm8ijfgjazx4cvxdi665fsr62h62xkvch";
+    };
+    "x86_64-darwin" = {
+      "basic"   = "fac3cdaaee7526f6c50ff167edb4ba7ab68efb763de24f65f63fb48cc1ba44c0";
+      "sdk"     = "98e6d797f1ce11e59b042b232f62380cec29ec7d5387b88a9e074b741c13e63a";
+      "sqlplus" = "02e66dc52398fced75e7efcb6b4372afcf617f7d88344fb7f0f4bb2bed371f3b";
+      "odbc"    = "5d0cdd7f9dd2e27affbc9b36ef9fc48e329713ecd36905fdd089366e365ae8a2";
+    };
+  }."${stdenv.hostPlatform.system}" or throwSystem;
+
+  # rels per component and architecture, optional
+  rels = {
+    "x86_64-darwin" = {
+      "sdk" = "2";
+    };
+  }."${stdenv.hostPlatform.system}" or {};
 
+  # convert platform to oracle architecture names
   arch = {
     "x86_64-linux" = "linux.x64";
     "x86_64-darwin" = "macos.x64";
   }."${stdenv.hostPlatform.system}" or throwSystem;
 
-  srcs = {
-    "x86_64-linux" = [
-      (requireSource "basic" arch version "" "5015e3c9fba84e009f7519893f798a1622c37d1ae2c55104ff502c52a0fe5194")
-      (requireSource "sdk" arch version "" "7f404c3573c062ce487a51ac4cfe650c878d7edf8e73b364ec852645ed1098cb")
-      (requireSource "sqlplus" arch version "" "d49b2bd97376591ca07e7a836278933c3f251875c215044feac73ba9f451dfc2") ]
-      ++ optional odbcSupport (requireSource "odbc" arch version "2" "365a4ae32c7062d9fbc3fb41add748e7881f774484a175a4b41a2c294ce9095d");
-    "x86_64-darwin" = [
-      (requireSource "basic" arch version "2" "3ed3102e5a24f0da638694191edb34933309fb472eb1df21ad5c86eedac3ebb9")
-      (requireSource "sdk" arch version "2" "e0befca9c4e71ebc9f444957ffa70f01aeeec5976ea27c40406471b04c34848b")
-      (requireSource "sqlplus" arch version "2" "d147cbb5b2a954fdcb4b642df4f0bd1153fd56e0f56e7fa301601b4f7e2abe0e") ]
-      ++ optional odbcSupport (requireSource "odbc" arch version "2" "1805c1ab6c8c5e8df7bdcc35d7f2b94c329ecf4dff9bde55d5f9b159ecd8b64e");
-  }."${stdenv.hostPlatform.system}" or throwSystem;
+  # calculate the filename of a single zip file
+  srcFilename = component: arch: version: rel:
+    "instantclient-${component}-${arch}-${version}" +
+    (optionalString (rel != "") "-${rel}") +
+    (optionalString (arch == "linux.x64") "dbru") + # ¯\_(ツ)_/¯
+    ".zip";
+
+  # fetcher for the clickthrough artifacts (requiring manual download)
+  fetchClickThrough =  srcFilename: hash: (requireFile {
+    name = srcFilename;
+    url = "https://www.oracle.com/database/technologies/instant-client/downloads.html";
+    sha256 = hash;
+  });
 
+  # fetcher for the non clickthrough artifacts
+  fetchSimple = srcFilename: hash: fetchurl {
+    url = "https://download.oracle.com/otn_software/linux/instantclient/193000/${srcFilename}";
+    sha256 = hash;
+  };
+
+  # pick the appropriate fetcher depending on the platform
+  fetcher = if stdenv.hostPlatform.system == "x86_64-linux" then fetchSimple else fetchClickThrough;
+
+  # assemble srcs
+  srcs = map (component:
+    (fetcher (srcFilename component arch version rels."${component}" or "") hashes."${component}" or ""))
+  components;
+
+  pname = "oracle-instantclient";
   extLib = stdenv.hostPlatform.extensions.sharedLibrary;
-in stdenv.mkDerivation rec {
-  inherit version srcs;
-  name = "oracle-instantclient-${version}";
+in stdenv.mkDerivation {
+  inherit pname version srcs;
 
   buildInputs = [ stdenv.cc.cc.lib ]
-    ++ optionals (stdenv.isLinux) [ libaio ]
+    ++ optional stdenv.isLinux libaio
     ++ optional odbcSupport unixODBC;
 
   nativeBuildInputs = [ makeWrapper unzip ]
     ++ optional stdenv.isLinux autoPatchelfHook
     ++ optional stdenv.isDarwin fixDarwinDylibNames;
 
+  outputs = [ "out" "dev" "lib"];
+
   unpackCmd = "unzip $curSrc";
 
   installPhase = ''
-    mkdir -p "$out/"{bin,include,lib,"share/java","share/${name}/demo/"}
-    install -Dm755 {sqlplus,adrci,genezi} $out/bin
-    ${optionalString stdenv.isDarwin ''
-      for exe in "$out/bin/"* ; do
-        install_name_tool -add_rpath "$out/lib" "$exe"
-      done
-    ''}
-    ln -sfn $out/bin/sqlplus $out/bin/sqlplus64
-    install -Dm644 *${extLib}* $out/lib
+    mkdir -p "$out/"{bin,include,lib,"share/java","share/${pname}-${version}/demo/"} $lib/lib
+    install -Dm755 {adrci,genezi,uidrvci,sqlplus} $out/bin
+
+    # cp to preserve symlinks
+    cp -P *${extLib}* $lib/lib
+
     install -Dm644 *.jar $out/share/java
     install -Dm644 sdk/include/* $out/include
-    install -Dm644 sdk/demo/* $out/share/${name}/demo
+    install -Dm644 sdk/demo/* $out/share/${pname}-${version}/demo
+
+    # provide alias
+    ln -sfn $out/bin/sqlplus $out/bin/sqlplus64
+  '';
 
-    # PECL::oci8 will not build without this
-    # this symlink only exists in dist zipfiles for some platforms
-    ln -sfn $out/lib/libclntsh${extLib}.12.1 $out/lib/libclntsh${extLib}
+  postFixup = optionalString stdenv.isDarwin ''
+    for exe in "$out/bin/"* ; do
+      if [ ! -L "$exe" ]; then
+        install_name_tool -add_rpath "$lib/lib" "$exe"
+      fi
+    done
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/orcania/default.nix b/pkgs/development/libraries/orcania/default.nix
new file mode 100644
index 00000000000..6a7fd78d514
--- /dev/null
+++ b/pkgs/development/libraries/orcania/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchFromGitHub, cmake, check, subunit }:
+stdenv.mkDerivation rec {
+  pname = "orcania";
+  version = "2.0.1";
+
+  src = fetchFromGitHub {
+    owner = "babelouest";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "1kq1cpayflh4xy442q6prrkalm8lcz2cxydrp1fv8ppq1cnq4zr7";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  checkInputs = [ check subunit ];
+
+  cmakeFlags = [ "-DBUILD_ORCANIA_TESTING=on" ];
+
+  doCheck = true;
+
+  preCheck = ''
+    export LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH"
+    export DYLD_FALLBACK_LIBRARY_PATH="$(pwd):$DYLD_FALLBACK_LIBRARY_PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Potluck with different functions for different purposes that can be shared among C programs";
+    homepage = "https://github.com/babelouest/orcania";
+    license = licenses.lgpl21;
+    maintainers = with maintainers; [ johnazoidberg ];
+  };
+}
diff --git a/pkgs/development/libraries/packr/default.nix b/pkgs/development/libraries/packr/default.nix
new file mode 100644
index 00000000000..bc8133aaf82
--- /dev/null
+++ b/pkgs/development/libraries/packr/default.nix
@@ -0,0 +1,25 @@
+{ buildGoModule
+, fetchFromGitHub
+, lib
+}:
+
+buildGoModule rec {
+  pname = "packr";
+  version = "2.5.2";
+
+  src = fetchFromGitHub {
+    owner = "gobuffalo";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "1ciffa5xbd93fylwz93wr4m4fj83dcla55dmdshaqz28rbsapnc1";
+  };
+
+  modSha256 = "086gydrl3i35hawb5m7rsb4a0llcpdpgid1xfw2z9n6jkwkclw4n";
+
+  meta = with lib; {
+    description = "The simple and easy way to embed static files into Go binaries";
+    homepage = "https://github.com/gobuffalo/packr";
+    license = licenses.mit;
+    maintainers = with maintainers; [ mmahut ];
+  };
+}
diff --git a/pkgs/development/libraries/pagmo2/default.nix b/pkgs/development/libraries/pagmo2/default.nix
index 842fae5ea93..47c6a27639d 100644
--- a/pkgs/development/libraries/pagmo2/default.nix
+++ b/pkgs/development/libraries/pagmo2/default.nix
@@ -1,12 +1,10 @@
-{ lib
-, fetchFromGitHub
+{ fetchFromGitHub
 , stdenv
 , cmake
 , eigen
 , nlopt
 , ipopt
 , boost
-, writeText
 }:
 
 stdenv.mkDerivation rec {
diff --git a/pkgs/development/libraries/pcl/default.nix b/pkgs/development/libraries/pcl/default.nix
index 08a1613c2fe..33158129469 100644
--- a/pkgs/development/libraries/pcl/default.nix
+++ b/pkgs/development/libraries/pcl/default.nix
@@ -1,6 +1,6 @@
-{ stdenv, fetchFromGitHub, fetchpatch, cmake
+{ stdenv, fetchFromGitHub, cmake
 , qhull, flann, boost, vtk, eigen, pkgconfig, qtbase
-, libusb1, libpcap, libXt, libpng, Cocoa, AGL, cf-private, OpenGL
+, libusb1, libpcap, libXt, libpng, Cocoa, AGL, OpenGL
 }:
 
 stdenv.mkDerivation rec {
@@ -18,8 +18,8 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = [ pkgconfig cmake ];
   buildInputs = [ qhull flann boost eigen libusb1 libpcap
                   libpng vtk qtbase libXt ]
+    ++ stdenv.lib.optionals stdenv.isDarwin [ Cocoa AGL ];
 
-    ++ stdenv.lib.optionals stdenv.isDarwin [ Cocoa AGL cf-private ];
   cmakeFlags = stdenv.lib.optionals stdenv.isDarwin [
     "-DOPENGL_INCLUDE_DIR=${OpenGL}/Library/Frameworks"
   ];
diff --git a/pkgs/development/libraries/physics/apfel/default.nix b/pkgs/development/libraries/physics/apfel/default.nix
index 30b56afb8a9..d542c6cf1d7 100644
--- a/pkgs/development/libraries/physics/apfel/default.nix
+++ b/pkgs/development/libraries/physics/apfel/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "apfel-${version}";
-  version = "3.0.3";
+  version = "3.0.4";
 
   src = fetchFromGitHub {
     owner = "scarrazza";
     repo = "apfel";
     rev = version;
-    sha256 = "13dvcc5ba6djflrcy5zf5ikaw8s78zd8ac6ickc0hxhbmx1gjb4j";
+    sha256 = "13n5ygbqvskg3qq5n4sff1nbii0li0zf1vqissai7x0hynxgy7p6";
   };
 
   buildInputs = [ gfortran lhapdf python2 ];
diff --git a/pkgs/development/libraries/physics/geant4/default.nix b/pkgs/development/libraries/physics/geant4/default.nix
index 7123858b8ed..5f51c6a194c 100644
--- a/pkgs/development/libraries/physics/geant4/default.nix
+++ b/pkgs/development/libraries/physics/geant4/default.nix
@@ -68,7 +68,7 @@ stdenv.mkDerivation rec {
     ++ stdenv.lib.optionals enableGDML [ xercesc ]
     ++ stdenv.lib.optionals enableXM [ motif ]
     ++ stdenv.lib.optionals enableQT [ qtbase ]
-    ++ stdenv.lib.optionals enableInventor [ libXpm coin3d soxt ];
+    ++ stdenv.lib.optionals enableInventor [ libXpm coin3d soxt motif ];
 
   postFixup = ''
     # Don't try to export invalid environment variables.
diff --git a/pkgs/development/libraries/physics/geant4/g4py/default.nix b/pkgs/development/libraries/physics/geant4/g4py/default.nix
index f28f0fd6420..0b1f3f0490d 100644
--- a/pkgs/development/libraries/physics/geant4/g4py/default.nix
+++ b/pkgs/development/libraries/physics/geant4/g4py/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cmake, xercesc
+{ stdenv, cmake, xercesc
 
 # The target version of Geant4
 , geant4
diff --git a/pkgs/development/libraries/physics/hepmc/default.nix b/pkgs/development/libraries/physics/hepmc2/default.nix
index b935a3d56ea..d61a68ebe34 100644
--- a/pkgs/development/libraries/physics/hepmc/default.nix
+++ b/pkgs/development/libraries/physics/hepmc2/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "hepmc-${version}";
-  version = "2.06.09";
+  version = "2.06.10";
 
   src = fetchurl {
-    url = "http://lcgapp.cern.ch/project/simu/HepMC/download/HepMC-${version}.tar.gz";
-    sha256 = "020sc7hzy7d6d1i6bs352hdzy5zy5zxkc33cw0jhh8s0jz5281y6";
+    url = "http://hepmc.web.cern.ch/hepmc/releases/HepMC-${version}.tar.gz";
+    sha256 = "190i9jlnwz1xpc495y0xc70s4zdqb9s2zdq1zkjy2ivl7ygdvpjs";
   };
 
   patches = [ ./in_source.patch ];
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "The HepMC package is an object oriented event record written in C++ for High Energy Physics Monte Carlo Generators";
     license     = stdenv.lib.licenses.gpl2;
-    homepage    = http://lcgapp.cern.ch/project/simu/HepMC/;
+    homepage    = http://hepmc.web.cern.ch/hepmc/;
     platforms   = stdenv.lib.platforms.unix;
     maintainers = with stdenv.lib.maintainers; [ veprbl ];
   };
diff --git a/pkgs/development/libraries/physics/hepmc/in_source.patch b/pkgs/development/libraries/physics/hepmc2/in_source.patch
index 836a5655869..836a5655869 100644
--- a/pkgs/development/libraries/physics/hepmc/in_source.patch
+++ b/pkgs/development/libraries/physics/hepmc2/in_source.patch
diff --git a/pkgs/development/libraries/physics/pythia/default.nix b/pkgs/development/libraries/physics/pythia/default.nix
index e84aaf37325..e6b351c206d 100644
--- a/pkgs/development/libraries/physics/pythia/default.nix
+++ b/pkgs/development/libraries/physics/pythia/default.nix
@@ -1,15 +1,15 @@
-{ stdenv, fetchurl, boost, fastjet, hepmc, lhapdf, rsync, zlib }:
+{ stdenv, fetchurl, boost, fastjet, hepmc2, lhapdf, rsync, zlib }:
 
 stdenv.mkDerivation rec {
   name = "pythia-${version}";
-  version = "8.240";
+  version = "8.243";
 
   src = fetchurl {
     url = "http://home.thep.lu.se/~torbjorn/pythia8/pythia${builtins.replaceStrings ["."] [""] version}.tgz";
-    sha256 = "13cd86030j1f00n4xw30g26cgir3a5lsn9n0z13dh1vprbc9ax6j";
+    sha256 = "0y8w5gdaczg8vdw63rkgjr1dcvqs2clqkdia34p30xcwgm1jgv7q";
   };
 
-  buildInputs = [ boost fastjet hepmc zlib rsync lhapdf ];
+  buildInputs = [ boost fastjet hepmc2 zlib rsync lhapdf ];
 
   preConfigure = ''
     patchShebangs ./configure
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
 
   configureFlags = [
     "--enable-shared"
-    "--with-hepmc2=${hepmc}"
+    "--with-hepmc2=${hepmc2}"
     "--with-lhapdf6=${lhapdf}"
   ];
 
diff --git a/pkgs/development/libraries/physics/rivet/default.nix b/pkgs/development/libraries/physics/rivet/default.nix
index 40ccd8cfd20..c068424e416 100644
--- a/pkgs/development/libraries/physics/rivet/default.nix
+++ b/pkgs/development/libraries/physics/rivet/default.nix
@@ -1,8 +1,8 @@
-{ stdenv, fetchurl, fastjet, ghostscript, gsl, hepmc, imagemagick, less, python2, texlive, yoda, which, makeWrapper }:
+{ stdenv, fetchurl, fastjet, ghostscript, gsl, hepmc2, imagemagick, less, python2, texlive, yoda, which, makeWrapper }:
 
 stdenv.mkDerivation rec {
   name = "rivet-${version}";
-  version = "2.7.0";
+  version = "2.7.2";
 
   src = fetchurl {
     url = "https://www.hepforge.org/archive/rivet/Rivet-${version}.tar.bz2";
@@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
     xkeyval
     xstring
     ;};
-  buildInputs = [ hepmc imagemagick python2 latex makeWrapper ];
+  buildInputs = [ hepmc2 imagemagick python2 latex makeWrapper ];
   propagatedBuildInputs = [ fastjet ghostscript gsl yoda ];
 
   preConfigure = ''
@@ -58,7 +58,7 @@ stdenv.mkDerivation rec {
 
   configureFlags = [
     "--with-fastjet=${fastjet}"
-    "--with-hepmc=${hepmc}"
+    "--with-hepmc=${hepmc2}"
     "--with-yoda=${yoda}"
   ];
 
diff --git a/pkgs/development/libraries/physics/thepeg/default.nix b/pkgs/development/libraries/physics/thepeg/default.nix
index 046413c64f4..272761977ba 100644
--- a/pkgs/development/libraries/physics/thepeg/default.nix
+++ b/pkgs/development/libraries/physics/thepeg/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, boost, fastjet, gsl, hepmc, lhapdf, rivet, zlib }:
+{ stdenv, fetchurl, boost, fastjet, gsl, hepmc2, lhapdf, rivet, zlib }:
 
 stdenv.mkDerivation rec {
   name = "thepeg-${version}";
@@ -9,10 +9,10 @@ stdenv.mkDerivation rec {
     sha256 = "1rmmwhk9abn9mc9j3127axjwpvymv21ld4wcivwz01pldkxh06n6";
   };
 
-  buildInputs = [ boost fastjet gsl hepmc lhapdf rivet zlib ];
+  buildInputs = [ boost fastjet gsl hepmc2 lhapdf rivet zlib ];
 
   configureFlags = [
-    "--with-hepmc=${hepmc}"
+    "--with-hepmc=${hepmc2}"
     "--with-rivet=${rivet}"
     "--without-javagui"
   ];
diff --git a/pkgs/development/libraries/physics/yoda/default.nix b/pkgs/development/libraries/physics/yoda/default.nix
index 7a89d61753d..08afe6d6452 100644
--- a/pkgs/development/libraries/physics/yoda/default.nix
+++ b/pkgs/development/libraries/physics/yoda/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "yoda-${version}";
-  version = "1.7.4";
+  version = "1.7.7";
 
   src = fetchurl {
     url = "https://www.hepforge.org/archive/yoda/YODA-${version}.tar.bz2";
-    sha256 = "0w9s3qv87hrmpq4dkrxcrl2hn2vcsbvy8ml99w85404wksw1dwrx";
+    sha256 = "1ki88rscnym0vjxpfgql8m1lrc7vm1jb9w4jhw9lvv3rk84lpdng";
   };
 
   pythonPath = []; # python wrapper support
diff --git a/pkgs/development/libraries/pixman/default.nix b/pkgs/development/libraries/pixman/default.nix
index 2a033304b66..d3bbb867974 100644
--- a/pkgs/development/libraries/pixman/default.nix
+++ b/pkgs/development/libraries/pixman/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, pkgconfig, libpng, glib /*just passthru*/ }:
+{ stdenv, fetchurl, pkgconfig, libpng, glib /*just passthru*/ }:
 
 stdenv.mkDerivation rec {
   name = "pixman-${version}";
diff --git a/pkgs/development/libraries/png++/default.nix b/pkgs/development/libraries/png++/default.nix
index 54a563c518f..3f6a609121a 100644
--- a/pkgs/development/libraries/png++/default.nix
+++ b/pkgs/development/libraries/png++/default.nix
@@ -5,11 +5,11 @@ assert docSupport -> doxygen != null;
 
 stdenv.mkDerivation rec {
   name = "pngpp-${version}";
-  version = "0.2.9";
+  version = "0.2.10";
 
   src = fetchurl {
     url = "mirror://savannah/pngpp/png++-${version}.tar.gz";
-    sha256 = "14c74fsc3q8iawf60m74xkkawkqbhd8k8x315m06qaqjcl2nmg5b";
+    sha256 = "1qgf8j25r57wjqlnzdkm8ya5x1bmj6xjvapv8f2visqnmcbg52lr";
   };
 
   doCheck = true;
diff --git a/pkgs/development/libraries/poco/default.nix b/pkgs/development/libraries/poco/default.nix
index 4dffa7486a1..68ddf5c91d1 100644
--- a/pkgs/development/libraries/poco/default.nix
+++ b/pkgs/development/libraries/poco/default.nix
@@ -3,11 +3,11 @@
 stdenv.mkDerivation rec {
   name = "poco-${version}";
 
-  version = "1.9.0";
+  version = "1.9.2";
 
   src = fetchurl {
     url = "https://pocoproject.org/releases/${name}/${name}-all.tar.gz";
-    sha256 = "11z1i0drbacs7c7d5virc3kz7wh79svd06iffh8j6giikl7vz1q3";
+    sha256 = "0jkbxw6z8l7zpr7bh2xcyzk8a5apzyz4ranhl66gxna1ay0gpzvd";
   };
 
   nativeBuildInputs = [ cmake pkgconfig ];
diff --git a/pkgs/development/libraries/podofo/default.nix b/pkgs/development/libraries/podofo/default.nix
index ce3f5ab6b78..722c1cae872 100644
--- a/pkgs/development/libraries/podofo/default.nix
+++ b/pkgs/development/libraries/podofo/default.nix
@@ -1,6 +1,5 @@
 { stdenv, fetchurl, cmake, zlib, freetype, libjpeg, libtiff, fontconfig
 , openssl, libpng, lua5, pkgconfig, libidn, expat, fetchpatch
-, gcc5 # TODO(@Dridus) remove this at next hash break
 }:
 
 stdenv.mkDerivation rec {
diff --git a/pkgs/development/libraries/polkit/default.nix b/pkgs/development/libraries/polkit/default.nix
index fb16a7fb693..b5b9f1f7fa4 100644
--- a/pkgs/development/libraries/polkit/default.nix
+++ b/pkgs/development/libraries/polkit/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, autoreconfHook, pkgconfig, glib, expat, pam, perl
+{ stdenv, fetchurl, pkgconfig, glib, expat, pam, perl
 , intltool, spidermonkey_60 , gobject-introspection, libxslt, docbook_xsl, dbus
 , docbook_xml_dtd_412, gtk-doc, coreutils
 , useSystemd ? stdenv.isLinux, systemd
diff --git a/pkgs/development/libraries/proj-datumgrid/default.nix b/pkgs/development/libraries/proj-datumgrid/default.nix
new file mode 100644
index 00000000000..f1c13e93aec
--- /dev/null
+++ b/pkgs/development/libraries/proj-datumgrid/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  name = "proj-datumgrid";
+  version = "world-1.0";
+
+  src = fetchFromGitHub {
+    owner = "OSGeo";
+    repo = "proj-datumgrid";
+    rev = version;
+    sha256 = "132wp77fszx33wann0fjkmi1isxvsb0v9iw0gd9sxapa9h6hf3am";
+  };
+
+  sourceRoot = "source/scripts";
+
+  buildPhase = ''
+    $CC nad2bin.c -o nad2bin
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp nad2bin $out/bin/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Repository for proj datum grids";
+    homepage = https://proj4.org;
+    license = licenses.mit;
+    platforms = platforms.linux ++ platforms.darwin;
+    maintainers = with maintainers; [ ];
+  };
+}
diff --git a/pkgs/development/libraries/proj/5.2.nix b/pkgs/development/libraries/proj/5.2.nix
new file mode 100644
index 00000000000..8fb4515e70d
--- /dev/null
+++ b/pkgs/development/libraries/proj/5.2.nix
@@ -0,0 +1,20 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation {
+  name = "proj-5.2.0";
+
+  src = fetchurl {
+    url = https://download.osgeo.org/proj/proj-5.2.0.tar.gz;
+    sha256 = "0q3ydh2j8qhwlxmnac72pg69rw2znbi5b6k5wama8qmwzycr94gg";
+  };
+
+  doCheck = stdenv.is64bit;
+
+  meta = with stdenv.lib; {
+    description = "Cartographic Projections Library";
+    homepage = https://proj4.org;
+    license = licenses.mit;
+    platforms = platforms.linux ++ platforms.darwin;
+    maintainers = with maintainers; [ vbgl ];
+  };
+}
diff --git a/pkgs/development/libraries/proj/default.nix b/pkgs/development/libraries/proj/default.nix
index 8fb4515e70d..ea89dbee0f6 100644
--- a/pkgs/development/libraries/proj/default.nix
+++ b/pkgs/development/libraries/proj/default.nix
@@ -1,13 +1,22 @@
-{ stdenv, fetchurl }:
+{ stdenv, fetchFromGitHub, pkg-config, sqlite, autoreconfHook }:
 
-stdenv.mkDerivation {
-  name = "proj-5.2.0";
+stdenv.mkDerivation rec {
+  name = "proj";
+  version = "6.1.1";
 
-  src = fetchurl {
-    url = https://download.osgeo.org/proj/proj-5.2.0.tar.gz;
-    sha256 = "0q3ydh2j8qhwlxmnac72pg69rw2znbi5b6k5wama8qmwzycr94gg";
+  src = fetchFromGitHub {
+    owner = "OSGeo";
+    repo = "PROJ";
+    rev = version;
+    sha256 = "0w2v2l22kv0xzq5hwl7n8ki6an8vfsr0lg0cdbkwcl4xv889ysma";
   };
 
+  outputs = [ "out" "dev"];
+
+  nativeBuildInputs = [ pkg-config autoreconfHook ];
+
+  buildInputs = [ sqlite ];
+
   doCheck = stdenv.is64bit;
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/prometheus-cpp/default.nix b/pkgs/development/libraries/prometheus-cpp/default.nix
index 23c8257ac8f..6f49db4d206 100644
--- a/pkgs/development/libraries/prometheus-cpp/default.nix
+++ b/pkgs/development/libraries/prometheus-cpp/default.nix
@@ -10,13 +10,13 @@
 
 stdenv.mkDerivation rec {
   pname = "prometheus-cpp";
-  version = "0.6.0";
+  version = "0.7.0";
 
   src = fetchFromGitHub {
     owner = "jupp0r";
     repo = pname;
     rev = "v${version}";
-    sha256 = "sha256:1a0gpfmk0z9wgsbzvx823aqbs7w836l0j0rnsxl9ifwgdxnxbl6m";
+    sha256 = "15bda1q1jbvixbx1qf41ykcdmsywhhwmi4xgsha12r5m9fh8jzxj";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/properties-cpp/default.nix b/pkgs/development/libraries/properties-cpp/default.nix
index 06444e77670..bd20dc540c0 100644
--- a/pkgs/development/libraries/properties-cpp/default.nix
+++ b/pkgs/development/libraries/properties-cpp/default.nix
@@ -1,5 +1,5 @@
-{ stdenv, lib, fetchurl, cmake, pkgconfig, gtest, doxygen
-, graphviz, lcov, writeText }:
+{ stdenv, fetchurl, cmake, pkgconfig, gtest, doxygen
+, graphviz, lcov }:
 
 stdenv.mkDerivation rec {
   pname = "properties-cpp";
diff --git a/pkgs/development/libraries/protobuf/3.4.nix b/pkgs/development/libraries/protobuf/3.4.nix
deleted file mode 100644
index 5a9034a56a8..00000000000
--- a/pkgs/development/libraries/protobuf/3.4.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ callPackage, lib, ... }:
-
-lib.overrideDerivation (callPackage ./generic-v3.nix {
-  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
deleted file mode 100644
index db9cb6f0371..00000000000
--- a/pkgs/development/libraries/protobuf/3.5.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ 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/protobuf/3.8.nix b/pkgs/development/libraries/protobuf/3.8.nix
new file mode 100644
index 00000000000..2ea03643b3a
--- /dev/null
+++ b/pkgs/development/libraries/protobuf/3.8.nix
@@ -0,0 +1,6 @@
+{ callPackage, ... }:
+
+callPackage ./generic-v3.nix {
+  version = "3.8.0";
+  sha256 = "0vll02a6k46k720wfh25sl4hdai0130s3ix2l1wh6j1lm9pi7bm8";
+}
diff --git a/pkgs/development/libraries/protobuf/3.9.nix b/pkgs/development/libraries/protobuf/3.9.nix
new file mode 100644
index 00000000000..a2f3e0e0164
--- /dev/null
+++ b/pkgs/development/libraries/protobuf/3.9.nix
@@ -0,0 +1,6 @@
+{ callPackage, ... }:
+
+callPackage ./generic-v3.nix {
+  version = "3.9.1";
+  sha256 = "0vv85xb65dx6fa76fsnyps13kaamvwfzd8hr6ii1payr73x4zy2h";
+}
diff --git a/pkgs/development/libraries/protobuf/generic-v3.nix b/pkgs/development/libraries/protobuf/generic-v3.nix
index 883dff56f2e..a98521a2d1e 100644
--- a/pkgs/development/libraries/protobuf/generic-v3.nix
+++ b/pkgs/development/libraries/protobuf/generic-v3.nix
@@ -1,6 +1,6 @@
 { stdenv
 , fetchFromGitHub
-, autoreconfHook, zlib, gmock, which, buildPackages
+, autoreconfHook, zlib, gmock, buildPackages
 , version, sha256
 , ...
 }:
@@ -40,10 +40,6 @@ mkProtobufDerivation = buildProtobuf: stdenv: stdenv.mkDerivation rec {
 
   dontDisableStatic = true;
 
-  NIX_CFLAGS_COMPILE = with stdenv.lib;
-    # gcc before 6 doesn't know this option
-    optionalString (hasPrefix "gcc-6" stdenv.cc.cc.name) "-Wno-error=misleading-indentation";
-
   meta = {
     description = "Google's data interchange format";
     longDescription =
diff --git a/pkgs/development/libraries/protozero/default.nix b/pkgs/development/libraries/protozero/default.nix
index a18d768c288..25e0f14d026 100644
--- a/pkgs/development/libraries/protozero/default.nix
+++ b/pkgs/development/libraries/protozero/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "protozero-${version}";
-  version = "1.6.7";
+  version = "1.6.8";
 
   src = fetchFromGitHub {
     owner = "mapbox";
     repo = "protozero";
     rev = "v${version}";
-    sha256 = "1ryvn3iwxiaih3mvyy45nbwxnhzfc8vby0xh9m6d6fpakhcpf6s3";
+    sha256 = "1hfijpfylf1c71wa3mk70gjc88b6k1q7cxb87cwqdflw5q2x8ma6";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/ptex/default.nix b/pkgs/development/libraries/ptex/default.nix
index aa17771ec9f..b4571d07fbf 100644
--- a/pkgs/development/libraries/ptex/default.nix
+++ b/pkgs/development/libraries/ptex/default.nix
@@ -1,36 +1,27 @@
-{ stdenv, fetchFromGitHub, zlib, python, cmake }:
+{ stdenv, fetchFromGitHub, zlib, python, cmake, pkg-config }:
 
 stdenv.mkDerivation rec
 {
-  name = "ptex-${version}";
-  version = "2.3.0";
+  pname = "ptex";
+  version = "2.3.2";
 
   src = fetchFromGitHub {
     owner = "wdas";
     repo = "ptex";
     rev = "v${version}";
-    sha256 = "0nfz0y66bmi6xckn1whi4sfd8i3ibln212fgm4img2z98b6vccyg";
+    sha256 = "1c3pdqszn4y3d86qzng8b0hqdrchnl39adq5ab30wfnrgl2hnm4z";
   };
 
   outputs = [ "bin" "dev" "out" "lib" ];
 
-  buildInputs = [ zlib python cmake ];
+  buildInputs = [ zlib python cmake pkg-config ];
 
   enableParallelBuilding = true;
 
-  buildPhase = ''
-      mkdir -p $out
-
-      make prefix=$out
-
-      mkdir -p $bin/bin
-      mkdir -p $dev/include
-      mkdir -p $lib/lib
-      '';
-
-  installPhase = ''
-    make install
-    mv $out/bin $bin/
+  # Can be removed in the next release
+  # https://github.com/wdas/ptex/pull/42
+  patchPhase = ''
+    echo v${version} >version
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/pth/default.nix b/pkgs/development/libraries/pth/default.nix
index c315cb8f72b..b2173ec21ee 100644
--- a/pkgs/development/libraries/pth/default.nix
+++ b/pkgs/development/libraries/pth/default.nix
@@ -10,6 +10,8 @@ stdenv.mkDerivation rec {
 
   preConfigure = stdenv.lib.optionalString stdenv.isAarch32 ''
     configureFlagsArray=("CFLAGS=-DJB_SP=8 -DJB_PC=9")
+  '' + stdenv.lib.optionalString (stdenv.hostPlatform.libc == "glibc") ''
+    configureFlagsArray+=("ac_cv_check_sjlj=ssjlj")
   '';
 
   meta = with stdenv.lib; {
@@ -17,6 +19,5 @@ stdenv.mkDerivation rec {
     homepage = https://www.gnu.org/software/pth;
     license = licenses.lgpl21Plus;
     platforms = platforms.all;
-    broken = stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform.isAarch64;
   };
 }
diff --git a/pkgs/development/libraries/ptlib/default.nix b/pkgs/development/libraries/ptlib/default.nix
index d1dcc5fdb97..e7abedf3121 100644
--- a/pkgs/development/libraries/ptlib/default.nix
+++ b/pkgs/development/libraries/ptlib/default.nix
@@ -25,6 +25,11 @@ 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 {
+      name = "openssl-1.1.patch";
+      url = "https://git.archlinux.org/svntogit/packages.git/plain/trunk/openssl-1.1.0.patch?h=packages/ptlib&id=1dfa9f55e7e030d261228fca27dda82979ca7f30";
+      sha256 = "11hdgyyibycg0wf5ls0wk9hksa4jd434i86xqiccbyg17n4l6lc1";
+    })
     ./ptlib-2.10.11-glibc-2.26.patch
   ];
 
diff --git a/pkgs/development/libraries/pyotherside/default.nix b/pkgs/development/libraries/pyotherside/default.nix
index c7d43ae7026..a7f5e03c738 100644
--- a/pkgs/development/libraries/pyotherside/default.nix
+++ b/pkgs/development/libraries/pyotherside/default.nix
@@ -3,13 +3,13 @@
 
 stdenv.mkDerivation rec {
   pname = "pyotherside";
-  version = "1.5.6";
+  version = "1.5.8";
 
   src = fetchFromGitHub {
     owner = "thp";
     repo = "pyotherside";
     rev = version;
-    sha256 = "1cjx0fbrq9qvbirwy76pw1f5skm2afd51k4qb269ql4gpl67d5lv";
+    sha256 = "0dnsvyg990ln3bdjdyc5b4lbb63wcjij0skq8pb4x4jglfy7vz4z";
   };
 
   nativeBuildInputs = [ qmake ];
diff --git a/pkgs/development/libraries/qca2/default.nix b/pkgs/development/libraries/qca2/default.nix
index ec32c44a91f..885b7b378cc 100644
--- a/pkgs/development/libraries/qca2/default.nix
+++ b/pkgs/development/libraries/qca2/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cmake, pkgconfig, qt, darwin }:
+{ stdenv, fetchurl, openssl_1_0_2, cmake, pkgconfig, qt, darwin }:
 
 stdenv.mkDerivation rec {
   name = "qca-${version}";
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ cmake pkgconfig ];
-  buildInputs = [ qt ]
+  buildInputs = [ openssl_1_0_2 qt ]
     ++ stdenv.lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security;
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/qgnomeplatform/default.nix b/pkgs/development/libraries/qgnomeplatform/default.nix
index 1fb3a415dc6..94c69a4a14b 100644
--- a/pkgs/development/libraries/qgnomeplatform/default.nix
+++ b/pkgs/development/libraries/qgnomeplatform/default.nix
@@ -1,7 +1,7 @@
-{ stdenv, fetchFromGitHub, pkgconfig, gtk3, qtbase, qmake }:
+{ mkDerivation, lib, fetchFromGitHub, pkgconfig, gtk3, qtbase, qmake }:
 
-stdenv.mkDerivation rec {
-  name = "qgnomeplatform-${version}";
+mkDerivation rec {
+  pname = "qgnomeplatform";
   version = "0.5";
 
   src = fetchFromGitHub {
@@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
       --replace "\$\$[QT_INSTALL_PLUGINS]" "$out/$qtPluginPrefix"
   '';
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "QPlatformTheme for a better Qt application inclusion in GNOME";
     homepage = https://github.com/FedoraQt/QGnomePlatform;
     license = licenses.lgpl21Plus;
diff --git a/pkgs/development/libraries/qpdf/default.nix b/pkgs/development/libraries/qpdf/default.nix
index dceda3c04bd..5bccbf74965 100644
--- a/pkgs/development/libraries/qpdf/default.nix
+++ b/pkgs/development/libraries/qpdf/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, libjpeg, zlib, perl }:
+{ stdenv, fetchurl, libjpeg, zlib, perl }:
 
 let version = "8.4.2";
 in
diff --git a/pkgs/development/libraries/qt-3/default.nix b/pkgs/development/libraries/qt-3/default.nix
index dc05251478c..3b3f406485c 100644
--- a/pkgs/development/libraries/qt-3/default.nix
+++ b/pkgs/development/libraries/qt-3/default.nix
@@ -6,8 +6,9 @@
 , cursorSupport ? true, libXcursor ? null
 , threadSupport ? true
 , mysqlSupport ? false, mysql ? null
-, libGLSupported
-, openglSupport ? libGLSupported, libGLU_combined ? null, libXmu ? null
+, libGLSupported ? stdenv.lib.elem stdenv.hostPlatform.system stdenv.lib.platforms.mesaPlatforms
+, openglSupport ? stdenv.lib.elem stdenv.hostPlatform.system stdenv.lib.platforms.mesaPlatforms
+, libGLU_combined ? null, libXmu ? null
 , xlibsWrapper, xorgproto, zlib, libjpeg, libpng, which
 }:
 
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 d5bd065ab64..8c1c76db8f4 100644
--- a/pkgs/development/libraries/qt-4.x/4.8/default.nix
+++ b/pkgs/development/libraries/qt-4.x/4.8/default.nix
@@ -1,11 +1,12 @@
 { stdenv, lib, fetchurl, fetchpatch, substituteAll
 , libXrender, libXinerama, libXcursor, libXv, libXext
 , libXfixes, libXrandr, libSM, freetype, fontconfig, zlib, libjpeg, libpng
-, libmng, which, libGLSupported, libGLU, openssl, dbus, cups, pkgconfig
+, libmng, which, 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)
-, flashplayerFix ? false, gdk_pixbuf
+, libGLSupported ? stdenv.lib.elem stdenv.hostPlatform.system stdenv.lib.platforms.mesaPlatforms
+, flashplayerFix ? false, gdk-pixbuf
 , gtkStyle ? stdenv.hostPlatform == stdenv.buildPlatform, gtk2
 , gnomeStyle ? false, libgnomeui, GConf, gnome_vfs
 , developerBuild ? false
@@ -13,7 +14,7 @@
 , examples ? false
 , demos ? false
 # darwin support
-, cf-private, libobjc, ApplicationServices, OpenGL, Cocoa, AGL, libcxx
+, libobjc, ApplicationServices, OpenGL, Cocoa, AGL, libcxx
 }:
 
 let
@@ -82,11 +83,14 @@ stdenv.mkDerivation rec {
           + "21b342d71c19e6d68b649947f913410fe6129ea4/debian/patches/kubuntu_39_fix_medium_font.diff";
         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";
-      })
+      # Patches are no longer available from here, so vendoring it for now.
+      #(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";
+      #})
+      ./qt4-gcc6.patch
+      ./qt4-openssl-1.1.patch
     ]
     ++ lib.optional gtkStyle (substituteAll ({
         src = ./dlopen-gtkstyle.diff;
@@ -187,8 +191,8 @@ stdenv.mkDerivation rec {
     [ cups # Qt dlopen's libcups instead of linking to it
       postgresql sqlite libjpeg libmng libtiff icu ]
     ++ lib.optionals (mysql != null) [ mysql.connector-c ]
-    ++ lib.optionals gtkStyle [ gtk2 gdk_pixbuf ]
-    ++ lib.optionals stdenv.isDarwin [ cf-private ApplicationServices OpenGL Cocoa AGL libcxx libobjc ];
+    ++ lib.optionals gtkStyle [ gtk2 gdk-pixbuf ]
+    ++ lib.optionals stdenv.isDarwin [ ApplicationServices OpenGL Cocoa AGL libcxx libobjc ];
 
   nativeBuildInputs = [ perl pkgconfig which ];
 
diff --git a/pkgs/development/libraries/qt-4.x/4.8/qt4-gcc6.patch b/pkgs/development/libraries/qt-4.x/4.8/qt4-gcc6.patch
new file mode 100644
index 00000000000..000e345cf13
--- /dev/null
+++ b/pkgs/development/libraries/qt-4.x/4.8/qt4-gcc6.patch
@@ -0,0 +1,33 @@
+--- qt-everywhere-opensource-src-4.8.7/configure.gcc6	2016-04-15 07:04:19.430268222 -0500
++++ qt-everywhere-opensource-src-4.8.7/configure	2016-04-15 07:05:22.157568689 -0500
+@@ -7744,7 +7744,7 @@
+     *-g++*)
+ 	# Check gcc's version
+ 	case "$(${QMAKE_CONF_COMPILER} -dumpversion)" in
+-	    5*|4*|3.4*)
++	    8*|7*|6*|5*|4*|3.4*)
+ 		;;
+             3.3*)
+                 canBuildWebKit="no"
+@@ -8060,7 +8060,7 @@
+     3.*)
+         COMPILER_VERSION="3.*"
+         ;;
+-    5*|4.*)
++    8*|7*|6*|5*|4.*)
+         COMPILER_VERSION="4"
+         ;;
+     *)
+--- qt-everywhere-opensource-src-4.8.7/src/xmlpatterns/api/qcoloroutput_p.h.gcc6	2015-05-07 09:14:48.000000000 -0500
++++ qt-everywhere-opensource-src-4.8.7/src/xmlpatterns/api/qcoloroutput_p.h	2016-04-15 07:04:19.431268227 -0500
+@@ -70,8 +70,8 @@
+             ForegroundShift = 10,
+             BackgroundShift = 20,
+             SpecialShift    = 20,
+-            ForegroundMask  = ((1 << ForegroundShift) - 1) << ForegroundShift,
+-            BackgroundMask  = ((1 << BackgroundShift) - 1) << BackgroundShift
++            ForegroundMask  = 0x1f << ForegroundShift,
++            BackgroundMask  = 0x7 << BackgroundShift
+         };
+ 
+     public:
diff --git a/pkgs/development/libraries/qt-4.x/4.8/qt4-openssl-1.1.patch b/pkgs/development/libraries/qt-4.x/4.8/qt4-openssl-1.1.patch
new file mode 100644
index 00000000000..1931ceb0c74
--- /dev/null
+++ b/pkgs/development/libraries/qt-4.x/4.8/qt4-openssl-1.1.patch
@@ -0,0 +1,398 @@
+--- a/src/network/ssl/qsslcertificate.cpp
++++ b/src/network/ssl/qsslcertificate.cpp
+@@ -259,10 +259,10 @@
+ QByteArray QSslCertificate::version() const
+ {
+     QMutexLocker lock(QMutexPool::globalInstanceGet(d.data()));
+-    if (d->versionString.isEmpty() && d->x509)
++    if (d->versionString.isEmpty() && d->x509) {
+         d->versionString =
+-            QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->version)) + 1);
+-
++	    QByteArray::number(qlonglong(q_X509_get_version(d->x509)) + 1);
++    }
+     return d->versionString;
+ }
+ 
+@@ -276,7 +276,7 @@
+ {
+     QMutexLocker lock(QMutexPool::globalInstanceGet(d.data()));
+     if (d->serialNumberString.isEmpty() && d->x509) {
+-        ASN1_INTEGER *serialNumber = d->x509->cert_info->serialNumber;
++        ASN1_INTEGER *serialNumber = q_X509_get_serialNumber(d->x509);
+         // if we cannot convert to a long, just output the hexadecimal number
+         if (serialNumber->length > 4) {
+             QByteArray hexString;
+@@ -489,24 +489,33 @@
+     QSslKey key;
+ 
+     key.d->type = QSsl::PublicKey;
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+     X509_PUBKEY *xkey = d->x509->cert_info->key;
++#else
++    X509_PUBKEY *xkey = q_X509_get_X509_PUBKEY(d->x509);
++#endif
+     EVP_PKEY *pkey = q_X509_PUBKEY_get(xkey);
+     Q_ASSERT(pkey);
+ 
+-    if (q_EVP_PKEY_type(pkey->type) == EVP_PKEY_RSA) {
++    int key_id;
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
++    key_id = q_EVP_PKEY_type(pkey->type);
++#else
++    key_id = q_EVP_PKEY_base_id(pkey);
++#endif
++    if (key_id == EVP_PKEY_RSA) {
+         key.d->rsa = q_EVP_PKEY_get1_RSA(pkey);
+         key.d->algorithm = QSsl::Rsa;
+         key.d->isNull = false;
+-    } else if (q_EVP_PKEY_type(pkey->type) == EVP_PKEY_DSA) {
++    } else if (key_id == EVP_PKEY_DSA) {
+         key.d->dsa = q_EVP_PKEY_get1_DSA(pkey);
+         key.d->algorithm = QSsl::Dsa;
+         key.d->isNull = false;
+-    } else if (q_EVP_PKEY_type(pkey->type) == EVP_PKEY_DH) {
++    } else if (key_id == EVP_PKEY_DH) {
+         // DH unsupported
+     } else {
+         // error?
+     }
+-
+     q_EVP_PKEY_free(pkey);
+     return key;
+ }
+--- a/src/network/ssl/qsslkey.cpp
++++ b/src/network/ssl/qsslkey.cpp
+@@ -321,8 +321,19 @@
+ {
+     if (d->isNull)
+         return -1;
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+     return (d->algorithm == QSsl::Rsa)
+            ? q_BN_num_bits(d->rsa->n) : q_BN_num_bits(d->dsa->p);
++#else
++    if (d->algorithm == QSsl::Rsa) {
++        return q_RSA_bits(d->rsa);
++    }else{
++        BIGNUM *p = NULL;
++        q_DSA_get0_pqg(d->dsa, &p, NULL, NULL);
++	return q_BN_num_bits(p);
++    }
++#endif
++
+ }
+ 
+ /*!
+--- a/src/network/ssl/qsslsocket_openssl.cpp
++++ b/src/network/ssl/qsslsocket_openssl.cpp
+@@ -93,6 +93,7 @@
+ bool QSslSocketPrivate::s_loadedCiphersAndCerts = false;
+ bool QSslSocketPrivate::s_loadRootCertsOnDemand = false;
+ 
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ /* \internal
+ 
+     From OpenSSL's thread(3) manual page:
+@@ -174,6 +175,8 @@
+ }
+ } // extern "C"
+ 
++#endif //OPENSSL_VERSION_NUMBER >= 0x10100000L
++
+ QSslSocketBackendPrivate::QSslSocketBackendPrivate()
+     : ssl(0),
+       ctx(0),
+@@ -222,9 +225,12 @@
+             ciph.d->encryptionMethod = descriptionList.at(4).mid(4);
+         ciph.d->exportable = (descriptionList.size() > 6 && descriptionList.at(6) == QLatin1String("export"));
+ 
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+         ciph.d->bits = cipher->strength_bits;
+         ciph.d->supportedBits = cipher->alg_bits;
+-
++#else
++	ciph.d->bits = q_SSL_CIPHER_get_bits(cipher, &ciph.d->supportedBits);
++#endif
+     }
+     return ciph;
+ }
+@@ -367,7 +373,7 @@
+         //
+         // See also: QSslContext::fromConfiguration()
+         if (caCertificate.expiryDate() >= QDateTime::currentDateTime()) {
+-            q_X509_STORE_add_cert(ctx->cert_store, (X509 *)caCertificate.handle());
++	  q_X509_STORE_add_cert(q_SSL_CTX_get_cert_store(ctx), (X509 *)caCertificate.handle());
+         }
+     }
+ 
+@@ -504,8 +510,10 @@
+ */
+ void QSslSocketPrivate::deinitialize()
+ {
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+     q_CRYPTO_set_id_callback(0);
+     q_CRYPTO_set_locking_callback(0);
++#endif
+ }
+ 
+ /*!
+@@ -526,13 +534,17 @@
+         return false;
+ 
+     // Check if the library itself needs to be initialized.
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+     QMutexLocker locker(openssl_locks()->initLock());
++#endif
+     if (!s_libraryLoaded) {
+         s_libraryLoaded = true;
+ 
+         // Initialize OpenSSL.
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+         q_CRYPTO_set_id_callback(id_function);
+         q_CRYPTO_set_locking_callback(locking_function);
++#endif
+         if (q_SSL_library_init() != 1)
+             return false;
+         q_SSL_load_error_strings();
+@@ -571,7 +583,9 @@
+ 
+ void QSslSocketPrivate::ensureCiphersAndCertsLoaded()
+ {
+-    QMutexLocker locker(openssl_locks()->initLock());
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
++  QMutexLocker locker(openssl_locks()->initLock());
++#endif
+     if (s_loadedCiphersAndCerts)
+         return;
+     s_loadedCiphersAndCerts = true;
+@@ -663,13 +677,18 @@
+     STACK_OF(SSL_CIPHER) *supportedCiphers = q_SSL_get_ciphers(mySsl);
+     for (int i = 0; i < q_sk_SSL_CIPHER_num(supportedCiphers); ++i) {
+         if (SSL_CIPHER *cipher = q_sk_SSL_CIPHER_value(supportedCiphers, i)) {
+-            if (cipher->valid) {
++
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
++	  if (cipher->valid) {
++#endif
+                 QSslCipher ciph = QSslSocketBackendPrivate::QSslCipher_from_SSL_CIPHER(cipher);
+                 if (!ciph.isNull()) {
+                     if (!ciph.name().toLower().startsWith(QLatin1String("adh")))
+                         ciphers << ciph;
+                 }
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+             }
++#endif
+         }
+     }
+ 
+--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -290,6 +290,22 @@
+ DEFINEFUNC(void, OPENSSL_add_all_algorithms_conf, void, DUMMYARG, return, DUMMYARG)
+ DEFINEFUNC3(int, SSL_CTX_load_verify_locations, SSL_CTX *ctx, ctx, const char *CAfile, CAfile, const char *CApath, CApath, return 0, return)
+ DEFINEFUNC(long, SSLeay, void, DUMMYARG, return 0, return)
++DEFINEFUNC(X509_STORE *, SSL_CTX_get_cert_store, const SSL_CTX *ctx, ctx, return 0, return)
++
++DEFINEFUNC(ASN1_INTEGER *, X509_get_serialNumber, X509 *x, x, return 0, return)
++#if OPENSSL_VERSION_NUMBER >= 0x10100000L
++DEFINEFUNC(int, EVP_PKEY_id, const EVP_PKEY *pkey, pkey, return 0, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, const EVP_PKEY *pkey, pkey, return 0, return)
++DEFINEFUNC2(int, SSL_CIPHER_get_bits, const SSL_CIPHER *cipher, cipher, int *alg_bits, alg_bits, return 0, return)
++DEFINEFUNC2(long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, long options, options, return 0, return)
++DEFINEFUNC(long, X509_get_version, X509 *x, x, return 0, return)
++DEFINEFUNC(X509_PUBKEY *, X509_get_X509_PUBKEY, X509 *x, x, return 0, return)
++DEFINEFUNC(int, RSA_bits,  const RSA *rsa, rsa, return 0, return)
++DEFINEFUNC(int, DSA_security_bits, const DSA *dsa, dsa, return 0, return)
++DEFINEFUNC(ASN1_TIME *, X509_get_notAfter, X509 *x, x, return 0, return)
++DEFINEFUNC(ASN1_TIME *, X509_get_notBefore, X509 *x, x, return 0, return)
++DEFINEFUNC4(void, DSA_get0_pqg, const DSA *d, d, BIGNUM **p, p, BIGNUM **q, q, BIGNUM **g, g, return, return)
++#endif
+ 
+ #ifdef Q_OS_SYMBIAN
+ #define RESOLVEFUNC(func, ordinal, lib) \
+@@ -801,6 +817,7 @@
+     RESOLVEFUNC(SSL_CTX_use_PrivateKey)
+     RESOLVEFUNC(SSL_CTX_use_RSAPrivateKey)
+     RESOLVEFUNC(SSL_CTX_use_PrivateKey_file)
++    RESOLVEFUNC(SSL_CTX_get_cert_store)
+     RESOLVEFUNC(SSL_accept)
+     RESOLVEFUNC(SSL_clear)
+     RESOLVEFUNC(SSL_connect)
+@@ -823,6 +840,23 @@
+     RESOLVEFUNC(SSL_set_connect_state)
+     RESOLVEFUNC(SSL_shutdown)
+     RESOLVEFUNC(SSL_write)
++
++    RESOLVEFUNC(X509_get_serialNumber)
++#if OPENSSL_VERSION_NUMBER >= 0x10100000L
++    RESOLVEFUNC(SSL_CTX_ctrl)
++    RESOLVEFUNC(EVP_PKEY_id)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++    RESOLVEFUNC(SSL_CIPHER_get_bits)
++    RESOLVEFUNC(SSL_CTX_set_options)
++    RESOLVEFUNC(X509_get_version)
++    RESOLVEFUNC(X509_get_X509_PUBKEY)
++    RESOLVEFUNC(RSA_bits)
++    RESOLVEFUNC(DSA_security_bits)
++    RESOLVEFUNC(DSA_get0_pqg)
++    RESOLVEFUNC(X509_get_notAfter)
++    RESOLVEFUNC(X509_get_notBefore)
++#endif
++
+ #ifndef OPENSSL_NO_SSL2
+     RESOLVEFUNC(SSLv2_client_method)
+ #endif
+--- a/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -399,7 +399,25 @@
+ 		PEM_ASN1_write_bio((int (*)(void*, unsigned char**))q_i2d_DSAPrivateKey,PEM_STRING_DSA,\
+ 			bp,(char *)x,enc,kstr,klen,cb,u)
+ #endif
++
++X509_STORE * q_SSL_CTX_get_cert_store(const SSL_CTX *ctx);
++ASN1_INTEGER * q_X509_get_serialNumber(X509 *x);
++
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ #define q_SSL_CTX_set_options(ctx,op) q_SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL)
++#define q_X509_get_version(x) X509_get_version(x)
++#else
++int q_EVP_PKEY_id(const EVP_PKEY *pkey);
++int q_EVP_PKEY_base_id(const EVP_PKEY *pkey);
++int q_SSL_CIPHER_get_bits(const SSL_CIPHER *cipher, int *alg_bits);
++long q_SSL_CTX_set_options(SSL_CTX *ctx, long options);
++long q_X509_get_version(X509 *x);
++X509_PUBKEY * q_X509_get_X509_PUBKEY(X509 *x);
++int q_RSA_bits(const RSA *rsa);
++int q_DSA_security_bits(const DSA *dsa);
++void q_DSA_get0_pqg(const DSA *d, BIGNUM **p, BIGNUM **q, BIGNUM **g);
++#endif
++
+ #define q_SKM_sk_num(type, st) ((int (*)(const STACK_OF(type) *))q_sk_num)(st)
+ #define q_SKM_sk_value(type, st,i) ((type * (*)(const STACK_OF(type) *, int))q_sk_value)(st, i)
+ #define q_sk_GENERAL_NAME_num(st) q_SKM_sk_num(GENERAL_NAME, (st))
+@@ -410,8 +428,15 @@
+ #define q_sk_SSL_CIPHER_value(st, i) q_SKM_sk_value(SSL_CIPHER, (st), (i))
+ #define q_SSL_CTX_add_extra_chain_cert(ctx,x509) \
+         q_SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509)
++
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ #define q_X509_get_notAfter(x) X509_get_notAfter(x)
+ #define q_X509_get_notBefore(x) X509_get_notBefore(x)
++#else
++ASN1_TIME *q_X509_get_notAfter(X509 *x);
++ASN1_TIME *q_X509_get_notBefore(X509 *x);
++#endif
++
+ #define q_EVP_PKEY_assign_RSA(pkey,rsa) q_EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
+ 					(char *)(rsa))
+ #define q_EVP_PKEY_assign_DSA(pkey,dsa) q_EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
+--- qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslcertificate.cpp.omv~	2017-03-15 02:27:18.143322736 +0100
++++ qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslcertificate.cpp	2017-03-15 02:29:56.215819741 +0100
+@@ -696,7 +696,7 @@
+         unsigned char *data = 0;
+         int size = q_ASN1_STRING_to_UTF8(&data, q_X509_NAME_ENTRY_get_data(e));
+         info[QString::fromUtf8(obj)] = QString::fromUtf8((char*)data, size);
+-        q_CRYPTO_free(data);
++        q_OPENSSL_free(data);
+     }
+     return info;
+ }
+--- qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslkey.cpp.0131~	2017-03-15 02:22:37.053244125 +0100
++++ qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslkey.cpp	2017-03-15 02:22:37.055244057 +0100
+@@ -328,7 +328,7 @@
+     if (d->algorithm == QSsl::Rsa) {
+         return q_RSA_bits(d->rsa);
+     }else{
+-        BIGNUM *p = NULL;
++        const BIGNUM *p = NULL;
+         q_DSA_get0_pqg(d->dsa, &p, NULL, NULL);
+ 	return q_BN_num_bits(p);
+     }
+--- qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslsocket_openssl_symbols.cpp.0131~	2017-03-15 02:22:37.054244091 +0100
++++ qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslsocket_openssl_symbols.cpp	2017-03-15 02:29:41.155236836 +0100
+@@ -111,16 +111,16 @@
+ DEFINEFUNC2(int, ASN1_STRING_to_UTF8, unsigned char **a, a, ASN1_STRING *b, b, return 0, return);
+ DEFINEFUNC4(long, BIO_ctrl, BIO *a, a, int b, b, long c, c, void *d, d, return -1, return)
+ DEFINEFUNC(int, BIO_free, BIO *a, a, return 0, return)
+-DEFINEFUNC(BIO *, BIO_new, BIO_METHOD *a, a, return 0, return)
++DEFINEFUNC(BIO *, BIO_new, const BIO_METHOD *a, a, return 0, return)
+ DEFINEFUNC2(BIO *, BIO_new_mem_buf, void *a, a, int b, b, return 0, return)
+ DEFINEFUNC3(int, BIO_read, BIO *a, a, void *b, b, int c, c, return -1, return)
+-DEFINEFUNC(BIO_METHOD *, BIO_s_mem, void, DUMMYARG, return 0, return)
++DEFINEFUNC(const BIO_METHOD *, BIO_s_mem, void, DUMMYARG, return 0, return)
+ DEFINEFUNC3(int, BIO_write, BIO *a, a, const void *b, b, int c, c, return -1, return)
+ DEFINEFUNC(int, BN_num_bits, const BIGNUM *a, a, return 0, return)
+ DEFINEFUNC(int, CRYPTO_num_locks, DUMMYARG, DUMMYARG, return 0, return)
+ DEFINEFUNC(void, CRYPTO_set_locking_callback, void (*a)(int, int, const char *, int), a, return, DUMMYARG)
+ DEFINEFUNC(void, CRYPTO_set_id_callback, unsigned long (*a)(), a, return, DUMMYARG)
+-DEFINEFUNC(void, CRYPTO_free, void *a, a, return, DUMMYARG)
++DEFINEFUNC(void, OPENSSL_free, void *a, a, return, DUMMYARG)
+ DEFINEFUNC(void, DSA_free, DSA *a, a, return, DUMMYARG)
+ #if  OPENSSL_VERSION_NUMBER < 0x00908000L
+ DEFINEFUNC3(X509 *, d2i_X509, X509 **a, a, unsigned char **b, b, long c, c, return 0, return)
+@@ -300,7 +300,7 @@
+ DEFINEFUNC(int, DSA_security_bits, const DSA *dsa, dsa, return 0, return)
+ DEFINEFUNC(ASN1_TIME *, X509_get_notAfter, X509 *x, x, return 0, return)
+ DEFINEFUNC(ASN1_TIME *, X509_get_notBefore, X509 *x, x, return 0, return)
+-DEFINEFUNC4(void, DSA_get0_pqg, const DSA *d, d, BIGNUM **p, p, BIGNUM **q, q, BIGNUM **g, g, return, return)
++DEFINEFUNC4(void, DSA_get0_pqg, const DSA *d, d, const BIGNUM **p, p, const BIGNUM **q, q, const BIGNUM **g, g, return, return)
+ #endif
+ 
+ #ifdef Q_OS_SYMBIAN
+--- qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslsocket_openssl_symbols_p.h.0131~	2017-03-15 02:22:37.054244091 +0100
++++ qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslsocket_openssl_symbols_p.h	2017-03-15 02:29:50.192986268 +0100
+@@ -59,6 +59,9 @@
+ QT_BEGIN_NAMESPACE
+ 
+ #define DUMMYARG
++#ifndef OPENSSL_NO_SSL2
++#define OPENSSL_NO_SSL2 1
++#endif
+ 
+ #if !defined QT_LINKED_OPENSSL
+ // **************** Shared declarations ******************
+@@ -207,16 +210,16 @@
+ int q_ASN1_STRING_to_UTF8(unsigned char **a, ASN1_STRING *b);
+ long q_BIO_ctrl(BIO *a, int b, long c, void *d);
+ int q_BIO_free(BIO *a);
+-BIO *q_BIO_new(BIO_METHOD *a);
++BIO *q_BIO_new(const BIO_METHOD *a);
+ BIO *q_BIO_new_mem_buf(void *a, int b);
+ int q_BIO_read(BIO *a, void *b, int c);
+-BIO_METHOD *q_BIO_s_mem();
++const BIO_METHOD *q_BIO_s_mem();
+ int q_BIO_write(BIO *a, const void *b, int c);
+ int q_BN_num_bits(const BIGNUM *a);
+ int q_CRYPTO_num_locks();
+ void q_CRYPTO_set_locking_callback(void (*a)(int, int, const char *, int));
+ void q_CRYPTO_set_id_callback(unsigned long (*a)());
+-void q_CRYPTO_free(void *a);
++void q_OPENSSL_free(void *a);
+ void q_DSA_free(DSA *a);
+ #if OPENSSL_VERSION_NUMBER >= 0x00908000L
+ // 0.9.8 broke SC and BC by changing this function's signature.
+@@ -326,7 +329,6 @@
+ void q_SSL_set_connect_state(SSL *a);
+ int q_SSL_shutdown(SSL *a);
+ #if OPENSSL_VERSION_NUMBER >= 0x10000000L
+-const SSL_METHOD *q_SSLv2_client_method();
+ const SSL_METHOD *q_SSLv3_client_method();
+ const SSL_METHOD *q_SSLv23_client_method();
+ const SSL_METHOD *q_TLSv1_client_method();
+@@ -335,7 +337,6 @@
+ const SSL_METHOD *q_SSLv23_server_method();
+ const SSL_METHOD *q_TLSv1_server_method();
+ #else
+-SSL_METHOD *q_SSLv2_client_method();
+ SSL_METHOD *q_SSLv3_client_method();
+ SSL_METHOD *q_SSLv23_client_method();
+ SSL_METHOD *q_TLSv1_client_method();
+@@ -415,7 +416,7 @@
+ X509_PUBKEY * q_X509_get_X509_PUBKEY(X509 *x);
+ int q_RSA_bits(const RSA *rsa);
+ int q_DSA_security_bits(const DSA *dsa);
+-void q_DSA_get0_pqg(const DSA *d, BIGNUM **p, BIGNUM **q, BIGNUM **g);
++void q_DSA_get0_pqg(const DSA *d, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g);
+ #endif
+ 
+ #define q_SKM_sk_num(type, st) ((int (*)(const STACK_OF(type) *))q_sk_num)(st)
diff --git a/pkgs/development/libraries/qt-5/5.11/default.nix b/pkgs/development/libraries/qt-5/5.11/default.nix
index f43329d3553..7f0937db30f 100644
--- a/pkgs/development/libraries/qt-5/5.11/default.nix
+++ b/pkgs/development/libraries/qt-5/5.11/default.nix
@@ -9,18 +9,17 @@ 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.
+3. Check that the new packages build correctly.
+4. Commit the changes and open a pull request.
 
 */
 
 {
   newScope,
-  stdenv, fetchurl, fetchFromGitHub, makeSetupHook,
+  stdenv, fetchurl, fetchFromGitHub, makeSetupHook, makeWrapper,
   bison, cups ? null, harfbuzz, libGL, perl,
   gstreamer, gst-plugins-base, gtk3, dconf,
-  cf-private, llvmPackages_5,
+  llvmPackages_5,
 
   # options
   developerBuild ? false,
@@ -32,7 +31,9 @@ with stdenv.lib;
 
 let
 
-  qtCompatVersion = "5.11";
+  qtCompatVersion = srcs.qtbase.version;
+
+  stdenvActual = if stdenv.cc.isClang then llvmPackages_5.stdenv else stdenv;
 
   mirror = "https://download.qt.io";
   srcs = import ./srcs.nix { inherit fetchurl; inherit mirror; } // {
@@ -64,16 +65,18 @@ let
     qtwebkit = [ ./qtwebkit.patch ];
   };
 
-  mkDerivation =
-    import ../mkDerivation.nix {
-      inherit (stdenv) lib;
-      stdenv = if stdenv.cc.isClang then llvmPackages_5.stdenv else stdenv;
-    }
-    { inherit debug; };
-
   qtModule =
     import ../qtModule.nix
-    { inherit mkDerivation perl; inherit (stdenv) lib; }
+    {
+      inherit perl;
+      inherit (stdenv) lib;
+      # Use a variant of mkDerivation that does not include wrapQtApplications
+      # to avoid cyclic dependencies between Qt modules.
+      mkDerivation =
+        import ../mkDerivation.nix
+        { inherit (stdenv) lib; inherit debug; wrapQtAppsHook = null; }
+        stdenvActual.mkDerivation;
+    }
     { inherit self srcs patches; };
 
   addPackages = self: with self;
@@ -81,7 +84,11 @@ let
       callPackage = self.newScope { inherit qtCompatVersion qtModule srcs; };
     in {
 
-      inherit mkDerivation;
+      mkDerivationWith =
+        import ../mkDerivation.nix
+        { inherit (stdenv) lib; inherit debug; inherit (self) wrapQtAppsHook; };
+
+      mkDerivation = mkDerivationWith stdenvActual.mkDerivation;
 
       qtbase = callPackage ../modules/qtbase.nix {
         inherit (srcs.qtbase) src version;
@@ -92,17 +99,13 @@ let
       };
 
       qtcharts = callPackage ../modules/qtcharts.nix {};
-      qtconnectivity = callPackage ../modules/qtconnectivity.nix {
-        inherit cf-private;
-      };
+      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 {
-        inherit cf-private;
-      };
+      qtmacextras = callPackage ../modules/qtmacextras.nix {};
       qtmultimedia = callPackage ../modules/qtmultimedia.nix {
         inherit gstreamer gst-plugins-base;
       };
@@ -146,6 +149,12 @@ let
           fix_qt_builtin_paths = ../hooks/fix-qt-builtin-paths.sh;
         };
       } ../hooks/qmake-hook.sh;
+
+      wrapQtAppsHook = makeSetupHook {
+        deps =
+          [ self.qtbase.dev makeWrapper ]
+          ++ optional stdenv.isLinux self.qtwayland.dev;
+      } ../hooks/wrap-qt-apps-hook.sh;
     };
 
    self = makeScope newScope addPackages;
diff --git a/pkgs/development/libraries/qt-5/5.11/qttools.patch b/pkgs/development/libraries/qt-5/5.11/qttools.patch
index fbba439ef7a..622efc35b6b 100644
--- a/pkgs/development/libraries/qt-5/5.11/qttools.patch
+++ b/pkgs/development/libraries/qt-5/5.11/qttools.patch
@@ -69,3 +69,18 @@ index 4318b16f..d60db4ff 100644
      _qt5_LinguistTools_check_file_exists(${imported_location})
  
      set_target_properties(Qt5::lconvert PROPERTIES
+--- a/src/macdeployqt/shared/shared.cpp
++++ b/src/macdeployqt/shared/shared.cpp
+@@ -1241,6 +1241,12 @@ bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInf
+     if (!QFile(qmlImportScannerPath).exists())
+         qmlImportScannerPath = QCoreApplication::applicationDirPath() + "/qmlimportscanner";
+ 
++#ifdef NIXPKGS_QMLIMPORTSCANNER
++    // Fallback: Nixpkgs hardcoded path
++    if (!QFile(qmlImportScannerPath).exists())
++        qmlImportScannerPath = NIXPKGS_QMLIMPORTSCANNER;
++#endif
++
+     // Verify that we found a qmlimportscanner binary
+     if (!QFile(qmlImportScannerPath).exists()) {
+         LogError() << "qmlimportscanner not found at" << qmlImportScannerPath;
diff --git a/pkgs/development/libraries/qt-5/5.12/default.nix b/pkgs/development/libraries/qt-5/5.12/default.nix
index ef0cf97a428..1bc63d0e2b9 100644
--- a/pkgs/development/libraries/qt-5/5.12/default.nix
+++ b/pkgs/development/libraries/qt-5/5.12/default.nix
@@ -9,18 +9,17 @@ 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.
+3. Check that the new packages build correctly.
+4. Commit the changes and open a pull request.
 
 */
 
 {
   newScope,
-  stdenv, fetchurl, fetchFromGitHub, makeSetupHook,
+  stdenv, fetchurl, fetchFromGitHub, makeSetupHook, makeWrapper,
   bison, cups ? null, harfbuzz, libGL, perl,
   gstreamer, gst-plugins-base, gtk3, dconf,
-  cf-private, llvmPackages_5,
+  llvmPackages_5,
 
   # options
   developerBuild ? false,
@@ -32,7 +31,9 @@ with stdenv.lib;
 
 let
 
-  qtCompatVersion = "5.12";
+  qtCompatVersion = srcs.qtbase.version;
+
+  stdenvActual = if stdenv.cc.isClang then llvmPackages_5.stdenv else stdenv;
 
   mirror = "https://download.qt.io";
   srcs = import ./srcs.nix { inherit fetchurl; inherit mirror; } // {
@@ -66,18 +67,21 @@ let
         ./qtwebkit-darwin-no-readline.patch
         ./qtwebkit-darwin-no-qos-classes.patch
       ];
+    qttools = [ ./qttools.patch ];
   };
 
-  mkDerivation =
-    import ../mkDerivation.nix {
-      inherit (stdenv) lib;
-      stdenv = if stdenv.cc.isClang then llvmPackages_5.stdenv else stdenv;
-    }
-    { inherit debug; };
-
   qtModule =
     import ../qtModule.nix
-    { inherit mkDerivation perl; inherit (stdenv) lib; }
+    {
+      inherit perl;
+      inherit (stdenv) lib;
+      # Use a variant of mkDerivation that does not include wrapQtApplications
+      # to avoid cyclic dependencies between Qt modules.
+      mkDerivation =
+        import ../mkDerivation.nix
+        { inherit (stdenv) lib; inherit debug; wrapQtAppsHook = null; }
+        stdenvActual.mkDerivation;
+    }
     { inherit self srcs patches; };
 
   addPackages = self: with self;
@@ -85,7 +89,11 @@ let
       callPackage = self.newScope { inherit qtCompatVersion qtModule srcs; };
     in {
 
-      inherit mkDerivation;
+      mkDerivationWith =
+        import ../mkDerivation.nix
+        { inherit (stdenv) lib; inherit debug; inherit (self) wrapQtAppsHook; };
+
+      mkDerivation = mkDerivationWith stdenvActual.mkDerivation;
 
       qtbase = callPackage ../modules/qtbase.nix {
         inherit (srcs.qtbase) src version;
@@ -96,17 +104,13 @@ let
       };
 
       qtcharts = callPackage ../modules/qtcharts.nix {};
-      qtconnectivity = callPackage ../modules/qtconnectivity.nix {
-        inherit cf-private;
-      };
+      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 {
-        inherit cf-private;
-      };
+      qtmacextras = callPackage ../modules/qtmacextras.nix {};
       qtmultimedia = callPackage ../modules/qtmultimedia.nix {
         inherit gstreamer gst-plugins-base;
       };
@@ -150,6 +154,12 @@ let
           fix_qt_builtin_paths = ../hooks/fix-qt-builtin-paths.sh;
         };
       } ../hooks/qmake-hook.sh;
+
+      wrapQtAppsHook = makeSetupHook {
+        deps =
+          [ self.qtbase.dev makeWrapper ]
+          ++ optional stdenv.isLinux self.qtwayland.dev;
+      } ../hooks/wrap-qt-apps-hook.sh;
     };
 
    self = makeScope newScope addPackages;
diff --git a/pkgs/development/libraries/qt-5/5.12/qtbase.patch b/pkgs/development/libraries/qt-5/5.12/qtbase.patch
index 68ebd56b76c..aa987acbe92 100644
--- a/pkgs/development/libraries/qt-5/5.12/qtbase.patch
+++ b/pkgs/development/libraries/qt-5/5.12/qtbase.patch
@@ -1094,3 +1094,63 @@ index 99d87e2e46..a4eab2aa72 100644
  !!ELSE
      set(imported_location \"$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
  !!ENDIF
+diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
+index b14a494296..779c4eda95 100644
+--- a/src/corelib/kernel/qcore_mac_p.h
++++ b/src/corelib/kernel/qcore_mac_p.h
+@@ -211,7 +211,7 @@ private:
+ 
+ // --------------------------------------------------------------------------
+ 
+-#if !defined(QT_BOOTSTRAPPED)
++#if 0
+ 
+ QT_END_NAMESPACE
+ #include <os/activity.h>
+@@ -289,7 +289,19 @@ QT_MAC_WEAK_IMPORT(_os_activity_current);
+ 
+ #define QT_APPLE_SCOPED_LOG_ACTIVITY(...) QAppleLogActivity scopedLogActivity = QT_APPLE_LOG_ACTIVITY(__VA_ARGS__).enter();
+ 
+-#endif // !defined(QT_BOOTSTRAPPED)
++#else // !defined(QT_BOOTSTRAPPED)
++
++#define QT_APPLE_LOG_ACTIVITY_WITH_PARENT3(...)
++#define QT_APPLE_LOG_ACTIVITY_WITH_PARENT2(...)
++#define QT_APPLE_LOG_ACTIVITY_WITH_PARENT(...)
++
++#define QT_APPLE_LOG_ACTIVITY2(...)
++#define QT_APPLE_LOG_ACTIVITY1(...)
++#define QT_APPLE_LOG_ACTIVITY(...)
++
++#define QT_APPLE_SCOPED_LOG_ACTIVITY(...)
++
++#endif
+ 
+ // -------------------------------------------------------------------------
+ 
+diff --git a/src/testlib/qappletestlogger.cpp b/src/testlib/qappletestlogger.cpp
+index 2c1005ad80..244147ea7d 100644
+--- a/src/testlib/qappletestlogger.cpp
++++ b/src/testlib/qappletestlogger.cpp
+@@ -43,7 +43,7 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#if defined(QT_USE_APPLE_UNIFIED_LOGGING)
++#if defined(QT_USE_APPLE_UNIFIED_LOGGING) && 0
+ 
+ using namespace QTestPrivate;
+ 
+diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp
+index 1268730cc6..a50e9b0764 100644
+--- a/src/testlib/qtestlog.cpp
++++ b/src/testlib/qtestlog.cpp
+@@ -524,7 +524,7 @@ void QTestLog::addLogger(LogMode mode, const char *filename)
+ #endif
+     }
+ 
+-#if defined(QT_USE_APPLE_UNIFIED_LOGGING)
++#if defined(QT_USE_APPLE_UNIFIED_LOGGING) && 0
+     // Logger that also feeds messages to AUL. It needs to wrap the existing
+     // logger, as it needs to be able to short circuit the existing logger
+     // in case AUL prints to stderr.
diff --git a/pkgs/development/libraries/qt-5/5.12/qttools.patch b/pkgs/development/libraries/qt-5/5.12/qttools.patch
new file mode 100644
index 00000000000..8ae12198ca2
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.12/qttools.patch
@@ -0,0 +1,15 @@
+--- a/src/macdeployqt/shared/shared.cpp
++++ b/src/macdeployqt/shared/shared.cpp
+@@ -1241,6 +1241,12 @@ bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInf
+     if (!QFile(qmlImportScannerPath).exists())
+         qmlImportScannerPath = QCoreApplication::applicationDirPath() + "/qmlimportscanner";
+ 
++#ifdef NIXPKGS_QMLIMPORTSCANNER
++    // Fallback: Nixpkgs hardcoded path
++    if (!QFile(qmlImportScannerPath).exists())
++        qmlImportScannerPath = NIXPKGS_QMLIMPORTSCANNER;
++#endif
++
+     // Verify that we found a qmlimportscanner binary
+     if (!QFile(qmlImportScannerPath).exists()) {
+         LogError() << "qmlimportscanner not found at" << qmlImportScannerPath;
diff --git a/pkgs/development/libraries/qt-5/5.12/qtwebengine-darwin-no-platform-check.patch b/pkgs/development/libraries/qt-5/5.12/qtwebengine-darwin-no-platform-check.patch
index 364330169bf..546e753144d 100644
--- a/pkgs/development/libraries/qt-5/5.12/qtwebengine-darwin-no-platform-check.patch
+++ b/pkgs/development/libraries/qt-5/5.12/qtwebengine-darwin-no-platform-check.patch
@@ -19,3 +19,15 @@ diff --git a/mkspecs/features/platform.prf b/mkspecs/features/platform.prf
      }
    } else {
      skipBuild("Unknown platform. Qt WebEngine only supports Linux, Windows, and macOS.")
+diff --git a/src/core/config/mac_osx.pri b/src/core/config/mac_osx.pri
+--- a/src/core/config/mac_osx.pri
++++ b/src/core/config/mac_osx.pri
+@@ -5,8 +5,6 @@ load(functions)
+ # otherwise query for it.
+ QMAKE_MAC_SDK_VERSION = $$eval(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.SDKVersion)
+ isEmpty(QMAKE_MAC_SDK_VERSION) {
+-     QMAKE_MAC_SDK_VERSION = $$system("/usr/bin/xcodebuild -sdk $${QMAKE_MAC_SDK} -version SDKVersion 2>/dev/null")
+-     isEmpty(QMAKE_MAC_SDK_VERSION): error("Could not resolve SDK version for \'$${QMAKE_MAC_SDK}\'")
+ }
+
+ QMAKE_CLANG_DIR = "/usr"
diff --git a/pkgs/development/libraries/qt-5/5.6/default.nix b/pkgs/development/libraries/qt-5/5.6/default.nix
deleted file mode 100644
index e493fc169ab..00000000000
--- a/pkgs/development/libraries/qt-5/5.6/default.nix
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
-
-# New packages
-
-READ THIS FIRST
-
-This module is for official packages in Qt 5. All available packages are listed
-in `./srcs.nix`, although a few are not yet packaged in Nixpkgs (see below).
-
-IF YOUR PACKAGE IS NOT LISTED IN `./srcs.nix`, IT DOES NOT GO HERE.
-
-Many of the packages released upstream are not yet built in Nixpkgs due to lack
-of demand. To add a Nixpkgs build for an upstream package, copy one of the
-existing packages here and modify it as necessary.
-
-# Updates
-
-1. Update the URL in `./fetch.sh`.
-2. Run `./maintainers/scripts/fetch-kde-qt.sh pkgs/development/libraries/qt-5/$VERSION/`
-   from the top of the Nixpkgs tree.
-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, fetchpatch, makeSetupHook,
-  bison, cups ? null, harfbuzz, libGL, perl,
-  gstreamer, gst-plugins-base,
-  cf-private,
-
-  # options
-  developerBuild ? false,
-  decryptSslTraffic ? false,
-  debug ? false,
-}:
-
-with stdenv.lib;
-
-let
-
-  qtCompatVersion = "5.6";
-
-  mirror = "http://download.qt.io";
-  srcs = import ./srcs.nix { inherit fetchurl; inherit mirror; };
-
-  patches = {
-    qtbase = [
-      ./qtbase.patch
-      ./qtbase-fixguicmake.patch
-      (fetchpatch {
-        name = "CVE-2018-15518.patch";
-        url = "https://codereview.qt-project.org/gitweb?p=qt/qtbase.git;a=patch;h=28a6e642af2ccb454dd019f551c2908753f76f08";
-        sha256 = "0nyssg7d0br7qgzp481f1w8b4p1bj2ggv9iyfrm1mng5v9fypdd7";
-      })
-      (fetchpatch {
-        name = "CVE-2018-19873.patch";
-        url = "https://codereview.qt-project.org/gitweb?p=qt/qtbase.git;a=patch;h=c9b9f663d7243988bcb5fee9180ea9cb3a321a86";
-        sha256 = "1q01cafy92c1j8cgrv4sk133mi3d48x8kbg3glbnnbijpc4k6di5";
-      })
-      (fetchpatch {
-        name = "CVE-2018-19870.patch";
-        url = "http://code.qt.io/cgit/qt/qtbase.git/patch/?id=ac0a910756f91726e03c0e6a89d213bdb4f48fec";
-        sha256 = "00qb9yqwvwnp202am3lqirkjxln1cj8v4wvmlyqya6hna176lj2l";
-      })
-    ];
-    qtdeclarative = [ ./qtdeclarative.patch ];
-    qtscript = [ ./qtscript.patch ];
-    qtserialport = [ ./qtserialport.patch ];
-    qttools = [ ./qttools.patch ];
-    qtwebengine = [ ./qtwebengine-seccomp.patch ];
-    qtwebkit = [ ./qtwebkit.patch ];
-    qtvirtualkeyboard = [
-      (fetchpatch {
-        name = "CVE-2018-19865-A.patch";
-        url = "https://codereview.qt-project.org/gitweb?p=qt/qtvirtualkeyboard.git;a=patch;h=c02115db1de1f3aba81e109043766d600f886522";
-        sha256 = "0ncnyl8f3ypi1kcb9z2i8j33snix111h28njrx8rb49ny01ap8x2";
-      })
-      (fetchpatch {
-        name = "CVE-2018-19865-B.patch";
-        url = "https://codereview.qt-project.org/gitweb?p=qt/qtvirtualkeyboard.git;a=patch;h=01fc537adc74d5e102c8cc93384cdf5cb08b4442";
-        sha256 = "19z8kxqf2lpjqr8189ingrpadch4niviw3p5v93zgx24v7950q27";
-      })
-      (fetchpatch {
-        name = "CVE-2018-19865-C.patch";
-        url = "https://codereview.qt-project.org/gitweb?p=qt/qtvirtualkeyboard.git;a=patch;h=993a21ba03534b172d5354405cc9d50a2a822e24";
-        sha256 = "1bipqxr9bvy8z402pv9kj2w1yzcsj1v03l09pg5jyg1xh6jbgiky";
-      })
-    ];
-    qtimageformats = [
-      (fetchpatch {
-        name = "CVE-2018-19871.patch";
-        url = "https://codereview.qt-project.org/gitweb?p=qt/qtimageformats.git;a=patch;h=9299ab07df61c56b70e047f1fe5f06b6ff541aa3";
-        sha256 = "0fd3mxdlc0s405j02bc0g72fvdfvpi31a837xfwf40m5j4jbyndr";
-      })
-    ];
-    qtsvg = [
-      (fetchpatch {
-        name = "CVE-2018-19869.patch";
-        url = "http://code.qt.io/cgit/qt/qtsvg.git/patch/?id=c5f1dd14098d1cc2cb52448fb44f53966d331443";
-        sha256 = "1kgyfsxw2f0qv5fx9y7wysjsvqikam0qc7wzhklf0406zz6rhxbl";
-      })
-    ];
-  };
-
-  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 bison cups harfbuzz libGL;
-        inherit (srcs.qtbase) src version;
-        patches = patches.qtbase;
-        inherit developerBuild decryptSslTraffic;
-      };
-
-      /* qt3d = not packaged */
-      /* qtactiveqt = not packaged */
-      /* qtandroidextras = not packaged */
-      /* qtcanvas3d = not packaged */
-      qtconnectivity = callPackage ../modules/qtconnectivity.nix {
-        inherit cf-private;
-      };
-      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 ../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 {};
-      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 ../modules/qtx11extras.nix {};
-      qtxmlpatterns = callPackage ../modules/qtxmlpatterns.nix {};
-      qtvirtualkeyboard = callPackage ../modules/qtvirtualkeyboard.nix {};
-
-      env = callPackage ../qt-env.nix {};
-      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; };
-      } ../hooks/qmake-hook.sh;
-    };
-
-   self = makeScope newScope addPackages;
-
-in self
diff --git a/pkgs/development/libraries/qt-5/5.6/fetch.sh b/pkgs/development/libraries/qt-5/5.6/fetch.sh
deleted file mode 100644
index bb9eb66a01d..00000000000
--- a/pkgs/development/libraries/qt-5/5.6/fetch.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-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/ )
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase-fixguicmake.patch b/pkgs/development/libraries/qt-5/5.6/qtbase-fixguicmake.patch
deleted file mode 100644
index 8b46d432812..00000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase-fixguicmake.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
-index 0bbc871..3673634 100644
---- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
-+++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
-@@ -286,7 +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})
- 
--        set(imported_location \"$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
-+        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}
-diff --git a/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in b/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
-index 5baf0fd..3583745 100644
---- a/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
-+++ b/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 \"$${CMAKE_PLUGIN_DIR}$${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 \"$${CMAKE_PLUGIN_DIR}$${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.patch b/pkgs/development/libraries/qt-5/5.6/qtbase.patch
deleted file mode 100644
index d8322cbc199..00000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase.patch
+++ /dev/null
@@ -1,795 +0,0 @@
-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/qtdeclarative.patch b/pkgs/development/libraries/qt-5/5.6/qtdeclarative.patch
deleted file mode 100644
index dbddaa2a1d6..00000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtdeclarative.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-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);
- 
-+    // 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/qtscript.patch b/pkgs/development/libraries/qt-5/5.6/qtscript.patch
deleted file mode 100644
index 5508dec1280..00000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtscript.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-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.6/qtserialport.patch b/pkgs/development/libraries/qt-5/5.6/qtserialport.patch
deleted file mode 100644
index b2cffbe4f39..00000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtserialport.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-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()) {
-+#ifdef NIXPKGS_LIBUDEV
-+        udevLibrary->setFileNameAndVersion(QLatin1String(NIXPKGS_LIBUDEV), 1);
-+#else
-         udevLibrary->setFileNameAndVersion(QStringLiteral("udev"), 1);
-+#endif
-         if (!udevLibrary->load()) {
-+#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;
diff --git a/pkgs/development/libraries/qt-5/5.6/qttools.patch b/pkgs/development/libraries/qt-5/5.6/qttools.patch
deleted file mode 100644
index dcb15e0e55a..00000000000
--- a/pkgs/development/libraries/qt-5/5.6/qttools.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-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/qtwebengine-seccomp.patch b/pkgs/development/libraries/qt-5/5.6/qtwebengine-seccomp.patch
deleted file mode 100644
index bf6af805982..00000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtwebengine-seccomp.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-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/qtwebkit.patch b/pkgs/development/libraries/qt-5/5.6/qtwebkit.patch
deleted file mode 100644
index da1658554e4..00000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtwebkit.patch
+++ /dev/null
@@ -1,149 +0,0 @@
-diff --git a/Source/JavaScriptCore/API/JSStringRef.cpp b/Source/JavaScriptCore/API/JSStringRef.cpp
-index 812f3d413..77a3fd0f4 100644
---- a/Source/JavaScriptCore/API/JSStringRef.cpp
-+++ b/Source/JavaScriptCore/API/JSStringRef.cpp
-@@ -37,7 +37,7 @@ using namespace WTF::Unicode;
- JSStringRef JSStringCreateWithCharacters(const JSChar* chars, size_t numChars)
- {
-     initializeThreading();
--    return OpaqueJSString::create(chars, numChars).leakRef();
-+    return OpaqueJSString::create(reinterpret_cast<const UChar*>(chars), numChars).leakRef();
- }
- 
- JSStringRef JSStringCreateWithUTF8CString(const char* string)
-@@ -62,7 +62,7 @@ JSStringRef JSStringCreateWithUTF8CString(const char* string)
- JSStringRef JSStringCreateWithCharactersNoCopy(const JSChar* chars, size_t numChars)
- {
-     initializeThreading();
--    return OpaqueJSString::create(StringImpl::createWithoutCopying(chars, numChars, WTF::DoesNotHaveTerminatingNullCharacter)).leakRef();
-+    return OpaqueJSString::create(StringImpl::createWithoutCopying(reinterpret_cast<const UChar*>(chars), numChars, WTF::DoesNotHaveTerminatingNullCharacter)).leakRef();
- }
- 
- JSStringRef JSStringRetain(JSStringRef string)
-@@ -83,7 +83,7 @@ size_t JSStringGetLength(JSStringRef string)
- 
- const JSChar* JSStringGetCharactersPtr(JSStringRef string)
- {
--    return string->characters();
-+    return reinterpret_cast<const JSChar*>(string->characters());
- }
- 
- size_t JSStringGetMaximumUTF8CStringSize(JSStringRef string)
-diff --git a/Source/JavaScriptCore/runtime/DateConversion.cpp b/Source/JavaScriptCore/runtime/DateConversion.cpp
-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
- #if OS(WINDOWS)
-             TIME_ZONE_INFORMATION timeZoneInformation;
-             GetTimeZoneInformation(&timeZoneInformation);
--            const WCHAR* timeZoneName = t.isDST() ? timeZoneInformation.DaylightName : timeZoneInformation.StandardName;
-+            const WCHAR* winTimeZoneName = t.isDST() ? timeZoneInformation.DaylightName : timeZoneInformation.StandardName;
-+            String timeZoneName(reinterpret_cast<const UChar*>(winTimeZoneName));
- #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 9df2c95cf..f5d6121fd 100644
---- a/Source/WTF/wtf/TypeTraits.h
-+++ b/Source/WTF/wtf/TypeTraits.h
-@@ -72,6 +72,9 @@ namespace WTF {
-     template<> struct IsInteger<unsigned long>      { static const bool value = true; };
-     template<> struct IsInteger<long long>          { static const bool value = true; };
-     template<> struct IsInteger<unsigned long long> { static const bool value = true; };
-+#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(_HAS_CHAR16_T_LANGUAGE_SUPPORT) && _HAS_CHAR16_T_LANGUAGE_SUPPORT)
-+    template<> struct IsInteger<char16_t>           { static const bool value = true; };
-+#endif
- #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 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)
- size_t WKStringGetCharacters(WKStringRef stringRef, WKChar* buffer, size_t bufferLength)
- {
-     COMPILE_ASSERT(sizeof(WKChar) == sizeof(UChar), WKStringGetCharacters_sizeof_WKChar_matches_UChar);
--    return (toImpl(stringRef)->getCharacters(static_cast<UChar*>(buffer), bufferLength));
-+    return (toImpl(stringRef)->getCharacters(reinterpret_cast<UChar*>(buffer), bufferLength));
- }
- 
- 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/srcs.nix b/pkgs/development/libraries/qt-5/5.6/srcs.nix
deleted file mode 100644
index 87d35a43d86..00000000000
--- a/pkgs/development/libraries/qt-5/5.6/srcs.nix
+++ /dev/null
@@ -1,309 +0,0 @@
-# DO NOT EDIT! This file is generated automatically by fetch-kde-qt.sh
-{ fetchurl, mirror }:
-
-{
-  qt3d = {
-    version = "5.6.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.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.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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.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.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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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.3";
-    src = fetchurl {
-      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 9baca8124bd..b27c5d3eb58 100644
--- a/pkgs/development/libraries/qt-5/5.9/default.nix
+++ b/pkgs/development/libraries/qt-5/5.9/default.nix
@@ -9,18 +9,16 @@ 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.
+3. Check that the new packages build correctly.
+4. Commit the changes and open a pull request.
 
 */
 
 {
   newScope,
-  stdenv, fetchurl, fetchpatch, makeSetupHook,
+  stdenv, fetchurl, fetchpatch, makeSetupHook, makeWrapper,
   bison, cups ? null, harfbuzz, libGL, perl,
   gstreamer, gst-plugins-base, gtk3, dconf,
-  cf-private,
 
   # options
   developerBuild ? false,
@@ -32,13 +30,17 @@ with stdenv.lib;
 
 let
 
-  qtCompatVersion = "5.9";
+  qtCompatVersion = srcs.qtbase.version;
 
   mirror = "http://download.qt.io";
   srcs = import ./srcs.nix { inherit fetchurl; inherit mirror; };
 
   patches = {
-    qtbase = [ ./qtbase.patch ./qtbase-fixguicmake.patch ];
+    qtbase = [
+      ./qtbase.patch
+      ./qtbase-fixguicmake.patch
+      ./qtbase-openssl_1_1.patch
+    ];
     qtdeclarative = [ ./qtdeclarative.patch ];
     qtscript = [ ./qtscript.patch ];
     qtserialport = [ ./qtserialport.patch ];
@@ -68,14 +70,18 @@ let
 
   };
 
-  mkDerivation =
-    import ../mkDerivation.nix
-    { inherit stdenv; inherit (stdenv) lib; }
-    { inherit debug; };
-
   qtModule =
     import ../qtModule.nix
-    { inherit mkDerivation perl; inherit (stdenv) lib; }
+    {
+      inherit perl;
+      inherit (stdenv) lib;
+      # Use a variant of mkDerivation that does not include wrapQtApplications
+      # to avoid cyclic dependencies between Qt modules.
+      mkDerivation =
+        import ../mkDerivation.nix
+        { inherit (stdenv) lib; inherit debug; wrapQtAppsHook = null; }
+        stdenv.mkDerivation;
+    }
     { inherit self srcs patches; };
 
   addPackages = self: with self;
@@ -83,7 +89,11 @@ let
       callPackage = self.newScope { inherit qtCompatVersion qtModule srcs; };
     in {
 
-      inherit mkDerivation;
+      mkDerivationWith =
+        import ../mkDerivation.nix
+        { inherit (stdenv) lib; inherit debug; inherit (self) wrapQtAppsHook; };
+
+      mkDerivation = mkDerivationWith stdenv.mkDerivation;
 
       qtbase = callPackage ../modules/qtbase.nix {
         inherit (srcs.qtbase) src version;
@@ -94,17 +104,13 @@ let
       };
 
       qtcharts = callPackage ../modules/qtcharts.nix {};
-      qtconnectivity = callPackage ../modules/qtconnectivity.nix {
-        inherit cf-private;
-      };
+      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 {
-        inherit cf-private;
-      };
+      qtmacextras = callPackage ../modules/qtmacextras.nix {};
       qtmultimedia = callPackage ../modules/qtmultimedia.nix {
         inherit gstreamer gst-plugins-base;
       };
@@ -145,6 +151,12 @@ let
           fix_qt_builtin_paths = ../hooks/fix-qt-builtin-paths.sh;
         };
       } ../hooks/qmake-hook.sh;
+
+      wrapQtAppsHook = makeSetupHook {
+        deps =
+          [ self.qtbase.dev makeWrapper ]
+          ++ optional stdenv.isLinux self.qtwayland.dev;
+      } ../hooks/wrap-qt-apps-hook.sh;
     };
 
    self = makeScope newScope addPackages;
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase-openssl_1_1.patch b/pkgs/development/libraries/qt-5/5.9/qtbase-openssl_1_1.patch
new file mode 100644
index 00000000000..d5f4d7527cb
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.9/qtbase-openssl_1_1.patch
@@ -0,0 +1,3985 @@
+commit 2d88fc0ce4ac76924a65ffd797183de9422ba672
+Author: Andreas Rammhold <andreas@rammhold.de>
+Date:   Wed Mar 6 00:18:51 2019 +0100
+
+    openssl1.1 compat
+
+diff --git a/config.tests/openssl/openssl.cpp b/config.tests/openssl/openssl.cpp
+index 6c8a9e8f19..d33b62389c 100644
+--- a/config.tests/openssl/openssl.cpp
++++ b/config.tests/openssl/openssl.cpp
+@@ -39,8 +39,8 @@
+ 
+ #include <openssl/opensslv.h>
+ 
+-#if !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER-0 < 0x0090700fL || OPENSSL_VERSION_NUMBER-0 >= 0x10100000L
+-#  error "OpenSSL >= 0.9.7, and < 1.1.0 is required"
++#if !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER-0 < 0x0090700fL
++#  error "OpenSSL >= 0.9.7 is required"
+ #endif
+ 
+ #include <openssl/ssl.h>
+diff --git a/config.tests/openssl11/openssl.cpp b/config.tests/openssl11/openssl.cpp
+new file mode 100644
+index 0000000000..c20cc59deb
+--- /dev/null
++++ b/config.tests/openssl11/openssl.cpp
+@@ -0,0 +1,48 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the config.tests of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:LGPL$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** GNU Lesser General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU Lesser
++** General Public License version 3 as published by the Free Software
++** Foundation and appearing in the file LICENSE.LGPL3 included in the
++** packaging of this file. Please review the following information to
++** ensure the GNU Lesser General Public License version 3 requirements
++** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
++**
++** GNU General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU
++** General Public License version 2.0 or (at your option) the GNU General
++** Public license version 3 or any later version approved by the KDE Free
++** Qt Foundation. The licenses are as published by the Free Software
++** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
++** included in the packaging of this file. Please review the following
++** information to ensure the GNU General Public License requirements will
++** be met: https://www.gnu.org/licenses/gpl-2.0.html and
++** https://www.gnu.org/licenses/gpl-3.0.html.
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++#include <openssl/opensslv.h>
++
++#if !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER-0 < 0x10100000L
++#  error "OpenSSL >= 1.1 is required"
++#endif
++
++int main()
++{
++}
+diff --git a/config.tests/openssl11/openssl11.pro b/config.tests/openssl11/openssl11.pro
+new file mode 100644
+index 0000000000..a023aee4aa
+--- /dev/null
++++ b/config.tests/openssl11/openssl11.pro
+@@ -0,0 +1,2 @@
++SOURCES = openssl.cpp
++CONFIG -= x11 qt
+diff --git a/src/network/configure.json b/src/network/configure.json
+index 2cf90ed94b..a021c0734b 100644
+--- a/src/network/configure.json
++++ b/src/network/configure.json
+@@ -77,6 +77,17 @@
+                 },
+                 { "libs": "-lssl -lcrypto", "condition": "!config.win32" }
+             ]
++        },
++        "openssl11": {
++            "label": "OpenSSL v. 1.1 support",
++            "type": "compile",
++            "test": "openssl11",
++	    "sources": [
++		{
++                    "comment": "placeholder for OPENSSL_PATH",
++                    "libs": ""
++                }
++	    ]
+         }
+     },
+ 
+@@ -182,7 +193,7 @@
+             "enable": "input.openssl == 'yes' || input.openssl == 'linked' || input.openssl == 'runtime'",
+             "disable": "input.openssl == 'no' || input.ssl == 'no'",
+             "autoDetect": "!config.winrt",
+-            "condition": "!features.securetransport && (features.openssl-linked || libs.openssl_headers)",
++            "condition": "!features.securetransport && (features.openssl-linked || libs.openssl_headers || feature.opensslv11)",
+             "output": [
+                 "privateFeature",
+                 { "type": "publicQtConfig", "condition": "!features.openssl-linked" },
+@@ -193,7 +204,7 @@
+             "label": "  Qt directly linked to OpenSSL",
+             "enable": "input.openssl == 'linked'",
+             "disable": "input.openssl != 'linked'",
+-            "condition": "!features.securetransport && libs.openssl",
++            "condition": "!features.securetransport && (libs.openssl || feature.opensslv11)",
+             "output": [
+                 "privateFeature",
+                 { "type": "define", "name": "QT_LINKED_OPENSSL" }
+@@ -213,6 +224,11 @@
+             "condition": "config.winrt || features.securetransport || features.openssl",
+             "output": [ "publicFeature", "feature" ]
+         },
++        "opensslv11": {
++            "label": "OpenSSL v. 1.1",
++            "condition": "libs.openssl11",
++            "output": ["publicFeature", "feature"]
++        },
+         "sctp": {
+             "label": "SCTP",
+             "autoDetect": false,
+diff --git a/src/network/ssl/qsslcertificate_openssl.cpp b/src/network/ssl/qsslcertificate_openssl.cpp
+index 28b7eda54a..71e514a025 100644
+--- a/src/network/ssl/qsslcertificate_openssl.cpp
++++ b/src/network/ssl/qsslcertificate_openssl.cpp
+@@ -1,6 +1,7 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2017 The Qt Company Ltd.
++** Copyright (C) 2016 Richard J. Moore <rich@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtNetwork module of the Qt Toolkit.
+@@ -64,12 +65,14 @@ bool QSslCertificate::operator==(const QSslCertificate &other) const
+ uint qHash(const QSslCertificate &key, uint seed) Q_DECL_NOTHROW
+ {
+     if (X509 * const x509 = key.d->x509) {
+-        (void)q_X509_cmp(x509, x509); // populate x509->sha1_hash
+-                                      // (if someone knows a better way...)
+-        return qHashBits(x509->sha1_hash, SHA_DIGEST_LENGTH, seed);
+-    } else {
+-        return seed;
++        const EVP_MD *sha1 = q_EVP_sha1();
++        unsigned int len = 0;
++        unsigned char md[EVP_MAX_MD_SIZE];
++        q_X509_digest(x509, sha1, md, &len);
++        return qHashBits(md, len, seed);
+     }
++
++    return seed;
+ }
+ 
+ bool QSslCertificate::isNull() const
+@@ -89,8 +92,7 @@ QByteArray QSslCertificate::version() const
+ {
+     QMutexLocker lock(QMutexPool::globalInstanceGet(d.data()));
+     if (d->versionString.isEmpty() && d->x509)
+-        d->versionString =
+-            QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->version)) + 1);
++        d->versionString = QByteArray::number(qlonglong(q_X509_get_version(d->x509)) + 1);
+ 
+     return d->versionString;
+ }
+@@ -99,7 +101,7 @@ QByteArray QSslCertificate::serialNumber() const
+ {
+     QMutexLocker lock(QMutexPool::globalInstanceGet(d.data()));
+     if (d->serialNumberString.isEmpty() && d->x509) {
+-        ASN1_INTEGER *serialNumber = d->x509->cert_info->serialNumber;
++        ASN1_INTEGER *serialNumber = q_X509_get_serialNumber(d->x509);
+         QByteArray hexString;
+         hexString.reserve(serialNumber->length * 3);
+         for (int a = 0; a < serialNumber->length; ++a) {
+@@ -199,14 +201,15 @@ QMultiMap<QSsl::AlternativeNameEntryType, QString> QSslCertificate::subjectAlter
+                 continue;
+             }
+ 
+-            const char *altNameStr = reinterpret_cast<const char *>(q_ASN1_STRING_data(genName->d.ia5));
++            const char *altNameStr = reinterpret_cast<const char *>(q_ASN1_STRING_get0_data(genName->d.ia5));
+             const QString altName = QString::fromLatin1(altNameStr, len);
+             if (genName->type == GEN_DNS)
+                 result.insert(QSsl::DnsEntry, altName);
+             else if (genName->type == GEN_EMAIL)
+                 result.insert(QSsl::EmailEntry, altName);
+         }
+-        q_sk_pop_free((STACK*)altNames, reinterpret_cast<void(*)(void*)>(q_sk_free));
++
++        q_OPENSSL_sk_pop_free((OPENSSL_STACK*)altNames, reinterpret_cast<void(*)(void*)>(q_OPENSSL_sk_free));
+     }
+ 
+     return result;
+@@ -235,25 +238,26 @@ QSslKey QSslCertificate::publicKey() const
+     QSslKey key;
+ 
+     key.d->type = QSsl::PublicKey;
+-    X509_PUBKEY *xkey = d->x509->cert_info->key;
+-    EVP_PKEY *pkey = q_X509_PUBKEY_get(xkey);
++
++    EVP_PKEY *pkey = q_X509_get_pubkey(d->x509);
+     Q_ASSERT(pkey);
++    const int keyType = q_EVP_PKEY_type(q_EVP_PKEY_base_id(pkey));
+ 
+-    if (q_EVP_PKEY_type(pkey->type) == EVP_PKEY_RSA) {
++    if (keyType == EVP_PKEY_RSA) {
+         key.d->rsa = q_EVP_PKEY_get1_RSA(pkey);
+         key.d->algorithm = QSsl::Rsa;
+         key.d->isNull = false;
+-    } else if (q_EVP_PKEY_type(pkey->type) == EVP_PKEY_DSA) {
++    } else if (keyType == EVP_PKEY_DSA) {
+         key.d->dsa = q_EVP_PKEY_get1_DSA(pkey);
+         key.d->algorithm = QSsl::Dsa;
+         key.d->isNull = false;
+ #ifndef OPENSSL_NO_EC
+-    } else if (q_EVP_PKEY_type(pkey->type) == EVP_PKEY_EC) {
++    } else if (keyType == EVP_PKEY_EC) {
+         key.d->ec = q_EVP_PKEY_get1_EC_KEY(pkey);
+         key.d->algorithm = QSsl::Ec;
+         key.d->isNull = false;
+ #endif
+-    } else if (q_EVP_PKEY_type(pkey->type) == EVP_PKEY_DH) {
++    } else if (keyType == EVP_PKEY_DH) {
+         // DH unsupported
+     } else {
+         // error?
+@@ -275,7 +279,7 @@ static QVariant x509UnknownExtensionToValue(X509_EXTENSION *ext)
+     X509V3_EXT_METHOD *meth = const_cast<X509V3_EXT_METHOD *>(q_X509V3_EXT_get(ext));
+     if (!meth) {
+         ASN1_OCTET_STRING *value = q_X509_EXTENSION_get_data(ext);
+-        QByteArray result( reinterpret_cast<const char *>(q_ASN1_STRING_data(value)),
++        QByteArray result( reinterpret_cast<const char *>(q_ASN1_STRING_get0_data(value)),
+                            q_ASN1_STRING_length(value));
+         return result;
+     }
+@@ -371,7 +375,7 @@ static QVariant x509ExtensionToValue(X509_EXTENSION *ext)
+                         continue;
+                     }
+ 
+-                    const char *uriStr = reinterpret_cast<const char *>(q_ASN1_STRING_data(name->d.uniformResourceIdentifier));
++                    const char *uriStr = reinterpret_cast<const char *>(q_ASN1_STRING_get0_data(name->d.uniformResourceIdentifier));
+                     const QString uri = QString::fromUtf8(uriStr, len);
+ 
+                     result[QString::fromUtf8(QSslCertificatePrivate::asn1ObjectName(ad->method))] = uri;
+@@ -380,11 +384,7 @@ static QVariant x509ExtensionToValue(X509_EXTENSION *ext)
+                 }
+             }
+ 
+-#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+-            q_sk_pop_free((_STACK*)info, reinterpret_cast<void(*)(void*)>(q_sk_free));
+-#else
+-            q_sk_pop_free((STACK*)info, reinterpret_cast<void(*)(void*)>(q_sk_free));
+-#endif
++            q_OPENSSL_sk_pop_free((OPENSSL_STACK*)info, reinterpret_cast<void(*)(void *)>(q_OPENSSL_sk_free));
+             return result;
+         }
+         break;
+@@ -607,7 +607,11 @@ static QMap<QByteArray, QString> _q_mapFromX509Name(X509_NAME *name)
+         unsigned char *data = 0;
+         int size = q_ASN1_STRING_to_UTF8(&data, q_X509_NAME_ENTRY_get_data(e));
+         info.insertMulti(name, QString::fromUtf8((char*)data, size));
++#if QT_CONFIG(opensslv11)
++        q_CRYPTO_free(data, 0, 0);
++#else
+         q_CRYPTO_free(data);
++#endif
+     }
+ 
+     return info;
+@@ -619,8 +623,9 @@ QSslCertificate QSslCertificatePrivate::QSslCertificate_from_X509(X509 *x509)
+     if (!x509 || !QSslSocket::supportsSsl())
+         return certificate;
+ 
+-    ASN1_TIME *nbef = q_X509_get_notBefore(x509);
+-    ASN1_TIME *naft = q_X509_get_notAfter(x509);
++    ASN1_TIME *nbef = q_X509_getm_notBefore(x509);
++    ASN1_TIME *naft = q_X509_getm_notAfter(x509);
++
+     certificate.d->notValidBefore = q_getTimeFromASN1(nbef);
+     certificate.d->notValidAfter = q_getTimeFromASN1(naft);
+     certificate.d->null = false;
+diff --git a/src/network/ssl/qsslcontext_openssl.cpp b/src/network/ssl/qsslcontext_openssl.cpp
+index c92d8fc3f8..cef503710c 100644
+--- a/src/network/ssl/qsslcontext_openssl.cpp
++++ b/src/network/ssl/qsslcontext_openssl.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2017 The Qt Company Ltd.
+ ** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+ ** Copyright (C) 2014 Governikus GmbH & Co. KG.
+ ** Contact: https://www.qt.io/licensing/
+@@ -41,22 +41,14 @@
+ 
+ 
+ #include <QtNetwork/qsslsocket.h>
+-#include <QtNetwork/qssldiffiehellmanparameters.h>
+-#include <QtCore/qmutex.h>
+ 
+ #include "private/qssl_p.h"
+ #include "private/qsslcontext_openssl_p.h"
+-#include "private/qsslsocket_p.h"
+ #include "private/qsslsocket_openssl_p.h"
+ #include "private/qsslsocket_openssl_symbols_p.h"
+-#include "private/qssldiffiehellmanparameters_p.h"
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// defined in qsslsocket_openssl.cpp:
+-extern int q_X509Callback(int ok, X509_STORE_CTX *ctx);
+-extern QString getErrorsFromOpenSsl();
+-
+ QSslContext::QSslContext()
+     : ctx(0),
+     pkey(0),
+@@ -78,301 +70,6 @@ QSslContext::~QSslContext()
+         q_SSL_SESSION_free(session);
+ }
+ 
+-static inline QString msgErrorSettingEllipticCurves(const QString &why)
+-{
+-    return QSslSocket::tr("Error when setting the elliptic curves (%1)").arg(why);
+-}
+-
+-// static
+-void QSslContext::initSslContext(QSslContext *sslContext, QSslSocket::SslMode mode, const QSslConfiguration &configuration, bool allowRootCertOnDemandLoading)
+-{
+-    sslContext->sslConfiguration = configuration;
+-    sslContext->errorCode = QSslError::NoError;
+-
+-    bool client = (mode == QSslSocket::SslClientMode);
+-
+-    bool reinitialized = false;
+-    bool unsupportedProtocol = false;
+-init_context:
+-    switch (sslContext->sslConfiguration.protocol()) {
+-    case QSsl::SslV2:
+-#ifndef OPENSSL_NO_SSL2
+-        sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv2_client_method() : q_SSLv2_server_method());
+-#else
+-        // SSL 2 not supported by the system, but chosen deliberately -> error
+-        sslContext->ctx = 0;
+-        unsupportedProtocol = true;
+-#endif
+-        break;
+-    case QSsl::SslV3:
+-#ifndef OPENSSL_NO_SSL3_METHOD
+-        sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv3_client_method() : q_SSLv3_server_method());
+-#else
+-        // SSL 3 not supported by the system, but chosen deliberately -> error
+-        sslContext->ctx = 0;
+-        unsupportedProtocol = true;
+-#endif
+-        break;
+-    case QSsl::SecureProtocols:
+-        // SSLv2 and SSLv3 will be disabled by SSL options
+-        // But we need q_SSLv23_server_method() otherwise AnyProtocol will be unable to connect on Win32.
+-    case QSsl::TlsV1SslV3:
+-        // SSLv2 will will be disabled by SSL options
+-    case QSsl::AnyProtocol:
+-    default:
+-        sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv23_client_method() : q_SSLv23_server_method());
+-        break;
+-    case QSsl::TlsV1_0:
+-        sslContext->ctx = q_SSL_CTX_new(client ? q_TLSv1_client_method() : q_TLSv1_server_method());
+-        break;
+-    case QSsl::TlsV1_1:
+-#if OPENSSL_VERSION_NUMBER >= 0x10001000L
+-        sslContext->ctx = q_SSL_CTX_new(client ? q_TLSv1_1_client_method() : q_TLSv1_1_server_method());
+-#else
+-        // TLS 1.1 not supported by the system, but chosen deliberately -> error
+-        sslContext->ctx = 0;
+-        unsupportedProtocol = true;
+-#endif
+-        break;
+-    case QSsl::TlsV1_2:
+-#if OPENSSL_VERSION_NUMBER >= 0x10001000L
+-        sslContext->ctx = q_SSL_CTX_new(client ? q_TLSv1_2_client_method() : q_TLSv1_2_server_method());
+-#else
+-        // TLS 1.2 not supported by the system, but chosen deliberately -> error
+-        sslContext->ctx = 0;
+-        unsupportedProtocol = true;
+-#endif
+-        break;
+-    case QSsl::TlsV1_0OrLater:
+-        // Specific protocols will be specified via SSL options.
+-        sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv23_client_method() : q_SSLv23_server_method());
+-        break;
+-    case QSsl::TlsV1_1OrLater:
+-    case QSsl::TlsV1_2OrLater:
+-#if OPENSSL_VERSION_NUMBER >= 0x10001000L
+-        // Specific protocols will be specified via SSL options.
+-        sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv23_client_method() : q_SSLv23_server_method());
+-#else
+-        // TLS 1.1/1.2 not supported by the system, but chosen deliberately -> error
+-        sslContext->ctx = 0;
+-        unsupportedProtocol = true;
+-#endif
+-        break;
+-    }
+-
+-    if (!sslContext->ctx) {
+-        // After stopping Flash 10 the SSL library looses its ciphers. Try re-adding them
+-        // by re-initializing the library.
+-        if (!reinitialized) {
+-            reinitialized = true;
+-            if (q_SSL_library_init() == 1)
+-                goto init_context;
+-        }
+-
+-        sslContext->errorStr = QSslSocket::tr("Error creating SSL context (%1)").arg(
+-            unsupportedProtocol ? QSslSocket::tr("unsupported protocol") : QSslSocketBackendPrivate::getErrorsFromOpenSsl()
+-        );
+-        sslContext->errorCode = QSslError::UnspecifiedError;
+-        return;
+-    }
+-
+-    // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+-    q_SSL_CTX_set_options(sslContext->ctx, options);
+-
+-#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+-    // Tell OpenSSL to release memory early
+-    // http://www.openssl.org/docs/ssl/SSL_CTX_set_mode.html
+-    if (q_SSLeay() >= 0x10000000L)
+-        q_SSL_CTX_set_mode(sslContext->ctx, SSL_MODE_RELEASE_BUFFERS);
+-#endif
+-
+-    // Initialize ciphers
+-    QByteArray cipherString;
+-    bool first = true;
+-    QList<QSslCipher> ciphers = sslContext->sslConfiguration.ciphers();
+-    if (ciphers.isEmpty())
+-        ciphers = QSslSocketPrivate::defaultCiphers();
+-    for (const QSslCipher &cipher : qAsConst(ciphers)) {
+-        if (first)
+-            first = false;
+-        else
+-            cipherString.append(':');
+-        cipherString.append(cipher.name().toLatin1());
+-    }
+-
+-    if (!q_SSL_CTX_set_cipher_list(sslContext->ctx, cipherString.data())) {
+-        sslContext->errorStr = QSslSocket::tr("Invalid or empty cipher list (%1)").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
+-        sslContext->errorCode = QSslError::UnspecifiedError;
+-        return;
+-    }
+-
+-    const QDateTime now = QDateTime::currentDateTimeUtc();
+-
+-    // Add all our CAs to this store.
+-    const auto caCertificates = sslContext->sslConfiguration.caCertificates();
+-    for (const QSslCertificate &caCertificate : caCertificates) {
+-        // From https://www.openssl.org/docs/ssl/SSL_CTX_load_verify_locations.html:
+-        //
+-        // If several CA certificates matching the name, key identifier, and
+-        // serial number condition are available, only the first one will be
+-        // examined. This may lead to unexpected results if the same CA
+-        // certificate is available with different expiration dates. If a
+-        // ``certificate expired'' verification error occurs, no other
+-        // certificate will be searched. Make sure to not have expired
+-        // certificates mixed with valid ones.
+-        //
+-        // See also: QSslSocketBackendPrivate::verify()
+-        if (caCertificate.expiryDate() >= now) {
+-            q_X509_STORE_add_cert(q_SSL_CTX_get_cert_store(sslContext->ctx), (X509 *)caCertificate.handle());
+-        }
+-    }
+-
+-    if (QSslSocketPrivate::s_loadRootCertsOnDemand && allowRootCertOnDemandLoading) {
+-        // tell OpenSSL the directories where to look up the root certs on demand
+-        const QList<QByteArray> unixDirs = QSslSocketPrivate::unixRootCertDirectories();
+-        for (const QByteArray &unixDir : unixDirs)
+-            q_SSL_CTX_load_verify_locations(sslContext->ctx, 0, unixDir.constData());
+-    }
+-
+-    if (!sslContext->sslConfiguration.localCertificate().isNull()) {
+-        // Require a private key as well.
+-        if (sslContext->sslConfiguration.privateKey().isNull()) {
+-            sslContext->errorStr = QSslSocket::tr("Cannot provide a certificate with no key, %1").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
+-            sslContext->errorCode = QSslError::UnspecifiedError;
+-            return;
+-        }
+-
+-        // Load certificate
+-        if (!q_SSL_CTX_use_certificate(sslContext->ctx, (X509 *)sslContext->sslConfiguration.localCertificate().handle())) {
+-            sslContext->errorStr = QSslSocket::tr("Error loading local certificate, %1").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
+-            sslContext->errorCode = QSslError::UnspecifiedError;
+-            return;
+-        }
+-
+-        if (configuration.d->privateKey.algorithm() == QSsl::Opaque) {
+-            sslContext->pkey = reinterpret_cast<EVP_PKEY *>(configuration.d->privateKey.handle());
+-        } else {
+-            // Load private key
+-            sslContext->pkey = q_EVP_PKEY_new();
+-            // before we were using EVP_PKEY_assign_R* functions and did not use EVP_PKEY_free.
+-            // this lead to a memory leak. Now we use the *_set1_* functions which do not
+-            // take ownership of the RSA/DSA key instance because the QSslKey already has ownership.
+-            if (configuration.d->privateKey.algorithm() == QSsl::Rsa)
+-                q_EVP_PKEY_set1_RSA(sslContext->pkey, reinterpret_cast<RSA *>(configuration.d->privateKey.handle()));
+-            else if (configuration.d->privateKey.algorithm() == QSsl::Dsa)
+-                q_EVP_PKEY_set1_DSA(sslContext->pkey, reinterpret_cast<DSA *>(configuration.d->privateKey.handle()));
+-#ifndef OPENSSL_NO_EC
+-            else if (configuration.d->privateKey.algorithm() == QSsl::Ec)
+-                q_EVP_PKEY_set1_EC_KEY(sslContext->pkey, reinterpret_cast<EC_KEY *>(configuration.d->privateKey.handle()));
+-#endif
+-        }
+-
+-        if (!q_SSL_CTX_use_PrivateKey(sslContext->ctx, sslContext->pkey)) {
+-            sslContext->errorStr = QSslSocket::tr("Error loading private key, %1").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
+-            sslContext->errorCode = QSslError::UnspecifiedError;
+-            return;
+-        }
+-        if (configuration.d->privateKey.algorithm() == QSsl::Opaque)
+-            sslContext->pkey = 0; // Don't free the private key, it belongs to QSslKey
+-
+-        // Check if the certificate matches the private key.
+-        if (!q_SSL_CTX_check_private_key(sslContext->ctx)) {
+-            sslContext->errorStr = QSslSocket::tr("Private key does not certify public key, %1").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
+-            sslContext->errorCode = QSslError::UnspecifiedError;
+-            return;
+-        }
+-
+-        // If we have any intermediate certificates then we need to add them to our chain
+-        bool first = true;
+-        for (const QSslCertificate &cert : qAsConst(configuration.d->localCertificateChain)) {
+-            if (first) {
+-                first = false;
+-                continue;
+-            }
+-            q_SSL_CTX_ctrl(sslContext->ctx, SSL_CTRL_EXTRA_CHAIN_CERT, 0,
+-                           q_X509_dup(reinterpret_cast<X509 *>(cert.handle())));
+-        }
+-    }
+-
+-    // Initialize peer verification.
+-    if (sslContext->sslConfiguration.peerVerifyMode() == QSslSocket::VerifyNone) {
+-        q_SSL_CTX_set_verify(sslContext->ctx, SSL_VERIFY_NONE, 0);
+-    } else {
+-        q_SSL_CTX_set_verify(sslContext->ctx, SSL_VERIFY_PEER, q_X509Callback);
+-    }
+-
+-    // Set verification depth.
+-    if (sslContext->sslConfiguration.peerVerifyDepth() != 0)
+-        q_SSL_CTX_set_verify_depth(sslContext->ctx, sslContext->sslConfiguration.peerVerifyDepth());
+-
+-    // set persisted session if the user set it
+-    if (!configuration.sessionTicket().isEmpty())
+-        sslContext->setSessionASN1(configuration.sessionTicket());
+-
+-    // Set temp DH params
+-    QSslDiffieHellmanParameters dhparams = configuration.diffieHellmanParameters();
+-
+-    if (!dhparams.isValid()) {
+-        sslContext->errorStr = QSslSocket::tr("Diffie-Hellman parameters are not valid");
+-        sslContext->errorCode = QSslError::UnspecifiedError;
+-        return;
+-    }
+-
+-    if (!dhparams.isEmpty()) {
+-        const QByteArray &params = dhparams.d->derData;
+-        const char *ptr = params.constData();
+-        DH *dh = q_d2i_DHparams(NULL, reinterpret_cast<const unsigned char **>(&ptr), params.length());
+-        if (dh == NULL)
+-            qFatal("q_d2i_DHparams failed to convert QSslDiffieHellmanParameters to DER form");
+-        q_SSL_CTX_set_tmp_dh(sslContext->ctx, dh);
+-        q_DH_free(dh);
+-    }
+-
+-#ifndef OPENSSL_NO_EC
+-#if OPENSSL_VERSION_NUMBER >= 0x10002000L
+-    if (q_SSLeay() >= 0x10002000L) {
+-        q_SSL_CTX_ctrl(sslContext->ctx, SSL_CTRL_SET_ECDH_AUTO, 1, NULL);
+-    } else
+-#endif
+-    {
+-        // Set temp ECDH params
+-        EC_KEY *ecdh = 0;
+-        ecdh = q_EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
+-        q_SSL_CTX_set_tmp_ecdh(sslContext->ctx, ecdh);
+-        q_EC_KEY_free(ecdh);
+-    }
+-#endif // OPENSSL_NO_EC
+-
+-#if OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)
+-    if (!client)
+-        q_SSL_CTX_use_psk_identity_hint(sslContext->ctx, sslContext->sslConfiguration.preSharedKeyIdentityHint().constData());
+-#endif // OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)
+-
+-    const QVector<QSslEllipticCurve> qcurves = sslContext->sslConfiguration.ellipticCurves();
+-    if (!qcurves.isEmpty()) {
+-#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !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,
+-            // but let's avoid a copy into a temporary array
+-            if (!q_SSL_CTX_ctrl(sslContext->ctx,
+-                                SSL_CTRL_SET_CURVES,
+-                                qcurves.size(),
+-                                const_cast<int *>(reinterpret_cast<const int *>(qcurves.data())))) {
+-                sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
+-                sslContext->errorCode = QSslError::UnspecifiedError;
+-            }
+-        } else
+-#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L && !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"));
+-            sslContext->errorCode = QSslError::UnspecifiedError;
+-        }
+-    }
+-}
+-
+ QSslContext* QSslContext::fromConfiguration(QSslSocket::SslMode mode, const QSslConfiguration &configuration, bool allowRootCertOnDemandLoading)
+ {
+     QSslContext *sslContext = new QSslContext();
+@@ -463,7 +160,7 @@ SSL* QSslContext::createSsl()
+         m_npnContext.len = m_supportedNPNVersions.count();
+         m_npnContext.status = QSslConfiguration::NextProtocolNegotiationNone;
+ #if OPENSSL_VERSION_NUMBER >= 0x10002000L
+-        if (q_SSLeay() >= 0x10002000L) {
++        if (QSslSocket::sslLibraryVersionNumber() >= 0x10002000L) {
+             // Callback's type has a parameter 'const unsigned char ** out'
+             // since it was introduced in 1.0.2. Internally, OpenSSL's own code
+             // (tests/examples) cast it to unsigned char * (since it's 'out').
+@@ -508,7 +205,7 @@ bool QSslContext::cacheSession(SSL* ssl)
+             unsigned char *data = reinterpret_cast<unsigned char *>(m_sessionASN1.data());
+             if (!q_i2d_SSL_SESSION(session, &data))
+                 qCWarning(lcSsl, "could not store persistent version of SSL session");
+-            m_sessionTicketLifeTimeHint = session->tlsext_tick_lifetime_hint;
++            m_sessionTicketLifeTimeHint = q_SSL_SESSION_get_ticket_lifetime_hint(session);
+         }
+     }
+ 
+diff --git a/src/network/ssl/qsslcontext_openssl11.cpp b/src/network/ssl/qsslcontext_openssl11.cpp
+new file mode 100644
+index 0000000000..787b6ae3f5
+--- /dev/null
++++ b/src/network/ssl/qsslcontext_openssl11.cpp
+@@ -0,0 +1,277 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 The Qt Company Ltd.
++** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
++** Copyright (C) 2014 Governikus GmbH & Co. KG.
++** Copyright (C) 2016 Richard J. Moore <rich@kde.org>
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtNetwork module of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:LGPL$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** GNU Lesser General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU Lesser
++** General Public License version 3 as published by the Free Software
++** Foundation and appearing in the file LICENSE.LGPL3 included in the
++** packaging of this file. Please review the following information to
++** ensure the GNU Lesser General Public License version 3 requirements
++** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
++**
++** GNU General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU
++** General Public License version 2.0 or (at your option) the GNU General
++** Public license version 3 or any later version approved by the KDE Free
++** Qt Foundation. The licenses are as published by the Free Software
++** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
++** included in the packaging of this file. Please review the following
++** information to ensure the GNU General Public License requirements will
++** be met: https://www.gnu.org/licenses/gpl-2.0.html and
++** https://www.gnu.org/licenses/gpl-3.0.html.
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++
++#include <QtNetwork/qsslsocket.h>
++#include <QtNetwork/qssldiffiehellmanparameters.h>
++
++#include "private/qssl_p.h"
++#include "private/qsslcontext_openssl_p.h"
++#include "private/qsslsocket_p.h"
++#include "private/qsslsocket_openssl_p.h"
++#include "private/qsslsocket_openssl_symbols_p.h"
++#include "private/qssldiffiehellmanparameters_p.h"
++
++#include <vector>
++
++QT_BEGIN_NAMESPACE
++
++// defined in qsslsocket_openssl.cpp:
++extern int q_X509Callback(int ok, X509_STORE_CTX *ctx);
++extern QString getErrorsFromOpenSsl();
++
++static inline QString msgErrorSettingEllipticCurves(const QString &why)
++{
++    return QSslSocket::tr("Error when setting the elliptic curves (%1)").arg(why);
++}
++
++// static
++void QSslContext::initSslContext(QSslContext *sslContext, QSslSocket::SslMode mode, const QSslConfiguration &configuration, bool allowRootCertOnDemandLoading)
++{
++    sslContext->sslConfiguration = configuration;
++    sslContext->errorCode = QSslError::NoError;
++
++    bool client = (mode == QSslSocket::SslClientMode);
++
++    bool reinitialized = false;
++    bool unsupportedProtocol = false;
++init_context:
++    if (sslContext->sslConfiguration.protocol() == QSsl::SslV2) {
++        // SSL 2 is no longer supported, but chosen deliberately -> error
++        sslContext->ctx = nullptr;
++        unsupportedProtocol = true;
++    } else {
++        // The ssl options will actually control the supported methods
++        sslContext->ctx = q_SSL_CTX_new(client ? q_TLS_client_method() : q_TLS_server_method());
++    }
++
++    if (!sslContext->ctx) {
++        // After stopping Flash 10 the SSL library loses its ciphers. Try re-adding them
++        // by re-initializing the library.
++        if (!reinitialized) {
++            reinitialized = true;
++            if (q_OPENSSL_init_ssl(0, nullptr) == 1)
++                goto init_context;
++        }
++
++        sslContext->errorStr = QSslSocket::tr("Error creating SSL context (%1)").arg(
++            unsupportedProtocol ? QSslSocket::tr("unsupported protocol") : QSslSocketBackendPrivate::getErrorsFromOpenSsl()
++        );
++        sslContext->errorCode = QSslError::UnspecifiedError;
++        return;
++    }
++
++    // Enable bug workarounds.
++    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    q_SSL_CTX_set_options(sslContext->ctx, options);
++
++    // Tell OpenSSL to release memory early
++    // http://www.openssl.org/docs/ssl/SSL_CTX_set_mode.html
++    q_SSL_CTX_set_mode(sslContext->ctx, SSL_MODE_RELEASE_BUFFERS);
++
++    // Initialize ciphers
++    QByteArray cipherString;
++    bool first = true;
++    QList<QSslCipher> ciphers = sslContext->sslConfiguration.ciphers();
++    if (ciphers.isEmpty())
++        ciphers = QSslSocketPrivate::defaultCiphers();
++    for (const QSslCipher &cipher : qAsConst(ciphers)) {
++        if (first)
++            first = false;
++        else
++            cipherString.append(':');
++        cipherString.append(cipher.name().toLatin1());
++    }
++
++    if (!q_SSL_CTX_set_cipher_list(sslContext->ctx, cipherString.data())) {
++        sslContext->errorStr = QSslSocket::tr("Invalid or empty cipher list (%1)").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
++        sslContext->errorCode = QSslError::UnspecifiedError;
++        return;
++    }
++
++    const QDateTime now = QDateTime::currentDateTimeUtc();
++
++    // Add all our CAs to this store.
++    const auto caCertificates = sslContext->sslConfiguration.caCertificates();
++    for (const QSslCertificate &caCertificate : caCertificates) {
++        // From https://www.openssl.org/docs/ssl/SSL_CTX_load_verify_locations.html:
++        //
++        // If several CA certificates matching the name, key identifier, and
++        // serial number condition are available, only the first one will be
++        // examined. This may lead to unexpected results if the same CA
++        // certificate is available with different expiration dates. If a
++        // ``certificate expired'' verification error occurs, no other
++        // certificate will be searched. Make sure to not have expired
++        // certificates mixed with valid ones.
++        //
++        // See also: QSslSocketBackendPrivate::verify()
++        if (caCertificate.expiryDate() >= now) {
++            q_X509_STORE_add_cert(q_SSL_CTX_get_cert_store(sslContext->ctx), (X509 *)caCertificate.handle());
++        }
++    }
++
++    if (QSslSocketPrivate::s_loadRootCertsOnDemand && allowRootCertOnDemandLoading) {
++        // tell OpenSSL the directories where to look up the root certs on demand
++        const QList<QByteArray> unixDirs = QSslSocketPrivate::unixRootCertDirectories();
++        for (const QByteArray &unixDir : unixDirs)
++            q_SSL_CTX_load_verify_locations(sslContext->ctx, nullptr, unixDir.constData());
++    }
++
++    if (!sslContext->sslConfiguration.localCertificate().isNull()) {
++        // Require a private key as well.
++        if (sslContext->sslConfiguration.privateKey().isNull()) {
++            sslContext->errorStr = QSslSocket::tr("Cannot provide a certificate with no key, %1").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
++            sslContext->errorCode = QSslError::UnspecifiedError;
++            return;
++        }
++
++        // Load certificate
++        if (!q_SSL_CTX_use_certificate(sslContext->ctx, (X509 *)sslContext->sslConfiguration.localCertificate().handle())) {
++            sslContext->errorStr = QSslSocket::tr("Error loading local certificate, %1").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
++            sslContext->errorCode = QSslError::UnspecifiedError;
++            return;
++        }
++
++        if (configuration.d->privateKey.algorithm() == QSsl::Opaque) {
++            sslContext->pkey = reinterpret_cast<EVP_PKEY *>(configuration.d->privateKey.handle());
++        } else {
++            // Load private key
++            sslContext->pkey = q_EVP_PKEY_new();
++            // before we were using EVP_PKEY_assign_R* functions and did not use EVP_PKEY_free.
++            // this lead to a memory leak. Now we use the *_set1_* functions which do not
++            // take ownership of the RSA/DSA key instance because the QSslKey already has ownership.
++            if (configuration.d->privateKey.algorithm() == QSsl::Rsa)
++                q_EVP_PKEY_set1_RSA(sslContext->pkey, reinterpret_cast<RSA *>(configuration.d->privateKey.handle()));
++            else if (configuration.d->privateKey.algorithm() == QSsl::Dsa)
++                q_EVP_PKEY_set1_DSA(sslContext->pkey, reinterpret_cast<DSA *>(configuration.d->privateKey.handle()));
++#ifndef OPENSSL_NO_EC
++            else if (configuration.d->privateKey.algorithm() == QSsl::Ec)
++                q_EVP_PKEY_set1_EC_KEY(sslContext->pkey, reinterpret_cast<EC_KEY *>(configuration.d->privateKey.handle()));
++#endif
++        }
++
++        if (!q_SSL_CTX_use_PrivateKey(sslContext->ctx, sslContext->pkey)) {
++            sslContext->errorStr = QSslSocket::tr("Error loading private key, %1").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
++            sslContext->errorCode = QSslError::UnspecifiedError;
++            return;
++        }
++        if (configuration.d->privateKey.algorithm() == QSsl::Opaque)
++            sslContext->pkey = nullptr; // Don't free the private key, it belongs to QSslKey
++
++        // Check if the certificate matches the private key.
++        if (!q_SSL_CTX_check_private_key(sslContext->ctx)) {
++            sslContext->errorStr = QSslSocket::tr("Private key does not certify public key, %1").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
++            sslContext->errorCode = QSslError::UnspecifiedError;
++            return;
++        }
++
++        // If we have any intermediate certificates then we need to add them to our chain
++        bool first = true;
++        for (const QSslCertificate &cert : qAsConst(configuration.d->localCertificateChain)) {
++            if (first) {
++                first = false;
++                continue;
++            }
++            q_SSL_CTX_ctrl(sslContext->ctx, SSL_CTRL_EXTRA_CHAIN_CERT, 0,
++                           q_X509_dup(reinterpret_cast<X509 *>(cert.handle())));
++        }
++    }
++
++    // Initialize peer verification.
++    if (sslContext->sslConfiguration.peerVerifyMode() == QSslSocket::VerifyNone) {
++        q_SSL_CTX_set_verify(sslContext->ctx, SSL_VERIFY_NONE, nullptr);
++    } else {
++        q_SSL_CTX_set_verify(sslContext->ctx, SSL_VERIFY_PEER, q_X509Callback);
++    }
++
++    // Set verification depth.
++    if (sslContext->sslConfiguration.peerVerifyDepth() != 0)
++        q_SSL_CTX_set_verify_depth(sslContext->ctx, sslContext->sslConfiguration.peerVerifyDepth());
++
++    // set persisted session if the user set it
++    if (!configuration.sessionTicket().isEmpty())
++        sslContext->setSessionASN1(configuration.sessionTicket());
++
++    // Set temp DH params
++    QSslDiffieHellmanParameters dhparams = configuration.diffieHellmanParameters();
++
++    if (!dhparams.isValid()) {
++        sslContext->errorStr = QSslSocket::tr("Diffie-Hellman parameters are not valid");
++        sslContext->errorCode = QSslError::UnspecifiedError;
++        return;
++    }
++
++    if (!dhparams.isEmpty()) {
++        const QByteArray &params = dhparams.d->derData;
++        const char *ptr = params.constData();
++        DH *dh = q_d2i_DHparams(NULL, reinterpret_cast<const unsigned char **>(&ptr), params.length());
++        if (dh == NULL)
++            qFatal("q_d2i_DHparams failed to convert QSslDiffieHellmanParameters to DER form");
++        q_SSL_CTX_set_tmp_dh(sslContext->ctx, dh);
++        q_DH_free(dh);
++    }
++
++#ifndef OPENSSL_NO_PSK
++    if (!client)
++        q_SSL_CTX_use_psk_identity_hint(sslContext->ctx, sslContext->sslConfiguration.preSharedKeyIdentityHint().constData());
++#endif // !OPENSSL_NO_PSK
++
++    const QVector<QSslEllipticCurve> qcurves = sslContext->sslConfiguration.ellipticCurves();
++    if (!qcurves.isEmpty()) {
++#ifdef OPENSSL_NO_EC
++        sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocket::tr("OpenSSL version with disabled elliptic curves"));
++        sslContext->errorCode = QSslError::UnspecifiedError;
++#else
++        // Set the curves to be used.
++        std::vector<int> curves;
++        curves.reserve(qcurves.size());
++        for (const auto &sslCurve : qcurves)
++            curves.push_back(sslCurve.id);
++        if (!q_SSL_CTX_ctrl(sslContext->ctx, SSL_CTRL_SET_CURVES, long(curves.size()), &curves[0])) {
++            sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
++            sslContext->errorCode = QSslError::UnspecifiedError;
++        }
++#endif
++    }
++}
++
++QT_END_NAMESPACE
+diff --git a/src/network/ssl/qsslcontext_opensslpre11.cpp b/src/network/ssl/qsslcontext_opensslpre11.cpp
+new file mode 100644
+index 0000000000..9c01c2f2dc
+--- /dev/null
++++ b/src/network/ssl/qsslcontext_opensslpre11.cpp
+@@ -0,0 +1,354 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 The Qt Company Ltd.
++** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
++** Copyright (C) 2014 Governikus GmbH & Co. KG.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtNetwork module of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:LGPL$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** GNU Lesser General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU Lesser
++** General Public License version 3 as published by the Free Software
++** Foundation and appearing in the file LICENSE.LGPL3 included in the
++** packaging of this file. Please review the following information to
++** ensure the GNU Lesser General Public License version 3 requirements
++** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
++**
++** GNU General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU
++** General Public License version 2.0 or (at your option) the GNU General
++** Public license version 3 or any later version approved by the KDE Free
++** Qt Foundation. The licenses are as published by the Free Software
++** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
++** included in the packaging of this file. Please review the following
++** information to ensure the GNU General Public License requirements will
++** be met: https://www.gnu.org/licenses/gpl-2.0.html and
++** https://www.gnu.org/licenses/gpl-3.0.html.
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++
++#include <QtNetwork/qsslsocket.h>
++#include <QtNetwork/qssldiffiehellmanparameters.h>
++
++#include "private/qssl_p.h"
++#include "private/qsslcontext_openssl_p.h"
++#include "private/qsslsocket_p.h"
++#include "private/qsslsocket_openssl_p.h"
++#include "private/qsslsocket_openssl_symbols_p.h"
++#include "private/qssldiffiehellmanparameters_p.h"
++
++QT_BEGIN_NAMESPACE
++
++// defined in qsslsocket_openssl.cpp:
++extern int q_X509Callback(int ok, X509_STORE_CTX *ctx);
++extern QString getErrorsFromOpenSsl();
++
++static inline QString msgErrorSettingEllipticCurves(const QString &why)
++{
++    return QSslSocket::tr("Error when setting the elliptic curves (%1)").arg(why);
++}
++
++// static
++void QSslContext::initSslContext(QSslContext *sslContext, QSslSocket::SslMode mode, const QSslConfiguration &configuration, bool allowRootCertOnDemandLoading)
++{
++    sslContext->sslConfiguration = configuration;
++    sslContext->errorCode = QSslError::NoError;
++
++    bool client = (mode == QSslSocket::SslClientMode);
++
++    bool reinitialized = false;
++    bool unsupportedProtocol = false;
++init_context:
++    switch (sslContext->sslConfiguration.protocol()) {
++    case QSsl::SslV2:
++#ifndef OPENSSL_NO_SSL2
++        sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv2_client_method() : q_SSLv2_server_method());
++#else
++        // SSL 2 not supported by the system, but chosen deliberately -> error
++        sslContext->ctx = 0;
++        unsupportedProtocol = true;
++#endif
++        break;
++    case QSsl::SslV3:
++#ifndef OPENSSL_NO_SSL3_METHOD
++        sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv3_client_method() : q_SSLv3_server_method());
++#else
++        // SSL 3 not supported by the system, but chosen deliberately -> error
++        sslContext->ctx = 0;
++        unsupportedProtocol = true;
++#endif
++        break;
++    case QSsl::SecureProtocols:
++        // SSLv2 and SSLv3 will be disabled by SSL options
++        // But we need q_SSLv23_server_method() otherwise AnyProtocol will be unable to connect on Win32.
++    case QSsl::TlsV1SslV3:
++        // SSLv2 will will be disabled by SSL options
++    case QSsl::AnyProtocol:
++    default:
++        sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv23_client_method() : q_SSLv23_server_method());
++        break;
++    case QSsl::TlsV1_0:
++        sslContext->ctx = q_SSL_CTX_new(client ? q_TLSv1_client_method() : q_TLSv1_server_method());
++        break;
++    case QSsl::TlsV1_1:
++#if OPENSSL_VERSION_NUMBER >= 0x10001000L
++        sslContext->ctx = q_SSL_CTX_new(client ? q_TLSv1_1_client_method() : q_TLSv1_1_server_method());
++#else
++        // TLS 1.1 not supported by the system, but chosen deliberately -> error
++        sslContext->ctx = 0;
++        unsupportedProtocol = true;
++#endif
++        break;
++    case QSsl::TlsV1_2:
++#if OPENSSL_VERSION_NUMBER >= 0x10001000L
++        sslContext->ctx = q_SSL_CTX_new(client ? q_TLSv1_2_client_method() : q_TLSv1_2_server_method());
++#else
++        // TLS 1.2 not supported by the system, but chosen deliberately -> error
++        sslContext->ctx = 0;
++        unsupportedProtocol = true;
++#endif
++        break;
++    case QSsl::TlsV1_0OrLater:
++        // Specific protocols will be specified via SSL options.
++        sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv23_client_method() : q_SSLv23_server_method());
++        break;
++    case QSsl::TlsV1_1OrLater:
++    case QSsl::TlsV1_2OrLater:
++#if OPENSSL_VERSION_NUMBER >= 0x10001000L
++        // Specific protocols will be specified via SSL options.
++        sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv23_client_method() : q_SSLv23_server_method());
++#else
++        // TLS 1.1/1.2 not supported by the system, but chosen deliberately -> error
++        sslContext->ctx = 0;
++        unsupportedProtocol = true;
++#endif
++        break;
++    }
++
++    if (!sslContext->ctx) {
++        // After stopping Flash 10 the SSL library loses its ciphers. Try re-adding them
++        // by re-initializing the library.
++        if (!reinitialized) {
++            reinitialized = true;
++            if (q_SSL_library_init() == 1)
++                goto init_context;
++        }
++
++        sslContext->errorStr = QSslSocket::tr("Error creating SSL context (%1)").arg(
++            unsupportedProtocol ? QSslSocket::tr("unsupported protocol") : QSslSocketBackendPrivate::getErrorsFromOpenSsl()
++        );
++        sslContext->errorCode = QSslError::UnspecifiedError;
++        return;
++    }
++
++    // Enable bug workarounds.
++    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    q_SSL_CTX_set_options(sslContext->ctx, options);
++
++#if OPENSSL_VERSION_NUMBER >= 0x10000000L
++    // Tell OpenSSL to release memory early
++    // http://www.openssl.org/docs/ssl/SSL_CTX_set_mode.html
++    if (q_SSLeay() >= 0x10000000L)
++        q_SSL_CTX_set_mode(sslContext->ctx, SSL_MODE_RELEASE_BUFFERS);
++#endif
++
++    // Initialize ciphers
++    QByteArray cipherString;
++    bool first = true;
++    QList<QSslCipher> ciphers = sslContext->sslConfiguration.ciphers();
++    if (ciphers.isEmpty())
++        ciphers = QSslSocketPrivate::defaultCiphers();
++    for (const QSslCipher &cipher : qAsConst(ciphers)) {
++        if (first)
++            first = false;
++        else
++            cipherString.append(':');
++        cipherString.append(cipher.name().toLatin1());
++    }
++
++    if (!q_SSL_CTX_set_cipher_list(sslContext->ctx, cipherString.data())) {
++        sslContext->errorStr = QSslSocket::tr("Invalid or empty cipher list (%1)").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
++        sslContext->errorCode = QSslError::UnspecifiedError;
++        return;
++    }
++
++    const QDateTime now = QDateTime::currentDateTimeUtc();
++
++    // Add all our CAs to this store.
++    const auto caCertificates = sslContext->sslConfiguration.caCertificates();
++    for (const QSslCertificate &caCertificate : caCertificates) {
++        // From https://www.openssl.org/docs/ssl/SSL_CTX_load_verify_locations.html:
++        //
++        // If several CA certificates matching the name, key identifier, and
++        // serial number condition are available, only the first one will be
++        // examined. This may lead to unexpected results if the same CA
++        // certificate is available with different expiration dates. If a
++        // ``certificate expired'' verification error occurs, no other
++        // certificate will be searched. Make sure to not have expired
++        // certificates mixed with valid ones.
++        //
++        // See also: QSslSocketBackendPrivate::verify()
++        if (caCertificate.expiryDate() >= now) {
++            q_X509_STORE_add_cert(q_SSL_CTX_get_cert_store(sslContext->ctx), (X509 *)caCertificate.handle());
++        }
++    }
++
++    if (QSslSocketPrivate::s_loadRootCertsOnDemand && allowRootCertOnDemandLoading) {
++        // tell OpenSSL the directories where to look up the root certs on demand
++        const QList<QByteArray> unixDirs = QSslSocketPrivate::unixRootCertDirectories();
++        for (const QByteArray &unixDir : unixDirs)
++            q_SSL_CTX_load_verify_locations(sslContext->ctx, 0, unixDir.constData());
++    }
++
++    if (!sslContext->sslConfiguration.localCertificate().isNull()) {
++        // Require a private key as well.
++        if (sslContext->sslConfiguration.privateKey().isNull()) {
++            sslContext->errorStr = QSslSocket::tr("Cannot provide a certificate with no key, %1").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
++            sslContext->errorCode = QSslError::UnspecifiedError;
++            return;
++        }
++
++        // Load certificate
++        if (!q_SSL_CTX_use_certificate(sslContext->ctx, (X509 *)sslContext->sslConfiguration.localCertificate().handle())) {
++            sslContext->errorStr = QSslSocket::tr("Error loading local certificate, %1").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
++            sslContext->errorCode = QSslError::UnspecifiedError;
++            return;
++        }
++
++        if (configuration.d->privateKey.algorithm() == QSsl::Opaque) {
++            sslContext->pkey = reinterpret_cast<EVP_PKEY *>(configuration.d->privateKey.handle());
++        } else {
++            // Load private key
++            sslContext->pkey = q_EVP_PKEY_new();
++            // before we were using EVP_PKEY_assign_R* functions and did not use EVP_PKEY_free.
++            // this lead to a memory leak. Now we use the *_set1_* functions which do not
++            // take ownership of the RSA/DSA key instance because the QSslKey already has ownership.
++            if (configuration.d->privateKey.algorithm() == QSsl::Rsa)
++                q_EVP_PKEY_set1_RSA(sslContext->pkey, reinterpret_cast<RSA *>(configuration.d->privateKey.handle()));
++            else if (configuration.d->privateKey.algorithm() == QSsl::Dsa)
++                q_EVP_PKEY_set1_DSA(sslContext->pkey, reinterpret_cast<DSA *>(configuration.d->privateKey.handle()));
++#ifndef OPENSSL_NO_EC
++            else if (configuration.d->privateKey.algorithm() == QSsl::Ec)
++                q_EVP_PKEY_set1_EC_KEY(sslContext->pkey, reinterpret_cast<EC_KEY *>(configuration.d->privateKey.handle()));
++#endif
++        }
++
++        if (!q_SSL_CTX_use_PrivateKey(sslContext->ctx, sslContext->pkey)) {
++            sslContext->errorStr = QSslSocket::tr("Error loading private key, %1").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
++            sslContext->errorCode = QSslError::UnspecifiedError;
++            return;
++        }
++        if (configuration.d->privateKey.algorithm() == QSsl::Opaque)
++            sslContext->pkey = 0; // Don't free the private key, it belongs to QSslKey
++
++        // Check if the certificate matches the private key.
++        if (!q_SSL_CTX_check_private_key(sslContext->ctx)) {
++            sslContext->errorStr = QSslSocket::tr("Private key does not certify public key, %1").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
++            sslContext->errorCode = QSslError::UnspecifiedError;
++            return;
++        }
++
++        // If we have any intermediate certificates then we need to add them to our chain
++        bool first = true;
++        for (const QSslCertificate &cert : qAsConst(configuration.d->localCertificateChain)) {
++            if (first) {
++                first = false;
++                continue;
++            }
++            q_SSL_CTX_ctrl(sslContext->ctx, SSL_CTRL_EXTRA_CHAIN_CERT, 0,
++                           q_X509_dup(reinterpret_cast<X509 *>(cert.handle())));
++        }
++    }
++
++    // Initialize peer verification.
++    if (sslContext->sslConfiguration.peerVerifyMode() == QSslSocket::VerifyNone) {
++        q_SSL_CTX_set_verify(sslContext->ctx, SSL_VERIFY_NONE, 0);
++    } else {
++        q_SSL_CTX_set_verify(sslContext->ctx, SSL_VERIFY_PEER, q_X509Callback);
++    }
++
++    // Set verification depth.
++    if (sslContext->sslConfiguration.peerVerifyDepth() != 0)
++        q_SSL_CTX_set_verify_depth(sslContext->ctx, sslContext->sslConfiguration.peerVerifyDepth());
++
++    // set persisted session if the user set it
++    if (!configuration.sessionTicket().isEmpty())
++        sslContext->setSessionASN1(configuration.sessionTicket());
++
++    // Set temp DH params
++    QSslDiffieHellmanParameters dhparams = configuration.diffieHellmanParameters();
++
++    if (!dhparams.isValid()) {
++        sslContext->errorStr = QSslSocket::tr("Diffie-Hellman parameters are not valid");
++        sslContext->errorCode = QSslError::UnspecifiedError;
++        return;
++    }
++
++    if (!dhparams.isEmpty()) {
++        const QByteArray &params = dhparams.d->derData;
++        const char *ptr = params.constData();
++        DH *dh = q_d2i_DHparams(NULL, reinterpret_cast<const unsigned char **>(&ptr), params.length());
++        if (dh == NULL)
++            qFatal("q_d2i_DHparams failed to convert QSslDiffieHellmanParameters to DER form");
++        q_SSL_CTX_set_tmp_dh(sslContext->ctx, dh);
++        q_DH_free(dh);
++    }
++
++#ifndef OPENSSL_NO_EC
++#if OPENSSL_VERSION_NUMBER >= 0x10002000L
++    if (q_SSLeay() >= 0x10002000L) {
++        q_SSL_CTX_ctrl(sslContext->ctx, SSL_CTRL_SET_ECDH_AUTO, 1, NULL);
++    } else
++#endif
++    {
++        // Set temp ECDH params
++        EC_KEY *ecdh = 0;
++        ecdh = q_EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
++        q_SSL_CTX_set_tmp_ecdh(sslContext->ctx, ecdh);
++        q_EC_KEY_free(ecdh);
++    }
++#endif // OPENSSL_NO_EC
++
++#if OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)
++    if (!client)
++        q_SSL_CTX_use_psk_identity_hint(sslContext->ctx, sslContext->sslConfiguration.preSharedKeyIdentityHint().constData());
++#endif // OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)
++
++    const QVector<QSslEllipticCurve> qcurves = sslContext->sslConfiguration.ellipticCurves();
++    if (!qcurves.isEmpty()) {
++#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !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,
++            // but let's avoid a copy into a temporary array
++            if (!q_SSL_CTX_ctrl(sslContext->ctx,
++                                SSL_CTRL_SET_CURVES,
++                                qcurves.size(),
++                                const_cast<int *>(reinterpret_cast<const int *>(qcurves.data())))) {
++                sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
++                sslContext->errorCode = QSslError::UnspecifiedError;
++            }
++        } else
++#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L && !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"));
++            sslContext->errorCode = QSslError::UnspecifiedError;
++        }
++    }
++}
++
++QT_END_NAMESPACE
+diff --git a/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index 90687b05c5..5ebad822f1 100644
+--- a/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -1,6 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2015 Mikkel Krautz <mikkel@krautz.dk>
++** Copyright (C) 2016 Richard J. Moore <rich@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtNetwork module of the Qt Toolkit.
+@@ -50,8 +51,8 @@
+ #include <QtCore/qdebug.h>
+ #endif
+ 
+-// For q_BN_is_word.
+ #include <openssl/bn.h>
++#include <openssl/dh.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -62,13 +63,6 @@ static bool isSafeDH(DH *dh)
+ 
+     QSslSocketPrivate::ensureInitialized();
+ 
+-    // Mark p < 1024 bits as unsafe.
+-    if (q_BN_num_bits(dh->p) < 1024) {
+-        return false;
+-    }
+-
+-    if (q_DH_check(dh, &status) != 1)
+-        return false;
+ 
+     // From https://wiki.openssl.org/index.php/Diffie-Hellman_parameters:
+     //
+@@ -81,11 +75,39 @@ static bool isSafeDH(DH *dh)
+     //     Without the test, the IETF parameters would
+     //     fail validation. For details, see Diffie-Hellman
+     //     Parameter Check (when g = 2, must p mod 24 == 11?).
++#if QT_CONFIG(opensslv11)
++    // Mark p < 1024 bits as unsafe.
++    if (q_DH_bits(dh) < 1024)
++        return false;
++
++    if (q_DH_check(dh, &status) != 1)
++        return false;
++
++    const BIGNUM *p = nullptr;
++    const BIGNUM *q = nullptr;
++    const BIGNUM *g = nullptr;
++    q_DH_get0_pqg(dh, &p, &q, &g);
++
++    if (q_BN_is_word(const_cast<BIGNUM *>(g), DH_GENERATOR_2)) {
++        long residue = q_BN_mod_word(p, 24);
++        if (residue == 11 || residue == 23)
++            status &= ~DH_NOT_SUITABLE_GENERATOR;
++    }
++
++#else
++    // Mark p < 1024 bits as unsafe.
++    if (q_BN_num_bits(dh->p) < 1024)
++        return false;
++
++    if (q_DH_check(dh, &status) != 1)
++        return false;
++
+     if (q_BN_is_word(dh->g, DH_GENERATOR_2)) {
+         long residue = q_BN_mod_word(dh->p, 24);
+         if (residue == 11 || residue == 23)
+             status &= ~DH_NOT_SUITABLE_GENERATOR;
+     }
++#endif
+ 
+     bad |= DH_CHECK_P_NOT_PRIME;
+     bad |= DH_CHECK_P_NOT_SAFE_PRIME;
+diff --git a/src/network/ssl/qsslellipticcurve.h b/src/network/ssl/qsslellipticcurve.h
+index 231566063e..57dda19bad 100644
+--- a/src/network/ssl/qsslellipticcurve.h
++++ b/src/network/ssl/qsslellipticcurve.h
+@@ -80,6 +80,7 @@ private:
+     friend Q_DECL_CONSTEXPR bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) Q_DECL_NOTHROW;
+     friend Q_DECL_CONSTEXPR uint qHash(QSslEllipticCurve curve, uint seed) Q_DECL_NOTHROW;
+ 
++    friend class QSslContext;
+     friend class QSslSocketPrivate;
+     friend class QSslSocketBackendPrivate;
+ };
+diff --git a/src/network/ssl/qsslellipticcurve_openssl.cpp b/src/network/ssl/qsslellipticcurve_openssl.cpp
+index e18197b703..8cd14837f0 100644
+--- a/src/network/ssl/qsslellipticcurve_openssl.cpp
++++ b/src/network/ssl/qsslellipticcurve_openssl.cpp
+@@ -1,6 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2014 Governikus GmbH & Co. KG.
++** Copyright (C) 2016 Richard J. Moore <rich@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtNetwork module of the Qt Toolkit.
+@@ -78,17 +79,18 @@ QSslEllipticCurve QSslEllipticCurve::fromShortName(const QString &name)
+     QSslEllipticCurve result;
+ 
+ #ifndef OPENSSL_NO_EC
+-    const QByteArray curveNameLatin1 = name.toLatin1();
+ 
++    const QByteArray curveNameLatin1 = name.toLatin1();
+     int nid = q_OBJ_sn2nid(curveNameLatin1.data());
+ 
+ #if OPENSSL_VERSION_NUMBER >= 0x10002000L
+-    if (nid == 0 && q_SSLeay() >= 0x10002000L)
++    if (nid == 0 && QSslSocket::sslLibraryVersionNumber() >= 0x10002000L)
+         nid = q_EC_curve_nist2nid(curveNameLatin1.data());
+ #endif // OPENSSL_VERSION_NUMBER >= 0x10002000L
+ 
+     result.id = nid;
+-#endif
++
++#endif // !OPENSSL_NO_EC
+ 
+     return result;
+ }
+diff --git a/src/network/ssl/qsslkey_openssl.cpp b/src/network/ssl/qsslkey_openssl.cpp
+index 26119023d1..2b03af9441 100644
+--- a/src/network/ssl/qsslkey_openssl.cpp
++++ b/src/network/ssl/qsslkey_openssl.cpp
+@@ -1,6 +1,7 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2017 The Qt Company Ltd.
++** Copyright (C) 2016 Richard J. Moore <rich@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtNetwork module of the Qt Toolkit.
+@@ -87,33 +88,32 @@ bool QSslKeyPrivate::fromEVP_PKEY(EVP_PKEY *pkey)
+     if (pkey == nullptr)
+         return false;
+ 
+-    if (pkey->type == EVP_PKEY_RSA) {
++#if QT_CONFIG(opensslv11)
++    const int keyType = q_EVP_PKEY_type(q_EVP_PKEY_base_id(pkey));
++#else
++    const int keyType = pkey->type;
++#endif
++    if (keyType == EVP_PKEY_RSA) {
+         isNull = false;
+         algorithm = QSsl::Rsa;
+         type = QSsl::PrivateKey;
+ 
+-        rsa = q_RSA_new();
+-        memcpy(rsa, q_EVP_PKEY_get1_RSA(pkey), sizeof(RSA));
+-
++        rsa = q_EVP_PKEY_get1_RSA(pkey);
+         return true;
+-    }
+-    else if (pkey->type == EVP_PKEY_DSA) {
++    } else if (keyType == EVP_PKEY_DSA) {
+         isNull = false;
+         algorithm = QSsl::Dsa;
+         type = QSsl::PrivateKey;
+ 
+-        dsa = q_DSA_new();
+-        memcpy(dsa, q_EVP_PKEY_get1_DSA(pkey), sizeof(DSA));
+-
++        dsa = q_EVP_PKEY_get1_DSA(pkey);
+         return true;
+     }
+ #ifndef OPENSSL_NO_EC
+-    else if (pkey->type == EVP_PKEY_EC) {
++    else if (keyType == EVP_PKEY_EC) {
+         isNull = false;
+         algorithm = QSsl::Ec;
+         type = QSsl::PrivateKey;
+-        ec = q_EC_KEY_dup(q_EVP_PKEY_get1_EC_KEY(pkey));
+-
++        ec = q_EVP_PKEY_get1_EC_KEY(pkey);
+         return true;
+     }
+ #endif
+@@ -181,8 +181,8 @@ int QSslKeyPrivate::length() const
+         return -1;
+ 
+     switch (algorithm) {
+-        case QSsl::Rsa: return q_BN_num_bits(rsa->n);
+-        case QSsl::Dsa: return q_BN_num_bits(dsa->p);
++        case QSsl::Rsa: return q_RSA_bits(rsa);
++        case QSsl::Dsa: return q_DSA_bits(dsa);
+ #ifndef OPENSSL_NO_EC
+         case QSsl::Ec: return q_EC_GROUP_get_degree(q_EC_KEY_get0_group(ec));
+ #endif
+@@ -276,7 +276,13 @@ Qt::HANDLE QSslKeyPrivate::handle() const
+ 
+ static QByteArray doCrypt(QSslKeyPrivate::Cipher cipher, const QByteArray &data, const QByteArray &key, const QByteArray &iv, int enc)
+ {
+-    EVP_CIPHER_CTX ctx;
++#if QT_CONFIG(opensslv11)
++    EVP_CIPHER_CTX *ctx = q_EVP_CIPHER_CTX_new();
++#else
++    EVP_CIPHER_CTX evpCipherContext;
++    EVP_CIPHER_CTX *ctx = &evpCipherContext;
++#endif
++
+     const EVP_CIPHER* type = 0;
+     int i = 0, len = 0;
+ 
+@@ -294,21 +300,44 @@ static QByteArray doCrypt(QSslKeyPrivate::Cipher cipher, const QByteArray &data,
+ 
+     QByteArray output;
+     output.resize(data.size() + EVP_MAX_BLOCK_LENGTH);
+-    q_EVP_CIPHER_CTX_init(&ctx);
+-    q_EVP_CipherInit(&ctx, type, NULL, NULL, enc);
+-    q_EVP_CIPHER_CTX_set_key_length(&ctx, key.size());
++
++#if QT_CONFIG(opensslv11)
++    q_EVP_CIPHER_CTX_reset(ctx);
++#else
++    q_EVP_CIPHER_CTX_init(ctx);
++#endif
++
++    q_EVP_CipherInit(ctx, type, NULL, NULL, enc);
++    q_EVP_CIPHER_CTX_set_key_length(ctx, key.size());
+     if (cipher == QSslKeyPrivate::Rc2Cbc)
+-        q_EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_SET_RC2_KEY_BITS, 8 * key.size(), NULL);
+-    q_EVP_CipherInit(&ctx, NULL,
++        q_EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC2_KEY_BITS, 8 * key.size(), NULL);
++
++#if QT_CONFIG(opensslv11)
++    // EVP_CipherInit in 1.1 resets the context thus making the calls above useless.
++    // We call EVP_CipherInit_ex instead.
++    q_EVP_CipherInit_ex(ctx, nullptr, nullptr,
++                        reinterpret_cast<const unsigned char *>(key.constData()),
++                        reinterpret_cast<const unsigned char *>(iv.constData()),
++                        enc);
++#else
++    q_EVP_CipherInit(ctx, NULL,
+         reinterpret_cast<const unsigned char *>(key.constData()),
+         reinterpret_cast<const unsigned char *>(iv.constData()), enc);
+-    q_EVP_CipherUpdate(&ctx,
++#endif // opensslv11
++
++    q_EVP_CipherUpdate(ctx,
+         reinterpret_cast<unsigned char *>(output.data()), &len,
+         reinterpret_cast<const unsigned char *>(data.constData()), data.size());
+-    q_EVP_CipherFinal(&ctx,
++    q_EVP_CipherFinal(ctx,
+         reinterpret_cast<unsigned char *>(output.data()) + len, &i);
+     len += i;
+-    q_EVP_CIPHER_CTX_cleanup(&ctx);
++
++#if QT_CONFIG(opensslv11)
++    q_EVP_CIPHER_CTX_reset(ctx);
++    q_EVP_CIPHER_CTX_free(ctx);
++#else
++    q_EVP_CIPHER_CTX_cleanup(ctx);
++#endif
+ 
+     return output.left(len);
+ }
+diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
+index f5b493897e..45cea490fc 100644
+--- a/src/network/ssl/qsslsocket_openssl.cpp
++++ b/src/network/ssl/qsslsocket_openssl.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2017 The Qt Company Ltd.
+ ** Copyright (C) 2014 Governikus GmbH & Co. KG
+ ** Contact: https://www.qt.io/licensing/
+ **
+@@ -97,70 +97,6 @@ bool QSslSocketPrivate::s_loadRootCertsOnDemand = false;
+ int QSslSocketBackendPrivate::s_indexForSSLExtraData = -1;
+ #endif
+ 
+-/* \internal
+-
+-    From OpenSSL's thread(3) manual page:
+-
+-    OpenSSL can safely be used in multi-threaded applications provided that at
+-    least two callback functions are set.
+-
+-    locking_function(int mode, int n, const char *file, int line) is needed to
+-    perform locking on shared data structures.  (Note that OpenSSL uses a
+-    number of global data structures that will be implicitly shared
+-    whenever multiple threads use OpenSSL.)  Multi-threaded
+-    applications will crash at random if it is not set.  ...
+-    ...
+-    id_function(void) is a function that returns a thread ID. It is not
+-    needed on Windows nor on platforms where getpid() returns a different
+-    ID for each thread (most notably Linux)
+-*/
+-class QOpenSslLocks
+-{
+-public:
+-    inline QOpenSslLocks()
+-        : initLocker(QMutex::Recursive),
+-          locksLocker(QMutex::Recursive)
+-    {
+-        QMutexLocker locker(&locksLocker);
+-        int numLocks = q_CRYPTO_num_locks();
+-        locks = new QMutex *[numLocks];
+-        memset(locks, 0, numLocks * sizeof(QMutex *));
+-    }
+-    inline ~QOpenSslLocks()
+-    {
+-        QMutexLocker locker(&locksLocker);
+-        for (int i = 0; i < q_CRYPTO_num_locks(); ++i)
+-            delete locks[i];
+-        delete [] locks;
+-
+-        QSslSocketPrivate::deinitialize();
+-    }
+-    inline QMutex *lock(int num)
+-    {
+-        QMutexLocker locker(&locksLocker);
+-        QMutex *tmp = locks[num];
+-        if (!tmp)
+-            tmp = locks[num] = new QMutex(QMutex::Recursive);
+-        return tmp;
+-    }
+-
+-    QMutex *globalLock()
+-    {
+-        return &locksLocker;
+-    }
+-
+-    QMutex *initLock()
+-    {
+-        return &initLocker;
+-    }
+-
+-private:
+-    QMutex initLocker;
+-    QMutex locksLocker;
+-    QMutex **locks;
+-};
+-Q_GLOBAL_STATIC(QOpenSslLocks, openssl_locks)
+-
+ QString QSslSocketBackendPrivate::getErrorsFromOpenSsl()
+ {
+     QString errorString;
+@@ -175,20 +111,6 @@ QString QSslSocketBackendPrivate::getErrorsFromOpenSsl()
+ }
+ 
+ extern "C" {
+-static void locking_function(int mode, int lockNumber, const char *, int)
+-{
+-    QMutex *mutex = openssl_locks()->lock(lockNumber);
+-
+-    // Lock or unlock it
+-    if (mode & CRYPTO_LOCK)
+-        mutex->lock();
+-    else
+-        mutex->unlock();
+-}
+-static unsigned long id_function()
+-{
+-    return (quintptr)QThread::currentThreadId();
+-}
+ 
+ #if OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)
+ static unsigned int q_ssl_psk_client_callback(SSL *ssl,
+@@ -227,7 +149,7 @@ QSslSocketBackendPrivate::~QSslSocketBackendPrivate()
+     destroySslContext();
+ }
+ 
+-QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSL_CIPHER(SSL_CIPHER *cipher)
++QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher)
+ {
+     QSslCipher ciph;
+ 
+@@ -283,6 +205,7 @@ struct QSslErrorList
+     QMutex mutex;
+     QVector<QSslErrorEntry> errors;
+ };
++
+ Q_GLOBAL_STATIC(QSslErrorList, _q_sslErrorList)
+ 
+ int q_X509Callback(int ok, X509_STORE_CTX *ctx)
+@@ -312,7 +235,7 @@ int q_X509Callback(int ok, X509_STORE_CTX *ctx)
+         }
+ #endif
+     }
+-    // Always return OK to allow verification to continue. We're handle the
++    // Always return OK to allow verification to continue. We handle the
+     // errors gracefully after collecting all errors, after verification has
+     // completed.
+     return 1;
+@@ -397,7 +320,7 @@ bool QSslSocketBackendPrivate::initSslContext()
+     if (configuration.protocol != QSsl::SslV2 &&
+         configuration.protocol != QSsl::SslV3 &&
+         configuration.protocol != QSsl::UnknownProtocol &&
+-        mode == QSslSocket::SslClientMode && q_SSLeay() >= 0x00090806fL) {
++        mode == QSslSocket::SslClientMode && QSslSocket::sslLibraryVersionNumber() >= 0x00090806fL) {
+         // Set server hostname on TLS extension. RFC4366 section 3.1 requires it in ACE format.
+         QString tlsHostName = verificationPeerName.isEmpty() ? q->peerName() : verificationPeerName;
+         if (tlsHostName.isEmpty())
+@@ -438,13 +361,13 @@ bool QSslSocketBackendPrivate::initSslContext()
+ 
+ #if OPENSSL_VERSION_NUMBER >= 0x10001000L
+     // Save a pointer to this object into the SSL structure.
+-    if (q_SSLeay() >= 0x10001000L)
++    if (QSslSocket::sslLibraryVersionNumber() >= 0x10001000L)
+         q_SSL_set_ex_data(ssl, s_indexForSSLExtraData, this);
+ #endif
+ 
+ #if OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)
+     // Set the client callback for PSK
+-    if (q_SSLeay() >= 0x10001000L) {
++    if (QSslSocket::sslLibraryVersionNumber() >= 0x10001000L) {
+         if (mode == QSslSocket::SslClientMode)
+             q_SSL_set_psk_client_callback(ssl, &q_ssl_psk_client_callback);
+         else if (mode == QSslSocket::SslServerMode)
+@@ -464,16 +387,6 @@ void QSslSocketBackendPrivate::destroySslContext()
+     sslContextPointer.clear();
+ }
+ 
+-/*!
+-    \internal
+-*/
+-void QSslSocketPrivate::deinitialize()
+-{
+-    q_CRYPTO_set_id_callback(0);
+-    q_CRYPTO_set_locking_callback(0);
+-    q_ERR_free_strings();
+-}
+-
+ /*!
+     \internal
+ 
+@@ -486,91 +399,6 @@ bool QSslSocketPrivate::supportsSsl()
+     return ensureLibraryLoaded();
+ }
+ 
+-bool QSslSocketPrivate::ensureLibraryLoaded()
+-{
+-    if (!q_resolveOpenSslSymbols())
+-        return false;
+-
+-    // Check if the library itself needs to be initialized.
+-    QMutexLocker locker(openssl_locks()->initLock());
+-
+-    if (!s_libraryLoaded) {
+-        s_libraryLoaded = true;
+-
+-        // Initialize OpenSSL.
+-        q_CRYPTO_set_id_callback(id_function);
+-        q_CRYPTO_set_locking_callback(locking_function);
+-        if (q_SSL_library_init() != 1)
+-            return false;
+-        q_SSL_load_error_strings();
+-        q_OpenSSL_add_all_algorithms();
+-
+-#if OPENSSL_VERSION_NUMBER >= 0x10001000L
+-        if (q_SSLeay() >= 0x10001000L)
+-            QSslSocketBackendPrivate::s_indexForSSLExtraData = q_SSL_get_ex_new_index(0L, NULL, NULL, NULL, NULL);
+-#endif
+-
+-        // Initialize OpenSSL's random seed.
+-        if (!q_RAND_status()) {
+-            qWarning("Random number generator not seeded, disabling SSL support");
+-            return false;
+-        }
+-    }
+-    return true;
+-}
+-
+-void QSslSocketPrivate::ensureCiphersAndCertsLoaded()
+-{
+-    QMutexLocker locker(openssl_locks()->initLock());
+-    if (s_loadedCiphersAndCerts)
+-        return;
+-    s_loadedCiphersAndCerts = true;
+-
+-    resetDefaultCiphers();
+-    resetDefaultEllipticCurves();
+-
+-#if QT_CONFIG(library)
+-    //load symbols needed to receive certificates from system store
+-#if defined(Q_OS_WIN)
+-    HINSTANCE hLib = LoadLibraryW(L"Crypt32");
+-    if (hLib) {
+-        ptrCertOpenSystemStoreW = (PtrCertOpenSystemStoreW)GetProcAddress(hLib, "CertOpenSystemStoreW");
+-        ptrCertFindCertificateInStore = (PtrCertFindCertificateInStore)GetProcAddress(hLib, "CertFindCertificateInStore");
+-        ptrCertCloseStore = (PtrCertCloseStore)GetProcAddress(hLib, "CertCloseStore");
+-        if (!ptrCertOpenSystemStoreW || !ptrCertFindCertificateInStore || !ptrCertCloseStore)
+-            qCWarning(lcSsl, "could not resolve symbols in crypt32 library"); // should never happen
+-    } else {
+-        qCWarning(lcSsl, "could not load crypt32 library"); // should never happen
+-    }
+-#elif defined(Q_OS_QNX)
+-    s_loadRootCertsOnDemand = true;
+-#elif defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
+-    // check whether we can enable on-demand root-cert loading (i.e. check whether the sym links are there)
+-    QList<QByteArray> dirs = unixRootCertDirectories();
+-    QStringList symLinkFilter;
+-    symLinkFilter << QLatin1String("[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9]");
+-    for (int a = 0; a < dirs.count(); ++a) {
+-        QDirIterator iterator(QLatin1String(dirs.at(a)), symLinkFilter, QDir::Files);
+-        if (iterator.hasNext()) {
+-            s_loadRootCertsOnDemand = true;
+-            break;
+-        }
+-    }
+-#endif
+-#endif // QT_CONFIG(library)
+-    // if on-demand loading was not enabled, load the certs now
+-    if (!s_loadRootCertsOnDemand)
+-        setDefaultCaCertificates(systemCaCertificates());
+-#ifdef Q_OS_WIN
+-    //Enabled for fetching additional root certs from windows update on windows 6+
+-    //This flag is set false by setDefaultCaCertificates() indicating the app uses
+-    //its own cert bundle rather than the system one.
+-    //Same logic that disables the unix on demand cert loading.
+-    //Unlike unix, we do preload the certificates from the cert store.
+-    if ((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_6_0)
+-        s_loadRootCertsOnDemand = true;
+-#endif
+-}
+ 
+ /*!
+     \internal
+@@ -587,26 +415,6 @@ void QSslSocketPrivate::ensureInitialized()
+     ensureCiphersAndCertsLoaded();
+ }
+ 
+-long QSslSocketPrivate::sslLibraryVersionNumber()
+-{
+-    if (!supportsSsl())
+-        return 0;
+-
+-    return q_SSLeay();
+-}
+-
+-QString QSslSocketPrivate::sslLibraryVersionString()
+-{
+-    if (!supportsSsl())
+-        return QString();
+-
+-    const char *versionString = q_SSLeay_version(SSLEAY_VERSION);
+-    if (!versionString)
+-        return QString();
+-
+-    return QString::fromLatin1(versionString);
+-}
+-
+ long QSslSocketPrivate::sslLibraryBuildVersionNumber()
+ {
+     return OPENSSL_VERSION_NUMBER;
+@@ -628,7 +436,11 @@ QString QSslSocketPrivate::sslLibraryBuildVersionString()
+ */
+ void QSslSocketPrivate::resetDefaultCiphers()
+ {
++#if QT_CONFIG(opensslv11)
++    SSL_CTX *myCtx = q_SSL_CTX_new(q_TLS_client_method());
++#else
+     SSL_CTX *myCtx = q_SSL_CTX_new(q_SSLv23_client_method());
++#endif
+     SSL *mySsl = q_SSL_new(myCtx);
+ 
+     QList<QSslCipher> ciphers;
+@@ -664,7 +476,7 @@ void QSslSocketPrivate::resetDefaultEllipticCurves()
+     QVector<QSslEllipticCurve> curves;
+ 
+ #ifndef OPENSSL_NO_EC
+-    const size_t curveCount = q_EC_get_builtin_curves(NULL, 0);
++    const size_t curveCount = q_EC_get_builtin_curves(nullptr, 0);
+ 
+     QVarLengthArray<EC_builtin_curve> builtinCurves(static_cast<int>(curveCount));
+ 
+@@ -698,13 +510,14 @@ QList<QSslCertificate> QSslSocketPrivate::systemCaCertificates()
+     if (ptrCertOpenSystemStoreW && ptrCertFindCertificateInStore && ptrCertCloseStore) {
+         HCERTSTORE hSystemStore;
+         hSystemStore = ptrCertOpenSystemStoreW(0, L"ROOT");
+-        if(hSystemStore) {
+-            PCCERT_CONTEXT pc = NULL;
+-            while(1) {
+-                pc = ptrCertFindCertificateInStore( hSystemStore, X509_ASN_ENCODING, 0, CERT_FIND_ANY, NULL, pc);
+-                if(!pc)
++        if (hSystemStore) {
++            PCCERT_CONTEXT pc = nullptr;
++            while (1) {
++                pc = ptrCertFindCertificateInStore(hSystemStore, X509_ASN_ENCODING, 0, CERT_FIND_ANY, nullptr, pc);
++                if (!pc)
+                     break;
+-                QByteArray der((const char *)(pc->pbCertEncoded), static_cast<int>(pc->cbCertEncoded));
++                QByteArray der(reinterpret_cast<const char *>(pc->pbCertEncoded),
++                               static_cast<int>(pc->cbCertEncoded));
+                 QSslCertificate cert(der, QSsl::Der);
+                 systemCerts.append(cert);
+             }
+@@ -1504,14 +1317,8 @@ QSslCipher QSslSocketBackendPrivate::sessionCipher() const
+ {
+     if (!ssl)
+         return QSslCipher();
+-#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+-    // FIXME This is fairly evil, but needed to keep source level compatibility
+-    // with the OpenSSL 0.9.x implementation at maximum -- some other functions
+-    // don't take a const SSL_CIPHER* when they should
+-    SSL_CIPHER *sessionCipher = const_cast<SSL_CIPHER *>(q_SSL_get_current_cipher(ssl));
+-#else
+-    SSL_CIPHER *sessionCipher = q_SSL_get_current_cipher(ssl);
+-#endif
++
++    const SSL_CIPHER *sessionCipher = q_SSL_get_current_cipher(ssl);
+     return sessionCipher ? QSslCipher_from_SSL_CIPHER(sessionCipher) : QSslCipher();
+ }
+ 
+@@ -1537,112 +1344,6 @@ QSsl::SslProtocol QSslSocketBackendPrivate::sessionProtocol() const
+     return QSsl::UnknownProtocol;
+ }
+ 
+-void QSslSocketBackendPrivate::continueHandshake()
+-{
+-    Q_Q(QSslSocket);
+-    // if we have a max read buffer size, reset the plain socket's to match
+-    if (readBufferMaxSize)
+-        plainSocket->setReadBufferSize(readBufferMaxSize);
+-
+-    if (q_SSL_ctrl((ssl), SSL_CTRL_GET_SESSION_REUSED, 0, NULL))
+-        configuration.peerSessionShared = true;
+-
+-#ifdef QT_DECRYPT_SSL_TRAFFIC
+-    if (ssl->session && ssl->s3) {
+-        const char *mk = reinterpret_cast<const char *>(ssl->session->master_key);
+-        QByteArray masterKey(mk, ssl->session->master_key_length);
+-        const char *random = reinterpret_cast<const char *>(ssl->s3->client_random);
+-        QByteArray clientRandom(random, SSL3_RANDOM_SIZE);
+-
+-        // different format, needed for e.g. older Wireshark versions:
+-//        const char *sid = reinterpret_cast<const char *>(ssl->session->session_id);
+-//        QByteArray sessionID(sid, ssl->session->session_id_length);
+-//        QByteArray debugLineRSA("RSA Session-ID:");
+-//        debugLineRSA.append(sessionID.toHex().toUpper());
+-//        debugLineRSA.append(" Master-Key:");
+-//        debugLineRSA.append(masterKey.toHex().toUpper());
+-//        debugLineRSA.append("\n");
+-
+-        QByteArray debugLineClientRandom("CLIENT_RANDOM ");
+-        debugLineClientRandom.append(clientRandom.toHex().toUpper());
+-        debugLineClientRandom.append(" ");
+-        debugLineClientRandom.append(masterKey.toHex().toUpper());
+-        debugLineClientRandom.append("\n");
+-
+-        QString sslKeyFile = QDir::tempPath() + QLatin1String("/qt-ssl-keys");
+-        QFile file(sslKeyFile);
+-        if (!file.open(QIODevice::Append))
+-            qCWarning(lcSsl) << "could not open file" << sslKeyFile << "for appending";
+-        if (!file.write(debugLineClientRandom))
+-            qCWarning(lcSsl) << "could not write to file" << sslKeyFile;
+-        file.close();
+-    } else {
+-        qCWarning(lcSsl, "could not decrypt SSL traffic");
+-    }
+-#endif
+-
+-    // Cache this SSL session inside the QSslContext
+-    if (!(configuration.sslOptions & QSsl::SslOptionDisableSessionSharing)) {
+-        if (!sslContextPointer->cacheSession(ssl)) {
+-            sslContextPointer.clear(); // we could not cache the session
+-        } else {
+-            // Cache the session for permanent usage as well
+-            if (!(configuration.sslOptions & QSsl::SslOptionDisableSessionPersistence)) {
+-                if (!sslContextPointer->sessionASN1().isEmpty())
+-                    configuration.sslSession = sslContextPointer->sessionASN1();
+-                configuration.sslSessionTicketLifeTimeHint = sslContextPointer->sessionTicketLifeTimeHint();
+-            }
+-        }
+-    }
+-
+-#if OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_NEXTPROTONEG)
+-
+-    configuration.nextProtocolNegotiationStatus = sslContextPointer->npnContext().status;
+-    if (sslContextPointer->npnContext().status == QSslConfiguration::NextProtocolNegotiationUnsupported) {
+-        // we could not agree -> be conservative and use HTTP/1.1
+-        configuration.nextNegotiatedProtocol = QByteArrayLiteral("http/1.1");
+-    } else {
+-        const unsigned char *proto = 0;
+-        unsigned int proto_len = 0;
+-#if OPENSSL_VERSION_NUMBER >= 0x10002000L
+-        if (q_SSLeay() >= 0x10002000L) {
+-            q_SSL_get0_alpn_selected(ssl, &proto, &proto_len);
+-            if (proto_len && mode == QSslSocket::SslClientMode) {
+-                // Client does not have a callback that sets it ...
+-                configuration.nextProtocolNegotiationStatus = QSslConfiguration::NextProtocolNegotiationNegotiated;
+-            }
+-        }
+-
+-        if (!proto_len) { // Test if NPN was more lucky ...
+-#else
+-        {
+-#endif
+-            q_SSL_get0_next_proto_negotiated(ssl, &proto, &proto_len);
+-        }
+-
+-        if (proto_len)
+-            configuration.nextNegotiatedProtocol = QByteArray(reinterpret_cast<const char *>(proto), proto_len);
+-        else
+-            configuration.nextNegotiatedProtocol.clear();
+-    }
+-#endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ...
+-
+-#if OPENSSL_VERSION_NUMBER >= 0x10002000L
+-    if (q_SSLeay() >= 0x10002000L && mode == QSslSocket::SslClientMode) {
+-        EVP_PKEY *key;
+-        if (q_SSL_get_server_tmp_key(ssl, &key))
+-            configuration.ephemeralServerKey = QSslKey(key, QSsl::PublicKey);
+-    }
+-#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L ...
+-
+-    connectionEncrypted = true;
+-    emit q->encrypted();
+-    if (autoStartHandshake && pendingClose) {
+-        pendingClose = false;
+-        q->disconnectFromHost();
+-    }
+-}
+-
+ QList<QSslCertificate> QSslSocketBackendPrivate::STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509)
+ {
+     ensureInitialized();
+@@ -1696,12 +1397,12 @@ QList<QSslError> QSslSocketBackendPrivate::verify(const QList<QSslCertificate> &
+     QMutexLocker sslErrorListMutexLocker(&_q_sslErrorList()->mutex);
+ 
+     // Register a custom callback to get all verification errors.
+-    X509_STORE_set_verify_cb_func(certStore, q_X509Callback);
++    q_X509_STORE_set_verify_cb(certStore, q_X509Callback);
+ 
+     // Build the chain of intermediate certificates
+     STACK_OF(X509) *intermediates = 0;
+     if (certificateChain.length() > 1) {
+-        intermediates = (STACK_OF(X509) *) q_sk_new_null();
++        intermediates = (STACK_OF(X509) *) q_OPENSSL_sk_new_null();
+ 
+         if (!intermediates) {
+             q_X509_STORE_free(certStore);
+@@ -1715,11 +1416,8 @@ QList<QSslError> QSslSocketBackendPrivate::verify(const QList<QSslCertificate> &
+                 first = false;
+                 continue;
+             }
+-#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+-            q_sk_push( (_STACK *)intermediates, reinterpret_cast<X509 *>(cert.handle()));
+-#else
+-            q_sk_push( (STACK *)intermediates, reinterpret_cast<char *>(cert.handle()));
+-#endif
++
++            q_OPENSSL_sk_push((OPENSSL_STACK *)intermediates, reinterpret_cast<X509 *>(cert.handle()));
+         }
+     }
+ 
+@@ -1743,11 +1441,7 @@ QList<QSslError> QSslSocketBackendPrivate::verify(const QList<QSslCertificate> &
+     (void) q_X509_verify_cert(storeContext);
+ 
+     q_X509_STORE_CTX_free(storeContext);
+-#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+-    q_sk_free( (_STACK *) intermediates);
+-#else
+-    q_sk_free( (STACK *) intermediates);
+-#endif
++    q_OPENSSL_sk_free((OPENSSL_STACK *)intermediates);
+ 
+     // Now process the errors
+     const auto errorList = std::move(_q_sslErrorList()->errors);
+@@ -1821,7 +1515,8 @@ bool QSslSocketBackendPrivate::importPkcs12(QIODevice *device,
+     // Convert to Qt types
+     if (!key->d->fromEVP_PKEY(pkey)) {
+         qCWarning(lcSsl, "Unable to convert private key");
+-        q_sk_pop_free(reinterpret_cast<STACK *>(ca), reinterpret_cast<void(*)(void*)>(q_sk_free));
++        q_OPENSSL_sk_pop_free(reinterpret_cast<OPENSSL_STACK *>(ca),
++                              reinterpret_cast<void (*)(void *)>(q_OPENSSL_sk_free));
+         q_X509_free(x509);
+         q_EVP_PKEY_free(pkey);
+         q_PKCS12_free(p12);
+@@ -1836,7 +1531,11 @@ bool QSslSocketBackendPrivate::importPkcs12(QIODevice *device,
+         *caCertificates = QSslSocketBackendPrivate::STACKOFX509_to_QSslCertificates(ca);
+ 
+     // Clean up
+-    q_sk_pop_free(reinterpret_cast<STACK *>(ca), reinterpret_cast<void(*)(void*)>(q_sk_free));
++    // TODO: verify ASAP, in the past we had sk_pop_free with q_OPENSSL_sk_free
++    // which seems to be blatantly wrong and even crashes with 1.1.
++    q_OPENSSL_sk_pop_free(reinterpret_cast<OPENSSL_STACK *>(ca),
++                          reinterpret_cast<void (*)(void *)>(q_X509_free));
++
+     q_X509_free(x509);
+     q_EVP_PKEY_free(pkey);
+     q_PKCS12_free(p12);
+diff --git a/src/network/ssl/qsslsocket_openssl11.cpp b/src/network/ssl/qsslsocket_openssl11.cpp
+new file mode 100644
+index 0000000000..b6d18943a5
+--- /dev/null
++++ b/src/network/ssl/qsslsocket_openssl11.cpp
+@@ -0,0 +1,285 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 The Qt Company Ltd.
++** Copyright (C) 2014 Governikus GmbH & Co. KG
++** Copyright (C) 2016 Richard J. Moore <rich@kde.org>
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtNetwork module of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:LGPL$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** GNU Lesser General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU Lesser
++** General Public License version 3 as published by the Free Software
++** Foundation and appearing in the file LICENSE.LGPL3 included in the
++** packaging of this file. Please review the following information to
++** ensure the GNU Lesser General Public License version 3 requirements
++** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
++**
++** GNU General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU
++** General Public License version 2.0 or (at your option) the GNU General
++** Public license version 3 or any later version approved by the KDE Free
++** Qt Foundation. The licenses are as published by the Free Software
++** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
++** included in the packaging of this file. Please review the following
++** information to ensure the GNU General Public License requirements will
++** be met: https://www.gnu.org/licenses/gpl-2.0.html and
++** https://www.gnu.org/licenses/gpl-3.0.html.
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++/****************************************************************************
++**
++** In addition, as a special exception, the copyright holders listed above give
++** permission to link the code of its release of Qt with the OpenSSL project's
++** "OpenSSL" library (or modified versions of the "OpenSSL" library that use the
++** same license as the original version), and distribute the linked executables.
++**
++** You must comply with the GNU General Public License version 2 in all
++** respects for all of the code used other than the "OpenSSL" code.  If you
++** modify this file, you may extend this exception to your version of the file,
++** but you are not obligated to do so.  If you do not wish to do so, delete
++** this exception statement from your version of this file.
++**
++****************************************************************************/
++
++//#define QT_DECRYPT_SSL_TRAFFIC
++
++#include "qssl_p.h"
++#include "qsslsocket_openssl_p.h"
++#include "qsslsocket_openssl_symbols_p.h"
++#include "qsslsocket.h"
++#include "qsslkey.h"
++
++#include <QtCore/qdebug.h>
++#include <QtCore/qdir.h>
++#include <QtCore/qdiriterator.h>
++#include <QtCore/qfile.h>
++#include <QtCore/qmutex.h>
++#include <QtCore/qlibrary.h>
++
++QT_BEGIN_NAMESPACE
++
++Q_GLOBAL_STATIC_WITH_ARGS(QMutex, qt_opensslInitMutex, (QMutex::Recursive))
++
++/*!
++    \internal
++*/
++void QSslSocketPrivate::deinitialize()
++{
++    // This function exists only for compatibility with the pre-11 code,
++    // where deinitialize() actually does some cleanup. To be discarded
++    // once we retire < 1.1.
++}
++
++bool QSslSocketPrivate::ensureLibraryLoaded()
++{
++    if (!q_resolveOpenSslSymbols())
++        return false;
++
++    const QMutexLocker locker(qt_opensslInitMutex);
++
++    if (!s_libraryLoaded) {
++        s_libraryLoaded = true;
++
++        // Initialize OpenSSL.
++        if (q_OPENSSL_init_ssl(0, nullptr) != 1)
++            return false;
++        q_SSL_load_error_strings();
++        q_OpenSSL_add_all_algorithms();
++
++        QSslSocketBackendPrivate::s_indexForSSLExtraData
++            = q_CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, 0L, nullptr, nullptr,
++                                        nullptr, nullptr);
++
++        // Initialize OpenSSL's random seed.
++        if (!q_RAND_status()) {
++            qWarning("Random number generator not seeded, disabling SSL support");
++            return false;
++        }
++    }
++    return true;
++}
++
++void QSslSocketPrivate::ensureCiphersAndCertsLoaded()
++{
++    const QMutexLocker locker(qt_opensslInitMutex);
++
++    if (s_loadedCiphersAndCerts)
++        return;
++    s_loadedCiphersAndCerts = true;
++
++    resetDefaultCiphers();
++    resetDefaultEllipticCurves();
++
++#if QT_CONFIG(library)
++    //load symbols needed to receive certificates from system store
++#if defined(Q_OS_WIN)
++    HINSTANCE hLib = LoadLibraryW(L"Crypt32");
++    if (hLib) {
++        ptrCertOpenSystemStoreW = (PtrCertOpenSystemStoreW)GetProcAddress(hLib, "CertOpenSystemStoreW");
++        ptrCertFindCertificateInStore = (PtrCertFindCertificateInStore)GetProcAddress(hLib, "CertFindCertificateInStore");
++        ptrCertCloseStore = (PtrCertCloseStore)GetProcAddress(hLib, "CertCloseStore");
++        if (!ptrCertOpenSystemStoreW || !ptrCertFindCertificateInStore || !ptrCertCloseStore)
++            qCWarning(lcSsl, "could not resolve symbols in crypt32 library"); // should never happen
++    } else {
++        qCWarning(lcSsl, "could not load crypt32 library"); // should never happen
++    }
++#elif defined(Q_OS_QNX)
++    s_loadRootCertsOnDemand = true;
++#elif defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN)
++    // check whether we can enable on-demand root-cert loading (i.e. check whether the sym links are there)
++    QList<QByteArray> dirs = unixRootCertDirectories();
++    QStringList symLinkFilter;
++    symLinkFilter << QLatin1String("[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9]");
++    for (int a = 0; a < dirs.count(); ++a) {
++        QDirIterator iterator(QLatin1String(dirs.at(a)), symLinkFilter, QDir::Files);
++        if (iterator.hasNext()) {
++            s_loadRootCertsOnDemand = true;
++            break;
++        }
++    }
++#endif
++#endif // QT_CONFIG(library)
++    // if on-demand loading was not enabled, load the certs now
++    if (!s_loadRootCertsOnDemand)
++        setDefaultCaCertificates(systemCaCertificates());
++#ifdef Q_OS_WIN
++    //Enabled for fetching additional root certs from windows update on windows 6+
++    //This flag is set false by setDefaultCaCertificates() indicating the app uses
++    //its own cert bundle rather than the system one.
++    //Same logic that disables the unix on demand cert loading.
++    //Unlike unix, we do preload the certificates from the cert store.
++    if ((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_6_0)
++        s_loadRootCertsOnDemand = true;
++#endif
++}
++
++long QSslSocketPrivate::sslLibraryVersionNumber()
++{
++    if (!supportsSsl())
++        return 0;
++
++    return q_OpenSSL_version_num();
++}
++
++QString QSslSocketPrivate::sslLibraryVersionString()
++{
++    if (!supportsSsl())
++        return QString();
++
++    const char *versionString = q_OpenSSL_version(OPENSSL_VERSION);
++    if (!versionString)
++        return QString();
++
++    return QString::fromLatin1(versionString);
++}
++
++void QSslSocketBackendPrivate::continueHandshake()
++{
++    Q_Q(QSslSocket);
++    // if we have a max read buffer size, reset the plain socket's to match
++    if (readBufferMaxSize)
++        plainSocket->setReadBufferSize(readBufferMaxSize);
++
++    if (q_SSL_session_reused(ssl))
++        configuration.peerSessionShared = true;
++
++#ifdef QT_DECRYPT_SSL_TRAFFIC
++    if (q_SSL_get_session(ssl)) {
++        size_t master_key_len = q_SSL_SESSION_get_master_key(q_SSL_get_session(ssl), 0, 0);
++        size_t client_random_len = q_SSL_get_client_random(ssl, 0, 0);
++        QByteArray masterKey(int(master_key_len), 0); // Will not overflow
++        QByteArray clientRandom(int(client_random_len), 0); // Will not overflow
++
++        q_SSL_SESSION_get_master_key(q_SSL_get_session(ssl),
++                                     reinterpret_cast<unsigned char*>(masterKey.data()),
++                                     masterKey.size());
++        q_SSL_get_client_random(ssl, reinterpret_cast<unsigned char *>(clientRandom.data()),
++                                clientRandom.size());
++
++        QByteArray debugLineClientRandom("CLIENT_RANDOM ");
++        debugLineClientRandom.append(clientRandom.toHex().toUpper());
++        debugLineClientRandom.append(" ");
++        debugLineClientRandom.append(masterKey.toHex().toUpper());
++        debugLineClientRandom.append("\n");
++
++        QString sslKeyFile = QDir::tempPath() + QLatin1String("/qt-ssl-keys");
++        QFile file(sslKeyFile);
++        if (!file.open(QIODevice::Append))
++            qCWarning(lcSsl) << "could not open file" << sslKeyFile << "for appending";
++        if (!file.write(debugLineClientRandom))
++            qCWarning(lcSsl) << "could not write to file" << sslKeyFile;
++        file.close();
++    } else {
++        qCWarning(lcSsl, "could not decrypt SSL traffic");
++    }
++#endif
++
++    // Cache this SSL session inside the QSslContext
++    if (!(configuration.sslOptions & QSsl::SslOptionDisableSessionSharing)) {
++        if (!sslContextPointer->cacheSession(ssl)) {
++            sslContextPointer.clear(); // we could not cache the session
++        } else {
++            // Cache the session for permanent usage as well
++            if (!(configuration.sslOptions & QSsl::SslOptionDisableSessionPersistence)) {
++                if (!sslContextPointer->sessionASN1().isEmpty())
++                    configuration.sslSession = sslContextPointer->sessionASN1();
++                configuration.sslSessionTicketLifeTimeHint = sslContextPointer->sessionTicketLifeTimeHint();
++            }
++        }
++    }
++
++#if !defined(OPENSSL_NO_NEXTPROTONEG)
++
++    configuration.nextProtocolNegotiationStatus = sslContextPointer->npnContext().status;
++    if (sslContextPointer->npnContext().status == QSslConfiguration::NextProtocolNegotiationUnsupported) {
++        // we could not agree -> be conservative and use HTTP/1.1
++        configuration.nextNegotiatedProtocol = QByteArrayLiteral("http/1.1");
++    } else {
++        const unsigned char *proto = 0;
++        unsigned int proto_len = 0;
++
++        q_SSL_get0_alpn_selected(ssl, &proto, &proto_len);
++        if (proto_len && mode == QSslSocket::SslClientMode) {
++            // Client does not have a callback that sets it ...
++            configuration.nextProtocolNegotiationStatus = QSslConfiguration::NextProtocolNegotiationNegotiated;
++        }
++
++        if (!proto_len) { // Test if NPN was more lucky ...
++            q_SSL_get0_next_proto_negotiated(ssl, &proto, &proto_len);
++        }
++
++        if (proto_len)
++            configuration.nextNegotiatedProtocol = QByteArray(reinterpret_cast<const char *>(proto), proto_len);
++        else
++            configuration.nextNegotiatedProtocol.clear();
++    }
++#endif // !defined(OPENSSL_NO_NEXTPROTONEG)
++
++    if (mode == QSslSocket::SslClientMode) {
++        EVP_PKEY *key;
++        if (q_SSL_get_server_tmp_key(ssl, &key))
++            configuration.ephemeralServerKey = QSslKey(key, QSsl::PublicKey);
++    }
++
++    connectionEncrypted = true;
++    emit q->encrypted();
++    if (autoStartHandshake && pendingClose) {
++        pendingClose = false;
++        q->disconnectFromHost();
++    }
++}
++
++QT_END_NAMESPACE
+diff --git a/src/network/ssl/qsslsocket_openssl11_symbols_p.h b/src/network/ssl/qsslsocket_openssl11_symbols_p.h
+new file mode 100644
+index 0000000000..2980b3d23e
+--- /dev/null
++++ b/src/network/ssl/qsslsocket_openssl11_symbols_p.h
+@@ -0,0 +1,132 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 The Qt Company Ltd.
++** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
++** Copyright (C) 2016 Richard J. Moore <rich@kde.org>
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtNetwork module of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:LGPL$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** GNU Lesser General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU Lesser
++** General Public License version 3 as published by the Free Software
++** Foundation and appearing in the file LICENSE.LGPL3 included in the
++** packaging of this file. Please review the following information to
++** ensure the GNU Lesser General Public License version 3 requirements
++** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
++**
++** GNU General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU
++** General Public License version 2.0 or (at your option) the GNU General
++** Public license version 3 or any later version approved by the KDE Free
++** Qt Foundation. The licenses are as published by the Free Software
++** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
++** included in the packaging of this file. Please review the following
++** information to ensure the GNU General Public License requirements will
++** be met: https://www.gnu.org/licenses/gpl-2.0.html and
++** https://www.gnu.org/licenses/gpl-3.0.html.
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++/****************************************************************************
++**
++** In addition, as a special exception, the copyright holders listed above give
++** permission to link the code of its release of Qt with the OpenSSL project's
++** "OpenSSL" library (or modified versions of the "OpenSSL" library that use the
++** same license as the original version), and distribute the linked executables.
++**
++** You must comply with the GNU General Public License version 2 in all
++** respects for all of the code used other than the "OpenSSL" code.  If you
++** modify this file, you may extend this exception to your version of the file,
++** but you are not obligated to do so.  If you do not wish to do so, delete
++** this exception statement from your version of this file.
++**
++****************************************************************************/
++
++#ifndef QSSLSOCKET_OPENSSL11_SYMBOLS_P_H
++#define QSSLSOCKET_OPENSSL11_SYMBOLS_P_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API. It exists purely as an
++// implementation detail. This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++// Note: this file does not have QT_BEGIN_NAMESPACE/QT_END_NAMESPACE, it's done
++// in qsslsocket_openssl_symbols_p.h.
++
++#ifndef QSSLSOCKET_OPENSSL_SYMBOLS_P_H
++#error "You are not supposed to use this header file, include qsslsocket_openssl_symbols_p.h instead"
++#endif
++
++const unsigned char * q_ASN1_STRING_get0_data(const ASN1_STRING *x);
++
++Q_AUTOTEST_EXPORT BIO *q_BIO_new(const BIO_METHOD *a);
++Q_AUTOTEST_EXPORT const BIO_METHOD *q_BIO_s_mem();
++
++int q_DSA_bits(DSA *a);
++int q_EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++int q_RSA_bits(RSA *a);
++int q_OPENSSL_sk_num(OPENSSL_STACK *a);
++void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
++OPENSSL_STACK *q_OPENSSL_sk_new_null();
++void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
++void q_OPENSSL_sk_free(OPENSSL_STACK *a);
++void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
++int q_SSL_session_reused(SSL *a);
++unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
++size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
++size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
++int q_CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
++const SSL_METHOD *q_TLS_method();
++const SSL_METHOD *q_TLS_client_method();
++const SSL_METHOD *q_TLS_server_method();
++ASN1_TIME *q_X509_getm_notBefore(X509 *a);
++ASN1_TIME *q_X509_getm_notAfter(X509 *a);
++
++long q_X509_get_version(X509 *a);
++EVP_PKEY *q_X509_get_pubkey(X509 *a);
++void q_X509_STORE_set_verify_cb(X509_STORE *ctx, X509_STORE_CTX_verify_cb verify_cb);
++STACK_OF(X509) *q_X509_STORE_CTX_get0_chain(X509_STORE_CTX *ctx);
++void q_DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g);
++int q_DH_bits(DH *dh);
++
++# define q_SSL_load_error_strings() q_OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS \
++                                                       | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
++
++#define q_SKM_sk_num(type, st) ((int (*)(const STACK_OF(type) *))q_OPENSSL_sk_num)(st)
++#define q_SKM_sk_value(type, st,i) ((type * (*)(const STACK_OF(type) *, int))q_OPENSSL_sk_value)(st, i)
++
++#define q_OPENSSL_add_all_algorithms_conf()  q_OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
++                                                                   | OPENSSL_INIT_ADD_ALL_DIGESTS \
++                                                                   | OPENSSL_INIT_LOAD_CONFIG, NULL)
++#define  q_OPENSSL_add_all_algorithms_noconf() q_OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
++                                                                    | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)
++
++int q_OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
++void q_CRYPTO_free(void *str, const char *file, int line);
++
++long q_OpenSSL_version_num();
++const char *q_OpenSSL_version(int type);
++
++unsigned long q_SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION *session);
++
++#endif
+diff --git a/src/network/ssl/qsslsocket_openssl_p.h b/src/network/ssl/qsslsocket_openssl_p.h
+index b2adb3e547..7f9e884045 100644
+--- a/src/network/ssl/qsslsocket_openssl_p.h
++++ b/src/network/ssl/qsslsocket_openssl_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2017 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtNetwork module of the Qt Toolkit.
+@@ -98,8 +98,8 @@
+ #include <openssl/crypto.h>
+ #include <openssl/tls1.h>
+ 
+-#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+-typedef _STACK STACK;
++#if QT_CONFIG(opensslv11)
++#include <openssl/dh.h>
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -151,7 +151,7 @@ public:
+ #endif
+ 
+     Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+-    static QSslCipher QSslCipher_from_SSL_CIPHER(SSL_CIPHER *cipher);
++    static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+     static QString getErrorsFromOpenSsl();
+diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index c344a94427..0ef8bf6b5e 100644
+--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2017 The Qt Company Ltd.
+ ** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
++** Copyright (C) 2016 Richard J. Moore <rich@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtNetwork module of the Qt Toolkit.
+@@ -136,49 +137,195 @@ void qsslSocketCannotResolveSymbolWarning(const char *functionName)
+ 
+ #endif // QT_LINKED_OPENSSL
+ 
++#if QT_CONFIG(opensslv11)
++
++// Below are the functions first introduced in version 1.1:
++
++DEFINEFUNC(const unsigned char *, ASN1_STRING_get0_data, const ASN1_STRING *a, a, return 0, return)
++DEFINEFUNC2(int, OPENSSL_init_ssl, uint64_t opts, opts, const OPENSSL_INIT_SETTINGS *settings, settings, return 0, return)
++DEFINEFUNC2(int, OPENSSL_init_crypto, uint64_t opts, opts, const OPENSSL_INIT_SETTINGS *settings, settings, return 0, return)
++DEFINEFUNC(BIO *, BIO_new, const BIO_METHOD *a, a, return 0, return)
++DEFINEFUNC(const BIO_METHOD *, BIO_s_mem, void, DUMMYARG, return 0, return)
++DEFINEFUNC2(int, BN_is_word, BIGNUM *a, a, BN_ULONG w, w, return 0, return)
++DEFINEFUNC(int, EVP_CIPHER_CTX_reset, EVP_CIPHER_CTX *c, c, return 0, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
++DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
++DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
++DEFINEFUNC2(void, OPENSSL_sk_pop_free, OPENSSL_STACK *a, a, void (*b)(void*), b, return, DUMMYARG)
++DEFINEFUNC(OPENSSL_STACK *, OPENSSL_sk_new_null, DUMMYARG, DUMMYARG, return 0, return)
++DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMMYARG)
++DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
++DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return 0, return)
++DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
++DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC3(size_t, SSL_get_client_random, SSL *a, a, unsigned char *out, out, size_t outlen, outlen, return 0, return)
++DEFINEFUNC3(size_t, SSL_SESSION_get_master_key, const SSL_SESSION *ses, ses, unsigned char *out, out, size_t outlen, outlen, return 0, return)
++DEFINEFUNC6(int, CRYPTO_get_ex_new_index, int class_index, class_index, long argl, argl, void *argp, argp, CRYPTO_EX_new *new_func, new_func, CRYPTO_EX_dup *dup_func, dup_func, CRYPTO_EX_free *free_func, free_func, return -1, return)
++
++DEFINEFUNC(const SSL_METHOD *, TLS_method, DUMMYARG, DUMMYARG, return 0, return)
++DEFINEFUNC(const SSL_METHOD *, TLS_client_method, DUMMYARG, DUMMYARG, return 0, return)
++DEFINEFUNC(const SSL_METHOD *, TLS_server_method, DUMMYARG, DUMMYARG, return 0, return)
++DEFINEFUNC(ASN1_TIME *, X509_getm_notBefore, X509 *a, a, return 0, return)
++DEFINEFUNC(ASN1_TIME *, X509_getm_notAfter, X509 *a, a, return 0, return)
++DEFINEFUNC(long, X509_get_version, X509 *a, a, return -1, return)
++DEFINEFUNC(EVP_PKEY *, X509_get_pubkey, X509 *a, a, return 0, return)
++DEFINEFUNC2(void, X509_STORE_set_verify_cb, X509_STORE *a, a, X509_STORE_CTX_verify_cb verify_cb, verify_cb, return, DUMMYARG)
++DEFINEFUNC(STACK_OF(X509) *, X509_STORE_CTX_get0_chain, X509_STORE_CTX *a, a, return 0, return)
++DEFINEFUNC3(void, CRYPTO_free, void *str, str, const char *file, file, int line, line, return, DUMMYARG)
++DEFINEFUNC(long, OpenSSL_version_num, void, DUMMYARG, return 0, return)
++DEFINEFUNC(const char *, OpenSSL_version, int a, a, return 0, return)
++DEFINEFUNC(unsigned long, SSL_SESSION_get_ticket_lifetime_hint, const SSL_SESSION *session, session, return 0, return)
++DEFINEFUNC4(void, DH_get0_pqg, const DH *dh, dh, const BIGNUM **p, p, const BIGNUM **q, q, const BIGNUM **g, g, return, DUMMYARG)
++DEFINEFUNC(int, DH_bits, DH *dh, dh, return 0, return)
++
++#else // QT_CONFIG(opensslv11)
++
++// Functions below are either deprecated or removed in OpenSSL >= 1.1:
++
++DEFINEFUNC(unsigned char *, ASN1_STRING_data, ASN1_STRING *a, a, return 0, return)
++
+ #ifdef SSLEAY_MACROS
+ DEFINEFUNC3(void *, ASN1_dup, i2d_of_void *a, a, d2i_of_void *b, b, char *c, c, return 0, return)
+ #endif
++DEFINEFUNC2(BIO *, BIO_new_file, const char *filename, filename, const char *mode, mode, return 0, return)
++DEFINEFUNC(void, ERR_clear_error, DUMMYARG, DUMMYARG, return, DUMMYARG)
++DEFINEFUNC(BIO *, BIO_new, BIO_METHOD *a, a, return 0, return)
++DEFINEFUNC(BIO_METHOD *, BIO_s_mem, void, DUMMYARG, return 0, return)
++DEFINEFUNC(int, CRYPTO_num_locks, DUMMYARG, DUMMYARG, return 0, return)
++DEFINEFUNC(void, CRYPTO_set_locking_callback, void (*a)(int, int, const char *, int), a, return, DUMMYARG)
++DEFINEFUNC(void, CRYPTO_set_id_callback, unsigned long (*a)(), a, return, DUMMYARG)
++DEFINEFUNC(void, CRYPTO_free, void *a, a, return, DUMMYARG)
++DEFINEFUNC(unsigned long, ERR_peek_last_error, DUMMYARG, DUMMYARG, return 0, return)
++DEFINEFUNC(void, ERR_free_strings, void, DUMMYARG, return, DUMMYARG)
++DEFINEFUNC(void, EVP_CIPHER_CTX_cleanup, EVP_CIPHER_CTX *a, a, return, DUMMYARG)
++DEFINEFUNC(void, EVP_CIPHER_CTX_init, EVP_CIPHER_CTX *a, a, return, DUMMYARG)
++
++#ifdef SSLEAY_MACROS
++DEFINEFUNC6(void *, PEM_ASN1_read_bio, d2i_of_void *a, a, const char *b, b, BIO *c, c, void **d, d, pem_password_cb *e, e, void *f, f, return 0, return)
++DEFINEFUNC6(void *, PEM_ASN1_write_bio, d2i_of_void *a, a, const char *b, b, BIO *c, c, void **d, d, pem_password_cb *e, e, void *f, f, return 0, return)
++#endif // SSLEAY_MACROS
++
++DEFINEFUNC(int, sk_num, STACK *a, a, return -1, return)
++DEFINEFUNC2(void, sk_pop_free, STACK *a, a, void (*b)(void*), b, return, DUMMYARG)
++
++#if OPENSSL_VERSION_NUMBER >= 0x10000000L
++DEFINEFUNC(_STACK *, sk_new_null, DUMMYARG, DUMMYARG, return 0, return)
++DEFINEFUNC2(void, sk_push, _STACK *a, a, void *b, b, return, DUMMYARG)
++DEFINEFUNC(void, sk_free, _STACK *a, a, return, DUMMYARG)
++DEFINEFUNC2(void *, sk_value, STACK *a, a, int b, b, return 0, return)
++#else
++DEFINEFUNC(STACK *, sk_new_null, DUMMYARG, DUMMYARG, return 0, return)
++DEFINEFUNC2(void, sk_push, STACK *a, a, char *b, b, return, DUMMYARG)
++DEFINEFUNC(void, sk_free, STACK *a, a, return, DUMMYARG)
++DEFINEFUNC2(char *, sk_value, STACK *a, a, int b, b, return 0, return)
++#endif // OPENSSL_VERSION_NUMBER >= 0x10000000L
++
++DEFINEFUNC(int, SSL_library_init, void, DUMMYARG, return -1, return)
++DEFINEFUNC(void, SSL_load_error_strings, void, DUMMYARG, return, DUMMYARG)
++
++#if OPENSSL_VERSION_NUMBER >= 0x10001000L
++DEFINEFUNC5(int, SSL_get_ex_new_index, long argl, argl, void *argp, argp, CRYPTO_EX_new *new_func, new_func, CRYPTO_EX_dup *dup_func, dup_func, CRYPTO_EX_free *free_func, free_func, return -1, return)
++#endif // OPENSSL_VERSION_NUMBER >= 0x10001000L
++
++#if OPENSSL_VERSION_NUMBER >= 0x10000000L
++#ifndef OPENSSL_NO_SSL2
++DEFINEFUNC(const SSL_METHOD *, SSLv2_client_method, DUMMYARG, DUMMYARG, return 0, return)
++#endif
++#ifndef OPENSSL_NO_SSL3_METHOD
++DEFINEFUNC(const SSL_METHOD *, SSLv3_client_method, DUMMYARG, DUMMYARG, return 0, return)
++#endif
++DEFINEFUNC(const SSL_METHOD *, SSLv23_client_method, DUMMYARG, DUMMYARG, return 0, return)
++DEFINEFUNC(const SSL_METHOD *, TLSv1_client_method, DUMMYARG, DUMMYARG, return 0, return)
++#if OPENSSL_VERSION_NUMBER >= 0x10001000L
++DEFINEFUNC(const SSL_METHOD *, TLSv1_1_client_method, DUMMYARG, DUMMYARG, return 0, return)
++DEFINEFUNC(const SSL_METHOD *, TLSv1_2_client_method, DUMMYARG, DUMMYARG, return 0, return)
++#endif
++#ifndef OPENSSL_NO_SSL2
++DEFINEFUNC(const SSL_METHOD *, SSLv2_server_method, DUMMYARG, DUMMYARG, return 0, return)
++#endif
++#ifndef OPENSSL_NO_SSL3_METHOD
++DEFINEFUNC(const SSL_METHOD *, SSLv3_server_method, DUMMYARG, DUMMYARG, return 0, return)
++#endif
++DEFINEFUNC(const SSL_METHOD *, SSLv23_server_method, DUMMYARG, DUMMYARG, return 0, return)
++DEFINEFUNC(const SSL_METHOD *, TLSv1_server_method, DUMMYARG, DUMMYARG, return 0, return)
++#if OPENSSL_VERSION_NUMBER >= 0x10001000L
++DEFINEFUNC(const SSL_METHOD *, TLSv1_1_server_method, DUMMYARG, DUMMYARG, return 0, return)
++DEFINEFUNC(const SSL_METHOD *, TLSv1_2_server_method, DUMMYARG, DUMMYARG, return 0, return)
++#endif
++#else
++#ifndef OPENSSL_NO_SSL2
++DEFINEFUNC(SSL_METHOD *, SSLv2_client_method, DUMMYARG, DUMMYARG, return 0, return)
++#endif
++#ifndef OPENSSL_NO_SSL3_METHOD
++DEFINEFUNC(SSL_METHOD *, SSLv3_client_method, DUMMYARG, DUMMYARG, return 0, return)
++#endif
++DEFINEFUNC(SSL_METHOD *, SSLv23_client_method, DUMMYARG, DUMMYARG, return 0, return)
++DEFINEFUNC(SSL_METHOD *, TLSv1_client_method, DUMMYARG, DUMMYARG, return 0, return)
++#ifndef OPENSSL_NO_SSL2
++DEFINEFUNC(SSL_METHOD *, SSLv2_server_method, DUMMYARG, DUMMYARG, return 0, return)
++#endif
++#ifndef OPENSSL_NO_SSL3_METHOD
++DEFINEFUNC(SSL_METHOD *, SSLv3_server_method, DUMMYARG, DUMMYARG, return 0, return)
++#endif
++DEFINEFUNC(SSL_METHOD *, SSLv23_server_method, DUMMYARG, DUMMYARG, return 0, return)
++DEFINEFUNC(SSL_METHOD *, TLSv1_server_method, DUMMYARG, DUMMYARG, return 0, return)
++#endif
++
++DEFINEFUNC(STACK_OF(X509) *, X509_STORE_CTX_get_chain, X509_STORE_CTX *a, a, return 0, return)
++
++#ifdef SSLEAY_MACROS
++DEFINEFUNC2(int, i2d_DSAPrivateKey, const DSA *a, a, unsigned char **b, b, return -1, return)
++DEFINEFUNC2(int, i2d_RSAPrivateKey, const RSA *a, a, unsigned char **b, b, return -1, return)
++#ifndef OPENSSL_NO_EC
++DEFINEFUNC2(int, i2d_ECPrivateKey, const EC_KEY *a, a, unsigned char **b, b, return -1, return)
++#endif
++DEFINEFUNC3(RSA *, d2i_RSAPrivateKey, RSA **a, a, unsigned char **b, b, long c, c, return 0, return)
++DEFINEFUNC3(DSA *, d2i_DSAPrivateKey, DSA **a, a, unsigned char **b, b, long c, c, return 0, return)
++#ifndef OPENSSL_NO_EC
++DEFINEFUNC3(EC_KEY *, d2i_ECPrivateKey, EC_KEY **a, a, unsigned char **b, b, long c, c, return 0, return)
++#endif
++#endif
++DEFINEFUNC(char *, CONF_get1_default_config_file, DUMMYARG, DUMMYARG, return 0, return)
++DEFINEFUNC(void, OPENSSL_add_all_algorithms_noconf, void, DUMMYARG, return, DUMMYARG)
++DEFINEFUNC(void, OPENSSL_add_all_algorithms_conf, void, DUMMYARG, return, DUMMYARG)
++DEFINEFUNC(long, SSLeay, void, DUMMYARG, return 0, return)
++DEFINEFUNC(const char *, SSLeay_version, int a, a, return 0, return)
++
++#endif // QT_CONFIG(opensslv11)
++
+ DEFINEFUNC(long, ASN1_INTEGER_get, ASN1_INTEGER *a, a, return 0, return)
+-DEFINEFUNC(unsigned char *, ASN1_STRING_data, ASN1_STRING *a, a, return 0, return)
+ DEFINEFUNC(int, ASN1_STRING_length, ASN1_STRING *a, a, return 0, return)
+-DEFINEFUNC2(int, ASN1_STRING_to_UTF8, unsigned char **a, a, ASN1_STRING *b, b, return 0, return);
++DEFINEFUNC2(int, ASN1_STRING_to_UTF8, unsigned char **a, a, ASN1_STRING *b, b, return 0, return)
+ DEFINEFUNC4(long, BIO_ctrl, BIO *a, a, int b, b, long c, c, void *d, d, return -1, return)
+ DEFINEFUNC(int, BIO_free, BIO *a, a, return 0, return)
+-DEFINEFUNC(BIO *, BIO_new, BIO_METHOD *a, a, return 0, return)
+ DEFINEFUNC2(BIO *, BIO_new_mem_buf, void *a, a, int b, b, return 0, return)
+ DEFINEFUNC3(int, BIO_read, BIO *a, a, void *b, b, int c, c, return -1, return)
+-DEFINEFUNC(BIO_METHOD *, BIO_s_mem, void, DUMMYARG, return 0, return)
++
+ DEFINEFUNC3(int, BIO_write, BIO *a, a, const void *b, b, int c, c, return -1, return)
+ DEFINEFUNC(int, BN_num_bits, const BIGNUM *a, a, return 0, return)
+-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+-DEFINEFUNC2(int, BN_is_word, BIGNUM *a, a, BN_ULONG w, w, return 0, return)
+-#endif
+ DEFINEFUNC2(BN_ULONG, BN_mod_word, const BIGNUM *a, a, BN_ULONG w, w, return static_cast<BN_ULONG>(-1), return)
+ #ifndef OPENSSL_NO_EC
+ DEFINEFUNC(const EC_GROUP*, EC_KEY_get0_group, const EC_KEY* k, k, return 0, return)
+ DEFINEFUNC(int, EC_GROUP_get_degree, const EC_GROUP* g, g, return 0, return)
+ #endif
+-DEFINEFUNC(int, CRYPTO_num_locks, DUMMYARG, DUMMYARG, return 0, return)
+-DEFINEFUNC(void, CRYPTO_set_locking_callback, void (*a)(int, int, const char *, int), a, return, DUMMYARG)
+-DEFINEFUNC(void, CRYPTO_set_id_callback, unsigned long (*a)(), a, return, DUMMYARG)
+-DEFINEFUNC(void, CRYPTO_free, void *a, a, return, DUMMYARG)
+ DEFINEFUNC(DSA *, DSA_new, DUMMYARG, DUMMYARG, return 0, return)
+ DEFINEFUNC(void, DSA_free, DSA *a, a, return, DUMMYARG)
+ DEFINEFUNC3(X509 *, d2i_X509, X509 **a, a, const unsigned char **b, b, long c, c, return 0, return)
+ DEFINEFUNC2(char *, ERR_error_string, unsigned long a, a, char *b, b, return 0, return)
+ DEFINEFUNC(unsigned long, ERR_get_error, DUMMYARG, DUMMYARG, return 0, return)
+-DEFINEFUNC(void, ERR_free_strings, void, DUMMYARG, return, DUMMYARG)
+-DEFINEFUNC(void, EVP_CIPHER_CTX_cleanup, EVP_CIPHER_CTX *a, a, return, DUMMYARG)
+-DEFINEFUNC(void, EVP_CIPHER_CTX_init, EVP_CIPHER_CTX *a, a, return, DUMMYARG)
+-DEFINEFUNC4(int, EVP_CIPHER_CTX_ctrl, EVP_CIPHER_CTX *ctx, ctx, int type, type, int arg, arg, void *ptr, ptr, return 0, return);
++DEFINEFUNC(EVP_CIPHER_CTX *, EVP_CIPHER_CTX_new, void, DUMMYARG, return 0, return)
++DEFINEFUNC(void, EVP_CIPHER_CTX_free, EVP_CIPHER_CTX *a, a, return, DUMMYARG)
++DEFINEFUNC4(int, EVP_CIPHER_CTX_ctrl, EVP_CIPHER_CTX *ctx, ctx, int type, type, int arg, arg, void *ptr, ptr, return 0, return)
+ DEFINEFUNC2(int, EVP_CIPHER_CTX_set_key_length, EVP_CIPHER_CTX *ctx, ctx, int keylen, keylen, return 0, return)
+-DEFINEFUNC5(int, EVP_CipherInit, EVP_CIPHER_CTX *ctx, ctx, const EVP_CIPHER *type, type, const unsigned char *key, key, const unsigned char *iv, iv, int enc, enc, return 0, return);
+-DEFINEFUNC5(int, EVP_CipherUpdate, EVP_CIPHER_CTX *ctx, ctx, unsigned char *out, out, int *outl, outl, const unsigned char *in, in, int inl, inl, return 0, return);
+-DEFINEFUNC3(int, EVP_CipherFinal, EVP_CIPHER_CTX *ctx, ctx, unsigned char *out, out, int *outl, outl, return 0, return);
++DEFINEFUNC5(int, EVP_CipherInit, EVP_CIPHER_CTX *ctx, ctx, const EVP_CIPHER *type, type, const unsigned char *key, key, const unsigned char *iv, iv, int enc, enc, return 0, return)
++DEFINEFUNC6(int, EVP_CipherInit_ex, EVP_CIPHER_CTX *ctx, ctx, const EVP_CIPHER *cipher, cipher, ENGINE *impl, impl, const unsigned char *key, key, const unsigned char *iv, iv, int enc, enc, return 0, return)
++DEFINEFUNC5(int, EVP_CipherUpdate, EVP_CIPHER_CTX *ctx, ctx, unsigned char *out, out, int *outl, outl, const unsigned char *in, in, int inl, inl, return 0, return)
++DEFINEFUNC3(int, EVP_CipherFinal, EVP_CIPHER_CTX *ctx, ctx, unsigned char *out, out, int *outl, outl, return 0, return)
+ DEFINEFUNC(const EVP_CIPHER *, EVP_des_cbc, DUMMYARG, DUMMYARG, return 0, return)
+ DEFINEFUNC(const EVP_CIPHER *, EVP_des_ede3_cbc, DUMMYARG, DUMMYARG, return 0, return)
+ DEFINEFUNC(const EVP_CIPHER *, EVP_rc2_cbc, DUMMYARG, DUMMYARG, return 0, return)
++DEFINEFUNC(const EVP_MD *, EVP_sha1, DUMMYARG, DUMMYARG, return 0, return)
+ DEFINEFUNC3(int, EVP_PKEY_assign, EVP_PKEY *a, a, int b, b, char *c, c, return -1, return)
+ DEFINEFUNC2(int, EVP_PKEY_set1_RSA, EVP_PKEY *a, a, RSA *b, b, return -1, return)
+ DEFINEFUNC2(int, EVP_PKEY_set1_DSA, EVP_PKEY *a, a, DSA *b, b, return -1, return)
+@@ -202,10 +349,8 @@ DEFINEFUNC3(int, i2t_ASN1_OBJECT, char *a, a, int b, b, ASN1_OBJECT *c, c, retur
+ DEFINEFUNC4(int, OBJ_obj2txt, char *a, a, int b, b, ASN1_OBJECT *c, c, int d, d, return -1, return)
+ 
+ DEFINEFUNC(int, OBJ_obj2nid, const ASN1_OBJECT *a, a, return NID_undef, return)
+-#ifdef SSLEAY_MACROS
+-DEFINEFUNC6(void *, PEM_ASN1_read_bio, d2i_of_void *a, a, const char *b, b, BIO *c, c, void **d, d, pem_password_cb *e, e, void *f, f, return 0, return)
+-DEFINEFUNC6(void *, PEM_ASN1_write_bio, d2i_of_void *a, a, const char *b, b, BIO *c, c, void **d, d, pem_password_cb *e, e, void *f, f, return 0, return)
+-#else
++
++#ifndef SSLEAY_MACROS
+ DEFINEFUNC4(EVP_PKEY *, PEM_read_bio_PrivateKey, BIO *a, a, EVP_PKEY **b, b, pem_password_cb *c, c, void *d, d, return 0, return)
+ DEFINEFUNC4(DSA *, PEM_read_bio_DSAPrivateKey, BIO *a, a, DSA **b, b, pem_password_cb *c, c, void *d, d, return 0, return)
+ DEFINEFUNC4(RSA *, PEM_read_bio_RSAPrivateKey, BIO *a, a, RSA **b, b, pem_password_cb *c, c, void *d, d, return 0, return)
+@@ -218,7 +363,7 @@ DEFINEFUNC7(int, PEM_write_bio_RSAPrivateKey, BIO *a, a, RSA *b, b, const EVP_CI
+ #ifndef OPENSSL_NO_EC
+ DEFINEFUNC7(int, PEM_write_bio_ECPrivateKey, BIO *a, a, EC_KEY *b, b, const EVP_CIPHER *c, c, unsigned char *d, d, int e, e, pem_password_cb *f, f, void *g, g, return 0, return)
+ #endif
+-#endif
++#endif // !SSLEAY_MACROS
+ DEFINEFUNC4(EVP_PKEY *, PEM_read_bio_PUBKEY, BIO *a, a, EVP_PKEY **b, b, pem_password_cb *c, c, void *d, d, return 0, return)
+ DEFINEFUNC4(DSA *, PEM_read_bio_DSA_PUBKEY, BIO *a, a, DSA **b, b, pem_password_cb *c, c, void *d, d, return 0, return)
+ DEFINEFUNC4(RSA *, PEM_read_bio_RSA_PUBKEY, BIO *a, a, RSA **b, b, pem_password_cb *c, c, void *d, d, return 0, return)
+@@ -234,23 +379,10 @@ DEFINEFUNC2(void, RAND_seed, const void *a, a, int b, b, return, DUMMYARG)
+ DEFINEFUNC(int, RAND_status, void, DUMMYARG, return -1, return)
+ DEFINEFUNC(RSA *, RSA_new, DUMMYARG, DUMMYARG, return 0, return)
+ DEFINEFUNC(void, RSA_free, RSA *a, a, return, DUMMYARG)
+-DEFINEFUNC(int, sk_num, STACK *a, a, return -1, return)
+-DEFINEFUNC2(void, sk_pop_free, STACK *a, a, void (*b)(void*), b, return, DUMMYARG)
+-#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+-DEFINEFUNC(_STACK *, sk_new_null, DUMMYARG, DUMMYARG, return 0, return)
+-DEFINEFUNC2(void, sk_push, _STACK *a, a, void *b, b, return, DUMMYARG)
+-DEFINEFUNC(void, sk_free, _STACK *a, a, return, DUMMYARG)
+-DEFINEFUNC2(void *, sk_value, STACK *a, a, int b, b, return 0, return)
+-#else
+-DEFINEFUNC(STACK *, sk_new_null, DUMMYARG, DUMMYARG, return 0, return)
+-DEFINEFUNC2(void, sk_push, STACK *a, a, char *b, b, return, DUMMYARG)
+-DEFINEFUNC(void, sk_free, STACK *a, a, return, DUMMYARG)
+-DEFINEFUNC2(char *, sk_value, STACK *a, a, int b, b, return 0, return)
+-#endif
+ DEFINEFUNC(int, SSL_accept, SSL *a, a, return -1, return)
+ DEFINEFUNC(int, SSL_clear, SSL *a, a, return -1, return)
+-DEFINEFUNC3(char *, SSL_CIPHER_description, SSL_CIPHER *a, a, char *b, b, int c, c, return 0, return)
+-DEFINEFUNC2(int, SSL_CIPHER_get_bits, SSL_CIPHER *a, a, int *b, b, return 0, return)
++DEFINEFUNC3(char *, SSL_CIPHER_description, const SSL_CIPHER *a, a, char *b, b, int c, c, return 0, return)
++DEFINEFUNC2(int, SSL_CIPHER_get_bits, const SSL_CIPHER *a, a, int *b, b, return 0, return)
+ DEFINEFUNC(int, SSL_connect, SSL *a, a, return -1, return)
+ DEFINEFUNC(int, SSL_CTX_check_private_key, const SSL_CTX *a, a, return -1, return)
+ DEFINEFUNC4(long, SSL_CTX_ctrl, SSL_CTX *a, a, int b, b, long c, c, void *d, d, return -1, return)
+@@ -287,8 +419,6 @@ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ #else
+ DEFINEFUNC(long, SSL_get_verify_result, SSL *a, a, return -1, return)
+ #endif
+-DEFINEFUNC(int, SSL_library_init, void, DUMMYARG, return -1, return)
+-DEFINEFUNC(void, SSL_load_error_strings, void, DUMMYARG, return, DUMMYARG)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return 0, return)
+ DEFINEFUNC4(long, SSL_ctrl, SSL *a, a, int cmd, cmd, long larg, larg, void *parg, parg, return -1, return)
+ DEFINEFUNC3(int, SSL_read, SSL *a, a, void *b, b, int c, c, return -1, return)
+@@ -301,7 +431,6 @@ DEFINEFUNC(void, SSL_SESSION_free, SSL_SESSION *ses, ses, return, DUMMYARG)
+ DEFINEFUNC(SSL_SESSION*, SSL_get1_session, SSL *ssl, ssl, return 0, return)
+ DEFINEFUNC(SSL_SESSION*, SSL_get_session, const SSL *ssl, ssl, return 0, return)
+ #if OPENSSL_VERSION_NUMBER >= 0x10001000L
+-DEFINEFUNC5(int, SSL_get_ex_new_index, long argl, argl, void *argp, argp, CRYPTO_EX_new *new_func, new_func, CRYPTO_EX_dup *dup_func, dup_func, CRYPTO_EX_free *free_func, free_func, return -1, return)
+ DEFINEFUNC3(int, SSL_set_ex_data, SSL *ssl, ssl, int idx, idx, void *arg, arg, return 0, return)
+ DEFINEFUNC2(void *, SSL_get_ex_data, const SSL *ssl, ssl, int idx, idx, return NULL, return)
+ #endif
+@@ -310,51 +439,9 @@ DEFINEFUNC2(void, SSL_set_psk_client_callback, SSL* ssl, ssl, q_psk_client_callb
+ DEFINEFUNC2(void, SSL_set_psk_server_callback, SSL* ssl, ssl, q_psk_server_callback_t callback, callback, return, DUMMYARG)
+ DEFINEFUNC2(int, SSL_CTX_use_psk_identity_hint, SSL_CTX* ctx, ctx, const char *hint, hint, return 0, return)
+ #endif
+-#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+-#ifndef OPENSSL_NO_SSL2
+-DEFINEFUNC(const SSL_METHOD *, SSLv2_client_method, DUMMYARG, DUMMYARG, return 0, return)
+-#endif
+-#ifndef OPENSSL_NO_SSL3_METHOD
+-DEFINEFUNC(const SSL_METHOD *, SSLv3_client_method, DUMMYARG, DUMMYARG, return 0, return)
+-#endif
+-DEFINEFUNC(const SSL_METHOD *, SSLv23_client_method, DUMMYARG, DUMMYARG, return 0, return)
+-DEFINEFUNC(const SSL_METHOD *, TLSv1_client_method, DUMMYARG, DUMMYARG, return 0, return)
+-#if OPENSSL_VERSION_NUMBER >= 0x10001000L
+-DEFINEFUNC(const SSL_METHOD *, TLSv1_1_client_method, DUMMYARG, DUMMYARG, return 0, return)
+-DEFINEFUNC(const SSL_METHOD *, TLSv1_2_client_method, DUMMYARG, DUMMYARG, return 0, return)
+-#endif
+-#ifndef OPENSSL_NO_SSL2
+-DEFINEFUNC(const SSL_METHOD *, SSLv2_server_method, DUMMYARG, DUMMYARG, return 0, return)
+-#endif
+-#ifndef OPENSSL_NO_SSL3_METHOD
+-DEFINEFUNC(const SSL_METHOD *, SSLv3_server_method, DUMMYARG, DUMMYARG, return 0, return)
+-#endif
+-DEFINEFUNC(const SSL_METHOD *, SSLv23_server_method, DUMMYARG, DUMMYARG, return 0, return)
+-DEFINEFUNC(const SSL_METHOD *, TLSv1_server_method, DUMMYARG, DUMMYARG, return 0, return)
+-#if OPENSSL_VERSION_NUMBER >= 0x10001000L
+-DEFINEFUNC(const SSL_METHOD *, TLSv1_1_server_method, DUMMYARG, DUMMYARG, return 0, return)
+-DEFINEFUNC(const SSL_METHOD *, TLSv1_2_server_method, DUMMYARG, DUMMYARG, return 0, return)
+-#endif
+-#else
+-#ifndef OPENSSL_NO_SSL2
+-DEFINEFUNC(SSL_METHOD *, SSLv2_client_method, DUMMYARG, DUMMYARG, return 0, return)
+-#endif
+-#ifndef OPENSSL_NO_SSL3_METHOD
+-DEFINEFUNC(SSL_METHOD *, SSLv3_client_method, DUMMYARG, DUMMYARG, return 0, return)
+-#endif
+-DEFINEFUNC(SSL_METHOD *, SSLv23_client_method, DUMMYARG, DUMMYARG, return 0, return)
+-DEFINEFUNC(SSL_METHOD *, TLSv1_client_method, DUMMYARG, DUMMYARG, return 0, return)
+-#ifndef OPENSSL_NO_SSL2
+-DEFINEFUNC(SSL_METHOD *, SSLv2_server_method, DUMMYARG, DUMMYARG, return 0, return)
+-#endif
+-#ifndef OPENSSL_NO_SSL3_METHOD
+-DEFINEFUNC(SSL_METHOD *, SSLv3_server_method, DUMMYARG, DUMMYARG, return 0, return)
+-#endif
+-DEFINEFUNC(SSL_METHOD *, SSLv23_server_method, DUMMYARG, DUMMYARG, return 0, return)
+-DEFINEFUNC(SSL_METHOD *, TLSv1_server_method, DUMMYARG, DUMMYARG, return 0, return)
+-#endif
+ DEFINEFUNC3(int, SSL_write, SSL *a, a, const void *b, b, int c, c, return -1, return)
+ DEFINEFUNC2(int, X509_cmp, X509 *a, a, X509 *b, b, return -1, return)
++DEFINEFUNC4(int, X509_digest, const X509 *x509, x509, const EVP_MD *type, type, unsigned char *md, md, unsigned int *len, len, return -1, return)
+ #ifndef SSLEAY_MACROS
+ DEFINEFUNC(X509 *, X509_dup, X509 *a, a, return 0, return)
+ #endif
+@@ -378,6 +465,7 @@ DEFINEFUNC2(int, ASN1_STRING_print, BIO *a, a, ASN1_STRING *b, b, return 0, retu
+ DEFINEFUNC2(int, X509_check_issued, X509 *a, a, X509 *b, b, return -1, return)
+ DEFINEFUNC(X509_NAME *, X509_get_issuer_name, X509 *a, a, return 0, return)
+ DEFINEFUNC(X509_NAME *, X509_get_subject_name, X509 *a, a, return 0, return)
++DEFINEFUNC(ASN1_INTEGER *, X509_get_serialNumber, X509 *a, a, return 0, return)
+ DEFINEFUNC(int, X509_verify_cert, X509_STORE_CTX *a, a, return -1, return)
+ DEFINEFUNC(int, X509_NAME_entry_count, X509_NAME *a, a, return 0, return)
+ DEFINEFUNC2(X509_NAME_ENTRY *, X509_NAME_get_entry, X509_NAME *a, a, int b, b, return 0, return)
+@@ -393,25 +481,8 @@ DEFINEFUNC2(int, X509_STORE_CTX_set_purpose, X509_STORE_CTX *a, a, int b, b, ret
+ DEFINEFUNC(int, X509_STORE_CTX_get_error, X509_STORE_CTX *a, a, return -1, return)
+ DEFINEFUNC(int, X509_STORE_CTX_get_error_depth, X509_STORE_CTX *a, a, return -1, return)
+ DEFINEFUNC(X509 *, X509_STORE_CTX_get_current_cert, X509_STORE_CTX *a, a, return 0, return)
+-DEFINEFUNC(STACK_OF(X509) *, X509_STORE_CTX_get_chain, X509_STORE_CTX *a, a, return 0, return)
+ DEFINEFUNC(X509_STORE_CTX *, X509_STORE_CTX_new, DUMMYARG, DUMMYARG, return 0, return)
+-#ifdef SSLEAY_MACROS
+-DEFINEFUNC2(int, i2d_DSAPrivateKey, const DSA *a, a, unsigned char **b, b, return -1, return)
+-DEFINEFUNC2(int, i2d_RSAPrivateKey, const RSA *a, a, unsigned char **b, b, return -1, return)
+-#ifndef OPENSSL_NO_EC
+-DEFINEFUNC2(int, i2d_ECPrivateKey, const EC_KEY *a, a, unsigned char **b, b, return -1, return)
+-#endif
+-DEFINEFUNC3(RSA *, d2i_RSAPrivateKey, RSA **a, a, unsigned char **b, b, long c, c, return 0, return)
+-DEFINEFUNC3(DSA *, d2i_DSAPrivateKey, DSA **a, a, unsigned char **b, b, long c, c, return 0, return)
+-#ifndef OPENSSL_NO_EC
+-DEFINEFUNC3(EC_KEY *, d2i_ECPrivateKey, EC_KEY **a, a, unsigned char **b, b, long c, c, return 0, return)
+-#endif
+-#endif
+-DEFINEFUNC(void, OPENSSL_add_all_algorithms_noconf, void, DUMMYARG, return, DUMMYARG)
+-DEFINEFUNC(void, OPENSSL_add_all_algorithms_conf, void, DUMMYARG, return, DUMMYARG)
+ DEFINEFUNC3(int, SSL_CTX_load_verify_locations, SSL_CTX *ctx, ctx, const char *CAfile, CAfile, const char *CApath, CApath, return 0, return)
+-DEFINEFUNC(long, SSLeay, void, DUMMYARG, return 0, return)
+-DEFINEFUNC(const char *, SSLeay_version, int a, a, return 0, return)
+ DEFINEFUNC2(int, i2d_SSL_SESSION, SSL_SESSION *in, in, unsigned char **pp, pp, return 0, return)
+ DEFINEFUNC3(SSL_SESSION *, d2i_SSL_SESSION, SSL_SESSION **a, a, const unsigned char **pp, pp, long length, length, return 0, return)
+ #if OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_NEXTPROTONEG)
+@@ -694,8 +765,8 @@ static QPair<QLibrary*, QLibrary*> loadOpenSsl()
+ #ifndef Q_OS_DARWIN
+     // second attempt: find the development files libssl.so and libcrypto.so
+     //
+-    // disabled on OS X/iOS:
+-    //  OS X's /usr/lib/libssl.dylib, /usr/lib/libcrypto.dylib will be picked up in the third
++    // disabled on macOS/iOS:
++    //  macOS'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);
+@@ -754,7 +825,11 @@ bool q_resolveOpenSslSymbols()
+     static bool symbolsResolved = false;
+     static bool triedToResolveSymbols = false;
+ #ifndef QT_NO_THREAD
++#if QT_CONFIG(opensslv11)
++    QMutexLocker locker(QMutexPool::globalInstanceGet((void *)&q_OPENSSL_init_ssl));
++#else
+     QMutexLocker locker(QMutexPool::globalInstanceGet((void *)&q_SSL_library_init));
++#endif
+ #endif
+     if (symbolsResolved)
+         return true;
+@@ -771,11 +846,145 @@ bool q_resolveOpenSslSymbols()
+         // failed to load them
+         return false;
+ 
++#if QT_CONFIG(opensslv11)
++
++    RESOLVEFUNC(OPENSSL_init_ssl)
++    RESOLVEFUNC(OPENSSL_init_crypto)
++    RESOLVEFUNC(ASN1_STRING_get0_data)
++    RESOLVEFUNC(EVP_CIPHER_CTX_reset)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++    RESOLVEFUNC(RSA_bits)
++    RESOLVEFUNC(OPENSSL_sk_new_null)
++    RESOLVEFUNC(OPENSSL_sk_push)
++    RESOLVEFUNC(OPENSSL_sk_free)
++    RESOLVEFUNC(OPENSSL_sk_num)
++    RESOLVEFUNC(OPENSSL_sk_pop_free)
++    RESOLVEFUNC(OPENSSL_sk_value)
++    RESOLVEFUNC(DH_get0_pqg)
++    RESOLVEFUNC(SSL_CTX_set_options)
++    RESOLVEFUNC(SSL_get_client_random)
++    RESOLVEFUNC(SSL_SESSION_get_master_key)
++    RESOLVEFUNC(SSL_session_reused)
++    RESOLVEFUNC(SSL_get_session)
++    RESOLVEFUNC(CRYPTO_get_ex_new_index)
++    RESOLVEFUNC(TLS_method)
++    RESOLVEFUNC(TLS_client_method)
++    RESOLVEFUNC(TLS_server_method)
++    RESOLVEFUNC(X509_STORE_CTX_get0_chain)
++    RESOLVEFUNC(X509_getm_notBefore)
++    RESOLVEFUNC(X509_getm_notAfter)
++    RESOLVEFUNC(X509_get_version)
++    RESOLVEFUNC(X509_get_pubkey)
++    RESOLVEFUNC(X509_STORE_set_verify_cb)
++    RESOLVEFUNC(CRYPTO_free)
++    RESOLVEFUNC(OpenSSL_version_num)
++    RESOLVEFUNC(OpenSSL_version)
++    if (!_q_OpenSSL_version) {
++        // Apparently, we were built with OpenSSL 1.1 enabled but are now using
++        // a wrong library.
++        delete libs.first;
++        delete libs.second;
++        qCWarning(lcSsl, "Incompatible version of OpenSSL");
++        return false;
++    }
++
++    RESOLVEFUNC(SSL_SESSION_get_ticket_lifetime_hint)
++    RESOLVEFUNC(DH_bits)
++    RESOLVEFUNC(DSA_bits)
++
++#else // !opensslv11
++
++    RESOLVEFUNC(ASN1_STRING_data)
++
+ #ifdef SSLEAY_MACROS
+     RESOLVEFUNC(ASN1_dup)
++#endif // SSLEAY_MACROS
++    RESOLVEFUNC(BIO_new_file)
++    RESOLVEFUNC(ERR_clear_error)
++    RESOLVEFUNC(CRYPTO_free)
++    RESOLVEFUNC(CRYPTO_num_locks)
++    RESOLVEFUNC(CRYPTO_set_id_callback)
++    RESOLVEFUNC(CRYPTO_set_locking_callback)
++    RESOLVEFUNC(ERR_peek_last_error)
++    RESOLVEFUNC(ERR_free_strings)
++    RESOLVEFUNC(EVP_CIPHER_CTX_cleanup)
++    RESOLVEFUNC(EVP_CIPHER_CTX_init)
++
++#ifdef SSLEAY_MACROS // ### verify
++    RESOLVEFUNC(PEM_ASN1_read_bio)
++#endif // SSLEAY_MACROS
++
++    RESOLVEFUNC(sk_new_null)
++    RESOLVEFUNC(sk_push)
++    RESOLVEFUNC(sk_free)
++    RESOLVEFUNC(sk_num)
++    RESOLVEFUNC(sk_pop_free)
++    RESOLVEFUNC(sk_value)
++    RESOLVEFUNC(SSL_library_init)
++    RESOLVEFUNC(SSL_load_error_strings)
++#if OPENSSL_VERSION_NUMBER >= 0x10001000L
++    RESOLVEFUNC(SSL_get_ex_new_index)
++#endif
++#ifndef OPENSSL_NO_SSL2
++    RESOLVEFUNC(SSLv2_client_method)
+ #endif
++#ifndef OPENSSL_NO_SSL3_METHOD
++    RESOLVEFUNC(SSLv3_client_method)
++#endif
++    RESOLVEFUNC(SSLv23_client_method)
++    RESOLVEFUNC(TLSv1_client_method)
++#if OPENSSL_VERSION_NUMBER >= 0x10001000L
++    RESOLVEFUNC(TLSv1_1_client_method)
++    RESOLVEFUNC(TLSv1_2_client_method)
++#endif
++#ifndef OPENSSL_NO_SSL2
++    RESOLVEFUNC(SSLv2_server_method)
++#endif
++#ifndef OPENSSL_NO_SSL3_METHOD
++    RESOLVEFUNC(SSLv3_server_method)
++#endif
++    RESOLVEFUNC(SSLv23_server_method)
++    RESOLVEFUNC(TLSv1_server_method)
++#if OPENSSL_VERSION_NUMBER >= 0x10001000L
++    RESOLVEFUNC(TLSv1_1_server_method)
++    RESOLVEFUNC(TLSv1_2_server_method)
++#endif
++    RESOLVEFUNC(X509_STORE_CTX_get_chain)
++#ifdef SSLEAY_MACROS
++    RESOLVEFUNC(i2d_DSAPrivateKey)
++    RESOLVEFUNC(i2d_RSAPrivateKey)
++    RESOLVEFUNC(d2i_DSAPrivateKey)
++    RESOLVEFUNC(d2i_RSAPrivateKey)
++#endif
++    RESOLVEFUNC(CONF_get1_default_config_file)
++    RESOLVEFUNC(OPENSSL_add_all_algorithms_noconf)
++    RESOLVEFUNC(OPENSSL_add_all_algorithms_conf)
++    RESOLVEFUNC(SSLeay)
++
++    if (!_q_SSLeay || q_SSLeay() >= 0x10100000L) {
++        // OpenSSL 1.1 has deprecated and removed SSLeay. We consider a failure to
++        // resolve this symbol as a failure to resolve symbols.
++        // The right operand of '||' above is ... a bit of paranoia.
++        delete libs.first;
++        delete libs.second;
++        qCWarning(lcSsl, "Incompatible version of OpenSSL");
++        return false;
++    }
++
++
++    RESOLVEFUNC(SSLeay_version)
++
++#ifndef OPENSSL_NO_EC
++#if OPENSSL_VERSION_NUMBER >= 0x10002000L
++    if (q_SSLeay() >= 0x10002000L)
++        RESOLVEFUNC(EC_curve_nist2nid)
++#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L
++#endif // OPENSSL_NO_EC
++
++
++#endif // !opensslv11
++
+     RESOLVEFUNC(ASN1_INTEGER_get)
+-    RESOLVEFUNC(ASN1_STRING_data)
+     RESOLVEFUNC(ASN1_STRING_length)
+     RESOLVEFUNC(ASN1_STRING_to_UTF8)
+     RESOLVEFUNC(BIO_ctrl)
+@@ -794,25 +1003,22 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(BN_is_word)
+ #endif
+     RESOLVEFUNC(BN_mod_word)
+-    RESOLVEFUNC(CRYPTO_free)
+-    RESOLVEFUNC(CRYPTO_num_locks)
+-    RESOLVEFUNC(CRYPTO_set_id_callback)
+-    RESOLVEFUNC(CRYPTO_set_locking_callback)
+     RESOLVEFUNC(DSA_new)
+     RESOLVEFUNC(DSA_free)
+     RESOLVEFUNC(ERR_error_string)
+     RESOLVEFUNC(ERR_get_error)
+-    RESOLVEFUNC(ERR_free_strings)
+-    RESOLVEFUNC(EVP_CIPHER_CTX_cleanup)
+-    RESOLVEFUNC(EVP_CIPHER_CTX_init)
++    RESOLVEFUNC(EVP_CIPHER_CTX_new)
++    RESOLVEFUNC(EVP_CIPHER_CTX_free)
+     RESOLVEFUNC(EVP_CIPHER_CTX_ctrl)
+     RESOLVEFUNC(EVP_CIPHER_CTX_set_key_length)
+     RESOLVEFUNC(EVP_CipherInit)
++    RESOLVEFUNC(EVP_CipherInit_ex)
+     RESOLVEFUNC(EVP_CipherUpdate)
+     RESOLVEFUNC(EVP_CipherFinal)
+     RESOLVEFUNC(EVP_des_cbc)
+     RESOLVEFUNC(EVP_des_ede3_cbc)
+     RESOLVEFUNC(EVP_rc2_cbc)
++    RESOLVEFUNC(EVP_sha1)
+     RESOLVEFUNC(EVP_PKEY_assign)
+     RESOLVEFUNC(EVP_PKEY_set1_RSA)
+     RESOLVEFUNC(EVP_PKEY_set1_DSA)
+@@ -834,9 +1040,8 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(i2t_ASN1_OBJECT)
+     RESOLVEFUNC(OBJ_obj2txt)
+     RESOLVEFUNC(OBJ_obj2nid)
+-#ifdef SSLEAY_MACROS // ### verify
+-    RESOLVEFUNC(PEM_ASN1_read_bio)
+-#else
++
++#ifndef SSLEAY_MACROS
+     RESOLVEFUNC(PEM_read_bio_PrivateKey)
+     RESOLVEFUNC(PEM_read_bio_DSAPrivateKey)
+     RESOLVEFUNC(PEM_read_bio_RSAPrivateKey)
+@@ -849,7 +1054,8 @@ bool q_resolveOpenSslSymbols()
+ #ifndef OPENSSL_NO_EC
+     RESOLVEFUNC(PEM_write_bio_ECPrivateKey)
+ #endif
+-#endif
++#endif // !SSLEAY_MACROS
++
+     RESOLVEFUNC(PEM_read_bio_PUBKEY)
+     RESOLVEFUNC(PEM_read_bio_DSA_PUBKEY)
+     RESOLVEFUNC(PEM_read_bio_RSA_PUBKEY)
+@@ -865,12 +1071,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(RAND_status)
+     RESOLVEFUNC(RSA_new)
+     RESOLVEFUNC(RSA_free)
+-    RESOLVEFUNC(sk_new_null)
+-    RESOLVEFUNC(sk_push)
+-    RESOLVEFUNC(sk_free)
+-    RESOLVEFUNC(sk_num)
+-    RESOLVEFUNC(sk_pop_free)
+-    RESOLVEFUNC(sk_value)
+     RESOLVEFUNC(SSL_CIPHER_description)
+     RESOLVEFUNC(SSL_CIPHER_get_bits)
+     RESOLVEFUNC(SSL_CTX_check_private_key)
+@@ -898,8 +1098,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
+     RESOLVEFUNC(SSL_get_peer_certificate)
+     RESOLVEFUNC(SSL_get_verify_result)
+-    RESOLVEFUNC(SSL_library_init)
+-    RESOLVEFUNC(SSL_load_error_strings)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_ctrl)
+     RESOLVEFUNC(SSL_read)
+@@ -912,7 +1110,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_get1_session)
+     RESOLVEFUNC(SSL_get_session)
+ #if OPENSSL_VERSION_NUMBER >= 0x10001000L
+-    RESOLVEFUNC(SSL_get_ex_new_index)
+     RESOLVEFUNC(SSL_set_ex_data)
+     RESOLVEFUNC(SSL_get_ex_data)
+ #endif
+@@ -922,30 +1119,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_CTX_use_psk_identity_hint)
+ #endif
+     RESOLVEFUNC(SSL_write)
+-#ifndef OPENSSL_NO_SSL2
+-    RESOLVEFUNC(SSLv2_client_method)
+-#endif
+-#ifndef OPENSSL_NO_SSL3_METHOD
+-    RESOLVEFUNC(SSLv3_client_method)
+-#endif
+-    RESOLVEFUNC(SSLv23_client_method)
+-    RESOLVEFUNC(TLSv1_client_method)
+-#if OPENSSL_VERSION_NUMBER >= 0x10001000L
+-    RESOLVEFUNC(TLSv1_1_client_method)
+-    RESOLVEFUNC(TLSv1_2_client_method)
+-#endif
+-#ifndef OPENSSL_NO_SSL2
+-    RESOLVEFUNC(SSLv2_server_method)
+-#endif
+-#ifndef OPENSSL_NO_SSL3_METHOD
+-    RESOLVEFUNC(SSLv3_server_method)
+-#endif
+-    RESOLVEFUNC(SSLv23_server_method)
+-    RESOLVEFUNC(TLSv1_server_method)
+-#if OPENSSL_VERSION_NUMBER >= 0x10001000L
+-    RESOLVEFUNC(TLSv1_1_server_method)
+-    RESOLVEFUNC(TLSv1_2_server_method)
+-#endif
+     RESOLVEFUNC(X509_NAME_entry_count)
+     RESOLVEFUNC(X509_NAME_get_entry)
+     RESOLVEFUNC(X509_NAME_ENTRY_get_data)
+@@ -961,12 +1134,12 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(X509_STORE_CTX_get_error)
+     RESOLVEFUNC(X509_STORE_CTX_get_error_depth)
+     RESOLVEFUNC(X509_STORE_CTX_get_current_cert)
+-    RESOLVEFUNC(X509_STORE_CTX_get_chain)
+     RESOLVEFUNC(X509_cmp)
+ #ifndef SSLEAY_MACROS
+     RESOLVEFUNC(X509_dup)
+ #endif
+     RESOLVEFUNC(X509_print)
++    RESOLVEFUNC(X509_digest)
+     RESOLVEFUNC(X509_EXTENSION_get_object)
+     RESOLVEFUNC(X509_free)
+     RESOLVEFUNC(X509_get_ext)
+@@ -982,20 +1155,11 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(X509_check_issued)
+     RESOLVEFUNC(X509_get_issuer_name)
+     RESOLVEFUNC(X509_get_subject_name)
++    RESOLVEFUNC(X509_get_serialNumber)
+     RESOLVEFUNC(X509_verify_cert)
+     RESOLVEFUNC(d2i_X509)
+     RESOLVEFUNC(i2d_X509)
+-#ifdef SSLEAY_MACROS
+-    RESOLVEFUNC(i2d_DSAPrivateKey)
+-    RESOLVEFUNC(i2d_RSAPrivateKey)
+-    RESOLVEFUNC(d2i_DSAPrivateKey)
+-    RESOLVEFUNC(d2i_RSAPrivateKey)
+-#endif
+-    RESOLVEFUNC(OPENSSL_add_all_algorithms_noconf)
+-    RESOLVEFUNC(OPENSSL_add_all_algorithms_conf)
+     RESOLVEFUNC(SSL_CTX_load_verify_locations)
+-    RESOLVEFUNC(SSLeay)
+-    RESOLVEFUNC(SSLeay_version)
+     RESOLVEFUNC(i2d_SSL_SESSION)
+     RESOLVEFUNC(d2i_SSL_SESSION)
+ #if OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_NEXTPROTONEG)
+@@ -1019,27 +1183,14 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EC_KEY_new_by_curve_name)
+     RESOLVEFUNC(EC_KEY_free)
+     RESOLVEFUNC(EC_get_builtin_curves)
+-#if OPENSSL_VERSION_NUMBER >= 0x10002000L
+-    if (q_SSLeay() >= 0x10002000L)
+-        RESOLVEFUNC(EC_curve_nist2nid)
+-#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L
+ #endif // OPENSSL_NO_EC
+     RESOLVEFUNC(PKCS12_parse)
+     RESOLVEFUNC(d2i_PKCS12_bio)
+     RESOLVEFUNC(PKCS12_free)
+ 
++    symbolsResolved = true;
+     delete libs.first;
+     delete libs.second;
+-    if (!_q_SSLeay || q_SSLeay() >= 0x10100000L) {
+-        // OpenSSL 1.1 deprecated and removed SSLeay. We consider a failure to
+-        // resolve this symbol as a failure to resolve symbols.
+-        // The right operand of '||' above ... a bit of paranoia.
+-        qCWarning(lcSsl, "Incompatible version of OpenSSL");
+-        return false;
+-    }
+-
+-    symbolsResolved = true;
+-
+     return true;
+ }
+ #endif // QT_CONFIG(library)
+diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index b35a895d38..796bf2d4f5 100644
+--- a/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2017 The Qt Company Ltd.
+ ** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+ ** Contact: https://www.qt.io/licensing/
+ **
+@@ -56,6 +56,7 @@
+ #ifndef QSSLSOCKET_OPENSSL_SYMBOLS_P_H
+ #define QSSLSOCKET_OPENSSL_SYMBOLS_P_H
+ 
++
+ //
+ //  W A R N I N G
+ //  -------------
+@@ -215,17 +216,20 @@ QT_BEGIN_NAMESPACE
+ 
+ #endif // !defined QT_LINKED_OPENSSL
+ 
++#if QT_CONFIG(opensslv11)
++#include "qsslsocket_openssl11_symbols_p.h"
++#else
++#include "qsslsocket_opensslpre11_symbols_p.h"
++#endif // QT_CONFIG
++
+ bool q_resolveOpenSslSymbols();
+ long q_ASN1_INTEGER_get(ASN1_INTEGER *a);
+-unsigned char * q_ASN1_STRING_data(ASN1_STRING *a);
+ int q_ASN1_STRING_length(ASN1_STRING *a);
+ int q_ASN1_STRING_to_UTF8(unsigned char **a, ASN1_STRING *b);
+ long q_BIO_ctrl(BIO *a, int b, long c, void *d);
+ Q_AUTOTEST_EXPORT int q_BIO_free(BIO *a);
+-Q_AUTOTEST_EXPORT BIO *q_BIO_new(BIO_METHOD *a);
+ BIO *q_BIO_new_mem_buf(void *a, int b);
+ int q_BIO_read(BIO *a, void *b, int c);
+-Q_AUTOTEST_EXPORT BIO_METHOD *q_BIO_s_mem();
+ Q_AUTOTEST_EXPORT int q_BIO_write(BIO *a, const void *b, int c);
+ int q_BN_num_bits(const BIGNUM *a);
+ #if OPENSSL_VERSION_NUMBER >= 0x10100000L
+@@ -247,26 +251,23 @@ BN_ULONG q_BN_mod_word(const BIGNUM *a, BN_ULONG w);
+ const EC_GROUP* q_EC_KEY_get0_group(const EC_KEY* k);
+ int q_EC_GROUP_get_degree(const EC_GROUP* g);
+ #endif
+-int q_CRYPTO_num_locks();
+-void q_CRYPTO_set_locking_callback(void (*a)(int, int, const char *, int));
+-void q_CRYPTO_set_id_callback(unsigned long (*a)());
+-void q_CRYPTO_free(void *a);
+ DSA *q_DSA_new();
+ void q_DSA_free(DSA *a);
+ X509 *q_d2i_X509(X509 **a, const unsigned char **b, long c);
+ char *q_ERR_error_string(unsigned long a, char *b);
+ unsigned long q_ERR_get_error();
+-void q_ERR_free_strings();
+-void q_EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
+-void q_EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
++EVP_CIPHER_CTX *q_EVP_CIPHER_CTX_new();
++void q_EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a);
+ int q_EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
+ int q_EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
+ int q_EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, const unsigned char *key, const unsigned char *iv, int enc);
++int q_EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, const unsigned char *key, const unsigned char *iv, int enc);
+ int q_EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl);
+ int q_EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
+ const EVP_CIPHER *q_EVP_des_cbc();
+ const EVP_CIPHER *q_EVP_des_ede3_cbc();
+ const EVP_CIPHER *q_EVP_rc2_cbc();
++const EVP_MD *q_EVP_sha1();
+ int q_EVP_PKEY_assign(EVP_PKEY *a, int b, char *c);
+ Q_AUTOTEST_EXPORT int q_EVP_PKEY_set1_RSA(EVP_PKEY *a, RSA *b);
+ int q_EVP_PKEY_set1_DSA(EVP_PKEY *a, DSA *b);
+@@ -310,7 +311,7 @@ int q_PEM_write_bio_RSAPrivateKey(BIO *a, RSA *b, const EVP_CIPHER *c, unsigned
+ int q_PEM_write_bio_ECPrivateKey(BIO *a, EC_KEY *b, const EVP_CIPHER *c, unsigned char *d,
+                                   int e, pem_password_cb *f, void *g);
+ #endif
+-#endif
++#endif // SSLEAY_MACROS
+ Q_AUTOTEST_EXPORT EVP_PKEY *q_PEM_read_bio_PUBKEY(BIO *a, EVP_PKEY **b, pem_password_cb *c, void *d);
+ DSA *q_PEM_read_bio_DSA_PUBKEY(BIO *a, DSA **b, pem_password_cb *c, void *d);
+ RSA *q_PEM_read_bio_RSA_PUBKEY(BIO *a, RSA **b, pem_password_cb *c, void *d);
+@@ -326,23 +327,10 @@ void q_RAND_seed(const void *a, int b);
+ int q_RAND_status();
+ RSA *q_RSA_new();
+ void q_RSA_free(RSA *a);
+-int q_sk_num(STACK *a);
+-void q_sk_pop_free(STACK *a, void (*b)(void *));
+-#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+-_STACK *q_sk_new_null();
+-void q_sk_push(_STACK *st, void *data);
+-void q_sk_free(_STACK *a);
+-void * q_sk_value(STACK *a, int b);
+-#else
+-STACK *q_sk_new_null();
+-void q_sk_push(STACK *st, char *data);
+-void q_sk_free(STACK *a);
+-char * q_sk_value(STACK *a, int b);
+-#endif
+ int q_SSL_accept(SSL *a);
+ int q_SSL_clear(SSL *a);
+-char *q_SSL_CIPHER_description(SSL_CIPHER *a, char *b, int c);
+-int q_SSL_CIPHER_get_bits(SSL_CIPHER *a, int *b);
++char *q_SSL_CIPHER_description(const SSL_CIPHER *a, char *b, int c);
++int q_SSL_CIPHER_get_bits(const SSL_CIPHER *a, int *b);
+ int q_SSL_connect(SSL *a);
+ int q_SSL_CTX_check_private_key(const SSL_CTX *a);
+ long q_SSL_CTX_ctrl(SSL_CTX *a, int b, long c, void *d);
+@@ -374,8 +362,6 @@ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+ X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+-int q_SSL_library_init();
+-void q_SSL_load_error_strings();
+ SSL *q_SSL_new(SSL_CTX *a);
+ long q_SSL_ctrl(SSL *ssl,int cmd, long larg, void *parg);
+ int q_SSL_read(SSL *a, void *b, int c);
+@@ -388,7 +374,6 @@ void q_SSL_SESSION_free(SSL_SESSION *ses);
+ SSL_SESSION *q_SSL_get1_session(SSL *ssl);
+ SSL_SESSION *q_SSL_get_session(const SSL *ssl);
+ #if OPENSSL_VERSION_NUMBER >= 0x10001000L
+-int q_SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
+ int q_SSL_set_ex_data(SSL *ssl, int idx, void *arg);
+ void *q_SSL_get_ex_data(const SSL *ssl, int idx);
+ #endif
+@@ -399,49 +384,6 @@ typedef unsigned int (*q_psk_server_callback_t)(SSL *ssl, const char *identity,
+ void q_SSL_set_psk_server_callback(SSL *ssl, q_psk_server_callback_t callback);
+ int q_SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *hint);
+ #endif // OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)
+-#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+-#ifndef OPENSSL_NO_SSL2
+-const SSL_METHOD *q_SSLv2_client_method();
+-#endif
+-#ifndef OPENSSL_NO_SSL3_METHOD
+-const SSL_METHOD *q_SSLv3_client_method();
+-#endif
+-const SSL_METHOD *q_SSLv23_client_method();
+-const SSL_METHOD *q_TLSv1_client_method();
+-const SSL_METHOD *q_TLSv1_1_client_method();
+-const SSL_METHOD *q_TLSv1_2_client_method();
+-#ifndef OPENSSL_NO_SSL2
+-const SSL_METHOD *q_SSLv2_server_method();
+-#endif
+-#ifndef OPENSSL_NO_SSL3_METHOD
+-const SSL_METHOD *q_SSLv3_server_method();
+-#endif
+-const SSL_METHOD *q_SSLv23_server_method();
+-const SSL_METHOD *q_TLSv1_server_method();
+-const SSL_METHOD *q_TLSv1_1_server_method();
+-const SSL_METHOD *q_TLSv1_2_server_method();
+-#else
+-#ifndef OPENSSL_NO_SSL2
+-SSL_METHOD *q_SSLv2_client_method();
+-#endif
+-#ifndef OPENSSL_NO_SSL3_METHOD
+-SSL_METHOD *q_SSLv3_client_method();
+-#endif
+-SSL_METHOD *q_SSLv23_client_method();
+-SSL_METHOD *q_TLSv1_client_method();
+-SSL_METHOD *q_TLSv1_1_client_method();
+-SSL_METHOD *q_TLSv1_2_client_method();
+-#ifndef OPENSSL_NO_SSL2
+-SSL_METHOD *q_SSLv2_server_method();
+-#endif
+-#ifndef OPENSSL_NO_SSL3_METHOD
+-SSL_METHOD *q_SSLv3_server_method();
+-#endif
+-SSL_METHOD *q_SSLv23_server_method();
+-SSL_METHOD *q_TLSv1_server_method();
+-SSL_METHOD *q_TLSv1_1_server_method();
+-SSL_METHOD *q_TLSv1_2_server_method();
+-#endif
+ int q_SSL_write(SSL *a, const void *b, int c);
+ int q_X509_cmp(X509 *a, X509 *b);
+ #ifdef SSLEAY_MACROS
+@@ -452,6 +394,7 @@ void *q_ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x);
+ X509 *q_X509_dup(X509 *a);
+ #endif
+ void q_X509_print(BIO *a, X509*b);
++int q_X509_digest(const X509 *x509, const EVP_MD *type, unsigned char *md, unsigned int *len);
+ ASN1_OBJECT *q_X509_EXTENSION_get_object(X509_EXTENSION *a);
+ void q_X509_free(X509 *a);
+ X509_EXTENSION *q_X509_get_ext(X509 *a, int b);
+@@ -471,6 +414,7 @@ int q_ASN1_STRING_print(BIO *a, ASN1_STRING *b);
+ int q_X509_check_issued(X509 *a, X509 *b);
+ X509_NAME *q_X509_get_issuer_name(X509 *a);
+ X509_NAME *q_X509_get_subject_name(X509 *a);
++ASN1_INTEGER *q_X509_get_serialNumber(X509 *a);
+ int q_X509_verify_cert(X509_STORE_CTX *ctx);
+ int q_X509_NAME_entry_count(X509_NAME *a);
+ X509_NAME_ENTRY *q_X509_NAME_get_entry(X509_NAME *a,int b);
+@@ -488,7 +432,6 @@ int q_X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);
+ int q_X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);
+ int q_X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);
+ X509 *q_X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);
+-STACK_OF(X509) *q_X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx);
+ 
+ // Diffie-Hellman support
+ DH *q_DH_new();
+@@ -522,34 +465,9 @@ int q_PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
+ PKCS12 *q_d2i_PKCS12_bio(BIO *bio, PKCS12 **pkcs12);
+ void q_PKCS12_free(PKCS12 *pkcs12);
+ 
+-
+ #define q_BIO_get_mem_data(b, pp) (int)q_BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)
+ #define q_BIO_pending(b) (int)q_BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)
+-#ifdef SSLEAY_MACROS
+-int     q_i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);
+-int     q_i2d_RSAPrivateKey(const RSA *a, unsigned char **pp);
+-RSA *q_d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length);
+-DSA *q_d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length);
+-#define q_PEM_read_bio_RSAPrivateKey(bp, x, cb, u) \
+-        (RSA *)q_PEM_ASN1_read_bio( \
+-        (void *(*)(void**, const unsigned char**, long int))q_d2i_RSAPrivateKey, PEM_STRING_RSA, bp, (void **)x, cb, u)
+-#define q_PEM_read_bio_DSAPrivateKey(bp, x, cb, u) \
+-        (DSA *)q_PEM_ASN1_read_bio( \
+-        (void *(*)(void**, const unsigned char**, long int))q_d2i_DSAPrivateKey, PEM_STRING_DSA, bp, (void **)x, cb, u)
+-#define q_PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \
+-        PEM_ASN1_write_bio((int (*)(void*, unsigned char**))q_i2d_RSAPrivateKey,PEM_STRING_RSA,\
+-                           bp,(char *)x,enc,kstr,klen,cb,u)
+-#define q_PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \
+-        PEM_ASN1_write_bio((int (*)(void*, unsigned char**))q_i2d_DSAPrivateKey,PEM_STRING_DSA,\
+-                           bp,(char *)x,enc,kstr,klen,cb,u)
+-#define q_PEM_read_bio_DHparams(bp, dh, cb, u) \
+-        (DH *)q_PEM_ASN1_read_bio( \
+-        (void *(*)(void**, const unsigned char**, long int))q_d2i_DHparams, PEM_STRING_DHPARAMS, bp, (void **)x, cb, u)
+-#endif
+-#define q_SSL_CTX_set_options(ctx,op) q_SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL)
+ #define q_SSL_CTX_set_mode(ctx,op) q_SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL)
+-#define q_SKM_sk_num(type, st) ((int (*)(const STACK_OF(type) *))q_sk_num)(st)
+-#define q_SKM_sk_value(type, st,i) ((type * (*)(const STACK_OF(type) *, int))q_sk_value)(st, i)
+ #define q_sk_GENERAL_NAME_num(st) q_SKM_sk_num(GENERAL_NAME, (st))
+ #define q_sk_GENERAL_NAME_value(st, i) q_SKM_sk_value(GENERAL_NAME, (st), (i))
+ #define q_sk_X509_num(st) q_SKM_sk_num(X509, (st))
+@@ -558,18 +476,12 @@ DSA *q_d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length);
+ #define q_sk_SSL_CIPHER_value(st, i) q_SKM_sk_value(SSL_CIPHER, (st), (i))
+ #define q_SSL_CTX_add_extra_chain_cert(ctx,x509) \
+         q_SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509)
+-#define q_X509_get_notAfter(x) X509_get_notAfter(x)
+-#define q_X509_get_notBefore(x) X509_get_notBefore(x)
+ #define q_EVP_PKEY_assign_RSA(pkey,rsa) q_EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
+                                         (char *)(rsa))
+ #define q_EVP_PKEY_assign_DSA(pkey,dsa) q_EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
+                                         (char *)(dsa))
+ #define q_OpenSSL_add_all_algorithms() q_OPENSSL_add_all_algorithms_conf()
+-void q_OPENSSL_add_all_algorithms_noconf();
+-void q_OPENSSL_add_all_algorithms_conf();
+ int q_SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, const char *CApath);
+-long q_SSLeay();
+-const char *q_SSLeay_version(int type);
+ int q_i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp);
+ SSL_SESSION *q_d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, long length);
+ 
+diff --git a/src/network/ssl/qsslsocket_opensslpre11.cpp b/src/network/ssl/qsslsocket_opensslpre11.cpp
+new file mode 100644
+index 0000000000..e51888c5f2
+--- /dev/null
++++ b/src/network/ssl/qsslsocket_opensslpre11.cpp
+@@ -0,0 +1,424 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 The Qt Company Ltd.
++** Copyright (C) 2014 Governikus GmbH & Co. KG
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtNetwork module of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:LGPL$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** GNU Lesser General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU Lesser
++** General Public License version 3 as published by the Free Software
++** Foundation and appearing in the file LICENSE.LGPL3 included in the
++** packaging of this file. Please review the following information to
++** ensure the GNU Lesser General Public License version 3 requirements
++** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
++**
++** GNU General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU
++** General Public License version 2.0 or (at your option) the GNU General
++** Public license version 3 or any later version approved by the KDE Free
++** Qt Foundation. The licenses are as published by the Free Software
++** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
++** included in the packaging of this file. Please review the following
++** information to ensure the GNU General Public License requirements will
++** be met: https://www.gnu.org/licenses/gpl-2.0.html and
++** https://www.gnu.org/licenses/gpl-3.0.html.
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++/****************************************************************************
++**
++** In addition, as a special exception, the copyright holders listed above give
++** permission to link the code of its release of Qt with the OpenSSL project's
++** "OpenSSL" library (or modified versions of the "OpenSSL" library that use the
++** same license as the original version), and distribute the linked executables.
++**
++** You must comply with the GNU General Public License version 2 in all
++** respects for all of the code used other than the "OpenSSL" code.  If you
++** modify this file, you may extend this exception to your version of the file,
++** but you are not obligated to do so.  If you do not wish to do so, delete
++** this exception statement from your version of this file.
++**
++****************************************************************************/
++
++//#define QT_DECRYPT_SSL_TRAFFIC
++
++#include "qssl_p.h"
++#include "qsslsocket_openssl_p.h"
++#include "qsslsocket_openssl_symbols_p.h"
++#include "qsslsocket.h"
++#include "qsslkey.h"
++
++#include <QtCore/qdebug.h>
++#include <QtCore/qdir.h>
++#include <QtCore/qdiriterator.h>
++#include <QtCore/qthread.h>
++#include <QtCore/qfile.h>
++#include <QtCore/qmutex.h>
++#include <QtCore/qlibrary.h>
++
++QT_BEGIN_NAMESPACE
++
++/* \internal
++
++    From OpenSSL's thread(3) manual page:
++
++    OpenSSL can safely be used in multi-threaded applications provided that at
++    least two callback functions are set.
++
++    locking_function(int mode, int n, const char *file, int line) is needed to
++    perform locking on shared data structures.  (Note that OpenSSL uses a
++    number of global data structures that will be implicitly shared
++    whenever multiple threads use OpenSSL.)  Multi-threaded
++    applications will crash at random if it is not set.  ...
++    ...
++    id_function(void) is a function that returns a thread ID. It is not
++    needed on Windows nor on platforms where getpid() returns a different
++    ID for each thread (most notably Linux)
++*/
++
++class QOpenSslLocks
++{
++public:
++    QOpenSslLocks()
++        : initLocker(QMutex::Recursive),
++          locksLocker(QMutex::Recursive)
++    {
++        QMutexLocker locker(&locksLocker);
++        int numLocks = q_CRYPTO_num_locks();
++        locks = new QMutex *[numLocks];
++        memset(locks, 0, numLocks * sizeof(QMutex *));
++    }
++    ~QOpenSslLocks()
++    {
++        QMutexLocker locker(&locksLocker);
++        for (int i = 0; i < q_CRYPTO_num_locks(); ++i)
++            delete locks[i];
++        delete [] locks;
++
++        QSslSocketPrivate::deinitialize();
++    }
++    QMutex *lock(int num)
++    {
++        QMutexLocker locker(&locksLocker);
++        QMutex *tmp = locks[num];
++        if (!tmp)
++            tmp = locks[num] = new QMutex(QMutex::Recursive);
++        return tmp;
++    }
++
++    QMutex *globalLock()
++    {
++        return &locksLocker;
++    }
++
++    QMutex *initLock()
++    {
++        return &initLocker;
++    }
++
++private:
++    QMutex initLocker;
++    QMutex locksLocker;
++    QMutex **locks;
++};
++
++Q_GLOBAL_STATIC(QOpenSslLocks, openssl_locks)
++
++extern "C" {
++static void locking_function(int mode, int lockNumber, const char *, int)
++{
++    QMutex *mutex = openssl_locks()->lock(lockNumber);
++
++    // Lock or unlock it
++    if (mode & CRYPTO_LOCK)
++        mutex->lock();
++    else
++        mutex->unlock();
++}
++static unsigned long id_function()
++{
++    return (quintptr)QThread::currentThreadId();
++}
++
++} // extern "C"
++
++static void q_OpenSSL_add_all_algorithms_safe()
++{
++#ifdef Q_OS_WIN
++    // Prior to version 1.0.1m an attempt to call OpenSSL_add_all_algorithms on
++    // Windows could result in 'exit' call from OPENSSL_config (QTBUG-43843).
++    // We can predict this and avoid OPENSSL_add_all_algorithms call.
++    // From OpenSSL docs:
++    // "An application does not need to add algorithms to use them explicitly,
++    // for example by EVP_sha1(). It just needs to add them if it (or any of
++    // the functions it calls) needs to lookup algorithms.
++    // The cipher and digest lookup functions are used in many parts of the
++    // library. If the table is not initialized several functions will
++    // misbehave and complain they cannot find algorithms. This includes the
++    // PEM, PKCS#12, SSL and S/MIME libraries. This is a common query in
++    // the OpenSSL mailing lists."
++    //
++    // Anyway, as a result, we chose not to call this function if it would exit.
++
++    if (q_SSLeay() < 0x100010DFL)
++    {
++        // Now, before we try to call it, check if an attempt to open config file
++        // will result in exit:
++        if (char *confFileName = q_CONF_get1_default_config_file()) {
++            BIO *confFile = q_BIO_new_file(confFileName, "r");
++            const auto lastError = q_ERR_peek_last_error();
++            q_CRYPTO_free(confFileName);
++            if (confFile) {
++                q_BIO_free(confFile);
++            } else {
++                q_ERR_clear_error();
++                if (ERR_GET_REASON(lastError) == ERR_R_SYS_LIB) {
++                    qCWarning(lcSsl, "failed to open openssl.conf file");
++                    return;
++                }
++            }
++        }
++    }
++#endif // Q_OS_WIN
++
++    q_OpenSSL_add_all_algorithms();
++}
++
++
++/*!
++    \internal
++*/
++void QSslSocketPrivate::deinitialize()
++{
++    q_CRYPTO_set_id_callback(0);
++    q_CRYPTO_set_locking_callback(0);
++    q_ERR_free_strings();
++}
++
++
++bool QSslSocketPrivate::ensureLibraryLoaded()
++{
++    if (!q_resolveOpenSslSymbols())
++        return false;
++
++    // Check if the library itself needs to be initialized.
++    QMutexLocker locker(openssl_locks()->initLock());
++
++    if (!s_libraryLoaded) {
++        s_libraryLoaded = true;
++
++        // Initialize OpenSSL.
++        q_CRYPTO_set_id_callback(id_function);
++        q_CRYPTO_set_locking_callback(locking_function);
++        if (q_SSL_library_init() != 1)
++            return false;
++        q_SSL_load_error_strings();
++        q_OpenSSL_add_all_algorithms_safe();
++
++#if OPENSSL_VERSION_NUMBER >= 0x10001000L
++        if (q_SSLeay() >= 0x10001000L)
++            QSslSocketBackendPrivate::s_indexForSSLExtraData = q_SSL_get_ex_new_index(0L, NULL, NULL, NULL, NULL);
++#endif
++
++        // Initialize OpenSSL's random seed.
++        if (!q_RAND_status()) {
++            qWarning("Random number generator not seeded, disabling SSL support");
++            return false;
++        }
++    }
++    return true;
++}
++
++void QSslSocketPrivate::ensureCiphersAndCertsLoaded()
++{
++    QMutexLocker locker(openssl_locks()->initLock());
++    if (s_loadedCiphersAndCerts)
++        return;
++    s_loadedCiphersAndCerts = true;
++
++    resetDefaultCiphers();
++    resetDefaultEllipticCurves();
++
++#if QT_CONFIG(library)
++    //load symbols needed to receive certificates from system store
++#if defined(Q_OS_WIN)
++    HINSTANCE hLib = LoadLibraryW(L"Crypt32");
++    if (hLib) {
++        ptrCertOpenSystemStoreW = (PtrCertOpenSystemStoreW)GetProcAddress(hLib, "CertOpenSystemStoreW");
++        ptrCertFindCertificateInStore = (PtrCertFindCertificateInStore)GetProcAddress(hLib, "CertFindCertificateInStore");
++        ptrCertCloseStore = (PtrCertCloseStore)GetProcAddress(hLib, "CertCloseStore");
++        if (!ptrCertOpenSystemStoreW || !ptrCertFindCertificateInStore || !ptrCertCloseStore)
++            qCWarning(lcSsl, "could not resolve symbols in crypt32 library"); // should never happen
++    } else {
++        qCWarning(lcSsl, "could not load crypt32 library"); // should never happen
++    }
++#elif defined(Q_OS_QNX)
++    s_loadRootCertsOnDemand = true;
++#elif defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
++    // check whether we can enable on-demand root-cert loading (i.e. check whether the sym links are there)
++    QList<QByteArray> dirs = unixRootCertDirectories();
++    QStringList symLinkFilter;
++    symLinkFilter << QLatin1String("[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9]");
++    for (int a = 0; a < dirs.count(); ++a) {
++        QDirIterator iterator(QLatin1String(dirs.at(a)), symLinkFilter, QDir::Files);
++        if (iterator.hasNext()) {
++            s_loadRootCertsOnDemand = true;
++            break;
++        }
++    }
++#endif
++#endif // QT_CONFIG(library)
++    // if on-demand loading was not enabled, load the certs now
++    if (!s_loadRootCertsOnDemand)
++        setDefaultCaCertificates(systemCaCertificates());
++#ifdef Q_OS_WIN
++    //Enabled for fetching additional root certs from windows update on windows 6+
++    //This flag is set false by setDefaultCaCertificates() indicating the app uses
++    //its own cert bundle rather than the system one.
++    //Same logic that disables the unix on demand cert loading.
++    //Unlike unix, we do preload the certificates from the cert store.
++    if ((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_6_0)
++        s_loadRootCertsOnDemand = true;
++#endif
++}
++
++long QSslSocketPrivate::sslLibraryVersionNumber()
++{
++    if (!supportsSsl())
++        return 0;
++
++    return q_SSLeay();
++}
++
++QString QSslSocketPrivate::sslLibraryVersionString()
++{
++    if (!supportsSsl())
++        return QString();
++
++    const char *versionString = q_SSLeay_version(SSLEAY_VERSION);
++    if (!versionString)
++        return QString();
++
++    return QString::fromLatin1(versionString);
++}
++
++void QSslSocketBackendPrivate::continueHandshake()
++{
++    Q_Q(QSslSocket);
++    // if we have a max read buffer size, reset the plain socket's to match
++    if (readBufferMaxSize)
++        plainSocket->setReadBufferSize(readBufferMaxSize);
++
++    if (q_SSL_ctrl((ssl), SSL_CTRL_GET_SESSION_REUSED, 0, NULL))
++        configuration.peerSessionShared = true;
++
++#ifdef QT_DECRYPT_SSL_TRAFFIC
++    if (ssl->session && ssl->s3) {
++        const char *mk = reinterpret_cast<const char *>(ssl->session->master_key);
++        QByteArray masterKey(mk, ssl->session->master_key_length);
++        const char *random = reinterpret_cast<const char *>(ssl->s3->client_random);
++        QByteArray clientRandom(random, SSL3_RANDOM_SIZE);
++
++        // different format, needed for e.g. older Wireshark versions:
++//        const char *sid = reinterpret_cast<const char *>(ssl->session->session_id);
++//        QByteArray sessionID(sid, ssl->session->session_id_length);
++//        QByteArray debugLineRSA("RSA Session-ID:");
++//        debugLineRSA.append(sessionID.toHex().toUpper());
++//        debugLineRSA.append(" Master-Key:");
++//        debugLineRSA.append(masterKey.toHex().toUpper());
++//        debugLineRSA.append("\n");
++
++        QByteArray debugLineClientRandom("CLIENT_RANDOM ");
++        debugLineClientRandom.append(clientRandom.toHex().toUpper());
++        debugLineClientRandom.append(" ");
++        debugLineClientRandom.append(masterKey.toHex().toUpper());
++        debugLineClientRandom.append("\n");
++
++        QString sslKeyFile = QDir::tempPath() + QLatin1String("/qt-ssl-keys");
++        QFile file(sslKeyFile);
++        if (!file.open(QIODevice::Append))
++            qCWarning(lcSsl) << "could not open file" << sslKeyFile << "for appending";
++        if (!file.write(debugLineClientRandom))
++            qCWarning(lcSsl) << "could not write to file" << sslKeyFile;
++        file.close();
++    } else {
++        qCWarning(lcSsl, "could not decrypt SSL traffic");
++    }
++#endif
++
++    // Cache this SSL session inside the QSslContext
++    if (!(configuration.sslOptions & QSsl::SslOptionDisableSessionSharing)) {
++        if (!sslContextPointer->cacheSession(ssl)) {
++            sslContextPointer.clear(); // we could not cache the session
++        } else {
++            // Cache the session for permanent usage as well
++            if (!(configuration.sslOptions & QSsl::SslOptionDisableSessionPersistence)) {
++                if (!sslContextPointer->sessionASN1().isEmpty())
++                    configuration.sslSession = sslContextPointer->sessionASN1();
++                configuration.sslSessionTicketLifeTimeHint = sslContextPointer->sessionTicketLifeTimeHint();
++            }
++        }
++    }
++
++#if OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_NEXTPROTONEG)
++
++    configuration.nextProtocolNegotiationStatus = sslContextPointer->npnContext().status;
++    if (sslContextPointer->npnContext().status == QSslConfiguration::NextProtocolNegotiationUnsupported) {
++        // we could not agree -> be conservative and use HTTP/1.1
++        configuration.nextNegotiatedProtocol = QByteArrayLiteral("http/1.1");
++    } else {
++        const unsigned char *proto = 0;
++        unsigned int proto_len = 0;
++#if OPENSSL_VERSION_NUMBER >= 0x10002000L
++        if (q_SSLeay() >= 0x10002000L) {
++            q_SSL_get0_alpn_selected(ssl, &proto, &proto_len);
++            if (proto_len && mode == QSslSocket::SslClientMode) {
++                // Client does not have a callback that sets it ...
++                configuration.nextProtocolNegotiationStatus = QSslConfiguration::NextProtocolNegotiationNegotiated;
++            }
++        }
++
++        if (!proto_len) { // Test if NPN was more lucky ...
++#else
++        {
++#endif
++            q_SSL_get0_next_proto_negotiated(ssl, &proto, &proto_len);
++        }
++
++        if (proto_len)
++            configuration.nextNegotiatedProtocol = QByteArray(reinterpret_cast<const char *>(proto), proto_len);
++        else
++            configuration.nextNegotiatedProtocol.clear();
++    }
++#endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ...
++
++#if OPENSSL_VERSION_NUMBER >= 0x10002000L
++    if (q_SSLeay() >= 0x10002000L && mode == QSslSocket::SslClientMode) {
++        EVP_PKEY *key;
++        if (q_SSL_get_server_tmp_key(ssl, &key))
++            configuration.ephemeralServerKey = QSslKey(key, QSsl::PublicKey);
++    }
++#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L ...
++
++    connectionEncrypted = true;
++    emit q->encrypted();
++    if (autoStartHandshake && pendingClose) {
++        pendingClose = false;
++        q->disconnectFromHost();
++    }
++}
++
++QT_END_NAMESPACE
+diff --git a/src/network/ssl/ssl.pri b/src/network/ssl/ssl.pri
+index d2b0c2d60d..2783effaf1 100644
+--- a/src/network/ssl/ssl.pri
++++ b/src/network/ssl/ssl.pri
+@@ -60,13 +60,25 @@ qtConfig(ssl) {
+         HEADERS += ssl/qsslcontext_openssl_p.h \
+                    ssl/qsslsocket_openssl_p.h \
+                    ssl/qsslsocket_openssl_symbols_p.h
+-        SOURCES += ssl/qsslcertificate_openssl.cpp \
+-                   ssl/qsslcontext_openssl.cpp \
++        SOURCES += ssl/qsslsocket_openssl_symbols.cpp \
+                    ssl/qssldiffiehellmanparameters_openssl.cpp \
++                   ssl/qsslcertificate_openssl.cpp \
+                    ssl/qsslellipticcurve_openssl.cpp \
+                    ssl/qsslkey_openssl.cpp \
+                    ssl/qsslsocket_openssl.cpp \
+-                   ssl/qsslsocket_openssl_symbols.cpp
++                   ssl/qsslcontext_openssl.cpp
++
++        qtConfig(opensslv11) {
++            HEADERS += ssl/qsslsocket_openssl11_symbols_p.h
++            SOURCES += ssl/qsslsocket_openssl11.cpp \
++                       ssl/qsslcontext_openssl11.cpp
++
++            QMAKE_CXXFLAGS += -DOPENSSL_API_COMPAT=0x10100000L
++        } else {
++            HEADERS += ssl/qsslsocket_opensslpre11_symbols_p.h
++            SOURCES += ssl/qsslsocket_opensslpre11.cpp \
++                       ssl/qsslcontext_opensslpre11.cpp
++        }
+ 
+         darwin:SOURCES += ssl/qsslsocket_mac_shared.cpp
+ 
diff --git a/pkgs/development/libraries/qt-5/5.9/qtbase.patch b/pkgs/development/libraries/qt-5/5.9/qtbase.patch
index 086ddf4fe3e..f87c508a380 100644
--- a/pkgs/development/libraries/qt-5/5.9/qtbase.patch
+++ b/pkgs/development/libraries/qt-5/5.9/qtbase.patch
@@ -994,28 +994,6 @@ index 9a24938284..74962b4ae2 100644
          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
diff --git a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh
index 3a558153988..436c2e1d032 100644
--- a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh
+++ b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh
@@ -19,12 +19,14 @@ export QMAKEPATH
 QMAKEMODULES=
 export QMAKEMODULES
 
-addToQMAKEPATH() {
-    if [ -d "$1/mkspecs" ]; then
+qmakePathHook() {
+    if [ -d "$1/mkspecs" ]
+    then
         QMAKEMODULES="${QMAKEMODULES}${QMAKEMODULES:+:}/mkspecs"
         QMAKEPATH="${QMAKEPATH}${QMAKEPATH:+:}$1"
     fi
 }
+envBuildHostHooks+=(qmakePathHook)
 
 # Propagate any runtime dependency of the building package.
 # Each dependency is propagated to the user environment and as a build
@@ -32,18 +34,18 @@ addToQMAKEPATH() {
 # 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"
+qtEnvHostTargetHook() {
+    if providesQtRuntime "$1" && [ "z${!outputBin}" != "z${!outputDev}" ]
+    then
+        propagatedBuildInputs+=" $1"
     fi
 }
-envHostTargetHooks+=(qtEnvHook)
+envHostTargetHooks+=(qtEnvHostTargetHook)
 
 postPatchMkspecs() {
+    # Prevent this hook from running multiple times
+    dontPatchMkspecs=1
+
     local bin="${!outputBin}"
     local dev="${!outputDev}"
     local doc="${!outputDoc}"
diff --git a/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh b/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh
new file mode 100644
index 00000000000..e7d7d132617
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh
@@ -0,0 +1,102 @@
+# Inherit arguments given in mkDerivation
+qtWrapperArgs=( $qtWrapperArgs )
+
+qtHostPathSeen=()
+
+qtUnseenHostPath() {
+    for pkg in "${qtHostPathSeen[@]}"
+    do
+        if [ "${pkg:?}" == "$1" ]
+        then
+            return 1
+        fi
+    done
+
+    qtHostPathSeen+=("$1")
+    return 0
+}
+
+qtHostPathHook() {
+    qtUnseenHostPath "$1" || return 0
+
+    local pluginDir="$1/${qtPluginPrefix:?}"
+    if [ -d "$pluginDir" ]
+    then
+        qtWrapperArgs+=(--prefix QT_PLUGIN_PATH : "$pluginDir")
+    fi
+
+    local qmlDir="$1/${qtQmlPrefix:?}"
+    if [ -d "$qmlDir" ]
+    then
+        qtWrapperArgs+=(--prefix QML2_IMPORT_PATH : "$qmlDir")
+    fi
+}
+addEnvHooks "$hostOffset" qtHostPathHook
+
+makeQtWrapper() {
+    local original="$1"
+    local wrapper="$2"
+    shift 2
+    makeWrapper "$original" "$wrapper" "${qtWrapperArgs[@]}" "$@"
+}
+
+wrapQtApp() {
+    local program="$1"
+    shift 1
+    wrapProgram "$program" "${qtWrapperArgs[@]}" "$@"
+}
+
+qtOwnPathsHook() {
+    local xdgDataDir="${!outputBin}/share"
+    if [ -d "$xdgDataDir" ]
+    then
+        qtWrapperArgs+=(--prefix XDG_DATA_DIRS : "$xdgDataDir")
+    fi
+
+    local xdgConfigDir="${!outputBin}/etc/xdg"
+    if [ -d "$xdgConfigDir" ]
+    then
+        qtWrapperArgs+=(--prefix XDG_CONFIG_DIRS : "$xdgConfigDir")
+    fi
+
+    qtHostPathHook "${!outputBin}"
+}
+
+preFixupPhases+=" qtOwnPathsHook"
+
+# Note: $qtWrapperArgs still gets defined even if $dontWrapQtApps is set.
+wrapQtAppsHook() {
+    # skip this hook when requested
+    [ -z "$dontWrapQtApps" ] || return 0
+
+    # guard against running multiple times (e.g. due to propagation)
+    [ -z "$wrapQtAppsHookHasRun" ] || return 0
+    wrapQtAppsHookHasRun=1
+
+    local targetDirs=( "$prefix/bin" "$prefix/libexec"  )
+    echo "wrapping Qt applications in ${targetDirs[@]}"
+
+    for targetDir in "${targetDirs[@]}"
+    do
+        [ -d "$targetDir" ] || continue
+
+        find "$targetDir" -executable -print0 | while IFS= read -r -d '' file
+        do
+            isELF "$file" || continue
+
+            if [ -f "$file" ]
+            then
+                echo "wrapping $file"
+                wrapQtApp "$file"
+            elif [ -h "$file" ]
+            then
+                target="$(readlink -e "$file")"
+                echo "wrapping $file -> $target"
+                rm "$file"
+                makeQtWrapper "$target" "$file"
+            fi
+        done
+    done
+}
+
+fixupOutputHooks+=(wrapQtAppsHook)
diff --git a/pkgs/development/libraries/qt-5/mkDerivation.nix b/pkgs/development/libraries/qt-5/mkDerivation.nix
index d4e2143d564..95357c096df 100644
--- a/pkgs/development/libraries/qt-5/mkDerivation.nix
+++ b/pkgs/development/libraries/qt-5/mkDerivation.nix
@@ -1,8 +1,8 @@
-{ stdenv, lib }:
+{ lib, debug, wrapQtAppsHook }:
 
 let inherit (lib) optional; in
 
-{ debug }:
+mkDerivation:
 
 args:
 
@@ -24,7 +24,9 @@ let
 
     enableParallelBuilding = args.enableParallelBuilding or true;
 
+    nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ wrapQtAppsHook ];
+
   };
 in
 
-stdenv.mkDerivation (args // args_)
+mkDerivation (args // args_)
diff --git a/pkgs/development/libraries/qt-5/modules/qtbase.nix b/pkgs/development/libraries/qt-5/modules/qtbase.nix
index bd92d9bc27c..2c300d1c2f1 100644
--- a/pkgs/development/libraries/qt-5/modules/qtbase.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtbase.nix
@@ -56,7 +56,7 @@ stdenv.mkDerivation {
           # TODO: move to buildInputs, this should not be propagated.
           AGL AppKit ApplicationServices Carbon Cocoa CoreAudio CoreBluetooth
           CoreLocation CoreServices DiskArbitration Foundation OpenGL
-          darwin.libobjc libiconv
+          darwin.libobjc libiconv MetalKit
         ]
       else
         [
@@ -78,8 +78,6 @@ stdenv.mkDerivation {
       [ libinput ]
       ++ lib.optional withGtk3 gtk3
     )
-       # Needed for OBJC_CLASS_$_NSDate symbols.
-    ++ lib.optional stdenv.isDarwin darwin.cf-private
     ++ lib.optional developerBuild gdb
     ++ lib.optional (cups != null) cups
     ++ lib.optional (mysql != null) mysql.connector-c
@@ -148,6 +146,11 @@ stdenv.mkDerivation {
             sed -i mkspecs/common/linux.conf \
                 -e "/^QMAKE_INCDIR_OPENGL/ s|$|${libGL.dev or libGL}/include|" \
                 -e "/^QMAKE_LIBDIR_OPENGL/ s|$|${libGL.out}/lib|"
+          '' +
+        lib.optionalString (stdenv.hostPlatform.isx86_32 && stdenv.cc.isGNU)
+          ''
+            sed -i mkspecs/common/gcc-base-unix.conf \
+                -e "/^QMAKE_LFLAGS_SHLIB/ s/-shared/-shared -static-libgcc/"
           ''
     );
 
diff --git a/pkgs/development/libraries/qt-5/modules/qtconnectivity.nix b/pkgs/development/libraries/qt-5/modules/qtconnectivity.nix
index 17e7f0ee7cf..36a736d03dc 100644
--- a/pkgs/development/libraries/qt-5/modules/qtconnectivity.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtconnectivity.nix
@@ -1,8 +1,8 @@
-{ qtModule, stdenv, qtbase, qtdeclarative, bluez, cf-private }:
+{ qtModule, stdenv, qtbase, qtdeclarative, bluez }:
 
 qtModule {
   name = "qtconnectivity";
   qtInputs = [ qtbase qtdeclarative ];
-  buildInputs = if stdenv.isDarwin then [ cf-private ] else [ bluez ];
+  buildInputs = stdenv.lib.optional stdenv.isLinux bluez;
   outputs = [ "out" "dev" "bin" ];
 }
diff --git a/pkgs/development/libraries/qt-5/modules/qtmacextras.nix b/pkgs/development/libraries/qt-5/modules/qtmacextras.nix
index 3f254885986..11964caf17b 100644
--- a/pkgs/development/libraries/qt-5/modules/qtmacextras.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtmacextras.nix
@@ -1,10 +1,8 @@
-{ stdenv, qtModule, qtbase, cf-private }:
+{ stdenv, qtModule, qtbase }:
 
 qtModule {
   name = "qtmacextras";
-  qtInputs = [ qtbase ]
-    # Needed for _OBJC_CLASS_$_NSData symbols.
-    ++ stdenv.lib.optional stdenv.isDarwin cf-private;
+  qtInputs = [ qtbase ];
   meta = with stdenv.lib; {
     maintainers = with maintainers; [ periklis ];
     platforms = platforms.darwin;
diff --git a/pkgs/development/libraries/qt-5/modules/qtspeech.nix b/pkgs/development/libraries/qt-5/modules/qtspeech.nix
index 7b4b19ccab5..ddef01a9482 100644
--- a/pkgs/development/libraries/qt-5/modules/qtspeech.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtspeech.nix
@@ -3,5 +3,5 @@
 qtModule {
   name = "qtspeech";
   qtInputs = [ ];
-  outputs = [ "out" "dev" "bin" ];
+  outputs = [ "out" "dev" ];
 }
diff --git a/pkgs/development/libraries/qt-5/modules/qttools.nix b/pkgs/development/libraries/qt-5/modules/qttools.nix
index 622d841b405..573472a8b5a 100644
--- a/pkgs/development/libraries/qt-5/modules/qttools.nix
+++ b/pkgs/development/libraries/qt-5/modules/qttools.nix
@@ -1,4 +1,4 @@
-{ qtModule, stdenv, lib, qtbase }:
+{ qtModule, stdenv, lib, qtbase, qtdeclarative }:
 
 with lib;
 
@@ -32,5 +32,8 @@ qtModule {
     "bin/macdeployqt"
   ];
 
+  NIX_CFLAGS_COMPILE =
+    lib.optional stdenv.isDarwin ''-DNIXPKGS_QMLIMPORTSCANNER="${qtdeclarative.dev}/bin/qmlimportscanner"'';
+
   setupHook = ../hooks/qttools-setup-hook.sh;
 }
diff --git a/pkgs/development/libraries/qt-5/modules/qtwebengine.nix b/pkgs/development/libraries/qt-5/modules/qtwebengine.nix
index aa9cdb4d5ae..357c81fa4f6 100644
--- a/pkgs/development/libraries/qt-5/modules/qtwebengine.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtwebengine.nix
@@ -20,8 +20,6 @@
 
 with stdenv.lib;
 
-let qt56 = qtCompatVersion == "5.6"; in
-
 qtModule {
   name = "qtwebengine";
   qtInputs = [ qtdeclarative qtquickcontrols qtlocation qtwebchannel ];
@@ -48,9 +46,9 @@ qtModule {
     # Patch Chromium build files
     + optionalString (lib.versionOlder qtCompatVersion "5.12") ''
       substituteInPlace ./src/3rdparty/chromium/build/common.gypi --replace /bin/echo ${coreutils}/bin/echo
-      substituteInPlace ./src/3rdparty/chromium/v8/${if qt56 then "build" else "gypfiles"}/toolchain.gypi \
+      substituteInPlace ./src/3rdparty/chromium/v8/gypfiles/toolchain.gypi \
         --replace /bin/echo ${coreutils}/bin/echo
-      substituteInPlace ./src/3rdparty/chromium/v8/${if qt56 then "build" else "gypfiles"}/standalone.gypi \
+      substituteInPlace ./src/3rdparty/chromium/v8/gypfiles/standalone.gypi \
         --replace /bin/echo ${coreutils}/bin/echo
     ''
     # Patch library paths in Qt sources
@@ -200,14 +198,6 @@ EOF
     (runCommand "MacOS_SDK_sandbox.h" {} ''
       install -Dm444 "${lib.getDev darwin.apple_sdk.sdk}"/include/sandbox.h "$out"/include/sandbox.h
     '')
-
-    # For:
-    # _NSDefaultRunLoopMode
-    # _OBJC_CLASS_$_NSDate
-    # _OBJC_CLASS_$_NSDictionary
-    # _OBJC_CLASS_$_NSRunLoop
-    # _OBJC_CLASS_$_NSURL
-    darwin.cf-private
   ]);
 
   __impureHostDeps = optional stdenv.isDarwin "/usr/lib/libsandbox.1.dylib";
@@ -227,7 +217,6 @@ EOF
     description = "A web engine based on the Chromium web browser";
     maintainers = with maintainers; [ matthewbauer ];
     platforms = platforms.unix;
-    broken = qt56; # 2018-09-13, no successful build since 2018-04-25
   };
 
 }
diff --git a/pkgs/development/libraries/qt-5/modules/qtwebkit.nix b/pkgs/development/libraries/qt-5/modules/qtwebkit.nix
index 2a474ab0ffe..d65449023b3 100644
--- a/pkgs/development/libraries/qt-5/modules/qtwebkit.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtwebkit.nix
@@ -1,6 +1,6 @@
 { qtModule, stdenv, lib, fetchurl
 , qtbase, qtdeclarative, qtlocation, qtmultimedia, qtsensors, qtwebchannel
-, fontconfig, gdk_pixbuf, gtk2, libwebp, libxml2, libxslt
+, fontconfig, gtk2, libwebp, libxml2, libxslt
 , sqlite, systemd, glib, gst_all_1, cmake
 , bison2, flex, gdb, gperf, perl, pkgconfig, python2, ruby
 , darwin
@@ -28,7 +28,7 @@ qtModule {
     ++ optional (stdenv.isDarwin && lib.versionAtLeast qtbase.version "5.9.0") qtmultimedia
     ++ optional usingAnnulenWebkitFork qtwebchannel;
   buildInputs = [ fontconfig libwebp libxml2 libxslt sqlite glib gst_all_1.gstreamer gst_all_1.gst-plugins-base ]
-    ++ optionals (stdenv.isDarwin) (with darwin; with apple_sdk.frameworks; [ cf-private ICU OpenGL ])
+    ++ optionals (stdenv.isDarwin) (with darwin; with apple_sdk.frameworks; [ ICU OpenGL ])
     ++ optional usingAnnulenWebkitFork hyphen;
   nativeBuildInputs = [
     bison2 flex gdb gperf perl pkgconfig python2 ruby
diff --git a/pkgs/development/libraries/qt-5/modules/qtwebview.nix b/pkgs/development/libraries/qt-5/modules/qtwebview.nix
index 6d5274cbc58..906d750c5d3 100644
--- a/pkgs/development/libraries/qt-5/modules/qtwebview.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtwebview.nix
@@ -1,20 +1,14 @@
 { darwin, stdenv, qtModule, qtdeclarative, qtwebengine }:
 
 with stdenv.lib;
- 
+
 qtModule {
   name = "qtwebview";
   qtInputs = [ qtdeclarative qtwebengine ];
   buildInputs = optional (stdenv.isDarwin) [
     darwin.apple_sdk.frameworks.CoreFoundation
     darwin.apple_sdk.frameworks.WebKit
-
-    # For:
-    # _OBJC_CLASS_$_NSArray
-    # _OBJC_CLASS_$_NSDate
-    # _OBJC_CLASS_$_NSURL
-    darwin.cf-private
   ];
   outputs = [ "out" "dev" "bin" ];
   NIX_LDFLAGS = optionalString stdenv.isDarwin "-framework CoreFoundation -framework WebKit";
-}
\ No newline at end of file
+}
diff --git a/pkgs/development/libraries/qtpbfimageplugin/default.nix b/pkgs/development/libraries/qtpbfimageplugin/default.nix
new file mode 100644
index 00000000000..8ad908013bd
--- /dev/null
+++ b/pkgs/development/libraries/qtpbfimageplugin/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, fetchFromGitHub, qmake, qtbase, protobuf }:
+
+stdenv.mkDerivation rec {
+  pname = "qtpbfimageplugin";
+  version = "1.4";
+
+  src = fetchFromGitHub {
+    owner = "tumic0";
+    repo = "QtPBFImagePlugin";
+    rev = version;
+    sha256 = "0d39i7rmhrmm2df49gd47zm37gnz3fmyr6hfc6hhzvk08jb6956r";
+  };
+
+  nativeBuildInputs = [ qmake ];
+  buildInputs = [ qtbase protobuf ];
+
+  postPatch = ''
+    # Fix plugin dir
+    substituteInPlace pbfplugin.pro \
+      --replace "\$\$[QT_INSTALL_PLUGINS]" "$out/$qtPluginPrefix"
+
+    # Fix darwin build
+    substituteInPlace pbfplugin.pro \
+      --replace '$$PROTOBUF/lib/libprotobuf-lite.a' '${protobuf}/lib/libprotobuf-lite.dylib'
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Qt image plugin for displaying Mapbox vector tiles";
+    longDescription = ''
+      QtPBFImagePlugin is a Qt image plugin that enables applications capable of
+      displaying raster MBTiles maps or raster XYZ online maps to also display PBF
+      vector tiles without (almost) any application modifications.
+    '';
+    homepage = https://github.com/tumic0/QtPBFImagePlugin;
+    license = licenses.lgpl3;
+    maintainers = [ maintainers.sikmir ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/qtstyleplugins/default.nix b/pkgs/development/libraries/qtstyleplugins/default.nix
index b94cdd22f7f..dd50e6ec039 100644
--- a/pkgs/development/libraries/qtstyleplugins/default.nix
+++ b/pkgs/development/libraries/qtstyleplugins/default.nix
@@ -1,6 +1,6 @@
-{ stdenv, fetchFromGitHub, qmake, pkgconfig, gtk2 }:
+{ stdenv, mkDerivation, fetchFromGitHub, qmake, pkgconfig, gtk2 }:
 
-stdenv.mkDerivation rec {
+mkDerivation rec {
   name = "qtstyleplugins-2017-03-11";
 
   src = fetchFromGitHub {
diff --git a/pkgs/development/libraries/qtutilities/default.nix b/pkgs/development/libraries/qtutilities/default.nix
new file mode 100644
index 00000000000..63b0a9f42a6
--- /dev/null
+++ b/pkgs/development/libraries/qtutilities/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchFromGitHub, cpp-utilities, qttools, qtbase, cmake, pkgconfig }:
+
+stdenv.mkDerivation rec {
+  pname = "qtutilities";
+  version = "5.13.0";
+
+  src = fetchFromGitHub {
+    owner = "Martchus";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "03drxwpr3xdh4hm8pkd5mhjs0mzhz6634ldyq78pml39ciqm51nl";
+  };
+
+  buildInputs = [ qtbase cpp-utilities ];
+  nativeBuildInputs = [ cmake qttools ];
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/Martchus/qtutilities";
+    description = "Common C++ classes and routines used by @Martchus' applications featuring argument parser, IO and conversion utilities";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ doronbehar ];
+    platforms   = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/rdkafka/default.nix b/pkgs/development/libraries/rdkafka/default.nix
index 840891d55ef..9f4fe54e805 100644
--- a/pkgs/development/libraries/rdkafka/default.nix
+++ b/pkgs/development/libraries/rdkafka/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "rdkafka-${version}";
-  version = "1.0.0";
+  version = "1.0.1";
 
   src = fetchFromGitHub {
     owner = "edenhill";
     repo = "librdkafka";
     rev = "v${version}";
-    sha256 = "1k4lk2vvvni87brs3j51by3j69ff2892jiq2f4979sxncq0apzlg";
+    sha256 = "1jxwsizqwckjzirh9gsvlca46z4y3i47vcifs1fh8gxb2lvdfgwb";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/readline/readline-8.0-patches.nix b/pkgs/development/libraries/readline/readline-8.0-patches.nix
index b8019fb3350..433da83dab9 100644
--- a/pkgs/development/libraries/readline/readline-8.0-patches.nix
+++ b/pkgs/development/libraries/readline/readline-8.0-patches.nix
@@ -1,4 +1,5 @@
 # Automatically generated by `update-patch-set.sh'; do not edit.
 
 patch: [
+(patch "001" "0sfh7wn0pr743xspnb1zndxndlv9rc0hcg14cbw5cmyg6f4ykrfq")
 ]
diff --git a/pkgs/development/libraries/rocksdb/0001-findzlib.patch b/pkgs/development/libraries/rocksdb/0001-findzlib.patch
new file mode 100644
index 00000000000..eb532620773
--- /dev/null
+++ b/pkgs/development/libraries/rocksdb/0001-findzlib.patch
@@ -0,0 +1,13 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 132d3b0..37fec63 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -92,7 +92,7 @@ else()
+   endif()
+ 
+   if(WITH_ZLIB)
+-    find_package(zlib REQUIRED)
++	  find_package(ZLIB REQUIRED)
+     add_definitions(-DZLIB)
+     if(ZLIB_INCLUDE_DIRS)
+       # CMake 3
diff --git a/pkgs/development/libraries/rocksdb/default.nix b/pkgs/development/libraries/rocksdb/default.nix
index 4e51051dfe0..05ecf0f8f25 100644
--- a/pkgs/development/libraries/rocksdb/default.nix
+++ b/pkgs/development/libraries/rocksdb/default.nix
@@ -1,86 +1,44 @@
-{ stdenv
-, fetchFromGitHub
-, fixDarwinDylibNames
-, which, perl
+{ stdenv, fetchFromGitHub, lib, bzip2, cmake, lz4, snappy, zlib, zstd, enableLite ? false }:
 
-# Optional Arguments
-, snappy ? null, google-gflags ? null, zlib ? null, bzip2 ? null, lz4 ? null
-
-# Malloc implementation
-, jemalloc ? null, gperftools ? null
-
-, enableLite ? false
-}:
-
-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.11.3";
-
-  outputs = [ "dev" "out" "static" "bin" ];
+  pname = "rocksdb";
+  version = "6.1.2";
 
   src = fetchFromGitHub {
     owner = "facebook";
-    repo = "rocksdb";
+    repo = pname;
     rev = "v${version}";
-    sha256 = "15x2r7aib1xinwcchl32wghs8g96k4q5xgv6z97mxgp35475x01p";
+    sha256 = "0gy2zjga3r8k9pbn2b0b5fzv4m0h2ip3zmyja1i7fli9n56civ3y";
   };
 
-  nativeBuildInputs = [ which perl ];
-  buildInputs = [ snappy google-gflags zlib bzip2 lz4 malloc fixDarwinDylibNames ];
-
-  postPatch = ''
-    # Hack to fix typos
-    sed -i 's,#inlcude,#include,g' build_tools/build_detect_platform
-  '';
-
-  # Environment vars used for building certain configurations
-  PORTABLE = "1";
-  USE_SSE = "1";
-  CMAKE_CXX_FLAGS = "-std=gnu++11";
-  JEMALLOC_LIB = stdenv.lib.optionalString (malloc == jemalloc) "-ljemalloc";
-
-  LIBNAME = "librocksdb${stdenv.lib.optionalString enableLite "_lite"}";
-  ${if enableLite then "CXXFLAGS" else null} = "-DROCKSDB_LITE=1";
-
-  buildAndInstallFlags = [
-    "USE_RTTI=1"
-    "DEBUG_LEVEL=0"
-    "DISABLE_WARNING_AS_ERROR=1"
-  ];
-
-  buildFlags = buildAndInstallFlags ++ [
-    "shared_lib"
-    "static_lib"
-  ] ++ tools ;
-
-  installFlags = buildAndInstallFlags ++ [
-    "INSTALL_PATH=\${out}"
-    "install-shared"
-    "install-static"
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ bzip2 lz4 snappy zlib zstd ];
+
+  patches = [ ./0001-findzlib.patch ];
+
+  cmakeFlags = [
+    "-DPORTABLE=1"
+    "-DWITH_JEMALLOC=0"
+    "-DWITH_JNI=0"
+    "-DWITH_TESTS=0"
+    "-DWITH_TOOLS=0"
+    "-DWITH_BZ2=1"
+    "-DWITH_LZ4=1"
+    "-DWITH_SNAPPY=1"
+    "-DWITH_ZLIB=1"
+    "-DWITH_ZSTD=1"
+    "-DWITH_GFLAGS=0"
+    (lib.optional
+        (stdenv.hostPlatform.system == "i686-linux"
+         || stdenv.hostPlatform.system == "x86_64-linux")
+        "-DFORCE_SSE42=1")
+    (lib.optional enableLite "-DROCKSDB_LITE=1")
   ];
 
-  postInstall = ''
-    # 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;
-
   meta = with stdenv.lib; {
     homepage = https://rocksdb.org;
     description = "A library that provides an embeddable, persistent key-value store for fast storage";
-    license = licenses.bsd3;
-    platforms = platforms.x86_64;
-    maintainers = with maintainers; [ adev ];
+    license = licenses.asl20;
+    maintainers = with maintainers; [ adev magenbluten ];
   };
 }
diff --git a/pkgs/development/libraries/science/biology/mirtk/default.nix b/pkgs/development/libraries/science/biology/mirtk/default.nix
index 51beba898f6..22bcc56c82a 100644
--- a/pkgs/development/libraries/science/biology/mirtk/default.nix
+++ b/pkgs/development/libraries/science/biology/mirtk/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, gtest, fetchFromGitHub, cmake, boost, eigen, python, vtk, zlib }:
+{ stdenv, gtest, fetchFromGitHub, cmake, boost, eigen, python, vtk, zlib }:
 
 stdenv.mkDerivation rec {
   version = "2.0.0";
diff --git a/pkgs/development/libraries/science/math/brial/default.nix b/pkgs/development/libraries/science/math/brial/default.nix
index 38b77781867..16850fb1665 100644
--- a/pkgs/development/libraries/science/math/brial/default.nix
+++ b/pkgs/development/libraries/science/math/brial/default.nix
@@ -8,14 +8,14 @@
 }:
 
 stdenv.mkDerivation rec {
-  version = "1.2.4";
+  version = "1.2.5";
   name = "brial-${version}";
 
   src = fetchFromGitHub {
     owner = "BRiAl";
     repo = "BRiAl";
     rev = version;
-    sha256 = "08skgmwz190mvpkh0ddx92ilva6bxidxwh1qg16ipi768x92193s";
+    sha256 = "1nv56fp3brpzanxj7vwvxqdafqfsfhdgq5imr3m94psw5gdfqwja";
   };
 
   # FIXME package boost-test and enable checks
diff --git a/pkgs/development/libraries/science/math/caffe2/default.nix b/pkgs/development/libraries/science/math/caffe2/default.nix
index d568e945202..4746f77a216 100644
--- a/pkgs/development/libraries/science/math/caffe2/default.nix
+++ b/pkgs/development/libraries/science/math/caffe2/default.nix
@@ -1,6 +1,6 @@
 { stdenv, lib, config, fetchFromGitHub
 , cmake
-, glog, google-gflags, gtest
+, glog, gflags, gtest
 , protobuf, snappy
 , python, future, six, python-protobuf, numpy, pydot
 , eigen
@@ -74,7 +74,7 @@ stdenv.mkDerivation rec {
   outputs = [ "bin" "out" ];
   propagatedBuildOutputs = [ ]; # otherwise propagates out -> bin cycle
 
-  buildInputs = [ glog google-gflags protobuf snappy eigen ]
+  buildInputs = [ glog gflags protobuf snappy eigen ]
     ++ lib.optional useCuda cudatoolkit
     ++ lib.optional useCudnn cudnn
     ++ lib.optional useOpenmp openmp
diff --git a/pkgs/development/libraries/science/math/fenics/default.nix b/pkgs/development/libraries/science/math/fenics/default.nix
index 8134cc63eb0..4ae5ea52255 100644
--- a/pkgs/development/libraries/science/math/fenics/default.nix
+++ b/pkgs/development/libraries/science/math/fenics/default.nix
@@ -83,7 +83,7 @@ let
     '';
     meta = {
       description = "A domain-specific language for finite element variational forms";
-      homepage = http://fenicsproject.org/;
+      homepage = https://fenicsproject.org/;
       platforms = stdenv.lib.platforms.all;
       license = stdenv.lib.licenses.lgpl3;
     };
@@ -102,7 +102,7 @@ let
     '';
     meta = {
       description = "A compiler for finite element variational forms";
-      homepage = http://fenicsproject.org/;
+      homepage = https://fenicsproject.org/;
       platforms = stdenv.lib.platforms.all;
       license = stdenv.lib.licenses.lgpl3;
     };
@@ -117,7 +117,7 @@ let
     buildInputs = [ numpy six ];
     meta = {
       description = "Instant inlining of C and C++ code in Python";
-      homepage = http://fenicsproject.org/;
+      homepage = https://fenicsproject.org/;
       platforms = stdenv.lib.platforms.all;
       license = stdenv.lib.licenses.lgpl3;
     };
@@ -162,7 +162,7 @@ stdenv.mkDerivation {
   postInstall = "source $out/share/dolfin/dolfin.conf";
   meta = {
     description = "The FEniCS Problem Solving Environment in Python and C++";
-    homepage = http://fenicsproject.org/;
+    homepage = https://fenicsproject.org/;
     platforms = stdenv.lib.platforms.darwin;
     license = stdenv.lib.licenses.lgpl3;
   };
diff --git a/pkgs/development/libraries/science/math/liblapack/default.nix b/pkgs/development/libraries/science/math/liblapack/default.nix
index c26e9c575ab..46538d0022e 100644
--- a/pkgs/development/libraries/science/math/liblapack/default.nix
+++ b/pkgs/development/libraries/science/math/liblapack/default.nix
@@ -7,8 +7,7 @@
   shared ? false
 }:
 let
-  usedLibExtension = if shared then ".so" else ".a";
-  inherit (stdenv.lib) optional optionals;
+  inherit (stdenv.lib) optional;
   version = "3.8.0";
 in
 
diff --git a/pkgs/development/libraries/science/math/mkl/default.nix b/pkgs/development/libraries/science/math/mkl/default.nix
index 350cfb1f7a2..2dcac58bf6c 100644
--- a/pkgs/development/libraries/science/math/mkl/default.nix
+++ b/pkgs/development/libraries/science/math/mkl/default.nix
@@ -1,4 +1,4 @@
-{ stdenvNoCC, writeText, fetchurl, rpmextract, undmg, darwin }:
+{ stdenvNoCC, fetchurl, rpmextract, undmg, darwin }:
 /*
   For details on using mkl as a blas provider for python packages such as numpy,
   numexpr, scipy, etc., see the Python section of the NixPkgs manual.
diff --git a/pkgs/development/libraries/science/math/nccl/default.nix b/pkgs/development/libraries/science/math/nccl/default.nix
index a099b779a78..c9aeb83c469 100644
--- a/pkgs/development/libraries/science/math/nccl/default.nix
+++ b/pkgs/development/libraries/science/math/nccl/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "nccl-${version}-cuda-${cudatoolkit.majorVersion}";
-  version = "2.4.2-1";
+  version = "2.4.8-1";
 
   src = fetchFromGitHub {
     owner = "NVIDIA";
     repo = "nccl";
     rev = "v${version}";
-    sha256 = "0aa4gv51nbmmdhx6vp40l249m4arp30sijrn6kwxdfi1k9kajiq5";
+    sha256 = "05m66y64rgsdyybvjybhy6clikwv438b1m484ikai78fb2b7mvyq";
   };
 
   outputs = [ "out" "dev" ];
diff --git a/pkgs/development/libraries/science/math/openblas/default.nix b/pkgs/development/libraries/science/math/openblas/default.nix
index 8ec00f7e2b8..d967bbf8c3e 100644
--- a/pkgs/development/libraries/science/math/openblas/default.nix
+++ b/pkgs/development/libraries/science/math/openblas/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, fetchpatch, gfortran, perl, which, config
+{ stdenv, fetchFromGitHub, perl, which
 # 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).
diff --git a/pkgs/development/libraries/science/math/or-tools/default.nix b/pkgs/development/libraries/science/math/or-tools/default.nix
index ba6827bf694..2dd63ebfc85 100644
--- a/pkgs/development/libraries/science/math/or-tools/default.nix
+++ b/pkgs/development/libraries/science/math/or-tools/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, cmake, abseil-cpp, google-gflags, which
+{ stdenv, fetchFromGitHub, cmake, abseil-cpp, gflags, which
 , lsb-release, glog, protobuf, cbc, zlib
 , ensureNewerSourcesForZipFilesHook, python, swig
 , pythonProtobuf }:
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
   configurePhase = ''
     cat <<EOF > Makefile.local
     UNIX_ABSL_DIR=${abseil-cpp}
-    UNIX_GFLAGS_DIR=${google-gflags}
+    UNIX_GFLAGS_DIR=${gflags}
     UNIX_GLOG_DIR=${glog}
     UNIX_PROTOBUF_DIR=${protobuf}
     UNIX_CBC_DIR=${cbc}
@@ -50,7 +50,7 @@ stdenv.mkDerivation rec {
     python.pkgs.setuptools python.pkgs.wheel
   ];
   propagatedBuildInputs = [
-    abseil-cpp google-gflags glog protobuf cbc
+    abseil-cpp gflags glog protobuf cbc
     pythonProtobuf python.pkgs.six
   ];
 
diff --git a/pkgs/development/libraries/science/math/osi/default.nix b/pkgs/development/libraries/science/math/osi/default.nix
new file mode 100644
index 00000000000..1cc80e78a10
--- /dev/null
+++ b/pkgs/development/libraries/science/math/osi/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, lib, fetchurl, gfortran, pkgconfig
+, blas, zlib, bzip2
+, withGurobi ? false, gurobi
+, withCplex ? false, cplex }:
+
+stdenv.mkDerivation rec {
+  pname = "osi";
+  version = "0.108.4";
+
+  src = fetchurl {
+    url = "https://www.coin-or.org/download/source/Osi/Osi-${version}.tgz";
+    sha256 = "13bwhdh01g37vp3kjwl9nvij5s5ikh5f7zgrqgwrqfyk35q2x9s5";
+  };
+
+  buildInputs =
+    [ blas zlib bzip2 ]
+    ++ lib.optional withGurobi gurobi
+    ++ lib.optional withCplex cplex;
+  nativeBuildInputs = [ gfortran pkgconfig ];
+  configureFlags =
+    lib.optionals withGurobi [ "--with-gurobi-incdir=${gurobi}/include" "--with-gurobi-lib=-lgurobi${gurobi.libSuffix}" ]
+    ++ lib.optionals withCplex [ "--with-cplex-incdir=${cplex}/cplex/include/ilcplex" "--with-cplex-lib=-lcplex${cplex.libSuffix}" ];
+
+  NIX_LDFLAGS =
+    lib.optional withCplex "-L${cplex}/cplex/bin/${cplex.libArch}";
+
+  # Compile errors 
+  NIX_CFLAGS_COMPILE = [ "-Wno-cast-qual" ];
+  hardeningDisable = [ "format" ];
+
+  enableParallelBuilding = true;
+
+  passthru = { inherit withGurobi withCplex; };
+
+  meta = with stdenv.lib; {
+    description = "An abstract base class to a generic linear programming (LP) solver";
+    homepage = "https://github.com/coin-or/Osi";
+    license = licenses.epl10;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ abbradar ];
+  };
+}
diff --git a/pkgs/development/libraries/science/math/spooles/default.nix b/pkgs/development/libraries/science/math/spooles/default.nix
new file mode 100644
index 00000000000..953f5a70b8a
--- /dev/null
+++ b/pkgs/development/libraries/science/math/spooles/default.nix
@@ -0,0 +1,48 @@
+{ stdenv, fetchurl, gfortran, perl }:
+
+stdenv.mkDerivation rec {
+  pname = "spooles";
+  version = "2.2";
+
+  src = fetchurl {
+    url = "http://www.netlib.org/linalg/spooles/spooles.${version}.tgz";
+    sha256 = "1pf5z3vvwd8smbpibyabprdvcmax0grzvx2y0liy98c7x6h5jid8";
+  };
+
+  sourceRoot = ".";
+
+  patches = [
+    ./spooles.patch
+  ];
+
+  buildPhase = ''
+    make lib
+  '';
+
+  installPhase = ''
+    mkdir -p $out/lib $out/include/spooles
+    cp libspooles.a libspooles.so.2.2 $out/lib/
+    ln -s libspooles.so.2.2 $out/lib/libspooles.so.2
+    ln -s libspooles.so.2 $out/lib/libspooles.so
+    for h in *.h; do
+      if [ $h != 'MPI.h' ]; then
+         cp $h $out/include/spooles
+         d=`basename $h .h`
+         if [ -d $d ]; then
+            mkdir $out/include/spooles/$d
+            cp $d/*.h $out/include/spooles/$d
+         fi
+      fi
+    done
+  '';
+
+  nativeBuildInputs = [ perl ];
+
+  meta = with stdenv.lib; {
+    homepage = "http://www.netlib.org/linalg/spooles/";
+    description = "Library for solving sparse real and complex linear systems of equations";
+    license = licenses.publicDomain;
+    maintainers = with maintainers; [ gebner ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/science/math/spooles/spooles.patch b/pkgs/development/libraries/science/math/spooles/spooles.patch
new file mode 100644
index 00000000000..c0c93c9365c
--- /dev/null
+++ b/pkgs/development/libraries/science/math/spooles/spooles.patch
@@ -0,0 +1,188 @@
+diff --git a/I2Ohash/src/util.c b/I2Ohash/src/util.c
+index 72d082e..f32f667 100644
+--- a/I2Ohash/src/util.c
++++ b/I2Ohash/src/util.c
+@@ -39,9 +39,10 @@ fflush(stdout) ;
+ */
+ loc1 = (key1 + 1) % hashtable->nlist ;
+ loc2 = (key2 + 1) % hashtable->nlist ;
+-loc  = (loc1*loc2) % hashtable->nlist ;
++long int loc3  = (long int)loc1*(long int)loc2 % hashtable->nlist ;
++loc =(int) loc3;
+ #if MYDEBUG > 0
+-fprintf(stdout, "\n loc1 = %d, loc2 = %d, loc3 = %d", loc1, loc2, loc) ;
++fprintf(stdout, "\n loc1 = %d, loc2 = %d, loc3 = %ld, loc = %d", loc1, loc2, loc3, loc) ;
+ fflush(stdout) ;
+ #endif
+ /*
+@@ -158,9 +159,10 @@ fflush(stdout) ;
+ #endif
+ loc1 = (key1 + 1) % hashtable->nlist ;
+ loc2 = (key2 + 1) % hashtable->nlist ;
+-loc  = (loc1*loc2) % hashtable->nlist ;
++long int loc3  = (long int)loc1*(long int)loc2 % hashtable->nlist ;
++loc =(int) loc3;
+ #if MYDEBUG > 0
+-fprintf(stdout, "\n loc1 = %d, loc2 = %d, loc3 = %d", loc1, loc2, loc) ;
++fprintf(stdout, "\n loc1 = %d, loc2 = %d, loc3 = %ld, loc = %d", loc1, loc2, loc3, loc) ;
+ fflush(stdout) ;
+ #endif
+ /*
+diff --git a/MPI/makefile b/MPI/makefile
+index 0c09f86..d25e70a 100644
+--- a/MPI/makefile
++++ b/MPI/makefile
+@@ -2,7 +2,7 @@ all_drivers :
+ 	cd drivers ; make drivers
+ 
+ lib :
+-	cd src ; make spoolesMPI.a
++	cd src ; make makeLib
+ 
+ clean :
+ 	cd src ; make clean
+diff --git a/MPI/src/makefile b/MPI/src/makefile
+index f7650b7..71e4c49 100644
+--- a/MPI/src/makefile
++++ b/MPI/src/makefile
+@@ -42,3 +42,8 @@ $(OBJ).a : \
+ 
+ clean :
+ 	- rm -f *.a *.o
++
++makeLib :
++	perl ../../makeLib > makeG
++	make -f makeG
++	rm -f makeG
+diff --git a/MT/makefile b/MT/makefile
+index 9b86a32..d25e70a 100644
+--- a/MT/makefile
++++ b/MT/makefile
+@@ -2,7 +2,7 @@ all_drivers :
+ 	cd drivers ; make drivers
+ 
+ lib :
+-	cd src ; make spoolesMT.a
++	cd src ; make makeLib
+ 
+ clean :
+ 	cd src ; make clean
+diff --git a/Make.inc b/Make.inc
+index f99eb8f..2de8a25 100644
+--- a/Make.inc
++++ b/Make.inc
+@@ -12,7 +12,7 @@
+ # for solaris
+ #
+ # CC = gcc
+-  CC = /usr/lang-4.0/bin/cc
++#  CC = /usr/lang-4.0/bin/cc
+ #
+ # for sgi
+ #
+@@ -28,7 +28,7 @@
+ # 
+ # OPTLEVEL = 
+ # OPTLEVEL = -g -v
+-  OPTLEVEL = -O
++  OPTLEVEL = -O3
+ # OPTLEVEL = -xO5 -v
+ # OPTLEVEL = -O3
+ # OPTLEVEL = -O4
+@@ -43,7 +43,7 @@
+ #  set any load flags
+ #
+ #  LDFLAGS = -Wl,+parallel -Wl,+tm,spp2000 # for hp exemplar
+-   LDFLAGS =
++#   LDFLAGS =
+ #
+ #---------------------------------------------------------------------
+ #
+@@ -103,7 +103,7 @@
+ #  MPI install library
+ #
+ # MPI_INSTALL_DIR = 
+-  MPI_INSTALL_DIR = /usr/local/mpich-1.0.13
++#  MPI_INSTALL_DIR = /usr/lib/openmpi
+ #
+ #---------------------------------------------------------------------
+ #
+@@ -142,6 +142,6 @@
+ #  MPI include path
+ #
+ # MPI_INCLUDE_DIR = 
+-  MPI_INCLUDE_DIR = -I$(MPI_INSTALL_DIR)/include
++#  MPI_INCLUDE_DIR = -I/usr/include/mpi
+ #
+ #---------------------------------------------------------------------
+diff --git a/Utilities/src/iohb.c b/Utilities/src/iohb.c
+index ac38f7b..ac34034 100644
+--- a/Utilities/src/iohb.c
++++ b/Utilities/src/iohb.c
+@@ -1725,7 +1725,7 @@ static void upcase(char* S)
+ 
+ static void IOHBTerminate(char* message) 
+ {
+-   fprintf(stderr,message);
++   fputs(message, stderr);
+    exit(1);
+ }
+ 
+diff --git a/makeLib b/makeLib
+index 1780f39..7697b06 100755
+--- a/makeLib
++++ b/makeLib
+@@ -64,14 +64,19 @@ foreach $src ( @srcnames ) {
+    $srcname = " \\\n     " . $src ;
+    print $srcname ;
+ }
++print "\n\n.SUFFIXES: .c .o .lo .a .so" ;
+ print "\n\nOBJ_FILES = \$\{SRC:.c=.o\}" ;
++print "\n\nLOBJ_FILES = \$\{SRC:.c=.lo\}" ;
+ print "\n\n" ;
+ print <<'EOF' ;
+ .c.o :
+-	$(PURIFY) $(CC) -c $(CFLAGS) $*.c -o $(OBJ)_$*.o
++	$(PURIFY) $(CC) -c $(CFLAGS) $*.c -o $(OBJ)_$*.o $(MPI_INCLUDE_DIR)
+ 
+-../../spooles.a : ${OBJ_FILES}
+-	$(AR) $(ARFLAGS) ../../spooles.a $(OBJ)_*.o
++.c.lo :
++	$(PURIFY) $(CC) -c $(CFLAGS) $*.c -fPIC -DPIC -o $(OBJ)_$*.lo $(MPI_INCLUDE_DIR)
++
++../../libspooles.a : ${OBJ_FILES} ${LOBJ_FILES}
++	$(AR) $(ARFLAGS) ../../libspooles.a $(OBJ)_*.o
+ 	rm -f $(OBJ)_*.o
+-	$(RANLIB) ../../spooles.a
++	$(RANLIB) ../../libspooles.a
+ EOF
+diff --git a/makefile b/makefile
+index f014c7d..7c8042a 100755
+--- a/makefile
++++ b/makefile
+@@ -124,7 +124,9 @@ lib :
+ 	cd ZV               ; make lib
+ 	cd misc             ; make lib
+ #cd MPI              ; make lib
+-#cd MT               ; make lib
++	cd MT               ; make lib
++	gcc -shared */*/*.lo -Wl,-soname,libspooles.so.2.2 -o libspooles.so.2.2 -lpthread -lm
++	ln -s libspooles.so.2.2 libspooles.so
+ 
+ global :
+ 	cd A2/src             ; make -f makeGlobalLib
+diff --git a/timings.h b/timings.h
+index 23df189..685800b 100644
+--- a/timings.h
++++ b/timings.h
+@@ -2,9 +2,8 @@
+ #define _TIMINGS_
+ #include <sys/time.h>
+ static struct timeval  TV ;
+-static struct timezone TZ ;
+ #define MARKTIME(t) \
+-   gettimeofday(&TV, &TZ) ; \
++   gettimeofday(&TV, NULL) ; \
+    t = (TV.tv_sec + 0.000001*TV.tv_usec)
+ #endif
+ 
diff --git a/pkgs/development/libraries/science/math/sympow/default.nix b/pkgs/development/libraries/science/math/sympow/default.nix
index 080cab86ca4..2e543abd411 100644
--- a/pkgs/development/libraries/science/math/sympow/default.nix
+++ b/pkgs/development/libraries/science/math/sympow/default.nix
@@ -1,89 +1,74 @@
 { stdenv
-, fetchurl
-, fetchpatch
+, fetchFromGitLab
 , makeWrapper
+, which
+, autoconf
+, help2man
+, file
+, pari
 }:
 
 stdenv.mkDerivation rec {
-  version = "1.018.1";
+  version = "2.023.5";
   name = "sympow-${version}";
 
-  src = fetchurl {
-    # Original website no longer reachable
-    url = "mirror://sageupstream/sympow/sympow-${version}.tar.bz2";
-    sha256 = "0hphs7ia1wr5mydf288zvwj4svrymfpadcg3pi6w80km2yg5bm3c";
+  src = fetchFromGitLab {
+    group = "rezozer";
+    owner = "forks";
+    repo = "sympow";
+    rev = "v${version}";
+    sha256 = "1c5a2pizgqsf3pjkf7rfj20022ym4ixhrddp8ivs2nbzxwz6qvv9";
   };
 
+  postUnpack = ''
+    patchShebangs .
+  '';
+
   nativeBuildInputs = [
     makeWrapper
+    which
+    autoconf
+    help2man
+    file
+    pari
   ];
 
   configurePhase = ''
     runHook preConfigure
+    export PREFIX="$out"
+    export VARPREFIX="$out" # see comment on postInstall
     ./Configure # doesn't take any options
     runHook postConfigure
   '';
 
-  installPhase = ''
-    runHook preInstall
-    install -D datafiles/* --target-directory "$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
+  # Usually, sympow has 3 levels of caching: statically distributed in /usr/,
+  # shared in /var and per-user in ~/.sympow. The shared cache assumes trust in
+  # other users and a shared /var is not compatible with nix's approach, so we
+  # set VARPREFIX to the read-only $out. This effectively disables shared
+  # caching. See https://trac.sagemath.org/ticket/3360#comment:36 and sympow's
+  # README for more details on caching.
+  # sympow will complain at runtime about the lack of write-permissions on the
+  # shared cache. We pass the `-quiet` flag by default to disable this.
+  postInstall = ''
+    wrapProgram "$out/bin/sympow" --add-flags '-quiet'
   '';
 
-  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&id=5088e641a45b23d0385d8e63be65315129b4cf58";
-      sha256 = "1m0vz048layb47r1jjf7fplw650ccc9x0w3l322iqmppzmv3022a";
-    })
-  ];
+  # Example from the README as a sanity check.
+  doInstallCheck = true;
+  installCheckPhase = ''
+    export HOME="$TMP/home"
+    mkdir -p "$HOME"
+    "$out/bin/sympow" -sp 2p16 -curve "[1,2,3,4,5]" | grep '8.3705'
+  '';
 
   meta = with stdenv.lib; {
-    description = "A package to compute special values of symmetric power elliptic curve L-functions";
+    description = "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;
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/science/math/tensorflow/bin.nix b/pkgs/development/libraries/science/math/tensorflow/bin.nix
new file mode 100644
index 00000000000..3db7a6f1d1e
--- /dev/null
+++ b/pkgs/development/libraries/science/math/tensorflow/bin.nix
@@ -0,0 +1,72 @@
+{ stdenv
+, fetchurl
+, patchelf
+, cudaSupport ? false, symlinkJoin, cudatoolkit, cudnn, nvidia_x11
+}:
+
+with stdenv.lib;
+let
+  unavailable = throw "libtensorflow is not available for this platform!";
+
+  tfType = if cudaSupport then "gpu" else "cpu";
+
+  system = 
+    if      stdenv.isLinux  then "linux"
+    else if stdenv.isDarwin then "darwin"
+    else unavailable;
+
+  platform =
+    if stdenv.isx86_64 then "x86_64"
+    else unavailable;
+
+  rpath = makeLibraryPath ([stdenv.cc.libc stdenv.cc.cc.lib] ++
+            optionals cudaSupport [ cudatoolkit.out cudatoolkit.lib cudnn nvidia_x11 ]);
+
+  packages = import ./binary-hashes.nix;
+  packageName = "${tfType}-${system}-${platform}";
+  url = packages.${packageName} or unavailable;
+
+  patchLibs =
+    if stdenv.isDarwin
+    then ''
+      install_name_tool -id $out/lib/libtensorflow.dylib $out/lib/libtensorflow.dylib
+      install_name_tool -id $out/lib/libtensorflow_framework.dylib $out/lib/libtensorflow_framework.dylib
+    ''
+    else ''
+      patchelf --set-rpath "${rpath}:$out/lib" $out/lib/libtensorflow.so
+      patchelf --set-rpath "${rpath}" $out/lib/libtensorflow_framework.so
+    '';
+
+in stdenv.mkDerivation rec {
+  pname = "libtensorflow";
+  inherit (packages) version;
+
+  src = fetchurl url;
+
+  # Patch library to use our libc, libstdc++ and others
+  buildCommand = ''
+    mkdir -pv $out
+    tar -C $out -xzf $src
+    chmod -R +w $out
+    ${patchLibs}
+
+    # Write pkgconfig file.
+    mkdir $out/lib/pkgconfig
+    cat > $out/lib/pkgconfig/tensorflow.pc << EOF
+    Name: TensorFlow
+    Version: ${version}
+    Description: Library for computation using data flow graphs for scalable machine learning
+    Requires:
+    Libs: -L$out/lib -ltensorflow
+    Cflags: -I$out/include/tensorflow
+    EOF
+  '';
+
+  meta = {
+    description = "C API for TensorFlow";
+    homepage = https://www.tensorflow.org/install/lang_c;
+    license = licenses.asl20;
+    platforms = [ "x86_64-linux" "x86_64-darwin" ];
+    maintainers = with maintainers; [ basvandijk ];
+  };
+}
diff --git a/pkgs/development/libraries/science/math/tensorflow/binary-hashes.nix b/pkgs/development/libraries/science/math/tensorflow/binary-hashes.nix
new file mode 100644
index 00000000000..892dfa2a609
--- /dev/null
+++ b/pkgs/development/libraries/science/math/tensorflow/binary-hashes.nix
@@ -0,0 +1,15 @@
+{
+version = "1.14.0";
+"cpu-linux-x86_64" = {
+  url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.14.0.tar.gz";
+  sha256 = "04bi3ijq4sbb8c5vk964zlv0j9mrjnzzxd9q9knq3h273nc1a36k";
+};
+"gpu-linux-x86_64" = {
+  url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-1.14.0.tar.gz";
+  sha256 = "1ffnpyj9jjgwxpjfiyjvq4dm3n6nwiksim5jld9zw7fdswh215x6";
+};
+"cpu-darwin-x86_64" = {
+  url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-darwin-x86_64-1.14.0.tar.gz";
+  sha256 = "0zsd5ils1a17j6jzh0c7q1z56fw46gkzybbnms7h2rgg8al0rh92";
+};
+}
diff --git a/pkgs/development/libraries/science/math/tensorflow/prefetcher.sh b/pkgs/development/libraries/science/math/tensorflow/prefetcher.sh
new file mode 100755
index 00000000000..515f25df4c1
--- /dev/null
+++ b/pkgs/development/libraries/science/math/tensorflow/prefetcher.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+version=1.14.0
+hashfile=binary-hashes.nix
+rm -f $hashfile
+echo "{" >> $hashfile
+echo "version = \"$version\";" >> $hashfile
+for sys in "linux" "darwin"; do
+    for tfpref in "cpu" "gpu"; do
+        for platform in "x86_64"; do
+            if [ $sys = "darwin" ] && [ $tfpref = "gpu" ]; then
+               continue
+            fi
+            url=https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-$tfpref-$sys-$platform-$version.tar.gz
+            hash=$(nix-prefetch-url $url)
+            echo "\"${tfpref}-${sys}-${platform}\" = {" >> $hashfile
+            echo "  url = \"$url\";" >> $hashfile
+            echo "  sha256 = \"$hash\";" >> $hashfile
+            echo "};" >> $hashfile
+        done
+    done
+done
+echo "}" >> $hashfile
+
diff --git a/pkgs/development/libraries/serialdv/default.nix b/pkgs/development/libraries/serialdv/default.nix
new file mode 100644
index 00000000000..11f9d301347
--- /dev/null
+++ b/pkgs/development/libraries/serialdv/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchFromGitHub, cmake }:
+
+stdenv.mkDerivation rec {
+  pname = "serialdv";
+  version ="1.1.1";
+
+  src = fetchFromGitHub {
+    owner = "f4exb";
+    repo = "serialdv";
+    rev = "v${version}";
+    sha256 = "0swalyp8cbs7if6gxbcl7wf83ml8ch3k7ww4hws89rzpjvf070fr";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  meta = with stdenv.lib; {
+    description = "C++ Minimal interface to encode and decode audio with AMBE3000 based devices in packet mode over a serial link.";
+    homepage = "https://github.com/f4exb/serialdv";
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ alkeryn ];
+  };
+}
+
diff --git a/pkgs/development/libraries/sfml/default.nix b/pkgs/development/libraries/sfml/default.nix
index 8e1b9ae394b..1b043d33ad6 100644
--- a/pkgs/development/libraries/sfml/default.nix
+++ b/pkgs/development/libraries/sfml/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchzip, cmake, libX11, freetype, libjpeg, openal, flac, libvorbis
 , glew, libXrandr, libXrender, udev, xcbutilimage
-, cf-private, IOKit, Foundation, AppKit, OpenAL
+, IOKit, Foundation, AppKit, OpenAL
 }:
 
 let
@@ -19,10 +19,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ freetype libjpeg openal flac libvorbis glew ]
     ++ stdenv.lib.optional stdenv.isLinux udev
     ++ stdenv.lib.optionals (!stdenv.isDarwin) [ libX11 libXrandr libXrender xcbutilimage ]
-    ++ stdenv.lib.optionals stdenv.isDarwin [ IOKit Foundation AppKit OpenAL
-    # Needed for _NSDefaultRunLoopMode, _OBJC_CLASS_$_NSArray, _OBJC_CLASS_$_NSDate
-    cf-private
-    ];
+    ++ stdenv.lib.optionals stdenv.isDarwin [ IOKit Foundation AppKit OpenAL ];
 
   cmakeFlags = [ "-DSFML_INSTALL_PKGCONFIG_FILES=yes"
                  "-DSFML_MISC_INSTALL_PREFIX=share/SFML"
diff --git a/pkgs/development/libraries/shibboleth-sp/default.nix b/pkgs/development/libraries/shibboleth-sp/default.nix
index 74f861297d1..dd9b01a0a01 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.1";
+  version = "3.0.4.1";
 
   src = fetchgit {
     url = "https://git.shibboleth.net/git/cpp-sp.git";
     rev = version;
-    sha256 = "01q13p7gc0janjfml6zs46na8qnval8hc833fk2wrnmi4w9xw4fd";
+    sha256 = "1qb4dbz5gk10b9w1rf6f4vv7c2wb3a8bfzif6yiaq96ilqad7gdr";
   };
 
   nativeBuildInputs = [ autoreconfHook pkgconfig ];
diff --git a/pkgs/development/libraries/simgear/default.nix b/pkgs/development/libraries/simgear/default.nix
index 11612eeb288..471bcb22234 100644
--- a/pkgs/development/libraries/simgear/default.nix
+++ b/pkgs/development/libraries/simgear/default.nix
@@ -3,26 +3,29 @@
 , openscenegraph, openal, expat, cmake, apr
 , curl
 }:
-
+let
+  version = "2019.1.1";
+  shortVersion = builtins.substring 0 6 version;
+in
 stdenv.mkDerivation rec {
-  name = "simgear-${version}";
-  version = "2018.3.1";
-  shortVersion = "2018.3";
+  pname = "simgear";
+  inherit version;
 
   src = fetchurl {
-    url = "mirror://sourceforge/flightgear/release-${shortVersion}/${name}.tar.bz2";
-    sha256 = "0sm0v8v1sw5xzkzhf0gzh6fwx93hd62h5lm9s9hgci40x7480i99";
+    url = "mirror://sourceforge/flightgear/release-${shortVersion}/${pname}-${version}.tar.bz2";
+    sha256 = "12sl18limlj61hlwl3bcv5ysfdpsjmd07cxchhf9xa8shk6d87i0";
   };
 
+  nativeBuildInputs = [ cmake ];
   buildInputs = [ plib freeglut xorgproto libX11 libXext libXi
                   libICE libSM libXt libXmu libGLU_combined boost zlib libjpeg freealut
-                  openscenegraph openal expat cmake apr curl ];
+                  openscenegraph openal expat apr curl ];
 
   enableParallelBuilding = true;
 
   meta = with stdenv.lib; {
     description = "Simulation construction toolkit";
-    homepage = https://gitorious.org/fg/simgear;
+    homepage = "https://gitorious.org/fg/simgear";
     maintainers = with maintainers; [ raskin ];
     platforms = platforms.linux;
     license = licenses.lgpl2;
diff --git a/pkgs/development/libraries/simpleitk/default.nix b/pkgs/development/libraries/simpleitk/default.nix
index 90dfe8ebfab..1cf40c92db6 100644
--- a/pkgs/development/libraries/simpleitk/default.nix
+++ b/pkgs/development/libraries/simpleitk/default.nix
@@ -1,13 +1,14 @@
-{ stdenv, fetchurl, cmake, git, swig, lua, itk }:
+{ stdenv, fetchFromGitHub, cmake, git, swig, lua, itk, tcl, tk }:
 
 stdenv.mkDerivation rec {
-  pname    = "simpleitk";
-  version = "1.2.0";
-  name  = "${pname}-${version}";
+  pname = "simpleitk";
+  version = "1.2.2";
 
-  src = fetchurl {
-    url    = "https://sourceforge.net/projects/${pname}/files/SimpleITK/${version}/Source/SimpleITK-${version}.tar.gz";
-    sha256 = "10lxsr0144li6bmfgs646cvczczqkgmvvs3ndds66q8lg9zwbnky";
+  src = fetchFromGitHub {
+    owner = "SimpleITK";
+    repo = "SimpleITK";
+    rev = "v${version}";
+    sha256 = "1cgq9cxxplv6bkm2zfvcc0lgyh5zw1hbry30k1429n9737wnadaw";
   };
 
   nativeBuildInputs = [ cmake git swig ];
@@ -21,7 +22,7 @@ stdenv.mkDerivation rec {
     homepage = http://www.simpleitk.org;
     description = "Simplified interface to ITK";
     maintainers = with maintainers; [ bcdarwin ];
-    platforms = platforms.unix;
+    platforms = platforms.linux;
     license = licenses.asl20;
   };
 }
diff --git a/pkgs/development/libraries/skalibs/default.nix b/pkgs/development/libraries/skalibs/default.nix
index e56d677e8a4..c885f00a33c 100644
--- a/pkgs/development/libraries/skalibs/default.nix
+++ b/pkgs/development/libraries/skalibs/default.nix
@@ -1,11 +1,11 @@
-{ stdenv, skawarePackages }:
+{ skawarePackages }:
 
 with skawarePackages;
 
 buildPackage {
   pname = "skalibs";
-  version = "2.8.0.0";
-  sha256 = "06hyiq68jh32qwr2mydw3dbnm4zzpynnnmprd5g4iqavsycyvh53";
+  version = "2.8.1.0";
+  sha256 = "1fk6n402ywn4kpy6ng7sfnnqcg0mp6wq2hrv8sv3kxd0nh3na723";
 
   description = "A set of general-purpose C programming libraries";
 
diff --git a/pkgs/development/libraries/soil/default.nix b/pkgs/development/libraries/soil/default.nix
index 6e30825cfb3..2f3ec44a08c 100644
--- a/pkgs/development/libraries/soil/default.nix
+++ b/pkgs/development/libraries/soil/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, unzip, mesa_noglu, libX11 }:
+{ stdenv, fetchurl, unzip, mesa, libX11 }:
 
 stdenv.mkDerivation rec {
   name = "soil";
@@ -8,8 +8,8 @@ stdenv.mkDerivation rec {
     sha256 = "00gpwp9dldzhsdhksjvmbhsd2ialraqbv6v6dpikdmpncj6mnc52";
   };
 
-  buildInputs = [ unzip mesa_noglu libX11 ];
-  
+  buildInputs = [ unzip mesa libX11 ];
+
   sourceRoot = "Simple OpenGL Image Library/projects/makefile";
   preBuild   = "mkdir obj";
   preInstall = "mkdir -p $out/lib $out/include";
diff --git a/pkgs/development/libraries/soqt/default.nix b/pkgs/development/libraries/soqt/default.nix
index 9769596621b..98226ce20f4 100644
--- a/pkgs/development/libraries/soqt/default.nix
+++ b/pkgs/development/libraries/soqt/default.nix
@@ -1,17 +1,19 @@
-{ fetchurl, stdenv, coin3d, qt4, pkgconfig }:
+{ fetchhg, stdenv, coin3d, qt5, cmake, pkgconfig }:
 
 stdenv.mkDerivation rec {
-  name = "soqt-${version}";
-  version = "1.5.0";
+  pname = "soqt";
+  version = "1.6.0a";
 
-  src = fetchurl {
-    url = "https://bitbucket.org/Coin3D/coin/downloads/SoQt-${version}.tar.gz";
-    sha256 = "14dbh8ynzjcgwgxjc6530c5plji7vn62kbdf447w0dp53564p8zn";
+  src = fetchhg {
+    url = "https://bitbucket.org/Coin3D/soqt";
+    rev = "5f2afb4890e0059eb27e1671f980d10ebfb9e762";
+    sha256 = "0j9lsci4cx95v16l0jaky0vzh4lbdliwz7wc17442ihjaqiqmv8m";
+    fetchSubrepos = true;
   };
 
-  buildInputs = [ coin3d qt4 ];
+  buildInputs = [ coin3d qt5.qtbase ];
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ cmake pkgconfig ];
 
   meta = {
     homepage = https://bitbucket.org/Coin3D/coin/wiki/Home;
diff --git a/pkgs/development/libraries/soundtouch/default.nix b/pkgs/development/libraries/soundtouch/default.nix
index 95a97f30b6e..71c7915c2ed 100644
--- a/pkgs/development/libraries/soundtouch/default.nix
+++ b/pkgs/development/libraries/soundtouch/default.nix
@@ -1,22 +1,24 @@
-{stdenv, fetchurl, autoconf, automake, libtool}:
+{stdenv, lib, fetchFromGitLab, autoconf, automake, libtool}:
 
 stdenv.mkDerivation rec {
-  pName = "soundtouch";
-  name = "${pName}-2.0.0";
-  src = fetchurl {
-    url = "https://www.surina.net/soundtouch/${name}.tar.gz";
-    sha256 = "09cxr02mfyj2bg731bj0i9hh565x8l9p91aclxs8wpqv8b8zf96j";
+  pname = "soundtouch";
+  version = "2.1.2";
+
+  src = fetchFromGitLab {
+    owner = pname;
+    repo = pname;
+    rev = version;
+    sha256 = "174wgm3s0inmbnkrlnspxjwm2014qhjhkbdqa5r8rbfi0nzqxzsz";
   };
 
-  buildInputs = [ autoconf automake libtool ];
+  nativeBuildInputs = [ autoconf automake libtool ];
 
   preConfigure = "./bootstrap";
 
-  meta = {
-      description = "A program and library for changing the tempo, pitch and playback rate of audio";
-      homepage = http://www.surina.net/soundtouch/;
-      downloadPage = http://www.surina.net/soundtouch/sourcecode.html;
-      license = stdenv.lib.licenses.lgpl21;
-      platforms = stdenv.lib.platforms.all;
+  meta = with lib; {
+    description = "A program and library for changing the tempo, pitch and playback rate of audio";
+    homepage = "http://www.surina.net/soundtouch/";
+    license = licenses.lgpl21;
+    platforms = platforms.all;
   };
 }
diff --git a/pkgs/development/libraries/soxt/default.nix b/pkgs/development/libraries/soxt/default.nix
index c219d5bfb36..50ba9c944ab 100644
--- a/pkgs/development/libraries/soxt/default.nix
+++ b/pkgs/development/libraries/soxt/default.nix
@@ -1,15 +1,18 @@
-{ fetchurl, stdenv, coin3d, motif, xlibsWrapper, libGLU_combined }:
+{ fetchhg, stdenv, cmake, coin3d, motif, xlibsWrapper, libXmu, libGLU_combined }:
 
 stdenv.mkDerivation rec {
-  name = "soxt-${version}";
-  version = "1.3.0";
+  pname = "soxt";
+  version = "unstable-2019-06-14";
 
-  src = fetchurl {
-    url = "https://bitbucket.org/Coin3D/coin/downloads/SoXt-${version}.tar.gz";
-    sha256= "f5443aadafe8e2222b9b5a23d1f228bb0f3e7d98949b8ea8676171b7ea5bf013";
+  src = fetchhg {
+    url = "https://bitbucket.org/Coin3D/soxt";
+    rev = "85e135bb266fbb17e47fc336b876a576a239c15c";
+    sha256 = "0vk5cgn53yqf7csqdnlnyyhi4mbgx4wlsq70613p5fgxlvxzhcym";
+    fetchSubrepos = true;
   };
 
-  buildInputs = [ coin3d motif xlibsWrapper libGLU_combined ];
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ coin3d motif xlibsWrapper libGLU_combined libXmu ];
 
   meta = with stdenv.lib; {
     homepage = https://bitbucket.org/Coin3D/coin/wiki/Home;
diff --git a/pkgs/development/libraries/speexdsp/default.nix b/pkgs/development/libraries/speexdsp/default.nix
index 16be9fa1e3b..4d74c7e0559 100644
--- a/pkgs/development/libraries/speexdsp/default.nix
+++ b/pkgs/development/libraries/speexdsp/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, autoreconfHook, pkgconfig, fftw }:
 
 stdenv.mkDerivation rec {
-  name = "speexdsp-1.2rc3";
+  name = "speexdsp-1.2.0";
 
   src = fetchurl {
     url = "http://downloads.us.xiph.org/releases/speex/${name}.tar.gz";
-    sha256 = "1wcjyrnwlkayb20zdhp48y260rfyzg925qpjpljd5x9r01h8irja";
+    sha256 = "0wa7sqpk3x61zz99m7lwkgr6yv62ml6lfgs5xja65vlvdzy44838";
   };
 
   patches = [ ./build-fix.patch ];
diff --git a/pkgs/development/libraries/spice-gtk/default.nix b/pkgs/development/libraries/spice-gtk/default.nix
index 0169a42ed65..8f92e0b64f6 100644
--- a/pkgs/development/libraries/spice-gtk/default.nix
+++ b/pkgs/development/libraries/spice-gtk/default.nix
@@ -1,14 +1,12 @@
 { stdenv
 , fetchurl
 , pkgconfig
-, fetchpatch
 , meson
 , ninja
 , python3
 , spice-protocol
 , gettext
 , openssl
-, libpulseaudio
 , pixman
 , gobject-introspection
 , libjpeg_turbo
@@ -89,10 +87,13 @@ stdenv.mkDerivation rec {
     vala
   ];
 
+  propagatedBuildInputs = [
+    gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good
+  ];
+
   buildInputs = [
     cyrus_sasl
     epoxy
-    gst_all_1.gst-plugins-base
     gtk3
     json-glib
     libcacard
@@ -111,7 +112,6 @@ stdenv.mkDerivation rec {
   PKG_CONFIG_POLKIT_GOBJECT_1_POLICYDIR = "${placeholder "out"}/share/polkit-1/actions";
 
   mesonFlags = [
-    "-Dauto_features=enabled"
     "-Dcelt051=disabled"
     "-Dpulse=disabled" # is deprecated upstream
   ];
diff --git a/pkgs/development/libraries/spice/default.nix b/pkgs/development/libraries/spice/default.nix
index 902bc6a5560..d2c4ddb8631 100644
--- a/pkgs/development/libraries/spice/default.nix
+++ b/pkgs/development/libraries/spice/default.nix
@@ -1,5 +1,4 @@
 { stdenv
-, substituteAll
 , fetchurl
 , meson
 , ninja
@@ -78,7 +77,6 @@ stdenv.mkDerivation rec {
   NIX_CFLAGS_COMPILE = "-fno-stack-protector";
 
   mesonFlags = [
-    "-Dauto_features=enabled"
     "-Dgstreamer=1.0"
     "-Dcelt051=disabled"
   ];
diff --git a/pkgs/development/libraries/sqlcipher/default.nix b/pkgs/development/libraries/sqlcipher/default.nix
index ce72c2737be..6cf8d97cb67 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 = "4.1.0";
+  version = "4.2.0";
 
   src = fetchFromGitHub {
     owner = "sqlcipher";
     repo = "sqlcipher";
     rev = "v${version}";
-    sha256 = "0w0f4pg3jfzismpgqnbf60bjbbll2ang48216bc4m20mm2dpp5ar";
+    sha256 = "1wpymql2ps4k2qkfa5mdifihb1n815xlz7imcd8ri1gn2qla8q8i";
   };
 
   buildInputs = [ readline ncurses openssl tcl ];
diff --git a/pkgs/development/libraries/sqlite/default.nix b/pkgs/development/libraries/sqlite/default.nix
index b2351a32fa6..ea1c38ea476 100644
--- a/pkgs/development/libraries/sqlite/default.nix
+++ b/pkgs/development/libraries/sqlite/default.nix
@@ -9,7 +9,7 @@ let
 in
 
 stdenv.mkDerivation rec {
-  pname = "sqlite";
+  name = "sqlite-${version}";
   version = "3.28.0";
 
   # NB! Make sure to update analyzer.nix src (in the same directory).
@@ -71,7 +71,6 @@ stdenv.mkDerivation rec {
     sed -i $out/lib/libsqlite3.la -e "s/dependency_libs=.*/dependency_libs='''/"
   '';
 
-  enableParallelBuilding = true;
   doCheck = false; # fails to link against tcl
 
   meta = {
diff --git a/pkgs/development/libraries/swiften/default.nix b/pkgs/development/libraries/swiften/default.nix
index c83f5b0f5ac..e30da732a46 100644
--- a/pkgs/development/libraries/swiften/default.nix
+++ b/pkgs/development/libraries/swiften/default.nix
@@ -12,6 +12,8 @@ stdenv.mkDerivation rec {
     sha256 = "0w0aiszjd58ynxpacwcgf052zpmbpcym4dhci64vbfgch6wryz0w";
   };
 
+  patches = [ ./scons.patch ];
+
   sconsFlags = [
     "openssl=${openssl.dev}"
     "boost_includedir=${boost.dev}/include"
@@ -23,6 +25,8 @@ stdenv.mkDerivation rec {
     installFlags+=" SWIFT_INSTALLDIR=$out"
   '';
 
+  enableParallelBuilding = true;
+
   meta = with stdenv.lib; {
     description = "An XMPP library for C++, used by the Swift client";
     homepage    = http://swift.im/swiften.html;
diff --git a/pkgs/development/libraries/swiften/scons.patch b/pkgs/development/libraries/swiften/scons.patch
new file mode 100644
index 00000000000..d956767696d
--- /dev/null
+++ b/pkgs/development/libraries/swiften/scons.patch
@@ -0,0 +1,9 @@
+--- a/BuildTools/SCons/SConscript.boot
++++ b/BuildTools/SCons/SConscript.boot
+@@ -129,5 +129 @@ vars.Add(PathVariable("sparkle_public_dsa_key", "Optional path to a public DSA k
+-env_ENV = {
+-    'PATH' : os.environ['PATH'],
+-    'LD_LIBRARY_PATH' : os.environ.get("LD_LIBRARY_PATH", ""),
+-    'TERM' : os.environ.get("TERM", ""),
+-}
++env_ENV = os.environ
diff --git a/pkgs/development/libraries/symengine/default.nix b/pkgs/development/libraries/symengine/default.nix
index 40e1a280aa2..424dc116c7e 100644
--- a/pkgs/development/libraries/symengine/default.nix
+++ b/pkgs/development/libraries/symengine/default.nix
@@ -9,13 +9,13 @@
 
 stdenv.mkDerivation rec {
   name = "symengine-${version}";
-  version = "0.4.0";
+  version = "0.4.1";
 
   src = fetchFromGitHub {
     owner = "symengine";
     repo = "symengine";
     rev = "v${version}";
-    sha256 = "1kz893p3pmsw3gfwickk2nliw8p63yp89xriad7kpw4kmhvgr8gb";
+    sha256 = "0qqxr7l5lr81k6fs2h5isr43x0dw07rwg3ivl6vd8zmmcgsp9ygd";
   };
 
   nativeBuildInputs = [ cmake ];
diff --git a/pkgs/development/libraries/tbb/default.nix b/pkgs/development/libraries/tbb/default.nix
index b406e792d16..89b163a0917 100644
--- a/pkgs/development/libraries/tbb/default.nix
+++ b/pkgs/development/libraries/tbb/default.nix
@@ -2,13 +2,13 @@
 
 with stdenv.lib; stdenv.mkDerivation rec {
   name = "tbb-${version}";
-  version = "2019_U7";
+  version = "2019_U8";
 
   src = fetchFromGitHub {
     owner = "01org";
     repo = "tbb";
     rev = version;
-    sha256 = "0hf8vkb1g2dqihqw7fzhc90i1p7yvp45gbamj0mnnhffz2ablz1b";
+    sha256 = "0z0kh1a5g28gckcxlv3x7qqskh5fsl8knf2ypbbvk7z9ln9k3wfq";
   };
 
   makeFlags = concatStringsSep " " (
diff --git a/pkgs/development/libraries/tdlib/default.nix b/pkgs/development/libraries/tdlib/default.nix
new file mode 100644
index 00000000000..716f3d313b4
--- /dev/null
+++ b/pkgs/development/libraries/tdlib/default.nix
@@ -0,0 +1,24 @@
+{ fetchFromGitHub, gperf, openssl, readline, zlib, cmake, stdenv }:
+
+stdenv.mkDerivation rec {
+  version = "1.4.0";
+  pname = "tdlib";
+
+  src = fetchFromGitHub {
+    owner = "tdlib";
+    repo = "td";
+    rev = "v${version}";
+    sha256 = "1ijyn14rjb87rqm39hg7md8ab33yiy8cgzw3p0m37scn58gabpp7";
+  };
+
+  buildInputs = [ gperf openssl readline zlib ];
+  nativeBuildInputs = [ cmake ];
+
+  meta = with stdenv.lib; {
+    description = "Cross-platform library for building Telegram clients";
+    homepage = "https://core.telegram.org/tdlib/";
+    license = [ licenses.boost ];
+    platforms = platforms.linux;
+    maintainers = [ maintainers.vyorkin ];
+  };
+}
diff --git a/pkgs/development/libraries/theft/default.nix b/pkgs/development/libraries/theft/default.nix
index 881f9c033a3..8d72d9a7d8e 100644
--- a/pkgs/development/libraries/theft/default.nix
+++ b/pkgs/development/libraries/theft/default.nix
@@ -1,14 +1,14 @@
 { stdenv, fetchFromGitHub }:
 
 stdenv.mkDerivation rec {
-  version = "0.4.4";
+  version = "0.4.5";
   name = "theft-${version}";
 
   src = fetchFromGitHub {
-    owner = "silentbicycle";
-    repo = "theft";
-    rev = "v${version}";
-    sha256 = "1csdhnb10k7vsyd44vjpg430nf6a909wj8af2zawdkbvnxn5wxc4";
+    owner  = "silentbicycle";
+    repo   = "theft";
+    rev    = "v${version}";
+    sha256 = "1n2mkawfl2bpd4pwy3mdzxwlqjjvb5bdrr2x2gldlyqdwbk7qjhd";
   };
 
   preConfigure = "patchShebangs ./scripts/mk_bits_lut";
@@ -17,13 +17,21 @@ stdenv.mkDerivation rec {
   checkTarget = "test";
   
   installFlags = [ "PREFIX=$(out)" ];
-  postInstall = "install -m644 vendor/greatest.h $out/include/";
+
+  # fix the libtheft.pc file to use the right installation
+  # directory. should be fixed upstream, too
+  postInstall = ''
+    install -m644 vendor/greatest.h $out/include/
+
+    substituteInPlace $out/lib/pkgconfig/libtheft.pc \
+      --replace "/usr/local" "$out"
+  '';
   
-  meta = {
+  meta = with stdenv.lib; {
     description = "A C library for property-based testing";
-    platforms = stdenv.lib.platforms.linux;
-    homepage = "https://github.com/silentbicycle/theft/";
-    license = stdenv.lib.licenses.isc;
-    maintainers = [ stdenv.lib.maintainers.kquick ];
+    homepage    = "https://github.com/silentbicycle/theft/";
+    platforms   = platforms.unix;
+    license     = licenses.isc;
+    maintainers = with maintainers; [ kquick thoughtpolice ];
   };
 }
diff --git a/pkgs/development/libraries/thrift/0.10.nix b/pkgs/development/libraries/thrift/0.10.nix
new file mode 100644
index 00000000000..d626673a227
--- /dev/null
+++ b/pkgs/development/libraries/thrift/0.10.nix
@@ -0,0 +1,39 @@
+{ stdenv, fetchurl, boost, zlib, libevent, openssl, python, pkgconfig, bison
+, flex, twisted
+}:
+
+stdenv.mkDerivation rec {
+  pname = "thrift";
+  version = "0.10.0";
+
+  src = fetchurl {
+    url = "https://archive.apache.org/dist/thrift/${version}/${pname}-${version}.tar.gz";
+    sha256 = "02x1xw0l669idkn6xww39j60kqxzcbmim4mvpb5h9nz8wqnx1292";
+  };
+
+  #enableParallelBuilding = true; problems on hydra
+
+  # Workaround to make the python wrapper not drop this package:
+  # pythonFull.buildEnv.override { extraLibs = [ thrift ]; }
+  pythonPath = [];
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [
+    boost zlib libevent openssl python bison flex twisted
+  ];
+
+  preConfigure = "export PY_PREFIX=$out";
+
+  # TODO: package boost-test, so we can run the test suite. (Currently it fails
+  # to find libboost_unit_test_framework.a.)
+  configureFlags = [ "--enable-tests=no" ];
+  doCheck = false;
+
+  meta = with stdenv.lib; {
+    description = "Library for scalable cross-language services";
+    homepage = "http://thrift.apache.org/";
+    license = licenses.asl20;
+    platforms = platforms.linux ++ platforms.darwin;
+    maintainers = [ maintainers.bjornfor ];
+  };
+}
diff --git a/pkgs/development/libraries/tk/generic.nix b/pkgs/development/libraries/tk/generic.nix
index 6e4640fabb7..a65c6053f29 100644
--- a/pkgs/development/libraries/tk/generic.nix
+++ b/pkgs/development/libraries/tk/generic.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, src, pkgconfig, tcl, libXft, fontconfig, patches ? []
+{ stdenv, lib, src, pkgconfig, tcl, libXft, patches ? []
 , enableAqua ? stdenv.isDarwin, darwin
 , ... }:
 
@@ -32,11 +32,9 @@ stdenv.mkDerivation {
     ++ stdenv.lib.optional enableAqua "--enable-aqua";
 
   nativeBuildInputs = [ pkgconfig ];
+  buildInputs = lib.optional enableAqua (with darwin.apple_sdk.frameworks; [ Cocoa ]);
 
-  propagatedBuildInputs = [ tcl libXft ]
-    ++ lib.optional enableAqua (with darwin; with apple_sdk.frameworks; [
-      Cocoa cf-private
-    ]);
+  propagatedBuildInputs = [ tcl libXft ];
 
   doCheck = false; # fails. can't find itself
 
diff --git a/pkgs/development/libraries/tracker-miners/default.nix b/pkgs/development/libraries/tracker-miners/default.nix
new file mode 100644
index 00000000000..9f31e70ad53
--- /dev/null
+++ b/pkgs/development/libraries/tracker-miners/default.nix
@@ -0,0 +1,140 @@
+{ stdenv
+, fetchurl
+, substituteAll
+, intltool
+, itstool
+, libxslt
+, gexiv2
+, tracker
+, meson
+, ninja
+, pkgconfig
+, vala
+, wrapGAppsHook
+, bzip2
+, dbus
+, evolution-data-server
+, exempi
+, flac
+, giflib
+, glib
+, gnome3
+, gst_all_1
+, icu
+, json-glib
+, libcue
+, libexif
+, libgrss
+, libgsf
+, libgxps
+, libiptcdata
+, libjpeg
+, libosinfo
+, libpng
+, libseccomp
+, libsoup
+, libtiff
+, libuuid
+, libvorbis
+, libxml2
+, poppler
+, taglib
+, upower
+, totem-pl-parser
+}:
+
+stdenv.mkDerivation rec {
+  pname = "tracker-miners";
+  version = "2.2.2";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
+    sha256 = "0kk5xaajamb8jlm6cfdbc2m3axzr6bnph84m7697xmb0pkg8hdiw";
+  };
+
+  nativeBuildInputs = [
+    intltool
+    itstool
+    libxslt
+    meson
+    ninja
+    pkgconfig
+    vala
+    wrapGAppsHook
+  ];
+
+  # TODO: add libenca, libosinfo
+  buildInputs = [
+    bzip2
+    dbus
+    evolution-data-server
+    exempi
+    flac
+    giflib
+    glib
+    gexiv2
+    totem-pl-parser
+    tracker
+    gst_all_1.gst-plugins-base
+    gst_all_1.gstreamer
+    icu
+    json-glib
+    libcue
+    libexif
+    libgrss
+    libgsf
+    libgxps
+    libiptcdata
+    libjpeg
+    libosinfo
+    libpng
+    libseccomp
+    libsoup
+    libtiff
+    libuuid
+    libvorbis
+    libxml2
+    poppler
+    taglib
+    upower
+  ];
+
+  mesonFlags = [
+    # TODO: tests do not like our sandbox
+    "-Dfunctional_tests=false"
+    "-Ddbus_services=${placeholder "out"}/share/dbus-1/services"
+    "-Dsystemd_user_services=${placeholder "out"}/lib/systemd/user"
+  ];
+
+  patches = [
+    (substituteAll {
+      src = ./fix-paths.patch;
+      inherit tracker;
+    })
+    # https://bugzilla.gnome.org/show_bug.cgi?id=795576
+    (fetchurl {
+      url = https://bugzilla.gnome.org/attachment.cgi?id=371427;
+      sha256 = "187flswvzymjfxwfrrhizb1cvs780zm39aa3i2vwa5fbllr7kcpf";
+    })
+  ];
+
+  postInstall = ''
+    glib-compile-schemas "$out/share/glib-2.0/schemas"
+  '';
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+      attrPath = "gnome3.${pname}";
+      versionPolicy = "none";
+    };
+  };
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Projects/Tracker;
+    description = "Desktop-neutral user information store, search tool and indexer";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/tracker-miners/fix-paths.patch b/pkgs/development/libraries/tracker-miners/fix-paths.patch
new file mode 100644
index 00000000000..724c51cb56f
--- /dev/null
+++ b/pkgs/development/libraries/tracker-miners/fix-paths.patch
@@ -0,0 +1,20 @@
+--- a/src/libtracker-miners-common/tracker-domain-ontology.c
++++ b/src/libtracker-miners-common/tracker-domain-ontology.c
+@@ -323,7 +323,7 @@
+ 			goto end;
+ 		}
+ 	} else {
+-		path = g_build_filename (SHAREDIR, "tracker", "domain-ontologies",
++		path = g_build_filename ("@tracker@", "share", "tracker", "domain-ontologies",
+ 		                         DEFAULT_RULE, NULL);
+ 
+ 		if (!g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
+@@ -388,7 +388,7 @@
+ 	if (!priv->ontology_location) {
+ 		gchar *ontology_path;
+ 
+-		ontology_path = g_build_filename (SHAREDIR, "tracker", "ontologies",
++		ontology_path = g_build_filename ("@tracker@", "share", "tracker", "ontologies",
+ 		                                  priv->ontology_name, NULL);
+ 
+ 		if (!g_file_test (ontology_path, G_FILE_TEST_IS_DIR)) {
diff --git a/pkgs/development/libraries/tracker/default.nix b/pkgs/development/libraries/tracker/default.nix
new file mode 100644
index 00000000000..397184f798a
--- /dev/null
+++ b/pkgs/development/libraries/tracker/default.nix
@@ -0,0 +1,71 @@
+{ stdenv, fetchurl, intltool, meson, ninja, pkgconfig, gobject-introspection, python3
+, gtk-doc, docbook_xsl, docbook_xml_dtd_412, docbook_xml_dtd_43, glibcLocales
+, libxml2, upower, glib, wrapGAppsHook, vala, sqlite, libxslt, libstemmer
+, gnome3, icu, libuuid, networkmanager, libsoup, json-glib
+, substituteAll}:
+
+let
+  pname = "tracker";
+  version = "2.2.2";
+in stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+
+  outputs = [ "out" "dev" "devdoc" ];
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${name}.tar.xz";
+    sha256 = "1rp2c6k7ajcm553p9kpni87zgi9aplm3s01rl7pk575az5i399y6";
+  };
+
+  nativeBuildInputs = [
+    meson ninja vala pkgconfig intltool libxslt wrapGAppsHook gobject-introspection
+    gtk-doc docbook_xsl docbook_xml_dtd_412 docbook_xml_dtd_43 glibcLocales
+    python3 # for data-generators
+  ];
+
+  buildInputs = [
+    glib libxml2 sqlite upower icu networkmanager libsoup libuuid json-glib libstemmer
+  ];
+
+  LC_ALL = "en_US.UTF-8";
+
+  mesonFlags = [
+    "-Ddbus_services=${placeholder ''out''}/share/dbus-1/services"
+    "-Dsystemd_user_services=${placeholder ''out''}/lib/systemd/user"
+    # TODO: figure out wrapping unit tests, some of them fail on missing gsettings-desktop-schemas
+    "-Dfunctional_tests=false"
+    "-Ddocs=true"
+  ];
+
+  patches = [
+    (substituteAll {
+      src = ./fix-paths.patch;
+      gdbus = "${glib.bin}/bin/gdbus";
+    })
+  ];
+
+  postPatch = ''
+    patchShebangs utils/g-ir-merge/g-ir-merge
+    patchShebangs utils/data-generators/cc/generate
+  '';
+
+  postInstall = ''
+    glib-compile-schemas "$out/share/glib-2.0/schemas"
+  '';
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+      attrPath = "gnome3.${pname}";
+      versionPolicy = "none";
+    };
+  };
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.gnome.org/Projects/Tracker;
+    description = "Desktop-neutral user information store, search tool and indexer";
+    maintainers = gnome3.maintainers;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/development/libraries/tracker/fix-paths.patch b/pkgs/development/libraries/tracker/fix-paths.patch
new file mode 100644
index 00000000000..f5c13c3fcda
--- /dev/null
+++ b/pkgs/development/libraries/tracker/fix-paths.patch
@@ -0,0 +1,12 @@
+--- a/src/tracker-store/tracker-store.desktop.in
++++ b/src/tracker-store/tracker-store.desktop.in
+@@ -1,8 +1,8 @@
+ [Desktop Entry]
+ Name=Tracker Store
+ Comment=Metadata database store and lookup manager
+-Exec=gdbus call -e -d org.freedesktop.DBus -o /org/freedesktop/DBus -m org.freedesktop.DBus.StartServiceByName org.freedesktop.Tracker1 0
++Exec=@gdbus@ call -e -d org.freedesktop.DBus -o /org/freedesktop/DBus -m org.freedesktop.DBus.StartServiceByName org.freedesktop.Tracker1 0
+ Terminal=false
+ Type=Application
+ Categories=Utility;
+ X-GNOME-Autostart-enabled=true
diff --git a/pkgs/development/libraries/trompeloeil/default.nix b/pkgs/development/libraries/trompeloeil/default.nix
new file mode 100644
index 00000000000..552bd4c1c51
--- /dev/null
+++ b/pkgs/development/libraries/trompeloeil/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchFromGitHub, cmake }:
+
+stdenv.mkDerivation rec {
+  name = "trompeloeil-${version}";
+  version = "34";
+
+  src = fetchFromGitHub {
+    owner = "rollbear";
+    repo = "trompeloeil";
+    rev = "v${version}";
+    sha256 = "0mj3zni18kfm04jrqjaa1p6ii5q0dz6qdm3hi57z9lzygaxbdc97";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  meta = with stdenv.lib; {
+    description = "Header only C++14 mocking framework";
+    homepage = "https://github.com/rollbear/trompeloeil";
+    license = licenses.boost;
+    maintainers = [ maintainers.bjornfor ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/uid_wrapper/default.nix b/pkgs/development/libraries/uid_wrapper/default.nix
index bd9fb796247..8a79dab45b2 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.4";
+  name = "uid_wrapper-1.2.7";
 
   src = fetchurl {
     url = "mirror://samba/cwrap/${name}.tar.gz";
-    sha256 = "1yjhrm3rcyiykkrgpifmig117mzjxrms75kp8gpp8022f59zcq1w";
+    sha256 = "0mpzr70n24b0khri89hipxiqqay370m93syhnywrdmdxr3dhw2d8";
   };
 
   nativeBuildInputs = [ cmake pkgconfig ];
diff --git a/pkgs/development/libraries/umockdev/default.nix b/pkgs/development/libraries/umockdev/default.nix
index b6f1136ea2b..6a228556306 100644
--- a/pkgs/development/libraries/umockdev/default.nix
+++ b/pkgs/development/libraries/umockdev/default.nix
@@ -1,30 +1,48 @@
-{ stdenv, fetchFromGitHub, autoreconfHook, umockdev, gobject-introspection
-, pkgconfig, glib, systemd, libgudev, vala }:
+{ stdenv, fetchurl, fetchpatch, pkgconfig
+, gobject-introspection, glib, systemd, libgudev, vala
+, usbutils, which, python3 }:
 
 stdenv.mkDerivation rec {
   name = "umockdev-${version}";
-  version = "0.12.1";
+  version = "0.13.1";
 
   outputs = [ "bin" "out" "dev" "doc" ];
 
-  src = fetchFromGitHub {
-    owner  = "martinpitt";
-    repo   = "umockdev";
-    rev    = version;
-    sha256 = "0wnmz4jh04mvqzjnqvxrah969gg4x4v8d6ip61zc7jpbwnqb2fpg";
+  src = fetchurl {
+    url = "https://github.com/martinpitt/umockdev/releases/download/${version}/${name}.tar.xz";
+    sha256 = "197a169imiirgm73d9fn9234cx56agyw9d2f47h7f1d8s2d51lla";
   };
 
+  patches = [
+    ./fix-test-paths.patch
+    # https://github.com/NixOS/nixpkgs/commit/9960a2be9b32a6d868046c5bfa188b9a0dd66682#commitcomment-34734461
+    ./disable-failed-test.patch
+    # https://github.com/martinpitt/umockdev/pull/93
+    (fetchpatch {
+      url = "https://github.com/abbradar/umockdev/commit/ce22f893bf50de0b32760238a3e2cfb194db89e9.patch";
+      sha256 = "01q3qhs30x8hl23iigimsa2ikbiw8y8y0bpmh02mh1my87shpwnx";
+    })
+  ];
+
   # autoreconfHook complains if we try to build the documentation
   postPatch = ''
     echo 'EXTRA_DIST =' > docs/gtk-doc.make
   '';
 
+  preCheck = ''
+    patchShebangs tests/test-static-code
+  '';
+
   buildInputs = [ glib systemd libgudev ];
 
-  nativeBuildInputs = [ autoreconfHook pkgconfig vala gobject-introspection ];
+  nativeBuildInputs = [ pkgconfig vala gobject-introspection ];
+
+  checkInputs = [ python3 which usbutils ];
 
   enableParallelBuilding = true;
 
+  doCheck = true;
+
   meta = with stdenv.lib; {
     description = "Mock hardware devices for creating unit tests";
     license = licenses.lgpl2;
diff --git a/pkgs/development/libraries/umockdev/disable-failed-test.patch b/pkgs/development/libraries/umockdev/disable-failed-test.patch
new file mode 100644
index 00000000000..69e74dd38b8
--- /dev/null
+++ b/pkgs/development/libraries/umockdev/disable-failed-test.patch
@@ -0,0 +1,13 @@
+diff --git a/tests/test-umockdev-vala.vala b/tests/test-umockdev-vala.vala
+index 8b104b2..d9889b8 100644
+--- a/tests/test-umockdev-vala.vala
++++ b/tests/test-umockdev-vala.vala
+@@ -668,7 +668,7 @@ main (string[] args)
+ 
+   /* tests for mocking ioctls */
+   Test.add_func ("/umockdev-testbed-vala/usbfs_ioctl_static", t_usbfs_ioctl_static);
+-  Test.add_func ("/umockdev-testbed-vala/usbfs_ioctl_tree", t_usbfs_ioctl_tree);
++  /* Test.add_func ("/umockdev-testbed-vala/usbfs_ioctl_tree", t_usbfs_ioctl_tree); */
+   Test.add_func ("/umockdev-testbed-vala/usbfs_ioctl_tree_with_default_device", t_usbfs_ioctl_tree_with_default_device);
+   Test.add_func ("/umockdev-testbed-vala/usbfs_ioctl_tree_override_default_device", t_usbfs_ioctl_tree_override_default_device);
+   Test.add_func ("/umockdev-testbed-vala/usbfs_ioctl_tree_xz", t_usbfs_ioctl_tree_xz);
diff --git a/pkgs/development/libraries/umockdev/fix-test-paths.patch b/pkgs/development/libraries/umockdev/fix-test-paths.patch
new file mode 100644
index 00000000000..53015d66268
--- /dev/null
+++ b/pkgs/development/libraries/umockdev/fix-test-paths.patch
@@ -0,0 +1,12 @@
+diff -ru3 umockdev-0.13.1/tests/test-umockdev.c umockdev-0.13.1-new/tests/test-umockdev.c
+--- umockdev-0.13.1/tests/test-umockdev.c	2019-08-18 20:39:39.708262517 +0300
++++ umockdev-0.13.1-new/tests/test-umockdev.c	2019-08-18 21:04:27.688761503 +0300
+@@ -1084,7 +1084,7 @@
+ 
+     /* sys/ in other dir should not be trapped */
+     errno = 0;
+-    dirfd = open("/run", O_RDONLY | O_DIRECTORY);
++    dirfd = open("/tmp", O_RDONLY | O_DIRECTORY);
+     g_assert_cmpint(openat(dirfd, "sys", O_RDONLY), <, 0);
+     g_assert_cmpint(errno, ==, ENOENT);
+     g_assert_cmpint(openat64(dirfd, "sys", O_RDONLY), <, 0);
diff --git a/pkgs/development/libraries/unicap/default.nix b/pkgs/development/libraries/unicap/default.nix
index 1aa5e671702..a902b6f8451 100644
--- a/pkgs/development/libraries/unicap/default.nix
+++ b/pkgs/development/libraries/unicap/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, libusb, libraw1394, dcraw, intltool, perl, v4l_utils }:
+{ stdenv, fetchurl, libusb, libraw1394, dcraw, intltool, perl, v4l-utils }:
 
 stdenv.mkDerivation rec {
   name = "libunicap-${version}";
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
     sha256 = "05zcnnm4dfc6idihfi0fq5xka6x86zi89wip2ca19yz768sd33s9";
   };
 
-  buildInputs = [ libusb libraw1394 dcraw intltool perl v4l_utils ];
+  buildInputs = [ libusb libraw1394 dcraw intltool perl v4l-utils ];
 
   patches = [
     # Debian has a patch that fixes the build.
diff --git a/pkgs/development/libraries/unixODBCDrivers/default.nix b/pkgs/development/libraries/unixODBCDrivers/default.nix
index 7d4c6c7a299..7b72e12a66b 100644
--- a/pkgs/development/libraries/unixODBCDrivers/default.nix
+++ b/pkgs/development/libraries/unixODBCDrivers/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv, unixODBC, cmake, postgresql, mysql55, mariadb, sqlite, zlib, libxml2, dpkg, lib, openssl, kerberos, curl, libuuid, autoPatchelfHook }:
+{ fetchurl, stdenv, unixODBC, cmake, postgresql, mysql, mariadb, sqlite, zlib, libxml2, dpkg, lib, openssl, kerberos, curl, libuuid, autoPatchelfHook }:
 
 # I haven't done any parameter tweaking.. So the defaults provided here might be bad
 
@@ -67,7 +67,7 @@
     };
 
     nativeBuildInputs = [ cmake ];
-    buildInputs = [ unixODBC mysql55 ];
+    buildInputs = [ unixODBC mysql ];
 
     cmakeFlags = [ "-DWITH_UNIXODBC=1" ];
 
diff --git a/pkgs/development/libraries/utmps/default.nix b/pkgs/development/libraries/utmps/default.nix
index 81562659c0d..16d4a8fa40b 100644
--- a/pkgs/development/libraries/utmps/default.nix
+++ b/pkgs/development/libraries/utmps/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, skawarePackages }:
+{ skawarePackages }:
 
 with skawarePackages;
 
diff --git a/pkgs/development/libraries/vaapi-intel/default.nix b/pkgs/development/libraries/vaapi-intel/default.nix
index 14d49c3d0f0..640f50eb45b 100644
--- a/pkgs/development/libraries/vaapi-intel/default.nix
+++ b/pkgs/development/libraries/vaapi-intel/default.nix
@@ -47,6 +47,6 @@ stdenv.mkDerivation rec {
     license = licenses.mit;
     description = "Intel driver for the VAAPI library";
     platforms = platforms.unix;
-    maintainers = with maintainers; [ garbas ];
+    maintainers = with maintainers; [ ];
   };
 }
diff --git a/pkgs/development/libraries/vaapi-vdpau/default.nix b/pkgs/development/libraries/vaapi-vdpau/default.nix
index 07ca9d2e62e..e3fd7ad57e0 100644
--- a/pkgs/development/libraries/vaapi-vdpau/default.nix
+++ b/pkgs/development/libraries/vaapi-vdpau/default.nix
@@ -1,37 +1,40 @@
-{ 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";
-                                sha256 = "1n2cys59wyv8ylx9i5m3s6856mgx24hzcp45w1ahdfbzdv9wrfbl";
-                              });
-in
+{ stdenv, fetchurl, fetchpatch, libvdpau, libGLU_combined, libva, pkgconfig }:
+
 stdenv.mkDerivation rec {
-  name = "libva-vdpau-driver-0.7.4";
-  
+  pname = "libva-vdpau-driver";
+  version = "0.7.4";
+
   src = fetchurl {
-    url = "https://www.freedesktop.org/software/vaapi/releases/libva-vdpau-driver/${name}.tar.bz2";
+    url = "https://www.freedesktop.org/software/vaapi/releases/${pname}/${pname}-${version}.tar.bz2";
     sha256 = "1fcvgshzyc50yb8qqm6v6wn23ghimay23ci0p8sm8gxcy211jp0m";
   };
 
-  patches = [ ./glext85.patch
-              (fetchurl { url = "http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/x11-libs/libva-vdpau-driver/files/libva-vdpau-driver-0.7.4-VAEncH264VUIBufferType.patch?revision=1.1";
-                          name = "libva-vdpau-driver-0.7.4-VAEncH264VUIBufferType.patch";
-                          sha256 = "166svcav6axkrlb3i4rbf6dkwjnqdf69xw339az1f5yabj72pqqs";
-                        }) ];
+  patches = [
+    (fetchpatch { url = "https://src.fedoraproject.org/rpms/libva-vdpau-driver/raw/0ad71107e28a60ea453ac70e895cf64342bd58d0/f/libva-vdpau-driver-0.7.4-glext-85.patch";
+                  sha256 = "0f0v7cl7kna3jcfnxw48b9mfl0hpacw72df9vym96sa2206vqlb0"; })
+    (fetchpatch { url = "https://src.fedoraproject.org/rpms/libva-vdpau-driver/raw/0ad71107e28a60ea453ac70e895cf64342bd58d0/f/libva-vdpau-driver-0.7.4-drop-h264-api.patch";
+                  sha256 = "0q5w83jbf4qqmhwf54h906pzxgvhqv7g2vrkw7jzgnrxhhj9sj60"; })
+    (fetchpatch { url = "https://src.fedoraproject.org/rpms/libva-vdpau-driver/raw/0ad71107e28a60ea453ac70e895cf64342bd58d0/f/libva-vdpau-driver-0.7.4-fix_type.patch";
+                  sha256 = "0s5dk6aa4sm0iyicnf2fwfsrqbvr58nbp77mhjg5bvwlar7znqv7"; })
+    (fetchpatch { url = "https://src.fedoraproject.org/rpms/libva-vdpau-driver/raw/0ad71107e28a60ea453ac70e895cf64342bd58d0/f/sigfpe-crash.patch";
+                  sha256 = "15snqf60ib0xb3cnav5b2r55qv8lv2fa4p6jwxajh8wbvqpw0ibz"; })
+    (fetchpatch { url = "https://src.fedoraproject.org/rpms/libva-vdpau-driver/raw/0ad71107e28a60ea453ac70e895cf64342bd58d0/f/implement-vaquerysurfaceattributes.patch";
+                  sha256 = "1dapx3bqqblw6l2iqqw1yff6qifam8q4m2rq343kwb3dqhy2ymy5"; })
+    (fetchpatch { url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/x11-libs/libva-vdpau-driver/files/libva-vdpau-driver-0.7.4-include-linux-videodev2.h.patch";
+                  sha256 = "1m4is6lk580mppsx2mvdv1xifj6gvx724si4qynsm9qrdfdc9fby"; })
+  ];
 
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ libvdpau libGLU_combined libva ];
 
-  preConfigure = ''
-    patch -p0 < ${libvdpau08patch}  # use -p0 instead of -p1
+  postPatch = ''
     sed -i -e "s,LIBVA_DRIVERS_PATH=.*,LIBVA_DRIVERS_PATH=$out/lib/dri," configure
   '';
 
-
-  meta = {
-    homepage = https://cgit.freedesktop.org/vaapi/vdpau-driver/;
-    license = stdenv.lib.licenses.gpl2Plus;
+  meta = with stdenv.lib; {
+    homepage = "https://cgit.freedesktop.org/vaapi/vdpau-driver";
+    license = licenses.gpl2Plus;
     description = "VDPAU driver for the VAAPI library";
-    platforms = stdenv.lib.platforms.linux;
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/development/libraries/vaapi-vdpau/glext85.patch b/pkgs/development/libraries/vaapi-vdpau/glext85.patch
deleted file mode 100644
index 073b8cf1190..00000000000
--- a/pkgs/development/libraries/vaapi-vdpau/glext85.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-http://www.mail-archive.com/libva@lists.freedesktop.org/msg01457.html
-
-diff --git a/src/utils_glx.h b/src/utils_glx.h
-index 19d03e4..f270fba 100644
---- a/src/utils_glx.h
-+++ b/src/utils_glx.h
-@@ -42,6 +42,13 @@ typedef void (*PFNGLVDPAUMAPSURFACESNVPROC)(GLsizei numSurfaces, const GLvdpauSu
- typedef void (*PFNGLVDPAUUNMAPSURFACESNVPROC)(GLsizei numSurface, const GLvdpauSurfaceNV *surfaces);
- #endif
- 
-+#if GL_GLEXT_VERSION >= 85
-+/* XXX: PFNGLMULTITEXCOORD2FPROC got out of the GL_VERSION_1_3_DEPRECATED
-+   block and is not defined if GL_VERSION_1_3 is defined in <GL/gl.h>
-+   Redefine the type here as an interim solution */
-+typedef void (*PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t);
-+#endif
-+
- /* GLX_EXT_texture_from_pixmap */
- #if GLX_GLXEXT_VERSION < 18
- typedef void (*PFNGLXBINDTEXIMAGEEXTPROC)(Display *, GLXDrawable, int, const int *);
diff --git a/pkgs/development/libraries/vapoursynth/default.nix b/pkgs/development/libraries/vapoursynth/default.nix
index 7121b6fed02..65132806d88 100644
--- a/pkgs/development/libraries/vapoursynth/default.nix
+++ b/pkgs/development/libraries/vapoursynth/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, pkgconfig, autoreconfHook
+{ stdenv, fetchFromGitHub, pkgconfig, autoreconfHook, makeWrapper
 , zimg, libass, python3, libiconv
 , ApplicationServices, nasm
 , ocrSupport ?  false, tesseract ? null
@@ -11,17 +11,17 @@ assert imwriSupport -> imagemagick7 != null;
 with stdenv.lib;
 
 stdenv.mkDerivation rec {
-  name = "vapoursynth-${version}";
-  version = "R45.1";
+  pname = "vapoursynth";
+  version = "R46";
 
   src = fetchFromGitHub {
     owner  = "vapoursynth";
     repo   = "vapoursynth";
     rev    = version;
-    sha256 = "09fj4k75cksx1imivqfyr945swlr8k392kkdgzldwc4404qv82s6";
+    sha256 = "1xbwva12l68awplardf47ydlx904wifw468npaxa9cx9dvd5mv13";
   };
 
-  nativeBuildInputs = [ pkgconfig autoreconfHook nasm ];
+  nativeBuildInputs = [ pkgconfig autoreconfHook nasm makeWrapper ];
   buildInputs = [
     zimg libass
     (python3.withPackages (ps: with ps; [ sphinx cython ]))
@@ -37,12 +37,17 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
+  postInstall = ''
+    wrapProgram $out/bin/vspipe \
+        --prefix PYTHONPATH : $out/${python3.sitePackages}
+  '';
+
   meta = with stdenv.lib; {
     description = "A video processing framework with the future in mind";
     homepage    = http://www.vapoursynth.com/;
     license     = licenses.lgpl21;
     platforms   = platforms.x86_64;
-    maintainers = with maintainers; [ rnhmjoj ];
+    maintainers = with maintainers; [ rnhmjoj tadeokondrak ];
   };
 
 }
diff --git a/pkgs/development/libraries/vapoursynth/editor.nix b/pkgs/development/libraries/vapoursynth/editor.nix
new file mode 100644
index 00000000000..3853718c154
--- /dev/null
+++ b/pkgs/development/libraries/vapoursynth/editor.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchFromBitbucket, makeWrapper
+, python3, vapoursynth
+, qmake, qtbase, qtwebsockets
+}:
+
+stdenv.mkDerivation rec {
+  pname = "vapoursynth-editor";
+  version = "R19";
+
+  src = fetchFromBitbucket {
+    owner = "mystery_keeper";
+    repo = pname;
+    rev = stdenv.lib.toLower version;
+    sha256 = "1zlaynkkvizf128ln50yvzz3b764f5a0yryp6993s9fkwa7djb6n";
+  };
+
+  nativeBuildInputs = [ qmake makeWrapper ];
+  buildInputs = [ qtbase vapoursynth qtwebsockets ];
+
+  preConfigure = "cd pro";
+
+  installPhase = ''
+    cd ../build/release*
+    mkdir -p $out/bin
+    for bin in vsedit{,-job-server{,-watcher}}; do
+        mv $bin $out/bin
+
+        wrapProgram $out/bin/$bin \
+            --prefix PYTHONPATH : ${vapoursynth}/${python3.sitePackages} \
+            --prefix LD_LIBRARY_PATH : ${vapoursynth}/lib
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Cross-platform editor for VapourSynth scripts";
+    homepage = "https://bitbucket.org/mystery_keeper/vapoursynth-editor";
+    license = licenses.mit;
+    maintainers = with maintainers; [ tadeokondrak ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/virglrenderer/default.nix b/pkgs/development/libraries/virglrenderer/default.nix
index 4473100a9f2..72803e09f07 100644
--- a/pkgs/development/libraries/virglrenderer/default.nix
+++ b/pkgs/development/libraries/virglrenderer/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, libGLU, epoxy, libX11, libdrm, mesa_noglu }:
+{ stdenv, fetchurl, pkgconfig, libGLU, epoxy, libX11, libdrm, mesa }:
 
 
 stdenv.mkDerivation rec {
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
     sha256 = "041agg1d6i8hg250y30f08n3via0hs9rbijxdrfifb8ara805v0m";
   };
 
-  buildInputs = [ libGLU epoxy libX11 libdrm mesa_noglu ];
+  buildInputs = [ libGLU epoxy libX11 libdrm mesa ];
 
   nativeBuildInputs = [ pkgconfig ];
 
diff --git a/pkgs/development/libraries/volume-key/default.nix b/pkgs/development/libraries/volume-key/default.nix
index 32f816023e5..f6669f2f8fe 100644
--- a/pkgs/development/libraries/volume-key/default.nix
+++ b/pkgs/development/libraries/volume-key/default.nix
@@ -1,7 +1,6 @@
 { stdenv, fetchgit, autoreconfHook, pkgconfig, gettext, python3
 , ncurses, swig, glib, utillinux, cryptsetup, nss, gpgme
 , autoconf, automake, libtool
-, writeShellScriptBin
 , buildPackages
 }:
 
diff --git a/pkgs/development/libraries/vte/2.90.nix b/pkgs/development/libraries/vte/2.90.nix
index 4b2b74c5e1d..f4e8c128ccb 100644
--- a/pkgs/development/libraries/vte/2.90.nix
+++ b/pkgs/development/libraries/vte/2.90.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, intltool, pkgconfig, gnome3, glib, gtk3, ncurses, gobject-introspection }:
+{ stdenv, fetchurl, intltool, pkgconfig, glib, gtk3, ncurses, gobject-introspection }:
 
 stdenv.mkDerivation rec {
   versionMajor = "0.36";
diff --git a/pkgs/development/libraries/vtk/default.nix b/pkgs/development/libraries/vtk/default.nix
index 60fd6647429..c0b8fd7d167 100644
--- a/pkgs/development/libraries/vtk/default.nix
+++ b/pkgs/development/libraries/vtk/default.nix
@@ -2,7 +2,7 @@
 , qtLib ? null
 # Darwin support
 , Cocoa, CoreServices, DiskArbitration, IOKit, CFNetwork, Security, GLUT, OpenGL
-, ApplicationServices, CoreText, IOSurface, cf-private, ImageIO, xpc, libobjc }:
+, ApplicationServices, CoreText, IOSurface, ImageIO, xpc, libobjc }:
 
 with stdenv.lib;
 
@@ -20,13 +20,13 @@ stdenv.mkDerivation rec {
     sha256 = "0nm7xwwj7rnsxjdv2ssviys8nhci4n9iiiqm2y14s520hl2dsp1d";
   };
 
-  buildInputs =
-    if !stdenv.isDarwin
-    then [ cmake libGLU_combined libX11 xorgproto libXt ] ++ optional (qtLib != null) qtLib
-    else [ cmake qtLib xpc CoreServices DiskArbitration IOKit cf-private
-           CFNetwork Security ApplicationServices CoreText IOSurface ImageIO
-           OpenGL GLUT ];
-  propagatedBuildInputs = stdenv.lib.optionals stdenv.isDarwin [ Cocoa libobjc ];
+  buildInputs = [ cmake ]
+    ++ optional (qtLib != null) qtLib
+    ++ optionals stdenv.isLinux [ libGLU_combined libX11 xorgproto libXt ]
+    ++ optionals stdenv.isDarwin [ xpc Cocoa CoreServices DiskArbitration IOKit
+                                   CFNetwork Security ApplicationServices CoreText
+                                   IOSurface ImageIO OpenGL GLUT ];
+  propagatedBuildInputs = stdenv.lib.optionals stdenv.isDarwin [ libobjc ];
 
 
   preBuild = ''
diff --git a/pkgs/development/libraries/vulkan-loader/default.nix b/pkgs/development/libraries/vulkan-loader/default.nix
index 891ad373e02..a44e91e1bf5 100644
--- a/pkgs/development/libraries/vulkan-loader/default.nix
+++ b/pkgs/development/libraries/vulkan-loader/default.nix
@@ -21,8 +21,10 @@ stdenv.mkDerivation rec {
   buildInputs = [ cmake python3 xlibsWrapper libxcb libXrandr libXext wayland ];
   enableParallelBuilding = true;
 
+  patches = [ ./system-search-path.patch ];
+
   cmakeFlags = [
-    "-DFALLBACK_DATA_DIRS=${addOpenGLRunpath.driverLink}/share:/usr/local/share:/usr/share"
+    "-DSYSTEM_SEARCH_PATH=${addOpenGLRunpath.driverLink}/share"
     "-DVULKAN_HEADERS_INSTALL_DIR=${vulkan-headers}"
   ];
 
diff --git a/pkgs/development/libraries/vulkan-loader/system-search-path.patch b/pkgs/development/libraries/vulkan-loader/system-search-path.patch
new file mode 100644
index 00000000000..26f83e6d534
--- /dev/null
+++ b/pkgs/development/libraries/vulkan-loader/system-search-path.patch
@@ -0,0 +1,45 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 9ac5ce835..cbdb0ff56 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -88,6 +88,12 @@ if(UNIX)
+             STRING
+             "Search path to use when XDG_DATA_DIRS is unset or empty or the current process is SUID/SGID. Default is freedesktop compliant."
+         )
++    set(
++        SYSTEM_SEARCH_PATH ""
++        CACHE
++            STRING
++            "Search path to always use, after all other search paths."
++    )
+ endif()
+ 
+ if(UNIX AND NOT APPLE) # i.e.: Linux
+@@ -184,6 +190,7 @@ if(UNIX)
+     add_definitions(-DFALLBACK_CONFIG_DIRS="${FALLBACK_CONFIG_DIRS}")
+     add_definitions(-DFALLBACK_DATA_DIRS="${FALLBACK_DATA_DIRS}")
+     add_definitions(-DSYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}")
++    add_definitions(-DSYSTEM_SEARCH_PATH="${SYSTEM_SEARCH_PATH}")
+ 
+     # Make sure /etc is searched by the loader
+     if(NOT (CMAKE_INSTALL_FULL_SYSCONFDIR STREQUAL "/etc"))
+diff --git a/loader/loader.c b/loader/loader.c
+index 0d3b5a947..abe357004 100644
+--- a/loader/loader.c
++++ b/loader/loader.c
+@@ -3688,6 +3688,7 @@ static VkResult ReadDataFilesInSearchPaths(const struct loader_instance *inst, e
+                 search_path_size += DetermineDataFilePathSize(xdgdatahome, rel_size);
+                 search_path_size += DetermineDataFilePathSize(home_root, rel_size);
+             }
++            search_path_size += DetermineDataFilePathSize(SYSTEM_SEARCH_PATH, rel_size);
+ #endif
+         }
+     }
+@@ -3737,6 +3738,7 @@ static VkResult ReadDataFilesInSearchPaths(const struct loader_instance *inst, e
+                 CopyDataFilePath(xdgdatahome, relative_location, rel_size, &cur_path_ptr);
+                 CopyDataFilePath(home_root, relative_location, rel_size, &cur_path_ptr);
+             }
++            CopyDataFilePath(SYSTEM_SEARCH_PATH, relative_location, rel_size, &cur_path_ptr);
+         }
+ 
+         // Remove the last path separator
diff --git a/pkgs/development/libraries/wasilibc/default.nix b/pkgs/development/libraries/wasilibc/default.nix
index 229d67b81ed..fb8c0e0fa21 100644
--- a/pkgs/development/libraries/wasilibc/default.nix
+++ b/pkgs/development/libraries/wasilibc/default.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchFromGitHub, lib }:
 
 stdenv.mkDerivation {
-  name = "wasilibc-20190413";
+  name = "wasilibc-20190712";
   src = fetchFromGitHub {
     owner = "CraneStation";
-    repo = "wasi-sysroot";
-    rev = "079d7bda78bc0ad8f69c1594444b54786545ce57";
-    sha256 = "09s906bc9485wzkgibnpfh0mii7jkldzr1a6g8k7ch0si8rshi5r";
+    repo = "wasi-libc";
+    rev = "8df0d4cd6a559b58d4a34b738a5a766b567448cf";
+    sha256 = "1n4gvgzacpagar2mx8g9950q0brnhwz7jg2q44sa5mnjmlnkiqhh";
   };
   makeFlags = [
     "WASM_CC=${stdenv.cc.targetPrefix}cc"
diff --git a/pkgs/development/libraries/wavpack/default.nix b/pkgs/development/libraries/wavpack/default.nix
index 9eb3254001d..8af33c10319 100644
--- a/pkgs/development/libraries/wavpack/default.nix
+++ b/pkgs/development/libraries/wavpack/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, libiconv }:
+{ stdenv, fetchurl, libiconv, fetchpatch }:
 
 stdenv.mkDerivation rec {
   name = "wavpack-${version}";
@@ -13,6 +13,64 @@ stdenv.mkDerivation rec {
     sha256 = "0i19c6krc0p9krwrqy9s5xahaafigqzxcn31piidmlaqadyn4f8r";
   };
 
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/dbry/WavPack/commit/26cb47f99d481ad9b93eeff80d26e6b63bbd7e15.patch";
+      name = "CVE-2018-10536-CVE-2018-10537.patch";
+      sha256 = "0s0fyycd4x7pw4vl1yp2vp4zrlk04j85idvnxz5h96fj6196anw6";
+    })
+    (fetchpatch {
+      url = "https://github.com/dbry/WavPack/commit/6f8bb34c2993a48ab9afbe353e6d0cff7c8d821d.patch";
+      name = "CVE-2018-10538-CVE-2018-10539-CVE-2018-10540.patch";
+      sha256 = "03qzmaq9mwiqbzrx1lvkgkhz3cjv7dky1b4lka3d5q2rwdlyw5qk";
+    })
+    (fetchpatch {
+      url = "https://github.com/dbry/WavPack/commit/d5bf76b5a88d044a1be1d5656698e3ba737167e5.patch";
+      name = "CVE-2018-6767.patch";
+      sha256 = "158c60i188kbxl0hzb7g74g21pknz7fk429vnbbx9zk1mlyyyl5b";
+    })
+    (fetchpatch {
+      url = "https://github.com/dbry/WavPack/commit/bf408e95f43fafdcef42c3f5f9c9d0e6ab0331b9.patch";
+      name = "CVE-2019-11498-1.patch";
+      sha256 = "161dw759v1lzbhj7daw2gbmcji8s0njpa65xmqhqw73bwpzb3xkd";
+    })
+    (fetchpatch {
+      url = "https://github.com/dbry/WavPack/commit/cd353bccafb1274a525c3536aaff8c48c3a33aa0.patch";
+      name = "CVE-2019-11498-2.patch";
+      sha256 = "120sb1iqkq2gadh0qydqvca4vwx31zb7gk1d0nm0y5agav2ai0dk";
+    })
+    (fetchpatch {
+      url = "https://github.com/dbry/WavPack/commit/4c0faba32fddbd0745cbfaf1e1aeb3da5d35b9fc.patch";
+      name = "CVE-2019-11498-3.patch";
+      sha256 = "12744yn1035mf7wzgqrkyadw5mwqf9v34ckj2m5sirk97k47k0wa";
+    })
+    (fetchpatch {
+      url = "https://github.com/dbry/WavPack/commit/bc6cba3f552c44565f7f1e66dc1580189addb2b4.patch";
+      name = "CVE-2019-11498-4.patch";
+      sha256 = "0qdw071b14hmxkjw6kn83d8hzq89l3hqh64pl1f1wb8m51w5xfg7";
+    })
+    (fetchpatch {
+      url = "https://github.com/dbry/WavPack/commit/070ef6f138956d9ea9612e69586152339dbefe51.patch";
+      name = "CVE-2018-19840.patch";
+      sha256 = "08y27py8hnki74ad8wbknnd36vj5pzzcm2vk3ngcbsjnj7x5mffz";
+    })
+    (fetchpatch {
+      url = "https://github.com/dbry/WavPack/commit/bba5389dc598a92bdf2b297c3ea34620b6679b5b.patch";
+      name = "CVE-2018-19841.patch";
+      sha256 = "08gx5xx51bi86cqqy7cv1d25k669a7wnkksasjspphwkpwkcxymy";
+    })
+    (fetchpatch {
+      url = "https://github.com/dbry/WavPack/commit/f68a9555b548306c5b1ee45199ccdc4a16a6101b.patch";
+      name = "CVE-2019-1010317.patch";
+      sha256 = "0v748nd9408v6ah37cn8wr0k0m0ny1g884q8q92j1dhwad69kfid";
+    })
+    (fetchpatch {
+      url = "https://github.com/dbry/WavPack/commit/33a0025d1d63ccd05d9dbaa6923d52b1446a62fe.patch";
+      name = "CVE-2019-1010319.patch";
+      sha256 = "011sqdgpykilaj2c4ns298z7aad03yprpva0dqr39nx88ji6jnrb";
+    })
+  ];
+
   meta = with stdenv.lib; {
     description = "Hybrid audio compression format";
     homepage    = http://www.wavpack.com/;
diff --git a/pkgs/development/libraries/wcslib/default.nix b/pkgs/development/libraries/wcslib/default.nix
index 187eed6ae83..5f9015fa960 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 = "6.2";
+  version = "6.4";
   name = "wcslib-${version}";
 
   buildInputs = [ flex ];
 
   src = fetchurl {
     url = "ftp://ftp.atnf.csiro.au/pub/software/wcslib/${name}.tar.bz2";
-    sha256 ="01fqckazhbfqqhyr0wd9vcks1m2afmsh83l981alxg2r54jgwkdv";
+    sha256 ="003h23m6d5wcs29v2vbnl63f3z35k5x70lpsqlz5c9bp1bvizh8k";
   };
 
   prePatch = ''
diff --git a/pkgs/development/libraries/webkitgtk/default.nix b/pkgs/development/libraries/webkitgtk/default.nix
index 91848ce1fb6..927301589b4 100644
--- a/pkgs/development/libraries/webkitgtk/default.nix
+++ b/pkgs/development/libraries/webkitgtk/default.nix
@@ -15,7 +15,7 @@ assert stdenv.isDarwin -> !enableGtk2Plugins;
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "webkitgtk-${version}";
-  version = "2.24.2";
+  version = "2.24.3";
 
   meta = {
     description = "Web content rendering engine, GTK+ port";
@@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "https://webkitgtk.org/releases/${name}.tar.xz";
-    sha256 = "071jnjvjq6wsxx1jh4ql3j53h1nhphs5ga67fa5i9xjvs3qb3701";
+    sha256 = "0lbcrw5axwrbrajxq7fqywfyh0djqi23ynzb5wi5ghw2grnp83cl";
   };
 
   patches = optionals stdenv.isDarwin [
diff --git a/pkgs/development/libraries/wiredtiger/default.nix b/pkgs/development/libraries/wiredtiger/default.nix
index c45f521dcbb..bccf4f69e9d 100644
--- a/pkgs/development/libraries/wiredtiger/default.nix
+++ b/pkgs/development/libraries/wiredtiger/default.nix
@@ -26,13 +26,13 @@ let
 in
 stdenv.mkDerivation rec {
   name = "wiredtiger-${version}";
-  version = "2.6.1";
+  version = "3.2.0";
 
   src = fetchFromGitHub {
     repo = "wiredtiger";
     owner = "wiredtiger";
     rev = version;
-    sha256 = "1nj319w3hvkq3za2dz9m0p1w683gycdb392v1jb910bhzpsq30pd";
+    sha256 = "1s27l51p2p3kbdjmccvlg43i7zx84hhchs3779w9giab4nvd0y19";
   };
 
   nativeBuildInputs = [ automake autoconf libtool ];
@@ -58,17 +58,10 @@ stdenv.mkDerivation rec {
     ./autogen.sh
   '';
 
-  prePatch = stdenv.lib.optionalString stdenv.isDarwin ''
-    substituteInPlace api/leveldb/leveldb_wt.h --replace \
-      '#include "wiredtiger.h"' \
-      ''$'#include "wiredtiger.h"\n#include "pthread.h"'
-  '';
-
   meta = {
     homepage = http://wiredtiger.com/;
     description = "";
     license = licenses.gpl2;
     platforms = intersectLists platforms.unix platforms.x86_64;
-    broken = true; # Broken by f689a6d1c6796c4a4f116ffec6c4624379e04bc9.
   };
 }
diff --git a/pkgs/development/libraries/wlc/default.nix b/pkgs/development/libraries/wlc/default.nix
deleted file mode 100644
index 572adfeb0bb..00000000000
--- a/pkgs/development/libraries/wlc/default.nix
+++ /dev/null
@@ -1,39 +0,0 @@
-{ stdenv, fetchFromGitHub, cmake, pkgconfig
-, wayland, pixman, libxkbcommon, libinput, xcbutilwm, xcbutilimage, libGL
-, libX11, dbus, wayland-protocols, libdrm, mesa_noglu
-, libpthreadstubs, libXdmcp, libXext, libXfixes
-, withOptionalPackages ? true, zlib, valgrind, doxygen
-}:
-
-stdenv.mkDerivation rec {
-  name = "wlc-${version}";
-  version = "0.0.11";
-
-  src = fetchFromGitHub {
-    owner = "Cloudef";
-    repo = "wlc";
-    rev = "v${version}";
-    fetchSubmodules = true;
-    sha256 = "1qnak907gjd35hq4b0rrhgb7kz5iwnirh8yk372yzxpgk7dq0gz9";
-  };
-
-  nativeBuildInputs = [ cmake pkgconfig ];
-
-  buildInputs = [
-    wayland pixman libxkbcommon libinput xcbutilwm xcbutilimage libGL
-    libX11 libXfixes dbus wayland-protocols
-    libpthreadstubs libXdmcp libXext libdrm mesa_noglu ]
-    ++ stdenv.lib.optionals withOptionalPackages [ zlib valgrind doxygen ];
-
-  doCheck = true;
-  checkTarget = "test";
-  enableParallelBuilding = true;
-
-  meta = with stdenv.lib; {
-    description = "A library for making a simple Wayland compositor";
-    homepage    = https://github.com/Cloudef/wlc;
-    license     = licenses.mit;
-    platforms   = platforms.linux;
-    maintainers = with maintainers; [ primeos ]; # Trying to keep it up-to-date.
-  };
-}
diff --git a/pkgs/development/libraries/wlroots/default.nix b/pkgs/development/libraries/wlroots/default.nix
index 47e1c37492c..b85616842ea 100644
--- a/pkgs/development/libraries/wlroots/default.nix
+++ b/pkgs/development/libraries/wlroots/default.nix
@@ -1,7 +1,7 @@
-{ stdenv, fetchFromGitHub, fetchpatch, meson, ninja, pkgconfig
+{ stdenv, fetchFromGitHub, meson, ninja, pkgconfig
 , wayland, libGL, wayland-protocols, libinput, libxkbcommon, pixman
-, xcbutilwm, libX11, libcap, xcbutilimage, xcbutilerrors, mesa_noglu
-, libpng, ffmpeg_4
+, xcbutilwm, libX11, libcap, xcbutilimage, xcbutilerrors, mesa
+, libpng, ffmpeg_4, freerdp
 }:
 
 stdenv.mkDerivation rec {
@@ -23,8 +23,8 @@ stdenv.mkDerivation rec {
 
   buildInputs = [
     wayland libGL wayland-protocols libinput libxkbcommon pixman
-    xcbutilwm libX11 libcap xcbutilimage xcbutilerrors mesa_noglu
-    libpng ffmpeg_4
+    xcbutilwm libX11 libcap xcbutilimage xcbutilerrors mesa
+    libpng ffmpeg_4 freerdp
   ];
 
   mesonFlags = [
diff --git a/pkgs/development/libraries/wolfssl/default.nix b/pkgs/development/libraries/wolfssl/default.nix
index e7feaabc739..549e492e944 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 = "4.0.0";
+  version = "4.1.0";
 
   src = fetchFromGitHub {
     owner = "wolfSSL";
     repo = "wolfssl";
     rev = "v${version}-stable";
-    sha256 = "155lmgz81ky0x04c8m2yzlsm58i9jk6hiw1ajc3wizvbpczbca57";
+    sha256 = "16d1dzbdx6x7czbxf6i1rlb5mv59yzzpnha7qgwab3yq62rlsgw3";
   };
 
   configureFlags = [ "--enable-all" ];
diff --git a/pkgs/development/libraries/wt/default.nix b/pkgs/development/libraries/wt/default.nix
index e1c339d1e0f..ba77189b2a5 100644
--- a/pkgs/development/libraries/wt/default.nix
+++ b/pkgs/development/libraries/wt/default.nix
@@ -34,7 +34,7 @@ let
       ];
 
       meta = with stdenv.lib; {
-        homepage = https://www.webtoolkit.eu/wt;
+        homepage = "https://www.webtoolkit.eu/wt";
         description = "C++ library for developing web applications";
         platforms = platforms.linux;
         license = licenses.gpl2;
@@ -43,12 +43,12 @@ let
     };
 in {
   wt3 = generic {
-    version = "3.3.11";
-    sha256 = "1s1bwg3s7brnspr9ya1vg5mr29dbvhf05s606fiv409b7ladqvxq";
+    version = "3.4.0";
+    sha256 = "0y0b2h9jf5cg1gdh48dj32pj5nsvipab1cgygncxf98c46ikhysg";
   };
 
   wt4 = generic {
-    version = "4.0.5";
-    sha256 = "1gn8f30mjmn9aaxdazk49wijz37nglfww15ydrjiyhl6v5xhsjdv";
+    version = "4.1.0";
+    sha256 = "1a9nl5gs8m8pssf2l3z6kbl2rc9fw5ad7lfslw5yr3gzi0zqn05x";
   };
 }
diff --git a/pkgs/development/libraries/wxSVG/default.nix b/pkgs/development/libraries/wxSVG/default.nix
index b18dd23ec82..ce8e3f0f677 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.17";
+  version = "1.5.20";
 
   src = fetchurl {
     url = "mirror://sourceforge/project/wxsvg/wxsvg/${version}/${srcName}.tar.bz2";
-    sha256 = "154d9ad91ff0g9ah2k8f22yhlfkss307anyliyf3111kghil929z";
+    sha256 = "17j5j61l5mv7x0ncsm1kv3k5mmjqyxfpddjn7j84wdgrj62xldhm";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/development/libraries/wxwidgets/2.8/default.nix b/pkgs/development/libraries/wxwidgets/2.8/default.nix
index 1b08bb090b4..b952e8b1267 100644
--- a/pkgs/development/libraries/wxwidgets/2.8/default.nix
+++ b/pkgs/development/libraries/wxwidgets/2.8/default.nix
@@ -1,7 +1,8 @@
 { stdenv, fetchurl, pkgconfig, gtk2, libXinerama, libSM, libXxf86vm, xorgproto
 , gstreamer, gst-plugins-base, GConf, libX11, cairo
-, libGLSupported
-, withMesa ? libGLSupported, libGLU ? null, libGL ? null
+, libGLSupported ? stdenv.lib.elem stdenv.hostPlatform.system stdenv.lib.platforms.mesaPlatforms
+, withMesa ? stdenv.lib.elem stdenv.hostPlatform.system stdenv.lib.platforms.mesaPlatforms
+, libGLU ? null, libGL ? null
 , compat24 ? false, compat26 ? true, unicode ? true,
 }:
 
diff --git a/pkgs/development/libraries/wxwidgets/2.9/default.nix b/pkgs/development/libraries/wxwidgets/2.9/default.nix
index 18e0cebec85..369d011f9b3 100644
--- a/pkgs/development/libraries/wxwidgets/2.9/default.nix
+++ b/pkgs/development/libraries/wxwidgets/2.9/default.nix
@@ -1,7 +1,8 @@
 { stdenv, fetchurl, pkgconfig, gtk2, libXinerama, libSM, libXxf86vm, xorgproto
 , gstreamer, gst-plugins-base, GConf, setfile
-, libGLSupported
-, withMesa ? libGLSupported, libGLU ? null, libGL ? null
+, libGLSupported ? stdenv.lib.elem stdenv.hostPlatform.system stdenv.lib.platforms.mesaPlatforms
+, withMesa ? stdenv.lib.elem stdenv.hostPlatform.system stdenv.lib.platforms.mesaPlatforms
+, libGLU ? null, libGL ? null
 , compat24 ? false, compat26 ? true, unicode ? true
 , Carbon ? null, Cocoa ? null, Kernel ? null, QuickTime ? null, AGL ? null
 }:
diff --git a/pkgs/development/libraries/wxwidgets/3.0/default.nix b/pkgs/development/libraries/wxwidgets/3.0/default.nix
index a89f132b832..b33b0b15331 100644
--- a/pkgs/development/libraries/wxwidgets/3.0/default.nix
+++ b/pkgs/development/libraries/wxwidgets/3.0/default.nix
@@ -1,8 +1,9 @@
-{ stdenv, fetchFromGitHub, fetchurl, fetchpatch, pkgconfig
+{ stdenv, fetchFromGitHub, fetchurl, pkgconfig
 , gtk2, gtk3, libXinerama, libSM, libXxf86vm
 , xorgproto, gstreamer, gst-plugins-base, GConf, setfile
-, libGLSupported
-, withMesa ? libGLSupported, libGLU ? null, libGL ? null
+, libGLSupported ? stdenv.lib.elem stdenv.hostPlatform.system stdenv.lib.platforms.mesaPlatforms
+, withMesa ? stdenv.lib.elem stdenv.hostPlatform.system stdenv.lib.platforms.mesaPlatforms
+, libGLU ? null, libGL ? null
 , compat24 ? false, compat26 ? true, unicode ? true
 , withGtk2 ? true
 , withWebKit ? false, webkitgtk24x-gtk2 ? null, webkitgtk ? null
diff --git a/pkgs/development/libraries/wxwidgets/3.0/mac.nix b/pkgs/development/libraries/wxwidgets/3.0/mac.nix
index 6e559cfb6a9..cbe8bd8ac5e 100644
--- a/pkgs/development/libraries/wxwidgets/3.0/mac.nix
+++ b/pkgs/development/libraries/wxwidgets/3.0/mac.nix
@@ -1,6 +1,6 @@
-{ stdenv, fetchzip, fetchpatch, expat, libiconv, libjpeg, libpng, libtiff, zlib
+{ stdenv, fetchzip, expat, libiconv, libjpeg, libpng, libtiff, zlib
 # darwin only attributes
-, cf-private, derez, rez, setfile
+, derez, rez, setfile
 , AGL, Cocoa, Kernel
 }:
 
@@ -16,15 +16,9 @@ stdenv.mkDerivation rec {
   buildInputs = [
     expat libiconv libjpeg libpng libtiff zlib
     derez rez setfile
-    Cocoa Kernel
-
-    # Needed for CFURLGetFSRef, etc. which have deen deprecated
-    # since 10.9 and are not part of swift-corelibs CoreFoundation.
-    cf-private
+    AGL Cocoa Kernel
   ];
 
-  propagatedBuildInputs = [ AGL ];
-
   postPatch = ''
     substituteInPlace configure --replace "-framework System" -lSystem
   '';
@@ -71,6 +65,5 @@ stdenv.mkDerivation rec {
     homepage = https://www.wxwidgets.org/;
     description = "a C++ library that lets developers create applications for Windows, macOS, Linux and other platforms with a single code base";
     longDescription = "wxWidgets gives you a single, easy-to-use API for writing GUI applications on multiple platforms that still utilize the native platform's controls and utilities. Link with the appropriate library for your platform and compiler, and your application will adopt the look and feel appropriate to that platform. On top of great GUI functionality, wxWidgets gives you: online help, network programming, streams, clipboard and drag and drop, multithreading, image loading and saving in a variety of popular formats, database support, HTML viewing and printing, and much more.";
-    broken = true;
   };
 }
diff --git a/pkgs/development/libraries/wxwidgets/3.1/default.nix b/pkgs/development/libraries/wxwidgets/3.1/default.nix
index 4b410a307bb..cee967ef2aa 100644
--- a/pkgs/development/libraries/wxwidgets/3.1/default.nix
+++ b/pkgs/development/libraries/wxwidgets/3.1/default.nix
@@ -1,16 +1,94 @@
-{ stdenv, fetchFromGitHub
-, wxGTK30
+{ stdenv, fetchFromGitHub, fetchurl, pkgconfig
+, gtk2, gtk3, libXinerama, libSM, libXxf86vm
+, xorgproto, gstreamer, gst-plugins-base, GConf, setfile
+, libGLSupported ? stdenv.lib.elem stdenv.hostPlatform.system stdenv.lib.platforms.mesaPlatforms
+, withMesa ? libGLSupported, libGLU ? null, libGL ? null
+, compat28 ? false, compat30 ? true, unicode ? true
+, withGtk2 ? true
+, withWebKit ? false, webkitgtk24x-gtk2 ? null, webkitgtk ? null
+, AGL ? null, Carbon ? null, Cocoa ? null, Kernel ? null, QTKit ? null
 }:
 
+
+assert withMesa -> libGLU != null && libGL != null;
+assert withWebKit -> (if withGtk2 then webkitgtk24x-gtk2 else webkitgtk) != null;
+
 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
+stdenv.mkDerivation rec {
+  version = "3.1.2";
+  name = "wxwidgets-${version}";
+
+  src = fetchFromGitHub {
+    owner = "wxWidgets";
+    repo = "wxWidgets";
+    rev = "v${version}";
+    sha256 = "0gfdhb7xq5vzasm7s1di39nchv42zsp0dmn4v6knzb7mgsb107wb";
+  };
+
+  buildInputs =
+    [ (if withGtk2 then gtk2 else gtk3) libXinerama libSM libXxf86vm xorgproto gstreamer
+      gst-plugins-base GConf ]
+    ++ optional withMesa libGLU
+    ++ optional withWebKit (if withGtk2 then webkitgtk24x-gtk2 else webkitgtk)
+    ++ optionals stdenv.isDarwin [ setfile Carbon Cocoa Kernel QTKit ];
+
+  nativeBuildInputs = [ pkgconfig ];
+
+  propagatedBuildInputs = optional stdenv.isDarwin AGL;
+
+  patches = [
+    (fetchurl { # https://trac.wxwidgets.org/ticket/17942
+      url = "https://trac.wxwidgets.org/raw-attachment/ticket/17942/"
+          + "fix_assertion_using_hide_in_destroy.diff";
+      sha256 = "009y3dav79wiig789vkkc07g1qdqprg1544lih79199kb1h64lvy";
+    })
+  ];
+
+  configureFlags =
+    [ "--disable-precomp-headers" "--enable-mediactrl"
+      (if compat28 then "--enable-compat28" else "--disable-compat28")
+      (if compat30 then "--enable-compat30" else "--disable-compat30") ]
+    ++ optional unicode "--enable-unicode"
+    ++ optional withMesa "--with-opengl"
+    ++ optionals stdenv.isDarwin
+      # allow building on 64-bit
+      [ "--with-cocoa" "--enable-universal-binaries" "--with-macosx-version-min=10.7" ]
+    ++ optionals withWebKit
+      ["--enable-webview" "--enable-webviewwebkit"];
+
+  SEARCH_LIB = "${libGLU.out}/lib ${libGL.out}/lib ";
+
+  preConfigure = "
+    substituteInPlace configure --replace 'SEARCH_INCLUDE=' 'DUMMY_SEARCH_INCLUDE='
+    substituteInPlace configure --replace 'SEARCH_LIB=' 'DUMMY_SEARCH_LIB='
+    substituteInPlace configure --replace /usr /no-such-path
+  " + optionalString stdenv.isDarwin ''
+    substituteInPlace configure --replace \
+      'ac_cv_prog_SETFILE="/Developer/Tools/SetFile"' \
+      'ac_cv_prog_SETFILE="${setfile}/bin/SetFile"'
+    substituteInPlace configure --replace \
+      "-framework System" \
+      -lSystem
+  '';
+
+  postInstall = "
+    (cd $out/include && ln -s wx-*/* .)
+  ";
+
+  passthru = {
+    inherit compat28 compat30 unicode;
+    gtk = if withGtk2 then gtk2 else gtk3;
+  };
+
+  enableParallelBuilding = true;
+
+  meta = {
+    platforms = with platforms; darwin ++ linux;
+    license = licenses.wxWindows;
+    homepage = https://www.wxwidgets.org/;
+    description = "a C++ library that lets developers create applications for Windows, macOS, Linux and other platforms with a single code base";
+    longDescription = "wxWidgets gives you a single, easy-to-use API for writing GUI applications on multiple platforms that still utilize the native platform's controls and utilities. Link with the appropriate library for your platform and compiler, and your application will adopt the look and feel appropriate to that platform. On top of great GUI functionality, wxWidgets gives you: online help, network programming, streams, clipboard and drag and drop, multithreading, image loading and saving in a variety of popular formats, database support, HTML viewing and printing, and much more.";
+    badPlatforms = [ "x86_64-darwin" ];
+  };
+}
diff --git a/pkgs/development/libraries/x265/default.nix b/pkgs/development/libraries/x265/default.nix
index 398c309d938..f2189cb014e 100644
--- a/pkgs/development/libraries/x265/default.nix
+++ b/pkgs/development/libraries/x265/default.nix
@@ -17,14 +17,14 @@ in
 
 stdenv.mkDerivation rec {
   name = "x265-${version}";
-  version = "3.0";
+  version = "3.1.1";
 
   src = fetchurl {
     urls = [
       "https://get.videolan.org/x265/x265_${version}.tar.gz"
       "ftp://ftp.videolan.org/pub/videolan/x265/x265_${version}.tar.gz"
     ];
-    sha256 = "0qh65wdpasrspkm1y0dlfa123myax568yi0sas0lmg5b1hkgrff5";
+    sha256 = "1l68lgdbsi4wjz5vad98ggx7mf92rnvzlq34m6w0a08ark3h0yc2";
   };
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/xapian/default.nix b/pkgs/development/libraries/xapian/default.nix
index c10dfdaa961..271c7adf3d9 100644
--- a/pkgs/development/libraries/xapian/default.nix
+++ b/pkgs/development/libraries/xapian/default.nix
@@ -38,5 +38,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 = generic "1.4.11" "01xwqljnp5afjf9097lyfbqc6x5bcqszfdkn9l1j86imwbrv45lz";
+  xapian_1_4 = generic "1.4.12" "0z5c1y9vp519h2x2igjq39v6j615nppry0wasd0xn4hphgd3d2jg";
 }
diff --git a/pkgs/development/libraries/xdg-desktop-portal-gtk/default.nix b/pkgs/development/libraries/xdg-desktop-portal-gtk/default.nix
index 780b7d630cb..9b031602371 100644
--- a/pkgs/development/libraries/xdg-desktop-portal-gtk/default.nix
+++ b/pkgs/development/libraries/xdg-desktop-portal-gtk/default.nix
@@ -1,18 +1,39 @@
-{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, libxml2, xdg-desktop-portal, gtk3, glib, wrapGAppsHook, gnome3, gsettings-desktop-schemas }:
+{ stdenv
+, fetchFromGitHub
+, autoreconfHook
+, pkgconfig
+, libxml2
+, xdg-desktop-portal
+, gtk3
+, glib
+, wrapGAppsHook
+, gsettings-desktop-schemas
+}:
 
 stdenv.mkDerivation rec {
   pname = "xdg-desktop-portal-gtk";
-  version = "1.2.0";
+  version = "1.4.0";
 
   src = fetchFromGitHub {
     owner = "flatpak";
     repo = pname;
     rev = version;
-    sha256 = "1vgnsahljzrjcdjzv1dxhp2rf709pnf8595an82llnylwa8rdp1j";
+    sha256 = "1zryfg6232vz1pmv0zqcxvl4clnbb15kjf55b24cimkcnidklbap";
   };
 
-  nativeBuildInputs = [ autoreconfHook pkgconfig libxml2 xdg-desktop-portal wrapGAppsHook ];
-  buildInputs = [ glib gtk3 gsettings-desktop-schemas ];
+  nativeBuildInputs = [
+    autoreconfHook
+    libxml2
+    pkgconfig
+    wrapGAppsHook
+    xdg-desktop-portal
+  ];
+
+  buildInputs = [
+    glib
+    gsettings-desktop-schemas
+    gtk3
+  ];
 
   meta = with stdenv.lib; {
     description = "Desktop integration portals for sandboxed apps";
diff --git a/pkgs/development/libraries/xdg-desktop-portal/default.nix b/pkgs/development/libraries/xdg-desktop-portal/default.nix
index 3f02946c770..4be7bd1474c 100644
--- a/pkgs/development/libraries/xdg-desktop-portal/default.nix
+++ b/pkgs/development/libraries/xdg-desktop-portal/default.nix
@@ -1,8 +1,8 @@
-{ stdenv, fetchFromGitHub, substituteAll, autoreconfHook, pkgconfig, libxml2, glib, pipewire, fontconfig, flatpak, gsettings-desktop-schemas, acl, dbus, fuse, geoclue2, wrapGAppsHook }:
+{ stdenv, fetchFromGitHub, substituteAll, autoreconfHook, pkgconfig, libxml2, glib, pipewire, fontconfig, flatpak, gsettings-desktop-schemas, acl, dbus, fuse, geoclue2, json-glib, wrapGAppsHook }:
 
 stdenv.mkDerivation rec {
   pname = "xdg-desktop-portal";
-  version = "1.2.0";
+  version = "1.4.2";
 
   outputs = [ "out" "installedTests" ];
 
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
     owner = "flatpak";
     repo = pname;
     rev = version;
-    sha256 = "1gjyif4gly0mkdx6ir6wc4vhfh1raah9jq03q28i88hr7phjdy71";
+    sha256 = "1rs3kmpczkr6nm08kb9njnl7n3rmhh0ral0xav6f0y70pyh8whx6";
   };
 
   patches = [
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
   ];
 
   nativeBuildInputs = [ autoreconfHook pkgconfig libxml2 wrapGAppsHook ];
-  buildInputs = [ glib pipewire fontconfig flatpak acl dbus geoclue2 fuse gsettings-desktop-schemas ];
+  buildInputs = [ glib pipewire fontconfig flatpak acl dbus geoclue2 fuse gsettings-desktop-schemas json-glib ];
 
   doCheck = true; # XXX: investigate!
 
diff --git a/pkgs/development/libraries/xdg-desktop-portal/respect-path-env-var.patch b/pkgs/development/libraries/xdg-desktop-portal/respect-path-env-var.patch
index f884899ecd1..d970f5636ae 100644
--- a/pkgs/development/libraries/xdg-desktop-portal/respect-path-env-var.patch
+++ b/pkgs/development/libraries/xdg-desktop-portal/respect-path-env-var.patch
@@ -1,10 +1,12 @@
---- a/src/xdg-desktop-portal.c
-+++ b/src/xdg-desktop-portal.c
-@@ -177,38 +177,50 @@
- static void
- load_installed_portals (void)
+diff --git a/src/portal-impl.c b/src/portal-impl.c
+index 4fd48ff..346da7c 100644
+--- a/src/portal-impl.c
++++ b/src/portal-impl.c
+@@ -116,38 +116,50 @@ sort_impl_by_name (gconstpointer a,
+ void
+ load_installed_portals (gboolean opt_verbose)
  {
--  const char *portal_dir = PKGDATADIR "/portals";
+-  const char *portal_dir = DATADIR "/xdg-desktop-portal/portals";
 -  g_autoptr(GFile) dir = g_file_new_for_path (portal_dir);
 -  g_autoptr(GFileEnumerator) enumerator = NULL;
  
@@ -14,7 +16,7 @@
 +  const char *portal_dir = g_getenv ("XDG_DESKTOP_PORTAL_PATH");
 +
 +  if (portal_dir == NULL)
-+    portal_dir = PKGDATADIR "/portals";
++    portal_dir = DATADIR "/portals";
  
 -  if (enumerator == NULL)
 -    return;
@@ -56,7 +58,7 @@
 -      path = g_file_get_path (child);
 +          name = g_file_info_get_name (info);
  
--      if (!register_portal (path, &error))
+-      if (!register_portal (path, opt_verbose, &error))
 -        {
 -          g_warning ("Error loading %s: %s", path, error->message);
 -          continue;
@@ -66,7 +68,7 @@
 +          child = g_file_enumerator_get_child (enumerator, info);
 +          path = g_file_get_path (child);
 +
-+          if (!register_portal (path, &error))
++          if (!register_portal (path, opt_verbose, &error))
 +            {
 +              g_warning ("Error loading %s: %s", path, error->message);
 +              continue;
diff --git a/pkgs/development/libraries/xine-lib/default.nix b/pkgs/development/libraries/xine-lib/default.nix
index d86dac05073..fd772a1ff9d 100644
--- a/pkgs/development/libraries/xine-lib/default.nix
+++ b/pkgs/development/libraries/xine-lib/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, xorg, alsaLib, libGLU_combined, aalib
+{ stdenv, fetchurl, fetchpatch, pkgconfig, xorg, alsaLib, libGLU_combined, aalib
 , libvorbis, libtheora, speex, zlib, perl, ffmpeg
 , flac, libcaca, libpulseaudio, libmng, libcdio, libv4l, vcdimager
 , libmpcdec
@@ -20,6 +20,14 @@ stdenv.mkDerivation rec {
     libcaca libpulseaudio libmng libcdio libv4l vcdimager libmpcdec
   ];
 
+  patches = [
+    (fetchpatch {
+      name = "0001-fix-XINE_PLUGIN_PATH-splitting.patch";
+      url = "https://sourceforge.net/p/xine/mailman/attachment/32394053-5e27-6558-f0c9-49e0da0bc3cc%40gmx.de/1/";
+      sha256 = "0nrsdn7myvjs8fl9rj6k4g1bnv0a84prsscg1q9n49gwn339v5rc";
+    })
+  ];
+
   NIX_LDFLAGS = "-lxcb-shm";
 
   propagatedBuildInputs = [zlib];
diff --git a/pkgs/development/libraries/xml-security-c/cxx11.patch b/pkgs/development/libraries/xml-security-c/cxx11.patch
deleted file mode 100644
index bc87d4c1411..00000000000
--- a/pkgs/development/libraries/xml-security-c/cxx11.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- xml-security-c-1.6.1/xsec/tools/checksig/InteropResolver.cpp.orig	2016-02-02 23:57:26.204655144 +0000
-+++ xml-security-c-1.6.1/xsec/tools/checksig/InteropResolver.cpp	2016-02-02 23:57:35.796692305 +0000
-@@ -645,7 +645,7 @@
- 
- 	}
- 
--	return false;
-+	return NULL;
- 
- }
- 
diff --git a/pkgs/development/libraries/xml-security-c/default.nix b/pkgs/development/libraries/xml-security-c/default.nix
index fec4bbe8efe..35ae93e7939 100644
--- a/pkgs/development/libraries/xml-security-c/default.nix
+++ b/pkgs/development/libraries/xml-security-c/default.nix
@@ -2,20 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "xml-security-c-${version}";
-  version = "1.7.3";
+  version = "2.0.2";
 
   src = fetchurl {
     url = "https://www.apache.org/dist/santuario/c-library/${name}.tar.gz";
-    sha256 = "e5226e7319d44f6fd9147a13fb853f5c711b9e75bf60ec273a0ef8a190592583";
+    sha256 = "1prh5sxzipkqglpsh53iblbr7rxi54wbijxdjiahzjmrijqa40y3";
   };
 
-  patches = [ ./cxx11.patch ];
-
-  postPatch = ''
-    mkdir -p xsec/yes/lib
-    sed -i -e 's/-O2 -DNDEBUG/-DNDEBUG/g' configure
-  '';
-
   configureFlags = [
     "--with-openssl"
     "--with-xerces"
diff --git a/pkgs/development/libraries/xml-tooling-c/default.nix b/pkgs/development/libraries/xml-tooling-c/default.nix
index 8e1d71fab3f..fbe515f6217 100644
--- a/pkgs/development/libraries/xml-tooling-c/default.nix
+++ b/pkgs/development/libraries/xml-tooling-c/default.nix
@@ -1,17 +1,19 @@
-{ stdenv, fetchgit, autoreconfHook, boost, curl, openssl, log4shib, xercesc, xml-security-c }:
+{ stdenv, fetchgit, autoreconfHook, pkgconfig
+, boost, curl, openssl, log4shib, xercesc, xml-security-c
+}:
 
 stdenv.mkDerivation rec {
   name = "xml-tooling-c-${version}";
-  version = "1.6.3";
+  version = "3.0.4";
 
   src = fetchgit {
     url = "https://git.shibboleth.net/git/cpp-xmltooling.git";
     rev = version;
-    sha256 = "09z2pp3yy3kqx22vwgxyi3s0vlpdv9camw8dpi3q8piff6zxak3q";
+    sha256 = "0frj4w70l06nva6dvdcivgm1ax69rqbjdzzbgp0sxhiqhddslbas";
   };
 
   buildInputs = [ boost curl openssl log4shib xercesc xml-security-c ];
-  nativeBuildInputs = [ autoreconfHook ];
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/xxHash/default.nix b/pkgs/development/libraries/xxHash/default.nix
index 9f2b83d7597..70701f2d070 100644
--- a/pkgs/development/libraries/xxHash/default.nix
+++ b/pkgs/development/libraries/xxHash/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "xxHash-${version}";
-  version = "0.7.0";
+  version = "0.7.1";
 
   src = fetchFromGitHub {
     owner = "Cyan4973";
     repo = "xxHash";
     rev = "v${version}";
-    sha256 = "19iyr7x0s7in9kp9wrj4iimdx58nv6jndz9x5ndnl07gd90y7jxb";
+    sha256 = "0hh1ypwk86m3b0x4433k95f94b48kvl7s79dml0f3g0cv8jdvkgw";
   };
 
   outputs = [ "out" "dev" ];
diff --git a/pkgs/development/libraries/yder/default.nix b/pkgs/development/libraries/yder/default.nix
new file mode 100644
index 00000000000..82d2d20cb3e
--- /dev/null
+++ b/pkgs/development/libraries/yder/default.nix
@@ -0,0 +1,46 @@
+{ stdenv, lib, fetchFromGitHub, cmake, orcania, systemd, check, subunit
+, withSystemd ? stdenv.isLinux
+}:
+assert withSystemd -> systemd != null;
+stdenv.mkDerivation rec {
+  pname = "yder";
+  version = "1.4.7";
+
+  src = fetchFromGitHub {
+    owner = "babelouest";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "19ghiwpi972wjqvlgg576nk2nkf1ii5l1kvzb056496xfmlysrwa";
+  };
+
+  patches = [
+    # We set CMAKE_INSTALL_LIBDIR to the absolute path in $out, so
+    # prefix and exec_prefix cannot be $out, too
+    ./fix-pkgconfig.patch
+  ];
+
+  nativeBuildInputs = [ cmake ];
+
+  buildInputs = [ orcania ] ++ lib.optional withSystemd systemd;
+
+  checkInputs = [ check subunit ];
+
+  cmakeFlags = [
+    "-DBUILD_YDER_TESTING=on"
+  ] ++ lib.optional (!withSystemd) "-DWITH_JOURNALD=off";
+
+  doCheck = true;
+
+  preCheck = ''
+    export LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH"
+    export DYLD_FALLBACK_LIBRARY_PATH="$(pwd):$DYLD_FALLBACK_LIBRARY_PATH"
+  '';
+
+  meta = with lib; {
+    description = "Logging library for C applications";
+    homepage = "https://github.com/babelouest/yder";
+    license = licenses.lgpl21;
+    maintainers = with maintainers; [ johnazoidberg ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/yder/fix-pkgconfig.patch b/pkgs/development/libraries/yder/fix-pkgconfig.patch
new file mode 100644
index 00000000000..61a67c5897b
--- /dev/null
+++ b/pkgs/development/libraries/yder/fix-pkgconfig.patch
@@ -0,0 +1,9 @@
+--- i/libyder.pc.in
++++ w/libyder.pc.in
+@@ -1,7 +1,5 @@
+-prefix=@CMAKE_INSTALL_PREFIX@
+-exec_prefix=@CMAKE_INSTALL_PREFIX@
+-libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
+-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
++libdir=@CMAKE_INSTALL_LIBDIR@
++includedir=@CMAKE_INSTALL_INCLUDEDIR@
diff --git a/pkgs/development/libraries/zeromq/4.x.nix b/pkgs/development/libraries/zeromq/4.x.nix
index 9fc0c4ac230..8a89d2ae1c7 100644
--- a/pkgs/development/libraries/zeromq/4.x.nix
+++ b/pkgs/development/libraries/zeromq/4.x.nix
@@ -1,14 +1,14 @@
-{ stdenv, fetchFromGitHub, cmake, asciidoc }:
+{ stdenv, fetchFromGitHub, cmake, asciidoc, enableDrafts ? false }:
 
 stdenv.mkDerivation rec {
   name = "zeromq-${version}";
-  version = "4.3.1";
+  version = "4.3.2";
 
   src = fetchFromGitHub {
     owner = "zeromq";
     repo = "libzmq";
     rev = "v${version}";
-    sha256 = "0z7ka82ihlsncqmf8jj4lnjyr418dzxfs0psx5mccqb09yx9shgm";
+    sha256 = "1q37z05i76ili31j6jlw8988iy6vxadlmd306f99phxfdpqa6bn9";
   };
 
   nativeBuildInputs = [ cmake asciidoc ];
@@ -17,6 +17,8 @@ stdenv.mkDerivation rec {
 
   doCheck = false; # fails all the tests (ctest)
 
+  cmakeFlags = if enableDrafts then [ "-DENABLE_DRAFTS=ON" ] else null;
+
   meta = with stdenv.lib; {
     branch = "4";
     homepage = http://www.zeromq.org;
diff --git a/pkgs/development/libraries/zimg/default.nix b/pkgs/development/libraries/zimg/default.nix
index 12fb076d946..75f10f94fb3 100644
--- a/pkgs/development/libraries/zimg/default.nix
+++ b/pkgs/development/libraries/zimg/default.nix
@@ -1,18 +1,20 @@
 { stdenv, fetchFromGitHub, autoreconfHook }:
 
-stdenv.mkDerivation rec{
-  name = "zimg-${version}";
-  version = "2.8";
+stdenv.mkDerivation rec {
+  pname = "zimg";
+  version = "2.9.2";
 
   src = fetchFromGitHub {
     owner  = "sekrit-twc";
     repo   = "zimg";
     rev    = "release-${version}";
-    sha256 = "0s4n1swg1hgv81l8hvf0ny0fn305vf6l6dakbj452304p6ihxd83";
+    sha256 = "0jlgrlfs9maixd8mx7gk2kfawz8ixnihkxi7vhyzfy1gq49vmxm2";
   };
 
   nativeBuildInputs = [ autoreconfHook ];
 
+  enableParallelBuilding = true;
+
   meta = with stdenv.lib; {
     description = "Scaling, colorspace conversion and dithering library";
     homepage    = https://github.com/sekrit-twc/zimg;
diff --git a/pkgs/development/libraries/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix
index 3a5638b2281..592abea4ea0 100644
--- a/pkgs/development/libraries/zlib/default.nix
+++ b/pkgs/development/libraries/zlib/default.nix
@@ -1,9 +1,19 @@
 { stdenv
 , fetchurl
-, static ? true
+# Note: If `{ static = false; shared = false; }`, upstream's default is used
+#       (which is building both static and shared as of zlib 1.2.11).
 , shared ? true
+, static ? true
+# If true, a separate .static ouput is created and the .a is moved there.
+# In this case `pkg-config` will auto detection will currently not work if the
+# .static output is given as `buildInputs` to another package (#66461), because
+# the `.pc` file lists only the main output's lib dir.
+# If false, and if `{ static = true; }`, the .a stays in the main output.
+, splitStaticOutput ? static
 }:
 
+assert splitStaticOutput -> static;
+
 stdenv.mkDerivation (rec {
   name = "zlib-${version}";
   version = "1.2.11";
@@ -26,14 +36,35 @@ stdenv.mkDerivation (rec {
   '';
 
   outputs = [ "out" "dev" ]
-    ++ stdenv.lib.optional (shared && static) "static";
+    ++ stdenv.lib.optional splitStaticOutput "static";
   setOutputFlags = false;
   outputDoc = "dev"; # single tiny man3 page
 
-  configureFlags = stdenv.lib.optional shared "--shared"
-                   ++ stdenv.lib.optional (static && !shared) "--static";
+  # For zlib's ./configure (as of verion 1.2.11), the order
+  # of --static/--shared flags matters!
+  # `--shared --static` builds only static libs, while
+  # `--static --shared` builds both.
+  # So we use the latter order to be able to build both.
+  # Also, giving just `--shared` builds both,
+  # giving just `--static` builds only static,
+  # and giving nothing builds both.
+  # So we have 3 possible ways to build both:
+  # `--static --shared`, `--shared` and giving nothing.
+  # Of these, we choose `--shared`, only because that's
+  # what we did in the past and we can avoid mass rebuilds this way.
+  # As a result, we pass `--static` only when we want just static.
+  configureFlags = stdenv.lib.optional (static && !shared) "--static"
+                   ++ stdenv.lib.optional shared "--shared";
+
+  # Note we don't need to set `dontDisableStatic`, because static-disabling
+  # works by grepping for `enable-static` in the `./configure` script
+  # (see `pkgs/stdenv/generic/setup.sh`), and zlib's handwritten one does
+  # not have such.
+  # It wouldn't hurt setting `dontDisableStatic = static && !splitStaticOutput`
+  # here (in case zlib ever switches to autoconf in the future),
+  # but we don't do it simply to avoid mass rebuilds.
 
-  postInstall = stdenv.lib.optionalString (shared && static) ''
+  postInstall = stdenv.lib.optionalString splitStaticOutput ''
     moveToOutput lib/libz.a "$static"
   ''
     # jww (2015-01-06): Sometimes this library install as a .so, even on
@@ -54,6 +85,8 @@ stdenv.mkDerivation (rec {
   # to the bootstrap-tools libgcc (as uses to happen on arm/mips)
   NIX_CFLAGS_COMPILE = stdenv.lib.optionalString (!stdenv.hostPlatform.isDarwin) "-static-libgcc";
 
+  # We don't strip on static cross-compilation because of reports that native
+  # stripping corrupted the target library; see commit 12e960f5 for the report.
   dontStrip = stdenv.hostPlatform != stdenv.buildPlatform && static;
   configurePlatforms = [];
 
@@ -68,6 +101,8 @@ stdenv.mkDerivation (rec {
   ] ++ stdenv.lib.optionals (stdenv.hostPlatform.libc == "msvcrt") [
     "-f" "win32/Makefile.gcc"
   ] ++ stdenv.lib.optionals shared [
+    # Note that as of writing (zlib 1.2.11), this flag only has an effect
+    # for Windows as it is specific to `win32/Makefile.gcc`.
     "SHARED_MODE=1"
   ];
 
@@ -86,5 +121,5 @@ stdenv.mkDerivation (rec {
     export CHOST=${stdenv.hostPlatform.config}
   '';
 } // stdenv.lib.optionalAttrs (stdenv.hostPlatform.libc == "msvcrt") {
-  configurePhase = ":";
+  dontConfigure = true;
 })
diff --git a/pkgs/development/libraries/zlog/default.nix b/pkgs/development/libraries/zlog/default.nix
index d3dc41371de..330b91e995d 100644
--- a/pkgs/development/libraries/zlog/default.nix
+++ b/pkgs/development/libraries/zlog/default.nix
@@ -1,13 +1,13 @@
 { stdenv, fetchzip }:
 
 stdenv.mkDerivation rec {
-  version = "1.2.12";
+  version = "1.2.14";
   name = "zlog-${version}";
 
   src = fetchzip {
     name = "${name}-src";
     url = "https://github.com/HardySimpson/zlog/archive/${version}.tar.gz";
-    sha256 = "1ychld0dcfdak2wnmkj941i0xav6ynlb3n6hz1kz03yy74ll2fqi";
+    sha256 = "1qcrfmh2vbarkx7ij3gwk174qmgmhm2j336bfaakln1ixd9lkxa5";
   };
 
   configurePhase = ''
diff --git a/pkgs/development/libraries/zziplib/default.nix b/pkgs/development/libraries/zziplib/default.nix
index 6aede4e9653..010c73336b9 100644
--- a/pkgs/development/libraries/zziplib/default.nix
+++ b/pkgs/development/libraries/zziplib/default.nix
@@ -1,4 +1,4 @@
-{ docbook_xml_dtd_412, fetchurl, stdenv, perl, python2, zip, xmlto, zlib }:
+{ docbook_xml_dtd_412, fetchurl, stdenv, perl, python2, zip, xmlto, zlib, fetchpatch }:
 
 stdenv.mkDerivation rec {
   name = "zziplib-${version}";
@@ -9,6 +9,13 @@ stdenv.mkDerivation rec {
     sha256 = "0i052a7shww0fzsxrdp3rd7g4mbzx7324a8ysbc0br7frpblcql4";
   };
 
+  patches = [
+    (fetchpatch {
+      name = "CVE-2018-17828.patch";
+      url = "https://github.com/gdraheim/zziplib/commit/f609ae8971f3c0ce6.diff";
+      sha256 = "0jhiz4fgr93wzh6q03avn95b2nsf6402jaki6hxirxyhs5v9ahry";
+    })
+  ];
   postPatch = ''
     sed -i -e s,--export-dynamic,, configure
   '';