summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2020-04-13 16:48:38 -0400
committerGitHub <noreply@github.com>2020-04-13 16:48:38 -0400
commite520d6af29158ff6d17c34ec16b1f2e79bccad45 (patch)
treeddf031dda697cba7549ed8357ca3454c30433fbd /pkgs
parent940c35568bc2fa135eafe0817027c765d9840469 (diff)
parentc6ff360cc437d366c10f2f827edd5a7fb47e73c3 (diff)
downloadnixpkgs-e520d6af29158ff6d17c34ec16b1f2e79bccad45.tar
nixpkgs-e520d6af29158ff6d17c34ec16b1f2e79bccad45.tar.gz
nixpkgs-e520d6af29158ff6d17c34ec16b1f2e79bccad45.tar.bz2
nixpkgs-e520d6af29158ff6d17c34ec16b1f2e79bccad45.tar.lz
nixpkgs-e520d6af29158ff6d17c34ec16b1f2e79bccad45.tar.xz
nixpkgs-e520d6af29158ff6d17c34ec16b1f2e79bccad45.tar.zst
nixpkgs-e520d6af29158ff6d17c34ec16b1f2e79bccad45.zip
Merge pull request #84415 from matthewbauer/mb-cross-fixes-april2020
Cross compilation fixes [april 2020]
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/applications/version-management/git-and-tools/git/default.nix2
-rw-r--r--pkgs/applications/video/kodi/default.nix74
-rw-r--r--pkgs/build-support/setup-hooks/auto-patchelf.sh4
-rw-r--r--pkgs/data/icons/hicolor-icon-theme/setup-hook.sh2
-rw-r--r--pkgs/desktops/gnome-3/core/epiphany/default.nix1
-rw-r--r--pkgs/development/libraries/cracklib/default.nix3
-rw-r--r--pkgs/development/libraries/flatbuffers/default.nix4
-rw-r--r--pkgs/development/libraries/fstrcmp/cross.patch24
-rw-r--r--pkgs/development/libraries/fstrcmp/default.nix6
-rw-r--r--pkgs/development/libraries/ftgl/default.nix2
-rw-r--r--pkgs/development/libraries/gdk-pixbuf/default.nix4
-rw-r--r--pkgs/development/libraries/gdk-pixbuf/setup-hook.sh2
-rw-r--r--pkgs/development/libraries/glib/setup-hook.sh3
-rw-r--r--pkgs/development/libraries/libasyncns/default.nix5
-rw-r--r--pkgs/development/libraries/libcddb/default.nix5
-rw-r--r--pkgs/development/libraries/libcdio/default.nix4
-rw-r--r--pkgs/development/libraries/libcec/default.nix4
-rw-r--r--pkgs/development/libraries/libcrossguid/default.nix4
-rw-r--r--pkgs/development/libraries/libva/default.nix4
-rw-r--r--pkgs/development/libraries/libvisual/default.nix5
-rw-r--r--pkgs/development/libraries/libvpx/default.nix8
-rw-r--r--pkgs/development/libraries/tinyxml/2.6.2.nix4
-rw-r--r--pkgs/development/libraries/vulkan-loader/default.nix4
-rw-r--r--pkgs/development/libraries/waylandpp/default.nix6
-rw-r--r--pkgs/development/python-modules/python-dbusmock/default.nix4
-rw-r--r--pkgs/misc/emulators/retroarch/default.nix10
-rw-r--r--pkgs/os-specific/linux/alsa-plugins/default.nix4
-rw-r--r--pkgs/os-specific/linux/bluez/default.nix24
-rw-r--r--pkgs/os-specific/linux/plymouth/default.nix3
-rw-r--r--pkgs/servers/x11/xorg/overrides.nix9
-rw-r--r--pkgs/tools/misc/dvtm/dvtm.nix5
-rw-r--r--pkgs/top-level/unix-tools.nix4
32 files changed, 171 insertions, 76 deletions
diff --git a/pkgs/applications/version-management/git-and-tools/git/default.nix b/pkgs/applications/version-management/git-and-tools/git/default.nix
index 6169c2d0296..ca3bf667b4a 100644
--- a/pkgs/applications/version-management/git-and-tools/git/default.nix
+++ b/pkgs/applications/version-management/git-and-tools/git/default.nix
@@ -80,6 +80,8 @@ stdenv.mkDerivation {
   configureFlags = stdenv.lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
     "ac_cv_fread_reads_directories=yes"
     "ac_cv_snprintf_returns_bogus=no"
+    "ac_cv_iconv_omits_bom=no"
+    "ac_cv_prog_CURL_CONFIG=${curl.dev}/bin/curl-config"
   ];
 
   preBuild = ''
diff --git a/pkgs/applications/video/kodi/default.nix b/pkgs/applications/video/kodi/default.nix
index d13dd3201a3..6d02bcefb08 100644
--- a/pkgs/applications/video/kodi/default.nix
+++ b/pkgs/applications/video/kodi/default.nix
@@ -4,22 +4,20 @@
 , boost, avahi, lame, autoreconfHook
 , gettext, pcre-cpp, yajl, fribidi, which
 , openssl, gperf, tinyxml2, taglib, libssh, swig, jre
-, libX11, xorgproto, libxml2
-, libXt, libXmu, libXext
-, libXinerama, libXrandr
-, libXtst, libXfixes, systemd
+, libxml2, systemd
 , alsaLib, libGLU, libGL, glew, fontconfig, freetype, ftgl
 , libjpeg, libpng, libtiff
 , libmpeg2, libsamplerate, libmad
 , libogg, libvorbis, flac, libxslt
 , lzo, libcdio, libmodplug, libass, libbluray
 , sqlite, libmysqlclient, nasm, gnutls, libva, libdrm
