about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Peebles <copumpkin@users.noreply.github.com>2016-11-16 12:11:15 -0500
committerGitHub <noreply@github.com>2016-11-16 12:11:15 -0500
commitf6a7296499cb397651f3ec8d7244330db88980d7 (patch)
treedf0b71dc84e78aa191791948d86fd3437e9a49a9
parentc4d2d56f22ea4ada899cd26141b774112b6bfdf7 (diff)
parentfc1f6f55ea6c7eb1f98027db532683755fb7d4b9 (diff)
downloadnixlib-f6a7296499cb397651f3ec8d7244330db88980d7.tar
nixlib-f6a7296499cb397651f3ec8d7244330db88980d7.tar.gz
nixlib-f6a7296499cb397651f3ec8d7244330db88980d7.tar.bz2
nixlib-f6a7296499cb397651f3ec8d7244330db88980d7.tar.lz
nixlib-f6a7296499cb397651f3ec8d7244330db88980d7.tar.xz
nixlib-f6a7296499cb397651f3ec8d7244330db88980d7.tar.zst
nixlib-f6a7296499cb397651f3ec8d7244330db88980d7.zip
Merge pull request #16540 from matthewbauer/xcbuild
xcbuild: add wrapper
-rw-r--r--pkgs/development/tools/xcbuild/default.nix11
-rw-r--r--pkgs/development/tools/xcbuild/platform.nix152
-rw-r--r--pkgs/development/tools/xcbuild/sdk.nix31
-rw-r--r--pkgs/development/tools/xcbuild/setup-hook.sh31
-rw-r--r--pkgs/development/tools/xcbuild/toolchain.nix109
-rw-r--r--pkgs/development/tools/xcbuild/wrapper.nix72
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/Librpcsvc/default.nix24
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/adv_cmds/xcode.nix47
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/basic_cmds/default.nix29
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/default.nix10
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/developer_cmds/default.nix26
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/network_cmds/default.nix43
-rw-r--r--pkgs/tools/misc/contacts/default.nix11
-rw-r--r--pkgs/top-level/all-packages.nix10
14 files changed, 594 insertions, 12 deletions
diff --git a/pkgs/development/tools/xcbuild/default.nix b/pkgs/development/tools/xcbuild/default.nix
index e313672aea3f..1393034ff205 100644
--- a/pkgs/development/tools/xcbuild/default.nix
+++ b/pkgs/development/tools/xcbuild/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, cmake, fetchFromGitHub, zlib, libxml2, libpng, CoreServices, CoreGraphics, ImageIO }:
+{ stdenv, cmake, fetchFromGitHub, zlib, libxml2, libpng, CoreServices, CoreGraphics, ImageIO, ninja }:
 
 let
   googletest = fetchFromGitHub {
@@ -16,13 +16,13 @@ let
   };
 in stdenv.mkDerivation rec {
   name    = "xcbuild-${stdenv.lib.substring 0 8 version}";
-  version = "49f8a5923f1381f87ac03ad4c1b138d1d2b74369";
+  version = "0ab861abcc11185a17d59608f96a015752a6fadc";
 
   src = fetchFromGitHub {
     owner  = "facebook";
     repo   = "xcbuild";
     rev    = version;
-    sha256 = "0l107xkh7dab2xc58dqyrrhpd1gp12cpzh0wrx0i9jbh0idbwnk0";
+    sha256 = "12h0rn8v0js2vph2pwp5wvcrfkj12nz365i5qxw9miyfn4msnz26";
   };
 
   prePatch = ''
@@ -39,5 +39,6 @@ in stdenv.mkDerivation rec {
     rmdir $out/usr
   '';
 
-  buildInputs = [ cmake zlib libxml2 libpng CoreServices CoreGraphics ImageIO ];
-}
\ No newline at end of file
+  buildInputs = [ cmake zlib libxml2 libpng ninja ]
+    ++ stdenv.lib.optionals stdenv.isDarwin [ CoreServices CoreGraphics ImageIO ];
+}
diff --git a/pkgs/development/tools/xcbuild/platform.nix b/pkgs/development/tools/xcbuild/platform.nix
new file mode 100644
index 000000000000..0b03d4120e85
--- /dev/null
+++ b/pkgs/development/tools/xcbuild/platform.nix
@@ -0,0 +1,152 @@
+{ stdenv, sdk, writeText, platformName, xcbuild }:
+
+let
+
+  Info = {
+    CFBundleIdentifier = platformName;
+    Type = "Platform";
+    Name = "macosx";
+  };
+
+  Version = {
+    ProjectName = "OSXPlatformSupport";
+  };
+
+  # These files are all based off of Xcode spec fies found in
+  # /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Speciications/.
+
+  # Based off of the MacOSX Architectures.xcpsec file. All i386 stuff
+  # is removed because NixPkgs only supports darwin-x86_64.
+  Architectures = [
+    {
+		  Identifier = "Standard";
+	    Type = "Architecture";
+		  Name = "Standard Architectures (64-bit Intel)";
+		  RealArchitectures = [ "x86_64" ];
+      ArchitectureSetting = "ARCHS_STANDARD";
+    }
+    {
+      Identifier = "Universal";
+      Type = "Architecture";
+      Name = "Universal (64-bit Intel)";
+      RealArchitectures = [ "x86_64" ];
+      ArchitectureSetting = "ARCHS_STANDARD_32_64_BIT";
+    }
+    {
+      Identifier = "Native";
+      Type = "Architecture";
+      Name = "Native Architecture of Build Machine";
+      ArchitectureSetting = "NATIVE_ARCH_ACTUAL";
+    }
+    {
+      Identifier = "Standard64bit";
+      Type = "Architecture";
+      Name = "64-bit Intel";
+      RealArchitectures = [ "x86_64" ];
+      ArchitectureSetting = "ARCHS_STANDARD_64_BIT";
+    }
+    {
+      Identifier = "x86_64";
+      Type = "Architecture";
+      Name = "Intel 64-bit";
+    }
+    {
+      Identifier = "Standard_Including_64_bit";
+      Type = "Architecture";
+      Name = "Standard Architectures (including 64-bit)";
+      RealArchitectures = [ "x86_64" ];
+      ArchitectureSetting = "ARCHS_STANDARD_INCLUDING_64_BIT";
+    }
+  ];
+
+  # Based off of the MacOSX Package Types.xcpsec file. Only keep the
+  # bare minimum needed.
+  PackageTypes = [
+    {
+      Identifier = "com.apple.package-type.mach-o-executable";
+      Type = "PackageType";
+      Name = "Mach-O Executable";
+      DefaultBuildSettings = {
+        EXECUTABLE_NAME = "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)";
+        EXECUTABLE_PATH = "$(EXECUTABLE_NAME)";
+      };
+      ProductReference = {
+        FileType = "compiled.mach-o.executable";
+        Name = "$(EXECUTABLE_NAME)";
+      };
+    }
+    {
+      Identifier = "com.apple.package-type.mach-o-objfile";
+      Type = "PackageType";
+      Name = "Mach-O Object File";
+      DefaultBuildSettings = {
+        EXECUTABLE_NAME = "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)";
+        EXECUTABLE_PATH = "$(EXECUTABLE_NAME)";
+      };
+      ProductReference = {
+        FileType = "compiled.mach-o.objfile";
+        Name = "$(EXECUTABLE_NAME)";
+      };
+    }
+    {
+      Identifier = "com.apple.package-type.mach-o-dylib";
+      Type = "PackageType";
+      Name = "Mach-O Dynamic Library";
+      DefaultBuildSettings = {
+        EXECUTABLE_NAME = "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)";
+        EXECUTABLE_PATH = "$(EXECUTABLE_NAME)";
+      };
+      ProductReference = {
+        FileType = "compiled.mach-o.dylib";
+        Name = "$(EXECUTABLE_NAME)";
+      };
+    }
+  ];
+
+  # Based off of the MacOSX Product Types.xcpsec file. All
+  # bundles/wrapper are removed, because we prefer dynamic products in
+  # NixPkgs.
+  ProductTypes = [
+    {
+      Identifier = "com.apple.product-type.tool";
+      Type = "ProductType";
+      Name = "Command-line Tool";
+      PackageTypes = [ "com.apple.package-type.mach-o-executable" ];
+    }
+    {
+      Identifier = "com.apple.product-type.objfile";
+      Type = "ProductType";
+      Name = "Object File";
+      PackageTypes = [ "com.apple.package-type.mach-o-objfile" ];
+    }
+    {
+      Identifier = "com.apple.product-type.library.dynamic";
+      Type = "ProductType";
+      Name = "Dynamic Library";
+      PackageTypes = [ "com.apple.package-type.mach-o-dylib" ];
+    }
+  ];
+
+in
+
+stdenv.mkDerivation {
+  name = "nixpkgs.platform";
+  buildInputs = [ xcbuild ];
+  buildCommand = ''
+    mkdir -p $out/
+    cd $out/
+
+    plutil -convert xml1 -o Info.plist ${writeText "Info.plist" (builtins.toJSON Info)}
+    plutil -convert xml1 -o version.plist ${writeText "version.plist" (builtins.toJSON Version)}
+
+    mkdir -p $out/Developer/Library/Xcode/Specifications/
+    cd $out/Developer/Library/Xcode/Specifications/
+    plutil -convert xml1 -o Architectures.xcspec ${writeText "Architectures.xcspec" (builtins.toJSON Architectures)}
+    plutil -convert xml1 -o PackageTypes.xcspec ${writeText "PackageTypes.xcspec" (builtins.toJSON PackageTypes)}
+    plutil -convert xml1 -o ProductTypes.xcspec ${writeText "ProductTypes.xcspec" (builtins.toJSON ProductTypes)}
+
+    mkdir -p $out/Developer/SDKs/
+    cd $out/Developer/SDKs/
+    ln -s ${sdk}
+  '';
+}
diff --git a/pkgs/development/tools/xcbuild/sdk.nix b/pkgs/development/tools/xcbuild/sdk.nix
new file mode 100644
index 000000000000..7d587249bf8e
--- /dev/null
+++ b/pkgs/development/tools/xcbuild/sdk.nix
@@ -0,0 +1,31 @@
+{ stdenv, writeText, toolchainName, sdkName, xcbuild }:
+
+let
+
+  SDKSettings = {
+    CanonicalName = sdkName;
+    DisplayName = sdkName;
+    Toolchains = [ toolchainName ];
+    Version = "10.10";
+    MaximumDeploymentTarget = "10.10";
+    isBaseSDK = "YES";
+  };
+
+  SystemVersion = {
+    ProductName = "Mac OS X";
+    ProductVersion = "10.10";
+  };
+
+in
+
+stdenv.mkDerivation {
+  name = "nix.nixpkgs.sdk";
+  buildInputs = [ xcbuild ];
+  buildCommand = ''
+    mkdir -p $out/
+    plutil -convert xml1 -o $out/SDKSettings.plist ${writeText "SDKSettings.json" (builtins.toJSON SDKSettings)}
+
+    mkdir -p $out/System/Library/CoreServices/
+    plutil -convert xml1 -o $out/System/Library/CoreServices/SystemVersion.plist ${writeText "SystemVersion.plist" (builtins.toJSON SystemVersion)}
+  '';
+}
diff --git a/pkgs/development/tools/xcbuild/setup-hook.sh b/pkgs/development/tools/xcbuild/setup-hook.sh
new file mode 100644
index 000000000000..c3b26a6ac796
--- /dev/null
+++ b/pkgs/development/tools/xcbuild/setup-hook.sh
@@ -0,0 +1,31 @@
+xcbuildBuildPhase() {
+    export DSTROOT=$out
+
+    runHook preBuild
+
+    echo "running xcodebuild"
+
+    xcodebuild OTHER_CFLAGS="$NIX_CFLAGS_COMPILE" OTHER_CPLUSPLUSFLAGS="$NIX_CFLAGS_COMPILE" OTHER_LDFLAGS="$NIX_LDFLAGS" build
+
+    runHook postBuild
+}
+
+xcbuildInstallPhase () {
+    runHook preInstall
+
+    # not implemented
+    # xcodebuild install
+
+    runHook postInstall
+}
+
+if [ -z "$dontUseXcbuild" ]; then
+    buildPhase=xcbuildBuildPhase
+    if [ -z "$installPhase" ]; then
+        installPhase=xcbuildInstallPhase
+    fi
+fi
+
+# if [ -d "*.xcodeproj" ]; then
+#     buildPhase=xcbuildPhase
+# fi
diff --git a/pkgs/development/tools/xcbuild/toolchain.nix b/pkgs/development/tools/xcbuild/toolchain.nix
new file mode 100644
index 000000000000..386f67a9d631
--- /dev/null
+++ b/pkgs/development/tools/xcbuild/toolchain.nix
@@ -0,0 +1,109 @@
+{stdenv, writeText, toolchainName, xcbuild
+, llvm, cctools, gcc, bootstrap_cmds, binutils
+, yacc, flex, m4, unifdef, gperf, indent, ctags, makeWrapper}:
+
+let
+
+  ToolchainInfo = {
+    Identifier = toolchainName;
+  };
+
+in
+
+stdenv.mkDerivation {
+  name = "nixpkgs.xctoolchain";
+  buildInputs = [ xcbuild makeWrapper ];
+
+  propagatedBuildInputs = [ llvm gcc yacc flex m4 unifdef gperf indent ]
+    ++ stdenv.lib.optionals stdenv.isDarwin [ cctools bootstrap_cmds binutils ];
+  ## cctools should build on Linux but it doesn't currentl
+
+  buildCommand = ''
+    mkdir -p $out
+    plutil -convert xml1 -o $out/ToolchainInfo.plist ${writeText "ToolchainInfo.plist" (builtins.toJSON ToolchainInfo)}
+
+    mkdir -p $out/usr/include
+    mkdir -p $out/usr/lib
+    mkdir -p $out/usr/libexec
+    mkdir -p $out/usr/share
+
+    mkdir -p $out/usr/bin
+    cd $out/usr/bin
+    ln -s ${stdenv.cc}/bin/cpp
+    ln -s ${stdenv.cc}/bin/c++
+    ln -s ${stdenv.cc}/bin/cc
+    ln -s c++ clang++
+    ln -s cc clang
+
+    ln -s ${llvm}/bin/llvm-cov
+    ln -s ${llvm}/bin/llvm-dsymutil
+    ln -s ${llvm}/bin/llvm-dwarfdump
+    ln -s ${llvm}/bin/llvm-nm
+    ln -s ${llvm}/bin/llvm-objdump
+    ln -s ${llvm}/bin/llvm-otool
+    ln -s ${llvm}/bin/llvm-profdata
+    ln -s ${llvm}/bin/llvm-size
+
+    ln -s ${yacc}/bin/yacc
+    ln -s ${yacc}/bin/bison
+    ln -s ${flex}/bin/flex
+    ln -s ${flex}/bin/flex++
+
+    ln -s flex lex
+
+    ln -s ${m4}/bin/m4
+    ln -s m4 gm4
+
+    ln -s ${unifdef}/bin/unifdef
+    ln -s ${unifdef}/bin/unifdefall
+
+    ln -s ${gperf}/bin/gperf
+    ln -s ${gcc}/bin/gcov
+    ln -s ${gcc}/bin/mkdep
+    ln -s ${indent}/bin/indent
+    ln -s ${ctags}/bin/ctags
+  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+    ln -s ${bootstrap_cmds}/bin/mig
+    ln -s ${binutils}/bin/lipo
+
+    ln -s ${cctools}/bin/ar
+    ln -s ${cctools}/bin/as
+    ln -s ${cctools}/bin/nm
+    ln -s ${cctools}/bin/nmedit
+    ln -s ${cctools}/bin/ld
+    ln -s ${cctools}/bin/libtool
+    ln -s ${cctools}/bin/strings
+    ln -s ${cctools}/bin/strip
+    ln -s ${cctools}/bin/install_name_tool
+    ln -s ${cctools}/bin/bitcode_strip
+    ln -s ${cctools}/bin/codesign_allocate
+    ln -s ${cctools}/bin/dsymutil
+    ln -s ${cctools}/bin/dyldinfo
+    ln -s ${cctools}/bin/otool
+    ln -s ${cctools}/bin/unwinddump
+    ln -s ${cctools}/bin/size
+    ln -s ${cctools}/bin/segedit
+    ln -s ${cctools}/bin/pagestuff
+    ln -s ${cctools}/bin/ranlib
+    ln -s ${cctools}/bin/redo_prebinding
+  '';
+}
+
+# other commands in /bin/
+#   asa
+#   cmpdylib (in cctools)
+#   ctf_insert (in cctools)
+#   dwarfdump
+#   lorder
+#   rebase
+#   rpcgen (in developer_cmds)
+#   what
+
+
+# swift: see #11463
+#   swift
+#   swift-compress
+#   swift-demangle
+#   swift-stdlib-tool
+#   swift-update
+#   swiftc
diff --git a/pkgs/development/tools/xcbuild/wrapper.nix b/pkgs/development/tools/xcbuild/wrapper.nix
new file mode 100644
index 000000000000..fc03c273fc58
--- /dev/null
+++ b/pkgs/development/tools/xcbuild/wrapper.nix
@@ -0,0 +1,72 @@
+{ stdenv, callPackage, makeWrapper, writeText, CoreServices, ImageIO, CoreGraphics
+, cctools, bootstrap_cmds, binutils}:
+
+let
+
+  toolchainName = "com.apple.dt.toolchain.XcodeDefault";
+  platformName = "com.apple.platform.macosx";
+  sdkName = "macosx10.10";
+
+  xcbuild = callPackage ./default.nix {
+    inherit CoreServices ImageIO CoreGraphics;
+  };
+
+  toolchain = callPackage ./toolchain.nix {
+    inherit cctools bootstrap_cmds toolchainName xcbuild binutils stdenv;
+  };
+
+  sdk = callPackage ./sdk.nix {
+    inherit toolchainName sdkName xcbuild;
+  };
+
+  platform = callPackage ./platform.nix {
+    inherit sdk platformName xcbuild;
+  };
+
+  xcconfig = writeText "nix.xcconfig" ''
+    SDKROOT=${sdkName}
+  '';
+
+in
+
+stdenv.mkDerivation {
+  name = "xcbuild-wrapper";
+
+  buildInputs = [ xcbuild makeWrapper ];
+
+  setupHook = ./setup-hook.sh;
+
+  phases = [ "installPhase" "fixupPhase" ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cd $out/bin/
+
+    for file in ${xcbuild}/bin/*; do
+      ln -s $file
+    done
+
+    mkdir -p $out/Library/Xcode/
+    ln -s ${xcbuild}/Library/Xcode/Specifications $out/Library/Xcode/Specifications
+
+    mkdir -p $out/Platforms/
+    ln -s ${platform} $out/Platforms/
+
+    mkdir -p $out/Toolchains/
+    ln -s ${toolchain} $out/Toolchains/
+
+    wrapProgram $out/bin/xcodebuild \
+      --add-flags "-xcconfig ${xcconfig}" \
+      --add-flags "DERIVED_DATA_DIR=." \
+      --set DEVELOPER_DIR "$out"
+    wrapProgram $out/bin/xcrun \
+      --add-flags "-sdk ${sdkName}" \
+      --set DEVELOPER_DIR "$out"
+  '';
+
+  passthru = {
+    raw = xcbuild;
+  };
+
+  preferLocalBuild = true;
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/Librpcsvc/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Librpcsvc/default.nix
new file mode 100644
index 000000000000..512ec6253c78
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/Librpcsvc/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, appleDerivation, developer_cmds }:
+
+appleDerivation rec {
+  phases = [ "unpackPhase" "installPhase" ];
+
+  buildInputs = [ developer_cmds ];
+
+  installPhase = ''
+    export DSTROOT=$out
+    export SRCROOT=$PWD
+    export OBJROOT=$PWD
+
+    . ./xcodescripts/install_rpcsvc.sh
+
+    mv $out/usr/* $out
+    rmdir $out/usr/
+  '';
+
+  meta = with stdenv.lib; {
+    maintainers = with maintainers; [ matthewbauer ];
+    platforms   = platforms.darwin;
+    license     = licenses.apsl20;
+  };
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/xcode.nix b/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/xcode.nix
new file mode 100644
index 000000000000..254b4a231c22
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/xcode.nix
@@ -0,0 +1,47 @@
+{ stdenv, appleDerivation, fetchurl, xcbuild, libcxx }:
+
+appleDerivation {
+
+  # pkill requires special private headers that are unavailable in
+  # NixPkgs. These ones are needed:
+  #  - xpc/xpxc.h
+  #  - os/base_private.h
+  #  - _simple.h
+  # We disable it here for now. TODO: build pkill inside adv_cmds
+
+  # We also disable locale here because of some issues with a missing
+  # "lstdc++".
+  patchPhase = ''
+    substituteInPlace adv_cmds.xcodeproj/project.pbxproj \
+      --replace "FD201DC214369B4200906237 /* pkill.c in Sources */," "" \
+      --replace "FDF278D60FC6204E00D7A3C6 /* locale.cc in Sources */," ""
+  '';
+
+  # temporary install phase until xcodebuild has "install" support
+  installPhase = ''
+    mkdir -p $out/bin/
+    install adv_cmds-*/Build/Products/Release/* $out/bin/
+
+    for n in 1 8; do
+      mkdir -p $out/share/man/man$n
+      install */*.$n $out/share/man/man$n
+    done
+
+    mkdir -p $out/System/Library/LaunchDaemons
+    install fingerd/finger.plist $out/System/Library/LaunchDaemons
+
+    # from variant_links.sh
+    # ln -s $out/bin/pkill $out/bin/pgrep
+    # ln -s $out/share/man/man1/pkill.1 $out/share/man/man1/pgrep.1
+  '';
+
+  buildInputs = [ xcbuild libcxx ];
+
+  # temporary fix for iostream issue
+  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1";
+
+  meta = {
+    platforms = stdenv.lib.platforms.darwin;
+    maintainers = with stdenv.lib.maintainers; [ matthewbauer ];
+  };
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/basic_cmds/default.nix b/pkgs/os-specific/darwin/apple-source-releases/basic_cmds/default.nix
new file mode 100644
index 000000000000..9e8b78e57d6c
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/basic_cmds/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, appleDerivation, fetchurl, xcbuild }:
+
+appleDerivation rec {
+  buildInputs = [ xcbuild ];
+
+  # These PBXcp calls should be patched in xcbuild to allow them to
+  # automatically be prefixed.
+  patchPhase = ''
+    substituteInPlace basic_cmds.xcodeproj/project.pbxproj \
+      --replace "dstPath = /usr/share/man/man1;" "dstPath = $out/share/man/man1;" \
+      --replace "dstPath = /usr/share/man/man5;" "dstPath = $out/share/man/man5;"
+  '';
+
+  # temporary install phase until xcodebuild has "install" support
+  installPhase = ''
+    mkdir -p $out/bin/
+    install basic_cmds-*/Build/Products/Release/* $out/bin/
+
+    for n in 1; do
+      mkdir -p $out/share/man/man$n
+      install */*.$n $out/share/man/man$n
+    done
+  '';
+
+  meta = {
+    platforms = stdenv.lib.platforms.darwin;
+    maintainers = with stdenv.lib.maintainers; [ matthewbauer ];
+  };
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/default.nix b/pkgs/os-specific/darwin/apple-source-releases/default.nix
index d86754ecc74c..c63d7465a13d 100644
--- a/pkgs/os-specific/darwin/apple-source-releases/default.nix
+++ b/pkgs/os-specific/darwin/apple-source-releases/default.nix
@@ -34,6 +34,11 @@ let
 
       libutil       = "43";
       libunwind     = "35.3";
+      Librpcsvc     = "26";
+      developer_cmds= "62";
+      network_cmds  = "481.20.1";
+      basic_cmds    = "55";
+      adv_cmds      = "163";
     };
     "osx-10.11.5" = {
       Libc          = "1082.50.1"; # 10.11.6 still unreleased :/
@@ -221,6 +226,11 @@ let
     removefile      = applePackage "removefile"        "osx-10.11.6"     "1b6r74ry3k01kypvlaclf33fha15pcm0kzx9zrymlg66wg0s0i3r" {};
     Security        = applePackage "Security"          "osx-10.9.5"      "1nv0dczf67dhk17hscx52izgdcyacgyy12ag0jh6nl5hmfzsn8yy" {};
     xnu             = applePackage "xnu"               "osx-10.11.6"     "0yhziq4dqqcbjpf6vyqn8xhwva2zb525gndkx8cp8alzwp76jnr9" {};
+    Librpcsvc       = applePackage "Librpcsvc"         "osx-10.11.6"     "1zwfwcl9irxl1dlnf2b4v30vdybp0p0r6n6g1pd14zbdci1jcg2k" {};
+    adv_cmds        = applePackage "adv_cmds/xcode.nix" "osx-10.11.6"    "12gbv35i09aij9g90p6b3x2f3ramw43qcb2gjrg8lzkzmwvcyw9q" {};
+    basic_cmds      = applePackage "basic_cmds"        "osx-10.11.6"     "0hvab4b1v5q2x134hdkal0rmz5gsdqyki1vb0dbw4py1bqf0yaw9" {};
+    developer_cmds  = applePackage "developer_cmds"    "osx-10.11.6"     "1r9c2b6dcl22diqf90x58psvz797d3lxh4r2wppr7lldgbgn24di" {};
+    network_cmds    = applePackage "network_cmds"      "osx-10.11.6"     "0lhi9wz84qr1r2ab3fb4nvmdg9gxn817n5ldg7zw9gnf3wwn42kw" {};
 
     libsecurity_apple_csp      = libsecPackage "libsecurity_apple_csp"      "osx-10.7.5" "1ngyn1ik27n4x981px3kfd1z1n8zx7r5w812b6qfjpy5nw4h746w" {};
     libsecurity_apple_cspdl    = libsecPackage "libsecurity_apple_cspdl"    "osx-10.7.5" "1svqa5fhw7p7njzf8bzg7zgc5776aqjhdbnlhpwmr5hmz5i0x8r7" {};
diff --git a/pkgs/os-specific/darwin/apple-source-releases/developer_cmds/default.nix b/pkgs/os-specific/darwin/apple-source-releases/developer_cmds/default.nix
new file mode 100644
index 000000000000..67fbf83496ed
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/developer_cmds/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchurl, appleDerivation, xcbuild }:
+
+appleDerivation rec {
+  buildInputs = [ xcbuild ];
+
+  patchPhase = ''
+    substituteInPlace rpcgen/rpc_main.c \
+      --replace "/usr/bin/cpp" "${stdenv.cc}/bin/cpp"
+  '';
+
+  # temporary install phase until xcodebuild has "install" support
+  installPhase = ''
+    mkdir -p $out/bin/
+    install developer_cmds-*/Build/Products/Release/* $out/bin/
+
+    for n in 1; do
+      mkdir -p $out/share/man/man$n
+      install */*.$n $out/share/man/man$n
+    done
+  '';
+
+  meta = {
+    platforms = stdenv.lib.platforms.darwin;
+    maintainers = with stdenv.lib.maintainers; [ matthewbauer ];
+  };
+}
diff --git a/pkgs/os-specific/darwin/apple-source-releases/network_cmds/default.nix b/pkgs/os-specific/darwin/apple-source-releases/network_cmds/default.nix
new file mode 100644
index 000000000000..357a87689a03
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-source-releases/network_cmds/default.nix
@@ -0,0 +1,43 @@
+{ stdenv, appleDerivation, xcbuild, openssl, Librpcsvc, xnu, libpcap, developer_cmds }:
+
+appleDerivation rec {
+  buildInputs = [ xcbuild openssl xnu Librpcsvc libpcap developer_cmds ];
+
+  NIX_CFLAGS_COMPILE = " -I./unbound -I${xnu}/Library/Frameworks/System.framework/Headers/";
+
+  # "spray" requires some files that aren't compiling correctly in xcbuild.
+  # "rtadvd" seems to fail with some missing constants.
+  # We disable spray and rtadvd here for now.
+  patchPhase = ''
+    substituteInPlace network_cmds.xcodeproj/project.pbxproj \
+      --replace "7294F0EA0EE8BAC80052EC88 /* PBXTargetDependency */," "" \
+      --replace "7216D34D0EE89FEC00AE70E4 /* PBXTargetDependency */," ""
+  '';
+
+  # temporary install phase until xcodebuild has "install" support
+  installPhase = ''
+    mkdir -p $out/bin/
+    install network_cmds-*/Build/Products/Release/* $out/bin/
+
+    for n in 1 5; do
+      mkdir -p $out/share/man/man$n
+      install */*.$n $out/share/man/man$n
+    done
+
+    # TODO: patch files to load from $out/ instead of /usr/
+
+    # mkdir -p $out/etc/
+    # install rtadvd.tproj/rtadvd.conf ip6addrctl.tproj/ip6addrctl.conf $out/etc/
+
+    # mkdir -p $out/local/OpenSourceVersions/
+    # install network_cmds.plist $out/local/OpenSourceVersions/
+
+    # mkdir -p $out/System/Library/LaunchDaemons
+    # install kdumpd.tproj/com.apple.kdumpd.plist $out/System/Library/LaunchDaemons
+ '';
+
+  meta = {
+    platforms = stdenv.lib.platforms.darwin;
+    maintainers = with stdenv.lib.maintainers; [ matthewbauer ];
+  };
+}
diff --git a/pkgs/tools/misc/contacts/default.nix b/pkgs/tools/misc/contacts/default.nix
index 2bfe0eb42665..d146cd93343e 100644
--- a/pkgs/tools/misc/contacts/default.nix
+++ b/pkgs/tools/misc/contacts/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl }:
+{ stdenv, fetchurl, xcbuild, Foundation, AddressBook }:
 
 stdenv.mkDerivation rec {
   version = "1.1a-3";
@@ -9,15 +9,16 @@ stdenv.mkDerivation rec {
     sha256 = "0wdqc1ndgrdhqapvvgx5xihc750szv08lp91x4l6n0gh59cpxpg3";
   };
 
-  preBuild = ''
-    substituteInPlace Makefile --replace "xcodebuild" "/usr/bin/xcodebuild"
-  '';
+  buildInputs = [ xcbuild Foundation AddressBook ];
 
   installPhase = ''
     mkdir -p $out/bin
-    cp ./build/Deployment/contacts $out/bin
+    cp ./contacts-*/Build/Products/Default/contacts $out/bin
   '';
 
+  ## FIXME: the framework setup hook isn't adding these correctly
+  NIX_LDFLAGS = " -F${Foundation}/Library/Frameworks/ -F${AddressBook}/Library/Frameworks/";
+
   meta = with stdenv.lib; {
     description = "Access contacts from the Mac address book from command-line";
     homepage    = http://www.gnufoo.org/contacts/contacts.html;
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 3d74d74e18cb..5c498628cb7b 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -764,7 +764,9 @@ in
 
   cpulimit = callPackage ../tools/misc/cpulimit { };
 
-  contacts = callPackage ../tools/misc/contacts { };
+  contacts = callPackage ../tools/misc/contacts {
+    inherit (darwin.apple_sdk.frameworks) Foundation AddressBook;
+  };
 
   coturn = callPackage ../servers/coturn { };
 
@@ -6491,7 +6493,11 @@ in
 
   xc3sprog = callPackage ../development/tools/misc/xc3sprog { };
 
-  xcbuild  = callPackage ../development/tools/xcbuild { inherit (darwin.apple_sdk.frameworks) CoreServices CoreGraphics ImageIO; };
+  xcbuild  = callPackage ../development/tools/xcbuild/wrapper.nix {
+    inherit (darwin.apple_sdk.frameworks) CoreServices CoreGraphics ImageIO;
+    inherit (darwin) cctools bootstrap_cmds binutils;
+    stdenv = clangStdenv;
+  };
 
   xmlindent = callPackage ../development/web/xmlindent {};