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