nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 72 lines 1.9 kB view raw
1{ 2 composeAndroidPackages, 3 stdenv, 4 lib, 5 ant, 6 jdk, 7 gnumake, 8 gawk, 9 meta, 10}: 11 12{ 13 name, 14 release ? false, 15 keyStore ? null, 16 keyAlias ? null, 17 keyStorePassword ? null, 18 keyAliasPassword ? null, 19 antFlags ? "", 20 ... 21}@args: 22 23assert 24 release 25 -> keyStore != null && keyAlias != null && keyStorePassword != null && keyAliasPassword != null; 26 27let 28 androidSdkFormalArgs = lib.functionArgs composeAndroidPackages; 29 androidArgs = builtins.intersectAttrs androidSdkFormalArgs args; 30 androidsdk = (composeAndroidPackages androidArgs).androidsdk; 31 32 extraArgs = removeAttrs args ([ "name" ] ++ builtins.attrNames androidSdkFormalArgs); 33in 34stdenv.mkDerivation ( 35 { 36 name = lib.replaceStrings [ " " ] [ "" ] name; # Android APKs may contain white spaces in their names, but Nix store paths cannot 37 ANDROID_HOME = "${androidsdk}/libexec/android-sdk"; 38 buildInputs = [ 39 jdk 40 ant 41 ]; 42 buildPhase = '' 43 ${lib.optionalString release '' 44 # Provide key singing attributes 45 ( echo "key.store=${keyStore}" 46 echo "key.alias=${keyAlias}" 47 echo "key.store.password=${keyStorePassword}" 48 echo "key.alias.password=${keyAliasPassword}" 49 ) >> ant.properties 50 ''} 51 52 export ANDROID_SDK_HOME=`pwd` # Key files cannot be stored in the user's home directory. This overrides it. 53 54 ${lib.optionalString (args ? includeNDK && args.includeNDK) '' 55 export GNUMAKE=${gnumake}/bin/make 56 export NDK_HOST_AWK=${gawk}/bin/gawk 57 ${androidsdk}/libexec/android-sdk/ndk-bundle/ndk-build 58 ''} 59 ant ${antFlags} ${if release then "release" else "debug"} 60 ''; 61 installPhase = '' 62 mkdir -p $out 63 mv bin/*-${if release then "release" else "debug"}.apk $out 64 65 mkdir -p $out/nix-support 66 echo "file binary-dist \"$(echo $out/*.apk)\"" > $out/nix-support/hydra-build-products 67 ''; 68 69 inherit meta; 70 } 71 // extraArgs 72)