about summary refs log tree commit diff
path: root/pkgs/development/tools/aapt/default.nix
blob: 3bdb1e2f96eb7dbbc2c7b38fa632ae8f36312d63 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{ lib
, stdenvNoCC
, fetchzip
, autoPatchelfHook
, libcxx
}:

stdenvNoCC.mkDerivation rec {
  pname = "aapt";
  version = "8.4.1-11315950";

  src =
    let
      urlAndHash =
        if stdenvNoCC.hostPlatform.isLinux then {
          url = "https://dl.google.com/android/maven2/com/android/tools/build/aapt2/${version}/aapt2-${version}-linux.jar";
          hash = "sha256-eSQaZrRtb5aCG320hrXAL256fxa/oMhBC4hcTA1KRxs=";
        } else if stdenvNoCC.hostPlatform.isDarwin then {
          url = "https://dl.google.com/android/maven2/com/android/tools/build/aapt2/${version}/aapt2-${version}-osx.jar";
          hash = "sha256-LUihNjase79JbUkHDb10A5d6pJ+VXDVfv7m09hkL8kY=";
        } else throw "Unsupport platform: ${stdenvNoCC.system}";
    in
    fetchzip (urlAndHash // {
      extension = "zip";
      stripRoot = false;
    });

  nativeBuildInputs = lib.optionals stdenvNoCC.hostPlatform.isLinux [ autoPatchelfHook ];
  buildInputs = lib.optionals stdenvNoCC.hostPlatform.isLinux [ libcxx ];

  installPhase = ''
    runHook preInstall

    install -D aapt2 $out/bin/aapt2

    runHook postInstall
  '';

  meta = {
    description = "Build tool that compiles and packages Android app's resources";
    mainProgram = "aapt2";
    homepage = "https://developer.android.com/tools/aapt2";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ linsui ];
    platforms = lib.platforms.unix;
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
  };
}