Merge pull request #245205 from emilytrau/xcodes-from-source

xcodes: build from source
This commit is contained in:
Emily Trau 2023-12-31 22:24:19 +11:00 committed by GitHub
commit 90ea5d6f68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 277 additions and 22 deletions

View file

@ -29,6 +29,7 @@ in rec {
url = dep.packageRef.location;
rev = dep.state.checkoutState.revision;
sha256 = hashes.${dep.subpath};
fetchSubmodules = true;
})) workspaceState.object.dependencies
);

View file

@ -23,7 +23,7 @@ hashes=""
jq -r '.object.dependencies[] | "\(.subpath) \(.packageRef.location) \(.state.checkoutState.revision)"' $stateFile \
| while read -r name url rev; do
echo >&2 "-- Fetching $name"
sha256="$(nix-prefetch-git $url $rev | jq -r .sha256)"
sha256="$(nix-prefetch-git --fetch-submodules $url $rev | jq -r .sha256)"
hashes+="
\"$name\" = \"$sha256\";"
echo >&2

View file

@ -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;
};
})

View file

@ -0,0 +1,17 @@
# This file was generated by swiftpm2nix.
{
workspaceStateFile = ./workspace-state.json;
hashes = {
"data" = "1jf2y9dbg1qvxkkabdkihdnr1kmznq79h18j65a7iw1hljdp8hyg";
"Foundation" = "0hcpc15v38l32qc2sh4gqj909b1f90knln9yz3mfiyf6xi7iy6q7";
"KeychainAccess" = "0m57pq1vn5qarmlx5x4kfv0yzjylafl3ipih5p60zyfsx6k5b55l";
"LegibleError" = "08x5agha74chq1z5c7c5r2vasdk81pyl2k085miapd4l3jszz4fj";
"Path.swift" = "05qk7kwb1254zwdxc3sjc3gprccnv9fwapmy5y6ygxjz8a6jfk83";
"PromiseKit" = "0vlkd4famjgbd4qs2ldi5aqg13nk77h7ddsdigyxxzgkwgxl076d";
"Rainbow" = "0iv31azny668vpsjgmldgkgn9cp8i5h9rlc6w5bs8q63nwq19wb0";
"swift-argument-parser" = "19b4pkcx4xf0iwg0nbr7wvkkbwl6h8sch848gid6l98728glmcw9";
"SwiftSoup" = "14klizw8jhmxhxays1b1yh4bp0nbb3l4l1pj6sdnf0iqs0wladv8";
"Version" = "0s5bwr1li6dnsnalfyraq1kzhqmmn9qwp1mld4msrn3q5vvjmql9";
"Yams" = "11abhcfkmqm3cmh7vp7rqzvxd1zj02j2866a2pp6v9m89456xb76";
};
}

View file

