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/adv_cmds/ps.nix35
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/CF/add-cf-initialize.patch18
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/CF/add-cfmachport.patch22
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/CF/default.nix41
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/CarbonHeaders/default.nix20
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/CommonCrypto/default.nix16
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/CoreOSMakefiles/default.nix30
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/Csu/default.nix27
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/IOKit/default.nix187
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/Libc/825_40_1.nix15
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/Libc/default.nix30
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/Libinfo/default.nix16
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/Libm/default.nix13
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/Libnotify/default.nix11
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix147
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/Libsystem/system_c_symbols1530
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/Libsystem/system_kernel_symbols929
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/Security/default.nix116
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/adv_cmds/default.nix30
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/architecture/default.nix23
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/bootstrap_cmds/default.nix44
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/configd/default.nix205
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/copyfile/default.nix10
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/default.nix83
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/dtrace/default.nix50
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/dyld/default.nix18
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/eap8021x/default.nix11
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/launchd/default.nix14
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/libauto/auto_dtrace.h129
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/libauto/default.nix74
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/libclosure/default.nix10
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/libdispatch/default.nix13
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix15
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/libpthread/default.nix13
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/libresolv/default.nix51
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/libunwind/default.nix29
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/mDNSResponder/default.nix10
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/objc4/default.nix35
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/objc4/objc-probes.h65
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/objc4/pure.nix118
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/objc4/spinlocks.patch107
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/ppp/default.nix16
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/removefile/default.nix10
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix117
-rw-r--r--pkgs/os-specific/darwin/cctools-port/default.nix64
-rw-r--r--pkgs/os-specific/darwin/cctools/ld-ignore-rpath-link.patch (renamed from pkgs/os-specific/darwin/cctools-port/ld-ignore-rpath-link.patch)0
-rw-r--r--pkgs/os-specific/darwin/cctools/ld-rpath-nonfinal.patch (renamed from pkgs/os-specific/darwin/cctools-port/ld-rpath-nonfinal.patch)0
-rw-r--r--pkgs/os-specific/darwin/cctools/port.nix102
-rw-r--r--pkgs/os-specific/darwin/command-line-tools/default.nix66
-rw-r--r--pkgs/os-specific/darwin/libc/default.nix40
-rw-r--r--pkgs/os-specific/darwin/libc/fileport.patch38
-rw-r--r--pkgs/os-specific/linux/afuse/default.nix14
-rw-r--r--pkgs/os-specific/linux/android-udev-rules/default.nix23
-rw-r--r--pkgs/os-specific/linux/ati-drivers/default.nix2
-rw-r--r--pkgs/os-specific/linux/batman-adv/alfred.nix27
-rw-r--r--pkgs/os-specific/linux/batman-adv/batctl.nix4
-rw-r--r--pkgs/os-specific/linux/batman-adv/default.nix6
-rw-r--r--pkgs/os-specific/linux/cifs-utils/default.nix11
-rw-r--r--pkgs/os-specific/linux/consoletools/default.nix14
-rw-r--r--pkgs/os-specific/linux/dmtcp/default.nix22
-rw-r--r--pkgs/os-specific/linux/firejail/default.nix8
-rw-r--r--pkgs/os-specific/linux/firmware/iwlegacy/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/iwlwifi/default.nix9
-rw-r--r--pkgs/os-specific/linux/firmware/zd1211/default.nix4
-rw-r--r--pkgs/os-specific/linux/flashbench/default.nix27
-rw-r--r--pkgs/os-specific/linux/freefall/default.nix42
-rw-r--r--pkgs/os-specific/linux/iproute/default.nix11
-rw-r--r--pkgs/os-specific/linux/jfbview/default.nix44
-rw-r--r--pkgs/os-specific/linux/kernel/bridge-stp-helper.patch13
-rw-r--r--pkgs/os-specific/linux/kernel/common-config.nix7
-rw-r--r--pkgs/os-specific/linux/kernel/generic.nix4
-rw-r--r--pkgs/os-specific/linux/kernel/linux-3.10.nix4
-rw-r--r--pkgs/os-specific/linux/kernel/linux-3.12.nix4
-rw-r--r--pkgs/os-specific/linux/kernel/linux-3.14.nix4
-rw-r--r--pkgs/os-specific/linux/kernel/linux-3.16.nix17
-rw-r--r--pkgs/os-specific/linux/kernel/linux-3.17.nix17
-rw-r--r--pkgs/os-specific/linux/kernel/linux-3.18.nix4
-rw-r--r--pkgs/os-specific/linux/kernel/linux-3.2.nix4
-rw-r--r--pkgs/os-specific/linux/kernel/linux-3.4.nix4
-rw-r--r--pkgs/os-specific/linux/kernel/linux-testing.nix8
-rw-r--r--pkgs/os-specific/linux/kernel/patches.nix17
-rw-r--r--pkgs/os-specific/linux/libcap/progs.nix8
-rw-r--r--pkgs/os-specific/linux/lxc/default.nix4
-rw-r--r--pkgs/os-specific/linux/mstpd/default.nix24
-rw-r--r--pkgs/os-specific/linux/mstpd/fixes.patch72
-rw-r--r--pkgs/os-specific/linux/nfs-utils/default.nix41
-rw-r--r--pkgs/os-specific/linux/nfs-utils/no-install.patch19
-rw-r--r--pkgs/os-specific/linux/nvidia-x11/default.nix4
-rw-r--r--pkgs/os-specific/linux/nvidia-x11/legacy173.nix2
-rw-r--r--pkgs/os-specific/linux/nvidia-x11/legacy304.nix2
-rw-r--r--pkgs/os-specific/linux/nvidia-x11/legacy340.nix4
-rw-r--r--pkgs/os-specific/linux/ocz-toolbox/default.nix2
-rw-r--r--pkgs/os-specific/linux/opengl/xorg-sys/default.nix2
-rw-r--r--pkgs/os-specific/linux/pam_krb5/default.nix8
-rw-r--r--pkgs/os-specific/linux/pcmciautils/default.nix8
-rw-r--r--pkgs/os-specific/linux/prl-tools/default.nix2
-rw-r--r--pkgs/os-specific/linux/radeontop/default.nix38
-rw-r--r--pkgs/os-specific/linux/sdparm/default.nix11
-rw-r--r--pkgs/os-specific/linux/spl/default.nix43
-rw-r--r--pkgs/os-specific/linux/spl/generic.nix61
-rw-r--r--pkgs/os-specific/linux/spl/git.nix49
-rw-r--r--pkgs/os-specific/linux/spl/install_prefix-git.patch173
-rw-r--r--pkgs/os-specific/linux/spl/kernel-3.16.patch34
-rw-r--r--pkgs/os-specific/linux/spl/kernel-3.17.patch175
-rw-r--r--pkgs/os-specific/linux/spl/time.patch18
-rw-r--r--pkgs/os-specific/linux/sysdig/default.nix4
-rw-r--r--pkgs/os-specific/linux/systemd/default.nix2
-rw-r--r--pkgs/os-specific/linux/util-linux/default.nix10
-rw-r--r--pkgs/os-specific/linux/util-linux/rtcwake-search-PATH-for-shutdown.patch30
-rw-r--r--pkgs/os-specific/linux/xf86-input-wacom/default.nix4
-rw-r--r--pkgs/os-specific/linux/zfs/3.19-compat-git.patch146
-rw-r--r--pkgs/os-specific/linux/zfs/bc151f7b312dea09c6ec5b9a320e65140789643a.patch84
-rw-r--r--pkgs/os-specific/linux/zfs/default.nix67
-rw-r--r--pkgs/os-specific/linux/zfs/generic.nix94
-rw-r--r--pkgs/os-specific/linux/zfs/git.nix75
-rw-r--r--pkgs/os-specific/linux/zfs/nix-build-git.patch133
-rw-r--r--pkgs/os-specific/linux/zfs/remove-lock-checks.patch64
117 files changed, 5871 insertions, 836 deletions
diff --git a/pkgs/os-specific/darwin/adv_cmds/ps.nix b/pkgs/os-specific/darwin/adv_cmds/ps.nix
new file mode 100644
index 000000000000..c3d3d1588627
--- /dev/null
+++ b/pkgs/os-specific/darwin/adv_cmds/ps.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "ps-${version}";
+  version = "153";
+
+  src = fetchurl {
+    url    = "http://opensource.apple.com/tarballs/adv_cmds/adv_cmds-${version}.tar.gz";
+    sha256 = "174v6a4zkcm2pafzgdm6kvs48z5f911zl7k49hv7kjq6gm58w99v";
+  };
+
+  buildPhase = ''
+    cd ps
+    cc -Os -Wall -I. -c -o fmt.o fmt.c
+    cc -Os -Wall -I. -c -o keyword.o keyword.c
+    cc -Os -Wall -I. -c -o nlist.o nlist.c
+    cc -Os -Wall -I. -c -o print.o print.c
+    cc -Os -Wall -I. -c -o ps.o ps.c
+    cc -Os -Wall -I. -c -o tasks.o tasks.c
+    cc -o ps fmt.o keyword.o nlist.o print.o ps.o tasks.o
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin $out/share/man/man1
+
+    cp ps   $out/bin/ps
+    cp ps.1 $out/share/man/man1
+  '';
+
+
+  meta = {
+    platforms = stdenv.lib.platforms.darwin;
+    maintainers = with stdenv.lib.maintainers; [ gridaphobe ];
+  };
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/CF/add-cf-initialize.patch b/pkgs/os-specific/darwin/apple-source-releases/CF/add-cf-initialize.patch
new file mode 100644
index 000000000000..46c230cfd1de
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/CF/add-cf-initialize.patch
@@ -0,0 +1,18 @@
+--- CF-855.17/CFRuntime.c	2014-11-26 21:29:48.000000000 -0800
++++ CF-855.17/CFRuntime.c.new	2014-11-26 21:30:01.000000000 -0800
+@@ -756,6 +756,7 @@
+ extern void __CFErrorInitialize(void);
+ extern void __CFTreeInitialize(void);
+ extern void __CFURLInitialize(void);
++extern void __CFPreferencesDomainInitialize(void);
+ #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI
+ extern void __CFMachPortInitialize(void);
+ #endif
+@@ -1015,6 +1016,7 @@
+         __CFErrorInitialize();
+         __CFTreeInitialize();
+         __CFURLInitialize();
++        __CFPreferencesDomainInitialize();
+         
+ #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_WINDOWS
+         __CFBundleInitialize();
diff --git a/pkgs/os-specific/darwin/apple-source-releases/CF/add-cfmachport.patch b/pkgs/os-specific/darwin/apple-source-releases/CF/add-cfmachport.patch
new file mode 100644
index 000000000000..a1018d389c14
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/CF/add-cfmachport.patch
@@ -0,0 +1,22 @@
+--- CF-855.17/CoreFoundation.h  2015-01-03 00:17:41.000000000 -0500
++++ CF-855.17/CoreFoundation.h.new  2015-01-03 00:18:35.000000000 -0500
+@@ -72,6 +72,7 @@
+ #include <CoreFoundation/CFDictionary.h>
+ #include <CoreFoundation/CFError.h>
+ #include <CoreFoundation/CFLocale.h>
++#include <CoreFoundation/CFMachPort.h>
+ #include <CoreFoundation/CFNumber.h>
+ #include <CoreFoundation/CFNumberFormatter.h>
+ #include <CoreFoundation/CFPreferences.h>
+
+--- CF-855.17/Makefile  2015-01-03 00:32:52.000000000 -0500
++++ CF-855.17/Makefile.new  2015-01-03 00:33:07.000000000 -0500
+@@ -9,7 +9,7 @@
+ HFILES = $(wildcard *.h)
+ INTERMEDIATE_HFILES = $(addprefix $(OBJBASE)/CoreFoundation/,$(HFILES))
+ 
+-PUBLIC_HEADERS=CFArray.h CFBag.h CFBase.h CFBinaryHeap.h CFBitVector.h CFBundle.h CFByteOrder.h CFCalendar.h CFCharacterSet.h CFData.h CFDate.h CFDateFormatter.h CFDictionary.h CFError.h CFLocale.h CFMessagePort.h CFNumber.h CFNumberFormatter.h CFPlugIn.h CFPlugInCOM.h CFPreferences.h CFPropertyList.h CFRunLoop.h CFSet.h CFSocket.h CFStream.h CFString.h CFStringEncodingExt.h CFTimeZone.h CFTree.h CFURL.h CFURLAccess.h CFUUID.h CFUserNotification.h CFXMLNode.h CFXMLParser.h CFAvailability.h CFUtilities.h CoreFoundation.h
++PUBLIC_HEADERS=CFArray.h CFBag.h CFBase.h CFBinaryHeap.h CFBitVector.h CFBundle.h CFByteOrder.h CFCalendar.h CFCharacterSet.h CFData.h CFDate.h CFDateFormatter.h CFDictionary.h CFError.h CFLocale.h CFMachPort.h CFMessagePort.h CFNumber.h CFNumberFormatter.h CFPlugIn.h CFPlugInCOM.h CFPreferences.h CFPropertyList.h CFRunLoop.h CFSet.h CFSocket.h CFStream.h CFString.h CFStringEncodingExt.h CFTimeZone.h CFTree.h CFURL.h CFURLAccess.h CFUUID.h CFUserNotification.h CFXMLNode.h CFXMLParser.h CFAvailability.h CFUtilities.h CoreFoundation.h
+ 
+ PRIVATE_HEADERS=CFBundlePriv.h CFCharacterSetPriv.h CFError_Private.h CFLogUtilities.h CFPriv.h CFRuntime.h CFStorage.h CFStreamAbstract.h CFStreamPriv.h CFStreamInternal.h CFStringDefaultEncoding.h CFStringEncodingConverter.h CFStringEncodingConverterExt.h CFUniChar.h CFUnicodeDecomposition.h CFUnicodePrecomposition.h ForFoundationOnly.h CFBurstTrie.h CFICULogging.h
+ 
diff --git a/pkgs/os-specific/darwin/apple-source-releases/CF/default.nix b/pkgs/os-specific/darwin/apple-source-releases/CF/default.nix
new file mode 100644
index 000000000000..3d4ac89e0a7e
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/CF/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, appleDerivation, icu, dyld, libdispatch, launchd, libclosure }:
+
+appleDerivation {
+  buildInputs = [ dyld icu libdispatch launchd libclosure ];
+
+  patches = [ ./add-cf-initialize.patch ./add-cfmachport.patch ];
+
+  preBuild = ''
+    substituteInPlace Makefile \
+      --replace "/usr/bin/clang" "clang" \
+      --replace "-arch i386 " "" \
+      --replace "/usr/bin/" "" \
+      --replace "/usr/sbin/" "" \
+      --replace "/bin/" "" \
+      --replace "INSTALLNAME=/System" "INSTALLNAME=$out" \
+      --replace "install_name_tool -id /System" "install_name_tool -id $out" \
+      --replace "-licucore.A" "-licui18n -licuuc" \
+      --replace 'chown -RH -f root:wheel $(DSTBASE)/CoreFoundation.framework' "" \
+      --replace 'chmod -RH' 'chmod -R'
+
+    replacement=''$'#define __PTK_FRAMEWORK_COREFOUNDATION_KEY5 55\n#define _pthread_getspecific_direct(key) pthread_getspecific((key))\n#define _pthread_setspecific_direct(key, val) pthread_setspecific((key), (val))'
+
+    substituteInPlace CFPlatform.c --replace "#include <pthread/tsd_private.h>" "$replacement"
+
+    substituteInPlace CFRunLoop.c --replace "#include <pthread/private.h>" ""
+
+    substituteInPlace CFURLPriv.h \
+      --replace "#include <CoreFoundation/CFFileSecurity.h>" "" \
+      --replace "#include <CoreFoundation/CFURLEnumerator.h>" "" \
+      --replace "CFFileSecurityRef" "void *" \
+      --replace "CFURLEnumeratorResult" "void *" \
+      --replace "CFURLEnumeratorRef" "void *"
+
+    export DSTROOT=$out
+  '';
+
+  postInstall = ''
+    mv $out/System/* $out
+    rmdir $out/System
+  '';
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/CarbonHeaders/default.nix b/pkgs/os-specific/darwin/apple-source-releases/CarbonHeaders/default.nix
new file mode 100644
index 000000000000..38215fa8f900
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/CarbonHeaders/default.nix
@@ -0,0 +1,20 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  installPhase = ''
+    mkdir -p $out/include
+    cp MacTypes.h          $out/include
+    cp ConditionalMacros.h $out/include
+
+    substituteInPlace $out/include/MacTypes.h \
+      --replace "CarbonCore/" ""
+  '';
+
+  meta = with stdenv.lib; {
+    maintainers = with maintainers; [ copumpkin ];
+    platforms   = platforms.darwin;
+    license     = licenses.apsl20;
+  };
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/CommonCrypto/default.nix b/pkgs/os-specific/darwin/apple-source-releases/CommonCrypto/default.nix
new file mode 100644
index 000000000000..5bcf94a18cef
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/CommonCrypto/default.nix
@@ -0,0 +1,16 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  installPhase = ''
+    mkdir -p $out/include/CommonCrypto
+    cp include/* $out/include/CommonCrypto
+  '';
+
+  meta = with stdenv.lib; {
+    maintainers = with maintainers; [ copumpkin ];
+    platforms   = platforms.darwin;
+    license     = licenses.apsl20;
+  };
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/CoreOSMakefiles/default.nix b/pkgs/os-specific/darwin/apple-source-releases/CoreOSMakefiles/default.nix
new file mode 100644
index 000000000000..9f6031771c2d
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/CoreOSMakefiles/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, appleDerivation, unifdef }:
+
+appleDerivation {
+  buildinputs = [ unifdef ];
+
+  phases = [ "unpackPhase" "installPhase" ];
+
+  preInstall = ''
+    substituteInPlace Makefile \
+      --replace "rsync -a --exclude=.svn --exclude=.git" "cp -r"
+
+    substituteInPlace Standard/Commands.in \
+      --replace "/bin/sh" "bash" \
+      --replace "/usr/bin/compress" "compress" \
+      --replace "/usr/bin/gzip" "gzip" \
+      --replace "/bin/pax" "pax" \
+      --replace "/usr/bin/tar" "tar" \
+      --replace "xcrun -find" "echo" \
+      --replace '$(Install_Program_Group)   -s' '$(Install_Program_Group)' \
+      --replace '$(Install_Program_Mode)   -s'  '$(Install_Program_Mode)'
+
+    substituteInPlace ReleaseControl/Common.make \
+      --replace "/tmp" "$TMPDIR"
+
+    substituteInPlace ReleaseControl/BSDCommon.make \
+      --replace '$(shell xcrun -find -sdk $(SDKROOT) cc)' "cc"
+
+    export DSTROOT=$out
+  '';
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/Csu/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Csu/default.nix
new file mode 100644
index 000000000000..893e9f2b2ebd
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/Csu/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  postUnpack = ''
+    substituteInPlace $sourceRoot/Makefile \
+      --replace "/usr/lib" "/lib" \
+      --replace "/usr/local/lib" "/lib" \
+      --replace "/usr/bin" "" \
+      --replace "/bin/" ""
+  '';
+
+  # Mac OS didn't support rpaths back before 10.5, and this package intentionally builds stubs targeting versions prior to that
+  NIX_DONT_SET_RPATH = "1";
+  NIX_NO_SELF_RPATH  = "1";
+
+  installPhase = ''
+    export DSTROOT=$out
+    make install
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Apple's common startup stubs for darwin";
+    maintainers = with maintainers; [ copumpkin ];
+    platforms   = platforms.darwin;
+    license     = licenses.apsl20;
+  };
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/IOKit/default.nix b/pkgs/os-specific/darwin/apple-source-releases/IOKit/default.nix
new file mode 100644
index 000000000000..12f38cd195fe
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/IOKit/default.nix
@@ -0,0 +1,187 @@
+{ stdenv, appleDerivation, IOKitSrcs, xnu }:
+
+# Someday it'll make sense to split these out into their own packages, but today is not that day.
+appleDerivation {
+  srcs = stdenv.lib.attrValues IOKitSrcs;
+  sourceRoot = ".";
+
+  phases = [ "unpackPhase" "installPhase" ];
+
+  __propagatedImpureHostDeps = [
+    "/System/Library/Frameworks/IOKit.framework/IOKit"
+    "/System/Library/Frameworks/IOKit.framework/Resources"
+    "/System/Library/Frameworks/IOKit.framework/Versions"
+  ];
+
+  installPhase = ''
+    ###### IMPURITIES
+    mkdir -p $out/Library/Frameworks/IOKit.framework
+    pushd $out/Library/Frameworks/IOKit.framework
+    ln -s /System/Library/Frameworks/IOKit.framework/IOKit
+    ln -s /System/Library/Frameworks/IOKit.framework/Resources
+    popd
+
+    ###### HEADERS
+
+    export dest=$out/Library/Frameworks/IOKit.framework/Headers
+    mkdir -p $dest
+
+    pushd $dest
+    mkdir audio avc DV firewire graphics hid hidsystem i2c kext ndrvsupport
+    mkdir network ps pwr_mgt sbp2 scsi serial storage stream usb video
+    popd
+
+    # root: complete
+    cp IOKitUser-907.100.13/IOCFBundle.h                                       $dest
+    cp IOKitUser-907.100.13/IOCFPlugIn.h                                       $dest
+    cp IOKitUser-907.100.13/IOCFSerialize.h                                    $dest
+    cp IOKitUser-907.100.13/IOCFUnserialize.h                                  $dest
+    cp IOKitUser-907.100.13/IOCFURLAccess.h                                    $dest
+    cp IOKitUser-907.100.13/IODataQueueClient.h                                $dest
+    cp IOKitUser-907.100.13/IOKitLib.h                                         $dest
+    cp IOKitUser-907.100.13/iokitmig.h                                         $dest
+    cp ${xnu}/Library/PrivateFrameworks/IOKit.framework/Versions/A/Headers/*.h $dest
+
+    # audio: complete
+    cp IOAudioFamily-197.4.2/IOAudioDefines.h          $dest/audio
+    cp IOKitUser-907.100.13/audio.subproj/IOAudioLib.h $dest/audio
+    cp IOAudioFamily-197.4.2/IOAudioTypes.h            $dest/audio
+
+    # avc: complete
+    cp IOFireWireAVC-422.4.0/IOFireWireAVC/IOFireWireAVCConsts.h $dest/avc
+    cp IOFireWireAVC-422.4.0/IOFireWireAVCLib/IOFireWireAVCLib.h $dest/avc
+
+    # DV: complete
+    cp IOFWDVComponents-207.4.1/DVFamily.h $dest/DV
+
+    # firewire: complete
+    cp IOFireWireFamily-455.4.0/IOFireWireFamily.kmodproj/IOFireWireFamilyCommon.h $dest/firewire
+    cp IOFireWireFamily-455.4.0/IOFireWireLib.CFPlugInProj/IOFireWireLib.h         $dest/firewire
+    cp IOFireWireFamily-455.4.0/IOFireWireLib.CFPlugInProj/IOFireWireLibIsoch.h    $dest/firewire
+    cp IOFireWireFamily-455.4.0/IOFireWireFamily.kmodproj/IOFWIsoch.h              $dest/firewire
+
+    # graphics: missing AppleGraphicsDeviceControlUserCommand.h
+    cp IOGraphics-471.92.1/IOGraphicsFamily/IOKit/graphics/IOAccelClientConnect.h     $dest/graphics
+    cp IOGraphics-471.92.1/IOGraphicsFamily/IOKit/graphics/IOAccelSurfaceConnect.h    $dest/graphics
+    cp IOGraphics-471.92.1/IOGraphicsFamily/IOKit/graphics/IOAccelTypes.h             $dest/graphics
+    cp IOGraphics-471.92.1/IOGraphicsFamily/IOKit/graphics/IOFramebufferShared.h      $dest/graphics
+    cp IOGraphics-471.92.1/IOGraphicsFamily/IOKit/graphics/IOGraphicsEngine.h         $dest/graphics
+    cp IOGraphics-471.92.1/IOGraphicsFamily/IOKit/graphics/IOGraphicsInterface.h      $dest/graphics
+    cp IOGraphics-471.92.1/IOGraphicsFamily/IOKit/graphics/IOGraphicsInterfaceTypes.h $dest/graphics
+    cp IOKitUser-907.100.13/graphics.subproj/IOGraphicsLib.h                          $dest/graphics
+    cp IOGraphics-471.92.1/IOGraphicsFamily/IOKit/graphics/IOGraphicsTypes.h          $dest/graphics
+
+    # hid: complete
+    cp IOKitUser-907.100.13/hid.subproj/IOHIDBase.h         $dest/hid
+    cp IOKitUser-907.100.13/hid.subproj/IOHIDDevice.h       $dest/hid
+    cp IOKitUser-907.100.13/hid.subproj/IOHIDDevicePlugIn.h $dest/hid
+    cp IOKitUser-907.100.13/hid.subproj/IOHIDElement.h      $dest/hid
+    cp IOKitUser-907.100.13/hid.subproj/IOHIDLib.h          $dest/hid
+    cp IOKitUser-907.100.13/hid.subproj/IOHIDManager.h      $dest/hid
+    cp IOKitUser-907.100.13/hid.subproj/IOHIDQueue.h        $dest/hid
+    cp IOKitUser-907.100.13/hid.subproj/IOHIDTransaction.h  $dest/hid
+    cp IOKitUser-907.100.13/hid.subproj/IOHIDValue.h        $dest/hid
+    cp IOHIDFamily-503.215.2/IOHIDFamily/IOHIDKeys.h        $dest/hid
+    cp IOHIDFamily-503.215.2/IOHIDFamily/IOHIDUsageTables.h $dest/hid
+    cp IOHIDFamily-503.215.2/IOHIDLib/IOHIDLibObsolete.h    $dest/hid
+
+    # hidsystem: complete
+    cp IOHIDFamily-503.215.2/IOHIDSystem/IOKit/hidsystem/ev_keymap.h      $dest/hidsystem
+    cp IOKitUser-907.100.13/hidsystem.subproj/event_status_driver.h       $dest/hidsystem
+    cp IOKitUser-907.100.13/hidsystem.subproj/IOHIDLib.h                  $dest/hidsystem
+    cp IOHIDFamily-503.215.2/IOHIDSystem/IOKit/hidsystem/IOHIDParameter.h $dest/hidsystem
+    cp IOHIDFamily-503.215.2/IOHIDSystem/IOKit/hidsystem/IOHIDShared.h    $dest/hidsystem
+    cp IOHIDFamily-503.215.2/IOHIDSystem/IOKit/hidsystem/IOHIDTypes.h     $dest/hidsystem
+    cp IOHIDFamily-503.215.2/IOHIDSystem/IOKit/hidsystem/IOLLEvent.h      $dest/hidsystem
+
+
+    # i2c: complete
+    cp IOGraphics-471.92.1/IOGraphicsFamily/IOKit/i2c/IOI2CInterface.h $dest/i2c
+
+    # kext: complete
+    cp IOKitUser-907.100.13/kext.subproj/KextManager.h $dest/kext
+
+    # ndrvsupport: complete
+    cp IOGraphics-471.92.1/IONDRVSupport/IOKit/ndrvsupport/IOMacOSTypes.h $dest/ndrvsupport
+    cp IOGraphics-471.92.1/IONDRVSupport/IOKit/ndrvsupport/IOMacOSVideo.h $dest/ndrvsupport
+
+    # network: complete
+    cp IONetworkingFamily-100/IOEthernetController.h       $dest/network
+    cp IONetworkingFamily-100/IOEthernetInterface.h        $dest/network
+    cp IONetworkingFamily-100/IOEthernetStats.h            $dest/network
+    cp IONetworkingFamily-100/IONetworkController.h        $dest/network
+    cp IONetworkingFamily-100/IONetworkData.h              $dest/network
+    cp IONetworkingFamily-100/IONetworkInterface.h         $dest/network
+    cp IOKitUser-907.100.13/network.subproj/IONetworkLib.h $dest/network
+    cp IONetworkingFamily-100/IONetworkMedium.h            $dest/network
+    cp IONetworkingFamily-100/IONetworkStack.h             $dest/network
+    cp IONetworkingFamily-100/IONetworkStats.h             $dest/network
+    cp IONetworkingFamily-100/IONetworkUserClient.h        $dest/network
+
+    # ps: missing IOUPSPlugIn.h
+    cp IOKitUser-907.100.13/ps.subproj/IOPowerSources.h $dest/ps
+    cp IOKitUser-907.100.13/ps.subproj/IOPSKeys.h       $dest/ps
+
+    # pwr_mgt: complete
+    cp IOKitUser-907.100.13/pwr_mgt.subproj/IOPMKeys.h                                 $dest/pwr_mgt
+    cp IOKitUser-907.100.13/pwr_mgt.subproj/IOPMLib.h                                  $dest/pwr_mgt
+    cp ${xnu}/Library/PrivateFrameworks/IOKit.framework/Versions/A/Headers/pwr_mgt/*.h $dest/pwr_mgt
+    cp IOKitUser-907.100.13/pwr_mgt.subproj/IOPMLibPrivate.h                           $dest/pwr_mgt # Private
+
+    # sbp2: complete
+    cp IOFireWireSBP2-426.4.1/IOFireWireSBP2Lib/IOFireWireSBP2Lib.h $dest/sbp2
+
+    # scsi: omitted for now
+
+    # serial: complete
+    cp IOSerialFamily-64.1.1/IOSerialFamily.kmodproj/IOSerialKeys.h $dest/serial
+    cp IOSerialFamily-64.1.1/IOSerialFamily.kmodproj/ioss.h         $dest/serial
+
+    # storage: complete
+    # Needs ata subdirectory
+    cp IOStorageFamily-172/IOAppleLabelScheme.h                                        $dest/storage
+    cp IOStorageFamily-172/IOApplePartitionScheme.h                                    $dest/storage
+    cp IOBDStorageFamily-14/IOBDBlockStorageDevice.h                                   $dest/storage
+    cp IOBDStorageFamily-14/IOBDMedia.h                                                $dest/storage
+    cp IOBDStorageFamily-14/IOBDMediaBSDClient.h                                       $dest/storage
+    cp IOBDStorageFamily-14/IOBDTypes.h                                                $dest/storage
+    cp IOStorageFamily-172/IOBlockStorageDevice.h                                      $dest/storage
+    cp IOStorageFamily-172/IOBlockStorageDriver.h                                      $dest/storage
+    cp IOCDStorageFamily-51/IOCDBlockStorageDevice.h                                   $dest/storage
+    cp IOCDStorageFamily-51/IOCDMedia.h                                                $dest/storage
+    cp IOCDStorageFamily-51/IOCDMediaBSDClient.h                                       $dest/storage
+    cp IOCDStorageFamily-51/IOCDPartitionScheme.h                                      $dest/storage
+    cp IOCDStorageFamily-51/IOCDTypes.h                                                $dest/storage
+    cp IODVDStorageFamily-35/IODVDBlockStorageDevice.h                                 $dest/storage
+    cp IODVDStorageFamily-35/IODVDMedia.h                                              $dest/storage
+    cp IODVDStorageFamily-35/IODVDMediaBSDClient.h                                     $dest/storage
+    cp IODVDStorageFamily-35/IODVDTypes.h                                              $dest/storage
+    cp IOStorageFamily-172/IOFDiskPartitionScheme.h                                    $dest/storage
+    cp IOStorageFamily-172/IOFilterScheme.h                                            $dest/storage
+    cp IOFireWireSerialBusProtocolTransport-251.0.1/IOFireWireStorageCharacteristics.h $dest/storage
+    cp IOStorageFamily-172/IOGUIDPartitionScheme.h                                     $dest/storage
+    cp IOStorageFamily-172/IOMedia.h                                                   $dest/storage
+    cp IOStorageFamily-172/IOMediaBSDClient.h                                          $dest/storage
+    cp IOStorageFamily-172/IOPartitionScheme.h                                         $dest/storage
+    cp IOStorageFamily-172/IOStorage.h                                                 $dest/storage
+    cp IOStorageFamily-172/IOStorageCardCharacteristics.h                              $dest/storage
+    cp IOStorageFamily-172/IOStorageDeviceCharacteristics.h                            $dest/storage
+    cp IOStorageFamily-172/IOStorageProtocolCharacteristics.h                          $dest/storage
+
+    # stream: missing altogether
+
+    # usb: complete
+    cp IOUSBFamily-630.4.5/IOUSBFamily/Headers/IOUSBLib.h            $dest/usb
+    cp IOUSBFamily-630.4.5/IOUSBUserClient/Headers/IOUSBUserClient.h $dest/usb
+    cp IOUSBFamily-560.4.2/IOUSBFamily/Headers/USB.h                 $dest/usb # This file is empty in 630.4.5!
+    cp IOUSBFamily-630.4.5/IOUSBFamily/Headers/USBSpec.h             $dest/usb
+
+    # video: missing altogether
+  '';
+
+  meta = with stdenv.lib; {
+    maintainers = with maintainers; [ joelteon copumpkin ];
+    platforms   = platforms.darwin;
+    license     = licenses.apsl20;
+  };
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libc/825_40_1.nix b/pkgs/os-specific/darwin/apple-source-releases/Libc/825_40_1.nix
new file mode 100644
index 000000000000..b5e7e5123930
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/Libc/825_40_1.nix
@@ -0,0 +1,15 @@
+{ stdenv, appleDerivation, ed, unifdef }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  buildInputs = [ ed unifdef ];
+
+  installPhase = ''
+    export SRCROOT=$PWD
+    export DSTROOT=$out
+    export PUBLIC_HEADERS_FOLDER_PATH=include
+    export PRIVATE_HEADERS_FOLDER_PATH=include
+    bash xcodescripts/headers.sh
+  '';
+}
\ No newline at end of file
diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libc/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Libc/default.nix
new file mode 100644
index 000000000000..16cfa9e554b6
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/Libc/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, appleDerivation, ed, unifdef, Libc_old }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  buildInputs = [ ed unifdef ];
+
+  # TODO: asl.h actually comes from syslog project now
+  installPhase = ''
+    export SRCROOT=$PWD
+    export DSTROOT=$out
+    export PUBLIC_HEADERS_FOLDER_PATH=include
+    export PRIVATE_HEADERS_FOLDER_PATH=include
+    bash xcodescripts/headers.sh
+
+    # 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
+    cp    ${Libc_old}/include/ucontext.h $out/include
+    cp    ${Libc_old}/include/pthread*.h $out/include
+    cp    ${Libc_old}/include/sched.h    $out/include
+    cp -R ${Libc_old}/include/malloc     $out/include
+
+    mkdir -p $out/include/libkern
+    cp ${Libc_old}/include/asl.h                    $out/include
+    cp ${Libc_old}/include/libproc.h                $out/include
+    cp ${Libc_old}/include/libkern/OSAtomic.h       $out/include/libkern
+    cp ${Libc_old}/include/libkern/OSCacheControl.h $out/include/libkern
+  '';
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libinfo/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Libinfo/default.nix
new file mode 100644
index 000000000000..2756857ba677
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/Libinfo/default.nix
@@ -0,0 +1,16 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  installPhase = ''
+    substituteInPlace xcodescripts/install_files.sh \
+      --replace "/usr/local/" "/" \
+      --replace "/usr/" "/" \
+      --replace '-o "$INSTALL_OWNER" -g "$INSTALL_GROUP"' "" \
+      --replace "ln -h" "ln -n"
+
+    export DSTROOT=$out
+    sh xcodescripts/install_files.sh
+  '';
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libm/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Libm/default.nix
new file mode 100644
index 000000000000..b409a7347ef2
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/Libm/default.nix
@@ -0,0 +1,13 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  installPhase = ''
+    mkdir -p $out/include
+
+    cp Source/Intel/math.h $out/include
+    cp Source/Intel/fenv.h $out/include
+    cp Source/complex.h    $out/include
+  '';
+}
\ No newline at end of file
diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libnotify/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Libnotify/default.nix
new file mode 100644
index 000000000000..810c8e8315a5
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/Libnotify/default.nix
@@ -0,0 +1,11 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  installPhase = ''
+    mkdir -p $out/include
+    cp notify.h      $out/include
+    cp notify_keys.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
new file mode 100644
index 000000000000..ecab09413324
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix
@@ -0,0 +1,147 @@
+{ stdenv, appleDerivation, cpio, bootstrap_cmds, xnu, Libc, Libm, libdispatch, cctools, Libinfo,
+  dyld, Csu, architecture, libclosure, CarbonHeaders, ncurses, CommonCrypto, copyfile,
+  removefile, libresolv, Libnotify, libpthread, mDNSResponder, launchd, version }:
+
+appleDerivation rec {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  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"
+                 "system_stats"
+                 "unc"
+                 "unwind"
+                 "xpc"
+               ];
+
+  installPhase = ''
+    export NIX_ENFORCE_PURITY=
+
+    mkdir -p $out/lib $out/include
+
+    # Set up our include directories
+    (cd ${xnu}/include && find . -name '*.h' -or -name '*.defs' | cpio -pdm $out/include)
+    cp ${xnu}/Library/Frameworks/Kernel.framework/Versions/A/Headers/Availability*.h $out/include
+    cp ${xnu}/Library/Frameworks/Kernel.framework/Versions/A/Headers/stdarg.h        $out/include
+
+    for dep in ${Libc} ${Libm} ${Libinfo} ${dyld} ${architecture} ${libclosure} ${CarbonHeaders} \
+               ${libdispatch} ${ncurses} ${CommonCrypto} ${copyfile} ${removefile} ${libresolv} \
+               ${Libnotify} ${mDNSResponder} ${launchd}; do
+      (cd $dep/include && find . -name '*.h' | cpio -pdm $out/include)
+    done
+
+    (cd ${cctools}/include/mach-o && find . -name '*.h' | cpio -pdm $out/include/mach-o)
+
+    cat <<EOF > $out/include/TargetConditionals.h
+    #ifndef __TARGETCONDITIONALS__
+    #define __TARGETCONDITIONALS__
+    #define TARGET_OS_MAC           1
+    #define TARGET_OS_WIN32         0
+    #define TARGET_OS_UNIX          0
+    #define TARGET_OS_EMBEDDED      0
+    #define TARGET_OS_IPHONE        0
+    #define TARGET_IPHONE_SIMULATOR 0
+    #define TARGET_OS_LINUX         0
+
+    #define TARGET_CPU_PPC          0
+    #define TARGET_CPU_PPC64        0
+    #define TARGET_CPU_68K          0
+    #define TARGET_CPU_X86          0
+    #define TARGET_CPU_X86_64       1
+    #define TARGET_CPU_ARM          0
+    #define TARGET_CPU_MIPS         0
+    #define TARGET_CPU_SPARC        0
+    #define TARGET_CPU_ALPHA        0
+    #define TARGET_RT_MAC_CFM       0
+    #define TARGET_RT_MAC_MACHO     1
+    #define TARGET_RT_LITTLE_ENDIAN 1
+    #define TARGET_RT_BIG_ENDIAN    0
+    #define TARGET_RT_64_BIT        1
+    #endif  /* __TARGETCONDITIONALS__ */
+    EOF
+
+    # The startup object files
+    cp ${Csu}/lib/* $out/lib
+
+    # 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 ${version} \
+       -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 gcc_s.10.4 gcc_s.10.5; do
+      ln -s libSystem.dylib $out/lib/lib$name.dylib
+    done
+
+    # This probably doesn't belong here, but we want to stay similar to glibc, which includes resolv internally...
+    cp ${libresolv}/lib/libresolv.9.dylib $out/lib/libresolv.9.dylib
+    resolv_libSystem=$(otool -L "$out/lib/libresolv.9.dylib" | tail -n +3 | grep -o "$NIX_STORE.*-\S*") || true
+    echo $libs
+
+    chmod +w $out/lib/libresolv.9.dylib
+    install_name_tool \
+      -id $out/lib/libresolv.9.dylib \
+      -change "$resolv_libSystem" $out/lib/libSystem.dylib \
+      -delete_rpath ${libresolv}/lib \
+      $out/lib/libresolv.9.dylib
+    ln -s libresolv.9.dylib $out/lib/libresolv.dylib
+
+    otool -L $out/lib/libresolv.dylib
+  '';
+
+  meta = with stdenv.lib; {
+    description = "The Mac OS libc/libSystem (impure symlinks to binaries with pure headers)";
+    maintainers = with maintainers; [ copumpkin gridaphobe ];
+    platforms   = platforms.darwin;
+    license     = licenses.apsl20;
+  };
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libsystem/system_c_symbols b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/system_c_symbols
new file mode 100644
index 000000000000..0c814899c3c4
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/system_c_symbols
@@ -0,0 +1,1530 @@
+_NSGetNextSearchPathEnumeration
+_NSStartSearchPathEnumeration
+_OSAtomicAdd32
+_OSAtomicAdd32Barrier
+_OSAtomicAnd32
+_OSAtomicDequeue
+_OSAtomicEnqueue
+_OSSpinLockLock
+_OSSpinLockUnlock
+__Block_copy
+__Block_release
+__CurrentRuneLocale
+__DefaultRuneLocale
+__Exit
+__NSGetArgc
+__NSGetArgv
+__NSGetEnviron
+__NSGetMachExecuteHeader
+__NSGetProgname
+__PathLocale
+__Read_RuneMagi
+___Balloc_D2A
+___Bfree_D2A
+___ULtod_D2A
+____mb_cur_max
+____mb_cur_max_l
+____runetype
+____runetype_l
+____tolower
+____tolower_l
+____toupper
+____toupper_l
+___add_ovflpage
+___addel
+___any_on_D2A
+___assert_rtn
+___b2d_D2A
+___big_delete
+___big_insert
+___big_keydata
+___big_return
+___big_split
+___bigtens_D2A
+___bt_close
+___bt_cmp
+___bt_defcmp
+___bt_defpfx
+___bt_delete
+___bt_dleaf
+___bt_fd
+___bt_free
+___bt_get
+___bt_new
+___bt_open
+___bt_pgin
+___bt_pgout
+___bt_put
+___bt_ret
+___bt_search
+___bt_seq
+___bt_setcur
+___bt_split
+___bt_sync
+___buf_free
+___bzero
+___cVersionNumber
+___cVersionString
+___call_hash
+___chmod_extended
+___cleanup
+___cmp_D2A
+___collate_equiv_match
+___collate_load_error
+___collate_lookup
+___commpage_gettimeofday
+___copybits_D2A
+___cxa_atexit
+___cxa_finalize
+___cxa_thread_atexit
+___d2b_D2A
+___dbpanic
+___decrement_D2A
+___default_hash
+___default_utx
+___delpair
+___diff_D2A
+___dtoa
+___error
+___exit
+___expand_table
+___fchmod_extended
+___fcntl
+___fcntl_nocancel
+___fflush
+___fgetwc
+___find_bigpair
+___find_last_page
+___fix_locale_grouping_str
+___fork
+___fpclassifyd
+___fpclassifyl
+___fread
+___free_ovflpage
+___freedtoa
+___fstat64_extended
+___fstat_extended
+___gdtoa
+___gdtoa_locks
+___get_buf
+___get_page
+___getdirentries64
+___gethex_D2A
+___getlogin
+___getonlyClocaleconv
+___gettimeofday
+___hash_open
+___hdtoa
+___hexdig_D2A
+___hexdig_init_D2A
+___hexnan_D2A
+___hi0bits_D2A
+___hldtoa
+___i2b_D2A
+___ibitmap
+___increment_D2A
+___isctype
+___istype
+___istype_l
+___kill
+___ldtoa
+___libc_init
+___lo0bits_D2A
+___log2
+___lshift_D2A
+___lstat64_extended
+___lstat_extended
+___maskrune
+___maskrune_l
+___match_D2A
+___mb_cur_max
+___mb_sb_limit
+___memccpy_chk
+___memcpy_chk
+___memmove_chk
+___memset_chk
+___mkdir_extended
+___mkfifo_extended
+___mult_D2A
+___multadd_D2A
+___nrv_alloc_D2A
+___open
+___open_extended
+___open_nocancel
+___opendir2
+___opendir2$INODE64
+___ovfl_delete
+___ovfl_get
+___ovfl_put
+___pow5mult_D2A
+___pthread_sigmask
+___pthread_workqueue_setkill
+___put_page
+___quorem_D2A
+___ratio_D2A
+___rec_close
+___rec_delete
+___rec_dleaf
+___rec_fd
+___rec_fmap
+___rec_fpipe
+___rec_get
+___rec_iput
+___rec_open
+___rec_put
+___rec_ret
+___rec_search
+___rec_seq
+___rec_sync
+___rec_vmap
+___rec_vpipe
+___reclaim_buf
+___recvfrom
+___recvfrom_nocancel
+___rshift_D2A
+___rv_alloc_D2A
+___s2b_D2A
+___sF
+___sclose
+___sdidinit
+___semwait_signal
+___semwait_signal_nocancel
+___sendto
+___sendto_nocancel
+___set_ones_D2A
+___setlogin
+___setonlyClocaleconv
+___settimeofday
+___sflags
+___sflush
+___sfp
+___sfvwrite
+___sglue
+___sigaction
+___sigaltstack
+___sinit
+___slbexpand
+___smakebuf
+___snprintf_chk
+___split_page
+___sprintf_chk
+___sread
+___srefill
+___srget
+___sseek
+___stack_chk_fail
+___stack_chk_guard
+___stat64_extended
+___stat_extended
+___stderrp
+___stdinp
+___stdoutp
+___stpcpy_chk
+___stpncpy_chk
+___strcat_chk
+___strcp_D2A
+___strcpy_chk
+___strlcat_chk
+___strlcpy_chk
+___strncat_chk
+___strncpy_chk
+___strtodg
+___strtopdd
+___strtopx
+___sum_D2A
+___svfscanf
+___swbuf
+___swhatbuf
+___swrite
+___swsetup
+___sysctl
+___tens_D2A
+___tinytens_D2A
+___tolower
+___tolower_l
+___toupper
+___toupper_l
+___trailz_D2A
+___ulp_D2A
+___umask_extended
+___ungetc
+___ungetwc
+___unix_conforming
+___vsnprintf_chk
+___vsprintf_chk
+___wait4
+___wait4_nocancel
+___wcwidth
+___wcwidth_l
+__allocenvstate
+__c_locale
+__cleanup
+__closeutx
+__copyenv
+__cthread_init_routine
+__deallocenvstate
+__dyld_register_func_for_add_image
+__endutxent
+__exit
+__flockfile_debug_stub
+__fseeko
+__ftello
+__fwalk
+__get_cpu_capabilities
+__getenvp
+__getutxent
+__getutxid
+__getutxline
+__inet_aton_check
+__init_clock_port
+__int_to_time
+__libc_fork_child
+__long_to_time
+__mkpath_np
+__mktemp
+__openutx
+__os_alloc_once
+__os_alloc_once_table
+__os_assert_log
+__os_assert_log_ctx
+__os_assumes_log
+__os_assumes_log_ctx
+__os_avoid_tail_call
+__osx_assert_log
+__osx_assert_log_ctx
+__osx_assumes_log
+__osx_assumes_log_ctx
+__osx_avoid_tail_call
+__platform_bzero
+__platform_memccpy
+__platform_memchr
+__platform_memcmp
+__platform_memmove
+__platform_memset
+__platform_memset_pattern16
+__platform_memset_pattern4
+__platform_memset_pattern8
+__platform_strchr
+__platform_strcmp
+__platform_strncmp
+__putenvp
+__pututxline
+__rand48_add
+__rand48_mult
+__rand48_seed
+__readdir_unlocked
+__readdir_unlocked$INODE64
+__reclaim_telldir
+__seekdir
+__seekdir$INODE64
+__setenvp
+__setutxent
+__sigaction_nobind
+__sigintr
+__signal_nobind
+__sigtramp
+__sigvec_nobind
+__simple_asl_log
+__simple_asl_log_prog
+__simple_asl_msg_new
+__simple_asl_msg_set
+__simple_asl_send
+__simple_dprintf
+__simple_salloc
+__simple_sappend
+__simple_sfree
+__simple_sprintf
+__simple_string
+__simple_vsprintf
+__sread
+__sseek
+__swrite
+__time32_to_time
+__time64_to_time
+__time_to_int
+__time_to_long
+__time_to_time32
+__time_to_time64
+__tlv_atexit
+__tlv_exit
+__unsetenvp
+__utmpxname
+_a64l
+_abort
+_abs
+_access
+_acl_add_flag_np
+_acl_add_perm
+_acl_calc_mask
+_acl_clear_flags_np
+_acl_clear_perms
+_acl_copy_entry
+_acl_copy_ext
+_acl_copy_ext_native
+_acl_copy_int
+_acl_copy_int_native
+_acl_create_entry
+_acl_create_entry_np
+_acl_delete_def_file
+_acl_delete_entry
+_acl_delete_fd_np
+_acl_delete_file_np
+_acl_delete_flag_np
+_acl_delete_link_np
+_acl_delete_perm
+_acl_dup
+_acl_free
+_acl_from_text
+_acl_get_entry
+_acl_get_fd
+_acl_get_fd_np
+_acl_get_file
+_acl_get_flag_np
+_acl_get_flagset_np
+_acl_get_link_np
+_acl_get_perm_np
+_acl_get_permset
+_acl_get_permset_mask_np
+_acl_get_qualifier
+_acl_get_tag_type
+_acl_init
+_acl_maximal_permset_mask_np
+_acl_set_fd
+_acl_set_fd_np
+_acl_set_file
+_acl_set_flagset_np
+_acl_set_link_np
+_acl_set_permset
+_acl_set_permset_mask_np
+_acl_set_qualifier
+_acl_set_tag_type
+_acl_size
+_acl_to_text
+_acl_valid
+_acl_valid_fd_np
+_acl_valid_file_np
+_acl_valid_link
+_addr2ascii
+_alarm
+_alphasort
+_alphasort$INODE64
+_arc4random
+_arc4random_addrandom
+_arc4random_buf
+_arc4random_stir
+_arc4random_uniform
+_ascii2addr
+_asctime
+_asctime_r
+_asl_get
+_asl_new
+_asl_open
+_asl_send
+_asl_set
+_asl_set_query
+_asprintf
+_asprintf_l
+_asxprintf
+_asxprintf_exec
+_atexit
+_atexit_b
+_atof
+_atof_l
+_atoi
+_atoi_l
+_atol
+_atol_l
+_atoll
+_atoll_l
+_backtrace
+_backtrace_symbols
+_backtrace_symbols_fd
+_basename
+_bcmp
+_bcopy
+_bootstrap_parent
+_bootstrap_port
+_brk
+_bsd_signal
+_bsearch
+_bsearch_b
+_btowc
+_btowc_l
+_bzero
+_calloc
+_catclose
+_catgets
+_catopen
+_cfgetispeed
+_cfgetospeed
+_cfmakeraw
+_cfsetispeed
+_cfsetospeed
+_cfsetspeed
+_cgetcap
+_cgetclose
+_cgetent
+_cgetfirst
+_cgetmatch
+_cgetnext
+_cgetnum
+_cgetset
+_cgetstr
+_cgetustr
+_chdir
+_chflags
+_chmod
+_chmodx_np
+_clearerr
+_clearerr_unlocked
+_clock
+_clock_get_time
+_clock_port
+_clock_sem
+_close$NOCANCEL
+_closedir
+_compat_mode
+_confstr
+_copy_printf_domain
+_creat
+_creat$NOCANCEL
+_crypt
+_ctermid
+_ctermid_r
+_ctime
+_ctime_r
+_daemon
+_daemon$1050
+_daylight
+_dbm_clearerr
+_dbm_close
+_dbm_delete
+_dbm_dirfno
+_dbm_error
+_dbm_fetch
+_dbm_firstkey
+_dbm_nextkey
+_dbm_open
+_dbm_store
+_dbopen
+_devname
+_devname_r
+_difftime
+_digittoint
+_digittoint_l
+_dirfd
+_dirname
+_dispatch_get_global_queue
+_div
+_dladdr
+_dlsym
+_dprintf
+_dprintf_l
+_drand48
+_dup2
+_duplocale
+_dxprintf
+_dxprintf_exec
+_dyld_get_program_sdk_version
+_dyld_get_sdk_version
+_ecvt
+_encrypt
+_endttyent
+_endusershell
+_endutxent
+_endutxent_wtmp
+_erand48
+_err
+_err_set_exit
+_err_set_exit_b
+_err_set_file
+_errc
+_errx
+_execl
+_execle
+_execlp
+_execv
+_execvP
+_execve
+_execvp
+_exit
+_f_prealloc
+_fchdir
+_fchmodx_np
+_fclose
+_fcntl$NOCANCEL
+_fcvt
+_fdopen
+_fdopen$DARWIN_EXTSN
+_fegetenv
+_feof
+_feof_unlocked
+_ferror
+_ferror_unlocked
+_fesetenv
+_fflagstostr
+_fflush
+_ffsctl
+_fgetc
+_fgetln
+_fgetpos
+_fgetrune
+_fgets
+_fgetwc
+_fgetwc_l
+_fgetwln
+_fgetwln_l
+_fgetws
+_fgetws_l
+_fileno
+_fileno_unlocked
+_filesec_dup
+_filesec_free
+_filesec_get_property
+_filesec_init
+_filesec_query_property
+_filesec_set_property
+_filesec_unset_property
+_flockfile
+_flsl
+_fmtcheck
+_fmtmsg
+_fnmatch
+_fopen
+_fopen$DARWIN_EXTSN
+_fork
+_forkpty
+_fparseln
+_fprintf
+_fprintf_l
+_fpurge
+_fputc
+_fputrune
+_fputs
+_fputwc
+_fputwc_l
+_fputws
+_fputws_l
+_fread
+_free
+_free_printf_comp
+_free_printf_domain
+_freeifaddrs
+_freelocale
+_freopen
+_fscanf
+_fscanf_l
+_fsctl
+_fseek
+_fseeko
+_fsetpos
+_fstat
+_fstat$INODE64
+_fstatfs
+_fstatfs$INODE64
+_fstatvfs
+_fstatx64_np
+_fstatx_np
+_fstatx_np$INODE64
+_fsync$NOCANCEL
+_fsync_volume_np
+_ftell
+_ftello
+_ftime
+_ftok
+_ftruncate
+_ftrylockfile
+_fts_children
+_fts_children$INODE64
+_fts_close
+_fts_close$INODE64
+_fts_open
+_fts_open$INODE64
+_fts_open_b
+_fts_open_b$INODE64
+_fts_read
+_fts_read$INODE64
+_fts_set
+_fts_set$INODE64
+_ftw
+_ftw$INODE64
+_fungetrune
+_funlockfile
+_funopen
+_fwide
+_fwprintf
+_fwprintf_l
+_fwrite
+_fwscanf
+_fwscanf_l
+_fxprintf
+_fxprintf_exec
+_gcvt
+_getattrlist
+_getbsize
+_getc
+_getc_unlocked
+_getchar
+_getchar_unlocked
+_getcwd
+_getdate
+_getdate_err
+_getdelim
+_getdirentries
+_getdiskbyname
+_getdtablesize
+_getenv
+_geteuid
+_getfsstat
+_getfsstat$INODE64
+_getfsstat64
+_getgrgid
+_getgrnam
+_getgroupcount
+_getgrouplist
+_getgroups$DARWIN_EXTSN
+_gethostid
+_gethostname
+_getifaddrs
+_getipv4sourcefilter
+_getlastlogx
+_getlastlogxbyname
+_getline
+_getloadavg
+_getlogin
+_getlogin_r
+_getmntinfo
+_getmntinfo$INODE64
+_getmntinfo64
+_getmode
+_getopt
+_getopt_long
+_getopt_long_only
+_getpagesize
+_getpass
+_getpeereid
+_getpgrp
+_getpid
+_getpriority
+_getprogname
+_getpwnam
+_getpwuid
+_getpwuid_r
+_getrlimit
+_getrusage
+_gets
+_getsectiondata
+_getsockopt
+_getsourcefilter
+_getsubopt
+_gettimeofday
+_getttyent
+_getttynam
+_getuid
+_getusershell
+_getutmp
+_getutmpx
+_getutxent
+_getutxent_wtmp
+_getutxid
+_getutxline
+_getvfsbyname
+_getw
+_getwc
+_getwc_l
+_getwchar
+_getwchar_l
+_getwd
+_glob
+_glob$INODE64
+_glob_b
+_glob_b$INODE64
+_globfree
+_gmtime
+_gmtime_r
+_grantpt
+_hash_create
+_hash_destroy
+_hash_purge
+_hash_search
+_hash_stats
+_hash_traverse
+_hcreate
+_hdestroy
+_heapsort
+_heapsort_b
+_host_get_clock_service
+_hsearch
+_if_nametoindex
+_imaxabs
+_imaxdiv
+_index
+_inet_addr
+_inet_aton
+_inet_lnaof
+_inet_makeaddr
+_inet_net_ntop
+_inet_net_pton
+_inet_neta
+_inet_netof
+_inet_network
+_inet_nsap_addr
+_inet_nsap_ntoa
+_inet_ntoa
+_inet_ntop
+_inet_ntop4
+_inet_ntop6
+_inet_pton
+_initstate
+_insque
+_ioctl
+_isalnum
+_isalnum_l
+_isalpha
+_isalpha_l
+_isascii
+_isatty
+_isblank
+_isblank_l
+_iscntrl
+_iscntrl_l
+_isdigit
+_isdigit_l
+_isgraph
+_isgraph_l
+_ishexnumber
+_ishexnumber_l
+_isideogram
+_isideogram_l
+_islower
+_islower_l
+_isnumber
+_isnumber_l
+_isphonogram
+_isphonogram_l
+_isprint
+_isprint_l
+_ispunct
+_ispunct_l
+_isrune
+_isrune_l
+_issetugid
+_isspace
+_isspace_l
+_isspecial
+_isspecial_l
+_isupper
+_isupper_l
+_iswalnum
+_iswalnum_l
+_iswalpha
+_iswalpha_l
+_iswascii
+_iswblank
+_iswblank_l
+_iswcntrl
+_iswcntrl_l
+_iswctype
+_iswctype_l
+_iswdigit
+_iswdigit_l
+_iswgraph
+_iswgraph_l
+_iswhexnumber
+_iswhexnumber_l
+_iswideogram
+_iswideogram_l
+_iswlower
+_iswlower_l
+_iswnumber
+_iswnumber_l
+_iswphonogram
+_iswphonogram_l
+_iswprint
+_iswprint_l
+_iswpunct
+_iswpunct_l
+_iswrune
+_iswrune_l
+_iswspace
+_iswspace_l
+_iswspecial
+_iswspecial_l
+_iswupper
+_iswupper_l
+_iswxdigit
+_iswxdigit_l
+_isxdigit
+_isxdigit_l
+_jrand48
+_kill
+_killpg
+_l64a
+_labs
+_lchflags
+_lchmod
+_lcong48
+_ldiv
+_lfind
+_link_addr
+_link_ntoa
+_llabs
+_lldiv
+_localeconv
+_localeconv_l
+_localtime
+_localtime_r
+_lockf
+_lockf$NOCANCEL
+_login
+_login_tty
+_logout
+_logwtmp
+_lrand48
+_lsearch
+_lseek
+_lstat
+_lstat$INODE64
+_lstatx64_np
+_lstatx_np
+_lstatx_np$INODE64
+_lutimes
+_mach_absolute_time
+_mach_error_string
+_mach_host_self
+_mach_port_deallocate
+_mach_task_self_
+_mach_timebase_info
+_malloc
+_mblen
+_mblen_l
+_mbmb
+_mbr_gid_to_uuid
+_mbr_uid_to_uuid
+_mbr_uuid_to_id
+_mbrlen
+_mbrlen_l
+_mbrrune
+_mbrtowc
+_mbrtowc_l
+_mbrune
+_mbsinit
+_mbsinit_l
+_mbsnrtowcs
+_mbsnrtowcs_l
+_mbsrtowcs
+_mbsrtowcs_l
+_mbstowcs
+_mbstowcs_l
+_mbtowc
+_mbtowc_l
+_memccpy
+_memchr
+_memcmp
+_memcpy
+_memmem
+_memmove
+_memset
+_memset_pattern16
+_memset_pattern4
+_memset_pattern8
+_memset_s
+_mergesort
+_mergesort_b
+_mkdir
+_mkdirx_np
+_mkdtemp
+_mkfifox_np
+_mkpath_np
+_mkstemp
+_mkstemps
+_mktemp
+_mktime
+_mmap
+_monaddition
+_moncontrol
+_moncount
+_moninit
+_monitor
+_monoutput
+_monreset
+_monstartup
+_mpool_close
+_mpool_filter
+_mpool_get
+_mpool_new
+_mpool_open
+_mpool_put
+_mpool_sync
+_mrand48
+_munmap
+_nan
+_nanf
+_nanl
+_nanosleep
+_nanosleep$NOCANCEL
+_new_printf_comp
+_new_printf_domain
+_newlocale
+_nextwctype
+_nextwctype_l
+_nftw
+_nftw$INODE64
+_nice
+_nl_langinfo
+_nl_langinfo_l
+_notify_cancel
+_notify_check
+_notify_monitor_file
+_notify_post
+_notify_register_check
+_nrand48
+_off32
+_off64
+_offtime
+_open$NOCANCEL
+_opendev
+_opendir
+_opendir$INODE64
+_openpty
+_openx_np
+_optarg
+_opterr
+_optind
+_optopt
+_optreset
+_pathconf
+_pause
+_pause$NOCANCEL
+_pclose
+_perror
+_pipe
+_popen
+_popen$DARWIN_EXTSN
+_posix2time
+_posix_openpt
+_posix_spawn
+_posix_spawn_file_actions_addclose
+_posix_spawn_file_actions_adddup2
+_posix_spawn_file_actions_destroy
+_posix_spawn_file_actions_init
+_posix_spawnattr_destroy
+_posix_spawnattr_init
+_posix_spawnattr_setflags
+_posix_spawnattr_setsigdefault
+_posix_spawnattr_setsigmask
+_posix_spawnp
+_pread$NOCANCEL
+_printf
+_printf_l
+_proc_name
+_pselect
+_pselect$1050
+_pselect$DARWIN_EXTSN
+_pselect$DARWIN_EXTSN$NOCANCEL
+_pselect$NOCANCEL
+_psignal
+_psort
+_psort_b
+_psort_r
+_pthread_get_stackaddr_np
+_pthread_get_stacksize_np
+_pthread_getspecific
+_pthread_key_create
+_pthread_key_init_np
+_pthread_kill
+_pthread_mutex_destroy
+_pthread_mutex_init
+_pthread_mutex_lock
+_pthread_mutex_trylock
+_pthread_mutex_unlock
+_pthread_once
+_pthread_rwlock_destroy
+_pthread_rwlock_rdlock
+_pthread_rwlock_unlock
+_pthread_rwlock_wrlock
+_pthread_self
+_pthread_setspecific
+_pthread_sigmask
+_pthread_testcancel
+_ptsname
+_putc
+_putc_unlocked
+_putchar
+_putchar_unlocked
+_putenv
+_puts
+_pututxline
+_putw
+_putwc
+_putwc_l
+_putwchar
+_putwchar_l
+_pwrite$NOCANCEL
+_qsort
+_qsort_b
+_qsort_r
+_querylocale
+_radixsort
+_raise
+_rand
+_rand_r
+_random
+_rb_tree_count
+_rb_tree_find_node
+_rb_tree_find_node_geq
+_rb_tree_find_node_leq
+_rb_tree_init
+_rb_tree_insert_node
+_rb_tree_iterate
+_rb_tree_remove_node
+_read$NOCANCEL
+_readdir
+_readdir$INODE64
+_readdir_r
+_readdir_r$INODE64
+_readlink
+_readpassphrase
+_realloc
+_reallocf
+_realpath
+_realpath$DARWIN_EXTSN
+_recv
+_recv$NOCANCEL
+_regcomp
+_regcomp_l
+_regerror
+_regexec
+_regfree
+_register_printf_domain_function
+_register_printf_domain_render_std
+_regncomp
+_regncomp_l
+_regnexec
+_regwcomp
+_regwcomp_l
+_regwexec
+_regwncomp
+_regwncomp_l
+_regwnexec
+_remove
+_remque
+_rewind
+_rewinddir
+_rewinddir$INODE64
+_rindex
+_rmdir
+_sbrk
+_scandir
+_scandir$INODE64
+_scandir_b
+_scandir_b$INODE64
+_scanf
+_scanf_l
+_seed48
+_seekdir
+_seekdir$INODE64
+_select
+_select$1050
+_select$DARWIN_EXTSN
+_select$DARWIN_EXTSN$NOCANCEL
+_select$NOCANCEL
+_semaphore_create
+_send
+_send$NOCANCEL
+_setattrlist
+_setbuf
+_setbuffer
+_setenv
+_sethostid
+_sethostname
+_setinvalidrune
+_setipv4sourcefilter
+_setitimer
+_setkey
+_setlinebuf
+_setlocale
+_setlogin
+_setmode
+_setpgid
+_setpgrp
+_setpriority
+_setprogname
+_setregid
+_setreuid
+_setrgid
+_setrlimit
+_setruid
+_setrunelocale
+_setsid
+_setsockopt
+_setsourcefilter
+_setstate
+_settimeofday
+_setttyent
+_setusershell
+_setutxent
+_setutxent_wtmp
+_setvbuf
+_sigaction
+_sigaddset
+_sigaltstack
+_sigblock
+_sigdelset
+_sigemptyset
+_sigfillset
+_sighold
+_sigignore
+_siginterrupt
+_sigismember
+_signal
+_sigpause
+_sigpause$NOCANCEL
+_sigprocmask
+_sigrelse
+_sigset
+_sigsetmask
+_sigsuspend
+_sigsuspend$NOCANCEL
+_sigvec
+_skip
+_sl_add
+_sl_find
+_sl_free
+_sl_init
+_sleep
+_sleep$NOCANCEL
+_snprintf
+_snprintf_l
+_sockatmark
+_socket
+_socketpair
+_spin_lock
+_spin_unlock
+_sprintf
+_sprintf_l
+_sradixsort
+_srand
+_srand48
+_sranddev
+_srandom
+_srandomdev
+_sscanf
+_sscanf_l
+_stat
+_stat$INODE64
+_statfs$INODE64
+_statvfs
+_statx64_np
+_statx_np
+_statx_np$INODE64
+_stpcpy
+_stpncpy
+_strcasecmp
+_strcasecmp_l
+_strcasestr
+_strcasestr_l
+_strcat
+_strchr
+_strcmp
+_strcoll
+_strcoll_l
+_strcpy
+_strcspn
+_strdup
+_strerror
+_strerror_r
+_strfmon
+_strfmon_l
+_strftime
+_strftime_l
+_strlcat
+_strlcpy
+_strlen
+_strmode
+_strncasecmp
+_strncasecmp_l
+_strncat
+_strncmp
+_strncpy
+_strndup
+_strnlen
+_strnstr
+_strpbrk
+_strptime
+_strptime_l
+_strrchr
+_strsep
+_strsignal
+_strspn
+_strstr
+_strtod
+_strtod_l
+_strtof
+_strtof_l
+_strtofflags
+_strtoimax
+_strtoimax_l
+_strtok
+_strtok_r
+_strtol
+_strtol_l
+_strtold
+_strtold_l
+_strtoll
+_strtoll_l
+_strtoq
+_strtoq_l
+_strtoul
+_strtoul_l
+_strtoull
+_strtoull_l
+_strtoumax
+_strtoumax_l
+_strtouq
+_strtouq_l
+_strunvis
+_strunvisx
+_strvis
+_strvisx
+_strxfrm
+_strxfrm_l
+_suboptarg
+_swab
+_swprintf
+_swprintf_l
+_swscanf
+_swscanf_l
+_sxprintf
+_sxprintf_exec
+_sync_volume_np
+_sys_errlist
+_sys_nerr
+_sys_siglist
+_sys_signame
+_sysconf
+_sysctl
+_sysctlbyname
+_sysctlnametomib
+_syslog
+_system
+_system$NOCANCEL
+_task_set_special_port
+_tcdrain
+_tcdrain$NOCANCEL
+_tcflow
+_tcflush
+_tcgetattr
+_tcgetpgrp
+_tcgetsid
+_tcsendbreak
+_tcsetattr
+_tcsetpgrp
+_tdelete
+_telldir
+_telldir$INODE64
+_tempnam
+_tfind
+_thread_stack_pcs
+_time
+_time2posix
+_timegm
+_timelocal
+_timeoff
+_times
+_timezone
+_tmpfile
+_tmpnam
+_toascii
+_tolower
+_tolower_l
+_toupper
+_toupper_l
+_towctrans
+_towctrans_l
+_towlower
+_towlower_l
+_towupper
+_towupper_l
+_tsearch
+_ttyname
+_ttyname_r
+_ttyslot
+_twalk
+_tzname
+_tzset
+_tzsetwall
+_ualarm
+_ulimit
+_umask
+_umaskx_np
+_uname
+_ungetc
+_ungetwc
+_ungetwc_l
+_unlink
+_unlockpt
+_unsetenv
+_unvis
+_uselocale
+_usleep
+_usleep$NOCANCEL
+_utime
+_utimes
+_utmpxname
+_uuid_clear
+_uuid_compare
+_uuid_copy
+_uuid_generate
+_uuid_generate_random
+_uuid_generate_time
+_uuid_is_null
+_uuid_pack
+_uuid_parse
+_uuid_unpack
+_uuid_unparse
+_uuid_unparse_lower
+_uuid_unparse_upper
+_vasprintf
+_vasprintf_l
+_vasxprintf
+_vasxprintf_exec
+_vdprintf
+_vdprintf_l
+_vdxprintf
+_vdxprintf_exec
+_verr
+_verrc
+_verrx
+_vfprintf
+_vfprintf_l
+_vfscanf
+_vfscanf_l
+_vfwprintf
+_vfwprintf_l
+_vfwscanf
+_vfwscanf_l
+_vfxprintf
+_vfxprintf_exec
+_vis
+_vm_allocate
+_vprintf
+_vprintf_l
+_vscanf
+_vscanf_l
+_vsnprintf
+_vsnprintf_l
+_vsprintf
+_vsprintf_l
+_vsscanf
+_vsscanf_l
+_vswprintf
+_vswprintf_l
+_vswscanf
+_vswscanf_l
+_vsxprintf
+_vsxprintf_exec
+_vwarn
+_vwarnc
+_vwarnx
+_vwprintf
+_vwprintf_l
+_vwscanf
+_vwscanf_l
+_vxprintf
+_vxprintf_exec
+_wait
+_wait$NOCANCEL
+_wait3
+_wait4
+_waitpid
+_waitpid$NOCANCEL
+_warn
+_warnc
+_warnx
+_wcpcpy
+_wcpncpy
+_wcrtomb
+_wcrtomb_l
+_wcscasecmp
+_wcscasecmp_l
+_wcscat
+_wcschr
+_wcscmp
+_wcscoll
+_wcscoll_l
+_wcscpy
+_wcscspn
+_wcsdup
+_wcsftime
+_wcsftime_l
+_wcslcat
+_wcslcpy
+_wcslen
+_wcsncasecmp
+_wcsncasecmp_l
+_wcsncat
+_wcsncmp
+_wcsncpy
+_wcsnlen
+_wcsnrtombs
+_wcsnrtombs_l
+_wcspbrk
+_wcsrchr
+_wcsrtombs
+_wcsrtombs_l
+_wcsspn
+_wcsstr
+_wcstod
+_wcstod_l
+_wcstof
+_wcstof_l
+_wcstoimax
+_wcstoimax_l
+_wcstok
+_wcstol
+_wcstol_l
+_wcstold
+_wcstold_l
+_wcstoll
+_wcstoll_l
+_wcstombs
+_wcstombs_l
+_wcstoul
+_wcstoul_l
+_wcstoull
+_wcstoull_l
+_wcstoumax
+_wcstoumax_l
+_wcswidth
+_wcswidth_l
+_wcsxfrm
+_wcsxfrm_l
+_wctob
+_wctob_l
+_wctomb
+_wctomb_l
+_wctrans
+_wctrans_l
+_wctype
+_wctype_l
+_wcwidth
+_wcwidth_l
+_wmemchr
+_wmemcmp
+_wmemcpy
+_wmemmove
+_wmemset
+_wordexp
+_wordfree
+_wprintf
+_wprintf_l
+_write$NOCANCEL
+_writev$NOCANCEL
+_wscanf
+_wscanf_l
+_wtmpxname
+_xprintf
+_xprintf_exec
+dyld_stub_binder
+mcount
diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libsystem/system_kernel_symbols b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/system_kernel_symbols
new file mode 100644
index 000000000000..9d53dea70253
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/system_kernel_symbols
@@ -0,0 +1,929 @@
+_NDR_record
+_____old_semwait_signal_nocancel
+_____sigwait_nocancel
+____kernelVersionNumber
+____kernelVersionString
+___accept
+___accept_nocancel
+___access_extended
+___aio_suspend_nocancel
+___bind
+___bsdthread_create
+___bsdthread_register
+___bsdthread_terminate
+___carbon_delete
+___chmod
+___chmod_extended
+___chud
+___close_nocancel
+___commpage_gettimeofday
+___connect
+___connect_nocancel
+___copyfile
+___delete
+___disable_threadsignal
+___error
+___exit
+___fchmod
+___fchmod_extended
+___fcntl
+___fcntl_nocancel
+___fork
+___fsgetpath
+___fstat64_extended
+___fstat_extended
+___fsync_nocancel
+___get_remove_counter
+___getattrlist
+___getdirentries64
+___gethostuuid
+___getlcid
+___getlogin
+___getpeername
+___getpid
+___getrlimit
+___getsgroups
+___getsockname
+___gettid
+___gettimeofday
+___getwgroups
+___guarded_open_np
+___identitysvc
+___inc_remove_counter
+___initgroups
+___ioctl
+___iopolicysys
+___kdebug_trace
+___kernelVersionNumber
+___kernelVersionString
+___kill
+___lchown
+___libkernel_init
+___listen
+___lseek
+___lstat64_extended
+___lstat_extended
+___mac_execve
+___mac_get_fd
+___mac_get_file
+___mac_get_lcid
+___mac_get_lctx
+___mac_get_link
+___mac_get_mount
+___mac_get_pid
+___mac_get_proc
+___mac_getfsstat
+___mac_mount
+___mac_set_fd
+___mac_set_file
+___mac_set_lctx
+___mac_set_link
+___mac_set_proc
+___mac_syscall
+___mkdir_extended
+___mkfifo_extended
+___mmap
+___mprotect
+___msgctl
+___msgrcv_nocancel
+___msgsnd_nocancel
+___msgsys
+___msync
+___msync_nocancel
+___munmap
+___old_semwait_signal
+___open
+___open_dprotected_np
+___open_extended
+___open_nocancel
+___pipe
+___poll_nocancel
+___posix_spawn
+___pread_nocancel
+___proc_info
+___process_policy
+___psynch_cvbroad
+___psynch_cvclrprepost
+___psynch_cvsignal
+___psynch_cvwait
+___psynch_mutexdrop
+___psynch_mutexwait
+___psynch_rw_downgrade
+___psynch_rw_longrdlock
+___psynch_rw_rdlock
+___psynch_rw_unlock
+___psynch_rw_unlock2
+___psynch_rw_upgrade
+___psynch_rw_wrlock
+___psynch_rw_yieldwrlock
+___pthread_canceled
+___pthread_chdir
+___pthread_fchdir
+___pthread_kill
+___pthread_markcancel
+___pthread_sigmask
+___ptrace
+___pwrite_nocancel
+___read_nocancel
+___readv_nocancel
+___recvfrom
+___recvfrom_nocancel
+___recvmsg
+___recvmsg_nocancel
+___rename
+___rmdir
+___sandbox_me
+___sandbox_mm
+___sandbox_ms
+___sandbox_msp
+___select
+___select_nocancel
+___sem_open
+___sem_wait_nocancel
+___semctl
+___semsys
+___semwait_signal
+___semwait_signal_nocancel
+___sendmsg
+___sendmsg_nocancel
+___sendto
+___sendto_nocancel
+___setattrlist
+___setlcid
+___setlogin
+___setregid
+___setreuid
+___setrlimit
+___setsgroups
+___settid
+___settid_with_pid
+___settimeofday
+___setwgroups
+___shared_region_check_np
+___shared_region_map_and_slide_np
+___shm_open
+___shmctl
+___shmsys
+___sigaction
+___sigaltstack
+___sigreturn
+___sigsuspend
+___sigsuspend_nocancel
+___sigwait
+___socketpair
+___stack_snapshot
+___stat64_extended
+___stat_extended
+___syscall
+___syscall_logger
+___sysctl
+___telemetry
+___thread_selfid
+___umask_extended
+___unlink
+___vfork
+___wait4
+___wait4_nocancel
+___waitid_nocancel
+___workq_kernreturn
+___workq_open
+___write_nocancel
+___writev_nocancel
+__cpu_capabilities
+__cpu_has_altivec
+__exit
+__get_cpu_capabilities
+__getprivatesystemidentifier
+__host_page_size
+__init_cpu_capabilities
+__kernelrpc_mach_port_allocate
+__kernelrpc_mach_port_allocate_full
+__kernelrpc_mach_port_allocate_name
+__kernelrpc_mach_port_allocate_qos
+__kernelrpc_mach_port_allocate_trap
+__kernelrpc_mach_port_construct
+__kernelrpc_mach_port_construct_trap
+__kernelrpc_mach_port_deallocate
+__kernelrpc_mach_port_deallocate_trap
+__kernelrpc_mach_port_destroy
+__kernelrpc_mach_port_destroy_trap
+__kernelrpc_mach_port_destruct
+__kernelrpc_mach_port_destruct_trap
+__kernelrpc_mach_port_dnrequest_info
+__kernelrpc_mach_port_extract_member
+__kernelrpc_mach_port_extract_member_trap
+__kernelrpc_mach_port_extract_right
+__kernelrpc_mach_port_get_attributes
+__kernelrpc_mach_port_get_context
+__kernelrpc_mach_port_get_refs
+__kernelrpc_mach_port_get_set_status
+__kernelrpc_mach_port_get_srights
+__kernelrpc_mach_port_guard
+__kernelrpc_mach_port_guard_trap
+__kernelrpc_mach_port_insert_member
+__kernelrpc_mach_port_insert_member_trap
+__kernelrpc_mach_port_insert_right
+__kernelrpc_mach_port_insert_right_trap
+__kernelrpc_mach_port_kernel_object
+__kernelrpc_mach_port_kobject
+__kernelrpc_mach_port_mod_refs
+__kernelrpc_mach_port_mod_refs_trap
+__kernelrpc_mach_port_move_member
+__kernelrpc_mach_port_move_member_trap
+__kernelrpc_mach_port_names
+__kernelrpc_mach_port_peek
+__kernelrpc_mach_port_rename
+__kernelrpc_mach_port_request_notification
+__kernelrpc_mach_port_set_attributes
+__kernelrpc_mach_port_set_context
+__kernelrpc_mach_port_set_mscount
+__kernelrpc_mach_port_set_seqno
+__kernelrpc_mach_port_space_info
+__kernelrpc_mach_port_type
+__kernelrpc_mach_port_unguard
+__kernelrpc_mach_port_unguard_trap
+__kernelrpc_mach_vm_allocate
+__kernelrpc_mach_vm_allocate_trap
+__kernelrpc_mach_vm_deallocate
+__kernelrpc_mach_vm_deallocate_trap
+__kernelrpc_mach_vm_map
+__kernelrpc_mach_vm_map_trap
+__kernelrpc_mach_vm_protect
+__kernelrpc_mach_vm_protect_trap
+__kernelrpc_mach_vm_read
+__kernelrpc_mach_vm_remap
+__kernelrpc_task_set_port_space
+__kernelrpc_vm_map
+__kernelrpc_vm_read
+__kernelrpc_vm_remap
+__mach_errors
+__mach_fork_child
+__mach_snprintf
+__mach_vsnprintf
+__os_alloc_once_table
+__register_gethostuuid_callback
+_accept
+_accept$NOCANCEL
+_access
+_accessx_np
+_acct
+_act_get_state
+_act_set_state
+_adjtime
+_aio_cancel
+_aio_error
+_aio_fsync
+_aio_read
+_aio_return
+_aio_suspend
+_aio_suspend$NOCANCEL
+_aio_write
+_audit
+_audit_session_join
+_audit_session_port
+_audit_session_self
+_auditctl
+_auditon
+_bind
+_bootstrap_port
+_cerror
+_cerror_nocancel
+_change_fdguard_np
+_chdir
+_chflags
+_chmod
+_chown
+_chroot
+_clock_alarm
+_clock_alarm_reply
+_clock_get_attributes
+_clock_get_time
+_clock_set_attributes
+_clock_set_time
+_clock_sleep
+_clock_sleep_trap
+_close
+_close$NOCANCEL
+_connect
+_connect$NOCANCEL
+_connectx
+_csops
+_csops_audittoken
+_disconnectx
+_dup
+_dup2
+_errno
+_etap_trace_thread
+_exc_server
+_exc_server_routine
+_exception_raise
+_exception_raise_state
+_exception_raise_state_identity
+_exchangedata
+_execve
+_fchdir
+_fchflags
+_fchmod
+_fchown
+_fcntl
+_fcntl$NOCANCEL
+_fdatasync
+_ffsctl
+_fgetattrlist
+_fgetxattr
+_fhopen
+_fileport_makefd
+_fileport_makeport
+_flistxattr
+_flock
+_fpathconf
+_fremovexattr
+_fsctl
+_fsetattrlist
+_fsetxattr
+_fstat
+_fstat$INODE64
+_fstat64
+_fstatfs
+_fstatfs$INODE64
+_fstatfs64
+_fsync
+_fsync$NOCANCEL
+_ftruncate
+_futimes
+_get_dp_control_port
+_getattrlist
+_getaudit
+_getaudit_addr
+_getauid
+_getdirentries
+_getdirentriesattr
+_getdtablesize
+_getegid
+_geteuid
+_getfh
+_getfsstat
+_getfsstat$INODE64
+_getfsstat64
+_getgid
+_getgroups
+_gethostuuid
+_getiopolicy_np
+_getitimer
+_getpeername
+_getpgid
+_getpgrp
+_getpid
+_getppid
+_getpriority
+_getrlimit
+_getrusage
+_getsgroups_np
+_getsid
+_getsockname
+_getsockopt
+_getuid
+_getwgroups_np
+_getxattr
+_guarded_close_np
+_guarded_kqueue_np
+_guarded_open_np
+_host_default_memory_manager
+_host_get_UNDServer
+_host_get_boot_info
+_host_get_clock_control
+_host_get_clock_service
+_host_get_exception_ports
+_host_get_io_master
+_host_get_special_port
+_host_info
+_host_kernel_version
+_host_lockgroup_info
+_host_page_size
+_host_priv_statistics
+_host_processor_info
+_host_processor_set_priv
+_host_processor_sets
+_host_processors
+_host_reboot
+_host_request_notification
+_host_security_create_task_token
+_host_security_set_task_token
+_host_self
+_host_self_trap
+_host_set_UNDServer
+_host_set_exception_ports
+_host_set_special_port
+_host_statistics
+_host_statistics64
+_host_swap_exception_ports
+_host_virtual_physical_table_info
+_host_zone_info
+_i386_get_ldt
+_i386_set_ldt
+_important_boost_assertion_token
+_internal_catch_exc_subsystem
+_ioctl
+_issetugid
+_kas_info
+_kevent
+_kevent64
+_kext_request
+_kill
+_kmod_control
+_kmod_create
+_kmod_destroy
+_kmod_get_info
+_kqueue
+_lchown
+_ledger
+_link
+_lio_listio
+_listen
+_listxattr
+_lock_acquire
+_lock_handoff
+_lock_handoff_accept
+_lock_make_stable
+_lock_release
+_lock_set_create
+_lock_set_destroy
+_lock_try
+_lseek
+_lstat
+_lstat$INODE64
+_lstat64
+_mach_absolute_time
+_mach_error
+_mach_error_full_diag
+_mach_error_string
+_mach_error_type
+_mach_host_self
+_mach_init
+_mach_make_memory_entry
+_mach_make_memory_entry_64
+_mach_memory_object_memory_entry
+_mach_memory_object_memory_entry_64
+_mach_msg
+_mach_msg_destroy
+_mach_msg_overwrite
+_mach_msg_overwrite_trap
+_mach_msg_receive
+_mach_msg_send
+_mach_msg_server
+_mach_msg_server_importance
+_mach_msg_server_once
+_mach_msg_trap
+_mach_notify_dead_name
+_mach_notify_no_senders
+_mach_notify_port_deleted
+_mach_notify_port_destroyed
+_mach_notify_send_once
+_mach_port_allocate
+_mach_port_allocate_full
+_mach_port_allocate_name
+_mach_port_allocate_qos
+_mach_port_construct
+_mach_port_deallocate
+_mach_port_destroy
+_mach_port_destruct
+_mach_port_dnrequest_info
+_mach_port_extract_member
+_mach_port_extract_right
+_mach_port_get_attributes
+_mach_port_get_context
+_mach_port_get_refs
+_mach_port_get_set_status
+_mach_port_get_srights
+_mach_port_guard
+_mach_port_insert_member
+_mach_port_insert_right
+_mach_port_kernel_object
+_mach_port_kobject
+_mach_port_mod_refs
+_mach_port_move_member
+_mach_port_names
+_mach_port_peek
+_mach_port_rename
+_mach_port_request_notification
+_mach_port_set_attributes
+_mach_port_set_context
+_mach_port_set_mscount
+_mach_port_set_seqno
+_mach_port_space_info
+_mach_port_type
+_mach_port_unguard
+_mach_ports_lookup
+_mach_ports_register
+_mach_reply_port
+_mach_task_self
+_mach_task_self_
+_mach_thread_self
+_mach_timebase_info
+_mach_vm_allocate
+_mach_vm_behavior_set
+_mach_vm_copy
+_mach_vm_deallocate
+_mach_vm_inherit
+_mach_vm_machine_attribute
+_mach_vm_map
+_mach_vm_msync
+_mach_vm_page_info
+_mach_vm_page_query
+_mach_vm_protect
+_mach_vm_purgable_control
+_mach_vm_read
+_mach_vm_read_list
+_mach_vm_read_overwrite
+_mach_vm_region
+_mach_vm_region_recurse
+_mach_vm_remap
+_mach_vm_wire
+_mach_vm_write
+_mach_wait_until
+_mach_zone_force_gc
+_mach_zone_info
+_macx_backing_store_recovery
+_macx_backing_store_suspend
+_macx_swapoff
+_macx_swapon
+_macx_triggers
+_madvise
+_memorystatus_control
+_memorystatus_get_level
+_mig_allocate
+_mig_dealloc_reply_port
+_mig_deallocate
+_mig_get_reply_port
+_mig_put_reply_port
+_mig_reply_setup
+_mig_strncpy
+_mincore
+_minherit
+_mk_timer_arm
+_mk_timer_cancel
+_mk_timer_create
+_mk_timer_destroy
+_mkdir
+_mkfifo
+_mknod
+_mlock
+_mlockall
+_mmap
+_modwatch
+_mount
+_mprotect
+_msg_receive
+_msg_rpc
+_msg_send
+_msgctl
+_msgget
+_msgrcv
+_msgrcv$NOCANCEL
+_msgsnd
+_msgsnd$NOCANCEL
+_msgsys
+_msync
+_msync$NOCANCEL
+_munlock
+_munlockall
+_munmap
+_netname_check_in
+_netname_check_out
+_netname_look_up
+_netname_version
+_nfsclnt
+_nfssvc
+_non_boost_assertion_token
+_normal_boost_assertion_token
+_open
+_open$NOCANCEL
+_open_dprotected_np
+_panic
+_panic_init
+_pathconf
+_peeloff
+_pid_for_task
+_pid_resume
+_pid_suspend
+_pipe
+_poll
+_poll$NOCANCEL
+_port_obj_init
+_port_obj_table
+_port_obj_table_size
+_posix_madvise
+_posix_spawn
+_posix_spawn_file_actions_addclose
+_posix_spawn_file_actions_adddup2
+_posix_spawn_file_actions_addinherit_np
+_posix_spawn_file_actions_addopen
+_posix_spawn_file_actions_destroy
+_posix_spawn_file_actions_init
+_posix_spawnattr_destroy
+_posix_spawnattr_getbinpref_np
+_posix_spawnattr_getcpumonitor
+_posix_spawnattr_getflags
+_posix_spawnattr_getmacpolicyinfo_np
+_posix_spawnattr_getpcontrol_np
+_posix_spawnattr_getpgroup
+_posix_spawnattr_getprocesstype_np
+_posix_spawnattr_getsigdefault
+_posix_spawnattr_getsigmask
+_posix_spawnattr_init
+_posix_spawnattr_set_importancewatch_port_np
+_posix_spawnattr_setauditsessionport_np
+_posix_spawnattr_setbinpref_np
+_posix_spawnattr_setcpumonitor
+_posix_spawnattr_setcpumonitor_default
+_posix_spawnattr_setexceptionports_np
+_posix_spawnattr_setflags
+_posix_spawnattr_setmacpolicyinfo_np
+_posix_spawnattr_setpcontrol_np
+_posix_spawnattr_setpgroup
+_posix_spawnattr_setprocesstype_np
+_posix_spawnattr_setsigdefault
+_posix_spawnattr_setsigmask
+_posix_spawnattr_setspecialport_np
+_pread
+_pread$NOCANCEL
+_proc_clear_delayidlesleep
+_proc_clear_vmpressure
+_proc_disable_apptype
+_proc_disable_cpumon
+_proc_disable_wakemon
+_proc_donate_importance_boost
+_proc_enable_apptype
+_proc_get_cpumon_params
+_proc_get_dirty
+_proc_get_wakemon_params
+_proc_importance_assertion_begin_with_msg
+_proc_importance_assertion_complete
+_proc_kmsgbuf
+_proc_libversion
+_proc_listallpids
+_proc_listchildpids
+_proc_listpgrppids
+_proc_listpids
+_proc_listpidspath
+_proc_name
+_proc_pid_rusage
+_proc_pidfdinfo
+_proc_pidfileportinfo
+_proc_pidinfo
+_proc_pidpath
+_proc_regionfilename
+_proc_rlimit_control
+_proc_set_cpumon_defaults
+_proc_set_cpumon_params
+_proc_set_delayidlesleep
+_proc_set_dirty
+_proc_set_owner_vmpressure
+_proc_set_wakemon_defaults
+_proc_set_wakemon_params
+_proc_setpcontrol
+_proc_suppress
+_proc_terminate
+_proc_track_dirty
+_proc_uuid_policy
+_processor_assign
+_processor_control
+_processor_exit
+_processor_get_assignment
+_processor_info
+_processor_set_create
+_processor_set_default
+_processor_set_destroy
+_processor_set_info
+_processor_set_max_priority
+_processor_set_policy_control
+_processor_set_policy_disable
+_processor_set_policy_enable
+_processor_set_stack_usage
+_processor_set_statistics
+_processor_set_tasks
+_processor_set_threads
+_processor_start
+_pthread_getugid_np
+_pthread_setugid_np
+_ptrace
+_pwrite
+_pwrite$NOCANCEL
+_quota
+_quotactl
+_read
+_read$NOCANCEL
+_readlink
+_readv
+_readv$NOCANCEL
+_reboot
+_recvfrom
+_recvfrom$NOCANCEL
+_recvmsg
+_recvmsg$NOCANCEL
+_removexattr
+_rename
+_revoke
+_rmdir
+_searchfs
+_select
+_select$1050
+_select$DARWIN_EXTSN
+_select$DARWIN_EXTSN$NOCANCEL
+_select$NOCANCEL
+_sem_close
+_sem_destroy
+_sem_getvalue
+_sem_init
+_sem_open
+_sem_post
+_sem_trywait
+_sem_unlink
+_sem_wait
+_sem_wait$NOCANCEL
+_semaphore_create
+_semaphore_destroy
+_semaphore_signal
+_semaphore_signal_all
+_semaphore_signal_all_trap
+_semaphore_signal_thread
+_semaphore_signal_thread_trap
+_semaphore_signal_trap
+_semaphore_timedwait
+_semaphore_timedwait_signal
+_semaphore_timedwait_signal_trap
+_semaphore_timedwait_trap
+_semaphore_wait
+_semaphore_wait_signal
+_semaphore_wait_signal_trap
+_semaphore_wait_trap
+_semctl
+_semget
+_semop
+_semsys
+_sendfile
+_sendmsg
+_sendmsg$NOCANCEL
+_sendto
+_sendto$NOCANCEL
+_set_dp_control_port
+_setattrlist
+_setaudit
+_setaudit_addr
+_setauid
+_setegid
+_seteuid
+_setgid
+_setgroups
+_setiopolicy_np
+_setitimer
+_setpgid
+_setpriority
+_setprivexec
+_setquota
+_setregid
+_setreuid
+_setrlimit
+_setsgroups_np
+_setsid
+_setsockopt
+_setuid
+_setwgroups_np
+_setxattr
+_shm_open
+_shm_unlink
+_shmat
+_shmctl
+_shmdt
+_shmget
+_shmsys
+_shutdown
+_sigpending
+_sigprocmask
+_sigsuspend
+_sigsuspend$NOCANCEL
+_socket
+_socket_delegate
+_socketpair
+_stat
+_stat$INODE64
+_stat64
+_statfs
+_statfs$INODE64
+_statfs64
+_swapon
+_swtch
+_swtch_pri
+_symlink
+_sync
+_syscall
+_syscall_thread_switch
+_system_override
+_task_assign
+_task_assign_default
+_task_create
+_task_for_pid
+_task_get_assignment
+_task_get_emulation_vector
+_task_get_exception_ports
+_task_get_special_port
+_task_get_state
+_task_info
+_task_name_for_pid
+_task_policy
+_task_policy_get
+_task_policy_set
+_task_purgable_info
+_task_resume
+_task_resume2
+_task_sample
+_task_self_
+_task_self_trap
+_task_set_emulation
+_task_set_emulation_vector
+_task_set_exception_ports
+_task_set_info
+_task_set_phys_footprint_limit
+_task_set_policy
+_task_set_port_space
+_task_set_ras_pc
+_task_set_special_port
+_task_set_state
+_task_suspend
+_task_suspend2
+_task_swap_exception_ports
+_task_terminate
+_task_threads
+_task_zone_info
+_thread_abort
+_thread_abort_safely
+_thread_assign
+_thread_assign_default
+_thread_create
+_thread_create_running
+_thread_depress_abort
+_thread_get_assignment
+_thread_get_exception_ports
+_thread_get_special_port
+_thread_get_state
+_thread_info
+_thread_policy
+_thread_policy_get
+_thread_policy_set
+_thread_resume
+_thread_sample
+_thread_self_trap
+_thread_set_exception_ports
+_thread_set_policy
+_thread_set_special_port
+_thread_set_state
+_thread_suspend
+_thread_swap_exception_ports
+_thread_switch
+_thread_terminate
+_thread_wire
+_truncate
+_umask
+_undelete
+_unlink
+_unmount
+_utimes
+_vfork
+_vfs_purge
+_vm_allocate
+_vm_allocate_cpm
+_vm_behavior_set
+_vm_copy
+_vm_deallocate
+_vm_inherit
+_vm_kernel_page_mask
+_vm_kernel_page_shift
+_vm_kernel_page_size
+_vm_machine_attribute
+_vm_map
+_vm_map_page_query
+_vm_msync
+_vm_page_mask
+_vm_page_shift
+_vm_page_size
+_vm_pressure_monitor
+_vm_protect
+_vm_purgable_control
+_vm_read
+_vm_read_list
+_vm_read_overwrite
+_vm_region_64
+_vm_region_recurse_64
+_vm_remap
+_vm_wire
+_vm_write
+_vprintf_stderr_func
+_wait4
+_waitevent
+_waitid
+_waitid$NOCANCEL
+_watchevent
+_write
+_write$NOCANCEL
+_writev
+_writev$NOCANCEL
diff --git a/pkgs/os-specific/darwin/apple-source-releases/Security/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Security/default.nix
new file mode 100644
index 000000000000..f09842630fdb
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/Security/default.nix
@@ -0,0 +1,116 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  __propagatedImpureHostDeps = [
+    "/System/Library/Frameworks/Security.framework/Security"
+    "/System/Library/Frameworks/Security.framework/Resources"
+    "/System/Library/Frameworks/Security.framework/PlugIns"
+    "/System/Library/Frameworks/Security.framework/XPCServices"
+    "/System/Library/Frameworks/Security.framework/Versions"
+  ];
+
+  installPhase = ''
+    ###### IMPURITIES
+    mkdir -p $out/Library/Frameworks/Security.framework
+    pushd $out/Library/Frameworks/Security.framework
+    ln -s /System/Library/Frameworks/Security.framework/Security
+    ln -s /System/Library/Frameworks/Security.framework/Resources
+    ln -s /System/Library/Frameworks/Security.framework/PlugIns
+    ln -s /System/Library/Frameworks/Security.framework/XPCServices
+    popd
+
+    ###### HEADERS
+
+    export dest=$out/Library/Frameworks/Security.framework/Headers
+    mkdir -p $dest
+
+    cp libsecurity_asn1/lib/SecAsn1Coder.h     $dest
+    cp libsecurity_asn1/lib/SecAsn1Templates.h $dest
+    cp libsecurity_asn1/lib/SecAsn1Types.h     $dest
+    cp libsecurity_asn1/lib/oidsalg.h          $dest
+    cp libsecurity_asn1/lib/oidsattr.h         $dest
+
+    cp libsecurity_authorization/lib/AuthSession.h         $dest
+    cp libsecurity_authorization/lib/Authorization.h       $dest
+    cp libsecurity_authorization/lib/AuthorizationDB.h     $dest
+    cp libsecurity_authorization/lib/AuthorizationPlugin.h $dest
+    cp libsecurity_authorization/lib/AuthorizationTags.h   $dest
+
+    cp libsecurity_cms/lib/CMSDecoder.h $dest
+    cp libsecurity_cms/lib/CMSEncoder.h $dest
+
+    cp libsecurity_codesigning/lib/CSCommon.h       $dest
+    cp libsecurity_codesigning/lib/CodeSigning.h    $dest
+    cp libsecurity_codesigning/lib/SecCode.h        $dest
+    cp libsecurity_codesigning/lib/SecCodeHost.h    $dest
+    cp libsecurity_codesigning/lib/SecRequirement.h $dest
+    cp libsecurity_codesigning/lib/SecStaticCode.h  $dest
+    cp libsecurity_codesigning/lib/SecTask.h        $dest
+
+    cp libsecurity_cssm/lib/certextensions.h $dest
+    cp libsecurity_cssm/lib/cssm.h           $dest
+    cp libsecurity_cssm/lib/cssmaci.h        $dest
+    cp libsecurity_cssm/lib/cssmapi.h        $dest
+    cp libsecurity_cssm/lib/cssmapple.h      $dest
+    cp libsecurity_cssm/lib/cssmcli.h        $dest
+    cp libsecurity_cssm/lib/cssmconfig.h     $dest
+    cp libsecurity_cssm/lib/cssmcspi.h       $dest
+    cp libsecurity_cssm/lib/cssmdli.h        $dest
+    cp libsecurity_cssm/lib/cssmerr.h        $dest
+    cp libsecurity_cssm/lib/cssmkrapi.h      $dest
+    cp libsecurity_cssm/lib/cssmkrspi.h      $dest
+    cp libsecurity_cssm/lib/cssmspi.h        $dest
+    cp libsecurity_cssm/lib/cssmtpi.h        $dest
+    cp libsecurity_cssm/lib/cssmtype.h       $dest
+    cp libsecurity_cssm/lib/eisl.h           $dest
+    cp libsecurity_cssm/lib/emmspi.h         $dest
+    cp libsecurity_cssm/lib/emmtype.h        $dest
+    cp libsecurity_cssm/lib/oidsbase.h       $dest
+    cp libsecurity_cssm/lib/oidscert.h       $dest
+    cp libsecurity_cssm/lib/oidscrl.h        $dest
+    cp libsecurity_cssm/lib/x509defs.h       $dest
+
+    cp libsecurity_keychain/lib/SecACL.h                $dest
+    cp libsecurity_keychain/lib/SecAccess.h             $dest
+    cp libsecurity_keychain/lib/SecBase.h               $dest
+    cp libsecurity_keychain/lib/SecCertificate.h        $dest
+    cp libsecurity_keychain/lib/SecCertificatePriv.h    $dest # Private
+    cp libsecurity_keychain/lib/SecCertificateOIDs.h    $dest
+    cp libsecurity_keychain/lib/SecIdentity.h           $dest
+    cp libsecurity_keychain/lib/SecIdentitySearch.h     $dest
+    cp libsecurity_keychain/lib/SecImportExport.h       $dest
+    cp libsecurity_keychain/lib/SecItem.h               $dest
+    cp libsecurity_keychain/lib/SecKey.h                $dest
+    cp libsecurity_keychain/lib/SecKeychain.h           $dest
+    cp libsecurity_keychain/lib/SecKeychainItem.h       $dest
+    cp libsecurity_keychain/lib/SecKeychainSearch.h     $dest
+    cp libsecurity_keychain/lib/SecPolicy.h             $dest
+    cp libsecurity_keychain/lib/SecPolicySearch.h       $dest
+    cp libsecurity_keychain/lib/SecRandom.h             $dest
+    cp libsecurity_keychain/lib/SecTrust.h              $dest
+    cp libsecurity_keychain/lib/SecTrustSettings.h      $dest
+    cp libsecurity_keychain/lib/SecTrustedApplication.h $dest
+    cp libsecurity_keychain/lib/Security.h              $dest
+
+    cp libsecurity_manifest/lib/SecureDownload.h $dest
+
+    cp libsecurity_mds/lib/mds.h        $dest
+    cp libsecurity_mds/lib/mds_schema.h $dest
+
+    cp libsecurity_ssl/lib/CipherSuite.h     $dest
+    cp libsecurity_ssl/lib/SecureTransport.h $dest
+
+    cp libsecurity_transform/lib/SecCustomTransform.h        $dest
+    cp libsecurity_transform/lib/SecDecodeTransform.h        $dest
+    cp libsecurity_transform/lib/SecDigestTransform.h        $dest
+    cp libsecurity_transform/lib/SecEncodeTransform.h        $dest
+    cp libsecurity_transform/lib/SecEncryptTransform.h       $dest
+    cp libsecurity_transform/lib/SecReadTransform.h          $dest
+    cp libsecurity_transform/lib/SecSignVerifyTransform.h    $dest
+    cp libsecurity_transform/lib/SecTransform.h              $dest
+    cp libsecurity_transform/lib/SecTransformReadTransform.h $dest
+
+  '';
+}
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
new file mode 100644
index 000000000000..db467254f171
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, appleDerivation, version }:
+
+appleDerivation {
+  # Will override the name until we provide all of adv_cmds
+  name = "ps-${version}";
+
+  buildPhase = ''
+    cd ps
+    cc -Os -Wall -I. -c -o fmt.o fmt.c
+    cc -Os -Wall -I. -c -o keyword.o keyword.c
+    cc -Os -Wall -I. -c -o nlist.o nlist.c
+    cc -Os -Wall -I. -c -o print.o print.c
+    cc -Os -Wall -I. -c -o ps.o ps.c
+    cc -Os -Wall -I. -c -o tasks.o tasks.c
+    cc -o ps fmt.o keyword.o nlist.o print.o ps.o tasks.o
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin $out/share/man/man1
+
+    cp ps   $out/bin/ps
+    cp ps.1 $out/share/man/man1
+  '';
+
+
+  meta = {
+    platforms = stdenv.lib.platforms.darwin;
+    maintainers = with stdenv.lib.maintainers; [ gridaphobe ];
+  };
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/architecture/default.nix b/pkgs/os-specific/darwin/apple-source-releases/architecture/default.nix
new file mode 100644
index 000000000000..edb7869269ac
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/architecture/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  postUnpack = ''
+    substituteInPlace $sourceRoot/Makefile \
+      --replace "/usr/include" "/include" \
+      --replace "/usr/bin/" "" \
+      --replace "/bin/" ""
+  '';
+
+  installPhase = ''
+    export DSTROOT=$out
+    make install
+  '';
+
+  meta = with stdenv.lib; {
+    maintainers = with maintainers; [ copumpkin ];
+    platforms   = platforms.darwin;
+    license     = licenses.apsl20;
+  };
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/bootstrap_cmds/default.nix b/pkgs/os-specific/darwin/apple-source-releases/bootstrap_cmds/default.nix
new file mode 100644
index 000000000000..8dce3fd36097
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/bootstrap_cmds/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, appleDerivation, yacc, flex }:
+
+appleDerivation {
+  buildInputs = [ yacc flex ];
+
+  buildPhase = ''
+    cd migcom.tproj
+    yacc -d parser.y
+    flex --header-file=lexxer.yy.h -o lexxer.yy.c lexxer.l
+
+    cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o error.o error.c
+    cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o global.o global.c
+    cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o handler.o header.c
+    cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o header.o header.c
+    cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o mig.o mig.c
+    cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o routine.o routine.c
+    cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o server.o server.c
+    cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o statement.o statement.c
+    cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o string.o string.c
+    cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o type.o type.c
+    cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o user.o user.c
+    cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o utils.o utils.c
+    cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o lexxer.yy.o lexxer.yy.c
+    cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o y.tab.o y.tab.c
+
+    cc -dead_strip -o migcom error.o global.o header.o mig.o routine.o server.o statement.o string.o type.o user.o utils.o lexxer.yy.o y.tab.o
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin $out/libexec $out/share/man/man1
+
+    chmod +x mig.sh
+    cp mig.sh   $out/bin/mig
+    cp migcom   $out/libexec
+    cp mig.1    $out/share/man/man1
+    cp migcom.1 $out/share/man/man1
+
+    substituteInPlace $out/bin/mig \
+      --replace 'arch=`/usr/bin/arch`' 'arch=i386' \
+      --replace '/usr/bin/' "" \
+      --replace '/bin/rmdir' "rmdir" \
+      --replace 'C=''${MIGCC}' "C=cc"
+  '';
+}
\ No newline at end of file
diff --git a/pkgs/os-specific/darwin/apple-source-releases/configd/default.nix b/pkgs/os-specific/darwin/apple-source-releases/configd/default.nix
new file mode 100644
index 000000000000..3427081bfaa8
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/configd/default.nix
@@ -0,0 +1,205 @@
+{ stdenv, appleDerivation, launchd, bootstrap_cmds, xnu, ppp, IOKit, eap8021x, Security }:
+
+appleDerivation {
+  buildInputs = [ launchd bootstrap_cmds xnu ppp IOKit eap8021x ];
+
+  propagatedBuildInputs = [ Security ];
+
+  patchPhase = ''
+    substituteInPlace SystemConfiguration.fproj/SCNetworkReachabilityInternal.h \
+      --replace '#include <xpc/xpc.h>' ""
+
+    substituteInPlace SystemConfiguration.fproj/SCNetworkReachability.c \
+      --replace ''$'#define\tHAVE_VPN_STATUS' ""
+
+    substituteInPlace SystemConfiguration.fproj/reachability/SCNetworkReachabilityServer_client.c \
+      --replace '#include <xpc/xpc.h>' '#include "fake_xpc.h"' \
+      --replace '#include <xpc/private.h>' "" \
+
+    # Our neutered CoreFoundation doesn't have this function, but I think we'll live...
+    substituteInPlace SystemConfiguration.fproj/SCNetworkConnectionPrivate.c \
+      --replace 'CFPreferencesAppValueIsForced(serviceID, USER_PREFERENCES_APPLICATION_ID)' 'FALSE' \
+      --replace 'CFPreferencesAppValueIsForced(userPrivate->serviceID, USER_PREFERENCES_APPLICATION_ID)' 'FALSE'
+
+    cat >SystemConfiguration.fproj/fake_xpc.h <<EOF
+    typedef void *xpc_type_t;
+    typedef void *xpc_object_t;
+    typedef void *xpc_connection_t;
+
+    xpc_type_t xpc_get_type(xpc_object_t object);
+    xpc_object_t xpc_dictionary_create(const char * const *keys, const xpc_object_t *values, size_t count);
+    char *xpc_copy_description(xpc_object_t object);
+    int64_t  xpc_dictionary_get_int64(xpc_object_t xdict, const char *key);
+    uint64_t xpc_dictionary_get_uint64(xpc_object_t xdict, const char *key);
+    void xpc_connection_set_event_handler(xpc_connection_t connection, void *handler);
+
+    extern const struct _xpc_type_s _xpc_type_error;
+    #define XPC_TYPE_ERROR (&_xpc_type_error)
+
+    extern const struct _xpc_type_s _xpc_type_dictionary;
+    #define XPC_TYPE_DICTIONARY (&_xpc_type_dictionary)
+
+    extern const struct _xpc_type_s _xpc_type_array;
+    #define XPC_TYPE_ARRAY (&_xpc_type_array)
+
+    extern const struct _xpc_dictionary_s _xpc_error_connection_interrupted;
+    #define XPC_ERROR_CONNECTION_INTERRUPTED (&_xpc_error_connection_interrupted)
+
+    extern const struct _xpc_dictionary_s _xpc_error_connection_invalid;
+    #define XPC_ERROR_CONNECTION_INVALID (&_xpc_error_connection_invalid)
+
+    extern const char *const _xpc_error_key_description;
+    #define XPC_ERROR_KEY_DESCRIPTION _xpc_error_key_description
+
+    #define XPC_CONNECTION_MACH_SERVICE_PRIVILEGED (1 << 1)
+    EOF
+  '';
+
+  buildPhase = ''
+    pushd SystemConfiguration.fproj >/dev/null
+
+    mkdir -p SystemConfiguration.framework/Resources
+    cp ../get-mobility-info       SystemConfiguration.framework/Resources
+    cp Info.plist                 SystemConfiguration.framework/Resources
+    cp -r English.lproj           SystemConfiguration.framework/Resources
+    cp NetworkConfiguration.plist SystemConfiguration.framework/Resources
+
+    mkdir -p SystemConfiguration.framework/Headers
+    mkdir -p SystemConfiguration.framework/PrivateHeaders
+
+    # The standard public headers
+    cp SCSchemaDefinitions.h        SystemConfiguration.framework/Headers
+    cp SystemConfiguration.h        SystemConfiguration.framework/Headers
+    cp SCDynamicStore.h             SystemConfiguration.framework/Headers
+    cp SCDynamicStoreCopySpecific.h SystemConfiguration.framework/Headers
+    cp SCPreferences.h              SystemConfiguration.framework/Headers
+    cp CaptiveNetwork.h             SystemConfiguration.framework/Headers
+    cp SCPreferencesPath.h          SystemConfiguration.framework/Headers
+    cp SCDynamicStoreKey.h          SystemConfiguration.framework/Headers
+    cp SCPreferencesSetSpecific.h   SystemConfiguration.framework/Headers
+    cp SCNetworkConfiguration.h     SystemConfiguration.framework/Headers
+    cp SCNetworkConnection.h        SystemConfiguration.framework/Headers
+    cp SCNetworkReachability.h      SystemConfiguration.framework/Headers
+    cp DHCPClientPreferences.h      SystemConfiguration.framework/Headers
+    cp SCNetwork.h                  SystemConfiguration.framework/Headers
+    cp SCDynamicStoreCopyDHCPInfo.h SystemConfiguration.framework/Headers
+
+    # TODO: Do we want to preserve private headers or just make them public?
+    cp SCDPlugin.h                         SystemConfiguration.framework/PrivateHeaders
+    cp SCPrivate.h                         SystemConfiguration.framework/PrivateHeaders
+    cp SCDynamicStorePrivate.h             SystemConfiguration.framework/PrivateHeaders
+    cp SCDynamicStoreCopySpecificPrivate.h SystemConfiguration.framework/PrivateHeaders
+    cp SCDynamicStoreSetSpecificPrivate.h  SystemConfiguration.framework/PrivateHeaders
+    cp SCValidation.h                      SystemConfiguration.framework/PrivateHeaders
+    cp SCPreferencesPrivate.h              SystemConfiguration.framework/PrivateHeaders
+    cp DeviceOnHold.h                      SystemConfiguration.framework/PrivateHeaders
+    cp LinkConfiguration.h                 SystemConfiguration.framework/PrivateHeaders
+    cp SCPreferencesPathKey.h              SystemConfiguration.framework/PrivateHeaders
+    cp SCPreferencesSetSpecificPrivate.h   SystemConfiguration.framework/PrivateHeaders
+    cp SCNetworkConnectionPrivate.h        SystemConfiguration.framework/PrivateHeaders
+    cp SCPreferencesGetSpecificPrivate.h   SystemConfiguration.framework/PrivateHeaders
+    cp SCSchemaDefinitionsPrivate.h        SystemConfiguration.framework/PrivateHeaders
+    cp SCNetworkConfigurationPrivate.h     SystemConfiguration.framework/PrivateHeaders
+    cp SCPreferencesKeychainPrivate.h      SystemConfiguration.framework/PrivateHeaders
+    cp SCNetworkSignature.h                SystemConfiguration.framework/PrivateHeaders
+    cp SCNetworkSignaturePrivate.h         SystemConfiguration.framework/PrivateHeaders
+    cp VPNPrivate.h                        SystemConfiguration.framework/PrivateHeaders
+    cp VPNConfiguration.h                  SystemConfiguration.framework/PrivateHeaders
+    cp VPNTunnelPrivate.h                  SystemConfiguration.framework/PrivateHeaders
+    cp VPNTunnel.h                         SystemConfiguration.framework/PrivateHeaders
+
+    mkdir derived
+
+    cat >derived/SystemConfiguration_vers.c <<EOF
+    const unsigned char SystemConfigurationVersionString[] __attribute__ ((used)) = "@(#)PROGRAM:SystemConfiguration  PROJECT:configd-" "\n"; const double SystemConfigurationVersionNumber __attribute__ ((used)) = (double)0.;
+    EOF
+
+    mig -arch x86_64 -header derived/shared_dns_info.h -user derived/shared_dns_infoUser.c -sheader /dev/null -server /dev/null ../dnsinfo/shared_dns_info.defs
+    mig -arch x86_64 -header derived/config.h          -user derived/configUser.c          -sheader /dev/null -server /dev/null config.defs
+    mig -arch x86_64 -header derived/helper.h          -user derived/helperUser.c          -sheader /dev/null -server /dev/null helper/helper.defs
+    mig -arch x86_64 -header derived/pppcontroller.h   -user derived/pppcontrollerUser.c   -sheader /dev/null -server /dev/null pppcontroller.defs
+
+    cc -I. -Ihelper -Iderived -F. -c SCSchemaDefinitions.c -o SCSchemaDefinitions.o
+    cc -I. -Ihelper -Iderived -F. -c SCD.c -o SCD.o
+    cc -I. -Ihelper -Iderived -F. -c SCDKeys.c -o SCDKeys.o
+    cc -I. -Ihelper -Iderived -F. -c SCDPrivate.c -o SCDPrivate.o
+    cc -I. -Ihelper -Iderived -F. -c SCDPlugin.c -o SCDPlugin.o
+    cc -I. -Ihelper -Iderived -F. -c CaptiveNetwork.c -o CaptiveNetwork.o
+    cc -I. -Ihelper -Iderived -F. -c SCDOpen.c -o SCDOpen.o
+    cc -I. -Ihelper -Iderived -F. -c SCDList.c -o SCDList.o
+    cc -I. -Ihelper -Iderived -F. -c SCDAdd.c -o SCDAdd.o
+    cc -I. -Ihelper -Iderived -F. -c SCDGet.c -o SCDGet.o
+    cc -I. -Ihelper -Iderived -F. -c SCDSet.c -o SCDSet.o
+    cc -I. -Ihelper -Iderived -F. -c SCDRemove.c -o SCDRemove.o
+    cc -I. -Ihelper -Iderived -F. -c SCDNotify.c -o SCDNotify.o
+    cc -I. -Ihelper -Iderived -F. -c SCDNotifierSetKeys.c -o SCDNotifierSetKeys.o
+    cc -I. -Ihelper -Iderived -F. -c SCDNotifierAdd.c -o SCDNotifierAdd.o
+    cc -I. -Ihelper -Iderived -F. -c SCDNotifierRemove.c -o SCDNotifierRemove.o
+    cc -I. -Ihelper -Iderived -F. -c SCDNotifierGetChanges.c -o SCDNotifierGetChanges.o
+    cc -I. -Ihelper -Iderived -F. -c SCDNotifierWait.c -o SCDNotifierWait.o
+    cc -I. -Ihelper -Iderived -F. -c SCDNotifierInformViaCallback.c -o SCDNotifierInformViaCallback.o
+    cc -I. -Ihelper -Iderived -F. -c SCDNotifierInformViaFD.c -o SCDNotifierInformViaFD.o
+    cc -I. -Ihelper -Iderived -F. -c SCDNotifierInformViaSignal.c -o SCDNotifierInformViaSignal.o
+    cc -I. -Ihelper -Iderived -F. -c SCDNotifierCancel.c -o SCDNotifierCancel.o
+    cc -I. -Ihelper -Iderived -F. -c SCDSnapshot.c -o SCDSnapshot.o
+    cc -I. -Ihelper -Iderived -F. -c SCP.c -o SCP.o
+    cc -I. -Ihelper -Iderived -F. -c SCPOpen.c -o SCPOpen.o
+    cc -I. -Ihelper -Iderived -F. -c SCPLock.c -o SCPLock.o
+    cc -I. -Ihelper -Iderived -F. -c SCPUnlock.c -o SCPUnlock.o
+    cc -I. -Ihelper -Iderived -F. -c SCPList.c -o SCPList.o
+    cc -I. -Ihelper -Iderived -F. -c SCPGet.c -o SCPGet.o
+    cc -I. -Ihelper -Iderived -F. -c SCPAdd.c -o SCPAdd.o
+    cc -I. -Ihelper -Iderived -F. -c SCPSet.c -o SCPSet.o
+    cc -I. -Ihelper -Iderived -F. -c SCPRemove.c -o SCPRemove.o
+    cc -I. -Ihelper -Iderived -F. -c SCPCommit.c -o SCPCommit.o
+    cc -I. -Ihelper -Iderived -F. -c SCPApply.c -o SCPApply.o
+    cc -I. -Ihelper -Iderived -F. -c SCPPath.c -o SCPPath.o
+    cc -I. -Ihelper -Iderived -F. -c SCDConsoleUser.c -o SCDConsoleUser.o
+    cc -I. -Ihelper -Iderived -F. -c SCDHostName.c -o SCDHostName.o
+    cc -I. -Ihelper -Iderived -F. -c SCLocation.c -o SCLocation.o
+    cc -I. -Ihelper -Iderived -F. -c SCNetwork.c -o SCNetwork.o
+    cc -I. -Ihelper -Iderived -F. -c derived/pppcontrollerUser.c -o pppcontrollerUser.o
+    cc -I. -Ihelper -Iderived -F. -c SCNetworkConnection.c -o SCNetworkConnection.o
+    cc -I. -Ihelper -Iderived -F. -c SCNetworkConnectionPrivate.c -o SCNetworkConnectionPrivate.o
+    cc -I. -Ihelper -Iderived -I../dnsinfo -F. -c SCNetworkReachability.c -o SCNetworkReachability.o
+    cc -I. -Ihelper -Iderived -F. -c SCProxies.c -o SCProxies.o
+    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${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${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
+    cc -I. -Ihelper -Iderived -F. -c SCNetworkConfigurationInternal.c -o SCNetworkConfigurationInternal.o
+    cc -I. -Ihelper -Iderived -F. -c SCNetworkInterface.c -o SCNetworkInterface.o
+    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${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
+    cc -I. -Ihelper -Iderived -F. -c VPNPrivate.c -o VPNPrivate.o
+    cc -I. -Ihelper -Iderived -F. -c VPNConfiguration.c -o VPNConfiguration.o
+    cc -I. -Ihelper -Iderived -F. -c VPNTunnel.c -o VPNTunnel.o
+    cc -I. -Ihelper -Iderived -F. -c derived/helperUser.c -o helperUser.o
+    cc -I. -Ihelper -Iderived -F. -c reachability/SCNetworkReachabilityServer_client.c -o SCNetworkReachabilityServer_client.o
+    cc -I. -Ihelper -Iderived -F. -c reachability/rb.c -o rb.o
+    cc -I. -Ihelper -Iderived -F. -c derived/SystemConfiguration_vers.c -o SystemConfiguration_vers.o
+
+    cc -dynamiclib *.o -install_name $out/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration -dead_strip -framework CoreFoundation -single_module -o SystemConfiguration.framework/SystemConfiguration
+
+    popd >/dev/null
+  '';
+
+  installPhase = ''
+    mkdir -p $out/include
+    cp dnsinfo/*.h $out/include/
+
+    mkdir -p $out/Library/Frameworks/
+    mv SystemConfiguration.fproj/SystemConfiguration.framework $out/Library/Frameworks
+  '';
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/copyfile/default.nix b/pkgs/os-specific/darwin/apple-source-releases/copyfile/default.nix
new file mode 100644
index 000000000000..c1a2acccaa97
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/copyfile/default.nix
@@ -0,0 +1,10 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  installPhase = ''
+    mkdir -p $out/include/
+    cp copyfile.h $out/include/
+  '';
+}
\ No newline at end of file
diff --git a/pkgs/os-specific/darwin/apple-source-releases/default.nix b/pkgs/os-specific/darwin/apple-source-releases/default.nix
new file mode 100644
index 000000000000..afaf602bec5f
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/default.nix
@@ -0,0 +1,83 @@
+{ stdenv, fetchurl, pkgs }:
+
+let
+  fetchApple = version: sha256: name: fetchurl {
+    url = "http://www.opensource.apple.com/tarballs/${name}/${name}-${version}.tar.gz";
+    inherit sha256;
+  };
+
+  applePackage = namePath: version: sha256:
+    let
+      name = builtins.elemAt (stdenv.lib.splitString "/" namePath) 0;
+
+      appleDerivation = attrs: stdenv.mkDerivation ({
+        inherit version;
+        name = "${name}-${version}";
+      } // (if attrs ? srcs then {} else {
+        src  = fetchApple version sha256 name;
+      }) // attrs);
+      callPackage = pkgs.newScope (packages // pkgs.darwin // { inherit appleDerivation name version; });
+    in callPackage (./. + builtins.toPath "/${namePath}");
+
+  IOKitSpecs = {
+    IOAudioFamily                        = fetchApple "197.4.2"    "1dmrczdmbdkvnhjbv233wx4xczgpf5wjrhr83aizrwpks5avkxbr";
+    IOFireWireFamily                     = fetchApple "455.4.0"    "034n2v6z7lf1cx3sp3309z4sn8mkchjcrsf177iag46yzlzcjgfl";
+    IOFWDVComponents                     = fetchApple "207.4.1"    "1brr0yn6mxgapw3bvlhyissfksifzj2mqsvj9vmps6zwcsxjfw7m";
+    IOFireWireAVC                        = fetchApple "422.4.0"    "1anw8cfmwkavnrs28bzshwa3cwk4r1p3x72561zljx57d0na9164";
+    IOFireWireSBP2                       = fetchApple "426.4.1"    "0asik6qjhf3jjp22awsiyyd6rj02zwnx47l0afbwmxpn5bchfk60";
+    IOFireWireSerialBusProtocolTransport = fetchApple "251.0.1"    "09kiq907qpk94zbij1mrcfcnyyc5ncvlxavxjrj4v5braxm78lhi";
+    IOGraphics                           = fetchApple "471.92.1"   "1c110c9chafy5ilvnc08my9ka530aljggbn66gh3sjsg7lzck9nb";
+    IOHIDFamily                          = fetchApple "503.215.2"  "0nx9mzdw848y6ppcfvip3ybczd1fxkr413zhi9qhw7gnpvac5g3n";
+    IONetworkingFamily                   = fetchApple "100"        "10r769mqq7aiksdsvyz76xjln0lg7dj4pkg2x067ygyf9md55hlz";
+    IOSerialFamily                       = fetchApple "64.1.1"     "1bfkqmg7clwm23byr3iji812j7v1p6565b1ri6p78zviqxnxh7cx";
+    IOStorageFamily                      = fetchApple "172"        "0w5yr8ppl82anwph2zba0ppjji6ipf5x410zhcm1drzwn4bbkxrj";
+    IOBDStorageFamily                    = fetchApple "14"         "1rbvmh311n853j5qb6hfda94vym9wkws5w736w2r7dwbrjyppc1q";
+    IOCDStorageFamily                    = fetchApple "51"         "1905sxwmpxdcnm6yggklc5zimx1558ygm3ycj6b34f9h48xfxzgy";
+    IODVDStorageFamily                   = fetchApple "35"         "1fv82rn199mi998l41c0qpnlp3irhqp2rb7v53pxbx7cra4zx3i6";
+    # There should be an IOStreamFamily project here, but they haven't released it :(
+    IOUSBFamily                          = fetchApple "630.4.5"    "1znqb6frxgab9mkyv7csa08c26p9p0ip6hqb4wm9c7j85kf71f4j"; # This is from 10.8 :(
+    IOUSBFamily_older                    = fetchApple "560.4.2"    "113lmpz8n6sibd27p42h8bl7a6c3myc6zngwri7gnvf8qlajzyml" "IOUSBFamily"; # This is even older :(
+    IOKitUser                            = fetchApple "907.100.13" "0kcbrlyxcyirvg5p95hjd9k8a01k161zg0bsfgfhkb90kh2s8x0m";
+    # There should be an IOVideo here, but they haven't released it :(
+  };
+
+  IOKitSrcs = stdenv.lib.mapAttrs (name: value: if builtins.isFunction value then value name else value) IOKitSpecs;
+
+  packages = {
+    adv_cmds        = applePackage "adv_cmds"          "153"         "174v6a4zkcm2pafzgdm6kvs48z5f911zl7k49hv7kjq6gm58w99v" {};
+    architecture    = applePackage "architecture"      "265"         "05wz8wmxlqssfp29x203fwfb8pgbdjj1mpz12v508658166yzqj8" {};
+    bootstrap_cmds  = applePackage "bootstrap_cmds"    "86"          "0xr0296jm1r3q7kbam98h85g23qlfi763z54ahj563n636kyk2wb" {};
+    CarbonHeaders   = applePackage "CarbonHeaders"     "9A581"       "1hc0yijlpwq39x5bic6nnywqp2m1wj1f11j33m2q7p505h1h740c" {};
+    CF              = applePackage "CF"                "855.17"      "1sadmxi9fsvsmdyxvg2133sdzvkzwil5fvyyidxsyk1iyfzqsvln" {};
+    CommonCrypto    = applePackage "CommonCrypto"      "60049"       "1azin6w7cnzl0iv8kd2qzgwcp6a45zy64y5z1i6jysjcl6xmlw2h" {};
+    configd         = applePackage "configd"           "453.19"      "1gxakahk8gallf16xmhxhprdxkh3prrmzxnmxfvj0slr0939mmr2" {};
+    copyfile        = applePackage "copyfile"          "103.92.1"    "15i2hw5aqx0fklvmq6avin5s00adacvzqc740vviwc2y742vrdcd" {};
+    CoreOSMakefiles = applePackage "CoreOSMakefiles"   "76"          "0sw3w3sjil0kvxz8y86b81sz82rcd1nijayki1a1bsnsf0hz6qbf" {};
+    Csu             = applePackage "Csu"               "79"          "1hif4dz23isgx85sgh11yg8amvp2ksvvhz3y5v07zppml7df2lnh" {};
+    dtrace          = applePackage "dtrace"            "118.1"       "0pp5x8dgvzmg9vvg32hpy2brm17dpmbwrcr4prsmdmfvd4767wcf" { cctools = pkgs.darwin.cctools_native; };
+    dyld            = applePackage "dyld"              "239.4"       "07z7lyv6x0f6gllb5hymccl31zisrdhz4gqp722xcs9nhsqaqvn7" {};
+    eap8021x        = applePackage "eap8021x"          "180"         "1ynkq8zmhgqhpkdg2syj085lzya0fz55d3423hvf9kcgpbjcd9ic" {};
+    IOKit           = applePackage "IOKit"             "907.100.13"  "0kcbrlyxcyirvg5p95hjd9k8a01k161zg0bsfgfhkb90kh2s8x0m" { inherit IOKitSrcs; };
+    launchd         = applePackage "launchd"           "842.92.1"    "0w30hvwqq8j5n90s3qyp0fccxflvrmmjnicjri4i1vd2g196jdgj" {};
+    libauto         = applePackage "libauto"           "185.5"       "17z27yq5d7zfkwr49r7f0vn9pxvj95884sd2k6lq6rfaz9gxqhy3" {};
+    Libc            = applePackage "Libc"              "997.90.3"    "1jz5bx9l4q484vn28c6n9b28psja3rpxiqbj6zwrwvlndzmq1yz5" {};
+    Libc_old        = applePackage "Libc/825_40_1.nix" "825.40.1"    "0xsx1im52gwlmcrv4lnhhhn9dyk5ci6g27k6yvibn9vj8fzjxwcf" {};
+    libclosure      = applePackage "libclosure"        "63"          "083v5xhihkkajj2yvz0dwgbi0jl2qvzk22p7pqq1zp3ry85xagrx" {};
+    libdispatch     = applePackage "libdispatch"       "339.92.1"    "1lc5033cmkwxy3r26gh9plimxshxfcbgw6i0j7mgjlnpk86iy5bk" {};
+    libiconv        = applePackage "libiconv"          "41"          "10q7yd35flr893nysn9i04njgks4m3gis7jivb9ra9dcb77gqdcn" {};
+    Libinfo         = applePackage "Libinfo"           "449.1.3"     "1ix6f7xwjnq9bqgv8w27k4j64bqn1mfhh91nc7ciiv55axpdb9hq" {};
+    Libm            = applePackage "Libm"              "2026"        "02sd82ig2jvvyyfschmb4gpz6psnizri8sh6i982v341x6y4ysl7" {};
+    Libnotify       = applePackage "Libnotify"         "121.20.1"    "164rx4za5z74s0mk9x0m1815r1m9kfal8dz3bfaw7figyjd6nqad" {};
+    libpthread      = applePackage "libpthread"        "105.1.4"     "09vwwahcvmxvx2xl0890gkp91n61dld29j73y2pa597bqkag2qpg" {};
+    libresolv       = applePackage "libresolv"         "54"          "028mp2smd744ryxwl8cqz4njv8h540sdw3an1yl7yxqcs04r0p4b" {};
+    Libsystem       = applePackage "Libsystem"         "1197.1.1"    "1yfj2qdrf9vrzs7p9m4wlb7zzxcrim1gw43x4lvz4qydpp5kg2rh" { cctools = pkgs.darwin.cctools_native; };
+    libunwind       = applePackage "libunwind"         "35.3"        "0miffaa41cv0lzf8az5k1j1ng8jvqvxcr4qrlkf3xyj479arbk1b" {};
+    mDNSResponder   = applePackage "mDNSResponder"     "522.92.1"    "1cp87qda1s7brriv413i71yggm8yqfwv64vknrnqv24fcb8hzbmy" {};
+    objc4           = applePackage "objc4"             "551.1"       "1jrdb6yyb5jwwj27c1r0nr2y2ihqjln8ynj61mpkvp144c1cm5bg" {};
+    objc4_pure      = applePackage "objc4/pure.nix"    "551.1"       "1jrdb6yyb5jwwj27c1r0nr2y2ihqjln8ynj61mpkvp144c1cm5bg" {};
+    ppp             = applePackage "ppp"               "727.90.1"    "166xz1q7al12hm3q3drlp2r6fgdrsq3pmazjp3nsqg3vnglyh4gk" {};
+    removefile      = applePackage "removefile"        "33"          "0ycvp7cnv40952a1jyhm258p6gg5xzh30x86z5gb204x80knw30y" {};
+    Security        = applePackage "Security"          "55471.14.18" "1nv0dczf67dhk17hscx52izgdcyacgyy12ag0jh6nl5hmfzsn8yy" {};
+    xnu             = applePackage "xnu"               "2422.115.4"  "1ssw5fzvgix20bw6y13c39ib0zs7ykpig3irlwbaccpjpci5jl0s" {};
+  };
+in packages
diff --git a/pkgs/os-specific/darwin/apple-source-releases/dtrace/default.nix b/pkgs/os-specific/darwin/apple-source-releases/dtrace/default.nix
new file mode 100644
index 000000000000..5fcd04266d5a
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/dtrace/default.nix
@@ -0,0 +1,50 @@
+{ stdenv, appleDerivation, cctools, zlib }:
+
+appleDerivation {
+  buildInputs = [ cctools zlib ];
+
+  buildPhase = ''
+    export CFLAGS=" -I$PWD/head -I$PWD/sys -I$PWD/libelf -I$PWD/libdwarf"
+
+    pushd libelf
+    for f in *.c; do
+      if [ "$f" != "lintsup.c" ]; then # Apple doesn't use it, so I don't either
+        cc -D_INT64_TYPE -D_LONGLONG_TYPE -D_ILP32 $CFLAGS -c $f
+      fi
+    done
+    libtool -static -o libelf.a *.o
+    popd
+
+    pushd libdwarf
+    ./configure CFLAGS="$CFLAGS -Icmplrs"
+    make
+    popd
+
+    cp libelf/libelf.a     tools/ctfconvert
+    cp libdwarf/libdwarf.a tools/ctfconvert
+
+    pushd tools/ctfconvert
+    for f in ../../darwin_shim.c *.c; do
+      cc -DNDEBUG -DNS_BLOCK_ASSERTIONS $CFLAGS -c $f
+    done
+
+    export COMMON="alist.o ctf.o darwin_shim.o hash.o iidesc.o input.o list.o \
+      memory.o output.o stack.o strtab.o symbol.o tdata.o traverse.o util.o"
+
+    export CONVERT="ctfconvert.o dwarf.o merge.o st_bugs.o st_parse.o stabs.o"
+    export MERGE="barrier.o ctfmerge.o dwarf.o fifo.o merge.o st_bugs.o st_parse.o stabs.o utils.o"
+    export DUMP="dump.o fifo.o utils.o"
+
+    clang -o ctfconvert $CONVERT $COMMON -L. -lz -lelf -ldwarf
+    clang -o ctfmerge   $MERGE   $COMMON -L. -lz -lelf -ldwarf
+    clang -o ctfdump    $DUMP    $COMMON -L. -lz -lelf
+    popd
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp tools/ctfconvert/ctfconvert $out/bin
+    cp tools/ctfconvert/ctfmerge   $out/bin
+    cp tools/ctfconvert/ctfdump    $out/bin
+  '';
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/dyld/default.nix b/pkgs/os-specific/darwin/apple-source-releases/dyld/default.nix
new file mode 100644
index 000000000000..56b0d93f99be
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/dyld/default.nix
@@ -0,0 +1,18 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  installPhase = ''
+    mkdir -p $out/lib $out/include
+    ln -s /usr/lib/dyld $out/lib/dyld
+    cp -r include $out/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Impure primitive symlinks to the Mac OS native dyld, along with headers";
+    maintainers = with maintainers; [ copumpkin ];
+    platforms   = platforms.darwin;
+    license     = licenses.apsl20;
+  };
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/eap8021x/default.nix b/pkgs/os-specific/darwin/apple-source-releases/eap8021x/default.nix
new file mode 100644
index 000000000000..af9493fe32e8
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/eap8021x/default.nix
@@ -0,0 +1,11 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" "fixupPhase" ];
+
+  installPhase = ''
+    mkdir -p $out/Library/Frameworks/EAP8021X.framework/Headers
+
+    cp EAP8021X.fproj/EAPClientProperties.h $out/Library/Frameworks/EAP8021X.framework/Headers
+  '';
+}
\ No newline at end of file
diff --git a/pkgs/os-specific/darwin/apple-source-releases/launchd/default.nix b/pkgs/os-specific/darwin/apple-source-releases/launchd/default.nix
new file mode 100644
index 000000000000..c0e00ca1636e
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/launchd/default.nix
@@ -0,0 +1,14 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  # No clue why the same file has two different names. Ask Apple!
+  installPhase = ''
+    mkdir -p $out/include/ $out/include/servers
+    cp liblaunch/*.h $out/include
+
+    cp liblaunch/bootstrap.h $out/include/servers
+    cp liblaunch/bootstrap.h $out/include/servers/bootstrap_defs.h
+  '';
+}
\ No newline at end of file
diff --git a/pkgs/os-specific/darwin/apple-source-releases/libauto/auto_dtrace.h b/pkgs/os-specific/darwin/apple-source-releases/libauto/auto_dtrace.h
new file mode 100644
index 000000000000..bf367a3cabb3
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/libauto/auto_dtrace.h
@@ -0,0 +1,129 @@
+/*
+ * Generated by dtrace(1M).
+ */
+
+#ifndef _AUTO_DTRACE_H
+#define _AUTO_DTRACE_H
+
+#include <unistd.h>
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#define GARBAGE_COLLECTION_STABILITY "___dtrace_stability$garbage_collection$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0"
+
+#define GARBAGE_COLLECTION_TYPEDEFS "___dtrace_typedefs$garbage_collection$v2$6175746f5f636f6c6c656374696f6e5f70686173655f74$6175746f5f636f6c6c656374696f6e5f747970655f74$6d616c6c6f635f7a6f6e655f74"
+
+#if !defined(DTRACE_PROBES_DISABLED) || !DTRACE_PROBES_DISABLED
+
+#define GARBAGE_COLLECTION_AUTO_BLOCK_LOST_THREAD_LOCALITY(arg0, arg1) \
+do { \
+  __asm__ volatile(".reference " GARBAGE_COLLECTION_TYPEDEFS); \
+  __dtrace_probe$garbage_collection$auto_block_lost_thread_locality$v1$766f6964202a$75696e7436345f74(arg0, arg1); \
+  __asm__ volatile(".reference " GARBAGE_COLLECTION_STABILITY); \
+} while (0)
+#define GARBAGE_COLLECTION_AUTO_BLOCK_LOST_THREAD_LOCALITY_ENABLED() \
+  ({ int _r = __dtrace_isenabled$garbage_collection$auto_block_lost_thread_locality$v1(); \
+    __asm__ volatile(""); \
+    _r; })
+#define GARBAGE_COLLECTION_AUTO_REFCOUNT_ONE_ALLOCATION(arg0) \
+do { \
+  __asm__ volatile(".reference " GARBAGE_COLLECTION_TYPEDEFS); \
+  __dtrace_probe$garbage_collection$auto_refcount_one_allocation$v1$75696e7436345f74(arg0); \
+  __asm__ volatile(".reference " GARBAGE_COLLECTION_STABILITY); \
+} while (0)
+#define GARBAGE_COLLECTION_AUTO_REFCOUNT_ONE_ALLOCATION_ENABLED() \
+  ({ int _r = __dtrace_isenabled$garbage_collection$auto_refcount_one_allocation$v1(); \
+    __asm__ volatile(""); \
+    _r; })
+#define GARBAGE_COLLECTION_COLLECTION_BEGIN(arg0, arg1) \
+do { \
+  __asm__ volatile(".reference " GARBAGE_COLLECTION_TYPEDEFS); \
+  __dtrace_probe$garbage_collection$collection_begin$v1$6d616c6c6f635f7a6f6e655f74202a$6175746f5f636f6c6c656374696f6e5f747970655f74(arg0, arg1); \
+  __asm__ volatile(".reference " GARBAGE_COLLECTION_STABILITY); \
+} while (0)
+#define GARBAGE_COLLECTION_COLLECTION_BEGIN_ENABLED() \
+  ({ int _r = __dtrace_isenabled$garbage_collection$collection_begin$v1(); \
+    __asm__ volatile(""); \
+    _r; })
+#define GARBAGE_COLLECTION_COLLECTION_END(arg0, arg1, arg2, arg3, arg4) \
+do { \
+  __asm__ volatile(".reference " GARBAGE_COLLECTION_TYPEDEFS); \
+  __dtrace_probe$garbage_collection$collection_end$v1$6d616c6c6f635f7a6f6e655f74202a$75696e7436345f74$75696e7436345f74$75696e7436345f74$75696e7436345f74(arg0, arg1, arg2, arg3, arg4); \
+  __asm__ volatile(".reference " GARBAGE_COLLECTION_STABILITY); \
+} while (0)
+#define GARBAGE_COLLECTION_COLLECTION_END_ENABLED() \
+  ({ int _r = __dtrace_isenabled$garbage_collection$collection_end$v1(); \
+    __asm__ volatile(""); \
+    _r; })
+#define GARBAGE_COLLECTION_COLLECTION_PHASE_BEGIN(arg0, arg1) \
+do { \
+  __asm__ volatile(".reference " GARBAGE_COLLECTION_TYPEDEFS); \
+  __dtrace_probe$garbage_collection$collection_phase_begin$v1$6d616c6c6f635f7a6f6e655f74202a$6175746f5f636f6c6c656374696f6e5f70686173655f74(arg0, arg1); \
+  __asm__ volatile(".reference " GARBAGE_COLLECTION_STABILITY); \
+} while (0)
+#define GARBAGE_COLLECTION_COLLECTION_PHASE_BEGIN_ENABLED() \
+  ({ int _r = __dtrace_isenabled$garbage_collection$collection_phase_begin$v1(); \
+    __asm__ volatile(""); \
+    _r; })
+#define GARBAGE_COLLECTION_COLLECTION_PHASE_END(arg0, arg1, arg2, arg3) \
+do { \
+  __asm__ volatile(".reference " GARBAGE_COLLECTION_TYPEDEFS); \
+  __dtrace_probe$garbage_collection$collection_phase_end$v1$6d616c6c6f635f7a6f6e655f74202a$6175746f5f636f6c6c656374696f6e5f70686173655f74$75696e7436345f74$75696e7436345f74(arg0, arg1, arg2, arg3); \
+  __asm__ volatile(".reference " GARBAGE_COLLECTION_STABILITY); \
+} while (0)
+#define GARBAGE_COLLECTION_COLLECTION_PHASE_END_ENABLED() \
+  ({ int _r = __dtrace_isenabled$garbage_collection$collection_phase_end$v1(); \
+    __asm__ volatile(""); \
+    _r; })
+
+
+extern void __dtrace_probe$garbage_collection$auto_block_lost_thread_locality$v1$766f6964202a$75696e7436345f74(const void *, uint64_t);
+extern int __dtrace_isenabled$garbage_collection$auto_block_lost_thread_locality$v1(void);
+extern void __dtrace_probe$garbage_collection$auto_refcount_one_allocation$v1$75696e7436345f74(uint64_t);
+extern int __dtrace_isenabled$garbage_collection$auto_refcount_one_allocation$v1(void);
+extern void __dtrace_probe$garbage_collection$collection_begin$v1$6d616c6c6f635f7a6f6e655f74202a$6175746f5f636f6c6c656374696f6e5f747970655f74(const malloc_zone_t *, auto_collection_type_t);
+extern int __dtrace_isenabled$garbage_collection$collection_begin$v1(void);
+extern void __dtrace_probe$garbage_collection$collection_end$v1$6d616c6c6f635f7a6f6e655f74202a$75696e7436345f74$75696e7436345f74$75696e7436345f74$75696e7436345f74(const malloc_zone_t *, uint64_t, uint64_t, uint64_t, uint64_t);
+extern int __dtrace_isenabled$garbage_collection$collection_end$v1(void);
+extern void __dtrace_probe$garbage_collection$collection_phase_begin$v1$6d616c6c6f635f7a6f6e655f74202a$6175746f5f636f6c6c656374696f6e5f70686173655f74(const malloc_zone_t *, auto_collection_phase_t);
+extern int __dtrace_isenabled$garbage_collection$collection_phase_begin$v1(void);
+extern void __dtrace_probe$garbage_collection$collection_phase_end$v1$6d616c6c6f635f7a6f6e655f74202a$6175746f5f636f6c6c656374696f6e5f70686173655f74$75696e7436345f74$75696e7436345f74(const malloc_zone_t *, auto_collection_phase_t, uint64_t, uint64_t);
+extern int __dtrace_isenabled$garbage_collection$collection_phase_end$v1(void);
+
+#else
+
+#define GARBAGE_COLLECTION_AUTO_BLOCK_LOST_THREAD_LOCALITY(arg0, arg1) \
+do { \
+  } while (0)
+#define GARBAGE_COLLECTION_AUTO_BLOCK_LOST_THREAD_LOCALITY_ENABLED() (0)
+#define GARBAGE_COLLECTION_AUTO_REFCOUNT_ONE_ALLOCATION(arg0) \
+do { \
+  } while (0)
+#define GARBAGE_COLLECTION_AUTO_REFCOUNT_ONE_ALLOCATION_ENABLED() (0)
+#define GARBAGE_COLLECTION_COLLECTION_BEGIN(arg0, arg1) \
+do { \
+  } while (0)
+#define GARBAGE_COLLECTION_COLLECTION_BEGIN_ENABLED() (0)
+#define GARBAGE_COLLECTION_COLLECTION_END(arg0, arg1, arg2, arg3, arg4) \
+do { \
+  } while (0)
+#define GARBAGE_COLLECTION_COLLECTION_END_ENABLED() (0)
+#define GARBAGE_COLLECTION_COLLECTION_PHASE_BEGIN(arg0, arg1) \
+do { \
+  } while (0)
+#define GARBAGE_COLLECTION_COLLECTION_PHASE_BEGIN_ENABLED() (0)
+#define GARBAGE_COLLECTION_COLLECTION_PHASE_END(arg0, arg1, arg2, arg3) \
+do { \
+  } while (0)
+#define GARBAGE_COLLECTION_COLLECTION_PHASE_END_ENABLED() (0)
+
+#endif /* !defined(DTRACE_PROBES_DISABLED) || !DTRACE_PROBES_DISABLED */
+
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif  /* _AUTO_DTRACE_H */
diff --git a/pkgs/os-specific/darwin/apple-source-releases/libauto/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libauto/default.nix
new file mode 100644
index 000000000000..1c61297c7d5f
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/libauto/default.nix
@@ -0,0 +1,74 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  buildPhase = ''
+    cp ${./auto_dtrace.h} ./auto_dtrace.h
+
+    substituteInPlace auto_zone.cpp \
+      --replace "#include <msgtracer_client.h>" ''$'#include <asl.h>\nstatic void msgtracer_log_with_keys(...) { };'
+
+    substituteInPlace Definitions.h \
+      --replace "#include <System/pthread_machdep.h>" ""
+
+    # getspecific_direct is more efficient, but this should be equivalent...
+    substituteInPlace Zone.h \
+      --replace "_pthread_getspecific_direct" "pthread_getspecific" \
+      --replace "_pthread_has_direct_tsd()" "0" \
+      --replace "__PTK_FRAMEWORK_GC_KEY0" "110" \
+      --replace "__PTK_FRAMEWORK_GC_KEY1" "111" \
+      --replace "__PTK_FRAMEWORK_GC_KEY2" "112" \
+      --replace "__PTK_FRAMEWORK_GC_KEY3" "113" \
+      --replace "__PTK_FRAMEWORK_GC_KEY4" "114" \
+      --replace "__PTK_FRAMEWORK_GC_KEY5" "115" \
+      --replace "__PTK_FRAMEWORK_GC_KEY6" "116" \
+      --replace "__PTK_FRAMEWORK_GC_KEY7" "117" \
+      --replace "__PTK_FRAMEWORK_GC_KEY8" "118" \
+      --replace "__PTK_FRAMEWORK_GC_KEY9" "119"
+
+    substituteInPlace auto_zone.cpp \
+      --replace "__PTK_FRAMEWORK_GC_KEY9" "119" \
+      --replace "__PTK_FRAMEWORK_GC_KEY0" "110" \
+
+    substituteInPlace Zone.cpp \
+      --replace "_pthread_getspecific_direct" "pthread_getspecific" \
+      --replace "__PTK_FRAMEWORK_GC_KEY9" "119" \
+      --replace "__PTK_FRAMEWORK_GC_KEY0" "110" \
+      --replace "__PTK_LIBDISPATCH_KEY0"  "20" \
+      --replace "struct auto_zone_cursor {" ''$'extern "C" int pthread_key_init_np(int, void (*)(void *));\nstruct auto_zone_cursor {'
+
+    substituteInPlace auto_impl_utilities.c \
+      --replace "#   include <CrashReporterClient.h>" "void CRSetCrashLogMessage(void *msg) { };"
+
+    c++ -I. -O3 -c -Wno-c++11-extensions auto_zone.cpp
+    cc  -I. -O3 -Iauto_tester -c auto_impl_utilities.c
+    c++ -I. -O3 -c auto_weak.cpp
+    c++ -I. -O3 -c Admin.cpp
+    c++ -I. -O3 -c Bitmap.cpp
+    c++ -I. -O3 -c Definitions.cpp
+    c++ -I. -O3 -c Environment.cpp
+    c++ -I. -O3 -c Large.cpp
+    c++ -I. -O3 -c Region.cpp
+    c++ -I. -O3 -c Subzone.cpp
+    c++ -I. -O3 -c WriteBarrier.cpp
+    c++ -I. -O3 -c Zone.cpp
+    c++ -I. -O3 -c Thread.cpp
+    c++ -I. -O3 -c InUseEnumerator.cpp
+    c++ -I. -O3 -c auto_gdb_interface.cpp
+    c++ -I. -O3 -c PointerHash.cpp
+    c++ -I. -O3 -c ThreadLocalCollector.cpp
+    c++ -I. -O3 -c ZoneDump.cpp
+    c++ -I. -O3 -c ZoneCollectors.cpp
+    c++ -I. -O3 -c SubzonePartition.cpp
+    c++ -I. -O3 -c ZoneCollectionChecking.cpp
+    c++ -I. -O3 -c ZoneCompaction.cpp
+    c++ -I. -O3 -c BlockRef.cpp
+
+    c++ -Wl,-no_dtrace_dof --stdlib=libc++ -dynamiclib -install_name $out/lib/libauto.dylib -o libauto.dylib *.o
+  '';
+
+  installPhase = ''
+    mkdir -p $out/lib $out/include
+    cp auto_zone.h auto_weak.h auto_tester/auto_tester.h auto_gdb_interface.h $out/include
+    cp libauto.dylib $out/lib
+  '';
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/libclosure/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libclosure/default.nix
new file mode 100644
index 000000000000..a0201f9db2c1
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/libclosure/default.nix
@@ -0,0 +1,10 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  installPhase = ''
+    mkdir -p $out/include
+    cp *.h $out/include/
+  '';
+}
\ No newline at end of file
diff --git a/pkgs/os-specific/darwin/apple-source-releases/libdispatch/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libdispatch/default.nix
new file mode 100644
index 000000000000..56c00557d43f
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/libdispatch/default.nix
@@ -0,0 +1,13 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  installPhase = ''
+    mkdir -p $out/include/dispatch $out/include/os
+
+    cp -r dispatch/*.h $out/include/dispatch
+    cp -r private/*.h  $out/include/dispatch
+    cp -r os/object.h  $out/include/os
+  '';
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix
new file mode 100644
index 000000000000..5b82835d3e64
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix
@@ -0,0 +1,15 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  preConfigure = "cd libiconv";
+
+  postInstall = ''
+    mv $out/lib/libiconv.dylib $out/lib/libiconv-nocharset.dylib
+    install_name_tool -id $out/lib/libiconv-nocharset.dylib $out/lib/libiconv-nocharset.dylib
+
+    ld -dylib -o $out/lib/libiconv.dylib \
+      -reexport_library $out/lib/libiconv-nocharset.dylib \
+      -reexport_library $out/lib/libcharset.dylib \
+      -dylib_compatibility_version 7.0.0
+  '';
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/libpthread/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libpthread/default.nix
new file mode 100644
index 000000000000..027784e2ea6d
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/libpthread/default.nix
@@ -0,0 +1,13 @@
+{ stdenv, appleDerivation, libdispatch, xnu }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" "fixupPhase" ];
+
+  propagatedBuildInputs = [ libdispatch xnu ];
+
+  installPhase = ''
+    mkdir -p $out/include/pthread
+    cp pthread/*.h $out/include/pthread/
+    cp private/*.h $out/include/pthread/
+  '';
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/libresolv/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libresolv/default.nix
new file mode 100644
index 000000000000..a74198e8ddd7
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/libresolv/default.nix
@@ -0,0 +1,51 @@
+{ stdenv, appleDerivation, Libinfo, configd, mDNSResponder }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "buildPhase" "installPhase" ];
+
+  buildInputs = [ Libinfo configd mDNSResponder ];
+
+  buildPhase = ''
+    cc -I. -c dns_util.c
+    cc -I. -c dns.c
+    cc -I. -c dns_async.c
+    cc -I. -c base64.c
+    cc -I. -c dst_api.c
+    cc -I. -c dst_hmac_link.c
+    cc -I. -c dst_support.c
+    cc -I. -c ns_date.c
+    cc -I. -c ns_name.c
+    cc -I. -c ns_netint.c
+    cc -I. -c ns_parse.c
+    cc -I. -c ns_print.c
+    cc -I. -c ns_samedomain.c
+    cc -I. -c ns_sign.c
+    cc -I. -c ns_ttl.c
+    cc -I. -c ns_verify.c
+    cc -I. -c res_comp.c
+    cc -I. -c res_data.c
+    cc -I. -c res_debug.c
+    cc -I. -c res_findzonecut.c
+    cc -I. -c res_init.c
+    cc -I. -c res_mkquery.c
+    cc -I. -c res_mkupdate.c
+    cc -I. -c res_query.c
+    cc -I. -c res_send.c
+    cc -I. -c res_sendsigned.c
+    cc -I. -c res_update.c
+    cc -dynamiclib -install_name $out/lib/libresolv.9.dylib -o libresolv.9.dylib *.o
+  '';
+
+  installPhase = ''
+    mkdir -p $out/include $out/include/arpa $out/lib
+
+    cp dns.h           $out/include/
+    cp dns_util.h      $out/include
+    cp nameser.h       $out/include
+    ln -s ../nameser.h $out/include/arpa
+    cp resolv.h        $out/include
+
+    cp libresolv.9.dylib $out/lib
+    ln -s libresolv.9.dylib $out/lib/libresolv.dylib
+  '';
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/libunwind/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libunwind/default.nix
new file mode 100644
index 000000000000..32c8d6717f0b
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/libunwind/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, appleDerivation, dyld }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "buildPhase" "installPhase" ];
+
+  buildInputs = [ dyld ];
+
+  buildPhase = ''
+    # cd src
+    # cc -I$PWD/../include -c libuwind.cxx
+    # cc -I$PWD/../include -c Registers.s
+    # cc -I$PWD/../include -c unw_getcontext.s
+    # cc -I$PWD/../include -c UnwindLevel1.c
+    # cc -I$PWD/../include -c UnwindLevel1-gcc-ext.c
+    # cc -I$PWD/../include -c Unwind-sjlj.c
+  '';
+
+  installPhase = ''
+    mkdir -p $out
+
+    cp -r include $out
+  '';
+
+  meta = with stdenv.lib; {
+    maintainers = with maintainers; [ copumpkin ];
+    platforms   = platforms.darwin;
+    license     = licenses.apsl20;
+  };
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/mDNSResponder/default.nix b/pkgs/os-specific/darwin/apple-source-releases/mDNSResponder/default.nix
new file mode 100644
index 000000000000..63674808d93b
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/mDNSResponder/default.nix
@@ -0,0 +1,10 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  installPhase = ''
+    mkdir -p $out/include
+    cp mDNSShared/dns_sd.h $out/include
+  '';
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/objc4/default.nix b/pkgs/os-specific/darwin/apple-source-releases/objc4/default.nix
new file mode 100644
index 000000000000..cea5fc9a4e2c
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/objc4/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  # Not strictly necessary, since libSystem depends on it, but it's nice to be explicit so we
+  # can easily find out what's impure.
+  __propagatedImpureHostDeps = [
+    "/usr/lib/libauto.dylib"
+    "/usr/lib/libc++abi.dylib"
+    "/usr/lib/libc++.1.dylib"
+    "/usr/lib/libSystem.B.dylib"
+  ];
+
+  installPhase = ''
+    mkdir -p $out/include/objc $out/lib
+    ln -s /usr/lib/libobjc.dylib $out/lib/libobjc.dylib
+    cp runtime/OldClasses.subproj/List.h $out/include/objc/List.h
+    cp runtime/NSObjCRuntime.h $out/include/objc/NSObjCRuntime.h
+    cp runtime/NSObject.h $out/include/objc/NSObject.h
+    cp runtime/Protocol.h $out/include/objc/Protocol.h
+    cp runtime/hashtable.h $out/include/objc/hashtable.h
+    cp runtime/hashtable2.h $out/include/objc/hashtable2.h
+    cp runtime/message.h $out/include/objc/message.h
+    cp runtime/objc-api.h $out/include/objc/objc-api.h
+    cp runtime/objc-auto.h $out/include/objc/objc-auto.h
+    cp runtime/objc-class.h $out/include/objc/objc-class.h
+    cp runtime/objc-exception.h $out/include/objc/objc-exception.h
+    cp runtime/objc-load.h $out/include/objc/objc-load.h
+    cp runtime/objc-runtime.h $out/include/objc/objc-runtime.h
+    cp runtime/objc-sync.h $out/include/objc/objc-sync.h
+    cp runtime/objc.h $out/include/objc/objc.h
+    cp runtime/runtime.h $out/include/objc/runtime.h
+  '';
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/objc4/objc-probes.h b/pkgs/os-specific/darwin/apple-source-releases/objc4/objc-probes.h
new file mode 100644
index 000000000000..4ad9ba9ad104
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/objc4/objc-probes.h
@@ -0,0 +1,65 @@
+/*
+ * Generated by dtrace(1M).
+ */
+
+#ifndef _OBJC_PROBES_H
+#define _OBJC_PROBES_H
+
+#include <unistd.h>
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#define OBJC_RUNTIME_STABILITY "___dtrace_stability$objc_runtime$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0"
+
+#define OBJC_RUNTIME_TYPEDEFS "___dtrace_typedefs$objc_runtime$v2"
+
+#if !defined(DTRACE_PROBES_DISABLED) || !DTRACE_PROBES_DISABLED
+
+#define OBJC_RUNTIME_OBJC_EXCEPTION_RETHROW() \
+do { \
+  __asm__ volatile(".reference " OBJC_RUNTIME_TYPEDEFS); \
+  __dtrace_probe$objc_runtime$objc_exception_rethrow$v1(); \
+  __asm__ volatile(".reference " OBJC_RUNTIME_STABILITY); \
+} while (0)
+#define OBJC_RUNTIME_OBJC_EXCEPTION_RETHROW_ENABLED() \
+  ({ int _r = __dtrace_isenabled$objc_runtime$objc_exception_rethrow$v1(); \
+    __asm__ volatile(""); \
+    _r; })
+#define OBJC_RUNTIME_OBJC_EXCEPTION_THROW(arg0) \
+do { \
+  __asm__ volatile(".reference " OBJC_RUNTIME_TYPEDEFS); \
+  __dtrace_probe$objc_runtime$objc_exception_throw$v1$766f6964202a(arg0); \
+  __asm__ volatile(".reference " OBJC_RUNTIME_STABILITY); \
+} while (0)
+#define OBJC_RUNTIME_OBJC_EXCEPTION_THROW_ENABLED() \
+  ({ int _r = __dtrace_isenabled$objc_runtime$objc_exception_throw$v1(); \
+    __asm__ volatile(""); \
+    _r; })
+
+
+extern void __dtrace_probe$objc_runtime$objc_exception_rethrow$v1(void);
+extern int __dtrace_isenabled$objc_runtime$objc_exception_rethrow$v1(void);
+extern void __dtrace_probe$objc_runtime$objc_exception_throw$v1$766f6964202a(const void *);
+extern int __dtrace_isenabled$objc_runtime$objc_exception_throw$v1(void);
+
+#else
+
+#define OBJC_RUNTIME_OBJC_EXCEPTION_RETHROW() \
+do { \
+  } while (0)
+#define OBJC_RUNTIME_OBJC_EXCEPTION_RETHROW_ENABLED() (0)
+#define OBJC_RUNTIME_OBJC_EXCEPTION_THROW(arg0) \
+do { \
+  } while (0)
+#define OBJC_RUNTIME_OBJC_EXCEPTION_THROW_ENABLED() (0)
+
+#endif /* !defined(DTRACE_PROBES_DISABLED) || !DTRACE_PROBES_DISABLED */
+
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif  /* _OBJC_PROBES_H */
diff --git a/pkgs/os-specific/darwin/apple-source-releases/objc4/pure.nix b/pkgs/os-specific/darwin/apple-source-releases/objc4/pure.nix
new file mode 100644
index 000000000000..28dcbdcb4a2a
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/objc4/pure.nix
@@ -0,0 +1,118 @@
+{ stdenv, fetchapplesource, libauto, launchd, libc_old, libunwind }:
+
+stdenv.mkDerivation rec {
+  version = "551.1";
+  name    = "objc4-${version}";
+
+  src = fetchapplesource {
+    inherit version;
+    name   = "objc4";
+    sha256 = "1jrdb6yyb5jwwj27c1r0nr2y2ihqjln8ynj61mpkvp144c1cm5bg";
+  };
+
+  patches = [ ./spinlocks.patch ];
+
+  buildInputs = [ libauto launchd libc_old libunwind ];
+
+  buildPhase = ''
+    cp ${./objc-probes.h} runtime/objc-probes.h
+
+    mkdir -p build/include/objc
+
+    cp runtime/hashtable.h               build/include/objc/hashtable.h
+    cp runtime/OldClasses.subproj/List.h build/include/objc/List.h
+    cp runtime/hashtable2.h              build/include/objc/hashtable2.h
+    cp runtime/message.h                 build/include/objc/message.h
+    cp runtime/objc-api.h                build/include/objc/objc-api.h
+    cp runtime/objc-auto.h               build/include/objc/objc-auto.h
+    cp runtime/objc-class.h              build/include/objc/objc-class.h
+    cp runtime/objc-exception.h          build/include/objc/objc-exception.h
+    cp runtime/objc-load.h               build/include/objc/objc-load.h
+    cp runtime/objc-sync.h               build/include/objc/objc-sync.h
+    cp runtime/objc.h                    build/include/objc/objc.h
+    cp runtime/objc-runtime.h            build/include/objc/objc-runtime.h
+    cp runtime/Object.h                  build/include/objc/Object.h
+    cp runtime/Protocol.h                build/include/objc/Protocol.h
+    cp runtime/runtime.h                 build/include/objc/runtime.h
+    cp runtime/NSObject.h                build/include/objc/NSObject.h
+    cp runtime/NSObjCRuntime.h           build/include/objc/NSObjCRuntime.h
+
+    # These would normally be in local/include but we don't do local, so they're
+    # going in with the others
+    cp runtime/maptable.h                build/include/objc/maptable.h
+    cp runtime/objc-abi.h                build/include/objc/objc-abi.h
+    cp runtime/objc-auto-dump.h          build/include/objc/objc-auto-dump.h
+    cp runtime/objc-gdb.h                build/include/objc/objc-gdb.h
+    cp runtime/objc-internal.h           build/include/objc/objc-internal.h
+
+    cc -o markgc markgc.c
+
+    FLAGS="-Wno-deprecated-register -Wno-unknown-pragmas -Wno-deprecated-objc-isa-usage -Wno-invalid-offsetof -Wno-inline-new-delete  -Wno-cast-of-sel-type -Iruntime -Ibuild/include -Iruntime/Accessors.subproj -D_LIBCPP_VISIBLE= -DOS_OBJECT_USE_OBJC=0 -DNDEBUG=1"
+
+    cc -std=gnu++11 $FLAGS -c runtime/hashtable2.mm
+    cc -std=gnu++11 $FLAGS -c runtime/maptable.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-auto.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-cache.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-class-old.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-class.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-errors.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-exception.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-file.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-initialize.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-layout.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-load.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-loadmethod.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-lockdebug.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-runtime-new.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-runtime-old.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-runtime.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-sel-set.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-sel.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-sync.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-typeencoding.mm
+    cc -std=gnu++11 $FLAGS -c runtime/Object.mm
+    cc -std=gnu++11 $FLAGS -c runtime/Protocol.mm
+
+    cc -std=gnu++11 $FLAGS -c runtime/objc-references.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-os.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-auto-dump.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-file-old.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-block-trampolines.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-externalref.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-weak.mm
+    cc -std=gnu++11 $FLAGS -c runtime/NSObject.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-opt.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-cache-old.mm
+    cc -std=gnu++11 $FLAGS -c runtime/objc-sel-old.mm
+
+    cc -std=gnu++11 $FLAGS -c runtime/Accessors.subproj/objc-accessors.mm
+
+    cc $FLAGS -c runtime/objc-sel-table.s
+
+    cc $FLAGS -c runtime/OldClasses.subproj/List.m
+    cc $FLAGS -c runtime/Messengers.subproj/objc-msg-arm.s
+    cc $FLAGS -c runtime/Messengers.subproj/objc-msg-i386.s
+    cc $FLAGS -c runtime/Messengers.subproj/objc-msg-x86_64.s
+    cc $FLAGS -c runtime/Messengers.subproj/objc-msg-simulator-i386.s
+
+    cc $FLAGS -c runtime/a1a2-blocktramps-i386.s
+    cc $FLAGS -c runtime/a2a3-blocktramps-i386.s
+
+    cc $FLAGS -c runtime/a1a2-blocktramps-x86_64.s
+    cc $FLAGS -c runtime/a2a3-blocktramps-x86_64.s
+
+    cc $FLAGS -c runtime/a1a2-blocktramps-arm.s
+    cc $FLAGS -c runtime/a2a3-blocktramps-arm.s
+
+    c++ -Wl,-no_dtrace_dof --stdlib=libc++ -dynamiclib -lauto -install_name $out/lib/libobjc.dylib -o libobjc.dylib *.o
+
+    ./markgc -p libobjc.dylib
+  '';
+
+  installPhase = ''
+    mkdir -p $out/include $out/lib
+
+    mv build/include/objc $out/include
+    mv libobjc.dylib $out/lib
+  '';
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/objc4/spinlocks.patch b/pkgs/os-specific/darwin/apple-source-releases/objc4/spinlocks.patch
new file mode 100644
index 000000000000..50c6a983fe4d
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/objc4/spinlocks.patch
@@ -0,0 +1,107 @@
+--- objc4-551.1/runtime/objc-os.h	2013-06-10 21:16:15.000000000 -0400
++++ ../objc4-551.1/runtime/objc-os.h	2015-01-19 01:01:36.000000000 -0500
+@@ -77,27 +77,72 @@
+ #   include <mach-o/getsect.h>
+ #   include <mach-o/dyld_priv.h>
+ #   include <malloc/malloc.h>
+-#   include <os/lock_private.h>
+ #   include <libkern/OSAtomic.h>
+ #   include <libkern/OSCacheControl.h>
+-#   include <System/pthread_machdep.h>
+ #   include "objc-probes.h"  // generated dtrace probe definitions.
+ 
++#define __PTK_FRAMEWORK_OBJC_KEY5 45
++#define __PTK_FRAMEWORK_OBJC_KEY6 46
++#define __PTK_FRAMEWORK_OBJC_KEY7 47
++#define __PTK_FRAMEWORK_OBJC_KEY8 48
++#define __PTK_FRAMEWORK_OBJC_KEY9 49
++
++extern "C" int pthread_key_init_np(int, void (*)(void *));
++
+ // Some libc functions call objc_msgSend() 
+ // so we can't use them without deadlocks.
+ void syslog(int, const char *, ...) UNAVAILABLE_ATTRIBUTE;
+ void vsyslog(int, const char *, va_list) UNAVAILABLE_ATTRIBUTE;
+ 
++#if defined(__i386__) || defined(__x86_64__)
++
++// Inlined spinlock.
++// Not for arm on iOS because it hurts uniprocessor performance.
++
++#define ARR_SPINLOCK_INIT 0
++// XXX -- Careful: OSSpinLock isn't volatile, but should be
++typedef volatile int ARRSpinLock;
++__attribute__((always_inline))
++static inline void ARRSpinLockLock(ARRSpinLock *l)
++{
++    unsigned y;
++again:
++    if (__builtin_expect(__sync_lock_test_and_set(l, 1), 0) == 0) {
++        return;
++    }
++    for (y = 1000; y; y--) {
++#if defined(__i386__) || defined(__x86_64__)
++        asm("pause");
++#endif
++        if (*l == 0) goto again;
++    }
++    thread_switch(THREAD_NULL, SWITCH_OPTION_DEPRESS, 1);
++    goto again;
++}
++__attribute__((always_inline))
++static inline void ARRSpinLockUnlock(ARRSpinLock *l)
++{
++    __sync_lock_release(l);
++}
++__attribute__((always_inline))
++static inline int ARRSpinLockTry(ARRSpinLock *l)
++{
++    return __sync_bool_compare_and_swap(l, 0, 1);
++}
++
++#define spinlock_t ARRSpinLock
++#define spinlock_trylock(l) ARRSpinLockTry(l)
++#define spinlock_lock(l) ARRSpinLockLock(l)
++#define spinlock_unlock(l) ARRSpinLockUnlock(l)
++#define SPINLOCK_INITIALIZER ARR_SPINLOCK_INIT 
+ 
+-#define spinlock_t os_lock_handoff_s
+-#define spinlock_trylock(l) os_lock_trylock(l)
+-#define spinlock_lock(l) os_lock_lock(l)
+-#define spinlock_unlock(l) os_lock_unlock(l)
+-#define SPINLOCK_INITIALIZER OS_LOCK_HANDOFF_INIT
++#endif
+ 
+ 
+ #if !TARGET_OS_IPHONE
+-#   include <CrashReporterClient.h>
++#define CRSetCrashLogMessage(msg)
++#define CRGetCrashLogMessage() 0
++#define CRSetCrashLogMessage2(msg)
+ #else
+     // CrashReporterClient not yet available on iOS
+     __BEGIN_DECLS
+@@ -594,21 +639,13 @@
+ { 
+     assert(is_valid_direct_key(k));
+ 
+-    if (_pthread_has_direct_tsd()) {
+-        return _pthread_getspecific_direct(k);
+-    } else {
+-        return pthread_getspecific(k);
+-    }
++    return pthread_getspecific(k);
+ }
+ static inline void tls_set_direct(tls_key_t k, void *value) 
+ { 
+     assert(is_valid_direct_key(k));
+ 
+-    if (_pthread_has_direct_tsd()) {
+-        _pthread_setspecific_direct(k, value);
+-    } else {
+-        pthread_setspecific(k, value);
+-    }
++    pthread_setspecific(k, value);
+ }
+ 
+ // not arm
diff --git a/pkgs/os-specific/darwin/apple-source-releases/ppp/default.nix b/pkgs/os-specific/darwin/apple-source-releases/ppp/default.nix
new file mode 100644
index 000000000000..ffc19801c5dc
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/ppp/default.nix
@@ -0,0 +1,16 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" "fixupPhase" ];
+
+  installPhase = ''
+    mkdir -p $out/include/ppp
+
+    cp Controller/ppp_msg.h                    $out/include/ppp
+    cp Controller/pppcontroller_types.h        $out/include/ppp
+    cp Controller/pppcontroller_types.h        $out/include
+    cp Controller/pppcontroller.defs           $out/include/ppp
+    cp Controller/pppcontroller_mach_defines.h $out/include
+    cp Controller/PPPControllerPriv.h          $out/include/ppp
+  '';
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/removefile/default.nix b/pkgs/os-specific/darwin/apple-source-releases/removefile/default.nix
new file mode 100644
index 000000000000..315f93bef084
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/removefile/default.nix
@@ -0,0 +1,10 @@
+{ stdenv, appleDerivation }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  installPhase = ''
+    mkdir -p $out/include/
+    cp removefile.h checkint.h $out/include/
+  '';
+}
\ No newline at end of file
diff --git a/pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix b/pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix
new file mode 100644
index 000000000000..8276d2f4b425
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix
@@ -0,0 +1,117 @@
+{ stdenv, appleDerivation, fetchzip, bootstrap_cmds, bison, flex, gnum4, unifdef, perl }:
+
+appleDerivation {
+  phases = [ "unpackPhase" "patchPhase" "installPhase" ];
+
+  buildInputs = [ bootstrap_cmds bison flex gnum4 unifdef perl ];
+
+  patchPhase = ''
+    substituteInPlace Makefile \
+      --replace "/bin/" "" \
+      --replace "MAKEJOBS := " '# MAKEJOBS := '
+
+    substituteInPlace makedefs/MakeInc.cmd \
+      --replace "/usr/bin/" "" \
+      --replace "/bin/" "" \
+      --replace "-Werror " ""
+
+    substituteInPlace makedefs/MakeInc.def \
+      --replace "-c -S -m" "-c -m"
+
+    substituteInPlace makedefs/MakeInc.top \
+      --replace "MEMORY_SIZE := " 'MEMORY_SIZE := 1073741824 # '
+
+    substituteInPlace libkern/kxld/Makefile \
+      --replace "-Werror " ""
+
+    substituteInPlace SETUP/kextsymboltool/Makefile \
+      --replace "-lstdc++" "-lc++"
+
+    substituteInPlace libsyscall/xcodescripts/mach_install_mig.sh \
+      --replace "/usr/include" "/include" \
+      --replace "/usr/local/include" "/include" \
+      --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'
+
+    patchShebangs .
+  '';
+
+  installPhase = ''
+    # This is a bit of a hack...
+    mkdir -p sdk/usr/local/libexec
+
+    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
+      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
+      fi
+    EOF
+    chmod +x sdk/usr/local/libexec/availability.pl
+
+    export SDKROOT_RESOLVED=$PWD/sdk
+    export HOST_SDKROOT_RESOLVED=$PWD/sdk
+    export PLATFORM=MacOSX
+    export SDKVERSION=10.7
+
+    export CC=cc
+    export CXX=c++
+    export MIG=${bootstrap_cmds}/bin/mig
+    export MIGCOM=${bootstrap_cmds}/libexec/migcom
+    export STRIP=sentinel-missing
+    export LIPO=sentinel-missing
+    export LIBTOOL=sentinel-missing
+    export NM=sentinel-missing
+    export UNIFDEF=${unifdef}/bin/unifdef
+    export DSYMUTIL=sentinel-missing
+    export CTFCONVERT=sentinel-missing
+    export CTFMERGE=sentinel-missing
+    export CTFINSERT=sentinel-missing
+    export NMEDIT=sentinel-missing
+
+    export HOST_OS_VERSION=10.7
+    export HOST_CC=cc
+    export HOST_FLEX=${flex}/bin/flex
+    export HOST_BISON=${bison}/bin/bison
+    export HOST_GM4=${gnum4}/bin/m4
+    export HOST_CODESIGN='echo dummy_codesign'
+    export HOST_CODESIGN_ALLOCATE=echo
+
+    export DSTROOT=$out
+    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
+
+    # Build the mach headers we crave
+    export MIGCC=cc
+    export ARCHS="x86_64"
+    export SRCROOT=$PWD/libsyscall
+    export DERIVED_SOURCES_DIR=$out/include
+    export SDKROOT=$out
+    libsyscall/xcodescripts/mach_install_mig.sh
+
+    # Get rid of the System prefix
+    mv $out/System/* $out/
+
+    # Add some symlinks
+    ln -s $out/Library/Frameworks/System.framework/Versions/B \
+          $out/Library/Frameworks/System.framework/Versions/Current
+    ln -s $out/Library/Frameworks/System.framework/Versions/Current/PrivateHeaders \
+          $out/Library/Frameworks/System.framework/Headers
+
+    # IOKit (and possibly the others) is incomplete, so let's not make it visible from here...
+    mkdir $out/Library/PrivateFrameworks
+    mv $out/Library/Frameworks/IOKit.framework $out/Library/PrivateFrameworks
+  '';
+}
diff --git a/pkgs/os-specific/darwin/cctools-port/default.nix b/pkgs/os-specific/darwin/cctools-port/default.nix
deleted file mode 100644
index cdc259c1e2a0..000000000000
--- a/pkgs/os-specific/darwin/cctools-port/default.nix
+++ /dev/null
@@ -1,64 +0,0 @@
-{ stdenv, cross, fetchurl, autoconf, automake, libtool
-, libcxx, llvm, clang, openssl, libuuid
-, maloader, makeWrapper, xctoolchain
-}:
-
-stdenv.mkDerivation rec {
-  name = "cctools-port-${version}";
-  version = "845";
-
-  src = fetchurl {
-    url = "https://github.com/tpoechtrager/cctools-port/archive/"
-        + "cctools-${version}-ld64-136-1.tar.gz";
-    sha256 = "06pg6h1g8avgx4j6cfykdpggf490li796gzhhyqn27jsagli307i";
-  };
-
-  buildInputs = [
-    autoconf automake libtool libcxx llvm clang openssl libuuid makeWrapper
-  ];
-
-  patches = [ ./ld-rpath-nonfinal.patch ./ld-ignore-rpath-link.patch ];
-
-  enableParallelBuilding = true;
-
-  postPatch = ''
-    patchShebangs tools
-    sed -i -e 's/which/type -P/' tools/*.sh
-    sed -i -e 's|clang++|& -I${libcxx}/include/c++/v1|' cctools/autogen.sh
-
-    # Workaround for https://www.sourceware.org/bugzilla/show_bug.cgi?id=11157
-    cat > cctools/include/unistd.h <<EOF
-    #ifdef __block
-    #  undef __block
-    #  include_next "unistd.h"
-    #  define __block __attribute__((__blocks__(byref)))
-    #else
-    #  include_next "unistd.h"
-    #endif
-    EOF
-  '';
-
-  preConfigure = ''
-    cd cctools
-    sh autogen.sh
-  '';
-
-  configureFlags = [
-    "CXXFLAGS=-I${libcxx}/include/c++/v1"
-    "--target=${cross.config}"
-  ];
-
-  postInstall = ''
-    for tool in dyldinfo dwarfdump dsymutil; do
-      makeWrapper "${maloader}/bin/ld-mac" "$out/bin/${cross.config}-$tool" \
-        --add-flags "${xctoolchain}/bin/$tool"
-      ln -s "$out/bin/${cross.config}-$tool" "$out/bin/$tool"
-    done
-  '';
-
-  meta = {
-    homepage = "http://www.opensource.apple.com/source/cctools/";
-    description = "Mac OS X Compiler Tools (cross-platform port)";
-    license = stdenv.lib.licenses.apsl20;
-  };
-}
diff --git a/pkgs/os-specific/darwin/cctools-port/ld-ignore-rpath-link.patch b/pkgs/os-specific/darwin/cctools/ld-ignore-rpath-link.patch
index fc87f69ac32d..fc87f69ac32d 100644
--- a/pkgs/os-specific/darwin/cctools-port/ld-ignore-rpath-link.patch
+++ b/pkgs/os-specific/darwin/cctools/ld-ignore-rpath-link.patch
diff --git a/pkgs/os-specific/darwin/cctools-port/ld-rpath-nonfinal.patch b/pkgs/os-specific/darwin/cctools/ld-rpath-nonfinal.patch
index 265d0d304771..265d0d304771 100644
--- a/pkgs/os-specific/darwin/cctools-port/ld-rpath-nonfinal.patch
+++ b/pkgs/os-specific/darwin/cctools/ld-rpath-nonfinal.patch
diff --git a/pkgs/os-specific/darwin/cctools/port.nix b/pkgs/os-specific/darwin/cctools/port.nix
new file mode 100644
index 000000000000..bfb389ef37cf
--- /dev/null
+++ b/pkgs/os-specific/darwin/cctools/port.nix
@@ -0,0 +1,102 @@
+{ stdenv, fetchurl, autoconf, automake, libtool
+, llvm, libcxx, libcxxabi, clang, openssl, libuuid
+, libobjc ? null
+}:
+
+let
+  baseParams = rec {
+    name = "cctools-port-${version}";
+    version = "862";
+
+    src = let
+      # Should be fetchFromGitHub but it was whining so this will do for now
+      owner  = "tpoechtrager";
+      repo   = "cctools-port";
+      rev    = "59d21d2c793c51d205c8b4ab14b9b28e63c72445";
+    in fetchurl {
+      url    = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
+      sha256 = "01f31ijpnplbiyp7ldwzy8vbkn3j3m56n5blsvsav5nlp4lp2g71";
+    };
+
+    buildInputs = [ autoconf automake libtool openssl libuuid ] ++
+      # Only need llvm and clang if the stdenv isn't already clang-based (TODO: just make a stdenv.cc.isClang)
+      stdenv.lib.optionals (!stdenv.isDarwin) [ llvm clang ] ++
+      stdenv.lib.optionals stdenv.isDarwin [ libcxxabi libobjc ];
+
+    patches = [
+      ./ld-rpath-nonfinal.patch ./ld-ignore-rpath-link.patch
+    ];
+
+    enableParallelBuilding = true;
+
+    configureFlags = stdenv.lib.optionals (!stdenv.isDarwin) [ "CXXFLAGS=-I${libcxx}/include/c++/v1" ];
+
+    postPatch = ''
+      sed -i -e 's/addStandardLibraryDirectories = true/addStandardLibraryDirectories = false/' cctools/ld64/src/ld/Options.cpp
+
+      # FIXME: there are far more absolute path references that I don't want to fix right now
+      substituteInPlace cctools/configure.ac \
+        --replace "-isystem /usr/local/include -isystem /usr/pkg/include" "" \
+        --replace "-L/usr/local/lib" "" \
+
+      substituteInPlace cctools/include/Makefile \
+        --replace "/bin/" ""
+
+      patchShebangs tools
+      sed -i -e 's/which/type -P/' tools/*.sh
+
+      # Workaround for https://www.sourceware.org/bugzilla/show_bug.cgi?id=11157
+      cat > cctools/include/unistd.h <<EOF
+      #ifdef __block
+      #  undef __block
+      #  include_next "unistd.h"
+      #  define __block __attribute__((__blocks__(byref)))
+      #else
+      #  include_next "unistd.h"
+      #endif
+      EOF
+    '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+      sed -i -e 's|clang++|& -I${libcxx}/include/c++/v1|' cctools/autogen.sh
+    '';
+
+    preConfigure = ''
+      cd cctools
+      sh autogen.sh
+    '';
+
+    preInstall = ''
+      pushd include
+      make DSTROOT=$out/include RC_OS=common install
+      popd
+    '';
+
+    meta = {
+      homepage = "http://www.opensource.apple.com/source/cctools/";
+      description = "Mac OS X Compiler Tools (cross-platform port)";
+      license = stdenv.lib.licenses.apsl20;
+    };
+  };
+in {
+  native = stdenv.mkDerivation (baseParams // {
+    # A hack for now...
+    postInstall = ''
+      cat >$out/bin/dsymutil << EOF
+      #!${stdenv.shell}
+      EOF
+      chmod +x $out/bin/dsymutil
+    '';
+  });
+
+  cross =
+    { cross, maloader, makeWrapper, xctoolchain}: stdenv.mkDerivation (baseParams // {
+      configureFlags = baseParams.configureFlags ++ [ "--target=${cross.config}" ];
+
+      postInstall = ''
+        for tool in dyldinfo dwarfdump dsymutil; do
+          ${makeWrapper}/bin/makeWrapper "${maloader}/bin/ld-mac" "$out/bin/${cross.config}-$tool" \
+            --add-flags "${xctoolchain}/bin/$tool"
+          ln -s "$out/bin/${cross.config}-$tool" "$out/bin/$tool"
+        done
+      '';
+    });
+}
diff --git a/pkgs/os-specific/darwin/command-line-tools/default.nix b/pkgs/os-specific/darwin/command-line-tools/default.nix
index a4ac20fa0851..c437c76cfd6a 100644
--- a/pkgs/os-specific/darwin/command-line-tools/default.nix
+++ b/pkgs/os-specific/darwin/command-line-tools/default.nix
@@ -1,71 +1,43 @@
-{ stdenv, fetchadc, xar, gzip, cpio }:
+{ stdenv, fetchurl, xar, gzip, cpio }:
 
 let
-  name = "command-line-tools-mac-os-10.9";
-
-  pkg = { installPhase }: stdenv.mkDerivation {
-    name = "${name}.pkg";
-
-    phases = [ "installPhase" ];
-
-    inherit installPhase;
+  pkg = { name, sha256 }: stdenv.mkDerivation {
+    inherit name;
 
-    meta = with stdenv.lib; {
-      description = "Developer tools .pkg file";
-      maintainers = with maintainers; [ copumpkin ];
-      platforms   = platforms.darwin;
-      license     = licenses.unfree;
+    src = fetchurl {
+      url = "http://swcdn.apple.com/content/downloads/00/14/031-07556/i7hoqm3awowxdy48l34uel4qvwhdq8lgam/${name}.pkg";
+      inherit sha256;
     };
-  };
 
-  basic = pkg: stdenv.mkDerivation {
-    inherit name;
+    buildInputs = [ xar gzip cpio ];
 
     phases = [ "unpackPhase" "installPhase" ];
 
-    outputs = [ "sdk" "tools" ];
-
     unpackPhase = ''
-      ${xar}/bin/xar -x -f "${pkg}"
+      xar -x -f $src
     '';
 
     installPhase = ''
       start="$(pwd)"
-      mkdir -p $sdk
-      mkdir -p $tools
-
-      cd $sdk
-      cat $start/DevSDK_OSX109.pkg/Payload | ${gzip}/bin/gzip -d | ${cpio}/bin/cpio -idm
-
-      cd $tools
-      cat $start/CLTools_Executables.pkg/Payload | ${gzip}/bin/gzip -d | ${cpio}/bin/cpio -idm
+      mkdir -p $out
+      cd $out
+      cat $start/Payload | gzip -d | cpio -idm
     '';
 
     meta = with stdenv.lib; {
-      description = "Mac OS command-line developer tools and SDK";
+      description = "Apple developer tools ${name}";
       maintainers = with maintainers; [ copumpkin ];
       platforms   = platforms.darwin;
-      license     = licenses.unfree;
     };
   };
 in rec {
-  dmg = fetchadc {
-    # Isn't this a beautiful path? Note the subtle differences before and after the slash!
-    path   = "Developer_Tools/command_line_tools_os_x_10.9_for_xcode__xcode_6/command_line_tools_for_os_x_10.9_for_xcode_6.dmg";
-    sha256 = "0zrpf73r3kfk9pdh6p6j6w1sbw7s2pp0f8rd83660r5hk1y3j5jc";
+  tools = pkg {
+    name   = "CLTools_Executables";
+    sha256 = "1rqrgip9pwr9d6p1hkd027lzxpymr1qm54jjnkldjjb8m4nps7bp";
   };
 
-  pure = { xpwn }: basic (pkg {
-    installPhase = ''
-      ${xpwn}/bin/hdutil ${dmg} extract "Command Line Tools (OS X 10.9).pkg" $out
-    '';
-  });
-
-  impure = basic (pkg {
-    installPhase = ''
-      /usr/bin/hdiutil attach ${dmg} -mountpoint clt-mount -nobrowse
-      cp "clt-mount/Command Line Tools (OS X 10.9).pkg" $out
-      /usr/bin/hdiutil unmount clt-mount
-    '';
-  });
+  sdk = pkg {
+    name   = "DevSDK_OSX109";
+    sha256 = "0x6r61h78r5cxk9dbw6fnjpn6ydi4kcajvllpczx3mi52crlkm4x";
+  };
 }
diff --git a/pkgs/os-specific/darwin/libc/default.nix b/pkgs/os-specific/darwin/libc/default.nix
new file mode 100644
index 000000000000..4d01434c3b9f
--- /dev/null
+++ b/pkgs/os-specific/darwin/libc/default.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchurl, fetchgit, fetchzip, perl, python }:
+
+let
+  osx_sdk = fetchgit {
+    url = "https://github.com/samdmarshall/OSXPrivateSDK";
+    rev = "refs/heads/master";
+    sha256 = "04m71xhjyac42h7alxjsqsipq07hm85wibvm3h65dqafcbqkl1i1";
+  };
+  dispatch = fetchzip {
+    url = "https://opensource.apple.com/tarballs/libdispatch/libdispatch-339.92.1.tar.gz";
+    sha256 = "0faxm4r7lamz57m9pr72jwm0qiwcrcy5dsiff0g9qyfi10pnj5i4";
+  };
+in
+stdenv.mkDerivation rec {
+  version = "825.40.1";
+  name = "libc-${version}";
+  src = fetchurl {
+    url = "https://opensource.apple.com/tarballs/Libc/Libc-${version}.tar.gz";
+    sha256 = "0xsx1im52gwlmcrv4lnhhhn9dyk5ci6g27k6yvibn9vj8fzjxwcf";
+  };
+
+  buildInputs = [ perl ];
+
+  patches = [ ./fileport.patch ];
+
+  configurePhase = ''
+    mkdir -p scratch
+    mkdir -p scratch/System/sys
+    ln -sv ${osx_sdk}/System/Library/Frameworks/System.framework/PrivateHeaders/sys/fsctl.h scratch/System/sys
+    mkdir tmpbin
+    ln -s /usr/bin/xcodebuild tmpbin
+    ln -s /usr/sbin/dtrace tmpbin
+    export PATH=$PATH:$(pwd -P)/tmpbin
+  '';
+
+  buildPhase = ''
+    BASE=$(pwd -P)
+    xcodebuild HEADER_SEARCH_PATHS="$BASE/fbsdcompat $BASE/pthreads $BASE/include $BASE/locale $BASE/locale/FreeBSD ${osx_sdk}/usr/local/include ${osx_sdk}/usr/include $BASE/stdtime/FreeBSD $BASE/gen ${osx_sdk}/System/Library/Frameworks/System.framework/PrivateHeaders $BASE/scratch ${osx_sdk}/System/Library/Frameworks/System.framework/PrivateHeaders/uuid $BASE/gdtoa"
+  '';
+}
diff --git a/pkgs/os-specific/darwin/libc/fileport.patch b/pkgs/os-specific/darwin/libc/fileport.patch
new file mode 100644
index 000000000000..968b0da9d30f
--- /dev/null
+++ b/pkgs/os-specific/darwin/libc/fileport.patch
@@ -0,0 +1,38 @@
+diff --git a/Platforms/macosx/Makefile.inc b/Platforms/macosx/Makefile.inc
+index ff3617f..fdda58f 100644
+--- a/Platforms/macosx/Makefile.inc
++++ b/Platforms/macosx/Makefile.inc
+@@ -41,7 +41,7 @@ FEATURE_PATCH_3417676 = 1
+ FEATURE_PATCH_5243343 = 1
+ 
+ # plockstat dtrace support
+-FEATURE_PLOCKSTAT = 1
++FEATURE_PLOCKSTAT = 0
+ 
+ # Timezone change notification
+ FEATURE_TIMEZONE_CHANGE_NOTIFICATION = 1
+diff --git a/gen/asl.c b/gen/asl.c
+index 1948c92..53fce02 100644
+--- a/gen/asl.c
++++ b/gen/asl.c
+@@ -35,6 +35,7 @@
+ #include <time.h>
+ #include <sys/time.h>
+ #include <sys/fcntl.h>
++#include <sys/fileport.h>
+ #include <crt_externs.h>
+ #include <asl.h>
+ #include <regex.h>
+diff --git a/locale/FreeBSD/toupper.c b/locale/FreeBSD/toupper.c
+index d02ddd6..e5a1f10 100644
+--- a/locale/FreeBSD/toupper.c
++++ b/locale/FreeBSD/toupper.c
+@@ -39,6 +39,8 @@ __FBSDID("$FreeBSD: src/lib/libc/locale/toupper.c,v 1.13 2007/01/09 00:28:01 imp
+ #include <stdio.h>
+ #include <runetype.h>
+ 
++#define __ct_rune_t ct_rune_t
++
+ __ct_rune_t
+ ___toupper_l(c, loc)
+ 	__ct_rune_t c;
diff --git a/pkgs/os-specific/linux/afuse/default.nix b/pkgs/os-specific/linux/afuse/default.nix
index 70c8f36105c7..4cf533110705 100644
--- a/pkgs/os-specific/linux/afuse/default.nix
+++ b/pkgs/os-specific/linux/afuse/default.nix
@@ -1,18 +1,18 @@
-{ stdenv, fetchurl, pkgconfig, fuse }:
+{ stdenv, fetchurl, pkgconfig, autoreconfHook, fuse }:
 
 stdenv.mkDerivation {
-  name = "afuse-0.2";
+  name = "afuse-0.4.1";
 
   src = fetchurl {
-    url = mirror://sourceforge/afuse/0.2/afuse-0.2.tar.gz;
-    sha256 = "1lj2jdks0bgwxbjqp5a9f7qdry19kar6pg7dh1ml98gapx9siylj";
+    url = https://github.com/pcarrier/afuse/archive/v0.4.1.tar.gz;
+    sha256 = "1sfhicmxppkvdd4z9klfn63snb71gr9hff6xij1gzk94xg6m0ycc";
   };
 
-  buildInputs = [ pkgconfig fuse ];
+  buildInputs = [ autoreconfHook pkgconfig fuse ];
 
-  meta = { 
+  meta = {
     description = "Automounter in userspace";
-    homepage = http://sourceforge.net/projects/afuse;
+    homepage = https://github.com/pcarrier/afuse;
     license = stdenv.lib.licenses.gpl2;
     maintainers = [ stdenv.lib.maintainers.marcweber ];
     platforms = stdenv.lib.platforms.linux;
diff --git a/pkgs/os-specific/linux/android-udev-rules/default.nix b/pkgs/os-specific/linux/android-udev-rules/default.nix
new file mode 100644
index 000000000000..534ba9970043
--- /dev/null
+++ b/pkgs/os-specific/linux/android-udev-rules/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchgit }:
+
+stdenv.mkDerivation {
+  name = "android-udev-rules";
+
+  src = fetchgit {
+    url = "git://github.com/M0Rf30/android-udev-rules";
+    rev = "82f78561f388363a925e6663211988d9527de0c6";
+    sha256 = "badd7a152acf92c75335917c07125ffb1b5fda0bed5ec1e474d76e48a8d9f0db";
+  };
+
+  installPhase = ''
+    install -D 51-android.rules $out/lib/udev/rules.d/51-android.rules
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/M0Rf30/android-udev-rules;
+    description = "Android udev rules list aimed to be the most comprehensive on the net";
+    platforms = platforms.linux;
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ abbradar ];
+  };
+}
diff --git a/pkgs/os-specific/linux/ati-drivers/default.nix b/pkgs/os-specific/linux/ati-drivers/default.nix
index 4f64b1358324..179166bbc79a 100644
--- a/pkgs/os-specific/linux/ati-drivers/default.nix
+++ b/pkgs/os-specific/linux/ati-drivers/default.nix
@@ -36,7 +36,7 @@ stdenv.mkDerivation {
   builder = ./builder.sh;
 
   inherit libXxf86vm xf86vidmodeproto;
-  gcc = stdenv.cc.gcc;
+  gcc = stdenv.cc.cc;
 
   src = fetchurl {
     url = http://www2.ati.com/drivers/linux/amd-catalyst-omega-14.12-linux-run-installers.zip;
diff --git a/pkgs/os-specific/linux/batman-adv/alfred.nix b/pkgs/os-specific/linux/batman-adv/alfred.nix
new file mode 100644
index 000000000000..2d9f5079586c
--- /dev/null
+++ b/pkgs/os-specific/linux/batman-adv/alfred.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchurl, pkgconfig, gpsd }:
+
+let
+  ver = "2014.4.0";
+in
+stdenv.mkDerivation rec {
+  name = "alfred-${ver}";
+
+  src = fetchurl {
+    url = "http://downloads.open-mesh.org/batman/releases/batman-adv-${ver}/${name}.tar.gz";
+    sha256 = "99e6c64e7069b0b7cb861369d5c198bfc7d74d41509b8edd8a17ba78e7c8d034";
+  };
+
+  buildInputs = [ pkgconfig gpsd ];
+
+  preBuild = ''
+    makeFlags="PREFIX=$out PKG_CONFIG=${pkgconfig}/bin/pkg-config"
+  '';
+
+  meta = {
+    homepage = http://www.open-mesh.org/projects/batman-adv/wiki/Wiki;
+    description = "B.A.T.M.A.N. routing protocol in a linux kernel module for layer 2, information distribution tool";
+    license = stdenv.lib.licenses.gpl2;
+    maintainers = with stdenv.lib.maintainers; [ fpletz ];
+    platforms = with stdenv.lib.platforms; linux;
+  };
+}
diff --git a/pkgs/os-specific/linux/batman-adv/batctl.nix b/pkgs/os-specific/linux/batman-adv/batctl.nix
index 6e57e7651c45..5ac3e6b4117f 100644
--- a/pkgs/os-specific/linux/batman-adv/batctl.nix
+++ b/pkgs/os-specific/linux/batman-adv/batctl.nix
@@ -1,14 +1,14 @@
 {stdenv, fetchurl}:
 
 let
-  ver = "2013.4.0";
+  ver = "2014.4.0";
 in
 stdenv.mkDerivation rec {
   name = "batctl-${ver}";
 
   src = fetchurl {
     url = "http://downloads.open-mesh.org/batman/releases/batman-adv-${ver}/${name}.tar.gz";
-    sha256 = "0k6b695h38m92a8wn5gvb3z746m3fm0ygv58yyn163adcsvf7sjd";
+    sha256 = "4deae3b6664d0d13acf7a8ece74175a31a72fe58fb15cb9112a9a2014b32cb4c";
   };
 
   preBuild = ''
diff --git a/pkgs/os-specific/linux/batman-adv/default.nix b/pkgs/os-specific/linux/batman-adv/default.nix
index 8407f270f484..341b6f3af1d5 100644
--- a/pkgs/os-specific/linux/batman-adv/default.nix
+++ b/pkgs/os-specific/linux/batman-adv/default.nix
@@ -2,14 +2,14 @@
 
 assert stdenv.lib.versionOlder kernel.version "3.17";
 
-let base = "batman-adv-2014.3.0"; in
+let base = "batman-adv-2014.4.0"; in
 
 stdenv.mkDerivation rec {
   name = "${base}-${kernel.version}";
 
   src = fetchurl {
     url = "http://downloads.open-mesh.org/batman/releases/${base}/${base}.tar.gz";
-    sha1 = "wh3if8v4wfwskvzwqsjsyr929krzfmsx";
+    sha256 = "757b9ddd346680f6fd87dc28fde6da0ddc0423a65fbc88fdbaa7b247fed2c1a8";
   };
 
   preBuild = ''
@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
     homepage = http://www.open-mesh.org/projects/batman-adv/wiki/Wiki;
     description = "B.A.T.M.A.N. routing protocol in a linux kernel module for layer 2";
     license = stdenv.lib.licenses.gpl2;
-    maintainers = with stdenv.lib.maintainers; [viric];
+    maintainers = with stdenv.lib.maintainers; [ viric fpletz ];
     platforms = with stdenv.lib.platforms; linux;
   };
 }
diff --git a/pkgs/os-specific/linux/cifs-utils/default.nix b/pkgs/os-specific/linux/cifs-utils/default.nix
index 0183a606b2e1..46a927209a23 100644
--- a/pkgs/os-specific/linux/cifs-utils/default.nix
+++ b/pkgs/os-specific/linux/cifs-utils/default.nix
@@ -1,18 +1,21 @@
-{ stdenv, fetchurl }:
+{ stdenv, fetchurl, kerberos, keyutils, pam }:
 
 stdenv.mkDerivation rec {
   name = "cifs-utils-6.4";
 
   src = fetchurl {
-    url = "ftp://ftp.samba.org/pub/linux-cifs/cifs-utils/${name}.tar.bz2";
+    url = "mirror://samba/pub/linux-cifs/cifs-utils/${name}.tar.bz2";
     sha256 = "1qz6d2xg4z1if0hy7qwyzgcr59l0alkhci6gxgjdldglda967z1q";
   };
 
+  buildInputs = [ kerberos keyutils pam ];
+
   makeFlags = "root_sbindir=$(out)/sbin";
 
-  meta = {
+  meta = with stdenv.lib; {
     homepage = http://www.samba.org/linux-cifs/cifs-utils/;
     description = "Tools for managing Linux CIFS client filesystems";
-    platforms = stdenv.lib.platforms.linux;
+    platforms = platforms.linux;
+    license = licenses.lgpl3;
   };
 }
diff --git a/pkgs/os-specific/linux/consoletools/default.nix b/pkgs/os-specific/linux/consoletools/default.nix
index 83c694972e60..6961768e7d32 100644
--- a/pkgs/os-specific/linux/consoletools/default.nix
+++ b/pkgs/os-specific/linux/consoletools/default.nix
@@ -2,20 +2,22 @@
 
 stdenv.mkDerivation rec {
   name = "linuxconsoletools-${version}";
-  version = "1.4.7";
+  version = "1.4.8";
 
   src = fetchurl {
     url = "mirror://sourceforge/linuxconsole/${name}.tar.bz2";
-    sha256 = "1wgcmmjiqw3hh36jzvhgq07kq13ar2miafz02xshds2b0kdcz4s4";
+    sha256 = "0spf9hx48cqx2i46pkz0gbrn7xrk68cw8iyrfbs2b3k0bxcsri13";
   };
 
   buildInputs = [ SDL ];
-  makeFlags = [ "PREFIX=$(out)" ];
+  makeFlags = [ "DESTDIR=$(out)"];
 
-  meta = {
-    homepage = "https://sourceforge.net/projects/linuxconsole/";
+  meta = with stdenv.lib; {
+    homepage = https://sourceforge.net/projects/linuxconsole/;
     description = "A set of tools for joysticks and serial peripherals";
-    license = stdenv.lib.licenses.gpl2Plus;
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ pSub ];
 
     longDescription = ''
       The included tools are:
diff --git a/pkgs/os-specific/linux/dmtcp/default.nix b/pkgs/os-specific/linux/dmtcp/default.nix
index c863be14461c..fea41affe2c4 100644
--- a/pkgs/os-specific/linux/dmtcp/default.nix
+++ b/pkgs/os-specific/linux/dmtcp/default.nix
@@ -4,28 +4,30 @@
 stdenv.mkDerivation rec {
   name = "dmtcp-${version}";
 
-  version = "1.2.0";
+  version = "2.3.1";
 
   buildInputs = [ perl python ];
 
   src = fetchurl {
-    url = "mirror://sourceforge/dmtcp/dmtcp_${version}.tar.gz";
-    sha256 = "1pw3m4l1xf887xagd0yrrnb35s372j0kvjziyy3gmx9fxpga1jzb";
+    url = "mirror://sourceforge/dmtcp/dmtcp-${version}.tar.gz";
+    sha256 = "1f83ae112e102d4fbf69dded0dfaa6daeb60c4c0c569297553785a876e95ba15";
   };
 
   preConfigure = ''
-    substituteInPlace dmtcp/src/dmtcp_coordinator.cpp \
-      --replace /bin/bash /bin/sh
-    substituteInPlace utils/gdb-add-symbol-file \
-      --replace /bin/bash /bin/sh
+    substituteInPlace src/dmtcp_coordinator.cpp \
+      --replace /bin/bash ${stdenv.shell}
+    substituteInPlace util/gdb-add-symbol-file \
+      --replace /bin/bash ${stdenv.shell}
     substituteInPlace test/autotest.py \
       --replace /usr/bin/env $(type -p env) \
       --replace /bin/bash $(type -p bash) \
       --replace /usr/bin/perl $(type -p perl) \
-      --replace /usr/bin/python $(type -p python)
+      --replace /usr/bin/python $(type -p python) \
+      --replace "os.environ['USER']" "\"nixbld1\"" \
+      --replace "os.getenv('USER')" "\"nixbld1\""
   '';
 
-  doCheck = true;
+  doCheck = false;
 
   meta = {
     description = "Distributed MultiThreaded Checkpointing";
@@ -36,6 +38,6 @@ stdenv.mkDerivation rec {
       not modify the user's program or the operating system.
     '';
     homepage = http://dmtcp.sourceforge.net/;
-    license = "LGPL";
+    license = stdenv.lib.licenses.lgpl3Plus; # most files seem this or LGPL-2.1+
   };
 }
diff --git a/pkgs/os-specific/linux/firejail/default.nix b/pkgs/os-specific/linux/firejail/default.nix
index 9f3397fc8efd..c2d95c3d5354 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.18";
+    version="0.9.20";
     name="${baseName}-${version}";
-    hash="0qsjbnx9xzvzcbq7wdcf51v5abi4ml9jsai7w6xmns51qx4325a2";
-    url="mirror://sourceforge/project/firejail/firejail/firejail-0.9.18-rc1.tar.bz2";
-    sha256="0qsjbnx9xzvzcbq7wdcf51v5abi4ml9jsai7w6xmns51qx4325a2";
+    hash="1sjahmpjd6zmn27xp5xl683xm3353rp3094sgl2brq6477ffbi6y";
+    url="mirror://sourceforge/project/firejail/firejail/firejail-0.9.20-rc1.tar.bz2";
+    sha256="1sjahmpjd6zmn27xp5xl683xm3353rp3094sgl2brq6477ffbi6y";
   };
   buildInputs = [
   ];
diff --git a/pkgs/os-specific/linux/firmware/iwlegacy/default.nix b/pkgs/os-specific/linux/firmware/iwlegacy/default.nix
index 48472c96659c..99524e4504e9 100644
--- a/pkgs/os-specific/linux/firmware/iwlegacy/default.nix
+++ b/pkgs/os-specific/linux/firmware/iwlegacy/default.nix
@@ -12,7 +12,7 @@ let
   fetchPackage =
     { name, sha256 }: fetchurl {
       name = "iwlwifi-${name}.tgz";
-      url = "http://wireless.kernel.org/en/users/Drivers/iwlegacy?action=AttachFile&do=get&target=iwlwifi-${name}.tgz";
+      url = "https://wireless.wiki.kernel.org/_media/en/users/drivers/iwlwifi-${name}.tgz";
       inherit sha256;
     };
 
diff --git a/pkgs/os-specific/linux/firmware/iwlwifi/default.nix b/pkgs/os-specific/linux/firmware/iwlwifi/default.nix
index f6df3bb50f42..a0236fc3c996 100644
--- a/pkgs/os-specific/linux/firmware/iwlwifi/default.nix
+++ b/pkgs/os-specific/linux/firmware/iwlwifi/default.nix
@@ -39,16 +39,15 @@ let
     { name = "7265-ucode-25.228.9.0"; sha256 = "1dv9bai1s6vdigsahbrxjwlndnp2dsgkqz8j7021d34s99kbi6z8"; }
 
     # Kernel 3.17+
-    { name = "7260-ucode-23.10.10.0"; sha256 = "0n8blgwj3765zyripgbawbi3h97qyficdv72mmzf8hznk30p6kxg"; }
-    { name = "3160-ucode-23.10.10.0"; sha256 = "0332j710495980avzvhjixnr6f4f8v0srpnqn05x1q0c9sw6n7pp"; }
-    # Bad archive, assumed a problem with the served blob
-    #{ name = "7265-ucode-23.10.10.0"; sha256 = "1v2q9b3dah1p4mnmvv1blvi9awjcbiafmjyll5hi1hr6p28xwhva"; }
+    { name = "7260-ucode-23.11.10.0"; sha256 = "1d9w7kd3h3632qmwb44943lxdafjn3ii8ha9wdvqri3b8fjfn7sa"; }
+    { name = "3160-ucode-23.11.10.0"; sha256 = "0ijpgfzz8735rsbkc6mvk3w7f1v9rr9dgy1l79vzmzc1vh2zpbdm"; }
+    { name = "7265-ucode-23.11.10.0"; sha256 = "1az8nq6z1ns1220309wp8jq1sc5flz2ac5k41pgj50503h54rlvi"; }
   ];
 
   fetchPackage =
     { name, sha256 }: fetchurl {
       name = "iwlwifi-${name}.tgz";
-      url = "http://wireless.kernel.org/en/users/Drivers/iwlwifi?action=AttachFile&do=get&target=iwlwifi-${name}.tgz";
+      url = "https://wireless.wiki.kernel.org/_media/en/users/drivers/iwlwifi-${name}.tgz";
       inherit sha256;
     };
 
diff --git a/pkgs/os-specific/linux/firmware/zd1211/default.nix b/pkgs/os-specific/linux/firmware/zd1211/default.nix
index cb4466dc20f4..96e534e3b805 100644
--- a/pkgs/os-specific/linux/firmware/zd1211/default.nix
+++ b/pkgs/os-specific/linux/firmware/zd1211/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   pname = "zd1211-firmware";
-  version = "1.4";
+  version = "1.5";
 
   name = "${pname}-${version}";
   
   src = fetchurl {
     url = "mirror://sourceforge/zd1211/${name}.tar.bz2";
-    sha256 = "866308f6f59f7075f075d4959dff2ede47735c751251fecd1496df1ba4d338e1";
+    sha256 = "04ibs0qw8bh6h6zmm5iz6lddgknwhsjq8ib3gyck6a7psw83h7gi";
   };
   
   buildPhase = "true";
diff --git a/pkgs/os-specific/linux/flashbench/default.nix b/pkgs/os-specific/linux/flashbench/default.nix
new file mode 100644
index 000000000000..0a6364f07df5
--- /dev/null
+++ b/pkgs/os-specific/linux/flashbench/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchgit }:
+
+stdenv.mkDerivation rec {
+  name = "flashbench-${version}";
+  version = "2012-06-06";
+
+  src = fetchgit {
+    url = "https://github.com/bradfa/flashbench.git";
+    rev = "2e30b1968a66147412f21002ea844122a0d5e2f0";
+    sha256 = "037rhd2alwfip9qk78cy8fwwnc2kdyzccsyc7v2zpmvl4vvpvnhg";
+  };
+
+  installPhase = ''
+    install -d -m755 $out/bin $out/share/doc/flashbench
+    install -v -m755 flashbench $out/bin
+    install -v -m755 erase $out/bin/flashbench-erase
+    install -v -m644 README $out/share/doc/flashbench
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Testing tool for flash based memory devices";
+    homepage = https://github.com/bradfa/flashbench;
+    platforms = platforms.linux;
+    license = licenses.gpl2;
+    maintainers = [ maintainers.rycee ];
+  };
+}
diff --git a/pkgs/os-specific/linux/freefall/default.nix b/pkgs/os-specific/linux/freefall/default.nix
new file mode 100644
index 000000000000..9903cb5b963d
--- /dev/null
+++ b/pkgs/os-specific/linux/freefall/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  version = "3.18.3";
+  name = "freefall-${version}";
+
+  src = fetchurl {
+    url = "mirror://kernel/linux/kernel/v3.x/linux-${version}.tar.xz";
+    sha256 = "0ma2x68975xsi9kb15p0615nx9sm5ppb309kfdz7fgx9pg84q0hf";
+  };
+
+  buildPhase = ''
+    cd Documentation/laptops
+
+    # Default time-out is a little low, probably because the AC/lid status
+    # functions were never implemented. Because no-one still uses HDDs, right?
+    substituteInPlace freefall.c --replace "alarm(2)" "alarm(5)"
+
+    cc -o freefall freefall.c
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    install freefall $out/bin
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Free-fall protection for spinning HP/Dell laptop hard drives";
+    longDescription = ''
+      ATA/ATAPI-7 specifies the IDLE IMMEDIATE command with unload feature.
+      Issuing this command should cause the drive to switch to idle mode and
+      unload disk heads. This feature is being used in modern laptops in
+      conjunction with accelerometers and appropriate software to implement
+      a shock protection facility. The idea is to stop all I/O operations on
+      the internal hard drive and park its heads on the ramp when critical
+      situations are anticipated. This has no effect on SSD devices!
+    '';
+    license = with licenses; gpl2;
+    platforms = with platforms; linux;
+    maintainers = with maintainers; [ nckx ];
+  };
+}
diff --git a/pkgs/os-specific/linux/iproute/default.nix b/pkgs/os-specific/linux/iproute/default.nix
index d6b3231ec460..6cfde916815a 100644
--- a/pkgs/os-specific/linux/iproute/default.nix
+++ b/pkgs/os-specific/linux/iproute/default.nix
@@ -1,12 +1,11 @@
-{ fetchgit, stdenv, flex, bison, db, iptables, pkgconfig }:
+{ fetchurl, stdenv, flex, bison, db, iptables, pkgconfig }:
 
 stdenv.mkDerivation rec {
-  name = "iproute2-3.17.0";
+  name = "iproute2-3.18.0";
 
-  src = fetchgit {
-    url = "git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git";
-    rev = "refs/tags/v3.17.0";
-    sha256 = "113ayyy7cjxn0bf67fh4is4z0jysgif016kv7ig0jp6r68xp2spa";
+  src = fetchurl {
+    url = "mirror://kernel/linux/utils/net/iproute2/${name}.tar.xz";
+    sha256 = "1pzipx6m27rv42b76isik5amziijb88lj5kxvyqlj1xx98aq58fm";
   };
 
   patch = [ ./vpnc.patch ];
diff --git a/pkgs/os-specific/linux/jfbview/default.nix b/pkgs/os-specific/linux/jfbview/default.nix
new file mode 100644
index 000000000000..b497784861f4
--- /dev/null
+++ b/pkgs/os-specific/linux/jfbview/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchFromGitHub, freetype, imlib2, jbig2dec, libjpeg, libX11, mujs
+, mupdf, ncurses, openjpeg, openssl }:
+
+stdenv.mkDerivation rec {
+  version = "0.4.2"; # TODO: update to 0.5 or later when nixpkgs has caught up
+  name = "jfbview-${version}";
+
+  src = fetchFromGitHub {
+    repo = "JFBView";
+    owner = "jichu4n";
+    rev = version;
+    sha256 = "1hhlzvs0jhygd3mqpzg5zymrbay9c8ilc4wjnwg00lvxhv3rwswr";
+  };
+
+  buildInputs = [ freetype imlib2 jbig2dec libjpeg libX11 mujs mupdf ncurses
+    openjpeg openssl ];
+
+  enableParallelBuilding = true;
+
+  makeFlags = "jfbpdf jfbview";
+
+  installPhase = ''
+    mkdir -p $out/bin
+    install jfbpdf jfbview $out/bin
+  '';
+
+  meta = with stdenv.lib; {
+    description = "PDF and image viewer for the Linux framebuffer";
+    longDescription = ''
+      PDF and image viewer for the Linux framebuffer. Very fast with a number
+      of advanced and unique features including:
+      - Reads PDFs (MuPDF) and common image formats (Imlib2).
+      - Supports arbitrary zoom (10% - 1000%) and rotation.
+      - Table of Contents (TOC) viewer for PDF documents.
+      - Multi-threaded rendering on multi-core machines.
+      - Asynchronous background rendering of the next page.
+      - Customizable multi-threaded caching.
+    '';
+    homepage = http://seasonofcode.com/pages/jfbview.html;
+    license = with licenses; asl20;
+    platforms = with platforms; linux;
+    maintainers = with maintainers; [ nckx ];
+  };
+}
diff --git a/pkgs/os-specific/linux/kernel/bridge-stp-helper.patch b/pkgs/os-specific/linux/kernel/bridge-stp-helper.patch
new file mode 100644
index 000000000000..70d0f944c2a0
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/bridge-stp-helper.patch
@@ -0,0 +1,13 @@
+diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
+index aea3d13..8fcbf81 100644
+--- a/net/bridge/br_private.h
++++ b/net/bridge/br_private.h
+@@ -39,7 +39,7 @@
+ #define BR_GROUPFWD_8021AD	0xB801u
+ 
+ /* Path to usermode spanning tree program */
+-#define BR_STP_PROG	"/sbin/bridge-stp"
++#define BR_STP_PROG	"/run/current-system/sw/bin/bridge-stp"
+ 
+ typedef struct bridge_id bridge_id;
+ typedef struct mac_addr mac_addr;
diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix
index 48493044065c..4f08e5a6fd81 100644
--- a/pkgs/os-specific/linux/kernel/common-config.nix
+++ b/pkgs/os-specific/linux/kernel/common-config.nix
@@ -6,7 +6,12 @@ with stdenv.lib;
   # Power management and debugging.
   DEBUG_KERNEL y
   PM_ADVANCED_DEBUG y
-  PM_RUNTIME y
+  ${optionalString (versionOlder version "3.19") ''
+    PM_RUNTIME y
+  ''}
+  ${optionalString (versionAtLeast version "3.10") ''
+    X86_INTEL_PSTATE y
+  ''}
   TIMER_STATS y
   ${optionalString (versionOlder version "3.10") ''
     USB_SUSPEND y
diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix
index 13250e45494f..b42892f9f2d8 100644
--- a/pkgs/os-specific/linux/kernel/generic.nix
+++ b/pkgs/os-specific/linux/kernel/generic.nix
@@ -57,6 +57,10 @@ let
     autoModules = stdenv.platform.kernelAutoModules;
     arch = stdenv.platform.kernelArch;
 
+    preConfigure = ''
+        buildFlagsArray+=("KBUILD_BUILD_TIMESTAMP=Thu Jan 1 00:00:01 UTC 1970")
+    '';
+
     crossAttrs = let
         cp = stdenv.cross.platform;
       in {
diff --git a/pkgs/os-specific/linux/kernel/linux-3.10.nix b/pkgs/os-specific/linux/kernel/linux-3.10.nix
index 80143bb49050..5a27d289417f 100644
--- a/pkgs/os-specific/linux/kernel/linux-3.10.nix
+++ b/pkgs/os-specific/linux/kernel/linux-3.10.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, ... } @ args:
 
 import ./generic.nix (args // rec {
-  version = "3.10.63";
+  version = "3.10.68";
   extraMeta.branch = "3.10";
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v3.x/linux-${version}.tar.xz";
-    sha256 = "0ajgw7xr4ilbssr9lcs4078584kr5nlycc3gc28ywc29z7vi8sjm";
+    sha256 = "13r8xd1qv2cmzk9dzh6xzy0sr4yf301a959lnf7v7ji3bs7gzp4a";
   };
 
   features.iwlwifi = true;
diff --git a/pkgs/os-specific/linux/kernel/linux-3.12.nix b/pkgs/os-specific/linux/kernel/linux-3.12.nix
index 1dd49edf6d78..acfe74828e72 100644
--- a/pkgs/os-specific/linux/kernel/linux-3.12.nix
+++ b/pkgs/os-specific/linux/kernel/linux-3.12.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, ... } @ args:
 
 import ./generic.nix (args // rec {
-  version = "3.12.35";
+  version = "3.12.37";
   extraMeta.branch = "3.12";
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v3.x/linux-${version}.tar.xz";
-    sha256 = "1krzd21hi93kwmffaxfbmyh8cbxl6afgma3yk14xm5ff5z0nlaxy";
+    sha256 = "0p7d6qdk7327yzfxzlxbxizrf7dm8vxbc3spm2ai4q278wxbi8jx";
   };
 
   features.iwlwifi = true;
diff --git a/pkgs/os-specific/linux/kernel/linux-3.14.nix b/pkgs/os-specific/linux/kernel/linux-3.14.nix
index 7d4c741193f9..30af9e562e6d 100644
--- a/pkgs/os-specific/linux/kernel/linux-3.14.nix
+++ b/pkgs/os-specific/linux/kernel/linux-3.14.nix
@@ -1,13 +1,13 @@
 { stdenv, fetchurl, ... } @ args:
 
 import ./generic.nix (args // rec {
-  version = "3.14.27";
+  version = "3.14.32";
   # Remember to update grsecurity!
   extraMeta.branch = "3.14";
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v3.x/linux-${version}.tar.xz";
-    sha256 = "09fxykm280zy3jq2zak6qiglsgv4756ryqwmx23hl014rk8bzszn";
+    sha256 = "1dmmb8z641ak5fsm3al5j6ifh77dvm94npwhvwmr0wp6z8k76w02";
   };
 
   features.iwlwifi = true;
diff --git a/pkgs/os-specific/linux/kernel/linux-3.16.nix b/pkgs/os-specific/linux/kernel/linux-3.16.nix
deleted file mode 100644
index 6997d51a0f1a..000000000000
--- a/pkgs/os-specific/linux/kernel/linux-3.16.nix
+++ /dev/null
@@ -1,17 +0,0 @@
-{ stdenv, fetchurl, ... } @ args:
-
-import ./generic.nix (args // rec {
-  version = "3.16.7";
-  extraMeta.branch = "3.16";
-
-  src = fetchurl {
-    url = "mirror://kernel/linux/kernel/v3.x/linux-${version}.tar.xz";
-    sha256 = "0vm3ahw6wzq72z6jim05pcj9gzjw8jc4r1dr5wnfl810nib89pbk";
-  };
-
-  features.iwlwifi = true;
-  features.efiBootStub = true;
-  features.needsCifsUtils = true;
-  features.canDisableNetfilterConntrackHelpers = true;
-  features.netfilterRPFilter = true;
-} // (args.argsOverride or {}))
diff --git a/pkgs/os-specific/linux/kernel/linux-3.17.nix b/pkgs/os-specific/linux/kernel/linux-3.17.nix
deleted file mode 100644
index a459e33f4d66..000000000000
--- a/pkgs/os-specific/linux/kernel/linux-3.17.nix
+++ /dev/null
@@ -1,17 +0,0 @@
-{ stdenv, fetchurl, ... } @ args:
-
-import ./generic.nix (args // rec {
-  version = "3.17.7";
-  extraMeta.branch = "3.17";
-
-  src = fetchurl {
-    url = "mirror://kernel/linux/kernel/v3.x/linux-${version}.tar.xz";
-    sha256 = "074f56sz22wqnn21gamwf63llhsqc2hgb7dzkbkd5gqjx6pfdj53";
-  };
-
-  features.iwlwifi = true;
-  features.efiBootStub = true;
-  features.needsCifsUtils = true;
-  features.canDisableNetfilterConntrackHelpers = true;
-  features.netfilterRPFilter = true;
-} // (args.argsOverride or {}))
diff --git a/pkgs/os-specific/linux/kernel/linux-3.18.nix b/pkgs/os-specific/linux/kernel/linux-3.18.nix
index e12588e052ba..73c17f6c1ca3 100644
--- a/pkgs/os-specific/linux/kernel/linux-3.18.nix
+++ b/pkgs/os-specific/linux/kernel/linux-3.18.nix
@@ -1,13 +1,13 @@
 { stdenv, fetchurl, ... } @ args:
 
 import ./generic.nix (args // rec {
-  version = "3.18.1";
+  version = "3.18.6";
   # Remember to update grsecurity!
   extraMeta.branch = "3.18";
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v3.x/linux-${version}.tar.xz";
-    sha256 = "13m0s2m0zg304w86yvcmxgbjl41c4kc420044avi8rnr1xwcscsq";
+    sha256 = "1xaky9yqkpa63936z7h4x3pxp4z45jwhslxpg4nmgakk262a9hf4";
   };
 
   features.iwlwifi = true;
diff --git a/pkgs/os-specific/linux/kernel/linux-3.2.nix b/pkgs/os-specific/linux/kernel/linux-3.2.nix
index 330b643e46a2..994d14ecae58 100644
--- a/pkgs/os-specific/linux/kernel/linux-3.2.nix
+++ b/pkgs/os-specific/linux/kernel/linux-3.2.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, ... } @ args:
 
 import ./generic.nix (args // rec {
-  version = "3.2.65";
+  version = "3.2.66";
   extraMeta.branch = "3.2";
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v3.x/linux-${version}.tar.xz";
-    sha256 = "1j9ibivhrkav5dfb7pv5m2j2y4577nqxp63npcpmna7wp7y132wm";
+    sha256 = "09l0rfv10c5kzlgfhi339ly496f6j9ichq3arpvkb3fivjkxcm45";
   };
 
   # We don't provide these patches if grsecurity is enabled, because
