btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / an / android-studio-tools / package.nix
blob2b1bca479841896ced861113e7e57ed2e05a52a0
2   lib,
3   stdenvNoCC,
4   fetchzip,
5   makeWrapper,
6   openjdk,
7 }:
9 stdenvNoCC.mkDerivation {
10   pname = "android-studio-tools";
11   version = "11076708";
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-11076708_latest.zip";
17     hash = "sha256-NjxJzHRT2/zZ9YzzjqaMVxpOELkDneQgc1/y1GUnZow=";
18   };
20   postPatch = ''
21     find . -type f -not -path "./bin/*" -exec chmod -x {} \;
22   '' + lib.optionalString stdenvNoCC.hostPlatform.isDarwin ''
23     for f in cmdline-tools/bin/*; do
24       sed -i 's|start up script for Linux|start up script for Mac|' $f
25     done
26   '';
28   nativeBuildInputs = [ makeWrapper ];
30   dontConfigure = true;
31   dontBuild = true;
33   installPhase = ''
34     runHook preInstall
36     mkdir -p $out
37     cp -r . $out
39     for f in $out/bin/*; do
40       wrapProgram $f --set JAVA_HOME "${openjdk}"
41     done
43     runHook postInstall
44   '';
46   meta = {
47     description = "Android Studio CLI Tools";
48     homepage = "https://developer.android.com/studio";
49     downloadPage = "https://developer.android.com/studio";
50     changelog = "https://developer.android.com/studio/releases";
51     license = lib.licenses.unfree;
52     maintainers = with lib.maintainers; [ pandapip1 ];
53     platforms = lib.platforms.all;
54     sourceProvenance = with lib.sourceTypes; [ fromSource ]; # The 'binaries' are actually shell scripts
55   };