androidenv: support 5 years of Android APIs with images; test 10 without

Cut down on the number of system images that need to be fetched by just
supporting packages from the last 5 years. Still test the last 10 years
of APIs without images.

authored by Morgan Jones and committed by Masum Reza 81ac8a76 c75818be

+19 -12
+3
doc/languages-frameworks/android.section.md
··· 88 88 have an aarch64-linux compile). 89 89 * `platformVersions` specifies which platform SDK versions should be included. 90 90 It defaults to including only the latest API level, though you can add more. 91 + * `numLatestPlatformVersions` specifies how many of the latest API levels to include, 92 + if you are using the default for `platformVersions`. It defaults to 1, though you can 93 + increase this to, for example, 5 to get the last 5 years of Android API packages. 91 94 * `minPlatformVersion` and `maxPlatformVersion` take priority over `platformVersions` 92 95 if both are provided. Note that `maxPlatformVersion` always defaults to the latest 93 96 Android SDK platform version, allowing you to specify `minPlatformVersion` to describe
+9 -1
pkgs/development/mobile/androidenv/compose-android-packages.nix
··· 82 82 emulatorVersion ? repo.latest.emulator, 83 83 minPlatformVersion ? null, 84 84 maxPlatformVersion ? coerceInt repo.latest.platforms, 85 + numLatestPlatformVersions ? 1, 85 86 platformVersions ? 86 87 if minPlatformVersion != null && maxPlatformVersion != null then 87 88 let ··· 92 93 lib.max minPlatformVersionInt maxPlatformVersionInt 93 94 ) 94 95 else 95 - map coerceInt [ repo.latest.platforms ], 96 + let 97 + minPlatformVersionInt = if minPlatformVersion == null then 1 else coerceInt minPlatformVersion; 98 + latestPlatformVersionInt = lib.max minPlatformVersionInt (coerceInt repo.latest.platforms); 99 + firstPlatformVersionInt = lib.max minPlatformVersionInt ( 100 + latestPlatformVersionInt - (lib.max 1 numLatestPlatformVersions) + 1 101 + ); 102 + in 103 + lib.range firstPlatformVersionInt latestPlatformVersionInt, 96 104 includeSources ? false, 97 105 includeSystemImages ? false, 98 106 systemImageTypes ? [
+2 -1
pkgs/development/mobile/androidenv/default.nix
··· 18 18 }; 19 19 20 20 androidPkgs = composeAndroidPackages { 21 - minPlatformVersion = 28; 21 + # Support roughly the last 5 years of Android packages and system images by default in nixpkgs. 22 + numLatestPlatformVersions = 5; 22 23 includeEmulator = "if-supported"; 23 24 includeSystemImages = "if-supported"; 24 25 includeNDK = "if-supported";
+5 -10
pkgs/development/mobile/androidenv/examples/shell.nix
··· 47 47 48 48 androidComposition = androidEnv.composeAndroidPackages { 49 49 includeSources = true; 50 - includeSystemImages = true; 50 + includeSystemImages = false; 51 51 includeEmulator = "if-supported"; 52 52 includeNDK = "if-supported"; 53 53 useGoogleAPIs = true; 54 54 55 - minPlatformVersion = 23; 55 + # Make sure everything from the last decade works since we are not using system images. 56 + numLatestPlatformVersions = 10; 56 57 57 58 # If you want to use a custom repo JSON: 58 59 # repoJson = ../repo.json; ··· 100 101 101 102 androidSdk = androidComposition.androidsdk; 102 103 platformTools = androidComposition.platform-tools; 104 + firstSdk = pkgs.lib.foldl' pkgs.lib.min 100 androidComposition.platformVersions; 103 105 latestSdk = pkgs.lib.foldl' pkgs.lib.max 0 androidComposition.platformVersions; 104 106 jdk = pkgs.jdk; 105 107 in ··· 171 173 "extras;google;gcm" 172 174 ) 173 175 174 - for x in $(seq 23 ${toString latestSdk}); do 176 + for x in $(seq ${toString firstSdk} ${toString latestSdk}); do 175 177 if [ $x -ne 34 ]; then 176 178 # FIXME couldn't find platforms;android-34, even though it's in the correct directory!! sdkmanager's bug?! 177 179 packages+=("platforms;android-$x") 178 180 fi 179 181 packages+=("sources;android-$x") 180 - if [ $x -ge 28 ]; then 181 - if [ $x -lt 34 ]; then 182 - packages+=("system-images;android-$x;google_apis_playstore;x86_64") 183 - else 184 - packages+=("system-images;android-$x;google_apis;x86_64") 185 - fi 186 - fi 187 182 done 188 183 189 184 ${pkgs.lib.optionalString includeAuto ''packages+=("extras;google;auto")''}