summary refs log tree commit diff
path: root/pkgs/os-specific
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/os-specific')
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/adv_cmds/default.nix3
-rw-r--r--pkgs/os-specific/darwin/binutils/default.nix2
-rw-r--r--pkgs/os-specific/darwin/opencflite/default.nix2
-rw-r--r--pkgs/os-specific/linux/alsa-lib/default.nix2
-rw-r--r--pkgs/os-specific/linux/apparmor/2.9/default.nix183
-rw-r--r--pkgs/os-specific/linux/apparmor/default.nix8
-rw-r--r--pkgs/os-specific/linux/ati-drivers/default.nix18
-rw-r--r--pkgs/os-specific/linux/bluez/bluez5.nix2
-rw-r--r--pkgs/os-specific/linux/bluez/bluez5_28.nix2
-rw-r--r--pkgs/os-specific/linux/bluez/default.nix2
-rw-r--r--pkgs/os-specific/linux/cgmanager/default.nix4
-rw-r--r--pkgs/os-specific/linux/checksec/default.nix2
-rw-r--r--pkgs/os-specific/linux/conspy/default.nix8
-rw-r--r--pkgs/os-specific/linux/criu/default.nix14
-rw-r--r--pkgs/os-specific/linux/drbd/default.nix4
-rw-r--r--pkgs/os-specific/linux/firejail/default.nix8
-rw-r--r--pkgs/os-specific/linux/fusionio/util.nix2
-rw-r--r--pkgs/os-specific/linux/iptables/1.6.nix33
-rw-r--r--pkgs/os-specific/linux/kbd/default.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/linux-testing.nix6
-rw-r--r--pkgs/os-specific/linux/kernel/manual-config.nix2
-rw-r--r--pkgs/os-specific/linux/kernel/patches.nix4
-rw-r--r--pkgs/os-specific/linux/kernel/qat_common_Makefile.patch10
-rw-r--r--pkgs/os-specific/linux/klibc/shrunk.nix6
-rw-r--r--pkgs/os-specific/linux/libcap/default.nix19
-rw-r--r--pkgs/os-specific/linux/libcap/man.nix2
-rw-r--r--pkgs/os-specific/linux/libcap/pam.nix2
-rw-r--r--pkgs/os-specific/linux/libcap/progs.nix5
-rw-r--r--pkgs/os-specific/linux/libnl/default.nix2
-rw-r--r--pkgs/os-specific/linux/lvm2/default.nix6
-rw-r--r--pkgs/os-specific/linux/lxc/default.nix9
-rw-r--r--pkgs/os-specific/linux/lxc/support-db2x.patch4
-rw-r--r--pkgs/os-specific/linux/mdadm/default.nix2
-rw-r--r--pkgs/os-specific/linux/module-init-tools/default.nix5
-rw-r--r--pkgs/os-specific/linux/nfs-utils/default.nix2
-rw-r--r--pkgs/os-specific/linux/pam/default.nix13
-rw-r--r--pkgs/os-specific/linux/shadow/default.nix2
-rw-r--r--pkgs/os-specific/linux/sysdig/default.nix4
-rw-r--r--pkgs/os-specific/linux/sysstat/default.nix2
-rw-r--r--pkgs/os-specific/linux/systemd/cryptsetup-generator.nix25
-rw-r--r--pkgs/os-specific/linux/systemd/default.nix67
-rw-r--r--pkgs/os-specific/linux/systemd/hwdb-location.diff19
-rw-r--r--pkgs/os-specific/linux/systemd/libudev.nix19
-rw-r--r--pkgs/os-specific/linux/udev/145.nix53
-rw-r--r--pkgs/os-specific/linux/util-linux/default.nix21
45 files changed, 514 insertions, 98 deletions
diff --git a/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/default.nix b/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/default.nix
index d72afac88fee..b8b436efe24f 100644
--- a/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/default.nix
+++ b/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/default.nix
@@ -73,12 +73,15 @@ in appleDerivation {
 
     install -d 0755 $ps/bin
     install ps $ps/bin/ps
+    touch "$out"
   '';
 
   outputs = [
+    "out"
     "ps"
     "locale"
   ];
+  setOutputFlags = false;
 
   # ps uses this syscall to get process info
   propagatedSandboxProfile = stdenv.lib.sandbox.allow "mach-priv-task-port";
diff --git a/pkgs/os-specific/darwin/binutils/default.nix b/pkgs/os-specific/darwin/binutils/default.nix
index abe4aa67b143..d671c7c72303 100644
--- a/pkgs/os-specific/darwin/binutils/default.nix
+++ b/pkgs/os-specific/darwin/binutils/default.nix
@@ -32,7 +32,7 @@ stdenv.mkDerivation {
 
     # FIXME: this will give us incorrect man pages for bits of cctools
     ln -s ${binutils-raw}/share $out/share
-    ln -s ${binutils-raw}/lib $out/lib
+    ln -s ${binutils-raw.out}/lib $out/lib
 
     ln -s ${cctools}/libexec $out/libexec
   '';
diff --git a/pkgs/os-specific/darwin/opencflite/default.nix b/pkgs/os-specific/darwin/opencflite/default.nix
index a2408bfc5c8a..1cd7f2bf9d6e 100644
--- a/pkgs/os-specific/darwin/opencflite/default.nix
+++ b/pkgs/os-specific/darwin/opencflite/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
   };
 
   configureFlags = [ "--with-uuid=${libuuid}" ];
-  buildInputs = [ icu tzdata.lib ];
+  buildInputs = [ icu tzdata.dev ];
   enableParallelBuilding = true;
 
   meta = {
diff --git a/pkgs/os-specific/linux/alsa-lib/default.nix b/pkgs/os-specific/linux/alsa-lib/default.nix
index c4fd46b3c7da..d2637f99119c 100644
--- a/pkgs/os-specific/linux/alsa-lib/default.nix
+++ b/pkgs/os-specific/linux/alsa-lib/default.nix
@@ -25,6 +25,8 @@ stdenv.mkDerivation rec {
     sed -i -e 's/u_int\([0-9]*\)_t/uint\1_t/g' include/pcm.h
   '';
 
+  outputs = [ "dev" "out" ];
+
   crossAttrs = {
     patchPhase = ''
       sed -i s/extern/static/g include/iatomic.h
diff --git a/pkgs/os-specific/linux/apparmor/2.9/default.nix b/pkgs/os-specific/linux/apparmor/2.9/default.nix
new file mode 100644
index 000000000000..5e8ccc756918
--- /dev/null
+++ b/pkgs/os-specific/linux/apparmor/2.9/default.nix
@@ -0,0 +1,183 @@
+{ stdenv, fetchurl, autoconf, automake, libtool, pkgconfig, perl, which
+, glibc, flex, bison, python27, swig, dbus, pam
+}:
+
+let
+  apparmor-series = "2.9";
+  apparmor-patchver = "2";
+  apparmor-version = "${apparmor-series}.${apparmor-patchver}";
+
+  apparmor-meta = component: with stdenv.lib; {
+      homepage = http://apparmor.net/;
+      description = "Linux application security system - ${component}";
+      license = licenses.gpl2;
+      maintainers = with maintainers; [ phreedom thoughtpolice joachifm ];
+      platforms = platforms.linux;
+  };
+
+  apparmor-sources = fetchurl {
+    url = "https://launchpad.net/apparmor/${apparmor-series}/${apparmor-version}/+download/apparmor-${apparmor-version}.tar.gz";
+    sha256 = "1mayly7d7w959fya7z8q6kab2x3jcwhqhkpx36jsvpjhxkhmc4fh";
+  };
+
+  prePatchCommon = ''
+    substituteInPlace ./common/Make.rules --replace "/usr/bin/pod2man" "${perl}/bin/pod2man"
+    substituteInPlace ./common/Make.rules --replace "/usr/bin/pod2html" "${perl}/bin/pod2html"
+    substituteInPlace ./common/Make.rules --replace "/usr/include/linux/capability.h" "${glibc.dev}/include/linux/capability.h"
+    substituteInPlace ./common/Make.rules --replace "/usr/share/man" "share/man"
+  '';
+
+  libapparmor = stdenv.mkDerivation {
+    name = "libapparmor-${apparmor-version}";
+    src = apparmor-sources;
+
+    buildInputs = [
+      autoconf
+      automake
+      bison
+      flex
+      dbus # requires patch to dbus ...
+      glibc
+      libtool
+      perl
+      pkgconfig
+      python27
+      swig
+      which
+    ];
+
+    prePatch = prePatchCommon + ''
+      substituteInPlace ./libraries/libapparmor/src/Makefile.am --replace "/usr/include/netinet/in.h" "${glibc.dev}/include/netinet/in.h"
+      substituteInPlace ./libraries/libapparmor/src/Makefile.in --replace "/usr/include/netinet/in.h" "${glibc.dev}/include/netinet/in.h"
+      '';
+
+    buildPhase = ''
+      cd ./libraries/libapparmor
+      ./autogen.sh
+      ./configure --prefix="$out" --with-python --with-perl
+      make
+      '';
+
+    installPhase = ''
+      make install
+    '';
+
+    meta = apparmor-meta "library";
+  };
+
+  apparmor-utils = stdenv.mkDerivation {
+    name = "apparmor-utils-${apparmor-version}";
+    src = apparmor-sources;
+
+    buildInputs = [
+      python27
+      libapparmor
+      which
+    ];
+
+    prePatch = prePatchCommon;
+
+    buildPhase = ''
+      cd ./utils
+      make LANGS=""
+    '';
+
+    installPhase = ''
+      make install LANGS="" DESTDIR="$out" BINDIR="$out/bin" VIM_INSTALL_PATH="$out/share" PYPREFIX=""
+    '';
+
+    meta = apparmor-meta "user-land utilities";
+  };
+
+  apparmor-parser = stdenv.mkDerivation {
+    name = "apparmor-parser-${apparmor-version}";
+    src = apparmor-sources;
+
+    buildInputs = [
+      libapparmor
+      bison
+      flex
+      which
+    ];
+
+    prePatch = prePatchCommon + ''
+      substituteInPlace ./parser/Makefile --replace "/usr/bin/bison" "${bison}/bin/bison"
+      substituteInPlace ./parser/Makefile --replace "/usr/bin/flex" "${flex}/bin/flex"
+      substituteInPlace ./parser/Makefile --replace "/usr/include/linux/capability.h" "${glibc.dev}/include/linux/capability.h"
+      ## techdoc.pdf still doesn't build ...
+      substituteInPlace ./parser/Makefile --replace "manpages htmlmanpages pdf" "manpages htmlmanpages"
+    '';
+
+    buildPhase = ''
+      cd ./parser
+      make LANGS="" USE_SYSTEM=1 INCLUDEDIR=${libapparmor}/include
+    '';
+
+    installPhase = ''
+      make install LANGS="" USE_SYSTEM=1 INCLUDEDIR=${libapparmor}/include DESTDIR="$out" DISTRO="unknown"
+    '';
+
+    meta = apparmor-meta "rule parser";
+  };
+
+  apparmor-pam = stdenv.mkDerivation {
+    name = "apparmor-pam-${apparmor-version}";
+    src = apparmor-sources;
+
+    buildInputs = [
+      libapparmor
+      pam
+      pkgconfig
+      which
+    ];
+
+    buildPhase = ''
+      cd ./changehat/pam_apparmor
+      make USE_SYSTEM=1
+    '';
+
+    installPhase = ''
+      make install DESTDIR="$out"
+    '';
+
+    meta = apparmor-meta "PAM service";
+  };
+
+  apparmor-profiles = stdenv.mkDerivation {
+    name = "apparmor-profiles-${apparmor-version}";
+    src = apparmor-sources;
+
+    buildInputs = [ which ];
+
+    buildPhase = ''
+      cd ./profiles
+      make
+    '';
+
+    installPhase = ''
+      make install DESTDIR="$out" EXTRAS_DEST="$out/share/apparmor/extra-profiles"
+    '';
+
+    meta = apparmor-meta "profiles";
+  };
+
+  apparmor-kernel-patches = stdenv.mkDerivation {
+    name = "apparmor-kernel-patches-${apparmor-version}";
+    src = apparmor-sources;
+
+    phases = ''unpackPhase installPhase'';
+
+    installPhase = ''
+      mkdir "$out"
+      cp -R ./kernel-patches "$out"
+    '';
+
+    meta = apparmor-meta "kernel patches";
+  };
+
+in
+
+{
+  inherit libapparmor apparmor-utils apparmor-parser apparmor-pam
+  apparmor-profiles apparmor-kernel-patches;
+}
diff --git a/pkgs/os-specific/linux/apparmor/default.nix b/pkgs/os-specific/linux/apparmor/default.nix
index 64c6f66575b6..49fdbab24caa 100644
--- a/pkgs/os-specific/linux/apparmor/default.nix
+++ b/pkgs/os-specific/linux/apparmor/default.nix
@@ -22,7 +22,7 @@ let
   prePatchCommon = ''
     substituteInPlace ./common/Make.rules --replace "/usr/bin/pod2man" "${perl}/bin/pod2man"
     substituteInPlace ./common/Make.rules --replace "/usr/bin/pod2html" "${perl}/bin/pod2html"
-    substituteInPlace ./common/Make.rules --replace "/usr/include/linux/capability.h" "${glibc}/include/linux/capability.h"
+    substituteInPlace ./common/Make.rules --replace "/usr/include/linux/capability.h" "${glibc.dev}/include/linux/capability.h"
     substituteInPlace ./common/Make.rules --replace "/usr/share/man" "share/man"
   '';
 
@@ -49,8 +49,8 @@ let
     dontDisableStatic = true;
 
     prePatch = prePatchCommon + ''
-      substituteInPlace ./libraries/libapparmor/src/Makefile.am --replace "/usr/include/netinet/in.h" "${glibc}/include/netinet/in.h"
-      substituteInPlace ./libraries/libapparmor/src/Makefile.in --replace "/usr/include/netinet/in.h" "${glibc}/include/netinet/in.h"
+      substituteInPlace ./libraries/libapparmor/src/Makefile.am --replace "/usr/include/netinet/in.h" "${glibc.dev}/include/netinet/in.h"
+      substituteInPlace ./libraries/libapparmor/src/Makefile.in --replace "/usr/include/netinet/in.h" "${glibc.dev}/include/netinet/in.h"
       '';
 
     postPatch = "cd ./libraries/libapparmor";
@@ -104,7 +104,7 @@ let
     prePatch = prePatchCommon + ''
       substituteInPlace ./parser/Makefile --replace "/usr/bin/bison" "${bison}/bin/bison"
       substituteInPlace ./parser/Makefile --replace "/usr/bin/flex" "${flex}/bin/flex"
-      substituteInPlace ./parser/Makefile --replace "/usr/include/linux/capability.h" "${glibc}/include/linux/capability.h"
+      substituteInPlace ./parser/Makefile --replace "/usr/include/linux/capability.h" "${glibc.dev}/include/linux/capability.h"
       ## techdoc.pdf still doesn't build ...
       substituteInPlace ./parser/Makefile --replace "manpages htmlmanpages pdf" "manpages htmlmanpages"
     '';
diff --git a/pkgs/os-specific/linux/ati-drivers/default.nix b/pkgs/os-specific/linux/ati-drivers/default.nix
index 377297feaf75..78903da1f1a1 100644
--- a/pkgs/os-specific/linux/ati-drivers/default.nix
+++ b/pkgs/os-specific/linux/ati-drivers/default.nix
@@ -85,15 +85,17 @@ stdenv.mkDerivation {
 
   inherit glibc /* glibc only used for setting interpreter */;
 
+  # outputs TODO: probably many fixes are needed;
+  # this in particular would be much better by lib.makeLibraryPath
   LD_LIBRARY_PATH = stdenv.lib.concatStringsSep ":"
-    [ "${xorg.libXrandr}/lib/"
-      "${xorg.libXrender}/lib/"
-      "${xorg.libXext}/lib/"
-      "${xorg.libX11}/lib/"
-      "${xorg.libXinerama}/lib/"
-      "${xorg.libSM}/lib/"
-      "${xorg.libICE}/lib/"
-      "${stdenv.cc.cc}/lib/"
+    [ "${xorg.libXrandr.out}/lib/"
+      "${xorg.libXrender.out}/lib/"
+      "${xorg.libXext.out}/lib/"
+      "${xorg.libX11.out}/lib/"
+      "${xorg.libXinerama.out}/lib/"
+      "${xorg.libSM.out}/lib/"
+      "${xorg.libICE.out}/lib/"
+      "${stdenv.cc.cc.out}/lib/"
     ];
 
   # without this some applications like blender don't start, but they start
diff --git a/pkgs/os-specific/linux/bluez/bluez5.nix b/pkgs/os-specific/linux/bluez/bluez5.nix
index 2b73dc798c3f..9750a2a76499 100644
--- a/pkgs/os-specific/linux/bluez/bluez5.nix
+++ b/pkgs/os-specific/linux/bluez/bluez5.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
     [ pythonDBus pygobject pygobject3 recursivePthLoader ];
 
   buildInputs =
-    [ pkgconfig dbus.libs glib alsaLib python pythonPackages.wrapPython
+    [ pkgconfig dbus glib alsaLib python pythonPackages.wrapPython
       readline libsndfile udev libical
       # Disables GStreamer; not clear what it gains us other than a
       # zillion extra dependencies.
diff --git a/pkgs/os-specific/linux/bluez/bluez5_28.nix b/pkgs/os-specific/linux/bluez/bluez5_28.nix
index 80adc0fd56b8..68db9345bd0e 100644
--- a/pkgs/os-specific/linux/bluez/bluez5_28.nix
+++ b/pkgs/os-specific/linux/bluez/bluez5_28.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
     [ pythonDBus pygobject pygobject3 recursivePthLoader ];
 
   buildInputs =
-    [ pkgconfig dbus.libs glib alsaLib python pythonPackages.wrapPython
+    [ pkgconfig dbus glib alsaLib python pythonPackages.wrapPython
       readline libsndfile udev libical
       # Disables GStreamer; not clear what it gains us other than a
       # zillion extra dependencies.
diff --git a/pkgs/os-specific/linux/bluez/default.nix b/pkgs/os-specific/linux/bluez/default.nix
index 23e5171d1780..4f30bc19caf8 100644
--- a/pkgs/os-specific/linux/bluez/default.nix
+++ b/pkgs/os-specific/linux/bluez/default.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs =
-    [ pkgconfig dbus.libs glib libusb alsaLib python makeWrapper
+    [ pkgconfig dbus glib libusb alsaLib python makeWrapper
       readline libsndfile
       # Disables GStreamer; not clear what it gains us other than a
       # zillion extra dependencies.
diff --git a/pkgs/os-specific/linux/cgmanager/default.nix b/pkgs/os-specific/linux/cgmanager/default.nix
index 1c79fddeca96..2260ac08b632 100644
--- a/pkgs/os-specific/linux/cgmanager/default.nix
+++ b/pkgs/os-specific/linux/cgmanager/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, pkgconfig, libnih, dbus, pam }:
 
 stdenv.mkDerivation rec {
-  name = "cgmanager-0.39";
+  name = "cgmanager-0.41";
 
   src = fetchurl {
     url = "https://linuxcontainers.org/downloads/cgmanager/${name}.tar.gz";
-    sha256 = "0ysv8klnybp727aad2k0aa67s05q027pzfl7rmm0map4nizlhrcy";
+    sha256 = "0n5l4g78ifvyfnj8x9xz06mqn4y8j73sgg4xsbak7hiszfz5bc99";
   };
 
   nativeBuildInputs = [ pkgconfig ];
diff --git a/pkgs/os-specific/linux/checksec/default.nix b/pkgs/os-specific/linux/checksec/default.nix
index b423dc3a0862..60468538be24 100644
--- a/pkgs/os-specific/linux/checksec/default.nix
+++ b/pkgs/os-specific/linux/checksec/default.nix
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
     cp checksec.sh $out/bin/checksec
     chmod +x $out/bin/checksec
     substituteInPlace $out/bin/checksec --replace /bin/bash ${stdenv.shell}
-    substituteInPlace $out/bin/checksec --replace /lib/libc.so.6 ${glibc}/lib/libc.so.6
+    substituteInPlace $out/bin/checksec --replace /lib/libc.so.6 ${glibc.out}/lib/libc.so.6
     substituteInPlace $out/bin/checksec --replace find ${findutils}/bin/find
     substituteInPlace $out/bin/checksec --replace "file $" "${file}/bin/file $"
     substituteInPlace $out/bin/checksec --replace "xargs file" "xargs ${file}/bin/file"
diff --git a/pkgs/os-specific/linux/conspy/default.nix b/pkgs/os-specific/linux/conspy/default.nix
index 3c209c6253dd..32905b8ec39f 100644
--- a/pkgs/os-specific/linux/conspy/default.nix
+++ b/pkgs/os-specific/linux/conspy/default.nix
@@ -3,11 +3,11 @@ let
   s = # Generated upstream information
   rec {
     baseName="conspy";
-    version="1.13";
+    version="1.14";
     name="${baseName}-${version}";
-    hash="059sag372n09y1ddb1i0sx013kzkbr8a9pjqk03kyijn8h1z5hl2";
-    url="mirror://sourceforge/project/conspy/conspy-1.13-1/conspy-1.13.tar.gz";
-    sha256="059sag372n09y1ddb1i0sx013kzkbr8a9pjqk03kyijn8h1z5hl2";
+    hash="069k26xpzsvrn3197ix5yd294zvz03zi2xqj4fip6rlsw74habsf";
+    url="mirror://sourceforge/project/conspy/conspy-1.14-1/conspy-1.14.tar.gz";
+    sha256="069k26xpzsvrn3197ix5yd294zvz03zi2xqj4fip6rlsw74habsf";
   };
   buildInputs = [
     autoconf automake ncurses
diff --git a/pkgs/os-specific/linux/criu/default.nix b/pkgs/os-specific/linux/criu/default.nix
index 6afaf36bd80a..0d06864df1e5 100644
--- a/pkgs/os-specific/linux/criu/default.nix
+++ b/pkgs/os-specific/linux/criu/default.nix
@@ -1,27 +1,29 @@
 { stdenv, fetchurl, protobuf, protobufc, asciidoc
-, xmlto, utillinux, docbook_xsl, libpaper }:
+, xmlto, utillinux, docbook_xsl, libpaper, libnl, libcap, pkgconfig
+, python }:
 
 stdenv.mkDerivation rec {
   name    = "criu-${version}";
-  version = "1.3-rc2";
+  version = "2.0";
 
   src = fetchurl {
     url    = "http://download.openvz.org/criu/${name}.tar.bz2";
-    sha256 = "1h9ii91aq8cja22j3520vg3qb3y9h6c064s4115s2ldylm8jmi0s";
+    sha256 = "1zqqshslcf503lqip89azp1zz0i8kb7v19b3dyp52izpak62c1z8";
   };
 
   enableParallelBuilding = true;
-  buildInputs = [ protobuf protobufc asciidoc xmlto libpaper ];
+  buildInputs = [ protobuf protobufc asciidoc xmlto libpaper libnl libcap pkgconfig python ];
 
   patchPhase = ''
     chmod +w ./scripts/gen-offsets.sh
     substituteInPlace ./scripts/gen-offsets.sh --replace hexdump ${utillinux}/bin/hexdump
     substituteInPlace ./Documentation/Makefile --replace "2>/dev/null" ""
     substituteInPlace ./Documentation/Makefile --replace "--skip-validation" "--skip-validation -x ${docbook_xsl}/xml/xsl/docbook/manpages/docbook.xsl"
-    substituteInPlace ./Makefile --replace "-Werror" ""
+    substituteInPlace ./criu/Makefile --replace "-I/usr/include/libnl3" "-I${libnl}/include/libnl3"
+    substituteInPlace ./Makefile --replace "tar-name := $(shell git tag -l v$(CRIU_VERSION))" "tar-name = 2.0" # --replace "-Werror" ""
+    ln -sf ${protobuf}/include/google/protobuf/descriptor.proto ./images/google/protobuf/descriptor.proto
   '';
 
-  configurePhase = "make config PREFIX=$out";
   buildPhase     = "make PREFIX=$out";
 
   installPhase = ''
diff --git a/pkgs/os-specific/linux/drbd/default.nix b/pkgs/os-specific/linux/drbd/default.nix
index d90d6faac396..60615fb1e5be 100644
--- a/pkgs/os-specific/linux/drbd/default.nix
+++ b/pkgs/os-specific/linux/drbd/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, flex, udev, perl }:
+{ stdenv, fetchurl, flex, systemd, perl }:
 
 assert stdenv.isLinux;
 
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
 
   preConfigure =
     ''
-      export PATH=${udev}/sbin:$PATH
+      export PATH=${systemd.udev.bin}/sbin:$PATH
       substituteInPlace user/Makefile.in --replace /sbin/ $out/sbin/
       substituteInPlace user/legacy/Makefile.in \
         --replace /sbin/ $out/sbin/ \
diff --git a/pkgs/os-specific/linux/firejail/default.nix b/pkgs/os-specific/linux/firejail/default.nix
index 57820f92cc4f..dac0eb0d0f50 100644
--- a/pkgs/os-specific/linux/firejail/default.nix
+++ b/pkgs/os-specific/linux/firejail/default.nix
@@ -3,11 +3,11 @@ let
   s = # Generated upstream information
   rec {
     baseName="firejail";
-    version="0.9.38";
+    version="0.9.40";
     name="${baseName}-${version}";
-    hash="0j0zvff9rwjwxcxddfhgzimjgmr99kd04nl40dllkrv3apv5ag4i";
-    url="mirror://sourceforge/project/firejail/firejail/firejail-0.9.38-rc1.tar.bz2";
-    sha256="0j0zvff9rwjwxcxddfhgzimjgmr99kd04nl40dllkrv3apv5ag4i";
+    hash="1vr0z694wibjkcpmyg7lz68r53z857c8hsb02cqxi4lfkkcmzgh2";
+    url="mirror://sourceforge/project/firejail/firejail/firejail-0.9.40-rc1.tar.bz2";
+    sha256="1vr0z694wibjkcpmyg7lz68r53z857c8hsb02cqxi4lfkkcmzgh2";
   };
   buildInputs = [
     which
diff --git a/pkgs/os-specific/linux/fusionio/util.nix b/pkgs/os-specific/linux/fusionio/util.nix
index e2f8d423a61d..e77d596dc6f8 100644
--- a/pkgs/os-specific/linux/fusionio/util.nix
+++ b/pkgs/os-specific/linux/fusionio/util.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation {
     cp -r $TMPDIR/{etc,usr/{bin,lib,share}} $out
     for BIN in $(find $out/bin -type f); do
       echo Patching $BIN
-      patchelf --set-interpreter "${glibc}/lib/ld-linux-x86-64.so.2" --set-rpath "${glibc}/lib:${gcc.cc}/lib:${libuuid}/lib:$out/lib" $BIN
+      patchelf --set-interpreter "${glibc.out}/lib/ld-linux-x86-64.so.2" --set-rpath "${glibc.out}/lib:${gcc.cc}/lib:${libuuid}/lib:$out/lib" $BIN
 
       # Test our binary to see if it was correctly patched
       set +e
diff --git a/pkgs/os-specific/linux/iptables/1.6.nix b/pkgs/os-specific/linux/iptables/1.6.nix
new file mode 100644
index 000000000000..88821a15d73e
--- /dev/null
+++ b/pkgs/os-specific/linux/iptables/1.6.nix
@@ -0,0 +1,33 @@
+{stdenv, fetchurl, bison, flex, libnetfilter_conntrack, libnftnl, libmnl}:
+
+stdenv.mkDerivation rec {
+  name = "iptables-${version}";
+  version = "1.6.0";
+
+  src = fetchurl {
+    url = "http://www.netfilter.org/projects/iptables/files/${name}.tar.bz2";
+    sha256 = "0q0w1x4aijid8wj7dg1ny9fqwll483f1sqw7kvkskd8q1c52mdsb";
+  };
+
+  nativeBuildInputs = [bison flex];
+
+  buildInputs = [libnetfilter_conntrack libnftnl libmnl];
+  
+  preConfigure = ''
+    export NIX_LDFLAGS="$NIX_LDFLAGS -lmnl -lnftnl"
+  '';
+
+  configureFlags = ''
+    --enable-devel
+    --enable-shared
+  '';
+
+  meta = {
+    description = "A program to configure the Linux IP packet filtering ruleset";
+    homepage = http://www.netfilter.org/projects/iptables/index.html;
+    platforms = stdenv.lib.platforms.linux;
+    downloadPage = "http://www.netfilter.org/projects/iptables/files/";
+    updateWalker = true;
+    inherit version;
+  };
+}
diff --git a/pkgs/os-specific/linux/kbd/default.nix b/pkgs/os-specific/linux/kbd/default.nix
index bb2915958f7c..fddaa84a8240 100644
--- a/pkgs/os-specific/linux/kbd/default.nix
+++ b/pkgs/os-specific/linux/kbd/default.nix
@@ -40,7 +40,7 @@ stdenv.mkDerivation rec {
       # Fix the path to gzip/bzip2.
       substituteInPlace src/libkeymap/findfile.c \
         --replace gzip ${gzip}/bin/gzip \
-        --replace bzip2 ${bzip2}/bin/bzip2 \
+        --replace bzip2 ${bzip2.bin}/bin/bzip2 \
 
       # We get a warning in armv5tel-linux and the fuloong2f, so we
       # disable -Werror in it.
diff --git a/pkgs/os-specific/linux/kernel/linux-testing.nix b/pkgs/os-specific/linux/kernel/linux-testing.nix
index e3edaa43b8cd..ea9eb4d551b0 100644
--- a/pkgs/os-specific/linux/kernel/linux-testing.nix
+++ b/pkgs/os-specific/linux/kernel/linux-testing.nix
@@ -1,13 +1,13 @@
 { stdenv, fetchurl, perl, buildLinux, ... } @ args:
 
 import ./generic.nix (args // rec {
-  version = "4.6-rc2";
-  modDirVersion = "4.6.0-rc2";
+  version = "4.6-rc3";
+  modDirVersion = "4.6.0-rc3";
   extraMeta.branch = "4.6";
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v4.x/testing/linux-${version}.tar.xz";
-    sha256 = "0zihk9s1rkgmn0ghiz9xkg0w88w524af5mmad45rbxhm5751nxcr";
+    sha256 = "1vhvhbldk5pvwxhdndyzvyqy5mscpnlz09sfyh2c9rk6wc1hc8xv";
   };
 
   features.iwlwifi = true;
diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix
index 67342d4ab8ae..ffe09cc2fee5 100644
--- a/pkgs/os-specific/linux/kernel/manual-config.nix
+++ b/pkgs/os-specific/linux/kernel/manual-config.nix
@@ -74,7 +74,7 @@ let
 
       installsFirmware = (config.isEnabled "FW_LOADER") &&
         (isModular || (config.isDisabled "FIRMWARE_IN_KERNEL"));
-    in (optionalAttrs isModular { outputs = [ "out" "dev" ]; }) // {
+    in (optionalAttrs isModular { outputs = [ "out" "dev" ]; propagatedBuildOutputs = ""; }) // {
       passthru = {
         inherit version modDirVersion config kernelPatches configfile;
       };
diff --git a/pkgs/os-specific/linux/kernel/patches.nix b/pkgs/os-specific/linux/kernel/patches.nix
index a23ee7823a61..707ebb544bf4 100644
--- a/pkgs/os-specific/linux/kernel/patches.nix
+++ b/pkgs/os-specific/linux/kernel/patches.nix
@@ -154,4 +154,8 @@ rec {
     { name = "mfd_fix_dependency";
       patch = ./chromiumos-patches/mfd-fix-dependency.patch;
     };
+  qat_common_Makefile =
+    { name = "qat_common_Makefile";
+      patch = ./qat_common_Makefile.patch;
+    };
 }
diff --git a/pkgs/os-specific/linux/kernel/qat_common_Makefile.patch b/pkgs/os-specific/linux/kernel/qat_common_Makefile.patch
new file mode 100644
index 000000000000..2d4476a7fe50
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/qat_common_Makefile.patch
@@ -0,0 +1,10 @@
+--- a/drivers/crypto/qat/qat_common/Makefile
++++ b/drivers/crypto/qat/qat_common/Makefile
+@@ -2,6 +2,7 @@
+ 			     $(obj)/qat_rsapubkey-asn1.h
+ $(obj)/qat_rsaprivkey-asn1.o: $(obj)/qat_rsaprivkey-asn1.c \
+ 			      $(obj)/qat_rsaprivkey-asn1.h
++$(obj)/qat_asym_algs.o: $(obj)/qat_rsaprivkey-asn1.h $(obj)/qat_rsapubkey-asn1.h
+ 
+ clean-files += qat_rsapubkey-asn1.c qat_rsapubkey-asn1.h
+ clean-files += qat_rsaprivkey-asn1.c qat_rsapvivkey-asn1.h
diff --git a/pkgs/os-specific/linux/klibc/shrunk.nix b/pkgs/os-specific/linux/klibc/shrunk.nix
index 066b4fcb4e06..2ce833d104fd 100644
--- a/pkgs/os-specific/linux/klibc/shrunk.nix
+++ b/pkgs/os-specific/linux/klibc/shrunk.nix
@@ -8,10 +8,10 @@ stdenv.mkDerivation {
   name = "${klibc.name}";
   buildCommand = ''
     mkdir -p $out/lib
-    cp -prd ${klibc}/lib/klibc/bin $out/
-    cp -p ${klibc}/lib/*.so $out/lib/
+    cp -prd ${klibc.out}/lib/klibc/bin $out/
+    cp -p ${klibc.out}/lib/*.so $out/lib/
     chmod +w $out/*
-    old=$(echo ${klibc}/lib/klibc-*.so)
+    old=$(echo ${klibc.out}/lib/klibc-*.so)
     new=$(echo $out/lib/klibc-*.so)
     for i in $out/bin/*; do
       echo $i
diff --git a/pkgs/os-specific/linux/libcap/default.nix b/pkgs/os-specific/linux/libcap/default.nix
index 8157270d67d7..c8484babcdf8 100644
--- a/pkgs/os-specific/linux/libcap/default.nix
+++ b/pkgs/os-specific/linux/libcap/default.nix
@@ -3,12 +3,14 @@
 stdenv.mkDerivation rec {
   name = "libcap-${version}";
   version = "2.24";
-  
+
   src = fetchurl {
     url = "mirror://kernel/linux/libs/security/linux-privs/libcap2/${name}.tar.xz";
     sha256 = "0rbc9qbqs5bp9am9s9g83wxj5k4ixps2agy9dxr1v1fwg27mdr6f";
   };
-  
+
+  outputs = [ "dev" "out" ];
+
   nativeBuildInputs = [ perl ];
   propagatedBuildInputs = [ attr ];
 
@@ -16,14 +18,11 @@ stdenv.mkDerivation rec {
 
   makeFlags = "lib=lib prefix=$(out)";
 
-  passthru = {
-    postinst = n : ''
-      mkdir -p $out/share/doc/${n}
-      cp ../License $out/share/doc/${n}/License
-    '';
-  };
-
-  postInstall = passthru.postinst name;
+  postInstall = ''
+    rm "$out"/lib/*.a
+    mkdir -p "$dev/share/doc/${name}"
+    cp ../License "$dev/share/doc/${name}/License"
+  '';
 
   meta = {
     description = "Library for working with POSIX capabilities";
diff --git a/pkgs/os-specific/linux/libcap/man.nix b/pkgs/os-specific/linux/libcap/man.nix
index 9aac3c4e1f5a..eeb780f095bd 100644
--- a/pkgs/os-specific/linux/libcap/man.nix
+++ b/pkgs/os-specific/linux/libcap/man.nix
@@ -10,6 +10,4 @@ stdenv.mkDerivation rec {
   makeFlags = "MANDIR=$(out)/share/man";
 
   preConfigure = "cd doc";
-
-  postInstall = libcap.postinst name;
 }
diff --git a/pkgs/os-specific/linux/libcap/pam.nix b/pkgs/os-specific/linux/libcap/pam.nix
index b78f32dccbb4..3dd7cd947af2 100644
--- a/pkgs/os-specific/linux/libcap/pam.nix
+++ b/pkgs/os-specific/linux/libcap/pam.nix
@@ -12,6 +12,4 @@ stdenv.mkDerivation rec {
   preConfigure = "cd pam_cap";
 
   makeFlags = "${libcap.makeFlags} PAM_CAP=yes";
-
-  postInstall = libcap.postinst name;
 }
diff --git a/pkgs/os-specific/linux/libcap/progs.nix b/pkgs/os-specific/linux/libcap/progs.nix
index ae4446c82e6c..e3871f15f885 100644
--- a/pkgs/os-specific/linux/libcap/progs.nix
+++ b/pkgs/os-specific/linux/libcap/progs.nix
@@ -21,5 +21,8 @@ stdenv.mkDerivation rec {
 
   installFlags = "RAISE_SETFCAP=no";
 
-  postInstall = libcap.postinst name;
+  postInstall = ''
+    mkdir -p "$out/share/doc/${name}"
+    cp ../License "$out/share/doc/${name}/"
+  '';
 }
diff --git a/pkgs/os-specific/linux/libnl/default.nix b/pkgs/os-specific/linux/libnl/default.nix
index afd9695420e3..1e1ed0a6112c 100644
--- a/pkgs/os-specific/linux/libnl/default.nix
+++ b/pkgs/os-specific/linux/libnl/default.nix
@@ -11,6 +11,8 @@ stdenv.mkDerivation {
     owner = "thom311";
   };
 
+  outputs = [ "dev" "bin" "out" "man" ];
+
   nativeBuildInputs = [ autoreconfHook bison flex pkgconfig ];
 
   meta = {
diff --git a/pkgs/os-specific/linux/lvm2/default.nix b/pkgs/os-specific/linux/lvm2/default.nix
index 351c2f609814..9147cb813714 100644
--- a/pkgs/os-specific/linux/lvm2/default.nix
+++ b/pkgs/os-specific/linux/lvm2/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, udev, utillinux, coreutils, enable_dmeventd ? false }:
+{ stdenv, fetchurl, pkgconfig, systemd, libudev, utillinux, coreutils, enable_dmeventd ? false }:
 
 let
   version = "2.02.140";
@@ -22,7 +22,7 @@ stdenv.mkDerivation {
   ] ++ stdenv.lib.optional enable_dmeventd " --enable-dmeventd";
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ udev ];
+  buildInputs = [ libudev ];
 
   preConfigure =
     ''
@@ -30,7 +30,7 @@ stdenv.mkDerivation {
         --replace /usr/bin/tr ${coreutils}/bin/tr
       substituteInPlace scripts/lvm2_activation_generator_systemd_red_hat.c \
         --replace /usr/sbin/lvm $out/sbin/lvm \
-        --replace /usr/bin/udevadm ${udev}/bin/udevadm
+        --replace /usr/bin/udevadm ${systemd.udev.bin}/bin/udevadm
 
       sed -i /DEFAULT_SYS_DIR/d Makefile.in
       sed -i /DEFAULT_PROFILE_DIR/d conf/Makefile.in
diff --git a/pkgs/os-specific/linux/lxc/default.nix b/pkgs/os-specific/linux/lxc/default.nix
index fcfe4975fd72..4ac5d0c7951c 100644
--- a/pkgs/os-specific/linux/lxc/default.nix
+++ b/pkgs/os-specific/linux/lxc/default.nix
@@ -12,11 +12,11 @@ in
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "lxc-${version}";
-  version = "1.1.5";
+  version = "2.0.0";
 
   src = fetchurl {
     url = "https://linuxcontainers.org/downloads/lxc/lxc-${version}.tar.gz";
-    sha256 = "1gnhgs4i2zamfdydj895inr9i072658wd47nf1ryw5710hdsv24m";
+    sha256 = "1r0hgk91n3frrmla1681l74ag5sngbbkdagvjfqzxwcf9l8pwwsv";
   };
 
   nativeBuildInputs = [
@@ -29,10 +29,6 @@ stdenv.mkDerivation rec {
 
   patches = [
     ./support-db2x.patch
-    (fetchpatch {
-      url = "https://github.com/lxc/lxc/commit/3db8dd39a797f87f8b348f1b6b44953a25f3f170.patch";
-      sha256 = "0scbzm9dqqhqsl0ri8da8a34r4qj9ph0cg68l9s7gw01vpvqbs8l";
-    })
   ];
 
   XML_CATALOG_FILES = "${docbook_xml_dtd_45}/xml/dtd/docbook/catalog.xml";
@@ -40,7 +36,6 @@ stdenv.mkDerivation rec {
   configureFlags = [
     "--localstatedir=/var"
     "--sysconfdir=/etc"
-    "--enable-doc"
     "--disable-api-docs"
     "--with-init-script=none"
     "--with-distro=nixos" # just to be sure it is "unknown"
diff --git a/pkgs/os-specific/linux/lxc/support-db2x.patch b/pkgs/os-specific/linux/lxc/support-db2x.patch
index 4662ca2e5048..16715992d35f 100644
--- a/pkgs/os-specific/linux/lxc/support-db2x.patch
+++ b/pkgs/os-specific/linux/lxc/support-db2x.patch
@@ -1,8 +1,8 @@
 diff --git a/configure.ac b/configure.ac
-index 92a4690..4dd341b 100644
+index 84f8699..dce9033 100644
 --- a/configure.ac
 +++ b/configure.ac
-@@ -91,9 +91,9 @@ if test "x$enable_doc" = "xyes" -o "x$enable_doc" = "xauto"; then
+@@ -192,9 +192,9 @@ if test "x$enable_doc" = "xyes" -o "x$enable_doc" = "xauto"; then
  	AC_SUBST(db2xman)
  fi
  AM_CONDITIONAL([ENABLE_DOCBOOK], [test "x$db2xman" != "x"])
diff --git a/pkgs/os-specific/linux/mdadm/default.nix b/pkgs/os-specific/linux/mdadm/default.nix
index 465dc58199ed..3fe9d462412c 100644
--- a/pkgs/os-specific/linux/mdadm/default.nix
+++ b/pkgs/os-specific/linux/mdadm/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
 
   # This is to avoid self-references, which causes the initrd to explode
   # in size and in turn prevents mdraid systems from booting.
-  allowedReferences = [ stdenv.glibc ];
+  allowedReferences = [ stdenv.glibc.out ];
 
   patches = [ ./no-self-references.patch ];
 
diff --git a/pkgs/os-specific/linux/module-init-tools/default.nix b/pkgs/os-specific/linux/module-init-tools/default.nix
index 1302d7b1fef0..ded6e77e43b4 100644
--- a/pkgs/os-specific/linux/module-init-tools/default.nix
+++ b/pkgs/os-specific/linux/module-init-tools/default.nix
@@ -1,5 +1,7 @@
 { stdenv, fetchurl, docbook2x, docbook_sgml_dtd_41 }:
 
+assert (stdenv.lib.elem stdenv.system stdenv.lib.platforms.linux);
+
 stdenv.mkDerivation {
   name = "module-init-tools-3.16";
 
@@ -20,6 +22,8 @@ stdenv.mkDerivation {
     })
   ];
 
+  buildInputs = [ stdenv.glibc.dev stdenv.glibc.static ];
+
   SGML_CATALOG_FILES = "${docbook_sgml_dtd_41}/sgml/dtd/docbook-4.1/docbook.cat";
 
   patches = [ ./module-dir.patch ./docbook2man.patch ];
@@ -29,5 +33,6 @@ stdenv.mkDerivation {
   meta = {
     homepage = http://www.kernel.org/pub/linux/utils/kernel/module-init-tools/;
     description = "Tools for loading and managing Linux kernel modules";
+    platforms = stdenv.lib.platforms.linux;
   };
 }
diff --git a/pkgs/os-specific/linux/nfs-utils/default.nix b/pkgs/os-specific/linux/nfs-utils/default.nix
index 0dde3bca4e47..504d3790d868 100644
--- a/pkgs/os-specific/linux/nfs-utils/default.nix
+++ b/pkgs/os-specific/linux/nfs-utils/default.nix
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
       "--with-statedir=/var/lib/nfs"
       "--with-tirpcinclude=${libtirpc}/include/tirpc"
     ]
-    ++ stdenv.lib.optional (stdenv ? glibc) "--with-rpcgen=${stdenv.glibc}/bin/rpcgen";
+    ++ stdenv.lib.optional (stdenv ? glibc) "--with-rpcgen=${stdenv.glibc.bin}/bin/rpcgen";
 
   patchPhase =
     ''
diff --git a/pkgs/os-specific/linux/pam/default.nix b/pkgs/os-specific/linux/pam/default.nix
index f7cadd469d70..d84c6224eebe 100644
--- a/pkgs/os-specific/linux/pam/default.nix
+++ b/pkgs/os-specific/linux/pam/default.nix
@@ -9,10 +9,14 @@ stdenv.mkDerivation rec {
     sha256 = "1n9lnf9gjs72kbj1g354v1xhi2j27aqaah15vykh7cnkq08i4arl";
   };
 
+  outputs = [ "out" "doc" "man" /* "modules" */ ];
+
   nativeBuildInputs = [ flex ];
 
   buildInputs = [ cracklib ];
 
+  enableParallelBuilding = true;
+
   crossAttrs = {
     propagatedBuildInputs = [ flex.crossDrv cracklib.crossDrv ];
     preConfigure = preConfigure + ''
@@ -31,7 +35,14 @@ stdenv.mkDerivation rec {
   postInstall = ''
     mv -v $out/sbin/unix_chkpwd{,.orig}
     ln -sv /var/setuid-wrappers/unix_chkpwd $out/sbin/unix_chkpwd
-  '';
+  ''; /*
+    rm -rf $out/etc
+    mkdir -p $modules/lib
+    mv $out/lib/security $modules/lib/
+  '';*/
+  # don't move modules, because libpam needs to (be able to) find them,
+  # which is done by dlopening $out/lib/security/pam_foo.so
+  # $out/etc was also missed: pam_env(login:session): Unable to open config file
 
   preConfigure = ''
     configureFlags="$configureFlags --includedir=$out/include/security"
diff --git a/pkgs/os-specific/linux/shadow/default.nix b/pkgs/os-specific/linux/shadow/default.nix
index f928dc8e657c..321e94e3aaf4 100644
--- a/pkgs/os-specific/linux/shadow/default.nix
+++ b/pkgs/os-specific/linux/shadow/default.nix
@@ -37,7 +37,7 @@ stdenv.mkDerivation rec {
 
   preBuild = assert glibc != null;
     ''
-      substituteInPlace lib/nscd.c --replace /usr/sbin/nscd ${glibc}/sbin/nscd
+      substituteInPlace lib/nscd.c --replace /usr/sbin/nscd ${glibc.bin}/bin/nscd
     '';
 
   postInstall =
diff --git a/pkgs/os-specific/linux/sysdig/default.nix b/pkgs/os-specific/linux/sysdig/default.nix
index c9a594e684cf..8296ec62c5b2 100644
--- a/pkgs/os-specific/linux/sysdig/default.nix
+++ b/pkgs/os-specific/linux/sysdig/default.nix
@@ -3,10 +3,10 @@ let
   inherit (stdenv.lib) optional optionalString;
   s = rec {
     baseName="sysdig";
-    version = "0.8.0";
+    version = "0.9.0";
     name="${baseName}-${version}";
     url="https://github.com/draios/sysdig/archive/${version}.tar.gz";
-    sha256 = "1939k3clwxg09m1bn0szqiy2nxg66srl72n7476jc58hgaraq3dr";
+    sha256 = "198x1zmlydvi4i1sfvs8xjh9z5pb47l6xs4phrnkwwak46rhka3j";
   };
   buildInputs = [
     cmake zlib luajit ncurses perl jsoncpp libb64 openssl curl
diff --git a/pkgs/os-specific/linux/sysstat/default.nix b/pkgs/os-specific/linux/sysstat/default.nix
index 6544210b2067..16431c465c16 100644
--- a/pkgs/os-specific/linux/sysstat/default.nix
+++ b/pkgs/os-specific/linux/sysstat/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
   preConfigure = ''
     export PATH_CP=$(type -tp cp)
     export PATH_CHKCONFIG=/no-such-program
-    export BZIP=${bzip2}/bin/bzip2
+    export BZIP=${bzip2.bin}/bin/bzip2
     export SYSTEMCTL=systemctl
   '';
 
diff --git a/pkgs/os-specific/linux/systemd/cryptsetup-generator.nix b/pkgs/os-specific/linux/systemd/cryptsetup-generator.nix
new file mode 100644
index 000000000000..2935990755c6
--- /dev/null
+++ b/pkgs/os-specific/linux/systemd/cryptsetup-generator.nix
@@ -0,0 +1,25 @@
+{ stdenv, systemd, cryptsetup }:
+
+assert stdenv.isLinux;
+
+stdenv.lib.overrideDerivation systemd (p: {
+  version = p.version;
+  name = "systemd-cryptsetup-generator";
+
+  nativeBuildInputs = p.nativeBuildInputs ++ [ cryptsetup ];
+  outputs = [ "out" ];
+
+  buildPhase = ''
+    make $makeFlags built-sources
+    make $makeFlags systemd-cryptsetup
+    make $makeFlags systemd-cryptsetup-generator
+  '';
+
+  installPhase = ''
+    mkdir -p $out/lib/systemd/
+    cp systemd-cryptsetup $out/lib/systemd/systemd-cryptsetup
+
+    mkdir -p $out/lib/systemd/system-generators/
+    cp systemd-cryptsetup-generator $out/lib/systemd/system-generators/systemd-cryptsetup-generator
+  '';
+})
diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix
index cb1521a4005e..0f066e380c1b 100644
--- a/pkgs/os-specific/linux/systemd/default.nix
+++ b/pkgs/os-specific/linux/systemd/default.nix
@@ -1,5 +1,5 @@
-{ stdenv, fetchFromGitHub, pkgconfig, intltool, gperf, libcap, dbus, kmod
-, xz, pam, acl, cryptsetup, libuuid, m4, utillinuxMinimal
+{ stdenv, fetchFromGitHub, pkgconfig, intltool, gperf, libcap, kmod
+, zlib, xz, pam, acl, cryptsetup, libuuid, m4, utillinux, libffi
 , glib, kbd, libxslt, coreutils, libgcrypt, libgpgerror, libapparmor, audit, lz4
 , kexectools, libmicrohttpd, linuxHeaders, libseccomp
 , autoreconfHook, gettext, docbook_xsl, docbook_xml_dtd_42, docbook_xml_dtd_45
@@ -19,18 +19,27 @@ stdenv.mkDerivation rec {
     sha256 = "1q0pyrljmq73qcan9rfqsiw66l1g159m5in5qgb8zwlwhl928670";
   };
 
-  outputs = [ "out" "man" "doc" ];
+  patches = [ ./hwdb-location.diff ];
+
+  /* gave up for now!
+  outputs = [ "out" "libudev" "doc" ]; # maybe: "dev"
+  # note: there are many references to ${systemd}/...
+  outputDev = "out";
+  propagatedBuildOutputs = "libudev";
+  */
+  outputs = [ "out" "man" ];
 
   buildInputs =
     [ linuxHeaders pkgconfig intltool gperf libcap kmod xz pam acl
       /* cryptsetup */ libuuid m4 glib libxslt libgcrypt libgpgerror
-      libmicrohttpd kexectools libseccomp audit lz4 libapparmor
+      libmicrohttpd kexectools libseccomp libffi audit lz4 libapparmor
       /* FIXME: we may be able to prevent the following dependencies
          by generating an autoconf'd tarball, but that's probably not
          worth it. */
       autoreconfHook gettext docbook_xsl docbook_xml_dtd_42 docbook_xml_dtd_45
     ];
 
+
   configureFlags =
     [ "--localstatedir=/var"
       "--sysconfdir=/etc"
@@ -74,14 +83,15 @@ stdenv.mkDerivation rec {
       for i in src/remount-fs/remount-fs.c src/core/mount.c src/core/swap.c src/fsck/fsck.c units/emergency.service.in units/rescue.service.in src/journal/cat.c src/core/shutdown.c src/nspawn/nspawn.c src/shared/generator.c; do
         test -e $i
         substituteInPlace $i \
-          --replace /usr/bin/getent ${stdenv.glibc}/bin/getent \
-          --replace /bin/mount ${utillinuxMinimal}/bin/mount \
-          --replace /bin/umount ${utillinuxMinimal}/bin/umount \
-          --replace /sbin/swapon ${utillinuxMinimal}/sbin/swapon \
-          --replace /sbin/swapoff ${utillinuxMinimal}/sbin/swapoff \
+          --replace /usr/bin/getent ${stdenv.glibc.bin}/bin/getent \
+          --replace /bin/mount ${utillinux.bin}/bin/mount \
+          --replace /bin/umount ${utillinux.bin}/bin/umount \
+          --replace /sbin/swapon ${utillinux.bin}/sbin/swapon \
+          --replace /sbin/swapoff ${utillinux.bin}/sbin/swapoff \
+          --replace /sbin/fsck ${utillinux.bin}/sbin/fsck \
           --replace /bin/echo ${coreutils}/bin/echo \
           --replace /bin/cat ${coreutils}/bin/cat \
-          --replace /sbin/sulogin ${utillinuxMinimal}/sbin/sulogin \
+          --replace /sbin/sulogin ${utillinux.bin}/sbin/sulogin \
           --replace /usr/lib/systemd/systemd-fsck $out/lib/systemd/systemd-fsck
       done
 
@@ -89,12 +99,24 @@ stdenv.mkDerivation rec {
         --replace /usr/lib/systemd/catalog/ $out/lib/systemd/catalog/
 
       configureFlagsArray+=("--with-ntp-servers=0.nixos.pool.ntp.org 1.nixos.pool.ntp.org 2.nixos.pool.ntp.org 3.nixos.pool.ntp.org")
+
+      #export NIX_CFLAGS_LINK+=" -Wl,-rpath,$libudev/lib"
     '';
 
+  /*
+  makeFlags = [
+    "udevlibexecdir=$(libudev)/lib/udev"
+    # udev rules refer to $out, and anything but libs should probably go to $out
+    "udevrulesdir=$(out)/lib/udev/rules.d"
+    "udevhwdbdir=$(out)/lib/udev/hwdb.d"
+  ];
+  */
+
+
   PYTHON_BINARY = "${coreutils}/bin/env python"; # don't want a build time dependency on Python
 
   NIX_CFLAGS_COMPILE =
-    [ # Can't say ${polkit}/bin/pkttyagent here because that would
+    [ # Can't say ${polkit.bin}/bin/pkttyagent here because that would
       # lead to a cyclic dependency.
       "-UPOLKIT_AGENT_BINARY_PATH" "-DPOLKIT_AGENT_BINARY_PATH=\"/run/current-system/sw/bin/pkttyagent\""
       "-fno-stack-protector"
@@ -147,8 +169,30 @@ stdenv.mkDerivation rec {
       # "kernel-install" shouldn't be used on NixOS.
       find $out -name "*kernel-install*" -exec rm {} \;
     ''; # */
+  /*
+      # Move lib(g)udev to a separate output. TODO: maybe split them up
+      #   to avoid libudev pulling glib
+      mkdir -p "$libudev/lib"
+      mv "$out"/lib/lib{,g}udev* "$libudev/lib/"
+
+      for i in "$libudev"/lib/*.la; do
+        substituteInPlace $i --replace "$out" "$libudev"
+      done
+      for i in "$out"/lib/pkgconfig/{libudev,gudev-1.0}.pc; do
+        substituteInPlace $i --replace "libdir=$out" "libdir=$libudev"
+      done
+  */
 
   enableParallelBuilding = true;
+  /*
+  # some libs fail to link to liblzma and/or libffi
+  postFixup = let extraLibs = stdenv.lib.makeLibraryPath [ xz.out libffi.out zlib.out ];
+    in ''
+      for f in "$out"/lib/*.so.0.*; do
+        patchelf --set-rpath `patchelf --print-rpath "$f"`':${extraLibs}' "$f"
+      done
+    '';
+  */
 
   # The interface version prevents NixOS from switching to an
   # incompatible systemd at runtime.  (Switching across reboots is
@@ -165,3 +209,4 @@ stdenv.mkDerivation rec {
     maintainers = [ stdenv.lib.maintainers.eelco stdenv.lib.maintainers.simons ];
   };
 }
+
diff --git a/pkgs/os-specific/linux/systemd/hwdb-location.diff b/pkgs/os-specific/linux/systemd/hwdb-location.diff
new file mode 100644
index 000000000000..31e7a027f50d
--- /dev/null
+++ b/pkgs/os-specific/linux/systemd/hwdb-location.diff
@@ -0,0 +1,19 @@
+diff --git a/src/libsystemd/sd-hwdb/sd-hwdb.c b/src/libsystemd/sd-hwdb/sd-hwdb.c
+index 06c9831..e74825c 100644
+--- a/src/libsystemd/sd-hwdb/sd-hwdb.c
++++ b/src/libsystemd/sd-hwdb/sd-hwdb.c
+@@ -268,13 +268,8 @@ static int trie_search_f(sd_hwdb *hwdb, const char *search) {
+ }
+ 
+ static const char hwdb_bin_paths[] =
+-        "/etc/systemd/hwdb/hwdb.bin\0"
+         "/etc/udev/hwdb.bin\0"
+-        "/usr/lib/systemd/hwdb/hwdb.bin\0"
+-#ifdef HAVE_SPLIT_USR
+-        "/lib/systemd/hwdb/hwdb.bin\0"
+-#endif
+-        UDEVLIBEXECDIR "/hwdb.bin\0";
++        ;
+ 
+ _public_ int sd_hwdb_new(sd_hwdb **ret) {
+         _cleanup_hwdb_unref_ sd_hwdb *hwdb = NULL;
diff --git a/pkgs/os-specific/linux/systemd/libudev.nix b/pkgs/os-specific/linux/systemd/libudev.nix
new file mode 100644
index 000000000000..0fe45aee9164
--- /dev/null
+++ b/pkgs/os-specific/linux/systemd/libudev.nix
@@ -0,0 +1,19 @@
+{ stdenv, systemd }:
+
+stdenv.mkDerivation {
+  name = "libudev-${systemd.version}";
+
+  unpackPhase = ":";
+  outputs = [ "dev" "out" ];
+  installPhase = ''
+    mkdir -p "$out/lib" "$dev/lib/pkgconfig" "$dev/include"
+    cp -P "${systemd}"/lib/libudev.* "$out/lib/"
+    cp -P "${systemd}"/lib/pkgconfig/libudev.pc "$dev/lib/pkgconfig/"
+    cp -P "${systemd}"/include/libudev.h "$dev/include/"
+
+    substituteInPlace "$dev"/lib/pkgconfig/*.pc \
+      --replace "${systemd}" "$out"
+    sed "/^includedir=/cincludedir=$dev/include" -i "$dev"/lib/pkgconfig/*.pc
+  '';
+}
+
diff --git a/pkgs/os-specific/linux/udev/145.nix b/pkgs/os-specific/linux/udev/145.nix
new file mode 100644
index 000000000000..6dd551e1ce13
--- /dev/null
+++ b/pkgs/os-specific/linux/udev/145.nix
@@ -0,0 +1,53 @@
+{ stdenv, fetchurl, gperf, pkgconfig, glib, acl, libusb, usbutils, pciutils }:
+
+assert stdenv ? glibc;
+
+stdenv.mkDerivation rec {
+  name = "udev-145";
+
+  src = fetchurl {
+    url = "mirror://kernel/linux/utils/kernel/hotplug/${name}.tar.bz2";
+    sha256 = "1zmibp6n7d582fqx8vmg9vb2a1435hghfpz36056bc25ccwf7yiv";
+  };
+
+  buildInputs = [gperf pkgconfig glib acl libusb usbutils];
+
+  configureFlags = "--with-pci-ids-path=${pciutils}/share/pci.ids";
+
+  preConfigure =
+    ''
+      substituteInPlace extras/keymap/Makefile.in \
+        --replace /usr/include ${stdenv.glibc.dev}/include
+    '';
+
+  postInstall =
+    ''
+      # Install some rules that really should be installed by default.
+      for i in 40-alsa.rules 40-infiniband.rules 40-isdn.rules 40-pilot-links.rules 64-device-mapper.rules 64-md-raid.rules; do
+        cp rules/packages/$i $out/libexec/rules.d/
+      done
+
+      # The path to rule_generator.functions in write_cd_rules and
+      # write_net_rules is broken.  Also, don't store the mutable
+      # persistant rules in /etc/udev/rules.d but in
+      # /var/lib/udev/rules.d.
+      for i in $out/libexec/write_cd_rules $out/libexec/write_net_rules; do
+        substituteInPlace $i \
+          --replace /lib/udev $out/libexec \
+          --replace /etc/udev/rules.d /var/lib/udev/rules.d
+      done
+
+      # Don't set PATH to /bin:/sbin; won't work in NixOS.
+      substituteInPlace $out/libexec/rule_generator.functions \
+        --replace 'PATH=' '#PATH='
+
+      # Don't hardcore the FIRMWARE_DIRS variable; obtain it from the
+      # environment of the caller.
+      sed '3,4d' -i $out/libexec/firmware.sh
+    '';
+
+  meta = {
+    homepage = http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html;
+    description = "Udev manages the /dev filesystem";
+  };
+}
diff --git a/pkgs/os-specific/linux/util-linux/default.nix b/pkgs/os-specific/linux/util-linux/default.nix
index a84740b1a30b..263fa4490dc8 100644
--- a/pkgs/os-specific/linux/util-linux/default.nix
+++ b/pkgs/os-specific/linux/util-linux/default.nix
@@ -1,6 +1,4 @@
-{ stdenv, fetchurl, zlib, ncurses ? null, perl ? null, pam, systemd ? null
-, pkgconfig
-}:
+{ stdenv, fetchurl, pkgconfig, zlib, ncurses ? null, perl ? null, pam, systemd }:
 
 stdenv.mkDerivation rec {
   name = "util-linux-2.27.1";
@@ -10,12 +8,15 @@ stdenv.mkDerivation rec {
     sha256 = "1452hz5zx56a3mad8yrg5wb0vy5zi19mpjp6zx1yr6p9xp6qz08a";
   };
 
-  outputs = [ "out" "man" ];
-
   patches = [
     ./rtcwake-search-PATH-for-shutdown.patch
   ];
 
+  outputs = [ "bin" "out" "man" ]; # TODO: $bin is kept the first for now
+  # due to lots of ${utillinux}/bin occurences and headers being rather small
+  outputDev = "bin";
+
+
   #FIXME: make it also work on non-nixos?
   postPatch = ''
     # Substituting store paths would create a circular dependency on systemd
@@ -46,6 +47,9 @@ stdenv.mkDerivation rec {
     ''}
   '';
 
+  makeFlags = "usrbin_execdir=$(bin)/bin usrsbin_execdir=$(bin)/sbin";
+
+  nativeBuildInputs = [ pkgconfig ];
   buildInputs =
     [ zlib pam ]
     ++ stdenv.lib.optional (ncurses != null) ncurses
@@ -53,15 +57,16 @@ stdenv.mkDerivation rec {
     ++ stdenv.lib.optional (perl != null) perl;
 
   postInstall = ''
-    rm $out/bin/su # su should be supplied by the su package (shadow)
+    rm "$bin/bin/su" # su should be supplied by the su package (shadow)
   '';
 
   enableParallelBuilding = true;
 
-  meta = {
+  meta = with stdenv.lib; {
     homepage = http://www.kernel.org/pub/linux/utils/util-linux/;
     description = "A set of system utilities for Linux";
-    platforms = stdenv.lib.platforms.linux;
+    license = licenses.gpl2; # also contains parts under more permissive licenses
+    platforms = platforms.linux;
     priority = 6; # lower priority than coreutils ("kill") and shadow ("login" etc.) packages
   };
 }