diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-01-26 18:06:19 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2021-01-26 18:21:18 +0000 |
commit | 7ac6743433dd45ceaead2ca96f6356dc0d064ce6 (patch) | |
tree | b68ec89d7d2a8d2b6e6b1ff94ba26d6af4096350 /nixpkgs/pkgs/development/mobile/androidenv/examples/shell.nix | |
parent | c5c7451dbef37b51f52792d6395a670ef5183d27 (diff) | |
parent | 891f607d5301d6730cb1f9dcf3618bcb1ab7f10e (diff) | |
download | nixlib-7ac6743433dd45ceaead2ca96f6356dc0d064ce6.tar nixlib-7ac6743433dd45ceaead2ca96f6356dc0d064ce6.tar.gz nixlib-7ac6743433dd45ceaead2ca96f6356dc0d064ce6.tar.bz2 nixlib-7ac6743433dd45ceaead2ca96f6356dc0d064ce6.tar.lz nixlib-7ac6743433dd45ceaead2ca96f6356dc0d064ce6.tar.xz nixlib-7ac6743433dd45ceaead2ca96f6356dc0d064ce6.tar.zst nixlib-7ac6743433dd45ceaead2ca96f6356dc0d064ce6.zip |
Merge commit '891f607d5301d6730cb1f9dcf3618bcb1ab7f10e'
Diffstat (limited to 'nixpkgs/pkgs/development/mobile/androidenv/examples/shell.nix')
-rw-r--r-- | nixpkgs/pkgs/development/mobile/androidenv/examples/shell.nix | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/mobile/androidenv/examples/shell.nix b/nixpkgs/pkgs/development/mobile/androidenv/examples/shell.nix new file mode 100644 index 000000000000..aa5337c92988 --- /dev/null +++ b/nixpkgs/pkgs/development/mobile/androidenv/examples/shell.nix @@ -0,0 +1,145 @@ +{ + # If you copy this example out of nixpkgs, use these lines instead of the next. + # This example pins nixpkgs: https://nix.dev/tutorials/towards-reproducibility-pinning-nixpkgs.html + /*nixpkgsSource ? (builtins.fetchTarball { + name = "nixpkgs-20.09"; + url = https://github.com/NixOS/nixpkgs/archive/20.09.tar.gz; + sha256 = "1wg61h4gndm3vcprdcg7rc4s1v3jkm5xd7lw8r2f67w502y94gcy"; + }), + pkgs ? import nixpkgsSource {}, + pkgs_i686 ? import nixpkgsSource { system = "i686-linux"; },*/ + + # If you want to use the in-tree version of nixpkgs: + pkgs ? import ../../../../.. {}, + pkgs_i686 ? import ../../../../.. { system = "i686-linux"; }, + + config ? pkgs.config +}: + +# Copy this file to your Android project. +let + # Declaration of versions for everything. This is useful since these + # versions may be used in multiple places in this Nix expression. + android = { + versions = { + tools = "26.1.1"; + platformTools = "30.0.5"; + buildTools = "30.0.3"; + ndk = "22.0.7026061"; + + # or the LTS NDK: + # ndk = "21.3.6528147"; + cmake = "3.10.2"; + emulator = "30.3.4"; + }; + + platforms = ["23" "24" "25" "26" "27" "28" "29" "30"]; + abis = ["armeabi-v7a" "arm64-v8a"]; + extras = ["extras;google;gcm"]; + }; + + # If you copy this example out of nixpkgs, something like this will work: + /*androidEnvNixpkgs = fetchTarball { + name = "androidenv"; + url = https://github.com/NixOS/nixpkgs/archive/<fill me in from Git>.tar.gz; + sha256 = "<fill me in with nix-prefetch-url --unpack>"; + }; + + androidEnv = pkgs.callPackage "${androidEnvNixpkgs}/pkgs/development/mobile/androidenv" { + inherit config pkgs pkgs_i686; + licenseAccepted = true; + };*/ + + # Otherwise, just use the in-tree androidenv: + androidEnv = pkgs.callPackage ./.. { + inherit config pkgs pkgs_i686; + licenseAccepted = true; + }; + + androidComposition = androidEnv.composeAndroidPackages { + toolsVersion = android.versions.tools; + platformToolsVersion = android.versions.platformTools; + buildToolsVersions = [android.versions.buildTools]; + platformVersions = android.platforms; + abiVersions = android.abis; + + includeSources = true; + includeSystemImages = true; + includeEmulator = true; + emulatorVersion = android.versions.emulator; + + includeNDK = true; + ndkVersion = android.versions.ndk; + cmakeVersions = [android.versions.cmake]; + + useGoogleAPIs = true; + includeExtras = android.extras; + + # If you want to use a custom repo JSON: + # repoJson = ../repo.json; + + # If you want to use custom repo XMLs: + /*repoXmls = { + packages = [ ../xml/repository2-1.xml ]; + images = [ + ../xml/android-sys-img2-1.xml + ../xml/android-tv-sys-img2-1.xml + ../xml/android-wear-sys-img2-1.xml + ../xml/android-wear-cn-sys-img2-1.xml + ../xml/google_apis-sys-img2-1.xml + ../xml/google_apis_playstore-sys-img2-1.xml + ]; + addons = [ ../xml/addon2-1.xml ]; + };*/ + + # Accepting more licenses declaratively: + extraLicenses = [ + # Already accepted for you with the global accept_license = true or + # licenseAccepted = true on androidenv. + # "android-sdk-license" + + # These aren't, but are useful for more uncommon setups. + "android-sdk-preview-license" + "android-googletv-license" + "android-sdk-arm-dbt-license" + "google-gdk-license" + "intel-android-extra-license" + "intel-android-sysimage-license" + "mips-android-sysimage-license" + ]; + }; + + androidSdk = androidComposition.androidsdk; + platformTools = androidComposition.platform-tools; + jdk = pkgs.jdk; +in +pkgs.mkShell rec { + name = "androidenv-demo"; + buildInputs = [ androidSdk platformTools jdk pkgs.android-studio ]; + + LANG = "C.UTF-8"; + LC_ALL = "C.UTF-8"; + JAVA_HOME = jdk.home; + + # Note: ANDROID_HOME is deprecated. Use ANDROID_SDK_ROOT. + ANDROID_SDK_ROOT = "${androidSdk}/libexec/android-sdk"; + ANDROID_NDK_ROOT = "${ANDROID_SDK_ROOT}/ndk-bundle"; + + # Ensures that we don't have to use a FHS env by using the nix store's aapt2. + GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${ANDROID_SDK_ROOT}/build-tools/${android.versions.buildTools}/aapt2"; + + shellHook = '' + # Add cmake to the path. + cmake_root="$(echo "$ANDROID_SDK_ROOT/cmake/${android.versions.cmake}".*/)" + export PATH="$cmake_root/bin:$PATH" + + # Write out local.properties for Android Studio. + cat <<EOF > local.properties +# This file was automatically generated by nix-shell. +sdk.dir=$ANDROID_SDK_ROOT +ndk.dir=$ANDROID_NDK_ROOT +cmake.dir=$cmake_root +EOF + ''; +} + |