diff --git a/pkgs/os-specific/linux/kernel/linux-3.4.nix b/pkgs/os-specific/linux/kernel/linux-3.4.nix
index d4da722f6c2b..2d0530237210 100644
--- a/pkgs/os-specific/linux/kernel/linux-3.4.nix
+++ b/pkgs/os-specific/linux/kernel/linux-3.4.nix
@@ -1,12 +1,12 @@
 { stdenv, fetchurl, ... } @ args:
 
 import ./generic.nix (args // rec {
-  version = "3.4.105";
+  version = "3.4.106";
   extraMeta.branch = "3.4";
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v3.x/linux-${version}.tar.xz";
-    sha256 = "0xhwdkpcmvbvk1rq0mz2f2pmh322flly7wr66wdd5bypfvanrk23";
+    sha256 = "1l1k2kmlz0j12ly63w3mhvdzp5fpc22ajda4kw66fyjx96npm8sc";
   };
 
   kernelPatches = args.kernelPatches ++
diff --git a/pkgs/os-specific/linux/kernel/linux-testing.nix b/pkgs/os-specific/linux/kernel/linux-testing.nix
index 69cefcda698f..d9d16f9ac770 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, ... } @ args:
 
 import ./generic.nix (args // rec {
-  version = "3.18-rc7";
-  modDirVersion = "3.18.0-rc7";
-  extraMeta.branch = "3.18";
+  version = "3.19-rc7";
+  modDirVersion = "3.19.0-rc7";
+  extraMeta.branch = "3.19";
 
   src = fetchurl {
     url = "mirror://kernel/linux/kernel/v3.x/testing/linux-${version}.tar.xz";
-    sha256 = "1zq7jd33jq4ibvjdsj8cm4zlgjag7j8r7w7ajmzivr7npdb9fvvk";
+    sha256 = "007xjngbyvdx127rkrzxs23kxcw2z54gzad9954iwhphqw0kpq9x";
   };
 
   features.iwlwifi = true;
diff --git a/pkgs/os-specific/linux/kernel/patches.nix b/pkgs/os-specific/linux/kernel/patches.nix
index 8c707c7e570d..6c8047ab1d4c 100644
--- a/pkgs/os-specific/linux/kernel/patches.nix
+++ b/pkgs/os-specific/linux/kernel/patches.nix
@@ -32,6 +32,11 @@ in
 
 rec {
 
+  bridge_stp_helper =
+    { name = "bridge-stp-helper";
+      patch = ./bridge-stp-helper.patch;
+    };
+
   no_xsave =
     { name = "no-xsave";
       patch = ./no-xsave.patch;
@@ -60,17 +65,17 @@ rec {
   };
 
   grsecurity_stable = grsecPatch
-    { kversion  = "3.14.27";
-      revision  = "201412280859";
+    { kversion  = "3.14.32";
+      revision  = "201502062101";
       branch    = "stable";
-      sha256    = "185sq4bsgwmpq9g0g5fhm69ba875xhxha2rs0cn6n647v90rxrjk";
+      sha256    = "1qni3x6kwrhgqbhwm02m9wnmz7y2ydwwxw9ckk06xyq3j9qgv3aj";
     };
 
   grsecurity_unstable = grsecPatch
-    { kversion  = "3.18.1";
-      revision  = "201412281149";
+    { kversion  = "3.18.6";
+      revision  = "201502062100";
       branch    = "test";
-      sha256    = "10pq6lslfn6ck7pm1651s6pd5mqmjxvqv3iv70qrpwwb2gdhpdin";
+      sha256    = "11cy7qqkahd323hmi67r4psgryapk1qwamm9m15rhbfqgq428306";
     };
 
   grsec_fix_path =
diff --git a/pkgs/os-specific/linux/libcap/progs.nix b/pkgs/os-specific/linux/libcap/progs.nix
index 1902b4acb1a4..ae4446c82e6c 100644
--- a/pkgs/os-specific/linux/libcap/progs.nix
+++ b/pkgs/os-specific/linux/libcap/progs.nix
@@ -9,6 +9,14 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ libcap ];
 
+  prePatch = ''
+    # use relative bash path
+    substituteInPlace progs/capsh.c --replace "/bin/bash" "bash"
+
+    # ensure capsh can find bash in $PATH
+    substituteInPlace progs/capsh.c --replace execve execvpe
+  '';
+
   preConfigure = "cd progs";
 
   installFlags = "RAISE_SETFCAP=no";
diff --git a/pkgs/os-specific/linux/lxc/default.nix b/pkgs/os-specific/linux/lxc/default.nix
index 79e65fdb613d..04ca4514a0f4 100644
--- a/pkgs/os-specific/linux/lxc/default.nix
+++ b/pkgs/os-specific/linux/lxc/default.nix
@@ -3,11 +3,11 @@
 }:
 
 stdenv.mkDerivation rec {
-  name = "lxc-1.0.6";
+  name = "lxc-1.0.7";
 
   src = fetchurl {
     url = "http://github.com/lxc/lxc/archive/${name}.tar.gz";
-    sha256 = "075i5h136b3dnf8nk6mpailz6i18yv1zcsj0jdpr9kg2i6d1ksia";
+    sha256 = "1wm8n1b8j3x37757h2yyz53k3b6r2r301fmkviqf4xp0jaav1cd0";
   };
 
   buildInputs = [ libcap apparmor perl docbook2x gnutls autoreconfHook pkgconfig ];
diff --git a/pkgs/os-specific/linux/mstpd/default.nix b/pkgs/os-specific/linux/mstpd/default.nix
new file mode 100644
index 000000000000..374300db460a
--- /dev/null
+++ b/pkgs/os-specific/linux/mstpd/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchsvn }:
+
+stdenv.mkDerivation rec {
+  name = "mstpd-svn-${toString version}";
+  version = 61;
+
+  src = fetchsvn {
+    url = "svn://svn.code.sf.net/p/mstpd/code/trunk";
+    rev = version;
+    sha256 = "0n5vqqqq8hk6iqdz100j9ps4zkz71vyl5qgz5bzjhayab2dyq1fd";
+  };
+
+  patches = [ ./fixes.patch ];
+
+  installFlags = [ "DESTDIR=\${out}" ];
+
+  meta = with stdenv.lib; {
+    description = "Multiple Spanning Tree Protocol daemon";
+    homepage = http://sourceforge.net/projects/mstpd/;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ wkennington ];
+  };
+}
diff --git a/pkgs/os-specific/linux/mstpd/fixes.patch b/pkgs/os-specific/linux/mstpd/fixes.patch
new file mode 100644
index 000000000000..7303e1d7b4d3
--- /dev/null
+++ b/pkgs/os-specific/linux/mstpd/fixes.patch
@@ -0,0 +1,72 @@
+diff --git a/Makefile b/Makefile
+index dde9f81..5af7cab 100644
+--- a/Makefile
++++ b/Makefile
+@@ -34,7 +34,6 @@ install: all
+ 	-mkdir -pv $(DESTDIR)/sbin
+ 	install -m 755 mstpd $(DESTDIR)/sbin/mstpd
+ 	install -m 755 mstpctl $(DESTDIR)/sbin/mstpctl
+-	install -m 755 bridge-stp /sbin/bridge-stp
+ 	-mkdir -pv $(DESTDIR)/lib/mstpctl-utils/
+ 	cp -rv lib/* $(DESTDIR)/lib/mstpctl-utils/
+ 	gzip -f $(DESTDIR)/lib/mstpctl-utils/mstpctl.8
+@@ -42,8 +41,9 @@ install: all
+ 	if [ -d $(DESTDIR)/etc/network/if-pre-up.d ] ; then ln -sf /lib/mstpctl-utils/ifupdown.sh $(DESTDIR)/etc/network/if-pre-up.d/mstpctl ; fi
+ 	if [ -d $(DESTDIR)/etc/network/if-pre-up.d ] ; then ln -sf /lib/mstpctl-utils/ifupdown.sh $(DESTDIR)/etc/network/if-post-down.d/mstpctl ; fi
+ 	if [ -d $(DESTDIR)/etc/bash_completion.d ] ; then ln -sf /lib/mstpctl-utils/bash_completion $(DESTDIR)/etc/bash_completion.d/mstpctl ; fi
+-	ln -sf /lib/mstpctl-utils/mstpctl.8.gz $(DESTDIR)/usr/share/man/man8/mstpctl.8.gz
+-	ln -sf /lib/mstpctl-utils/mstpctl-utils-interfaces.5.gz $(DESTDIR)/usr/share/man/man5/mstpctl-utils-interfaces.5.gz
++	mkdir -p $(DESTDIR)/share/man/man8 $(DESTDIR)/share/man/man5
++	ln -sf /lib/mstpctl-utils/mstpctl.8.gz $(DESTDIR)/share/man/man8/mstpctl.8.gz
++	ln -sf /lib/mstpctl-utils/mstpctl-utils-interfaces.5.gz $(DESTDIR)/share/man/man5/mstpctl-utils-interfaces.5.gz
+ 
+ romfs: all
+ 	$(ROMFSINST) /sbin/mstpd
+diff --git a/bridge_track.c b/bridge_track.c
+index c92fdf6..0c01aec 100644
+--- a/bridge_track.c
++++ b/bridge_track.c
+@@ -28,6 +28,7 @@
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <linux/param.h>
++#include <linux/in6.h>
+ #include <linux/if_bridge.h>
+ #include <asm/byteorder.h>
+ 
+diff --git a/broadcom_xstrata/driver_deps.c b/broadcom_xstrata/driver_deps.c
+index e72e9e3..5194253 100644
+--- a/broadcom_xstrata/driver_deps.c
++++ b/broadcom_xstrata/driver_deps.c
+@@ -14,6 +14,7 @@
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <asm/byteorder.h>
++#include <linux/in6.h>
+ #include <linux/if_bridge.h>
+ 
+ #include "log.h"
+diff --git a/ctl_functions.h b/ctl_functions.h
+index 9c3b914..df464de 100644
+--- a/ctl_functions.h
++++ b/ctl_functions.h
+@@ -27,6 +27,7 @@
+ #ifndef CTL_SOCKET_H
+ #define CTL_SOCKET_H
+ 
++#include <linux/in6.h>
+ #include <linux/if_bridge.h>
+ #include <asm/byteorder.h>
+ 
+diff --git a/mstp.c b/mstp.c
+index 1c6a2df..b2a1acd 100644
+--- a/mstp.c
++++ b/mstp.c
+@@ -37,6 +37,7 @@
+ 
+ #include <string.h>
+ #include <sys/time.h>
++#include <linux/in6.h>
+ #include <linux/if_bridge.h>
+ #include <asm/byteorder.h>
+ 
diff --git a/pkgs/os-specific/linux/nfs-utils/default.nix b/pkgs/os-specific/linux/nfs-utils/default.nix
index 9c4905bd5293..e0fc88d995b5 100644
--- a/pkgs/os-specific/linux/nfs-utils/default.nix
+++ b/pkgs/os-specific/linux/nfs-utils/default.nix
@@ -1,18 +1,18 @@
 { fetchurl, stdenv, tcp_wrappers, utillinux, libcap, libtirpc, libevent, libnfsidmap
-, lvm2, e2fsprogs, python
+, lvm2, e2fsprogs, python, sqlite
 }:
 
 stdenv.mkDerivation rec {
-  name = "nfs-utils-1.2.5";
+  name = "nfs-utils-1.3.2";
 
   src = fetchurl {
     url = "mirror://sourceforge/nfs/${name}.tar.bz2";
-    sha256 = "16ssfkj36ljifyaskgwpd3ys8ylhi5gasq88aha3bhg5dr7yv59m";
+    sha256 = "1xwilpdr1vizq2yhpzxpwqqr9f8kn0dy2wcpc626mf30ybp7572v";
   };
 
   buildInputs =
     [ tcp_wrappers utillinux libcap libtirpc libevent libnfsidmap
-      lvm2 e2fsprogs python
+      lvm2 e2fsprogs python sqlite
     ];
 
   # FIXME: Add the dependencies needed for NFSv4 and TI-RPC.
@@ -23,24 +23,21 @@ stdenv.mkDerivation rec {
     ]
     ++ stdenv.lib.optional (stdenv ? glibc) "--with-rpcgen=${stdenv.glibc}/bin/rpcgen";
 
-  patchPhase =
-    ''
-      for i in "tests/"*.sh
-      do
-        sed -i "$i" -e's|/bin/bash|/bin/sh|g'
-        chmod +x "$i"
-      done
-      sed -i s,/usr/sbin,$out/sbin, utils/statd/statd.c
-
-      # https://bugzilla.redhat.com/show_bug.cgi?id=749195
-      sed -i s,PAGE_SIZE,getpagesize\(\), utils/blkmapd/device-process.c
-    '';
+  patches = [ ./no-install.patch ];
 
-  preBuild =
-    ''
-      makeFlags="sbindir=$out/sbin"
-      installFlags="statedir=$TMPDIR" # hack to make `make install' work
-    '';
+  postPatch = ''
+    for i in "tests/"*.sh
+    do
+      sed -i "$i" -e's|/bin/bash|/bin/sh|g'
+      chmod +x "$i"
+    done
+    sed -i s,/usr/sbin,$out/sbin, utils/statd/statd.c
+  '';
+
+  preBuild = ''
+    makeFlags="sbindir=$out/sbin"
+    installFlags="statedir=$TMPDIR" # hack to make `make install' work
+  '';
 
   # One test fails on mips.
   doCheck = !stdenv.isMips;
@@ -58,6 +55,6 @@ stdenv.mkDerivation rec {
     license = stdenv.lib.licenses.gpl2;
 
     platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.ludo ];
+    maintainers = [ ];
   };
 }
diff --git a/pkgs/os-specific/linux/nfs-utils/no-install.patch b/pkgs/os-specific/linux/nfs-utils/no-install.patch
new file mode 100644
index 000000000000..b45008dc0362
--- /dev/null
+++ b/pkgs/os-specific/linux/nfs-utils/no-install.patch
@@ -0,0 +1,19 @@
+diff --git a/Makefile.in b/Makefile.in
+index 6a5c7c2..64342fe 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -872,14 +872,6 @@ uninstall-am:
+ 
+ 
+ install-data-hook:
+-	if [ ! -d $(DESTDIR)$(statedir) ]; then mkdir -p $(DESTDIR)$(statedir); fi
+-	touch $(DESTDIR)$(statedir)/xtab; chmod 644 $(DESTDIR)$(statedir)/xtab
+-	touch $(DESTDIR)$(statedir)/etab; chmod 644 $(DESTDIR)$(statedir)/etab
+-	touch $(DESTDIR)$(statedir)/rmtab; chmod 644 $(DESTDIR)$(statedir)/rmtab
+-	mkdir -p $(DESTDIR)$(statdpath)/sm $(DESTDIR)$(statdpath)/sm.bak
+-	touch $(DESTDIR)$(statdpath)/state
+-	chmod go-rwx $(DESTDIR)$(statdpath)/sm $(DESTDIR)$(statdpath)/sm.bak $(DESTDIR)$(statdpath)/state
+-	-chown $(statduser) $(DESTDIR)$(statdpath)/sm $(DESTDIR)$(statdpath)/sm.bak $(DESTDIR)$(statdpath)/state
+ 
+ uninstall-hook:
+ 	rm $(DESTDIR)$(statedir)/xtab
diff --git a/pkgs/os-specific/linux/nvidia-x11/default.nix b/pkgs/os-specific/linux/nvidia-x11/default.nix
index 0d27c89eac2c..63cb33a52a28 100644
--- a/pkgs/os-specific/linux/nvidia-x11/default.nix
+++ b/pkgs/os-specific/linux/nvidia-x11/default.nix
@@ -42,9 +42,9 @@ stdenv.mkDerivation {
   dontStrip = true;
 
   glPath      = makeLibraryPath [xlibs.libXext xlibs.libX11 xlibs.libXrandr];
-  cudaPath    = makeLibraryPath [zlib stdenv.cc.gcc];
+  cudaPath    = makeLibraryPath [zlib stdenv.cc.cc];
   openclPath  = makeLibraryPath [zlib];
-  allLibPath  = makeLibraryPath [xlibs.libXext xlibs.libX11 xlibs.libXrandr zlib stdenv.cc.gcc];
+  allLibPath  = makeLibraryPath [xlibs.libXext xlibs.libX11 xlibs.libXrandr zlib stdenv.cc.cc];
 
   programPath = optionalString (!libsOnly) (makeLibraryPath
     [ gtk atk pango glib gdk_pixbuf xlibs.libXv ] );
diff --git a/pkgs/os-specific/linux/nvidia-x11/legacy173.nix b/pkgs/os-specific/linux/nvidia-x11/legacy173.nix
index 79d8adfb2e17..432a756b6f6b 100644
--- a/pkgs/os-specific/linux/nvidia-x11/legacy173.nix
+++ b/pkgs/os-specific/linux/nvidia-x11/legacy173.nix
@@ -32,7 +32,7 @@ stdenv.mkDerivation {
 
   glPath = stdenv.lib.makeLibraryPath [xlibs.libXext xlibs.libX11 xlibs.libXrandr];
 
-  cudaPath = stdenv.lib.makeLibraryPath [zlib stdenv.cc.gcc];
+  cudaPath = stdenv.lib.makeLibraryPath [zlib stdenv.cc.cc];
 
   programPath = stdenv.lib.makeLibraryPath [ gtk atk pango glib gdk_pixbuf xlibs.libXv ];
 
diff --git a/pkgs/os-specific/linux/nvidia-x11/legacy304.nix b/pkgs/os-specific/linux/nvidia-x11/legacy304.nix
index e37b4354408b..d5e350a0302a 100644
--- a/pkgs/os-specific/linux/nvidia-x11/legacy304.nix
+++ b/pkgs/os-specific/linux/nvidia-x11/legacy304.nix
@@ -36,7 +36,7 @@ stdenv.mkDerivation {
 
   glPath = stdenv.lib.makeLibraryPath [xlibs.libXext xlibs.libX11 xlibs.libXrandr];
 
-  cudaPath = stdenv.lib.makeLibraryPath [zlib stdenv.cc.gcc];
+  cudaPath = stdenv.lib.makeLibraryPath [zlib stdenv.cc.cc];
 
   programPath = optionalString (!libsOnly) (stdenv.lib.makeLibraryPath
     [ gtk atk pango glib gdk_pixbuf xlibs.libXv ] );
diff --git a/pkgs/os-specific/linux/nvidia-x11/legacy340.nix b/pkgs/os-specific/linux/nvidia-x11/legacy340.nix
index 7af7e63c388d..e0fd15fad3b1 100644
--- a/pkgs/os-specific/linux/nvidia-x11/legacy340.nix
+++ b/pkgs/os-specific/linux/nvidia-x11/legacy340.nix
@@ -45,9 +45,9 @@ stdenv.mkDerivation {
   dontStrip = true;
 
   glPath      = makeLibraryPath [xlibs.libXext xlibs.libX11 xlibs.libXrandr];
-  cudaPath    = makeLibraryPath [zlib stdenv.cc.gcc];
+  cudaPath    = makeLibraryPath [zlib stdenv.cc.cc];
   openclPath  = makeLibraryPath [zlib];
-  allLibPath  = makeLibraryPath [xlibs.libXext xlibs.libX11 xlibs.libXrandr zlib stdenv.cc.gcc];
+  allLibPath  = makeLibraryPath [xlibs.libXext xlibs.libX11 xlibs.libXrandr zlib stdenv.cc.cc];
 
   programPath = optionalString (!libsOnly) (makeLibraryPath
     [ gtk atk pango glib gdk_pixbuf xlibs.libXv ] );
diff --git a/pkgs/os-specific/linux/ocz-toolbox/default.nix b/pkgs/os-specific/linux/ocz-toolbox/default.nix
index 65d4fa0f07a5..4537cdac3e99 100644
--- a/pkgs/os-specific/linux/ocz-toolbox/default.nix
+++ b/pkgs/os-specific/linux/ocz-toolbox/default.nix
@@ -16,7 +16,7 @@ in stdenv.mkDerivation rec {
     cd linux${arch}
   '';
 
-  libPath = stdenv.lib.makeLibraryPath [ stdenv.cc.gcc libXrender fontconfig freetype libXext libX11 ];
+  libPath = stdenv.lib.makeLibraryPath [ stdenv.cc.cc libXrender fontconfig freetype libXext libX11 ];
 
   installPhase = ''
     install -Dm755 OCZToolbox $out/bin/OCZToolbox
diff --git a/pkgs/os-specific/linux/opengl/xorg-sys/default.nix b/pkgs/os-specific/linux/opengl/xorg-sys/default.nix
index acd1499a36cd..2cebb8d9dcc2 100644
--- a/pkgs/os-specific/linux/opengl/xorg-sys/default.nix
+++ b/pkgs/os-specific/linux/opengl/xorg-sys/default.nix
@@ -11,6 +11,6 @@
 stdenv.mkDerivation {
   name = "xorg-sys-opengl-3";
   builder = ./builder.sh;
-  neededLibs = [xlibs.libXxf86vm xlibs.libXext expat libdrm stdenv.cc.gcc];
+  neededLibs = [xlibs.libXxf86vm xlibs.libXext expat libdrm stdenv.cc.cc];
 }
 
diff --git a/pkgs/os-specific/linux/pam_krb5/default.nix b/pkgs/os-specific/linux/pam_krb5/default.nix
index 5c0cc033de9f..40e7e1216a64 100644
--- a/pkgs/os-specific/linux/pam_krb5/default.nix
+++ b/pkgs/os-specific/linux/pam_krb5/default.nix
@@ -1,17 +1,17 @@
 { stdenv, fetchurl, pam, kerberos }:
 
 stdenv.mkDerivation rec {
-  name = "pam_krb5-2.4.9";
+  name = "pam-krb5-4.7";
 
   src = fetchurl {
-    url = "https://fedorahosted.org/releases/p/a/pam_krb5/${name}.tar.gz";
-    sha256 = "0vcb35shzp406jvvz0pkgqm8qq1qzhgwmkl0nrm0wrrkqlr22rfb";
+    url = "http://archives.eyrie.org/software/kerberos/${name}.tar.gz";
+    sha256 = "04klg9a2rhdz0a2dw4f0ybcm28vcbab6lrynwq7rm4sn0hnzakwv";
   };
 
   buildInputs = [ pam kerberos ];
 
   meta = with stdenv.lib; {
-    homepage = https://fedorahosted.org/pam_krb5;
+    homepage = http://www.eyrie.org/~eagle/software/pam-krb5/;
     description = "PAM module allowing PAM-aware applications to authenticate users by performing an AS exchange with a Kerberos KDC";
     longDescription = ''
       pam_krb5 can optionally convert Kerberos 5 credentials to Kerberos IV
diff --git a/pkgs/os-specific/linux/pcmciautils/default.nix b/pkgs/os-specific/linux/pcmciautils/default.nix
index 787b72fde480..ce5814965efd 100644
--- a/pkgs/os-specific/linux/pcmciautils/default.nix
+++ b/pkgs/os-specific/linux/pcmciautils/default.nix
@@ -8,11 +8,11 @@
 
 # FIXME: should add an option to choose between hotplug and udev.
 stdenv.mkDerivation rec {
-  name = "pcmciautils-015";
+  name = "pcmciautils-017";
 
   src = fetchurl {
-    url = "http://kernel.org/pub/linux/utils/kernel/pcmcia/${name}.tar.bz2";
-    sha256 = "4847485c412b47e3d88fa83ef811229e0e7941217303bc8449c30a3dc2128b6e";
+    url = "https://kernel.org/pub/linux/utils/kernel/pcmcia/${name}.tar.gz";
+    sha256 = "5d8e2efad8a7f692129610603da232f2144851753d8d49a70eeb8eb1be6f6bc3";
   };
 
   buildInputs = [udev yacc sysfsutils module_init_tools flex];
@@ -44,7 +44,7 @@ stdenv.mkDerivation rec {
     '') firmware;
 
   meta = {
-    homepage = http://kernel.org/pub/linux/utils/kernel/pcmcia/pcmcia.html;
+    homepage = https://www.kernel.org/pub/linux/utils/kernel/pcmcia/;
     longDescription = "
       PCMCIAutils contains the initialization tools necessary to allow
       the PCMCIA subsystem to behave (almost) as every other
diff --git a/pkgs/os-specific/linux/prl-tools/default.nix b/pkgs/os-specific/linux/prl-tools/default.nix
index f76d409fcfbe..0dac7c4358d7 100644
--- a/pkgs/os-specific/linux/prl-tools/default.nix
+++ b/pkgs/os-specific/linux/prl-tools/default.nix
@@ -83,7 +83,7 @@ stdenv.mkDerivation rec {
   '';
 
   libPath = with xorg;
-            stdenv.lib.makeLibraryPath ([ stdenv.cc.gcc libXrandr libXext libX11 libXcomposite libXinerama ]
+            stdenv.lib.makeLibraryPath ([ stdenv.cc.cc libXrandr libXext libX11 libXcomposite libXinerama ]
             ++ lib.optionals (!libsOnly) [ libXi glib dbus_glib zlib ]);
 
   desktops = map (x: substituteAll ({
diff --git a/pkgs/os-specific/linux/radeontop/default.nix b/pkgs/os-specific/linux/radeontop/default.nix
new file mode 100644
index 000000000000..7ec74c895c62
--- /dev/null
+++ b/pkgs/os-specific/linux/radeontop/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, fetchFromGitHub, pkgconfig, gettext, ncurses, libdrm, libpciaccess }:
+
+let version = "v0.8-8-g2499679"; in
+stdenv.mkDerivation {
+  name = "radeontop-${version}";
+
+  src = fetchFromGitHub {
+    sha256 = "112zf6ms0qpmr9h3l4lg5wik5j206mgij0nypba5lnqzksxh2f88";
+    rev = "2499679fda60c3f6239886296fd2a74155f45f77";
+    repo = "radeontop";
+    owner = "clbr";
+  };
+
+  buildInputs = [ pkgconfig gettext ncurses libdrm libpciaccess ];
+
+  enableParallelBuilding = true;
+
+  patchPhase = ''
+    substituteInPlace getver.sh --replace ver=unknown ver=${version}
+  '';
+
+  makeFlags = "PREFIX=$(out)";
+
+  meta = with stdenv.lib; {
+    description = "Top-like tool for viewing AMD Radeon GPU utilization";
+    longDescription = ''
+      View GPU utilization, both for the total activity percent and individual
+      blocks. Supports R600 and later cards: even Southern Islands should work.
+      Works with both the open drivers and AMD Catalyst. Total GPU utilization
+      is also valid for OpenCL loads; the other blocks are only useful for GL
+      loads. Requires root rights or other permissions to read /dev/mem.
+    '';
+    homepage = https://github.com/clbr/radeontop;
+    platforms = platforms.linux;
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ rycee nckx ];
+  };
+}
diff --git a/pkgs/os-specific/linux/sdparm/default.nix b/pkgs/os-specific/linux/sdparm/default.nix
index 30943d8cd413..3b0f7c694ac0 100644
--- a/pkgs/os-specific/linux/sdparm/default.nix
+++ b/pkgs/os-specific/linux/sdparm/default.nix
@@ -1,16 +1,17 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation {
-  name = "sdparm-1.08";
+  name = "sdparm-1.09";
 
   src = fetchurl {
-    url = http://sg.danny.cz/sg/p/sdparm-1.08.tgz;
-    sha256 = "0msy8anggdand1yr50vg2azcfgks7sbfpnqk7xzw9adi2jj7hsrp";
+    url = http://sg.danny.cz/sg/p/sdparm-1.09.tar.xz;
+    sha256 = "0jakqyjwi72zqjzss04bally0xl0lc4710mx8da08vpmir1hfphg";
   };
 
-  meta = {
+  meta = with stdenv.lib; {
     homepage = http://sg.danny.cz/sg/sdparm.html;
     description = "A utility to access SCSI device parameters";
-    license = stdenv.lib.licenses.free;
+    license = with licenses; bsd3;
+    maintainers = with maintainers; [ nckx ];
   };
 }
diff --git a/pkgs/os-specific/linux/spl/default.nix b/pkgs/os-specific/linux/spl/default.nix
index 0648be4e41a1..618b59b32aa5 100644
--- a/pkgs/os-specific/linux/spl/default.nix
+++ b/pkgs/os-specific/linux/spl/default.nix
@@ -1,7 +1,6 @@
-{ stdenv, fetchFromGitHub, kernel, perl, autoconf, automake, libtool, coreutils, gawk }:
+{ callPackage, fetchFromGitHub, ... } @ args:
 
-stdenv.mkDerivation rec {
-  name = "spl-${version}-${kernel.version}";
+callPackage ./generic.nix (args // rec {
   version = "0.6.3-1.2";
 
   src = fetchFromGitHub {
@@ -11,39 +10,5 @@ stdenv.mkDerivation rec {
     sha256 = "0id0m3sfpkz8w7b2pc51px8kvz8xnaf8msps57ddarxidmxvb45g";
   };
 
-  patches = [ ./install_prefix.patch ./const.patch ];
-
-  buildInputs = [ perl autoconf automake libtool ];
-
-  preConfigure = ''
-    ./autogen.sh
-
-    substituteInPlace ./module/spl/spl-generic.c --replace /usr/bin/hostid hostid
-    substituteInPlace ./module/spl/spl-module.c  --replace /bin/mknod mknod
-
-    substituteInPlace ./module/spl/spl-generic.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:${gawk}:/bin"
-    substituteInPlace ./module/splat/splat-vnode.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:/bin"
-    substituteInPlace ./module/splat/splat-linux.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:/bin"
-  '';
-
-  configureFlags = ''
-     --with-linux=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source
-     --with-linux-obj=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build
-  '';
-
-  enableParallelBuilding = true;
-
-  meta = {
-    description = "Kernel module driver for solaris porting layer (needed by in-kernel zfs)";
-
-    longDescription = ''
-      This kernel module is a porting layer for ZFS to work inside the linux
-      kernel.
-    '';
-
-    homepage = http://zfsonlinux.org/;
-    platforms = stdenv.lib.platforms.linux;
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = with stdenv.lib.maintainers; [ jcumming wizeman ];
-  };
-}
+  patches = [ ./install_prefix.patch ./const.patch ./time.patch ];
+})
diff --git a/pkgs/os-specific/linux/spl/generic.nix b/pkgs/os-specific/linux/spl/generic.nix
new file mode 100644
index 000000000000..c25ff6608e21
--- /dev/null
+++ b/pkgs/os-specific/linux/spl/generic.nix
@@ -0,0 +1,61 @@
+{ stdenv, autoconf, automake, libtool, coreutils, gawk
+, configFile ? "all"
+
+# Kernel dependencies
+, kernel ? null
+
+# Version specific parameters
+, version, src, patches
+, ...
+}:
+
+with stdenv.lib;
+let
+  buildKernel = any (n: n == configFile) [ "kernel" "all" ];
+  buildUser = any (n: n == configFile) [ "user" "all" ];
+in
+
+assert any (n: n == configFile) [ "kernel" "user" "all" ];
+assert buildKernel -> kernel != null;
+
+stdenv.mkDerivation rec {
+  name = "spl-${configFile}-${version}${optionalString buildKernel "-${kernel.version}"}";
+
+  inherit version src patches;
+
+  buildInputs = [ autoconf automake libtool ];
+
+  preConfigure = ''
+    ./autogen.sh
+
+    substituteInPlace ./module/spl/spl-generic.c --replace /usr/bin/hostid hostid
+    substituteInPlace ./module/spl/spl-module.c  --replace /bin/mknod mknod
+
+    substituteInPlace ./module/spl/spl-generic.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:${gawk}:/bin"
+    substituteInPlace ./module/splat/splat-vnode.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:/bin"
+    substituteInPlace ./module/splat/splat-linux.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:/bin"
+  '';
+
+  configureFlags = [
+    "--with-config=${configFile}"
+  ] ++ optionals buildKernel [
+    "--with-linux=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
+    "--with-linux-obj=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
+  ];
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "Kernel module driver for solaris porting layer (needed by in-kernel zfs)";
+
+    longDescription = ''
+      This kernel module is a porting layer for ZFS to work inside the linux
+      kernel.
+    '';
+
+    homepage = http://zfsonlinux.org/;
+    platforms = platforms.linux;
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ jcumming wizeman wkennington ];
+  };
+}
diff --git a/pkgs/os-specific/linux/spl/git.nix b/pkgs/os-specific/linux/spl/git.nix
index 93629495164b..fc204bc02321 100644
--- a/pkgs/os-specific/linux/spl/git.nix
+++ b/pkgs/os-specific/linux/spl/git.nix
@@ -1,46 +1,13 @@
-{ stdenv, fetchgit, kernel, perl, autoconf, automake, libtool, coreutils, gawk }:
+{ callPackage, fetchgit, ... } @ args:
+
+callPackage ./generic.nix (args // rec {
+  version = "086476f";
 
-stdenv.mkDerivation {
-  name = "spl-0.6.3-${kernel.version}";
   src = fetchgit {
     url = git://github.com/zfsonlinux/spl.git;
-    rev = "31cb5383bff0fddc5058973e32a6f2c446d45e59";
-    sha256 = "0mcivbddms8kbapbs9x6achqyvh5i6h1rd2b3jm8g5yjn0flc5gl";
+    rev = "086476f92005506cb07e75f889e8ddb69026e842";
+    sha256 = "1n3cjdwxccvcns7jydgznkb6jy0p59qx1yg512jjf4m9hf5p2pwm";
   };
 
-  patches = [ ./install_prefix.patch ./const.patch ./kernel-3.16.patch ./kernel-3.17.patch ];
-
-  buildInputs = [ perl autoconf automake libtool ];
-
-  preConfigure = ''
-    ./autogen.sh
-
-    substituteInPlace ./module/spl/spl-generic.c --replace /usr/bin/hostid hostid
-    substituteInPlace ./module/spl/spl-module.c  --replace /bin/mknod mknod
-
-    substituteInPlace ./module/spl/spl-generic.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:${gawk}:/bin"
-    substituteInPlace ./module/splat/splat-vnode.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:/bin"
-    substituteInPlace ./module/splat/splat-linux.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:/bin"
-  '';
-
-  configureFlags = ''
-     --with-linux=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source
-     --with-linux-obj=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build
-  '';
-
-  enableParallelBuilding = true;
-
-  meta = {
-    description = "Kernel module driver for solaris porting layer (needed by in-kernel zfs)";
-
-    longDescription = ''
-      This kernel module is a porting layer for ZFS to work inside the linux
-      kernel.
-    '';
-
-    homepage = http://zfsonlinux.org/;
-    platforms = stdenv.lib.platforms.linux;
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = with stdenv.lib.maintainers; [ wizeman ];
-  };
-}
+  patches = [ ./const.patch ./install_prefix-git.patch ];
+})
diff --git a/pkgs/os-specific/linux/spl/install_prefix-git.patch b/pkgs/os-specific/linux/spl/install_prefix-git.patch
new file mode 100644
index 000000000000..0f12f531f7ae
--- /dev/null
+++ b/pkgs/os-specific/linux/spl/install_prefix-git.patch
@@ -0,0 +1,173 @@
+diff --git a/Makefile.am b/Makefile.am
+index 89af931..674420c 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -12,10 +12,10 @@ endif
+ if CONFIG_KERNEL
+ SUBDIRS += module
+ 
+-extradir = @prefix@/src/spl-$(VERSION)
++extradir = @prefix@/libexec/spl
+ extra_HEADERS = spl.release.in spl_config.h.in
+ 
+-kerneldir = @prefix@/src/spl-$(VERSION)/$(LINUX_VERSION)
++kerneldir = @prefix@/libexec/spl/$(LINUX_VERSION)
+ nodist_kernel_HEADERS = spl.release spl_config.h module/$(LINUX_SYMBOLS)
+ endif
+ 
+diff --git a/include/Makefile.am b/include/Makefile.am
+index 3200222..4a47aaa 100644
+--- a/include/Makefile.am
++++ b/include/Makefile.am
+@@ -13,6 +13,6 @@ USER_H =
+ EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
+ 
+ if CONFIG_KERNEL
+-kerneldir = @prefix@/src/spl-$(VERSION)/include
++kerneldir = @prefix@/libexec/spl/include
+ kernel_HEADERS = $(KERNEL_H)
+ endif
+diff --git a/include/fs/Makefile.am b/include/fs/Makefile.am
+index e0da4b3..d6d7af0 100644
+--- a/include/fs/Makefile.am
++++ b/include/fs/Makefile.am
+@@ -8,6 +8,6 @@ USER_H =
+ EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
+ 
+ if CONFIG_KERNEL
+-kerneldir = @prefix@/src/spl-$(VERSION)/include/fs
++kerneldir = @prefix@/libexec/spl/include/fs
+ kernel_HEADERS = $(KERNEL_H)
+ endif
+diff --git a/include/linux/Makefile.am b/include/linux/Makefile.am
+index 1cca44a..e0d843b 100644
+--- a/include/linux/Makefile.am
++++ b/include/linux/Makefile.am
+@@ -19,6 +19,6 @@ USER_H =
+ EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
+ 
+ if CONFIG_KERNEL
+-kerneldir = @prefix@/src/spl-$(VERSION)/include/linux
++kerneldir = @prefix@/libexec/spl/include/linux
+ kernel_HEADERS = $(KERNEL_H)
+ endif
+diff --git a/include/rpc/Makefile.am b/include/rpc/Makefile.am
+index cfc8246..4fbd33d 100644
+--- a/include/rpc/Makefile.am
++++ b/include/rpc/Makefile.am
+@@ -9,6 +9,6 @@ USER_H =
+ EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
+ 
+ if CONFIG_KERNEL
+-kerneldir = @prefix@/src/spl-$(VERSION)/include/rpc
++kerneldir = @prefix@/libexec/spl/include/rpc
+ kernel_HEADERS = $(KERNEL_H)
+ endif
+diff --git a/include/sharefs/Makefile.am b/include/sharefs/Makefile.am
+index 10e7093..febecdf 100644
+--- a/include/sharefs/Makefile.am
++++ b/include/sharefs/Makefile.am
+@@ -8,6 +8,6 @@ USER_H =
+ EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
+ 
+ if CONFIG_KERNEL
+-kerneldir = @prefix@/src/spl-$(VERSION)/include/sharefs
++kerneldir = @prefix@/libexec/spl/include/sharefs
+ kernel_HEADERS = $(KERNEL_H)
+ endif
+diff --git a/include/sys/Makefile.am b/include/sys/Makefile.am
+index 2d21c57..3958cfd 100644
+--- a/include/sys/Makefile.am
++++ b/include/sys/Makefile.am
+@@ -104,7 +104,7 @@ USER_H =
+ EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
+ 
+ if CONFIG_KERNEL
+-kerneldir = @prefix@/src/spl-$(VERSION)/include/sys
++kerneldir = @prefix@/libexec/spl/include/sys
+ kernel_HEADERS = $(KERNEL_H)
+ endif
+ 
+diff --git a/include/sys/fm/Makefile.am b/include/sys/fm/Makefile.am
+index 2821cbe..a84ce8e 100644
+--- a/include/sys/fm/Makefile.am
++++ b/include/sys/fm/Makefile.am
+@@ -9,6 +9,6 @@ USER_H =
+ EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
+ 
+ if CONFIG_KERNEL
+-kerneldir = @prefix@/src/spl-$(VERSION)/include/sys/fm
++kerneldir = @prefix@/libexec/spl/include/sys/fm
+ kernel_HEADERS = $(KERNEL_H)
+ endif
+diff --git a/include/sys/fs/Makefile.am b/include/sys/fs/Makefile.am
+index 581083e..0c35fb7 100644
+--- a/include/sys/fs/Makefile.am
++++ b/include/sys/fs/Makefile.am
+@@ -8,6 +8,6 @@ USER_H =
+ EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
+ 
+ if CONFIG_KERNEL
+-kerneldir = @prefix@/src/spl-$(VERSION)/include/sys/fs
++kerneldir = @prefix@/libexec/spl/include/sys/fs
+ kernel_HEADERS = $(KERNEL_H)
+ endif
+diff --git a/include/sys/sysevent/Makefile.am b/include/sys/sysevent/Makefile.am
+index 63d9af3..de1aa18 100644
+--- a/include/sys/sysevent/Makefile.am
++++ b/include/sys/sysevent/Makefile.am
+@@ -8,6 +8,6 @@ USER_H =
+ EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
+ 
+ if CONFIG_KERNEL
+-kerneldir = @prefix@/src/spl-$(VERSION)/include/sys/sysevent
++kerneldir = @prefix@/libexec/spl/include/sys/sysevent
+ kernel_HEADERS = $(KERNEL_H)
+ endif
+diff --git a/include/util/Makefile.am b/include/util/Makefile.am
+index b721b50..cbb9a05 100644
+--- a/include/util/Makefile.am
++++ b/include/util/Makefile.am
+@@ -9,6 +9,6 @@ USER_H =
+ EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
+ 
+ if CONFIG_KERNEL
+-kerneldir = @prefix@/src/spl-$(VERSION)/include/util
++kerneldir = @prefix@/libexec/spl/include/util
+ kernel_HEADERS = $(KERNEL_H)
+ endif
+diff --git a/include/vm/Makefile.am b/include/vm/Makefile.am
+index 7faab0a..8148b3d 100644
+--- a/include/vm/Makefile.am
++++ b/include/vm/Makefile.am
+@@ -10,6 +10,6 @@ USER_H =
+ EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
+ 
+ if CONFIG_KERNEL
+-kerneldir = @prefix@/src/spl-$(VERSION)/include/vm
++kerneldir = @prefix@/libexec/spl/include/vm
+ kernel_HEADERS = $(KERNEL_H)
+ endif
+diff --git a/module/Makefile.in b/module/Makefile.in
+index 41c1010..3141397 100644
+--- a/module/Makefile.in
++++ b/module/Makefile.in
+@@ -21,15 +21,15 @@ clean:
+ modules_install:
+ 	@# Install the kernel modules
+ 	$(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` $@ \
+-		INSTALL_MOD_PATH=$(DESTDIR)$(INSTALL_MOD_PATH) \
++		INSTALL_MOD_PATH=@prefix@/$(INSTALL_MOD_PATH) \
+ 		INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \
+ 		KERNELRELEASE=@LINUX_VERSION@
+ 	@# Remove extraneous build products when packaging
+-	kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
++	kmoddir=@prefix@/$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
+ 	if [ -n $$kmoddir ]; then \
+ 		find $$kmoddir -name 'modules.*' | xargs $(RM); \
+ 	fi
+-	sysmap=$(DESTDIR)$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \
++	sysmap=@prefix@/$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \
+ 	if [ -f $$sysmap ]; then \
+ 		depmod -ae -F $$sysmap @LINUX_VERSION@; \
+ 	fi
diff --git a/pkgs/os-specific/linux/spl/kernel-3.16.patch b/pkgs/os-specific/linux/spl/kernel-3.16.patch
deleted file mode 100644
index 25641c7a384f..000000000000
--- a/pkgs/os-specific/linux/spl/kernel-3.16.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From e3020723dc43af2bc22af0d68571a61daf9b44d0 Mon Sep 17 00:00:00 2001
-From: Turbo Fredriksson <turbo@bayour.com>
-Date: Sun, 14 Sep 2014 15:47:22 +0000
-Subject: [PATCH] Linux 3.16 compat: smp_mb__after_clear_bit()
-
-The smp_mb__{before,after}_clear_bit functions have been renamed
-smp_mb__{before,after}_atomic.  Rather than adding a compatibility
-function to handle this the code has been updated to use smp_wmb().
-
-This has the advantage of being a stable functionally equivalent
-interface.  On many architectures smp_mb__after_clear_bit() expands
-to smp_wmb().  Others might be able to do something slightly more
-efficient but this will be safe and correct on all of them.
-
-Signed-off-by: Turbo Fredriksson <turbo@bayour.com>
-Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
-Closes #386
----
- module/spl/spl-kmem.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c
-index 6de513e..79954eb 100644
---- a/module/spl/spl-kmem.c
-+++ b/module/spl/spl-kmem.c
-@@ -2365,7 +2365,7 @@ spl_kmem_cache_reap_now(spl_kmem_cache_t *skc, int count)
- 
- 	spl_slab_reclaim(skc, count, 1);
- 	clear_bit(KMC_BIT_REAPING, &skc->skc_flags);
--	smp_mb__after_clear_bit();
-+	smp_wmb();
- 	wake_up_bit(&skc->skc_flags, KMC_BIT_REAPING);
- out:
- 	atomic_dec(&skc->skc_ref);
diff --git a/pkgs/os-specific/linux/spl/kernel-3.17.patch b/pkgs/os-specific/linux/spl/kernel-3.17.patch
deleted file mode 100644
index f5ce2c8805d8..000000000000
--- a/pkgs/os-specific/linux/spl/kernel-3.17.patch
+++ /dev/null
@@ -1,175 +0,0 @@
-From 2fc44f66ec9b83069593d87cf311069458c0d5ae Mon Sep 17 00:00:00 2001
-From: Ned Bass <bass6@llnl.gov>
-Date: Fri, 8 Aug 2014 17:41:22 -0700
-Subject: [PATCH] Linux 3.17 compat: remove wait_on_bit action function
-
-Linux kernel 3.17 removes the action function argument from
-wait_on_bit().  Add autoconf test and compatibility macro to support
-the new interface.
-
-The former "wait_on_bit" interface required an 'action' function to
-be provided which does the actual waiting. There were over 20 such
-functions in the kernel, many of them identical, though most cases
-can be satisfied by one of just two functions: one which uses
-io_schedule() and one which just uses schedule().  This API change
-was made to consolidate all of those redundant wait functions.
-
-References: torvalds/linux@7431620
-
-Signed-off-by: Ned Bass <bass6@llnl.gov>
-Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
-Closes #378
----
- config/spl-build.m4         | 26 ++++++++++++++++++++++++++
- include/linux/Makefile.am   |  1 +
- include/linux/wait_compat.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
- include/sys/types.h         |  1 +
- module/spl/spl-kmem.c       | 11 ++---------
- 5 files changed, 75 insertions(+), 9 deletions(-)
- create mode 100644 include/linux/wait_compat.h
-
-diff --git a/config/spl-build.m4 b/config/spl-build.m4
-index eef5233..2514d8c 100644
---- a/config/spl-build.m4
-+++ b/config/spl-build.m4
-@@ -94,6 +94,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
- 	SPL_AC_2ARGS_VFS_GETATTR
- 	SPL_AC_USLEEP_RANGE
- 	SPL_AC_KMEM_CACHE_ALLOCFLAGS
-+	SPL_AC_WAIT_ON_BIT
- ])
- 
- AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
-@@ -2570,3 +2571,28 @@ AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
- 		])
- 	])
- ])
-+
-+dnl #
-+dnl # 3.17 API change,
-+dnl # wait_on_bit() no longer requires an action argument. The former
-+dnl # "wait_on_bit" interface required an 'action' function to be provided
-+dnl # which does the actual waiting. There were over 20 such functions in the
-+dnl # kernel, many of them identical, though most cases can be satisfied by one
-+dnl # of just two functions: one which uses io_schedule() and one which just
-+dnl # uses schedule().  This API change was made to consolidate all of those
-+dnl # redundant wait functions.
-+dnl #
-+AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
-+	AC_MSG_CHECKING([whether wait_on_bit() takes an action])
-+	SPL_LINUX_TRY_COMPILE([
-+		#include <linux/wait.h>
-+	],[
-+		int (*action)(void *) = NULL;
-+		wait_on_bit(NULL, 0, action, 0);
-+	],[
-+		AC_MSG_RESULT(yes)
-+		AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])
-+	],[
-+		AC_MSG_RESULT(no)
-+	])
-+])
-diff --git a/include/linux/Makefile.am b/include/linux/Makefile.am
-index 59f2ec5..ec7023d 100644
---- a/include/linux/Makefile.am
-+++ b/include/linux/Makefile.am
-@@ -17,6 +17,7 @@ KERNEL_H = \
- 	$(top_srcdir)/include/linux/sysctl_compat.h \
- 	$(top_srcdir)/include/linux/time_compat.h \
- 	$(top_srcdir)/include/linux/uaccess_compat.h \
-+	$(top_srcdir)/include/linux/wait_compat.h \
- 	$(top_srcdir)/include/linux/zlib_compat.h
- 
- USER_H =
-diff --git a/include/linux/wait_compat.h b/include/linux/wait_compat.h
-new file mode 100644
-index 0000000..66f9a9a
---- /dev/null
-+++ b/include/linux/wait_compat.h
-@@ -0,0 +1,45 @@
-+/*****************************************************************************\
-+ *  Copyright (C) 2007-2014 Lawrence Livermore National Security, LLC.
-+ *  Copyright (C) 2007 The Regents of the University of California.
-+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-+ *  Written by Brian Behlendorf <behlendorf1@llnl.gov>.
-+ *  UCRL-CODE-235197
-+ *
-+ *  This file is part of the SPL, Solaris Porting Layer.
-+ *  For details, see <http://zfsonlinux.org/>.
-+ *
-+ *  The SPL is free software; you can redistribute it and/or modify it
-+ *  under the terms of the GNU General Public License as published by the
-+ *  Free Software Foundation; either version 2 of the License, or (at your
-+ *  option) any later version.
-+ *
-+ *  The SPL is distributed in the hope that it will be useful, but WITHOUT
-+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-+ *  for more details.
-+ *
-+ *  You should have received a copy of the GNU General Public License along
-+ *  with the SPL.  If not, see <http://www.gnu.org/licenses/>.
-+\*****************************************************************************/
-+
-+#ifndef _SPL_WAIT_COMPAT_H
-+#define _SPL_WAIT_COMPAT_H
-+
-+
-+#ifndef HAVE_WAIT_ON_BIT_ACTION
-+#  define spl_wait_on_bit(word, bit, mode) wait_on_bit(word, bit, mode)
-+#else
-+
-+static inline int
-+spl_bit_wait(void *word)
-+{
-+        schedule();
-+        return 0;
-+}
-+
-+#define spl_wait_on_bit(word, bit, mode)			\
-+	wait_on_bit(word, bit, spl_bit_wait, mode)
-+
-+#endif /* HAVE_WAIT_ON_BIT_ACTION */
-+
-+#endif /* SPL_WAIT_COMPAT_H */
-diff --git a/include/sys/types.h b/include/sys/types.h
-index decb6bb..fcec0fa 100644
---- a/include/sys/types.h
-+++ b/include/sys/types.h
-@@ -43,6 +43,7 @@
- #include <linux/zlib_compat.h>
- #include <linux/mm_compat.h>
- #include <linux/delay.h>
-+#include <linux/wait_compat.h>
- 
- #ifndef HAVE_UINTPTR_T
- typedef unsigned long			uintptr_t;
-diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c
-index 0a9d775..6de513e 100644
---- a/module/spl/spl-kmem.c
-+++ b/module/spl/spl-kmem.c
-@@ -1900,13 +1900,6 @@ spl_cache_grow_wait(spl_kmem_cache_t *skc)
- 	return !test_bit(KMC_BIT_GROWING, &skc->skc_flags);
- }
- 
--static int
--spl_cache_reclaim_wait(void *word)
--{
--	schedule();
--	return 0;
--}
--
- /*
-  * No available objects on any slabs, create a new slab.  Note that this
-  * functionality is disabled for KMC_SLAB caches which are backed by the
-@@ -1928,8 +1921,8 @@ spl_cache_grow(spl_kmem_cache_t *skc, int flags, void **obj)
- 	 * then return so the local magazine can be rechecked for new objects.
- 	 */
- 	if (test_bit(KMC_BIT_REAPING, &skc->skc_flags)) {
--		rc = wait_on_bit(&skc->skc_flags, KMC_BIT_REAPING,
--		    spl_cache_reclaim_wait, TASK_UNINTERRUPTIBLE);
-+		rc = spl_wait_on_bit(&skc->skc_flags, KMC_BIT_REAPING,
-+		    TASK_UNINTERRUPTIBLE);
- 		SRETURN(rc ? rc : -EAGAIN);
- 	}
- 
diff --git a/pkgs/os-specific/linux/spl/time.patch b/pkgs/os-specific/linux/spl/time.patch
new file mode 100644
index 000000000000..6b1e23bc05ef
--- /dev/null
+++ b/pkgs/os-specific/linux/spl/time.patch
@@ -0,0 +1,18 @@
+diff --git a/module/spl/spl-time.c b/module/spl/spl-time.c
+index 0ed49cc..b0fad4f 100644
+--- a/module/spl/spl-time.c
++++ b/module/spl/spl-time.c
+@@ -40,12 +40,7 @@ extern unsigned long long monotonic_clock(void);
+ void
+ __gethrestime(timestruc_t *ts)
+ {
+-	struct timespec tspec;
+-
+-	getnstimeofday(&tspec);
+-
+-	ts->tv_sec = tspec.tv_sec;
+-	ts->tv_nsec = tspec.tv_nsec;
++	*ts = current_kernel_time();
+ }
+ EXPORT_SYMBOL(__gethrestime);
+ 
diff --git a/pkgs/os-specific/linux/sysdig/default.nix b/pkgs/os-specific/linux/sysdig/default.nix
index 6b9526c15b27..1dec2dcb80b8 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.1.93";
+    version = "0.1.95";
     name="${baseName}-${version}";
     url="https://github.com/draios/sysdig/archive/${version}.tar.gz";
-    sha256 = "0rcbls1i82z2mwd3kcsidvhbb0xf0f4p7l2z3168wbpsh5nm9clz";
+    sha256 = "1h7yjfpgnhmzvc9862k7salc80sw7chmxx5chh4xw1lzsjz1nz5s";
   };
   buildInputs = [
     cmake zlib luajit
diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix
index e1b8f9ea92c0..a55d71a3c08c 100644
--- a/pkgs/os-specific/linux/systemd/default.nix
+++ b/pkgs/os-specific/linux/systemd/default.nix
@@ -86,7 +86,7 @@ stdenv.mkDerivation rec {
 
   # This is needed because systemd uses the gold linker, which doesn't
   # yet have the wrapper script to add rpath flags automatically.
-  NIX_LDFLAGS = "-rpath ${pam}/lib -rpath ${libcap}/lib -rpath ${acl}/lib -rpath ${stdenv.cc.gcc}/lib";
+  NIX_LDFLAGS = "-rpath ${pam}/lib -rpath ${libcap}/lib -rpath ${acl}/lib -rpath ${stdenv.cc.cc}/lib";
 
   PYTHON_BINARY = "${coreutils}/bin/env python"; # don't want a build time dependency on Python
 
diff --git a/pkgs/os-specific/linux/util-linux/default.nix b/pkgs/os-specific/linux/util-linux/default.nix
index 3b76eb63ea5f..8842e76362a3 100644
--- a/pkgs/os-specific/linux/util-linux/default.nix
+++ b/pkgs/os-specific/linux/util-linux/default.nix
@@ -8,6 +8,16 @@ stdenv.mkDerivation rec {
     sha256 = "e0457f715b73f4a349e1acb08cb410bf0edc9a74a3f75c357070f31f70e33cd6";
   };
 
+  patches = [ ./rtcwake-search-PATH-for-shutdown.patch ];
+
+  #FIXME: make it also work on non-nixos?
+  postPatch = ''
+    # Substituting store paths would create a circular dependency on systemd
+    substituteInPlace include/pathnames.h \
+      --replace "/bin/login" "/run/current-system/sw/bin/login" \
+      --replace "/sbin/shutdown" "/run/current-system/sw/bin/shutdown"
+  '';
+
   crossAttrs = {
     # Work around use of `AC_RUN_IFELSE'.
     preConfigure = "export scanf_cv_type_modifier=ms";
diff --git a/pkgs/os-specific/linux/util-linux/rtcwake-search-PATH-for-shutdown.patch b/pkgs/os-specific/linux/util-linux/rtcwake-search-PATH-for-shutdown.patch
new file mode 100644
index 000000000000..92cb07d43834
--- /dev/null
+++ b/pkgs/os-specific/linux/util-linux/rtcwake-search-PATH-for-shutdown.patch
@@ -0,0 +1,30 @@
+Search $PATH for the shutdown binary instead of hard-coding /sbin/shutdown,
+which isn't valid on NixOS (and a compatibility link on most other modern
+distros anyway).
+
+  -- nckx <tobias.geerinckx.rice@gmail.com>
+
+diff -Naur a/include/pathnames.h b/include/pathnames.h
+--- a/include/pathnames.h	2014-09-16 14:37:06.138551680 +0200
++++ b/include/pathnames.h	2015-01-01 20:41:02.510948314 +0100
+@@ -43,7 +43,7 @@
+ #define _PATH_INITTAB		"/etc/inittab"
+ #define _PATH_RC		"/etc/rc"
+ #define _PATH_REBOOT		"/sbin/reboot"
+-#define _PATH_SHUTDOWN		"/sbin/shutdown"
++#define _PATH_SHUTDOWN		"shutdown"
+ #define _PATH_SINGLE		"/etc/singleboot"
+ #define _PATH_SHUTDOWN_CONF	"/etc/shutdown.conf"
+ 
+diff -Naur a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c
+--- a/sys-utils/rtcwake.c	2014-10-24 11:21:20.447389309 +0200
++++ b/sys-utils/rtcwake.c	2015-01-01 20:57:59.398911209 +0100
+@@ -582,7 +582,7 @@
+ 		arg[i]   = NULL;
+ 
+ 		if (!dryrun) {
+-			execv(arg[0], arg);
++			execvp(arg[0], arg);
+ 
+ 			warn(_("failed to execute %s"), _PATH_SHUTDOWN);
+ 			rc = EXIT_FAILURE;
diff --git a/pkgs/os-specific/linux/xf86-input-wacom/default.nix b/pkgs/os-specific/linux/xf86-input-wacom/default.nix
index 2d3dc4888a3a..5242aabe507c 100644
--- a/pkgs/os-specific/linux/xf86-input-wacom/default.nix
+++ b/pkgs/os-specific/linux/xf86-input-wacom/default.nix
@@ -3,11 +3,11 @@
 , ncurses, pkgconfig, randrproto, xorgserver, xproto, udev, libXinerama, pixman }:
 
 stdenv.mkDerivation rec {
-  name = "xf86-input-wacom-0.27.0";
+  name = "xf86-input-wacom-0.28.0";
 
   src = fetchurl {
     url = "mirror://sourceforge/linuxwacom/${name}.tar.bz2";
-    sha256 = "0hpc0waa91d34h2fw1sjhxzn2xya51627jrps9rw4a2zb5hh6a6i";
+    sha256 = "0fr4ssdam8nxkahznqril8q2pbakb4r9ghhg61yl7997yy7006bw";
   };
 
   buildInputs = [ inputproto libX11 libXext libXi libXrandr libXrender
diff --git a/pkgs/os-specific/linux/zfs/3.19-compat-git.patch b/pkgs/os-specific/linux/zfs/3.19-compat-git.patch
new file mode 100644
index 000000000000..07c4eb55acda
--- /dev/null
+++ b/pkgs/os-specific/linux/zfs/3.19-compat-git.patch
@@ -0,0 +1,146 @@
+From 5a562310d706c3c2f2adc067fe73f1061c4fc386 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@higgsboson.tk>
+Date: Sat, 7 Feb 2015 13:41:01 +0100
+Subject: [PATCH] Linux 3.19 compat: file_inode was added
+
+struct access f->f_dentry->d_inode was replaced by accessor function
+file_inode(f)
+---
+ config/kernel-file-inode.m4 | 20 ++++++++++++++++++++
+ config/kernel.m4            |  1 +
+ include/linux/Makefile.am   |  1 +
+ include/linux/fs_compat.h   | 38 ++++++++++++++++++++++++++++++++++++++
+ include/sys/zpl.h           |  1 +
+ module/zfs/zpl_file.c       |  4 ++--
+ 6 files changed, 63 insertions(+), 2 deletions(-)
+ create mode 100644 config/kernel-file-inode.m4
+ create mode 100644 include/linux/fs_compat.h
+
+diff --git a/config/kernel-file-inode.m4 b/config/kernel-file-inode.m4
+new file mode 100644
+index 0000000..13af4e6
+--- /dev/null
++++ b/config/kernel-file-inode.m4
+@@ -0,0 +1,20 @@
++dnl #
++dnl # 3.19 API change
++dnl # struct access f->f_dentry->d_inode was replaced by accessor function
++dnl # file_inode(f)
++dnl #
++AC_DEFUN([ZFS_AC_KERNEL_FILE_INODE], [
++	AC_MSG_CHECKING([whether file_inode() is available])
++	ZFS_LINUX_TRY_COMPILE([
++		#include <linux/fs.h>
++	],[
++		struct file *f = NULL;
++		file_inode(f);
++	],[
++		AC_MSG_RESULT(yes)
++		AC_DEFINE(HAVE_FILE_INODE, 1,
++		          [file_inode() is available])
++	],[
++		AC_MSG_RESULT(no)
++	])
++])
+diff --git a/config/kernel.m4 b/config/kernel.m4
+index bdfb19c..e0b7954 100644
+--- a/config/kernel.m4
++++ b/config/kernel.m4
+@@ -61,6 +61,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
+ 	ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL
+ 	ZFS_AC_KERNEL_CURRENT_UMASK
+ 	ZFS_AC_KERNEL_SHOW_OPTIONS
++	ZFS_AC_KERNEL_FILE_INODE
+ 	ZFS_AC_KERNEL_FSYNC
+ 	ZFS_AC_KERNEL_EVICT_INODE
+ 	ZFS_AC_KERNEL_DIRTY_INODE_WITH_FLAGS
+diff --git a/include/linux/Makefile.am b/include/linux/Makefile.am
+index d00b1c8..480af26 100644
+--- a/include/linux/Makefile.am
++++ b/include/linux/Makefile.am
+@@ -4,6 +4,7 @@ KERNEL_H = \
+ 	$(top_srcdir)/include/linux/dcache_compat.h \
+ 	$(top_srcdir)/include/linux/xattr_compat.h \
+ 	$(top_srcdir)/include/linux/vfs_compat.h \
++	$(top_srcdir)/include/linux/fs_compat.h \
+ 	$(top_srcdir)/include/linux/blkdev_compat.h \
+ 	$(top_srcdir)/include/linux/utsname_compat.h
+ 
+diff --git a/include/linux/fs_compat.h b/include/linux/fs_compat.h
+new file mode 100644
+index 0000000..7860d75
+--- /dev/null
++++ b/include/linux/fs_compat.h
+@@ -0,0 +1,38 @@
++/*
++ * CDDL HEADER START
++ *
++ * The contents of this file are subject to the terms of the
++ * Common Development and Distribution License (the "License").
++ * You may not use this file except in compliance with the License.
++ *
++ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
++ * or http://www.opensolaris.org/os/licensing.
++ * See the License for the specific language governing permissions
++ * and limitations under the License.
++ *
++ * When distributing Covered Code, include this CDDL HEADER in each
++ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
++ * If applicable, add the following below this CDDL HEADER, with the
++ * fields enclosed by brackets "[]" replaced with your own identifying
++ * information: Portions Copyright [yyyy] [name of copyright owner]
++ *
++ * CDDL HEADER END
++ */
++
++/*
++ * Copyright (C) 2015 Jörg Thalheim.
++ */
++
++#ifndef _ZFS_FS_H
++#define	_ZFS_FS_H
++
++#include <linux/fs.h>
++
++#ifndef HAVE_FILE_INODE
++static inline struct inode *file_inode(const struct file *f)
++{
++    return f->f_dentry->d_inode;
++}
++#endif /* HAVE_FILE_INODE */
++
++#endif /* _ZFS_FS_H */
+diff --git a/include/sys/zpl.h b/include/sys/zpl.h
+index 3fc5d97..20eb27b 100644
+--- a/include/sys/zpl.h
++++ b/include/sys/zpl.h
+@@ -31,6 +31,7 @@
+ #include <linux/exportfs.h>
+ #include <linux/falloc.h>
+ #include <linux/file_compat.h>
++#include <linux/fs_compat.h>
+ #include <linux/task_io_accounting_ops.h>
+ #include <linux/vfs_compat.h>
+ #include <linux/writeback.h>
+diff --git a/module/zfs/zpl_file.c b/module/zfs/zpl_file.c
+index 1f4f219..5f5bbba 100644
+--- a/module/zfs/zpl_file.c
++++ b/module/zfs/zpl_file.c
+@@ -617,7 +617,7 @@ zpl_fallocate(struct file *filp, int mode, loff_t offset, loff_t len)
+ static int
+ zpl_ioctl_getflags(struct file *filp, void __user *arg)
+ {
+-	struct inode *ip = filp->f_dentry->d_inode;
++	struct inode *ip = file_inode(filp);
+ 	unsigned int ioctl_flags = 0;
+ 	uint64_t zfs_flags = ITOZ(ip)->z_pflags;
+ 	int error;
+@@ -653,7 +653,7 @@ zpl_ioctl_getflags(struct file *filp, void __user *arg)
+ static int
+ zpl_ioctl_setflags(struct file *filp, void __user *arg)
+ {
+-	struct inode	*ip = filp->f_dentry->d_inode;
++	struct inode	*ip = file_inode(filp);
+ 	uint64_t	zfs_flags = ITOZ(ip)->z_pflags;
+ 	unsigned int	ioctl_flags;
+ 	cred_t		*cr = CRED();
diff --git a/pkgs/os-specific/linux/zfs/bc151f7b312dea09c6ec5b9a320e65140789643a.patch b/pkgs/os-specific/linux/zfs/bc151f7b312dea09c6ec5b9a320e65140789643a.patch
deleted file mode 100644
index 382c8ce63eea..000000000000
--- a/pkgs/os-specific/linux/zfs/bc151f7b312dea09c6ec5b9a320e65140789643a.patch
+++ /dev/null
@@ -1,84 +0,0 @@
-From bc151f7b312dea09c6ec5b9a320e65140789643a Mon Sep 17 00:00:00 2001
-From: Ned Bass <bass6@llnl.gov>
-Date: Thu, 16 Oct 2014 13:52:56 -0700
-Subject: [PATCH] Remove checks for mandatory locks
-
-The Linux VFS handles mandatory locks generically so we shouldn't
-need to check for conflicting locks in zfs_read(), zfs_write(), or
-zfs_freesp().  Linux 3.18 removed the lock_may_read() and
-lock_may_write() interfaces which we were relying on for this
-purpose.  Rather than emulating those interfaces we remove the
-redundant checks.
-
-Signed-off-by: Ned Bass <bass6@llnl.gov>
-Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
-Closes #2804
----
- module/zfs/zfs_vnops.c | 18 ------------------
- module/zfs/zfs_znode.c | 10 ----------
- 2 files changed, 28 deletions(-)
-
-diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c
-index 33f9e0e..2f55e56 100644
---- a/module/zfs/zfs_vnops.c
-+++ b/module/zfs/zfs_vnops.c
-@@ -474,15 +474,6 @@ zfs_read(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
- 	}
- 
- 	/*
--	 * Check for mandatory locks
--	 */
--	if (mandatory_lock(ip) &&
--	    !lock_may_read(ip, uio->uio_loffset, uio->uio_resid)) {
--		ZFS_EXIT(zsb);
--		return (SET_ERROR(EAGAIN));
--	}
--
--	/*
- 	 * If we're in FRSYNC mode, sync out this znode before reading it.
- 	 */
- 	if (ioflag & FRSYNC || zsb->z_os->os_sync == ZFS_SYNC_ALWAYS)
-@@ -651,15 +642,6 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
- 	}
- 
- 	/*
--	 * Check for mandatory locks before calling zfs_range_lock()
--	 * in order to prevent a deadlock with locks set via fcntl().
--	 */
--	if (mandatory_lock(ip) && !lock_may_write(ip, woff, n)) {
--		ZFS_EXIT(zsb);
--		return (SET_ERROR(EAGAIN));
--	}
--
--	/*
- 	 * Pre-fault the pages to ensure slow (eg NFS) pages
- 	 * don't hold up txg.
- 	 * Skip this if uio contains loaned arc_buf.
-diff --git a/module/zfs/zfs_znode.c b/module/zfs/zfs_znode.c
-index 90dbfd3..f02c021 100644
---- a/module/zfs/zfs_znode.c
-+++ b/module/zfs/zfs_znode.c
-@@ -1546,7 +1546,6 @@ zfs_trunc(znode_t *zp, uint64_t end)
- int
- zfs_freesp(znode_t *zp, uint64_t off, uint64_t len, int flag, boolean_t log)
- {
--	struct inode *ip = ZTOI(zp);
- 	dmu_tx_t *tx;
- 	zfs_sb_t *zsb = ZTOZSB(zp);
- 	zilog_t *zilog = zsb->z_log;
-@@ -1567,15 +1566,6 @@ zfs_freesp(znode_t *zp, uint64_t off, uint64_t len, int flag, boolean_t log)
- 		goto out;
- 	}
- 
--	/*
--	 * Check for any locks in the region to be freed.
--	 */
--	if (ip->i_flock && mandatory_lock(ip)) {
--		uint64_t length = (len ? len : zp->z_size - off);
--		if (!lock_may_write(ip, off, length))
--			return (SET_ERROR(EAGAIN));
--	}
--
- 	if (len == 0) {
- 		error = zfs_trunc(zp, off);
- 	} else {
diff --git a/pkgs/os-specific/linux/zfs/default.nix b/pkgs/os-specific/linux/zfs/default.nix
index 3661137fc295..11b77c3d66f4 100644
--- a/pkgs/os-specific/linux/zfs/default.nix
+++ b/pkgs/os-specific/linux/zfs/default.nix
@@ -1,7 +1,6 @@
-{ stdenv, fetchFromGitHub, kernel, spl, perl, autoconf, automake, libtool, zlib, libuuid, coreutils, utillinux }:
+{ callPackage, fetchFromGitHub, ... } @ args:
 
-stdenv.mkDerivation rec {
-  name = "zfs-${version}-${kernel.version}";
+callPackage ./generic.nix (args // rec {
   version = "0.6.3-1.2";
 
   src = fetchFromGitHub {
@@ -15,64 +14,4 @@ stdenv.mkDerivation rec {
     ./mount_zfs_prefix.patch
     ./nix-build.patch # Remove in >=0.6.4
   ];
-
-  buildInputs = [ spl perl autoconf automake libtool zlib libuuid coreutils ];
-
-  # for zdb to get the rpath to libgcc_s, needed for pthread_cancel to work
-  NIX_CFLAGS_LINK = "-lgcc_s";
-
-  preConfigure = ''
-    substituteInPlace ./module/zfs/zfs_ctldir.c   --replace "umount -t zfs"           "${utillinux}/bin/umount -t zfs"
-    substituteInPlace ./module/zfs/zfs_ctldir.c   --replace "mount -t zfs"            "${utillinux}/bin/mount -t zfs"
-    substituteInPlace ./lib/libzfs/libzfs_mount.c --replace "/bin/umount"             "${utillinux}/bin/umount"
-    substituteInPlace ./lib/libzfs/libzfs_mount.c --replace "/bin/mount"              "${utillinux}/bin/mount"
-    substituteInPlace ./udev/rules.d/*            --replace "/lib/udev/vdev_id"       "$out/lib/udev/vdev_id"
-    substituteInPlace ./cmd/ztest/ztest.c         --replace "/usr/sbin/ztest"         "$out/sbin/ztest"
-    substituteInPlace ./cmd/ztest/ztest.c         --replace "/usr/sbin/zdb"           "$out/sbin/zdb"
-    substituteInPlace ./config/user-systemd.m4    --replace "/usr/lib/modules-load.d" "$out/etc/modules-load.d"
-    substituteInPlace ./config/zfs-build.m4       --replace "\$sysconfdir/init.d"     "$out/etc/init.d"
-    substituteInPlace ./etc/zfs/Makefile.am       --replace "\$(sysconfdir)"          "$out/etc"
-    substituteInPlace ./cmd/zed/Makefile.am       --replace "\$(sysconfdir)"          "$out/etc"
-
-    ./autogen.sh
-  '';
-
-  configureFlags = [
-    "--enable-systemd"
-    "--with-linux=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
-    "--with-linux-obj=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
-    "--with-spl=${spl}/libexec/spl"
-    "--with-dracutdir=$(out)/lib/dracut"
-    "--with-udevdir=$(out)/lib/udev"
-    "--with-systemdunitdir=$(out)/etc/systemd/system"
-    "--with-systemdpresetdir=$(out)/etc/systemd/system-preset"
-    "--sysconfdir=/etc"
-    "--localstatedir=/var"
-  ];
-
-  enableParallelBuilding = true;
-
-  # Remove provided services as they are buggy
-  postInstall = ''
-    rm $out/etc/systemd/system/zfs-import-*.service
-
-    sed -i '/zfs-import-scan.service/d' $out/etc/systemd/system/*
-
-    for i in $out/etc/systemd/system/*; do
-      substituteInPlace $i --replace "zfs-import-cache.service" "zfs-import.target"
-    done
-  '';
-
-  meta = {
-    description = "ZFS Filesystem Linux Kernel module";
-    longDescription = ''
-      ZFS is a filesystem that combines a logical volume manager with a
-      Copy-On-Write filesystem with data integrity detection and repair,
-      snapshotting, cloning, block devices, deduplication, and more.
-      '';
-    homepage = http://zfsonlinux.org/;
-    license = stdenv.lib.licenses.cddl;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = with stdenv.lib.maintainers; [ jcumming wizeman ];
-  };
-}
+})
diff --git a/pkgs/os-specific/linux/zfs/generic.nix b/pkgs/os-specific/linux/zfs/generic.nix
new file mode 100644
index 000000000000..ba3884a5e9ba
--- /dev/null
+++ b/pkgs/os-specific/linux/zfs/generic.nix
@@ -0,0 +1,94 @@
+{ stdenv, fetchFromGitHub, autoconf, automake, libtool, utillinux
+, configFile ? "all"
+
+# Userspace dependencies
+, zlib, libuuid, python
+
+# Kernel dependencies
+, kernel ? null, spl ? null
+
+# Version specific settings
+, version, src, patches
+, ...
+}:
+
+with stdenv.lib;
+let
+  buildKernel = any (n: n == configFile) [ "kernel" "all" ];
+  buildUser = any (n: n == configFile) [ "user" "all" ];
+in
+
+assert any (n: n == configFile) [ "kernel" "user" "all" ];
+assert buildKernel -> kernel != null && spl != null;
+
+stdenv.mkDerivation rec {
+  name = "zfs-${configFile}-${version}${optionalString buildKernel "-${kernel.version}"}";
+
+  inherit version src patches;
+
+  buildInputs = [ autoconf automake libtool ]
+    ++ optionals buildKernel [ spl ]
+    ++ optionals buildUser [ zlib libuuid python ];
+
+  # for zdb to get the rpath to libgcc_s, needed for pthread_cancel to work
+  NIX_CFLAGS_LINK = "-lgcc_s";
+
+  preConfigure = ''
+    substituteInPlace ./module/zfs/zfs_ctldir.c   --replace "umount -t zfs"           "${utillinux}/bin/umount -t zfs"
+    substituteInPlace ./module/zfs/zfs_ctldir.c   --replace "mount -t zfs"            "${utillinux}/bin/mount -t zfs"
+    substituteInPlace ./lib/libzfs/libzfs_mount.c --replace "/bin/umount"             "${utillinux}/bin/umount"
+    substituteInPlace ./lib/libzfs/libzfs_mount.c --replace "/bin/mount"              "${utillinux}/bin/mount"
+    substituteInPlace ./udev/rules.d/*            --replace "/lib/udev/vdev_id"       "$out/lib/udev/vdev_id"
+    substituteInPlace ./cmd/ztest/ztest.c         --replace "/usr/sbin/ztest"         "$out/sbin/ztest"
+    substituteInPlace ./cmd/ztest/ztest.c         --replace "/usr/sbin/zdb"           "$out/sbin/zdb"
+    substituteInPlace ./config/user-systemd.m4    --replace "/usr/lib/modules-load.d" "$out/etc/modules-load.d"
+    substituteInPlace ./config/zfs-build.m4       --replace "\$sysconfdir/init.d"     "$out/etc/init.d"
+    substituteInPlace ./etc/zfs/Makefile.am       --replace "\$(sysconfdir)"          "$out/etc"
+    substituteInPlace ./cmd/zed/Makefile.am       --replace "\$(sysconfdir)"          "$out/etc"
+    substituteInPlace ./module/Makefile.in        --replace "/bin/cp"                 "cp"
+
+    ./autogen.sh
+  '';
+
+  configureFlags = [
+    "--with-config=${configFile}"
+  ] ++ optionals buildUser [
+    "--with-dracutdir=$(out)/lib/dracut"
+    "--with-udevdir=$(out)/lib/udev"
+    "--with-systemdunitdir=$(out)/etc/systemd/system"
+    "--with-systemdpresetdir=$(out)/etc/systemd/system-preset"
+    "--sysconfdir=/etc"
+    "--localstatedir=/var"
+    "--enable-systemd"
+  ] ++ optionals buildKernel [
+    "--with-spl=${spl}/libexec/spl"
+    "--with-linux=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
+    "--with-linux-obj=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
+  ];
+
+  enableParallelBuilding = true;
+
+  # Remove provided services as they are buggy
+  postInstall = optionalString buildUser ''
+    rm $out/etc/systemd/system/zfs-import-*.service
+
+    sed -i '/zfs-import-scan.service/d' $out/etc/systemd/system/*
+
+    for i in $out/etc/systemd/system/*; do
+      substituteInPlace $i --replace "zfs-import-cache.service" "zfs-import.target"
+    done
+  '';
+
+  meta = {
+    description = "ZFS Filesystem Linux Kernel module";
+    longDescription = ''
+      ZFS is a filesystem that combines a logical volume manager with a
+      Copy-On-Write filesystem with data integrity detection and repair,
+      snapshotting, cloning, block devices, deduplication, and more.
+      '';
+    homepage = http://zfsonlinux.org/;
+    license = licenses.cddl;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ jcumming wizeman wkennington ];
+  };
+}
diff --git a/pkgs/os-specific/linux/zfs/git.nix b/pkgs/os-specific/linux/zfs/git.nix
index fde5310deed2..da48880ae16d 100644
--- a/pkgs/os-specific/linux/zfs/git.nix
+++ b/pkgs/os-specific/linux/zfs/git.nix
@@ -1,73 +1,18 @@
-{ stdenv, fetchgit, kernel, spl_git, perl, autoconf, automake, libtool, zlib, libuuid, coreutils, utillinux }:
+{ callPackage, fetchgit, spl_git, ... } @ args:
 
-stdenv.mkDerivation {
-  name = "zfs-0.6.3-${kernel.version}";
+callPackage ./generic.nix (args // rec {
+  version = "33b4de5";
 
   src = fetchgit {
     url = git://github.com/zfsonlinux/zfs.git;
-    rev = "07dabd234dd51a1e5adc5bd21cddf5b5fdc70732";
-    sha256 = "1yqsfdhyzh33aisfvwqd692n5kfgnlz7yjixd2gqn8vx9bv0dz0b";
+    rev = "33b4de513ee81c2a87e1b954a9544a5eec1f8f94";
+    sha256 = "07kdml65l22z1xi8jif5hr7zr7a8mykyms4f5yrf8nyad20kp6il";
   };
 
-  patches = [ ./mount_zfs_prefix.patch ./nix-build.patch ./bc151f7b312dea09c6ec5b9a320e65140789643a.patch ];
-
-  buildInputs = [ spl_git perl autoconf automake libtool zlib libuuid coreutils ];
-
-  # for zdb to get the rpath to libgcc_s, needed for pthread_cancel to work
-  NIX_CFLAGS_LINK = "-lgcc_s";
-
-  preConfigure = ''
-    substituteInPlace ./module/zfs/zfs_ctldir.c   --replace "umount -t zfs"           "${utillinux}/bin/umount -t zfs"
-    substituteInPlace ./module/zfs/zfs_ctldir.c   --replace "mount -t zfs"            "${utillinux}/bin/mount -t zfs"
-    substituteInPlace ./lib/libzfs/libzfs_mount.c --replace "/bin/umount"             "${utillinux}/bin/umount"
-    substituteInPlace ./lib/libzfs/libzfs_mount.c --replace "/bin/mount"              "${utillinux}/bin/mount"
-    substituteInPlace ./udev/rules.d/*            --replace "/lib/udev/vdev_id"       "$out/lib/udev/vdev_id"
-    substituteInPlace ./cmd/ztest/ztest.c         --replace "/usr/sbin/ztest"         "$out/sbin/ztest"
-    substituteInPlace ./cmd/ztest/ztest.c         --replace "/usr/sbin/zdb"           "$out/sbin/zdb"
-    substituteInPlace ./config/user-systemd.m4    --replace "/usr/lib/modules-load.d" "$out/etc/modules-load.d"
-    substituteInPlace ./config/zfs-build.m4       --replace "\$sysconfdir/init.d"     "$out/etc/init.d"
-    substituteInPlace ./etc/zfs/Makefile.am       --replace "\$(sysconfdir)"          "$out/etc"
-    substituteInPlace ./cmd/zed/Makefile.am       --replace "\$(sysconfdir)"          "$out/etc"
-
-    ./autogen.sh
-  '';
-
-  configureFlags = [
-    "--enable-systemd"
-    "--with-linux=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
-    "--with-linux-obj=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
-    "--with-spl=${spl_git}/libexec/spl"
-    "--with-dracutdir=$(out)/lib/dracut"
-    "--with-udevdir=$(out)/lib/udev"
-    "--with-systemdunitdir=$(out)/etc/systemd/system"
-    "--with-systemdpresetdir=$(out)/etc/systemd/system-preset"
-    "--sysconfdir=/etc"
-    "--localstatedir=/var"
+  patches = [
+    ./nix-build-git.patch
+    ./3.19-compat-git.patch # Remove once PR-3084 is mainlined
   ];
 
-  enableParallelBuilding = true;
-
-  # Remove provided services as they are buggy
-  postInstall = ''
-    rm $out/etc/systemd/system/zfs-import-*.service
-
-    sed -i '/zfs-import-scan.service/d' $out/etc/systemd/system/*
-
-    for i in $out/etc/systemd/system/*; do
-      substituteInPlace $i --replace "zfs-import-cache.service" "zfs-import.target"
-    done
-  '';
-
-  meta = {
-    description = "ZFS Filesystem Linux Kernel module";
-    longDescription = ''
-      ZFS is a filesystem that combines a logical volume manager with a
-      Copy-On-Write filesystem with data integrity detection and repair,
-      snapshotting, cloning, block devices, deduplication, and more.
-      '';
-    homepage = http://zfsonlinux.org/;
-    license = stdenv.lib.licenses.cddl;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = with stdenv.lib.maintainers; [ wizeman ];
-  };
-}
+  spl = spl_git;
+})
diff --git a/pkgs/os-specific/linux/zfs/nix-build-git.patch b/pkgs/os-specific/linux/zfs/nix-build-git.patch
new file mode 100644
index 000000000000..ae8e82f703af
--- /dev/null
+++ b/pkgs/os-specific/linux/zfs/nix-build-git.patch
@@ -0,0 +1,133 @@
+diff --git a/Makefile.am b/Makefile.am
+index 49b417a..f4af44d 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -12,10 +12,10 @@ endif
+ if CONFIG_KERNEL
+ SUBDIRS += module
+ 
+-extradir = @prefix@/src/zfs-$(VERSION)
++extradir = @prefix@/libexec/zfs-$(VERSION)
+ extra_HEADERS = zfs.release.in zfs_config.h.in
+ 
+-kerneldir = @prefix@/src/zfs-$(VERSION)/$(LINUX_VERSION)
++kerneldir = @prefix@/zfs-$(VERSION)/$(LINUX_VERSION)
+ nodist_kernel_HEADERS = zfs.release zfs_config.h module/$(LINUX_SYMBOLS)
+ endif
+ 
+diff --git a/include/Makefile.am b/include/Makefile.am
+index a94cad5..a160fe2 100644
+--- a/include/Makefile.am
++++ b/include/Makefile.am
+@@ -29,6 +29,6 @@ libzfs_HEADERS = $(COMMON_H) $(USER_H)
+ endif
+ 
+ if CONFIG_KERNEL
+-kerneldir = @prefix@/src/zfs-$(VERSION)/include
++kerneldir = @prefix@/include
+ kernel_HEADERS = $(COMMON_H) $(KERNEL_H)
+ endif
+diff --git a/include/linux/Makefile.am b/include/linux/Makefile.am
+index d00b1c8..3242d2e 100644
+--- a/include/linux/Makefile.am
++++ b/include/linux/Makefile.am
+@@ -17,6 +17,6 @@ libzfs_HEADERS = $(COMMON_H) $(USER_H)
+ endif
+ 
+ if CONFIG_KERNEL
+-kerneldir = @prefix@/src/zfs-$(VERSION)/include/linux
++kerneldir = @prefix@/include/linux
+ kernel_HEADERS = $(COMMON_H) $(KERNEL_H)
+ endif
+diff --git a/include/sys/Makefile.am b/include/sys/Makefile.am
+index 7ddace0..8da3870 100644
+--- a/include/sys/Makefile.am
++++ b/include/sys/Makefile.am
+@@ -102,6 +102,6 @@ libzfs_HEADERS = $(COMMON_H) $(USER_H)
+ endif
+ 
+ if CONFIG_KERNEL
+-kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys
++kerneldir = @prefix@/include/sys
+ kernel_HEADERS = $(COMMON_H) $(KERNEL_H)
+ endif
+diff --git a/include/sys/fm/Makefile.am b/include/sys/fm/Makefile.am
+index 8bca5d8..a5eafcd 100644
+--- a/include/sys/fm/Makefile.am
++++ b/include/sys/fm/Makefile.am
+@@ -16,6 +16,6 @@ libzfs_HEADERS = $(COMMON_H) $(USER_H)
+ endif
+ 
+ if CONFIG_KERNEL
+-kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys/fm
++kerneldir = @prefix@/include/sys/fm
+ kernel_HEADERS = $(COMMON_H) $(KERNEL_H)
+ endif
+diff --git a/include/sys/fm/fs/Makefile.am b/include/sys/fm/fs/Makefile.am
+index fdc9eb5..807c47c 100644
+--- a/include/sys/fm/fs/Makefile.am
++++ b/include/sys/fm/fs/Makefile.am
+@@ -13,6 +13,6 @@ libzfs_HEADERS = $(COMMON_H) $(USER_H)
+ endif
+ 
+ if CONFIG_KERNEL
+-kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys/fm/fs
++kerneldir = @prefix@/include/sys/fm/fs
+ kernel_HEADERS = $(COMMON_H) $(KERNEL_H)
+ endif
+diff --git a/include/sys/fs/Makefile.am b/include/sys/fs/Makefile.am
+index 0859b9f..b0c6eec 100644
+--- a/include/sys/fs/Makefile.am
++++ b/include/sys/fs/Makefile.am
+@@ -13,6 +13,6 @@ libzfs_HEADERS = $(COMMON_H) $(USER_H)
+ endif
+ 
+ if CONFIG_KERNEL
+-kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys/fs
++kerneldir = @prefix@/include/sys/fs
+ kernel_HEADERS = $(COMMON_H) $(KERNEL_H)
+ endif
+diff --git a/module/Makefile.in b/module/Makefile.in
+index 686402b..9cbf598 100644
+--- a/module/Makefile.in
++++ b/module/Makefile.in
+@@ -18,9 +18,9 @@ modules:
+ 	@# installed devel headers, or they may be in the module
+ 	@# subdirectory when building against the spl source tree.
+ 	@if [ -f @SPL_OBJ@/@SPL_SYMBOLS@ ]; then \
+-		/bin/cp @SPL_OBJ@/@SPL_SYMBOLS@ .; \
++		cp @SPL_OBJ@/@SPL_SYMBOLS@ .; \
+ 	elif [ -f @SPL_OBJ@/module/@SPL_SYMBOLS@ ]; then \
+-		/bin/cp @SPL_OBJ@/module/@SPL_SYMBOLS@ .; \
++		cp @SPL_OBJ@/module/@SPL_SYMBOLS@ .; \
+ 	else \
+ 		echo -e "\n" \
+ 		"*** Missing spl symbols ensure you have built the spl:\n" \
+@@ -28,6 +28,8 @@ modules:
+ 		"*** - @SPL_OBJ@/module/@SPL_SYMBOLS@\n"; \
+ 		exit 1; \
+ 	fi
++	@# when copying a file out of the nix store, we need to make it writable again. 
++	chmod +w @SPL_SYMBOLS@
+ 	$(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ CONFIG_ZFS=m $@
+ 
+ clean:
+@@ -42,15 +44,15 @@ clean:
+ modules_install:
+ 	@# Install the kernel modules
+ 	$(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` $@ \
+-		INSTALL_MOD_PATH=$(DESTDIR)$(INSTALL_MOD_PATH) \
++		INSTALL_MOD_PATH=@prefix@/$(INSTALL_MOD_PATH) \
+ 		INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \
+ 		KERNELRELEASE=@LINUX_VERSION@
+ 	@# Remove extraneous build products when packaging
+-	kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
++	kmoddir=@prefix@/$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
+ 	if [ -n $$kmoddir ]; then \
+ 		find $$kmoddir -name 'modules.*' | xargs $(RM); \
+ 	fi
+-	sysmap=$(DESTDIR)$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \
++	sysmap=@prefix@/$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \
+ 	if [ -f $$sysmap ]; then \
+ 		depmod -ae -F $$sysmap @LINUX_VERSION@; \
+ 	fi
diff --git a/pkgs/os-specific/linux/zfs/remove-lock-checks.patch b/pkgs/os-specific/linux/zfs/remove-lock-checks.patch
deleted file mode 100644
index 1261b49ee1d4..000000000000
--- a/pkgs/os-specific/linux/zfs/remove-lock-checks.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c
-index 33f9e0e..2f55e56 100644
---- a/module/zfs/zfs_vnops.c
-+++ b/module/zfs/zfs_vnops.c
-@@ -474,15 +474,6 @@ zfs_read(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
- 	}
- 
- 	/*
--	 * Check for mandatory locks
--	 */
--	if (mandatory_lock(ip) &&
--	    !lock_may_read(ip, uio->uio_loffset, uio->uio_resid)) {
--		ZFS_EXIT(zsb);
--		return (SET_ERROR(EAGAIN));
--	}
--
--	/*
- 	 * If we're in FRSYNC mode, sync out this znode before reading it.
- 	 */
- 	if (ioflag & FRSYNC || zsb->z_os->os_sync == ZFS_SYNC_ALWAYS)
-@@ -651,15 +642,6 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
- 	}
- 
- 	/*
--	 * Check for mandatory locks before calling zfs_range_lock()
--	 * in order to prevent a deadlock with locks set via fcntl().
--	 */
--	if (mandatory_lock(ip) && !lock_may_write(ip, woff, n)) {
--		ZFS_EXIT(zsb);
--		return (SET_ERROR(EAGAIN));
--	}
--
--	/*
- 	 * Pre-fault the pages to ensure slow (eg NFS) pages
- 	 * don't hold up txg.
- 	 * Skip this if uio contains loaned arc_buf.
-diff --git a/module/zfs/zfs_znode.c b/module/zfs/zfs_znode.c
-index 90dbfd3..f02c021 100644
---- a/module/zfs/zfs_znode.c
-+++ b/module/zfs/zfs_znode.c
-@@ -1546,7 +1546,6 @@ zfs_trunc(znode_t *zp, uint64_t end)
- int
- zfs_freesp(znode_t *zp, uint64_t off, uint64_t len, int flag, boolean_t log)
- {
--	struct inode *ip = ZTOI(zp);
- 	dmu_tx_t *tx;
- 	zfs_sb_t *zsb = ZTOZSB(zp);
- 	zilog_t *zilog = zsb->z_log;
-@@ -1567,15 +1566,6 @@ zfs_freesp(znode_t *zp, uint64_t off, uint64_t len, int flag, boolean_t log)
- 		goto out;
- 	}
- 
--	/*
--	 * Check for any locks in the region to be freed.
--	 */
--	if (ip->i_flock && mandatory_lock(ip)) {
--		uint64_t length = (len ? len : zp->z_size - off);
--		if (!lock_may_write(ip, off, length))
--			return (SET_ERROR(EAGAIN));
--	}
--
- 	if (len == 0) {
- 		error = zfs_trunc(zp, off);
- 	} else {