about summary refs log tree commit diff
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2016-08-15 19:05:52 -0400
committerShea Levy <shea@shealevy.com>2016-08-15 19:05:52 -0400
commit9adad8612b082bcbae30c81678a04b79a44079a4 (patch)
tree6814d056ee2960d122842dc9c830bb411c40d5ff
parent57b2d1e9b0dcdd1d25bd2d450174764b9417ffc1 (diff)
downloadnixlib-9adad8612b082bcbae30c81678a04b79a44079a4.tar
nixlib-9adad8612b082bcbae30c81678a04b79a44079a4.tar.gz
nixlib-9adad8612b082bcbae30c81678a04b79a44079a4.tar.bz2
nixlib-9adad8612b082bcbae30c81678a04b79a44079a4.tar.lz
nixlib-9adad8612b082bcbae30c81678a04b79a44079a4.tar.xz
nixlib-9adad8612b082bcbae30c81678a04b79a44079a4.tar.zst
nixlib-9adad8612b082bcbae30c81678a04b79a44079a4.zip
Revert "Merge branch 'modprobe-fix' of git://github.com/abbradar/nixpkgs"
Was meant to go into staging, sorry

This reverts commit 57b2d1e9b0dcdd1d25bd2d450174764b9417ffc1, reversing
changes made to 760b2b9048ea775c319cb348d74447a20dea513e.
-rw-r--r--nixos/modules/config/zram.nix2
-rw-r--r--nixos/modules/hardware/video/bumblebee.nix1
-rw-r--r--nixos/modules/hardware/video/webcam/facetimehd.nix1
-rw-r--r--nixos/modules/services/hardware/tlp.nix4
-rw-r--r--nixos/modules/services/hardware/udev.nix5
-rw-r--r--nixos/modules/services/network-filesystems/openafs-client/default.nix2
-rw-r--r--nixos/modules/services/networking/fan.nix2
-rw-r--r--nixos/modules/services/networking/strongswan.nix2
-rw-r--r--nixos/modules/system/boot/kernel.nix5
-rw-r--r--nixos/modules/system/boot/modprobe.nix41
-rw-r--r--nixos/modules/system/boot/stage-2-init.sh1
-rw-r--r--nixos/modules/tasks/cpu-freq.nix2
-rw-r--r--nixos/modules/virtualisation/docker.nix3
-rw-r--r--nixos/modules/virtualisation/qemu-vm.nix26
-rw-r--r--pkgs/development/libraries/fftw/default.nix22
-rw-r--r--pkgs/development/libraries/libdrm/default.nix4
-rw-r--r--pkgs/development/libraries/mesa/default.nix127
-rw-r--r--pkgs/development/python-modules/generic/run_setup.py2
-rw-r--r--pkgs/development/tools/misc/lttng-tools/default.nix2
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/Libc/default.nix4
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix69
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/configd/default.nix15
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/default.nix25
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/libpthread/default.nix10
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix25
-rw-r--r--pkgs/os-specific/darwin/swift-corefoundation/default.nix32
-rw-r--r--pkgs/os-specific/linux/kernel/manual-config.nix4
-rw-r--r--pkgs/os-specific/linux/kmod/aggregator.nix2
-rw-r--r--pkgs/os-specific/linux/kmod/default.nix30
-rw-r--r--pkgs/os-specific/linux/kmod/module-dir.patch151
-rw-r--r--pkgs/stdenv/darwin/make-bootstrap-tools.nix3
-rw-r--r--pkgs/tools/networking/network-manager/0.9.8/default.nix8
-rw-r--r--pkgs/tools/networking/network-manager/0.9.8/nixos-purity.patch4
-rw-r--r--pkgs/tools/networking/network-manager/default.nix4
-rw-r--r--pkgs/tools/networking/network-manager/openconnect.nix6
-rw-r--r--pkgs/tools/networking/network-manager/openvpn.nix6
-rw-r--r--pkgs/tools/networking/network-manager/vpnc.nix6
-rw-r--r--pkgs/tools/text/diffutils/default.nix4
-rw-r--r--pkgs/top-level/all-packages.nix2
39 files changed, 300 insertions, 364 deletions
diff --git a/nixos/modules/config/zram.nix b/nixos/modules/config/zram.nix
index ad41ad4f3d7c..019932b04e8d 100644
--- a/nixos/modules/config/zram.nix
+++ b/nixos/modules/config/zram.nix
@@ -8,7 +8,7 @@ let
 
   devices = map (nr: "zram${toString nr}") (range 0 (cfg.numDevices - 1));
 
-  modprobe = "${pkgs.kmod}/bin/modprobe";
+  modprobe = "${config.system.sbin.modprobe}/sbin/modprobe";
 
 in
 
diff --git a/nixos/modules/hardware/video/bumblebee.nix b/nixos/modules/hardware/video/bumblebee.nix
index 69db518ab21c..b10846ac18a1 100644
--- a/nixos/modules/hardware/video/bumblebee.nix
+++ b/nixos/modules/hardware/video/bumblebee.nix
@@ -75,6 +75,7 @@ in
       serviceConfig = {
         ExecStart = "${bumblebee}/bin/bumblebeed --use-syslog -g ${cfg.group} --driver ${cfg.driver}";
       };
+      environment.MODULE_DIR="/run/current-system/kernel-modules/lib/modules/";
     };
   };
 }
diff --git a/nixos/modules/hardware/video/webcam/facetimehd.nix b/nixos/modules/hardware/video/webcam/facetimehd.nix
index d311f600c319..2a2fcf3057d4 100644
--- a/nixos/modules/hardware/video/webcam/facetimehd.nix
+++ b/nixos/modules/hardware/video/webcam/facetimehd.nix
@@ -36,6 +36,7 @@ in
 
     # and load it back on resume
     powerManagement.resumeCommands = ''
+      export MODULE_DIR=/run/current-system/kernel-modules/lib/modules
       ${pkgs.kmod}/bin/modprobe -v facetimehd
     '';
 
diff --git a/nixos/modules/services/hardware/tlp.nix b/nixos/modules/services/hardware/tlp.nix
index 281d02a8c65e..5ab7daafa85b 100644
--- a/nixos/modules/services/hardware/tlp.nix
+++ b/nixos/modules/services/hardware/tlp.nix
@@ -72,6 +72,8 @@ in
           ExecStart = "${tlp}/bin/tlp init start";
           ExecStop = "${tlp}/bin/tlp init stop";
         };
+
+        environment.MODULE_DIR="/run/current-system/kernel-modules/lib/modules/";
       };
 
       tlp-sleep = {
@@ -90,6 +92,8 @@ in
           ExecStart = "${tlp}/bin/tlp suspend";
           ExecStop = "${tlp}/bin/tlp resume";
         };
+
+        environment.MODULE_DIR="/run/current-system/kernel-modules/lib/modules/";
       };
     };
 
