2012-11-07 20:10:39 +00:00
|
|
|
{ stdenv, androidsdk, jdk, ant }:
|
|
|
|
{ name, src, platformVersions ? [ "8" ], useGoogleAPIs ? false
|
|
|
|
, release ? false, keyStore ? null, keyAlias ? null, keyStorePassword ? null, keyAliasPassword ? null
|
|
|
|
}:
|
|
|
|
|
|
|
|
assert release -> keyStore != null && keyAlias != null && keyStorePassword != null && keyAliasPassword != null;
|
|
|
|
|
|
|
|
let
|
2012-12-28 18:54:15 +00:00
|
|
|
platformName = if stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux" then "linux"
|
2012-11-07 20:10:39 +00:00
|
|
|
else if stdenv.system == "x86_64-darwin" then "macosx"
|
|
|
|
else throw "Platform: ${stdenv.system} is not supported!";
|
|
|
|
|
|
|
|
androidsdkComposition = androidsdk { inherit platformVersions useGoogleAPIs; };
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
inherit name src;
|
|
|
|
|
2012-11-08 14:01:06 +00:00
|
|
|
ANDROID_HOME = "${androidsdkComposition}/libexec/android-sdk-${platformName}";
|
2012-11-07 20:10:39 +00:00
|
|
|
|
|
|
|
buildInputs = [ jdk ant ];
|
|
|
|
|
|
|
|
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.
|
|
|
|
ant ${if release then "release" else "debug"}
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
|
|
|
mv bin/*-${if release then "release" else "debug"}.apk $out
|
2013-03-05 11:29:48 +00:00
|
|
|
|
|
|
|
mkdir -p $out/nix-support
|
2013-03-05 13:33:49 +00:00
|
|
|
echo "file binary-dist $(ls $out/*.apk)" > $out/nix-support/hydra-build-products
|
2012-11-07 20:10:39 +00:00
|
|
|
'';
|
|
|
|
}
|