summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorJohn Ericson <Ericson2314@yahoo.com>2018-05-23 17:14:48 -0400
committerGitHub <noreply@github.com>2018-05-23 17:14:48 -0400
commite351265e85825c8970d4cc4e741e58eaea285419 (patch)
tree68d2af96fcc1e4e2533c298bf184be00f8eee829 /pkgs
parent457d3651ca53c0ac8dddbf91681f9a13ac3741c4 (diff)
parent3ab9caa3faf7655fe1c4a861799de4da21d20de5 (diff)
downloadnixlib-e351265e85825c8970d4cc4e741e58eaea285419.tar
nixlib-e351265e85825c8970d4cc4e741e58eaea285419.tar.gz
nixlib-e351265e85825c8970d4cc4e741e58eaea285419.tar.bz2
nixlib-e351265e85825c8970d4cc4e741e58eaea285419.tar.lz
nixlib-e351265e85825c8970d4cc4e741e58eaea285419.tar.xz
nixlib-e351265e85825c8970d4cc4e741e58eaea285419.tar.zst
nixlib-e351265e85825c8970d4cc4e741e58eaea285419.zip
Merge pull request #40897 from alexfmpe/purify-xcode
Use requireFile for impure XCode dependency
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/os-specific/darwin/ios-sdk-pkgs/default.nix4
-rw-r--r--pkgs/os-specific/darwin/xcode/default.nix98
-rw-r--r--pkgs/top-level/darwin-packages.nix3
3 files changed, 51 insertions, 54 deletions
diff --git a/pkgs/os-specific/darwin/ios-sdk-pkgs/default.nix b/pkgs/os-specific/darwin/ios-sdk-pkgs/default.nix
index f336b14ee37b..ebca738431c3 100644
--- a/pkgs/os-specific/darwin/ios-sdk-pkgs/default.nix
+++ b/pkgs/os-specific/darwin/ios-sdk-pkgs/default.nix
@@ -6,6 +6,7 @@
 , wrapBintoolsWith
 , wrapCCWith
 , buildIosSdk, targetIosSdkPkgs
+, xcode
 }:
 
 let
@@ -21,11 +22,10 @@ iosPlatformArch = { parsed, ... }: {
 in
 
 rec {
-  # TODO(kmicklas): Make a pure version of this for each supported SDK version.
   sdk = rec {
     name = "ios-sdk";
     type = "derivation";
-    outPath = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhone${sdkType}.platform/Developer/SDKs/iPhone${sdkType}${version}.sdk";
+    outPath = xcode + "/Contents/Developer/Platforms/iPhone${sdkType}.platform/Developer/SDKs/iPhone${sdkType}${version}.sdk";
 
     sdkType = if targetPlatform.isiPhoneSimulator then "Simulator" else "OS";
     version = targetPlatform.sdkVer;
diff --git a/pkgs/os-specific/darwin/xcode/default.nix b/pkgs/os-specific/darwin/xcode/default.nix
index d3a9ec012ebf..bed4cd6490d1 100644
--- a/pkgs/os-specific/darwin/xcode/default.nix
+++ b/pkgs/os-specific/darwin/xcode/default.nix
@@ -1,52 +1,48 @@
-{ stdenv, requireFile, xpwn }:
-
-with stdenv.lib;
-
-let
-  osxVersion = "10.9";
-in stdenv.mkDerivation rec {
-  name = "xcode-${version}";
-  version = "5.1";
-
-  src = requireFile {
-    name = "xcode_${version}.dmg";
-    url = meta.homepage;
-    sha256 = "70bb550cc14eca80b9825f4ae9bfbf7f076bb75777311be428bc30a7eb7a6f7e";
-  };
-
-  phases = [ "unpackPhase" "patchPhase" "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=MacOSX${osxVersion}.sdk";
-
-  patches = optional (osxVersion == "10.9") ./gcc-fix-enum-attributes.patch;
-
-  installPhase = ''
-    mkdir -p "$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"
-
-    mkdir -p "$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;
-  };
+{ stdenv, requireFile }:
+
+let requireXcode = version: sha256:
+  let
+    xip = "Xcode_" + version +  ".xip";
+    # TODO(alexfmpe): Find out how to validate the .xip signature in Linux
+    unxip = if stdenv.isDarwin
+            then ''
+              open -W ${xip}
+              rm -rf ${xip}
+            ''
+            else ''
+              xar -xf ${xip}
+              rm -rf ${xip}
+              pbzx -n Content | cpio -i
+              rm Content Metadata
+            '';
+    app = requireFile rec {
+      name     = "Xcode.app";
+      url      = "https://download.developer.apple.com/Developer_Tools/Xcode_" + version + "/" + xip;
+      hashMode = "recursive";
+      inherit sha256;
+      message  = ''
+        Unfortunately, we cannot download ${name} automatically.
+        Please go to ${url}
+        to download it yourself, and add it to the Nix store by running the following commands."
+        Note: download (~ 5GB), extraction and storing of Xcode will take a while
+
+        ${unxip}
+        nix-store --add-fixed --recursive sha256 Xcode.app
+        rm -rf Xcode.app
+      '';
+    };
+    meta = with stdenv.lib; {
+      homepage = https://developer.apple.com/downloads/;
+      description = "Apple's XCode SDK";
+      license = licenses.unfree;
+      platforms = platforms.darwin ++ platforms.linux;
+    };
+
+  in app.overrideAttrs ( oldAttrs: oldAttrs // { inherit meta; });
+
+in {
+  xcode_8_1 = requireXcode "8.1" "18xjvfipwzia66gm3r9p770xdd4r375vak7chw5vgqnv9yyjiq2n";
+  xcode_8_2 = requireXcode "8.2" "13nd1zsfqcp9hwp15hndr0rsbb8rgprrz7zr2ablj4697qca06m2";
+  xcode_9_1 = requireXcode "9.1" "0ab1403wy84ys3yn26fj78cazhpnslmh3nzzp1wxib3mr1afjvic";
+  xcode_9_2 = requireXcode "9.2" "1bgfgdp266cbbqf2axcflz92frzvhi0qw0jdkcw6r85kdpc8dj4c";
 }
diff --git a/pkgs/top-level/darwin-packages.nix b/pkgs/top-level/darwin-packages.nix
index 907ec0c75924..a53b16919ee3 100644
--- a/pkgs/top-level/darwin-packages.nix
+++ b/pkgs/top-level/darwin-packages.nix
@@ -47,6 +47,7 @@ in
   iosSdkPkgs = darwin.callPackage ../os-specific/darwin/ios-sdk-pkgs {
     buildIosSdk = buildPackages.darwin.iosSdkPkgs.sdk;
     targetIosSdkPkgs = targetPackages.darwin.iosSdkPkgs;
+    xcode = darwin.xcode_8_2;
     inherit (pkgs.llvmPackages) clang-unwrapped;
   };
 
@@ -68,7 +69,7 @@ in
 
   usr-include = callPackage ../os-specific/darwin/usr-include { };
 
-  xcode = callPackage ../os-specific/darwin/xcode { };
+  inherit (callPackages ../os-specific/darwin/xcode { } ) xcode_8_1 xcode_8_2 xcode_9_1 xcode_9_2;
 
   CoreSymbolication = callPackage ../os-specific/darwin/CoreSymbolication { };