about summary refs log tree commit diff
path: root/pkgs/os-specific/darwin/xcode/default.nix
blob: 5c8e7a3ef6c1b323a12d24bdd66c18ce79ce92a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{ stdenv, requireFile, xpwn }:

stdenv.mkDerivation rec {
  name = "xcode-${version}";
  version = "5.0.2";

  src = requireFile {
    name = "xcode_${version}.dmg";
    url = meta.homepage;
    sha256 = "0mrligqkfqwx8cy883pxm4w5w7a17nfh227zdspfll23r9agf32k";
  };

  phases = [ "unpackPhase" "installPhase" "fixupPhase" ];
  outputs = [ "out" "toolchain" ];

  unpackCmd = let
    basePath = "Xcode.app/Contents/Developer/Platforms/MacOSX.platform";
    sdkPath = "${basePath}/Developer/SDKs";
  in ''
    ${xpwn}/bin/dmg extract "$curSrc" main.hfs > /dev/null
    ${xpwn}/bin/hfsplus main.hfs extractall "${sdkPath}" > /dev/null
  '';

  setSourceRoot = "sourceRoot=MacOSX10.9.sdk";

  installPhase = ''
    ensureDir "$out/share/sysroot"
    cp -a * "$out/share/sysroot/"
    ln -s "$out/share/sysroot/usr/lib" "$out/lib"
    ln -s "$out/share/sysroot/usr/include" "$out/include"

    ensureDir "$toolchain"
    pushd "$toolchain"
    ${xpwn}/bin/hfsplus "$(dirs +1)/../main.hfs" extractall \
      Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr \
      > /dev/null
    popd
  '';

  meta = {
    homepage = "https://developer.apple.com/downloads/";
    description = "Apple's XCode SDK";
    license = stdenv.lib.licenses.unfree;
  };
}