-, curl, bzip2, zip, unzip, glxinfo, xdpyinfo
+, curl, bzip2, zip, unzip, glxinfo
 , libcec, libcec_platform, dcadec, libuuid
 , libcrossguid, libmicrohttpd
-, bluez, doxygen, giflib, glib, harfbuzz, lcms2, libidn, libpthreadstubs, libtasn1, libXdmcp
+, bluez, doxygen, giflib, glib, harfbuzz, lcms2, libidn, libpthreadstubs, libtasn1
 , libplist, p11-kit, zlib, flatbuffers, fmt, fstrcmp, rapidjson
 , lirc
+, x11Support ? true, libX11, xorgproto, libXt, libXmu, libXext, libXinerama, libXrandr, libXtst, libXfixes, xdpyinfo, libXdmcp
 , dbusSupport ? true, dbus ? null
 , joystickSupport ? true, cwiid ? null
 , nfsSupport ? true, libnfs ? null
@@ -32,6 +30,7 @@
 , useWayland ? false, wayland ? null, wayland-protocols ? null
 , waylandpp ?  null, libxkbcommon ? null
 , useGbm ? false, mesa ? null, libinput ? null
+, buildPackages
 }:
 
 assert dbusSupport  -> dbus != null;
@@ -94,10 +93,18 @@ let
     sha256  = "1krsjlr949iy5l6ljxancza1yi6w1annxc5s6k283i9mb15qy8cy";
     preConfigure = ''
       cp ${kodi_src}/tools/depends/target/ffmpeg/{CMakeLists.txt,*.cmake} .
+      sed -i 's/ --cpu=''${CPU}//' CMakeLists.txt
+      sed -i 's/--strip=''${CMAKE_STRIP}/--strip=''${CMAKE_STRIP} --ranlib=''${CMAKE_RANLIB}/' CMakeLists.txt
     '';
-    buildInputs = [ gnutls libidn libtasn1 p11-kit zlib libva ]
+    cmakeFlags = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+      "-DCROSSCOMPILING=ON"
+      "-DCPU=${stdenv.hostPlatform.parsed.cpu.name}"
+      "-DOS=${stdenv.hostPlatform.parsed.kernel.name}"
+      "-DPKG_CONFIG_EXECUTABLE=pkgconfig"
+    ];
+    buildInputs = [ libidn libtasn1 p11-kit zlib libva ]
       ++ lib.optional  vdpauSupport    libvdpau;
-    nativeBuildInputs = [ cmake nasm pkgconfig ];
+    nativeBuildInputs = [ cmake nasm pkgconfig gnutls ];
   };
 
   # We can build these externally but FindLibDvd.cmake forces us to build it
