summary refs log tree commit diff
path: root/pkgs/servers
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2016-04-13 09:25:28 +0200
committerVladimír Čunát <vcunat@gmail.com>2016-04-13 09:25:28 +0200
commit39ebb01d6e8d19b042fe65d303234d0db27877eb (patch)
tree083025f5791bfce9f14e1d3f4c66035ef82ba72d /pkgs/servers
parent81cedab4f1fe9578e004ce03de5630a25c737a9e (diff)
parent87b49397bf1e26ac17c4a55fed41bd836fefc39d (diff)
downloadnixlib-39ebb01d6e8d19b042fe65d303234d0db27877eb.tar
nixlib-39ebb01d6e8d19b042fe65d303234d0db27877eb.tar.gz
nixlib-39ebb01d6e8d19b042fe65d303234d0db27877eb.tar.bz2
nixlib-39ebb01d6e8d19b042fe65d303234d0db27877eb.tar.lz
nixlib-39ebb01d6e8d19b042fe65d303234d0db27877eb.tar.xz
nixlib-39ebb01d6e8d19b042fe65d303234d0db27877eb.tar.zst
nixlib-39ebb01d6e8d19b042fe65d303234d0db27877eb.zip
Merge branch 'staging', containing closure-size #7701
Diffstat (limited to 'pkgs/servers')
-rw-r--r--pkgs/servers/dns/nsd/default.nix2
-rw-r--r--pkgs/servers/http/apache-httpd/2.2.nix30
-rw-r--r--pkgs/servers/http/apache-httpd/2.4.nix27
-rw-r--r--pkgs/servers/http/apache-modules/mod_fastcgi/default.nix2
-rw-r--r--pkgs/servers/http/nginx/default.nix2
-rw-r--r--pkgs/servers/http/nginx/unstable.nix2
-rw-r--r--pkgs/servers/http/nix-binary-cache/default.nix12
-rw-r--r--pkgs/servers/http/openresty/default.nix4
-rw-r--r--pkgs/servers/mail/opensmtpd/default.nix2
-rw-r--r--pkgs/servers/meteor/default.nix4
-rw-r--r--pkgs/servers/monitoring/net-snmp/default.nix6
-rw-r--r--pkgs/servers/nosql/arangodb/default.nix3
-rw-r--r--pkgs/servers/openafs-client/default.nix2
-rw-r--r--pkgs/servers/plex/default.nix4
-rw-r--r--pkgs/servers/pulseaudio/default.nix9
-rw-r--r--pkgs/servers/shellinabox/default.nix4
-rw-r--r--pkgs/servers/shishi/default.nix13
-rw-r--r--pkgs/servers/sql/mariadb/default.nix8
-rw-r--r--pkgs/servers/sql/monetdb/default.nix2
-rw-r--r--pkgs/servers/sql/postgresql/default.nix16
-rw-r--r--pkgs/servers/x11/xorg/builder.sh6
-rw-r--r--pkgs/servers/x11/xorg/default.nix15
-rw-r--r--pkgs/servers/x11/xorg/imake-cc-wrapper-uberhack.patch13
-rw-r--r--pkgs/servers/x11/xorg/overrides.nix130
-rw-r--r--pkgs/servers/x11/xquartz/default.nix2
25 files changed, 243 insertions, 77 deletions
diff --git a/pkgs/servers/dns/nsd/default.nix b/pkgs/servers/dns/nsd/default.nix
index d11ef186c319..646e50c78f95 100644
--- a/pkgs/servers/dns/nsd/default.nix
+++ b/pkgs/servers/dns/nsd/default.nix
@@ -35,7 +35,7 @@ stdenv.mkDerivation rec {
      ++ edf rootServer       "root-server"
      ++ edf rrtypes          "draft-rrtypes"
      ++ edf zoneStats        "zone-stats"
-     ++ [ "--with-ssl=${openssl}" "--with-libevent=${libevent}" ];
+     ++ [ "--with-ssl=${openssl.dev}" "--with-libevent=${libevent.dev}" ];
 
   meta = with stdenv.lib; {
     homepage = http://www.nlnetlabs.nl;
diff --git a/pkgs/servers/http/apache-httpd/2.2.nix b/pkgs/servers/http/apache-httpd/2.2.nix
index 99d6fe12aa1c..bb4fa9782d6a 100644
--- a/pkgs/servers/http/apache-httpd/2.2.nix
+++ b/pkgs/servers/http/apache-httpd/2.2.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, openssl, perl, zlib
+{ stdenv, fetchurl, pkgconfig, openssl, perl, zlib
 , sslSupport, proxySupport ? true
 , apr, aprutil, pcre
 , ldapSupport ? true, openldap
@@ -20,17 +20,24 @@ stdenv.mkDerivation rec {
     sha256 = "1b165zi7jrrlz5wmyy3b34lcs3dl4g0dymfb0qxwdnimylcrsbzk";
   };
 
-  buildInputs = [perl apr aprutil pcre] ++
-    stdenv.lib.optional sslSupport openssl;
+  # FIXME: -dev depends on -doc
+  outputs = [ "dev" "out" "doc" ];
+  setOutputFlags = false; # it would move $out/modules, etc.
 
-  # An apr-util header file includes an apr header file
-  # through #include "" (quotes)
-  # passing simply CFLAGS did not help, then I go by NIX_CFLAGS_COMPILE
-  NIX_CFLAGS_COMPILE = "-iquote ${apr}/include/apr-1";
+  propagatedBuildInputs = [ apr ]; # otherwise mod_* fail to find includes often
+  buildInputs = [ pkgconfig perl aprutil pcre zlib ] ++
+    stdenv.lib.optional sslSupport openssl;
 
   # Required for ‘pthread_cancel’.
   NIX_LDFLAGS = (if stdenv.isDarwin then "" else "-lgcc_s");
 
+  patchPhase = ''
+    sed -i config.layout -e "s|installbuilddir:.*|installbuilddir: $dev/share/build|"
+  '';
+
+  preConfigure = ''
+    configureFlags="$configureFlags --includedir=$dev/include"
+  '';
   configureFlags = ''
     --with-z=${zlib}
     --with-pcre=${pcre}
@@ -44,13 +51,18 @@ stdenv.mkDerivation rec {
     --enable-disk-cache
     --enable-file-cache
     --enable-mem-cache
+    --docdir=$(doc)/share/doc
   '';
 
   enableParallelBuilding = true;
 
+  stripDebugList = "lib modules bin";
+
   postInstall = ''
-    echo "removing manual"
-    rm -rf $out/manual
+    mkdir -p $doc/share/doc/httpd
+    mv $out/manual $doc/share/doc/httpd
+    mkdir -p $dev/bin
+    mv $out/bin/apxs $dev/bin/apxs
   '';
 
   passthru = {
diff --git a/pkgs/servers/http/apache-httpd/2.4.nix b/pkgs/servers/http/apache-httpd/2.4.nix
index a2e039bd399f..a39d0e8e3158 100644
--- a/pkgs/servers/http/apache-httpd/2.4.nix
+++ b/pkgs/servers/http/apache-httpd/2.4.nix
@@ -24,15 +24,27 @@ stdenv.mkDerivation rec {
     sha256 = "0k7xm6ldzvakzq39nw6b39190ihlkc28all2gkvckxa1vr8b0i06";
   };
 
+  # FIXME: -dev depends on -doc
+  outputs = [ "dev" "out" "doc" ];
+  setOutputFlags = false; # it would move $out/modules, etc.
+
   buildInputs = [perl] ++
+    optional sslSupport openssl ++
     optional ldapSupport openldap ++    # there is no --with-ldap flag
     optional libxml2Support libxml2 ++
     optional http2Support libnghttp2 ++
     optional stdenv.isDarwin libiconv;
 
+  patchPhase = ''
+    sed -i config.layout -e "s|installbuilddir:.*|installbuilddir: $dev/share/build|"
+  '';
+
   # Required for ‘pthread_cancel’.
   NIX_LDFLAGS = stdenv.lib.optionalString (!stdenv.isDarwin) "-lgcc_s";
 
+  preConfigure = ''
+    configureFlags="$configureFlags --includedir=$dev/include"
+  '';
   configureFlags = ''
     --with-apr=${apr}
     --with-apr-util=${aprutil}
@@ -46,19 +58,22 @@ stdenv.mkDerivation rec {
     --enable-imagemap
     --enable-cgi
     ${optionalString proxySupport "--enable-proxy"}
-    ${optionalString sslSupport "--enable-ssl --with-ssl=${openssl}"}
+    ${optionalString sslSupport "--enable-ssl"}
     ${optionalString http2Support "--enable-http2 --with-nghttp2=${libnghttp2}"}
     ${optionalString luaSupport "--enable-lua --with-lua=${lua5}"}
-    ${optionalString libxml2Support "--with-libxml2=${libxml2}/include/libxml2"}
+    ${optionalString libxml2Support "--with-libxml2=${libxml2.dev}/include/libxml2"}
+    --docdir=$(doc)/share/doc
   '';
 
+  enableParallelBuilding = true;
+
   postInstall = ''
-    echo "removing manual"
-    rm -rf $out/manual
+    mkdir -p $doc/share/doc/httpd
+    mv $out/manual $doc/share/doc/httpd
+    mkdir -p $dev/bin
+    mv $out/bin/apxs $dev/bin/apxs
   '';
 
-  enableParallelBuilding = true;
-
   passthru = {
     inherit apr aprutil sslSupport proxySupport ldapSupport;
   };
diff --git a/pkgs/servers/http/apache-modules/mod_fastcgi/default.nix b/pkgs/servers/http/apache-modules/mod_fastcgi/default.nix
index e70c3105408f..178900570d07 100644
--- a/pkgs/servers/http/apache-modules/mod_fastcgi/default.nix
+++ b/pkgs/servers/http/apache-modules/mod_fastcgi/default.nix
@@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
 
   preBuild = ''
     cp Makefile.AP2 Makefile
-    makeFlags="top_dir=${apacheHttpd} prefix=$out"
+    makeFlags="top_dir=${apacheHttpd}/share prefix=$out"
   '';
 
   meta = {
diff --git a/pkgs/servers/http/nginx/default.nix b/pkgs/servers/http/nginx/default.nix
index 178c0fcbd9e4..b3bc092dc401 100644
--- a/pkgs/servers/http/nginx/default.nix
+++ b/pkgs/servers/http/nginx/default.nix
@@ -52,7 +52,7 @@ stdenv.mkDerivation rec {
         [ "--with-file-aio" "--with-aio_module" ]
     ++ map (mod: "--add-module=${mod.src}") modules;
 
-  NIX_CFLAGS_COMPILE = [ "-I${libxml2}/include/libxml2" ] ++ optional stdenv.isDarwin "-Wno-error=deprecated-declarations -Wno-error=conditional-uninitialized";
+  NIX_CFLAGS_COMPILE = [ "-I${libxml2.dev}/include/libxml2" ] ++ optional stdenv.isDarwin "-Wno-error=deprecated-declarations -Wno-error=conditional-uninitialized";
 
   preConfigure = (concatMapStringsSep "\n" (mod: mod.preConfigure or "") modules)
     + optionalString (hardening && (stdenv.cc.cc.isGNU or false)) ''
diff --git a/pkgs/servers/http/nginx/unstable.nix b/pkgs/servers/http/nginx/unstable.nix
index e85fb96d2edb..257cf96b4a70 100644
--- a/pkgs/servers/http/nginx/unstable.nix
+++ b/pkgs/servers/http/nginx/unstable.nix
@@ -50,7 +50,7 @@ stdenv.mkDerivation rec {
     ++ optional (elem stdenv.system (with platforms; linux ++ freebsd)) "--with-file-aio"
     ++ map (mod: "--add-module=${mod.src}") modules;
 
-  NIX_CFLAGS_COMPILE = [ "-I${libxml2}/include/libxml2" ] ++ optional stdenv.isDarwin "-Wno-error=deprecated-declarations";
+  NIX_CFLAGS_COMPILE = [ "-I${libxml2.dev}/include/libxml2" ] ++ optional stdenv.isDarwin "-Wno-error=deprecated-declarations";
 
   preConfigure = (concatMapStringsSep "\n" (mod: mod.preConfigure or "") modules)
     + optionalString (hardening && (stdenv.cc.cc.isGNU or false)) ''
diff --git a/pkgs/servers/http/nix-binary-cache/default.nix b/pkgs/servers/http/nix-binary-cache/default.nix
index b007c09b0560..674557d74fc2 100644
--- a/pkgs/servers/http/nix-binary-cache/default.nix
+++ b/pkgs/servers/http/nix-binary-cache/default.nix
@@ -15,11 +15,11 @@ stdenv.mkDerivation rec {
       --replace @coreutils@ "${coreutils}/bin" \
       --replace @findutils@ "${findutils}/bin" \
       --replace @nix@ "${nix}/bin" \
-      --replace @xz@ "${xz}/bin" \
-      --replace @bzip2@ "${bzip2}/bin" \
+      --replace @xz@ "${xz.bin}/bin" \
+      --replace @bzip2@ "${bzip2.bin}/bin" \
       --replace @gnused@ "${gnused}/bin" \
       --replace @gnugrep@ "${gnugrep}/bin" \
-      --replace @openssl@ "${openssl}/bin" \
+      --replace @openssl@ "${openssl.bin}/bin" \
       --replace @lighttpd@ "${lighttpd}/sbin" \
       --replace @iproute@ "${iproute}/sbin" \
       --replace "xXxXx" "xXxXx"
@@ -32,11 +32,11 @@ stdenv.mkDerivation rec {
       --replace @coreutils@ "${coreutils}/bin" \
       --replace @findutils@ "${findutils}/bin" \
       --replace @nix@ "${nix}/bin" \
-      --replace @xz@ "${xz}/bin" \
-      --replace @bzip2@ "${bzip2}/bin" \
+      --replace @xz@ "${xz.bin}/bin" \
+      --replace @bzip2@ "${bzip2.bin}/bin" \
       --replace @gnused@ "${gnused}/bin" \
       --replace @gnugrep@ "${gnugrep}/bin" \
-      --replace @openssl@ "${openssl}/bin" \
+      --replace @openssl@ "${openssl.bin}/bin" \
       --replace @lighttpd@ "${lighttpd}/sbin" \
       --replace @iproute@ "${iproute}/sbin" \
       --replace "xXxXx" "xXxXx"
diff --git a/pkgs/servers/http/openresty/default.nix b/pkgs/servers/http/openresty/default.nix
index 14f95761cfb1..147e24c014d2 100644
--- a/pkgs/servers/http/openresty/default.nix
+++ b/pkgs/servers/http/openresty/default.nix
@@ -46,8 +46,8 @@ stdenv.mkDerivation rec {
   '';
 
   preConfigure = ''
-    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${libxml2}/include/libxml2 $additionalFlags"
-    export PATH="$PATH:${stdenv.cc.libc}/sbin"
+    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${libxml2.dev}/include/libxml2 $additionalFlags"
+    export PATH="$PATH:${stdenv.cc.libc.bin}/bin"
     patchShebangs .
   '';
 
diff --git a/pkgs/servers/mail/opensmtpd/default.nix b/pkgs/servers/mail/opensmtpd/default.nix
index 5e3f084674b2..94bc9f2bfe98 100644
--- a/pkgs/servers/mail/opensmtpd/default.nix
+++ b/pkgs/servers/mail/opensmtpd/default.nix
@@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
     "--with-privsep-user=smtpd"
     "--with-queue-user=smtpq"
     "--with-ca-file=/etc/ssl/certs/ca-certificates.crt"
-    "--with-libevent-dir=${libevent}"
+    "--with-libevent-dir=${libevent.dev}"
     "--enable-table-db"
   ];
 
diff --git a/pkgs/servers/meteor/default.nix b/pkgs/servers/meteor/default.nix
index 5e13b4520c9b..7412378f3dec 100644
--- a/pkgs/servers/meteor/default.nix
+++ b/pkgs/servers/meteor/default.nix
@@ -40,7 +40,7 @@ stdenv.mkDerivation rec {
     popd
     substituteInPlace $out/tools/cli/main.js \
       --replace "@INTERPRETER@" "$(cat $NIX_CC/nix-support/dynamic-linker)" \
-      --replace "@RPATH@" "${stdenv.cc.cc}/lib:${zlib}/lib" \
+      --replace "@RPATH@" "${stdenv.cc.cc}/lib:${zlib.out}/lib" \
       --replace "@PATCHELF@" "${patchelf}/bin/patchelf"
 
     # Patch node.
@@ -54,7 +54,7 @@ stdenv.mkDerivation rec {
     for p in $devBundle/mongodb/bin/mongo{,d}; do
       patchelf \
         --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
-        --set-rpath "$(patchelf --print-rpath $p):${stdenv.cc.cc}/lib:${zlib}/lib" \
+        --set-rpath "$(patchelf --print-rpath $p):${stdenv.cc.cc}/lib:${zlib.out}/lib" \
         $p
     done
 
diff --git a/pkgs/servers/monitoring/net-snmp/default.nix b/pkgs/servers/monitoring/net-snmp/default.nix
index f2533c99b083..816ac1bdb25e 100644
--- a/pkgs/servers/monitoring/net-snmp/default.nix
+++ b/pkgs/servers/monitoring/net-snmp/default.nix
@@ -31,6 +31,12 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
+  postInstall = ''
+    for f in $out/lib/*.la $out/bin/net-snmp-config $out/bin/net-snmp-create-v3-user; do
+      sed 's|-L${openssl}|-L${openssl.out}|g' -i $f
+    done
+  '';
+
   meta = with stdenv.lib; {
     description = "Clients and server for the SNMP network monitoring protocol";
     homepage = http://net-snmp.sourceforge.net/;
diff --git a/pkgs/servers/nosql/arangodb/default.nix b/pkgs/servers/nosql/arangodb/default.nix
index 7ccd29bc783a..ffcd507653a0 100644
--- a/pkgs/servers/nosql/arangodb/default.nix
+++ b/pkgs/servers/nosql/arangodb/default.nix
@@ -15,9 +15,10 @@ stdenv.mkDerivation rec {
     openssl zlib python gyp go readline
   ];
 
+  configureFlagsArray = [ "--with-openssl-lib=${openssl.out}/lib" ];
+
   NIX_CFLAGS_COMPILE = "-Wno-error=strict-overflow";
 
-  configureFlagsArray = [ "--with-openssl-lib=${openssl}/lib" ];
 
   patchPhase = ''
     substituteInPlace 3rdParty/V8-3.31.74.1/build/gyp/gyp --replace /bin/bash ${bash}/bin/bash
diff --git a/pkgs/servers/openafs-client/default.nix b/pkgs/servers/openafs-client/default.nix
index abc6d78f20c7..40d3edcf21a4 100644
--- a/pkgs/servers/openafs-client/default.nix
+++ b/pkgs/servers/openafs-client/default.nix
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
     for i in `grep -l -R '/usr/\(include\|src\)' .`; do
       echo "Patch /usr/include and /usr/src in $i"
       substituteInPlace $i \
-        --replace "/usr/include" "${glibc}/include" \
+        --replace "/usr/include" "${glibc.dev}/include" \
         --replace "/usr/src" "$TMP"
     done
 
diff --git a/pkgs/servers/plex/default.nix b/pkgs/servers/plex/default.nix
index ac54e8af9aa0..22a5c852e15d 100644
--- a/pkgs/servers/plex/default.nix
+++ b/pkgs/servers/plex/default.nix
@@ -40,12 +40,12 @@ in stdenv.mkDerivation rec {
     # Now we need to patch up the executables and libraries to work on Nix.
     # Side note: PLEASE don't put spaces in your binary names. This is stupid.
     for bin in "Plex Media Server" "Plex DLNA Server" "Plex Media Scanner"; do
-      patchelf --set-interpreter "${glibc}/lib/ld-linux-x86-64.so.2" "$out/usr/lib/plexmediaserver/$bin"
+      patchelf --set-interpreter "${glibc.out}/lib/ld-linux-x86-64.so.2" "$out/usr/lib/plexmediaserver/$bin"
       patchelf --set-rpath "$out/usr/lib/plexmediaserver" "$out/usr/lib/plexmediaserver/$bin"
     done
 
     find $out/usr/lib/plexmediaserver/Resources -type f -a -perm -0100 \
-        -print -exec patchelf --set-interpreter "${glibc}/lib/ld-linux-x86-64.so.2" '{}' \;
+        -print -exec patchelf --set-interpreter "${glibc.out}/lib/ld-linux-x86-64.so.2" '{}' \;
 
     # executables need libstdc++.so.6
     ln -s "${stdenv.lib.makeLibraryPath [ stdenv.cc.cc ]}/libstdc++.so.6" "$out/usr/lib/plexmediaserver/libstdc++.so.6"
diff --git a/pkgs/servers/pulseaudio/default.nix b/pkgs/servers/pulseaudio/default.nix
index 896b41f6780d..02f5363be8e7 100644
--- a/pkgs/servers/pulseaudio/default.nix
+++ b/pkgs/servers/pulseaudio/default.nix
@@ -43,6 +43,8 @@ stdenv.mkDerivation rec {
 
   patches = [ ./caps-fix.patch ];
 
+  outputs = [ "dev" "out" ];
+
   nativeBuildInputs = [ pkgconfig intltool autoreconfHook ];
 
   propagatedBuildInputs =
@@ -50,7 +52,7 @@ stdenv.mkDerivation rec {
 
   buildInputs =
     [ json_c libsndfile speexdsp fftwFloat ]
-    ++ lib.optionals stdenv.isLinux [ glib dbus.libs ]
+    ++ lib.optionals stdenv.isLinux [ glib dbus ]
     ++ lib.optionals (!libOnly) (
       [ libasyncns webrtc-audio-processing ]
       ++ lib.optional jackaudioSupport libjack2
@@ -110,8 +112,9 @@ stdenv.mkDerivation rec {
 
   postInstall = lib.optionalString libOnly ''
     rm -rf $out/{bin,share,etc,lib/{pulse-*,systemd}}
-    sed 's|-lltdl|-L${libtool}/lib -lltdl|' -i $out/lib/pulseaudio/libpulsecore-${version}.la
-  '';
+    sed 's|-lltdl|-L${libtool.lib}/lib -lltdl|' -i $out/lib/pulseaudio/libpulsecore-${version}.la
+  ''
+    + ''moveToOutput lib/cmake "$dev" '';
 
   meta = {
     description = "Sound server for POSIX and Win32 systems";
diff --git a/pkgs/servers/shellinabox/default.nix b/pkgs/servers/shellinabox/default.nix
index 0a651762f185..c9f4e2d253f9 100644
--- a/pkgs/servers/shellinabox/default.nix
+++ b/pkgs/servers/shellinabox/default.nix
@@ -22,12 +22,12 @@ stdenv.mkDerivation rec {
     substituteInPlace ./shellinabox/launcher.c --replace "/usr/games" "${openssh}/bin"
     substituteInPlace ./shellinabox/service.c --replace "/bin/login" "${shadow}/bin/login"
     substituteInPlace ./shellinabox/launcher.c --replace "/bin/login" "${shadow}/bin/login"
-    substituteInPlace ./libhttp/ssl.c --replace "/usr/bin" "${openssl}/bin"
+    substituteInPlace ./libhttp/ssl.c --replace "/usr/bin" "${openssl.bin}/bin"
   '';
 
   postInstall = ''
     wrapProgram $out/bin/shellinaboxd \
-      --prefix LD_LIBRARY_PATH : ${openssl}/lib
+      --prefix LD_LIBRARY_PATH : ${openssl.out}/lib
     mkdir -p $out/lib
     cp shellinabox/* $out/lib
   '';
diff --git a/pkgs/servers/shishi/default.nix b/pkgs/servers/shishi/default.nix
index e26fd6ca749e..85dfa805fc14 100644
--- a/pkgs/servers/shishi/default.nix
+++ b/pkgs/servers/shishi/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl
+{ stdenv, fetchurl, pkgconfig
 , libgcrypt, libgpgerror, libtasn1
 
 # Optional Dependencies
@@ -31,6 +31,7 @@ stdenv.mkDerivation rec {
   # Fixes support for gcrypt 1.6+
   patches = [ ./gcrypt-fix.patch ./freebsd-unistd.patch ];
 
+  nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ libgcrypt libgpgerror libtasn1 optPam optLibidn optGnutls ];
 
   configureFlags = [
@@ -60,13 +61,13 @@ stdenv.mkDerivation rec {
   postInstall = ''
     sed -i $out/lib/libshi{sa,shi}.la \
   '' + optionalString (optLibidn != null) ''
-      -e 's,\(-lidn\),-L${optLibidn}/lib \1,' \
+      -e 's,\(-lidn\),-L${optLibidn.out}/lib \1,' \
   '' + optionalString (optGnutls != null) ''
-      -e 's,\(-lgnutls\),-L${optGnutls}/lib \1,' \
+      -e 's,\(-lgnutls\),-L${optGnutls.out}/lib \1,' \
   '' + ''
-      -e 's,\(-lgcrypt\),-L${libgcrypt}/lib \1,' \
-      -e 's,\(-lgpg-error\),-L${libgpgerror}/lib \1,' \
-      -e 's,\(-ltasn1\),-L${libtasn1}/lib \1,'
+      -e 's,\(-lgcrypt\),-L${libgcrypt.out}/lib \1,' \
+      -e 's,\(-lgpg-error\),-L${libgpgerror.out}/lib \1,' \
+      -e 's,\(-ltasn1\),-L${libtasn1.out}/lib \1,'
   '';
 
   meta = {
diff --git a/pkgs/servers/sql/mariadb/default.nix b/pkgs/servers/sql/mariadb/default.nix
index 9ca1a23ea345..6091703c52cd 100644
--- a/pkgs/servers/sql/mariadb/default.nix
+++ b/pkgs/servers/sql/mariadb/default.nix
@@ -60,13 +60,15 @@ stdenv.mkDerivation rec {
   ] ++ stdenv.lib.optionals stdenv.isDarwin [
     "-DWITHOUT_OQGRAPH_STORAGE_ENGINE=1"
     "-DWITHOUT_TOKUDB=1"
-    "-DCURSES_LIBRARY=${ncurses}/lib/libncurses.dylib"
+    "-DCURSES_LIBRARY=${ncurses.out}/lib/libncurses.dylib"
   ];
 
   # fails to find lex_token.h sometimes
   enableParallelBuilding = false;
 
   outputs = [ "out" "lib" ];
+  setOutputFlags = false;
+  moveToDev = false;
 
   prePatch = ''
     substituteInPlace cmake/libutils.cmake \
@@ -112,8 +114,8 @@ stdenv.mkDerivation rec {
   '' + ''
     # Fix the mysql_config
     sed -i $out/bin/mysql_config \
-      -e 's,-lz,-L${zlib}/lib -lz,g' \
-      -e 's,-lssl,-L${openssl}/lib -lssl,g'
+      -e 's,-lz,-L${zlib.out}/lib -lz,g' \
+      -e 's,-lssl,-L${openssl.out}/lib -lssl,g'
 
     # Add mysql_config to libs since configure scripts use it
     mkdir -p $lib/bin
diff --git a/pkgs/servers/sql/monetdb/default.nix b/pkgs/servers/sql/monetdb/default.nix
index afd2222918eb..443dafef55ca 100644
--- a/pkgs/servers/sql/monetdb/default.nix
+++ b/pkgs/servers/sql/monetdb/default.nix
@@ -17,7 +17,7 @@ composableDerivation.composableDerivation {} {
             /* perl TODO export these (SWIG only if its present) HAVE_PERL=1 HAVE_PERL_DEVEL=1 HAVE_PERL_SWIG=1 */
           };
 
-  buildInputs = [ (pcre.override { unicodeSupport = true; })
+  buildInputs = [ pcre
                    openssl readline libxml2 ]; # optional python perl php java ?
 
   cfg = {
diff --git a/pkgs/servers/sql/postgresql/default.nix b/pkgs/servers/sql/postgresql/default.nix
index bba2bf2d6825..5fec92a5bf8a 100644
--- a/pkgs/servers/sql/postgresql/default.nix
+++ b/pkgs/servers/sql/postgresql/default.nix
@@ -10,7 +10,8 @@ let
       inherit sha256;
     };
 
-    outputs = [ "out" "doc" ];
+    outputs = [ "out" "lib" "doc" ];
+    setOutputFlags = false; # $out retains configureFlags :-/
 
     buildInputs =
       [ zlib readline openssl ]
@@ -20,8 +21,11 @@ let
 
     makeFlags = [ "world" ];
 
-    configureFlags =
-      [ "--with-openssl" ]
+    configureFlags = [
+      "--with-openssl"
+      "--sysconfdir=/etc"
+      "--libdir=$(lib)/lib"
+    ]
       ++ lib.optional (stdenv.isDarwin)  "--with-uuid=e2fs"
       ++ lib.optional (!stdenv.isDarwin) "--with-ossp-uuid";
 
@@ -36,8 +40,12 @@ let
 
     postInstall =
       ''
+        moveToOutput "lib/pgxs" "$out" # looks strange, but not deleting it
+        moveToOutput "lib/*.a" "$out"
+        moveToOutput "lib/libecpg*" "$out"
+
         # Prevent a retained dependency on gcc-wrapper.
-        substituteInPlace $out/lib/pgxs/src/Makefile.global --replace ${stdenv.cc}/bin/ld ld
+        substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv.cc}/bin/ld ld
       '';
 
     disallowedReferences = [ stdenv.cc ];
diff --git a/pkgs/servers/x11/xorg/builder.sh b/pkgs/servers/x11/xorg/builder.sh
index f5b8803a98a3..c9e53f3800d3 100644
--- a/pkgs/servers/x11/xorg/builder.sh
+++ b/pkgs/servers/x11/xorg/builder.sh
@@ -10,7 +10,7 @@ postInstall() {
 
     local r p requires
     set +o pipefail
-    requires=$(grep "Requires:" $out/lib/pkgconfig/*.pc | \
+    requires=$(grep "Requires:" ${!outputDev}/lib/pkgconfig/*.pc | \
         sed "s/Requires://" | sed "s/,/ /g")
     set -o pipefail
 
@@ -33,10 +33,6 @@ postInstall() {
             done
         fi
     done
-
-    mkdir -p "$out/nix-support"
-    echo "$propagatedBuildInputs" > "$out/nix-support/propagated-build-inputs"
-    echo "$propagatedNativeBuildInputs" > "$out/nix-support/propagated-native-build-inputs"
 }
 
 
diff --git a/pkgs/servers/x11/xorg/default.nix b/pkgs/servers/x11/xorg/default.nix
index bb9e73d31cd3..7ba97cf35b04 100644
--- a/pkgs/servers/x11/xorg/default.nix
+++ b/pkgs/servers/x11/xorg/default.nix
@@ -2347,6 +2347,21 @@ let
     meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit dri2proto dri3proto renderproto libdrm openssl libX11 libXau libXaw libxcb xcbutil xcbutilwm xcbutilimage xcbutilkeysyms xcbutilrenderutil libXdmcp libXfixes libxkbfile libXmu libXpm libXrender libXres libXt ;};
 
+  # TODO:
+  # With the current state of ./generate-expr-from-tarballs.pl,
+  # this will get overwritten when next invoked.
+  # Could add a special case to ./generate-expr-from-tarballs.pl,
+  # or perhaps there's a cleaner solution.
+  #xquartz = (mkDerivation "xquartz" {
+  #  name = "xorg-server-1.14.6";
+  #  builder = ./builder.sh;
+  #  src = fetchurl {
+  #    url = mirror://xorg/individual/xserver/xorg-server-1.14.6.tar.bz2;
+  #    sha256 = "0c57vp1z0p38dj5gfipkmlw6bvbz1mrr0sb3sbghdxxdyq4kzcz8";
+  #  };
+  #  buildInputs = [pkgconfig renderproto libdrm openssl libX11 libXau libXaw libXdmcp libXfixes libxkbfile libXmu libXpm libXrender libXres libXt libXv ];
+  #}) // {inherit renderproto libdrm openssl libX11 libXau libXaw libXdmcp libXfixes libxkbfile libXmu libXpm libXrender libXres libXt libXv ;};
+
   xorgsgmldoctools = (mkDerivation "xorgsgmldoctools" {
     name = "xorg-sgml-doctools-1.11";
     builder = ./builder.sh;
diff --git a/pkgs/servers/x11/xorg/imake-cc-wrapper-uberhack.patch b/pkgs/servers/x11/xorg/imake-cc-wrapper-uberhack.patch
new file mode 100644
index 000000000000..fe079eeb42a7
--- /dev/null
+++ b/pkgs/servers/x11/xorg/imake-cc-wrapper-uberhack.patch
@@ -0,0 +1,13 @@
+diff --git a/imake.c b/imake.c
+index c20cd4a..ec2589b 100644
+--- a/imake.c
++++ b/imake.c
+@@ -959,7 +959,7 @@ get_libc_version(FILE *inFile)
+ {
+   char aout[4096], *tmpdir;
+   FILE *fp;
+-  const char *format = "%s -o %s -x c -";
++  const char *format = "f=$(mktemp imakeXXXXXX.c); cat > $f; %s $f -o %s";
+   char *cc;
+   int len;
+   char *command;
diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix
index 7bd179067cd0..a0405ec077f3 100644
--- a/pkgs/servers/x11/xorg/overrides.nix
+++ b/pkgs/servers/x11/xorg/overrides.nix
@@ -48,7 +48,7 @@ in
   imake = attrs: attrs // {
     inherit (xorg) xorgcffiles;
     x11BuildHook = ./imake.sh;
-    patches = [./imake.patch];
+    patches = [./imake.patch ./imake-cc-wrapper-uberhack.patch];
     setupHook = if stdenv.isDarwin then ./darwin-imake-setup-hook.sh else null;
     CFLAGS = [ "-DIMAKE_COMPILETIME_CPP=\\\"${if stdenv.isDarwin
       then "${args.tradcpp}/bin/cpp"
@@ -73,7 +73,7 @@ in
   libxcb = attrs : attrs // {
     nativeBuildInputs = [ args.python ];
     configureFlags = "--enable-xkb --enable-xinput";
-    outputs = [ "out" "doc" "man" ];
+    outputs = [ "dev" "out" "doc" ];
   };
 
   xcbproto = attrs : attrs // {
@@ -81,6 +81,7 @@ in
   };
 
   libX11 = attrs: attrs // {
+    outputs = [ "dev" "out" "man" ];
     preConfigure = setMalloc0ReturnsNullCrossCompiling + ''
       sed 's,^as_dummy.*,as_dummy="\$PATH",' -i configure
     '';
@@ -90,7 +91,6 @@ in
         rm -rf $out/share/doc
       '';
     CPP = stdenv.lib.optionalString stdenv.isDarwin "clang -E -";
-    outputs = [ "out" "man" ];
   };
 
   libAppleWM = attrs: attrs // {
@@ -100,7 +100,16 @@ in
     '';
   };
 
+  libXau = attrs: attrs // {
+    outputs = [ "dev" "out" ];
+  };
+
+  libXdmcp = attrs: attrs // {
+    outputs = [ "dev" "out" "doc" ];
+  };
+
   libXfont = attrs: attrs // {
+    outputs = [ "dev" "out" ];
     propagatedBuildInputs = [ args.freetype ]; # propagate link reqs. like bzip2
     # prevents "misaligned_stack_error_entering_dyld_stub_binder"
     configureFlags = lib.optionals isDarwin [
@@ -109,14 +118,10 @@ in
   };
 
   libXxf86vm = attrs: attrs // {
+    outputs = [ "dev" "out" ];
     preConfigure = setMalloc0ReturnsNullCrossCompiling;
   };
 
-  libXrandr = attrs: attrs // {
-    preConfigure = setMalloc0ReturnsNullCrossCompiling;
-    propagatedBuildInputs = [xorg.libXrender];
-  };
-
   # Propagate some build inputs because of header file dependencies.
   # Note: most of these are in Requires.private, so maybe builder.sh
   # should propagate them automatically.
@@ -126,7 +131,7 @@ in
     '';
     propagatedBuildInputs = [ xorg.libSM ];
     CPP = stdenv.lib.optionalString stdenv.isDarwin "clang -E -";
-    outputs = [ "out" "doc" "man" ];
+    outputs = [ "dev" "out" "docdev" ];
   };
 
   # See https://bugs.freedesktop.org/show_bug.cgi?id=47792
@@ -139,44 +144,106 @@ in
     propagatedBuildInputs = [ xorg.fixesproto ];
   };
 
+  libICE = attrs: attrs // {
+    outputs = [ "dev" "out" "doc" ];
+  };
+
   libXcomposite = attrs: attrs // {
+    outputs = [ "dev" "out" ];
     propagatedBuildInputs = [ xorg.libXfixes ];
   };
 
   libXaw = attrs: attrs // {
+    outputs = [ "dev" "out" "docdev" ];
     propagatedBuildInputs = [ xorg.libXmu ];
   };
 
+  libXcursor = attrs: attrs // {
+    outputs = [ "dev" "out" ];
+  };
+
+  libXdamage = attrs: attrs // {
+    outputs = [ "dev" "out" ];
+  };
+
   libXft = attrs: attrs // {
+    outputs = [ "dev" "out" ];
     propagatedBuildInputs = [ xorg.libXrender args.freetype args.fontconfig ];
     preConfigure = setMalloc0ReturnsNullCrossCompiling;
     # the include files need ft2build.h, and Requires.private isn't enough for us
     postInstall = ''
-      sed "/^Requires:/s/$/, freetype2/" -i "$out/lib/pkgconfig/xft.pc"
+      sed "/^Requires:/s/$/, freetype2/" -i "$dev/lib/pkgconfig/xft.pc"
     '';
   };
 
   libXext = attrs: attrs // {
+    outputs = [ "dev" "out" "doc" ];
     propagatedBuildInputs = [ xorg.xproto xorg.libXau ];
     preConfigure = setMalloc0ReturnsNullCrossCompiling;
   };
 
-  libSM = attrs: attrs
-    // { propagatedBuildInputs = [ xorg.libICE ]; };
+  libXfixes = attrs: attrs // {
+    outputs = [ "dev" "out" ];
+  };
+
+  libXi = attrs: attrs // {
+    outputs = [ "dev" "out" "doc" ];
+  };
+
+  libXinerama = attrs: attrs // {
+    outputs = [ "dev" "out" ];
+  };
+
+  libXmu = attrs: attrs // {
+    outputs = [ "dev" "out" "doc" ];
+    buildFlags = ''BITMAP_DEFINES=-DBITMAPDIR=\"/no-such-path\"'';
+  };
+
+  libXrandr = attrs: attrs // {
+    outputs = [ "dev" "out" ];
+    preConfigure = setMalloc0ReturnsNullCrossCompiling;
+    propagatedBuildInputs = [xorg.libXrender];
+  };
+
+  libSM = attrs: attrs // {
+    outputs = [ "dev" "out" "doc" ];
+    propagatedBuildInputs = [ xorg.libICE ];
+  };
 
-  libXrender = attrs: attrs
-    // { preConfigure = setMalloc0ReturnsNullCrossCompiling; };
+  libXrender = attrs: attrs // {
+    outputs = [ "dev" "out" "doc" ];
+    preConfigure = setMalloc0ReturnsNullCrossCompiling;
+  };
 
-  libXvMC = attrs: attrs
-    // { buildInputs = attrs.buildInputs ++ [xorg.renderproto]; };
+  libXres = attrs: attrs // {
+    outputs = [ "dev" "out" "docdev" ];
+  };
+
+  libXv = attrs: attrs // {
+    outputs = [ "dev" "out" "docdev" ];
+  };
+
+  libXvMC = attrs: attrs // {
+    outputs = [ "dev" "out" "doc" ];
+    buildInputs = attrs.buildInputs ++ [xorg.renderproto];
+  };
 
   libXpm = attrs: attrs // {
+    outputs = [ "dev" "out" "bin" ]; # tiny man in $bin
     patchPhase = "sed -i '/USE_GETTEXT_TRUE/d' sxpm/Makefile.in cxpm/Makefile.in";
   };
 
   libXpresent = attrs: attrs
     // { buildInputs = with xorg; attrs.buildInputs ++ [ libXext libXfixes libXrandr ]; };
 
+  libxkbfile = attrs: attrs // {
+    outputs = [ "dev" "out" ]; # mainly to avoid propagation
+  };
+
+  libxshmfence = attrs: attrs // {
+    outputs = [ "dev" "out" ]; # mainly to avoid propagation
+  };
+
   setxkbmap = attrs: attrs // {
     postInstall =
       ''
@@ -193,10 +260,30 @@ in
     buildInputs = attrs.buildInputs ++ [ args.freetype args.fontconfig ];
   };
 
+  xcbutil = attrs: attrs // {
+    outputs = [ "dev" "out" ];
+  };
+
   xcbutilcursor = attrs: attrs // {
     meta.maintainers = [ stdenv.lib.maintainers.lovek323 ];
   };
 
+  xcbutilimage = attrs: attrs // {
+    outputs = [ "dev" "out" ]; # mainly to get rid of propagating others
+  };
+
+  xcbutilkeysyms = attrs: attrs // {
+    outputs = [ "dev" "out" ]; # mainly to get rid of propagating others
+  };
+
+  xcbutilrenderutil = attrs: attrs // {
+    outputs = [ "dev" "out" ]; # mainly to get rid of propagating others
+  };
+
+  xcbutilwm = attrs: attrs // {
+    outputs = [ "dev" "out" ]; # mainly to get rid of propagating others
+  };
+
   xf86inputevdev = attrs: attrs // {
     preBuild = "sed -e '/motion_history_proc/d; /history_size/d;' -i src/*.c";
     installFlags = "sdkdir=\${out}/include/xorg";
@@ -280,7 +367,7 @@ in
       version = (builtins.parseDrvName attrs.name).version;
       commonBuildInputs = attrs.buildInputs ++ [ xtrans ];
       commonPropagatedBuildInputs = [
-        args.zlib args.mesa args.dbus.libs
+        args.zlib args.mesa args.dbus
         xf86bigfontproto glproto xf86driproto
         compositeproto scrnsaverproto resourceproto
         xf86dgaproto
@@ -307,6 +394,7 @@ in
     in
       if (!isDarwin)
       then {
+        outputs = [ "dev" "out" ];
         buildInputs = [ makeWrapper ] ++ commonBuildInputs;
         propagatedBuildInputs = [ libpciaccess ] ++ commonPropagatedBuildInputs ++ lib.optionals stdenv.isLinux [
           args.udev
@@ -329,6 +417,12 @@ in
             --set XKB_BINDIR "${xorg.xkbcomp}/bin" \
             --set XORG_DRI_DRIVER_PATH ${args.mesa}/lib/dri \
             --add-flags "-xkbdir ${xorg.xkeyboardconfig}/share/X11/xkb"
+          ( # assert() keeps runtime reference xorgserver-dev in xf86-video-intel and others
+            cd "$dev"
+            for f in include/xorg/*.h; do
+              sed "1i#line 1 \"${attrs.name}/$f\"" -i "$f"
+            done
+          )
         '';
         passthru.version = version; # needed by virtualbox guest additions
       } else {
@@ -402,7 +496,7 @@ in
     stdenv = if isDarwin then args.clangStdenv else stdenv;
     buildInputs = attrs.buildInputs ++ lib.optional isDarwin args.bootstrap_cmds;
     configureFlags = [
-      "--with-xserver=${xorg.xorgserver}/bin/X"
+      "--with-xserver=${xorg.xorgserver.out}/bin/X"
     ] ++ lib.optionals isDarwin [
       "--with-bundle-id-prefix=org.nixos.xquartz"
       "--with-launchdaemons-dir=\${out}/LaunchDaemons"
diff --git a/pkgs/servers/x11/xquartz/default.nix b/pkgs/servers/x11/xquartz/default.nix
index 920b66147f26..db0c446617af 100644
--- a/pkgs/servers/x11/xquartz/default.nix
+++ b/pkgs/servers/x11/xquartz/default.nix
@@ -159,7 +159,7 @@ in stdenv.mkDerivation {
       --replace "@ENCODINGSDIR@"    "${xorg.encodings}/share/fonts/X11/encodings" \
       --replace "@MKFONTDIR@"       "${xorg.mkfontdir}/bin/mkfontdir" \
       --replace "@MKFONTSCALE@"     "${xorg.mkfontscale}/bin/mkfontscale" \
-      --replace "@FC_CACHE@"        "${fontconfig}/bin/fc-cache" \
+      --replace "@FC_CACHE@"        "${fontconfig.bin}/bin/fc-cache" \
       --replace "@FONTCONFIG_FILE@" "$fontsConfPath"
 
     cp ${./xinitrc} $out/etc/X11/xinit/xinitrc