@ -0,0 +1,194 @@
{
"object": {
"artifacts": [],
"dependencies": [
{
"basedOn": null,
"packageRef": {
"identity": "data",
"kind": "remoteSourceControl",
"location": "https://github.com/xcodereleases/data",
"name": "XcodeReleases"
},
"state": {
"checkoutState": {
"revision": "fcf527b187817f67c05223676341f3ab69d4214d"
},
"name": "sourceControlCheckout"
},
"subpath": "data"
},
{
"basedOn": null,
"packageRef": {
"identity": "foundation",
"kind": "remoteSourceControl",
"location": "https://github.com/PromiseKit/Foundation.git",
"name": "PMKFoundation"
},
"state": {
"checkoutState": {
"revision": "985f17fa69ee0e5b7eb3ff9be87ffc4e05fc0927",
"version": "3.4.0"
},
"name": "sourceControlCheckout"
},
"subpath": "Foundation"
},
{
"basedOn": null,
"packageRef": {
"identity": "keychainaccess",
"kind": "remoteSourceControl",
"location": "https://github.com/kishikawakatsumi/KeychainAccess.git",
"name": "KeychainAccess"
},
"state": {
"checkoutState": {
"revision": "8d33ffd6f74b3bcfc99af759d4204c6395a3f918",
"version": "3.2.1"
},
"name": "sourceControlCheckout"
},
"subpath": "KeychainAccess"
},
{
"basedOn": null,
"packageRef": {
"identity": "legibleerror",
"kind": "remoteSourceControl",
"location": "https://github.com/mxcl/LegibleError.git",
"name": "LegibleError"
},
"state": {
"checkoutState": {
"revision": "909e9bab3ded97350b28a5ab41dd745dd8aa9710",
"version": "1.0.4"
},
"name": "sourceControlCheckout"
},
"subpath": "LegibleError"
},
{
"basedOn": null,
"packageRef": {
"identity": "path.swift",
"kind": "remoteSourceControl",
"location": "https://github.com/mxcl/Path.swift.git",
"name": "Path.swift"
},
"state": {
"checkoutState": {
"revision": "dac007e907a4f4c565cfdc55a9ce148a761a11d5",
"version": "0.16.3"
},
"name": "sourceControlCheckout"
},
"subpath": "Path.swift"
},
{
"basedOn": null,
"packageRef": {
"identity": "promisekit",
"kind": "remoteSourceControl",
"location": "https://github.com/mxcl/PromiseKit.git",
"name": "PromiseKit"
},
"state": {
"checkoutState": {
"revision": "1c296a8637838901d2b01e4c46875ee749506133",
"version": "6.8.5"
},
"name": "sourceControlCheckout"
},
"subpath": "PromiseKit"
},
{
"basedOn": null,
"packageRef": {
"identity": "rainbow",
"kind": "remoteSourceControl",
"location": "https://github.com/onevcat/Rainbow.git",
"name": "Rainbow"
},
"state": {
"checkoutState": {
"revision": "626c3d4b6b55354b4af3aa309f998fae9b31a3d9",
"version": "3.2.0"
},
"name": "sourceControlCheckout"
},
"subpath": "Rainbow"
},
{
"basedOn": null,
"packageRef": {
"identity": "swift-argument-parser",
"kind": "remoteSourceControl",
"location": "https://github.com/apple/swift-argument-parser",
"name": "swift-argument-parser"
},
"state": {
"checkoutState": {
"revision": "9f39744e025c7d377987f30b03770805dcb0bcd1",
"version": "1.1.4"
},
"name": "sourceControlCheckout"
},
"subpath": "swift-argument-parser"
},
{
"basedOn": null,
"packageRef": {
"identity": "swiftsoup",
"kind": "remoteSourceControl",
"location": "https://github.com/scinfu/SwiftSoup.git",
"name": "SwiftSoup"
},
"state": {
"checkoutState": {
"revision": "aeb5b4249c273d1783a5299e05be1b26e061ea81",
"version": "2.0.0"
},
"name": "sourceControlCheckout"
},
"subpath": "SwiftSoup"
},
{
"basedOn": null,
"packageRef": {
"identity": "version",
"kind": "remoteSourceControl",
"location": "https://github.com/mxcl/Version.git",
"name": "Version"
},
"state": {
"checkoutState": {
"revision": "087c91fedc110f9f833b14ef4c32745dabca8913",
"version": "1.0.3"
},
"name": "sourceControlCheckout"
},
"subpath": "Version"
},
{
"basedOn": null,
"packageRef": {
"identity": "yams",
"kind": "remoteSourceControl",
"location": "https://github.com/jpsim/Yams",
"name": "Yams"
},
"state": {
"checkoutState": {
"revision": "01835dc202670b5bb90d07f3eae41867e9ed29f6",
"version": "5.0.1"
},
"name": "sourceControlCheckout"
},
"subpath": "Yams"
}
]
},
"version": 6
}

View file

@ -94,6 +94,7 @@ let
Libsystem = callPackage ./libSystem.nix { };
LibsystemCross = pkgs.darwin.Libsystem;
libcharset = callPackage ./libcharset.nix { };
libcompression = callPackage ./libcompression.nix { };
libunwind = callPackage ./libunwind.nix { };
libnetwork = callPackage ./libnetwork.nix { };
libpm = callPackage ./libpm.nix { };

View file

@ -0,0 +1,20 @@
{ stdenvNoCC, buildPackages, MacOSX-SDK }:
let self = stdenvNoCC.mkDerivation {
pname = "libcompression";
version = MacOSX-SDK.version;
dontUnpack = true;
dontBuild = true;
installPhase = ''
mkdir -p $out/lib
cp ${MacOSX-SDK}/usr/lib/libcompression* $out/lib
'';
passthru = {
tbdRewrites = {
const."/usr/lib/libcompression.dylib" = "${self}/lib/libcompression.dylib";
};
};
}; in self

View file

@ -4178,7 +4178,10 @@ with pkgs;
xcodeenv = callPackage ../development/mobile/xcodeenv { };
xcodes = callPackage ../development/tools/xcodes { };
xcodes = swiftPackages.callPackage ../development/tools/xcodes {
inherit (swiftPackages.apple_sdk.frameworks) CryptoKit LocalAuthentication;
inherit (swiftPackages.apple_sdk) libcompression;
};
gomobile = callPackage ../development/mobile/gomobile { };