@@ -152,29 +159,31 @@ in stdenv.mkDerivation {
 
     buildInputs = [
       gnutls libidn libtasn1 nasm p11-kit
-      libxml2 yasm python2Packages.python
+      libxml2 python2Packages.python
       boost libmicrohttpd
       gettext pcre-cpp yajl fribidi libva libdrm
-      openssl gperf tinyxml2 taglib libssh swig jre
-      libX11 xorgproto libXt libXmu libXext
-      libXinerama libXrandr libXtst libXfixes
-      alsaLib libGL libGLU glew fontconfig freetype ftgl
+      openssl gperf tinyxml2 taglib libssh
+      alsaLib libGL libGLU fontconfig freetype ftgl
       libjpeg libpng libtiff
       libmpeg2 libsamplerate libmad
       libogg libvorbis flac libxslt systemd
       lzo libcdio libmodplug libass libbluray
       sqlite libmysqlclient avahi lame
-      curl bzip2 zip unzip glxinfo xdpyinfo
+      curl bzip2 zip unzip glxinfo
       libcec libcec_platform dcadec libuuid
       libgcrypt libgpgerror libunistring
-      libcrossguid cwiid libplist
-      bluez giflib glib harfbuzz lcms2 libpthreadstubs libXdmcp
+      libcrossguid libplist
+      bluez giflib glib harfbuzz lcms2 libpthreadstubs
       ffmpeg flatbuffers fmt fstrcmp rapidjson
       lirc
       # libdvdcss libdvdnav libdvdread
     ]
+    ++ lib.optional x11Support [
+      libX11 xorgproto libXt libXmu libXext libXdmcp
+      libXinerama libXrandr libXtst libXfixes
+    ]
     ++ lib.optional  dbusSupport     dbus
-    ++ lib.optionals joystickSupport [ cwiid ]
+    ++ lib.optional joystickSupport cwiid
     ++ lib.optional  nfsSupport      libnfs
     ++ lib.optional  pulseSupport    libpulseaudio
     ++ lib.optional  rtmpSupport     rtmpdump
@@ -183,7 +192,7 @@ in stdenv.mkDerivation {
     ++ lib.optional  usbSupport      libusb
     ++ lib.optional  vdpauSupport    libvdpau
     ++ lib.optionals useWayland [
-      wayland waylandpp
+      wayland waylandpp wayland-protocols
       # Not sure why ".dev" is needed here, but CMake doesn't find libxkbcommon otherwise
       libxkbcommon.dev
     ]
@@ -200,8 +209,16 @@ in stdenv.mkDerivation {
       which
       pkgconfig gnumake
       autoconf automake libtool # still needed for some components. Check if that is the case with 19.0
+      jre yasm gettext python2Packages.python flatbuffers
+
+      # for TexturePacker
+      giflib zlib libpng libjpeg lzo
     ] ++ lib.optionals useWayland [ wayland-protocols ];
 
+    depsBuildBuild = [
+      buildPackages.stdenv.cc
+    ];
+
     cmakeFlags = [
       "-Dlibdvdcss_URL=${libdvdcss.src}"
       "-Dlibdvdnav_URL=${libdvdnav.src}"
@@ -210,9 +227,14 @@ in stdenv.mkDerivation {
       "-DENABLE_EVENTCLIENTS=ON"
       "-DENABLE_INTERNAL_CROSSGUID=OFF"
       "-DENABLE_OPTICAL=ON"
+      "-DLIRC_DEVICE=/run/lirc/lircd"
+      "-DSWIG_EXECUTABLE=${buildPackages.swig}/bin/swig"
+      "-DFLATBUFFERS_FLATC_EXECUTABLE=${buildPackages.flatbuffers}/bin/flatc"
+      "-DPYTHON_EXECUTABLE=${buildPackages.python2Packages.python}/bin/python"
     ] ++ lib.optional useWayland [
       "-DCORE_PLATFORM_NAME=wayland"
       "-DWAYLAND_RENDER_SYSTEM=gl"
+      "-DWAYLANDPP_SCANNER=${buildPackages.waylandpp}/bin/wayland-scanner++"
     ] ++ lib.optional useGbm [
       "-DCORE_PLATFORM_NAME=gbm"
       "-DGBM_RENDER_SYSTEM=gles"
@@ -224,6 +246,16 @@ in stdenv.mkDerivation {
     # I'm guessing there is a thing waiting to time out
     doCheck = false;
 
+    # Need these tools on the build system when cross compiling,
+    # hacky, but have found no other way.
+    preConfigure = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
+      CXX=c++ LD=ld make -C tools/depends/native/JsonSchemaBuilder
+      cmakeFlags+=" -DWITH_JSONSCHEMABUILDER=$PWD/tools/depends/native/JsonSchemaBuilder/bin"
+
+      CXX=c++ LD=ld make EXTRA_CONFIGURE= -C tools/depends/native/TexturePacker
+      cmakeFlags+=" -DWITH_TEXTUREPACKER=$PWD/tools/depends/native/TexturePacker/bin"
+    '';
+
     postPatch = ''
       substituteInPlace xbmc/platform/linux/LinuxTimezone.cpp \
         --replace 'usr/share/zoneinfo' 'etc/zoneinfo'
@@ -232,9 +264,11 @@ in stdenv.mkDerivation {
     postInstall = ''
       for p in $(ls $out/bin/) ; do
         wrapProgram $out/bin/$p \
-          --prefix PATH            ":" "${lib.makeBinPath [ python2Packages.python glxinfo xdpyinfo ]}" \
+          --prefix PATH            ":" "${lib.makeBinPath ([ python2Packages.python glxinfo ] ++ lib.optional x11Support xdpyinfo)}" \
           --prefix LD_LIBRARY_PATH ":" "${lib.makeLibraryPath
-              ([ curl systemd libmad libvdpau libcec libcec_platform rtmpdump libass ] ++ lib.optional nfsSupport libnfs)}"
+              ([ curl systemd libmad libvdpau libcec libcec_platform libass ]
+                 ++ lib.optional nfsSupport libnfs
+                 ++ lib.optional rtmpSupport rtmpdump)}"
       done
 
       substituteInPlace $out/share/xsessions/kodi.desktop \
diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.sh b/pkgs/build-support/setup-hooks/auto-patchelf.sh
index 52c50091d08..72970623ed7 100644
--- a/pkgs/build-support/setup-hooks/auto-patchelf.sh
+++ b/pkgs/build-support/setup-hooks/auto-patchelf.sh
@@ -15,7 +15,7 @@ isExecutable() {
     # *or* there is an INTERP section. This also catches position-independent
     # executables, as they typically have an INTERP section but their ELF type
     # is DYN.
-    isExeResult="$(LANG=C readelf -h -l "$1" 2> /dev/null \
+    isExeResult="$(LANG=C $READELF -h -l "$1" 2> /dev/null \
         | grep '^ *Type: *EXEC\>\|^ *INTERP\>')"
     # not using grep -q, because it can cause Broken pipe
     [ -n "$isExeResult" ]
@@ -207,7 +207,7 @@ autoPatchelf() {
     # outside of this function.
     while IFS= read -r -d $'\0' file; do
       isELF "$file" || continue
-      segmentHeaders="$(LANG=C readelf -l "$file")"
+      segmentHeaders="$(LANG=C $READELF -l "$file")"
       # Skip if the ELF file doesn't have segment headers (eg. object files).
       # not using grep -q, because it can cause Broken pipe
       [ -n "$(echo "$segmentHeaders" | grep '^Program Headers:')" ] || continue
diff --git a/pkgs/data/icons/hicolor-icon-theme/setup-hook.sh b/pkgs/data/icons/hicolor-icon-theme/setup-hook.sh
index f07bab4b269..f7c99418144 100644
--- a/pkgs/data/icons/hicolor-icon-theme/setup-hook.sh
+++ b/pkgs/data/icons/hicolor-icon-theme/setup-hook.sh
@@ -10,4 +10,4 @@ hicolorIconThemeHook() {
 }
 
 # I think this is meant to be a runtime dep
-addEnvHooks "${hostOffset:?}" hicolorIconThemeHook
+addEnvHooks "${targetOffset:?}" hicolorIconThemeHook
diff --git a/pkgs/desktops/gnome-3/core/epiphany/default.nix b/pkgs/desktops/gnome-3/core/epiphany/default.nix
index 5ede0184d21..c41f5d79eb7 100644
--- a/pkgs/desktops/gnome-3/core/epiphany/default.nix
+++ b/pkgs/desktops/gnome-3/core/epiphany/default.nix
@@ -58,6 +58,7 @@ stdenv.mkDerivation rec {
     python3
     wrapGAppsHook
     buildPackages.glib
+    buildPackages.gtk3
   ];
 
   buildInputs = [
diff --git a/pkgs/development/libraries/cracklib/default.nix b/pkgs/development/libraries/cracklib/default.nix
index 4f3270d677a..c10a69d72f9 100644
--- a/pkgs/development/libraries/cracklib/default.nix
+++ b/pkgs/development/libraries/cracklib/default.nix
@@ -18,10 +18,11 @@ stdenv.mkDerivation rec {
   nativeBuildInputs = lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) buildPackages.cracklib;
   buildInputs = [ zlib gettext ];
 
-  postPatch = ''
+  postPatch = stdenv.lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) ''
     chmod +x util/cracklib-format
     patchShebangs util
 
+  '' + ''
     ln -vs ${toString wordlists} dicts/
   '';
 
diff --git a/pkgs/development/libraries/flatbuffers/default.nix b/pkgs/development/libraries/flatbuffers/default.nix
index fecd54e0ef5..825e052ad87 100644
--- a/pkgs/development/libraries/flatbuffers/default.nix
+++ b/pkgs/development/libraries/flatbuffers/default.nix
@@ -18,7 +18,9 @@ stdenv.mkDerivation (rec {
   nativeBuildInputs = [ cmake ];
   enableParallelBuilding = true;
 
-  doCheck = true;
+  cmakeFlags = [ "-DFLATBUFFERS_BUILD_TESTS=${if doCheck then "ON" else "OFF"}" ];
+
+  doCheck = stdenv.hostPlatform == stdenv.buildPlatform;
   checkTarget = "test";
 
   meta = {
diff --git a/pkgs/development/libraries/fstrcmp/cross.patch b/pkgs/development/libraries/fstrcmp/cross.patch
new file mode 100644
index 00000000000..f794e3b91da
--- /dev/null
+++ b/pkgs/development/libraries/fstrcmp/cross.patch
@@ -0,0 +1,24 @@
+diff '--color=auto' -ur fstrcmp-0.7-D001-old/configure.ac fstrcmp-0.7.D001/configure.ac
+--- fstrcmp-0.7-D001-old/configure.ac	2014-03-04 19:13:45.000000000 -0500
++++ fstrcmp-0.7.D001/configure.ac	2020-04-02 13:57:52.805154634 -0400
+@@ -32,6 +32,8 @@
+ AC_OBJEXT
+ AC_EXEEXT
+ 
++LT_INIT
++
+ dnl @synopsis AC_ADD_CFLAGS
+ dnl
+ dnl Add the given option to CFLAGS, if it doesn't break the compiler
+diff '--color=auto' -ur fstrcmp-0.7-D001-old/Makefile.in fstrcmp-0.7.D001/Makefile.in
+--- fstrcmp-0.7-D001-old/Makefile.in	2014-03-04 19:13:45.000000000 -0500
++++ fstrcmp-0.7.D001/Makefile.in	2020-04-02 13:57:12.355269595 -0400
+@@ -37,6 +37,8 @@
+ srcdir = @srcdir@
+ VPATH = @srcdir@
+ 
++top_builddir = $(srcdir)
++
+ #
+ # the name of the install program to use
+ #
diff --git a/pkgs/development/libraries/fstrcmp/default.nix b/pkgs/development/libraries/fstrcmp/default.nix
index 732cd68551b..46b579d4abd 100644
--- a/pkgs/development/libraries/fstrcmp/default.nix
+++ b/pkgs/development/libraries/fstrcmp/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchzip, libtool, ghostscript, groff }:
+{ stdenv, fetchzip, libtool, ghostscript, groff, autoreconfHook }:
 
 stdenv.mkDerivation rec {
   pname = "fstrcmp";
@@ -9,9 +9,11 @@ stdenv.mkDerivation rec {
     sha256 = "0yg3y3k0wz50gmhgigfi2dx725w1gc8snb95ih7vpcnj6kabgz9a";
   };
 
+  patches = [ ./cross.patch ];
+
   outputs = [ "out" "dev" "doc" "man" "devman" ];
 
-  nativeBuildInputs = [ libtool ghostscript groff ];
+  nativeBuildInputs = [ libtool ghostscript groff autoreconfHook ];
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/ftgl/default.nix b/pkgs/development/libraries/ftgl/default.nix
index 21be623314f..a0ce9db815b 100644
--- a/pkgs/development/libraries/ftgl/default.nix
+++ b/pkgs/development/libraries/ftgl/default.nix
@@ -18,6 +18,8 @@ stdenv.mkDerivation {
       [ libGL libGLU ])
     ;
 
+  configureFlags = [ "--with-ft-prefix=${stdenv.lib.getDev freetype}" ];
+
   enableParallelBuilding = true;
 
   meta = {
diff --git a/pkgs/development/libraries/gdk-pixbuf/default.nix b/pkgs/development/libraries/gdk-pixbuf/default.nix
index b45b578eac0..82fbbc967ef 100644
--- a/pkgs/development/libraries/gdk-pixbuf/default.nix
+++ b/pkgs/development/libraries/gdk-pixbuf/default.nix
@@ -35,7 +35,7 @@ in stdenv.mkDerivation rec {
 
   nativeBuildInputs = [
     meson ninja pkgconfig gettext python3 libxml2 libxslt docbook_xsl docbook_xml_dtd_43
-    gtk-doc gobject-introspection makeWrapper
+    gtk-doc gobject-introspection makeWrapper glib
   ]
     ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
@@ -68,7 +68,7 @@ in stdenv.mkDerivation rec {
     + ''
       moveToOutput "bin" "$dev"
       moveToOutput "bin/gdk-pixbuf-thumbnailer" "$out"
-
+    '' + stdenv.lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) ''
       # We need to install 'loaders.cache' in lib/gdk-pixbuf-2.0/2.10.0/
       $dev/bin/gdk-pixbuf-query-loaders --update-cache
     '';
diff --git a/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh b/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh
index 06958be3213..bdfd00009dc 100644
--- a/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh
+++ b/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh
@@ -14,4 +14,4 @@ findGdkPixbufLoaders() {
 
 }
 
-addEnvHooks "$hostOffset" findGdkPixbufLoaders
+addEnvHooks "$targetOffset" findGdkPixbufLoaders
diff --git a/pkgs/development/libraries/glib/setup-hook.sh b/pkgs/development/libraries/glib/setup-hook.sh
index 5d9c330b62e..8ead5510ec4 100644
--- a/pkgs/development/libraries/glib/setup-hook.sh
+++ b/pkgs/development/libraries/glib/setup-hook.sh
@@ -1,4 +1,3 @@
-
 make_glib_find_gsettings_schemas() {
     # For packages that need gschemas of other packages (e.g. empathy)
     for maybe_dir in "$1"/share/gsettings-schemas/*; do
@@ -7,7 +6,7 @@ make_glib_find_gsettings_schemas() {
         fi
     done
 }
-addEnvHooks "$hostOffset" make_glib_find_gsettings_schemas
+addEnvHooks "$targetOffset" make_glib_find_gsettings_schemas
 
 # Install gschemas, if any, in a package-specific directory
 glibPreInstallPhase() {
diff --git a/pkgs/development/libraries/libasyncns/default.nix b/pkgs/development/libraries/libasyncns/default.nix
index d8b4f1d7df2..9a91551c3a4 100644
--- a/pkgs/development/libraries/libasyncns/default.nix
+++ b/pkgs/development/libraries/libasyncns/default.nix
@@ -8,6 +8,11 @@ stdenv.mkDerivation rec {
     sha256 = "0x5b6lcic4cd7q0bx00x93kvpyzl7n2abbgvqbrlzrfb8vknc6jg";
   };
 
+  configureFlags = stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+    "ac_cv_func_malloc_0_nonnull=yes"
+    "ac_cv_func_realloc_0_nonnull=yes"
+  ];
+
   meta = with stdenv.lib; {
     homepage = "http://0pointer.de/lennart/projects/libasyncns/";
     description = "A C library for Linux/Unix for executing name service queries asynchronously";
diff --git a/pkgs/development/libraries/libcddb/default.nix b/pkgs/development/libraries/libcddb/default.nix
index 26a69fe9fc7..2b837ff1ce1 100644
--- a/pkgs/development/libraries/libcddb/default.nix
+++ b/pkgs/development/libraries/libcddb/default.nix
@@ -10,6 +10,11 @@ stdenv.mkDerivation rec {
 
   buildInputs = stdenv.lib.optional stdenv.isDarwin libiconv;
 
+  configureFlags = stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+    "ac_cv_func_malloc_0_nonnull=yes"
+    "ac_cv_func_realloc_0_nonnull=yes"
+  ];
+
   doCheck = false; # fails 3 of 5 tests with locale errors
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libcdio/default.nix b/pkgs/development/libraries/libcdio/default.nix
index e4522bf00be..b0b7b55a19d 100644
--- a/pkgs/development/libraries/libcdio/default.nix
+++ b/pkgs/development/libraries/libcdio/default.nix
@@ -12,8 +12,8 @@ stdenv.mkDerivation rec {
     patchShebangs .
   '';
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ libcddb ncurses help2man ]
+  nativeBuildInputs = [ pkgconfig help2man ];
+  buildInputs = [ libcddb ncurses ]
     ++ stdenv.lib.optionals stdenv.isDarwin [ libiconv Carbon IOKit ];
 
   doCheck = !stdenv.isDarwin;
diff --git a/pkgs/development/libraries/libcec/default.nix b/pkgs/development/libraries/libcec/default.nix
index 2ea55db2247..09ebac93869 100644
--- a/pkgs/development/libraries/libcec/default.nix
+++ b/pkgs/development/libraries/libcec/default.nix
@@ -11,8 +11,8 @@ stdenv.mkDerivation {
     sha256 = "02j09y06csaic4m0fyb4dr9l3hl15nxbbniwq0i1qlccpxjak0j3";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ cmake udev libcec_platform ] ++
+  nativeBuildInputs = [ pkgconfig cmake ];
+  buildInputs = [ udev libcec_platform ] ++
     stdenv.lib.optional (libraspberrypi != null) libraspberrypi;
 
   cmakeFlags = [ "-DBUILD_SHARED_LIBS=1" ];
diff --git a/pkgs/development/libraries/libcrossguid/default.nix b/pkgs/development/libraries/libcrossguid/default.nix
index 0d0f06aac37..8e2be72987c 100644
--- a/pkgs/development/libraries/libcrossguid/default.nix
+++ b/pkgs/development/libraries/libcrossguid/default.nix
@@ -15,8 +15,8 @@ stdenv.mkDerivation rec {
   buildInputs = [ libuuid ];
 
   buildPhase = ''
-    g++ -c guid.cpp -o guid.o $CXXFLAGS -std=c++11 -DGUID_LIBUUID
-    ar rvs libcrossguid.a guid.o
+    $CXX -c guid.cpp -o guid.o $CXXFLAGS -std=c++11 -DGUID_LIBUUID
+    $AR rvs libcrossguid.a guid.o
   '';
   installPhase = ''
     mkdir -p $out/{lib,include}
diff --git a/pkgs/development/libraries/libva/default.nix b/pkgs/development/libraries/libva/default.nix
index 1c8e78a3a37..be374eaf895 100644
--- a/pkgs/development/libraries/libva/default.nix
+++ b/pkgs/development/libraries/libva/default.nix
@@ -2,6 +2,7 @@
 , libXext, libdrm, libXfixes, wayland, libffi, libX11
 , libGL, mesa
 , minimal ? false, libva-minimal
+, buildPackages
 }:
 
 stdenv.mkDerivation rec {
@@ -18,7 +19,7 @@ stdenv.mkDerivation rec {
 
   outputs = [ "dev" "out" ];
 
-  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  nativeBuildInputs = [ autoreconfHook pkgconfig wayland ];
 
   buildInputs = [ libdrm ]
     ++ lib.optionals (!minimal) [ libva-minimal libX11 libXext libXfixes wayland libffi libGL ];
@@ -29,6 +30,7 @@ stdenv.mkDerivation rec {
   configureFlags = [
     # Add FHS paths for non-NixOS applications.
     "--with-drivers-path=${mesa.drivers.driverLink}/lib/dri:/usr/lib/dri:/usr/lib32/dri"
+    "ac_cv_path_WAYLAND_SCANNER=${buildPackages.wayland}/bin/wayland-scanner"
   ] ++ lib.optionals (!minimal) [ "--enable-glx" ];
 
   installFlags = [
diff --git a/pkgs/development/libraries/libvisual/default.nix b/pkgs/development/libraries/libvisual/default.nix
index 8880daed88e..8fe53acc245 100644
--- a/pkgs/development/libraries/libvisual/default.nix
+++ b/pkgs/development/libraries/libvisual/default.nix
@@ -13,6 +13,11 @@ stdenv.mkDerivation rec {
 
   hardeningDisable = [ "format" ];
 
+  configureFlags = stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+    "ac_cv_func_malloc_0_nonnull=yes"
+    "ac_cv_func_realloc_0_nonnull=yes"
+  ];
+
   meta = {
     description = "An abstraction library for audio visualisations";
     homepage = "https://sourceforge.net/projects/libvisual/";
diff --git a/pkgs/development/libraries/libvpx/default.nix b/pkgs/development/libraries/libvpx/default.nix
index ca3ec9856c2..007df403ff7 100644
--- a/pkgs/development/libraries/libvpx/default.nix
+++ b/pkgs/development/libraries/libvpx/default.nix
@@ -135,16 +135,10 @@ stdenv.mkDerivation rec {
                     experimentalFpMbStatsSupport ||
                     experimentalEmulateHardwareSupport) "experimental")
   ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
-    #"--extra-cflags="
-    #"--extra-cxxflags="
-    #"--prefix="
-    #"--libc="
-    #"--libdir="
-    "--enable-external-build"
     # libvpx darwin targets include darwin version (ie. ARCH-darwinXX-gcc, XX being the darwin version)
     # See all_platforms: https://github.com/webmproject/libvpx/blob/master/configure
     # Darwin versions: 10.4=8, 10.5=9, 10.6=10, 10.7=11, 10.8=12, 10.9=13, 10.10=14
-    "--force-target=${stdenv.hostPlatform.config}${
+    "--force-target=${stdenv.hostPlatform.parsed.cpu.name}-${stdenv.hostPlatform.parsed.kernel.name}${
             if stdenv.hostPlatform.isDarwin then
               if      stdenv.hostPlatform.osxMinVersion == "10.10" then "14"
               else if stdenv.hostPlatform.osxMinVersion == "10.9"  then "13"
diff --git a/pkgs/development/libraries/tinyxml/2.6.2.nix b/pkgs/development/libraries/tinyxml/2.6.2.nix
index 664030bc1bc..9c909d5e14d 100644
--- a/pkgs/development/libraries/tinyxml/2.6.2.nix
+++ b/pkgs/development/libraries/tinyxml/2.6.2.nix
@@ -23,14 +23,14 @@ in stdenv.mkDerivation {
     ./2.6.2-cxx.patch
   ];
 
-  preConfigure = "export LD=${if stdenv.isDarwin then "clang++" else "g++"}";
+  preConfigure = "export LD=${stdenv.cc.targetPrefix}c++";
 
   hardeningDisable = [ "format" ];
 
   NIX_CFLAGS_COMPILE =
     stdenv.lib.optionalString stdenv.isDarwin "-mmacosx-version-min=10.9";
 
-  buildInputs = [ unzip ];
+  nativeBuildInputs = [ unzip ];
   buildPhase = ''
     # use STL (xbmc requires it)
     sed '1i#define TIXML_USE_STL 1' -i tinyxml.h
diff --git a/pkgs/development/libraries/vulkan-loader/default.nix b/pkgs/development/libraries/vulkan-loader/default.nix
index 53f492bf8b0..e650a28c61e 100644
--- a/pkgs/development/libraries/vulkan-loader/default.nix
+++ b/pkgs/development/libraries/vulkan-loader/default.nix
@@ -12,8 +12,8 @@ stdenv.mkDerivation rec {
     sha256 = "12n4mxc6db89258k8i47ql1zna7k94lkwv7lpxg39nm8ypa1ywrv";
   };
 
-  nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ cmake python3 xlibsWrapper libxcb libXrandr libXext wayland ];
+  nativeBuildInputs = [ pkgconfig cmake ];
+  buildInputs = [ python3 xlibsWrapper libxcb libXrandr libXext wayland ];
   enableParallelBuilding = true;
 
   preConfigure = ''
diff --git a/pkgs/development/libraries/waylandpp/default.nix b/pkgs/development/libraries/waylandpp/default.nix
index 06faec558c0..59fac7bfe4a 100644
--- a/pkgs/development/libraries/waylandpp/default.nix
+++ b/pkgs/development/libraries/waylandpp/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, cmake, pkgconfig, pugixml, wayland, libGL }:
+{ stdenv, fetchFromGitHub, cmake, pkgconfig, pugixml, wayland, libGL, libffi, buildPackages }:
 
 stdenv.mkDerivation rec {
   pname = "waylandpp";
@@ -11,8 +11,10 @@ stdenv.mkDerivation rec {
     sha256 = "16h57hzd688664qcyznzhjp3hxipdkzgv46x82yhkww24av8b55n";
   };
 
+  cmakeFlags = stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "-DWAYLAND_SCANNERPP=${buildPackages.waylandpp}/bin/wayland-scanner++";
+
   nativeBuildInputs = [ cmake pkgconfig ];
-  buildInputs = [ pugixml wayland libGL ];
+  buildInputs = [ pugixml wayland libGL libffi ];
 
   meta = with stdenv.lib; {
     description = "Wayland C++ binding";
diff --git a/pkgs/development/python-modules/python-dbusmock/default.nix b/pkgs/development/python-modules/python-dbusmock/default.nix
index 3d6a4a7aee0..d643603a067 100644
--- a/pkgs/development/python-modules/python-dbusmock/default.nix
+++ b/pkgs/development/python-modules/python-dbusmock/default.nix
@@ -44,12 +44,12 @@ buildPythonPackage rec {
 
   checkInputs = [
     nose dbus dbus-python which pycodestyle pyflakes
-    pygobject3 bluez bluez.test networkmanager
+    pygobject3 bluez (lib.getOutput "test" bluez) networkmanager
   ];
 
   checkPhase = ''
     runHook preCheck
-    export PATH="$PATH:${bluez.test}/test";
+    export PATH="$PATH:${lib.getOutput "test" bluez}/test";
     nosetests -v
     runHook postCheck
   '';
diff --git a/pkgs/misc/emulators/retroarch/default.nix b/pkgs/misc/emulators/retroarch/default.nix
index a91e2de8593..28a641ec970 100644
--- a/pkgs/misc/emulators/retroarch/default.nix
+++ b/pkgs/misc/emulators/retroarch/default.nix
@@ -15,6 +15,8 @@
 , enableNvidiaCgToolkit ? false, nvidia_cg_toolkit ? null
 , withVulkan ? stdenv.isLinux, vulkan-loader ? null
 , fetchurl
+, wayland
+, libxkbcommon
 }:
 
 with stdenv.lib;
@@ -30,7 +32,7 @@ stdenv.mkDerivation rec {
     rev = "v${version}";
   };
 
-  nativeBuildInputs = [ pkgconfig ]
+  nativeBuildInputs = [ pkgconfig wayland ]
                       ++ optional withVulkan makeWrapper;
 
   buildInputs = [ ffmpeg freetype libxml2 libGLU libGL python3 SDL2 which ]
@@ -38,7 +40,11 @@ stdenv.mkDerivation rec {
                 ++ optional withVulkan vulkan-loader
                 ++ optionals stdenv.isDarwin [ libobjc AppKit Foundation ]
                 ++ optionals stdenv.isLinux [ alsaLib libdrm libpulseaudio libv4l libX11
-                                              libXdmcp libXext libXxf86vm mesa udev ];
+                                              libXdmcp libXext libXxf86vm mesa udev
+                                              wayland libxkbcommon ];
+
+  # we use prefix-less pkg-config
+  PKG_CONF_PATH = "pkg-config";
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/os-specific/linux/alsa-plugins/default.nix b/pkgs/os-specific/linux/alsa-plugins/default.nix
index b524d7906da..a69d86c5c4d 100644
--- a/pkgs/os-specific/linux/alsa-plugins/default.nix
+++ b/pkgs/os-specific/linux/alsa-plugins/default.nix
@@ -9,9 +9,11 @@ stdenv.mkDerivation rec {
     sha256 = "0z9k3ssbfk2ky2w13avgyf202j1drsz9sv3834bp33cj1i2hc3qw";
   };
 
+  nativeBuildInputs = [ pkgconfig ];
+
   # ToDo: a52, etc.?
   buildInputs =
-    [ pkgconfig alsaLib libogg ]
+    [ alsaLib libogg ]
     ++ lib.optional (libpulseaudio != null) libpulseaudio
     ++ lib.optional (libjack2 != null) libjack2;
 
diff --git a/pkgs/os-specific/linux/bluez/default.nix b/pkgs/os-specific/linux/bluez/default.nix
index 78d88d941e8..401ab39bca3 100644
--- a/pkgs/os-specific/linux/bluez/default.nix
+++ b/pkgs/os-specific/linux/bluez/default.nix
@@ -11,9 +11,13 @@
 , readline
 , systemd
 , udev
-}:
-
-stdenv.mkDerivation rec {
+}: let
+  pythonPath = with python3.pkgs; [
+    dbus-python
+    pygobject3
+    recursivePthLoader
+  ];
+in stdenv.mkDerivation rec {
   pname = "bluez";
   version = "5.54";
 
@@ -22,12 +26,6 @@ stdenv.mkDerivation rec {
     sha256 = "1p2ncvjz6alr9n3l5wvq2arqgc7xjs6dqyar1l9jp0z8cfgapkb8";
   };
 
-  pythonPath = with python3.pkgs; [
-    dbus-python
-    pygobject3
-    recursivePthLoader
-  ];
-
   buildInputs = [
     alsaLib
     dbus
@@ -44,7 +42,7 @@ stdenv.mkDerivation rec {
     python3.pkgs.wrapPython
   ];
 
-  outputs = [ "out" "dev" "test" ];
+  outputs = [ "out" "dev" ] ++ lib.optional doCheck "test";
 
   postPatch = ''
     substituteInPlace tools/hid2hci.rules \
@@ -79,7 +77,7 @@ stdenv.mkDerivation rec {
 
   doCheck = stdenv.hostPlatform.isx86_64;
 
-  postInstall = ''
+  postInstall = lib.optionalString doCheck ''
     mkdir -p $test/{bin,test}
     cp -a test $test
     pushd $test/test
@@ -94,8 +92,8 @@ stdenv.mkDerivation rec {
       ln -s ../test/$a $test/bin/bluez-$a
     done
     popd
-    wrapPythonProgramsIn $test/test "$test/test $pythonPath"
-
+    wrapPythonProgramsIn $test/test "$test/test ${toString pythonPath}"
+  '' + ''
     # for bluez4 compatibility for NixOS
     mkdir $out/sbin
     ln -s ../libexec/bluetooth/bluetoothd $out/sbin/bluetoothd
diff --git a/pkgs/os-specific/linux/plymouth/default.nix b/pkgs/os-specific/linux/plymouth/default.nix
index b4c4909cac5..7a6c227f401 100644
--- a/pkgs/os-specific/linux/plymouth/default.nix
+++ b/pkgs/os-specific/linux/plymouth/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, autoreconfHook, pkgconfig, libxslt, docbook_xsl
-, gtk3, udev, systemd
+, gtk3, udev, systemd, lib
 }:
 
 stdenv.mkDerivation rec {
@@ -44,6 +44,7 @@ stdenv.mkDerivation rec {
     "--enable-pango"
     "--enable-gdm-transition"
     "--enable-gtk"
+    "ac_cv_path_SYSTEMD_ASK_PASSWORD_AGENT=${lib.getBin systemd}/bin/systemd-tty-ask-password-agent"
   ];
 
   configurePlatforms = [ "host" ];
diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix
index e398b9b5d65..c6fe55ad9f7 100644
--- a/pkgs/servers/x11/xorg/overrides.nix
+++ b/pkgs/servers/x11/xorg/overrides.nix
@@ -256,6 +256,15 @@ self: super:
 
   libXres = super.libXres.overrideAttrs (attrs: {
     outputs = [ "out" "dev" "devdoc" ];
+    buildInputs = with self; attrs.buildInputs ++ [ utilmacros ];
+    configureFlags = attrs.configureFlags or []
+      ++ malloc0ReturnsNullCrossFlag;
+  });
+
+  libXScrnSaver = super.libXScrnSaver.overrideAttrs (attrs: {
+    buildInputs = with self; attrs.buildInputs ++ [ utilmacros ];
+    configureFlags = attrs.configureFlags or []
+      ++ malloc0ReturnsNullCrossFlag;
   });
 
   libXv = super.libXv.overrideAttrs (attrs: {
diff --git a/pkgs/tools/misc/dvtm/dvtm.nix b/pkgs/tools/misc/dvtm/dvtm.nix
index 61af9fac177..5bb8efb5540 100644
--- a/pkgs/tools/misc/dvtm/dvtm.nix
+++ b/pkgs/tools/misc/dvtm/dvtm.nix
@@ -9,6 +9,7 @@ stdenv.mkDerivation {
     cp ${builtins.toFile "config.h" customConfig} ./config.h
   '';
 
+  nativeBuildInputs = [ ncurses ];
   buildInputs = [ ncurses ];
 
   prePatch = ''
@@ -16,9 +17,7 @@ stdenv.mkDerivation {
       --replace /usr/share/terminfo $out/share/terminfo
   '';
 
-  installPhase = ''
-    make PREFIX=$out install
-  '';
+  makeFlags = [ "PREFIX=$(out)" ];
 
   meta = with stdenv.lib; {
     description = "Dynamic virtual terminal manager";
diff --git a/pkgs/top-level/unix-tools.nix b/pkgs/top-level/unix-tools.nix
index 56bab2fe411..cdad9de61f4 100644
--- a/pkgs/top-level/unix-tools.nix
+++ b/pkgs/top-level/unix-tools.nix
@@ -66,12 +66,12 @@ let
       linux = pkgs.utillinux;
     };
     getconf = {
-      linux = if stdenv.hostPlatform.libc == "glibc" then pkgs.glibc
+      linux = if stdenv.hostPlatform.libc == "glibc" then pkgs.stdenv.cc.libc
               else pkgs.netbsd.getconf;
       darwin = pkgs.darwin.system_cmds;
     };
     getent = {
-      linux = if stdenv.hostPlatform.libc == "glibc" then pkgs.glibc
+      linux = if stdenv.hostPlatform.libc == "glibc" then pkgs.stdenv.cc.libc
               else pkgs.netbsd.getent;
       darwin = pkgs.netbsd.getent;
     };