1{
2 lib,
3 stdenvNoCC,
4 fetchzip,
5 makeWrapper,
6 openjdk,
7}:
8
9stdenvNoCC.mkDerivation {
10 pname = "android-studio-tools";
11 version = "13114758";
12
13 src = fetchzip {
14 # The only difference between the Linux and Mac versions is a single comment at the top of all the scripts
15 # Therefore, we will use the Linux version and just patch the comment
16 url = "https://dl.google.com/android/repository/commandlinetools-linux-13114758_latest.zip";
17 hash = "sha256-dt8nwjL8wyRfBZOedCPYXh7zyeMUeH0gOPpTcpxCegU=";
18 };
19
20 postPatch = ''
21 find . -type f -not -path "./bin/*" -exec chmod -x {} \;
22 ''
23 + lib.optionalString stdenvNoCC.hostPlatform.isDarwin ''
24 for f in cmdline-tools/bin/*; do
25 sed -i 's|start up script for Linux|start up script for Mac|' $f
26 done
27 '';
28
29 nativeBuildInputs = [ makeWrapper ];
30
31 dontConfigure = true;
32 dontBuild = true;
33
34 installPhase = ''
35 runHook preInstall
36
37 mkdir -p $out
38 cp -r . $out
39
40 for f in $out/bin/*; do
41 wrapProgram $f --set JAVA_HOME "${openjdk}"
42 done
43
44 runHook postInstall
45 '';
46
47 meta = {
48 description = "Android Studio CLI Tools";
49 homepage = "https://developer.android.com/studio";
50 downloadPage = "https://developer.android.com/studio";
51 changelog = "https://developer.android.com/studio/releases";
52 license = lib.licenses.unfree;
53 maintainers = with lib.maintainers; [ pandapip1 ];
54 teams = [ lib.teams.android ];
55 platforms = lib.platforms.all;
56 sourceProvenance = with lib.sourceTypes; [ fromSource ]; # The 'binaries' are actually shell scripts
57 };
58}