From 62b59e5353c8ef514ca948032bee89eec6e9f875 Mon Sep 17 00:00:00 2001 From: Ali Abrar Date: Tue, 16 May 2017 15:27:27 -0400 Subject: [PATCH 1/8] Add buildGradleApp to androidenv --- .../mobile/androidenv/androidsdk.nix | 3 + .../mobile/androidenv/build-gradle-app.nix | 112 ++++++++++++++++++ .../development/mobile/androidenv/default.nix | 11 +- .../mobile/androidenv/google-repository.nix | 18 +++ 4 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/mobile/androidenv/build-gradle-app.nix create mode 100644 pkgs/development/mobile/androidenv/google-repository.nix diff --git a/pkgs/development/mobile/androidenv/androidsdk.nix b/pkgs/development/mobile/androidenv/androidsdk.nix index 699af16cf041..36ac0b067855 100644 --- a/pkgs/development/mobile/androidenv/androidsdk.nix +++ b/pkgs/development/mobile/androidenv/androidsdk.nix @@ -1,6 +1,7 @@ { stdenv, stdenv_32bit, fetchurl, unzip, makeWrapper , platformTools, buildTools, support, supportRepository, platforms, sysimages, addons, sources , libX11, libXext, libXrender, libxcb, libXau, libXdmcp, libXtst, libGLU_combined, alsaLib +, googleRepository , freetype, fontconfig, glib, gtk2, atk, file, jdk, coreutils, libpulseaudio, dbus , zlib, glxinfo, xkeyboardconfig , includeSources @@ -168,6 +169,8 @@ stdenv.mkDerivation rec { ${stdenv.lib.optionalString useInstantApps "ln -s ${addons.instant_apps}/whsdk instantapps"} + ln -s ${googleRepository}/m2repository + cd ../.. # Symlink required sources diff --git a/pkgs/development/mobile/androidenv/build-gradle-app.nix b/pkgs/development/mobile/androidenv/build-gradle-app.nix new file mode 100644 index 000000000000..d1d7abdc9634 --- /dev/null +++ b/pkgs/development/mobile/androidenv/build-gradle-app.nix @@ -0,0 +1,112 @@ +{ stdenv, androidsdk, jdk, androidndk, gnumake, gawk, file, which, gradle, fetchurl, buildEnv }: + +args@{ name, src, platformVersions ? [ "8" ], useGoogleAPIs ? false, useExtraSupportLibs ? false, useGooglePlayServices ? false +, release ? false, keyStore ? null, keyAlias ? null, keyStorePassword ? null, keyAliasPassword ? null +, useNDK ? false, buildInputs ? [], mavenDeps, gradleTask, buildDirectory ? "./." +}: + +assert release -> keyStore != null && keyAlias != null && keyStorePassword != null && keyAliasPassword != null; + +let + m2install = { repo, version, artifactId, groupId, jarSha256, pomSha256, aarSha256, suffix ? "" }: + let m2Name = "${artifactId}-${version}"; + m2Path = "${builtins.replaceStrings ["."] ["/"] groupId}/${artifactId}/${version}"; + m2PomFilename = "${m2Name}${suffix}.pom"; + m2JarFilename = "${m2Name}${suffix}.jar"; + m2AarFilename = "${m2Name}${suffix}.aar"; + m2Jar = + if jarSha256 == null + then null + else fetchurl { + sha256 = jarSha256; + url = "${repo}${m2Path}/${m2JarFilename}"; + }; + m2Pom = + if pomSha256 == null + then null + else fetchurl { + sha256 = pomSha256; + url = "${repo}${m2Path}/${m2PomFilename}"; + }; + m2Aar = + if aarSha256 == null + then null + else fetchurl { + sha256 = aarSha256; + url = "${repo}${m2Path}/${m2AarFilename}"; + }; + in stdenv.mkDerivation rec { + name = m2Name; + inherit m2Name m2Path m2Pom m2Jar m2Aar m2JarFilename m2PomFilename m2AarFilename; + + installPhase = '' + mkdir -p $out/m2/$m2Path + ${if m2Jar != null + then "cp $m2Jar $out/m2/$m2Path/$m2JarFilename" + else ""} + ${if m2Pom != null + then "cp $m2Pom $out/m2/$m2Path/$m2PomFilename" + else ""} + ${if m2Aar != null + then "cp $m2Aar $out/m2/$m2Path/$m2AarFilename" + else ""} + ''; + + phases = "installPhase"; + }; + platformName = if stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux" then "linux" + else if stdenv.system == "x86_64-darwin" then "macosx" + else throw "Platform: ${stdenv.system} is not supported!"; + + androidsdkComposition = androidsdk { + inherit platformVersions useGoogleAPIs useExtraSupportLibs useGooglePlayServices; + abiVersions = [ "armeabi-v7a" ]; + }; +in +stdenv.mkDerivation ({ + name = stdenv.lib.replaceChars [" "] [""] name; + + ANDROID_HOME = "${androidsdkComposition}/libexec"; + ANDROID_NDK_HOME = "${androidndk}/libexec/android-ndk-r10e"; + + buildInputs = [ jdk gradle ] ++ + stdenv.lib.optional useNDK [ androidndk gnumake gawk file which ] ++ + buildInputs; + + DEPENDENCIES = buildEnv { name = "${name}-maven-deps"; + paths = map m2install mavenDeps; + }; + + buildPhase = '' + buildDir=`pwd` + cp -r $ANDROID_HOME $buildDir/local_sdk + chmod -R 755 local_sdk + export ANDROID_HOME=$buildDir/local_sdk + export ANDROID_SDK_HOME=`pwd` # Key files cannot be stored in the user's home directory. This overrides it. + + mkdir "$ANDROID_HOME/licenses" || true + echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license" + echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license" + + export APP_HOME=`pwd` + export CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + mkdir -p .m2/repository + for dep in $DEPENDENCIES ; do + cp -RL $dep/m2/* .m2/repository/ ; done + chmod -R 755 .m2 + mkdir -p .m2/repository/com/android/support + cp -RL local_sdk/extras/android/m2repository/com/android/support/* .m2/repository/com/android/support/ + cp -RL local_sdk/extras/google/m2repository/* .m2/repository/ + gradle ${gradleTask} --offline --no-daemon -g ./tmp -Dmaven.repo.local=`pwd`/.m2/repository + ''; + + installPhase = '' + mkdir -p $out + mv ${buildDirectory}/build/outputs/apk/*.apk $out + + mkdir -p $out/nix-support + echo "file binary-dist \"$(echo $out/*.apk)\"" > $out/nix-support/hydra-build-products + ''; +} // +builtins.removeAttrs args ["name" "mavenDeps"]) diff --git a/pkgs/development/mobile/androidenv/default.nix b/pkgs/development/mobile/androidenv/default.nix index 5846e4fb6de0..cb93717861c1 100644 --- a/pkgs/development/mobile/androidenv/default.nix +++ b/pkgs/development/mobile/androidenv/default.nix @@ -23,6 +23,10 @@ rec { inherit (pkgs) stdenv fetchurl unzip; }; + googleRepository = import ./google-repository.nix { + inherit (pkgs) stdenv fetchurl unzip; + }; + platforms = if (pkgs.stdenv.system == "i686-linux" || pkgs.stdenv.system == "x86_64-linux") then import ./platforms-linux.nix { inherit (pkgs) stdenv fetchurl unzip; @@ -50,7 +54,7 @@ rec { inherit (pkgs) zlib glxinfo freetype fontconfig glib gtk2 atk libGLU_combined file alsaLib jdk coreutils libpulseaudio dbus; inherit (pkgs.xorg) libX11 libXext libXrender libxcb libXau libXdmcp libXtst xkeyboardconfig; - inherit platformTools buildTools support supportRepository platforms sysimages addons sources includeSources; + inherit platformTools buildTools support supportRepository googleRepository platforms sysimages addons sources includeSources; stdenv_32bit = pkgs_i686.stdenv; }; @@ -296,4 +300,9 @@ rec { androidndk = androidndk_10e; targetAndroidndkPkgs = targetPackages.androidenv.androidndkPkgs_10e; }; + + buildGradleApp = import ./build-gradle-app.nix { + inherit (pkgs) stdenv jdk gnumake gawk file which gradle fetchurl buildEnv; + inherit androidsdk androidndk; + }; } diff --git a/pkgs/development/mobile/androidenv/google-repository.nix b/pkgs/development/mobile/androidenv/google-repository.nix new file mode 100644 index 000000000000..abc1b46c7433 --- /dev/null +++ b/pkgs/development/mobile/androidenv/google-repository.nix @@ -0,0 +1,18 @@ +{stdenv, fetchurl, unzip}: + +stdenv.mkDerivation rec { + version = "gms_v9_rc41_wear_2_0_rc6"; + name = "google-repository"; + src = fetchurl { + url = "https://dl-ssl.google.com/android/repository/google_m2repository_${version}.zip"; + sha256 = "0gjmmzkvjp80krbak5nkmkvvs75givqbz0cvw58f6kc7i9jm12nf"; + }; + + buildCommand = '' + mkdir -p $out + cd $out + unzip $src + ''; + + buildInputs = [ unzip ]; +} From 1cc64da8d4bad1f1134103fa466f627c4544acd6 Mon Sep 17 00:00:00 2001 From: Ali Abrar Date: Tue, 16 May 2017 17:22:55 -0400 Subject: [PATCH 2/8] add signing to buildGradleApp --- .../mobile/androidenv/build-gradle-app.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkgs/development/mobile/androidenv/build-gradle-app.nix b/pkgs/development/mobile/androidenv/build-gradle-app.nix index d1d7abdc9634..8921e78528ce 100644 --- a/pkgs/development/mobile/androidenv/build-gradle-app.nix +++ b/pkgs/development/mobile/androidenv/build-gradle-app.nix @@ -78,6 +78,25 @@ stdenv.mkDerivation ({ }; buildPhase = '' + ${stdenv.lib.optionalString release '' + # Provide key signing attributes + ( echo "RELEASE_STORE_FILE=${keyStore}" + echo "RELEASE_KEY_ALIAS=${keyAlias}" + echo "RELEASE_STORE_PASSWORD=${keyStorePassword}" + echo "RELEASE_KEY_PASSWORD=${keyAliasPassword}" + ) >> local.properties + + cat >>build.gradle < Date: Tue, 16 May 2017 18:38:23 -0400 Subject: [PATCH 3/8] Add android sdk license acceptance --- pkgs/development/mobile/androidenv/build-gradle-app.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/mobile/androidenv/build-gradle-app.nix b/pkgs/development/mobile/androidenv/build-gradle-app.nix index 8921e78528ce..ee6783214723 100644 --- a/pkgs/development/mobile/androidenv/build-gradle-app.nix +++ b/pkgs/development/mobile/androidenv/build-gradle-app.nix @@ -2,10 +2,11 @@ args@{ name, src, platformVersions ? [ "8" ], useGoogleAPIs ? false, useExtraSupportLibs ? false, useGooglePlayServices ? false , release ? false, keyStore ? null, keyAlias ? null, keyStorePassword ? null, keyAliasPassword ? null -, useNDK ? false, buildInputs ? [], mavenDeps, gradleTask, buildDirectory ? "./." +, useNDK ? false, buildInputs ? [], mavenDeps, gradleTask, buildDirectory ? "./.", acceptAndroidSdkLicenses ? false }: assert release -> keyStore != null && keyAlias != null && keyStorePassword != null && keyAliasPassword != null; +assert acceptAndroidSdkLicenses; let m2install = { repo, version, artifactId, groupId, jarSha256, pomSha256, aarSha256, suffix ? "" }: @@ -108,7 +109,6 @@ stdenv.mkDerivation ({ echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license" export APP_HOME=`pwd` - export CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar mkdir -p .m2/repository for dep in $DEPENDENCIES ; do From abddf4ab83f3ec1f8bf1b2b4e16aa27c6d36a55d Mon Sep 17 00:00:00 2001 From: Ali Abrar Date: Tue, 16 May 2017 21:40:21 -0400 Subject: [PATCH 4/8] Don't append signingConfigs to build.gradle --- .../mobile/androidenv/build-gradle-app.nix | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/pkgs/development/mobile/androidenv/build-gradle-app.nix b/pkgs/development/mobile/androidenv/build-gradle-app.nix index ee6783214723..f20f917c7738 100644 --- a/pkgs/development/mobile/androidenv/build-gradle-app.nix +++ b/pkgs/development/mobile/androidenv/build-gradle-app.nix @@ -85,18 +85,7 @@ stdenv.mkDerivation ({ echo "RELEASE_KEY_ALIAS=${keyAlias}" echo "RELEASE_STORE_PASSWORD=${keyStorePassword}" echo "RELEASE_KEY_PASSWORD=${keyAliasPassword}" - ) >> local.properties - - cat >>build.gradle <> gradle.properties ''} buildDir=`pwd` cp -r $ANDROID_HOME $buildDir/local_sdk From fe04fe868b0cbf8fd349101e883eaaa7a4196300 Mon Sep 17 00:00:00 2001 From: Ryan Trinkle Date: Wed, 14 Jun 2017 18:01:37 -0400 Subject: [PATCH 5/8] Fix gradle build --- pkgs/development/mobile/androidenv/build-gradle-app.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/development/mobile/androidenv/build-gradle-app.nix b/pkgs/development/mobile/androidenv/build-gradle-app.nix index f20f917c7738..7601fe14d0a2 100644 --- a/pkgs/development/mobile/androidenv/build-gradle-app.nix +++ b/pkgs/development/mobile/androidenv/build-gradle-app.nix @@ -100,8 +100,9 @@ stdenv.mkDerivation ({ export APP_HOME=`pwd` mkdir -p .m2/repository - for dep in $DEPENDENCIES ; do - cp -RL $dep/m2/* .m2/repository/ ; done + if [ -d "$DEPENDENCIES/m2" ] ; then + cp -RL "$DEPENDENCIES"/m2/* .m2/repository/ + fi chmod -R 755 .m2 mkdir -p .m2/repository/com/android/support cp -RL local_sdk/extras/android/m2repository/com/android/support/* .m2/repository/com/android/support/ From 2e8feba171b6d8bfec07df9cec5df5e3ee321ced Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 21 Jun 2018 12:12:02 -0400 Subject: [PATCH 6/8] androidenv: Use fetchzip instead of googlerepository --- .../mobile/androidenv/androidsdk.nix | 13 ++++++++++--- pkgs/development/mobile/androidenv/default.nix | 6 +----- .../mobile/androidenv/google-repository.nix | 18 ------------------ 3 files changed, 11 insertions(+), 26 deletions(-) delete mode 100644 pkgs/development/mobile/androidenv/google-repository.nix diff --git a/pkgs/development/mobile/androidenv/androidsdk.nix b/pkgs/development/mobile/androidenv/androidsdk.nix index 36ac0b067855..593b38036b72 100644 --- a/pkgs/development/mobile/androidenv/androidsdk.nix +++ b/pkgs/development/mobile/androidenv/androidsdk.nix @@ -1,7 +1,6 @@ -{ stdenv, stdenv_32bit, fetchurl, unzip, makeWrapper +{ stdenv, stdenv_32bit, fetchurl, fetchzip, unzip, makeWrapper , platformTools, buildTools, support, supportRepository, platforms, sysimages, addons, sources , libX11, libXext, libXrender, libxcb, libXau, libXdmcp, libXtst, libGLU_combined, alsaLib -, googleRepository , freetype, fontconfig, glib, gtk2, atk, file, jdk, coreutils, libpulseaudio, dbus , zlib, glxinfo, xkeyboardconfig , includeSources @@ -9,7 +8,15 @@ { platformVersions, abiVersions, useGoogleAPIs, useExtraSupportLibs ? false , useGooglePlayServices ? false, useInstantApps ? false }: -let inherit (stdenv.lib) makeLibraryPath; in +let inherit (stdenv.lib) makeLibraryPath; + + googleRepository = let version = "gms_v9_rc41_wear_2_0_rc6"; + in fetchzip rec { + url = "https://dl-ssl.google.com/android/repository/google_m2repository_${version}.zip"; + sha256 = "0k99xmynv0k62d301zx5jnjkddflr51i5lb02l9incg7m5cn8kzx"; + }; + +in stdenv.mkDerivation rec { name = "android-sdk-${version}"; diff --git a/pkgs/development/mobile/androidenv/default.nix b/pkgs/development/mobile/androidenv/default.nix index cb93717861c1..21a96c889248 100644 --- a/pkgs/development/mobile/androidenv/default.nix +++ b/pkgs/development/mobile/androidenv/default.nix @@ -23,10 +23,6 @@ rec { inherit (pkgs) stdenv fetchurl unzip; }; - googleRepository = import ./google-repository.nix { - inherit (pkgs) stdenv fetchurl unzip; - }; - platforms = if (pkgs.stdenv.system == "i686-linux" || pkgs.stdenv.system == "x86_64-linux") then import ./platforms-linux.nix { inherit (pkgs) stdenv fetchurl unzip; @@ -54,7 +50,7 @@ rec { inherit (pkgs) zlib glxinfo freetype fontconfig glib gtk2 atk libGLU_combined file alsaLib jdk coreutils libpulseaudio dbus; inherit (pkgs.xorg) libX11 libXext libXrender libxcb libXau libXdmcp libXtst xkeyboardconfig; - inherit platformTools buildTools support supportRepository googleRepository platforms sysimages addons sources includeSources; + inherit platformTools buildTools support supportRepository platforms sysimages addons sources includeSources; stdenv_32bit = pkgs_i686.stdenv; }; diff --git a/pkgs/development/mobile/androidenv/google-repository.nix b/pkgs/development/mobile/androidenv/google-repository.nix deleted file mode 100644 index abc1b46c7433..000000000000 --- a/pkgs/development/mobile/androidenv/google-repository.nix +++ /dev/null @@ -1,18 +0,0 @@ -{stdenv, fetchurl, unzip}: - -stdenv.mkDerivation rec { - version = "gms_v9_rc41_wear_2_0_rc6"; - name = "google-repository"; - src = fetchurl { - url = "https://dl-ssl.google.com/android/repository/google_m2repository_${version}.zip"; - sha256 = "0gjmmzkvjp80krbak5nkmkvvs75givqbz0cvw58f6kc7i9jm12nf"; - }; - - buildCommand = '' - mkdir -p $out - cd $out - unzip $src - ''; - - buildInputs = [ unzip ]; -} From b72da4bee8cbe20951e9818c335554d2abd566df Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 21 Jun 2018 12:48:05 -0400 Subject: [PATCH 7/8] androidenv.buildGradleApp: refactor --- .../mobile/androidenv/androidsdk.nix | 2 +- .../mobile/androidenv/build-gradle-app.nix | 105 ++++++++---------- .../development/mobile/androidenv/default.nix | 18 ++- 3 files changed, 58 insertions(+), 67 deletions(-) diff --git a/pkgs/development/mobile/androidenv/androidsdk.nix b/pkgs/development/mobile/androidenv/androidsdk.nix index 593b38036b72..a90c9f8476e3 100644 --- a/pkgs/development/mobile/androidenv/androidsdk.nix +++ b/pkgs/development/mobile/androidenv/androidsdk.nix @@ -176,7 +176,7 @@ stdenv.mkDerivation rec { ${stdenv.lib.optionalString useInstantApps "ln -s ${addons.instant_apps}/whsdk instantapps"} - ln -s ${googleRepository}/m2repository + ln -s ${googleRepository} m2repository cd ../.. diff --git a/pkgs/development/mobile/androidenv/build-gradle-app.nix b/pkgs/development/mobile/androidenv/build-gradle-app.nix index 7601fe14d0a2..1ca51fae1c29 100644 --- a/pkgs/development/mobile/androidenv/build-gradle-app.nix +++ b/pkgs/development/mobile/androidenv/build-gradle-app.nix @@ -1,66 +1,48 @@ -{ stdenv, androidsdk, jdk, androidndk, gnumake, gawk, file, which, gradle, fetchurl, buildEnv }: +{ stdenv, androidsdk, jdk, androidndk, gnumake, gawk, file +, which, gradle, fetchurl, buildEnv, runCommand }: -args@{ name, src, platformVersions ? [ "8" ], useGoogleAPIs ? false, useExtraSupportLibs ? false, useGooglePlayServices ? false -, release ? false, keyStore ? null, keyAlias ? null, keyStorePassword ? null, keyAliasPassword ? null -, useNDK ? false, buildInputs ? [], mavenDeps, gradleTask, buildDirectory ? "./.", acceptAndroidSdkLicenses ? false -}: +args@{ name, src, platformVersions ? [ "8" ], useGoogleAPIs ? false + , useExtraSupportLibs ? false, useGooglePlayServices ? false + , release ? false, keyStore ? null, keyAlias ? null + , keyStorePassword ? null, keyAliasPassword ? null + , useNDK ? false, buildInputs ? [], mavenDeps, gradleTask + , buildDirectory ? "./.", acceptAndroidSdkLicenses ? false }: -assert release -> keyStore != null && keyAlias != null && keyStorePassword != null && keyAliasPassword != null; +assert release -> keyStore != null; +assert release -> keyAlias != null; +assert release -> keyStorePassword != null; +assert release -> keyAliasPassword != null; assert acceptAndroidSdkLicenses; let - m2install = { repo, version, artifactId, groupId, jarSha256, pomSha256, aarSha256, suffix ? "" }: + inherit (stdenv.lib) optionalString; + + m2install = { repo, version, artifactId, groupId + , jarSha256, pomSha256, aarSha256, suffix ? "" }: let m2Name = "${artifactId}-${version}"; m2Path = "${builtins.replaceStrings ["."] ["/"] groupId}/${artifactId}/${version}"; - m2PomFilename = "${m2Name}${suffix}.pom"; - m2JarFilename = "${m2Name}${suffix}.jar"; - m2AarFilename = "${m2Name}${suffix}.aar"; - m2Jar = - if jarSha256 == null - then null - else fetchurl { - sha256 = jarSha256; - url = "${repo}${m2Path}/${m2JarFilename}"; - }; - m2Pom = - if pomSha256 == null - then null - else fetchurl { - sha256 = pomSha256; - url = "${repo}${m2Path}/${m2PomFilename}"; - }; - m2Aar = - if aarSha256 == null - then null - else fetchurl { - sha256 = aarSha256; - url = "${repo}${m2Path}/${m2AarFilename}"; - }; - in stdenv.mkDerivation rec { - name = m2Name; - inherit m2Name m2Path m2Pom m2Jar m2Aar m2JarFilename m2PomFilename m2AarFilename; - - installPhase = '' - mkdir -p $out/m2/$m2Path - ${if m2Jar != null - then "cp $m2Jar $out/m2/$m2Path/$m2JarFilename" - else ""} - ${if m2Pom != null - then "cp $m2Pom $out/m2/$m2Path/$m2PomFilename" - else ""} - ${if m2Aar != null - then "cp $m2Aar $out/m2/$m2Path/$m2AarFilename" - else ""} - ''; - - phases = "installPhase"; - }; - platformName = if stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux" then "linux" - else if stdenv.system == "x86_64-darwin" then "macosx" - else throw "Platform: ${stdenv.system} is not supported!"; + in runCommand m2Name {} ('' + mkdir -p $out/m2/${m2Path} + '' + optionalString (jarSha256 != null) '' + install -D ${fetchurl { + url = "${repo}${m2Path}/${m2Name}${suffix}.jar"; + sha256 = jarSha256; + }} $out/m2/${m2Path}/${m2Name}${suffix}.jar + '' + optionalString (pomSha256 != null) '' + install -D ${fetchurl { + url = "${repo}${m2Path}/${m2Name}${suffix}.pom"; + sha256 = pomSha256; + }} $out/m2/${m2Path}/${m2Name}${suffix}.pom + '' + optionalString (aarSha256 != null) '' + install -D ${fetchurl { + url = "${repo}${m2Path}/${m2Name}${suffix}.aar"; + sha256 = aarSha256; + }} $out/m2/${m2Path}/${m2Name}${suffix}.aar + ''); androidsdkComposition = androidsdk { - inherit platformVersions useGoogleAPIs useExtraSupportLibs useGooglePlayServices; + inherit platformVersions useGoogleAPIs + useExtraSupportLibs useGooglePlayServices; abiVersions = [ "armeabi-v7a" ]; }; in @@ -68,7 +50,7 @@ stdenv.mkDerivation ({ name = stdenv.lib.replaceChars [" "] [""] name; ANDROID_HOME = "${androidsdkComposition}/libexec"; - ANDROID_NDK_HOME = "${androidndk}/libexec/android-ndk-r10e"; + ANDROID_NDK_HOME = "${androidndk}/libexec/${androidndk.name}"; buildInputs = [ jdk gradle ] ++ stdenv.lib.optional useNDK [ androidndk gnumake gawk file which ] ++ @@ -79,7 +61,7 @@ stdenv.mkDerivation ({ }; buildPhase = '' - ${stdenv.lib.optionalString release '' + ${optionalString release '' # Provide key signing attributes ( echo "RELEASE_STORE_FILE=${keyStore}" echo "RELEASE_KEY_ALIAS=${keyAlias}" @@ -91,9 +73,11 @@ stdenv.mkDerivation ({ cp -r $ANDROID_HOME $buildDir/local_sdk chmod -R 755 local_sdk export ANDROID_HOME=$buildDir/local_sdk - export ANDROID_SDK_HOME=`pwd` # Key files cannot be stored in the user's home directory. This overrides it. + # Key files cannot be stored in the user's home directory. This + # overrides it. + export ANDROID_SDK_HOME=`pwd` - mkdir "$ANDROID_HOME/licenses" || true + mkdir -p "$ANDROID_HOME/licenses" echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license" echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license" @@ -113,9 +97,8 @@ stdenv.mkDerivation ({ installPhase = '' mkdir -p $out mv ${buildDirectory}/build/outputs/apk/*.apk $out - + mkdir -p $out/nix-support echo "file binary-dist \"$(echo $out/*.apk)\"" > $out/nix-support/hydra-build-products ''; -} // -builtins.removeAttrs args ["name" "mavenDeps"]) +} // builtins.removeAttrs args ["name" "mavenDeps"]) diff --git a/pkgs/development/mobile/androidenv/default.nix b/pkgs/development/mobile/androidenv/default.nix index 21a96c889248..65ec63201c83 100644 --- a/pkgs/development/mobile/androidenv/default.nix +++ b/pkgs/development/mobile/androidenv/default.nix @@ -2,6 +2,8 @@ , includeSources ? true }: +# TODO: use callPackage instead of import to avoid so many inherits + rec { platformTools = import ./platform-tools.nix { inherit buildPackages pkgs; @@ -46,11 +48,16 @@ rec { }; androidsdk = import ./androidsdk.nix { - inherit (pkgs) stdenv fetchurl unzip makeWrapper; - inherit (pkgs) zlib glxinfo freetype fontconfig glib gtk2 atk libGLU_combined file alsaLib jdk coreutils libpulseaudio dbus; - inherit (pkgs.xorg) libX11 libXext libXrender libxcb libXau libXdmcp libXtst xkeyboardconfig; + inherit (pkgs) stdenv fetchurl unzip makeWrapper zlib + glxinfo freetype fontconfig glib gtk2 atk + libGLU_combined file alsaLib jdk coreutils + libpulseaudio dbus fetchzip; + inherit (pkgs.xorg) libX11 libXext libXrender + libxcb libXau libXdmcp libXtst xkeyboardconfig; - inherit platformTools buildTools support supportRepository platforms sysimages addons sources includeSources; + inherit platformTools buildTools support + supportRepository platforms sysimages + addons sources includeSources; stdenv_32bit = pkgs_i686.stdenv; }; @@ -298,7 +305,8 @@ rec { }; buildGradleApp = import ./build-gradle-app.nix { - inherit (pkgs) stdenv jdk gnumake gawk file which gradle fetchurl buildEnv; + inherit (pkgs) stdenv jdk gnumake gawk file runCommand + which gradle fetchurl buildEnv; inherit androidsdk androidndk; }; } From 2a0c328712438e1c37d76b6bf4da36045c2228e1 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 21 Jun 2018 16:09:11 -0400 Subject: [PATCH 8/8] androidenv: add "androidsdk_latest" for latest sdk This is easier than having to remember which SDKs are supported, etc. Stuff based on this can become more future-proof. --- pkgs/development/mobile/androidenv/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/development/mobile/androidenv/default.nix b/pkgs/development/mobile/androidenv/default.nix index 65ec63201c83..d6d6b8a0cadc 100644 --- a/pkgs/development/mobile/androidenv/default.nix +++ b/pkgs/development/mobile/androidenv/default.nix @@ -222,6 +222,8 @@ rec { useInstantApps = true; }; + androidsdk_latest = androidsdk_8_0; + androidndk_10e = import ./androidndk.nix { inherit (buildPackages) p7zip makeWrapper;