1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-24 06:31:02 +00:00
nixpkgs/pkgs/development/mobile/androidenv/build-app.nix
2018-07-20 18:48:37 +00:00

52 lines
1.7 KiB
Nix

{ stdenv, androidsdk, jdk, ant, androidndk, gnumake, gawk, file, which }:
args@{ name, src, platformVersions ? [ "8" ], useGoogleAPIs ? false, antFlags ? ""
, release ? false, keyStore ? null, keyAlias ? null, keyStorePassword ? null, keyAliasPassword ? null
, useNDK ? false, ...
}:
assert release -> keyStore != null && keyAlias != null && keyStorePassword != null && keyAliasPassword != null;
let
androidsdkComposition = androidsdk {
inherit platformVersions useGoogleAPIs;
abiVersions = [];
};
in
stdenv.mkDerivation ({
name = stdenv.lib.replaceChars [" "] [""] name;
ANDROID_HOME = "${androidsdkComposition}/libexec";
buildInputs = [ jdk ant ] ++
stdenv.lib.optional useNDK [ androidndk gnumake gawk file which ];
buildPhase = ''
${stdenv.lib.optionalString release ''
# Provide key singing attributes
( echo "key.store=${keyStore}"
echo "key.alias=${keyAlias}"
echo "key.store.password=${keyStorePassword}"
echo "key.alias.password=${keyAliasPassword}"
) >> ant.properties
''}
export ANDROID_SDK_HOME=`pwd` # Key files cannot be stored in the user's home directory. This overrides it.
${if useNDK then ''
export GNUMAKE=${gnumake}/bin/make
export NDK_HOST_AWK=${gawk}/bin/gawk
${androidndk}/bin/ndk-build
'' else ""}
ant ${antFlags} ${if release then "release" else "debug"}
'';
installPhase = ''
mkdir -p $out
mv bin/*-${if release then "release" else "debug"}.apk $out
mkdir -p $out/nix-support
echo "file binary-dist \"$(echo $out/*.apk)\"" > $out/nix-support/hydra-build-products
'';
} //
builtins.removeAttrs args ["name"])