diff --git a/nixos/modules/services/hardware/udev.nix b/nixos/modules/services/hardware/udev.nix
index 7c4c93d0fcb3..e7741083d1ae 100644
--- a/nixos/modules/services/hardware/udev.nix
+++ b/nixos/modules/services/hardware/udev.nix
@@ -58,7 +58,7 @@ let
       # Fix some paths in the standard udev rules.  Hacky.
       for i in $out/*.rules; do
         substituteInPlace $i \
-          --replace \"/sbin/modprobe \"${pkgs.kmod}/bin/modprobe \
+          --replace \"/sbin/modprobe \"${config.system.sbin.modprobe}/sbin/modprobe \
           --replace \"/sbin/mdadm \"${pkgs.mdadm}/sbin/mdadm \
           --replace \"/sbin/blkid \"${pkgs.utillinux}/sbin/blkid \
           --replace \"/bin/mount \"${pkgs.utillinux}/bin/mount \
@@ -316,7 +316,8 @@ in
       '';
 
     systemd.services.systemd-udevd =
-      { restartTriggers = cfg.packages;
+      { environment.MODULE_DIR = "/run/booted-system/kernel-modules/lib/modules";
+        restartTriggers = cfg.packages;
       };
 
   };
diff --git a/nixos/modules/services/network-filesystems/openafs-client/default.nix b/nixos/modules/services/network-filesystems/openafs-client/default.nix
index 891f41c8dcdc..61c66bb88357 100644
--- a/nixos/modules/services/network-filesystems/openafs-client/default.nix
+++ b/nixos/modules/services/network-filesystems/openafs-client/default.nix
@@ -80,7 +80,7 @@ in
       preStart = ''
         mkdir -p -m 0755 /afs
         mkdir -m 0700 -p ${cfg.cacheDirectory}
-        ${pkgs.kmod}/bin/insmod ${openafsPkgs}/lib/openafs/libafs-*.ko || true
+        ${pkgs.kmod}/sbin/insmod ${openafsPkgs}/lib/openafs/libafs-*.ko || true
         ${openafsPkgs}/sbin/afsd -confdir ${afsConfig} -cachedir ${cfg.cacheDirectory} ${if cfg.sparse then "-dynroot-sparse" else "-dynroot"} -fakestat -afsdb
         ${openafsPkgs}/bin/fs setcrypt ${if cfg.crypt then "on" else "off"}
       '';
diff --git a/nixos/modules/services/networking/fan.nix b/nixos/modules/services/networking/fan.nix
index 7f4e36478325..3170567e5b4a 100644
--- a/nixos/modules/services/networking/fan.nix
+++ b/nixos/modules/services/networking/fan.nix
@@ -5,7 +5,7 @@ with lib;
 let
 
   cfg = config.networking.fan;
-  modprobe = "${pkgs.kmod}/bin/modprobe";
+  modprobe = "${config.system.sbin.modprobe}/sbin/modprobe";
 
 in
 
diff --git a/nixos/modules/services/networking/strongswan.nix b/nixos/modules/services/networking/strongswan.nix
index 8778b0364f9a..d6960a5df471 100644
--- a/nixos/modules/services/networking/strongswan.nix
+++ b/nixos/modules/services/networking/strongswan.nix
@@ -118,7 +118,7 @@ in
     systemd.services.strongswan = {
       description = "strongSwan IPSec Service";
       wantedBy = [ "multi-user.target" ];
-      path = with pkgs; [ kmod iproute iptables utillinux ]; # XXX Linux
+      path = with pkgs; [ config.system.sbin.modprobe iproute iptables utillinux ]; # XXX Linux
       wants = [ "keys.target" ];
       after = [ "network.target" "keys.target" ];
       environment = {
diff --git a/nixos/modules/system/boot/kernel.nix b/nixos/modules/system/boot/kernel.nix
index 0f342f44fe76..a6bbca9b30bb 100644
--- a/nixos/modules/system/boot/kernel.nix
+++ b/nixos/modules/system/boot/kernel.nix
@@ -228,6 +228,7 @@ in
     systemd.services."systemd-modules-load" =
       { wantedBy = [ "multi-user.target" ];
         restartTriggers = [ kernelModulesConf ];
+        environment.MODULE_DIR = "/run/booted-system/kernel-modules/lib/modules";
         serviceConfig =
           { # Ignore failed module loads.  Typically some of the
             # modules in ‘boot.kernelModules’ are "nice to have but
@@ -237,6 +238,10 @@ in
           };
       };
 
+    systemd.services.kmod-static-nodes =
+      { environment.MODULE_DIR = "/run/booted-system/kernel-modules/lib/modules";
+      };
+
     lib.kernelConfig = {
       isYes = option: {
         assertion = config: config.isYes option;
diff --git a/nixos/modules/system/boot/modprobe.nix b/nixos/modules/system/boot/modprobe.nix
index b915a98d5375..9bb10eac9880 100644
--- a/nixos/modules/system/boot/modprobe.nix
+++ b/nixos/modules/system/boot/modprobe.nix
@@ -8,6 +8,41 @@ with lib;
 
   options = {
 
+    system.sbin.modprobe = mkOption {
+      internal = true;
+      default = pkgs.stdenv.mkDerivation {
+        name = "modprobe";
+        buildCommand = ''
+          mkdir -p $out/bin
+          for i in ${pkgs.kmod}/sbin/*; do
+            name=$(basename $i)
+            echo "$text" > $out/bin/$name
+            echo 'exec '$i' "$@"' >> $out/bin/$name
+            chmod +x $out/bin/$name
+          done
+          ln -s bin $out/sbin
+        '';
+        text =
+          ''
+            #! ${pkgs.stdenv.shell}
+            export MODULE_DIR=/run/current-system/kernel-modules/lib/modules
+
+            # Fall back to the kernel modules used at boot time if the
+            # modules in the current configuration don't match the
+            # running kernel.
+            if [ ! -d "$MODULE_DIR/$(${pkgs.coreutils}/bin/uname -r)" ]; then
+                MODULE_DIR=/run/booted-system/kernel-modules/lib/modules/
+            fi
+
+          '';
+        meta.priority = 4;
+      };
+      description = ''
+        Wrapper around modprobe that sets the path to the modules
+        tree.
+      '';
+    };
+
     boot.blacklistedKernelModules = mkOption {
       type = types.listOf types.str;
       default = [];
@@ -52,7 +87,7 @@ with lib;
       '';
     environment.etc."modprobe.d/debian.conf".source = pkgs.kmod-debian-aliases;
 
-    environment.systemPackages = [ pkgs.kmod ];
+    environment.systemPackages = [ config.system.sbin.modprobe pkgs.kmod ];
 
     system.activationScripts.modprobe =
       ''
@@ -60,9 +95,11 @@ with lib;
         # in the right location in the Nix store for kernel modules).
         # We need this when the kernel (or some module) auto-loads a
         # module.
-        echo ${pkgs.kmod}/bin/modprobe > /proc/sys/kernel/modprobe
+        echo ${config.system.sbin.modprobe}/sbin/modprobe > /proc/sys/kernel/modprobe
       '';
 
+    environment.sessionVariables.MODULE_DIR = "/run/current-system/kernel-modules/lib/modules";
+
   };
 
 }
diff --git a/nixos/modules/system/boot/stage-2-init.sh b/nixos/modules/system/boot/stage-2-init.sh
index c5a14f0766d5..4a7f073ea8ad 100644
--- a/nixos/modules/system/boot/stage-2-init.sh
+++ b/nixos/modules/system/boot/stage-2-init.sh
@@ -207,5 +207,6 @@ exec {logOutFd}>&- {logErrFd}>&-
 # Start systemd.
 echo "starting systemd..."
 PATH=/run/current-system/systemd/lib/systemd \
+    MODULE_DIR=/run/booted-system/kernel-modules/lib/modules \
     LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive \
     exec systemd
diff --git a/nixos/modules/tasks/cpu-freq.nix b/nixos/modules/tasks/cpu-freq.nix
index 2fe7f4f8197a..1f4d1db33cef 100644
--- a/nixos/modules/tasks/cpu-freq.nix
+++ b/nixos/modules/tasks/cpu-freq.nix
@@ -38,7 +38,7 @@ in
       description = "CPU Frequency Governor Setup";
       after = [ "systemd-modules-load.service" ];
       wantedBy = [ "multi-user.target" ];
-      path = [ cpupower pkgs.kmod ];
+      path = [ cpupower config.system.sbin.modprobe ];
       unitConfig.ConditionVirtualization = false;
       serviceConfig = {
         Type = "oneshot";
diff --git a/nixos/modules/virtualisation/docker.nix b/nixos/modules/virtualisation/docker.nix
index ebc2be087a5b..c99fc78d49e7 100644
--- a/nixos/modules/virtualisation/docker.nix
+++ b/nixos/modules/virtualisation/docker.nix
@@ -95,7 +95,8 @@ in
           LimitNPROC = 1048576;
         } // proxy_env;
 
-        path = [ pkgs.kmod ] ++ (optional (cfg.storageDriver == "zfs") pkgs.zfs);
+        path = [ config.system.sbin.modprobe ] ++ (optional (cfg.storageDriver == "zfs") pkgs.zfs);
+        environment.MODULE_DIR = "/run/current-system/kernel-modules/lib/modules";
 
         postStart = if cfg.socketActivation then "" else cfg.postStart;
 
diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix
index 777ee31e4dcc..b77b319f4a28 100644
--- a/nixos/modules/virtualisation/qemu-vm.nix
+++ b/nixos/modules/virtualisation/qemu-vm.nix
@@ -135,13 +135,13 @@ let
         }
         ''
           # Create a /boot EFI partition with 40M
-          ${pkgs.gptfdisk}/bin/sgdisk -G /dev/vda
-          ${pkgs.gptfdisk}/bin/sgdisk -a 1 -n 1:34:2047 -c 1:"BIOS Boot Partition" -t 1:ef02 /dev/vda
-          ${pkgs.gptfdisk}/bin/sgdisk -a 512 -N 2 -c 2:"EFI System" -t 2:ef00 /dev/vda
-          ${pkgs.gptfdisk}/bin/sgdisk -A 1:set:1 /dev/vda
-          ${pkgs.gptfdisk}/bin/sgdisk -A 2:set:2 /dev/vda
-          ${pkgs.gptfdisk}/bin/sgdisk -h 2 /dev/vda
-          ${pkgs.gptfdisk}/bin/sgdisk -C /dev/vda
+          ${pkgs.gptfdisk}/sbin/sgdisk -G /dev/vda
+          ${pkgs.gptfdisk}/sbin/sgdisk -a 1 -n 1:34:2047 -c 1:"BIOS Boot Partition" -t 1:ef02 /dev/vda
+          ${pkgs.gptfdisk}/sbin/sgdisk -a 512 -N 2 -c 2:"EFI System" -t 2:ef00 /dev/vda
+          ${pkgs.gptfdisk}/sbin/sgdisk -A 1:set:1 /dev/vda
+          ${pkgs.gptfdisk}/sbin/sgdisk -A 2:set:2 /dev/vda
+          ${pkgs.gptfdisk}/sbin/sgdisk -h 2 /dev/vda
+          ${pkgs.gptfdisk}/sbin/sgdisk -C /dev/vda
           ${pkgs.utillinux}/bin/sfdisk /dev/vda -A 2
           . /sys/class/block/vda2/uevent
           mknod /dev/vda2 b $MAJOR $MINOR
@@ -151,11 +151,11 @@ let
           ${pkgs.mtools}/bin/mlabel -i /dev/vda2 ::boot
 
           # Mount /boot; load necessary modules first.
-          ${pkgs.kmod}/bin/insmod ${pkgs.linux}/lib/modules/*/kernel/fs/nls/nls_cp437.ko.xz || true
-          ${pkgs.kmod}/bin/insmod ${pkgs.linux}/lib/modules/*/kernel/fs/nls/nls_iso8859-1.ko.xz || true
-          ${pkgs.kmod}/bin/insmod ${pkgs.linux}/lib/modules/*/kernel/fs/fat/fat.ko.xz || true
-          ${pkgs.kmod}/bin/insmod ${pkgs.linux}/lib/modules/*/kernel/fs/fat/vfat.ko.xz || true
-          ${pkgs.kmod}/bin/insmod ${pkgs.linux}/lib/modules/*/kernel/fs/efivarfs/efivarfs.ko.xz || true
+          ${pkgs.kmod}/sbin/insmod ${pkgs.linux}/lib/modules/*/kernel/fs/nls/nls_cp437.ko.xz || true
+          ${pkgs.kmod}/sbin/insmod ${pkgs.linux}/lib/modules/*/kernel/fs/nls/nls_iso8859-1.ko.xz || true
+          ${pkgs.kmod}/sbin/insmod ${pkgs.linux}/lib/modules/*/kernel/fs/fat/fat.ko.xz || true
+          ${pkgs.kmod}/sbin/insmod ${pkgs.linux}/lib/modules/*/kernel/fs/fat/vfat.ko.xz || true
+          ${pkgs.kmod}/sbin/insmod ${pkgs.linux}/lib/modules/*/kernel/fs/efivarfs/efivarfs.ko.xz || true
           mkdir /boot
           mount /dev/vda2 /boot
 
@@ -370,7 +370,7 @@ in
     boot.initrd.extraUtilsCommands =
       ''
         # We need mke2fs in the initrd.
-        copy_bin_and_libs ${pkgs.e2fsprogs}/bin/mke2fs
+        copy_bin_and_libs ${pkgs.e2fsprogs}/sbin/mke2fs
       '';
 
     boot.initrd.postDeviceCommands =
diff --git a/pkgs/development/libraries/fftw/default.nix b/pkgs/development/libraries/fftw/default.nix
index cf009599665e..6b92848fd0f7 100644
--- a/pkgs/development/libraries/fftw/default.nix
+++ b/pkgs/development/libraries/fftw/default.nix
@@ -1,24 +1,34 @@
-{ fetchurl, stdenv, lib, precision ? "double" }:
+{ fetchFromGitHub , stdenv, lib, ocaml, perl, indent, transfig, ghostscript, texinfo, libtool, gettext, automake, autoconf, precision ? "double" }:
 
 with lib;
 
 assert elem precision [ "single" "double" "long-double" "quad-precision" ];
 
-let version = "3.3.5"; in
+let version = "3.3.5-rc1"; in
 
 stdenv.mkDerivation rec {
   name = "fftw-${precision}-${version}";
 
-  src = fetchurl {
-    url = "ftp://ftp.fftw.org/pub/fftw/fftw-${version}.tar.gz";
-    sha256 = "1kwbx92ps0r7s2mqy7lxbxanslxdzj7dp7r7gmdkzv1j8yqf3kwf";
+  src = fetchFromGitHub {
+    owner = "FFTW";
+    repo = "fftw3";
+    rev = "fftw-${version}";
+    sha256 = "1gc57xvdqbapq30ylj3fxwkv61la4kzyf7ji0q0xqjwpji2ynqi4";
   };
 
+  nativeBuildInputs = [ ocaml perl indent transfig ghostscript texinfo libtool gettext automake autoconf ];
+
+  # remove the ./configure lines, so we can use nix's configureFlags
+  patchPhase = "sed -e '27,29d' -i bootstrap.sh";
+
+  preConfigurePhases =  "./bootstrap.sh";
+
   outputs = [ "dev" "out" "doc" ]; # it's dev-doc only
   outputBin = "dev"; # fftw-wisdom
 
   configureFlags =
-    [ "--enable-shared" "--disable-static"
+    [ "--enable-maintainer-mode"
+      "--enable-shared" "--disable-static"
       "--enable-threads"
     ]
     ++ optional (precision != "double") "--enable-${precision}"
diff --git a/pkgs/development/libraries/libdrm/default.nix b/pkgs/development/libraries/libdrm/default.nix
index 13a7cfe0fb9f..d2bb05a3bb64 100644
--- a/pkgs/development/libraries/libdrm/default.nix
+++ b/pkgs/development/libraries/libdrm/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, pkgconfig, libpthreadstubs, libpciaccess, udev, valgrind }:
 
 stdenv.mkDerivation rec {
-  name = "libdrm-2.4.70";
+  name = "libdrm-2.4.68";
 
   src = fetchurl {
     url = "http://dri.freedesktop.org/libdrm/${name}.tar.bz2";
-    sha256 = "b17d4b39ed97ca0e4cffa0db06ff609e617bac94646ec38e8e0579d530540e7b";
+    sha256 = "5b4bd9a5922929bc716411cb74061fbf31b06ba36feb89bc1358a91a8d0ca9df";
   };
 
   outputs = [ "dev" "out" ];
diff --git a/pkgs/development/libraries/mesa/default.nix b/pkgs/development/libraries/mesa/default.nix
index 8f037d239d04..4ed47f46a321 100644
--- a/pkgs/development/libraries/mesa/default.nix
+++ b/pkgs/development/libraries/mesa/default.nix
@@ -1,12 +1,13 @@
-{ stdenv, fetchurl, fetchpatch
-, pkgconfig, intltool, autoreconfHook, substituteAll
-, file, expat, libdrm, xorg, wayland, libudev
-, llvmPackages, libffi, libomxil-bellagio, libva
-, libelf, libvdpau, python
-, grsecEnabled ? false
+{ stdenv, fetchurl, fetchpatch, pkgconfig, intltool, autoreconfHook, substituteAll
+, file, expat, libdrm, xorg, wayland, libudev, llvmPackages, libffi, libomxil-bellagio
+, libvdpau, libelf, libva
+, grsecEnabled
 , enableTextureFloats ? false # Texture floats are patented, see docs/patents.txt
 }:
 
+if ! stdenv.lib.lists.elem stdenv.system stdenv.lib.platforms.mesaPlatforms then
+  throw "unsupported platform for Mesa"
+else
 
 /** Packaging design:
   - The basic mesa ($out) contains headers and libraries (GLU is in mesa_glu now).
@@ -19,15 +20,11 @@
   - libOSMesa is in $osmesa (~4 MB)
 */
 
