Merge pull request #227669 from hadilq/androidenv-put-a-much-nicer-error-message-that-includes-the-available-options
androidenv: raise a much nicer error message
This commit is contained in:
commit
a5ca94c021
|
@ -116,6 +116,7 @@ rec {
|
|||
deployAndroidPackages = callPackage ./deploy-androidpackages.nix {
|
||||
inherit stdenv lib mkLicenses;
|
||||
};
|
||||
|
||||
deployAndroidPackage = ({package, os ? null, buildInputs ? [], patchInstructions ? "", meta ? {}, ...}@args:
|
||||
let
|
||||
extraParams = removeAttrs args [ "package" "os" "buildInputs" "patchInstructions" ];
|
||||
|
@ -127,15 +128,25 @@ rec {
|
|||
} // extraParams
|
||||
));
|
||||
|
||||
# put a much nicer error message that includes the available options.
|
||||
check-version = packages: package: version:
|
||||
if lib.hasAttrByPath [ package version ] packages then
|
||||
packages.${package}.${version}
|
||||
else
|
||||
throw ''
|
||||
The version ${version} is missing in package ${package}.
|
||||
The only available versions are ${builtins.concatStringsSep ", " (builtins.attrNames packages.${package})}.
|
||||
'';
|
||||
|
||||
platform-tools = callPackage ./platform-tools.nix {
|
||||
inherit deployAndroidPackage;
|
||||
os = if stdenv.system == "aarch64-darwin" then "macosx" else os; # "macosx" is a universal binary here
|
||||
package = packages.platform-tools.${platformToolsVersion};
|
||||
package = check-version packages "platform-tools" platformToolsVersion;
|
||||
};
|
||||
|
||||
tools = callPackage ./tools.nix {
|
||||
inherit deployAndroidPackage os;
|
||||
package = packages.tools.${toolsVersion};
|
||||
package = check-version packages "tools" toolsVersion;
|
||||
|
||||
postInstall = ''
|
||||
${linkPlugin { name = "platform-tools"; plugin = platform-tools; }}
|
||||
|
@ -152,7 +163,7 @@ rec {
|
|||
build-tools = map (version:
|
||||
callPackage ./build-tools.nix {
|
||||
inherit deployAndroidPackage os;
|
||||
package = packages.build-tools.${version};
|
||||
package = check-version packages "build-tools" version;
|
||||
|
||||
postInstall = ''
|
||||
${linkPlugin { name = "tools"; plugin = tools; check = toolsVersion != null; }}
|
||||
|
@ -162,7 +173,7 @@ rec {
|
|||
|
||||
emulator = callPackage ./emulator.nix {
|
||||
inherit deployAndroidPackage os;
|
||||
package = packages.emulator.${emulatorVersion};
|
||||
package = check-version packages "emulator" emulatorVersion;
|
||||
|
||||
postInstall = ''
|
||||
${linkSystemImages { images = system-images; check = includeSystemImages; }}
|
||||
|
@ -172,14 +183,14 @@ rec {
|
|||
platforms = map (version:
|
||||
deployAndroidPackage {
|
||||
inherit os;
|
||||
package = packages.platforms.${version};
|
||||
package = check-version packages "platforms" version;
|
||||
}
|
||||
) platformVersions;
|
||||
|
||||
sources = map (version:
|
||||
deployAndroidPackage {
|
||||
inherit os;
|
||||
package = packages.sources.${version};
|
||||
package = check-version packages "sources" version;
|
||||
}
|
||||
) platformVersions;
|
||||
|
||||
|
@ -223,7 +234,7 @@ rec {
|
|||
cmake = map (version:
|
||||
callPackage ./cmake.nix {
|
||||
inherit deployAndroidPackage os;
|
||||
package = packages.cmake.${version};
|
||||
package = check-version packages "cmake" version;
|
||||
}
|
||||
) cmakeVersions;
|
||||
|
||||
|
@ -243,14 +254,14 @@ rec {
|
|||
google-apis = map (version:
|
||||
deployAndroidPackage {
|
||||
inherit os;
|
||||
package = addons.addons.${version}.google_apis;
|
||||
package = (check-version addons "addons" version).google_apis;
|
||||
}
|
||||
) (builtins.filter (platformVersion: platformVersion < "26") platformVersions); # API level 26 and higher include Google APIs by default
|
||||
|
||||
google-tv-addons = map (version:
|
||||
deployAndroidPackage {
|
||||
inherit os;
|
||||
package = addons.addons.${version}.google_tv_addon;
|
||||
package = (check-version addons "addons" version).google_tv_addon;
|
||||
}
|
||||
) platformVersions;
|
||||
|
||||
|
@ -320,7 +331,7 @@ rec {
|
|||
'' else callPackage ./cmdline-tools.nix {
|
||||
inherit deployAndroidPackage os cmdLineToolsVersion;
|
||||
|
||||
package = packages.cmdline-tools.${cmdLineToolsVersion};
|
||||
package = check-version packages "cmdline-tools" cmdLineToolsVersion;
|
||||
|
||||
postInstall = ''
|
||||
# Symlink all requested plugins
|
||||
|
|
Loading…
Reference in a new issue