about summary refs log tree commit diff
path: root/pkgs/development/tools/xcodes/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/tools/xcodes/default.nix')
-rw-r--r--pkgs/development/tools/xcodes/default.nix59
1 files changed, 39 insertions, 20 deletions
diff --git a/pkgs/development/tools/xcodes/default.nix b/pkgs/development/tools/xcodes/default.nix
index f10fd76aa0202..a7449aa08651c 100644
--- a/pkgs/development/tools/xcodes/default.nix
+++ b/pkgs/development/tools/xcodes/default.nix
@@ -1,41 +1,60 @@
-{ lib, stdenv, fetchurl, unzip }:
-
+{ lib
+, stdenv
+, fetchFromGitHub
+, swift
+, swiftpm
+, swiftpm2nix
+, makeWrapper
+, CryptoKit
+, LocalAuthentication
+, libcompression
+, aria2
+}:
+let
+  generated = swiftpm2nix.helpers ./generated;
+in
 stdenv.mkDerivation (finalAttrs: {
   pname = "xcodes";
   version = "1.4.1";
 
-  src = fetchurl {
-    url = "https://github.com/XcodesOrg/xcodes/releases/download/${finalAttrs.version}/xcodes.zip";
-    hash = "sha256-PtXF2eqNfEX29EtXlcjdxrUs7BPn/YurUuFFeLpXwrk=";
+  src = fetchFromGitHub {
+    owner = "XcodesOrg";
+    repo = finalAttrs.pname;
+    rev = finalAttrs.version;
+    hash = "sha256-ARrSQ9ozM90Yg7y4WdU7jjNQ64sXHuhxZh/iNJcFfY0=";
   };
 
-  nativeBuildInputs = [ unzip ];
+  nativeBuildInputs = [ swift swiftpm makeWrapper ];
 
-  unpackPhase = ''
-    runHook preUnpack
-    unzip -q $src
-    runHook postUnpack
-  '';
+  buildInputs = [
+    CryptoKit
+    LocalAuthentication
+    libcompression
+  ];
 
-  dontPatch = true;
-  dontConfigure = true;
-  dontBuild = true;
+  configurePhase = generated.configure;
 
   installPhase = ''
     runHook preInstall
-    mkdir -p $out/bin
-    install -m755 xcodes $out/bin/xcodes
+
+    binPath="$(swiftpmBinPath)"
+    install -D $binPath/xcodes $out/bin/xcodes
+    wrapProgram $out/bin/xcodes \
+      --prefix PATH : ${lib.makeBinPath [ aria2 ]}
+
     runHook postInstall
   '';
 
-  dontFixup = true;
-
   meta = with lib; {
     changelog = "https://github.com/XcodesOrg/xcodes/releases/tag/${finalAttrs.version}";
     description = "Command-line tool to install and switch between multiple versions of Xcode";
     homepage = "https://github.com/XcodesOrg/xcodes";
-    license = licenses.mit;
-    maintainers = with maintainers; [ _0x120581f ];
+    license = with licenses; [
+      mit
+      # unxip
+      lgpl3Only
+    ];
+    maintainers = with maintainers; [ _0x120581f emilytrau ];
     platforms = platforms.darwin;
   };
 })