···11+{
22+ lib,
33+ stdenvNoCC,
44+ fetchzip,
55+ makeWrapper,
66+ openjdk,
77+}:
88+99+stdenvNoCC.mkDerivation {
1010+ pname = "android-studio-tools";
1111+ version = "11076708";
1212+1313+ src = fetchzip {
1414+ # The only difference between the Linux and Mac versions is a single comment at the top of all the scripts
1515+ # Therefore, we will use the Linux version and just patch the comment
1616+ url = "https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip";
1717+ hash = "sha256-NjxJzHRT2/zZ9YzzjqaMVxpOELkDneQgc1/y1GUnZow=";
1818+ };
1919+2020+ postPatch = ''
2121+ find . -type f -not -path "./bin/*" -exec chmod -x {} \;
2222+ '' + lib.optionalString stdenvNoCC.isDarwin ''
2323+ for f in cmdline-tools/bin/*; do
2424+ sed -i 's|start up script for Linux|start up script for Mac|' $f
2525+ done
2626+ '';
2727+2828+ nativeBuildInputs = [ makeWrapper ];
2929+3030+ dontConfigure = true;
3131+ dontBuild = true;
3232+3333+ installPhase = ''
3434+ runHook preInstall
3535+3636+ mkdir -p $out
3737+ cp -r . $out
3838+3939+ for f in $out/bin/*; do
4040+ wrapProgram $f --set JAVA_HOME "${openjdk}"
4141+ done
4242+4343+ runHook postInstall
4444+ '';
4545+4646+ meta = {
4747+ description = "Android Studio CLI Tools";
4848+ homepage = "https://developer.android.com/studio";
4949+ downloadPage = "https://developer.android.com/studio";
5050+ changelog = "https://developer.android.com/studio/releases";
5151+ license = lib.licenses.unfree;
5252+ maintainers = with lib.maintainers; [ pandapip1 ];
5353+ platforms = lib.platforms.all;
5454+ sourceProvenance = with lib.sourceTypes; [ fromSource ]; # The 'binaries' are actually shell scripts
5555+ };
5656+}