-with stdenv.lib;
-
-if ! lists.elem stdenv.system platforms.mesaPlatforms then
-  throw "unsupported platform for Mesa"
-else
+with { inherit (stdenv.lib) optional optionalString; };
 
 let
-  version = "12.0.1";
-  branch  = head (splitString "." version);
+  version = "11.2.2";
+  # this is the default search path for DRI drivers
   driverLink = "/run/opengl-driver" + optionalString stdenv.isi686 "-32";
 in
 
@@ -37,20 +34,20 @@ stdenv.mkDerivation {
   src =  fetchurl {
     urls = [
       "ftp://ftp.freedesktop.org/pub/mesa/${version}/mesa-${version}.tar.xz"
-      "ftp://ftp.freedesktop.org/pub/mesa/older-versions/${branch}.x/${version}/mesa-${version}.tar.xz"
+      (with stdenv.lib; ''ftp://ftp.freedesktop.org/pub/mesa/older-versions/''
+        + head (splitString "." version) + ''.x/${version}/mesa-${version}.tar.xz'')
       "https://launchpad.net/mesa/trunk/${version}/+download/mesa-${version}.tar.xz"
     ];
-    sha256 = "12b3i59xdn2in2hchrkgh4fwij8zhznibx976l3pdj3qkyvlzcms";
+    sha256 = "40e148812388ec7c6d7b6657d5a16e2e8dabba8b97ddfceea5197947647bdfb4";
   };
 
   prePatch = "patchShebangs .";
 
-  # TODO:
-  #  revive ./dricore-gallium.patch when it gets ported (from Ubuntu), as it saved
-  #  ~35 MB in $drivers; watch https://launchpad.net/ubuntu/+source/mesa/+changelog
   patches = [
     ./glx_ro_text_segm.patch # fix for grsecurity/PaX
     ./symlink-drivers.patch
+   # TODO: revive ./dricore-gallium.patch when it gets ported (from Ubuntu),
+   #  as it saved ~35 MB in $drivers; watch https://launchpad.net/ubuntu/+source/mesa/+changelog
   ] ++ optional stdenv.isLinux
       (substituteAll {
         src = ./dlopen-absolute-paths.diff;
@@ -64,59 +61,61 @@ stdenv.mkDerivation {
 
   outputs = [ "dev" "out" "drivers" "osmesa" ];
 
-  # TODO: Figure out how to enable opencl without having a runtime dependency on clang
   configureFlags = [
     "--sysconfdir=/etc"
     "--localstatedir=/var"
     "--with-dri-driverdir=$(drivers)/lib/dri"
     "--with-dri-searchpath=${driverLink}/lib/dri"
-    "--with-egl-platforms=x11,wayland,drm"
-    (optionalString (stdenv.system != "armv7l-linux")
-      "--with-gallium-drivers=svga,i915,ilo,r300,r600,radeonsi,nouveau,freedreno,swrast")
-    (optionalString (stdenv.system != "armv7l-linux")
-      "--with-dri-drivers=i915,i965,nouveau,radeon,r200,swrast")
-
-    (enableFeature enableTextureFloats "texture-float")
-    (enableFeature grsecEnabled "glx-rts")
-    (enableFeature stdenv.isLinux "dri3")
-    (enableFeature stdenv.isLinux "nine") # Direct3D in Wine
-    "--enable-dri"
-    "--enable-driglx-direct"
+
     "--enable-gles1"
     "--enable-gles2"
+    "--enable-dri"
+  ] ++ optional stdenv.isLinux "--enable-dri3"
+    ++ [
     "--enable-glx"
-    "--enable-glx-tls"
     "--enable-gallium-osmesa" # used by wine
-    "--enable-gallium-llvm"
     "--enable-egl"
     "--enable-xa" # used in vmware driver
     "--enable-gbm"
+  ] ++ optional stdenv.isLinux "--enable-nine" # Direct3D in Wine
+    ++ [
     "--enable-xvmc"
     "--enable-vdpau"
+    #"--enable-omx"
+    #"--enable-va"
+
+    # TODO: Figure out how to enable opencl without having a runtime dependency on clang
+    "--disable-opencl"
+
+    (if "armv7l-linux" == stdenv.system
+      then null
+      else "--with-gallium-drivers=svga,i915,ilo,r300,r600,radeonsi,nouveau,freedreno,swrast")
     "--enable-shared-glapi"
     "--enable-sysfs"
+    "--enable-driglx-direct" # seems enabled anyway
+    "--enable-glx-tls"
+    (if "armv7l-linux" == stdenv.system
+      then "--with-dri-drivers="
+      else "--with-dri-drivers=i915,i965,nouveau,radeon,r200,swrast")
+    "--with-egl-platforms=x11,wayland,drm"
+
+    "--enable-gallium-llvm"
     "--enable-llvm-shared-libs"
-    "--enable-omx"
-    "--enable-va"
-    "--disable-opencl"
-  ];
+  ] ++ optional enableTextureFloats "--enable-texture-float"
+    ++ optional grsecEnabled "--enable-glx-rts"; # slight performance degradation, enable only for grsec
 
   nativeBuildInputs = [ pkgconfig file ];
 
-  propagatedBuildInputs = with xorg;
-    [ libXdamage libXxf86vm ]
+  propagatedBuildInputs = with xorg; [ libXdamage libXxf86vm ]
     ++ optional stdenv.isLinux libdrm;
 
   buildInputs = with xorg; [
     autoreconfHook intltool expat llvmPackages.llvm
     glproto dri2proto dri3proto presentproto
     libX11 libXext libxcb libXt libXfixes libxshmfence
-    libffi wayland libvdpau libelf libXvMC
-    libomxil-bellagio libva libpthreadstubs
-    (python.withPackages (ps: [ ps.Mako ]))
+    libffi wayland libvdpau libelf libXvMC /* libomxil-bellagio libva */
   ] ++ optional stdenv.isLinux libudev;
 
-
   enableParallelBuilding = true;
   doCheck = false;
 
@@ -125,42 +124,42 @@ stdenv.mkDerivation {
     "localstatedir=\${TMPDIR}"
   ];
 
-  # TODO: probably not all .la files are completely fixed, but it shouldn't matter;
-  postInstall = ''
-    # move gallium-related stuff to $drivers, so $out doesn't depend on LLVM
-    mv -t "$drivers/lib/"    \
-      $out/lib/libXvMC*      \
-      $out/lib/d3d           \
-      $out/lib/vdpau         \
-      $out/lib/bellagio      \
-      $out/lib/libxatracker* \
-
-    mv $out/lib/dri/* $drivers/lib/dri
+  # move gallium-related stuff to $drivers, so $out doesn't depend on LLVM;
+  #   also move libOSMesa to $osmesa, as it's relatively big
+  # ToDo: probably not all .la files are completely fixed, but it shouldn't matter
+  postInstall = with stdenv.lib; ''
+    mv -t "$drivers/lib/" \
+      $out/lib/libXvMC* \
+      $out/lib/d3d \
+      $out/lib/vdpau \
+      $out/lib/libxatracker*
 
-    # move libOSMesa to $osmesa, as it's relatively big
     mkdir -p {$osmesa,$drivers}/lib/
-    mv -t $osmesa/lib/ $out/lib/libOSMesa*
+    mv -t $osmesa/lib/ \
+      $out/lib/libOSMesa*
 
-    # now fix references in .la files
-    sed "/^libdir=/s,$out,$osmesa," -i $osmesa/lib/libOSMesa*.la
+  '' + /* now fix references in .la files */ ''
+    sed "/^libdir=/s,$out,$osmesa," -i \
+      $osmesa/lib/libOSMesa*.la
 
-    # set the default search path for DRI drivers; used e.g. by X server
+  '' + /* set the default search path for DRI drivers; used e.g. by X server */ ''
     substituteInPlace "$dev/lib/pkgconfig/dri.pc" --replace '$(drivers)' "${driverLink}"
   '';
+  #ToDo: @vcunat isn't sure if drirc will be found when in $out/etc/, but it doesn't seem important ATM */
 
-  # TODO:
-  #  @vcunat isn't sure if drirc will be found when in $out/etc/;
-  #  check $out doesn't depend on llvm: builder failures are ignored
-  #  for some reason grep -qv '${llvmPackages.llvm}' -R "$out";
-  postFixup = ''
+  postFixup =
     # add RPATH so the drivers can find the moved libgallium and libdricore9
     # moved here to avoid problems with stripping patchelfed files
+  ''
     for lib in $drivers/lib/*.so* $drivers/lib/*/*.so*; do
       if [[ ! -L "$lib" ]]; then
         patchelf --set-rpath "$(patchelf --print-rpath $lib):$drivers/lib" "$lib"
       fi
     done
   '';
+  # ToDo + /* check $out doesn't depend on llvm */ ''
+  # builder failures are ignored for some reason
+  #   grep -qv '${llvmPackages.llvm}' -R "$out"
 
   passthru = { inherit libdrm version driverLink; };
 
diff --git a/pkgs/development/python-modules/generic/run_setup.py b/pkgs/development/python-modules/generic/run_setup.py
index e3a530eb0cb6..d980ac7d23d4 100644
--- a/pkgs/development/python-modules/generic/run_setup.py
+++ b/pkgs/development/python-modules/generic/run_setup.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
 import setuptools
 import tokenize
 
diff --git a/pkgs/development/tools/misc/lttng-tools/default.nix b/pkgs/development/tools/misc/lttng-tools/default.nix
index 827c1d0e67f8..627a51916cb8 100644
--- a/pkgs/development/tools/misc/lttng-tools/default.nix
+++ b/pkgs/development/tools/misc/lttng-tools/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ popt libuuid liburcu lttng-ust libxml2 ];
 
   prePatch = ''
-    sed -e "s|/sbin/modprobe|${kmod}/bin/modprobe|g" \
+    sed -e "s|/sbin/modprobe|${kmod}/sbin/modprobe|g" \
         -i src/bin/lttng-sessiond/modprobe.c
   '';
 
diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libc/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Libc/default.nix
index ce04be0e0836..16cfa9e554b6 100644
--- a/pkgs/os-specific/darwin/apple-source-releases/Libc/default.nix
+++ b/pkgs/os-specific/darwin/apple-source-releases/Libc/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, appleDerivation, ed, unifdef, Libc_old, Libc_10-9 }:
+{ stdenv, appleDerivation, ed, unifdef, Libc_old }:
 
 appleDerivation {
   phases = [ "unpackPhase" "installPhase" ];
@@ -13,8 +13,6 @@ appleDerivation {
     export PRIVATE_HEADERS_FOLDER_PATH=include
     bash xcodescripts/headers.sh
 
-    cp ${Libc_10-9}/include/NSSystemDirectories.h $out/include
-
     # Ugh Apple stopped releasing this stuff so we need an older one...
     cp    ${Libc_old}/include/spawn.h    $out/include
     cp    ${Libc_old}/include/setjmp.h   $out/include
diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix
index 27d2360a9800..1c9b5879e6ec 100644
--- a/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix
+++ b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix
@@ -5,7 +5,42 @@
 appleDerivation rec {
   phases = [ "unpackPhase" "installPhase" ];
 
-  buildInputs = [ cpio ];
+  buildInputs = [ cpio libpthread ];
+
+  systemlibs = [ "cache"
+                 "commonCrypto"
+                 "compiler_rt"
+                 "copyfile"
+                 "corecrypto"
+                 "dispatch"
+                 "dyld"
+                 "keymgr"
+                 "kxld"
+                 "launch"
+                 "macho"
+                 "quarantine"
+                 "removefile"
+                 "system_asl"
+                 "system_blocks"
+                 # "system_c" # special re-export here to hide newer functions
+                 "system_configuration"
+                 "system_dnssd"
+                 "system_info"
+                 # "system_kernel" # special re-export here to hide newer functions
+                 "system_m"
+                 "system_malloc"
+                 "system_network"
+                 "system_notify"
+                 "system_platform"
+                 "system_pthread"
+                 "system_sandbox"
+                 # does not exist in El Capitan beta
+                 # FIXME: does anything on yosemite actually need this?
+                 # "system_stats"
+                 "unc"
+                 "unwind"
+                 "xpc"
+               ];
 
   installPhase = ''
     export NIX_ENFORCE_PURITY=
@@ -19,7 +54,7 @@ appleDerivation rec {
 
     for dep in ${Libc} ${Libm} ${Libinfo} ${dyld} ${architecture} ${libclosure} ${CarbonHeaders} \
                ${libdispatch} ${ncurses.dev} ${CommonCrypto} ${copyfile} ${removefile} ${libresolv} \
-               ${Libnotify} ${mDNSResponder} ${launchd} ${libutil} ${libpthread}; do
+               ${Libnotify} ${mDNSResponder} ${launchd} ${libutil}; do
       (cd $dep/include && find . -name '*.h' | cpio -pdm $out/include)
     done
 
@@ -56,9 +91,33 @@ appleDerivation rec {
     # The startup object files
     cp ${Csu}/lib/* $out/lib
 
-    # OMG impurity
-    ln -s /usr/lib/libSystem.B.dylib $out/lib/libSystem.B.dylib
-    ln -s /usr/lib/libSystem.dylib $out/lib/libSystem.dylib
+    # selectively re-export functions from libsystem_c and libsystem_kernel
+    # to provide a consistent interface across OSX verions
+    mkdir -p $out/lib/system
+    ld -macosx_version_min 10.7 -arch x86_64 -dylib \
+       -o $out/lib/system/libsystem_c.dylib \
+       /usr/lib/libSystem.dylib \
+       -reexported_symbols_list ${./system_c_symbols}
+
+    ld -macosx_version_min 10.7 -arch x86_64 -dylib \
+       -o $out/lib/system/libsystem_kernel.dylib \
+       /usr/lib/libSystem.dylib \
+       -reexported_symbols_list ${./system_kernel_symbols}
+
+    # Set up the actual library link
+    clang -c -o CompatibilityHacks.o -Os CompatibilityHacks.c
+    clang -c -o init.o -Os init.c
+    ld -macosx_version_min 10.7 \
+       -arch x86_64 \
+       -dylib \
+       -o $out/lib/libSystem.dylib \
+       CompatibilityHacks.o init.o \
+       -compatibility_version 1.0 \
+       -current_version 1197.1.1 \
+       -reexport_library $out/lib/system/libsystem_c.dylib \
+       -reexport_library $out/lib/system/libsystem_kernel.dylib \
+        ${stdenv.lib.concatStringsSep " "
+          (map (l: "-reexport_library /usr/lib/system/lib${l}.dylib") systemlibs)}
 
     # Set up links to pretend we work like a conventional unix (Apple's design, not mine!)
     for name in c dbm dl info m mx poll proc pthread rpcsvc util gcc_s.10.4 gcc_s.10.5; do
diff --git a/pkgs/os-specific/darwin/apple-source-releases/configd/default.nix b/pkgs/os-specific/darwin/apple-source-releases/configd/default.nix
index 24797fc286a7..1fbacfb92845 100644
--- a/pkgs/os-specific/darwin/apple-source-releases/configd/default.nix
+++ b/pkgs/os-specific/darwin/apple-source-releases/configd/default.nix
@@ -3,7 +3,7 @@
 appleDerivation {
   meta.broken = stdenv.cc.nativeLibc;
 
-  buildInputs = [ launchd bootstrap_cmds ppp IOKit eap8021x ];
+  buildInputs = [ launchd bootstrap_cmds xnu ppp IOKit eap8021x ];
 
   propagatedBuildInputs = [ Security ];
 
@@ -12,11 +12,6 @@ appleDerivation {
   '';
 
   patchPhase = ''
-    HACK=$PWD/hack
-    mkdir $HACK
-    cp -r ${xnu}/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/net $HACK
-
-
     substituteInPlace SystemConfiguration.fproj/SCNetworkReachabilityInternal.h \
       --replace '#include <xpc/xpc.h>' ""
 
@@ -177,9 +172,9 @@ appleDerivation {
     cc -I. -Ihelper -Iderived -F. -c DHCP.c -o DHCP.o
     cc -I. -Ihelper -Iderived -F. -c moh.c -o moh.o
     cc -I. -Ihelper -Iderived -F. -c DeviceOnHold.c -o DeviceOnHold.o
-    cc -I. -Ihelper -Iderived -I $HACK -F. -c LinkConfiguration.c -o LinkConfiguration.o
+    cc -I. -Ihelper -Iderived -I${xnu}/Library/Frameworks/System.framework/Versions/B/PrivateHeaders -F. -c LinkConfiguration.c -o LinkConfiguration.o
     cc -I. -Ihelper -Iderived -F. -c dy_framework.c -o dy_framework.o
-    cc -I. -Ihelper -Iderived -I $HACK -F. -c VLANConfiguration.c -o VLANConfiguration.o
+    cc -I. -Ihelper -Iderived -I${xnu}/Library/Frameworks/System.framework/Versions/B/PrivateHeaders -F. -c VLANConfiguration.c -o VLANConfiguration.o
     cc -I. -Ihelper -Iderived -F. -c derived/configUser.c -o configUser.o
     cc -I. -Ihelper -Iderived -F. -c SCPreferencesPathKey.c -o SCPreferencesPathKey.o
     cc -I. -Ihelper -Iderived -I../dnsinfo -F. -c derived/shared_dns_infoUser.c -o shared_dns_infoUser.o
@@ -188,8 +183,8 @@ appleDerivation {
     cc -I. -Ihelper -Iderived -F. -c SCNetworkProtocol.c -o SCNetworkProtocol.o
     cc -I. -Ihelper -Iderived -F. -c SCNetworkService.c -o SCNetworkService.o
     cc -I. -Ihelper -Iderived -F. -c SCNetworkSet.c -o SCNetworkSet.o
-    cc -I. -Ihelper -Iderived -I $HACK -F. -c BondConfiguration.c -o BondConfiguration.o
-    cc -I. -Ihelper -Iderived -I $HACK -F. -c BridgeConfiguration.c -o BridgeConfiguration.o
+    cc -I. -Ihelper -Iderived -I${xnu}/Library/Frameworks/System.framework/Versions/B/PrivateHeaders -F. -c BondConfiguration.c -o BondConfiguration.o
+    cc -I. -Ihelper -Iderived -I${xnu}/Library/Frameworks/System.framework/Versions/B/PrivateHeaders -F. -c BridgeConfiguration.c -o BridgeConfiguration.o
     cc -I. -Ihelper -Iderived -F. -c helper/SCHelper_client.c -o SCHelper_client.o
     cc -I. -Ihelper -Iderived -F. -c SCPreferencesKeychainPrivate.c -o SCPreferencesKeychainPrivate.o
     cc -I. -Ihelper -Iderived -F. -c SCNetworkSignature.c -o SCNetworkSignature.o
diff --git a/pkgs/os-specific/darwin/apple-source-releases/default.nix b/pkgs/os-specific/darwin/apple-source-releases/default.nix
index d7710abf291b..ce128f14530b 100644
--- a/pkgs/os-specific/darwin/apple-source-releases/default.nix
+++ b/pkgs/os-specific/darwin/apple-source-releases/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchzip, pkgs }:
+{ stdenv, fetchurl, pkgs }:
 
 let
   # This attrset can in theory be computed automatically, but for that to work nicely we need
@@ -6,13 +6,9 @@ let
   # a stdenv out of something like this. With some care we can probably get rid of this, but for
   # now it's staying here.
   versions = {
-    "osx-10.11.6" = {
-      dtrace        = "168";
-      xnu           = "3248.60.10";
-      libpthread    = "138.10.4";
-    };
-    "osx-10.11.5" = {
-      Libc          = "1082.50.1"; # 10.11.6 still unreleased :/
+    "osx-10.11.2" = {
+      dtrace = "168";
+      xnu    = "3248.20.55";
     };
     "osx-10.10.5" = {
       adv_cmds      = "158";
@@ -189,18 +185,13 @@ let
     CoreOSMakefiles = applePackage "CoreOSMakefiles"   "osx-10.5"        "0kxp53spbn7109l7cvhi88pmfsi81lwmbws819b6wr3hm16v84f4" {};
     Csu             = applePackage "Csu"               "osx-10.10.5"     "0yh5mslyx28xzpv8qww14infkylvc1ssi57imhi471fs91sisagj" {};
     dtrace          = applePackage "dtrace"            "osx-10.10.5"     "0pp5x8dgvzmg9vvg32hpy2brm17dpmbwrcr4prsmdmfvd4767wcf" {};
-    dtracen         = applePackage "dtrace"            "osx-10.11.6"     "04mi0jy8gy0w59rk9i9dqznysv6fzz1v5mq779s41cp308yi0h1c" {};
+    dtracen         = applePackage "dtrace"            "osx-10.11.2"     "04mi0jy8gy0w59rk9i9dqznysv6fzz1v5mq779s41cp308yi0h1c" {};
     dyld            = applePackage "dyld"              "osx-10.10.5"     "167f74ln8pmfimwn6kwh199ylvy3fw72fd15da94mf34ii0zar6k" {};
     eap8021x        = applePackage "eap8021x"          "osx-10.10.5"     "1f37dpbcgrd1b14nrv2lpqrkap74myjbparz9masx92df6kcn7l2" {};
     IOKit           = applePackage "IOKit"             "osx-10.10.5"     "0kcbrlyxcyirvg5p95hjd9k8a01k161zg0bsfgfhkb90kh2s8x0m" { inherit IOKitSrcs; };
     launchd         = applePackage "launchd"           "osx-10.9.5"      "0w30hvwqq8j5n90s3qyp0fccxflvrmmjnicjri4i1vd2g196jdgj" {};
     libauto         = applePackage "libauto"           "osx-10.9.5"      "17z27yq5d7zfkwr49r7f0vn9pxvj95884sd2k6lq6rfaz9gxqhy3" {};
-    Libc            = applePackage "Libc"              "osx-10.11.5"     "1qv7r0dgz06jy9i5agbqzxgdibb0m8ylki6g5n5pary88lzrawfd" {
-      Libc_10-9 = fetchzip {
-        url    = "http://www.opensource.apple.com/tarballs/Libc/Libc-997.90.3.tar.gz";
-        sha256 = "1xchgxkxg5288r2b9yfrqji2gsgdap92k4wx2dbjwslixws12pq7";
-      };
-    };
+    Libc            = applePackage "Libc"              "osx-10.9.5"      "1jz5bx9l4q484vn28c6n9b28psja3rpxiqbj6zwrwvlndzmq1yz5" {};
     Libc_old        = applePackage "Libc/825_40_1.nix" "osx-10.8.5"      "0xsx1im52gwlmcrv4lnhhhn9dyk5ci6g27k6yvibn9vj8fzjxwcf" {};
     libclosure      = applePackage "libclosure"        "osx-10.10.5"     "1zqy1zvra46cmqv6vsf1mcsz3a76r9bky145phfwh4ab6y15vjpq" {};
     libdispatch     = applePackage "libdispatch"       "osx-10.9.5"      "1lc5033cmkwxy3r26gh9plimxshxfcbgw6i0j7mgjlnpk86iy5bk" {};
@@ -208,7 +199,7 @@ let
     Libinfo         = applePackage "Libinfo"           "osx-10.10.5"     "19n72s652rrqnc9hzlh4xq3h7xsfyjyklmcgyzyj0v0z68ww3z6h" {};
     Libm            = applePackage "Libm"              "osx-10.7.4"      "02sd82ig2jvvyyfschmb4gpz6psnizri8sh6i982v341x6y4ysl7" {};
     Libnotify       = applePackage "Libnotify"         "osx-10.9.5"      "164rx4za5z74s0mk9x0m1815r1m9kfal8dz3bfaw7figyjd6nqad" {};
-    libpthread      = applePackage "libpthread"        "osx-10.11.6"     "1kbw738cmr9pa7pz1igmajs307clfq7gv2vm1sqdzhcnnjxbl28w" {};
+    libpthread      = applePackage "libpthread"        "osx-10.10.5"     "1p2y6xvsfqyakivr6d48fgrd163b5m9r045cxyfwrf8w0r33nfn3" {};
     libresolv       = applePackage "libresolv"         "osx-10.10.5"     "0nvssf4qaqgs1dxwayzdy66757k99969f6c7n68n58n2yh6f5f6a" {};
     Libsystem       = applePackage "Libsystem"         "osx-10.9.5"      "1yfj2qdrf9vrzs7p9m4wlb7zzxcrim1gw43x4lvz4qydpp5kg2rh" {};
     libutil         = applePackage "libutil"           "osx-10.10.5"     "12gsvmj342n5d81kqwba68bmz3zf2757442g1sz2y5xmcapa3g5f" {};
@@ -218,7 +209,7 @@ let
     ppp             = applePackage "ppp"               "osx-10.10.5"     "01v7i0xds185glv8psvlffylfcfhbx1wgsfg74kx5rh3lyrigwrb" {};
     removefile      = applePackage "removefile"        "osx-10.10.5"     "1f2jw5irq6fz2jv5pag1w2ivfp8659v74f0h8kh0yx0rqw4asm33" {};
     Security        = applePackage "Security"          "osx-10.9.5"      "1nv0dczf67dhk17hscx52izgdcyacgyy12ag0jh6nl5hmfzsn8yy" {};
-    xnu             = applePackage "xnu"               "osx-10.11.6"     "0yhziq4dqqcbjpf6vyqn8xhwva2zb525gndkx8cp8alzwp76jnr9" {};
+    xnu             = applePackage "xnu"               "osx-10.9.5"      "1ssw5fzvgix20bw6y13c39ib0zs7ykpig3irlwbaccpjpci5jl0s" {};
 
     # Pending work... we can't change the above packages in place because the bootstrap depends on them, so we detach the expressions
     # here so we can work on them.
diff --git a/pkgs/os-specific/darwin/apple-source-releases/libpthread/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libpthread/default.nix
index c9d4b654a589..027784e2ea6d 100644
--- a/pkgs/os-specific/darwin/apple-source-releases/libpthread/default.nix
+++ b/pkgs/os-specific/darwin/apple-source-releases/libpthread/default.nix
@@ -6,14 +6,8 @@ appleDerivation {
   propagatedBuildInputs = [ libdispatch xnu ];
 
   installPhase = ''
-    mkdir -p $out/include/pthread/
-    mkdir -p $out/include/sys/_types
+    mkdir -p $out/include/pthread
     cp pthread/*.h $out/include/pthread/
-
-    # This overwrites qos.h, and is probably not necessary, but I'll leave it here for now
-    # cp private/*.h $out/include/pthread/
-
-    cp -r sys $out/include
-    cp -r sys/_pthread/*.h $out/include/sys/_types/
+    cp private/*.h $out/include/pthread/
   '';
 }
diff --git a/pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix b/pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix
index 0ce9c54e48c4..4933f94d4a93 100644
--- a/pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix
+++ b/pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix
@@ -30,12 +30,11 @@ appleDerivation {
     substituteInPlace libsyscall/xcodescripts/mach_install_mig.sh \
       --replace "/usr/include" "/include" \
       --replace "/usr/local/include" "/include" \
-      --replace 'MIG=`' "# " \
-      --replace 'MIGCC=`' "# " \
+      --replace "MIG=" "# " \
+      --replace "MIGCC=" "# " \
       --replace " -o 0" "" \
       --replace '$SRC/$mig' '-I$DSTROOT/include $SRC/$mig' \
-      --replace '$SRC/servers/netname.defs' '-I$DSTROOT/include $SRC/servers/netname.defs' \
-      --replace '$BUILT_PRODUCTS_DIR/mig_hdr' '$BUILT_PRODUCTS_DIR'
+      --replace '$SRC/servers/netname.defs' '-I$DSTROOT/include $SRC/servers/netname.defs'
 
     patchShebangs .
   '';
@@ -47,9 +46,9 @@ appleDerivation {
     cat > sdk/usr/local/libexec/availability.pl <<EOF
       #!$SHELL
       if [ "\$1" == "--macosx" ]; then
-        echo 10.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 10.10 10.11
+        echo 10.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9
       elif [ "\$1" == "--ios" ]; then
-        echo 2.0 2.1 2.2 3.0 3.1 3.2 4.0 4.1 4.2 4.3 5.0 5.1 6.0 6.1 7.0 8.0 9.0
+        echo 2.0 2.1 2.2 3.0 3.1 3.2 4.0 4.1 4.2 4.3 5.0 5.1 6.0 6.1 7.0
       fi
     EOF
     chmod +x sdk/usr/local/libexec/availability.pl
@@ -57,7 +56,7 @@ appleDerivation {
     export SDKROOT_RESOLVED=$PWD/sdk
     export HOST_SDKROOT_RESOLVED=$PWD/sdk
     export PLATFORM=MacOSX
-    export SDKVERSION=10.11
+    export SDKVERSION=10.7
 
     export CC=cc
     export CXX=c++
@@ -88,13 +87,13 @@ appleDerivation {
     make installhdrs
 
     mv $out/usr/include $out
+    rmdir $out/usr
 
     # TODO: figure out why I need to do this
     cp libsyscall/wrappers/*.h $out/include
     mkdir -p $out/include/os
     cp libsyscall/os/tsd.h $out/include/os/tsd.h
     cp EXTERNAL_HEADERS/AssertMacros.h $out/include
-    cp EXTERNAL_HEADERS/Availability*.h $out/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/
 
     # Build the mach headers we crave
     export MIGCC=cc
@@ -102,21 +101,11 @@ appleDerivation {
     export SRCROOT=$PWD/libsyscall
     export DERIVED_SOURCES_DIR=$out/include
     export SDKROOT=$out
-    export OBJROOT=$PWD
-    export BUILT_PRODUCTS_DIR=$out
     libsyscall/xcodescripts/mach_install_mig.sh
 
     # Get rid of the System prefix
     mv $out/System/* $out/
 
-    # TODO: do I need this?
-    mv $out/internal_hdr/include/mach/*.h $out/include/mach
-
-    # Get rid of some junk lying around
-    rm -rf $out/internal_hdr
-    rm -rf $out/usr
-    rm -rf $out/local
-
     # Add some symlinks
     ln -s $out/Library/Frameworks/System.framework/Versions/B \
           $out/Library/Frameworks/System.framework/Versions/Current
diff --git a/pkgs/os-specific/darwin/swift-corefoundation/default.nix b/pkgs/os-specific/darwin/swift-corefoundation/default.nix
deleted file mode 100644
index 969168fa54ba..000000000000
--- a/pkgs/os-specific/darwin/swift-corefoundation/default.nix
+++ /dev/null
@@ -1,32 +0,0 @@
-{ stdenv, fetchFromGitHub, python, ninja, libxml2 }:
-
-stdenv.mkDerivation {
-  name = "swift-corefoundation";
-
-  src = fetchFromGitHub {
-    owner  = "apple";
-    repo   = "swift-corelibs-foundation";
-    rev    = "dce4233f583ec15190b240d6116396bf9641cd57";
-    sha256 = "0i2ldvy14x05k2vgl5z0g5l2i5llifdfbij5zwfdwb8jmmq215qr";
-  };
-
-  buildInputs = [ ninja python libxml2 ];
-
-  patchPhase = ''
-    substituteInPlace CoreFoundation/build.py \
-      --replace '-I''${SYSROOT}/usr/include/libxml2' '-I${libxml2.dev}/include/libxml2' \
-  '';
-
-  configurePhase = ":";
-
-  buildPhase = ''
-    cd CoreFoundation
-    ../configure --sysroot unused
-    ninja
-  '';
-
-  installPhase = ''
-    mkdir -p $out/lib
-    cp ../Build/CoreFoundation/libCoreFoundation.a $out/lib
-  '';
-}
diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix
index c5a4ba2b18ad..8da8f20eae27 100644
--- a/pkgs/os-specific/linux/kernel/manual-config.nix
+++ b/pkgs/os-specific/linux/kernel/manual-config.nix
@@ -93,7 +93,7 @@ let
             echo "stripping FHS paths in \`$mf'..."
             sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g ; s|/sbin/||g'
         done
-        sed -i Makefile -e 's|= depmod|= ${kmod}/bin/depmod|'
+        sed -i Makefile -e 's|= depmod|= ${kmod}/sbin/depmod|'
       '';
 
       configurePhase = ''
@@ -188,7 +188,7 @@ let
         find -empty -type d -delete
 
         # Remove reference to kmod
-        sed -i Makefile -e 's|= ${kmod}/bin/depmod|= depmod|'
+        sed -i Makefile -e 's|= ${kmod}/sbin/depmod|= depmod|'
       '' else optionalString installsFirmware ''
         make firmware_install $makeFlags "''${makeFlagsArray[@]}" \
           $installFlags "''${installFlagsArray[@]}"
diff --git a/pkgs/os-specific/linux/kmod/aggregator.nix b/pkgs/os-specific/linux/kmod/aggregator.nix
index 88069ba4bf13..161af38ff608 100644
--- a/pkgs/os-specific/linux/kmod/aggregator.nix
+++ b/pkgs/os-specific/linux/kmod/aggregator.nix
@@ -21,7 +21,7 @@ buildEnv {
       # kernel version number, otherwise depmod will use `uname -r'.
       if test -w $out/lib/modules/$kernelVersion; then
           rm -f $out/lib/modules/$kernelVersion/modules.*
-          ${kmod}/bin/depmod -b $out -a $kernelVersion
+          ${kmod}/sbin/depmod -b $out -a $kernelVersion
       fi
     '';
 }
diff --git a/pkgs/os-specific/linux/kmod/default.nix b/pkgs/os-specific/linux/kmod/default.nix
index 58b0b9883512..12449a0a7dda 100644
--- a/pkgs/os-specific/linux/kmod/default.nix
+++ b/pkgs/os-specific/linux/kmod/default.nix
@@ -1,37 +1,25 @@
-{ stdenv, lib, fetchurl, autoreconfHook, xz, zlib, pkgconfig, libxslt }:
+{ stdenv, fetchurl, xz, zlib, pkgconfig, libxslt }:
 
-let
-  systems = [ "current-system" "booted-system" ];
-  modulesDirs = lib.concatMapStringsSep ":" (x: "/run/${x}/kernel-modules/lib/modules") systems;
-
-in stdenv.mkDerivation rec {
-  name = "kmod-${version}";
-  version = "22";
+stdenv.mkDerivation rec {
+  name = "kmod-22";
 
   src = fetchurl {
     url = "mirror://kernel/linux/utils/kernel/kmod/${name}.tar.xz";
     sha256 = "10lzfkmnpq6a43a3gkx7x633njh216w0bjwz31rv8a1jlgg1sfxs";
   };
 
-  nativeBuildInputs = [ autoreconfHook pkgconfig libxslt ];
-  buildInputs = [ xz /* zlib */ ];
+  buildInputs = [ pkgconfig libxslt xz /* zlib */ ];
 
-  configureFlags = [
-    "--sysconfdir=/etc"
-    "--with-xz"
-    "--with-modulesdirs=${modulesDirs}"
-    # "--with-zlib"
-  ];
+  configureFlags = [ "--sysconfdir=/etc" "--with-xz" /* "--with-zlib" */ ];
 
   patches = [ ./module-dir.patch ];
 
   postInstall = ''
-    for prog in rmmod insmod lsmod modinfo modprobe depmod; do
-      ln -sv $out/bin/kmod $out/bin/$prog
+    ln -s kmod $out/bin/lsmod
+    mkdir -p $out/sbin
+    for prog in rmmod insmod modinfo modprobe depmod; do
+      ln -sv $out/bin/kmod $out/sbin/$prog
     done
-
-    # Backwards compatibility
-    ln -s bin $out/sbin
   '';
 
   meta = {
diff --git a/pkgs/os-specific/linux/kmod/module-dir.patch b/pkgs/os-specific/linux/kmod/module-dir.patch
index f7432e3756e9..0c4ab4bd4c44 100644
--- a/pkgs/os-specific/linux/kmod/module-dir.patch
+++ b/pkgs/os-specific/linux/kmod/module-dir.patch
@@ -1,46 +1,7 @@
-diff --git a/Makefile.am b/Makefile.am
-index d4eeb7e..5c9f603 100644
---- a/Makefile.am
-+++ b/Makefile.am
-@@ -19,6 +19,7 @@ AM_CPPFLAGS = \
- 	-include $(top_builddir)/config.h \
- 	-I$(top_srcdir) \
- 	-DSYSCONFDIR=\""$(sysconfdir)"\" \
-+	-DMODULESDIRS=\""$(shell echo $(modulesdirs) | $(SED) 's|:|\\",\\"|g')"\" \
- 	${zlib_CFLAGS}
- 
- AM_CFLAGS = $(OUR_CFLAGS)
-diff --git a/configure.ac b/configure.ac
-index 23510c8..66490cf 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -202,6 +202,12 @@ GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat])
- ], [
- AM_CONDITIONAL([ENABLE_GTK_DOC], false)])
- 
-+AC_ARG_WITH([modulesdirs],
-+	AS_HELP_STRING([--with-modulesdirs=DIRS], [Kernel modules directories, separated by :]),
-+	[],
-+	[with_modulesdirs=/lib/modules])
-+AC_SUBST([modulesdirs], [$with_modulesdirs])
-+
- 
- #####################################################################
- # Default CFLAGS and LDFLAGS
-diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
-index 69fe431..d37da32 100644
---- a/libkmod/libkmod.c
-+++ b/libkmod/libkmod.c
-@@ -206,12 +206,15 @@ static int log_priority(const char *priority)
- 	return 0;
- }
- 
--static const char *dirname_default_prefix = "/lib/modules";
-+static const char *dirname_default_prefixes[] = {
-+	MODULESDIRS,
-+	NULL
-+};
- 
+diff -ru -x '*~' kmod-17-orig/libkmod/libkmod.c kmod-17/libkmod/libkmod.c
+--- kmod-17-orig/libkmod/libkmod.c	2014-04-01 12:40:37.161940089 +0200
++++ kmod-17/libkmod/libkmod.c	2014-04-17 13:47:15.871441987 +0200
+@@ -201,7 +201,7 @@
  static char *get_kernel_release(const char *dirname)
  {
  	struct utsname u;
@@ -49,109 +10,51 @@ index 69fe431..d37da32 100644
  
  	if (dirname != NULL)
  		return path_make_absolute_cwd(dirname);
-@@ -219,8 +222,42 @@ static char *get_kernel_release(const char *dirname)
+@@ -209,7 +209,10 @@
  	if (uname(&u) < 0)
  		return NULL;
  
 -	if (asprintf(&p, "%s/%s", dirname_default_prefix, u.release) < 0)
--		return NULL;
-+	if ((dirname_prefix = getenv("MODULE_DIR")) != NULL) {
-+		if(asprintf(&p, "%s/%s", dirname_prefix, u.release) < 0)
-+			return NULL;
-+	} else {
-+		size_t i;
-+		char buf[PATH_MAX];
++	if ((dirname_prefix = getenv("MODULE_DIR")) == NULL)
++		dirname_prefix = dirname_default_prefix;
 +
-+		for (i = 0; dirname_default_prefixes[i] != NULL; i++) {
-+			int plen;
-+			struct stat dirstat;
-+
-+			plen = snprintf(buf, sizeof(buf), "%s/%s", dirname_default_prefixes[i], u.release);
-+			if (plen < 0)
-+				return NULL;
-+			else if (plen >= PATH_MAX)
-+				continue;
-+
-+			if (dirname_default_prefixes[i + 1] != NULL) {
-+				if (stat(buf, &dirstat) < 0) {
-+					if (errno == ENOENT)
-+						continue;
-+					else
-+						return NULL;
-+				}
-+
-+				if (!S_ISDIR(dirstat.st_mode))
-+					continue;
-+			}
-+
-+			p = malloc(plen + 1);
-+			if (p == NULL)
-+				return NULL;
-+			memcpy(p, buf, plen + 1);
-+			break;
-+		}
-+	}
++	if (asprintf(&p, "%s/%s", dirname_prefix, u.release) < 0)
+ 		return NULL;
  
  	return p;
- }
-diff --git a/tools/static-nodes.c b/tools/static-nodes.c
-index 8d2356d..2ed306d 100644
---- a/tools/static-nodes.c
-+++ b/tools/static-nodes.c
-@@ -29,10 +29,11 @@
- #include <unistd.h>
- #include <sys/stat.h>
- #include <sys/types.h>
--#include <sys/utsname.h>
- 
- #include <shared/util.h>
- 
-+#include <libkmod/libkmod.h>
-+
- #include "kmod.h"
- 
- struct static_nodes_format {
-@@ -154,8 +155,8 @@ static void help(void)
- 
- static int do_static_nodes(int argc, char *argv[])
- {
--	struct utsname kernel;
- 	char modules[PATH_MAX], buf[4096];
-+	struct kmod_ctx *ctx;
- 	const char *output = "/dev/stdout";
+diff -ru -x '*~' kmod-17-orig/tools/static-nodes.c kmod-17/tools/static-nodes.c
+--- kmod-17-orig/tools/static-nodes.c	2013-12-17 22:05:42.159047316 +0100
++++ kmod-17/tools/static-nodes.c	2014-04-17 13:51:17.945974320 +0200
+@@ -159,6 +159,7 @@
  	FILE *in = NULL, *out = NULL;
  	const struct static_nodes_format *format = &static_nodes_format_human;
-@@ -206,22 +207,25 @@ static int do_static_nodes(int argc, char *argv[])
- 		}
- 	}
+ 	int r, ret = EXIT_SUCCESS;
++	char *dirname_prefix;
  
--	if (uname(&kernel) < 0) {
--		fputs("Error: uname failed!\n", stderr);
-+	ctx = kmod_new(NULL, NULL);
-+	if (ctx == NULL) {
-+		fprintf(stderr, "Error: failed to create kmod context\n");
- 		ret = EXIT_FAILURE;
+ 	for (;;) {
+ 		int c, idx = 0, valid;
+@@ -211,16 +212,19 @@
  		goto finish;
  	}
--
+ 
 -	snprintf(modules, sizeof(modules), "/lib/modules/%s/modules.devname", kernel.release);
-+	if (snprintf(modules, sizeof(modules), "%s/modules.devname", kmod_get_dirname(ctx)) < 0) {
-+		fprintf(stderr, "Error: path to modules.devname is too long\n");
-+		ret = EXIT_FAILURE;
-+		goto finish;
-+	}
-+	kmod_unref(ctx);
++	if ((dirname_prefix = getenv("MODULE_DIR")) == NULL)
++		dirname_prefix = "/lib/modules";
++
++	snprintf(modules, sizeof(modules), "%s/%s/modules.devname", dirname_prefix, kernel.release);
  	in = fopen(modules, "re");
  	if (in == NULL) {
  		if (errno == ENOENT) {
 -			fprintf(stderr, "Warning: /lib/modules/%s/modules.devname not found - ignoring\n",
 -				kernel.release);
-+			fprintf(stderr, "Warning: %s not found - ignoring\n", modules);
++			fprintf(stderr, "Warning: %s/%s/modules.devname not found - ignoring\n",
++				dirname_prefix, kernel.release);
  			ret = EXIT_SUCCESS;
  		} else {
 -			fprintf(stderr, "Error: could not open /lib/modules/%s/modules.devname - %m\n",
 -				kernel.release);
-+			fprintf(stderr, "Error: could not open %s - %m\n", modules);
++			fprintf(stderr, "Error: could not open %s/%s/modules.devname - %m\n",
++				dirname_prefix, kernel.release);
  			ret = EXIT_FAILURE;
  		}
  		goto finish;
diff --git a/pkgs/stdenv/darwin/make-bootstrap-tools.nix b/pkgs/stdenv/darwin/make-bootstrap-tools.nix
index 41c94bd16745..deefb6bbad2d 100644
--- a/pkgs/stdenv/darwin/make-bootstrap-tools.nix
+++ b/pkgs/stdenv/darwin/make-bootstrap-tools.nix
@@ -27,6 +27,7 @@ rec {
       # C standard library stuff
       cp -d ${darwin.Libsystem}/lib/*.o $out/lib/
       cp -d ${darwin.Libsystem}/lib/*.dylib $out/lib/
+      cp -d ${darwin.Libsystem}/lib/system/*.dylib $out/lib/
 
       # Resolv is actually a link to another package, so let's copy it properly
       rm $out/lib/libresolv.9.dylib
@@ -90,7 +91,7 @@ rec {
       cp -d ${xz.out}/lib/liblzma*.*     $out/lib
 
       # Copy binutils.
-      for i in as ld ar ranlib nm strip otool install_name_tool dsymutil lipo; do
+      for i in as ld ar ranlib nm strip otool install_name_tool dsymutil; do
         cp ${darwin.cctools}/bin/$i $out/bin
       done
 
diff --git a/pkgs/tools/networking/network-manager/0.9.8/default.nix b/pkgs/tools/networking/network-manager/0.9.8/default.nix
index 0c791631daa4..4fad1ca2ab9a 100644
--- a/pkgs/tools/networking/network-manager/0.9.8/default.nix
+++ b/pkgs/tools/networking/network-manager/0.9.8/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, intltool, pkgconfig, dbus_glib
 , udev, libnl, libuuid, gnutls, dhcp
-, libgcrypt, perl, libgudev, avahi, ppp, kmod }:
+, libgcrypt, perl, libgudev }:
 
 stdenv.mkDerivation rec {
   name = "network-manager-${version}";
@@ -13,12 +13,6 @@ stdenv.mkDerivation rec {
 
   preConfigure = ''
     substituteInPlace tools/glib-mkenums --replace /usr/bin/perl ${perl}/bin/perl
-    substituteInPlace src/nm-device.c \
-      --replace @avahi@ ${avahi} \
-      --replace @kmod@ ${kmod}
-    substituteInPlace src/ppp-manager/nm-ppp-manager.c \
-      --replace @ppp@ ${ppp} \
-      --replace @kmod@ ${kmod}
   '';
 
   # Right now we hardcode quite a few paths at build time. Probably we should
diff --git a/pkgs/tools/networking/network-manager/0.9.8/nixos-purity.patch b/pkgs/tools/networking/network-manager/0.9.8/nixos-purity.patch
index 9ebc080ba96f..831b2010fcfc 100644
--- a/pkgs/tools/networking/network-manager/0.9.8/nixos-purity.patch
+++ b/pkgs/tools/networking/network-manager/0.9.8/nixos-purity.patch
@@ -47,7 +47,7 @@ index 1dc94ee..e60f3c8 100644
  
  	for (iter = modules; *iter; iter++) {
 -		char *argv[3] = { "/sbin/modprobe", *iter, NULL };
-+		char *argv[3] = { "@kmod@/bin/modprobe", *iter, NULL };
++		char *argv[3] = { "/var/run/current-system/sw/bin/modprobe", *iter, NULL };
  		char *envp[1] = { NULL };
  		GError *error = NULL;
  
@@ -71,7 +71,7 @@ index 59698c3..7dba0f7 100644
  	/* Make sure /dev/ppp exists (bgo #533064) */
  	if (stat ("/dev/ppp", &st) || !S_ISCHR (st.st_mode))
 -		ignored = system ("/sbin/modprobe ppp_generic");
-+		ignored = system ("@kmod@/bin/modprobe ppp_generic");
++		ignored = system ("/var/run/current-system/sw/bin/modprobe ppp_generic");
  
  	connection = nm_act_request_get_connection (req);
  	g_assert (connection);
diff --git a/pkgs/tools/networking/network-manager/default.nix b/pkgs/tools/networking/network-manager/default.nix
index 57bf1a51a1ae..66a261c7cf64 100644
--- a/pkgs/tools/networking/network-manager/default.nix
+++ b/pkgs/tools/networking/network-manager/default.nix
@@ -2,7 +2,7 @@
 , systemd, libgudev, libnl, libuuid, polkit, gnutls, ppp, dhcp, iptables
 , libgcrypt, dnsmasq, bluez5, readline
 , gobjectIntrospection, modemmanager, openresolv, libndp, newt, libsoup
-, ethtool, gnused, coreutils, file, inetutils, kmod }:
+, ethtool, gnused, coreutils, file, inetutils }:
 
 stdenv.mkDerivation rec {
   name    = "network-manager-${version}";
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
     substituteInPlace configure --replace /usr/bin/uname ${coreutils}/bin/uname
     substituteInPlace configure --replace /usr/bin/file ${file}/bin/file
     substituteInPlace src/devices/nm-device.c --replace /usr/bin/ping ${inetutils}/bin/ping
-    substituteInPlace src/NetworkManagerUtils.c --replace /sbin/modprobe ${kmod}/bin/modprobe
+    substituteInPlace src/NetworkManagerUtils.c --replace /sbin/modprobe /run/current-system/sw/sbin/modprobe
     substituteInPlace data/84-nm-drivers.rules \
       --replace /bin/sh ${stdenv.shell}
     substituteInPlace data/85-nm-unmanaged.rules \
diff --git a/pkgs/tools/networking/network-manager/openconnect.nix b/pkgs/tools/networking/network-manager/openconnect.nix
index b1b24bceb576..43eb681be295 100644
--- a/pkgs/tools/networking/network-manager/openconnect.nix
+++ b/pkgs/tools/networking/network-manager/openconnect.nix
@@ -23,10 +23,10 @@ stdenv.mkDerivation rec {
 
   preConfigure = ''
      substituteInPlace "configure" \
-       --replace "/sbin/sysctl" "${procps}/bin/sysctl"
+       --replace "/sbin/sysctl" "${procps}/sbin/sysctl"
      substituteInPlace "src/nm-openconnect-service.c" \
-       --replace "/usr/sbin/openconnect" "${openconnect}/bin/openconnect" \
-       --replace "/sbin/modprobe" "${kmod}/bin/modprobe"
+       --replace "/usr/sbin/openconnect" "${openconnect}/sbin/openconnect" \
+       --replace "/sbin/modprobe" "${kmod}/sbin/modprobe"
   '';
 
   meta = {
diff --git a/pkgs/tools/networking/network-manager/openvpn.nix b/pkgs/tools/networking/network-manager/openvpn.nix
index 6fd1a666f0e8..34e3a3e2959a 100644
--- a/pkgs/tools/networking/network-manager/openvpn.nix
+++ b/pkgs/tools/networking/network-manager/openvpn.nix
@@ -27,10 +27,10 @@ stdenv.mkDerivation rec {
      substituteInPlace "configure" \
        --replace "/sbin/sysctl" "${procps}/sbin/sysctl"
      substituteInPlace "src/nm-openvpn-service.c" \
-       --replace "/sbin/openvpn" "${openvpn}/bin/openvpn" \
-       --replace "/sbin/modprobe" "${kmod}/bin/modprobe"
+       --replace "/sbin/openvpn" "${openvpn}/sbin/openvpn" \
+       --replace "/sbin/modprobe" "${kmod}/sbin/modprobe"
      substituteInPlace "properties/auth-helpers.c" \
-       --replace "/sbin/openvpn" "${openvpn}/bin/openvpn"
+       --replace "/sbin/openvpn" "${openvpn}/sbin/openvpn"
   '';
 
   meta = {
diff --git a/pkgs/tools/networking/network-manager/vpnc.nix b/pkgs/tools/networking/network-manager/vpnc.nix
index b760fe6e4f7d..97b2001d7592 100644
--- a/pkgs/tools/networking/network-manager/vpnc.nix
+++ b/pkgs/tools/networking/network-manager/vpnc.nix
@@ -24,10 +24,10 @@ stdenv.mkDerivation rec {
 
   preConfigure = ''
      substituteInPlace "configure" \
-       --replace "/sbin/sysctl" "${procps}/bin/sysctl"
+       --replace "/sbin/sysctl" "${procps}/sbin/sysctl"
      substituteInPlace "src/nm-vpnc-service.c" \
-       --replace "/sbin/vpnc" "${vpnc}/bin/vpnc" \
-       --replace "/sbin/modprobe" "${kmod}/bin/modprobe"
+       --replace "/sbin/vpnc" "${vpnc}/sbin/vpnc" \
+       --replace "/sbin/modprobe" "${kmod}/sbin/modprobe"
   '';
 
   meta = {
diff --git a/pkgs/tools/text/diffutils/default.nix b/pkgs/tools/text/diffutils/default.nix
index 8b6c5ca5c772..420e0a37ba7e 100644
--- a/pkgs/tools/text/diffutils/default.nix
+++ b/pkgs/tools/text/diffutils/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, xz, coreutils ? null }:
 
 stdenv.mkDerivation rec {
-  name = "diffutils-3.4";
+  name = "diffutils-3.3";
 
   src = fetchurl {
     url = "mirror://gnu/diffutils/${name}.tar.xz";
-    sha256 = "1qlw328qpbss07zrb14ls0rhnhbvxrnssgbmrxxj2gdcy8jw0lyv";
+    sha256 = "1761vymxbp4wb5rzjvabhdkskk95pghnn67464byvzb5mfl8jpm2";
   };
 
   outputs = [ "out" "info" ];
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index e107eb1dbcf1..796400d3568e 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -10832,8 +10832,6 @@ in
 
     opencflite = callPackage ../os-specific/darwin/opencflite {};
 
-    swift-corefoundation = callPackage ../os-specific/darwin/swift-corefoundation {};
-
     xcode = callPackage ../os-specific/darwin/xcode {};
 
     osx_sdk = callPackage ../os-specific/darwin/osx-sdk {};